diff options
873 files changed, 8184 insertions, 4883 deletions
| @@ -88,6 +88,7 @@ Kay Sievers <kay.sievers@vrfy.org> | |||
| 88 | Kenneth W Chen <kenneth.w.chen@intel.com> | 88 | Kenneth W Chen <kenneth.w.chen@intel.com> |
| 89 | Konstantin Khlebnikov <koct9i@gmail.com> <k.khlebnikov@samsung.com> | 89 | Konstantin Khlebnikov <koct9i@gmail.com> <k.khlebnikov@samsung.com> |
| 90 | Koushik <raghavendra.koushik@neterion.com> | 90 | Koushik <raghavendra.koushik@neterion.com> |
| 91 | Krzysztof Kozlowski <krzk@kernel.org> <k.kozlowski@samsung.com> | ||
| 91 | Krzysztof Kozlowski <krzk@kernel.org> <k.kozlowski.k@gmail.com> | 92 | Krzysztof Kozlowski <krzk@kernel.org> <k.kozlowski.k@gmail.com> |
| 92 | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 93 | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| 93 | Leonid I Ananiev <leonid.i.ananiev@intel.com> | 94 | Leonid I Ananiev <leonid.i.ananiev@intel.com> |
| @@ -158,6 +159,8 @@ Valdis Kletnieks <Valdis.Kletnieks@vt.edu> | |||
| 158 | Viresh Kumar <vireshk@kernel.org> <viresh.kumar@st.com> | 159 | Viresh Kumar <vireshk@kernel.org> <viresh.kumar@st.com> |
| 159 | Viresh Kumar <vireshk@kernel.org> <viresh.linux@gmail.com> | 160 | Viresh Kumar <vireshk@kernel.org> <viresh.linux@gmail.com> |
| 160 | Viresh Kumar <vireshk@kernel.org> <viresh.kumar2@arm.com> | 161 | Viresh Kumar <vireshk@kernel.org> <viresh.kumar2@arm.com> |
| 162 | Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@virtuozzo.com> | ||
| 163 | Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@parallels.com> | ||
| 161 | Takashi YOSHII <takashi.yoshii.zj@renesas.com> | 164 | Takashi YOSHII <takashi.yoshii.zj@renesas.com> |
| 162 | Yusuke Goda <goda.yusuke@renesas.com> | 165 | Yusuke Goda <goda.yusuke@renesas.com> |
| 163 | Gustavo Padovan <gustavo@las.ic.unicamp.br> | 166 | Gustavo Padovan <gustavo@las.ic.unicamp.br> |
diff --git a/Documentation/ABI/stable/sysfs-devices b/Documentation/ABI/stable/sysfs-devices index 43f78b88da28..df449d79b563 100644 --- a/Documentation/ABI/stable/sysfs-devices +++ b/Documentation/ABI/stable/sysfs-devices | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | # Note: This documents additional properties of any device beyond what | 1 | # Note: This documents additional properties of any device beyond what |
| 2 | # is documented in Documentation/sysfs-rules.txt | 2 | # is documented in Documentation/sysfs-rules.txt |
| 3 | 3 | ||
| 4 | What: /sys/devices/*/of_path | 4 | What: /sys/devices/*/of_node |
| 5 | Date: February 2015 | 5 | Date: February 2015 |
| 6 | Contact: Device Tree mailing list <devicetree@vger.kernel.org> | 6 | Contact: Device Tree mailing list <devicetree@vger.kernel.org> |
| 7 | Description: | 7 | Description: |
diff --git a/Documentation/PCI/MSI-HOWTO.txt b/Documentation/PCI/MSI-HOWTO.txt index c55df2911136..cd9c9f6a7cd9 100644 --- a/Documentation/PCI/MSI-HOWTO.txt +++ b/Documentation/PCI/MSI-HOWTO.txt | |||
| @@ -94,14 +94,11 @@ has a requirements for a minimum number of vectors the driver can pass a | |||
| 94 | min_vecs argument set to this limit, and the PCI core will return -ENOSPC | 94 | min_vecs argument set to this limit, and the PCI core will return -ENOSPC |
| 95 | if it can't meet the minimum number of vectors. | 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 | 97 | The flags argument is used to specify which type of interrupt can be used |
| 98 | PCI_IRQ_NOMSI and PCI_IRQ_NOMSIX flag in case a device claims to support | 98 | by the device and the driver (PCI_IRQ_LEGACY, PCI_IRQ_MSI, PCI_IRQ_MSIX). |
| 99 | MSI or MSI-X, but the support is broken, or to pass PCI_IRQ_NOLEGACY in | 99 | A convenient short-hand (PCI_IRQ_ALL_TYPES) is also available to ask for |
| 100 | case the device does not support legacy interrupt lines. | 100 | any possible kind of interrupt. If the PCI_IRQ_AFFINITY flag is set, |
| 101 | 101 | pci_alloc_irq_vectors() will spread the interrupts around the available CPUs. | |
| 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. | ||
| 105 | 102 | ||
| 106 | To get the Linux IRQ numbers passed to request_irq() and free_irq() and the | 103 | To get the Linux IRQ numbers passed to request_irq() and free_irq() and the |
| 107 | vectors, use the following function: | 104 | vectors, use the following function: |
| @@ -131,7 +128,7 @@ larger than the number supported by the device it will automatically be | |||
| 131 | capped to the supported limit, so there is no need to query the number of | 128 | capped to the supported limit, so there is no need to query the number of |
| 132 | vectors supported beforehand: | 129 | vectors supported beforehand: |
| 133 | 130 | ||
| 134 | nvec = pci_alloc_irq_vectors(pdev, 1, nvec, 0); | 131 | nvec = pci_alloc_irq_vectors(pdev, 1, nvec, PCI_IRQ_ALL_TYPES) |
| 135 | if (nvec < 0) | 132 | if (nvec < 0) |
| 136 | goto out_err; | 133 | goto out_err; |
| 137 | 134 | ||
| @@ -140,7 +137,7 @@ interrupts it can request a particular number of interrupts by passing that | |||
| 140 | number to pci_alloc_irq_vectors() function as both 'min_vecs' and | 137 | number to pci_alloc_irq_vectors() function as both 'min_vecs' and |
| 141 | 'max_vecs' parameters: | 138 | 'max_vecs' parameters: |
| 142 | 139 | ||
| 143 | ret = pci_alloc_irq_vectors(pdev, nvec, nvec, 0); | 140 | ret = pci_alloc_irq_vectors(pdev, nvec, nvec, PCI_IRQ_ALL_TYPES); |
| 144 | if (ret < 0) | 141 | if (ret < 0) |
| 145 | goto out_err; | 142 | goto out_err; |
| 146 | 143 | ||
| @@ -148,15 +145,14 @@ The most notorious example of the request type described above is enabling | |||
| 148 | the single MSI mode for a device. It could be done by passing two 1s as | 145 | the single MSI mode for a device. It could be done by passing two 1s as |
| 149 | 'min_vecs' and 'max_vecs': | 146 | 'min_vecs' and 'max_vecs': |
| 150 | 147 | ||
| 151 | ret = pci_alloc_irq_vectors(pdev, 1, 1, 0); | 148 | ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES); |
| 152 | if (ret < 0) | 149 | if (ret < 0) |
| 153 | goto out_err; | 150 | goto out_err; |
| 154 | 151 | ||
| 155 | Some devices might not support using legacy line interrupts, in which case | 152 | Some devices might not support using legacy line interrupts, in which case |
| 156 | the PCI_IRQ_NOLEGACY flag can be used to fail the request if the platform | 153 | the driver can specify that only MSI or MSI-X is acceptable: |
| 157 | can't provide MSI or MSI-X interrupts: | ||
| 158 | 154 | ||
| 159 | nvec = pci_alloc_irq_vectors(pdev, 1, nvec, PCI_IRQ_NOLEGACY); | 155 | nvec = pci_alloc_irq_vectors(pdev, 1, nvec, PCI_IRQ_MSI | PCI_IRQ_MSIX); |
| 160 | if (nvec < 0) | 156 | if (nvec < 0) |
| 161 | goto out_err; | 157 | goto out_err; |
| 162 | 158 | ||
diff --git a/Documentation/PCI/pci.txt b/Documentation/PCI/pci.txt index 123881f62219..77f49dc5be23 100644 --- a/Documentation/PCI/pci.txt +++ b/Documentation/PCI/pci.txt | |||
| @@ -124,7 +124,6 @@ initialization with a pointer to a structure describing the driver | |||
| 124 | 124 | ||
| 125 | The ID table is an array of struct pci_device_id entries ending with an | 125 | The ID table is an array of struct pci_device_id entries ending with an |
| 126 | all-zero entry. Definitions with static const are generally preferred. | 126 | all-zero entry. Definitions with static const are generally preferred. |
| 127 | Use of the deprecated macro DEFINE_PCI_DEVICE_TABLE should be avoided. | ||
| 128 | 127 | ||
| 129 | Each entry consists of: | 128 | Each entry consists of: |
| 130 | 129 | ||
diff --git a/Documentation/arm/CCN.txt b/Documentation/arm/CCN.txt index ffca443a19b4..15cdb7bc57c3 100644 --- a/Documentation/arm/CCN.txt +++ b/Documentation/arm/CCN.txt | |||
| @@ -18,13 +18,17 @@ and config2 fields of the perf_event_attr structure. The "events" | |||
| 18 | directory provides configuration templates for all documented | 18 | directory provides configuration templates for all documented |
| 19 | events, that can be used with perf tool. For example "xp_valid_flit" | 19 | events, that can be used with perf tool. For example "xp_valid_flit" |
| 20 | is an equivalent of "type=0x8,event=0x4". Other parameters must be | 20 | is an equivalent of "type=0x8,event=0x4". Other parameters must be |
| 21 | explicitly specified. For events originating from device, "node" | 21 | explicitly specified. |
| 22 | defines its index. All crosspoint events require "xp" (index), | ||
| 23 | "port" (device port number) and "vc" (virtual channel ID) and | ||
| 24 | "dir" (direction). Watchpoints (special "event" value 0xfe) also | ||
| 25 | require comparator values ("cmp_l" and "cmp_h") and "mask", being | ||
| 26 | index of the comparator mask. | ||
| 27 | 22 | ||
| 23 | For events originating from device, "node" defines its index. | ||
| 24 | |||
| 25 | Crosspoint PMU events require "xp" (index), "bus" (bus number) | ||
| 26 | and "vc" (virtual channel ID). | ||
| 27 | |||
| 28 | Crosspoint watchpoint-based events (special "event" value 0xfe) | ||
| 29 | require "xp" and "vc" as as above plus "port" (device port index), | ||
| 30 | "dir" (transmit/receive direction), comparator values ("cmp_l" | ||
| 31 | and "cmp_h") and "mask", being index of the comparator mask. | ||
| 28 | Masks are defined separately from the event description | 32 | Masks are defined separately from the event description |
| 29 | (due to limited number of the config values) in the "cmp_mask" | 33 | (due to limited number of the config values) in the "cmp_mask" |
| 30 | directory, with first 8 configurable by user and additional | 34 | directory, with first 8 configurable by user and additional |
diff --git a/Documentation/arm64/silicon-errata.txt b/Documentation/arm64/silicon-errata.txt index 4da60b463995..ccc60324e738 100644 --- a/Documentation/arm64/silicon-errata.txt +++ b/Documentation/arm64/silicon-errata.txt | |||
| @@ -53,6 +53,7 @@ stable kernels. | |||
| 53 | | ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 | | 53 | | ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 | |
| 54 | | ARM | Cortex-A57 | #852523 | N/A | | 54 | | ARM | Cortex-A57 | #852523 | N/A | |
| 55 | | ARM | Cortex-A57 | #834220 | ARM64_ERRATUM_834220 | | 55 | | ARM | Cortex-A57 | #834220 | ARM64_ERRATUM_834220 | |
| 56 | | ARM | Cortex-A72 | #853709 | N/A | | ||
| 56 | | ARM | MMU-500 | #841119,#826419 | N/A | | 57 | | ARM | MMU-500 | #841119,#826419 | N/A | |
| 57 | | | | | | | 58 | | | | | | |
| 58 | | Cavium | ThunderX ITS | #22375, #24313 | CAVIUM_ERRATUM_22375 | | 59 | | Cavium | ThunderX ITS | #22375, #24313 | CAVIUM_ERRATUM_22375 | |
diff --git a/Documentation/cpu-freq/cpufreq-stats.txt b/Documentation/cpu-freq/cpufreq-stats.txt index fc647492e940..8d9773f23550 100644 --- a/Documentation/cpu-freq/cpufreq-stats.txt +++ b/Documentation/cpu-freq/cpufreq-stats.txt | |||
| @@ -103,7 +103,7 @@ Config Main Menu | |||
| 103 | Power management options (ACPI, APM) ---> | 103 | Power management options (ACPI, APM) ---> |
| 104 | CPU Frequency scaling ---> | 104 | CPU Frequency scaling ---> |
| 105 | [*] CPU Frequency scaling | 105 | [*] CPU Frequency scaling |
| 106 | <*> CPU frequency translation statistics | 106 | [*] CPU frequency translation statistics |
| 107 | [*] CPU frequency translation statistics details | 107 | [*] CPU frequency translation statistics details |
| 108 | 108 | ||
| 109 | 109 | ||
diff --git a/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt b/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt index bf99e2f24788..205593f56fe7 100644 --- a/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt +++ b/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt | |||
| @@ -16,6 +16,11 @@ Required properties: | |||
| 16 | - vref-supply: The regulator supply ADC reference voltage. | 16 | - vref-supply: The regulator supply ADC reference voltage. |
| 17 | - #io-channel-cells: Should be 1, see ../iio-bindings.txt | 17 | - #io-channel-cells: Should be 1, see ../iio-bindings.txt |
| 18 | 18 | ||
| 19 | Optional properties: | ||
| 20 | - resets: Must contain an entry for each entry in reset-names if need support | ||
| 21 | this option. See ../reset/reset.txt for details. | ||
| 22 | - reset-names: Must include the name "saradc-apb". | ||
| 23 | |||
| 19 | Example: | 24 | Example: |
| 20 | saradc: saradc@2006c000 { | 25 | saradc: saradc@2006c000 { |
| 21 | compatible = "rockchip,saradc"; | 26 | compatible = "rockchip,saradc"; |
| @@ -23,6 +28,8 @@ Example: | |||
| 23 | interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>; | 28 | interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>; |
| 24 | clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; | 29 | clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; |
| 25 | clock-names = "saradc", "apb_pclk"; | 30 | clock-names = "saradc", "apb_pclk"; |
| 31 | resets = <&cru SRST_SARADC>; | ||
| 32 | reset-names = "saradc-apb"; | ||
| 26 | #io-channel-cells = <1>; | 33 | #io-channel-cells = <1>; |
| 27 | vref-supply = <&vcc18>; | 34 | vref-supply = <&vcc18>; |
| 28 | }; | 35 | }; |
diff --git a/Documentation/devicetree/bindings/serial/8250.txt b/Documentation/devicetree/bindings/serial/8250.txt index f5561ac7e17e..936ab5b87324 100644 --- a/Documentation/devicetree/bindings/serial/8250.txt +++ b/Documentation/devicetree/bindings/serial/8250.txt | |||
| @@ -42,9 +42,6 @@ Optional properties: | |||
| 42 | - auto-flow-control: one way to enable automatic flow control support. The | 42 | - auto-flow-control: one way to enable automatic flow control support. The |
| 43 | driver is allowed to detect support for the capability even without this | 43 | driver is allowed to detect support for the capability even without this |
| 44 | property. | 44 | property. |
| 45 | - {rts,cts,dtr,dsr,rng,dcd}-gpios: specify a GPIO for RTS/CTS/DTR/DSR/RI/DCD | ||
| 46 | line respectively. It will use specified GPIO instead of the peripheral | ||
| 47 | function pin for the UART feature. If unsure, don't specify this property. | ||
| 48 | 45 | ||
| 49 | Note: | 46 | Note: |
| 50 | * fsl,ns16550: | 47 | * fsl,ns16550: |
| @@ -66,19 +63,3 @@ Example: | |||
| 66 | interrupts = <10>; | 63 | interrupts = <10>; |
| 67 | reg-shift = <2>; | 64 | reg-shift = <2>; |
| 68 | }; | 65 | }; |
| 69 | |||
| 70 | Example for OMAP UART using GPIO-based modem control signals: | ||
| 71 | |||
| 72 | uart4: serial@49042000 { | ||
| 73 | compatible = "ti,omap3-uart"; | ||
| 74 | reg = <0x49042000 0x400>; | ||
| 75 | interrupts = <80>; | ||
| 76 | ti,hwmods = "uart4"; | ||
| 77 | clock-frequency = <48000000>; | ||
| 78 | cts-gpios = <&gpio3 5 GPIO_ACTIVE_LOW>; | ||
| 79 | rts-gpios = <&gpio3 6 GPIO_ACTIVE_LOW>; | ||
| 80 | dtr-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>; | ||
| 81 | dsr-gpios = <&gpio1 13 GPIO_ACTIVE_LOW>; | ||
| 82 | dcd-gpios = <&gpio1 14 GPIO_ACTIVE_LOW>; | ||
| 83 | rng-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>; | ||
| 84 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/omap-mcpdm.txt b/Documentation/devicetree/bindings/sound/omap-mcpdm.txt index 6f6c2f8e908d..0741dff048dd 100644 --- a/Documentation/devicetree/bindings/sound/omap-mcpdm.txt +++ b/Documentation/devicetree/bindings/sound/omap-mcpdm.txt | |||
| @@ -8,8 +8,6 @@ Required properties: | |||
| 8 | - interrupts: Interrupt number for McPDM | 8 | - interrupts: Interrupt number for McPDM |
| 9 | - interrupt-parent: The parent interrupt controller | 9 | - interrupt-parent: The parent interrupt controller |
| 10 | - ti,hwmods: Name of the hwmod associated to the McPDM | 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 | Example: | 12 | Example: |
| 15 | 13 | ||
| @@ -21,11 +19,3 @@ mcpdm: mcpdm@40132000 { | |||
| 21 | interrupt-parent = <&gic>; | 19 | interrupt-parent = <&gic>; |
| 22 | ti,hwmods = "mcpdm"; | 20 | ti,hwmods = "mcpdm"; |
| 23 | }; | 21 | }; |
| 24 | |||
| 25 | In board DTS file the pdmclk needs to be added: | ||
| 26 | |||
| 27 | &mcpdm { | ||
| 28 | clocks = <&twl6040>; | ||
| 29 | clock-names = "pdmclk"; | ||
| 30 | status = "okay"; | ||
| 31 | }; | ||
diff --git a/Documentation/devicetree/bindings/thermal/thermal.txt b/Documentation/devicetree/bindings/thermal/thermal.txt index 41b817f7b670..88b6ea1ad290 100644 --- a/Documentation/devicetree/bindings/thermal/thermal.txt +++ b/Documentation/devicetree/bindings/thermal/thermal.txt | |||
| @@ -62,7 +62,7 @@ For more examples of cooling devices, refer to the example sections below. | |||
| 62 | Required properties: | 62 | Required properties: |
| 63 | - #cooling-cells: Used to provide cooling device specific information | 63 | - #cooling-cells: Used to provide cooling device specific information |
| 64 | Type: unsigned while referring to it. Must be at least 2, in order | 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 | in the reference. The first cell is the minimum | 66 | in the reference. The first cell is the minimum |
| 67 | cooling state requested and the second cell is | 67 | cooling state requested and the second cell is |
| 68 | the maximum cooling state requested in the reference. | 68 | the maximum cooling state requested in the reference. |
| @@ -119,7 +119,7 @@ Required properties: | |||
| 119 | Optional property: | 119 | Optional property: |
| 120 | - contribution: The cooling contribution to the thermal zone of the | 120 | - contribution: The cooling contribution to the thermal zone of the |
| 121 | Type: unsigned referred cooling device at the referred trip point. | 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 | of all cooling contributions within a thermal zone. | 123 | of all cooling contributions within a thermal zone. |
| 124 | 124 | ||
| 125 | Note: Using the THERMAL_NO_LIMIT (-1UL) constant in the cooling-device phandle | 125 | Note: Using the THERMAL_NO_LIMIT (-1UL) constant in the cooling-device phandle |
| @@ -145,7 +145,7 @@ Required properties: | |||
| 145 | Size: one cell | 145 | Size: one cell |
| 146 | 146 | ||
| 147 | - thermal-sensors: A list of thermal sensor phandles and sensor specifier | 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 | phandles + sensor | 149 | phandles + sensor |
| 150 | specifier | 150 | specifier |
| 151 | 151 | ||
| @@ -473,7 +473,7 @@ thermal-zones { | |||
| 473 | <&adc>; /* pcb north */ | 473 | <&adc>; /* pcb north */ |
| 474 | 474 | ||
| 475 | /* hotspot = 100 * bandgap - 120 * adc + 484 */ | 475 | /* hotspot = 100 * bandgap - 120 * adc + 484 */ |
| 476 | coefficients = <100 -120 484>; | 476 | coefficients = <100 -120 484>; |
| 477 | 477 | ||
| 478 | trips { | 478 | trips { |
| 479 | ... | 479 | ... |
| @@ -502,7 +502,7 @@ from the ADC sensor. The binding would be then: | |||
| 502 | thermal-sensors = <&adc>; | 502 | thermal-sensors = <&adc>; |
| 503 | 503 | ||
| 504 | /* hotspot = 1 * adc + 6000 */ | 504 | /* hotspot = 1 * adc + 6000 */ |
| 505 | coefficients = <1 6000>; | 505 | coefficients = <1 6000>; |
| 506 | 506 | ||
| 507 | (d) - Board thermal | 507 | (d) - Board thermal |
| 508 | 508 | ||
diff --git a/Documentation/filesystems/overlayfs.txt b/Documentation/filesystems/overlayfs.txt index d6259c786316..bcbf9710e4af 100644 --- a/Documentation/filesystems/overlayfs.txt +++ b/Documentation/filesystems/overlayfs.txt | |||
| @@ -183,12 +183,10 @@ The copy_up operation essentially creates a new, identical file and | |||
| 183 | moves it over to the old name. The new file may be on a different | 183 | moves it over to the old name. The new file may be on a different |
| 184 | filesystem, so both st_dev and st_ino of the file may change. | 184 | filesystem, so both st_dev and st_ino of the file may change. |
| 185 | 185 | ||
| 186 | Any open files referring to this inode will access the old data and | 186 | Any open files referring to this inode will access the old data. |
| 187 | metadata. Similarly any file locks obtained before copy_up will not | ||
| 188 | apply to the copied up file. | ||
| 189 | 187 | ||
| 190 | On a file opened with O_RDONLY fchmod(2), fchown(2), futimesat(2) and | 188 | Any file locks (and leases) obtained before copy_up will not apply |
| 191 | fsetxattr(2) will fail with EROFS. | 189 | to the copied up file. |
| 192 | 190 | ||
| 193 | If a file with multiple hard links is copied up, then this will | 191 | If a file with multiple hard links is copied up, then this will |
| 194 | "break" the link. Changes will not be propagated to other names | 192 | "break" the link. Changes will not be propagated to other names |
diff --git a/Documentation/i2c/slave-interface b/Documentation/i2c/slave-interface index 80807adb8ded..7e2a228f21bc 100644 --- a/Documentation/i2c/slave-interface +++ b/Documentation/i2c/slave-interface | |||
| @@ -145,6 +145,11 @@ If you want to add slave support to the bus driver: | |||
| 145 | 145 | ||
| 146 | * Catch the slave interrupts and send appropriate i2c_slave_events to the backend. | 146 | * Catch the slave interrupts and send appropriate i2c_slave_events to the backend. |
| 147 | 147 | ||
| 148 | Note that most hardware supports being master _and_ slave on the same bus. So, | ||
| 149 | if you extend a bus driver, please make sure that the driver supports that as | ||
| 150 | well. In almost all cases, slave support does not need to disable the master | ||
| 151 | functionality. | ||
| 152 | |||
| 148 | Check the i2c-rcar driver as an example. | 153 | Check the i2c-rcar driver as an example. |
| 149 | 154 | ||
| 150 | 155 | ||
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 46c030a49186..a4f4d693e2c1 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
| @@ -3032,6 +3032,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
| 3032 | PAGE_SIZE is used as alignment. | 3032 | PAGE_SIZE is used as alignment. |
| 3033 | PCI-PCI bridge can be specified, if resource | 3033 | PCI-PCI bridge can be specified, if resource |
| 3034 | windows need to be expanded. | 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 | ecrc= Enable/disable PCIe ECRC (transaction layer | 3039 | ecrc= Enable/disable PCIe ECRC (transaction layer |
| 3036 | end-to-end CRC checking). | 3040 | end-to-end CRC checking). |
| 3037 | bios: Use BIOS/firmware settings. This is the | 3041 | bios: Use BIOS/firmware settings. This is the |
diff --git a/Documentation/networking/dsa/dsa.txt b/Documentation/networking/dsa/dsa.txt index 9d05ed7f7da5..f20c884c048a 100644 --- a/Documentation/networking/dsa/dsa.txt +++ b/Documentation/networking/dsa/dsa.txt | |||
| @@ -587,26 +587,6 @@ of DSA, would be the its port-based VLAN, used by the associated bridge device. | |||
| 587 | TODO | 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 | Making SWITCHDEV and DSA converge towards an unified codebase | 590 | Making SWITCHDEV and DSA converge towards an unified codebase |
| 611 | ------------------------------------------------------------- | 591 | ------------------------------------------------------------- |
| 612 | 592 | ||
diff --git a/Documentation/rapidio/mport_cdev.txt b/Documentation/rapidio/mport_cdev.txt index 6e491a662461..a53f786ee2e9 100644 --- a/Documentation/rapidio/mport_cdev.txt +++ b/Documentation/rapidio/mport_cdev.txt | |||
| @@ -80,6 +80,10 @@ functionality of their platform when planning to use this driver: | |||
| 80 | 80 | ||
| 81 | III. Module parameters | 81 | III. Module parameters |
| 82 | 82 | ||
| 83 | - 'dma_timeout' - DMA transfer completion timeout (in msec, default value 3000). | ||
| 84 | This parameter set a maximum completion wait time for SYNC mode DMA | ||
| 85 | transfer requests and for RIO_WAIT_FOR_ASYNC ioctl requests. | ||
| 86 | |||
| 83 | - 'dbg_level' - This parameter allows to control amount of debug information | 87 | - 'dbg_level' - This parameter allows to control amount of debug information |
| 84 | generated by this device driver. This parameter is formed by set of | 88 | generated by this device driver. This parameter is formed by set of |
| 85 | bit masks that correspond to the specific functional blocks. | 89 | bit masks that correspond to the specific functional blocks. |
diff --git a/MAINTAINERS b/MAINTAINERS index 0bbe4b105c34..644ff65d336d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -798,6 +798,7 @@ M: Laura Abbott <labbott@redhat.com> | |||
| 798 | M: Sumit Semwal <sumit.semwal@linaro.org> | 798 | M: Sumit Semwal <sumit.semwal@linaro.org> |
| 799 | L: devel@driverdev.osuosl.org | 799 | L: devel@driverdev.osuosl.org |
| 800 | S: Supported | 800 | S: Supported |
| 801 | F: Documentation/devicetree/bindings/staging/ion/ | ||
| 801 | F: drivers/staging/android/ion | 802 | F: drivers/staging/android/ion |
| 802 | F: drivers/staging/android/uapi/ion.h | 803 | F: drivers/staging/android/uapi/ion.h |
| 803 | F: drivers/staging/android/uapi/ion_test.h | 804 | F: drivers/staging/android/uapi/ion_test.h |
| @@ -881,6 +882,15 @@ S: Supported | |||
| 881 | F: drivers/gpu/drm/arc/ | 882 | F: drivers/gpu/drm/arc/ |
| 882 | F: Documentation/devicetree/bindings/display/snps,arcpgu.txt | 883 | F: Documentation/devicetree/bindings/display/snps,arcpgu.txt |
| 883 | 884 | ||
| 885 | ARM ARCHITECTED TIMER DRIVER | ||
| 886 | M: Mark Rutland <mark.rutland@arm.com> | ||
| 887 | M: Marc Zyngier <marc.zyngier@arm.com> | ||
| 888 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) | ||
| 889 | S: Maintained | ||
| 890 | F: arch/arm/include/asm/arch_timer.h | ||
| 891 | F: arch/arm64/include/asm/arch_timer.h | ||
| 892 | F: drivers/clocksource/arm_arch_timer.c | ||
| 893 | |||
| 884 | ARM HDLCD DRM DRIVER | 894 | ARM HDLCD DRM DRIVER |
| 885 | M: Liviu Dudau <liviu.dudau@arm.com> | 895 | M: Liviu Dudau <liviu.dudau@arm.com> |
| 886 | S: Supported | 896 | S: Supported |
| @@ -1614,7 +1624,8 @@ N: rockchip | |||
| 1614 | 1624 | ||
| 1615 | ARM/SAMSUNG EXYNOS ARM ARCHITECTURES | 1625 | ARM/SAMSUNG EXYNOS ARM ARCHITECTURES |
| 1616 | M: Kukjin Kim <kgene@kernel.org> | 1626 | M: Kukjin Kim <kgene@kernel.org> |
| 1617 | M: Krzysztof Kozlowski <k.kozlowski@samsung.com> | 1627 | M: Krzysztof Kozlowski <krzk@kernel.org> |
| 1628 | R: Javier Martinez Canillas <javier@osg.samsung.com> | ||
| 1618 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) | 1629 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) |
| 1619 | L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) | 1630 | L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) |
| 1620 | S: Maintained | 1631 | S: Maintained |
| @@ -1634,7 +1645,6 @@ F: drivers/*/*s3c64xx* | |||
| 1634 | F: drivers/*/*s5pv210* | 1645 | F: drivers/*/*s5pv210* |
| 1635 | F: drivers/memory/samsung/* | 1646 | F: drivers/memory/samsung/* |
| 1636 | F: drivers/soc/samsung/* | 1647 | F: drivers/soc/samsung/* |
| 1637 | F: drivers/spi/spi-s3c* | ||
| 1638 | F: Documentation/arm/Samsung/ | 1648 | F: Documentation/arm/Samsung/ |
| 1639 | F: Documentation/devicetree/bindings/arm/samsung/ | 1649 | F: Documentation/devicetree/bindings/arm/samsung/ |
| 1640 | F: Documentation/devicetree/bindings/sram/samsung-sram.txt | 1650 | F: Documentation/devicetree/bindings/sram/samsung-sram.txt |
| @@ -1822,6 +1832,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-stericsson.git | |||
| 1822 | ARM/UNIPHIER ARCHITECTURE | 1832 | ARM/UNIPHIER ARCHITECTURE |
| 1823 | M: Masahiro Yamada <yamada.masahiro@socionext.com> | 1833 | M: Masahiro Yamada <yamada.masahiro@socionext.com> |
| 1824 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) | 1834 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) |
| 1835 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-uniphier.git | ||
| 1825 | S: Maintained | 1836 | S: Maintained |
| 1826 | F: arch/arm/boot/dts/uniphier* | 1837 | F: arch/arm/boot/dts/uniphier* |
| 1827 | F: arch/arm/include/asm/hardware/cache-uniphier.h | 1838 | F: arch/arm/include/asm/hardware/cache-uniphier.h |
| @@ -2475,7 +2486,7 @@ F: include/net/bluetooth/ | |||
| 2475 | BONDING DRIVER | 2486 | BONDING DRIVER |
| 2476 | M: Jay Vosburgh <j.vosburgh@gmail.com> | 2487 | M: Jay Vosburgh <j.vosburgh@gmail.com> |
| 2477 | M: Veaceslav Falico <vfalico@gmail.com> | 2488 | M: Veaceslav Falico <vfalico@gmail.com> |
| 2478 | M: Andy Gospodarek <gospo@cumulusnetworks.com> | 2489 | M: Andy Gospodarek <andy@greyhouse.net> |
| 2479 | L: netdev@vger.kernel.org | 2490 | L: netdev@vger.kernel.org |
| 2480 | W: http://sourceforge.net/projects/bonding/ | 2491 | W: http://sourceforge.net/projects/bonding/ |
| 2481 | S: Supported | 2492 | S: Supported |
| @@ -3238,7 +3249,7 @@ F: kernel/cpuset.c | |||
| 3238 | CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG) | 3249 | CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG) |
| 3239 | M: Johannes Weiner <hannes@cmpxchg.org> | 3250 | M: Johannes Weiner <hannes@cmpxchg.org> |
| 3240 | M: Michal Hocko <mhocko@kernel.org> | 3251 | M: Michal Hocko <mhocko@kernel.org> |
| 3241 | M: Vladimir Davydov <vdavydov@virtuozzo.com> | 3252 | M: Vladimir Davydov <vdavydov.dev@gmail.com> |
| 3242 | L: cgroups@vger.kernel.org | 3253 | L: cgroups@vger.kernel.org |
| 3243 | L: linux-mm@kvack.org | 3254 | L: linux-mm@kvack.org |
| 3244 | S: Maintained | 3255 | S: Maintained |
| @@ -3259,7 +3270,7 @@ S: Maintained | |||
| 3259 | F: drivers/net/wan/cosa* | 3270 | F: drivers/net/wan/cosa* |
| 3260 | 3271 | ||
| 3261 | CPMAC ETHERNET DRIVER | 3272 | CPMAC ETHERNET DRIVER |
| 3262 | M: Florian Fainelli <florian@openwrt.org> | 3273 | M: Florian Fainelli <f.fainelli@gmail.com> |
| 3263 | L: netdev@vger.kernel.org | 3274 | L: netdev@vger.kernel.org |
| 3264 | S: Maintained | 3275 | S: Maintained |
| 3265 | F: drivers/net/ethernet/ti/cpmac.c | 3276 | F: drivers/net/ethernet/ti/cpmac.c |
| @@ -7455,7 +7466,8 @@ F: Documentation/devicetree/bindings/sound/max9860.txt | |||
| 7455 | F: sound/soc/codecs/max9860.* | 7466 | F: sound/soc/codecs/max9860.* |
| 7456 | 7467 | ||
| 7457 | MAXIM MUIC CHARGER DRIVERS FOR EXYNOS BASED BOARDS | 7468 | MAXIM MUIC CHARGER DRIVERS FOR EXYNOS BASED BOARDS |
| 7458 | M: Krzysztof Kozlowski <k.kozlowski@samsung.com> | 7469 | M: Krzysztof Kozlowski <krzk@kernel.org> |
| 7470 | M: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | ||
| 7459 | L: linux-pm@vger.kernel.org | 7471 | L: linux-pm@vger.kernel.org |
| 7460 | S: Supported | 7472 | S: Supported |
| 7461 | F: drivers/power/max14577_charger.c | 7473 | F: drivers/power/max14577_charger.c |
| @@ -7471,7 +7483,8 @@ F: include/dt-bindings/*/*max77802.h | |||
| 7471 | 7483 | ||
| 7472 | MAXIM PMIC AND MUIC DRIVERS FOR EXYNOS BASED BOARDS | 7484 | MAXIM PMIC AND MUIC DRIVERS FOR EXYNOS BASED BOARDS |
| 7473 | M: Chanwoo Choi <cw00.choi@samsung.com> | 7485 | M: Chanwoo Choi <cw00.choi@samsung.com> |
| 7474 | M: Krzysztof Kozlowski <k.kozlowski@samsung.com> | 7486 | M: Krzysztof Kozlowski <krzk@kernel.org> |
| 7487 | M: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | ||
| 7475 | L: linux-kernel@vger.kernel.org | 7488 | L: linux-kernel@vger.kernel.org |
| 7476 | S: Supported | 7489 | S: Supported |
| 7477 | F: drivers/*/max14577*.c | 7490 | F: drivers/*/max14577*.c |
| @@ -7661,7 +7674,7 @@ L: linux-rdma@vger.kernel.org | |||
| 7661 | S: Supported | 7674 | S: Supported |
| 7662 | W: https://github.com/SoftRoCE/rxe-dev/wiki/rxe-dev:-Home | 7675 | W: https://github.com/SoftRoCE/rxe-dev/wiki/rxe-dev:-Home |
| 7663 | Q: http://patchwork.kernel.org/project/linux-rdma/list/ | 7676 | Q: http://patchwork.kernel.org/project/linux-rdma/list/ |
| 7664 | F: drivers/infiniband/hw/rxe/ | 7677 | F: drivers/infiniband/sw/rxe/ |
| 7665 | F: include/uapi/rdma/rdma_user_rxe.h | 7678 | F: include/uapi/rdma/rdma_user_rxe.h |
| 7666 | 7679 | ||
| 7667 | MEMBARRIER SUPPORT | 7680 | MEMBARRIER SUPPORT |
| @@ -9237,7 +9250,7 @@ F: drivers/pinctrl/sh-pfc/ | |||
| 9237 | 9250 | ||
| 9238 | PIN CONTROLLER - SAMSUNG | 9251 | PIN CONTROLLER - SAMSUNG |
| 9239 | M: Tomasz Figa <tomasz.figa@gmail.com> | 9252 | M: Tomasz Figa <tomasz.figa@gmail.com> |
| 9240 | M: Krzysztof Kozlowski <k.kozlowski@samsung.com> | 9253 | M: Krzysztof Kozlowski <krzk@kernel.org> |
| 9241 | M: Sylwester Nawrocki <s.nawrocki@samsung.com> | 9254 | M: Sylwester Nawrocki <s.nawrocki@samsung.com> |
| 9242 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) | 9255 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) |
| 9243 | L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) | 9256 | L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) |
| @@ -10170,7 +10183,7 @@ S: Maintained | |||
| 10170 | F: drivers/platform/x86/samsung-laptop.c | 10183 | F: drivers/platform/x86/samsung-laptop.c |
| 10171 | 10184 | ||
| 10172 | SAMSUNG AUDIO (ASoC) DRIVERS | 10185 | SAMSUNG AUDIO (ASoC) DRIVERS |
| 10173 | M: Krzysztof Kozlowski <k.kozlowski@samsung.com> | 10186 | M: Krzysztof Kozlowski <krzk@kernel.org> |
| 10174 | M: Sangbeom Kim <sbkim73@samsung.com> | 10187 | M: Sangbeom Kim <sbkim73@samsung.com> |
| 10175 | M: Sylwester Nawrocki <s.nawrocki@samsung.com> | 10188 | M: Sylwester Nawrocki <s.nawrocki@samsung.com> |
| 10176 | L: alsa-devel@alsa-project.org (moderated for non-subscribers) | 10189 | L: alsa-devel@alsa-project.org (moderated for non-subscribers) |
| @@ -10185,7 +10198,8 @@ F: drivers/video/fbdev/s3c-fb.c | |||
| 10185 | 10198 | ||
| 10186 | SAMSUNG MULTIFUNCTION PMIC DEVICE DRIVERS | 10199 | SAMSUNG MULTIFUNCTION PMIC DEVICE DRIVERS |
| 10187 | M: Sangbeom Kim <sbkim73@samsung.com> | 10200 | M: Sangbeom Kim <sbkim73@samsung.com> |
| 10188 | M: Krzysztof Kozlowski <k.kozlowski@samsung.com> | 10201 | M: Krzysztof Kozlowski <krzk@kernel.org> |
| 10202 | M: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | ||
| 10189 | L: linux-kernel@vger.kernel.org | 10203 | L: linux-kernel@vger.kernel.org |
| 10190 | L: linux-samsung-soc@vger.kernel.org | 10204 | L: linux-samsung-soc@vger.kernel.org |
| 10191 | S: Supported | 10205 | S: Supported |
| @@ -10244,6 +10258,17 @@ S: Supported | |||
| 10244 | L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) | 10258 | L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) |
| 10245 | F: drivers/clk/samsung/ | 10259 | F: drivers/clk/samsung/ |
| 10246 | 10260 | ||
| 10261 | SAMSUNG SPI DRIVERS | ||
| 10262 | M: Kukjin Kim <kgene@kernel.org> | ||
| 10263 | M: Krzysztof Kozlowski <krzk@kernel.org> | ||
| 10264 | M: Andi Shyti <andi.shyti@samsung.com> | ||
| 10265 | L: linux-spi@vger.kernel.org | ||
| 10266 | L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) | ||
| 10267 | S: Maintained | ||
| 10268 | F: Documentation/devicetree/bindings/spi/spi-samsung.txt | ||
| 10269 | F: drivers/spi/spi-s3c* | ||
| 10270 | F: include/linux/platform_data/spi-s3c64xx.h | ||
| 10271 | |||
| 10247 | SAMSUNG SXGBE DRIVERS | 10272 | SAMSUNG SXGBE DRIVERS |
| 10248 | M: Byungho An <bh74.an@samsung.com> | 10273 | M: Byungho An <bh74.an@samsung.com> |
| 10249 | M: Girish K S <ks.giri@samsung.com> | 10274 | M: Girish K S <ks.giri@samsung.com> |
| @@ -11223,12 +11248,8 @@ S: Odd Fixes | |||
| 11223 | F: drivers/staging/vt665?/ | 11248 | F: drivers/staging/vt665?/ |
| 11224 | 11249 | ||
| 11225 | STAGING - WILC1000 WIFI DRIVER | 11250 | STAGING - WILC1000 WIFI DRIVER |
| 11226 | M: Johnny Kim <johnny.kim@atmel.com> | 11251 | M: Aditya Shankar <aditya.shankar@microchip.com> |
| 11227 | M: Austin Shin <austin.shin@atmel.com> | 11252 | M: Ganesh Krishna <ganesh.krishna@microchip.com> |
| 11228 | M: Chris Park <chris.park@atmel.com> | ||
| 11229 | M: Tony Cho <tony.cho@atmel.com> | ||
| 11230 | M: Glen Lee <glen.lee@atmel.com> | ||
| 11231 | M: Leo Kim <leo.kim@atmel.com> | ||
| 11232 | L: linux-wireless@vger.kernel.org | 11253 | L: linux-wireless@vger.kernel.org |
| 11233 | S: Supported | 11254 | S: Supported |
| 11234 | F: drivers/staging/wilc1000/ | 11255 | F: drivers/staging/wilc1000/ |
| @@ -1,7 +1,7 @@ | |||
| 1 | VERSION = 4 | 1 | VERSION = 4 |
| 2 | PATCHLEVEL = 8 | 2 | PATCHLEVEL = 8 |
| 3 | SUBLEVEL = 0 | 3 | SUBLEVEL = 0 |
| 4 | EXTRAVERSION = -rc3 | 4 | EXTRAVERSION = -rc6 |
| 5 | NAME = Psychotic Stoned Sheep | 5 | NAME = Psychotic Stoned Sheep |
| 6 | 6 | ||
| 7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
diff --git a/arch/Kconfig b/arch/Kconfig index e9c9334507dd..fd6e9712af81 100644 --- a/arch/Kconfig +++ b/arch/Kconfig | |||
| @@ -336,17 +336,6 @@ config HAVE_ARCH_SECCOMP_FILTER | |||
| 336 | results in the system call being skipped immediately. | 336 | results in the system call being skipped immediately. |
| 337 | - seccomp syscall wired up | 337 | - seccomp syscall wired up |
| 338 | 338 | ||
| 339 | For best performance, an arch should use seccomp_phase1 and | ||
| 340 | seccomp_phase2 directly. It should call seccomp_phase1 for all | ||
| 341 | syscalls if TIF_SECCOMP is set, but seccomp_phase1 does not | ||
| 342 | need to be called from a ptrace-safe context. It must then | ||
| 343 | call seccomp_phase2 if seccomp_phase1 returns anything other | ||
| 344 | than SECCOMP_PHASE1_OK or SECCOMP_PHASE1_SKIP. | ||
| 345 | |||
| 346 | As an additional optimization, an arch may provide seccomp_data | ||
| 347 | directly to seccomp_phase1; this avoids multiple calls | ||
| 348 | to the syscall_xyz helpers for every syscall. | ||
| 349 | |||
| 350 | config SECCOMP_FILTER | 339 | config SECCOMP_FILTER |
| 351 | def_bool y | 340 | def_bool y |
| 352 | depends on HAVE_ARCH_SECCOMP_FILTER && SECCOMP && NET | 341 | depends on HAVE_ARCH_SECCOMP_FILTER && SECCOMP && NET |
diff --git a/arch/alpha/include/asm/uaccess.h b/arch/alpha/include/asm/uaccess.h index c419b43c461d..466e42e96bfa 100644 --- a/arch/alpha/include/asm/uaccess.h +++ b/arch/alpha/include/asm/uaccess.h | |||
| @@ -371,14 +371,6 @@ __copy_tofrom_user_nocheck(void *to, const void *from, long len) | |||
| 371 | return __cu_len; | 371 | return __cu_len; |
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | extern inline long | ||
| 375 | __copy_tofrom_user(void *to, const void *from, long len, const void __user *validate) | ||
| 376 | { | ||
| 377 | if (__access_ok((unsigned long)validate, len, get_fs())) | ||
| 378 | len = __copy_tofrom_user_nocheck(to, from, len); | ||
| 379 | return len; | ||
| 380 | } | ||
| 381 | |||
| 382 | #define __copy_to_user(to, from, n) \ | 374 | #define __copy_to_user(to, from, n) \ |
| 383 | ({ \ | 375 | ({ \ |
| 384 | __chk_user_ptr(to); \ | 376 | __chk_user_ptr(to); \ |
| @@ -393,17 +385,22 @@ __copy_tofrom_user(void *to, const void *from, long len, const void __user *vali | |||
| 393 | #define __copy_to_user_inatomic __copy_to_user | 385 | #define __copy_to_user_inatomic __copy_to_user |
| 394 | #define __copy_from_user_inatomic __copy_from_user | 386 | #define __copy_from_user_inatomic __copy_from_user |
| 395 | 387 | ||
| 396 | |||
| 397 | extern inline long | 388 | extern inline long |
| 398 | copy_to_user(void __user *to, const void *from, long n) | 389 | copy_to_user(void __user *to, const void *from, long n) |
| 399 | { | 390 | { |
| 400 | return __copy_tofrom_user((__force void *)to, from, n, to); | 391 | if (likely(__access_ok((unsigned long)to, n, get_fs()))) |
| 392 | n = __copy_tofrom_user_nocheck((__force void *)to, from, n); | ||
| 393 | return n; | ||
| 401 | } | 394 | } |
| 402 | 395 | ||
| 403 | extern inline long | 396 | extern inline long |
| 404 | copy_from_user(void *to, const void __user *from, long n) | 397 | copy_from_user(void *to, const void __user *from, long n) |
| 405 | { | 398 | { |
| 406 | return __copy_tofrom_user(to, (__force void *)from, n, from); | 399 | if (likely(__access_ok((unsigned long)from, n, get_fs()))) |
| 400 | n = __copy_tofrom_user_nocheck(to, (__force void *)from, n); | ||
| 401 | else | ||
| 402 | memset(to, 0, n); | ||
| 403 | return n; | ||
| 407 | } | 404 | } |
| 408 | 405 | ||
| 409 | extern void __do_clear_user(void); | 406 | extern void __do_clear_user(void); |
diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h index ad7860c5ce15..51597f344a62 100644 --- a/arch/arc/include/asm/entry.h +++ b/arch/arc/include/asm/entry.h | |||
| @@ -142,7 +142,7 @@ | |||
| 142 | 142 | ||
| 143 | #ifdef CONFIG_ARC_CURR_IN_REG | 143 | #ifdef CONFIG_ARC_CURR_IN_REG |
| 144 | ; Retrieve orig r25 and save it with rest of callee_regs | 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 | PUSH r12 | 146 | PUSH r12 |
| 147 | #else | 147 | #else |
| 148 | PUSH r25 | 148 | PUSH r25 |
| @@ -198,7 +198,7 @@ | |||
| 198 | 198 | ||
| 199 | ; SP is back to start of pt_regs | 199 | ; SP is back to start of pt_regs |
| 200 | #ifdef CONFIG_ARC_CURR_IN_REG | 200 | #ifdef CONFIG_ARC_CURR_IN_REG |
| 201 | st.as r12, [sp, PT_user_r25] | 201 | st r12, [sp, PT_user_r25] |
| 202 | #endif | 202 | #endif |
| 203 | .endm | 203 | .endm |
| 204 | 204 | ||
diff --git a/arch/arc/include/asm/irqflags-compact.h b/arch/arc/include/asm/irqflags-compact.h index c1d36458bfb7..4c6eed80cd8b 100644 --- a/arch/arc/include/asm/irqflags-compact.h +++ b/arch/arc/include/asm/irqflags-compact.h | |||
| @@ -188,10 +188,10 @@ static inline int arch_irqs_disabled(void) | |||
| 188 | .endm | 188 | .endm |
| 189 | 189 | ||
| 190 | .macro IRQ_ENABLE scratch | 190 | .macro IRQ_ENABLE scratch |
| 191 | TRACE_ASM_IRQ_ENABLE | ||
| 191 | lr \scratch, [status32] | 192 | lr \scratch, [status32] |
| 192 | or \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK) | 193 | or \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK) |
| 193 | flag \scratch | 194 | flag \scratch |
| 194 | TRACE_ASM_IRQ_ENABLE | ||
| 195 | .endm | 195 | .endm |
| 196 | 196 | ||
| 197 | #endif /* __ASSEMBLY__ */ | 197 | #endif /* __ASSEMBLY__ */ |
diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h index 0f92d97432a2..89eeb3720051 100644 --- a/arch/arc/include/asm/pgtable.h +++ b/arch/arc/include/asm/pgtable.h | |||
| @@ -280,7 +280,7 @@ static inline void pmd_set(pmd_t *pmdp, pte_t *ptep) | |||
| 280 | 280 | ||
| 281 | #define pte_page(pte) pfn_to_page(pte_pfn(pte)) | 281 | #define pte_page(pte) pfn_to_page(pte_pfn(pte)) |
| 282 | #define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot) | 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 | /* Don't use virt_to_pfn for macros below: could cause truncations for PAE40*/ | 285 | /* Don't use virt_to_pfn for macros below: could cause truncations for PAE40*/ |
| 286 | #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) | 286 | #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) |
diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h index a78d5670884f..41faf17cd28d 100644 --- a/arch/arc/include/asm/uaccess.h +++ b/arch/arc/include/asm/uaccess.h | |||
| @@ -83,7 +83,10 @@ | |||
| 83 | "2: ;nop\n" \ | 83 | "2: ;nop\n" \ |
| 84 | " .section .fixup, \"ax\"\n" \ | 84 | " .section .fixup, \"ax\"\n" \ |
| 85 | " .align 4\n" \ | 85 | " .align 4\n" \ |
| 86 | "3: mov %0, %3\n" \ | 86 | "3: # return -EFAULT\n" \ |
| 87 | " mov %0, %3\n" \ | ||
| 88 | " # zero out dst ptr\n" \ | ||
| 89 | " mov %1, 0\n" \ | ||
| 87 | " j 2b\n" \ | 90 | " j 2b\n" \ |
| 88 | " .previous\n" \ | 91 | " .previous\n" \ |
| 89 | " .section __ex_table, \"a\"\n" \ | 92 | " .section __ex_table, \"a\"\n" \ |
| @@ -101,7 +104,11 @@ | |||
| 101 | "2: ;nop\n" \ | 104 | "2: ;nop\n" \ |
| 102 | " .section .fixup, \"ax\"\n" \ | 105 | " .section .fixup, \"ax\"\n" \ |
| 103 | " .align 4\n" \ | 106 | " .align 4\n" \ |
| 104 | "3: mov %0, %3\n" \ | 107 | "3: # return -EFAULT\n" \ |
| 108 | " mov %0, %3\n" \ | ||
| 109 | " # zero out dst ptr\n" \ | ||
| 110 | " mov %1, 0\n" \ | ||
| 111 | " mov %R1, 0\n" \ | ||
| 105 | " j 2b\n" \ | 112 | " j 2b\n" \ |
| 106 | " .previous\n" \ | 113 | " .previous\n" \ |
| 107 | " .section __ex_table, \"a\"\n" \ | 114 | " .section __ex_table, \"a\"\n" \ |
diff --git a/arch/arc/include/uapi/asm/elf.h b/arch/arc/include/uapi/asm/elf.h index 0f99ac8fcbb2..0037a587320d 100644 --- a/arch/arc/include/uapi/asm/elf.h +++ b/arch/arc/include/uapi/asm/elf.h | |||
| @@ -13,8 +13,15 @@ | |||
| 13 | 13 | ||
| 14 | /* Machine specific ELF Hdr flags */ | 14 | /* Machine specific ELF Hdr flags */ |
| 15 | #define EF_ARC_OSABI_MSK 0x00000f00 | 15 | #define EF_ARC_OSABI_MSK 0x00000f00 |
| 16 | #define EF_ARC_OSABI_ORIG 0x00000000 /* MUST be zero for back-compat */ | 16 | |
| 17 | #define EF_ARC_OSABI_CURRENT 0x00000300 /* v3 (no legacy syscalls) */ | 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 | typedef unsigned long elf_greg_t; | 26 | typedef unsigned long elf_greg_t; |
| 20 | typedef unsigned long elf_fpregset_t; | 27 | typedef unsigned long elf_fpregset_t; |
diff --git a/arch/arc/kernel/arcksyms.c b/arch/arc/kernel/arcksyms.c index 4d9e77724bed..000dd041ab42 100644 --- a/arch/arc/kernel/arcksyms.c +++ b/arch/arc/kernel/arcksyms.c | |||
| @@ -28,6 +28,7 @@ extern void __muldf3(void); | |||
| 28 | extern void __divdf3(void); | 28 | extern void __divdf3(void); |
| 29 | extern void __floatunsidf(void); | 29 | extern void __floatunsidf(void); |
| 30 | extern void __floatunsisf(void); | 30 | extern void __floatunsisf(void); |
| 31 | extern void __udivdi3(void); | ||
| 31 | 32 | ||
| 32 | EXPORT_SYMBOL(__ashldi3); | 33 | EXPORT_SYMBOL(__ashldi3); |
| 33 | EXPORT_SYMBOL(__ashrdi3); | 34 | EXPORT_SYMBOL(__ashrdi3); |
| @@ -45,6 +46,7 @@ EXPORT_SYMBOL(__muldf3); | |||
| 45 | EXPORT_SYMBOL(__divdf3); | 46 | EXPORT_SYMBOL(__divdf3); |
| 46 | EXPORT_SYMBOL(__floatunsidf); | 47 | EXPORT_SYMBOL(__floatunsidf); |
| 47 | EXPORT_SYMBOL(__floatunsisf); | 48 | EXPORT_SYMBOL(__floatunsisf); |
| 49 | EXPORT_SYMBOL(__udivdi3); | ||
| 48 | 50 | ||
| 49 | /* ARC optimised assembler routines */ | 51 | /* ARC optimised assembler routines */ |
| 50 | EXPORT_SYMBOL(memset); | 52 | EXPORT_SYMBOL(memset); |
diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c index b5db9e7fd649..be1972bd2729 100644 --- a/arch/arc/kernel/process.c +++ b/arch/arc/kernel/process.c | |||
| @@ -199,7 +199,7 @@ int elf_check_arch(const struct elf32_hdr *x) | |||
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | eflags = x->e_flags; | 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 | pr_err("ABI mismatch - you need newer toolchain\n"); | 203 | pr_err("ABI mismatch - you need newer toolchain\n"); |
| 204 | force_sigsegv(SIGSEGV, current); | 204 | force_sigsegv(SIGSEGV, current); |
| 205 | return 0; | 205 | return 0; |
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c index a946400a86d0..f52a0d0dc462 100644 --- a/arch/arc/kernel/setup.c +++ b/arch/arc/kernel/setup.c | |||
| @@ -291,8 +291,10 @@ static char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len) | |||
| 291 | cpu->dccm.base_addr, TO_KB(cpu->dccm.sz), | 291 | cpu->dccm.base_addr, TO_KB(cpu->dccm.sz), |
| 292 | cpu->iccm.base_addr, TO_KB(cpu->iccm.sz)); | 292 | cpu->iccm.base_addr, TO_KB(cpu->iccm.sz)); |
| 293 | 293 | ||
| 294 | n += scnprintf(buf + n, len - n, | 294 | n += scnprintf(buf + n, len - n, "OS ABI [v%d]\t: %s\n", |
| 295 | "OS ABI [v3]\t: no-legacy-syscalls\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 | return buf; | 299 | return buf; |
| 298 | } | 300 | } |
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c index 5a294b2c3cb3..0b10efe3a6a7 100644 --- a/arch/arc/mm/cache.c +++ b/arch/arc/mm/cache.c | |||
| @@ -921,6 +921,15 @@ void arc_cache_init(void) | |||
| 921 | 921 | ||
| 922 | printk(arc_cache_mumbojumbo(0, str, sizeof(str))); | 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 | if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE)) { | 933 | if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE)) { |
| 925 | struct cpuinfo_arc_cache *ic = &cpuinfo_arc700[cpu].icache; | 934 | struct cpuinfo_arc_cache *ic = &cpuinfo_arc700[cpu].icache; |
| 926 | 935 | ||
diff --git a/arch/arc/mm/highmem.c b/arch/arc/mm/highmem.c index 04f83322c9fd..77ff64a874a1 100644 --- a/arch/arc/mm/highmem.c +++ b/arch/arc/mm/highmem.c | |||
| @@ -61,6 +61,7 @@ void *kmap(struct page *page) | |||
| 61 | 61 | ||
| 62 | return kmap_high(page); | 62 | return kmap_high(page); |
| 63 | } | 63 | } |
| 64 | EXPORT_SYMBOL(kmap); | ||
| 64 | 65 | ||
| 65 | void *kmap_atomic(struct page *page) | 66 | void *kmap_atomic(struct page *page) |
| 66 | { | 67 | { |
diff --git a/arch/arm/boot/dts/am335x-baltos.dtsi b/arch/arm/boot/dts/am335x-baltos.dtsi index c8609d8d2c55..b689172632ef 100644 --- a/arch/arm/boot/dts/am335x-baltos.dtsi +++ b/arch/arm/boot/dts/am335x-baltos.dtsi | |||
| @@ -226,7 +226,7 @@ | |||
| 226 | 226 | ||
| 227 | #address-cells = <1>; | 227 | #address-cells = <1>; |
| 228 | #size-cells = <1>; | 228 | #size-cells = <1>; |
| 229 | elm_id = <&elm>; | 229 | ti,elm-id = <&elm>; |
| 230 | }; | 230 | }; |
| 231 | }; | 231 | }; |
| 232 | 232 | ||
diff --git a/arch/arm/boot/dts/am335x-igep0033.dtsi b/arch/arm/boot/dts/am335x-igep0033.dtsi index df63484ef9b3..e7d9ca1305fa 100644 --- a/arch/arm/boot/dts/am335x-igep0033.dtsi +++ b/arch/arm/boot/dts/am335x-igep0033.dtsi | |||
| @@ -161,7 +161,7 @@ | |||
| 161 | 161 | ||
| 162 | #address-cells = <1>; | 162 | #address-cells = <1>; |
| 163 | #size-cells = <1>; | 163 | #size-cells = <1>; |
| 164 | elm_id = <&elm>; | 164 | ti,elm-id = <&elm>; |
| 165 | 165 | ||
| 166 | /* MTD partition table */ | 166 | /* MTD partition table */ |
| 167 | partition@0 { | 167 | partition@0 { |
diff --git a/arch/arm/boot/dts/am335x-phycore-som.dtsi b/arch/arm/boot/dts/am335x-phycore-som.dtsi index 86f773165d5c..1263c9d4cba3 100644 --- a/arch/arm/boot/dts/am335x-phycore-som.dtsi +++ b/arch/arm/boot/dts/am335x-phycore-som.dtsi | |||
| @@ -197,7 +197,7 @@ | |||
| 197 | gpmc,wr-access-ns = <30>; | 197 | gpmc,wr-access-ns = <30>; |
| 198 | gpmc,wr-data-mux-bus-ns = <0>; | 198 | gpmc,wr-data-mux-bus-ns = <0>; |
| 199 | 199 | ||
| 200 | elm_id = <&elm>; | 200 | ti,elm-id = <&elm>; |
| 201 | 201 | ||
| 202 | #address-cells = <1>; | 202 | #address-cells = <1>; |
| 203 | #size-cells = <1>; | 203 | #size-cells = <1>; |
diff --git a/arch/arm/boot/dts/armada-388-clearfog.dts b/arch/arm/boot/dts/armada-388-clearfog.dts index 2e0556af6e5e..d3e6bd805006 100644 --- a/arch/arm/boot/dts/armada-388-clearfog.dts +++ b/arch/arm/boot/dts/armada-388-clearfog.dts | |||
| @@ -390,12 +390,12 @@ | |||
| 390 | 390 | ||
| 391 | port@0 { | 391 | port@0 { |
| 392 | reg = <0>; | 392 | reg = <0>; |
| 393 | label = "lan1"; | 393 | label = "lan5"; |
| 394 | }; | 394 | }; |
| 395 | 395 | ||
| 396 | port@1 { | 396 | port@1 { |
| 397 | reg = <1>; | 397 | reg = <1>; |
| 398 | label = "lan2"; | 398 | label = "lan4"; |
| 399 | }; | 399 | }; |
| 400 | 400 | ||
| 401 | port@2 { | 401 | port@2 { |
| @@ -405,12 +405,12 @@ | |||
| 405 | 405 | ||
| 406 | port@3 { | 406 | port@3 { |
| 407 | reg = <3>; | 407 | reg = <3>; |
| 408 | label = "lan4"; | 408 | label = "lan2"; |
| 409 | }; | 409 | }; |
| 410 | 410 | ||
| 411 | port@4 { | 411 | port@4 { |
| 412 | reg = <4>; | 412 | reg = <4>; |
| 413 | label = "lan5"; | 413 | label = "lan1"; |
| 414 | }; | 414 | }; |
| 415 | 415 | ||
| 416 | port@5 { | 416 | port@5 { |
diff --git a/arch/arm/boot/dts/bcm2835-rpi.dtsi b/arch/arm/boot/dts/bcm2835-rpi.dtsi index caf2707680c1..e9b47b2bbc33 100644 --- a/arch/arm/boot/dts/bcm2835-rpi.dtsi +++ b/arch/arm/boot/dts/bcm2835-rpi.dtsi | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | / { | 3 | / { |
| 4 | memory { | 4 | memory { |
| 5 | device_type = "memory"; | ||
| 5 | reg = <0 0x10000000>; | 6 | reg = <0 0x10000000>; |
| 6 | }; | 7 | }; |
| 7 | 8 | ||
diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi index b98252232d20..445624a1a1de 100644 --- a/arch/arm/boot/dts/bcm283x.dtsi +++ b/arch/arm/boot/dts/bcm283x.dtsi | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | #include <dt-bindings/clock/bcm2835.h> | 2 | #include <dt-bindings/clock/bcm2835.h> |
| 3 | #include <dt-bindings/clock/bcm2835-aux.h> | 3 | #include <dt-bindings/clock/bcm2835-aux.h> |
| 4 | #include <dt-bindings/gpio/gpio.h> | 4 | #include <dt-bindings/gpio/gpio.h> |
| 5 | #include "skeleton.dtsi" | ||
| 6 | 5 | ||
| 7 | /* This include file covers the common peripherals and configuration between | 6 | /* This include file covers the common peripherals and configuration between |
| 8 | * bcm2835 and bcm2836 implementations, leaving the CPU configuration to | 7 | * bcm2835 and bcm2836 implementations, leaving the CPU configuration to |
| @@ -13,6 +12,8 @@ | |||
| 13 | compatible = "brcm,bcm2835"; | 12 | compatible = "brcm,bcm2835"; |
| 14 | model = "BCM2835"; | 13 | model = "BCM2835"; |
| 15 | interrupt-parent = <&intc>; | 14 | interrupt-parent = <&intc>; |
| 15 | #address-cells = <1>; | ||
| 16 | #size-cells = <1>; | ||
| 16 | 17 | ||
| 17 | chosen { | 18 | chosen { |
| 18 | bootargs = "earlyprintk console=ttyAMA0"; | 19 | bootargs = "earlyprintk console=ttyAMA0"; |
diff --git a/arch/arm/boot/dts/exynos5410-odroidxu.dts b/arch/arm/boot/dts/exynos5410-odroidxu.dts index d9499310a301..f6d135245a4b 100644 --- a/arch/arm/boot/dts/exynos5410-odroidxu.dts +++ b/arch/arm/boot/dts/exynos5410-odroidxu.dts | |||
| @@ -447,14 +447,11 @@ | |||
| 447 | samsung,dw-mshc-ciu-div = <3>; | 447 | samsung,dw-mshc-ciu-div = <3>; |
| 448 | samsung,dw-mshc-sdr-timing = <0 4>; | 448 | samsung,dw-mshc-sdr-timing = <0 4>; |
| 449 | samsung,dw-mshc-ddr-timing = <0 2>; | 449 | samsung,dw-mshc-ddr-timing = <0 2>; |
| 450 | samsung,dw-mshc-hs400-timing = <0 2>; | ||
| 451 | samsung,read-strobe-delay = <90>; | ||
| 452 | pinctrl-names = "default"; | 450 | pinctrl-names = "default"; |
| 453 | pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus1 &sd0_bus4 &sd0_bus8 &sd0_cd>; | 451 | pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus1 &sd0_bus4 &sd0_bus8 &sd0_cd>; |
| 454 | bus-width = <8>; | 452 | bus-width = <8>; |
| 455 | cap-mmc-highspeed; | 453 | cap-mmc-highspeed; |
| 456 | mmc-hs200-1_8v; | 454 | mmc-hs200-1_8v; |
| 457 | mmc-hs400-1_8v; | ||
| 458 | vmmc-supply = <&ldo20_reg>; | 455 | vmmc-supply = <&ldo20_reg>; |
| 459 | vqmmc-supply = <&ldo11_reg>; | 456 | vqmmc-supply = <&ldo11_reg>; |
| 460 | }; | 457 | }; |
diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi index b620ac884cfd..b13b0b2db881 100644 --- a/arch/arm/boot/dts/imx6qdl.dtsi +++ b/arch/arm/boot/dts/imx6qdl.dtsi | |||
| @@ -243,7 +243,7 @@ | |||
| 243 | clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>, | 243 | clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>, |
| 244 | <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_ASRC>, | 244 | <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_ASRC>, |
| 245 | <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_ESAI_EXTAL>, | 245 | <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_ESAI_EXTAL>, |
| 246 | <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_MLB>, | 246 | <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_DUMMY>, |
| 247 | <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>; | 247 | <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>; |
| 248 | clock-names = "core", "rxtx0", | 248 | clock-names = "core", "rxtx0", |
| 249 | "rxtx1", "rxtx2", | 249 | "rxtx1", "rxtx2", |
diff --git a/arch/arm/boot/dts/imx6sx-sabreauto.dts b/arch/arm/boot/dts/imx6sx-sabreauto.dts index 96ea936eeeb0..240a2864d044 100644 --- a/arch/arm/boot/dts/imx6sx-sabreauto.dts +++ b/arch/arm/boot/dts/imx6sx-sabreauto.dts | |||
| @@ -64,7 +64,7 @@ | |||
| 64 | cd-gpios = <&gpio7 11 GPIO_ACTIVE_LOW>; | 64 | cd-gpios = <&gpio7 11 GPIO_ACTIVE_LOW>; |
| 65 | no-1-8-v; | 65 | no-1-8-v; |
| 66 | keep-power-in-suspend; | 66 | keep-power-in-suspend; |
| 67 | enable-sdio-wakup; | 67 | wakeup-source; |
| 68 | status = "okay"; | 68 | status = "okay"; |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
diff --git a/arch/arm/boot/dts/imx7d-sdb.dts b/arch/arm/boot/dts/imx7d-sdb.dts index 95ee268ed510..2f33c463cbce 100644 --- a/arch/arm/boot/dts/imx7d-sdb.dts +++ b/arch/arm/boot/dts/imx7d-sdb.dts | |||
| @@ -131,7 +131,7 @@ | |||
| 131 | ti,y-min = /bits/ 16 <0>; | 131 | ti,y-min = /bits/ 16 <0>; |
| 132 | ti,y-max = /bits/ 16 <0>; | 132 | ti,y-max = /bits/ 16 <0>; |
| 133 | ti,pressure-max = /bits/ 16 <0>; | 133 | ti,pressure-max = /bits/ 16 <0>; |
| 134 | ti,x-plat-ohms = /bits/ 16 <400>; | 134 | ti,x-plate-ohms = /bits/ 16 <400>; |
| 135 | wakeup-source; | 135 | wakeup-source; |
| 136 | }; | 136 | }; |
| 137 | }; | 137 | }; |
diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts index ef84d8699a76..5bf62897014c 100644 --- a/arch/arm/boot/dts/kirkwood-ib62x0.dts +++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts | |||
| @@ -113,7 +113,7 @@ | |||
| 113 | 113 | ||
| 114 | partition@e0000 { | 114 | partition@e0000 { |
| 115 | label = "u-boot environment"; | 115 | label = "u-boot environment"; |
| 116 | reg = <0xe0000 0x100000>; | 116 | reg = <0xe0000 0x20000>; |
| 117 | }; | 117 | }; |
| 118 | 118 | ||
| 119 | partition@100000 { | 119 | partition@100000 { |
diff --git a/arch/arm/boot/dts/kirkwood-openrd.dtsi b/arch/arm/boot/dts/kirkwood-openrd.dtsi index e4ecab112601..7175511a92da 100644 --- a/arch/arm/boot/dts/kirkwood-openrd.dtsi +++ b/arch/arm/boot/dts/kirkwood-openrd.dtsi | |||
| @@ -116,6 +116,10 @@ | |||
| 116 | }; | 116 | }; |
| 117 | }; | 117 | }; |
| 118 | 118 | ||
| 119 | &pciec { | ||
| 120 | status = "okay"; | ||
| 121 | }; | ||
| 122 | |||
| 119 | &pcie0 { | 123 | &pcie0 { |
| 120 | status = "okay"; | 124 | status = "okay"; |
| 121 | }; | 125 | }; |
diff --git a/arch/arm/boot/dts/logicpd-som-lv.dtsi b/arch/arm/boot/dts/logicpd-som-lv.dtsi index 365f39ff58bb..0ff1c2de95bf 100644 --- a/arch/arm/boot/dts/logicpd-som-lv.dtsi +++ b/arch/arm/boot/dts/logicpd-som-lv.dtsi | |||
| @@ -35,10 +35,15 @@ | |||
| 35 | ranges = <0 0 0x00000000 0x1000000>; /* CS0: 16MB for NAND */ | 35 | ranges = <0 0 0x00000000 0x1000000>; /* CS0: 16MB for NAND */ |
| 36 | 36 | ||
| 37 | nand@0,0 { | 37 | nand@0,0 { |
| 38 | linux,mtd-name = "micron,mt29f4g16abbda3w"; | 38 | compatible = "ti,omap2-nand"; |
| 39 | reg = <0 0 4>; /* CS0, offset 0, IO size 4 */ | 39 | reg = <0 0 4>; /* CS0, offset 0, IO size 4 */ |
| 40 | interrupt-parent = <&gpmc>; | ||
| 41 | interrupts = <0 IRQ_TYPE_NONE>, /* fifoevent */ | ||
| 42 | <1 IRQ_TYPE_NONE>; /* termcount */ | ||
| 43 | linux,mtd-name = "micron,mt29f4g16abbda3w"; | ||
| 40 | nand-bus-width = <16>; | 44 | nand-bus-width = <16>; |
| 41 | ti,nand-ecc-opt = "bch8"; | 45 | ti,nand-ecc-opt = "bch8"; |
| 46 | rb-gpios = <&gpmc 0 GPIO_ACTIVE_HIGH>; /* gpmc_wait0 */ | ||
| 42 | gpmc,sync-clk-ps = <0>; | 47 | gpmc,sync-clk-ps = <0>; |
| 43 | gpmc,cs-on-ns = <0>; | 48 | gpmc,cs-on-ns = <0>; |
| 44 | gpmc,cs-rd-off-ns = <44>; | 49 | gpmc,cs-rd-off-ns = <44>; |
| @@ -54,10 +59,6 @@ | |||
| 54 | gpmc,wr-access-ns = <40>; | 59 | gpmc,wr-access-ns = <40>; |
| 55 | gpmc,wr-data-mux-bus-ns = <0>; | 60 | gpmc,wr-data-mux-bus-ns = <0>; |
| 56 | gpmc,device-width = <2>; | 61 | gpmc,device-width = <2>; |
| 57 | |||
| 58 | gpmc,page-burst-access-ns = <5>; | ||
| 59 | gpmc,cycle2cycle-delay-ns = <50>; | ||
| 60 | |||
| 61 | #address-cells = <1>; | 62 | #address-cells = <1>; |
| 62 | #size-cells = <1>; | 63 | #size-cells = <1>; |
| 63 | 64 | ||
diff --git a/arch/arm/boot/dts/logicpd-torpedo-som.dtsi b/arch/arm/boot/dts/logicpd-torpedo-som.dtsi index 5e9a13c0eaf7..1c2c74655416 100644 --- a/arch/arm/boot/dts/logicpd-torpedo-som.dtsi +++ b/arch/arm/boot/dts/logicpd-torpedo-som.dtsi | |||
| @@ -46,6 +46,7 @@ | |||
| 46 | linux,mtd-name = "micron,mt29f4g16abbda3w"; | 46 | linux,mtd-name = "micron,mt29f4g16abbda3w"; |
| 47 | nand-bus-width = <16>; | 47 | nand-bus-width = <16>; |
| 48 | ti,nand-ecc-opt = "bch8"; | 48 | ti,nand-ecc-opt = "bch8"; |
| 49 | rb-gpios = <&gpmc 0 GPIO_ACTIVE_HIGH>; /* gpmc_wait0 */ | ||
| 49 | gpmc,sync-clk-ps = <0>; | 50 | gpmc,sync-clk-ps = <0>; |
| 50 | gpmc,cs-on-ns = <0>; | 51 | gpmc,cs-on-ns = <0>; |
| 51 | gpmc,cs-rd-off-ns = <44>; | 52 | gpmc,cs-rd-off-ns = <44>; |
diff --git a/arch/arm/boot/dts/omap3-overo-base.dtsi b/arch/arm/boot/dts/omap3-overo-base.dtsi index de256fa8da48..3e946cac55f3 100644 --- a/arch/arm/boot/dts/omap3-overo-base.dtsi +++ b/arch/arm/boot/dts/omap3-overo-base.dtsi | |||
| @@ -223,7 +223,9 @@ | |||
| 223 | }; | 223 | }; |
| 224 | 224 | ||
| 225 | &gpmc { | 225 | &gpmc { |
| 226 | ranges = <0 0 0x00000000 0x20000000>; | 226 | ranges = <0 0 0x30000000 0x1000000>, /* CS0 */ |
| 227 | <4 0 0x2b000000 0x1000000>, /* CS4 */ | ||
| 228 | <5 0 0x2c000000 0x1000000>; /* CS5 */ | ||
| 227 | 229 | ||
| 228 | nand@0,0 { | 230 | nand@0,0 { |
| 229 | compatible = "ti,omap2-nand"; | 231 | compatible = "ti,omap2-nand"; |
diff --git a/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi b/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi index 7df27926ead2..4f4c6efbd518 100644 --- a/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi +++ b/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi | |||
| @@ -55,8 +55,6 @@ | |||
| 55 | #include "omap-gpmc-smsc9221.dtsi" | 55 | #include "omap-gpmc-smsc9221.dtsi" |
| 56 | 56 | ||
| 57 | &gpmc { | 57 | &gpmc { |
| 58 | ranges = <5 0 0x2c000000 0x1000000>; /* CS5 */ | ||
| 59 | |||
| 60 | ethernet@gpmc { | 58 | ethernet@gpmc { |
| 61 | reg = <5 0 0xff>; | 59 | reg = <5 0 0xff>; |
| 62 | interrupt-parent = <&gpio6>; | 60 | interrupt-parent = <&gpio6>; |
diff --git a/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi b/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi index 9e24b6a1d07b..1b304e2f1bd2 100644 --- a/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi +++ b/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi | |||
| @@ -27,8 +27,6 @@ | |||
| 27 | #include "omap-gpmc-smsc9221.dtsi" | 27 | #include "omap-gpmc-smsc9221.dtsi" |
| 28 | 28 | ||
| 29 | &gpmc { | 29 | &gpmc { |
| 30 | ranges = <5 0 0x2c000000 0x1000000>; /* CS5 */ | ||
| 31 | |||
| 32 | ethernet@gpmc { | 30 | ethernet@gpmc { |
| 33 | reg = <5 0 0xff>; | 31 | reg = <5 0 0xff>; |
| 34 | interrupt-parent = <&gpio6>; | 32 | interrupt-parent = <&gpio6>; |
diff --git a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi index 334109e14613..82e98ee3023a 100644 --- a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi +++ b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi | |||
| @@ -15,9 +15,6 @@ | |||
| 15 | #include "omap-gpmc-smsc9221.dtsi" | 15 | #include "omap-gpmc-smsc9221.dtsi" |
| 16 | 16 | ||
| 17 | &gpmc { | 17 | &gpmc { |
| 18 | ranges = <4 0 0x2b000000 0x1000000>, /* CS4 */ | ||
| 19 | <5 0 0x2c000000 0x1000000>; /* CS5 */ | ||
| 20 | |||
| 21 | smsc1: ethernet@gpmc { | 18 | smsc1: ethernet@gpmc { |
| 22 | reg = <5 0 0xff>; | 19 | reg = <5 0 0xff>; |
| 23 | interrupt-parent = <&gpio6>; | 20 | interrupt-parent = <&gpio6>; |
diff --git a/arch/arm/boot/dts/rk3066a.dtsi b/arch/arm/boot/dts/rk3066a.dtsi index c0ba86c3a2ab..0d0dae3a1694 100644 --- a/arch/arm/boot/dts/rk3066a.dtsi +++ b/arch/arm/boot/dts/rk3066a.dtsi | |||
| @@ -197,6 +197,8 @@ | |||
| 197 | clock-names = "saradc", "apb_pclk"; | 197 | clock-names = "saradc", "apb_pclk"; |
| 198 | interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; | 198 | interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; |
| 199 | #io-channel-cells = <1>; | 199 | #io-channel-cells = <1>; |
| 200 | resets = <&cru SRST_SARADC>; | ||
| 201 | reset-names = "saradc-apb"; | ||
| 200 | status = "disabled"; | 202 | status = "disabled"; |
| 201 | }; | 203 | }; |
| 202 | 204 | ||
diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi index cd33f0170890..91c4b3c7a8d5 100644 --- a/arch/arm/boot/dts/rk3288.dtsi +++ b/arch/arm/boot/dts/rk3288.dtsi | |||
| @@ -279,6 +279,8 @@ | |||
| 279 | #io-channel-cells = <1>; | 279 | #io-channel-cells = <1>; |
| 280 | clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; | 280 | clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; |
| 281 | clock-names = "saradc", "apb_pclk"; | 281 | clock-names = "saradc", "apb_pclk"; |
| 282 | resets = <&cru SRST_SARADC>; | ||
| 283 | reset-names = "saradc-apb"; | ||
| 282 | status = "disabled"; | 284 | status = "disabled"; |
| 283 | }; | 285 | }; |
| 284 | 286 | ||
diff --git a/arch/arm/boot/dts/rk3xxx.dtsi b/arch/arm/boot/dts/rk3xxx.dtsi index 99bbcc2c9b89..e2cd683b4e4b 100644 --- a/arch/arm/boot/dts/rk3xxx.dtsi +++ b/arch/arm/boot/dts/rk3xxx.dtsi | |||
| @@ -399,6 +399,8 @@ | |||
| 399 | #io-channel-cells = <1>; | 399 | #io-channel-cells = <1>; |
| 400 | clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; | 400 | clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; |
| 401 | clock-names = "saradc", "apb_pclk"; | 401 | clock-names = "saradc", "apb_pclk"; |
| 402 | resets = <&cru SRST_SARADC>; | ||
| 403 | reset-names = "saradc-apb"; | ||
| 402 | status = "disabled"; | 404 | status = "disabled"; |
| 403 | }; | 405 | }; |
| 404 | 406 | ||
diff --git a/arch/arm/boot/dts/stih407-family.dtsi b/arch/arm/boot/dts/stih407-family.dtsi index d294e82447a2..8b063ab10c19 100644 --- a/arch/arm/boot/dts/stih407-family.dtsi +++ b/arch/arm/boot/dts/stih407-family.dtsi | |||
| @@ -550,8 +550,9 @@ | |||
| 550 | interrupt-names = "mmcirq"; | 550 | interrupt-names = "mmcirq"; |
| 551 | pinctrl-names = "default"; | 551 | pinctrl-names = "default"; |
| 552 | pinctrl-0 = <&pinctrl_mmc0>; | 552 | pinctrl-0 = <&pinctrl_mmc0>; |
| 553 | clock-names = "mmc"; | 553 | clock-names = "mmc", "icn"; |
| 554 | clocks = <&clk_s_c0_flexgen CLK_MMC_0>; | 554 | clocks = <&clk_s_c0_flexgen CLK_MMC_0>, |
| 555 | <&clk_s_c0_flexgen CLK_RX_ICN_HVA>; | ||
| 555 | bus-width = <8>; | 556 | bus-width = <8>; |
| 556 | non-removable; | 557 | non-removable; |
| 557 | }; | 558 | }; |
| @@ -565,8 +566,9 @@ | |||
| 565 | interrupt-names = "mmcirq"; | 566 | interrupt-names = "mmcirq"; |
| 566 | pinctrl-names = "default"; | 567 | pinctrl-names = "default"; |
| 567 | pinctrl-0 = <&pinctrl_sd1>; | 568 | pinctrl-0 = <&pinctrl_sd1>; |
| 568 | clock-names = "mmc"; | 569 | clock-names = "mmc", "icn"; |
| 569 | clocks = <&clk_s_c0_flexgen CLK_MMC_1>; | 570 | clocks = <&clk_s_c0_flexgen CLK_MMC_1>, |
| 571 | <&clk_s_c0_flexgen CLK_RX_ICN_HVA>; | ||
| 570 | resets = <&softreset STIH407_MMC1_SOFTRESET>; | 572 | resets = <&softreset STIH407_MMC1_SOFTRESET>; |
| 571 | bus-width = <4>; | 573 | bus-width = <4>; |
| 572 | }; | 574 | }; |
diff --git a/arch/arm/boot/dts/stih410.dtsi b/arch/arm/boot/dts/stih410.dtsi index 18ed1ad10d32..40318869c733 100644 --- a/arch/arm/boot/dts/stih410.dtsi +++ b/arch/arm/boot/dts/stih410.dtsi | |||
| @@ -41,7 +41,8 @@ | |||
| 41 | compatible = "st,st-ohci-300x"; | 41 | compatible = "st,st-ohci-300x"; |
| 42 | reg = <0x9a03c00 0x100>; | 42 | reg = <0x9a03c00 0x100>; |
| 43 | interrupts = <GIC_SPI 180 IRQ_TYPE_NONE>; | 43 | interrupts = <GIC_SPI 180 IRQ_TYPE_NONE>; |
| 44 | clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>; | 44 | clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>, |
| 45 | <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>; | ||
| 45 | resets = <&powerdown STIH407_USB2_PORT0_POWERDOWN>, | 46 | resets = <&powerdown STIH407_USB2_PORT0_POWERDOWN>, |
| 46 | <&softreset STIH407_USB2_PORT0_SOFTRESET>; | 47 | <&softreset STIH407_USB2_PORT0_SOFTRESET>; |
| 47 | reset-names = "power", "softreset"; | 48 | reset-names = "power", "softreset"; |
| @@ -57,7 +58,8 @@ | |||
| 57 | interrupts = <GIC_SPI 151 IRQ_TYPE_NONE>; | 58 | interrupts = <GIC_SPI 151 IRQ_TYPE_NONE>; |
| 58 | pinctrl-names = "default"; | 59 | pinctrl-names = "default"; |
| 59 | pinctrl-0 = <&pinctrl_usb0>; | 60 | pinctrl-0 = <&pinctrl_usb0>; |
| 60 | clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>; | 61 | clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>, |
| 62 | <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>; | ||
| 61 | resets = <&powerdown STIH407_USB2_PORT0_POWERDOWN>, | 63 | resets = <&powerdown STIH407_USB2_PORT0_POWERDOWN>, |
| 62 | <&softreset STIH407_USB2_PORT0_SOFTRESET>; | 64 | <&softreset STIH407_USB2_PORT0_SOFTRESET>; |
| 63 | reset-names = "power", "softreset"; | 65 | reset-names = "power", "softreset"; |
| @@ -71,7 +73,8 @@ | |||
| 71 | compatible = "st,st-ohci-300x"; | 73 | compatible = "st,st-ohci-300x"; |
| 72 | reg = <0x9a83c00 0x100>; | 74 | reg = <0x9a83c00 0x100>; |
| 73 | interrupts = <GIC_SPI 181 IRQ_TYPE_NONE>; | 75 | interrupts = <GIC_SPI 181 IRQ_TYPE_NONE>; |
| 74 | clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>; | 76 | clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>, |
| 77 | <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>; | ||
| 75 | resets = <&powerdown STIH407_USB2_PORT1_POWERDOWN>, | 78 | resets = <&powerdown STIH407_USB2_PORT1_POWERDOWN>, |
| 76 | <&softreset STIH407_USB2_PORT1_SOFTRESET>; | 79 | <&softreset STIH407_USB2_PORT1_SOFTRESET>; |
| 77 | reset-names = "power", "softreset"; | 80 | reset-names = "power", "softreset"; |
| @@ -87,7 +90,8 @@ | |||
| 87 | interrupts = <GIC_SPI 153 IRQ_TYPE_NONE>; | 90 | interrupts = <GIC_SPI 153 IRQ_TYPE_NONE>; |
| 88 | pinctrl-names = "default"; | 91 | pinctrl-names = "default"; |
| 89 | pinctrl-0 = <&pinctrl_usb1>; | 92 | pinctrl-0 = <&pinctrl_usb1>; |
| 90 | clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>; | 93 | clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>, |
| 94 | <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>; | ||
| 91 | resets = <&powerdown STIH407_USB2_PORT1_POWERDOWN>, | 95 | resets = <&powerdown STIH407_USB2_PORT1_POWERDOWN>, |
| 92 | <&softreset STIH407_USB2_PORT1_SOFTRESET>; | 96 | <&softreset STIH407_USB2_PORT1_SOFTRESET>; |
| 93 | reset-names = "power", "softreset"; | 97 | reset-names = "power", "softreset"; |
diff --git a/arch/arm/boot/dts/sun5i-a13.dtsi b/arch/arm/boot/dts/sun5i-a13.dtsi index e012890e0cf2..a17ba0243db3 100644 --- a/arch/arm/boot/dts/sun5i-a13.dtsi +++ b/arch/arm/boot/dts/sun5i-a13.dtsi | |||
| @@ -84,7 +84,7 @@ | |||
| 84 | trips { | 84 | trips { |
| 85 | cpu_alert0: cpu_alert0 { | 85 | cpu_alert0: cpu_alert0 { |
| 86 | /* milliCelsius */ | 86 | /* milliCelsius */ |
| 87 | temperature = <850000>; | 87 | temperature = <85000>; |
| 88 | hysteresis = <2000>; | 88 | hysteresis = <2000>; |
| 89 | type = "passive"; | 89 | type = "passive"; |
| 90 | }; | 90 | }; |
diff --git a/arch/arm/boot/dts/tegra114-dalmore.dts b/arch/arm/boot/dts/tegra114-dalmore.dts index 1dfc492cc004..1444fbd543e7 100644 --- a/arch/arm/boot/dts/tegra114-dalmore.dts +++ b/arch/arm/boot/dts/tegra114-dalmore.dts | |||
| @@ -897,7 +897,7 @@ | |||
| 897 | palmas: tps65913@58 { | 897 | palmas: tps65913@58 { |
| 898 | compatible = "ti,palmas"; | 898 | compatible = "ti,palmas"; |
| 899 | reg = <0x58>; | 899 | reg = <0x58>; |
| 900 | interrupts = <0 86 IRQ_TYPE_LEVEL_LOW>; | 900 | interrupts = <0 86 IRQ_TYPE_LEVEL_HIGH>; |
| 901 | 901 | ||
| 902 | #interrupt-cells = <2>; | 902 | #interrupt-cells = <2>; |
| 903 | interrupt-controller; | 903 | interrupt-controller; |
diff --git a/arch/arm/boot/dts/tegra114-roth.dts b/arch/arm/boot/dts/tegra114-roth.dts index 70cf40996c3f..966a7fc044af 100644 --- a/arch/arm/boot/dts/tegra114-roth.dts +++ b/arch/arm/boot/dts/tegra114-roth.dts | |||
| @@ -802,7 +802,7 @@ | |||
| 802 | palmas: pmic@58 { | 802 | palmas: pmic@58 { |
| 803 | compatible = "ti,palmas"; | 803 | compatible = "ti,palmas"; |
| 804 | reg = <0x58>; | 804 | reg = <0x58>; |
| 805 | interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_LOW>; | 805 | interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>; |
| 806 | 806 | ||
| 807 | #interrupt-cells = <2>; | 807 | #interrupt-cells = <2>; |
| 808 | interrupt-controller; | 808 | interrupt-controller; |
diff --git a/arch/arm/boot/dts/tegra114-tn7.dts b/arch/arm/boot/dts/tegra114-tn7.dts index 17dd14545862..a161fa1dfb61 100644 --- a/arch/arm/boot/dts/tegra114-tn7.dts +++ b/arch/arm/boot/dts/tegra114-tn7.dts | |||
| @@ -63,7 +63,7 @@ | |||
| 63 | palmas: pmic@58 { | 63 | palmas: pmic@58 { |
| 64 | compatible = "ti,palmas"; | 64 | compatible = "ti,palmas"; |
| 65 | reg = <0x58>; | 65 | reg = <0x58>; |
| 66 | interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_LOW>; | 66 | interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>; |
| 67 | 67 | ||
| 68 | #interrupt-cells = <2>; | 68 | #interrupt-cells = <2>; |
| 69 | interrupt-controller; | 69 | interrupt-controller; |
diff --git a/arch/arm/boot/dts/tegra124-jetson-tk1.dts b/arch/arm/boot/dts/tegra124-jetson-tk1.dts index 6403e0de540e..e52b82449a79 100644 --- a/arch/arm/boot/dts/tegra124-jetson-tk1.dts +++ b/arch/arm/boot/dts/tegra124-jetson-tk1.dts | |||
| @@ -1382,7 +1382,7 @@ | |||
| 1382 | * Pin 41: BR_UART1_TXD | 1382 | * Pin 41: BR_UART1_TXD |
| 1383 | * Pin 44: BR_UART1_RXD | 1383 | * Pin 44: BR_UART1_RXD |
| 1384 | */ | 1384 | */ |
| 1385 | serial@0,70006000 { | 1385 | serial@70006000 { |
| 1386 | compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart"; | 1386 | compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart"; |
| 1387 | status = "okay"; | 1387 | status = "okay"; |
| 1388 | }; | 1388 | }; |
| @@ -1394,7 +1394,7 @@ | |||
| 1394 | * Pin 71: UART2_CTS_L | 1394 | * Pin 71: UART2_CTS_L |
| 1395 | * Pin 74: UART2_RTS_L | 1395 | * Pin 74: UART2_RTS_L |
| 1396 | */ | 1396 | */ |
| 1397 | serial@0,70006040 { | 1397 | serial@70006040 { |
| 1398 | compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart"; | 1398 | compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart"; |
| 1399 | status = "okay"; | 1399 | status = "okay"; |
| 1400 | }; | 1400 | }; |
diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c index 0e97b4b871f9..6c7b06854fce 100644 --- a/arch/arm/common/locomo.c +++ b/arch/arm/common/locomo.c | |||
| @@ -140,7 +140,7 @@ static struct locomo_dev_info locomo_devices[] = { | |||
| 140 | 140 | ||
| 141 | static void locomo_handler(struct irq_desc *desc) | 141 | static void locomo_handler(struct irq_desc *desc) |
| 142 | { | 142 | { |
| 143 | struct locomo *lchip = irq_desc_get_chip_data(desc); | 143 | struct locomo *lchip = irq_desc_get_handler_data(desc); |
| 144 | int req, i; | 144 | int req, i; |
| 145 | 145 | ||
| 146 | /* Acknowledge the parent IRQ */ | 146 | /* Acknowledge the parent IRQ */ |
| @@ -200,8 +200,7 @@ static void locomo_setup_irq(struct locomo *lchip) | |||
| 200 | * Install handler for IRQ_LOCOMO_HW. | 200 | * Install handler for IRQ_LOCOMO_HW. |
| 201 | */ | 201 | */ |
| 202 | irq_set_irq_type(lchip->irq, IRQ_TYPE_EDGE_FALLING); | 202 | irq_set_irq_type(lchip->irq, IRQ_TYPE_EDGE_FALLING); |
| 203 | irq_set_chip_data(lchip->irq, lchip); | 203 | irq_set_chained_handler_and_data(lchip->irq, locomo_handler, lchip); |
| 204 | irq_set_chained_handler(lchip->irq, locomo_handler); | ||
| 205 | 204 | ||
| 206 | /* Install handlers for IRQ_LOCOMO_* */ | 205 | /* Install handlers for IRQ_LOCOMO_* */ |
| 207 | for ( ; irq <= lchip->irq_base + 3; irq++) { | 206 | for ( ; irq <= lchip->irq_base + 3; irq++) { |
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index fb0a0a4dfea4..2e076c492005 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c | |||
| @@ -472,8 +472,8 @@ static int sa1111_setup_irq(struct sa1111 *sachip, unsigned irq_base) | |||
| 472 | * specifies that S0ReadyInt and S1ReadyInt should be '1'. | 472 | * specifies that S0ReadyInt and S1ReadyInt should be '1'. |
| 473 | */ | 473 | */ |
| 474 | sa1111_writel(0, irqbase + SA1111_INTPOL0); | 474 | sa1111_writel(0, irqbase + SA1111_INTPOL0); |
| 475 | sa1111_writel(SA1111_IRQMASK_HI(IRQ_S0_READY_NINT) | | 475 | sa1111_writel(BIT(IRQ_S0_READY_NINT & 31) | |
| 476 | SA1111_IRQMASK_HI(IRQ_S1_READY_NINT), | 476 | BIT(IRQ_S1_READY_NINT & 31), |
| 477 | irqbase + SA1111_INTPOL1); | 477 | irqbase + SA1111_INTPOL1); |
| 478 | 478 | ||
| 479 | /* clear all IRQs */ | 479 | /* clear all IRQs */ |
| @@ -754,7 +754,7 @@ static int __sa1111_probe(struct device *me, struct resource *mem, int irq) | |||
| 754 | if (sachip->irq != NO_IRQ) { | 754 | if (sachip->irq != NO_IRQ) { |
| 755 | ret = sa1111_setup_irq(sachip, pd->irq_base); | 755 | ret = sa1111_setup_irq(sachip, pd->irq_base); |
| 756 | if (ret) | 756 | if (ret) |
| 757 | goto err_unmap; | 757 | goto err_clk; |
| 758 | } | 758 | } |
| 759 | 759 | ||
| 760 | #ifdef CONFIG_ARCH_SA1100 | 760 | #ifdef CONFIG_ARCH_SA1100 |
| @@ -799,6 +799,8 @@ static int __sa1111_probe(struct device *me, struct resource *mem, int irq) | |||
| 799 | 799 | ||
| 800 | return 0; | 800 | return 0; |
| 801 | 801 | ||
| 802 | err_clk: | ||
| 803 | clk_disable(sachip->clk); | ||
| 802 | err_unmap: | 804 | err_unmap: |
| 803 | iounmap(sachip->base); | 805 | iounmap(sachip->base); |
| 804 | err_clk_unprep: | 806 | err_clk_unprep: |
| @@ -869,9 +871,9 @@ struct sa1111_save_data { | |||
| 869 | 871 | ||
| 870 | #ifdef CONFIG_PM | 872 | #ifdef CONFIG_PM |
| 871 | 873 | ||
| 872 | static int sa1111_suspend(struct platform_device *dev, pm_message_t state) | 874 | static int sa1111_suspend_noirq(struct device *dev) |
| 873 | { | 875 | { |
| 874 | struct sa1111 *sachip = platform_get_drvdata(dev); | 876 | struct sa1111 *sachip = dev_get_drvdata(dev); |
| 875 | struct sa1111_save_data *save; | 877 | struct sa1111_save_data *save; |
| 876 | unsigned long flags; | 878 | unsigned long flags; |
| 877 | unsigned int val; | 879 | unsigned int val; |
| @@ -934,9 +936,9 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state) | |||
| 934 | * restored by their respective drivers, and must be called | 936 | * restored by their respective drivers, and must be called |
| 935 | * via LDM after this function. | 937 | * via LDM after this function. |
| 936 | */ | 938 | */ |
| 937 | static int sa1111_resume(struct platform_device *dev) | 939 | static int sa1111_resume_noirq(struct device *dev) |
| 938 | { | 940 | { |
| 939 | struct sa1111 *sachip = platform_get_drvdata(dev); | 941 | struct sa1111 *sachip = dev_get_drvdata(dev); |
| 940 | struct sa1111_save_data *save; | 942 | struct sa1111_save_data *save; |
| 941 | unsigned long flags, id; | 943 | unsigned long flags, id; |
| 942 | void __iomem *base; | 944 | void __iomem *base; |
| @@ -952,7 +954,7 @@ static int sa1111_resume(struct platform_device *dev) | |||
| 952 | id = sa1111_readl(sachip->base + SA1111_SKID); | 954 | id = sa1111_readl(sachip->base + SA1111_SKID); |
| 953 | if ((id & SKID_ID_MASK) != SKID_SA1111_ID) { | 955 | if ((id & SKID_ID_MASK) != SKID_SA1111_ID) { |
| 954 | __sa1111_remove(sachip); | 956 | __sa1111_remove(sachip); |
| 955 | platform_set_drvdata(dev, NULL); | 957 | dev_set_drvdata(dev, NULL); |
| 956 | kfree(save); | 958 | kfree(save); |
| 957 | return 0; | 959 | return 0; |
| 958 | } | 960 | } |
| @@ -1003,8 +1005,8 @@ static int sa1111_resume(struct platform_device *dev) | |||
| 1003 | } | 1005 | } |
| 1004 | 1006 | ||
| 1005 | #else | 1007 | #else |
| 1006 | #define sa1111_suspend NULL | 1008 | #define sa1111_suspend_noirq NULL |
| 1007 | #define sa1111_resume NULL | 1009 | #define sa1111_resume_noirq NULL |
| 1008 | #endif | 1010 | #endif |
| 1009 | 1011 | ||
| 1010 | static int sa1111_probe(struct platform_device *pdev) | 1012 | static int sa1111_probe(struct platform_device *pdev) |
| @@ -1017,7 +1019,7 @@ static int sa1111_probe(struct platform_device *pdev) | |||
| 1017 | return -EINVAL; | 1019 | return -EINVAL; |
| 1018 | irq = platform_get_irq(pdev, 0); | 1020 | irq = platform_get_irq(pdev, 0); |
| 1019 | if (irq < 0) | 1021 | if (irq < 0) |
| 1020 | return -ENXIO; | 1022 | return irq; |
| 1021 | 1023 | ||
| 1022 | return __sa1111_probe(&pdev->dev, mem, irq); | 1024 | return __sa1111_probe(&pdev->dev, mem, irq); |
| 1023 | } | 1025 | } |
| @@ -1038,6 +1040,11 @@ static int sa1111_remove(struct platform_device *pdev) | |||
| 1038 | return 0; | 1040 | return 0; |
| 1039 | } | 1041 | } |
| 1040 | 1042 | ||
| 1043 | static struct dev_pm_ops sa1111_pm_ops = { | ||
| 1044 | .suspend_noirq = sa1111_suspend_noirq, | ||
| 1045 | .resume_noirq = sa1111_resume_noirq, | ||
| 1046 | }; | ||
| 1047 | |||
| 1041 | /* | 1048 | /* |
| 1042 | * Not sure if this should be on the system bus or not yet. | 1049 | * Not sure if this should be on the system bus or not yet. |
| 1043 | * We really want some way to register a system device at | 1050 | * We really want some way to register a system device at |
| @@ -1050,10 +1057,9 @@ static int sa1111_remove(struct platform_device *pdev) | |||
| 1050 | static struct platform_driver sa1111_device_driver = { | 1057 | static struct platform_driver sa1111_device_driver = { |
| 1051 | .probe = sa1111_probe, | 1058 | .probe = sa1111_probe, |
| 1052 | .remove = sa1111_remove, | 1059 | .remove = sa1111_remove, |
| 1053 | .suspend = sa1111_suspend, | ||
| 1054 | .resume = sa1111_resume, | ||
| 1055 | .driver = { | 1060 | .driver = { |
| 1056 | .name = "sa1111", | 1061 | .name = "sa1111", |
| 1062 | .pm = &sa1111_pm_ops, | ||
| 1057 | }, | 1063 | }, |
| 1058 | }; | 1064 | }; |
| 1059 | 1065 | ||
diff --git a/arch/arm/configs/keystone_defconfig b/arch/arm/configs/keystone_defconfig index 71b42e66488a..78cd2f197e01 100644 --- a/arch/arm/configs/keystone_defconfig +++ b/arch/arm/configs/keystone_defconfig | |||
| @@ -161,6 +161,7 @@ CONFIG_USB_MON=y | |||
| 161 | CONFIG_USB_XHCI_HCD=y | 161 | CONFIG_USB_XHCI_HCD=y |
| 162 | CONFIG_USB_STORAGE=y | 162 | CONFIG_USB_STORAGE=y |
| 163 | CONFIG_USB_DWC3=y | 163 | CONFIG_USB_DWC3=y |
| 164 | CONFIG_NOP_USB_XCEIV=y | ||
| 164 | CONFIG_KEYSTONE_USB_PHY=y | 165 | CONFIG_KEYSTONE_USB_PHY=y |
| 165 | CONFIG_NEW_LEDS=y | 166 | CONFIG_NEW_LEDS=y |
| 166 | CONFIG_LEDS_CLASS=y | 167 | CONFIG_LEDS_CLASS=y |
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index 2c8665cd9dc5..ea3566fb92e2 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig | |||
| @@ -781,7 +781,7 @@ CONFIG_MXS_DMA=y | |||
| 781 | CONFIG_DMA_BCM2835=y | 781 | CONFIG_DMA_BCM2835=y |
| 782 | CONFIG_DMA_OMAP=y | 782 | CONFIG_DMA_OMAP=y |
| 783 | CONFIG_QCOM_BAM_DMA=y | 783 | CONFIG_QCOM_BAM_DMA=y |
| 784 | CONFIG_XILINX_VDMA=y | 784 | CONFIG_XILINX_DMA=y |
| 785 | CONFIG_DMA_SUN6I=y | 785 | CONFIG_DMA_SUN6I=y |
| 786 | CONFIG_STAGING=y | 786 | CONFIG_STAGING=y |
| 787 | CONFIG_SENSORS_ISL29018=y | 787 | CONFIG_SENSORS_ISL29018=y |
diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h index d0131ee6f6af..3f82e9da7cec 100644 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h | |||
| @@ -47,6 +47,7 @@ | |||
| 47 | #define PMD_SECT_WB (PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) | 47 | #define PMD_SECT_WB (PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) |
| 48 | #define PMD_SECT_MINICACHE (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE) | 48 | #define PMD_SECT_MINICACHE (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE) |
| 49 | #define PMD_SECT_WBWA (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) | 49 | #define PMD_SECT_WBWA (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) |
| 50 | #define PMD_SECT_CACHE_MASK (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) | ||
| 50 | #define PMD_SECT_NONSHARED_DEV (PMD_SECT_TEX(2)) | 51 | #define PMD_SECT_NONSHARED_DEV (PMD_SECT_TEX(2)) |
| 51 | 52 | ||
| 52 | /* | 53 | /* |
diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h index f8f1cff62065..4cd664abfcd3 100644 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h | |||
| @@ -62,6 +62,7 @@ | |||
| 62 | #define PMD_SECT_WT (_AT(pmdval_t, 2) << 2) /* normal inner write-through */ | 62 | #define PMD_SECT_WT (_AT(pmdval_t, 2) << 2) /* normal inner write-through */ |
| 63 | #define PMD_SECT_WB (_AT(pmdval_t, 3) << 2) /* normal inner write-back */ | 63 | #define PMD_SECT_WB (_AT(pmdval_t, 3) << 2) /* normal inner write-back */ |
| 64 | #define PMD_SECT_WBWA (_AT(pmdval_t, 7) << 2) /* normal inner write-alloc */ | 64 | #define PMD_SECT_WBWA (_AT(pmdval_t, 7) << 2) /* normal inner write-alloc */ |
| 65 | #define PMD_SECT_CACHE_MASK (_AT(pmdval_t, 7) << 2) | ||
| 65 | 66 | ||
| 66 | /* | 67 | /* |
| 67 | * + Level 3 descriptor (PTE) | 68 | * + Level 3 descriptor (PTE) |
diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S index 0b1e4a93d67e..15d073ae5da2 100644 --- a/arch/arm/kernel/hyp-stub.S +++ b/arch/arm/kernel/hyp-stub.S | |||
| @@ -142,6 +142,19 @@ ARM_BE8(orr r7, r7, #(1 << 25)) @ HSCTLR.EE | |||
| 142 | and r7, #0x1f @ Preserve HPMN | 142 | and r7, #0x1f @ Preserve HPMN |
| 143 | mcr p15, 4, r7, c1, c1, 1 @ HDCR | 143 | mcr p15, 4, r7, c1, c1, 1 @ HDCR |
| 144 | 144 | ||
| 145 | @ Make sure NS-SVC is initialised appropriately | ||
| 146 | mrc p15, 0, r7, c1, c0, 0 @ SCTLR | ||
| 147 | orr r7, #(1 << 5) @ CP15 barriers enabled | ||
| 148 | bic r7, #(3 << 7) @ Clear SED/ITD for v8 (RES0 for v7) | ||
| 149 | bic r7, #(3 << 19) @ WXN and UWXN disabled | ||
| 150 | mcr p15, 0, r7, c1, c0, 0 @ SCTLR | ||
| 151 | |||
| 152 | mrc p15, 0, r7, c0, c0, 0 @ MIDR | ||
| 153 | mcr p15, 4, r7, c0, c0, 0 @ VPIDR | ||
| 154 | |||
| 155 | mrc p15, 0, r7, c0, c0, 5 @ MPIDR | ||
| 156 | mcr p15, 4, r7, c0, c0, 5 @ VMPIDR | ||
| 157 | |||
| 145 | #if !defined(ZIMAGE) && defined(CONFIG_ARM_ARCH_TIMER) | 158 | #if !defined(ZIMAGE) && defined(CONFIG_ARM_ARCH_TIMER) |
| 146 | @ make CNTP_* and CNTPCT accessible from PL1 | 159 | @ make CNTP_* and CNTPCT accessible from PL1 |
| 147 | mrc p15, 0, r7, c0, c1, 1 @ ID_PFR1 | 160 | mrc p15, 0, r7, c0, c1, 1 @ ID_PFR1 |
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 75f130ef6504..c94b90d43772 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c | |||
| @@ -158,8 +158,6 @@ void kvm_arch_destroy_vm(struct kvm *kvm) | |||
| 158 | { | 158 | { |
| 159 | int i; | 159 | int i; |
| 160 | 160 | ||
| 161 | kvm_free_stage2_pgd(kvm); | ||
| 162 | |||
| 163 | for (i = 0; i < KVM_MAX_VCPUS; ++i) { | 161 | for (i = 0; i < KVM_MAX_VCPUS; ++i) { |
| 164 | if (kvm->vcpus[i]) { | 162 | if (kvm->vcpus[i]) { |
| 165 | kvm_arch_vcpu_free(kvm->vcpus[i]); | 163 | kvm_arch_vcpu_free(kvm->vcpus[i]); |
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index bda27b6b1aa2..e9a5c0e0c115 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c | |||
| @@ -1309,7 +1309,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, | |||
| 1309 | smp_rmb(); | 1309 | smp_rmb(); |
| 1310 | 1310 | ||
| 1311 | pfn = gfn_to_pfn_prot(kvm, gfn, write_fault, &writable); | 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 | return -EFAULT; | 1313 | return -EFAULT; |
| 1314 | 1314 | ||
| 1315 | if (kvm_is_device_pfn(pfn)) { | 1315 | if (kvm_is_device_pfn(pfn)) { |
| @@ -1714,7 +1714,8 @@ int kvm_mmu_init(void) | |||
| 1714 | kern_hyp_va(PAGE_OFFSET), kern_hyp_va(~0UL)); | 1714 | kern_hyp_va(PAGE_OFFSET), kern_hyp_va(~0UL)); |
| 1715 | 1715 | ||
| 1716 | if (hyp_idmap_start >= kern_hyp_va(PAGE_OFFSET) && | 1716 | if (hyp_idmap_start >= kern_hyp_va(PAGE_OFFSET) && |
| 1717 | hyp_idmap_start < kern_hyp_va(~0UL)) { | 1717 | hyp_idmap_start < kern_hyp_va(~0UL) && |
| 1718 | hyp_idmap_start != (unsigned long)__hyp_idmap_text_start) { | ||
| 1718 | /* | 1719 | /* |
| 1719 | * The idmap page is intersecting with the VA space, | 1720 | * The idmap page is intersecting with the VA space, |
| 1720 | * it is not safe to continue further. | 1721 | * it is not safe to continue further. |
| @@ -1893,6 +1894,7 @@ void kvm_arch_memslots_updated(struct kvm *kvm, struct kvm_memslots *slots) | |||
| 1893 | 1894 | ||
| 1894 | void kvm_arch_flush_shadow_all(struct kvm *kvm) | 1895 | void kvm_arch_flush_shadow_all(struct kvm *kvm) |
| 1895 | { | 1896 | { |
| 1897 | kvm_free_stage2_pgd(kvm); | ||
| 1896 | } | 1898 | } |
| 1897 | 1899 | ||
| 1898 | void kvm_arch_flush_shadow_memslot(struct kvm *kvm, | 1900 | void kvm_arch_flush_shadow_memslot(struct kvm *kvm, |
diff --git a/arch/arm/mach-exynos/suspend.c b/arch/arm/mach-exynos/suspend.c index 3750575c73c5..06332f626565 100644 --- a/arch/arm/mach-exynos/suspend.c +++ b/arch/arm/mach-exynos/suspend.c | |||
| @@ -255,6 +255,12 @@ static int __init exynos_pmu_irq_init(struct device_node *node, | |||
| 255 | return -ENOMEM; | 255 | return -ENOMEM; |
| 256 | } | 256 | } |
| 257 | 257 | ||
| 258 | /* | ||
| 259 | * Clear the OF_POPULATED flag set in of_irq_init so that | ||
| 260 | * later the Exynos PMU platform device won't be skipped. | ||
| 261 | */ | ||
| 262 | of_node_clear_flag(node, OF_POPULATED); | ||
| 263 | |||
| 258 | return 0; | 264 | return 0; |
| 259 | } | 265 | } |
| 260 | 266 | ||
diff --git a/arch/arm/mach-imx/mach-imx6ul.c b/arch/arm/mach-imx/mach-imx6ul.c index 5d9bfab279dd..6bb7d9cf1e38 100644 --- a/arch/arm/mach-imx/mach-imx6ul.c +++ b/arch/arm/mach-imx/mach-imx6ul.c | |||
| @@ -64,6 +64,7 @@ static void __init imx6ul_init_machine(void) | |||
| 64 | if (parent == NULL) | 64 | if (parent == NULL) |
| 65 | pr_warn("failed to initialize soc device\n"); | 65 | pr_warn("failed to initialize soc device\n"); |
| 66 | 66 | ||
| 67 | of_platform_default_populate(NULL, NULL, parent); | ||
| 67 | imx6ul_enet_init(); | 68 | imx6ul_enet_init(); |
| 68 | imx_anatop_init(); | 69 | imx_anatop_init(); |
| 69 | imx6ul_pm_init(); | 70 | imx6ul_pm_init(); |
diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c index 58924b3844df..fe708e26d021 100644 --- a/arch/arm/mach-imx/pm-imx6.c +++ b/arch/arm/mach-imx/pm-imx6.c | |||
| @@ -295,7 +295,7 @@ int imx6_set_lpm(enum mxc_cpu_pwr_mode mode) | |||
| 295 | val &= ~BM_CLPCR_SBYOS; | 295 | val &= ~BM_CLPCR_SBYOS; |
| 296 | if (cpu_is_imx6sl()) | 296 | if (cpu_is_imx6sl()) |
| 297 | val |= BM_CLPCR_BYPASS_PMIC_READY; | 297 | val |= BM_CLPCR_BYPASS_PMIC_READY; |
| 298 | if (cpu_is_imx6sl() || cpu_is_imx6sx()) | 298 | if (cpu_is_imx6sl() || cpu_is_imx6sx() || cpu_is_imx6ul()) |
| 299 | val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS; | 299 | val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS; |
| 300 | else | 300 | else |
| 301 | val |= BM_CLPCR_BYP_MMDC_CH1_LPM_HS; | 301 | val |= BM_CLPCR_BYP_MMDC_CH1_LPM_HS; |
| @@ -310,7 +310,7 @@ int imx6_set_lpm(enum mxc_cpu_pwr_mode mode) | |||
| 310 | val |= 0x3 << BP_CLPCR_STBY_COUNT; | 310 | val |= 0x3 << BP_CLPCR_STBY_COUNT; |
| 311 | val |= BM_CLPCR_VSTBY; | 311 | val |= BM_CLPCR_VSTBY; |
| 312 | val |= BM_CLPCR_SBYOS; | 312 | val |= BM_CLPCR_SBYOS; |
| 313 | if (cpu_is_imx6sl()) | 313 | if (cpu_is_imx6sl() || cpu_is_imx6sx()) |
| 314 | val |= BM_CLPCR_BYPASS_PMIC_READY; | 314 | val |= BM_CLPCR_BYPASS_PMIC_READY; |
| 315 | if (cpu_is_imx6sl() || cpu_is_imx6sx() || cpu_is_imx6ul()) | 315 | if (cpu_is_imx6sl() || cpu_is_imx6sx() || cpu_is_imx6ul()) |
| 316 | val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS; | 316 | val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS; |
diff --git a/arch/arm/mach-omap2/cm33xx.c b/arch/arm/mach-omap2/cm33xx.c index c073fb57dd13..6f2d0aec0513 100644 --- a/arch/arm/mach-omap2/cm33xx.c +++ b/arch/arm/mach-omap2/cm33xx.c | |||
| @@ -220,9 +220,6 @@ static int am33xx_cm_wait_module_ready(u8 part, s16 inst, u16 clkctrl_offs, | |||
| 220 | { | 220 | { |
| 221 | int i = 0; | 221 | int i = 0; |
| 222 | 222 | ||
| 223 | if (!clkctrl_offs) | ||
| 224 | return 0; | ||
| 225 | |||
| 226 | omap_test_timeout(_is_module_ready(inst, clkctrl_offs), | 223 | omap_test_timeout(_is_module_ready(inst, clkctrl_offs), |
| 227 | MAX_MODULE_READY_TIME, i); | 224 | MAX_MODULE_READY_TIME, i); |
| 228 | 225 | ||
| @@ -246,9 +243,6 @@ static int am33xx_cm_wait_module_idle(u8 part, s16 inst, u16 clkctrl_offs, | |||
| 246 | { | 243 | { |
| 247 | int i = 0; | 244 | int i = 0; |
| 248 | 245 | ||
| 249 | if (!clkctrl_offs) | ||
| 250 | return 0; | ||
| 251 | |||
| 252 | omap_test_timeout((_clkctrl_idlest(inst, clkctrl_offs) == | 246 | omap_test_timeout((_clkctrl_idlest(inst, clkctrl_offs) == |
| 253 | CLKCTRL_IDLEST_DISABLED), | 247 | CLKCTRL_IDLEST_DISABLED), |
| 254 | MAX_MODULE_READY_TIME, i); | 248 | MAX_MODULE_READY_TIME, i); |
diff --git a/arch/arm/mach-omap2/cminst44xx.c b/arch/arm/mach-omap2/cminst44xx.c index 2c0e07ed6b99..2ab27ade136a 100644 --- a/arch/arm/mach-omap2/cminst44xx.c +++ b/arch/arm/mach-omap2/cminst44xx.c | |||
| @@ -278,9 +278,6 @@ static int omap4_cminst_wait_module_ready(u8 part, s16 inst, u16 clkctrl_offs, | |||
| 278 | { | 278 | { |
| 279 | int i = 0; | 279 | int i = 0; |
| 280 | 280 | ||
| 281 | if (!clkctrl_offs) | ||
| 282 | return 0; | ||
| 283 | |||
| 284 | omap_test_timeout(_is_module_ready(part, inst, clkctrl_offs), | 281 | omap_test_timeout(_is_module_ready(part, inst, clkctrl_offs), |
| 285 | MAX_MODULE_READY_TIME, i); | 282 | MAX_MODULE_READY_TIME, i); |
| 286 | 283 | ||
| @@ -304,9 +301,6 @@ static int omap4_cminst_wait_module_idle(u8 part, s16 inst, u16 clkctrl_offs, | |||
| 304 | { | 301 | { |
| 305 | int i = 0; | 302 | int i = 0; |
| 306 | 303 | ||
| 307 | if (!clkctrl_offs) | ||
| 308 | return 0; | ||
| 309 | |||
| 310 | omap_test_timeout((_clkctrl_idlest(part, inst, clkctrl_offs) == | 304 | omap_test_timeout((_clkctrl_idlest(part, inst, clkctrl_offs) == |
| 311 | CLKCTRL_IDLEST_DISABLED), | 305 | CLKCTRL_IDLEST_DISABLED), |
| 312 | MAX_MODULE_DISABLE_TIME, i); | 306 | MAX_MODULE_DISABLE_TIME, i); |
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 5b709383381c..1052b29697b8 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c | |||
| @@ -1053,6 +1053,10 @@ static int _omap4_wait_target_disable(struct omap_hwmod *oh) | |||
| 1053 | if (oh->flags & HWMOD_NO_IDLEST) | 1053 | if (oh->flags & HWMOD_NO_IDLEST) |
| 1054 | return 0; | 1054 | return 0; |
| 1055 | 1055 | ||
| 1056 | if (!oh->prcm.omap4.clkctrl_offs && | ||
| 1057 | !(oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET)) | ||
| 1058 | return 0; | ||
| 1059 | |||
| 1056 | return omap_cm_wait_module_idle(oh->clkdm->prcm_partition, | 1060 | return omap_cm_wait_module_idle(oh->clkdm->prcm_partition, |
| 1057 | oh->clkdm->cm_inst, | 1061 | oh->clkdm->cm_inst, |
| 1058 | oh->prcm.omap4.clkctrl_offs, 0); | 1062 | oh->prcm.omap4.clkctrl_offs, 0); |
| @@ -2971,6 +2975,10 @@ static int _omap4_wait_target_ready(struct omap_hwmod *oh) | |||
| 2971 | if (!_find_mpu_rt_port(oh)) | 2975 | if (!_find_mpu_rt_port(oh)) |
| 2972 | return 0; | 2976 | return 0; |
| 2973 | 2977 | ||
| 2978 | if (!oh->prcm.omap4.clkctrl_offs && | ||
| 2979 | !(oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET)) | ||
| 2980 | return 0; | ||
| 2981 | |||
| 2974 | /* XXX check module SIDLEMODE, hardreset status */ | 2982 | /* XXX check module SIDLEMODE, hardreset status */ |
| 2975 | 2983 | ||
| 2976 | return omap_cm_wait_module_ready(oh->clkdm->prcm_partition, | 2984 | return omap_cm_wait_module_ready(oh->clkdm->prcm_partition, |
diff --git a/arch/arm/mach-omap2/omap_hwmod.h b/arch/arm/mach-omap2/omap_hwmod.h index 4041bad79a9a..78904017f18c 100644 --- a/arch/arm/mach-omap2/omap_hwmod.h +++ b/arch/arm/mach-omap2/omap_hwmod.h | |||
| @@ -443,8 +443,12 @@ struct omap_hwmod_omap2_prcm { | |||
| 443 | * HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT: Some IP blocks don't have a PRCM | 443 | * HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT: Some IP blocks don't have a PRCM |
| 444 | * module-level context loss register associated with them; this | 444 | * module-level context loss register associated with them; this |
| 445 | * flag bit should be set in those cases | 445 | * flag bit should be set in those cases |
| 446 | * HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET: Some IP blocks have a valid CLKCTRL | ||
| 447 | * offset of zero; this flag bit should be set in those cases to | ||
| 448 | * distinguish from hwmods that have no clkctrl offset. | ||
| 446 | */ | 449 | */ |
| 447 | #define HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT (1 << 0) | 450 | #define HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT (1 << 0) |
| 451 | #define HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET (1 << 1) | ||
| 448 | 452 | ||
| 449 | /** | 453 | /** |
| 450 | * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data | 454 | * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data |
diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c index 55c5878577f4..e2d84aa7f595 100644 --- a/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #define CLKCTRL(oh, clkctrl) ((oh).prcm.omap4.clkctrl_offs = (clkctrl)) | 29 | #define CLKCTRL(oh, clkctrl) ((oh).prcm.omap4.clkctrl_offs = (clkctrl)) |
| 30 | #define RSTCTRL(oh, rstctrl) ((oh).prcm.omap4.rstctrl_offs = (rstctrl)) | 30 | #define RSTCTRL(oh, rstctrl) ((oh).prcm.omap4.rstctrl_offs = (rstctrl)) |
| 31 | #define RSTST(oh, rstst) ((oh).prcm.omap4.rstst_offs = (rstst)) | 31 | #define RSTST(oh, rstst) ((oh).prcm.omap4.rstst_offs = (rstst)) |
| 32 | #define PRCM_FLAGS(oh, flag) ((oh).prcm.omap4.flags = (flag)) | ||
| 32 | 33 | ||
| 33 | /* | 34 | /* |
| 34 | * 'l3' class | 35 | * 'l3' class |
| @@ -1296,6 +1297,7 @@ static void omap_hwmod_am33xx_clkctrl(void) | |||
| 1296 | CLKCTRL(am33xx_i2c1_hwmod, AM33XX_CM_WKUP_I2C0_CLKCTRL_OFFSET); | 1297 | CLKCTRL(am33xx_i2c1_hwmod, AM33XX_CM_WKUP_I2C0_CLKCTRL_OFFSET); |
| 1297 | CLKCTRL(am33xx_wd_timer1_hwmod, AM33XX_CM_WKUP_WDT1_CLKCTRL_OFFSET); | 1298 | CLKCTRL(am33xx_wd_timer1_hwmod, AM33XX_CM_WKUP_WDT1_CLKCTRL_OFFSET); |
| 1298 | CLKCTRL(am33xx_rtc_hwmod, AM33XX_CM_RTC_RTC_CLKCTRL_OFFSET); | 1299 | CLKCTRL(am33xx_rtc_hwmod, AM33XX_CM_RTC_RTC_CLKCTRL_OFFSET); |
| 1300 | PRCM_FLAGS(am33xx_rtc_hwmod, HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET); | ||
| 1299 | CLKCTRL(am33xx_mmc2_hwmod, AM33XX_CM_PER_MMC2_CLKCTRL_OFFSET); | 1301 | CLKCTRL(am33xx_mmc2_hwmod, AM33XX_CM_PER_MMC2_CLKCTRL_OFFSET); |
| 1300 | CLKCTRL(am33xx_gpmc_hwmod, AM33XX_CM_PER_GPMC_CLKCTRL_OFFSET); | 1302 | CLKCTRL(am33xx_gpmc_hwmod, AM33XX_CM_PER_GPMC_CLKCTRL_OFFSET); |
| 1301 | CLKCTRL(am33xx_l4_ls_hwmod, AM33XX_CM_PER_L4LS_CLKCTRL_OFFSET); | 1303 | CLKCTRL(am33xx_l4_ls_hwmod, AM33XX_CM_PER_L4LS_CLKCTRL_OFFSET); |
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c index d72ee6185d5e..1cc4a6f3954e 100644 --- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | |||
| @@ -722,8 +722,20 @@ static struct omap_hwmod omap3xxx_dss_dispc_hwmod = { | |||
| 722 | * display serial interface controller | 722 | * display serial interface controller |
| 723 | */ | 723 | */ |
| 724 | 724 | ||
| 725 | static struct omap_hwmod_class_sysconfig omap3xxx_dsi_sysc = { | ||
| 726 | .rev_offs = 0x0000, | ||
| 727 | .sysc_offs = 0x0010, | ||
| 728 | .syss_offs = 0x0014, | ||
| 729 | .sysc_flags = (SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY | | ||
| 730 | SYSC_HAS_ENAWAKEUP | SYSC_HAS_SIDLEMODE | | ||
| 731 | SYSC_HAS_SOFTRESET | SYSS_HAS_RESET_STATUS), | ||
| 732 | .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART), | ||
| 733 | .sysc_fields = &omap_hwmod_sysc_type1, | ||
| 734 | }; | ||
| 735 | |||
| 725 | static struct omap_hwmod_class omap3xxx_dsi_hwmod_class = { | 736 | static struct omap_hwmod_class omap3xxx_dsi_hwmod_class = { |
| 726 | .name = "dsi", | 737 | .name = "dsi", |
| 738 | .sysc = &omap3xxx_dsi_sysc, | ||
| 727 | }; | 739 | }; |
| 728 | 740 | ||
| 729 | static struct omap_hwmod_irq_info omap3xxx_dsi1_irqs[] = { | 741 | static struct omap_hwmod_irq_info omap3xxx_dsi1_irqs[] = { |
diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c index c410d84b243d..66070acaa888 100644 --- a/arch/arm/mach-pxa/idp.c +++ b/arch/arm/mach-pxa/idp.c | |||
| @@ -83,7 +83,8 @@ static struct resource smc91x_resources[] = { | |||
| 83 | }; | 83 | }; |
| 84 | 84 | ||
| 85 | static struct smc91x_platdata smc91x_platdata = { | 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 | static struct platform_device smc91x_device = { | 90 | static struct platform_device smc91x_device = { |
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c index 7245f3359564..d6159f8ef0c2 100644 --- a/arch/arm/mach-pxa/lubbock.c +++ b/arch/arm/mach-pxa/lubbock.c | |||
| @@ -137,6 +137,18 @@ static struct pxa2xx_udc_mach_info udc_info __initdata = { | |||
| 137 | // no D+ pullup; lubbock can't connect/disconnect in software | 137 | // no D+ pullup; lubbock can't connect/disconnect in software |
| 138 | }; | 138 | }; |
| 139 | 139 | ||
| 140 | static void lubbock_init_pcmcia(void) | ||
| 141 | { | ||
| 142 | struct clk *clk; | ||
| 143 | |||
| 144 | /* Add an alias for the SA1111 PCMCIA clock */ | ||
| 145 | clk = clk_get_sys("pxa2xx-pcmcia", NULL); | ||
| 146 | if (!IS_ERR(clk)) { | ||
| 147 | clkdev_create(clk, NULL, "1800"); | ||
| 148 | clk_put(clk); | ||
| 149 | } | ||
| 150 | } | ||
| 151 | |||
| 140 | static struct resource sa1111_resources[] = { | 152 | static struct resource sa1111_resources[] = { |
| 141 | [0] = { | 153 | [0] = { |
| 142 | .start = 0x10000000, | 154 | .start = 0x10000000, |
| @@ -467,6 +479,8 @@ static void __init lubbock_init(void) | |||
| 467 | pxa_set_btuart_info(NULL); | 479 | pxa_set_btuart_info(NULL); |
| 468 | pxa_set_stuart_info(NULL); | 480 | pxa_set_stuart_info(NULL); |
| 469 | 481 | ||
| 482 | lubbock_init_pcmcia(); | ||
| 483 | |||
| 470 | clk_add_alias("SA1111_CLK", NULL, "GPIO11_CLK", NULL); | 484 | clk_add_alias("SA1111_CLK", NULL, "GPIO11_CLK", NULL); |
| 471 | pxa_set_udc_info(&udc_info); | 485 | pxa_set_udc_info(&udc_info); |
| 472 | pxa_set_fb_info(NULL, &sharp_lm8v31); | 486 | pxa_set_fb_info(NULL, &sharp_lm8v31); |
diff --git a/arch/arm/mach-pxa/xcep.c b/arch/arm/mach-pxa/xcep.c index 3f06cd90567a..056369ef250e 100644 --- a/arch/arm/mach-pxa/xcep.c +++ b/arch/arm/mach-pxa/xcep.c | |||
| @@ -120,7 +120,8 @@ static struct resource smc91x_resources[] = { | |||
| 120 | }; | 120 | }; |
| 121 | 121 | ||
| 122 | static struct smc91x_platdata xcep_smc91x_info = { | 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 | static struct platform_device smc91x_device = { | 127 | static struct platform_device smc91x_device = { |
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c index baf174542e36..a0ead0ae23d6 100644 --- a/arch/arm/mach-realview/core.c +++ b/arch/arm/mach-realview/core.c | |||
| @@ -93,7 +93,8 @@ static struct smsc911x_platform_config smsc911x_config = { | |||
| 93 | }; | 93 | }; |
| 94 | 94 | ||
| 95 | static struct smc91x_platdata smc91x_platdata = { | 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 | static struct platform_device realview_eth_device = { | 100 | static struct platform_device realview_eth_device = { |
diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c index cbf53bb9c814..0db46895c82a 100644 --- a/arch/arm/mach-sa1100/clock.c +++ b/arch/arm/mach-sa1100/clock.c | |||
| @@ -125,6 +125,8 @@ static unsigned long clk_36864_get_rate(struct clk *clk) | |||
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | static struct clkops clk_36864_ops = { | 127 | static struct clkops clk_36864_ops = { |
| 128 | .enable = clk_cpu_enable, | ||
| 129 | .disable = clk_cpu_disable, | ||
| 128 | .get_rate = clk_36864_get_rate, | 130 | .get_rate = clk_36864_get_rate, |
| 129 | }; | 131 | }; |
| 130 | 132 | ||
| @@ -140,9 +142,8 @@ static struct clk_lookup sa11xx_clkregs[] = { | |||
| 140 | CLKDEV_INIT(NULL, "OSTIMER0", &clk_36864), | 142 | CLKDEV_INIT(NULL, "OSTIMER0", &clk_36864), |
| 141 | }; | 143 | }; |
| 142 | 144 | ||
| 143 | static int __init sa11xx_clk_init(void) | 145 | int __init sa11xx_clk_init(void) |
| 144 | { | 146 | { |
| 145 | clkdev_add_table(sa11xx_clkregs, ARRAY_SIZE(sa11xx_clkregs)); | 147 | clkdev_add_table(sa11xx_clkregs, ARRAY_SIZE(sa11xx_clkregs)); |
| 146 | return 0; | 148 | return 0; |
| 147 | } | 149 | } |
| 148 | core_initcall(sa11xx_clk_init); | ||
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index 345e63f4eb71..3e09beddb6e8 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | 34 | ||
| 35 | #include <mach/hardware.h> | 35 | #include <mach/hardware.h> |
| 36 | #include <mach/irqs.h> | 36 | #include <mach/irqs.h> |
| 37 | #include <mach/reset.h> | ||
| 37 | 38 | ||
| 38 | #include "generic.h" | 39 | #include "generic.h" |
| 39 | #include <clocksource/pxa.h> | 40 | #include <clocksource/pxa.h> |
| @@ -95,6 +96,8 @@ static void sa1100_power_off(void) | |||
| 95 | 96 | ||
| 96 | void sa11x0_restart(enum reboot_mode mode, const char *cmd) | 97 | void sa11x0_restart(enum reboot_mode mode, const char *cmd) |
| 97 | { | 98 | { |
| 99 | clear_reset_status(RESET_STATUS_ALL); | ||
| 100 | |||
| 98 | if (mode == REBOOT_SOFT) { | 101 | if (mode == REBOOT_SOFT) { |
| 99 | /* Jump into ROM at address 0 */ | 102 | /* Jump into ROM at address 0 */ |
| 100 | soft_restart(0); | 103 | soft_restart(0); |
| @@ -388,6 +391,7 @@ void __init sa1100_init_irq(void) | |||
| 388 | sa11x0_init_irq_nodt(IRQ_GPIO0_SC, irq_resource.start); | 391 | sa11x0_init_irq_nodt(IRQ_GPIO0_SC, irq_resource.start); |
| 389 | 392 | ||
| 390 | sa1100_init_gpio(); | 393 | sa1100_init_gpio(); |
| 394 | sa11xx_clk_init(); | ||
| 391 | } | 395 | } |
| 392 | 396 | ||
| 393 | /* | 397 | /* |
diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h index 0d92e119b36b..68199b603ff7 100644 --- a/arch/arm/mach-sa1100/generic.h +++ b/arch/arm/mach-sa1100/generic.h | |||
| @@ -44,3 +44,5 @@ int sa11x0_pm_init(void); | |||
| 44 | #else | 44 | #else |
| 45 | static inline int sa11x0_pm_init(void) { return 0; } | 45 | static inline int sa11x0_pm_init(void) { return 0; } |
| 46 | #endif | 46 | #endif |
| 47 | |||
| 48 | int sa11xx_clk_init(void); | ||
diff --git a/arch/arm/mach-sa1100/pleb.c b/arch/arm/mach-sa1100/pleb.c index 1525d7b5f1b7..88149f85bc49 100644 --- a/arch/arm/mach-sa1100/pleb.c +++ b/arch/arm/mach-sa1100/pleb.c | |||
| @@ -45,7 +45,7 @@ static struct resource smc91x_resources[] = { | |||
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | static struct smc91x_platdata smc91x_platdata = { | 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 | static struct platform_device smc91x_device = { | 51 | static struct platform_device smc91x_device = { |
diff --git a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c index 62437b57813e..73e3adbc1330 100644 --- a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c +++ b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c | |||
| @@ -41,39 +41,26 @@ | |||
| 41 | 41 | ||
| 42 | #define REGULATOR_IRQ_MASK BIT(2) /* IRQ2, active low */ | 42 | #define REGULATOR_IRQ_MASK BIT(2) /* IRQ2, active low */ |
| 43 | 43 | ||
| 44 | static void __iomem *irqc; | 44 | /* start of DA9210 System Control and Event Registers */ |
| 45 | |||
| 46 | static const u8 da9063_mask_regs[] = { | ||
| 47 | DA9063_REG_IRQ_MASK_A, | ||
| 48 | DA9063_REG_IRQ_MASK_B, | ||
| 49 | DA9063_REG_IRQ_MASK_C, | ||
| 50 | DA9063_REG_IRQ_MASK_D, | ||
| 51 | }; | ||
| 52 | |||
| 53 | /* DA9210 System Control and Event Registers */ | ||
| 54 | #define DA9210_REG_MASK_A 0x54 | 45 | #define DA9210_REG_MASK_A 0x54 |
| 55 | #define DA9210_REG_MASK_B 0x55 | ||
| 56 | |||
| 57 | static const u8 da9210_mask_regs[] = { | ||
| 58 | DA9210_REG_MASK_A, | ||
| 59 | DA9210_REG_MASK_B, | ||
| 60 | }; | ||
| 61 | |||
| 62 | static void da9xxx_mask_irqs(struct i2c_client *client, const u8 regs[], | ||
| 63 | unsigned int nregs) | ||
| 64 | { | ||
| 65 | unsigned int i; | ||
| 66 | 46 | ||
| 67 | dev_info(&client->dev, "Masking %s interrupt sources\n", client->name); | 47 | static void __iomem *irqc; |
| 68 | 48 | ||
| 69 | for (i = 0; i < nregs; i++) { | 49 | /* first byte sets the memory pointer, following are consecutive reg values */ |
| 70 | int error = i2c_smbus_write_byte_data(client, regs[i], ~0); | 50 | static u8 da9063_irq_clr[] = { DA9063_REG_IRQ_MASK_A, 0xff, 0xff, 0xff, 0xff }; |
| 71 | if (error) { | 51 | static u8 da9210_irq_clr[] = { DA9210_REG_MASK_A, 0xff, 0xff }; |
| 72 | dev_err(&client->dev, "i2c error %d\n", error); | 52 | |
| 73 | return; | 53 | static struct i2c_msg da9xxx_msgs[2] = { |
| 74 | } | 54 | { |
| 75 | } | 55 | .addr = 0x58, |
| 76 | } | 56 | .len = ARRAY_SIZE(da9063_irq_clr), |
| 57 | .buf = da9063_irq_clr, | ||
| 58 | }, { | ||
| 59 | .addr = 0x68, | ||
| 60 | .len = ARRAY_SIZE(da9210_irq_clr), | ||
| 61 | .buf = da9210_irq_clr, | ||
| 62 | }, | ||
| 63 | }; | ||
| 77 | 64 | ||
| 78 | static int regulator_quirk_notify(struct notifier_block *nb, | 65 | static int regulator_quirk_notify(struct notifier_block *nb, |
| 79 | unsigned long action, void *data) | 66 | unsigned long action, void *data) |
| @@ -93,12 +80,15 @@ static int regulator_quirk_notify(struct notifier_block *nb, | |||
| 93 | client = to_i2c_client(dev); | 80 | client = to_i2c_client(dev); |
| 94 | dev_dbg(dev, "Detected %s\n", client->name); | 81 | dev_dbg(dev, "Detected %s\n", client->name); |
| 95 | 82 | ||
| 96 | if ((client->addr == 0x58 && !strcmp(client->name, "da9063"))) | 83 | if ((client->addr == 0x58 && !strcmp(client->name, "da9063")) || |
| 97 | da9xxx_mask_irqs(client, da9063_mask_regs, | 84 | (client->addr == 0x68 && !strcmp(client->name, "da9210"))) { |
| 98 | ARRAY_SIZE(da9063_mask_regs)); | 85 | int ret; |
| 99 | else if (client->addr == 0x68 && !strcmp(client->name, "da9210")) | 86 | |
| 100 | da9xxx_mask_irqs(client, da9210_mask_regs, | 87 | dev_info(&client->dev, "clearing da9063/da9210 interrupts\n"); |
| 101 | ARRAY_SIZE(da9210_mask_regs)); | 88 | ret = i2c_transfer(client->adapter, da9xxx_msgs, ARRAY_SIZE(da9xxx_msgs)); |
| 89 | if (ret != ARRAY_SIZE(da9xxx_msgs)) | ||
| 90 | dev_err(&client->dev, "i2c error %d\n", ret); | ||
| 91 | } | ||
| 102 | 92 | ||
| 103 | mon = ioread32(irqc + IRQC_MONITOR); | 93 | mon = ioread32(irqc + IRQC_MONITOR); |
| 104 | if (mon & REGULATOR_IRQ_MASK) | 94 | if (mon & REGULATOR_IRQ_MASK) |
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 6344913f0804..30fe03f95c85 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c | |||
| @@ -137,7 +137,7 @@ void __init init_default_cache_policy(unsigned long pmd) | |||
| 137 | 137 | ||
| 138 | initial_pmd_value = pmd; | 138 | initial_pmd_value = pmd; |
| 139 | 139 | ||
| 140 | pmd &= PMD_SECT_TEX(1) | PMD_SECT_BUFFERABLE | PMD_SECT_CACHEABLE; | 140 | pmd &= PMD_SECT_CACHE_MASK; |
| 141 | 141 | ||
| 142 | for (i = 0; i < ARRAY_SIZE(cache_policies); i++) | 142 | for (i = 0; i < ARRAY_SIZE(cache_policies); i++) |
| 143 | if (cache_policies[i].pmd == pmd) { | 143 | if (cache_policies[i].pmd == pmd) { |
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S index a7123b4e129d..d00d52c9de3e 100644 --- a/arch/arm/mm/proc-v7.S +++ b/arch/arm/mm/proc-v7.S | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include <asm/hwcap.h> | 16 | #include <asm/hwcap.h> |
| 17 | #include <asm/pgtable-hwdef.h> | 17 | #include <asm/pgtable-hwdef.h> |
| 18 | #include <asm/pgtable.h> | 18 | #include <asm/pgtable.h> |
| 19 | #include <asm/memory.h> | ||
| 19 | 20 | ||
| 20 | #include "proc-macros.S" | 21 | #include "proc-macros.S" |
| 21 | 22 | ||
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index b0b82f5ea338..f193414d0f6f 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c | |||
| @@ -50,7 +50,7 @@ DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu); | |||
| 50 | static struct vcpu_info __percpu *xen_vcpu_info; | 50 | static struct vcpu_info __percpu *xen_vcpu_info; |
| 51 | 51 | ||
| 52 | /* Linux <-> Xen vCPU id mapping */ | 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 | EXPORT_PER_CPU_SYMBOL(xen_vcpu_id); | 54 | EXPORT_PER_CPU_SYMBOL(xen_vcpu_id); |
| 55 | 55 | ||
| 56 | /* These are unused until we support booting "pre-ballooned" */ | 56 | /* These are unused until we support booting "pre-ballooned" */ |
| @@ -170,9 +170,6 @@ static int xen_starting_cpu(unsigned int cpu) | |||
| 170 | pr_info("Xen: initializing cpu%d\n", cpu); | 170 | pr_info("Xen: initializing cpu%d\n", cpu); |
| 171 | vcpup = per_cpu_ptr(xen_vcpu_info, cpu); | 171 | vcpup = per_cpu_ptr(xen_vcpu_info, cpu); |
| 172 | 172 | ||
| 173 | /* Direct vCPU id mapping for ARM guests. */ | ||
| 174 | per_cpu(xen_vcpu_id, cpu) = cpu; | ||
| 175 | |||
| 176 | info.mfn = virt_to_gfn(vcpup); | 173 | info.mfn = virt_to_gfn(vcpup); |
| 177 | info.offset = xen_offset_in_page(vcpup); | 174 | info.offset = xen_offset_in_page(vcpup); |
| 178 | 175 | ||
| @@ -330,6 +327,7 @@ static int __init xen_guest_init(void) | |||
| 330 | { | 327 | { |
| 331 | struct xen_add_to_physmap xatp; | 328 | struct xen_add_to_physmap xatp; |
| 332 | struct shared_info *shared_info_page = NULL; | 329 | struct shared_info *shared_info_page = NULL; |
| 330 | int cpu; | ||
| 333 | 331 | ||
| 334 | if (!xen_domain()) | 332 | if (!xen_domain()) |
| 335 | return 0; | 333 | return 0; |
| @@ -380,7 +378,8 @@ static int __init xen_guest_init(void) | |||
| 380 | return -ENOMEM; | 378 | return -ENOMEM; |
| 381 | 379 | ||
| 382 | /* Direct vCPU id mapping for ARM guests. */ | 380 | /* Direct vCPU id mapping for ARM guests. */ |
| 383 | per_cpu(xen_vcpu_id, 0) = 0; | 381 | for_each_possible_cpu(cpu) |
| 382 | per_cpu(xen_vcpu_id, cpu) = cpu; | ||
| 384 | 383 | ||
| 385 | xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames(); | 384 | xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames(); |
| 386 | if (xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn, | 385 | if (xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn, |
diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi index 445aa678f914..c2b9bcb0ef61 100644 --- a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi +++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi | |||
| @@ -255,10 +255,10 @@ | |||
| 255 | /* Local timer */ | 255 | /* Local timer */ |
| 256 | timer { | 256 | timer { |
| 257 | compatible = "arm,armv8-timer"; | 257 | compatible = "arm,armv8-timer"; |
| 258 | interrupts = <1 13 0xf01>, | 258 | interrupts = <1 13 0xf08>, |
| 259 | <1 14 0xf01>, | 259 | <1 14 0xf08>, |
| 260 | <1 11 0xf01>, | 260 | <1 11 0xf08>, |
| 261 | <1 10 0xf01>; | 261 | <1 10 0xf08>; |
| 262 | }; | 262 | }; |
| 263 | 263 | ||
| 264 | timer0: timer0@ffc03000 { | 264 | timer0: timer0@ffc03000 { |
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi index e502c24b0ac7..bf6c8d051002 100644 --- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | |||
| @@ -102,13 +102,13 @@ | |||
| 102 | timer { | 102 | timer { |
| 103 | compatible = "arm,armv8-timer"; | 103 | compatible = "arm,armv8-timer"; |
| 104 | interrupts = <GIC_PPI 13 | 104 | interrupts = <GIC_PPI 13 |
| 105 | (GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_EDGE_RISING)>, | 105 | (GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_LEVEL_LOW)>, |
| 106 | <GIC_PPI 14 | 106 | <GIC_PPI 14 |
| 107 | (GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_EDGE_RISING)>, | 107 | (GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_LEVEL_LOW)>, |
| 108 | <GIC_PPI 11 | 108 | <GIC_PPI 11 |
| 109 | (GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_EDGE_RISING)>, | 109 | (GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_LEVEL_LOW)>, |
| 110 | <GIC_PPI 10 | 110 | <GIC_PPI 10 |
| 111 | (GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_EDGE_RISING)>; | 111 | (GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_LEVEL_LOW)>; |
| 112 | }; | 112 | }; |
| 113 | 113 | ||
| 114 | xtal: xtal-clk { | 114 | xtal: xtal-clk { |
diff --git a/arch/arm64/boot/dts/apm/apm-storm.dtsi b/arch/arm64/boot/dts/apm/apm-storm.dtsi index f1c2c713f9b0..c29dab9d1834 100644 --- a/arch/arm64/boot/dts/apm/apm-storm.dtsi +++ b/arch/arm64/boot/dts/apm/apm-storm.dtsi | |||
| @@ -110,10 +110,10 @@ | |||
| 110 | 110 | ||
| 111 | timer { | 111 | timer { |
| 112 | compatible = "arm,armv8-timer"; | 112 | compatible = "arm,armv8-timer"; |
| 113 | interrupts = <1 0 0xff01>, /* Secure Phys IRQ */ | 113 | interrupts = <1 0 0xff08>, /* Secure Phys IRQ */ |
| 114 | <1 13 0xff01>, /* Non-secure Phys IRQ */ | 114 | <1 13 0xff08>, /* Non-secure Phys IRQ */ |
| 115 | <1 14 0xff01>, /* Virt IRQ */ | 115 | <1 14 0xff08>, /* Virt IRQ */ |
| 116 | <1 15 0xff01>; /* Hyp IRQ */ | 116 | <1 15 0xff08>; /* Hyp IRQ */ |
| 117 | clock-frequency = <50000000>; | 117 | clock-frequency = <50000000>; |
| 118 | }; | 118 | }; |
| 119 | 119 | ||
diff --git a/arch/arm64/boot/dts/broadcom/bcm2835-rpi.dtsi b/arch/arm64/boot/dts/broadcom/bcm2835-rpi.dtsi new file mode 120000 index 000000000000..3937b77cb310 --- /dev/null +++ b/arch/arm64/boot/dts/broadcom/bcm2835-rpi.dtsi | |||
| @@ -0,0 +1 @@ | |||
| ../../../../arm/boot/dts/bcm2835-rpi.dtsi \ No newline at end of file | |||
diff --git a/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts b/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts index 6f47dd2bb1db..7841b724e340 100644 --- a/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts +++ b/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /dts-v1/; | 1 | /dts-v1/; |
| 2 | #include "bcm2837.dtsi" | 2 | #include "bcm2837.dtsi" |
| 3 | #include "../../../../arm/boot/dts/bcm2835-rpi.dtsi" | 3 | #include "bcm2835-rpi.dtsi" |
| 4 | #include "../../../../arm/boot/dts/bcm283x-rpi-smsc9514.dtsi" | 4 | #include "bcm283x-rpi-smsc9514.dtsi" |
| 5 | 5 | ||
| 6 | / { | 6 | / { |
| 7 | compatible = "raspberrypi,3-model-b", "brcm,bcm2837"; | 7 | compatible = "raspberrypi,3-model-b", "brcm,bcm2837"; |
diff --git a/arch/arm64/boot/dts/broadcom/bcm2837.dtsi b/arch/arm64/boot/dts/broadcom/bcm2837.dtsi index f2a31d06845d..8216bbb29fe0 100644 --- a/arch/arm64/boot/dts/broadcom/bcm2837.dtsi +++ b/arch/arm64/boot/dts/broadcom/bcm2837.dtsi | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #include "../../../../arm/boot/dts/bcm283x.dtsi" | 1 | #include "bcm283x.dtsi" |
| 2 | 2 | ||
| 3 | / { | 3 | / { |
| 4 | compatible = "brcm,bcm2836"; | 4 | compatible = "brcm,bcm2836"; |
diff --git a/arch/arm64/boot/dts/broadcom/bcm283x-rpi-smsc9514.dtsi b/arch/arm64/boot/dts/broadcom/bcm283x-rpi-smsc9514.dtsi new file mode 120000 index 000000000000..dca7c057d5a5 --- /dev/null +++ b/arch/arm64/boot/dts/broadcom/bcm283x-rpi-smsc9514.dtsi | |||
| @@ -0,0 +1 @@ | |||
| ../../../../arm/boot/dts/bcm283x-rpi-smsc9514.dtsi \ No newline at end of file | |||
diff --git a/arch/arm64/boot/dts/broadcom/bcm283x.dtsi b/arch/arm64/boot/dts/broadcom/bcm283x.dtsi new file mode 120000 index 000000000000..5f54e4cab99b --- /dev/null +++ b/arch/arm64/boot/dts/broadcom/bcm283x.dtsi | |||
| @@ -0,0 +1 @@ | |||
| ../../../../arm/boot/dts/bcm283x.dtsi \ No newline at end of file | |||
diff --git a/arch/arm64/boot/dts/broadcom/ns2.dtsi b/arch/arm64/boot/dts/broadcom/ns2.dtsi index f53b0955bfd3..d4a12fad8afd 100644 --- a/arch/arm64/boot/dts/broadcom/ns2.dtsi +++ b/arch/arm64/boot/dts/broadcom/ns2.dtsi | |||
| @@ -88,13 +88,13 @@ | |||
| 88 | timer { | 88 | timer { |
| 89 | compatible = "arm,armv8-timer"; | 89 | compatible = "arm,armv8-timer"; |
| 90 | interrupts = <GIC_PPI 13 (GIC_CPU_MASK_RAW(0xff) | | 90 | interrupts = <GIC_PPI 13 (GIC_CPU_MASK_RAW(0xff) | |
| 91 | IRQ_TYPE_EDGE_RISING)>, | 91 | IRQ_TYPE_LEVEL_LOW)>, |
| 92 | <GIC_PPI 14 (GIC_CPU_MASK_RAW(0xff) | | 92 | <GIC_PPI 14 (GIC_CPU_MASK_RAW(0xff) | |
| 93 | IRQ_TYPE_EDGE_RISING)>, | 93 | IRQ_TYPE_LEVEL_LOW)>, |
| 94 | <GIC_PPI 11 (GIC_CPU_MASK_RAW(0xff) | | 94 | <GIC_PPI 11 (GIC_CPU_MASK_RAW(0xff) | |
| 95 | IRQ_TYPE_EDGE_RISING)>, | 95 | IRQ_TYPE_LEVEL_LOW)>, |
| 96 | <GIC_PPI 10 (GIC_CPU_MASK_RAW(0xff) | | 96 | <GIC_PPI 10 (GIC_CPU_MASK_RAW(0xff) | |
| 97 | IRQ_TYPE_EDGE_RISING)>; | 97 | IRQ_TYPE_LEVEL_LOW)>; |
| 98 | }; | 98 | }; |
| 99 | 99 | ||
| 100 | pmu { | 100 | pmu { |
diff --git a/arch/arm64/boot/dts/cavium/thunder-88xx.dtsi b/arch/arm64/boot/dts/cavium/thunder-88xx.dtsi index 2eb9b225f0bc..04dc8a8d1539 100644 --- a/arch/arm64/boot/dts/cavium/thunder-88xx.dtsi +++ b/arch/arm64/boot/dts/cavium/thunder-88xx.dtsi | |||
| @@ -354,10 +354,10 @@ | |||
| 354 | 354 | ||
| 355 | timer { | 355 | timer { |
| 356 | compatible = "arm,armv8-timer"; | 356 | compatible = "arm,armv8-timer"; |
| 357 | interrupts = <1 13 0xff01>, | 357 | interrupts = <1 13 4>, |
| 358 | <1 14 0xff01>, | 358 | <1 14 4>, |
| 359 | <1 11 0xff01>, | 359 | <1 11 4>, |
| 360 | <1 10 0xff01>; | 360 | <1 10 4>; |
| 361 | }; | 361 | }; |
| 362 | 362 | ||
| 363 | pmu { | 363 | pmu { |
diff --git a/arch/arm64/boot/dts/exynos/exynos7.dtsi b/arch/arm64/boot/dts/exynos/exynos7.dtsi index ca663dfe5189..162831546e18 100644 --- a/arch/arm64/boot/dts/exynos/exynos7.dtsi +++ b/arch/arm64/boot/dts/exynos/exynos7.dtsi | |||
| @@ -473,10 +473,10 @@ | |||
| 473 | 473 | ||
| 474 | timer { | 474 | timer { |
| 475 | compatible = "arm,armv8-timer"; | 475 | compatible = "arm,armv8-timer"; |
| 476 | interrupts = <1 13 0xff01>, | 476 | interrupts = <1 13 0xff08>, |
| 477 | <1 14 0xff01>, | 477 | <1 14 0xff08>, |
| 478 | <1 11 0xff01>, | 478 | <1 11 0xff08>, |
| 479 | <1 10 0xff01>; | 479 | <1 10 0xff08>; |
| 480 | }; | 480 | }; |
| 481 | 481 | ||
| 482 | pmu_system_controller: system-controller@105c0000 { | 482 | pmu_system_controller: system-controller@105c0000 { |
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi index e669fbd7f9c3..a67e210e2019 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi | |||
| @@ -119,10 +119,10 @@ | |||
| 119 | 119 | ||
| 120 | timer { | 120 | timer { |
| 121 | compatible = "arm,armv8-timer"; | 121 | compatible = "arm,armv8-timer"; |
| 122 | interrupts = <1 13 0x1>, /* Physical Secure PPI */ | 122 | interrupts = <1 13 0xf08>, /* Physical Secure PPI */ |
| 123 | <1 14 0x1>, /* Physical Non-Secure PPI */ | 123 | <1 14 0xf08>, /* Physical Non-Secure PPI */ |
| 124 | <1 11 0x1>, /* Virtual PPI */ | 124 | <1 11 0xf08>, /* Virtual PPI */ |
| 125 | <1 10 0x1>; /* Hypervisor PPI */ | 125 | <1 10 0xf08>; /* Hypervisor PPI */ |
| 126 | }; | 126 | }; |
| 127 | 127 | ||
| 128 | pmu { | 128 | pmu { |
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi index 21023a388c29..e3b6034ea5d9 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi | |||
| @@ -191,10 +191,10 @@ | |||
| 191 | 191 | ||
| 192 | timer { | 192 | timer { |
| 193 | compatible = "arm,armv8-timer"; | 193 | compatible = "arm,armv8-timer"; |
| 194 | interrupts = <1 13 0x8>, /* Physical Secure PPI, active-low */ | 194 | interrupts = <1 13 4>, /* Physical Secure PPI, active-low */ |
| 195 | <1 14 0x8>, /* Physical Non-Secure PPI, active-low */ | 195 | <1 14 4>, /* Physical Non-Secure PPI, active-low */ |
| 196 | <1 11 0x8>, /* Virtual PPI, active-low */ | 196 | <1 11 4>, /* Virtual PPI, active-low */ |
| 197 | <1 10 0x8>; /* Hypervisor PPI, active-low */ | 197 | <1 10 4>; /* Hypervisor PPI, active-low */ |
| 198 | }; | 198 | }; |
| 199 | 199 | ||
| 200 | pmu { | 200 | pmu { |
diff --git a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi index eab1a42fb934..c2a6745f168c 100644 --- a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi +++ b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi | |||
| @@ -122,10 +122,10 @@ | |||
| 122 | 122 | ||
| 123 | timer { | 123 | timer { |
| 124 | compatible = "arm,armv8-timer"; | 124 | compatible = "arm,armv8-timer"; |
| 125 | interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>, | 125 | interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, |
| 126 | <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>, | 126 | <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, |
| 127 | <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>, | 127 | <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, |
| 128 | <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>; | 128 | <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>; |
| 129 | }; | 129 | }; |
| 130 | 130 | ||
| 131 | odmi: odmi@300000 { | 131 | odmi: odmi@300000 { |
diff --git a/arch/arm64/boot/dts/rockchip/rk3368.dtsi b/arch/arm64/boot/dts/rockchip/rk3368.dtsi index d02a900378e1..4f44d1191bfd 100644 --- a/arch/arm64/boot/dts/rockchip/rk3368.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3368.dtsi | |||
| @@ -270,6 +270,8 @@ | |||
| 270 | #io-channel-cells = <1>; | 270 | #io-channel-cells = <1>; |
| 271 | clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; | 271 | clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; |
| 272 | clock-names = "saradc", "apb_pclk"; | 272 | clock-names = "saradc", "apb_pclk"; |
| 273 | resets = <&cru SRST_SARADC>; | ||
| 274 | reset-names = "saradc-apb"; | ||
| 273 | status = "disabled"; | 275 | status = "disabled"; |
| 274 | }; | 276 | }; |
| 275 | 277 | ||
diff --git a/arch/arm64/boot/dts/socionext/uniphier-ph1-ld20.dtsi b/arch/arm64/boot/dts/socionext/uniphier-ph1-ld20.dtsi index c223915f0907..d73bdc8c9115 100644 --- a/arch/arm64/boot/dts/socionext/uniphier-ph1-ld20.dtsi +++ b/arch/arm64/boot/dts/socionext/uniphier-ph1-ld20.dtsi | |||
| @@ -129,10 +129,10 @@ | |||
| 129 | 129 | ||
| 130 | timer { | 130 | timer { |
| 131 | compatible = "arm,armv8-timer"; | 131 | compatible = "arm,armv8-timer"; |
| 132 | interrupts = <1 13 0xf01>, | 132 | interrupts = <1 13 4>, |
| 133 | <1 14 0xf01>, | 133 | <1 14 4>, |
| 134 | <1 11 0xf01>, | 134 | <1 11 4>, |
| 135 | <1 10 0xf01>; | 135 | <1 10 4>; |
| 136 | }; | 136 | }; |
| 137 | 137 | ||
| 138 | soc { | 138 | soc { |
diff --git a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi index e595f22e7e4b..3e2e51fbd2bc 100644 --- a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi +++ b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi | |||
| @@ -65,10 +65,10 @@ | |||
| 65 | timer { | 65 | timer { |
| 66 | compatible = "arm,armv8-timer"; | 66 | compatible = "arm,armv8-timer"; |
| 67 | interrupt-parent = <&gic>; | 67 | interrupt-parent = <&gic>; |
| 68 | interrupts = <1 13 0xf01>, | 68 | interrupts = <1 13 0xf08>, |
| 69 | <1 14 0xf01>, | 69 | <1 14 0xf08>, |
| 70 | <1 11 0xf01>, | 70 | <1 11 0xf08>, |
| 71 | <1 10 0xf01>; | 71 | <1 10 0xf08>; |
| 72 | }; | 72 | }; |
| 73 | 73 | ||
| 74 | amba_apu { | 74 | amba_apu { |
diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h index 0a456bef8c79..2fee2f59288c 100644 --- a/arch/arm64/include/asm/percpu.h +++ b/arch/arm64/include/asm/percpu.h | |||
| @@ -199,19 +199,19 @@ static inline unsigned long __percpu_xchg(void *ptr, unsigned long val, | |||
| 199 | #define _percpu_read(pcp) \ | 199 | #define _percpu_read(pcp) \ |
| 200 | ({ \ | 200 | ({ \ |
| 201 | typeof(pcp) __retval; \ | 201 | typeof(pcp) __retval; \ |
| 202 | preempt_disable(); \ | 202 | preempt_disable_notrace(); \ |
| 203 | __retval = (typeof(pcp))__percpu_read(raw_cpu_ptr(&(pcp)), \ | 203 | __retval = (typeof(pcp))__percpu_read(raw_cpu_ptr(&(pcp)), \ |
| 204 | sizeof(pcp)); \ | 204 | sizeof(pcp)); \ |
| 205 | preempt_enable(); \ | 205 | preempt_enable_notrace(); \ |
| 206 | __retval; \ | 206 | __retval; \ |
| 207 | }) | 207 | }) |
| 208 | 208 | ||
| 209 | #define _percpu_write(pcp, val) \ | 209 | #define _percpu_write(pcp, val) \ |
| 210 | do { \ | 210 | do { \ |
| 211 | preempt_disable(); \ | 211 | preempt_disable_notrace(); \ |
| 212 | __percpu_write(raw_cpu_ptr(&(pcp)), (unsigned long)(val), \ | 212 | __percpu_write(raw_cpu_ptr(&(pcp)), (unsigned long)(val), \ |
| 213 | sizeof(pcp)); \ | 213 | sizeof(pcp)); \ |
| 214 | preempt_enable(); \ | 214 | preempt_enable_notrace(); \ |
| 215 | } while(0) \ | 215 | } while(0) \ |
| 216 | 216 | ||
| 217 | #define _pcp_protect(operation, pcp, val) \ | 217 | #define _pcp_protect(operation, pcp, val) \ |
diff --git a/arch/arm64/include/asm/spinlock.h b/arch/arm64/include/asm/spinlock.h index e875a5a551d7..89206b568cd4 100644 --- a/arch/arm64/include/asm/spinlock.h +++ b/arch/arm64/include/asm/spinlock.h | |||
| @@ -363,4 +363,14 @@ static inline int arch_read_trylock(arch_rwlock_t *rw) | |||
| 363 | #define arch_read_relax(lock) cpu_relax() | 363 | #define arch_read_relax(lock) cpu_relax() |
| 364 | #define arch_write_relax(lock) cpu_relax() | 364 | #define arch_write_relax(lock) cpu_relax() |
| 365 | 365 | ||
| 366 | /* | ||
| 367 | * Accesses appearing in program order before a spin_lock() operation | ||
| 368 | * can be reordered with accesses inside the critical section, by virtue | ||
| 369 | * of arch_spin_lock being constructed using acquire semantics. | ||
| 370 | * | ||
| 371 | * In cases where this is problematic (e.g. try_to_wake_up), an | ||
| 372 | * smp_mb__before_spinlock() can restore the required ordering. | ||
| 373 | */ | ||
| 374 | #define smp_mb__before_spinlock() smp_mb() | ||
| 375 | |||
| 366 | #endif /* __ASM_SPINLOCK_H */ | 376 | #endif /* __ASM_SPINLOCK_H */ |
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index b77f58355da1..3e7b050e99dc 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S | |||
| @@ -757,6 +757,9 @@ ENTRY(__enable_mmu) | |||
| 757 | isb | 757 | isb |
| 758 | bl __create_page_tables // recreate kernel mapping | 758 | bl __create_page_tables // recreate kernel mapping |
| 759 | 759 | ||
| 760 | tlbi vmalle1 // Remove any stale TLB entries | ||
| 761 | dsb nsh | ||
| 762 | |||
| 760 | msr sctlr_el1, x19 // re-enable the MMU | 763 | msr sctlr_el1, x19 // re-enable the MMU |
| 761 | isb | 764 | isb |
| 762 | ic iallu // flush instructions fetched | 765 | ic iallu // flush instructions fetched |
diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index ae7855f16ec2..5a84b4562603 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c | |||
| @@ -256,7 +256,7 @@ static int __hyp_text __guest_run(struct kvm_vcpu *vcpu) | |||
| 256 | 256 | ||
| 257 | /* | 257 | /* |
| 258 | * We must restore the 32-bit state before the sysregs, thanks | 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 | __sysreg32_restore_state(vcpu); | 261 | __sysreg32_restore_state(vcpu); |
| 262 | __sysreg_restore_guest_state(guest_ctxt); | 262 | __sysreg_restore_guest_state(guest_ctxt); |
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index b0b225ceca18..e51367d159d0 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c | |||
| @@ -823,14 +823,6 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, | |||
| 823 | * Architected system registers. | 823 | * Architected system registers. |
| 824 | * Important: Must be sorted ascending by Op0, Op1, CRn, CRm, Op2 | 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 | * Debug handling: We do trap most, if not all debug related system | 826 | * Debug handling: We do trap most, if not all debug related system |
| 835 | * registers. The implementation is good enough to ensure that a guest | 827 | * registers. The implementation is good enough to ensure that a guest |
| 836 | * can use these with minimal performance degradation. The drawback is | 828 | * can use these with minimal performance degradation. The drawback is |
| @@ -1360,7 +1352,7 @@ static const struct sys_reg_desc cp15_regs[] = { | |||
| 1360 | { Op1( 0), CRn(10), CRm( 3), Op2( 1), access_vm_reg, NULL, c10_AMAIR1 }, | 1352 | { Op1( 0), CRn(10), CRm( 3), Op2( 1), access_vm_reg, NULL, c10_AMAIR1 }, |
| 1361 | 1353 | ||
| 1362 | /* ICC_SRE */ | 1354 | /* ICC_SRE */ |
| 1363 | { Op1( 0), CRn(12), CRm(12), Op2( 5), trap_raz_wi }, | 1355 | { Op1( 0), CRn(12), CRm(12), Op2( 5), access_gic_sre }, |
| 1364 | 1356 | ||
| 1365 | { Op1( 0), CRn(13), CRm( 0), Op2( 1), access_vm_reg, NULL, c13_CID }, | 1357 | { Op1( 0), CRn(13), CRm( 0), Op2( 1), access_vm_reg, NULL, c13_CID }, |
| 1366 | 1358 | ||
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S index 5bb61de23201..9d37e967fa19 100644 --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S | |||
| @@ -100,7 +100,16 @@ ENTRY(cpu_do_resume) | |||
| 100 | 100 | ||
| 101 | msr tcr_el1, x8 | 101 | msr tcr_el1, x8 |
| 102 | msr vbar_el1, x9 | 102 | msr vbar_el1, x9 |
| 103 | |||
| 104 | /* | ||
| 105 | * __cpu_setup() cleared MDSCR_EL1.MDE and friends, before unmasking | ||
| 106 | * debug exceptions. By restoring MDSCR_EL1 here, we may take a debug | ||
| 107 | * exception. Mask them until local_dbg_restore() in cpu_suspend() | ||
| 108 | * resets them. | ||
| 109 | */ | ||
| 110 | disable_dbg | ||
| 103 | msr mdscr_el1, x10 | 111 | msr mdscr_el1, x10 |
| 112 | |||
| 104 | msr sctlr_el1, x12 | 113 | msr sctlr_el1, x12 |
| 105 | /* | 114 | /* |
| 106 | * Restore oslsr_el1 by writing oslar_el1 | 115 | * Restore oslsr_el1 by writing oslar_el1 |
diff --git a/arch/avr32/include/asm/uaccess.h b/arch/avr32/include/asm/uaccess.h index 68cf638faf48..b1ec1fa06463 100644 --- a/arch/avr32/include/asm/uaccess.h +++ b/arch/avr32/include/asm/uaccess.h | |||
| @@ -74,7 +74,7 @@ extern __kernel_size_t __copy_user(void *to, const void *from, | |||
| 74 | 74 | ||
| 75 | extern __kernel_size_t copy_to_user(void __user *to, const void *from, | 75 | extern __kernel_size_t copy_to_user(void __user *to, const void *from, |
| 76 | __kernel_size_t n); | 76 | __kernel_size_t n); |
| 77 | extern __kernel_size_t copy_from_user(void *to, const void __user *from, | 77 | extern __kernel_size_t ___copy_from_user(void *to, const void __user *from, |
| 78 | __kernel_size_t n); | 78 | __kernel_size_t n); |
| 79 | 79 | ||
| 80 | static inline __kernel_size_t __copy_to_user(void __user *to, const void *from, | 80 | static inline __kernel_size_t __copy_to_user(void __user *to, const void *from, |
| @@ -88,6 +88,15 @@ static inline __kernel_size_t __copy_from_user(void *to, | |||
| 88 | { | 88 | { |
| 89 | return __copy_user(to, (const void __force *)from, n); | 89 | return __copy_user(to, (const void __force *)from, n); |
| 90 | } | 90 | } |
| 91 | static inline __kernel_size_t copy_from_user(void *to, | ||
| 92 | const void __user *from, | ||
| 93 | __kernel_size_t n) | ||
| 94 | { | ||
| 95 | size_t res = ___copy_from_user(to, from, n); | ||
| 96 | if (unlikely(res)) | ||
| 97 | memset(to + (n - res), 0, res); | ||
| 98 | return res; | ||
| 99 | } | ||
| 91 | 100 | ||
| 92 | #define __copy_to_user_inatomic __copy_to_user | 101 | #define __copy_to_user_inatomic __copy_to_user |
| 93 | #define __copy_from_user_inatomic __copy_from_user | 102 | #define __copy_from_user_inatomic __copy_from_user |
diff --git a/arch/avr32/kernel/avr32_ksyms.c b/arch/avr32/kernel/avr32_ksyms.c index d93ead02daed..7c6cf14f0985 100644 --- a/arch/avr32/kernel/avr32_ksyms.c +++ b/arch/avr32/kernel/avr32_ksyms.c | |||
| @@ -36,7 +36,7 @@ EXPORT_SYMBOL(copy_page); | |||
| 36 | /* | 36 | /* |
| 37 | * Userspace access stuff. | 37 | * Userspace access stuff. |
| 38 | */ | 38 | */ |
| 39 | EXPORT_SYMBOL(copy_from_user); | 39 | EXPORT_SYMBOL(___copy_from_user); |
| 40 | EXPORT_SYMBOL(copy_to_user); | 40 | EXPORT_SYMBOL(copy_to_user); |
| 41 | EXPORT_SYMBOL(__copy_user); | 41 | EXPORT_SYMBOL(__copy_user); |
| 42 | EXPORT_SYMBOL(strncpy_from_user); | 42 | EXPORT_SYMBOL(strncpy_from_user); |
diff --git a/arch/avr32/lib/copy_user.S b/arch/avr32/lib/copy_user.S index ea59c04b07de..96a6de9d578f 100644 --- a/arch/avr32/lib/copy_user.S +++ b/arch/avr32/lib/copy_user.S | |||
| @@ -25,11 +25,11 @@ | |||
| 25 | .align 1 | 25 | .align 1 |
| 26 | .global copy_from_user | 26 | .global copy_from_user |
| 27 | .type copy_from_user, @function | 27 | .type copy_from_user, @function |
| 28 | copy_from_user: | 28 | ___copy_from_user: |
| 29 | branch_if_kernel r8, __copy_user | 29 | branch_if_kernel r8, __copy_user |
| 30 | ret_if_privileged r8, r11, r10, r10 | 30 | ret_if_privileged r8, r11, r10, r10 |
| 31 | rjmp __copy_user | 31 | rjmp __copy_user |
| 32 | .size copy_from_user, . - copy_from_user | 32 | .size ___copy_from_user, . - ___copy_from_user |
| 33 | 33 | ||
| 34 | .global copy_to_user | 34 | .global copy_to_user |
| 35 | .type copy_to_user, @function | 35 | .type copy_to_user, @function |
diff --git a/arch/blackfin/include/asm/uaccess.h b/arch/blackfin/include/asm/uaccess.h index 12f5d6851bbc..0a2a70096d8b 100644 --- a/arch/blackfin/include/asm/uaccess.h +++ b/arch/blackfin/include/asm/uaccess.h | |||
| @@ -171,11 +171,12 @@ static inline int bad_user_access_length(void) | |||
| 171 | static inline unsigned long __must_check | 171 | static inline unsigned long __must_check |
| 172 | copy_from_user(void *to, const void __user *from, unsigned long n) | 172 | copy_from_user(void *to, const void __user *from, unsigned long n) |
| 173 | { | 173 | { |
| 174 | if (access_ok(VERIFY_READ, from, n)) | 174 | if (likely(access_ok(VERIFY_READ, from, n))) { |
| 175 | memcpy(to, (const void __force *)from, n); | 175 | memcpy(to, (const void __force *)from, n); |
| 176 | else | 176 | return 0; |
| 177 | return n; | 177 | } |
| 178 | return 0; | 178 | memset(to, 0, n); |
| 179 | return n; | ||
| 179 | } | 180 | } |
| 180 | 181 | ||
| 181 | static inline unsigned long __must_check | 182 | static inline unsigned long __must_check |
diff --git a/arch/blackfin/mach-bf561/boards/cm_bf561.c b/arch/blackfin/mach-bf561/boards/cm_bf561.c index c6db52ba3a06..10c57771822d 100644 --- a/arch/blackfin/mach-bf561/boards/cm_bf561.c +++ b/arch/blackfin/mach-bf561/boards/cm_bf561.c | |||
| @@ -146,7 +146,8 @@ static struct platform_device hitachi_fb_device = { | |||
| 146 | #include <linux/smc91x.h> | 146 | #include <linux/smc91x.h> |
| 147 | 147 | ||
| 148 | static struct smc91x_platdata smc91x_info = { | 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 | .leda = RPC_LED_100_10, | 151 | .leda = RPC_LED_100_10, |
| 151 | .ledb = RPC_LED_TX_RX, | 152 | .ledb = RPC_LED_TX_RX, |
| 152 | }; | 153 | }; |
diff --git a/arch/blackfin/mach-bf561/boards/ezkit.c b/arch/blackfin/mach-bf561/boards/ezkit.c index f35525b55819..57d1c43726d9 100644 --- a/arch/blackfin/mach-bf561/boards/ezkit.c +++ b/arch/blackfin/mach-bf561/boards/ezkit.c | |||
| @@ -134,7 +134,8 @@ static struct platform_device net2272_bfin_device = { | |||
| 134 | #include <linux/smc91x.h> | 134 | #include <linux/smc91x.h> |
| 135 | 135 | ||
| 136 | static struct smc91x_platdata smc91x_info = { | 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 | .leda = RPC_LED_100_10, | 139 | .leda = RPC_LED_100_10, |
| 139 | .ledb = RPC_LED_TX_RX, | 140 | .ledb = RPC_LED_TX_RX, |
| 140 | }; | 141 | }; |
diff --git a/arch/cris/include/asm/uaccess.h b/arch/cris/include/asm/uaccess.h index e3530d0f13ee..56c7d5750abd 100644 --- a/arch/cris/include/asm/uaccess.h +++ b/arch/cris/include/asm/uaccess.h | |||
| @@ -194,30 +194,6 @@ extern unsigned long __copy_user(void __user *to, const void *from, unsigned lon | |||
| 194 | extern unsigned long __copy_user_zeroing(void *to, const void __user *from, unsigned long n); | 194 | extern unsigned long __copy_user_zeroing(void *to, const void __user *from, unsigned long n); |
| 195 | extern unsigned long __do_clear_user(void __user *to, unsigned long n); | 195 | extern unsigned long __do_clear_user(void __user *to, unsigned long n); |
| 196 | 196 | ||
| 197 | static inline unsigned long | ||
| 198 | __generic_copy_to_user(void __user *to, const void *from, unsigned long n) | ||
| 199 | { | ||
| 200 | if (access_ok(VERIFY_WRITE, to, n)) | ||
| 201 | return __copy_user(to, from, n); | ||
| 202 | return n; | ||
| 203 | } | ||
| 204 | |||
| 205 | static inline unsigned long | ||
| 206 | __generic_copy_from_user(void *to, const void __user *from, unsigned long n) | ||
| 207 | { | ||
| 208 | if (access_ok(VERIFY_READ, from, n)) | ||
| 209 | return __copy_user_zeroing(to, from, n); | ||
| 210 | return n; | ||
| 211 | } | ||
| 212 | |||
| 213 | static inline unsigned long | ||
| 214 | __generic_clear_user(void __user *to, unsigned long n) | ||
| 215 | { | ||
| 216 | if (access_ok(VERIFY_WRITE, to, n)) | ||
| 217 | return __do_clear_user(to, n); | ||
| 218 | return n; | ||
| 219 | } | ||
| 220 | |||
| 221 | static inline long | 197 | static inline long |
| 222 | __strncpy_from_user(char *dst, const char __user *src, long count) | 198 | __strncpy_from_user(char *dst, const char __user *src, long count) |
| 223 | { | 199 | { |
| @@ -282,7 +258,7 @@ __constant_copy_from_user(void *to, const void __user *from, unsigned long n) | |||
| 282 | else if (n == 24) | 258 | else if (n == 24) |
| 283 | __asm_copy_from_user_24(to, from, ret); | 259 | __asm_copy_from_user_24(to, from, ret); |
| 284 | else | 260 | else |
| 285 | ret = __generic_copy_from_user(to, from, n); | 261 | ret = __copy_user_zeroing(to, from, n); |
| 286 | 262 | ||
| 287 | return ret; | 263 | return ret; |
| 288 | } | 264 | } |
| @@ -333,7 +309,7 @@ __constant_copy_to_user(void __user *to, const void *from, unsigned long n) | |||
| 333 | else if (n == 24) | 309 | else if (n == 24) |
| 334 | __asm_copy_to_user_24(to, from, ret); | 310 | __asm_copy_to_user_24(to, from, ret); |
| 335 | else | 311 | else |
| 336 | ret = __generic_copy_to_user(to, from, n); | 312 | ret = __copy_user(to, from, n); |
| 337 | 313 | ||
| 338 | return ret; | 314 | return ret; |
| 339 | } | 315 | } |
| @@ -366,26 +342,43 @@ __constant_clear_user(void __user *to, unsigned long n) | |||
| 366 | else if (n == 24) | 342 | else if (n == 24) |
| 367 | __asm_clear_24(to, ret); | 343 | __asm_clear_24(to, ret); |
| 368 | else | 344 | else |
| 369 | ret = __generic_clear_user(to, n); | 345 | ret = __do_clear_user(to, n); |
| 370 | 346 | ||
| 371 | return ret; | 347 | return ret; |
| 372 | } | 348 | } |
| 373 | 349 | ||
| 374 | 350 | ||
| 375 | #define clear_user(to, n) \ | 351 | static inline size_t clear_user(void __user *to, size_t n) |
| 376 | (__builtin_constant_p(n) ? \ | 352 | { |
| 377 | __constant_clear_user(to, n) : \ | 353 | if (unlikely(!access_ok(VERIFY_WRITE, to, n))) |
| 378 | __generic_clear_user(to, n)) | 354 | return n; |
| 355 | if (__builtin_constant_p(n)) | ||
| 356 | return __constant_clear_user(to, n); | ||
| 357 | else | ||
| 358 | return __do_clear_user(to, n); | ||
| 359 | } | ||
| 379 | 360 | ||
| 380 | #define copy_from_user(to, from, n) \ | 361 | static inline size_t copy_from_user(void *to, const void __user *from, size_t n) |
| 381 | (__builtin_constant_p(n) ? \ | 362 | { |
| 382 | __constant_copy_from_user(to, from, n) : \ | 363 | if (unlikely(!access_ok(VERIFY_READ, from, n))) { |
| 383 | __generic_copy_from_user(to, from, n)) | 364 | memset(to, 0, n); |
| 365 | return n; | ||
| 366 | } | ||
| 367 | if (__builtin_constant_p(n)) | ||
| 368 | return __constant_copy_from_user(to, from, n); | ||
| 369 | else | ||
| 370 | return __copy_user_zeroing(to, from, n); | ||
| 371 | } | ||
| 384 | 372 | ||
| 385 | #define copy_to_user(to, from, n) \ | 373 | static inline size_t copy_to_user(void __user *to, const void *from, size_t n) |
| 386 | (__builtin_constant_p(n) ? \ | 374 | { |
| 387 | __constant_copy_to_user(to, from, n) : \ | 375 | if (unlikely(!access_ok(VERIFY_WRITE, to, n))) |
| 388 | __generic_copy_to_user(to, from, n)) | 376 | return n; |
| 377 | if (__builtin_constant_p(n)) | ||
| 378 | return __constant_copy_to_user(to, from, n); | ||
| 379 | else | ||
| 380 | return __copy_user(to, from, n); | ||
| 381 | } | ||
| 389 | 382 | ||
| 390 | /* We let the __ versions of copy_from/to_user inline, because they're often | 383 | /* We let the __ versions of copy_from/to_user inline, because they're often |
| 391 | * used in fast paths and have only a small space overhead. | 384 | * used in fast paths and have only a small space overhead. |
diff --git a/arch/frv/include/asm/uaccess.h b/arch/frv/include/asm/uaccess.h index 3ac9a59d65d4..87d9e34c5df8 100644 --- a/arch/frv/include/asm/uaccess.h +++ b/arch/frv/include/asm/uaccess.h | |||
| @@ -263,19 +263,25 @@ do { \ | |||
| 263 | extern long __memset_user(void *dst, unsigned long count); | 263 | extern long __memset_user(void *dst, unsigned long count); |
| 264 | extern long __memcpy_user(void *dst, const void *src, unsigned long count); | 264 | extern long __memcpy_user(void *dst, const void *src, unsigned long count); |
| 265 | 265 | ||
| 266 | #define clear_user(dst,count) __memset_user(____force(dst), (count)) | 266 | #define __clear_user(dst,count) __memset_user(____force(dst), (count)) |
| 267 | #define __copy_from_user_inatomic(to, from, n) __memcpy_user((to), ____force(from), (n)) | 267 | #define __copy_from_user_inatomic(to, from, n) __memcpy_user((to), ____force(from), (n)) |
| 268 | #define __copy_to_user_inatomic(to, from, n) __memcpy_user(____force(to), (from), (n)) | 268 | #define __copy_to_user_inatomic(to, from, n) __memcpy_user(____force(to), (from), (n)) |
| 269 | 269 | ||
| 270 | #else | 270 | #else |
| 271 | 271 | ||
| 272 | #define clear_user(dst,count) (memset(____force(dst), 0, (count)), 0) | 272 | #define __clear_user(dst,count) (memset(____force(dst), 0, (count)), 0) |
| 273 | #define __copy_from_user_inatomic(to, from, n) (memcpy((to), ____force(from), (n)), 0) | 273 | #define __copy_from_user_inatomic(to, from, n) (memcpy((to), ____force(from), (n)), 0) |
| 274 | #define __copy_to_user_inatomic(to, from, n) (memcpy(____force(to), (from), (n)), 0) | 274 | #define __copy_to_user_inatomic(to, from, n) (memcpy(____force(to), (from), (n)), 0) |
| 275 | 275 | ||
| 276 | #endif | 276 | #endif |
| 277 | 277 | ||
| 278 | #define __clear_user clear_user | 278 | static inline unsigned long __must_check |
| 279 | clear_user(void __user *to, unsigned long n) | ||
| 280 | { | ||
| 281 | if (likely(__access_ok(to, n))) | ||
| 282 | n = __clear_user(to, n); | ||
| 283 | return n; | ||
| 284 | } | ||
| 279 | 285 | ||
| 280 | static inline unsigned long __must_check | 286 | static inline unsigned long __must_check |
| 281 | __copy_to_user(void __user *to, const void *from, unsigned long n) | 287 | __copy_to_user(void __user *to, const void *from, unsigned long n) |
diff --git a/arch/hexagon/include/asm/uaccess.h b/arch/hexagon/include/asm/uaccess.h index f000a382bc7f..f61cfb28e9f2 100644 --- a/arch/hexagon/include/asm/uaccess.h +++ b/arch/hexagon/include/asm/uaccess.h | |||
| @@ -103,7 +103,8 @@ static inline long hexagon_strncpy_from_user(char *dst, const char __user *src, | |||
| 103 | { | 103 | { |
| 104 | long res = __strnlen_user(src, n); | 104 | long res = __strnlen_user(src, n); |
| 105 | 105 | ||
| 106 | /* return from strnlen can't be zero -- that would be rubbish. */ | 106 | if (unlikely(!res)) |
| 107 | return -EFAULT; | ||
| 107 | 108 | ||
| 108 | if (res > n) { | 109 | if (res > n) { |
| 109 | copy_from_user(dst, src, n); | 110 | copy_from_user(dst, src, n); |
diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h index 465c70982f40..bfe13196f770 100644 --- a/arch/ia64/include/asm/uaccess.h +++ b/arch/ia64/include/asm/uaccess.h | |||
| @@ -241,8 +241,7 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use | |||
| 241 | static inline unsigned long | 241 | static inline unsigned long |
| 242 | __copy_to_user (void __user *to, const void *from, unsigned long count) | 242 | __copy_to_user (void __user *to, const void *from, unsigned long count) |
| 243 | { | 243 | { |
| 244 | if (!__builtin_constant_p(count)) | 244 | check_object_size(from, count, true); |
| 245 | check_object_size(from, count, true); | ||
| 246 | 245 | ||
| 247 | return __copy_user(to, (__force void __user *) from, count); | 246 | return __copy_user(to, (__force void __user *) from, count); |
| 248 | } | 247 | } |
| @@ -250,8 +249,7 @@ __copy_to_user (void __user *to, const void *from, unsigned long count) | |||
| 250 | static inline unsigned long | 249 | static inline unsigned long |
| 251 | __copy_from_user (void *to, const void __user *from, unsigned long count) | 250 | __copy_from_user (void *to, const void __user *from, unsigned long count) |
| 252 | { | 251 | { |
| 253 | if (!__builtin_constant_p(count)) | 252 | check_object_size(to, count, false); |
| 254 | check_object_size(to, count, false); | ||
| 255 | 253 | ||
| 256 | return __copy_user((__force void __user *) to, from, count); | 254 | return __copy_user((__force void __user *) to, from, count); |
| 257 | } | 255 | } |
| @@ -265,27 +263,22 @@ __copy_from_user (void *to, const void __user *from, unsigned long count) | |||
| 265 | long __cu_len = (n); \ | 263 | long __cu_len = (n); \ |
| 266 | \ | 264 | \ |
| 267 | if (__access_ok(__cu_to, __cu_len, get_fs())) { \ | 265 | if (__access_ok(__cu_to, __cu_len, get_fs())) { \ |
| 268 | if (!__builtin_constant_p(n)) \ | 266 | check_object_size(__cu_from, __cu_len, true); \ |
| 269 | check_object_size(__cu_from, __cu_len, true); \ | ||
| 270 | __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \ | 267 | __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \ |
| 271 | } \ | 268 | } \ |
| 272 | __cu_len; \ | 269 | __cu_len; \ |
| 273 | }) | 270 | }) |
| 274 | 271 | ||
| 275 | #define copy_from_user(to, from, n) \ | 272 | static inline unsigned long |
| 276 | ({ \ | 273 | copy_from_user(void *to, const void __user *from, unsigned long n) |
| 277 | void *__cu_to = (to); \ | 274 | { |
| 278 | const void __user *__cu_from = (from); \ | 275 | check_object_size(to, n, false); |
| 279 | long __cu_len = (n); \ | 276 | if (likely(__access_ok(from, n, get_fs()))) |
| 280 | \ | 277 | n = __copy_user((__force void __user *) to, from, n); |
| 281 | __chk_user_ptr(__cu_from); \ | 278 | else |
| 282 | if (__access_ok(__cu_from, __cu_len, get_fs())) { \ | 279 | memset(to, 0, n); |
| 283 | if (!__builtin_constant_p(n)) \ | 280 | return n; |
| 284 | check_object_size(__cu_to, __cu_len, false); \ | 281 | } |
| 285 | __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \ | ||
| 286 | } \ | ||
| 287 | __cu_len; \ | ||
| 288 | }) | ||
| 289 | 282 | ||
| 290 | #define __copy_in_user(to, from, size) __copy_user((to), (from), (size)) | 283 | #define __copy_in_user(to, from, size) __copy_user((to), (from), (size)) |
| 291 | 284 | ||
diff --git a/arch/m32r/include/asm/uaccess.h b/arch/m32r/include/asm/uaccess.h index cac7014daef3..6f8982157a75 100644 --- a/arch/m32r/include/asm/uaccess.h +++ b/arch/m32r/include/asm/uaccess.h | |||
| @@ -219,7 +219,7 @@ extern int fixup_exception(struct pt_regs *regs); | |||
| 219 | #define __get_user_nocheck(x, ptr, size) \ | 219 | #define __get_user_nocheck(x, ptr, size) \ |
| 220 | ({ \ | 220 | ({ \ |
| 221 | long __gu_err = 0; \ | 221 | long __gu_err = 0; \ |
| 222 | unsigned long __gu_val; \ | 222 | unsigned long __gu_val = 0; \ |
| 223 | might_fault(); \ | 223 | might_fault(); \ |
| 224 | __get_user_size(__gu_val, (ptr), (size), __gu_err); \ | 224 | __get_user_size(__gu_val, (ptr), (size), __gu_err); \ |
| 225 | (x) = (__force __typeof__(*(ptr)))__gu_val; \ | 225 | (x) = (__force __typeof__(*(ptr)))__gu_val; \ |
diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h index 8282cbce7e39..273e61225c27 100644 --- a/arch/metag/include/asm/uaccess.h +++ b/arch/metag/include/asm/uaccess.h | |||
| @@ -204,8 +204,9 @@ extern unsigned long __must_check __copy_user_zeroing(void *to, | |||
| 204 | static inline unsigned long | 204 | static inline unsigned long |
| 205 | copy_from_user(void *to, const void __user *from, unsigned long n) | 205 | copy_from_user(void *to, const void __user *from, unsigned long n) |
| 206 | { | 206 | { |
| 207 | if (access_ok(VERIFY_READ, from, n)) | 207 | if (likely(access_ok(VERIFY_READ, from, n))) |
| 208 | return __copy_user_zeroing(to, from, n); | 208 | return __copy_user_zeroing(to, from, n); |
| 209 | memset(to, 0, n); | ||
| 209 | return n; | 210 | return n; |
| 210 | } | 211 | } |
| 211 | 212 | ||
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h index 331b0d35f89c..826676778094 100644 --- a/arch/microblaze/include/asm/uaccess.h +++ b/arch/microblaze/include/asm/uaccess.h | |||
| @@ -227,7 +227,7 @@ extern long __user_bad(void); | |||
| 227 | 227 | ||
| 228 | #define __get_user(x, ptr) \ | 228 | #define __get_user(x, ptr) \ |
| 229 | ({ \ | 229 | ({ \ |
| 230 | unsigned long __gu_val; \ | 230 | unsigned long __gu_val = 0; \ |
| 231 | /*unsigned long __gu_ptr = (unsigned long)(ptr);*/ \ | 231 | /*unsigned long __gu_ptr = (unsigned long)(ptr);*/ \ |
| 232 | long __gu_err; \ | 232 | long __gu_err; \ |
| 233 | switch (sizeof(*(ptr))) { \ | 233 | switch (sizeof(*(ptr))) { \ |
| @@ -373,10 +373,13 @@ extern long __user_bad(void); | |||
| 373 | static inline long copy_from_user(void *to, | 373 | static inline long copy_from_user(void *to, |
| 374 | const void __user *from, unsigned long n) | 374 | const void __user *from, unsigned long n) |
| 375 | { | 375 | { |
| 376 | unsigned long res = n; | ||
| 376 | might_fault(); | 377 | might_fault(); |
| 377 | if (access_ok(VERIFY_READ, from, n)) | 378 | if (likely(access_ok(VERIFY_READ, from, n))) |
| 378 | return __copy_from_user(to, from, n); | 379 | res = __copy_from_user(to, from, n); |
| 379 | return n; | 380 | if (unlikely(res)) |
| 381 | memset(to + (n - res), 0, res); | ||
| 382 | return res; | ||
| 380 | } | 383 | } |
| 381 | 384 | ||
| 382 | #define __copy_to_user(to, from, n) \ | 385 | #define __copy_to_user(to, from, n) \ |
diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h index ea0cd9773914..5f987598054f 100644 --- a/arch/mips/include/asm/page.h +++ b/arch/mips/include/asm/page.h | |||
| @@ -164,7 +164,7 @@ typedef struct { unsigned long pgprot; } pgprot_t; | |||
| 164 | */ | 164 | */ |
| 165 | static inline unsigned long ___pa(unsigned long x) | 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 | * For MIPS64 the virtual address may either be in one of | 169 | * For MIPS64 the virtual address may either be in one of |
| 170 | * the compatibility segements ckseg0 or ckseg1, or it may | 170 | * the compatibility segements ckseg0 or ckseg1, or it may |
| @@ -173,7 +173,7 @@ static inline unsigned long ___pa(unsigned long x) | |||
| 173 | return x < CKSEG0 ? XPHYSADDR(x) : CPHYSADDR(x); | 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 | * We're using the standard MIPS32 legacy memory map, ie. | 178 | * We're using the standard MIPS32 legacy memory map, ie. |
| 179 | * the address x is going to be in kseg0 or kseg1. We can | 179 | * the address x is going to be in kseg0 or kseg1. We can |
diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h index 11b965f98d95..21a2aaba20d5 100644 --- a/arch/mips/include/asm/uaccess.h +++ b/arch/mips/include/asm/uaccess.h | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
| 15 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
| 16 | #include <linux/thread_info.h> | 16 | #include <linux/thread_info.h> |
| 17 | #include <linux/string.h> | ||
| 17 | #include <asm/asm-eva.h> | 18 | #include <asm/asm-eva.h> |
| 18 | 19 | ||
| 19 | /* | 20 | /* |
| @@ -1170,6 +1171,8 @@ extern size_t __copy_in_user_eva(void *__to, const void *__from, size_t __n); | |||
| 1170 | __cu_len = __invoke_copy_from_user(__cu_to, \ | 1171 | __cu_len = __invoke_copy_from_user(__cu_to, \ |
| 1171 | __cu_from, \ | 1172 | __cu_from, \ |
| 1172 | __cu_len); \ | 1173 | __cu_len); \ |
| 1174 | } else { \ | ||
| 1175 | memset(__cu_to, 0, __cu_len); \ | ||
| 1173 | } \ | 1176 | } \ |
| 1174 | } \ | 1177 | } \ |
| 1175 | __cu_len; \ | 1178 | __cu_len; \ |
diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c index 6cfdcf55572d..121008c0fcc9 100644 --- a/arch/mips/kvm/mmu.c +++ b/arch/mips/kvm/mmu.c | |||
| @@ -40,7 +40,7 @@ static int kvm_mips_map_page(struct kvm *kvm, gfn_t gfn) | |||
| 40 | srcu_idx = srcu_read_lock(&kvm->srcu); | 40 | srcu_idx = srcu_read_lock(&kvm->srcu); |
| 41 | pfn = gfn_to_pfn(kvm, gfn); | 41 | pfn = gfn_to_pfn(kvm, gfn); |
| 42 | 42 | ||
| 43 | if (is_error_pfn(pfn)) { | 43 | if (is_error_noslot_pfn(pfn)) { |
| 44 | kvm_err("Couldn't get pfn for gfn %#llx!\n", gfn); | 44 | kvm_err("Couldn't get pfn for gfn %#llx!\n", gfn); |
| 45 | err = -EFAULT; | 45 | err = -EFAULT; |
| 46 | goto out; | 46 | goto out; |
diff --git a/arch/mn10300/include/asm/uaccess.h b/arch/mn10300/include/asm/uaccess.h index 20f7bf6de384..d012e877a95a 100644 --- a/arch/mn10300/include/asm/uaccess.h +++ b/arch/mn10300/include/asm/uaccess.h | |||
| @@ -166,6 +166,7 @@ struct __large_struct { unsigned long buf[100]; }; | |||
| 166 | "2:\n" \ | 166 | "2:\n" \ |
| 167 | " .section .fixup,\"ax\"\n" \ | 167 | " .section .fixup,\"ax\"\n" \ |
| 168 | "3:\n\t" \ | 168 | "3:\n\t" \ |
| 169 | " mov 0,%1\n" \ | ||
| 169 | " mov %3,%0\n" \ | 170 | " mov %3,%0\n" \ |
| 170 | " jmp 2b\n" \ | 171 | " jmp 2b\n" \ |
| 171 | " .previous\n" \ | 172 | " .previous\n" \ |
diff --git a/arch/mn10300/lib/usercopy.c b/arch/mn10300/lib/usercopy.c index 7826e6c364e7..ce8899e5e171 100644 --- a/arch/mn10300/lib/usercopy.c +++ b/arch/mn10300/lib/usercopy.c | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | * as published by the Free Software Foundation; either version | 9 | * as published by the Free Software Foundation; either version |
| 10 | * 2 of the Licence, or (at your option) any later version. | 10 | * 2 of the Licence, or (at your option) any later version. |
| 11 | */ | 11 | */ |
| 12 | #include <asm/uaccess.h> | 12 | #include <linux/uaccess.h> |
| 13 | 13 | ||
| 14 | unsigned long | 14 | unsigned long |
| 15 | __generic_copy_to_user(void *to, const void *from, unsigned long n) | 15 | __generic_copy_to_user(void *to, const void *from, unsigned long n) |
| @@ -24,6 +24,8 @@ __generic_copy_from_user(void *to, const void *from, unsigned long n) | |||
| 24 | { | 24 | { |
| 25 | if (access_ok(VERIFY_READ, from, n)) | 25 | if (access_ok(VERIFY_READ, from, n)) |
| 26 | __copy_user_zeroing(to, from, n); | 26 | __copy_user_zeroing(to, from, n); |
| 27 | else | ||
| 28 | memset(to, 0, n); | ||
| 27 | return n; | 29 | return n; |
| 28 | } | 30 | } |
| 29 | 31 | ||
diff --git a/arch/nios2/include/asm/uaccess.h b/arch/nios2/include/asm/uaccess.h index caa51ff85a3c..0ab82324c817 100644 --- a/arch/nios2/include/asm/uaccess.h +++ b/arch/nios2/include/asm/uaccess.h | |||
| @@ -102,9 +102,12 @@ extern long __copy_to_user(void __user *to, const void *from, unsigned long n); | |||
| 102 | static inline long copy_from_user(void *to, const void __user *from, | 102 | static inline long copy_from_user(void *to, const void __user *from, |
| 103 | unsigned long n) | 103 | unsigned long n) |
| 104 | { | 104 | { |
| 105 | if (!access_ok(VERIFY_READ, from, n)) | 105 | unsigned long res = n; |
| 106 | return n; | 106 | if (access_ok(VERIFY_READ, from, n)) |
| 107 | return __copy_from_user(to, from, n); | 107 | res = __copy_from_user(to, from, n); |
| 108 | if (unlikely(res)) | ||
| 109 | memset(to + (n - res), 0, res); | ||
| 110 | return res; | ||
| 108 | } | 111 | } |
| 109 | 112 | ||
| 110 | static inline long copy_to_user(void __user *to, const void *from, | 113 | static inline long copy_to_user(void __user *to, const void *from, |
| @@ -139,7 +142,7 @@ extern long strnlen_user(const char __user *s, long n); | |||
| 139 | 142 | ||
| 140 | #define __get_user_unknown(val, size, ptr, err) do { \ | 143 | #define __get_user_unknown(val, size, ptr, err) do { \ |
| 141 | err = 0; \ | 144 | err = 0; \ |
| 142 | if (copy_from_user(&(val), ptr, size)) { \ | 145 | if (__copy_from_user(&(val), ptr, size)) { \ |
| 143 | err = -EFAULT; \ | 146 | err = -EFAULT; \ |
| 144 | } \ | 147 | } \ |
| 145 | } while (0) | 148 | } while (0) |
| @@ -166,7 +169,7 @@ do { \ | |||
| 166 | ({ \ | 169 | ({ \ |
| 167 | long __gu_err = -EFAULT; \ | 170 | long __gu_err = -EFAULT; \ |
| 168 | const __typeof__(*(ptr)) __user *__gu_ptr = (ptr); \ | 171 | const __typeof__(*(ptr)) __user *__gu_ptr = (ptr); \ |
| 169 | unsigned long __gu_val; \ | 172 | unsigned long __gu_val = 0; \ |
| 170 | __get_user_common(__gu_val, sizeof(*(ptr)), __gu_ptr, __gu_err);\ | 173 | __get_user_common(__gu_val, sizeof(*(ptr)), __gu_ptr, __gu_err);\ |
| 171 | (x) = (__force __typeof__(x))__gu_val; \ | 174 | (x) = (__force __typeof__(x))__gu_val; \ |
| 172 | __gu_err; \ | 175 | __gu_err; \ |
diff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/asm/uaccess.h index a6bd07ca3d6c..cbad29b5a131 100644 --- a/arch/openrisc/include/asm/uaccess.h +++ b/arch/openrisc/include/asm/uaccess.h | |||
| @@ -273,28 +273,20 @@ __copy_tofrom_user(void *to, const void *from, unsigned long size); | |||
| 273 | static inline unsigned long | 273 | static inline unsigned long |
| 274 | copy_from_user(void *to, const void *from, unsigned long n) | 274 | copy_from_user(void *to, const void *from, unsigned long n) |
| 275 | { | 275 | { |
| 276 | unsigned long over; | 276 | unsigned long res = n; |
| 277 | 277 | ||
| 278 | if (access_ok(VERIFY_READ, from, n)) | 278 | if (likely(access_ok(VERIFY_READ, from, n))) |
| 279 | return __copy_tofrom_user(to, from, n); | 279 | n = __copy_tofrom_user(to, from, n); |
| 280 | if ((unsigned long)from < TASK_SIZE) { | 280 | if (unlikely(res)) |
| 281 | over = (unsigned long)from + n - TASK_SIZE; | 281 | memset(to + (n - res), 0, res); |
| 282 | return __copy_tofrom_user(to, from, n - over) + over; | 282 | return res; |
| 283 | } | ||
| 284 | return n; | ||
| 285 | } | 283 | } |
| 286 | 284 | ||
| 287 | static inline unsigned long | 285 | static inline unsigned long |
| 288 | copy_to_user(void *to, const void *from, unsigned long n) | 286 | copy_to_user(void *to, const void *from, unsigned long n) |
| 289 | { | 287 | { |
| 290 | unsigned long over; | 288 | if (likely(access_ok(VERIFY_WRITE, to, n))) |
| 291 | 289 | n = __copy_tofrom_user(to, from, n); | |
| 292 | if (access_ok(VERIFY_WRITE, to, n)) | ||
| 293 | return __copy_tofrom_user(to, from, n); | ||
| 294 | if ((unsigned long)to < TASK_SIZE) { | ||
| 295 | over = (unsigned long)to + n - TASK_SIZE; | ||
| 296 | return __copy_tofrom_user(to, from, n - over) + over; | ||
| 297 | } | ||
| 298 | return n; | 290 | return n; |
| 299 | } | 291 | } |
| 300 | 292 | ||
| @@ -303,13 +295,8 @@ extern unsigned long __clear_user(void *addr, unsigned long size); | |||
| 303 | static inline __must_check unsigned long | 295 | static inline __must_check unsigned long |
| 304 | clear_user(void *addr, unsigned long size) | 296 | clear_user(void *addr, unsigned long size) |
| 305 | { | 297 | { |
| 306 | 298 | if (likely(access_ok(VERIFY_WRITE, addr, size))) | |
| 307 | if (access_ok(VERIFY_WRITE, addr, size)) | 299 | size = __clear_user(addr, size); |
| 308 | return __clear_user(addr, size); | ||
| 309 | if ((unsigned long)addr < TASK_SIZE) { | ||
| 310 | unsigned long over = (unsigned long)addr + size - TASK_SIZE; | ||
| 311 | return __clear_user(addr, size - over) + over; | ||
| 312 | } | ||
| 313 | return size; | 300 | return size; |
| 314 | } | 301 | } |
| 315 | 302 | ||
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index cd8778103165..af12c2db9bb8 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | config PARISC | 1 | config PARISC |
| 2 | def_bool y | 2 | def_bool y |
| 3 | select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS | ||
| 4 | select ARCH_MIGHT_HAVE_PC_PARPORT | 3 | select ARCH_MIGHT_HAVE_PC_PARPORT |
| 5 | select HAVE_IDE | 4 | select HAVE_IDE |
| 6 | select HAVE_OPROFILE | 5 | select HAVE_OPROFILE |
diff --git a/arch/parisc/configs/c8000_defconfig b/arch/parisc/configs/c8000_defconfig index 1a8f6f95689e..f6a4c016304b 100644 --- a/arch/parisc/configs/c8000_defconfig +++ b/arch/parisc/configs/c8000_defconfig | |||
| @@ -245,7 +245,6 @@ CONFIG_DEBUG_RT_MUTEXES=y | |||
| 245 | CONFIG_PROVE_RCU_DELAY=y | 245 | CONFIG_PROVE_RCU_DELAY=y |
| 246 | CONFIG_DEBUG_BLOCK_EXT_DEVT=y | 246 | CONFIG_DEBUG_BLOCK_EXT_DEVT=y |
| 247 | CONFIG_LATENCYTOP=y | 247 | CONFIG_LATENCYTOP=y |
| 248 | CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y | ||
| 249 | CONFIG_KEYS=y | 248 | CONFIG_KEYS=y |
| 250 | # CONFIG_CRYPTO_HW is not set | 249 | # CONFIG_CRYPTO_HW is not set |
| 251 | CONFIG_FONTS=y | 250 | CONFIG_FONTS=y |
diff --git a/arch/parisc/configs/generic-64bit_defconfig b/arch/parisc/configs/generic-64bit_defconfig index 7e0792658952..c564e6e1fa23 100644 --- a/arch/parisc/configs/generic-64bit_defconfig +++ b/arch/parisc/configs/generic-64bit_defconfig | |||
| @@ -291,7 +291,6 @@ CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC=y | |||
| 291 | CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y | 291 | CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y |
| 292 | # CONFIG_SCHED_DEBUG is not set | 292 | # CONFIG_SCHED_DEBUG is not set |
| 293 | CONFIG_TIMER_STATS=y | 293 | CONFIG_TIMER_STATS=y |
| 294 | CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y | ||
| 295 | CONFIG_CRYPTO_MANAGER=y | 294 | CONFIG_CRYPTO_MANAGER=y |
| 296 | CONFIG_CRYPTO_ECB=m | 295 | CONFIG_CRYPTO_ECB=m |
| 297 | CONFIG_CRYPTO_PCBC=m | 296 | CONFIG_CRYPTO_PCBC=m |
diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h index 0f59fd9ca205..482847865dac 100644 --- a/arch/parisc/include/asm/uaccess.h +++ b/arch/parisc/include/asm/uaccess.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <asm-generic/uaccess-unaligned.h> | 10 | #include <asm-generic/uaccess-unaligned.h> |
| 11 | 11 | ||
| 12 | #include <linux/bug.h> | 12 | #include <linux/bug.h> |
| 13 | #include <linux/string.h> | ||
| 13 | 14 | ||
| 14 | #define VERIFY_READ 0 | 15 | #define VERIFY_READ 0 |
| 15 | #define VERIFY_WRITE 1 | 16 | #define VERIFY_WRITE 1 |
| @@ -208,26 +209,30 @@ unsigned long copy_in_user(void __user *dst, const void __user *src, unsigned lo | |||
| 208 | #define __copy_to_user_inatomic __copy_to_user | 209 | #define __copy_to_user_inatomic __copy_to_user |
| 209 | #define __copy_from_user_inatomic __copy_from_user | 210 | #define __copy_from_user_inatomic __copy_from_user |
| 210 | 211 | ||
| 211 | extern void copy_from_user_overflow(void) | 212 | extern void __compiletime_error("usercopy buffer size is too small") |
| 212 | #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS | 213 | __bad_copy_user(void); |
| 213 | __compiletime_error("copy_from_user() buffer size is not provably correct") | 214 | |
| 214 | #else | 215 | static inline void copy_user_overflow(int size, unsigned long count) |
| 215 | __compiletime_warning("copy_from_user() buffer size is not provably correct") | 216 | { |
| 216 | #endif | 217 | WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count); |
| 217 | ; | 218 | } |
| 218 | 219 | ||
| 219 | static inline unsigned long __must_check copy_from_user(void *to, | 220 | static inline unsigned long __must_check copy_from_user(void *to, |
| 220 | const void __user *from, | 221 | const void __user *from, |
| 221 | unsigned long n) | 222 | unsigned long n) |
| 222 | { | 223 | { |
| 223 | int sz = __compiletime_object_size(to); | 224 | int sz = __compiletime_object_size(to); |
| 224 | int ret = -EFAULT; | 225 | unsigned long ret = n; |
| 225 | 226 | ||
| 226 | if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n)) | 227 | if (likely(sz == -1 || sz >= n)) |
| 227 | ret = __copy_from_user(to, from, n); | 228 | ret = __copy_from_user(to, from, n); |
| 228 | else | 229 | else if (!__builtin_constant_p(n)) |
| 229 | copy_from_user_overflow(); | 230 | copy_user_overflow(sz, n); |
| 231 | else | ||
| 232 | __bad_copy_user(); | ||
| 230 | 233 | ||
| 234 | if (unlikely(ret)) | ||
| 235 | memset(to + (n - ret), 0, ret); | ||
| 231 | return ret; | 236 | return ret; |
| 232 | } | 237 | } |
| 233 | 238 | ||
diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index c1dc6c14deb8..c266227fdd5b 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h | |||
| @@ -308,40 +308,21 @@ extern unsigned long __copy_tofrom_user(void __user *to, | |||
| 308 | static inline unsigned long copy_from_user(void *to, | 308 | static inline unsigned long copy_from_user(void *to, |
| 309 | const void __user *from, unsigned long n) | 309 | const void __user *from, unsigned long n) |
| 310 | { | 310 | { |
| 311 | unsigned long over; | 311 | if (likely(access_ok(VERIFY_READ, from, n))) { |
| 312 | 312 | check_object_size(to, n, false); | |
| 313 | if (access_ok(VERIFY_READ, from, n)) { | ||
| 314 | if (!__builtin_constant_p(n)) | ||
| 315 | check_object_size(to, n, false); | ||
| 316 | return __copy_tofrom_user((__force void __user *)to, from, n); | 313 | return __copy_tofrom_user((__force void __user *)to, from, n); |
| 317 | } | 314 | } |
| 318 | if ((unsigned long)from < TASK_SIZE) { | 315 | memset(to, 0, n); |
| 319 | over = (unsigned long)from + n - TASK_SIZE; | ||
| 320 | if (!__builtin_constant_p(n - over)) | ||
| 321 | check_object_size(to, n - over, false); | ||
| 322 | return __copy_tofrom_user((__force void __user *)to, from, | ||
| 323 | n - over) + over; | ||
| 324 | } | ||
| 325 | return n; | 316 | return n; |
| 326 | } | 317 | } |
| 327 | 318 | ||
| 328 | static inline unsigned long copy_to_user(void __user *to, | 319 | static inline unsigned long copy_to_user(void __user *to, |
| 329 | const void *from, unsigned long n) | 320 | const void *from, unsigned long n) |
| 330 | { | 321 | { |
| 331 | unsigned long over; | ||
| 332 | |||
| 333 | if (access_ok(VERIFY_WRITE, to, n)) { | 322 | if (access_ok(VERIFY_WRITE, to, n)) { |
| 334 | if (!__builtin_constant_p(n)) | 323 | check_object_size(from, n, true); |
| 335 | check_object_size(from, n, true); | ||
| 336 | return __copy_tofrom_user(to, (__force void __user *)from, n); | 324 | return __copy_tofrom_user(to, (__force void __user *)from, n); |
| 337 | } | 325 | } |
| 338 | if ((unsigned long)to < TASK_SIZE) { | ||
| 339 | over = (unsigned long)to + n - TASK_SIZE; | ||
| 340 | if (!__builtin_constant_p(n)) | ||
| 341 | check_object_size(from, n - over, true); | ||
| 342 | return __copy_tofrom_user(to, (__force void __user *)from, | ||
| 343 | n - over) + over; | ||
| 344 | } | ||
| 345 | return n; | 326 | return n; |
| 346 | } | 327 | } |
| 347 | 328 | ||
| @@ -383,8 +364,7 @@ static inline unsigned long __copy_from_user_inatomic(void *to, | |||
| 383 | return 0; | 364 | return 0; |
| 384 | } | 365 | } |
| 385 | 366 | ||
| 386 | if (!__builtin_constant_p(n)) | 367 | check_object_size(to, n, false); |
| 387 | check_object_size(to, n, false); | ||
| 388 | 368 | ||
| 389 | return __copy_tofrom_user((__force void __user *)to, from, n); | 369 | return __copy_tofrom_user((__force void __user *)to, from, n); |
| 390 | } | 370 | } |
| @@ -412,8 +392,8 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to, | |||
| 412 | if (ret == 0) | 392 | if (ret == 0) |
| 413 | return 0; | 393 | return 0; |
| 414 | } | 394 | } |
| 415 | if (!__builtin_constant_p(n)) | 395 | |
| 416 | check_object_size(from, n, true); | 396 | check_object_size(from, n, true); |
| 417 | 397 | ||
| 418 | return __copy_tofrom_user(to, (__force const void __user *)from, n); | 398 | return __copy_tofrom_user(to, (__force const void __user *)from, n); |
| 419 | } | 399 | } |
| @@ -439,10 +419,6 @@ static inline unsigned long clear_user(void __user *addr, unsigned long size) | |||
| 439 | might_fault(); | 419 | might_fault(); |
| 440 | if (likely(access_ok(VERIFY_WRITE, addr, size))) | 420 | if (likely(access_ok(VERIFY_WRITE, addr, size))) |
| 441 | return __clear_user(addr, size); | 421 | return __clear_user(addr, size); |
| 442 | if ((unsigned long)addr < TASK_SIZE) { | ||
| 443 | unsigned long over = (unsigned long)addr + size - TASK_SIZE; | ||
| 444 | return __clear_user(addr, size - over) + over; | ||
| 445 | } | ||
| 446 | return size; | 422 | return size; |
| 447 | } | 423 | } |
| 448 | 424 | ||
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index e751fe25d6ab..c109f073d454 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig | |||
| @@ -68,7 +68,6 @@ config DEBUG_RODATA | |||
| 68 | config S390 | 68 | config S390 |
| 69 | def_bool y | 69 | def_bool y |
| 70 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE | 70 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE |
| 71 | select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS | ||
| 72 | select ARCH_HAS_DEVMEM_IS_ALLOWED | 71 | select ARCH_HAS_DEVMEM_IS_ALLOWED |
| 73 | select ARCH_HAS_ELF_RANDOMIZE | 72 | select ARCH_HAS_ELF_RANDOMIZE |
| 74 | select ARCH_HAS_GCOV_PROFILE_ALL | 73 | select ARCH_HAS_GCOV_PROFILE_ALL |
diff --git a/arch/s390/configs/default_defconfig b/arch/s390/configs/default_defconfig index 26e0c7f08814..412b1bd21029 100644 --- a/arch/s390/configs/default_defconfig +++ b/arch/s390/configs/default_defconfig | |||
| @@ -602,7 +602,6 @@ CONFIG_FAIL_FUTEX=y | |||
| 602 | CONFIG_FAULT_INJECTION_DEBUG_FS=y | 602 | CONFIG_FAULT_INJECTION_DEBUG_FS=y |
| 603 | CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y | 603 | CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y |
| 604 | CONFIG_LATENCYTOP=y | 604 | CONFIG_LATENCYTOP=y |
| 605 | CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y | ||
| 606 | CONFIG_IRQSOFF_TRACER=y | 605 | CONFIG_IRQSOFF_TRACER=y |
| 607 | CONFIG_PREEMPT_TRACER=y | 606 | CONFIG_PREEMPT_TRACER=y |
| 608 | CONFIG_SCHED_TRACER=y | 607 | CONFIG_SCHED_TRACER=y |
diff --git a/arch/s390/configs/gcov_defconfig b/arch/s390/configs/gcov_defconfig index 24879dab47bc..bec279eb4b93 100644 --- a/arch/s390/configs/gcov_defconfig +++ b/arch/s390/configs/gcov_defconfig | |||
| @@ -552,7 +552,6 @@ CONFIG_NOTIFIER_ERROR_INJECTION=m | |||
| 552 | CONFIG_CPU_NOTIFIER_ERROR_INJECT=m | 552 | CONFIG_CPU_NOTIFIER_ERROR_INJECT=m |
| 553 | CONFIG_PM_NOTIFIER_ERROR_INJECT=m | 553 | CONFIG_PM_NOTIFIER_ERROR_INJECT=m |
| 554 | CONFIG_LATENCYTOP=y | 554 | CONFIG_LATENCYTOP=y |
| 555 | CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y | ||
| 556 | CONFIG_BLK_DEV_IO_TRACE=y | 555 | CONFIG_BLK_DEV_IO_TRACE=y |
| 557 | # CONFIG_KPROBE_EVENT is not set | 556 | # CONFIG_KPROBE_EVENT is not set |
| 558 | CONFIG_TRACE_ENUM_MAP_FILE=y | 557 | CONFIG_TRACE_ENUM_MAP_FILE=y |
diff --git a/arch/s390/configs/performance_defconfig b/arch/s390/configs/performance_defconfig index a5c1e5f2a0ca..1751446a5bbb 100644 --- a/arch/s390/configs/performance_defconfig +++ b/arch/s390/configs/performance_defconfig | |||
| @@ -549,7 +549,6 @@ CONFIG_TIMER_STATS=y | |||
| 549 | CONFIG_RCU_TORTURE_TEST=m | 549 | CONFIG_RCU_TORTURE_TEST=m |
| 550 | CONFIG_RCU_CPU_STALL_TIMEOUT=60 | 550 | CONFIG_RCU_CPU_STALL_TIMEOUT=60 |
| 551 | CONFIG_LATENCYTOP=y | 551 | CONFIG_LATENCYTOP=y |
| 552 | CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y | ||
| 553 | CONFIG_SCHED_TRACER=y | 552 | CONFIG_SCHED_TRACER=y |
| 554 | CONFIG_FTRACE_SYSCALLS=y | 553 | CONFIG_FTRACE_SYSCALLS=y |
| 555 | CONFIG_STACK_TRACER=y | 554 | CONFIG_STACK_TRACER=y |
diff --git a/arch/s390/defconfig b/arch/s390/defconfig index 73610f2e3b4f..2d40ef0a6295 100644 --- a/arch/s390/defconfig +++ b/arch/s390/defconfig | |||
| @@ -172,7 +172,6 @@ CONFIG_DEBUG_NOTIFIERS=y | |||
| 172 | CONFIG_RCU_CPU_STALL_TIMEOUT=60 | 172 | CONFIG_RCU_CPU_STALL_TIMEOUT=60 |
| 173 | CONFIG_RCU_TRACE=y | 173 | CONFIG_RCU_TRACE=y |
| 174 | CONFIG_LATENCYTOP=y | 174 | CONFIG_LATENCYTOP=y |
| 175 | CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y | ||
| 176 | CONFIG_SCHED_TRACER=y | 175 | CONFIG_SCHED_TRACER=y |
| 177 | CONFIG_FTRACE_SYSCALLS=y | 176 | CONFIG_FTRACE_SYSCALLS=y |
| 178 | CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP=y | 177 | CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP=y |
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h index 9b49cf1daa8f..52d7c8709279 100644 --- a/arch/s390/include/asm/uaccess.h +++ b/arch/s390/include/asm/uaccess.h | |||
| @@ -266,28 +266,28 @@ int __put_user_bad(void) __attribute__((noreturn)); | |||
| 266 | __chk_user_ptr(ptr); \ | 266 | __chk_user_ptr(ptr); \ |
| 267 | switch (sizeof(*(ptr))) { \ | 267 | switch (sizeof(*(ptr))) { \ |
| 268 | case 1: { \ | 268 | case 1: { \ |
| 269 | unsigned char __x; \ | 269 | unsigned char __x = 0; \ |
| 270 | __gu_err = __get_user_fn(&__x, ptr, \ | 270 | __gu_err = __get_user_fn(&__x, ptr, \ |
| 271 | sizeof(*(ptr))); \ | 271 | sizeof(*(ptr))); \ |
| 272 | (x) = *(__force __typeof__(*(ptr)) *) &__x; \ | 272 | (x) = *(__force __typeof__(*(ptr)) *) &__x; \ |
| 273 | break; \ | 273 | break; \ |
| 274 | }; \ | 274 | }; \ |
| 275 | case 2: { \ | 275 | case 2: { \ |
| 276 | unsigned short __x; \ | 276 | unsigned short __x = 0; \ |
| 277 | __gu_err = __get_user_fn(&__x, ptr, \ | 277 | __gu_err = __get_user_fn(&__x, ptr, \ |
| 278 | sizeof(*(ptr))); \ | 278 | sizeof(*(ptr))); \ |
| 279 | (x) = *(__force __typeof__(*(ptr)) *) &__x; \ | 279 | (x) = *(__force __typeof__(*(ptr)) *) &__x; \ |
| 280 | break; \ | 280 | break; \ |
| 281 | }; \ | 281 | }; \ |
| 282 | case 4: { \ | 282 | case 4: { \ |
| 283 | unsigned int __x; \ | 283 | unsigned int __x = 0; \ |
| 284 | __gu_err = __get_user_fn(&__x, ptr, \ | 284 | __gu_err = __get_user_fn(&__x, ptr, \ |
| 285 | sizeof(*(ptr))); \ | 285 | sizeof(*(ptr))); \ |
| 286 | (x) = *(__force __typeof__(*(ptr)) *) &__x; \ | 286 | (x) = *(__force __typeof__(*(ptr)) *) &__x; \ |
| 287 | break; \ | 287 | break; \ |
| 288 | }; \ | 288 | }; \ |
| 289 | case 8: { \ | 289 | case 8: { \ |
| 290 | unsigned long long __x; \ | 290 | unsigned long long __x = 0; \ |
| 291 | __gu_err = __get_user_fn(&__x, ptr, \ | 291 | __gu_err = __get_user_fn(&__x, ptr, \ |
| 292 | sizeof(*(ptr))); \ | 292 | sizeof(*(ptr))); \ |
| 293 | (x) = *(__force __typeof__(*(ptr)) *) &__x; \ | 293 | (x) = *(__force __typeof__(*(ptr)) *) &__x; \ |
| @@ -311,6 +311,14 @@ int __get_user_bad(void) __attribute__((noreturn)); | |||
| 311 | #define __put_user_unaligned __put_user | 311 | #define __put_user_unaligned __put_user |
| 312 | #define __get_user_unaligned __get_user | 312 | #define __get_user_unaligned __get_user |
| 313 | 313 | ||
| 314 | extern void __compiletime_error("usercopy buffer size is too small") | ||
| 315 | __bad_copy_user(void); | ||
| 316 | |||
| 317 | static inline void copy_user_overflow(int size, unsigned long count) | ||
| 318 | { | ||
| 319 | WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count); | ||
| 320 | } | ||
| 321 | |||
| 314 | /** | 322 | /** |
| 315 | * copy_to_user: - Copy a block of data into user space. | 323 | * copy_to_user: - Copy a block of data into user space. |
| 316 | * @to: Destination address, in user space. | 324 | * @to: Destination address, in user space. |
| @@ -332,12 +340,6 @@ copy_to_user(void __user *to, const void *from, unsigned long n) | |||
| 332 | return __copy_to_user(to, from, n); | 340 | return __copy_to_user(to, from, n); |
| 333 | } | 341 | } |
| 334 | 342 | ||
| 335 | void copy_from_user_overflow(void) | ||
| 336 | #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS | ||
| 337 | __compiletime_warning("copy_from_user() buffer size is not provably correct") | ||
| 338 | #endif | ||
| 339 | ; | ||
| 340 | |||
| 341 | /** | 343 | /** |
| 342 | * copy_from_user: - Copy a block of data from user space. | 344 | * copy_from_user: - Copy a block of data from user space. |
| 343 | * @to: Destination address, in kernel space. | 345 | * @to: Destination address, in kernel space. |
| @@ -362,7 +364,10 @@ copy_from_user(void *to, const void __user *from, unsigned long n) | |||
| 362 | 364 | ||
| 363 | might_fault(); | 365 | might_fault(); |
| 364 | if (unlikely(sz != -1 && sz < n)) { | 366 | if (unlikely(sz != -1 && sz < n)) { |
| 365 | copy_from_user_overflow(); | 367 | if (!__builtin_constant_p(n)) |
| 368 | copy_user_overflow(sz, n); | ||
| 369 | else | ||
| 370 | __bad_copy_user(); | ||
| 366 | return n; | 371 | return n; |
| 367 | } | 372 | } |
| 368 | return __copy_from_user(to, from, n); | 373 | return __copy_from_user(to, from, n); |
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index ba5f456edaa9..7f7ba5f23f13 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c | |||
| @@ -204,11 +204,9 @@ static void __init conmode_default(void) | |||
| 204 | #endif | 204 | #endif |
| 205 | } | 205 | } |
| 206 | } else if (MACHINE_IS_KVM) { | 206 | } else if (MACHINE_IS_KVM) { |
| 207 | if (sclp.has_vt220 && | 207 | if (sclp.has_vt220 && IS_ENABLED(CONFIG_SCLP_VT220_CONSOLE)) |
| 208 | config_enabled(CONFIG_SCLP_VT220_CONSOLE)) | ||
| 209 | SET_CONSOLE_VT220; | 208 | SET_CONSOLE_VT220; |
| 210 | else if (sclp.has_linemode && | 209 | else if (sclp.has_linemode && IS_ENABLED(CONFIG_SCLP_CONSOLE)) |
| 211 | config_enabled(CONFIG_SCLP_CONSOLE)) | ||
| 212 | SET_CONSOLE_SCLP; | 210 | SET_CONSOLE_SCLP; |
| 213 | else | 211 | else |
| 214 | SET_CONSOLE_HVC; | 212 | SET_CONSOLE_HVC; |
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index f142215ed30d..607ec91966c7 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
| @@ -2231,9 +2231,10 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) | |||
| 2231 | return -EINVAL; | 2231 | return -EINVAL; |
| 2232 | current->thread.fpu.fpc = fpu->fpc; | 2232 | current->thread.fpu.fpc = fpu->fpc; |
| 2233 | if (MACHINE_HAS_VX) | 2233 | if (MACHINE_HAS_VX) |
| 2234 | convert_fp_to_vx(current->thread.fpu.vxrs, (freg_t *)fpu->fprs); | 2234 | convert_fp_to_vx((__vector128 *) vcpu->run->s.regs.vrs, |
| 2235 | (freg_t *) fpu->fprs); | ||
| 2235 | else | 2236 | else |
| 2236 | memcpy(current->thread.fpu.fprs, &fpu->fprs, sizeof(fpu->fprs)); | 2237 | memcpy(vcpu->run->s.regs.fprs, &fpu->fprs, sizeof(fpu->fprs)); |
| 2237 | return 0; | 2238 | return 0; |
| 2238 | } | 2239 | } |
| 2239 | 2240 | ||
| @@ -2242,9 +2243,10 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) | |||
| 2242 | /* make sure we have the latest values */ | 2243 | /* make sure we have the latest values */ |
| 2243 | save_fpu_regs(); | 2244 | save_fpu_regs(); |
| 2244 | if (MACHINE_HAS_VX) | 2245 | if (MACHINE_HAS_VX) |
| 2245 | convert_vx_to_fp((freg_t *)fpu->fprs, current->thread.fpu.vxrs); | 2246 | convert_vx_to_fp((freg_t *) fpu->fprs, |
| 2247 | (__vector128 *) vcpu->run->s.regs.vrs); | ||
| 2246 | else | 2248 | else |
| 2247 | memcpy(fpu->fprs, current->thread.fpu.fprs, sizeof(fpu->fprs)); | 2249 | memcpy(fpu->fprs, vcpu->run->s.regs.fprs, sizeof(fpu->fprs)); |
| 2248 | fpu->fpc = current->thread.fpu.fpc; | 2250 | fpu->fpc = current->thread.fpu.fpc; |
| 2249 | return 0; | 2251 | return 0; |
| 2250 | } | 2252 | } |
diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c index c106488b4137..d8673e243f13 100644 --- a/arch/s390/kvm/vsie.c +++ b/arch/s390/kvm/vsie.c | |||
| @@ -584,7 +584,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) | |||
| 584 | /* Validity 0x0044 will be checked by SIE */ | 584 | /* Validity 0x0044 will be checked by SIE */ |
| 585 | if (rc) | 585 | if (rc) |
| 586 | goto unpin; | 586 | goto unpin; |
| 587 | scb_s->gvrd = hpa; | 587 | scb_s->riccbd = hpa; |
| 588 | } | 588 | } |
| 589 | return 0; | 589 | return 0; |
| 590 | unpin: | 590 | unpin: |
diff --git a/arch/score/include/asm/uaccess.h b/arch/score/include/asm/uaccess.h index 20a3591225cc..01aec8ccde83 100644 --- a/arch/score/include/asm/uaccess.h +++ b/arch/score/include/asm/uaccess.h | |||
| @@ -163,7 +163,7 @@ do { \ | |||
| 163 | __get_user_asm(val, "lw", ptr); \ | 163 | __get_user_asm(val, "lw", ptr); \ |
| 164 | break; \ | 164 | break; \ |
| 165 | case 8: \ | 165 | case 8: \ |
| 166 | if ((copy_from_user((void *)&val, ptr, 8)) == 0) \ | 166 | if (__copy_from_user((void *)&val, ptr, 8) == 0) \ |
| 167 | __gu_err = 0; \ | 167 | __gu_err = 0; \ |
| 168 | else \ | 168 | else \ |
| 169 | __gu_err = -EFAULT; \ | 169 | __gu_err = -EFAULT; \ |
| @@ -188,6 +188,8 @@ do { \ | |||
| 188 | \ | 188 | \ |
| 189 | if (likely(access_ok(VERIFY_READ, __gu_ptr, size))) \ | 189 | if (likely(access_ok(VERIFY_READ, __gu_ptr, size))) \ |
| 190 | __get_user_common((x), size, __gu_ptr); \ | 190 | __get_user_common((x), size, __gu_ptr); \ |
| 191 | else \ | ||
| 192 | (x) = 0; \ | ||
| 191 | \ | 193 | \ |
| 192 | __gu_err; \ | 194 | __gu_err; \ |
| 193 | }) | 195 | }) |
| @@ -201,6 +203,7 @@ do { \ | |||
| 201 | "2:\n" \ | 203 | "2:\n" \ |
| 202 | ".section .fixup,\"ax\"\n" \ | 204 | ".section .fixup,\"ax\"\n" \ |
| 203 | "3:li %0, %4\n" \ | 205 | "3:li %0, %4\n" \ |
| 206 | "li %1, 0\n" \ | ||
| 204 | "j 2b\n" \ | 207 | "j 2b\n" \ |
| 205 | ".previous\n" \ | 208 | ".previous\n" \ |
| 206 | ".section __ex_table,\"a\"\n" \ | 209 | ".section __ex_table,\"a\"\n" \ |
| @@ -298,35 +301,34 @@ extern int __copy_tofrom_user(void *to, const void *from, unsigned long len); | |||
| 298 | static inline unsigned long | 301 | static inline unsigned long |
| 299 | copy_from_user(void *to, const void *from, unsigned long len) | 302 | copy_from_user(void *to, const void *from, unsigned long len) |
| 300 | { | 303 | { |
| 301 | unsigned long over; | 304 | unsigned long res = len; |
| 302 | 305 | ||
| 303 | if (access_ok(VERIFY_READ, from, len)) | 306 | if (likely(access_ok(VERIFY_READ, from, len))) |
| 304 | return __copy_tofrom_user(to, from, len); | 307 | res = __copy_tofrom_user(to, from, len); |
| 305 | 308 | ||
| 306 | if ((unsigned long)from < TASK_SIZE) { | 309 | if (unlikely(res)) |
| 307 | over = (unsigned long)from + len - TASK_SIZE; | 310 | memset(to + (len - res), 0, res); |
| 308 | return __copy_tofrom_user(to, from, len - over) + over; | 311 | |
| 309 | } | 312 | return res; |
| 310 | return len; | ||
| 311 | } | 313 | } |
| 312 | 314 | ||
| 313 | static inline unsigned long | 315 | static inline unsigned long |
| 314 | copy_to_user(void *to, const void *from, unsigned long len) | 316 | copy_to_user(void *to, const void *from, unsigned long len) |
| 315 | { | 317 | { |
| 316 | unsigned long over; | 318 | if (likely(access_ok(VERIFY_WRITE, to, len))) |
| 317 | 319 | len = __copy_tofrom_user(to, from, len); | |
| 318 | if (access_ok(VERIFY_WRITE, to, len)) | ||
| 319 | return __copy_tofrom_user(to, from, len); | ||
| 320 | 320 | ||
| 321 | if ((unsigned long)to < TASK_SIZE) { | ||
| 322 | over = (unsigned long)to + len - TASK_SIZE; | ||
| 323 | return __copy_tofrom_user(to, from, len - over) + over; | ||
| 324 | } | ||
| 325 | return len; | 321 | return len; |
| 326 | } | 322 | } |
| 327 | 323 | ||
| 328 | #define __copy_from_user(to, from, len) \ | 324 | static inline unsigned long |
| 329 | __copy_tofrom_user((to), (from), (len)) | 325 | __copy_from_user(void *to, const void *from, unsigned long len) |
| 326 | { | ||
| 327 | unsigned long left = __copy_tofrom_user(to, from, len); | ||
| 328 | if (unlikely(left)) | ||
| 329 | memset(to + (len - left), 0, left); | ||
| 330 | return left; | ||
| 331 | } | ||
| 330 | 332 | ||
| 331 | #define __copy_to_user(to, from, len) \ | 333 | #define __copy_to_user(to, from, len) \ |
| 332 | __copy_tofrom_user((to), (from), (len)) | 334 | __copy_tofrom_user((to), (from), (len)) |
| @@ -340,17 +342,17 @@ __copy_to_user_inatomic(void *to, const void *from, unsigned long len) | |||
| 340 | static inline unsigned long | 342 | static inline unsigned long |
| 341 | __copy_from_user_inatomic(void *to, const void *from, unsigned long len) | 343 | __copy_from_user_inatomic(void *to, const void *from, unsigned long len) |
| 342 | { | 344 | { |
| 343 | return __copy_from_user(to, from, len); | 345 | return __copy_tofrom_user(to, from, len); |
| 344 | } | 346 | } |
| 345 | 347 | ||
| 346 | #define __copy_in_user(to, from, len) __copy_from_user(to, from, len) | 348 | #define __copy_in_user(to, from, len) __copy_tofrom_user(to, from, len) |
| 347 | 349 | ||
| 348 | static inline unsigned long | 350 | static inline unsigned long |
| 349 | copy_in_user(void *to, const void *from, unsigned long len) | 351 | copy_in_user(void *to, const void *from, unsigned long len) |
| 350 | { | 352 | { |
| 351 | if (access_ok(VERIFY_READ, from, len) && | 353 | if (access_ok(VERIFY_READ, from, len) && |
| 352 | access_ok(VERFITY_WRITE, to, len)) | 354 | access_ok(VERFITY_WRITE, to, len)) |
| 353 | return copy_from_user(to, from, len); | 355 | return __copy_tofrom_user(to, from, len); |
| 354 | } | 356 | } |
| 355 | 357 | ||
| 356 | /* | 358 | /* |
diff --git a/arch/sh/include/asm/uaccess.h b/arch/sh/include/asm/uaccess.h index a49635c51266..92ade79ac427 100644 --- a/arch/sh/include/asm/uaccess.h +++ b/arch/sh/include/asm/uaccess.h | |||
| @@ -151,7 +151,10 @@ copy_from_user(void *to, const void __user *from, unsigned long n) | |||
| 151 | __kernel_size_t __copy_size = (__kernel_size_t) n; | 151 | __kernel_size_t __copy_size = (__kernel_size_t) n; |
| 152 | 152 | ||
| 153 | if (__copy_size && __access_ok(__copy_from, __copy_size)) | 153 | if (__copy_size && __access_ok(__copy_from, __copy_size)) |
| 154 | return __copy_user(to, from, __copy_size); | 154 | __copy_size = __copy_user(to, from, __copy_size); |
| 155 | |||
| 156 | if (unlikely(__copy_size)) | ||
| 157 | memset(to + (n - __copy_size), 0, __copy_size); | ||
| 155 | 158 | ||
| 156 | return __copy_size; | 159 | return __copy_size; |
| 157 | } | 160 | } |
diff --git a/arch/sh/include/asm/uaccess_64.h b/arch/sh/include/asm/uaccess_64.h index c01376c76b86..ca5073dd4596 100644 --- a/arch/sh/include/asm/uaccess_64.h +++ b/arch/sh/include/asm/uaccess_64.h | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #define __get_user_size(x,ptr,size,retval) \ | 24 | #define __get_user_size(x,ptr,size,retval) \ |
| 25 | do { \ | 25 | do { \ |
| 26 | retval = 0; \ | 26 | retval = 0; \ |
| 27 | x = 0; \ | ||
| 27 | switch (size) { \ | 28 | switch (size) { \ |
| 28 | case 1: \ | 29 | case 1: \ |
| 29 | retval = __get_user_asm_b((void *)&x, \ | 30 | retval = __get_user_asm_b((void *)&x, \ |
diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h index 341a5a133f48..ea55f86d7ccd 100644 --- a/arch/sparc/include/asm/uaccess_32.h +++ b/arch/sparc/include/asm/uaccess_32.h | |||
| @@ -249,8 +249,7 @@ unsigned long __copy_user(void __user *to, const void __user *from, unsigned lon | |||
| 249 | static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) | 249 | static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) |
| 250 | { | 250 | { |
| 251 | if (n && __access_ok((unsigned long) to, n)) { | 251 | if (n && __access_ok((unsigned long) to, n)) { |
| 252 | if (!__builtin_constant_p(n)) | 252 | check_object_size(from, n, true); |
| 253 | check_object_size(from, n, true); | ||
| 254 | return __copy_user(to, (__force void __user *) from, n); | 253 | return __copy_user(to, (__force void __user *) from, n); |
| 255 | } else | 254 | } else |
| 256 | return n; | 255 | return n; |
| @@ -258,19 +257,19 @@ static inline unsigned long copy_to_user(void __user *to, const void *from, unsi | |||
| 258 | 257 | ||
| 259 | static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n) | 258 | static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n) |
| 260 | { | 259 | { |
| 261 | if (!__builtin_constant_p(n)) | 260 | check_object_size(from, n, true); |
| 262 | check_object_size(from, n, true); | ||
| 263 | return __copy_user(to, (__force void __user *) from, n); | 261 | return __copy_user(to, (__force void __user *) from, n); |
| 264 | } | 262 | } |
| 265 | 263 | ||
| 266 | static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) | 264 | static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) |
| 267 | { | 265 | { |
| 268 | if (n && __access_ok((unsigned long) from, n)) { | 266 | if (n && __access_ok((unsigned long) from, n)) { |
| 269 | if (!__builtin_constant_p(n)) | 267 | check_object_size(to, n, false); |
| 270 | check_object_size(to, n, false); | ||
| 271 | return __copy_user((__force void __user *) to, from, n); | 268 | return __copy_user((__force void __user *) to, from, n); |
| 272 | } else | 269 | } else { |
| 270 | memset(to, 0, n); | ||
| 273 | return n; | 271 | return n; |
| 272 | } | ||
| 274 | } | 273 | } |
| 275 | 274 | ||
| 276 | static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n) | 275 | static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n) |
diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h index 8bda94fab8e8..37a315d0ddd4 100644 --- a/arch/sparc/include/asm/uaccess_64.h +++ b/arch/sparc/include/asm/uaccess_64.h | |||
| @@ -212,8 +212,7 @@ copy_from_user(void *to, const void __user *from, unsigned long size) | |||
| 212 | { | 212 | { |
| 213 | unsigned long ret; | 213 | unsigned long ret; |
| 214 | 214 | ||
| 215 | if (!__builtin_constant_p(size)) | 215 | check_object_size(to, size, false); |
| 216 | check_object_size(to, size, false); | ||
| 217 | 216 | ||
| 218 | ret = ___copy_from_user(to, from, size); | 217 | ret = ___copy_from_user(to, from, size); |
| 219 | if (unlikely(ret)) | 218 | if (unlikely(ret)) |
| @@ -233,8 +232,8 @@ copy_to_user(void __user *to, const void *from, unsigned long size) | |||
| 233 | { | 232 | { |
| 234 | unsigned long ret; | 233 | unsigned long ret; |
| 235 | 234 | ||
| 236 | if (!__builtin_constant_p(size)) | 235 | check_object_size(from, size, true); |
| 237 | check_object_size(from, size, true); | 236 | |
| 238 | ret = ___copy_to_user(to, from, size); | 237 | ret = ___copy_to_user(to, from, size); |
| 239 | if (unlikely(ret)) | 238 | if (unlikely(ret)) |
| 240 | ret = copy_to_user_fixup(to, from, size); | 239 | ret = copy_to_user_fixup(to, from, size); |
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index 4820a02838ac..78da75b670bc 100644 --- a/arch/tile/Kconfig +++ b/arch/tile/Kconfig | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | config TILE | 4 | config TILE |
| 5 | def_bool y | 5 | def_bool y |
| 6 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE | 6 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE |
| 7 | select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS | ||
| 8 | select ARCH_HAS_DEVMEM_IS_ALLOWED | 7 | select ARCH_HAS_DEVMEM_IS_ALLOWED |
| 9 | select ARCH_HAVE_NMI_SAFE_CMPXCHG | 8 | select ARCH_HAVE_NMI_SAFE_CMPXCHG |
| 10 | select ARCH_WANT_FRAME_POINTERS | 9 | select ARCH_WANT_FRAME_POINTERS |
diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h index 0a9c4265763b..a77369e91e54 100644 --- a/arch/tile/include/asm/uaccess.h +++ b/arch/tile/include/asm/uaccess.h | |||
| @@ -416,14 +416,13 @@ _copy_from_user(void *to, const void __user *from, unsigned long n) | |||
| 416 | return n; | 416 | return n; |
| 417 | } | 417 | } |
| 418 | 418 | ||
| 419 | #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS | 419 | extern void __compiletime_error("usercopy buffer size is too small") |
| 420 | /* | 420 | __bad_copy_user(void); |
| 421 | * There are still unprovable places in the generic code as of 2.6.34, so this | 421 | |
| 422 | * option is not really compatible with -Werror, which is more useful in | 422 | static inline void copy_user_overflow(int size, unsigned long count) |
| 423 | * general. | 423 | { |
| 424 | */ | 424 | WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count); |
| 425 | extern void copy_from_user_overflow(void) | 425 | } |
| 426 | __compiletime_warning("copy_from_user() size is not provably correct"); | ||
| 427 | 426 | ||
| 428 | static inline unsigned long __must_check copy_from_user(void *to, | 427 | static inline unsigned long __must_check copy_from_user(void *to, |
| 429 | const void __user *from, | 428 | const void __user *from, |
| @@ -433,14 +432,13 @@ static inline unsigned long __must_check copy_from_user(void *to, | |||
| 433 | 432 | ||
| 434 | if (likely(sz == -1 || sz >= n)) | 433 | if (likely(sz == -1 || sz >= n)) |
| 435 | n = _copy_from_user(to, from, n); | 434 | n = _copy_from_user(to, from, n); |
| 435 | else if (!__builtin_constant_p(n)) | ||
| 436 | copy_user_overflow(sz, n); | ||
| 436 | else | 437 | else |
| 437 | copy_from_user_overflow(); | 438 | __bad_copy_user(); |
| 438 | 439 | ||
| 439 | return n; | 440 | return n; |
| 440 | } | 441 | } |
| 441 | #else | ||
| 442 | #define copy_from_user _copy_from_user | ||
| 443 | #endif | ||
| 444 | 442 | ||
| 445 | #ifdef __tilegx__ | 443 | #ifdef __tilegx__ |
| 446 | /** | 444 | /** |
diff --git a/arch/um/include/asm/common.lds.S b/arch/um/include/asm/common.lds.S index 1dd5bd8a8c59..133055311dce 100644 --- a/arch/um/include/asm/common.lds.S +++ b/arch/um/include/asm/common.lds.S | |||
| @@ -81,7 +81,7 @@ | |||
| 81 | .altinstr_replacement : { *(.altinstr_replacement) } | 81 | .altinstr_replacement : { *(.altinstr_replacement) } |
| 82 | /* .exit.text is discard at runtime, not link time, to deal with references | 82 | /* .exit.text is discard at runtime, not link time, to deal with references |
| 83 | from .altinstructions and .eh_frame */ | 83 | from .altinstructions and .eh_frame */ |
| 84 | .exit.text : { *(.exit.text) } | 84 | .exit.text : { EXIT_TEXT } |
| 85 | .exit.data : { *(.exit.data) } | 85 | .exit.data : { *(.exit.data) } |
| 86 | 86 | ||
| 87 | .preinit_array : { | 87 | .preinit_array : { |
diff --git a/arch/um/kernel/skas/syscall.c b/arch/um/kernel/skas/syscall.c index ef4b8f949b51..b783ac87d98a 100644 --- a/arch/um/kernel/skas/syscall.c +++ b/arch/um/kernel/skas/syscall.c | |||
| @@ -21,21 +21,17 @@ void handle_syscall(struct uml_pt_regs *r) | |||
| 21 | PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS); | 21 | PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS); |
| 22 | 22 | ||
| 23 | if (syscall_trace_enter(regs)) | 23 | if (syscall_trace_enter(regs)) |
| 24 | return; | 24 | goto out; |
| 25 | 25 | ||
| 26 | /* Do the seccomp check after ptrace; failures should be fast. */ | 26 | /* Do the seccomp check after ptrace; failures should be fast. */ |
| 27 | if (secure_computing(NULL) == -1) | 27 | if (secure_computing(NULL) == -1) |
| 28 | return; | 28 | goto out; |
| 29 | 29 | ||
| 30 | /* Update the syscall number after orig_ax has potentially been updated | ||
| 31 | * with ptrace. | ||
| 32 | */ | ||
| 33 | UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp); | ||
| 34 | syscall = UPT_SYSCALL_NR(r); | 30 | syscall = UPT_SYSCALL_NR(r); |
| 35 | |||
| 36 | if (syscall >= 0 && syscall <= __NR_syscall_max) | 31 | if (syscall >= 0 && syscall <= __NR_syscall_max) |
| 37 | PT_REGS_SET_SYSCALL_RETURN(regs, | 32 | PT_REGS_SET_SYSCALL_RETURN(regs, |
| 38 | EXECUTE_SYSCALL(syscall, regs)); | 33 | EXECUTE_SYSCALL(syscall, regs)); |
| 39 | 34 | ||
| 35 | out: | ||
| 40 | syscall_trace_leave(regs); | 36 | syscall_trace_leave(regs); |
| 41 | } | 37 | } |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c580d8c33562..2a1f0ce7c59a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
| @@ -24,7 +24,6 @@ config X86 | |||
| 24 | select ARCH_DISCARD_MEMBLOCK | 24 | select ARCH_DISCARD_MEMBLOCK |
| 25 | select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI | 25 | select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI |
| 26 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE | 26 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE |
| 27 | select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS | ||
| 28 | select ARCH_HAS_DEVMEM_IS_ALLOWED | 27 | select ARCH_HAS_DEVMEM_IS_ALLOWED |
| 29 | select ARCH_HAS_ELF_RANDOMIZE | 28 | select ARCH_HAS_ELF_RANDOMIZE |
| 30 | select ARCH_HAS_FAST_MULTIPLIER | 29 | select ARCH_HAS_FAST_MULTIPLIER |
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index ff574dad95cc..94dd4a31f5b3 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c | |||
| @@ -1004,79 +1004,87 @@ static efi_status_t alloc_e820ext(u32 nr_desc, struct setup_data **e820ext, | |||
| 1004 | return status; | 1004 | return status; |
| 1005 | } | 1005 | } |
| 1006 | 1006 | ||
| 1007 | static efi_status_t exit_boot(struct boot_params *boot_params, | 1007 | struct exit_boot_struct { |
| 1008 | void *handle, bool is64) | 1008 | struct boot_params *boot_params; |
| 1009 | { | 1009 | struct efi_info *efi; |
| 1010 | struct efi_info *efi = &boot_params->efi_info; | ||
| 1011 | unsigned long map_sz, key, desc_size; | ||
| 1012 | efi_memory_desc_t *mem_map; | ||
| 1013 | struct setup_data *e820ext; | 1010 | struct setup_data *e820ext; |
| 1014 | const char *signature; | ||
| 1015 | __u32 e820ext_size; | 1011 | __u32 e820ext_size; |
| 1016 | __u32 nr_desc, prev_nr_desc; | 1012 | bool is64; |
| 1017 | efi_status_t status; | 1013 | }; |
| 1018 | __u32 desc_version; | ||
| 1019 | bool called_exit = false; | ||
| 1020 | u8 nr_entries; | ||
| 1021 | int i; | ||
| 1022 | |||
| 1023 | nr_desc = 0; | ||
| 1024 | e820ext = NULL; | ||
| 1025 | e820ext_size = 0; | ||
| 1026 | |||
| 1027 | get_map: | ||
| 1028 | status = efi_get_memory_map(sys_table, &mem_map, &map_sz, &desc_size, | ||
| 1029 | &desc_version, &key); | ||
| 1030 | |||
| 1031 | if (status != EFI_SUCCESS) | ||
| 1032 | return status; | ||
| 1033 | |||
| 1034 | prev_nr_desc = nr_desc; | ||
| 1035 | nr_desc = map_sz / desc_size; | ||
| 1036 | if (nr_desc > prev_nr_desc && | ||
| 1037 | nr_desc > ARRAY_SIZE(boot_params->e820_map)) { | ||
| 1038 | u32 nr_e820ext = nr_desc - ARRAY_SIZE(boot_params->e820_map); | ||
| 1039 | |||
| 1040 | status = alloc_e820ext(nr_e820ext, &e820ext, &e820ext_size); | ||
| 1041 | if (status != EFI_SUCCESS) | ||
| 1042 | goto free_mem_map; | ||
| 1043 | 1014 | ||
| 1044 | efi_call_early(free_pool, mem_map); | 1015 | static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg, |
| 1045 | goto get_map; /* Allocated memory, get map again */ | 1016 | struct efi_boot_memmap *map, |
| 1017 | void *priv) | ||
| 1018 | { | ||
| 1019 | static bool first = true; | ||
| 1020 | const char *signature; | ||
| 1021 | __u32 nr_desc; | ||
| 1022 | efi_status_t status; | ||
| 1023 | struct exit_boot_struct *p = priv; | ||
| 1024 | |||
| 1025 | if (first) { | ||
| 1026 | nr_desc = *map->buff_size / *map->desc_size; | ||
| 1027 | if (nr_desc > ARRAY_SIZE(p->boot_params->e820_map)) { | ||
| 1028 | u32 nr_e820ext = nr_desc - | ||
| 1029 | ARRAY_SIZE(p->boot_params->e820_map); | ||
| 1030 | |||
| 1031 | status = alloc_e820ext(nr_e820ext, &p->e820ext, | ||
| 1032 | &p->e820ext_size); | ||
| 1033 | if (status != EFI_SUCCESS) | ||
| 1034 | return status; | ||
| 1035 | } | ||
| 1036 | first = false; | ||
| 1046 | } | 1037 | } |
| 1047 | 1038 | ||
| 1048 | signature = is64 ? EFI64_LOADER_SIGNATURE : EFI32_LOADER_SIGNATURE; | 1039 | signature = p->is64 ? EFI64_LOADER_SIGNATURE : EFI32_LOADER_SIGNATURE; |
| 1049 | memcpy(&efi->efi_loader_signature, signature, sizeof(__u32)); | 1040 | memcpy(&p->efi->efi_loader_signature, signature, sizeof(__u32)); |
| 1050 | 1041 | ||
| 1051 | efi->efi_systab = (unsigned long)sys_table; | 1042 | p->efi->efi_systab = (unsigned long)sys_table_arg; |
| 1052 | efi->efi_memdesc_size = desc_size; | 1043 | p->efi->efi_memdesc_size = *map->desc_size; |
| 1053 | efi->efi_memdesc_version = desc_version; | 1044 | p->efi->efi_memdesc_version = *map->desc_ver; |
| 1054 | efi->efi_memmap = (unsigned long)mem_map; | 1045 | p->efi->efi_memmap = (unsigned long)*map->map; |
| 1055 | efi->efi_memmap_size = map_sz; | 1046 | p->efi->efi_memmap_size = *map->map_size; |
| 1056 | 1047 | ||
| 1057 | #ifdef CONFIG_X86_64 | 1048 | #ifdef CONFIG_X86_64 |
| 1058 | efi->efi_systab_hi = (unsigned long)sys_table >> 32; | 1049 | p->efi->efi_systab_hi = (unsigned long)sys_table_arg >> 32; |
| 1059 | efi->efi_memmap_hi = (unsigned long)mem_map >> 32; | 1050 | p->efi->efi_memmap_hi = (unsigned long)*map->map >> 32; |
| 1060 | #endif | 1051 | #endif |
| 1061 | 1052 | ||
| 1053 | return EFI_SUCCESS; | ||
| 1054 | } | ||
| 1055 | |||
| 1056 | static efi_status_t exit_boot(struct boot_params *boot_params, | ||
| 1057 | void *handle, bool is64) | ||
| 1058 | { | ||
| 1059 | unsigned long map_sz, key, desc_size, buff_size; | ||
| 1060 | efi_memory_desc_t *mem_map; | ||
| 1061 | struct setup_data *e820ext; | ||
| 1062 | __u32 e820ext_size; | ||
| 1063 | efi_status_t status; | ||
| 1064 | __u32 desc_version; | ||
| 1065 | struct efi_boot_memmap map; | ||
| 1066 | struct exit_boot_struct priv; | ||
| 1067 | |||
| 1068 | map.map = &mem_map; | ||
| 1069 | map.map_size = &map_sz; | ||
| 1070 | map.desc_size = &desc_size; | ||
| 1071 | map.desc_ver = &desc_version; | ||
| 1072 | map.key_ptr = &key; | ||
| 1073 | map.buff_size = &buff_size; | ||
| 1074 | priv.boot_params = boot_params; | ||
| 1075 | priv.efi = &boot_params->efi_info; | ||
| 1076 | priv.e820ext = NULL; | ||
| 1077 | priv.e820ext_size = 0; | ||
| 1078 | priv.is64 = is64; | ||
| 1079 | |||
| 1062 | /* Might as well exit boot services now */ | 1080 | /* Might as well exit boot services now */ |
| 1063 | status = efi_call_early(exit_boot_services, handle, key); | 1081 | status = efi_exit_boot_services(sys_table, handle, &map, &priv, |
| 1064 | if (status != EFI_SUCCESS) { | 1082 | exit_boot_func); |
| 1065 | /* | 1083 | if (status != EFI_SUCCESS) |
| 1066 | * ExitBootServices() will fail if any of the event | 1084 | return status; |
| 1067 | * handlers change the memory map. In which case, we | ||
| 1068 | * must be prepared to retry, but only once so that | ||
| 1069 | * we're guaranteed to exit on repeated failures instead | ||
| 1070 | * of spinning forever. | ||
| 1071 | */ | ||
| 1072 | if (called_exit) | ||
| 1073 | goto free_mem_map; | ||
| 1074 | |||
| 1075 | called_exit = true; | ||
| 1076 | efi_call_early(free_pool, mem_map); | ||
| 1077 | goto get_map; | ||
| 1078 | } | ||
| 1079 | 1085 | ||
| 1086 | e820ext = priv.e820ext; | ||
| 1087 | e820ext_size = priv.e820ext_size; | ||
| 1080 | /* Historic? */ | 1088 | /* Historic? */ |
| 1081 | boot_params->alt_mem_k = 32 * 1024; | 1089 | boot_params->alt_mem_k = 32 * 1024; |
| 1082 | 1090 | ||
| @@ -1085,10 +1093,6 @@ get_map: | |||
| 1085 | return status; | 1093 | return status; |
| 1086 | 1094 | ||
| 1087 | return EFI_SUCCESS; | 1095 | return EFI_SUCCESS; |
| 1088 | |||
| 1089 | free_mem_map: | ||
| 1090 | efi_call_early(free_pool, mem_map); | ||
| 1091 | return status; | ||
| 1092 | } | 1096 | } |
| 1093 | 1097 | ||
| 1094 | /* | 1098 | /* |
diff --git a/arch/x86/configs/tiny.config b/arch/x86/configs/tiny.config index 4e2ecfa23c15..4b429df40d7a 100644 --- a/arch/x86/configs/tiny.config +++ b/arch/x86/configs/tiny.config | |||
| @@ -1 +1,3 @@ | |||
| 1 | CONFIG_NOHIGHMEM=y | 1 | CONFIG_NOHIGHMEM=y |
| 2 | # CONFIG_HIGHMEM4G is not set | ||
| 3 | # CONFIG_HIGHMEM64G is not set | ||
diff --git a/arch/x86/crypto/sha256-mb/sha256_mb.c b/arch/x86/crypto/sha256-mb/sha256_mb.c index 89fa85e8b10c..6f97fb33ae21 100644 --- a/arch/x86/crypto/sha256-mb/sha256_mb.c +++ b/arch/x86/crypto/sha256-mb/sha256_mb.c | |||
| @@ -485,10 +485,10 @@ static int sha_complete_job(struct mcryptd_hash_request_ctx *rctx, | |||
| 485 | 485 | ||
| 486 | req = cast_mcryptd_ctx_to_req(req_ctx); | 486 | req = cast_mcryptd_ctx_to_req(req_ctx); |
| 487 | if (irqs_disabled()) | 487 | if (irqs_disabled()) |
| 488 | rctx->complete(&req->base, ret); | 488 | req_ctx->complete(&req->base, ret); |
| 489 | else { | 489 | else { |
| 490 | local_bh_disable(); | 490 | local_bh_disable(); |
| 491 | rctx->complete(&req->base, ret); | 491 | req_ctx->complete(&req->base, ret); |
| 492 | local_bh_enable(); | 492 | local_bh_enable(); |
| 493 | } | 493 | } |
| 494 | } | 494 | } |
diff --git a/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S b/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S index b691da981cd9..a78a0694ddef 100644 --- a/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S +++ b/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S | |||
| @@ -265,13 +265,14 @@ ENTRY(sha256_mb_mgr_get_comp_job_avx2) | |||
| 265 | vpinsrd $1, _args_digest+1*32(state, idx, 4), %xmm0, %xmm0 | 265 | vpinsrd $1, _args_digest+1*32(state, idx, 4), %xmm0, %xmm0 |
| 266 | vpinsrd $2, _args_digest+2*32(state, idx, 4), %xmm0, %xmm0 | 266 | vpinsrd $2, _args_digest+2*32(state, idx, 4), %xmm0, %xmm0 |
| 267 | vpinsrd $3, _args_digest+3*32(state, idx, 4), %xmm0, %xmm0 | 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 | vpinsrd $1, _args_digest+5*32(state, idx, 4), %xmm1, %xmm1 | 269 | vpinsrd $1, _args_digest+5*32(state, idx, 4), %xmm1, %xmm1 |
| 270 | vpinsrd $2, _args_digest+6*32(state, idx, 4), %xmm1, %xmm1 | 270 | vpinsrd $2, _args_digest+6*32(state, idx, 4), %xmm1, %xmm1 |
| 271 | vpinsrd $3, _args_digest+7*32(state, idx, 4), %xmm1, %xmm1 | 271 | vpinsrd $3, _args_digest+7*32(state, idx, 4), %xmm1, %xmm1 |
| 272 | 272 | ||
| 273 | vmovdqu %xmm0, _result_digest(job_rax) | 273 | vmovdqu %xmm0, _result_digest(job_rax) |
| 274 | movl tmp2_w, _result_digest+1*16(job_rax) | 274 | offset = (_result_digest + 1*16) |
| 275 | vmovdqu %xmm1, offset(job_rax) | ||
| 275 | 276 | ||
| 276 | pop %rbx | 277 | pop %rbx |
| 277 | 278 | ||
diff --git a/arch/x86/crypto/sha512-mb/sha512_mb.c b/arch/x86/crypto/sha512-mb/sha512_mb.c index f4cf5b78fd36..d210174a52b0 100644 --- a/arch/x86/crypto/sha512-mb/sha512_mb.c +++ b/arch/x86/crypto/sha512-mb/sha512_mb.c | |||
| @@ -497,10 +497,10 @@ static int sha_complete_job(struct mcryptd_hash_request_ctx *rctx, | |||
| 497 | 497 | ||
| 498 | req = cast_mcryptd_ctx_to_req(req_ctx); | 498 | req = cast_mcryptd_ctx_to_req(req_ctx); |
| 499 | if (irqs_disabled()) | 499 | if (irqs_disabled()) |
| 500 | rctx->complete(&req->base, ret); | 500 | req_ctx->complete(&req->base, ret); |
| 501 | else { | 501 | else { |
| 502 | local_bh_disable(); | 502 | local_bh_disable(); |
| 503 | rctx->complete(&req->base, ret); | 503 | req_ctx->complete(&req->base, ret); |
| 504 | local_bh_enable(); | 504 | local_bh_enable(); |
| 505 | } | 505 | } |
| 506 | } | 506 | } |
diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index e6131d4454e6..65577f081d07 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c | |||
| @@ -29,6 +29,8 @@ | |||
| 29 | 29 | ||
| 30 | #define COUNTER_SHIFT 16 | 30 | #define COUNTER_SHIFT 16 |
| 31 | 31 | ||
| 32 | static HLIST_HEAD(uncore_unused_list); | ||
| 33 | |||
| 32 | struct amd_uncore { | 34 | struct amd_uncore { |
| 33 | int id; | 35 | int id; |
| 34 | int refcnt; | 36 | int refcnt; |
| @@ -39,7 +41,7 @@ struct amd_uncore { | |||
| 39 | cpumask_t *active_mask; | 41 | cpumask_t *active_mask; |
| 40 | struct pmu *pmu; | 42 | struct pmu *pmu; |
| 41 | struct perf_event *events[MAX_COUNTERS]; | 43 | struct perf_event *events[MAX_COUNTERS]; |
| 42 | struct amd_uncore *free_when_cpu_online; | 44 | struct hlist_node node; |
| 43 | }; | 45 | }; |
| 44 | 46 | ||
| 45 | static struct amd_uncore * __percpu *amd_uncore_nb; | 47 | static struct amd_uncore * __percpu *amd_uncore_nb; |
| @@ -306,6 +308,7 @@ static int amd_uncore_cpu_up_prepare(unsigned int cpu) | |||
| 306 | uncore_nb->msr_base = MSR_F15H_NB_PERF_CTL; | 308 | uncore_nb->msr_base = MSR_F15H_NB_PERF_CTL; |
| 307 | uncore_nb->active_mask = &amd_nb_active_mask; | 309 | uncore_nb->active_mask = &amd_nb_active_mask; |
| 308 | uncore_nb->pmu = &amd_nb_pmu; | 310 | uncore_nb->pmu = &amd_nb_pmu; |
| 311 | uncore_nb->id = -1; | ||
| 309 | *per_cpu_ptr(amd_uncore_nb, cpu) = uncore_nb; | 312 | *per_cpu_ptr(amd_uncore_nb, cpu) = uncore_nb; |
| 310 | } | 313 | } |
| 311 | 314 | ||
| @@ -319,6 +322,7 @@ static int amd_uncore_cpu_up_prepare(unsigned int cpu) | |||
| 319 | uncore_l2->msr_base = MSR_F16H_L2I_PERF_CTL; | 322 | uncore_l2->msr_base = MSR_F16H_L2I_PERF_CTL; |
| 320 | uncore_l2->active_mask = &amd_l2_active_mask; | 323 | uncore_l2->active_mask = &amd_l2_active_mask; |
| 321 | uncore_l2->pmu = &amd_l2_pmu; | 324 | uncore_l2->pmu = &amd_l2_pmu; |
| 325 | uncore_l2->id = -1; | ||
| 322 | *per_cpu_ptr(amd_uncore_l2, cpu) = uncore_l2; | 326 | *per_cpu_ptr(amd_uncore_l2, cpu) = uncore_l2; |
| 323 | } | 327 | } |
| 324 | 328 | ||
| @@ -348,7 +352,7 @@ amd_uncore_find_online_sibling(struct amd_uncore *this, | |||
| 348 | continue; | 352 | continue; |
| 349 | 353 | ||
| 350 | if (this->id == that->id) { | 354 | if (this->id == that->id) { |
| 351 | that->free_when_cpu_online = this; | 355 | hlist_add_head(&this->node, &uncore_unused_list); |
| 352 | this = that; | 356 | this = that; |
| 353 | break; | 357 | break; |
| 354 | } | 358 | } |
| @@ -388,13 +392,23 @@ static int amd_uncore_cpu_starting(unsigned int cpu) | |||
| 388 | return 0; | 392 | return 0; |
| 389 | } | 393 | } |
| 390 | 394 | ||
| 395 | static void uncore_clean_online(void) | ||
| 396 | { | ||
| 397 | struct amd_uncore *uncore; | ||
| 398 | struct hlist_node *n; | ||
| 399 | |||
| 400 | hlist_for_each_entry_safe(uncore, n, &uncore_unused_list, node) { | ||
| 401 | hlist_del(&uncore->node); | ||
| 402 | kfree(uncore); | ||
| 403 | } | ||
| 404 | } | ||
| 405 | |||
| 391 | static void uncore_online(unsigned int cpu, | 406 | static void uncore_online(unsigned int cpu, |
| 392 | struct amd_uncore * __percpu *uncores) | 407 | struct amd_uncore * __percpu *uncores) |
| 393 | { | 408 | { |
| 394 | struct amd_uncore *uncore = *per_cpu_ptr(uncores, cpu); | 409 | struct amd_uncore *uncore = *per_cpu_ptr(uncores, cpu); |
| 395 | 410 | ||
| 396 | kfree(uncore->free_when_cpu_online); | 411 | uncore_clean_online(); |
| 397 | uncore->free_when_cpu_online = NULL; | ||
| 398 | 412 | ||
| 399 | if (cpu == uncore->cpu) | 413 | if (cpu == uncore->cpu) |
| 400 | cpumask_set_cpu(cpu, uncore->active_mask); | 414 | cpumask_set_cpu(cpu, uncore->active_mask); |
diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c index 0a6e393a2e62..bdcd6510992c 100644 --- a/arch/x86/events/intel/bts.c +++ b/arch/x86/events/intel/bts.c | |||
| @@ -31,7 +31,17 @@ | |||
| 31 | struct bts_ctx { | 31 | struct bts_ctx { |
| 32 | struct perf_output_handle handle; | 32 | struct perf_output_handle handle; |
| 33 | struct debug_store ds_back; | 33 | struct debug_store ds_back; |
| 34 | int started; | 34 | int state; |
| 35 | }; | ||
| 36 | |||
| 37 | /* BTS context states: */ | ||
| 38 | enum { | ||
| 39 | /* no ongoing AUX transactions */ | ||
| 40 | BTS_STATE_STOPPED = 0, | ||
| 41 | /* AUX transaction is on, BTS tracing is disabled */ | ||
| 42 | BTS_STATE_INACTIVE, | ||
| 43 | /* AUX transaction is on, BTS tracing is running */ | ||
| 44 | BTS_STATE_ACTIVE, | ||
| 35 | }; | 45 | }; |
| 36 | 46 | ||
| 37 | static DEFINE_PER_CPU(struct bts_ctx, bts_ctx); | 47 | static DEFINE_PER_CPU(struct bts_ctx, bts_ctx); |
| @@ -204,6 +214,15 @@ static void bts_update(struct bts_ctx *bts) | |||
| 204 | static int | 214 | static int |
| 205 | bts_buffer_reset(struct bts_buffer *buf, struct perf_output_handle *handle); | 215 | bts_buffer_reset(struct bts_buffer *buf, struct perf_output_handle *handle); |
| 206 | 216 | ||
| 217 | /* | ||
| 218 | * Ordering PMU callbacks wrt themselves and the PMI is done by means | ||
| 219 | * of bts::state, which: | ||
| 220 | * - is set when bts::handle::event is valid, that is, between | ||
| 221 | * perf_aux_output_begin() and perf_aux_output_end(); | ||
| 222 | * - is zero otherwise; | ||
| 223 | * - is ordered against bts::handle::event with a compiler barrier. | ||
| 224 | */ | ||
| 225 | |||
| 207 | static void __bts_event_start(struct perf_event *event) | 226 | static void __bts_event_start(struct perf_event *event) |
| 208 | { | 227 | { |
| 209 | struct bts_ctx *bts = this_cpu_ptr(&bts_ctx); | 228 | struct bts_ctx *bts = this_cpu_ptr(&bts_ctx); |
| @@ -221,10 +240,13 @@ static void __bts_event_start(struct perf_event *event) | |||
| 221 | 240 | ||
| 222 | /* | 241 | /* |
| 223 | * local barrier to make sure that ds configuration made it | 242 | * local barrier to make sure that ds configuration made it |
| 224 | * before we enable BTS | 243 | * before we enable BTS and bts::state goes ACTIVE |
| 225 | */ | 244 | */ |
| 226 | wmb(); | 245 | wmb(); |
| 227 | 246 | ||
| 247 | /* INACTIVE/STOPPED -> ACTIVE */ | ||
| 248 | WRITE_ONCE(bts->state, BTS_STATE_ACTIVE); | ||
| 249 | |||
| 228 | intel_pmu_enable_bts(config); | 250 | intel_pmu_enable_bts(config); |
| 229 | 251 | ||
| 230 | } | 252 | } |
| @@ -251,9 +273,6 @@ static void bts_event_start(struct perf_event *event, int flags) | |||
| 251 | 273 | ||
| 252 | __bts_event_start(event); | 274 | __bts_event_start(event); |
| 253 | 275 | ||
| 254 | /* PMI handler: this counter is running and likely generating PMIs */ | ||
| 255 | ACCESS_ONCE(bts->started) = 1; | ||
| 256 | |||
| 257 | return; | 276 | return; |
| 258 | 277 | ||
| 259 | fail_end_stop: | 278 | fail_end_stop: |
| @@ -263,30 +282,34 @@ fail_stop: | |||
| 263 | event->hw.state = PERF_HES_STOPPED; | 282 | event->hw.state = PERF_HES_STOPPED; |
| 264 | } | 283 | } |
| 265 | 284 | ||
| 266 | static void __bts_event_stop(struct perf_event *event) | 285 | static void __bts_event_stop(struct perf_event *event, int state) |
| 267 | { | 286 | { |
| 287 | struct bts_ctx *bts = this_cpu_ptr(&bts_ctx); | ||
| 288 | |||
| 289 | /* ACTIVE -> INACTIVE(PMI)/STOPPED(->stop()) */ | ||
| 290 | WRITE_ONCE(bts->state, state); | ||
| 291 | |||
| 268 | /* | 292 | /* |
| 269 | * No extra synchronization is mandated by the documentation to have | 293 | * No extra synchronization is mandated by the documentation to have |
| 270 | * BTS data stores globally visible. | 294 | * BTS data stores globally visible. |
| 271 | */ | 295 | */ |
| 272 | intel_pmu_disable_bts(); | 296 | intel_pmu_disable_bts(); |
| 273 | |||
| 274 | if (event->hw.state & PERF_HES_STOPPED) | ||
| 275 | return; | ||
| 276 | |||
| 277 | ACCESS_ONCE(event->hw.state) |= PERF_HES_STOPPED; | ||
| 278 | } | 297 | } |
| 279 | 298 | ||
| 280 | static void bts_event_stop(struct perf_event *event, int flags) | 299 | static void bts_event_stop(struct perf_event *event, int flags) |
| 281 | { | 300 | { |
| 282 | struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); | 301 | struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); |
| 283 | struct bts_ctx *bts = this_cpu_ptr(&bts_ctx); | 302 | struct bts_ctx *bts = this_cpu_ptr(&bts_ctx); |
| 284 | struct bts_buffer *buf = perf_get_aux(&bts->handle); | 303 | struct bts_buffer *buf = NULL; |
| 304 | int state = READ_ONCE(bts->state); | ||
| 285 | 305 | ||
| 286 | /* PMI handler: don't restart this counter */ | 306 | if (state == BTS_STATE_ACTIVE) |
| 287 | ACCESS_ONCE(bts->started) = 0; | 307 | __bts_event_stop(event, BTS_STATE_STOPPED); |
| 288 | 308 | ||
| 289 | __bts_event_stop(event); | 309 | if (state != BTS_STATE_STOPPED) |
| 310 | buf = perf_get_aux(&bts->handle); | ||
| 311 | |||
| 312 | event->hw.state |= PERF_HES_STOPPED; | ||
| 290 | 313 | ||
| 291 | if (flags & PERF_EF_UPDATE) { | 314 | if (flags & PERF_EF_UPDATE) { |
| 292 | bts_update(bts); | 315 | bts_update(bts); |
| @@ -296,6 +319,7 @@ static void bts_event_stop(struct perf_event *event, int flags) | |||
| 296 | bts->handle.head = | 319 | bts->handle.head = |
| 297 | local_xchg(&buf->data_size, | 320 | local_xchg(&buf->data_size, |
| 298 | buf->nr_pages << PAGE_SHIFT); | 321 | buf->nr_pages << PAGE_SHIFT); |
| 322 | |||
| 299 | perf_aux_output_end(&bts->handle, local_xchg(&buf->data_size, 0), | 323 | perf_aux_output_end(&bts->handle, local_xchg(&buf->data_size, 0), |
| 300 | !!local_xchg(&buf->lost, 0)); | 324 | !!local_xchg(&buf->lost, 0)); |
| 301 | } | 325 | } |
| @@ -310,8 +334,20 @@ static void bts_event_stop(struct perf_event *event, int flags) | |||
| 310 | void intel_bts_enable_local(void) | 334 | void intel_bts_enable_local(void) |
| 311 | { | 335 | { |
| 312 | struct bts_ctx *bts = this_cpu_ptr(&bts_ctx); | 336 | struct bts_ctx *bts = this_cpu_ptr(&bts_ctx); |
| 337 | int state = READ_ONCE(bts->state); | ||
| 338 | |||
| 339 | /* | ||
| 340 | * Here we transition from INACTIVE to ACTIVE; | ||
| 341 | * if we instead are STOPPED from the interrupt handler, | ||
| 342 | * stay that way. Can't be ACTIVE here though. | ||
| 343 | */ | ||
| 344 | if (WARN_ON_ONCE(state == BTS_STATE_ACTIVE)) | ||
| 345 | return; | ||
| 346 | |||
| 347 | if (state == BTS_STATE_STOPPED) | ||
| 348 | return; | ||
| 313 | 349 | ||
| 314 | if (bts->handle.event && bts->started) | 350 | if (bts->handle.event) |
| 315 | __bts_event_start(bts->handle.event); | 351 | __bts_event_start(bts->handle.event); |
| 316 | } | 352 | } |
| 317 | 353 | ||
| @@ -319,8 +355,15 @@ void intel_bts_disable_local(void) | |||
| 319 | { | 355 | { |
| 320 | struct bts_ctx *bts = this_cpu_ptr(&bts_ctx); | 356 | struct bts_ctx *bts = this_cpu_ptr(&bts_ctx); |
| 321 | 357 | ||
| 358 | /* | ||
| 359 | * Here we transition from ACTIVE to INACTIVE; | ||
| 360 | * do nothing for STOPPED or INACTIVE. | ||
| 361 | */ | ||
| 362 | if (READ_ONCE(bts->state) != BTS_STATE_ACTIVE) | ||
| 363 | return; | ||
| 364 | |||
| 322 | if (bts->handle.event) | 365 | if (bts->handle.event) |
| 323 | __bts_event_stop(bts->handle.event); | 366 | __bts_event_stop(bts->handle.event, BTS_STATE_INACTIVE); |
| 324 | } | 367 | } |
| 325 | 368 | ||
| 326 | static int | 369 | static int |
| @@ -335,8 +378,6 @@ bts_buffer_reset(struct bts_buffer *buf, struct perf_output_handle *handle) | |||
| 335 | return 0; | 378 | return 0; |
| 336 | 379 | ||
| 337 | head = handle->head & ((buf->nr_pages << PAGE_SHIFT) - 1); | 380 | head = handle->head & ((buf->nr_pages << PAGE_SHIFT) - 1); |
| 338 | if (WARN_ON_ONCE(head != local_read(&buf->head))) | ||
| 339 | return -EINVAL; | ||
| 340 | 381 | ||
| 341 | phys = &buf->buf[buf->cur_buf]; | 382 | phys = &buf->buf[buf->cur_buf]; |
| 342 | space = phys->offset + phys->displacement + phys->size - head; | 383 | space = phys->offset + phys->displacement + phys->size - head; |
| @@ -403,22 +444,37 @@ bts_buffer_reset(struct bts_buffer *buf, struct perf_output_handle *handle) | |||
| 403 | 444 | ||
| 404 | int intel_bts_interrupt(void) | 445 | int intel_bts_interrupt(void) |
| 405 | { | 446 | { |
| 447 | struct debug_store *ds = this_cpu_ptr(&cpu_hw_events)->ds; | ||
| 406 | struct bts_ctx *bts = this_cpu_ptr(&bts_ctx); | 448 | struct bts_ctx *bts = this_cpu_ptr(&bts_ctx); |
| 407 | struct perf_event *event = bts->handle.event; | 449 | struct perf_event *event = bts->handle.event; |
| 408 | struct bts_buffer *buf; | 450 | struct bts_buffer *buf; |
| 409 | s64 old_head; | 451 | s64 old_head; |
| 410 | int err; | 452 | int err = -ENOSPC, handled = 0; |
| 411 | 453 | ||
| 412 | if (!event || !bts->started) | 454 | /* |
| 413 | return 0; | 455 | * The only surefire way of knowing if this NMI is ours is by checking |
| 456 | * the write ptr against the PMI threshold. | ||
| 457 | */ | ||
| 458 | if (ds->bts_index >= ds->bts_interrupt_threshold) | ||
| 459 | handled = 1; | ||
| 460 | |||
| 461 | /* | ||
| 462 | * this is wrapped in intel_bts_enable_local/intel_bts_disable_local, | ||
| 463 | * so we can only be INACTIVE or STOPPED | ||
| 464 | */ | ||
| 465 | if (READ_ONCE(bts->state) == BTS_STATE_STOPPED) | ||
| 466 | return handled; | ||
| 414 | 467 | ||
| 415 | buf = perf_get_aux(&bts->handle); | 468 | buf = perf_get_aux(&bts->handle); |
| 469 | if (!buf) | ||
| 470 | return handled; | ||
| 471 | |||
| 416 | /* | 472 | /* |
| 417 | * Skip snapshot counters: they don't use the interrupt, but | 473 | * Skip snapshot counters: they don't use the interrupt, but |
| 418 | * there's no other way of telling, because the pointer will | 474 | * there's no other way of telling, because the pointer will |
| 419 | * keep moving | 475 | * keep moving |
| 420 | */ | 476 | */ |
| 421 | if (!buf || buf->snapshot) | 477 | if (buf->snapshot) |
| 422 | return 0; | 478 | return 0; |
| 423 | 479 | ||
| 424 | old_head = local_read(&buf->head); | 480 | old_head = local_read(&buf->head); |
| @@ -426,18 +482,27 @@ int intel_bts_interrupt(void) | |||
| 426 | 482 | ||
| 427 | /* no new data */ | 483 | /* no new data */ |
| 428 | if (old_head == local_read(&buf->head)) | 484 | if (old_head == local_read(&buf->head)) |
| 429 | return 0; | 485 | return handled; |
| 430 | 486 | ||
| 431 | perf_aux_output_end(&bts->handle, local_xchg(&buf->data_size, 0), | 487 | perf_aux_output_end(&bts->handle, local_xchg(&buf->data_size, 0), |
| 432 | !!local_xchg(&buf->lost, 0)); | 488 | !!local_xchg(&buf->lost, 0)); |
| 433 | 489 | ||
| 434 | buf = perf_aux_output_begin(&bts->handle, event); | 490 | buf = perf_aux_output_begin(&bts->handle, event); |
| 435 | if (!buf) | 491 | if (buf) |
| 436 | return 1; | 492 | err = bts_buffer_reset(buf, &bts->handle); |
| 493 | |||
| 494 | if (err) { | ||
| 495 | WRITE_ONCE(bts->state, BTS_STATE_STOPPED); | ||
| 437 | 496 | ||
| 438 | err = bts_buffer_reset(buf, &bts->handle); | 497 | if (buf) { |
| 439 | if (err) | 498 | /* |
| 440 | perf_aux_output_end(&bts->handle, 0, false); | 499 | * BTS_STATE_STOPPED should be visible before |
| 500 | * cleared handle::event | ||
| 501 | */ | ||
| 502 | barrier(); | ||
| 503 | perf_aux_output_end(&bts->handle, 0, false); | ||
| 504 | } | ||
| 505 | } | ||
| 441 | 506 | ||
| 442 | return 1; | 507 | return 1; |
| 443 | } | 508 | } |
diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c index 783c49ddef29..8f82b02934fa 100644 --- a/arch/x86/events/intel/cqm.c +++ b/arch/x86/events/intel/cqm.c | |||
| @@ -458,6 +458,11 @@ static void __intel_cqm_event_count(void *info); | |||
| 458 | static void init_mbm_sample(u32 rmid, u32 evt_type); | 458 | static void init_mbm_sample(u32 rmid, u32 evt_type); |
| 459 | static void __intel_mbm_event_count(void *info); | 459 | static void __intel_mbm_event_count(void *info); |
| 460 | 460 | ||
| 461 | static bool is_cqm_event(int e) | ||
| 462 | { | ||
| 463 | return (e == QOS_L3_OCCUP_EVENT_ID); | ||
| 464 | } | ||
| 465 | |||
| 461 | static bool is_mbm_event(int e) | 466 | static bool is_mbm_event(int e) |
| 462 | { | 467 | { |
| 463 | return (e >= QOS_MBM_TOTAL_EVENT_ID && e <= QOS_MBM_LOCAL_EVENT_ID); | 468 | return (e >= QOS_MBM_TOTAL_EVENT_ID && e <= QOS_MBM_LOCAL_EVENT_ID); |
| @@ -1366,6 +1371,10 @@ static int intel_cqm_event_init(struct perf_event *event) | |||
| 1366 | (event->attr.config > QOS_MBM_LOCAL_EVENT_ID)) | 1371 | (event->attr.config > QOS_MBM_LOCAL_EVENT_ID)) |
| 1367 | return -EINVAL; | 1372 | return -EINVAL; |
| 1368 | 1373 | ||
| 1374 | if ((is_cqm_event(event->attr.config) && !cqm_enabled) || | ||
| 1375 | (is_mbm_event(event->attr.config) && !mbm_enabled)) | ||
| 1376 | return -EINVAL; | ||
| 1377 | |||
| 1369 | /* unsupported modes and filters */ | 1378 | /* unsupported modes and filters */ |
| 1370 | if (event->attr.exclude_user || | 1379 | if (event->attr.exclude_user || |
| 1371 | event->attr.exclude_kernel || | 1380 | event->attr.exclude_kernel || |
diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index 7ce9f3f669e6..9b983a474253 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c | |||
| @@ -1274,18 +1274,18 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs) | |||
| 1274 | struct pebs_record_nhm *p = at; | 1274 | struct pebs_record_nhm *p = at; |
| 1275 | u64 pebs_status; | 1275 | u64 pebs_status; |
| 1276 | 1276 | ||
| 1277 | /* PEBS v3 has accurate status bits */ | 1277 | pebs_status = p->status & cpuc->pebs_enabled; |
| 1278 | pebs_status &= (1ULL << x86_pmu.max_pebs_events) - 1; | ||
| 1279 | |||
| 1280 | /* PEBS v3 has more accurate status bits */ | ||
| 1278 | if (x86_pmu.intel_cap.pebs_format >= 3) { | 1281 | if (x86_pmu.intel_cap.pebs_format >= 3) { |
| 1279 | for_each_set_bit(bit, (unsigned long *)&p->status, | 1282 | for_each_set_bit(bit, (unsigned long *)&pebs_status, |
| 1280 | MAX_PEBS_EVENTS) | 1283 | x86_pmu.max_pebs_events) |
| 1281 | counts[bit]++; | 1284 | counts[bit]++; |
| 1282 | 1285 | ||
| 1283 | continue; | 1286 | continue; |
| 1284 | } | 1287 | } |
| 1285 | 1288 | ||
| 1286 | pebs_status = p->status & cpuc->pebs_enabled; | ||
| 1287 | pebs_status &= (1ULL << x86_pmu.max_pebs_events) - 1; | ||
| 1288 | |||
| 1289 | /* | 1289 | /* |
| 1290 | * On some CPUs the PEBS status can be zero when PEBS is | 1290 | * On some CPUs the PEBS status can be zero when PEBS is |
| 1291 | * racing with clearing of GLOBAL_STATUS. | 1291 | * racing with clearing of GLOBAL_STATUS. |
| @@ -1333,8 +1333,11 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs) | |||
| 1333 | continue; | 1333 | continue; |
| 1334 | 1334 | ||
| 1335 | event = cpuc->events[bit]; | 1335 | event = cpuc->events[bit]; |
| 1336 | WARN_ON_ONCE(!event); | 1336 | if (WARN_ON_ONCE(!event)) |
| 1337 | WARN_ON_ONCE(!event->attr.precise_ip); | 1337 | continue; |
| 1338 | |||
| 1339 | if (WARN_ON_ONCE(!event->attr.precise_ip)) | ||
| 1340 | continue; | ||
| 1338 | 1341 | ||
| 1339 | /* log dropped samples number */ | 1342 | /* log dropped samples number */ |
| 1340 | if (error[bit]) | 1343 | if (error[bit]) |
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index a0ae610b9280..2131c4ce7d8a 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h | |||
| @@ -433,7 +433,11 @@ do { \ | |||
| 433 | #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \ | 433 | #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \ |
| 434 | asm volatile("1: mov"itype" %1,%"rtype"0\n" \ | 434 | asm volatile("1: mov"itype" %1,%"rtype"0\n" \ |
| 435 | "2:\n" \ | 435 | "2:\n" \ |
| 436 | _ASM_EXTABLE_EX(1b, 2b) \ | 436 | ".section .fixup,\"ax\"\n" \ |
| 437 | "3:xor"itype" %"rtype"0,%"rtype"0\n" \ | ||
| 438 | " jmp 2b\n" \ | ||
| 439 | ".previous\n" \ | ||
| 440 | _ASM_EXTABLE_EX(1b, 3b) \ | ||
| 437 | : ltype(x) : "m" (__m(addr))) | 441 | : ltype(x) : "m" (__m(addr))) |
| 438 | 442 | ||
| 439 | #define __put_user_nocheck(x, ptr, size) \ | 443 | #define __put_user_nocheck(x, ptr, size) \ |
| @@ -697,44 +701,15 @@ unsigned long __must_check _copy_from_user(void *to, const void __user *from, | |||
| 697 | unsigned long __must_check _copy_to_user(void __user *to, const void *from, | 701 | unsigned long __must_check _copy_to_user(void __user *to, const void *from, |
| 698 | unsigned n); | 702 | unsigned n); |
| 699 | 703 | ||
| 700 | #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS | 704 | extern void __compiletime_error("usercopy buffer size is too small") |
| 701 | # define copy_user_diag __compiletime_error | 705 | __bad_copy_user(void); |
| 702 | #else | ||
| 703 | # define copy_user_diag __compiletime_warning | ||
| 704 | #endif | ||
| 705 | |||
| 706 | extern void copy_user_diag("copy_from_user() buffer size is too small") | ||
| 707 | copy_from_user_overflow(void); | ||
| 708 | extern void copy_user_diag("copy_to_user() buffer size is too small") | ||
| 709 | copy_to_user_overflow(void) __asm__("copy_from_user_overflow"); | ||
| 710 | |||
| 711 | #undef copy_user_diag | ||
| 712 | |||
| 713 | #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS | ||
| 714 | |||
| 715 | extern void | ||
| 716 | __compiletime_warning("copy_from_user() buffer size is not provably correct") | ||
| 717 | __copy_from_user_overflow(void) __asm__("copy_from_user_overflow"); | ||
| 718 | #define __copy_from_user_overflow(size, count) __copy_from_user_overflow() | ||
| 719 | |||
| 720 | extern void | ||
| 721 | __compiletime_warning("copy_to_user() buffer size is not provably correct") | ||
| 722 | __copy_to_user_overflow(void) __asm__("copy_from_user_overflow"); | ||
| 723 | #define __copy_to_user_overflow(size, count) __copy_to_user_overflow() | ||
| 724 | 706 | ||
| 725 | #else | 707 | static inline void copy_user_overflow(int size, unsigned long count) |
| 726 | |||
| 727 | static inline void | ||
| 728 | __copy_from_user_overflow(int size, unsigned long count) | ||
| 729 | { | 708 | { |
| 730 | WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count); | 709 | WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count); |
| 731 | } | 710 | } |
| 732 | 711 | ||
| 733 | #define __copy_to_user_overflow __copy_from_user_overflow | 712 | static __always_inline unsigned long __must_check |
| 734 | |||
| 735 | #endif | ||
| 736 | |||
| 737 | static inline unsigned long __must_check | ||
| 738 | copy_from_user(void *to, const void __user *from, unsigned long n) | 713 | copy_from_user(void *to, const void __user *from, unsigned long n) |
| 739 | { | 714 | { |
| 740 | int sz = __compiletime_object_size(to); | 715 | int sz = __compiletime_object_size(to); |
| @@ -743,36 +718,18 @@ copy_from_user(void *to, const void __user *from, unsigned long n) | |||
| 743 | 718 | ||
| 744 | kasan_check_write(to, n); | 719 | kasan_check_write(to, n); |
| 745 | 720 | ||
| 746 | /* | ||
| 747 | * While we would like to have the compiler do the checking for us | ||
| 748 | * even in the non-constant size case, any false positives there are | ||
| 749 | * a problem (especially when DEBUG_STRICT_USER_COPY_CHECKS, but even | ||
| 750 | * without - the [hopefully] dangerous looking nature of the warning | ||
| 751 | * would make people go look at the respecitive call sites over and | ||
| 752 | * over again just to find that there's no problem). | ||
| 753 | * | ||
| 754 | * And there are cases where it's just not realistic for the compiler | ||
| 755 | * to prove the count to be in range. For example when multiple call | ||
| 756 | * sites of a helper function - perhaps in different source files - | ||
| 757 | * all doing proper range checking, yet the helper function not doing | ||
| 758 | * so again. | ||
| 759 | * | ||
| 760 | * Therefore limit the compile time checking to the constant size | ||
| 761 | * case, and do only runtime checking for non-constant sizes. | ||
| 762 | */ | ||
| 763 | |||
| 764 | if (likely(sz < 0 || sz >= n)) { | 721 | if (likely(sz < 0 || sz >= n)) { |
| 765 | check_object_size(to, n, false); | 722 | check_object_size(to, n, false); |
| 766 | n = _copy_from_user(to, from, n); | 723 | n = _copy_from_user(to, from, n); |
| 767 | } else if (__builtin_constant_p(n)) | 724 | } else if (!__builtin_constant_p(n)) |
| 768 | copy_from_user_overflow(); | 725 | copy_user_overflow(sz, n); |
| 769 | else | 726 | else |
| 770 | __copy_from_user_overflow(sz, n); | 727 | __bad_copy_user(); |
| 771 | 728 | ||
| 772 | return n; | 729 | return n; |
| 773 | } | 730 | } |
| 774 | 731 | ||
| 775 | static inline unsigned long __must_check | 732 | static __always_inline unsigned long __must_check |
| 776 | copy_to_user(void __user *to, const void *from, unsigned long n) | 733 | copy_to_user(void __user *to, const void *from, unsigned long n) |
| 777 | { | 734 | { |
| 778 | int sz = __compiletime_object_size(from); | 735 | int sz = __compiletime_object_size(from); |
| @@ -781,21 +738,17 @@ copy_to_user(void __user *to, const void *from, unsigned long n) | |||
| 781 | 738 | ||
| 782 | might_fault(); | 739 | might_fault(); |
| 783 | 740 | ||
| 784 | /* See the comment in copy_from_user() above. */ | ||
| 785 | if (likely(sz < 0 || sz >= n)) { | 741 | if (likely(sz < 0 || sz >= n)) { |
| 786 | check_object_size(from, n, true); | 742 | check_object_size(from, n, true); |
| 787 | n = _copy_to_user(to, from, n); | 743 | n = _copy_to_user(to, from, n); |
| 788 | } else if (__builtin_constant_p(n)) | 744 | } else if (!__builtin_constant_p(n)) |
| 789 | copy_to_user_overflow(); | 745 | copy_user_overflow(sz, n); |
| 790 | else | 746 | else |
| 791 | __copy_to_user_overflow(sz, n); | 747 | __bad_copy_user(); |
| 792 | 748 | ||
| 793 | return n; | 749 | return n; |
| 794 | } | 750 | } |
| 795 | 751 | ||
| 796 | #undef __copy_from_user_overflow | ||
| 797 | #undef __copy_to_user_overflow | ||
| 798 | |||
| 799 | /* | 752 | /* |
| 800 | * We rely on the nested NMI work to allow atomic faults from the NMI path; the | 753 | * We rely on the nested NMI work to allow atomic faults from the NMI path; the |
| 801 | * nested NMI paths are careful to preserve CR2. | 754 | * nested NMI paths are careful to preserve CR2. |
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index cea4fc19e844..f3e9b2df4b16 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c | |||
| @@ -1623,6 +1623,9 @@ void __init enable_IR_x2apic(void) | |||
| 1623 | unsigned long flags; | 1623 | unsigned long flags; |
| 1624 | int ret, ir_stat; | 1624 | int ret, ir_stat; |
| 1625 | 1625 | ||
| 1626 | if (skip_ioapic_setup) | ||
| 1627 | return; | ||
| 1628 | |||
| 1626 | ir_stat = irq_remapping_prepare(); | 1629 | ir_stat = irq_remapping_prepare(); |
| 1627 | if (ir_stat < 0 && !x2apic_supported()) | 1630 | if (ir_stat < 0 && !x2apic_supported()) |
| 1628 | return; | 1631 | return; |
| @@ -2090,7 +2093,6 @@ int generic_processor_info(int apicid, int version) | |||
| 2090 | return -EINVAL; | 2093 | return -EINVAL; |
| 2091 | } | 2094 | } |
| 2092 | 2095 | ||
| 2093 | num_processors++; | ||
| 2094 | if (apicid == boot_cpu_physical_apicid) { | 2096 | if (apicid == boot_cpu_physical_apicid) { |
| 2095 | /* | 2097 | /* |
| 2096 | * x86_bios_cpu_apicid is required to have processors listed | 2098 | * x86_bios_cpu_apicid is required to have processors listed |
| @@ -2113,10 +2115,13 @@ int generic_processor_info(int apicid, int version) | |||
| 2113 | 2115 | ||
| 2114 | pr_warning("APIC: Package limit reached. Processor %d/0x%x ignored.\n", | 2116 | pr_warning("APIC: Package limit reached. Processor %d/0x%x ignored.\n", |
| 2115 | thiscpu, apicid); | 2117 | thiscpu, apicid); |
| 2118 | |||
| 2116 | disabled_cpus++; | 2119 | disabled_cpus++; |
| 2117 | return -ENOSPC; | 2120 | return -ENOSPC; |
| 2118 | } | 2121 | } |
| 2119 | 2122 | ||
| 2123 | num_processors++; | ||
| 2124 | |||
| 2120 | /* | 2125 | /* |
| 2121 | * Validate version | 2126 | * Validate version |
| 2122 | */ | 2127 | */ |
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index f5c69d8974e1..b81fe2d63e15 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
| @@ -669,6 +669,17 @@ static void init_amd_gh(struct cpuinfo_x86 *c) | |||
| 669 | set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH); | 669 | set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH); |
| 670 | } | 670 | } |
| 671 | 671 | ||
| 672 | #define MSR_AMD64_DE_CFG 0xC0011029 | ||
| 673 | |||
| 674 | static void init_amd_ln(struct cpuinfo_x86 *c) | ||
| 675 | { | ||
| 676 | /* | ||
| 677 | * Apply erratum 665 fix unconditionally so machines without a BIOS | ||
| 678 | * fix work. | ||
| 679 | */ | ||
| 680 | msr_set_bit(MSR_AMD64_DE_CFG, 31); | ||
| 681 | } | ||
| 682 | |||
| 672 | static void init_amd_bd(struct cpuinfo_x86 *c) | 683 | static void init_amd_bd(struct cpuinfo_x86 *c) |
| 673 | { | 684 | { |
| 674 | u64 value; | 685 | u64 value; |
| @@ -726,6 +737,7 @@ static void init_amd(struct cpuinfo_x86 *c) | |||
| 726 | case 6: init_amd_k7(c); break; | 737 | case 6: init_amd_k7(c); break; |
| 727 | case 0xf: init_amd_k8(c); break; | 738 | case 0xf: init_amd_k8(c); break; |
| 728 | case 0x10: init_amd_gh(c); break; | 739 | case 0x10: init_amd_gh(c); break; |
| 740 | case 0x12: init_amd_ln(c); break; | ||
| 729 | case 0x15: init_amd_bd(c); break; | 741 | case 0x15: init_amd_bd(c); break; |
| 730 | } | 742 | } |
| 731 | 743 | ||
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index b816971f5da4..620ab06bcf45 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c | |||
| @@ -54,6 +54,7 @@ static LIST_HEAD(pcache); | |||
| 54 | */ | 54 | */ |
| 55 | static u8 *container; | 55 | static u8 *container; |
| 56 | static size_t container_size; | 56 | static size_t container_size; |
| 57 | static bool ucode_builtin; | ||
| 57 | 58 | ||
| 58 | static u32 ucode_new_rev; | 59 | static u32 ucode_new_rev; |
| 59 | static u8 amd_ucode_patch[PATCH_MAX_SIZE]; | 60 | static u8 amd_ucode_patch[PATCH_MAX_SIZE]; |
| @@ -281,18 +282,22 @@ static bool __init load_builtin_amd_microcode(struct cpio_data *cp, | |||
| 281 | void __init load_ucode_amd_bsp(unsigned int family) | 282 | void __init load_ucode_amd_bsp(unsigned int family) |
| 282 | { | 283 | { |
| 283 | struct cpio_data cp; | 284 | struct cpio_data cp; |
| 285 | bool *builtin; | ||
| 284 | void **data; | 286 | void **data; |
| 285 | size_t *size; | 287 | size_t *size; |
| 286 | 288 | ||
| 287 | #ifdef CONFIG_X86_32 | 289 | #ifdef CONFIG_X86_32 |
| 288 | data = (void **)__pa_nodebug(&ucode_cpio.data); | 290 | data = (void **)__pa_nodebug(&ucode_cpio.data); |
| 289 | size = (size_t *)__pa_nodebug(&ucode_cpio.size); | 291 | size = (size_t *)__pa_nodebug(&ucode_cpio.size); |
| 292 | builtin = (bool *)__pa_nodebug(&ucode_builtin); | ||
| 290 | #else | 293 | #else |
| 291 | data = &ucode_cpio.data; | 294 | data = &ucode_cpio.data; |
| 292 | size = &ucode_cpio.size; | 295 | size = &ucode_cpio.size; |
| 296 | builtin = &ucode_builtin; | ||
| 293 | #endif | 297 | #endif |
| 294 | 298 | ||
| 295 | if (!load_builtin_amd_microcode(&cp, family)) | 299 | *builtin = load_builtin_amd_microcode(&cp, family); |
| 300 | if (!*builtin) | ||
| 296 | cp = find_ucode_in_initrd(); | 301 | cp = find_ucode_in_initrd(); |
| 297 | 302 | ||
| 298 | if (!(cp.data && cp.size)) | 303 | if (!(cp.data && cp.size)) |
| @@ -373,7 +378,8 @@ void load_ucode_amd_ap(void) | |||
| 373 | return; | 378 | return; |
| 374 | 379 | ||
| 375 | /* Add CONFIG_RANDOMIZE_MEMORY offset. */ | 380 | /* Add CONFIG_RANDOMIZE_MEMORY offset. */ |
| 376 | cont += PAGE_OFFSET - __PAGE_OFFSET_BASE; | 381 | if (!ucode_builtin) |
| 382 | cont += PAGE_OFFSET - __PAGE_OFFSET_BASE; | ||
| 377 | 383 | ||
| 378 | eax = cpuid_eax(0x00000001); | 384 | eax = cpuid_eax(0x00000001); |
| 379 | eq = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ); | 385 | eq = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ); |
| @@ -439,7 +445,8 @@ int __init save_microcode_in_initrd_amd(void) | |||
| 439 | container = cont_va; | 445 | container = cont_va; |
| 440 | 446 | ||
| 441 | /* Add CONFIG_RANDOMIZE_MEMORY offset. */ | 447 | /* Add CONFIG_RANDOMIZE_MEMORY offset. */ |
| 442 | container += PAGE_OFFSET - __PAGE_OFFSET_BASE; | 448 | if (!ucode_builtin) |
| 449 | container += PAGE_OFFSET - __PAGE_OFFSET_BASE; | ||
| 443 | 450 | ||
| 444 | eax = cpuid_eax(0x00000001); | 451 | eax = cpuid_eax(0x00000001); |
| 445 | eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); | 452 | eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); |
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index 1d39bfbd26bb..3692249a70f1 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c | |||
| @@ -289,6 +289,7 @@ void __init kvmclock_init(void) | |||
| 289 | put_cpu(); | 289 | put_cpu(); |
| 290 | 290 | ||
| 291 | x86_platform.calibrate_tsc = kvm_get_tsc_khz; | 291 | x86_platform.calibrate_tsc = kvm_get_tsc_khz; |
| 292 | x86_platform.calibrate_cpu = kvm_get_tsc_khz; | ||
| 292 | x86_platform.get_wallclock = kvm_get_wallclock; | 293 | x86_platform.get_wallclock = kvm_get_wallclock; |
| 293 | x86_platform.set_wallclock = kvm_set_wallclock; | 294 | x86_platform.set_wallclock = kvm_set_wallclock; |
| 294 | #ifdef CONFIG_X86_LOCAL_APIC | 295 | #ifdef CONFIG_X86_LOCAL_APIC |
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index ad5bc9578a73..1acfd76e3e26 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c | |||
| @@ -56,12 +56,12 @@ asm (".pushsection .entry.text, \"ax\"\n" | |||
| 56 | ".popsection"); | 56 | ".popsection"); |
| 57 | 57 | ||
| 58 | /* identity function, which can be inlined */ | 58 | /* identity function, which can be inlined */ |
| 59 | u32 _paravirt_ident_32(u32 x) | 59 | u32 notrace _paravirt_ident_32(u32 x) |
| 60 | { | 60 | { |
| 61 | return x; | 61 | return x; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | u64 _paravirt_ident_64(u64 x) | 64 | u64 notrace _paravirt_ident_64(u64 x) |
| 65 | { | 65 | { |
| 66 | return x; | 66 | return x; |
| 67 | } | 67 | } |
diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c index 5f42d038fcb4..c7220ba94aa7 100644 --- a/arch/x86/kvm/ioapic.c +++ b/arch/x86/kvm/ioapic.c | |||
| @@ -109,6 +109,7 @@ static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu *vcpu) | |||
| 109 | { | 109 | { |
| 110 | bool new_val, old_val; | 110 | bool new_val, old_val; |
| 111 | struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic; | 111 | struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic; |
| 112 | struct dest_map *dest_map = &ioapic->rtc_status.dest_map; | ||
| 112 | union kvm_ioapic_redirect_entry *e; | 113 | union kvm_ioapic_redirect_entry *e; |
| 113 | 114 | ||
| 114 | e = &ioapic->redirtbl[RTC_GSI]; | 115 | e = &ioapic->redirtbl[RTC_GSI]; |
| @@ -117,16 +118,17 @@ static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu *vcpu) | |||
| 117 | return; | 118 | return; |
| 118 | 119 | ||
| 119 | new_val = kvm_apic_pending_eoi(vcpu, e->fields.vector); | 120 | new_val = kvm_apic_pending_eoi(vcpu, e->fields.vector); |
| 120 | old_val = test_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map.map); | 121 | old_val = test_bit(vcpu->vcpu_id, dest_map->map); |
| 121 | 122 | ||
| 122 | if (new_val == old_val) | 123 | if (new_val == old_val) |
| 123 | return; | 124 | return; |
| 124 | 125 | ||
| 125 | if (new_val) { | 126 | if (new_val) { |
| 126 | __set_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map.map); | 127 | __set_bit(vcpu->vcpu_id, dest_map->map); |
| 128 | dest_map->vectors[vcpu->vcpu_id] = e->fields.vector; | ||
| 127 | ioapic->rtc_status.pending_eoi++; | 129 | ioapic->rtc_status.pending_eoi++; |
| 128 | } else { | 130 | } else { |
| 129 | __clear_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map.map); | 131 | __clear_bit(vcpu->vcpu_id, dest_map->map); |
| 130 | ioapic->rtc_status.pending_eoi--; | 132 | ioapic->rtc_status.pending_eoi--; |
| 131 | rtc_status_pending_eoi_check_valid(ioapic); | 133 | rtc_status_pending_eoi_check_valid(ioapic); |
| 132 | } | 134 | } |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index a45d8580f91e..5cede40e2552 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
| @@ -422,6 +422,7 @@ struct nested_vmx { | |||
| 422 | struct list_head vmcs02_pool; | 422 | struct list_head vmcs02_pool; |
| 423 | int vmcs02_num; | 423 | int vmcs02_num; |
| 424 | u64 vmcs01_tsc_offset; | 424 | u64 vmcs01_tsc_offset; |
| 425 | bool change_vmcs01_virtual_x2apic_mode; | ||
| 425 | /* L2 must run next, and mustn't decide to exit to L1. */ | 426 | /* L2 must run next, and mustn't decide to exit to L1. */ |
| 426 | bool nested_run_pending; | 427 | bool nested_run_pending; |
| 427 | /* | 428 | /* |
| @@ -435,6 +436,8 @@ struct nested_vmx { | |||
| 435 | bool pi_pending; | 436 | bool pi_pending; |
| 436 | u16 posted_intr_nv; | 437 | u16 posted_intr_nv; |
| 437 | 438 | ||
| 439 | unsigned long *msr_bitmap; | ||
| 440 | |||
| 438 | struct hrtimer preemption_timer; | 441 | struct hrtimer preemption_timer; |
| 439 | bool preemption_timer_expired; | 442 | bool preemption_timer_expired; |
| 440 | 443 | ||
| @@ -924,7 +927,6 @@ static unsigned long *vmx_msr_bitmap_legacy; | |||
| 924 | static unsigned long *vmx_msr_bitmap_longmode; | 927 | static unsigned long *vmx_msr_bitmap_longmode; |
| 925 | static unsigned long *vmx_msr_bitmap_legacy_x2apic; | 928 | static unsigned long *vmx_msr_bitmap_legacy_x2apic; |
| 926 | static unsigned long *vmx_msr_bitmap_longmode_x2apic; | 929 | static unsigned long *vmx_msr_bitmap_longmode_x2apic; |
| 927 | static unsigned long *vmx_msr_bitmap_nested; | ||
| 928 | static unsigned long *vmx_vmread_bitmap; | 930 | static unsigned long *vmx_vmread_bitmap; |
| 929 | static unsigned long *vmx_vmwrite_bitmap; | 931 | static unsigned long *vmx_vmwrite_bitmap; |
| 930 | 932 | ||
| @@ -2198,6 +2200,12 @@ static void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) | |||
| 2198 | new.control) != old.control); | 2200 | new.control) != old.control); |
| 2199 | } | 2201 | } |
| 2200 | 2202 | ||
| 2203 | static void decache_tsc_multiplier(struct vcpu_vmx *vmx) | ||
| 2204 | { | ||
| 2205 | vmx->current_tsc_ratio = vmx->vcpu.arch.tsc_scaling_ratio; | ||
| 2206 | vmcs_write64(TSC_MULTIPLIER, vmx->current_tsc_ratio); | ||
| 2207 | } | ||
| 2208 | |||
| 2201 | /* | 2209 | /* |
| 2202 | * Switches to specified vcpu, until a matching vcpu_put(), but assumes | 2210 | * Switches to specified vcpu, until a matching vcpu_put(), but assumes |
| 2203 | * vcpu mutex is already taken. | 2211 | * vcpu mutex is already taken. |
| @@ -2256,10 +2264,8 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | |||
| 2256 | 2264 | ||
| 2257 | /* Setup TSC multiplier */ | 2265 | /* Setup TSC multiplier */ |
| 2258 | if (kvm_has_tsc_control && | 2266 | if (kvm_has_tsc_control && |
| 2259 | vmx->current_tsc_ratio != vcpu->arch.tsc_scaling_ratio) { | 2267 | vmx->current_tsc_ratio != vcpu->arch.tsc_scaling_ratio) |
| 2260 | vmx->current_tsc_ratio = vcpu->arch.tsc_scaling_ratio; | 2268 | decache_tsc_multiplier(vmx); |
| 2261 | vmcs_write64(TSC_MULTIPLIER, vmx->current_tsc_ratio); | ||
| 2262 | } | ||
| 2263 | 2269 | ||
| 2264 | vmx_vcpu_pi_load(vcpu, cpu); | 2270 | vmx_vcpu_pi_load(vcpu, cpu); |
| 2265 | vmx->host_pkru = read_pkru(); | 2271 | vmx->host_pkru = read_pkru(); |
| @@ -2508,7 +2514,7 @@ static void vmx_set_msr_bitmap(struct kvm_vcpu *vcpu) | |||
| 2508 | unsigned long *msr_bitmap; | 2514 | unsigned long *msr_bitmap; |
| 2509 | 2515 | ||
| 2510 | if (is_guest_mode(vcpu)) | 2516 | if (is_guest_mode(vcpu)) |
| 2511 | msr_bitmap = vmx_msr_bitmap_nested; | 2517 | msr_bitmap = to_vmx(vcpu)->nested.msr_bitmap; |
| 2512 | else if (cpu_has_secondary_exec_ctrls() && | 2518 | else if (cpu_has_secondary_exec_ctrls() && |
| 2513 | (vmcs_read32(SECONDARY_VM_EXEC_CONTROL) & | 2519 | (vmcs_read32(SECONDARY_VM_EXEC_CONTROL) & |
| 2514 | SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE)) { | 2520 | SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE)) { |
| @@ -6363,13 +6369,6 @@ static __init int hardware_setup(void) | |||
| 6363 | if (!vmx_msr_bitmap_longmode_x2apic) | 6369 | if (!vmx_msr_bitmap_longmode_x2apic) |
| 6364 | goto out4; | 6370 | goto out4; |
| 6365 | 6371 | ||
| 6366 | if (nested) { | ||
| 6367 | vmx_msr_bitmap_nested = | ||
| 6368 | (unsigned long *)__get_free_page(GFP_KERNEL); | ||
| 6369 | if (!vmx_msr_bitmap_nested) | ||
| 6370 | goto out5; | ||
| 6371 | } | ||
| 6372 | |||
| 6373 | vmx_vmread_bitmap = (unsigned long *)__get_free_page(GFP_KERNEL); | 6372 | vmx_vmread_bitmap = (unsigned long *)__get_free_page(GFP_KERNEL); |
| 6374 | if (!vmx_vmread_bitmap) | 6373 | if (!vmx_vmread_bitmap) |
| 6375 | goto out6; | 6374 | goto out6; |
| @@ -6392,8 +6391,6 @@ static __init int hardware_setup(void) | |||
| 6392 | 6391 | ||
| 6393 | memset(vmx_msr_bitmap_legacy, 0xff, PAGE_SIZE); | 6392 | memset(vmx_msr_bitmap_legacy, 0xff, PAGE_SIZE); |
| 6394 | memset(vmx_msr_bitmap_longmode, 0xff, PAGE_SIZE); | 6393 | memset(vmx_msr_bitmap_longmode, 0xff, PAGE_SIZE); |
| 6395 | if (nested) | ||
| 6396 | memset(vmx_msr_bitmap_nested, 0xff, PAGE_SIZE); | ||
| 6397 | 6394 | ||
| 6398 | if (setup_vmcs_config(&vmcs_config) < 0) { | 6395 | if (setup_vmcs_config(&vmcs_config) < 0) { |
| 6399 | r = -EIO; | 6396 | r = -EIO; |
| @@ -6529,9 +6526,6 @@ out8: | |||
| 6529 | out7: | 6526 | out7: |
| 6530 | free_page((unsigned long)vmx_vmread_bitmap); | 6527 | free_page((unsigned long)vmx_vmread_bitmap); |
| 6531 | out6: | 6528 | out6: |
| 6532 | if (nested) | ||
| 6533 | free_page((unsigned long)vmx_msr_bitmap_nested); | ||
| 6534 | out5: | ||
| 6535 | free_page((unsigned long)vmx_msr_bitmap_longmode_x2apic); | 6529 | free_page((unsigned long)vmx_msr_bitmap_longmode_x2apic); |
| 6536 | out4: | 6530 | out4: |
| 6537 | free_page((unsigned long)vmx_msr_bitmap_longmode); | 6531 | free_page((unsigned long)vmx_msr_bitmap_longmode); |
| @@ -6557,8 +6551,6 @@ static __exit void hardware_unsetup(void) | |||
| 6557 | free_page((unsigned long)vmx_io_bitmap_a); | 6551 | free_page((unsigned long)vmx_io_bitmap_a); |
| 6558 | free_page((unsigned long)vmx_vmwrite_bitmap); | 6552 | free_page((unsigned long)vmx_vmwrite_bitmap); |
| 6559 | free_page((unsigned long)vmx_vmread_bitmap); | 6553 | free_page((unsigned long)vmx_vmread_bitmap); |
| 6560 | if (nested) | ||
| 6561 | free_page((unsigned long)vmx_msr_bitmap_nested); | ||
| 6562 | 6554 | ||
| 6563 | free_kvm_area(); | 6555 | free_kvm_area(); |
| 6564 | } | 6556 | } |
| @@ -6995,16 +6987,21 @@ static int handle_vmon(struct kvm_vcpu *vcpu) | |||
| 6995 | return 1; | 6987 | return 1; |
| 6996 | } | 6988 | } |
| 6997 | 6989 | ||
| 6990 | if (cpu_has_vmx_msr_bitmap()) { | ||
| 6991 | vmx->nested.msr_bitmap = | ||
| 6992 | (unsigned long *)__get_free_page(GFP_KERNEL); | ||
| 6993 | if (!vmx->nested.msr_bitmap) | ||
| 6994 | goto out_msr_bitmap; | ||
| 6995 | } | ||
| 6996 | |||
| 6998 | vmx->nested.cached_vmcs12 = kmalloc(VMCS12_SIZE, GFP_KERNEL); | 6997 | vmx->nested.cached_vmcs12 = kmalloc(VMCS12_SIZE, GFP_KERNEL); |
| 6999 | if (!vmx->nested.cached_vmcs12) | 6998 | if (!vmx->nested.cached_vmcs12) |
| 7000 | return -ENOMEM; | 6999 | goto out_cached_vmcs12; |
| 7001 | 7000 | ||
| 7002 | if (enable_shadow_vmcs) { | 7001 | if (enable_shadow_vmcs) { |
| 7003 | shadow_vmcs = alloc_vmcs(); | 7002 | shadow_vmcs = alloc_vmcs(); |
| 7004 | if (!shadow_vmcs) { | 7003 | if (!shadow_vmcs) |
| 7005 | kfree(vmx->nested.cached_vmcs12); | 7004 | goto out_shadow_vmcs; |
| 7006 | return -ENOMEM; | ||
| 7007 | } | ||
| 7008 | /* mark vmcs as shadow */ | 7005 | /* mark vmcs as shadow */ |
| 7009 | shadow_vmcs->revision_id |= (1u << 31); | 7006 | shadow_vmcs->revision_id |= (1u << 31); |
| 7010 | /* init shadow vmcs */ | 7007 | /* init shadow vmcs */ |
| @@ -7024,6 +7021,15 @@ static int handle_vmon(struct kvm_vcpu *vcpu) | |||
| 7024 | skip_emulated_instruction(vcpu); | 7021 | skip_emulated_instruction(vcpu); |
| 7025 | nested_vmx_succeed(vcpu); | 7022 | nested_vmx_succeed(vcpu); |
| 7026 | return 1; | 7023 | return 1; |
| 7024 | |||
| 7025 | out_shadow_vmcs: | ||
| 7026 | kfree(vmx->nested.cached_vmcs12); | ||
| 7027 | |||
| 7028 | out_cached_vmcs12: | ||
| 7029 | free_page((unsigned long)vmx->nested.msr_bitmap); | ||
| 7030 | |||
| 7031 | out_msr_bitmap: | ||
| 7032 | return -ENOMEM; | ||
| 7027 | } | 7033 | } |
| 7028 | 7034 | ||
| 7029 | /* | 7035 | /* |
| @@ -7098,6 +7104,10 @@ static void free_nested(struct vcpu_vmx *vmx) | |||
| 7098 | vmx->nested.vmxon = false; | 7104 | vmx->nested.vmxon = false; |
| 7099 | free_vpid(vmx->nested.vpid02); | 7105 | free_vpid(vmx->nested.vpid02); |
| 7100 | nested_release_vmcs12(vmx); | 7106 | nested_release_vmcs12(vmx); |
| 7107 | if (vmx->nested.msr_bitmap) { | ||
| 7108 | free_page((unsigned long)vmx->nested.msr_bitmap); | ||
| 7109 | vmx->nested.msr_bitmap = NULL; | ||
| 7110 | } | ||
| 7101 | if (enable_shadow_vmcs) | 7111 | if (enable_shadow_vmcs) |
| 7102 | free_vmcs(vmx->nested.current_shadow_vmcs); | 7112 | free_vmcs(vmx->nested.current_shadow_vmcs); |
| 7103 | kfree(vmx->nested.cached_vmcs12); | 7113 | kfree(vmx->nested.cached_vmcs12); |
| @@ -8419,6 +8429,12 @@ static void vmx_set_virtual_x2apic_mode(struct kvm_vcpu *vcpu, bool set) | |||
| 8419 | { | 8429 | { |
| 8420 | u32 sec_exec_control; | 8430 | u32 sec_exec_control; |
| 8421 | 8431 | ||
| 8432 | /* Postpone execution until vmcs01 is the current VMCS. */ | ||
| 8433 | if (is_guest_mode(vcpu)) { | ||
| 8434 | to_vmx(vcpu)->nested.change_vmcs01_virtual_x2apic_mode = true; | ||
| 8435 | return; | ||
| 8436 | } | ||
| 8437 | |||
| 8422 | /* | 8438 | /* |
| 8423 | * There is not point to enable virtualize x2apic without enable | 8439 | * There is not point to enable virtualize x2apic without enable |
| 8424 | * apicv | 8440 | * apicv |
| @@ -9472,8 +9488,10 @@ static inline bool nested_vmx_merge_msr_bitmap(struct kvm_vcpu *vcpu, | |||
| 9472 | { | 9488 | { |
| 9473 | int msr; | 9489 | int msr; |
| 9474 | struct page *page; | 9490 | struct page *page; |
| 9475 | unsigned long *msr_bitmap; | 9491 | unsigned long *msr_bitmap_l1; |
| 9492 | unsigned long *msr_bitmap_l0 = to_vmx(vcpu)->nested.msr_bitmap; | ||
| 9476 | 9493 | ||
| 9494 | /* This shortcut is ok because we support only x2APIC MSRs so far. */ | ||
| 9477 | if (!nested_cpu_has_virt_x2apic_mode(vmcs12)) | 9495 | if (!nested_cpu_has_virt_x2apic_mode(vmcs12)) |
| 9478 | return false; | 9496 | return false; |
| 9479 | 9497 | ||
| @@ -9482,63 +9500,37 @@ static inline bool nested_vmx_merge_msr_bitmap(struct kvm_vcpu *vcpu, | |||
| 9482 | WARN_ON(1); | 9500 | WARN_ON(1); |
| 9483 | return false; | 9501 | return false; |
| 9484 | } | 9502 | } |
| 9485 | msr_bitmap = (unsigned long *)kmap(page); | 9503 | msr_bitmap_l1 = (unsigned long *)kmap(page); |
| 9486 | if (!msr_bitmap) { | 9504 | if (!msr_bitmap_l1) { |
| 9487 | nested_release_page_clean(page); | 9505 | nested_release_page_clean(page); |
| 9488 | WARN_ON(1); | 9506 | WARN_ON(1); |
| 9489 | return false; | 9507 | return false; |
| 9490 | } | 9508 | } |
| 9491 | 9509 | ||
| 9510 | memset(msr_bitmap_l0, 0xff, PAGE_SIZE); | ||
| 9511 | |||
| 9492 | if (nested_cpu_has_virt_x2apic_mode(vmcs12)) { | 9512 | if (nested_cpu_has_virt_x2apic_mode(vmcs12)) { |
| 9493 | if (nested_cpu_has_apic_reg_virt(vmcs12)) | 9513 | if (nested_cpu_has_apic_reg_virt(vmcs12)) |
| 9494 | for (msr = 0x800; msr <= 0x8ff; msr++) | 9514 | for (msr = 0x800; msr <= 0x8ff; msr++) |
| 9495 | nested_vmx_disable_intercept_for_msr( | 9515 | nested_vmx_disable_intercept_for_msr( |
| 9496 | msr_bitmap, | 9516 | msr_bitmap_l1, msr_bitmap_l0, |
| 9497 | vmx_msr_bitmap_nested, | ||
| 9498 | msr, MSR_TYPE_R); | 9517 | msr, MSR_TYPE_R); |
| 9499 | /* TPR is allowed */ | 9518 | |
| 9500 | nested_vmx_disable_intercept_for_msr(msr_bitmap, | 9519 | nested_vmx_disable_intercept_for_msr( |
| 9501 | vmx_msr_bitmap_nested, | 9520 | msr_bitmap_l1, msr_bitmap_l0, |
| 9502 | APIC_BASE_MSR + (APIC_TASKPRI >> 4), | 9521 | APIC_BASE_MSR + (APIC_TASKPRI >> 4), |
| 9503 | MSR_TYPE_R | MSR_TYPE_W); | 9522 | MSR_TYPE_R | MSR_TYPE_W); |
| 9523 | |||
| 9504 | if (nested_cpu_has_vid(vmcs12)) { | 9524 | if (nested_cpu_has_vid(vmcs12)) { |
| 9505 | /* EOI and self-IPI are allowed */ | ||
| 9506 | nested_vmx_disable_intercept_for_msr( | 9525 | nested_vmx_disable_intercept_for_msr( |
| 9507 | msr_bitmap, | 9526 | msr_bitmap_l1, msr_bitmap_l0, |
| 9508 | vmx_msr_bitmap_nested, | ||
| 9509 | APIC_BASE_MSR + (APIC_EOI >> 4), | 9527 | APIC_BASE_MSR + (APIC_EOI >> 4), |
| 9510 | MSR_TYPE_W); | 9528 | MSR_TYPE_W); |
| 9511 | nested_vmx_disable_intercept_for_msr( | 9529 | nested_vmx_disable_intercept_for_msr( |
| 9512 | msr_bitmap, | 9530 | msr_bitmap_l1, msr_bitmap_l0, |
| 9513 | vmx_msr_bitmap_nested, | ||
| 9514 | APIC_BASE_MSR + (APIC_SELF_IPI >> 4), | 9531 | APIC_BASE_MSR + (APIC_SELF_IPI >> 4), |
| 9515 | MSR_TYPE_W); | 9532 | MSR_TYPE_W); |
| 9516 | } | 9533 | } |
| 9517 | } else { | ||
| 9518 | /* | ||
| 9519 | * Enable reading intercept of all the x2apic | ||
| 9520 | * MSRs. We should not rely on vmcs12 to do any | ||
| 9521 | * optimizations here, it may have been modified | ||
| 9522 | * by L1. | ||
| 9523 | */ | ||
| 9524 | for (msr = 0x800; msr <= 0x8ff; msr++) | ||
| 9525 | __vmx_enable_intercept_for_msr( | ||
| 9526 | vmx_msr_bitmap_nested, | ||
| 9527 | msr, | ||
| 9528 | MSR_TYPE_R); | ||
| 9529 | |||
| 9530 | __vmx_enable_intercept_for_msr( | ||
| 9531 | vmx_msr_bitmap_nested, | ||
| 9532 | APIC_BASE_MSR + (APIC_TASKPRI >> 4), | ||
| 9533 | MSR_TYPE_W); | ||
| 9534 | __vmx_enable_intercept_for_msr( | ||
| 9535 | vmx_msr_bitmap_nested, | ||
| 9536 | APIC_BASE_MSR + (APIC_EOI >> 4), | ||
| 9537 | MSR_TYPE_W); | ||
| 9538 | __vmx_enable_intercept_for_msr( | ||
| 9539 | vmx_msr_bitmap_nested, | ||
| 9540 | APIC_BASE_MSR + (APIC_SELF_IPI >> 4), | ||
| 9541 | MSR_TYPE_W); | ||
| 9542 | } | 9534 | } |
| 9543 | kunmap(page); | 9535 | kunmap(page); |
| 9544 | nested_release_page_clean(page); | 9536 | nested_release_page_clean(page); |
| @@ -9957,10 +9949,10 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) | |||
| 9957 | } | 9949 | } |
| 9958 | 9950 | ||
| 9959 | if (cpu_has_vmx_msr_bitmap() && | 9951 | if (cpu_has_vmx_msr_bitmap() && |
| 9960 | exec_control & CPU_BASED_USE_MSR_BITMAPS) { | 9952 | exec_control & CPU_BASED_USE_MSR_BITMAPS && |
| 9961 | nested_vmx_merge_msr_bitmap(vcpu, vmcs12); | 9953 | nested_vmx_merge_msr_bitmap(vcpu, vmcs12)) |
| 9962 | /* MSR_BITMAP will be set by following vmx_set_efer. */ | 9954 | ; /* MSR_BITMAP will be set by following vmx_set_efer. */ |
| 9963 | } else | 9955 | else |
| 9964 | exec_control &= ~CPU_BASED_USE_MSR_BITMAPS; | 9956 | exec_control &= ~CPU_BASED_USE_MSR_BITMAPS; |
| 9965 | 9957 | ||
| 9966 | /* | 9958 | /* |
| @@ -10011,6 +10003,8 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) | |||
| 10011 | vmx->nested.vmcs01_tsc_offset + vmcs12->tsc_offset); | 10003 | vmx->nested.vmcs01_tsc_offset + vmcs12->tsc_offset); |
| 10012 | else | 10004 | else |
| 10013 | vmcs_write64(TSC_OFFSET, vmx->nested.vmcs01_tsc_offset); | 10005 | vmcs_write64(TSC_OFFSET, vmx->nested.vmcs01_tsc_offset); |
| 10006 | if (kvm_has_tsc_control) | ||
| 10007 | decache_tsc_multiplier(vmx); | ||
| 10014 | 10008 | ||
| 10015 | if (enable_vpid) { | 10009 | if (enable_vpid) { |
| 10016 | /* | 10010 | /* |
| @@ -10767,6 +10761,14 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason, | |||
| 10767 | else | 10761 | else |
| 10768 | vmcs_set_bits(PIN_BASED_VM_EXEC_CONTROL, | 10762 | vmcs_set_bits(PIN_BASED_VM_EXEC_CONTROL, |
| 10769 | PIN_BASED_VMX_PREEMPTION_TIMER); | 10763 | PIN_BASED_VMX_PREEMPTION_TIMER); |
| 10764 | if (kvm_has_tsc_control) | ||
| 10765 | decache_tsc_multiplier(vmx); | ||
| 10766 | |||
| 10767 | if (vmx->nested.change_vmcs01_virtual_x2apic_mode) { | ||
| 10768 | vmx->nested.change_vmcs01_virtual_x2apic_mode = false; | ||
| 10769 | vmx_set_virtual_x2apic_mode(vcpu, | ||
| 10770 | vcpu->arch.apic_base & X2APIC_ENABLE); | ||
| 10771 | } | ||
| 10770 | 10772 | ||
| 10771 | /* This is needed for same reason as it was needed in prepare_vmcs02 */ | 10773 | /* This is needed for same reason as it was needed in prepare_vmcs02 */ |
| 10772 | vmx->host_rsp = 0; | 10774 | vmx->host_rsp = 0; |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 19f9f9e05c2a..699f8726539a 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
| @@ -2743,16 +2743,16 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | |||
| 2743 | if (tsc_delta < 0) | 2743 | if (tsc_delta < 0) |
| 2744 | mark_tsc_unstable("KVM discovered backwards TSC"); | 2744 | mark_tsc_unstable("KVM discovered backwards TSC"); |
| 2745 | 2745 | ||
| 2746 | if (kvm_lapic_hv_timer_in_use(vcpu) && | ||
| 2747 | kvm_x86_ops->set_hv_timer(vcpu, | ||
| 2748 | kvm_get_lapic_tscdeadline_msr(vcpu))) | ||
| 2749 | kvm_lapic_switch_to_sw_timer(vcpu); | ||
| 2750 | if (check_tsc_unstable()) { | 2746 | if (check_tsc_unstable()) { |
| 2751 | u64 offset = kvm_compute_tsc_offset(vcpu, | 2747 | u64 offset = kvm_compute_tsc_offset(vcpu, |
| 2752 | vcpu->arch.last_guest_tsc); | 2748 | vcpu->arch.last_guest_tsc); |
| 2753 | kvm_x86_ops->write_tsc_offset(vcpu, offset); | 2749 | kvm_x86_ops->write_tsc_offset(vcpu, offset); |
| 2754 | vcpu->arch.tsc_catchup = 1; | 2750 | vcpu->arch.tsc_catchup = 1; |
| 2755 | } | 2751 | } |
| 2752 | if (kvm_lapic_hv_timer_in_use(vcpu) && | ||
| 2753 | kvm_x86_ops->set_hv_timer(vcpu, | ||
| 2754 | kvm_get_lapic_tscdeadline_msr(vcpu))) | ||
| 2755 | kvm_lapic_switch_to_sw_timer(vcpu); | ||
| 2756 | /* | 2756 | /* |
| 2757 | * On a host with synchronized TSC, there is no need to update | 2757 | * On a host with synchronized TSC, there is no need to update |
| 2758 | * kvmclock on vcpu->cpu migration | 2758 | * kvmclock on vcpu->cpu migration |
diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c index ec8654f117d8..bda8d5eef04d 100644 --- a/arch/x86/mm/kaslr.c +++ b/arch/x86/mm/kaslr.c | |||
| @@ -77,7 +77,7 @@ static inline unsigned long get_padding(struct kaslr_memory_region *region) | |||
| 77 | */ | 77 | */ |
| 78 | static inline bool kaslr_memory_enabled(void) | 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 | /* Initialize base and padding for each memory region randomized with KASLR */ | 83 | /* Initialize base and padding for each memory region randomized with KASLR */ |
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index ecb1b69c1651..170cc4ff057b 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c | |||
| @@ -927,9 +927,10 @@ int track_pfn_copy(struct vm_area_struct *vma) | |||
| 927 | } | 927 | } |
| 928 | 928 | ||
| 929 | /* | 929 | /* |
| 930 | * prot is passed in as a parameter for the new mapping. If the vma has a | 930 | * prot is passed in as a parameter for the new mapping. If the vma has |
| 931 | * linear pfn mapping for the entire range reserve the entire vma range with | 931 | * a linear pfn mapping for the entire range, or no vma is provided, |
| 932 | * single reserve_pfn_range call. | 932 | * reserve the entire pfn + size range with single reserve_pfn_range |
| 933 | * call. | ||
| 933 | */ | 934 | */ |
| 934 | int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, | 935 | int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, |
| 935 | unsigned long pfn, unsigned long addr, unsigned long size) | 936 | unsigned long pfn, unsigned long addr, unsigned long size) |
| @@ -938,11 +939,12 @@ int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, | |||
| 938 | enum page_cache_mode pcm; | 939 | enum page_cache_mode pcm; |
| 939 | 940 | ||
| 940 | /* reserve the whole chunk starting from paddr */ | 941 | /* reserve the whole chunk starting from paddr */ |
| 941 | if (addr == vma->vm_start && size == (vma->vm_end - vma->vm_start)) { | 942 | if (!vma || (addr == vma->vm_start |
| 943 | && size == (vma->vm_end - vma->vm_start))) { | ||
| 942 | int ret; | 944 | int ret; |
| 943 | 945 | ||
| 944 | ret = reserve_pfn_range(paddr, size, prot, 0); | 946 | ret = reserve_pfn_range(paddr, size, prot, 0); |
| 945 | if (!ret) | 947 | if (ret == 0 && vma) |
| 946 | vma->vm_flags |= VM_PAT; | 948 | vma->vm_flags |= VM_PAT; |
| 947 | return ret; | 949 | return ret; |
| 948 | } | 950 | } |
| @@ -997,7 +999,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, | |||
| 997 | resource_size_t paddr; | 999 | resource_size_t paddr; |
| 998 | unsigned long prot; | 1000 | unsigned long prot; |
| 999 | 1001 | ||
| 1000 | if (!(vma->vm_flags & VM_PAT)) | 1002 | if (vma && !(vma->vm_flags & VM_PAT)) |
| 1001 | return; | 1003 | return; |
| 1002 | 1004 | ||
| 1003 | /* free the chunk starting from pfn or the whole chunk */ | 1005 | /* free the chunk starting from pfn or the whole chunk */ |
| @@ -1011,7 +1013,8 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, | |||
| 1011 | size = vma->vm_end - vma->vm_start; | 1013 | size = vma->vm_end - vma->vm_start; |
| 1012 | } | 1014 | } |
| 1013 | free_pfn_range(paddr, size); | 1015 | free_pfn_range(paddr, size); |
| 1014 | vma->vm_flags &= ~VM_PAT; | 1016 | if (vma) |
| 1017 | vma->vm_flags &= ~VM_PAT; | ||
| 1015 | } | 1018 | } |
| 1016 | 1019 | ||
| 1017 | /* | 1020 | /* |
diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c index 837ea36a837d..6d52b94f4bb9 100644 --- a/arch/x86/pci/fixup.c +++ b/arch/x86/pci/fixup.c | |||
| @@ -553,15 +553,21 @@ static void twinhead_reserve_killing_zone(struct pci_dev *dev) | |||
| 553 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x27B9, twinhead_reserve_killing_zone); | 553 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x27B9, twinhead_reserve_killing_zone); |
| 554 | 554 | ||
| 555 | /* | 555 | /* |
| 556 | * Broadwell EP Home Agent BARs erroneously return non-zero values when read. | 556 | * Device [8086:2fc0] |
| 557 | * Erratum HSE43 | ||
| 558 | * CONFIG_TDP_NOMINAL CSR Implemented at Incorrect Offset | ||
| 559 | * http://www.intel.com/content/www/us/en/processors/xeon/xeon-e5-v3-spec-update.html | ||
| 557 | * | 560 | * |
| 558 | * See http://www.intel.com/content/www/us/en/processors/xeon/xeon-e5-v4-spec-update.html | 561 | * Devices [8086:6f60,6fa0,6fc0] |
| 559 | * entry BDF2. | 562 | * Erratum BDF2 |
| 563 | * PCI BARs in the Home Agent Will Return Non-Zero Values During Enumeration | ||
| 564 | * http://www.intel.com/content/www/us/en/processors/xeon/xeon-e5-v4-spec-update.html | ||
| 560 | */ | 565 | */ |
| 561 | static void pci_bdwep_bar(struct pci_dev *dev) | 566 | static void pci_invalid_bar(struct pci_dev *dev) |
| 562 | { | 567 | { |
| 563 | dev->non_compliant_bars = 1; | 568 | dev->non_compliant_bars = 1; |
| 564 | } | 569 | } |
| 565 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6f60, pci_bdwep_bar); | 570 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2fc0, pci_invalid_bar); |
| 566 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fa0, pci_bdwep_bar); | 571 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6f60, pci_invalid_bar); |
| 567 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fc0, pci_bdwep_bar); | 572 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fa0, pci_invalid_bar); |
| 573 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fc0, pci_invalid_bar); | ||
diff --git a/arch/x86/pci/vmd.c b/arch/x86/pci/vmd.c index b814ca675131..7948be342ee9 100644 --- a/arch/x86/pci/vmd.c +++ b/arch/x86/pci/vmd.c | |||
| @@ -41,6 +41,7 @@ static DEFINE_RAW_SPINLOCK(list_lock); | |||
| 41 | * @node: list item for parent traversal. | 41 | * @node: list item for parent traversal. |
| 42 | * @rcu: RCU callback item for freeing. | 42 | * @rcu: RCU callback item for freeing. |
| 43 | * @irq: back pointer to parent. | 43 | * @irq: back pointer to parent. |
| 44 | * @enabled: true if driver enabled IRQ | ||
| 44 | * @virq: the virtual IRQ value provided to the requesting driver. | 45 | * @virq: the virtual IRQ value provided to the requesting driver. |
| 45 | * | 46 | * |
| 46 | * Every MSI/MSI-X IRQ requested for a device in a VMD domain will be mapped to | 47 | * Every MSI/MSI-X IRQ requested for a device in a VMD domain will be mapped to |
| @@ -50,6 +51,7 @@ struct vmd_irq { | |||
| 50 | struct list_head node; | 51 | struct list_head node; |
| 51 | struct rcu_head rcu; | 52 | struct rcu_head rcu; |
| 52 | struct vmd_irq_list *irq; | 53 | struct vmd_irq_list *irq; |
| 54 | bool enabled; | ||
| 53 | unsigned int virq; | 55 | unsigned int virq; |
| 54 | }; | 56 | }; |
| 55 | 57 | ||
| @@ -122,7 +124,9 @@ static void vmd_irq_enable(struct irq_data *data) | |||
| 122 | unsigned long flags; | 124 | unsigned long flags; |
| 123 | 125 | ||
| 124 | raw_spin_lock_irqsave(&list_lock, flags); | 126 | raw_spin_lock_irqsave(&list_lock, flags); |
| 127 | WARN_ON(vmdirq->enabled); | ||
| 125 | list_add_tail_rcu(&vmdirq->node, &vmdirq->irq->irq_list); | 128 | list_add_tail_rcu(&vmdirq->node, &vmdirq->irq->irq_list); |
| 129 | vmdirq->enabled = true; | ||
| 126 | raw_spin_unlock_irqrestore(&list_lock, flags); | 130 | raw_spin_unlock_irqrestore(&list_lock, flags); |
| 127 | 131 | ||
| 128 | data->chip->irq_unmask(data); | 132 | data->chip->irq_unmask(data); |
| @@ -136,8 +140,10 @@ static void vmd_irq_disable(struct irq_data *data) | |||
| 136 | data->chip->irq_mask(data); | 140 | data->chip->irq_mask(data); |
| 137 | 141 | ||
| 138 | raw_spin_lock_irqsave(&list_lock, flags); | 142 | raw_spin_lock_irqsave(&list_lock, flags); |
| 139 | list_del_rcu(&vmdirq->node); | 143 | if (vmdirq->enabled) { |
| 140 | INIT_LIST_HEAD_RCU(&vmdirq->node); | 144 | list_del_rcu(&vmdirq->node); |
| 145 | vmdirq->enabled = false; | ||
| 146 | } | ||
| 141 | raw_spin_unlock_irqrestore(&list_lock, flags); | 147 | raw_spin_unlock_irqrestore(&list_lock, flags); |
| 142 | } | 148 | } |
| 143 | 149 | ||
diff --git a/arch/x86/um/ptrace_32.c b/arch/x86/um/ptrace_32.c index ebd4dd6ef73b..a7ef7b131e25 100644 --- a/arch/x86/um/ptrace_32.c +++ b/arch/x86/um/ptrace_32.c | |||
| @@ -84,7 +84,10 @@ int putreg(struct task_struct *child, int regno, unsigned long value) | |||
| 84 | case EAX: | 84 | case EAX: |
| 85 | case EIP: | 85 | case EIP: |
| 86 | case UESP: | 86 | case UESP: |
| 87 | break; | ||
| 87 | case ORIG_EAX: | 88 | case ORIG_EAX: |
| 89 | /* Update the syscall number. */ | ||
| 90 | UPT_SYSCALL_NR(&child->thread.regs.regs) = value; | ||
| 88 | break; | 91 | break; |
| 89 | case FS: | 92 | case FS: |
| 90 | if (value && (value & 3) != 3) | 93 | if (value && (value & 3) != 3) |
diff --git a/arch/x86/um/ptrace_64.c b/arch/x86/um/ptrace_64.c index faab418876ce..0b5c184dd5b3 100644 --- a/arch/x86/um/ptrace_64.c +++ b/arch/x86/um/ptrace_64.c | |||
| @@ -78,7 +78,11 @@ int putreg(struct task_struct *child, int regno, unsigned long value) | |||
| 78 | case RSI: | 78 | case RSI: |
| 79 | case RDI: | 79 | case RDI: |
| 80 | case RBP: | 80 | case RBP: |
| 81 | break; | ||
| 82 | |||
| 81 | case ORIG_RAX: | 83 | case ORIG_RAX: |
| 84 | /* Update the syscall number. */ | ||
| 85 | UPT_SYSCALL_NR(&child->thread.regs.regs) = value; | ||
| 82 | break; | 86 | break; |
| 83 | 87 | ||
| 84 | case FS: | 88 | case FS: |
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 8ffb089b19a5..b86ebb1a9a7f 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
| @@ -118,7 +118,7 @@ DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu); | |||
| 118 | DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info); | 118 | DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info); |
| 119 | 119 | ||
| 120 | /* Linux <-> Xen vCPU id mapping */ | 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 | EXPORT_PER_CPU_SYMBOL(xen_vcpu_id); | 122 | EXPORT_PER_CPU_SYMBOL(xen_vcpu_id); |
| 123 | 123 | ||
| 124 | enum xen_domain_type xen_domain_type = XEN_NATIVE; | 124 | enum xen_domain_type xen_domain_type = XEN_NATIVE; |
diff --git a/block/bio.c b/block/bio.c index f39477538fef..aa7354088008 100644 --- a/block/bio.c +++ b/block/bio.c | |||
| @@ -667,18 +667,19 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, | |||
| 667 | bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; | 667 | bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; |
| 668 | bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; | 668 | bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; |
| 669 | 669 | ||
| 670 | if (bio_op(bio) == REQ_OP_DISCARD) | 670 | switch (bio_op(bio)) { |
| 671 | goto integrity_clone; | 671 | case REQ_OP_DISCARD: |
| 672 | 672 | case REQ_OP_SECURE_ERASE: | |
| 673 | if (bio_op(bio) == REQ_OP_WRITE_SAME) { | 673 | break; |
| 674 | case REQ_OP_WRITE_SAME: | ||
| 674 | bio->bi_io_vec[bio->bi_vcnt++] = bio_src->bi_io_vec[0]; | 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 | if (bio_integrity(bio_src)) { | 683 | if (bio_integrity(bio_src)) { |
| 683 | int ret; | 684 | int ret; |
| 684 | 685 | ||
| @@ -1788,7 +1789,7 @@ struct bio *bio_split(struct bio *bio, int sectors, | |||
| 1788 | * Discards need a mutable bio_vec to accommodate the payload | 1789 | * Discards need a mutable bio_vec to accommodate the payload |
| 1789 | * required by the DSM TRIM and UNMAP commands. | 1790 | * required by the DSM TRIM and UNMAP commands. |
| 1790 | */ | 1791 | */ |
| 1791 | if (bio_op(bio) == REQ_OP_DISCARD) | 1792 | if (bio_op(bio) == REQ_OP_DISCARD || bio_op(bio) == REQ_OP_SECURE_ERASE) |
| 1792 | split = bio_clone_bioset(bio, gfp, bs); | 1793 | split = bio_clone_bioset(bio, gfp, bs); |
| 1793 | else | 1794 | else |
| 1794 | split = bio_clone_fast(bio, gfp, bs); | 1795 | split = bio_clone_fast(bio, gfp, bs); |
diff --git a/block/blk-core.c b/block/blk-core.c index 999442ec4601..36c7ac328d8c 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
| @@ -515,7 +515,9 @@ EXPORT_SYMBOL_GPL(blk_queue_bypass_end); | |||
| 515 | 515 | ||
| 516 | void blk_set_queue_dying(struct request_queue *q) | 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 | if (q->mq_ops) | 522 | if (q->mq_ops) |
| 521 | blk_mq_wake_waiters(q); | 523 | blk_mq_wake_waiters(q); |
diff --git a/block/blk-merge.c b/block/blk-merge.c index 3eec75a9e91d..2642e5fc8b69 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c | |||
| @@ -94,9 +94,31 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, | |||
| 94 | bool do_split = true; | 94 | bool do_split = true; |
| 95 | struct bio *new = NULL; | 95 | struct bio *new = NULL; |
| 96 | const unsigned max_sectors = get_max_io_size(q, bio); | 96 | const unsigned max_sectors = get_max_io_size(q, bio); |
| 97 | unsigned bvecs = 0; | ||
| 97 | 98 | ||
| 98 | bio_for_each_segment(bv, bio, iter) { | 99 | bio_for_each_segment(bv, bio, iter) { |
| 99 | /* | 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 | |||
| 121 | /* | ||
| 100 | * If the queue doesn't support SG gaps and adding this | 122 | * If the queue doesn't support SG gaps and adding this |
| 101 | * offset would create a gap, disallow it. | 123 | * offset would create a gap, disallow it. |
| 102 | */ | 124 | */ |
| @@ -172,12 +194,18 @@ void blk_queue_split(struct request_queue *q, struct bio **bio, | |||
| 172 | struct bio *split, *res; | 194 | struct bio *split, *res; |
| 173 | unsigned nsegs; | 195 | unsigned nsegs; |
| 174 | 196 | ||
| 175 | if (bio_op(*bio) == REQ_OP_DISCARD) | 197 | switch (bio_op(*bio)) { |
| 198 | case REQ_OP_DISCARD: | ||
| 199 | case REQ_OP_SECURE_ERASE: | ||
| 176 | split = blk_bio_discard_split(q, *bio, bs, &nsegs); | 200 | split = blk_bio_discard_split(q, *bio, bs, &nsegs); |
| 177 | else if (bio_op(*bio) == REQ_OP_WRITE_SAME) | 201 | break; |
| 202 | case REQ_OP_WRITE_SAME: | ||
| 178 | split = blk_bio_write_same_split(q, *bio, bs, &nsegs); | 203 | split = blk_bio_write_same_split(q, *bio, bs, &nsegs); |
| 179 | else | 204 | break; |
| 205 | default: | ||
| 180 | split = blk_bio_segment_split(q, *bio, q->bio_split, &nsegs); | 206 | split = blk_bio_segment_split(q, *bio, q->bio_split, &nsegs); |
| 207 | break; | ||
| 208 | } | ||
| 181 | 209 | ||
| 182 | /* physical segments can be figured out during splitting */ | 210 | /* physical segments can be figured out during splitting */ |
| 183 | res = split ? split : *bio; | 211 | res = split ? split : *bio; |
| @@ -213,7 +241,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, | |||
| 213 | * This should probably be returning 0, but blk_add_request_payload() | 241 | * This should probably be returning 0, but blk_add_request_payload() |
| 214 | * (Christoph!!!!) | 242 | * (Christoph!!!!) |
| 215 | */ | 243 | */ |
| 216 | if (bio_op(bio) == REQ_OP_DISCARD) | 244 | if (bio_op(bio) == REQ_OP_DISCARD || bio_op(bio) == REQ_OP_SECURE_ERASE) |
| 217 | return 1; | 245 | return 1; |
| 218 | 246 | ||
| 219 | if (bio_op(bio) == REQ_OP_WRITE_SAME) | 247 | if (bio_op(bio) == REQ_OP_WRITE_SAME) |
| @@ -385,7 +413,9 @@ static int __blk_bios_map_sg(struct request_queue *q, struct bio *bio, | |||
| 385 | nsegs = 0; | 413 | nsegs = 0; |
| 386 | cluster = blk_queue_cluster(q); | 414 | cluster = blk_queue_cluster(q); |
| 387 | 415 | ||
| 388 | if (bio_op(bio) == REQ_OP_DISCARD) { | 416 | switch (bio_op(bio)) { |
| 417 | case REQ_OP_DISCARD: | ||
| 418 | case REQ_OP_SECURE_ERASE: | ||
| 389 | /* | 419 | /* |
| 390 | * This is a hack - drivers should be neither modifying the | 420 | * This is a hack - drivers should be neither modifying the |
| 391 | * biovec, nor relying on bi_vcnt - but because of | 421 | * biovec, nor relying on bi_vcnt - but because of |
| @@ -393,19 +423,16 @@ static int __blk_bios_map_sg(struct request_queue *q, struct bio *bio, | |||
| 393 | * a payload we need to set up here (thank you Christoph) and | 423 | * a payload we need to set up here (thank you Christoph) and |
| 394 | * bi_vcnt is really the only way of telling if we need to. | 424 | * bi_vcnt is really the only way of telling if we need to. |
| 395 | */ | 425 | */ |
| 396 | 426 | if (!bio->bi_vcnt) | |
| 397 | if (bio->bi_vcnt) | 427 | return 0; |
| 398 | goto single_segment; | 428 | /* Fall through */ |
| 399 | 429 | case REQ_OP_WRITE_SAME: | |
| 400 | return 0; | ||
| 401 | } | ||
| 402 | |||
| 403 | if (bio_op(bio) == REQ_OP_WRITE_SAME) { | ||
| 404 | single_segment: | ||
| 405 | *sg = sglist; | 430 | *sg = sglist; |
| 406 | bvec = bio_iovec(bio); | 431 | bvec = bio_iovec(bio); |
| 407 | sg_set_page(*sg, bvec.bv_page, bvec.bv_len, bvec.bv_offset); | 432 | sg_set_page(*sg, bvec.bv_page, bvec.bv_len, bvec.bv_offset); |
| 408 | return 1; | 433 | return 1; |
| 434 | default: | ||
| 435 | break; | ||
| 409 | } | 436 | } |
| 410 | 437 | ||
| 411 | for_each_bio(bio) | 438 | for_each_bio(bio) |
diff --git a/block/blk-mq.c b/block/blk-mq.c index e931a0e8e73d..13f5a6c1de76 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
| @@ -793,11 +793,12 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx) | |||
| 793 | struct list_head *dptr; | 793 | struct list_head *dptr; |
| 794 | int queued; | 794 | int queued; |
| 795 | 795 | ||
| 796 | WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask)); | ||
| 797 | |||
| 798 | if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state))) | 796 | if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state))) |
| 799 | return; | 797 | return; |
| 800 | 798 | ||
| 799 | WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) && | ||
| 800 | cpu_online(hctx->next_cpu)); | ||
| 801 | |||
| 801 | hctx->run++; | 802 | hctx->run++; |
| 802 | 803 | ||
| 803 | /* | 804 | /* |
| @@ -1036,10 +1037,11 @@ void blk_mq_delay_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs) | |||
| 1036 | EXPORT_SYMBOL(blk_mq_delay_queue); | 1037 | EXPORT_SYMBOL(blk_mq_delay_queue); |
| 1037 | 1038 | ||
| 1038 | static inline void __blk_mq_insert_req_list(struct blk_mq_hw_ctx *hctx, | 1039 | static inline void __blk_mq_insert_req_list(struct blk_mq_hw_ctx *hctx, |
| 1039 | struct blk_mq_ctx *ctx, | ||
| 1040 | struct request *rq, | 1040 | struct request *rq, |
| 1041 | bool at_head) | 1041 | bool at_head) |
| 1042 | { | 1042 | { |
| 1043 | struct blk_mq_ctx *ctx = rq->mq_ctx; | ||
| 1044 | |||
| 1043 | trace_block_rq_insert(hctx->queue, rq); | 1045 | trace_block_rq_insert(hctx->queue, rq); |
| 1044 | 1046 | ||
| 1045 | if (at_head) | 1047 | if (at_head) |
| @@ -1053,20 +1055,16 @@ static void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx, | |||
| 1053 | { | 1055 | { |
| 1054 | struct blk_mq_ctx *ctx = rq->mq_ctx; | 1056 | struct blk_mq_ctx *ctx = rq->mq_ctx; |
| 1055 | 1057 | ||
| 1056 | __blk_mq_insert_req_list(hctx, ctx, rq, at_head); | 1058 | __blk_mq_insert_req_list(hctx, rq, at_head); |
| 1057 | blk_mq_hctx_mark_pending(hctx, ctx); | 1059 | blk_mq_hctx_mark_pending(hctx, ctx); |
| 1058 | } | 1060 | } |
| 1059 | 1061 | ||
| 1060 | void blk_mq_insert_request(struct request *rq, bool at_head, bool run_queue, | 1062 | void blk_mq_insert_request(struct request *rq, bool at_head, bool run_queue, |
| 1061 | bool async) | 1063 | bool async) |
| 1062 | { | 1064 | { |
| 1065 | struct blk_mq_ctx *ctx = rq->mq_ctx; | ||
| 1063 | struct request_queue *q = rq->q; | 1066 | struct request_queue *q = rq->q; |
| 1064 | struct blk_mq_hw_ctx *hctx; | 1067 | struct blk_mq_hw_ctx *hctx; |
| 1065 | struct blk_mq_ctx *ctx = rq->mq_ctx, *current_ctx; | ||
| 1066 | |||
| 1067 | current_ctx = blk_mq_get_ctx(q); | ||
| 1068 | if (!cpu_online(ctx->cpu)) | ||
| 1069 | rq->mq_ctx = ctx = current_ctx; | ||
| 1070 | 1068 | ||
| 1071 | hctx = q->mq_ops->map_queue(q, ctx->cpu); | 1069 | hctx = q->mq_ops->map_queue(q, ctx->cpu); |
| 1072 | 1070 | ||
| @@ -1076,8 +1074,6 @@ void blk_mq_insert_request(struct request *rq, bool at_head, bool run_queue, | |||
| 1076 | 1074 | ||
| 1077 | if (run_queue) | 1075 | if (run_queue) |
| 1078 | blk_mq_run_hw_queue(hctx, async); | 1076 | blk_mq_run_hw_queue(hctx, async); |
| 1079 | |||
| 1080 | blk_mq_put_ctx(current_ctx); | ||
| 1081 | } | 1077 | } |
| 1082 | 1078 | ||
| 1083 | static void blk_mq_insert_requests(struct request_queue *q, | 1079 | static void blk_mq_insert_requests(struct request_queue *q, |
| @@ -1088,14 +1084,9 @@ static void blk_mq_insert_requests(struct request_queue *q, | |||
| 1088 | 1084 | ||
| 1089 | { | 1085 | { |
| 1090 | struct blk_mq_hw_ctx *hctx; | 1086 | struct blk_mq_hw_ctx *hctx; |
| 1091 | struct blk_mq_ctx *current_ctx; | ||
| 1092 | 1087 | ||
| 1093 | trace_block_unplug(q, depth, !from_schedule); | 1088 | trace_block_unplug(q, depth, !from_schedule); |
| 1094 | 1089 | ||
| 1095 | current_ctx = blk_mq_get_ctx(q); | ||
| 1096 | |||
| 1097 | if (!cpu_online(ctx->cpu)) | ||
| 1098 | ctx = current_ctx; | ||
| 1099 | hctx = q->mq_ops->map_queue(q, ctx->cpu); | 1090 | hctx = q->mq_ops->map_queue(q, ctx->cpu); |
| 1100 | 1091 | ||
| 1101 | /* | 1092 | /* |
| @@ -1107,15 +1098,14 @@ static void blk_mq_insert_requests(struct request_queue *q, | |||
| 1107 | struct request *rq; | 1098 | struct request *rq; |
| 1108 | 1099 | ||
| 1109 | rq = list_first_entry(list, struct request, queuelist); | 1100 | rq = list_first_entry(list, struct request, queuelist); |
| 1101 | BUG_ON(rq->mq_ctx != ctx); | ||
| 1110 | list_del_init(&rq->queuelist); | 1102 | list_del_init(&rq->queuelist); |
| 1111 | rq->mq_ctx = ctx; | 1103 | __blk_mq_insert_req_list(hctx, rq, false); |
| 1112 | __blk_mq_insert_req_list(hctx, ctx, rq, false); | ||
| 1113 | } | 1104 | } |
| 1114 | blk_mq_hctx_mark_pending(hctx, ctx); | 1105 | blk_mq_hctx_mark_pending(hctx, ctx); |
| 1115 | spin_unlock(&ctx->lock); | 1106 | spin_unlock(&ctx->lock); |
| 1116 | 1107 | ||
| 1117 | blk_mq_run_hw_queue(hctx, from_schedule); | 1108 | blk_mq_run_hw_queue(hctx, from_schedule); |
| 1118 | blk_mq_put_ctx(current_ctx); | ||
| 1119 | } | 1109 | } |
| 1120 | 1110 | ||
| 1121 | static int plug_ctx_cmp(void *priv, struct list_head *a, struct list_head *b) | 1111 | static int plug_ctx_cmp(void *priv, struct list_head *a, struct list_head *b) |
| @@ -1630,16 +1620,17 @@ static int blk_mq_alloc_bitmap(struct blk_mq_ctxmap *bitmap, int node) | |||
| 1630 | return 0; | 1620 | return 0; |
| 1631 | } | 1621 | } |
| 1632 | 1622 | ||
| 1623 | /* | ||
| 1624 | * 'cpu' is going away. splice any existing rq_list entries from this | ||
| 1625 | * software queue to the hw queue dispatch list, and ensure that it | ||
| 1626 | * gets run. | ||
| 1627 | */ | ||
| 1633 | static int blk_mq_hctx_cpu_offline(struct blk_mq_hw_ctx *hctx, int cpu) | 1628 | static int blk_mq_hctx_cpu_offline(struct blk_mq_hw_ctx *hctx, int cpu) |
| 1634 | { | 1629 | { |
| 1635 | struct request_queue *q = hctx->queue; | ||
| 1636 | struct blk_mq_ctx *ctx; | 1630 | struct blk_mq_ctx *ctx; |
| 1637 | LIST_HEAD(tmp); | 1631 | LIST_HEAD(tmp); |
| 1638 | 1632 | ||
| 1639 | /* | 1633 | ctx = __blk_mq_get_ctx(hctx->queue, cpu); |
| 1640 | * Move ctx entries to new CPU, if this one is going away. | ||
| 1641 | */ | ||
| 1642 | ctx = __blk_mq_get_ctx(q, cpu); | ||
| 1643 | 1634 | ||
| 1644 | spin_lock(&ctx->lock); | 1635 | spin_lock(&ctx->lock); |
| 1645 | if (!list_empty(&ctx->rq_list)) { | 1636 | if (!list_empty(&ctx->rq_list)) { |
| @@ -1651,24 +1642,11 @@ static int blk_mq_hctx_cpu_offline(struct blk_mq_hw_ctx *hctx, int cpu) | |||
| 1651 | if (list_empty(&tmp)) | 1642 | if (list_empty(&tmp)) |
| 1652 | return NOTIFY_OK; | 1643 | return NOTIFY_OK; |
| 1653 | 1644 | ||
| 1654 | ctx = blk_mq_get_ctx(q); | 1645 | spin_lock(&hctx->lock); |
| 1655 | spin_lock(&ctx->lock); | 1646 | list_splice_tail_init(&tmp, &hctx->dispatch); |
| 1656 | 1647 | spin_unlock(&hctx->lock); | |
| 1657 | while (!list_empty(&tmp)) { | ||
| 1658 | struct request *rq; | ||
| 1659 | |||
| 1660 | rq = list_first_entry(&tmp, struct request, queuelist); | ||
| 1661 | rq->mq_ctx = ctx; | ||
| 1662 | list_move_tail(&rq->queuelist, &ctx->rq_list); | ||
| 1663 | } | ||
| 1664 | |||
| 1665 | hctx = q->mq_ops->map_queue(q, ctx->cpu); | ||
| 1666 | blk_mq_hctx_mark_pending(hctx, ctx); | ||
| 1667 | |||
| 1668 | spin_unlock(&ctx->lock); | ||
| 1669 | 1648 | ||
| 1670 | blk_mq_run_hw_queue(hctx, true); | 1649 | blk_mq_run_hw_queue(hctx, true); |
| 1671 | blk_mq_put_ctx(ctx); | ||
| 1672 | return NOTIFY_OK; | 1650 | return NOTIFY_OK; |
| 1673 | } | 1651 | } |
| 1674 | 1652 | ||
diff --git a/block/elevator.c b/block/elevator.c index 7096c22041e7..f7d973a56fd7 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
| @@ -366,7 +366,7 @@ void elv_dispatch_sort(struct request_queue *q, struct request *rq) | |||
| 366 | list_for_each_prev(entry, &q->queue_head) { | 366 | list_for_each_prev(entry, &q->queue_head) { |
| 367 | struct request *pos = list_entry_rq(entry); | 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 | break; | 370 | break; |
| 371 | if (rq_data_dir(rq) != rq_data_dir(pos)) | 371 | if (rq_data_dir(rq) != rq_data_dir(pos)) |
| 372 | break; | 372 | break; |
diff --git a/crypto/cryptd.c b/crypto/cryptd.c index cf8037a87b2d..0c654e59f215 100644 --- a/crypto/cryptd.c +++ b/crypto/cryptd.c | |||
| @@ -631,9 +631,14 @@ static int cryptd_hash_export(struct ahash_request *req, void *out) | |||
| 631 | 631 | ||
| 632 | static int cryptd_hash_import(struct ahash_request *req, const void *in) | 632 | static int cryptd_hash_import(struct ahash_request *req, const void *in) |
| 633 | { | 633 | { |
| 634 | struct cryptd_hash_request_ctx *rctx = ahash_request_ctx(req); | 634 | struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); |
| 635 | struct cryptd_hash_ctx *ctx = crypto_ahash_ctx(tfm); | ||
| 636 | struct shash_desc *desc = cryptd_shash_desc(req); | ||
| 637 | |||
| 638 | desc->tfm = ctx->child; | ||
| 639 | desc->flags = req->base.flags; | ||
| 635 | 640 | ||
| 636 | return crypto_shash_import(&rctx->desc, in); | 641 | return crypto_shash_import(desc, in); |
| 637 | } | 642 | } |
| 638 | 643 | ||
| 639 | static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb, | 644 | static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb, |
| @@ -733,13 +738,14 @@ static void cryptd_aead_crypt(struct aead_request *req, | |||
| 733 | rctx = aead_request_ctx(req); | 738 | rctx = aead_request_ctx(req); |
| 734 | compl = rctx->complete; | 739 | compl = rctx->complete; |
| 735 | 740 | ||
| 741 | tfm = crypto_aead_reqtfm(req); | ||
| 742 | |||
| 736 | if (unlikely(err == -EINPROGRESS)) | 743 | if (unlikely(err == -EINPROGRESS)) |
| 737 | goto out; | 744 | goto out; |
| 738 | aead_request_set_tfm(req, child); | 745 | aead_request_set_tfm(req, child); |
| 739 | err = crypt( req ); | 746 | err = crypt( req ); |
| 740 | 747 | ||
| 741 | out: | 748 | out: |
| 742 | tfm = crypto_aead_reqtfm(req); | ||
| 743 | ctx = crypto_aead_ctx(tfm); | 749 | ctx = crypto_aead_ctx(tfm); |
| 744 | refcnt = atomic_read(&ctx->refcnt); | 750 | refcnt = atomic_read(&ctx->refcnt); |
| 745 | 751 | ||
diff --git a/drivers/acpi/nfit/mce.c b/drivers/acpi/nfit/mce.c index 4c745bf389fe..161f91539ae6 100644 --- a/drivers/acpi/nfit/mce.c +++ b/drivers/acpi/nfit/mce.c | |||
| @@ -42,7 +42,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val, | |||
| 42 | list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { | 42 | list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { |
| 43 | struct acpi_nfit_system_address *spa = nfit_spa->spa; | 43 | struct acpi_nfit_system_address *spa = nfit_spa->spa; |
| 44 | 44 | ||
| 45 | if (nfit_spa_type(spa) == NFIT_SPA_PM) | 45 | if (nfit_spa_type(spa) != NFIT_SPA_PM) |
| 46 | continue; | 46 | continue; |
| 47 | /* find the spa that covers the mce addr */ | 47 | /* find the spa that covers the mce addr */ |
| 48 | if (spa->address > mce->addr) | 48 | if (spa->address > mce->addr) |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index ad9fc84a8601..e878fc799af7 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
| @@ -2054,7 +2054,7 @@ int __init acpi_scan_init(void) | |||
| 2054 | 2054 | ||
| 2055 | static struct acpi_probe_entry *ape; | 2055 | static struct acpi_probe_entry *ape; |
| 2056 | static int acpi_probe_count; | 2056 | static int acpi_probe_count; |
| 2057 | static DEFINE_SPINLOCK(acpi_probe_lock); | 2057 | static DEFINE_MUTEX(acpi_probe_mutex); |
| 2058 | 2058 | ||
| 2059 | static int __init acpi_match_madt(struct acpi_subtable_header *header, | 2059 | static int __init acpi_match_madt(struct acpi_subtable_header *header, |
| 2060 | const unsigned long end) | 2060 | const unsigned long end) |
| @@ -2073,7 +2073,7 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr) | |||
| 2073 | if (acpi_disabled) | 2073 | if (acpi_disabled) |
| 2074 | return 0; | 2074 | return 0; |
| 2075 | 2075 | ||
| 2076 | spin_lock(&acpi_probe_lock); | 2076 | mutex_lock(&acpi_probe_mutex); |
| 2077 | for (ape = ap_head; nr; ape++, nr--) { | 2077 | for (ape = ap_head; nr; ape++, nr--) { |
| 2078 | if (ACPI_COMPARE_NAME(ACPI_SIG_MADT, ape->id)) { | 2078 | if (ACPI_COMPARE_NAME(ACPI_SIG_MADT, ape->id)) { |
| 2079 | acpi_probe_count = 0; | 2079 | acpi_probe_count = 0; |
| @@ -2086,7 +2086,7 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr) | |||
| 2086 | count++; | 2086 | count++; |
| 2087 | } | 2087 | } |
| 2088 | } | 2088 | } |
| 2089 | spin_unlock(&acpi_probe_lock); | 2089 | mutex_unlock(&acpi_probe_mutex); |
| 2090 | 2090 | ||
| 2091 | return count; | 2091 | return count; |
| 2092 | } | 2092 | } |
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index 7461a587b39b..dcf2c724fd06 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c | |||
| @@ -2524,7 +2524,7 @@ static int ahci_host_activate_multi_irqs(struct ata_host *host, | |||
| 2524 | 2524 | ||
| 2525 | /* Do not receive interrupts sent by dummy ports */ | 2525 | /* Do not receive interrupts sent by dummy ports */ |
| 2526 | if (!pp) { | 2526 | if (!pp) { |
| 2527 | disable_irq(irq + i); | 2527 | disable_irq(irq); |
| 2528 | continue; | 2528 | continue; |
| 2529 | } | 2529 | } |
| 2530 | 2530 | ||
diff --git a/drivers/ata/pata_ninja32.c b/drivers/ata/pata_ninja32.c index 633aa2934a18..44f97ad3c88d 100644 --- a/drivers/ata/pata_ninja32.c +++ b/drivers/ata/pata_ninja32.c | |||
| @@ -144,7 +144,7 @@ static int ninja32_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
| 144 | ap->ioaddr.altstatus_addr = base + 0x1E; | 144 | ap->ioaddr.altstatus_addr = base + 0x1E; |
| 145 | ap->ioaddr.bmdma_addr = base; | 145 | ap->ioaddr.bmdma_addr = base; |
| 146 | ata_sff_std_ports(&ap->ioaddr); | 146 | ata_sff_std_ports(&ap->ioaddr); |
| 147 | ap->pflags = ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE; | 147 | ap->pflags |= ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE; |
| 148 | 148 | ||
| 149 | ninja32_program(base); | 149 | ninja32_program(base); |
| 150 | /* FIXME: Should we disable them at remove ? */ | 150 | /* FIXME: Should we disable them at remove ? */ |
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index e097d355cc04..82a081ea4317 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c | |||
| @@ -301,7 +301,7 @@ static int rpm_idle(struct device *dev, int rpmflags) | |||
| 301 | int (*callback)(struct device *); | 301 | int (*callback)(struct device *); |
| 302 | int retval; | 302 | int retval; |
| 303 | 303 | ||
| 304 | trace_rpm_idle(dev, rpmflags); | 304 | trace_rpm_idle_rcuidle(dev, rpmflags); |
| 305 | retval = rpm_check_suspend_allowed(dev); | 305 | retval = rpm_check_suspend_allowed(dev); |
| 306 | if (retval < 0) | 306 | if (retval < 0) |
| 307 | ; /* Conditions are wrong. */ | 307 | ; /* Conditions are wrong. */ |
| @@ -337,7 +337,7 @@ static int rpm_idle(struct device *dev, int rpmflags) | |||
| 337 | dev->power.request_pending = true; | 337 | dev->power.request_pending = true; |
| 338 | queue_work(pm_wq, &dev->power.work); | 338 | queue_work(pm_wq, &dev->power.work); |
| 339 | } | 339 | } |
| 340 | trace_rpm_return_int(dev, _THIS_IP_, 0); | 340 | trace_rpm_return_int_rcuidle(dev, _THIS_IP_, 0); |
| 341 | return 0; | 341 | return 0; |
| 342 | } | 342 | } |
| 343 | 343 | ||
| @@ -352,7 +352,7 @@ static int rpm_idle(struct device *dev, int rpmflags) | |||
| 352 | wake_up_all(&dev->power.wait_queue); | 352 | wake_up_all(&dev->power.wait_queue); |
| 353 | 353 | ||
| 354 | out: | 354 | out: |
| 355 | trace_rpm_return_int(dev, _THIS_IP_, retval); | 355 | trace_rpm_return_int_rcuidle(dev, _THIS_IP_, retval); |
| 356 | return retval ? retval : rpm_suspend(dev, rpmflags | RPM_AUTO); | 356 | return retval ? retval : rpm_suspend(dev, rpmflags | RPM_AUTO); |
| 357 | } | 357 | } |
| 358 | 358 | ||
| @@ -419,7 +419,7 @@ static int rpm_suspend(struct device *dev, int rpmflags) | |||
| 419 | struct device *parent = NULL; | 419 | struct device *parent = NULL; |
| 420 | int retval; | 420 | int retval; |
| 421 | 421 | ||
| 422 | trace_rpm_suspend(dev, rpmflags); | 422 | trace_rpm_suspend_rcuidle(dev, rpmflags); |
| 423 | 423 | ||
| 424 | repeat: | 424 | repeat: |
| 425 | retval = rpm_check_suspend_allowed(dev); | 425 | retval = rpm_check_suspend_allowed(dev); |
| @@ -549,7 +549,7 @@ static int rpm_suspend(struct device *dev, int rpmflags) | |||
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | out: | 551 | out: |
| 552 | trace_rpm_return_int(dev, _THIS_IP_, retval); | 552 | trace_rpm_return_int_rcuidle(dev, _THIS_IP_, retval); |
| 553 | 553 | ||
| 554 | return retval; | 554 | return retval; |
| 555 | 555 | ||
| @@ -601,7 +601,7 @@ static int rpm_resume(struct device *dev, int rpmflags) | |||
| 601 | struct device *parent = NULL; | 601 | struct device *parent = NULL; |
| 602 | int retval = 0; | 602 | int retval = 0; |
| 603 | 603 | ||
| 604 | trace_rpm_resume(dev, rpmflags); | 604 | trace_rpm_resume_rcuidle(dev, rpmflags); |
| 605 | 605 | ||
| 606 | repeat: | 606 | repeat: |
| 607 | if (dev->power.runtime_error) | 607 | if (dev->power.runtime_error) |
| @@ -764,7 +764,7 @@ static int rpm_resume(struct device *dev, int rpmflags) | |||
| 764 | spin_lock_irq(&dev->power.lock); | 764 | spin_lock_irq(&dev->power.lock); |
| 765 | } | 765 | } |
| 766 | 766 | ||
| 767 | trace_rpm_return_int(dev, _THIS_IP_, retval); | 767 | trace_rpm_return_int_rcuidle(dev, _THIS_IP_, retval); |
| 768 | 768 | ||
| 769 | return retval; | 769 | return retval; |
| 770 | } | 770 | } |
diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c index aa56af87d941..b11af3f2c1db 100644 --- a/drivers/base/regmap/regcache-rbtree.c +++ b/drivers/base/regmap/regcache-rbtree.c | |||
| @@ -404,6 +404,7 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg, | |||
| 404 | unsigned int new_base_reg, new_top_reg; | 404 | unsigned int new_base_reg, new_top_reg; |
| 405 | unsigned int min, max; | 405 | unsigned int min, max; |
| 406 | unsigned int max_dist; | 406 | unsigned int max_dist; |
| 407 | unsigned int dist, best_dist = UINT_MAX; | ||
| 407 | 408 | ||
| 408 | max_dist = map->reg_stride * sizeof(*rbnode_tmp) / | 409 | max_dist = map->reg_stride * sizeof(*rbnode_tmp) / |
| 409 | map->cache_word_size; | 410 | map->cache_word_size; |
| @@ -423,24 +424,41 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg, | |||
| 423 | &base_reg, &top_reg); | 424 | &base_reg, &top_reg); |
| 424 | 425 | ||
| 425 | if (base_reg <= max && top_reg >= min) { | 426 | if (base_reg <= max && top_reg >= min) { |
| 426 | new_base_reg = min(reg, base_reg); | 427 | if (reg < base_reg) |
| 427 | new_top_reg = max(reg, top_reg); | 428 | dist = base_reg - reg; |
| 428 | } else { | 429 | else if (reg > top_reg) |
| 429 | if (max < base_reg) | 430 | dist = reg - top_reg; |
| 430 | node = node->rb_left; | ||
| 431 | else | 431 | else |
| 432 | node = node->rb_right; | 432 | dist = 0; |
| 433 | 433 | if (dist < best_dist) { | |
| 434 | continue; | 434 | rbnode = rbnode_tmp; |
| 435 | best_dist = dist; | ||
| 436 | new_base_reg = min(reg, base_reg); | ||
| 437 | new_top_reg = max(reg, top_reg); | ||
| 438 | } | ||
| 435 | } | 439 | } |
| 436 | 440 | ||
| 437 | ret = regcache_rbtree_insert_to_block(map, rbnode_tmp, | 441 | /* |
| 442 | * Keep looking, we want to choose the closest block, | ||
| 443 | * otherwise we might end up creating overlapping | ||
| 444 | * blocks, which breaks the rbtree. | ||
| 445 | */ | ||
| 446 | if (reg < base_reg) | ||
| 447 | node = node->rb_left; | ||
| 448 | else if (reg > top_reg) | ||
| 449 | node = node->rb_right; | ||
| 450 | else | ||
| 451 | break; | ||
| 452 | } | ||
| 453 | |||
| 454 | if (rbnode) { | ||
| 455 | ret = regcache_rbtree_insert_to_block(map, rbnode, | ||
| 438 | new_base_reg, | 456 | new_base_reg, |
| 439 | new_top_reg, reg, | 457 | new_top_reg, reg, |
| 440 | value); | 458 | value); |
| 441 | if (ret) | 459 | if (ret) |
| 442 | return ret; | 460 | return ret; |
| 443 | rbtree_ctx->cached_rbnode = rbnode_tmp; | 461 | rbtree_ctx->cached_rbnode = rbnode; |
| 444 | return 0; | 462 | return 0; |
| 445 | } | 463 | } |
| 446 | 464 | ||
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index df7ff7290821..4e582561e1e7 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c | |||
| @@ -38,10 +38,11 @@ static int regcache_hw_init(struct regmap *map) | |||
| 38 | 38 | ||
| 39 | /* calculate the size of reg_defaults */ | 39 | /* calculate the size of reg_defaults */ |
| 40 | for (count = 0, i = 0; i < map->num_reg_defaults_raw; i++) | 40 | for (count = 0, i = 0; i < map->num_reg_defaults_raw; i++) |
| 41 | if (!regmap_volatile(map, i * map->reg_stride)) | 41 | if (regmap_readable(map, i * map->reg_stride) && |
| 42 | !regmap_volatile(map, i * map->reg_stride)) | ||
| 42 | count++; | 43 | count++; |
| 43 | 44 | ||
| 44 | /* all registers are volatile, so just bypass */ | 45 | /* all registers are unreadable or volatile, so just bypass */ |
| 45 | if (!count) { | 46 | if (!count) { |
| 46 | map->cache_bypass = true; | 47 | map->cache_bypass = true; |
| 47 | return 0; | 48 | return 0; |
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 51fa7d66a393..25d26bb18970 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c | |||
| @@ -1474,6 +1474,8 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg, | |||
| 1474 | ret = map->bus->write(map->bus_context, buf, len); | 1474 | ret = map->bus->write(map->bus_context, buf, len); |
| 1475 | 1475 | ||
| 1476 | kfree(buf); | 1476 | kfree(buf); |
| 1477 | } else if (ret != 0 && !map->cache_bypass && map->format.parse_val) { | ||
| 1478 | regcache_drop_region(map, reg, reg + 1); | ||
| 1477 | } | 1479 | } |
| 1478 | 1480 | ||
| 1479 | trace_regmap_hw_write_done(map, reg, val_len / map->format.val_bytes); | 1481 | trace_regmap_hw_write_done(map, reg, val_len / map->format.val_bytes); |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index b71a9c767009..e3d8e4ced4a2 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
| @@ -3706,22 +3706,21 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) | |||
| 3706 | if (UFDCS->rawcmd == 1) | 3706 | if (UFDCS->rawcmd == 1) |
| 3707 | UFDCS->rawcmd = 2; | 3707 | UFDCS->rawcmd = 2; |
| 3708 | 3708 | ||
| 3709 | if (mode & (FMODE_READ|FMODE_WRITE)) { | 3709 | if (!(mode & FMODE_NDELAY)) { |
| 3710 | UDRS->last_checked = 0; | 3710 | if (mode & (FMODE_READ|FMODE_WRITE)) { |
| 3711 | clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); | 3711 | UDRS->last_checked = 0; |
| 3712 | check_disk_change(bdev); | 3712 | clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); |
| 3713 | if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) | 3713 | check_disk_change(bdev); |
| 3714 | goto out; | 3714 | if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) |
| 3715 | if (test_bit(FD_OPEN_SHOULD_FAIL_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 | goto out; | 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 | mutex_unlock(&open_lock); | 3724 | mutex_unlock(&open_lock); |
| 3726 | mutex_unlock(&floppy_mutex); | 3725 | mutex_unlock(&floppy_mutex); |
| 3727 | return 0; | 3726 | return 0; |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index be4fea6a5dd3..88ef6d4729b4 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
| @@ -189,6 +189,8 @@ struct blkfront_info | |||
| 189 | struct mutex mutex; | 189 | struct mutex mutex; |
| 190 | struct xenbus_device *xbdev; | 190 | struct xenbus_device *xbdev; |
| 191 | struct gendisk *gd; | 191 | struct gendisk *gd; |
| 192 | u16 sector_size; | ||
| 193 | unsigned int physical_sector_size; | ||
| 192 | int vdevice; | 194 | int vdevice; |
| 193 | blkif_vdev_t handle; | 195 | blkif_vdev_t handle; |
| 194 | enum blkif_state connected; | 196 | enum blkif_state connected; |
| @@ -910,9 +912,45 @@ static struct blk_mq_ops blkfront_mq_ops = { | |||
| 910 | .map_queue = blk_mq_map_queue, | 912 | .map_queue = blk_mq_map_queue, |
| 911 | }; | 913 | }; |
| 912 | 914 | ||
| 915 | static void blkif_set_queue_limits(struct blkfront_info *info) | ||
| 916 | { | ||
| 917 | struct request_queue *rq = info->rq; | ||
| 918 | struct gendisk *gd = info->gd; | ||
| 919 | unsigned int segments = info->max_indirect_segments ? : | ||
| 920 | BLKIF_MAX_SEGMENTS_PER_REQUEST; | ||
| 921 | |||
| 922 | queue_flag_set_unlocked(QUEUE_FLAG_VIRT, rq); | ||
| 923 | |||
| 924 | if (info->feature_discard) { | ||
| 925 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, rq); | ||
| 926 | blk_queue_max_discard_sectors(rq, get_capacity(gd)); | ||
| 927 | rq->limits.discard_granularity = info->discard_granularity; | ||
| 928 | rq->limits.discard_alignment = info->discard_alignment; | ||
| 929 | if (info->feature_secdiscard) | ||
| 930 | queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, rq); | ||
| 931 | } | ||
| 932 | |||
| 933 | /* Hard sector size and max sectors impersonate the equiv. hardware. */ | ||
| 934 | blk_queue_logical_block_size(rq, info->sector_size); | ||
| 935 | blk_queue_physical_block_size(rq, info->physical_sector_size); | ||
| 936 | blk_queue_max_hw_sectors(rq, (segments * XEN_PAGE_SIZE) / 512); | ||
| 937 | |||
| 938 | /* Each segment in a request is up to an aligned page in size. */ | ||
| 939 | blk_queue_segment_boundary(rq, PAGE_SIZE - 1); | ||
| 940 | blk_queue_max_segment_size(rq, PAGE_SIZE); | ||
| 941 | |||
| 942 | /* Ensure a merged request will fit in a single I/O ring slot. */ | ||
| 943 | blk_queue_max_segments(rq, segments / GRANTS_PER_PSEG); | ||
| 944 | |||
| 945 | /* Make sure buffer addresses are sector-aligned. */ | ||
| 946 | blk_queue_dma_alignment(rq, 511); | ||
| 947 | |||
| 948 | /* Make sure we don't use bounce buffers. */ | ||
| 949 | blk_queue_bounce_limit(rq, BLK_BOUNCE_ANY); | ||
| 950 | } | ||
| 951 | |||
| 913 | static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, | 952 | static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, |
| 914 | unsigned int physical_sector_size, | 953 | unsigned int physical_sector_size) |
| 915 | unsigned int segments) | ||
| 916 | { | 954 | { |
| 917 | struct request_queue *rq; | 955 | struct request_queue *rq; |
| 918 | struct blkfront_info *info = gd->private_data; | 956 | struct blkfront_info *info = gd->private_data; |
| @@ -944,36 +982,11 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, | |||
| 944 | } | 982 | } |
| 945 | 983 | ||
| 946 | rq->queuedata = info; | 984 | rq->queuedata = info; |
| 947 | queue_flag_set_unlocked(QUEUE_FLAG_VIRT, rq); | 985 | info->rq = gd->queue = rq; |
| 948 | 986 | info->gd = gd; | |
| 949 | if (info->feature_discard) { | 987 | info->sector_size = sector_size; |
| 950 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, rq); | 988 | info->physical_sector_size = physical_sector_size; |
| 951 | blk_queue_max_discard_sectors(rq, get_capacity(gd)); | 989 | blkif_set_queue_limits(info); |
| 952 | rq->limits.discard_granularity = info->discard_granularity; | ||
| 953 | rq->limits.discard_alignment = info->discard_alignment; | ||
| 954 | if (info->feature_secdiscard) | ||
| 955 | queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, rq); | ||
| 956 | } | ||
| 957 | |||
| 958 | /* Hard sector size and max sectors impersonate the equiv. hardware. */ | ||
| 959 | blk_queue_logical_block_size(rq, sector_size); | ||
| 960 | blk_queue_physical_block_size(rq, physical_sector_size); | ||
| 961 | blk_queue_max_hw_sectors(rq, (segments * XEN_PAGE_SIZE) / 512); | ||
| 962 | |||
| 963 | /* Each segment in a request is up to an aligned page in size. */ | ||
| 964 | blk_queue_segment_boundary(rq, PAGE_SIZE - 1); | ||
| 965 | blk_queue_max_segment_size(rq, PAGE_SIZE); | ||
| 966 | |||
| 967 | /* Ensure a merged request will fit in a single I/O ring slot. */ | ||
| 968 | blk_queue_max_segments(rq, segments / GRANTS_PER_PSEG); | ||
| 969 | |||
| 970 | /* Make sure buffer addresses are sector-aligned. */ | ||
| 971 | blk_queue_dma_alignment(rq, 511); | ||
| 972 | |||
| 973 | /* Make sure we don't use bounce buffers. */ | ||
| 974 | blk_queue_bounce_limit(rq, BLK_BOUNCE_ANY); | ||
| 975 | |||
| 976 | gd->queue = rq; | ||
| 977 | 990 | ||
| 978 | return 0; | 991 | return 0; |
| 979 | } | 992 | } |
| @@ -1136,16 +1149,11 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity, | |||
| 1136 | gd->private_data = info; | 1149 | gd->private_data = info; |
| 1137 | set_capacity(gd, capacity); | 1150 | set_capacity(gd, capacity); |
| 1138 | 1151 | ||
| 1139 | if (xlvbd_init_blk_queue(gd, sector_size, physical_sector_size, | 1152 | if (xlvbd_init_blk_queue(gd, sector_size, physical_sector_size)) { |
| 1140 | info->max_indirect_segments ? : | ||
| 1141 | BLKIF_MAX_SEGMENTS_PER_REQUEST)) { | ||
| 1142 | del_gendisk(gd); | 1153 | del_gendisk(gd); |
| 1143 | goto release; | 1154 | goto release; |
| 1144 | } | 1155 | } |
| 1145 | 1156 | ||
| 1146 | info->rq = gd->queue; | ||
| 1147 | info->gd = gd; | ||
| 1148 | |||
| 1149 | xlvbd_flush(info); | 1157 | xlvbd_flush(info); |
| 1150 | 1158 | ||
| 1151 | if (vdisk_info & VDISK_READONLY) | 1159 | if (vdisk_info & VDISK_READONLY) |
| @@ -1315,7 +1323,7 @@ free_shadow: | |||
| 1315 | rinfo->ring_ref[i] = GRANT_INVALID_REF; | 1323 | rinfo->ring_ref[i] = GRANT_INVALID_REF; |
| 1316 | } | 1324 | } |
| 1317 | } | 1325 | } |
| 1318 | free_pages((unsigned long)rinfo->ring.sring, get_order(info->nr_ring_pages * PAGE_SIZE)); | 1326 | free_pages((unsigned long)rinfo->ring.sring, get_order(info->nr_ring_pages * XEN_PAGE_SIZE)); |
| 1319 | rinfo->ring.sring = NULL; | 1327 | rinfo->ring.sring = NULL; |
| 1320 | 1328 | ||
| 1321 | if (rinfo->irq) | 1329 | if (rinfo->irq) |
| @@ -2007,8 +2015,10 @@ static int blkif_recover(struct blkfront_info *info) | |||
| 2007 | struct split_bio *split_bio; | 2015 | struct split_bio *split_bio; |
| 2008 | 2016 | ||
| 2009 | blkfront_gather_backend_features(info); | 2017 | blkfront_gather_backend_features(info); |
| 2018 | /* Reset limits changed by blk_mq_update_nr_hw_queues(). */ | ||
| 2019 | blkif_set_queue_limits(info); | ||
| 2010 | segs = info->max_indirect_segments ? : BLKIF_MAX_SEGMENTS_PER_REQUEST; | 2020 | segs = info->max_indirect_segments ? : BLKIF_MAX_SEGMENTS_PER_REQUEST; |
| 2011 | blk_queue_max_segments(info->rq, segs); | 2021 | blk_queue_max_segments(info->rq, segs / GRANTS_PER_PSEG); |
| 2012 | 2022 | ||
| 2013 | for (r_index = 0; r_index < info->nr_rings; r_index++) { | 2023 | for (r_index = 0; r_index < info->nr_rings; r_index++) { |
| 2014 | struct blkfront_ring_info *rinfo = &info->rinfo[r_index]; | 2024 | struct blkfront_ring_info *rinfo = &info->rinfo[r_index]; |
| @@ -2432,7 +2442,7 @@ static void blkfront_connect(struct blkfront_info *info) | |||
| 2432 | if (err) { | 2442 | if (err) { |
| 2433 | xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s", | 2443 | xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s", |
| 2434 | info->xbdev->otherend); | 2444 | info->xbdev->otherend); |
| 2435 | return; | 2445 | goto fail; |
| 2436 | } | 2446 | } |
| 2437 | 2447 | ||
| 2438 | xenbus_switch_state(info->xbdev, XenbusStateConnected); | 2448 | xenbus_switch_state(info->xbdev, XenbusStateConnected); |
| @@ -2445,6 +2455,11 @@ static void blkfront_connect(struct blkfront_info *info) | |||
| 2445 | device_add_disk(&info->xbdev->dev, info->gd); | 2455 | device_add_disk(&info->xbdev->dev, info->gd); |
| 2446 | 2456 | ||
| 2447 | info->is_ready = 1; | 2457 | info->is_ready = 1; |
| 2458 | return; | ||
| 2459 | |||
| 2460 | fail: | ||
| 2461 | blkif_free(info, 0); | ||
| 2462 | return; | ||
| 2448 | } | 2463 | } |
| 2449 | 2464 | ||
| 2450 | /** | 2465 | /** |
diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c index 5755907f836f..ffa7c9dcbd7a 100644 --- a/drivers/bus/arm-cci.c +++ b/drivers/bus/arm-cci.c | |||
| @@ -551,7 +551,7 @@ static struct attribute *cci5xx_pmu_event_attrs[] = { | |||
| 551 | CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_wrq, 0xB), | 551 | CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_wrq, 0xB), |
| 552 | CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_snoop_cd_hs, 0xC), | 552 | CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_snoop_cd_hs, 0xC), |
| 553 | CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_rq_stall_addr_hazard, 0xD), | 553 | CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_rq_stall_addr_hazard, 0xD), |
| 554 | CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_snopp_rq_stall_tt_full, 0xE), | 554 | CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_snoop_rq_stall_tt_full, 0xE), |
| 555 | CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_snoop_rq_tzmp1_prot, 0xF), | 555 | CCI5xx_GLOBAL_EVENT_EXT_ATTR_ENTRY(cci_snoop_rq_tzmp1_prot, 0xF), |
| 556 | NULL | 556 | NULL |
| 557 | }; | 557 | }; |
diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c index 97a9185af433..884c0305e290 100644 --- a/drivers/bus/arm-ccn.c +++ b/drivers/bus/arm-ccn.c | |||
| @@ -187,6 +187,7 @@ struct arm_ccn { | |||
| 187 | struct arm_ccn_component *xp; | 187 | struct arm_ccn_component *xp; |
| 188 | 188 | ||
| 189 | struct arm_ccn_dt dt; | 189 | struct arm_ccn_dt dt; |
| 190 | int mn_id; | ||
| 190 | }; | 191 | }; |
| 191 | 192 | ||
| 192 | static DEFINE_MUTEX(arm_ccn_mutex); | 193 | static DEFINE_MUTEX(arm_ccn_mutex); |
| @@ -212,6 +213,7 @@ static int arm_ccn_node_to_xp_port(int node) | |||
| 212 | #define CCN_CONFIG_TYPE(_config) (((_config) >> 8) & 0xff) | 213 | #define CCN_CONFIG_TYPE(_config) (((_config) >> 8) & 0xff) |
| 213 | #define CCN_CONFIG_EVENT(_config) (((_config) >> 16) & 0xff) | 214 | #define CCN_CONFIG_EVENT(_config) (((_config) >> 16) & 0xff) |
| 214 | #define CCN_CONFIG_PORT(_config) (((_config) >> 24) & 0x3) | 215 | #define CCN_CONFIG_PORT(_config) (((_config) >> 24) & 0x3) |
| 216 | #define CCN_CONFIG_BUS(_config) (((_config) >> 24) & 0x3) | ||
| 215 | #define CCN_CONFIG_VC(_config) (((_config) >> 26) & 0x7) | 217 | #define CCN_CONFIG_VC(_config) (((_config) >> 26) & 0x7) |
| 216 | #define CCN_CONFIG_DIR(_config) (((_config) >> 29) & 0x1) | 218 | #define CCN_CONFIG_DIR(_config) (((_config) >> 29) & 0x1) |
| 217 | #define CCN_CONFIG_MASK(_config) (((_config) >> 30) & 0xf) | 219 | #define CCN_CONFIG_MASK(_config) (((_config) >> 30) & 0xf) |
| @@ -241,6 +243,7 @@ static CCN_FORMAT_ATTR(xp, "config:0-7"); | |||
| 241 | static CCN_FORMAT_ATTR(type, "config:8-15"); | 243 | static CCN_FORMAT_ATTR(type, "config:8-15"); |
| 242 | static CCN_FORMAT_ATTR(event, "config:16-23"); | 244 | static CCN_FORMAT_ATTR(event, "config:16-23"); |
| 243 | static CCN_FORMAT_ATTR(port, "config:24-25"); | 245 | static CCN_FORMAT_ATTR(port, "config:24-25"); |
| 246 | static CCN_FORMAT_ATTR(bus, "config:24-25"); | ||
| 244 | static CCN_FORMAT_ATTR(vc, "config:26-28"); | 247 | static CCN_FORMAT_ATTR(vc, "config:26-28"); |
| 245 | static CCN_FORMAT_ATTR(dir, "config:29-29"); | 248 | static CCN_FORMAT_ATTR(dir, "config:29-29"); |
| 246 | static CCN_FORMAT_ATTR(mask, "config:30-33"); | 249 | static CCN_FORMAT_ATTR(mask, "config:30-33"); |
| @@ -253,6 +256,7 @@ static struct attribute *arm_ccn_pmu_format_attrs[] = { | |||
| 253 | &arm_ccn_pmu_format_attr_type.attr.attr, | 256 | &arm_ccn_pmu_format_attr_type.attr.attr, |
| 254 | &arm_ccn_pmu_format_attr_event.attr.attr, | 257 | &arm_ccn_pmu_format_attr_event.attr.attr, |
| 255 | &arm_ccn_pmu_format_attr_port.attr.attr, | 258 | &arm_ccn_pmu_format_attr_port.attr.attr, |
| 259 | &arm_ccn_pmu_format_attr_bus.attr.attr, | ||
| 256 | &arm_ccn_pmu_format_attr_vc.attr.attr, | 260 | &arm_ccn_pmu_format_attr_vc.attr.attr, |
| 257 | &arm_ccn_pmu_format_attr_dir.attr.attr, | 261 | &arm_ccn_pmu_format_attr_dir.attr.attr, |
| 258 | &arm_ccn_pmu_format_attr_mask.attr.attr, | 262 | &arm_ccn_pmu_format_attr_mask.attr.attr, |
| @@ -328,6 +332,7 @@ struct arm_ccn_pmu_event { | |||
| 328 | static ssize_t arm_ccn_pmu_event_show(struct device *dev, | 332 | static ssize_t arm_ccn_pmu_event_show(struct device *dev, |
| 329 | struct device_attribute *attr, char *buf) | 333 | struct device_attribute *attr, char *buf) |
| 330 | { | 334 | { |
| 335 | struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev)); | ||
| 331 | struct arm_ccn_pmu_event *event = container_of(attr, | 336 | struct arm_ccn_pmu_event *event = container_of(attr, |
| 332 | struct arm_ccn_pmu_event, attr); | 337 | struct arm_ccn_pmu_event, attr); |
| 333 | ssize_t res; | 338 | ssize_t res; |
| @@ -349,10 +354,17 @@ static ssize_t arm_ccn_pmu_event_show(struct device *dev, | |||
| 349 | break; | 354 | break; |
| 350 | case CCN_TYPE_XP: | 355 | case CCN_TYPE_XP: |
| 351 | res += snprintf(buf + res, PAGE_SIZE - res, | 356 | res += snprintf(buf + res, PAGE_SIZE - res, |
| 352 | ",xp=?,port=?,vc=?,dir=?"); | 357 | ",xp=?,vc=?"); |
| 353 | if (event->event == CCN_EVENT_WATCHPOINT) | 358 | if (event->event == CCN_EVENT_WATCHPOINT) |
| 354 | res += snprintf(buf + res, PAGE_SIZE - res, | 359 | res += snprintf(buf + res, PAGE_SIZE - res, |
| 355 | ",cmp_l=?,cmp_h=?,mask=?"); | 360 | ",port=?,dir=?,cmp_l=?,cmp_h=?,mask=?"); |
| 361 | else | ||
| 362 | res += snprintf(buf + res, PAGE_SIZE - res, | ||
| 363 | ",bus=?"); | ||
| 364 | |||
| 365 | break; | ||
| 366 | case CCN_TYPE_MN: | ||
| 367 | res += snprintf(buf + res, PAGE_SIZE - res, ",node=%d", ccn->mn_id); | ||
| 356 | break; | 368 | break; |
| 357 | default: | 369 | default: |
| 358 | res += snprintf(buf + res, PAGE_SIZE - res, ",node=?"); | 370 | res += snprintf(buf + res, PAGE_SIZE - res, ",node=?"); |
| @@ -383,9 +395,9 @@ static umode_t arm_ccn_pmu_events_is_visible(struct kobject *kobj, | |||
| 383 | } | 395 | } |
| 384 | 396 | ||
| 385 | static struct arm_ccn_pmu_event arm_ccn_pmu_events[] = { | 397 | static struct arm_ccn_pmu_event arm_ccn_pmu_events[] = { |
| 386 | CCN_EVENT_MN(eobarrier, "dir=0,vc=0,cmp_h=0x1c00", CCN_IDX_MASK_OPCODE), | 398 | CCN_EVENT_MN(eobarrier, "dir=1,vc=0,cmp_h=0x1c00", CCN_IDX_MASK_OPCODE), |
| 387 | CCN_EVENT_MN(ecbarrier, "dir=0,vc=0,cmp_h=0x1e00", CCN_IDX_MASK_OPCODE), | 399 | CCN_EVENT_MN(ecbarrier, "dir=1,vc=0,cmp_h=0x1e00", CCN_IDX_MASK_OPCODE), |
| 388 | CCN_EVENT_MN(dvmop, "dir=0,vc=0,cmp_h=0x2800", CCN_IDX_MASK_OPCODE), | 400 | CCN_EVENT_MN(dvmop, "dir=1,vc=0,cmp_h=0x2800", CCN_IDX_MASK_OPCODE), |
| 389 | CCN_EVENT_HNI(txdatflits, "dir=1,vc=3", CCN_IDX_MASK_ANY), | 401 | CCN_EVENT_HNI(txdatflits, "dir=1,vc=3", CCN_IDX_MASK_ANY), |
| 390 | CCN_EVENT_HNI(rxdatflits, "dir=0,vc=3", CCN_IDX_MASK_ANY), | 402 | CCN_EVENT_HNI(rxdatflits, "dir=0,vc=3", CCN_IDX_MASK_ANY), |
| 391 | CCN_EVENT_HNI(txreqflits, "dir=1,vc=0", CCN_IDX_MASK_ANY), | 403 | CCN_EVENT_HNI(txreqflits, "dir=1,vc=0", CCN_IDX_MASK_ANY), |
| @@ -733,9 +745,10 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) | |||
| 733 | 745 | ||
| 734 | if (has_branch_stack(event) || event->attr.exclude_user || | 746 | if (has_branch_stack(event) || event->attr.exclude_user || |
| 735 | event->attr.exclude_kernel || event->attr.exclude_hv || | 747 | event->attr.exclude_kernel || event->attr.exclude_hv || |
| 736 | event->attr.exclude_idle) { | 748 | event->attr.exclude_idle || event->attr.exclude_host || |
| 749 | event->attr.exclude_guest) { | ||
| 737 | dev_warn(ccn->dev, "Can't exclude execution levels!\n"); | 750 | dev_warn(ccn->dev, "Can't exclude execution levels!\n"); |
| 738 | return -EOPNOTSUPP; | 751 | return -EINVAL; |
| 739 | } | 752 | } |
| 740 | 753 | ||
| 741 | if (event->cpu < 0) { | 754 | if (event->cpu < 0) { |
| @@ -759,6 +772,12 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) | |||
| 759 | 772 | ||
| 760 | /* Validate node/xp vs topology */ | 773 | /* Validate node/xp vs topology */ |
| 761 | switch (type) { | 774 | switch (type) { |
| 775 | case CCN_TYPE_MN: | ||
| 776 | if (node_xp != ccn->mn_id) { | ||
| 777 | dev_warn(ccn->dev, "Invalid MN ID %d!\n", node_xp); | ||
| 778 | return -EINVAL; | ||
| 779 | } | ||
| 780 | break; | ||
| 762 | case CCN_TYPE_XP: | 781 | case CCN_TYPE_XP: |
| 763 | if (node_xp >= ccn->num_xps) { | 782 | if (node_xp >= ccn->num_xps) { |
| 764 | dev_warn(ccn->dev, "Invalid XP ID %d!\n", node_xp); | 783 | dev_warn(ccn->dev, "Invalid XP ID %d!\n", node_xp); |
| @@ -886,6 +905,10 @@ static void arm_ccn_pmu_xp_dt_config(struct perf_event *event, int enable) | |||
| 886 | struct arm_ccn_component *xp; | 905 | struct arm_ccn_component *xp; |
| 887 | u32 val, dt_cfg; | 906 | u32 val, dt_cfg; |
| 888 | 907 | ||
| 908 | /* Nothing to do for cycle counter */ | ||
| 909 | if (hw->idx == CCN_IDX_PMU_CYCLE_COUNTER) | ||
| 910 | return; | ||
| 911 | |||
| 889 | if (CCN_CONFIG_TYPE(event->attr.config) == CCN_TYPE_XP) | 912 | if (CCN_CONFIG_TYPE(event->attr.config) == CCN_TYPE_XP) |
| 890 | xp = &ccn->xp[CCN_CONFIG_XP(event->attr.config)]; | 913 | xp = &ccn->xp[CCN_CONFIG_XP(event->attr.config)]; |
| 891 | else | 914 | else |
| @@ -917,38 +940,17 @@ static void arm_ccn_pmu_event_start(struct perf_event *event, int flags) | |||
| 917 | arm_ccn_pmu_read_counter(ccn, hw->idx)); | 940 | arm_ccn_pmu_read_counter(ccn, hw->idx)); |
| 918 | hw->state = 0; | 941 | hw->state = 0; |
| 919 | 942 | ||
| 920 | /* | ||
| 921 | * Pin the timer, so that the overflows are handled by the chosen | ||
| 922 | * event->cpu (this is the same one as presented in "cpumask" | ||
| 923 | * attribute). | ||
| 924 | */ | ||
| 925 | if (!ccn->irq) | ||
| 926 | hrtimer_start(&ccn->dt.hrtimer, arm_ccn_pmu_timer_period(), | ||
| 927 | HRTIMER_MODE_REL_PINNED); | ||
| 928 | |||
| 929 | /* Set the DT bus input, engaging the counter */ | 943 | /* Set the DT bus input, engaging the counter */ |
| 930 | arm_ccn_pmu_xp_dt_config(event, 1); | 944 | arm_ccn_pmu_xp_dt_config(event, 1); |
| 931 | } | 945 | } |
| 932 | 946 | ||
| 933 | static void arm_ccn_pmu_event_stop(struct perf_event *event, int flags) | 947 | static void arm_ccn_pmu_event_stop(struct perf_event *event, int flags) |
| 934 | { | 948 | { |
| 935 | struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); | ||
| 936 | struct hw_perf_event *hw = &event->hw; | 949 | struct hw_perf_event *hw = &event->hw; |
| 937 | u64 timeout; | ||
| 938 | 950 | ||
| 939 | /* Disable counting, setting the DT bus to pass-through mode */ | 951 | /* Disable counting, setting the DT bus to pass-through mode */ |
| 940 | arm_ccn_pmu_xp_dt_config(event, 0); | 952 | arm_ccn_pmu_xp_dt_config(event, 0); |
| 941 | 953 | ||
| 942 | if (!ccn->irq) | ||
| 943 | hrtimer_cancel(&ccn->dt.hrtimer); | ||
| 944 | |||
| 945 | /* Let the DT bus drain */ | ||
| 946 | timeout = arm_ccn_pmu_read_counter(ccn, CCN_IDX_PMU_CYCLE_COUNTER) + | ||
| 947 | ccn->num_xps; | ||
| 948 | while (arm_ccn_pmu_read_counter(ccn, CCN_IDX_PMU_CYCLE_COUNTER) < | ||
| 949 | timeout) | ||
| 950 | cpu_relax(); | ||
| 951 | |||
| 952 | if (flags & PERF_EF_UPDATE) | 954 | if (flags & PERF_EF_UPDATE) |
| 953 | arm_ccn_pmu_event_update(event); | 955 | arm_ccn_pmu_event_update(event); |
| 954 | 956 | ||
| @@ -988,7 +990,7 @@ static void arm_ccn_pmu_xp_watchpoint_config(struct perf_event *event) | |||
| 988 | 990 | ||
| 989 | /* Comparison values */ | 991 | /* Comparison values */ |
| 990 | writel(cmp_l & 0xffffffff, source->base + CCN_XP_DT_CMP_VAL_L(wp)); | 992 | writel(cmp_l & 0xffffffff, source->base + CCN_XP_DT_CMP_VAL_L(wp)); |
| 991 | writel((cmp_l >> 32) & 0xefffffff, | 993 | writel((cmp_l >> 32) & 0x7fffffff, |
| 992 | source->base + CCN_XP_DT_CMP_VAL_L(wp) + 4); | 994 | source->base + CCN_XP_DT_CMP_VAL_L(wp) + 4); |
| 993 | writel(cmp_h & 0xffffffff, source->base + CCN_XP_DT_CMP_VAL_H(wp)); | 995 | writel(cmp_h & 0xffffffff, source->base + CCN_XP_DT_CMP_VAL_H(wp)); |
| 994 | writel((cmp_h >> 32) & 0x0fffffff, | 996 | writel((cmp_h >> 32) & 0x0fffffff, |
| @@ -996,7 +998,7 @@ static void arm_ccn_pmu_xp_watchpoint_config(struct perf_event *event) | |||
| 996 | 998 | ||
| 997 | /* Mask */ | 999 | /* Mask */ |
| 998 | writel(mask_l & 0xffffffff, source->base + CCN_XP_DT_CMP_MASK_L(wp)); | 1000 | writel(mask_l & 0xffffffff, source->base + CCN_XP_DT_CMP_MASK_L(wp)); |
| 999 | writel((mask_l >> 32) & 0xefffffff, | 1001 | writel((mask_l >> 32) & 0x7fffffff, |
| 1000 | source->base + CCN_XP_DT_CMP_MASK_L(wp) + 4); | 1002 | source->base + CCN_XP_DT_CMP_MASK_L(wp) + 4); |
| 1001 | writel(mask_h & 0xffffffff, source->base + CCN_XP_DT_CMP_MASK_H(wp)); | 1003 | writel(mask_h & 0xffffffff, source->base + CCN_XP_DT_CMP_MASK_H(wp)); |
| 1002 | writel((mask_h >> 32) & 0x0fffffff, | 1004 | writel((mask_h >> 32) & 0x0fffffff, |
| @@ -1014,7 +1016,7 @@ static void arm_ccn_pmu_xp_event_config(struct perf_event *event) | |||
| 1014 | hw->event_base = CCN_XP_DT_CONFIG__DT_CFG__XP_PMU_EVENT(hw->config_base); | 1016 | hw->event_base = CCN_XP_DT_CONFIG__DT_CFG__XP_PMU_EVENT(hw->config_base); |
| 1015 | 1017 | ||
| 1016 | id = (CCN_CONFIG_VC(event->attr.config) << 4) | | 1018 | id = (CCN_CONFIG_VC(event->attr.config) << 4) | |
| 1017 | (CCN_CONFIG_PORT(event->attr.config) << 3) | | 1019 | (CCN_CONFIG_BUS(event->attr.config) << 3) | |
| 1018 | (CCN_CONFIG_EVENT(event->attr.config) << 0); | 1020 | (CCN_CONFIG_EVENT(event->attr.config) << 0); |
| 1019 | 1021 | ||
| 1020 | val = readl(source->base + CCN_XP_PMU_EVENT_SEL); | 1022 | val = readl(source->base + CCN_XP_PMU_EVENT_SEL); |
| @@ -1099,15 +1101,31 @@ static void arm_ccn_pmu_event_config(struct perf_event *event) | |||
| 1099 | spin_unlock(&ccn->dt.config_lock); | 1101 | spin_unlock(&ccn->dt.config_lock); |
| 1100 | } | 1102 | } |
| 1101 | 1103 | ||
| 1104 | static int arm_ccn_pmu_active_counters(struct arm_ccn *ccn) | ||
| 1105 | { | ||
| 1106 | return bitmap_weight(ccn->dt.pmu_counters_mask, | ||
| 1107 | CCN_NUM_PMU_EVENT_COUNTERS + 1); | ||
| 1108 | } | ||
| 1109 | |||
| 1102 | static int arm_ccn_pmu_event_add(struct perf_event *event, int flags) | 1110 | static int arm_ccn_pmu_event_add(struct perf_event *event, int flags) |
| 1103 | { | 1111 | { |
| 1104 | int err; | 1112 | int err; |
| 1105 | struct hw_perf_event *hw = &event->hw; | 1113 | struct hw_perf_event *hw = &event->hw; |
| 1114 | struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); | ||
| 1106 | 1115 | ||
| 1107 | err = arm_ccn_pmu_event_alloc(event); | 1116 | err = arm_ccn_pmu_event_alloc(event); |
| 1108 | if (err) | 1117 | if (err) |
| 1109 | return err; | 1118 | return err; |
| 1110 | 1119 | ||
| 1120 | /* | ||
| 1121 | * Pin the timer, so that the overflows are handled by the chosen | ||
| 1122 | * event->cpu (this is the same one as presented in "cpumask" | ||
| 1123 | * attribute). | ||
| 1124 | */ | ||
| 1125 | if (!ccn->irq && arm_ccn_pmu_active_counters(ccn) == 1) | ||
| 1126 | hrtimer_start(&ccn->dt.hrtimer, arm_ccn_pmu_timer_period(), | ||
| 1127 | HRTIMER_MODE_REL_PINNED); | ||
| 1128 | |||
| 1111 | arm_ccn_pmu_event_config(event); | 1129 | arm_ccn_pmu_event_config(event); |
| 1112 | 1130 | ||
| 1113 | hw->state = PERF_HES_STOPPED; | 1131 | hw->state = PERF_HES_STOPPED; |
| @@ -1120,9 +1138,14 @@ static int arm_ccn_pmu_event_add(struct perf_event *event, int flags) | |||
| 1120 | 1138 | ||
| 1121 | static void arm_ccn_pmu_event_del(struct perf_event *event, int flags) | 1139 | static void arm_ccn_pmu_event_del(struct perf_event *event, int flags) |
| 1122 | { | 1140 | { |
| 1141 | struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); | ||
| 1142 | |||
| 1123 | arm_ccn_pmu_event_stop(event, PERF_EF_UPDATE); | 1143 | arm_ccn_pmu_event_stop(event, PERF_EF_UPDATE); |
| 1124 | 1144 | ||
| 1125 | arm_ccn_pmu_event_release(event); | 1145 | arm_ccn_pmu_event_release(event); |
| 1146 | |||
| 1147 | if (!ccn->irq && arm_ccn_pmu_active_counters(ccn) == 0) | ||
| 1148 | hrtimer_cancel(&ccn->dt.hrtimer); | ||
| 1126 | } | 1149 | } |
| 1127 | 1150 | ||
| 1128 | static void arm_ccn_pmu_event_read(struct perf_event *event) | 1151 | static void arm_ccn_pmu_event_read(struct perf_event *event) |
| @@ -1130,6 +1153,24 @@ static void arm_ccn_pmu_event_read(struct perf_event *event) | |||
| 1130 | arm_ccn_pmu_event_update(event); | 1153 | arm_ccn_pmu_event_update(event); |
| 1131 | } | 1154 | } |
| 1132 | 1155 | ||
| 1156 | static void arm_ccn_pmu_enable(struct pmu *pmu) | ||
| 1157 | { | ||
| 1158 | struct arm_ccn *ccn = pmu_to_arm_ccn(pmu); | ||
| 1159 | |||
| 1160 | u32 val = readl(ccn->dt.base + CCN_DT_PMCR); | ||
| 1161 | val |= CCN_DT_PMCR__PMU_EN; | ||
| 1162 | writel(val, ccn->dt.base + CCN_DT_PMCR); | ||
| 1163 | } | ||
| 1164 | |||
| 1165 | static void arm_ccn_pmu_disable(struct pmu *pmu) | ||
| 1166 | { | ||
| 1167 | struct arm_ccn *ccn = pmu_to_arm_ccn(pmu); | ||
| 1168 | |||
| 1169 | u32 val = readl(ccn->dt.base + CCN_DT_PMCR); | ||
| 1170 | val &= ~CCN_DT_PMCR__PMU_EN; | ||
| 1171 | writel(val, ccn->dt.base + CCN_DT_PMCR); | ||
| 1172 | } | ||
| 1173 | |||
| 1133 | static irqreturn_t arm_ccn_pmu_overflow_handler(struct arm_ccn_dt *dt) | 1174 | static irqreturn_t arm_ccn_pmu_overflow_handler(struct arm_ccn_dt *dt) |
| 1134 | { | 1175 | { |
| 1135 | u32 pmovsr = readl(dt->base + CCN_DT_PMOVSR); | 1176 | u32 pmovsr = readl(dt->base + CCN_DT_PMOVSR); |
| @@ -1252,6 +1293,8 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn) | |||
| 1252 | .start = arm_ccn_pmu_event_start, | 1293 | .start = arm_ccn_pmu_event_start, |
| 1253 | .stop = arm_ccn_pmu_event_stop, | 1294 | .stop = arm_ccn_pmu_event_stop, |
| 1254 | .read = arm_ccn_pmu_event_read, | 1295 | .read = arm_ccn_pmu_event_read, |
| 1296 | .pmu_enable = arm_ccn_pmu_enable, | ||
| 1297 | .pmu_disable = arm_ccn_pmu_disable, | ||
| 1255 | }; | 1298 | }; |
| 1256 | 1299 | ||
| 1257 | /* No overflow interrupt? Have to use a timer instead. */ | 1300 | /* No overflow interrupt? Have to use a timer instead. */ |
| @@ -1361,6 +1404,8 @@ static int arm_ccn_init_nodes(struct arm_ccn *ccn, int region, | |||
| 1361 | 1404 | ||
| 1362 | switch (type) { | 1405 | switch (type) { |
| 1363 | case CCN_TYPE_MN: | 1406 | case CCN_TYPE_MN: |
| 1407 | ccn->mn_id = id; | ||
| 1408 | return 0; | ||
| 1364 | case CCN_TYPE_DT: | 1409 | case CCN_TYPE_DT: |
| 1365 | return 0; | 1410 | return 0; |
| 1366 | case CCN_TYPE_XP: | 1411 | case CCN_TYPE_XP: |
| @@ -1471,8 +1516,9 @@ static int arm_ccn_probe(struct platform_device *pdev) | |||
| 1471 | /* Can set 'disable' bits, so can acknowledge interrupts */ | 1516 | /* Can set 'disable' bits, so can acknowledge interrupts */ |
| 1472 | writel(CCN_MN_ERRINT_STATUS__PMU_EVENTS__ENABLE, | 1517 | writel(CCN_MN_ERRINT_STATUS__PMU_EVENTS__ENABLE, |
| 1473 | ccn->base + CCN_MN_ERRINT_STATUS); | 1518 | ccn->base + CCN_MN_ERRINT_STATUS); |
| 1474 | err = devm_request_irq(ccn->dev, irq, arm_ccn_irq_handler, 0, | 1519 | err = devm_request_irq(ccn->dev, irq, arm_ccn_irq_handler, |
| 1475 | dev_name(ccn->dev), ccn); | 1520 | IRQF_NOBALANCING | IRQF_NO_THREAD, |
| 1521 | dev_name(ccn->dev), ccn); | ||
| 1476 | if (err) | 1522 | if (err) |
| 1477 | return err; | 1523 | return err; |
| 1478 | 1524 | ||
diff --git a/drivers/bus/vexpress-config.c b/drivers/bus/vexpress-config.c index c3cb76b363c6..9efdf1de4035 100644 --- a/drivers/bus/vexpress-config.c +++ b/drivers/bus/vexpress-config.c | |||
| @@ -178,6 +178,7 @@ static int vexpress_config_populate(struct device_node *node) | |||
| 178 | 178 | ||
| 179 | parent = class_find_device(vexpress_config_class, NULL, bridge, | 179 | parent = class_find_device(vexpress_config_class, NULL, bridge, |
| 180 | vexpress_config_node_match); | 180 | vexpress_config_node_match); |
| 181 | of_node_put(bridge); | ||
| 181 | if (WARN_ON(!parent)) | 182 | if (WARN_ON(!parent)) |
| 182 | return -ENODEV; | 183 | return -ENODEV; |
| 183 | 184 | ||
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index 56ad5a5936a9..8c0770bf8881 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig | |||
| @@ -244,7 +244,7 @@ config HW_RANDOM_TX4939 | |||
| 244 | 244 | ||
| 245 | config HW_RANDOM_MXC_RNGA | 245 | config HW_RANDOM_MXC_RNGA |
| 246 | tristate "Freescale i.MX RNGA Random Number Generator" | 246 | tristate "Freescale i.MX RNGA Random Number Generator" |
| 247 | depends on ARCH_HAS_RNGA | 247 | depends on SOC_IMX31 |
| 248 | default HW_RANDOM | 248 | default HW_RANDOM |
| 249 | ---help--- | 249 | ---help--- |
| 250 | This driver provides kernel-side support for the Random Number | 250 | This driver provides kernel-side support for the Random Number |
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index 08c7e23ed535..0c75c3f1689f 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c | |||
| @@ -957,7 +957,7 @@ int tpm2_auto_startup(struct tpm_chip *chip) | |||
| 957 | goto out; | 957 | goto out; |
| 958 | 958 | ||
| 959 | rc = tpm2_do_selftest(chip); | 959 | rc = tpm2_do_selftest(chip); |
| 960 | if (rc != TPM2_RC_INITIALIZE) { | 960 | if (rc != 0 && rc != TPM2_RC_INITIALIZE) { |
| 961 | dev_err(&chip->dev, "TPM self test failed\n"); | 961 | dev_err(&chip->dev, "TPM self test failed\n"); |
| 962 | goto out; | 962 | goto out; |
| 963 | } | 963 | } |
| @@ -974,7 +974,6 @@ int tpm2_auto_startup(struct tpm_chip *chip) | |||
| 974 | } | 974 | } |
| 975 | } | 975 | } |
| 976 | 976 | ||
| 977 | return rc; | ||
| 978 | out: | 977 | out: |
| 979 | if (rc > 0) | 978 | if (rc > 0) |
| 980 | rc = -ENODEV; | 979 | rc = -ENODEV; |
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index d2406fe25533..5da47e26a012 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
| @@ -165,6 +165,12 @@ struct ports_device { | |||
| 165 | */ | 165 | */ |
| 166 | struct virtqueue *c_ivq, *c_ovq; | 166 | struct virtqueue *c_ivq, *c_ovq; |
| 167 | 167 | ||
| 168 | /* | ||
| 169 | * A control packet buffer for guest->host requests, protected | ||
| 170 | * by c_ovq_lock. | ||
| 171 | */ | ||
| 172 | struct virtio_console_control cpkt; | ||
| 173 | |||
| 168 | /* Array of per-port IO virtqueues */ | 174 | /* Array of per-port IO virtqueues */ |
| 169 | struct virtqueue **in_vqs, **out_vqs; | 175 | struct virtqueue **in_vqs, **out_vqs; |
| 170 | 176 | ||
| @@ -560,28 +566,29 @@ static ssize_t __send_control_msg(struct ports_device *portdev, u32 port_id, | |||
| 560 | unsigned int event, unsigned int value) | 566 | unsigned int event, unsigned int value) |
| 561 | { | 567 | { |
| 562 | struct scatterlist sg[1]; | 568 | struct scatterlist sg[1]; |
| 563 | struct virtio_console_control cpkt; | ||
| 564 | struct virtqueue *vq; | 569 | struct virtqueue *vq; |
| 565 | unsigned int len; | 570 | unsigned int len; |
| 566 | 571 | ||
| 567 | if (!use_multiport(portdev)) | 572 | if (!use_multiport(portdev)) |
| 568 | return 0; | 573 | return 0; |
| 569 | 574 | ||
| 570 | cpkt.id = cpu_to_virtio32(portdev->vdev, port_id); | ||
| 571 | cpkt.event = cpu_to_virtio16(portdev->vdev, event); | ||
| 572 | cpkt.value = cpu_to_virtio16(portdev->vdev, value); | ||
| 573 | |||
| 574 | vq = portdev->c_ovq; | 575 | vq = portdev->c_ovq; |
| 575 | 576 | ||
| 576 | sg_init_one(sg, &cpkt, sizeof(cpkt)); | ||
| 577 | |||
| 578 | spin_lock(&portdev->c_ovq_lock); | 577 | spin_lock(&portdev->c_ovq_lock); |
| 579 | if (virtqueue_add_outbuf(vq, sg, 1, &cpkt, GFP_ATOMIC) == 0) { | 578 | |
| 579 | portdev->cpkt.id = cpu_to_virtio32(portdev->vdev, port_id); | ||
| 580 | portdev->cpkt.event = cpu_to_virtio16(portdev->vdev, event); | ||
| 581 | portdev->cpkt.value = cpu_to_virtio16(portdev->vdev, value); | ||
| 582 | |||
| 583 | sg_init_one(sg, &portdev->cpkt, sizeof(struct virtio_console_control)); | ||
| 584 | |||
| 585 | if (virtqueue_add_outbuf(vq, sg, 1, &portdev->cpkt, GFP_ATOMIC) == 0) { | ||
| 580 | virtqueue_kick(vq); | 586 | virtqueue_kick(vq); |
| 581 | while (!virtqueue_get_buf(vq, &len) | 587 | while (!virtqueue_get_buf(vq, &len) |
| 582 | && !virtqueue_is_broken(vq)) | 588 | && !virtqueue_is_broken(vq)) |
| 583 | cpu_relax(); | 589 | cpu_relax(); |
| 584 | } | 590 | } |
| 591 | |||
| 585 | spin_unlock(&portdev->c_ovq_lock); | 592 | spin_unlock(&portdev->c_ovq_lock); |
| 586 | return 0; | 593 | return 0; |
| 587 | } | 594 | } |
diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c b/drivers/clk/renesas/r8a7795-cpg-mssr.c index d359c92e13a6..e38bf60c0ff4 100644 --- a/drivers/clk/renesas/r8a7795-cpg-mssr.c +++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c | |||
| @@ -69,6 +69,7 @@ static const struct cpg_core_clk r8a7795_core_clks[] __initconst = { | |||
| 69 | DEF_FIXED(".s1", CLK_S1, CLK_PLL1_DIV2, 3, 1), | 69 | DEF_FIXED(".s1", CLK_S1, CLK_PLL1_DIV2, 3, 1), |
| 70 | DEF_FIXED(".s2", CLK_S2, CLK_PLL1_DIV2, 4, 1), | 70 | DEF_FIXED(".s2", CLK_S2, CLK_PLL1_DIV2, 4, 1), |
| 71 | DEF_FIXED(".s3", CLK_S3, CLK_PLL1_DIV2, 6, 1), | 71 | DEF_FIXED(".s3", CLK_S3, CLK_PLL1_DIV2, 6, 1), |
| 72 | DEF_FIXED(".sdsrc", CLK_SDSRC, CLK_PLL1_DIV2, 2, 1), | ||
| 72 | 73 | ||
| 73 | /* Core Clock Outputs */ | 74 | /* Core Clock Outputs */ |
| 74 | DEF_FIXED("ztr", R8A7795_CLK_ZTR, CLK_PLL1_DIV2, 6, 1), | 75 | DEF_FIXED("ztr", R8A7795_CLK_ZTR, CLK_PLL1_DIV2, 6, 1), |
| @@ -87,10 +88,10 @@ static const struct cpg_core_clk r8a7795_core_clks[] __initconst = { | |||
| 87 | DEF_FIXED("s3d2", R8A7795_CLK_S3D2, CLK_S3, 2, 1), | 88 | DEF_FIXED("s3d2", R8A7795_CLK_S3D2, CLK_S3, 2, 1), |
| 88 | DEF_FIXED("s3d4", R8A7795_CLK_S3D4, CLK_S3, 4, 1), | 89 | DEF_FIXED("s3d4", R8A7795_CLK_S3D4, CLK_S3, 4, 1), |
| 89 | 90 | ||
| 90 | DEF_GEN3_SD("sd0", R8A7795_CLK_SD0, CLK_PLL1_DIV2, 0x0074), | 91 | DEF_GEN3_SD("sd0", R8A7795_CLK_SD0, CLK_SDSRC, 0x0074), |
| 91 | DEF_GEN3_SD("sd1", R8A7795_CLK_SD1, CLK_PLL1_DIV2, 0x0078), | 92 | DEF_GEN3_SD("sd1", R8A7795_CLK_SD1, CLK_SDSRC, 0x0078), |
| 92 | DEF_GEN3_SD("sd2", R8A7795_CLK_SD2, CLK_PLL1_DIV2, 0x0268), | 93 | DEF_GEN3_SD("sd2", R8A7795_CLK_SD2, CLK_SDSRC, 0x0268), |
| 93 | DEF_GEN3_SD("sd3", R8A7795_CLK_SD3, CLK_PLL1_DIV2, 0x026c), | 94 | DEF_GEN3_SD("sd3", R8A7795_CLK_SD3, CLK_SDSRC, 0x026c), |
| 94 | 95 | ||
| 95 | DEF_FIXED("cl", R8A7795_CLK_CL, CLK_PLL1_DIV2, 48, 1), | 96 | DEF_FIXED("cl", R8A7795_CLK_CL, CLK_PLL1_DIV2, 48, 1), |
| 96 | DEF_FIXED("cp", R8A7795_CLK_CP, CLK_EXTAL, 2, 1), | 97 | DEF_FIXED("cp", R8A7795_CLK_CP, CLK_EXTAL, 2, 1), |
diff --git a/drivers/clk/rockchip/clk-rk3399.c b/drivers/clk/rockchip/clk-rk3399.c index c109d80e7a8a..cdfabeb9a034 100644 --- a/drivers/clk/rockchip/clk-rk3399.c +++ b/drivers/clk/rockchip/clk-rk3399.c | |||
| @@ -833,9 +833,9 @@ static struct rockchip_clk_branch rk3399_clk_branches[] __initdata = { | |||
| 833 | 833 | ||
| 834 | /* perihp */ | 834 | /* perihp */ |
| 835 | GATE(0, "cpll_aclk_perihp_src", "cpll", CLK_IGNORE_UNUSED, | 835 | GATE(0, "cpll_aclk_perihp_src", "cpll", CLK_IGNORE_UNUSED, |
| 836 | RK3399_CLKGATE_CON(5), 0, GFLAGS), | ||
| 837 | GATE(0, "gpll_aclk_perihp_src", "gpll", CLK_IGNORE_UNUSED, | ||
| 838 | RK3399_CLKGATE_CON(5), 1, GFLAGS), | 836 | RK3399_CLKGATE_CON(5), 1, GFLAGS), |
| 837 | GATE(0, "gpll_aclk_perihp_src", "gpll", CLK_IGNORE_UNUSED, | ||
| 838 | RK3399_CLKGATE_CON(5), 0, GFLAGS), | ||
| 839 | COMPOSITE(ACLK_PERIHP, "aclk_perihp", mux_aclk_perihp_p, CLK_IGNORE_UNUSED, | 839 | COMPOSITE(ACLK_PERIHP, "aclk_perihp", mux_aclk_perihp_p, CLK_IGNORE_UNUSED, |
| 840 | RK3399_CLKSEL_CON(14), 7, 1, MFLAGS, 0, 5, DFLAGS, | 840 | RK3399_CLKSEL_CON(14), 7, 1, MFLAGS, 0, 5, DFLAGS, |
| 841 | RK3399_CLKGATE_CON(5), 2, GFLAGS), | 841 | RK3399_CLKGATE_CON(5), 2, GFLAGS), |
| @@ -923,9 +923,9 @@ static struct rockchip_clk_branch rk3399_clk_branches[] __initdata = { | |||
| 923 | RK3399_CLKGATE_CON(6), 14, GFLAGS), | 923 | RK3399_CLKGATE_CON(6), 14, GFLAGS), |
| 924 | 924 | ||
| 925 | GATE(0, "cpll_aclk_emmc_src", "cpll", CLK_IGNORE_UNUSED, | 925 | GATE(0, "cpll_aclk_emmc_src", "cpll", CLK_IGNORE_UNUSED, |
| 926 | RK3399_CLKGATE_CON(6), 12, GFLAGS), | ||
| 927 | GATE(0, "gpll_aclk_emmc_src", "gpll", CLK_IGNORE_UNUSED, | ||
| 928 | RK3399_CLKGATE_CON(6), 13, GFLAGS), | 926 | RK3399_CLKGATE_CON(6), 13, GFLAGS), |
| 927 | GATE(0, "gpll_aclk_emmc_src", "gpll", CLK_IGNORE_UNUSED, | ||
| 928 | RK3399_CLKGATE_CON(6), 12, GFLAGS), | ||
| 929 | COMPOSITE_NOGATE(ACLK_EMMC, "aclk_emmc", mux_aclk_emmc_p, CLK_IGNORE_UNUSED, | 929 | COMPOSITE_NOGATE(ACLK_EMMC, "aclk_emmc", mux_aclk_emmc_p, CLK_IGNORE_UNUSED, |
| 930 | RK3399_CLKSEL_CON(21), 7, 1, MFLAGS, 0, 5, DFLAGS), | 930 | RK3399_CLKSEL_CON(21), 7, 1, MFLAGS, 0, 5, DFLAGS), |
| 931 | GATE(ACLK_EMMC_CORE, "aclk_emmccore", "aclk_emmc", CLK_IGNORE_UNUSED, | 931 | GATE(ACLK_EMMC_CORE, "aclk_emmccore", "aclk_emmc", CLK_IGNORE_UNUSED, |
| @@ -1071,7 +1071,7 @@ static struct rockchip_clk_branch rk3399_clk_branches[] __initdata = { | |||
| 1071 | /* vio */ | 1071 | /* vio */ |
| 1072 | COMPOSITE(ACLK_VIO, "aclk_vio", mux_pll_src_cpll_gpll_ppll_p, CLK_IGNORE_UNUSED, | 1072 | COMPOSITE(ACLK_VIO, "aclk_vio", mux_pll_src_cpll_gpll_ppll_p, CLK_IGNORE_UNUSED, |
| 1073 | RK3399_CLKSEL_CON(42), 6, 2, MFLAGS, 0, 5, DFLAGS, | 1073 | RK3399_CLKSEL_CON(42), 6, 2, MFLAGS, 0, 5, DFLAGS, |
| 1074 | RK3399_CLKGATE_CON(11), 10, GFLAGS), | 1074 | RK3399_CLKGATE_CON(11), 0, GFLAGS), |
| 1075 | COMPOSITE_NOMUX(PCLK_VIO, "pclk_vio", "aclk_vio", 0, | 1075 | COMPOSITE_NOMUX(PCLK_VIO, "pclk_vio", "aclk_vio", 0, |
| 1076 | RK3399_CLKSEL_CON(43), 0, 5, DFLAGS, | 1076 | RK3399_CLKSEL_CON(43), 0, 5, DFLAGS, |
| 1077 | RK3399_CLKGATE_CON(11), 1, GFLAGS), | 1077 | RK3399_CLKGATE_CON(11), 1, GFLAGS), |
| @@ -1484,6 +1484,7 @@ static const char *const rk3399_cru_critical_clocks[] __initconst = { | |||
| 1484 | "hclk_perilp1", | 1484 | "hclk_perilp1", |
| 1485 | "hclk_perilp1_noc", | 1485 | "hclk_perilp1_noc", |
| 1486 | "aclk_dmac0_perilp", | 1486 | "aclk_dmac0_perilp", |
| 1487 | "aclk_emmc_noc", | ||
| 1487 | "gpll_hclk_perilp1_src", | 1488 | "gpll_hclk_perilp1_src", |
| 1488 | "gpll_aclk_perilp0_src", | 1489 | "gpll_aclk_perilp0_src", |
| 1489 | "gpll_aclk_perihp_src", | 1490 | "gpll_aclk_perihp_src", |
diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c index 9af359544110..267f99523fbe 100644 --- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c +++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c | |||
| @@ -783,14 +783,14 @@ static struct ccu_reset_map sun8i_h3_ccu_resets[] = { | |||
| 783 | [RST_BUS_I2S1] = { 0x2d0, BIT(13) }, | 783 | [RST_BUS_I2S1] = { 0x2d0, BIT(13) }, |
| 784 | [RST_BUS_I2S2] = { 0x2d0, BIT(14) }, | 784 | [RST_BUS_I2S2] = { 0x2d0, BIT(14) }, |
| 785 | 785 | ||
| 786 | [RST_BUS_I2C0] = { 0x2d4, BIT(0) }, | 786 | [RST_BUS_I2C0] = { 0x2d8, BIT(0) }, |
| 787 | [RST_BUS_I2C1] = { 0x2d4, BIT(1) }, | 787 | [RST_BUS_I2C1] = { 0x2d8, BIT(1) }, |
| 788 | [RST_BUS_I2C2] = { 0x2d4, BIT(2) }, | 788 | [RST_BUS_I2C2] = { 0x2d8, BIT(2) }, |
| 789 | [RST_BUS_UART0] = { 0x2d4, BIT(16) }, | 789 | [RST_BUS_UART0] = { 0x2d8, BIT(16) }, |
| 790 | [RST_BUS_UART1] = { 0x2d4, BIT(17) }, | 790 | [RST_BUS_UART1] = { 0x2d8, BIT(17) }, |
| 791 | [RST_BUS_UART2] = { 0x2d4, BIT(18) }, | 791 | [RST_BUS_UART2] = { 0x2d8, BIT(18) }, |
| 792 | [RST_BUS_UART3] = { 0x2d4, BIT(19) }, | 792 | [RST_BUS_UART3] = { 0x2d8, BIT(19) }, |
| 793 | [RST_BUS_SCR] = { 0x2d4, BIT(20) }, | 793 | [RST_BUS_SCR] = { 0x2d8, BIT(20) }, |
| 794 | }; | 794 | }; |
| 795 | 795 | ||
| 796 | static const struct sunxi_ccu_desc sun8i_h3_ccu_desc = { | 796 | static const struct sunxi_ccu_desc sun8i_h3_ccu_desc = { |
diff --git a/drivers/clk/sunxi-ng/ccu_common.c b/drivers/clk/sunxi-ng/ccu_common.c index fc17b5295e16..51d4bac97ab3 100644 --- a/drivers/clk/sunxi-ng/ccu_common.c +++ b/drivers/clk/sunxi-ng/ccu_common.c | |||
| @@ -31,7 +31,7 @@ void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock) | |||
| 31 | return; | 31 | return; |
| 32 | 32 | ||
| 33 | WARN_ON(readl_relaxed_poll_timeout(common->base + common->reg, reg, | 33 | WARN_ON(readl_relaxed_poll_timeout(common->base + common->reg, reg, |
| 34 | !(reg & lock), 100, 70000)); | 34 | reg & lock, 100, 70000)); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, | 37 | int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, |
diff --git a/drivers/clk/sunxi-ng/ccu_nk.c b/drivers/clk/sunxi-ng/ccu_nk.c index 4470ffc8cf0d..d6fafb397489 100644 --- a/drivers/clk/sunxi-ng/ccu_nk.c +++ b/drivers/clk/sunxi-ng/ccu_nk.c | |||
| @@ -14,9 +14,9 @@ | |||
| 14 | #include "ccu_gate.h" | 14 | #include "ccu_gate.h" |
| 15 | #include "ccu_nk.h" | 15 | #include "ccu_nk.h" |
| 16 | 16 | ||
| 17 | void ccu_nk_find_best(unsigned long parent, unsigned long rate, | 17 | static void ccu_nk_find_best(unsigned long parent, unsigned long rate, |
| 18 | unsigned int max_n, unsigned int max_k, | 18 | unsigned int max_n, unsigned int max_k, |
| 19 | unsigned int *n, unsigned int *k) | 19 | unsigned int *n, unsigned int *k) |
| 20 | { | 20 | { |
| 21 | unsigned long best_rate = 0; | 21 | unsigned long best_rate = 0; |
| 22 | unsigned int best_k = 0, best_n = 0; | 22 | unsigned int best_k = 0, best_n = 0; |
diff --git a/drivers/clk/sunxi/clk-a10-pll2.c b/drivers/clk/sunxi/clk-a10-pll2.c index 0ee1f363e4be..d8eab90ae661 100644 --- a/drivers/clk/sunxi/clk-a10-pll2.c +++ b/drivers/clk/sunxi/clk-a10-pll2.c | |||
| @@ -73,7 +73,7 @@ static void __init sun4i_pll2_setup(struct device_node *node, | |||
| 73 | SUN4I_PLL2_PRE_DIV_WIDTH, | 73 | SUN4I_PLL2_PRE_DIV_WIDTH, |
| 74 | CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO, | 74 | CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO, |
| 75 | &sun4i_a10_pll2_lock); | 75 | &sun4i_a10_pll2_lock); |
| 76 | if (!prediv_clk) { | 76 | if (IS_ERR(prediv_clk)) { |
| 77 | pr_err("Couldn't register the prediv clock\n"); | 77 | pr_err("Couldn't register the prediv clock\n"); |
| 78 | goto err_free_array; | 78 | goto err_free_array; |
| 79 | } | 79 | } |
| @@ -106,7 +106,7 @@ static void __init sun4i_pll2_setup(struct device_node *node, | |||
| 106 | &mult->hw, &clk_multiplier_ops, | 106 | &mult->hw, &clk_multiplier_ops, |
| 107 | &gate->hw, &clk_gate_ops, | 107 | &gate->hw, &clk_gate_ops, |
| 108 | CLK_SET_RATE_PARENT); | 108 | CLK_SET_RATE_PARENT); |
| 109 | if (!base_clk) { | 109 | if (IS_ERR(base_clk)) { |
| 110 | pr_err("Couldn't register the base multiplier clock\n"); | 110 | pr_err("Couldn't register the base multiplier clock\n"); |
| 111 | goto err_free_multiplier; | 111 | goto err_free_multiplier; |
| 112 | } | 112 | } |
diff --git a/drivers/clk/sunxi/clk-sun8i-mbus.c b/drivers/clk/sunxi/clk-sun8i-mbus.c index 411d3033a96e..b200ebf159ee 100644 --- a/drivers/clk/sunxi/clk-sun8i-mbus.c +++ b/drivers/clk/sunxi/clk-sun8i-mbus.c | |||
| @@ -48,7 +48,7 @@ static void __init sun8i_a23_mbus_setup(struct device_node *node) | |||
| 48 | return; | 48 | return; |
| 49 | 49 | ||
| 50 | reg = of_io_request_and_map(node, 0, of_node_full_name(node)); | 50 | reg = of_io_request_and_map(node, 0, of_node_full_name(node)); |
| 51 | if (!reg) { | 51 | if (IS_ERR(reg)) { |
| 52 | pr_err("Could not get registers for sun8i-mbus-clk\n"); | 52 | pr_err("Could not get registers for sun8i-mbus-clk\n"); |
| 53 | goto err_free_parents; | 53 | goto err_free_parents; |
| 54 | } | 54 | } |
diff --git a/drivers/clk/tegra/clk-tegra114.c b/drivers/clk/tegra/clk-tegra114.c index 64da7b79a6e4..933b5dd698b8 100644 --- a/drivers/clk/tegra/clk-tegra114.c +++ b/drivers/clk/tegra/clk-tegra114.c | |||
| @@ -428,7 +428,7 @@ static struct tegra_clk_pll_params pll_d_params = { | |||
| 428 | .div_nmp = &pllp_nmp, | 428 | .div_nmp = &pllp_nmp, |
| 429 | .freq_table = pll_d_freq_table, | 429 | .freq_table = pll_d_freq_table, |
| 430 | .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | | 430 | .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | |
| 431 | TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE, | 431 | TEGRA_PLL_HAS_LOCK_ENABLE, |
| 432 | }; | 432 | }; |
| 433 | 433 | ||
| 434 | static struct tegra_clk_pll_params pll_d2_params = { | 434 | static struct tegra_clk_pll_params pll_d2_params = { |
| @@ -446,7 +446,7 @@ static struct tegra_clk_pll_params pll_d2_params = { | |||
| 446 | .div_nmp = &pllp_nmp, | 446 | .div_nmp = &pllp_nmp, |
| 447 | .freq_table = pll_d_freq_table, | 447 | .freq_table = pll_d_freq_table, |
| 448 | .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | | 448 | .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | |
| 449 | TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE, | 449 | TEGRA_PLL_HAS_LOCK_ENABLE, |
| 450 | }; | 450 | }; |
| 451 | 451 | ||
| 452 | static const struct pdiv_map pllu_p[] = { | 452 | static const struct pdiv_map pllu_p[] = { |
diff --git a/drivers/clocksource/pxa_timer.c b/drivers/clocksource/pxa_timer.c index 937e10b84d58..3e1cb512f3ce 100644 --- a/drivers/clocksource/pxa_timer.c +++ b/drivers/clocksource/pxa_timer.c | |||
| @@ -21,6 +21,8 @@ | |||
| 21 | #include <linux/of_irq.h> | 21 | #include <linux/of_irq.h> |
| 22 | #include <linux/sched_clock.h> | 22 | #include <linux/sched_clock.h> |
| 23 | 23 | ||
| 24 | #include <clocksource/pxa.h> | ||
| 25 | |||
| 24 | #include <asm/div64.h> | 26 | #include <asm/div64.h> |
| 25 | 27 | ||
| 26 | #define OSMR0 0x00 /* OS Timer 0 Match Register */ | 28 | #define OSMR0 0x00 /* OS Timer 0 Match Register */ |
diff --git a/drivers/clocksource/sun4i_timer.c b/drivers/clocksource/sun4i_timer.c index 97669ee4df2a..c83452cacb41 100644 --- a/drivers/clocksource/sun4i_timer.c +++ b/drivers/clocksource/sun4i_timer.c | |||
| @@ -123,12 +123,16 @@ static struct clock_event_device sun4i_clockevent = { | |||
| 123 | .set_next_event = sun4i_clkevt_next_event, | 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 | static irqreturn_t sun4i_timer_interrupt(int irq, void *dev_id) | 131 | static irqreturn_t sun4i_timer_interrupt(int irq, void *dev_id) |
| 128 | { | 132 | { |
| 129 | struct clock_event_device *evt = (struct clock_event_device *)dev_id; | 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 | evt->event_handler(evt); | 136 | evt->event_handler(evt); |
| 133 | 137 | ||
| 134 | return IRQ_HANDLED; | 138 | return IRQ_HANDLED; |
| @@ -208,6 +212,9 @@ static int __init sun4i_timer_init(struct device_node *node) | |||
| 208 | /* Make sure timer is stopped before playing with interrupts */ | 212 | /* Make sure timer is stopped before playing with interrupts */ |
| 209 | sun4i_clkevt_time_stop(0); | 213 | sun4i_clkevt_time_stop(0); |
| 210 | 214 | ||
| 215 | /* clear timer0 interrupt */ | ||
| 216 | sun4i_timer_clear_interrupt(); | ||
| 217 | |||
| 211 | sun4i_clockevent.cpumask = cpu_possible_mask; | 218 | sun4i_clockevent.cpumask = cpu_possible_mask; |
| 212 | sun4i_clockevent.irq = irq; | 219 | sun4i_clockevent.irq = irq; |
| 213 | 220 | ||
diff --git a/drivers/clocksource/time-pistachio.c b/drivers/clocksource/time-pistachio.c index a7d9a08e4b0e..a8e6c7df853d 100644 --- a/drivers/clocksource/time-pistachio.c +++ b/drivers/clocksource/time-pistachio.c | |||
| @@ -202,10 +202,10 @@ static int __init pistachio_clksrc_of_init(struct device_node *node) | |||
| 202 | rate = clk_get_rate(fast_clk); | 202 | rate = clk_get_rate(fast_clk); |
| 203 | 203 | ||
| 204 | /* Disable irq's for clocksource usage */ | 204 | /* Disable irq's for clocksource usage */ |
| 205 | gpt_writel(&pcs_gpt.base, 0, TIMER_IRQ_MASK, 0); | 205 | gpt_writel(pcs_gpt.base, 0, TIMER_IRQ_MASK, 0); |
| 206 | gpt_writel(&pcs_gpt.base, 0, TIMER_IRQ_MASK, 1); | 206 | gpt_writel(pcs_gpt.base, 0, TIMER_IRQ_MASK, 1); |
| 207 | gpt_writel(&pcs_gpt.base, 0, TIMER_IRQ_MASK, 2); | 207 | gpt_writel(pcs_gpt.base, 0, TIMER_IRQ_MASK, 2); |
| 208 | gpt_writel(&pcs_gpt.base, 0, TIMER_IRQ_MASK, 3); | 208 | gpt_writel(pcs_gpt.base, 0, TIMER_IRQ_MASK, 3); |
| 209 | 209 | ||
| 210 | /* Enable timer block */ | 210 | /* Enable timer block */ |
| 211 | writel(TIMER_ME_GLOBAL, pcs_gpt.base); | 211 | writel(TIMER_ME_GLOBAL, pcs_gpt.base); |
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c index 1ffac0cb0cb7..7f0f5b26d8c5 100644 --- a/drivers/clocksource/timer-atmel-pit.c +++ b/drivers/clocksource/timer-atmel-pit.c | |||
| @@ -240,6 +240,7 @@ static int __init at91sam926x_pit_common_init(struct pit_data *data) | |||
| 240 | static int __init at91sam926x_pit_dt_init(struct device_node *node) | 240 | static int __init at91sam926x_pit_dt_init(struct device_node *node) |
| 241 | { | 241 | { |
| 242 | struct pit_data *data; | 242 | struct pit_data *data; |
| 243 | int ret; | ||
| 243 | 244 | ||
| 244 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 245 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
| 245 | if (!data) | 246 | if (!data) |
| @@ -261,6 +262,12 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node) | |||
| 261 | return PTR_ERR(data->mck); | 262 | return PTR_ERR(data->mck); |
| 262 | } | 263 | } |
| 263 | 264 | ||
| 265 | ret = clk_prepare_enable(data->mck); | ||
| 266 | if (ret) { | ||
| 267 | pr_err("Unable to enable mck\n"); | ||
| 268 | return ret; | ||
| 269 | } | ||
| 270 | |||
| 264 | /* Get the interrupts property */ | 271 | /* Get the interrupts property */ |
| 265 | data->irq = irq_of_parse_and_map(node, 0); | 272 | data->irq = irq_of_parse_and_map(node, 0); |
| 266 | if (!data->irq) { | 273 | if (!data->irq) { |
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c index 0bb44d5b5df4..2ee40fd360ca 100644 --- a/drivers/cpufreq/cpufreq-dt-platdev.c +++ b/drivers/cpufreq/cpufreq-dt-platdev.c | |||
| @@ -74,6 +74,8 @@ static const struct of_device_id machines[] __initconst = { | |||
| 74 | { .compatible = "ti,omap5", }, | 74 | { .compatible = "ti,omap5", }, |
| 75 | 75 | ||
| 76 | { .compatible = "xlnx,zynq-7000", }, | 76 | { .compatible = "xlnx,zynq-7000", }, |
| 77 | |||
| 78 | { } | ||
| 77 | }; | 79 | }; |
| 78 | 80 | ||
| 79 | static int __init cpufreq_dt_platdev_init(void) | 81 | static int __init cpufreq_dt_platdev_init(void) |
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 6dc597126b79..b3044219772c 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c | |||
| @@ -556,7 +556,10 @@ skip_enc: | |||
| 556 | 556 | ||
| 557 | /* Read and write assoclen bytes */ | 557 | /* Read and write assoclen bytes */ |
| 558 | append_math_add(desc, VARSEQINLEN, ZERO, REG3, CAAM_CMD_SZ); | 558 | append_math_add(desc, VARSEQINLEN, ZERO, REG3, CAAM_CMD_SZ); |
| 559 | append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ); | 559 | if (alg->caam.geniv) |
| 560 | append_math_add_imm_u32(desc, VARSEQOUTLEN, REG3, IMM, ivsize); | ||
| 561 | else | ||
| 562 | append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ); | ||
| 560 | 563 | ||
| 561 | /* Skip assoc data */ | 564 | /* Skip assoc data */ |
| 562 | append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF); | 565 | append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF); |
| @@ -565,6 +568,14 @@ skip_enc: | |||
| 565 | append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS2 | FIFOLD_TYPE_MSG | | 568 | append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS2 | FIFOLD_TYPE_MSG | |
| 566 | KEY_VLF); | 569 | KEY_VLF); |
| 567 | 570 | ||
| 571 | if (alg->caam.geniv) { | ||
| 572 | append_seq_load(desc, ivsize, LDST_CLASS_1_CCB | | ||
| 573 | LDST_SRCDST_BYTE_CONTEXT | | ||
| 574 | (ctx1_iv_off << LDST_OFFSET_SHIFT)); | ||
| 575 | append_move(desc, MOVE_SRC_CLASS1CTX | MOVE_DEST_CLASS2INFIFO | | ||
| 576 | (ctx1_iv_off << MOVE_OFFSET_SHIFT) | ivsize); | ||
| 577 | } | ||
| 578 | |||
| 568 | /* Load Counter into CONTEXT1 reg */ | 579 | /* Load Counter into CONTEXT1 reg */ |
| 569 | if (is_rfc3686) | 580 | if (is_rfc3686) |
| 570 | append_load_imm_u32(desc, be32_to_cpu(1), LDST_IMM | | 581 | append_load_imm_u32(desc, be32_to_cpu(1), LDST_IMM | |
| @@ -2150,7 +2161,7 @@ static void init_authenc_job(struct aead_request *req, | |||
| 2150 | 2161 | ||
| 2151 | init_aead_job(req, edesc, all_contig, encrypt); | 2162 | init_aead_job(req, edesc, all_contig, encrypt); |
| 2152 | 2163 | ||
| 2153 | if (ivsize && (is_rfc3686 || !(alg->caam.geniv && encrypt))) | 2164 | if (ivsize && ((is_rfc3686 && encrypt) || !alg->caam.geniv)) |
| 2154 | append_load_as_imm(desc, req->iv, ivsize, | 2165 | append_load_as_imm(desc, req->iv, ivsize, |
| 2155 | LDST_CLASS_1_CCB | | 2166 | LDST_CLASS_1_CCB | |
| 2156 | LDST_SRCDST_BYTE_CONTEXT | | 2167 | LDST_SRCDST_BYTE_CONTEXT | |
| @@ -2537,20 +2548,6 @@ static int aead_decrypt(struct aead_request *req) | |||
| 2537 | return ret; | 2548 | return ret; |
| 2538 | } | 2549 | } |
| 2539 | 2550 | ||
| 2540 | static int aead_givdecrypt(struct aead_request *req) | ||
| 2541 | { | ||
| 2542 | struct crypto_aead *aead = crypto_aead_reqtfm(req); | ||
| 2543 | unsigned int ivsize = crypto_aead_ivsize(aead); | ||
| 2544 | |||
| 2545 | if (req->cryptlen < ivsize) | ||
| 2546 | return -EINVAL; | ||
| 2547 | |||
| 2548 | req->cryptlen -= ivsize; | ||
| 2549 | req->assoclen += ivsize; | ||
| 2550 | |||
| 2551 | return aead_decrypt(req); | ||
| 2552 | } | ||
| 2553 | |||
| 2554 | /* | 2551 | /* |
| 2555 | * allocate and map the ablkcipher extended descriptor for ablkcipher | 2552 | * allocate and map the ablkcipher extended descriptor for ablkcipher |
| 2556 | */ | 2553 | */ |
| @@ -3210,7 +3207,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3210 | .setkey = aead_setkey, | 3207 | .setkey = aead_setkey, |
| 3211 | .setauthsize = aead_setauthsize, | 3208 | .setauthsize = aead_setauthsize, |
| 3212 | .encrypt = aead_encrypt, | 3209 | .encrypt = aead_encrypt, |
| 3213 | .decrypt = aead_givdecrypt, | 3210 | .decrypt = aead_decrypt, |
| 3214 | .ivsize = AES_BLOCK_SIZE, | 3211 | .ivsize = AES_BLOCK_SIZE, |
| 3215 | .maxauthsize = MD5_DIGEST_SIZE, | 3212 | .maxauthsize = MD5_DIGEST_SIZE, |
| 3216 | }, | 3213 | }, |
| @@ -3256,7 +3253,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3256 | .setkey = aead_setkey, | 3253 | .setkey = aead_setkey, |
| 3257 | .setauthsize = aead_setauthsize, | 3254 | .setauthsize = aead_setauthsize, |
| 3258 | .encrypt = aead_encrypt, | 3255 | .encrypt = aead_encrypt, |
| 3259 | .decrypt = aead_givdecrypt, | 3256 | .decrypt = aead_decrypt, |
| 3260 | .ivsize = AES_BLOCK_SIZE, | 3257 | .ivsize = AES_BLOCK_SIZE, |
| 3261 | .maxauthsize = SHA1_DIGEST_SIZE, | 3258 | .maxauthsize = SHA1_DIGEST_SIZE, |
| 3262 | }, | 3259 | }, |
| @@ -3302,7 +3299,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3302 | .setkey = aead_setkey, | 3299 | .setkey = aead_setkey, |
| 3303 | .setauthsize = aead_setauthsize, | 3300 | .setauthsize = aead_setauthsize, |
| 3304 | .encrypt = aead_encrypt, | 3301 | .encrypt = aead_encrypt, |
| 3305 | .decrypt = aead_givdecrypt, | 3302 | .decrypt = aead_decrypt, |
| 3306 | .ivsize = AES_BLOCK_SIZE, | 3303 | .ivsize = AES_BLOCK_SIZE, |
| 3307 | .maxauthsize = SHA224_DIGEST_SIZE, | 3304 | .maxauthsize = SHA224_DIGEST_SIZE, |
| 3308 | }, | 3305 | }, |
| @@ -3348,7 +3345,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3348 | .setkey = aead_setkey, | 3345 | .setkey = aead_setkey, |
| 3349 | .setauthsize = aead_setauthsize, | 3346 | .setauthsize = aead_setauthsize, |
| 3350 | .encrypt = aead_encrypt, | 3347 | .encrypt = aead_encrypt, |
| 3351 | .decrypt = aead_givdecrypt, | 3348 | .decrypt = aead_decrypt, |
| 3352 | .ivsize = AES_BLOCK_SIZE, | 3349 | .ivsize = AES_BLOCK_SIZE, |
| 3353 | .maxauthsize = SHA256_DIGEST_SIZE, | 3350 | .maxauthsize = SHA256_DIGEST_SIZE, |
| 3354 | }, | 3351 | }, |
| @@ -3394,7 +3391,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3394 | .setkey = aead_setkey, | 3391 | .setkey = aead_setkey, |
| 3395 | .setauthsize = aead_setauthsize, | 3392 | .setauthsize = aead_setauthsize, |
| 3396 | .encrypt = aead_encrypt, | 3393 | .encrypt = aead_encrypt, |
| 3397 | .decrypt = aead_givdecrypt, | 3394 | .decrypt = aead_decrypt, |
| 3398 | .ivsize = AES_BLOCK_SIZE, | 3395 | .ivsize = AES_BLOCK_SIZE, |
| 3399 | .maxauthsize = SHA384_DIGEST_SIZE, | 3396 | .maxauthsize = SHA384_DIGEST_SIZE, |
| 3400 | }, | 3397 | }, |
| @@ -3440,7 +3437,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3440 | .setkey = aead_setkey, | 3437 | .setkey = aead_setkey, |
| 3441 | .setauthsize = aead_setauthsize, | 3438 | .setauthsize = aead_setauthsize, |
| 3442 | .encrypt = aead_encrypt, | 3439 | .encrypt = aead_encrypt, |
| 3443 | .decrypt = aead_givdecrypt, | 3440 | .decrypt = aead_decrypt, |
| 3444 | .ivsize = AES_BLOCK_SIZE, | 3441 | .ivsize = AES_BLOCK_SIZE, |
| 3445 | .maxauthsize = SHA512_DIGEST_SIZE, | 3442 | .maxauthsize = SHA512_DIGEST_SIZE, |
| 3446 | }, | 3443 | }, |
| @@ -3486,7 +3483,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3486 | .setkey = aead_setkey, | 3483 | .setkey = aead_setkey, |
| 3487 | .setauthsize = aead_setauthsize, | 3484 | .setauthsize = aead_setauthsize, |
| 3488 | .encrypt = aead_encrypt, | 3485 | .encrypt = aead_encrypt, |
| 3489 | .decrypt = aead_givdecrypt, | 3486 | .decrypt = aead_decrypt, |
| 3490 | .ivsize = DES3_EDE_BLOCK_SIZE, | 3487 | .ivsize = DES3_EDE_BLOCK_SIZE, |
| 3491 | .maxauthsize = MD5_DIGEST_SIZE, | 3488 | .maxauthsize = MD5_DIGEST_SIZE, |
| 3492 | }, | 3489 | }, |
| @@ -3534,7 +3531,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3534 | .setkey = aead_setkey, | 3531 | .setkey = aead_setkey, |
| 3535 | .setauthsize = aead_setauthsize, | 3532 | .setauthsize = aead_setauthsize, |
| 3536 | .encrypt = aead_encrypt, | 3533 | .encrypt = aead_encrypt, |
| 3537 | .decrypt = aead_givdecrypt, | 3534 | .decrypt = aead_decrypt, |
| 3538 | .ivsize = DES3_EDE_BLOCK_SIZE, | 3535 | .ivsize = DES3_EDE_BLOCK_SIZE, |
| 3539 | .maxauthsize = SHA1_DIGEST_SIZE, | 3536 | .maxauthsize = SHA1_DIGEST_SIZE, |
| 3540 | }, | 3537 | }, |
| @@ -3582,7 +3579,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3582 | .setkey = aead_setkey, | 3579 | .setkey = aead_setkey, |
| 3583 | .setauthsize = aead_setauthsize, | 3580 | .setauthsize = aead_setauthsize, |
| 3584 | .encrypt = aead_encrypt, | 3581 | .encrypt = aead_encrypt, |
| 3585 | .decrypt = aead_givdecrypt, | 3582 | .decrypt = aead_decrypt, |
| 3586 | .ivsize = DES3_EDE_BLOCK_SIZE, | 3583 | .ivsize = DES3_EDE_BLOCK_SIZE, |
| 3587 | .maxauthsize = SHA224_DIGEST_SIZE, | 3584 | .maxauthsize = SHA224_DIGEST_SIZE, |
| 3588 | }, | 3585 | }, |
| @@ -3630,7 +3627,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3630 | .setkey = aead_setkey, | 3627 | .setkey = aead_setkey, |
| 3631 | .setauthsize = aead_setauthsize, | 3628 | .setauthsize = aead_setauthsize, |
| 3632 | .encrypt = aead_encrypt, | 3629 | .encrypt = aead_encrypt, |
| 3633 | .decrypt = aead_givdecrypt, | 3630 | .decrypt = aead_decrypt, |
| 3634 | .ivsize = DES3_EDE_BLOCK_SIZE, | 3631 | .ivsize = DES3_EDE_BLOCK_SIZE, |
| 3635 | .maxauthsize = SHA256_DIGEST_SIZE, | 3632 | .maxauthsize = SHA256_DIGEST_SIZE, |
| 3636 | }, | 3633 | }, |
| @@ -3678,7 +3675,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3678 | .setkey = aead_setkey, | 3675 | .setkey = aead_setkey, |
| 3679 | .setauthsize = aead_setauthsize, | 3676 | .setauthsize = aead_setauthsize, |
| 3680 | .encrypt = aead_encrypt, | 3677 | .encrypt = aead_encrypt, |
| 3681 | .decrypt = aead_givdecrypt, | 3678 | .decrypt = aead_decrypt, |
| 3682 | .ivsize = DES3_EDE_BLOCK_SIZE, | 3679 | .ivsize = DES3_EDE_BLOCK_SIZE, |
| 3683 | .maxauthsize = SHA384_DIGEST_SIZE, | 3680 | .maxauthsize = SHA384_DIGEST_SIZE, |
| 3684 | }, | 3681 | }, |
| @@ -3726,7 +3723,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3726 | .setkey = aead_setkey, | 3723 | .setkey = aead_setkey, |
| 3727 | .setauthsize = aead_setauthsize, | 3724 | .setauthsize = aead_setauthsize, |
| 3728 | .encrypt = aead_encrypt, | 3725 | .encrypt = aead_encrypt, |
| 3729 | .decrypt = aead_givdecrypt, | 3726 | .decrypt = aead_decrypt, |
| 3730 | .ivsize = DES3_EDE_BLOCK_SIZE, | 3727 | .ivsize = DES3_EDE_BLOCK_SIZE, |
| 3731 | .maxauthsize = SHA512_DIGEST_SIZE, | 3728 | .maxauthsize = SHA512_DIGEST_SIZE, |
| 3732 | }, | 3729 | }, |
| @@ -3772,7 +3769,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3772 | .setkey = aead_setkey, | 3769 | .setkey = aead_setkey, |
| 3773 | .setauthsize = aead_setauthsize, | 3770 | .setauthsize = aead_setauthsize, |
| 3774 | .encrypt = aead_encrypt, | 3771 | .encrypt = aead_encrypt, |
| 3775 | .decrypt = aead_givdecrypt, | 3772 | .decrypt = aead_decrypt, |
| 3776 | .ivsize = DES_BLOCK_SIZE, | 3773 | .ivsize = DES_BLOCK_SIZE, |
| 3777 | .maxauthsize = MD5_DIGEST_SIZE, | 3774 | .maxauthsize = MD5_DIGEST_SIZE, |
| 3778 | }, | 3775 | }, |
| @@ -3818,7 +3815,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3818 | .setkey = aead_setkey, | 3815 | .setkey = aead_setkey, |
| 3819 | .setauthsize = aead_setauthsize, | 3816 | .setauthsize = aead_setauthsize, |
| 3820 | .encrypt = aead_encrypt, | 3817 | .encrypt = aead_encrypt, |
| 3821 | .decrypt = aead_givdecrypt, | 3818 | .decrypt = aead_decrypt, |
| 3822 | .ivsize = DES_BLOCK_SIZE, | 3819 | .ivsize = DES_BLOCK_SIZE, |
| 3823 | .maxauthsize = SHA1_DIGEST_SIZE, | 3820 | .maxauthsize = SHA1_DIGEST_SIZE, |
| 3824 | }, | 3821 | }, |
| @@ -3864,7 +3861,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3864 | .setkey = aead_setkey, | 3861 | .setkey = aead_setkey, |
| 3865 | .setauthsize = aead_setauthsize, | 3862 | .setauthsize = aead_setauthsize, |
| 3866 | .encrypt = aead_encrypt, | 3863 | .encrypt = aead_encrypt, |
| 3867 | .decrypt = aead_givdecrypt, | 3864 | .decrypt = aead_decrypt, |
| 3868 | .ivsize = DES_BLOCK_SIZE, | 3865 | .ivsize = DES_BLOCK_SIZE, |
| 3869 | .maxauthsize = SHA224_DIGEST_SIZE, | 3866 | .maxauthsize = SHA224_DIGEST_SIZE, |
| 3870 | }, | 3867 | }, |
| @@ -3910,7 +3907,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3910 | .setkey = aead_setkey, | 3907 | .setkey = aead_setkey, |
| 3911 | .setauthsize = aead_setauthsize, | 3908 | .setauthsize = aead_setauthsize, |
| 3912 | .encrypt = aead_encrypt, | 3909 | .encrypt = aead_encrypt, |
| 3913 | .decrypt = aead_givdecrypt, | 3910 | .decrypt = aead_decrypt, |
| 3914 | .ivsize = DES_BLOCK_SIZE, | 3911 | .ivsize = DES_BLOCK_SIZE, |
| 3915 | .maxauthsize = SHA256_DIGEST_SIZE, | 3912 | .maxauthsize = SHA256_DIGEST_SIZE, |
| 3916 | }, | 3913 | }, |
| @@ -3956,7 +3953,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 3956 | .setkey = aead_setkey, | 3953 | .setkey = aead_setkey, |
| 3957 | .setauthsize = aead_setauthsize, | 3954 | .setauthsize = aead_setauthsize, |
| 3958 | .encrypt = aead_encrypt, | 3955 | .encrypt = aead_encrypt, |
| 3959 | .decrypt = aead_givdecrypt, | 3956 | .decrypt = aead_decrypt, |
| 3960 | .ivsize = DES_BLOCK_SIZE, | 3957 | .ivsize = DES_BLOCK_SIZE, |
| 3961 | .maxauthsize = SHA384_DIGEST_SIZE, | 3958 | .maxauthsize = SHA384_DIGEST_SIZE, |
| 3962 | }, | 3959 | }, |
| @@ -4002,7 +3999,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 4002 | .setkey = aead_setkey, | 3999 | .setkey = aead_setkey, |
| 4003 | .setauthsize = aead_setauthsize, | 4000 | .setauthsize = aead_setauthsize, |
| 4004 | .encrypt = aead_encrypt, | 4001 | .encrypt = aead_encrypt, |
| 4005 | .decrypt = aead_givdecrypt, | 4002 | .decrypt = aead_decrypt, |
| 4006 | .ivsize = DES_BLOCK_SIZE, | 4003 | .ivsize = DES_BLOCK_SIZE, |
| 4007 | .maxauthsize = SHA512_DIGEST_SIZE, | 4004 | .maxauthsize = SHA512_DIGEST_SIZE, |
| 4008 | }, | 4005 | }, |
| @@ -4051,7 +4048,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 4051 | .setkey = aead_setkey, | 4048 | .setkey = aead_setkey, |
| 4052 | .setauthsize = aead_setauthsize, | 4049 | .setauthsize = aead_setauthsize, |
| 4053 | .encrypt = aead_encrypt, | 4050 | .encrypt = aead_encrypt, |
| 4054 | .decrypt = aead_givdecrypt, | 4051 | .decrypt = aead_decrypt, |
| 4055 | .ivsize = CTR_RFC3686_IV_SIZE, | 4052 | .ivsize = CTR_RFC3686_IV_SIZE, |
| 4056 | .maxauthsize = MD5_DIGEST_SIZE, | 4053 | .maxauthsize = MD5_DIGEST_SIZE, |
| 4057 | }, | 4054 | }, |
| @@ -4102,7 +4099,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 4102 | .setkey = aead_setkey, | 4099 | .setkey = aead_setkey, |
| 4103 | .setauthsize = aead_setauthsize, | 4100 | .setauthsize = aead_setauthsize, |
| 4104 | .encrypt = aead_encrypt, | 4101 | .encrypt = aead_encrypt, |
| 4105 | .decrypt = aead_givdecrypt, | 4102 | .decrypt = aead_decrypt, |
| 4106 | .ivsize = CTR_RFC3686_IV_SIZE, | 4103 | .ivsize = CTR_RFC3686_IV_SIZE, |
| 4107 | .maxauthsize = SHA1_DIGEST_SIZE, | 4104 | .maxauthsize = SHA1_DIGEST_SIZE, |
| 4108 | }, | 4105 | }, |
| @@ -4153,7 +4150,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 4153 | .setkey = aead_setkey, | 4150 | .setkey = aead_setkey, |
| 4154 | .setauthsize = aead_setauthsize, | 4151 | .setauthsize = aead_setauthsize, |
| 4155 | .encrypt = aead_encrypt, | 4152 | .encrypt = aead_encrypt, |
| 4156 | .decrypt = aead_givdecrypt, | 4153 | .decrypt = aead_decrypt, |
| 4157 | .ivsize = CTR_RFC3686_IV_SIZE, | 4154 | .ivsize = CTR_RFC3686_IV_SIZE, |
| 4158 | .maxauthsize = SHA224_DIGEST_SIZE, | 4155 | .maxauthsize = SHA224_DIGEST_SIZE, |
| 4159 | }, | 4156 | }, |
| @@ -4204,7 +4201,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 4204 | .setkey = aead_setkey, | 4201 | .setkey = aead_setkey, |
| 4205 | .setauthsize = aead_setauthsize, | 4202 | .setauthsize = aead_setauthsize, |
| 4206 | .encrypt = aead_encrypt, | 4203 | .encrypt = aead_encrypt, |
| 4207 | .decrypt = aead_givdecrypt, | 4204 | .decrypt = aead_decrypt, |
| 4208 | .ivsize = CTR_RFC3686_IV_SIZE, | 4205 | .ivsize = CTR_RFC3686_IV_SIZE, |
| 4209 | .maxauthsize = SHA256_DIGEST_SIZE, | 4206 | .maxauthsize = SHA256_DIGEST_SIZE, |
| 4210 | }, | 4207 | }, |
| @@ -4255,7 +4252,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 4255 | .setkey = aead_setkey, | 4252 | .setkey = aead_setkey, |
| 4256 | .setauthsize = aead_setauthsize, | 4253 | .setauthsize = aead_setauthsize, |
| 4257 | .encrypt = aead_encrypt, | 4254 | .encrypt = aead_encrypt, |
| 4258 | .decrypt = aead_givdecrypt, | 4255 | .decrypt = aead_decrypt, |
| 4259 | .ivsize = CTR_RFC3686_IV_SIZE, | 4256 | .ivsize = CTR_RFC3686_IV_SIZE, |
| 4260 | .maxauthsize = SHA384_DIGEST_SIZE, | 4257 | .maxauthsize = SHA384_DIGEST_SIZE, |
| 4261 | }, | 4258 | }, |
| @@ -4306,7 +4303,7 @@ static struct caam_aead_alg driver_aeads[] = { | |||
| 4306 | .setkey = aead_setkey, | 4303 | .setkey = aead_setkey, |
| 4307 | .setauthsize = aead_setauthsize, | 4304 | .setauthsize = aead_setauthsize, |
| 4308 | .encrypt = aead_encrypt, | 4305 | .encrypt = aead_encrypt, |
| 4309 | .decrypt = aead_givdecrypt, | 4306 | .decrypt = aead_decrypt, |
| 4310 | .ivsize = CTR_RFC3686_IV_SIZE, | 4307 | .ivsize = CTR_RFC3686_IV_SIZE, |
| 4311 | .maxauthsize = SHA512_DIGEST_SIZE, | 4308 | .maxauthsize = SHA512_DIGEST_SIZE, |
| 4312 | }, | 4309 | }, |
diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c index 769148dbaeb3..20f35df8a01f 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c | |||
| @@ -1260,8 +1260,8 @@ static struct crypto_alg qat_algs[] = { { | |||
| 1260 | .setkey = qat_alg_ablkcipher_xts_setkey, | 1260 | .setkey = qat_alg_ablkcipher_xts_setkey, |
| 1261 | .decrypt = qat_alg_ablkcipher_decrypt, | 1261 | .decrypt = qat_alg_ablkcipher_decrypt, |
| 1262 | .encrypt = qat_alg_ablkcipher_encrypt, | 1262 | .encrypt = qat_alg_ablkcipher_encrypt, |
| 1263 | .min_keysize = AES_MIN_KEY_SIZE, | 1263 | .min_keysize = 2 * AES_MIN_KEY_SIZE, |
| 1264 | .max_keysize = AES_MAX_KEY_SIZE, | 1264 | .max_keysize = 2 * AES_MAX_KEY_SIZE, |
| 1265 | .ivsize = AES_BLOCK_SIZE, | 1265 | .ivsize = AES_BLOCK_SIZE, |
| 1266 | }, | 1266 | }, |
| 1267 | }, | 1267 | }, |
diff --git a/drivers/crypto/vmx/aes_xts.c b/drivers/crypto/vmx/aes_xts.c index cfb25413917c..24353ec336c5 100644 --- a/drivers/crypto/vmx/aes_xts.c +++ b/drivers/crypto/vmx/aes_xts.c | |||
| @@ -129,8 +129,8 @@ static int p8_aes_xts_crypt(struct blkcipher_desc *desc, | |||
| 129 | 129 | ||
| 130 | blkcipher_walk_init(&walk, dst, src, nbytes); | 130 | blkcipher_walk_init(&walk, dst, src, nbytes); |
| 131 | 131 | ||
| 132 | iv = (u8 *)walk.iv; | ||
| 133 | ret = blkcipher_walk_virt(desc, &walk); | 132 | ret = blkcipher_walk_virt(desc, &walk); |
| 133 | iv = walk.iv; | ||
| 134 | memset(tweak, 0, AES_BLOCK_SIZE); | 134 | memset(tweak, 0, AES_BLOCK_SIZE); |
| 135 | aes_p8_encrypt(iv, tweak, &ctx->tweak_key); | 135 | aes_p8_encrypt(iv, tweak, &ctx->tweak_key); |
| 136 | 136 | ||
diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c index 803f3953b341..29f600f2c447 100644 --- a/drivers/dax/dax.c +++ b/drivers/dax/dax.c | |||
| @@ -459,7 +459,7 @@ static int __dax_dev_pmd_fault(struct dax_dev *dax_dev, | |||
| 459 | } | 459 | } |
| 460 | 460 | ||
| 461 | pgoff = linear_page_index(vma, pmd_addr); | 461 | pgoff = linear_page_index(vma, pmd_addr); |
| 462 | phys = pgoff_to_phys(dax_dev, pgoff, PAGE_SIZE); | 462 | phys = pgoff_to_phys(dax_dev, pgoff, PMD_SIZE); |
| 463 | if (phys == -1) { | 463 | if (phys == -1) { |
| 464 | dev_dbg(dev, "%s: phys_to_pgoff(%#lx) failed\n", __func__, | 464 | dev_dbg(dev, "%s: phys_to_pgoff(%#lx) failed\n", __func__, |
| 465 | pgoff); | 465 | pgoff); |
diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c index dfb168568af1..1f01e98c83c7 100644 --- a/drivers/dax/pmem.c +++ b/drivers/dax/pmem.c | |||
| @@ -116,6 +116,9 @@ static int dax_pmem_probe(struct device *dev) | |||
| 116 | if (rc) | 116 | if (rc) |
| 117 | return rc; | 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 | nd_region = to_nd_region(dev->parent); | 122 | nd_region = to_nd_region(dev->parent); |
| 120 | dax_region = alloc_dax_region(dev, nd_region->id, &res, | 123 | dax_region = alloc_dax_region(dev, nd_region->id, &res, |
| 121 | le32_to_cpu(pfn_sb->align), addr, PFN_DEV|PFN_MAP); | 124 | le32_to_cpu(pfn_sb->align), addr, PFN_DEV|PFN_MAP); |
diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index e434ffe7bc5c..832cbd647145 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c | |||
| @@ -2067,7 +2067,7 @@ err_dma_unregister: | |||
| 2067 | err_clk_disable: | 2067 | err_clk_disable: |
| 2068 | clk_disable_unprepare(atxdmac->clk); | 2068 | clk_disable_unprepare(atxdmac->clk); |
| 2069 | err_free_irq: | 2069 | err_free_irq: |
| 2070 | free_irq(atxdmac->irq, atxdmac->dma.dev); | 2070 | free_irq(atxdmac->irq, atxdmac); |
| 2071 | return ret; | 2071 | return ret; |
| 2072 | } | 2072 | } |
| 2073 | 2073 | ||
| @@ -2081,7 +2081,7 @@ static int at_xdmac_remove(struct platform_device *pdev) | |||
| 2081 | dma_async_device_unregister(&atxdmac->dma); | 2081 | dma_async_device_unregister(&atxdmac->dma); |
| 2082 | clk_disable_unprepare(atxdmac->clk); | 2082 | clk_disable_unprepare(atxdmac->clk); |
| 2083 | 2083 | ||
| 2084 | free_irq(atxdmac->irq, atxdmac->dma.dev); | 2084 | free_irq(atxdmac->irq, atxdmac); |
| 2085 | 2085 | ||
| 2086 | for (i = 0; i < atxdmac->dma.chancnt; i++) { | 2086 | for (i = 0; i < atxdmac->dma.chancnt; i++) { |
| 2087 | struct at_xdmac_chan *atchan = &atxdmac->chan[i]; | 2087 | struct at_xdmac_chan *atchan = &atxdmac->chan[i]; |
diff --git a/drivers/dma/fsl_raid.c b/drivers/dma/fsl_raid.c index aad167eaaee8..de2a2a2b1d75 100644 --- a/drivers/dma/fsl_raid.c +++ b/drivers/dma/fsl_raid.c | |||
| @@ -836,6 +836,7 @@ static int fsl_re_probe(struct platform_device *ofdev) | |||
| 836 | rc = of_property_read_u32(np, "reg", &off); | 836 | rc = of_property_read_u32(np, "reg", &off); |
| 837 | if (rc) { | 837 | if (rc) { |
| 838 | dev_err(dev, "Reg property not found in JQ node\n"); | 838 | dev_err(dev, "Reg property not found in JQ node\n"); |
| 839 | of_node_put(np); | ||
| 839 | return -ENODEV; | 840 | return -ENODEV; |
| 840 | } | 841 | } |
| 841 | /* Find out the Job Rings present under each JQ */ | 842 | /* Find out the Job Rings present under each JQ */ |
diff --git a/drivers/dma/img-mdc-dma.c b/drivers/dma/img-mdc-dma.c index a4c53be482cf..624f1e1e9c55 100644 --- a/drivers/dma/img-mdc-dma.c +++ b/drivers/dma/img-mdc-dma.c | |||
| @@ -861,7 +861,6 @@ static int mdc_dma_probe(struct platform_device *pdev) | |||
| 861 | { | 861 | { |
| 862 | struct mdc_dma *mdma; | 862 | struct mdc_dma *mdma; |
| 863 | struct resource *res; | 863 | struct resource *res; |
| 864 | const struct of_device_id *match; | ||
| 865 | unsigned int i; | 864 | unsigned int i; |
| 866 | u32 val; | 865 | u32 val; |
| 867 | int ret; | 866 | int ret; |
| @@ -871,8 +870,7 @@ static int mdc_dma_probe(struct platform_device *pdev) | |||
| 871 | return -ENOMEM; | 870 | return -ENOMEM; |
| 872 | platform_set_drvdata(pdev, mdma); | 871 | platform_set_drvdata(pdev, mdma); |
| 873 | 872 | ||
| 874 | match = of_match_device(mdc_dma_of_match, &pdev->dev); | 873 | mdma->soc = of_device_get_match_data(&pdev->dev); |
| 875 | mdma->soc = match->data; | ||
| 876 | 874 | ||
| 877 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 875 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 878 | mdma->regs = devm_ioremap_resource(&pdev->dev, res); | 876 | mdma->regs = devm_ioremap_resource(&pdev->dev, res); |
diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c index dc7850a422b8..3f56f9ca4482 100644 --- a/drivers/dma/pxa_dma.c +++ b/drivers/dma/pxa_dma.c | |||
| @@ -638,7 +638,7 @@ static bool pxad_try_hotchain(struct virt_dma_chan *vc, | |||
| 638 | vd_last_issued = list_entry(vc->desc_issued.prev, | 638 | vd_last_issued = list_entry(vc->desc_issued.prev, |
| 639 | struct virt_dma_desc, node); | 639 | struct virt_dma_desc, node); |
| 640 | pxad_desc_chain(vd_last_issued, vd); | 640 | pxad_desc_chain(vd_last_issued, vd); |
| 641 | if (is_chan_running(chan) || is_desc_completed(vd_last_issued)) | 641 | if (is_chan_running(chan) || is_desc_completed(vd)) |
| 642 | return true; | 642 | return true; |
| 643 | } | 643 | } |
| 644 | 644 | ||
| @@ -671,6 +671,7 @@ static irqreturn_t pxad_chan_handler(int irq, void *dev_id) | |||
| 671 | struct virt_dma_desc *vd, *tmp; | 671 | struct virt_dma_desc *vd, *tmp; |
| 672 | unsigned int dcsr; | 672 | unsigned int dcsr; |
| 673 | unsigned long flags; | 673 | unsigned long flags; |
| 674 | bool vd_completed; | ||
| 674 | dma_cookie_t last_started = 0; | 675 | dma_cookie_t last_started = 0; |
| 675 | 676 | ||
| 676 | BUG_ON(!chan); | 677 | BUG_ON(!chan); |
| @@ -681,15 +682,17 @@ static irqreturn_t pxad_chan_handler(int irq, void *dev_id) | |||
| 681 | 682 | ||
| 682 | spin_lock_irqsave(&chan->vc.lock, flags); | 683 | spin_lock_irqsave(&chan->vc.lock, flags); |
| 683 | list_for_each_entry_safe(vd, tmp, &chan->vc.desc_issued, node) { | 684 | list_for_each_entry_safe(vd, tmp, &chan->vc.desc_issued, node) { |
| 685 | vd_completed = is_desc_completed(vd); | ||
| 684 | dev_dbg(&chan->vc.chan.dev->device, | 686 | dev_dbg(&chan->vc.chan.dev->device, |
| 685 | "%s(): checking txd %p[%x]: completed=%d\n", | 687 | "%s(): checking txd %p[%x]: completed=%d dcsr=0x%x\n", |
| 686 | __func__, vd, vd->tx.cookie, is_desc_completed(vd)); | 688 | __func__, vd, vd->tx.cookie, vd_completed, |
| 689 | dcsr); | ||
| 687 | last_started = vd->tx.cookie; | 690 | last_started = vd->tx.cookie; |
| 688 | if (to_pxad_sw_desc(vd)->cyclic) { | 691 | if (to_pxad_sw_desc(vd)->cyclic) { |
| 689 | vchan_cyclic_callback(vd); | 692 | vchan_cyclic_callback(vd); |
| 690 | break; | 693 | break; |
| 691 | } | 694 | } |
| 692 | if (is_desc_completed(vd)) { | 695 | if (vd_completed) { |
| 693 | list_del(&vd->node); | 696 | list_del(&vd->node); |
| 694 | vchan_cookie_complete(vd); | 697 | vchan_cookie_complete(vd); |
| 695 | } else { | 698 | } else { |
diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c index 749f1bd5d65d..06ecdc38cee0 100644 --- a/drivers/dma/sh/usb-dmac.c +++ b/drivers/dma/sh/usb-dmac.c | |||
| @@ -600,27 +600,30 @@ static irqreturn_t usb_dmac_isr_channel(int irq, void *dev) | |||
| 600 | { | 600 | { |
| 601 | struct usb_dmac_chan *chan = dev; | 601 | struct usb_dmac_chan *chan = dev; |
| 602 | irqreturn_t ret = IRQ_NONE; | 602 | irqreturn_t ret = IRQ_NONE; |
| 603 | u32 mask = USB_DMACHCR_TE; | 603 | u32 mask = 0; |
| 604 | u32 check_bits = USB_DMACHCR_TE | USB_DMACHCR_SP; | ||
| 605 | u32 chcr; | 604 | u32 chcr; |
| 605 | bool xfer_end = false; | ||
| 606 | 606 | ||
| 607 | spin_lock(&chan->vc.lock); | 607 | spin_lock(&chan->vc.lock); |
| 608 | 608 | ||
| 609 | chcr = usb_dmac_chan_read(chan, USB_DMACHCR); | 609 | chcr = usb_dmac_chan_read(chan, USB_DMACHCR); |
| 610 | if (chcr & check_bits) | 610 | if (chcr & (USB_DMACHCR_TE | USB_DMACHCR_SP)) { |
| 611 | mask |= USB_DMACHCR_DE | check_bits; | 611 | mask |= USB_DMACHCR_DE | USB_DMACHCR_TE | USB_DMACHCR_SP; |
| 612 | if (chcr & USB_DMACHCR_DE) | ||
| 613 | xfer_end = true; | ||
| 614 | ret |= IRQ_HANDLED; | ||
| 615 | } | ||
| 612 | if (chcr & USB_DMACHCR_NULL) { | 616 | if (chcr & USB_DMACHCR_NULL) { |
| 613 | /* An interruption of TE will happen after we set FTE */ | 617 | /* An interruption of TE will happen after we set FTE */ |
| 614 | mask |= USB_DMACHCR_NULL; | 618 | mask |= USB_DMACHCR_NULL; |
| 615 | chcr |= USB_DMACHCR_FTE; | 619 | chcr |= USB_DMACHCR_FTE; |
| 616 | ret |= IRQ_HANDLED; | 620 | ret |= IRQ_HANDLED; |
| 617 | } | 621 | } |
| 618 | usb_dmac_chan_write(chan, USB_DMACHCR, chcr & ~mask); | 622 | if (mask) |
| 623 | usb_dmac_chan_write(chan, USB_DMACHCR, chcr & ~mask); | ||
| 619 | 624 | ||
| 620 | if (chcr & check_bits) { | 625 | if (xfer_end) |
| 621 | usb_dmac_isr_transfer_end(chan); | 626 | usb_dmac_isr_transfer_end(chan); |
| 622 | ret |= IRQ_HANDLED; | ||
| 623 | } | ||
| 624 | 627 | ||
| 625 | spin_unlock(&chan->vc.lock); | 628 | spin_unlock(&chan->vc.lock); |
| 626 | 629 | ||
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c index 438893762076..ce2bc2a38101 100644 --- a/drivers/firmware/arm_scpi.c +++ b/drivers/firmware/arm_scpi.c | |||
| @@ -709,9 +709,10 @@ static int scpi_probe(struct platform_device *pdev) | |||
| 709 | struct mbox_client *cl = &pchan->cl; | 709 | struct mbox_client *cl = &pchan->cl; |
| 710 | struct device_node *shmem = of_parse_phandle(np, "shmem", idx); | 710 | struct device_node *shmem = of_parse_phandle(np, "shmem", idx); |
| 711 | 711 | ||
| 712 | if (of_address_to_resource(shmem, 0, &res)) { | 712 | ret = of_address_to_resource(shmem, 0, &res); |
| 713 | of_node_put(shmem); | ||
| 714 | if (ret) { | ||
| 713 | dev_err(dev, "failed to get SCPI payload mem resource\n"); | 715 | dev_err(dev, "failed to get SCPI payload mem resource\n"); |
| 714 | ret = -EINVAL; | ||
| 715 | goto err; | 716 | goto err; |
| 716 | } | 717 | } |
| 717 | 718 | ||
diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c index 94a58a082b99..44c01390d035 100644 --- a/drivers/firmware/dmi-id.c +++ b/drivers/firmware/dmi-id.c | |||
| @@ -229,14 +229,14 @@ static int __init dmi_id_init(void) | |||
| 229 | 229 | ||
| 230 | ret = device_register(dmi_dev); | 230 | ret = device_register(dmi_dev); |
| 231 | if (ret) | 231 | if (ret) |
| 232 | goto fail_free_dmi_dev; | 232 | goto fail_put_dmi_dev; |
| 233 | 233 | ||
| 234 | return 0; | 234 | return 0; |
| 235 | 235 | ||
| 236 | fail_free_dmi_dev: | 236 | fail_put_dmi_dev: |
| 237 | kfree(dmi_dev); | 237 | put_device(dmi_dev); |
| 238 | fail_class_unregister: | ||
| 239 | 238 | ||
| 239 | fail_class_unregister: | ||
| 240 | class_unregister(&dmi_class); | 240 | class_unregister(&dmi_class); |
| 241 | 241 | ||
| 242 | return ret; | 242 | return ret; |
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 5a2631af7410..7dd2e2d37231 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c | |||
| @@ -657,9 +657,12 @@ static int __init fdt_find_uefi_params(unsigned long node, const char *uname, | |||
| 657 | } | 657 | } |
| 658 | 658 | ||
| 659 | if (subnode) { | 659 | if (subnode) { |
| 660 | node = of_get_flat_dt_subnode_by_name(node, subnode); | 660 | int err = of_get_flat_dt_subnode_by_name(node, subnode); |
| 661 | if (node < 0) | 661 | |
| 662 | if (err < 0) | ||
| 662 | return 0; | 663 | return 0; |
| 664 | |||
| 665 | node = err; | ||
| 663 | } | 666 | } |
| 664 | 667 | ||
| 665 | return __find_uefi_params(node, info, dt_params[i].params); | 668 | return __find_uefi_params(node, info, dt_params[i].params); |
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index 3bd127f95315..aded10662020 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c | |||
| @@ -41,6 +41,8 @@ static unsigned long __chunk_size = EFI_READ_CHUNK_SIZE; | |||
| 41 | #define EFI_ALLOC_ALIGN EFI_PAGE_SIZE | 41 | #define EFI_ALLOC_ALIGN EFI_PAGE_SIZE |
| 42 | #endif | 42 | #endif |
| 43 | 43 | ||
| 44 | #define EFI_MMAP_NR_SLACK_SLOTS 8 | ||
| 45 | |||
| 44 | struct file_info { | 46 | struct file_info { |
| 45 | efi_file_handle_t *handle; | 47 | efi_file_handle_t *handle; |
| 46 | u64 size; | 48 | u64 size; |
| @@ -63,49 +65,62 @@ void efi_printk(efi_system_table_t *sys_table_arg, char *str) | |||
| 63 | } | 65 | } |
| 64 | } | 66 | } |
| 65 | 67 | ||
| 68 | static inline bool mmap_has_headroom(unsigned long buff_size, | ||
| 69 | unsigned long map_size, | ||
| 70 | unsigned long desc_size) | ||
| 71 | { | ||
| 72 | unsigned long slack = buff_size - map_size; | ||
| 73 | |||
| 74 | return slack / desc_size >= EFI_MMAP_NR_SLACK_SLOTS; | ||
| 75 | } | ||
| 76 | |||
| 66 | efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, | 77 | efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, |
| 67 | efi_memory_desc_t **map, | 78 | struct efi_boot_memmap *map) |
| 68 | unsigned long *map_size, | ||
| 69 | unsigned long *desc_size, | ||
| 70 | u32 *desc_ver, | ||
| 71 | unsigned long *key_ptr) | ||
| 72 | { | 79 | { |
| 73 | efi_memory_desc_t *m = NULL; | 80 | efi_memory_desc_t *m = NULL; |
| 74 | efi_status_t status; | 81 | efi_status_t status; |
| 75 | unsigned long key; | 82 | unsigned long key; |
| 76 | u32 desc_version; | 83 | u32 desc_version; |
| 77 | 84 | ||
| 78 | *map_size = sizeof(*m) * 32; | 85 | *map->desc_size = sizeof(*m); |
| 86 | *map->map_size = *map->desc_size * 32; | ||
| 87 | *map->buff_size = *map->map_size; | ||
| 79 | again: | 88 | again: |
| 80 | /* | ||
| 81 | * Add an additional efi_memory_desc_t because we're doing an | ||
| 82 | * allocation which may be in a new descriptor region. | ||
| 83 | */ | ||
| 84 | *map_size += sizeof(*m); | ||
| 85 | status = efi_call_early(allocate_pool, EFI_LOADER_DATA, | 89 | status = efi_call_early(allocate_pool, EFI_LOADER_DATA, |
| 86 | *map_size, (void **)&m); | 90 | *map->map_size, (void **)&m); |
| 87 | if (status != EFI_SUCCESS) | 91 | if (status != EFI_SUCCESS) |
| 88 | goto fail; | 92 | goto fail; |
| 89 | 93 | ||
| 90 | *desc_size = 0; | 94 | *map->desc_size = 0; |
| 91 | key = 0; | 95 | key = 0; |
| 92 | status = efi_call_early(get_memory_map, map_size, m, | 96 | status = efi_call_early(get_memory_map, map->map_size, m, |
| 93 | &key, desc_size, &desc_version); | 97 | &key, map->desc_size, &desc_version); |
| 94 | if (status == EFI_BUFFER_TOO_SMALL) { | 98 | if (status == EFI_BUFFER_TOO_SMALL || |
| 99 | !mmap_has_headroom(*map->buff_size, *map->map_size, | ||
| 100 | *map->desc_size)) { | ||
| 95 | efi_call_early(free_pool, m); | 101 | efi_call_early(free_pool, m); |
| 102 | /* | ||
| 103 | * Make sure there is some entries of headroom so that the | ||
| 104 | * buffer can be reused for a new map after allocations are | ||
| 105 | * no longer permitted. Its unlikely that the map will grow to | ||
| 106 | * exceed this headroom once we are ready to trigger | ||
| 107 | * ExitBootServices() | ||
| 108 | */ | ||
| 109 | *map->map_size += *map->desc_size * EFI_MMAP_NR_SLACK_SLOTS; | ||
| 110 | *map->buff_size = *map->map_size; | ||
| 96 | goto again; | 111 | goto again; |
| 97 | } | 112 | } |
| 98 | 113 | ||
| 99 | if (status != EFI_SUCCESS) | 114 | if (status != EFI_SUCCESS) |
| 100 | efi_call_early(free_pool, m); | 115 | efi_call_early(free_pool, m); |
| 101 | 116 | ||
| 102 | if (key_ptr && status == EFI_SUCCESS) | 117 | if (map->key_ptr && status == EFI_SUCCESS) |
| 103 | *key_ptr = key; | 118 | *map->key_ptr = key; |
| 104 | if (desc_ver && status == EFI_SUCCESS) | 119 | if (map->desc_ver && status == EFI_SUCCESS) |
| 105 | *desc_ver = desc_version; | 120 | *map->desc_ver = desc_version; |
| 106 | 121 | ||
| 107 | fail: | 122 | fail: |
| 108 | *map = m; | 123 | *map->map = m; |
| 109 | return status; | 124 | return status; |
| 110 | } | 125 | } |
| 111 | 126 | ||
| @@ -113,13 +128,20 @@ fail: | |||
| 113 | unsigned long get_dram_base(efi_system_table_t *sys_table_arg) | 128 | unsigned long get_dram_base(efi_system_table_t *sys_table_arg) |
| 114 | { | 129 | { |
| 115 | efi_status_t status; | 130 | efi_status_t status; |
| 116 | unsigned long map_size; | 131 | unsigned long map_size, buff_size; |
| 117 | unsigned long membase = EFI_ERROR; | 132 | unsigned long membase = EFI_ERROR; |
| 118 | struct efi_memory_map map; | 133 | struct efi_memory_map map; |
| 119 | efi_memory_desc_t *md; | 134 | efi_memory_desc_t *md; |
| 135 | struct efi_boot_memmap boot_map; | ||
| 120 | 136 | ||
| 121 | status = efi_get_memory_map(sys_table_arg, (efi_memory_desc_t **)&map.map, | 137 | boot_map.map = (efi_memory_desc_t **)&map.map; |
| 122 | &map_size, &map.desc_size, NULL, NULL); | 138 | boot_map.map_size = &map_size; |
| 139 | boot_map.desc_size = &map.desc_size; | ||
| 140 | boot_map.desc_ver = NULL; | ||
| 141 | boot_map.key_ptr = NULL; | ||
| 142 | boot_map.buff_size = &buff_size; | ||
| 143 | |||
| 144 | status = efi_get_memory_map(sys_table_arg, &boot_map); | ||
| 123 | if (status != EFI_SUCCESS) | 145 | if (status != EFI_SUCCESS) |
| 124 | return membase; | 146 | return membase; |
| 125 | 147 | ||
| @@ -144,15 +166,22 @@ efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg, | |||
| 144 | unsigned long size, unsigned long align, | 166 | unsigned long size, unsigned long align, |
| 145 | unsigned long *addr, unsigned long max) | 167 | unsigned long *addr, unsigned long max) |
| 146 | { | 168 | { |
| 147 | unsigned long map_size, desc_size; | 169 | unsigned long map_size, desc_size, buff_size; |
| 148 | efi_memory_desc_t *map; | 170 | efi_memory_desc_t *map; |
| 149 | efi_status_t status; | 171 | efi_status_t status; |
| 150 | unsigned long nr_pages; | 172 | unsigned long nr_pages; |
| 151 | u64 max_addr = 0; | 173 | u64 max_addr = 0; |
| 152 | int i; | 174 | int i; |
| 175 | struct efi_boot_memmap boot_map; | ||
| 176 | |||
| 177 | boot_map.map = ↦ | ||
| 178 | boot_map.map_size = &map_size; | ||
| 179 | boot_map.desc_size = &desc_size; | ||
| 180 | boot_map.desc_ver = NULL; | ||
| 181 | boot_map.key_ptr = NULL; | ||
| 182 | boot_map.buff_size = &buff_size; | ||
| 153 | 183 | ||
| 154 | status = efi_get_memory_map(sys_table_arg, &map, &map_size, &desc_size, | 184 | status = efi_get_memory_map(sys_table_arg, &boot_map); |
| 155 | NULL, NULL); | ||
| 156 | if (status != EFI_SUCCESS) | 185 | if (status != EFI_SUCCESS) |
| 157 | goto fail; | 186 | goto fail; |
| 158 | 187 | ||
| @@ -230,14 +259,21 @@ efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, | |||
| 230 | unsigned long size, unsigned long align, | 259 | unsigned long size, unsigned long align, |
| 231 | unsigned long *addr) | 260 | unsigned long *addr) |
| 232 | { | 261 | { |
| 233 | unsigned long map_size, desc_size; | 262 | unsigned long map_size, desc_size, buff_size; |
| 234 | efi_memory_desc_t *map; | 263 | efi_memory_desc_t *map; |
| 235 | efi_status_t status; | 264 | efi_status_t status; |
| 236 | unsigned long nr_pages; | 265 | unsigned long nr_pages; |
| 237 | int i; | 266 | int i; |
| 267 | struct efi_boot_memmap boot_map; | ||
| 238 | 268 | ||
| 239 | status = efi_get_memory_map(sys_table_arg, &map, &map_size, &desc_size, | 269 | boot_map.map = ↦ |
| 240 | NULL, NULL); | 270 | boot_map.map_size = &map_size; |
| 271 | boot_map.desc_size = &desc_size; | ||
| 272 | boot_map.desc_ver = NULL; | ||
| 273 | boot_map.key_ptr = NULL; | ||
| 274 | boot_map.buff_size = &buff_size; | ||
| 275 | |||
| 276 | status = efi_get_memory_map(sys_table_arg, &boot_map); | ||
| 241 | if (status != EFI_SUCCESS) | 277 | if (status != EFI_SUCCESS) |
| 242 | goto fail; | 278 | goto fail; |
| 243 | 279 | ||
| @@ -704,3 +740,76 @@ char *efi_convert_cmdline(efi_system_table_t *sys_table_arg, | |||
| 704 | *cmd_line_len = options_bytes; | 740 | *cmd_line_len = options_bytes; |
| 705 | return (char *)cmdline_addr; | 741 | return (char *)cmdline_addr; |
| 706 | } | 742 | } |
| 743 | |||
| 744 | /* | ||
| 745 | * Handle calling ExitBootServices according to the requirements set out by the | ||
| 746 | * spec. Obtains the current memory map, and returns that info after calling | ||
| 747 | * ExitBootServices. The client must specify a function to perform any | ||
| 748 | * processing of the memory map data prior to ExitBootServices. A client | ||
| 749 | * specific structure may be passed to the function via priv. The client | ||
| 750 | * function may be called multiple times. | ||
| 751 | */ | ||
| 752 | efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table_arg, | ||
| 753 | void *handle, | ||
| 754 | struct efi_boot_memmap *map, | ||
| 755 | void *priv, | ||
| 756 | efi_exit_boot_map_processing priv_func) | ||
| 757 | { | ||
| 758 | efi_status_t status; | ||
| 759 | |||
| 760 | status = efi_get_memory_map(sys_table_arg, map); | ||
| 761 | |||
| 762 | if (status != EFI_SUCCESS) | ||
| 763 | goto fail; | ||
| 764 | |||
| 765 | status = priv_func(sys_table_arg, map, priv); | ||
| 766 | if (status != EFI_SUCCESS) | ||
| 767 | goto free_map; | ||
| 768 | |||
| 769 | status = efi_call_early(exit_boot_services, handle, *map->key_ptr); | ||
| 770 | |||
| 771 | if (status == EFI_INVALID_PARAMETER) { | ||
| 772 | /* | ||
| 773 | * The memory map changed between efi_get_memory_map() and | ||
| 774 | * exit_boot_services(). Per the UEFI Spec v2.6, Section 6.4: | ||
| 775 | * EFI_BOOT_SERVICES.ExitBootServices we need to get the | ||
| 776 | * updated map, and try again. The spec implies one retry | ||
| 777 | * should be sufficent, which is confirmed against the EDK2 | ||
| 778 | * implementation. Per the spec, we can only invoke | ||
| 779 | * get_memory_map() and exit_boot_services() - we cannot alloc | ||
| 780 | * so efi_get_memory_map() cannot be used, and we must reuse | ||
| 781 | * the buffer. For all practical purposes, the headroom in the | ||
| 782 | * buffer should account for any changes in the map so the call | ||
| 783 | * to get_memory_map() is expected to succeed here. | ||
| 784 | */ | ||
| 785 | *map->map_size = *map->buff_size; | ||
| 786 | status = efi_call_early(get_memory_map, | ||
| 787 | map->map_size, | ||
| 788 | *map->map, | ||
| 789 | map->key_ptr, | ||
| 790 | map->desc_size, | ||
| 791 | map->desc_ver); | ||
| 792 | |||
| 793 | /* exit_boot_services() was called, thus cannot free */ | ||
| 794 | if (status != EFI_SUCCESS) | ||
| 795 | goto fail; | ||
| 796 | |||
| 797 | status = priv_func(sys_table_arg, map, priv); | ||
| 798 | /* exit_boot_services() was called, thus cannot free */ | ||
| 799 | if (status != EFI_SUCCESS) | ||
| 800 | goto fail; | ||
| 801 | |||
| 802 | status = efi_call_early(exit_boot_services, handle, *map->key_ptr); | ||
| 803 | } | ||
| 804 | |||
| 805 | /* exit_boot_services() was called, thus cannot free */ | ||
| 806 | if (status != EFI_SUCCESS) | ||
| 807 | goto fail; | ||
| 808 | |||
| 809 | return EFI_SUCCESS; | ||
| 810 | |||
| 811 | free_map: | ||
| 812 | efi_call_early(free_pool, *map->map); | ||
| 813 | fail: | ||
| 814 | return status; | ||
| 815 | } | ||
diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c index e58abfa953cc..a6a93116a8f0 100644 --- a/drivers/firmware/efi/libstub/fdt.c +++ b/drivers/firmware/efi/libstub/fdt.c | |||
| @@ -152,6 +152,27 @@ fdt_set_fail: | |||
| 152 | #define EFI_FDT_ALIGN EFI_PAGE_SIZE | 152 | #define EFI_FDT_ALIGN EFI_PAGE_SIZE |
| 153 | #endif | 153 | #endif |
| 154 | 154 | ||
| 155 | struct exit_boot_struct { | ||
| 156 | efi_memory_desc_t *runtime_map; | ||
| 157 | int *runtime_entry_count; | ||
| 158 | }; | ||
| 159 | |||
| 160 | static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg, | ||
| 161 | struct efi_boot_memmap *map, | ||
| 162 | void *priv) | ||
| 163 | { | ||
| 164 | struct exit_boot_struct *p = priv; | ||
| 165 | /* | ||
| 166 | * Update the memory map with virtual addresses. The function will also | ||
| 167 | * populate @runtime_map with copies of just the EFI_MEMORY_RUNTIME | ||
| 168 | * entries so that we can pass it straight to SetVirtualAddressMap() | ||
| 169 | */ | ||
| 170 | efi_get_virtmap(*map->map, *map->map_size, *map->desc_size, | ||
| 171 | p->runtime_map, p->runtime_entry_count); | ||
| 172 | |||
| 173 | return EFI_SUCCESS; | ||
| 174 | } | ||
| 175 | |||
| 155 | /* | 176 | /* |
| 156 | * Allocate memory for a new FDT, then add EFI, commandline, and | 177 | * Allocate memory for a new FDT, then add EFI, commandline, and |
| 157 | * initrd related fields to the FDT. This routine increases the | 178 | * initrd related fields to the FDT. This routine increases the |
| @@ -175,13 +196,22 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, | |||
| 175 | unsigned long fdt_addr, | 196 | unsigned long fdt_addr, |
| 176 | unsigned long fdt_size) | 197 | unsigned long fdt_size) |
| 177 | { | 198 | { |
| 178 | unsigned long map_size, desc_size; | 199 | unsigned long map_size, desc_size, buff_size; |
| 179 | u32 desc_ver; | 200 | u32 desc_ver; |
| 180 | unsigned long mmap_key; | 201 | unsigned long mmap_key; |
| 181 | efi_memory_desc_t *memory_map, *runtime_map; | 202 | efi_memory_desc_t *memory_map, *runtime_map; |
| 182 | unsigned long new_fdt_size; | 203 | unsigned long new_fdt_size; |
| 183 | efi_status_t status; | 204 | efi_status_t status; |
| 184 | int runtime_entry_count = 0; | 205 | int runtime_entry_count = 0; |
| 206 | struct efi_boot_memmap map; | ||
| 207 | struct exit_boot_struct priv; | ||
| 208 | |||
| 209 | map.map = &runtime_map; | ||
| 210 | map.map_size = &map_size; | ||
| 211 | map.desc_size = &desc_size; | ||
| 212 | map.desc_ver = &desc_ver; | ||
| 213 | map.key_ptr = &mmap_key; | ||
| 214 | map.buff_size = &buff_size; | ||
| 185 | 215 | ||
| 186 | /* | 216 | /* |
| 187 | * Get a copy of the current memory map that we will use to prepare | 217 | * Get a copy of the current memory map that we will use to prepare |
| @@ -189,8 +219,7 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, | |||
| 189 | * subsequent allocations adding entries, since they could not affect | 219 | * subsequent allocations adding entries, since they could not affect |
| 190 | * the number of EFI_MEMORY_RUNTIME regions. | 220 | * the number of EFI_MEMORY_RUNTIME regions. |
| 191 | */ | 221 | */ |
| 192 | status = efi_get_memory_map(sys_table, &runtime_map, &map_size, | 222 | status = efi_get_memory_map(sys_table, &map); |
| 193 | &desc_size, &desc_ver, &mmap_key); | ||
| 194 | if (status != EFI_SUCCESS) { | 223 | if (status != EFI_SUCCESS) { |
| 195 | pr_efi_err(sys_table, "Unable to retrieve UEFI memory map.\n"); | 224 | pr_efi_err(sys_table, "Unable to retrieve UEFI memory map.\n"); |
| 196 | return status; | 225 | return status; |
| @@ -199,6 +228,7 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, | |||
| 199 | pr_efi(sys_table, | 228 | pr_efi(sys_table, |
| 200 | "Exiting boot services and installing virtual address map...\n"); | 229 | "Exiting boot services and installing virtual address map...\n"); |
| 201 | 230 | ||
| 231 | map.map = &memory_map; | ||
| 202 | /* | 232 | /* |
| 203 | * Estimate size of new FDT, and allocate memory for it. We | 233 | * Estimate size of new FDT, and allocate memory for it. We |
| 204 | * will allocate a bigger buffer if this ends up being too | 234 | * will allocate a bigger buffer if this ends up being too |
| @@ -218,8 +248,7 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, | |||
| 218 | * we can get the memory map key needed for | 248 | * we can get the memory map key needed for |
| 219 | * exit_boot_services(). | 249 | * exit_boot_services(). |
| 220 | */ | 250 | */ |
| 221 | status = efi_get_memory_map(sys_table, &memory_map, &map_size, | 251 | status = efi_get_memory_map(sys_table, &map); |
| 222 | &desc_size, &desc_ver, &mmap_key); | ||
| 223 | if (status != EFI_SUCCESS) | 252 | if (status != EFI_SUCCESS) |
| 224 | goto fail_free_new_fdt; | 253 | goto fail_free_new_fdt; |
| 225 | 254 | ||
| @@ -250,16 +279,11 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, | |||
| 250 | } | 279 | } |
| 251 | } | 280 | } |
| 252 | 281 | ||
| 253 | /* | 282 | sys_table->boottime->free_pool(memory_map); |
| 254 | * Update the memory map with virtual addresses. The function will also | 283 | priv.runtime_map = runtime_map; |
| 255 | * populate @runtime_map with copies of just the EFI_MEMORY_RUNTIME | 284 | priv.runtime_entry_count = &runtime_entry_count; |
| 256 | * entries so that we can pass it straight into SetVirtualAddressMap() | 285 | status = efi_exit_boot_services(sys_table, handle, &map, &priv, |
| 257 | */ | 286 | exit_boot_func); |
| 258 | efi_get_virtmap(memory_map, map_size, desc_size, runtime_map, | ||
| 259 | &runtime_entry_count); | ||
| 260 | |||
| 261 | /* Now we are ready to exit_boot_services.*/ | ||
| 262 | status = sys_table->boottime->exit_boot_services(handle, mmap_key); | ||
| 263 | 287 | ||
| 264 | if (status == EFI_SUCCESS) { | 288 | if (status == EFI_SUCCESS) { |
| 265 | efi_set_virtual_address_map_t *svam; | 289 | efi_set_virtual_address_map_t *svam; |
diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi/libstub/random.c index 53f6d3fe6d86..0c9f58c5ba50 100644 --- a/drivers/firmware/efi/libstub/random.c +++ b/drivers/firmware/efi/libstub/random.c | |||
| @@ -73,12 +73,20 @@ efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg, | |||
| 73 | unsigned long random_seed) | 73 | unsigned long random_seed) |
| 74 | { | 74 | { |
| 75 | unsigned long map_size, desc_size, total_slots = 0, target_slot; | 75 | unsigned long map_size, desc_size, total_slots = 0, target_slot; |
| 76 | unsigned long buff_size; | ||
| 76 | efi_status_t status; | 77 | efi_status_t status; |
| 77 | efi_memory_desc_t *memory_map; | 78 | efi_memory_desc_t *memory_map; |
| 78 | int map_offset; | 79 | int map_offset; |
| 80 | struct efi_boot_memmap map; | ||
| 79 | 81 | ||
| 80 | status = efi_get_memory_map(sys_table_arg, &memory_map, &map_size, | 82 | map.map = &memory_map; |
| 81 | &desc_size, NULL, NULL); | 83 | map.map_size = &map_size; |
| 84 | map.desc_size = &desc_size; | ||
| 85 | map.desc_ver = NULL; | ||
| 86 | map.key_ptr = NULL; | ||
| 87 | map.buff_size = &buff_size; | ||
| 88 | |||
| 89 | status = efi_get_memory_map(sys_table_arg, &map); | ||
| 82 | if (status != EFI_SUCCESS) | 90 | if (status != EFI_SUCCESS) |
| 83 | return status; | 91 | return status; |
| 84 | 92 | ||
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 98dd47a30fc7..24caedb00a7a 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
| @@ -50,6 +50,7 @@ config GPIO_DEVRES | |||
| 50 | config OF_GPIO | 50 | config OF_GPIO |
| 51 | def_bool y | 51 | def_bool y |
| 52 | depends on OF | 52 | depends on OF |
| 53 | depends on HAS_IOMEM | ||
| 53 | 54 | ||
| 54 | config GPIO_ACPI | 55 | config GPIO_ACPI |
| 55 | def_bool y | 56 | def_bool y |
| @@ -188,7 +189,7 @@ config GPIO_EP93XX | |||
| 188 | config GPIO_ETRAXFS | 189 | config GPIO_ETRAXFS |
| 189 | bool "Axis ETRAX FS General I/O" | 190 | bool "Axis ETRAX FS General I/O" |
| 190 | depends on CRIS || COMPILE_TEST | 191 | depends on CRIS || COMPILE_TEST |
| 191 | depends on OF | 192 | depends on OF_GPIO |
| 192 | select GPIO_GENERIC | 193 | select GPIO_GENERIC |
| 193 | select GPIOLIB_IRQCHIP | 194 | select GPIOLIB_IRQCHIP |
| 194 | help | 195 | help |
| @@ -214,7 +215,7 @@ config GPIO_GENERIC_PLATFORM | |||
| 214 | 215 | ||
| 215 | config GPIO_GRGPIO | 216 | config GPIO_GRGPIO |
| 216 | tristate "Aeroflex Gaisler GRGPIO support" | 217 | tristate "Aeroflex Gaisler GRGPIO support" |
| 217 | depends on OF | 218 | depends on OF_GPIO |
| 218 | select GPIO_GENERIC | 219 | select GPIO_GENERIC |
| 219 | select IRQ_DOMAIN | 220 | select IRQ_DOMAIN |
| 220 | help | 221 | help |
| @@ -312,7 +313,7 @@ config GPIO_MPC8XXX | |||
| 312 | config GPIO_MVEBU | 313 | config GPIO_MVEBU |
| 313 | def_bool y | 314 | def_bool y |
| 314 | depends on PLAT_ORION | 315 | depends on PLAT_ORION |
| 315 | depends on OF | 316 | depends on OF_GPIO |
| 316 | select GENERIC_IRQ_CHIP | 317 | select GENERIC_IRQ_CHIP |
| 317 | 318 | ||
| 318 | config GPIO_MXC | 319 | config GPIO_MXC |
| @@ -405,7 +406,7 @@ config GPIO_TEGRA | |||
| 405 | bool "NVIDIA Tegra GPIO support" | 406 | bool "NVIDIA Tegra GPIO support" |
| 406 | default ARCH_TEGRA | 407 | default ARCH_TEGRA |
| 407 | depends on ARCH_TEGRA || COMPILE_TEST | 408 | depends on ARCH_TEGRA || COMPILE_TEST |
| 408 | depends on OF | 409 | depends on OF_GPIO |
| 409 | help | 410 | help |
| 410 | Say yes here to support GPIO pins on NVIDIA Tegra SoCs. | 411 | Say yes here to support GPIO pins on NVIDIA Tegra SoCs. |
| 411 | 412 | ||
| @@ -1099,7 +1100,7 @@ menu "SPI GPIO expanders" | |||
| 1099 | 1100 | ||
| 1100 | config GPIO_74X164 | 1101 | config GPIO_74X164 |
| 1101 | tristate "74x164 serial-in/parallel-out 8-bits shift register" | 1102 | tristate "74x164 serial-in/parallel-out 8-bits shift register" |
| 1102 | depends on OF | 1103 | depends on OF_GPIO |
| 1103 | help | 1104 | help |
| 1104 | Driver for 74x164 compatible serial-in/parallel-out 8-outputs | 1105 | Driver for 74x164 compatible serial-in/parallel-out 8-outputs |
| 1105 | shift registers. This driver can be used to provide access | 1106 | shift registers. This driver can be used to provide access |
| @@ -1130,6 +1131,7 @@ menu "SPI or I2C GPIO expanders" | |||
| 1130 | 1131 | ||
| 1131 | config GPIO_MCP23S08 | 1132 | config GPIO_MCP23S08 |
| 1132 | tristate "Microchip MCP23xxx I/O expander" | 1133 | tristate "Microchip MCP23xxx I/O expander" |
| 1134 | depends on OF_GPIO | ||
| 1133 | select GPIOLIB_IRQCHIP | 1135 | select GPIOLIB_IRQCHIP |
| 1134 | help | 1136 | help |
| 1135 | SPI/I2C driver for Microchip MCP23S08/MCP23S17/MCP23008/MCP23017 | 1137 | SPI/I2C driver for Microchip MCP23S08/MCP23S17/MCP23008/MCP23017 |
diff --git a/drivers/gpio/gpio-max730x.c b/drivers/gpio/gpio-max730x.c index 08807368f007..946d09195598 100644 --- a/drivers/gpio/gpio-max730x.c +++ b/drivers/gpio/gpio-max730x.c | |||
| @@ -192,6 +192,10 @@ int __max730x_probe(struct max7301 *ts) | |||
| 192 | ts->chip.parent = dev; | 192 | ts->chip.parent = dev; |
| 193 | ts->chip.owner = THIS_MODULE; | 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 | * initialize pullups according to platform data and cache the | 200 | * initialize pullups according to platform data and cache the |
| 197 | * register values for later use. | 201 | * register values for later use. |
| @@ -213,10 +217,6 @@ int __max730x_probe(struct max7301 *ts) | |||
| 213 | } | 217 | } |
| 214 | } | 218 | } |
| 215 | 219 | ||
| 216 | ret = gpiochip_add_data(&ts->chip, ts); | ||
| 217 | if (ret) | ||
| 218 | goto exit_destroy; | ||
| 219 | |||
| 220 | return ret; | 220 | return ret; |
| 221 | 221 | ||
| 222 | exit_destroy: | 222 | exit_destroy: |
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c index ac22efc1840e..99d37b56c258 100644 --- a/drivers/gpio/gpio-mcp23s08.c +++ b/drivers/gpio/gpio-mcp23s08.c | |||
| @@ -564,7 +564,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, | |||
| 564 | mcp->chip.direction_output = mcp23s08_direction_output; | 564 | mcp->chip.direction_output = mcp23s08_direction_output; |
| 565 | mcp->chip.set = mcp23s08_set; | 565 | mcp->chip.set = mcp23s08_set; |
| 566 | mcp->chip.dbg_show = mcp23s08_dbg_show; | 566 | mcp->chip.dbg_show = mcp23s08_dbg_show; |
| 567 | #ifdef CONFIG_OF | 567 | #ifdef CONFIG_OF_GPIO |
| 568 | mcp->chip.of_gpio_n_cells = 2; | 568 | mcp->chip.of_gpio_n_cells = 2; |
| 569 | mcp->chip.of_node = dev->of_node; | 569 | mcp->chip.of_node = dev->of_node; |
| 570 | #endif | 570 | #endif |
diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c index 0c99e8fb9af3..8d8ee0ebf14c 100644 --- a/drivers/gpio/gpio-sa1100.c +++ b/drivers/gpio/gpio-sa1100.c | |||
| @@ -155,7 +155,7 @@ static int sa1100_gpio_irqdomain_map(struct irq_domain *d, | |||
| 155 | { | 155 | { |
| 156 | irq_set_chip_and_handler(irq, &sa1100_gpio_irq_chip, | 156 | irq_set_chip_and_handler(irq, &sa1100_gpio_irq_chip, |
| 157 | handle_edge_irq); | 157 | handle_edge_irq); |
| 158 | irq_set_noprobe(irq); | 158 | irq_set_probe(irq); |
| 159 | 159 | ||
| 160 | return 0; | 160 | return 0; |
| 161 | } | 161 | } |
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 75e7b3919ea7..a28feb3edf33 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c | |||
| @@ -16,7 +16,6 @@ | |||
| 16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
| 17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
| 18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
| 19 | #include <linux/io-mapping.h> | ||
| 20 | #include <linux/gpio/consumer.h> | 19 | #include <linux/gpio/consumer.h> |
| 21 | #include <linux/of.h> | 20 | #include <linux/of.h> |
| 22 | #include <linux/of_address.h> | 21 | #include <linux/of_address.h> |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 8c704c86597b..700c56baf2de 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
| @@ -426,6 +426,8 @@ struct amdgpu_mman { | |||
| 426 | 426 | ||
| 427 | /* custom LRU management */ | 427 | /* custom LRU management */ |
| 428 | struct amdgpu_mman_lru log2_size[AMDGPU_TTM_LRU_SIZE]; | 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 | int amdgpu_copy_buffer(struct amdgpu_ring *ring, | 433 | int amdgpu_copy_buffer(struct amdgpu_ring *ring, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c index 983175363b06..fe872b82e619 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | |||
| @@ -321,6 +321,19 @@ bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device * | |||
| 321 | (le16_to_cpu(path->usConnObjectId) & | 321 | (le16_to_cpu(path->usConnObjectId) & |
| 322 | OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT; | 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 | connector_type = | 337 | connector_type = |
| 325 | object_connector_convert[con_obj_id]; | 338 | object_connector_convert[con_obj_id]; |
| 326 | connector_object_id = con_obj_id; | 339 | connector_object_id = con_obj_id; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c index a31d7ef3032c..ec1282af2479 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | |||
| @@ -280,7 +280,7 @@ void amdgpu_ib_pool_fini(struct amdgpu_device *adev) | |||
| 280 | int amdgpu_ib_ring_tests(struct amdgpu_device *adev) | 280 | int amdgpu_ib_ring_tests(struct amdgpu_device *adev) |
| 281 | { | 281 | { |
| 282 | unsigned i; | 282 | unsigned i; |
| 283 | int r; | 283 | int r, ret = 0; |
| 284 | 284 | ||
| 285 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { | 285 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { |
| 286 | struct amdgpu_ring *ring = adev->rings[i]; | 286 | struct amdgpu_ring *ring = adev->rings[i]; |
| @@ -301,10 +301,11 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev) | |||
| 301 | } else { | 301 | } else { |
| 302 | /* still not good, but we can live with it */ | 302 | /* still not good, but we can live with it */ |
| 303 | DRM_ERROR("amdgpu: failed testing IB on ring %d (%d).\n", i, r); | 303 | DRM_ERROR("amdgpu: failed testing IB on ring %d (%d).\n", i, r); |
| 304 | ret = r; | ||
| 304 | } | 305 | } |
| 305 | } | 306 | } |
| 306 | } | 307 | } |
| 307 | return 0; | 308 | return ret; |
| 308 | } | 309 | } |
| 309 | 310 | ||
| 310 | /* | 311 | /* |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 9b61c8ba7aaf..716f2afeb6a9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
| @@ -251,8 +251,8 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, | |||
| 251 | 251 | ||
| 252 | adev = amdgpu_get_adev(bo->bdev); | 252 | adev = amdgpu_get_adev(bo->bdev); |
| 253 | ring = adev->mman.buffer_funcs_ring; | 253 | ring = adev->mman.buffer_funcs_ring; |
| 254 | old_start = old_mem->start << PAGE_SHIFT; | 254 | old_start = (u64)old_mem->start << PAGE_SHIFT; |
| 255 | new_start = new_mem->start << PAGE_SHIFT; | 255 | new_start = (u64)new_mem->start << PAGE_SHIFT; |
| 256 | 256 | ||
| 257 | switch (old_mem->mem_type) { | 257 | switch (old_mem->mem_type) { |
| 258 | case TTM_PL_VRAM: | 258 | case TTM_PL_VRAM: |
| @@ -950,6 +950,8 @@ static struct list_head *amdgpu_ttm_lru_tail(struct ttm_buffer_object *tbo) | |||
| 950 | struct list_head *res = lru->lru[tbo->mem.mem_type]; | 950 | struct list_head *res = lru->lru[tbo->mem.mem_type]; |
| 951 | 951 | ||
| 952 | lru->lru[tbo->mem.mem_type] = &tbo->lru; | 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 | return res; | 956 | return res; |
| 955 | } | 957 | } |
| @@ -960,6 +962,8 @@ static struct list_head *amdgpu_ttm_swap_lru_tail(struct ttm_buffer_object *tbo) | |||
| 960 | struct list_head *res = lru->swap_lru; | 962 | struct list_head *res = lru->swap_lru; |
| 961 | 963 | ||
| 962 | lru->swap_lru = &tbo->swap; | 964 | lru->swap_lru = &tbo->swap; |
| 965 | while ((++lru)->swap_lru == res) | ||
| 966 | lru->swap_lru = &tbo->swap; | ||
| 963 | 967 | ||
| 964 | return res; | 968 | return res; |
| 965 | } | 969 | } |
| @@ -1011,6 +1015,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) | |||
| 1011 | lru->swap_lru = &adev->mman.bdev.glob->swap_lru; | 1015 | lru->swap_lru = &adev->mman.bdev.glob->swap_lru; |
| 1012 | } | 1016 | } |
| 1013 | 1017 | ||
| 1018 | for (j = 0; j < TTM_NUM_MEM_TYPES; ++j) | ||
| 1019 | adev->mman.guard.lru[j] = NULL; | ||
| 1020 | adev->mman.guard.swap_lru = NULL; | ||
| 1021 | |||
| 1014 | adev->mman.initialized = true; | 1022 | adev->mman.initialized = true; |
| 1015 | r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM, | 1023 | r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM, |
| 1016 | adev->mc.real_vram_size >> PAGE_SHIFT); | 1024 | adev->mc.real_vram_size >> PAGE_SHIFT); |
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c index ee6466912497..77fdd9911c3c 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c +++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c | |||
| @@ -52,6 +52,7 @@ static void cik_sdma_set_ring_funcs(struct amdgpu_device *adev); | |||
| 52 | static void cik_sdma_set_irq_funcs(struct amdgpu_device *adev); | 52 | static void cik_sdma_set_irq_funcs(struct amdgpu_device *adev); |
| 53 | static void cik_sdma_set_buffer_funcs(struct amdgpu_device *adev); | 53 | static void cik_sdma_set_buffer_funcs(struct amdgpu_device *adev); |
| 54 | static void cik_sdma_set_vm_pte_funcs(struct amdgpu_device *adev); | 54 | static void cik_sdma_set_vm_pte_funcs(struct amdgpu_device *adev); |
| 55 | static int cik_sdma_soft_reset(void *handle); | ||
| 55 | 56 | ||
| 56 | MODULE_FIRMWARE("radeon/bonaire_sdma.bin"); | 57 | MODULE_FIRMWARE("radeon/bonaire_sdma.bin"); |
| 57 | MODULE_FIRMWARE("radeon/bonaire_sdma1.bin"); | 58 | MODULE_FIRMWARE("radeon/bonaire_sdma1.bin"); |
| @@ -1037,6 +1038,8 @@ static int cik_sdma_resume(void *handle) | |||
| 1037 | { | 1038 | { |
| 1038 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1039 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 1039 | 1040 | ||
| 1041 | cik_sdma_soft_reset(handle); | ||
| 1042 | |||
| 1040 | return cik_sdma_hw_init(adev); | 1043 | return cik_sdma_hw_init(adev); |
| 1041 | } | 1044 | } |
| 1042 | 1045 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c index d869d058ef24..425413fcaf02 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | |||
| @@ -2755,8 +2755,7 @@ static int gfx_v7_0_cp_compute_resume(struct amdgpu_device *adev) | |||
| 2755 | u64 wb_gpu_addr; | 2755 | u64 wb_gpu_addr; |
| 2756 | u32 *buf; | 2756 | u32 *buf; |
| 2757 | struct bonaire_mqd *mqd; | 2757 | struct bonaire_mqd *mqd; |
| 2758 | 2758 | struct amdgpu_ring *ring; | |
| 2759 | gfx_v7_0_cp_compute_enable(adev, true); | ||
| 2760 | 2759 | ||
| 2761 | /* fix up chicken bits */ | 2760 | /* fix up chicken bits */ |
| 2762 | tmp = RREG32(mmCP_CPF_DEBUG); | 2761 | tmp = RREG32(mmCP_CPF_DEBUG); |
| @@ -2791,7 +2790,7 @@ static int gfx_v7_0_cp_compute_resume(struct amdgpu_device *adev) | |||
| 2791 | 2790 | ||
| 2792 | /* init the queues. Just two for now. */ | 2791 | /* init the queues. Just two for now. */ |
| 2793 | for (i = 0; i < adev->gfx.num_compute_rings; i++) { | 2792 | for (i = 0; i < adev->gfx.num_compute_rings; i++) { |
| 2794 | struct amdgpu_ring *ring = &adev->gfx.compute_ring[i]; | 2793 | ring = &adev->gfx.compute_ring[i]; |
| 2795 | 2794 | ||
| 2796 | if (ring->mqd_obj == NULL) { | 2795 | if (ring->mqd_obj == NULL) { |
| 2797 | r = amdgpu_bo_create(adev, | 2796 | r = amdgpu_bo_create(adev, |
| @@ -2970,6 +2969,13 @@ static int gfx_v7_0_cp_compute_resume(struct amdgpu_device *adev) | |||
| 2970 | amdgpu_bo_unreserve(ring->mqd_obj); | 2969 | amdgpu_bo_unreserve(ring->mqd_obj); |
| 2971 | 2970 | ||
| 2972 | ring->ready = true; | 2971 | ring->ready = true; |
| 2972 | } | ||
| 2973 | |||
| 2974 | gfx_v7_0_cp_compute_enable(adev, true); | ||
| 2975 | |||
| 2976 | for (i = 0; i < adev->gfx.num_compute_rings; i++) { | ||
| 2977 | ring = &adev->gfx.compute_ring[i]; | ||
| 2978 | |||
| 2973 | r = amdgpu_ring_test_ring(ring); | 2979 | r = amdgpu_ring_test_ring(ring); |
| 2974 | if (r) | 2980 | if (r) |
| 2975 | ring->ready = false; | 2981 | ring->ready = false; |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c index 1351c7e834a2..a64715d90503 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | |||
| @@ -714,7 +714,7 @@ static int sdma_v2_4_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
| 714 | DRM_ERROR("amdgpu: IB test timed out\n"); | 714 | DRM_ERROR("amdgpu: IB test timed out\n"); |
| 715 | r = -ETIMEDOUT; | 715 | r = -ETIMEDOUT; |
| 716 | goto err1; | 716 | goto err1; |
| 717 | } else if (r) { | 717 | } else if (r < 0) { |
| 718 | DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r); | 718 | DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r); |
| 719 | goto err1; | 719 | goto err1; |
| 720 | } | 720 | } |
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c index ef312bb75fda..963a24d46a93 100644 --- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | |||
| @@ -405,7 +405,7 @@ void amd_sched_job_recovery(struct amd_gpu_scheduler *sched) | |||
| 405 | spin_lock(&sched->job_list_lock); | 405 | spin_lock(&sched->job_list_lock); |
| 406 | s_job = list_first_entry_or_null(&sched->ring_mirror_list, | 406 | s_job = list_first_entry_or_null(&sched->ring_mirror_list, |
| 407 | struct amd_sched_job, node); | 407 | struct amd_sched_job, node); |
| 408 | if (s_job) | 408 | if (s_job && sched->timeout != MAX_SCHEDULE_TIMEOUT) |
| 409 | schedule_delayed_work(&s_job->work_tdr, sched->timeout); | 409 | schedule_delayed_work(&s_job->work_tdr, sched->timeout); |
| 410 | 410 | ||
| 411 | list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) { | 411 | list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) { |
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c index a978381ef95b..9b17a66cf0e1 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | |||
| @@ -387,7 +387,7 @@ void atmel_hlcdc_crtc_irq(struct drm_crtc *c) | |||
| 387 | atmel_hlcdc_crtc_finish_page_flip(drm_crtc_to_atmel_hlcdc_crtc(c)); | 387 | atmel_hlcdc_crtc_finish_page_flip(drm_crtc_to_atmel_hlcdc_crtc(c)); |
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | void atmel_hlcdc_crtc_reset(struct drm_crtc *crtc) | 390 | static void atmel_hlcdc_crtc_reset(struct drm_crtc *crtc) |
| 391 | { | 391 | { |
| 392 | struct atmel_hlcdc_crtc_state *state; | 392 | struct atmel_hlcdc_crtc_state *state; |
| 393 | 393 | ||
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c index 016c191221f3..52c527f6642a 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | |||
| @@ -320,19 +320,19 @@ atmel_hlcdc_plane_update_pos_and_size(struct atmel_hlcdc_plane *plane, | |||
| 320 | u32 *coeff_tab = heo_upscaling_ycoef; | 320 | u32 *coeff_tab = heo_upscaling_ycoef; |
| 321 | u32 max_memsize; | 321 | u32 max_memsize; |
| 322 | 322 | ||
| 323 | if (state->crtc_w < state->src_w) | 323 | if (state->crtc_h < state->src_h) |
| 324 | coeff_tab = heo_downscaling_ycoef; | 324 | coeff_tab = heo_downscaling_ycoef; |
| 325 | for (i = 0; i < ARRAY_SIZE(heo_upscaling_ycoef); i++) | 325 | for (i = 0; i < ARRAY_SIZE(heo_upscaling_ycoef); i++) |
| 326 | atmel_hlcdc_layer_update_cfg(&plane->layer, | 326 | atmel_hlcdc_layer_update_cfg(&plane->layer, |
| 327 | 33 + i, | 327 | 33 + i, |
| 328 | 0xffffffff, | 328 | 0xffffffff, |
| 329 | coeff_tab[i]); | 329 | coeff_tab[i]); |
| 330 | factor = ((8 * 256 * state->src_w) - (256 * 4)) / | 330 | factor = ((8 * 256 * state->src_h) - (256 * 4)) / |
| 331 | state->crtc_w; | 331 | state->crtc_h; |
| 332 | factor++; | 332 | factor++; |
| 333 | max_memsize = ((factor * state->crtc_w) + (256 * 4)) / | 333 | max_memsize = ((factor * state->crtc_h) + (256 * 4)) / |
| 334 | 2048; | 334 | 2048; |
| 335 | if (max_memsize > state->src_w) | 335 | if (max_memsize > state->src_h) |
| 336 | factor--; | 336 | factor--; |
| 337 | factor_reg |= (factor << 16) | 0x80000000; | 337 | factor_reg |= (factor << 16) | 0x80000000; |
| 338 | } | 338 | } |
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index fa3930757972..2a3ded44cf2a 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c | |||
| @@ -475,7 +475,7 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, | |||
| 475 | val, | 475 | val, |
| 476 | -1, | 476 | -1, |
| 477 | &replaced); | 477 | &replaced); |
| 478 | state->color_mgmt_changed = replaced; | 478 | state->color_mgmt_changed |= replaced; |
| 479 | return ret; | 479 | return ret; |
| 480 | } else if (property == config->ctm_property) { | 480 | } else if (property == config->ctm_property) { |
| 481 | ret = drm_atomic_replace_property_blob_from_id(crtc, | 481 | ret = drm_atomic_replace_property_blob_from_id(crtc, |
| @@ -483,7 +483,7 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, | |||
| 483 | val, | 483 | val, |
| 484 | sizeof(struct drm_color_ctm), | 484 | sizeof(struct drm_color_ctm), |
| 485 | &replaced); | 485 | &replaced); |
| 486 | state->color_mgmt_changed = replaced; | 486 | state->color_mgmt_changed |= replaced; |
| 487 | return ret; | 487 | return ret; |
| 488 | } else if (property == config->gamma_lut_property) { | 488 | } else if (property == config->gamma_lut_property) { |
| 489 | ret = drm_atomic_replace_property_blob_from_id(crtc, | 489 | ret = drm_atomic_replace_property_blob_from_id(crtc, |
| @@ -491,7 +491,7 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, | |||
| 491 | val, | 491 | val, |
| 492 | -1, | 492 | -1, |
| 493 | &replaced); | 493 | &replaced); |
| 494 | state->color_mgmt_changed = replaced; | 494 | state->color_mgmt_changed |= replaced; |
| 495 | return ret; | 495 | return ret; |
| 496 | } else if (crtc->funcs->atomic_set_property) | 496 | } else if (crtc->funcs->atomic_set_property) |
| 497 | return crtc->funcs->atomic_set_property(crtc, state, property, val); | 497 | return crtc->funcs->atomic_set_property(crtc, state, property, val); |
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index b1dbb60af99f..ddebe54cd5ca 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
| @@ -5404,6 +5404,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, | |||
| 5404 | struct drm_pending_vblank_event *e = NULL; | 5404 | struct drm_pending_vblank_event *e = NULL; |
| 5405 | int ret = -EINVAL; | 5405 | int ret = -EINVAL; |
| 5406 | 5406 | ||
| 5407 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) | ||
| 5408 | return -EINVAL; | ||
| 5409 | |||
| 5407 | if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS || | 5410 | if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS || |
| 5408 | page_flip->reserved != 0) | 5411 | page_flip->reserved != 0) |
| 5409 | return -EINVAL; | 5412 | return -EINVAL; |
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 95ddd56b89f0..5de36d8dcc68 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c | |||
| @@ -1281,6 +1281,11 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 1281 | 1281 | ||
| 1282 | intel_runtime_pm_enable(dev_priv); | 1282 | intel_runtime_pm_enable(dev_priv); |
| 1283 | 1283 | ||
| 1284 | /* Everything is in place, we can now relax! */ | ||
| 1285 | DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n", | ||
| 1286 | driver.name, driver.major, driver.minor, driver.patchlevel, | ||
| 1287 | driver.date, pci_name(pdev), dev_priv->drm.primary->index); | ||
| 1288 | |||
| 1284 | intel_runtime_pm_put(dev_priv); | 1289 | intel_runtime_pm_put(dev_priv); |
| 1285 | 1290 | ||
| 1286 | return 0; | 1291 | return 0; |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 20fe9d52e256..f68c78918d63 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
| @@ -882,11 +882,12 @@ struct i915_gem_context { | |||
| 882 | 882 | ||
| 883 | struct i915_ctx_hang_stats hang_stats; | 883 | struct i915_ctx_hang_stats hang_stats; |
| 884 | 884 | ||
| 885 | /* Unique identifier for this context, used by the hw for tracking */ | ||
| 886 | unsigned long flags; | 885 | unsigned long flags; |
| 887 | #define CONTEXT_NO_ZEROMAP BIT(0) | 886 | #define CONTEXT_NO_ZEROMAP BIT(0) |
| 888 | #define CONTEXT_NO_ERROR_CAPTURE BIT(1) | 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 | u32 user_handle; | 891 | u32 user_handle; |
| 891 | 892 | ||
| 892 | u32 ggtt_alignment; | 893 | u32 ggtt_alignment; |
| @@ -1963,6 +1964,13 @@ struct drm_i915_private { | |||
| 1963 | struct i915_suspend_saved_registers regfile; | 1964 | struct i915_suspend_saved_registers regfile; |
| 1964 | struct vlv_s0ix_state vlv_s0ix_state; | 1965 | struct vlv_s0ix_state vlv_s0ix_state; |
| 1965 | 1966 | ||
| 1967 | enum { | ||
| 1968 | I915_SKL_SAGV_UNKNOWN = 0, | ||
| 1969 | I915_SKL_SAGV_DISABLED, | ||
| 1970 | I915_SKL_SAGV_ENABLED, | ||
| 1971 | I915_SKL_SAGV_NOT_CONTROLLED | ||
| 1972 | } skl_sagv_status; | ||
| 1973 | |||
| 1966 | struct { | 1974 | struct { |
| 1967 | /* | 1975 | /* |
| 1968 | * Raw watermark latency values: | 1976 | * Raw watermark latency values: |
| @@ -3591,6 +3599,7 @@ int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle); | |||
| 3591 | /* belongs in i915_gem_gtt.h */ | 3599 | /* belongs in i915_gem_gtt.h */ |
| 3592 | static inline void i915_gem_chipset_flush(struct drm_i915_private *dev_priv) | 3600 | static inline void i915_gem_chipset_flush(struct drm_i915_private *dev_priv) |
| 3593 | { | 3601 | { |
| 3602 | wmb(); | ||
| 3594 | if (INTEL_GEN(dev_priv) < 6) | 3603 | if (INTEL_GEN(dev_priv) < 6) |
| 3595 | intel_gtt_chipset_flush(); | 3604 | intel_gtt_chipset_flush(); |
| 3596 | } | 3605 | } |
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 1978633e7549..b35e5b6475b2 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c | |||
| @@ -943,8 +943,6 @@ i915_gem_execbuffer_move_to_gpu(struct drm_i915_gem_request *req, | |||
| 943 | { | 943 | { |
| 944 | const unsigned other_rings = ~intel_engine_flag(req->engine); | 944 | const unsigned other_rings = ~intel_engine_flag(req->engine); |
| 945 | struct i915_vma *vma; | 945 | struct i915_vma *vma; |
| 946 | uint32_t flush_domains = 0; | ||
| 947 | bool flush_chipset = false; | ||
| 948 | int ret; | 946 | int ret; |
| 949 | 947 | ||
| 950 | list_for_each_entry(vma, vmas, exec_list) { | 948 | list_for_each_entry(vma, vmas, exec_list) { |
| @@ -957,16 +955,11 @@ i915_gem_execbuffer_move_to_gpu(struct drm_i915_gem_request *req, | |||
| 957 | } | 955 | } |
| 958 | 956 | ||
| 959 | if (obj->base.write_domain & I915_GEM_DOMAIN_CPU) | 957 | if (obj->base.write_domain & I915_GEM_DOMAIN_CPU) |
| 960 | flush_chipset |= i915_gem_clflush_object(obj, false); | 958 | i915_gem_clflush_object(obj, false); |
| 961 | |||
| 962 | flush_domains |= obj->base.write_domain; | ||
| 963 | } | 959 | } |
| 964 | 960 | ||
| 965 | if (flush_chipset) | 961 | /* Unconditionally flush any chipset caches (for streaming writes). */ |
| 966 | i915_gem_chipset_flush(req->engine->i915); | 962 | i915_gem_chipset_flush(req->engine->i915); |
| 967 | |||
| 968 | if (flush_domains & I915_GEM_DOMAIN_GTT) | ||
| 969 | wmb(); | ||
| 970 | 963 | ||
| 971 | /* Unconditionally invalidate gpu caches and ensure that we do flush | 964 | /* Unconditionally invalidate gpu caches and ensure that we do flush |
| 972 | * any residual writes from the previous batch. | 965 | * any residual writes from the previous batch. |
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 7a30af79d799..f38ceffd82c3 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c | |||
| @@ -122,8 +122,11 @@ int intel_sanitize_enable_ppgtt(struct drm_i915_private *dev_priv, | |||
| 122 | has_full_48bit_ppgtt = | 122 | has_full_48bit_ppgtt = |
| 123 | IS_BROADWELL(dev_priv) || INTEL_GEN(dev_priv) >= 9; | 123 | IS_BROADWELL(dev_priv) || INTEL_GEN(dev_priv) >= 9; |
| 124 | 124 | ||
| 125 | if (intel_vgpu_active(dev_priv)) | 125 | if (intel_vgpu_active(dev_priv)) { |
| 126 | has_full_ppgtt = false; /* emulation is too hard */ | 126 | /* emulation is too hard */ |
| 127 | has_full_ppgtt = false; | ||
| 128 | has_full_48bit_ppgtt = false; | ||
| 129 | } | ||
| 127 | 130 | ||
| 128 | if (!has_aliasing_ppgtt) | 131 | if (!has_aliasing_ppgtt) |
| 129 | return 0; | 132 | return 0; |
| @@ -158,7 +161,7 @@ int intel_sanitize_enable_ppgtt(struct drm_i915_private *dev_priv, | |||
| 158 | return 0; | 161 | return 0; |
| 159 | } | 162 | } |
| 160 | 163 | ||
| 161 | if (INTEL_GEN(dev_priv) >= 8 && i915.enable_execlists) | 164 | if (INTEL_GEN(dev_priv) >= 8 && i915.enable_execlists && has_full_ppgtt) |
| 162 | return has_full_48bit_ppgtt ? 3 : 2; | 165 | return has_full_48bit_ppgtt ? 3 : 2; |
| 163 | else | 166 | else |
| 164 | return has_aliasing_ppgtt ? 1 : 0; | 167 | return has_aliasing_ppgtt ? 1 : 0; |
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 5c06413ae0e6..bf2cad3f9e1f 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h | |||
| @@ -7145,6 +7145,15 @@ enum { | |||
| 7145 | 7145 | ||
| 7146 | #define GEN6_PCODE_MAILBOX _MMIO(0x138124) | 7146 | #define GEN6_PCODE_MAILBOX _MMIO(0x138124) |
| 7147 | #define GEN6_PCODE_READY (1<<31) | 7147 | #define GEN6_PCODE_READY (1<<31) |
| 7148 | #define GEN6_PCODE_ERROR_MASK 0xFF | ||
| 7149 | #define GEN6_PCODE_SUCCESS 0x0 | ||
| 7150 | #define GEN6_PCODE_ILLEGAL_CMD 0x1 | ||
| 7151 | #define GEN6_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE 0x2 | ||
| 7152 | #define GEN6_PCODE_TIMEOUT 0x3 | ||
| 7153 | #define GEN6_PCODE_UNIMPLEMENTED_CMD 0xFF | ||
| 7154 | #define GEN7_PCODE_TIMEOUT 0x2 | ||
| 7155 | #define GEN7_PCODE_ILLEGAL_DATA 0x3 | ||
| 7156 | #define GEN7_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE 0x10 | ||
| 7148 | #define GEN6_PCODE_WRITE_RC6VIDS 0x4 | 7157 | #define GEN6_PCODE_WRITE_RC6VIDS 0x4 |
| 7149 | #define GEN6_PCODE_READ_RC6VIDS 0x5 | 7158 | #define GEN6_PCODE_READ_RC6VIDS 0x5 |
| 7150 | #define GEN6_ENCODE_RC6_VID(mv) (((mv) - 245) / 5) | 7159 | #define GEN6_ENCODE_RC6_VID(mv) (((mv) - 245) / 5) |
| @@ -7166,6 +7175,10 @@ enum { | |||
| 7166 | #define HSW_PCODE_DE_WRITE_FREQ_REQ 0x17 | 7175 | #define HSW_PCODE_DE_WRITE_FREQ_REQ 0x17 |
| 7167 | #define DISPLAY_IPS_CONTROL 0x19 | 7176 | #define DISPLAY_IPS_CONTROL 0x19 |
| 7168 | #define HSW_PCODE_DYNAMIC_DUTY_CYCLE_CONTROL 0x1A | 7177 | #define HSW_PCODE_DYNAMIC_DUTY_CYCLE_CONTROL 0x1A |
| 7178 | #define GEN9_PCODE_SAGV_CONTROL 0x21 | ||
| 7179 | #define GEN9_SAGV_DISABLE 0x0 | ||
| 7180 | #define GEN9_SAGV_IS_DISABLED 0x1 | ||
| 7181 | #define GEN9_SAGV_ENABLE 0x3 | ||
| 7169 | #define GEN6_PCODE_DATA _MMIO(0x138128) | 7182 | #define GEN6_PCODE_DATA _MMIO(0x138128) |
| 7170 | #define GEN6_PCODE_FREQ_IA_RATIO_SHIFT 8 | 7183 | #define GEN6_PCODE_FREQ_IA_RATIO_SHIFT 8 |
| 7171 | #define GEN6_PCODE_FREQ_RING_RATIO_SHIFT 16 | 7184 | #define GEN6_PCODE_FREQ_RING_RATIO_SHIFT 16 |
diff --git a/drivers/gpu/drm/i915/i915_vgpu.c b/drivers/gpu/drm/i915/i915_vgpu.c index f6acb5a0e701..b81cfb3b22ec 100644 --- a/drivers/gpu/drm/i915/i915_vgpu.c +++ b/drivers/gpu/drm/i915/i915_vgpu.c | |||
| @@ -65,9 +65,6 @@ void i915_check_vgpu(struct drm_i915_private *dev_priv) | |||
| 65 | 65 | ||
| 66 | BUILD_BUG_ON(sizeof(struct vgt_if) != VGT_PVINFO_SIZE); | 66 | BUILD_BUG_ON(sizeof(struct vgt_if) != VGT_PVINFO_SIZE); |
| 67 | 67 | ||
| 68 | if (!IS_HASWELL(dev_priv)) | ||
| 69 | return; | ||
| 70 | |||
| 71 | magic = __raw_i915_read64(dev_priv, vgtif_reg(magic)); | 68 | magic = __raw_i915_read64(dev_priv, vgtif_reg(magic)); |
| 72 | if (magic != VGT_MAGIC) | 69 | if (magic != VGT_MAGIC) |
| 73 | return; | 70 | return; |
diff --git a/drivers/gpu/drm/i915/intel_csr.c b/drivers/gpu/drm/i915/intel_csr.c index 3edb9580928e..c3b33a10c15c 100644 --- a/drivers/gpu/drm/i915/intel_csr.c +++ b/drivers/gpu/drm/i915/intel_csr.c | |||
| @@ -41,15 +41,15 @@ | |||
| 41 | * be moved to FW_FAILED. | 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 | MODULE_FIRMWARE(I915_CSR_KBL); | 45 | MODULE_FIRMWARE(I915_CSR_KBL); |
| 46 | #define KBL_CSR_VERSION_REQUIRED CSR_VERSION(1, 1) | 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 | MODULE_FIRMWARE(I915_CSR_SKL); | 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 | MODULE_FIRMWARE(I915_CSR_BXT); | 53 | MODULE_FIRMWARE(I915_CSR_BXT); |
| 54 | #define BXT_CSR_VERSION_REQUIRED CSR_VERSION(1, 7) | 54 | #define BXT_CSR_VERSION_REQUIRED CSR_VERSION(1, 7) |
| 55 | 55 | ||
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 2a751b6e0253..175595fc3e45 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
| @@ -13759,6 +13759,13 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state) | |||
| 13759 | intel_state->cdclk_pll_vco != dev_priv->cdclk_pll.vco)) | 13759 | intel_state->cdclk_pll_vco != dev_priv->cdclk_pll.vco)) |
| 13760 | dev_priv->display.modeset_commit_cdclk(state); | 13760 | dev_priv->display.modeset_commit_cdclk(state); |
| 13761 | 13761 | ||
| 13762 | /* | ||
| 13763 | * SKL workaround: bspec recommends we disable the SAGV when we | ||
| 13764 | * have more then one pipe enabled | ||
| 13765 | */ | ||
| 13766 | if (IS_SKYLAKE(dev_priv) && !skl_can_enable_sagv(state)) | ||
| 13767 | skl_disable_sagv(dev_priv); | ||
| 13768 | |||
| 13762 | intel_modeset_verify_disabled(dev); | 13769 | intel_modeset_verify_disabled(dev); |
| 13763 | } | 13770 | } |
| 13764 | 13771 | ||
| @@ -13832,6 +13839,10 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state) | |||
| 13832 | intel_modeset_verify_crtc(crtc, old_crtc_state, crtc->state); | 13839 | intel_modeset_verify_crtc(crtc, old_crtc_state, crtc->state); |
| 13833 | } | 13840 | } |
| 13834 | 13841 | ||
| 13842 | if (IS_SKYLAKE(dev_priv) && intel_state->modeset && | ||
| 13843 | skl_can_enable_sagv(state)) | ||
| 13844 | skl_enable_sagv(dev_priv); | ||
| 13845 | |||
| 13835 | drm_atomic_helper_commit_hw_done(state); | 13846 | drm_atomic_helper_commit_hw_done(state); |
| 13836 | 13847 | ||
| 13837 | if (intel_state->modeset) | 13848 | if (intel_state->modeset) |
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index cc937a19b1ba..ff399b9a5c1f 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
| @@ -1716,6 +1716,9 @@ void ilk_wm_get_hw_state(struct drm_device *dev); | |||
| 1716 | void skl_wm_get_hw_state(struct drm_device *dev); | 1716 | void skl_wm_get_hw_state(struct drm_device *dev); |
| 1717 | void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv, | 1717 | void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv, |
| 1718 | struct skl_ddb_allocation *ddb /* out */); | 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 | uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config); | 1722 | uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config); |
| 1720 | bool ilk_disable_lp_wm(struct drm_device *dev); | 1723 | bool ilk_disable_lp_wm(struct drm_device *dev); |
| 1721 | int sanitize_rc6_option(struct drm_i915_private *dev_priv, int enable_rc6); | 1724 | int sanitize_rc6_option(struct drm_i915_private *dev_priv, int enable_rc6); |
diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c index 47bdf9dad0d3..b9e5a63a7c9e 100644 --- a/drivers/gpu/drm/i915/intel_dvo.c +++ b/drivers/gpu/drm/i915/intel_dvo.c | |||
| @@ -554,7 +554,6 @@ void intel_dvo_init(struct drm_device *dev) | |||
| 554 | return; | 554 | return; |
| 555 | } | 555 | } |
| 556 | 556 | ||
| 557 | drm_encoder_cleanup(&intel_encoder->base); | ||
| 558 | kfree(intel_dvo); | 557 | kfree(intel_dvo); |
| 559 | kfree(intel_connector); | 558 | kfree(intel_connector); |
| 560 | } | 559 | } |
diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c index adca262d591a..7acbbbf97833 100644 --- a/drivers/gpu/drm/i915/intel_opregion.c +++ b/drivers/gpu/drm/i915/intel_opregion.c | |||
| @@ -1047,6 +1047,23 @@ err_out: | |||
| 1047 | return err; | 1047 | return err; |
| 1048 | } | 1048 | } |
| 1049 | 1049 | ||
| 1050 | static int intel_use_opregion_panel_type_callback(const struct dmi_system_id *id) | ||
| 1051 | { | ||
| 1052 | DRM_INFO("Using panel type from OpRegion on %s\n", id->ident); | ||
| 1053 | return 1; | ||
| 1054 | } | ||
| 1055 | |||
| 1056 | static const struct dmi_system_id intel_use_opregion_panel_type[] = { | ||
| 1057 | { | ||
| 1058 | .callback = intel_use_opregion_panel_type_callback, | ||
| 1059 | .ident = "Conrac GmbH IX45GM2", | ||
| 1060 | .matches = {DMI_MATCH(DMI_SYS_VENDOR, "Conrac GmbH"), | ||
| 1061 | DMI_MATCH(DMI_PRODUCT_NAME, "IX45GM2"), | ||
| 1062 | }, | ||
| 1063 | }, | ||
| 1064 | { } | ||
| 1065 | }; | ||
| 1066 | |||
| 1050 | int | 1067 | int |
| 1051 | intel_opregion_get_panel_type(struct drm_i915_private *dev_priv) | 1068 | intel_opregion_get_panel_type(struct drm_i915_private *dev_priv) |
| 1052 | { | 1069 | { |
| @@ -1073,6 +1090,16 @@ intel_opregion_get_panel_type(struct drm_i915_private *dev_priv) | |||
| 1073 | } | 1090 | } |
| 1074 | 1091 | ||
| 1075 | /* | 1092 | /* |
| 1093 | * So far we know that some machined must use it, others must not use it. | ||
| 1094 | * There doesn't seem to be any way to determine which way to go, except | ||
| 1095 | * via a quirk list :( | ||
| 1096 | */ | ||
| 1097 | if (!dmi_check_system(intel_use_opregion_panel_type)) { | ||
| 1098 | DRM_DEBUG_KMS("Ignoring OpRegion panel type (%d)\n", ret - 1); | ||
| 1099 | return -ENODEV; | ||
| 1100 | } | ||
| 1101 | |||
| 1102 | /* | ||
| 1076 | * FIXME On Dell XPS 13 9350 the OpRegion panel type (0) gives us | 1103 | * FIXME On Dell XPS 13 9350 the OpRegion panel type (0) gives us |
| 1077 | * low vswing for eDP, whereas the VBT panel type (2) gives us normal | 1104 | * low vswing for eDP, whereas the VBT panel type (2) gives us normal |
| 1078 | * vswing instead. Low vswing results in some display flickers, so | 1105 | * vswing instead. Low vswing results in some display flickers, so |
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index d5deb58a2128..2d2481392824 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c | |||
| @@ -2852,6 +2852,7 @@ bool ilk_disable_lp_wm(struct drm_device *dev) | |||
| 2852 | 2852 | ||
| 2853 | #define SKL_DDB_SIZE 896 /* in blocks */ | 2853 | #define SKL_DDB_SIZE 896 /* in blocks */ |
| 2854 | #define BXT_DDB_SIZE 512 | 2854 | #define BXT_DDB_SIZE 512 |
| 2855 | #define SKL_SAGV_BLOCK_TIME 30 /* µs */ | ||
| 2855 | 2856 | ||
| 2856 | /* | 2857 | /* |
| 2857 | * Return the index of a plane in the SKL DDB and wm result arrays. Primary | 2858 | * Return the index of a plane in the SKL DDB and wm result arrays. Primary |
| @@ -2875,6 +2876,153 @@ skl_wm_plane_id(const struct intel_plane *plane) | |||
| 2875 | } | 2876 | } |
| 2876 | } | 2877 | } |
| 2877 | 2878 | ||
| 2879 | /* | ||
| 2880 | * SAGV dynamically adjusts the system agent voltage and clock frequencies | ||
| 2881 | * depending on power and performance requirements. The display engine access | ||
| 2882 | * to system memory is blocked during the adjustment time. Because of the | ||
| 2883 | * blocking time, having this enabled can cause full system hangs and/or pipe | ||
| 2884 | * underruns if we don't meet all of the following requirements: | ||
| 2885 | * | ||
| 2886 | * - <= 1 pipe enabled | ||
| 2887 | * - All planes can enable watermarks for latencies >= SAGV engine block time | ||
| 2888 | * - We're not using an interlaced display configuration | ||
| 2889 | */ | ||
| 2890 | int | ||
| 2891 | skl_enable_sagv(struct drm_i915_private *dev_priv) | ||
| 2892 | { | ||
| 2893 | int ret; | ||
| 2894 | |||
| 2895 | if (dev_priv->skl_sagv_status == I915_SKL_SAGV_NOT_CONTROLLED || | ||
| 2896 | dev_priv->skl_sagv_status == I915_SKL_SAGV_ENABLED) | ||
| 2897 | return 0; | ||
| 2898 | |||
| 2899 | DRM_DEBUG_KMS("Enabling the SAGV\n"); | ||
| 2900 | mutex_lock(&dev_priv->rps.hw_lock); | ||
| 2901 | |||
| 2902 | ret = sandybridge_pcode_write(dev_priv, GEN9_PCODE_SAGV_CONTROL, | ||
| 2903 | GEN9_SAGV_ENABLE); | ||
| 2904 | |||
| 2905 | /* We don't need to wait for the SAGV when enabling */ | ||
| 2906 | mutex_unlock(&dev_priv->rps.hw_lock); | ||
| 2907 | |||
| 2908 | /* | ||
| 2909 | * Some skl systems, pre-release machines in particular, | ||
| 2910 | * don't actually have an SAGV. | ||
| 2911 | */ | ||
| 2912 | if (ret == -ENXIO) { | ||
| 2913 | DRM_DEBUG_DRIVER("No SAGV found on system, ignoring\n"); | ||
| 2914 | dev_priv->skl_sagv_status = I915_SKL_SAGV_NOT_CONTROLLED; | ||
| 2915 | return 0; | ||
| 2916 | } else if (ret < 0) { | ||
| 2917 | DRM_ERROR("Failed to enable the SAGV\n"); | ||
| 2918 | return ret; | ||
| 2919 | } | ||
| 2920 | |||
| 2921 | dev_priv->skl_sagv_status = I915_SKL_SAGV_ENABLED; | ||
| 2922 | return 0; | ||
| 2923 | } | ||
| 2924 | |||
| 2925 | static int | ||
| 2926 | skl_do_sagv_disable(struct drm_i915_private *dev_priv) | ||
| 2927 | { | ||
| 2928 | int ret; | ||
| 2929 | uint32_t temp = GEN9_SAGV_DISABLE; | ||
| 2930 | |||
| 2931 | ret = sandybridge_pcode_read(dev_priv, GEN9_PCODE_SAGV_CONTROL, | ||
| 2932 | &temp); | ||
| 2933 | if (ret) | ||
| 2934 | return ret; | ||
| 2935 | else | ||
| 2936 | return temp & GEN9_SAGV_IS_DISABLED; | ||
| 2937 | } | ||
| 2938 | |||
| 2939 | int | ||
| 2940 | skl_disable_sagv(struct drm_i915_private *dev_priv) | ||
| 2941 | { | ||
| 2942 | int ret, result; | ||
| 2943 | |||
| 2944 | if (dev_priv->skl_sagv_status == I915_SKL_SAGV_NOT_CONTROLLED || | ||
| 2945 | dev_priv->skl_sagv_status == I915_SKL_SAGV_DISABLED) | ||
| 2946 | return 0; | ||
| 2947 | |||
| 2948 | DRM_DEBUG_KMS("Disabling the SAGV\n"); | ||
| 2949 | mutex_lock(&dev_priv->rps.hw_lock); | ||
| 2950 | |||
| 2951 | /* bspec says to keep retrying for at least 1 ms */ | ||
| 2952 | ret = wait_for(result = skl_do_sagv_disable(dev_priv), 1); | ||
| 2953 | mutex_unlock(&dev_priv->rps.hw_lock); | ||
| 2954 | |||
| 2955 | if (ret == -ETIMEDOUT) { | ||
| 2956 | DRM_ERROR("Request to disable SAGV timed out\n"); | ||
| 2957 | return -ETIMEDOUT; | ||
| 2958 | } | ||
| 2959 | |||
| 2960 | /* | ||
| 2961 | * Some skl systems, pre-release machines in particular, | ||
| 2962 | * don't actually have an SAGV. | ||
| 2963 | */ | ||
| 2964 | if (result == -ENXIO) { | ||
| 2965 | DRM_DEBUG_DRIVER("No SAGV found on system, ignoring\n"); | ||
| 2966 | dev_priv->skl_sagv_status = I915_SKL_SAGV_NOT_CONTROLLED; | ||
| 2967 | return 0; | ||
| 2968 | } else if (result < 0) { | ||
| 2969 | DRM_ERROR("Failed to disable the SAGV\n"); | ||
| 2970 | return result; | ||
| 2971 | } | ||
| 2972 | |||
| 2973 | dev_priv->skl_sagv_status = I915_SKL_SAGV_DISABLED; | ||
| 2974 | return 0; | ||
| 2975 | } | ||
| 2976 | |||
| 2977 | bool skl_can_enable_sagv(struct drm_atomic_state *state) | ||
| 2978 | { | ||
| 2979 | struct drm_device *dev = state->dev; | ||
| 2980 | struct drm_i915_private *dev_priv = to_i915(dev); | ||
| 2981 | struct intel_atomic_state *intel_state = to_intel_atomic_state(state); | ||
| 2982 | struct drm_crtc *crtc; | ||
| 2983 | enum pipe pipe; | ||
| 2984 | int level, plane; | ||
| 2985 | |||
| 2986 | /* | ||
| 2987 | * SKL workaround: bspec recommends we disable the SAGV when we have | ||
| 2988 | * more then one pipe enabled | ||
| 2989 | * | ||
| 2990 | * If there are no active CRTCs, no additional checks need be performed | ||
| 2991 | */ | ||
| 2992 | if (hweight32(intel_state->active_crtcs) == 0) | ||
| 2993 | return true; | ||
| 2994 | else if (hweight32(intel_state->active_crtcs) > 1) | ||
| 2995 | return false; | ||
| 2996 | |||
| 2997 | /* Since we're now guaranteed to only have one active CRTC... */ | ||
| 2998 | pipe = ffs(intel_state->active_crtcs) - 1; | ||
| 2999 | crtc = dev_priv->pipe_to_crtc_mapping[pipe]; | ||
| 3000 | |||
| 3001 | if (crtc->state->mode.flags & DRM_MODE_FLAG_INTERLACE) | ||
| 3002 | return false; | ||
| 3003 | |||
| 3004 | for_each_plane(dev_priv, pipe, plane) { | ||
| 3005 | /* Skip this plane if it's not enabled */ | ||
| 3006 | if (intel_state->wm_results.plane[pipe][plane][0] == 0) | ||
| 3007 | continue; | ||
| 3008 | |||
| 3009 | /* Find the highest enabled wm level for this plane */ | ||
| 3010 | for (level = ilk_wm_max_level(dev); | ||
| 3011 | intel_state->wm_results.plane[pipe][plane][level] == 0; --level) | ||
| 3012 | { } | ||
| 3013 | |||
| 3014 | /* | ||
| 3015 | * If any of the planes on this pipe don't enable wm levels | ||
| 3016 | * that incur memory latencies higher then 30µs we can't enable | ||
| 3017 | * the SAGV | ||
| 3018 | */ | ||
| 3019 | if (dev_priv->wm.skl_latency[level] < SKL_SAGV_BLOCK_TIME) | ||
| 3020 | return false; | ||
| 3021 | } | ||
| 3022 | |||
| 3023 | return true; | ||
| 3024 | } | ||
| 3025 | |||
| 2878 | static void | 3026 | static void |
| 2879 | skl_ddb_get_pipe_allocation_limits(struct drm_device *dev, | 3027 | skl_ddb_get_pipe_allocation_limits(struct drm_device *dev, |
| 2880 | const struct intel_crtc_state *cstate, | 3028 | const struct intel_crtc_state *cstate, |
| @@ -3107,8 +3255,6 @@ skl_get_total_relative_data_rate(struct intel_crtc_state *intel_cstate) | |||
| 3107 | total_data_rate += intel_cstate->wm.skl.plane_y_data_rate[id]; | 3255 | total_data_rate += intel_cstate->wm.skl.plane_y_data_rate[id]; |
| 3108 | } | 3256 | } |
| 3109 | 3257 | ||
| 3110 | WARN_ON(cstate->plane_mask && total_data_rate == 0); | ||
| 3111 | |||
| 3112 | return total_data_rate; | 3258 | return total_data_rate; |
| 3113 | } | 3259 | } |
| 3114 | 3260 | ||
| @@ -3912,9 +4058,24 @@ skl_compute_ddb(struct drm_atomic_state *state) | |||
| 3912 | * pretend that all pipes switched active status so that we'll | 4058 | * pretend that all pipes switched active status so that we'll |
| 3913 | * ensure a full DDB recompute. | 4059 | * ensure a full DDB recompute. |
| 3914 | */ | 4060 | */ |
| 3915 | if (dev_priv->wm.distrust_bios_wm) | 4061 | if (dev_priv->wm.distrust_bios_wm) { |
| 4062 | ret = drm_modeset_lock(&dev->mode_config.connection_mutex, | ||
| 4063 | state->acquire_ctx); | ||
| 4064 | if (ret) | ||
| 4065 | return ret; | ||
| 4066 | |||
| 3916 | intel_state->active_pipe_changes = ~0; | 4067 | intel_state->active_pipe_changes = ~0; |
| 3917 | 4068 | ||
| 4069 | /* | ||
| 4070 | * We usually only initialize intel_state->active_crtcs if we | ||
| 4071 | * we're doing a modeset; make sure this field is always | ||
| 4072 | * initialized during the sanitization process that happens | ||
| 4073 | * on the first commit too. | ||
| 4074 | */ | ||
| 4075 | if (!intel_state->modeset) | ||
| 4076 | intel_state->active_crtcs = dev_priv->active_crtcs; | ||
| 4077 | } | ||
| 4078 | |||
| 3918 | /* | 4079 | /* |
| 3919 | * If the modeset changes which CRTC's are active, we need to | 4080 | * If the modeset changes which CRTC's are active, we need to |
| 3920 | * recompute the DDB allocation for *all* active pipes, even | 4081 | * recompute the DDB allocation for *all* active pipes, even |
| @@ -3943,11 +4104,33 @@ skl_compute_ddb(struct drm_atomic_state *state) | |||
| 3943 | ret = skl_allocate_pipe_ddb(cstate, ddb); | 4104 | ret = skl_allocate_pipe_ddb(cstate, ddb); |
| 3944 | if (ret) | 4105 | if (ret) |
| 3945 | return ret; | 4106 | return ret; |
| 4107 | |||
| 4108 | ret = drm_atomic_add_affected_planes(state, &intel_crtc->base); | ||
| 4109 | if (ret) | ||
| 4110 | return ret; | ||
| 3946 | } | 4111 | } |
| 3947 | 4112 | ||
| 3948 | return 0; | 4113 | return 0; |
| 3949 | } | 4114 | } |
| 3950 | 4115 | ||
| 4116 | static void | ||
| 4117 | skl_copy_wm_for_pipe(struct skl_wm_values *dst, | ||
| 4118 | struct skl_wm_values *src, | ||
| 4119 | enum pipe pipe) | ||
| 4120 | { | ||
| 4121 | dst->wm_linetime[pipe] = src->wm_linetime[pipe]; | ||
| 4122 | memcpy(dst->plane[pipe], src->plane[pipe], | ||
| 4123 | sizeof(dst->plane[pipe])); | ||
| 4124 | memcpy(dst->plane_trans[pipe], src->plane_trans[pipe], | ||
| 4125 | sizeof(dst->plane_trans[pipe])); | ||
| 4126 | |||
| 4127 | dst->ddb.pipe[pipe] = src->ddb.pipe[pipe]; | ||
| 4128 | memcpy(dst->ddb.y_plane[pipe], src->ddb.y_plane[pipe], | ||
| 4129 | sizeof(dst->ddb.y_plane[pipe])); | ||
| 4130 | memcpy(dst->ddb.plane[pipe], src->ddb.plane[pipe], | ||
| 4131 | sizeof(dst->ddb.plane[pipe])); | ||
| 4132 | } | ||
| 4133 | |||
| 3951 | static int | 4134 | static int |
| 3952 | skl_compute_wm(struct drm_atomic_state *state) | 4135 | skl_compute_wm(struct drm_atomic_state *state) |
| 3953 | { | 4136 | { |
| @@ -4020,8 +4203,10 @@ static void skl_update_wm(struct drm_crtc *crtc) | |||
| 4020 | struct drm_device *dev = crtc->dev; | 4203 | struct drm_device *dev = crtc->dev; |
| 4021 | struct drm_i915_private *dev_priv = to_i915(dev); | 4204 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 4022 | struct skl_wm_values *results = &dev_priv->wm.skl_results; | 4205 | struct skl_wm_values *results = &dev_priv->wm.skl_results; |
| 4206 | struct skl_wm_values *hw_vals = &dev_priv->wm.skl_hw; | ||
| 4023 | struct intel_crtc_state *cstate = to_intel_crtc_state(crtc->state); | 4207 | struct intel_crtc_state *cstate = to_intel_crtc_state(crtc->state); |
| 4024 | struct skl_pipe_wm *pipe_wm = &cstate->wm.skl.optimal; | 4208 | struct skl_pipe_wm *pipe_wm = &cstate->wm.skl.optimal; |
| 4209 | int pipe; | ||
| 4025 | 4210 | ||
| 4026 | if ((results->dirty_pipes & drm_crtc_mask(crtc)) == 0) | 4211 | if ((results->dirty_pipes & drm_crtc_mask(crtc)) == 0) |
| 4027 | return; | 4212 | return; |
| @@ -4033,8 +4218,12 @@ static void skl_update_wm(struct drm_crtc *crtc) | |||
| 4033 | skl_write_wm_values(dev_priv, results); | 4218 | skl_write_wm_values(dev_priv, results); |
| 4034 | skl_flush_wm_values(dev_priv, results); | 4219 | skl_flush_wm_values(dev_priv, results); |
| 4035 | 4220 | ||
| 4036 | /* store the new configuration */ | 4221 | /* |
| 4037 | dev_priv->wm.skl_hw = *results; | 4222 | * Store the new configuration (but only for the pipes that have |
| 4223 | * changed; the other values weren't recomputed). | ||
| 4224 | */ | ||
| 4225 | for_each_pipe_masked(dev_priv, pipe, results->dirty_pipes) | ||
| 4226 | skl_copy_wm_for_pipe(hw_vals, results, pipe); | ||
| 4038 | 4227 | ||
| 4039 | mutex_unlock(&dev_priv->wm.wm_mutex); | 4228 | mutex_unlock(&dev_priv->wm.wm_mutex); |
| 4040 | } | 4229 | } |
| @@ -7658,8 +7847,54 @@ void intel_init_pm(struct drm_device *dev) | |||
| 7658 | } | 7847 | } |
| 7659 | } | 7848 | } |
| 7660 | 7849 | ||
| 7850 | static inline int gen6_check_mailbox_status(struct drm_i915_private *dev_priv) | ||
| 7851 | { | ||
| 7852 | uint32_t flags = | ||
| 7853 | I915_READ_FW(GEN6_PCODE_MAILBOX) & GEN6_PCODE_ERROR_MASK; | ||
| 7854 | |||
| 7855 | switch (flags) { | ||
| 7856 | case GEN6_PCODE_SUCCESS: | ||
| 7857 | return 0; | ||
| 7858 | case GEN6_PCODE_UNIMPLEMENTED_CMD: | ||
| 7859 | case GEN6_PCODE_ILLEGAL_CMD: | ||
| 7860 | return -ENXIO; | ||
| 7861 | case GEN6_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE: | ||
| 7862 | case GEN7_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE: | ||
| 7863 | return -EOVERFLOW; | ||
| 7864 | case GEN6_PCODE_TIMEOUT: | ||
| 7865 | return -ETIMEDOUT; | ||
| 7866 | default: | ||
| 7867 | MISSING_CASE(flags) | ||
| 7868 | return 0; | ||
| 7869 | } | ||
| 7870 | } | ||
| 7871 | |||
| 7872 | static inline int gen7_check_mailbox_status(struct drm_i915_private *dev_priv) | ||
| 7873 | { | ||
| 7874 | uint32_t flags = | ||
| 7875 | I915_READ_FW(GEN6_PCODE_MAILBOX) & GEN6_PCODE_ERROR_MASK; | ||
| 7876 | |||
| 7877 | switch (flags) { | ||
| 7878 | case GEN6_PCODE_SUCCESS: | ||
| 7879 | return 0; | ||
| 7880 | case GEN6_PCODE_ILLEGAL_CMD: | ||
| 7881 | return -ENXIO; | ||
| 7882 | case GEN7_PCODE_TIMEOUT: | ||
| 7883 | return -ETIMEDOUT; | ||
| 7884 | case GEN7_PCODE_ILLEGAL_DATA: | ||
| 7885 | return -EINVAL; | ||
| 7886 | case GEN7_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE: | ||
| 7887 | return -EOVERFLOW; | ||
| 7888 | default: | ||
| 7889 | MISSING_CASE(flags); | ||
| 7890 | return 0; | ||
| 7891 | } | ||
| 7892 | } | ||
| 7893 | |||
| 7661 | int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u32 mbox, u32 *val) | 7894 | int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u32 mbox, u32 *val) |
| 7662 | { | 7895 | { |
| 7896 | int status; | ||
| 7897 | |||
| 7663 | WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock)); | 7898 | WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock)); |
| 7664 | 7899 | ||
| 7665 | /* GEN6_PCODE_* are outside of the forcewake domain, we can | 7900 | /* GEN6_PCODE_* are outside of the forcewake domain, we can |
| @@ -7686,12 +7921,25 @@ int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u32 mbox, u32 *val | |||
| 7686 | *val = I915_READ_FW(GEN6_PCODE_DATA); | 7921 | *val = I915_READ_FW(GEN6_PCODE_DATA); |
| 7687 | I915_WRITE_FW(GEN6_PCODE_DATA, 0); | 7922 | I915_WRITE_FW(GEN6_PCODE_DATA, 0); |
| 7688 | 7923 | ||
| 7924 | if (INTEL_GEN(dev_priv) > 6) | ||
| 7925 | status = gen7_check_mailbox_status(dev_priv); | ||
| 7926 | else | ||
| 7927 | status = gen6_check_mailbox_status(dev_priv); | ||
| 7928 | |||
| 7929 | if (status) { | ||
| 7930 | DRM_DEBUG_DRIVER("warning: pcode (read) mailbox access failed: %d\n", | ||
| 7931 | status); | ||
| 7932 | return status; | ||
| 7933 | } | ||
| 7934 | |||
| 7689 | return 0; | 7935 | return 0; |
| 7690 | } | 7936 | } |
| 7691 | 7937 | ||
| 7692 | int sandybridge_pcode_write(struct drm_i915_private *dev_priv, | 7938 | int sandybridge_pcode_write(struct drm_i915_private *dev_priv, |
| 7693 | u32 mbox, u32 val) | 7939 | u32 mbox, u32 val) |
| 7694 | { | 7940 | { |
| 7941 | int status; | ||
| 7942 | |||
| 7695 | WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock)); | 7943 | WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock)); |
| 7696 | 7944 | ||
| 7697 | /* GEN6_PCODE_* are outside of the forcewake domain, we can | 7945 | /* GEN6_PCODE_* are outside of the forcewake domain, we can |
| @@ -7716,6 +7964,17 @@ int sandybridge_pcode_write(struct drm_i915_private *dev_priv, | |||
| 7716 | 7964 | ||
| 7717 | I915_WRITE_FW(GEN6_PCODE_DATA, 0); | 7965 | I915_WRITE_FW(GEN6_PCODE_DATA, 0); |
| 7718 | 7966 | ||
| 7967 | if (INTEL_GEN(dev_priv) > 6) | ||
| 7968 | status = gen7_check_mailbox_status(dev_priv); | ||
| 7969 | else | ||
| 7970 | status = gen6_check_mailbox_status(dev_priv); | ||
| 7971 | |||
| 7972 | if (status) { | ||
| 7973 | DRM_DEBUG_DRIVER("warning: pcode (write) mailbox access failed: %d\n", | ||
| 7974 | status); | ||
| 7975 | return status; | ||
| 7976 | } | ||
| 7977 | |||
| 7719 | return 0; | 7978 | return 0; |
| 7720 | } | 7979 | } |
| 7721 | 7980 | ||
diff --git a/drivers/gpu/drm/i915/intel_psr.c b/drivers/gpu/drm/i915/intel_psr.c index 2b0d1baf15b3..cf171b4b8c67 100644 --- a/drivers/gpu/drm/i915/intel_psr.c +++ b/drivers/gpu/drm/i915/intel_psr.c | |||
| @@ -255,14 +255,14 @@ static void hsw_psr_enable_source(struct intel_dp *intel_dp) | |||
| 255 | struct drm_i915_private *dev_priv = to_i915(dev); | 255 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 256 | 256 | ||
| 257 | uint32_t max_sleep_time = 0x1f; | 257 | uint32_t max_sleep_time = 0x1f; |
| 258 | /* Lately it was identified that depending on panel idle frame count | 258 | /* |
| 259 | * calculated at HW can be off by 1. So let's use what came | 259 | * Let's respect VBT in case VBT asks a higher idle_frame value. |
| 260 | * from VBT + 1. | 260 | * Let's use 6 as the minimum to cover all known cases including |
| 261 | * There are also other cases where panel demands at least 4 | 261 | * the off-by-one issue that HW has in some cases. Also there are |
| 262 | * but VBT is not being set. To cover these 2 cases lets use | 262 | * cases where sink should be able to train |
| 263 | * at least 5 when VBT isn't set to be on the safest side. | 263 | * with the 5 or 6 idle patterns. |
| 264 | */ | 264 | */ |
| 265 | uint32_t idle_frames = dev_priv->vbt.psr.idle_frames + 1; | 265 | uint32_t idle_frames = max(6, dev_priv->vbt.psr.idle_frames); |
| 266 | uint32_t val = EDP_PSR_ENABLE; | 266 | uint32_t val = EDP_PSR_ENABLE; |
| 267 | 267 | ||
| 268 | val |= max_sleep_time << EDP_PSR_MAX_SLEEP_TIME_SHIFT; | 268 | val |= max_sleep_time << EDP_PSR_MAX_SLEEP_TIME_SHIFT; |
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index 9f7dafce3a4c..7bf90e9e6139 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c | |||
| @@ -171,10 +171,34 @@ static void imx_drm_output_poll_changed(struct drm_device *drm) | |||
| 171 | drm_fbdev_cma_hotplug_event(imxdrm->fbhelper); | 171 | drm_fbdev_cma_hotplug_event(imxdrm->fbhelper); |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | static int imx_drm_atomic_check(struct drm_device *dev, | ||
| 175 | struct drm_atomic_state *state) | ||
| 176 | { | ||
| 177 | int ret; | ||
| 178 | |||
| 179 | ret = drm_atomic_helper_check_modeset(dev, state); | ||
| 180 | if (ret) | ||
| 181 | return ret; | ||
| 182 | |||
| 183 | ret = drm_atomic_helper_check_planes(dev, state); | ||
| 184 | if (ret) | ||
| 185 | return ret; | ||
| 186 | |||
| 187 | /* | ||
| 188 | * Check modeset again in case crtc_state->mode_changed is | ||
| 189 | * updated in plane's ->atomic_check callback. | ||
| 190 | */ | ||
| 191 | ret = drm_atomic_helper_check_modeset(dev, state); | ||
| 192 | if (ret) | ||
| 193 | return ret; | ||
| 194 | |||
| 195 | return ret; | ||
| 196 | } | ||
| 197 | |||
| 174 | static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { | 198 | static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { |
| 175 | .fb_create = drm_fb_cma_create, | 199 | .fb_create = drm_fb_cma_create, |
| 176 | .output_poll_changed = imx_drm_output_poll_changed, | 200 | .output_poll_changed = imx_drm_output_poll_changed, |
| 177 | .atomic_check = drm_atomic_helper_check, | 201 | .atomic_check = imx_drm_atomic_check, |
| 178 | .atomic_commit = drm_atomic_helper_commit, | 202 | .atomic_commit = drm_atomic_helper_commit, |
| 179 | }; | 203 | }; |
| 180 | 204 | ||
diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c index 08e188bc10fc..462056e4b9e4 100644 --- a/drivers/gpu/drm/imx/ipuv3-crtc.c +++ b/drivers/gpu/drm/imx/ipuv3-crtc.c | |||
| @@ -76,6 +76,8 @@ static void ipu_crtc_disable(struct drm_crtc *crtc) | |||
| 76 | crtc->state->event = NULL; | 76 | crtc->state->event = NULL; |
| 77 | } | 77 | } |
| 78 | spin_unlock_irq(&crtc->dev->event_lock); | 78 | spin_unlock_irq(&crtc->dev->event_lock); |
| 79 | |||
| 80 | drm_crtc_vblank_off(crtc); | ||
| 79 | } | 81 | } |
| 80 | 82 | ||
| 81 | static void imx_drm_crtc_reset(struct drm_crtc *crtc) | 83 | static void imx_drm_crtc_reset(struct drm_crtc *crtc) |
| @@ -175,6 +177,8 @@ static int ipu_crtc_atomic_check(struct drm_crtc *crtc, | |||
| 175 | static void ipu_crtc_atomic_begin(struct drm_crtc *crtc, | 177 | static void ipu_crtc_atomic_begin(struct drm_crtc *crtc, |
| 176 | struct drm_crtc_state *old_crtc_state) | 178 | struct drm_crtc_state *old_crtc_state) |
| 177 | { | 179 | { |
| 180 | drm_crtc_vblank_on(crtc); | ||
| 181 | |||
| 178 | spin_lock_irq(&crtc->dev->event_lock); | 182 | spin_lock_irq(&crtc->dev->event_lock); |
| 179 | if (crtc->state->event) { | 183 | if (crtc->state->event) { |
| 180 | WARN_ON(drm_crtc_vblank_get(crtc)); | 184 | WARN_ON(drm_crtc_vblank_get(crtc)); |
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c index 4ad67d015ec7..29423e757d36 100644 --- a/drivers/gpu/drm/imx/ipuv3-plane.c +++ b/drivers/gpu/drm/imx/ipuv3-plane.c | |||
| @@ -319,13 +319,14 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, | |||
| 319 | return -EINVAL; | 319 | return -EINVAL; |
| 320 | 320 | ||
| 321 | /* | 321 | /* |
| 322 | * since we cannot touch active IDMAC channels, we do not support | 322 | * We support resizing active plane or changing its format by |
| 323 | * resizing the enabled plane or changing its format | 323 | * forcing CRTC mode change and disabling-enabling plane in plane's |
| 324 | * ->atomic_update callback. | ||
| 324 | */ | 325 | */ |
| 325 | if (old_fb && (state->src_w != old_state->src_w || | 326 | if (old_fb && (state->src_w != old_state->src_w || |
| 326 | state->src_h != old_state->src_h || | 327 | state->src_h != old_state->src_h || |
| 327 | fb->pixel_format != old_fb->pixel_format)) | 328 | fb->pixel_format != old_fb->pixel_format)) |
| 328 | return -EINVAL; | 329 | crtc_state->mode_changed = true; |
| 329 | 330 | ||
| 330 | eba = drm_plane_state_to_eba(state); | 331 | eba = drm_plane_state_to_eba(state); |
| 331 | 332 | ||
| @@ -336,7 +337,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, | |||
| 336 | return -EINVAL; | 337 | return -EINVAL; |
| 337 | 338 | ||
| 338 | if (old_fb && fb->pitches[0] != old_fb->pitches[0]) | 339 | if (old_fb && fb->pitches[0] != old_fb->pitches[0]) |
| 339 | return -EINVAL; | 340 | crtc_state->mode_changed = true; |
| 340 | 341 | ||
| 341 | switch (fb->pixel_format) { | 342 | switch (fb->pixel_format) { |
| 342 | case DRM_FORMAT_YUV420: | 343 | case DRM_FORMAT_YUV420: |
| @@ -372,7 +373,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, | |||
| 372 | return -EINVAL; | 373 | return -EINVAL; |
| 373 | 374 | ||
| 374 | if (old_fb && old_fb->pitches[1] != fb->pitches[1]) | 375 | if (old_fb && old_fb->pitches[1] != fb->pitches[1]) |
| 375 | return -EINVAL; | 376 | crtc_state->mode_changed = true; |
| 376 | } | 377 | } |
| 377 | 378 | ||
| 378 | return 0; | 379 | return 0; |
| @@ -392,8 +393,14 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, | |||
| 392 | enum ipu_color_space ics; | 393 | enum ipu_color_space ics; |
| 393 | 394 | ||
| 394 | if (old_state->fb) { | 395 | if (old_state->fb) { |
| 395 | ipu_plane_atomic_set_base(ipu_plane, old_state); | 396 | struct drm_crtc_state *crtc_state = state->crtc->state; |
| 396 | return; | 397 | |
| 398 | if (!crtc_state->mode_changed) { | ||
| 399 | ipu_plane_atomic_set_base(ipu_plane, old_state); | ||
| 400 | return; | ||
| 401 | } | ||
| 402 | |||
| 403 | ipu_disable_plane(plane); | ||
| 397 | } | 404 | } |
| 398 | 405 | ||
| 399 | switch (ipu_plane->dp_flow) { | 406 | switch (ipu_plane->dp_flow) { |
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index b4bc7f1ef717..d0da52f2a806 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h | |||
| @@ -157,6 +157,12 @@ struct msm_drm_private { | |||
| 157 | struct shrinker shrinker; | 157 | struct shrinker shrinker; |
| 158 | 158 | ||
| 159 | struct msm_vblank_ctrl vblank_ctrl; | 159 | struct msm_vblank_ctrl vblank_ctrl; |
| 160 | |||
| 161 | /* task holding struct_mutex.. currently only used in submit path | ||
| 162 | * to detect and reject faults from copy_from_user() for submit | ||
| 163 | * ioctl. | ||
| 164 | */ | ||
| 165 | struct task_struct *struct_mutex_task; | ||
| 160 | }; | 166 | }; |
| 161 | 167 | ||
| 162 | struct msm_format { | 168 | struct msm_format { |
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 6cd4af443139..85f3047e05ae 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c | |||
| @@ -196,11 +196,20 @@ int msm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
| 196 | { | 196 | { |
| 197 | struct drm_gem_object *obj = vma->vm_private_data; | 197 | struct drm_gem_object *obj = vma->vm_private_data; |
| 198 | struct drm_device *dev = obj->dev; | 198 | struct drm_device *dev = obj->dev; |
| 199 | struct msm_drm_private *priv = dev->dev_private; | ||
| 199 | struct page **pages; | 200 | struct page **pages; |
| 200 | unsigned long pfn; | 201 | unsigned long pfn; |
| 201 | pgoff_t pgoff; | 202 | pgoff_t pgoff; |
| 202 | int ret; | 203 | int ret; |
| 203 | 204 | ||
| 205 | /* This should only happen if userspace tries to pass a mmap'd | ||
| 206 | * but unfaulted gem bo vaddr into submit ioctl, triggering | ||
| 207 | * a page fault while struct_mutex is already held. This is | ||
| 208 | * not a valid use-case so just bail. | ||
| 209 | */ | ||
| 210 | if (priv->struct_mutex_task == current) | ||
| 211 | return VM_FAULT_SIGBUS; | ||
| 212 | |||
| 204 | /* Make sure we don't parallel update on a fault, nor move or remove | 213 | /* Make sure we don't parallel update on a fault, nor move or remove |
| 205 | * something from beneath our feet | 214 | * something from beneath our feet |
| 206 | */ | 215 | */ |
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 9766f9ae4b7d..880d6a9af7c8 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c | |||
| @@ -64,6 +64,14 @@ void msm_gem_submit_free(struct msm_gem_submit *submit) | |||
| 64 | kfree(submit); | 64 | kfree(submit); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | static inline unsigned long __must_check | ||
| 68 | copy_from_user_inatomic(void *to, const void __user *from, unsigned long n) | ||
| 69 | { | ||
| 70 | if (access_ok(VERIFY_READ, from, n)) | ||
| 71 | return __copy_from_user_inatomic(to, from, n); | ||
| 72 | return -EFAULT; | ||
| 73 | } | ||
| 74 | |||
| 67 | static int submit_lookup_objects(struct msm_gem_submit *submit, | 75 | static int submit_lookup_objects(struct msm_gem_submit *submit, |
| 68 | struct drm_msm_gem_submit *args, struct drm_file *file) | 76 | struct drm_msm_gem_submit *args, struct drm_file *file) |
| 69 | { | 77 | { |
| @@ -71,6 +79,7 @@ static int submit_lookup_objects(struct msm_gem_submit *submit, | |||
| 71 | int ret = 0; | 79 | int ret = 0; |
| 72 | 80 | ||
| 73 | spin_lock(&file->table_lock); | 81 | spin_lock(&file->table_lock); |
| 82 | pagefault_disable(); | ||
| 74 | 83 | ||
| 75 | for (i = 0; i < args->nr_bos; i++) { | 84 | for (i = 0; i < args->nr_bos; i++) { |
| 76 | struct drm_msm_gem_submit_bo submit_bo; | 85 | struct drm_msm_gem_submit_bo submit_bo; |
| @@ -84,10 +93,15 @@ static int submit_lookup_objects(struct msm_gem_submit *submit, | |||
| 84 | */ | 93 | */ |
| 85 | submit->bos[i].flags = 0; | 94 | submit->bos[i].flags = 0; |
| 86 | 95 | ||
| 87 | ret = copy_from_user(&submit_bo, userptr, sizeof(submit_bo)); | 96 | ret = copy_from_user_inatomic(&submit_bo, userptr, sizeof(submit_bo)); |
| 88 | if (ret) { | 97 | if (unlikely(ret)) { |
| 89 | ret = -EFAULT; | 98 | pagefault_enable(); |
| 90 | goto out_unlock; | 99 | spin_unlock(&file->table_lock); |
| 100 | ret = copy_from_user(&submit_bo, userptr, sizeof(submit_bo)); | ||
| 101 | if (ret) | ||
| 102 | goto out; | ||
| 103 | spin_lock(&file->table_lock); | ||
| 104 | pagefault_disable(); | ||
| 91 | } | 105 | } |
| 92 | 106 | ||
| 93 | if (submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) { | 107 | if (submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) { |
| @@ -127,9 +141,12 @@ static int submit_lookup_objects(struct msm_gem_submit *submit, | |||
| 127 | } | 141 | } |
| 128 | 142 | ||
| 129 | out_unlock: | 143 | out_unlock: |
| 130 | submit->nr_bos = i; | 144 | pagefault_enable(); |
| 131 | spin_unlock(&file->table_lock); | 145 | spin_unlock(&file->table_lock); |
| 132 | 146 | ||
| 147 | out: | ||
| 148 | submit->nr_bos = i; | ||
| 149 | |||
| 133 | return ret; | 150 | return ret; |
| 134 | } | 151 | } |
| 135 | 152 | ||
| @@ -377,6 +394,8 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, | |||
| 377 | if (ret) | 394 | if (ret) |
| 378 | return ret; | 395 | return ret; |
| 379 | 396 | ||
| 397 | priv->struct_mutex_task = current; | ||
| 398 | |||
| 380 | submit = submit_create(dev, gpu, args->nr_bos, args->nr_cmds); | 399 | submit = submit_create(dev, gpu, args->nr_bos, args->nr_cmds); |
| 381 | if (!submit) { | 400 | if (!submit) { |
| 382 | ret = -ENOMEM; | 401 | ret = -ENOMEM; |
| @@ -468,6 +487,7 @@ out: | |||
| 468 | if (ret) | 487 | if (ret) |
| 469 | msm_gem_submit_free(submit); | 488 | msm_gem_submit_free(submit); |
| 470 | out_unlock: | 489 | out_unlock: |
| 490 | priv->struct_mutex_task = NULL; | ||
| 471 | mutex_unlock(&dev->struct_mutex); | 491 | mutex_unlock(&dev->struct_mutex); |
| 472 | return ret; | 492 | return ret; |
| 473 | } | 493 | } |
diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c index f2ad17aa33f0..dc57b628e074 100644 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c | |||
| @@ -225,6 +225,17 @@ static bool nouveau_pr3_present(struct pci_dev *pdev) | |||
| 225 | if (!parent_pdev) | 225 | if (!parent_pdev) |
| 226 | return false; | 226 | return false; |
| 227 | 227 | ||
| 228 | if (!parent_pdev->bridge_d3) { | ||
| 229 | /* | ||
| 230 | * Parent PCI bridge is currently not power managed. | ||
| 231 | * Since userspace can change these afterwards to be on | ||
| 232 | * the safe side we stick with _DSM and prevent usage of | ||
| 233 | * _PR3 from the bridge. | ||
| 234 | */ | ||
| 235 | pci_d3cold_disable(pdev); | ||
| 236 | return false; | ||
| 237 | } | ||
| 238 | |||
| 228 | parent_adev = ACPI_COMPANION(&parent_pdev->dev); | 239 | parent_adev = ACPI_COMPANION(&parent_pdev->dev); |
| 229 | if (!parent_adev) | 240 | if (!parent_adev) |
| 230 | return false; | 241 | return false; |
diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c index df2657051afd..28c1423049c5 100644 --- a/drivers/gpu/drm/qxl/qxl_fb.c +++ b/drivers/gpu/drm/qxl/qxl_fb.c | |||
| @@ -73,10 +73,12 @@ static void qxl_fb_image_init(struct qxl_fb_image *qxl_fb_image, | |||
| 73 | } | 73 | } |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | #ifdef CONFIG_DRM_FBDEV_EMULATION | ||
| 76 | static struct fb_deferred_io qxl_defio = { | 77 | static struct fb_deferred_io qxl_defio = { |
| 77 | .delay = QXL_DIRTY_DELAY, | 78 | .delay = QXL_DIRTY_DELAY, |
| 78 | .deferred_io = drm_fb_helper_deferred_io, | 79 | .deferred_io = drm_fb_helper_deferred_io, |
| 79 | }; | 80 | }; |
| 81 | #endif | ||
| 80 | 82 | ||
| 81 | static struct fb_ops qxlfb_ops = { | 83 | static struct fb_ops qxlfb_ops = { |
| 82 | .owner = THIS_MODULE, | 84 | .owner = THIS_MODULE, |
| @@ -313,8 +315,10 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev, | |||
| 313 | goto out_destroy_fbi; | 315 | goto out_destroy_fbi; |
| 314 | } | 316 | } |
| 315 | 317 | ||
| 318 | #ifdef CONFIG_DRM_FBDEV_EMULATION | ||
| 316 | info->fbdefio = &qxl_defio; | 319 | info->fbdefio = &qxl_defio; |
| 317 | fb_deferred_io_init(info); | 320 | fb_deferred_io_init(info); |
| 321 | #endif | ||
| 318 | 322 | ||
| 319 | qdev->fbdev_info = info; | 323 | qdev->fbdev_info = info; |
| 320 | qdev->fbdev_qfb = &qfbdev->qfb; | 324 | qdev->fbdev_qfb = &qfbdev->qfb; |
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c index a97abc8af657..1dcf39084555 100644 --- a/drivers/gpu/drm/radeon/atombios_crtc.c +++ b/drivers/gpu/drm/radeon/atombios_crtc.c | |||
| @@ -627,7 +627,9 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc, | |||
| 627 | if (radeon_crtc->ss.refdiv) { | 627 | if (radeon_crtc->ss.refdiv) { |
| 628 | radeon_crtc->pll_flags |= RADEON_PLL_USE_REF_DIV; | 628 | radeon_crtc->pll_flags |= RADEON_PLL_USE_REF_DIV; |
| 629 | radeon_crtc->pll_reference_div = radeon_crtc->ss.refdiv; | 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 | radeon_crtc->pll_flags |= RADEON_PLL_USE_FRAC_FB_DIV; | 633 | radeon_crtc->pll_flags |= RADEON_PLL_USE_FRAC_FB_DIV; |
| 632 | } | 634 | } |
| 633 | } | 635 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 0c00e192c845..c2e0a1ccdfbc 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c | |||
| @@ -263,8 +263,8 @@ static int radeon_move_blit(struct ttm_buffer_object *bo, | |||
| 263 | 263 | ||
| 264 | rdev = radeon_get_rdev(bo->bdev); | 264 | rdev = radeon_get_rdev(bo->bdev); |
| 265 | ridx = radeon_copy_ring_index(rdev); | 265 | ridx = radeon_copy_ring_index(rdev); |
| 266 | old_start = old_mem->start << PAGE_SHIFT; | 266 | old_start = (u64)old_mem->start << PAGE_SHIFT; |
| 267 | new_start = new_mem->start << PAGE_SHIFT; | 267 | new_start = (u64)new_mem->start << PAGE_SHIFT; |
| 268 | 268 | ||
| 269 | switch (old_mem->mem_type) { | 269 | switch (old_mem->mem_type) { |
| 270 | case TTM_PL_VRAM: | 270 | case TTM_PL_VRAM: |
diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c index 3d228ad90e0f..3dea1216bafd 100644 --- a/drivers/gpu/drm/tegra/dsi.c +++ b/drivers/gpu/drm/tegra/dsi.c | |||
| @@ -840,6 +840,21 @@ static const struct drm_encoder_funcs tegra_dsi_encoder_funcs = { | |||
| 840 | .destroy = tegra_output_encoder_destroy, | 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 | static void tegra_dsi_encoder_disable(struct drm_encoder *encoder) | 858 | static void tegra_dsi_encoder_disable(struct drm_encoder *encoder) |
| 844 | { | 859 | { |
| 845 | struct tegra_output *output = encoder_to_output(encoder); | 860 | struct tegra_output *output = encoder_to_output(encoder); |
| @@ -876,7 +891,26 @@ static void tegra_dsi_encoder_disable(struct drm_encoder *encoder) | |||
| 876 | 891 | ||
| 877 | tegra_dsi_disable(dsi); | 892 | tegra_dsi_disable(dsi); |
| 878 | 893 | ||
| 879 | pm_runtime_put(dsi->dev); | 894 | tegra_dsi_unprepare(dsi); |
| 895 | } | ||
| 896 | |||
| 897 | static void tegra_dsi_prepare(struct tegra_dsi *dsi) | ||
| 898 | { | ||
| 899 | int err; | ||
| 900 | |||
| 901 | pm_runtime_get_sync(dsi->dev); | ||
| 902 | |||
| 903 | err = tegra_mipi_enable(dsi->mipi); | ||
| 904 | if (err < 0) | ||
| 905 | dev_err(dsi->dev, "failed to enable MIPI calibration: %d\n", | ||
| 906 | err); | ||
| 907 | |||
| 908 | err = tegra_dsi_pad_calibrate(dsi); | ||
| 909 | if (err < 0) | ||
| 910 | dev_err(dsi->dev, "MIPI calibration failed: %d\n", err); | ||
| 911 | |||
| 912 | if (dsi->slave) | ||
| 913 | tegra_dsi_prepare(dsi->slave); | ||
| 880 | } | 914 | } |
| 881 | 915 | ||
| 882 | static void tegra_dsi_encoder_enable(struct drm_encoder *encoder) | 916 | static void tegra_dsi_encoder_enable(struct drm_encoder *encoder) |
| @@ -887,13 +921,8 @@ static void tegra_dsi_encoder_enable(struct drm_encoder *encoder) | |||
| 887 | struct tegra_dsi *dsi = to_dsi(output); | 921 | struct tegra_dsi *dsi = to_dsi(output); |
| 888 | struct tegra_dsi_state *state; | 922 | struct tegra_dsi_state *state; |
| 889 | u32 value; | 923 | u32 value; |
| 890 | int err; | ||
| 891 | |||
| 892 | pm_runtime_get_sync(dsi->dev); | ||
| 893 | 924 | ||
| 894 | err = tegra_dsi_pad_calibrate(dsi); | 925 | tegra_dsi_prepare(dsi); |
| 895 | if (err < 0) | ||
| 896 | dev_err(dsi->dev, "MIPI calibration failed: %d\n", err); | ||
| 897 | 926 | ||
| 898 | state = tegra_dsi_get_state(dsi); | 927 | state = tegra_dsi_get_state(dsi); |
| 899 | 928 | ||
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c index d5df555aeba0..9688bfa92ccd 100644 --- a/drivers/gpu/drm/udl/udl_fb.c +++ b/drivers/gpu/drm/udl/udl_fb.c | |||
| @@ -203,6 +203,7 @@ static int udl_fb_open(struct fb_info *info, int user) | |||
| 203 | 203 | ||
| 204 | ufbdev->fb_count++; | 204 | ufbdev->fb_count++; |
| 205 | 205 | ||
| 206 | #ifdef CONFIG_DRM_FBDEV_EMULATION | ||
| 206 | if (fb_defio && (info->fbdefio == NULL)) { | 207 | if (fb_defio && (info->fbdefio == NULL)) { |
| 207 | /* enable defio at last moment if not disabled by client */ | 208 | /* enable defio at last moment if not disabled by client */ |
| 208 | 209 | ||
| @@ -218,6 +219,7 @@ static int udl_fb_open(struct fb_info *info, int user) | |||
| 218 | info->fbdefio = fbdefio; | 219 | info->fbdefio = fbdefio; |
| 219 | fb_deferred_io_init(info); | 220 | fb_deferred_io_init(info); |
| 220 | } | 221 | } |
| 222 | #endif | ||
| 221 | 223 | ||
| 222 | pr_notice("open /dev/fb%d user=%d fb_info=%p count=%d\n", | 224 | pr_notice("open /dev/fb%d user=%d fb_info=%p count=%d\n", |
| 223 | info->node, user, info, ufbdev->fb_count); | 225 | info->node, user, info, ufbdev->fb_count); |
| @@ -235,12 +237,14 @@ static int udl_fb_release(struct fb_info *info, int user) | |||
| 235 | 237 | ||
| 236 | ufbdev->fb_count--; | 238 | ufbdev->fb_count--; |
| 237 | 239 | ||
| 240 | #ifdef CONFIG_DRM_FBDEV_EMULATION | ||
| 238 | if ((ufbdev->fb_count == 0) && (info->fbdefio)) { | 241 | if ((ufbdev->fb_count == 0) && (info->fbdefio)) { |
| 239 | fb_deferred_io_cleanup(info); | 242 | fb_deferred_io_cleanup(info); |
| 240 | kfree(info->fbdefio); | 243 | kfree(info->fbdefio); |
| 241 | info->fbdefio = NULL; | 244 | info->fbdefio = NULL; |
| 242 | info->fbops->fb_mmap = udl_fb_mmap; | 245 | info->fbops->fb_mmap = udl_fb_mmap; |
| 243 | } | 246 | } |
| 247 | #endif | ||
| 244 | 248 | ||
| 245 | pr_warn("released /dev/fb%d user=%d count=%d\n", | 249 | pr_warn("released /dev/fb%d user=%d count=%d\n", |
| 246 | info->node, user, ufbdev->fb_count); | 250 | info->node, user, ufbdev->fb_count); |
diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c index 59adcf8532dd..3f6704cf6608 100644 --- a/drivers/gpu/drm/vc4/vc4_bo.c +++ b/drivers/gpu/drm/vc4/vc4_bo.c | |||
| @@ -144,7 +144,7 @@ static struct list_head *vc4_get_cache_list_for_size(struct drm_device *dev, | |||
| 144 | return &vc4->bo_cache.size_list[page_index]; | 144 | return &vc4->bo_cache.size_list[page_index]; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | void vc4_bo_cache_purge(struct drm_device *dev) | 147 | static void vc4_bo_cache_purge(struct drm_device *dev) |
| 148 | { | 148 | { |
| 149 | struct vc4_dev *vc4 = to_vc4_dev(dev); | 149 | struct vc4_dev *vc4 = to_vc4_dev(dev); |
| 150 | 150 | ||
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c index 8b42d31a7f0e..9ecef9385491 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.c +++ b/drivers/gpu/drm/vc4/vc4_drv.c | |||
| @@ -57,21 +57,21 @@ static int vc4_get_param_ioctl(struct drm_device *dev, void *data, | |||
| 57 | switch (args->param) { | 57 | switch (args->param) { |
| 58 | case DRM_VC4_PARAM_V3D_IDENT0: | 58 | case DRM_VC4_PARAM_V3D_IDENT0: |
| 59 | ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev); | 59 | ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev); |
| 60 | if (ret) | 60 | if (ret < 0) |
| 61 | return ret; | 61 | return ret; |
| 62 | args->value = V3D_READ(V3D_IDENT0); | 62 | args->value = V3D_READ(V3D_IDENT0); |
| 63 | pm_runtime_put(&vc4->v3d->pdev->dev); | 63 | pm_runtime_put(&vc4->v3d->pdev->dev); |
| 64 | break; | 64 | break; |
| 65 | case DRM_VC4_PARAM_V3D_IDENT1: | 65 | case DRM_VC4_PARAM_V3D_IDENT1: |
| 66 | ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev); | 66 | ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev); |
| 67 | if (ret) | 67 | if (ret < 0) |
| 68 | return ret; | 68 | return ret; |
| 69 | args->value = V3D_READ(V3D_IDENT1); | 69 | args->value = V3D_READ(V3D_IDENT1); |
| 70 | pm_runtime_put(&vc4->v3d->pdev->dev); | 70 | pm_runtime_put(&vc4->v3d->pdev->dev); |
| 71 | break; | 71 | break; |
| 72 | case DRM_VC4_PARAM_V3D_IDENT2: | 72 | case DRM_VC4_PARAM_V3D_IDENT2: |
| 73 | ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev); | 73 | ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev); |
| 74 | if (ret) | 74 | if (ret < 0) |
| 75 | return ret; | 75 | return ret; |
| 76 | args->value = V3D_READ(V3D_IDENT2); | 76 | args->value = V3D_READ(V3D_IDENT2); |
| 77 | pm_runtime_put(&vc4->v3d->pdev->dev); | 77 | pm_runtime_put(&vc4->v3d->pdev->dev); |
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h index 489e3de0c050..428e24919ef1 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h | |||
| @@ -321,6 +321,15 @@ vc4_first_render_job(struct vc4_dev *vc4) | |||
| 321 | struct vc4_exec_info, head); | 321 | struct vc4_exec_info, head); |
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | static inline struct vc4_exec_info * | ||
| 325 | vc4_last_render_job(struct vc4_dev *vc4) | ||
| 326 | { | ||
| 327 | if (list_empty(&vc4->render_job_list)) | ||
| 328 | return NULL; | ||
| 329 | return list_last_entry(&vc4->render_job_list, | ||
| 330 | struct vc4_exec_info, head); | ||
| 331 | } | ||
| 332 | |||
| 324 | /** | 333 | /** |
| 325 | * struct vc4_texture_sample_info - saves the offsets into the UBO for texture | 334 | * struct vc4_texture_sample_info - saves the offsets into the UBO for texture |
| 326 | * setup parameters. | 335 | * setup parameters. |
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c index 6155e8aca1c6..b262c5c26f10 100644 --- a/drivers/gpu/drm/vc4/vc4_gem.c +++ b/drivers/gpu/drm/vc4/vc4_gem.c | |||
| @@ -534,8 +534,8 @@ vc4_cl_lookup_bos(struct drm_device *dev, | |||
| 534 | return -EINVAL; | 534 | return -EINVAL; |
| 535 | } | 535 | } |
| 536 | 536 | ||
| 537 | exec->bo = kcalloc(exec->bo_count, sizeof(struct drm_gem_cma_object *), | 537 | exec->bo = drm_calloc_large(exec->bo_count, |
| 538 | GFP_KERNEL); | 538 | sizeof(struct drm_gem_cma_object *)); |
| 539 | if (!exec->bo) { | 539 | if (!exec->bo) { |
| 540 | DRM_ERROR("Failed to allocate validated BO pointers\n"); | 540 | DRM_ERROR("Failed to allocate validated BO pointers\n"); |
| 541 | return -ENOMEM; | 541 | return -ENOMEM; |
| @@ -572,8 +572,8 @@ vc4_cl_lookup_bos(struct drm_device *dev, | |||
| 572 | spin_unlock(&file_priv->table_lock); | 572 | spin_unlock(&file_priv->table_lock); |
| 573 | 573 | ||
| 574 | fail: | 574 | fail: |
| 575 | kfree(handles); | 575 | drm_free_large(handles); |
| 576 | return 0; | 576 | return ret; |
| 577 | } | 577 | } |
| 578 | 578 | ||
| 579 | static int | 579 | static int |
| @@ -608,7 +608,7 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec) | |||
| 608 | * read the contents back for validation, and I think the | 608 | * read the contents back for validation, and I think the |
| 609 | * bo->vaddr is uncached access. | 609 | * bo->vaddr is uncached access. |
| 610 | */ | 610 | */ |
| 611 | temp = kmalloc(temp_size, GFP_KERNEL); | 611 | temp = drm_malloc_ab(temp_size, 1); |
| 612 | if (!temp) { | 612 | if (!temp) { |
| 613 | DRM_ERROR("Failed to allocate storage for copying " | 613 | DRM_ERROR("Failed to allocate storage for copying " |
| 614 | "in bin/render CLs.\n"); | 614 | "in bin/render CLs.\n"); |
| @@ -675,7 +675,7 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec) | |||
| 675 | ret = vc4_validate_shader_recs(dev, exec); | 675 | ret = vc4_validate_shader_recs(dev, exec); |
| 676 | 676 | ||
| 677 | fail: | 677 | fail: |
| 678 | kfree(temp); | 678 | drm_free_large(temp); |
| 679 | return ret; | 679 | return ret; |
| 680 | } | 680 | } |
| 681 | 681 | ||
| @@ -688,7 +688,7 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec) | |||
| 688 | if (exec->bo) { | 688 | if (exec->bo) { |
| 689 | for (i = 0; i < exec->bo_count; i++) | 689 | for (i = 0; i < exec->bo_count; i++) |
| 690 | drm_gem_object_unreference_unlocked(&exec->bo[i]->base); | 690 | drm_gem_object_unreference_unlocked(&exec->bo[i]->base); |
| 691 | kfree(exec->bo); | 691 | drm_free_large(exec->bo); |
| 692 | } | 692 | } |
| 693 | 693 | ||
| 694 | while (!list_empty(&exec->unref_list)) { | 694 | while (!list_empty(&exec->unref_list)) { |
| @@ -942,8 +942,8 @@ vc4_gem_destroy(struct drm_device *dev) | |||
| 942 | vc4->overflow_mem = NULL; | 942 | vc4->overflow_mem = NULL; |
| 943 | } | 943 | } |
| 944 | 944 | ||
| 945 | vc4_bo_cache_destroy(dev); | ||
| 946 | |||
| 947 | if (vc4->hang_state) | 945 | if (vc4->hang_state) |
| 948 | vc4_free_hang_state(dev, vc4->hang_state); | 946 | vc4_free_hang_state(dev, vc4->hang_state); |
| 947 | |||
| 948 | vc4_bo_cache_destroy(dev); | ||
| 949 | } | 949 | } |
diff --git a/drivers/gpu/drm/vc4/vc4_irq.c b/drivers/gpu/drm/vc4/vc4_irq.c index b0104a346a74..094bc6a475c1 100644 --- a/drivers/gpu/drm/vc4/vc4_irq.c +++ b/drivers/gpu/drm/vc4/vc4_irq.c | |||
| @@ -83,8 +83,10 @@ vc4_overflow_mem_work(struct work_struct *work) | |||
| 83 | 83 | ||
| 84 | spin_lock_irqsave(&vc4->job_lock, irqflags); | 84 | spin_lock_irqsave(&vc4->job_lock, irqflags); |
| 85 | current_exec = vc4_first_bin_job(vc4); | 85 | current_exec = vc4_first_bin_job(vc4); |
| 86 | if (!current_exec) | ||
| 87 | current_exec = vc4_last_render_job(vc4); | ||
| 86 | if (current_exec) { | 88 | if (current_exec) { |
| 87 | vc4->overflow_mem->seqno = vc4->finished_seqno + 1; | 89 | vc4->overflow_mem->seqno = current_exec->seqno; |
| 88 | list_add_tail(&vc4->overflow_mem->unref_head, | 90 | list_add_tail(&vc4->overflow_mem->unref_head, |
| 89 | ¤t_exec->unref_list); | 91 | ¤t_exec->unref_list); |
| 90 | vc4->overflow_mem = NULL; | 92 | vc4->overflow_mem = NULL; |
diff --git a/drivers/gpu/drm/vc4/vc4_validate_shaders.c b/drivers/gpu/drm/vc4/vc4_validate_shaders.c index 46527e989ce3..2543cf5b8b51 100644 --- a/drivers/gpu/drm/vc4/vc4_validate_shaders.c +++ b/drivers/gpu/drm/vc4/vc4_validate_shaders.c | |||
| @@ -309,8 +309,14 @@ validate_uniform_address_write(struct vc4_validated_shader_info *validated_shade | |||
| 309 | * of uniforms on each side. However, this scheme is easy to | 309 | * of uniforms on each side. However, this scheme is easy to |
| 310 | * validate so it's all we allow for now. | 310 | * validate so it's all we allow for now. |
| 311 | */ | 311 | */ |
| 312 | 312 | switch (QPU_GET_FIELD(inst, QPU_SIG)) { | |
| 313 | if (QPU_GET_FIELD(inst, QPU_SIG) != QPU_SIG_NONE) { | 313 | case QPU_SIG_NONE: |
| 314 | case QPU_SIG_SCOREBOARD_UNLOCK: | ||
| 315 | case QPU_SIG_COLOR_LOAD: | ||
| 316 | case QPU_SIG_LOAD_TMU0: | ||
| 317 | case QPU_SIG_LOAD_TMU1: | ||
| 318 | break; | ||
| 319 | default: | ||
| 314 | DRM_ERROR("uniforms address change must be " | 320 | DRM_ERROR("uniforms address change must be " |
| 315 | "normal math\n"); | 321 | "normal math\n"); |
| 316 | return false; | 322 | return false; |
diff --git a/drivers/gpu/host1x/mipi.c b/drivers/gpu/host1x/mipi.c index 52a6fd224127..e00809d996a2 100644 --- a/drivers/gpu/host1x/mipi.c +++ b/drivers/gpu/host1x/mipi.c | |||
| @@ -242,20 +242,6 @@ struct tegra_mipi_device *tegra_mipi_request(struct device *device) | |||
| 242 | dev->pads = args.args[0]; | 242 | dev->pads = args.args[0]; |
| 243 | dev->device = device; | 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 | return dev; | 245 | return dev; |
| 260 | 246 | ||
| 261 | put: | 247 | put: |
| @@ -270,29 +256,42 @@ EXPORT_SYMBOL(tegra_mipi_request); | |||
| 270 | 256 | ||
| 271 | void tegra_mipi_free(struct tegra_mipi_device *device) | 257 | void tegra_mipi_free(struct tegra_mipi_device *device) |
| 272 | { | 258 | { |
| 273 | int err; | 259 | platform_device_put(device->pdev); |
| 260 | kfree(device); | ||
| 261 | } | ||
| 262 | EXPORT_SYMBOL(tegra_mipi_free); | ||
| 274 | 263 | ||
| 275 | mutex_lock(&device->mipi->lock); | 264 | int tegra_mipi_enable(struct tegra_mipi_device *dev) |
| 265 | { | ||
| 266 | int err = 0; | ||
| 276 | 267 | ||
| 277 | if (--device->mipi->usage_count == 0) { | 268 | mutex_lock(&dev->mipi->lock); |
| 278 | err = tegra_mipi_power_down(device->mipi); | ||
| 279 | if (err < 0) { | ||
| 280 | /* | ||
| 281 | * Not much that can be done here, so an error message | ||
| 282 | * will have to do. | ||
| 283 | */ | ||
| 284 | dev_err(device->mipi->dev, | ||
| 285 | "failed to power down MIPI bricks: %d\n", | ||
| 286 | err); | ||
| 287 | } | ||
| 288 | } | ||
| 289 | 269 | ||
| 290 | mutex_unlock(&device->mipi->lock); | 270 | if (dev->mipi->usage_count++ == 0) |
| 271 | err = tegra_mipi_power_up(dev->mipi); | ||
| 272 | |||
| 273 | mutex_unlock(&dev->mipi->lock); | ||
| 274 | |||
| 275 | return err; | ||
| 291 | 276 | ||
| 292 | platform_device_put(device->pdev); | ||
| 293 | kfree(device); | ||
| 294 | } | 277 | } |
| 295 | EXPORT_SYMBOL(tegra_mipi_free); | 278 | EXPORT_SYMBOL(tegra_mipi_enable); |
| 279 | |||
| 280 | int tegra_mipi_disable(struct tegra_mipi_device *dev) | ||
| 281 | { | ||
| 282 | int err = 0; | ||
| 283 | |||
| 284 | mutex_lock(&dev->mipi->lock); | ||
| 285 | |||
| 286 | if (--dev->mipi->usage_count == 0) | ||
| 287 | err = tegra_mipi_power_down(dev->mipi); | ||
| 288 | |||
| 289 | mutex_unlock(&dev->mipi->lock); | ||
| 290 | |||
| 291 | return err; | ||
| 292 | |||
| 293 | } | ||
| 294 | EXPORT_SYMBOL(tegra_mipi_disable); | ||
| 296 | 295 | ||
| 297 | static int tegra_mipi_wait(struct tegra_mipi *mipi) | 296 | static int tegra_mipi_wait(struct tegra_mipi *mipi) |
| 298 | { | 297 | { |
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index d0203a115eff..4667012b46b7 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
| @@ -2015,6 +2015,7 @@ static struct attribute *it87_attributes_in[] = { | |||
| 2015 | &sensor_dev_attr_in10_input.dev_attr.attr, /* 41 */ | 2015 | &sensor_dev_attr_in10_input.dev_attr.attr, /* 41 */ |
| 2016 | &sensor_dev_attr_in11_input.dev_attr.attr, /* 41 */ | 2016 | &sensor_dev_attr_in11_input.dev_attr.attr, /* 41 */ |
| 2017 | &sensor_dev_attr_in12_input.dev_attr.attr, /* 41 */ | 2017 | &sensor_dev_attr_in12_input.dev_attr.attr, /* 41 */ |
| 2018 | NULL | ||
| 2018 | }; | 2019 | }; |
| 2019 | 2020 | ||
| 2020 | static const struct attribute_group it87_group_in = { | 2021 | static const struct attribute_group it87_group_in = { |
diff --git a/drivers/i2c/busses/i2c-bcm-kona.c b/drivers/i2c/busses/i2c-bcm-kona.c index f98743277e3c..258cb9a40ab3 100644 --- a/drivers/i2c/busses/i2c-bcm-kona.c +++ b/drivers/i2c/busses/i2c-bcm-kona.c | |||
| @@ -643,7 +643,7 @@ static int bcm_kona_i2c_xfer(struct i2c_adapter *adapter, | |||
| 643 | if (rc < 0) { | 643 | if (rc < 0) { |
| 644 | dev_err(dev->device, | 644 | dev_err(dev->device, |
| 645 | "restart cmd failed rc = %d\n", rc); | 645 | "restart cmd failed rc = %d\n", rc); |
| 646 | goto xfer_send_stop; | 646 | goto xfer_send_stop; |
| 647 | } | 647 | } |
| 648 | } | 648 | } |
| 649 | 649 | ||
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index 90bbd9f9dd8f..3c16a2f7c673 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c | |||
| @@ -767,7 +767,7 @@ static int cdns_i2c_setclk(unsigned long clk_in, struct cdns_i2c *id) | |||
| 767 | * depending on the scaling direction. | 767 | * depending on the scaling direction. |
| 768 | * | 768 | * |
| 769 | * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK | 769 | * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK |
| 770 | * to acknowedge the change, NOTIFY_DONE if the notification is | 770 | * to acknowledge the change, NOTIFY_DONE if the notification is |
| 771 | * considered irrelevant. | 771 | * considered irrelevant. |
| 772 | */ | 772 | */ |
| 773 | static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long | 773 | static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long |
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c index c6922b806fb7..fcd973d5131e 100644 --- a/drivers/i2c/busses/i2c-designware-core.c +++ b/drivers/i2c/busses/i2c-designware-core.c | |||
| @@ -367,13 +367,17 @@ int i2c_dw_init(struct dw_i2c_dev *dev) | |||
| 367 | dev_dbg(dev->dev, "Fast-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt); | 367 | dev_dbg(dev->dev, "Fast-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt); |
| 368 | 368 | ||
| 369 | /* Configure SDA Hold Time if required */ | 369 | /* Configure SDA Hold Time if required */ |
| 370 | if (dev->sda_hold_time) { | 370 | reg = dw_readl(dev, DW_IC_COMP_VERSION); |
| 371 | reg = dw_readl(dev, DW_IC_COMP_VERSION); | 371 | if (reg >= DW_IC_SDA_HOLD_MIN_VERS) { |
| 372 | if (reg >= DW_IC_SDA_HOLD_MIN_VERS) | 372 | if (dev->sda_hold_time) { |
| 373 | dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD); | 373 | dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD); |
| 374 | else | 374 | } else { |
| 375 | dev_warn(dev->dev, | 375 | /* Keep previous hold time setting if no one set it */ |
| 376 | "Hardware too old to adjust SDA hold time."); | 376 | dev->sda_hold_time = dw_readl(dev, DW_IC_SDA_HOLD); |
| 377 | } | ||
| 378 | } else { | ||
| 379 | dev_warn(dev->dev, | ||
| 380 | "Hardware too old to adjust SDA hold time.\n"); | ||
| 377 | } | 381 | } |
| 378 | 382 | ||
| 379 | /* Configure Tx/Rx FIFO threshold levels */ | 383 | /* Configure Tx/Rx FIFO threshold levels */ |
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 52407f3c9e1c..9bd849dacee8 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c | |||
| @@ -378,7 +378,7 @@ static void rcar_i2c_dma(struct rcar_i2c_priv *priv) | |||
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | dma_addr = dma_map_single(chan->device->dev, buf, len, dir); | 380 | dma_addr = dma_map_single(chan->device->dev, buf, len, dir); |
| 381 | if (dma_mapping_error(dev, dma_addr)) { | 381 | if (dma_mapping_error(chan->device->dev, dma_addr)) { |
| 382 | dev_dbg(dev, "dma map failed, using PIO\n"); | 382 | dev_dbg(dev, "dma map failed, using PIO\n"); |
| 383 | return; | 383 | return; |
| 384 | } | 384 | } |
diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index 2bc8b01153d6..5c5b7cada8be 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c | |||
| @@ -918,7 +918,7 @@ static void rk3x_i2c_adapt_div(struct rk3x_i2c *i2c, unsigned long clk_rate) | |||
| 918 | * Code adapted from i2c-cadence.c. | 918 | * Code adapted from i2c-cadence.c. |
| 919 | * | 919 | * |
| 920 | * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK | 920 | * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK |
| 921 | * to acknowedge the change, NOTIFY_DONE if the notification is | 921 | * to acknowledge the change, NOTIFY_DONE if the notification is |
| 922 | * considered irrelevant. | 922 | * considered irrelevant. |
| 923 | */ | 923 | */ |
| 924 | static int rk3x_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long | 924 | static int rk3x_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long |
| @@ -1111,6 +1111,15 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap, | |||
| 1111 | return ret < 0 ? ret : num; | 1111 | return ret < 0 ? ret : num; |
| 1112 | } | 1112 | } |
| 1113 | 1113 | ||
| 1114 | static __maybe_unused int rk3x_i2c_resume(struct device *dev) | ||
| 1115 | { | ||
| 1116 | struct rk3x_i2c *i2c = dev_get_drvdata(dev); | ||
| 1117 | |||
| 1118 | rk3x_i2c_adapt_div(i2c, clk_get_rate(i2c->clk)); | ||
| 1119 | |||
| 1120 | return 0; | ||
| 1121 | } | ||
| 1122 | |||
| 1114 | static u32 rk3x_i2c_func(struct i2c_adapter *adap) | 1123 | static u32 rk3x_i2c_func(struct i2c_adapter *adap) |
| 1115 | { | 1124 | { |
| 1116 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING; | 1125 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING; |
| @@ -1334,12 +1343,15 @@ static int rk3x_i2c_remove(struct platform_device *pdev) | |||
| 1334 | return 0; | 1343 | return 0; |
| 1335 | } | 1344 | } |
| 1336 | 1345 | ||
| 1346 | static SIMPLE_DEV_PM_OPS(rk3x_i2c_pm_ops, NULL, rk3x_i2c_resume); | ||
| 1347 | |||
| 1337 | static struct platform_driver rk3x_i2c_driver = { | 1348 | static struct platform_driver rk3x_i2c_driver = { |
| 1338 | .probe = rk3x_i2c_probe, | 1349 | .probe = rk3x_i2c_probe, |
| 1339 | .remove = rk3x_i2c_remove, | 1350 | .remove = rk3x_i2c_remove, |
| 1340 | .driver = { | 1351 | .driver = { |
| 1341 | .name = "rk3x-i2c", | 1352 | .name = "rk3x-i2c", |
| 1342 | .of_match_table = rk3x_i2c_match, | 1353 | .of_match_table = rk3x_i2c_match, |
| 1354 | .pm = &rk3x_i2c_pm_ops, | ||
| 1343 | }, | 1355 | }, |
| 1344 | }; | 1356 | }; |
| 1345 | 1357 | ||
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 6fb3e2645992..05b1eeab9cf5 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c | |||
| @@ -610,7 +610,7 @@ static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd) | |||
| 610 | return; | 610 | return; |
| 611 | 611 | ||
| 612 | dma_addr = dma_map_single(chan->device->dev, pd->msg->buf, pd->msg->len, dir); | 612 | dma_addr = dma_map_single(chan->device->dev, pd->msg->buf, pd->msg->len, dir); |
| 613 | if (dma_mapping_error(pd->dev, dma_addr)) { | 613 | if (dma_mapping_error(chan->device->dev, dma_addr)) { |
| 614 | dev_dbg(pd->dev, "dma map failed, using PIO\n"); | 614 | dev_dbg(pd->dev, "dma map failed, using PIO\n"); |
| 615 | return; | 615 | return; |
| 616 | } | 616 | } |
diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c index 215ac87f606d..b3893f6282ba 100644 --- a/drivers/i2c/muxes/i2c-demux-pinctrl.c +++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c | |||
| @@ -37,8 +37,6 @@ struct i2c_demux_pinctrl_priv { | |||
| 37 | struct i2c_demux_pinctrl_chan chan[]; | 37 | struct i2c_demux_pinctrl_chan chan[]; |
| 38 | }; | 38 | }; |
| 39 | 39 | ||
| 40 | static struct property status_okay = { .name = "status", .length = 3, .value = "ok" }; | ||
| 41 | |||
| 42 | static int i2c_demux_master_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) | 40 | static int i2c_demux_master_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) |
| 43 | { | 41 | { |
| 44 | struct i2c_demux_pinctrl_priv *priv = adap->algo_data; | 42 | struct i2c_demux_pinctrl_priv *priv = adap->algo_data; |
| @@ -107,6 +105,7 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne | |||
| 107 | of_changeset_revert(&priv->chan[new_chan].chgset); | 105 | of_changeset_revert(&priv->chan[new_chan].chgset); |
| 108 | err: | 106 | err: |
| 109 | dev_err(priv->dev, "failed to setup demux-adapter %d (%d)\n", new_chan, ret); | 107 | dev_err(priv->dev, "failed to setup demux-adapter %d (%d)\n", new_chan, ret); |
| 108 | priv->cur_chan = -EINVAL; | ||
| 110 | return ret; | 109 | return ret; |
| 111 | } | 110 | } |
| 112 | 111 | ||
| @@ -192,6 +191,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev) | |||
| 192 | { | 191 | { |
| 193 | struct device_node *np = pdev->dev.of_node; | 192 | struct device_node *np = pdev->dev.of_node; |
| 194 | struct i2c_demux_pinctrl_priv *priv; | 193 | struct i2c_demux_pinctrl_priv *priv; |
| 194 | struct property *props; | ||
| 195 | int num_chan, i, j, err; | 195 | int num_chan, i, j, err; |
| 196 | 196 | ||
| 197 | num_chan = of_count_phandle_with_args(np, "i2c-parent", NULL); | 197 | num_chan = of_count_phandle_with_args(np, "i2c-parent", NULL); |
| @@ -202,7 +202,10 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev) | |||
| 202 | 202 | ||
| 203 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv) | 203 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv) |
| 204 | + num_chan * sizeof(struct i2c_demux_pinctrl_chan), GFP_KERNEL); | 204 | + num_chan * sizeof(struct i2c_demux_pinctrl_chan), GFP_KERNEL); |
| 205 | if (!priv) | 205 | |
| 206 | props = devm_kcalloc(&pdev->dev, num_chan, sizeof(*props), GFP_KERNEL); | ||
| 207 | |||
| 208 | if (!priv || !props) | ||
| 206 | return -ENOMEM; | 209 | return -ENOMEM; |
| 207 | 210 | ||
| 208 | err = of_property_read_string(np, "i2c-bus-name", &priv->bus_name); | 211 | err = of_property_read_string(np, "i2c-bus-name", &priv->bus_name); |
| @@ -220,8 +223,12 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev) | |||
| 220 | } | 223 | } |
| 221 | priv->chan[i].parent_np = adap_np; | 224 | priv->chan[i].parent_np = adap_np; |
| 222 | 225 | ||
| 226 | props[i].name = devm_kstrdup(&pdev->dev, "status", GFP_KERNEL); | ||
| 227 | props[i].value = devm_kstrdup(&pdev->dev, "ok", GFP_KERNEL); | ||
| 228 | props[i].length = 3; | ||
| 229 | |||
| 223 | of_changeset_init(&priv->chan[i].chgset); | 230 | of_changeset_init(&priv->chan[i].chgset); |
| 224 | of_changeset_update_property(&priv->chan[i].chgset, adap_np, &status_okay); | 231 | of_changeset_update_property(&priv->chan[i].chgset, adap_np, &props[i]); |
| 225 | } | 232 | } |
| 226 | 233 | ||
| 227 | priv->num_chan = num_chan; | 234 | priv->num_chan = num_chan; |
diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index 89d78208de3f..78f148ea9d9f 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig | |||
| @@ -20,6 +20,8 @@ config BMA180 | |||
| 20 | config BMA220 | 20 | config BMA220 |
| 21 | tristate "Bosch BMA220 3-Axis Accelerometer Driver" | 21 | tristate "Bosch BMA220 3-Axis Accelerometer Driver" |
| 22 | depends on SPI | 22 | depends on SPI |
| 23 | select IIO_BUFFER | ||
| 24 | select IIO_TRIGGERED_BUFFER | ||
| 23 | help | 25 | help |
| 24 | Say yes here to add support for the Bosch BMA220 triaxial | 26 | Say yes here to add support for the Bosch BMA220 triaxial |
| 25 | acceleration sensor. | 27 | acceleration sensor. |
| @@ -234,7 +236,8 @@ config STK8312 | |||
| 234 | config STK8BA50 | 236 | config STK8BA50 |
| 235 | tristate "Sensortek STK8BA50 3-Axis Accelerometer Driver" | 237 | tristate "Sensortek STK8BA50 3-Axis Accelerometer Driver" |
| 236 | depends on I2C | 238 | depends on I2C |
| 237 | depends on IIO_TRIGGER | 239 | select IIO_BUFFER |
| 240 | select IIO_TRIGGERED_BUFFER | ||
| 238 | help | 241 | help |
| 239 | Say yes here to get support for the Sensortek STK8BA50 3-axis | 242 | Say yes here to get support for the Sensortek STK8BA50 3-axis |
| 240 | accelerometer. | 243 | accelerometer. |
diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index 1098d10df8e8..5099f295dd37 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c | |||
| @@ -253,7 +253,7 @@ static int bma220_probe(struct spi_device *spi) | |||
| 253 | if (ret < 0) | 253 | if (ret < 0) |
| 254 | return ret; | 254 | return ret; |
| 255 | 255 | ||
| 256 | ret = iio_triggered_buffer_setup(indio_dev, NULL, | 256 | ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time, |
| 257 | bma220_trigger_handler, NULL); | 257 | bma220_trigger_handler, NULL); |
| 258 | if (ret < 0) { | 258 | if (ret < 0) { |
| 259 | dev_err(&spi->dev, "iio triggered buffer setup failed\n"); | 259 | dev_err(&spi->dev, "iio triggered buffer setup failed\n"); |
diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index bf17aae66145..59b380dbf27f 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c | |||
| @@ -67,6 +67,9 @@ | |||
| 67 | #define BMC150_ACCEL_REG_PMU_BW 0x10 | 67 | #define BMC150_ACCEL_REG_PMU_BW 0x10 |
| 68 | #define BMC150_ACCEL_DEF_BW 125 | 68 | #define BMC150_ACCEL_DEF_BW 125 |
| 69 | 69 | ||
| 70 | #define BMC150_ACCEL_REG_RESET 0x14 | ||
| 71 | #define BMC150_ACCEL_RESET_VAL 0xB6 | ||
| 72 | |||
| 70 | #define BMC150_ACCEL_REG_INT_MAP_0 0x19 | 73 | #define BMC150_ACCEL_REG_INT_MAP_0 0x19 |
| 71 | #define BMC150_ACCEL_INT_MAP_0_BIT_SLOPE BIT(2) | 74 | #define BMC150_ACCEL_INT_MAP_0_BIT_SLOPE BIT(2) |
| 72 | 75 | ||
| @@ -1497,6 +1500,14 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data) | |||
| 1497 | int ret, i; | 1500 | int ret, i; |
| 1498 | unsigned int val; | 1501 | unsigned int val; |
| 1499 | 1502 | ||
| 1503 | /* | ||
| 1504 | * Reset chip to get it in a known good state. A delay of 1.8ms after | ||
| 1505 | * reset is required according to the data sheets of supported chips. | ||
| 1506 | */ | ||
| 1507 | regmap_write(data->regmap, BMC150_ACCEL_REG_RESET, | ||
| 1508 | BMC150_ACCEL_RESET_VAL); | ||
| 1509 | usleep_range(1800, 2500); | ||
| 1510 | |||
| 1500 | ret = regmap_read(data->regmap, BMC150_ACCEL_REG_CHIP_ID, &val); | 1511 | ret = regmap_read(data->regmap, BMC150_ACCEL_REG_CHIP_ID, &val); |
| 1501 | if (ret < 0) { | 1512 | if (ret < 0) { |
| 1502 | dev_err(dev, "Error: Reading chip id\n"); | 1513 | dev_err(dev, "Error: Reading chip id\n"); |
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index 3a9f106787d2..9d72d4bcf5e9 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c | |||
| @@ -160,11 +160,13 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev, | |||
| 160 | if (ret < 0) | 160 | if (ret < 0) |
| 161 | goto error_ret; | 161 | goto error_ret; |
| 162 | *val = ret; | 162 | *val = ret; |
| 163 | ret = IIO_VAL_INT; | ||
| 163 | break; | 164 | break; |
| 164 | case IIO_CHAN_INFO_SCALE: | 165 | case IIO_CHAN_INFO_SCALE: |
| 165 | ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); | 166 | ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); |
| 166 | if (ret < 0) | 167 | if (ret < 0) |
| 167 | goto error_ret; | 168 | goto error_ret; |
| 169 | *val = 0; | ||
| 168 | *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK]; | 170 | *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK]; |
| 169 | ret = IIO_VAL_INT_PLUS_MICRO; | 171 | ret = IIO_VAL_INT_PLUS_MICRO; |
| 170 | break; | 172 | break; |
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 1de31bdd4ce4..767577298ee3 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig | |||
| @@ -389,6 +389,7 @@ config QCOM_SPMI_VADC | |||
| 389 | config ROCKCHIP_SARADC | 389 | config ROCKCHIP_SARADC |
| 390 | tristate "Rockchip SARADC driver" | 390 | tristate "Rockchip SARADC driver" |
| 391 | depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST) | 391 | depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST) |
| 392 | depends on RESET_CONTROLLER | ||
| 392 | help | 393 | help |
| 393 | Say yes here to build support for the SARADC found in SoCs from | 394 | Say yes here to build support for the SARADC found in SoCs from |
| 394 | Rockchip. | 395 | Rockchip. |
diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index b6163764489c..9704090b7908 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c | |||
| @@ -527,6 +527,7 @@ static struct attribute_group ad799x_event_attrs_group = { | |||
| 527 | static const struct iio_info ad7991_info = { | 527 | static const struct iio_info ad7991_info = { |
| 528 | .read_raw = &ad799x_read_raw, | 528 | .read_raw = &ad799x_read_raw, |
| 529 | .driver_module = THIS_MODULE, | 529 | .driver_module = THIS_MODULE, |
| 530 | .update_scan_mode = ad799x_update_scan_mode, | ||
| 530 | }; | 531 | }; |
| 531 | 532 | ||
| 532 | static const struct iio_info ad7993_4_7_8_noirq_info = { | 533 | static const struct iio_info ad7993_4_7_8_noirq_info = { |
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 52430ba171f3..0438c68015e8 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c | |||
| @@ -381,8 +381,8 @@ static irqreturn_t at91_adc_rl_interrupt(int irq, void *private) | |||
| 381 | st->ts_bufferedmeasure = false; | 381 | st->ts_bufferedmeasure = false; |
| 382 | input_report_key(st->ts_input, BTN_TOUCH, 0); | 382 | input_report_key(st->ts_input, BTN_TOUCH, 0); |
| 383 | input_sync(st->ts_input); | 383 | input_sync(st->ts_input); |
| 384 | } else if (status & AT91_ADC_EOC(3)) { | 384 | } else if (status & AT91_ADC_EOC(3) && st->ts_input) { |
| 385 | /* Conversion finished */ | 385 | /* Conversion finished and we've a touchscreen */ |
| 386 | if (st->ts_bufferedmeasure) { | 386 | if (st->ts_bufferedmeasure) { |
| 387 | /* | 387 | /* |
| 388 | * Last measurement is always discarded, since it can | 388 | * Last measurement is always discarded, since it can |
diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c index f9ad6c2d6821..85d701291654 100644 --- a/drivers/iio/adc/rockchip_saradc.c +++ b/drivers/iio/adc/rockchip_saradc.c | |||
| @@ -21,6 +21,8 @@ | |||
| 21 | #include <linux/of_device.h> | 21 | #include <linux/of_device.h> |
| 22 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
| 23 | #include <linux/completion.h> | 23 | #include <linux/completion.h> |
| 24 | #include <linux/delay.h> | ||
| 25 | #include <linux/reset.h> | ||
| 24 | #include <linux/regulator/consumer.h> | 26 | #include <linux/regulator/consumer.h> |
| 25 | #include <linux/iio/iio.h> | 27 | #include <linux/iio/iio.h> |
| 26 | 28 | ||
| @@ -53,6 +55,7 @@ struct rockchip_saradc { | |||
| 53 | struct clk *clk; | 55 | struct clk *clk; |
| 54 | struct completion completion; | 56 | struct completion completion; |
| 55 | struct regulator *vref; | 57 | struct regulator *vref; |
| 58 | struct reset_control *reset; | ||
| 56 | const struct rockchip_saradc_data *data; | 59 | const struct rockchip_saradc_data *data; |
| 57 | u16 last_val; | 60 | u16 last_val; |
| 58 | }; | 61 | }; |
| @@ -190,6 +193,16 @@ static const struct of_device_id rockchip_saradc_match[] = { | |||
| 190 | }; | 193 | }; |
| 191 | MODULE_DEVICE_TABLE(of, rockchip_saradc_match); | 194 | MODULE_DEVICE_TABLE(of, rockchip_saradc_match); |
| 192 | 195 | ||
| 196 | /** | ||
| 197 | * Reset SARADC Controller. | ||
| 198 | */ | ||
| 199 | static void rockchip_saradc_reset_controller(struct reset_control *reset) | ||
| 200 | { | ||
| 201 | reset_control_assert(reset); | ||
| 202 | usleep_range(10, 20); | ||
| 203 | reset_control_deassert(reset); | ||
| 204 | } | ||
| 205 | |||
| 193 | static int rockchip_saradc_probe(struct platform_device *pdev) | 206 | static int rockchip_saradc_probe(struct platform_device *pdev) |
| 194 | { | 207 | { |
| 195 | struct rockchip_saradc *info = NULL; | 208 | struct rockchip_saradc *info = NULL; |
| @@ -218,6 +231,20 @@ static int rockchip_saradc_probe(struct platform_device *pdev) | |||
| 218 | if (IS_ERR(info->regs)) | 231 | if (IS_ERR(info->regs)) |
| 219 | return PTR_ERR(info->regs); | 232 | return PTR_ERR(info->regs); |
| 220 | 233 | ||
| 234 | /* | ||
| 235 | * The reset should be an optional property, as it should work | ||
| 236 | * with old devicetrees as well | ||
| 237 | */ | ||
| 238 | info->reset = devm_reset_control_get(&pdev->dev, "saradc-apb"); | ||
| 239 | if (IS_ERR(info->reset)) { | ||
| 240 | ret = PTR_ERR(info->reset); | ||
| 241 | if (ret != -ENOENT) | ||
| 242 | return ret; | ||
| 243 | |||
| 244 | dev_dbg(&pdev->dev, "no reset control found\n"); | ||
| 245 | info->reset = NULL; | ||
| 246 | } | ||
| 247 | |||
| 221 | init_completion(&info->completion); | 248 | init_completion(&info->completion); |
| 222 | 249 | ||
| 223 | irq = platform_get_irq(pdev, 0); | 250 | irq = platform_get_irq(pdev, 0); |
| @@ -252,6 +279,9 @@ static int rockchip_saradc_probe(struct platform_device *pdev) | |||
| 252 | return PTR_ERR(info->vref); | 279 | return PTR_ERR(info->vref); |
| 253 | } | 280 | } |
| 254 | 281 | ||
| 282 | if (info->reset) | ||
| 283 | rockchip_saradc_reset_controller(info->reset); | ||
| 284 | |||
| 255 | /* | 285 | /* |
| 256 | * Use a default value for the converter clock. | 286 | * Use a default value for the converter clock. |
| 257 | * This may become user-configurable in the future. | 287 | * This may become user-configurable in the future. |
diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index 1ef398770a1f..066abaf80201 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c | |||
| @@ -489,7 +489,8 @@ static struct iio_info ads1115_info = { | |||
| 489 | #ifdef CONFIG_OF | 489 | #ifdef CONFIG_OF |
| 490 | static int ads1015_get_channels_config_of(struct i2c_client *client) | 490 | static int ads1015_get_channels_config_of(struct i2c_client *client) |
| 491 | { | 491 | { |
| 492 | struct ads1015_data *data = i2c_get_clientdata(client); | 492 | struct iio_dev *indio_dev = i2c_get_clientdata(client); |
| 493 | struct ads1015_data *data = iio_priv(indio_dev); | ||
| 493 | struct device_node *node; | 494 | struct device_node *node; |
| 494 | 495 | ||
| 495 | if (!client->dev.of_node || | 496 | if (!client->dev.of_node || |
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 8a368756881b..c3cfacca2541 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | struct tiadc_device { | 33 | struct tiadc_device { |
| 34 | struct ti_tscadc_dev *mfd_tscadc; | 34 | struct ti_tscadc_dev *mfd_tscadc; |
| 35 | struct mutex fifo1_lock; /* to protect fifo access */ | ||
| 35 | int channels; | 36 | int channels; |
| 36 | u8 channel_line[8]; | 37 | u8 channel_line[8]; |
| 37 | u8 channel_step[8]; | 38 | u8 channel_step[8]; |
| @@ -359,6 +360,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, | |||
| 359 | int *val, int *val2, long mask) | 360 | int *val, int *val2, long mask) |
| 360 | { | 361 | { |
| 361 | struct tiadc_device *adc_dev = iio_priv(indio_dev); | 362 | struct tiadc_device *adc_dev = iio_priv(indio_dev); |
| 363 | int ret = IIO_VAL_INT; | ||
| 362 | int i, map_val; | 364 | int i, map_val; |
| 363 | unsigned int fifo1count, read, stepid; | 365 | unsigned int fifo1count, read, stepid; |
| 364 | bool found = false; | 366 | bool found = false; |
| @@ -372,13 +374,14 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, | |||
| 372 | if (!step_en) | 374 | if (!step_en) |
| 373 | return -EINVAL; | 375 | return -EINVAL; |
| 374 | 376 | ||
| 377 | mutex_lock(&adc_dev->fifo1_lock); | ||
| 375 | fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); | 378 | fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); |
| 376 | while (fifo1count--) | 379 | while (fifo1count--) |
| 377 | tiadc_readl(adc_dev, REG_FIFO1); | 380 | tiadc_readl(adc_dev, REG_FIFO1); |
| 378 | 381 | ||
| 379 | am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en); | 382 | am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en); |
| 380 | 383 | ||
| 381 | timeout = jiffies + usecs_to_jiffies | 384 | timeout = jiffies + msecs_to_jiffies |
| 382 | (IDLE_TIMEOUT * adc_dev->channels); | 385 | (IDLE_TIMEOUT * adc_dev->channels); |
| 383 | /* Wait for Fifo threshold interrupt */ | 386 | /* Wait for Fifo threshold interrupt */ |
| 384 | while (1) { | 387 | while (1) { |
| @@ -388,7 +391,8 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, | |||
| 388 | 391 | ||
| 389 | if (time_after(jiffies, timeout)) { | 392 | if (time_after(jiffies, timeout)) { |
| 390 | am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); | 393 | am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); |
| 391 | return -EAGAIN; | 394 | ret = -EAGAIN; |
| 395 | goto err_unlock; | ||
| 392 | } | 396 | } |
| 393 | } | 397 | } |
| 394 | map_val = adc_dev->channel_step[chan->scan_index]; | 398 | map_val = adc_dev->channel_step[chan->scan_index]; |
| @@ -414,8 +418,11 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, | |||
| 414 | am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); | 418 | am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); |
| 415 | 419 | ||
| 416 | if (found == false) | 420 | if (found == false) |
| 417 | return -EBUSY; | 421 | ret = -EBUSY; |
| 418 | return IIO_VAL_INT; | 422 | |
| 423 | err_unlock: | ||
| 424 | mutex_unlock(&adc_dev->fifo1_lock); | ||
| 425 | return ret; | ||
| 419 | } | 426 | } |
| 420 | 427 | ||
| 421 | static const struct iio_info tiadc_info = { | 428 | static const struct iio_info tiadc_info = { |
| @@ -483,6 +490,7 @@ static int tiadc_probe(struct platform_device *pdev) | |||
| 483 | 490 | ||
| 484 | tiadc_step_config(indio_dev); | 491 | tiadc_step_config(indio_dev); |
| 485 | tiadc_writel(adc_dev, REG_FIFO1THR, FIFO1_THRESHOLD); | 492 | tiadc_writel(adc_dev, REG_FIFO1THR, FIFO1_THRESHOLD); |
| 493 | mutex_init(&adc_dev->fifo1_lock); | ||
| 486 | 494 | ||
| 487 | err = tiadc_channel_init(indio_dev, adc_dev->channels); | 495 | err = tiadc_channel_init(indio_dev, adc_dev->channels); |
| 488 | if (err < 0) | 496 | if (err < 0) |
diff --git a/drivers/iio/chemical/atlas-ph-sensor.c b/drivers/iio/chemical/atlas-ph-sensor.c index ae038a59d256..407f141a1eee 100644 --- a/drivers/iio/chemical/atlas-ph-sensor.c +++ b/drivers/iio/chemical/atlas-ph-sensor.c | |||
| @@ -434,7 +434,7 @@ static int atlas_read_raw(struct iio_dev *indio_dev, | |||
| 434 | break; | 434 | break; |
| 435 | case IIO_ELECTRICALCONDUCTIVITY: | 435 | case IIO_ELECTRICALCONDUCTIVITY: |
| 436 | *val = 1; /* 0.00001 */ | 436 | *val = 1; /* 0.00001 */ |
| 437 | *val = 100000; | 437 | *val2 = 100000; |
| 438 | break; | 438 | break; |
| 439 | case IIO_CONCENTRATION: | 439 | case IIO_CONCENTRATION: |
| 440 | *val = 0; /* 0.000000001 */ | 440 | *val = 0; /* 0.000000001 */ |
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c index e81f434760f4..dc33c1dd5191 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c | |||
| @@ -56,8 +56,8 @@ static struct { | |||
| 56 | {HID_USAGE_SENSOR_ALS, 0, 1, 0}, | 56 | {HID_USAGE_SENSOR_ALS, 0, 1, 0}, |
| 57 | {HID_USAGE_SENSOR_ALS, HID_USAGE_SENSOR_UNITS_LUX, 1, 0}, | 57 | {HID_USAGE_SENSOR_ALS, HID_USAGE_SENSOR_UNITS_LUX, 1, 0}, |
| 58 | 58 | ||
| 59 | {HID_USAGE_SENSOR_PRESSURE, 0, 100000, 0}, | 59 | {HID_USAGE_SENSOR_PRESSURE, 0, 100, 0}, |
| 60 | {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 1, 0}, | 60 | {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000}, |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | static int pow_10(unsigned power) | 63 | static int pow_10(unsigned power) |
diff --git a/drivers/iio/dac/stx104.c b/drivers/iio/dac/stx104.c index 792a97164cb2..bebbd00304ce 100644 --- a/drivers/iio/dac/stx104.c +++ b/drivers/iio/dac/stx104.c | |||
| @@ -65,6 +65,16 @@ struct stx104_gpio { | |||
| 65 | unsigned int out_state; | 65 | unsigned int out_state; |
| 66 | }; | 66 | }; |
| 67 | 67 | ||
| 68 | /** | ||
| 69 | * struct stx104_dev - STX104 device private data structure | ||
| 70 | * @indio_dev: IIO device | ||
| 71 | * @chip: instance of the gpio_chip | ||
| 72 | */ | ||
| 73 | struct stx104_dev { | ||
| 74 | struct iio_dev *indio_dev; | ||
| 75 | struct gpio_chip *chip; | ||
| 76 | }; | ||
| 77 | |||
| 68 | static int stx104_read_raw(struct iio_dev *indio_dev, | 78 | static int stx104_read_raw(struct iio_dev *indio_dev, |
| 69 | struct iio_chan_spec const *chan, int *val, int *val2, long mask) | 79 | struct iio_chan_spec const *chan, int *val, int *val2, long mask) |
| 70 | { | 80 | { |
| @@ -107,6 +117,7 @@ static const struct iio_chan_spec stx104_channels[STX104_NUM_CHAN] = { | |||
| 107 | static int stx104_gpio_get_direction(struct gpio_chip *chip, | 117 | static int stx104_gpio_get_direction(struct gpio_chip *chip, |
| 108 | unsigned int offset) | 118 | unsigned int offset) |
| 109 | { | 119 | { |
| 120 | /* GPIO 0-3 are input only, while the rest are output only */ | ||
| 110 | if (offset < 4) | 121 | if (offset < 4) |
| 111 | return 1; | 122 | return 1; |
| 112 | 123 | ||
| @@ -169,6 +180,7 @@ static int stx104_probe(struct device *dev, unsigned int id) | |||
| 169 | struct iio_dev *indio_dev; | 180 | struct iio_dev *indio_dev; |
| 170 | struct stx104_iio *priv; | 181 | struct stx104_iio *priv; |
| 171 | struct stx104_gpio *stx104gpio; | 182 | struct stx104_gpio *stx104gpio; |
| 183 | struct stx104_dev *stx104dev; | ||
| 172 | int err; | 184 | int err; |
| 173 | 185 | ||
| 174 | indio_dev = devm_iio_device_alloc(dev, sizeof(*priv)); | 186 | indio_dev = devm_iio_device_alloc(dev, sizeof(*priv)); |
| @@ -179,6 +191,10 @@ static int stx104_probe(struct device *dev, unsigned int id) | |||
| 179 | if (!stx104gpio) | 191 | if (!stx104gpio) |
| 180 | return -ENOMEM; | 192 | return -ENOMEM; |
| 181 | 193 | ||
| 194 | stx104dev = devm_kzalloc(dev, sizeof(*stx104dev), GFP_KERNEL); | ||
| 195 | if (!stx104dev) | ||
| 196 | return -ENOMEM; | ||
| 197 | |||
| 182 | if (!devm_request_region(dev, base[id], STX104_EXTENT, | 198 | if (!devm_request_region(dev, base[id], STX104_EXTENT, |
| 183 | dev_name(dev))) { | 199 | dev_name(dev))) { |
| 184 | dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", | 200 | dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", |
| @@ -199,12 +215,6 @@ static int stx104_probe(struct device *dev, unsigned int id) | |||
| 199 | outw(0, base[id] + 4); | 215 | outw(0, base[id] + 4); |
| 200 | outw(0, base[id] + 6); | 216 | outw(0, base[id] + 6); |
| 201 | 217 | ||
| 202 | err = devm_iio_device_register(dev, indio_dev); | ||
| 203 | if (err) { | ||
| 204 | dev_err(dev, "IIO device registering failed (%d)\n", err); | ||
| 205 | return err; | ||
| 206 | } | ||
| 207 | |||
| 208 | stx104gpio->chip.label = dev_name(dev); | 218 | stx104gpio->chip.label = dev_name(dev); |
| 209 | stx104gpio->chip.parent = dev; | 219 | stx104gpio->chip.parent = dev; |
| 210 | stx104gpio->chip.owner = THIS_MODULE; | 220 | stx104gpio->chip.owner = THIS_MODULE; |
| @@ -220,7 +230,9 @@ static int stx104_probe(struct device *dev, unsigned int id) | |||
| 220 | 230 | ||
| 221 | spin_lock_init(&stx104gpio->lock); | 231 | spin_lock_init(&stx104gpio->lock); |
| 222 | 232 | ||
| 223 | dev_set_drvdata(dev, stx104gpio); | 233 | stx104dev->indio_dev = indio_dev; |
| 234 | stx104dev->chip = &stx104gpio->chip; | ||
| 235 | dev_set_drvdata(dev, stx104dev); | ||
| 224 | 236 | ||
| 225 | err = gpiochip_add_data(&stx104gpio->chip, stx104gpio); | 237 | err = gpiochip_add_data(&stx104gpio->chip, stx104gpio); |
| 226 | if (err) { | 238 | if (err) { |
| @@ -228,14 +240,22 @@ static int stx104_probe(struct device *dev, unsigned int id) | |||
| 228 | return err; | 240 | return err; |
| 229 | } | 241 | } |
| 230 | 242 | ||
| 243 | err = iio_device_register(indio_dev); | ||
| 244 | if (err) { | ||
| 245 | dev_err(dev, "IIO device registering failed (%d)\n", err); | ||
| 246 | gpiochip_remove(&stx104gpio->chip); | ||
| 247 | return err; | ||
| 248 | } | ||
| 249 | |||
| 231 | return 0; | 250 | return 0; |
| 232 | } | 251 | } |
| 233 | 252 | ||
| 234 | static int stx104_remove(struct device *dev, unsigned int id) | 253 | static int stx104_remove(struct device *dev, unsigned int id) |
| 235 | { | 254 | { |
| 236 | struct stx104_gpio *const stx104gpio = dev_get_drvdata(dev); | 255 | struct stx104_dev *const stx104dev = dev_get_drvdata(dev); |
| 237 | 256 | ||
| 238 | gpiochip_remove(&stx104gpio->chip); | 257 | iio_device_unregister(stx104dev->indio_dev); |
| 258 | gpiochip_remove(stx104dev->chip); | ||
| 239 | 259 | ||
| 240 | return 0; | 260 | return 0; |
| 241 | } | 261 | } |
diff --git a/drivers/iio/humidity/Kconfig b/drivers/iio/humidity/Kconfig index 738a86d9e4a9..d04124345992 100644 --- a/drivers/iio/humidity/Kconfig +++ b/drivers/iio/humidity/Kconfig | |||
| @@ -6,6 +6,8 @@ menu "Humidity sensors" | |||
| 6 | config AM2315 | 6 | config AM2315 |
| 7 | tristate "Aosong AM2315 relative humidity and temperature sensor" | 7 | tristate "Aosong AM2315 relative humidity and temperature sensor" |
| 8 | depends on I2C | 8 | depends on I2C |
| 9 | select IIO_BUFFER | ||
| 10 | select IIO_TRIGGERED_BUFFER | ||
| 9 | help | 11 | help |
| 10 | If you say yes here you get support for the Aosong AM2315 | 12 | If you say yes here you get support for the Aosong AM2315 |
| 11 | relative humidity and ambient temperature sensor. | 13 | relative humidity and ambient temperature sensor. |
diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c index 3e200f69e886..ff96b6d0fdae 100644 --- a/drivers/iio/humidity/am2315.c +++ b/drivers/iio/humidity/am2315.c | |||
| @@ -244,7 +244,7 @@ static int am2315_probe(struct i2c_client *client, | |||
| 244 | indio_dev->channels = am2315_channels; | 244 | indio_dev->channels = am2315_channels; |
| 245 | indio_dev->num_channels = ARRAY_SIZE(am2315_channels); | 245 | indio_dev->num_channels = ARRAY_SIZE(am2315_channels); |
| 246 | 246 | ||
| 247 | ret = iio_triggered_buffer_setup(indio_dev, NULL, | 247 | ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time, |
| 248 | am2315_trigger_handler, NULL); | 248 | am2315_trigger_handler, NULL); |
| 249 | if (ret < 0) { | 249 | if (ret < 0) { |
| 250 | dev_err(&client->dev, "iio triggered buffer setup failed\n"); | 250 | dev_err(&client->dev, "iio triggered buffer setup failed\n"); |
diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c index a03832a5fc95..e0c9c70c2a4a 100644 --- a/drivers/iio/humidity/hdc100x.c +++ b/drivers/iio/humidity/hdc100x.c | |||
| @@ -142,7 +142,7 @@ static int hdc100x_get_measurement(struct hdc100x_data *data, | |||
| 142 | struct i2c_client *client = data->client; | 142 | struct i2c_client *client = data->client; |
| 143 | int delay = data->adc_int_us[chan->address]; | 143 | int delay = data->adc_int_us[chan->address]; |
| 144 | int ret; | 144 | int ret; |
| 145 | int val; | 145 | __be16 val; |
| 146 | 146 | ||
| 147 | /* start measurement */ | 147 | /* start measurement */ |
| 148 | ret = i2c_smbus_write_byte(client, chan->address); | 148 | ret = i2c_smbus_write_byte(client, chan->address); |
| @@ -154,26 +154,13 @@ static int hdc100x_get_measurement(struct hdc100x_data *data, | |||
| 154 | /* wait for integration time to pass */ | 154 | /* wait for integration time to pass */ |
| 155 | usleep_range(delay, delay + 1000); | 155 | usleep_range(delay, delay + 1000); |
| 156 | 156 | ||
| 157 | /* | 157 | /* read measurement */ |
| 158 | * i2c_smbus_read_word_data cannot() be used here due to the command | 158 | ret = i2c_master_recv(data->client, (char *)&val, sizeof(val)); |
| 159 | * value not being understood and causes NAKs preventing any reading | ||
| 160 | * from being accessed. | ||
| 161 | */ | ||
| 162 | ret = i2c_smbus_read_byte(client); | ||
| 163 | if (ret < 0) { | 159 | if (ret < 0) { |
| 164 | dev_err(&client->dev, "cannot read high byte measurement"); | 160 | dev_err(&client->dev, "cannot read sensor data\n"); |
| 165 | return ret; | 161 | return ret; |
| 166 | } | 162 | } |
| 167 | val = ret << 8; | 163 | return be16_to_cpu(val); |
| 168 | |||
| 169 | ret = i2c_smbus_read_byte(client); | ||
| 170 | if (ret < 0) { | ||
| 171 | dev_err(&client->dev, "cannot read low byte measurement"); | ||
| 172 | return ret; | ||
| 173 | } | ||
| 174 | val |= ret; | ||
| 175 | |||
| 176 | return val; | ||
| 177 | } | 164 | } |
| 178 | 165 | ||
| 179 | static int hdc100x_get_heater_status(struct hdc100x_data *data) | 166 | static int hdc100x_get_heater_status(struct hdc100x_data *data) |
| @@ -272,8 +259,8 @@ static int hdc100x_probe(struct i2c_client *client, | |||
| 272 | struct iio_dev *indio_dev; | 259 | struct iio_dev *indio_dev; |
| 273 | struct hdc100x_data *data; | 260 | struct hdc100x_data *data; |
| 274 | 261 | ||
| 275 | if (!i2c_check_functionality(client->adapter, | 262 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA | |
| 276 | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BYTE)) | 263 | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_I2C)) |
| 277 | return -EOPNOTSUPP; | 264 | return -EOPNOTSUPP; |
| 278 | 265 | ||
| 279 | indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); | 266 | indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); |
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 90462fcf5436..158aaf44dd95 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c | |||
| @@ -107,9 +107,10 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, | |||
| 107 | { | 107 | { |
| 108 | struct iio_dev *indio_dev = filp->private_data; | 108 | struct iio_dev *indio_dev = filp->private_data; |
| 109 | struct iio_buffer *rb = indio_dev->buffer; | 109 | struct iio_buffer *rb = indio_dev->buffer; |
| 110 | DEFINE_WAIT_FUNC(wait, woken_wake_function); | ||
| 110 | size_t datum_size; | 111 | size_t datum_size; |
| 111 | size_t to_wait; | 112 | size_t to_wait; |
| 112 | int ret; | 113 | int ret = 0; |
| 113 | 114 | ||
| 114 | if (!indio_dev->info) | 115 | if (!indio_dev->info) |
| 115 | return -ENODEV; | 116 | return -ENODEV; |
| @@ -131,19 +132,29 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, | |||
| 131 | else | 132 | else |
| 132 | to_wait = min_t(size_t, n / datum_size, rb->watermark); | 133 | to_wait = min_t(size_t, n / datum_size, rb->watermark); |
| 133 | 134 | ||
| 135 | add_wait_queue(&rb->pollq, &wait); | ||
| 134 | do { | 136 | do { |
| 135 | ret = wait_event_interruptible(rb->pollq, | 137 | if (!indio_dev->info) { |
| 136 | iio_buffer_ready(indio_dev, rb, to_wait, n / datum_size)); | 138 | ret = -ENODEV; |
| 137 | if (ret) | 139 | break; |
| 138 | return ret; | 140 | } |
| 139 | 141 | ||
| 140 | if (!indio_dev->info) | 142 | if (!iio_buffer_ready(indio_dev, rb, to_wait, n / datum_size)) { |
| 141 | return -ENODEV; | 143 | if (signal_pending(current)) { |
| 144 | ret = -ERESTARTSYS; | ||
| 145 | break; | ||
| 146 | } | ||
| 147 | |||
| 148 | wait_woken(&wait, TASK_INTERRUPTIBLE, | ||
| 149 | MAX_SCHEDULE_TIMEOUT); | ||
| 150 | continue; | ||
| 151 | } | ||
| 142 | 152 | ||
| 143 | ret = rb->access->read_first_n(rb, n, buf); | 153 | ret = rb->access->read_first_n(rb, n, buf); |
| 144 | if (ret == 0 && (filp->f_flags & O_NONBLOCK)) | 154 | if (ret == 0 && (filp->f_flags & O_NONBLOCK)) |
| 145 | ret = -EAGAIN; | 155 | ret = -EAGAIN; |
| 146 | } while (ret == 0); | 156 | } while (ret == 0); |
| 157 | remove_wait_queue(&rb->pollq, &wait); | ||
| 147 | 158 | ||
| 148 | return ret; | 159 | return ret; |
| 149 | } | 160 | } |
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index f914d5d140e4..d2b889918c3e 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c | |||
| @@ -613,9 +613,8 @@ ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals) | |||
| 613 | return sprintf(buf, "%d.%09u\n", vals[0], vals[1]); | 613 | return sprintf(buf, "%d.%09u\n", vals[0], vals[1]); |
| 614 | case IIO_VAL_FRACTIONAL: | 614 | case IIO_VAL_FRACTIONAL: |
| 615 | tmp = div_s64((s64)vals[0] * 1000000000LL, vals[1]); | 615 | tmp = div_s64((s64)vals[0] * 1000000000LL, vals[1]); |
| 616 | vals[1] = do_div(tmp, 1000000000LL); | 616 | vals[0] = (int)div_s64_rem(tmp, 1000000000, &vals[1]); |
| 617 | vals[0] = tmp; | 617 | return sprintf(buf, "%d.%09u\n", vals[0], abs(vals[1])); |
| 618 | return sprintf(buf, "%d.%09u\n", vals[0], vals[1]); | ||
| 619 | case IIO_VAL_FRACTIONAL_LOG2: | 618 | case IIO_VAL_FRACTIONAL_LOG2: |
| 620 | tmp = (s64)vals[0] * 1000000000LL >> vals[1]; | 619 | tmp = (s64)vals[0] * 1000000000LL >> vals[1]; |
| 621 | vals[1] = do_div(tmp, 1000000000LL); | 620 | vals[1] = do_div(tmp, 1000000000LL); |
diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 7c566f516572..3574945183fe 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig | |||
| @@ -76,7 +76,6 @@ config BH1750 | |||
| 76 | config BH1780 | 76 | config BH1780 |
| 77 | tristate "ROHM BH1780 ambient light sensor" | 77 | tristate "ROHM BH1780 ambient light sensor" |
| 78 | depends on I2C | 78 | depends on I2C |
| 79 | depends on !SENSORS_BH1780 | ||
| 80 | help | 79 | help |
| 81 | Say Y here to build support for the ROHM BH1780GLI ambient | 80 | Say Y here to build support for the ROHM BH1780GLI ambient |
| 82 | light sensor. | 81 | light sensor. |
| @@ -238,6 +237,8 @@ config MAX44000 | |||
| 238 | tristate "MAX44000 Ambient and Infrared Proximity Sensor" | 237 | tristate "MAX44000 Ambient and Infrared Proximity Sensor" |
| 239 | depends on I2C | 238 | depends on I2C |
| 240 | select REGMAP_I2C | 239 | select REGMAP_I2C |
| 240 | select IIO_BUFFER | ||
| 241 | select IIO_TRIGGERED_BUFFER | ||
| 241 | help | 242 | help |
| 242 | Say Y here if you want to build support for Maxim Integrated's | 243 | Say Y here if you want to build support for Maxim Integrated's |
| 243 | MAX44000 ambient and infrared proximity sensor device. | 244 | MAX44000 ambient and infrared proximity sensor device. |
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index 6943688e66df..e5a533cbd53f 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c | |||
| @@ -970,7 +970,7 @@ int bmp280_common_probe(struct device *dev, | |||
| 970 | data->vdda = devm_regulator_get(dev, "vdda"); | 970 | data->vdda = devm_regulator_get(dev, "vdda"); |
| 971 | if (IS_ERR(data->vdda)) { | 971 | if (IS_ERR(data->vdda)) { |
| 972 | dev_err(dev, "failed to get VDDA regulator\n"); | 972 | dev_err(dev, "failed to get VDDA regulator\n"); |
| 973 | ret = PTR_ERR(data->vddd); | 973 | ret = PTR_ERR(data->vdda); |
| 974 | goto out_disable_vddd; | 974 | goto out_disable_vddd; |
| 975 | } | 975 | } |
| 976 | ret = regulator_enable(data->vdda); | 976 | ret = regulator_enable(data->vdda); |
| @@ -1079,7 +1079,8 @@ EXPORT_SYMBOL(bmp280_common_remove); | |||
| 1079 | #ifdef CONFIG_PM | 1079 | #ifdef CONFIG_PM |
| 1080 | static int bmp280_runtime_suspend(struct device *dev) | 1080 | static int bmp280_runtime_suspend(struct device *dev) |
| 1081 | { | 1081 | { |
| 1082 | struct bmp280_data *data = dev_get_drvdata(dev); | 1082 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
| 1083 | struct bmp280_data *data = iio_priv(indio_dev); | ||
| 1083 | int ret; | 1084 | int ret; |
| 1084 | 1085 | ||
| 1085 | ret = regulator_disable(data->vdda); | 1086 | ret = regulator_disable(data->vdda); |
| @@ -1090,7 +1091,8 @@ static int bmp280_runtime_suspend(struct device *dev) | |||
| 1090 | 1091 | ||
| 1091 | static int bmp280_runtime_resume(struct device *dev) | 1092 | static int bmp280_runtime_resume(struct device *dev) |
| 1092 | { | 1093 | { |
| 1093 | struct bmp280_data *data = dev_get_drvdata(dev); | 1094 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
| 1095 | struct bmp280_data *data = iio_priv(indio_dev); | ||
| 1094 | int ret; | 1096 | int ret; |
| 1095 | 1097 | ||
| 1096 | ret = regulator_enable(data->vddd); | 1098 | ret = regulator_enable(data->vddd); |
diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c index 2e3a70e1b245..5656deb17261 100644 --- a/drivers/iio/proximity/as3935.c +++ b/drivers/iio/proximity/as3935.c | |||
| @@ -397,7 +397,7 @@ static int as3935_probe(struct spi_device *spi) | |||
| 397 | return ret; | 397 | return ret; |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | ret = iio_triggered_buffer_setup(indio_dev, NULL, | 400 | ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time, |
| 401 | &as3935_trigger_handler, NULL); | 401 | &as3935_trigger_handler, NULL); |
| 402 | 402 | ||
| 403 | if (ret) { | 403 | if (ret) { |
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index e6dfa1bd3def..5f65a78b27c9 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
| @@ -2462,18 +2462,24 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv) | |||
| 2462 | 2462 | ||
| 2463 | if (addr->dev_addr.bound_dev_if) { | 2463 | if (addr->dev_addr.bound_dev_if) { |
| 2464 | ndev = dev_get_by_index(&init_net, addr->dev_addr.bound_dev_if); | 2464 | ndev = dev_get_by_index(&init_net, addr->dev_addr.bound_dev_if); |
| 2465 | if (!ndev) | 2465 | if (!ndev) { |
| 2466 | return -ENODEV; | 2466 | ret = -ENODEV; |
| 2467 | goto err2; | ||
| 2468 | } | ||
| 2467 | 2469 | ||
| 2468 | if (ndev->flags & IFF_LOOPBACK) { | 2470 | if (ndev->flags & IFF_LOOPBACK) { |
| 2469 | dev_put(ndev); | 2471 | dev_put(ndev); |
| 2470 | if (!id_priv->id.device->get_netdev) | 2472 | if (!id_priv->id.device->get_netdev) { |
| 2471 | return -EOPNOTSUPP; | 2473 | ret = -EOPNOTSUPP; |
| 2474 | goto err2; | ||
| 2475 | } | ||
| 2472 | 2476 | ||
| 2473 | ndev = id_priv->id.device->get_netdev(id_priv->id.device, | 2477 | ndev = id_priv->id.device->get_netdev(id_priv->id.device, |
| 2474 | id_priv->id.port_num); | 2478 | id_priv->id.port_num); |
| 2475 | if (!ndev) | 2479 | if (!ndev) { |
| 2476 | return -ENODEV; | 2480 | ret = -ENODEV; |
| 2481 | goto err2; | ||
| 2482 | } | ||
| 2477 | } | 2483 | } |
| 2478 | 2484 | ||
| 2479 | route->path_rec->net = &init_net; | 2485 | route->path_rec->net = &init_net; |
diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c index 3a3c5d73bbfc..51c79b2fb0b8 100644 --- a/drivers/infiniband/core/multicast.c +++ b/drivers/infiniband/core/multicast.c | |||
| @@ -106,7 +106,6 @@ struct mcast_group { | |||
| 106 | atomic_t refcount; | 106 | atomic_t refcount; |
| 107 | enum mcast_group_state state; | 107 | enum mcast_group_state state; |
| 108 | struct ib_sa_query *query; | 108 | struct ib_sa_query *query; |
| 109 | int query_id; | ||
| 110 | u16 pkey_index; | 109 | u16 pkey_index; |
| 111 | u8 leave_state; | 110 | u8 leave_state; |
| 112 | int retries; | 111 | int retries; |
| @@ -340,11 +339,7 @@ static int send_join(struct mcast_group *group, struct mcast_member *member) | |||
| 340 | member->multicast.comp_mask, | 339 | member->multicast.comp_mask, |
| 341 | 3000, GFP_KERNEL, join_handler, group, | 340 | 3000, GFP_KERNEL, join_handler, group, |
| 342 | &group->query); | 341 | &group->query); |
| 343 | if (ret >= 0) { | 342 | return (ret > 0) ? 0 : ret; |
| 344 | group->query_id = ret; | ||
| 345 | ret = 0; | ||
| 346 | } | ||
| 347 | return ret; | ||
| 348 | } | 343 | } |
| 349 | 344 | ||
| 350 | static int send_leave(struct mcast_group *group, u8 leave_state) | 345 | static int send_leave(struct mcast_group *group, u8 leave_state) |
| @@ -364,11 +359,7 @@ static int send_leave(struct mcast_group *group, u8 leave_state) | |||
| 364 | IB_SA_MCMEMBER_REC_JOIN_STATE, | 359 | IB_SA_MCMEMBER_REC_JOIN_STATE, |
| 365 | 3000, GFP_KERNEL, leave_handler, | 360 | 3000, GFP_KERNEL, leave_handler, |
| 366 | group, &group->query); | 361 | group, &group->query); |
| 367 | if (ret >= 0) { | 362 | return (ret > 0) ? 0 : ret; |
| 368 | group->query_id = ret; | ||
| 369 | ret = 0; | ||
| 370 | } | ||
| 371 | return ret; | ||
| 372 | } | 363 | } |
| 373 | 364 | ||
| 374 | static void join_group(struct mcast_group *group, struct mcast_member *member, | 365 | static void join_group(struct mcast_group *group, struct mcast_member *member, |
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index 3aca7f6171b4..80f988984f44 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c | |||
| @@ -333,6 +333,8 @@ static void remove_ep_tid(struct c4iw_ep *ep) | |||
| 333 | 333 | ||
| 334 | spin_lock_irqsave(&ep->com.dev->lock, flags); | 334 | spin_lock_irqsave(&ep->com.dev->lock, flags); |
| 335 | _remove_handle(ep->com.dev, &ep->com.dev->hwtid_idr, ep->hwtid, 0); | 335 | _remove_handle(ep->com.dev, &ep->com.dev->hwtid_idr, ep->hwtid, 0); |
| 336 | if (idr_is_empty(&ep->com.dev->hwtid_idr)) | ||
| 337 | wake_up(&ep->com.dev->wait); | ||
| 336 | spin_unlock_irqrestore(&ep->com.dev->lock, flags); | 338 | spin_unlock_irqrestore(&ep->com.dev->lock, flags); |
| 337 | } | 339 | } |
| 338 | 340 | ||
| @@ -1827,8 +1829,12 @@ static int process_mpa_request(struct c4iw_ep *ep, struct sk_buff *skb) | |||
| 1827 | (ep->mpa_pkt + sizeof(*mpa)); | 1829 | (ep->mpa_pkt + sizeof(*mpa)); |
| 1828 | ep->ird = ntohs(mpa_v2_params->ird) & | 1830 | ep->ird = ntohs(mpa_v2_params->ird) & |
| 1829 | MPA_V2_IRD_ORD_MASK; | 1831 | MPA_V2_IRD_ORD_MASK; |
| 1832 | ep->ird = min_t(u32, ep->ird, | ||
| 1833 | cur_max_read_depth(ep->com.dev)); | ||
| 1830 | ep->ord = ntohs(mpa_v2_params->ord) & | 1834 | ep->ord = ntohs(mpa_v2_params->ord) & |
| 1831 | MPA_V2_IRD_ORD_MASK; | 1835 | MPA_V2_IRD_ORD_MASK; |
| 1836 | ep->ord = min_t(u32, ep->ord, | ||
| 1837 | cur_max_read_depth(ep->com.dev)); | ||
| 1832 | PDBG("%s initiator ird %u ord %u\n", __func__, ep->ird, | 1838 | PDBG("%s initiator ird %u ord %u\n", __func__, ep->ird, |
| 1833 | ep->ord); | 1839 | ep->ord); |
| 1834 | if (ntohs(mpa_v2_params->ird) & MPA_V2_PEER2PEER_MODEL) | 1840 | if (ntohs(mpa_v2_params->ird) & MPA_V2_PEER2PEER_MODEL) |
| @@ -2113,8 +2119,10 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip, | |||
| 2113 | } | 2119 | } |
| 2114 | ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t, | 2120 | ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t, |
| 2115 | n, pdev, rt_tos2priority(tos)); | 2121 | n, pdev, rt_tos2priority(tos)); |
| 2116 | if (!ep->l2t) | 2122 | if (!ep->l2t) { |
| 2123 | dev_put(pdev); | ||
| 2117 | goto out; | 2124 | goto out; |
| 2125 | } | ||
| 2118 | ep->mtu = pdev->mtu; | 2126 | ep->mtu = pdev->mtu; |
| 2119 | ep->tx_chan = cxgb4_port_chan(pdev); | 2127 | ep->tx_chan = cxgb4_port_chan(pdev); |
| 2120 | ep->smac_idx = cxgb4_tp_smt_idx(adapter_type, | 2128 | ep->smac_idx = cxgb4_tp_smt_idx(adapter_type, |
| @@ -3136,7 +3144,7 @@ int c4iw_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
| 3136 | if (ep->mpa_attr.version == 2 && ep->mpa_attr.enhanced_rdma_conn) { | 3144 | if (ep->mpa_attr.version == 2 && ep->mpa_attr.enhanced_rdma_conn) { |
| 3137 | if (conn_param->ord > ep->ird) { | 3145 | if (conn_param->ord > ep->ird) { |
| 3138 | if (RELAXED_IRD_NEGOTIATION) { | 3146 | if (RELAXED_IRD_NEGOTIATION) { |
| 3139 | ep->ord = ep->ird; | 3147 | conn_param->ord = ep->ird; |
| 3140 | } else { | 3148 | } else { |
| 3141 | ep->ird = conn_param->ird; | 3149 | ep->ird = conn_param->ird; |
| 3142 | ep->ord = conn_param->ord; | 3150 | ep->ord = conn_param->ord; |
diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c index 812ab7278b8e..ac926c942fee 100644 --- a/drivers/infiniband/hw/cxgb4/cq.c +++ b/drivers/infiniband/hw/cxgb4/cq.c | |||
| @@ -1016,15 +1016,15 @@ int c4iw_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata) | |||
| 1016 | int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) | 1016 | int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) |
| 1017 | { | 1017 | { |
| 1018 | struct c4iw_cq *chp; | 1018 | struct c4iw_cq *chp; |
| 1019 | int ret; | 1019 | int ret = 0; |
| 1020 | unsigned long flag; | 1020 | unsigned long flag; |
| 1021 | 1021 | ||
| 1022 | chp = to_c4iw_cq(ibcq); | 1022 | chp = to_c4iw_cq(ibcq); |
| 1023 | spin_lock_irqsave(&chp->lock, flag); | 1023 | spin_lock_irqsave(&chp->lock, flag); |
| 1024 | ret = t4_arm_cq(&chp->cq, | 1024 | t4_arm_cq(&chp->cq, |
| 1025 | (flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED); | 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 | spin_unlock_irqrestore(&chp->lock, flag); | 1028 | spin_unlock_irqrestore(&chp->lock, flag); |
| 1027 | if (ret && !(flags & IB_CQ_REPORT_MISSED_EVENTS)) | ||
| 1028 | ret = 0; | ||
| 1029 | return ret; | 1029 | return ret; |
| 1030 | } | 1030 | } |
diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c index 071d7332ec06..3c4b2126e0d1 100644 --- a/drivers/infiniband/hw/cxgb4/device.c +++ b/drivers/infiniband/hw/cxgb4/device.c | |||
| @@ -872,9 +872,13 @@ static void c4iw_rdev_close(struct c4iw_rdev *rdev) | |||
| 872 | static void c4iw_dealloc(struct uld_ctx *ctx) | 872 | static void c4iw_dealloc(struct uld_ctx *ctx) |
| 873 | { | 873 | { |
| 874 | c4iw_rdev_close(&ctx->dev->rdev); | 874 | c4iw_rdev_close(&ctx->dev->rdev); |
| 875 | WARN_ON_ONCE(!idr_is_empty(&ctx->dev->cqidr)); | ||
| 875 | idr_destroy(&ctx->dev->cqidr); | 876 | idr_destroy(&ctx->dev->cqidr); |
| 877 | WARN_ON_ONCE(!idr_is_empty(&ctx->dev->qpidr)); | ||
| 876 | idr_destroy(&ctx->dev->qpidr); | 878 | idr_destroy(&ctx->dev->qpidr); |
| 879 | WARN_ON_ONCE(!idr_is_empty(&ctx->dev->mmidr)); | ||
| 877 | idr_destroy(&ctx->dev->mmidr); | 880 | idr_destroy(&ctx->dev->mmidr); |
| 881 | wait_event(ctx->dev->wait, idr_is_empty(&ctx->dev->hwtid_idr)); | ||
| 878 | idr_destroy(&ctx->dev->hwtid_idr); | 882 | idr_destroy(&ctx->dev->hwtid_idr); |
| 879 | idr_destroy(&ctx->dev->stid_idr); | 883 | idr_destroy(&ctx->dev->stid_idr); |
| 880 | idr_destroy(&ctx->dev->atid_idr); | 884 | idr_destroy(&ctx->dev->atid_idr); |
| @@ -992,6 +996,7 @@ static struct c4iw_dev *c4iw_alloc(const struct cxgb4_lld_info *infop) | |||
| 992 | mutex_init(&devp->rdev.stats.lock); | 996 | mutex_init(&devp->rdev.stats.lock); |
| 993 | mutex_init(&devp->db_mutex); | 997 | mutex_init(&devp->db_mutex); |
| 994 | INIT_LIST_HEAD(&devp->db_fc_list); | 998 | INIT_LIST_HEAD(&devp->db_fc_list); |
| 999 | init_waitqueue_head(&devp->wait); | ||
| 995 | devp->avail_ird = devp->rdev.lldi.max_ird_adapter; | 1000 | devp->avail_ird = devp->rdev.lldi.max_ird_adapter; |
| 996 | 1001 | ||
| 997 | if (c4iw_debugfs_root) { | 1002 | if (c4iw_debugfs_root) { |
diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h index aa47e0ae80bc..4b83b84f7ddf 100644 --- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h +++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h | |||
| @@ -263,6 +263,7 @@ struct c4iw_dev { | |||
| 263 | struct idr stid_idr; | 263 | struct idr stid_idr; |
| 264 | struct list_head db_fc_list; | 264 | struct list_head db_fc_list; |
| 265 | u32 avail_ird; | 265 | u32 avail_ird; |
| 266 | wait_queue_head_t wait; | ||
| 266 | }; | 267 | }; |
| 267 | 268 | ||
| 268 | static inline struct c4iw_dev *to_c4iw_dev(struct ib_device *ibdev) | 269 | static inline struct c4iw_dev *to_c4iw_dev(struct ib_device *ibdev) |
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c index edb1172b6f54..690435229be7 100644 --- a/drivers/infiniband/hw/cxgb4/qp.c +++ b/drivers/infiniband/hw/cxgb4/qp.c | |||
| @@ -683,7 +683,7 @@ static int build_inv_stag(union t4_wr *wqe, struct ib_send_wr *wr, | |||
| 683 | return 0; | 683 | return 0; |
| 684 | } | 684 | } |
| 685 | 685 | ||
| 686 | void _free_qp(struct kref *kref) | 686 | static void _free_qp(struct kref *kref) |
| 687 | { | 687 | { |
| 688 | struct c4iw_qp *qhp; | 688 | struct c4iw_qp *qhp; |
| 689 | 689 | ||
diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h index 6126bbe36095..02173f4315fa 100644 --- a/drivers/infiniband/hw/cxgb4/t4.h +++ b/drivers/infiniband/hw/cxgb4/t4.h | |||
| @@ -634,6 +634,11 @@ static inline int t4_valid_cqe(struct t4_cq *cq, struct t4_cqe *cqe) | |||
| 634 | return (CQE_GENBIT(cqe) == cq->gen); | 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 | static inline int t4_next_hw_cqe(struct t4_cq *cq, struct t4_cqe **cqe) | 642 | static inline int t4_next_hw_cqe(struct t4_cq *cq, struct t4_cqe **cqe) |
| 638 | { | 643 | { |
| 639 | int ret; | 644 | int ret; |
diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/hfi1/affinity.c index 79575ee873f2..0566393e5aba 100644 --- a/drivers/infiniband/hw/hfi1/affinity.c +++ b/drivers/infiniband/hw/hfi1/affinity.c | |||
| @@ -47,7 +47,6 @@ | |||
| 47 | #include <linux/topology.h> | 47 | #include <linux/topology.h> |
| 48 | #include <linux/cpumask.h> | 48 | #include <linux/cpumask.h> |
| 49 | #include <linux/module.h> | 49 | #include <linux/module.h> |
| 50 | #include <linux/cpumask.h> | ||
| 51 | 50 | ||
| 52 | #include "hfi.h" | 51 | #include "hfi.h" |
| 53 | #include "affinity.h" | 52 | #include "affinity.h" |
| @@ -682,7 +681,7 @@ int hfi1_set_sdma_affinity(struct hfi1_devdata *dd, const char *buf, | |||
| 682 | size_t count) | 681 | size_t count) |
| 683 | { | 682 | { |
| 684 | struct hfi1_affinity_node *entry; | 683 | struct hfi1_affinity_node *entry; |
| 685 | struct cpumask mask; | 684 | cpumask_var_t mask; |
| 686 | int ret, i; | 685 | int ret, i; |
| 687 | 686 | ||
| 688 | spin_lock(&node_affinity.lock); | 687 | spin_lock(&node_affinity.lock); |
| @@ -692,19 +691,24 @@ int hfi1_set_sdma_affinity(struct hfi1_devdata *dd, const char *buf, | |||
| 692 | if (!entry) | 691 | if (!entry) |
| 693 | return -EINVAL; | 692 | return -EINVAL; |
| 694 | 693 | ||
| 695 | ret = cpulist_parse(buf, &mask); | 694 | ret = zalloc_cpumask_var(&mask, GFP_KERNEL); |
| 695 | if (!ret) | ||
| 696 | return -ENOMEM; | ||
| 697 | |||
| 698 | ret = cpulist_parse(buf, mask); | ||
| 696 | if (ret) | 699 | if (ret) |
| 697 | return ret; | 700 | goto out; |
| 698 | 701 | ||
| 699 | if (!cpumask_subset(&mask, cpu_online_mask) || cpumask_empty(&mask)) { | 702 | if (!cpumask_subset(mask, cpu_online_mask) || cpumask_empty(mask)) { |
| 700 | dd_dev_warn(dd, "Invalid CPU mask\n"); | 703 | dd_dev_warn(dd, "Invalid CPU mask\n"); |
| 701 | return -EINVAL; | 704 | ret = -EINVAL; |
| 705 | goto out; | ||
| 702 | } | 706 | } |
| 703 | 707 | ||
| 704 | mutex_lock(&sdma_affinity_mutex); | 708 | mutex_lock(&sdma_affinity_mutex); |
| 705 | /* reset the SDMA interrupt affinity details */ | 709 | /* reset the SDMA interrupt affinity details */ |
| 706 | init_cpu_mask_set(&entry->def_intr); | 710 | init_cpu_mask_set(&entry->def_intr); |
| 707 | cpumask_copy(&entry->def_intr.mask, &mask); | 711 | cpumask_copy(&entry->def_intr.mask, mask); |
| 708 | /* | 712 | /* |
| 709 | * Reassign the affinity for each SDMA interrupt. | 713 | * Reassign the affinity for each SDMA interrupt. |
| 710 | */ | 714 | */ |
| @@ -720,8 +724,9 @@ int hfi1_set_sdma_affinity(struct hfi1_devdata *dd, const char *buf, | |||
| 720 | if (ret) | 724 | if (ret) |
| 721 | break; | 725 | break; |
| 722 | } | 726 | } |
| 723 | |||
| 724 | mutex_unlock(&sdma_affinity_mutex); | 727 | mutex_unlock(&sdma_affinity_mutex); |
| 728 | out: | ||
| 729 | free_cpumask_var(mask); | ||
| 725 | return ret ? ret : strnlen(buf, PAGE_SIZE); | 730 | return ret ? ret : strnlen(buf, PAGE_SIZE); |
| 726 | } | 731 | } |
| 727 | 732 | ||
diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c index b32638d58ae8..cc38004cea42 100644 --- a/drivers/infiniband/hw/hfi1/chip.c +++ b/drivers/infiniband/hw/hfi1/chip.c | |||
| @@ -9490,6 +9490,78 @@ static void init_lcb(struct hfi1_devdata *dd) | |||
| 9490 | write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x00); | 9490 | write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x00); |
| 9491 | } | 9491 | } |
| 9492 | 9492 | ||
| 9493 | /* | ||
| 9494 | * Perform a test read on the QSFP. Return 0 on success, -ERRNO | ||
| 9495 | * on error. | ||
| 9496 | */ | ||
| 9497 | static int test_qsfp_read(struct hfi1_pportdata *ppd) | ||
| 9498 | { | ||
| 9499 | int ret; | ||
| 9500 | u8 status; | ||
| 9501 | |||
| 9502 | /* report success if not a QSFP */ | ||
| 9503 | if (ppd->port_type != PORT_TYPE_QSFP) | ||
| 9504 | return 0; | ||
| 9505 | |||
| 9506 | /* read byte 2, the status byte */ | ||
| 9507 | ret = one_qsfp_read(ppd, ppd->dd->hfi1_id, 2, &status, 1); | ||
| 9508 | if (ret < 0) | ||
| 9509 | return ret; | ||
| 9510 | if (ret != 1) | ||
| 9511 | return -EIO; | ||
| 9512 | |||
| 9513 | return 0; /* success */ | ||
| 9514 | } | ||
| 9515 | |||
| 9516 | /* | ||
| 9517 | * Values for QSFP retry. | ||
| 9518 | * | ||
| 9519 | * Give up after 10s (20 x 500ms). The overall timeout was empirically | ||
| 9520 | * arrived at from experience on a large cluster. | ||
| 9521 | */ | ||
| 9522 | #define MAX_QSFP_RETRIES 20 | ||
| 9523 | #define QSFP_RETRY_WAIT 500 /* msec */ | ||
| 9524 | |||
| 9525 | /* | ||
| 9526 | * Try a QSFP read. If it fails, schedule a retry for later. | ||
| 9527 | * Called on first link activation after driver load. | ||
| 9528 | */ | ||
| 9529 | static void try_start_link(struct hfi1_pportdata *ppd) | ||
| 9530 | { | ||
| 9531 | if (test_qsfp_read(ppd)) { | ||
| 9532 | /* read failed */ | ||
| 9533 | if (ppd->qsfp_retry_count >= MAX_QSFP_RETRIES) { | ||
| 9534 | dd_dev_err(ppd->dd, "QSFP not responding, giving up\n"); | ||
| 9535 | return; | ||
| 9536 | } | ||
| 9537 | dd_dev_info(ppd->dd, | ||
| 9538 | "QSFP not responding, waiting and retrying %d\n", | ||
| 9539 | (int)ppd->qsfp_retry_count); | ||
| 9540 | ppd->qsfp_retry_count++; | ||
| 9541 | queue_delayed_work(ppd->hfi1_wq, &ppd->start_link_work, | ||
| 9542 | msecs_to_jiffies(QSFP_RETRY_WAIT)); | ||
| 9543 | return; | ||
| 9544 | } | ||
| 9545 | ppd->qsfp_retry_count = 0; | ||
| 9546 | |||
| 9547 | /* | ||
| 9548 | * Tune the SerDes to a ballpark setting for optimal signal and bit | ||
| 9549 | * error rate. Needs to be done before starting the link. | ||
| 9550 | */ | ||
| 9551 | tune_serdes(ppd); | ||
| 9552 | start_link(ppd); | ||
| 9553 | } | ||
| 9554 | |||
| 9555 | /* | ||
| 9556 | * Workqueue function to start the link after a delay. | ||
| 9557 | */ | ||
| 9558 | void handle_start_link(struct work_struct *work) | ||
| 9559 | { | ||
| 9560 | struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata, | ||
| 9561 | start_link_work.work); | ||
| 9562 | try_start_link(ppd); | ||
| 9563 | } | ||
| 9564 | |||
| 9493 | int bringup_serdes(struct hfi1_pportdata *ppd) | 9565 | int bringup_serdes(struct hfi1_pportdata *ppd) |
| 9494 | { | 9566 | { |
| 9495 | struct hfi1_devdata *dd = ppd->dd; | 9567 | struct hfi1_devdata *dd = ppd->dd; |
| @@ -9525,14 +9597,8 @@ int bringup_serdes(struct hfi1_pportdata *ppd) | |||
| 9525 | set_qsfp_int_n(ppd, 1); | 9597 | set_qsfp_int_n(ppd, 1); |
| 9526 | } | 9598 | } |
| 9527 | 9599 | ||
| 9528 | /* | 9600 | try_start_link(ppd); |
| 9529 | * Tune the SerDes to a ballpark setting for | 9601 | return 0; |
| 9530 | * optimal signal and bit error rate | ||
| 9531 | * Needs to be done before starting the link | ||
| 9532 | */ | ||
| 9533 | tune_serdes(ppd); | ||
| 9534 | |||
| 9535 | return start_link(ppd); | ||
| 9536 | } | 9602 | } |
| 9537 | 9603 | ||
| 9538 | void hfi1_quiet_serdes(struct hfi1_pportdata *ppd) | 9604 | void hfi1_quiet_serdes(struct hfi1_pportdata *ppd) |
| @@ -9549,6 +9615,10 @@ void hfi1_quiet_serdes(struct hfi1_pportdata *ppd) | |||
| 9549 | ppd->driver_link_ready = 0; | 9615 | ppd->driver_link_ready = 0; |
| 9550 | ppd->link_enabled = 0; | 9616 | ppd->link_enabled = 0; |
| 9551 | 9617 | ||
| 9618 | ppd->qsfp_retry_count = MAX_QSFP_RETRIES; /* prevent more retries */ | ||
| 9619 | flush_delayed_work(&ppd->start_link_work); | ||
| 9620 | cancel_delayed_work_sync(&ppd->start_link_work); | ||
| 9621 | |||
| 9552 | ppd->offline_disabled_reason = | 9622 | ppd->offline_disabled_reason = |
| 9553 | HFI1_ODR_MASK(OPA_LINKDOWN_REASON_SMA_DISABLED); | 9623 | HFI1_ODR_MASK(OPA_LINKDOWN_REASON_SMA_DISABLED); |
| 9554 | set_link_down_reason(ppd, OPA_LINKDOWN_REASON_SMA_DISABLED, 0, | 9624 | set_link_down_reason(ppd, OPA_LINKDOWN_REASON_SMA_DISABLED, 0, |
| @@ -12865,7 +12935,7 @@ fail: | |||
| 12865 | */ | 12935 | */ |
| 12866 | static int set_up_context_variables(struct hfi1_devdata *dd) | 12936 | static int set_up_context_variables(struct hfi1_devdata *dd) |
| 12867 | { | 12937 | { |
| 12868 | int num_kernel_contexts; | 12938 | unsigned long num_kernel_contexts; |
| 12869 | int total_contexts; | 12939 | int total_contexts; |
| 12870 | int ret; | 12940 | int ret; |
| 12871 | unsigned ngroups; | 12941 | unsigned ngroups; |
| @@ -12894,9 +12964,9 @@ static int set_up_context_variables(struct hfi1_devdata *dd) | |||
| 12894 | */ | 12964 | */ |
| 12895 | if (num_kernel_contexts > (dd->chip_send_contexts - num_vls - 1)) { | 12965 | if (num_kernel_contexts > (dd->chip_send_contexts - num_vls - 1)) { |
| 12896 | dd_dev_err(dd, | 12966 | dd_dev_err(dd, |
| 12897 | "Reducing # kernel rcv contexts to: %d, from %d\n", | 12967 | "Reducing # kernel rcv contexts to: %d, from %lu\n", |
| 12898 | (int)(dd->chip_send_contexts - num_vls - 1), | 12968 | (int)(dd->chip_send_contexts - num_vls - 1), |
| 12899 | (int)num_kernel_contexts); | 12969 | num_kernel_contexts); |
| 12900 | num_kernel_contexts = dd->chip_send_contexts - num_vls - 1; | 12970 | num_kernel_contexts = dd->chip_send_contexts - num_vls - 1; |
| 12901 | } | 12971 | } |
| 12902 | /* | 12972 | /* |
diff --git a/drivers/infiniband/hw/hfi1/chip.h b/drivers/infiniband/hw/hfi1/chip.h index ed11107c50fe..e29573769efc 100644 --- a/drivers/infiniband/hw/hfi1/chip.h +++ b/drivers/infiniband/hw/hfi1/chip.h | |||
| @@ -706,6 +706,7 @@ void handle_link_up(struct work_struct *work); | |||
| 706 | void handle_link_down(struct work_struct *work); | 706 | void handle_link_down(struct work_struct *work); |
| 707 | void handle_link_downgrade(struct work_struct *work); | 707 | void handle_link_downgrade(struct work_struct *work); |
| 708 | void handle_link_bounce(struct work_struct *work); | 708 | void handle_link_bounce(struct work_struct *work); |
| 709 | void handle_start_link(struct work_struct *work); | ||
| 709 | void handle_sma_message(struct work_struct *work); | 710 | void handle_sma_message(struct work_struct *work); |
| 710 | void reset_qsfp(struct hfi1_pportdata *ppd); | 711 | void reset_qsfp(struct hfi1_pportdata *ppd); |
| 711 | void qsfp_event(struct work_struct *work); | 712 | void qsfp_event(struct work_struct *work); |
diff --git a/drivers/infiniband/hw/hfi1/debugfs.c b/drivers/infiniband/hw/hfi1/debugfs.c index dbab9d9cc288..5e9be16f6cd3 100644 --- a/drivers/infiniband/hw/hfi1/debugfs.c +++ b/drivers/infiniband/hw/hfi1/debugfs.c | |||
| @@ -59,6 +59,40 @@ | |||
| 59 | 59 | ||
| 60 | static struct dentry *hfi1_dbg_root; | 60 | static struct dentry *hfi1_dbg_root; |
| 61 | 61 | ||
| 62 | /* wrappers to enforce srcu in seq file */ | ||
| 63 | static ssize_t hfi1_seq_read( | ||
| 64 | struct file *file, | ||
| 65 | char __user *buf, | ||
| 66 | size_t size, | ||
| 67 | loff_t *ppos) | ||
| 68 | { | ||
| 69 | struct dentry *d = file->f_path.dentry; | ||
| 70 | int srcu_idx; | ||
| 71 | ssize_t r; | ||
| 72 | |||
| 73 | r = debugfs_use_file_start(d, &srcu_idx); | ||
| 74 | if (likely(!r)) | ||
| 75 | r = seq_read(file, buf, size, ppos); | ||
| 76 | debugfs_use_file_finish(srcu_idx); | ||
| 77 | return r; | ||
| 78 | } | ||
| 79 | |||
| 80 | static loff_t hfi1_seq_lseek( | ||
| 81 | struct file *file, | ||
| 82 | loff_t offset, | ||
| 83 | int whence) | ||
| 84 | { | ||
| 85 | struct dentry *d = file->f_path.dentry; | ||
| 86 | int srcu_idx; | ||
| 87 | loff_t r; | ||
| 88 | |||
| 89 | r = debugfs_use_file_start(d, &srcu_idx); | ||
| 90 | if (likely(!r)) | ||
| 91 | r = seq_lseek(file, offset, whence); | ||
| 92 | debugfs_use_file_finish(srcu_idx); | ||
| 93 | return r; | ||
| 94 | } | ||
| 95 | |||
| 62 | #define private2dd(file) (file_inode(file)->i_private) | 96 | #define private2dd(file) (file_inode(file)->i_private) |
| 63 | #define private2ppd(file) (file_inode(file)->i_private) | 97 | #define private2ppd(file) (file_inode(file)->i_private) |
| 64 | 98 | ||
| @@ -87,8 +121,8 @@ static int _##name##_open(struct inode *inode, struct file *s) \ | |||
| 87 | static const struct file_operations _##name##_file_ops = { \ | 121 | static const struct file_operations _##name##_file_ops = { \ |
| 88 | .owner = THIS_MODULE, \ | 122 | .owner = THIS_MODULE, \ |
| 89 | .open = _##name##_open, \ | 123 | .open = _##name##_open, \ |
| 90 | .read = seq_read, \ | 124 | .read = hfi1_seq_read, \ |
| 91 | .llseek = seq_lseek, \ | 125 | .llseek = hfi1_seq_lseek, \ |
| 92 | .release = seq_release \ | 126 | .release = seq_release \ |
| 93 | } | 127 | } |
| 94 | 128 | ||
| @@ -105,11 +139,9 @@ do { \ | |||
| 105 | DEBUGFS_FILE_CREATE(#name, parent, data, &_##name##_file_ops, S_IRUGO) | 139 | DEBUGFS_FILE_CREATE(#name, parent, data, &_##name##_file_ops, S_IRUGO) |
| 106 | 140 | ||
| 107 | static void *_opcode_stats_seq_start(struct seq_file *s, loff_t *pos) | 141 | static void *_opcode_stats_seq_start(struct seq_file *s, loff_t *pos) |
| 108 | __acquires(RCU) | ||
| 109 | { | 142 | { |
| 110 | struct hfi1_opcode_stats_perctx *opstats; | 143 | struct hfi1_opcode_stats_perctx *opstats; |
| 111 | 144 | ||
| 112 | rcu_read_lock(); | ||
| 113 | if (*pos >= ARRAY_SIZE(opstats->stats)) | 145 | if (*pos >= ARRAY_SIZE(opstats->stats)) |
| 114 | return NULL; | 146 | return NULL; |
| 115 | return pos; | 147 | return pos; |
| @@ -126,9 +158,7 @@ static void *_opcode_stats_seq_next(struct seq_file *s, void *v, loff_t *pos) | |||
| 126 | } | 158 | } |
| 127 | 159 | ||
| 128 | static void _opcode_stats_seq_stop(struct seq_file *s, void *v) | 160 | static void _opcode_stats_seq_stop(struct seq_file *s, void *v) |
| 129 | __releases(RCU) | ||
| 130 | { | 161 | { |
| 131 | rcu_read_unlock(); | ||
| 132 | } | 162 | } |
| 133 | 163 | ||
| 134 | static int _opcode_stats_seq_show(struct seq_file *s, void *v) | 164 | static int _opcode_stats_seq_show(struct seq_file *s, void *v) |
| @@ -223,28 +253,32 @@ DEBUGFS_SEQ_FILE_OPEN(ctx_stats) | |||
| 223 | DEBUGFS_FILE_OPS(ctx_stats); | 253 | DEBUGFS_FILE_OPS(ctx_stats); |
| 224 | 254 | ||
| 225 | static void *_qp_stats_seq_start(struct seq_file *s, loff_t *pos) | 255 | static void *_qp_stats_seq_start(struct seq_file *s, loff_t *pos) |
| 226 | __acquires(RCU) | 256 | __acquires(RCU) |
| 227 | { | 257 | { |
| 228 | struct qp_iter *iter; | 258 | struct qp_iter *iter; |
| 229 | loff_t n = *pos; | 259 | loff_t n = *pos; |
| 230 | 260 | ||
| 231 | rcu_read_lock(); | ||
| 232 | iter = qp_iter_init(s->private); | 261 | iter = qp_iter_init(s->private); |
| 262 | |||
| 263 | /* stop calls rcu_read_unlock */ | ||
| 264 | rcu_read_lock(); | ||
| 265 | |||
| 233 | if (!iter) | 266 | if (!iter) |
| 234 | return NULL; | 267 | return NULL; |
| 235 | 268 | ||
| 236 | while (n--) { | 269 | do { |
| 237 | if (qp_iter_next(iter)) { | 270 | if (qp_iter_next(iter)) { |
| 238 | kfree(iter); | 271 | kfree(iter); |
| 239 | return NULL; | 272 | return NULL; |
| 240 | } | 273 | } |
| 241 | } | 274 | } while (n--); |
| 242 | 275 | ||
| 243 | return iter; | 276 | return iter; |
| 244 | } | 277 | } |
| 245 | 278 | ||
| 246 | static void *_qp_stats_seq_next(struct seq_file *s, void *iter_ptr, | 279 | static void *_qp_stats_seq_next(struct seq_file *s, void *iter_ptr, |
| 247 | loff_t *pos) | 280 | loff_t *pos) |
| 281 | __must_hold(RCU) | ||
| 248 | { | 282 | { |
| 249 | struct qp_iter *iter = iter_ptr; | 283 | struct qp_iter *iter = iter_ptr; |
| 250 | 284 | ||
| @@ -259,7 +293,7 @@ static void *_qp_stats_seq_next(struct seq_file *s, void *iter_ptr, | |||
| 259 | } | 293 | } |
| 260 | 294 | ||
| 261 | static void _qp_stats_seq_stop(struct seq_file *s, void *iter_ptr) | 295 | static void _qp_stats_seq_stop(struct seq_file *s, void *iter_ptr) |
| 262 | __releases(RCU) | 296 | __releases(RCU) |
| 263 | { | 297 | { |
| 264 | rcu_read_unlock(); | 298 | rcu_read_unlock(); |
| 265 | } | 299 | } |
| @@ -281,12 +315,10 @@ DEBUGFS_SEQ_FILE_OPEN(qp_stats) | |||
| 281 | DEBUGFS_FILE_OPS(qp_stats); | 315 | DEBUGFS_FILE_OPS(qp_stats); |
| 282 | 316 | ||
| 283 | static void *_sdes_seq_start(struct seq_file *s, loff_t *pos) | 317 | static void *_sdes_seq_start(struct seq_file *s, loff_t *pos) |
| 284 | __acquires(RCU) | ||
| 285 | { | 318 | { |
| 286 | struct hfi1_ibdev *ibd; | 319 | struct hfi1_ibdev *ibd; |
| 287 | struct hfi1_devdata *dd; | 320 | struct hfi1_devdata *dd; |
| 288 | 321 | ||
| 289 | rcu_read_lock(); | ||
| 290 | ibd = (struct hfi1_ibdev *)s->private; | 322 | ibd = (struct hfi1_ibdev *)s->private; |
| 291 | dd = dd_from_dev(ibd); | 323 | dd = dd_from_dev(ibd); |
| 292 | if (!dd->per_sdma || *pos >= dd->num_sdma) | 324 | if (!dd->per_sdma || *pos >= dd->num_sdma) |
| @@ -306,9 +338,7 @@ static void *_sdes_seq_next(struct seq_file *s, void *v, loff_t *pos) | |||
| 306 | } | 338 | } |
| 307 | 339 | ||
| 308 | static void _sdes_seq_stop(struct seq_file *s, void *v) | 340 | static void _sdes_seq_stop(struct seq_file *s, void *v) |
| 309 | __releases(RCU) | ||
| 310 | { | 341 | { |
| 311 | rcu_read_unlock(); | ||
| 312 | } | 342 | } |
| 313 | 343 | ||
| 314 | static int _sdes_seq_show(struct seq_file *s, void *v) | 344 | static int _sdes_seq_show(struct seq_file *s, void *v) |
| @@ -335,11 +365,9 @@ static ssize_t dev_counters_read(struct file *file, char __user *buf, | |||
| 335 | struct hfi1_devdata *dd; | 365 | struct hfi1_devdata *dd; |
| 336 | ssize_t rval; | 366 | ssize_t rval; |
| 337 | 367 | ||
| 338 | rcu_read_lock(); | ||
| 339 | dd = private2dd(file); | 368 | dd = private2dd(file); |
| 340 | avail = hfi1_read_cntrs(dd, NULL, &counters); | 369 | avail = hfi1_read_cntrs(dd, NULL, &counters); |
| 341 | rval = simple_read_from_buffer(buf, count, ppos, counters, avail); | 370 | rval = simple_read_from_buffer(buf, count, ppos, counters, avail); |
| 342 | rcu_read_unlock(); | ||
| 343 | return rval; | 371 | return rval; |
| 344 | } | 372 | } |
| 345 | 373 | ||
| @@ -352,11 +380,9 @@ static ssize_t dev_names_read(struct file *file, char __user *buf, | |||
| 352 | struct hfi1_devdata *dd; | 380 | struct hfi1_devdata *dd; |
| 353 | ssize_t rval; | 381 | ssize_t rval; |
| 354 | 382 | ||
| 355 | rcu_read_lock(); | ||
| 356 | dd = private2dd(file); | 383 | dd = private2dd(file); |
| 357 | avail = hfi1_read_cntrs(dd, &names, NULL); | 384 | avail = hfi1_read_cntrs(dd, &names, NULL); |
| 358 | rval = simple_read_from_buffer(buf, count, ppos, names, avail); | 385 | rval = simple_read_from_buffer(buf, count, ppos, names, avail); |
| 359 | rcu_read_unlock(); | ||
| 360 | return rval; | 386 | return rval; |
| 361 | } | 387 | } |
| 362 | 388 | ||
| @@ -379,11 +405,9 @@ static ssize_t portnames_read(struct file *file, char __user *buf, | |||
| 379 | struct hfi1_devdata *dd; | 405 | struct hfi1_devdata *dd; |
| 380 | ssize_t rval; | 406 | ssize_t rval; |
| 381 | 407 | ||
| 382 | rcu_read_lock(); | ||
| 383 | dd = private2dd(file); | 408 | dd = private2dd(file); |
| 384 | avail = hfi1_read_portcntrs(dd->pport, &names, NULL); | 409 | avail = hfi1_read_portcntrs(dd->pport, &names, NULL); |
| 385 | rval = simple_read_from_buffer(buf, count, ppos, names, avail); | 410 | rval = simple_read_from_buffer(buf, count, ppos, names, avail); |
| 386 | rcu_read_unlock(); | ||
| 387 | return rval; | 411 | return rval; |
| 388 | } | 412 | } |
| 389 | 413 | ||
| @@ -396,11 +420,9 @@ static ssize_t portcntrs_debugfs_read(struct file *file, char __user *buf, | |||
| 396 | struct hfi1_pportdata *ppd; | 420 | struct hfi1_pportdata *ppd; |
| 397 | ssize_t rval; | 421 | ssize_t rval; |
| 398 | 422 | ||
| 399 | rcu_read_lock(); | ||
| 400 | ppd = private2ppd(file); | 423 | ppd = private2ppd(file); |
| 401 | avail = hfi1_read_portcntrs(ppd, NULL, &counters); | 424 | avail = hfi1_read_portcntrs(ppd, NULL, &counters); |
| 402 | rval = simple_read_from_buffer(buf, count, ppos, counters, avail); | 425 | rval = simple_read_from_buffer(buf, count, ppos, counters, avail); |
| 403 | rcu_read_unlock(); | ||
| 404 | return rval; | 426 | return rval; |
| 405 | } | 427 | } |
| 406 | 428 | ||
| @@ -430,16 +452,13 @@ static ssize_t asic_flags_read(struct file *file, char __user *buf, | |||
| 430 | int used; | 452 | int used; |
| 431 | int i; | 453 | int i; |
| 432 | 454 | ||
| 433 | rcu_read_lock(); | ||
| 434 | ppd = private2ppd(file); | 455 | ppd = private2ppd(file); |
| 435 | dd = ppd->dd; | 456 | dd = ppd->dd; |
| 436 | size = PAGE_SIZE; | 457 | size = PAGE_SIZE; |
| 437 | used = 0; | 458 | used = 0; |
| 438 | tmp = kmalloc(size, GFP_KERNEL); | 459 | tmp = kmalloc(size, GFP_KERNEL); |
| 439 | if (!tmp) { | 460 | if (!tmp) |
| 440 | rcu_read_unlock(); | ||
| 441 | return -ENOMEM; | 461 | return -ENOMEM; |
| 442 | } | ||
| 443 | 462 | ||
| 444 | scratch0 = read_csr(dd, ASIC_CFG_SCRATCH); | 463 | scratch0 = read_csr(dd, ASIC_CFG_SCRATCH); |
| 445 | used += scnprintf(tmp + used, size - used, | 464 | used += scnprintf(tmp + used, size - used, |
| @@ -466,7 +485,6 @@ static ssize_t asic_flags_read(struct file *file, char __user *buf, | |||
| 466 | used += scnprintf(tmp + used, size - used, "Write bits to clear\n"); | 485 | used += scnprintf(tmp + used, size - used, "Write bits to clear\n"); |
| 467 | 486 | ||
| 468 | ret = simple_read_from_buffer(buf, count, ppos, tmp, used); | 487 | ret = simple_read_from_buffer(buf, count, ppos, tmp, used); |
| 469 | rcu_read_unlock(); | ||
| 470 | kfree(tmp); | 488 | kfree(tmp); |
| 471 | return ret; | 489 | return ret; |
| 472 | } | 490 | } |
| @@ -482,15 +500,12 @@ static ssize_t asic_flags_write(struct file *file, const char __user *buf, | |||
| 482 | u64 scratch0; | 500 | u64 scratch0; |
| 483 | u64 clear; | 501 | u64 clear; |
| 484 | 502 | ||
| 485 | rcu_read_lock(); | ||
| 486 | ppd = private2ppd(file); | 503 | ppd = private2ppd(file); |
| 487 | dd = ppd->dd; | 504 | dd = ppd->dd; |
| 488 | 505 | ||
| 489 | buff = kmalloc(count + 1, GFP_KERNEL); | 506 | buff = kmalloc(count + 1, GFP_KERNEL); |
| 490 | if (!buff) { | 507 | if (!buff) |
| 491 | ret = -ENOMEM; | 508 | return -ENOMEM; |
| 492 | goto do_return; | ||
| 493 | } | ||
| 494 | 509 | ||
| 495 | ret = copy_from_user(buff, buf, count); | 510 | ret = copy_from_user(buff, buf, count); |
| 496 | if (ret > 0) { | 511 | if (ret > 0) { |
| @@ -523,8 +538,6 @@ static ssize_t asic_flags_write(struct file *file, const char __user *buf, | |||
| 523 | 538 | ||
| 524 | do_free: | 539 | do_free: |
| 525 | kfree(buff); | 540 | kfree(buff); |
| 526 | do_return: | ||
| 527 | rcu_read_unlock(); | ||
| 528 | return ret; | 541 | return ret; |
| 529 | } | 542 | } |
| 530 | 543 | ||
| @@ -538,18 +551,14 @@ static ssize_t qsfp_debugfs_dump(struct file *file, char __user *buf, | |||
| 538 | char *tmp; | 551 | char *tmp; |
| 539 | int ret; | 552 | int ret; |
| 540 | 553 | ||
| 541 | rcu_read_lock(); | ||
| 542 | ppd = private2ppd(file); | 554 | ppd = private2ppd(file); |
| 543 | tmp = kmalloc(PAGE_SIZE, GFP_KERNEL); | 555 | tmp = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 544 | if (!tmp) { | 556 | if (!tmp) |
| 545 | rcu_read_unlock(); | ||
| 546 | return -ENOMEM; | 557 | return -ENOMEM; |
| 547 | } | ||
| 548 | 558 | ||
| 549 | ret = qsfp_dump(ppd, tmp, PAGE_SIZE); | 559 | ret = qsfp_dump(ppd, tmp, PAGE_SIZE); |
| 550 | if (ret > 0) | 560 | if (ret > 0) |
| 551 | ret = simple_read_from_buffer(buf, count, ppos, tmp, ret); | 561 | ret = simple_read_from_buffer(buf, count, ppos, tmp, ret); |
| 552 | rcu_read_unlock(); | ||
| 553 | kfree(tmp); | 562 | kfree(tmp); |
| 554 | return ret; | 563 | return ret; |
| 555 | } | 564 | } |
| @@ -565,7 +574,6 @@ static ssize_t __i2c_debugfs_write(struct file *file, const char __user *buf, | |||
| 565 | int offset; | 574 | int offset; |
| 566 | int total_written; | 575 | int total_written; |
| 567 | 576 | ||
| 568 | rcu_read_lock(); | ||
| 569 | ppd = private2ppd(file); | 577 | ppd = private2ppd(file); |
| 570 | 578 | ||
| 571 | /* byte offset format: [offsetSize][i2cAddr][offsetHigh][offsetLow] */ | 579 | /* byte offset format: [offsetSize][i2cAddr][offsetHigh][offsetLow] */ |
| @@ -573,16 +581,12 @@ static ssize_t __i2c_debugfs_write(struct file *file, const char __user *buf, | |||
| 573 | offset = *ppos & 0xffff; | 581 | offset = *ppos & 0xffff; |
| 574 | 582 | ||
| 575 | /* explicitly reject invalid address 0 to catch cp and cat */ | 583 | /* explicitly reject invalid address 0 to catch cp and cat */ |
| 576 | if (i2c_addr == 0) { | 584 | if (i2c_addr == 0) |
| 577 | ret = -EINVAL; | 585 | return -EINVAL; |
| 578 | goto _return; | ||
| 579 | } | ||
| 580 | 586 | ||
| 581 | buff = kmalloc(count, GFP_KERNEL); | 587 | buff = kmalloc(count, GFP_KERNEL); |
| 582 | if (!buff) { | 588 | if (!buff) |
| 583 | ret = -ENOMEM; | 589 | return -ENOMEM; |
| 584 | goto _return; | ||
| 585 | } | ||
| 586 | 590 | ||
| 587 | ret = copy_from_user(buff, buf, count); | 591 | ret = copy_from_user(buff, buf, count); |
| 588 | if (ret > 0) { | 592 | if (ret > 0) { |
| @@ -602,8 +606,6 @@ static ssize_t __i2c_debugfs_write(struct file *file, const char __user *buf, | |||
| 602 | 606 | ||
| 603 | _free: | 607 | _free: |
| 604 | kfree(buff); | 608 | kfree(buff); |
| 605 | _return: | ||
| 606 | rcu_read_unlock(); | ||
| 607 | return ret; | 609 | return ret; |
| 608 | } | 610 | } |
| 609 | 611 | ||
| @@ -632,7 +634,6 @@ static ssize_t __i2c_debugfs_read(struct file *file, char __user *buf, | |||
| 632 | int offset; | 634 | int offset; |
| 633 | int total_read; | 635 | int total_read; |
| 634 | 636 | ||
| 635 | rcu_read_lock(); | ||
| 636 | ppd = private2ppd(file); | 637 | ppd = private2ppd(file); |
| 637 | 638 | ||
| 638 | /* byte offset format: [offsetSize][i2cAddr][offsetHigh][offsetLow] */ | 639 | /* byte offset format: [offsetSize][i2cAddr][offsetHigh][offsetLow] */ |
| @@ -640,16 +641,12 @@ static ssize_t __i2c_debugfs_read(struct file *file, char __user *buf, | |||
| 640 | offset = *ppos & 0xffff; | 641 | offset = *ppos & 0xffff; |
| 641 | 642 | ||
| 642 | /* explicitly reject invalid address 0 to catch cp and cat */ | 643 | /* explicitly reject invalid address 0 to catch cp and cat */ |
| 643 | if (i2c_addr == 0) { | 644 | if (i2c_addr == 0) |
| 644 | ret = -EINVAL; | 645 | return -EINVAL; |
| 645 | goto _return; | ||
| 646 | } | ||
| 647 | 646 | ||
| 648 | buff = kmalloc(count, GFP_KERNEL); | 647 | buff = kmalloc(count, GFP_KERNEL); |
| 649 | if (!buff) { | 648 | if (!buff) |
| 650 | ret = -ENOMEM; | 649 | return -ENOMEM; |
| 651 | goto _return; | ||
| 652 | } | ||
| 653 | 650 | ||
| 654 | total_read = i2c_read(ppd, target, i2c_addr, offset, buff, count); | 651 | total_read = i2c_read(ppd, target, i2c_addr, offset, buff, count); |
| 655 | if (total_read < 0) { | 652 | if (total_read < 0) { |
| @@ -669,8 +666,6 @@ static ssize_t __i2c_debugfs_read(struct file *file, char __user *buf, | |||
| 669 | 666 | ||
| 670 | _free: | 667 | _free: |
| 671 | kfree(buff); | 668 | kfree(buff); |
| 672 | _return: | ||
| 673 | rcu_read_unlock(); | ||
| 674 | return ret; | 669 | return ret; |
| 675 | } | 670 | } |
| 676 | 671 | ||
| @@ -697,26 +692,20 @@ static ssize_t __qsfp_debugfs_write(struct file *file, const char __user *buf, | |||
| 697 | int ret; | 692 | int ret; |
| 698 | int total_written; | 693 | int total_written; |
| 699 | 694 | ||
| 700 | rcu_read_lock(); | 695 | if (*ppos + count > QSFP_PAGESIZE * 4) /* base page + page00-page03 */ |
| 701 | if (*ppos + count > QSFP_PAGESIZE * 4) { /* base page + page00-page03 */ | 696 | return -EINVAL; |
| 702 | ret = -EINVAL; | ||
| 703 | goto _return; | ||
| 704 | } | ||
| 705 | 697 | ||
| 706 | ppd = private2ppd(file); | 698 | ppd = private2ppd(file); |
| 707 | 699 | ||
| 708 | buff = kmalloc(count, GFP_KERNEL); | 700 | buff = kmalloc(count, GFP_KERNEL); |
| 709 | if (!buff) { | 701 | if (!buff) |
| 710 | ret = -ENOMEM; | 702 | return -ENOMEM; |
| 711 | goto _return; | ||
| 712 | } | ||
| 713 | 703 | ||
| 714 | ret = copy_from_user(buff, buf, count); | 704 | ret = copy_from_user(buff, buf, count); |
| 715 | if (ret > 0) { | 705 | if (ret > 0) { |
| 716 | ret = -EFAULT; | 706 | ret = -EFAULT; |
| 717 | goto _free; | 707 | goto _free; |
| 718 | } | 708 | } |
| 719 | |||
| 720 | total_written = qsfp_write(ppd, target, *ppos, buff, count); | 709 | total_written = qsfp_write(ppd, target, *ppos, buff, count); |
| 721 | if (total_written < 0) { | 710 | if (total_written < 0) { |
| 722 | ret = total_written; | 711 | ret = total_written; |
| @@ -729,8 +718,6 @@ static ssize_t __qsfp_debugfs_write(struct file *file, const char __user *buf, | |||
| 729 | 718 | ||
| 730 | _free: | 719 | _free: |
| 731 | kfree(buff); | 720 | kfree(buff); |
| 732 | _return: | ||
| 733 | rcu_read_unlock(); | ||
| 734 | return ret; | 721 | return ret; |
| 735 | } | 722 | } |
| 736 | 723 | ||
| @@ -757,7 +744,6 @@ static ssize_t __qsfp_debugfs_read(struct file *file, char __user *buf, | |||
| 757 | int ret; | 744 | int ret; |
| 758 | int total_read; | 745 | int total_read; |
| 759 | 746 | ||
| 760 | rcu_read_lock(); | ||
| 761 | if (*ppos + count > QSFP_PAGESIZE * 4) { /* base page + page00-page03 */ | 747 | if (*ppos + count > QSFP_PAGESIZE * 4) { /* base page + page00-page03 */ |
| 762 | ret = -EINVAL; | 748 | ret = -EINVAL; |
| 763 | goto _return; | 749 | goto _return; |
| @@ -790,7 +776,6 @@ static ssize_t __qsfp_debugfs_read(struct file *file, char __user *buf, | |||
| 790 | _free: | 776 | _free: |
| 791 | kfree(buff); | 777 | kfree(buff); |
| 792 | _return: | 778 | _return: |
| 793 | rcu_read_unlock(); | ||
| 794 | return ret; | 779 | return ret; |
| 795 | } | 780 | } |
| 796 | 781 | ||
| @@ -1006,7 +991,6 @@ void hfi1_dbg_ibdev_exit(struct hfi1_ibdev *ibd) | |||
| 1006 | debugfs_remove_recursive(ibd->hfi1_ibdev_dbg); | 991 | debugfs_remove_recursive(ibd->hfi1_ibdev_dbg); |
| 1007 | out: | 992 | out: |
| 1008 | ibd->hfi1_ibdev_dbg = NULL; | 993 | ibd->hfi1_ibdev_dbg = NULL; |
| 1009 | synchronize_rcu(); | ||
| 1010 | } | 994 | } |
| 1011 | 995 | ||
| 1012 | /* | 996 | /* |
| @@ -1031,9 +1015,7 @@ static const char * const hfi1_statnames[] = { | |||
| 1031 | }; | 1015 | }; |
| 1032 | 1016 | ||
| 1033 | static void *_driver_stats_names_seq_start(struct seq_file *s, loff_t *pos) | 1017 | static void *_driver_stats_names_seq_start(struct seq_file *s, loff_t *pos) |
| 1034 | __acquires(RCU) | ||
| 1035 | { | 1018 | { |
| 1036 | rcu_read_lock(); | ||
| 1037 | if (*pos >= ARRAY_SIZE(hfi1_statnames)) | 1019 | if (*pos >= ARRAY_SIZE(hfi1_statnames)) |
| 1038 | return NULL; | 1020 | return NULL; |
| 1039 | return pos; | 1021 | return pos; |
| @@ -1051,9 +1033,7 @@ static void *_driver_stats_names_seq_next( | |||
| 1051 | } | 1033 | } |
| 1052 | 1034 | ||
| 1053 | static void _driver_stats_names_seq_stop(struct seq_file *s, void *v) | 1035 | static void _driver_stats_names_seq_stop(struct seq_file *s, void *v) |
| 1054 | __releases(RCU) | ||
| 1055 | { | 1036 | { |
| 1056 | rcu_read_unlock(); | ||
| 1057 | } | 1037 | } |
| 1058 | 1038 | ||
| 1059 | static int _driver_stats_names_seq_show(struct seq_file *s, void *v) | 1039 | static int _driver_stats_names_seq_show(struct seq_file *s, void *v) |
| @@ -1069,9 +1049,7 @@ DEBUGFS_SEQ_FILE_OPEN(driver_stats_names) | |||
| 1069 | DEBUGFS_FILE_OPS(driver_stats_names); | 1049 | DEBUGFS_FILE_OPS(driver_stats_names); |
| 1070 | 1050 | ||
| 1071 | static void *_driver_stats_seq_start(struct seq_file *s, loff_t *pos) | 1051 | static void *_driver_stats_seq_start(struct seq_file *s, loff_t *pos) |
| 1072 | __acquires(RCU) | ||
| 1073 | { | 1052 | { |
| 1074 | rcu_read_lock(); | ||
| 1075 | if (*pos >= ARRAY_SIZE(hfi1_statnames)) | 1053 | if (*pos >= ARRAY_SIZE(hfi1_statnames)) |
| 1076 | return NULL; | 1054 | return NULL; |
| 1077 | return pos; | 1055 | return pos; |
| @@ -1086,9 +1064,7 @@ static void *_driver_stats_seq_next(struct seq_file *s, void *v, loff_t *pos) | |||
| 1086 | } | 1064 | } |
| 1087 | 1065 | ||
| 1088 | static void _driver_stats_seq_stop(struct seq_file *s, void *v) | 1066 | static void _driver_stats_seq_stop(struct seq_file *s, void *v) |
| 1089 | __releases(RCU) | ||
| 1090 | { | 1067 | { |
| 1091 | rcu_read_unlock(); | ||
| 1092 | } | 1068 | } |
| 1093 | 1069 | ||
| 1094 | static u64 hfi1_sps_ints(void) | 1070 | static u64 hfi1_sps_ints(void) |
diff --git a/drivers/infiniband/hw/hfi1/driver.c b/drivers/infiniband/hw/hfi1/driver.c index 8246dc7d0573..303f10555729 100644 --- a/drivers/infiniband/hw/hfi1/driver.c +++ b/drivers/infiniband/hw/hfi1/driver.c | |||
| @@ -888,14 +888,15 @@ void set_all_slowpath(struct hfi1_devdata *dd) | |||
| 888 | } | 888 | } |
| 889 | 889 | ||
| 890 | static inline int set_armed_to_active(struct hfi1_ctxtdata *rcd, | 890 | static inline int set_armed_to_active(struct hfi1_ctxtdata *rcd, |
| 891 | struct hfi1_packet packet, | 891 | struct hfi1_packet *packet, |
| 892 | struct hfi1_devdata *dd) | 892 | struct hfi1_devdata *dd) |
| 893 | { | 893 | { |
| 894 | struct work_struct *lsaw = &rcd->ppd->linkstate_active_work; | 894 | struct work_struct *lsaw = &rcd->ppd->linkstate_active_work; |
| 895 | struct hfi1_message_header *hdr = hfi1_get_msgheader(packet.rcd->dd, | 895 | struct hfi1_message_header *hdr = hfi1_get_msgheader(packet->rcd->dd, |
| 896 | packet.rhf_addr); | 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 | int hwstate = read_logical_state(dd); | 900 | int hwstate = read_logical_state(dd); |
| 900 | 901 | ||
| 901 | if (hwstate != LSTATE_ACTIVE) { | 902 | if (hwstate != LSTATE_ACTIVE) { |
| @@ -979,7 +980,7 @@ int handle_receive_interrupt(struct hfi1_ctxtdata *rcd, int thread) | |||
| 979 | /* Auto activate link on non-SC15 packet receive */ | 980 | /* Auto activate link on non-SC15 packet receive */ |
| 980 | if (unlikely(rcd->ppd->host_link_state == | 981 | if (unlikely(rcd->ppd->host_link_state == |
| 981 | HLS_UP_ARMED) && | 982 | HLS_UP_ARMED) && |
| 982 | set_armed_to_active(rcd, packet, dd)) | 983 | set_armed_to_active(rcd, &packet, dd)) |
| 983 | goto bail; | 984 | goto bail; |
| 984 | last = process_rcv_packet(&packet, thread); | 985 | last = process_rcv_packet(&packet, thread); |
| 985 | } | 986 | } |
diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c index 1ecbec192358..7e03ccd2554d 100644 --- a/drivers/infiniband/hw/hfi1/file_ops.c +++ b/drivers/infiniband/hw/hfi1/file_ops.c | |||
| @@ -183,6 +183,7 @@ static int hfi1_file_open(struct inode *inode, struct file *fp) | |||
| 183 | if (fd) { | 183 | if (fd) { |
| 184 | fd->rec_cpu_num = -1; /* no cpu affinity by default */ | 184 | fd->rec_cpu_num = -1; /* no cpu affinity by default */ |
| 185 | fd->mm = current->mm; | 185 | fd->mm = current->mm; |
| 186 | atomic_inc(&fd->mm->mm_count); | ||
| 186 | } | 187 | } |
| 187 | 188 | ||
| 188 | fp->private_data = fd; | 189 | fp->private_data = fd; |
| @@ -222,7 +223,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, | |||
| 222 | ret = assign_ctxt(fp, &uinfo); | 223 | ret = assign_ctxt(fp, &uinfo); |
| 223 | if (ret < 0) | 224 | if (ret < 0) |
| 224 | return ret; | 225 | return ret; |
| 225 | setup_ctxt(fp); | 226 | ret = setup_ctxt(fp); |
| 226 | if (ret) | 227 | if (ret) |
| 227 | return ret; | 228 | return ret; |
| 228 | ret = user_init(fp); | 229 | ret = user_init(fp); |
| @@ -779,6 +780,7 @@ static int hfi1_file_close(struct inode *inode, struct file *fp) | |||
| 779 | mutex_unlock(&hfi1_mutex); | 780 | mutex_unlock(&hfi1_mutex); |
| 780 | hfi1_free_ctxtdata(dd, uctxt); | 781 | hfi1_free_ctxtdata(dd, uctxt); |
| 781 | done: | 782 | done: |
| 783 | mmdrop(fdata->mm); | ||
| 782 | kobject_put(&dd->kobj); | 784 | kobject_put(&dd->kobj); |
| 783 | kfree(fdata); | 785 | kfree(fdata); |
| 784 | return 0; | 786 | return 0; |
diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h index 1000e0fd96d9..325ec211370f 100644 --- a/drivers/infiniband/hw/hfi1/hfi.h +++ b/drivers/infiniband/hw/hfi1/hfi.h | |||
| @@ -605,6 +605,7 @@ struct hfi1_pportdata { | |||
| 605 | struct work_struct freeze_work; | 605 | struct work_struct freeze_work; |
| 606 | struct work_struct link_downgrade_work; | 606 | struct work_struct link_downgrade_work; |
| 607 | struct work_struct link_bounce_work; | 607 | struct work_struct link_bounce_work; |
| 608 | struct delayed_work start_link_work; | ||
| 608 | /* host link state variables */ | 609 | /* host link state variables */ |
| 609 | struct mutex hls_lock; | 610 | struct mutex hls_lock; |
| 610 | u32 host_link_state; | 611 | u32 host_link_state; |
| @@ -659,6 +660,7 @@ struct hfi1_pportdata { | |||
| 659 | u8 linkinit_reason; | 660 | u8 linkinit_reason; |
| 660 | u8 local_tx_rate; /* rate given to 8051 firmware */ | 661 | u8 local_tx_rate; /* rate given to 8051 firmware */ |
| 661 | u8 last_pstate; /* info only */ | 662 | u8 last_pstate; /* info only */ |
| 663 | u8 qsfp_retry_count; | ||
| 662 | 664 | ||
| 663 | /* placeholders for IB MAD packet settings */ | 665 | /* placeholders for IB MAD packet settings */ |
| 664 | u8 overrun_threshold; | 666 | u8 overrun_threshold; |
| @@ -1272,9 +1274,26 @@ static inline int hdr2sc(struct hfi1_message_header *hdr, u64 rhf) | |||
| 1272 | ((!!(rhf_dc_info(rhf))) << 4); | 1274 | ((!!(rhf_dc_info(rhf))) << 4); |
| 1273 | } | 1275 | } |
| 1274 | 1276 | ||
| 1277 | #define HFI1_JKEY_WIDTH 16 | ||
| 1278 | #define HFI1_JKEY_MASK (BIT(16) - 1) | ||
| 1279 | #define HFI1_ADMIN_JKEY_RANGE 32 | ||
| 1280 | |||
| 1281 | /* | ||
| 1282 | * J_KEYs are split and allocated in the following groups: | ||
| 1283 | * 0 - 31 - users with administrator privileges | ||
| 1284 | * 32 - 63 - kernel protocols using KDETH packets | ||
| 1285 | * 64 - 65535 - all other users using KDETH packets | ||
| 1286 | */ | ||
| 1275 | static inline u16 generate_jkey(kuid_t uid) | 1287 | static inline u16 generate_jkey(kuid_t uid) |
| 1276 | { | 1288 | { |
| 1277 | return from_kuid(current_user_ns(), uid) & 0xffff; | 1289 | u16 jkey = from_kuid(current_user_ns(), uid) & HFI1_JKEY_MASK; |
| 1290 | |||
| 1291 | if (capable(CAP_SYS_ADMIN)) | ||
| 1292 | jkey &= HFI1_ADMIN_JKEY_RANGE - 1; | ||
| 1293 | else if (jkey < 64) | ||
| 1294 | jkey |= BIT(HFI1_JKEY_WIDTH - 1); | ||
| 1295 | |||
| 1296 | return jkey; | ||
| 1278 | } | 1297 | } |
| 1279 | 1298 | ||
| 1280 | /* | 1299 | /* |
| @@ -1656,7 +1675,6 @@ struct cc_state *get_cc_state_protected(struct hfi1_pportdata *ppd) | |||
| 1656 | struct hfi1_devdata *hfi1_init_dd(struct pci_dev *, | 1675 | struct hfi1_devdata *hfi1_init_dd(struct pci_dev *, |
| 1657 | const struct pci_device_id *); | 1676 | const struct pci_device_id *); |
| 1658 | void hfi1_free_devdata(struct hfi1_devdata *); | 1677 | void hfi1_free_devdata(struct hfi1_devdata *); |
| 1659 | void cc_state_reclaim(struct rcu_head *rcu); | ||
| 1660 | struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, size_t extra); | 1678 | struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, size_t extra); |
| 1661 | 1679 | ||
| 1662 | /* LED beaconing functions */ | 1680 | /* LED beaconing functions */ |
| @@ -1788,7 +1806,7 @@ extern unsigned int hfi1_max_mtu; | |||
| 1788 | extern unsigned int hfi1_cu; | 1806 | extern unsigned int hfi1_cu; |
| 1789 | extern unsigned int user_credit_return_threshold; | 1807 | extern unsigned int user_credit_return_threshold; |
| 1790 | extern int num_user_contexts; | 1808 | extern int num_user_contexts; |
| 1791 | extern unsigned n_krcvqs; | 1809 | extern unsigned long n_krcvqs; |
| 1792 | extern uint krcvqs[]; | 1810 | extern uint krcvqs[]; |
| 1793 | extern int krcvqsset; | 1811 | extern int krcvqsset; |
| 1794 | extern uint kdeth_qp; | 1812 | extern uint kdeth_qp; |
diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c index a358d23ecd54..384b43d2fd49 100644 --- a/drivers/infiniband/hw/hfi1/init.c +++ b/drivers/infiniband/hw/hfi1/init.c | |||
| @@ -94,7 +94,7 @@ module_param_array(krcvqs, uint, &krcvqsset, S_IRUGO); | |||
| 94 | MODULE_PARM_DESC(krcvqs, "Array of the number of non-control kernel receive queues by VL"); | 94 | MODULE_PARM_DESC(krcvqs, "Array of the number of non-control kernel receive queues by VL"); |
| 95 | 95 | ||
| 96 | /* computed based on above array */ | 96 | /* computed based on above array */ |
| 97 | unsigned n_krcvqs; | 97 | unsigned long n_krcvqs; |
| 98 | 98 | ||
| 99 | static unsigned hfi1_rcvarr_split = 25; | 99 | static unsigned hfi1_rcvarr_split = 25; |
| 100 | module_param_named(rcvarr_split, hfi1_rcvarr_split, uint, S_IRUGO); | 100 | module_param_named(rcvarr_split, hfi1_rcvarr_split, uint, S_IRUGO); |
| @@ -500,6 +500,7 @@ void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd, | |||
| 500 | INIT_WORK(&ppd->link_downgrade_work, handle_link_downgrade); | 500 | INIT_WORK(&ppd->link_downgrade_work, handle_link_downgrade); |
| 501 | INIT_WORK(&ppd->sma_message_work, handle_sma_message); | 501 | INIT_WORK(&ppd->sma_message_work, handle_sma_message); |
| 502 | INIT_WORK(&ppd->link_bounce_work, handle_link_bounce); | 502 | INIT_WORK(&ppd->link_bounce_work, handle_link_bounce); |
| 503 | INIT_DELAYED_WORK(&ppd->start_link_work, handle_start_link); | ||
| 503 | INIT_WORK(&ppd->linkstate_active_work, receive_interrupt_work); | 504 | INIT_WORK(&ppd->linkstate_active_work, receive_interrupt_work); |
| 504 | INIT_WORK(&ppd->qsfp_info.qsfp_work, qsfp_event); | 505 | INIT_WORK(&ppd->qsfp_info.qsfp_work, qsfp_event); |
| 505 | 506 | ||
| @@ -1333,7 +1334,7 @@ static void cleanup_device_data(struct hfi1_devdata *dd) | |||
| 1333 | spin_unlock(&ppd->cc_state_lock); | 1334 | spin_unlock(&ppd->cc_state_lock); |
| 1334 | 1335 | ||
| 1335 | if (cc_state) | 1336 | if (cc_state) |
| 1336 | call_rcu(&cc_state->rcu, cc_state_reclaim); | 1337 | kfree_rcu(cc_state, rcu); |
| 1337 | } | 1338 | } |
| 1338 | 1339 | ||
| 1339 | free_credit_return(dd); | 1340 | free_credit_return(dd); |
diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c index 1263abe01999..7ffc14f21523 100644 --- a/drivers/infiniband/hw/hfi1/mad.c +++ b/drivers/infiniband/hw/hfi1/mad.c | |||
| @@ -1819,6 +1819,11 @@ static int __subn_get_opa_cable_info(struct opa_smp *smp, u32 am, u8 *data, | |||
| 1819 | u32 len = OPA_AM_CI_LEN(am) + 1; | 1819 | u32 len = OPA_AM_CI_LEN(am) + 1; |
| 1820 | int ret; | 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 | #define __CI_PAGE_SIZE BIT(7) /* 128 bytes */ | 1827 | #define __CI_PAGE_SIZE BIT(7) /* 128 bytes */ |
| 1823 | #define __CI_PAGE_MASK ~(__CI_PAGE_SIZE - 1) | 1828 | #define __CI_PAGE_MASK ~(__CI_PAGE_SIZE - 1) |
| 1824 | #define __CI_PAGE_NUM(a) ((a) & __CI_PAGE_MASK) | 1829 | #define __CI_PAGE_NUM(a) ((a) & __CI_PAGE_MASK) |
| @@ -2599,7 +2604,7 @@ static int pma_get_opa_datacounters(struct opa_pma_mad *pmp, | |||
| 2599 | u8 lq, num_vls; | 2604 | u8 lq, num_vls; |
| 2600 | u8 res_lli, res_ler; | 2605 | u8 res_lli, res_ler; |
| 2601 | u64 port_mask; | 2606 | u64 port_mask; |
| 2602 | unsigned long port_num; | 2607 | u8 port_num; |
| 2603 | unsigned long vl; | 2608 | unsigned long vl; |
| 2604 | u32 vl_select_mask; | 2609 | u32 vl_select_mask; |
| 2605 | int vfi; | 2610 | int vfi; |
| @@ -2633,9 +2638,9 @@ static int pma_get_opa_datacounters(struct opa_pma_mad *pmp, | |||
| 2633 | */ | 2638 | */ |
| 2634 | port_mask = be64_to_cpu(req->port_select_mask[3]); | 2639 | port_mask = be64_to_cpu(req->port_select_mask[3]); |
| 2635 | port_num = find_first_bit((unsigned long *)&port_mask, | 2640 | port_num = find_first_bit((unsigned long *)&port_mask, |
| 2636 | sizeof(port_mask)); | 2641 | sizeof(port_mask) * 8); |
| 2637 | 2642 | ||
| 2638 | if ((u8)port_num != port) { | 2643 | if (port_num != port) { |
| 2639 | pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; | 2644 | pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; |
| 2640 | return reply((struct ib_mad_hdr *)pmp); | 2645 | return reply((struct ib_mad_hdr *)pmp); |
| 2641 | } | 2646 | } |
| @@ -2837,7 +2842,7 @@ static int pma_get_opa_porterrors(struct opa_pma_mad *pmp, | |||
| 2837 | */ | 2842 | */ |
| 2838 | port_mask = be64_to_cpu(req->port_select_mask[3]); | 2843 | port_mask = be64_to_cpu(req->port_select_mask[3]); |
| 2839 | port_num = find_first_bit((unsigned long *)&port_mask, | 2844 | port_num = find_first_bit((unsigned long *)&port_mask, |
| 2840 | sizeof(port_mask)); | 2845 | sizeof(port_mask) * 8); |
| 2841 | 2846 | ||
| 2842 | if (port_num != port) { | 2847 | if (port_num != port) { |
| 2843 | pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; | 2848 | pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; |
| @@ -3010,7 +3015,7 @@ static int pma_get_opa_errorinfo(struct opa_pma_mad *pmp, | |||
| 3010 | */ | 3015 | */ |
| 3011 | port_mask = be64_to_cpu(req->port_select_mask[3]); | 3016 | port_mask = be64_to_cpu(req->port_select_mask[3]); |
| 3012 | port_num = find_first_bit((unsigned long *)&port_mask, | 3017 | port_num = find_first_bit((unsigned long *)&port_mask, |
| 3013 | sizeof(port_mask)); | 3018 | sizeof(port_mask) * 8); |
| 3014 | 3019 | ||
| 3015 | if (port_num != port) { | 3020 | if (port_num != port) { |
| 3016 | pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; | 3021 | pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; |
| @@ -3247,7 +3252,7 @@ static int pma_set_opa_errorinfo(struct opa_pma_mad *pmp, | |||
| 3247 | */ | 3252 | */ |
| 3248 | port_mask = be64_to_cpu(req->port_select_mask[3]); | 3253 | port_mask = be64_to_cpu(req->port_select_mask[3]); |
| 3249 | port_num = find_first_bit((unsigned long *)&port_mask, | 3254 | port_num = find_first_bit((unsigned long *)&port_mask, |
| 3250 | sizeof(port_mask)); | 3255 | sizeof(port_mask) * 8); |
| 3251 | 3256 | ||
| 3252 | if (port_num != port) { | 3257 | if (port_num != port) { |
| 3253 | pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; | 3258 | pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD; |
| @@ -3398,7 +3403,7 @@ static void apply_cc_state(struct hfi1_pportdata *ppd) | |||
| 3398 | 3403 | ||
| 3399 | spin_unlock(&ppd->cc_state_lock); | 3404 | spin_unlock(&ppd->cc_state_lock); |
| 3400 | 3405 | ||
| 3401 | call_rcu(&old_cc_state->rcu, cc_state_reclaim); | 3406 | kfree_rcu(old_cc_state, rcu); |
| 3402 | } | 3407 | } |
| 3403 | 3408 | ||
| 3404 | static int __subn_set_opa_cong_setting(struct opa_smp *smp, u32 am, u8 *data, | 3409 | static int __subn_set_opa_cong_setting(struct opa_smp *smp, u32 am, u8 *data, |
| @@ -3553,13 +3558,6 @@ static int __subn_get_opa_cc_table(struct opa_smp *smp, u32 am, u8 *data, | |||
| 3553 | return reply((struct ib_mad_hdr *)smp); | 3558 | return reply((struct ib_mad_hdr *)smp); |
| 3554 | } | 3559 | } |
| 3555 | 3560 | ||
| 3556 | void cc_state_reclaim(struct rcu_head *rcu) | ||
| 3557 | { | ||
| 3558 | struct cc_state *cc_state = container_of(rcu, struct cc_state, rcu); | ||
| 3559 | |||
| 3560 | kfree(cc_state); | ||
| 3561 | } | ||
| 3562 | |||
| 3563 | static int __subn_set_opa_cc_table(struct opa_smp *smp, u32 am, u8 *data, | 3561 | static int __subn_set_opa_cc_table(struct opa_smp *smp, u32 am, u8 *data, |
| 3564 | struct ib_device *ibdev, u8 port, | 3562 | struct ib_device *ibdev, u8 port, |
| 3565 | u32 *resp_len) | 3563 | u32 *resp_len) |
diff --git a/drivers/infiniband/hw/hfi1/pio_copy.c b/drivers/infiniband/hw/hfi1/pio_copy.c index 8c25e1b58849..3a1ef3056282 100644 --- a/drivers/infiniband/hw/hfi1/pio_copy.c +++ b/drivers/infiniband/hw/hfi1/pio_copy.c | |||
| @@ -771,6 +771,9 @@ void seg_pio_copy_mid(struct pio_buf *pbuf, const void *from, size_t nbytes) | |||
| 771 | read_extra_bytes(pbuf, from, to_fill); | 771 | read_extra_bytes(pbuf, from, to_fill); |
| 772 | from += to_fill; | 772 | from += to_fill; |
| 773 | nbytes -= to_fill; | 773 | nbytes -= to_fill; |
| 774 | /* may not be enough valid bytes left to align */ | ||
| 775 | if (extra > nbytes) | ||
| 776 | extra = nbytes; | ||
| 774 | 777 | ||
| 775 | /* ...now write carry */ | 778 | /* ...now write carry */ |
| 776 | dest = pbuf->start + (pbuf->qw_written * sizeof(u64)); | 779 | dest = pbuf->start + (pbuf->qw_written * sizeof(u64)); |
| @@ -798,6 +801,15 @@ void seg_pio_copy_mid(struct pio_buf *pbuf, const void *from, size_t nbytes) | |||
| 798 | read_low_bytes(pbuf, from, extra); | 801 | read_low_bytes(pbuf, from, extra); |
| 799 | from += extra; | 802 | from += extra; |
| 800 | nbytes -= extra; | 803 | nbytes -= extra; |
| 804 | /* | ||
| 805 | * If no bytes are left, return early - we are done. | ||
| 806 | * NOTE: This short-circuit is *required* because | ||
| 807 | * "extra" may have been reduced in size and "from" | ||
| 808 | * is not aligned, as required when leaving this | ||
| 809 | * if block. | ||
| 810 | */ | ||
| 811 | if (nbytes == 0) | ||
| 812 | return; | ||
| 801 | } | 813 | } |
| 802 | 814 | ||
| 803 | /* at this point, from is QW aligned */ | 815 | /* at this point, from is QW aligned */ |
diff --git a/drivers/infiniband/hw/hfi1/qp.c b/drivers/infiniband/hw/hfi1/qp.c index a5aa3517e7d5..4e4d8317c281 100644 --- a/drivers/infiniband/hw/hfi1/qp.c +++ b/drivers/infiniband/hw/hfi1/qp.c | |||
| @@ -656,10 +656,6 @@ struct qp_iter *qp_iter_init(struct hfi1_ibdev *dev) | |||
| 656 | 656 | ||
| 657 | iter->dev = dev; | 657 | iter->dev = dev; |
| 658 | iter->specials = dev->rdi.ibdev.phys_port_cnt * 2; | 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 | return iter; | 660 | return iter; |
| 665 | } | 661 | } |
diff --git a/drivers/infiniband/hw/hfi1/qsfp.c b/drivers/infiniband/hw/hfi1/qsfp.c index a207717ade2a..4e95ad810847 100644 --- a/drivers/infiniband/hw/hfi1/qsfp.c +++ b/drivers/infiniband/hw/hfi1/qsfp.c | |||
| @@ -706,8 +706,8 @@ int get_cable_info(struct hfi1_devdata *dd, u32 port_num, u32 addr, u32 len, | |||
| 706 | u8 *data) | 706 | u8 *data) |
| 707 | { | 707 | { |
| 708 | struct hfi1_pportdata *ppd; | 708 | struct hfi1_pportdata *ppd; |
| 709 | u32 excess_len = 0; | 709 | u32 excess_len = len; |
| 710 | int ret = 0; | 710 | int ret = 0, offset = 0; |
| 711 | 711 | ||
| 712 | if (port_num > dd->num_pports || port_num < 1) { | 712 | if (port_num > dd->num_pports || port_num < 1) { |
| 713 | dd_dev_info(dd, "%s: Invalid port number %d\n", | 713 | dd_dev_info(dd, "%s: Invalid port number %d\n", |
| @@ -740,6 +740,34 @@ int get_cable_info(struct hfi1_devdata *dd, u32 port_num, u32 addr, u32 len, | |||
| 740 | } | 740 | } |
| 741 | 741 | ||
| 742 | memcpy(data, &ppd->qsfp_info.cache[addr], len); | 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 | return 0; | 771 | return 0; |
| 744 | 772 | ||
| 745 | set_zeroes: | 773 | set_zeroes: |
diff --git a/drivers/infiniband/hw/hfi1/qsfp.h b/drivers/infiniband/hw/hfi1/qsfp.h index 69275ebd9597..36cf52359848 100644 --- a/drivers/infiniband/hw/hfi1/qsfp.h +++ b/drivers/infiniband/hw/hfi1/qsfp.h | |||
| @@ -74,6 +74,9 @@ | |||
| 74 | /* Defined fields that Intel requires of qualified cables */ | 74 | /* Defined fields that Intel requires of qualified cables */ |
| 75 | /* Byte 0 is Identifier, not checked */ | 75 | /* Byte 0 is Identifier, not checked */ |
| 76 | /* Byte 1 is reserved "status MSB" */ | 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 | #define QSFP_TX_CTRL_BYTE_OFFS 86 | 80 | #define QSFP_TX_CTRL_BYTE_OFFS 86 |
| 78 | #define QSFP_PWR_CTRL_BYTE_OFFS 93 | 81 | #define QSFP_PWR_CTRL_BYTE_OFFS 93 |
| 79 | #define QSFP_CDR_CTRL_BYTE_OFFS 98 | 82 | #define QSFP_CDR_CTRL_BYTE_OFFS 98 |
diff --git a/drivers/infiniband/hw/hfi1/user_sdma.c b/drivers/infiniband/hw/hfi1/user_sdma.c index 0ecf27903dc2..1694037d1eee 100644 --- a/drivers/infiniband/hw/hfi1/user_sdma.c +++ b/drivers/infiniband/hw/hfi1/user_sdma.c | |||
| @@ -114,6 +114,8 @@ MODULE_PARM_DESC(sdma_comp_size, "Size of User SDMA completion ring. Default: 12 | |||
| 114 | #define KDETH_HCRC_LOWER_SHIFT 24 | 114 | #define KDETH_HCRC_LOWER_SHIFT 24 |
| 115 | #define KDETH_HCRC_LOWER_MASK 0xff | 115 | #define KDETH_HCRC_LOWER_MASK 0xff |
| 116 | 116 | ||
| 117 | #define AHG_KDETH_INTR_SHIFT 12 | ||
| 118 | |||
| 117 | #define PBC2LRH(x) ((((x) & 0xfff) << 2) - 4) | 119 | #define PBC2LRH(x) ((((x) & 0xfff) << 2) - 4) |
| 118 | #define LRH2PBC(x) ((((x) >> 2) + 1) & 0xfff) | 120 | #define LRH2PBC(x) ((((x) >> 2) + 1) & 0xfff) |
| 119 | 121 | ||
| @@ -1480,7 +1482,8 @@ static int set_txreq_header_ahg(struct user_sdma_request *req, | |||
| 1480 | /* Clear KDETH.SH on last packet */ | 1482 | /* Clear KDETH.SH on last packet */ |
| 1481 | if (unlikely(tx->flags & TXREQ_FLAGS_REQ_LAST_PKT)) { | 1483 | if (unlikely(tx->flags & TXREQ_FLAGS_REQ_LAST_PKT)) { |
| 1482 | val |= cpu_to_le16(KDETH_GET(hdr->kdeth.ver_tid_offset, | 1484 | val |= cpu_to_le16(KDETH_GET(hdr->kdeth.ver_tid_offset, |
| 1483 | INTR) >> 16); | 1485 | INTR) << |
| 1486 | AHG_KDETH_INTR_SHIFT); | ||
| 1484 | val &= cpu_to_le16(~(1U << 13)); | 1487 | val &= cpu_to_le16(~(1U << 13)); |
| 1485 | AHG_HEADER_SET(req->ahg, diff, 7, 16, 14, val); | 1488 | AHG_HEADER_SET(req->ahg, diff, 7, 16, 14, val); |
| 1486 | } else { | 1489 | } else { |
diff --git a/drivers/infiniband/hw/i40iw/i40iw.h b/drivers/infiniband/hw/i40iw/i40iw.h index b738acdb9b02..8ec09e470f84 100644 --- a/drivers/infiniband/hw/i40iw/i40iw.h +++ b/drivers/infiniband/hw/i40iw/i40iw.h | |||
| @@ -232,7 +232,7 @@ struct i40iw_device { | |||
| 232 | struct i40e_client *client; | 232 | struct i40e_client *client; |
| 233 | struct i40iw_hw hw; | 233 | struct i40iw_hw hw; |
| 234 | struct i40iw_cm_core cm_core; | 234 | struct i40iw_cm_core cm_core; |
| 235 | unsigned long *mem_resources; | 235 | u8 *mem_resources; |
| 236 | unsigned long *allocated_qps; | 236 | unsigned long *allocated_qps; |
| 237 | unsigned long *allocated_cqs; | 237 | unsigned long *allocated_cqs; |
| 238 | unsigned long *allocated_mrs; | 238 | unsigned long *allocated_mrs; |
| @@ -435,8 +435,8 @@ static inline int i40iw_alloc_resource(struct i40iw_device *iwdev, | |||
| 435 | *next = resource_num + 1; | 435 | *next = resource_num + 1; |
| 436 | if (*next == max_resources) | 436 | if (*next == max_resources) |
| 437 | *next = 0; | 437 | *next = 0; |
| 438 | spin_unlock_irqrestore(&iwdev->resource_lock, flags); | ||
| 439 | *req_resource_num = resource_num; | 438 | *req_resource_num = resource_num; |
| 439 | spin_unlock_irqrestore(&iwdev->resource_lock, flags); | ||
| 440 | 440 | ||
| 441 | return 0; | 441 | return 0; |
| 442 | } | 442 | } |
diff --git a/drivers/infiniband/hw/i40iw/i40iw_cm.c b/drivers/infiniband/hw/i40iw/i40iw_cm.c index 5026dc79978a..7ca0638579c0 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_cm.c +++ b/drivers/infiniband/hw/i40iw/i40iw_cm.c | |||
| @@ -535,8 +535,8 @@ static struct i40iw_puda_buf *i40iw_form_cm_frame(struct i40iw_cm_node *cm_node, | |||
| 535 | buf += hdr_len; | 535 | buf += hdr_len; |
| 536 | } | 536 | } |
| 537 | 537 | ||
| 538 | if (pd_len) | 538 | if (pdata && pdata->addr) |
| 539 | memcpy(buf, pdata->addr, pd_len); | 539 | memcpy(buf, pdata->addr, pdata->size); |
| 540 | 540 | ||
| 541 | atomic_set(&sqbuf->refcount, 1); | 541 | atomic_set(&sqbuf->refcount, 1); |
| 542 | 542 | ||
| @@ -3347,26 +3347,6 @@ int i40iw_cm_disconn(struct i40iw_qp *iwqp) | |||
| 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 | * i40iw_qp_disconnect - free qp and close cm | 3350 | * i40iw_qp_disconnect - free qp and close cm |
| 3371 | * @iwqp: associate qp for the connection | 3351 | * @iwqp: associate qp for the connection |
| 3372 | */ | 3352 | */ |
| @@ -3638,7 +3618,7 @@ int i40iw_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
| 3638 | } else { | 3618 | } else { |
| 3639 | if (iwqp->page) | 3619 | if (iwqp->page) |
| 3640 | iwqp->sc_qp.qp_uk.sq_base = kmap(iwqp->page); | 3620 | iwqp->sc_qp.qp_uk.sq_base = kmap(iwqp->page); |
| 3641 | i40iw_loopback_nop(&iwqp->sc_qp); | 3621 | dev->iw_priv_qp_ops->qp_send_lsmm(&iwqp->sc_qp, NULL, 0, 0); |
| 3642 | } | 3622 | } |
| 3643 | 3623 | ||
| 3644 | if (iwqp->page) | 3624 | if (iwqp->page) |
diff --git a/drivers/infiniband/hw/i40iw/i40iw_hw.c b/drivers/infiniband/hw/i40iw/i40iw_hw.c index 3ee0cad96bc6..0c92a40b3e86 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_hw.c +++ b/drivers/infiniband/hw/i40iw/i40iw_hw.c | |||
| @@ -265,6 +265,7 @@ void i40iw_next_iw_state(struct i40iw_qp *iwqp, | |||
| 265 | info.dont_send_fin = false; | 265 | info.dont_send_fin = false; |
| 266 | if (iwqp->sc_qp.term_flags && (state == I40IW_QP_STATE_ERROR)) | 266 | if (iwqp->sc_qp.term_flags && (state == I40IW_QP_STATE_ERROR)) |
| 267 | info.reset_tcp_conn = true; | 267 | info.reset_tcp_conn = true; |
| 268 | iwqp->hw_iwarp_state = state; | ||
| 268 | i40iw_hw_modify_qp(iwqp->iwdev, iwqp, &info, 0); | 269 | i40iw_hw_modify_qp(iwqp->iwdev, iwqp, &info, 0); |
| 269 | } | 270 | } |
| 270 | 271 | ||
diff --git a/drivers/infiniband/hw/i40iw/i40iw_main.c b/drivers/infiniband/hw/i40iw/i40iw_main.c index 6e9081380a27..445e230d5ff8 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_main.c +++ b/drivers/infiniband/hw/i40iw/i40iw_main.c | |||
| @@ -100,7 +100,7 @@ static struct notifier_block i40iw_net_notifier = { | |||
| 100 | .notifier_call = i40iw_net_event | 100 | .notifier_call = i40iw_net_event |
| 101 | }; | 101 | }; |
| 102 | 102 | ||
| 103 | static int i40iw_notifiers_registered; | 103 | static atomic_t i40iw_notifiers_registered; |
| 104 | 104 | ||
| 105 | /** | 105 | /** |
| 106 | * i40iw_find_i40e_handler - find a handler given a client info | 106 | * i40iw_find_i40e_handler - find a handler given a client info |
| @@ -1342,12 +1342,11 @@ exit: | |||
| 1342 | */ | 1342 | */ |
| 1343 | static void i40iw_register_notifiers(void) | 1343 | static void i40iw_register_notifiers(void) |
| 1344 | { | 1344 | { |
| 1345 | if (!i40iw_notifiers_registered) { | 1345 | if (atomic_inc_return(&i40iw_notifiers_registered) == 1) { |
| 1346 | register_inetaddr_notifier(&i40iw_inetaddr_notifier); | 1346 | register_inetaddr_notifier(&i40iw_inetaddr_notifier); |
| 1347 | register_inet6addr_notifier(&i40iw_inetaddr6_notifier); | 1347 | register_inet6addr_notifier(&i40iw_inetaddr6_notifier); |
| 1348 | register_netevent_notifier(&i40iw_net_notifier); | 1348 | register_netevent_notifier(&i40iw_net_notifier); |
| 1349 | } | 1349 | } |
| 1350 | i40iw_notifiers_registered++; | ||
| 1351 | } | 1350 | } |
| 1352 | 1351 | ||
| 1353 | /** | 1352 | /** |
| @@ -1429,8 +1428,7 @@ static void i40iw_deinit_device(struct i40iw_device *iwdev, bool reset, bool del | |||
| 1429 | i40iw_del_macip_entry(iwdev, (u8)iwdev->mac_ip_table_idx); | 1428 | i40iw_del_macip_entry(iwdev, (u8)iwdev->mac_ip_table_idx); |
| 1430 | /* fallthrough */ | 1429 | /* fallthrough */ |
| 1431 | case INET_NOTIFIER: | 1430 | case INET_NOTIFIER: |
| 1432 | if (i40iw_notifiers_registered > 0) { | 1431 | if (!atomic_dec_return(&i40iw_notifiers_registered)) { |
| 1433 | i40iw_notifiers_registered--; | ||
| 1434 | unregister_netevent_notifier(&i40iw_net_notifier); | 1432 | unregister_netevent_notifier(&i40iw_net_notifier); |
| 1435 | unregister_inetaddr_notifier(&i40iw_inetaddr_notifier); | 1433 | unregister_inetaddr_notifier(&i40iw_inetaddr_notifier); |
| 1436 | unregister_inet6addr_notifier(&i40iw_inetaddr6_notifier); | 1434 | unregister_inet6addr_notifier(&i40iw_inetaddr6_notifier); |
| @@ -1558,6 +1556,10 @@ static int i40iw_open(struct i40e_info *ldev, struct i40e_client *client) | |||
| 1558 | enum i40iw_status_code status; | 1556 | enum i40iw_status_code status; |
| 1559 | struct i40iw_handler *hdl; | 1557 | struct i40iw_handler *hdl; |
| 1560 | 1558 | ||
| 1559 | hdl = i40iw_find_netdev(ldev->netdev); | ||
| 1560 | if (hdl) | ||
| 1561 | return 0; | ||
| 1562 | |||
| 1561 | hdl = kzalloc(sizeof(*hdl), GFP_KERNEL); | 1563 | hdl = kzalloc(sizeof(*hdl), GFP_KERNEL); |
| 1562 | if (!hdl) | 1564 | if (!hdl) |
| 1563 | return -ENOMEM; | 1565 | return -ENOMEM; |
diff --git a/drivers/infiniband/hw/i40iw/i40iw_utils.c b/drivers/infiniband/hw/i40iw/i40iw_utils.c index 0e8db0a35141..6fd043b1d714 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_utils.c +++ b/drivers/infiniband/hw/i40iw/i40iw_utils.c | |||
| @@ -673,8 +673,11 @@ enum i40iw_status_code i40iw_free_virt_mem(struct i40iw_hw *hw, | |||
| 673 | { | 673 | { |
| 674 | if (!mem) | 674 | if (!mem) |
| 675 | return I40IW_ERR_PARAM; | 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 | kfree(mem->va); | 680 | kfree(mem->va); |
| 677 | mem->va = NULL; | ||
| 678 | return 0; | 681 | return 0; |
| 679 | } | 682 | } |
| 680 | 683 | ||
diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c index 2360338877bf..6329c971c22f 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_verbs.c +++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c | |||
| @@ -794,7 +794,6 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd, | |||
| 794 | return &iwqp->ibqp; | 794 | return &iwqp->ibqp; |
| 795 | error: | 795 | error: |
| 796 | i40iw_free_qp_resources(iwdev, iwqp, qp_num); | 796 | i40iw_free_qp_resources(iwdev, iwqp, qp_num); |
| 797 | kfree(mem); | ||
| 798 | return ERR_PTR(err_code); | 797 | return ERR_PTR(err_code); |
| 799 | } | 798 | } |
| 800 | 799 | ||
| @@ -1926,8 +1925,7 @@ static int i40iw_dereg_mr(struct ib_mr *ib_mr) | |||
| 1926 | } | 1925 | } |
| 1927 | if (iwpbl->pbl_allocated) | 1926 | if (iwpbl->pbl_allocated) |
| 1928 | i40iw_free_pble(iwdev->pble_rsrc, palloc); | 1927 | i40iw_free_pble(iwdev->pble_rsrc, palloc); |
| 1929 | kfree(iwpbl->iwmr); | 1928 | kfree(iwmr); |
| 1930 | iwpbl->iwmr = NULL; | ||
| 1931 | return 0; | 1929 | return 0; |
| 1932 | } | 1930 | } |
| 1933 | 1931 | ||
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c index d6fc8a6e8c33..5df63dacaaa3 100644 --- a/drivers/infiniband/hw/mlx4/cq.c +++ b/drivers/infiniband/hw/mlx4/cq.c | |||
| @@ -576,8 +576,8 @@ static int mlx4_ib_ipoib_csum_ok(__be16 status, __be16 checksum) | |||
| 576 | checksum == cpu_to_be16(0xffff); | 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, | 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) | 580 | unsigned tail, struct mlx4_cqe *cqe, int is_eth) |
| 581 | { | 581 | { |
| 582 | struct mlx4_ib_proxy_sqp_hdr *hdr; | 582 | struct mlx4_ib_proxy_sqp_hdr *hdr; |
| 583 | 583 | ||
| @@ -600,8 +600,6 @@ static int use_tunnel_data(struct mlx4_ib_qp *qp, struct mlx4_ib_cq *cq, struct | |||
| 600 | wc->slid = be16_to_cpu(hdr->tun.slid_mac_47_32); | 600 | wc->slid = be16_to_cpu(hdr->tun.slid_mac_47_32); |
| 601 | wc->sl = (u8) (be16_to_cpu(hdr->tun.sl_vid) >> 12); | 601 | wc->sl = (u8) (be16_to_cpu(hdr->tun.sl_vid) >> 12); |
| 602 | } | 602 | } |
| 603 | |||
| 604 | return 0; | ||
| 605 | } | 603 | } |
| 606 | 604 | ||
| 607 | static void mlx4_ib_qp_sw_comp(struct mlx4_ib_qp *qp, int num_entries, | 605 | static void mlx4_ib_qp_sw_comp(struct mlx4_ib_qp *qp, int num_entries, |
| @@ -689,12 +687,6 @@ repoll: | |||
| 689 | is_error = (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == | 687 | is_error = (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == |
| 690 | MLX4_CQE_OPCODE_ERROR; | 688 | MLX4_CQE_OPCODE_ERROR; |
| 691 | 689 | ||
| 692 | if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == MLX4_OPCODE_NOP && | ||
| 693 | is_send)) { | ||
| 694 | pr_warn("Completion for NOP opcode detected!\n"); | ||
| 695 | return -EINVAL; | ||
| 696 | } | ||
| 697 | |||
| 698 | /* Resize CQ in progress */ | 690 | /* Resize CQ in progress */ |
| 699 | if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == MLX4_CQE_OPCODE_RESIZE)) { | 691 | if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == MLX4_CQE_OPCODE_RESIZE)) { |
| 700 | if (cq->resize_buf) { | 692 | if (cq->resize_buf) { |
| @@ -720,12 +712,6 @@ repoll: | |||
| 720 | */ | 712 | */ |
| 721 | mqp = __mlx4_qp_lookup(to_mdev(cq->ibcq.device)->dev, | 713 | mqp = __mlx4_qp_lookup(to_mdev(cq->ibcq.device)->dev, |
| 722 | be32_to_cpu(cqe->vlan_my_qpn)); | 714 | be32_to_cpu(cqe->vlan_my_qpn)); |
| 723 | if (unlikely(!mqp)) { | ||
| 724 | pr_warn("CQ %06x with entry for unknown QPN %06x\n", | ||
| 725 | cq->mcq.cqn, be32_to_cpu(cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK); | ||
| 726 | return -EINVAL; | ||
| 727 | } | ||
| 728 | |||
| 729 | *cur_qp = to_mibqp(mqp); | 715 | *cur_qp = to_mibqp(mqp); |
| 730 | } | 716 | } |
| 731 | 717 | ||
| @@ -738,11 +724,6 @@ repoll: | |||
| 738 | /* SRQ is also in the radix tree */ | 724 | /* SRQ is also in the radix tree */ |
| 739 | msrq = mlx4_srq_lookup(to_mdev(cq->ibcq.device)->dev, | 725 | msrq = mlx4_srq_lookup(to_mdev(cq->ibcq.device)->dev, |
| 740 | srq_num); | 726 | srq_num); |
| 741 | if (unlikely(!msrq)) { | ||
| 742 | pr_warn("CQ %06x with entry for unknown SRQN %06x\n", | ||
| 743 | cq->mcq.cqn, srq_num); | ||
| 744 | return -EINVAL; | ||
| 745 | } | ||
| 746 | } | 727 | } |
| 747 | 728 | ||
| 748 | if (is_send) { | 729 | if (is_send) { |
| @@ -852,9 +833,11 @@ repoll: | |||
| 852 | if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) { | 833 | if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) { |
| 853 | if ((*cur_qp)->mlx4_ib_qp_type & | 834 | if ((*cur_qp)->mlx4_ib_qp_type & |
| 854 | (MLX4_IB_QPT_PROXY_SMI_OWNER | | 835 | (MLX4_IB_QPT_PROXY_SMI_OWNER | |
| 855 | MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI)) | 836 | MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI)) { |
| 856 | return use_tunnel_data(*cur_qp, cq, wc, tail, | 837 | use_tunnel_data(*cur_qp, cq, wc, tail, cqe, |
| 857 | cqe, is_eth); | 838 | is_eth); |
| 839 | return 0; | ||
| 840 | } | ||
| 858 | } | 841 | } |
| 859 | 842 | ||
| 860 | wc->slid = be16_to_cpu(cqe->rlid); | 843 | wc->slid = be16_to_cpu(cqe->rlid); |
| @@ -891,7 +874,6 @@ int mlx4_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) | |||
| 891 | struct mlx4_ib_qp *cur_qp = NULL; | 874 | struct mlx4_ib_qp *cur_qp = NULL; |
| 892 | unsigned long flags; | 875 | unsigned long flags; |
| 893 | int npolled; | 876 | int npolled; |
| 894 | int err = 0; | ||
| 895 | struct mlx4_ib_dev *mdev = to_mdev(cq->ibcq.device); | 877 | struct mlx4_ib_dev *mdev = to_mdev(cq->ibcq.device); |
| 896 | 878 | ||
| 897 | spin_lock_irqsave(&cq->lock, flags); | 879 | spin_lock_irqsave(&cq->lock, flags); |
| @@ -901,8 +883,7 @@ int mlx4_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) | |||
| 901 | } | 883 | } |
| 902 | 884 | ||
| 903 | for (npolled = 0; npolled < num_entries; ++npolled) { | 885 | for (npolled = 0; npolled < num_entries; ++npolled) { |
| 904 | err = mlx4_ib_poll_one(cq, &cur_qp, wc + npolled); | 886 | if (mlx4_ib_poll_one(cq, &cur_qp, wc + npolled)) |
| 905 | if (err) | ||
| 906 | break; | 887 | break; |
| 907 | } | 888 | } |
| 908 | 889 | ||
| @@ -911,10 +892,7 @@ int mlx4_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) | |||
| 911 | out: | 892 | out: |
| 912 | spin_unlock_irqrestore(&cq->lock, flags); | 893 | spin_unlock_irqrestore(&cq->lock, flags); |
| 913 | 894 | ||
| 914 | if (err == 0 || err == -EAGAIN) | 895 | return npolled; |
| 915 | return npolled; | ||
| 916 | else | ||
| 917 | return err; | ||
| 918 | } | 896 | } |
| 919 | 897 | ||
| 920 | int mlx4_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) | 898 | int mlx4_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) |
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c index 9c2e53d28f98..0f21c3a25552 100644 --- a/drivers/infiniband/hw/mlx4/mad.c +++ b/drivers/infiniband/hw/mlx4/mad.c | |||
| @@ -1128,6 +1128,27 @@ void handle_port_mgmt_change_event(struct work_struct *work) | |||
| 1128 | 1128 | ||
| 1129 | /* Generate GUID changed event */ | 1129 | /* Generate GUID changed event */ |
| 1130 | if (changed_attr & MLX4_EQ_PORT_INFO_GID_PFX_CHANGE_MASK) { | 1130 | if (changed_attr & MLX4_EQ_PORT_INFO_GID_PFX_CHANGE_MASK) { |
| 1131 | if (mlx4_is_master(dev->dev)) { | ||
| 1132 | union ib_gid gid; | ||
| 1133 | int err = 0; | ||
| 1134 | |||
| 1135 | if (!eqe->event.port_mgmt_change.params.port_info.gid_prefix) | ||
| 1136 | err = __mlx4_ib_query_gid(&dev->ib_dev, port, 0, &gid, 1); | ||
| 1137 | else | ||
| 1138 | gid.global.subnet_prefix = | ||
| 1139 | eqe->event.port_mgmt_change.params.port_info.gid_prefix; | ||
| 1140 | if (err) { | ||
| 1141 | pr_warn("Could not change QP1 subnet prefix for port %d: query_gid error (%d)\n", | ||
| 1142 | port, err); | ||
| 1143 | } else { | ||
| 1144 | pr_debug("Changing QP1 subnet prefix for port %d. old=0x%llx. new=0x%llx\n", | ||
| 1145 | port, | ||
| 1146 | (u64)atomic64_read(&dev->sriov.demux[port - 1].subnet_prefix), | ||
| 1147 | be64_to_cpu(gid.global.subnet_prefix)); | ||
| 1148 | atomic64_set(&dev->sriov.demux[port - 1].subnet_prefix, | ||
| 1149 | be64_to_cpu(gid.global.subnet_prefix)); | ||
| 1150 | } | ||
| 1151 | } | ||
| 1131 | mlx4_ib_dispatch_event(dev, port, IB_EVENT_GID_CHANGE); | 1152 | mlx4_ib_dispatch_event(dev, port, IB_EVENT_GID_CHANGE); |
| 1132 | /*if master, notify all slaves*/ | 1153 | /*if master, notify all slaves*/ |
| 1133 | if (mlx4_is_master(dev->dev)) | 1154 | if (mlx4_is_master(dev->dev)) |
| @@ -2202,6 +2223,8 @@ int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev) | |||
| 2202 | if (err) | 2223 | if (err) |
| 2203 | goto demux_err; | 2224 | goto demux_err; |
| 2204 | dev->sriov.demux[i].guid_cache[0] = gid.global.interface_id; | 2225 | dev->sriov.demux[i].guid_cache[0] = gid.global.interface_id; |
| 2226 | atomic64_set(&dev->sriov.demux[i].subnet_prefix, | ||
| 2227 | be64_to_cpu(gid.global.subnet_prefix)); | ||
| 2205 | err = alloc_pv_object(dev, mlx4_master_func_num(dev->dev), i + 1, | 2228 | err = alloc_pv_object(dev, mlx4_master_func_num(dev->dev), i + 1, |
| 2206 | &dev->sriov.sqps[i]); | 2229 | &dev->sriov.sqps[i]); |
| 2207 | if (err) | 2230 | if (err) |
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 2af44c2de262..87ba9bca4181 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c | |||
| @@ -2202,6 +2202,9 @@ static int mlx4_ib_alloc_diag_counters(struct mlx4_ib_dev *ibdev) | |||
| 2202 | bool per_port = !!(ibdev->dev->caps.flags2 & | 2202 | bool per_port = !!(ibdev->dev->caps.flags2 & |
| 2203 | MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT); | 2203 | MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT); |
| 2204 | 2204 | ||
| 2205 | if (mlx4_is_slave(ibdev->dev)) | ||
| 2206 | return 0; | ||
| 2207 | |||
| 2205 | for (i = 0; i < MLX4_DIAG_COUNTERS_TYPES; i++) { | 2208 | for (i = 0; i < MLX4_DIAG_COUNTERS_TYPES; i++) { |
| 2206 | /* i == 1 means we are building port counters */ | 2209 | /* i == 1 means we are building port counters */ |
| 2207 | if (i && !per_port) | 2210 | if (i && !per_port) |
diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c index 8f7ad07915b0..097bfcc4ee99 100644 --- a/drivers/infiniband/hw/mlx4/mcg.c +++ b/drivers/infiniband/hw/mlx4/mcg.c | |||
| @@ -489,7 +489,7 @@ static u8 get_leave_state(struct mcast_group *group) | |||
| 489 | if (!group->members[i]) | 489 | if (!group->members[i]) |
| 490 | leave_state |= (1 << i); | 490 | leave_state |= (1 << i); |
| 491 | 491 | ||
| 492 | return leave_state & (group->rec.scope_join_state & 7); | 492 | return leave_state & (group->rec.scope_join_state & 0xf); |
| 493 | } | 493 | } |
| 494 | 494 | ||
| 495 | static int join_group(struct mcast_group *group, int slave, u8 join_mask) | 495 | static int join_group(struct mcast_group *group, int slave, u8 join_mask) |
| @@ -564,8 +564,8 @@ static void mlx4_ib_mcg_timeout_handler(struct work_struct *work) | |||
| 564 | } else | 564 | } else |
| 565 | mcg_warn_group(group, "DRIVER BUG\n"); | 565 | mcg_warn_group(group, "DRIVER BUG\n"); |
| 566 | } else if (group->state == MCAST_LEAVE_SENT) { | 566 | } else if (group->state == MCAST_LEAVE_SENT) { |
| 567 | if (group->rec.scope_join_state & 7) | 567 | if (group->rec.scope_join_state & 0xf) |
| 568 | group->rec.scope_join_state &= 0xf8; | 568 | group->rec.scope_join_state &= 0xf0; |
| 569 | group->state = MCAST_IDLE; | 569 | group->state = MCAST_IDLE; |
| 570 | mutex_unlock(&group->lock); | 570 | mutex_unlock(&group->lock); |
| 571 | if (release_group(group, 1)) | 571 | if (release_group(group, 1)) |
| @@ -605,7 +605,7 @@ static int handle_leave_req(struct mcast_group *group, u8 leave_mask, | |||
| 605 | static int handle_join_req(struct mcast_group *group, u8 join_mask, | 605 | static int handle_join_req(struct mcast_group *group, u8 join_mask, |
| 606 | struct mcast_req *req) | 606 | struct mcast_req *req) |
| 607 | { | 607 | { |
| 608 | u8 group_join_state = group->rec.scope_join_state & 7; | 608 | u8 group_join_state = group->rec.scope_join_state & 0xf; |
| 609 | int ref = 0; | 609 | int ref = 0; |
| 610 | u16 status; | 610 | u16 status; |
| 611 | struct ib_sa_mcmember_data *sa_data = (struct ib_sa_mcmember_data *)req->sa_mad.data; | 611 | struct ib_sa_mcmember_data *sa_data = (struct ib_sa_mcmember_data *)req->sa_mad.data; |
| @@ -690,8 +690,8 @@ static void mlx4_ib_mcg_work_handler(struct work_struct *work) | |||
| 690 | u8 cur_join_state; | 690 | u8 cur_join_state; |
| 691 | 691 | ||
| 692 | resp_join_state = ((struct ib_sa_mcmember_data *) | 692 | resp_join_state = ((struct ib_sa_mcmember_data *) |
| 693 | group->response_sa_mad.data)->scope_join_state & 7; | 693 | group->response_sa_mad.data)->scope_join_state & 0xf; |
| 694 | cur_join_state = group->rec.scope_join_state & 7; | 694 | cur_join_state = group->rec.scope_join_state & 0xf; |
| 695 | 695 | ||
| 696 | if (method == IB_MGMT_METHOD_GET_RESP) { | 696 | if (method == IB_MGMT_METHOD_GET_RESP) { |
| 697 | /* successfull join */ | 697 | /* successfull join */ |
| @@ -710,7 +710,7 @@ process_requests: | |||
| 710 | req = list_first_entry(&group->pending_list, struct mcast_req, | 710 | req = list_first_entry(&group->pending_list, struct mcast_req, |
| 711 | group_list); | 711 | group_list); |
| 712 | sa_data = (struct ib_sa_mcmember_data *)req->sa_mad.data; | 712 | sa_data = (struct ib_sa_mcmember_data *)req->sa_mad.data; |
| 713 | req_join_state = sa_data->scope_join_state & 0x7; | 713 | req_join_state = sa_data->scope_join_state & 0xf; |
| 714 | 714 | ||
| 715 | /* For a leave request, we will immediately answer the VF, and | 715 | /* For a leave request, we will immediately answer the VF, and |
| 716 | * update our internal counters. The actual leave will be sent | 716 | * update our internal counters. The actual leave will be sent |
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h index 7c5832ede4bd..686ab48ff644 100644 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h | |||
| @@ -448,7 +448,7 @@ struct mlx4_ib_demux_ctx { | |||
| 448 | struct workqueue_struct *wq; | 448 | struct workqueue_struct *wq; |
| 449 | struct workqueue_struct *ud_wq; | 449 | struct workqueue_struct *ud_wq; |
| 450 | spinlock_t ud_lock; | 450 | spinlock_t ud_lock; |
| 451 | __be64 subnet_prefix; | 451 | atomic64_t subnet_prefix; |
| 452 | __be64 guid_cache[128]; | 452 | __be64 guid_cache[128]; |
| 453 | struct mlx4_ib_dev *dev; | 453 | struct mlx4_ib_dev *dev; |
| 454 | /* the following lock protects both mcg_table and mcg_mgid0_list */ | 454 | /* the following lock protects both mcg_table and mcg_mgid0_list */ |
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index 768085f59566..7fb9629bd12b 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c | |||
| @@ -2493,24 +2493,27 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr, | |||
| 2493 | sqp->ud_header.grh.flow_label = | 2493 | sqp->ud_header.grh.flow_label = |
| 2494 | ah->av.ib.sl_tclass_flowlabel & cpu_to_be32(0xfffff); | 2494 | ah->av.ib.sl_tclass_flowlabel & cpu_to_be32(0xfffff); |
| 2495 | sqp->ud_header.grh.hop_limit = ah->av.ib.hop_limit; | 2495 | sqp->ud_header.grh.hop_limit = ah->av.ib.hop_limit; |
| 2496 | if (is_eth) | 2496 | if (is_eth) { |
| 2497 | memcpy(sqp->ud_header.grh.source_gid.raw, sgid.raw, 16); | 2497 | memcpy(sqp->ud_header.grh.source_gid.raw, sgid.raw, 16); |
| 2498 | else { | 2498 | } else { |
| 2499 | if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) { | 2499 | if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) { |
| 2500 | /* When multi-function is enabled, the ib_core gid | 2500 | /* When multi-function is enabled, the ib_core gid |
| 2501 | * indexes don't necessarily match the hw ones, so | 2501 | * indexes don't necessarily match the hw ones, so |
| 2502 | * we must use our own cache */ | 2502 | * we must use our own cache |
| 2503 | sqp->ud_header.grh.source_gid.global.subnet_prefix = | 2503 | */ |
| 2504 | to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1]. | 2504 | sqp->ud_header.grh.source_gid.global.subnet_prefix = |
| 2505 | subnet_prefix; | 2505 | cpu_to_be64(atomic64_read(&(to_mdev(ib_dev)->sriov. |
| 2506 | sqp->ud_header.grh.source_gid.global.interface_id = | 2506 | demux[sqp->qp.port - 1]. |
| 2507 | to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1]. | 2507 | subnet_prefix))); |
| 2508 | guid_cache[ah->av.ib.gid_index]; | 2508 | sqp->ud_header.grh.source_gid.global.interface_id = |
| 2509 | } else | 2509 | to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1]. |
| 2510 | ib_get_cached_gid(ib_dev, | 2510 | guid_cache[ah->av.ib.gid_index]; |
| 2511 | be32_to_cpu(ah->av.ib.port_pd) >> 24, | 2511 | } else { |
| 2512 | ah->av.ib.gid_index, | 2512 | ib_get_cached_gid(ib_dev, |
| 2513 | &sqp->ud_header.grh.source_gid, NULL); | 2513 | be32_to_cpu(ah->av.ib.port_pd) >> 24, |
| 2514 | ah->av.ib.gid_index, | ||
| 2515 | &sqp->ud_header.grh.source_gid, NULL); | ||
| 2516 | } | ||
| 2514 | } | 2517 | } |
| 2515 | memcpy(sqp->ud_header.grh.destination_gid.raw, | 2518 | memcpy(sqp->ud_header.grh.destination_gid.raw, |
| 2516 | ah->av.ib.dgid, 16); | 2519 | ah->av.ib.dgid, 16); |
diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c index 308a358e5b46..e4fac9292e4a 100644 --- a/drivers/infiniband/hw/mlx5/cq.c +++ b/drivers/infiniband/hw/mlx5/cq.c | |||
| @@ -553,12 +553,6 @@ repoll: | |||
| 553 | * from the table. | 553 | * from the table. |
| 554 | */ | 554 | */ |
| 555 | mqp = __mlx5_qp_lookup(dev->mdev, qpn); | 555 | mqp = __mlx5_qp_lookup(dev->mdev, qpn); |
| 556 | if (unlikely(!mqp)) { | ||
| 557 | mlx5_ib_warn(dev, "CQE@CQ %06x for unknown QPN %6x\n", | ||
| 558 | cq->mcq.cqn, qpn); | ||
| 559 | return -EINVAL; | ||
| 560 | } | ||
| 561 | |||
| 562 | *cur_qp = to_mibqp(mqp); | 556 | *cur_qp = to_mibqp(mqp); |
| 563 | } | 557 | } |
| 564 | 558 | ||
| @@ -619,13 +613,6 @@ repoll: | |||
| 619 | read_lock(&dev->mdev->priv.mkey_table.lock); | 613 | read_lock(&dev->mdev->priv.mkey_table.lock); |
| 620 | mmkey = __mlx5_mr_lookup(dev->mdev, | 614 | mmkey = __mlx5_mr_lookup(dev->mdev, |
| 621 | mlx5_base_mkey(be32_to_cpu(sig_err_cqe->mkey))); | 615 | mlx5_base_mkey(be32_to_cpu(sig_err_cqe->mkey))); |
| 622 | if (unlikely(!mmkey)) { | ||
| 623 | read_unlock(&dev->mdev->priv.mkey_table.lock); | ||
| 624 | mlx5_ib_warn(dev, "CQE@CQ %06x for unknown MR %6x\n", | ||
| 625 | cq->mcq.cqn, be32_to_cpu(sig_err_cqe->mkey)); | ||
| 626 | return -EINVAL; | ||
| 627 | } | ||
| 628 | |||
| 629 | mr = to_mibmr(mmkey); | 616 | mr = to_mibmr(mmkey); |
| 630 | get_sig_err_item(sig_err_cqe, &mr->sig->err_item); | 617 | get_sig_err_item(sig_err_cqe, &mr->sig->err_item); |
| 631 | mr->sig->sig_err_exists = true; | 618 | mr->sig->sig_err_exists = true; |
| @@ -676,7 +663,6 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) | |||
| 676 | unsigned long flags; | 663 | unsigned long flags; |
| 677 | int soft_polled = 0; | 664 | int soft_polled = 0; |
| 678 | int npolled; | 665 | int npolled; |
| 679 | int err = 0; | ||
| 680 | 666 | ||
| 681 | spin_lock_irqsave(&cq->lock, flags); | 667 | spin_lock_irqsave(&cq->lock, flags); |
| 682 | if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { | 668 | if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { |
| @@ -688,8 +674,7 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) | |||
| 688 | soft_polled = poll_soft_wc(cq, num_entries, wc); | 674 | soft_polled = poll_soft_wc(cq, num_entries, wc); |
| 689 | 675 | ||
| 690 | for (npolled = 0; npolled < num_entries - soft_polled; npolled++) { | 676 | for (npolled = 0; npolled < num_entries - soft_polled; npolled++) { |
| 691 | err = mlx5_poll_one(cq, &cur_qp, wc + soft_polled + npolled); | 677 | if (mlx5_poll_one(cq, &cur_qp, wc + soft_polled + npolled)) |
| 692 | if (err) | ||
| 693 | break; | 678 | break; |
| 694 | } | 679 | } |
| 695 | 680 | ||
| @@ -698,10 +683,7 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) | |||
| 698 | out: | 683 | out: |
| 699 | spin_unlock_irqrestore(&cq->lock, flags); | 684 | spin_unlock_irqrestore(&cq->lock, flags); |
| 700 | 685 | ||
| 701 | if (err == 0 || err == -EAGAIN) | 686 | return soft_polled + npolled; |
| 702 | return soft_polled + npolled; | ||
| 703 | else | ||
| 704 | return err; | ||
| 705 | } | 687 | } |
| 706 | 688 | ||
| 707 | int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) | 689 | int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) |
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index a84bb766fc62..e19537cf44ab 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c | |||
| @@ -37,7 +37,6 @@ | |||
| 37 | #include <linux/pci.h> | 37 | #include <linux/pci.h> |
| 38 | #include <linux/dma-mapping.h> | 38 | #include <linux/dma-mapping.h> |
| 39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
| 40 | #include <linux/io-mapping.h> | ||
| 41 | #if defined(CONFIG_X86) | 40 | #if defined(CONFIG_X86) |
| 42 | #include <asm/pat.h> | 41 | #include <asm/pat.h> |
| 43 | #endif | 42 | #endif |
| @@ -289,7 +288,9 @@ __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num, | |||
| 289 | 288 | ||
| 290 | static int mlx5_use_mad_ifc(struct mlx5_ib_dev *dev) | 289 | static int mlx5_use_mad_ifc(struct mlx5_ib_dev *dev) |
| 291 | { | 290 | { |
| 292 | return !MLX5_CAP_GEN(dev->mdev, ib_virt); | 291 | if (MLX5_CAP_GEN(dev->mdev, port_type) == MLX5_CAP_PORT_TYPE_IB) |
| 292 | return !MLX5_CAP_GEN(dev->mdev, ib_virt); | ||
| 293 | return 0; | ||
| 293 | } | 294 | } |
| 294 | 295 | ||
| 295 | enum { | 296 | enum { |
| @@ -1429,6 +1430,13 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v, | |||
| 1429 | dmac_47_16), | 1430 | dmac_47_16), |
| 1430 | ib_spec->eth.val.dst_mac); | 1431 | ib_spec->eth.val.dst_mac); |
| 1431 | 1432 | ||
| 1433 | ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_c, | ||
| 1434 | smac_47_16), | ||
| 1435 | ib_spec->eth.mask.src_mac); | ||
| 1436 | ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_v, | ||
| 1437 | smac_47_16), | ||
| 1438 | ib_spec->eth.val.src_mac); | ||
| 1439 | |||
| 1432 | if (ib_spec->eth.mask.vlan_tag) { | 1440 | if (ib_spec->eth.mask.vlan_tag) { |
| 1433 | MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, | 1441 | MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, |
| 1434 | vlan_tag, 1); | 1442 | vlan_tag, 1); |
| @@ -1850,6 +1858,7 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp, | |||
| 1850 | int domain) | 1858 | int domain) |
| 1851 | { | 1859 | { |
| 1852 | struct mlx5_ib_dev *dev = to_mdev(qp->device); | 1860 | struct mlx5_ib_dev *dev = to_mdev(qp->device); |
| 1861 | struct mlx5_ib_qp *mqp = to_mqp(qp); | ||
| 1853 | struct mlx5_ib_flow_handler *handler = NULL; | 1862 | struct mlx5_ib_flow_handler *handler = NULL; |
| 1854 | struct mlx5_flow_destination *dst = NULL; | 1863 | struct mlx5_flow_destination *dst = NULL; |
| 1855 | struct mlx5_ib_flow_prio *ft_prio; | 1864 | struct mlx5_ib_flow_prio *ft_prio; |
| @@ -1876,7 +1885,10 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp, | |||
| 1876 | } | 1885 | } |
| 1877 | 1886 | ||
| 1878 | dst->type = MLX5_FLOW_DESTINATION_TYPE_TIR; | 1887 | dst->type = MLX5_FLOW_DESTINATION_TYPE_TIR; |
| 1879 | dst->tir_num = to_mqp(qp)->raw_packet_qp.rq.tirn; | 1888 | if (mqp->flags & MLX5_IB_QP_RSS) |
| 1889 | dst->tir_num = mqp->rss_qp.tirn; | ||
| 1890 | else | ||
| 1891 | dst->tir_num = mqp->raw_packet_qp.rq.tirn; | ||
| 1880 | 1892 | ||
| 1881 | if (flow_attr->type == IB_FLOW_ATTR_NORMAL) { | 1893 | if (flow_attr->type == IB_FLOW_ATTR_NORMAL) { |
| 1882 | if (flow_attr->flags & IB_FLOW_ATTR_FLAGS_DONT_TRAP) { | 1894 | if (flow_attr->flags & IB_FLOW_ATTR_FLAGS_DONT_TRAP) { |
diff --git a/drivers/infiniband/hw/mlx5/mem.c b/drivers/infiniband/hw/mlx5/mem.c index 40df2cca0609..996b54e366b0 100644 --- a/drivers/infiniband/hw/mlx5/mem.c +++ b/drivers/infiniband/hw/mlx5/mem.c | |||
| @@ -71,7 +71,7 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift, | |||
| 71 | 71 | ||
| 72 | addr = addr >> page_shift; | 72 | addr = addr >> page_shift; |
| 73 | tmp = (unsigned long)addr; | 73 | tmp = (unsigned long)addr; |
| 74 | m = find_first_bit(&tmp, sizeof(tmp)); | 74 | m = find_first_bit(&tmp, BITS_PER_LONG); |
| 75 | skip = 1 << m; | 75 | skip = 1 << m; |
| 76 | mask = skip - 1; | 76 | mask = skip - 1; |
| 77 | i = 0; | 77 | i = 0; |
| @@ -81,7 +81,7 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift, | |||
| 81 | for (k = 0; k < len; k++) { | 81 | for (k = 0; k < len; k++) { |
| 82 | if (!(i & mask)) { | 82 | if (!(i & mask)) { |
| 83 | tmp = (unsigned long)pfn; | 83 | tmp = (unsigned long)pfn; |
| 84 | m = min_t(unsigned long, m, find_first_bit(&tmp, sizeof(tmp))); | 84 | m = min_t(unsigned long, m, find_first_bit(&tmp, BITS_PER_LONG)); |
| 85 | skip = 1 << m; | 85 | skip = 1 << m; |
| 86 | mask = skip - 1; | 86 | mask = skip - 1; |
| 87 | base = pfn; | 87 | base = pfn; |
| @@ -89,7 +89,7 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift, | |||
| 89 | } else { | 89 | } else { |
| 90 | if (base + p != pfn) { | 90 | if (base + p != pfn) { |
| 91 | tmp = (unsigned long)p; | 91 | tmp = (unsigned long)p; |
| 92 | m = find_first_bit(&tmp, sizeof(tmp)); | 92 | m = find_first_bit(&tmp, BITS_PER_LONG); |
| 93 | skip = 1 << m; | 93 | skip = 1 << m; |
| 94 | mask = skip - 1; | 94 | mask = skip - 1; |
| 95 | base = pfn; | 95 | base = pfn; |
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h index 372385d0f993..95146f4aa3e3 100644 --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h | |||
| @@ -402,6 +402,7 @@ enum mlx5_ib_qp_flags { | |||
| 402 | /* QP uses 1 as its source QP number */ | 402 | /* QP uses 1 as its source QP number */ |
| 403 | MLX5_IB_QP_SQPN_QP1 = 1 << 6, | 403 | MLX5_IB_QP_SQPN_QP1 = 1 << 6, |
| 404 | MLX5_IB_QP_CAP_SCATTER_FCS = 1 << 7, | 404 | MLX5_IB_QP_CAP_SCATTER_FCS = 1 << 7, |
| 405 | MLX5_IB_QP_RSS = 1 << 8, | ||
| 405 | }; | 406 | }; |
| 406 | 407 | ||
| 407 | struct mlx5_umr_wr { | 408 | struct mlx5_umr_wr { |
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 0dd7d93cac95..affc3f6598ca 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c | |||
| @@ -1449,6 +1449,7 @@ create_tir: | |||
| 1449 | kvfree(in); | 1449 | kvfree(in); |
| 1450 | /* qpn is reserved for that QP */ | 1450 | /* qpn is reserved for that QP */ |
| 1451 | qp->trans_qp.base.mqp.qpn = 0; | 1451 | qp->trans_qp.base.mqp.qpn = 0; |
| 1452 | qp->flags |= MLX5_IB_QP_RSS; | ||
| 1452 | return 0; | 1453 | return 0; |
| 1453 | 1454 | ||
| 1454 | err: | 1455 | err: |
| @@ -3658,12 +3659,8 @@ static int begin_wqe(struct mlx5_ib_qp *qp, void **seg, | |||
| 3658 | struct ib_send_wr *wr, unsigned *idx, | 3659 | struct ib_send_wr *wr, unsigned *idx, |
| 3659 | int *size, int nreq) | 3660 | int *size, int nreq) |
| 3660 | { | 3661 | { |
| 3661 | int err = 0; | 3662 | if (unlikely(mlx5_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq))) |
| 3662 | 3663 | return -ENOMEM; | |
| 3663 | if (unlikely(mlx5_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq))) { | ||
| 3664 | err = -ENOMEM; | ||
| 3665 | return err; | ||
| 3666 | } | ||
| 3667 | 3664 | ||
| 3668 | *idx = qp->sq.cur_post & (qp->sq.wqe_cnt - 1); | 3665 | *idx = qp->sq.cur_post & (qp->sq.wqe_cnt - 1); |
| 3669 | *seg = mlx5_get_send_wqe(qp, *idx); | 3666 | *seg = mlx5_get_send_wqe(qp, *idx); |
| @@ -3679,7 +3676,7 @@ static int begin_wqe(struct mlx5_ib_qp *qp, void **seg, | |||
| 3679 | *seg += sizeof(**ctrl); | 3676 | *seg += sizeof(**ctrl); |
| 3680 | *size = sizeof(**ctrl) / 16; | 3677 | *size = sizeof(**ctrl) / 16; |
| 3681 | 3678 | ||
| 3682 | return err; | 3679 | return 0; |
| 3683 | } | 3680 | } |
| 3684 | 3681 | ||
| 3685 | static void finish_wqe(struct mlx5_ib_qp *qp, | 3682 | static void finish_wqe(struct mlx5_ib_qp *qp, |
| @@ -3758,7 +3755,7 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
| 3758 | num_sge = wr->num_sge; | 3755 | num_sge = wr->num_sge; |
| 3759 | if (unlikely(num_sge > qp->sq.max_gs)) { | 3756 | if (unlikely(num_sge > qp->sq.max_gs)) { |
| 3760 | mlx5_ib_warn(dev, "\n"); | 3757 | mlx5_ib_warn(dev, "\n"); |
| 3761 | err = -ENOMEM; | 3758 | err = -EINVAL; |
| 3762 | *bad_wr = wr; | 3759 | *bad_wr = wr; |
| 3763 | goto out; | 3760 | goto out; |
| 3764 | } | 3761 | } |
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index 16740dcb876b..67fc0b6857e1 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c | |||
| @@ -1156,18 +1156,18 @@ static void ocrdma_get_attr(struct ocrdma_dev *dev, | |||
| 1156 | attr->max_srq = | 1156 | attr->max_srq = |
| 1157 | (rsp->max_srq_rpir_qps & OCRDMA_MBX_QUERY_CFG_MAX_SRQ_MASK) >> | 1157 | (rsp->max_srq_rpir_qps & OCRDMA_MBX_QUERY_CFG_MAX_SRQ_MASK) >> |
| 1158 | OCRDMA_MBX_QUERY_CFG_MAX_SRQ_OFFSET; | 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 | OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK) >> | 1160 | OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK) >> |
| 1161 | OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT); | 1161 | OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT); |
| 1162 | attr->max_recv_sge = (rsp->max_write_send_sge & | 1162 | attr->max_recv_sge = (rsp->max_recv_send_sge & |
| 1163 | OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK) >> | 1163 | OCRDMA_MBX_QUERY_CFG_MAX_RECV_SGE_MASK) >> |
| 1164 | OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT; | 1164 | OCRDMA_MBX_QUERY_CFG_MAX_RECV_SGE_SHIFT; |
| 1165 | attr->max_srq_sge = (rsp->max_srq_rqe_sge & | 1165 | attr->max_srq_sge = (rsp->max_srq_rqe_sge & |
| 1166 | OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_MASK) >> | 1166 | OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_MASK) >> |
| 1167 | OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_OFFSET; | 1167 | OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_OFFSET; |
| 1168 | attr->max_rdma_sge = (rsp->max_write_send_sge & | 1168 | attr->max_rdma_sge = (rsp->max_wr_rd_sge & |
| 1169 | OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_MASK) >> | 1169 | OCRDMA_MBX_QUERY_CFG_MAX_RD_SGE_MASK) >> |
| 1170 | OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_SHIFT; | 1170 | OCRDMA_MBX_QUERY_CFG_MAX_RD_SGE_SHIFT; |
| 1171 | attr->max_ord_per_qp = (rsp->max_ird_ord_per_qp & | 1171 | attr->max_ord_per_qp = (rsp->max_ird_ord_per_qp & |
| 1172 | OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_MASK) >> | 1172 | OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_MASK) >> |
| 1173 | OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_SHIFT; | 1173 | OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_SHIFT; |
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_sli.h b/drivers/infiniband/hw/ocrdma/ocrdma_sli.h index 0efc9662c6d8..37df4481bb8f 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_sli.h +++ b/drivers/infiniband/hw/ocrdma/ocrdma_sli.h | |||
| @@ -554,9 +554,9 @@ enum { | |||
| 554 | OCRDMA_MBX_QUERY_CFG_L3_TYPE_MASK = 0x18, | 554 | OCRDMA_MBX_QUERY_CFG_L3_TYPE_MASK = 0x18, |
| 555 | OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT = 0, | 555 | OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT = 0, |
| 556 | OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK = 0xFFFF, | 556 | OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK = 0xFFFF, |
| 557 | OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_SHIFT = 16, | 557 | OCRDMA_MBX_QUERY_CFG_MAX_RECV_SGE_SHIFT = 16, |
| 558 | OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_MASK = 0xFFFF << | 558 | OCRDMA_MBX_QUERY_CFG_MAX_RECV_SGE_MASK = 0xFFFF << |
| 559 | OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_SHIFT, | 559 | OCRDMA_MBX_QUERY_CFG_MAX_RECV_SGE_SHIFT, |
| 560 | 560 | ||
| 561 | OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_SHIFT = 0, | 561 | OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_SHIFT = 0, |
| 562 | OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_MASK = 0xFFFF, | 562 | OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_MASK = 0xFFFF, |
| @@ -612,6 +612,8 @@ enum { | |||
| 612 | OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_OFFSET = 0, | 612 | OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_OFFSET = 0, |
| 613 | OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_MASK = 0xFFFF << | 613 | OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_MASK = 0xFFFF << |
| 614 | OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_OFFSET, | 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 | struct ocrdma_mbx_query_config { | 619 | struct ocrdma_mbx_query_config { |
| @@ -619,7 +621,7 @@ struct ocrdma_mbx_query_config { | |||
| 619 | struct ocrdma_mbx_rsp rsp; | 621 | struct ocrdma_mbx_rsp rsp; |
| 620 | u32 qp_srq_cq_ird_ord; | 622 | u32 qp_srq_cq_ird_ord; |
| 621 | u32 max_pd_ca_ack_delay; | 623 | u32 max_pd_ca_ack_delay; |
| 622 | u32 max_write_send_sge; | 624 | u32 max_recv_send_sge; |
| 623 | u32 max_ird_ord_per_qp; | 625 | u32 max_ird_ord_per_qp; |
| 624 | u32 max_shared_ird_ord; | 626 | u32 max_shared_ird_ord; |
| 625 | u32 max_mr; | 627 | u32 max_mr; |
| @@ -639,6 +641,8 @@ struct ocrdma_mbx_query_config { | |||
| 639 | u32 max_wqes_rqes_per_q; | 641 | u32 max_wqes_rqes_per_q; |
| 640 | u32 max_cq_cqes_per_cq; | 642 | u32 max_cq_cqes_per_cq; |
| 641 | u32 max_srq_rqe_sge; | 643 | u32 max_srq_rqe_sge; |
| 644 | u32 max_wr_rd_sge; | ||
| 645 | u32 ird_pgsz_num_pages; | ||
| 642 | }; | 646 | }; |
| 643 | 647 | ||
| 644 | struct ocrdma_fw_ver_rsp { | 648 | struct ocrdma_fw_ver_rsp { |
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index b1a3d91fe8b9..0aa854737e74 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | |||
| @@ -125,8 +125,8 @@ int ocrdma_query_device(struct ib_device *ibdev, struct ib_device_attr *attr, | |||
| 125 | IB_DEVICE_SYS_IMAGE_GUID | | 125 | IB_DEVICE_SYS_IMAGE_GUID | |
| 126 | IB_DEVICE_LOCAL_DMA_LKEY | | 126 | IB_DEVICE_LOCAL_DMA_LKEY | |
| 127 | IB_DEVICE_MEM_MGT_EXTENSIONS; | 127 | IB_DEVICE_MEM_MGT_EXTENSIONS; |
| 128 | attr->max_sge = dev->attr.max_send_sge; | 128 | attr->max_sge = min(dev->attr.max_send_sge, dev->attr.max_recv_sge); |
| 129 | attr->max_sge_rd = attr->max_sge; | 129 | attr->max_sge_rd = dev->attr.max_rdma_sge; |
| 130 | attr->max_cq = dev->attr.max_cq; | 130 | attr->max_cq = dev->attr.max_cq; |
| 131 | attr->max_cqe = dev->attr.max_cqe; | 131 | attr->max_cqe = dev->attr.max_cqe; |
| 132 | attr->max_mr = dev->attr.max_mr; | 132 | attr->max_mr = dev->attr.max_mr; |
diff --git a/drivers/infiniband/hw/qib/qib_debugfs.c b/drivers/infiniband/hw/qib/qib_debugfs.c index 5e75b43c596b..5bad8e3b40bb 100644 --- a/drivers/infiniband/hw/qib/qib_debugfs.c +++ b/drivers/infiniband/hw/qib/qib_debugfs.c | |||
| @@ -189,27 +189,32 @@ static int _ctx_stats_seq_show(struct seq_file *s, void *v) | |||
| 189 | DEBUGFS_FILE(ctx_stats) | 189 | DEBUGFS_FILE(ctx_stats) |
| 190 | 190 | ||
| 191 | static void *_qp_stats_seq_start(struct seq_file *s, loff_t *pos) | 191 | static void *_qp_stats_seq_start(struct seq_file *s, loff_t *pos) |
| 192 | __acquires(RCU) | ||
| 192 | { | 193 | { |
| 193 | struct qib_qp_iter *iter; | 194 | struct qib_qp_iter *iter; |
| 194 | loff_t n = *pos; | 195 | loff_t n = *pos; |
| 195 | 196 | ||
| 196 | rcu_read_lock(); | ||
| 197 | iter = qib_qp_iter_init(s->private); | 197 | iter = qib_qp_iter_init(s->private); |
| 198 | |||
| 199 | /* stop calls rcu_read_unlock */ | ||
| 200 | rcu_read_lock(); | ||
| 201 | |||
| 198 | if (!iter) | 202 | if (!iter) |
| 199 | return NULL; | 203 | return NULL; |
| 200 | 204 | ||
| 201 | while (n--) { | 205 | do { |
| 202 | if (qib_qp_iter_next(iter)) { | 206 | if (qib_qp_iter_next(iter)) { |
| 203 | kfree(iter); | 207 | kfree(iter); |
| 204 | return NULL; | 208 | return NULL; |
| 205 | } | 209 | } |
| 206 | } | 210 | } while (n--); |
| 207 | 211 | ||
| 208 | return iter; | 212 | return iter; |
| 209 | } | 213 | } |
| 210 | 214 | ||
| 211 | static void *_qp_stats_seq_next(struct seq_file *s, void *iter_ptr, | 215 | static void *_qp_stats_seq_next(struct seq_file *s, void *iter_ptr, |
| 212 | loff_t *pos) | 216 | loff_t *pos) |
| 217 | __must_hold(RCU) | ||
| 213 | { | 218 | { |
| 214 | struct qib_qp_iter *iter = iter_ptr; | 219 | struct qib_qp_iter *iter = iter_ptr; |
| 215 | 220 | ||
| @@ -224,6 +229,7 @@ static void *_qp_stats_seq_next(struct seq_file *s, void *iter_ptr, | |||
| 224 | } | 229 | } |
| 225 | 230 | ||
| 226 | static void _qp_stats_seq_stop(struct seq_file *s, void *iter_ptr) | 231 | static void _qp_stats_seq_stop(struct seq_file *s, void *iter_ptr) |
| 232 | __releases(RCU) | ||
| 227 | { | 233 | { |
| 228 | rcu_read_unlock(); | 234 | rcu_read_unlock(); |
| 229 | } | 235 | } |
diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c index fcdf37913a26..c3edc033f7c4 100644 --- a/drivers/infiniband/hw/qib/qib_fs.c +++ b/drivers/infiniband/hw/qib/qib_fs.c | |||
| @@ -328,26 +328,12 @@ static ssize_t flash_write(struct file *file, const char __user *buf, | |||
| 328 | 328 | ||
| 329 | pos = *ppos; | 329 | pos = *ppos; |
| 330 | 330 | ||
| 331 | if (pos != 0) { | 331 | if (pos != 0 || count != sizeof(struct qib_flash)) |
| 332 | ret = -EINVAL; | 332 | return -EINVAL; |
| 333 | goto bail; | ||
| 334 | } | ||
| 335 | |||
| 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 | 333 | ||
| 347 | if (copy_from_user(tmp, buf, count)) { | 334 | tmp = memdup_user(buf, count); |
| 348 | ret = -EFAULT; | 335 | if (IS_ERR(tmp)) |
| 349 | goto bail_tmp; | 336 | return PTR_ERR(tmp); |
| 350 | } | ||
| 351 | 337 | ||
| 352 | dd = private2dd(file); | 338 | dd = private2dd(file); |
| 353 | if (qib_eeprom_write(dd, pos, tmp, count)) { | 339 | if (qib_eeprom_write(dd, pos, tmp, count)) { |
| @@ -361,8 +347,6 @@ static ssize_t flash_write(struct file *file, const char __user *buf, | |||
| 361 | 347 | ||
| 362 | bail_tmp: | 348 | bail_tmp: |
| 363 | kfree(tmp); | 349 | kfree(tmp); |
| 364 | |||
| 365 | bail: | ||
| 366 | return ret; | 350 | return ret; |
| 367 | } | 351 | } |
| 368 | 352 | ||
diff --git a/drivers/infiniband/hw/qib/qib_qp.c b/drivers/infiniband/hw/qib/qib_qp.c index 9cc0aae1d781..f9b8cd2354d1 100644 --- a/drivers/infiniband/hw/qib/qib_qp.c +++ b/drivers/infiniband/hw/qib/qib_qp.c | |||
| @@ -573,10 +573,6 @@ struct qib_qp_iter *qib_qp_iter_init(struct qib_ibdev *dev) | |||
| 573 | return NULL; | 573 | return NULL; |
| 574 | 574 | ||
| 575 | iter->dev = dev; | 575 | iter->dev = dev; |
| 576 | if (qib_qp_iter_next(iter)) { | ||
| 577 | kfree(iter); | ||
| 578 | return NULL; | ||
| 579 | } | ||
| 580 | 576 | ||
| 581 | return iter; | 577 | return iter; |
| 582 | } | 578 | } |
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_main.c b/drivers/infiniband/hw/usnic/usnic_ib_main.c index c229b9f4a52d..0a89a955550b 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_main.c +++ b/drivers/infiniband/hw/usnic/usnic_ib_main.c | |||
| @@ -664,7 +664,8 @@ static int __init usnic_ib_init(void) | |||
| 664 | return err; | 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 | usnic_err("Unable to register with PCI\n"); | 669 | usnic_err("Unable to register with PCI\n"); |
| 669 | goto out_umem_fini; | 670 | goto out_umem_fini; |
| 670 | } | 671 | } |
diff --git a/drivers/infiniband/sw/rdmavt/mr.c b/drivers/infiniband/sw/rdmavt/mr.c index 80c4b6b401b8..46b64970058e 100644 --- a/drivers/infiniband/sw/rdmavt/mr.c +++ b/drivers/infiniband/sw/rdmavt/mr.c | |||
| @@ -294,7 +294,7 @@ static void __rvt_free_mr(struct rvt_mr *mr) | |||
| 294 | { | 294 | { |
| 295 | rvt_deinit_mregion(&mr->mr); | 295 | rvt_deinit_mregion(&mr->mr); |
| 296 | rvt_free_lkey(&mr->mr); | 296 | rvt_free_lkey(&mr->mr); |
| 297 | vfree(mr); | 297 | kfree(mr); |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | /** | 300 | /** |
diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c index bdb540f25a88..870b4f212fbc 100644 --- a/drivers/infiniband/sw/rdmavt/qp.c +++ b/drivers/infiniband/sw/rdmavt/qp.c | |||
| @@ -873,7 +873,8 @@ bail_qpn: | |||
| 873 | free_qpn(&rdi->qp_dev->qpn_table, qp->ibqp.qp_num); | 873 | free_qpn(&rdi->qp_dev->qpn_table, qp->ibqp.qp_num); |
| 874 | 874 | ||
| 875 | bail_rq_wq: | 875 | bail_rq_wq: |
| 876 | vfree(qp->r_rq.wq); | 876 | if (!qp->ip) |
| 877 | vfree(qp->r_rq.wq); | ||
| 877 | 878 | ||
| 878 | bail_driver_priv: | 879 | bail_driver_priv: |
| 879 | rdi->driver_f.qp_priv_free(rdi, qp); | 880 | rdi->driver_f.qp_priv_free(rdi, qp); |
diff --git a/drivers/infiniband/sw/rxe/rxe.c b/drivers/infiniband/sw/rxe/rxe.c index 55f0e8f0ca79..ddd59270ff6d 100644 --- a/drivers/infiniband/sw/rxe/rxe.c +++ b/drivers/infiniband/sw/rxe/rxe.c | |||
| @@ -362,15 +362,34 @@ static int __init rxe_module_init(void) | |||
| 362 | return err; | 362 | return err; |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | err = rxe_net_init(); | 365 | err = rxe_net_ipv4_init(); |
| 366 | if (err) { | 366 | if (err) { |
| 367 | pr_err("rxe: unable to init\n"); | 367 | pr_err("rxe: unable to init ipv4 tunnel\n"); |
| 368 | rxe_cache_exit(); | 368 | rxe_cache_exit(); |
| 369 | return err; | 369 | goto exit; |
| 370 | } | ||
| 371 | |||
| 372 | err = rxe_net_ipv6_init(); | ||
| 373 | if (err) { | ||
| 374 | pr_err("rxe: unable to init ipv6 tunnel\n"); | ||
| 375 | rxe_cache_exit(); | ||
| 376 | goto exit; | ||
| 370 | } | 377 | } |
| 378 | |||
| 379 | err = register_netdevice_notifier(&rxe_net_notifier); | ||
| 380 | if (err) { | ||
| 381 | pr_err("rxe: Failed to rigister netdev notifier\n"); | ||
| 382 | goto exit; | ||
| 383 | } | ||
| 384 | |||
| 371 | pr_info("rxe: loaded\n"); | 385 | pr_info("rxe: loaded\n"); |
| 372 | 386 | ||
| 373 | return 0; | 387 | return 0; |
| 388 | |||
| 389 | exit: | ||
| 390 | rxe_release_udp_tunnel(recv_sockets.sk4); | ||
| 391 | rxe_release_udp_tunnel(recv_sockets.sk6); | ||
| 392 | return err; | ||
| 374 | } | 393 | } |
| 375 | 394 | ||
| 376 | static void __exit rxe_module_exit(void) | 395 | static void __exit rxe_module_exit(void) |
diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index 36f67de44095..1c59ef2c67aa 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c | |||
| @@ -689,7 +689,14 @@ int rxe_completer(void *arg) | |||
| 689 | qp->req.need_retry = 1; | 689 | qp->req.need_retry = 1; |
| 690 | rxe_run_task(&qp->req.task, 1); | 690 | rxe_run_task(&qp->req.task, 1); |
| 691 | } | 691 | } |
| 692 | |||
| 693 | if (pkt) { | ||
| 694 | rxe_drop_ref(pkt->qp); | ||
| 695 | kfree_skb(skb); | ||
| 696 | } | ||
| 697 | |||
| 692 | goto exit; | 698 | goto exit; |
| 699 | |||
| 693 | } else { | 700 | } else { |
| 694 | wqe->status = IB_WC_RETRY_EXC_ERR; | 701 | wqe->status = IB_WC_RETRY_EXC_ERR; |
| 695 | state = COMPST_ERROR; | 702 | state = COMPST_ERROR; |
| @@ -716,6 +723,12 @@ int rxe_completer(void *arg) | |||
| 716 | case COMPST_ERROR: | 723 | case COMPST_ERROR: |
| 717 | do_complete(qp, wqe); | 724 | do_complete(qp, wqe); |
| 718 | rxe_qp_error(qp); | 725 | rxe_qp_error(qp); |
| 726 | |||
| 727 | if (pkt) { | ||
| 728 | rxe_drop_ref(pkt->qp); | ||
| 729 | kfree_skb(skb); | ||
| 730 | } | ||
| 731 | |||
| 719 | goto exit; | 732 | goto exit; |
| 720 | } | 733 | } |
| 721 | } | 734 | } |
diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index 0b8d2ea8b41d..eedf2f1cafdf 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c | |||
| @@ -275,9 +275,10 @@ static struct socket *rxe_setup_udp_tunnel(struct net *net, __be16 port, | |||
| 275 | return sock; | 275 | return sock; |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | static void rxe_release_udp_tunnel(struct socket *sk) | 278 | void rxe_release_udp_tunnel(struct socket *sk) |
| 279 | { | 279 | { |
| 280 | udp_tunnel_sock_release(sk); | 280 | if (sk) |
| 281 | udp_tunnel_sock_release(sk); | ||
| 281 | } | 282 | } |
| 282 | 283 | ||
| 283 | static void prepare_udp_hdr(struct sk_buff *skb, __be16 src_port, | 284 | static void prepare_udp_hdr(struct sk_buff *skb, __be16 src_port, |
| @@ -658,51 +659,45 @@ out: | |||
| 658 | return NOTIFY_OK; | 659 | return NOTIFY_OK; |
| 659 | } | 660 | } |
| 660 | 661 | ||
| 661 | static struct notifier_block rxe_net_notifier = { | 662 | struct notifier_block rxe_net_notifier = { |
| 662 | .notifier_call = rxe_notify, | 663 | .notifier_call = rxe_notify, |
| 663 | }; | 664 | }; |
| 664 | 665 | ||
| 665 | int rxe_net_init(void) | 666 | int rxe_net_ipv4_init(void) |
| 666 | { | 667 | { |
| 667 | int err; | ||
| 668 | |||
| 669 | spin_lock_init(&dev_list_lock); | 668 | spin_lock_init(&dev_list_lock); |
| 670 | 669 | ||
| 671 | recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net, | ||
| 672 | htons(ROCE_V2_UDP_DPORT), true); | ||
| 673 | if (IS_ERR(recv_sockets.sk6)) { | ||
| 674 | recv_sockets.sk6 = NULL; | ||
| 675 | pr_err("rxe: Failed to create IPv6 UDP tunnel\n"); | ||
| 676 | return -1; | ||
| 677 | } | ||
| 678 | |||
| 679 | recv_sockets.sk4 = rxe_setup_udp_tunnel(&init_net, | 670 | recv_sockets.sk4 = rxe_setup_udp_tunnel(&init_net, |
| 680 | htons(ROCE_V2_UDP_DPORT), false); | 671 | htons(ROCE_V2_UDP_DPORT), false); |
| 681 | if (IS_ERR(recv_sockets.sk4)) { | 672 | if (IS_ERR(recv_sockets.sk4)) { |
| 682 | rxe_release_udp_tunnel(recv_sockets.sk6); | ||
| 683 | recv_sockets.sk4 = NULL; | 673 | recv_sockets.sk4 = NULL; |
| 684 | recv_sockets.sk6 = NULL; | ||
| 685 | pr_err("rxe: Failed to create IPv4 UDP tunnel\n"); | 674 | pr_err("rxe: Failed to create IPv4 UDP tunnel\n"); |
| 686 | return -1; | 675 | return -1; |
| 687 | } | 676 | } |
| 688 | 677 | ||
| 689 | err = register_netdevice_notifier(&rxe_net_notifier); | 678 | return 0; |
| 690 | if (err) { | ||
| 691 | rxe_release_udp_tunnel(recv_sockets.sk6); | ||
| 692 | rxe_release_udp_tunnel(recv_sockets.sk4); | ||
| 693 | pr_err("rxe: Failed to rigister netdev notifier\n"); | ||
| 694 | } | ||
| 695 | |||
| 696 | return err; | ||
| 697 | } | 679 | } |
| 698 | 680 | ||
| 699 | void rxe_net_exit(void) | 681 | int rxe_net_ipv6_init(void) |
| 700 | { | 682 | { |
| 701 | if (recv_sockets.sk6) | 683 | #if IS_ENABLED(CONFIG_IPV6) |
| 702 | rxe_release_udp_tunnel(recv_sockets.sk6); | ||
| 703 | 684 | ||
| 704 | if (recv_sockets.sk4) | 685 | spin_lock_init(&dev_list_lock); |
| 705 | rxe_release_udp_tunnel(recv_sockets.sk4); | ||
| 706 | 686 | ||
| 687 | recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net, | ||
| 688 | htons(ROCE_V2_UDP_DPORT), true); | ||
| 689 | if (IS_ERR(recv_sockets.sk6)) { | ||
| 690 | recv_sockets.sk6 = NULL; | ||
| 691 | pr_err("rxe: Failed to create IPv6 UDP tunnel\n"); | ||
| 692 | return -1; | ||
| 693 | } | ||
| 694 | #endif | ||
| 695 | return 0; | ||
| 696 | } | ||
| 697 | |||
| 698 | void rxe_net_exit(void) | ||
| 699 | { | ||
| 700 | rxe_release_udp_tunnel(recv_sockets.sk6); | ||
| 701 | rxe_release_udp_tunnel(recv_sockets.sk4); | ||
| 707 | unregister_netdevice_notifier(&rxe_net_notifier); | 702 | unregister_netdevice_notifier(&rxe_net_notifier); |
| 708 | } | 703 | } |
diff --git a/drivers/infiniband/sw/rxe/rxe_net.h b/drivers/infiniband/sw/rxe/rxe_net.h index 7b06f76d16cc..0daf7f09e5b5 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.h +++ b/drivers/infiniband/sw/rxe/rxe_net.h | |||
| @@ -44,10 +44,13 @@ struct rxe_recv_sockets { | |||
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | extern struct rxe_recv_sockets recv_sockets; | 46 | extern struct rxe_recv_sockets recv_sockets; |
| 47 | extern struct notifier_block rxe_net_notifier; | ||
| 48 | void rxe_release_udp_tunnel(struct socket *sk); | ||
| 47 | 49 | ||
| 48 | struct rxe_dev *rxe_net_add(struct net_device *ndev); | 50 | struct rxe_dev *rxe_net_add(struct net_device *ndev); |
| 49 | 51 | ||
| 50 | int rxe_net_init(void); | 52 | int rxe_net_ipv4_init(void); |
| 53 | int rxe_net_ipv6_init(void); | ||
| 51 | void rxe_net_exit(void); | 54 | void rxe_net_exit(void); |
| 52 | 55 | ||
| 53 | #endif /* RXE_NET_H */ | 56 | #endif /* RXE_NET_H */ |
diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c index 3d464c23e08b..144d2f129fcd 100644 --- a/drivers/infiniband/sw/rxe/rxe_recv.c +++ b/drivers/infiniband/sw/rxe/rxe_recv.c | |||
| @@ -312,7 +312,7 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) | |||
| 312 | * make a copy of the skb to post to the next qp | 312 | * make a copy of the skb to post to the next qp |
| 313 | */ | 313 | */ |
| 314 | skb_copy = (mce->qp_list.next != &mcg->qp_list) ? | 314 | skb_copy = (mce->qp_list.next != &mcg->qp_list) ? |
| 315 | skb_clone(skb, GFP_KERNEL) : NULL; | 315 | skb_clone(skb, GFP_ATOMIC) : NULL; |
| 316 | 316 | ||
| 317 | pkt->qp = qp; | 317 | pkt->qp = qp; |
| 318 | rxe_add_ref(qp); | 318 | rxe_add_ref(qp); |
diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index 33b2d9d77021..13a848a518e8 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c | |||
| @@ -511,24 +511,21 @@ static int fill_packet(struct rxe_qp *qp, struct rxe_send_wqe *wqe, | |||
| 511 | } | 511 | } |
| 512 | 512 | ||
| 513 | static void update_wqe_state(struct rxe_qp *qp, | 513 | static void update_wqe_state(struct rxe_qp *qp, |
| 514 | struct rxe_send_wqe *wqe, | 514 | struct rxe_send_wqe *wqe, |
| 515 | struct rxe_pkt_info *pkt, | 515 | struct rxe_pkt_info *pkt) |
| 516 | enum wqe_state *prev_state) | ||
| 517 | { | 516 | { |
| 518 | enum wqe_state prev_state_ = wqe->state; | ||
| 519 | |||
| 520 | if (pkt->mask & RXE_END_MASK) { | 517 | if (pkt->mask & RXE_END_MASK) { |
| 521 | if (qp_type(qp) == IB_QPT_RC) | 518 | if (qp_type(qp) == IB_QPT_RC) |
| 522 | wqe->state = wqe_state_pending; | 519 | wqe->state = wqe_state_pending; |
| 523 | } else { | 520 | } else { |
| 524 | wqe->state = wqe_state_processing; | 521 | wqe->state = wqe_state_processing; |
| 525 | } | 522 | } |
| 526 | |||
| 527 | *prev_state = prev_state_; | ||
| 528 | } | 523 | } |
| 529 | 524 | ||
| 530 | static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, | 525 | static void update_wqe_psn(struct rxe_qp *qp, |
| 531 | struct rxe_pkt_info *pkt, int payload) | 526 | struct rxe_send_wqe *wqe, |
| 527 | struct rxe_pkt_info *pkt, | ||
| 528 | int payload) | ||
| 532 | { | 529 | { |
| 533 | /* number of packets left to send including current one */ | 530 | /* number of packets left to send including current one */ |
| 534 | int num_pkt = (wqe->dma.resid + payload + qp->mtu - 1) / qp->mtu; | 531 | int num_pkt = (wqe->dma.resid + payload + qp->mtu - 1) / qp->mtu; |
| @@ -546,9 +543,34 @@ static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, | |||
| 546 | qp->req.psn = (wqe->first_psn + num_pkt) & BTH_PSN_MASK; | 543 | qp->req.psn = (wqe->first_psn + num_pkt) & BTH_PSN_MASK; |
| 547 | else | 544 | else |
| 548 | qp->req.psn = (qp->req.psn + 1) & BTH_PSN_MASK; | 545 | qp->req.psn = (qp->req.psn + 1) & BTH_PSN_MASK; |
| 546 | } | ||
| 549 | 547 | ||
| 550 | qp->req.opcode = pkt->opcode; | 548 | static void save_state(struct rxe_send_wqe *wqe, |
| 549 | struct rxe_qp *qp, | ||
| 550 | struct rxe_send_wqe *rollback_wqe, | ||
| 551 | struct rxe_qp *rollback_qp) | ||
| 552 | { | ||
| 553 | rollback_wqe->state = wqe->state; | ||
| 554 | rollback_wqe->first_psn = wqe->first_psn; | ||
| 555 | rollback_wqe->last_psn = wqe->last_psn; | ||
| 556 | rollback_qp->req.psn = qp->req.psn; | ||
| 557 | } | ||
| 551 | 558 | ||
| 559 | static void rollback_state(struct rxe_send_wqe *wqe, | ||
| 560 | struct rxe_qp *qp, | ||
| 561 | struct rxe_send_wqe *rollback_wqe, | ||
| 562 | struct rxe_qp *rollback_qp) | ||
| 563 | { | ||
| 564 | wqe->state = rollback_wqe->state; | ||
| 565 | wqe->first_psn = rollback_wqe->first_psn; | ||
| 566 | wqe->last_psn = rollback_wqe->last_psn; | ||
| 567 | qp->req.psn = rollback_qp->req.psn; | ||
| 568 | } | ||
| 569 | |||
| 570 | static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, | ||
| 571 | struct rxe_pkt_info *pkt, int payload) | ||
| 572 | { | ||
| 573 | qp->req.opcode = pkt->opcode; | ||
| 552 | 574 | ||
| 553 | if (pkt->mask & RXE_END_MASK) | 575 | if (pkt->mask & RXE_END_MASK) |
| 554 | qp->req.wqe_index = next_index(qp->sq.queue, qp->req.wqe_index); | 576 | qp->req.wqe_index = next_index(qp->sq.queue, qp->req.wqe_index); |
| @@ -571,7 +593,8 @@ int rxe_requester(void *arg) | |||
| 571 | int mtu; | 593 | int mtu; |
| 572 | int opcode; | 594 | int opcode; |
| 573 | int ret; | 595 | int ret; |
| 574 | enum wqe_state prev_state; | 596 | struct rxe_qp rollback_qp; |
| 597 | struct rxe_send_wqe rollback_wqe; | ||
| 575 | 598 | ||
| 576 | next_wqe: | 599 | next_wqe: |
| 577 | if (unlikely(!qp->valid || qp->req.state == QP_STATE_ERROR)) | 600 | if (unlikely(!qp->valid || qp->req.state == QP_STATE_ERROR)) |
| @@ -688,13 +711,21 @@ next_wqe: | |||
| 688 | goto err; | 711 | goto err; |
| 689 | } | 712 | } |
| 690 | 713 | ||
| 691 | update_wqe_state(qp, wqe, &pkt, &prev_state); | 714 | /* |
| 715 | * To prevent a race on wqe access between requester and completer, | ||
| 716 | * wqe members state and psn need to be set before calling | ||
| 717 | * rxe_xmit_packet(). | ||
| 718 | * Otherwise, completer might initiate an unjustified retry flow. | ||
| 719 | */ | ||
| 720 | save_state(wqe, qp, &rollback_wqe, &rollback_qp); | ||
| 721 | update_wqe_state(qp, wqe, &pkt); | ||
| 722 | update_wqe_psn(qp, wqe, &pkt, payload); | ||
| 692 | ret = rxe_xmit_packet(to_rdev(qp->ibqp.device), qp, &pkt, skb); | 723 | ret = rxe_xmit_packet(to_rdev(qp->ibqp.device), qp, &pkt, skb); |
| 693 | if (ret) { | 724 | if (ret) { |
| 694 | qp->need_req_skb = 1; | 725 | qp->need_req_skb = 1; |
| 695 | kfree_skb(skb); | 726 | kfree_skb(skb); |
| 696 | 727 | ||
| 697 | wqe->state = prev_state; | 728 | rollback_state(wqe, qp, &rollback_wqe, &rollback_qp); |
| 698 | 729 | ||
| 699 | if (ret == -EAGAIN) { | 730 | if (ret == -EAGAIN) { |
| 700 | rxe_run_task(&qp->req.task, 1); | 731 | rxe_run_task(&qp->req.task, 1); |
diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c index ebb03b46e2ad..3e0f0f2baace 100644 --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c | |||
| @@ -972,11 +972,13 @@ static int send_atomic_ack(struct rxe_qp *qp, struct rxe_pkt_info *pkt, | |||
| 972 | free_rd_atomic_resource(qp, res); | 972 | free_rd_atomic_resource(qp, res); |
| 973 | rxe_advance_resp_resource(qp); | 973 | rxe_advance_resp_resource(qp); |
| 974 | 974 | ||
| 975 | memcpy(SKB_TO_PKT(skb), &ack_pkt, sizeof(skb->cb)); | ||
| 976 | |||
| 975 | res->type = RXE_ATOMIC_MASK; | 977 | res->type = RXE_ATOMIC_MASK; |
| 976 | res->atomic.skb = skb; | 978 | res->atomic.skb = skb; |
| 977 | res->first_psn = qp->resp.psn; | 979 | res->first_psn = ack_pkt.psn; |
| 978 | res->last_psn = qp->resp.psn; | 980 | res->last_psn = ack_pkt.psn; |
| 979 | res->cur_psn = qp->resp.psn; | 981 | res->cur_psn = ack_pkt.psn; |
| 980 | 982 | ||
| 981 | rc = rxe_xmit_packet(rxe, qp, &ack_pkt, skb_copy); | 983 | rc = rxe_xmit_packet(rxe, qp, &ack_pkt, skb_copy); |
| 982 | if (rc) { | 984 | if (rc) { |
| @@ -1116,8 +1118,7 @@ static enum resp_states duplicate_request(struct rxe_qp *qp, | |||
| 1116 | rc = RESPST_CLEANUP; | 1118 | rc = RESPST_CLEANUP; |
| 1117 | goto out; | 1119 | goto out; |
| 1118 | } | 1120 | } |
| 1119 | bth_set_psn(SKB_TO_PKT(skb_copy), | 1121 | |
| 1120 | qp->resp.psn - 1); | ||
| 1121 | /* Resend the result. */ | 1122 | /* Resend the result. */ |
| 1122 | rc = rxe_xmit_packet(to_rdev(qp->ibqp.device), qp, | 1123 | rc = rxe_xmit_packet(to_rdev(qp->ibqp.device), qp, |
| 1123 | pkt, skb_copy); | 1124 | pkt, skb_copy); |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h index 4f7d9b48df64..9dbfcc0ab577 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib.h +++ b/drivers/infiniband/ulp/ipoib/ipoib.h | |||
| @@ -478,6 +478,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb, | |||
| 478 | struct ipoib_ah *address, u32 qpn); | 478 | struct ipoib_ah *address, u32 qpn); |
| 479 | void ipoib_reap_ah(struct work_struct *work); | 479 | void ipoib_reap_ah(struct work_struct *work); |
| 480 | 480 | ||
| 481 | struct ipoib_path *__path_find(struct net_device *dev, void *gid); | ||
| 481 | void ipoib_mark_paths_invalid(struct net_device *dev); | 482 | void ipoib_mark_paths_invalid(struct net_device *dev); |
| 482 | void ipoib_flush_paths(struct net_device *dev); | 483 | void ipoib_flush_paths(struct net_device *dev); |
| 483 | int ipoib_check_sm_sendonly_fullmember_support(struct ipoib_dev_priv *priv); | 484 | int ipoib_check_sm_sendonly_fullmember_support(struct ipoib_dev_priv *priv); |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c index 951d9abcca8b..4ad297d3de89 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c | |||
| @@ -1318,6 +1318,8 @@ void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx) | |||
| 1318 | } | 1318 | } |
| 1319 | } | 1319 | } |
| 1320 | 1320 | ||
| 1321 | #define QPN_AND_OPTIONS_OFFSET 4 | ||
| 1322 | |||
| 1321 | static void ipoib_cm_tx_start(struct work_struct *work) | 1323 | static void ipoib_cm_tx_start(struct work_struct *work) |
| 1322 | { | 1324 | { |
| 1323 | struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv, | 1325 | struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv, |
| @@ -1326,6 +1328,7 @@ static void ipoib_cm_tx_start(struct work_struct *work) | |||
| 1326 | struct ipoib_neigh *neigh; | 1328 | struct ipoib_neigh *neigh; |
| 1327 | struct ipoib_cm_tx *p; | 1329 | struct ipoib_cm_tx *p; |
| 1328 | unsigned long flags; | 1330 | unsigned long flags; |
| 1331 | struct ipoib_path *path; | ||
| 1329 | int ret; | 1332 | int ret; |
| 1330 | 1333 | ||
| 1331 | struct ib_sa_path_rec pathrec; | 1334 | struct ib_sa_path_rec pathrec; |
| @@ -1338,7 +1341,19 @@ static void ipoib_cm_tx_start(struct work_struct *work) | |||
| 1338 | p = list_entry(priv->cm.start_list.next, typeof(*p), list); | 1341 | p = list_entry(priv->cm.start_list.next, typeof(*p), list); |
| 1339 | list_del_init(&p->list); | 1342 | list_del_init(&p->list); |
| 1340 | neigh = p->neigh; | 1343 | neigh = p->neigh; |
| 1344 | |||
| 1341 | qpn = IPOIB_QPN(neigh->daddr); | 1345 | qpn = IPOIB_QPN(neigh->daddr); |
| 1346 | /* | ||
| 1347 | * As long as the search is with these 2 locks, | ||
| 1348 | * path existence indicates its validity. | ||
| 1349 | */ | ||
| 1350 | path = __path_find(dev, neigh->daddr + QPN_AND_OPTIONS_OFFSET); | ||
| 1351 | if (!path) { | ||
| 1352 | pr_info("%s ignore not valid path %pI6\n", | ||
| 1353 | __func__, | ||
| 1354 | neigh->daddr + QPN_AND_OPTIONS_OFFSET); | ||
| 1355 | goto free_neigh; | ||
| 1356 | } | ||
| 1342 | memcpy(&pathrec, &p->path->pathrec, sizeof pathrec); | 1357 | memcpy(&pathrec, &p->path->pathrec, sizeof pathrec); |
| 1343 | 1358 | ||
| 1344 | spin_unlock_irqrestore(&priv->lock, flags); | 1359 | spin_unlock_irqrestore(&priv->lock, flags); |
| @@ -1350,6 +1365,7 @@ static void ipoib_cm_tx_start(struct work_struct *work) | |||
| 1350 | spin_lock_irqsave(&priv->lock, flags); | 1365 | spin_lock_irqsave(&priv->lock, flags); |
| 1351 | 1366 | ||
| 1352 | if (ret) { | 1367 | if (ret) { |
| 1368 | free_neigh: | ||
| 1353 | neigh = p->neigh; | 1369 | neigh = p->neigh; |
| 1354 | if (neigh) { | 1370 | if (neigh) { |
| 1355 | neigh->cm = NULL; | 1371 | neigh->cm = NULL; |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index dc6d241b9406..be11d5d5b8c1 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c | |||
| @@ -1161,8 +1161,17 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, | |||
| 1161 | } | 1161 | } |
| 1162 | 1162 | ||
| 1163 | if (level == IPOIB_FLUSH_LIGHT) { | 1163 | if (level == IPOIB_FLUSH_LIGHT) { |
| 1164 | int oper_up; | ||
| 1164 | ipoib_mark_paths_invalid(dev); | 1165 | ipoib_mark_paths_invalid(dev); |
| 1166 | /* Set IPoIB operation as down to prevent races between: | ||
| 1167 | * the flush flow which leaves MCG and on the fly joins | ||
| 1168 | * which can happen during that time. mcast restart task | ||
| 1169 | * should deal with join requests we missed. | ||
| 1170 | */ | ||
| 1171 | oper_up = test_and_clear_bit(IPOIB_FLAG_OPER_UP, &priv->flags); | ||
| 1165 | ipoib_mcast_dev_flush(dev); | 1172 | ipoib_mcast_dev_flush(dev); |
| 1173 | if (oper_up) | ||
| 1174 | set_bit(IPOIB_FLAG_OPER_UP, &priv->flags); | ||
| 1166 | ipoib_flush_ah(dev); | 1175 | ipoib_flush_ah(dev); |
| 1167 | } | 1176 | } |
| 1168 | 1177 | ||
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 74bcaa064226..cc1c1b062ea5 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
| @@ -485,7 +485,7 @@ int ipoib_set_mode(struct net_device *dev, const char *buf) | |||
| 485 | return -EINVAL; | 485 | return -EINVAL; |
| 486 | } | 486 | } |
| 487 | 487 | ||
| 488 | static struct ipoib_path *__path_find(struct net_device *dev, void *gid) | 488 | struct ipoib_path *__path_find(struct net_device *dev, void *gid) |
| 489 | { | 489 | { |
| 490 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 490 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 491 | struct rb_node *n = priv->path_tree.rb_node; | 491 | struct rb_node *n = priv->path_tree.rb_node; |
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index ba6be060a476..cae9bbcc27e7 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c | |||
| @@ -403,6 +403,7 @@ isert_init_conn(struct isert_conn *isert_conn) | |||
| 403 | INIT_LIST_HEAD(&isert_conn->node); | 403 | INIT_LIST_HEAD(&isert_conn->node); |
| 404 | init_completion(&isert_conn->login_comp); | 404 | init_completion(&isert_conn->login_comp); |
| 405 | init_completion(&isert_conn->login_req_comp); | 405 | init_completion(&isert_conn->login_req_comp); |
| 406 | init_waitqueue_head(&isert_conn->rem_wait); | ||
| 406 | kref_init(&isert_conn->kref); | 407 | kref_init(&isert_conn->kref); |
| 407 | mutex_init(&isert_conn->mutex); | 408 | mutex_init(&isert_conn->mutex); |
| 408 | INIT_WORK(&isert_conn->release_work, isert_release_work); | 409 | INIT_WORK(&isert_conn->release_work, isert_release_work); |
| @@ -448,7 +449,7 @@ isert_alloc_login_buf(struct isert_conn *isert_conn, | |||
| 448 | 449 | ||
| 449 | isert_conn->login_rsp_buf = kzalloc(ISER_RX_PAYLOAD_SIZE, GFP_KERNEL); | 450 | isert_conn->login_rsp_buf = kzalloc(ISER_RX_PAYLOAD_SIZE, GFP_KERNEL); |
| 450 | if (!isert_conn->login_rsp_buf) { | 451 | if (!isert_conn->login_rsp_buf) { |
| 451 | isert_err("Unable to allocate isert_conn->login_rspbuf\n"); | 452 | ret = -ENOMEM; |
| 452 | goto out_unmap_login_req_buf; | 453 | goto out_unmap_login_req_buf; |
| 453 | } | 454 | } |
| 454 | 455 | ||
| @@ -578,7 +579,8 @@ isert_connect_release(struct isert_conn *isert_conn) | |||
| 578 | BUG_ON(!device); | 579 | BUG_ON(!device); |
| 579 | 580 | ||
| 580 | isert_free_rx_descriptors(isert_conn); | 581 | isert_free_rx_descriptors(isert_conn); |
| 581 | if (isert_conn->cm_id) | 582 | if (isert_conn->cm_id && |
| 583 | !isert_conn->dev_removed) | ||
| 582 | rdma_destroy_id(isert_conn->cm_id); | 584 | rdma_destroy_id(isert_conn->cm_id); |
| 583 | 585 | ||
| 584 | if (isert_conn->qp) { | 586 | if (isert_conn->qp) { |
| @@ -593,7 +595,10 @@ isert_connect_release(struct isert_conn *isert_conn) | |||
| 593 | 595 | ||
| 594 | isert_device_put(device); | 596 | isert_device_put(device); |
| 595 | 597 | ||
| 596 | kfree(isert_conn); | 598 | if (isert_conn->dev_removed) |
| 599 | wake_up_interruptible(&isert_conn->rem_wait); | ||
| 600 | else | ||
| 601 | kfree(isert_conn); | ||
| 597 | } | 602 | } |
| 598 | 603 | ||
| 599 | static void | 604 | static void |
| @@ -753,6 +758,7 @@ static int | |||
| 753 | isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) | 758 | isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) |
| 754 | { | 759 | { |
| 755 | struct isert_np *isert_np = cma_id->context; | 760 | struct isert_np *isert_np = cma_id->context; |
| 761 | struct isert_conn *isert_conn; | ||
| 756 | int ret = 0; | 762 | int ret = 0; |
| 757 | 763 | ||
| 758 | isert_info("%s (%d): status %d id %p np %p\n", | 764 | isert_info("%s (%d): status %d id %p np %p\n", |
| @@ -773,10 +779,21 @@ isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) | |||
| 773 | break; | 779 | break; |
| 774 | case RDMA_CM_EVENT_ADDR_CHANGE: /* FALLTHRU */ | 780 | case RDMA_CM_EVENT_ADDR_CHANGE: /* FALLTHRU */ |
| 775 | case RDMA_CM_EVENT_DISCONNECTED: /* FALLTHRU */ | 781 | case RDMA_CM_EVENT_DISCONNECTED: /* FALLTHRU */ |
| 776 | case RDMA_CM_EVENT_DEVICE_REMOVAL: /* FALLTHRU */ | ||
| 777 | case RDMA_CM_EVENT_TIMEWAIT_EXIT: /* FALLTHRU */ | 782 | case RDMA_CM_EVENT_TIMEWAIT_EXIT: /* FALLTHRU */ |
| 778 | ret = isert_disconnected_handler(cma_id, event->event); | 783 | ret = isert_disconnected_handler(cma_id, event->event); |
| 779 | break; | 784 | break; |
| 785 | case RDMA_CM_EVENT_DEVICE_REMOVAL: | ||
| 786 | isert_conn = cma_id->qp->qp_context; | ||
| 787 | isert_conn->dev_removed = true; | ||
| 788 | isert_disconnected_handler(cma_id, event->event); | ||
| 789 | wait_event_interruptible(isert_conn->rem_wait, | ||
| 790 | isert_conn->state == ISER_CONN_DOWN); | ||
| 791 | kfree(isert_conn); | ||
| 792 | /* | ||
| 793 | * return non-zero from the callback to destroy | ||
| 794 | * the rdma cm id | ||
| 795 | */ | ||
| 796 | return 1; | ||
| 780 | case RDMA_CM_EVENT_REJECTED: /* FALLTHRU */ | 797 | case RDMA_CM_EVENT_REJECTED: /* FALLTHRU */ |
| 781 | case RDMA_CM_EVENT_UNREACHABLE: /* FALLTHRU */ | 798 | case RDMA_CM_EVENT_UNREACHABLE: /* FALLTHRU */ |
| 782 | case RDMA_CM_EVENT_CONNECT_ERROR: | 799 | case RDMA_CM_EVENT_CONNECT_ERROR: |
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h index fc791efe3a10..c02ada57d7f5 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.h +++ b/drivers/infiniband/ulp/isert/ib_isert.h | |||
| @@ -158,6 +158,8 @@ struct isert_conn { | |||
| 158 | struct work_struct release_work; | 158 | struct work_struct release_work; |
| 159 | bool logout_posted; | 159 | bool logout_posted; |
| 160 | bool snd_w_inv; | 160 | bool snd_w_inv; |
| 161 | wait_queue_head_t rem_wait; | ||
| 162 | bool dev_removed; | ||
| 161 | }; | 163 | }; |
| 162 | 164 | ||
| 163 | #define ISERT_MAX_CQ 64 | 165 | #define ISERT_MAX_CQ 64 |
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index dfa23b075a88..883bbfe08e0e 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c | |||
| @@ -522,6 +522,11 @@ static int srpt_refresh_port(struct srpt_port *sport) | |||
| 522 | if (ret) | 522 | if (ret) |
| 523 | goto err_query_port; | 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 | if (!sport->mad_agent) { | 530 | if (!sport->mad_agent) { |
| 526 | memset(®_req, 0, sizeof(reg_req)); | 531 | memset(®_req, 0, sizeof(reg_req)); |
| 527 | reg_req.mgmt_class = IB_MGMT_CLASS_DEVICE_MGMT; | 532 | reg_req.mgmt_class = IB_MGMT_CLASS_DEVICE_MGMT; |
| @@ -2548,10 +2553,6 @@ static void srpt_add_one(struct ib_device *device) | |||
| 2548 | sdev->device->name, i); | 2553 | sdev->device->name, i); |
| 2549 | goto err_ring; | 2554 | goto err_ring; |
| 2550 | } | 2555 | } |
| 2551 | snprintf(sport->port_guid, sizeof(sport->port_guid), | ||
| 2552 | "0x%016llx%016llx", | ||
| 2553 | be64_to_cpu(sport->gid.global.subnet_prefix), | ||
| 2554 | be64_to_cpu(sport->gid.global.interface_id)); | ||
| 2555 | } | 2556 | } |
| 2556 | 2557 | ||
| 2557 | spin_lock(&srpt_dev_lock); | 2558 | spin_lock(&srpt_dev_lock); |
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index 7d61439be5f2..0c07e1023a46 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c | |||
| @@ -376,7 +376,7 @@ static int tegra_kbc_start(struct tegra_kbc *kbc) | |||
| 376 | /* Reset the KBC controller to clear all previous status.*/ | 376 | /* Reset the KBC controller to clear all previous status.*/ |
| 377 | reset_control_assert(kbc->rst); | 377 | reset_control_assert(kbc->rst); |
| 378 | udelay(100); | 378 | udelay(100); |
| 379 | reset_control_assert(kbc->rst); | 379 | reset_control_deassert(kbc->rst); |
| 380 | udelay(100); | 380 | udelay(100); |
| 381 | 381 | ||
| 382 | tegra_kbc_config_pins(kbc); | 382 | tegra_kbc_config_pins(kbc); |
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c index faa295ec4f31..c83bce89028b 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c | |||
| @@ -553,7 +553,6 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr, | |||
| 553 | goto free_struct_buff; | 553 | goto free_struct_buff; |
| 554 | 554 | ||
| 555 | reg = find_first_bit(rdesc->presense_map, RMI_REG_DESC_PRESENSE_BITS); | 555 | reg = find_first_bit(rdesc->presense_map, RMI_REG_DESC_PRESENSE_BITS); |
| 556 | map_offset = 0; | ||
| 557 | for (i = 0; i < rdesc->num_registers; i++) { | 556 | for (i = 0; i < rdesc->num_registers; i++) { |
| 558 | struct rmi_register_desc_item *item = &rdesc->registers[i]; | 557 | struct rmi_register_desc_item *item = &rdesc->registers[i]; |
| 559 | int reg_size = struct_buf[offset]; | 558 | int reg_size = struct_buf[offset]; |
| @@ -576,6 +575,8 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr, | |||
| 576 | item->reg = reg; | 575 | item->reg = reg; |
| 577 | item->reg_size = reg_size; | 576 | item->reg_size = reg_size; |
| 578 | 577 | ||
| 578 | map_offset = 0; | ||
| 579 | |||
| 579 | do { | 580 | do { |
| 580 | for (b = 0; b < 7; b++) { | 581 | for (b = 0; b < 7; b++) { |
| 581 | if (struct_buf[offset] & (0x1 << b)) | 582 | if (struct_buf[offset] & (0x1 << b)) |
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index b4d34086e73f..405252a884dd 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c | |||
| @@ -1305,6 +1305,7 @@ static int __init i8042_create_aux_port(int idx) | |||
| 1305 | serio->write = i8042_aux_write; | 1305 | serio->write = i8042_aux_write; |
| 1306 | serio->start = i8042_start; | 1306 | serio->start = i8042_start; |
| 1307 | serio->stop = i8042_stop; | 1307 | serio->stop = i8042_stop; |
| 1308 | serio->ps2_cmd_mutex = &i8042_mutex; | ||
| 1308 | serio->port_data = port; | 1309 | serio->port_data = port; |
| 1309 | serio->dev.parent = &i8042_platform_device->dev; | 1310 | serio->dev.parent = &i8042_platform_device->dev; |
| 1310 | if (idx < 0) { | 1311 | if (idx < 0) { |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index a61b2153ab8c..1ce3ecbe37f8 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
| @@ -1473,7 +1473,6 @@ static int ads7846_remove(struct spi_device *spi) | |||
| 1473 | 1473 | ||
| 1474 | ads784x_hwmon_unregister(spi, ts); | 1474 | ads784x_hwmon_unregister(spi, ts); |
| 1475 | 1475 | ||
| 1476 | regulator_disable(ts->reg); | ||
| 1477 | regulator_put(ts->reg); | 1476 | regulator_put(ts->reg); |
| 1478 | 1477 | ||
| 1479 | if (!ts->get_pendown_state) { | 1478 | if (!ts->get_pendown_state) { |
diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c index 7379fe153cf9..b2744a64e933 100644 --- a/drivers/input/touchscreen/silead.c +++ b/drivers/input/touchscreen/silead.c | |||
| @@ -464,7 +464,7 @@ static int silead_ts_probe(struct i2c_client *client, | |||
| 464 | return -ENODEV; | 464 | return -ENODEV; |
| 465 | 465 | ||
| 466 | /* Power GPIO pin */ | 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 | if (IS_ERR(data->gpio_power)) { | 468 | if (IS_ERR(data->gpio_power)) { |
| 469 | if (PTR_ERR(data->gpio_power) != -EPROBE_DEFER) | 469 | if (PTR_ERR(data->gpio_power) != -EPROBE_DEFER) |
| 470 | dev_err(dev, "Shutdown GPIO request failed\n"); | 470 | dev_err(dev, "Shutdown GPIO request failed\n"); |
diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index ce801170d5f2..641e88761319 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c | |||
| @@ -879,7 +879,7 @@ static void arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu) | |||
| 879 | * We may have concurrent producers, so we need to be careful | 879 | * We may have concurrent producers, so we need to be careful |
| 880 | * not to touch any of the shadow cmdq state. | 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 | dev_err(smmu->dev, "skipping command in error state:\n"); | 883 | dev_err(smmu->dev, "skipping command in error state:\n"); |
| 884 | for (i = 0; i < ARRAY_SIZE(cmd); ++i) | 884 | for (i = 0; i < ARRAY_SIZE(cmd); ++i) |
| 885 | dev_err(smmu->dev, "\t0x%016llx\n", (unsigned long long)cmd[i]); | 885 | dev_err(smmu->dev, "\t0x%016llx\n", (unsigned long long)cmd[i]); |
| @@ -890,7 +890,7 @@ static void arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu) | |||
| 890 | return; | 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 | static void arm_smmu_cmdq_issue_cmd(struct arm_smmu_device *smmu, | 896 | static void arm_smmu_cmdq_issue_cmd(struct arm_smmu_device *smmu, |
| @@ -1034,6 +1034,9 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_device *smmu, u32 sid, | |||
| 1034 | case STRTAB_STE_0_CFG_S2_TRANS: | 1034 | case STRTAB_STE_0_CFG_S2_TRANS: |
| 1035 | ste_live = true; | 1035 | ste_live = true; |
| 1036 | break; | 1036 | break; |
| 1037 | case STRTAB_STE_0_CFG_ABORT: | ||
| 1038 | if (disable_bypass) | ||
| 1039 | break; | ||
| 1037 | default: | 1040 | default: |
| 1038 | BUG(); /* STE corruption */ | 1041 | BUG(); /* STE corruption */ |
| 1039 | } | 1042 | } |
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 4f49fe29f202..2db74ebc3240 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c | |||
| @@ -686,8 +686,7 @@ static struct iommu_gather_ops arm_smmu_gather_ops = { | |||
| 686 | 686 | ||
| 687 | static irqreturn_t arm_smmu_context_fault(int irq, void *dev) | 687 | static irqreturn_t arm_smmu_context_fault(int irq, void *dev) |
| 688 | { | 688 | { |
| 689 | int flags, ret; | 689 | u32 fsr, fsynr; |
| 690 | u32 fsr, fsynr, resume; | ||
| 691 | unsigned long iova; | 690 | unsigned long iova; |
| 692 | struct iommu_domain *domain = dev; | 691 | struct iommu_domain *domain = dev; |
| 693 | struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); | 692 | struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); |
| @@ -701,34 +700,15 @@ static irqreturn_t arm_smmu_context_fault(int irq, void *dev) | |||
| 701 | if (!(fsr & FSR_FAULT)) | 700 | if (!(fsr & FSR_FAULT)) |
| 702 | return IRQ_NONE; | 701 | return IRQ_NONE; |
| 703 | 702 | ||
| 704 | if (fsr & FSR_IGN) | ||
| 705 | dev_err_ratelimited(smmu->dev, | ||
| 706 | "Unexpected context fault (fsr 0x%x)\n", | ||
| 707 | fsr); | ||
| 708 | |||
| 709 | fsynr = readl_relaxed(cb_base + ARM_SMMU_CB_FSYNR0); | 703 | fsynr = readl_relaxed(cb_base + ARM_SMMU_CB_FSYNR0); |
| 710 | flags = fsynr & FSYNR0_WNR ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ; | ||
| 711 | |||
| 712 | iova = readq_relaxed(cb_base + ARM_SMMU_CB_FAR); | 704 | iova = readq_relaxed(cb_base + ARM_SMMU_CB_FAR); |
| 713 | if (!report_iommu_fault(domain, smmu->dev, iova, flags)) { | ||
| 714 | ret = IRQ_HANDLED; | ||
| 715 | resume = RESUME_RETRY; | ||
| 716 | } else { | ||
| 717 | dev_err_ratelimited(smmu->dev, | ||
| 718 | "Unhandled context fault: iova=0x%08lx, fsynr=0x%x, cb=%d\n", | ||
| 719 | iova, fsynr, cfg->cbndx); | ||
| 720 | ret = IRQ_NONE; | ||
| 721 | resume = RESUME_TERMINATE; | ||
| 722 | } | ||
| 723 | |||
| 724 | /* Clear the faulting FSR */ | ||
| 725 | writel(fsr, cb_base + ARM_SMMU_CB_FSR); | ||
| 726 | 705 | ||
| 727 | /* Retry or terminate any stalled transactions */ | 706 | dev_err_ratelimited(smmu->dev, |
| 728 | if (fsr & FSR_SS) | 707 | "Unhandled context fault: fsr=0x%x, iova=0x%08lx, fsynr=0x%x, cb=%d\n", |
| 729 | writel_relaxed(resume, cb_base + ARM_SMMU_CB_RESUME); | 708 | fsr, iova, fsynr, cfg->cbndx); |
| 730 | 709 | ||
| 731 | return ret; | 710 | writel(fsr, cb_base + ARM_SMMU_CB_FSR); |
| 711 | return IRQ_HANDLED; | ||
| 732 | } | 712 | } |
| 733 | 713 | ||
| 734 | static irqreturn_t arm_smmu_global_fault(int irq, void *dev) | 714 | static irqreturn_t arm_smmu_global_fault(int irq, void *dev) |
| @@ -837,7 +817,7 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain, | |||
| 837 | } | 817 | } |
| 838 | 818 | ||
| 839 | /* SCTLR */ | 819 | /* SCTLR */ |
| 840 | reg = SCTLR_CFCFG | SCTLR_CFIE | SCTLR_CFRE | SCTLR_M | SCTLR_EAE_SBOP; | 820 | reg = SCTLR_CFIE | SCTLR_CFRE | SCTLR_M | SCTLR_EAE_SBOP; |
| 841 | if (stage1) | 821 | if (stage1) |
| 842 | reg |= SCTLR_S1_ASIDPNE; | 822 | reg |= SCTLR_S1_ASIDPNE; |
| 843 | #ifdef __BIG_ENDIAN | 823 | #ifdef __BIG_ENDIAN |
diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index 8c6139986d7d..def8ca1c982d 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c | |||
| @@ -286,12 +286,14 @@ static int arm_v7s_pte_to_prot(arm_v7s_iopte pte, int lvl) | |||
| 286 | int prot = IOMMU_READ; | 286 | int prot = IOMMU_READ; |
| 287 | arm_v7s_iopte attr = pte >> ARM_V7S_ATTR_SHIFT(lvl); | 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 | prot |= IOMMU_WRITE; | 290 | prot |= IOMMU_WRITE; |
| 291 | if ((attr & (ARM_V7S_TEX_MASK << ARM_V7S_TEX_SHIFT)) == 0) | 291 | if ((attr & (ARM_V7S_TEX_MASK << ARM_V7S_TEX_SHIFT)) == 0) |
| 292 | prot |= IOMMU_MMIO; | 292 | prot |= IOMMU_MMIO; |
| 293 | else if (pte & ARM_V7S_ATTR_C) | 293 | else if (pte & ARM_V7S_ATTR_C) |
| 294 | prot |= IOMMU_CACHE; | 294 | prot |= IOMMU_CACHE; |
| 295 | if (pte & ARM_V7S_ATTR_XN(lvl)) | ||
| 296 | prot |= IOMMU_NOEXEC; | ||
| 295 | 297 | ||
| 296 | return prot; | 298 | return prot; |
| 297 | } | 299 | } |
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 7ceaba81efb4..36b9c28a5c91 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c | |||
| @@ -1545,7 +1545,12 @@ static int its_force_quiescent(void __iomem *base) | |||
| 1545 | u32 val; | 1545 | u32 val; |
| 1546 | 1546 | ||
| 1547 | val = readl_relaxed(base + GITS_CTLR); | 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 | return 0; | 1554 | return 0; |
| 1550 | 1555 | ||
| 1551 | /* Disable the generation of all interrupts to this ITS */ | 1556 | /* Disable the generation of all interrupts to this ITS */ |
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 6fc56c3466b0..ede5672ab34d 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c | |||
| @@ -667,13 +667,20 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, | |||
| 667 | #endif | 667 | #endif |
| 668 | 668 | ||
| 669 | #ifdef CONFIG_CPU_PM | 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 | static int gic_cpu_pm_notifier(struct notifier_block *self, | 676 | static int gic_cpu_pm_notifier(struct notifier_block *self, |
| 671 | unsigned long cmd, void *v) | 677 | unsigned long cmd, void *v) |
| 672 | { | 678 | { |
| 673 | if (cmd == CPU_PM_EXIT) { | 679 | if (cmd == CPU_PM_EXIT) { |
| 674 | gic_enable_redist(true); | 680 | if (gic_dist_security_disabled()) |
| 681 | gic_enable_redist(true); | ||
| 675 | gic_cpu_sys_reg_init(); | 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 | gic_write_grpen1(0); | 684 | gic_write_grpen1(0); |
| 678 | gic_enable_redist(false); | 685 | gic_enable_redist(false); |
| 679 | } | 686 | } |
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index c2cab572c511..390fac59c6bc 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c | |||
| @@ -769,6 +769,13 @@ static void gic_raise_softirq(const struct cpumask *mask, unsigned int irq) | |||
| 769 | int cpu; | 769 | int cpu; |
| 770 | unsigned long flags, map = 0; | 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 | raw_spin_lock_irqsave(&irq_controller_lock, flags); | 779 | raw_spin_lock_irqsave(&irq_controller_lock, flags); |
| 773 | 780 | ||
| 774 | /* Convert our logical CPU mask into a physical one. */ | 781 | /* Convert our logical CPU mask into a physical one. */ |
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index c5f33c3bd228..83f498393a7f 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c | |||
| @@ -713,9 +713,6 @@ static int gic_shared_irq_domain_map(struct irq_domain *d, unsigned int virq, | |||
| 713 | unsigned long flags; | 713 | unsigned long flags; |
| 714 | int i; | 714 | int i; |
| 715 | 715 | ||
| 716 | irq_set_chip_and_handler(virq, &gic_level_irq_controller, | ||
| 717 | handle_level_irq); | ||
| 718 | |||
| 719 | spin_lock_irqsave(&gic_lock, flags); | 716 | spin_lock_irqsave(&gic_lock, flags); |
| 720 | gic_map_to_pin(intr, gic_cpu_pin); | 717 | gic_map_to_pin(intr, gic_cpu_pin); |
| 721 | gic_map_to_vpe(intr, mips_cm_vp_id(vpe)); | 718 | gic_map_to_vpe(intr, mips_cm_vp_id(vpe)); |
| @@ -732,6 +729,10 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq, | |||
| 732 | { | 729 | { |
| 733 | if (GIC_HWIRQ_TO_LOCAL(hw) < GIC_NUM_LOCAL_INTRS) | 730 | if (GIC_HWIRQ_TO_LOCAL(hw) < GIC_NUM_LOCAL_INTRS) |
| 734 | return gic_local_irq_domain_map(d, virq, hw); | 731 | return gic_local_irq_domain_map(d, virq, hw); |
| 732 | |||
| 733 | irq_set_chip_and_handler(virq, &gic_level_irq_controller, | ||
| 734 | handle_level_irq); | ||
| 735 | |||
| 735 | return gic_shared_irq_domain_map(d, virq, hw, 0); | 736 | return gic_shared_irq_domain_map(d, virq, hw, 0); |
| 736 | } | 737 | } |
| 737 | 738 | ||
| @@ -771,11 +772,13 @@ static int gic_irq_domain_alloc(struct irq_domain *d, unsigned int virq, | |||
| 771 | hwirq = GIC_SHARED_TO_HWIRQ(base_hwirq + i); | 772 | hwirq = GIC_SHARED_TO_HWIRQ(base_hwirq + i); |
| 772 | 773 | ||
| 773 | ret = irq_domain_set_hwirq_and_chip(d, virq + i, hwirq, | 774 | ret = irq_domain_set_hwirq_and_chip(d, virq + i, hwirq, |
| 774 | &gic_edge_irq_controller, | 775 | &gic_level_irq_controller, |
| 775 | NULL); | 776 | NULL); |
| 776 | if (ret) | 777 | if (ret) |
| 777 | goto error; | 778 | goto error; |
| 778 | 779 | ||
| 780 | irq_set_handler(virq + i, handle_level_irq); | ||
| 781 | |||
| 779 | ret = gic_shared_irq_domain_map(d, virq + i, hwirq, cpu); | 782 | ret = gic_shared_irq_domain_map(d, virq + i, hwirq, cpu); |
| 780 | if (ret) | 783 | if (ret) |
| 781 | goto error; | 784 | goto error; |
| @@ -890,10 +893,17 @@ void gic_dev_domain_free(struct irq_domain *d, unsigned int virq, | |||
| 890 | return; | 893 | return; |
| 891 | } | 894 | } |
| 892 | 895 | ||
| 896 | static void gic_dev_domain_activate(struct irq_domain *domain, | ||
| 897 | struct irq_data *d) | ||
| 898 | { | ||
| 899 | gic_shared_irq_domain_map(domain, d->irq, d->hwirq, 0); | ||
| 900 | } | ||
| 901 | |||
| 893 | static struct irq_domain_ops gic_dev_domain_ops = { | 902 | static struct irq_domain_ops gic_dev_domain_ops = { |
| 894 | .xlate = gic_dev_domain_xlate, | 903 | .xlate = gic_dev_domain_xlate, |
| 895 | .alloc = gic_dev_domain_alloc, | 904 | .alloc = gic_dev_domain_alloc, |
| 896 | .free = gic_dev_domain_free, | 905 | .free = gic_dev_domain_free, |
| 906 | .activate = gic_dev_domain_activate, | ||
| 897 | }; | 907 | }; |
| 898 | 908 | ||
| 899 | static int gic_ipi_domain_xlate(struct irq_domain *d, struct device_node *ctrlr, | 909 | static int gic_ipi_domain_xlate(struct irq_domain *d, struct device_node *ctrlr, |
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 97c372908e78..7817d40d81e7 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig | |||
| @@ -127,6 +127,7 @@ config XGENE_SLIMPRO_MBOX | |||
| 127 | config BCM_PDC_MBOX | 127 | config BCM_PDC_MBOX |
| 128 | tristate "Broadcom PDC Mailbox" | 128 | tristate "Broadcom PDC Mailbox" |
| 129 | depends on ARM64 || COMPILE_TEST | 129 | depends on ARM64 || COMPILE_TEST |
| 130 | depends on HAS_DMA | ||
| 130 | default ARCH_BCM_IPROC | 131 | default ARCH_BCM_IPROC |
| 131 | help | 132 | help |
| 132 | Mailbox implementation for the Broadcom PDC ring manager, | 133 | Mailbox implementation for the Broadcom PDC ring manager, |
diff --git a/drivers/mailbox/bcm-pdc-mailbox.c b/drivers/mailbox/bcm-pdc-mailbox.c index cbe0c1ee4ba9..c19dd820ea9b 100644 --- a/drivers/mailbox/bcm-pdc-mailbox.c +++ b/drivers/mailbox/bcm-pdc-mailbox.c | |||
| @@ -469,7 +469,7 @@ static const struct file_operations pdc_debugfs_stats = { | |||
| 469 | * this directory for a SPU. | 469 | * this directory for a SPU. |
| 470 | * @pdcs: PDC state structure | 470 | * @pdcs: PDC state structure |
| 471 | */ | 471 | */ |
| 472 | void pdc_setup_debugfs(struct pdc_state *pdcs) | 472 | static void pdc_setup_debugfs(struct pdc_state *pdcs) |
| 473 | { | 473 | { |
| 474 | char spu_stats_name[16]; | 474 | char spu_stats_name[16]; |
| 475 | 475 | ||
| @@ -485,7 +485,7 @@ void pdc_setup_debugfs(struct pdc_state *pdcs) | |||
| 485 | &pdc_debugfs_stats); | 485 | &pdc_debugfs_stats); |
| 486 | } | 486 | } |
| 487 | 487 | ||
| 488 | void pdc_free_debugfs(void) | 488 | static void pdc_free_debugfs(void) |
| 489 | { | 489 | { |
| 490 | if (debugfs_dir && simple_empty(debugfs_dir)) { | 490 | if (debugfs_dir && simple_empty(debugfs_dir)) { |
| 491 | debugfs_remove_recursive(debugfs_dir); | 491 | debugfs_remove_recursive(debugfs_dir); |
| @@ -1191,10 +1191,11 @@ static void pdc_shutdown(struct mbox_chan *chan) | |||
| 1191 | { | 1191 | { |
| 1192 | struct pdc_state *pdcs = chan->con_priv; | 1192 | struct pdc_state *pdcs = chan->con_priv; |
| 1193 | 1193 | ||
| 1194 | if (pdcs) | 1194 | if (!pdcs) |
| 1195 | dev_dbg(&pdcs->pdev->dev, | 1195 | return; |
| 1196 | "Shutdown mailbox channel for PDC %u", pdcs->pdc_idx); | ||
| 1197 | 1196 | ||
| 1197 | dev_dbg(&pdcs->pdev->dev, | ||
| 1198 | "Shutdown mailbox channel for PDC %u", pdcs->pdc_idx); | ||
| 1198 | pdc_ring_free(pdcs); | 1199 | pdc_ring_free(pdcs); |
| 1199 | } | 1200 | } |
| 1200 | 1201 | ||
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 95a4ca6ce6ff..849ad441cd76 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c | |||
| @@ -760,7 +760,8 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size, | |||
| 760 | if (!d->nr_stripes || | 760 | if (!d->nr_stripes || |
| 761 | d->nr_stripes > INT_MAX || | 761 | d->nr_stripes > INT_MAX || |
| 762 | d->nr_stripes > SIZE_MAX / sizeof(atomic_t)) { | 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 | return -ENOMEM; | 765 | return -ENOMEM; |
| 765 | } | 766 | } |
| 766 | 767 | ||
| @@ -1820,7 +1821,7 @@ static int cache_alloc(struct cache *ca) | |||
| 1820 | free = roundup_pow_of_two(ca->sb.nbuckets) >> 10; | 1821 | free = roundup_pow_of_two(ca->sb.nbuckets) >> 10; |
| 1821 | 1822 | ||
| 1822 | if (!init_fifo(&ca->free[RESERVE_BTREE], 8, GFP_KERNEL) || | 1823 | if (!init_fifo(&ca->free[RESERVE_BTREE], 8, GFP_KERNEL) || |
| 1823 | !init_fifo(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || | 1824 | !init_fifo_exact(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || |
| 1824 | !init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL) || | 1825 | !init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL) || |
| 1825 | !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) || | 1826 | !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) || |
| 1826 | !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) || | 1827 | !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) || |
| @@ -1844,7 +1845,7 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page, | |||
| 1844 | struct block_device *bdev, struct cache *ca) | 1845 | struct block_device *bdev, struct cache *ca) |
| 1845 | { | 1846 | { |
| 1846 | char name[BDEVNAME_SIZE]; | 1847 | char name[BDEVNAME_SIZE]; |
| 1847 | const char *err = NULL; | 1848 | const char *err = NULL; /* must be set for any error case */ |
| 1848 | int ret = 0; | 1849 | int ret = 0; |
| 1849 | 1850 | ||
| 1850 | memcpy(&ca->sb, sb, sizeof(struct cache_sb)); | 1851 | memcpy(&ca->sb, sb, sizeof(struct cache_sb)); |
| @@ -1861,8 +1862,13 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page, | |||
| 1861 | ca->discard = CACHE_DISCARD(&ca->sb); | 1862 | ca->discard = CACHE_DISCARD(&ca->sb); |
| 1862 | 1863 | ||
| 1863 | ret = cache_alloc(ca); | 1864 | ret = cache_alloc(ca); |
| 1864 | if (ret != 0) | 1865 | if (ret != 0) { |
| 1866 | if (ret == -ENOMEM) | ||
| 1867 | err = "cache_alloc(): -ENOMEM"; | ||
| 1868 | else | ||
| 1869 | err = "cache_alloc(): unknown error"; | ||
| 1865 | goto err; | 1870 | goto err; |
| 1871 | } | ||
| 1866 | 1872 | ||
| 1867 | if (kobject_add(&ca->kobj, &part_to_dev(bdev->bd_part)->kobj, "bcache")) { | 1873 | if (kobject_add(&ca->kobj, &part_to_dev(bdev->bd_part)->kobj, "bcache")) { |
| 1868 | err = "error calling kobject_add"; | 1874 | err = "error calling kobject_add"; |
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 6fff794e0c72..13041ee37ad6 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
| @@ -2183,19 +2183,29 @@ location_show(struct mddev *mddev, char *page) | |||
| 2183 | static ssize_t | 2183 | static ssize_t |
| 2184 | location_store(struct mddev *mddev, const char *buf, size_t len) | 2184 | location_store(struct mddev *mddev, const char *buf, size_t len) |
| 2185 | { | 2185 | { |
| 2186 | int rv; | ||
| 2186 | 2187 | ||
| 2188 | rv = mddev_lock(mddev); | ||
| 2189 | if (rv) | ||
| 2190 | return rv; | ||
| 2187 | if (mddev->pers) { | 2191 | if (mddev->pers) { |
| 2188 | if (!mddev->pers->quiesce) | 2192 | if (!mddev->pers->quiesce) { |
| 2189 | return -EBUSY; | 2193 | rv = -EBUSY; |
| 2190 | if (mddev->recovery || mddev->sync_thread) | 2194 | goto out; |
| 2191 | return -EBUSY; | 2195 | } |
| 2196 | if (mddev->recovery || mddev->sync_thread) { | ||
| 2197 | rv = -EBUSY; | ||
| 2198 | goto out; | ||
| 2199 | } | ||
| 2192 | } | 2200 | } |
| 2193 | 2201 | ||
| 2194 | if (mddev->bitmap || mddev->bitmap_info.file || | 2202 | if (mddev->bitmap || mddev->bitmap_info.file || |
| 2195 | mddev->bitmap_info.offset) { | 2203 | mddev->bitmap_info.offset) { |
| 2196 | /* bitmap already configured. Only option is to clear it */ | 2204 | /* bitmap already configured. Only option is to clear it */ |
| 2197 | if (strncmp(buf, "none", 4) != 0) | 2205 | if (strncmp(buf, "none", 4) != 0) { |
| 2198 | return -EBUSY; | 2206 | rv = -EBUSY; |
| 2207 | goto out; | ||
| 2208 | } | ||
| 2199 | if (mddev->pers) { | 2209 | if (mddev->pers) { |
| 2200 | mddev->pers->quiesce(mddev, 1); | 2210 | mddev->pers->quiesce(mddev, 1); |
| 2201 | bitmap_destroy(mddev); | 2211 | bitmap_destroy(mddev); |
| @@ -2214,21 +2224,25 @@ location_store(struct mddev *mddev, const char *buf, size_t len) | |||
| 2214 | /* nothing to be done */; | 2224 | /* nothing to be done */; |
| 2215 | else if (strncmp(buf, "file:", 5) == 0) { | 2225 | else if (strncmp(buf, "file:", 5) == 0) { |
| 2216 | /* Not supported yet */ | 2226 | /* Not supported yet */ |
| 2217 | return -EINVAL; | 2227 | rv = -EINVAL; |
| 2228 | goto out; | ||
| 2218 | } else { | 2229 | } else { |
| 2219 | int rv; | ||
| 2220 | if (buf[0] == '+') | 2230 | if (buf[0] == '+') |
| 2221 | rv = kstrtoll(buf+1, 10, &offset); | 2231 | rv = kstrtoll(buf+1, 10, &offset); |
| 2222 | else | 2232 | else |
| 2223 | rv = kstrtoll(buf, 10, &offset); | 2233 | rv = kstrtoll(buf, 10, &offset); |
| 2224 | if (rv) | 2234 | if (rv) |
| 2225 | return rv; | 2235 | goto out; |
| 2226 | if (offset == 0) | 2236 | if (offset == 0) { |
| 2227 | return -EINVAL; | 2237 | rv = -EINVAL; |
| 2238 | goto out; | ||
| 2239 | } | ||
| 2228 | if (mddev->bitmap_info.external == 0 && | 2240 | if (mddev->bitmap_info.external == 0 && |
| 2229 | mddev->major_version == 0 && | 2241 | mddev->major_version == 0 && |
| 2230 | offset != mddev->bitmap_info.default_offset) | 2242 | offset != mddev->bitmap_info.default_offset) { |
| 2231 | return -EINVAL; | 2243 | rv = -EINVAL; |
| 2244 | goto out; | ||
| 2245 | } | ||
| 2232 | mddev->bitmap_info.offset = offset; | 2246 | mddev->bitmap_info.offset = offset; |
| 2233 | if (mddev->pers) { | 2247 | if (mddev->pers) { |
| 2234 | struct bitmap *bitmap; | 2248 | struct bitmap *bitmap; |
| @@ -2245,7 +2259,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len) | |||
| 2245 | mddev->pers->quiesce(mddev, 0); | 2259 | mddev->pers->quiesce(mddev, 0); |
| 2246 | if (rv) { | 2260 | if (rv) { |
| 2247 | bitmap_destroy(mddev); | 2261 | bitmap_destroy(mddev); |
| 2248 | return rv; | 2262 | goto out; |
| 2249 | } | 2263 | } |
| 2250 | } | 2264 | } |
| 2251 | } | 2265 | } |
| @@ -2257,6 +2271,11 @@ location_store(struct mddev *mddev, const char *buf, size_t len) | |||
| 2257 | set_bit(MD_CHANGE_DEVS, &mddev->flags); | 2271 | set_bit(MD_CHANGE_DEVS, &mddev->flags); |
| 2258 | md_wakeup_thread(mddev->thread); | 2272 | md_wakeup_thread(mddev->thread); |
| 2259 | } | 2273 | } |
| 2274 | rv = 0; | ||
| 2275 | out: | ||
| 2276 | mddev_unlock(mddev); | ||
| 2277 | if (rv) | ||
| 2278 | return rv; | ||
| 2260 | return len; | 2279 | return len; |
| 2261 | } | 2280 | } |
| 2262 | 2281 | ||
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c index 6571c81465e1..8625040bae92 100644 --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c | |||
| @@ -1879,7 +1879,7 @@ static int __init dm_bufio_init(void) | |||
| 1879 | __cache_size_refresh(); | 1879 | __cache_size_refresh(); |
| 1880 | mutex_unlock(&dm_bufio_clients_lock); | 1880 | mutex_unlock(&dm_bufio_clients_lock); |
| 1881 | 1881 | ||
| 1882 | dm_bufio_wq = create_singlethread_workqueue("dm_bufio_cache"); | 1882 | dm_bufio_wq = alloc_workqueue("dm_bufio_cache", WQ_MEM_RECLAIM, 0); |
| 1883 | if (!dm_bufio_wq) | 1883 | if (!dm_bufio_wq) |
| 1884 | return -ENOMEM; | 1884 | return -ENOMEM; |
| 1885 | 1885 | ||
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index eedba67b0e3e..874295757caa 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
| @@ -1453,7 +1453,7 @@ static int crypt_alloc_tfms(struct crypt_config *cc, char *ciphermode) | |||
| 1453 | unsigned i; | 1453 | unsigned i; |
| 1454 | int err; | 1454 | int err; |
| 1455 | 1455 | ||
| 1456 | cc->tfms = kmalloc(cc->tfms_count * sizeof(struct crypto_skcipher *), | 1456 | cc->tfms = kzalloc(cc->tfms_count * sizeof(struct crypto_skcipher *), |
| 1457 | GFP_KERNEL); | 1457 | GFP_KERNEL); |
| 1458 | if (!cc->tfms) | 1458 | if (!cc->tfms) |
| 1459 | return -ENOMEM; | 1459 | return -ENOMEM; |
| @@ -1924,6 +1924,13 @@ static int crypt_map(struct dm_target *ti, struct bio *bio) | |||
| 1924 | return DM_MAPIO_REMAPPED; | 1924 | return DM_MAPIO_REMAPPED; |
| 1925 | } | 1925 | } |
| 1926 | 1926 | ||
| 1927 | /* | ||
| 1928 | * Check if bio is too large, split as needed. | ||
| 1929 | */ | ||
| 1930 | if (unlikely(bio->bi_iter.bi_size > (BIO_MAX_PAGES << PAGE_SHIFT)) && | ||
| 1931 | bio_data_dir(bio) == WRITE) | ||
| 1932 | dm_accept_partial_bio(bio, ((BIO_MAX_PAGES << PAGE_SHIFT) >> SECTOR_SHIFT)); | ||
| 1933 | |||
| 1927 | io = dm_per_bio_data(bio, cc->per_bio_data_size); | 1934 | io = dm_per_bio_data(bio, cc->per_bio_data_size); |
| 1928 | crypt_io_init(io, cc, bio, dm_target_offset(ti, bio->bi_iter.bi_sector)); | 1935 | crypt_io_init(io, cc, bio, dm_target_offset(ti, bio->bi_iter.bi_sector)); |
| 1929 | io->ctx.req = (struct skcipher_request *)(io + 1); | 1936 | io->ctx.req = (struct skcipher_request *)(io + 1); |
diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c index 97e446d54a15..6a2e8dd44a1b 100644 --- a/drivers/md/dm-flakey.c +++ b/drivers/md/dm-flakey.c | |||
| @@ -289,15 +289,13 @@ static int flakey_map(struct dm_target *ti, struct bio *bio) | |||
| 289 | pb->bio_submitted = true; | 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 | if (bio_data_dir(bio) == READ) { | 295 | if (bio_data_dir(bio) == READ) { |
| 295 | /* If flags were specified, only corrupt those that match. */ | 296 | if (!fc->corrupt_bio_byte && !test_bit(DROP_WRITES, &fc->flags)) |
| 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 | ||
| 300 | return -EIO; | 297 | return -EIO; |
| 298 | goto map_bio; | ||
| 301 | } | 299 | } |
| 302 | 300 | ||
| 303 | /* | 301 | /* |
| @@ -334,14 +332,21 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error) | |||
| 334 | struct flakey_c *fc = ti->private; | 332 | struct flakey_c *fc = ti->private; |
| 335 | struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); | 333 | struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); |
| 336 | 334 | ||
| 337 | /* | ||
| 338 | * Corrupt successful READs while in down state. | ||
| 339 | */ | ||
| 340 | if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) { | 335 | if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) { |
| 341 | if (fc->corrupt_bio_byte) | 336 | if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && |
| 337 | all_corrupt_bio_flags_match(bio, fc)) { | ||
| 338 | /* | ||
| 339 | * Corrupt successful matching READs while in down state. | ||
| 340 | */ | ||
| 342 | corrupt_bio_data(bio, fc); | 341 | corrupt_bio_data(bio, fc); |
| 343 | else | 342 | |
| 343 | } else if (!test_bit(DROP_WRITES, &fc->flags)) { | ||
| 344 | /* | ||
| 345 | * Error read during the down_interval if drop_writes | ||
| 346 | * wasn't configured. | ||
| 347 | */ | ||
| 344 | return -EIO; | 348 | return -EIO; |
| 349 | } | ||
| 345 | } | 350 | } |
| 346 | 351 | ||
| 347 | return error; | 352 | return error; |
diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c index 4ab68033f9d1..49e4d8d4558f 100644 --- a/drivers/md/dm-log-writes.c +++ b/drivers/md/dm-log-writes.c | |||
| @@ -259,12 +259,12 @@ static int log_one_block(struct log_writes_c *lc, | |||
| 259 | goto out; | 259 | goto out; |
| 260 | sector++; | 260 | sector++; |
| 261 | 261 | ||
| 262 | bio = bio_alloc(GFP_KERNEL, block->vec_cnt); | 262 | atomic_inc(&lc->io_blocks); |
| 263 | bio = bio_alloc(GFP_KERNEL, min(block->vec_cnt, BIO_MAX_PAGES)); | ||
| 263 | if (!bio) { | 264 | if (!bio) { |
| 264 | DMERR("Couldn't alloc log bio"); | 265 | DMERR("Couldn't alloc log bio"); |
| 265 | goto error; | 266 | goto error; |
| 266 | } | 267 | } |
| 267 | atomic_inc(&lc->io_blocks); | ||
| 268 | bio->bi_iter.bi_size = 0; | 268 | bio->bi_iter.bi_size = 0; |
| 269 | bio->bi_iter.bi_sector = sector; | 269 | bio->bi_iter.bi_sector = sector; |
| 270 | bio->bi_bdev = lc->logdev->bdev; | 270 | bio->bi_bdev = lc->logdev->bdev; |
| @@ -282,7 +282,7 @@ static int log_one_block(struct log_writes_c *lc, | |||
| 282 | if (ret != block->vecs[i].bv_len) { | 282 | if (ret != block->vecs[i].bv_len) { |
| 283 | atomic_inc(&lc->io_blocks); | 283 | atomic_inc(&lc->io_blocks); |
| 284 | submit_bio(bio); | 284 | submit_bio(bio); |
| 285 | bio = bio_alloc(GFP_KERNEL, block->vec_cnt - i); | 285 | bio = bio_alloc(GFP_KERNEL, min(block->vec_cnt - i, BIO_MAX_PAGES)); |
| 286 | if (!bio) { | 286 | if (!bio) { |
| 287 | DMERR("Couldn't alloc log bio"); | 287 | DMERR("Couldn't alloc log bio"); |
| 288 | goto error; | 288 | goto error; |
| @@ -459,9 +459,9 @@ static int log_writes_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 459 | goto bad; | 459 | goto bad; |
| 460 | } | 460 | } |
| 461 | 461 | ||
| 462 | ret = -EINVAL; | ||
| 463 | lc->log_kthread = kthread_run(log_writes_kthread, lc, "log-write"); | 462 | lc->log_kthread = kthread_run(log_writes_kthread, lc, "log-write"); |
| 464 | if (!lc->log_kthread) { | 463 | if (IS_ERR(lc->log_kthread)) { |
| 464 | ret = PTR_ERR(lc->log_kthread); | ||
| 465 | ti->error = "Couldn't alloc kthread"; | 465 | ti->error = "Couldn't alloc kthread"; |
| 466 | dm_put_device(ti, lc->dev); | 466 | dm_put_device(ti, lc->dev); |
| 467 | dm_put_device(ti, lc->logdev); | 467 | dm_put_device(ti, lc->logdev); |
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c index 4ca2d1df5b44..07fc1ad42ec5 100644 --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c | |||
| @@ -291,9 +291,10 @@ static void header_from_disk(struct log_header_core *core, struct log_header_dis | |||
| 291 | core->nr_regions = le64_to_cpu(disk->nr_regions); | 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 | return dm_io(&lc->io_req, 1, &lc->header_location, NULL); | 299 | return dm_io(&lc->io_req, 1, &lc->header_location, NULL); |
| 299 | } | 300 | } |
| @@ -316,7 +317,7 @@ static int read_header(struct log_c *log) | |||
| 316 | { | 317 | { |
| 317 | int r; | 318 | int r; |
| 318 | 319 | ||
| 319 | r = rw_header(log, READ); | 320 | r = rw_header(log, REQ_OP_READ); |
| 320 | if (r) | 321 | if (r) |
| 321 | return r; | 322 | return r; |
| 322 | 323 | ||
| @@ -630,7 +631,7 @@ static int disk_resume(struct dm_dirty_log *log) | |||
| 630 | header_to_disk(&lc->header, lc->disk_header); | 631 | header_to_disk(&lc->header, lc->disk_header); |
| 631 | 632 | ||
| 632 | /* write the new header */ | 633 | /* write the new header */ |
| 633 | r = rw_header(lc, WRITE); | 634 | r = rw_header(lc, REQ_OP_WRITE); |
| 634 | if (!r) { | 635 | if (!r) { |
| 635 | r = flush_header(lc); | 636 | r = flush_header(lc); |
| 636 | if (r) | 637 | if (r) |
| @@ -698,7 +699,7 @@ static int disk_flush(struct dm_dirty_log *log) | |||
| 698 | log_clear_bit(lc, lc->clean_bits, i); | 699 | log_clear_bit(lc, lc->clean_bits, i); |
| 699 | } | 700 | } |
| 700 | 701 | ||
| 701 | r = rw_header(lc, WRITE); | 702 | r = rw_header(lc, REQ_OP_WRITE); |
| 702 | if (r) | 703 | if (r) |
| 703 | fail_log_device(lc); | 704 | fail_log_device(lc); |
| 704 | else { | 705 | else { |
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c index 41573f1f626f..34a840d9df76 100644 --- a/drivers/md/md-cluster.c +++ b/drivers/md/md-cluster.c | |||
| @@ -834,8 +834,10 @@ static int join(struct mddev *mddev, int nodes) | |||
| 834 | goto err; | 834 | goto err; |
| 835 | } | 835 | } |
| 836 | cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0); | 836 | cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0); |
| 837 | if (!cinfo->ack_lockres) | 837 | if (!cinfo->ack_lockres) { |
| 838 | ret = -ENOMEM; | ||
| 838 | goto err; | 839 | goto err; |
| 840 | } | ||
| 839 | /* get sync CR lock on ACK. */ | 841 | /* get sync CR lock on ACK. */ |
| 840 | if (dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR)) | 842 | if (dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR)) |
| 841 | pr_err("md-cluster: failed to get a sync CR lock on ACK!(%d)\n", | 843 | pr_err("md-cluster: failed to get a sync CR lock on ACK!(%d)\n", |
| @@ -849,8 +851,10 @@ static int join(struct mddev *mddev, int nodes) | |||
| 849 | pr_info("md-cluster: Joined cluster %s slot %d\n", str, cinfo->slot_number); | 851 | pr_info("md-cluster: Joined cluster %s slot %d\n", str, cinfo->slot_number); |
| 850 | snprintf(str, 64, "bitmap%04d", cinfo->slot_number - 1); | 852 | snprintf(str, 64, "bitmap%04d", cinfo->slot_number - 1); |
| 851 | cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1); | 853 | cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1); |
| 852 | if (!cinfo->bitmap_lockres) | 854 | if (!cinfo->bitmap_lockres) { |
| 855 | ret = -ENOMEM; | ||
| 853 | goto err; | 856 | goto err; |
| 857 | } | ||
| 854 | if (dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW)) { | 858 | if (dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW)) { |
| 855 | pr_err("Failed to get bitmap lock\n"); | 859 | pr_err("Failed to get bitmap lock\n"); |
| 856 | ret = -EINVAL; | 860 | ret = -EINVAL; |
| @@ -858,8 +862,10 @@ static int join(struct mddev *mddev, int nodes) | |||
| 858 | } | 862 | } |
| 859 | 863 | ||
| 860 | cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0); | 864 | cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0); |
| 861 | if (!cinfo->resync_lockres) | 865 | if (!cinfo->resync_lockres) { |
| 866 | ret = -ENOMEM; | ||
| 862 | goto err; | 867 | goto err; |
| 868 | } | ||
| 863 | 869 | ||
| 864 | return 0; | 870 | return 0; |
| 865 | err: | 871 | err: |
diff --git a/drivers/md/md.c b/drivers/md/md.c index d646f6e444f0..915e84d631a2 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
| @@ -1604,11 +1604,8 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev) | |||
| 1604 | mddev->new_chunk_sectors = mddev->chunk_sectors; | 1604 | mddev->new_chunk_sectors = mddev->chunk_sectors; |
| 1605 | } | 1605 | } |
| 1606 | 1606 | ||
| 1607 | if (le32_to_cpu(sb->feature_map) & MD_FEATURE_JOURNAL) { | 1607 | if (le32_to_cpu(sb->feature_map) & MD_FEATURE_JOURNAL) |
| 1608 | set_bit(MD_HAS_JOURNAL, &mddev->flags); | 1608 | set_bit(MD_HAS_JOURNAL, &mddev->flags); |
| 1609 | if (mddev->recovery_cp == MaxSector) | ||
| 1610 | set_bit(MD_JOURNAL_CLEAN, &mddev->flags); | ||
| 1611 | } | ||
| 1612 | } else if (mddev->pers == NULL) { | 1609 | } else if (mddev->pers == NULL) { |
| 1613 | /* Insist of good event counter while assembling, except for | 1610 | /* Insist of good event counter while assembling, except for |
| 1614 | * spares (which don't need an event count) */ | 1611 | * spares (which don't need an event count) */ |
| @@ -5851,6 +5848,9 @@ static int get_array_info(struct mddev *mddev, void __user *arg) | |||
| 5851 | working++; | 5848 | working++; |
| 5852 | if (test_bit(In_sync, &rdev->flags)) | 5849 | if (test_bit(In_sync, &rdev->flags)) |
| 5853 | insync++; | 5850 | insync++; |
| 5851 | else if (test_bit(Journal, &rdev->flags)) | ||
| 5852 | /* TODO: add journal count to md_u.h */ | ||
| 5853 | ; | ||
| 5854 | else | 5854 | else |
| 5855 | spare++; | 5855 | spare++; |
| 5856 | } | 5856 | } |
| @@ -7610,16 +7610,12 @@ EXPORT_SYMBOL(unregister_md_cluster_operations); | |||
| 7610 | 7610 | ||
| 7611 | int md_setup_cluster(struct mddev *mddev, int nodes) | 7611 | int md_setup_cluster(struct mddev *mddev, int nodes) |
| 7612 | { | 7612 | { |
| 7613 | int err; | 7613 | if (!md_cluster_ops) |
| 7614 | 7614 | request_module("md-cluster"); | |
| 7615 | err = request_module("md-cluster"); | ||
| 7616 | if (err) { | ||
| 7617 | pr_err("md-cluster module not found.\n"); | ||
| 7618 | return -ENOENT; | ||
| 7619 | } | ||
| 7620 | |||
| 7621 | spin_lock(&pers_lock); | 7615 | spin_lock(&pers_lock); |
| 7616 | /* ensure module won't be unloaded */ | ||
| 7622 | if (!md_cluster_ops || !try_module_get(md_cluster_mod)) { | 7617 | if (!md_cluster_ops || !try_module_get(md_cluster_mod)) { |
| 7618 | pr_err("can't find md-cluster module or get it's reference.\n"); | ||
| 7623 | spin_unlock(&pers_lock); | 7619 | spin_unlock(&pers_lock); |
| 7624 | return -ENOENT; | 7620 | return -ENOENT; |
| 7625 | } | 7621 | } |
| @@ -7862,6 +7858,7 @@ void md_do_sync(struct md_thread *thread) | |||
| 7862 | */ | 7858 | */ |
| 7863 | 7859 | ||
| 7864 | do { | 7860 | do { |
| 7861 | int mddev2_minor = -1; | ||
| 7865 | mddev->curr_resync = 2; | 7862 | mddev->curr_resync = 2; |
| 7866 | 7863 | ||
| 7867 | try_again: | 7864 | try_again: |
| @@ -7891,10 +7888,14 @@ void md_do_sync(struct md_thread *thread) | |||
| 7891 | prepare_to_wait(&resync_wait, &wq, TASK_INTERRUPTIBLE); | 7888 | prepare_to_wait(&resync_wait, &wq, TASK_INTERRUPTIBLE); |
| 7892 | if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery) && | 7889 | if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery) && |
| 7893 | mddev2->curr_resync >= mddev->curr_resync) { | 7890 | mddev2->curr_resync >= mddev->curr_resync) { |
| 7894 | printk(KERN_INFO "md: delaying %s of %s" | 7891 | if (mddev2_minor != mddev2->md_minor) { |
| 7895 | " until %s has finished (they" | 7892 | mddev2_minor = mddev2->md_minor; |
| 7896 | " share one or more physical units)\n", | 7893 | printk(KERN_INFO "md: delaying %s of %s" |
| 7897 | desc, mdname(mddev), mdname(mddev2)); | 7894 | " until %s has finished (they" |
| 7895 | " share one or more physical units)\n", | ||
| 7896 | desc, mdname(mddev), | ||
| 7897 | mdname(mddev2)); | ||
| 7898 | } | ||
| 7898 | mddev_put(mddev2); | 7899 | mddev_put(mddev2); |
| 7899 | if (signal_pending(current)) | 7900 | if (signal_pending(current)) |
| 7900 | flush_signals(current); | 7901 | flush_signals(current); |
| @@ -8275,16 +8276,13 @@ no_add: | |||
| 8275 | static void md_start_sync(struct work_struct *ws) | 8276 | static void md_start_sync(struct work_struct *ws) |
| 8276 | { | 8277 | { |
| 8277 | struct mddev *mddev = container_of(ws, struct mddev, del_work); | 8278 | struct mddev *mddev = container_of(ws, struct mddev, del_work); |
| 8278 | int ret = 0; | ||
| 8279 | 8279 | ||
| 8280 | mddev->sync_thread = md_register_thread(md_do_sync, | 8280 | mddev->sync_thread = md_register_thread(md_do_sync, |
| 8281 | mddev, | 8281 | mddev, |
| 8282 | "resync"); | 8282 | "resync"); |
| 8283 | if (!mddev->sync_thread) { | 8283 | if (!mddev->sync_thread) { |
| 8284 | if (!(mddev_is_clustered(mddev) && ret == -EAGAIN)) | 8284 | printk(KERN_ERR "%s: could not start resync thread...\n", |
| 8285 | printk(KERN_ERR "%s: could not start resync" | 8285 | mdname(mddev)); |
| 8286 | " thread...\n", | ||
| 8287 | mdname(mddev)); | ||
| 8288 | /* leave the spares where they are, it shouldn't hurt */ | 8286 | /* leave the spares where they are, it shouldn't hurt */ |
| 8289 | clear_bit(MD_RECOVERY_SYNC, &mddev->recovery); | 8287 | clear_bit(MD_RECOVERY_SYNC, &mddev->recovery); |
| 8290 | clear_bit(MD_RECOVERY_RESHAPE, &mddev->recovery); | 8288 | clear_bit(MD_RECOVERY_RESHAPE, &mddev->recovery); |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 0e4efcd10795..be1a9fca3b2d 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
| @@ -1064,6 +1064,8 @@ static void __make_request(struct mddev *mddev, struct bio *bio) | |||
| 1064 | int max_sectors; | 1064 | int max_sectors; |
| 1065 | int sectors; | 1065 | int sectors; |
| 1066 | 1066 | ||
| 1067 | md_write_start(mddev, bio); | ||
| 1068 | |||
| 1067 | /* | 1069 | /* |
| 1068 | * Register the new request and wait if the reconstruction | 1070 | * Register the new request and wait if the reconstruction |
| 1069 | * thread has put up a bar for new requests. | 1071 | * thread has put up a bar for new requests. |
| @@ -1445,8 +1447,6 @@ static void raid10_make_request(struct mddev *mddev, struct bio *bio) | |||
| 1445 | return; | 1447 | return; |
| 1446 | } | 1448 | } |
| 1447 | 1449 | ||
| 1448 | md_write_start(mddev, bio); | ||
| 1449 | |||
| 1450 | do { | 1450 | do { |
| 1451 | 1451 | ||
| 1452 | /* | 1452 | /* |
| @@ -2465,20 +2465,21 @@ static int narrow_write_error(struct r10bio *r10_bio, int i) | |||
| 2465 | 2465 | ||
| 2466 | while (sect_to_write) { | 2466 | while (sect_to_write) { |
| 2467 | struct bio *wbio; | 2467 | struct bio *wbio; |
| 2468 | sector_t wsector; | ||
| 2468 | if (sectors > sect_to_write) | 2469 | if (sectors > sect_to_write) |
| 2469 | sectors = sect_to_write; | 2470 | sectors = sect_to_write; |
| 2470 | /* Write at 'sector' for 'sectors' */ | 2471 | /* Write at 'sector' for 'sectors' */ |
| 2471 | wbio = bio_clone_mddev(bio, GFP_NOIO, mddev); | 2472 | wbio = bio_clone_mddev(bio, GFP_NOIO, mddev); |
| 2472 | bio_trim(wbio, sector - bio->bi_iter.bi_sector, sectors); | 2473 | bio_trim(wbio, sector - bio->bi_iter.bi_sector, sectors); |
| 2473 | wbio->bi_iter.bi_sector = (r10_bio->devs[i].addr+ | 2474 | wsector = r10_bio->devs[i].addr + (sector - r10_bio->sector); |
| 2474 | choose_data_offset(r10_bio, rdev) + | 2475 | wbio->bi_iter.bi_sector = wsector + |
| 2475 | (sector - r10_bio->sector)); | 2476 | choose_data_offset(r10_bio, rdev); |
| 2476 | wbio->bi_bdev = rdev->bdev; | 2477 | wbio->bi_bdev = rdev->bdev; |
| 2477 | bio_set_op_attrs(wbio, REQ_OP_WRITE, 0); | 2478 | bio_set_op_attrs(wbio, REQ_OP_WRITE, 0); |
| 2478 | 2479 | ||
| 2479 | if (submit_bio_wait(wbio) < 0) | 2480 | if (submit_bio_wait(wbio) < 0) |
| 2480 | /* Failure! */ | 2481 | /* Failure! */ |
| 2481 | ok = rdev_set_badblocks(rdev, sector, | 2482 | ok = rdev_set_badblocks(rdev, wsector, |
| 2482 | sectors, 0) | 2483 | sectors, 0) |
| 2483 | && ok; | 2484 | && ok; |
| 2484 | 2485 | ||
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c index 51f76ddbe265..1b1ab4a1d132 100644 --- a/drivers/md/raid5-cache.c +++ b/drivers/md/raid5-cache.c | |||
| @@ -96,7 +96,6 @@ struct r5l_log { | |||
| 96 | spinlock_t no_space_stripes_lock; | 96 | spinlock_t no_space_stripes_lock; |
| 97 | 97 | ||
| 98 | bool need_cache_flush; | 98 | bool need_cache_flush; |
| 99 | bool in_teardown; | ||
| 100 | }; | 99 | }; |
| 101 | 100 | ||
| 102 | /* | 101 | /* |
| @@ -704,31 +703,22 @@ static void r5l_write_super_and_discard_space(struct r5l_log *log, | |||
| 704 | 703 | ||
| 705 | mddev = log->rdev->mddev; | 704 | mddev = log->rdev->mddev; |
| 706 | /* | 705 | /* |
| 707 | * This is to avoid a deadlock. r5l_quiesce holds reconfig_mutex and | 706 | * Discard could zero data, so before discard we must make sure |
| 708 | * wait for this thread to finish. This thread waits for | 707 | * superblock is updated to new log tail. Updating superblock (either |
| 709 | * MD_CHANGE_PENDING clear, which is supposed to be done in | 708 | * directly call md_update_sb() or depend on md thread) must hold |
| 710 | * md_check_recovery(). md_check_recovery() tries to get | 709 | * reconfig mutex. On the other hand, raid5_quiesce is called with |
| 711 | * reconfig_mutex. Since r5l_quiesce already holds the mutex, | 710 | * reconfig_mutex hold. The first step of raid5_quiesce() is waitting |
| 712 | * md_check_recovery() fails, so the PENDING never get cleared. The | 711 | * for all IO finish, hence waitting for reclaim thread, while reclaim |
| 713 | * in_teardown check workaround this issue. | 712 | * thread is calling this function and waitting for reconfig mutex. So |
| 713 | * there is a deadlock. We workaround this issue with a trylock. | ||
| 714 | * FIXME: we could miss discard if we can't take reconfig mutex | ||
| 714 | */ | 715 | */ |
| 715 | if (!log->in_teardown) { | 716 | set_mask_bits(&mddev->flags, 0, |
| 716 | set_mask_bits(&mddev->flags, 0, | 717 | BIT(MD_CHANGE_DEVS) | BIT(MD_CHANGE_PENDING)); |
| 717 | BIT(MD_CHANGE_DEVS) | BIT(MD_CHANGE_PENDING)); | 718 | if (!mddev_trylock(mddev)) |
| 718 | md_wakeup_thread(mddev->thread); | 719 | return; |
| 719 | wait_event(mddev->sb_wait, | 720 | md_update_sb(mddev, 1); |
| 720 | !test_bit(MD_CHANGE_PENDING, &mddev->flags) || | 721 | mddev_unlock(mddev); |
| 721 | log->in_teardown); | ||
| 722 | /* | ||
| 723 | * r5l_quiesce could run after in_teardown check and hold | ||
| 724 | * mutex first. Superblock might get updated twice. | ||
| 725 | */ | ||
| 726 | if (log->in_teardown) | ||
| 727 | md_update_sb(mddev, 1); | ||
| 728 | } else { | ||
| 729 | WARN_ON(!mddev_is_locked(mddev)); | ||
| 730 | md_update_sb(mddev, 1); | ||
| 731 | } | ||
| 732 | 722 | ||
| 733 | /* discard IO error really doesn't matter, ignore it */ | 723 | /* discard IO error really doesn't matter, ignore it */ |
| 734 | if (log->last_checkpoint < end) { | 724 | if (log->last_checkpoint < end) { |
| @@ -827,7 +817,6 @@ void r5l_quiesce(struct r5l_log *log, int state) | |||
| 827 | if (!log || state == 2) | 817 | if (!log || state == 2) |
| 828 | return; | 818 | return; |
| 829 | if (state == 0) { | 819 | if (state == 0) { |
| 830 | log->in_teardown = 0; | ||
| 831 | /* | 820 | /* |
| 832 | * This is a special case for hotadd. In suspend, the array has | 821 | * This is a special case for hotadd. In suspend, the array has |
| 833 | * no journal. In resume, journal is initialized as well as the | 822 | * no journal. In resume, journal is initialized as well as the |
| @@ -838,11 +827,6 @@ void r5l_quiesce(struct r5l_log *log, int state) | |||
| 838 | log->reclaim_thread = md_register_thread(r5l_reclaim_thread, | 827 | log->reclaim_thread = md_register_thread(r5l_reclaim_thread, |
| 839 | log->rdev->mddev, "reclaim"); | 828 | log->rdev->mddev, "reclaim"); |
| 840 | } else if (state == 1) { | 829 | } else if (state == 1) { |
| 841 | /* | ||
| 842 | * at this point all stripes are finished, so io_unit is at | ||
| 843 | * least in STRIPE_END state | ||
| 844 | */ | ||
| 845 | log->in_teardown = 1; | ||
| 846 | /* make sure r5l_write_super_and_discard_space exits */ | 830 | /* make sure r5l_write_super_and_discard_space exits */ |
| 847 | mddev = log->rdev->mddev; | 831 | mddev = log->rdev->mddev; |
| 848 | wake_up(&mddev->sb_wait); | 832 | wake_up(&mddev->sb_wait); |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 8912407a4dd0..ee7fc3701700 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
| @@ -659,6 +659,7 @@ raid5_get_active_stripe(struct r5conf *conf, sector_t sector, | |||
| 659 | { | 659 | { |
| 660 | struct stripe_head *sh; | 660 | struct stripe_head *sh; |
| 661 | int hash = stripe_hash_locks_hash(sector); | 661 | int hash = stripe_hash_locks_hash(sector); |
| 662 | int inc_empty_inactive_list_flag; | ||
| 662 | 663 | ||
| 663 | pr_debug("get_stripe, sector %llu\n", (unsigned long long)sector); | 664 | pr_debug("get_stripe, sector %llu\n", (unsigned long long)sector); |
| 664 | 665 | ||
| @@ -703,7 +704,12 @@ raid5_get_active_stripe(struct r5conf *conf, sector_t sector, | |||
| 703 | atomic_inc(&conf->active_stripes); | 704 | atomic_inc(&conf->active_stripes); |
| 704 | BUG_ON(list_empty(&sh->lru) && | 705 | BUG_ON(list_empty(&sh->lru) && |
| 705 | !test_bit(STRIPE_EXPANDING, &sh->state)); | 706 | !test_bit(STRIPE_EXPANDING, &sh->state)); |
| 707 | inc_empty_inactive_list_flag = 0; | ||
| 708 | if (!list_empty(conf->inactive_list + hash)) | ||
| 709 | inc_empty_inactive_list_flag = 1; | ||
| 706 | list_del_init(&sh->lru); | 710 | list_del_init(&sh->lru); |
| 711 | if (list_empty(conf->inactive_list + hash) && inc_empty_inactive_list_flag) | ||
| 712 | atomic_inc(&conf->empty_inactive_list_nr); | ||
| 707 | if (sh->group) { | 713 | if (sh->group) { |
| 708 | sh->group->stripes_cnt--; | 714 | sh->group->stripes_cnt--; |
| 709 | sh->group = NULL; | 715 | sh->group = NULL; |
| @@ -762,6 +768,7 @@ static void stripe_add_to_batch_list(struct r5conf *conf, struct stripe_head *sh | |||
| 762 | sector_t head_sector, tmp_sec; | 768 | sector_t head_sector, tmp_sec; |
| 763 | int hash; | 769 | int hash; |
| 764 | int dd_idx; | 770 | int dd_idx; |
| 771 | int inc_empty_inactive_list_flag; | ||
| 765 | 772 | ||
| 766 | /* Don't cross chunks, so stripe pd_idx/qd_idx is the same */ | 773 | /* Don't cross chunks, so stripe pd_idx/qd_idx is the same */ |
| 767 | tmp_sec = sh->sector; | 774 | tmp_sec = sh->sector; |
| @@ -779,7 +786,12 @@ static void stripe_add_to_batch_list(struct r5conf *conf, struct stripe_head *sh | |||
| 779 | atomic_inc(&conf->active_stripes); | 786 | atomic_inc(&conf->active_stripes); |
| 780 | BUG_ON(list_empty(&head->lru) && | 787 | BUG_ON(list_empty(&head->lru) && |
| 781 | !test_bit(STRIPE_EXPANDING, &head->state)); | 788 | !test_bit(STRIPE_EXPANDING, &head->state)); |
| 789 | inc_empty_inactive_list_flag = 0; | ||
| 790 | if (!list_empty(conf->inactive_list + hash)) | ||
| 791 | inc_empty_inactive_list_flag = 1; | ||
| 782 | list_del_init(&head->lru); | 792 | list_del_init(&head->lru); |
| 793 | if (list_empty(conf->inactive_list + hash) && inc_empty_inactive_list_flag) | ||
| 794 | atomic_inc(&conf->empty_inactive_list_nr); | ||
| 783 | if (head->group) { | 795 | if (head->group) { |
| 784 | head->group->stripes_cnt--; | 796 | head->group->stripes_cnt--; |
| 785 | head->group = NULL; | 797 | head->group = NULL; |
| @@ -993,7 +1005,6 @@ again: | |||
| 993 | 1005 | ||
| 994 | set_bit(STRIPE_IO_STARTED, &sh->state); | 1006 | set_bit(STRIPE_IO_STARTED, &sh->state); |
| 995 | 1007 | ||
| 996 | bio_reset(bi); | ||
| 997 | bi->bi_bdev = rdev->bdev; | 1008 | bi->bi_bdev = rdev->bdev; |
| 998 | bio_set_op_attrs(bi, op, op_flags); | 1009 | bio_set_op_attrs(bi, op, op_flags); |
| 999 | bi->bi_end_io = op_is_write(op) | 1010 | bi->bi_end_io = op_is_write(op) |
| @@ -1045,7 +1056,6 @@ again: | |||
| 1045 | 1056 | ||
| 1046 | set_bit(STRIPE_IO_STARTED, &sh->state); | 1057 | set_bit(STRIPE_IO_STARTED, &sh->state); |
| 1047 | 1058 | ||
| 1048 | bio_reset(rbi); | ||
| 1049 | rbi->bi_bdev = rrdev->bdev; | 1059 | rbi->bi_bdev = rrdev->bdev; |
| 1050 | bio_set_op_attrs(rbi, op, op_flags); | 1060 | bio_set_op_attrs(rbi, op, op_flags); |
| 1051 | BUG_ON(!op_is_write(op)); | 1061 | BUG_ON(!op_is_write(op)); |
| @@ -1978,9 +1988,11 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request) | |||
| 1978 | put_cpu(); | 1988 | put_cpu(); |
| 1979 | } | 1989 | } |
| 1980 | 1990 | ||
| 1981 | static struct stripe_head *alloc_stripe(struct kmem_cache *sc, gfp_t gfp) | 1991 | static struct stripe_head *alloc_stripe(struct kmem_cache *sc, gfp_t gfp, |
| 1992 | int disks) | ||
| 1982 | { | 1993 | { |
| 1983 | struct stripe_head *sh; | 1994 | struct stripe_head *sh; |
| 1995 | int i; | ||
| 1984 | 1996 | ||
| 1985 | sh = kmem_cache_zalloc(sc, gfp); | 1997 | sh = kmem_cache_zalloc(sc, gfp); |
| 1986 | if (sh) { | 1998 | if (sh) { |
| @@ -1989,6 +2001,17 @@ static struct stripe_head *alloc_stripe(struct kmem_cache *sc, gfp_t gfp) | |||
| 1989 | INIT_LIST_HEAD(&sh->batch_list); | 2001 | INIT_LIST_HEAD(&sh->batch_list); |
| 1990 | INIT_LIST_HEAD(&sh->lru); | 2002 | INIT_LIST_HEAD(&sh->lru); |
| 1991 | atomic_set(&sh->count, 1); | 2003 | atomic_set(&sh->count, 1); |
| 2004 | for (i = 0; i < disks; i++) { | ||
| 2005 | struct r5dev *dev = &sh->dev[i]; | ||
| 2006 | |||
| 2007 | bio_init(&dev->req); | ||
| 2008 | dev->req.bi_io_vec = &dev->vec; | ||
| 2009 | dev->req.bi_max_vecs = 1; | ||
| 2010 | |||
| 2011 | bio_init(&dev->rreq); | ||
| 2012 | dev->rreq.bi_io_vec = &dev->rvec; | ||
| 2013 | dev->rreq.bi_max_vecs = 1; | ||
| 2014 | } | ||
| 1992 | } | 2015 | } |
| 1993 | return sh; | 2016 | return sh; |
| 1994 | } | 2017 | } |
| @@ -1996,7 +2019,7 @@ static int grow_one_stripe(struct r5conf *conf, gfp_t gfp) | |||
| 1996 | { | 2019 | { |
| 1997 | struct stripe_head *sh; | 2020 | struct stripe_head *sh; |
| 1998 | 2021 | ||
| 1999 | sh = alloc_stripe(conf->slab_cache, gfp); | 2022 | sh = alloc_stripe(conf->slab_cache, gfp, conf->pool_size); |
| 2000 | if (!sh) | 2023 | if (!sh) |
| 2001 | return 0; | 2024 | return 0; |
| 2002 | 2025 | ||
| @@ -2167,7 +2190,7 @@ static int resize_stripes(struct r5conf *conf, int newsize) | |||
| 2167 | mutex_lock(&conf->cache_size_mutex); | 2190 | mutex_lock(&conf->cache_size_mutex); |
| 2168 | 2191 | ||
| 2169 | for (i = conf->max_nr_stripes; i; i--) { | 2192 | for (i = conf->max_nr_stripes; i; i--) { |
| 2170 | nsh = alloc_stripe(sc, GFP_KERNEL); | 2193 | nsh = alloc_stripe(sc, GFP_KERNEL, newsize); |
| 2171 | if (!nsh) | 2194 | if (!nsh) |
| 2172 | break; | 2195 | break; |
| 2173 | 2196 | ||
| @@ -2299,6 +2322,7 @@ static void raid5_end_read_request(struct bio * bi) | |||
| 2299 | (unsigned long long)sh->sector, i, atomic_read(&sh->count), | 2322 | (unsigned long long)sh->sector, i, atomic_read(&sh->count), |
| 2300 | bi->bi_error); | 2323 | bi->bi_error); |
| 2301 | if (i == disks) { | 2324 | if (i == disks) { |
| 2325 | bio_reset(bi); | ||
| 2302 | BUG(); | 2326 | BUG(); |
| 2303 | return; | 2327 | return; |
| 2304 | } | 2328 | } |
| @@ -2399,6 +2423,7 @@ static void raid5_end_read_request(struct bio * bi) | |||
| 2399 | } | 2423 | } |
| 2400 | } | 2424 | } |
| 2401 | rdev_dec_pending(rdev, conf->mddev); | 2425 | rdev_dec_pending(rdev, conf->mddev); |
| 2426 | bio_reset(bi); | ||
| 2402 | clear_bit(R5_LOCKED, &sh->dev[i].flags); | 2427 | clear_bit(R5_LOCKED, &sh->dev[i].flags); |
| 2403 | set_bit(STRIPE_HANDLE, &sh->state); | 2428 | set_bit(STRIPE_HANDLE, &sh->state); |
| 2404 | raid5_release_stripe(sh); | 2429 | raid5_release_stripe(sh); |
| @@ -2436,6 +2461,7 @@ static void raid5_end_write_request(struct bio *bi) | |||
| 2436 | (unsigned long long)sh->sector, i, atomic_read(&sh->count), | 2461 | (unsigned long long)sh->sector, i, atomic_read(&sh->count), |
| 2437 | bi->bi_error); | 2462 | bi->bi_error); |
| 2438 | if (i == disks) { | 2463 | if (i == disks) { |
| 2464 | bio_reset(bi); | ||
| 2439 | BUG(); | 2465 | BUG(); |
| 2440 | return; | 2466 | return; |
| 2441 | } | 2467 | } |
| @@ -2472,6 +2498,7 @@ static void raid5_end_write_request(struct bio *bi) | |||
| 2472 | if (sh->batch_head && bi->bi_error && !replacement) | 2498 | if (sh->batch_head && bi->bi_error && !replacement) |
| 2473 | set_bit(STRIPE_BATCH_ERR, &sh->batch_head->state); | 2499 | set_bit(STRIPE_BATCH_ERR, &sh->batch_head->state); |
| 2474 | 2500 | ||
| 2501 | bio_reset(bi); | ||
| 2475 | if (!test_and_clear_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags)) | 2502 | if (!test_and_clear_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags)) |
| 2476 | clear_bit(R5_LOCKED, &sh->dev[i].flags); | 2503 | clear_bit(R5_LOCKED, &sh->dev[i].flags); |
| 2477 | set_bit(STRIPE_HANDLE, &sh->state); | 2504 | set_bit(STRIPE_HANDLE, &sh->state); |
| @@ -2485,16 +2512,6 @@ static void raid5_build_block(struct stripe_head *sh, int i, int previous) | |||
| 2485 | { | 2512 | { |
| 2486 | struct r5dev *dev = &sh->dev[i]; | 2513 | struct r5dev *dev = &sh->dev[i]; |
| 2487 | 2514 | ||
| 2488 | bio_init(&dev->req); | ||
| 2489 | dev->req.bi_io_vec = &dev->vec; | ||
| 2490 | dev->req.bi_max_vecs = 1; | ||
| 2491 | dev->req.bi_private = sh; | ||
| 2492 | |||
| 2493 | bio_init(&dev->rreq); | ||
| 2494 | dev->rreq.bi_io_vec = &dev->rvec; | ||
| 2495 | dev->rreq.bi_max_vecs = 1; | ||
| 2496 | dev->rreq.bi_private = sh; | ||
| 2497 | |||
| 2498 | dev->flags = 0; | 2515 | dev->flags = 0; |
| 2499 | dev->sector = raid5_compute_blocknr(sh, i, previous); | 2516 | dev->sector = raid5_compute_blocknr(sh, i, previous); |
| 2500 | } | 2517 | } |
| @@ -4628,7 +4645,9 @@ finish: | |||
| 4628 | } | 4645 | } |
| 4629 | 4646 | ||
| 4630 | if (!bio_list_empty(&s.return_bi)) { | 4647 | if (!bio_list_empty(&s.return_bi)) { |
| 4631 | if (test_bit(MD_CHANGE_PENDING, &conf->mddev->flags)) { | 4648 | if (test_bit(MD_CHANGE_PENDING, &conf->mddev->flags) && |
| 4649 | (s.failed <= conf->max_degraded || | ||
| 4650 | conf->mddev->external == 0)) { | ||
| 4632 | spin_lock_irq(&conf->device_lock); | 4651 | spin_lock_irq(&conf->device_lock); |
| 4633 | bio_list_merge(&conf->return_bi, &s.return_bi); | 4652 | bio_list_merge(&conf->return_bi, &s.return_bi); |
| 4634 | spin_unlock_irq(&conf->device_lock); | 4653 | spin_unlock_irq(&conf->device_lock); |
| @@ -6620,6 +6639,16 @@ static struct r5conf *setup_conf(struct mddev *mddev) | |||
| 6620 | } | 6639 | } |
| 6621 | 6640 | ||
| 6622 | conf->min_nr_stripes = NR_STRIPES; | 6641 | conf->min_nr_stripes = NR_STRIPES; |
| 6642 | if (mddev->reshape_position != MaxSector) { | ||
| 6643 | int stripes = max_t(int, | ||
| 6644 | ((mddev->chunk_sectors << 9) / STRIPE_SIZE) * 4, | ||
| 6645 | ((mddev->new_chunk_sectors << 9) / STRIPE_SIZE) * 4); | ||
| 6646 | conf->min_nr_stripes = max(NR_STRIPES, stripes); | ||
| 6647 | if (conf->min_nr_stripes != NR_STRIPES) | ||
| 6648 | printk(KERN_INFO | ||
| 6649 | "md/raid:%s: force stripe size %d for reshape\n", | ||
| 6650 | mdname(mddev), conf->min_nr_stripes); | ||
| 6651 | } | ||
| 6623 | memory = conf->min_nr_stripes * (sizeof(struct stripe_head) + | 6652 | memory = conf->min_nr_stripes * (sizeof(struct stripe_head) + |
| 6624 | max_disks * ((sizeof(struct bio) + PAGE_SIZE))) / 1024; | 6653 | max_disks * ((sizeof(struct bio) + PAGE_SIZE))) / 1024; |
| 6625 | atomic_set(&conf->empty_inactive_list_nr, NR_STRIPE_HASH_LOCKS); | 6654 | atomic_set(&conf->empty_inactive_list_nr, NR_STRIPE_HASH_LOCKS); |
| @@ -6826,11 +6855,14 @@ static int raid5_run(struct mddev *mddev) | |||
| 6826 | if (IS_ERR(conf)) | 6855 | if (IS_ERR(conf)) |
| 6827 | return PTR_ERR(conf); | 6856 | return PTR_ERR(conf); |
| 6828 | 6857 | ||
| 6829 | if (test_bit(MD_HAS_JOURNAL, &mddev->flags) && !journal_dev) { | 6858 | if (test_bit(MD_HAS_JOURNAL, &mddev->flags)) { |
| 6830 | printk(KERN_ERR "md/raid:%s: journal disk is missing, force array readonly\n", | 6859 | if (!journal_dev) { |
| 6831 | mdname(mddev)); | 6860 | pr_err("md/raid:%s: journal disk is missing, force array readonly\n", |
| 6832 | mddev->ro = 1; | 6861 | mdname(mddev)); |
| 6833 | set_disk_ro(mddev->gendisk, 1); | 6862 | mddev->ro = 1; |
| 6863 | set_disk_ro(mddev->gendisk, 1); | ||
| 6864 | } else if (mddev->recovery_cp == MaxSector) | ||
| 6865 | set_bit(MD_JOURNAL_CLEAN, &mddev->flags); | ||
| 6834 | } | 6866 | } |
| 6835 | 6867 | ||
| 6836 | conf->min_offset_diff = min_offset_diff; | 6868 | conf->min_offset_diff = min_offset_diff; |
diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c index 869c83fb3c5d..f00f3e742265 100644 --- a/drivers/memory/omap-gpmc.c +++ b/drivers/memory/omap-gpmc.c | |||
| @@ -2185,7 +2185,7 @@ static int gpmc_probe_dt(struct platform_device *pdev) | |||
| 2185 | return 0; | 2185 | return 0; |
| 2186 | } | 2186 | } |
| 2187 | 2187 | ||
| 2188 | static int gpmc_probe_dt_children(struct platform_device *pdev) | 2188 | static void gpmc_probe_dt_children(struct platform_device *pdev) |
| 2189 | { | 2189 | { |
| 2190 | int ret; | 2190 | int ret; |
| 2191 | struct device_node *child; | 2191 | struct device_node *child; |
| @@ -2200,11 +2200,11 @@ static int gpmc_probe_dt_children(struct platform_device *pdev) | |||
| 2200 | else | 2200 | else |
| 2201 | ret = gpmc_probe_generic_child(pdev, child); | 2201 | ret = gpmc_probe_generic_child(pdev, child); |
| 2202 | 2202 | ||
| 2203 | if (ret) | 2203 | if (ret) { |
| 2204 | return ret; | 2204 | dev_err(&pdev->dev, "failed to probe DT child '%s': %d\n", |
| 2205 | child->name, ret); | ||
| 2206 | } | ||
| 2205 | } | 2207 | } |
| 2206 | |||
| 2207 | return 0; | ||
| 2208 | } | 2208 | } |
| 2209 | #else | 2209 | #else |
| 2210 | static int gpmc_probe_dt(struct platform_device *pdev) | 2210 | static int gpmc_probe_dt(struct platform_device *pdev) |
| @@ -2212,9 +2212,8 @@ static int gpmc_probe_dt(struct platform_device *pdev) | |||
| 2212 | return 0; | 2212 | return 0; |
| 2213 | } | 2213 | } |
| 2214 | 2214 | ||
| 2215 | static int gpmc_probe_dt_children(struct platform_device *pdev) | 2215 | static void gpmc_probe_dt_children(struct platform_device *pdev) |
| 2216 | { | 2216 | { |
| 2217 | return 0; | ||
| 2218 | } | 2217 | } |
| 2219 | #endif /* CONFIG_OF */ | 2218 | #endif /* CONFIG_OF */ |
| 2220 | 2219 | ||
| @@ -2369,16 +2368,10 @@ static int gpmc_probe(struct platform_device *pdev) | |||
| 2369 | goto setup_irq_failed; | 2368 | goto setup_irq_failed; |
| 2370 | } | 2369 | } |
| 2371 | 2370 | ||
| 2372 | rc = gpmc_probe_dt_children(pdev); | 2371 | gpmc_probe_dt_children(pdev); |
| 2373 | if (rc < 0) { | ||
| 2374 | dev_err(gpmc->dev, "failed to probe DT children\n"); | ||
| 2375 | goto dt_children_failed; | ||
| 2376 | } | ||
| 2377 | 2372 | ||
| 2378 | return 0; | 2373 | return 0; |
| 2379 | 2374 | ||
| 2380 | dt_children_failed: | ||
| 2381 | gpmc_free_irq(gpmc); | ||
| 2382 | setup_irq_failed: | 2375 | setup_irq_failed: |
| 2383 | gpmc_gpio_exit(gpmc); | 2376 | gpmc_gpio_exit(gpmc); |
| 2384 | gpio_init_failed: | 2377 | gpio_init_failed: |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index a216b4667742..d00252828966 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
| @@ -345,16 +345,6 @@ config SENSORS_TSL2550 | |||
| 345 | This driver can also be built as a module. If so, the module | 345 | This driver can also be built as a module. If so, the module |
| 346 | will be called tsl2550. | 346 | will be called tsl2550. |
| 347 | 347 | ||
| 348 | config SENSORS_BH1780 | ||
| 349 | tristate "ROHM BH1780GLI ambient light sensor" | ||
| 350 | depends on I2C && SYSFS | ||
| 351 | help | ||
| 352 | If you say yes here you get support for the ROHM BH1780GLI | ||
| 353 | ambient light sensor. | ||
| 354 | |||
| 355 | This driver can also be built as a module. If so, the module | ||
| 356 | will be called bh1780gli. | ||
| 357 | |||
| 358 | config SENSORS_BH1770 | 348 | config SENSORS_BH1770 |
| 359 | tristate "BH1770GLC / SFH7770 combined ALS - Proximity sensor" | 349 | tristate "BH1770GLC / SFH7770 combined ALS - Proximity sensor" |
| 360 | depends on I2C | 350 | depends on I2C |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 7410c6d9a34d..fb32516ddfe2 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
| @@ -19,7 +19,6 @@ obj-$(CONFIG_TIFM_CORE) += tifm_core.o | |||
| 19 | obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o | 19 | obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o |
| 20 | obj-$(CONFIG_PHANTOM) += phantom.o | 20 | obj-$(CONFIG_PHANTOM) += phantom.o |
| 21 | obj-$(CONFIG_QCOM_COINCELL) += qcom-coincell.o | 21 | obj-$(CONFIG_QCOM_COINCELL) += qcom-coincell.o |
| 22 | obj-$(CONFIG_SENSORS_BH1780) += bh1780gli.o | ||
| 23 | obj-$(CONFIG_SENSORS_BH1770) += bh1770glc.o | 22 | obj-$(CONFIG_SENSORS_BH1770) += bh1770glc.o |
| 24 | obj-$(CONFIG_SENSORS_APDS990X) += apds990x.o | 23 | obj-$(CONFIG_SENSORS_APDS990X) += apds990x.o |
| 25 | obj-$(CONFIG_SGI_IOC4) += ioc4.o | 24 | obj-$(CONFIG_SGI_IOC4) += ioc4.o |
diff --git a/drivers/misc/bh1780gli.c b/drivers/misc/bh1780gli.c deleted file mode 100644 index 7f90ce5a569a..000000000000 --- a/drivers/misc/bh1780gli.c +++ /dev/null | |||
| @@ -1,259 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * bh1780gli.c | ||
| 3 | * ROHM Ambient Light Sensor Driver | ||
| 4 | * | ||
| 5 | * Copyright (C) 2010 Texas Instruments | ||
| 6 | * Author: Hemanth V <hemanthv@ti.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify it | ||
| 9 | * under the terms of the GNU General Public License version 2 as published by | ||
| 10 | * the Free Software Foundation. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 15 | * more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License along with | ||
| 18 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | */ | ||
| 20 | #include <linux/i2c.h> | ||
| 21 | #include <linux/slab.h> | ||
| 22 | #include <linux/mutex.h> | ||
| 23 | #include <linux/platform_device.h> | ||
| 24 | #include <linux/delay.h> | ||
| 25 | #include <linux/module.h> | ||
| 26 | #include <linux/of.h> | ||
| 27 | |||
| 28 | #define BH1780_REG_CONTROL 0x80 | ||
| 29 | #define BH1780_REG_PARTID 0x8A | ||
| 30 | #define BH1780_REG_MANFID 0x8B | ||
| 31 | #define BH1780_REG_DLOW 0x8C | ||
| 32 | #define BH1780_REG_DHIGH 0x8D | ||
| 33 | |||
| 34 | #define BH1780_REVMASK (0xf) | ||
| 35 | #define BH1780_POWMASK (0x3) | ||
| 36 | #define BH1780_POFF (0x0) | ||
| 37 | #define BH1780_PON (0x3) | ||
| 38 | |||
| 39 | /* power on settling time in ms */ | ||
| 40 | #define BH1780_PON_DELAY 2 | ||
| 41 | |||
| 42 | struct bh1780_data { | ||
| 43 | struct i2c_client *client; | ||
| 44 | int power_state; | ||
| 45 | /* lock for sysfs operations */ | ||
| 46 | struct mutex lock; | ||
| 47 | }; | ||
| 48 | |||
| 49 | static int bh1780_write(struct bh1780_data *ddata, u8 reg, u8 val, char *msg) | ||
| 50 | { | ||
| 51 | int ret = i2c_smbus_write_byte_data(ddata->client, reg, val); | ||
| 52 | if (ret < 0) | ||
| 53 | dev_err(&ddata->client->dev, | ||
| 54 | "i2c_smbus_write_byte_data failed error %d Register (%s)\n", | ||
| 55 | ret, msg); | ||
| 56 | return ret; | ||
| 57 | } | ||
| 58 | |||
| 59 | static int bh1780_read(struct bh1780_data *ddata, u8 reg, char *msg) | ||
| 60 | { | ||
| 61 | int ret = i2c_smbus_read_byte_data(ddata->client, reg); | ||
| 62 | if (ret < 0) | ||
| 63 | dev_err(&ddata->client->dev, | ||
| 64 | "i2c_smbus_read_byte_data failed error %d Register (%s)\n", | ||
| 65 | ret, msg); | ||
| 66 | return ret; | ||
| 67 | } | ||
| 68 | |||
| 69 | static ssize_t bh1780_show_lux(struct device *dev, | ||
| 70 | struct device_attribute *attr, char *buf) | ||
| 71 | { | ||
| 72 | struct platform_device *pdev = to_platform_device(dev); | ||
| 73 | struct bh1780_data *ddata = platform_get_drvdata(pdev); | ||
| 74 | int lsb, msb; | ||
| 75 | |||
| 76 | lsb = bh1780_read(ddata, BH1780_REG_DLOW, "DLOW"); | ||
| 77 | if (lsb < 0) | ||
| 78 | return lsb; | ||
| 79 | |||
| 80 | msb = bh1780_read(ddata, BH1780_REG_DHIGH, "DHIGH"); | ||
| 81 | if (msb < 0) | ||
| 82 | return msb; | ||
| 83 | |||
| 84 | return sprintf(buf, "%d\n", (msb << 8) | lsb); | ||
| 85 | } | ||
| 86 | |||
| 87 | static ssize_t bh1780_show_power_state(struct device *dev, | ||
| 88 | struct device_attribute *attr, | ||
| 89 | char *buf) | ||
| 90 | { | ||
| 91 | struct platform_device *pdev = to_platform_device(dev); | ||
| 92 | struct bh1780_data *ddata = platform_get_drvdata(pdev); | ||
| 93 | int state; | ||
| 94 | |||
| 95 | state = bh1780_read(ddata, BH1780_REG_CONTROL, "CONTROL"); | ||
| 96 | if (state < 0) | ||
| 97 | return state; | ||
| 98 | |||
| 99 | return sprintf(buf, "%d\n", state & BH1780_POWMASK); | ||
| 100 | } | ||
| 101 | |||
| 102 | static ssize_t bh1780_store_power_state(struct device *dev, | ||
| 103 | struct device_attribute *attr, | ||
| 104 | const char *buf, size_t count) | ||
| 105 | { | ||
| 106 | struct platform_device *pdev = to_platform_device(dev); | ||
| 107 | struct bh1780_data *ddata = platform_get_drvdata(pdev); | ||
| 108 | unsigned long val; | ||
| 109 | int error; | ||
| 110 | |||
| 111 | error = kstrtoul(buf, 0, &val); | ||
| 112 | if (error) | ||
| 113 | return error; | ||
| 114 | |||
| 115 | if (val < BH1780_POFF || val > BH1780_PON) | ||
| 116 | return -EINVAL; | ||
| 117 | |||
| 118 | mutex_lock(&ddata->lock); | ||
| 119 | |||
| 120 | error = bh1780_write(ddata, BH1780_REG_CONTROL, val, "CONTROL"); | ||
| 121 | if (error < 0) { | ||
| 122 | mutex_unlock(&ddata->lock); | ||
| 123 | return error; | ||
| 124 | } | ||
| 125 | |||
| 126 | msleep(BH1780_PON_DELAY); | ||
| 127 | ddata->power_state = val; | ||
| 128 | mutex_unlock(&ddata->lock); | ||
| 129 | |||
| 130 | return count; | ||
| 131 | } | ||
| 132 | |||
| 133 | static DEVICE_ATTR(lux, S_IRUGO, bh1780_show_lux, NULL); | ||
| 134 | |||
| 135 | static DEVICE_ATTR(power_state, S_IWUSR | S_IRUGO, | ||
| 136 | bh1780_show_power_state, bh1780_store_power_state); | ||
| 137 | |||
| 138 | static struct attribute *bh1780_attributes[] = { | ||
| 139 | &dev_attr_power_state.attr, | ||
| 140 | &dev_attr_lux.attr, | ||
| 141 | NULL | ||
| 142 | }; | ||
| 143 | |||
| 144 | static const struct attribute_group bh1780_attr_group = { | ||
| 145 | .attrs = bh1780_attributes, | ||
| 146 | }; | ||
| 147 | |||
| 148 | static int bh1780_probe(struct i2c_client *client, | ||
| 149 | const struct i2c_device_id *id) | ||
| 150 | { | ||
| 151 | int ret; | ||
| 152 | struct bh1780_data *ddata; | ||
| 153 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | ||
| 154 | |||
| 155 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) | ||
| 156 | return -EIO; | ||
| 157 | |||
| 158 | ddata = devm_kzalloc(&client->dev, sizeof(struct bh1780_data), | ||
| 159 | GFP_KERNEL); | ||
| 160 | if (ddata == NULL) | ||
| 161 | return -ENOMEM; | ||
| 162 | |||
| 163 | ddata->client = client; | ||
| 164 | i2c_set_clientdata(client, ddata); | ||
| 165 | |||
| 166 | ret = bh1780_read(ddata, BH1780_REG_PARTID, "PART ID"); | ||
| 167 | if (ret < 0) | ||
| 168 | return ret; | ||
| 169 | |||
| 170 | dev_info(&client->dev, "Ambient Light Sensor, Rev : %d\n", | ||
| 171 | (ret & BH1780_REVMASK)); | ||
| 172 | |||
| 173 | mutex_init(&ddata->lock); | ||
| 174 | |||
| 175 | return sysfs_create_group(&client->dev.kobj, &bh1780_attr_group); | ||
| 176 | } | ||
| 177 | |||
| 178 | static int bh1780_remove(struct i2c_client *client) | ||
| 179 | { | ||
| 180 | sysfs_remove_group(&client->dev.kobj, &bh1780_attr_group); | ||
| 181 | |||
| 182 | return 0; | ||
| 183 | } | ||
| 184 | |||
| 185 | #ifdef CONFIG_PM_SLEEP | ||
| 186 | static int bh1780_suspend(struct device *dev) | ||
| 187 | { | ||
| 188 | struct bh1780_data *ddata; | ||
| 189 | int state, ret; | ||
| 190 | struct i2c_client *client = to_i2c_client(dev); | ||
| 191 | |||
| 192 | ddata = i2c_get_clientdata(client); | ||
| 193 | state = bh1780_read(ddata, BH1780_REG_CONTROL, "CONTROL"); | ||
| 194 | if (state < 0) | ||
| 195 | return state; | ||
| 196 | |||
| 197 | ddata->power_state = state & BH1780_POWMASK; | ||
| 198 | |||
| 199 | ret = bh1780_write(ddata, BH1780_REG_CONTROL, BH1780_POFF, | ||
| 200 | "CONTROL"); | ||
| 201 | |||
| 202 | if (ret < 0) | ||
| 203 | return ret; | ||
| 204 | |||
| 205 | return 0; | ||
| 206 | } | ||
| 207 | |||
| 208 | static int bh1780_resume(struct device *dev) | ||
| 209 | { | ||
| 210 | struct bh1780_data *ddata; | ||
| 211 | int state, ret; | ||
| 212 | struct i2c_client *client = to_i2c_client(dev); | ||
| 213 | |||
| 214 | ddata = i2c_get_clientdata(client); | ||
| 215 | state = ddata->power_state; | ||
| 216 | ret = bh1780_write(ddata, BH1780_REG_CONTROL, state, | ||
| 217 | "CONTROL"); | ||
| 218 | |||
| 219 | if (ret < 0) | ||
| 220 | return ret; | ||
| 221 | |||
| 222 | return 0; | ||
| 223 | } | ||
| 224 | #endif /* CONFIG_PM_SLEEP */ | ||
| 225 | |||
| 226 | static SIMPLE_DEV_PM_OPS(bh1780_pm, bh1780_suspend, bh1780_resume); | ||
| 227 | |||
| 228 | static const struct i2c_device_id bh1780_id[] = { | ||
| 229 | { "bh1780", 0 }, | ||
| 230 | { }, | ||
| 231 | }; | ||
| 232 | |||
| 233 | MODULE_DEVICE_TABLE(i2c, bh1780_id); | ||
| 234 | |||
| 235 | #ifdef CONFIG_OF | ||
| 236 | static const struct of_device_id of_bh1780_match[] = { | ||
| 237 | { .compatible = "rohm,bh1780gli", }, | ||
| 238 | {}, | ||
| 239 | }; | ||
| 240 | |||
| 241 | MODULE_DEVICE_TABLE(of, of_bh1780_match); | ||
| 242 | #endif | ||
| 243 | |||
| 244 | static struct i2c_driver bh1780_driver = { | ||
| 245 | .probe = bh1780_probe, | ||
| 246 | .remove = bh1780_remove, | ||
| 247 | .id_table = bh1780_id, | ||
| 248 | .driver = { | ||
| 249 | .name = "bh1780", | ||
| 250 | .pm = &bh1780_pm, | ||
| 251 | .of_match_table = of_match_ptr(of_bh1780_match), | ||
| 252 | }, | ||
| 253 | }; | ||
| 254 | |||
| 255 | module_i2c_driver(bh1780_driver); | ||
| 256 | |||
| 257 | MODULE_DESCRIPTION("BH1780GLI Ambient Light Sensor Driver"); | ||
| 258 | MODULE_LICENSE("GPL"); | ||
| 259 | MODULE_AUTHOR("Hemanth V <hemanthv@ti.com>"); | ||
diff --git a/drivers/misc/lkdtm_rodata.c b/drivers/misc/lkdtm_rodata.c index 166b1db3969f..3564477b8c2d 100644 --- a/drivers/misc/lkdtm_rodata.c +++ b/drivers/misc/lkdtm_rodata.c | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | */ | 4 | */ |
| 5 | #include "lkdtm.h" | 5 | #include "lkdtm.h" |
| 6 | 6 | ||
| 7 | void lkdtm_rodata_do_nothing(void) | 7 | void notrace lkdtm_rodata_do_nothing(void) |
| 8 | { | 8 | { |
| 9 | /* Does nothing. We just want an architecture agnostic "return". */ | 9 | /* Does nothing. We just want an architecture agnostic "return". */ |
| 10 | } | 10 | } |
diff --git a/drivers/misc/lkdtm_usercopy.c b/drivers/misc/lkdtm_usercopy.c index 5525a204db93..1dd611423d8b 100644 --- a/drivers/misc/lkdtm_usercopy.c +++ b/drivers/misc/lkdtm_usercopy.c | |||
| @@ -9,7 +9,15 @@ | |||
| 9 | #include <linux/uaccess.h> | 9 | #include <linux/uaccess.h> |
| 10 | #include <asm/cacheflush.h> | 10 | #include <asm/cacheflush.h> |
| 11 | 11 | ||
| 12 | static size_t cache_size = 1024; | 12 | /* |
| 13 | * Many of the tests here end up using const sizes, but those would | ||
| 14 | * normally be ignored by hardened usercopy, so force the compiler | ||
| 15 | * into choosing the non-const path to make sure we trigger the | ||
| 16 | * hardened usercopy checks by added "unconst" to all the const copies, | ||
| 17 | * and making sure "cache_size" isn't optimized into a const. | ||
| 18 | */ | ||
| 19 | static volatile size_t unconst = 0; | ||
| 20 | static volatile size_t cache_size = 1024; | ||
| 13 | static struct kmem_cache *bad_cache; | 21 | static struct kmem_cache *bad_cache; |
| 14 | 22 | ||
| 15 | static const unsigned char test_text[] = "This is a test.\n"; | 23 | static const unsigned char test_text[] = "This is a test.\n"; |
| @@ -67,14 +75,14 @@ static noinline void do_usercopy_stack(bool to_user, bool bad_frame) | |||
| 67 | if (to_user) { | 75 | if (to_user) { |
| 68 | pr_info("attempting good copy_to_user of local stack\n"); | 76 | pr_info("attempting good copy_to_user of local stack\n"); |
| 69 | if (copy_to_user((void __user *)user_addr, good_stack, | 77 | if (copy_to_user((void __user *)user_addr, good_stack, |
| 70 | sizeof(good_stack))) { | 78 | unconst + sizeof(good_stack))) { |
| 71 | pr_warn("copy_to_user failed unexpectedly?!\n"); | 79 | pr_warn("copy_to_user failed unexpectedly?!\n"); |
| 72 | goto free_user; | 80 | goto free_user; |
| 73 | } | 81 | } |
| 74 | 82 | ||
| 75 | pr_info("attempting bad copy_to_user of distant stack\n"); | 83 | pr_info("attempting bad copy_to_user of distant stack\n"); |
| 76 | if (copy_to_user((void __user *)user_addr, bad_stack, | 84 | if (copy_to_user((void __user *)user_addr, bad_stack, |
| 77 | sizeof(good_stack))) { | 85 | unconst + sizeof(good_stack))) { |
| 78 | pr_warn("copy_to_user failed, but lacked Oops\n"); | 86 | pr_warn("copy_to_user failed, but lacked Oops\n"); |
| 79 | goto free_user; | 87 | goto free_user; |
| 80 | } | 88 | } |
| @@ -88,14 +96,14 @@ static noinline void do_usercopy_stack(bool to_user, bool bad_frame) | |||
| 88 | 96 | ||
| 89 | pr_info("attempting good copy_from_user of local stack\n"); | 97 | pr_info("attempting good copy_from_user of local stack\n"); |
| 90 | if (copy_from_user(good_stack, (void __user *)user_addr, | 98 | if (copy_from_user(good_stack, (void __user *)user_addr, |
| 91 | sizeof(good_stack))) { | 99 | unconst + sizeof(good_stack))) { |
| 92 | pr_warn("copy_from_user failed unexpectedly?!\n"); | 100 | pr_warn("copy_from_user failed unexpectedly?!\n"); |
| 93 | goto free_user; | 101 | goto free_user; |
| 94 | } | 102 | } |
| 95 | 103 | ||
| 96 | pr_info("attempting bad copy_from_user of distant stack\n"); | 104 | pr_info("attempting bad copy_from_user of distant stack\n"); |
| 97 | if (copy_from_user(bad_stack, (void __user *)user_addr, | 105 | if (copy_from_user(bad_stack, (void __user *)user_addr, |
| 98 | sizeof(good_stack))) { | 106 | unconst + sizeof(good_stack))) { |
| 99 | pr_warn("copy_from_user failed, but lacked Oops\n"); | 107 | pr_warn("copy_from_user failed, but lacked Oops\n"); |
| 100 | goto free_user; | 108 | goto free_user; |
| 101 | } | 109 | } |
| @@ -109,7 +117,7 @@ static void do_usercopy_heap_size(bool to_user) | |||
| 109 | { | 117 | { |
| 110 | unsigned long user_addr; | 118 | unsigned long user_addr; |
| 111 | unsigned char *one, *two; | 119 | unsigned char *one, *two; |
| 112 | const size_t size = 1024; | 120 | size_t size = unconst + 1024; |
| 113 | 121 | ||
| 114 | one = kmalloc(size, GFP_KERNEL); | 122 | one = kmalloc(size, GFP_KERNEL); |
| 115 | two = kmalloc(size, GFP_KERNEL); | 123 | two = kmalloc(size, GFP_KERNEL); |
| @@ -285,13 +293,14 @@ void lkdtm_USERCOPY_KERNEL(void) | |||
| 285 | 293 | ||
| 286 | pr_info("attempting good copy_to_user from kernel rodata\n"); | 294 | pr_info("attempting good copy_to_user from kernel rodata\n"); |
| 287 | if (copy_to_user((void __user *)user_addr, test_text, | 295 | if (copy_to_user((void __user *)user_addr, test_text, |
| 288 | sizeof(test_text))) { | 296 | unconst + sizeof(test_text))) { |
| 289 | pr_warn("copy_to_user failed unexpectedly?!\n"); | 297 | pr_warn("copy_to_user failed unexpectedly?!\n"); |
| 290 | goto free_user; | 298 | goto free_user; |
| 291 | } | 299 | } |
| 292 | 300 | ||
| 293 | pr_info("attempting bad copy_to_user from kernel text\n"); | 301 | pr_info("attempting bad copy_to_user from kernel text\n"); |
| 294 | if (copy_to_user((void __user *)user_addr, vm_mmap, PAGE_SIZE)) { | 302 | if (copy_to_user((void __user *)user_addr, vm_mmap, |
| 303 | unconst + PAGE_SIZE)) { | ||
| 295 | pr_warn("copy_to_user failed, but lacked Oops\n"); | 304 | pr_warn("copy_to_user failed, but lacked Oops\n"); |
| 296 | goto free_user; | 305 | goto free_user; |
| 297 | } | 306 | } |
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c index e2fb44cc5c37..dc3a854e02d3 100644 --- a/drivers/misc/mei/hw-me.c +++ b/drivers/misc/mei/hw-me.c | |||
| @@ -1263,8 +1263,14 @@ static bool mei_me_fw_type_nm(struct pci_dev *pdev) | |||
| 1263 | static bool mei_me_fw_type_sps(struct pci_dev *pdev) | 1263 | static bool mei_me_fw_type_sps(struct pci_dev *pdev) |
| 1264 | { | 1264 | { |
| 1265 | u32 reg; | 1265 | u32 reg; |
| 1266 | /* Read ME FW Status check for SPS Firmware */ | 1266 | unsigned int devfn; |
| 1267 | pci_read_config_dword(pdev, PCI_CFG_HFS_1, ®); | 1267 | |
| 1268 | /* | ||
| 1269 | * Read ME FW Status register to check for SPS Firmware | ||
| 1270 | * The SPS FW is only signaled in pci function 0 | ||
| 1271 | */ | ||
| 1272 | devfn = PCI_DEVFN(PCI_SLOT(pdev->devfn), 0); | ||
| 1273 | pci_bus_read_config_dword(pdev->bus, devfn, PCI_CFG_HFS_1, ®); | ||
| 1268 | trace_mei_pci_cfg_read(&pdev->dev, "PCI_CFG_HFS_1", PCI_CFG_HFS_1, reg); | 1274 | trace_mei_pci_cfg_read(&pdev->dev, "PCI_CFG_HFS_1", PCI_CFG_HFS_1, reg); |
| 1269 | /* if bits [19:16] = 15, running SPS Firmware */ | 1275 | /* if bits [19:16] = 15, running SPS Firmware */ |
| 1270 | return (reg & 0xf0000) == 0xf0000; | 1276 | return (reg & 0xf0000) == 0xf0000; |
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index 64e64da6da44..71cea9b296b2 100644 --- a/drivers/misc/mei/pci-me.c +++ b/drivers/misc/mei/pci-me.c | |||
| @@ -85,8 +85,8 @@ static const struct pci_device_id mei_me_pci_tbl[] = { | |||
| 85 | 85 | ||
| 86 | {MEI_PCI_DEVICE(MEI_DEV_ID_SPT, mei_me_pch8_cfg)}, | 86 | {MEI_PCI_DEVICE(MEI_DEV_ID_SPT, mei_me_pch8_cfg)}, |
| 87 | {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_2, mei_me_pch8_cfg)}, | 87 | {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_2, mei_me_pch8_cfg)}, |
| 88 | {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H, mei_me_pch8_cfg)}, | 88 | {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H, mei_me_pch8_sps_cfg)}, |
| 89 | {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H_2, mei_me_pch8_cfg)}, | 89 | {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H_2, mei_me_pch8_sps_cfg)}, |
| 90 | 90 | ||
| 91 | {MEI_PCI_DEVICE(MEI_DEV_ID_BXT_M, mei_me_pch8_cfg)}, | 91 | {MEI_PCI_DEVICE(MEI_DEV_ID_BXT_M, mei_me_pch8_cfg)}, |
| 92 | {MEI_PCI_DEVICE(MEI_DEV_ID_APL_I, mei_me_pch8_cfg)}, | 92 | {MEI_PCI_DEVICE(MEI_DEV_ID_APL_I, mei_me_pch8_cfg)}, |
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 48a5dd740f3b..2206d4477dbb 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
| @@ -1726,6 +1726,7 @@ static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct request *req) | |||
| 1726 | break; | 1726 | break; |
| 1727 | 1727 | ||
| 1728 | if (req_op(next) == REQ_OP_DISCARD || | 1728 | if (req_op(next) == REQ_OP_DISCARD || |
| 1729 | req_op(next) == REQ_OP_SECURE_ERASE || | ||
| 1729 | req_op(next) == REQ_OP_FLUSH) | 1730 | req_op(next) == REQ_OP_FLUSH) |
| 1730 | break; | 1731 | break; |
| 1731 | 1732 | ||
| @@ -2150,6 +2151,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
| 2150 | struct mmc_card *card = md->queue.card; | 2151 | struct mmc_card *card = md->queue.card; |
| 2151 | struct mmc_host *host = card->host; | 2152 | struct mmc_host *host = card->host; |
| 2152 | unsigned long flags; | 2153 | unsigned long flags; |
| 2154 | bool req_is_special = mmc_req_is_special(req); | ||
| 2153 | 2155 | ||
| 2154 | if (req && !mq->mqrq_prev->req) | 2156 | if (req && !mq->mqrq_prev->req) |
| 2155 | /* claim host only for the first request */ | 2157 | /* claim host only for the first request */ |
| @@ -2190,8 +2192,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
| 2190 | } | 2192 | } |
| 2191 | 2193 | ||
| 2192 | out: | 2194 | out: |
| 2193 | if ((!req && !(mq->flags & MMC_QUEUE_NEW_REQUEST)) || | 2195 | if ((!req && !(mq->flags & MMC_QUEUE_NEW_REQUEST)) || req_is_special) |
| 2194 | mmc_req_is_special(req)) | ||
| 2195 | /* | 2196 | /* |
| 2196 | * Release host when there are no more requests | 2197 | * Release host when there are no more requests |
| 2197 | * and after special request(discard, flush) is done. | 2198 | * and after special request(discard, flush) is done. |
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index bf14642a576a..708057261b38 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c | |||
| @@ -33,7 +33,8 @@ static int mmc_prep_request(struct request_queue *q, struct request *req) | |||
| 33 | /* | 33 | /* |
| 34 | * We only like normal block requests and discards. | 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 | blk_dump_rq_flags(req, "MMC bad request"); | 38 | blk_dump_rq_flags(req, "MMC bad request"); |
| 38 | return BLKPREP_KILL; | 39 | return BLKPREP_KILL; |
| 39 | } | 40 | } |
| @@ -64,6 +65,8 @@ static int mmc_queue_thread(void *d) | |||
| 64 | spin_unlock_irq(q->queue_lock); | 65 | spin_unlock_irq(q->queue_lock); |
| 65 | 66 | ||
| 66 | if (req || mq->mqrq_prev->req) { | 67 | if (req || mq->mqrq_prev->req) { |
| 68 | bool req_is_special = mmc_req_is_special(req); | ||
| 69 | |||
| 67 | set_current_state(TASK_RUNNING); | 70 | set_current_state(TASK_RUNNING); |
| 68 | mq->issue_fn(mq, req); | 71 | mq->issue_fn(mq, req); |
| 69 | cond_resched(); | 72 | cond_resched(); |
| @@ -79,7 +82,7 @@ static int mmc_queue_thread(void *d) | |||
| 79 | * has been finished. Do not assign it to previous | 82 | * has been finished. Do not assign it to previous |
| 80 | * request. | 83 | * request. |
| 81 | */ | 84 | */ |
| 82 | if (mmc_req_is_special(req)) | 85 | if (req_is_special) |
| 83 | mq->mqrq_cur->req = NULL; | 86 | mq->mqrq_cur->req = NULL; |
| 84 | 87 | ||
| 85 | mq->mqrq_prev->brq.mrq.data = NULL; | 88 | mq->mqrq_prev->brq.mrq.data = NULL; |
diff --git a/drivers/mmc/card/queue.h b/drivers/mmc/card/queue.h index d62531124d54..fee5e1271465 100644 --- a/drivers/mmc/card/queue.h +++ b/drivers/mmc/card/queue.h | |||
| @@ -4,7 +4,9 @@ | |||
| 4 | static inline bool mmc_req_is_special(struct request *req) | 4 | static inline bool mmc_req_is_special(struct request *req) |
| 5 | { | 5 | { |
| 6 | return req && | 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 | struct request; | 12 | struct request; |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 217e8da0628c..9599ed6f1213 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
| @@ -1341,9 +1341,10 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
| 1341 | slave_dev->name); | 1341 | slave_dev->name); |
| 1342 | } | 1342 | } |
| 1343 | 1343 | ||
| 1344 | /* already enslaved */ | 1344 | /* already in-use? */ |
| 1345 | if (slave_dev->flags & IFF_SLAVE) { | 1345 | if (netdev_is_rx_handler_busy(slave_dev)) { |
| 1346 | netdev_dbg(bond_dev, "Error: Device was already enslaved\n"); | 1346 | netdev_err(bond_dev, |
| 1347 | "Error: Device is in use and cannot be enslaved\n"); | ||
| 1347 | return -EBUSY; | 1348 | return -EBUSY; |
| 1348 | } | 1349 | } |
| 1349 | 1350 | ||
diff --git a/drivers/net/dsa/bcm_sf2.h b/drivers/net/dsa/bcm_sf2.h index 463bed8cbe4c..dd446e466699 100644 --- a/drivers/net/dsa/bcm_sf2.h +++ b/drivers/net/dsa/bcm_sf2.h | |||
| @@ -205,8 +205,8 @@ static inline void name##_writeq(struct bcm_sf2_priv *priv, u64 val, \ | |||
| 205 | static inline void intrl2_##which##_mask_clear(struct bcm_sf2_priv *priv, \ | 205 | static inline void intrl2_##which##_mask_clear(struct bcm_sf2_priv *priv, \ |
| 206 | u32 mask) \ | 206 | u32 mask) \ |
| 207 | { \ | 207 | { \ |
| 208 | intrl2_##which##_writel(priv, mask, INTRL2_CPU_MASK_CLEAR); \ | ||
| 209 | priv->irq##which##_mask &= ~(mask); \ | 208 | priv->irq##which##_mask &= ~(mask); \ |
| 209 | intrl2_##which##_writel(priv, mask, INTRL2_CPU_MASK_CLEAR); \ | ||
| 210 | } \ | 210 | } \ |
| 211 | static inline void intrl2_##which##_mask_set(struct bcm_sf2_priv *priv, \ | 211 | static inline void intrl2_##which##_mask_set(struct bcm_sf2_priv *priv, \ |
| 212 | u32 mask) \ | 212 | u32 mask) \ |
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index d1d9d3cf9139..710679067594 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c | |||
| @@ -2656,15 +2656,19 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) | |||
| 2656 | return ret; | 2656 | return ret; |
| 2657 | } | 2657 | } |
| 2658 | 2658 | ||
| 2659 | /* Rate Control: disable ingress rate limiting. */ | ||
| 2659 | if (mv88e6xxx_6352_family(chip) || mv88e6xxx_6351_family(chip) || | 2660 | if (mv88e6xxx_6352_family(chip) || mv88e6xxx_6351_family(chip) || |
| 2660 | mv88e6xxx_6165_family(chip) || mv88e6xxx_6097_family(chip) || | 2661 | mv88e6xxx_6165_family(chip) || mv88e6xxx_6097_family(chip) || |
| 2661 | mv88e6xxx_6185_family(chip) || mv88e6xxx_6095_family(chip) || | ||
| 2662 | mv88e6xxx_6320_family(chip)) { | 2662 | mv88e6xxx_6320_family(chip)) { |
| 2663 | /* Rate Control: disable ingress rate limiting. */ | ||
| 2664 | ret = _mv88e6xxx_reg_write(chip, REG_PORT(port), | 2663 | ret = _mv88e6xxx_reg_write(chip, REG_PORT(port), |
| 2665 | PORT_RATE_CONTROL, 0x0001); | 2664 | PORT_RATE_CONTROL, 0x0001); |
| 2666 | if (ret) | 2665 | if (ret) |
| 2667 | return ret; | 2666 | return ret; |
| 2667 | } else if (mv88e6xxx_6185_family(chip) || mv88e6xxx_6095_family(chip)) { | ||
| 2668 | ret = _mv88e6xxx_reg_write(chip, REG_PORT(port), | ||
| 2669 | PORT_RATE_CONTROL, 0x0000); | ||
| 2670 | if (ret) | ||
| 2671 | return ret; | ||
| 2668 | } | 2672 | } |
| 2669 | 2673 | ||
| 2670 | /* Port Control 1: disable trunking, disable sending | 2674 | /* Port Control 1: disable trunking, disable sending |
diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c index 6453148d066a..4eb17daefc4f 100644 --- a/drivers/net/ethernet/atheros/alx/main.c +++ b/drivers/net/ethernet/atheros/alx/main.c | |||
| @@ -1545,6 +1545,8 @@ static const struct pci_device_id alx_pci_tbl[] = { | |||
| 1545 | .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, | 1545 | .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, |
| 1546 | { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2400), | 1546 | { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2400), |
| 1547 | .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, | 1547 | .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, |
| 1548 | { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2500), | ||
| 1549 | .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, | ||
| 1548 | { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8162), | 1550 | { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8162), |
| 1549 | .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, | 1551 | .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, |
| 1550 | { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8171) }, | 1552 | { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8171) }, |
diff --git a/drivers/net/ethernet/atheros/alx/reg.h b/drivers/net/ethernet/atheros/alx/reg.h index 0959e6824cb6..1fc2d852249f 100644 --- a/drivers/net/ethernet/atheros/alx/reg.h +++ b/drivers/net/ethernet/atheros/alx/reg.h | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #define ALX_DEV_ID_AR8161 0x1091 | 38 | #define ALX_DEV_ID_AR8161 0x1091 |
| 39 | #define ALX_DEV_ID_E2200 0xe091 | 39 | #define ALX_DEV_ID_E2200 0xe091 |
| 40 | #define ALX_DEV_ID_E2400 0xe0a1 | 40 | #define ALX_DEV_ID_E2400 0xe0a1 |
| 41 | #define ALX_DEV_ID_E2500 0xe0b1 | ||
| 41 | #define ALX_DEV_ID_AR8162 0x1090 | 42 | #define ALX_DEV_ID_AR8162 0x1090 |
| 42 | #define ALX_DEV_ID_AR8171 0x10A1 | 43 | #define ALX_DEV_ID_AR8171 0x10A1 |
| 43 | #define ALX_DEV_ID_AR8172 0x10A0 | 44 | #define ALX_DEV_ID_AR8172 0x10A0 |
diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c b/drivers/net/ethernet/broadcom/bgmac-bcma.c index 9a9745c4047c..625235db644f 100644 --- a/drivers/net/ethernet/broadcom/bgmac-bcma.c +++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c | |||
| @@ -159,7 +159,7 @@ static int bgmac_probe(struct bcma_device *core) | |||
| 159 | 159 | ||
| 160 | if (!bgmac_is_bcm4707_family(core)) { | 160 | if (!bgmac_is_bcm4707_family(core)) { |
| 161 | mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr); | 161 | mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr); |
| 162 | if (!IS_ERR(mii_bus)) { | 162 | if (IS_ERR(mii_bus)) { |
| 163 | err = PTR_ERR(mii_bus); | 163 | err = PTR_ERR(mii_bus); |
| 164 | goto err; | 164 | goto err; |
| 165 | } | 165 | } |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 97e892511666..fa3386bb14f7 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | |||
| @@ -772,6 +772,11 @@ void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl) | |||
| 772 | (bp->common.bc_ver & 0xff00) >> 8, | 772 | (bp->common.bc_ver & 0xff00) >> 8, |
| 773 | (bp->common.bc_ver & 0xff)); | 773 | (bp->common.bc_ver & 0xff)); |
| 774 | 774 | ||
| 775 | if (pci_channel_offline(bp->pdev)) { | ||
| 776 | BNX2X_ERR("Cannot dump MCP info while in PCI error\n"); | ||
| 777 | return; | ||
| 778 | } | ||
| 779 | |||
| 775 | val = REG_RD(bp, MCP_REG_MCPR_CPU_PROGRAM_COUNTER); | 780 | val = REG_RD(bp, MCP_REG_MCPR_CPU_PROGRAM_COUNTER); |
| 776 | if (val == REG_RD(bp, MCP_REG_MCPR_CPU_PROGRAM_COUNTER)) | 781 | if (val == REG_RD(bp, MCP_REG_MCPR_CPU_PROGRAM_COUNTER)) |
| 777 | BNX2X_ERR("%s" "MCP PC at 0x%x\n", lvl, val); | 782 | BNX2X_ERR("%s" "MCP PC at 0x%x\n", lvl, val); |
| @@ -9415,10 +9420,16 @@ unload_error: | |||
| 9415 | /* Release IRQs */ | 9420 | /* Release IRQs */ |
| 9416 | bnx2x_free_irq(bp); | 9421 | bnx2x_free_irq(bp); |
| 9417 | 9422 | ||
| 9418 | /* Reset the chip */ | 9423 | /* Reset the chip, unless PCI function is offline. If we reach this |
| 9419 | rc = bnx2x_reset_hw(bp, reset_code); | 9424 | * point following a PCI error handling, it means device is really |
| 9420 | if (rc) | 9425 | * in a bad state and we're about to remove it, so reset the chip |
| 9421 | BNX2X_ERR("HW_RESET failed\n"); | 9426 | * is not a good idea. |
| 9427 | */ | ||
| 9428 | if (!pci_channel_offline(bp->pdev)) { | ||
| 9429 | rc = bnx2x_reset_hw(bp, reset_code); | ||
| 9430 | if (rc) | ||
| 9431 | BNX2X_ERR("HW_RESET failed\n"); | ||
| 9432 | } | ||
| 9422 | 9433 | ||
| 9423 | /* Report UNLOAD_DONE to MCP */ | 9434 | /* Report UNLOAD_DONE to MCP */ |
| 9424 | bnx2x_send_unload_done(bp, keep_link); | 9435 | bnx2x_send_unload_done(bp, keep_link); |
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 2cf79100c9cb..228c964e709a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c | |||
| @@ -353,8 +353,8 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 353 | push_len = (length + sizeof(*tx_push) + 7) / 8; | 353 | push_len = (length + sizeof(*tx_push) + 7) / 8; |
| 354 | if (push_len > 16) { | 354 | if (push_len > 16) { |
| 355 | __iowrite64_copy(txr->tx_doorbell, tx_push_buf, 16); | 355 | __iowrite64_copy(txr->tx_doorbell, tx_push_buf, 16); |
| 356 | __iowrite64_copy(txr->tx_doorbell + 4, tx_push_buf + 1, | 356 | __iowrite32_copy(txr->tx_doorbell + 4, tx_push_buf + 1, |
| 357 | push_len - 16); | 357 | (push_len - 16) << 1); |
| 358 | } else { | 358 | } else { |
| 359 | __iowrite64_copy(txr->tx_doorbell, tx_push_buf, | 359 | __iowrite64_copy(txr->tx_doorbell, tx_push_buf, |
| 360 | push_len); | 360 | push_len); |
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 659261218d9f..a2551bcd1027 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
| @@ -14012,6 +14012,7 @@ static int tg3_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) | |||
| 14012 | if ((ec->rx_coalesce_usecs > MAX_RXCOL_TICKS) || | 14012 | if ((ec->rx_coalesce_usecs > MAX_RXCOL_TICKS) || |
| 14013 | (!ec->rx_coalesce_usecs) || | 14013 | (!ec->rx_coalesce_usecs) || |
| 14014 | (ec->tx_coalesce_usecs > MAX_TXCOL_TICKS) || | 14014 | (ec->tx_coalesce_usecs > MAX_TXCOL_TICKS) || |
| 14015 | (!ec->tx_coalesce_usecs) || | ||
| 14015 | (ec->rx_max_coalesced_frames > MAX_RXMAX_FRAMES) || | 14016 | (ec->rx_max_coalesced_frames > MAX_RXMAX_FRAMES) || |
| 14016 | (ec->tx_max_coalesced_frames > MAX_TXMAX_FRAMES) || | 14017 | (ec->tx_max_coalesced_frames > MAX_TXMAX_FRAMES) || |
| 14017 | (ec->rx_coalesce_usecs_irq > max_rxcoal_tick_int) || | 14018 | (ec->rx_coalesce_usecs_irq > max_rxcoal_tick_int) || |
| @@ -14022,16 +14023,6 @@ static int tg3_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) | |||
| 14022 | (ec->stats_block_coalesce_usecs < min_stat_coal_ticks)) | 14023 | (ec->stats_block_coalesce_usecs < min_stat_coal_ticks)) |
| 14023 | return -EINVAL; | 14024 | return -EINVAL; |
| 14024 | 14025 | ||
| 14025 | /* No rx interrupts will be generated if both are zero */ | ||
| 14026 | if ((ec->rx_coalesce_usecs == 0) && | ||
| 14027 | (ec->rx_max_coalesced_frames == 0)) | ||
| 14028 | return -EINVAL; | ||
| 14029 | |||
| 14030 | /* No tx interrupts will be generated if both are zero */ | ||
| 14031 | if ((ec->tx_coalesce_usecs == 0) && | ||
| 14032 | (ec->tx_max_coalesced_frames == 0)) | ||
| 14033 | return -EINVAL; | ||
| 14034 | |||
| 14035 | /* Only copy relevant parameters, ignore all others. */ | 14026 | /* Only copy relevant parameters, ignore all others. */ |
| 14036 | tp->coal.rx_coalesce_usecs = ec->rx_coalesce_usecs; | 14027 | tp->coal.rx_coalesce_usecs = ec->rx_coalesce_usecs; |
| 14037 | tp->coal.tx_coalesce_usecs = ec->tx_coalesce_usecs; | 14028 | tp->coal.tx_coalesce_usecs = ec->tx_coalesce_usecs; |
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index 89c0cfa9719f..d954a97b0b0b 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c | |||
| @@ -1323,6 +1323,24 @@ dma_error: | |||
| 1323 | return 0; | 1323 | return 0; |
| 1324 | } | 1324 | } |
| 1325 | 1325 | ||
| 1326 | static inline int macb_clear_csum(struct sk_buff *skb) | ||
| 1327 | { | ||
| 1328 | /* no change for packets without checksum offloading */ | ||
| 1329 | if (skb->ip_summed != CHECKSUM_PARTIAL) | ||
| 1330 | return 0; | ||
| 1331 | |||
| 1332 | /* make sure we can modify the header */ | ||
| 1333 | if (unlikely(skb_cow_head(skb, 0))) | ||
| 1334 | return -1; | ||
| 1335 | |||
| 1336 | /* initialize checksum field | ||
| 1337 | * This is required - at least for Zynq, which otherwise calculates | ||
| 1338 | * wrong UDP header checksums for UDP packets with UDP data len <=2 | ||
| 1339 | */ | ||
| 1340 | *(__sum16 *)(skb_checksum_start(skb) + skb->csum_offset) = 0; | ||
| 1341 | return 0; | ||
| 1342 | } | ||
| 1343 | |||
| 1326 | static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) | 1344 | static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| 1327 | { | 1345 | { |
| 1328 | u16 queue_index = skb_get_queue_mapping(skb); | 1346 | u16 queue_index = skb_get_queue_mapping(skb); |
| @@ -1362,6 +1380,11 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1362 | return NETDEV_TX_BUSY; | 1380 | return NETDEV_TX_BUSY; |
| 1363 | } | 1381 | } |
| 1364 | 1382 | ||
| 1383 | if (macb_clear_csum(skb)) { | ||
| 1384 | dev_kfree_skb_any(skb); | ||
| 1385 | return NETDEV_TX_OK; | ||
| 1386 | } | ||
| 1387 | |||
| 1365 | /* Map socket buffer for DMA transfer */ | 1388 | /* Map socket buffer for DMA transfer */ |
| 1366 | if (!macb_tx_map(bp, queue, skb)) { | 1389 | if (!macb_tx_map(bp, queue, skb)) { |
| 1367 | dev_kfree_skb_any(skb); | 1390 | dev_kfree_skb_any(skb); |
diff --git a/drivers/net/ethernet/cavium/thunder/nic.h b/drivers/net/ethernet/cavium/thunder/nic.h index 83025bb4737c..e29815d9e6f4 100644 --- a/drivers/net/ethernet/cavium/thunder/nic.h +++ b/drivers/net/ethernet/cavium/thunder/nic.h | |||
| @@ -279,6 +279,7 @@ struct nicvf { | |||
| 279 | u8 sqs_id; | 279 | u8 sqs_id; |
| 280 | bool sqs_mode; | 280 | bool sqs_mode; |
| 281 | bool hw_tso; | 281 | bool hw_tso; |
| 282 | bool t88; | ||
| 282 | 283 | ||
| 283 | /* Receive buffer alloc */ | 284 | /* Receive buffer alloc */ |
| 284 | u32 rb_page_offset; | 285 | u32 rb_page_offset; |
diff --git a/drivers/net/ethernet/cavium/thunder/nic_main.c b/drivers/net/ethernet/cavium/thunder/nic_main.c index 16ed20357c5c..85cc782b9060 100644 --- a/drivers/net/ethernet/cavium/thunder/nic_main.c +++ b/drivers/net/ethernet/cavium/thunder/nic_main.c | |||
| @@ -251,9 +251,14 @@ static void nic_set_tx_pkt_pad(struct nicpf *nic, int size) | |||
| 251 | int lmac; | 251 | int lmac; |
| 252 | u64 lmac_cfg; | 252 | u64 lmac_cfg; |
| 253 | 253 | ||
| 254 | /* Max value that can be set is 60 */ | 254 | /* There is a issue in HW where-in while sending GSO sized |
| 255 | if (size > 60) | 255 | * pkts as part of TSO, if pkt len falls below this size |
| 256 | size = 60; | 256 | * NIC will zero PAD packet and also updates IP total length. |
| 257 | * Hence set this value to lessthan min pkt size of MAC+IP+TCP | ||
| 258 | * headers, BGX will do the padding to transmit 64 byte pkt. | ||
| 259 | */ | ||
| 260 | if (size > 52) | ||
| 261 | size = 52; | ||
| 257 | 262 | ||
| 258 | for (lmac = 0; lmac < (MAX_BGX_PER_CN88XX * MAX_LMAC_PER_BGX); lmac++) { | 263 | for (lmac = 0; lmac < (MAX_BGX_PER_CN88XX * MAX_LMAC_PER_BGX); lmac++) { |
| 259 | lmac_cfg = nic_reg_read(nic, NIC_PF_LMAC_0_7_CFG | (lmac << 3)); | 264 | lmac_cfg = nic_reg_read(nic, NIC_PF_LMAC_0_7_CFG | (lmac << 3)); |
diff --git a/drivers/net/ethernet/cavium/thunder/nic_reg.h b/drivers/net/ethernet/cavium/thunder/nic_reg.h index afb10e326b4f..fab35a593898 100644 --- a/drivers/net/ethernet/cavium/thunder/nic_reg.h +++ b/drivers/net/ethernet/cavium/thunder/nic_reg.h | |||
| @@ -170,7 +170,6 @@ | |||
| 170 | #define NIC_QSET_SQ_0_7_DOOR (0x010838) | 170 | #define NIC_QSET_SQ_0_7_DOOR (0x010838) |
| 171 | #define NIC_QSET_SQ_0_7_STATUS (0x010840) | 171 | #define NIC_QSET_SQ_0_7_STATUS (0x010840) |
| 172 | #define NIC_QSET_SQ_0_7_DEBUG (0x010848) | 172 | #define NIC_QSET_SQ_0_7_DEBUG (0x010848) |
| 173 | #define NIC_QSET_SQ_0_7_CNM_CHG (0x010860) | ||
| 174 | #define NIC_QSET_SQ_0_7_STAT_0_1 (0x010900) | 173 | #define NIC_QSET_SQ_0_7_STAT_0_1 (0x010900) |
| 175 | 174 | ||
| 176 | #define NIC_QSET_RBDR_0_1_CFG (0x010C00) | 175 | #define NIC_QSET_RBDR_0_1_CFG (0x010C00) |
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c b/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c index d2d8ef270142..ad4fddb55421 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c | |||
| @@ -382,7 +382,10 @@ static void nicvf_get_regs(struct net_device *dev, | |||
| 382 | p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DOOR, q); | 382 | p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DOOR, q); |
| 383 | p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STATUS, q); | 383 | p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STATUS, q); |
| 384 | p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DEBUG, q); | 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 | p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STAT_0_1, q); | 389 | p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STAT_0_1, q); |
| 387 | reg_offset = NIC_QSET_SQ_0_7_STAT_0_1 | (1 << 3); | 390 | reg_offset = NIC_QSET_SQ_0_7_STAT_0_1 | (1 << 3); |
| 388 | p[i++] = nicvf_queue_reg_read(nic, reg_offset, q); | 391 | p[i++] = nicvf_queue_reg_read(nic, reg_offset, q); |
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c index a19e73f11d73..3240349615bd 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c | |||
| @@ -513,6 +513,7 @@ static void nicvf_snd_pkt_handler(struct net_device *netdev, | |||
| 513 | struct nicvf *nic = netdev_priv(netdev); | 513 | struct nicvf *nic = netdev_priv(netdev); |
| 514 | struct snd_queue *sq; | 514 | struct snd_queue *sq; |
| 515 | struct sq_hdr_subdesc *hdr; | 515 | struct sq_hdr_subdesc *hdr; |
| 516 | struct sq_hdr_subdesc *tso_sqe; | ||
| 516 | 517 | ||
| 517 | sq = &nic->qs->sq[cqe_tx->sq_idx]; | 518 | sq = &nic->qs->sq[cqe_tx->sq_idx]; |
| 518 | 519 | ||
| @@ -527,17 +528,21 @@ static void nicvf_snd_pkt_handler(struct net_device *netdev, | |||
| 527 | 528 | ||
| 528 | nicvf_check_cqe_tx_errs(nic, cq, cqe_tx); | 529 | nicvf_check_cqe_tx_errs(nic, cq, cqe_tx); |
| 529 | skb = (struct sk_buff *)sq->skbuff[cqe_tx->sqe_ptr]; | 530 | skb = (struct sk_buff *)sq->skbuff[cqe_tx->sqe_ptr]; |
| 530 | /* For TSO offloaded packets only one SQE will have a valid SKB */ | ||
| 531 | if (skb) { | 531 | if (skb) { |
| 532 | /* Check for dummy descriptor used for HW TSO offload on 88xx */ | ||
| 533 | if (hdr->dont_send) { | ||
| 534 | /* Get actual TSO descriptors and free them */ | ||
| 535 | tso_sqe = | ||
| 536 | (struct sq_hdr_subdesc *)GET_SQ_DESC(sq, hdr->rsvd2); | ||
| 537 | nicvf_put_sq_desc(sq, tso_sqe->subdesc_cnt + 1); | ||
| 538 | } | ||
| 532 | nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1); | 539 | nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1); |
| 533 | prefetch(skb); | 540 | prefetch(skb); |
| 534 | dev_consume_skb_any(skb); | 541 | dev_consume_skb_any(skb); |
| 535 | sq->skbuff[cqe_tx->sqe_ptr] = (u64)NULL; | 542 | sq->skbuff[cqe_tx->sqe_ptr] = (u64)NULL; |
| 536 | } else { | 543 | } else { |
| 537 | /* In case of HW TSO, HW sends a CQE for each segment of a TSO | 544 | /* In case of SW TSO on 88xx, only last segment will have |
| 538 | * packet instead of a single CQE for the whole TSO packet | 545 | * a SKB attached, so just free SQEs here. |
| 539 | * transmitted. Each of this CQE points to the same SQE, so | ||
| 540 | * avoid freeing same SQE multiple times. | ||
| 541 | */ | 546 | */ |
| 542 | if (!nic->hw_tso) | 547 | if (!nic->hw_tso) |
| 543 | nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1); | 548 | nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1); |
| @@ -1502,6 +1507,7 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 1502 | struct net_device *netdev; | 1507 | struct net_device *netdev; |
| 1503 | struct nicvf *nic; | 1508 | struct nicvf *nic; |
| 1504 | int err, qcount; | 1509 | int err, qcount; |
| 1510 | u16 sdevid; | ||
| 1505 | 1511 | ||
| 1506 | err = pci_enable_device(pdev); | 1512 | err = pci_enable_device(pdev); |
| 1507 | if (err) { | 1513 | if (err) { |
| @@ -1575,6 +1581,10 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 1575 | if (!pass1_silicon(nic->pdev)) | 1581 | if (!pass1_silicon(nic->pdev)) |
| 1576 | nic->hw_tso = true; | 1582 | nic->hw_tso = true; |
| 1577 | 1583 | ||
| 1584 | pci_read_config_word(nic->pdev, PCI_SUBSYSTEM_ID, &sdevid); | ||
| 1585 | if (sdevid == 0xA134) | ||
| 1586 | nic->t88 = true; | ||
| 1587 | |||
| 1578 | /* Check if this VF is in QS only mode */ | 1588 | /* Check if this VF is in QS only mode */ |
| 1579 | if (nic->sqs_mode) | 1589 | if (nic->sqs_mode) |
| 1580 | return 0; | 1590 | return 0; |
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c index 0ff8e60deccb..dda3ea3f3bb6 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c | |||
| @@ -938,6 +938,8 @@ static int nicvf_tso_count_subdescs(struct sk_buff *skb) | |||
| 938 | return num_edescs + sh->gso_segs; | 938 | return num_edescs + sh->gso_segs; |
| 939 | } | 939 | } |
| 940 | 940 | ||
| 941 | #define POST_CQE_DESC_COUNT 2 | ||
| 942 | |||
| 941 | /* Get the number of SQ descriptors needed to xmit this skb */ | 943 | /* Get the number of SQ descriptors needed to xmit this skb */ |
| 942 | static int nicvf_sq_subdesc_required(struct nicvf *nic, struct sk_buff *skb) | 944 | static int nicvf_sq_subdesc_required(struct nicvf *nic, struct sk_buff *skb) |
| 943 | { | 945 | { |
| @@ -948,6 +950,10 @@ static int nicvf_sq_subdesc_required(struct nicvf *nic, struct sk_buff *skb) | |||
| 948 | return subdesc_cnt; | 950 | return subdesc_cnt; |
| 949 | } | 951 | } |
| 950 | 952 | ||
| 953 | /* Dummy descriptors to get TSO pkt completion notification */ | ||
| 954 | if (nic->t88 && nic->hw_tso && skb_shinfo(skb)->gso_size) | ||
| 955 | subdesc_cnt += POST_CQE_DESC_COUNT; | ||
| 956 | |||
| 951 | if (skb_shinfo(skb)->nr_frags) | 957 | if (skb_shinfo(skb)->nr_frags) |
| 952 | subdesc_cnt += skb_shinfo(skb)->nr_frags; | 958 | subdesc_cnt += skb_shinfo(skb)->nr_frags; |
| 953 | 959 | ||
| @@ -965,14 +971,21 @@ nicvf_sq_add_hdr_subdesc(struct nicvf *nic, struct snd_queue *sq, int qentry, | |||
| 965 | struct sq_hdr_subdesc *hdr; | 971 | struct sq_hdr_subdesc *hdr; |
| 966 | 972 | ||
| 967 | hdr = (struct sq_hdr_subdesc *)GET_SQ_DESC(sq, qentry); | 973 | hdr = (struct sq_hdr_subdesc *)GET_SQ_DESC(sq, qentry); |
| 968 | sq->skbuff[qentry] = (u64)skb; | ||
| 969 | |||
| 970 | memset(hdr, 0, SND_QUEUE_DESC_SIZE); | 974 | memset(hdr, 0, SND_QUEUE_DESC_SIZE); |
| 971 | hdr->subdesc_type = SQ_DESC_TYPE_HEADER; | 975 | hdr->subdesc_type = SQ_DESC_TYPE_HEADER; |
| 972 | /* Enable notification via CQE after processing SQE */ | 976 | |
| 973 | hdr->post_cqe = 1; | 977 | if (nic->t88 && nic->hw_tso && skb_shinfo(skb)->gso_size) { |
| 974 | /* No of subdescriptors following this */ | 978 | /* post_cqe = 0, to avoid HW posting a CQE for every TSO |
| 975 | hdr->subdesc_cnt = subdesc_cnt; | 979 | * segment transmitted on 88xx. |
| 980 | */ | ||
| 981 | hdr->subdesc_cnt = subdesc_cnt - POST_CQE_DESC_COUNT; | ||
| 982 | } else { | ||
| 983 | sq->skbuff[qentry] = (u64)skb; | ||
| 984 | /* Enable notification via CQE after processing SQE */ | ||
| 985 | hdr->post_cqe = 1; | ||
| 986 | /* No of subdescriptors following this */ | ||
| 987 | hdr->subdesc_cnt = subdesc_cnt; | ||
| 988 | } | ||
| 976 | hdr->tot_len = len; | 989 | hdr->tot_len = len; |
| 977 | 990 | ||
| 978 | /* Offload checksum calculation to HW */ | 991 | /* Offload checksum calculation to HW */ |
| @@ -1023,6 +1036,37 @@ static inline void nicvf_sq_add_gather_subdesc(struct snd_queue *sq, int qentry, | |||
| 1023 | gather->addr = data; | 1036 | gather->addr = data; |
| 1024 | } | 1037 | } |
| 1025 | 1038 | ||
| 1039 | /* Add HDR + IMMEDIATE subdescriptors right after descriptors of a TSO | ||
| 1040 | * packet so that a CQE is posted as a notifation for transmission of | ||
| 1041 | * TSO packet. | ||
| 1042 | */ | ||
| 1043 | static inline void nicvf_sq_add_cqe_subdesc(struct snd_queue *sq, int qentry, | ||
| 1044 | int tso_sqe, struct sk_buff *skb) | ||
| 1045 | { | ||
| 1046 | struct sq_imm_subdesc *imm; | ||
| 1047 | struct sq_hdr_subdesc *hdr; | ||
| 1048 | |||
| 1049 | sq->skbuff[qentry] = (u64)skb; | ||
| 1050 | |||
| 1051 | hdr = (struct sq_hdr_subdesc *)GET_SQ_DESC(sq, qentry); | ||
| 1052 | memset(hdr, 0, SND_QUEUE_DESC_SIZE); | ||
| 1053 | hdr->subdesc_type = SQ_DESC_TYPE_HEADER; | ||
| 1054 | /* Enable notification via CQE after processing SQE */ | ||
| 1055 | hdr->post_cqe = 1; | ||
| 1056 | /* There is no packet to transmit here */ | ||
| 1057 | hdr->dont_send = 1; | ||
| 1058 | hdr->subdesc_cnt = POST_CQE_DESC_COUNT - 1; | ||
| 1059 | hdr->tot_len = 1; | ||
| 1060 | /* Actual TSO header SQE index, needed for cleanup */ | ||
| 1061 | hdr->rsvd2 = tso_sqe; | ||
| 1062 | |||
| 1063 | qentry = nicvf_get_nxt_sqentry(sq, qentry); | ||
| 1064 | imm = (struct sq_imm_subdesc *)GET_SQ_DESC(sq, qentry); | ||
| 1065 | memset(imm, 0, SND_QUEUE_DESC_SIZE); | ||
| 1066 | imm->subdesc_type = SQ_DESC_TYPE_IMMEDIATE; | ||
| 1067 | imm->len = 1; | ||
| 1068 | } | ||
| 1069 | |||
| 1026 | /* Segment a TSO packet into 'gso_size' segments and append | 1070 | /* Segment a TSO packet into 'gso_size' segments and append |
| 1027 | * them to SQ for transfer | 1071 | * them to SQ for transfer |
| 1028 | */ | 1072 | */ |
| @@ -1096,7 +1140,7 @@ static int nicvf_sq_append_tso(struct nicvf *nic, struct snd_queue *sq, | |||
| 1096 | int nicvf_sq_append_skb(struct nicvf *nic, struct sk_buff *skb) | 1140 | int nicvf_sq_append_skb(struct nicvf *nic, struct sk_buff *skb) |
| 1097 | { | 1141 | { |
| 1098 | int i, size; | 1142 | int i, size; |
| 1099 | int subdesc_cnt; | 1143 | int subdesc_cnt, tso_sqe = 0; |
| 1100 | int sq_num, qentry; | 1144 | int sq_num, qentry; |
| 1101 | struct queue_set *qs; | 1145 | struct queue_set *qs; |
| 1102 | struct snd_queue *sq; | 1146 | struct snd_queue *sq; |
| @@ -1131,6 +1175,7 @@ int nicvf_sq_append_skb(struct nicvf *nic, struct sk_buff *skb) | |||
| 1131 | /* Add SQ header subdesc */ | 1175 | /* Add SQ header subdesc */ |
| 1132 | nicvf_sq_add_hdr_subdesc(nic, sq, qentry, subdesc_cnt - 1, | 1176 | nicvf_sq_add_hdr_subdesc(nic, sq, qentry, subdesc_cnt - 1, |
| 1133 | skb, skb->len); | 1177 | skb, skb->len); |
| 1178 | tso_sqe = qentry; | ||
| 1134 | 1179 | ||
| 1135 | /* Add SQ gather subdescs */ | 1180 | /* Add SQ gather subdescs */ |
| 1136 | qentry = nicvf_get_nxt_sqentry(sq, qentry); | 1181 | qentry = nicvf_get_nxt_sqentry(sq, qentry); |
| @@ -1154,6 +1199,11 @@ int nicvf_sq_append_skb(struct nicvf *nic, struct sk_buff *skb) | |||
| 1154 | } | 1199 | } |
| 1155 | 1200 | ||
| 1156 | doorbell: | 1201 | doorbell: |
| 1202 | if (nic->t88 && skb_shinfo(skb)->gso_size) { | ||
| 1203 | qentry = nicvf_get_nxt_sqentry(sq, qentry); | ||
| 1204 | nicvf_sq_add_cqe_subdesc(sq, qentry, tso_sqe, skb); | ||
| 1205 | } | ||
| 1206 | |||
| 1157 | /* make sure all memory stores are done before ringing doorbell */ | 1207 | /* make sure all memory stores are done before ringing doorbell */ |
| 1158 | smp_wmb(); | 1208 | smp_wmb(); |
| 1159 | 1209 | ||
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index c45de49dc963..c762a8c8c954 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | |||
| @@ -4335,6 +4335,11 @@ static void cfg_queues(struct adapter *adap) | |||
| 4335 | #endif | 4335 | #endif |
| 4336 | int ciq_size; | 4336 | int ciq_size; |
| 4337 | 4337 | ||
| 4338 | /* Reduce memory usage in kdump environment, disable all offload. | ||
| 4339 | */ | ||
| 4340 | if (is_kdump_kernel()) | ||
| 4341 | adap->params.offload = 0; | ||
| 4342 | |||
| 4338 | for_each_port(adap, i) | 4343 | for_each_port(adap, i) |
| 4339 | n10g += is_x_10g_port(&adap2pinfo(adap, i)->link_cfg); | 4344 | n10g += is_x_10g_port(&adap2pinfo(adap, i)->link_cfg); |
| 4340 | #ifdef CONFIG_CHELSIO_T4_DCB | 4345 | #ifdef CONFIG_CHELSIO_T4_DCB |
| @@ -4365,11 +4370,6 @@ static void cfg_queues(struct adapter *adap) | |||
| 4365 | if (q10g > netif_get_num_default_rss_queues()) | 4370 | if (q10g > netif_get_num_default_rss_queues()) |
| 4366 | q10g = netif_get_num_default_rss_queues(); | 4371 | q10g = netif_get_num_default_rss_queues(); |
| 4367 | 4372 | ||
| 4368 | /* Reduce memory usage in kdump environment, disable all offload. | ||
| 4369 | */ | ||
| 4370 | if (is_kdump_kernel()) | ||
| 4371 | adap->params.offload = 0; | ||
| 4372 | |||
| 4373 | for_each_port(adap, i) { | 4373 | for_each_port(adap, i) { |
| 4374 | struct port_info *pi = adap2pinfo(adap, i); | 4374 | struct port_info *pi = adap2pinfo(adap, i); |
| 4375 | 4375 | ||
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index d20935dc8399..4b4f5bc0e279 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c | |||
| @@ -2922,17 +2922,25 @@ static bool gfar_add_rx_frag(struct gfar_rx_buff *rxb, u32 lstatus, | |||
| 2922 | { | 2922 | { |
| 2923 | unsigned int size = lstatus & BD_LENGTH_MASK; | 2923 | unsigned int size = lstatus & BD_LENGTH_MASK; |
| 2924 | struct page *page = rxb->page; | 2924 | struct page *page = rxb->page; |
| 2925 | bool last = !!(lstatus & BD_LFLAG(RXBD_LAST)); | ||
| 2925 | 2926 | ||
| 2926 | /* Remove the FCS from the packet length */ | 2927 | /* Remove the FCS from the packet length */ |
| 2927 | if (likely(lstatus & BD_LFLAG(RXBD_LAST))) | 2928 | if (last) |
| 2928 | size -= ETH_FCS_LEN; | 2929 | size -= ETH_FCS_LEN; |
| 2929 | 2930 | ||
| 2930 | if (likely(first)) | 2931 | if (likely(first)) { |
| 2931 | skb_put(skb, size); | 2932 | skb_put(skb, size); |
| 2932 | else | 2933 | } else { |
| 2933 | skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, | 2934 | /* the last fragments' length contains the full frame length */ |
| 2934 | rxb->page_offset + RXBUF_ALIGNMENT, | 2935 | if (last) |
| 2935 | size, GFAR_RXB_TRUESIZE); | 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 | /* try reuse page */ | 2945 | /* try reuse page */ |
| 2938 | if (unlikely(page_count(page) != 1)) | 2946 | if (unlikely(page_count(page) != 1)) |
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h index 373fd094f2f3..6e8a9c8467b9 100644 --- a/drivers/net/ethernet/freescale/gianfar.h +++ b/drivers/net/ethernet/freescale/gianfar.h | |||
| @@ -100,7 +100,8 @@ extern const char gfar_driver_version[]; | |||
| 100 | #define DEFAULT_RX_LFC_THR 16 | 100 | #define DEFAULT_RX_LFC_THR 16 |
| 101 | #define DEFAULT_LFC_PTVVAL 4 | 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 | #define GFAR_SKBFRAG_SIZE (RXBUF_ALIGNMENT + GFAR_RXB_SIZE \ | 105 | #define GFAR_SKBFRAG_SIZE (RXBUF_ALIGNMENT + GFAR_RXB_SIZE \ |
| 105 | + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) | 106 | + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) |
| 106 | #define GFAR_RXB_TRUESIZE 2048 | 107 | #define GFAR_RXB_TRUESIZE 2048 |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c index ff8b6a468b24..6ea872287307 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c | |||
| @@ -328,9 +328,10 @@ static void hns_ppe_init_hw(struct hns_ppe_cb *ppe_cb) | |||
| 328 | static void hns_ppe_uninit_hw(struct hns_ppe_cb *ppe_cb) | 328 | static void hns_ppe_uninit_hw(struct hns_ppe_cb *ppe_cb) |
| 329 | { | 329 | { |
| 330 | u32 port; | 330 | u32 port; |
| 331 | struct dsaf_device *dsaf_dev = ppe_cb->ppe_common_cb->dsaf_dev; | ||
| 332 | 331 | ||
| 333 | if (ppe_cb->ppe_common_cb) { | 332 | if (ppe_cb->ppe_common_cb) { |
| 333 | struct dsaf_device *dsaf_dev = ppe_cb->ppe_common_cb->dsaf_dev; | ||
| 334 | |||
| 334 | port = ppe_cb->index; | 335 | port = ppe_cb->index; |
| 335 | dsaf_dev->misc_op->ppe_srst(dsaf_dev, port, 0); | 336 | dsaf_dev->misc_op->ppe_srst(dsaf_dev, port, 0); |
| 336 | } | 337 | } |
diff --git a/drivers/net/ethernet/intel/i40e/i40e_client.c b/drivers/net/ethernet/intel/i40e/i40e_client.c index e1370c556a3c..618f18436618 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_client.c +++ b/drivers/net/ethernet/intel/i40e/i40e_client.c | |||
| @@ -199,6 +199,7 @@ void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi) | |||
| 199 | void i40e_notify_client_of_netdev_open(struct i40e_vsi *vsi) | 199 | void i40e_notify_client_of_netdev_open(struct i40e_vsi *vsi) |
| 200 | { | 200 | { |
| 201 | struct i40e_client_instance *cdev; | 201 | struct i40e_client_instance *cdev; |
| 202 | int ret = 0; | ||
| 202 | 203 | ||
| 203 | if (!vsi) | 204 | if (!vsi) |
| 204 | return; | 205 | return; |
| @@ -211,7 +212,14 @@ void i40e_notify_client_of_netdev_open(struct i40e_vsi *vsi) | |||
| 211 | "Cannot locate client instance open routine\n"); | 212 | "Cannot locate client instance open routine\n"); |
| 212 | continue; | 213 | continue; |
| 213 | } | 214 | } |
| 214 | cdev->client->ops->open(&cdev->lan_info, cdev->client); | 215 | if (!(test_bit(__I40E_CLIENT_INSTANCE_OPENED, |
| 216 | &cdev->state))) { | ||
| 217 | ret = cdev->client->ops->open(&cdev->lan_info, | ||
| 218 | cdev->client); | ||
| 219 | if (!ret) | ||
| 220 | set_bit(__I40E_CLIENT_INSTANCE_OPENED, | ||
| 221 | &cdev->state); | ||
| 222 | } | ||
| 215 | } | 223 | } |
| 216 | } | 224 | } |
| 217 | mutex_unlock(&i40e_client_instance_mutex); | 225 | mutex_unlock(&i40e_client_instance_mutex); |
| @@ -407,12 +415,14 @@ struct i40e_vsi *i40e_vsi_lookup(struct i40e_pf *pf, | |||
| 407 | * i40e_client_add_instance - add a client instance struct to the instance list | 415 | * i40e_client_add_instance - add a client instance struct to the instance list |
| 408 | * @pf: pointer to the board struct | 416 | * @pf: pointer to the board struct |
| 409 | * @client: pointer to a client struct in the client list. | 417 | * @client: pointer to a client struct in the client list. |
| 418 | * @existing: if there was already an existing instance | ||
| 410 | * | 419 | * |
| 411 | * Returns cdev ptr on success, NULL on failure | 420 | * Returns cdev ptr on success or if already exists, NULL on failure |
| 412 | **/ | 421 | **/ |
| 413 | static | 422 | static |
| 414 | struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf, | 423 | struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf, |
| 415 | struct i40e_client *client) | 424 | struct i40e_client *client, |
| 425 | bool *existing) | ||
| 416 | { | 426 | { |
| 417 | struct i40e_client_instance *cdev; | 427 | struct i40e_client_instance *cdev; |
| 418 | struct netdev_hw_addr *mac = NULL; | 428 | struct netdev_hw_addr *mac = NULL; |
| @@ -421,7 +431,7 @@ struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf, | |||
| 421 | mutex_lock(&i40e_client_instance_mutex); | 431 | mutex_lock(&i40e_client_instance_mutex); |
| 422 | list_for_each_entry(cdev, &i40e_client_instances, list) { | 432 | list_for_each_entry(cdev, &i40e_client_instances, list) { |
| 423 | if ((cdev->lan_info.pf == pf) && (cdev->client == client)) { | 433 | if ((cdev->lan_info.pf == pf) && (cdev->client == client)) { |
| 424 | cdev = NULL; | 434 | *existing = true; |
| 425 | goto out; | 435 | goto out; |
| 426 | } | 436 | } |
| 427 | } | 437 | } |
| @@ -505,6 +515,7 @@ void i40e_client_subtask(struct i40e_pf *pf) | |||
| 505 | { | 515 | { |
| 506 | struct i40e_client_instance *cdev; | 516 | struct i40e_client_instance *cdev; |
| 507 | struct i40e_client *client; | 517 | struct i40e_client *client; |
| 518 | bool existing = false; | ||
| 508 | int ret = 0; | 519 | int ret = 0; |
| 509 | 520 | ||
| 510 | if (!(pf->flags & I40E_FLAG_SERVICE_CLIENT_REQUESTED)) | 521 | if (!(pf->flags & I40E_FLAG_SERVICE_CLIENT_REQUESTED)) |
| @@ -528,18 +539,25 @@ void i40e_client_subtask(struct i40e_pf *pf) | |||
| 528 | /* check if L2 VSI is up, if not we are not ready */ | 539 | /* check if L2 VSI is up, if not we are not ready */ |
| 529 | if (test_bit(__I40E_DOWN, &pf->vsi[pf->lan_vsi]->state)) | 540 | if (test_bit(__I40E_DOWN, &pf->vsi[pf->lan_vsi]->state)) |
| 530 | continue; | 541 | continue; |
| 542 | } else { | ||
| 543 | dev_warn(&pf->pdev->dev, "This client %s is being instanciated at probe\n", | ||
| 544 | client->name); | ||
| 531 | } | 545 | } |
| 532 | 546 | ||
| 533 | /* Add the client instance to the instance list */ | 547 | /* Add the client instance to the instance list */ |
| 534 | cdev = i40e_client_add_instance(pf, client); | 548 | cdev = i40e_client_add_instance(pf, client, &existing); |
| 535 | if (!cdev) | 549 | if (!cdev) |
| 536 | continue; | 550 | continue; |
| 537 | 551 | ||
| 538 | /* Also up the ref_cnt of no. of instances of this client */ | 552 | if (!existing) { |
| 539 | atomic_inc(&client->ref_cnt); | 553 | /* Also up the ref_cnt for no. of instances of this |
| 540 | dev_info(&pf->pdev->dev, "Added instance of Client %s to PF%d bus=0x%02x func=0x%02x\n", | 554 | * client. |
| 541 | client->name, pf->hw.pf_id, | 555 | */ |
| 542 | pf->hw.bus.device, pf->hw.bus.func); | 556 | atomic_inc(&client->ref_cnt); |
| 557 | dev_info(&pf->pdev->dev, "Added instance of Client %s to PF%d bus=0x%02x func=0x%02x\n", | ||
| 558 | client->name, pf->hw.pf_id, | ||
| 559 | pf->hw.bus.device, pf->hw.bus.func); | ||
| 560 | } | ||
| 543 | 561 | ||
| 544 | /* Send an Open request to the client */ | 562 | /* Send an Open request to the client */ |
| 545 | atomic_inc(&cdev->ref_cnt); | 563 | atomic_inc(&cdev->ref_cnt); |
| @@ -588,7 +606,8 @@ int i40e_lan_add_device(struct i40e_pf *pf) | |||
| 588 | pf->hw.pf_id, pf->hw.bus.device, pf->hw.bus.func); | 606 | pf->hw.pf_id, pf->hw.bus.device, pf->hw.bus.func); |
| 589 | 607 | ||
| 590 | /* Since in some cases register may have happened before a device gets | 608 | /* Since in some cases register may have happened before a device gets |
| 591 | * added, we can schedule a subtask to go initiate the clients. | 609 | * added, we can schedule a subtask to go initiate the clients if |
| 610 | * they can be launched at probe time. | ||
| 592 | */ | 611 | */ |
| 593 | pf->flags |= I40E_FLAG_SERVICE_CLIENT_REQUESTED; | 612 | pf->flags |= I40E_FLAG_SERVICE_CLIENT_REQUESTED; |
| 594 | i40e_service_event_schedule(pf); | 613 | i40e_service_event_schedule(pf); |
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index c6ac7a61812f..d0b3a1bb82ca 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c | |||
| @@ -5113,9 +5113,13 @@ static int i40e_init_pf_dcb(struct i40e_pf *pf) | |||
| 5113 | DCB_CAP_DCBX_VER_IEEE; | 5113 | DCB_CAP_DCBX_VER_IEEE; |
| 5114 | 5114 | ||
| 5115 | pf->flags |= I40E_FLAG_DCB_CAPABLE; | 5115 | pf->flags |= I40E_FLAG_DCB_CAPABLE; |
| 5116 | /* Enable DCB tagging only when more than one TC */ | 5116 | /* Enable DCB tagging only when more than one TC |
| 5117 | * or explicitly disable if only one TC | ||
| 5118 | */ | ||
| 5117 | if (i40e_dcb_get_num_tc(&hw->local_dcbx_config) > 1) | 5119 | if (i40e_dcb_get_num_tc(&hw->local_dcbx_config) > 1) |
| 5118 | pf->flags |= I40E_FLAG_DCB_ENABLED; | 5120 | pf->flags |= I40E_FLAG_DCB_ENABLED; |
| 5121 | else | ||
| 5122 | pf->flags &= ~I40E_FLAG_DCB_ENABLED; | ||
| 5119 | dev_dbg(&pf->pdev->dev, | 5123 | dev_dbg(&pf->pdev->dev, |
| 5120 | "DCBX offload is supported for this PF.\n"); | 5124 | "DCBX offload is supported for this PF.\n"); |
| 5121 | } | 5125 | } |
| @@ -5431,7 +5435,6 @@ int i40e_open(struct net_device *netdev) | |||
| 5431 | wr32(&pf->hw, I40E_GLLAN_TSOMSK_L, be32_to_cpu(TCP_FLAG_CWR) >> 16); | 5435 | wr32(&pf->hw, I40E_GLLAN_TSOMSK_L, be32_to_cpu(TCP_FLAG_CWR) >> 16); |
| 5432 | 5436 | ||
| 5433 | udp_tunnel_get_rx_info(netdev); | 5437 | udp_tunnel_get_rx_info(netdev); |
| 5434 | i40e_notify_client_of_netdev_open(vsi); | ||
| 5435 | 5438 | ||
| 5436 | return 0; | 5439 | return 0; |
| 5437 | } | 5440 | } |
| @@ -5717,7 +5720,7 @@ static int i40e_handle_lldp_event(struct i40e_pf *pf, | |||
| 5717 | u8 type; | 5720 | u8 type; |
| 5718 | 5721 | ||
| 5719 | /* Not DCB capable or capability disabled */ | 5722 | /* Not DCB capable or capability disabled */ |
| 5720 | if (!(pf->flags & I40E_FLAG_DCB_CAPABLE)) | 5723 | if (!(pf->flags & I40E_FLAG_DCB_ENABLED)) |
| 5721 | return ret; | 5724 | return ret; |
| 5722 | 5725 | ||
| 5723 | /* Ignore if event is not for Nearest Bridge */ | 5726 | /* Ignore if event is not for Nearest Bridge */ |
| @@ -7897,6 +7900,7 @@ static int i40e_init_interrupt_scheme(struct i40e_pf *pf) | |||
| 7897 | #endif | 7900 | #endif |
| 7898 | I40E_FLAG_RSS_ENABLED | | 7901 | I40E_FLAG_RSS_ENABLED | |
| 7899 | I40E_FLAG_DCB_CAPABLE | | 7902 | I40E_FLAG_DCB_CAPABLE | |
| 7903 | I40E_FLAG_DCB_ENABLED | | ||
| 7900 | I40E_FLAG_SRIOV_ENABLED | | 7904 | I40E_FLAG_SRIOV_ENABLED | |
| 7901 | I40E_FLAG_FD_SB_ENABLED | | 7905 | I40E_FLAG_FD_SB_ENABLED | |
| 7902 | I40E_FLAG_FD_ATR_ENABLED | | 7906 | I40E_FLAG_FD_ATR_ENABLED | |
| @@ -10503,6 +10507,7 @@ static void i40e_determine_queue_usage(struct i40e_pf *pf) | |||
| 10503 | I40E_FLAG_FD_SB_ENABLED | | 10507 | I40E_FLAG_FD_SB_ENABLED | |
| 10504 | I40E_FLAG_FD_ATR_ENABLED | | 10508 | I40E_FLAG_FD_ATR_ENABLED | |
| 10505 | I40E_FLAG_DCB_CAPABLE | | 10509 | I40E_FLAG_DCB_CAPABLE | |
| 10510 | I40E_FLAG_DCB_ENABLED | | ||
| 10506 | I40E_FLAG_SRIOV_ENABLED | | 10511 | I40E_FLAG_SRIOV_ENABLED | |
| 10507 | I40E_FLAG_VMDQ_ENABLED); | 10512 | I40E_FLAG_VMDQ_ENABLED); |
| 10508 | } else if (!(pf->flags & (I40E_FLAG_RSS_ENABLED | | 10513 | } else if (!(pf->flags & (I40E_FLAG_RSS_ENABLED | |
| @@ -10526,7 +10531,8 @@ static void i40e_determine_queue_usage(struct i40e_pf *pf) | |||
| 10526 | /* Not enough queues for all TCs */ | 10531 | /* Not enough queues for all TCs */ |
| 10527 | if ((pf->flags & I40E_FLAG_DCB_CAPABLE) && | 10532 | if ((pf->flags & I40E_FLAG_DCB_CAPABLE) && |
| 10528 | (queues_left < I40E_MAX_TRAFFIC_CLASS)) { | 10533 | (queues_left < I40E_MAX_TRAFFIC_CLASS)) { |
| 10529 | pf->flags &= ~I40E_FLAG_DCB_CAPABLE; | 10534 | pf->flags &= ~(I40E_FLAG_DCB_CAPABLE | |
| 10535 | I40E_FLAG_DCB_ENABLED); | ||
| 10530 | dev_info(&pf->pdev->dev, "not enough queues for DCB. DCB is disabled.\n"); | 10536 | dev_info(&pf->pdev->dev, "not enough queues for DCB. DCB is disabled.\n"); |
| 10531 | } | 10537 | } |
| 10532 | pf->num_lan_qps = max_t(int, pf->rss_size_max, | 10538 | pf->num_lan_qps = max_t(int, pf->rss_size_max, |
| @@ -10923,7 +10929,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 10923 | err = i40e_init_pf_dcb(pf); | 10929 | err = i40e_init_pf_dcb(pf); |
| 10924 | if (err) { | 10930 | if (err) { |
| 10925 | dev_info(&pdev->dev, "DCB init failed %d, disabled\n", err); | 10931 | dev_info(&pdev->dev, "DCB init failed %d, disabled\n", err); |
| 10926 | pf->flags &= ~I40E_FLAG_DCB_CAPABLE; | 10932 | pf->flags &= ~(I40E_FLAG_DCB_CAPABLE & I40E_FLAG_DCB_ENABLED); |
| 10927 | /* Continue without DCB enabled */ | 10933 | /* Continue without DCB enabled */ |
| 10928 | } | 10934 | } |
| 10929 | #endif /* CONFIG_I40E_DCB */ | 10935 | #endif /* CONFIG_I40E_DCB */ |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index b4217f30e89c..c47b605e8651 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | |||
| @@ -2958,8 +2958,10 @@ s32 ixgbe_clear_vmdq_generic(struct ixgbe_hw *hw, u32 rar, u32 vmdq) | |||
| 2958 | } | 2958 | } |
| 2959 | 2959 | ||
| 2960 | /* was that the last pool using this rar? */ | 2960 | /* was that the last pool using this rar? */ |
| 2961 | if (mpsar_lo == 0 && mpsar_hi == 0 && rar != 0) | 2961 | if (mpsar_lo == 0 && mpsar_hi == 0 && |
| 2962 | rar != 0 && rar != hw->mac.san_mac_rar_index) | ||
| 2962 | hw->mac.ops.clear_rar(hw, rar); | 2963 | hw->mac.ops.clear_rar(hw, rar); |
| 2964 | |||
| 2963 | return 0; | 2965 | return 0; |
| 2964 | } | 2966 | } |
| 2965 | 2967 | ||
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index f1609542adf1..d9199151a83e 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | |||
| @@ -50,6 +50,10 @@ static const struct mtk_ethtool_stats { | |||
| 50 | MTK_ETHTOOL_STAT(rx_flow_control_packets), | 50 | MTK_ETHTOOL_STAT(rx_flow_control_packets), |
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | static const char * const mtk_clks_source_name[] = { | ||
| 54 | "ethif", "esw", "gp1", "gp2" | ||
| 55 | }; | ||
| 56 | |||
| 53 | void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg) | 57 | void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg) |
| 54 | { | 58 | { |
| 55 | __raw_writel(val, eth->base + reg); | 59 | __raw_writel(val, eth->base + reg); |
| @@ -291,7 +295,7 @@ err_phy: | |||
| 291 | static int mtk_mdio_init(struct mtk_eth *eth) | 295 | static int mtk_mdio_init(struct mtk_eth *eth) |
| 292 | { | 296 | { |
| 293 | struct device_node *mii_np; | 297 | struct device_node *mii_np; |
| 294 | int err; | 298 | int ret; |
| 295 | 299 | ||
| 296 | mii_np = of_get_child_by_name(eth->dev->of_node, "mdio-bus"); | 300 | mii_np = of_get_child_by_name(eth->dev->of_node, "mdio-bus"); |
| 297 | if (!mii_np) { | 301 | if (!mii_np) { |
| @@ -300,13 +304,13 @@ static int mtk_mdio_init(struct mtk_eth *eth) | |||
| 300 | } | 304 | } |
| 301 | 305 | ||
| 302 | if (!of_device_is_available(mii_np)) { | 306 | if (!of_device_is_available(mii_np)) { |
| 303 | err = 0; | 307 | ret = -ENODEV; |
| 304 | goto err_put_node; | 308 | goto err_put_node; |
| 305 | } | 309 | } |
| 306 | 310 | ||
| 307 | eth->mii_bus = mdiobus_alloc(); | 311 | eth->mii_bus = devm_mdiobus_alloc(eth->dev); |
| 308 | if (!eth->mii_bus) { | 312 | if (!eth->mii_bus) { |
| 309 | err = -ENOMEM; | 313 | ret = -ENOMEM; |
| 310 | goto err_put_node; | 314 | goto err_put_node; |
| 311 | } | 315 | } |
| 312 | 316 | ||
| @@ -317,19 +321,11 @@ static int mtk_mdio_init(struct mtk_eth *eth) | |||
| 317 | eth->mii_bus->parent = eth->dev; | 321 | eth->mii_bus->parent = eth->dev; |
| 318 | 322 | ||
| 319 | snprintf(eth->mii_bus->id, MII_BUS_ID_SIZE, "%s", mii_np->name); | 323 | snprintf(eth->mii_bus->id, MII_BUS_ID_SIZE, "%s", mii_np->name); |
| 320 | err = of_mdiobus_register(eth->mii_bus, mii_np); | 324 | ret = of_mdiobus_register(eth->mii_bus, mii_np); |
| 321 | if (err) | ||
| 322 | goto err_free_bus; | ||
| 323 | |||
| 324 | return 0; | ||
| 325 | |||
| 326 | err_free_bus: | ||
| 327 | mdiobus_free(eth->mii_bus); | ||
| 328 | 325 | ||
| 329 | err_put_node: | 326 | err_put_node: |
| 330 | of_node_put(mii_np); | 327 | of_node_put(mii_np); |
| 331 | eth->mii_bus = NULL; | 328 | return ret; |
| 332 | return err; | ||
| 333 | } | 329 | } |
| 334 | 330 | ||
| 335 | static void mtk_mdio_cleanup(struct mtk_eth *eth) | 331 | static void mtk_mdio_cleanup(struct mtk_eth *eth) |
| @@ -338,8 +334,6 @@ static void mtk_mdio_cleanup(struct mtk_eth *eth) | |||
| 338 | return; | 334 | return; |
| 339 | 335 | ||
| 340 | mdiobus_unregister(eth->mii_bus); | 336 | mdiobus_unregister(eth->mii_bus); |
| 341 | of_node_put(eth->mii_bus->dev.of_node); | ||
| 342 | mdiobus_free(eth->mii_bus); | ||
| 343 | } | 337 | } |
| 344 | 338 | ||
| 345 | static inline void mtk_irq_disable(struct mtk_eth *eth, u32 mask) | 339 | static inline void mtk_irq_disable(struct mtk_eth *eth, u32 mask) |
| @@ -588,14 +582,15 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, | |||
| 588 | dma_addr_t mapped_addr; | 582 | dma_addr_t mapped_addr; |
| 589 | unsigned int nr_frags; | 583 | unsigned int nr_frags; |
| 590 | int i, n_desc = 1; | 584 | int i, n_desc = 1; |
| 591 | u32 txd4 = 0; | 585 | u32 txd4 = 0, fport; |
| 592 | 586 | ||
| 593 | itxd = ring->next_free; | 587 | itxd = ring->next_free; |
| 594 | if (itxd == ring->last_free) | 588 | if (itxd == ring->last_free) |
| 595 | return -ENOMEM; | 589 | return -ENOMEM; |
| 596 | 590 | ||
| 597 | /* set the forward port */ | 591 | /* set the forward port */ |
| 598 | txd4 |= (mac->id + 1) << TX_DMA_FPORT_SHIFT; | 592 | fport = (mac->id + 1) << TX_DMA_FPORT_SHIFT; |
| 593 | txd4 |= fport; | ||
| 599 | 594 | ||
| 600 | tx_buf = mtk_desc_to_tx_buf(ring, itxd); | 595 | tx_buf = mtk_desc_to_tx_buf(ring, itxd); |
| 601 | memset(tx_buf, 0, sizeof(*tx_buf)); | 596 | memset(tx_buf, 0, sizeof(*tx_buf)); |
| @@ -653,7 +648,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, | |||
| 653 | WRITE_ONCE(txd->txd3, (TX_DMA_SWC | | 648 | WRITE_ONCE(txd->txd3, (TX_DMA_SWC | |
| 654 | TX_DMA_PLEN0(frag_map_size) | | 649 | TX_DMA_PLEN0(frag_map_size) | |
| 655 | last_frag * TX_DMA_LS0)); | 650 | last_frag * TX_DMA_LS0)); |
| 656 | WRITE_ONCE(txd->txd4, 0); | 651 | WRITE_ONCE(txd->txd4, fport); |
| 657 | 652 | ||
| 658 | tx_buf->skb = (struct sk_buff *)MTK_DMA_DUMMY_DESC; | 653 | tx_buf->skb = (struct sk_buff *)MTK_DMA_DUMMY_DESC; |
| 659 | tx_buf = mtk_desc_to_tx_buf(ring, txd); | 654 | tx_buf = mtk_desc_to_tx_buf(ring, txd); |
| @@ -865,7 +860,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, | |||
| 865 | /* receive data */ | 860 | /* receive data */ |
| 866 | skb = build_skb(data, ring->frag_size); | 861 | skb = build_skb(data, ring->frag_size); |
| 867 | if (unlikely(!skb)) { | 862 | if (unlikely(!skb)) { |
| 868 | put_page(virt_to_head_page(new_data)); | 863 | skb_free_frag(new_data); |
| 869 | netdev->stats.rx_dropped++; | 864 | netdev->stats.rx_dropped++; |
| 870 | goto release_desc; | 865 | goto release_desc; |
| 871 | } | 866 | } |
| @@ -1506,10 +1501,7 @@ static void mtk_uninit(struct net_device *dev) | |||
| 1506 | struct mtk_eth *eth = mac->hw; | 1501 | struct mtk_eth *eth = mac->hw; |
| 1507 | 1502 | ||
| 1508 | phy_disconnect(mac->phy_dev); | 1503 | phy_disconnect(mac->phy_dev); |
| 1509 | mtk_mdio_cleanup(eth); | ||
| 1510 | mtk_irq_disable(eth, ~0); | 1504 | mtk_irq_disable(eth, ~0); |
| 1511 | free_irq(eth->irq[1], dev); | ||
| 1512 | free_irq(eth->irq[2], dev); | ||
| 1513 | } | 1505 | } |
| 1514 | 1506 | ||
| 1515 | static int mtk_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | 1507 | static int mtk_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| @@ -1813,6 +1805,7 @@ static int mtk_probe(struct platform_device *pdev) | |||
| 1813 | if (!eth) | 1805 | if (!eth) |
| 1814 | return -ENOMEM; | 1806 | return -ENOMEM; |
| 1815 | 1807 | ||
| 1808 | eth->dev = &pdev->dev; | ||
| 1816 | eth->base = devm_ioremap_resource(&pdev->dev, res); | 1809 | eth->base = devm_ioremap_resource(&pdev->dev, res); |
| 1817 | if (IS_ERR(eth->base)) | 1810 | if (IS_ERR(eth->base)) |
| 1818 | return PTR_ERR(eth->base); | 1811 | return PTR_ERR(eth->base); |
| @@ -1847,21 +1840,21 @@ static int mtk_probe(struct platform_device *pdev) | |||
| 1847 | return -ENXIO; | 1840 | return -ENXIO; |
| 1848 | } | 1841 | } |
| 1849 | } | 1842 | } |
| 1843 | for (i = 0; i < ARRAY_SIZE(eth->clks); i++) { | ||
| 1844 | eth->clks[i] = devm_clk_get(eth->dev, | ||
| 1845 | mtk_clks_source_name[i]); | ||
| 1846 | if (IS_ERR(eth->clks[i])) { | ||
| 1847 | if (PTR_ERR(eth->clks[i]) == -EPROBE_DEFER) | ||
| 1848 | return -EPROBE_DEFER; | ||
| 1849 | return -ENODEV; | ||
| 1850 | } | ||
| 1851 | } | ||
| 1850 | 1852 | ||
| 1851 | eth->clk_ethif = devm_clk_get(&pdev->dev, "ethif"); | 1853 | clk_prepare_enable(eth->clks[MTK_CLK_ETHIF]); |
| 1852 | eth->clk_esw = devm_clk_get(&pdev->dev, "esw"); | 1854 | clk_prepare_enable(eth->clks[MTK_CLK_ESW]); |
| 1853 | eth->clk_gp1 = devm_clk_get(&pdev->dev, "gp1"); | 1855 | clk_prepare_enable(eth->clks[MTK_CLK_GP1]); |
| 1854 | eth->clk_gp2 = devm_clk_get(&pdev->dev, "gp2"); | 1856 | clk_prepare_enable(eth->clks[MTK_CLK_GP2]); |
| 1855 | if (IS_ERR(eth->clk_esw) || IS_ERR(eth->clk_gp1) || | ||
| 1856 | IS_ERR(eth->clk_gp2) || IS_ERR(eth->clk_ethif)) | ||
| 1857 | return -ENODEV; | ||
| 1858 | |||
| 1859 | clk_prepare_enable(eth->clk_ethif); | ||
| 1860 | clk_prepare_enable(eth->clk_esw); | ||
| 1861 | clk_prepare_enable(eth->clk_gp1); | ||
| 1862 | clk_prepare_enable(eth->clk_gp2); | ||
| 1863 | 1857 | ||
| 1864 | eth->dev = &pdev->dev; | ||
| 1865 | eth->msg_enable = netif_msg_init(mtk_msg_level, MTK_DEFAULT_MSG_ENABLE); | 1858 | eth->msg_enable = netif_msg_init(mtk_msg_level, MTK_DEFAULT_MSG_ENABLE); |
| 1866 | INIT_WORK(ð->pending_work, mtk_pending_work); | 1859 | INIT_WORK(ð->pending_work, mtk_pending_work); |
| 1867 | 1860 | ||
| @@ -1903,15 +1896,24 @@ err_free_dev: | |||
| 1903 | static int mtk_remove(struct platform_device *pdev) | 1896 | static int mtk_remove(struct platform_device *pdev) |
| 1904 | { | 1897 | { |
| 1905 | struct mtk_eth *eth = platform_get_drvdata(pdev); | 1898 | struct mtk_eth *eth = platform_get_drvdata(pdev); |
| 1899 | int i; | ||
| 1906 | 1900 | ||
| 1907 | clk_disable_unprepare(eth->clk_ethif); | 1901 | /* stop all devices to make sure that dma is properly shut down */ |
| 1908 | clk_disable_unprepare(eth->clk_esw); | 1902 | for (i = 0; i < MTK_MAC_COUNT; i++) { |
| 1909 | clk_disable_unprepare(eth->clk_gp1); | 1903 | if (!eth->netdev[i]) |
| 1910 | clk_disable_unprepare(eth->clk_gp2); | 1904 | continue; |
| 1905 | mtk_stop(eth->netdev[i]); | ||
| 1906 | } | ||
| 1907 | |||
| 1908 | clk_disable_unprepare(eth->clks[MTK_CLK_ETHIF]); | ||
| 1909 | clk_disable_unprepare(eth->clks[MTK_CLK_ESW]); | ||
| 1910 | clk_disable_unprepare(eth->clks[MTK_CLK_GP1]); | ||
| 1911 | clk_disable_unprepare(eth->clks[MTK_CLK_GP2]); | ||
| 1911 | 1912 | ||
| 1912 | netif_napi_del(ð->tx_napi); | 1913 | netif_napi_del(ð->tx_napi); |
| 1913 | netif_napi_del(ð->rx_napi); | 1914 | netif_napi_del(ð->rx_napi); |
| 1914 | mtk_cleanup(eth); | 1915 | mtk_cleanup(eth); |
| 1916 | mtk_mdio_cleanup(eth); | ||
| 1915 | platform_set_drvdata(pdev, NULL); | 1917 | platform_set_drvdata(pdev, NULL); |
| 1916 | 1918 | ||
| 1917 | return 0; | 1919 | return 0; |
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index f82e3acb947b..6e1ade7a25c5 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h | |||
| @@ -290,6 +290,17 @@ enum mtk_tx_flags { | |||
| 290 | MTK_TX_FLAGS_PAGE0 = 0x02, | 290 | MTK_TX_FLAGS_PAGE0 = 0x02, |
| 291 | }; | 291 | }; |
| 292 | 292 | ||
| 293 | /* This enum allows us to identify how the clock is defined on the array of the | ||
| 294 | * clock in the order | ||
| 295 | */ | ||
| 296 | enum mtk_clks_map { | ||
| 297 | MTK_CLK_ETHIF, | ||
| 298 | MTK_CLK_ESW, | ||
| 299 | MTK_CLK_GP1, | ||
| 300 | MTK_CLK_GP2, | ||
| 301 | MTK_CLK_MAX | ||
| 302 | }; | ||
| 303 | |||
| 293 | /* struct mtk_tx_buf - This struct holds the pointers to the memory pointed at | 304 | /* struct mtk_tx_buf - This struct holds the pointers to the memory pointed at |
| 294 | * by the TX descriptor s | 305 | * by the TX descriptor s |
| 295 | * @skb: The SKB pointer of the packet being sent | 306 | * @skb: The SKB pointer of the packet being sent |
| @@ -370,10 +381,7 @@ struct mtk_rx_ring { | |||
| 370 | * @scratch_ring: Newer SoCs need memory for a second HW managed TX ring | 381 | * @scratch_ring: Newer SoCs need memory for a second HW managed TX ring |
| 371 | * @phy_scratch_ring: physical address of scratch_ring | 382 | * @phy_scratch_ring: physical address of scratch_ring |
| 372 | * @scratch_head: The scratch memory that scratch_ring points to. | 383 | * @scratch_head: The scratch memory that scratch_ring points to. |
| 373 | * @clk_ethif: The ethif clock | 384 | * @clks: clock array for all clocks required |
| 374 | * @clk_esw: The switch clock | ||
| 375 | * @clk_gp1: The gmac1 clock | ||
| 376 | * @clk_gp2: The gmac2 clock | ||
| 377 | * @mii_bus: If there is a bus we need to create an instance for it | 385 | * @mii_bus: If there is a bus we need to create an instance for it |
| 378 | * @pending_work: The workqueue used to reset the dma ring | 386 | * @pending_work: The workqueue used to reset the dma ring |
| 379 | */ | 387 | */ |
| @@ -400,10 +408,8 @@ struct mtk_eth { | |||
| 400 | struct mtk_tx_dma *scratch_ring; | 408 | struct mtk_tx_dma *scratch_ring; |
| 401 | dma_addr_t phy_scratch_ring; | 409 | dma_addr_t phy_scratch_ring; |
| 402 | void *scratch_head; | 410 | void *scratch_head; |
| 403 | struct clk *clk_ethif; | 411 | struct clk *clks[MTK_CLK_MAX]; |
| 404 | struct clk *clk_esw; | 412 | |
| 405 | struct clk *clk_gp1; | ||
| 406 | struct clk *clk_gp2; | ||
| 407 | struct mii_bus *mii_bus; | 413 | struct mii_bus *mii_bus; |
| 408 | struct work_struct pending_work; | 414 | struct work_struct pending_work; |
| 409 | }; | 415 | }; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c index 99c6bbdff501..b04760a5034b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c | |||
| @@ -94,7 +94,7 @@ static u8 mlx4_en_dcbnl_getcap(struct net_device *dev, int capid, u8 *cap) | |||
| 94 | *cap = true; | 94 | *cap = true; |
| 95 | break; | 95 | break; |
| 96 | case DCB_CAP_ATTR_DCBX: | 96 | case DCB_CAP_ATTR_DCBX: |
| 97 | *cap = priv->cee_params.dcbx_cap; | 97 | *cap = priv->dcbx_cap; |
| 98 | break; | 98 | break; |
| 99 | case DCB_CAP_ATTR_PFC_TCS: | 99 | case DCB_CAP_ATTR_PFC_TCS: |
| 100 | *cap = 1 << mlx4_max_tc(priv->mdev->dev); | 100 | *cap = 1 << mlx4_max_tc(priv->mdev->dev); |
| @@ -111,14 +111,14 @@ static u8 mlx4_en_dcbnl_getpfcstate(struct net_device *netdev) | |||
| 111 | { | 111 | { |
| 112 | struct mlx4_en_priv *priv = netdev_priv(netdev); | 112 | struct mlx4_en_priv *priv = netdev_priv(netdev); |
| 113 | 113 | ||
| 114 | return priv->cee_params.dcb_cfg.pfc_state; | 114 | return priv->cee_config.pfc_state; |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | static void mlx4_en_dcbnl_setpfcstate(struct net_device *netdev, u8 state) | 117 | static void mlx4_en_dcbnl_setpfcstate(struct net_device *netdev, u8 state) |
| 118 | { | 118 | { |
| 119 | struct mlx4_en_priv *priv = netdev_priv(netdev); | 119 | struct mlx4_en_priv *priv = netdev_priv(netdev); |
| 120 | 120 | ||
| 121 | priv->cee_params.dcb_cfg.pfc_state = state; | 121 | priv->cee_config.pfc_state = state; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | static void mlx4_en_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority, | 124 | static void mlx4_en_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority, |
| @@ -126,7 +126,7 @@ static void mlx4_en_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority, | |||
| 126 | { | 126 | { |
| 127 | struct mlx4_en_priv *priv = netdev_priv(netdev); | 127 | struct mlx4_en_priv *priv = netdev_priv(netdev); |
| 128 | 128 | ||
| 129 | *setting = priv->cee_params.dcb_cfg.tc_config[priority].dcb_pfc; | 129 | *setting = priv->cee_config.dcb_pfc[priority]; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | static void mlx4_en_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority, | 132 | static void mlx4_en_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority, |
| @@ -134,8 +134,8 @@ static void mlx4_en_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority, | |||
| 134 | { | 134 | { |
| 135 | struct mlx4_en_priv *priv = netdev_priv(netdev); | 135 | struct mlx4_en_priv *priv = netdev_priv(netdev); |
| 136 | 136 | ||
| 137 | priv->cee_params.dcb_cfg.tc_config[priority].dcb_pfc = setting; | 137 | priv->cee_config.dcb_pfc[priority] = setting; |
| 138 | priv->cee_params.dcb_cfg.pfc_state = true; | 138 | priv->cee_config.pfc_state = true; |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | static int mlx4_en_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num) | 141 | static int mlx4_en_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num) |
| @@ -157,13 +157,11 @@ static u8 mlx4_en_dcbnl_set_all(struct net_device *netdev) | |||
| 157 | { | 157 | { |
| 158 | struct mlx4_en_priv *priv = netdev_priv(netdev); | 158 | struct mlx4_en_priv *priv = netdev_priv(netdev); |
| 159 | struct mlx4_en_dev *mdev = priv->mdev; | 159 | struct mlx4_en_dev *mdev = priv->mdev; |
| 160 | struct mlx4_en_cee_config *dcb_cfg = &priv->cee_params.dcb_cfg; | ||
| 161 | int err = 0; | ||
| 162 | 160 | ||
| 163 | if (!(priv->cee_params.dcbx_cap & DCB_CAP_DCBX_VER_CEE)) | 161 | if (!(priv->dcbx_cap & DCB_CAP_DCBX_VER_CEE)) |
| 164 | return -EINVAL; | 162 | return 1; |
| 165 | 163 | ||
| 166 | if (dcb_cfg->pfc_state) { | 164 | if (priv->cee_config.pfc_state) { |
| 167 | int tc; | 165 | int tc; |
| 168 | 166 | ||
| 169 | priv->prof->rx_pause = 0; | 167 | priv->prof->rx_pause = 0; |
| @@ -171,7 +169,7 @@ static u8 mlx4_en_dcbnl_set_all(struct net_device *netdev) | |||
| 171 | for (tc = 0; tc < CEE_DCBX_MAX_PRIO; tc++) { | 169 | for (tc = 0; tc < CEE_DCBX_MAX_PRIO; tc++) { |
| 172 | u8 tc_mask = 1 << tc; | 170 | u8 tc_mask = 1 << tc; |
| 173 | 171 | ||
| 174 | switch (dcb_cfg->tc_config[tc].dcb_pfc) { | 172 | switch (priv->cee_config.dcb_pfc[tc]) { |
| 175 | case pfc_disabled: | 173 | case pfc_disabled: |
| 176 | priv->prof->tx_ppp &= ~tc_mask; | 174 | priv->prof->tx_ppp &= ~tc_mask; |
| 177 | priv->prof->rx_ppp &= ~tc_mask; | 175 | priv->prof->rx_ppp &= ~tc_mask; |
| @@ -199,15 +197,17 @@ static u8 mlx4_en_dcbnl_set_all(struct net_device *netdev) | |||
| 199 | en_dbg(DRV, priv, "Set pfc off\n"); | 197 | en_dbg(DRV, priv, "Set pfc off\n"); |
| 200 | } | 198 | } |
| 201 | 199 | ||
| 202 | err = mlx4_SET_PORT_general(mdev->dev, priv->port, | 200 | if (mlx4_SET_PORT_general(mdev->dev, priv->port, |
| 203 | priv->rx_skb_size + ETH_FCS_LEN, | 201 | priv->rx_skb_size + ETH_FCS_LEN, |
| 204 | priv->prof->tx_pause, | 202 | priv->prof->tx_pause, |
| 205 | priv->prof->tx_ppp, | 203 | priv->prof->tx_ppp, |
| 206 | priv->prof->rx_pause, | 204 | priv->prof->rx_pause, |
| 207 | priv->prof->rx_ppp); | 205 | priv->prof->rx_ppp)) { |
| 208 | if (err) | ||
| 209 | en_err(priv, "Failed setting pause params\n"); | 206 | en_err(priv, "Failed setting pause params\n"); |
| 210 | return err; | 207 | return 1; |
| 208 | } | ||
| 209 | |||
| 210 | return 0; | ||
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | static u8 mlx4_en_dcbnl_get_state(struct net_device *dev) | 213 | static u8 mlx4_en_dcbnl_get_state(struct net_device *dev) |
| @@ -225,7 +225,7 @@ static u8 mlx4_en_dcbnl_set_state(struct net_device *dev, u8 state) | |||
| 225 | struct mlx4_en_priv *priv = netdev_priv(dev); | 225 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 226 | int num_tcs = 0; | 226 | int num_tcs = 0; |
| 227 | 227 | ||
| 228 | if (!(priv->cee_params.dcbx_cap & DCB_CAP_DCBX_VER_CEE)) | 228 | if (!(priv->dcbx_cap & DCB_CAP_DCBX_VER_CEE)) |
| 229 | return 1; | 229 | return 1; |
| 230 | 230 | ||
| 231 | if (!!(state) == !!(priv->flags & MLX4_EN_FLAG_DCB_ENABLED)) | 231 | if (!!(state) == !!(priv->flags & MLX4_EN_FLAG_DCB_ENABLED)) |
| @@ -238,7 +238,10 @@ static u8 mlx4_en_dcbnl_set_state(struct net_device *dev, u8 state) | |||
| 238 | priv->flags &= ~MLX4_EN_FLAG_DCB_ENABLED; | 238 | priv->flags &= ~MLX4_EN_FLAG_DCB_ENABLED; |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | return mlx4_en_setup_tc(dev, num_tcs); | 241 | if (mlx4_en_setup_tc(dev, num_tcs)) |
| 242 | return 1; | ||
| 243 | |||
| 244 | return 0; | ||
| 242 | } | 245 | } |
| 243 | 246 | ||
| 244 | /* On success returns a non-zero 802.1p user priority bitmap | 247 | /* On success returns a non-zero 802.1p user priority bitmap |
| @@ -252,7 +255,7 @@ static int mlx4_en_dcbnl_getapp(struct net_device *netdev, u8 idtype, u16 id) | |||
| 252 | .selector = idtype, | 255 | .selector = idtype, |
| 253 | .protocol = id, | 256 | .protocol = id, |
| 254 | }; | 257 | }; |
| 255 | if (!(priv->cee_params.dcbx_cap & DCB_CAP_DCBX_VER_CEE)) | 258 | if (!(priv->dcbx_cap & DCB_CAP_DCBX_VER_CEE)) |
| 256 | return 0; | 259 | return 0; |
| 257 | 260 | ||
| 258 | return dcb_getapp(netdev, &app); | 261 | return dcb_getapp(netdev, &app); |
| @@ -264,7 +267,7 @@ static int mlx4_en_dcbnl_setapp(struct net_device *netdev, u8 idtype, | |||
| 264 | struct mlx4_en_priv *priv = netdev_priv(netdev); | 267 | struct mlx4_en_priv *priv = netdev_priv(netdev); |
| 265 | struct dcb_app app; | 268 | struct dcb_app app; |
| 266 | 269 | ||
| 267 | if (!(priv->cee_params.dcbx_cap & DCB_CAP_DCBX_VER_CEE)) | 270 | if (!(priv->dcbx_cap & DCB_CAP_DCBX_VER_CEE)) |
| 268 | return -EINVAL; | 271 | return -EINVAL; |
| 269 | 272 | ||
| 270 | memset(&app, 0, sizeof(struct dcb_app)); | 273 | memset(&app, 0, sizeof(struct dcb_app)); |
| @@ -433,7 +436,7 @@ static u8 mlx4_en_dcbnl_getdcbx(struct net_device *dev) | |||
| 433 | { | 436 | { |
| 434 | struct mlx4_en_priv *priv = netdev_priv(dev); | 437 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 435 | 438 | ||
| 436 | return priv->cee_params.dcbx_cap; | 439 | return priv->dcbx_cap; |
| 437 | } | 440 | } |
| 438 | 441 | ||
| 439 | static u8 mlx4_en_dcbnl_setdcbx(struct net_device *dev, u8 mode) | 442 | static u8 mlx4_en_dcbnl_setdcbx(struct net_device *dev, u8 mode) |
| @@ -442,7 +445,7 @@ static u8 mlx4_en_dcbnl_setdcbx(struct net_device *dev, u8 mode) | |||
| 442 | struct ieee_ets ets = {0}; | 445 | struct ieee_ets ets = {0}; |
| 443 | struct ieee_pfc pfc = {0}; | 446 | struct ieee_pfc pfc = {0}; |
| 444 | 447 | ||
| 445 | if (mode == priv->cee_params.dcbx_cap) | 448 | if (mode == priv->dcbx_cap) |
| 446 | return 0; | 449 | return 0; |
| 447 | 450 | ||
| 448 | if ((mode & DCB_CAP_DCBX_LLD_MANAGED) || | 451 | if ((mode & DCB_CAP_DCBX_LLD_MANAGED) || |
| @@ -451,7 +454,7 @@ static u8 mlx4_en_dcbnl_setdcbx(struct net_device *dev, u8 mode) | |||
| 451 | !(mode & DCB_CAP_DCBX_HOST)) | 454 | !(mode & DCB_CAP_DCBX_HOST)) |
| 452 | goto err; | 455 | goto err; |
| 453 | 456 | ||
| 454 | priv->cee_params.dcbx_cap = mode; | 457 | priv->dcbx_cap = mode; |
| 455 | 458 | ||
| 456 | ets.ets_cap = IEEE_8021QAZ_MAX_TCS; | 459 | ets.ets_cap = IEEE_8021QAZ_MAX_TCS; |
| 457 | pfc.pfc_cap = IEEE_8021QAZ_MAX_TCS; | 460 | pfc.pfc_cap = IEEE_8021QAZ_MAX_TCS; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 4198e9bf89d0..fedb829276f4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c | |||
| @@ -71,10 +71,11 @@ int mlx4_en_setup_tc(struct net_device *dev, u8 up) | |||
| 71 | #ifdef CONFIG_MLX4_EN_DCB | 71 | #ifdef CONFIG_MLX4_EN_DCB |
| 72 | if (!mlx4_is_slave(priv->mdev->dev)) { | 72 | if (!mlx4_is_slave(priv->mdev->dev)) { |
| 73 | if (up) { | 73 | if (up) { |
| 74 | priv->flags |= MLX4_EN_FLAG_DCB_ENABLED; | 74 | if (priv->dcbx_cap) |
| 75 | priv->flags |= MLX4_EN_FLAG_DCB_ENABLED; | ||
| 75 | } else { | 76 | } else { |
| 76 | priv->flags &= ~MLX4_EN_FLAG_DCB_ENABLED; | 77 | priv->flags &= ~MLX4_EN_FLAG_DCB_ENABLED; |
| 77 | priv->cee_params.dcb_cfg.pfc_state = false; | 78 | priv->cee_config.pfc_state = false; |
| 78 | } | 79 | } |
| 79 | } | 80 | } |
| 80 | #endif /* CONFIG_MLX4_EN_DCB */ | 81 | #endif /* CONFIG_MLX4_EN_DCB */ |
| @@ -3048,9 +3049,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, | |||
| 3048 | struct mlx4_en_priv *priv; | 3049 | struct mlx4_en_priv *priv; |
| 3049 | int i; | 3050 | int i; |
| 3050 | int err; | 3051 | int err; |
| 3051 | #ifdef CONFIG_MLX4_EN_DCB | ||
| 3052 | struct tc_configuration *tc; | ||
| 3053 | #endif | ||
| 3054 | 3052 | ||
| 3055 | dev = alloc_etherdev_mqs(sizeof(struct mlx4_en_priv), | 3053 | dev = alloc_etherdev_mqs(sizeof(struct mlx4_en_priv), |
| 3056 | MAX_TX_RINGS, MAX_RX_RINGS); | 3054 | MAX_TX_RINGS, MAX_RX_RINGS); |
| @@ -3117,16 +3115,13 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, | |||
| 3117 | priv->msg_enable = MLX4_EN_MSG_LEVEL; | 3115 | priv->msg_enable = MLX4_EN_MSG_LEVEL; |
| 3118 | #ifdef CONFIG_MLX4_EN_DCB | 3116 | #ifdef CONFIG_MLX4_EN_DCB |
| 3119 | if (!mlx4_is_slave(priv->mdev->dev)) { | 3117 | if (!mlx4_is_slave(priv->mdev->dev)) { |
| 3120 | priv->cee_params.dcbx_cap = DCB_CAP_DCBX_VER_CEE | | 3118 | priv->dcbx_cap = DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_HOST | |
| 3121 | DCB_CAP_DCBX_HOST | | 3119 | DCB_CAP_DCBX_VER_IEEE; |
| 3122 | DCB_CAP_DCBX_VER_IEEE; | ||
| 3123 | priv->flags |= MLX4_EN_DCB_ENABLED; | 3120 | priv->flags |= MLX4_EN_DCB_ENABLED; |
| 3124 | priv->cee_params.dcb_cfg.pfc_state = false; | 3121 | priv->cee_config.pfc_state = false; |
| 3125 | 3122 | ||
| 3126 | for (i = 0; i < MLX4_EN_NUM_UP; i++) { | 3123 | for (i = 0; i < MLX4_EN_NUM_UP; i++) |
| 3127 | tc = &priv->cee_params.dcb_cfg.tc_config[i]; | 3124 | priv->cee_config.dcb_pfc[i] = pfc_disabled; |
| 3128 | tc->dcb_pfc = pfc_disabled; | ||
| 3129 | } | ||
| 3130 | 3125 | ||
| 3131 | if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ETS_CFG) { | 3126 | if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ETS_CFG) { |
| 3132 | dev->dcbnl_ops = &mlx4_en_dcbnl_ops; | 3127 | dev->dcbnl_ops = &mlx4_en_dcbnl_ops; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 9df87ca0515a..e2509bba3e7c 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c | |||
| @@ -818,7 +818,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 818 | real_size = get_real_size(skb, shinfo, dev, &lso_header_size, | 818 | real_size = get_real_size(skb, shinfo, dev, &lso_header_size, |
| 819 | &inline_ok, &fragptr); | 819 | &inline_ok, &fragptr); |
| 820 | if (unlikely(!real_size)) | 820 | if (unlikely(!real_size)) |
| 821 | goto tx_drop; | 821 | goto tx_drop_count; |
| 822 | 822 | ||
| 823 | /* Align descriptor to TXBB size */ | 823 | /* Align descriptor to TXBB size */ |
| 824 | desc_size = ALIGN(real_size, TXBB_SIZE); | 824 | desc_size = ALIGN(real_size, TXBB_SIZE); |
| @@ -826,7 +826,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 826 | if (unlikely(nr_txbb > MAX_DESC_TXBBS)) { | 826 | if (unlikely(nr_txbb > MAX_DESC_TXBBS)) { |
| 827 | if (netif_msg_tx_err(priv)) | 827 | if (netif_msg_tx_err(priv)) |
| 828 | en_warn(priv, "Oversized header or SG list\n"); | 828 | en_warn(priv, "Oversized header or SG list\n"); |
| 829 | goto tx_drop; | 829 | goto tx_drop_count; |
| 830 | } | 830 | } |
| 831 | 831 | ||
| 832 | bf_ok = ring->bf_enabled; | 832 | bf_ok = ring->bf_enabled; |
| @@ -1071,9 +1071,10 @@ tx_drop_unmap: | |||
| 1071 | PCI_DMA_TODEVICE); | 1071 | PCI_DMA_TODEVICE); |
| 1072 | } | 1072 | } |
| 1073 | 1073 | ||
| 1074 | tx_drop_count: | ||
| 1075 | ring->tx_dropped++; | ||
| 1074 | tx_drop: | 1076 | tx_drop: |
| 1075 | dev_kfree_skb_any(skb); | 1077 | dev_kfree_skb_any(skb); |
| 1076 | ring->tx_dropped++; | ||
| 1077 | return NETDEV_TX_OK; | 1078 | return NETDEV_TX_OK; |
| 1078 | } | 1079 | } |
| 1079 | 1080 | ||
| @@ -1106,7 +1107,7 @@ netdev_tx_t mlx4_en_xmit_frame(struct mlx4_en_rx_alloc *frame, | |||
| 1106 | goto tx_drop; | 1107 | goto tx_drop; |
| 1107 | 1108 | ||
| 1108 | if (mlx4_en_is_tx_ring_full(ring)) | 1109 | if (mlx4_en_is_tx_ring_full(ring)) |
| 1109 | goto tx_drop; | 1110 | goto tx_drop_count; |
| 1110 | 1111 | ||
| 1111 | /* fetch ring->cons far ahead before needing it to avoid stall */ | 1112 | /* fetch ring->cons far ahead before needing it to avoid stall */ |
| 1112 | ring_cons = READ_ONCE(ring->cons); | 1113 | ring_cons = READ_ONCE(ring->cons); |
| @@ -1176,7 +1177,8 @@ netdev_tx_t mlx4_en_xmit_frame(struct mlx4_en_rx_alloc *frame, | |||
| 1176 | 1177 | ||
| 1177 | return NETDEV_TX_OK; | 1178 | return NETDEV_TX_OK; |
| 1178 | 1179 | ||
| 1179 | tx_drop: | 1180 | tx_drop_count: |
| 1180 | ring->tx_dropped++; | 1181 | ring->tx_dropped++; |
| 1182 | tx_drop: | ||
| 1181 | return NETDEV_TX_BUSY; | 1183 | return NETDEV_TX_BUSY; |
| 1182 | } | 1184 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index 2c2913dcae98..9099dbd04951 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | |||
| @@ -482,20 +482,10 @@ enum dcb_pfc_type { | |||
| 482 | pfc_enabled_rx | 482 | pfc_enabled_rx |
| 483 | }; | 483 | }; |
| 484 | 484 | ||
| 485 | struct tc_configuration { | ||
| 486 | enum dcb_pfc_type dcb_pfc; | ||
| 487 | }; | ||
| 488 | |||
| 489 | struct mlx4_en_cee_config { | 485 | struct mlx4_en_cee_config { |
| 490 | bool pfc_state; | 486 | bool pfc_state; |
| 491 | struct tc_configuration tc_config[MLX4_EN_NUM_UP]; | 487 | enum dcb_pfc_type dcb_pfc[MLX4_EN_NUM_UP]; |
| 492 | }; | 488 | }; |
| 493 | |||
| 494 | struct mlx4_en_cee_params { | ||
| 495 | u8 dcbx_cap; | ||
| 496 | struct mlx4_en_cee_config dcb_cfg; | ||
| 497 | }; | ||
| 498 | |||
| 499 | #endif | 489 | #endif |
| 500 | 490 | ||
| 501 | struct ethtool_flow_id { | 491 | struct ethtool_flow_id { |
| @@ -624,7 +614,8 @@ struct mlx4_en_priv { | |||
| 624 | struct ieee_ets ets; | 614 | struct ieee_ets ets; |
| 625 | u16 maxrate[IEEE_8021QAZ_MAX_TCS]; | 615 | u16 maxrate[IEEE_8021QAZ_MAX_TCS]; |
| 626 | enum dcbnl_cndd_states cndd_state[IEEE_8021QAZ_MAX_TCS]; | 616 | enum dcbnl_cndd_states cndd_state[IEEE_8021QAZ_MAX_TCS]; |
| 627 | struct mlx4_en_cee_params cee_params; | 617 | struct mlx4_en_cee_config cee_config; |
| 618 | u8 dcbx_cap; | ||
| 628 | #endif | 619 | #endif |
| 629 | #ifdef CONFIG_RFS_ACCEL | 620 | #ifdef CONFIG_RFS_ACCEL |
| 630 | spinlock_t filters_lock; | 621 | spinlock_t filters_lock; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c index 3d2095e5c61c..c5b2064297a1 100644 --- a/drivers/net/ethernet/mellanox/mlx4/port.c +++ b/drivers/net/ethernet/mellanox/mlx4/port.c | |||
| @@ -52,7 +52,7 @@ | |||
| 52 | 52 | ||
| 53 | #define MLX4_FLAG_V_IGNORE_FCS_MASK 0x2 | 53 | #define MLX4_FLAG_V_IGNORE_FCS_MASK 0x2 |
| 54 | #define MLX4_IGNORE_FCS_MASK 0x1 | 54 | #define MLX4_IGNORE_FCS_MASK 0x1 |
| 55 | #define MLNX4_TX_MAX_NUMBER 8 | 55 | #define MLX4_TC_MAX_NUMBER 8 |
| 56 | 56 | ||
| 57 | void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table) | 57 | void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table) |
| 58 | { | 58 | { |
| @@ -2022,7 +2022,7 @@ int mlx4_max_tc(struct mlx4_dev *dev) | |||
| 2022 | u8 num_tc = dev->caps.max_tc_eth; | 2022 | u8 num_tc = dev->caps.max_tc_eth; |
| 2023 | 2023 | ||
| 2024 | if (!num_tc) | 2024 | if (!num_tc) |
| 2025 | num_tc = MLNX4_TX_MAX_NUMBER; | 2025 | num_tc = MLX4_TC_MAX_NUMBER; |
| 2026 | 2026 | ||
| 2027 | return num_tc; | 2027 | return num_tc; |
| 2028 | } | 2028 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c index d6e2a1cae19a..c2ec01a22d55 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c | |||
| @@ -143,13 +143,14 @@ static struct mlx5_cmd_layout *get_inst(struct mlx5_cmd *cmd, int idx) | |||
| 143 | return cmd->cmd_buf + (idx << cmd->log_stride); | 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 | u8 *ptr = buf; | 148 | u8 *ptr = buf; |
| 149 | u8 sum = 0; | 149 | u8 sum = 0; |
| 150 | int i; | 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 | sum ^= ptr[i]; | 154 | sum ^= ptr[i]; |
| 154 | 155 | ||
| 155 | return sum; | 156 | return sum; |
| @@ -157,41 +158,49 @@ static u8 xor8_buf(void *buf, int len) | |||
| 157 | 158 | ||
| 158 | static int verify_block_sig(struct mlx5_cmd_prot_block *block) | 159 | static int verify_block_sig(struct mlx5_cmd_prot_block *block) |
| 159 | { | 160 | { |
| 160 | if (xor8_buf(block->rsvd0, sizeof(*block) - sizeof(block->data) - 1) != 0xff) | 161 | size_t rsvd0_off = offsetof(struct mlx5_cmd_prot_block, rsvd0); |
| 162 | int xor_len = sizeof(*block) - sizeof(block->data) - 1; | ||
| 163 | |||
| 164 | if (xor8_buf(block, rsvd0_off, xor_len) != 0xff) | ||
| 161 | return -EINVAL; | 165 | return -EINVAL; |
| 162 | 166 | ||
| 163 | if (xor8_buf(block, sizeof(*block)) != 0xff) | 167 | if (xor8_buf(block, 0, sizeof(*block)) != 0xff) |
| 164 | return -EINVAL; | 168 | return -EINVAL; |
| 165 | 169 | ||
| 166 | return 0; | 170 | return 0; |
| 167 | } | 171 | } |
| 168 | 172 | ||
| 169 | static void calc_block_sig(struct mlx5_cmd_prot_block *block, u8 token, | 173 | static void calc_block_sig(struct mlx5_cmd_prot_block *block) |
| 170 | int csum) | ||
| 171 | { | 174 | { |
| 172 | block->token = token; | 175 | int ctrl_xor_len = sizeof(*block) - sizeof(block->data) - 2; |
| 173 | if (csum) { | 176 | size_t rsvd0_off = offsetof(struct mlx5_cmd_prot_block, rsvd0); |
| 174 | block->ctrl_sig = ~xor8_buf(block->rsvd0, sizeof(*block) - | 177 | |
| 175 | sizeof(block->data) - 2); | 178 | block->ctrl_sig = ~xor8_buf(block, rsvd0_off, ctrl_xor_len); |
| 176 | block->sig = ~xor8_buf(block, sizeof(*block) - 1); | 179 | block->sig = ~xor8_buf(block, 0, sizeof(*block) - 1); |
| 177 | } | ||
| 178 | } | 180 | } |
| 179 | 181 | ||
| 180 | static void calc_chain_sig(struct mlx5_cmd_msg *msg, u8 token, int csum) | 182 | static void calc_chain_sig(struct mlx5_cmd_msg *msg) |
| 181 | { | 183 | { |
| 182 | struct mlx5_cmd_mailbox *next = msg->next; | 184 | struct mlx5_cmd_mailbox *next = msg->next; |
| 183 | 185 | int size = msg->len; | |
| 184 | while (next) { | 186 | int blen = size - min_t(int, sizeof(msg->first.data), size); |
| 185 | calc_block_sig(next->buf, token, csum); | 187 | int n = (blen + MLX5_CMD_DATA_BLOCK_SIZE - 1) |
| 188 | / MLX5_CMD_DATA_BLOCK_SIZE; | ||
| 189 | int i = 0; | ||
| 190 | |||
| 191 | for (i = 0; i < n && next; i++) { | ||
| 192 | calc_block_sig(next->buf); | ||
| 186 | next = next->next; | 193 | next = next->next; |
| 187 | } | 194 | } |
| 188 | } | 195 | } |
| 189 | 196 | ||
| 190 | static void set_signature(struct mlx5_cmd_work_ent *ent, int csum) | 197 | static void set_signature(struct mlx5_cmd_work_ent *ent, int csum) |
| 191 | { | 198 | { |
| 192 | ent->lay->sig = ~xor8_buf(ent->lay, sizeof(*ent->lay)); | 199 | ent->lay->sig = ~xor8_buf(ent->lay, 0, sizeof(*ent->lay)); |
| 193 | calc_chain_sig(ent->in, ent->token, csum); | 200 | if (csum) { |
| 194 | calc_chain_sig(ent->out, ent->token, csum); | 201 | calc_chain_sig(ent->in); |
| 202 | calc_chain_sig(ent->out); | ||
| 203 | } | ||
| 195 | } | 204 | } |
| 196 | 205 | ||
| 197 | static void poll_timeout(struct mlx5_cmd_work_ent *ent) | 206 | static void poll_timeout(struct mlx5_cmd_work_ent *ent) |
| @@ -222,12 +231,17 @@ static int verify_signature(struct mlx5_cmd_work_ent *ent) | |||
| 222 | struct mlx5_cmd_mailbox *next = ent->out->next; | 231 | struct mlx5_cmd_mailbox *next = ent->out->next; |
| 223 | int err; | 232 | int err; |
| 224 | u8 sig; | 233 | u8 sig; |
| 234 | int size = ent->out->len; | ||
| 235 | int blen = size - min_t(int, sizeof(ent->out->first.data), size); | ||
| 236 | int n = (blen + MLX5_CMD_DATA_BLOCK_SIZE - 1) | ||
| 237 | / MLX5_CMD_DATA_BLOCK_SIZE; | ||
| 238 | int i = 0; | ||
| 225 | 239 | ||
| 226 | sig = xor8_buf(ent->lay, sizeof(*ent->lay)); | 240 | sig = xor8_buf(ent->lay, 0, sizeof(*ent->lay)); |
| 227 | if (sig != 0xff) | 241 | if (sig != 0xff) |
| 228 | return -EINVAL; | 242 | return -EINVAL; |
| 229 | 243 | ||
| 230 | while (next) { | 244 | for (i = 0; i < n && next; i++) { |
| 231 | err = verify_block_sig(next->buf); | 245 | err = verify_block_sig(next->buf); |
| 232 | if (err) | 246 | if (err) |
| 233 | return err; | 247 | return err; |
| @@ -656,7 +670,6 @@ static void cmd_work_handler(struct work_struct *work) | |||
| 656 | spin_unlock_irqrestore(&cmd->alloc_lock, flags); | 670 | spin_unlock_irqrestore(&cmd->alloc_lock, flags); |
| 657 | } | 671 | } |
| 658 | 672 | ||
| 659 | ent->token = alloc_token(cmd); | ||
| 660 | cmd->ent_arr[ent->idx] = ent; | 673 | cmd->ent_arr[ent->idx] = ent; |
| 661 | lay = get_inst(cmd, ent->idx); | 674 | lay = get_inst(cmd, ent->idx); |
| 662 | ent->lay = lay; | 675 | ent->lay = lay; |
| @@ -766,7 +779,8 @@ static u8 *get_status_ptr(struct mlx5_outbox_hdr *out) | |||
| 766 | static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, | 779 | static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, |
| 767 | struct mlx5_cmd_msg *out, void *uout, int uout_size, | 780 | struct mlx5_cmd_msg *out, void *uout, int uout_size, |
| 768 | mlx5_cmd_cbk_t callback, | 781 | mlx5_cmd_cbk_t callback, |
| 769 | void *context, int page_queue, u8 *status) | 782 | void *context, int page_queue, u8 *status, |
| 783 | u8 token) | ||
| 770 | { | 784 | { |
| 771 | struct mlx5_cmd *cmd = &dev->cmd; | 785 | struct mlx5_cmd *cmd = &dev->cmd; |
| 772 | struct mlx5_cmd_work_ent *ent; | 786 | struct mlx5_cmd_work_ent *ent; |
| @@ -783,6 +797,8 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, | |||
| 783 | if (IS_ERR(ent)) | 797 | if (IS_ERR(ent)) |
| 784 | return PTR_ERR(ent); | 798 | return PTR_ERR(ent); |
| 785 | 799 | ||
| 800 | ent->token = token; | ||
| 801 | |||
| 786 | if (!callback) | 802 | if (!callback) |
| 787 | init_completion(&ent->done); | 803 | init_completion(&ent->done); |
| 788 | 804 | ||
| @@ -854,7 +870,8 @@ static const struct file_operations fops = { | |||
| 854 | .write = dbg_write, | 870 | .write = dbg_write, |
| 855 | }; | 871 | }; |
| 856 | 872 | ||
| 857 | static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size) | 873 | static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size, |
| 874 | u8 token) | ||
| 858 | { | 875 | { |
| 859 | struct mlx5_cmd_prot_block *block; | 876 | struct mlx5_cmd_prot_block *block; |
| 860 | struct mlx5_cmd_mailbox *next; | 877 | struct mlx5_cmd_mailbox *next; |
| @@ -880,6 +897,7 @@ static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size) | |||
| 880 | memcpy(block->data, from, copy); | 897 | memcpy(block->data, from, copy); |
| 881 | from += copy; | 898 | from += copy; |
| 882 | size -= copy; | 899 | size -= copy; |
| 900 | block->token = token; | ||
| 883 | next = next->next; | 901 | next = next->next; |
| 884 | } | 902 | } |
| 885 | 903 | ||
| @@ -949,7 +967,8 @@ static void free_cmd_box(struct mlx5_core_dev *dev, | |||
| 949 | } | 967 | } |
| 950 | 968 | ||
| 951 | static struct mlx5_cmd_msg *mlx5_alloc_cmd_msg(struct mlx5_core_dev *dev, | 969 | static struct mlx5_cmd_msg *mlx5_alloc_cmd_msg(struct mlx5_core_dev *dev, |
| 952 | gfp_t flags, int size) | 970 | gfp_t flags, int size, |
| 971 | u8 token) | ||
| 953 | { | 972 | { |
| 954 | struct mlx5_cmd_mailbox *tmp, *head = NULL; | 973 | struct mlx5_cmd_mailbox *tmp, *head = NULL; |
| 955 | struct mlx5_cmd_prot_block *block; | 974 | struct mlx5_cmd_prot_block *block; |
| @@ -978,6 +997,7 @@ static struct mlx5_cmd_msg *mlx5_alloc_cmd_msg(struct mlx5_core_dev *dev, | |||
| 978 | tmp->next = head; | 997 | tmp->next = head; |
| 979 | block->next = cpu_to_be64(tmp->next ? tmp->next->dma : 0); | 998 | block->next = cpu_to_be64(tmp->next ? tmp->next->dma : 0); |
| 980 | block->block_num = cpu_to_be32(n - i - 1); | 999 | block->block_num = cpu_to_be32(n - i - 1); |
| 1000 | block->token = token; | ||
| 981 | head = tmp; | 1001 | head = tmp; |
| 982 | } | 1002 | } |
| 983 | msg->next = head; | 1003 | msg->next = head; |
| @@ -1352,7 +1372,7 @@ static struct mlx5_cmd_msg *alloc_msg(struct mlx5_core_dev *dev, int in_size, | |||
| 1352 | } | 1372 | } |
| 1353 | 1373 | ||
| 1354 | if (IS_ERR(msg)) | 1374 | if (IS_ERR(msg)) |
| 1355 | msg = mlx5_alloc_cmd_msg(dev, gfp, in_size); | 1375 | msg = mlx5_alloc_cmd_msg(dev, gfp, in_size, 0); |
| 1356 | 1376 | ||
| 1357 | return msg; | 1377 | return msg; |
| 1358 | } | 1378 | } |
| @@ -1377,6 +1397,7 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, | |||
| 1377 | int err; | 1397 | int err; |
| 1378 | u8 status = 0; | 1398 | u8 status = 0; |
| 1379 | u32 drv_synd; | 1399 | u32 drv_synd; |
| 1400 | u8 token; | ||
| 1380 | 1401 | ||
| 1381 | if (pci_channel_offline(dev->pdev) || | 1402 | if (pci_channel_offline(dev->pdev) || |
| 1382 | dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { | 1403 | dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { |
| @@ -1395,20 +1416,22 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, | |||
| 1395 | return err; | 1416 | return err; |
| 1396 | } | 1417 | } |
| 1397 | 1418 | ||
| 1398 | err = mlx5_copy_to_msg(inb, in, in_size); | 1419 | token = alloc_token(&dev->cmd); |
| 1420 | |||
| 1421 | err = mlx5_copy_to_msg(inb, in, in_size, token); | ||
| 1399 | if (err) { | 1422 | if (err) { |
| 1400 | mlx5_core_warn(dev, "err %d\n", err); | 1423 | mlx5_core_warn(dev, "err %d\n", err); |
| 1401 | goto out_in; | 1424 | goto out_in; |
| 1402 | } | 1425 | } |
| 1403 | 1426 | ||
| 1404 | outb = mlx5_alloc_cmd_msg(dev, gfp, out_size); | 1427 | outb = mlx5_alloc_cmd_msg(dev, gfp, out_size, token); |
| 1405 | if (IS_ERR(outb)) { | 1428 | if (IS_ERR(outb)) { |
| 1406 | err = PTR_ERR(outb); | 1429 | err = PTR_ERR(outb); |
| 1407 | goto out_in; | 1430 | goto out_in; |
| 1408 | } | 1431 | } |
| 1409 | 1432 | ||
| 1410 | err = mlx5_cmd_invoke(dev, inb, outb, out, out_size, callback, context, | 1433 | err = mlx5_cmd_invoke(dev, inb, outb, out, out_size, callback, context, |
| 1411 | pages_queue, &status); | 1434 | pages_queue, &status, token); |
| 1412 | if (err) | 1435 | if (err) |
| 1413 | goto out_out; | 1436 | goto out_out; |
| 1414 | 1437 | ||
| @@ -1476,7 +1499,7 @@ static int create_msg_cache(struct mlx5_core_dev *dev) | |||
| 1476 | INIT_LIST_HEAD(&cmd->cache.med.head); | 1499 | INIT_LIST_HEAD(&cmd->cache.med.head); |
| 1477 | 1500 | ||
| 1478 | for (i = 0; i < NUM_LONG_LISTS; i++) { | 1501 | for (i = 0; i < NUM_LONG_LISTS; i++) { |
| 1479 | msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, LONG_LIST_SIZE); | 1502 | msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, LONG_LIST_SIZE, 0); |
| 1480 | if (IS_ERR(msg)) { | 1503 | if (IS_ERR(msg)) { |
| 1481 | err = PTR_ERR(msg); | 1504 | err = PTR_ERR(msg); |
| 1482 | goto ex_err; | 1505 | goto ex_err; |
| @@ -1486,7 +1509,7 @@ static int create_msg_cache(struct mlx5_core_dev *dev) | |||
| 1486 | } | 1509 | } |
| 1487 | 1510 | ||
| 1488 | for (i = 0; i < NUM_MED_LISTS; i++) { | 1511 | for (i = 0; i < NUM_MED_LISTS; i++) { |
| 1489 | msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, MED_LIST_SIZE); | 1512 | msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, MED_LIST_SIZE, 0); |
| 1490 | if (IS_ERR(msg)) { | 1513 | if (IS_ERR(msg)) { |
| 1491 | err = PTR_ERR(msg); | 1514 | err = PTR_ERR(msg); |
| 1492 | goto ex_err; | 1515 | goto ex_err; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 1b495efa7490..bf722aa88cf0 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h | |||
| @@ -73,8 +73,12 @@ | |||
| 73 | #define MLX5_MPWRQ_PAGES_PER_WQE BIT(MLX5_MPWRQ_WQE_PAGE_ORDER) | 73 | #define MLX5_MPWRQ_PAGES_PER_WQE BIT(MLX5_MPWRQ_WQE_PAGE_ORDER) |
| 74 | #define MLX5_MPWRQ_STRIDES_PER_PAGE (MLX5_MPWRQ_NUM_STRIDES >> \ | 74 | #define MLX5_MPWRQ_STRIDES_PER_PAGE (MLX5_MPWRQ_NUM_STRIDES >> \ |
| 75 | MLX5_MPWRQ_WQE_PAGE_ORDER) | 75 | MLX5_MPWRQ_WQE_PAGE_ORDER) |
| 76 | #define MLX5_CHANNEL_MAX_NUM_MTTS (ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8) * \ | 76 | |
| 77 | BIT(MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW)) | 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 | #define MLX5_UMR_ALIGN (2048) | 82 | #define MLX5_UMR_ALIGN (2048) |
| 79 | #define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (128) | 83 | #define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (128) |
| 80 | 84 | ||
| @@ -219,9 +223,8 @@ struct mlx5e_tstamp { | |||
| 219 | }; | 223 | }; |
| 220 | 224 | ||
| 221 | enum { | 225 | enum { |
| 222 | MLX5E_RQ_STATE_POST_WQES_ENABLE, | 226 | MLX5E_RQ_STATE_FLUSH, |
| 223 | MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, | 227 | MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, |
| 224 | MLX5E_RQ_STATE_FLUSH_TIMEOUT, | ||
| 225 | MLX5E_RQ_STATE_AM, | 228 | MLX5E_RQ_STATE_AM, |
| 226 | }; | 229 | }; |
| 227 | 230 | ||
| @@ -304,6 +307,7 @@ struct mlx5e_rq { | |||
| 304 | 307 | ||
| 305 | unsigned long state; | 308 | unsigned long state; |
| 306 | int ix; | 309 | int ix; |
| 310 | u32 mpwqe_mtt_offset; | ||
| 307 | 311 | ||
| 308 | struct mlx5e_rx_am am; /* Adaptive Moderation */ | 312 | struct mlx5e_rx_am am; /* Adaptive Moderation */ |
| 309 | 313 | ||
| @@ -365,9 +369,8 @@ struct mlx5e_sq_dma { | |||
| 365 | }; | 369 | }; |
| 366 | 370 | ||
| 367 | enum { | 371 | enum { |
| 368 | MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, | 372 | MLX5E_SQ_STATE_FLUSH, |
| 369 | MLX5E_SQ_STATE_BF_ENABLE, | 373 | MLX5E_SQ_STATE_BF_ENABLE, |
| 370 | MLX5E_SQ_STATE_TX_TIMEOUT, | ||
| 371 | }; | 374 | }; |
| 372 | 375 | ||
| 373 | struct mlx5e_ico_wqe_info { | 376 | struct mlx5e_ico_wqe_info { |
| @@ -698,7 +701,6 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget); | |||
| 698 | bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget); | 701 | bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget); |
| 699 | int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget); | 702 | int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget); |
| 700 | void mlx5e_free_tx_descs(struct mlx5e_sq *sq); | 703 | void mlx5e_free_tx_descs(struct mlx5e_sq *sq); |
| 701 | void mlx5e_free_rx_descs(struct mlx5e_rq *rq); | ||
| 702 | 704 | ||
| 703 | void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); | 705 | void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); |
| 704 | void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); | 706 | void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); |
| @@ -814,11 +816,6 @@ static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev) | |||
| 814 | MLX5E_MAX_NUM_CHANNELS); | 816 | MLX5E_MAX_NUM_CHANNELS); |
| 815 | } | 817 | } |
| 816 | 818 | ||
| 817 | static inline int mlx5e_get_mtt_octw(int npages) | ||
| 818 | { | ||
| 819 | return ALIGN(npages, 8) / 2; | ||
| 820 | } | ||
| 821 | |||
| 822 | extern const struct ethtool_ops mlx5e_ethtool_ops; | 819 | extern const struct ethtool_ops mlx5e_ethtool_ops; |
| 823 | #ifdef CONFIG_MLX5_CORE_EN_DCB | 820 | #ifdef CONFIG_MLX5_CORE_EN_DCB |
| 824 | extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops; | 821 | extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c index 673043ccd76c..9cce153e1035 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c | |||
| @@ -139,7 +139,7 @@ int mlx5e_refresh_tirs_self_loopback_enable(struct mlx5_core_dev *mdev) | |||
| 139 | struct mlx5e_tir *tir; | 139 | struct mlx5e_tir *tir; |
| 140 | void *in; | 140 | void *in; |
| 141 | int inlen; | 141 | int inlen; |
| 142 | int err; | 142 | int err = 0; |
| 143 | 143 | ||
| 144 | inlen = MLX5_ST_SZ_BYTES(modify_tir_in); | 144 | inlen = MLX5_ST_SZ_BYTES(modify_tir_in); |
| 145 | in = mlx5_vzalloc(inlen); | 145 | in = mlx5_vzalloc(inlen); |
| @@ -151,10 +151,11 @@ int mlx5e_refresh_tirs_self_loopback_enable(struct mlx5_core_dev *mdev) | |||
| 151 | list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) { | 151 | list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) { |
| 152 | err = mlx5_core_modify_tir(mdev, tir->tirn, in, inlen); | 152 | err = mlx5_core_modify_tir(mdev, tir->tirn, in, inlen); |
| 153 | if (err) | 153 | if (err) |
| 154 | return err; | 154 | goto out; |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | out: | ||
| 157 | kvfree(in); | 158 | kvfree(in); |
| 158 | 159 | ||
| 159 | return 0; | 160 | return err; |
| 160 | } | 161 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c index caa9a3ccc3f3..762af16ed021 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | |||
| @@ -127,29 +127,40 @@ int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets) | |||
| 127 | return mlx5_set_port_tc_bw_alloc(mdev, tc_tx_bw); | 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 | int bw_sum = 0; | 133 | int bw_sum = 0; |
| 133 | int i; | 134 | int i; |
| 134 | 135 | ||
| 135 | /* Validate Priority */ | 136 | /* Validate Priority */ |
| 136 | for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { | 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 | return -EINVAL; | 142 | return -EINVAL; |
| 143 | } | ||
| 139 | } | 144 | } |
| 140 | 145 | ||
| 141 | /* Validate Bandwidth Sum */ | 146 | /* Validate Bandwidth Sum */ |
| 142 | for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { | 147 | for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { |
| 143 | if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_ETS) { | 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 | return -EINVAL; | 152 | return -EINVAL; |
| 153 | } | ||
| 146 | 154 | ||
| 147 | bw_sum += ets->tc_tx_bw[i]; | 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 | return -EINVAL; | 162 | return -EINVAL; |
| 163 | } | ||
| 153 | return 0; | 164 | return 0; |
| 154 | } | 165 | } |
| 155 | 166 | ||
| @@ -159,7 +170,7 @@ static int mlx5e_dcbnl_ieee_setets(struct net_device *netdev, | |||
| 159 | struct mlx5e_priv *priv = netdev_priv(netdev); | 170 | struct mlx5e_priv *priv = netdev_priv(netdev); |
| 160 | int err; | 171 | int err; |
| 161 | 172 | ||
| 162 | err = mlx5e_dbcnl_validate_ets(ets); | 173 | err = mlx5e_dbcnl_validate_ets(netdev, ets); |
| 163 | if (err) | 174 | if (err) |
| 164 | return err; | 175 | return err; |
| 165 | 176 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index 4a3757e60441..7a346bb2ed00 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | |||
| @@ -331,7 +331,7 @@ static void mlx5e_get_ethtool_stats(struct net_device *dev, | |||
| 331 | if (mlx5e_query_global_pause_combined(priv)) { | 331 | if (mlx5e_query_global_pause_combined(priv)) { |
| 332 | for (i = 0; i < NUM_PPORT_PER_PRIO_PFC_COUNTERS; i++) { | 332 | for (i = 0; i < NUM_PPORT_PER_PRIO_PFC_COUNTERS; i++) { |
| 333 | data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.per_prio_counters[0], | 333 | data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.per_prio_counters[0], |
| 334 | pport_per_prio_pfc_stats_desc, 0); | 334 | pport_per_prio_pfc_stats_desc, i); |
| 335 | } | 335 | } |
| 336 | } | 336 | } |
| 337 | 337 | ||
| @@ -352,15 +352,61 @@ static void mlx5e_get_ethtool_stats(struct net_device *dev, | |||
| 352 | sq_stats_desc, j); | 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 | static void mlx5e_get_ringparam(struct net_device *dev, | 399 | static void mlx5e_get_ringparam(struct net_device *dev, |
| 356 | struct ethtool_ringparam *param) | 400 | struct ethtool_ringparam *param) |
| 357 | { | 401 | { |
| 358 | struct mlx5e_priv *priv = netdev_priv(dev); | 402 | struct mlx5e_priv *priv = netdev_priv(dev); |
| 359 | int rq_wq_type = priv->params.rq_wq_type; | 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 | param->tx_max_pending = 1 << MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE; | 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 | param->tx_pending = 1 << priv->params.log_sq_size; | 410 | param->tx_pending = 1 << priv->params.log_sq_size; |
| 365 | } | 411 | } |
| 366 | 412 | ||
| @@ -370,9 +416,13 @@ static int mlx5e_set_ringparam(struct net_device *dev, | |||
| 370 | struct mlx5e_priv *priv = netdev_priv(dev); | 416 | struct mlx5e_priv *priv = netdev_priv(dev); |
| 371 | bool was_opened; | 417 | bool was_opened; |
| 372 | int rq_wq_type = priv->params.rq_wq_type; | 418 | int rq_wq_type = priv->params.rq_wq_type; |
| 419 | u32 rx_pending_wqes; | ||
| 420 | u32 min_rq_size; | ||
| 421 | u32 max_rq_size; | ||
| 373 | u16 min_rx_wqes; | 422 | u16 min_rx_wqes; |
| 374 | u8 log_rq_size; | 423 | u8 log_rq_size; |
| 375 | u8 log_sq_size; | 424 | u8 log_sq_size; |
| 425 | u32 num_mtts; | ||
| 376 | int err = 0; | 426 | int err = 0; |
| 377 | 427 | ||
| 378 | if (param->rx_jumbo_pending) { | 428 | if (param->rx_jumbo_pending) { |
| @@ -385,18 +435,36 @@ static int mlx5e_set_ringparam(struct net_device *dev, | |||
| 385 | __func__); | 435 | __func__); |
| 386 | return -EINVAL; | 436 | return -EINVAL; |
| 387 | } | 437 | } |
| 388 | if (param->rx_pending < (1 << mlx5_min_log_rq_size(rq_wq_type))) { | 438 | |
| 439 | min_rq_size = mlx5e_rx_wqes_to_packets(priv, rq_wq_type, | ||
| 440 | 1 << mlx5_min_log_rq_size(rq_wq_type)); | ||
| 441 | max_rq_size = mlx5e_rx_wqes_to_packets(priv, rq_wq_type, | ||
| 442 | 1 << mlx5_max_log_rq_size(rq_wq_type)); | ||
| 443 | rx_pending_wqes = mlx5e_packets_to_rx_wqes(priv, rq_wq_type, | ||
| 444 | param->rx_pending); | ||
| 445 | |||
| 446 | if (param->rx_pending < min_rq_size) { | ||
| 389 | netdev_info(dev, "%s: rx_pending (%d) < min (%d)\n", | 447 | netdev_info(dev, "%s: rx_pending (%d) < min (%d)\n", |
| 390 | __func__, param->rx_pending, | 448 | __func__, param->rx_pending, |
| 391 | 1 << mlx5_min_log_rq_size(rq_wq_type)); | 449 | min_rq_size); |
| 392 | return -EINVAL; | 450 | return -EINVAL; |
| 393 | } | 451 | } |
| 394 | if (param->rx_pending > (1 << mlx5_max_log_rq_size(rq_wq_type))) { | 452 | if (param->rx_pending > max_rq_size) { |
| 395 | netdev_info(dev, "%s: rx_pending (%d) > max (%d)\n", | 453 | netdev_info(dev, "%s: rx_pending (%d) > max (%d)\n", |
| 396 | __func__, param->rx_pending, | 454 | __func__, param->rx_pending, |
| 397 | 1 << mlx5_max_log_rq_size(rq_wq_type)); | 455 | max_rq_size); |
| 398 | return -EINVAL; | 456 | return -EINVAL; |
| 399 | } | 457 | } |
| 458 | |||
| 459 | num_mtts = MLX5E_REQUIRED_MTTS(priv->params.num_channels, | ||
| 460 | rx_pending_wqes); | ||
| 461 | if (priv->params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ && | ||
| 462 | !MLX5E_VALID_NUM_MTTS(num_mtts)) { | ||
| 463 | netdev_info(dev, "%s: rx_pending (%d) request can't be satisfied, try to reduce.\n", | ||
| 464 | __func__, param->rx_pending); | ||
| 465 | return -EINVAL; | ||
| 466 | } | ||
| 467 | |||
| 400 | if (param->tx_pending < (1 << MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)) { | 468 | if (param->tx_pending < (1 << MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)) { |
| 401 | netdev_info(dev, "%s: tx_pending (%d) < min (%d)\n", | 469 | netdev_info(dev, "%s: tx_pending (%d) < min (%d)\n", |
| 402 | __func__, param->tx_pending, | 470 | __func__, param->tx_pending, |
| @@ -410,9 +478,9 @@ static int mlx5e_set_ringparam(struct net_device *dev, | |||
| 410 | return -EINVAL; | 478 | return -EINVAL; |
| 411 | } | 479 | } |
| 412 | 480 | ||
| 413 | log_rq_size = order_base_2(param->rx_pending); | 481 | log_rq_size = order_base_2(rx_pending_wqes); |
| 414 | log_sq_size = order_base_2(param->tx_pending); | 482 | log_sq_size = order_base_2(param->tx_pending); |
| 415 | min_rx_wqes = mlx5_min_rx_wqes(rq_wq_type, param->rx_pending); | 483 | min_rx_wqes = mlx5_min_rx_wqes(rq_wq_type, rx_pending_wqes); |
| 416 | 484 | ||
| 417 | if (log_rq_size == priv->params.log_rq_size && | 485 | if (log_rq_size == priv->params.log_rq_size && |
| 418 | log_sq_size == priv->params.log_sq_size && | 486 | log_sq_size == priv->params.log_sq_size && |
| @@ -454,6 +522,7 @@ static int mlx5e_set_channels(struct net_device *dev, | |||
| 454 | unsigned int count = ch->combined_count; | 522 | unsigned int count = ch->combined_count; |
| 455 | bool arfs_enabled; | 523 | bool arfs_enabled; |
| 456 | bool was_opened; | 524 | bool was_opened; |
| 525 | u32 num_mtts; | ||
| 457 | int err = 0; | 526 | int err = 0; |
| 458 | 527 | ||
| 459 | if (!count) { | 528 | if (!count) { |
| @@ -472,6 +541,14 @@ static int mlx5e_set_channels(struct net_device *dev, | |||
| 472 | return -EINVAL; | 541 | return -EINVAL; |
| 473 | } | 542 | } |
| 474 | 543 | ||
| 544 | num_mtts = MLX5E_REQUIRED_MTTS(count, BIT(priv->params.log_rq_size)); | ||
| 545 | if (priv->params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ && | ||
| 546 | !MLX5E_VALID_NUM_MTTS(num_mtts)) { | ||
| 547 | netdev_info(dev, "%s: rx count (%d) request can't be satisfied, try to reduce.\n", | ||
| 548 | __func__, count); | ||
| 549 | return -EINVAL; | ||
| 550 | } | ||
| 551 | |||
| 475 | if (priv->params.num_channels == count) | 552 | if (priv->params.num_channels == count) |
| 476 | return 0; | 553 | return 0; |
| 477 | 554 | ||
| @@ -582,9 +659,10 @@ out: | |||
| 582 | static void ptys2ethtool_supported_link(unsigned long *supported_modes, | 659 | static void ptys2ethtool_supported_link(unsigned long *supported_modes, |
| 583 | u32 eth_proto_cap) | 660 | u32 eth_proto_cap) |
| 584 | { | 661 | { |
| 662 | unsigned long proto_cap = eth_proto_cap; | ||
| 585 | int proto; | 663 | int proto; |
| 586 | 664 | ||
| 587 | for_each_set_bit(proto, (unsigned long *)ð_proto_cap, MLX5E_LINK_MODES_NUMBER) | 665 | for_each_set_bit(proto, &proto_cap, MLX5E_LINK_MODES_NUMBER) |
| 588 | bitmap_or(supported_modes, supported_modes, | 666 | bitmap_or(supported_modes, supported_modes, |
| 589 | ptys2ethtool_table[proto].supported, | 667 | ptys2ethtool_table[proto].supported, |
| 590 | __ETHTOOL_LINK_MODE_MASK_NBITS); | 668 | __ETHTOOL_LINK_MODE_MASK_NBITS); |
| @@ -593,9 +671,10 @@ static void ptys2ethtool_supported_link(unsigned long *supported_modes, | |||
| 593 | static void ptys2ethtool_adver_link(unsigned long *advertising_modes, | 671 | static void ptys2ethtool_adver_link(unsigned long *advertising_modes, |
| 594 | u32 eth_proto_cap) | 672 | u32 eth_proto_cap) |
| 595 | { | 673 | { |
| 674 | unsigned long proto_cap = eth_proto_cap; | ||
| 596 | int proto; | 675 | int proto; |
| 597 | 676 | ||
| 598 | for_each_set_bit(proto, (unsigned long *)ð_proto_cap, MLX5E_LINK_MODES_NUMBER) | 677 | for_each_set_bit(proto, &proto_cap, MLX5E_LINK_MODES_NUMBER) |
| 599 | bitmap_or(advertising_modes, advertising_modes, | 678 | bitmap_or(advertising_modes, advertising_modes, |
| 600 | ptys2ethtool_table[proto].advertised, | 679 | ptys2ethtool_table[proto].advertised, |
| 601 | __ETHTOOL_LINK_MODE_MASK_NBITS); | 680 | __ETHTOOL_LINK_MODE_MASK_NBITS); |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 870bea37c57c..2459c7f3db8d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c | |||
| @@ -39,13 +39,6 @@ | |||
| 39 | #include "eswitch.h" | 39 | #include "eswitch.h" |
| 40 | #include "vxlan.h" | 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 | struct mlx5e_rq_param { | 42 | struct mlx5e_rq_param { |
| 50 | u32 rqc[MLX5_ST_SZ_DW(rqc)]; | 43 | u32 rqc[MLX5_ST_SZ_DW(rqc)]; |
| 51 | struct mlx5_wq_param wq; | 44 | struct mlx5_wq_param wq; |
| @@ -162,6 +155,7 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv) | |||
| 162 | s->tx_queue_stopped += sq_stats->stopped; | 155 | s->tx_queue_stopped += sq_stats->stopped; |
| 163 | s->tx_queue_wake += sq_stats->wake; | 156 | s->tx_queue_wake += sq_stats->wake; |
| 164 | s->tx_queue_dropped += sq_stats->dropped; | 157 | s->tx_queue_dropped += sq_stats->dropped; |
| 158 | s->tx_xmit_more += sq_stats->xmit_more; | ||
| 165 | s->tx_csum_partial_inner += sq_stats->csum_partial_inner; | 159 | s->tx_csum_partial_inner += sq_stats->csum_partial_inner; |
| 166 | tx_offload_none += sq_stats->csum_none; | 160 | tx_offload_none += sq_stats->csum_none; |
| 167 | } | 161 | } |
| @@ -340,6 +334,9 @@ static int mlx5e_create_rq(struct mlx5e_channel *c, | |||
| 340 | rq->alloc_wqe = mlx5e_alloc_rx_mpwqe; | 334 | rq->alloc_wqe = mlx5e_alloc_rx_mpwqe; |
| 341 | rq->dealloc_wqe = mlx5e_dealloc_rx_mpwqe; | 335 | rq->dealloc_wqe = mlx5e_dealloc_rx_mpwqe; |
| 342 | 336 | ||
| 337 | rq->mpwqe_mtt_offset = c->ix * | ||
| 338 | MLX5E_REQUIRED_MTTS(1, BIT(priv->params.log_rq_size)); | ||
| 339 | |||
| 343 | rq->mpwqe_stride_sz = BIT(priv->params.mpwqe_log_stride_sz); | 340 | rq->mpwqe_stride_sz = BIT(priv->params.mpwqe_log_stride_sz); |
| 344 | rq->mpwqe_num_strides = BIT(priv->params.mpwqe_log_num_strides); | 341 | rq->mpwqe_num_strides = BIT(priv->params.mpwqe_log_num_strides); |
| 345 | rq->wqe_sz = rq->mpwqe_stride_sz * rq->mpwqe_num_strides; | 342 | rq->wqe_sz = rq->mpwqe_stride_sz * rq->mpwqe_num_strides; |
| @@ -428,7 +425,6 @@ static int mlx5e_enable_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param) | |||
| 428 | 425 | ||
| 429 | MLX5_SET(rqc, rqc, cqn, rq->cq.mcq.cqn); | 426 | MLX5_SET(rqc, rqc, cqn, rq->cq.mcq.cqn); |
| 430 | MLX5_SET(rqc, rqc, state, MLX5_RQC_STATE_RST); | 427 | MLX5_SET(rqc, rqc, state, MLX5_RQC_STATE_RST); |
| 431 | MLX5_SET(rqc, rqc, flush_in_error_en, 1); | ||
| 432 | MLX5_SET(rqc, rqc, vsd, priv->params.vlan_strip_disable); | 428 | MLX5_SET(rqc, rqc, vsd, priv->params.vlan_strip_disable); |
| 433 | MLX5_SET(wq, wq, log_wq_pg_sz, rq->wq_ctrl.buf.page_shift - | 429 | MLX5_SET(wq, wq, log_wq_pg_sz, rq->wq_ctrl.buf.page_shift - |
| 434 | MLX5_ADAPTER_PAGE_SHIFT); | 430 | MLX5_ADAPTER_PAGE_SHIFT); |
| @@ -525,6 +521,27 @@ static int mlx5e_wait_for_min_rx_wqes(struct mlx5e_rq *rq) | |||
| 525 | return -ETIMEDOUT; | 521 | return -ETIMEDOUT; |
| 526 | } | 522 | } |
| 527 | 523 | ||
| 524 | static void mlx5e_free_rx_descs(struct mlx5e_rq *rq) | ||
| 525 | { | ||
| 526 | struct mlx5_wq_ll *wq = &rq->wq; | ||
| 527 | struct mlx5e_rx_wqe *wqe; | ||
| 528 | __be16 wqe_ix_be; | ||
| 529 | u16 wqe_ix; | ||
| 530 | |||
| 531 | /* UMR WQE (if in progress) is always at wq->head */ | ||
| 532 | if (test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state)) | ||
| 533 | mlx5e_free_rx_fragmented_mpwqe(rq, &rq->wqe_info[wq->head]); | ||
| 534 | |||
| 535 | while (!mlx5_wq_ll_is_empty(wq)) { | ||
| 536 | wqe_ix_be = *wq->tail_next; | ||
| 537 | wqe_ix = be16_to_cpu(wqe_ix_be); | ||
| 538 | wqe = mlx5_wq_ll_get_wqe(&rq->wq, wqe_ix); | ||
| 539 | rq->dealloc_wqe(rq, wqe_ix); | ||
| 540 | mlx5_wq_ll_pop(&rq->wq, wqe_ix_be, | ||
| 541 | &wqe->next.next_wqe_index); | ||
| 542 | } | ||
| 543 | } | ||
| 544 | |||
| 528 | static int mlx5e_open_rq(struct mlx5e_channel *c, | 545 | static int mlx5e_open_rq(struct mlx5e_channel *c, |
| 529 | struct mlx5e_rq_param *param, | 546 | struct mlx5e_rq_param *param, |
| 530 | struct mlx5e_rq *rq) | 547 | struct mlx5e_rq *rq) |
| @@ -548,8 +565,6 @@ static int mlx5e_open_rq(struct mlx5e_channel *c, | |||
| 548 | if (param->am_enabled) | 565 | if (param->am_enabled) |
| 549 | set_bit(MLX5E_RQ_STATE_AM, &c->rq.state); | 566 | set_bit(MLX5E_RQ_STATE_AM, &c->rq.state); |
| 550 | 567 | ||
| 551 | set_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state); | ||
| 552 | |||
| 553 | sq->ico_wqe_info[pi].opcode = MLX5_OPCODE_NOP; | 568 | sq->ico_wqe_info[pi].opcode = MLX5_OPCODE_NOP; |
| 554 | sq->ico_wqe_info[pi].num_wqebbs = 1; | 569 | sq->ico_wqe_info[pi].num_wqebbs = 1; |
| 555 | mlx5e_send_nop(sq, true); /* trigger mlx5e_post_rx_wqes() */ | 570 | mlx5e_send_nop(sq, true); /* trigger mlx5e_post_rx_wqes() */ |
| @@ -566,23 +581,8 @@ err_destroy_rq: | |||
| 566 | 581 | ||
| 567 | static void mlx5e_close_rq(struct mlx5e_rq *rq) | 582 | static void mlx5e_close_rq(struct mlx5e_rq *rq) |
| 568 | { | 583 | { |
| 569 | int tout = 0; | 584 | set_bit(MLX5E_RQ_STATE_FLUSH, &rq->state); |
| 570 | int err; | ||
| 571 | |||
| 572 | clear_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state); | ||
| 573 | napi_synchronize(&rq->channel->napi); /* prevent mlx5e_post_rx_wqes */ | 585 | napi_synchronize(&rq->channel->napi); /* prevent mlx5e_post_rx_wqes */ |
| 574 | |||
| 575 | err = mlx5e_modify_rq_state(rq, MLX5_RQC_STATE_RDY, MLX5_RQC_STATE_ERR); | ||
| 576 | while (!mlx5_wq_ll_is_empty(&rq->wq) && !err && | ||
| 577 | tout++ < MLX5_EN_QP_FLUSH_MAX_ITER) | ||
| 578 | msleep(MLX5_EN_QP_FLUSH_MSLEEP_QUANT); | ||
| 579 | |||
| 580 | if (err || tout == MLX5_EN_QP_FLUSH_MAX_ITER) | ||
| 581 | set_bit(MLX5E_RQ_STATE_FLUSH_TIMEOUT, &rq->state); | ||
| 582 | |||
| 583 | /* avoid destroying rq before mlx5e_poll_rx_cq() is done with it */ | ||
| 584 | napi_synchronize(&rq->channel->napi); | ||
| 585 | |||
| 586 | cancel_work_sync(&rq->am.work); | 586 | cancel_work_sync(&rq->am.work); |
| 587 | 587 | ||
| 588 | mlx5e_disable_rq(rq); | 588 | mlx5e_disable_rq(rq); |
| @@ -821,7 +821,6 @@ static int mlx5e_open_sq(struct mlx5e_channel *c, | |||
| 821 | goto err_disable_sq; | 821 | goto err_disable_sq; |
| 822 | 822 | ||
| 823 | if (sq->txq) { | 823 | if (sq->txq) { |
| 824 | set_bit(MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, &sq->state); | ||
| 825 | netdev_tx_reset_queue(sq->txq); | 824 | netdev_tx_reset_queue(sq->txq); |
| 826 | netif_tx_start_queue(sq->txq); | 825 | netif_tx_start_queue(sq->txq); |
| 827 | } | 826 | } |
| @@ -845,38 +844,20 @@ static inline void netif_tx_disable_queue(struct netdev_queue *txq) | |||
| 845 | 844 | ||
| 846 | static void mlx5e_close_sq(struct mlx5e_sq *sq) | 845 | static void mlx5e_close_sq(struct mlx5e_sq *sq) |
| 847 | { | 846 | { |
| 848 | int tout = 0; | 847 | set_bit(MLX5E_SQ_STATE_FLUSH, &sq->state); |
| 849 | int err; | 848 | /* prevent netif_tx_wake_queue */ |
| 849 | napi_synchronize(&sq->channel->napi); | ||
| 850 | 850 | ||
| 851 | if (sq->txq) { | 851 | if (sq->txq) { |
| 852 | clear_bit(MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, &sq->state); | ||
| 853 | /* prevent netif_tx_wake_queue */ | ||
| 854 | napi_synchronize(&sq->channel->napi); | ||
| 855 | netif_tx_disable_queue(sq->txq); | 852 | netif_tx_disable_queue(sq->txq); |
| 856 | 853 | ||
| 857 | /* ensure hw is notified of all pending wqes */ | 854 | /* last doorbell out, godspeed .. */ |
| 858 | if (mlx5e_sq_has_room_for(sq, 1)) | 855 | if (mlx5e_sq_has_room_for(sq, 1)) |
| 859 | mlx5e_send_nop(sq, true); | 856 | mlx5e_send_nop(sq, true); |
| 860 | |||
| 861 | err = mlx5e_modify_sq(sq, MLX5_SQC_STATE_RDY, | ||
| 862 | MLX5_SQC_STATE_ERR, false, 0); | ||
| 863 | if (err) | ||
| 864 | set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state); | ||
| 865 | } | ||
| 866 | |||
| 867 | /* wait till sq is empty, unless a TX timeout occurred on this SQ */ | ||
| 868 | while (sq->cc != sq->pc && | ||
| 869 | !test_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state)) { | ||
| 870 | msleep(MLX5_EN_QP_FLUSH_MSLEEP_QUANT); | ||
| 871 | if (tout++ > MLX5_EN_QP_FLUSH_MAX_ITER) | ||
| 872 | set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state); | ||
| 873 | } | 857 | } |
| 874 | 858 | ||
| 875 | /* avoid destroying sq before mlx5e_poll_tx_cq() is done with it */ | ||
| 876 | napi_synchronize(&sq->channel->napi); | ||
| 877 | |||
| 878 | mlx5e_free_tx_descs(sq); | ||
| 879 | mlx5e_disable_sq(sq); | 859 | mlx5e_disable_sq(sq); |
| 860 | mlx5e_free_tx_descs(sq); | ||
| 880 | mlx5e_destroy_sq(sq); | 861 | mlx5e_destroy_sq(sq); |
| 881 | } | 862 | } |
| 882 | 863 | ||
| @@ -1826,10 +1807,6 @@ int mlx5e_open_locked(struct net_device *netdev) | |||
| 1826 | netif_set_real_num_tx_queues(netdev, num_txqs); | 1807 | netif_set_real_num_tx_queues(netdev, num_txqs); |
| 1827 | netif_set_real_num_rx_queues(netdev, priv->params.num_channels); | 1808 | netif_set_real_num_rx_queues(netdev, priv->params.num_channels); |
| 1828 | 1809 | ||
| 1829 | err = mlx5e_set_dev_port_mtu(netdev); | ||
| 1830 | if (err) | ||
| 1831 | goto err_clear_state_opened_flag; | ||
| 1832 | |||
| 1833 | err = mlx5e_open_channels(priv); | 1810 | err = mlx5e_open_channels(priv); |
| 1834 | if (err) { | 1811 | if (err) { |
| 1835 | netdev_err(netdev, "%s: mlx5e_open_channels failed, %d\n", | 1812 | netdev_err(netdev, "%s: mlx5e_open_channels failed, %d\n", |
| @@ -2573,6 +2550,7 @@ static int mlx5e_change_mtu(struct net_device *netdev, int new_mtu) | |||
| 2573 | u16 max_mtu; | 2550 | u16 max_mtu; |
| 2574 | u16 min_mtu; | 2551 | u16 min_mtu; |
| 2575 | int err = 0; | 2552 | int err = 0; |
| 2553 | bool reset; | ||
| 2576 | 2554 | ||
| 2577 | mlx5_query_port_max_mtu(mdev, &max_mtu, 1); | 2555 | mlx5_query_port_max_mtu(mdev, &max_mtu, 1); |
| 2578 | 2556 | ||
| @@ -2588,13 +2566,18 @@ static int mlx5e_change_mtu(struct net_device *netdev, int new_mtu) | |||
| 2588 | 2566 | ||
| 2589 | mutex_lock(&priv->state_lock); | 2567 | mutex_lock(&priv->state_lock); |
| 2590 | 2568 | ||
| 2569 | reset = !priv->params.lro_en && | ||
| 2570 | (priv->params.rq_wq_type != | ||
| 2571 | MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ); | ||
| 2572 | |||
| 2591 | was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state); | 2573 | was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state); |
| 2592 | if (was_opened) | 2574 | if (was_opened && reset) |
| 2593 | mlx5e_close_locked(netdev); | 2575 | mlx5e_close_locked(netdev); |
| 2594 | 2576 | ||
| 2595 | netdev->mtu = new_mtu; | 2577 | netdev->mtu = new_mtu; |
| 2578 | mlx5e_set_dev_port_mtu(netdev); | ||
| 2596 | 2579 | ||
| 2597 | if (was_opened) | 2580 | if (was_opened && reset) |
| 2598 | err = mlx5e_open_locked(netdev); | 2581 | err = mlx5e_open_locked(netdev); |
| 2599 | 2582 | ||
| 2600 | mutex_unlock(&priv->state_lock); | 2583 | mutex_unlock(&priv->state_lock); |
| @@ -2794,7 +2777,7 @@ static void mlx5e_tx_timeout(struct net_device *dev) | |||
| 2794 | if (!netif_xmit_stopped(netdev_get_tx_queue(dev, i))) | 2777 | if (!netif_xmit_stopped(netdev_get_tx_queue(dev, i))) |
| 2795 | continue; | 2778 | continue; |
| 2796 | sched_work = true; | 2779 | sched_work = true; |
| 2797 | set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state); | 2780 | set_bit(MLX5E_SQ_STATE_FLUSH, &sq->state); |
| 2798 | netdev_err(dev, "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x\n", | 2781 | netdev_err(dev, "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x\n", |
| 2799 | i, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc); | 2782 | i, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc); |
| 2800 | } | 2783 | } |
| @@ -3231,8 +3214,8 @@ static int mlx5e_create_umr_mkey(struct mlx5e_priv *priv) | |||
| 3231 | struct mlx5_create_mkey_mbox_in *in; | 3214 | struct mlx5_create_mkey_mbox_in *in; |
| 3232 | struct mlx5_mkey_seg *mkc; | 3215 | struct mlx5_mkey_seg *mkc; |
| 3233 | int inlen = sizeof(*in); | 3216 | int inlen = sizeof(*in); |
| 3234 | u64 npages = | 3217 | u64 npages = MLX5E_REQUIRED_MTTS(priv->profile->max_nch(mdev), |
| 3235 | priv->profile->max_nch(mdev) * MLX5_CHANNEL_MAX_NUM_MTTS; | 3218 | BIT(MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW)); |
| 3236 | int err; | 3219 | int err; |
| 3237 | 3220 | ||
| 3238 | in = mlx5_vzalloc(inlen); | 3221 | in = mlx5_vzalloc(inlen); |
| @@ -3246,10 +3229,12 @@ static int mlx5e_create_umr_mkey(struct mlx5e_priv *priv) | |||
| 3246 | MLX5_PERM_LOCAL_WRITE | | 3229 | MLX5_PERM_LOCAL_WRITE | |
| 3247 | MLX5_ACCESS_MODE_MTT; | 3230 | MLX5_ACCESS_MODE_MTT; |
| 3248 | 3231 | ||
| 3232 | npages = min_t(u32, ALIGN(U16_MAX, 4) * 2, npages); | ||
| 3233 | |||
| 3249 | mkc->qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); | 3234 | mkc->qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); |
| 3250 | mkc->flags_pd = cpu_to_be32(mdev->mlx5e_res.pdn); | 3235 | mkc->flags_pd = cpu_to_be32(mdev->mlx5e_res.pdn); |
| 3251 | mkc->len = cpu_to_be64(npages << PAGE_SHIFT); | 3236 | mkc->len = cpu_to_be64(npages << PAGE_SHIFT); |
| 3252 | mkc->xlt_oct_size = cpu_to_be32(mlx5e_get_mtt_octw(npages)); | 3237 | mkc->xlt_oct_size = cpu_to_be32(MLX5_MTT_OCTW(npages)); |
| 3253 | mkc->log2_page_size = PAGE_SHIFT; | 3238 | mkc->log2_page_size = PAGE_SHIFT; |
| 3254 | 3239 | ||
| 3255 | err = mlx5_core_create_mkey(mdev, &priv->umr_mkey, in, inlen, NULL, | 3240 | err = mlx5_core_create_mkey(mdev, &priv->umr_mkey, in, inlen, NULL, |
| @@ -3385,6 +3370,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv) | |||
| 3385 | queue_work(priv->wq, &priv->set_rx_mode_work); | 3370 | queue_work(priv->wq, &priv->set_rx_mode_work); |
| 3386 | 3371 | ||
| 3387 | if (MLX5_CAP_GEN(mdev, vport_group_manager)) { | 3372 | if (MLX5_CAP_GEN(mdev, vport_group_manager)) { |
| 3373 | mlx5_query_nic_vport_mac_address(mdev, 0, rep.hw_id); | ||
| 3388 | rep.load = mlx5e_nic_rep_load; | 3374 | rep.load = mlx5e_nic_rep_load; |
| 3389 | rep.unload = mlx5e_nic_rep_unload; | 3375 | rep.unload = mlx5e_nic_rep_unload; |
| 3390 | rep.vport = 0; | 3376 | rep.vport = 0; |
| @@ -3463,6 +3449,8 @@ void *mlx5e_create_netdev(struct mlx5_core_dev *mdev, | |||
| 3463 | 3449 | ||
| 3464 | mlx5e_init_l2_addr(priv); | 3450 | mlx5e_init_l2_addr(priv); |
| 3465 | 3451 | ||
| 3452 | mlx5e_set_dev_port_mtu(netdev); | ||
| 3453 | |||
| 3466 | err = register_netdev(netdev); | 3454 | err = register_netdev(netdev); |
| 3467 | if (err) { | 3455 | if (err) { |
| 3468 | mlx5_core_err(mdev, "register_netdev failed, %d\n", err); | 3456 | mlx5_core_err(mdev, "register_netdev failed, %d\n", err); |
| @@ -3501,16 +3489,20 @@ static void mlx5e_register_vport_rep(struct mlx5_core_dev *mdev) | |||
| 3501 | struct mlx5_eswitch *esw = mdev->priv.eswitch; | 3489 | struct mlx5_eswitch *esw = mdev->priv.eswitch; |
| 3502 | int total_vfs = MLX5_TOTAL_VPORTS(mdev); | 3490 | int total_vfs = MLX5_TOTAL_VPORTS(mdev); |
| 3503 | int vport; | 3491 | int vport; |
| 3492 | u8 mac[ETH_ALEN]; | ||
| 3504 | 3493 | ||
| 3505 | if (!MLX5_CAP_GEN(mdev, vport_group_manager)) | 3494 | if (!MLX5_CAP_GEN(mdev, vport_group_manager)) |
| 3506 | return; | 3495 | return; |
| 3507 | 3496 | ||
| 3497 | mlx5_query_nic_vport_mac_address(mdev, 0, mac); | ||
| 3498 | |||
| 3508 | for (vport = 1; vport < total_vfs; vport++) { | 3499 | for (vport = 1; vport < total_vfs; vport++) { |
| 3509 | struct mlx5_eswitch_rep rep; | 3500 | struct mlx5_eswitch_rep rep; |
| 3510 | 3501 | ||
| 3511 | rep.load = mlx5e_vport_rep_load; | 3502 | rep.load = mlx5e_vport_rep_load; |
| 3512 | rep.unload = mlx5e_vport_rep_unload; | 3503 | rep.unload = mlx5e_vport_rep_unload; |
| 3513 | rep.vport = vport; | 3504 | rep.vport = vport; |
| 3505 | ether_addr_copy(rep.hw_id, mac); | ||
| 3514 | mlx5_eswitch_register_vport_rep(esw, &rep); | 3506 | mlx5_eswitch_register_vport_rep(esw, &rep); |
| 3515 | } | 3507 | } |
| 3516 | } | 3508 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c index 1c7d8b8314bf..134de4a11f1d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | |||
| @@ -135,17 +135,16 @@ static const struct ethtool_ops mlx5e_rep_ethtool_ops = { | |||
| 135 | int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr) | 135 | int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr) |
| 136 | { | 136 | { |
| 137 | struct mlx5e_priv *priv = netdev_priv(dev); | 137 | struct mlx5e_priv *priv = netdev_priv(dev); |
| 138 | struct mlx5_eswitch_rep *rep = priv->ppriv; | ||
| 138 | struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; | 139 | struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; |
| 139 | u8 mac[ETH_ALEN]; | ||
| 140 | 140 | ||
| 141 | if (esw->mode == SRIOV_NONE) | 141 | if (esw->mode == SRIOV_NONE) |
| 142 | return -EOPNOTSUPP; | 142 | return -EOPNOTSUPP; |
| 143 | 143 | ||
| 144 | switch (attr->id) { | 144 | switch (attr->id) { |
| 145 | case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: | 145 | case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: |
| 146 | mlx5_query_nic_vport_mac_address(priv->mdev, 0, mac); | ||
| 147 | attr->u.ppid.id_len = ETH_ALEN; | 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 | break; | 148 | break; |
| 150 | default: | 149 | default: |
| 151 | return -EOPNOTSUPP; | 150 | return -EOPNOTSUPP; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 9f2a16a507e0..e7c969df3dad 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | |||
| @@ -324,9 +324,9 @@ mlx5e_copy_skb_header_fragmented_mpwqe(struct device *pdev, | |||
| 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 | wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8); | 330 | wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8); |
| 331 | } | 331 | } |
| 332 | 332 | ||
| @@ -340,7 +340,7 @@ static void mlx5e_build_umr_wqe(struct mlx5e_rq *rq, | |||
| 340 | struct mlx5_wqe_data_seg *dseg = &wqe->data; | 340 | struct mlx5_wqe_data_seg *dseg = &wqe->data; |
| 341 | struct mlx5e_mpw_info *wi = &rq->wqe_info[ix]; | 341 | struct mlx5e_mpw_info *wi = &rq->wqe_info[ix]; |
| 342 | u8 ds_cnt = DIV_ROUND_UP(sizeof(*wqe), MLX5_SEND_WQE_DS); | 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 | memset(wqe, 0, sizeof(*wqe)); | 345 | memset(wqe, 0, sizeof(*wqe)); |
| 346 | cseg->opmod_idx_opcode = | 346 | cseg->opmod_idx_opcode = |
| @@ -353,9 +353,9 @@ static void mlx5e_build_umr_wqe(struct mlx5e_rq *rq, | |||
| 353 | 353 | ||
| 354 | ucseg->flags = MLX5_UMR_TRANSLATION_OFFSET_EN; | 354 | ucseg->flags = MLX5_UMR_TRANSLATION_OFFSET_EN; |
| 355 | ucseg->klm_octowords = | 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 | ucseg->bsf_octowords = | 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 | ucseg->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_FREE); | 359 | ucseg->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_FREE); |
| 360 | 360 | ||
| 361 | dseg->lkey = sq->mkey_be; | 361 | dseg->lkey = sq->mkey_be; |
| @@ -423,7 +423,7 @@ static int mlx5e_alloc_rx_fragmented_mpwqe(struct mlx5e_rq *rq, | |||
| 423 | { | 423 | { |
| 424 | struct mlx5e_mpw_info *wi = &rq->wqe_info[ix]; | 424 | struct mlx5e_mpw_info *wi = &rq->wqe_info[ix]; |
| 425 | int mtt_sz = mlx5e_get_wqe_mtt_sz(); | 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 | int i; | 427 | int i; |
| 428 | 428 | ||
| 429 | wi->umr.dma_info = kmalloc(sizeof(*wi->umr.dma_info) * | 429 | wi->umr.dma_info = kmalloc(sizeof(*wi->umr.dma_info) * |
| @@ -506,6 +506,12 @@ void mlx5e_post_rx_fragmented_mpwqe(struct mlx5e_rq *rq) | |||
| 506 | struct mlx5e_rx_wqe *wqe = mlx5_wq_ll_get_wqe(wq, wq->head); | 506 | struct mlx5e_rx_wqe *wqe = mlx5_wq_ll_get_wqe(wq, wq->head); |
| 507 | 507 | ||
| 508 | clear_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state); | 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 | mlx5_wq_ll_push(wq, be16_to_cpu(wqe->next.next_wqe_index)); | 515 | mlx5_wq_ll_push(wq, be16_to_cpu(wqe->next.next_wqe_index)); |
| 510 | rq->stats.mpwqe_frag++; | 516 | rq->stats.mpwqe_frag++; |
| 511 | 517 | ||
| @@ -595,26 +601,9 @@ void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix) | |||
| 595 | wi->free_wqe(rq, wi); | 601 | wi->free_wqe(rq, wi); |
| 596 | } | 602 | } |
| 597 | 603 | ||
| 598 | void mlx5e_free_rx_descs(struct mlx5e_rq *rq) | ||
| 599 | { | ||
| 600 | struct mlx5_wq_ll *wq = &rq->wq; | ||
| 601 | struct mlx5e_rx_wqe *wqe; | ||
| 602 | __be16 wqe_ix_be; | ||
| 603 | u16 wqe_ix; | ||
| 604 | |||
| 605 | while (!mlx5_wq_ll_is_empty(wq)) { | ||
| 606 | wqe_ix_be = *wq->tail_next; | ||
| 607 | wqe_ix = be16_to_cpu(wqe_ix_be); | ||
| 608 | wqe = mlx5_wq_ll_get_wqe(&rq->wq, wqe_ix); | ||
| 609 | rq->dealloc_wqe(rq, wqe_ix); | ||
| 610 | mlx5_wq_ll_pop(&rq->wq, wqe_ix_be, | ||
| 611 | &wqe->next.next_wqe_index); | ||
| 612 | } | ||
| 613 | } | ||
| 614 | |||
| 615 | #define RQ_CANNOT_POST(rq) \ | 604 | #define RQ_CANNOT_POST(rq) \ |
| 616 | (!test_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state) || \ | 605 | (test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state) || \ |
| 617 | test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state)) | 606 | test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state)) |
| 618 | 607 | ||
| 619 | bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq) | 608 | bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq) |
| 620 | { | 609 | { |
| @@ -648,24 +637,32 @@ bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq) | |||
| 648 | static void mlx5e_lro_update_hdr(struct sk_buff *skb, struct mlx5_cqe64 *cqe, | 637 | static void mlx5e_lro_update_hdr(struct sk_buff *skb, struct mlx5_cqe64 *cqe, |
| 649 | u32 cqe_bcnt) | 638 | u32 cqe_bcnt) |
| 650 | { | 639 | { |
| 651 | struct ethhdr *eth = (struct ethhdr *)(skb->data); | 640 | struct ethhdr *eth = (struct ethhdr *)(skb->data); |
| 652 | struct iphdr *ipv4 = (struct iphdr *)(skb->data + ETH_HLEN); | 641 | struct iphdr *ipv4; |
| 653 | struct ipv6hdr *ipv6 = (struct ipv6hdr *)(skb->data + ETH_HLEN); | 642 | struct ipv6hdr *ipv6; |
| 654 | struct tcphdr *tcp; | 643 | struct tcphdr *tcp; |
| 644 | int network_depth = 0; | ||
| 645 | __be16 proto; | ||
| 646 | u16 tot_len; | ||
| 655 | 647 | ||
| 656 | u8 l4_hdr_type = get_cqe_l4_hdr_type(cqe); | 648 | u8 l4_hdr_type = get_cqe_l4_hdr_type(cqe); |
| 657 | int tcp_ack = ((CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA == l4_hdr_type) || | 649 | int tcp_ack = ((CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA == l4_hdr_type) || |
| 658 | (CQE_L4_HDR_TYPE_TCP_ACK_AND_DATA == l4_hdr_type)); | 650 | (CQE_L4_HDR_TYPE_TCP_ACK_AND_DATA == l4_hdr_type)); |
| 659 | 651 | ||
| 660 | u16 tot_len = cqe_bcnt - ETH_HLEN; | 652 | skb->mac_len = ETH_HLEN; |
| 653 | proto = __vlan_get_protocol(skb, eth->h_proto, &network_depth); | ||
| 654 | |||
| 655 | ipv4 = (struct iphdr *)(skb->data + network_depth); | ||
| 656 | ipv6 = (struct ipv6hdr *)(skb->data + network_depth); | ||
| 657 | tot_len = cqe_bcnt - network_depth; | ||
| 661 | 658 | ||
| 662 | if (eth->h_proto == htons(ETH_P_IP)) { | 659 | if (proto == htons(ETH_P_IP)) { |
| 663 | tcp = (struct tcphdr *)(skb->data + ETH_HLEN + | 660 | tcp = (struct tcphdr *)(skb->data + network_depth + |
| 664 | sizeof(struct iphdr)); | 661 | sizeof(struct iphdr)); |
| 665 | ipv6 = NULL; | 662 | ipv6 = NULL; |
| 666 | skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; | 663 | skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; |
| 667 | } else { | 664 | } else { |
| 668 | tcp = (struct tcphdr *)(skb->data + ETH_HLEN + | 665 | tcp = (struct tcphdr *)(skb->data + network_depth + |
| 669 | sizeof(struct ipv6hdr)); | 666 | sizeof(struct ipv6hdr)); |
| 670 | ipv4 = NULL; | 667 | ipv4 = NULL; |
| 671 | skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; | 668 | skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; |
| @@ -916,7 +913,7 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget) | |||
| 916 | struct mlx5e_rq *rq = container_of(cq, struct mlx5e_rq, cq); | 913 | struct mlx5e_rq *rq = container_of(cq, struct mlx5e_rq, cq); |
| 917 | int work_done = 0; | 914 | int work_done = 0; |
| 918 | 915 | ||
| 919 | if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH_TIMEOUT, &rq->state))) | 916 | if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state))) |
| 920 | return 0; | 917 | return 0; |
| 921 | 918 | ||
| 922 | if (cq->decmprs_left) | 919 | if (cq->decmprs_left) |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h index 7b9d8a989b52..499487ce3b53 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | |||
| @@ -70,6 +70,7 @@ struct mlx5e_sw_stats { | |||
| 70 | u64 tx_queue_stopped; | 70 | u64 tx_queue_stopped; |
| 71 | u64 tx_queue_wake; | 71 | u64 tx_queue_wake; |
| 72 | u64 tx_queue_dropped; | 72 | u64 tx_queue_dropped; |
| 73 | u64 tx_xmit_more; | ||
| 73 | u64 rx_wqe_err; | 74 | u64 rx_wqe_err; |
| 74 | u64 rx_mpwqe_filler; | 75 | u64 rx_mpwqe_filler; |
| 75 | u64 rx_mpwqe_frag; | 76 | u64 rx_mpwqe_frag; |
| @@ -101,6 +102,7 @@ static const struct counter_desc sw_stats_desc[] = { | |||
| 101 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) }, | 102 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) }, |
| 102 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_wake) }, | 103 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_wake) }, |
| 103 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_dropped) }, | 104 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_dropped) }, |
| 105 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_xmit_more) }, | ||
| 104 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_wqe_err) }, | 106 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_wqe_err) }, |
| 105 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_filler) }, | 107 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_filler) }, |
| 106 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_frag) }, | 108 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_frag) }, |
| @@ -298,6 +300,7 @@ struct mlx5e_sq_stats { | |||
| 298 | /* commonly accessed in data path */ | 300 | /* commonly accessed in data path */ |
| 299 | u64 packets; | 301 | u64 packets; |
| 300 | u64 bytes; | 302 | u64 bytes; |
| 303 | u64 xmit_more; | ||
| 301 | u64 tso_packets; | 304 | u64 tso_packets; |
| 302 | u64 tso_bytes; | 305 | u64 tso_bytes; |
| 303 | u64 tso_inner_packets; | 306 | u64 tso_inner_packets; |
| @@ -324,6 +327,7 @@ static const struct counter_desc sq_stats_desc[] = { | |||
| 324 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, stopped) }, | 327 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, stopped) }, |
| 325 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, wake) }, | 328 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, wake) }, |
| 326 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, dropped) }, | 329 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, dropped) }, |
| 330 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, xmit_more) }, | ||
| 327 | }; | 331 | }; |
| 328 | 332 | ||
| 329 | #define NUM_SW_COUNTERS ARRAY_SIZE(sw_stats_desc) | 333 | #define NUM_SW_COUNTERS ARRAY_SIZE(sw_stats_desc) |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index dc8b1cb0fdc8..22cfc4ac1837 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | |||
| @@ -170,7 +170,7 @@ static int parse_cls_flower(struct mlx5e_priv *priv, struct mlx5_flow_spec *spec | |||
| 170 | if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_CONTROL)) { | 170 | if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_CONTROL)) { |
| 171 | struct flow_dissector_key_control *key = | 171 | struct flow_dissector_key_control *key = |
| 172 | skb_flow_dissector_target(f->dissector, | 172 | skb_flow_dissector_target(f->dissector, |
| 173 | FLOW_DISSECTOR_KEY_BASIC, | 173 | FLOW_DISSECTOR_KEY_CONTROL, |
| 174 | f->key); | 174 | f->key); |
| 175 | addr_type = key->addr_type; | 175 | addr_type = key->addr_type; |
| 176 | } | 176 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c index e073bf59890d..eb0e72537f10 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | |||
| @@ -356,6 +356,7 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb) | |||
| 356 | sq->stats.stopped++; | 356 | sq->stats.stopped++; |
| 357 | } | 357 | } |
| 358 | 358 | ||
| 359 | sq->stats.xmit_more += skb->xmit_more; | ||
| 359 | if (!skb->xmit_more || netif_xmit_stopped(sq->txq)) { | 360 | if (!skb->xmit_more || netif_xmit_stopped(sq->txq)) { |
| 360 | int bf_sz = 0; | 361 | int bf_sz = 0; |
| 361 | 362 | ||
| @@ -394,35 +395,6 @@ netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 394 | return mlx5e_sq_xmit(sq, skb); | 395 | return mlx5e_sq_xmit(sq, skb); |
| 395 | } | 396 | } |
| 396 | 397 | ||
| 397 | void mlx5e_free_tx_descs(struct mlx5e_sq *sq) | ||
| 398 | { | ||
| 399 | struct mlx5e_tx_wqe_info *wi; | ||
| 400 | struct sk_buff *skb; | ||
| 401 | u16 ci; | ||
| 402 | int i; | ||
| 403 | |||
| 404 | while (sq->cc != sq->pc) { | ||
| 405 | ci = sq->cc & sq->wq.sz_m1; | ||
| 406 | skb = sq->skb[ci]; | ||
| 407 | wi = &sq->wqe_info[ci]; | ||
| 408 | |||
| 409 | if (!skb) { /* nop */ | ||
| 410 | sq->cc++; | ||
| 411 | continue; | ||
| 412 | } | ||
| 413 | |||
| 414 | for (i = 0; i < wi->num_dma; i++) { | ||
| 415 | struct mlx5e_sq_dma *dma = | ||
| 416 | mlx5e_dma_get(sq, sq->dma_fifo_cc++); | ||
| 417 | |||
| 418 | mlx5e_tx_dma_unmap(sq->pdev, dma); | ||
| 419 | } | ||
| 420 | |||
| 421 | dev_kfree_skb_any(skb); | ||
| 422 | sq->cc += wi->num_wqebbs; | ||
| 423 | } | ||
| 424 | } | ||
| 425 | |||
| 426 | bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget) | 398 | bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget) |
| 427 | { | 399 | { |
| 428 | struct mlx5e_sq *sq; | 400 | struct mlx5e_sq *sq; |
| @@ -434,7 +406,7 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget) | |||
| 434 | 406 | ||
| 435 | sq = container_of(cq, struct mlx5e_sq, cq); | 407 | sq = container_of(cq, struct mlx5e_sq, cq); |
| 436 | 408 | ||
| 437 | if (unlikely(test_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state))) | 409 | if (unlikely(test_bit(MLX5E_SQ_STATE_FLUSH, &sq->state))) |
| 438 | return false; | 410 | return false; |
| 439 | 411 | ||
| 440 | npkts = 0; | 412 | npkts = 0; |
| @@ -512,11 +484,39 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget) | |||
| 512 | netdev_tx_completed_queue(sq->txq, npkts, nbytes); | 484 | netdev_tx_completed_queue(sq->txq, npkts, nbytes); |
| 513 | 485 | ||
| 514 | if (netif_tx_queue_stopped(sq->txq) && | 486 | if (netif_tx_queue_stopped(sq->txq) && |
| 515 | mlx5e_sq_has_room_for(sq, MLX5E_SQ_STOP_ROOM) && | 487 | mlx5e_sq_has_room_for(sq, MLX5E_SQ_STOP_ROOM)) { |
| 516 | likely(test_bit(MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, &sq->state))) { | 488 | netif_tx_wake_queue(sq->txq); |
| 517 | netif_tx_wake_queue(sq->txq); | 489 | sq->stats.wake++; |
| 518 | sq->stats.wake++; | ||
| 519 | } | 490 | } |
| 520 | 491 | ||
| 521 | return (i == MLX5E_TX_CQ_POLL_BUDGET); | 492 | return (i == MLX5E_TX_CQ_POLL_BUDGET); |
| 522 | } | 493 | } |
| 494 | |||
| 495 | void mlx5e_free_tx_descs(struct mlx5e_sq *sq) | ||
| 496 | { | ||
| 497 | struct mlx5e_tx_wqe_info *wi; | ||
| 498 | struct sk_buff *skb; | ||
| 499 | u16 ci; | ||
| 500 | int i; | ||
| 501 | |||
| 502 | while (sq->cc != sq->pc) { | ||
| 503 | ci = sq->cc & sq->wq.sz_m1; | ||
| 504 | skb = sq->skb[ci]; | ||
| 505 | wi = &sq->wqe_info[ci]; | ||
| 506 | |||
| 507 | if (!skb) { /* nop */ | ||
| 508 | sq->cc++; | ||
| 509 | continue; | ||
| 510 | } | ||
| 511 | |||
| 512 | for (i = 0; i < wi->num_dma; i++) { | ||
| 513 | struct mlx5e_sq_dma *dma = | ||
| 514 | mlx5e_dma_get(sq, sq->dma_fifo_cc++); | ||
| 515 | |||
| 516 | mlx5e_tx_dma_unmap(sq->pdev, dma); | ||
| 517 | } | ||
| 518 | |||
| 519 | dev_kfree_skb_any(skb); | ||
| 520 | sq->cc += wi->num_wqebbs; | ||
| 521 | } | ||
| 522 | } | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c index 64ae2e800daa..9bf33bb69210 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | |||
| @@ -51,16 +51,18 @@ struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq) | |||
| 51 | 51 | ||
| 52 | static void mlx5e_poll_ico_cq(struct mlx5e_cq *cq) | 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 | struct mlx5_wq_cyc *wq; | 55 | struct mlx5_wq_cyc *wq; |
| 55 | struct mlx5_cqe64 *cqe; | 56 | struct mlx5_cqe64 *cqe; |
| 56 | struct mlx5e_sq *sq; | ||
| 57 | u16 sqcc; | 57 | u16 sqcc; |
| 58 | 58 | ||
| 59 | if (unlikely(test_bit(MLX5E_SQ_STATE_FLUSH, &sq->state))) | ||
| 60 | return; | ||
| 61 | |||
| 59 | cqe = mlx5e_get_cqe(cq); | 62 | cqe = mlx5e_get_cqe(cq); |
| 60 | if (likely(!cqe)) | 63 | if (likely(!cqe)) |
| 61 | return; | 64 | return; |
| 62 | 65 | ||
| 63 | sq = container_of(cq, struct mlx5e_sq, cq); | ||
| 64 | wq = &sq->wq; | 66 | wq = &sq->wq; |
| 65 | 67 | ||
| 66 | /* sq->cc must be updated only after mlx5_cqwq_update_db_record(), | 68 | /* sq->cc must be updated only after mlx5_cqwq_update_db_record(), |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index f6d667797ee1..8b78f156214e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | |||
| @@ -1451,7 +1451,8 @@ static void esw_enable_vport(struct mlx5_eswitch *esw, int vport_num, | |||
| 1451 | 1451 | ||
| 1452 | esw_debug(esw->dev, "Enabling VPORT(%d)\n", vport_num); | 1452 | esw_debug(esw->dev, "Enabling VPORT(%d)\n", vport_num); |
| 1453 | 1453 | ||
| 1454 | if (vport_num) { /* Only VFs need ACLs for VST and spoofchk filtering */ | 1454 | /* Only VFs need ACLs for VST and spoofchk filtering */ |
| 1455 | if (vport_num && esw->mode == SRIOV_LEGACY) { | ||
| 1455 | esw_vport_ingress_config(esw, vport); | 1456 | esw_vport_ingress_config(esw, vport); |
| 1456 | esw_vport_egress_config(esw, vport); | 1457 | esw_vport_egress_config(esw, vport); |
| 1457 | } | 1458 | } |
| @@ -1502,7 +1503,7 @@ static void esw_disable_vport(struct mlx5_eswitch *esw, int vport_num) | |||
| 1502 | */ | 1503 | */ |
| 1503 | esw_vport_change_handle_locked(vport); | 1504 | esw_vport_change_handle_locked(vport); |
| 1504 | vport->enabled_events = 0; | 1505 | vport->enabled_events = 0; |
| 1505 | if (vport_num) { | 1506 | if (vport_num && esw->mode == SRIOV_LEGACY) { |
| 1506 | esw_vport_disable_egress_acl(esw, vport); | 1507 | esw_vport_disable_egress_acl(esw, vport); |
| 1507 | esw_vport_disable_ingress_acl(esw, vport); | 1508 | esw_vport_disable_ingress_acl(esw, vport); |
| 1508 | } | 1509 | } |
| @@ -1767,7 +1768,7 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw, | |||
| 1767 | vport, err); | 1768 | vport, err); |
| 1768 | 1769 | ||
| 1769 | mutex_lock(&esw->state_lock); | 1770 | mutex_lock(&esw->state_lock); |
| 1770 | if (evport->enabled) | 1771 | if (evport->enabled && esw->mode == SRIOV_LEGACY) |
| 1771 | err = esw_vport_ingress_config(esw, evport); | 1772 | err = esw_vport_ingress_config(esw, evport); |
| 1772 | mutex_unlock(&esw->state_lock); | 1773 | mutex_unlock(&esw->state_lock); |
| 1773 | return err; | 1774 | return err; |
| @@ -1839,7 +1840,7 @@ int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw, | |||
| 1839 | mutex_lock(&esw->state_lock); | 1840 | mutex_lock(&esw->state_lock); |
| 1840 | evport->vlan = vlan; | 1841 | evport->vlan = vlan; |
| 1841 | evport->qos = qos; | 1842 | evport->qos = qos; |
| 1842 | if (evport->enabled) { | 1843 | if (evport->enabled && esw->mode == SRIOV_LEGACY) { |
| 1843 | err = esw_vport_ingress_config(esw, evport); | 1844 | err = esw_vport_ingress_config(esw, evport); |
| 1844 | if (err) | 1845 | if (err) |
| 1845 | goto out; | 1846 | goto out; |
| @@ -1868,10 +1869,11 @@ int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, | |||
| 1868 | mutex_lock(&esw->state_lock); | 1869 | mutex_lock(&esw->state_lock); |
| 1869 | pschk = evport->spoofchk; | 1870 | pschk = evport->spoofchk; |
| 1870 | evport->spoofchk = spoofchk; | 1871 | evport->spoofchk = spoofchk; |
| 1871 | if (evport->enabled) | 1872 | if (evport->enabled && esw->mode == SRIOV_LEGACY) { |
| 1872 | err = esw_vport_ingress_config(esw, evport); | 1873 | err = esw_vport_ingress_config(esw, evport); |
| 1873 | if (err) | 1874 | if (err) |
| 1874 | evport->spoofchk = pschk; | 1875 | evport->spoofchk = pschk; |
| 1876 | } | ||
| 1875 | mutex_unlock(&esw->state_lock); | 1877 | mutex_unlock(&esw->state_lock); |
| 1876 | 1878 | ||
| 1877 | return err; | 1879 | return err; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h index c0b05603fc31..a96140971d77 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | |||
| @@ -174,6 +174,7 @@ struct mlx5_eswitch_rep { | |||
| 174 | void *priv_data; | 174 | void *priv_data; |
| 175 | struct list_head vport_sqs_list; | 175 | struct list_head vport_sqs_list; |
| 176 | bool valid; | 176 | bool valid; |
| 177 | u8 hw_id[ETH_ALEN]; | ||
| 177 | }; | 178 | }; |
| 178 | 179 | ||
| 179 | struct mlx5_esw_offload { | 180 | struct mlx5_esw_offload { |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index a357e8eeeed8..3dc83a9459a4 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | |||
| @@ -113,7 +113,7 @@ mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw, int vport, u32 sqn | |||
| 113 | dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT; | 113 | dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT; |
| 114 | dest.vport_num = vport; | 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 | MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, | 117 | MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, |
| 118 | 0, &dest); | 118 | 0, &dest); |
| 119 | if (IS_ERR(flow_rule)) | 119 | if (IS_ERR(flow_rule)) |
| @@ -535,7 +535,7 @@ void esw_offloads_cleanup(struct mlx5_eswitch *esw, int nvports) | |||
| 535 | esw_destroy_offloads_fdb_table(esw); | 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 | switch (mode) { | 540 | switch (mode) { |
| 541 | case DEVLINK_ESWITCH_MODE_LEGACY: | 541 | case DEVLINK_ESWITCH_MODE_LEGACY: |
| @@ -551,6 +551,22 @@ static int mlx5_esw_mode_from_devlink(u16 mode, u16 *mlx5_mode) | |||
| 551 | return 0; | 551 | return 0; |
| 552 | } | 552 | } |
| 553 | 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; | ||
| 562 | break; | ||
| 563 | default: | ||
| 564 | return -EINVAL; | ||
| 565 | } | ||
| 566 | |||
| 567 | return 0; | ||
| 568 | } | ||
| 569 | |||
| 554 | int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode) | 570 | int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode) |
| 555 | { | 571 | { |
| 556 | struct mlx5_core_dev *dev; | 572 | struct mlx5_core_dev *dev; |
| @@ -566,7 +582,7 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode) | |||
| 566 | if (cur_mlx5_mode == SRIOV_NONE) | 582 | if (cur_mlx5_mode == SRIOV_NONE) |
| 567 | return -EOPNOTSUPP; | 583 | return -EOPNOTSUPP; |
| 568 | 584 | ||
| 569 | if (mlx5_esw_mode_from_devlink(mode, &mlx5_mode)) | 585 | if (esw_mode_from_devlink(mode, &mlx5_mode)) |
| 570 | return -EINVAL; | 586 | return -EINVAL; |
| 571 | 587 | ||
| 572 | if (cur_mlx5_mode == mlx5_mode) | 588 | if (cur_mlx5_mode == mlx5_mode) |
| @@ -592,9 +608,7 @@ int mlx5_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode) | |||
| 592 | if (dev->priv.eswitch->mode == SRIOV_NONE) | 608 | if (dev->priv.eswitch->mode == SRIOV_NONE) |
| 593 | return -EOPNOTSUPP; | 609 | return -EOPNOTSUPP; |
| 594 | 610 | ||
| 595 | *mode = dev->priv.eswitch->mode; | 611 | return esw_mode_to_devlink(dev->priv.eswitch->mode, mode); |
| 596 | |||
| 597 | return 0; | ||
| 598 | } | 612 | } |
| 599 | 613 | ||
| 600 | void mlx5_eswitch_register_vport_rep(struct mlx5_eswitch *esw, | 614 | void mlx5_eswitch_register_vport_rep(struct mlx5_eswitch *esw, |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c index 75bb8c864557..3d6c1f65e586 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | |||
| @@ -80,7 +80,7 @@ | |||
| 80 | LEFTOVERS_NUM_PRIOS) | 80 | LEFTOVERS_NUM_PRIOS) |
| 81 | 81 | ||
| 82 | #define ETHTOOL_PRIO_NUM_LEVELS 1 | 82 | #define ETHTOOL_PRIO_NUM_LEVELS 1 |
| 83 | #define ETHTOOL_NUM_PRIOS 10 | 83 | #define ETHTOOL_NUM_PRIOS 11 |
| 84 | #define ETHTOOL_MIN_LEVEL (KERNEL_MIN_LEVEL + ETHTOOL_NUM_PRIOS) | 84 | #define ETHTOOL_MIN_LEVEL (KERNEL_MIN_LEVEL + ETHTOOL_NUM_PRIOS) |
| 85 | /* Vlan, mac, ttc, aRFS */ | 85 | /* Vlan, mac, ttc, aRFS */ |
| 86 | #define KERNEL_NIC_PRIO_NUM_LEVELS 4 | 86 | #define KERNEL_NIC_PRIO_NUM_LEVELS 4 |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c index c2877e9de8a1..3a9195b4169d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c | |||
| @@ -126,12 +126,21 @@ static struct rb_node *mlx5_fc_stats_query(struct mlx5_core_dev *dev, | |||
| 126 | for (node = &first->node; node; node = rb_next(node)) { | 126 | for (node = &first->node; node; node = rb_next(node)) { |
| 127 | struct mlx5_fc *counter = rb_entry(node, struct mlx5_fc, node); | 127 | struct mlx5_fc *counter = rb_entry(node, struct mlx5_fc, node); |
| 128 | struct mlx5_fc_cache *c = &counter->cache; | 128 | struct mlx5_fc_cache *c = &counter->cache; |
| 129 | u64 packets; | ||
| 130 | u64 bytes; | ||
| 129 | 131 | ||
| 130 | if (counter->id > last_id) | 132 | if (counter->id > last_id) |
| 131 | break; | 133 | break; |
| 132 | 134 | ||
| 133 | mlx5_cmd_fc_bulk_get(dev, b, | 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 | out: | 146 | out: |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 4f491d43e77d..2385bae92672 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c | |||
| @@ -1420,36 +1420,12 @@ static pci_ers_result_t mlx5_pci_err_detected(struct pci_dev *pdev, | |||
| 1420 | dev_info(&pdev->dev, "%s was called\n", __func__); | 1420 | dev_info(&pdev->dev, "%s was called\n", __func__); |
| 1421 | mlx5_enter_error_state(dev); | 1421 | mlx5_enter_error_state(dev); |
| 1422 | mlx5_unload_one(dev, priv); | 1422 | mlx5_unload_one(dev, priv); |
| 1423 | pci_save_state(pdev); | ||
| 1423 | mlx5_pci_disable_device(dev); | 1424 | mlx5_pci_disable_device(dev); |
| 1424 | return state == pci_channel_io_perm_failure ? | 1425 | return state == pci_channel_io_perm_failure ? |
| 1425 | PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET; | 1426 | PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET; |
| 1426 | } | 1427 | } |
| 1427 | 1428 | ||
| 1428 | static pci_ers_result_t mlx5_pci_slot_reset(struct pci_dev *pdev) | ||
| 1429 | { | ||
| 1430 | struct mlx5_core_dev *dev = pci_get_drvdata(pdev); | ||
| 1431 | int err = 0; | ||
| 1432 | |||
| 1433 | dev_info(&pdev->dev, "%s was called\n", __func__); | ||
| 1434 | |||
| 1435 | err = mlx5_pci_enable_device(dev); | ||
| 1436 | if (err) { | ||
| 1437 | dev_err(&pdev->dev, "%s: mlx5_pci_enable_device failed with error code: %d\n" | ||
| 1438 | , __func__, err); | ||
| 1439 | return PCI_ERS_RESULT_DISCONNECT; | ||
| 1440 | } | ||
| 1441 | pci_set_master(pdev); | ||
| 1442 | pci_set_power_state(pdev, PCI_D0); | ||
| 1443 | pci_restore_state(pdev); | ||
| 1444 | |||
| 1445 | return err ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED; | ||
| 1446 | } | ||
| 1447 | |||
| 1448 | void mlx5_disable_device(struct mlx5_core_dev *dev) | ||
| 1449 | { | ||
| 1450 | mlx5_pci_err_detected(dev->pdev, 0); | ||
| 1451 | } | ||
| 1452 | |||
| 1453 | /* wait for the device to show vital signs by waiting | 1429 | /* wait for the device to show vital signs by waiting |
| 1454 | * for the health counter to start counting. | 1430 | * for the health counter to start counting. |
| 1455 | */ | 1431 | */ |
| @@ -1477,21 +1453,44 @@ static int wait_vital(struct pci_dev *pdev) | |||
| 1477 | return -ETIMEDOUT; | 1453 | return -ETIMEDOUT; |
| 1478 | } | 1454 | } |
| 1479 | 1455 | ||
| 1480 | static void mlx5_pci_resume(struct pci_dev *pdev) | 1456 | static pci_ers_result_t mlx5_pci_slot_reset(struct pci_dev *pdev) |
| 1481 | { | 1457 | { |
| 1482 | struct mlx5_core_dev *dev = pci_get_drvdata(pdev); | 1458 | struct mlx5_core_dev *dev = pci_get_drvdata(pdev); |
| 1483 | struct mlx5_priv *priv = &dev->priv; | ||
| 1484 | int err; | 1459 | int err; |
| 1485 | 1460 | ||
| 1486 | dev_info(&pdev->dev, "%s was called\n", __func__); | 1461 | dev_info(&pdev->dev, "%s was called\n", __func__); |
| 1487 | 1462 | ||
| 1488 | pci_save_state(pdev); | 1463 | err = mlx5_pci_enable_device(dev); |
| 1489 | err = wait_vital(pdev); | ||
| 1490 | if (err) { | 1464 | if (err) { |
| 1465 | dev_err(&pdev->dev, "%s: mlx5_pci_enable_device failed with error code: %d\n" | ||
| 1466 | , __func__, err); | ||
| 1467 | return PCI_ERS_RESULT_DISCONNECT; | ||
| 1468 | } | ||
| 1469 | |||
| 1470 | pci_set_master(pdev); | ||
| 1471 | pci_restore_state(pdev); | ||
| 1472 | |||
| 1473 | if (wait_vital(pdev)) { | ||
| 1491 | dev_err(&pdev->dev, "%s: wait_vital timed out\n", __func__); | 1474 | dev_err(&pdev->dev, "%s: wait_vital timed out\n", __func__); |
| 1492 | return; | 1475 | return PCI_ERS_RESULT_DISCONNECT; |
| 1493 | } | 1476 | } |
| 1494 | 1477 | ||
| 1478 | return PCI_ERS_RESULT_RECOVERED; | ||
| 1479 | } | ||
| 1480 | |||
| 1481 | void mlx5_disable_device(struct mlx5_core_dev *dev) | ||
| 1482 | { | ||
| 1483 | mlx5_pci_err_detected(dev->pdev, 0); | ||
| 1484 | } | ||
| 1485 | |||
| 1486 | static void mlx5_pci_resume(struct pci_dev *pdev) | ||
| 1487 | { | ||
| 1488 | struct mlx5_core_dev *dev = pci_get_drvdata(pdev); | ||
| 1489 | struct mlx5_priv *priv = &dev->priv; | ||
| 1490 | int err; | ||
| 1491 | |||
| 1492 | dev_info(&pdev->dev, "%s was called\n", __func__); | ||
| 1493 | |||
| 1495 | err = mlx5_load_one(dev, priv); | 1494 | err = mlx5_load_one(dev, priv); |
| 1496 | if (err) | 1495 | if (err) |
| 1497 | dev_err(&pdev->dev, "%s: mlx5_load_one failed with error code: %d\n" | 1496 | dev_err(&pdev->dev, "%s: mlx5_load_one failed with error code: %d\n" |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/port.h b/drivers/net/ethernet/mellanox/mlxsw/port.h index f33b997f2b61..af371a82c35b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/port.h +++ b/drivers/net/ethernet/mellanox/mlxsw/port.h | |||
| @@ -56,6 +56,7 @@ | |||
| 56 | #define MLXSW_PORT_PHY_BITS_MASK (MLXSW_PORT_MAX_PHY_PORTS - 1) | 56 | #define MLXSW_PORT_PHY_BITS_MASK (MLXSW_PORT_MAX_PHY_PORTS - 1) |
| 57 | 57 | ||
| 58 | #define MLXSW_PORT_CPU_PORT 0x0 | 58 | #define MLXSW_PORT_CPU_PORT 0x0 |
| 59 | #define MLXSW_PORT_ROUTER_PORT (MLXSW_PORT_MAX_PHY_PORTS + 2) | ||
| 59 | 60 | ||
| 60 | #define MLXSW_PORT_DONT_CARE (MLXSW_PORT_MAX_PORTS) | 61 | #define MLXSW_PORT_DONT_CARE (MLXSW_PORT_MAX_PORTS) |
| 61 | 62 | ||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 1f8168906811..d48873bcbddf 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c | |||
| @@ -56,6 +56,7 @@ | |||
| 56 | #include <generated/utsrelease.h> | 56 | #include <generated/utsrelease.h> |
| 57 | #include <net/pkt_cls.h> | 57 | #include <net/pkt_cls.h> |
| 58 | #include <net/tc_act/tc_mirred.h> | 58 | #include <net/tc_act/tc_mirred.h> |
| 59 | #include <net/netevent.h> | ||
| 59 | 60 | ||
| 60 | #include "spectrum.h" | 61 | #include "spectrum.h" |
| 61 | #include "core.h" | 62 | #include "core.h" |
| @@ -2105,6 +2106,13 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, | |||
| 2105 | dev->netdev_ops = &mlxsw_sp_port_netdev_ops; | 2106 | dev->netdev_ops = &mlxsw_sp_port_netdev_ops; |
| 2106 | dev->ethtool_ops = &mlxsw_sp_port_ethtool_ops; | 2107 | dev->ethtool_ops = &mlxsw_sp_port_ethtool_ops; |
| 2107 | 2108 | ||
| 2109 | err = mlxsw_sp_port_swid_set(mlxsw_sp_port, 0); | ||
| 2110 | if (err) { | ||
| 2111 | dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set SWID\n", | ||
| 2112 | mlxsw_sp_port->local_port); | ||
| 2113 | goto err_port_swid_set; | ||
| 2114 | } | ||
| 2115 | |||
| 2108 | err = mlxsw_sp_port_dev_addr_init(mlxsw_sp_port); | 2116 | err = mlxsw_sp_port_dev_addr_init(mlxsw_sp_port); |
| 2109 | if (err) { | 2117 | if (err) { |
| 2110 | dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unable to init port mac address\n", | 2118 | dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unable to init port mac address\n", |
| @@ -2130,13 +2138,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, | |||
| 2130 | goto err_port_system_port_mapping_set; | 2138 | goto err_port_system_port_mapping_set; |
| 2131 | } | 2139 | } |
| 2132 | 2140 | ||
| 2133 | err = mlxsw_sp_port_swid_set(mlxsw_sp_port, 0); | ||
| 2134 | if (err) { | ||
| 2135 | dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set SWID\n", | ||
| 2136 | mlxsw_sp_port->local_port); | ||
| 2137 | goto err_port_swid_set; | ||
| 2138 | } | ||
| 2139 | |||
| 2140 | err = mlxsw_sp_port_speed_by_width_set(mlxsw_sp_port, width); | 2141 | err = mlxsw_sp_port_speed_by_width_set(mlxsw_sp_port, width); |
| 2141 | if (err) { | 2142 | if (err) { |
| 2142 | dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to enable speeds\n", | 2143 | dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to enable speeds\n", |
| @@ -2218,10 +2219,10 @@ err_port_buffers_init: | |||
| 2218 | err_port_admin_status_set: | 2219 | err_port_admin_status_set: |
| 2219 | err_port_mtu_set: | 2220 | err_port_mtu_set: |
| 2220 | err_port_speed_by_width_set: | 2221 | err_port_speed_by_width_set: |
| 2221 | mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT); | ||
| 2222 | err_port_swid_set: | ||
| 2223 | err_port_system_port_mapping_set: | 2222 | err_port_system_port_mapping_set: |
| 2224 | err_dev_addr_init: | 2223 | err_dev_addr_init: |
| 2224 | mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT); | ||
| 2225 | err_port_swid_set: | ||
| 2225 | free_percpu(mlxsw_sp_port->pcpu_stats); | 2226 | free_percpu(mlxsw_sp_port->pcpu_stats); |
| 2226 | err_alloc_stats: | 2227 | err_alloc_stats: |
| 2227 | kfree(mlxsw_sp_port->untagged_vlans); | 2228 | kfree(mlxsw_sp_port->untagged_vlans); |
| @@ -3324,6 +3325,39 @@ static struct mlxsw_sp_fid *mlxsw_sp_bridge_fid_get(struct mlxsw_sp *mlxsw_sp, | |||
| 3324 | return mlxsw_sp_fid_find(mlxsw_sp, fid); | 3325 | return mlxsw_sp_fid_find(mlxsw_sp, fid); |
| 3325 | } | 3326 | } |
| 3326 | 3327 | ||
| 3328 | static enum mlxsw_flood_table_type mlxsw_sp_flood_table_type_get(u16 fid) | ||
| 3329 | { | ||
| 3330 | return mlxsw_sp_fid_is_vfid(fid) ? MLXSW_REG_SFGC_TABLE_TYPE_FID : | ||
| 3331 | MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST; | ||
| 3332 | } | ||
| 3333 | |||
| 3334 | static u16 mlxsw_sp_flood_table_index_get(u16 fid) | ||
| 3335 | { | ||
| 3336 | return mlxsw_sp_fid_is_vfid(fid) ? mlxsw_sp_fid_to_vfid(fid) : fid; | ||
| 3337 | } | ||
| 3338 | |||
| 3339 | static int mlxsw_sp_router_port_flood_set(struct mlxsw_sp *mlxsw_sp, u16 fid, | ||
| 3340 | bool set) | ||
| 3341 | { | ||
| 3342 | enum mlxsw_flood_table_type table_type; | ||
| 3343 | char *sftr_pl; | ||
| 3344 | u16 index; | ||
| 3345 | int err; | ||
| 3346 | |||
| 3347 | sftr_pl = kmalloc(MLXSW_REG_SFTR_LEN, GFP_KERNEL); | ||
| 3348 | if (!sftr_pl) | ||
| 3349 | return -ENOMEM; | ||
| 3350 | |||
| 3351 | table_type = mlxsw_sp_flood_table_type_get(fid); | ||
| 3352 | index = mlxsw_sp_flood_table_index_get(fid); | ||
| 3353 | mlxsw_reg_sftr_pack(sftr_pl, MLXSW_SP_FLOOD_TABLE_BM, index, table_type, | ||
| 3354 | 1, MLXSW_PORT_ROUTER_PORT, set); | ||
| 3355 | err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl); | ||
| 3356 | |||
| 3357 | kfree(sftr_pl); | ||
| 3358 | return err; | ||
| 3359 | } | ||
| 3360 | |||
| 3327 | static enum mlxsw_reg_ritr_if_type mlxsw_sp_rif_type_get(u16 fid) | 3361 | static enum mlxsw_reg_ritr_if_type mlxsw_sp_rif_type_get(u16 fid) |
| 3328 | { | 3362 | { |
| 3329 | if (mlxsw_sp_fid_is_vfid(fid)) | 3363 | if (mlxsw_sp_fid_is_vfid(fid)) |
| @@ -3360,10 +3394,14 @@ static int mlxsw_sp_rif_bridge_create(struct mlxsw_sp *mlxsw_sp, | |||
| 3360 | if (rif == MLXSW_SP_RIF_MAX) | 3394 | if (rif == MLXSW_SP_RIF_MAX) |
| 3361 | return -ERANGE; | 3395 | return -ERANGE; |
| 3362 | 3396 | ||
| 3363 | err = mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, true); | 3397 | err = mlxsw_sp_router_port_flood_set(mlxsw_sp, f->fid, true); |
| 3364 | if (err) | 3398 | if (err) |
| 3365 | return err; | 3399 | return err; |
| 3366 | 3400 | ||
| 3401 | err = mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, true); | ||
| 3402 | if (err) | ||
| 3403 | goto err_rif_bridge_op; | ||
| 3404 | |||
| 3367 | err = mlxsw_sp_rif_fdb_op(mlxsw_sp, l3_dev->dev_addr, f->fid, true); | 3405 | err = mlxsw_sp_rif_fdb_op(mlxsw_sp, l3_dev->dev_addr, f->fid, true); |
| 3368 | if (err) | 3406 | if (err) |
| 3369 | goto err_rif_fdb_op; | 3407 | goto err_rif_fdb_op; |
| @@ -3385,6 +3423,8 @@ err_rif_alloc: | |||
| 3385 | mlxsw_sp_rif_fdb_op(mlxsw_sp, l3_dev->dev_addr, f->fid, false); | 3423 | mlxsw_sp_rif_fdb_op(mlxsw_sp, l3_dev->dev_addr, f->fid, false); |
| 3386 | err_rif_fdb_op: | 3424 | err_rif_fdb_op: |
| 3387 | mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, false); | 3425 | mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, false); |
| 3426 | err_rif_bridge_op: | ||
| 3427 | mlxsw_sp_router_port_flood_set(mlxsw_sp, f->fid, false); | ||
| 3388 | return err; | 3428 | return err; |
| 3389 | } | 3429 | } |
| 3390 | 3430 | ||
| @@ -3404,6 +3444,8 @@ void mlxsw_sp_rif_bridge_destroy(struct mlxsw_sp *mlxsw_sp, | |||
| 3404 | 3444 | ||
| 3405 | mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, false); | 3445 | mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, false); |
| 3406 | 3446 | ||
| 3447 | mlxsw_sp_router_port_flood_set(mlxsw_sp, f->fid, false); | ||
| 3448 | |||
| 3407 | netdev_dbg(l3_dev, "RIF=%d destroyed\n", rif); | 3449 | netdev_dbg(l3_dev, "RIF=%d destroyed\n", rif); |
| 3408 | } | 3450 | } |
| 3409 | 3451 | ||
| @@ -4500,18 +4542,26 @@ static struct notifier_block mlxsw_sp_inetaddr_nb __read_mostly = { | |||
| 4500 | .priority = 10, /* Must be called before FIB notifier block */ | 4542 | .priority = 10, /* Must be called before FIB notifier block */ |
| 4501 | }; | 4543 | }; |
| 4502 | 4544 | ||
| 4545 | static struct notifier_block mlxsw_sp_router_netevent_nb __read_mostly = { | ||
| 4546 | .notifier_call = mlxsw_sp_router_netevent_event, | ||
| 4547 | }; | ||
| 4548 | |||
| 4503 | static int __init mlxsw_sp_module_init(void) | 4549 | static int __init mlxsw_sp_module_init(void) |
| 4504 | { | 4550 | { |
| 4505 | int err; | 4551 | int err; |
| 4506 | 4552 | ||
| 4507 | register_netdevice_notifier(&mlxsw_sp_netdevice_nb); | 4553 | register_netdevice_notifier(&mlxsw_sp_netdevice_nb); |
| 4508 | register_inetaddr_notifier(&mlxsw_sp_inetaddr_nb); | 4554 | register_inetaddr_notifier(&mlxsw_sp_inetaddr_nb); |
| 4555 | register_netevent_notifier(&mlxsw_sp_router_netevent_nb); | ||
| 4556 | |||
| 4509 | err = mlxsw_core_driver_register(&mlxsw_sp_driver); | 4557 | err = mlxsw_core_driver_register(&mlxsw_sp_driver); |
| 4510 | if (err) | 4558 | if (err) |
| 4511 | goto err_core_driver_register; | 4559 | goto err_core_driver_register; |
| 4512 | return 0; | 4560 | return 0; |
| 4513 | 4561 | ||
| 4514 | err_core_driver_register: | 4562 | err_core_driver_register: |
| 4563 | unregister_netevent_notifier(&mlxsw_sp_router_netevent_nb); | ||
| 4564 | unregister_inetaddr_notifier(&mlxsw_sp_inetaddr_nb); | ||
| 4515 | unregister_netdevice_notifier(&mlxsw_sp_netdevice_nb); | 4565 | unregister_netdevice_notifier(&mlxsw_sp_netdevice_nb); |
| 4516 | return err; | 4566 | return err; |
| 4517 | } | 4567 | } |
| @@ -4519,6 +4569,7 @@ err_core_driver_register: | |||
| 4519 | static void __exit mlxsw_sp_module_exit(void) | 4569 | static void __exit mlxsw_sp_module_exit(void) |
| 4520 | { | 4570 | { |
| 4521 | mlxsw_core_driver_unregister(&mlxsw_sp_driver); | 4571 | mlxsw_core_driver_unregister(&mlxsw_sp_driver); |
| 4572 | unregister_netevent_notifier(&mlxsw_sp_router_netevent_nb); | ||
| 4522 | unregister_inetaddr_notifier(&mlxsw_sp_inetaddr_nb); | 4573 | unregister_inetaddr_notifier(&mlxsw_sp_inetaddr_nb); |
| 4523 | unregister_netdevice_notifier(&mlxsw_sp_netdevice_nb); | 4574 | unregister_netdevice_notifier(&mlxsw_sp_netdevice_nb); |
| 4524 | } | 4575 | } |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index ab3feb81bd43..ac48abebe904 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h | |||
| @@ -587,6 +587,8 @@ int mlxsw_sp_router_neigh_construct(struct net_device *dev, | |||
| 587 | struct neighbour *n); | 587 | struct neighbour *n); |
| 588 | void mlxsw_sp_router_neigh_destroy(struct net_device *dev, | 588 | void mlxsw_sp_router_neigh_destroy(struct net_device *dev, |
| 589 | struct neighbour *n); | 589 | struct neighbour *n); |
| 590 | int mlxsw_sp_router_netevent_event(struct notifier_block *unused, | ||
| 591 | unsigned long event, void *ptr); | ||
| 590 | 592 | ||
| 591 | int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count); | 593 | int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count); |
| 592 | void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index); | 594 | void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index); |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c index 237418a0e6e0..953b214f38d0 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c | |||
| @@ -717,22 +717,18 @@ int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port, | |||
| 717 | u8 local_port = mlxsw_sp_port->local_port; | 717 | u8 local_port = mlxsw_sp_port->local_port; |
| 718 | u8 pg_buff = tc_index; | 718 | u8 pg_buff = tc_index; |
| 719 | enum mlxsw_reg_sbxx_dir dir = pool_type; | 719 | enum mlxsw_reg_sbxx_dir dir = pool_type; |
| 720 | u8 pool = pool_index; | 720 | u8 pool = pool_get(pool_index); |
| 721 | u32 max_buff; | 721 | u32 max_buff; |
| 722 | int err; | 722 | int err; |
| 723 | 723 | ||
| 724 | if (dir != dir_get(pool_index)) | ||
| 725 | return -EINVAL; | ||
| 726 | |||
| 724 | err = mlxsw_sp_sb_threshold_in(mlxsw_sp, pool, dir, | 727 | err = mlxsw_sp_sb_threshold_in(mlxsw_sp, pool, dir, |
| 725 | threshold, &max_buff); | 728 | threshold, &max_buff); |
| 726 | if (err) | 729 | if (err) |
| 727 | return err; | 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 | return mlxsw_sp_sb_cm_write(mlxsw_sp, local_port, pg_buff, dir, | 732 | return mlxsw_sp_sb_cm_write(mlxsw_sp, local_port, pg_buff, dir, |
| 737 | 0, max_buff, pool); | 733 | 0, max_buff, pool); |
| 738 | } | 734 | } |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 90bb93b037ec..3f5c51da6d3e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | |||
| @@ -107,6 +107,7 @@ mlxsw_sp_prefix_usage_clear(struct mlxsw_sp_prefix_usage *prefix_usage, | |||
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | struct mlxsw_sp_fib_key { | 109 | struct mlxsw_sp_fib_key { |
| 110 | struct net_device *dev; | ||
| 110 | unsigned char addr[sizeof(struct in6_addr)]; | 111 | unsigned char addr[sizeof(struct in6_addr)]; |
| 111 | unsigned char prefix_len; | 112 | unsigned char prefix_len; |
| 112 | }; | 113 | }; |
| @@ -123,7 +124,7 @@ struct mlxsw_sp_fib_entry { | |||
| 123 | struct rhash_head ht_node; | 124 | struct rhash_head ht_node; |
| 124 | struct mlxsw_sp_fib_key key; | 125 | struct mlxsw_sp_fib_key key; |
| 125 | enum mlxsw_sp_fib_entry_type type; | 126 | enum mlxsw_sp_fib_entry_type type; |
| 126 | u8 added:1; | 127 | unsigned int ref_count; |
| 127 | u16 rif; /* used for action local */ | 128 | u16 rif; /* used for action local */ |
| 128 | struct mlxsw_sp_vr *vr; | 129 | struct mlxsw_sp_vr *vr; |
| 129 | struct list_head nexthop_group_node; | 130 | struct list_head nexthop_group_node; |
| @@ -171,13 +172,15 @@ static void mlxsw_sp_fib_entry_remove(struct mlxsw_sp_fib *fib, | |||
| 171 | 172 | ||
| 172 | static struct mlxsw_sp_fib_entry * | 173 | static struct mlxsw_sp_fib_entry * |
| 173 | mlxsw_sp_fib_entry_create(struct mlxsw_sp_fib *fib, const void *addr, | 174 | mlxsw_sp_fib_entry_create(struct mlxsw_sp_fib *fib, const void *addr, |
| 174 | size_t addr_len, unsigned char prefix_len) | 175 | size_t addr_len, unsigned char prefix_len, |
| 176 | struct net_device *dev) | ||
| 175 | { | 177 | { |
| 176 | struct mlxsw_sp_fib_entry *fib_entry; | 178 | struct mlxsw_sp_fib_entry *fib_entry; |
| 177 | 179 | ||
| 178 | fib_entry = kzalloc(sizeof(*fib_entry), GFP_KERNEL); | 180 | fib_entry = kzalloc(sizeof(*fib_entry), GFP_KERNEL); |
| 179 | if (!fib_entry) | 181 | if (!fib_entry) |
| 180 | return NULL; | 182 | return NULL; |
| 183 | fib_entry->key.dev = dev; | ||
| 181 | memcpy(fib_entry->key.addr, addr, addr_len); | 184 | memcpy(fib_entry->key.addr, addr, addr_len); |
| 182 | fib_entry->key.prefix_len = prefix_len; | 185 | fib_entry->key.prefix_len = prefix_len; |
| 183 | return fib_entry; | 186 | return fib_entry; |
| @@ -190,10 +193,13 @@ static void mlxsw_sp_fib_entry_destroy(struct mlxsw_sp_fib_entry *fib_entry) | |||
| 190 | 193 | ||
| 191 | static struct mlxsw_sp_fib_entry * | 194 | static struct mlxsw_sp_fib_entry * |
| 192 | mlxsw_sp_fib_entry_lookup(struct mlxsw_sp_fib *fib, const void *addr, | 195 | mlxsw_sp_fib_entry_lookup(struct mlxsw_sp_fib *fib, const void *addr, |
| 193 | size_t addr_len, unsigned char prefix_len) | 196 | size_t addr_len, unsigned char prefix_len, |
| 197 | struct net_device *dev) | ||
| 194 | { | 198 | { |
| 195 | struct mlxsw_sp_fib_key key = {{ 0 } }; | 199 | struct mlxsw_sp_fib_key key; |
| 196 | 200 | ||
| 201 | memset(&key, 0, sizeof(key)); | ||
| 202 | key.dev = dev; | ||
| 197 | memcpy(key.addr, addr, addr_len); | 203 | memcpy(key.addr, addr, addr_len); |
| 198 | key.prefix_len = prefix_len; | 204 | key.prefix_len = prefix_len; |
| 199 | return rhashtable_lookup_fast(&fib->ht, &key, mlxsw_sp_fib_ht_params); | 205 | return rhashtable_lookup_fast(&fib->ht, &key, mlxsw_sp_fib_ht_params); |
| @@ -657,7 +663,7 @@ int mlxsw_sp_router_neigh_construct(struct net_device *dev, | |||
| 657 | return 0; | 663 | return 0; |
| 658 | } | 664 | } |
| 659 | 665 | ||
| 660 | r = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); | 666 | r = mlxsw_sp_rif_find_by_dev(mlxsw_sp, n->dev); |
| 661 | if (WARN_ON(!r)) | 667 | if (WARN_ON(!r)) |
| 662 | return -EINVAL; | 668 | return -EINVAL; |
| 663 | 669 | ||
| @@ -938,8 +944,8 @@ static void mlxsw_sp_router_neigh_update_hw(struct work_struct *work) | |||
| 938 | mlxsw_sp_port_dev_put(mlxsw_sp_port); | 944 | mlxsw_sp_port_dev_put(mlxsw_sp_port); |
| 939 | } | 945 | } |
| 940 | 946 | ||
| 941 | static int mlxsw_sp_router_netevent_event(struct notifier_block *unused, | 947 | int mlxsw_sp_router_netevent_event(struct notifier_block *unused, |
| 942 | unsigned long event, void *ptr) | 948 | unsigned long event, void *ptr) |
| 943 | { | 949 | { |
| 944 | struct mlxsw_sp_neigh_entry *neigh_entry; | 950 | struct mlxsw_sp_neigh_entry *neigh_entry; |
| 945 | struct mlxsw_sp_port *mlxsw_sp_port; | 951 | struct mlxsw_sp_port *mlxsw_sp_port; |
| @@ -1009,10 +1015,6 @@ static int mlxsw_sp_router_netevent_event(struct notifier_block *unused, | |||
| 1009 | return NOTIFY_DONE; | 1015 | return NOTIFY_DONE; |
| 1010 | } | 1016 | } |
| 1011 | 1017 | ||
| 1012 | static struct notifier_block mlxsw_sp_router_netevent_nb __read_mostly = { | ||
| 1013 | .notifier_call = mlxsw_sp_router_netevent_event, | ||
| 1014 | }; | ||
| 1015 | |||
| 1016 | static int mlxsw_sp_neigh_init(struct mlxsw_sp *mlxsw_sp) | 1018 | static int mlxsw_sp_neigh_init(struct mlxsw_sp *mlxsw_sp) |
| 1017 | { | 1019 | { |
| 1018 | int err; | 1020 | int err; |
| @@ -1027,10 +1029,6 @@ static int mlxsw_sp_neigh_init(struct mlxsw_sp *mlxsw_sp) | |||
| 1027 | */ | 1029 | */ |
| 1028 | mlxsw_sp_router_neighs_update_interval_init(mlxsw_sp); | 1030 | mlxsw_sp_router_neighs_update_interval_init(mlxsw_sp); |
| 1029 | 1031 | ||
| 1030 | err = register_netevent_notifier(&mlxsw_sp_router_netevent_nb); | ||
| 1031 | if (err) | ||
| 1032 | goto err_register_netevent_notifier; | ||
| 1033 | |||
| 1034 | /* Create the delayed works for the activity_update */ | 1032 | /* Create the delayed works for the activity_update */ |
| 1035 | INIT_DELAYED_WORK(&mlxsw_sp->router.neighs_update.dw, | 1033 | INIT_DELAYED_WORK(&mlxsw_sp->router.neighs_update.dw, |
| 1036 | mlxsw_sp_router_neighs_update_work); | 1034 | mlxsw_sp_router_neighs_update_work); |
| @@ -1039,17 +1037,12 @@ static int mlxsw_sp_neigh_init(struct mlxsw_sp *mlxsw_sp) | |||
| 1039 | mlxsw_core_schedule_dw(&mlxsw_sp->router.neighs_update.dw, 0); | 1037 | mlxsw_core_schedule_dw(&mlxsw_sp->router.neighs_update.dw, 0); |
| 1040 | mlxsw_core_schedule_dw(&mlxsw_sp->router.nexthop_probe_dw, 0); | 1038 | mlxsw_core_schedule_dw(&mlxsw_sp->router.nexthop_probe_dw, 0); |
| 1041 | return 0; | 1039 | return 0; |
| 1042 | |||
| 1043 | err_register_netevent_notifier: | ||
| 1044 | rhashtable_destroy(&mlxsw_sp->router.neigh_ht); | ||
| 1045 | return err; | ||
| 1046 | } | 1040 | } |
| 1047 | 1041 | ||
| 1048 | static void mlxsw_sp_neigh_fini(struct mlxsw_sp *mlxsw_sp) | 1042 | static void mlxsw_sp_neigh_fini(struct mlxsw_sp *mlxsw_sp) |
| 1049 | { | 1043 | { |
| 1050 | cancel_delayed_work_sync(&mlxsw_sp->router.neighs_update.dw); | 1044 | cancel_delayed_work_sync(&mlxsw_sp->router.neighs_update.dw); |
| 1051 | cancel_delayed_work_sync(&mlxsw_sp->router.nexthop_probe_dw); | 1045 | cancel_delayed_work_sync(&mlxsw_sp->router.nexthop_probe_dw); |
| 1052 | unregister_netevent_notifier(&mlxsw_sp_router_netevent_nb); | ||
| 1053 | rhashtable_destroy(&mlxsw_sp->router.neigh_ht); | 1046 | rhashtable_destroy(&mlxsw_sp->router.neigh_ht); |
| 1054 | } | 1047 | } |
| 1055 | 1048 | ||
| @@ -1524,7 +1517,14 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp) | |||
| 1524 | return err; | 1517 | return err; |
| 1525 | mlxsw_sp_lpm_init(mlxsw_sp); | 1518 | mlxsw_sp_lpm_init(mlxsw_sp); |
| 1526 | mlxsw_sp_vrs_init(mlxsw_sp); | 1519 | mlxsw_sp_vrs_init(mlxsw_sp); |
| 1527 | return mlxsw_sp_neigh_init(mlxsw_sp); | 1520 | err = mlxsw_sp_neigh_init(mlxsw_sp); |
| 1521 | if (err) | ||
| 1522 | goto err_neigh_init; | ||
| 1523 | return 0; | ||
| 1524 | |||
| 1525 | err_neigh_init: | ||
| 1526 | __mlxsw_sp_router_fini(mlxsw_sp); | ||
| 1527 | return err; | ||
| 1528 | } | 1528 | } |
| 1529 | 1529 | ||
| 1530 | void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp) | 1530 | void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp) |
| @@ -1626,11 +1626,8 @@ static int mlxsw_sp_fib_entry_op(struct mlxsw_sp *mlxsw_sp, | |||
| 1626 | static int mlxsw_sp_fib_entry_update(struct mlxsw_sp *mlxsw_sp, | 1626 | static int mlxsw_sp_fib_entry_update(struct mlxsw_sp *mlxsw_sp, |
| 1627 | struct mlxsw_sp_fib_entry *fib_entry) | 1627 | struct mlxsw_sp_fib_entry *fib_entry) |
| 1628 | { | 1628 | { |
| 1629 | enum mlxsw_reg_ralue_op op; | 1629 | return mlxsw_sp_fib_entry_op(mlxsw_sp, fib_entry, |
| 1630 | 1630 | MLXSW_REG_RALUE_OP_WRITE_WRITE); | |
| 1631 | op = !fib_entry->added ? MLXSW_REG_RALUE_OP_WRITE_WRITE : | ||
| 1632 | MLXSW_REG_RALUE_OP_WRITE_UPDATE; | ||
| 1633 | return mlxsw_sp_fib_entry_op(mlxsw_sp, fib_entry, op); | ||
| 1634 | } | 1631 | } |
| 1635 | 1632 | ||
| 1636 | static int mlxsw_sp_fib_entry_del(struct mlxsw_sp *mlxsw_sp, | 1633 | static int mlxsw_sp_fib_entry_del(struct mlxsw_sp *mlxsw_sp, |
| @@ -1695,34 +1692,93 @@ mlxsw_sp_router_fib4_entry_fini(struct mlxsw_sp *mlxsw_sp, | |||
| 1695 | mlxsw_sp_nexthop_group_put(mlxsw_sp, fib_entry); | 1692 | mlxsw_sp_nexthop_group_put(mlxsw_sp, fib_entry); |
| 1696 | } | 1693 | } |
| 1697 | 1694 | ||
| 1698 | static int | 1695 | static struct mlxsw_sp_fib_entry * |
| 1699 | mlxsw_sp_router_fib4_add_prepare(struct mlxsw_sp_port *mlxsw_sp_port, | 1696 | mlxsw_sp_fib_entry_get(struct mlxsw_sp *mlxsw_sp, |
| 1700 | const struct switchdev_obj_ipv4_fib *fib4, | 1697 | const struct switchdev_obj_ipv4_fib *fib4) |
| 1701 | struct switchdev_trans *trans) | ||
| 1702 | { | 1698 | { |
| 1703 | struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; | ||
| 1704 | struct mlxsw_sp_router_fib4_add_info *info; | ||
| 1705 | struct mlxsw_sp_fib_entry *fib_entry; | 1699 | struct mlxsw_sp_fib_entry *fib_entry; |
| 1700 | struct fib_info *fi = fib4->fi; | ||
| 1706 | struct mlxsw_sp_vr *vr; | 1701 | struct mlxsw_sp_vr *vr; |
| 1707 | int err; | 1702 | int err; |
| 1708 | 1703 | ||
| 1709 | vr = mlxsw_sp_vr_get(mlxsw_sp, fib4->dst_len, fib4->tb_id, | 1704 | vr = mlxsw_sp_vr_get(mlxsw_sp, fib4->dst_len, fib4->tb_id, |
| 1710 | MLXSW_SP_L3_PROTO_IPV4); | 1705 | MLXSW_SP_L3_PROTO_IPV4); |
| 1711 | if (IS_ERR(vr)) | 1706 | if (IS_ERR(vr)) |
| 1712 | return PTR_ERR(vr); | 1707 | return ERR_CAST(vr); |
| 1713 | 1708 | ||
| 1709 | fib_entry = mlxsw_sp_fib_entry_lookup(vr->fib, &fib4->dst, | ||
| 1710 | sizeof(fib4->dst), | ||
| 1711 | fib4->dst_len, fi->fib_dev); | ||
| 1712 | if (fib_entry) { | ||
| 1713 | /* Already exists, just take a reference */ | ||
| 1714 | fib_entry->ref_count++; | ||
| 1715 | return fib_entry; | ||
| 1716 | } | ||
| 1714 | fib_entry = mlxsw_sp_fib_entry_create(vr->fib, &fib4->dst, | 1717 | fib_entry = mlxsw_sp_fib_entry_create(vr->fib, &fib4->dst, |
| 1715 | sizeof(fib4->dst), fib4->dst_len); | 1718 | sizeof(fib4->dst), |
| 1719 | fib4->dst_len, fi->fib_dev); | ||
| 1716 | if (!fib_entry) { | 1720 | if (!fib_entry) { |
| 1717 | err = -ENOMEM; | 1721 | err = -ENOMEM; |
| 1718 | goto err_fib_entry_create; | 1722 | goto err_fib_entry_create; |
| 1719 | } | 1723 | } |
| 1720 | fib_entry->vr = vr; | 1724 | fib_entry->vr = vr; |
| 1725 | fib_entry->ref_count = 1; | ||
| 1721 | 1726 | ||
| 1722 | err = mlxsw_sp_router_fib4_entry_init(mlxsw_sp, fib4, fib_entry); | 1727 | err = mlxsw_sp_router_fib4_entry_init(mlxsw_sp, fib4, fib_entry); |
| 1723 | if (err) | 1728 | if (err) |
| 1724 | goto err_fib4_entry_init; | 1729 | goto err_fib4_entry_init; |
| 1725 | 1730 | ||
| 1731 | return fib_entry; | ||
| 1732 | |||
| 1733 | err_fib4_entry_init: | ||
| 1734 | mlxsw_sp_fib_entry_destroy(fib_entry); | ||
| 1735 | err_fib_entry_create: | ||
| 1736 | mlxsw_sp_vr_put(mlxsw_sp, vr); | ||
| 1737 | |||
| 1738 | return ERR_PTR(err); | ||
| 1739 | } | ||
| 1740 | |||
| 1741 | static struct mlxsw_sp_fib_entry * | ||
| 1742 | mlxsw_sp_fib_entry_find(struct mlxsw_sp *mlxsw_sp, | ||
| 1743 | const struct switchdev_obj_ipv4_fib *fib4) | ||
| 1744 | { | ||
| 1745 | struct mlxsw_sp_vr *vr; | ||
| 1746 | |||
| 1747 | vr = mlxsw_sp_vr_find(mlxsw_sp, fib4->tb_id, MLXSW_SP_L3_PROTO_IPV4); | ||
| 1748 | if (!vr) | ||
| 1749 | return NULL; | ||
| 1750 | |||
| 1751 | return mlxsw_sp_fib_entry_lookup(vr->fib, &fib4->dst, | ||
| 1752 | sizeof(fib4->dst), fib4->dst_len, | ||
| 1753 | fib4->fi->fib_dev); | ||
| 1754 | } | ||
| 1755 | |||
| 1756 | void mlxsw_sp_fib_entry_put(struct mlxsw_sp *mlxsw_sp, | ||
| 1757 | struct mlxsw_sp_fib_entry *fib_entry) | ||
| 1758 | { | ||
| 1759 | struct mlxsw_sp_vr *vr = fib_entry->vr; | ||
| 1760 | |||
| 1761 | if (--fib_entry->ref_count == 0) { | ||
| 1762 | mlxsw_sp_router_fib4_entry_fini(mlxsw_sp, fib_entry); | ||
| 1763 | mlxsw_sp_fib_entry_destroy(fib_entry); | ||
| 1764 | } | ||
| 1765 | mlxsw_sp_vr_put(mlxsw_sp, vr); | ||
| 1766 | } | ||
| 1767 | |||
| 1768 | static int | ||
| 1769 | mlxsw_sp_router_fib4_add_prepare(struct mlxsw_sp_port *mlxsw_sp_port, | ||
| 1770 | const struct switchdev_obj_ipv4_fib *fib4, | ||
| 1771 | struct switchdev_trans *trans) | ||
| 1772 | { | ||
| 1773 | struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; | ||
| 1774 | struct mlxsw_sp_router_fib4_add_info *info; | ||
| 1775 | struct mlxsw_sp_fib_entry *fib_entry; | ||
| 1776 | int err; | ||
| 1777 | |||
| 1778 | fib_entry = mlxsw_sp_fib_entry_get(mlxsw_sp, fib4); | ||
| 1779 | if (IS_ERR(fib_entry)) | ||
| 1780 | return PTR_ERR(fib_entry); | ||
| 1781 | |||
| 1726 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 1782 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
| 1727 | if (!info) { | 1783 | if (!info) { |
| 1728 | err = -ENOMEM; | 1784 | err = -ENOMEM; |
| @@ -1736,11 +1792,7 @@ mlxsw_sp_router_fib4_add_prepare(struct mlxsw_sp_port *mlxsw_sp_port, | |||
| 1736 | return 0; | 1792 | return 0; |
| 1737 | 1793 | ||
| 1738 | err_alloc_info: | 1794 | err_alloc_info: |
| 1739 | mlxsw_sp_router_fib4_entry_fini(mlxsw_sp, fib_entry); | 1795 | mlxsw_sp_fib_entry_put(mlxsw_sp, fib_entry); |
| 1740 | err_fib4_entry_init: | ||
| 1741 | mlxsw_sp_fib_entry_destroy(fib_entry); | ||
| 1742 | err_fib_entry_create: | ||
| 1743 | mlxsw_sp_vr_put(mlxsw_sp, vr); | ||
| 1744 | return err; | 1796 | return err; |
| 1745 | } | 1797 | } |
| 1746 | 1798 | ||
| @@ -1759,11 +1811,14 @@ mlxsw_sp_router_fib4_add_commit(struct mlxsw_sp_port *mlxsw_sp_port, | |||
| 1759 | fib_entry = info->fib_entry; | 1811 | fib_entry = info->fib_entry; |
| 1760 | kfree(info); | 1812 | kfree(info); |
| 1761 | 1813 | ||
| 1814 | if (fib_entry->ref_count != 1) | ||
| 1815 | return 0; | ||
| 1816 | |||
| 1762 | vr = fib_entry->vr; | 1817 | vr = fib_entry->vr; |
| 1763 | err = mlxsw_sp_fib_entry_insert(fib_entry->vr->fib, fib_entry); | 1818 | err = mlxsw_sp_fib_entry_insert(vr->fib, fib_entry); |
| 1764 | if (err) | 1819 | if (err) |
| 1765 | goto err_fib_entry_insert; | 1820 | goto err_fib_entry_insert; |
| 1766 | err = mlxsw_sp_fib_entry_update(mlxsw_sp, fib_entry); | 1821 | err = mlxsw_sp_fib_entry_update(mlxsw_sp_port->mlxsw_sp, fib_entry); |
| 1767 | if (err) | 1822 | if (err) |
| 1768 | goto err_fib_entry_add; | 1823 | goto err_fib_entry_add; |
| 1769 | return 0; | 1824 | return 0; |
| @@ -1771,9 +1826,7 @@ mlxsw_sp_router_fib4_add_commit(struct mlxsw_sp_port *mlxsw_sp_port, | |||
| 1771 | err_fib_entry_add: | 1826 | err_fib_entry_add: |
| 1772 | mlxsw_sp_fib_entry_remove(vr->fib, fib_entry); | 1827 | mlxsw_sp_fib_entry_remove(vr->fib, fib_entry); |
| 1773 | err_fib_entry_insert: | 1828 | err_fib_entry_insert: |
| 1774 | mlxsw_sp_router_fib4_entry_fini(mlxsw_sp, fib_entry); | 1829 | mlxsw_sp_fib_entry_put(mlxsw_sp, fib_entry); |
| 1775 | mlxsw_sp_fib_entry_destroy(fib_entry); | ||
| 1776 | mlxsw_sp_vr_put(mlxsw_sp, vr); | ||
| 1777 | return err; | 1830 | return err; |
| 1778 | } | 1831 | } |
| 1779 | 1832 | ||
| @@ -1793,23 +1846,18 @@ int mlxsw_sp_router_fib4_del(struct mlxsw_sp_port *mlxsw_sp_port, | |||
| 1793 | { | 1846 | { |
| 1794 | struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; | 1847 | struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; |
| 1795 | struct mlxsw_sp_fib_entry *fib_entry; | 1848 | struct mlxsw_sp_fib_entry *fib_entry; |
| 1796 | struct mlxsw_sp_vr *vr; | ||
| 1797 | 1849 | ||
| 1798 | vr = mlxsw_sp_vr_find(mlxsw_sp, fib4->tb_id, MLXSW_SP_L3_PROTO_IPV4); | 1850 | fib_entry = mlxsw_sp_fib_entry_find(mlxsw_sp, fib4); |
| 1799 | if (!vr) { | ||
| 1800 | dev_warn(mlxsw_sp->bus_info->dev, "Failed to find virtual router for FIB4 entry being removed.\n"); | ||
| 1801 | return -ENOENT; | ||
| 1802 | } | ||
| 1803 | fib_entry = mlxsw_sp_fib_entry_lookup(vr->fib, &fib4->dst, | ||
| 1804 | sizeof(fib4->dst), fib4->dst_len); | ||
| 1805 | if (!fib_entry) { | 1851 | if (!fib_entry) { |
| 1806 | dev_warn(mlxsw_sp->bus_info->dev, "Failed to find FIB4 entry being removed.\n"); | 1852 | dev_warn(mlxsw_sp->bus_info->dev, "Failed to find FIB4 entry being removed.\n"); |
| 1807 | return -ENOENT; | 1853 | return -ENOENT; |
| 1808 | } | 1854 | } |
| 1809 | mlxsw_sp_fib_entry_del(mlxsw_sp_port->mlxsw_sp, fib_entry); | 1855 | |
| 1810 | mlxsw_sp_fib_entry_remove(vr->fib, fib_entry); | 1856 | if (fib_entry->ref_count == 1) { |
| 1811 | mlxsw_sp_router_fib4_entry_fini(mlxsw_sp, fib_entry); | 1857 | mlxsw_sp_fib_entry_del(mlxsw_sp, fib_entry); |
| 1812 | mlxsw_sp_fib_entry_destroy(fib_entry); | 1858 | mlxsw_sp_fib_entry_remove(fib_entry->vr->fib, fib_entry); |
| 1813 | mlxsw_sp_vr_put(mlxsw_sp, vr); | 1859 | } |
| 1860 | |||
| 1861 | mlxsw_sp_fib_entry_put(mlxsw_sp, fib_entry); | ||
| 1814 | return 0; | 1862 | return 0; |
| 1815 | } | 1863 | } |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index d1b59cdfacc1..7b654c517b91 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | |||
| @@ -167,8 +167,8 @@ static int mlxsw_sp_port_attr_stp_state_set(struct mlxsw_sp_port *mlxsw_sp_port, | |||
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | static int __mlxsw_sp_port_flood_set(struct mlxsw_sp_port *mlxsw_sp_port, | 169 | static int __mlxsw_sp_port_flood_set(struct mlxsw_sp_port *mlxsw_sp_port, |
| 170 | u16 idx_begin, u16 idx_end, bool set, | 170 | u16 idx_begin, u16 idx_end, bool uc_set, |
| 171 | bool only_uc) | 171 | bool bm_set) |
| 172 | { | 172 | { |
| 173 | struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; | 173 | struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; |
| 174 | u16 local_port = mlxsw_sp_port->local_port; | 174 | u16 local_port = mlxsw_sp_port->local_port; |
| @@ -187,28 +187,22 @@ static int __mlxsw_sp_port_flood_set(struct mlxsw_sp_port *mlxsw_sp_port, | |||
| 187 | return -ENOMEM; | 187 | return -ENOMEM; |
| 188 | 188 | ||
| 189 | mlxsw_reg_sftr_pack(sftr_pl, MLXSW_SP_FLOOD_TABLE_UC, idx_begin, | 189 | mlxsw_reg_sftr_pack(sftr_pl, MLXSW_SP_FLOOD_TABLE_UC, idx_begin, |
| 190 | table_type, range, local_port, set); | 190 | table_type, range, local_port, uc_set); |
| 191 | err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl); | 191 | err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl); |
| 192 | if (err) | 192 | if (err) |
| 193 | goto buffer_out; | 193 | goto buffer_out; |
| 194 | 194 | ||
| 195 | /* Flooding control allows one to decide whether a given port will | ||
| 196 | * flood unicast traffic for which there is no FDB entry. | ||
| 197 | */ | ||
| 198 | if (only_uc) | ||
| 199 | goto buffer_out; | ||
| 200 | |||
| 201 | mlxsw_reg_sftr_pack(sftr_pl, MLXSW_SP_FLOOD_TABLE_BM, idx_begin, | 195 | mlxsw_reg_sftr_pack(sftr_pl, MLXSW_SP_FLOOD_TABLE_BM, idx_begin, |
| 202 | table_type, range, local_port, set); | 196 | table_type, range, local_port, bm_set); |
| 203 | err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl); | 197 | err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl); |
| 204 | if (err) | 198 | if (err) |
| 205 | goto err_flood_bm_set; | 199 | goto err_flood_bm_set; |
| 206 | else | 200 | |
| 207 | goto buffer_out; | 201 | goto buffer_out; |
| 208 | 202 | ||
| 209 | err_flood_bm_set: | 203 | err_flood_bm_set: |
| 210 | mlxsw_reg_sftr_pack(sftr_pl, MLXSW_SP_FLOOD_TABLE_UC, idx_begin, | 204 | mlxsw_reg_sftr_pack(sftr_pl, MLXSW_SP_FLOOD_TABLE_UC, idx_begin, |
| 211 | table_type, range, local_port, !set); | 205 | table_type, range, local_port, !uc_set); |
| 212 | mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl); | 206 | mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl); |
| 213 | buffer_out: | 207 | buffer_out: |
| 214 | kfree(sftr_pl); | 208 | kfree(sftr_pl); |
| @@ -257,8 +251,7 @@ int mlxsw_sp_vport_flood_set(struct mlxsw_sp_port *mlxsw_sp_vport, u16 fid, | |||
| 257 | * the start of the vFIDs range. | 251 | * the start of the vFIDs range. |
| 258 | */ | 252 | */ |
| 259 | vfid = mlxsw_sp_fid_to_vfid(fid); | 253 | vfid = mlxsw_sp_fid_to_vfid(fid); |
| 260 | return __mlxsw_sp_port_flood_set(mlxsw_sp_vport, vfid, vfid, set, | 254 | return __mlxsw_sp_port_flood_set(mlxsw_sp_vport, vfid, vfid, set, set); |
| 261 | false); | ||
| 262 | } | 255 | } |
| 263 | 256 | ||
| 264 | static int mlxsw_sp_port_attr_br_flags_set(struct mlxsw_sp_port *mlxsw_sp_port, | 257 | static int mlxsw_sp_port_attr_br_flags_set(struct mlxsw_sp_port *mlxsw_sp_port, |
| @@ -460,6 +453,9 @@ static int __mlxsw_sp_port_fid_join(struct mlxsw_sp_port *mlxsw_sp_port, | |||
| 460 | { | 453 | { |
| 461 | struct mlxsw_sp_fid *f; | 454 | struct mlxsw_sp_fid *f; |
| 462 | 455 | ||
| 456 | if (test_bit(fid, mlxsw_sp_port->active_vlans)) | ||
| 457 | return 0; | ||
| 458 | |||
| 463 | f = mlxsw_sp_fid_find(mlxsw_sp_port->mlxsw_sp, fid); | 459 | f = mlxsw_sp_fid_find(mlxsw_sp_port->mlxsw_sp, fid); |
| 464 | if (!f) { | 460 | if (!f) { |
| 465 | f = mlxsw_sp_fid_create(mlxsw_sp_port->mlxsw_sp, fid); | 461 | f = mlxsw_sp_fid_create(mlxsw_sp_port->mlxsw_sp, fid); |
| @@ -517,7 +513,7 @@ static int mlxsw_sp_port_fid_join(struct mlxsw_sp_port *mlxsw_sp_port, | |||
| 517 | } | 513 | } |
| 518 | 514 | ||
| 519 | err = __mlxsw_sp_port_flood_set(mlxsw_sp_port, fid_begin, fid_end, | 515 | err = __mlxsw_sp_port_flood_set(mlxsw_sp_port, fid_begin, fid_end, |
| 520 | true, false); | 516 | mlxsw_sp_port->uc_flood, true); |
| 521 | if (err) | 517 | if (err) |
| 522 | goto err_port_flood_set; | 518 | goto err_port_flood_set; |
| 523 | 519 | ||
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 88678c172b19..252e4924de0f 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c | |||
| @@ -41,7 +41,6 @@ | |||
| 41 | * Chris Telfer <chris.telfer@netronome.com> | 41 | * Chris Telfer <chris.telfer@netronome.com> |
| 42 | */ | 42 | */ |
| 43 | 43 | ||
| 44 | #include <linux/version.h> | ||
| 45 | #include <linux/module.h> | 44 | #include <linux/module.h> |
| 46 | #include <linux/kernel.h> | 45 | #include <linux/kernel.h> |
| 47 | #include <linux/init.h> | 46 | #include <linux/init.h> |
| @@ -1441,10 +1440,6 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget) | |||
| 1441 | 1440 | ||
| 1442 | nfp_net_set_hash(nn->netdev, skb, rxd); | 1441 | nfp_net_set_hash(nn->netdev, skb, rxd); |
| 1443 | 1442 | ||
| 1444 | /* Pad small frames to minimum */ | ||
| 1445 | if (skb_put_padto(skb, 60)) | ||
| 1446 | break; | ||
| 1447 | |||
| 1448 | /* Stats update */ | 1443 | /* Stats update */ |
| 1449 | u64_stats_update_begin(&r_vec->rx_sync); | 1444 | u64_stats_update_begin(&r_vec->rx_sync); |
| 1450 | r_vec->rx_pkts++; | 1445 | r_vec->rx_pkts++; |
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c index 7d7933d00b8f..4c9897220969 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c | |||
| @@ -40,7 +40,6 @@ | |||
| 40 | * Brad Petrus <brad.petrus@netronome.com> | 40 | * Brad Petrus <brad.petrus@netronome.com> |
| 41 | */ | 41 | */ |
| 42 | 42 | ||
| 43 | #include <linux/version.h> | ||
| 44 | #include <linux/kernel.h> | 43 | #include <linux/kernel.h> |
| 45 | #include <linux/netdevice.h> | 44 | #include <linux/netdevice.h> |
| 46 | #include <linux/etherdevice.h> | 45 | #include <linux/etherdevice.h> |
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_netvf_main.c b/drivers/net/ethernet/netronome/nfp/nfp_netvf_main.c index 37abef016a0a..f7062cb648e1 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_netvf_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_netvf_main.c | |||
| @@ -38,7 +38,6 @@ | |||
| 38 | * Rolf Neugebauer <rolf.neugebauer@netronome.com> | 38 | * Rolf Neugebauer <rolf.neugebauer@netronome.com> |
| 39 | */ | 39 | */ |
| 40 | 40 | ||
| 41 | #include <linux/version.h> | ||
| 42 | #include <linux/module.h> | 41 | #include <linux/module.h> |
| 43 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
| 44 | #include <linux/init.h> | 43 | #include <linux/init.h> |
| @@ -134,7 +133,7 @@ static int nfp_netvf_pci_probe(struct pci_dev *pdev, | |||
| 134 | } | 133 | } |
| 135 | 134 | ||
| 136 | nfp_net_get_fw_version(&fw_ver, ctrl_bar); | 135 | nfp_net_get_fw_version(&fw_ver, ctrl_bar); |
| 137 | if (fw_ver.class != NFP_NET_CFG_VERSION_CLASS_GENERIC) { | 136 | if (fw_ver.resv || fw_ver.class != NFP_NET_CFG_VERSION_CLASS_GENERIC) { |
| 138 | dev_err(&pdev->dev, "Unknown Firmware ABI %d.%d.%d.%d\n", | 137 | dev_err(&pdev->dev, "Unknown Firmware ABI %d.%d.%d.%d\n", |
| 139 | fw_ver.resv, fw_ver.class, fw_ver.major, fw_ver.minor); | 138 | fw_ver.resv, fw_ver.class, fw_ver.major, fw_ver.minor); |
| 140 | err = -EINVAL; | 139 | err = -EINVAL; |
| @@ -142,9 +141,7 @@ static int nfp_netvf_pci_probe(struct pci_dev *pdev, | |||
| 142 | } | 141 | } |
| 143 | 142 | ||
| 144 | /* Determine stride */ | 143 | /* Determine stride */ |
| 145 | if (nfp_net_fw_ver_eq(&fw_ver, 0, 0, 0, 0) || | 144 | if (nfp_net_fw_ver_eq(&fw_ver, 0, 0, 0, 1)) { |
| 146 | nfp_net_fw_ver_eq(&fw_ver, 0, 0, 0, 1) || | ||
| 147 | nfp_net_fw_ver_eq(&fw_ver, 0, 0, 0x12, 0x48)) { | ||
| 148 | stride = 2; | 145 | stride = 2; |
| 149 | tx_bar_no = NFP_NET_Q0_BAR; | 146 | tx_bar_no = NFP_NET_Q0_BAR; |
| 150 | rx_bar_no = NFP_NET_Q1_BAR; | 147 | rx_bar_no = NFP_NET_Q1_BAR; |
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c index 4d4ecba0aad9..8e13ec84c538 100644 --- a/drivers/net/ethernet/nxp/lpc_eth.c +++ b/drivers/net/ethernet/nxp/lpc_eth.c | |||
| @@ -475,14 +475,6 @@ static void __lpc_get_mac(struct netdata_local *pldat, u8 *mac) | |||
| 475 | mac[5] = tmp >> 8; | 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 | static void __lpc_params_setup(struct netdata_local *pldat) | 478 | static void __lpc_params_setup(struct netdata_local *pldat) |
| 487 | { | 479 | { |
| 488 | u32 tmp; | 480 | u32 tmp; |
| @@ -1056,7 +1048,7 @@ static int lpc_eth_close(struct net_device *ndev) | |||
| 1056 | writel(0, LPC_ENET_MAC2(pldat->net_base)); | 1048 | writel(0, LPC_ENET_MAC2(pldat->net_base)); |
| 1057 | spin_unlock_irqrestore(&pldat->lock, flags); | 1049 | spin_unlock_irqrestore(&pldat->lock, flags); |
| 1058 | 1050 | ||
| 1059 | __lpc_eth_clock_enable(pldat, false); | 1051 | clk_disable_unprepare(pldat->clk); |
| 1060 | 1052 | ||
| 1061 | return 0; | 1053 | return 0; |
| 1062 | } | 1054 | } |
| @@ -1197,11 +1189,14 @@ static int lpc_eth_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) | |||
| 1197 | static int lpc_eth_open(struct net_device *ndev) | 1189 | static int lpc_eth_open(struct net_device *ndev) |
| 1198 | { | 1190 | { |
| 1199 | struct netdata_local *pldat = netdev_priv(ndev); | 1191 | struct netdata_local *pldat = netdev_priv(ndev); |
| 1192 | int ret; | ||
| 1200 | 1193 | ||
| 1201 | if (netif_msg_ifup(pldat)) | 1194 | if (netif_msg_ifup(pldat)) |
| 1202 | dev_dbg(&pldat->pdev->dev, "enabling %s\n", ndev->name); | 1195 | dev_dbg(&pldat->pdev->dev, "enabling %s\n", ndev->name); |
| 1203 | 1196 | ||
| 1204 | __lpc_eth_clock_enable(pldat, true); | 1197 | ret = clk_prepare_enable(pldat->clk); |
| 1198 | if (ret) | ||
| 1199 | return ret; | ||
| 1205 | 1200 | ||
| 1206 | /* Suspended PHY makes LPC ethernet core block, so resume now */ | 1201 | /* Suspended PHY makes LPC ethernet core block, so resume now */ |
| 1207 | phy_resume(ndev->phydev); | 1202 | phy_resume(ndev->phydev); |
| @@ -1320,7 +1315,9 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) | |||
| 1320 | } | 1315 | } |
| 1321 | 1316 | ||
| 1322 | /* Enable network clock */ | 1317 | /* Enable network clock */ |
| 1323 | __lpc_eth_clock_enable(pldat, true); | 1318 | ret = clk_prepare_enable(pldat->clk); |
| 1319 | if (ret) | ||
| 1320 | goto err_out_clk_put; | ||
| 1324 | 1321 | ||
| 1325 | /* Map IO space */ | 1322 | /* Map IO space */ |
| 1326 | pldat->net_base = ioremap(res->start, resource_size(res)); | 1323 | pldat->net_base = ioremap(res->start, resource_size(res)); |
| @@ -1454,6 +1451,7 @@ err_out_iounmap: | |||
| 1454 | iounmap(pldat->net_base); | 1451 | iounmap(pldat->net_base); |
| 1455 | err_out_disable_clocks: | 1452 | err_out_disable_clocks: |
| 1456 | clk_disable_unprepare(pldat->clk); | 1453 | clk_disable_unprepare(pldat->clk); |
| 1454 | err_out_clk_put: | ||
| 1457 | clk_put(pldat->clk); | 1455 | clk_put(pldat->clk); |
| 1458 | err_out_free_dev: | 1456 | err_out_free_dev: |
| 1459 | free_netdev(ndev); | 1457 | free_netdev(ndev); |
diff --git a/drivers/net/ethernet/qlogic/qed/qed.h b/drivers/net/ethernet/qlogic/qed/qed.h index 35e53771533f..45ab74676573 100644 --- a/drivers/net/ethernet/qlogic/qed/qed.h +++ b/drivers/net/ethernet/qlogic/qed/qed.h | |||
| @@ -561,9 +561,18 @@ struct qed_dev { | |||
| 561 | static inline u8 qed_concrete_to_sw_fid(struct qed_dev *cdev, | 561 | static inline u8 qed_concrete_to_sw_fid(struct qed_dev *cdev, |
| 562 | u32 concrete_fid) | 562 | u32 concrete_fid) |
| 563 | { | 563 | { |
| 564 | u8 vfid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_VFID); | ||
| 564 | u8 pfid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_PFID); | 565 | u8 pfid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_PFID); |
| 566 | u8 vf_valid = GET_FIELD(concrete_fid, | ||
| 567 | PXP_CONCRETE_FID_VFVALID); | ||
| 568 | u8 sw_fid; | ||
| 565 | 569 | ||
| 566 | return pfid; | 570 | if (vf_valid) |
| 571 | sw_fid = vfid + MAX_NUM_PFS; | ||
| 572 | else | ||
| 573 | sw_fid = pfid; | ||
| 574 | |||
| 575 | return sw_fid; | ||
| 567 | } | 576 | } |
| 568 | 577 | ||
| 569 | #define PURE_LB_TC 8 | 578 | #define PURE_LB_TC 8 |
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c index 226cb08cc055..3656d2fd673d 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c +++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include "qed_dcbx.h" | 19 | #include "qed_dcbx.h" |
| 20 | #include "qed_hsi.h" | 20 | #include "qed_hsi.h" |
| 21 | #include "qed_sp.h" | 21 | #include "qed_sp.h" |
| 22 | #include "qed_sriov.h" | ||
| 22 | #ifdef CONFIG_DCB | 23 | #ifdef CONFIG_DCB |
| 23 | #include <linux/qed/qed_eth_if.h> | 24 | #include <linux/qed/qed_eth_if.h> |
| 24 | #endif | 25 | #endif |
| @@ -945,6 +946,9 @@ static int qed_dcbx_query_params(struct qed_hwfn *p_hwfn, | |||
| 945 | struct qed_ptt *p_ptt; | 946 | struct qed_ptt *p_ptt; |
| 946 | int rc; | 947 | int rc; |
| 947 | 948 | ||
| 949 | if (IS_VF(p_hwfn->cdev)) | ||
| 950 | return -EINVAL; | ||
| 951 | |||
| 948 | p_ptt = qed_ptt_acquire(p_hwfn); | 952 | p_ptt = qed_ptt_acquire(p_hwfn); |
| 949 | if (!p_ptt) | 953 | if (!p_ptt) |
| 950 | return -EBUSY; | 954 | return -EBUSY; |
| @@ -984,6 +988,7 @@ qed_dcbx_set_pfc_data(struct qed_hwfn *p_hwfn, | |||
| 984 | if (p_params->pfc.prio[i]) | 988 | if (p_params->pfc.prio[i]) |
| 985 | pfc_map |= BIT(i); | 989 | pfc_map |= BIT(i); |
| 986 | 990 | ||
| 991 | *pfc &= ~DCBX_PFC_PRI_EN_BITMAP_MASK; | ||
| 987 | *pfc |= (pfc_map << DCBX_PFC_PRI_EN_BITMAP_SHIFT); | 992 | *pfc |= (pfc_map << DCBX_PFC_PRI_EN_BITMAP_SHIFT); |
| 988 | 993 | ||
| 989 | DP_VERBOSE(p_hwfn, QED_MSG_DCB, "pfc = 0x%x\n", *pfc); | 994 | DP_VERBOSE(p_hwfn, QED_MSG_DCB, "pfc = 0x%x\n", *pfc); |
| @@ -1058,24 +1063,33 @@ qed_dcbx_set_app_data(struct qed_hwfn *p_hwfn, | |||
| 1058 | 1063 | ||
| 1059 | for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++) { | 1064 | for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++) { |
| 1060 | entry = &p_app->app_pri_tbl[i].entry; | 1065 | entry = &p_app->app_pri_tbl[i].entry; |
| 1066 | *entry = 0; | ||
| 1061 | if (ieee) { | 1067 | if (ieee) { |
| 1062 | *entry &= ~DCBX_APP_SF_IEEE_MASK; | 1068 | *entry &= ~(DCBX_APP_SF_IEEE_MASK | DCBX_APP_SF_MASK); |
| 1063 | switch (p_params->app_entry[i].sf_ieee) { | 1069 | switch (p_params->app_entry[i].sf_ieee) { |
| 1064 | case QED_DCBX_SF_IEEE_ETHTYPE: | 1070 | case QED_DCBX_SF_IEEE_ETHTYPE: |
| 1065 | *entry |= ((u32)DCBX_APP_SF_IEEE_ETHTYPE << | 1071 | *entry |= ((u32)DCBX_APP_SF_IEEE_ETHTYPE << |
| 1066 | DCBX_APP_SF_IEEE_SHIFT); | 1072 | DCBX_APP_SF_IEEE_SHIFT); |
| 1073 | *entry |= ((u32)DCBX_APP_SF_ETHTYPE << | ||
| 1074 | DCBX_APP_SF_SHIFT); | ||
| 1067 | break; | 1075 | break; |
| 1068 | case QED_DCBX_SF_IEEE_TCP_PORT: | 1076 | case QED_DCBX_SF_IEEE_TCP_PORT: |
| 1069 | *entry |= ((u32)DCBX_APP_SF_IEEE_TCP_PORT << | 1077 | *entry |= ((u32)DCBX_APP_SF_IEEE_TCP_PORT << |
| 1070 | DCBX_APP_SF_IEEE_SHIFT); | 1078 | DCBX_APP_SF_IEEE_SHIFT); |
| 1079 | *entry |= ((u32)DCBX_APP_SF_PORT << | ||
| 1080 | DCBX_APP_SF_SHIFT); | ||
| 1071 | break; | 1081 | break; |
| 1072 | case QED_DCBX_SF_IEEE_UDP_PORT: | 1082 | case QED_DCBX_SF_IEEE_UDP_PORT: |
| 1073 | *entry |= ((u32)DCBX_APP_SF_IEEE_UDP_PORT << | 1083 | *entry |= ((u32)DCBX_APP_SF_IEEE_UDP_PORT << |
| 1074 | DCBX_APP_SF_IEEE_SHIFT); | 1084 | DCBX_APP_SF_IEEE_SHIFT); |
| 1085 | *entry |= ((u32)DCBX_APP_SF_PORT << | ||
| 1086 | DCBX_APP_SF_SHIFT); | ||
| 1075 | break; | 1087 | break; |
| 1076 | case QED_DCBX_SF_IEEE_TCP_UDP_PORT: | 1088 | case QED_DCBX_SF_IEEE_TCP_UDP_PORT: |
| 1077 | *entry |= ((u32)DCBX_APP_SF_IEEE_TCP_UDP_PORT << | 1089 | *entry |= ((u32)DCBX_APP_SF_IEEE_TCP_UDP_PORT << |
| 1078 | DCBX_APP_SF_IEEE_SHIFT); | 1090 | DCBX_APP_SF_IEEE_SHIFT); |
| 1091 | *entry |= ((u32)DCBX_APP_SF_PORT << | ||
| 1092 | DCBX_APP_SF_SHIFT); | ||
| 1079 | break; | 1093 | break; |
| 1080 | } | 1094 | } |
| 1081 | } else { | 1095 | } else { |
| @@ -1175,7 +1189,7 @@ int qed_dcbx_get_config_params(struct qed_hwfn *p_hwfn, | |||
| 1175 | return 0; | 1189 | return 0; |
| 1176 | } | 1190 | } |
| 1177 | 1191 | ||
| 1178 | dcbx_info = kmalloc(sizeof(*dcbx_info), GFP_KERNEL); | 1192 | dcbx_info = kzalloc(sizeof(*dcbx_info), GFP_KERNEL); |
| 1179 | if (!dcbx_info) { | 1193 | if (!dcbx_info) { |
| 1180 | DP_ERR(p_hwfn, "Failed to allocate struct qed_dcbx_info\n"); | 1194 | DP_ERR(p_hwfn, "Failed to allocate struct qed_dcbx_info\n"); |
| 1181 | return -ENOMEM; | 1195 | return -ENOMEM; |
| @@ -1212,7 +1226,7 @@ static struct qed_dcbx_get *qed_dcbnl_get_dcbx(struct qed_hwfn *hwfn, | |||
| 1212 | { | 1226 | { |
| 1213 | struct qed_dcbx_get *dcbx_info; | 1227 | struct qed_dcbx_get *dcbx_info; |
| 1214 | 1228 | ||
| 1215 | dcbx_info = kmalloc(sizeof(*dcbx_info), GFP_KERNEL); | 1229 | dcbx_info = kzalloc(sizeof(*dcbx_info), GFP_KERNEL); |
| 1216 | if (!dcbx_info) { | 1230 | if (!dcbx_info) { |
| 1217 | DP_ERR(hwfn->cdev, "Failed to allocate memory for dcbx_info\n"); | 1231 | DP_ERR(hwfn->cdev, "Failed to allocate memory for dcbx_info\n"); |
| 1218 | return NULL; | 1232 | return NULL; |
diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c index e4bd02e46e57..9544e4c41359 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_main.c +++ b/drivers/net/ethernet/qlogic/qede/qede_main.c | |||
| @@ -722,11 +722,14 @@ netdev_tx_t qede_start_xmit(struct sk_buff *skb, | |||
| 722 | txq->tx_db.data.bd_prod = | 722 | txq->tx_db.data.bd_prod = |
| 723 | cpu_to_le16(qed_chain_get_prod_idx(&txq->tx_pbl)); | 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 | qede_update_tx_producer(txq); | 726 | qede_update_tx_producer(txq); |
| 727 | 727 | ||
| 728 | if (unlikely(qed_chain_get_elem_left(&txq->tx_pbl) | 728 | if (unlikely(qed_chain_get_elem_left(&txq->tx_pbl) |
| 729 | < (MAX_SKB_FRAGS + 1))) { | 729 | < (MAX_SKB_FRAGS + 1))) { |
| 730 | if (skb->xmit_more) | ||
| 731 | qede_update_tx_producer(txq); | ||
| 732 | |||
| 730 | netif_tx_stop_queue(netdev_txq); | 733 | netif_tx_stop_queue(netdev_txq); |
| 731 | DP_VERBOSE(edev, NETIF_MSG_TX_QUEUED, | 734 | DP_VERBOSE(edev, NETIF_MSG_TX_QUEUED, |
| 732 | "Stop queue was called\n"); | 735 | "Stop queue was called\n"); |
| @@ -2517,7 +2520,8 @@ static int __qede_probe(struct pci_dev *pdev, u32 dp_module, u8 dp_level, | |||
| 2517 | edev->ops->register_ops(cdev, &qede_ll_ops, edev); | 2520 | edev->ops->register_ops(cdev, &qede_ll_ops, edev); |
| 2518 | 2521 | ||
| 2519 | #ifdef CONFIG_DCB | 2522 | #ifdef CONFIG_DCB |
| 2520 | qede_set_dcbnl_ops(edev->ndev); | 2523 | if (!IS_VF(edev)) |
| 2524 | qede_set_dcbnl_ops(edev->ndev); | ||
| 2521 | #endif | 2525 | #endif |
| 2522 | 2526 | ||
| 2523 | INIT_DELAYED_WORK(&edev->sp_task, qede_sp_task); | 2527 | INIT_DELAYED_WORK(&edev->sp_task, qede_sp_task); |
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c index deae10d7426d..5297bf77211c 100644 --- a/drivers/net/ethernet/realtek/8139cp.c +++ b/drivers/net/ethernet/realtek/8139cp.c | |||
| @@ -467,8 +467,8 @@ static int cp_rx_poll(struct napi_struct *napi, int budget) | |||
| 467 | unsigned int rx_tail = cp->rx_tail; | 467 | unsigned int rx_tail = cp->rx_tail; |
| 468 | int rx; | 468 | int rx; |
| 469 | 469 | ||
| 470 | rx_status_loop: | ||
| 471 | rx = 0; | 470 | rx = 0; |
| 471 | rx_status_loop: | ||
| 472 | cpw16(IntrStatus, cp_rx_intr_mask); | 472 | cpw16(IntrStatus, cp_rx_intr_mask); |
| 473 | 473 | ||
| 474 | while (rx < budget) { | 474 | while (rx < budget) { |
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 799d58d86e6d..054e795df90f 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c | |||
| @@ -201,9 +201,14 @@ static const u16 sh_eth_offset_fast_rz[SH_ETH_MAX_REGISTER_OFFSET] = { | |||
| 201 | 201 | ||
| 202 | [ARSTR] = 0x0000, | 202 | [ARSTR] = 0x0000, |
| 203 | [TSU_CTRST] = 0x0004, | 203 | [TSU_CTRST] = 0x0004, |
| 204 | [TSU_FWSLC] = 0x0038, | ||
| 204 | [TSU_VTAG0] = 0x0058, | 205 | [TSU_VTAG0] = 0x0058, |
| 205 | [TSU_ADSBSY] = 0x0060, | 206 | [TSU_ADSBSY] = 0x0060, |
| 206 | [TSU_TEN] = 0x0064, | 207 | [TSU_TEN] = 0x0064, |
| 208 | [TSU_POST1] = 0x0070, | ||
| 209 | [TSU_POST2] = 0x0074, | ||
| 210 | [TSU_POST3] = 0x0078, | ||
| 211 | [TSU_POST4] = 0x007c, | ||
| 207 | [TSU_ADRH0] = 0x0100, | 212 | [TSU_ADRH0] = 0x0100, |
| 208 | 213 | ||
| 209 | [TXNLCR0] = 0x0080, | 214 | [TXNLCR0] = 0x0080, |
| @@ -2786,6 +2791,8 @@ static void sh_eth_tsu_init(struct sh_eth_private *mdp) | |||
| 2786 | { | 2791 | { |
| 2787 | if (sh_eth_is_rz_fast_ether(mdp)) { | 2792 | if (sh_eth_is_rz_fast_ether(mdp)) { |
| 2788 | sh_eth_tsu_write(mdp, 0, TSU_TEN); /* Disable all CAM entry */ | 2793 | sh_eth_tsu_write(mdp, 0, TSU_TEN); /* Disable all CAM entry */ |
| 2794 | sh_eth_tsu_write(mdp, TSU_FWSLC_POSTENU | TSU_FWSLC_POSTENL, | ||
| 2795 | TSU_FWSLC); /* Enable POST registers */ | ||
| 2789 | return; | 2796 | return; |
| 2790 | } | 2797 | } |
| 2791 | 2798 | ||
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index f658fee74f18..e00a669e9e09 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c | |||
| @@ -1517,13 +1517,14 @@ static void efx_ef10_get_stat_mask(struct efx_nic *efx, unsigned long *mask) | |||
| 1517 | } | 1517 | } |
| 1518 | 1518 | ||
| 1519 | #if BITS_PER_LONG == 64 | 1519 | #if BITS_PER_LONG == 64 |
| 1520 | BUILD_BUG_ON(BITS_TO_LONGS(EF10_STAT_COUNT) != 2); | ||
| 1520 | mask[0] = raw_mask[0]; | 1521 | mask[0] = raw_mask[0]; |
| 1521 | mask[1] = raw_mask[1]; | 1522 | mask[1] = raw_mask[1]; |
| 1522 | #else | 1523 | #else |
| 1524 | BUILD_BUG_ON(BITS_TO_LONGS(EF10_STAT_COUNT) != 3); | ||
| 1523 | mask[0] = raw_mask[0] & 0xffffffff; | 1525 | mask[0] = raw_mask[0] & 0xffffffff; |
| 1524 | mask[1] = raw_mask[0] >> 32; | 1526 | mask[1] = raw_mask[0] >> 32; |
| 1525 | mask[2] = raw_mask[1] & 0xffffffff; | 1527 | mask[2] = raw_mask[1] & 0xffffffff; |
| 1526 | mask[3] = raw_mask[1] >> 32; | ||
| 1527 | #endif | 1528 | #endif |
| 1528 | } | 1529 | } |
| 1529 | 1530 | ||
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c index 726b80f45906..503a3b6dce91 100644 --- a/drivers/net/ethernet/smsc/smc91x.c +++ b/drivers/net/ethernet/smsc/smc91x.c | |||
| @@ -2275,6 +2275,13 @@ static int smc_drv_probe(struct platform_device *pdev) | |||
| 2275 | if (pd) { | 2275 | if (pd) { |
| 2276 | memcpy(&lp->cfg, pd, sizeof(lp->cfg)); | 2276 | memcpy(&lp->cfg, pd, sizeof(lp->cfg)); |
| 2277 | lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags); | 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 | #if IS_BUILTIN(CONFIG_OF) | 2287 | #if IS_BUILTIN(CONFIG_OF) |
diff --git a/drivers/net/ethernet/smsc/smc91x.h b/drivers/net/ethernet/smsc/smc91x.h index 1a55c7976df0..ea8465467469 100644 --- a/drivers/net/ethernet/smsc/smc91x.h +++ b/drivers/net/ethernet/smsc/smc91x.h | |||
| @@ -37,6 +37,27 @@ | |||
| 37 | #include <linux/smc91x.h> | 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 | * Define your architecture specific bus configuration parameters here. | 61 | * Define your architecture specific bus configuration parameters here. |
| 41 | */ | 62 | */ |
| 42 | 63 | ||
| @@ -55,10 +76,30 @@ | |||
| 55 | #define SMC_IO_SHIFT (lp->io_shift) | 76 | #define SMC_IO_SHIFT (lp->io_shift) |
| 56 | 77 | ||
| 57 | #define SMC_inb(a, r) readb((a) + (r)) | 78 | #define SMC_inb(a, r) readb((a) + (r)) |
| 58 | #define SMC_inw(a, r) readw((a) + (r)) | 79 | #define SMC_inw(a, r) \ |
| 80 | ({ \ | ||
| 81 | unsigned int __smc_r = r; \ | ||
| 82 | SMC_16BIT(lp) ? readw((a) + __smc_r) : \ | ||
| 83 | SMC_8BIT(lp) ? SMC_inw_b(a, __smc_r) : \ | ||
| 84 | ({ BUG(); 0; }); \ | ||
| 85 | }) | ||
| 86 | |||
| 59 | #define SMC_inl(a, r) readl((a) + (r)) | 87 | #define SMC_inl(a, r) readl((a) + (r)) |
| 60 | #define SMC_outb(v, a, r) writeb(v, (a) + (r)) | 88 | #define SMC_outb(v, a, r) writeb(v, (a) + (r)) |
| 89 | #define SMC_outw(v, a, r) \ | ||
| 90 | do { \ | ||
| 91 | unsigned int __v = v, __smc_r = r; \ | ||
| 92 | if (SMC_16BIT(lp)) \ | ||
| 93 | __SMC_outw(__v, a, __smc_r); \ | ||
| 94 | else if (SMC_8BIT(lp)) \ | ||
| 95 | SMC_outw_b(__v, a, __smc_r); \ | ||
| 96 | else \ | ||
| 97 | BUG(); \ | ||
| 98 | } while (0) | ||
| 99 | |||
| 61 | #define SMC_outl(v, a, r) writel(v, (a) + (r)) | 100 | #define SMC_outl(v, a, r) writel(v, (a) + (r)) |
| 101 | #define SMC_insb(a, r, p, l) readsb((a) + (r), p, l) | ||
| 102 | #define SMC_outsb(a, r, p, l) writesb((a) + (r), p, l) | ||
| 62 | #define SMC_insw(a, r, p, l) readsw((a) + (r), p, l) | 103 | #define SMC_insw(a, r, p, l) readsw((a) + (r), p, l) |
| 63 | #define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) | 104 | #define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) |
| 64 | #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) | 105 | #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) |
| @@ -66,7 +107,7 @@ | |||
| 66 | #define SMC_IRQ_FLAGS (-1) /* from resource */ | 107 | #define SMC_IRQ_FLAGS (-1) /* from resource */ |
| 67 | 108 | ||
| 68 | /* We actually can't write halfwords properly if not word aligned */ | 109 | /* We actually can't write halfwords properly if not word aligned */ |
| 69 | static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg) | 110 | static inline void __SMC_outw(u16 val, void __iomem *ioaddr, int reg) |
| 70 | { | 111 | { |
| 71 | if ((machine_is_mainstone() || machine_is_stargate2() || | 112 | if ((machine_is_mainstone() || machine_is_stargate2() || |
| 72 | machine_is_pxa_idp()) && reg & 2) { | 113 | machine_is_pxa_idp()) && reg & 2) { |
| @@ -416,24 +457,8 @@ smc_pxa_dma_insw(void __iomem *ioaddr, struct smc_local *lp, int reg, int dma, | |||
| 416 | 457 | ||
| 417 | #if ! SMC_CAN_USE_16BIT | 458 | #if ! SMC_CAN_USE_16BIT |
| 418 | 459 | ||
| 419 | /* | 460 | #define SMC_outw(x, ioaddr, reg) SMC_outw_b(x, ioaddr, reg) |
| 420 | * Any 16-bit access is performed with two 8-bit accesses if the hardware | 461 | #define SMC_inw(ioaddr, reg) SMC_inw_b(ioaddr, reg) |
| 421 | * can't do it directly. Most registers are 16-bit so those are mandatory. | ||
| 422 | */ | ||
| 423 | #define SMC_outw(x, ioaddr, reg) \ | ||
| 424 | do { \ | ||
| 425 | unsigned int __val16 = (x); \ | ||
| 426 | SMC_outb( __val16, ioaddr, reg ); \ | ||
| 427 | SMC_outb( __val16 >> 8, ioaddr, reg + (1 << SMC_IO_SHIFT));\ | ||
| 428 | } while (0) | ||
| 429 | #define SMC_inw(ioaddr, reg) \ | ||
| 430 | ({ \ | ||
| 431 | unsigned int __val16; \ | ||
| 432 | __val16 = SMC_inb( ioaddr, reg ); \ | ||
| 433 | __val16 |= SMC_inb( ioaddr, reg + (1 << SMC_IO_SHIFT)) << 8; \ | ||
| 434 | __val16; \ | ||
| 435 | }) | ||
| 436 | |||
| 437 | #define SMC_insw(a, r, p, l) BUG() | 462 | #define SMC_insw(a, r, p, l) BUG() |
| 438 | #define SMC_outsw(a, r, p, l) BUG() | 463 | #define SMC_outsw(a, r, p, l) BUG() |
| 439 | 464 | ||
| @@ -445,7 +470,9 @@ smc_pxa_dma_insw(void __iomem *ioaddr, struct smc_local *lp, int reg, int dma, | |||
| 445 | #endif | 470 | #endif |
| 446 | 471 | ||
| 447 | #if ! SMC_CAN_USE_8BIT | 472 | #if ! SMC_CAN_USE_8BIT |
| 473 | #undef SMC_inb | ||
| 448 | #define SMC_inb(ioaddr, reg) ({ BUG(); 0; }) | 474 | #define SMC_inb(ioaddr, reg) ({ BUG(); 0; }) |
| 475 | #undef SMC_outb | ||
| 449 | #define SMC_outb(x, ioaddr, reg) BUG() | 476 | #define SMC_outb(x, ioaddr, reg) BUG() |
| 450 | #define SMC_insb(a, r, p, l) BUG() | 477 | #define SMC_insb(a, r, p, l) BUG() |
| 451 | #define SMC_outsb(a, r, p, l) BUG() | 478 | #define SMC_outsb(a, r, p, l) BUG() |
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index ca3134540d2d..4f8910b7db2e 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c | |||
| @@ -1099,15 +1099,8 @@ static int smsc911x_mii_init(struct platform_device *pdev, | |||
| 1099 | goto err_out_free_bus_2; | 1099 | goto err_out_free_bus_2; |
| 1100 | } | 1100 | } |
| 1101 | 1101 | ||
| 1102 | if (smsc911x_mii_probe(dev) < 0) { | ||
| 1103 | SMSC_WARN(pdata, probe, "Error registering mii bus"); | ||
| 1104 | goto err_out_unregister_bus_3; | ||
| 1105 | } | ||
| 1106 | |||
| 1107 | return 0; | 1102 | return 0; |
| 1108 | 1103 | ||
| 1109 | err_out_unregister_bus_3: | ||
| 1110 | mdiobus_unregister(pdata->mii_bus); | ||
| 1111 | err_out_free_bus_2: | 1104 | err_out_free_bus_2: |
| 1112 | mdiobus_free(pdata->mii_bus); | 1105 | mdiobus_free(pdata->mii_bus); |
| 1113 | err_out_1: | 1106 | err_out_1: |
| @@ -1514,23 +1507,90 @@ static void smsc911x_disable_irq_chip(struct net_device *dev) | |||
| 1514 | smsc911x_reg_write(pdata, INT_STS, 0xFFFFFFFF); | 1507 | smsc911x_reg_write(pdata, INT_STS, 0xFFFFFFFF); |
| 1515 | } | 1508 | } |
| 1516 | 1509 | ||
| 1510 | static irqreturn_t smsc911x_irqhandler(int irq, void *dev_id) | ||
| 1511 | { | ||
| 1512 | struct net_device *dev = dev_id; | ||
| 1513 | struct smsc911x_data *pdata = netdev_priv(dev); | ||
| 1514 | u32 intsts = smsc911x_reg_read(pdata, INT_STS); | ||
| 1515 | u32 inten = smsc911x_reg_read(pdata, INT_EN); | ||
| 1516 | int serviced = IRQ_NONE; | ||
| 1517 | u32 temp; | ||
| 1518 | |||
| 1519 | if (unlikely(intsts & inten & INT_STS_SW_INT_)) { | ||
| 1520 | temp = smsc911x_reg_read(pdata, INT_EN); | ||
| 1521 | temp &= (~INT_EN_SW_INT_EN_); | ||
| 1522 | smsc911x_reg_write(pdata, INT_EN, temp); | ||
| 1523 | smsc911x_reg_write(pdata, INT_STS, INT_STS_SW_INT_); | ||
| 1524 | pdata->software_irq_signal = 1; | ||
| 1525 | smp_wmb(); | ||
| 1526 | serviced = IRQ_HANDLED; | ||
| 1527 | } | ||
| 1528 | |||
| 1529 | if (unlikely(intsts & inten & INT_STS_RXSTOP_INT_)) { | ||
| 1530 | /* Called when there is a multicast update scheduled and | ||
| 1531 | * it is now safe to complete the update */ | ||
| 1532 | SMSC_TRACE(pdata, intr, "RX Stop interrupt"); | ||
| 1533 | smsc911x_reg_write(pdata, INT_STS, INT_STS_RXSTOP_INT_); | ||
| 1534 | if (pdata->multicast_update_pending) | ||
| 1535 | smsc911x_rx_multicast_update_workaround(pdata); | ||
| 1536 | serviced = IRQ_HANDLED; | ||
| 1537 | } | ||
| 1538 | |||
| 1539 | if (intsts & inten & INT_STS_TDFA_) { | ||
| 1540 | temp = smsc911x_reg_read(pdata, FIFO_INT); | ||
| 1541 | temp |= FIFO_INT_TX_AVAIL_LEVEL_; | ||
| 1542 | smsc911x_reg_write(pdata, FIFO_INT, temp); | ||
| 1543 | smsc911x_reg_write(pdata, INT_STS, INT_STS_TDFA_); | ||
| 1544 | netif_wake_queue(dev); | ||
| 1545 | serviced = IRQ_HANDLED; | ||
| 1546 | } | ||
| 1547 | |||
| 1548 | if (unlikely(intsts & inten & INT_STS_RXE_)) { | ||
| 1549 | SMSC_TRACE(pdata, intr, "RX Error interrupt"); | ||
| 1550 | smsc911x_reg_write(pdata, INT_STS, INT_STS_RXE_); | ||
| 1551 | serviced = IRQ_HANDLED; | ||
| 1552 | } | ||
| 1553 | |||
| 1554 | if (likely(intsts & inten & INT_STS_RSFL_)) { | ||
| 1555 | if (likely(napi_schedule_prep(&pdata->napi))) { | ||
| 1556 | /* Disable Rx interrupts */ | ||
| 1557 | temp = smsc911x_reg_read(pdata, INT_EN); | ||
| 1558 | temp &= (~INT_EN_RSFL_EN_); | ||
| 1559 | smsc911x_reg_write(pdata, INT_EN, temp); | ||
| 1560 | /* Schedule a NAPI poll */ | ||
| 1561 | __napi_schedule(&pdata->napi); | ||
| 1562 | } else { | ||
| 1563 | SMSC_WARN(pdata, rx_err, "napi_schedule_prep failed"); | ||
| 1564 | } | ||
| 1565 | serviced = IRQ_HANDLED; | ||
| 1566 | } | ||
| 1567 | |||
| 1568 | return serviced; | ||
| 1569 | } | ||
| 1570 | |||
| 1517 | static int smsc911x_open(struct net_device *dev) | 1571 | static int smsc911x_open(struct net_device *dev) |
| 1518 | { | 1572 | { |
| 1519 | struct smsc911x_data *pdata = netdev_priv(dev); | 1573 | struct smsc911x_data *pdata = netdev_priv(dev); |
| 1520 | unsigned int timeout; | 1574 | unsigned int timeout; |
| 1521 | unsigned int temp; | 1575 | unsigned int temp; |
| 1522 | unsigned int intcfg; | 1576 | unsigned int intcfg; |
| 1577 | int retval; | ||
| 1578 | int irq_flags; | ||
| 1523 | 1579 | ||
| 1524 | /* if the phy is not yet registered, retry later*/ | 1580 | /* find and start the given phy */ |
| 1525 | if (!dev->phydev) { | 1581 | if (!dev->phydev) { |
| 1526 | SMSC_WARN(pdata, hw, "phy_dev is NULL"); | 1582 | retval = smsc911x_mii_probe(dev); |
| 1527 | return -EAGAIN; | 1583 | if (retval < 0) { |
| 1584 | SMSC_WARN(pdata, probe, "Error starting phy"); | ||
| 1585 | goto out; | ||
| 1586 | } | ||
| 1528 | } | 1587 | } |
| 1529 | 1588 | ||
| 1530 | /* Reset the LAN911x */ | 1589 | /* Reset the LAN911x */ |
| 1531 | if (smsc911x_soft_reset(pdata)) { | 1590 | retval = smsc911x_soft_reset(pdata); |
| 1591 | if (retval) { | ||
| 1532 | SMSC_WARN(pdata, hw, "soft reset failed"); | 1592 | SMSC_WARN(pdata, hw, "soft reset failed"); |
| 1533 | return -EIO; | 1593 | goto mii_free_out; |
| 1534 | } | 1594 | } |
| 1535 | 1595 | ||
| 1536 | smsc911x_reg_write(pdata, HW_CFG, 0x00050000); | 1596 | smsc911x_reg_write(pdata, HW_CFG, 0x00050000); |
| @@ -1586,6 +1646,15 @@ static int smsc911x_open(struct net_device *dev) | |||
| 1586 | pdata->software_irq_signal = 0; | 1646 | pdata->software_irq_signal = 0; |
| 1587 | smp_wmb(); | 1647 | smp_wmb(); |
| 1588 | 1648 | ||
| 1649 | irq_flags = irq_get_trigger_type(dev->irq); | ||
| 1650 | retval = request_irq(dev->irq, smsc911x_irqhandler, | ||
| 1651 | irq_flags | IRQF_SHARED, dev->name, dev); | ||
| 1652 | if (retval) { | ||
| 1653 | SMSC_WARN(pdata, probe, | ||
| 1654 | "Unable to claim requested irq: %d", dev->irq); | ||
| 1655 | goto mii_free_out; | ||
| 1656 | } | ||
| 1657 | |||
| 1589 | temp = smsc911x_reg_read(pdata, INT_EN); | 1658 | temp = smsc911x_reg_read(pdata, INT_EN); |
| 1590 | temp |= INT_EN_SW_INT_EN_; | 1659 | temp |= INT_EN_SW_INT_EN_; |
| 1591 | smsc911x_reg_write(pdata, INT_EN, temp); | 1660 | smsc911x_reg_write(pdata, INT_EN, temp); |
| @@ -1600,7 +1669,8 @@ static int smsc911x_open(struct net_device *dev) | |||
| 1600 | if (!pdata->software_irq_signal) { | 1669 | if (!pdata->software_irq_signal) { |
| 1601 | netdev_warn(dev, "ISR failed signaling test (IRQ %d)\n", | 1670 | netdev_warn(dev, "ISR failed signaling test (IRQ %d)\n", |
| 1602 | dev->irq); | 1671 | dev->irq); |
| 1603 | return -ENODEV; | 1672 | retval = -ENODEV; |
| 1673 | goto irq_stop_out; | ||
| 1604 | } | 1674 | } |
| 1605 | SMSC_TRACE(pdata, ifup, "IRQ handler passed test using IRQ %d", | 1675 | SMSC_TRACE(pdata, ifup, "IRQ handler passed test using IRQ %d", |
| 1606 | dev->irq); | 1676 | dev->irq); |
| @@ -1646,6 +1716,14 @@ static int smsc911x_open(struct net_device *dev) | |||
| 1646 | 1716 | ||
| 1647 | netif_start_queue(dev); | 1717 | netif_start_queue(dev); |
| 1648 | return 0; | 1718 | return 0; |
| 1719 | |||
| 1720 | irq_stop_out: | ||
| 1721 | free_irq(dev->irq, dev); | ||
| 1722 | mii_free_out: | ||
| 1723 | phy_disconnect(dev->phydev); | ||
| 1724 | dev->phydev = NULL; | ||
| 1725 | out: | ||
| 1726 | return retval; | ||
| 1649 | } | 1727 | } |
| 1650 | 1728 | ||
| 1651 | /* Entry point for stopping the interface */ | 1729 | /* Entry point for stopping the interface */ |
| @@ -1667,9 +1745,15 @@ static int smsc911x_stop(struct net_device *dev) | |||
| 1667 | dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP); | 1745 | dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP); |
| 1668 | smsc911x_tx_update_txcounters(dev); | 1746 | smsc911x_tx_update_txcounters(dev); |
| 1669 | 1747 | ||
| 1748 | free_irq(dev->irq, dev); | ||
| 1749 | |||
| 1670 | /* Bring the PHY down */ | 1750 | /* Bring the PHY down */ |
| 1671 | if (dev->phydev) | 1751 | if (dev->phydev) { |
| 1672 | phy_stop(dev->phydev); | 1752 | phy_stop(dev->phydev); |
| 1753 | phy_disconnect(dev->phydev); | ||
| 1754 | dev->phydev = NULL; | ||
| 1755 | } | ||
| 1756 | netif_carrier_off(dev); | ||
| 1673 | 1757 | ||
| 1674 | SMSC_TRACE(pdata, ifdown, "Interface stopped"); | 1758 | SMSC_TRACE(pdata, ifdown, "Interface stopped"); |
| 1675 | return 0; | 1759 | return 0; |
| @@ -1811,67 +1895,6 @@ static void smsc911x_set_multicast_list(struct net_device *dev) | |||
| 1811 | spin_unlock_irqrestore(&pdata->mac_lock, flags); | 1895 | spin_unlock_irqrestore(&pdata->mac_lock, flags); |
| 1812 | } | 1896 | } |
| 1813 | 1897 | ||
| 1814 | static irqreturn_t smsc911x_irqhandler(int irq, void *dev_id) | ||
| 1815 | { | ||
| 1816 | struct net_device *dev = dev_id; | ||
| 1817 | struct smsc911x_data *pdata = netdev_priv(dev); | ||
| 1818 | u32 intsts = smsc911x_reg_read(pdata, INT_STS); | ||
| 1819 | u32 inten = smsc911x_reg_read(pdata, INT_EN); | ||
| 1820 | int serviced = IRQ_NONE; | ||
| 1821 | u32 temp; | ||
| 1822 | |||
| 1823 | if (unlikely(intsts & inten & INT_STS_SW_INT_)) { | ||
| 1824 | temp = smsc911x_reg_read(pdata, INT_EN); | ||
| 1825 | temp &= (~INT_EN_SW_INT_EN_); | ||
| 1826 | smsc911x_reg_write(pdata, INT_EN, temp); | ||
| 1827 | smsc911x_reg_write(pdata, INT_STS, INT_STS_SW_INT_); | ||
| 1828 | pdata->software_irq_signal = 1; | ||
| 1829 | smp_wmb(); | ||
| 1830 | serviced = IRQ_HANDLED; | ||
| 1831 | } | ||
| 1832 | |||
| 1833 | if (unlikely(intsts & inten & INT_STS_RXSTOP_INT_)) { | ||
| 1834 | /* Called when there is a multicast update scheduled and | ||
| 1835 | * it is now safe to complete the update */ | ||
| 1836 | SMSC_TRACE(pdata, intr, "RX Stop interrupt"); | ||
| 1837 | smsc911x_reg_write(pdata, INT_STS, INT_STS_RXSTOP_INT_); | ||
| 1838 | if (pdata->multicast_update_pending) | ||
| 1839 | smsc911x_rx_multicast_update_workaround(pdata); | ||
| 1840 | serviced = IRQ_HANDLED; | ||
| 1841 | } | ||
| 1842 | |||
| 1843 | if (intsts & inten & INT_STS_TDFA_) { | ||
| 1844 | temp = smsc911x_reg_read(pdata, FIFO_INT); | ||
| 1845 | temp |= FIFO_INT_TX_AVAIL_LEVEL_; | ||
| 1846 | smsc911x_reg_write(pdata, FIFO_INT, temp); | ||
| 1847 | smsc911x_reg_write(pdata, INT_STS, INT_STS_TDFA_); | ||
| 1848 | netif_wake_queue(dev); | ||
| 1849 | serviced = IRQ_HANDLED; | ||
| 1850 | } | ||
| 1851 | |||
| 1852 | if (unlikely(intsts & inten & INT_STS_RXE_)) { | ||
| 1853 | SMSC_TRACE(pdata, intr, "RX Error interrupt"); | ||
| 1854 | smsc911x_reg_write(pdata, INT_STS, INT_STS_RXE_); | ||
| 1855 | serviced = IRQ_HANDLED; | ||
| 1856 | } | ||
| 1857 | |||
| 1858 | if (likely(intsts & inten & INT_STS_RSFL_)) { | ||
| 1859 | if (likely(napi_schedule_prep(&pdata->napi))) { | ||
| 1860 | /* Disable Rx interrupts */ | ||
| 1861 | temp = smsc911x_reg_read(pdata, INT_EN); | ||
| 1862 | temp &= (~INT_EN_RSFL_EN_); | ||
| 1863 | smsc911x_reg_write(pdata, INT_EN, temp); | ||
| 1864 | /* Schedule a NAPI poll */ | ||
| 1865 | __napi_schedule(&pdata->napi); | ||
| 1866 | } else { | ||
| 1867 | SMSC_WARN(pdata, rx_err, "napi_schedule_prep failed"); | ||
| 1868 | } | ||
| 1869 | serviced = IRQ_HANDLED; | ||
| 1870 | } | ||
| 1871 | |||
| 1872 | return serviced; | ||
| 1873 | } | ||
| 1874 | |||
| 1875 | #ifdef CONFIG_NET_POLL_CONTROLLER | 1898 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 1876 | static void smsc911x_poll_controller(struct net_device *dev) | 1899 | static void smsc911x_poll_controller(struct net_device *dev) |
| 1877 | { | 1900 | { |
| @@ -2291,16 +2314,14 @@ static int smsc911x_drv_remove(struct platform_device *pdev) | |||
| 2291 | pdata = netdev_priv(dev); | 2314 | pdata = netdev_priv(dev); |
| 2292 | BUG_ON(!pdata); | 2315 | BUG_ON(!pdata); |
| 2293 | BUG_ON(!pdata->ioaddr); | 2316 | BUG_ON(!pdata->ioaddr); |
| 2294 | BUG_ON(!dev->phydev); | 2317 | WARN_ON(dev->phydev); |
| 2295 | 2318 | ||
| 2296 | SMSC_TRACE(pdata, ifdown, "Stopping driver"); | 2319 | SMSC_TRACE(pdata, ifdown, "Stopping driver"); |
| 2297 | 2320 | ||
| 2298 | phy_disconnect(dev->phydev); | ||
| 2299 | mdiobus_unregister(pdata->mii_bus); | 2321 | mdiobus_unregister(pdata->mii_bus); |
| 2300 | mdiobus_free(pdata->mii_bus); | 2322 | mdiobus_free(pdata->mii_bus); |
| 2301 | 2323 | ||
| 2302 | unregister_netdev(dev); | 2324 | unregister_netdev(dev); |
| 2303 | free_irq(dev->irq, dev); | ||
| 2304 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, | 2325 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, |
| 2305 | "smsc911x-memory"); | 2326 | "smsc911x-memory"); |
| 2306 | if (!res) | 2327 | if (!res) |
| @@ -2385,8 +2406,7 @@ static int smsc911x_drv_probe(struct platform_device *pdev) | |||
| 2385 | struct smsc911x_data *pdata; | 2406 | struct smsc911x_data *pdata; |
| 2386 | struct smsc911x_platform_config *config = dev_get_platdata(&pdev->dev); | 2407 | struct smsc911x_platform_config *config = dev_get_platdata(&pdev->dev); |
| 2387 | struct resource *res; | 2408 | struct resource *res; |
| 2388 | unsigned int intcfg = 0; | 2409 | int res_size, irq; |
| 2389 | int res_size, irq, irq_flags; | ||
| 2390 | int retval; | 2410 | int retval; |
| 2391 | 2411 | ||
| 2392 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, | 2412 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, |
| @@ -2425,7 +2445,6 @@ static int smsc911x_drv_probe(struct platform_device *pdev) | |||
| 2425 | 2445 | ||
| 2426 | pdata = netdev_priv(dev); | 2446 | pdata = netdev_priv(dev); |
| 2427 | dev->irq = irq; | 2447 | dev->irq = irq; |
| 2428 | irq_flags = irq_get_trigger_type(irq); | ||
| 2429 | pdata->ioaddr = ioremap_nocache(res->start, res_size); | 2448 | pdata->ioaddr = ioremap_nocache(res->start, res_size); |
| 2430 | 2449 | ||
| 2431 | pdata->dev = dev; | 2450 | pdata->dev = dev; |
| @@ -2472,43 +2491,23 @@ static int smsc911x_drv_probe(struct platform_device *pdev) | |||
| 2472 | if (retval < 0) | 2491 | if (retval < 0) |
| 2473 | goto out_disable_resources; | 2492 | goto out_disable_resources; |
| 2474 | 2493 | ||
| 2475 | /* configure irq polarity and type before connecting isr */ | 2494 | netif_carrier_off(dev); |
| 2476 | if (pdata->config.irq_polarity == SMSC911X_IRQ_POLARITY_ACTIVE_HIGH) | ||
| 2477 | intcfg |= INT_CFG_IRQ_POL_; | ||
| 2478 | |||
| 2479 | if (pdata->config.irq_type == SMSC911X_IRQ_TYPE_PUSH_PULL) | ||
| 2480 | intcfg |= INT_CFG_IRQ_TYPE_; | ||
| 2481 | |||
| 2482 | smsc911x_reg_write(pdata, INT_CFG, intcfg); | ||
| 2483 | |||
| 2484 | /* Ensure interrupts are globally disabled before connecting ISR */ | ||
| 2485 | smsc911x_disable_irq_chip(dev); | ||
| 2486 | 2495 | ||
| 2487 | retval = request_irq(dev->irq, smsc911x_irqhandler, | 2496 | retval = smsc911x_mii_init(pdev, dev); |
| 2488 | irq_flags | IRQF_SHARED, dev->name, dev); | ||
| 2489 | if (retval) { | 2497 | if (retval) { |
| 2490 | SMSC_WARN(pdata, probe, | 2498 | SMSC_WARN(pdata, probe, "Error %i initialising mii", retval); |
| 2491 | "Unable to claim requested irq: %d", dev->irq); | ||
| 2492 | goto out_disable_resources; | 2499 | goto out_disable_resources; |
| 2493 | } | 2500 | } |
| 2494 | 2501 | ||
| 2495 | netif_carrier_off(dev); | ||
| 2496 | |||
| 2497 | retval = register_netdev(dev); | 2502 | retval = register_netdev(dev); |
| 2498 | if (retval) { | 2503 | if (retval) { |
| 2499 | SMSC_WARN(pdata, probe, "Error %i registering device", retval); | 2504 | SMSC_WARN(pdata, probe, "Error %i registering device", retval); |
| 2500 | goto out_free_irq; | 2505 | goto out_disable_resources; |
| 2501 | } else { | 2506 | } else { |
| 2502 | SMSC_TRACE(pdata, probe, | 2507 | SMSC_TRACE(pdata, probe, |
| 2503 | "Network interface: \"%s\"", dev->name); | 2508 | "Network interface: \"%s\"", dev->name); |
| 2504 | } | 2509 | } |
| 2505 | 2510 | ||
| 2506 | retval = smsc911x_mii_init(pdev, dev); | ||
| 2507 | if (retval) { | ||
| 2508 | SMSC_WARN(pdata, probe, "Error %i initialising mii", retval); | ||
| 2509 | goto out_unregister_netdev_5; | ||
| 2510 | } | ||
| 2511 | |||
| 2512 | spin_lock_irq(&pdata->mac_lock); | 2511 | spin_lock_irq(&pdata->mac_lock); |
| 2513 | 2512 | ||
| 2514 | /* Check if mac address has been specified when bringing interface up */ | 2513 | /* Check if mac address has been specified when bringing interface up */ |
| @@ -2544,10 +2543,6 @@ static int smsc911x_drv_probe(struct platform_device *pdev) | |||
| 2544 | 2543 | ||
| 2545 | return 0; | 2544 | return 0; |
| 2546 | 2545 | ||
| 2547 | out_unregister_netdev_5: | ||
| 2548 | unregister_netdev(dev); | ||
| 2549 | out_free_irq: | ||
| 2550 | free_irq(dev->irq, dev); | ||
| 2551 | out_disable_resources: | 2546 | out_disable_resources: |
| 2552 | pm_runtime_put(&pdev->dev); | 2547 | pm_runtime_put(&pdev->dev); |
| 2553 | pm_runtime_disable(&pdev->dev); | 2548 | pm_runtime_disable(&pdev->dev); |
diff --git a/drivers/net/ethernet/synopsys/dwc_eth_qos.c b/drivers/net/ethernet/synopsys/dwc_eth_qos.c index 9f159a775af3..4490ebaed127 100644 --- a/drivers/net/ethernet/synopsys/dwc_eth_qos.c +++ b/drivers/net/ethernet/synopsys/dwc_eth_qos.c | |||
| @@ -1246,7 +1246,7 @@ static int dwceqos_mii_init(struct net_local *lp) | |||
| 1246 | lp->mii_bus->read = &dwceqos_mdio_read; | 1246 | lp->mii_bus->read = &dwceqos_mdio_read; |
| 1247 | lp->mii_bus->write = &dwceqos_mdio_write; | 1247 | lp->mii_bus->write = &dwceqos_mdio_write; |
| 1248 | lp->mii_bus->priv = lp; | 1248 | lp->mii_bus->priv = lp; |
| 1249 | lp->mii_bus->parent = &lp->ndev->dev; | 1249 | lp->mii_bus->parent = &lp->pdev->dev; |
| 1250 | 1250 | ||
| 1251 | of_address_to_resource(lp->pdev->dev.of_node, 0, &res); | 1251 | of_address_to_resource(lp->pdev->dev.of_node, 0, &res); |
| 1252 | snprintf(lp->mii_bus->id, MII_BUS_ID_SIZE, "%.8llx", | 1252 | snprintf(lp->mii_bus->id, MII_BUS_ID_SIZE, "%.8llx", |
| @@ -1622,13 +1622,7 @@ static void dwceqos_init_hw(struct net_local *lp) | |||
| 1622 | DWCEQOS_MMC_CTRL_RSTONRD); | 1622 | DWCEQOS_MMC_CTRL_RSTONRD); |
| 1623 | dwceqos_enable_mmc_interrupt(lp); | 1623 | dwceqos_enable_mmc_interrupt(lp); |
| 1624 | 1624 | ||
| 1625 | /* Enable Interrupts */ | 1625 | dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE, 0); |
| 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 | |||
| 1632 | dwceqos_write(lp, REG_DWCEQOS_MAC_IE, 0); | 1626 | dwceqos_write(lp, REG_DWCEQOS_MAC_IE, 0); |
| 1633 | 1627 | ||
| 1634 | dwceqos_write(lp, REG_DWCEQOS_MAC_CFG, DWCEQOS_MAC_CFG_IPC | | 1628 | dwceqos_write(lp, REG_DWCEQOS_MAC_CFG, DWCEQOS_MAC_CFG_IPC | |
| @@ -1905,6 +1899,15 @@ static int dwceqos_open(struct net_device *ndev) | |||
| 1905 | netif_start_queue(ndev); | 1899 | netif_start_queue(ndev); |
| 1906 | tasklet_enable(&lp->tx_bdreclaim_tasklet); | 1900 | tasklet_enable(&lp->tx_bdreclaim_tasklet); |
| 1907 | 1901 | ||
| 1902 | /* Enable Interrupts -- do this only after we enable NAPI and the | ||
| 1903 | * tasklet. | ||
| 1904 | */ | ||
| 1905 | dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE, | ||
| 1906 | DWCEQOS_DMA_CH0_IE_NIE | | ||
| 1907 | DWCEQOS_DMA_CH0_IE_RIE | DWCEQOS_DMA_CH0_IE_TIE | | ||
| 1908 | DWCEQOS_DMA_CH0_IE_AIE | | ||
| 1909 | DWCEQOS_DMA_CH0_IE_FBEE); | ||
| 1910 | |||
| 1908 | return 0; | 1911 | return 0; |
| 1909 | } | 1912 | } |
| 1910 | 1913 | ||
| @@ -2850,25 +2853,17 @@ static int dwceqos_probe(struct platform_device *pdev) | |||
| 2850 | 2853 | ||
| 2851 | ndev->features = ndev->hw_features; | 2854 | ndev->features = ndev->hw_features; |
| 2852 | 2855 | ||
| 2853 | netif_napi_add(ndev, &lp->napi, dwceqos_rx_poll, NAPI_POLL_WEIGHT); | ||
| 2854 | |||
| 2855 | ret = register_netdev(ndev); | ||
| 2856 | if (ret) { | ||
| 2857 | dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); | ||
| 2858 | goto err_out_clk_dis_aper; | ||
| 2859 | } | ||
| 2860 | |||
| 2861 | lp->phy_ref_clk = devm_clk_get(&pdev->dev, "phy_ref_clk"); | 2856 | lp->phy_ref_clk = devm_clk_get(&pdev->dev, "phy_ref_clk"); |
| 2862 | if (IS_ERR(lp->phy_ref_clk)) { | 2857 | if (IS_ERR(lp->phy_ref_clk)) { |
| 2863 | dev_err(&pdev->dev, "phy_ref_clk clock not found.\n"); | 2858 | dev_err(&pdev->dev, "phy_ref_clk clock not found.\n"); |
| 2864 | ret = PTR_ERR(lp->phy_ref_clk); | 2859 | ret = PTR_ERR(lp->phy_ref_clk); |
| 2865 | goto err_out_unregister_netdev; | 2860 | goto err_out_clk_dis_aper; |
| 2866 | } | 2861 | } |
| 2867 | 2862 | ||
| 2868 | ret = clk_prepare_enable(lp->phy_ref_clk); | 2863 | ret = clk_prepare_enable(lp->phy_ref_clk); |
| 2869 | if (ret) { | 2864 | if (ret) { |
| 2870 | dev_err(&pdev->dev, "Unable to enable device clock.\n"); | 2865 | dev_err(&pdev->dev, "Unable to enable device clock.\n"); |
| 2871 | goto err_out_unregister_netdev; | 2866 | goto err_out_clk_dis_aper; |
| 2872 | } | 2867 | } |
| 2873 | 2868 | ||
| 2874 | lp->phy_node = of_parse_phandle(lp->pdev->dev.of_node, | 2869 | lp->phy_node = of_parse_phandle(lp->pdev->dev.of_node, |
| @@ -2877,7 +2872,7 @@ static int dwceqos_probe(struct platform_device *pdev) | |||
| 2877 | ret = of_phy_register_fixed_link(lp->pdev->dev.of_node); | 2872 | ret = of_phy_register_fixed_link(lp->pdev->dev.of_node); |
| 2878 | if (ret < 0) { | 2873 | if (ret < 0) { |
| 2879 | dev_err(&pdev->dev, "invalid fixed-link"); | 2874 | dev_err(&pdev->dev, "invalid fixed-link"); |
| 2880 | goto err_out_unregister_clk_notifier; | 2875 | goto err_out_clk_dis_phy; |
| 2881 | } | 2876 | } |
| 2882 | 2877 | ||
| 2883 | lp->phy_node = of_node_get(lp->pdev->dev.of_node); | 2878 | lp->phy_node = of_node_get(lp->pdev->dev.of_node); |
| @@ -2886,7 +2881,7 @@ static int dwceqos_probe(struct platform_device *pdev) | |||
| 2886 | ret = of_get_phy_mode(lp->pdev->dev.of_node); | 2881 | ret = of_get_phy_mode(lp->pdev->dev.of_node); |
| 2887 | if (ret < 0) { | 2882 | if (ret < 0) { |
| 2888 | dev_err(&lp->pdev->dev, "error in getting phy i/f\n"); | 2883 | dev_err(&lp->pdev->dev, "error in getting phy i/f\n"); |
| 2889 | goto err_out_unregister_clk_notifier; | 2884 | goto err_out_clk_dis_phy; |
| 2890 | } | 2885 | } |
| 2891 | 2886 | ||
| 2892 | lp->phy_interface = ret; | 2887 | lp->phy_interface = ret; |
| @@ -2894,14 +2889,14 @@ static int dwceqos_probe(struct platform_device *pdev) | |||
| 2894 | ret = dwceqos_mii_init(lp); | 2889 | ret = dwceqos_mii_init(lp); |
| 2895 | if (ret) { | 2890 | if (ret) { |
| 2896 | dev_err(&lp->pdev->dev, "error in dwceqos_mii_init\n"); | 2891 | dev_err(&lp->pdev->dev, "error in dwceqos_mii_init\n"); |
| 2897 | goto err_out_unregister_clk_notifier; | 2892 | goto err_out_clk_dis_phy; |
| 2898 | } | 2893 | } |
| 2899 | 2894 | ||
| 2900 | ret = dwceqos_mii_probe(ndev); | 2895 | ret = dwceqos_mii_probe(ndev); |
| 2901 | if (ret != 0) { | 2896 | if (ret != 0) { |
| 2902 | netdev_err(ndev, "mii_probe fail.\n"); | 2897 | netdev_err(ndev, "mii_probe fail.\n"); |
| 2903 | ret = -ENXIO; | 2898 | ret = -ENXIO; |
| 2904 | goto err_out_unregister_clk_notifier; | 2899 | goto err_out_clk_dis_phy; |
| 2905 | } | 2900 | } |
| 2906 | 2901 | ||
| 2907 | dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0); | 2902 | dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0); |
| @@ -2919,7 +2914,7 @@ static int dwceqos_probe(struct platform_device *pdev) | |||
| 2919 | if (ret) { | 2914 | if (ret) { |
| 2920 | dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n", | 2915 | dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n", |
| 2921 | ret); | 2916 | ret); |
| 2922 | goto err_out_unregister_clk_notifier; | 2917 | goto err_out_clk_dis_phy; |
| 2923 | } | 2918 | } |
| 2924 | dev_info(&lp->pdev->dev, "pdev->id %d, baseaddr 0x%08lx, irq %d\n", | 2919 | dev_info(&lp->pdev->dev, "pdev->id %d, baseaddr 0x%08lx, irq %d\n", |
| 2925 | pdev->id, ndev->base_addr, ndev->irq); | 2920 | pdev->id, ndev->base_addr, ndev->irq); |
| @@ -2929,18 +2924,24 @@ static int dwceqos_probe(struct platform_device *pdev) | |||
| 2929 | if (ret) { | 2924 | if (ret) { |
| 2930 | dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n", | 2925 | dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n", |
| 2931 | ndev->irq, ret); | 2926 | ndev->irq, ret); |
| 2932 | goto err_out_unregister_clk_notifier; | 2927 | goto err_out_clk_dis_phy; |
| 2933 | } | 2928 | } |
| 2934 | 2929 | ||
| 2935 | if (netif_msg_probe(lp)) | 2930 | if (netif_msg_probe(lp)) |
| 2936 | netdev_dbg(ndev, "net_local@%p\n", lp); | 2931 | netdev_dbg(ndev, "net_local@%p\n", lp); |
| 2937 | 2932 | ||
| 2933 | netif_napi_add(ndev, &lp->napi, dwceqos_rx_poll, NAPI_POLL_WEIGHT); | ||
| 2934 | |||
| 2935 | ret = register_netdev(ndev); | ||
| 2936 | if (ret) { | ||
| 2937 | dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); | ||
| 2938 | goto err_out_clk_dis_phy; | ||
| 2939 | } | ||
| 2940 | |||
| 2938 | return 0; | 2941 | return 0; |
| 2939 | 2942 | ||
| 2940 | err_out_unregister_clk_notifier: | 2943 | err_out_clk_dis_phy: |
| 2941 | clk_disable_unprepare(lp->phy_ref_clk); | 2944 | clk_disable_unprepare(lp->phy_ref_clk); |
| 2942 | err_out_unregister_netdev: | ||
| 2943 | unregister_netdev(ndev); | ||
| 2944 | err_out_clk_dis_aper: | 2945 | err_out_clk_dis_aper: |
| 2945 | clk_disable_unprepare(lp->apb_pclk); | 2946 | clk_disable_unprepare(lp->apb_pclk); |
| 2946 | err_out_free_netdev: | 2947 | err_out_free_netdev: |
diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c index 7452b5f9d024..7108c68f16d3 100644 --- a/drivers/net/ethernet/tehuti/tehuti.c +++ b/drivers/net/ethernet/tehuti/tehuti.c | |||
| @@ -1987,7 +1987,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 1987 | if ((readl(nic->regs + FPGA_VER) & 0xFFF) >= 378) { | 1987 | if ((readl(nic->regs + FPGA_VER) & 0xFFF) >= 378) { |
| 1988 | err = pci_enable_msi(pdev); | 1988 | err = pci_enable_msi(pdev); |
| 1989 | if (err) | 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 | else | 1991 | else |
| 1992 | nic->irq_type = IRQ_MSI; | 1992 | nic->irq_type = IRQ_MSI; |
| 1993 | } else | 1993 | } else |
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c index 3cee84a24815..93dc10b10c09 100644 --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c | |||
| @@ -1131,11 +1131,13 @@ static int xemaclite_of_probe(struct platform_device *ofdev) | |||
| 1131 | lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong"); | 1131 | lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong"); |
| 1132 | mac_address = of_get_mac_address(ofdev->dev.of_node); | 1132 | mac_address = of_get_mac_address(ofdev->dev.of_node); |
| 1133 | 1133 | ||
| 1134 | if (mac_address) | 1134 | if (mac_address) { |
| 1135 | /* Set the MAC address. */ | 1135 | /* Set the MAC address. */ |
| 1136 | memcpy(ndev->dev_addr, mac_address, ETH_ALEN); | 1136 | memcpy(ndev->dev_addr, mac_address, ETH_ALEN); |
| 1137 | else | 1137 | } else { |
| 1138 | dev_warn(dev, "No MAC address found\n"); | 1138 | dev_warn(dev, "No MAC address found, using random\n"); |
| 1139 | eth_hw_addr_random(ndev); | ||
| 1140 | } | ||
| 1139 | 1141 | ||
| 1140 | /* Clear the Tx CSR's in case this is a restart */ | 1142 | /* Clear the Tx CSR's in case this is a restart */ |
| 1141 | __raw_writel(0, lp->base_addr + XEL_TSR_OFFSET); | 1143 | __raw_writel(0, lp->base_addr + XEL_TSR_OFFSET); |
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 47a64342cc16..b4863e4e522b 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig | |||
| @@ -303,6 +303,7 @@ config MDIO_HISI_FEMAC | |||
| 303 | 303 | ||
| 304 | config MDIO_XGENE | 304 | config MDIO_XGENE |
| 305 | tristate "APM X-Gene SoC MDIO bus controller" | 305 | tristate "APM X-Gene SoC MDIO bus controller" |
| 306 | depends on ARCH_XGENE || COMPILE_TEST | ||
| 306 | help | 307 | help |
| 307 | This module provides a driver for the MDIO busses found in the | 308 | This module provides a driver for the MDIO busses found in the |
| 308 | APM X-Gene SoC's. | 309 | APM X-Gene SoC's. |
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 053e87905b94..885ac9cbab5a 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c | |||
| @@ -964,7 +964,7 @@ static struct phy_driver ksphy_driver[] = { | |||
| 964 | .get_strings = kszphy_get_strings, | 964 | .get_strings = kszphy_get_strings, |
| 965 | .get_stats = kszphy_get_stats, | 965 | .get_stats = kszphy_get_stats, |
| 966 | .suspend = genphy_suspend, | 966 | .suspend = genphy_suspend, |
| 967 | .resume = genphy_resume, | 967 | .resume = kszphy_resume, |
| 968 | }, { | 968 | }, { |
| 969 | .phy_id = PHY_ID_KSZ8873MLL, | 969 | .phy_id = PHY_ID_KSZ8873MLL, |
| 970 | .phy_id_mask = MICREL_PHY_ID_MASK, | 970 | .phy_id_mask = MICREL_PHY_ID_MASK, |
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index c5dc2c363f96..c6f66832a1a6 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c | |||
| @@ -722,8 +722,10 @@ phy_err: | |||
| 722 | int phy_start_interrupts(struct phy_device *phydev) | 722 | int phy_start_interrupts(struct phy_device *phydev) |
| 723 | { | 723 | { |
| 724 | atomic_set(&phydev->irq_disable, 0); | 724 | atomic_set(&phydev->irq_disable, 0); |
| 725 | if (request_irq(phydev->irq, phy_interrupt, 0, "phy_interrupt", | 725 | if (request_irq(phydev->irq, phy_interrupt, |
| 726 | phydev) < 0) { | 726 | IRQF_SHARED, |
| 727 | "phy_interrupt", | ||
| 728 | phydev) < 0) { | ||
| 727 | pr_warn("%s: Can't get IRQ %d (PHY)\n", | 729 | pr_warn("%s: Can't get IRQ %d (PHY)\n", |
| 728 | phydev->mdio.bus->name, phydev->irq); | 730 | phydev->mdio.bus->name, phydev->irq); |
| 729 | phydev->irq = PHY_POLL; | 731 | phydev->irq = PHY_POLL; |
diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/team_mode_loadbalance.c index cdb19b385d42..b228bea7931f 100644 --- a/drivers/net/team/team_mode_loadbalance.c +++ b/drivers/net/team/team_mode_loadbalance.c | |||
| @@ -14,9 +14,23 @@ | |||
| 14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
| 15 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
| 16 | #include <linux/netdevice.h> | 16 | #include <linux/netdevice.h> |
| 17 | #include <linux/etherdevice.h> | ||
| 17 | #include <linux/filter.h> | 18 | #include <linux/filter.h> |
| 18 | #include <linux/if_team.h> | 19 | #include <linux/if_team.h> |
| 19 | 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 | } | ||
| 33 | |||
| 20 | struct lb_priv; | 34 | struct lb_priv; |
| 21 | 35 | ||
| 22 | typedef struct team_port *lb_select_tx_port_func_t(struct team *, | 36 | typedef struct team_port *lb_select_tx_port_func_t(struct team *, |
| @@ -652,6 +666,7 @@ static const struct team_mode_ops lb_mode_ops = { | |||
| 652 | .port_enter = lb_port_enter, | 666 | .port_enter = lb_port_enter, |
| 653 | .port_leave = lb_port_leave, | 667 | .port_leave = lb_port_leave, |
| 654 | .port_disabled = lb_port_disabled, | 668 | .port_disabled = lb_port_disabled, |
| 669 | .receive = lb_receive, | ||
| 655 | .transmit = lb_transmit, | 670 | .transmit = lb_transmit, |
| 656 | }; | 671 | }; |
| 657 | 672 | ||
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 9c8b5bc2b9d8..6f9df375c5d4 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
| @@ -894,11 +894,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 894 | if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC))) | 894 | if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC))) |
| 895 | goto drop; | 895 | goto drop; |
| 896 | 896 | ||
| 897 | if (skb->sk && sk_fullsock(skb->sk)) { | 897 | skb_tx_timestamp(skb); |
| 898 | sock_tx_timestamp(skb->sk, skb->sk->sk_tsflags, | ||
| 899 | &skb_shinfo(skb)->tx_flags); | ||
| 900 | sw_tx_timestamp(skb); | ||
| 901 | } | ||
| 902 | 898 | ||
| 903 | /* Orphan the skb - required as we might hang on to it | 899 | /* Orphan the skb - required as we might hang on to it |
| 904 | * for indefinite time. | 900 | * for indefinite time. |
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index 770212baaf05..528b9c9c4e60 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c | |||
| @@ -1009,6 +1009,7 @@ static int kaweth_probe( | |||
| 1009 | struct net_device *netdev; | 1009 | struct net_device *netdev; |
| 1010 | const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | 1010 | const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
| 1011 | int result = 0; | 1011 | int result = 0; |
| 1012 | int rv = -EIO; | ||
| 1012 | 1013 | ||
| 1013 | dev_dbg(dev, | 1014 | dev_dbg(dev, |
| 1014 | "Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x\n", | 1015 | "Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x\n", |
| @@ -1029,6 +1030,7 @@ static int kaweth_probe( | |||
| 1029 | kaweth = netdev_priv(netdev); | 1030 | kaweth = netdev_priv(netdev); |
| 1030 | kaweth->dev = udev; | 1031 | kaweth->dev = udev; |
| 1031 | kaweth->net = netdev; | 1032 | kaweth->net = netdev; |
| 1033 | kaweth->intf = intf; | ||
| 1032 | 1034 | ||
| 1033 | spin_lock_init(&kaweth->device_lock); | 1035 | spin_lock_init(&kaweth->device_lock); |
| 1034 | init_waitqueue_head(&kaweth->term_wait); | 1036 | init_waitqueue_head(&kaweth->term_wait); |
| @@ -1048,6 +1050,10 @@ static int kaweth_probe( | |||
| 1048 | /* Download the firmware */ | 1050 | /* Download the firmware */ |
| 1049 | dev_info(dev, "Downloading firmware...\n"); | 1051 | dev_info(dev, "Downloading firmware...\n"); |
| 1050 | kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); | 1052 | kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); |
| 1053 | if (!kaweth->firmware_buf) { | ||
| 1054 | rv = -ENOMEM; | ||
| 1055 | goto err_free_netdev; | ||
| 1056 | } | ||
| 1051 | if ((result = kaweth_download_firmware(kaweth, | 1057 | if ((result = kaweth_download_firmware(kaweth, |
| 1052 | "kaweth/new_code.bin", | 1058 | "kaweth/new_code.bin", |
| 1053 | 100, | 1059 | 100, |
| @@ -1139,8 +1145,6 @@ err_fw: | |||
| 1139 | 1145 | ||
| 1140 | dev_dbg(dev, "Initializing net device.\n"); | 1146 | dev_dbg(dev, "Initializing net device.\n"); |
| 1141 | 1147 | ||
| 1142 | kaweth->intf = intf; | ||
| 1143 | |||
| 1144 | kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); | 1148 | kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); |
| 1145 | if (!kaweth->tx_urb) | 1149 | if (!kaweth->tx_urb) |
| 1146 | goto err_free_netdev; | 1150 | goto err_free_netdev; |
| @@ -1204,7 +1208,7 @@ err_only_tx: | |||
| 1204 | err_free_netdev: | 1208 | err_free_netdev: |
| 1205 | free_netdev(netdev); | 1209 | free_netdev(netdev); |
| 1206 | 1210 | ||
| 1207 | return -EIO; | 1211 | return rv; |
| 1208 | } | 1212 | } |
| 1209 | 1213 | ||
| 1210 | /**************************************************************** | 1214 | /**************************************************************** |
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index c68fe495d3f9..4244b9d4418e 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c | |||
| @@ -914,7 +914,9 @@ vmxnet3_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq, | |||
| 914 | { | 914 | { |
| 915 | struct Vmxnet3_TxDataDesc *tdd; | 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 | memcpy(tdd->data, skb->data, ctx->copy_size); | 921 | memcpy(tdd->data, skb->data, ctx->copy_size); |
| 920 | netdev_dbg(adapter->netdev, | 922 | netdev_dbg(adapter->netdev, |
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h index 74fc03072b87..7dc37a090549 100644 --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h | |||
| @@ -69,10 +69,10 @@ | |||
| 69 | /* | 69 | /* |
| 70 | * Version numbers | 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 | /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ | 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 | #if defined(CONFIG_PCI_MSI) | 77 | #if defined(CONFIG_PCI_MSI) |
| 78 | /* RSS only makes sense if MSI-X is supported. */ | 78 | /* RSS only makes sense if MSI-X is supported. */ |
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index c0dda6fc0921..6e65832051d6 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
| @@ -2782,14 +2782,15 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, | |||
| 2782 | struct net_device *lowerdev = NULL; | 2782 | struct net_device *lowerdev = NULL; |
| 2783 | 2783 | ||
| 2784 | if (conf->flags & VXLAN_F_GPE) { | 2784 | if (conf->flags & VXLAN_F_GPE) { |
| 2785 | if (conf->flags & ~VXLAN_F_ALLOWED_GPE) | ||
| 2786 | return -EINVAL; | ||
| 2787 | /* For now, allow GPE only together with COLLECT_METADATA. | 2785 | /* For now, allow GPE only together with COLLECT_METADATA. |
| 2788 | * This can be relaxed later; in such case, the other side | 2786 | * This can be relaxed later; in such case, the other side |
| 2789 | * of the PtP link will have to be provided. | 2787 | * of the PtP link will have to be provided. |
| 2790 | */ | 2788 | */ |
| 2791 | if (!(conf->flags & VXLAN_F_COLLECT_METADATA)) | 2789 | if ((conf->flags & ~VXLAN_F_ALLOWED_GPE) || |
| 2790 | !(conf->flags & VXLAN_F_COLLECT_METADATA)) { | ||
| 2791 | pr_info("unsupported combination of extensions\n"); | ||
| 2792 | return -EINVAL; | 2792 | return -EINVAL; |
| 2793 | } | ||
| 2793 | 2794 | ||
| 2794 | vxlan_raw_setup(dev); | 2795 | vxlan_raw_setup(dev); |
| 2795 | } else { | 2796 | } else { |
| @@ -2842,6 +2843,9 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, | |||
| 2842 | dev->mtu = lowerdev->mtu - (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM); | 2843 | dev->mtu = lowerdev->mtu - (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM); |
| 2843 | 2844 | ||
| 2844 | needed_headroom = lowerdev->hard_header_len; | 2845 | needed_headroom = lowerdev->hard_header_len; |
| 2846 | } else if (vxlan_addr_multicast(&dst->remote_ip)) { | ||
| 2847 | pr_info("multicast destination requires interface to be specified\n"); | ||
| 2848 | return -EINVAL; | ||
| 2845 | } | 2849 | } |
| 2846 | 2850 | ||
| 2847 | if (conf->mtu) { | 2851 | if (conf->mtu) { |
| @@ -2874,8 +2878,10 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, | |||
| 2874 | tmp->cfg.saddr.sa.sa_family == AF_INET6) == use_ipv6 && | 2878 | tmp->cfg.saddr.sa.sa_family == AF_INET6) == use_ipv6 && |
| 2875 | tmp->cfg.dst_port == vxlan->cfg.dst_port && | 2879 | tmp->cfg.dst_port == vxlan->cfg.dst_port && |
| 2876 | (tmp->flags & VXLAN_F_RCV_FLAGS) == | 2880 | (tmp->flags & VXLAN_F_RCV_FLAGS) == |
| 2877 | (vxlan->flags & VXLAN_F_RCV_FLAGS)) | 2881 | (vxlan->flags & VXLAN_F_RCV_FLAGS)) { |
| 2878 | return -EEXIST; | 2882 | pr_info("duplicate VNI %u\n", be32_to_cpu(conf->vni)); |
| 2883 | return -EEXIST; | ||
| 2884 | } | ||
| 2879 | } | 2885 | } |
| 2880 | 2886 | ||
| 2881 | dev->ethtool_ops = &vxlan_ethtool_ops; | 2887 | dev->ethtool_ops = &vxlan_ethtool_ops; |
| @@ -2909,7 +2915,6 @@ static int vxlan_newlink(struct net *src_net, struct net_device *dev, | |||
| 2909 | struct nlattr *tb[], struct nlattr *data[]) | 2915 | struct nlattr *tb[], struct nlattr *data[]) |
| 2910 | { | 2916 | { |
| 2911 | struct vxlan_config conf; | 2917 | struct vxlan_config conf; |
| 2912 | int err; | ||
| 2913 | 2918 | ||
| 2914 | memset(&conf, 0, sizeof(conf)); | 2919 | memset(&conf, 0, sizeof(conf)); |
| 2915 | 2920 | ||
| @@ -3018,26 +3023,7 @@ static int vxlan_newlink(struct net *src_net, struct net_device *dev, | |||
| 3018 | if (tb[IFLA_MTU]) | 3023 | if (tb[IFLA_MTU]) |
| 3019 | conf.mtu = nla_get_u32(tb[IFLA_MTU]); | 3024 | conf.mtu = nla_get_u32(tb[IFLA_MTU]); |
| 3020 | 3025 | ||
| 3021 | err = vxlan_dev_configure(src_net, dev, &conf); | 3026 | return vxlan_dev_configure(src_net, dev, &conf); |
| 3022 | switch (err) { | ||
| 3023 | case -ENODEV: | ||
| 3024 | pr_info("ifindex %d does not exist\n", conf.remote_ifindex); | ||
| 3025 | break; | ||
| 3026 | |||
| 3027 | case -EPERM: | ||
| 3028 | pr_info("IPv6 is disabled via sysctl\n"); | ||
| 3029 | break; | ||
| 3030 | |||
| 3031 | case -EEXIST: | ||
| 3032 | pr_info("duplicate VNI %u\n", be32_to_cpu(conf.vni)); | ||
| 3033 | break; | ||
| 3034 | |||
| 3035 | case -EINVAL: | ||
| 3036 | pr_info("unsupported combination of extensions\n"); | ||
| 3037 | break; | ||
| 3038 | } | ||
| 3039 | |||
| 3040 | return err; | ||
| 3041 | } | 3027 | } |
| 3042 | 3028 | ||
| 3043 | static void vxlan_dellink(struct net_device *dev, struct list_head *head) | 3029 | static void vxlan_dellink(struct net_device *dev, struct list_head *head) |
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index 78db5d679f19..24c8d65bcf34 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c | |||
| @@ -1525,7 +1525,7 @@ static void ath10k_htt_rx_h_filter(struct ath10k *ar, | |||
| 1525 | static int ath10k_htt_rx_handle_amsdu(struct ath10k_htt *htt) | 1525 | static int ath10k_htt_rx_handle_amsdu(struct ath10k_htt *htt) |
| 1526 | { | 1526 | { |
| 1527 | struct ath10k *ar = htt->ar; | 1527 | struct ath10k *ar = htt->ar; |
| 1528 | static struct ieee80211_rx_status rx_status; | 1528 | struct ieee80211_rx_status *rx_status = &htt->rx_status; |
| 1529 | struct sk_buff_head amsdu; | 1529 | struct sk_buff_head amsdu; |
| 1530 | int ret; | 1530 | int ret; |
| 1531 | 1531 | ||
| @@ -1549,11 +1549,11 @@ static int ath10k_htt_rx_handle_amsdu(struct ath10k_htt *htt) | |||
| 1549 | return ret; | 1549 | return ret; |
| 1550 | } | 1550 | } |
| 1551 | 1551 | ||
| 1552 | ath10k_htt_rx_h_ppdu(ar, &amsdu, &rx_status, 0xffff); | 1552 | ath10k_htt_rx_h_ppdu(ar, &amsdu, rx_status, 0xffff); |
| 1553 | ath10k_htt_rx_h_unchain(ar, &amsdu, ret > 0); | 1553 | ath10k_htt_rx_h_unchain(ar, &amsdu, ret > 0); |
| 1554 | ath10k_htt_rx_h_filter(ar, &amsdu, &rx_status); | 1554 | ath10k_htt_rx_h_filter(ar, &amsdu, rx_status); |
| 1555 | ath10k_htt_rx_h_mpdu(ar, &amsdu, &rx_status); | 1555 | ath10k_htt_rx_h_mpdu(ar, &amsdu, rx_status); |
| 1556 | ath10k_htt_rx_h_deliver(ar, &amsdu, &rx_status); | 1556 | ath10k_htt_rx_h_deliver(ar, &amsdu, rx_status); |
| 1557 | 1557 | ||
| 1558 | return 0; | 1558 | return 0; |
| 1559 | } | 1559 | } |
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 9a22c478dd1b..07933c51a850 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c | |||
| @@ -3162,7 +3162,6 @@ static int ath10k_pci_probe(struct pci_dev *pdev, | |||
| 3162 | pci_hard_reset = ath10k_pci_qca988x_chip_reset; | 3162 | pci_hard_reset = ath10k_pci_qca988x_chip_reset; |
| 3163 | break; | 3163 | break; |
| 3164 | case QCA9887_1_0_DEVICE_ID: | 3164 | case QCA9887_1_0_DEVICE_ID: |
| 3165 | dev_warn(&pdev->dev, "QCA9887 support is still experimental, there are likely bugs. You have been warned.\n"); | ||
| 3166 | hw_rev = ATH10K_HW_QCA9887; | 3165 | hw_rev = ATH10K_HW_QCA9887; |
| 3167 | pci_ps = false; | 3166 | pci_ps = false; |
| 3168 | pci_soft_reset = ath10k_pci_warm_reset; | 3167 | pci_soft_reset = ath10k_pci_warm_reset; |
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index d1d0c06d627c..14b13f07cd1f 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
| @@ -2482,6 +2482,8 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) | |||
| 2482 | return -EINVAL; | 2482 | return -EINVAL; |
| 2483 | } | 2483 | } |
| 2484 | 2484 | ||
| 2485 | ath9k_gpio_cap_init(ah); | ||
| 2486 | |||
| 2485 | if (AR_SREV_9485(ah) || | 2487 | if (AR_SREV_9485(ah) || |
| 2486 | AR_SREV_9285(ah) || | 2488 | AR_SREV_9285(ah) || |
| 2487 | AR_SREV_9330(ah) || | 2489 | AR_SREV_9330(ah) || |
| @@ -2531,8 +2533,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) | |||
| 2531 | else | 2533 | else |
| 2532 | pCap->hw_caps &= ~ATH9K_HW_CAP_HT; | 2534 | pCap->hw_caps &= ~ATH9K_HW_CAP_HT; |
| 2533 | 2535 | ||
| 2534 | ath9k_gpio_cap_init(ah); | ||
| 2535 | |||
| 2536 | if (AR_SREV_9160_10_OR_LATER(ah) || AR_SREV_9100(ah)) | 2536 | if (AR_SREV_9160_10_OR_LATER(ah) || AR_SREV_9100(ah)) |
| 2537 | pCap->rts_aggr_limit = ATH_AMPDU_LIMIT_MAX; | 2537 | pCap->rts_aggr_limit = ATH_AMPDU_LIMIT_MAX; |
| 2538 | else | 2538 | else |
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index a394622c9022..7cb65c303f8d 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c | |||
| @@ -718,9 +718,12 @@ static int ath9k_start(struct ieee80211_hw *hw) | |||
| 718 | if (!ath_complete_reset(sc, false)) | 718 | if (!ath_complete_reset(sc, false)) |
| 719 | ah->reset_power_on = false; | 719 | ah->reset_power_on = false; |
| 720 | 720 | ||
| 721 | if (ah->led_pin >= 0) | 721 | if (ah->led_pin >= 0) { |
| 722 | ath9k_hw_set_gpio(ah, ah->led_pin, | 722 | ath9k_hw_set_gpio(ah, ah->led_pin, |
| 723 | (ah->config.led_active_high) ? 1 : 0); | 723 | (ah->config.led_active_high) ? 1 : 0); |
| 724 | ath9k_hw_gpio_request_out(ah, ah->led_pin, NULL, | ||
| 725 | AR_GPIO_OUTPUT_MUX_AS_OUTPUT); | ||
| 726 | } | ||
| 724 | 727 | ||
| 725 | /* | 728 | /* |
| 726 | * Reset key cache to sane defaults (all entries cleared) instead of | 729 | * Reset key cache to sane defaults (all entries cleared) instead of |
| @@ -864,9 +867,11 @@ static void ath9k_stop(struct ieee80211_hw *hw) | |||
| 864 | 867 | ||
| 865 | spin_lock_bh(&sc->sc_pcu_lock); | 868 | spin_lock_bh(&sc->sc_pcu_lock); |
| 866 | 869 | ||
| 867 | if (ah->led_pin >= 0) | 870 | if (ah->led_pin >= 0) { |
| 868 | ath9k_hw_set_gpio(ah, ah->led_pin, | 871 | ath9k_hw_set_gpio(ah, ah->led_pin, |
| 869 | (ah->config.led_active_high) ? 0 : 1); | 872 | (ah->config.led_active_high) ? 0 : 1); |
| 873 | ath9k_hw_gpio_request_in(ah, ah->led_pin, NULL); | ||
| 874 | } | ||
| 870 | 875 | ||
| 871 | ath_prepare_reset(sc); | 876 | ath_prepare_reset(sc); |
| 872 | 877 | ||
| @@ -1154,6 +1159,7 @@ void ath9k_calculate_summary_state(struct ath_softc *sc, | |||
| 1154 | bool changed = (iter_data.primary_sta != ctx->primary_sta); | 1159 | bool changed = (iter_data.primary_sta != ctx->primary_sta); |
| 1155 | 1160 | ||
| 1156 | if (iter_data.primary_sta) { | 1161 | if (iter_data.primary_sta) { |
| 1162 | iter_data.primary_beacon_vif = iter_data.primary_sta; | ||
| 1157 | iter_data.beacons = true; | 1163 | iter_data.beacons = true; |
| 1158 | ath9k_set_assoc_state(sc, iter_data.primary_sta, | 1164 | ath9k_set_assoc_state(sc, iter_data.primary_sta, |
| 1159 | changed); | 1165 | changed); |
| @@ -1563,13 +1569,13 @@ static int ath9k_sta_state(struct ieee80211_hw *hw, | |||
| 1563 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | 1569 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 1564 | int ret = 0; | 1570 | int ret = 0; |
| 1565 | 1571 | ||
| 1566 | if (old_state == IEEE80211_STA_AUTH && | 1572 | if (old_state == IEEE80211_STA_NOTEXIST && |
| 1567 | new_state == IEEE80211_STA_ASSOC) { | 1573 | new_state == IEEE80211_STA_NONE) { |
| 1568 | ret = ath9k_sta_add(hw, vif, sta); | 1574 | ret = ath9k_sta_add(hw, vif, sta); |
| 1569 | ath_dbg(common, CONFIG, | 1575 | ath_dbg(common, CONFIG, |
| 1570 | "Add station: %pM\n", sta->addr); | 1576 | "Add station: %pM\n", sta->addr); |
| 1571 | } else if (old_state == IEEE80211_STA_ASSOC && | 1577 | } else if (old_state == IEEE80211_STA_NONE && |
| 1572 | new_state == IEEE80211_STA_AUTH) { | 1578 | new_state == IEEE80211_STA_NOTEXIST) { |
| 1573 | ret = ath9k_sta_remove(hw, vif, sta); | 1579 | ret = ath9k_sta_remove(hw, vif, sta); |
| 1574 | ath_dbg(common, CONFIG, | 1580 | ath_dbg(common, CONFIG, |
| 1575 | "Remove station: %pM\n", sta->addr); | 1581 | "Remove station: %pM\n", sta->addr); |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index 2628d5e12c64..b8aec5e5ef93 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | |||
| @@ -4527,7 +4527,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev, | |||
| 4527 | (u8 *)&settings->beacon.head[ie_offset], | 4527 | (u8 *)&settings->beacon.head[ie_offset], |
| 4528 | settings->beacon.head_len - ie_offset, | 4528 | settings->beacon.head_len - ie_offset, |
| 4529 | WLAN_EID_SSID); | 4529 | WLAN_EID_SSID); |
| 4530 | if (!ssid_ie) | 4530 | if (!ssid_ie || ssid_ie->len > IEEE80211_MAX_SSID_LEN) |
| 4531 | return -EINVAL; | 4531 | return -EINVAL; |
| 4532 | 4532 | ||
| 4533 | memcpy(ssid_le.SSID, ssid_ie->data, ssid_ie->len); | 4533 | memcpy(ssid_le.SSID, ssid_ie->data, ssid_ie->len); |
| @@ -5635,7 +5635,7 @@ static s32 brcmf_notify_vif_event(struct brcmf_if *ifp, | |||
| 5635 | ifevent->action, ifevent->flags, ifevent->ifidx, | 5635 | ifevent->action, ifevent->flags, ifevent->ifidx, |
| 5636 | ifevent->bsscfgidx); | 5636 | ifevent->bsscfgidx); |
| 5637 | 5637 | ||
| 5638 | mutex_lock(&event->vif_event_lock); | 5638 | spin_lock(&event->vif_event_lock); |
| 5639 | event->action = ifevent->action; | 5639 | event->action = ifevent->action; |
| 5640 | vif = event->vif; | 5640 | vif = event->vif; |
| 5641 | 5641 | ||
| @@ -5643,7 +5643,7 @@ static s32 brcmf_notify_vif_event(struct brcmf_if *ifp, | |||
| 5643 | case BRCMF_E_IF_ADD: | 5643 | case BRCMF_E_IF_ADD: |
| 5644 | /* waiting process may have timed out */ | 5644 | /* waiting process may have timed out */ |
| 5645 | if (!cfg->vif_event.vif) { | 5645 | if (!cfg->vif_event.vif) { |
| 5646 | mutex_unlock(&event->vif_event_lock); | 5646 | spin_unlock(&event->vif_event_lock); |
| 5647 | return -EBADF; | 5647 | return -EBADF; |
| 5648 | } | 5648 | } |
| 5649 | 5649 | ||
| @@ -5654,24 +5654,24 @@ static s32 brcmf_notify_vif_event(struct brcmf_if *ifp, | |||
| 5654 | ifp->ndev->ieee80211_ptr = &vif->wdev; | 5654 | ifp->ndev->ieee80211_ptr = &vif->wdev; |
| 5655 | SET_NETDEV_DEV(ifp->ndev, wiphy_dev(cfg->wiphy)); | 5655 | SET_NETDEV_DEV(ifp->ndev, wiphy_dev(cfg->wiphy)); |
| 5656 | } | 5656 | } |
| 5657 | mutex_unlock(&event->vif_event_lock); | 5657 | spin_unlock(&event->vif_event_lock); |
| 5658 | wake_up(&event->vif_wq); | 5658 | wake_up(&event->vif_wq); |
| 5659 | return 0; | 5659 | return 0; |
| 5660 | 5660 | ||
| 5661 | case BRCMF_E_IF_DEL: | 5661 | case BRCMF_E_IF_DEL: |
| 5662 | mutex_unlock(&event->vif_event_lock); | 5662 | spin_unlock(&event->vif_event_lock); |
| 5663 | /* event may not be upon user request */ | 5663 | /* event may not be upon user request */ |
| 5664 | if (brcmf_cfg80211_vif_event_armed(cfg)) | 5664 | if (brcmf_cfg80211_vif_event_armed(cfg)) |
| 5665 | wake_up(&event->vif_wq); | 5665 | wake_up(&event->vif_wq); |
| 5666 | return 0; | 5666 | return 0; |
| 5667 | 5667 | ||
| 5668 | case BRCMF_E_IF_CHANGE: | 5668 | case BRCMF_E_IF_CHANGE: |
| 5669 | mutex_unlock(&event->vif_event_lock); | 5669 | spin_unlock(&event->vif_event_lock); |
| 5670 | wake_up(&event->vif_wq); | 5670 | wake_up(&event->vif_wq); |
| 5671 | return 0; | 5671 | return 0; |
| 5672 | 5672 | ||
| 5673 | default: | 5673 | default: |
| 5674 | mutex_unlock(&event->vif_event_lock); | 5674 | spin_unlock(&event->vif_event_lock); |
| 5675 | break; | 5675 | break; |
| 5676 | } | 5676 | } |
| 5677 | return -EINVAL; | 5677 | return -EINVAL; |
| @@ -5792,7 +5792,7 @@ static void wl_deinit_priv(struct brcmf_cfg80211_info *cfg) | |||
| 5792 | static void init_vif_event(struct brcmf_cfg80211_vif_event *event) | 5792 | static void init_vif_event(struct brcmf_cfg80211_vif_event *event) |
| 5793 | { | 5793 | { |
| 5794 | init_waitqueue_head(&event->vif_wq); | 5794 | init_waitqueue_head(&event->vif_wq); |
| 5795 | mutex_init(&event->vif_event_lock); | 5795 | spin_lock_init(&event->vif_event_lock); |
| 5796 | } | 5796 | } |
| 5797 | 5797 | ||
| 5798 | static s32 brcmf_dongle_roam(struct brcmf_if *ifp) | 5798 | static s32 brcmf_dongle_roam(struct brcmf_if *ifp) |
| @@ -6691,9 +6691,9 @@ static inline bool vif_event_equals(struct brcmf_cfg80211_vif_event *event, | |||
| 6691 | { | 6691 | { |
| 6692 | u8 evt_action; | 6692 | u8 evt_action; |
| 6693 | 6693 | ||
| 6694 | mutex_lock(&event->vif_event_lock); | 6694 | spin_lock(&event->vif_event_lock); |
| 6695 | evt_action = event->action; | 6695 | evt_action = event->action; |
| 6696 | mutex_unlock(&event->vif_event_lock); | 6696 | spin_unlock(&event->vif_event_lock); |
| 6697 | return evt_action == action; | 6697 | return evt_action == action; |
| 6698 | } | 6698 | } |
| 6699 | 6699 | ||
| @@ -6702,10 +6702,10 @@ void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg, | |||
| 6702 | { | 6702 | { |
| 6703 | struct brcmf_cfg80211_vif_event *event = &cfg->vif_event; | 6703 | struct brcmf_cfg80211_vif_event *event = &cfg->vif_event; |
| 6704 | 6704 | ||
| 6705 | mutex_lock(&event->vif_event_lock); | 6705 | spin_lock(&event->vif_event_lock); |
| 6706 | event->vif = vif; | 6706 | event->vif = vif; |
| 6707 | event->action = 0; | 6707 | event->action = 0; |
| 6708 | mutex_unlock(&event->vif_event_lock); | 6708 | spin_unlock(&event->vif_event_lock); |
| 6709 | } | 6709 | } |
| 6710 | 6710 | ||
| 6711 | bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg) | 6711 | bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg) |
| @@ -6713,9 +6713,9 @@ bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg) | |||
| 6713 | struct brcmf_cfg80211_vif_event *event = &cfg->vif_event; | 6713 | struct brcmf_cfg80211_vif_event *event = &cfg->vif_event; |
| 6714 | bool armed; | 6714 | bool armed; |
| 6715 | 6715 | ||
| 6716 | mutex_lock(&event->vif_event_lock); | 6716 | spin_lock(&event->vif_event_lock); |
| 6717 | armed = event->vif != NULL; | 6717 | armed = event->vif != NULL; |
| 6718 | mutex_unlock(&event->vif_event_lock); | 6718 | spin_unlock(&event->vif_event_lock); |
| 6719 | 6719 | ||
| 6720 | return armed; | 6720 | return armed; |
| 6721 | } | 6721 | } |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h index 7d77f869b7f1..8889832c17e0 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h | |||
| @@ -227,7 +227,7 @@ struct escan_info { | |||
| 227 | */ | 227 | */ |
| 228 | struct brcmf_cfg80211_vif_event { | 228 | struct brcmf_cfg80211_vif_event { |
| 229 | wait_queue_head_t vif_wq; | 229 | wait_queue_head_t vif_wq; |
| 230 | struct mutex vif_event_lock; | 230 | spinlock_t vif_event_lock; |
| 231 | u8 action; | 231 | u8 action; |
| 232 | struct brcmf_cfg80211_vif *vif; | 232 | struct brcmf_cfg80211_vif *vif; |
| 233 | }; | 233 | }; |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c index 8d16f0204985..65e8c8766441 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | |||
| @@ -743,7 +743,7 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx, | |||
| 743 | * serious troublesome side effects. The p2p module will clean | 743 | * serious troublesome side effects. The p2p module will clean |
| 744 | * up the ifp if needed. | 744 | * up the ifp if needed. |
| 745 | */ | 745 | */ |
| 746 | brcmf_p2p_ifp_removed(ifp); | 746 | brcmf_p2p_ifp_removed(ifp, rtnl_locked); |
| 747 | kfree(ifp); | 747 | kfree(ifp); |
| 748 | } | 748 | } |
| 749 | } | 749 | } |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c index 66f942f7448e..de19c7c92bc6 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | |||
| @@ -2297,7 +2297,7 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev) | |||
| 2297 | return err; | 2297 | return err; |
| 2298 | } | 2298 | } |
| 2299 | 2299 | ||
| 2300 | void brcmf_p2p_ifp_removed(struct brcmf_if *ifp) | 2300 | void brcmf_p2p_ifp_removed(struct brcmf_if *ifp, bool rtnl_locked) |
| 2301 | { | 2301 | { |
| 2302 | struct brcmf_cfg80211_info *cfg; | 2302 | struct brcmf_cfg80211_info *cfg; |
| 2303 | struct brcmf_cfg80211_vif *vif; | 2303 | struct brcmf_cfg80211_vif *vif; |
| @@ -2306,9 +2306,11 @@ void brcmf_p2p_ifp_removed(struct brcmf_if *ifp) | |||
| 2306 | vif = ifp->vif; | 2306 | vif = ifp->vif; |
| 2307 | cfg = wdev_to_cfg(&vif->wdev); | 2307 | cfg = wdev_to_cfg(&vif->wdev); |
| 2308 | cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif = NULL; | 2308 | cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif = NULL; |
| 2309 | rtnl_lock(); | 2309 | if (!rtnl_locked) |
| 2310 | rtnl_lock(); | ||
| 2310 | cfg80211_unregister_wdev(&vif->wdev); | 2311 | cfg80211_unregister_wdev(&vif->wdev); |
| 2311 | rtnl_unlock(); | 2312 | if (!rtnl_locked) |
| 2313 | rtnl_unlock(); | ||
| 2312 | brcmf_free_vif(vif); | 2314 | brcmf_free_vif(vif); |
| 2313 | } | 2315 | } |
| 2314 | 2316 | ||
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.h index a3bd18c2360b..8ce9447533ef 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.h | |||
| @@ -155,7 +155,7 @@ struct wireless_dev *brcmf_p2p_add_vif(struct wiphy *wiphy, const char *name, | |||
| 155 | int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev); | 155 | int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev); |
| 156 | int brcmf_p2p_ifchange(struct brcmf_cfg80211_info *cfg, | 156 | int brcmf_p2p_ifchange(struct brcmf_cfg80211_info *cfg, |
| 157 | enum brcmf_fil_p2p_if_types if_type); | 157 | enum brcmf_fil_p2p_if_types if_type); |
| 158 | void brcmf_p2p_ifp_removed(struct brcmf_if *ifp); | 158 | void brcmf_p2p_ifp_removed(struct brcmf_if *ifp, bool rtnl_locked); |
| 159 | int brcmf_p2p_start_device(struct wiphy *wiphy, struct wireless_dev *wdev); | 159 | int brcmf_p2p_start_device(struct wiphy *wiphy, struct wireless_dev *wdev); |
| 160 | void brcmf_p2p_stop_device(struct wiphy *wiphy, struct wireless_dev *wdev); | 160 | void brcmf_p2p_stop_device(struct wiphy *wiphy, struct wireless_dev *wdev); |
| 161 | int brcmf_p2p_scan_prep(struct wiphy *wiphy, | 161 | int brcmf_p2p_scan_prep(struct wiphy *wiphy, |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c index 1abcabb9b6cd..46b52bf705fb 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c | |||
| @@ -960,5 +960,6 @@ int iwl_mvm_start_fw_dbg_conf(struct iwl_mvm *mvm, u8 conf_id) | |||
| 960 | } | 960 | } |
| 961 | 961 | ||
| 962 | mvm->fw_dbg_conf = conf_id; | 962 | mvm->fw_dbg_conf = conf_id; |
| 963 | return ret; | 963 | |
| 964 | return 0; | ||
| 964 | } | 965 | } |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.h b/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.h index f7dff7612c9c..e9f1be9da7d4 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.h +++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.h | |||
| @@ -105,7 +105,8 @@ iwl_fw_dbg_trigger_vif_match(struct iwl_fw_dbg_trigger_tlv *trig, | |||
| 105 | { | 105 | { |
| 106 | u32 trig_vif = le32_to_cpu(trig->vif_type); | 106 | u32 trig_vif = le32_to_cpu(trig->vif_type); |
| 107 | 107 | ||
| 108 | return trig_vif == IWL_FW_DBG_CONF_VIF_ANY || vif->type == trig_vif; | 108 | return trig_vif == IWL_FW_DBG_CONF_VIF_ANY || |
| 109 | ieee80211_vif_type_p2p(vif) == trig_vif; | ||
| 109 | } | 110 | } |
| 110 | 111 | ||
| 111 | static inline bool | 112 | static inline bool |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c index 6d6064534d59..5dd77e336617 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | |||
| @@ -624,6 +624,7 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) | |||
| 624 | hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN | | 624 | hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN | |
| 625 | NL80211_FEATURE_LOW_PRIORITY_SCAN | | 625 | NL80211_FEATURE_LOW_PRIORITY_SCAN | |
| 626 | NL80211_FEATURE_P2P_GO_OPPPS | | 626 | NL80211_FEATURE_P2P_GO_OPPPS | |
| 627 | NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE | | ||
| 627 | NL80211_FEATURE_DYNAMIC_SMPS | | 628 | NL80211_FEATURE_DYNAMIC_SMPS | |
| 628 | NL80211_FEATURE_STATIC_SMPS | | 629 | NL80211_FEATURE_STATIC_SMPS | |
| 629 | NL80211_FEATURE_SUPPORTS_WMM_ADMISSION; | 630 | NL80211_FEATURE_SUPPORTS_WMM_ADMISSION; |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h index b4fc86d5d7ef..6a615bb73042 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | |||
| @@ -467,6 +467,8 @@ struct iwl_mvm_vif { | |||
| 467 | static inline struct iwl_mvm_vif * | 467 | static inline struct iwl_mvm_vif * |
| 468 | iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif) | 468 | iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif) |
| 469 | { | 469 | { |
| 470 | if (!vif) | ||
| 471 | return NULL; | ||
| 470 | return (void *)vif->drv_priv; | 472 | return (void *)vif->drv_priv; |
| 471 | } | 473 | } |
| 472 | 474 | ||
diff --git a/drivers/net/wireless/marvell/mwifiex/11n_aggr.c b/drivers/net/wireless/marvell/mwifiex/11n_aggr.c index dc49c3de1f25..c47d6366875d 100644 --- a/drivers/net/wireless/marvell/mwifiex/11n_aggr.c +++ b/drivers/net/wireless/marvell/mwifiex/11n_aggr.c | |||
| @@ -205,7 +205,8 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv, | |||
| 205 | 205 | ||
| 206 | do { | 206 | do { |
| 207 | /* Check if AMSDU can accommodate this MSDU */ | 207 | /* Check if AMSDU can accommodate this MSDU */ |
| 208 | if (skb_tailroom(skb_aggr) < (skb_src->len + LLC_SNAP_LEN)) | 208 | if ((skb_aggr->len + skb_src->len + LLC_SNAP_LEN) > |
| 209 | adapter->tx_buf_size) | ||
| 209 | break; | 210 | break; |
| 210 | 211 | ||
| 211 | skb_src = skb_dequeue(&pra_list->skb_head); | 212 | skb_src = skb_dequeue(&pra_list->skb_head); |
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index 458daf927336..935866fe5ec2 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c | |||
| @@ -185,8 +185,12 @@ long nvdimm_clear_poison(struct device *dev, phys_addr_t phys, | |||
| 185 | return -ENXIO; | 185 | return -ENXIO; |
| 186 | 186 | ||
| 187 | nd_desc = nvdimm_bus->nd_desc; | 187 | nd_desc = nvdimm_bus->nd_desc; |
| 188 | /* | ||
| 189 | * if ndctl does not exist, it's PMEM_LEGACY and | ||
| 190 | * we want to just pretend everything is handled. | ||
| 191 | */ | ||
| 188 | if (!nd_desc->ndctl) | 192 | if (!nd_desc->ndctl) |
| 189 | return -ENXIO; | 193 | return len; |
| 190 | 194 | ||
| 191 | memset(&ars_cap, 0, sizeof(ars_cap)); | 195 | memset(&ars_cap, 0, sizeof(ars_cap)); |
| 192 | ars_cap.address = phys; | 196 | ars_cap.address = phys; |
diff --git a/drivers/nvme/host/Kconfig b/drivers/nvme/host/Kconfig index db39d53cdfb9..f7d37a62f874 100644 --- a/drivers/nvme/host/Kconfig +++ b/drivers/nvme/host/Kconfig | |||
| @@ -30,8 +30,8 @@ config NVME_FABRICS | |||
| 30 | 30 | ||
| 31 | config NVME_RDMA | 31 | config NVME_RDMA |
| 32 | tristate "NVM Express over Fabrics RDMA host driver" | 32 | tristate "NVM Express over Fabrics RDMA host driver" |
| 33 | depends on INFINIBAND | 33 | depends on INFINIBAND && BLOCK |
| 34 | depends on BLK_DEV_NVME | 34 | select NVME_CORE |
| 35 | select NVME_FABRICS | 35 | select NVME_FABRICS |
| 36 | select SG_POOL | 36 | select SG_POOL |
| 37 | help | 37 | help |
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 7ff2e820bbf4..2feacc70bf61 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c | |||
| @@ -81,10 +81,12 @@ EXPORT_SYMBOL_GPL(nvme_cancel_request); | |||
| 81 | bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, | 81 | bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, |
| 82 | enum nvme_ctrl_state new_state) | 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 | bool changed = false; | 85 | bool changed = false; |
| 86 | 86 | ||
| 87 | spin_lock_irq(&ctrl->lock); | 87 | spin_lock_irq(&ctrl->lock); |
| 88 | |||
| 89 | old_state = ctrl->state; | ||
| 88 | switch (new_state) { | 90 | switch (new_state) { |
| 89 | case NVME_CTRL_LIVE: | 91 | case NVME_CTRL_LIVE: |
| 90 | switch (old_state) { | 92 | switch (old_state) { |
| @@ -140,11 +142,12 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, | |||
| 140 | default: | 142 | default: |
| 141 | break; | 143 | break; |
| 142 | } | 144 | } |
| 143 | spin_unlock_irq(&ctrl->lock); | ||
| 144 | 145 | ||
| 145 | if (changed) | 146 | if (changed) |
| 146 | ctrl->state = new_state; | 147 | ctrl->state = new_state; |
| 147 | 148 | ||
| 149 | spin_unlock_irq(&ctrl->lock); | ||
| 150 | |||
| 148 | return changed; | 151 | return changed; |
| 149 | } | 152 | } |
| 150 | EXPORT_SYMBOL_GPL(nvme_change_ctrl_state); | 153 | EXPORT_SYMBOL_GPL(nvme_change_ctrl_state); |
| @@ -608,7 +611,7 @@ int nvme_get_features(struct nvme_ctrl *dev, unsigned fid, unsigned nsid, | |||
| 608 | 611 | ||
| 609 | ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0, | 612 | ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0, |
| 610 | NVME_QID_ANY, 0, 0); | 613 | NVME_QID_ANY, 0, 0); |
| 611 | if (ret >= 0) | 614 | if (ret >= 0 && result) |
| 612 | *result = le32_to_cpu(cqe.result); | 615 | *result = le32_to_cpu(cqe.result); |
| 613 | return ret; | 616 | return ret; |
| 614 | } | 617 | } |
| @@ -628,7 +631,7 @@ int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dword11, | |||
| 628 | 631 | ||
| 629 | ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0, | 632 | ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0, |
| 630 | NVME_QID_ANY, 0, 0); | 633 | NVME_QID_ANY, 0, 0); |
| 631 | if (ret >= 0) | 634 | if (ret >= 0 && result) |
| 632 | *result = le32_to_cpu(cqe.result); | 635 | *result = le32_to_cpu(cqe.result); |
| 633 | return ret; | 636 | return ret; |
| 634 | } | 637 | } |
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index dc996761042f..4eff49174466 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c | |||
| @@ -47,8 +47,10 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn) | |||
| 47 | 47 | ||
| 48 | mutex_lock(&nvmf_hosts_mutex); | 48 | mutex_lock(&nvmf_hosts_mutex); |
| 49 | host = __nvmf_host_find(hostnqn); | 49 | host = __nvmf_host_find(hostnqn); |
| 50 | if (host) | 50 | if (host) { |
| 51 | kref_get(&host->ref); | ||
| 51 | goto out_unlock; | 52 | goto out_unlock; |
| 53 | } | ||
| 52 | 54 | ||
| 53 | host = kmalloc(sizeof(*host), GFP_KERNEL); | 55 | host = kmalloc(sizeof(*host), GFP_KERNEL); |
| 54 | if (!host) | 56 | if (!host) |
| @@ -56,7 +58,7 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn) | |||
| 56 | 58 | ||
| 57 | kref_init(&host->ref); | 59 | kref_init(&host->ref); |
| 58 | memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE); | 60 | memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE); |
| 59 | uuid_le_gen(&host->id); | 61 | uuid_be_gen(&host->id); |
| 60 | 62 | ||
| 61 | list_add_tail(&host->list, &nvmf_hosts); | 63 | list_add_tail(&host->list, &nvmf_hosts); |
| 62 | out_unlock: | 64 | out_unlock: |
| @@ -73,9 +75,9 @@ static struct nvmf_host *nvmf_host_default(void) | |||
| 73 | return NULL; | 75 | return NULL; |
| 74 | 76 | ||
| 75 | kref_init(&host->ref); | 77 | kref_init(&host->ref); |
| 76 | uuid_le_gen(&host->id); | 78 | uuid_be_gen(&host->id); |
| 77 | snprintf(host->nqn, NVMF_NQN_SIZE, | 79 | snprintf(host->nqn, NVMF_NQN_SIZE, |
| 78 | "nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUl", &host->id); | 80 | "nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb", &host->id); |
| 79 | 81 | ||
| 80 | mutex_lock(&nvmf_hosts_mutex); | 82 | mutex_lock(&nvmf_hosts_mutex); |
| 81 | list_add_tail(&host->list, &nvmf_hosts); | 83 | list_add_tail(&host->list, &nvmf_hosts); |
| @@ -363,7 +365,14 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl) | |||
| 363 | cmd.connect.opcode = nvme_fabrics_command; | 365 | cmd.connect.opcode = nvme_fabrics_command; |
| 364 | cmd.connect.fctype = nvme_fabrics_type_connect; | 366 | cmd.connect.fctype = nvme_fabrics_type_connect; |
| 365 | cmd.connect.qid = 0; | 367 | cmd.connect.qid = 0; |
| 366 | cmd.connect.sqsize = cpu_to_le16(ctrl->sqsize); | 368 | |
| 369 | /* | ||
| 370 | * fabrics spec sets a minimum of depth 32 for admin queue, | ||
| 371 | * so set the queue with this depth always until | ||
| 372 | * justification otherwise. | ||
| 373 | */ | ||
| 374 | cmd.connect.sqsize = cpu_to_le16(NVMF_AQ_DEPTH - 1); | ||
| 375 | |||
| 367 | /* | 376 | /* |
| 368 | * Set keep-alive timeout in seconds granularity (ms * 1000) | 377 | * Set keep-alive timeout in seconds granularity (ms * 1000) |
| 369 | * and add a grace period for controller kato enforcement | 378 | * and add a grace period for controller kato enforcement |
| @@ -375,7 +384,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl) | |||
| 375 | if (!data) | 384 | if (!data) |
| 376 | return -ENOMEM; | 385 | return -ENOMEM; |
| 377 | 386 | ||
| 378 | memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_le)); | 387 | memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be)); |
| 379 | data->cntlid = cpu_to_le16(0xffff); | 388 | data->cntlid = cpu_to_le16(0xffff); |
| 380 | strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); | 389 | strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); |
| 381 | strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); | 390 | strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); |
| @@ -434,7 +443,7 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid) | |||
| 434 | if (!data) | 443 | if (!data) |
| 435 | return -ENOMEM; | 444 | return -ENOMEM; |
| 436 | 445 | ||
| 437 | memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_le)); | 446 | memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be)); |
| 438 | data->cntlid = cpu_to_le16(ctrl->cntlid); | 447 | data->cntlid = cpu_to_le16(ctrl->cntlid); |
| 439 | strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); | 448 | strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); |
| 440 | strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); | 449 | strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); |
diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index 89df52c8be97..46e460aee52d 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h | |||
| @@ -34,7 +34,7 @@ struct nvmf_host { | |||
| 34 | struct kref ref; | 34 | struct kref ref; |
| 35 | struct list_head list; | 35 | struct list_head list; |
| 36 | char nqn[NVMF_NQN_SIZE]; | 36 | char nqn[NVMF_NQN_SIZE]; |
| 37 | uuid_le id; | 37 | uuid_be id; |
| 38 | }; | 38 | }; |
| 39 | 39 | ||
| 40 | /** | 40 | /** |
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 8dcf5a960951..60f7eab11865 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c | |||
| @@ -1693,7 +1693,12 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) | |||
| 1693 | nvme_suspend_queue(dev->queues[i]); | 1693 | nvme_suspend_queue(dev->queues[i]); |
| 1694 | 1694 | ||
| 1695 | if (csts & NVME_CSTS_CFS || !(csts & NVME_CSTS_RDY)) { | 1695 | if (csts & NVME_CSTS_CFS || !(csts & NVME_CSTS_RDY)) { |
| 1696 | nvme_suspend_queue(dev->queues[0]); | 1696 | /* A device might become IO incapable very soon during |
| 1697 | * probe, before the admin queue is configured. Thus, | ||
| 1698 | * queue_count can be 0 here. | ||
| 1699 | */ | ||
| 1700 | if (dev->queue_count) | ||
| 1701 | nvme_suspend_queue(dev->queues[0]); | ||
| 1697 | } else { | 1702 | } else { |
| 1698 | nvme_disable_io_queues(dev); | 1703 | nvme_disable_io_queues(dev); |
| 1699 | nvme_disable_admin_queue(dev, shutdown); | 1704 | nvme_disable_admin_queue(dev, shutdown); |
| @@ -2112,6 +2117,8 @@ static const struct pci_device_id nvme_id_table[] = { | |||
| 2112 | .driver_data = NVME_QUIRK_IDENTIFY_CNS, }, | 2117 | .driver_data = NVME_QUIRK_IDENTIFY_CNS, }, |
| 2113 | { PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */ | 2118 | { PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */ |
| 2114 | .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, }, | 2119 | .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, }, |
| 2120 | { PCI_DEVICE(0x1c5f, 0x0540), /* Memblaze Pblaze4 adapter */ | ||
| 2121 | .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, }, | ||
| 2115 | { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, | 2122 | { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, |
| 2116 | { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001) }, | 2123 | { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001) }, |
| 2117 | { 0, } | 2124 | { 0, } |
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 8d2875b4c56d..c2c2c28e6eb5 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c | |||
| @@ -43,10 +43,6 @@ | |||
| 43 | 43 | ||
| 44 | #define NVME_RDMA_MAX_INLINE_SEGMENTS 1 | 44 | #define NVME_RDMA_MAX_INLINE_SEGMENTS 1 |
| 45 | 45 | ||
| 46 | #define NVME_RDMA_MAX_PAGES_PER_MR 512 | ||
| 47 | |||
| 48 | #define NVME_RDMA_DEF_RECONNECT_DELAY 20 | ||
| 49 | |||
| 50 | /* | 46 | /* |
| 51 | * We handle AEN commands ourselves and don't even let the | 47 | * We handle AEN commands ourselves and don't even let the |
| 52 | * block layer know about them. | 48 | * block layer know about them. |
| @@ -77,7 +73,6 @@ struct nvme_rdma_request { | |||
| 77 | u32 num_sge; | 73 | u32 num_sge; |
| 78 | int nents; | 74 | int nents; |
| 79 | bool inline_data; | 75 | bool inline_data; |
| 80 | bool need_inval; | ||
| 81 | struct ib_reg_wr reg_wr; | 76 | struct ib_reg_wr reg_wr; |
| 82 | struct ib_cqe reg_cqe; | 77 | struct ib_cqe reg_cqe; |
| 83 | struct nvme_rdma_queue *queue; | 78 | struct nvme_rdma_queue *queue; |
| @@ -87,6 +82,8 @@ struct nvme_rdma_request { | |||
| 87 | 82 | ||
| 88 | enum nvme_rdma_queue_flags { | 83 | enum nvme_rdma_queue_flags { |
| 89 | NVME_RDMA_Q_CONNECTED = (1 << 0), | 84 | NVME_RDMA_Q_CONNECTED = (1 << 0), |
| 85 | NVME_RDMA_IB_QUEUE_ALLOCATED = (1 << 1), | ||
| 86 | NVME_RDMA_Q_DELETING = (1 << 2), | ||
| 90 | }; | 87 | }; |
| 91 | 88 | ||
| 92 | struct nvme_rdma_queue { | 89 | struct nvme_rdma_queue { |
| @@ -286,7 +283,7 @@ static int nvme_rdma_reinit_request(void *data, struct request *rq) | |||
| 286 | struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq); | 283 | struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq); |
| 287 | int ret = 0; | 284 | int ret = 0; |
| 288 | 285 | ||
| 289 | if (!req->need_inval) | 286 | if (!req->mr->need_inval) |
| 290 | goto out; | 287 | goto out; |
| 291 | 288 | ||
| 292 | ib_dereg_mr(req->mr); | 289 | ib_dereg_mr(req->mr); |
| @@ -296,9 +293,10 @@ static int nvme_rdma_reinit_request(void *data, struct request *rq) | |||
| 296 | if (IS_ERR(req->mr)) { | 293 | if (IS_ERR(req->mr)) { |
| 297 | ret = PTR_ERR(req->mr); | 294 | ret = PTR_ERR(req->mr); |
| 298 | req->mr = NULL; | 295 | req->mr = NULL; |
| 296 | goto out; | ||
| 299 | } | 297 | } |
| 300 | 298 | ||
| 301 | req->need_inval = false; | 299 | req->mr->need_inval = false; |
| 302 | 300 | ||
| 303 | out: | 301 | out: |
| 304 | return ret; | 302 | return ret; |
| @@ -485,9 +483,14 @@ out_err: | |||
| 485 | 483 | ||
| 486 | static void nvme_rdma_destroy_queue_ib(struct nvme_rdma_queue *queue) | 484 | static void nvme_rdma_destroy_queue_ib(struct nvme_rdma_queue *queue) |
| 487 | { | 485 | { |
| 488 | struct nvme_rdma_device *dev = queue->device; | 486 | struct nvme_rdma_device *dev; |
| 489 | struct ib_device *ibdev = dev->dev; | 487 | struct ib_device *ibdev; |
| 488 | |||
| 489 | if (!test_and_clear_bit(NVME_RDMA_IB_QUEUE_ALLOCATED, &queue->flags)) | ||
| 490 | return; | ||
| 490 | 491 | ||
| 492 | dev = queue->device; | ||
| 493 | ibdev = dev->dev; | ||
| 491 | rdma_destroy_qp(queue->cm_id); | 494 | rdma_destroy_qp(queue->cm_id); |
| 492 | ib_free_cq(queue->ib_cq); | 495 | ib_free_cq(queue->ib_cq); |
| 493 | 496 | ||
| @@ -538,6 +541,7 @@ static int nvme_rdma_create_queue_ib(struct nvme_rdma_queue *queue, | |||
| 538 | ret = -ENOMEM; | 541 | ret = -ENOMEM; |
| 539 | goto out_destroy_qp; | 542 | goto out_destroy_qp; |
| 540 | } | 543 | } |
| 544 | set_bit(NVME_RDMA_IB_QUEUE_ALLOCATED, &queue->flags); | ||
| 541 | 545 | ||
| 542 | return 0; | 546 | return 0; |
| 543 | 547 | ||
| @@ -557,6 +561,7 @@ static int nvme_rdma_init_queue(struct nvme_rdma_ctrl *ctrl, | |||
| 557 | 561 | ||
| 558 | queue = &ctrl->queues[idx]; | 562 | queue = &ctrl->queues[idx]; |
| 559 | queue->ctrl = ctrl; | 563 | queue->ctrl = ctrl; |
| 564 | queue->flags = 0; | ||
| 560 | init_completion(&queue->cm_done); | 565 | init_completion(&queue->cm_done); |
| 561 | 566 | ||
| 562 | if (idx > 0) | 567 | if (idx > 0) |
| @@ -595,6 +600,7 @@ static int nvme_rdma_init_queue(struct nvme_rdma_ctrl *ctrl, | |||
| 595 | return 0; | 600 | return 0; |
| 596 | 601 | ||
| 597 | out_destroy_cm_id: | 602 | out_destroy_cm_id: |
| 603 | nvme_rdma_destroy_queue_ib(queue); | ||
| 598 | rdma_destroy_id(queue->cm_id); | 604 | rdma_destroy_id(queue->cm_id); |
| 599 | return ret; | 605 | return ret; |
| 600 | } | 606 | } |
| @@ -613,7 +619,7 @@ static void nvme_rdma_free_queue(struct nvme_rdma_queue *queue) | |||
| 613 | 619 | ||
| 614 | static void nvme_rdma_stop_and_free_queue(struct nvme_rdma_queue *queue) | 620 | static void nvme_rdma_stop_and_free_queue(struct nvme_rdma_queue *queue) |
| 615 | { | 621 | { |
| 616 | if (!test_and_clear_bit(NVME_RDMA_Q_CONNECTED, &queue->flags)) | 622 | if (test_and_set_bit(NVME_RDMA_Q_DELETING, &queue->flags)) |
| 617 | return; | 623 | return; |
| 618 | nvme_rdma_stop_queue(queue); | 624 | nvme_rdma_stop_queue(queue); |
| 619 | nvme_rdma_free_queue(queue); | 625 | nvme_rdma_free_queue(queue); |
| @@ -645,7 +651,8 @@ static int nvme_rdma_init_io_queues(struct nvme_rdma_ctrl *ctrl) | |||
| 645 | int i, ret; | 651 | int i, ret; |
| 646 | 652 | ||
| 647 | for (i = 1; i < ctrl->queue_count; i++) { | 653 | for (i = 1; i < ctrl->queue_count; i++) { |
| 648 | ret = nvme_rdma_init_queue(ctrl, i, ctrl->ctrl.sqsize); | 654 | ret = nvme_rdma_init_queue(ctrl, i, |
| 655 | ctrl->ctrl.opts->queue_size); | ||
| 649 | if (ret) { | 656 | if (ret) { |
| 650 | dev_info(ctrl->ctrl.device, | 657 | dev_info(ctrl->ctrl.device, |
| 651 | "failed to initialize i/o queue: %d\n", ret); | 658 | "failed to initialize i/o queue: %d\n", ret); |
| @@ -656,7 +663,7 @@ static int nvme_rdma_init_io_queues(struct nvme_rdma_ctrl *ctrl) | |||
| 656 | return 0; | 663 | return 0; |
| 657 | 664 | ||
| 658 | out_free_queues: | 665 | out_free_queues: |
| 659 | for (; i >= 1; i--) | 666 | for (i--; i >= 1; i--) |
| 660 | nvme_rdma_stop_and_free_queue(&ctrl->queues[i]); | 667 | nvme_rdma_stop_and_free_queue(&ctrl->queues[i]); |
| 661 | 668 | ||
| 662 | return ret; | 669 | return ret; |
| @@ -765,8 +772,13 @@ static void nvme_rdma_error_recovery_work(struct work_struct *work) | |||
| 765 | { | 772 | { |
| 766 | struct nvme_rdma_ctrl *ctrl = container_of(work, | 773 | struct nvme_rdma_ctrl *ctrl = container_of(work, |
| 767 | struct nvme_rdma_ctrl, err_work); | 774 | struct nvme_rdma_ctrl, err_work); |
| 775 | int i; | ||
| 768 | 776 | ||
| 769 | nvme_stop_keep_alive(&ctrl->ctrl); | 777 | nvme_stop_keep_alive(&ctrl->ctrl); |
| 778 | |||
| 779 | for (i = 0; i < ctrl->queue_count; i++) | ||
| 780 | clear_bit(NVME_RDMA_Q_CONNECTED, &ctrl->queues[i].flags); | ||
| 781 | |||
| 770 | if (ctrl->queue_count > 1) | 782 | if (ctrl->queue_count > 1) |
| 771 | nvme_stop_queues(&ctrl->ctrl); | 783 | nvme_stop_queues(&ctrl->ctrl); |
| 772 | blk_mq_stop_hw_queues(ctrl->ctrl.admin_q); | 784 | blk_mq_stop_hw_queues(ctrl->ctrl.admin_q); |
| @@ -849,7 +861,7 @@ static void nvme_rdma_unmap_data(struct nvme_rdma_queue *queue, | |||
| 849 | if (!blk_rq_bytes(rq)) | 861 | if (!blk_rq_bytes(rq)) |
| 850 | return; | 862 | return; |
| 851 | 863 | ||
| 852 | if (req->need_inval) { | 864 | if (req->mr->need_inval) { |
| 853 | res = nvme_rdma_inv_rkey(queue, req); | 865 | res = nvme_rdma_inv_rkey(queue, req); |
| 854 | if (res < 0) { | 866 | if (res < 0) { |
| 855 | dev_err(ctrl->ctrl.device, | 867 | dev_err(ctrl->ctrl.device, |
| @@ -935,7 +947,7 @@ static int nvme_rdma_map_sg_fr(struct nvme_rdma_queue *queue, | |||
| 935 | IB_ACCESS_REMOTE_READ | | 947 | IB_ACCESS_REMOTE_READ | |
| 936 | IB_ACCESS_REMOTE_WRITE; | 948 | IB_ACCESS_REMOTE_WRITE; |
| 937 | 949 | ||
| 938 | req->need_inval = true; | 950 | req->mr->need_inval = true; |
| 939 | 951 | ||
| 940 | sg->addr = cpu_to_le64(req->mr->iova); | 952 | sg->addr = cpu_to_le64(req->mr->iova); |
| 941 | put_unaligned_le24(req->mr->length, sg->length); | 953 | put_unaligned_le24(req->mr->length, sg->length); |
| @@ -958,7 +970,7 @@ static int nvme_rdma_map_data(struct nvme_rdma_queue *queue, | |||
| 958 | 970 | ||
| 959 | req->num_sge = 1; | 971 | req->num_sge = 1; |
| 960 | req->inline_data = false; | 972 | req->inline_data = false; |
| 961 | req->need_inval = false; | 973 | req->mr->need_inval = false; |
| 962 | 974 | ||
| 963 | c->common.flags |= NVME_CMD_SGL_METABUF; | 975 | c->common.flags |= NVME_CMD_SGL_METABUF; |
| 964 | 976 | ||
| @@ -1145,7 +1157,7 @@ static int nvme_rdma_process_nvme_rsp(struct nvme_rdma_queue *queue, | |||
| 1145 | 1157 | ||
| 1146 | if ((wc->wc_flags & IB_WC_WITH_INVALIDATE) && | 1158 | if ((wc->wc_flags & IB_WC_WITH_INVALIDATE) && |
| 1147 | wc->ex.invalidate_rkey == req->mr->rkey) | 1159 | wc->ex.invalidate_rkey == req->mr->rkey) |
| 1148 | req->need_inval = false; | 1160 | req->mr->need_inval = false; |
| 1149 | 1161 | ||
| 1150 | blk_mq_complete_request(rq, status); | 1162 | blk_mq_complete_request(rq, status); |
| 1151 | 1163 | ||
| @@ -1278,8 +1290,22 @@ static int nvme_rdma_route_resolved(struct nvme_rdma_queue *queue) | |||
| 1278 | 1290 | ||
| 1279 | priv.recfmt = cpu_to_le16(NVME_RDMA_CM_FMT_1_0); | 1291 | priv.recfmt = cpu_to_le16(NVME_RDMA_CM_FMT_1_0); |
| 1280 | priv.qid = cpu_to_le16(nvme_rdma_queue_idx(queue)); | 1292 | priv.qid = cpu_to_le16(nvme_rdma_queue_idx(queue)); |
| 1281 | priv.hrqsize = cpu_to_le16(queue->queue_size); | 1293 | /* |
| 1282 | priv.hsqsize = cpu_to_le16(queue->queue_size); | 1294 | * set the admin queue depth to the minimum size |
| 1295 | * specified by the Fabrics standard. | ||
| 1296 | */ | ||
| 1297 | if (priv.qid == 0) { | ||
| 1298 | priv.hrqsize = cpu_to_le16(NVMF_AQ_DEPTH); | ||
| 1299 | priv.hsqsize = cpu_to_le16(NVMF_AQ_DEPTH - 1); | ||
| 1300 | } else { | ||
| 1301 | /* | ||
| 1302 | * current interpretation of the fabrics spec | ||
| 1303 | * is at minimum you make hrqsize sqsize+1, or a | ||
| 1304 | * 1's based representation of sqsize. | ||
| 1305 | */ | ||
| 1306 | priv.hrqsize = cpu_to_le16(queue->queue_size); | ||
| 1307 | priv.hsqsize = cpu_to_le16(queue->ctrl->ctrl.sqsize); | ||
| 1308 | } | ||
| 1283 | 1309 | ||
| 1284 | ret = rdma_connect(queue->cm_id, ¶m); | 1310 | ret = rdma_connect(queue->cm_id, ¶m); |
| 1285 | if (ret) { | 1311 | if (ret) { |
| @@ -1295,58 +1321,6 @@ out_destroy_queue_ib: | |||
| 1295 | return ret; | 1321 | return ret; |
| 1296 | } | 1322 | } |
| 1297 | 1323 | ||
| 1298 | /** | ||
| 1299 | * nvme_rdma_device_unplug() - Handle RDMA device unplug | ||
| 1300 | * @queue: Queue that owns the cm_id that caught the event | ||
| 1301 | * | ||
| 1302 | * DEVICE_REMOVAL event notifies us that the RDMA device is about | ||
| 1303 | * to unplug so we should take care of destroying our RDMA resources. | ||
| 1304 | * This event will be generated for each allocated cm_id. | ||
| 1305 | * | ||
| 1306 | * In our case, the RDMA resources are managed per controller and not | ||
| 1307 | * only per queue. So the way we handle this is we trigger an implicit | ||
| 1308 | * controller deletion upon the first DEVICE_REMOVAL event we see, and | ||
| 1309 | * hold the event inflight until the controller deletion is completed. | ||
| 1310 | * | ||
| 1311 | * One exception that we need to handle is the destruction of the cm_id | ||
| 1312 | * that caught the event. Since we hold the callout until the controller | ||
| 1313 | * deletion is completed, we'll deadlock if the controller deletion will | ||
| 1314 | * call rdma_destroy_id on this queue's cm_id. Thus, we claim ownership | ||
| 1315 | * of destroying this queue before-hand, destroy the queue resources, | ||
| 1316 | * then queue the controller deletion which won't destroy this queue and | ||
| 1317 | * we destroy the cm_id implicitely by returning a non-zero rc to the callout. | ||
| 1318 | */ | ||
| 1319 | static int nvme_rdma_device_unplug(struct nvme_rdma_queue *queue) | ||
| 1320 | { | ||
| 1321 | struct nvme_rdma_ctrl *ctrl = queue->ctrl; | ||
| 1322 | int ret; | ||
| 1323 | |||
| 1324 | /* Own the controller deletion */ | ||
| 1325 | if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING)) | ||
| 1326 | return 0; | ||
| 1327 | |||
| 1328 | dev_warn(ctrl->ctrl.device, | ||
| 1329 | "Got rdma device removal event, deleting ctrl\n"); | ||
| 1330 | |||
| 1331 | /* Get rid of reconnect work if its running */ | ||
| 1332 | cancel_delayed_work_sync(&ctrl->reconnect_work); | ||
| 1333 | |||
| 1334 | /* Disable the queue so ctrl delete won't free it */ | ||
| 1335 | if (test_and_clear_bit(NVME_RDMA_Q_CONNECTED, &queue->flags)) { | ||
| 1336 | /* Free this queue ourselves */ | ||
| 1337 | nvme_rdma_stop_queue(queue); | ||
| 1338 | nvme_rdma_destroy_queue_ib(queue); | ||
| 1339 | |||
| 1340 | /* Return non-zero so the cm_id will destroy implicitly */ | ||
| 1341 | ret = 1; | ||
| 1342 | } | ||
| 1343 | |||
| 1344 | /* Queue controller deletion */ | ||
| 1345 | queue_work(nvme_rdma_wq, &ctrl->delete_work); | ||
| 1346 | flush_work(&ctrl->delete_work); | ||
| 1347 | return ret; | ||
| 1348 | } | ||
| 1349 | |||
| 1350 | static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id, | 1324 | static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id, |
| 1351 | struct rdma_cm_event *ev) | 1325 | struct rdma_cm_event *ev) |
| 1352 | { | 1326 | { |
| @@ -1388,8 +1362,8 @@ static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id, | |||
| 1388 | nvme_rdma_error_recovery(queue->ctrl); | 1362 | nvme_rdma_error_recovery(queue->ctrl); |
| 1389 | break; | 1363 | break; |
| 1390 | case RDMA_CM_EVENT_DEVICE_REMOVAL: | 1364 | case RDMA_CM_EVENT_DEVICE_REMOVAL: |
| 1391 | /* return 1 means impliciy CM ID destroy */ | 1365 | /* device removal is handled via the ib_client API */ |
| 1392 | return nvme_rdma_device_unplug(queue); | 1366 | break; |
| 1393 | default: | 1367 | default: |
| 1394 | dev_err(queue->ctrl->ctrl.device, | 1368 | dev_err(queue->ctrl->ctrl.device, |
| 1395 | "Unexpected RDMA CM event (%d)\n", ev->event); | 1369 | "Unexpected RDMA CM event (%d)\n", ev->event); |
| @@ -1461,7 +1435,7 @@ static int nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx, | |||
| 1461 | if (rq->cmd_type == REQ_TYPE_FS && req_op(rq) == REQ_OP_FLUSH) | 1435 | if (rq->cmd_type == REQ_TYPE_FS && req_op(rq) == REQ_OP_FLUSH) |
| 1462 | flush = true; | 1436 | flush = true; |
| 1463 | ret = nvme_rdma_post_send(queue, sqe, req->sge, req->num_sge, | 1437 | ret = nvme_rdma_post_send(queue, sqe, req->sge, req->num_sge, |
| 1464 | req->need_inval ? &req->reg_wr.wr : NULL, flush); | 1438 | req->mr->need_inval ? &req->reg_wr.wr : NULL, flush); |
| 1465 | if (ret) { | 1439 | if (ret) { |
| 1466 | nvme_rdma_unmap_data(queue, rq); | 1440 | nvme_rdma_unmap_data(queue, rq); |
| 1467 | goto err; | 1441 | goto err; |
| @@ -1690,15 +1664,19 @@ static int __nvme_rdma_del_ctrl(struct nvme_rdma_ctrl *ctrl) | |||
| 1690 | static int nvme_rdma_del_ctrl(struct nvme_ctrl *nctrl) | 1664 | static int nvme_rdma_del_ctrl(struct nvme_ctrl *nctrl) |
| 1691 | { | 1665 | { |
| 1692 | struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl); | 1666 | struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl); |
| 1693 | int ret; | 1667 | int ret = 0; |
| 1694 | 1668 | ||
| 1669 | /* | ||
| 1670 | * Keep a reference until all work is flushed since | ||
| 1671 | * __nvme_rdma_del_ctrl can free the ctrl mem | ||
| 1672 | */ | ||
| 1673 | if (!kref_get_unless_zero(&ctrl->ctrl.kref)) | ||
| 1674 | return -EBUSY; | ||
| 1695 | ret = __nvme_rdma_del_ctrl(ctrl); | 1675 | ret = __nvme_rdma_del_ctrl(ctrl); |
| 1696 | if (ret) | 1676 | if (!ret) |
| 1697 | return ret; | 1677 | flush_work(&ctrl->delete_work); |
| 1698 | 1678 | nvme_put_ctrl(&ctrl->ctrl); | |
| 1699 | flush_work(&ctrl->delete_work); | 1679 | return ret; |
| 1700 | |||
| 1701 | return 0; | ||
| 1702 | } | 1680 | } |
| 1703 | 1681 | ||
| 1704 | static void nvme_rdma_remove_ctrl_work(struct work_struct *work) | 1682 | static void nvme_rdma_remove_ctrl_work(struct work_struct *work) |
| @@ -1816,7 +1794,7 @@ static int nvme_rdma_create_io_queues(struct nvme_rdma_ctrl *ctrl) | |||
| 1816 | 1794 | ||
| 1817 | memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set)); | 1795 | memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set)); |
| 1818 | ctrl->tag_set.ops = &nvme_rdma_mq_ops; | 1796 | ctrl->tag_set.ops = &nvme_rdma_mq_ops; |
| 1819 | ctrl->tag_set.queue_depth = ctrl->ctrl.sqsize; | 1797 | ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size; |
| 1820 | ctrl->tag_set.reserved_tags = 1; /* fabric connect */ | 1798 | ctrl->tag_set.reserved_tags = 1; /* fabric connect */ |
| 1821 | ctrl->tag_set.numa_node = NUMA_NO_NODE; | 1799 | ctrl->tag_set.numa_node = NUMA_NO_NODE; |
| 1822 | ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; | 1800 | ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; |
| @@ -1914,7 +1892,7 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, | |||
| 1914 | spin_lock_init(&ctrl->lock); | 1892 | spin_lock_init(&ctrl->lock); |
| 1915 | 1893 | ||
| 1916 | ctrl->queue_count = opts->nr_io_queues + 1; /* +1 for admin queue */ | 1894 | ctrl->queue_count = opts->nr_io_queues + 1; /* +1 for admin queue */ |
| 1917 | ctrl->ctrl.sqsize = opts->queue_size; | 1895 | ctrl->ctrl.sqsize = opts->queue_size - 1; |
| 1918 | ctrl->ctrl.kato = opts->kato; | 1896 | ctrl->ctrl.kato = opts->kato; |
| 1919 | 1897 | ||
| 1920 | ret = -ENOMEM; | 1898 | ret = -ENOMEM; |
| @@ -1995,27 +1973,57 @@ static struct nvmf_transport_ops nvme_rdma_transport = { | |||
| 1995 | .create_ctrl = nvme_rdma_create_ctrl, | 1973 | .create_ctrl = nvme_rdma_create_ctrl, |
| 1996 | }; | 1974 | }; |
| 1997 | 1975 | ||
| 1976 | static void nvme_rdma_add_one(struct ib_device *ib_device) | ||
| 1977 | { | ||
| 1978 | } | ||
| 1979 | |||
| 1980 | static void nvme_rdma_remove_one(struct ib_device *ib_device, void *client_data) | ||
| 1981 | { | ||
| 1982 | struct nvme_rdma_ctrl *ctrl; | ||
| 1983 | |||
| 1984 | /* Delete all controllers using this device */ | ||
| 1985 | mutex_lock(&nvme_rdma_ctrl_mutex); | ||
| 1986 | list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) { | ||
| 1987 | if (ctrl->device->dev != ib_device) | ||
| 1988 | continue; | ||
| 1989 | dev_info(ctrl->ctrl.device, | ||
| 1990 | "Removing ctrl: NQN \"%s\", addr %pISp\n", | ||
| 1991 | ctrl->ctrl.opts->subsysnqn, &ctrl->addr); | ||
| 1992 | __nvme_rdma_del_ctrl(ctrl); | ||
| 1993 | } | ||
| 1994 | mutex_unlock(&nvme_rdma_ctrl_mutex); | ||
| 1995 | |||
| 1996 | flush_workqueue(nvme_rdma_wq); | ||
| 1997 | } | ||
| 1998 | |||
| 1999 | static struct ib_client nvme_rdma_ib_client = { | ||
| 2000 | .name = "nvme_rdma", | ||
| 2001 | .add = nvme_rdma_add_one, | ||
| 2002 | .remove = nvme_rdma_remove_one | ||
| 2003 | }; | ||
| 2004 | |||
| 1998 | static int __init nvme_rdma_init_module(void) | 2005 | static int __init nvme_rdma_init_module(void) |
| 1999 | { | 2006 | { |
| 2007 | int ret; | ||
| 2008 | |||
| 2000 | nvme_rdma_wq = create_workqueue("nvme_rdma_wq"); | 2009 | nvme_rdma_wq = create_workqueue("nvme_rdma_wq"); |
| 2001 | if (!nvme_rdma_wq) | 2010 | if (!nvme_rdma_wq) |
| 2002 | return -ENOMEM; | 2011 | return -ENOMEM; |
| 2003 | 2012 | ||
| 2013 | ret = ib_register_client(&nvme_rdma_ib_client); | ||
| 2014 | if (ret) { | ||
| 2015 | destroy_workqueue(nvme_rdma_wq); | ||
| 2016 | return ret; | ||
| 2017 | } | ||
| 2018 | |||
| 2004 | nvmf_register_transport(&nvme_rdma_transport); | 2019 | nvmf_register_transport(&nvme_rdma_transport); |
| 2005 | return 0; | 2020 | return 0; |
| 2006 | } | 2021 | } |
| 2007 | 2022 | ||
| 2008 | static void __exit nvme_rdma_cleanup_module(void) | 2023 | static void __exit nvme_rdma_cleanup_module(void) |
| 2009 | { | 2024 | { |
| 2010 | struct nvme_rdma_ctrl *ctrl; | ||
| 2011 | |||
| 2012 | nvmf_unregister_transport(&nvme_rdma_transport); | 2025 | nvmf_unregister_transport(&nvme_rdma_transport); |
| 2013 | 2026 | ib_unregister_client(&nvme_rdma_ib_client); | |
| 2014 | mutex_lock(&nvme_rdma_ctrl_mutex); | ||
| 2015 | list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) | ||
| 2016 | __nvme_rdma_del_ctrl(ctrl); | ||
| 2017 | mutex_unlock(&nvme_rdma_ctrl_mutex); | ||
| 2018 | |||
| 2019 | destroy_workqueue(nvme_rdma_wq); | 2027 | destroy_workqueue(nvme_rdma_wq); |
| 2020 | } | 2028 | } |
| 2021 | 2029 | ||
diff --git a/drivers/nvme/target/Kconfig b/drivers/nvme/target/Kconfig index a5c31cbeb481..3a5b9d0576cb 100644 --- a/drivers/nvme/target/Kconfig +++ b/drivers/nvme/target/Kconfig | |||
| @@ -15,8 +15,8 @@ config NVME_TARGET | |||
| 15 | 15 | ||
| 16 | config NVME_TARGET_LOOP | 16 | config NVME_TARGET_LOOP |
| 17 | tristate "NVMe loopback device support" | 17 | tristate "NVMe loopback device support" |
| 18 | depends on BLK_DEV_NVME | ||
| 19 | depends on NVME_TARGET | 18 | depends on NVME_TARGET |
| 19 | select NVME_CORE | ||
| 20 | select NVME_FABRICS | 20 | select NVME_FABRICS |
| 21 | select SG_POOL | 21 | select SG_POOL |
| 22 | help | 22 | help |
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c index 7affd40a6b33..395e60dad835 100644 --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c | |||
| @@ -556,7 +556,7 @@ static int nvme_loop_create_io_queues(struct nvme_loop_ctrl *ctrl) | |||
| 556 | 556 | ||
| 557 | memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set)); | 557 | memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set)); |
| 558 | ctrl->tag_set.ops = &nvme_loop_mq_ops; | 558 | ctrl->tag_set.ops = &nvme_loop_mq_ops; |
| 559 | ctrl->tag_set.queue_depth = ctrl->ctrl.sqsize; | 559 | ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size; |
| 560 | ctrl->tag_set.reserved_tags = 1; /* fabric connect */ | 560 | ctrl->tag_set.reserved_tags = 1; /* fabric connect */ |
| 561 | ctrl->tag_set.numa_node = NUMA_NO_NODE; | 561 | ctrl->tag_set.numa_node = NUMA_NO_NODE; |
| 562 | ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; | 562 | ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; |
| @@ -620,7 +620,7 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev, | |||
| 620 | 620 | ||
| 621 | ret = -ENOMEM; | 621 | ret = -ENOMEM; |
| 622 | 622 | ||
| 623 | ctrl->ctrl.sqsize = opts->queue_size; | 623 | ctrl->ctrl.sqsize = opts->queue_size - 1; |
| 624 | ctrl->ctrl.kato = opts->kato; | 624 | ctrl->ctrl.kato = opts->kato; |
| 625 | 625 | ||
| 626 | ctrl->queues = kcalloc(opts->nr_io_queues + 1, sizeof(*ctrl->queues), | 626 | ctrl->queues = kcalloc(opts->nr_io_queues + 1, sizeof(*ctrl->queues), |
diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c index b4d648536c3e..1cbe6e053b5b 100644 --- a/drivers/nvme/target/rdma.c +++ b/drivers/nvme/target/rdma.c | |||
| @@ -978,10 +978,11 @@ static void nvmet_rdma_release_queue_work(struct work_struct *w) | |||
| 978 | container_of(w, struct nvmet_rdma_queue, release_work); | 978 | container_of(w, struct nvmet_rdma_queue, release_work); |
| 979 | struct rdma_cm_id *cm_id = queue->cm_id; | 979 | struct rdma_cm_id *cm_id = queue->cm_id; |
| 980 | struct nvmet_rdma_device *dev = queue->dev; | 980 | struct nvmet_rdma_device *dev = queue->dev; |
| 981 | enum nvmet_rdma_queue_state state = queue->state; | ||
| 981 | 982 | ||
| 982 | nvmet_rdma_free_queue(queue); | 983 | nvmet_rdma_free_queue(queue); |
| 983 | 984 | ||
| 984 | if (queue->state != NVMET_RDMA_IN_DEVICE_REMOVAL) | 985 | if (state != NVMET_RDMA_IN_DEVICE_REMOVAL) |
| 985 | rdma_destroy_id(cm_id); | 986 | rdma_destroy_id(cm_id); |
| 986 | 987 | ||
| 987 | kref_put(&dev->ref, nvmet_rdma_free_dev); | 988 | kref_put(&dev->ref, nvmet_rdma_free_dev); |
| @@ -1003,10 +1004,10 @@ nvmet_rdma_parse_cm_connect_req(struct rdma_conn_param *conn, | |||
| 1003 | queue->host_qid = le16_to_cpu(req->qid); | 1004 | queue->host_qid = le16_to_cpu(req->qid); |
| 1004 | 1005 | ||
| 1005 | /* | 1006 | /* |
| 1006 | * req->hsqsize corresponds to our recv queue size | 1007 | * req->hsqsize corresponds to our recv queue size plus 1 |
| 1007 | * req->hrqsize corresponds to our send queue size | 1008 | * req->hrqsize corresponds to our send queue size |
| 1008 | */ | 1009 | */ |
| 1009 | queue->recv_queue_size = le16_to_cpu(req->hsqsize); | 1010 | queue->recv_queue_size = le16_to_cpu(req->hsqsize) + 1; |
| 1010 | queue->send_queue_size = le16_to_cpu(req->hrqsize); | 1011 | queue->send_queue_size = le16_to_cpu(req->hrqsize); |
| 1011 | 1012 | ||
| 1012 | if (!queue->host_qid && queue->recv_queue_size > NVMF_AQ_DEPTH) | 1013 | if (!queue->host_qid && queue->recv_queue_size > NVMF_AQ_DEPTH) |
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index eafa6138a6b8..98f12223c734 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
| @@ -1069,7 +1069,7 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, | |||
| 1069 | nvec = maxvec; | 1069 | nvec = maxvec; |
| 1070 | 1070 | ||
| 1071 | for (;;) { | 1071 | for (;;) { |
| 1072 | if (!(flags & PCI_IRQ_NOAFFINITY)) { | 1072 | if (flags & PCI_IRQ_AFFINITY) { |
| 1073 | dev->irq_affinity = irq_create_affinity_mask(&nvec); | 1073 | dev->irq_affinity = irq_create_affinity_mask(&nvec); |
| 1074 | if (nvec < minvec) | 1074 | if (nvec < minvec) |
| 1075 | return -ENOSPC; | 1075 | return -ENOSPC; |
| @@ -1105,7 +1105,7 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, | |||
| 1105 | **/ | 1105 | **/ |
| 1106 | int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) | 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 | EXPORT_SYMBOL(pci_enable_msi_range); | 1110 | EXPORT_SYMBOL(pci_enable_msi_range); |
| 1111 | 1111 | ||
| @@ -1120,7 +1120,7 @@ static int __pci_enable_msix_range(struct pci_dev *dev, | |||
| 1120 | return -ERANGE; | 1120 | return -ERANGE; |
| 1121 | 1121 | ||
| 1122 | for (;;) { | 1122 | for (;;) { |
| 1123 | if (!(flags & PCI_IRQ_NOAFFINITY)) { | 1123 | if (flags & PCI_IRQ_AFFINITY) { |
| 1124 | dev->irq_affinity = irq_create_affinity_mask(&nvec); | 1124 | dev->irq_affinity = irq_create_affinity_mask(&nvec); |
| 1125 | if (nvec < minvec) | 1125 | if (nvec < minvec) |
| 1126 | return -ENOSPC; | 1126 | return -ENOSPC; |
| @@ -1160,8 +1160,7 @@ static int __pci_enable_msix_range(struct pci_dev *dev, | |||
| 1160 | int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, | 1160 | int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, |
| 1161 | int minvec, int maxvec) | 1161 | int minvec, int maxvec) |
| 1162 | { | 1162 | { |
| 1163 | return __pci_enable_msix_range(dev, entries, minvec, maxvec, | 1163 | return __pci_enable_msix_range(dev, entries, minvec, maxvec, 0); |
| 1164 | PCI_IRQ_NOAFFINITY); | ||
| 1165 | } | 1164 | } |
| 1166 | EXPORT_SYMBOL(pci_enable_msix_range); | 1165 | EXPORT_SYMBOL(pci_enable_msix_range); |
| 1167 | 1166 | ||
| @@ -1187,22 +1186,25 @@ int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, | |||
| 1187 | { | 1186 | { |
| 1188 | int vecs = -ENOSPC; | 1187 | int vecs = -ENOSPC; |
| 1189 | 1188 | ||
| 1190 | if (!(flags & PCI_IRQ_NOMSIX)) { | 1189 | if (flags & PCI_IRQ_MSIX) { |
| 1191 | vecs = __pci_enable_msix_range(dev, NULL, min_vecs, max_vecs, | 1190 | vecs = __pci_enable_msix_range(dev, NULL, min_vecs, max_vecs, |
| 1192 | flags); | 1191 | flags); |
| 1193 | if (vecs > 0) | 1192 | if (vecs > 0) |
| 1194 | return vecs; | 1193 | return vecs; |
| 1195 | } | 1194 | } |
| 1196 | 1195 | ||
| 1197 | if (!(flags & PCI_IRQ_NOMSI)) { | 1196 | if (flags & PCI_IRQ_MSI) { |
| 1198 | vecs = __pci_enable_msi_range(dev, min_vecs, max_vecs, flags); | 1197 | vecs = __pci_enable_msi_range(dev, min_vecs, max_vecs, flags); |
| 1199 | if (vecs > 0) | 1198 | if (vecs > 0) |
| 1200 | return vecs; | 1199 | return vecs; |
| 1201 | } | 1200 | } |
| 1202 | 1201 | ||
| 1203 | /* use legacy irq if allowed */ | 1202 | /* use legacy irq if allowed */ |
| 1204 | if (!(flags & PCI_IRQ_NOLEGACY) && min_vecs == 1) | 1203 | if ((flags & PCI_IRQ_LEGACY) && min_vecs == 1) { |
| 1204 | pci_intx(dev, 1); | ||
| 1205 | return 1; | 1205 | return 1; |
| 1206 | } | ||
| 1207 | |||
| 1206 | return vecs; | 1208 | return vecs; |
| 1207 | } | 1209 | } |
| 1208 | EXPORT_SYMBOL(pci_alloc_irq_vectors); | 1210 | EXPORT_SYMBOL(pci_alloc_irq_vectors); |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 37ff0158e45f..44e0ff37480b 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
| @@ -3327,9 +3327,9 @@ static void quirk_apple_wait_for_thunderbolt(struct pci_dev *dev) | |||
| 3327 | if (nhi->vendor != PCI_VENDOR_ID_INTEL | 3327 | if (nhi->vendor != PCI_VENDOR_ID_INTEL |
| 3328 | || (nhi->device != PCI_DEVICE_ID_INTEL_LIGHT_RIDGE && | 3328 | || (nhi->device != PCI_DEVICE_ID_INTEL_LIGHT_RIDGE && |
| 3329 | nhi->device != PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C && | 3329 | nhi->device != PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C && |
| 3330 | nhi->device != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_NHI && | ||
| 3330 | nhi->device != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI) | 3331 | nhi->device != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI) |
| 3331 | || nhi->subsystem_vendor != 0x2222 | 3332 | || nhi->class != PCI_CLASS_SYSTEM_OTHER << 8) |
| 3332 | || nhi->subsystem_device != 0x1111) | ||
| 3333 | goto out; | 3333 | goto out; |
| 3334 | dev_info(&dev->dev, "quirk: waiting for thunderbolt to reestablish PCI tunnels...\n"); | 3334 | dev_info(&dev->dev, "quirk: waiting for thunderbolt to reestablish PCI tunnels...\n"); |
| 3335 | device_pm_wait_for_dev(&dev->dev, &nhi->dev); | 3335 | device_pm_wait_for_dev(&dev->dev, &nhi->dev); |
| @@ -3344,6 +3344,9 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, | |||
| 3344 | PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C, | 3344 | PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C, |
| 3345 | quirk_apple_wait_for_thunderbolt); | 3345 | quirk_apple_wait_for_thunderbolt); |
| 3346 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, | 3346 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, |
| 3347 | PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE, | ||
| 3348 | quirk_apple_wait_for_thunderbolt); | ||
| 3349 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, | ||
| 3347 | PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE, | 3350 | PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE, |
| 3348 | quirk_apple_wait_for_thunderbolt); | 3351 | quirk_apple_wait_for_thunderbolt); |
| 3349 | #endif | 3352 | #endif |
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index d1ef7acf6930..f9357e09e9b3 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c | |||
| @@ -40,6 +40,7 @@ static void pci_destroy_dev(struct pci_dev *dev) | |||
| 40 | list_del(&dev->bus_list); | 40 | list_del(&dev->bus_list); |
| 41 | up_write(&pci_bus_sem); | 41 | up_write(&pci_bus_sem); |
| 42 | 42 | ||
| 43 | pci_bridge_d3_device_removed(dev); | ||
| 43 | pci_free_resources(dev); | 44 | pci_free_resources(dev); |
| 44 | put_device(&dev->dev); | 45 | put_device(&dev->dev); |
| 45 | } | 46 | } |
| @@ -96,8 +97,6 @@ static void pci_remove_bus_device(struct pci_dev *dev) | |||
| 96 | dev->subordinate = NULL; | 97 | dev->subordinate = NULL; |
| 97 | } | 98 | } |
| 98 | 99 | ||
| 99 | pci_bridge_d3_device_removed(dev); | ||
| 100 | |||
| 101 | pci_destroy_dev(dev); | 100 | pci_destroy_dev(dev); |
| 102 | } | 101 | } |
| 103 | 102 | ||
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 489ea1098c96..69b5e811ea2b 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
| @@ -977,7 +977,7 @@ static int pcmcia_bus_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
| 977 | 977 | ||
| 978 | /************************ runtime PM support ***************************/ | 978 | /************************ runtime PM support ***************************/ |
| 979 | 979 | ||
| 980 | static int pcmcia_dev_suspend(struct device *dev, pm_message_t state); | 980 | static int pcmcia_dev_suspend(struct device *dev); |
| 981 | static int pcmcia_dev_resume(struct device *dev); | 981 | static int pcmcia_dev_resume(struct device *dev); |
| 982 | 982 | ||
| 983 | static int runtime_suspend(struct device *dev) | 983 | static int runtime_suspend(struct device *dev) |
| @@ -985,7 +985,7 @@ static int runtime_suspend(struct device *dev) | |||
| 985 | int rc; | 985 | int rc; |
| 986 | 986 | ||
| 987 | device_lock(dev); | 987 | device_lock(dev); |
| 988 | rc = pcmcia_dev_suspend(dev, PMSG_SUSPEND); | 988 | rc = pcmcia_dev_suspend(dev); |
| 989 | device_unlock(dev); | 989 | device_unlock(dev); |
| 990 | return rc; | 990 | return rc; |
| 991 | } | 991 | } |
| @@ -1135,7 +1135,7 @@ ATTRIBUTE_GROUPS(pcmcia_dev); | |||
| 1135 | 1135 | ||
| 1136 | /* PM support, also needed for reset */ | 1136 | /* PM support, also needed for reset */ |
| 1137 | 1137 | ||
| 1138 | static int pcmcia_dev_suspend(struct device *dev, pm_message_t state) | 1138 | static int pcmcia_dev_suspend(struct device *dev) |
| 1139 | { | 1139 | { |
| 1140 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); | 1140 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); |
| 1141 | struct pcmcia_driver *p_drv = NULL; | 1141 | struct pcmcia_driver *p_drv = NULL; |
| @@ -1410,6 +1410,9 @@ static struct class_interface pcmcia_bus_interface __refdata = { | |||
| 1410 | .remove_dev = &pcmcia_bus_remove_socket, | 1410 | .remove_dev = &pcmcia_bus_remove_socket, |
| 1411 | }; | 1411 | }; |
| 1412 | 1412 | ||
| 1413 | static const struct dev_pm_ops pcmcia_bus_pm_ops = { | ||
| 1414 | SET_SYSTEM_SLEEP_PM_OPS(pcmcia_dev_suspend, pcmcia_dev_resume) | ||
| 1415 | }; | ||
| 1413 | 1416 | ||
| 1414 | struct bus_type pcmcia_bus_type = { | 1417 | struct bus_type pcmcia_bus_type = { |
| 1415 | .name = "pcmcia", | 1418 | .name = "pcmcia", |
| @@ -1418,8 +1421,7 @@ struct bus_type pcmcia_bus_type = { | |||
| 1418 | .dev_groups = pcmcia_dev_groups, | 1421 | .dev_groups = pcmcia_dev_groups, |
| 1419 | .probe = pcmcia_device_probe, | 1422 | .probe = pcmcia_device_probe, |
| 1420 | .remove = pcmcia_device_remove, | 1423 | .remove = pcmcia_device_remove, |
| 1421 | .suspend = pcmcia_dev_suspend, | 1424 | .pm = &pcmcia_bus_pm_ops, |
| 1422 | .resume = pcmcia_dev_resume, | ||
| 1423 | }; | 1425 | }; |
| 1424 | 1426 | ||
| 1425 | 1427 | ||
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c index 483f919e0d2e..91b5f5724cba 100644 --- a/drivers/pcmcia/pxa2xx_base.c +++ b/drivers/pcmcia/pxa2xx_base.c | |||
| @@ -214,9 +214,8 @@ pxa2xx_pcmcia_frequency_change(struct soc_pcmcia_socket *skt, | |||
| 214 | } | 214 | } |
| 215 | #endif | 215 | #endif |
| 216 | 216 | ||
| 217 | void pxa2xx_configure_sockets(struct device *dev) | 217 | void pxa2xx_configure_sockets(struct device *dev, struct pcmcia_low_level *ops) |
| 218 | { | 218 | { |
| 219 | struct pcmcia_low_level *ops = dev->platform_data; | ||
| 220 | /* | 219 | /* |
| 221 | * We have at least one socket, so set MECR:CIT | 220 | * We have at least one socket, so set MECR:CIT |
| 222 | * (Card Is There) | 221 | * (Card Is There) |
| @@ -322,7 +321,7 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev) | |||
| 322 | goto err1; | 321 | goto err1; |
| 323 | } | 322 | } |
| 324 | 323 | ||
| 325 | pxa2xx_configure_sockets(&dev->dev); | 324 | pxa2xx_configure_sockets(&dev->dev, ops); |
| 326 | dev_set_drvdata(&dev->dev, sinfo); | 325 | dev_set_drvdata(&dev->dev, sinfo); |
| 327 | 326 | ||
| 328 | return 0; | 327 | return 0; |
| @@ -348,7 +347,9 @@ static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev) | |||
| 348 | 347 | ||
| 349 | static int pxa2xx_drv_pcmcia_resume(struct device *dev) | 348 | static int pxa2xx_drv_pcmcia_resume(struct device *dev) |
| 350 | { | 349 | { |
| 351 | pxa2xx_configure_sockets(dev); | 350 | struct pcmcia_low_level *ops = (struct pcmcia_low_level *)dev->platform_data; |
| 351 | |||
| 352 | pxa2xx_configure_sockets(dev, ops); | ||
| 352 | return 0; | 353 | return 0; |
| 353 | } | 354 | } |
| 354 | 355 | ||
diff --git a/drivers/pcmcia/pxa2xx_base.h b/drivers/pcmcia/pxa2xx_base.h index b609b45469ed..e58c7a415418 100644 --- a/drivers/pcmcia/pxa2xx_base.h +++ b/drivers/pcmcia/pxa2xx_base.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | int pxa2xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt); | 1 | int pxa2xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt); |
| 2 | void pxa2xx_drv_pcmcia_ops(struct pcmcia_low_level *ops); | 2 | void pxa2xx_drv_pcmcia_ops(struct pcmcia_low_level *ops); |
| 3 | void pxa2xx_configure_sockets(struct device *dev); | 3 | void pxa2xx_configure_sockets(struct device *dev, struct pcmcia_low_level *ops); |
| 4 | 4 | ||
diff --git a/drivers/pcmcia/sa1111_badge4.c b/drivers/pcmcia/sa1111_badge4.c index 12f0dd091477..2f490930430d 100644 --- a/drivers/pcmcia/sa1111_badge4.c +++ b/drivers/pcmcia/sa1111_badge4.c | |||
| @@ -134,20 +134,14 @@ static struct pcmcia_low_level badge4_pcmcia_ops = { | |||
| 134 | 134 | ||
| 135 | int pcmcia_badge4_init(struct sa1111_dev *dev) | 135 | int pcmcia_badge4_init(struct sa1111_dev *dev) |
| 136 | { | 136 | { |
| 137 | int ret = -ENODEV; | 137 | printk(KERN_INFO |
| 138 | 138 | "%s: badge4_pcmvcc=%d, badge4_pcmvpp=%d, badge4_cfvcc=%d\n", | |
| 139 | if (machine_is_badge4()) { | 139 | __func__, |
| 140 | printk(KERN_INFO | 140 | badge4_pcmvcc, badge4_pcmvpp, badge4_cfvcc); |
| 141 | "%s: badge4_pcmvcc=%d, badge4_pcmvpp=%d, badge4_cfvcc=%d\n", | 141 | |
| 142 | __func__, | 142 | sa11xx_drv_pcmcia_ops(&badge4_pcmcia_ops); |
| 143 | badge4_pcmvcc, badge4_pcmvpp, badge4_cfvcc); | 143 | return sa1111_pcmcia_add(dev, &badge4_pcmcia_ops, |
| 144 | 144 | sa11xx_drv_pcmcia_add_one); | |
| 145 | sa11xx_drv_pcmcia_ops(&badge4_pcmcia_ops); | ||
| 146 | ret = sa1111_pcmcia_add(dev, &badge4_pcmcia_ops, | ||
| 147 | sa11xx_drv_pcmcia_add_one); | ||
| 148 | } | ||
| 149 | |||
| 150 | return ret; | ||
| 151 | } | 145 | } |
| 152 | 146 | ||
| 153 | static int __init pcmv_setup(char *s) | 147 | static int __init pcmv_setup(char *s) |
diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c index a1531feb8460..3d95dffcff7a 100644 --- a/drivers/pcmcia/sa1111_generic.c +++ b/drivers/pcmcia/sa1111_generic.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | #include <mach/hardware.h> | 19 | #include <mach/hardware.h> |
| 20 | #include <asm/hardware/sa1111.h> | 20 | #include <asm/hardware/sa1111.h> |
| 21 | #include <asm/mach-types.h> | ||
| 21 | #include <asm/irq.h> | 22 | #include <asm/irq.h> |
| 22 | 23 | ||
| 23 | #include "sa1111_generic.h" | 24 | #include "sa1111_generic.h" |
| @@ -203,19 +204,30 @@ static int pcmcia_probe(struct sa1111_dev *dev) | |||
| 203 | sa1111_writel(PCSSR_S0_SLEEP | PCSSR_S1_SLEEP, base + PCSSR); | 204 | sa1111_writel(PCSSR_S0_SLEEP | PCSSR_S1_SLEEP, base + PCSSR); |
| 204 | sa1111_writel(PCCR_S0_FLT | PCCR_S1_FLT, base + PCCR); | 205 | sa1111_writel(PCCR_S0_FLT | PCCR_S1_FLT, base + PCCR); |
| 205 | 206 | ||
| 207 | ret = -ENODEV; | ||
| 206 | #ifdef CONFIG_SA1100_BADGE4 | 208 | #ifdef CONFIG_SA1100_BADGE4 |
| 207 | pcmcia_badge4_init(dev); | 209 | if (machine_is_badge4()) |
| 210 | ret = pcmcia_badge4_init(dev); | ||
| 208 | #endif | 211 | #endif |
| 209 | #ifdef CONFIG_SA1100_JORNADA720 | 212 | #ifdef CONFIG_SA1100_JORNADA720 |
| 210 | pcmcia_jornada720_init(dev); | 213 | if (machine_is_jornada720()) |
| 214 | ret = pcmcia_jornada720_init(dev); | ||
| 211 | #endif | 215 | #endif |
| 212 | #ifdef CONFIG_ARCH_LUBBOCK | 216 | #ifdef CONFIG_ARCH_LUBBOCK |
| 213 | pcmcia_lubbock_init(dev); | 217 | if (machine_is_lubbock()) |
| 218 | ret = pcmcia_lubbock_init(dev); | ||
| 214 | #endif | 219 | #endif |
| 215 | #ifdef CONFIG_ASSABET_NEPONSET | 220 | #ifdef CONFIG_ASSABET_NEPONSET |
| 216 | pcmcia_neponset_init(dev); | 221 | if (machine_is_assabet()) |
| 222 | ret = pcmcia_neponset_init(dev); | ||
| 217 | #endif | 223 | #endif |
| 218 | return 0; | 224 | |
| 225 | if (ret) { | ||
| 226 | release_mem_region(dev->res.start, 512); | ||
| 227 | sa1111_disable_device(dev); | ||
| 228 | } | ||
| 229 | |||
| 230 | return ret; | ||
| 219 | } | 231 | } |
| 220 | 232 | ||
| 221 | static int pcmcia_remove(struct sa1111_dev *dev) | 233 | static int pcmcia_remove(struct sa1111_dev *dev) |
diff --git a/drivers/pcmcia/sa1111_jornada720.c b/drivers/pcmcia/sa1111_jornada720.c index c2c30580c83f..480a3ede27c8 100644 --- a/drivers/pcmcia/sa1111_jornada720.c +++ b/drivers/pcmcia/sa1111_jornada720.c | |||
| @@ -94,22 +94,17 @@ static struct pcmcia_low_level jornada720_pcmcia_ops = { | |||
| 94 | 94 | ||
| 95 | int pcmcia_jornada720_init(struct sa1111_dev *sadev) | 95 | int pcmcia_jornada720_init(struct sa1111_dev *sadev) |
| 96 | { | 96 | { |
| 97 | int ret = -ENODEV; | 97 | unsigned int pin = GPIO_A0 | GPIO_A1 | GPIO_A2 | GPIO_A3; |
| 98 | 98 | ||
| 99 | if (machine_is_jornada720()) { | 99 | /* Fixme: why messing around with SA11x0's GPIO1? */ |
| 100 | unsigned int pin = GPIO_A0 | GPIO_A1 | GPIO_A2 | GPIO_A3; | 100 | GRER |= 0x00000002; |
| 101 | 101 | ||
| 102 | GRER |= 0x00000002; | 102 | /* Set GPIO_A<3:1> to be outputs for PCMCIA/CF power controller: */ |
| 103 | sa1111_set_io_dir(sadev, pin, 0, 0); | ||
| 104 | sa1111_set_io(sadev, pin, 0); | ||
| 105 | sa1111_set_sleep_io(sadev, pin, 0); | ||
| 103 | 106 | ||
| 104 | /* Set GPIO_A<3:1> to be outputs for PCMCIA/CF power controller: */ | 107 | sa11xx_drv_pcmcia_ops(&jornada720_pcmcia_ops); |
| 105 | sa1111_set_io_dir(sadev, pin, 0, 0); | 108 | return sa1111_pcmcia_add(sadev, &jornada720_pcmcia_ops, |
| 106 | sa1111_set_io(sadev, pin, 0); | 109 | sa11xx_drv_pcmcia_add_one); |
| 107 | sa1111_set_sleep_io(sadev, pin, 0); | ||
| 108 | |||
| 109 | sa11xx_drv_pcmcia_ops(&jornada720_pcmcia_ops); | ||
| 110 | ret = sa1111_pcmcia_add(sadev, &jornada720_pcmcia_ops, | ||
| 111 | sa11xx_drv_pcmcia_add_one); | ||
| 112 | } | ||
| 113 | |||
| 114 | return ret; | ||
| 115 | } | 110 | } |
diff --git a/drivers/pcmcia/sa1111_lubbock.c b/drivers/pcmcia/sa1111_lubbock.c index c5caf5790451..e741f499c875 100644 --- a/drivers/pcmcia/sa1111_lubbock.c +++ b/drivers/pcmcia/sa1111_lubbock.c | |||
| @@ -210,27 +210,21 @@ static struct pcmcia_low_level lubbock_pcmcia_ops = { | |||
| 210 | 210 | ||
| 211 | int pcmcia_lubbock_init(struct sa1111_dev *sadev) | 211 | int pcmcia_lubbock_init(struct sa1111_dev *sadev) |
| 212 | { | 212 | { |
| 213 | int ret = -ENODEV; | 213 | /* |
| 214 | 214 | * Set GPIO_A<3:0> to be outputs for the MAX1600, | |
| 215 | if (machine_is_lubbock()) { | 215 | * and switch to standby mode. |
| 216 | /* | 216 | */ |
| 217 | * Set GPIO_A<3:0> to be outputs for the MAX1600, | 217 | sa1111_set_io_dir(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0, 0); |
| 218 | * and switch to standby mode. | 218 | sa1111_set_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); |
| 219 | */ | 219 | sa1111_set_sleep_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); |
| 220 | sa1111_set_io_dir(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0, 0); | ||
| 221 | sa1111_set_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); | ||
| 222 | sa1111_set_sleep_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); | ||
| 223 | |||
| 224 | /* Set CF Socket 1 power to standby mode. */ | ||
| 225 | lubbock_set_misc_wr((1 << 15) | (1 << 14), 0); | ||
| 226 | 220 | ||
| 227 | pxa2xx_drv_pcmcia_ops(&lubbock_pcmcia_ops); | 221 | /* Set CF Socket 1 power to standby mode. */ |
| 228 | pxa2xx_configure_sockets(&sadev->dev); | 222 | lubbock_set_misc_wr((1 << 15) | (1 << 14), 0); |
| 229 | ret = sa1111_pcmcia_add(sadev, &lubbock_pcmcia_ops, | ||
| 230 | pxa2xx_drv_pcmcia_add_one); | ||
| 231 | } | ||
| 232 | 223 | ||
| 233 | return ret; | 224 | pxa2xx_drv_pcmcia_ops(&lubbock_pcmcia_ops); |
| 225 | pxa2xx_configure_sockets(&sadev->dev, &lubbock_pcmcia_ops); | ||
| 226 | return sa1111_pcmcia_add(sadev, &lubbock_pcmcia_ops, | ||
| 227 | pxa2xx_drv_pcmcia_add_one); | ||
| 234 | } | 228 | } |
| 235 | 229 | ||
| 236 | MODULE_LICENSE("GPL"); | 230 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/pcmcia/sa1111_neponset.c b/drivers/pcmcia/sa1111_neponset.c index 1d78739c4c07..019c395eb4bf 100644 --- a/drivers/pcmcia/sa1111_neponset.c +++ b/drivers/pcmcia/sa1111_neponset.c | |||
| @@ -110,20 +110,14 @@ static struct pcmcia_low_level neponset_pcmcia_ops = { | |||
| 110 | 110 | ||
| 111 | int pcmcia_neponset_init(struct sa1111_dev *sadev) | 111 | int pcmcia_neponset_init(struct sa1111_dev *sadev) |
| 112 | { | 112 | { |
| 113 | int ret = -ENODEV; | 113 | /* |
| 114 | 114 | * Set GPIO_A<3:0> to be outputs for the MAX1600, | |
| 115 | if (machine_is_assabet()) { | 115 | * and switch to standby mode. |
| 116 | /* | 116 | */ |
| 117 | * Set GPIO_A<3:0> to be outputs for the MAX1600, | 117 | sa1111_set_io_dir(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0, 0); |
| 118 | * and switch to standby mode. | 118 | sa1111_set_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); |
| 119 | */ | 119 | sa1111_set_sleep_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); |
| 120 | sa1111_set_io_dir(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0, 0); | 120 | sa11xx_drv_pcmcia_ops(&neponset_pcmcia_ops); |
| 121 | sa1111_set_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); | 121 | return sa1111_pcmcia_add(sadev, &neponset_pcmcia_ops, |
| 122 | sa1111_set_sleep_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); | 122 | sa11xx_drv_pcmcia_add_one); |
| 123 | sa11xx_drv_pcmcia_ops(&neponset_pcmcia_ops); | ||
| 124 | ret = sa1111_pcmcia_add(sadev, &neponset_pcmcia_ops, | ||
| 125 | sa11xx_drv_pcmcia_add_one); | ||
| 126 | } | ||
| 127 | |||
| 128 | return ret; | ||
| 129 | } | 123 | } |
diff --git a/drivers/pcmcia/sa11xx_base.c b/drivers/pcmcia/sa11xx_base.c index 9f6ec87b9f9e..48140ac73ed6 100644 --- a/drivers/pcmcia/sa11xx_base.c +++ b/drivers/pcmcia/sa11xx_base.c | |||
| @@ -144,19 +144,19 @@ static int | |||
| 144 | sa1100_pcmcia_show_timing(struct soc_pcmcia_socket *skt, char *buf) | 144 | sa1100_pcmcia_show_timing(struct soc_pcmcia_socket *skt, char *buf) |
| 145 | { | 145 | { |
| 146 | struct soc_pcmcia_timing timing; | 146 | struct soc_pcmcia_timing timing; |
| 147 | unsigned int clock = clk_get_rate(skt->clk); | 147 | unsigned int clock = clk_get_rate(skt->clk) / 1000; |
| 148 | unsigned long mecr = MECR; | 148 | unsigned long mecr = MECR; |
| 149 | char *p = buf; | 149 | char *p = buf; |
| 150 | 150 | ||
| 151 | soc_common_pcmcia_get_timing(skt, &timing); | 151 | soc_common_pcmcia_get_timing(skt, &timing); |
| 152 | 152 | ||
| 153 | p+=sprintf(p, "I/O : %u (%u)\n", timing.io, | 153 | p+=sprintf(p, "I/O : %uns (%uns)\n", timing.io, |
| 154 | sa1100_pcmcia_cmd_time(clock, MECR_BSIO_GET(mecr, skt->nr))); | 154 | sa1100_pcmcia_cmd_time(clock, MECR_BSIO_GET(mecr, skt->nr))); |
| 155 | 155 | ||
| 156 | p+=sprintf(p, "attribute: %u (%u)\n", timing.attr, | 156 | p+=sprintf(p, "attribute: %uns (%uns)\n", timing.attr, |
| 157 | sa1100_pcmcia_cmd_time(clock, MECR_BSA_GET(mecr, skt->nr))); | 157 | sa1100_pcmcia_cmd_time(clock, MECR_BSA_GET(mecr, skt->nr))); |
| 158 | 158 | ||
| 159 | p+=sprintf(p, "common : %u (%u)\n", timing.mem, | 159 | p+=sprintf(p, "common : %uns (%uns)\n", timing.mem, |
| 160 | sa1100_pcmcia_cmd_time(clock, MECR_BSM_GET(mecr, skt->nr))); | 160 | sa1100_pcmcia_cmd_time(clock, MECR_BSM_GET(mecr, skt->nr))); |
| 161 | 161 | ||
| 162 | return p - buf; | 162 | return p - buf; |
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c index eed5e9c05353..d5ca760c4eb2 100644 --- a/drivers/pcmcia/soc_common.c +++ b/drivers/pcmcia/soc_common.c | |||
| @@ -235,7 +235,7 @@ static unsigned int soc_common_pcmcia_skt_state(struct soc_pcmcia_socket *skt) | |||
| 235 | stat |= skt->cs_state.Vcc ? SS_POWERON : 0; | 235 | stat |= skt->cs_state.Vcc ? SS_POWERON : 0; |
| 236 | 236 | ||
| 237 | if (skt->cs_state.flags & SS_IOCARD) | 237 | if (skt->cs_state.flags & SS_IOCARD) |
| 238 | stat |= state.bvd1 ? SS_STSCHG : 0; | 238 | stat |= state.bvd1 ? 0 : SS_STSCHG; |
| 239 | else { | 239 | else { |
| 240 | if (state.bvd1 == 0) | 240 | if (state.bvd1 == 0) |
| 241 | stat |= SS_BATDEAD; | 241 | stat |= SS_BATDEAD; |
diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index c494613c1909..f5e1008a223d 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c | |||
| @@ -925,6 +925,7 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) | |||
| 925 | if (i > 0 && spi != using_spi) { | 925 | if (i > 0 && spi != using_spi) { |
| 926 | pr_err("PPI/SPI IRQ type mismatch for %s!\n", | 926 | pr_err("PPI/SPI IRQ type mismatch for %s!\n", |
| 927 | dn->name); | 927 | dn->name); |
| 928 | of_node_put(dn); | ||
| 928 | kfree(irqs); | 929 | kfree(irqs); |
| 929 | return -EINVAL; | 930 | return -EINVAL; |
| 930 | } | 931 | } |
| @@ -969,7 +970,7 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) | |||
| 969 | if (cpumask_weight(&pmu->supported_cpus) == 0) { | 970 | if (cpumask_weight(&pmu->supported_cpus) == 0) { |
| 970 | int irq = platform_get_irq(pdev, 0); | 971 | int irq = platform_get_irq(pdev, 0); |
| 971 | 972 | ||
| 972 | if (irq_is_percpu(irq)) { | 973 | if (irq >= 0 && irq_is_percpu(irq)) { |
| 973 | /* If using PPIs, check the affinity of the partition */ | 974 | /* If using PPIs, check the affinity of the partition */ |
| 974 | int ret; | 975 | int ret; |
| 975 | 976 | ||
diff --git a/drivers/phy/phy-brcm-sata.c b/drivers/phy/phy-brcm-sata.c index 18d662610075..8ffc44afdb75 100644 --- a/drivers/phy/phy-brcm-sata.c +++ b/drivers/phy/phy-brcm-sata.c | |||
| @@ -367,7 +367,7 @@ static int brcm_sata_phy_init(struct phy *phy) | |||
| 367 | rc = -ENODEV; | 367 | rc = -ENODEV; |
| 368 | }; | 368 | }; |
| 369 | 369 | ||
| 370 | return 0; | 370 | return rc; |
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | static const struct phy_ops phy_ops = { | 373 | static const struct phy_ops phy_ops = { |
diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c index 0a45bc6088ae..8c7eb335622e 100644 --- a/drivers/phy/phy-sun4i-usb.c +++ b/drivers/phy/phy-sun4i-usb.c | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | #include <linux/power_supply.h> | 40 | #include <linux/power_supply.h> |
| 41 | #include <linux/regulator/consumer.h> | 41 | #include <linux/regulator/consumer.h> |
| 42 | #include <linux/reset.h> | 42 | #include <linux/reset.h> |
| 43 | #include <linux/usb/of.h> | ||
| 43 | #include <linux/workqueue.h> | 44 | #include <linux/workqueue.h> |
| 44 | 45 | ||
| 45 | #define REG_ISCR 0x00 | 46 | #define REG_ISCR 0x00 |
| @@ -110,6 +111,7 @@ struct sun4i_usb_phy_cfg { | |||
| 110 | struct sun4i_usb_phy_data { | 111 | struct sun4i_usb_phy_data { |
| 111 | void __iomem *base; | 112 | void __iomem *base; |
| 112 | const struct sun4i_usb_phy_cfg *cfg; | 113 | const struct sun4i_usb_phy_cfg *cfg; |
| 114 | enum usb_dr_mode dr_mode; | ||
| 113 | struct mutex mutex; | 115 | struct mutex mutex; |
| 114 | struct sun4i_usb_phy { | 116 | struct sun4i_usb_phy { |
| 115 | struct phy *phy; | 117 | struct phy *phy; |
| @@ -120,6 +122,7 @@ struct sun4i_usb_phy_data { | |||
| 120 | bool regulator_on; | 122 | bool regulator_on; |
| 121 | int index; | 123 | int index; |
| 122 | } phys[MAX_PHYS]; | 124 | } phys[MAX_PHYS]; |
| 125 | int first_phy; | ||
| 123 | /* phy0 / otg related variables */ | 126 | /* phy0 / otg related variables */ |
| 124 | struct extcon_dev *extcon; | 127 | struct extcon_dev *extcon; |
| 125 | bool phy0_init; | 128 | bool phy0_init; |
| @@ -285,16 +288,10 @@ static int sun4i_usb_phy_init(struct phy *_phy) | |||
| 285 | sun4i_usb_phy0_update_iscr(_phy, 0, ISCR_DPDM_PULLUP_EN); | 288 | sun4i_usb_phy0_update_iscr(_phy, 0, ISCR_DPDM_PULLUP_EN); |
| 286 | sun4i_usb_phy0_update_iscr(_phy, 0, ISCR_ID_PULLUP_EN); | 289 | sun4i_usb_phy0_update_iscr(_phy, 0, ISCR_ID_PULLUP_EN); |
| 287 | 290 | ||
| 288 | if (data->id_det_gpio) { | 291 | /* Force ISCR and cable state updates */ |
| 289 | /* OTG mode, force ISCR and cable state updates */ | 292 | data->id_det = -1; |
| 290 | data->id_det = -1; | 293 | data->vbus_det = -1; |
| 291 | data->vbus_det = -1; | 294 | queue_delayed_work(system_wq, &data->detect, 0); |
| 292 | queue_delayed_work(system_wq, &data->detect, 0); | ||
| 293 | } else { | ||
| 294 | /* Host only mode */ | ||
| 295 | sun4i_usb_phy0_set_id_detect(_phy, 0); | ||
| 296 | sun4i_usb_phy0_set_vbus_detect(_phy, 1); | ||
| 297 | } | ||
| 298 | } | 295 | } |
| 299 | 296 | ||
| 300 | return 0; | 297 | return 0; |
| @@ -319,6 +316,19 @@ static int sun4i_usb_phy_exit(struct phy *_phy) | |||
| 319 | return 0; | 316 | return 0; |
| 320 | } | 317 | } |
| 321 | 318 | ||
| 319 | static int sun4i_usb_phy0_get_id_det(struct sun4i_usb_phy_data *data) | ||
| 320 | { | ||
| 321 | switch (data->dr_mode) { | ||
| 322 | case USB_DR_MODE_OTG: | ||
| 323 | return gpiod_get_value_cansleep(data->id_det_gpio); | ||
| 324 | case USB_DR_MODE_HOST: | ||
| 325 | return 0; | ||
| 326 | case USB_DR_MODE_PERIPHERAL: | ||
| 327 | default: | ||
| 328 | return 1; | ||
| 329 | } | ||
| 330 | } | ||
| 331 | |||
| 322 | static int sun4i_usb_phy0_get_vbus_det(struct sun4i_usb_phy_data *data) | 332 | static int sun4i_usb_phy0_get_vbus_det(struct sun4i_usb_phy_data *data) |
| 323 | { | 333 | { |
| 324 | if (data->vbus_det_gpio) | 334 | if (data->vbus_det_gpio) |
| @@ -432,7 +442,10 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work) | |||
| 432 | struct phy *phy0 = data->phys[0].phy; | 442 | struct phy *phy0 = data->phys[0].phy; |
| 433 | int id_det, vbus_det, id_notify = 0, vbus_notify = 0; | 443 | int id_det, vbus_det, id_notify = 0, vbus_notify = 0; |
| 434 | 444 | ||
| 435 | id_det = gpiod_get_value_cansleep(data->id_det_gpio); | 445 | if (phy0 == NULL) |
| 446 | return; | ||
| 447 | |||
| 448 | id_det = sun4i_usb_phy0_get_id_det(data); | ||
| 436 | vbus_det = sun4i_usb_phy0_get_vbus_det(data); | 449 | vbus_det = sun4i_usb_phy0_get_vbus_det(data); |
| 437 | 450 | ||
| 438 | mutex_lock(&phy0->mutex); | 451 | mutex_lock(&phy0->mutex); |
| @@ -448,7 +461,8 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work) | |||
| 448 | * without vbus detection report vbus low for long enough for | 461 | * without vbus detection report vbus low for long enough for |
| 449 | * the musb-ip to end the current device session. | 462 | * the musb-ip to end the current device session. |
| 450 | */ | 463 | */ |
| 451 | if (!sun4i_usb_phy0_have_vbus_det(data) && id_det == 0) { | 464 | if (data->dr_mode == USB_DR_MODE_OTG && |
| 465 | !sun4i_usb_phy0_have_vbus_det(data) && id_det == 0) { | ||
| 452 | sun4i_usb_phy0_set_vbus_detect(phy0, 0); | 466 | sun4i_usb_phy0_set_vbus_detect(phy0, 0); |
| 453 | msleep(200); | 467 | msleep(200); |
| 454 | sun4i_usb_phy0_set_vbus_detect(phy0, 1); | 468 | sun4i_usb_phy0_set_vbus_detect(phy0, 1); |
| @@ -474,7 +488,8 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work) | |||
| 474 | * without vbus detection report vbus low for long enough to | 488 | * without vbus detection report vbus low for long enough to |
| 475 | * the musb-ip to end the current host session. | 489 | * the musb-ip to end the current host session. |
| 476 | */ | 490 | */ |
| 477 | if (!sun4i_usb_phy0_have_vbus_det(data) && id_det == 1) { | 491 | if (data->dr_mode == USB_DR_MODE_OTG && |
| 492 | !sun4i_usb_phy0_have_vbus_det(data) && id_det == 1) { | ||
| 478 | mutex_lock(&phy0->mutex); | 493 | mutex_lock(&phy0->mutex); |
| 479 | sun4i_usb_phy0_set_vbus_detect(phy0, 0); | 494 | sun4i_usb_phy0_set_vbus_detect(phy0, 0); |
| 480 | msleep(1000); | 495 | msleep(1000); |
| @@ -519,7 +534,8 @@ static struct phy *sun4i_usb_phy_xlate(struct device *dev, | |||
| 519 | { | 534 | { |
| 520 | struct sun4i_usb_phy_data *data = dev_get_drvdata(dev); | 535 | struct sun4i_usb_phy_data *data = dev_get_drvdata(dev); |
| 521 | 536 | ||
| 522 | if (args->args[0] >= data->cfg->num_phys) | 537 | if (args->args[0] < data->first_phy || |
| 538 | args->args[0] >= data->cfg->num_phys) | ||
| 523 | return ERR_PTR(-ENODEV); | 539 | return ERR_PTR(-ENODEV); |
| 524 | 540 | ||
| 525 | return data->phys[args->args[0]].phy; | 541 | return data->phys[args->args[0]].phy; |
| @@ -593,13 +609,17 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev) | |||
| 593 | return -EPROBE_DEFER; | 609 | return -EPROBE_DEFER; |
| 594 | } | 610 | } |
| 595 | 611 | ||
| 596 | /* vbus_det without id_det makes no sense, and is not supported */ | 612 | data->dr_mode = of_usb_get_dr_mode_by_phy(np, 0); |
| 597 | if (sun4i_usb_phy0_have_vbus_det(data) && !data->id_det_gpio) { | 613 | switch (data->dr_mode) { |
| 598 | dev_err(dev, "usb0_id_det missing or invalid\n"); | 614 | case USB_DR_MODE_OTG: |
| 599 | return -ENODEV; | 615 | /* otg without id_det makes no sense, and is not supported */ |
| 600 | } | 616 | if (!data->id_det_gpio) { |
| 601 | 617 | dev_err(dev, "usb0_id_det missing or invalid\n"); | |
| 602 | if (data->id_det_gpio) { | 618 | return -ENODEV; |
| 619 | } | ||
| 620 | /* fall through */ | ||
| 621 | case USB_DR_MODE_HOST: | ||
| 622 | case USB_DR_MODE_PERIPHERAL: | ||
| 603 | data->extcon = devm_extcon_dev_allocate(dev, | 623 | data->extcon = devm_extcon_dev_allocate(dev, |
| 604 | sun4i_usb_phy0_cable); | 624 | sun4i_usb_phy0_cable); |
| 605 | if (IS_ERR(data->extcon)) | 625 | if (IS_ERR(data->extcon)) |
| @@ -610,9 +630,13 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev) | |||
| 610 | dev_err(dev, "failed to register extcon: %d\n", ret); | 630 | dev_err(dev, "failed to register extcon: %d\n", ret); |
| 611 | return ret; | 631 | return ret; |
| 612 | } | 632 | } |
| 633 | break; | ||
| 634 | default: | ||
| 635 | dev_info(dev, "dr_mode unknown, not registering usb phy0\n"); | ||
| 636 | data->first_phy = 1; | ||
| 613 | } | 637 | } |
| 614 | 638 | ||
| 615 | for (i = 0; i < data->cfg->num_phys; i++) { | 639 | for (i = data->first_phy; i < data->cfg->num_phys; i++) { |
| 616 | struct sun4i_usb_phy *phy = data->phys + i; | 640 | struct sun4i_usb_phy *phy = data->phys + i; |
| 617 | char name[16]; | 641 | char name[16]; |
| 618 | 642 | ||
diff --git a/drivers/phy/phy-sun9i-usb.c b/drivers/phy/phy-sun9i-usb.c index ac4f31abefe3..28fce4bce638 100644 --- a/drivers/phy/phy-sun9i-usb.c +++ b/drivers/phy/phy-sun9i-usb.c | |||
| @@ -141,9 +141,9 @@ static int sun9i_usb_phy_probe(struct platform_device *pdev) | |||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | phy->hsic_clk = devm_clk_get(dev, "hsic_12M"); | 143 | phy->hsic_clk = devm_clk_get(dev, "hsic_12M"); |
| 144 | if (IS_ERR(phy->clk)) { | 144 | if (IS_ERR(phy->hsic_clk)) { |
| 145 | dev_err(dev, "failed to get hsic_12M clock\n"); | 145 | dev_err(dev, "failed to get hsic_12M clock\n"); |
| 146 | return PTR_ERR(phy->clk); | 146 | return PTR_ERR(phy->hsic_clk); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | phy->reset = devm_reset_control_get(dev, "hsic"); | 149 | phy->reset = devm_reset_control_get(dev, "hsic"); |
diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c index 5749a4eee746..0fe8fad25e4d 100644 --- a/drivers/pinctrl/intel/pinctrl-cherryview.c +++ b/drivers/pinctrl/intel/pinctrl-cherryview.c | |||
| @@ -1539,12 +1539,11 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq) | |||
| 1539 | offset += range->npins; | 1539 | offset += range->npins; |
| 1540 | } | 1540 | } |
| 1541 | 1541 | ||
| 1542 | /* Mask and clear all interrupts */ | 1542 | /* Clear all interrupts */ |
| 1543 | chv_writel(0, pctrl->regs + CHV_INTMASK); | ||
| 1544 | chv_writel(0xffff, pctrl->regs + CHV_INTSTAT); | 1543 | chv_writel(0xffff, pctrl->regs + CHV_INTSTAT); |
| 1545 | 1544 | ||
| 1546 | ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0, | 1545 | ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0, |
| 1547 | handle_simple_irq, IRQ_TYPE_NONE); | 1546 | handle_bad_irq, IRQ_TYPE_NONE); |
| 1548 | if (ret) { | 1547 | if (ret) { |
| 1549 | dev_err(pctrl->dev, "failed to add IRQ chip\n"); | 1548 | dev_err(pctrl->dev, "failed to add IRQ chip\n"); |
| 1550 | goto fail; | 1549 | goto fail; |
diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c index 7bad200bd67c..55375b1b3cc8 100644 --- a/drivers/pinctrl/pinctrl-pistachio.c +++ b/drivers/pinctrl/pinctrl-pistachio.c | |||
| @@ -809,17 +809,17 @@ static const struct pistachio_pin_group pistachio_groups[] = { | |||
| 809 | PADS_FUNCTION_SELECT2, 12, 0x3), | 809 | PADS_FUNCTION_SELECT2, 12, 0x3), |
| 810 | MFIO_MUX_PIN_GROUP(83, MIPS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG, | 810 | MFIO_MUX_PIN_GROUP(83, MIPS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG, |
| 811 | PADS_FUNCTION_SELECT2, 14, 0x3), | 811 | PADS_FUNCTION_SELECT2, 14, 0x3), |
| 812 | MFIO_MUX_PIN_GROUP(84, SYS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG, | 812 | MFIO_MUX_PIN_GROUP(84, AUDIO_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG, |
| 813 | PADS_FUNCTION_SELECT2, 16, 0x3), | 813 | PADS_FUNCTION_SELECT2, 16, 0x3), |
| 814 | MFIO_MUX_PIN_GROUP(85, WIFI_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG, | 814 | MFIO_MUX_PIN_GROUP(85, RPU_V_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG, |
| 815 | PADS_FUNCTION_SELECT2, 18, 0x3), | 815 | PADS_FUNCTION_SELECT2, 18, 0x3), |
| 816 | MFIO_MUX_PIN_GROUP(86, BT_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG, | 816 | MFIO_MUX_PIN_GROUP(86, RPU_L_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG, |
| 817 | PADS_FUNCTION_SELECT2, 20, 0x3), | 817 | PADS_FUNCTION_SELECT2, 20, 0x3), |
| 818 | MFIO_MUX_PIN_GROUP(87, RPU_V_PLL_LOCK, DREQ2, SOCIF_DEBUG, | 818 | MFIO_MUX_PIN_GROUP(87, SYS_PLL_LOCK, DREQ2, SOCIF_DEBUG, |
| 819 | PADS_FUNCTION_SELECT2, 22, 0x3), | 819 | PADS_FUNCTION_SELECT2, 22, 0x3), |
| 820 | MFIO_MUX_PIN_GROUP(88, RPU_L_PLL_LOCK, DREQ3, SOCIF_DEBUG, | 820 | MFIO_MUX_PIN_GROUP(88, WIFI_PLL_LOCK, DREQ3, SOCIF_DEBUG, |
| 821 | PADS_FUNCTION_SELECT2, 24, 0x3), | 821 | PADS_FUNCTION_SELECT2, 24, 0x3), |
| 822 | MFIO_MUX_PIN_GROUP(89, AUDIO_PLL_LOCK, DREQ4, DREQ5, | 822 | MFIO_MUX_PIN_GROUP(89, BT_PLL_LOCK, DREQ4, DREQ5, |
| 823 | PADS_FUNCTION_SELECT2, 26, 0x3), | 823 | PADS_FUNCTION_SELECT2, 26, 0x3), |
| 824 | PIN_GROUP(TCK, "tck"), | 824 | PIN_GROUP(TCK, "tck"), |
| 825 | PIN_GROUP(TRSTN, "trstn"), | 825 | PIN_GROUP(TRSTN, "trstn"), |
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c index ce483b03a263..f9d661e5c14a 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c +++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c | |||
| @@ -485,12 +485,12 @@ static const struct sunxi_desc_pin sun8i_a23_pins[] = { | |||
| 485 | SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8), | 485 | SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8), |
| 486 | SUNXI_FUNCTION(0x0, "gpio_in"), | 486 | SUNXI_FUNCTION(0x0, "gpio_in"), |
| 487 | SUNXI_FUNCTION(0x1, "gpio_out"), | 487 | SUNXI_FUNCTION(0x1, "gpio_out"), |
| 488 | SUNXI_FUNCTION(0x2, "uart2"), /* RTS */ | 488 | SUNXI_FUNCTION(0x2, "uart1"), /* RTS */ |
| 489 | SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 8)), /* PG_EINT8 */ | 489 | SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 8)), /* PG_EINT8 */ |
| 490 | SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9), | 490 | SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9), |
| 491 | SUNXI_FUNCTION(0x0, "gpio_in"), | 491 | SUNXI_FUNCTION(0x0, "gpio_in"), |
| 492 | SUNXI_FUNCTION(0x1, "gpio_out"), | 492 | SUNXI_FUNCTION(0x1, "gpio_out"), |
| 493 | SUNXI_FUNCTION(0x2, "uart2"), /* CTS */ | 493 | SUNXI_FUNCTION(0x2, "uart1"), /* CTS */ |
| 494 | SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 9)), /* PG_EINT9 */ | 494 | SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 9)), /* PG_EINT9 */ |
| 495 | SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10), | 495 | SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10), |
| 496 | SUNXI_FUNCTION(0x0, "gpio_in"), | 496 | SUNXI_FUNCTION(0x0, "gpio_in"), |
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c index 3040abe6f73a..3131cac2b76f 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c +++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c | |||
| @@ -407,12 +407,12 @@ static const struct sunxi_desc_pin sun8i_a33_pins[] = { | |||
| 407 | SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8), | 407 | SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8), |
| 408 | SUNXI_FUNCTION(0x0, "gpio_in"), | 408 | SUNXI_FUNCTION(0x0, "gpio_in"), |
| 409 | SUNXI_FUNCTION(0x1, "gpio_out"), | 409 | SUNXI_FUNCTION(0x1, "gpio_out"), |
| 410 | SUNXI_FUNCTION(0x2, "uart2"), /* RTS */ | 410 | SUNXI_FUNCTION(0x2, "uart1"), /* RTS */ |
| 411 | SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 8)), /* PG_EINT8 */ | 411 | SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 8)), /* PG_EINT8 */ |
| 412 | SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9), | 412 | SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9), |
| 413 | SUNXI_FUNCTION(0x0, "gpio_in"), | 413 | SUNXI_FUNCTION(0x0, "gpio_in"), |
| 414 | SUNXI_FUNCTION(0x1, "gpio_out"), | 414 | SUNXI_FUNCTION(0x1, "gpio_out"), |
| 415 | SUNXI_FUNCTION(0x2, "uart2"), /* CTS */ | 415 | SUNXI_FUNCTION(0x2, "uart1"), /* CTS */ |
| 416 | SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 9)), /* PG_EINT9 */ | 416 | SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 9)), /* PG_EINT9 */ |
| 417 | SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10), | 417 | SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10), |
| 418 | SUNXI_FUNCTION(0x0, "gpio_in"), | 418 | SUNXI_FUNCTION(0x0, "gpio_in"), |
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c index f99b183d5296..374a8028fec7 100644 --- a/drivers/platform/olpc/olpc-ec.c +++ b/drivers/platform/olpc/olpc-ec.c | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Generic driver for the OLPC Embedded Controller. | 2 | * Generic driver for the OLPC Embedded Controller. |
| 3 | * | 3 | * |
| 4 | * Author: Andres Salomon <dilinger@queued.net> | ||
| 5 | * | ||
| 4 | * Copyright (C) 2011-2012 One Laptop per Child Foundation. | 6 | * Copyright (C) 2011-2012 One Laptop per Child Foundation. |
| 5 | * | 7 | * |
| 6 | * Licensed under the GPL v2 or later. | 8 | * Licensed under the GPL v2 or later. |
| @@ -12,7 +14,7 @@ | |||
| 12 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
| 13 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
| 14 | #include <linux/workqueue.h> | 16 | #include <linux/workqueue.h> |
| 15 | #include <linux/module.h> | 17 | #include <linux/init.h> |
| 16 | #include <linux/list.h> | 18 | #include <linux/list.h> |
| 17 | #include <linux/olpc-ec.h> | 19 | #include <linux/olpc-ec.h> |
| 18 | #include <asm/olpc.h> | 20 | #include <asm/olpc.h> |
| @@ -326,8 +328,4 @@ static int __init olpc_ec_init_module(void) | |||
| 326 | { | 328 | { |
| 327 | return platform_driver_register(&olpc_ec_plat_driver); | 329 | return platform_driver_register(&olpc_ec_plat_driver); |
| 328 | } | 330 | } |
| 329 | |||
| 330 | arch_initcall(olpc_ec_init_module); | 331 | arch_initcall(olpc_ec_init_module); |
| 331 | |||
| 332 | MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>"); | ||
| 333 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/platform/x86/intel_pmic_gpio.c b/drivers/platform/x86/intel_pmic_gpio.c index 63b371d6ee55..91ae58510d92 100644 --- a/drivers/platform/x86/intel_pmic_gpio.c +++ b/drivers/platform/x86/intel_pmic_gpio.c | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | /* Moorestown PMIC GPIO (access through IPC) driver | 1 | /* Moorestown PMIC GPIO (access through IPC) driver |
| 2 | * Copyright (c) 2008 - 2009, Intel Corporation. | 2 | * Copyright (c) 2008 - 2009, Intel Corporation. |
| 3 | * | 3 | * |
| 4 | * Author: Alek Du <alek.du@intel.com> | ||
| 5 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as | 7 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
| @@ -21,7 +23,6 @@ | |||
| 21 | 23 | ||
| 22 | #define pr_fmt(fmt) "%s: " fmt, __func__ | 24 | #define pr_fmt(fmt) "%s: " fmt, __func__ |
| 23 | 25 | ||
| 24 | #include <linux/module.h> | ||
| 25 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
| 26 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
| 27 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
| @@ -322,9 +323,4 @@ static int __init platform_pmic_gpio_init(void) | |||
| 322 | { | 323 | { |
| 323 | return platform_driver_register(&platform_pmic_gpio_driver); | 324 | return platform_driver_register(&platform_pmic_gpio_driver); |
| 324 | } | 325 | } |
| 325 | |||
| 326 | subsys_initcall(platform_pmic_gpio_init); | 326 | subsys_initcall(platform_pmic_gpio_init); |
| 327 | |||
| 328 | MODULE_AUTHOR("Alek Du <alek.du@intel.com>"); | ||
| 329 | MODULE_DESCRIPTION("Intel Moorestown PMIC GPIO driver"); | ||
| 330 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/rapidio/devices/tsi721.c b/drivers/rapidio/devices/tsi721.c index 32f0f014a067..9d19b9a62011 100644 --- a/drivers/rapidio/devices/tsi721.c +++ b/drivers/rapidio/devices/tsi721.c | |||
| @@ -1161,7 +1161,7 @@ static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart, | |||
| 1161 | } else if (ibw_start < (ib_win->rstart + ib_win->size) && | 1161 | } else if (ibw_start < (ib_win->rstart + ib_win->size) && |
| 1162 | (ibw_start + ibw_size) > ib_win->rstart) { | 1162 | (ibw_start + ibw_size) > ib_win->rstart) { |
| 1163 | /* Return error if address translation involved */ | 1163 | /* Return error if address translation involved */ |
| 1164 | if (direct && ib_win->xlat) { | 1164 | if (!direct || ib_win->xlat) { |
| 1165 | ret = -EFAULT; | 1165 | ret = -EFAULT; |
| 1166 | break; | 1166 | break; |
| 1167 | } | 1167 | } |
diff --git a/drivers/regulator/max14577-regulator.c b/drivers/regulator/max14577-regulator.c index b2daa6641417..c9ff26199711 100644 --- a/drivers/regulator/max14577-regulator.c +++ b/drivers/regulator/max14577-regulator.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * max14577.c - Regulator driver for the Maxim 14577/77836 | 2 | * max14577.c - Regulator driver for the Maxim 14577/77836 |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2013,2014 Samsung Electronics | 4 | * Copyright (C) 2013,2014 Samsung Electronics |
| 5 | * Krzysztof Kozlowski <k.kozlowski@samsung.com> | 5 | * Krzysztof Kozlowski <krzk@kernel.org> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
| @@ -331,7 +331,7 @@ static void __exit max14577_regulator_exit(void) | |||
| 331 | } | 331 | } |
| 332 | module_exit(max14577_regulator_exit); | 332 | module_exit(max14577_regulator_exit); |
| 333 | 333 | ||
| 334 | MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski@samsung.com>"); | 334 | MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>"); |
| 335 | MODULE_DESCRIPTION("Maxim 14577/77836 regulator driver"); | 335 | MODULE_DESCRIPTION("Maxim 14577/77836 regulator driver"); |
| 336 | MODULE_LICENSE("GPL"); | 336 | MODULE_LICENSE("GPL"); |
| 337 | MODULE_ALIAS("platform:max14577-regulator"); | 337 | MODULE_ALIAS("platform:max14577-regulator"); |
diff --git a/drivers/regulator/max77693-regulator.c b/drivers/regulator/max77693-regulator.c index de730fd3f8a5..cfbb9512e486 100644 --- a/drivers/regulator/max77693-regulator.c +++ b/drivers/regulator/max77693-regulator.c | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2013-2015 Samsung Electronics | 4 | * Copyright (C) 2013-2015 Samsung Electronics |
| 5 | * Jonghwa Lee <jonghwa3.lee@samsung.com> | 5 | * Jonghwa Lee <jonghwa3.lee@samsung.com> |
| 6 | * Krzysztof Kozlowski <k.kozlowski.k@gmail.com> | 6 | * Krzysztof Kozlowski <krzk@kernel.org> |
| 7 | * | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
| @@ -314,5 +314,5 @@ module_exit(max77693_pmic_cleanup); | |||
| 314 | 314 | ||
| 315 | MODULE_DESCRIPTION("MAXIM 77693/77843 regulator driver"); | 315 | MODULE_DESCRIPTION("MAXIM 77693/77843 regulator driver"); |
| 316 | MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>"); | 316 | MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>"); |
| 317 | MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski.k@gmail.com>"); | 317 | MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>"); |
| 318 | MODULE_LICENSE("GPL"); | 318 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c index 5022fa8d10c6..8ed46a9a55c8 100644 --- a/drivers/regulator/qcom_smd-regulator.c +++ b/drivers/regulator/qcom_smd-regulator.c | |||
| @@ -178,20 +178,21 @@ static const struct regulator_desc pma8084_hfsmps = { | |||
| 178 | static const struct regulator_desc pma8084_ftsmps = { | 178 | static const struct regulator_desc pma8084_ftsmps = { |
| 179 | .linear_ranges = (struct regulator_linear_range[]) { | 179 | .linear_ranges = (struct regulator_linear_range[]) { |
| 180 | REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000), | 180 | REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000), |
| 181 | REGULATOR_LINEAR_RANGE(700000, 185, 339, 10000), | 181 | REGULATOR_LINEAR_RANGE(1280000, 185, 261, 10000), |
| 182 | }, | 182 | }, |
| 183 | .n_linear_ranges = 2, | 183 | .n_linear_ranges = 2, |
| 184 | .n_voltages = 340, | 184 | .n_voltages = 262, |
| 185 | .ops = &rpm_smps_ldo_ops, | 185 | .ops = &rpm_smps_ldo_ops, |
| 186 | }; | 186 | }; |
| 187 | 187 | ||
| 188 | static const struct regulator_desc pma8084_pldo = { | 188 | static const struct regulator_desc pma8084_pldo = { |
| 189 | .linear_ranges = (struct regulator_linear_range[]) { | 189 | .linear_ranges = (struct regulator_linear_range[]) { |
| 190 | REGULATOR_LINEAR_RANGE(750000, 0, 30, 25000), | 190 | REGULATOR_LINEAR_RANGE( 750000, 0, 63, 12500), |
| 191 | REGULATOR_LINEAR_RANGE(1500000, 31, 99, 50000), | 191 | REGULATOR_LINEAR_RANGE(1550000, 64, 126, 25000), |
| 192 | REGULATOR_LINEAR_RANGE(3100000, 127, 163, 50000), | ||
| 192 | }, | 193 | }, |
| 193 | .n_linear_ranges = 2, | 194 | .n_linear_ranges = 3, |
| 194 | .n_voltages = 100, | 195 | .n_voltages = 164, |
| 195 | .ops = &rpm_smps_ldo_ops, | 196 | .ops = &rpm_smps_ldo_ops, |
| 196 | }; | 197 | }; |
| 197 | 198 | ||
| @@ -221,29 +222,30 @@ static const struct regulator_desc pm8x41_hfsmps = { | |||
| 221 | static const struct regulator_desc pm8841_ftsmps = { | 222 | static const struct regulator_desc pm8841_ftsmps = { |
| 222 | .linear_ranges = (struct regulator_linear_range[]) { | 223 | .linear_ranges = (struct regulator_linear_range[]) { |
| 223 | REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000), | 224 | REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000), |
| 224 | REGULATOR_LINEAR_RANGE(700000, 185, 339, 10000), | 225 | REGULATOR_LINEAR_RANGE(1280000, 185, 261, 10000), |
| 225 | }, | 226 | }, |
| 226 | .n_linear_ranges = 2, | 227 | .n_linear_ranges = 2, |
| 227 | .n_voltages = 340, | 228 | .n_voltages = 262, |
| 228 | .ops = &rpm_smps_ldo_ops, | 229 | .ops = &rpm_smps_ldo_ops, |
| 229 | }; | 230 | }; |
| 230 | 231 | ||
| 231 | static const struct regulator_desc pm8941_boost = { | 232 | static const struct regulator_desc pm8941_boost = { |
| 232 | .linear_ranges = (struct regulator_linear_range[]) { | 233 | .linear_ranges = (struct regulator_linear_range[]) { |
| 233 | REGULATOR_LINEAR_RANGE(4000000, 0, 15, 100000), | 234 | REGULATOR_LINEAR_RANGE(4000000, 0, 30, 50000), |
| 234 | }, | 235 | }, |
| 235 | .n_linear_ranges = 1, | 236 | .n_linear_ranges = 1, |
| 236 | .n_voltages = 16, | 237 | .n_voltages = 31, |
| 237 | .ops = &rpm_smps_ldo_ops, | 238 | .ops = &rpm_smps_ldo_ops, |
| 238 | }; | 239 | }; |
| 239 | 240 | ||
| 240 | static const struct regulator_desc pm8941_pldo = { | 241 | static const struct regulator_desc pm8941_pldo = { |
| 241 | .linear_ranges = (struct regulator_linear_range[]) { | 242 | .linear_ranges = (struct regulator_linear_range[]) { |
| 242 | REGULATOR_LINEAR_RANGE( 750000, 0, 30, 25000), | 243 | REGULATOR_LINEAR_RANGE( 750000, 0, 63, 12500), |
| 243 | REGULATOR_LINEAR_RANGE(1500000, 31, 99, 50000), | 244 | REGULATOR_LINEAR_RANGE(1550000, 64, 126, 25000), |
| 245 | REGULATOR_LINEAR_RANGE(3100000, 127, 163, 50000), | ||
| 244 | }, | 246 | }, |
| 245 | .n_linear_ranges = 2, | 247 | .n_linear_ranges = 3, |
| 246 | .n_voltages = 100, | 248 | .n_voltages = 164, |
| 247 | .ops = &rpm_smps_ldo_ops, | 249 | .ops = &rpm_smps_ldo_ops, |
| 248 | }; | 250 | }; |
| 249 | 251 | ||
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 83458f7a2824..6dc96c8dfe75 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c | |||
| @@ -361,8 +361,9 @@ static const char * const snstext[] = { | |||
| 361 | 361 | ||
| 362 | /* Get sense key string or NULL if not available */ | 362 | /* Get sense key string or NULL if not available */ |
| 363 | const char * | 363 | const char * |
| 364 | scsi_sense_key_string(unsigned char key) { | 364 | scsi_sense_key_string(unsigned char key) |
| 365 | if (key <= 0xE) | 365 | { |
| 366 | if (key < ARRAY_SIZE(snstext)) | ||
| 366 | return snstext[key]; | 367 | return snstext[key]; |
| 367 | return NULL; | 368 | return NULL; |
| 368 | } | 369 | } |
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index eaccd651ccda..246456925335 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c | |||
| @@ -246,6 +246,10 @@ static struct { | |||
| 246 | {"IBM", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, | 246 | {"IBM", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, |
| 247 | {"SUN", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, | 247 | {"SUN", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, |
| 248 | {"DELL", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, | 248 | {"DELL", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, |
| 249 | {"STK", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, | ||
| 250 | {"NETAPP", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, | ||
| 251 | {"LSI", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, | ||
| 252 | {"ENGENIO", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, | ||
| 249 | {"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36}, | 253 | {"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36}, |
| 250 | {"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN}, | 254 | {"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN}, |
| 251 | {"SONY", "TSL", NULL, BLIST_FORCELUN}, /* DDS3 & DDS4 autoloaders */ | 255 | {"SONY", "TSL", NULL, BLIST_FORCELUN}, /* DDS3 & DDS4 autoloaders */ |
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index 3f0ff072184b..60b651bfaa01 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c | |||
| @@ -341,22 +341,6 @@ static int do_sas_phy_delete(struct device *dev, void *data) | |||
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | /** | 343 | /** |
| 344 | * is_sas_attached - check if device is SAS attached | ||
| 345 | * @sdev: scsi device to check | ||
| 346 | * | ||
| 347 | * returns true if the device is SAS attached | ||
| 348 | */ | ||
| 349 | int is_sas_attached(struct scsi_device *sdev) | ||
| 350 | { | ||
| 351 | struct Scsi_Host *shost = sdev->host; | ||
| 352 | |||
| 353 | return shost->transportt->host_attrs.ac.class == | ||
| 354 | &sas_host_class.class; | ||
| 355 | } | ||
| 356 | EXPORT_SYMBOL(is_sas_attached); | ||
| 357 | |||
| 358 | |||
| 359 | /** | ||
| 360 | * sas_remove_children - tear down a devices SAS data structures | 344 | * sas_remove_children - tear down a devices SAS data structures |
| 361 | * @dev: device belonging to the sas object | 345 | * @dev: device belonging to the sas object |
| 362 | * | 346 | * |
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 0e8601aa877a..8c9a35c91705 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c | |||
| @@ -587,7 +587,7 @@ static void ses_match_to_enclosure(struct enclosure_device *edev, | |||
| 587 | 587 | ||
| 588 | ses_enclosure_data_process(edev, to_scsi_device(edev->edev.parent), 0); | 588 | ses_enclosure_data_process(edev, to_scsi_device(edev->edev.parent), 0); |
| 589 | 589 | ||
| 590 | if (is_sas_attached(sdev)) | 590 | if (scsi_is_sas_rphy(&sdev->sdev_gendev)) |
| 591 | efd.addr = sas_get_address(sdev); | 591 | efd.addr = sas_get_address(sdev); |
| 592 | 592 | ||
| 593 | if (efd.addr) { | 593 | if (efd.addr) { |
diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c index e3da1a2fdb66..2a9da2e0ea6b 100644 --- a/drivers/scsi/wd719x.c +++ b/drivers/scsi/wd719x.c | |||
| @@ -962,7 +962,7 @@ static void wd719x_pci_remove(struct pci_dev *pdev) | |||
| 962 | scsi_host_put(sh); | 962 | scsi_host_put(sh); |
| 963 | } | 963 | } |
| 964 | 964 | ||
| 965 | static DEFINE_PCI_DEVICE_TABLE(wd719x_pci_table) = { | 965 | static const struct pci_device_id wd719x_pci_table[] = { |
| 966 | { PCI_DEVICE(PCI_VENDOR_ID_WD, 0x3296) }, | 966 | { PCI_DEVICE(PCI_VENDOR_ID_WD, 0x3296) }, |
| 967 | {} | 967 | {} |
| 968 | }; | 968 | }; |
diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c index 823cbc92d1e7..7a37090dabbe 100644 --- a/drivers/spi/spi-img-spfi.c +++ b/drivers/spi/spi-img-spfi.c | |||
| @@ -720,8 +720,6 @@ static int img_spfi_remove(struct platform_device *pdev) | |||
| 720 | clk_disable_unprepare(spfi->sys_clk); | 720 | clk_disable_unprepare(spfi->sys_clk); |
| 721 | } | 721 | } |
| 722 | 722 | ||
| 723 | spi_master_put(master); | ||
| 724 | |||
| 725 | return 0; | 723 | return 0; |
| 726 | } | 724 | } |
| 727 | 725 | ||
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 0be89e052428..899d7a8f0889 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c | |||
| @@ -685,7 +685,6 @@ static int mtk_spi_remove(struct platform_device *pdev) | |||
| 685 | pm_runtime_disable(&pdev->dev); | 685 | pm_runtime_disable(&pdev->dev); |
| 686 | 686 | ||
| 687 | mtk_spi_reset(mdata); | 687 | mtk_spi_reset(mdata); |
| 688 | spi_master_put(master); | ||
| 689 | 688 | ||
| 690 | return 0; | 689 | return 0; |
| 691 | } | 690 | } |
diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c index f3df522db93b..58d2d48e16a5 100644 --- a/drivers/spi/spi-pxa2xx-pci.c +++ b/drivers/spi/spi-pxa2xx-pci.c | |||
| @@ -214,6 +214,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, | |||
| 214 | return PTR_ERR(ssp->clk); | 214 | return PTR_ERR(ssp->clk); |
| 215 | 215 | ||
| 216 | memset(&pi, 0, sizeof(pi)); | 216 | memset(&pi, 0, sizeof(pi)); |
| 217 | pi.fwnode = dev->dev.fwnode; | ||
| 217 | pi.parent = &dev->dev; | 218 | pi.parent = &dev->dev; |
| 218 | pi.name = "pxa2xx-spi"; | 219 | pi.name = "pxa2xx-spi"; |
| 219 | pi.id = ssp->port_id; | 220 | pi.id = ssp->port_id; |
diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c index c338ef1136f6..7f1555621f8e 100644 --- a/drivers/spi/spi-qup.c +++ b/drivers/spi/spi-qup.c | |||
| @@ -1030,7 +1030,6 @@ static int spi_qup_remove(struct platform_device *pdev) | |||
| 1030 | 1030 | ||
| 1031 | pm_runtime_put_noidle(&pdev->dev); | 1031 | pm_runtime_put_noidle(&pdev->dev); |
| 1032 | pm_runtime_disable(&pdev->dev); | 1032 | pm_runtime_disable(&pdev->dev); |
| 1033 | spi_master_put(master); | ||
| 1034 | 1033 | ||
| 1035 | return 0; | 1034 | return 0; |
| 1036 | } | 1035 | } |
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index 0f83ad1d5a58..1de3a772eb7d 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c | |||
| @@ -262,6 +262,9 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p, | |||
| 262 | 262 | ||
| 263 | for (k = 0; k < ARRAY_SIZE(sh_msiof_spi_div_table); k++) { | 263 | for (k = 0; k < ARRAY_SIZE(sh_msiof_spi_div_table); k++) { |
| 264 | brps = DIV_ROUND_UP(div, sh_msiof_spi_div_table[k].div); | 264 | brps = DIV_ROUND_UP(div, sh_msiof_spi_div_table[k].div); |
| 265 | /* SCR_BRDV_DIV_1 is valid only if BRPS is x 1/1 or x 1/2 */ | ||
| 266 | if (sh_msiof_spi_div_table[k].div == 1 && brps > 2) | ||
| 267 | continue; | ||
| 265 | if (brps <= 32) /* max of brdv is 32 */ | 268 | if (brps <= 32) /* max of brdv is 32 */ |
| 266 | break; | 269 | break; |
| 267 | } | 270 | } |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 51ad42fad567..200ca228d885 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
| @@ -960,7 +960,7 @@ static int spi_transfer_one_message(struct spi_master *master, | |||
| 960 | struct spi_transfer *xfer; | 960 | struct spi_transfer *xfer; |
| 961 | bool keep_cs = false; | 961 | bool keep_cs = false; |
| 962 | int ret = 0; | 962 | int ret = 0; |
| 963 | unsigned long ms = 1; | 963 | unsigned long long ms = 1; |
| 964 | struct spi_statistics *statm = &master->statistics; | 964 | struct spi_statistics *statm = &master->statistics; |
| 965 | struct spi_statistics *stats = &msg->spi->statistics; | 965 | struct spi_statistics *stats = &msg->spi->statistics; |
| 966 | 966 | ||
| @@ -991,9 +991,13 @@ static int spi_transfer_one_message(struct spi_master *master, | |||
| 991 | 991 | ||
| 992 | if (ret > 0) { | 992 | if (ret > 0) { |
| 993 | ret = 0; | 993 | ret = 0; |
| 994 | ms = xfer->len * 8 * 1000 / xfer->speed_hz; | 994 | ms = 8LL * 1000LL * xfer->len; |
| 995 | do_div(ms, xfer->speed_hz); | ||
| 995 | ms += ms + 100; /* some tolerance */ | 996 | ms += ms + 100; /* some tolerance */ |
| 996 | 997 | ||
| 998 | if (ms > UINT_MAX) | ||
| 999 | ms = UINT_MAX; | ||
| 1000 | |||
| 997 | ms = wait_for_completion_timeout(&master->xfer_completion, | 1001 | ms = wait_for_completion_timeout(&master->xfer_completion, |
| 998 | msecs_to_jiffies(ms)); | 1002 | msecs_to_jiffies(ms)); |
| 999 | } | 1003 | } |
| @@ -1159,6 +1163,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread) | |||
| 1159 | if (ret < 0) { | 1163 | if (ret < 0) { |
| 1160 | dev_err(&master->dev, "Failed to power device: %d\n", | 1164 | dev_err(&master->dev, "Failed to power device: %d\n", |
| 1161 | ret); | 1165 | ret); |
| 1166 | mutex_unlock(&master->io_mutex); | ||
| 1162 | return; | 1167 | return; |
| 1163 | } | 1168 | } |
| 1164 | } | 1169 | } |
| @@ -1174,6 +1179,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread) | |||
| 1174 | 1179 | ||
| 1175 | if (master->auto_runtime_pm) | 1180 | if (master->auto_runtime_pm) |
| 1176 | pm_runtime_put(master->dev.parent); | 1181 | pm_runtime_put(master->dev.parent); |
| 1182 | mutex_unlock(&master->io_mutex); | ||
| 1177 | return; | 1183 | return; |
| 1178 | } | 1184 | } |
| 1179 | } | 1185 | } |
diff --git a/drivers/staging/comedi/drivers/adv_pci1760.c b/drivers/staging/comedi/drivers/adv_pci1760.c index d7dd1e55e347..9f525ff7290c 100644 --- a/drivers/staging/comedi/drivers/adv_pci1760.c +++ b/drivers/staging/comedi/drivers/adv_pci1760.c | |||
| @@ -196,6 +196,7 @@ static int pci1760_pwm_ns_to_div(unsigned int flags, unsigned int ns) | |||
| 196 | break; | 196 | break; |
| 197 | case CMDF_ROUND_DOWN: | 197 | case CMDF_ROUND_DOWN: |
| 198 | divisor = ns / PCI1760_PWM_TIMEBASE; | 198 | divisor = ns / PCI1760_PWM_TIMEBASE; |
| 199 | break; | ||
| 199 | default: | 200 | default: |
| 200 | return -EINVAL; | 201 | return -EINVAL; |
| 201 | } | 202 | } |
diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index 4ab186669f0c..ec5b9a23494d 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c | |||
| @@ -56,11 +56,6 @@ | |||
| 56 | 56 | ||
| 57 | #define N_CHANS 8 | 57 | #define N_CHANS 8 |
| 58 | 58 | ||
| 59 | enum waveform_state_bits { | ||
| 60 | WAVEFORM_AI_RUNNING, | ||
| 61 | WAVEFORM_AO_RUNNING | ||
| 62 | }; | ||
| 63 | |||
| 64 | /* Data unique to this driver */ | 59 | /* Data unique to this driver */ |
| 65 | struct waveform_private { | 60 | struct waveform_private { |
| 66 | struct timer_list ai_timer; /* timer for AI commands */ | 61 | struct timer_list ai_timer; /* timer for AI commands */ |
| @@ -68,7 +63,6 @@ struct waveform_private { | |||
| 68 | unsigned int wf_amplitude; /* waveform amplitude in microvolts */ | 63 | unsigned int wf_amplitude; /* waveform amplitude in microvolts */ |
| 69 | unsigned int wf_period; /* waveform period in microseconds */ | 64 | unsigned int wf_period; /* waveform period in microseconds */ |
| 70 | unsigned int wf_current; /* current time in waveform period */ | 65 | unsigned int wf_current; /* current time in waveform period */ |
| 71 | unsigned long state_bits; | ||
| 72 | unsigned int ai_scan_period; /* AI scan period in usec */ | 66 | unsigned int ai_scan_period; /* AI scan period in usec */ |
| 73 | unsigned int ai_convert_period; /* AI conversion period in usec */ | 67 | unsigned int ai_convert_period; /* AI conversion period in usec */ |
| 74 | struct timer_list ao_timer; /* timer for AO commands */ | 68 | struct timer_list ao_timer; /* timer for AO commands */ |
| @@ -191,10 +185,6 @@ static void waveform_ai_timer(unsigned long arg) | |||
| 191 | unsigned int nsamples; | 185 | unsigned int nsamples; |
| 192 | unsigned int time_increment; | 186 | unsigned int time_increment; |
| 193 | 187 | ||
| 194 | /* check command is still active */ | ||
| 195 | if (!test_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits)) | ||
| 196 | return; | ||
| 197 | |||
| 198 | now = ktime_to_us(ktime_get()); | 188 | now = ktime_to_us(ktime_get()); |
| 199 | nsamples = comedi_nsamples_left(s, UINT_MAX); | 189 | nsamples = comedi_nsamples_left(s, UINT_MAX); |
| 200 | 190 | ||
| @@ -386,11 +376,6 @@ static int waveform_ai_cmd(struct comedi_device *dev, | |||
| 386 | */ | 376 | */ |
| 387 | devpriv->ai_timer.expires = | 377 | devpriv->ai_timer.expires = |
| 388 | jiffies + usecs_to_jiffies(devpriv->ai_convert_period) + 1; | 378 | jiffies + usecs_to_jiffies(devpriv->ai_convert_period) + 1; |
| 389 | |||
| 390 | /* mark command as active */ | ||
| 391 | smp_mb__before_atomic(); | ||
| 392 | set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits); | ||
| 393 | smp_mb__after_atomic(); | ||
| 394 | add_timer(&devpriv->ai_timer); | 379 | add_timer(&devpriv->ai_timer); |
| 395 | return 0; | 380 | return 0; |
| 396 | } | 381 | } |
| @@ -400,11 +385,12 @@ static int waveform_ai_cancel(struct comedi_device *dev, | |||
| 400 | { | 385 | { |
| 401 | struct waveform_private *devpriv = dev->private; | 386 | struct waveform_private *devpriv = dev->private; |
| 402 | 387 | ||
| 403 | /* mark command as no longer active */ | 388 | if (in_softirq()) { |
| 404 | clear_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits); | 389 | /* Assume we were called from the timer routine itself. */ |
| 405 | smp_mb__after_atomic(); | 390 | del_timer(&devpriv->ai_timer); |
| 406 | /* cannot call del_timer_sync() as may be called from timer routine */ | 391 | } else { |
| 407 | del_timer(&devpriv->ai_timer); | 392 | del_timer_sync(&devpriv->ai_timer); |
| 393 | } | ||
| 408 | return 0; | 394 | return 0; |
| 409 | } | 395 | } |
| 410 | 396 | ||
| @@ -436,10 +422,6 @@ static void waveform_ao_timer(unsigned long arg) | |||
| 436 | u64 scans_since; | 422 | u64 scans_since; |
| 437 | unsigned int scans_avail = 0; | 423 | unsigned int scans_avail = 0; |
| 438 | 424 | ||
| 439 | /* check command is still active */ | ||
| 440 | if (!test_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits)) | ||
| 441 | return; | ||
| 442 | |||
| 443 | /* determine number of scan periods since last time */ | 425 | /* determine number of scan periods since last time */ |
| 444 | now = ktime_to_us(ktime_get()); | 426 | now = ktime_to_us(ktime_get()); |
| 445 | scans_since = now - devpriv->ao_last_scan_time; | 427 | scans_since = now - devpriv->ao_last_scan_time; |
| @@ -518,11 +500,6 @@ static int waveform_ao_inttrig_start(struct comedi_device *dev, | |||
| 518 | devpriv->ao_last_scan_time = ktime_to_us(ktime_get()); | 500 | devpriv->ao_last_scan_time = ktime_to_us(ktime_get()); |
| 519 | devpriv->ao_timer.expires = | 501 | devpriv->ao_timer.expires = |
| 520 | jiffies + usecs_to_jiffies(devpriv->ao_scan_period); | 502 | jiffies + usecs_to_jiffies(devpriv->ao_scan_period); |
| 521 | |||
| 522 | /* mark command as active */ | ||
| 523 | smp_mb__before_atomic(); | ||
| 524 | set_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits); | ||
| 525 | smp_mb__after_atomic(); | ||
| 526 | add_timer(&devpriv->ao_timer); | 503 | add_timer(&devpriv->ao_timer); |
| 527 | 504 | ||
| 528 | return 1; | 505 | return 1; |
| @@ -608,11 +585,12 @@ static int waveform_ao_cancel(struct comedi_device *dev, | |||
| 608 | struct waveform_private *devpriv = dev->private; | 585 | struct waveform_private *devpriv = dev->private; |
| 609 | 586 | ||
| 610 | s->async->inttrig = NULL; | 587 | s->async->inttrig = NULL; |
| 611 | /* mark command as no longer active */ | 588 | if (in_softirq()) { |
| 612 | clear_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits); | 589 | /* Assume we were called from the timer routine itself. */ |
| 613 | smp_mb__after_atomic(); | 590 | del_timer(&devpriv->ao_timer); |
| 614 | /* cannot call del_timer_sync() as may be called from timer routine */ | 591 | } else { |
| 615 | del_timer(&devpriv->ao_timer); | 592 | del_timer_sync(&devpriv->ao_timer); |
| 593 | } | ||
| 616 | return 0; | 594 | return 0; |
| 617 | } | 595 | } |
| 618 | 596 | ||
diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 65daef0c00d5..0f4eb954aa80 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c | |||
| @@ -634,7 +634,7 @@ static const void *daqboard2000_find_boardinfo(struct comedi_device *dev, | |||
| 634 | const struct daq200_boardtype *board; | 634 | const struct daq200_boardtype *board; |
| 635 | int i; | 635 | int i; |
| 636 | 636 | ||
| 637 | if (pcidev->subsystem_device != PCI_VENDOR_ID_IOTECH) | 637 | if (pcidev->subsystem_vendor != PCI_VENDOR_ID_IOTECH) |
| 638 | return NULL; | 638 | return NULL; |
| 639 | 639 | ||
| 640 | for (i = 0; i < ARRAY_SIZE(boardtypes); i++) { | 640 | for (i = 0; i < ARRAY_SIZE(boardtypes); i++) { |
diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 904f637797b6..8bbd93814340 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c | |||
| @@ -588,8 +588,8 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
| 588 | s = &dev->subdevices[0]; | 588 | s = &dev->subdevices[0]; |
| 589 | s->type = COMEDI_SUBD_AI; | 589 | s->type = COMEDI_SUBD_AI; |
| 590 | s->subdev_flags = SDF_READABLE | | 590 | s->subdev_flags = SDF_READABLE | |
| 591 | (it->options[2] == 1) ? SDF_DIFF : | 591 | ((it->options[2] == 1) ? SDF_DIFF : |
| 592 | (it->options[2] == 2) ? SDF_COMMON : SDF_GROUND; | 592 | (it->options[2] == 2) ? SDF_COMMON : SDF_GROUND); |
| 593 | s->n_chan = (it->options[2] == 1) ? 8 : 16; | 593 | s->n_chan = (it->options[2] == 1) ? 8 : 16; |
| 594 | s->maxdata = 0x0fff; | 594 | s->maxdata = 0x0fff; |
| 595 | s->range_table = board->is_pgh ? &dt2811_pgh_ai_ranges | 595 | s->range_table = board->is_pgh ? &dt2811_pgh_ai_ranges |
diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 8dabb19519a5..0f97d7b611d7 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c | |||
| @@ -2772,7 +2772,15 @@ static int ni_ao_inttrig(struct comedi_device *dev, | |||
| 2772 | int i; | 2772 | int i; |
| 2773 | static const int timeout = 1000; | 2773 | static const int timeout = 1000; |
| 2774 | 2774 | ||
| 2775 | if (trig_num != cmd->start_arg) | 2775 | /* |
| 2776 | * Require trig_num == cmd->start_arg when cmd->start_src == TRIG_INT. | ||
| 2777 | * For backwards compatibility, also allow trig_num == 0 when | ||
| 2778 | * cmd->start_src != TRIG_INT (i.e. when cmd->start_src == TRIG_EXT); | ||
| 2779 | * in that case, the internal trigger is being used as a pre-trigger | ||
| 2780 | * before the external trigger. | ||
| 2781 | */ | ||
| 2782 | if (!(trig_num == cmd->start_arg || | ||
| 2783 | (trig_num == 0 && cmd->start_src != TRIG_INT))) | ||
| 2776 | return -EINVAL; | 2784 | return -EINVAL; |
| 2777 | 2785 | ||
| 2778 | /* | 2786 | /* |
| @@ -5480,7 +5488,7 @@ static int ni_E_init(struct comedi_device *dev, | |||
| 5480 | s->maxdata = (devpriv->is_m_series) ? 0xffffffff | 5488 | s->maxdata = (devpriv->is_m_series) ? 0xffffffff |
| 5481 | : 0x00ffffff; | 5489 | : 0x00ffffff; |
| 5482 | s->insn_read = ni_tio_insn_read; | 5490 | s->insn_read = ni_tio_insn_read; |
| 5483 | s->insn_write = ni_tio_insn_read; | 5491 | s->insn_write = ni_tio_insn_write; |
| 5484 | s->insn_config = ni_tio_insn_config; | 5492 | s->insn_config = ni_tio_insn_config; |
| 5485 | #ifdef PCIDMA | 5493 | #ifdef PCIDMA |
| 5486 | if (dev->irq && devpriv->mite) { | 5494 | if (dev->irq && devpriv->mite) { |
diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 170ac980abcb..24c348d2f5bb 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c | |||
| @@ -419,6 +419,7 @@ static ssize_t ad5933_store(struct device *dev, | |||
| 419 | mutex_lock(&indio_dev->mlock); | 419 | mutex_lock(&indio_dev->mlock); |
| 420 | switch ((u32)this_attr->address) { | 420 | switch ((u32)this_attr->address) { |
| 421 | case AD5933_OUT_RANGE: | 421 | case AD5933_OUT_RANGE: |
| 422 | ret = -EINVAL; | ||
| 422 | for (i = 0; i < 4; i++) | 423 | for (i = 0; i < 4; i++) |
| 423 | if (val == st->range_avail[i]) { | 424 | if (val == st->range_avail[i]) { |
| 424 | st->ctrl_hb &= ~AD5933_CTRL_RANGE(0x3); | 425 | st->ctrl_hb &= ~AD5933_CTRL_RANGE(0x3); |
| @@ -426,7 +427,6 @@ static ssize_t ad5933_store(struct device *dev, | |||
| 426 | ret = ad5933_cmd(st, 0); | 427 | ret = ad5933_cmd(st, 0); |
| 427 | break; | 428 | break; |
| 428 | } | 429 | } |
| 429 | ret = -EINVAL; | ||
| 430 | break; | 430 | break; |
| 431 | case AD5933_IN_PGA_GAIN: | 431 | case AD5933_IN_PGA_GAIN: |
| 432 | if (sysfs_streq(buf, "1")) { | 432 | if (sysfs_streq(buf, "1")) { |
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 3664bfd0178b..2c4dc69731e8 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c | |||
| @@ -388,6 +388,7 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, | |||
| 388 | struct inode *inode = NULL; | 388 | struct inode *inode = NULL; |
| 389 | __u64 bits = 0; | 389 | __u64 bits = 0; |
| 390 | int rc = 0; | 390 | int rc = 0; |
| 391 | struct dentry *alias; | ||
| 391 | 392 | ||
| 392 | /* NB 1 request reference will be taken away by ll_intent_lock() | 393 | /* NB 1 request reference will be taken away by ll_intent_lock() |
| 393 | * when I return | 394 | * when I return |
| @@ -412,26 +413,12 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, | |||
| 412 | */ | 413 | */ |
| 413 | } | 414 | } |
| 414 | 415 | ||
| 415 | /* Only hash *de if it is unhashed (new dentry). | 416 | alias = ll_splice_alias(inode, *de); |
| 416 | * Atoimc_open may passing hashed dentries for open. | 417 | if (IS_ERR(alias)) { |
| 417 | */ | 418 | rc = PTR_ERR(alias); |
| 418 | if (d_unhashed(*de)) { | 419 | goto out; |
| 419 | struct dentry *alias; | ||
| 420 | |||
| 421 | alias = ll_splice_alias(inode, *de); | ||
| 422 | if (IS_ERR(alias)) { | ||
| 423 | rc = PTR_ERR(alias); | ||
| 424 | goto out; | ||
| 425 | } | ||
| 426 | *de = alias; | ||
| 427 | } else if (!it_disposition(it, DISP_LOOKUP_NEG) && | ||
| 428 | !it_disposition(it, DISP_OPEN_CREATE)) { | ||
| 429 | /* With DISP_OPEN_CREATE dentry will be | ||
| 430 | * instantiated in ll_create_it. | ||
| 431 | */ | ||
| 432 | LASSERT(!d_inode(*de)); | ||
| 433 | d_instantiate(*de, inode); | ||
| 434 | } | 420 | } |
| 421 | *de = alias; | ||
| 435 | 422 | ||
| 436 | if (!it_disposition(it, DISP_LOOKUP_NEG)) { | 423 | if (!it_disposition(it, DISP_LOOKUP_NEG)) { |
| 437 | /* we have lookup look - unhide dentry */ | 424 | /* we have lookup look - unhide dentry */ |
| @@ -587,6 +574,24 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, | |||
| 587 | dentry, PFID(ll_inode2fid(dir)), dir, file, open_flags, mode, | 574 | dentry, PFID(ll_inode2fid(dir)), dir, file, open_flags, mode, |
| 588 | *opened); | 575 | *opened); |
| 589 | 576 | ||
| 577 | /* Only negative dentries enter here */ | ||
| 578 | LASSERT(!d_inode(dentry)); | ||
| 579 | |||
| 580 | if (!d_in_lookup(dentry)) { | ||
| 581 | /* A valid negative dentry that just passed revalidation, | ||
| 582 | * there's little point to try and open it server-side, | ||
| 583 | * even though there's a minuscle chance it might succeed. | ||
| 584 | * Either way it's a valid race to just return -ENOENT here. | ||
| 585 | */ | ||
| 586 | if (!(open_flags & O_CREAT)) | ||
| 587 | return -ENOENT; | ||
| 588 | |||
| 589 | /* Otherwise we just unhash it to be rehashed afresh via | ||
| 590 | * lookup if necessary | ||
| 591 | */ | ||
| 592 | d_drop(dentry); | ||
| 593 | } | ||
| 594 | |||
| 590 | it = kzalloc(sizeof(*it), GFP_NOFS); | 595 | it = kzalloc(sizeof(*it), GFP_NOFS); |
| 591 | if (!it) | 596 | if (!it) |
| 592 | return -ENOMEM; | 597 | return -ENOMEM; |
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 0b1760cba6e3..78f524fcd214 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c | |||
| @@ -3363,7 +3363,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) | |||
| 3363 | if (!hif_workqueue) { | 3363 | if (!hif_workqueue) { |
| 3364 | netdev_err(vif->ndev, "Failed to create workqueue\n"); | 3364 | netdev_err(vif->ndev, "Failed to create workqueue\n"); |
| 3365 | result = -ENOMEM; | 3365 | result = -ENOMEM; |
| 3366 | goto _fail_mq_; | 3366 | goto _fail_; |
| 3367 | } | 3367 | } |
| 3368 | 3368 | ||
| 3369 | setup_timer(&periodic_rssi, GetPeriodicRSSI, | 3369 | setup_timer(&periodic_rssi, GetPeriodicRSSI, |
| @@ -3391,7 +3391,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) | |||
| 3391 | 3391 | ||
| 3392 | clients_count++; | 3392 | clients_count++; |
| 3393 | 3393 | ||
| 3394 | _fail_mq_: | ||
| 3395 | destroy_workqueue(hif_workqueue); | 3394 | destroy_workqueue(hif_workqueue); |
| 3396 | _fail_: | 3395 | _fail_: |
| 3397 | return result; | 3396 | return result; |
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 3a66255f14fc..32215110d597 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c | |||
| @@ -648,7 +648,7 @@ void wilc1000_wlan_deinit(struct net_device *dev) | |||
| 648 | mutex_unlock(&wl->hif_cs); | 648 | mutex_unlock(&wl->hif_cs); |
| 649 | } | 649 | } |
| 650 | if (&wl->txq_event) | 650 | if (&wl->txq_event) |
| 651 | wait_for_completion(&wl->txq_event); | 651 | complete(&wl->txq_event); |
| 652 | 652 | ||
| 653 | wlan_deinitialize_threads(dev); | 653 | wlan_deinitialize_threads(dev); |
| 654 | deinit_irq(dev); | 654 | deinit_irq(dev); |
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 9092600a1794..2c2e8aca8305 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | |||
| @@ -1191,7 +1191,7 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev, | |||
| 1191 | struct wilc_priv *priv; | 1191 | struct wilc_priv *priv; |
| 1192 | struct wilc_vif *vif; | 1192 | struct wilc_vif *vif; |
| 1193 | u32 i = 0; | 1193 | u32 i = 0; |
| 1194 | u32 associatedsta = 0; | 1194 | u32 associatedsta = ~0; |
| 1195 | u32 inactive_time = 0; | 1195 | u32 inactive_time = 0; |
| 1196 | priv = wiphy_priv(wiphy); | 1196 | priv = wiphy_priv(wiphy); |
| 1197 | vif = netdev_priv(dev); | 1197 | vif = netdev_priv(dev); |
| @@ -1204,7 +1204,7 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev, | |||
| 1204 | } | 1204 | } |
| 1205 | } | 1205 | } |
| 1206 | 1206 | ||
| 1207 | if (associatedsta == -1) { | 1207 | if (associatedsta == ~0) { |
| 1208 | netdev_err(dev, "sta required is not associated\n"); | 1208 | netdev_err(dev, "sta required is not associated\n"); |
| 1209 | return -ENOENT; | 1209 | return -ENOENT; |
| 1210 | } | 1210 | } |
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 3788ed74c9ab..a32b41783b77 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c | |||
| @@ -740,12 +740,22 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, | |||
| 740 | } | 740 | } |
| 741 | 741 | ||
| 742 | /* Bind cpufreq callbacks to thermal cooling device ops */ | 742 | /* Bind cpufreq callbacks to thermal cooling device ops */ |
| 743 | |||
| 743 | static struct thermal_cooling_device_ops cpufreq_cooling_ops = { | 744 | static struct thermal_cooling_device_ops cpufreq_cooling_ops = { |
| 744 | .get_max_state = cpufreq_get_max_state, | 745 | .get_max_state = cpufreq_get_max_state, |
| 745 | .get_cur_state = cpufreq_get_cur_state, | 746 | .get_cur_state = cpufreq_get_cur_state, |
| 746 | .set_cur_state = cpufreq_set_cur_state, | 747 | .set_cur_state = cpufreq_set_cur_state, |
| 747 | }; | 748 | }; |
| 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, | ||
| 757 | }; | ||
| 758 | |||
| 749 | /* Notifier for cpufreq policy change */ | 759 | /* Notifier for cpufreq policy change */ |
| 750 | static struct notifier_block thermal_cpufreq_notifier_block = { | 760 | static struct notifier_block thermal_cpufreq_notifier_block = { |
| 751 | .notifier_call = cpufreq_thermal_notifier, | 761 | .notifier_call = cpufreq_thermal_notifier, |
| @@ -795,6 +805,7 @@ __cpufreq_cooling_register(struct device_node *np, | |||
| 795 | struct cpumask temp_mask; | 805 | struct cpumask temp_mask; |
| 796 | unsigned int freq, i, num_cpus; | 806 | unsigned int freq, i, num_cpus; |
| 797 | int ret; | 807 | int ret; |
| 808 | struct thermal_cooling_device_ops *cooling_ops; | ||
| 798 | 809 | ||
| 799 | cpumask_and(&temp_mask, clip_cpus, cpu_online_mask); | 810 | cpumask_and(&temp_mask, clip_cpus, cpu_online_mask); |
| 800 | policy = cpufreq_cpu_get(cpumask_first(&temp_mask)); | 811 | policy = cpufreq_cpu_get(cpumask_first(&temp_mask)); |
| @@ -850,10 +861,6 @@ __cpufreq_cooling_register(struct device_node *np, | |||
| 850 | cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus); | 861 | cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus); |
| 851 | 862 | ||
| 852 | if (capacitance) { | 863 | if (capacitance) { |
| 853 | cpufreq_cooling_ops.get_requested_power = | ||
| 854 | cpufreq_get_requested_power; | ||
| 855 | cpufreq_cooling_ops.state2power = cpufreq_state2power; | ||
| 856 | cpufreq_cooling_ops.power2state = cpufreq_power2state; | ||
| 857 | cpufreq_dev->plat_get_static_power = plat_static_func; | 864 | cpufreq_dev->plat_get_static_power = plat_static_func; |
| 858 | 865 | ||
| 859 | ret = build_dyn_power_table(cpufreq_dev, capacitance); | 866 | ret = build_dyn_power_table(cpufreq_dev, capacitance); |
| @@ -861,6 +868,10 @@ __cpufreq_cooling_register(struct device_node *np, | |||
| 861 | cool_dev = ERR_PTR(ret); | 868 | cool_dev = ERR_PTR(ret); |
| 862 | goto free_table; | 869 | goto free_table; |
| 863 | } | 870 | } |
| 871 | |||
| 872 | cooling_ops = &cpufreq_power_cooling_ops; | ||
| 873 | } else { | ||
| 874 | cooling_ops = &cpufreq_cooling_ops; | ||
| 864 | } | 875 | } |
| 865 | 876 | ||
| 866 | ret = get_idr(&cpufreq_idr, &cpufreq_dev->id); | 877 | ret = get_idr(&cpufreq_idr, &cpufreq_dev->id); |
| @@ -885,7 +896,7 @@ __cpufreq_cooling_register(struct device_node *np, | |||
| 885 | cpufreq_dev->id); | 896 | cpufreq_dev->id); |
| 886 | 897 | ||
| 887 | cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev, | 898 | cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev, |
| 888 | &cpufreq_cooling_ops); | 899 | cooling_ops); |
| 889 | if (IS_ERR(cool_dev)) | 900 | if (IS_ERR(cool_dev)) |
| 890 | goto remove_idr; | 901 | goto remove_idr; |
| 891 | 902 | ||
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index c5547bd711db..e473548b5d28 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c | |||
| @@ -471,8 +471,6 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match); | |||
| 471 | 471 | ||
| 472 | static int imx_thermal_probe(struct platform_device *pdev) | 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 | struct imx_thermal_data *data; | 474 | struct imx_thermal_data *data; |
| 477 | struct regmap *map; | 475 | struct regmap *map; |
| 478 | int measure_freq; | 476 | int measure_freq; |
| @@ -490,7 +488,7 @@ static int imx_thermal_probe(struct platform_device *pdev) | |||
| 490 | } | 488 | } |
| 491 | data->tempmon = map; | 489 | data->tempmon = map; |
| 492 | 490 | ||
| 493 | data->socdata = of_id->data; | 491 | data->socdata = of_device_get_match_data(&pdev->dev); |
| 494 | 492 | ||
| 495 | /* make sure the IRQ flag is clear before enabling irq on i.MX6SX */ | 493 | /* make sure the IRQ flag is clear before enabling irq on i.MX6SX */ |
| 496 | if (data->socdata->version == TEMPMON_IMX6SX) { | 494 | if (data->socdata->version == TEMPMON_IMX6SX) { |
diff --git a/drivers/thermal/int340x_thermal/int3406_thermal.c b/drivers/thermal/int340x_thermal/int3406_thermal.c index a578cd257db4..1891f34ab7fc 100644 --- a/drivers/thermal/int340x_thermal/int3406_thermal.c +++ b/drivers/thermal/int340x_thermal/int3406_thermal.c | |||
| @@ -225,7 +225,6 @@ static struct platform_driver int3406_thermal_driver = { | |||
| 225 | .remove = int3406_thermal_remove, | 225 | .remove = int3406_thermal_remove, |
| 226 | .driver = { | 226 | .driver = { |
| 227 | .name = "int3406 thermal", | 227 | .name = "int3406 thermal", |
| 228 | .owner = THIS_MODULE, | ||
| 229 | .acpi_match_table = int3406_thermal_match, | 228 | .acpi_match_table = int3406_thermal_match, |
| 230 | }, | 229 | }, |
| 231 | }; | 230 | }; |
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 71a339271fa5..5f817923f374 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c | |||
| @@ -504,6 +504,7 @@ static int rcar_thermal_probe(struct platform_device *pdev) | |||
| 504 | if (IS_ERR(priv->zone)) { | 504 | if (IS_ERR(priv->zone)) { |
| 505 | dev_err(dev, "can't register thermal zone\n"); | 505 | dev_err(dev, "can't register thermal zone\n"); |
| 506 | ret = PTR_ERR(priv->zone); | 506 | ret = PTR_ERR(priv->zone); |
| 507 | priv->zone = NULL; | ||
| 507 | goto error_unregister; | 508 | goto error_unregister; |
| 508 | } | 509 | } |
| 509 | 510 | ||
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index 9c15344b657a..a8c20413dbda 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c | |||
| @@ -651,6 +651,12 @@ static struct pci_device_id nhi_ids[] = { | |||
| 651 | { | 651 | { |
| 652 | .class = PCI_CLASS_SYSTEM_OTHER << 8, .class_mask = ~0, | 652 | .class = PCI_CLASS_SYSTEM_OTHER << 8, .class_mask = ~0, |
| 653 | .vendor = PCI_VENDOR_ID_INTEL, | 653 | .vendor = PCI_VENDOR_ID_INTEL, |
| 654 | .device = PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_NHI, | ||
| 655 | .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, | ||
| 656 | }, | ||
| 657 | { | ||
| 658 | .class = PCI_CLASS_SYSTEM_OTHER << 8, .class_mask = ~0, | ||
| 659 | .vendor = PCI_VENDOR_ID_INTEL, | ||
| 654 | .device = PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI, | 660 | .device = PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI, |
| 655 | .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, | 661 | .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, |
| 656 | }, | 662 | }, |
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index 1e116f53d6dd..9840fdecb73b 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c | |||
| @@ -372,7 +372,9 @@ struct tb_switch *tb_switch_alloc(struct tb *tb, u64 route) | |||
| 372 | 372 | ||
| 373 | if (sw->config.device_id != PCI_DEVICE_ID_INTEL_LIGHT_RIDGE && | 373 | if (sw->config.device_id != PCI_DEVICE_ID_INTEL_LIGHT_RIDGE && |
| 374 | sw->config.device_id != PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C && | 374 | sw->config.device_id != PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C && |
| 375 | sw->config.device_id != PCI_DEVICE_ID_INTEL_PORT_RIDGE) | 375 | sw->config.device_id != PCI_DEVICE_ID_INTEL_PORT_RIDGE && |
| 376 | sw->config.device_id != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE && | ||
| 377 | sw->config.device_id != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE) | ||
| 376 | tb_sw_warn(sw, "unsupported switch device id %#x\n", | 378 | tb_sw_warn(sw, "unsupported switch device id %#x\n", |
| 377 | sw->config.device_id); | 379 | sw->config.device_id); |
| 378 | 380 | ||
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index 122e0e4029fe..1a16feac9a36 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h | |||
| @@ -15,8 +15,6 @@ | |||
| 15 | #include <linux/serial_reg.h> | 15 | #include <linux/serial_reg.h> |
| 16 | #include <linux/dmaengine.h> | 16 | #include <linux/dmaengine.h> |
| 17 | 17 | ||
| 18 | #include "../serial_mctrl_gpio.h" | ||
| 19 | |||
| 20 | struct uart_8250_dma { | 18 | struct uart_8250_dma { |
| 21 | int (*tx_dma)(struct uart_8250_port *p); | 19 | int (*tx_dma)(struct uart_8250_port *p); |
| 22 | int (*rx_dma)(struct uart_8250_port *p); | 20 | int (*rx_dma)(struct uart_8250_port *p); |
| @@ -133,43 +131,12 @@ void serial8250_em485_destroy(struct uart_8250_port *p); | |||
| 133 | 131 | ||
| 134 | static inline void serial8250_out_MCR(struct uart_8250_port *up, int value) | 132 | static inline void serial8250_out_MCR(struct uart_8250_port *up, int value) |
| 135 | { | 133 | { |
| 136 | int mctrl_gpio = 0; | ||
| 137 | |||
| 138 | serial_out(up, UART_MCR, value); | 134 | serial_out(up, UART_MCR, value); |
| 139 | |||
| 140 | if (value & UART_MCR_RTS) | ||
| 141 | mctrl_gpio |= TIOCM_RTS; | ||
| 142 | if (value & UART_MCR_DTR) | ||
| 143 | mctrl_gpio |= TIOCM_DTR; | ||
| 144 | |||
| 145 | mctrl_gpio_set(up->gpios, mctrl_gpio); | ||
| 146 | } | 135 | } |
| 147 | 136 | ||
| 148 | static inline int serial8250_in_MCR(struct uart_8250_port *up) | 137 | static inline int serial8250_in_MCR(struct uart_8250_port *up) |
| 149 | { | 138 | { |
| 150 | int mctrl, mctrl_gpio = 0; | 139 | return serial_in(up, UART_MCR); |
| 151 | |||
| 152 | mctrl = serial_in(up, UART_MCR); | ||
| 153 | |||
| 154 | /* save current MCR values */ | ||
| 155 | if (mctrl & UART_MCR_RTS) | ||
| 156 | mctrl_gpio |= TIOCM_RTS; | ||
| 157 | if (mctrl & UART_MCR_DTR) | ||
| 158 | mctrl_gpio |= TIOCM_DTR; | ||
| 159 | |||
| 160 | mctrl_gpio = mctrl_gpio_get_outputs(up->gpios, &mctrl_gpio); | ||
| 161 | |||
| 162 | if (mctrl_gpio & TIOCM_RTS) | ||
| 163 | mctrl |= UART_MCR_RTS; | ||
| 164 | else | ||
| 165 | mctrl &= ~UART_MCR_RTS; | ||
| 166 | |||
| 167 | if (mctrl_gpio & TIOCM_DTR) | ||
| 168 | mctrl |= UART_MCR_DTR; | ||
| 169 | else | ||
| 170 | mctrl &= ~UART_MCR_DTR; | ||
| 171 | |||
| 172 | return mctrl; | ||
| 173 | } | 140 | } |
| 174 | 141 | ||
| 175 | #if defined(__alpha__) && !defined(CONFIG_PCI) | 142 | #if defined(__alpha__) && !defined(CONFIG_PCI) |
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index 13ad5c3d2e68..dcf43f66404f 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c | |||
| @@ -974,8 +974,6 @@ int serial8250_register_8250_port(struct uart_8250_port *up) | |||
| 974 | 974 | ||
| 975 | uart = serial8250_find_match_or_unused(&up->port); | 975 | uart = serial8250_find_match_or_unused(&up->port); |
| 976 | if (uart && uart->port.type != PORT_8250_CIR) { | 976 | if (uart && uart->port.type != PORT_8250_CIR) { |
| 977 | struct mctrl_gpios *gpios; | ||
| 978 | |||
| 979 | if (uart->port.dev) | 977 | if (uart->port.dev) |
| 980 | uart_remove_one_port(&serial8250_reg, &uart->port); | 978 | uart_remove_one_port(&serial8250_reg, &uart->port); |
| 981 | 979 | ||
| @@ -1013,13 +1011,6 @@ int serial8250_register_8250_port(struct uart_8250_port *up) | |||
| 1013 | if (up->port.flags & UPF_FIXED_TYPE) | 1011 | if (up->port.flags & UPF_FIXED_TYPE) |
| 1014 | uart->port.type = up->port.type; | 1012 | uart->port.type = up->port.type; |
| 1015 | 1013 | ||
| 1016 | gpios = mctrl_gpio_init(&uart->port, 0); | ||
| 1017 | if (IS_ERR(gpios)) { | ||
| 1018 | if (PTR_ERR(gpios) != -ENOSYS) | ||
| 1019 | return PTR_ERR(gpios); | ||
| 1020 | } else | ||
| 1021 | uart->gpios = gpios; | ||
| 1022 | |||
| 1023 | serial8250_set_defaults(uart); | 1014 | serial8250_set_defaults(uart); |
| 1024 | 1015 | ||
| 1025 | /* Possibly override default I/O functions. */ | 1016 | /* Possibly override default I/O functions. */ |
diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c index 737b4b3957b0..0facc789fe7d 100644 --- a/drivers/tty/serial/8250/8250_fintek.c +++ b/drivers/tty/serial/8250/8250_fintek.c | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | #define IO_ADDR2 0x60 | 31 | #define IO_ADDR2 0x60 |
| 32 | #define LDN 0x7 | 32 | #define LDN 0x7 |
| 33 | 33 | ||
| 34 | #define IRQ_MODE 0x70 | 34 | #define FINTEK_IRQ_MODE 0x70 |
| 35 | #define IRQ_SHARE BIT(4) | 35 | #define IRQ_SHARE BIT(4) |
| 36 | #define IRQ_MODE_MASK (BIT(6) | BIT(5)) | 36 | #define IRQ_MODE_MASK (BIT(6) | BIT(5)) |
| 37 | #define IRQ_LEVEL_LOW 0 | 37 | #define IRQ_LEVEL_LOW 0 |
| @@ -195,7 +195,7 @@ static int fintek_8250_set_irq_mode(struct fintek_8250 *pdata, bool level_mode) | |||
| 195 | outb(LDN, pdata->base_port + ADDR_PORT); | 195 | outb(LDN, pdata->base_port + ADDR_PORT); |
| 196 | outb(pdata->index, pdata->base_port + DATA_PORT); | 196 | outb(pdata->index, pdata->base_port + DATA_PORT); |
| 197 | 197 | ||
| 198 | outb(IRQ_MODE, pdata->base_port + ADDR_PORT); | 198 | outb(FINTEK_IRQ_MODE, pdata->base_port + ADDR_PORT); |
| 199 | tmp = inb(pdata->base_port + DATA_PORT); | 199 | tmp = inb(pdata->base_port + DATA_PORT); |
| 200 | 200 | ||
| 201 | tmp &= ~IRQ_MODE_MASK; | 201 | tmp &= ~IRQ_MODE_MASK; |
diff --git a/drivers/tty/serial/8250/8250_mid.c b/drivers/tty/serial/8250/8250_mid.c index 339de9cd0866..20c5db2f4264 100644 --- a/drivers/tty/serial/8250/8250_mid.c +++ b/drivers/tty/serial/8250/8250_mid.c | |||
| @@ -168,6 +168,9 @@ static void mid8250_set_termios(struct uart_port *p, | |||
| 168 | unsigned long w = BIT(24) - 1; | 168 | unsigned long w = BIT(24) - 1; |
| 169 | unsigned long mul, div; | 169 | unsigned long mul, div; |
| 170 | 170 | ||
| 171 | /* Gracefully handle the B0 case: fall back to B9600 */ | ||
| 172 | fuart = fuart ? fuart : 9600 * 16; | ||
| 173 | |||
| 171 | if (mid->board->freq < fuart) { | 174 | if (mid->board->freq < fuart) { |
| 172 | /* Find prescaler value that satisfies Fuart < Fref */ | 175 | /* Find prescaler value that satisfies Fuart < Fref */ |
| 173 | if (mid->board->freq > baud) | 176 | if (mid->board->freq > baud) |
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index e14982f36a04..61ad6c3b20a0 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c | |||
| @@ -134,21 +134,18 @@ static void omap8250_set_mctrl(struct uart_port *port, unsigned int mctrl) | |||
| 134 | 134 | ||
| 135 | serial8250_do_set_mctrl(port, mctrl); | 135 | serial8250_do_set_mctrl(port, mctrl); |
| 136 | 136 | ||
| 137 | if (IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(up->gpios, | 137 | /* |
| 138 | UART_GPIO_RTS))) { | 138 | * Turn off autoRTS if RTS is lowered and restore autoRTS setting |
| 139 | /* | 139 | * if RTS is raised |
| 140 | * Turn off autoRTS if RTS is lowered and restore autoRTS | 140 | */ |
| 141 | * setting if RTS is raised | 141 | lcr = serial_in(up, UART_LCR); |
| 142 | */ | 142 | serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); |
| 143 | lcr = serial_in(up, UART_LCR); | 143 | if ((mctrl & TIOCM_RTS) && (port->status & UPSTAT_AUTORTS)) |
| 144 | serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); | 144 | priv->efr |= UART_EFR_RTS; |
| 145 | if ((mctrl & TIOCM_RTS) && (port->status & UPSTAT_AUTORTS)) | 145 | else |
| 146 | priv->efr |= UART_EFR_RTS; | 146 | priv->efr &= ~UART_EFR_RTS; |
| 147 | else | 147 | serial_out(up, UART_EFR, priv->efr); |
| 148 | priv->efr &= ~UART_EFR_RTS; | 148 | serial_out(up, UART_LCR, lcr); |
| 149 | serial_out(up, UART_EFR, priv->efr); | ||
| 150 | serial_out(up, UART_LCR, lcr); | ||
| 151 | } | ||
| 152 | } | 149 | } |
| 153 | 150 | ||
| 154 | /* | 151 | /* |
| @@ -449,9 +446,7 @@ static void omap_8250_set_termios(struct uart_port *port, | |||
| 449 | priv->efr = 0; | 446 | priv->efr = 0; |
| 450 | up->port.status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS | UPSTAT_AUTOXOFF); | 447 | up->port.status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS | UPSTAT_AUTOXOFF); |
| 451 | 448 | ||
| 452 | if (termios->c_cflag & CRTSCTS && up->port.flags & UPF_HARD_FLOW | 449 | if (termios->c_cflag & CRTSCTS && up->port.flags & UPF_HARD_FLOW) { |
| 453 | && IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(up->gpios, | ||
| 454 | UART_GPIO_RTS))) { | ||
| 455 | /* Enable AUTOCTS (autoRTS is enabled when RTS is raised) */ | 450 | /* Enable AUTOCTS (autoRTS is enabled when RTS is raised) */ |
| 456 | up->port.status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS; | 451 | up->port.status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS; |
| 457 | priv->efr |= UART_EFR_CTS; | 452 | priv->efr |= UART_EFR_CTS; |
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 20ebaea5c414..bc51b32b2774 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c | |||
| @@ -1950,6 +1950,43 @@ pci_wch_ch38x_setup(struct serial_private *priv, | |||
| 1950 | #define PCI_DEVICE_ID_PERICOM_PI7C9X7954 0x7954 | 1950 | #define PCI_DEVICE_ID_PERICOM_PI7C9X7954 0x7954 |
| 1951 | #define PCI_DEVICE_ID_PERICOM_PI7C9X7958 0x7958 | 1951 | #define PCI_DEVICE_ID_PERICOM_PI7C9X7958 0x7958 |
| 1952 | 1952 | ||
| 1953 | #define PCI_VENDOR_ID_ACCESIO 0x494f | ||
| 1954 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SDB 0x1051 | ||
| 1955 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2S 0x1053 | ||
| 1956 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SDB 0x105C | ||
| 1957 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4S 0x105E | ||
| 1958 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_2DB 0x1091 | ||
| 1959 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_2 0x1093 | ||
| 1960 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4DB 0x1099 | ||
| 1961 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_4 0x109B | ||
| 1962 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SMDB 0x10D1 | ||
| 1963 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2SM 0x10D3 | ||
| 1964 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SMDB 0x10DA | ||
| 1965 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4SM 0x10DC | ||
| 1966 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_1 0x1108 | ||
| 1967 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_2 0x1110 | ||
| 1968 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_2 0x1111 | ||
| 1969 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_4 0x1118 | ||
| 1970 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_4 0x1119 | ||
| 1971 | #define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2S 0x1152 | ||
| 1972 | #define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S 0x115A | ||
| 1973 | #define PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_2 0x1190 | ||
| 1974 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_2 0x1191 | ||
| 1975 | #define PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4 0x1198 | ||
| 1976 | #define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_4 0x1199 | ||
| 1977 | #define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2SM 0x11D0 | ||
| 1978 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM422_4 0x105A | ||
| 1979 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM485_4 0x105B | ||
| 1980 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM422_8 0x106A | ||
| 1981 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM485_8 0x106B | ||
| 1982 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4 0x1098 | ||
| 1983 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_8 0x10A9 | ||
| 1984 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SM 0x10D9 | ||
| 1985 | #define PCI_DEVICE_ID_ACCESIO_PCIE_COM_8SM 0x10E9 | ||
| 1986 | #define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4SM 0x11D8 | ||
| 1987 | |||
| 1988 | |||
| 1989 | |||
| 1953 | /* Unknown vendors/cards - this should not be in linux/pci_ids.h */ | 1990 | /* Unknown vendors/cards - this should not be in linux/pci_ids.h */ |
| 1954 | #define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584 | 1991 | #define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584 |
| 1955 | #define PCI_SUBDEVICE_ID_UNKNOWN_0x1588 0x1588 | 1992 | #define PCI_SUBDEVICE_ID_UNKNOWN_0x1588 0x1588 |
| @@ -5113,6 +5150,108 @@ static struct pci_device_id serial_pci_tbl[] = { | |||
| 5113 | 0, | 5150 | 0, |
| 5114 | 0, pbn_pericom_PI7C9X7958 }, | 5151 | 0, pbn_pericom_PI7C9X7958 }, |
| 5115 | /* | 5152 | /* |
| 5153 | * ACCES I/O Products quad | ||
| 5154 | */ | ||
| 5155 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SDB, | ||
| 5156 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5157 | pbn_pericom_PI7C9X7954 }, | ||
| 5158 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2S, | ||
| 5159 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5160 | pbn_pericom_PI7C9X7954 }, | ||
| 5161 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SDB, | ||
| 5162 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5163 | pbn_pericom_PI7C9X7954 }, | ||
| 5164 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4S, | ||
| 5165 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5166 | pbn_pericom_PI7C9X7954 }, | ||
| 5167 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_2DB, | ||
| 5168 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5169 | pbn_pericom_PI7C9X7954 }, | ||
| 5170 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_2, | ||
| 5171 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5172 | pbn_pericom_PI7C9X7954 }, | ||
| 5173 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4DB, | ||
| 5174 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5175 | pbn_pericom_PI7C9X7954 }, | ||
| 5176 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_4, | ||
| 5177 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5178 | pbn_pericom_PI7C9X7954 }, | ||
| 5179 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SMDB, | ||
| 5180 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5181 | pbn_pericom_PI7C9X7954 }, | ||
| 5182 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2SM, | ||
| 5183 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5184 | pbn_pericom_PI7C9X7954 }, | ||
| 5185 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SMDB, | ||
| 5186 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5187 | pbn_pericom_PI7C9X7954 }, | ||
| 5188 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4SM, | ||
| 5189 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5190 | pbn_pericom_PI7C9X7954 }, | ||
| 5191 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_1, | ||
| 5192 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5193 | pbn_pericom_PI7C9X7954 }, | ||
| 5194 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_2, | ||
| 5195 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5196 | pbn_pericom_PI7C9X7954 }, | ||
| 5197 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_2, | ||
| 5198 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5199 | pbn_pericom_PI7C9X7954 }, | ||
| 5200 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_4, | ||
| 5201 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5202 | pbn_pericom_PI7C9X7954 }, | ||
| 5203 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_4, | ||
| 5204 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5205 | pbn_pericom_PI7C9X7954 }, | ||
| 5206 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2S, | ||
| 5207 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5208 | pbn_pericom_PI7C9X7954 }, | ||
| 5209 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S, | ||
| 5210 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5211 | pbn_pericom_PI7C9X7954 }, | ||
| 5212 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_2, | ||
| 5213 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5214 | pbn_pericom_PI7C9X7954 }, | ||
| 5215 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_2, | ||
| 5216 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5217 | pbn_pericom_PI7C9X7954 }, | ||
| 5218 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4, | ||
| 5219 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5220 | pbn_pericom_PI7C9X7954 }, | ||
| 5221 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_4, | ||
| 5222 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5223 | pbn_pericom_PI7C9X7954 }, | ||
| 5224 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2SM, | ||
| 5225 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5226 | pbn_pericom_PI7C9X7954 }, | ||
| 5227 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM422_4, | ||
| 5228 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5229 | pbn_pericom_PI7C9X7958 }, | ||
| 5230 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM485_4, | ||
| 5231 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5232 | pbn_pericom_PI7C9X7958 }, | ||
| 5233 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM422_8, | ||
| 5234 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5235 | pbn_pericom_PI7C9X7958 }, | ||
| 5236 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM485_8, | ||
| 5237 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5238 | pbn_pericom_PI7C9X7958 }, | ||
| 5239 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4, | ||
| 5240 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5241 | pbn_pericom_PI7C9X7958 }, | ||
| 5242 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_8, | ||
| 5243 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5244 | pbn_pericom_PI7C9X7958 }, | ||
| 5245 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SM, | ||
| 5246 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5247 | pbn_pericom_PI7C9X7958 }, | ||
| 5248 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_8SM, | ||
| 5249 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5250 | pbn_pericom_PI7C9X7958 }, | ||
| 5251 | { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4SM, | ||
| 5252 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
| 5253 | pbn_pericom_PI7C9X7958 }, | ||
| 5254 | /* | ||
| 5116 | * Topic TP560 Data/Fax/Voice 56k modem (reported by Evan Clarke) | 5255 | * Topic TP560 Data/Fax/Voice 56k modem (reported by Evan Clarke) |
| 5117 | */ | 5256 | */ |
| 5118 | { PCI_VENDOR_ID_TOPIC, PCI_DEVICE_ID_TOPIC_TP560, | 5257 | { PCI_VENDOR_ID_TOPIC, PCI_DEVICE_ID_TOPIC_TP560, |
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 7481b95c6d84..bdfa659b9606 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c | |||
| @@ -1618,8 +1618,6 @@ static void serial8250_disable_ms(struct uart_port *port) | |||
| 1618 | if (up->bugs & UART_BUG_NOMSR) | 1618 | if (up->bugs & UART_BUG_NOMSR) |
| 1619 | return; | 1619 | return; |
| 1620 | 1620 | ||
| 1621 | mctrl_gpio_disable_ms(up->gpios); | ||
| 1622 | |||
| 1623 | up->ier &= ~UART_IER_MSI; | 1621 | up->ier &= ~UART_IER_MSI; |
| 1624 | serial_port_out(port, UART_IER, up->ier); | 1622 | serial_port_out(port, UART_IER, up->ier); |
| 1625 | } | 1623 | } |
| @@ -1632,8 +1630,6 @@ static void serial8250_enable_ms(struct uart_port *port) | |||
| 1632 | if (up->bugs & UART_BUG_NOMSR) | 1630 | if (up->bugs & UART_BUG_NOMSR) |
| 1633 | return; | 1631 | return; |
| 1634 | 1632 | ||
| 1635 | mctrl_gpio_enable_ms(up->gpios); | ||
| 1636 | |||
| 1637 | up->ier |= UART_IER_MSI; | 1633 | up->ier |= UART_IER_MSI; |
| 1638 | 1634 | ||
| 1639 | serial8250_rpm_get(up); | 1635 | serial8250_rpm_get(up); |
| @@ -1917,8 +1913,7 @@ unsigned int serial8250_do_get_mctrl(struct uart_port *port) | |||
| 1917 | ret |= TIOCM_DSR; | 1913 | ret |= TIOCM_DSR; |
| 1918 | if (status & UART_MSR_CTS) | 1914 | if (status & UART_MSR_CTS) |
| 1919 | ret |= TIOCM_CTS; | 1915 | ret |= TIOCM_CTS; |
| 1920 | 1916 | return ret; | |
| 1921 | return mctrl_gpio_get(up->gpios, &ret); | ||
| 1922 | } | 1917 | } |
| 1923 | EXPORT_SYMBOL_GPL(serial8250_do_get_mctrl); | 1918 | EXPORT_SYMBOL_GPL(serial8250_do_get_mctrl); |
| 1924 | 1919 | ||
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index c9ec839a5ddf..7c6f7afca5dd 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | config SERIAL_8250 | 6 | config SERIAL_8250 |
| 7 | tristate "8250/16550 and compatible serial support" | 7 | tristate "8250/16550 and compatible serial support" |
| 8 | select SERIAL_CORE | 8 | select SERIAL_CORE |
| 9 | select SERIAL_MCTRL_GPIO if GPIOLIB | ||
| 10 | ---help--- | 9 | ---help--- |
| 11 | This selects whether you want to include the driver for the standard | 10 | This selects whether you want to include the driver for the standard |
| 12 | serial ports. The standard answer is Y. People who might say N | 11 | serial ports. The standard answer is Y. People who might say N |
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 065f5d97aa67..b93356834bb5 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c | |||
| @@ -949,6 +949,15 @@ static int isr_setup_status_phase(struct ci_hdrc *ci) | |||
| 949 | int retval; | 949 | int retval; |
| 950 | struct ci_hw_ep *hwep; | 950 | struct ci_hw_ep *hwep; |
| 951 | 951 | ||
| 952 | /* | ||
| 953 | * Unexpected USB controller behavior, caused by bad signal integrity | ||
| 954 | * or ground reference problems, can lead to isr_setup_status_phase | ||
| 955 | * being called with ci->status equal to NULL. | ||
| 956 | * If this situation occurs, you should review your USB hardware design. | ||
| 957 | */ | ||
| 958 | if (WARN_ON_ONCE(!ci->status)) | ||
| 959 | return -EPIPE; | ||
| 960 | |||
| 952 | hwep = (ci->ep0_dir == TX) ? ci->ep0out : ci->ep0in; | 961 | hwep = (ci->ep0_dir == TX) ? ci->ep0out : ci->ep0in; |
| 953 | ci->status->context = ci; | 962 | ci->status->context = ci; |
| 954 | ci->status->complete = isr_setup_status_complete; | 963 | ci->status->complete = isr_setup_status_complete; |
| @@ -1596,8 +1605,11 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on) | |||
| 1596 | { | 1605 | { |
| 1597 | struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); | 1606 | struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); |
| 1598 | 1607 | ||
| 1599 | /* Data+ pullup controlled by OTG state machine in OTG fsm mode */ | 1608 | /* |
| 1600 | if (ci_otg_is_fsm_mode(ci)) | 1609 | * Data+ pullup controlled by OTG state machine in OTG fsm mode; |
| 1610 | * and don't touch Data+ in host mode for dual role config. | ||
| 1611 | */ | ||
| 1612 | if (ci_otg_is_fsm_mode(ci) || ci->role == CI_ROLE_HOST) | ||
| 1601 | return 0; | 1613 | return 0; |
| 1602 | 1614 | ||
| 1603 | pm_runtime_get_sync(&ci->gadget.dev); | 1615 | pm_runtime_get_sync(&ci->gadget.dev); |
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 051163189810..15ce4ab11688 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c | |||
| @@ -187,7 +187,7 @@ static const unsigned short high_speed_maxpacket_maxes[4] = { | |||
| 187 | [USB_ENDPOINT_XFER_CONTROL] = 64, | 187 | [USB_ENDPOINT_XFER_CONTROL] = 64, |
| 188 | [USB_ENDPOINT_XFER_ISOC] = 1024, | 188 | [USB_ENDPOINT_XFER_ISOC] = 1024, |
| 189 | [USB_ENDPOINT_XFER_BULK] = 512, | 189 | [USB_ENDPOINT_XFER_BULK] = 512, |
| 190 | [USB_ENDPOINT_XFER_INT] = 1023, | 190 | [USB_ENDPOINT_XFER_INT] = 1024, |
| 191 | }; | 191 | }; |
| 192 | static const unsigned short super_speed_maxpacket_maxes[4] = { | 192 | static const unsigned short super_speed_maxpacket_maxes[4] = { |
| 193 | [USB_ENDPOINT_XFER_CONTROL] = 512, | 193 | [USB_ENDPOINT_XFER_CONTROL] = 512, |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index e6a6d67c8705..09c8d9ca61ae 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
| @@ -1709,11 +1709,17 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb | |||
| 1709 | as->urb->start_frame = uurb->start_frame; | 1709 | as->urb->start_frame = uurb->start_frame; |
| 1710 | as->urb->number_of_packets = number_of_packets; | 1710 | as->urb->number_of_packets = number_of_packets; |
| 1711 | as->urb->stream_id = stream_id; | 1711 | as->urb->stream_id = stream_id; |
| 1712 | if (uurb->type == USBDEVFS_URB_TYPE_ISO || | 1712 | |
| 1713 | ps->dev->speed == USB_SPEED_HIGH) | 1713 | if (ep->desc.bInterval) { |
| 1714 | as->urb->interval = 1 << min(15, ep->desc.bInterval - 1); | 1714 | if (uurb->type == USBDEVFS_URB_TYPE_ISO || |
| 1715 | else | 1715 | ps->dev->speed == USB_SPEED_HIGH || |
| 1716 | as->urb->interval = ep->desc.bInterval; | 1716 | ps->dev->speed >= USB_SPEED_SUPER) |
| 1717 | as->urb->interval = 1 << | ||
| 1718 | min(15, ep->desc.bInterval - 1); | ||
| 1719 | else | ||
| 1720 | as->urb->interval = ep->desc.bInterval; | ||
| 1721 | } | ||
| 1722 | |||
| 1717 | as->urb->context = as; | 1723 | as->urb->context = as; |
| 1718 | as->urb->complete = async_completed; | 1724 | as->urb->complete = async_completed; |
| 1719 | for (totlen = u = 0; u < number_of_packets; u++) { | 1725 | for (totlen = u = 0; u < number_of_packets; u++) { |
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 9fae0291cd69..d64551243789 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h | |||
| @@ -868,6 +868,7 @@ struct dwc2_hsotg { | |||
| 868 | void *priv; | 868 | void *priv; |
| 869 | int irq; | 869 | int irq; |
| 870 | struct clk *clk; | 870 | struct clk *clk; |
| 871 | struct reset_control *reset; | ||
| 871 | 872 | ||
| 872 | unsigned int queuing_high_bandwidth:1; | 873 | unsigned int queuing_high_bandwidth:1; |
| 873 | unsigned int srp_success:1; | 874 | unsigned int srp_success:1; |
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index fc6f5251de5d..530959a8a6d1 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c | |||
| @@ -45,6 +45,7 @@ | |||
| 45 | #include <linux/platform_device.h> | 45 | #include <linux/platform_device.h> |
| 46 | #include <linux/phy/phy.h> | 46 | #include <linux/phy/phy.h> |
| 47 | #include <linux/platform_data/s3c-hsotg.h> | 47 | #include <linux/platform_data/s3c-hsotg.h> |
| 48 | #include <linux/reset.h> | ||
| 48 | 49 | ||
| 49 | #include <linux/usb/of.h> | 50 | #include <linux/usb/of.h> |
| 50 | 51 | ||
| @@ -337,6 +338,24 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) | |||
| 337 | { | 338 | { |
| 338 | int i, ret; | 339 | int i, ret; |
| 339 | 340 | ||
| 341 | hsotg->reset = devm_reset_control_get_optional(hsotg->dev, "dwc2"); | ||
| 342 | if (IS_ERR(hsotg->reset)) { | ||
| 343 | ret = PTR_ERR(hsotg->reset); | ||
| 344 | switch (ret) { | ||
| 345 | case -ENOENT: | ||
| 346 | case -ENOTSUPP: | ||
| 347 | hsotg->reset = NULL; | ||
| 348 | break; | ||
| 349 | default: | ||
| 350 | dev_err(hsotg->dev, "error getting reset control %d\n", | ||
| 351 | ret); | ||
| 352 | return ret; | ||
| 353 | } | ||
| 354 | } | ||
| 355 | |||
| 356 | if (hsotg->reset) | ||
| 357 | reset_control_deassert(hsotg->reset); | ||
| 358 | |||
| 340 | /* Set default UTMI width */ | 359 | /* Set default UTMI width */ |
| 341 | hsotg->phyif = GUSBCFG_PHYIF16; | 360 | hsotg->phyif = GUSBCFG_PHYIF16; |
| 342 | 361 | ||
| @@ -434,6 +453,9 @@ static int dwc2_driver_remove(struct platform_device *dev) | |||
| 434 | if (hsotg->ll_hw_enabled) | 453 | if (hsotg->ll_hw_enabled) |
| 435 | dwc2_lowlevel_hw_disable(hsotg); | 454 | dwc2_lowlevel_hw_disable(hsotg); |
| 436 | 455 | ||
| 456 | if (hsotg->reset) | ||
| 457 | reset_control_assert(hsotg->reset); | ||
| 458 | |||
| 437 | return 0; | 459 | return 0; |
| 438 | } | 460 | } |
| 439 | 461 | ||
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 946643157b78..35d092456bec 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
| @@ -1192,6 +1192,7 @@ static int dwc3_runtime_resume(struct device *dev) | |||
| 1192 | } | 1192 | } |
| 1193 | 1193 | ||
| 1194 | pm_runtime_mark_last_busy(dev); | 1194 | pm_runtime_mark_last_busy(dev); |
| 1195 | pm_runtime_put(dev); | ||
| 1195 | 1196 | ||
| 1196 | return 0; | 1197 | return 0; |
| 1197 | } | 1198 | } |
diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h index 22dfc3dd6a13..33ab2a203c1b 100644 --- a/drivers/usb/dwc3/debug.h +++ b/drivers/usb/dwc3/debug.h | |||
| @@ -192,7 +192,7 @@ dwc3_ep_event_string(const struct dwc3_event_depevt *event) | |||
| 192 | int ret; | 192 | int ret; |
| 193 | 193 | ||
| 194 | ret = sprintf(str, "ep%d%s: ", epnum >> 1, | 194 | ret = sprintf(str, "ep%d%s: ", epnum >> 1, |
| 195 | (epnum & 1) ? "in" : "in"); | 195 | (epnum & 1) ? "in" : "out"); |
| 196 | if (ret < 0) | 196 | if (ret < 0) |
| 197 | return "UNKNOWN"; | 197 | return "UNKNOWN"; |
| 198 | 198 | ||
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 2eb84d6c24a6..6df0f5dad9a4 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
| @@ -243,6 +243,15 @@ static int dwc3_pci_runtime_suspend(struct device *dev) | |||
| 243 | return -EBUSY; | 243 | return -EBUSY; |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | static int dwc3_pci_runtime_resume(struct device *dev) | ||
| 247 | { | ||
| 248 | struct platform_device *dwc3 = dev_get_drvdata(dev); | ||
| 249 | |||
| 250 | return pm_runtime_get(&dwc3->dev); | ||
| 251 | } | ||
| 252 | #endif /* CONFIG_PM */ | ||
| 253 | |||
| 254 | #ifdef CONFIG_PM_SLEEP | ||
| 246 | static int dwc3_pci_pm_dummy(struct device *dev) | 255 | static int dwc3_pci_pm_dummy(struct device *dev) |
| 247 | { | 256 | { |
| 248 | /* | 257 | /* |
| @@ -255,11 +264,11 @@ static int dwc3_pci_pm_dummy(struct device *dev) | |||
| 255 | */ | 264 | */ |
| 256 | return 0; | 265 | return 0; |
| 257 | } | 266 | } |
| 258 | #endif /* CONFIG_PM */ | 267 | #endif /* CONFIG_PM_SLEEP */ |
| 259 | 268 | ||
| 260 | static struct dev_pm_ops dwc3_pci_dev_pm_ops = { | 269 | static struct dev_pm_ops dwc3_pci_dev_pm_ops = { |
| 261 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_pm_dummy, dwc3_pci_pm_dummy) | 270 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_pm_dummy, dwc3_pci_pm_dummy) |
| 262 | SET_RUNTIME_PM_OPS(dwc3_pci_runtime_suspend, dwc3_pci_pm_dummy, | 271 | SET_RUNTIME_PM_OPS(dwc3_pci_runtime_suspend, dwc3_pci_runtime_resume, |
| 263 | NULL) | 272 | NULL) |
| 264 | }; | 273 | }; |
| 265 | 274 | ||
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 1f5597ef945d..122e64df2f4d 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
| @@ -1433,7 +1433,7 @@ static int dwc3_gadget_get_frame(struct usb_gadget *g) | |||
| 1433 | 1433 | ||
| 1434 | static int __dwc3_gadget_wakeup(struct dwc3 *dwc) | 1434 | static int __dwc3_gadget_wakeup(struct dwc3 *dwc) |
| 1435 | { | 1435 | { |
| 1436 | unsigned long timeout; | 1436 | int retries; |
| 1437 | 1437 | ||
| 1438 | int ret; | 1438 | int ret; |
| 1439 | u32 reg; | 1439 | u32 reg; |
| @@ -1484,9 +1484,9 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc) | |||
| 1484 | } | 1484 | } |
| 1485 | 1485 | ||
| 1486 | /* poll until Link State changes to ON */ | 1486 | /* poll until Link State changes to ON */ |
| 1487 | timeout = jiffies + msecs_to_jiffies(100); | 1487 | retries = 20000; |
| 1488 | 1488 | ||
| 1489 | while (!time_after(jiffies, timeout)) { | 1489 | while (retries--) { |
| 1490 | reg = dwc3_readl(dwc->regs, DWC3_DSTS); | 1490 | reg = dwc3_readl(dwc->regs, DWC3_DSTS); |
| 1491 | 1491 | ||
| 1492 | /* in HS, means ON */ | 1492 | /* in HS, means ON */ |
diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c index d58bfc32be9e..007ec6e4a5d4 100644 --- a/drivers/usb/gadget/function/f_eem.c +++ b/drivers/usb/gadget/function/f_eem.c | |||
| @@ -341,11 +341,15 @@ static struct sk_buff *eem_wrap(struct gether *port, struct sk_buff *skb) | |||
| 341 | { | 341 | { |
| 342 | struct sk_buff *skb2 = NULL; | 342 | struct sk_buff *skb2 = NULL; |
| 343 | struct usb_ep *in = port->in_ep; | 343 | struct usb_ep *in = port->in_ep; |
| 344 | int padlen = 0; | 344 | int headroom, tailroom, padlen = 0; |
| 345 | u16 len = skb->len; | 345 | u16 len; |
| 346 | 346 | ||
| 347 | int headroom = skb_headroom(skb); | 347 | if (!skb) |
| 348 | int tailroom = skb_tailroom(skb); | 348 | return NULL; |
| 349 | |||
| 350 | len = skb->len; | ||
| 351 | headroom = skb_headroom(skb); | ||
| 352 | tailroom = skb_tailroom(skb); | ||
| 349 | 353 | ||
| 350 | /* When (len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) is 0, | 354 | /* When (len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) is 0, |
| 351 | * stick two bytes of zero-length EEM packet on the end. | 355 | * stick two bytes of zero-length EEM packet on the end. |
diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c index c8005823b190..16562e461121 100644 --- a/drivers/usb/gadget/function/f_rndis.c +++ b/drivers/usb/gadget/function/f_rndis.c | |||
| @@ -374,6 +374,9 @@ static struct sk_buff *rndis_add_header(struct gether *port, | |||
| 374 | { | 374 | { |
| 375 | struct sk_buff *skb2; | 375 | struct sk_buff *skb2; |
| 376 | 376 | ||
| 377 | if (!skb) | ||
| 378 | return NULL; | ||
| 379 | |||
| 377 | skb2 = skb_realloc_headroom(skb, sizeof(struct rndis_packet_msg_type)); | 380 | skb2 = skb_realloc_headroom(skb, sizeof(struct rndis_packet_msg_type)); |
| 378 | rndis_add_hdr(skb2); | 381 | rndis_add_hdr(skb2); |
| 379 | 382 | ||
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index 6ded6345cd09..e0cd1e4c8892 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c | |||
| @@ -375,10 +375,15 @@ __acquires(&port->port_lock) | |||
| 375 | */ | 375 | */ |
| 376 | { | 376 | { |
| 377 | struct list_head *pool = &port->write_pool; | 377 | struct list_head *pool = &port->write_pool; |
| 378 | struct usb_ep *in = port->port_usb->in; | 378 | struct usb_ep *in; |
| 379 | int status = 0; | 379 | int status = 0; |
| 380 | bool do_tty_wake = false; | 380 | bool do_tty_wake = false; |
| 381 | 381 | ||
| 382 | if (!port->port_usb) | ||
| 383 | return status; | ||
| 384 | |||
| 385 | in = port->port_usb->in; | ||
| 386 | |||
| 382 | while (!port->write_busy && !list_empty(pool)) { | 387 | while (!port->write_busy && !list_empty(pool)) { |
| 383 | struct usb_request *req; | 388 | struct usb_request *req; |
| 384 | int len; | 389 | int len; |
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index 934f83881c30..40c04bb25f2f 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c | |||
| @@ -827,7 +827,7 @@ void usb_gadget_unmap_request_by_dev(struct device *dev, | |||
| 827 | return; | 827 | return; |
| 828 | 828 | ||
| 829 | if (req->num_mapped_sgs) { | 829 | if (req->num_mapped_sgs) { |
| 830 | dma_unmap_sg(dev, req->sg, req->num_mapped_sgs, | 830 | dma_unmap_sg(dev, req->sg, req->num_sgs, |
| 831 | is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 831 | is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
| 832 | 832 | ||
| 833 | req->num_mapped_sgs = 0; | 833 | req->num_mapped_sgs = 0; |
diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c index cf8819a5c5b2..8bb011ea78f7 100644 --- a/drivers/usb/gadget/udc/fsl_qe_udc.c +++ b/drivers/usb/gadget/udc/fsl_qe_udc.c | |||
| @@ -1878,11 +1878,8 @@ static int qe_get_frame(struct usb_gadget *gadget) | |||
| 1878 | 1878 | ||
| 1879 | tmp = in_be16(&udc->usb_param->frame_n); | 1879 | tmp = in_be16(&udc->usb_param->frame_n); |
| 1880 | if (tmp & 0x8000) | 1880 | if (tmp & 0x8000) |
| 1881 | tmp = tmp & 0x07ff; | 1881 | return tmp & 0x07ff; |
| 1882 | else | 1882 | return -EINVAL; |
| 1883 | tmp = -EINVAL; | ||
| 1884 | |||
| 1885 | return (int)tmp; | ||
| 1886 | } | 1883 | } |
| 1887 | 1884 | ||
| 1888 | static int fsl_qe_start(struct usb_gadget *gadget, | 1885 | static int fsl_qe_start(struct usb_gadget *gadget, |
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c index 93a3bec81df7..fb8fc34827ab 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c | |||
| @@ -106,6 +106,7 @@ | |||
| 106 | 106 | ||
| 107 | /* DRD_CON */ | 107 | /* DRD_CON */ |
| 108 | #define DRD_CON_PERI_CON BIT(24) | 108 | #define DRD_CON_PERI_CON BIT(24) |
| 109 | #define DRD_CON_VBOUT BIT(0) | ||
| 109 | 110 | ||
| 110 | /* USB_INT_ENA_1 and USB_INT_STA_1 */ | 111 | /* USB_INT_ENA_1 and USB_INT_STA_1 */ |
| 111 | #define USB_INT_1_B3_PLLWKUP BIT(31) | 112 | #define USB_INT_1_B3_PLLWKUP BIT(31) |
| @@ -363,6 +364,7 @@ static void usb3_init_epc_registers(struct renesas_usb3 *usb3) | |||
| 363 | { | 364 | { |
| 364 | /* FIXME: How to change host / peripheral mode as well? */ | 365 | /* FIXME: How to change host / peripheral mode as well? */ |
| 365 | usb3_set_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON); | 366 | usb3_set_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON); |
| 367 | usb3_clear_bit(usb3, DRD_CON_VBOUT, USB3_DRD_CON); | ||
| 366 | 368 | ||
| 367 | usb3_write(usb3, ~0, USB3_USB_INT_STA_1); | 369 | usb3_write(usb3, ~0, USB3_USB_INT_STA_1); |
| 368 | usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG); | 370 | usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG); |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index fd9fd12e4861..797137e26549 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
| @@ -850,6 +850,10 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) | |||
| 850 | spin_lock_irqsave(&xhci->lock, flags); | 850 | spin_lock_irqsave(&xhci->lock, flags); |
| 851 | 851 | ||
| 852 | ep->stop_cmds_pending--; | 852 | ep->stop_cmds_pending--; |
| 853 | if (xhci->xhc_state & XHCI_STATE_REMOVING) { | ||
| 854 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
| 855 | return; | ||
| 856 | } | ||
| 853 | if (xhci->xhc_state & XHCI_STATE_DYING) { | 857 | if (xhci->xhc_state & XHCI_STATE_DYING) { |
| 854 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | 858 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, |
| 855 | "Stop EP timer ran, but another timer marked " | 859 | "Stop EP timer ran, but another timer marked " |
| @@ -903,7 +907,7 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) | |||
| 903 | spin_unlock_irqrestore(&xhci->lock, flags); | 907 | spin_unlock_irqrestore(&xhci->lock, flags); |
| 904 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | 908 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, |
| 905 | "Calling usb_hc_died()"); | 909 | "Calling usb_hc_died()"); |
| 906 | usb_hc_died(xhci_to_hcd(xhci)->primary_hcd); | 910 | usb_hc_died(xhci_to_hcd(xhci)); |
| 907 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | 911 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, |
| 908 | "xHCI host controller is dead."); | 912 | "xHCI host controller is dead."); |
| 909 | } | 913 | } |
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index 192248f974ec..fe08e776fec3 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c | |||
| @@ -290,6 +290,7 @@ int musb_hub_control( | |||
| 290 | u32 temp; | 290 | u32 temp; |
| 291 | int retval = 0; | 291 | int retval = 0; |
| 292 | unsigned long flags; | 292 | unsigned long flags; |
| 293 | bool start_musb = false; | ||
| 293 | 294 | ||
| 294 | spin_lock_irqsave(&musb->lock, flags); | 295 | spin_lock_irqsave(&musb->lock, flags); |
| 295 | 296 | ||
| @@ -390,7 +391,7 @@ int musb_hub_control( | |||
| 390 | * logic relating to VBUS power-up. | 391 | * logic relating to VBUS power-up. |
| 391 | */ | 392 | */ |
| 392 | if (!hcd->self.is_b_host && musb_has_gadget(musb)) | 393 | if (!hcd->self.is_b_host && musb_has_gadget(musb)) |
| 393 | musb_start(musb); | 394 | start_musb = true; |
| 394 | break; | 395 | break; |
| 395 | case USB_PORT_FEAT_RESET: | 396 | case USB_PORT_FEAT_RESET: |
| 396 | musb_port_reset(musb, true); | 397 | musb_port_reset(musb, true); |
| @@ -451,5 +452,9 @@ error: | |||
| 451 | retval = -EPIPE; | 452 | retval = -EPIPE; |
| 452 | } | 453 | } |
| 453 | spin_unlock_irqrestore(&musb->lock, flags); | 454 | spin_unlock_irqrestore(&musb->lock, flags); |
| 455 | |||
| 456 | if (start_musb) | ||
| 457 | musb_start(musb); | ||
| 458 | |||
| 454 | return retval; | 459 | return retval; |
| 455 | } | 460 | } |
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c index 980c9dee09eb..427efb5eebae 100644 --- a/drivers/usb/phy/phy-generic.c +++ b/drivers/usb/phy/phy-generic.c | |||
| @@ -144,14 +144,18 @@ static irqreturn_t nop_gpio_vbus_thread(int irq, void *data) | |||
| 144 | int usb_gen_phy_init(struct usb_phy *phy) | 144 | int usb_gen_phy_init(struct usb_phy *phy) |
| 145 | { | 145 | { |
| 146 | struct usb_phy_generic *nop = dev_get_drvdata(phy->dev); | 146 | struct usb_phy_generic *nop = dev_get_drvdata(phy->dev); |
| 147 | int ret; | ||
| 147 | 148 | ||
| 148 | if (!IS_ERR(nop->vcc)) { | 149 | if (!IS_ERR(nop->vcc)) { |
| 149 | if (regulator_enable(nop->vcc)) | 150 | if (regulator_enable(nop->vcc)) |
| 150 | dev_err(phy->dev, "Failed to enable power\n"); | 151 | dev_err(phy->dev, "Failed to enable power\n"); |
| 151 | } | 152 | } |
| 152 | 153 | ||
| 153 | if (!IS_ERR(nop->clk)) | 154 | if (!IS_ERR(nop->clk)) { |
| 154 | clk_prepare_enable(nop->clk); | 155 | ret = clk_prepare_enable(nop->clk); |
| 156 | if (ret) | ||
| 157 | return ret; | ||
| 158 | } | ||
| 155 | 159 | ||
| 156 | nop_reset(nop); | 160 | nop_reset(nop); |
| 157 | 161 | ||
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c index d4be5d594896..28965ef4f824 100644 --- a/drivers/usb/renesas_usbhs/mod.c +++ b/drivers/usb/renesas_usbhs/mod.c | |||
| @@ -282,9 +282,16 @@ static irqreturn_t usbhs_interrupt(int irq, void *data) | |||
| 282 | if (usbhs_mod_is_host(priv)) | 282 | if (usbhs_mod_is_host(priv)) |
| 283 | usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC); | 283 | usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC); |
| 284 | 284 | ||
| 285 | usbhs_write(priv, BRDYSTS, ~irq_state.brdysts); | 285 | /* |
| 286 | * The driver should not clear the xxxSTS after the line of | ||
| 287 | * "call irq callback functions" because each "if" statement is | ||
| 288 | * possible to call the callback function for avoiding any side effects. | ||
| 289 | */ | ||
| 290 | if (irq_state.intsts0 & BRDY) | ||
| 291 | usbhs_write(priv, BRDYSTS, ~irq_state.brdysts); | ||
| 286 | usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts); | 292 | usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts); |
| 287 | usbhs_write(priv, BEMPSTS, ~irq_state.bempsts); | 293 | if (irq_state.intsts0 & BEMP) |
| 294 | usbhs_write(priv, BEMPSTS, ~irq_state.bempsts); | ||
| 288 | 295 | ||
| 289 | /* | 296 | /* |
| 290 | * call irq callback functions | 297 | * call irq callback functions |
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 92bc83b92d10..c4c64740a3e7 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
| @@ -1076,7 +1076,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) | |||
| 1076 | 1076 | ||
| 1077 | gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED); | 1077 | gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED); |
| 1078 | dev_info(dev, "%stransceiver found\n", | 1078 | dev_info(dev, "%stransceiver found\n", |
| 1079 | gpriv->transceiver ? "" : "no "); | 1079 | !IS_ERR(gpriv->transceiver) ? "" : "no "); |
| 1080 | 1080 | ||
| 1081 | /* | 1081 | /* |
| 1082 | * CAUTION | 1082 | * CAUTION |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 5608af4a369d..de9992b492b0 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
| @@ -1252,7 +1252,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 1252 | 1252 | ||
| 1253 | if (urb->transfer_buffer == NULL) { | 1253 | if (urb->transfer_buffer == NULL) { |
| 1254 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, | 1254 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, |
| 1255 | GFP_KERNEL); | 1255 | GFP_ATOMIC); |
| 1256 | if (!urb->transfer_buffer) | 1256 | if (!urb->transfer_buffer) |
| 1257 | goto exit; | 1257 | goto exit; |
| 1258 | } | 1258 | } |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index ed378fb232e7..57426d703a09 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
| @@ -1340,8 +1340,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 1340 | } | 1340 | } |
| 1341 | 1341 | ||
| 1342 | if (urb->transfer_buffer == NULL) { | 1342 | if (urb->transfer_buffer == NULL) { |
| 1343 | urb->transfer_buffer = | 1343 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, |
| 1344 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); | 1344 | GFP_ATOMIC); |
| 1345 | if (!urb->transfer_buffer) | 1345 | if (!urb->transfer_buffer) |
| 1346 | goto exit; | 1346 | goto exit; |
| 1347 | } | 1347 | } |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index bc472584a229..9894e341c6ac 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
| @@ -525,6 +525,12 @@ static void option_instat_callback(struct urb *urb); | |||
| 525 | #define VIATELECOM_VENDOR_ID 0x15eb | 525 | #define VIATELECOM_VENDOR_ID 0x15eb |
| 526 | #define VIATELECOM_PRODUCT_CDS7 0x0001 | 526 | #define VIATELECOM_PRODUCT_CDS7 0x0001 |
| 527 | 527 | ||
| 528 | /* WeTelecom products */ | ||
| 529 | #define WETELECOM_VENDOR_ID 0x22de | ||
| 530 | #define WETELECOM_PRODUCT_WMD200 0x6801 | ||
| 531 | #define WETELECOM_PRODUCT_6802 0x6802 | ||
| 532 | #define WETELECOM_PRODUCT_WMD300 0x6803 | ||
| 533 | |||
| 528 | struct option_blacklist_info { | 534 | struct option_blacklist_info { |
| 529 | /* bitmask of interface numbers blacklisted for send_setup */ | 535 | /* bitmask of interface numbers blacklisted for send_setup */ |
| 530 | const unsigned long sendsetup; | 536 | const unsigned long sendsetup; |
| @@ -1991,6 +1997,9 @@ static const struct usb_device_id option_ids[] = { | |||
| 1991 | { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */ | 1997 | { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */ |
| 1992 | { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, | 1998 | { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, |
| 1993 | { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) }, | 1999 | { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) }, |
| 2000 | { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD200, 0xff, 0xff, 0xff) }, | ||
| 2001 | { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_6802, 0xff, 0xff, 0xff) }, | ||
| 2002 | { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD300, 0xff, 0xff, 0xff) }, | ||
| 1994 | { } /* Terminating entry */ | 2003 | { } /* Terminating entry */ |
| 1995 | }; | 2004 | }; |
| 1996 | MODULE_DEVICE_TABLE(usb, option_ids); | 2005 | MODULE_DEVICE_TABLE(usb, option_ids); |
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 9d6320e8ff3e..6e29d053843d 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c | |||
| @@ -88,7 +88,7 @@ struct vhost_scsi_cmd { | |||
| 88 | struct scatterlist *tvc_prot_sgl; | 88 | struct scatterlist *tvc_prot_sgl; |
| 89 | struct page **tvc_upages; | 89 | struct page **tvc_upages; |
| 90 | /* Pointer to response header iovec */ | 90 | /* Pointer to response header iovec */ |
| 91 | struct iovec *tvc_resp_iov; | 91 | struct iovec tvc_resp_iov; |
| 92 | /* Pointer to vhost_scsi for our device */ | 92 | /* Pointer to vhost_scsi for our device */ |
| 93 | struct vhost_scsi *tvc_vhost; | 93 | struct vhost_scsi *tvc_vhost; |
| 94 | /* Pointer to vhost_virtqueue for the cmd */ | 94 | /* Pointer to vhost_virtqueue for the cmd */ |
| @@ -547,7 +547,7 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work) | |||
| 547 | memcpy(v_rsp.sense, cmd->tvc_sense_buf, | 547 | memcpy(v_rsp.sense, cmd->tvc_sense_buf, |
| 548 | se_cmd->scsi_sense_length); | 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 | cmd->tvc_in_iovs, sizeof(v_rsp)); | 551 | cmd->tvc_in_iovs, sizeof(v_rsp)); |
| 552 | ret = copy_to_iter(&v_rsp, sizeof(v_rsp), &iov_iter); | 552 | ret = copy_to_iter(&v_rsp, sizeof(v_rsp), &iov_iter); |
| 553 | if (likely(ret == sizeof(v_rsp))) { | 553 | if (likely(ret == sizeof(v_rsp))) { |
| @@ -1044,7 +1044,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) | |||
| 1044 | } | 1044 | } |
| 1045 | cmd->tvc_vhost = vs; | 1045 | cmd->tvc_vhost = vs; |
| 1046 | cmd->tvc_vq = vq; | 1046 | cmd->tvc_vq = vq; |
| 1047 | cmd->tvc_resp_iov = &vq->iov[out]; | 1047 | cmd->tvc_resp_iov = vq->iov[out]; |
| 1048 | cmd->tvc_in_iovs = in; | 1048 | cmd->tvc_in_iovs = in; |
| 1049 | 1049 | ||
| 1050 | pr_debug("vhost_scsi got command opcode: %#02x, lun: %d\n", | 1050 | pr_debug("vhost_scsi got command opcode: %#02x, lun: %d\n", |
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index e383ecdaca59..ed9c9eeedfe5 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
| @@ -167,7 +167,7 @@ static bool vring_use_dma_api(struct virtio_device *vdev) | |||
| 167 | * making all of the arch DMA ops work on the vring device itself | 167 | * making all of the arch DMA ops work on the vring device itself |
| 168 | * is a mess. For now, we use the parent device for DMA ops. | 168 | * is a mess. For now, we use the parent device for DMA ops. |
| 169 | */ | 169 | */ |
| 170 | struct device *vring_dma_dev(const struct vring_virtqueue *vq) | 170 | static struct device *vring_dma_dev(const struct vring_virtqueue *vq) |
| 171 | { | 171 | { |
| 172 | return vq->vq.vdev->dev.parent; | 172 | return vq->vq.vdev->dev.parent; |
| 173 | } | 173 | } |
diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c index 7487971f9f78..c1010f018bd8 100644 --- a/drivers/xen/xenbus/xenbus_dev_frontend.c +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c | |||
| @@ -316,7 +316,7 @@ static int xenbus_write_transaction(unsigned msg_type, | |||
| 316 | rc = -ENOMEM; | 316 | rc = -ENOMEM; |
| 317 | goto out; | 317 | goto out; |
| 318 | } | 318 | } |
| 319 | } else { | 319 | } else if (msg_type == XS_TRANSACTION_END) { |
| 320 | list_for_each_entry(trans, &u->transactions, list) | 320 | list_for_each_entry(trans, &u->transactions, list) |
| 321 | if (trans->handle.id == u->u.msg.tx_id) | 321 | if (trans->handle.id == u->u.msg.tx_id) |
| 322 | break; | 322 | break; |
| @@ -239,7 +239,12 @@ static struct dentry *aio_mount(struct file_system_type *fs_type, | |||
| 239 | static const struct dentry_operations ops = { | 239 | static const struct dentry_operations ops = { |
| 240 | .d_dname = simple_dname, | 240 | .d_dname = simple_dname, |
| 241 | }; | 241 | }; |
| 242 | return mount_pseudo(fs_type, "aio:", NULL, &ops, AIO_RING_MAGIC); | 242 | struct dentry *root = mount_pseudo(fs_type, "aio:", NULL, &ops, |
| 243 | AIO_RING_MAGIC); | ||
| 244 | |||
| 245 | if (!IS_ERR(root)) | ||
| 246 | root->d_sb->s_iflags |= SB_I_NOEXEC; | ||
| 247 | return root; | ||
| 243 | } | 248 | } |
| 244 | 249 | ||
| 245 | /* aio_setup | 250 | /* aio_setup |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 7f6aff3f72eb..e5495f37c6ed 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
| @@ -853,6 +853,7 @@ static int load_elf_binary(struct linux_binprm *bprm) | |||
| 853 | current->flags |= PF_RANDOMIZE; | 853 | current->flags |= PF_RANDOMIZE; |
| 854 | 854 | ||
| 855 | setup_new_exec(bprm); | 855 | setup_new_exec(bprm); |
| 856 | install_exec_creds(bprm); | ||
| 856 | 857 | ||
| 857 | /* Do this so that we can load the interpreter, if need be. We will | 858 | /* Do this so that we can load the interpreter, if need be. We will |
| 858 | change some of these later */ | 859 | change some of these later */ |
| @@ -1044,7 +1045,6 @@ static int load_elf_binary(struct linux_binprm *bprm) | |||
| 1044 | goto out; | 1045 | goto out; |
| 1045 | #endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */ | 1046 | #endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */ |
| 1046 | 1047 | ||
| 1047 | install_exec_creds(bprm); | ||
| 1048 | retval = create_elf_tables(bprm, &loc->elf_ex, | 1048 | retval = create_elf_tables(bprm, &loc->elf_ex, |
| 1049 | load_addr, interp_load_addr); | 1049 | load_addr, interp_load_addr); |
| 1050 | if (retval < 0) | 1050 | if (retval < 0) |
diff --git a/fs/block_dev.c b/fs/block_dev.c index c3cdde87cc8c..08ae99343d92 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
| @@ -249,7 +249,8 @@ struct super_block *freeze_bdev(struct block_device *bdev) | |||
| 249 | * thaw_bdev drops it. | 249 | * thaw_bdev drops it. |
| 250 | */ | 250 | */ |
| 251 | sb = get_super(bdev); | 251 | sb = get_super(bdev); |
| 252 | drop_super(sb); | 252 | if (sb) |
| 253 | drop_super(sb); | ||
| 253 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | 254 | mutex_unlock(&bdev->bd_fsfreeze_mutex); |
| 254 | return sb; | 255 | return sb; |
| 255 | } | 256 | } |
| @@ -646,7 +647,7 @@ static struct dentry *bd_mount(struct file_system_type *fs_type, | |||
| 646 | { | 647 | { |
| 647 | struct dentry *dent; | 648 | struct dentry *dent; |
| 648 | dent = mount_pseudo(fs_type, "bdev:", &bdev_sops, NULL, BDEVFS_MAGIC); | 649 | dent = mount_pseudo(fs_type, "bdev:", &bdev_sops, NULL, BDEVFS_MAGIC); |
| 649 | if (dent) | 650 | if (!IS_ERR(dent)) |
| 650 | dent->d_sb->s_iflags |= SB_I_CGROUPWB; | 651 | dent->d_sb->s_iflags |= SB_I_CGROUPWB; |
| 651 | return dent; | 652 | return dent; |
| 652 | } | 653 | } |
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 2b88439c2ee8..455a6b2fd539 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
| @@ -589,6 +589,7 @@ static void __merge_refs(struct list_head *head, int mode) | |||
| 589 | 589 | ||
| 590 | list_del(&ref2->list); | 590 | list_del(&ref2->list); |
| 591 | kmem_cache_free(btrfs_prelim_ref_cache, ref2); | 591 | kmem_cache_free(btrfs_prelim_ref_cache, ref2); |
| 592 | cond_resched(); | ||
| 592 | } | 593 | } |
| 593 | 594 | ||
| 594 | } | 595 | } |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 2fe8f89091a3..33fe03551105 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
| @@ -427,6 +427,7 @@ struct btrfs_space_info { | |||
| 427 | struct list_head ro_bgs; | 427 | struct list_head ro_bgs; |
| 428 | struct list_head priority_tickets; | 428 | struct list_head priority_tickets; |
| 429 | struct list_head tickets; | 429 | struct list_head tickets; |
| 430 | u64 tickets_id; | ||
| 430 | 431 | ||
| 431 | struct rw_semaphore groups_sem; | 432 | struct rw_semaphore groups_sem; |
| 432 | /* for block groups in our same type */ | 433 | /* for block groups in our same type */ |
| @@ -1028,6 +1029,7 @@ struct btrfs_fs_info { | |||
| 1028 | struct btrfs_workqueue *qgroup_rescan_workers; | 1029 | struct btrfs_workqueue *qgroup_rescan_workers; |
| 1029 | struct completion qgroup_rescan_completion; | 1030 | struct completion qgroup_rescan_completion; |
| 1030 | struct btrfs_work qgroup_rescan_work; | 1031 | struct btrfs_work qgroup_rescan_work; |
| 1032 | bool qgroup_rescan_running; /* protected by qgroup_rescan_lock */ | ||
| 1031 | 1033 | ||
| 1032 | /* filesystem state */ | 1034 | /* filesystem state */ |
| 1033 | unsigned long fs_state; | 1035 | unsigned long fs_state; |
| @@ -1079,6 +1081,8 @@ struct btrfs_fs_info { | |||
| 1079 | struct list_head pinned_chunks; | 1081 | struct list_head pinned_chunks; |
| 1080 | 1082 | ||
| 1081 | int creating_free_space_tree; | 1083 | int creating_free_space_tree; |
| 1084 | /* Used to record internally whether fs has been frozen */ | ||
| 1085 | int fs_frozen; | ||
| 1082 | }; | 1086 | }; |
| 1083 | 1087 | ||
| 1084 | struct btrfs_subvolume_writers { | 1088 | struct btrfs_subvolume_writers { |
| @@ -2578,7 +2582,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, | |||
| 2578 | struct btrfs_root *root, | 2582 | struct btrfs_root *root, |
| 2579 | u64 root_objectid, u64 owner, u64 offset, | 2583 | u64 root_objectid, u64 owner, u64 offset, |
| 2580 | struct btrfs_key *ins); | 2584 | struct btrfs_key *ins); |
| 2581 | int btrfs_reserve_extent(struct btrfs_root *root, u64 num_bytes, | 2585 | int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes, u64 num_bytes, |
| 2582 | u64 min_alloc_size, u64 empty_size, u64 hint_byte, | 2586 | u64 min_alloc_size, u64 empty_size, u64 hint_byte, |
| 2583 | struct btrfs_key *ins, int is_data, int delalloc); | 2587 | struct btrfs_key *ins, int is_data, int delalloc); |
| 2584 | int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 2588 | int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index d9ddcfc18c91..ac02e041464b 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c | |||
| @@ -541,7 +541,6 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info, | |||
| 541 | struct btrfs_delayed_ref_head *existing; | 541 | struct btrfs_delayed_ref_head *existing; |
| 542 | struct btrfs_delayed_ref_head *head_ref = NULL; | 542 | struct btrfs_delayed_ref_head *head_ref = NULL; |
| 543 | struct btrfs_delayed_ref_root *delayed_refs; | 543 | struct btrfs_delayed_ref_root *delayed_refs; |
| 544 | struct btrfs_qgroup_extent_record *qexisting; | ||
| 545 | int count_mod = 1; | 544 | int count_mod = 1; |
| 546 | int must_insert_reserved = 0; | 545 | int must_insert_reserved = 0; |
| 547 | 546 | ||
| @@ -606,10 +605,8 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info, | |||
| 606 | qrecord->num_bytes = num_bytes; | 605 | qrecord->num_bytes = num_bytes; |
| 607 | qrecord->old_roots = NULL; | 606 | qrecord->old_roots = NULL; |
| 608 | 607 | ||
| 609 | qexisting = btrfs_qgroup_insert_dirty_extent(fs_info, | 608 | if(btrfs_qgroup_insert_dirty_extent_nolock(fs_info, |
| 610 | delayed_refs, | 609 | delayed_refs, qrecord)) |
| 611 | qrecord); | ||
| 612 | if (qexisting) | ||
| 613 | kfree(qrecord); | 610 | kfree(qrecord); |
| 614 | } | 611 | } |
| 615 | 612 | ||
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 59febfb8d04a..54bc8c7c6bcd 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
| @@ -559,8 +559,29 @@ static noinline int check_leaf(struct btrfs_root *root, | |||
| 559 | u32 nritems = btrfs_header_nritems(leaf); | 559 | u32 nritems = btrfs_header_nritems(leaf); |
| 560 | int slot; | 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 | return 0; | 583 | return 0; |
| 584 | } | ||
| 564 | 585 | ||
| 565 | /* Check the 0 item */ | 586 | /* Check the 0 item */ |
| 566 | if (btrfs_item_offset_nr(leaf, 0) + btrfs_item_size_nr(leaf, 0) != | 587 | if (btrfs_item_offset_nr(leaf, 0) + btrfs_item_size_nr(leaf, 0) != |
| @@ -612,6 +633,19 @@ static noinline int check_leaf(struct btrfs_root *root, | |||
| 612 | return 0; | 633 | return 0; |
| 613 | } | 634 | } |
| 614 | 635 | ||
| 636 | static int check_node(struct btrfs_root *root, struct extent_buffer *node) | ||
| 637 | { | ||
| 638 | unsigned long nr = btrfs_header_nritems(node); | ||
| 639 | |||
| 640 | if (nr == 0 || nr > BTRFS_NODEPTRS_PER_BLOCK(root)) { | ||
| 641 | btrfs_crit(root->fs_info, | ||
| 642 | "corrupt node: block %llu root %llu nritems %lu", | ||
| 643 | node->start, root->objectid, nr); | ||
| 644 | return -EIO; | ||
| 645 | } | ||
| 646 | return 0; | ||
| 647 | } | ||
| 648 | |||
| 615 | static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, | 649 | static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, |
| 616 | u64 phy_offset, struct page *page, | 650 | u64 phy_offset, struct page *page, |
| 617 | u64 start, u64 end, int mirror) | 651 | u64 start, u64 end, int mirror) |
| @@ -682,6 +716,9 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, | |||
| 682 | ret = -EIO; | 716 | ret = -EIO; |
| 683 | } | 717 | } |
| 684 | 718 | ||
| 719 | if (found_level > 0 && check_node(root, eb)) | ||
| 720 | ret = -EIO; | ||
| 721 | |||
| 685 | if (!ret) | 722 | if (!ret) |
| 686 | set_extent_buffer_uptodate(eb); | 723 | set_extent_buffer_uptodate(eb); |
| 687 | err: | 724 | err: |
| @@ -1618,8 +1655,8 @@ fail: | |||
| 1618 | return ret; | 1655 | return ret; |
| 1619 | } | 1656 | } |
| 1620 | 1657 | ||
| 1621 | static struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info, | 1658 | struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info, |
| 1622 | u64 root_id) | 1659 | u64 root_id) |
| 1623 | { | 1660 | { |
| 1624 | struct btrfs_root *root; | 1661 | struct btrfs_root *root; |
| 1625 | 1662 | ||
| @@ -2298,6 +2335,7 @@ static void btrfs_init_qgroup(struct btrfs_fs_info *fs_info) | |||
| 2298 | fs_info->quota_enabled = 0; | 2335 | fs_info->quota_enabled = 0; |
| 2299 | fs_info->pending_quota_state = 0; | 2336 | fs_info->pending_quota_state = 0; |
| 2300 | fs_info->qgroup_ulist = NULL; | 2337 | fs_info->qgroup_ulist = NULL; |
| 2338 | fs_info->qgroup_rescan_running = false; | ||
| 2301 | mutex_init(&fs_info->qgroup_rescan_lock); | 2339 | mutex_init(&fs_info->qgroup_rescan_lock); |
| 2302 | } | 2340 | } |
| 2303 | 2341 | ||
| @@ -2624,6 +2662,7 @@ int open_ctree(struct super_block *sb, | |||
| 2624 | atomic_set(&fs_info->qgroup_op_seq, 0); | 2662 | atomic_set(&fs_info->qgroup_op_seq, 0); |
| 2625 | atomic_set(&fs_info->reada_works_cnt, 0); | 2663 | atomic_set(&fs_info->reada_works_cnt, 0); |
| 2626 | atomic64_set(&fs_info->tree_mod_seq, 0); | 2664 | atomic64_set(&fs_info->tree_mod_seq, 0); |
| 2665 | fs_info->fs_frozen = 0; | ||
| 2627 | fs_info->sb = sb; | 2666 | fs_info->sb = sb; |
| 2628 | fs_info->max_inline = BTRFS_DEFAULT_MAX_INLINE; | 2667 | fs_info->max_inline = BTRFS_DEFAULT_MAX_INLINE; |
| 2629 | fs_info->metadata_ratio = 0; | 2668 | fs_info->metadata_ratio = 0; |
| @@ -3739,8 +3778,15 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info, | |||
| 3739 | if (btrfs_root_refs(&root->root_item) == 0) | 3778 | if (btrfs_root_refs(&root->root_item) == 0) |
| 3740 | synchronize_srcu(&fs_info->subvol_srcu); | 3779 | synchronize_srcu(&fs_info->subvol_srcu); |
| 3741 | 3780 | ||
| 3742 | if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state)) | 3781 | if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state)) { |
| 3743 | btrfs_free_log(NULL, root); | 3782 | btrfs_free_log(NULL, root); |
| 3783 | if (root->reloc_root) { | ||
| 3784 | free_extent_buffer(root->reloc_root->node); | ||
| 3785 | free_extent_buffer(root->reloc_root->commit_root); | ||
| 3786 | btrfs_put_fs_root(root->reloc_root); | ||
| 3787 | root->reloc_root = NULL; | ||
| 3788 | } | ||
| 3789 | } | ||
| 3744 | 3790 | ||
| 3745 | if (root->free_ino_pinned) | 3791 | if (root->free_ino_pinned) |
| 3746 | __btrfs_remove_free_space_cache(root->free_ino_pinned); | 3792 | __btrfs_remove_free_space_cache(root->free_ino_pinned); |
| @@ -3851,7 +3897,7 @@ void close_ctree(struct btrfs_root *root) | |||
| 3851 | smp_mb(); | 3897 | smp_mb(); |
| 3852 | 3898 | ||
| 3853 | /* wait for the qgroup rescan worker to stop */ | 3899 | /* wait for the qgroup rescan worker to stop */ |
| 3854 | btrfs_qgroup_wait_for_completion(fs_info); | 3900 | btrfs_qgroup_wait_for_completion(fs_info, false); |
| 3855 | 3901 | ||
| 3856 | /* wait for the uuid_scan task to finish */ | 3902 | /* wait for the uuid_scan task to finish */ |
| 3857 | down(&fs_info->uuid_tree_rescan_sem); | 3903 | down(&fs_info->uuid_tree_rescan_sem); |
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index b3207a0e09f7..f19a982f5a4f 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h | |||
| @@ -68,6 +68,8 @@ struct extent_buffer *btrfs_find_tree_block(struct btrfs_fs_info *fs_info, | |||
| 68 | struct btrfs_root *btrfs_read_fs_root(struct btrfs_root *tree_root, | 68 | struct btrfs_root *btrfs_read_fs_root(struct btrfs_root *tree_root, |
| 69 | struct btrfs_key *location); | 69 | struct btrfs_key *location); |
| 70 | int btrfs_init_fs_root(struct btrfs_root *root); | 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 | int btrfs_insert_fs_root(struct btrfs_fs_info *fs_info, | 73 | int btrfs_insert_fs_root(struct btrfs_fs_info *fs_info, |
| 72 | struct btrfs_root *root); | 74 | struct btrfs_root *root); |
| 73 | void btrfs_free_fs_roots(struct btrfs_fs_info *fs_info); | 75 | void btrfs_free_fs_roots(struct btrfs_fs_info *fs_info); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 61b494e8e604..38c2df84cabd 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
| @@ -60,21 +60,6 @@ enum { | |||
| 60 | CHUNK_ALLOC_FORCE = 2, | 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 | static int update_block_group(struct btrfs_trans_handle *trans, | 63 | static int update_block_group(struct btrfs_trans_handle *trans, |
| 79 | struct btrfs_root *root, u64 bytenr, | 64 | struct btrfs_root *root, u64 bytenr, |
| 80 | u64 num_bytes, int alloc); | 65 | u64 num_bytes, int alloc); |
| @@ -104,9 +89,10 @@ static int find_next_key(struct btrfs_path *path, int level, | |||
| 104 | struct btrfs_key *key); | 89 | struct btrfs_key *key); |
| 105 | static void dump_space_info(struct btrfs_space_info *info, u64 bytes, | 90 | static void dump_space_info(struct btrfs_space_info *info, u64 bytes, |
| 106 | int dump_block_groups); | 91 | int dump_block_groups); |
| 107 | static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache, | 92 | static int btrfs_add_reserved_bytes(struct btrfs_block_group_cache *cache, |
| 108 | u64 num_bytes, int reserve, | 93 | u64 ram_bytes, u64 num_bytes, int delalloc); |
| 109 | int delalloc); | 94 | static int btrfs_free_reserved_bytes(struct btrfs_block_group_cache *cache, |
| 95 | u64 num_bytes, int delalloc); | ||
| 110 | static int block_rsv_use_bytes(struct btrfs_block_rsv *block_rsv, | 96 | static int block_rsv_use_bytes(struct btrfs_block_rsv *block_rsv, |
| 111 | u64 num_bytes); | 97 | u64 num_bytes); |
| 112 | int btrfs_pin_extent(struct btrfs_root *root, | 98 | int btrfs_pin_extent(struct btrfs_root *root, |
| @@ -3501,7 +3487,6 @@ again: | |||
| 3501 | dcs = BTRFS_DC_SETUP; | 3487 | dcs = BTRFS_DC_SETUP; |
| 3502 | else if (ret == -ENOSPC) | 3488 | else if (ret == -ENOSPC) |
| 3503 | set_bit(BTRFS_TRANS_CACHE_ENOSPC, &trans->transaction->flags); | 3489 | set_bit(BTRFS_TRANS_CACHE_ENOSPC, &trans->transaction->flags); |
| 3504 | btrfs_free_reserved_data_space(inode, 0, num_pages); | ||
| 3505 | 3490 | ||
| 3506 | out_put: | 3491 | out_put: |
| 3507 | iput(inode); | 3492 | iput(inode); |
| @@ -4472,6 +4457,15 @@ void check_system_chunk(struct btrfs_trans_handle *trans, | |||
| 4472 | } | 4457 | } |
| 4473 | } | 4458 | } |
| 4474 | 4459 | ||
| 4460 | /* | ||
| 4461 | * If force is CHUNK_ALLOC_FORCE: | ||
| 4462 | * - return 1 if it successfully allocates a chunk, | ||
| 4463 | * - return errors including -ENOSPC otherwise. | ||
| 4464 | * If force is NOT CHUNK_ALLOC_FORCE: | ||
| 4465 | * - return 0 if it doesn't need to allocate a new chunk, | ||
| 4466 | * - return 1 if it successfully allocates a chunk, | ||
| 4467 | * - return errors including -ENOSPC otherwise. | ||
| 4468 | */ | ||
| 4475 | static int do_chunk_alloc(struct btrfs_trans_handle *trans, | 4469 | static int do_chunk_alloc(struct btrfs_trans_handle *trans, |
| 4476 | struct btrfs_root *extent_root, u64 flags, int force) | 4470 | struct btrfs_root *extent_root, u64 flags, int force) |
| 4477 | { | 4471 | { |
| @@ -4882,7 +4876,7 @@ static int flush_space(struct btrfs_root *root, | |||
| 4882 | btrfs_get_alloc_profile(root, 0), | 4876 | btrfs_get_alloc_profile(root, 0), |
| 4883 | CHUNK_ALLOC_NO_FORCE); | 4877 | CHUNK_ALLOC_NO_FORCE); |
| 4884 | btrfs_end_transaction(trans, root); | 4878 | btrfs_end_transaction(trans, root); |
| 4885 | if (ret == -ENOSPC) | 4879 | if (ret > 0 || ret == -ENOSPC) |
| 4886 | ret = 0; | 4880 | ret = 0; |
| 4887 | break; | 4881 | break; |
| 4888 | case COMMIT_TRANS: | 4882 | case COMMIT_TRANS: |
| @@ -4907,11 +4901,6 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_root *root, | |||
| 4907 | u64 expected; | 4901 | u64 expected; |
| 4908 | u64 to_reclaim = 0; | 4902 | u64 to_reclaim = 0; |
| 4909 | 4903 | ||
| 4910 | to_reclaim = min_t(u64, num_online_cpus() * SZ_1M, SZ_16M); | ||
| 4911 | if (can_overcommit(root, space_info, to_reclaim, | ||
| 4912 | BTRFS_RESERVE_FLUSH_ALL)) | ||
| 4913 | return 0; | ||
| 4914 | |||
| 4915 | list_for_each_entry(ticket, &space_info->tickets, list) | 4904 | list_for_each_entry(ticket, &space_info->tickets, list) |
| 4916 | to_reclaim += ticket->bytes; | 4905 | to_reclaim += ticket->bytes; |
| 4917 | list_for_each_entry(ticket, &space_info->priority_tickets, list) | 4906 | list_for_each_entry(ticket, &space_info->priority_tickets, list) |
| @@ -4919,6 +4908,11 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_root *root, | |||
| 4919 | if (to_reclaim) | 4908 | if (to_reclaim) |
| 4920 | return to_reclaim; | 4909 | return to_reclaim; |
| 4921 | 4910 | ||
| 4911 | to_reclaim = min_t(u64, num_online_cpus() * SZ_1M, SZ_16M); | ||
| 4912 | if (can_overcommit(root, space_info, to_reclaim, | ||
| 4913 | BTRFS_RESERVE_FLUSH_ALL)) | ||
| 4914 | return 0; | ||
| 4915 | |||
| 4922 | used = space_info->bytes_used + space_info->bytes_reserved + | 4916 | used = space_info->bytes_used + space_info->bytes_reserved + |
| 4923 | space_info->bytes_pinned + space_info->bytes_readonly + | 4917 | space_info->bytes_pinned + space_info->bytes_readonly + |
| 4924 | space_info->bytes_may_use; | 4918 | space_info->bytes_may_use; |
| @@ -4972,12 +4966,12 @@ static void wake_all_tickets(struct list_head *head) | |||
| 4972 | */ | 4966 | */ |
| 4973 | static void btrfs_async_reclaim_metadata_space(struct work_struct *work) | 4967 | static void btrfs_async_reclaim_metadata_space(struct work_struct *work) |
| 4974 | { | 4968 | { |
| 4975 | struct reserve_ticket *last_ticket = NULL; | ||
| 4976 | struct btrfs_fs_info *fs_info; | 4969 | struct btrfs_fs_info *fs_info; |
| 4977 | struct btrfs_space_info *space_info; | 4970 | struct btrfs_space_info *space_info; |
| 4978 | u64 to_reclaim; | 4971 | u64 to_reclaim; |
| 4979 | int flush_state; | 4972 | int flush_state; |
| 4980 | int commit_cycles = 0; | 4973 | int commit_cycles = 0; |
| 4974 | u64 last_tickets_id; | ||
| 4981 | 4975 | ||
| 4982 | fs_info = container_of(work, struct btrfs_fs_info, async_reclaim_work); | 4976 | fs_info = container_of(work, struct btrfs_fs_info, async_reclaim_work); |
| 4983 | space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA); | 4977 | space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA); |
| @@ -4990,8 +4984,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) | |||
| 4990 | spin_unlock(&space_info->lock); | 4984 | spin_unlock(&space_info->lock); |
| 4991 | return; | 4985 | return; |
| 4992 | } | 4986 | } |
| 4993 | last_ticket = list_first_entry(&space_info->tickets, | 4987 | last_tickets_id = space_info->tickets_id; |
| 4994 | struct reserve_ticket, list); | ||
| 4995 | spin_unlock(&space_info->lock); | 4988 | spin_unlock(&space_info->lock); |
| 4996 | 4989 | ||
| 4997 | flush_state = FLUSH_DELAYED_ITEMS_NR; | 4990 | flush_state = FLUSH_DELAYED_ITEMS_NR; |
| @@ -5011,10 +5004,10 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) | |||
| 5011 | space_info); | 5004 | space_info); |
| 5012 | ticket = list_first_entry(&space_info->tickets, | 5005 | ticket = list_first_entry(&space_info->tickets, |
| 5013 | struct reserve_ticket, list); | 5006 | struct reserve_ticket, list); |
| 5014 | if (last_ticket == ticket) { | 5007 | if (last_tickets_id == space_info->tickets_id) { |
| 5015 | flush_state++; | 5008 | flush_state++; |
| 5016 | } else { | 5009 | } else { |
| 5017 | last_ticket = ticket; | 5010 | last_tickets_id = space_info->tickets_id; |
| 5018 | flush_state = FLUSH_DELAYED_ITEMS_NR; | 5011 | flush_state = FLUSH_DELAYED_ITEMS_NR; |
| 5019 | if (commit_cycles) | 5012 | if (commit_cycles) |
| 5020 | commit_cycles--; | 5013 | commit_cycles--; |
| @@ -5390,6 +5383,7 @@ again: | |||
| 5390 | list_del_init(&ticket->list); | 5383 | list_del_init(&ticket->list); |
| 5391 | num_bytes -= ticket->bytes; | 5384 | num_bytes -= ticket->bytes; |
| 5392 | ticket->bytes = 0; | 5385 | ticket->bytes = 0; |
| 5386 | space_info->tickets_id++; | ||
| 5393 | wake_up(&ticket->wait); | 5387 | wake_up(&ticket->wait); |
| 5394 | } else { | 5388 | } else { |
| 5395 | ticket->bytes -= num_bytes; | 5389 | ticket->bytes -= num_bytes; |
| @@ -5432,6 +5426,7 @@ again: | |||
| 5432 | num_bytes -= ticket->bytes; | 5426 | num_bytes -= ticket->bytes; |
| 5433 | space_info->bytes_may_use += ticket->bytes; | 5427 | space_info->bytes_may_use += ticket->bytes; |
| 5434 | ticket->bytes = 0; | 5428 | ticket->bytes = 0; |
| 5429 | space_info->tickets_id++; | ||
| 5435 | wake_up(&ticket->wait); | 5430 | wake_up(&ticket->wait); |
| 5436 | } else { | 5431 | } else { |
| 5437 | trace_btrfs_space_reservation(fs_info, "space_info", | 5432 | trace_btrfs_space_reservation(fs_info, "space_info", |
| @@ -6497,19 +6492,15 @@ void btrfs_wait_block_group_reservations(struct btrfs_block_group_cache *bg) | |||
| 6497 | } | 6492 | } |
| 6498 | 6493 | ||
| 6499 | /** | 6494 | /** |
| 6500 | * btrfs_update_reserved_bytes - update the block_group and space info counters | 6495 | * btrfs_add_reserved_bytes - update the block_group and space info counters |
| 6501 | * @cache: The cache we are manipulating | 6496 | * @cache: The cache we are manipulating |
| 6497 | * @ram_bytes: The number of bytes of file content, and will be same to | ||
| 6498 | * @num_bytes except for the compress path. | ||
| 6502 | * @num_bytes: The number of bytes in question | 6499 | * @num_bytes: The number of bytes in question |
| 6503 | * @reserve: One of the reservation enums | ||
| 6504 | * @delalloc: The blocks are allocated for the delalloc write | 6500 | * @delalloc: The blocks are allocated for the delalloc write |
| 6505 | * | 6501 | * |
| 6506 | * This is called by the allocator when it reserves space, or by somebody who is | 6502 | * This is called by the allocator when it reserves space. Metadata |
| 6507 | * freeing space that was never actually used on disk. For example if you | 6503 | * reservations should be called with RESERVE_ALLOC so we do the proper |
| 6508 | * reserve some space for a new leaf in transaction A and before transaction A | ||
| 6509 | * commits you free that leaf, you call this with reserve set to 0 in order to | ||
| 6510 | * clear the reservation. | ||
| 6511 | * | ||
| 6512 | * Metadata reservations should be called with RESERVE_ALLOC so we do the proper | ||
| 6513 | * ENOSPC accounting. For data we handle the reservation through clearing the | 6504 | * ENOSPC accounting. For data we handle the reservation through clearing the |
| 6514 | * delalloc bits in the io_tree. We have to do this since we could end up | 6505 | * delalloc bits in the io_tree. We have to do this since we could end up |
| 6515 | * allocating less disk space for the amount of data we have reserved in the | 6506 | * allocating less disk space for the amount of data we have reserved in the |
| @@ -6519,44 +6510,63 @@ void btrfs_wait_block_group_reservations(struct btrfs_block_group_cache *bg) | |||
| 6519 | * make the reservation and return -EAGAIN, otherwise this function always | 6510 | * make the reservation and return -EAGAIN, otherwise this function always |
| 6520 | * succeeds. | 6511 | * succeeds. |
| 6521 | */ | 6512 | */ |
| 6522 | static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache, | 6513 | static int btrfs_add_reserved_bytes(struct btrfs_block_group_cache *cache, |
| 6523 | u64 num_bytes, int reserve, int delalloc) | 6514 | u64 ram_bytes, u64 num_bytes, int delalloc) |
| 6524 | { | 6515 | { |
| 6525 | struct btrfs_space_info *space_info = cache->space_info; | 6516 | struct btrfs_space_info *space_info = cache->space_info; |
| 6526 | int ret = 0; | 6517 | int ret = 0; |
| 6527 | 6518 | ||
| 6528 | spin_lock(&space_info->lock); | 6519 | spin_lock(&space_info->lock); |
| 6529 | spin_lock(&cache->lock); | 6520 | spin_lock(&cache->lock); |
| 6530 | if (reserve != RESERVE_FREE) { | 6521 | if (cache->ro) { |
| 6531 | if (cache->ro) { | 6522 | ret = -EAGAIN; |
| 6532 | ret = -EAGAIN; | ||
| 6533 | } else { | ||
| 6534 | cache->reserved += num_bytes; | ||
| 6535 | space_info->bytes_reserved += num_bytes; | ||
| 6536 | if (reserve == RESERVE_ALLOC) { | ||
| 6537 | trace_btrfs_space_reservation(cache->fs_info, | ||
| 6538 | "space_info", space_info->flags, | ||
| 6539 | num_bytes, 0); | ||
| 6540 | space_info->bytes_may_use -= num_bytes; | ||
| 6541 | } | ||
| 6542 | |||
| 6543 | if (delalloc) | ||
| 6544 | cache->delalloc_bytes += num_bytes; | ||
| 6545 | } | ||
| 6546 | } else { | 6523 | } else { |
| 6547 | if (cache->ro) | 6524 | cache->reserved += num_bytes; |
| 6548 | space_info->bytes_readonly += num_bytes; | 6525 | space_info->bytes_reserved += num_bytes; |
| 6549 | cache->reserved -= num_bytes; | ||
| 6550 | space_info->bytes_reserved -= num_bytes; | ||
| 6551 | 6526 | ||
| 6527 | trace_btrfs_space_reservation(cache->fs_info, | ||
| 6528 | "space_info", space_info->flags, | ||
| 6529 | ram_bytes, 0); | ||
| 6530 | space_info->bytes_may_use -= ram_bytes; | ||
| 6552 | if (delalloc) | 6531 | if (delalloc) |
| 6553 | cache->delalloc_bytes -= num_bytes; | 6532 | cache->delalloc_bytes += num_bytes; |
| 6554 | } | 6533 | } |
| 6555 | spin_unlock(&cache->lock); | 6534 | spin_unlock(&cache->lock); |
| 6556 | spin_unlock(&space_info->lock); | 6535 | spin_unlock(&space_info->lock); |
| 6557 | return ret; | 6536 | return ret; |
| 6558 | } | 6537 | } |
| 6559 | 6538 | ||
| 6539 | /** | ||
| 6540 | * btrfs_free_reserved_bytes - update the block_group and space info counters | ||
| 6541 | * @cache: The cache we are manipulating | ||
| 6542 | * @num_bytes: The number of bytes in question | ||
| 6543 | * @delalloc: The blocks are allocated for the delalloc write | ||
| 6544 | * | ||
| 6545 | * This is called by somebody who is freeing space that was never actually used | ||
| 6546 | * on disk. For example if you reserve some space for a new leaf in transaction | ||
| 6547 | * A and before transaction A commits you free that leaf, you call this with | ||
| 6548 | * reserve set to 0 in order to clear the reservation. | ||
| 6549 | */ | ||
| 6550 | |||
| 6551 | static int btrfs_free_reserved_bytes(struct btrfs_block_group_cache *cache, | ||
| 6552 | u64 num_bytes, int delalloc) | ||
| 6553 | { | ||
| 6554 | struct btrfs_space_info *space_info = cache->space_info; | ||
| 6555 | int ret = 0; | ||
| 6556 | |||
| 6557 | spin_lock(&space_info->lock); | ||
| 6558 | spin_lock(&cache->lock); | ||
| 6559 | if (cache->ro) | ||
| 6560 | space_info->bytes_readonly += num_bytes; | ||
| 6561 | cache->reserved -= num_bytes; | ||
| 6562 | space_info->bytes_reserved -= num_bytes; | ||
| 6563 | |||
| 6564 | if (delalloc) | ||
| 6565 | cache->delalloc_bytes -= num_bytes; | ||
| 6566 | spin_unlock(&cache->lock); | ||
| 6567 | spin_unlock(&space_info->lock); | ||
| 6568 | return ret; | ||
| 6569 | } | ||
| 6560 | void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, | 6570 | void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, |
| 6561 | struct btrfs_root *root) | 6571 | struct btrfs_root *root) |
| 6562 | { | 6572 | { |
| @@ -7191,7 +7201,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans, | |||
| 7191 | WARN_ON(test_bit(EXTENT_BUFFER_DIRTY, &buf->bflags)); | 7201 | WARN_ON(test_bit(EXTENT_BUFFER_DIRTY, &buf->bflags)); |
| 7192 | 7202 | ||
| 7193 | btrfs_add_free_space(cache, buf->start, buf->len); | 7203 | btrfs_add_free_space(cache, buf->start, buf->len); |
| 7194 | btrfs_update_reserved_bytes(cache, buf->len, RESERVE_FREE, 0); | 7204 | btrfs_free_reserved_bytes(cache, buf->len, 0); |
| 7195 | btrfs_put_block_group(cache); | 7205 | btrfs_put_block_group(cache); |
| 7196 | trace_btrfs_reserved_extent_free(root, buf->start, buf->len); | 7206 | trace_btrfs_reserved_extent_free(root, buf->start, buf->len); |
| 7197 | pin = 0; | 7207 | pin = 0; |
| @@ -7416,9 +7426,9 @@ btrfs_release_block_group(struct btrfs_block_group_cache *cache, | |||
| 7416 | * the free space extent currently. | 7426 | * the free space extent currently. |
| 7417 | */ | 7427 | */ |
| 7418 | static noinline int find_free_extent(struct btrfs_root *orig_root, | 7428 | static noinline int find_free_extent(struct btrfs_root *orig_root, |
| 7419 | u64 num_bytes, u64 empty_size, | 7429 | u64 ram_bytes, u64 num_bytes, u64 empty_size, |
| 7420 | u64 hint_byte, struct btrfs_key *ins, | 7430 | u64 hint_byte, struct btrfs_key *ins, |
| 7421 | u64 flags, int delalloc) | 7431 | u64 flags, int delalloc) |
| 7422 | { | 7432 | { |
| 7423 | int ret = 0; | 7433 | int ret = 0; |
| 7424 | struct btrfs_root *root = orig_root->fs_info->extent_root; | 7434 | struct btrfs_root *root = orig_root->fs_info->extent_root; |
| @@ -7430,8 +7440,6 @@ static noinline int find_free_extent(struct btrfs_root *orig_root, | |||
| 7430 | struct btrfs_space_info *space_info; | 7440 | struct btrfs_space_info *space_info; |
| 7431 | int loop = 0; | 7441 | int loop = 0; |
| 7432 | int index = __get_raid_index(flags); | 7442 | int index = __get_raid_index(flags); |
| 7433 | int alloc_type = (flags & BTRFS_BLOCK_GROUP_DATA) ? | ||
| 7434 | RESERVE_ALLOC_NO_ACCOUNT : RESERVE_ALLOC; | ||
| 7435 | bool failed_cluster_refill = false; | 7443 | bool failed_cluster_refill = false; |
| 7436 | bool failed_alloc = false; | 7444 | bool failed_alloc = false; |
| 7437 | bool use_cluster = true; | 7445 | bool use_cluster = true; |
| @@ -7763,8 +7771,8 @@ checks: | |||
| 7763 | search_start - offset); | 7771 | search_start - offset); |
| 7764 | BUG_ON(offset > search_start); | 7772 | BUG_ON(offset > search_start); |
| 7765 | 7773 | ||
| 7766 | ret = btrfs_update_reserved_bytes(block_group, num_bytes, | 7774 | ret = btrfs_add_reserved_bytes(block_group, ram_bytes, |
| 7767 | alloc_type, delalloc); | 7775 | num_bytes, delalloc); |
| 7768 | if (ret == -EAGAIN) { | 7776 | if (ret == -EAGAIN) { |
| 7769 | btrfs_add_free_space(block_group, offset, num_bytes); | 7777 | btrfs_add_free_space(block_group, offset, num_bytes); |
| 7770 | goto loop; | 7778 | goto loop; |
| @@ -7936,7 +7944,7 @@ again: | |||
| 7936 | up_read(&info->groups_sem); | 7944 | up_read(&info->groups_sem); |
| 7937 | } | 7945 | } |
| 7938 | 7946 | ||
| 7939 | int btrfs_reserve_extent(struct btrfs_root *root, | 7947 | int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes, |
| 7940 | u64 num_bytes, u64 min_alloc_size, | 7948 | u64 num_bytes, u64 min_alloc_size, |
| 7941 | u64 empty_size, u64 hint_byte, | 7949 | u64 empty_size, u64 hint_byte, |
| 7942 | struct btrfs_key *ins, int is_data, int delalloc) | 7950 | struct btrfs_key *ins, int is_data, int delalloc) |
| @@ -7948,8 +7956,8 @@ int btrfs_reserve_extent(struct btrfs_root *root, | |||
| 7948 | flags = btrfs_get_alloc_profile(root, is_data); | 7956 | flags = btrfs_get_alloc_profile(root, is_data); |
| 7949 | again: | 7957 | again: |
| 7950 | WARN_ON(num_bytes < root->sectorsize); | 7958 | WARN_ON(num_bytes < root->sectorsize); |
| 7951 | ret = find_free_extent(root, num_bytes, empty_size, hint_byte, ins, | 7959 | ret = find_free_extent(root, ram_bytes, num_bytes, empty_size, |
| 7952 | flags, delalloc); | 7960 | hint_byte, ins, flags, delalloc); |
| 7953 | if (!ret && !is_data) { | 7961 | if (!ret && !is_data) { |
| 7954 | btrfs_dec_block_group_reservations(root->fs_info, | 7962 | btrfs_dec_block_group_reservations(root->fs_info, |
| 7955 | ins->objectid); | 7963 | ins->objectid); |
| @@ -7958,6 +7966,7 @@ again: | |||
| 7958 | num_bytes = min(num_bytes >> 1, ins->offset); | 7966 | num_bytes = min(num_bytes >> 1, ins->offset); |
| 7959 | num_bytes = round_down(num_bytes, root->sectorsize); | 7967 | num_bytes = round_down(num_bytes, root->sectorsize); |
| 7960 | num_bytes = max(num_bytes, min_alloc_size); | 7968 | num_bytes = max(num_bytes, min_alloc_size); |
| 7969 | ram_bytes = num_bytes; | ||
| 7961 | if (num_bytes == min_alloc_size) | 7970 | if (num_bytes == min_alloc_size) |
| 7962 | final_tried = true; | 7971 | final_tried = true; |
| 7963 | goto again; | 7972 | goto again; |
| @@ -7995,7 +8004,7 @@ static int __btrfs_free_reserved_extent(struct btrfs_root *root, | |||
| 7995 | if (btrfs_test_opt(root->fs_info, DISCARD)) | 8004 | if (btrfs_test_opt(root->fs_info, DISCARD)) |
| 7996 | ret = btrfs_discard_extent(root, start, len, NULL); | 8005 | ret = btrfs_discard_extent(root, start, len, NULL); |
| 7997 | btrfs_add_free_space(cache, start, len); | 8006 | btrfs_add_free_space(cache, start, len); |
| 7998 | btrfs_update_reserved_bytes(cache, len, RESERVE_FREE, delalloc); | 8007 | btrfs_free_reserved_bytes(cache, len, delalloc); |
| 7999 | trace_btrfs_reserved_extent_free(root, start, len); | 8008 | trace_btrfs_reserved_extent_free(root, start, len); |
| 8000 | } | 8009 | } |
| 8001 | 8010 | ||
| @@ -8208,6 +8217,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, | |||
| 8208 | { | 8217 | { |
| 8209 | int ret; | 8218 | int ret; |
| 8210 | struct btrfs_block_group_cache *block_group; | 8219 | struct btrfs_block_group_cache *block_group; |
| 8220 | struct btrfs_space_info *space_info; | ||
| 8211 | 8221 | ||
| 8212 | /* | 8222 | /* |
| 8213 | * Mixed block groups will exclude before processing the log so we only | 8223 | * Mixed block groups will exclude before processing the log so we only |
| @@ -8223,9 +8233,14 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, | |||
| 8223 | if (!block_group) | 8233 | if (!block_group) |
| 8224 | return -EINVAL; | 8234 | return -EINVAL; |
| 8225 | 8235 | ||
| 8226 | ret = btrfs_update_reserved_bytes(block_group, ins->offset, | 8236 | space_info = block_group->space_info; |
| 8227 | RESERVE_ALLOC_NO_ACCOUNT, 0); | 8237 | spin_lock(&space_info->lock); |
| 8228 | BUG_ON(ret); /* logic error */ | 8238 | spin_lock(&block_group->lock); |
| 8239 | space_info->bytes_reserved += ins->offset; | ||
| 8240 | block_group->reserved += ins->offset; | ||
| 8241 | spin_unlock(&block_group->lock); | ||
| 8242 | spin_unlock(&space_info->lock); | ||
| 8243 | |||
| 8229 | ret = alloc_reserved_file_extent(trans, root, 0, root_objectid, | 8244 | ret = alloc_reserved_file_extent(trans, root, 0, root_objectid, |
| 8230 | 0, owner, offset, ins, 1); | 8245 | 0, owner, offset, ins, 1); |
| 8231 | btrfs_put_block_group(block_group); | 8246 | btrfs_put_block_group(block_group); |
| @@ -8368,7 +8383,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, | |||
| 8368 | if (IS_ERR(block_rsv)) | 8383 | if (IS_ERR(block_rsv)) |
| 8369 | return ERR_CAST(block_rsv); | 8384 | return ERR_CAST(block_rsv); |
| 8370 | 8385 | ||
| 8371 | ret = btrfs_reserve_extent(root, blocksize, blocksize, | 8386 | ret = btrfs_reserve_extent(root, blocksize, blocksize, blocksize, |
| 8372 | empty_size, hint, &ins, 0, 0); | 8387 | empty_size, hint, &ins, 0, 0); |
| 8373 | if (ret) | 8388 | if (ret) |
| 8374 | goto out_unuse; | 8389 | goto out_unuse; |
| @@ -8521,35 +8536,6 @@ reada: | |||
| 8521 | wc->reada_slot = slot; | 8536 | wc->reada_slot = slot; |
| 8522 | } | 8537 | } |
| 8523 | 8538 | ||
| 8524 | /* | ||
| 8525 | * These may not be seen by the usual inc/dec ref code so we have to | ||
| 8526 | * add them here. | ||
| 8527 | */ | ||
| 8528 | static int record_one_subtree_extent(struct btrfs_trans_handle *trans, | ||
| 8529 | struct btrfs_root *root, u64 bytenr, | ||
| 8530 | u64 num_bytes) | ||
| 8531 | { | ||
| 8532 | struct btrfs_qgroup_extent_record *qrecord; | ||
| 8533 | struct btrfs_delayed_ref_root *delayed_refs; | ||
| 8534 | |||
| 8535 | qrecord = kmalloc(sizeof(*qrecord), GFP_NOFS); | ||
| 8536 | if (!qrecord) | ||
| 8537 | return -ENOMEM; | ||
| 8538 | |||
| 8539 | qrecord->bytenr = bytenr; | ||
| 8540 | qrecord->num_bytes = num_bytes; | ||
| 8541 | qrecord->old_roots = NULL; | ||
| 8542 | |||
| 8543 | delayed_refs = &trans->transaction->delayed_refs; | ||
| 8544 | spin_lock(&delayed_refs->lock); | ||
| 8545 | if (btrfs_qgroup_insert_dirty_extent(trans->fs_info, | ||
| 8546 | delayed_refs, qrecord)) | ||
| 8547 | kfree(qrecord); | ||
| 8548 | spin_unlock(&delayed_refs->lock); | ||
| 8549 | |||
| 8550 | return 0; | ||
| 8551 | } | ||
| 8552 | |||
| 8553 | static int account_leaf_items(struct btrfs_trans_handle *trans, | 8539 | static int account_leaf_items(struct btrfs_trans_handle *trans, |
| 8554 | struct btrfs_root *root, | 8540 | struct btrfs_root *root, |
| 8555 | struct extent_buffer *eb) | 8541 | struct extent_buffer *eb) |
| @@ -8583,7 +8569,8 @@ static int account_leaf_items(struct btrfs_trans_handle *trans, | |||
| 8583 | 8569 | ||
| 8584 | num_bytes = btrfs_file_extent_disk_num_bytes(eb, fi); | 8570 | num_bytes = btrfs_file_extent_disk_num_bytes(eb, fi); |
| 8585 | 8571 | ||
| 8586 | ret = record_one_subtree_extent(trans, root, bytenr, num_bytes); | 8572 | ret = btrfs_qgroup_insert_dirty_extent(trans, root->fs_info, |
| 8573 | bytenr, num_bytes, GFP_NOFS); | ||
| 8587 | if (ret) | 8574 | if (ret) |
| 8588 | return ret; | 8575 | return ret; |
| 8589 | } | 8576 | } |
| @@ -8732,8 +8719,9 @@ walk_down: | |||
| 8732 | btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK); | 8719 | btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK); |
| 8733 | path->locks[level] = BTRFS_READ_LOCK_BLOCKING; | 8720 | path->locks[level] = BTRFS_READ_LOCK_BLOCKING; |
| 8734 | 8721 | ||
| 8735 | ret = record_one_subtree_extent(trans, root, child_bytenr, | 8722 | ret = btrfs_qgroup_insert_dirty_extent(trans, |
| 8736 | root->nodesize); | 8723 | root->fs_info, child_bytenr, |
| 8724 | root->nodesize, GFP_NOFS); | ||
| 8737 | if (ret) | 8725 | if (ret) |
| 8738 | goto out; | 8726 | goto out; |
| 8739 | } | 8727 | } |
| @@ -9906,6 +9894,7 @@ static int find_first_block_group(struct btrfs_root *root, | |||
| 9906 | } else { | 9894 | } else { |
| 9907 | ret = 0; | 9895 | ret = 0; |
| 9908 | } | 9896 | } |
| 9897 | free_extent_map(em); | ||
| 9909 | goto out; | 9898 | goto out; |
| 9910 | } | 9899 | } |
| 9911 | path->slots[0]++; | 9900 | path->slots[0]++; |
| @@ -9942,6 +9931,7 @@ void btrfs_put_block_group_cache(struct btrfs_fs_info *info) | |||
| 9942 | block_group->iref = 0; | 9931 | block_group->iref = 0; |
| 9943 | block_group->inode = NULL; | 9932 | block_group->inode = NULL; |
| 9944 | spin_unlock(&block_group->lock); | 9933 | spin_unlock(&block_group->lock); |
| 9934 | ASSERT(block_group->io_ctl.inode == NULL); | ||
| 9945 | iput(inode); | 9935 | iput(inode); |
| 9946 | last = block_group->key.objectid + block_group->key.offset; | 9936 | last = block_group->key.objectid + block_group->key.offset; |
| 9947 | btrfs_put_block_group(block_group); | 9937 | btrfs_put_block_group(block_group); |
| @@ -9999,6 +9989,10 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info) | |||
| 9999 | free_excluded_extents(info->extent_root, block_group); | 9989 | free_excluded_extents(info->extent_root, block_group); |
| 10000 | 9990 | ||
| 10001 | btrfs_remove_free_space_cache(block_group); | 9991 | btrfs_remove_free_space_cache(block_group); |
| 9992 | ASSERT(list_empty(&block_group->dirty_list)); | ||
| 9993 | ASSERT(list_empty(&block_group->io_list)); | ||
| 9994 | ASSERT(list_empty(&block_group->bg_list)); | ||
| 9995 | ASSERT(atomic_read(&block_group->count) == 1); | ||
| 10002 | btrfs_put_block_group(block_group); | 9996 | btrfs_put_block_group(block_group); |
| 10003 | 9997 | ||
| 10004 | spin_lock(&info->block_group_cache_lock); | 9998 | spin_lock(&info->block_group_cache_lock); |
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index bc2729a7612d..28cd88fccc7e 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #define EXTENT_DAMAGED (1U << 14) | 20 | #define EXTENT_DAMAGED (1U << 14) |
| 21 | #define EXTENT_NORESERVE (1U << 15) | 21 | #define EXTENT_NORESERVE (1U << 15) |
| 22 | #define EXTENT_QGROUP_RESERVED (1U << 16) | 22 | #define EXTENT_QGROUP_RESERVED (1U << 16) |
| 23 | #define EXTENT_CLEAR_DATA_RESV (1U << 17) | ||
| 23 | #define EXTENT_IOBITS (EXTENT_LOCKED | EXTENT_WRITEBACK) | 24 | #define EXTENT_IOBITS (EXTENT_LOCKED | EXTENT_WRITEBACK) |
| 24 | #define EXTENT_CTLBITS (EXTENT_DO_ACCOUNTING | EXTENT_FIRST_DELALLOC) | 25 | #define EXTENT_CTLBITS (EXTENT_DO_ACCOUNTING | EXTENT_FIRST_DELALLOC) |
| 25 | 26 | ||
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 5842423f8f47..fea31a4a6e36 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
| @@ -2070,7 +2070,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) | |||
| 2070 | } | 2070 | } |
| 2071 | trans->sync = true; | 2071 | trans->sync = true; |
| 2072 | 2072 | ||
| 2073 | btrfs_init_log_ctx(&ctx); | 2073 | btrfs_init_log_ctx(&ctx, inode); |
| 2074 | 2074 | ||
| 2075 | ret = btrfs_log_dentry_safe(trans, root, dentry, start, end, &ctx); | 2075 | ret = btrfs_log_dentry_safe(trans, root, dentry, start, end, &ctx); |
| 2076 | if (ret < 0) { | 2076 | if (ret < 0) { |
| @@ -2675,6 +2675,7 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
| 2675 | 2675 | ||
| 2676 | alloc_start = round_down(offset, blocksize); | 2676 | alloc_start = round_down(offset, blocksize); |
| 2677 | alloc_end = round_up(offset + len, blocksize); | 2677 | alloc_end = round_up(offset + len, blocksize); |
| 2678 | cur_offset = alloc_start; | ||
| 2678 | 2679 | ||
| 2679 | /* Make sure we aren't being give some crap mode */ | 2680 | /* Make sure we aren't being give some crap mode */ |
| 2680 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) | 2681 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) |
| @@ -2767,7 +2768,6 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
| 2767 | 2768 | ||
| 2768 | /* First, check if we exceed the qgroup limit */ | 2769 | /* First, check if we exceed the qgroup limit */ |
| 2769 | INIT_LIST_HEAD(&reserve_list); | 2770 | INIT_LIST_HEAD(&reserve_list); |
| 2770 | cur_offset = alloc_start; | ||
| 2771 | while (1) { | 2771 | while (1) { |
| 2772 | em = btrfs_get_extent(inode, NULL, 0, cur_offset, | 2772 | em = btrfs_get_extent(inode, NULL, 0, cur_offset, |
| 2773 | alloc_end - cur_offset, 0); | 2773 | alloc_end - cur_offset, 0); |
| @@ -2794,6 +2794,14 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
| 2794 | last_byte - cur_offset); | 2794 | last_byte - cur_offset); |
| 2795 | if (ret < 0) | 2795 | if (ret < 0) |
| 2796 | break; | 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 | free_extent_map(em); | 2806 | free_extent_map(em); |
| 2799 | cur_offset = last_byte; | 2807 | cur_offset = last_byte; |
| @@ -2811,6 +2819,9 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
| 2811 | range->start, | 2819 | range->start, |
| 2812 | range->len, 1 << inode->i_blkbits, | 2820 | range->len, 1 << inode->i_blkbits, |
| 2813 | offset + len, &alloc_hint); | 2821 | offset + len, &alloc_hint); |
| 2822 | else | ||
| 2823 | btrfs_free_reserved_data_space(inode, range->start, | ||
| 2824 | range->len); | ||
| 2814 | list_del(&range->list); | 2825 | list_del(&range->list); |
| 2815 | kfree(range); | 2826 | kfree(range); |
| 2816 | } | 2827 | } |
| @@ -2845,18 +2856,11 @@ out_unlock: | |||
| 2845 | unlock_extent_cached(&BTRFS_I(inode)->io_tree, alloc_start, locked_end, | 2856 | unlock_extent_cached(&BTRFS_I(inode)->io_tree, alloc_start, locked_end, |
| 2846 | &cached_state, GFP_KERNEL); | 2857 | &cached_state, GFP_KERNEL); |
| 2847 | out: | 2858 | out: |
| 2848 | /* | ||
| 2849 | * As we waited the extent range, the data_rsv_map must be empty | ||
| 2850 | * in the range, as written data range will be released from it. | ||
| 2851 | * And for prealloacted extent, it will also be released when | ||
| 2852 | * its metadata is written. | ||
| 2853 | * So this is completely used as cleanup. | ||
| 2854 | */ | ||
| 2855 | btrfs_qgroup_free_data(inode, alloc_start, alloc_end - alloc_start); | ||
| 2856 | inode_unlock(inode); | 2859 | inode_unlock(inode); |
| 2857 | /* Let go of our reservation. */ | 2860 | /* Let go of our reservation. */ |
| 2858 | btrfs_free_reserved_data_space(inode, alloc_start, | 2861 | if (ret != 0) |
| 2859 | alloc_end - alloc_start); | 2862 | btrfs_free_reserved_data_space(inode, alloc_start, |
| 2863 | alloc_end - cur_offset); | ||
| 2860 | return ret; | 2864 | return ret; |
| 2861 | } | 2865 | } |
| 2862 | 2866 | ||
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c index aa6fabaee72e..359ee861b5a4 100644 --- a/fs/btrfs/inode-map.c +++ b/fs/btrfs/inode-map.c | |||
| @@ -495,10 +495,9 @@ again: | |||
| 495 | ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, prealloc, | 495 | ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, prealloc, |
| 496 | prealloc, prealloc, &alloc_hint); | 496 | prealloc, prealloc, &alloc_hint); |
| 497 | if (ret) { | 497 | if (ret) { |
| 498 | btrfs_delalloc_release_space(inode, 0, prealloc); | 498 | btrfs_delalloc_release_metadata(inode, prealloc); |
| 499 | goto out_put; | 499 | goto out_put; |
| 500 | } | 500 | } |
| 501 | btrfs_free_reserved_data_space(inode, 0, prealloc); | ||
| 502 | 501 | ||
| 503 | ret = btrfs_write_out_ino_cache(root, trans, path, inode); | 502 | ret = btrfs_write_out_ino_cache(root, trans, path, inode); |
| 504 | out_put: | 503 | out_put: |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 08dfc57e2270..e6811c42e41e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
| @@ -566,6 +566,8 @@ cont: | |||
| 566 | PAGE_SET_WRITEBACK | | 566 | PAGE_SET_WRITEBACK | |
| 567 | page_error_op | | 567 | page_error_op | |
| 568 | PAGE_END_WRITEBACK); | 568 | PAGE_END_WRITEBACK); |
| 569 | btrfs_free_reserved_data_space_noquota(inode, start, | ||
| 570 | end - start + 1); | ||
| 569 | goto free_pages_out; | 571 | goto free_pages_out; |
| 570 | } | 572 | } |
| 571 | } | 573 | } |
| @@ -742,7 +744,7 @@ retry: | |||
| 742 | lock_extent(io_tree, async_extent->start, | 744 | lock_extent(io_tree, async_extent->start, |
| 743 | async_extent->start + async_extent->ram_size - 1); | 745 | async_extent->start + async_extent->ram_size - 1); |
| 744 | 746 | ||
| 745 | ret = btrfs_reserve_extent(root, | 747 | ret = btrfs_reserve_extent(root, async_extent->ram_size, |
| 746 | async_extent->compressed_size, | 748 | async_extent->compressed_size, |
| 747 | async_extent->compressed_size, | 749 | async_extent->compressed_size, |
| 748 | 0, alloc_hint, &ins, 1, 1); | 750 | 0, alloc_hint, &ins, 1, 1); |
| @@ -969,7 +971,8 @@ static noinline int cow_file_range(struct inode *inode, | |||
| 969 | EXTENT_DEFRAG, PAGE_UNLOCK | | 971 | EXTENT_DEFRAG, PAGE_UNLOCK | |
| 970 | PAGE_CLEAR_DIRTY | PAGE_SET_WRITEBACK | | 972 | PAGE_CLEAR_DIRTY | PAGE_SET_WRITEBACK | |
| 971 | PAGE_END_WRITEBACK); | 973 | PAGE_END_WRITEBACK); |
| 972 | 974 | btrfs_free_reserved_data_space_noquota(inode, start, | |
| 975 | end - start + 1); | ||
| 973 | *nr_written = *nr_written + | 976 | *nr_written = *nr_written + |
| 974 | (end - start + PAGE_SIZE) / PAGE_SIZE; | 977 | (end - start + PAGE_SIZE) / PAGE_SIZE; |
| 975 | *page_started = 1; | 978 | *page_started = 1; |
| @@ -989,7 +992,7 @@ static noinline int cow_file_range(struct inode *inode, | |||
| 989 | unsigned long op; | 992 | unsigned long op; |
| 990 | 993 | ||
| 991 | cur_alloc_size = disk_num_bytes; | 994 | cur_alloc_size = disk_num_bytes; |
| 992 | ret = btrfs_reserve_extent(root, cur_alloc_size, | 995 | ret = btrfs_reserve_extent(root, cur_alloc_size, cur_alloc_size, |
| 993 | root->sectorsize, 0, alloc_hint, | 996 | root->sectorsize, 0, alloc_hint, |
| 994 | &ins, 1, 1); | 997 | &ins, 1, 1); |
| 995 | if (ret < 0) | 998 | if (ret < 0) |
| @@ -1489,8 +1492,10 @@ out_check: | |||
| 1489 | extent_clear_unlock_delalloc(inode, cur_offset, | 1492 | extent_clear_unlock_delalloc(inode, cur_offset, |
| 1490 | cur_offset + num_bytes - 1, | 1493 | cur_offset + num_bytes - 1, |
| 1491 | locked_page, EXTENT_LOCKED | | 1494 | locked_page, EXTENT_LOCKED | |
| 1492 | EXTENT_DELALLOC, PAGE_UNLOCK | | 1495 | EXTENT_DELALLOC | |
| 1493 | PAGE_SET_PRIVATE2); | 1496 | EXTENT_CLEAR_DATA_RESV, |
| 1497 | PAGE_UNLOCK | PAGE_SET_PRIVATE2); | ||
| 1498 | |||
| 1494 | if (!nolock && nocow) | 1499 | if (!nolock && nocow) |
| 1495 | btrfs_end_write_no_snapshoting(root); | 1500 | btrfs_end_write_no_snapshoting(root); |
| 1496 | cur_offset = extent_end; | 1501 | cur_offset = extent_end; |
| @@ -1807,7 +1812,9 @@ static void btrfs_clear_bit_hook(struct inode *inode, | |||
| 1807 | return; | 1812 | return; |
| 1808 | 1813 | ||
| 1809 | if (root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID | 1814 | if (root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID |
| 1810 | && do_list && !(state->state & EXTENT_NORESERVE)) | 1815 | && do_list && !(state->state & EXTENT_NORESERVE) |
| 1816 | && (*bits & (EXTENT_DO_ACCOUNTING | | ||
| 1817 | EXTENT_CLEAR_DATA_RESV))) | ||
| 1811 | btrfs_free_reserved_data_space_noquota(inode, | 1818 | btrfs_free_reserved_data_space_noquota(inode, |
| 1812 | state->start, len); | 1819 | state->start, len); |
| 1813 | 1820 | ||
| @@ -7251,7 +7258,7 @@ static struct extent_map *btrfs_new_extent_direct(struct inode *inode, | |||
| 7251 | int ret; | 7258 | int ret; |
| 7252 | 7259 | ||
| 7253 | alloc_hint = get_extent_allocation_hint(inode, start, len); | 7260 | alloc_hint = get_extent_allocation_hint(inode, start, len); |
| 7254 | ret = btrfs_reserve_extent(root, len, root->sectorsize, 0, | 7261 | ret = btrfs_reserve_extent(root, len, len, root->sectorsize, 0, |
| 7255 | alloc_hint, &ins, 1, 1); | 7262 | alloc_hint, &ins, 1, 1); |
| 7256 | if (ret) | 7263 | if (ret) |
| 7257 | return ERR_PTR(ret); | 7264 | return ERR_PTR(ret); |
| @@ -7751,6 +7758,13 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock, | |||
| 7751 | ret = PTR_ERR(em2); | 7758 | ret = PTR_ERR(em2); |
| 7752 | goto unlock_err; | 7759 | goto unlock_err; |
| 7753 | } | 7760 | } |
| 7761 | /* | ||
| 7762 | * For inode marked NODATACOW or extent marked PREALLOC, | ||
| 7763 | * use the existing or preallocated extent, so does not | ||
| 7764 | * need to adjust btrfs_space_info's bytes_may_use. | ||
| 7765 | */ | ||
| 7766 | btrfs_free_reserved_data_space_noquota(inode, | ||
| 7767 | start, len); | ||
| 7754 | goto unlock; | 7768 | goto unlock; |
| 7755 | } | 7769 | } |
| 7756 | } | 7770 | } |
| @@ -7785,7 +7799,6 @@ unlock: | |||
| 7785 | i_size_write(inode, start + len); | 7799 | i_size_write(inode, start + len); |
| 7786 | 7800 | ||
| 7787 | adjust_dio_outstanding_extents(inode, dio_data, len); | 7801 | adjust_dio_outstanding_extents(inode, dio_data, len); |
| 7788 | btrfs_free_reserved_data_space(inode, start, len); | ||
| 7789 | WARN_ON(dio_data->reserve < len); | 7802 | WARN_ON(dio_data->reserve < len); |
| 7790 | dio_data->reserve -= len; | 7803 | dio_data->reserve -= len; |
| 7791 | dio_data->unsubmitted_oe_range_end = start + len; | 7804 | dio_data->unsubmitted_oe_range_end = start + len; |
| @@ -10306,6 +10319,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode, | |||
| 10306 | u64 last_alloc = (u64)-1; | 10319 | u64 last_alloc = (u64)-1; |
| 10307 | int ret = 0; | 10320 | int ret = 0; |
| 10308 | bool own_trans = true; | 10321 | bool own_trans = true; |
| 10322 | u64 end = start + num_bytes - 1; | ||
| 10309 | 10323 | ||
| 10310 | if (trans) | 10324 | if (trans) |
| 10311 | own_trans = false; | 10325 | own_trans = false; |
| @@ -10327,8 +10341,8 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode, | |||
| 10327 | * sized chunks. | 10341 | * sized chunks. |
| 10328 | */ | 10342 | */ |
| 10329 | cur_bytes = min(cur_bytes, last_alloc); | 10343 | cur_bytes = min(cur_bytes, last_alloc); |
| 10330 | ret = btrfs_reserve_extent(root, cur_bytes, min_size, 0, | 10344 | ret = btrfs_reserve_extent(root, cur_bytes, cur_bytes, |
| 10331 | *alloc_hint, &ins, 1, 0); | 10345 | min_size, 0, *alloc_hint, &ins, 1, 0); |
| 10332 | if (ret) { | 10346 | if (ret) { |
| 10333 | if (own_trans) | 10347 | if (own_trans) |
| 10334 | btrfs_end_transaction(trans, root); | 10348 | btrfs_end_transaction(trans, root); |
| @@ -10414,6 +10428,9 @@ next: | |||
| 10414 | if (own_trans) | 10428 | if (own_trans) |
| 10415 | btrfs_end_transaction(trans, root); | 10429 | btrfs_end_transaction(trans, root); |
| 10416 | } | 10430 | } |
| 10431 | if (cur_offset < end) | ||
| 10432 | btrfs_free_reserved_data_space(inode, cur_offset, | ||
| 10433 | end - cur_offset + 1); | ||
| 10417 | return ret; | 10434 | return ret; |
| 10418 | } | 10435 | } |
| 10419 | 10436 | ||
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 14ed1e9e6bc8..b2a2da5893af 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
| @@ -5084,7 +5084,7 @@ static long btrfs_ioctl_quota_rescan_wait(struct file *file, void __user *arg) | |||
| 5084 | if (!capable(CAP_SYS_ADMIN)) | 5084 | if (!capable(CAP_SYS_ADMIN)) |
| 5085 | return -EPERM; | 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 | static long _btrfs_ioctl_set_received_subvol(struct file *file, | 5090 | static long _btrfs_ioctl_set_received_subvol(struct file *file, |
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 93ee1c18ef9d..8db2e29fdcf4 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
| @@ -995,7 +995,7 @@ int btrfs_quota_disable(struct btrfs_trans_handle *trans, | |||
| 995 | goto out; | 995 | goto out; |
| 996 | fs_info->quota_enabled = 0; | 996 | fs_info->quota_enabled = 0; |
| 997 | fs_info->pending_quota_state = 0; | 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 | spin_lock(&fs_info->qgroup_lock); | 999 | spin_lock(&fs_info->qgroup_lock); |
| 1000 | quota_root = fs_info->quota_root; | 1000 | quota_root = fs_info->quota_root; |
| 1001 | fs_info->quota_root = NULL; | 1001 | fs_info->quota_root = NULL; |
| @@ -1453,10 +1453,9 @@ int btrfs_qgroup_prepare_account_extents(struct btrfs_trans_handle *trans, | |||
| 1453 | return ret; | 1453 | return ret; |
| 1454 | } | 1454 | } |
| 1455 | 1455 | ||
| 1456 | struct btrfs_qgroup_extent_record * | 1456 | int btrfs_qgroup_insert_dirty_extent_nolock(struct btrfs_fs_info *fs_info, |
| 1457 | btrfs_qgroup_insert_dirty_extent(struct btrfs_fs_info *fs_info, | 1457 | struct btrfs_delayed_ref_root *delayed_refs, |
| 1458 | struct btrfs_delayed_ref_root *delayed_refs, | 1458 | struct btrfs_qgroup_extent_record *record) |
| 1459 | struct btrfs_qgroup_extent_record *record) | ||
| 1460 | { | 1459 | { |
| 1461 | struct rb_node **p = &delayed_refs->dirty_extent_root.rb_node; | 1460 | struct rb_node **p = &delayed_refs->dirty_extent_root.rb_node; |
| 1462 | struct rb_node *parent_node = NULL; | 1461 | struct rb_node *parent_node = NULL; |
| @@ -1475,12 +1474,42 @@ btrfs_qgroup_insert_dirty_extent(struct btrfs_fs_info *fs_info, | |||
| 1475 | else if (bytenr > entry->bytenr) | 1474 | else if (bytenr > entry->bytenr) |
| 1476 | p = &(*p)->rb_right; | 1475 | p = &(*p)->rb_right; |
| 1477 | else | 1476 | else |
| 1478 | return entry; | 1477 | return 1; |
| 1479 | } | 1478 | } |
| 1480 | 1479 | ||
| 1481 | rb_link_node(&record->node, parent_node, p); | 1480 | rb_link_node(&record->node, parent_node, p); |
| 1482 | rb_insert_color(&record->node, &delayed_refs->dirty_extent_root); | 1481 | rb_insert_color(&record->node, &delayed_refs->dirty_extent_root); |
| 1483 | return NULL; | 1482 | return 0; |
| 1483 | } | ||
| 1484 | |||
| 1485 | int btrfs_qgroup_insert_dirty_extent(struct btrfs_trans_handle *trans, | ||
| 1486 | struct btrfs_fs_info *fs_info, u64 bytenr, u64 num_bytes, | ||
| 1487 | gfp_t gfp_flag) | ||
| 1488 | { | ||
| 1489 | struct btrfs_qgroup_extent_record *record; | ||
| 1490 | struct btrfs_delayed_ref_root *delayed_refs; | ||
| 1491 | int ret; | ||
| 1492 | |||
| 1493 | if (!fs_info->quota_enabled || bytenr == 0 || num_bytes == 0) | ||
| 1494 | return 0; | ||
| 1495 | if (WARN_ON(trans == NULL)) | ||
| 1496 | return -EINVAL; | ||
| 1497 | record = kmalloc(sizeof(*record), gfp_flag); | ||
| 1498 | if (!record) | ||
| 1499 | return -ENOMEM; | ||
| 1500 | |||
| 1501 | delayed_refs = &trans->transaction->delayed_refs; | ||
| 1502 | record->bytenr = bytenr; | ||
| 1503 | record->num_bytes = num_bytes; | ||
| 1504 | record->old_roots = NULL; | ||
| 1505 | |||
| 1506 | spin_lock(&delayed_refs->lock); | ||
| 1507 | ret = btrfs_qgroup_insert_dirty_extent_nolock(fs_info, delayed_refs, | ||
| 1508 | record); | ||
| 1509 | spin_unlock(&delayed_refs->lock); | ||
| 1510 | if (ret > 0) | ||
| 1511 | kfree(record); | ||
| 1512 | return 0; | ||
| 1484 | } | 1513 | } |
| 1485 | 1514 | ||
| 1486 | #define UPDATE_NEW 0 | 1515 | #define UPDATE_NEW 0 |
| @@ -2303,6 +2332,10 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work) | |||
| 2303 | int err = -ENOMEM; | 2332 | int err = -ENOMEM; |
| 2304 | int ret = 0; | 2333 | int ret = 0; |
| 2305 | 2334 | ||
| 2335 | mutex_lock(&fs_info->qgroup_rescan_lock); | ||
| 2336 | fs_info->qgroup_rescan_running = true; | ||
| 2337 | mutex_unlock(&fs_info->qgroup_rescan_lock); | ||
| 2338 | |||
| 2306 | path = btrfs_alloc_path(); | 2339 | path = btrfs_alloc_path(); |
| 2307 | if (!path) | 2340 | if (!path) |
| 2308 | goto out; | 2341 | goto out; |
| @@ -2369,6 +2402,9 @@ out: | |||
| 2369 | } | 2402 | } |
| 2370 | 2403 | ||
| 2371 | done: | 2404 | done: |
| 2405 | mutex_lock(&fs_info->qgroup_rescan_lock); | ||
| 2406 | fs_info->qgroup_rescan_running = false; | ||
| 2407 | mutex_unlock(&fs_info->qgroup_rescan_lock); | ||
| 2372 | complete_all(&fs_info->qgroup_rescan_completion); | 2408 | complete_all(&fs_info->qgroup_rescan_completion); |
| 2373 | } | 2409 | } |
| 2374 | 2410 | ||
| @@ -2487,20 +2523,26 @@ btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info) | |||
| 2487 | return 0; | 2523 | return 0; |
| 2488 | } | 2524 | } |
| 2489 | 2525 | ||
| 2490 | int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info) | 2526 | int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info, |
| 2527 | bool interruptible) | ||
| 2491 | { | 2528 | { |
| 2492 | int running; | 2529 | int running; |
| 2493 | int ret = 0; | 2530 | int ret = 0; |
| 2494 | 2531 | ||
| 2495 | mutex_lock(&fs_info->qgroup_rescan_lock); | 2532 | mutex_lock(&fs_info->qgroup_rescan_lock); |
| 2496 | spin_lock(&fs_info->qgroup_lock); | 2533 | spin_lock(&fs_info->qgroup_lock); |
| 2497 | running = fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN; | 2534 | running = fs_info->qgroup_rescan_running; |
| 2498 | spin_unlock(&fs_info->qgroup_lock); | 2535 | spin_unlock(&fs_info->qgroup_lock); |
| 2499 | mutex_unlock(&fs_info->qgroup_rescan_lock); | 2536 | mutex_unlock(&fs_info->qgroup_rescan_lock); |
| 2500 | 2537 | ||
| 2501 | if (running) | 2538 | if (!running) |
| 2539 | return 0; | ||
| 2540 | |||
| 2541 | if (interruptible) | ||
| 2502 | ret = wait_for_completion_interruptible( | 2542 | ret = wait_for_completion_interruptible( |
| 2503 | &fs_info->qgroup_rescan_completion); | 2543 | &fs_info->qgroup_rescan_completion); |
| 2544 | else | ||
| 2545 | wait_for_completion(&fs_info->qgroup_rescan_completion); | ||
| 2504 | 2546 | ||
| 2505 | return ret; | 2547 | return ret; |
| 2506 | } | 2548 | } |
diff --git a/fs/btrfs/qgroup.h b/fs/btrfs/qgroup.h index 710887c06aaf..1bc64c864b62 100644 --- a/fs/btrfs/qgroup.h +++ b/fs/btrfs/qgroup.h | |||
| @@ -46,7 +46,8 @@ int btrfs_quota_disable(struct btrfs_trans_handle *trans, | |||
| 46 | struct btrfs_fs_info *fs_info); | 46 | struct btrfs_fs_info *fs_info); |
| 47 | int btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info); | 47 | int btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info); |
| 48 | void btrfs_qgroup_rescan_resume(struct btrfs_fs_info *fs_info); | 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 | int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, | 51 | int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, |
| 51 | struct btrfs_fs_info *fs_info, u64 src, u64 dst); | 52 | struct btrfs_fs_info *fs_info, u64 src, u64 dst); |
| 52 | int btrfs_del_qgroup_relation(struct btrfs_trans_handle *trans, | 53 | int btrfs_del_qgroup_relation(struct btrfs_trans_handle *trans, |
| @@ -63,10 +64,35 @@ void btrfs_free_qgroup_config(struct btrfs_fs_info *fs_info); | |||
| 63 | struct btrfs_delayed_extent_op; | 64 | struct btrfs_delayed_extent_op; |
| 64 | int btrfs_qgroup_prepare_account_extents(struct btrfs_trans_handle *trans, | 65 | int btrfs_qgroup_prepare_account_extents(struct btrfs_trans_handle *trans, |
| 65 | struct btrfs_fs_info *fs_info); | 66 | struct btrfs_fs_info *fs_info); |
| 66 | struct btrfs_qgroup_extent_record * | 67 | /* |
| 67 | btrfs_qgroup_insert_dirty_extent(struct btrfs_fs_info *fs_info, | 68 | * Insert one dirty extent record into @delayed_refs, informing qgroup to |
| 68 | struct btrfs_delayed_ref_root *delayed_refs, | 69 | * account that extent at commit trans time. |
| 69 | struct btrfs_qgroup_extent_record *record); | 70 | * |
| 71 | * No lock version, caller must acquire delayed ref lock and allocate memory. | ||
| 72 | * | ||
| 73 | * Return 0 for success insert | ||
| 74 | * Return >0 for existing record, caller can free @record safely. | ||
| 75 | * Error is not possible | ||
| 76 | */ | ||
| 77 | int btrfs_qgroup_insert_dirty_extent_nolock( | ||
| 78 | struct btrfs_fs_info *fs_info, | ||
| 79 | struct btrfs_delayed_ref_root *delayed_refs, | ||
| 80 | struct btrfs_qgroup_extent_record *record); | ||
| 81 | |||
| 82 | /* | ||
| 83 | * Insert one dirty extent record into @delayed_refs, informing qgroup to | ||
| 84 | * account that extent at commit trans time. | ||
| 85 | * | ||
| 86 | * Better encapsulated version. | ||
| 87 | * | ||
| 88 | * Return 0 if the operation is done. | ||
| 89 | * Return <0 for error, like memory allocation failure or invalid parameter | ||
| 90 | * (NULL trans) | ||
| 91 | */ | ||
| 92 | int btrfs_qgroup_insert_dirty_extent(struct btrfs_trans_handle *trans, | ||
| 93 | struct btrfs_fs_info *fs_info, u64 bytenr, u64 num_bytes, | ||
| 94 | gfp_t gfp_flag); | ||
| 95 | |||
| 70 | int | 96 | int |
| 71 | btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans, | 97 | btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans, |
| 72 | struct btrfs_fs_info *fs_info, | 98 | struct btrfs_fs_info *fs_info, |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index b26a5aea41b4..c0c13dc6fe12 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #include "async-thread.h" | 31 | #include "async-thread.h" |
| 32 | #include "free-space-cache.h" | 32 | #include "free-space-cache.h" |
| 33 | #include "inode-map.h" | 33 | #include "inode-map.h" |
| 34 | #include "qgroup.h" | ||
| 34 | 35 | ||
| 35 | /* | 36 | /* |
| 36 | * backref_node, mapping_node and tree_block start with this | 37 | * backref_node, mapping_node and tree_block start with this |
| @@ -3037,15 +3038,19 @@ int prealloc_file_extent_cluster(struct inode *inode, | |||
| 3037 | u64 num_bytes; | 3038 | u64 num_bytes; |
| 3038 | int nr = 0; | 3039 | int nr = 0; |
| 3039 | int ret = 0; | 3040 | int ret = 0; |
| 3041 | u64 prealloc_start = cluster->start - offset; | ||
| 3042 | u64 prealloc_end = cluster->end - offset; | ||
| 3043 | u64 cur_offset; | ||
| 3040 | 3044 | ||
| 3041 | BUG_ON(cluster->start != cluster->boundary[0]); | 3045 | BUG_ON(cluster->start != cluster->boundary[0]); |
| 3042 | inode_lock(inode); | 3046 | inode_lock(inode); |
| 3043 | 3047 | ||
| 3044 | ret = btrfs_check_data_free_space(inode, cluster->start, | 3048 | ret = btrfs_check_data_free_space(inode, prealloc_start, |
| 3045 | cluster->end + 1 - cluster->start); | 3049 | prealloc_end + 1 - prealloc_start); |
| 3046 | if (ret) | 3050 | if (ret) |
| 3047 | goto out; | 3051 | goto out; |
| 3048 | 3052 | ||
| 3053 | cur_offset = prealloc_start; | ||
| 3049 | while (nr < cluster->nr) { | 3054 | while (nr < cluster->nr) { |
| 3050 | start = cluster->boundary[nr] - offset; | 3055 | start = cluster->boundary[nr] - offset; |
| 3051 | if (nr + 1 < cluster->nr) | 3056 | if (nr + 1 < cluster->nr) |
| @@ -3055,16 +3060,21 @@ int prealloc_file_extent_cluster(struct inode *inode, | |||
| 3055 | 3060 | ||
| 3056 | lock_extent(&BTRFS_I(inode)->io_tree, start, end); | 3061 | lock_extent(&BTRFS_I(inode)->io_tree, start, end); |
| 3057 | num_bytes = end + 1 - start; | 3062 | num_bytes = end + 1 - start; |
| 3063 | if (cur_offset < start) | ||
| 3064 | btrfs_free_reserved_data_space(inode, cur_offset, | ||
| 3065 | start - cur_offset); | ||
| 3058 | ret = btrfs_prealloc_file_range(inode, 0, start, | 3066 | ret = btrfs_prealloc_file_range(inode, 0, start, |
| 3059 | num_bytes, num_bytes, | 3067 | num_bytes, num_bytes, |
| 3060 | end + 1, &alloc_hint); | 3068 | end + 1, &alloc_hint); |
| 3069 | cur_offset = end + 1; | ||
| 3061 | unlock_extent(&BTRFS_I(inode)->io_tree, start, end); | 3070 | unlock_extent(&BTRFS_I(inode)->io_tree, start, end); |
| 3062 | if (ret) | 3071 | if (ret) |
| 3063 | break; | 3072 | break; |
| 3064 | nr++; | 3073 | nr++; |
| 3065 | } | 3074 | } |
| 3066 | btrfs_free_reserved_data_space(inode, cluster->start, | 3075 | if (cur_offset < prealloc_end) |
| 3067 | cluster->end + 1 - cluster->start); | 3076 | btrfs_free_reserved_data_space(inode, cur_offset, |
| 3077 | prealloc_end + 1 - cur_offset); | ||
| 3068 | out: | 3078 | out: |
| 3069 | inode_unlock(inode); | 3079 | inode_unlock(inode); |
| 3070 | return ret; | 3080 | return ret; |
| @@ -3916,6 +3926,90 @@ int prepare_to_relocate(struct reloc_control *rc) | |||
| 3916 | return 0; | 3926 | return 0; |
| 3917 | } | 3927 | } |
| 3918 | 3928 | ||
| 3929 | /* | ||
| 3930 | * Qgroup fixer for data chunk relocation. | ||
| 3931 | * The data relocation is done in the following steps | ||
| 3932 | * 1) Copy data extents into data reloc tree | ||
| 3933 | * 2) Create tree reloc tree(special snapshot) for related subvolumes | ||
| 3934 | * 3) Modify file extents in tree reloc tree | ||
| 3935 | * 4) Merge tree reloc tree with original fs tree, by swapping tree blocks | ||
| 3936 | * | ||
| 3937 | * The problem is, data and tree reloc tree are not accounted to qgroup, | ||
| 3938 | * and 4) will only info qgroup to track tree blocks change, not file extents | ||
| 3939 | * in the tree blocks. | ||
| 3940 | * | ||
| 3941 | * The good news is, related data extents are all in data reloc tree, so we | ||
| 3942 | * only need to info qgroup to track all file extents in data reloc tree | ||
| 3943 | * before commit trans. | ||
| 3944 | */ | ||
| 3945 | static int qgroup_fix_relocated_data_extents(struct btrfs_trans_handle *trans, | ||
| 3946 | struct reloc_control *rc) | ||
| 3947 | { | ||
| 3948 | struct btrfs_fs_info *fs_info = rc->extent_root->fs_info; | ||
| 3949 | struct inode *inode = rc->data_inode; | ||
| 3950 | struct btrfs_root *data_reloc_root = BTRFS_I(inode)->root; | ||
| 3951 | struct btrfs_path *path; | ||
| 3952 | struct btrfs_key key; | ||
| 3953 | int ret = 0; | ||
| 3954 | |||
| 3955 | if (!fs_info->quota_enabled) | ||
| 3956 | return 0; | ||
| 3957 | |||
| 3958 | /* | ||
| 3959 | * Only for stage where we update data pointers the qgroup fix is | ||
| 3960 | * valid. | ||
| 3961 | * For MOVING_DATA stage, we will miss the timing of swapping tree | ||
| 3962 | * blocks, and won't fix it. | ||
| 3963 | */ | ||
| 3964 | if (!(rc->stage == UPDATE_DATA_PTRS && rc->extents_found)) | ||
| 3965 | return 0; | ||
| 3966 | |||
| 3967 | path = btrfs_alloc_path(); | ||
| 3968 | if (!path) | ||
| 3969 | return -ENOMEM; | ||
| 3970 | key.objectid = btrfs_ino(inode); | ||
| 3971 | key.type = BTRFS_EXTENT_DATA_KEY; | ||
| 3972 | key.offset = 0; | ||
| 3973 | |||
| 3974 | ret = btrfs_search_slot(NULL, data_reloc_root, &key, path, 0, 0); | ||
| 3975 | if (ret < 0) | ||
| 3976 | goto out; | ||
| 3977 | |||
| 3978 | lock_extent(&BTRFS_I(inode)->io_tree, 0, (u64)-1); | ||
| 3979 | while (1) { | ||
| 3980 | struct btrfs_file_extent_item *fi; | ||
| 3981 | |||
| 3982 | btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); | ||
| 3983 | if (key.objectid > btrfs_ino(inode)) | ||
| 3984 | break; | ||
| 3985 | if (key.type != BTRFS_EXTENT_DATA_KEY) | ||
| 3986 | goto next; | ||
| 3987 | fi = btrfs_item_ptr(path->nodes[0], path->slots[0], | ||
| 3988 | struct btrfs_file_extent_item); | ||
| 3989 | if (btrfs_file_extent_type(path->nodes[0], fi) != | ||
| 3990 | BTRFS_FILE_EXTENT_REG) | ||
| 3991 | goto next; | ||
| 3992 | ret = btrfs_qgroup_insert_dirty_extent(trans, fs_info, | ||
| 3993 | btrfs_file_extent_disk_bytenr(path->nodes[0], fi), | ||
| 3994 | btrfs_file_extent_disk_num_bytes(path->nodes[0], fi), | ||
| 3995 | GFP_NOFS); | ||
| 3996 | if (ret < 0) | ||
| 3997 | break; | ||
| 3998 | next: | ||
| 3999 | ret = btrfs_next_item(data_reloc_root, path); | ||
| 4000 | if (ret < 0) | ||
| 4001 | break; | ||
| 4002 | if (ret > 0) { | ||
| 4003 | ret = 0; | ||
| 4004 | break; | ||
| 4005 | } | ||
| 4006 | } | ||
| 4007 | unlock_extent(&BTRFS_I(inode)->io_tree, 0 , (u64)-1); | ||
| 4008 | out: | ||
| 4009 | btrfs_free_path(path); | ||
| 4010 | return ret; | ||
| 4011 | } | ||
| 4012 | |||
| 3919 | static noinline_for_stack int relocate_block_group(struct reloc_control *rc) | 4013 | static noinline_for_stack int relocate_block_group(struct reloc_control *rc) |
| 3920 | { | 4014 | { |
| 3921 | struct rb_root blocks = RB_ROOT; | 4015 | struct rb_root blocks = RB_ROOT; |
| @@ -4102,10 +4196,18 @@ restart: | |||
| 4102 | 4196 | ||
| 4103 | /* get rid of pinned extents */ | 4197 | /* get rid of pinned extents */ |
| 4104 | trans = btrfs_join_transaction(rc->extent_root); | 4198 | trans = btrfs_join_transaction(rc->extent_root); |
| 4105 | if (IS_ERR(trans)) | 4199 | if (IS_ERR(trans)) { |
| 4106 | err = PTR_ERR(trans); | 4200 | err = PTR_ERR(trans); |
| 4107 | else | 4201 | goto out_free; |
| 4108 | btrfs_commit_transaction(trans, rc->extent_root); | 4202 | } |
| 4203 | ret = qgroup_fix_relocated_data_extents(trans, rc); | ||
| 4204 | if (ret < 0) { | ||
| 4205 | btrfs_abort_transaction(trans, ret); | ||
| 4206 | if (!err) | ||
| 4207 | err = ret; | ||
| 4208 | goto out_free; | ||
| 4209 | } | ||
| 4210 | btrfs_commit_transaction(trans, rc->extent_root); | ||
| 4109 | out_free: | 4211 | out_free: |
| 4110 | btrfs_free_block_rsv(rc->extent_root, rc->block_rsv); | 4212 | btrfs_free_block_rsv(rc->extent_root, rc->block_rsv); |
| 4111 | btrfs_free_path(path); | 4213 | btrfs_free_path(path); |
| @@ -4468,10 +4570,16 @@ int btrfs_recover_relocation(struct btrfs_root *root) | |||
| 4468 | unset_reloc_control(rc); | 4570 | unset_reloc_control(rc); |
| 4469 | 4571 | ||
| 4470 | trans = btrfs_join_transaction(rc->extent_root); | 4572 | trans = btrfs_join_transaction(rc->extent_root); |
| 4471 | if (IS_ERR(trans)) | 4573 | if (IS_ERR(trans)) { |
| 4472 | err = PTR_ERR(trans); | 4574 | err = PTR_ERR(trans); |
| 4473 | else | 4575 | goto out_free; |
| 4474 | err = btrfs_commit_transaction(trans, rc->extent_root); | 4576 | } |
| 4577 | err = qgroup_fix_relocated_data_extents(trans, rc); | ||
| 4578 | if (err < 0) { | ||
| 4579 | btrfs_abort_transaction(trans, err); | ||
| 4580 | goto out_free; | ||
| 4581 | } | ||
| 4582 | err = btrfs_commit_transaction(trans, rc->extent_root); | ||
| 4475 | out_free: | 4583 | out_free: |
| 4476 | kfree(rc); | 4584 | kfree(rc); |
| 4477 | out: | 4585 | out: |
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c index 7fd7e1830cfe..091296062456 100644 --- a/fs/btrfs/root-tree.c +++ b/fs/btrfs/root-tree.c | |||
| @@ -272,6 +272,23 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root) | |||
| 272 | root_key.objectid = key.offset; | 272 | root_key.objectid = key.offset; |
| 273 | key.offset++; | 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 | root = btrfs_read_fs_root(tree_root, &root_key); | 292 | root = btrfs_read_fs_root(tree_root, &root_key); |
| 276 | err = PTR_ERR_OR_ZERO(root); | 293 | err = PTR_ERR_OR_ZERO(root); |
| 277 | if (err && err != -ENOENT) { | 294 | if (err && err != -ENOENT) { |
| @@ -310,16 +327,8 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root) | |||
| 310 | set_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state); | 327 | set_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state); |
| 311 | 328 | ||
| 312 | err = btrfs_insert_fs_root(root->fs_info, root); | 329 | err = btrfs_insert_fs_root(root->fs_info, root); |
| 313 | /* | ||
| 314 | * The root might have been inserted already, as before we look | ||
| 315 | * for orphan roots, log replay might have happened, which | ||
| 316 | * triggers a transaction commit and qgroup accounting, which | ||
| 317 | * in turn reads and inserts fs roots while doing backref | ||
| 318 | * walking. | ||
| 319 | */ | ||
| 320 | if (err == -EEXIST) | ||
| 321 | err = 0; | ||
| 322 | if (err) { | 330 | if (err) { |
| 331 | BUG_ON(err == -EEXIST); | ||
| 323 | btrfs_free_fs_root(root); | 332 | btrfs_free_fs_root(root); |
| 324 | break; | 333 | break; |
| 325 | } | 334 | } |
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index efe129fe2678..a87675ffd02b 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c | |||
| @@ -4268,10 +4268,12 @@ static int process_all_refs(struct send_ctx *sctx, | |||
| 4268 | } | 4268 | } |
| 4269 | btrfs_release_path(path); | 4269 | btrfs_release_path(path); |
| 4270 | 4270 | ||
| 4271 | /* | ||
| 4272 | * We don't actually care about pending_move as we are simply | ||
| 4273 | * re-creating this inode and will be rename'ing it into place once we | ||
| 4274 | * rename the parent directory. | ||
| 4275 | */ | ||
| 4271 | ret = process_recorded_refs(sctx, &pending_move); | 4276 | ret = process_recorded_refs(sctx, &pending_move); |
| 4272 | /* Only applicable to an incremental send. */ | ||
| 4273 | ASSERT(pending_move == 0); | ||
| 4274 | |||
| 4275 | out: | 4277 | out: |
| 4276 | btrfs_free_path(path); | 4278 | btrfs_free_path(path); |
| 4277 | return ret; | 4279 | return ret; |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 864ce334f696..4071fe2bd098 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
| @@ -2241,6 +2241,13 @@ static int btrfs_freeze(struct super_block *sb) | |||
| 2241 | struct btrfs_trans_handle *trans; | 2241 | struct btrfs_trans_handle *trans; |
| 2242 | struct btrfs_root *root = btrfs_sb(sb)->tree_root; | 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 | trans = btrfs_attach_transaction_barrier(root); | 2251 | trans = btrfs_attach_transaction_barrier(root); |
| 2245 | if (IS_ERR(trans)) { | 2252 | if (IS_ERR(trans)) { |
| 2246 | /* no transaction, don't bother */ | 2253 | /* no transaction, don't bother */ |
| @@ -2251,6 +2258,14 @@ static int btrfs_freeze(struct super_block *sb) | |||
| 2251 | return btrfs_commit_transaction(trans, root); | 2258 | return btrfs_commit_transaction(trans, root); |
| 2252 | } | 2259 | } |
| 2253 | 2260 | ||
| 2261 | static int btrfs_unfreeze(struct super_block *sb) | ||
| 2262 | { | ||
| 2263 | struct btrfs_root *root = btrfs_sb(sb)->tree_root; | ||
| 2264 | |||
| 2265 | root->fs_info->fs_frozen = 0; | ||
| 2266 | return 0; | ||
| 2267 | } | ||
| 2268 | |||
| 2254 | static int btrfs_show_devname(struct seq_file *m, struct dentry *root) | 2269 | static int btrfs_show_devname(struct seq_file *m, struct dentry *root) |
| 2255 | { | 2270 | { |
| 2256 | struct btrfs_fs_info *fs_info = btrfs_sb(root->d_sb); | 2271 | struct btrfs_fs_info *fs_info = btrfs_sb(root->d_sb); |
| @@ -2299,6 +2314,7 @@ static const struct super_operations btrfs_super_ops = { | |||
| 2299 | .statfs = btrfs_statfs, | 2314 | .statfs = btrfs_statfs, |
| 2300 | .remount_fs = btrfs_remount, | 2315 | .remount_fs = btrfs_remount, |
| 2301 | .freeze_fs = btrfs_freeze, | 2316 | .freeze_fs = btrfs_freeze, |
| 2317 | .unfreeze_fs = btrfs_unfreeze, | ||
| 2302 | }; | 2318 | }; |
| 2303 | 2319 | ||
| 2304 | static const struct file_operations btrfs_ctl_fops = { | 2320 | static const struct file_operations btrfs_ctl_fops = { |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 9cca0a721961..95d41919d034 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
| @@ -2278,8 +2278,13 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
| 2278 | 2278 | ||
| 2279 | kmem_cache_free(btrfs_trans_handle_cachep, trans); | 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 | if (current != root->fs_info->transaction_kthread && | 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 | btrfs_run_delayed_iputs(root); | 2288 | btrfs_run_delayed_iputs(root); |
| 2284 | 2289 | ||
| 2285 | return ret; | 2290 | return ret; |
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index fff3f3efa436..ef9c55bc7907 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include "backref.h" | 27 | #include "backref.h" |
| 28 | #include "hash.h" | 28 | #include "hash.h" |
| 29 | #include "compression.h" | 29 | #include "compression.h" |
| 30 | #include "qgroup.h" | ||
| 30 | 31 | ||
| 31 | /* magic values for the inode_only field in btrfs_log_inode: | 32 | /* magic values for the inode_only field in btrfs_log_inode: |
| 32 | * | 33 | * |
| @@ -680,6 +681,21 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans, | |||
| 680 | ins.type = BTRFS_EXTENT_ITEM_KEY; | 681 | ins.type = BTRFS_EXTENT_ITEM_KEY; |
| 681 | offset = key->offset - btrfs_file_extent_offset(eb, item); | 682 | offset = key->offset - btrfs_file_extent_offset(eb, item); |
| 682 | 683 | ||
| 684 | /* | ||
| 685 | * Manually record dirty extent, as here we did a shallow | ||
| 686 | * file extent item copy and skip normal backref update, | ||
| 687 | * but modifying extent tree all by ourselves. | ||
| 688 | * So need to manually record dirty extent for qgroup, | ||
| 689 | * as the owner of the file extent changed from log tree | ||
| 690 | * (doesn't affect qgroup) to fs/file tree(affects qgroup) | ||
| 691 | */ | ||
| 692 | ret = btrfs_qgroup_insert_dirty_extent(trans, root->fs_info, | ||
| 693 | btrfs_file_extent_disk_bytenr(eb, item), | ||
| 694 | btrfs_file_extent_disk_num_bytes(eb, item), | ||
| 695 | GFP_NOFS); | ||
| 696 | if (ret < 0) | ||
| 697 | goto out; | ||
| 698 | |||
| 683 | if (ins.objectid > 0) { | 699 | if (ins.objectid > 0) { |
| 684 | u64 csum_start; | 700 | u64 csum_start; |
| 685 | u64 csum_end; | 701 | u64 csum_end; |
| @@ -2807,7 +2823,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, | |||
| 2807 | */ | 2823 | */ |
| 2808 | mutex_unlock(&root->log_mutex); | 2824 | mutex_unlock(&root->log_mutex); |
| 2809 | 2825 | ||
| 2810 | btrfs_init_log_ctx(&root_log_ctx); | 2826 | btrfs_init_log_ctx(&root_log_ctx, NULL); |
| 2811 | 2827 | ||
| 2812 | mutex_lock(&log_root_tree->log_mutex); | 2828 | mutex_lock(&log_root_tree->log_mutex); |
| 2813 | atomic_inc(&log_root_tree->log_batch); | 2829 | atomic_inc(&log_root_tree->log_batch); |
| @@ -2851,6 +2867,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, | |||
| 2851 | 2867 | ||
| 2852 | if (log_root_tree->log_transid_committed >= root_log_ctx.log_transid) { | 2868 | if (log_root_tree->log_transid_committed >= root_log_ctx.log_transid) { |
| 2853 | blk_finish_plug(&plug); | 2869 | blk_finish_plug(&plug); |
| 2870 | list_del_init(&root_log_ctx.list); | ||
| 2854 | mutex_unlock(&log_root_tree->log_mutex); | 2871 | mutex_unlock(&log_root_tree->log_mutex); |
| 2855 | ret = root_log_ctx.log_ret; | 2872 | ret = root_log_ctx.log_ret; |
| 2856 | goto out; | 2873 | goto out; |
| @@ -4741,7 +4758,8 @@ again: | |||
| 4741 | if (ret < 0) { | 4758 | if (ret < 0) { |
| 4742 | err = ret; | 4759 | err = ret; |
| 4743 | goto out_unlock; | 4760 | goto out_unlock; |
| 4744 | } else if (ret > 0) { | 4761 | } else if (ret > 0 && ctx && |
| 4762 | other_ino != btrfs_ino(ctx->inode)) { | ||
| 4745 | struct btrfs_key inode_key; | 4763 | struct btrfs_key inode_key; |
| 4746 | struct inode *other_inode; | 4764 | struct inode *other_inode; |
| 4747 | 4765 | ||
diff --git a/fs/btrfs/tree-log.h b/fs/btrfs/tree-log.h index a9f1b75d080d..ab858e31ccbc 100644 --- a/fs/btrfs/tree-log.h +++ b/fs/btrfs/tree-log.h | |||
| @@ -30,15 +30,18 @@ struct btrfs_log_ctx { | |||
| 30 | int log_transid; | 30 | int log_transid; |
| 31 | int io_err; | 31 | int io_err; |
| 32 | bool log_new_dentries; | 32 | bool log_new_dentries; |
| 33 | struct inode *inode; | ||
| 33 | struct list_head list; | 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 | ctx->log_ret = 0; | 40 | ctx->log_ret = 0; |
| 39 | ctx->log_transid = 0; | 41 | ctx->log_transid = 0; |
| 40 | ctx->io_err = 0; | 42 | ctx->io_err = 0; |
| 41 | ctx->log_new_dentries = false; | 43 | ctx->log_new_dentries = false; |
| 44 | ctx->inode = inode; | ||
| 42 | INIT_LIST_HEAD(&ctx->list); | 45 | INIT_LIST_HEAD(&ctx->list); |
| 43 | } | 46 | } |
| 44 | 47 | ||
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 51f125508771..035efce603a9 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
| @@ -834,10 +834,6 @@ static void __free_device(struct work_struct *work) | |||
| 834 | struct btrfs_device *device; | 834 | struct btrfs_device *device; |
| 835 | 835 | ||
| 836 | device = container_of(work, struct btrfs_device, rcu_work); | 836 | device = container_of(work, struct btrfs_device, rcu_work); |
| 837 | |||
| 838 | if (device->bdev) | ||
| 839 | blkdev_put(device->bdev, device->mode); | ||
| 840 | |||
| 841 | rcu_string_free(device->name); | 837 | rcu_string_free(device->name); |
| 842 | kfree(device); | 838 | kfree(device); |
| 843 | } | 839 | } |
| @@ -852,6 +848,17 @@ static void free_device(struct rcu_head *head) | |||
| 852 | schedule_work(&device->rcu_work); | 848 | schedule_work(&device->rcu_work); |
| 853 | } | 849 | } |
| 854 | 850 | ||
| 851 | static void btrfs_close_bdev(struct btrfs_device *device) | ||
| 852 | { | ||
| 853 | if (device->bdev && device->writeable) { | ||
| 854 | sync_blockdev(device->bdev); | ||
| 855 | invalidate_bdev(device->bdev); | ||
| 856 | } | ||
| 857 | |||
| 858 | if (device->bdev) | ||
| 859 | blkdev_put(device->bdev, device->mode); | ||
| 860 | } | ||
| 861 | |||
| 855 | static void btrfs_close_one_device(struct btrfs_device *device) | 862 | static void btrfs_close_one_device(struct btrfs_device *device) |
| 856 | { | 863 | { |
| 857 | struct btrfs_fs_devices *fs_devices = device->fs_devices; | 864 | struct btrfs_fs_devices *fs_devices = device->fs_devices; |
| @@ -870,10 +877,7 @@ static void btrfs_close_one_device(struct btrfs_device *device) | |||
| 870 | if (device->missing) | 877 | if (device->missing) |
| 871 | fs_devices->missing_devices--; | 878 | fs_devices->missing_devices--; |
| 872 | 879 | ||
| 873 | if (device->bdev && device->writeable) { | 880 | btrfs_close_bdev(device); |
| 874 | sync_blockdev(device->bdev); | ||
| 875 | invalidate_bdev(device->bdev); | ||
| 876 | } | ||
| 877 | 881 | ||
| 878 | new_device = btrfs_alloc_device(NULL, &device->devid, | 882 | new_device = btrfs_alloc_device(NULL, &device->devid, |
| 879 | device->uuid); | 883 | device->uuid); |
| @@ -1932,6 +1936,8 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path, u64 devid) | |||
| 1932 | btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device); | 1936 | btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device); |
| 1933 | } | 1937 | } |
| 1934 | 1938 | ||
| 1939 | btrfs_close_bdev(device); | ||
| 1940 | |||
| 1935 | call_rcu(&device->rcu, free_device); | 1941 | call_rcu(&device->rcu, free_device); |
| 1936 | 1942 | ||
| 1937 | num_devices = btrfs_super_num_devices(root->fs_info->super_copy) - 1; | 1943 | num_devices = btrfs_super_num_devices(root->fs_info->super_copy) - 1; |
| @@ -2025,6 +2031,9 @@ void btrfs_rm_dev_replace_free_srcdev(struct btrfs_fs_info *fs_info, | |||
| 2025 | /* zero out the old super if it is writable */ | 2031 | /* zero out the old super if it is writable */ |
| 2026 | btrfs_scratch_superblocks(srcdev->bdev, srcdev->name->str); | 2032 | btrfs_scratch_superblocks(srcdev->bdev, srcdev->name->str); |
| 2027 | } | 2033 | } |
| 2034 | |||
| 2035 | btrfs_close_bdev(srcdev); | ||
| 2036 | |||
| 2028 | call_rcu(&srcdev->rcu, free_device); | 2037 | call_rcu(&srcdev->rcu, free_device); |
| 2029 | 2038 | ||
| 2030 | /* | 2039 | /* |
| @@ -2080,6 +2089,8 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info, | |||
| 2080 | * the device_list_mutex lock. | 2089 | * the device_list_mutex lock. |
| 2081 | */ | 2090 | */ |
| 2082 | btrfs_scratch_superblocks(tgtdev->bdev, tgtdev->name->str); | 2091 | btrfs_scratch_superblocks(tgtdev->bdev, tgtdev->name->str); |
| 2092 | |||
| 2093 | btrfs_close_bdev(tgtdev); | ||
| 2083 | call_rcu(&tgtdev->rcu, free_device); | 2094 | call_rcu(&tgtdev->rcu, free_device); |
| 2084 | } | 2095 | } |
| 2085 | 2096 | ||
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index c64a0b794d49..df4b3e6fa563 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c | |||
| @@ -597,7 +597,7 @@ static bool need_reset_readdir(struct ceph_file_info *fi, loff_t new_pos) | |||
| 597 | if (is_hash_order(new_pos)) { | 597 | if (is_hash_order(new_pos)) { |
| 598 | /* no need to reset last_name for a forward seek when | 598 | /* no need to reset last_name for a forward seek when |
| 599 | * dentries are sotred in hash order */ | 599 | * dentries are sotred in hash order */ |
| 600 | } else if (fi->frag |= fpos_frag(new_pos)) { | 600 | } else if (fi->frag != fpos_frag(new_pos)) { |
| 601 | return true; | 601 | return true; |
| 602 | } | 602 | } |
| 603 | rinfo = fi->last_readdir ? &fi->last_readdir->r_reply_info : NULL; | 603 | rinfo = fi->last_readdir ? &fi->last_readdir->r_reply_info : NULL; |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 6bbec5e784cd..14ae4b8e1a3c 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
| @@ -609,6 +609,9 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) | |||
| 609 | char *s, *p; | 609 | char *s, *p; |
| 610 | char sep; | 610 | char sep; |
| 611 | 611 | ||
| 612 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) | ||
| 613 | return dget(sb->s_root); | ||
| 614 | |||
| 612 | full_path = cifs_build_path_to_root(vol, cifs_sb, | 615 | full_path = cifs_build_path_to_root(vol, cifs_sb, |
| 613 | cifs_sb_master_tcon(cifs_sb)); | 616 | cifs_sb_master_tcon(cifs_sb)); |
| 614 | if (full_path == NULL) | 617 | if (full_path == NULL) |
| @@ -686,26 +689,22 @@ cifs_do_mount(struct file_system_type *fs_type, | |||
| 686 | cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL); | 689 | cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL); |
| 687 | if (cifs_sb->mountdata == NULL) { | 690 | if (cifs_sb->mountdata == NULL) { |
| 688 | root = ERR_PTR(-ENOMEM); | 691 | root = ERR_PTR(-ENOMEM); |
| 689 | goto out_cifs_sb; | 692 | goto out_free; |
| 690 | } | 693 | } |
| 691 | 694 | ||
| 692 | if (volume_info->prepath) { | 695 | rc = cifs_setup_cifs_sb(volume_info, cifs_sb); |
| 693 | cifs_sb->prepath = kstrdup(volume_info->prepath, GFP_KERNEL); | 696 | if (rc) { |
| 694 | if (cifs_sb->prepath == NULL) { | 697 | root = ERR_PTR(rc); |
| 695 | root = ERR_PTR(-ENOMEM); | 698 | goto out_free; |
| 696 | goto out_cifs_sb; | ||
| 697 | } | ||
| 698 | } | 699 | } |
| 699 | 700 | ||
| 700 | cifs_setup_cifs_sb(volume_info, cifs_sb); | ||
| 701 | |||
| 702 | rc = cifs_mount(cifs_sb, volume_info); | 701 | rc = cifs_mount(cifs_sb, volume_info); |
| 703 | if (rc) { | 702 | if (rc) { |
| 704 | if (!(flags & MS_SILENT)) | 703 | if (!(flags & MS_SILENT)) |
| 705 | cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n", | 704 | cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n", |
| 706 | rc); | 705 | rc); |
| 707 | root = ERR_PTR(rc); | 706 | root = ERR_PTR(rc); |
| 708 | goto out_mountdata; | 707 | goto out_free; |
| 709 | } | 708 | } |
| 710 | 709 | ||
| 711 | mnt_data.vol = volume_info; | 710 | mnt_data.vol = volume_info; |
| @@ -735,11 +734,7 @@ cifs_do_mount(struct file_system_type *fs_type, | |||
| 735 | sb->s_flags |= MS_ACTIVE; | 734 | sb->s_flags |= MS_ACTIVE; |
| 736 | } | 735 | } |
| 737 | 736 | ||
| 738 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) | 737 | root = cifs_get_root(volume_info, sb); |
| 739 | root = dget(sb->s_root); | ||
| 740 | else | ||
| 741 | root = cifs_get_root(volume_info, sb); | ||
| 742 | |||
| 743 | if (IS_ERR(root)) | 738 | if (IS_ERR(root)) |
| 744 | goto out_super; | 739 | goto out_super; |
| 745 | 740 | ||
| @@ -752,9 +747,9 @@ out: | |||
| 752 | cifs_cleanup_volume_info(volume_info); | 747 | cifs_cleanup_volume_info(volume_info); |
| 753 | return root; | 748 | return root; |
| 754 | 749 | ||
| 755 | out_mountdata: | 750 | out_free: |
| 751 | kfree(cifs_sb->prepath); | ||
| 756 | kfree(cifs_sb->mountdata); | 752 | kfree(cifs_sb->mountdata); |
| 757 | out_cifs_sb: | ||
| 758 | kfree(cifs_sb); | 753 | kfree(cifs_sb); |
| 759 | out_nls: | 754 | out_nls: |
| 760 | unload_nls(volume_info->local_nls); | 755 | unload_nls(volume_info->local_nls); |
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 1243bd326591..95dab43646f0 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
| @@ -184,7 +184,7 @@ extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, | |||
| 184 | unsigned int to_read); | 184 | unsigned int to_read); |
| 185 | extern int cifs_read_page_from_socket(struct TCP_Server_Info *server, | 185 | extern int cifs_read_page_from_socket(struct TCP_Server_Info *server, |
| 186 | struct page *page, unsigned int to_read); | 186 | struct page *page, unsigned int to_read); |
| 187 | extern void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, | 187 | extern int cifs_setup_cifs_sb(struct smb_vol *pvolume_info, |
| 188 | struct cifs_sb_info *cifs_sb); | 188 | struct cifs_sb_info *cifs_sb); |
| 189 | extern int cifs_match_super(struct super_block *, void *); | 189 | extern int cifs_match_super(struct super_block *, void *); |
| 190 | extern void cifs_cleanup_volume_info(struct smb_vol *pvolume_info); | 190 | extern void cifs_cleanup_volume_info(struct smb_vol *pvolume_info); |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 7ae03283bd61..2e4f4bad8b1e 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
| @@ -2781,6 +2781,24 @@ compare_mount_options(struct super_block *sb, struct cifs_mnt_data *mnt_data) | |||
| 2781 | return 1; | 2781 | return 1; |
| 2782 | } | 2782 | } |
| 2783 | 2783 | ||
| 2784 | static int | ||
| 2785 | match_prepath(struct super_block *sb, struct cifs_mnt_data *mnt_data) | ||
| 2786 | { | ||
| 2787 | struct cifs_sb_info *old = CIFS_SB(sb); | ||
| 2788 | struct cifs_sb_info *new = mnt_data->cifs_sb; | ||
| 2789 | |||
| 2790 | if (old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) { | ||
| 2791 | if (!(new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH)) | ||
| 2792 | return 0; | ||
| 2793 | /* The prepath should be null terminated strings */ | ||
| 2794 | if (strcmp(new->prepath, old->prepath)) | ||
| 2795 | return 0; | ||
| 2796 | |||
| 2797 | return 1; | ||
| 2798 | } | ||
| 2799 | return 0; | ||
| 2800 | } | ||
| 2801 | |||
| 2784 | int | 2802 | int |
| 2785 | cifs_match_super(struct super_block *sb, void *data) | 2803 | cifs_match_super(struct super_block *sb, void *data) |
| 2786 | { | 2804 | { |
| @@ -2808,7 +2826,8 @@ cifs_match_super(struct super_block *sb, void *data) | |||
| 2808 | 2826 | ||
| 2809 | if (!match_server(tcp_srv, volume_info) || | 2827 | if (!match_server(tcp_srv, volume_info) || |
| 2810 | !match_session(ses, volume_info) || | 2828 | !match_session(ses, volume_info) || |
| 2811 | !match_tcon(tcon, volume_info->UNC)) { | 2829 | !match_tcon(tcon, volume_info->UNC) || |
| 2830 | !match_prepath(sb, mnt_data)) { | ||
| 2812 | rc = 0; | 2831 | rc = 0; |
| 2813 | goto out; | 2832 | goto out; |
| 2814 | } | 2833 | } |
| @@ -3222,7 +3241,7 @@ void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon, | |||
| 3222 | } | 3241 | } |
| 3223 | } | 3242 | } |
| 3224 | 3243 | ||
| 3225 | void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, | 3244 | int cifs_setup_cifs_sb(struct smb_vol *pvolume_info, |
| 3226 | struct cifs_sb_info *cifs_sb) | 3245 | struct cifs_sb_info *cifs_sb) |
| 3227 | { | 3246 | { |
| 3228 | INIT_DELAYED_WORK(&cifs_sb->prune_tlinks, cifs_prune_tlinks); | 3247 | INIT_DELAYED_WORK(&cifs_sb->prune_tlinks, cifs_prune_tlinks); |
| @@ -3316,6 +3335,14 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, | |||
| 3316 | 3335 | ||
| 3317 | if ((pvolume_info->cifs_acl) && (pvolume_info->dynperm)) | 3336 | if ((pvolume_info->cifs_acl) && (pvolume_info->dynperm)) |
| 3318 | cifs_dbg(VFS, "mount option dynperm ignored if cifsacl mount option supported\n"); | 3337 | cifs_dbg(VFS, "mount option dynperm ignored if cifsacl mount option supported\n"); |
| 3338 | |||
| 3339 | if (pvolume_info->prepath) { | ||
| 3340 | cifs_sb->prepath = kstrdup(pvolume_info->prepath, GFP_KERNEL); | ||
| 3341 | if (cifs_sb->prepath == NULL) | ||
| 3342 | return -ENOMEM; | ||
| 3343 | } | ||
| 3344 | |||
| 3345 | return 0; | ||
| 3319 | } | 3346 | } |
| 3320 | 3347 | ||
| 3321 | static void | 3348 | static void |
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 0f9961eede1e..ed115acb5dee 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <linux/random.h> | 11 | #include <linux/random.h> |
| 12 | #include <linux/string.h> | 12 | #include <linux/string.h> |
| 13 | #include <linux/fscrypto.h> | 13 | #include <linux/fscrypto.h> |
| 14 | #include <linux/mount.h> | ||
| 14 | 15 | ||
| 15 | static int inode_has_encryption_context(struct inode *inode) | 16 | static int inode_has_encryption_context(struct inode *inode) |
| 16 | { | 17 | { |
| @@ -92,26 +93,42 @@ static int create_encryption_context_from_policy(struct inode *inode, | |||
| 92 | return inode->i_sb->s_cop->set_context(inode, &ctx, sizeof(ctx), NULL); | 93 | return inode->i_sb->s_cop->set_context(inode, &ctx, sizeof(ctx), NULL); |
| 93 | } | 94 | } |
| 94 | 95 | ||
| 95 | int fscrypt_process_policy(struct inode *inode, | 96 | int fscrypt_process_policy(struct file *filp, |
| 96 | const struct fscrypt_policy *policy) | 97 | const struct fscrypt_policy *policy) |
| 97 | { | 98 | { |
| 99 | struct inode *inode = file_inode(filp); | ||
| 100 | int ret; | ||
| 101 | |||
| 102 | if (!inode_owner_or_capable(inode)) | ||
| 103 | return -EACCES; | ||
| 104 | |||
| 98 | if (policy->version != 0) | 105 | if (policy->version != 0) |
| 99 | return -EINVAL; | 106 | return -EINVAL; |
| 100 | 107 | ||
| 108 | ret = mnt_want_write_file(filp); | ||
| 109 | if (ret) | ||
| 110 | return ret; | ||
| 111 | |||
| 101 | if (!inode_has_encryption_context(inode)) { | 112 | if (!inode_has_encryption_context(inode)) { |
| 102 | if (!inode->i_sb->s_cop->empty_dir) | 113 | if (!S_ISDIR(inode->i_mode)) |
| 103 | return -EOPNOTSUPP; | 114 | ret = -EINVAL; |
| 104 | if (!inode->i_sb->s_cop->empty_dir(inode)) | 115 | else if (!inode->i_sb->s_cop->empty_dir) |
| 105 | return -ENOTEMPTY; | 116 | ret = -EOPNOTSUPP; |
| 106 | return create_encryption_context_from_policy(inode, policy); | 117 | else if (!inode->i_sb->s_cop->empty_dir(inode)) |
| 118 | ret = -ENOTEMPTY; | ||
| 119 | else | ||
| 120 | ret = create_encryption_context_from_policy(inode, | ||
| 121 | policy); | ||
| 122 | } else if (!is_encryption_context_consistent_with_policy(inode, | ||
| 123 | policy)) { | ||
| 124 | printk(KERN_WARNING | ||
| 125 | "%s: Policy inconsistent with encryption context\n", | ||
| 126 | __func__); | ||
| 127 | ret = -EINVAL; | ||
| 107 | } | 128 | } |
| 108 | 129 | ||
| 109 | if (is_encryption_context_consistent_with_policy(inode, policy)) | 130 | mnt_drop_write_file(filp); |
| 110 | return 0; | 131 | return ret; |
| 111 | |||
| 112 | printk(KERN_WARNING "%s: Policy inconsistent with encryption context\n", | ||
| 113 | __func__); | ||
| 114 | return -EINVAL; | ||
| 115 | } | 132 | } |
| 116 | EXPORT_SYMBOL(fscrypt_process_policy); | 133 | EXPORT_SYMBOL(fscrypt_process_policy); |
| 117 | 134 | ||
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index d116453b0276..79a5941c2474 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
| @@ -585,7 +585,8 @@ struct dentry *devpts_pty_new(struct pts_fs_info *fsi, int index, void *priv) | |||
| 585 | */ | 585 | */ |
| 586 | void *devpts_get_priv(struct dentry *dentry) | 586 | void *devpts_get_priv(struct dentry *dentry) |
| 587 | { | 587 | { |
| 588 | WARN_ON_ONCE(dentry->d_sb->s_magic != DEVPTS_SUPER_MAGIC); | 588 | if (dentry->d_sb->s_magic != DEVPTS_SUPER_MAGIC) |
| 589 | return NULL; | ||
| 589 | return dentry->d_fsdata; | 590 | return dentry->d_fsdata; |
| 590 | } | 591 | } |
| 591 | 592 | ||
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c index eea64912c9c0..466f7d60edc2 100644 --- a/fs/dlm/debug_fs.c +++ b/fs/dlm/debug_fs.c | |||
| @@ -607,20 +607,54 @@ static const struct file_operations format2_fops; | |||
| 607 | static const struct file_operations format3_fops; | 607 | static const struct file_operations format3_fops; |
| 608 | static const struct file_operations format4_fops; | 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 | struct seq_file *seq; | 612 | struct seq_file *seq; |
| 613 | int ret = -1; | 613 | int ret; |
| 614 | 614 | ||
| 615 | if (file->f_op == &format1_fops) | 615 | ret = seq_open(file, &format1_seq_ops); |
| 616 | ret = seq_open(file, &format1_seq_ops); | 616 | if (ret) |
| 617 | else if (file->f_op == &format2_fops) | 617 | return ret; |
| 618 | ret = seq_open(file, &format2_seq_ops); | 618 | |
| 619 | else if (file->f_op == &format3_fops) | 619 | seq = file->private_data; |
| 620 | ret = seq_open(file, &format3_seq_ops); | 620 | seq->private = inode->i_private; /* the dlm_ls */ |
| 621 | else if (file->f_op == &format4_fops) | 621 | return 0; |
| 622 | ret = seq_open(file, &format4_seq_ops); | 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; | ||
| 623 | 656 | ||
| 657 | ret = seq_open(file, &format4_seq_ops); | ||
| 624 | if (ret) | 658 | if (ret) |
| 625 | return ret; | 659 | return ret; |
| 626 | 660 | ||
| @@ -631,7 +665,7 @@ static int table_open(struct inode *inode, struct file *file) | |||
| 631 | 665 | ||
| 632 | static const struct file_operations format1_fops = { | 666 | static const struct file_operations format1_fops = { |
| 633 | .owner = THIS_MODULE, | 667 | .owner = THIS_MODULE, |
| 634 | .open = table_open, | 668 | .open = table_open1, |
| 635 | .read = seq_read, | 669 | .read = seq_read, |
| 636 | .llseek = seq_lseek, | 670 | .llseek = seq_lseek, |
| 637 | .release = seq_release | 671 | .release = seq_release |
| @@ -639,7 +673,7 @@ static const struct file_operations format1_fops = { | |||
| 639 | 673 | ||
| 640 | static const struct file_operations format2_fops = { | 674 | static const struct file_operations format2_fops = { |
| 641 | .owner = THIS_MODULE, | 675 | .owner = THIS_MODULE, |
| 642 | .open = table_open, | 676 | .open = table_open2, |
| 643 | .read = seq_read, | 677 | .read = seq_read, |
| 644 | .llseek = seq_lseek, | 678 | .llseek = seq_lseek, |
| 645 | .release = seq_release | 679 | .release = seq_release |
| @@ -647,7 +681,7 @@ static const struct file_operations format2_fops = { | |||
| 647 | 681 | ||
| 648 | static const struct file_operations format3_fops = { | 682 | static const struct file_operations format3_fops = { |
| 649 | .owner = THIS_MODULE, | 683 | .owner = THIS_MODULE, |
| 650 | .open = table_open, | 684 | .open = table_open3, |
| 651 | .read = seq_read, | 685 | .read = seq_read, |
| 652 | .llseek = seq_lseek, | 686 | .llseek = seq_lseek, |
| 653 | .release = seq_release | 687 | .release = seq_release |
| @@ -655,7 +689,7 @@ static const struct file_operations format3_fops = { | |||
| 655 | 689 | ||
| 656 | static const struct file_operations format4_fops = { | 690 | static const struct file_operations format4_fops = { |
| 657 | .owner = THIS_MODULE, | 691 | .owner = THIS_MODULE, |
| 658 | .open = table_open, | 692 | .open = table_open4, |
| 659 | .read = seq_read, | 693 | .read = seq_read, |
| 660 | .llseek = seq_lseek, | 694 | .llseek = seq_lseek, |
| 661 | .release = seq_release | 695 | .release = seq_release |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 3131747199e1..c6ea25a190f8 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
| @@ -5466,8 +5466,6 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode) | |||
| 5466 | sbi->s_want_extra_isize, | 5466 | sbi->s_want_extra_isize, |
| 5467 | iloc, handle); | 5467 | iloc, handle); |
| 5468 | if (ret) { | 5468 | if (ret) { |
| 5469 | ext4_set_inode_state(inode, | ||
| 5470 | EXT4_STATE_NO_EXPAND); | ||
| 5471 | if (mnt_count != | 5469 | if (mnt_count != |
| 5472 | le16_to_cpu(sbi->s_es->s_mnt_count)) { | 5470 | le16_to_cpu(sbi->s_es->s_mnt_count)) { |
| 5473 | ext4_warning(inode->i_sb, | 5471 | ext4_warning(inode->i_sb, |
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 10686fd67fb4..1bb7df5e4536 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c | |||
| @@ -776,7 +776,7 @@ resizefs_out: | |||
| 776 | (struct fscrypt_policy __user *)arg, | 776 | (struct fscrypt_policy __user *)arg, |
| 777 | sizeof(policy))) | 777 | sizeof(policy))) |
| 778 | return -EFAULT; | 778 | return -EFAULT; |
| 779 | return fscrypt_process_policy(inode, &policy); | 779 | return fscrypt_process_policy(filp, &policy); |
| 780 | #else | 780 | #else |
| 781 | return -EOPNOTSUPP; | 781 | return -EOPNOTSUPP; |
| 782 | #endif | 782 | #endif |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 1c593aa0218e..3ec8708989ca 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
| @@ -2211,6 +2211,7 @@ void ext4_group_desc_csum_set(struct super_block *sb, __u32 block_group, | |||
| 2211 | 2211 | ||
| 2212 | /* Called at mount-time, super-block is locked */ | 2212 | /* Called at mount-time, super-block is locked */ |
| 2213 | static int ext4_check_descriptors(struct super_block *sb, | 2213 | static int ext4_check_descriptors(struct super_block *sb, |
| 2214 | ext4_fsblk_t sb_block, | ||
| 2214 | ext4_group_t *first_not_zeroed) | 2215 | ext4_group_t *first_not_zeroed) |
| 2215 | { | 2216 | { |
| 2216 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 2217 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
| @@ -2241,6 +2242,11 @@ static int ext4_check_descriptors(struct super_block *sb, | |||
| 2241 | grp = i; | 2242 | grp = i; |
| 2242 | 2243 | ||
| 2243 | block_bitmap = ext4_block_bitmap(sb, gdp); | 2244 | block_bitmap = ext4_block_bitmap(sb, gdp); |
| 2245 | if (block_bitmap == sb_block) { | ||
| 2246 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " | ||
| 2247 | "Block bitmap for group %u overlaps " | ||
| 2248 | "superblock", i); | ||
| 2249 | } | ||
| 2244 | if (block_bitmap < first_block || block_bitmap > last_block) { | 2250 | if (block_bitmap < first_block || block_bitmap > last_block) { |
| 2245 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " | 2251 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " |
| 2246 | "Block bitmap for group %u not in group " | 2252 | "Block bitmap for group %u not in group " |
| @@ -2248,6 +2254,11 @@ static int ext4_check_descriptors(struct super_block *sb, | |||
| 2248 | return 0; | 2254 | return 0; |
| 2249 | } | 2255 | } |
| 2250 | inode_bitmap = ext4_inode_bitmap(sb, gdp); | 2256 | inode_bitmap = ext4_inode_bitmap(sb, gdp); |
| 2257 | if (inode_bitmap == sb_block) { | ||
| 2258 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " | ||
| 2259 | "Inode bitmap for group %u overlaps " | ||
| 2260 | "superblock", i); | ||
| 2261 | } | ||
| 2251 | if (inode_bitmap < first_block || inode_bitmap > last_block) { | 2262 | if (inode_bitmap < first_block || inode_bitmap > last_block) { |
| 2252 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " | 2263 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " |
| 2253 | "Inode bitmap for group %u not in group " | 2264 | "Inode bitmap for group %u not in group " |
| @@ -2255,6 +2266,11 @@ static int ext4_check_descriptors(struct super_block *sb, | |||
| 2255 | return 0; | 2266 | return 0; |
| 2256 | } | 2267 | } |
| 2257 | inode_table = ext4_inode_table(sb, gdp); | 2268 | inode_table = ext4_inode_table(sb, gdp); |
| 2269 | if (inode_table == sb_block) { | ||
| 2270 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " | ||
| 2271 | "Inode table for group %u overlaps " | ||
| 2272 | "superblock", i); | ||
| 2273 | } | ||
| 2258 | if (inode_table < first_block || | 2274 | if (inode_table < first_block || |
| 2259 | inode_table + sbi->s_itb_per_group - 1 > last_block) { | 2275 | inode_table + sbi->s_itb_per_group - 1 > last_block) { |
| 2260 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " | 2276 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " |
| @@ -3757,7 +3773,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 3757 | goto failed_mount2; | 3773 | goto failed_mount2; |
| 3758 | } | 3774 | } |
| 3759 | } | 3775 | } |
| 3760 | if (!ext4_check_descriptors(sb, &first_not_zeroed)) { | 3776 | if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) { |
| 3761 | ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); | 3777 | ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); |
| 3762 | ret = -EFSCORRUPTED; | 3778 | ret = -EFSCORRUPTED; |
| 3763 | goto failed_mount2; | 3779 | goto failed_mount2; |
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 39e9cfb1b371..2eb935ca5d9e 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
| @@ -1353,15 +1353,19 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, | |||
| 1353 | size_t min_offs, free; | 1353 | size_t min_offs, free; |
| 1354 | int total_ino; | 1354 | int total_ino; |
| 1355 | void *base, *start, *end; | 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 | int s_min_extra_isize = le16_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_min_extra_isize); | 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 | down_write(&EXT4_I(inode)->xattr_sem); | 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 | retry: | 1365 | retry: |
| 1361 | if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) { | 1366 | isize_diff = new_extra_isize - EXT4_I(inode)->i_extra_isize; |
| 1362 | up_write(&EXT4_I(inode)->xattr_sem); | 1367 | if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) |
| 1363 | return 0; | 1368 | goto out; |
| 1364 | } | ||
| 1365 | 1369 | ||
| 1366 | header = IHDR(inode, raw_inode); | 1370 | header = IHDR(inode, raw_inode); |
| 1367 | entry = IFIRST(header); | 1371 | entry = IFIRST(header); |
| @@ -1382,7 +1386,7 @@ retry: | |||
| 1382 | goto cleanup; | 1386 | goto cleanup; |
| 1383 | 1387 | ||
| 1384 | free = ext4_xattr_free_space(last, &min_offs, base, &total_ino); | 1388 | free = ext4_xattr_free_space(last, &min_offs, base, &total_ino); |
| 1385 | if (free >= new_extra_isize) { | 1389 | if (free >= isize_diff) { |
| 1386 | entry = IFIRST(header); | 1390 | entry = IFIRST(header); |
| 1387 | ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize | 1391 | ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize |
| 1388 | - new_extra_isize, (void *)raw_inode + | 1392 | - new_extra_isize, (void *)raw_inode + |
| @@ -1390,8 +1394,7 @@ retry: | |||
| 1390 | (void *)header, total_ino, | 1394 | (void *)header, total_ino, |
| 1391 | inode->i_sb->s_blocksize); | 1395 | inode->i_sb->s_blocksize); |
| 1392 | EXT4_I(inode)->i_extra_isize = new_extra_isize; | 1396 | EXT4_I(inode)->i_extra_isize = new_extra_isize; |
| 1393 | error = 0; | 1397 | goto out; |
| 1394 | goto cleanup; | ||
| 1395 | } | 1398 | } |
| 1396 | 1399 | ||
| 1397 | /* | 1400 | /* |
| @@ -1414,7 +1417,7 @@ retry: | |||
| 1414 | end = bh->b_data + bh->b_size; | 1417 | end = bh->b_data + bh->b_size; |
| 1415 | min_offs = end - base; | 1418 | min_offs = end - base; |
| 1416 | free = ext4_xattr_free_space(first, &min_offs, base, NULL); | 1419 | free = ext4_xattr_free_space(first, &min_offs, base, NULL); |
| 1417 | if (free < new_extra_isize) { | 1420 | if (free < isize_diff) { |
| 1418 | if (!tried_min_extra_isize && s_min_extra_isize) { | 1421 | if (!tried_min_extra_isize && s_min_extra_isize) { |
| 1419 | tried_min_extra_isize++; | 1422 | tried_min_extra_isize++; |
| 1420 | new_extra_isize = s_min_extra_isize; | 1423 | new_extra_isize = s_min_extra_isize; |
| @@ -1428,7 +1431,7 @@ retry: | |||
| 1428 | free = inode->i_sb->s_blocksize; | 1431 | free = inode->i_sb->s_blocksize; |
| 1429 | } | 1432 | } |
| 1430 | 1433 | ||
| 1431 | while (new_extra_isize > 0) { | 1434 | while (isize_diff > 0) { |
| 1432 | size_t offs, size, entry_size; | 1435 | size_t offs, size, entry_size; |
| 1433 | struct ext4_xattr_entry *small_entry = NULL; | 1436 | struct ext4_xattr_entry *small_entry = NULL; |
| 1434 | struct ext4_xattr_info i = { | 1437 | struct ext4_xattr_info i = { |
| @@ -1459,7 +1462,7 @@ retry: | |||
| 1459 | EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) + | 1462 | EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) + |
| 1460 | EXT4_XATTR_LEN(last->e_name_len); | 1463 | EXT4_XATTR_LEN(last->e_name_len); |
| 1461 | if (total_size <= free && total_size < min_total_size) { | 1464 | if (total_size <= free && total_size < min_total_size) { |
| 1462 | if (total_size < new_extra_isize) { | 1465 | if (total_size < isize_diff) { |
| 1463 | small_entry = last; | 1466 | small_entry = last; |
| 1464 | } else { | 1467 | } else { |
| 1465 | entry = last; | 1468 | entry = last; |
| @@ -1514,22 +1517,22 @@ retry: | |||
| 1514 | error = ext4_xattr_ibody_set(handle, inode, &i, is); | 1517 | error = ext4_xattr_ibody_set(handle, inode, &i, is); |
| 1515 | if (error) | 1518 | if (error) |
| 1516 | goto cleanup; | 1519 | goto cleanup; |
| 1520 | total_ino -= entry_size; | ||
| 1517 | 1521 | ||
| 1518 | entry = IFIRST(header); | 1522 | entry = IFIRST(header); |
| 1519 | if (entry_size + EXT4_XATTR_SIZE(size) >= new_extra_isize) | 1523 | if (entry_size + EXT4_XATTR_SIZE(size) >= isize_diff) |
| 1520 | shift_bytes = new_extra_isize; | 1524 | shift_bytes = isize_diff; |
| 1521 | else | 1525 | else |
| 1522 | shift_bytes = entry_size + size; | 1526 | shift_bytes = entry_size + EXT4_XATTR_SIZE(size); |
| 1523 | /* Adjust the offsets and shift the remaining entries ahead */ | 1527 | /* Adjust the offsets and shift the remaining entries ahead */ |
| 1524 | ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize - | 1528 | ext4_xattr_shift_entries(entry, -shift_bytes, |
| 1525 | shift_bytes, (void *)raw_inode + | 1529 | (void *)raw_inode + EXT4_GOOD_OLD_INODE_SIZE + |
| 1526 | EXT4_GOOD_OLD_INODE_SIZE + extra_isize + shift_bytes, | 1530 | EXT4_I(inode)->i_extra_isize + shift_bytes, |
| 1527 | (void *)header, total_ino - entry_size, | 1531 | (void *)header, total_ino, inode->i_sb->s_blocksize); |
| 1528 | inode->i_sb->s_blocksize); | ||
| 1529 | 1532 | ||
| 1530 | extra_isize += shift_bytes; | 1533 | isize_diff -= shift_bytes; |
| 1531 | new_extra_isize -= shift_bytes; | 1534 | EXT4_I(inode)->i_extra_isize += shift_bytes; |
| 1532 | EXT4_I(inode)->i_extra_isize = extra_isize; | 1535 | header = IHDR(inode, raw_inode); |
| 1533 | 1536 | ||
| 1534 | i.name = b_entry_name; | 1537 | i.name = b_entry_name; |
| 1535 | i.value = buffer; | 1538 | i.value = buffer; |
| @@ -1551,6 +1554,8 @@ retry: | |||
| 1551 | kfree(bs); | 1554 | kfree(bs); |
| 1552 | } | 1555 | } |
| 1553 | brelse(bh); | 1556 | brelse(bh); |
| 1557 | out: | ||
| 1558 | ext4_clear_inode_state(inode, EXT4_STATE_NO_EXPAND); | ||
| 1554 | up_write(&EXT4_I(inode)->xattr_sem); | 1559 | up_write(&EXT4_I(inode)->xattr_sem); |
| 1555 | return 0; | 1560 | return 0; |
| 1556 | 1561 | ||
| @@ -1562,6 +1567,10 @@ cleanup: | |||
| 1562 | kfree(is); | 1567 | kfree(is); |
| 1563 | kfree(bs); | 1568 | kfree(bs); |
| 1564 | brelse(bh); | 1569 | brelse(bh); |
| 1570 | /* | ||
| 1571 | * We deliberately leave EXT4_STATE_NO_EXPAND set here since inode | ||
| 1572 | * size expansion failed. | ||
| 1573 | */ | ||
| 1565 | up_write(&EXT4_I(inode)->xattr_sem); | 1574 | up_write(&EXT4_I(inode)->xattr_sem); |
| 1566 | return error; | 1575 | return error; |
| 1567 | } | 1576 | } |
diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h index 69dd3e6566e0..a92e783fa057 100644 --- a/fs/ext4/xattr.h +++ b/fs/ext4/xattr.h | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #define EXT4_XATTR_INDEX_SYSTEM 7 | 24 | #define EXT4_XATTR_INDEX_SYSTEM 7 |
| 25 | #define EXT4_XATTR_INDEX_RICHACL 8 | 25 | #define EXT4_XATTR_INDEX_RICHACL 8 |
| 26 | #define EXT4_XATTR_INDEX_ENCRYPTION 9 | 26 | #define EXT4_XATTR_INDEX_ENCRYPTION 9 |
| 27 | #define EXT4_XATTR_INDEX_HURD 10 /* Reserved for Hurd */ | ||
| 27 | 28 | ||
| 28 | struct ext4_xattr_header { | 29 | struct ext4_xattr_header { |
| 29 | __le32 h_magic; /* magic number for identification */ | 30 | __le32 h_magic; /* magic number for identification */ |
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index d64d2a515cb2..ccb401eebc11 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c | |||
| @@ -1699,11 +1699,11 @@ static int f2fs_write_end(struct file *file, | |||
| 1699 | trace_f2fs_write_end(inode, pos, len, copied); | 1699 | trace_f2fs_write_end(inode, pos, len, copied); |
| 1700 | 1700 | ||
| 1701 | set_page_dirty(page); | 1701 | set_page_dirty(page); |
| 1702 | f2fs_put_page(page, 1); | ||
| 1703 | 1702 | ||
| 1704 | if (pos + copied > i_size_read(inode)) | 1703 | if (pos + copied > i_size_read(inode)) |
| 1705 | f2fs_i_size_write(inode, pos + copied); | 1704 | f2fs_i_size_write(inode, pos + copied); |
| 1706 | 1705 | ||
| 1706 | f2fs_put_page(page, 1); | ||
| 1707 | f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); | 1707 | f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); |
| 1708 | return copied; | 1708 | return copied; |
| 1709 | } | 1709 | } |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 675fa79d86f6..14f5fe2b841e 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
| @@ -538,7 +538,7 @@ struct f2fs_nm_info { | |||
| 538 | /* NAT cache management */ | 538 | /* NAT cache management */ |
| 539 | struct radix_tree_root nat_root;/* root of the nat entry cache */ | 539 | struct radix_tree_root nat_root;/* root of the nat entry cache */ |
| 540 | struct radix_tree_root nat_set_root;/* root of the nat set cache */ | 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 | struct list_head nat_entries; /* cached nat entry list (clean) */ | 542 | struct list_head nat_entries; /* cached nat entry list (clean) */ |
| 543 | unsigned int nat_cnt; /* the # of cached nat entries */ | 543 | unsigned int nat_cnt; /* the # of cached nat entries */ |
| 544 | unsigned int dirty_nat_cnt; /* total num of nat entries in set */ | 544 | unsigned int dirty_nat_cnt; /* total num of nat entries in set */ |
| @@ -787,7 +787,7 @@ struct f2fs_sb_info { | |||
| 787 | struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */ | 787 | struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */ |
| 788 | struct inode *meta_inode; /* cache meta blocks */ | 788 | struct inode *meta_inode; /* cache meta blocks */ |
| 789 | struct mutex cp_mutex; /* checkpoint procedure lock */ | 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 | struct rw_semaphore node_write; /* locking node writes */ | 791 | struct rw_semaphore node_write; /* locking node writes */ |
| 792 | wait_queue_head_t cp_wait; | 792 | wait_queue_head_t cp_wait; |
| 793 | unsigned long last_time[MAX_TIME]; /* to store time in jiffies */ | 793 | unsigned long last_time[MAX_TIME]; /* to store time in jiffies */ |
| @@ -1074,22 +1074,22 @@ static inline void clear_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f) | |||
| 1074 | 1074 | ||
| 1075 | static inline void f2fs_lock_op(struct f2fs_sb_info *sbi) | 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 | static inline void f2fs_unlock_op(struct f2fs_sb_info *sbi) | 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 | static inline void f2fs_lock_all(struct f2fs_sb_info *sbi) | 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 | static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi) | 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 | static inline int __get_cp_reason(struct f2fs_sb_info *sbi) | 1095 | static inline int __get_cp_reason(struct f2fs_sb_info *sbi) |
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 0e493f63ea41..28f4f4cbb8d8 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
| @@ -1757,21 +1757,14 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg) | |||
| 1757 | { | 1757 | { |
| 1758 | struct fscrypt_policy policy; | 1758 | struct fscrypt_policy policy; |
| 1759 | struct inode *inode = file_inode(filp); | 1759 | struct inode *inode = file_inode(filp); |
| 1760 | int ret; | ||
| 1761 | 1760 | ||
| 1762 | if (copy_from_user(&policy, (struct fscrypt_policy __user *)arg, | 1761 | if (copy_from_user(&policy, (struct fscrypt_policy __user *)arg, |
| 1763 | sizeof(policy))) | 1762 | sizeof(policy))) |
| 1764 | return -EFAULT; | 1763 | return -EFAULT; |
| 1765 | 1764 | ||
| 1766 | ret = mnt_want_write_file(filp); | ||
| 1767 | if (ret) | ||
| 1768 | return ret; | ||
| 1769 | |||
| 1770 | f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); | 1765 | f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); |
| 1771 | ret = fscrypt_process_policy(inode, &policy); | ||
| 1772 | 1766 | ||
| 1773 | mnt_drop_write_file(filp); | 1767 | return fscrypt_process_policy(filp, &policy); |
| 1774 | return ret; | ||
| 1775 | } | 1768 | } |
| 1776 | 1769 | ||
| 1777 | static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg) | 1770 | static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg) |
| @@ -2086,15 +2079,19 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, | |||
| 2086 | if (unlikely(f2fs_readonly(src->i_sb))) | 2079 | if (unlikely(f2fs_readonly(src->i_sb))) |
| 2087 | return -EROFS; | 2080 | return -EROFS; |
| 2088 | 2081 | ||
| 2089 | if (S_ISDIR(src->i_mode) || S_ISDIR(dst->i_mode)) | 2082 | if (!S_ISREG(src->i_mode) || !S_ISREG(dst->i_mode)) |
| 2090 | return -EISDIR; | 2083 | return -EINVAL; |
| 2091 | 2084 | ||
| 2092 | if (f2fs_encrypted_inode(src) || f2fs_encrypted_inode(dst)) | 2085 | if (f2fs_encrypted_inode(src) || f2fs_encrypted_inode(dst)) |
| 2093 | return -EOPNOTSUPP; | 2086 | return -EOPNOTSUPP; |
| 2094 | 2087 | ||
| 2095 | inode_lock(src); | 2088 | inode_lock(src); |
| 2096 | if (src != dst) | 2089 | if (src != dst) { |
| 2097 | inode_lock(dst); | 2090 | if (!inode_trylock(dst)) { |
| 2091 | ret = -EBUSY; | ||
| 2092 | goto out; | ||
| 2093 | } | ||
| 2094 | } | ||
| 2098 | 2095 | ||
| 2099 | ret = -EINVAL; | 2096 | ret = -EINVAL; |
| 2100 | if (pos_in + len > src->i_size || pos_in + len < pos_in) | 2097 | if (pos_in + len > src->i_size || pos_in + len < pos_in) |
| @@ -2152,6 +2149,7 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, | |||
| 2152 | out_unlock: | 2149 | out_unlock: |
| 2153 | if (src != dst) | 2150 | if (src != dst) |
| 2154 | inode_unlock(dst); | 2151 | inode_unlock(dst); |
| 2152 | out: | ||
| 2155 | inode_unlock(src); | 2153 | inode_unlock(src); |
| 2156 | return ret; | 2154 | return ret; |
| 2157 | } | 2155 | } |
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index b2fa4b615925..f75d197d5beb 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c | |||
| @@ -206,14 +206,14 @@ int need_dentry_mark(struct f2fs_sb_info *sbi, nid_t nid) | |||
| 206 | struct nat_entry *e; | 206 | struct nat_entry *e; |
| 207 | bool need = false; | 207 | bool need = false; |
| 208 | 208 | ||
| 209 | percpu_down_read(&nm_i->nat_tree_lock); | 209 | down_read(&nm_i->nat_tree_lock); |
| 210 | e = __lookup_nat_cache(nm_i, nid); | 210 | e = __lookup_nat_cache(nm_i, nid); |
| 211 | if (e) { | 211 | if (e) { |
| 212 | if (!get_nat_flag(e, IS_CHECKPOINTED) && | 212 | if (!get_nat_flag(e, IS_CHECKPOINTED) && |
| 213 | !get_nat_flag(e, HAS_FSYNCED_INODE)) | 213 | !get_nat_flag(e, HAS_FSYNCED_INODE)) |
| 214 | need = true; | 214 | need = true; |
| 215 | } | 215 | } |
| 216 | percpu_up_read(&nm_i->nat_tree_lock); | 216 | up_read(&nm_i->nat_tree_lock); |
| 217 | return need; | 217 | return need; |
| 218 | } | 218 | } |
| 219 | 219 | ||
| @@ -223,11 +223,11 @@ bool is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid) | |||
| 223 | struct nat_entry *e; | 223 | struct nat_entry *e; |
| 224 | bool is_cp = true; | 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 | e = __lookup_nat_cache(nm_i, nid); | 227 | e = __lookup_nat_cache(nm_i, nid); |
| 228 | if (e && !get_nat_flag(e, IS_CHECKPOINTED)) | 228 | if (e && !get_nat_flag(e, IS_CHECKPOINTED)) |
| 229 | is_cp = false; | 229 | is_cp = false; |
| 230 | percpu_up_read(&nm_i->nat_tree_lock); | 230 | up_read(&nm_i->nat_tree_lock); |
| 231 | return is_cp; | 231 | return is_cp; |
| 232 | } | 232 | } |
| 233 | 233 | ||
| @@ -237,13 +237,13 @@ bool need_inode_block_update(struct f2fs_sb_info *sbi, nid_t ino) | |||
| 237 | struct nat_entry *e; | 237 | struct nat_entry *e; |
| 238 | bool need_update = true; | 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 | e = __lookup_nat_cache(nm_i, ino); | 241 | e = __lookup_nat_cache(nm_i, ino); |
| 242 | if (e && get_nat_flag(e, HAS_LAST_FSYNC) && | 242 | if (e && get_nat_flag(e, HAS_LAST_FSYNC) && |
| 243 | (get_nat_flag(e, IS_CHECKPOINTED) || | 243 | (get_nat_flag(e, IS_CHECKPOINTED) || |
| 244 | get_nat_flag(e, HAS_FSYNCED_INODE))) | 244 | get_nat_flag(e, HAS_FSYNCED_INODE))) |
| 245 | need_update = false; | 245 | need_update = false; |
| 246 | percpu_up_read(&nm_i->nat_tree_lock); | 246 | up_read(&nm_i->nat_tree_lock); |
| 247 | return need_update; | 247 | return need_update; |
| 248 | } | 248 | } |
| 249 | 249 | ||
| @@ -284,7 +284,7 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni, | |||
| 284 | struct f2fs_nm_info *nm_i = NM_I(sbi); | 284 | struct f2fs_nm_info *nm_i = NM_I(sbi); |
| 285 | struct nat_entry *e; | 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 | e = __lookup_nat_cache(nm_i, ni->nid); | 288 | e = __lookup_nat_cache(nm_i, ni->nid); |
| 289 | if (!e) { | 289 | if (!e) { |
| 290 | e = grab_nat_entry(nm_i, ni->nid); | 290 | e = grab_nat_entry(nm_i, ni->nid); |
| @@ -334,7 +334,7 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni, | |||
| 334 | set_nat_flag(e, HAS_FSYNCED_INODE, true); | 334 | set_nat_flag(e, HAS_FSYNCED_INODE, true); |
| 335 | set_nat_flag(e, HAS_LAST_FSYNC, fsync_done); | 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 | int try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink) | 340 | int try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink) |
| @@ -342,7 +342,8 @@ int try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink) | |||
| 342 | struct f2fs_nm_info *nm_i = NM_I(sbi); | 342 | struct f2fs_nm_info *nm_i = NM_I(sbi); |
| 343 | int nr = nr_shrink; | 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 | while (nr_shrink && !list_empty(&nm_i->nat_entries)) { | 348 | while (nr_shrink && !list_empty(&nm_i->nat_entries)) { |
| 348 | struct nat_entry *ne; | 349 | struct nat_entry *ne; |
| @@ -351,7 +352,7 @@ int try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink) | |||
| 351 | __del_from_nat_cache(nm_i, ne); | 352 | __del_from_nat_cache(nm_i, ne); |
| 352 | nr_shrink--; | 353 | nr_shrink--; |
| 353 | } | 354 | } |
| 354 | percpu_up_write(&nm_i->nat_tree_lock); | 355 | up_write(&nm_i->nat_tree_lock); |
| 355 | return nr - nr_shrink; | 356 | return nr - nr_shrink; |
| 356 | } | 357 | } |
| 357 | 358 | ||
| @@ -373,13 +374,13 @@ void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni) | |||
| 373 | ni->nid = nid; | 374 | ni->nid = nid; |
| 374 | 375 | ||
| 375 | /* Check nat cache */ | 376 | /* Check nat cache */ |
| 376 | percpu_down_read(&nm_i->nat_tree_lock); | 377 | down_read(&nm_i->nat_tree_lock); |
| 377 | e = __lookup_nat_cache(nm_i, nid); | 378 | e = __lookup_nat_cache(nm_i, nid); |
| 378 | if (e) { | 379 | if (e) { |
| 379 | ni->ino = nat_get_ino(e); | 380 | ni->ino = nat_get_ino(e); |
| 380 | ni->blk_addr = nat_get_blkaddr(e); | 381 | ni->blk_addr = nat_get_blkaddr(e); |
| 381 | ni->version = nat_get_version(e); | 382 | ni->version = nat_get_version(e); |
| 382 | percpu_up_read(&nm_i->nat_tree_lock); | 383 | up_read(&nm_i->nat_tree_lock); |
| 383 | return; | 384 | return; |
| 384 | } | 385 | } |
| 385 | 386 | ||
| @@ -403,11 +404,11 @@ void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni) | |||
| 403 | node_info_from_raw_nat(ni, &ne); | 404 | node_info_from_raw_nat(ni, &ne); |
| 404 | f2fs_put_page(page, 1); | 405 | f2fs_put_page(page, 1); |
| 405 | cache: | 406 | cache: |
| 406 | percpu_up_read(&nm_i->nat_tree_lock); | 407 | up_read(&nm_i->nat_tree_lock); |
| 407 | /* cache nat entry */ | 408 | /* cache nat entry */ |
| 408 | percpu_down_write(&nm_i->nat_tree_lock); | 409 | down_write(&nm_i->nat_tree_lock); |
| 409 | cache_nat_entry(sbi, nid, &ne); | 410 | cache_nat_entry(sbi, nid, &ne); |
| 410 | percpu_up_write(&nm_i->nat_tree_lock); | 411 | up_write(&nm_i->nat_tree_lock); |
| 411 | } | 412 | } |
| 412 | 413 | ||
| 413 | /* | 414 | /* |
| @@ -1788,7 +1789,7 @@ void build_free_nids(struct f2fs_sb_info *sbi) | |||
| 1788 | ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), FREE_NID_PAGES, | 1789 | ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), FREE_NID_PAGES, |
| 1789 | META_NAT, true); | 1790 | META_NAT, true); |
| 1790 | 1791 | ||
| 1791 | percpu_down_read(&nm_i->nat_tree_lock); | 1792 | down_read(&nm_i->nat_tree_lock); |
| 1792 | 1793 | ||
| 1793 | while (1) { | 1794 | while (1) { |
| 1794 | struct page *page = get_current_nat_page(sbi, nid); | 1795 | struct page *page = get_current_nat_page(sbi, nid); |
| @@ -1820,7 +1821,7 @@ void build_free_nids(struct f2fs_sb_info *sbi) | |||
| 1820 | remove_free_nid(nm_i, nid); | 1821 | remove_free_nid(nm_i, nid); |
| 1821 | } | 1822 | } |
| 1822 | up_read(&curseg->journal_rwsem); | 1823 | up_read(&curseg->journal_rwsem); |
| 1823 | percpu_up_read(&nm_i->nat_tree_lock); | 1824 | up_read(&nm_i->nat_tree_lock); |
| 1824 | 1825 | ||
| 1825 | ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nm_i->next_scan_nid), | 1826 | ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nm_i->next_scan_nid), |
| 1826 | nm_i->ra_nid_pages, META_NAT, false); | 1827 | nm_i->ra_nid_pages, META_NAT, false); |
| @@ -2209,7 +2210,7 @@ void flush_nat_entries(struct f2fs_sb_info *sbi) | |||
| 2209 | if (!nm_i->dirty_nat_cnt) | 2210 | if (!nm_i->dirty_nat_cnt) |
| 2210 | return; | 2211 | return; |
| 2211 | 2212 | ||
| 2212 | percpu_down_write(&nm_i->nat_tree_lock); | 2213 | down_write(&nm_i->nat_tree_lock); |
| 2213 | 2214 | ||
| 2214 | /* | 2215 | /* |
| 2215 | * if there are no enough space in journal to store dirty nat | 2216 | * if there are no enough space in journal to store dirty nat |
| @@ -2232,7 +2233,7 @@ void flush_nat_entries(struct f2fs_sb_info *sbi) | |||
| 2232 | list_for_each_entry_safe(set, tmp, &sets, set_list) | 2233 | list_for_each_entry_safe(set, tmp, &sets, set_list) |
| 2233 | __flush_nat_entry_set(sbi, set); | 2234 | __flush_nat_entry_set(sbi, set); |
| 2234 | 2235 | ||
| 2235 | percpu_up_write(&nm_i->nat_tree_lock); | 2236 | up_write(&nm_i->nat_tree_lock); |
| 2236 | 2237 | ||
| 2237 | f2fs_bug_on(sbi, nm_i->dirty_nat_cnt); | 2238 | f2fs_bug_on(sbi, nm_i->dirty_nat_cnt); |
| 2238 | } | 2239 | } |
| @@ -2268,8 +2269,7 @@ static int init_node_manager(struct f2fs_sb_info *sbi) | |||
| 2268 | 2269 | ||
| 2269 | mutex_init(&nm_i->build_lock); | 2270 | mutex_init(&nm_i->build_lock); |
| 2270 | spin_lock_init(&nm_i->free_nid_list_lock); | 2271 | spin_lock_init(&nm_i->free_nid_list_lock); |
| 2271 | if (percpu_init_rwsem(&nm_i->nat_tree_lock)) | 2272 | init_rwsem(&nm_i->nat_tree_lock); |
| 2272 | return -ENOMEM; | ||
| 2273 | 2273 | ||
| 2274 | nm_i->next_scan_nid = le32_to_cpu(sbi->ckpt->next_free_nid); | 2274 | nm_i->next_scan_nid = le32_to_cpu(sbi->ckpt->next_free_nid); |
| 2275 | nm_i->bitmap_size = __bitmap_size(sbi, NAT_BITMAP); | 2275 | nm_i->bitmap_size = __bitmap_size(sbi, NAT_BITMAP); |
| @@ -2326,7 +2326,7 @@ void destroy_node_manager(struct f2fs_sb_info *sbi) | |||
| 2326 | spin_unlock(&nm_i->free_nid_list_lock); | 2326 | spin_unlock(&nm_i->free_nid_list_lock); |
| 2327 | 2327 | ||
| 2328 | /* destroy nat cache */ | 2328 | /* destroy nat cache */ |
| 2329 | percpu_down_write(&nm_i->nat_tree_lock); | 2329 | down_write(&nm_i->nat_tree_lock); |
| 2330 | while ((found = __gang_lookup_nat_cache(nm_i, | 2330 | while ((found = __gang_lookup_nat_cache(nm_i, |
| 2331 | nid, NATVEC_SIZE, natvec))) { | 2331 | nid, NATVEC_SIZE, natvec))) { |
| 2332 | unsigned idx; | 2332 | unsigned idx; |
| @@ -2351,9 +2351,8 @@ void destroy_node_manager(struct f2fs_sb_info *sbi) | |||
| 2351 | kmem_cache_free(nat_entry_set_slab, setvec[idx]); | 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 | kfree(nm_i->nat_bitmap); | 2356 | kfree(nm_i->nat_bitmap); |
| 2358 | sbi->nm_info = NULL; | 2357 | sbi->nm_info = NULL; |
| 2359 | kfree(nm_i); | 2358 | kfree(nm_i); |
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 1b86d3f638ef..7f863a645ab1 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
| @@ -706,8 +706,6 @@ static void destroy_percpu_info(struct f2fs_sb_info *sbi) | |||
| 706 | percpu_counter_destroy(&sbi->nr_pages[i]); | 706 | percpu_counter_destroy(&sbi->nr_pages[i]); |
| 707 | percpu_counter_destroy(&sbi->alloc_valid_block_count); | 707 | percpu_counter_destroy(&sbi->alloc_valid_block_count); |
| 708 | percpu_counter_destroy(&sbi->total_valid_inode_count); | 708 | percpu_counter_destroy(&sbi->total_valid_inode_count); |
| 709 | |||
| 710 | percpu_free_rwsem(&sbi->cp_rwsem); | ||
| 711 | } | 709 | } |
| 712 | 710 | ||
| 713 | static void f2fs_put_super(struct super_block *sb) | 711 | static void f2fs_put_super(struct super_block *sb) |
| @@ -1483,9 +1481,6 @@ static int init_percpu_info(struct f2fs_sb_info *sbi) | |||
| 1483 | { | 1481 | { |
| 1484 | int i, err; | 1482 | int i, err; |
| 1485 | 1483 | ||
| 1486 | if (percpu_init_rwsem(&sbi->cp_rwsem)) | ||
| 1487 | return -ENOMEM; | ||
| 1488 | |||
| 1489 | for (i = 0; i < NR_COUNT_TYPE; i++) { | 1484 | for (i = 0; i < NR_COUNT_TYPE; i++) { |
| 1490 | err = percpu_counter_init(&sbi->nr_pages[i], 0, GFP_KERNEL); | 1485 | err = percpu_counter_init(&sbi->nr_pages[i], 0, GFP_KERNEL); |
| 1491 | if (err) | 1486 | if (err) |
| @@ -1686,6 +1681,7 @@ try_onemore: | |||
| 1686 | sbi->write_io[i].bio = NULL; | 1681 | sbi->write_io[i].bio = NULL; |
| 1687 | } | 1682 | } |
| 1688 | 1683 | ||
| 1684 | init_rwsem(&sbi->cp_rwsem); | ||
| 1689 | init_waitqueue_head(&sbi->cp_wait); | 1685 | init_waitqueue_head(&sbi->cp_wait); |
| 1690 | init_sb_info(sbi); | 1686 | init_sb_info(sbi); |
| 1691 | 1687 | ||
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index f394aff59c36..3988b43c2f5a 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
| @@ -530,13 +530,13 @@ void fuse_read_fill(struct fuse_req *req, struct file *file, loff_t pos, | |||
| 530 | req->out.args[0].size = count; | 530 | req->out.args[0].size = count; |
| 531 | } | 531 | } |
| 532 | 532 | ||
| 533 | static void fuse_release_user_pages(struct fuse_req *req, int write) | 533 | static void fuse_release_user_pages(struct fuse_req *req, bool should_dirty) |
| 534 | { | 534 | { |
| 535 | unsigned i; | 535 | unsigned i; |
| 536 | 536 | ||
| 537 | for (i = 0; i < req->num_pages; i++) { | 537 | for (i = 0; i < req->num_pages; i++) { |
| 538 | struct page *page = req->pages[i]; | 538 | struct page *page = req->pages[i]; |
| 539 | if (write) | 539 | if (should_dirty) |
| 540 | set_page_dirty_lock(page); | 540 | set_page_dirty_lock(page); |
| 541 | put_page(page); | 541 | put_page(page); |
| 542 | } | 542 | } |
| @@ -1320,6 +1320,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, | |||
| 1320 | loff_t *ppos, int flags) | 1320 | loff_t *ppos, int flags) |
| 1321 | { | 1321 | { |
| 1322 | int write = flags & FUSE_DIO_WRITE; | 1322 | int write = flags & FUSE_DIO_WRITE; |
| 1323 | bool should_dirty = !write && iter_is_iovec(iter); | ||
| 1323 | int cuse = flags & FUSE_DIO_CUSE; | 1324 | int cuse = flags & FUSE_DIO_CUSE; |
| 1324 | struct file *file = io->file; | 1325 | struct file *file = io->file; |
| 1325 | struct inode *inode = file->f_mapping->host; | 1326 | struct inode *inode = file->f_mapping->host; |
| @@ -1363,7 +1364,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, | |||
| 1363 | nres = fuse_send_read(req, io, pos, nbytes, owner); | 1364 | nres = fuse_send_read(req, io, pos, nbytes, owner); |
| 1364 | 1365 | ||
| 1365 | if (!io->async) | 1366 | if (!io->async) |
| 1366 | fuse_release_user_pages(req, !write); | 1367 | fuse_release_user_pages(req, should_dirty); |
| 1367 | if (req->out.h.error) { | 1368 | if (req->out.h.error) { |
| 1368 | err = req->out.h.error; | 1369 | err = req->out.h.error; |
| 1369 | break; | 1370 | break; |
diff --git a/fs/ioctl.c b/fs/ioctl.c index 0f56deb24ce6..c415668c86d4 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c | |||
| @@ -568,7 +568,7 @@ static int ioctl_fsthaw(struct file *filp) | |||
| 568 | return thaw_super(sb); | 568 | return thaw_super(sb); |
| 569 | } | 569 | } |
| 570 | 570 | ||
| 571 | static long ioctl_file_dedupe_range(struct file *file, void __user *arg) | 571 | static int ioctl_file_dedupe_range(struct file *file, void __user *arg) |
| 572 | { | 572 | { |
| 573 | struct file_dedupe_range __user *argp = arg; | 573 | struct file_dedupe_range __user *argp = arg; |
| 574 | struct file_dedupe_range *same = NULL; | 574 | struct file_dedupe_range *same = NULL; |
| @@ -582,6 +582,10 @@ static long ioctl_file_dedupe_range(struct file *file, void __user *arg) | |||
| 582 | } | 582 | } |
| 583 | 583 | ||
| 584 | size = offsetof(struct file_dedupe_range __user, info[count]); | 584 | size = offsetof(struct file_dedupe_range __user, info[count]); |
| 585 | if (size > PAGE_SIZE) { | ||
| 586 | ret = -ENOMEM; | ||
| 587 | goto out; | ||
| 588 | } | ||
| 585 | 589 | ||
| 586 | same = memdup_user(argp, size); | 590 | same = memdup_user(argp, size); |
| 587 | if (IS_ERR(same)) { | 591 | if (IS_ERR(same)) { |
diff --git a/fs/iomap.c b/fs/iomap.c index 0342254646e3..706270f21b35 100644 --- a/fs/iomap.c +++ b/fs/iomap.c | |||
| @@ -428,9 +428,12 @@ static int iomap_to_fiemap(struct fiemap_extent_info *fi, | |||
| 428 | break; | 428 | break; |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | if (iomap->flags & IOMAP_F_MERGED) | ||
| 432 | flags |= FIEMAP_EXTENT_MERGED; | ||
| 433 | |||
| 431 | return fiemap_fill_next_extent(fi, iomap->offset, | 434 | return fiemap_fill_next_extent(fi, iomap->offset, |
| 432 | iomap->blkno != IOMAP_NULL_BLOCK ? iomap->blkno << 9: 0, | 435 | iomap->blkno != IOMAP_NULL_BLOCK ? iomap->blkno << 9: 0, |
| 433 | iomap->length, flags | FIEMAP_EXTENT_MERGED); | 436 | iomap->length, flags); |
| 434 | 437 | ||
| 435 | } | 438 | } |
| 436 | 439 | ||
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index e1574008adc9..2bcb86e6e6ca 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c | |||
| @@ -840,21 +840,35 @@ repeat: | |||
| 840 | mutex_lock(&kernfs_mutex); | 840 | mutex_lock(&kernfs_mutex); |
| 841 | 841 | ||
| 842 | list_for_each_entry(info, &kernfs_root(kn)->supers, node) { | 842 | list_for_each_entry(info, &kernfs_root(kn)->supers, node) { |
| 843 | struct kernfs_node *parent; | ||
| 843 | struct inode *inode; | 844 | struct inode *inode; |
| 844 | struct dentry *dentry; | ||
| 845 | 845 | ||
| 846 | /* | ||
| 847 | * We want fsnotify_modify() on @kn but as the | ||
| 848 | * modifications aren't originating from userland don't | ||
| 849 | * have the matching @file available. Look up the inodes | ||
| 850 | * and generate the events manually. | ||
| 851 | */ | ||
| 846 | inode = ilookup(info->sb, kn->ino); | 852 | inode = ilookup(info->sb, kn->ino); |
| 847 | if (!inode) | 853 | if (!inode) |
| 848 | continue; | 854 | continue; |
| 849 | 855 | ||
| 850 | dentry = d_find_any_alias(inode); | 856 | parent = kernfs_get_parent(kn); |
| 851 | if (dentry) { | 857 | if (parent) { |
| 852 | fsnotify_parent(NULL, dentry, FS_MODIFY); | 858 | struct inode *p_inode; |
| 853 | fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE, | 859 | |
| 854 | NULL, 0); | 860 | p_inode = ilookup(info->sb, parent->ino); |
| 855 | dput(dentry); | 861 | if (p_inode) { |
| 862 | fsnotify(p_inode, FS_MODIFY | FS_EVENT_ON_CHILD, | ||
| 863 | inode, FSNOTIFY_EVENT_INODE, kn->name, 0); | ||
| 864 | iput(p_inode); | ||
| 865 | } | ||
| 866 | |||
| 867 | kernfs_put(parent); | ||
| 856 | } | 868 | } |
| 857 | 869 | ||
| 870 | fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE, | ||
| 871 | kn->name, 0); | ||
| 858 | iput(inode); | 872 | iput(inode); |
| 859 | } | 873 | } |
| 860 | 874 | ||
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c index f55a4e756047..217847679f0e 100644 --- a/fs/nfs/blocklayout/blocklayout.c +++ b/fs/nfs/blocklayout/blocklayout.c | |||
| @@ -346,7 +346,7 @@ static void bl_write_cleanup(struct work_struct *work) | |||
| 346 | PAGE_SIZE - 1) & (loff_t)PAGE_MASK; | 346 | PAGE_SIZE - 1) & (loff_t)PAGE_MASK; |
| 347 | 347 | ||
| 348 | ext_tree_mark_written(bl, start >> SECTOR_SHIFT, | 348 | ext_tree_mark_written(bl, start >> SECTOR_SHIFT, |
| 349 | (end - start) >> SECTOR_SHIFT); | 349 | (end - start) >> SECTOR_SHIFT, end); |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | pnfs_ld_write_done(hdr); | 352 | pnfs_ld_write_done(hdr); |
diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/blocklayout.h index 18e6fd0b9506..efc007f00742 100644 --- a/fs/nfs/blocklayout/blocklayout.h +++ b/fs/nfs/blocklayout/blocklayout.h | |||
| @@ -141,6 +141,7 @@ struct pnfs_block_layout { | |||
| 141 | struct rb_root bl_ext_ro; | 141 | struct rb_root bl_ext_ro; |
| 142 | spinlock_t bl_ext_lock; /* Protects list manipulation */ | 142 | spinlock_t bl_ext_lock; /* Protects list manipulation */ |
| 143 | bool bl_scsi_layout; | 143 | bool bl_scsi_layout; |
| 144 | u64 bl_lwb; | ||
| 144 | }; | 145 | }; |
| 145 | 146 | ||
| 146 | static inline struct pnfs_block_layout * | 147 | static inline struct pnfs_block_layout * |
| @@ -182,7 +183,7 @@ int ext_tree_insert(struct pnfs_block_layout *bl, | |||
| 182 | int ext_tree_remove(struct pnfs_block_layout *bl, bool rw, sector_t start, | 183 | int ext_tree_remove(struct pnfs_block_layout *bl, bool rw, sector_t start, |
| 183 | sector_t end); | 184 | sector_t end); |
| 184 | int ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start, | 185 | int ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start, |
| 185 | sector_t len); | 186 | sector_t len, u64 lwb); |
| 186 | bool ext_tree_lookup(struct pnfs_block_layout *bl, sector_t isect, | 187 | bool ext_tree_lookup(struct pnfs_block_layout *bl, sector_t isect, |
| 187 | struct pnfs_block_extent *ret, bool rw); | 188 | struct pnfs_block_extent *ret, bool rw); |
| 188 | int ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg); | 189 | int ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg); |
diff --git a/fs/nfs/blocklayout/extent_tree.c b/fs/nfs/blocklayout/extent_tree.c index 992bcb19c11e..c85fbfd2d0d9 100644 --- a/fs/nfs/blocklayout/extent_tree.c +++ b/fs/nfs/blocklayout/extent_tree.c | |||
| @@ -402,7 +402,7 @@ ext_tree_split(struct rb_root *root, struct pnfs_block_extent *be, | |||
| 402 | 402 | ||
| 403 | int | 403 | int |
| 404 | ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start, | 404 | ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start, |
| 405 | sector_t len) | 405 | sector_t len, u64 lwb) |
| 406 | { | 406 | { |
| 407 | struct rb_root *root = &bl->bl_ext_rw; | 407 | struct rb_root *root = &bl->bl_ext_rw; |
| 408 | sector_t end = start + len; | 408 | sector_t end = start + len; |
| @@ -471,6 +471,8 @@ ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start, | |||
| 471 | } | 471 | } |
| 472 | } | 472 | } |
| 473 | out: | 473 | out: |
| 474 | if (bl->bl_lwb < lwb) | ||
| 475 | bl->bl_lwb = lwb; | ||
| 474 | spin_unlock(&bl->bl_ext_lock); | 476 | spin_unlock(&bl->bl_ext_lock); |
| 475 | 477 | ||
| 476 | __ext_put_deviceids(&tmp); | 478 | __ext_put_deviceids(&tmp); |
| @@ -518,7 +520,7 @@ static __be32 *encode_scsi_range(struct pnfs_block_extent *be, __be32 *p) | |||
| 518 | } | 520 | } |
| 519 | 521 | ||
| 520 | static int ext_tree_encode_commit(struct pnfs_block_layout *bl, __be32 *p, | 522 | static int ext_tree_encode_commit(struct pnfs_block_layout *bl, __be32 *p, |
| 521 | size_t buffer_size, size_t *count) | 523 | size_t buffer_size, size_t *count, __u64 *lastbyte) |
| 522 | { | 524 | { |
| 523 | struct pnfs_block_extent *be; | 525 | struct pnfs_block_extent *be; |
| 524 | int ret = 0; | 526 | int ret = 0; |
| @@ -542,6 +544,8 @@ static int ext_tree_encode_commit(struct pnfs_block_layout *bl, __be32 *p, | |||
| 542 | p = encode_block_extent(be, p); | 544 | p = encode_block_extent(be, p); |
| 543 | be->be_tag = EXTENT_COMMITTING; | 545 | be->be_tag = EXTENT_COMMITTING; |
| 544 | } | 546 | } |
| 547 | *lastbyte = bl->bl_lwb - 1; | ||
| 548 | bl->bl_lwb = 0; | ||
| 545 | spin_unlock(&bl->bl_ext_lock); | 549 | spin_unlock(&bl->bl_ext_lock); |
| 546 | 550 | ||
| 547 | return ret; | 551 | return ret; |
| @@ -564,7 +568,7 @@ ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg) | |||
| 564 | arg->layoutupdate_pages = &arg->layoutupdate_page; | 568 | arg->layoutupdate_pages = &arg->layoutupdate_page; |
| 565 | 569 | ||
| 566 | retry: | 570 | retry: |
| 567 | ret = ext_tree_encode_commit(bl, start_p + 1, buffer_size, &count); | 571 | ret = ext_tree_encode_commit(bl, start_p + 1, buffer_size, &count, &arg->lastbytewritten); |
| 568 | if (unlikely(ret)) { | 572 | if (unlikely(ret)) { |
| 569 | ext_tree_free_commitdata(arg, buffer_size); | 573 | ext_tree_free_commitdata(arg, buffer_size); |
| 570 | 574 | ||
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index a7f2e6e33305..52a28311e2a4 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c | |||
| @@ -275,6 +275,7 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv, | |||
| 275 | err_socks: | 275 | err_socks: |
| 276 | svc_rpcb_cleanup(serv, net); | 276 | svc_rpcb_cleanup(serv, net); |
| 277 | err_bind: | 277 | err_bind: |
| 278 | nn->cb_users[minorversion]--; | ||
| 278 | dprintk("NFS: Couldn't create callback socket: err = %d; " | 279 | dprintk("NFS: Couldn't create callback socket: err = %d; " |
| 279 | "net = %p\n", ret, net); | 280 | "net = %p\n", ret, net); |
| 280 | return ret; | 281 | return ret; |
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index c92a75e066a6..f953ef6b2f2e 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c | |||
| @@ -454,11 +454,8 @@ static bool referring_call_exists(struct nfs_client *clp, | |||
| 454 | ((u32 *)&rclist->rcl_sessionid.data)[3], | 454 | ((u32 *)&rclist->rcl_sessionid.data)[3], |
| 455 | ref->rc_sequenceid, ref->rc_slotid); | 455 | ref->rc_sequenceid, ref->rc_slotid); |
| 456 | 456 | ||
| 457 | spin_lock(&tbl->slot_tbl_lock); | 457 | status = nfs4_slot_wait_on_seqid(tbl, ref->rc_slotid, |
| 458 | status = (test_bit(ref->rc_slotid, tbl->used_slots) && | 458 | ref->rc_sequenceid, HZ >> 1) < 0; |
| 459 | tbl->slots[ref->rc_slotid].seq_nr == | ||
| 460 | ref->rc_sequenceid); | ||
| 461 | spin_unlock(&tbl->slot_tbl_lock); | ||
| 462 | if (status) | 459 | if (status) |
| 463 | goto out; | 460 | goto out; |
| 464 | } | 461 | } |
| @@ -487,7 +484,6 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, | |||
| 487 | goto out; | 484 | goto out; |
| 488 | 485 | ||
| 489 | tbl = &clp->cl_session->bc_slot_table; | 486 | tbl = &clp->cl_session->bc_slot_table; |
| 490 | slot = tbl->slots + args->csa_slotid; | ||
| 491 | 487 | ||
| 492 | /* Set up res before grabbing the spinlock */ | 488 | /* Set up res before grabbing the spinlock */ |
| 493 | memcpy(&res->csr_sessionid, &args->csa_sessionid, | 489 | memcpy(&res->csr_sessionid, &args->csa_sessionid, |
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 003ebce4bbc4..1e106780a237 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
| @@ -426,7 +426,7 @@ EXPORT_SYMBOL_GPL(nfs_mark_client_ready); | |||
| 426 | * Initialise the timeout values for a connection | 426 | * Initialise the timeout values for a connection |
| 427 | */ | 427 | */ |
| 428 | void nfs_init_timeout_values(struct rpc_timeout *to, int proto, | 428 | void nfs_init_timeout_values(struct rpc_timeout *to, int proto, |
| 429 | unsigned int timeo, unsigned int retrans) | 429 | int timeo, int retrans) |
| 430 | { | 430 | { |
| 431 | to->to_initval = timeo * HZ / 10; | 431 | to->to_initval = timeo * HZ / 10; |
| 432 | to->to_retries = retrans; | 432 | to->to_retries = retrans; |
| @@ -434,9 +434,9 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto, | |||
| 434 | switch (proto) { | 434 | switch (proto) { |
| 435 | case XPRT_TRANSPORT_TCP: | 435 | case XPRT_TRANSPORT_TCP: |
| 436 | case XPRT_TRANSPORT_RDMA: | 436 | case XPRT_TRANSPORT_RDMA: |
| 437 | if (to->to_retries == 0) | 437 | if (retrans == NFS_UNSPEC_RETRANS) |
| 438 | to->to_retries = NFS_DEF_TCP_RETRANS; | 438 | to->to_retries = NFS_DEF_TCP_RETRANS; |
| 439 | if (to->to_initval == 0) | 439 | if (timeo == NFS_UNSPEC_TIMEO || to->to_retries == 0) |
| 440 | to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10; | 440 | to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10; |
| 441 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) | 441 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) |
| 442 | to->to_initval = NFS_MAX_TCP_TIMEOUT; | 442 | to->to_initval = NFS_MAX_TCP_TIMEOUT; |
| @@ -449,9 +449,9 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto, | |||
| 449 | to->to_exponential = 0; | 449 | to->to_exponential = 0; |
| 450 | break; | 450 | break; |
| 451 | case XPRT_TRANSPORT_UDP: | 451 | case XPRT_TRANSPORT_UDP: |
| 452 | if (to->to_retries == 0) | 452 | if (retrans == NFS_UNSPEC_RETRANS) |
| 453 | to->to_retries = NFS_DEF_UDP_RETRANS; | 453 | to->to_retries = NFS_DEF_UDP_RETRANS; |
| 454 | if (!to->to_initval) | 454 | if (timeo == NFS_UNSPEC_TIMEO || to->to_initval == 0) |
| 455 | to->to_initval = NFS_DEF_UDP_TIMEO * HZ / 10; | 455 | to->to_initval = NFS_DEF_UDP_TIMEO * HZ / 10; |
| 456 | if (to->to_initval > NFS_MAX_UDP_TIMEOUT) | 456 | if (to->to_initval > NFS_MAX_UDP_TIMEOUT) |
| 457 | to->to_initval = NFS_MAX_UDP_TIMEOUT; | 457 | to->to_initval = NFS_MAX_UDP_TIMEOUT; |
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 7d620970f2e1..ca699ddc11c1 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
| @@ -657,7 +657,10 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from) | |||
| 657 | if (result <= 0) | 657 | if (result <= 0) |
| 658 | goto out; | 658 | goto out; |
| 659 | 659 | ||
| 660 | written = generic_write_sync(iocb, result); | 660 | result = generic_write_sync(iocb, result); |
| 661 | if (result < 0) | ||
| 662 | goto out; | ||
| 663 | written = result; | ||
| 661 | iocb->ki_pos += written; | 664 | iocb->ki_pos += written; |
| 662 | 665 | ||
| 663 | /* Return error values */ | 666 | /* Return error values */ |
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index e6206eaf2bdf..51b51369704c 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c | |||
| @@ -37,6 +37,7 @@ ff_layout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags) | |||
| 37 | if (ffl) { | 37 | if (ffl) { |
| 38 | INIT_LIST_HEAD(&ffl->error_list); | 38 | INIT_LIST_HEAD(&ffl->error_list); |
| 39 | INIT_LIST_HEAD(&ffl->mirrors); | 39 | INIT_LIST_HEAD(&ffl->mirrors); |
| 40 | ffl->last_report_time = ktime_get(); | ||
| 40 | return &ffl->generic_hdr; | 41 | return &ffl->generic_hdr; |
| 41 | } else | 42 | } else |
| 42 | return NULL; | 43 | return NULL; |
| @@ -640,19 +641,18 @@ nfs4_ff_layoutstat_start_io(struct nfs4_ff_layout_mirror *mirror, | |||
| 640 | { | 641 | { |
| 641 | static const ktime_t notime = {0}; | 642 | static const ktime_t notime = {0}; |
| 642 | s64 report_interval = FF_LAYOUTSTATS_REPORT_INTERVAL; | 643 | s64 report_interval = FF_LAYOUTSTATS_REPORT_INTERVAL; |
| 644 | struct nfs4_flexfile_layout *ffl = FF_LAYOUT_FROM_HDR(mirror->layout); | ||
| 643 | 645 | ||
| 644 | nfs4_ff_start_busy_timer(&layoutstat->busy_timer, now); | 646 | nfs4_ff_start_busy_timer(&layoutstat->busy_timer, now); |
| 645 | if (ktime_equal(mirror->start_time, notime)) | 647 | if (ktime_equal(mirror->start_time, notime)) |
| 646 | mirror->start_time = now; | 648 | mirror->start_time = now; |
| 647 | if (ktime_equal(mirror->last_report_time, notime)) | ||
| 648 | mirror->last_report_time = now; | ||
| 649 | if (mirror->report_interval != 0) | 649 | if (mirror->report_interval != 0) |
| 650 | report_interval = (s64)mirror->report_interval * 1000LL; | 650 | report_interval = (s64)mirror->report_interval * 1000LL; |
| 651 | else if (layoutstats_timer != 0) | 651 | else if (layoutstats_timer != 0) |
| 652 | report_interval = (s64)layoutstats_timer * 1000LL; | 652 | report_interval = (s64)layoutstats_timer * 1000LL; |
| 653 | if (ktime_to_ms(ktime_sub(now, mirror->last_report_time)) >= | 653 | if (ktime_to_ms(ktime_sub(now, ffl->last_report_time)) >= |
| 654 | report_interval) { | 654 | report_interval) { |
| 655 | mirror->last_report_time = now; | 655 | ffl->last_report_time = now; |
| 656 | return true; | 656 | return true; |
| 657 | } | 657 | } |
| 658 | 658 | ||
| @@ -806,11 +806,14 @@ ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment *lseg, | |||
| 806 | { | 806 | { |
| 807 | struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg); | 807 | struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg); |
| 808 | struct nfs4_pnfs_ds *ds; | 808 | struct nfs4_pnfs_ds *ds; |
| 809 | bool fail_return = false; | ||
| 809 | int idx; | 810 | int idx; |
| 810 | 811 | ||
| 811 | /* mirrors are sorted by efficiency */ | 812 | /* mirrors are sorted by efficiency */ |
| 812 | for (idx = start_idx; idx < fls->mirror_array_cnt; idx++) { | 813 | for (idx = start_idx; idx < fls->mirror_array_cnt; idx++) { |
| 813 | ds = nfs4_ff_layout_prepare_ds(lseg, idx, false); | 814 | if (idx+1 == fls->mirror_array_cnt) |
| 815 | fail_return = true; | ||
| 816 | ds = nfs4_ff_layout_prepare_ds(lseg, idx, fail_return); | ||
| 814 | if (ds) { | 817 | if (ds) { |
| 815 | *best_idx = idx; | 818 | *best_idx = idx; |
| 816 | return ds; | 819 | return ds; |
| @@ -859,6 +862,7 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio, | |||
| 859 | struct nfs4_pnfs_ds *ds; | 862 | struct nfs4_pnfs_ds *ds; |
| 860 | int ds_idx; | 863 | int ds_idx; |
| 861 | 864 | ||
| 865 | retry: | ||
| 862 | /* Use full layout for now */ | 866 | /* Use full layout for now */ |
| 863 | if (!pgio->pg_lseg) | 867 | if (!pgio->pg_lseg) |
| 864 | ff_layout_pg_get_read(pgio, req, false); | 868 | ff_layout_pg_get_read(pgio, req, false); |
| @@ -871,10 +875,13 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio, | |||
| 871 | 875 | ||
| 872 | ds = ff_layout_choose_best_ds_for_read(pgio->pg_lseg, 0, &ds_idx); | 876 | ds = ff_layout_choose_best_ds_for_read(pgio->pg_lseg, 0, &ds_idx); |
| 873 | if (!ds) { | 877 | if (!ds) { |
| 874 | if (ff_layout_no_fallback_to_mds(pgio->pg_lseg)) | 878 | if (!ff_layout_no_fallback_to_mds(pgio->pg_lseg)) |
| 875 | goto out_pnfs; | ||
| 876 | else | ||
| 877 | goto out_mds; | 879 | goto out_mds; |
| 880 | pnfs_put_lseg(pgio->pg_lseg); | ||
| 881 | pgio->pg_lseg = NULL; | ||
| 882 | /* Sleep for 1 second before retrying */ | ||
| 883 | ssleep(1); | ||
| 884 | goto retry; | ||
| 878 | } | 885 | } |
| 879 | 886 | ||
| 880 | mirror = FF_LAYOUT_COMP(pgio->pg_lseg, ds_idx); | 887 | mirror = FF_LAYOUT_COMP(pgio->pg_lseg, ds_idx); |
| @@ -890,12 +897,6 @@ out_mds: | |||
| 890 | pnfs_put_lseg(pgio->pg_lseg); | 897 | pnfs_put_lseg(pgio->pg_lseg); |
| 891 | pgio->pg_lseg = NULL; | 898 | pgio->pg_lseg = NULL; |
| 892 | nfs_pageio_reset_read_mds(pgio); | 899 | nfs_pageio_reset_read_mds(pgio); |
| 893 | return; | ||
| 894 | |||
| 895 | out_pnfs: | ||
| 896 | pnfs_set_lo_fail(pgio->pg_lseg); | ||
| 897 | pnfs_put_lseg(pgio->pg_lseg); | ||
| 898 | pgio->pg_lseg = NULL; | ||
| 899 | } | 900 | } |
| 900 | 901 | ||
| 901 | static void | 902 | static void |
| @@ -909,6 +910,7 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio, | |||
| 909 | int i; | 910 | int i; |
| 910 | int status; | 911 | int status; |
| 911 | 912 | ||
| 913 | retry: | ||
| 912 | if (!pgio->pg_lseg) { | 914 | if (!pgio->pg_lseg) { |
| 913 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, | 915 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, |
| 914 | req->wb_context, | 916 | req->wb_context, |
| @@ -940,10 +942,13 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio, | |||
| 940 | for (i = 0; i < pgio->pg_mirror_count; i++) { | 942 | for (i = 0; i < pgio->pg_mirror_count; i++) { |
| 941 | ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, i, true); | 943 | ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, i, true); |
| 942 | if (!ds) { | 944 | if (!ds) { |
| 943 | if (ff_layout_no_fallback_to_mds(pgio->pg_lseg)) | 945 | if (!ff_layout_no_fallback_to_mds(pgio->pg_lseg)) |
| 944 | goto out_pnfs; | ||
| 945 | else | ||
| 946 | goto out_mds; | 946 | goto out_mds; |
| 947 | pnfs_put_lseg(pgio->pg_lseg); | ||
| 948 | pgio->pg_lseg = NULL; | ||
| 949 | /* Sleep for 1 second before retrying */ | ||
| 950 | ssleep(1); | ||
| 951 | goto retry; | ||
| 947 | } | 952 | } |
| 948 | pgm = &pgio->pg_mirrors[i]; | 953 | pgm = &pgio->pg_mirrors[i]; |
| 949 | mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i); | 954 | mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i); |
| @@ -956,12 +961,6 @@ out_mds: | |||
| 956 | pnfs_put_lseg(pgio->pg_lseg); | 961 | pnfs_put_lseg(pgio->pg_lseg); |
| 957 | pgio->pg_lseg = NULL; | 962 | pgio->pg_lseg = NULL; |
| 958 | nfs_pageio_reset_write_mds(pgio); | 963 | nfs_pageio_reset_write_mds(pgio); |
| 959 | return; | ||
| 960 | |||
| 961 | out_pnfs: | ||
| 962 | pnfs_set_lo_fail(pgio->pg_lseg); | ||
| 963 | pnfs_put_lseg(pgio->pg_lseg); | ||
| 964 | pgio->pg_lseg = NULL; | ||
| 965 | } | 964 | } |
| 966 | 965 | ||
| 967 | static unsigned int | 966 | static unsigned int |
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h index 1bcdb15d0c41..3ee0c9fcea76 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.h +++ b/fs/nfs/flexfilelayout/flexfilelayout.h | |||
| @@ -84,7 +84,6 @@ struct nfs4_ff_layout_mirror { | |||
| 84 | struct nfs4_ff_layoutstat read_stat; | 84 | struct nfs4_ff_layoutstat read_stat; |
| 85 | struct nfs4_ff_layoutstat write_stat; | 85 | struct nfs4_ff_layoutstat write_stat; |
| 86 | ktime_t start_time; | 86 | ktime_t start_time; |
| 87 | ktime_t last_report_time; | ||
| 88 | u32 report_interval; | 87 | u32 report_interval; |
| 89 | }; | 88 | }; |
| 90 | 89 | ||
| @@ -101,6 +100,7 @@ struct nfs4_flexfile_layout { | |||
| 101 | struct pnfs_ds_commit_info commit_info; | 100 | struct pnfs_ds_commit_info commit_info; |
| 102 | struct list_head mirrors; | 101 | struct list_head mirrors; |
| 103 | struct list_head error_list; /* nfs4_ff_layout_ds_err */ | 102 | struct list_head error_list; /* nfs4_ff_layout_ds_err */ |
| 103 | ktime_t last_report_time; /* Layoutstat report times */ | ||
| 104 | }; | 104 | }; |
| 105 | 105 | ||
| 106 | static inline struct nfs4_flexfile_layout * | 106 | static inline struct nfs4_flexfile_layout * |
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c index 0aa36be71fce..f7a3f6b05369 100644 --- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c +++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c | |||
| @@ -17,8 +17,8 @@ | |||
| 17 | 17 | ||
| 18 | #define NFSDBG_FACILITY NFSDBG_PNFS_LD | 18 | #define NFSDBG_FACILITY NFSDBG_PNFS_LD |
| 19 | 19 | ||
| 20 | static unsigned int dataserver_timeo = NFS4_DEF_DS_TIMEO; | 20 | static unsigned int dataserver_timeo = NFS_DEF_TCP_RETRANS; |
| 21 | static unsigned int dataserver_retrans = NFS4_DEF_DS_RETRANS; | 21 | static unsigned int dataserver_retrans; |
| 22 | 22 | ||
| 23 | void nfs4_ff_layout_put_deviceid(struct nfs4_ff_layout_ds *mirror_ds) | 23 | void nfs4_ff_layout_put_deviceid(struct nfs4_ff_layout_ds *mirror_ds) |
| 24 | { | 24 | { |
| @@ -379,7 +379,7 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx, | |||
| 379 | 379 | ||
| 380 | devid = &mirror->mirror_ds->id_node; | 380 | devid = &mirror->mirror_ds->id_node; |
| 381 | if (ff_layout_test_devid_unavailable(devid)) | 381 | if (ff_layout_test_devid_unavailable(devid)) |
| 382 | goto out; | 382 | goto out_fail; |
| 383 | 383 | ||
| 384 | ds = mirror->mirror_ds->ds; | 384 | ds = mirror->mirror_ds->ds; |
| 385 | /* matching smp_wmb() in _nfs4_pnfs_v3/4_ds_connect */ | 385 | /* matching smp_wmb() in _nfs4_pnfs_v3/4_ds_connect */ |
| @@ -405,15 +405,16 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx, | |||
| 405 | mirror->mirror_ds->ds_versions[0].rsize = max_payload; | 405 | mirror->mirror_ds->ds_versions[0].rsize = max_payload; |
| 406 | if (mirror->mirror_ds->ds_versions[0].wsize > max_payload) | 406 | if (mirror->mirror_ds->ds_versions[0].wsize > max_payload) |
| 407 | mirror->mirror_ds->ds_versions[0].wsize = max_payload; | 407 | mirror->mirror_ds->ds_versions[0].wsize = max_payload; |
| 408 | } else { | 408 | goto out; |
| 409 | ff_layout_track_ds_error(FF_LAYOUT_FROM_HDR(lseg->pls_layout), | ||
| 410 | mirror, lseg->pls_range.offset, | ||
| 411 | lseg->pls_range.length, NFS4ERR_NXIO, | ||
| 412 | OP_ILLEGAL, GFP_NOIO); | ||
| 413 | if (fail_return || !ff_layout_has_available_ds(lseg)) | ||
| 414 | pnfs_error_mark_layout_for_return(ino, lseg); | ||
| 415 | ds = NULL; | ||
| 416 | } | 409 | } |
| 410 | ff_layout_track_ds_error(FF_LAYOUT_FROM_HDR(lseg->pls_layout), | ||
| 411 | mirror, lseg->pls_range.offset, | ||
| 412 | lseg->pls_range.length, NFS4ERR_NXIO, | ||
| 413 | OP_ILLEGAL, GFP_NOIO); | ||
| 414 | out_fail: | ||
| 415 | if (fail_return || !ff_layout_has_available_ds(lseg)) | ||
| 416 | pnfs_error_mark_layout_for_return(ino, lseg); | ||
| 417 | ds = NULL; | ||
| 417 | out: | 418 | out: |
| 418 | return ds; | 419 | return ds; |
| 419 | } | 420 | } |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 7ce5e023c3c3..74935a19e4bf 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
| @@ -58,6 +58,9 @@ struct nfs_clone_mount { | |||
| 58 | */ | 58 | */ |
| 59 | #define NFS_UNSPEC_PORT (-1) | 59 | #define NFS_UNSPEC_PORT (-1) |
| 60 | 60 | ||
| 61 | #define NFS_UNSPEC_RETRANS (UINT_MAX) | ||
| 62 | #define NFS_UNSPEC_TIMEO (UINT_MAX) | ||
| 63 | |||
| 61 | /* | 64 | /* |
| 62 | * Maximum number of pages that readdir can use for creating | 65 | * Maximum number of pages that readdir can use for creating |
| 63 | * a vmapped array of pages. | 66 | * a vmapped array of pages. |
| @@ -156,7 +159,7 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *, | |||
| 156 | int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *, struct nfs_fattr *); | 159 | int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *, struct nfs_fattr *); |
| 157 | void nfs_server_insert_lists(struct nfs_server *); | 160 | void nfs_server_insert_lists(struct nfs_server *); |
| 158 | void nfs_server_remove_lists(struct nfs_server *); | 161 | void nfs_server_remove_lists(struct nfs_server *); |
| 159 | void nfs_init_timeout_values(struct rpc_timeout *, int, unsigned int, unsigned int); | 162 | void nfs_init_timeout_values(struct rpc_timeout *to, int proto, int timeo, int retrans); |
| 160 | int nfs_init_server_rpcclient(struct nfs_server *, const struct rpc_timeout *t, | 163 | int nfs_init_server_rpcclient(struct nfs_server *, const struct rpc_timeout *t, |
| 161 | rpc_authflavor_t); | 164 | rpc_authflavor_t); |
| 162 | struct nfs_server *nfs_alloc_server(void); | 165 | struct nfs_server *nfs_alloc_server(void); |
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 6f4752734804..64b43b4ad9dd 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c | |||
| @@ -318,10 +318,22 @@ static void | |||
| 318 | nfs42_layoutstat_prepare(struct rpc_task *task, void *calldata) | 318 | nfs42_layoutstat_prepare(struct rpc_task *task, void *calldata) |
| 319 | { | 319 | { |
| 320 | struct nfs42_layoutstat_data *data = calldata; | 320 | struct nfs42_layoutstat_data *data = calldata; |
| 321 | struct nfs_server *server = NFS_SERVER(data->args.inode); | 321 | struct inode *inode = data->inode; |
| 322 | struct nfs_server *server = NFS_SERVER(inode); | ||
| 323 | struct pnfs_layout_hdr *lo; | ||
| 322 | 324 | ||
| 325 | spin_lock(&inode->i_lock); | ||
| 326 | lo = NFS_I(inode)->layout; | ||
| 327 | if (!pnfs_layout_is_valid(lo)) { | ||
| 328 | spin_unlock(&inode->i_lock); | ||
| 329 | rpc_exit(task, 0); | ||
| 330 | return; | ||
| 331 | } | ||
| 332 | nfs4_stateid_copy(&data->args.stateid, &lo->plh_stateid); | ||
| 333 | spin_unlock(&inode->i_lock); | ||
| 323 | nfs41_setup_sequence(nfs4_get_session(server), &data->args.seq_args, | 334 | nfs41_setup_sequence(nfs4_get_session(server), &data->args.seq_args, |
| 324 | &data->res.seq_res, task); | 335 | &data->res.seq_res, task); |
| 336 | |||
| 325 | } | 337 | } |
| 326 | 338 | ||
| 327 | static void | 339 | static void |
| @@ -341,11 +353,11 @@ nfs42_layoutstat_done(struct rpc_task *task, void *calldata) | |||
| 341 | case -NFS4ERR_ADMIN_REVOKED: | 353 | case -NFS4ERR_ADMIN_REVOKED: |
| 342 | case -NFS4ERR_DELEG_REVOKED: | 354 | case -NFS4ERR_DELEG_REVOKED: |
| 343 | case -NFS4ERR_STALE_STATEID: | 355 | case -NFS4ERR_STALE_STATEID: |
| 344 | case -NFS4ERR_OLD_STATEID: | ||
| 345 | case -NFS4ERR_BAD_STATEID: | 356 | case -NFS4ERR_BAD_STATEID: |
| 346 | spin_lock(&inode->i_lock); | 357 | spin_lock(&inode->i_lock); |
| 347 | lo = NFS_I(inode)->layout; | 358 | lo = NFS_I(inode)->layout; |
| 348 | if (lo && nfs4_stateid_match(&data->args.stateid, | 359 | if (pnfs_layout_is_valid(lo) && |
| 360 | nfs4_stateid_match(&data->args.stateid, | ||
| 349 | &lo->plh_stateid)) { | 361 | &lo->plh_stateid)) { |
| 350 | LIST_HEAD(head); | 362 | LIST_HEAD(head); |
| 351 | 363 | ||
| @@ -359,11 +371,23 @@ nfs42_layoutstat_done(struct rpc_task *task, void *calldata) | |||
| 359 | } else | 371 | } else |
| 360 | spin_unlock(&inode->i_lock); | 372 | spin_unlock(&inode->i_lock); |
| 361 | break; | 373 | break; |
| 374 | case -NFS4ERR_OLD_STATEID: | ||
| 375 | spin_lock(&inode->i_lock); | ||
| 376 | lo = NFS_I(inode)->layout; | ||
| 377 | if (pnfs_layout_is_valid(lo) && | ||
| 378 | nfs4_stateid_match_other(&data->args.stateid, | ||
| 379 | &lo->plh_stateid)) { | ||
| 380 | /* Do we need to delay before resending? */ | ||
| 381 | if (!nfs4_stateid_is_newer(&lo->plh_stateid, | ||
| 382 | &data->args.stateid)) | ||
| 383 | rpc_delay(task, HZ); | ||
| 384 | rpc_restart_call_prepare(task); | ||
| 385 | } | ||
| 386 | spin_unlock(&inode->i_lock); | ||
| 387 | break; | ||
| 362 | case -ENOTSUPP: | 388 | case -ENOTSUPP: |
| 363 | case -EOPNOTSUPP: | 389 | case -EOPNOTSUPP: |
| 364 | NFS_SERVER(inode)->caps &= ~NFS_CAP_LAYOUTSTATS; | 390 | NFS_SERVER(inode)->caps &= ~NFS_CAP_LAYOUTSTATS; |
| 365 | default: | ||
| 366 | break; | ||
| 367 | } | 391 | } |
| 368 | 392 | ||
| 369 | dprintk("%s server returns %d\n", __func__, task->tk_status); | 393 | dprintk("%s server returns %d\n", __func__, task->tk_status); |
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 8d7d08d4f95f..cd3b7cfdde16 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c | |||
| @@ -817,6 +817,11 @@ static int nfs4_set_client(struct nfs_server *server, | |||
| 817 | goto error; | 817 | goto error; |
| 818 | } | 818 | } |
| 819 | 819 | ||
| 820 | if (server->nfs_client == clp) { | ||
| 821 | error = -ELOOP; | ||
| 822 | goto error; | ||
| 823 | } | ||
| 824 | |||
| 820 | /* | 825 | /* |
| 821 | * Query for the lease time on clientid setup or renewal | 826 | * Query for the lease time on clientid setup or renewal |
| 822 | * | 827 | * |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 1949bbd806eb..a9dec32ba9ba 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
| @@ -634,15 +634,11 @@ out_sleep: | |||
| 634 | } | 634 | } |
| 635 | EXPORT_SYMBOL_GPL(nfs40_setup_sequence); | 635 | EXPORT_SYMBOL_GPL(nfs40_setup_sequence); |
| 636 | 636 | ||
| 637 | static int nfs40_sequence_done(struct rpc_task *task, | 637 | static void nfs40_sequence_free_slot(struct nfs4_sequence_res *res) |
| 638 | struct nfs4_sequence_res *res) | ||
| 639 | { | 638 | { |
| 640 | struct nfs4_slot *slot = res->sr_slot; | 639 | struct nfs4_slot *slot = res->sr_slot; |
| 641 | struct nfs4_slot_table *tbl; | 640 | struct nfs4_slot_table *tbl; |
| 642 | 641 | ||
| 643 | if (slot == NULL) | ||
| 644 | goto out; | ||
| 645 | |||
| 646 | tbl = slot->table; | 642 | tbl = slot->table; |
| 647 | spin_lock(&tbl->slot_tbl_lock); | 643 | spin_lock(&tbl->slot_tbl_lock); |
| 648 | if (!nfs41_wake_and_assign_slot(tbl, slot)) | 644 | if (!nfs41_wake_and_assign_slot(tbl, slot)) |
| @@ -650,7 +646,13 @@ static int nfs40_sequence_done(struct rpc_task *task, | |||
| 650 | spin_unlock(&tbl->slot_tbl_lock); | 646 | spin_unlock(&tbl->slot_tbl_lock); |
| 651 | 647 | ||
| 652 | res->sr_slot = NULL; | 648 | res->sr_slot = NULL; |
| 653 | out: | 649 | } |
| 650 | |||
| 651 | static int nfs40_sequence_done(struct rpc_task *task, | ||
| 652 | struct nfs4_sequence_res *res) | ||
| 653 | { | ||
| 654 | if (res->sr_slot != NULL) | ||
| 655 | nfs40_sequence_free_slot(res); | ||
| 654 | return 1; | 656 | return 1; |
| 655 | } | 657 | } |
| 656 | 658 | ||
| @@ -666,6 +668,11 @@ static void nfs41_sequence_free_slot(struct nfs4_sequence_res *res) | |||
| 666 | tbl = slot->table; | 668 | tbl = slot->table; |
| 667 | session = tbl->session; | 669 | session = tbl->session; |
| 668 | 670 | ||
| 671 | /* Bump the slot sequence number */ | ||
| 672 | if (slot->seq_done) | ||
| 673 | slot->seq_nr++; | ||
| 674 | slot->seq_done = 0; | ||
| 675 | |||
| 669 | spin_lock(&tbl->slot_tbl_lock); | 676 | spin_lock(&tbl->slot_tbl_lock); |
| 670 | /* Be nice to the server: try to ensure that the last transmitted | 677 | /* Be nice to the server: try to ensure that the last transmitted |
| 671 | * value for highest_user_slotid <= target_highest_slotid | 678 | * value for highest_user_slotid <= target_highest_slotid |
| @@ -686,9 +693,12 @@ out_unlock: | |||
| 686 | res->sr_slot = NULL; | 693 | res->sr_slot = NULL; |
| 687 | if (send_new_highest_used_slotid) | 694 | if (send_new_highest_used_slotid) |
| 688 | nfs41_notify_server(session->clp); | 695 | nfs41_notify_server(session->clp); |
| 696 | if (waitqueue_active(&tbl->slot_waitq)) | ||
| 697 | wake_up_all(&tbl->slot_waitq); | ||
| 689 | } | 698 | } |
| 690 | 699 | ||
| 691 | int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res) | 700 | static int nfs41_sequence_process(struct rpc_task *task, |
| 701 | struct nfs4_sequence_res *res) | ||
| 692 | { | 702 | { |
| 693 | struct nfs4_session *session; | 703 | struct nfs4_session *session; |
| 694 | struct nfs4_slot *slot = res->sr_slot; | 704 | struct nfs4_slot *slot = res->sr_slot; |
| @@ -714,7 +724,7 @@ int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res) | |||
| 714 | switch (res->sr_status) { | 724 | switch (res->sr_status) { |
| 715 | case 0: | 725 | case 0: |
| 716 | /* Update the slot's sequence and clientid lease timer */ | 726 | /* Update the slot's sequence and clientid lease timer */ |
| 717 | ++slot->seq_nr; | 727 | slot->seq_done = 1; |
| 718 | clp = session->clp; | 728 | clp = session->clp; |
| 719 | do_renew_lease(clp, res->sr_timestamp); | 729 | do_renew_lease(clp, res->sr_timestamp); |
| 720 | /* Check sequence flags */ | 730 | /* Check sequence flags */ |
| @@ -769,16 +779,16 @@ int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res) | |||
| 769 | goto retry_nowait; | 779 | goto retry_nowait; |
| 770 | default: | 780 | default: |
| 771 | /* Just update the slot sequence no. */ | 781 | /* Just update the slot sequence no. */ |
| 772 | ++slot->seq_nr; | 782 | slot->seq_done = 1; |
| 773 | } | 783 | } |
| 774 | out: | 784 | out: |
| 775 | /* The session may be reset by one of the error handlers. */ | 785 | /* The session may be reset by one of the error handlers. */ |
| 776 | dprintk("%s: Error %d free the slot \n", __func__, res->sr_status); | 786 | dprintk("%s: Error %d free the slot \n", __func__, res->sr_status); |
| 777 | nfs41_sequence_free_slot(res); | ||
| 778 | out_noaction: | 787 | out_noaction: |
| 779 | return ret; | 788 | return ret; |
| 780 | retry_nowait: | 789 | retry_nowait: |
| 781 | if (rpc_restart_call_prepare(task)) { | 790 | if (rpc_restart_call_prepare(task)) { |
| 791 | nfs41_sequence_free_slot(res); | ||
| 782 | task->tk_status = 0; | 792 | task->tk_status = 0; |
| 783 | ret = 0; | 793 | ret = 0; |
| 784 | } | 794 | } |
| @@ -789,8 +799,37 @@ out_retry: | |||
| 789 | rpc_delay(task, NFS4_POLL_RETRY_MAX); | 799 | rpc_delay(task, NFS4_POLL_RETRY_MAX); |
| 790 | return 0; | 800 | return 0; |
| 791 | } | 801 | } |
| 802 | |||
| 803 | int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res) | ||
| 804 | { | ||
| 805 | if (!nfs41_sequence_process(task, res)) | ||
| 806 | return 0; | ||
| 807 | if (res->sr_slot != NULL) | ||
| 808 | nfs41_sequence_free_slot(res); | ||
| 809 | return 1; | ||
| 810 | |||
| 811 | } | ||
| 792 | EXPORT_SYMBOL_GPL(nfs41_sequence_done); | 812 | EXPORT_SYMBOL_GPL(nfs41_sequence_done); |
| 793 | 813 | ||
| 814 | static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res) | ||
| 815 | { | ||
| 816 | if (res->sr_slot == NULL) | ||
| 817 | return 1; | ||
| 818 | if (res->sr_slot->table->session != NULL) | ||
| 819 | return nfs41_sequence_process(task, res); | ||
| 820 | return nfs40_sequence_done(task, res); | ||
| 821 | } | ||
| 822 | |||
| 823 | static void nfs4_sequence_free_slot(struct nfs4_sequence_res *res) | ||
| 824 | { | ||
| 825 | if (res->sr_slot != NULL) { | ||
| 826 | if (res->sr_slot->table->session != NULL) | ||
| 827 | nfs41_sequence_free_slot(res); | ||
| 828 | else | ||
| 829 | nfs40_sequence_free_slot(res); | ||
| 830 | } | ||
| 831 | } | ||
| 832 | |||
| 794 | int nfs4_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res) | 833 | int nfs4_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res) |
| 795 | { | 834 | { |
| 796 | if (res->sr_slot == NULL) | 835 | if (res->sr_slot == NULL) |
| @@ -920,6 +959,17 @@ static int nfs4_setup_sequence(const struct nfs_server *server, | |||
| 920 | args, res, task); | 959 | args, res, task); |
| 921 | } | 960 | } |
| 922 | 961 | ||
| 962 | static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res) | ||
| 963 | { | ||
| 964 | return nfs40_sequence_done(task, res); | ||
| 965 | } | ||
| 966 | |||
| 967 | static void nfs4_sequence_free_slot(struct nfs4_sequence_res *res) | ||
| 968 | { | ||
| 969 | if (res->sr_slot != NULL) | ||
| 970 | nfs40_sequence_free_slot(res); | ||
| 971 | } | ||
| 972 | |||
| 923 | int nfs4_sequence_done(struct rpc_task *task, | 973 | int nfs4_sequence_done(struct rpc_task *task, |
| 924 | struct nfs4_sequence_res *res) | 974 | struct nfs4_sequence_res *res) |
| 925 | { | 975 | { |
| @@ -1197,6 +1247,7 @@ static void nfs4_opendata_free(struct kref *kref) | |||
| 1197 | struct super_block *sb = p->dentry->d_sb; | 1247 | struct super_block *sb = p->dentry->d_sb; |
| 1198 | 1248 | ||
| 1199 | nfs_free_seqid(p->o_arg.seqid); | 1249 | nfs_free_seqid(p->o_arg.seqid); |
| 1250 | nfs4_sequence_free_slot(&p->o_res.seq_res); | ||
| 1200 | if (p->state != NULL) | 1251 | if (p->state != NULL) |
| 1201 | nfs4_put_open_state(p->state); | 1252 | nfs4_put_open_state(p->state); |
| 1202 | nfs4_put_state_owner(p->owner); | 1253 | nfs4_put_state_owner(p->owner); |
| @@ -1656,9 +1707,14 @@ err: | |||
| 1656 | static struct nfs4_state * | 1707 | static struct nfs4_state * |
| 1657 | nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data) | 1708 | nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data) |
| 1658 | { | 1709 | { |
| 1710 | struct nfs4_state *ret; | ||
| 1711 | |||
| 1659 | if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) | 1712 | if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) |
| 1660 | return _nfs4_opendata_reclaim_to_nfs4_state(data); | 1713 | ret =_nfs4_opendata_reclaim_to_nfs4_state(data); |
| 1661 | return _nfs4_opendata_to_nfs4_state(data); | 1714 | else |
| 1715 | ret = _nfs4_opendata_to_nfs4_state(data); | ||
| 1716 | nfs4_sequence_free_slot(&data->o_res.seq_res); | ||
| 1717 | return ret; | ||
| 1662 | } | 1718 | } |
| 1663 | 1719 | ||
| 1664 | static struct nfs_open_context *nfs4_state_find_open_context(struct nfs4_state *state) | 1720 | static struct nfs_open_context *nfs4_state_find_open_context(struct nfs4_state *state) |
| @@ -2056,7 +2112,7 @@ static void nfs4_open_done(struct rpc_task *task, void *calldata) | |||
| 2056 | 2112 | ||
| 2057 | data->rpc_status = task->tk_status; | 2113 | data->rpc_status = task->tk_status; |
| 2058 | 2114 | ||
| 2059 | if (!nfs4_sequence_done(task, &data->o_res.seq_res)) | 2115 | if (!nfs4_sequence_process(task, &data->o_res.seq_res)) |
| 2060 | return; | 2116 | return; |
| 2061 | 2117 | ||
| 2062 | if (task->tk_status == 0) { | 2118 | if (task->tk_status == 0) { |
| @@ -7514,12 +7570,20 @@ static int _nfs4_proc_create_session(struct nfs_client *clp, | |||
| 7514 | status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); | 7570 | status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); |
| 7515 | trace_nfs4_create_session(clp, status); | 7571 | trace_nfs4_create_session(clp, status); |
| 7516 | 7572 | ||
| 7573 | switch (status) { | ||
| 7574 | case -NFS4ERR_STALE_CLIENTID: | ||
| 7575 | case -NFS4ERR_DELAY: | ||
| 7576 | case -ETIMEDOUT: | ||
| 7577 | case -EACCES: | ||
| 7578 | case -EAGAIN: | ||
| 7579 | goto out; | ||
| 7580 | }; | ||
| 7581 | |||
| 7582 | clp->cl_seqid++; | ||
| 7517 | if (!status) { | 7583 | if (!status) { |
| 7518 | /* Verify the session's negotiated channel_attrs values */ | 7584 | /* Verify the session's negotiated channel_attrs values */ |
| 7519 | status = nfs4_verify_channel_attrs(&args, &res); | 7585 | status = nfs4_verify_channel_attrs(&args, &res); |
| 7520 | /* Increment the clientid slot sequence id */ | 7586 | /* Increment the clientid slot sequence id */ |
| 7521 | if (clp->cl_seqid == res.seqid) | ||
| 7522 | clp->cl_seqid++; | ||
| 7523 | if (status) | 7587 | if (status) |
| 7524 | goto out; | 7588 | goto out; |
| 7525 | nfs4_update_session(session, &res); | 7589 | nfs4_update_session(session, &res); |
| @@ -7864,7 +7928,7 @@ static void nfs4_layoutget_done(struct rpc_task *task, void *calldata) | |||
| 7864 | struct nfs4_layoutget *lgp = calldata; | 7928 | struct nfs4_layoutget *lgp = calldata; |
| 7865 | 7929 | ||
| 7866 | dprintk("--> %s\n", __func__); | 7930 | dprintk("--> %s\n", __func__); |
| 7867 | nfs41_sequence_done(task, &lgp->res.seq_res); | 7931 | nfs41_sequence_process(task, &lgp->res.seq_res); |
| 7868 | dprintk("<-- %s\n", __func__); | 7932 | dprintk("<-- %s\n", __func__); |
| 7869 | } | 7933 | } |
| 7870 | 7934 | ||
| @@ -8080,6 +8144,7 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout, gfp_t gfp_flags) | |||
| 8080 | /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */ | 8144 | /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */ |
| 8081 | if (status == 0 && lgp->res.layoutp->len) | 8145 | if (status == 0 && lgp->res.layoutp->len) |
| 8082 | lseg = pnfs_layout_process(lgp); | 8146 | lseg = pnfs_layout_process(lgp); |
| 8147 | nfs4_sequence_free_slot(&lgp->res.seq_res); | ||
| 8083 | rpc_put_task(task); | 8148 | rpc_put_task(task); |
| 8084 | dprintk("<-- %s status=%d\n", __func__, status); | 8149 | dprintk("<-- %s status=%d\n", __func__, status); |
| 8085 | if (status) | 8150 | if (status) |
| @@ -8106,7 +8171,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) | |||
| 8106 | 8171 | ||
| 8107 | dprintk("--> %s\n", __func__); | 8172 | dprintk("--> %s\n", __func__); |
| 8108 | 8173 | ||
| 8109 | if (!nfs41_sequence_done(task, &lrp->res.seq_res)) | 8174 | if (!nfs41_sequence_process(task, &lrp->res.seq_res)) |
| 8110 | return; | 8175 | return; |
| 8111 | 8176 | ||
| 8112 | server = NFS_SERVER(lrp->args.inode); | 8177 | server = NFS_SERVER(lrp->args.inode); |
| @@ -8118,6 +8183,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) | |||
| 8118 | case -NFS4ERR_DELAY: | 8183 | case -NFS4ERR_DELAY: |
| 8119 | if (nfs4_async_handle_error(task, server, NULL, NULL) != -EAGAIN) | 8184 | if (nfs4_async_handle_error(task, server, NULL, NULL) != -EAGAIN) |
| 8120 | break; | 8185 | break; |
| 8186 | nfs4_sequence_free_slot(&lrp->res.seq_res); | ||
| 8121 | rpc_restart_call_prepare(task); | 8187 | rpc_restart_call_prepare(task); |
| 8122 | return; | 8188 | return; |
| 8123 | } | 8189 | } |
| @@ -8132,12 +8198,16 @@ static void nfs4_layoutreturn_release(void *calldata) | |||
| 8132 | 8198 | ||
| 8133 | dprintk("--> %s\n", __func__); | 8199 | dprintk("--> %s\n", __func__); |
| 8134 | spin_lock(&lo->plh_inode->i_lock); | 8200 | spin_lock(&lo->plh_inode->i_lock); |
| 8135 | pnfs_mark_matching_lsegs_invalid(lo, &freeme, &lrp->args.range, | 8201 | if (lrp->res.lrs_present) { |
| 8136 | be32_to_cpu(lrp->args.stateid.seqid)); | 8202 | pnfs_mark_matching_lsegs_invalid(lo, &freeme, |
| 8137 | if (lrp->res.lrs_present && pnfs_layout_is_valid(lo)) | 8203 | &lrp->args.range, |
| 8204 | be32_to_cpu(lrp->args.stateid.seqid)); | ||
| 8138 | pnfs_set_layout_stateid(lo, &lrp->res.stateid, true); | 8205 | pnfs_set_layout_stateid(lo, &lrp->res.stateid, true); |
| 8206 | } else | ||
| 8207 | pnfs_mark_layout_stateid_invalid(lo, &freeme); | ||
| 8139 | pnfs_clear_layoutreturn_waitbit(lo); | 8208 | pnfs_clear_layoutreturn_waitbit(lo); |
| 8140 | spin_unlock(&lo->plh_inode->i_lock); | 8209 | spin_unlock(&lo->plh_inode->i_lock); |
| 8210 | nfs4_sequence_free_slot(&lrp->res.seq_res); | ||
| 8141 | pnfs_free_lseg_list(&freeme); | 8211 | pnfs_free_lseg_list(&freeme); |
| 8142 | pnfs_put_layout_hdr(lrp->args.layout); | 8212 | pnfs_put_layout_hdr(lrp->args.layout); |
| 8143 | nfs_iput_and_deactive(lrp->inode); | 8213 | nfs_iput_and_deactive(lrp->inode); |
diff --git a/fs/nfs/nfs4session.c b/fs/nfs/nfs4session.c index 332d06e64fa9..b62973045a3e 100644 --- a/fs/nfs/nfs4session.c +++ b/fs/nfs/nfs4session.c | |||
| @@ -28,6 +28,7 @@ static void nfs4_init_slot_table(struct nfs4_slot_table *tbl, const char *queue) | |||
| 28 | tbl->highest_used_slotid = NFS4_NO_SLOT; | 28 | tbl->highest_used_slotid = NFS4_NO_SLOT; |
| 29 | spin_lock_init(&tbl->slot_tbl_lock); | 29 | spin_lock_init(&tbl->slot_tbl_lock); |
| 30 | rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, queue); | 30 | rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, queue); |
| 31 | init_waitqueue_head(&tbl->slot_waitq); | ||
| 31 | init_completion(&tbl->complete); | 32 | init_completion(&tbl->complete); |
| 32 | } | 33 | } |
| 33 | 34 | ||
| @@ -172,6 +173,58 @@ struct nfs4_slot *nfs4_lookup_slot(struct nfs4_slot_table *tbl, u32 slotid) | |||
| 172 | return ERR_PTR(-E2BIG); | 173 | return ERR_PTR(-E2BIG); |
| 173 | } | 174 | } |
| 174 | 175 | ||
| 176 | static int nfs4_slot_get_seqid(struct nfs4_slot_table *tbl, u32 slotid, | ||
| 177 | u32 *seq_nr) | ||
| 178 | __must_hold(&tbl->slot_tbl_lock) | ||
| 179 | { | ||
| 180 | struct nfs4_slot *slot; | ||
| 181 | |||
| 182 | slot = nfs4_lookup_slot(tbl, slotid); | ||
| 183 | if (IS_ERR(slot)) | ||
| 184 | return PTR_ERR(slot); | ||
| 185 | *seq_nr = slot->seq_nr; | ||
| 186 | return 0; | ||
| 187 | } | ||
| 188 | |||
| 189 | /* | ||
| 190 | * nfs4_slot_seqid_in_use - test if a slot sequence id is still in use | ||
| 191 | * | ||
| 192 | * Given a slot table, slot id and sequence number, determine if the | ||
| 193 | * RPC call in question is still in flight. This function is mainly | ||
| 194 | * intended for use by the callback channel. | ||
| 195 | */ | ||
| 196 | static bool nfs4_slot_seqid_in_use(struct nfs4_slot_table *tbl, | ||
| 197 | u32 slotid, u32 seq_nr) | ||
| 198 | { | ||
| 199 | u32 cur_seq; | ||
| 200 | bool ret = false; | ||
| 201 | |||
| 202 | spin_lock(&tbl->slot_tbl_lock); | ||
| 203 | if (nfs4_slot_get_seqid(tbl, slotid, &cur_seq) == 0 && | ||
| 204 | cur_seq == seq_nr && test_bit(slotid, tbl->used_slots)) | ||
| 205 | ret = true; | ||
| 206 | spin_unlock(&tbl->slot_tbl_lock); | ||
| 207 | return ret; | ||
| 208 | } | ||
| 209 | |||
| 210 | /* | ||
| 211 | * nfs4_slot_wait_on_seqid - wait until a slot sequence id is complete | ||
| 212 | * | ||
| 213 | * Given a slot table, slot id and sequence number, wait until the | ||
| 214 | * corresponding RPC call completes. This function is mainly | ||
| 215 | * intended for use by the callback channel. | ||
| 216 | */ | ||
| 217 | int nfs4_slot_wait_on_seqid(struct nfs4_slot_table *tbl, | ||
| 218 | u32 slotid, u32 seq_nr, | ||
| 219 | unsigned long timeout) | ||
| 220 | { | ||
| 221 | if (wait_event_timeout(tbl->slot_waitq, | ||
| 222 | !nfs4_slot_seqid_in_use(tbl, slotid, seq_nr), | ||
| 223 | timeout) == 0) | ||
| 224 | return -ETIMEDOUT; | ||
| 225 | return 0; | ||
| 226 | } | ||
| 227 | |||
| 175 | /* | 228 | /* |
| 176 | * nfs4_alloc_slot - efficiently look for a free slot | 229 | * nfs4_alloc_slot - efficiently look for a free slot |
| 177 | * | 230 | * |
diff --git a/fs/nfs/nfs4session.h b/fs/nfs/nfs4session.h index 5b51298d1d03..f703b755351b 100644 --- a/fs/nfs/nfs4session.h +++ b/fs/nfs/nfs4session.h | |||
| @@ -21,7 +21,8 @@ struct nfs4_slot { | |||
| 21 | unsigned long generation; | 21 | unsigned long generation; |
| 22 | u32 slot_nr; | 22 | u32 slot_nr; |
| 23 | u32 seq_nr; | 23 | u32 seq_nr; |
| 24 | unsigned int interrupted : 1; | 24 | unsigned int interrupted : 1, |
| 25 | seq_done : 1; | ||
| 25 | }; | 26 | }; |
| 26 | 27 | ||
| 27 | /* Sessions */ | 28 | /* Sessions */ |
| @@ -36,6 +37,7 @@ struct nfs4_slot_table { | |||
| 36 | unsigned long used_slots[SLOT_TABLE_SZ]; /* used/unused bitmap */ | 37 | unsigned long used_slots[SLOT_TABLE_SZ]; /* used/unused bitmap */ |
| 37 | spinlock_t slot_tbl_lock; | 38 | spinlock_t slot_tbl_lock; |
| 38 | struct rpc_wait_queue slot_tbl_waitq; /* allocators may wait here */ | 39 | struct rpc_wait_queue slot_tbl_waitq; /* allocators may wait here */ |
| 40 | wait_queue_head_t slot_waitq; /* Completion wait on slot */ | ||
| 39 | u32 max_slots; /* # slots in table */ | 41 | u32 max_slots; /* # slots in table */ |
| 40 | u32 max_slotid; /* Max allowed slotid value */ | 42 | u32 max_slotid; /* Max allowed slotid value */ |
| 41 | u32 highest_used_slotid; /* sent to server on each SEQ. | 43 | u32 highest_used_slotid; /* sent to server on each SEQ. |
| @@ -78,6 +80,9 @@ extern int nfs4_setup_slot_table(struct nfs4_slot_table *tbl, | |||
| 78 | extern void nfs4_shutdown_slot_table(struct nfs4_slot_table *tbl); | 80 | extern void nfs4_shutdown_slot_table(struct nfs4_slot_table *tbl); |
| 79 | extern struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl); | 81 | extern struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl); |
| 80 | extern struct nfs4_slot *nfs4_lookup_slot(struct nfs4_slot_table *tbl, u32 slotid); | 82 | extern struct nfs4_slot *nfs4_lookup_slot(struct nfs4_slot_table *tbl, u32 slotid); |
| 83 | extern int nfs4_slot_wait_on_seqid(struct nfs4_slot_table *tbl, | ||
| 84 | u32 slotid, u32 seq_nr, | ||
| 85 | unsigned long timeout); | ||
| 81 | extern bool nfs4_try_to_lock_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot); | 86 | extern bool nfs4_try_to_lock_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot); |
| 82 | extern void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot); | 87 | extern void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot); |
| 83 | extern void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl); | 88 | extern void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl); |
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 70806cae0d36..2c93a85eda51 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
| @@ -365,7 +365,8 @@ pnfs_layout_remove_lseg(struct pnfs_layout_hdr *lo, | |||
| 365 | /* Matched by pnfs_get_layout_hdr in pnfs_layout_insert_lseg */ | 365 | /* Matched by pnfs_get_layout_hdr in pnfs_layout_insert_lseg */ |
| 366 | atomic_dec(&lo->plh_refcount); | 366 | atomic_dec(&lo->plh_refcount); |
| 367 | if (list_empty(&lo->plh_segs)) { | 367 | if (list_empty(&lo->plh_segs)) { |
| 368 | set_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags); | 368 | if (atomic_read(&lo->plh_outstanding) == 0) |
| 369 | set_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags); | ||
| 369 | clear_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags); | 370 | clear_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags); |
| 370 | } | 371 | } |
| 371 | rpc_wake_up(&NFS_SERVER(inode)->roc_rpcwaitq); | 372 | rpc_wake_up(&NFS_SERVER(inode)->roc_rpcwaitq); |
| @@ -768,17 +769,32 @@ pnfs_destroy_all_layouts(struct nfs_client *clp) | |||
| 768 | pnfs_destroy_layouts_byclid(clp, false); | 769 | pnfs_destroy_layouts_byclid(clp, false); |
| 769 | } | 770 | } |
| 770 | 771 | ||
| 772 | static void | ||
| 773 | pnfs_clear_layoutreturn_info(struct pnfs_layout_hdr *lo) | ||
| 774 | { | ||
| 775 | lo->plh_return_iomode = 0; | ||
| 776 | lo->plh_return_seq = 0; | ||
| 777 | clear_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags); | ||
| 778 | } | ||
| 779 | |||
| 771 | /* update lo->plh_stateid with new if is more recent */ | 780 | /* update lo->plh_stateid with new if is more recent */ |
| 772 | void | 781 | void |
| 773 | pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, | 782 | pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, |
| 774 | bool update_barrier) | 783 | bool update_barrier) |
| 775 | { | 784 | { |
| 776 | u32 oldseq, newseq, new_barrier = 0; | 785 | u32 oldseq, newseq, new_barrier = 0; |
| 777 | bool invalid = !pnfs_layout_is_valid(lo); | ||
| 778 | 786 | ||
| 779 | oldseq = be32_to_cpu(lo->plh_stateid.seqid); | 787 | oldseq = be32_to_cpu(lo->plh_stateid.seqid); |
| 780 | newseq = be32_to_cpu(new->seqid); | 788 | newseq = be32_to_cpu(new->seqid); |
| 781 | if (invalid || pnfs_seqid_is_newer(newseq, oldseq)) { | 789 | |
| 790 | if (!pnfs_layout_is_valid(lo)) { | ||
| 791 | nfs4_stateid_copy(&lo->plh_stateid, new); | ||
| 792 | lo->plh_barrier = newseq; | ||
| 793 | pnfs_clear_layoutreturn_info(lo); | ||
| 794 | clear_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags); | ||
| 795 | return; | ||
| 796 | } | ||
| 797 | if (pnfs_seqid_is_newer(newseq, oldseq)) { | ||
| 782 | nfs4_stateid_copy(&lo->plh_stateid, new); | 798 | nfs4_stateid_copy(&lo->plh_stateid, new); |
| 783 | /* | 799 | /* |
| 784 | * Because of wraparound, we want to keep the barrier | 800 | * Because of wraparound, we want to keep the barrier |
| @@ -790,7 +806,7 @@ pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, | |||
| 790 | new_barrier = be32_to_cpu(new->seqid); | 806 | new_barrier = be32_to_cpu(new->seqid); |
| 791 | else if (new_barrier == 0) | 807 | else if (new_barrier == 0) |
| 792 | return; | 808 | return; |
| 793 | if (invalid || pnfs_seqid_is_newer(new_barrier, lo->plh_barrier)) | 809 | if (pnfs_seqid_is_newer(new_barrier, lo->plh_barrier)) |
| 794 | lo->plh_barrier = new_barrier; | 810 | lo->plh_barrier = new_barrier; |
| 795 | } | 811 | } |
| 796 | 812 | ||
| @@ -886,19 +902,14 @@ void pnfs_clear_layoutreturn_waitbit(struct pnfs_layout_hdr *lo) | |||
| 886 | rpc_wake_up(&NFS_SERVER(lo->plh_inode)->roc_rpcwaitq); | 902 | rpc_wake_up(&NFS_SERVER(lo->plh_inode)->roc_rpcwaitq); |
| 887 | } | 903 | } |
| 888 | 904 | ||
| 889 | static void | ||
| 890 | pnfs_clear_layoutreturn_info(struct pnfs_layout_hdr *lo) | ||
| 891 | { | ||
| 892 | lo->plh_return_iomode = 0; | ||
| 893 | lo->plh_return_seq = 0; | ||
| 894 | clear_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags); | ||
| 895 | } | ||
| 896 | |||
| 897 | static bool | 905 | static bool |
| 898 | pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo, | 906 | pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo, |
| 899 | nfs4_stateid *stateid, | 907 | nfs4_stateid *stateid, |
| 900 | enum pnfs_iomode *iomode) | 908 | enum pnfs_iomode *iomode) |
| 901 | { | 909 | { |
| 910 | /* Serialise LAYOUTGET/LAYOUTRETURN */ | ||
| 911 | if (atomic_read(&lo->plh_outstanding) != 0) | ||
| 912 | return false; | ||
| 902 | if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) | 913 | if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) |
| 903 | return false; | 914 | return false; |
| 904 | pnfs_get_layout_hdr(lo); | 915 | pnfs_get_layout_hdr(lo); |
| @@ -1555,6 +1566,7 @@ pnfs_update_layout(struct inode *ino, | |||
| 1555 | } | 1566 | } |
| 1556 | 1567 | ||
| 1557 | lookup_again: | 1568 | lookup_again: |
| 1569 | nfs4_client_recover_expired_lease(clp); | ||
| 1558 | first = false; | 1570 | first = false; |
| 1559 | spin_lock(&ino->i_lock); | 1571 | spin_lock(&ino->i_lock); |
| 1560 | lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags); | 1572 | lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags); |
| @@ -1797,16 +1809,11 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) | |||
| 1797 | */ | 1809 | */ |
| 1798 | pnfs_mark_layout_stateid_invalid(lo, &free_me); | 1810 | pnfs_mark_layout_stateid_invalid(lo, &free_me); |
| 1799 | 1811 | ||
| 1800 | nfs4_stateid_copy(&lo->plh_stateid, &res->stateid); | 1812 | pnfs_set_layout_stateid(lo, &res->stateid, true); |
| 1801 | lo->plh_barrier = be32_to_cpu(res->stateid.seqid); | ||
| 1802 | } | 1813 | } |
| 1803 | 1814 | ||
| 1804 | pnfs_get_lseg(lseg); | 1815 | pnfs_get_lseg(lseg); |
| 1805 | pnfs_layout_insert_lseg(lo, lseg, &free_me); | 1816 | pnfs_layout_insert_lseg(lo, lseg, &free_me); |
| 1806 | if (!pnfs_layout_is_valid(lo)) { | ||
| 1807 | pnfs_clear_layoutreturn_info(lo); | ||
| 1808 | clear_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags); | ||
| 1809 | } | ||
| 1810 | 1817 | ||
| 1811 | 1818 | ||
| 1812 | if (res->return_on_close) | 1819 | if (res->return_on_close) |
| @@ -2510,7 +2517,6 @@ pnfs_report_layoutstat(struct inode *inode, gfp_t gfp_flags) | |||
| 2510 | 2517 | ||
| 2511 | data->args.fh = NFS_FH(inode); | 2518 | data->args.fh = NFS_FH(inode); |
| 2512 | data->args.inode = inode; | 2519 | data->args.inode = inode; |
| 2513 | nfs4_stateid_copy(&data->args.stateid, &hdr->plh_stateid); | ||
| 2514 | status = ld->prepare_layoutstats(&data->args); | 2520 | status = ld->prepare_layoutstats(&data->args); |
| 2515 | if (status) | 2521 | if (status) |
| 2516 | goto out_free; | 2522 | goto out_free; |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 18d446e1a82b..d39601381adf 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
| @@ -923,6 +923,8 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(void) | |||
| 923 | 923 | ||
| 924 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 924 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
| 925 | if (data) { | 925 | if (data) { |
| 926 | data->timeo = NFS_UNSPEC_TIMEO; | ||
| 927 | data->retrans = NFS_UNSPEC_RETRANS; | ||
| 926 | data->acregmin = NFS_DEF_ACREGMIN; | 928 | data->acregmin = NFS_DEF_ACREGMIN; |
| 927 | data->acregmax = NFS_DEF_ACREGMAX; | 929 | data->acregmax = NFS_DEF_ACREGMAX; |
| 928 | data->acdirmin = NFS_DEF_ACDIRMIN; | 930 | data->acdirmin = NFS_DEF_ACDIRMIN; |
| @@ -1189,6 +1191,19 @@ static int nfs_get_option_ul(substring_t args[], unsigned long *option) | |||
| 1189 | return rc; | 1191 | return rc; |
| 1190 | } | 1192 | } |
| 1191 | 1193 | ||
| 1194 | static int nfs_get_option_ul_bound(substring_t args[], unsigned long *option, | ||
| 1195 | unsigned long l_bound, unsigned long u_bound) | ||
| 1196 | { | ||
| 1197 | int ret; | ||
| 1198 | |||
| 1199 | ret = nfs_get_option_ul(args, option); | ||
| 1200 | if (ret != 0) | ||
| 1201 | return ret; | ||
| 1202 | if (*option < l_bound || *option > u_bound) | ||
| 1203 | return -ERANGE; | ||
| 1204 | return 0; | ||
| 1205 | } | ||
| 1206 | |||
| 1192 | /* | 1207 | /* |
| 1193 | * Error-check and convert a string of mount options from user space into | 1208 | * Error-check and convert a string of mount options from user space into |
| 1194 | * a data structure. The whole mount string is processed; bad options are | 1209 | * a data structure. The whole mount string is processed; bad options are |
| @@ -1352,12 +1367,12 @@ static int nfs_parse_mount_options(char *raw, | |||
| 1352 | mnt->bsize = option; | 1367 | mnt->bsize = option; |
| 1353 | break; | 1368 | break; |
| 1354 | case Opt_timeo: | 1369 | case Opt_timeo: |
| 1355 | if (nfs_get_option_ul(args, &option) || option == 0) | 1370 | if (nfs_get_option_ul_bound(args, &option, 1, INT_MAX)) |
| 1356 | goto out_invalid_value; | 1371 | goto out_invalid_value; |
| 1357 | mnt->timeo = option; | 1372 | mnt->timeo = option; |
| 1358 | break; | 1373 | break; |
| 1359 | case Opt_retrans: | 1374 | case Opt_retrans: |
| 1360 | if (nfs_get_option_ul(args, &option) || option == 0) | 1375 | if (nfs_get_option_ul_bound(args, &option, 0, INT_MAX)) |
| 1361 | goto out_invalid_value; | 1376 | goto out_invalid_value; |
| 1362 | mnt->retrans = option; | 1377 | mnt->retrans = option; |
| 1363 | break; | 1378 | break; |
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 54e5d6681786..43fdc2765aea 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c | |||
| @@ -80,6 +80,8 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new) | |||
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | for (name = buf; name < (buf + list_size); name += strlen(name) + 1) { | 82 | for (name = buf; name < (buf + list_size); name += strlen(name) + 1) { |
| 83 | if (ovl_is_private_xattr(name)) | ||
| 84 | continue; | ||
| 83 | retry: | 85 | retry: |
| 84 | size = vfs_getxattr(old, name, value, value_size); | 86 | size = vfs_getxattr(old, name, value, value_size); |
| 85 | if (size == -ERANGE) | 87 | if (size == -ERANGE) |
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 12bcd07b9e32..1560fdc09a5f 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c | |||
| @@ -12,6 +12,8 @@ | |||
| 12 | #include <linux/xattr.h> | 12 | #include <linux/xattr.h> |
| 13 | #include <linux/security.h> | 13 | #include <linux/security.h> |
| 14 | #include <linux/cred.h> | 14 | #include <linux/cred.h> |
| 15 | #include <linux/posix_acl.h> | ||
| 16 | #include <linux/posix_acl_xattr.h> | ||
| 15 | #include "overlayfs.h" | 17 | #include "overlayfs.h" |
| 16 | 18 | ||
| 17 | void ovl_cleanup(struct inode *wdir, struct dentry *wdentry) | 19 | void ovl_cleanup(struct inode *wdir, struct dentry *wdentry) |
| @@ -186,6 +188,9 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode, | |||
| 186 | struct dentry *newdentry; | 188 | struct dentry *newdentry; |
| 187 | int err; | 189 | int err; |
| 188 | 190 | ||
| 191 | if (!hardlink && !IS_POSIXACL(udir)) | ||
| 192 | stat->mode &= ~current_umask(); | ||
| 193 | |||
| 189 | inode_lock_nested(udir, I_MUTEX_PARENT); | 194 | inode_lock_nested(udir, I_MUTEX_PARENT); |
| 190 | newdentry = lookup_one_len(dentry->d_name.name, upperdir, | 195 | newdentry = lookup_one_len(dentry->d_name.name, upperdir, |
| 191 | dentry->d_name.len); | 196 | dentry->d_name.len); |
| @@ -335,6 +340,32 @@ out_free: | |||
| 335 | return ret; | 340 | return ret; |
| 336 | } | 341 | } |
| 337 | 342 | ||
| 343 | static int ovl_set_upper_acl(struct dentry *upperdentry, const char *name, | ||
| 344 | const struct posix_acl *acl) | ||
| 345 | { | ||
| 346 | void *buffer; | ||
| 347 | size_t size; | ||
| 348 | int err; | ||
| 349 | |||
| 350 | if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !acl) | ||
| 351 | return 0; | ||
| 352 | |||
| 353 | size = posix_acl_to_xattr(NULL, acl, NULL, 0); | ||
| 354 | buffer = kmalloc(size, GFP_KERNEL); | ||
| 355 | if (!buffer) | ||
| 356 | return -ENOMEM; | ||
| 357 | |||
| 358 | size = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); | ||
| 359 | err = size; | ||
| 360 | if (err < 0) | ||
| 361 | goto out_free; | ||
| 362 | |||
| 363 | err = vfs_setxattr(upperdentry, name, buffer, size, XATTR_CREATE); | ||
| 364 | out_free: | ||
| 365 | kfree(buffer); | ||
| 366 | return err; | ||
| 367 | } | ||
| 368 | |||
| 338 | static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode, | 369 | static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode, |
| 339 | struct kstat *stat, const char *link, | 370 | struct kstat *stat, const char *link, |
| 340 | struct dentry *hardlink) | 371 | struct dentry *hardlink) |
| @@ -346,10 +377,18 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode, | |||
| 346 | struct dentry *upper; | 377 | struct dentry *upper; |
| 347 | struct dentry *newdentry; | 378 | struct dentry *newdentry; |
| 348 | int err; | 379 | int err; |
| 380 | struct posix_acl *acl, *default_acl; | ||
| 349 | 381 | ||
| 350 | if (WARN_ON(!workdir)) | 382 | if (WARN_ON(!workdir)) |
| 351 | return -EROFS; | 383 | return -EROFS; |
| 352 | 384 | ||
| 385 | if (!hardlink) { | ||
| 386 | err = posix_acl_create(dentry->d_parent->d_inode, | ||
| 387 | &stat->mode, &default_acl, &acl); | ||
| 388 | if (err) | ||
| 389 | return err; | ||
| 390 | } | ||
| 391 | |||
| 353 | err = ovl_lock_rename_workdir(workdir, upperdir); | 392 | err = ovl_lock_rename_workdir(workdir, upperdir); |
| 354 | if (err) | 393 | if (err) |
| 355 | goto out; | 394 | goto out; |
| @@ -384,6 +423,17 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode, | |||
| 384 | if (err) | 423 | if (err) |
| 385 | goto out_cleanup; | 424 | goto out_cleanup; |
| 386 | } | 425 | } |
| 426 | if (!hardlink) { | ||
| 427 | err = ovl_set_upper_acl(newdentry, XATTR_NAME_POSIX_ACL_ACCESS, | ||
| 428 | acl); | ||
| 429 | if (err) | ||
| 430 | goto out_cleanup; | ||
| 431 | |||
| 432 | err = ovl_set_upper_acl(newdentry, XATTR_NAME_POSIX_ACL_DEFAULT, | ||
| 433 | default_acl); | ||
| 434 | if (err) | ||
| 435 | goto out_cleanup; | ||
| 436 | } | ||
| 387 | 437 | ||
| 388 | if (!hardlink && S_ISDIR(stat->mode)) { | 438 | if (!hardlink && S_ISDIR(stat->mode)) { |
| 389 | err = ovl_set_opaque(newdentry); | 439 | err = ovl_set_opaque(newdentry); |
| @@ -410,6 +460,10 @@ out_dput: | |||
| 410 | out_unlock: | 460 | out_unlock: |
| 411 | unlock_rename(workdir, upperdir); | 461 | unlock_rename(workdir, upperdir); |
| 412 | out: | 462 | out: |
| 463 | if (!hardlink) { | ||
| 464 | posix_acl_release(acl); | ||
| 465 | posix_acl_release(default_acl); | ||
| 466 | } | ||
| 413 | return err; | 467 | return err; |
| 414 | 468 | ||
| 415 | out_cleanup: | 469 | out_cleanup: |
| @@ -950,9 +1004,9 @@ const struct inode_operations ovl_dir_inode_operations = { | |||
| 950 | .permission = ovl_permission, | 1004 | .permission = ovl_permission, |
| 951 | .getattr = ovl_dir_getattr, | 1005 | .getattr = ovl_dir_getattr, |
| 952 | .setxattr = generic_setxattr, | 1006 | .setxattr = generic_setxattr, |
| 953 | .getxattr = ovl_getxattr, | 1007 | .getxattr = generic_getxattr, |
| 954 | .listxattr = ovl_listxattr, | 1008 | .listxattr = ovl_listxattr, |
| 955 | .removexattr = ovl_removexattr, | 1009 | .removexattr = generic_removexattr, |
| 956 | .get_acl = ovl_get_acl, | 1010 | .get_acl = ovl_get_acl, |
| 957 | .update_time = ovl_update_time, | 1011 | .update_time = ovl_update_time, |
| 958 | }; | 1012 | }; |
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 1b885c156028..c75625c1efa3 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
| 11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
| 12 | #include <linux/xattr.h> | 12 | #include <linux/xattr.h> |
| 13 | #include <linux/posix_acl.h> | ||
| 13 | #include "overlayfs.h" | 14 | #include "overlayfs.h" |
| 14 | 15 | ||
| 15 | static int ovl_copy_up_truncate(struct dentry *dentry) | 16 | static int ovl_copy_up_truncate(struct dentry *dentry) |
| @@ -191,32 +192,44 @@ static int ovl_readlink(struct dentry *dentry, char __user *buf, int bufsiz) | |||
| 191 | return err; | 192 | return err; |
| 192 | } | 193 | } |
| 193 | 194 | ||
| 194 | static bool ovl_is_private_xattr(const char *name) | 195 | bool ovl_is_private_xattr(const char *name) |
| 195 | { | 196 | { |
| 196 | #define OVL_XATTR_PRE_NAME OVL_XATTR_PREFIX "." | 197 | return strncmp(name, OVL_XATTR_PREFIX, |
| 197 | return strncmp(name, OVL_XATTR_PRE_NAME, | 198 | sizeof(OVL_XATTR_PREFIX) - 1) == 0; |
| 198 | sizeof(OVL_XATTR_PRE_NAME) - 1) == 0; | ||
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | int ovl_setxattr(struct dentry *dentry, struct inode *inode, | 201 | int ovl_xattr_set(struct dentry *dentry, const char *name, const void *value, |
| 202 | const char *name, const void *value, | 202 | size_t size, int flags) |
| 203 | size_t size, int flags) | ||
| 204 | { | 203 | { |
| 205 | int err; | 204 | int err; |
| 206 | struct dentry *upperdentry; | 205 | struct path realpath; |
| 206 | enum ovl_path_type type = ovl_path_real(dentry, &realpath); | ||
| 207 | const struct cred *old_cred; | 207 | const struct cred *old_cred; |
| 208 | 208 | ||
| 209 | err = ovl_want_write(dentry); | 209 | err = ovl_want_write(dentry); |
| 210 | if (err) | 210 | if (err) |
| 211 | goto out; | 211 | goto out; |
| 212 | 212 | ||
| 213 | if (!value && !OVL_TYPE_UPPER(type)) { | ||
| 214 | err = vfs_getxattr(realpath.dentry, name, NULL, 0); | ||
| 215 | if (err < 0) | ||
| 216 | goto out_drop_write; | ||
| 217 | } | ||
| 218 | |||
| 213 | err = ovl_copy_up(dentry); | 219 | err = ovl_copy_up(dentry); |
| 214 | if (err) | 220 | if (err) |
| 215 | goto out_drop_write; | 221 | goto out_drop_write; |
| 216 | 222 | ||
| 217 | upperdentry = ovl_dentry_upper(dentry); | 223 | if (!OVL_TYPE_UPPER(type)) |
| 224 | ovl_path_upper(dentry, &realpath); | ||
| 225 | |||
| 218 | old_cred = ovl_override_creds(dentry->d_sb); | 226 | old_cred = ovl_override_creds(dentry->d_sb); |
| 219 | err = vfs_setxattr(upperdentry, name, value, size, flags); | 227 | if (value) |
| 228 | err = vfs_setxattr(realpath.dentry, name, value, size, flags); | ||
| 229 | else { | ||
| 230 | WARN_ON(flags != XATTR_REPLACE); | ||
| 231 | err = vfs_removexattr(realpath.dentry, name); | ||
| 232 | } | ||
| 220 | revert_creds(old_cred); | 233 | revert_creds(old_cred); |
| 221 | 234 | ||
| 222 | out_drop_write: | 235 | out_drop_write: |
| @@ -225,16 +238,13 @@ out: | |||
| 225 | return err; | 238 | return err; |
| 226 | } | 239 | } |
| 227 | 240 | ||
| 228 | ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode, | 241 | int ovl_xattr_get(struct dentry *dentry, const char *name, |
| 229 | const char *name, void *value, size_t size) | 242 | void *value, size_t size) |
| 230 | { | 243 | { |
| 231 | struct dentry *realdentry = ovl_dentry_real(dentry); | 244 | struct dentry *realdentry = ovl_dentry_real(dentry); |
| 232 | ssize_t res; | 245 | ssize_t res; |
| 233 | const struct cred *old_cred; | 246 | const struct cred *old_cred; |
| 234 | 247 | ||
| 235 | if (ovl_is_private_xattr(name)) | ||
| 236 | return -ENODATA; | ||
| 237 | |||
| 238 | old_cred = ovl_override_creds(dentry->d_sb); | 248 | old_cred = ovl_override_creds(dentry->d_sb); |
| 239 | res = vfs_getxattr(realdentry, name, value, size); | 249 | res = vfs_getxattr(realdentry, name, value, size); |
| 240 | revert_creds(old_cred); | 250 | revert_creds(old_cred); |
| @@ -245,7 +255,8 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size) | |||
| 245 | { | 255 | { |
| 246 | struct dentry *realdentry = ovl_dentry_real(dentry); | 256 | struct dentry *realdentry = ovl_dentry_real(dentry); |
| 247 | ssize_t res; | 257 | ssize_t res; |
| 248 | int off; | 258 | size_t len; |
| 259 | char *s; | ||
| 249 | const struct cred *old_cred; | 260 | const struct cred *old_cred; |
| 250 | 261 | ||
| 251 | old_cred = ovl_override_creds(dentry->d_sb); | 262 | old_cred = ovl_override_creds(dentry->d_sb); |
| @@ -255,73 +266,39 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size) | |||
| 255 | return res; | 266 | return res; |
| 256 | 267 | ||
| 257 | /* filter out private xattrs */ | 268 | /* filter out private xattrs */ |
| 258 | for (off = 0; off < res;) { | 269 | for (s = list, len = res; len;) { |
| 259 | char *s = list + off; | 270 | size_t slen = strnlen(s, len) + 1; |
| 260 | size_t slen = strlen(s) + 1; | ||
| 261 | 271 | ||
| 262 | BUG_ON(off + slen > res); | 272 | /* underlying fs providing us with an broken xattr list? */ |
| 273 | if (WARN_ON(slen > len)) | ||
| 274 | return -EIO; | ||
| 263 | 275 | ||
| 276 | len -= slen; | ||
| 264 | if (ovl_is_private_xattr(s)) { | 277 | if (ovl_is_private_xattr(s)) { |
| 265 | res -= slen; | 278 | res -= slen; |
| 266 | memmove(s, s + slen, res - off); | 279 | memmove(s, s + slen, len); |
| 267 | } else { | 280 | } else { |
| 268 | off += slen; | 281 | s += slen; |
| 269 | } | 282 | } |
| 270 | } | 283 | } |
| 271 | 284 | ||
| 272 | return res; | 285 | return res; |
| 273 | } | 286 | } |
| 274 | 287 | ||
| 275 | int ovl_removexattr(struct dentry *dentry, const char *name) | ||
| 276 | { | ||
| 277 | int err; | ||
| 278 | struct path realpath; | ||
| 279 | enum ovl_path_type type = ovl_path_real(dentry, &realpath); | ||
| 280 | const struct cred *old_cred; | ||
| 281 | |||
| 282 | err = ovl_want_write(dentry); | ||
| 283 | if (err) | ||
| 284 | goto out; | ||
| 285 | |||
| 286 | err = -ENODATA; | ||
| 287 | if (ovl_is_private_xattr(name)) | ||
| 288 | goto out_drop_write; | ||
| 289 | |||
| 290 | if (!OVL_TYPE_UPPER(type)) { | ||
| 291 | err = vfs_getxattr(realpath.dentry, name, NULL, 0); | ||
| 292 | if (err < 0) | ||
| 293 | goto out_drop_write; | ||
| 294 | |||
| 295 | err = ovl_copy_up(dentry); | ||
| 296 | if (err) | ||
| 297 | goto out_drop_write; | ||
| 298 | |||
| 299 | ovl_path_upper(dentry, &realpath); | ||
| 300 | } | ||
| 301 | |||
| 302 | old_cred = ovl_override_creds(dentry->d_sb); | ||
| 303 | err = vfs_removexattr(realpath.dentry, name); | ||
| 304 | revert_creds(old_cred); | ||
| 305 | out_drop_write: | ||
| 306 | ovl_drop_write(dentry); | ||
| 307 | out: | ||
| 308 | return err; | ||
| 309 | } | ||
| 310 | |||
| 311 | struct posix_acl *ovl_get_acl(struct inode *inode, int type) | 288 | struct posix_acl *ovl_get_acl(struct inode *inode, int type) |
| 312 | { | 289 | { |
| 313 | struct inode *realinode = ovl_inode_real(inode, NULL); | 290 | struct inode *realinode = ovl_inode_real(inode, NULL); |
| 314 | const struct cred *old_cred; | 291 | const struct cred *old_cred; |
| 315 | struct posix_acl *acl; | 292 | struct posix_acl *acl; |
| 316 | 293 | ||
| 317 | if (!IS_POSIXACL(realinode)) | 294 | if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !IS_POSIXACL(realinode)) |
| 318 | return NULL; | 295 | return NULL; |
| 319 | 296 | ||
| 320 | if (!realinode->i_op->get_acl) | 297 | if (!realinode->i_op->get_acl) |
| 321 | return NULL; | 298 | return NULL; |
| 322 | 299 | ||
| 323 | old_cred = ovl_override_creds(inode->i_sb); | 300 | old_cred = ovl_override_creds(inode->i_sb); |
| 324 | acl = realinode->i_op->get_acl(realinode, type); | 301 | acl = get_acl(realinode, type); |
| 325 | revert_creds(old_cred); | 302 | revert_creds(old_cred); |
| 326 | 303 | ||
| 327 | return acl; | 304 | return acl; |
| @@ -391,9 +368,9 @@ static const struct inode_operations ovl_file_inode_operations = { | |||
| 391 | .permission = ovl_permission, | 368 | .permission = ovl_permission, |
| 392 | .getattr = ovl_getattr, | 369 | .getattr = ovl_getattr, |
| 393 | .setxattr = generic_setxattr, | 370 | .setxattr = generic_setxattr, |
| 394 | .getxattr = ovl_getxattr, | 371 | .getxattr = generic_getxattr, |
| 395 | .listxattr = ovl_listxattr, | 372 | .listxattr = ovl_listxattr, |
| 396 | .removexattr = ovl_removexattr, | 373 | .removexattr = generic_removexattr, |
| 397 | .get_acl = ovl_get_acl, | 374 | .get_acl = ovl_get_acl, |
| 398 | .update_time = ovl_update_time, | 375 | .update_time = ovl_update_time, |
| 399 | }; | 376 | }; |
| @@ -404,9 +381,9 @@ static const struct inode_operations ovl_symlink_inode_operations = { | |||
| 404 | .readlink = ovl_readlink, | 381 | .readlink = ovl_readlink, |
| 405 | .getattr = ovl_getattr, | 382 | .getattr = ovl_getattr, |
| 406 | .setxattr = generic_setxattr, | 383 | .setxattr = generic_setxattr, |
| 407 | .getxattr = ovl_getxattr, | 384 | .getxattr = generic_getxattr, |
| 408 | .listxattr = ovl_listxattr, | 385 | .listxattr = ovl_listxattr, |
| 409 | .removexattr = ovl_removexattr, | 386 | .removexattr = generic_removexattr, |
| 410 | .update_time = ovl_update_time, | 387 | .update_time = ovl_update_time, |
| 411 | }; | 388 | }; |
| 412 | 389 | ||
| @@ -415,6 +392,9 @@ static void ovl_fill_inode(struct inode *inode, umode_t mode) | |||
| 415 | inode->i_ino = get_next_ino(); | 392 | inode->i_ino = get_next_ino(); |
| 416 | inode->i_mode = mode; | 393 | inode->i_mode = mode; |
| 417 | inode->i_flags |= S_NOCMTIME; | 394 | inode->i_flags |= S_NOCMTIME; |
| 395 | #ifdef CONFIG_FS_POSIX_ACL | ||
| 396 | inode->i_acl = inode->i_default_acl = ACL_DONT_CACHE; | ||
| 397 | #endif | ||
| 418 | 398 | ||
| 419 | mode &= S_IFMT; | 399 | mode &= S_IFMT; |
| 420 | switch (mode) { | 400 | switch (mode) { |
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index e4f5c9536bfe..5813ccff8cd9 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h | |||
| @@ -24,8 +24,8 @@ enum ovl_path_type { | |||
| 24 | (OVL_TYPE_MERGE(type) || !OVL_TYPE_UPPER(type)) | 24 | (OVL_TYPE_MERGE(type) || !OVL_TYPE_UPPER(type)) |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | #define OVL_XATTR_PREFIX XATTR_TRUSTED_PREFIX "overlay" | 27 | #define OVL_XATTR_PREFIX XATTR_TRUSTED_PREFIX "overlay." |
| 28 | #define OVL_XATTR_OPAQUE OVL_XATTR_PREFIX ".opaque" | 28 | #define OVL_XATTR_OPAQUE OVL_XATTR_PREFIX "opaque" |
| 29 | 29 | ||
| 30 | #define OVL_ISUPPER_MASK 1UL | 30 | #define OVL_ISUPPER_MASK 1UL |
| 31 | 31 | ||
| @@ -179,20 +179,21 @@ int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list); | |||
| 179 | void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list); | 179 | void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list); |
| 180 | void ovl_cache_free(struct list_head *list); | 180 | void ovl_cache_free(struct list_head *list); |
| 181 | int ovl_check_d_type_supported(struct path *realpath); | 181 | int ovl_check_d_type_supported(struct path *realpath); |
| 182 | void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt, | ||
| 183 | struct dentry *dentry, int level); | ||
| 182 | 184 | ||
| 183 | /* inode.c */ | 185 | /* inode.c */ |
| 184 | int ovl_setattr(struct dentry *dentry, struct iattr *attr); | 186 | int ovl_setattr(struct dentry *dentry, struct iattr *attr); |
| 185 | int ovl_permission(struct inode *inode, int mask); | 187 | int ovl_permission(struct inode *inode, int mask); |
| 186 | int ovl_setxattr(struct dentry *dentry, struct inode *inode, | 188 | int ovl_xattr_set(struct dentry *dentry, const char *name, const void *value, |
| 187 | const char *name, const void *value, | 189 | size_t size, int flags); |
| 188 | size_t size, int flags); | 190 | int ovl_xattr_get(struct dentry *dentry, const char *name, |
| 189 | ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode, | 191 | void *value, size_t size); |
| 190 | const char *name, void *value, size_t size); | ||
| 191 | ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); | 192 | ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); |
| 192 | int ovl_removexattr(struct dentry *dentry, const char *name); | ||
| 193 | struct posix_acl *ovl_get_acl(struct inode *inode, int type); | 193 | struct posix_acl *ovl_get_acl(struct inode *inode, int type); |
| 194 | int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags); | 194 | int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags); |
| 195 | int ovl_update_time(struct inode *inode, struct timespec *ts, int flags); | 195 | int ovl_update_time(struct inode *inode, struct timespec *ts, int flags); |
| 196 | bool ovl_is_private_xattr(const char *name); | ||
| 196 | 197 | ||
| 197 | struct inode *ovl_new_inode(struct super_block *sb, umode_t mode); | 198 | struct inode *ovl_new_inode(struct super_block *sb, umode_t mode); |
| 198 | struct inode *ovl_get_inode(struct super_block *sb, struct inode *realinode); | 199 | struct inode *ovl_get_inode(struct super_block *sb, struct inode *realinode); |
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c index cf37fc76fc9f..f241b4ee3d8a 100644 --- a/fs/overlayfs/readdir.c +++ b/fs/overlayfs/readdir.c | |||
| @@ -248,7 +248,7 @@ static inline int ovl_dir_read(struct path *realpath, | |||
| 248 | err = rdd->err; | 248 | err = rdd->err; |
| 249 | } while (!err && rdd->count); | 249 | } while (!err && rdd->count); |
| 250 | 250 | ||
| 251 | if (!err && rdd->first_maybe_whiteout) | 251 | if (!err && rdd->first_maybe_whiteout && rdd->dentry) |
| 252 | err = ovl_check_whiteouts(realpath->dentry, rdd); | 252 | err = ovl_check_whiteouts(realpath->dentry, rdd); |
| 253 | 253 | ||
| 254 | fput(realfile); | 254 | fput(realfile); |
| @@ -606,3 +606,64 @@ int ovl_check_d_type_supported(struct path *realpath) | |||
| 606 | 606 | ||
| 607 | return rdd.d_type_supported; | 607 | return rdd.d_type_supported; |
| 608 | } | 608 | } |
| 609 | |||
| 610 | static void ovl_workdir_cleanup_recurse(struct path *path, int level) | ||
| 611 | { | ||
| 612 | int err; | ||
| 613 | struct inode *dir = path->dentry->d_inode; | ||
| 614 | LIST_HEAD(list); | ||
| 615 | struct ovl_cache_entry *p; | ||
| 616 | struct ovl_readdir_data rdd = { | ||
| 617 | .ctx.actor = ovl_fill_merge, | ||
| 618 | .dentry = NULL, | ||
| 619 | .list = &list, | ||
| 620 | .root = RB_ROOT, | ||
| 621 | .is_lowest = false, | ||
| 622 | }; | ||
| 623 | |||
| 624 | err = ovl_dir_read(path, &rdd); | ||
| 625 | if (err) | ||
| 626 | goto out; | ||
| 627 | |||
| 628 | inode_lock_nested(dir, I_MUTEX_PARENT); | ||
| 629 | list_for_each_entry(p, &list, l_node) { | ||
| 630 | struct dentry *dentry; | ||
| 631 | |||
| 632 | if (p->name[0] == '.') { | ||
| 633 | if (p->len == 1) | ||
| 634 | continue; | ||
| 635 | if (p->len == 2 && p->name[1] == '.') | ||
| 636 | continue; | ||
| 637 | } | ||
| 638 | dentry = lookup_one_len(p->name, path->dentry, p->len); | ||
| 639 | if (IS_ERR(dentry)) | ||
| 640 | continue; | ||
| 641 | if (dentry->d_inode) | ||
| 642 | ovl_workdir_cleanup(dir, path->mnt, dentry, level); | ||
| 643 | dput(dentry); | ||
| 644 | } | ||
| 645 | inode_unlock(dir); | ||
| 646 | out: | ||
| 647 | ovl_cache_free(&list); | ||
| 648 | } | ||
| 649 | |||
| 650 | void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt, | ||
| 651 | struct dentry *dentry, int level) | ||
| 652 | { | ||
| 653 | int err; | ||
| 654 | |||
| 655 | if (!d_is_dir(dentry) || level > 1) { | ||
| 656 | ovl_cleanup(dir, dentry); | ||
| 657 | return; | ||
| 658 | } | ||
| 659 | |||
| 660 | err = ovl_do_rmdir(dir, dentry); | ||
| 661 | if (err) { | ||
| 662 | struct path path = { .mnt = mnt, .dentry = dentry }; | ||
| 663 | |||
| 664 | inode_unlock(dir); | ||
| 665 | ovl_workdir_cleanup_recurse(&path, level + 1); | ||
| 666 | inode_lock_nested(dir, I_MUTEX_PARENT); | ||
| 667 | ovl_cleanup(dir, dentry); | ||
| 668 | } | ||
| 669 | } | ||
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 4036132842b5..e2a94a26767b 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c | |||
| @@ -814,6 +814,10 @@ retry: | |||
| 814 | struct kstat stat = { | 814 | struct kstat stat = { |
| 815 | .mode = S_IFDIR | 0, | 815 | .mode = S_IFDIR | 0, |
| 816 | }; | 816 | }; |
| 817 | struct iattr attr = { | ||
| 818 | .ia_valid = ATTR_MODE, | ||
| 819 | .ia_mode = stat.mode, | ||
| 820 | }; | ||
| 817 | 821 | ||
| 818 | if (work->d_inode) { | 822 | if (work->d_inode) { |
| 819 | err = -EEXIST; | 823 | err = -EEXIST; |
| @@ -821,7 +825,7 @@ retry: | |||
| 821 | goto out_dput; | 825 | goto out_dput; |
| 822 | 826 | ||
| 823 | retried = true; | 827 | retried = true; |
| 824 | ovl_cleanup(dir, work); | 828 | ovl_workdir_cleanup(dir, mnt, work, 0); |
| 825 | dput(work); | 829 | dput(work); |
| 826 | goto retry; | 830 | goto retry; |
| 827 | } | 831 | } |
| @@ -829,6 +833,21 @@ retry: | |||
| 829 | err = ovl_create_real(dir, work, &stat, NULL, NULL, true); | 833 | err = ovl_create_real(dir, work, &stat, NULL, NULL, true); |
| 830 | if (err) | 834 | if (err) |
| 831 | goto out_dput; | 835 | goto out_dput; |
| 836 | |||
| 837 | err = vfs_removexattr(work, XATTR_NAME_POSIX_ACL_DEFAULT); | ||
| 838 | if (err && err != -ENODATA && err != -EOPNOTSUPP) | ||
| 839 | goto out_dput; | ||
| 840 | |||
| 841 | err = vfs_removexattr(work, XATTR_NAME_POSIX_ACL_ACCESS); | ||
| 842 | if (err && err != -ENODATA && err != -EOPNOTSUPP) | ||
| 843 | goto out_dput; | ||
| 844 | |||
| 845 | /* Clear any inherited mode bits */ | ||
| 846 | inode_lock(work->d_inode); | ||
| 847 | err = notify_change(work, &attr, NULL); | ||
| 848 | inode_unlock(work->d_inode); | ||
| 849 | if (err) | ||
| 850 | goto out_dput; | ||
| 832 | } | 851 | } |
| 833 | out_unlock: | 852 | out_unlock: |
| 834 | inode_unlock(dir); | 853 | inode_unlock(dir); |
| @@ -967,10 +986,19 @@ static unsigned int ovl_split_lowerdirs(char *str) | |||
| 967 | return ctr; | 986 | return ctr; |
| 968 | } | 987 | } |
| 969 | 988 | ||
| 970 | static int ovl_posix_acl_xattr_set(const struct xattr_handler *handler, | 989 | static int __maybe_unused |
| 971 | struct dentry *dentry, struct inode *inode, | 990 | ovl_posix_acl_xattr_get(const struct xattr_handler *handler, |
| 972 | const char *name, const void *value, | 991 | struct dentry *dentry, struct inode *inode, |
| 973 | size_t size, int flags) | 992 | const char *name, void *buffer, size_t size) |
| 993 | { | ||
| 994 | return ovl_xattr_get(dentry, handler->name, buffer, size); | ||
| 995 | } | ||
| 996 | |||
| 997 | static int __maybe_unused | ||
| 998 | ovl_posix_acl_xattr_set(const struct xattr_handler *handler, | ||
| 999 | struct dentry *dentry, struct inode *inode, | ||
| 1000 | const char *name, const void *value, | ||
| 1001 | size_t size, int flags) | ||
| 974 | { | 1002 | { |
| 975 | struct dentry *workdir = ovl_workdir(dentry); | 1003 | struct dentry *workdir = ovl_workdir(dentry); |
| 976 | struct inode *realinode = ovl_inode_real(inode, NULL); | 1004 | struct inode *realinode = ovl_inode_real(inode, NULL); |
| @@ -998,19 +1026,22 @@ static int ovl_posix_acl_xattr_set(const struct xattr_handler *handler, | |||
| 998 | 1026 | ||
| 999 | posix_acl_release(acl); | 1027 | posix_acl_release(acl); |
| 1000 | 1028 | ||
| 1001 | return ovl_setxattr(dentry, inode, handler->name, value, size, flags); | 1029 | err = ovl_xattr_set(dentry, handler->name, value, size, flags); |
| 1030 | if (!err) | ||
| 1031 | ovl_copyattr(ovl_inode_real(inode, NULL), inode); | ||
| 1032 | |||
| 1033 | return err; | ||
| 1002 | 1034 | ||
| 1003 | out_acl_release: | 1035 | out_acl_release: |
| 1004 | posix_acl_release(acl); | 1036 | posix_acl_release(acl); |
| 1005 | return err; | 1037 | return err; |
| 1006 | } | 1038 | } |
| 1007 | 1039 | ||
| 1008 | static int ovl_other_xattr_set(const struct xattr_handler *handler, | 1040 | static int ovl_own_xattr_get(const struct xattr_handler *handler, |
| 1009 | struct dentry *dentry, struct inode *inode, | 1041 | struct dentry *dentry, struct inode *inode, |
| 1010 | const char *name, const void *value, | 1042 | const char *name, void *buffer, size_t size) |
| 1011 | size_t size, int flags) | ||
| 1012 | { | 1043 | { |
| 1013 | return ovl_setxattr(dentry, inode, name, value, size, flags); | 1044 | return -EPERM; |
| 1014 | } | 1045 | } |
| 1015 | 1046 | ||
| 1016 | static int ovl_own_xattr_set(const struct xattr_handler *handler, | 1047 | static int ovl_own_xattr_set(const struct xattr_handler *handler, |
| @@ -1021,42 +1052,59 @@ static int ovl_own_xattr_set(const struct xattr_handler *handler, | |||
| 1021 | return -EPERM; | 1052 | return -EPERM; |
| 1022 | } | 1053 | } |
| 1023 | 1054 | ||
| 1024 | static const struct xattr_handler ovl_posix_acl_access_xattr_handler = { | 1055 | static int ovl_other_xattr_get(const struct xattr_handler *handler, |
| 1056 | struct dentry *dentry, struct inode *inode, | ||
| 1057 | const char *name, void *buffer, size_t size) | ||
| 1058 | { | ||
| 1059 | return ovl_xattr_get(dentry, name, buffer, size); | ||
| 1060 | } | ||
| 1061 | |||
| 1062 | static int ovl_other_xattr_set(const struct xattr_handler *handler, | ||
| 1063 | struct dentry *dentry, struct inode *inode, | ||
| 1064 | const char *name, const void *value, | ||
| 1065 | size_t size, int flags) | ||
| 1066 | { | ||
| 1067 | return ovl_xattr_set(dentry, name, value, size, flags); | ||
| 1068 | } | ||
| 1069 | |||
| 1070 | static const struct xattr_handler __maybe_unused | ||
| 1071 | ovl_posix_acl_access_xattr_handler = { | ||
| 1025 | .name = XATTR_NAME_POSIX_ACL_ACCESS, | 1072 | .name = XATTR_NAME_POSIX_ACL_ACCESS, |
| 1026 | .flags = ACL_TYPE_ACCESS, | 1073 | .flags = ACL_TYPE_ACCESS, |
| 1074 | .get = ovl_posix_acl_xattr_get, | ||
| 1027 | .set = ovl_posix_acl_xattr_set, | 1075 | .set = ovl_posix_acl_xattr_set, |
| 1028 | }; | 1076 | }; |
| 1029 | 1077 | ||
| 1030 | static const struct xattr_handler ovl_posix_acl_default_xattr_handler = { | 1078 | static const struct xattr_handler __maybe_unused |
| 1079 | ovl_posix_acl_default_xattr_handler = { | ||
| 1031 | .name = XATTR_NAME_POSIX_ACL_DEFAULT, | 1080 | .name = XATTR_NAME_POSIX_ACL_DEFAULT, |
| 1032 | .flags = ACL_TYPE_DEFAULT, | 1081 | .flags = ACL_TYPE_DEFAULT, |
| 1082 | .get = ovl_posix_acl_xattr_get, | ||
| 1033 | .set = ovl_posix_acl_xattr_set, | 1083 | .set = ovl_posix_acl_xattr_set, |
| 1034 | }; | 1084 | }; |
| 1035 | 1085 | ||
| 1036 | static const struct xattr_handler ovl_own_xattr_handler = { | 1086 | static const struct xattr_handler ovl_own_xattr_handler = { |
| 1037 | .prefix = OVL_XATTR_PREFIX, | 1087 | .prefix = OVL_XATTR_PREFIX, |
| 1088 | .get = ovl_own_xattr_get, | ||
| 1038 | .set = ovl_own_xattr_set, | 1089 | .set = ovl_own_xattr_set, |
| 1039 | }; | 1090 | }; |
| 1040 | 1091 | ||
| 1041 | static const struct xattr_handler ovl_other_xattr_handler = { | 1092 | static const struct xattr_handler ovl_other_xattr_handler = { |
| 1042 | .prefix = "", /* catch all */ | 1093 | .prefix = "", /* catch all */ |
| 1094 | .get = ovl_other_xattr_get, | ||
| 1043 | .set = ovl_other_xattr_set, | 1095 | .set = ovl_other_xattr_set, |
| 1044 | }; | 1096 | }; |
| 1045 | 1097 | ||
| 1046 | static const struct xattr_handler *ovl_xattr_handlers[] = { | 1098 | static const struct xattr_handler *ovl_xattr_handlers[] = { |
| 1099 | #ifdef CONFIG_FS_POSIX_ACL | ||
| 1047 | &ovl_posix_acl_access_xattr_handler, | 1100 | &ovl_posix_acl_access_xattr_handler, |
| 1048 | &ovl_posix_acl_default_xattr_handler, | 1101 | &ovl_posix_acl_default_xattr_handler, |
| 1102 | #endif | ||
| 1049 | &ovl_own_xattr_handler, | 1103 | &ovl_own_xattr_handler, |
| 1050 | &ovl_other_xattr_handler, | 1104 | &ovl_other_xattr_handler, |
| 1051 | NULL | 1105 | NULL |
| 1052 | }; | 1106 | }; |
| 1053 | 1107 | ||
| 1054 | static const struct xattr_handler *ovl_xattr_noacl_handlers[] = { | ||
| 1055 | &ovl_own_xattr_handler, | ||
| 1056 | &ovl_other_xattr_handler, | ||
| 1057 | NULL, | ||
| 1058 | }; | ||
| 1059 | |||
| 1060 | static int ovl_fill_super(struct super_block *sb, void *data, int silent) | 1108 | static int ovl_fill_super(struct super_block *sb, void *data, int silent) |
| 1061 | { | 1109 | { |
| 1062 | struct path upperpath = { NULL, NULL }; | 1110 | struct path upperpath = { NULL, NULL }; |
| @@ -1132,7 +1180,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1132 | err = -EINVAL; | 1180 | err = -EINVAL; |
| 1133 | stacklen = ovl_split_lowerdirs(lowertmp); | 1181 | stacklen = ovl_split_lowerdirs(lowertmp); |
| 1134 | if (stacklen > OVL_MAX_STACK) { | 1182 | if (stacklen > OVL_MAX_STACK) { |
| 1135 | pr_err("overlayfs: too many lower directries, limit is %d\n", | 1183 | pr_err("overlayfs: too many lower directories, limit is %d\n", |
| 1136 | OVL_MAX_STACK); | 1184 | OVL_MAX_STACK); |
| 1137 | goto out_free_lowertmp; | 1185 | goto out_free_lowertmp; |
| 1138 | } else if (!ufs->config.upperdir && stacklen == 1) { | 1186 | } else if (!ufs->config.upperdir && stacklen == 1) { |
| @@ -1269,10 +1317,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1269 | 1317 | ||
| 1270 | sb->s_magic = OVERLAYFS_SUPER_MAGIC; | 1318 | sb->s_magic = OVERLAYFS_SUPER_MAGIC; |
| 1271 | sb->s_op = &ovl_super_operations; | 1319 | sb->s_op = &ovl_super_operations; |
| 1272 | if (IS_ENABLED(CONFIG_FS_POSIX_ACL)) | 1320 | sb->s_xattr = ovl_xattr_handlers; |
| 1273 | sb->s_xattr = ovl_xattr_handlers; | ||
| 1274 | else | ||
| 1275 | sb->s_xattr = ovl_xattr_noacl_handlers; | ||
| 1276 | sb->s_root = root_dentry; | 1321 | sb->s_root = root_dentry; |
| 1277 | sb->s_fs_info = ufs; | 1322 | sb->s_fs_info = ufs; |
| 1278 | sb->s_flags |= MS_POSIXACL; | 1323 | sb->s_flags |= MS_POSIXACL; |
diff --git a/fs/proc/base.c b/fs/proc/base.c index 54e270262979..ac0df4dde823 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
| @@ -1556,18 +1556,13 @@ static const struct file_operations proc_pid_set_comm_operations = { | |||
| 1556 | static int proc_exe_link(struct dentry *dentry, struct path *exe_path) | 1556 | static int proc_exe_link(struct dentry *dentry, struct path *exe_path) |
| 1557 | { | 1557 | { |
| 1558 | struct task_struct *task; | 1558 | struct task_struct *task; |
| 1559 | struct mm_struct *mm; | ||
| 1560 | struct file *exe_file; | 1559 | struct file *exe_file; |
| 1561 | 1560 | ||
| 1562 | task = get_proc_task(d_inode(dentry)); | 1561 | task = get_proc_task(d_inode(dentry)); |
| 1563 | if (!task) | 1562 | if (!task) |
| 1564 | return -ENOENT; | 1563 | return -ENOENT; |
| 1565 | mm = get_task_mm(task); | 1564 | exe_file = get_task_exe_file(task); |
| 1566 | put_task_struct(task); | 1565 | put_task_struct(task); |
| 1567 | if (!mm) | ||
| 1568 | return -ENOENT; | ||
| 1569 | exe_file = get_mm_exe_file(mm); | ||
| 1570 | mmput(mm); | ||
| 1571 | if (exe_file) { | 1566 | if (exe_file) { |
| 1572 | *exe_path = exe_file->f_path; | 1567 | *exe_path = exe_file->f_path; |
| 1573 | path_get(&exe_file->f_path); | 1568 | path_get(&exe_file->f_path); |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 187d84ef9de9..f6fa99eca515 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
| @@ -581,6 +581,8 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, | |||
| 581 | mss->anonymous_thp += HPAGE_PMD_SIZE; | 581 | mss->anonymous_thp += HPAGE_PMD_SIZE; |
| 582 | else if (PageSwapBacked(page)) | 582 | else if (PageSwapBacked(page)) |
| 583 | mss->shmem_thp += HPAGE_PMD_SIZE; | 583 | mss->shmem_thp += HPAGE_PMD_SIZE; |
| 584 | else if (is_zone_device_page(page)) | ||
| 585 | /* pass */; | ||
| 584 | else | 586 | else |
| 585 | VM_BUG_ON_PAGE(1, page); | 587 | VM_BUG_ON_PAGE(1, page); |
| 586 | smaps_account(mss, page, true, pmd_young(*pmd), pmd_dirty(*pmd)); | 588 | smaps_account(mss, page, true, pmd_young(*pmd), pmd_dirty(*pmd)); |
diff --git a/fs/seq_file.c b/fs/seq_file.c index 19f532e7d35e..6dc4296eed62 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
| @@ -223,8 +223,10 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) | |||
| 223 | size -= n; | 223 | size -= n; |
| 224 | buf += n; | 224 | buf += n; |
| 225 | copied += n; | 225 | copied += n; |
| 226 | if (!m->count) | 226 | if (!m->count) { |
| 227 | m->from = 0; | ||
| 227 | m->index++; | 228 | m->index++; |
| 229 | } | ||
| 228 | if (!size) | 230 | if (!size) |
| 229 | goto Done; | 231 | goto Done; |
| 230 | } | 232 | } |
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index f35523d4fa3a..b803213d1307 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
| @@ -114,9 +114,15 @@ static ssize_t sysfs_kf_read(struct kernfs_open_file *of, char *buf, | |||
| 114 | * If buf != of->prealloc_buf, we don't know how | 114 | * If buf != of->prealloc_buf, we don't know how |
| 115 | * large it is, so cannot safely pass it to ->show | 115 | * large it is, so cannot safely pass it to ->show |
| 116 | */ | 116 | */ |
| 117 | if (pos || WARN_ON_ONCE(buf != of->prealloc_buf)) | 117 | if (WARN_ON_ONCE(buf != of->prealloc_buf)) |
| 118 | return 0; | 118 | return 0; |
| 119 | len = ops->show(kobj, of->kn->priv, buf); | 119 | len = ops->show(kobj, of->kn->priv, buf); |
| 120 | if (pos) { | ||
| 121 | if (len <= pos) | ||
| 122 | return 0; | ||
| 123 | len -= pos; | ||
| 124 | memmove(buf, buf + pos, len); | ||
| 125 | } | ||
| 120 | return min(count, len); | 126 | return min(count, len); |
| 121 | } | 127 | } |
| 122 | 128 | ||
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c index b45345d701e7..51157da3f76e 100644 --- a/fs/ubifs/tnc_commit.c +++ b/fs/ubifs/tnc_commit.c | |||
| @@ -370,7 +370,7 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt) | |||
| 370 | 370 | ||
| 371 | p = c->gap_lebs; | 371 | p = c->gap_lebs; |
| 372 | do { | 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 | written = layout_leb_in_gaps(c, p); | 374 | written = layout_leb_in_gaps(c, p); |
| 375 | if (written < 0) { | 375 | if (written < 0) { |
| 376 | err = written; | 376 | err = written; |
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c index e237811f09ce..11a004114eba 100644 --- a/fs/ubifs/xattr.c +++ b/fs/ubifs/xattr.c | |||
| @@ -575,7 +575,8 @@ static int ubifs_xattr_get(const struct xattr_handler *handler, | |||
| 575 | dbg_gen("xattr '%s', ino %lu ('%pd'), buf size %zd", name, | 575 | dbg_gen("xattr '%s', ino %lu ('%pd'), buf size %zd", name, |
| 576 | inode->i_ino, dentry, size); | 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 | static int ubifs_xattr_set(const struct xattr_handler *handler, | 582 | static int ubifs_xattr_set(const struct xattr_handler *handler, |
| @@ -586,6 +587,8 @@ static int ubifs_xattr_set(const struct xattr_handler *handler, | |||
| 586 | dbg_gen("xattr '%s', host ino %lu ('%pd'), size %zd", | 587 | dbg_gen("xattr '%s', host ino %lu ('%pd'), size %zd", |
| 587 | name, inode->i_ino, dentry, size); | 588 | name, inode->i_ino, dentry, size); |
| 588 | 589 | ||
| 590 | name = xattr_full_name(handler, name); | ||
| 591 | |||
| 589 | if (value) | 592 | if (value) |
| 590 | return __ubifs_setxattr(inode, name, value, size, flags); | 593 | return __ubifs_setxattr(inode, name, value, size, flags); |
| 591 | else | 594 | else |
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 3dd8f1d54498..05b5243d89f6 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c | |||
| @@ -2278,6 +2278,8 @@ xfs_alloc_log_agf( | |||
| 2278 | offsetof(xfs_agf_t, agf_btreeblks), | 2278 | offsetof(xfs_agf_t, agf_btreeblks), |
| 2279 | offsetof(xfs_agf_t, agf_uuid), | 2279 | offsetof(xfs_agf_t, agf_uuid), |
| 2280 | offsetof(xfs_agf_t, agf_rmap_blocks), | 2280 | offsetof(xfs_agf_t, agf_rmap_blocks), |
| 2281 | /* needed so that we don't log the whole rest of the structure: */ | ||
| 2282 | offsetof(xfs_agf_t, agf_spare64), | ||
| 2281 | sizeof(xfs_agf_t) | 2283 | sizeof(xfs_agf_t) |
| 2282 | }; | 2284 | }; |
| 2283 | 2285 | ||
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index b5c213a051cd..08569792fe20 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c | |||
| @@ -1814,6 +1814,10 @@ xfs_btree_lookup( | |||
| 1814 | 1814 | ||
| 1815 | XFS_BTREE_STATS_INC(cur, lookup); | 1815 | XFS_BTREE_STATS_INC(cur, lookup); |
| 1816 | 1816 | ||
| 1817 | /* No such thing as a zero-level tree. */ | ||
| 1818 | if (cur->bc_nlevels == 0) | ||
| 1819 | return -EFSCORRUPTED; | ||
| 1820 | |||
| 1817 | block = NULL; | 1821 | block = NULL; |
| 1818 | keyno = 0; | 1822 | keyno = 0; |
| 1819 | 1823 | ||
| @@ -4554,15 +4558,22 @@ xfs_btree_simple_query_range( | |||
| 4554 | if (error) | 4558 | if (error) |
| 4555 | goto out; | 4559 | goto out; |
| 4556 | 4560 | ||
| 4561 | /* Nothing? See if there's anything to the right. */ | ||
| 4562 | if (!stat) { | ||
| 4563 | error = xfs_btree_increment(cur, 0, &stat); | ||
| 4564 | if (error) | ||
| 4565 | goto out; | ||
| 4566 | } | ||
| 4567 | |||
| 4557 | while (stat) { | 4568 | while (stat) { |
| 4558 | /* Find the record. */ | 4569 | /* Find the record. */ |
| 4559 | error = xfs_btree_get_rec(cur, &recp, &stat); | 4570 | error = xfs_btree_get_rec(cur, &recp, &stat); |
| 4560 | if (error || !stat) | 4571 | if (error || !stat) |
| 4561 | break; | 4572 | break; |
| 4562 | cur->bc_ops->init_high_key_from_rec(&rec_key, recp); | ||
| 4563 | 4573 | ||
| 4564 | /* Skip if high_key(rec) < low_key. */ | 4574 | /* Skip if high_key(rec) < low_key. */ |
| 4565 | if (firstrec) { | 4575 | if (firstrec) { |
| 4576 | cur->bc_ops->init_high_key_from_rec(&rec_key, recp); | ||
| 4566 | firstrec = false; | 4577 | firstrec = false; |
| 4567 | diff = cur->bc_ops->diff_two_keys(cur, low_key, | 4578 | diff = cur->bc_ops->diff_two_keys(cur, low_key, |
| 4568 | &rec_key); | 4579 | &rec_key); |
| @@ -4571,6 +4582,7 @@ xfs_btree_simple_query_range( | |||
| 4571 | } | 4582 | } |
| 4572 | 4583 | ||
| 4573 | /* Stop if high_key < low_key(rec). */ | 4584 | /* Stop if high_key < low_key(rec). */ |
| 4585 | cur->bc_ops->init_key_from_rec(&rec_key, recp); | ||
| 4574 | diff = cur->bc_ops->diff_two_keys(cur, &rec_key, high_key); | 4586 | diff = cur->bc_ops->diff_two_keys(cur, &rec_key, high_key); |
| 4575 | if (diff > 0) | 4587 | if (diff > 0) |
| 4576 | break; | 4588 | break; |
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 054a2032fdb3..c221d0ecd52e 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c | |||
| @@ -194,7 +194,7 @@ xfs_defer_trans_abort( | |||
| 194 | /* Abort intent items. */ | 194 | /* Abort intent items. */ |
| 195 | list_for_each_entry(dfp, &dop->dop_pending, dfp_list) { | 195 | list_for_each_entry(dfp, &dop->dop_pending, dfp_list) { |
| 196 | trace_xfs_defer_pending_abort(tp->t_mountp, dfp); | 196 | trace_xfs_defer_pending_abort(tp->t_mountp, dfp); |
| 197 | if (dfp->dfp_committed) | 197 | if (!dfp->dfp_done) |
| 198 | dfp->dfp_type->abort_intent(dfp->dfp_intent); | 198 | dfp->dfp_type->abort_intent(dfp->dfp_intent); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| @@ -290,7 +290,6 @@ xfs_defer_finish( | |||
| 290 | struct xfs_defer_pending *dfp; | 290 | struct xfs_defer_pending *dfp; |
| 291 | struct list_head *li; | 291 | struct list_head *li; |
| 292 | struct list_head *n; | 292 | struct list_head *n; |
| 293 | void *done_item = NULL; | ||
| 294 | void *state; | 293 | void *state; |
| 295 | int error = 0; | 294 | int error = 0; |
| 296 | void (*cleanup_fn)(struct xfs_trans *, void *, int); | 295 | void (*cleanup_fn)(struct xfs_trans *, void *, int); |
| @@ -309,19 +308,11 @@ xfs_defer_finish( | |||
| 309 | if (error) | 308 | if (error) |
| 310 | goto out; | 309 | goto out; |
| 311 | 310 | ||
| 312 | /* Mark all pending intents as committed. */ | ||
| 313 | list_for_each_entry_reverse(dfp, &dop->dop_pending, dfp_list) { | ||
| 314 | if (dfp->dfp_committed) | ||
| 315 | break; | ||
| 316 | trace_xfs_defer_pending_commit((*tp)->t_mountp, dfp); | ||
| 317 | dfp->dfp_committed = true; | ||
| 318 | } | ||
| 319 | |||
| 320 | /* Log an intent-done item for the first pending item. */ | 311 | /* Log an intent-done item for the first pending item. */ |
| 321 | dfp = list_first_entry(&dop->dop_pending, | 312 | dfp = list_first_entry(&dop->dop_pending, |
| 322 | struct xfs_defer_pending, dfp_list); | 313 | struct xfs_defer_pending, dfp_list); |
| 323 | trace_xfs_defer_pending_finish((*tp)->t_mountp, dfp); | 314 | trace_xfs_defer_pending_finish((*tp)->t_mountp, dfp); |
| 324 | done_item = dfp->dfp_type->create_done(*tp, dfp->dfp_intent, | 315 | dfp->dfp_done = dfp->dfp_type->create_done(*tp, dfp->dfp_intent, |
| 325 | dfp->dfp_count); | 316 | dfp->dfp_count); |
| 326 | cleanup_fn = dfp->dfp_type->finish_cleanup; | 317 | cleanup_fn = dfp->dfp_type->finish_cleanup; |
| 327 | 318 | ||
| @@ -331,7 +322,7 @@ xfs_defer_finish( | |||
| 331 | list_del(li); | 322 | list_del(li); |
| 332 | dfp->dfp_count--; | 323 | dfp->dfp_count--; |
| 333 | error = dfp->dfp_type->finish_item(*tp, dop, li, | 324 | error = dfp->dfp_type->finish_item(*tp, dop, li, |
| 334 | done_item, &state); | 325 | dfp->dfp_done, &state); |
| 335 | if (error) { | 326 | if (error) { |
| 336 | /* | 327 | /* |
| 337 | * Clean up after ourselves and jump out. | 328 | * Clean up after ourselves and jump out. |
| @@ -428,8 +419,8 @@ xfs_defer_add( | |||
| 428 | dfp = kmem_alloc(sizeof(struct xfs_defer_pending), | 419 | dfp = kmem_alloc(sizeof(struct xfs_defer_pending), |
| 429 | KM_SLEEP | KM_NOFS); | 420 | KM_SLEEP | KM_NOFS); |
| 430 | dfp->dfp_type = defer_op_types[type]; | 421 | dfp->dfp_type = defer_op_types[type]; |
| 431 | dfp->dfp_committed = false; | ||
| 432 | dfp->dfp_intent = NULL; | 422 | dfp->dfp_intent = NULL; |
| 423 | dfp->dfp_done = NULL; | ||
| 433 | dfp->dfp_count = 0; | 424 | dfp->dfp_count = 0; |
| 434 | INIT_LIST_HEAD(&dfp->dfp_work); | 425 | INIT_LIST_HEAD(&dfp->dfp_work); |
| 435 | list_add_tail(&dfp->dfp_list, &dop->dop_intake); | 426 | list_add_tail(&dfp->dfp_list, &dop->dop_intake); |
diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index cc3981c48296..e96533d178cf 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h | |||
| @@ -30,8 +30,8 @@ struct xfs_defer_op_type; | |||
| 30 | struct xfs_defer_pending { | 30 | struct xfs_defer_pending { |
| 31 | const struct xfs_defer_op_type *dfp_type; /* function pointers */ | 31 | const struct xfs_defer_op_type *dfp_type; /* function pointers */ |
| 32 | struct list_head dfp_list; /* pending items */ | 32 | struct list_head dfp_list; /* pending items */ |
| 33 | bool dfp_committed; /* committed trans? */ | ||
| 34 | void *dfp_intent; /* log intent item */ | 33 | void *dfp_intent; /* log intent item */ |
| 34 | void *dfp_done; /* log done item */ | ||
| 35 | struct list_head dfp_work; /* work items */ | 35 | struct list_head dfp_work; /* work items */ |
| 36 | unsigned int dfp_count; /* # extent items */ | 36 | unsigned int dfp_count; /* # extent items */ |
| 37 | }; | 37 | }; |
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index e6a8bea0f7ba..270fb5cf4fa1 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h | |||
| @@ -674,7 +674,8 @@ typedef struct xfs_agf { | |||
| 674 | #define XFS_AGF_BTREEBLKS 0x00000800 | 674 | #define XFS_AGF_BTREEBLKS 0x00000800 |
| 675 | #define XFS_AGF_UUID 0x00001000 | 675 | #define XFS_AGF_UUID 0x00001000 |
| 676 | #define XFS_AGF_RMAP_BLOCKS 0x00002000 | 676 | #define XFS_AGF_RMAP_BLOCKS 0x00002000 |
| 677 | #define XFS_AGF_NUM_BITS 14 | 677 | #define XFS_AGF_SPARE64 0x00004000 |
| 678 | #define XFS_AGF_NUM_BITS 15 | ||
| 678 | #define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1) | 679 | #define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1) |
| 679 | 680 | ||
| 680 | #define XFS_AGF_FLAGS \ | 681 | #define XFS_AGF_FLAGS \ |
| @@ -691,7 +692,8 @@ typedef struct xfs_agf { | |||
| 691 | { XFS_AGF_LONGEST, "LONGEST" }, \ | 692 | { XFS_AGF_LONGEST, "LONGEST" }, \ |
| 692 | { XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \ | 693 | { XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \ |
| 693 | { XFS_AGF_UUID, "UUID" }, \ | 694 | { XFS_AGF_UUID, "UUID" }, \ |
| 694 | { XFS_AGF_RMAP_BLOCKS, "RMAP_BLOCKS" } | 695 | { XFS_AGF_RMAP_BLOCKS, "RMAP_BLOCKS" }, \ |
| 696 | { XFS_AGF_SPARE64, "SPARE64" } | ||
| 695 | 697 | ||
| 696 | /* disk block (xfs_daddr_t) in the AG */ | 698 | /* disk block (xfs_daddr_t) in the AG */ |
| 697 | #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) | 699 | #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) |
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 0e3d4f5ec33c..4aecc5fefe96 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c | |||
| @@ -583,7 +583,8 @@ xfs_sb_verify( | |||
| 583 | * Only check the in progress field for the primary superblock as | 583 | * Only check the in progress field for the primary superblock as |
| 584 | * mkfs.xfs doesn't clear it from secondary superblocks. | 584 | * mkfs.xfs doesn't clear it from secondary superblocks. |
| 585 | */ | 585 | */ |
| 586 | return xfs_mount_validate_sb(mp, &sb, bp->b_bn == XFS_SB_DADDR, | 586 | return xfs_mount_validate_sb(mp, &sb, |
| 587 | bp->b_maps[0].bm_bn == XFS_SB_DADDR, | ||
| 587 | check_version); | 588 | check_version); |
| 588 | } | 589 | } |
| 589 | 590 | ||
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 607cc29bba21..b5b9bffe3520 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c | |||
| @@ -1611,7 +1611,7 @@ xfs_wait_buftarg( | |||
| 1611 | */ | 1611 | */ |
| 1612 | while (percpu_counter_sum(&btp->bt_io_count)) | 1612 | while (percpu_counter_sum(&btp->bt_io_count)) |
| 1613 | delay(100); | 1613 | delay(100); |
| 1614 | drain_workqueue(btp->bt_mount->m_buf_workqueue); | 1614 | flush_workqueue(btp->bt_mount->m_buf_workqueue); |
| 1615 | 1615 | ||
| 1616 | /* loop until there is nothing left on the lru list. */ | 1616 | /* loop until there is nothing left on the lru list. */ |
| 1617 | while (list_lru_count(&btp->bt_lru)) { | 1617 | while (list_lru_count(&btp->bt_lru)) { |
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 24ef83ef04de..fd6be45b3a1e 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
| @@ -1574,9 +1574,16 @@ xfs_fs_fill_super( | |||
| 1574 | } | 1574 | } |
| 1575 | } | 1575 | } |
| 1576 | 1576 | ||
| 1577 | if (xfs_sb_version_hasrmapbt(&mp->m_sb)) | 1577 | if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { |
| 1578 | if (mp->m_sb.sb_rblocks) { | ||
| 1579 | xfs_alert(mp, | ||
| 1580 | "EXPERIMENTAL reverse mapping btree not compatible with realtime device!"); | ||
| 1581 | error = -EINVAL; | ||
| 1582 | goto out_filestream_unmount; | ||
| 1583 | } | ||
| 1578 | xfs_alert(mp, | 1584 | xfs_alert(mp, |
| 1579 | "EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!"); | 1585 | "EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!"); |
| 1586 | } | ||
| 1580 | 1587 | ||
| 1581 | error = xfs_mountfs(mp); | 1588 | error = xfs_mountfs(mp); |
| 1582 | if (error) | 1589 | if (error) |
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 7e88bec3f359..d303a665dba9 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h | |||
| @@ -2295,7 +2295,7 @@ DECLARE_EVENT_CLASS(xfs_defer_pending_class, | |||
| 2295 | __entry->dev = mp ? mp->m_super->s_dev : 0; | 2295 | __entry->dev = mp ? mp->m_super->s_dev : 0; |
| 2296 | __entry->type = dfp->dfp_type->type; | 2296 | __entry->type = dfp->dfp_type->type; |
| 2297 | __entry->intent = dfp->dfp_intent; | 2297 | __entry->intent = dfp->dfp_intent; |
| 2298 | __entry->committed = dfp->dfp_committed; | 2298 | __entry->committed = dfp->dfp_done != NULL; |
| 2299 | __entry->nr = dfp->dfp_count; | 2299 | __entry->nr = dfp->dfp_count; |
| 2300 | ), | 2300 | ), |
| 2301 | TP_printk("dev %d:%d optype %d intent %p committed %d nr %d\n", | 2301 | TP_printk("dev %d:%d optype %d intent %p committed %d nr %d\n", |
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index 1bfa602958f2..6df9b0749671 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h | |||
| @@ -72,6 +72,7 @@ struct exception_table_entry | |||
| 72 | /* Returns 0 if exception not found and fixup otherwise. */ | 72 | /* Returns 0 if exception not found and fixup otherwise. */ |
| 73 | extern unsigned long search_exception_table(unsigned long); | 73 | extern unsigned long search_exception_table(unsigned long); |
| 74 | 74 | ||
| 75 | |||
| 75 | /* | 76 | /* |
| 76 | * architectures with an MMU should override these two | 77 | * architectures with an MMU should override these two |
| 77 | */ | 78 | */ |
| @@ -230,14 +231,18 @@ extern int __put_user_bad(void) __attribute__((noreturn)); | |||
| 230 | might_fault(); \ | 231 | might_fault(); \ |
| 231 | access_ok(VERIFY_READ, __p, sizeof(*ptr)) ? \ | 232 | access_ok(VERIFY_READ, __p, sizeof(*ptr)) ? \ |
| 232 | __get_user((x), (__typeof__(*(ptr)) *)__p) : \ | 233 | __get_user((x), (__typeof__(*(ptr)) *)__p) : \ |
| 233 | -EFAULT; \ | 234 | ((x) = (__typeof__(*(ptr)))0,-EFAULT); \ |
| 234 | }) | 235 | }) |
| 235 | 236 | ||
| 236 | #ifndef __get_user_fn | 237 | #ifndef __get_user_fn |
| 237 | static inline int __get_user_fn(size_t size, const void __user *ptr, void *x) | 238 | static inline int __get_user_fn(size_t size, const void __user *ptr, void *x) |
| 238 | { | 239 | { |
| 239 | size = __copy_from_user(x, ptr, size); | 240 | size_t n = __copy_from_user(x, ptr, size); |
| 240 | return size ? -EFAULT : size; | 241 | if (unlikely(n)) { |
| 242 | memset(x + (size - n), 0, n); | ||
| 243 | return -EFAULT; | ||
| 244 | } | ||
| 245 | return 0; | ||
| 241 | } | 246 | } |
| 242 | 247 | ||
| 243 | #define __get_user_fn(sz, u, k) __get_user_fn(sz, u, k) | 248 | #define __get_user_fn(sz, u, k) __get_user_fn(sz, u, k) |
| @@ -257,11 +262,13 @@ extern int __get_user_bad(void) __attribute__((noreturn)); | |||
| 257 | static inline long copy_from_user(void *to, | 262 | static inline long copy_from_user(void *to, |
| 258 | const void __user * from, unsigned long n) | 263 | const void __user * from, unsigned long n) |
| 259 | { | 264 | { |
| 265 | unsigned long res = n; | ||
| 260 | might_fault(); | 266 | might_fault(); |
| 261 | if (access_ok(VERIFY_READ, from, n)) | 267 | if (likely(access_ok(VERIFY_READ, from, n))) |
| 262 | return __copy_from_user(to, from, n); | 268 | res = __copy_from_user(to, from, n); |
| 263 | else | 269 | if (unlikely(res)) |
| 264 | return n; | 270 | memset(to + (n - res), 0, res); |
| 271 | return res; | ||
| 265 | } | 272 | } |
| 266 | 273 | ||
| 267 | static inline long copy_to_user(void __user *to, | 274 | static inline long copy_to_user(void __user *to, |
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 4d8452c2384b..c5eaf2f80a4c 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
| @@ -1056,7 +1056,7 @@ static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev, | |||
| 1056 | return NULL; | 1056 | return NULL; |
| 1057 | } | 1057 | } |
| 1058 | 1058 | ||
| 1059 | #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, validate, data, fn) \ | 1059 | #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \ |
| 1060 | static const void * __acpi_table_##name[] \ | 1060 | static const void * __acpi_table_##name[] \ |
| 1061 | __attribute__((unused)) \ | 1061 | __attribute__((unused)) \ |
| 1062 | = { (void *) table_id, \ | 1062 | = { (void *) table_id, \ |
diff --git a/include/linux/bio.h b/include/linux/bio.h index 59ffaa68b11b..23ddf4b46a9b 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
| @@ -71,7 +71,8 @@ static inline bool bio_has_data(struct bio *bio) | |||
| 71 | { | 71 | { |
| 72 | if (bio && | 72 | if (bio && |
| 73 | bio->bi_iter.bi_size && | 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 | return true; | 76 | return true; |
| 76 | 77 | ||
| 77 | return false; | 78 | return false; |
| @@ -79,7 +80,9 @@ static inline bool bio_has_data(struct bio *bio) | |||
| 79 | 80 | ||
| 80 | static inline bool bio_no_advance_iter(struct bio *bio) | 81 | static inline bool bio_no_advance_iter(struct bio *bio) |
| 81 | { | 82 | { |
| 82 | return bio_op(bio) == REQ_OP_DISCARD || bio_op(bio) == REQ_OP_WRITE_SAME; | 83 | return bio_op(bio) == REQ_OP_DISCARD || |
| 84 | bio_op(bio) == REQ_OP_SECURE_ERASE || | ||
| 85 | bio_op(bio) == REQ_OP_WRITE_SAME; | ||
| 83 | } | 86 | } |
| 84 | 87 | ||
| 85 | static inline bool bio_is_rw(struct bio *bio) | 88 | static inline bool bio_is_rw(struct bio *bio) |
| @@ -199,6 +202,9 @@ static inline unsigned bio_segments(struct bio *bio) | |||
| 199 | if (bio_op(bio) == REQ_OP_DISCARD) | 202 | if (bio_op(bio) == REQ_OP_DISCARD) |
| 200 | return 1; | 203 | return 1; |
| 201 | 204 | ||
| 205 | if (bio_op(bio) == REQ_OP_SECURE_ERASE) | ||
| 206 | return 1; | ||
| 207 | |||
| 202 | if (bio_op(bio) == REQ_OP_WRITE_SAME) | 208 | if (bio_op(bio) == REQ_OP_WRITE_SAME) |
| 203 | return 1; | 209 | return 1; |
| 204 | 210 | ||
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 2c210b6a7bcf..e79055c8b577 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
| @@ -882,7 +882,7 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq) | |||
| 882 | static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, | 882 | static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, |
| 883 | int op) | 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 | return min(q->limits.max_discard_sectors, UINT_MAX >> 9); | 886 | return min(q->limits.max_discard_sectors, UINT_MAX >> 9); |
| 887 | 887 | ||
| 888 | if (unlikely(op == REQ_OP_WRITE_SAME)) | 888 | if (unlikely(op == REQ_OP_WRITE_SAME)) |
| @@ -913,7 +913,9 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq, | |||
| 913 | if (unlikely(rq->cmd_type != REQ_TYPE_FS)) | 913 | if (unlikely(rq->cmd_type != REQ_TYPE_FS)) |
| 914 | return q->limits.max_hw_sectors; | 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 | return blk_queue_get_max_sectors(q, req_op(rq)); | 919 | return blk_queue_get_max_sectors(q, req_op(rq)); |
| 918 | 920 | ||
| 919 | return min(blk_max_size_offset(q, offset), | 921 | return min(blk_max_size_offset(q, offset), |
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index e2949397c19b..573c5a18908f 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h | |||
| @@ -158,7 +158,7 @@ | |||
| 158 | #define __compiler_offsetof(a, b) \ | 158 | #define __compiler_offsetof(a, b) \ |
| 159 | __builtin_offsetof(a, b) | 159 | __builtin_offsetof(a, b) |
| 160 | 160 | ||
| 161 | #if GCC_VERSION >= 40100 && GCC_VERSION < 40600 | 161 | #if GCC_VERSION >= 40100 |
| 162 | # define __compiletime_object_size(obj) __builtin_object_size(obj, 0) | 162 | # define __compiletime_object_size(obj) __builtin_object_size(obj, 0) |
| 163 | #endif | 163 | #endif |
| 164 | 164 | ||
| @@ -242,7 +242,11 @@ | |||
| 242 | */ | 242 | */ |
| 243 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0) | 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 | #if GCC_VERSION >= 40400 | 250 | #if GCC_VERSION >= 40400 |
| 247 | #define __HAVE_BUILTIN_BSWAP32__ | 251 | #define __HAVE_BUILTIN_BSWAP32__ |
| 248 | #define __HAVE_BUILTIN_BSWAP64__ | 252 | #define __HAVE_BUILTIN_BSWAP64__ |
| @@ -250,7 +254,7 @@ | |||
| 250 | #if GCC_VERSION >= 40800 | 254 | #if GCC_VERSION >= 40800 |
| 251 | #define __HAVE_BUILTIN_BSWAP16__ | 255 | #define __HAVE_BUILTIN_BSWAP16__ |
| 252 | #endif | 256 | #endif |
| 253 | #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ | 257 | #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP && !__CHECKER__ */ |
| 254 | 258 | ||
| 255 | #if GCC_VERSION >= 50000 | 259 | #if GCC_VERSION >= 50000 |
| 256 | #define KASAN_ABI_VERSION 4 | 260 | #define KASAN_ABI_VERSION 4 |
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 436aa4e42221..668569844d37 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
| @@ -527,13 +527,14 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s | |||
| 527 | * object's lifetime is managed by something other than RCU. That | 527 | * object's lifetime is managed by something other than RCU. That |
| 528 | * "something other" might be reference counting or simple immortality. | 528 | * "something other" might be reference counting or simple immortality. |
| 529 | * | 529 | * |
| 530 | * The seemingly unused size_t variable is to validate @p is indeed a pointer | 530 | * The seemingly unused variable ___typecheck_p validates that @p is |
| 531 | * type by making sure it can be dereferenced. | 531 | * indeed a pointer type by using a pointer to typeof(*p) as the type. |
| 532 | * Taking a pointer to typeof(*p) again is needed in case p is void *. | ||
| 532 | */ | 533 | */ |
| 533 | #define lockless_dereference(p) \ | 534 | #define lockless_dereference(p) \ |
| 534 | ({ \ | 535 | ({ \ |
| 535 | typeof(p) _________p1 = READ_ONCE(p); \ | 536 | typeof(p) _________p1 = READ_ONCE(p); \ |
| 536 | size_t __maybe_unused __size_of_ptr = sizeof(*(p)); \ | 537 | typeof(*(p)) *___typecheck_p __maybe_unused; \ |
| 537 | smp_read_barrier_depends(); /* Dependency order vs. p above. */ \ | 538 | smp_read_barrier_depends(); /* Dependency order vs. p above. */ \ |
| 538 | (_________p1); \ | 539 | (_________p1); \ |
| 539 | }) | 540 | }) |
diff --git a/include/linux/efi.h b/include/linux/efi.h index 7f5a58225385..0148a3046b48 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h | |||
| @@ -118,6 +118,15 @@ typedef struct { | |||
| 118 | u32 imagesize; | 118 | u32 imagesize; |
| 119 | } efi_capsule_header_t; | 119 | } efi_capsule_header_t; |
| 120 | 120 | ||
| 121 | struct efi_boot_memmap { | ||
| 122 | efi_memory_desc_t **map; | ||
| 123 | unsigned long *map_size; | ||
| 124 | unsigned long *desc_size; | ||
| 125 | u32 *desc_ver; | ||
| 126 | unsigned long *key_ptr; | ||
| 127 | unsigned long *buff_size; | ||
| 128 | }; | ||
| 129 | |||
| 121 | /* | 130 | /* |
| 122 | * EFI capsule flags | 131 | * EFI capsule flags |
| 123 | */ | 132 | */ |
| @@ -946,7 +955,7 @@ extern int efi_memattr_apply_permissions(struct mm_struct *mm, | |||
| 946 | /* Iterate through an efi_memory_map */ | 955 | /* Iterate through an efi_memory_map */ |
| 947 | #define for_each_efi_memory_desc_in_map(m, md) \ | 956 | #define for_each_efi_memory_desc_in_map(m, md) \ |
| 948 | for ((md) = (m)->map; \ | 957 | for ((md) = (m)->map; \ |
| 949 | ((void *)(md) + (m)->desc_size) <= (m)->map_end; \ | 958 | (md) && ((void *)(md) + (m)->desc_size) <= (m)->map_end; \ |
| 950 | (md) = (void *)(md) + (m)->desc_size) | 959 | (md) = (void *)(md) + (m)->desc_size) |
| 951 | 960 | ||
| 952 | /** | 961 | /** |
| @@ -1371,11 +1380,7 @@ char *efi_convert_cmdline(efi_system_table_t *sys_table_arg, | |||
| 1371 | efi_loaded_image_t *image, int *cmd_line_len); | 1380 | efi_loaded_image_t *image, int *cmd_line_len); |
| 1372 | 1381 | ||
| 1373 | efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, | 1382 | efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, |
| 1374 | efi_memory_desc_t **map, | 1383 | struct efi_boot_memmap *map); |
| 1375 | unsigned long *map_size, | ||
| 1376 | unsigned long *desc_size, | ||
| 1377 | u32 *desc_ver, | ||
| 1378 | unsigned long *key_ptr); | ||
| 1379 | 1384 | ||
| 1380 | efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, | 1385 | efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, |
| 1381 | unsigned long size, unsigned long align, | 1386 | unsigned long size, unsigned long align, |
| @@ -1457,4 +1462,14 @@ extern void efi_call_virt_check_flags(unsigned long flags, const char *call); | |||
| 1457 | arch_efi_call_virt_teardown(); \ | 1462 | arch_efi_call_virt_teardown(); \ |
| 1458 | }) | 1463 | }) |
| 1459 | 1464 | ||
| 1465 | typedef efi_status_t (*efi_exit_boot_map_processing)( | ||
| 1466 | efi_system_table_t *sys_table_arg, | ||
| 1467 | struct efi_boot_memmap *map, | ||
| 1468 | void *priv); | ||
| 1469 | |||
| 1470 | efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table, | ||
| 1471 | void *handle, | ||
| 1472 | struct efi_boot_memmap *map, | ||
| 1473 | void *priv, | ||
| 1474 | efi_exit_boot_map_processing priv_func); | ||
| 1460 | #endif /* _LINUX_EFI_H */ | 1475 | #endif /* _LINUX_EFI_H */ |
diff --git a/include/linux/fence.h b/include/linux/fence.h index 8cc719a63728..2ac6fa5f4712 100644 --- a/include/linux/fence.h +++ b/include/linux/fence.h | |||
| @@ -49,8 +49,6 @@ struct fence_cb; | |||
| 49 | * @timestamp: Timestamp when the fence was signaled. | 49 | * @timestamp: Timestamp when the fence was signaled. |
| 50 | * @status: Optional, only valid if < 0, must be set before calling | 50 | * @status: Optional, only valid if < 0, must be set before calling |
| 51 | * fence_signal, indicates that the fence has completed with an error. | 51 | * fence_signal, indicates that the fence has completed with an error. |
| 52 | * @child_list: list of children fences | ||
| 53 | * @active_list: list of active fences | ||
| 54 | * | 52 | * |
| 55 | * the flags member must be manipulated and read using the appropriate | 53 | * the flags member must be manipulated and read using the appropriate |
| 56 | * atomic ops (bit_*), so taking the spinlock will not be needed most | 54 | * atomic ops (bit_*), so taking the spinlock will not be needed most |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 3523bf62f328..901e25d495cc 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
| @@ -574,6 +574,7 @@ static inline void mapping_allow_writable(struct address_space *mapping) | |||
| 574 | 574 | ||
| 575 | struct posix_acl; | 575 | struct posix_acl; |
| 576 | #define ACL_NOT_CACHED ((void *)(-1)) | 576 | #define ACL_NOT_CACHED ((void *)(-1)) |
| 577 | #define ACL_DONT_CACHE ((void *)(-3)) | ||
| 577 | 578 | ||
| 578 | static inline struct posix_acl * | 579 | static inline struct posix_acl * |
| 579 | uncached_acl_sentinel(struct task_struct *task) | 580 | uncached_acl_sentinel(struct task_struct *task) |
diff --git a/include/linux/fscrypto.h b/include/linux/fscrypto.h index cfa6cde25f8e..76cff18bb032 100644 --- a/include/linux/fscrypto.h +++ b/include/linux/fscrypto.h | |||
| @@ -274,8 +274,7 @@ extern void fscrypt_restore_control_page(struct page *); | |||
| 274 | extern int fscrypt_zeroout_range(struct inode *, pgoff_t, sector_t, | 274 | extern int fscrypt_zeroout_range(struct inode *, pgoff_t, sector_t, |
| 275 | unsigned int); | 275 | unsigned int); |
| 276 | /* policy.c */ | 276 | /* policy.c */ |
| 277 | extern int fscrypt_process_policy(struct inode *, | 277 | extern int fscrypt_process_policy(struct file *, const struct fscrypt_policy *); |
| 278 | const struct fscrypt_policy *); | ||
| 279 | extern int fscrypt_get_policy(struct inode *, struct fscrypt_policy *); | 278 | extern int fscrypt_get_policy(struct inode *, struct fscrypt_policy *); |
| 280 | extern int fscrypt_has_permitted_context(struct inode *, struct inode *); | 279 | extern int fscrypt_has_permitted_context(struct inode *, struct inode *); |
| 281 | extern int fscrypt_inherit_context(struct inode *, struct inode *, | 280 | extern int fscrypt_inherit_context(struct inode *, struct inode *, |
| @@ -345,7 +344,7 @@ static inline int fscrypt_notsupp_zeroout_range(struct inode *i, pgoff_t p, | |||
| 345 | } | 344 | } |
| 346 | 345 | ||
| 347 | /* policy.c */ | 346 | /* policy.c */ |
| 348 | static inline int fscrypt_notsupp_process_policy(struct inode *i, | 347 | static inline int fscrypt_notsupp_process_policy(struct file *f, |
| 349 | const struct fscrypt_policy *p) | 348 | const struct fscrypt_policy *p) |
| 350 | { | 349 | { |
| 351 | return -EOPNOTSUPP; | 350 | return -EOPNOTSUPP; |
diff --git a/include/linux/host1x.h b/include/linux/host1x.h index d2ba7d334039..1ffbf2a8cb99 100644 --- a/include/linux/host1x.h +++ b/include/linux/host1x.h | |||
| @@ -304,6 +304,8 @@ struct tegra_mipi_device; | |||
| 304 | 304 | ||
| 305 | struct tegra_mipi_device *tegra_mipi_request(struct device *device); | 305 | struct tegra_mipi_device *tegra_mipi_request(struct device *device); |
| 306 | void tegra_mipi_free(struct tegra_mipi_device *device); | 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 | int tegra_mipi_calibrate(struct tegra_mipi_device *device); | 309 | int tegra_mipi_calibrate(struct tegra_mipi_device *device); |
| 308 | 310 | ||
| 309 | #endif | 311 | #endif |
diff --git a/include/linux/iio/sw_trigger.h b/include/linux/iio/sw_trigger.h index 5198f8ed08a4..c97eab67558f 100644 --- a/include/linux/iio/sw_trigger.h +++ b/include/linux/iio/sw_trigger.h | |||
| @@ -62,7 +62,7 @@ void iio_swt_group_init_type_name(struct iio_sw_trigger *t, | |||
| 62 | const char *name, | 62 | const char *name, |
| 63 | struct config_item_type *type) | 63 | struct config_item_type *type) |
| 64 | { | 64 | { |
| 65 | #ifdef CONFIG_CONFIGFS_FS | 65 | #if IS_ENABLED(CONFIG_CONFIGFS_FS) |
| 66 | config_group_init_type_name(&t->group, name, type); | 66 | config_group_init_type_name(&t->group, name, type); |
| 67 | #endif | 67 | #endif |
| 68 | } | 68 | } |
diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 3267df461012..3d70ece10313 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h | |||
| @@ -19,6 +19,11 @@ struct vm_fault; | |||
| 19 | #define IOMAP_UNWRITTEN 0x04 /* blocks allocated @blkno in unwritten state */ | 19 | #define IOMAP_UNWRITTEN 0x04 /* blocks allocated @blkno in unwritten state */ |
| 20 | 20 | ||
| 21 | /* | 21 | /* |
| 22 | * Flags for iomap mappings: | ||
| 23 | */ | ||
| 24 | #define IOMAP_F_MERGED 0x01 /* contains multiple blocks/extents */ | ||
| 25 | |||
| 26 | /* | ||
| 22 | * Magic value for blkno: | 27 | * Magic value for blkno: |
| 23 | */ | 28 | */ |
| 24 | #define IOMAP_NULL_BLOCK -1LL /* blkno is not valid */ | 29 | #define IOMAP_NULL_BLOCK -1LL /* blkno is not valid */ |
| @@ -27,7 +32,8 @@ struct iomap { | |||
| 27 | sector_t blkno; /* 1st sector of mapping, 512b units */ | 32 | sector_t blkno; /* 1st sector of mapping, 512b units */ |
| 28 | loff_t offset; /* file offset of mapping, bytes */ | 33 | loff_t offset; /* file offset of mapping, bytes */ |
| 29 | u64 length; /* length of mapping, bytes */ | 34 | u64 length; /* length of mapping, bytes */ |
| 30 | int type; /* type of mapping */ | 35 | u16 type; /* type of mapping */ |
| 36 | u16 flags; /* flags for mapping */ | ||
| 31 | struct block_device *bdev; /* block device for I/O */ | 37 | struct block_device *bdev; /* block device for I/O */ |
| 32 | }; | 38 | }; |
| 33 | 39 | ||
diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index 56b0b7ec66aa..99ac022edc60 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h | |||
| @@ -337,6 +337,7 @@ | |||
| 337 | */ | 337 | */ |
| 338 | #define E_ITS_MOVI_UNMAPPED_INTERRUPT 0x010107 | 338 | #define E_ITS_MOVI_UNMAPPED_INTERRUPT 0x010107 |
| 339 | #define E_ITS_MOVI_UNMAPPED_COLLECTION 0x010109 | 339 | #define E_ITS_MOVI_UNMAPPED_COLLECTION 0x010109 |
| 340 | #define E_ITS_INT_UNMAPPED_INTERRUPT 0x010307 | ||
| 340 | #define E_ITS_CLEAR_UNMAPPED_INTERRUPT 0x010507 | 341 | #define E_ITS_CLEAR_UNMAPPED_INTERRUPT 0x010507 |
| 341 | #define E_ITS_MAPD_DEVICE_OOR 0x010801 | 342 | #define E_ITS_MAPD_DEVICE_OOR 0x010801 |
| 342 | #define E_ITS_MAPC_PROCNUM_OOR 0x010902 | 343 | #define E_ITS_MAPC_PROCNUM_OOR 0x010902 |
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index 4429d255c8ab..5e5b2969d931 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h | |||
| @@ -195,6 +195,7 @@ static inline bool vma_migratable(struct vm_area_struct *vma) | |||
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | extern int mpol_misplaced(struct page *, struct vm_area_struct *, unsigned long); | 197 | extern int mpol_misplaced(struct page *, struct vm_area_struct *, unsigned long); |
| 198 | extern void mpol_put_task_policy(struct task_struct *); | ||
| 198 | 199 | ||
| 199 | #else | 200 | #else |
| 200 | 201 | ||
| @@ -297,5 +298,8 @@ static inline int mpol_misplaced(struct page *page, struct vm_area_struct *vma, | |||
| 297 | return -1; /* no node preference */ | 298 | return -1; /* no node preference */ |
| 298 | } | 299 | } |
| 299 | 300 | ||
| 301 | static inline void mpol_put_task_policy(struct task_struct *task) | ||
| 302 | { | ||
| 303 | } | ||
| 300 | #endif /* CONFIG_NUMA */ | 304 | #endif /* CONFIG_NUMA */ |
| 301 | #endif | 305 | #endif |
diff --git a/include/linux/mfd/da8xx-cfgchip.h b/include/linux/mfd/da8xx-cfgchip.h new file mode 100644 index 000000000000..304985e288d2 --- /dev/null +++ b/include/linux/mfd/da8xx-cfgchip.h | |||
| @@ -0,0 +1,153 @@ | |||
| 1 | /* | ||
| 2 | * TI DaVinci DA8xx CHIPCFGx registers for syscon consumers. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2016 David Lechner <david@lechnology.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef __LINUX_MFD_DA8XX_CFGCHIP_H | ||
| 18 | #define __LINUX_MFD_DA8XX_CFGCHIP_H | ||
| 19 | |||
| 20 | #include <linux/bitops.h> | ||
| 21 | |||
| 22 | /* register offset (32-bit registers) */ | ||
| 23 | #define CFGCHIP(n) ((n) * 4) | ||
| 24 | |||
| 25 | /* CFGCHIP0 (PLL0/EDMA3_0) register bits */ | ||
| 26 | #define CFGCHIP0_PLL_MASTER_LOCK BIT(4) | ||
| 27 | #define CFGCHIP0_EDMA30TC1DBS(n) ((n) << 2) | ||
| 28 | #define CFGCHIP0_EDMA30TC1DBS_MASK CFGCHIP0_EDMA30TC1DBS(0x3) | ||
| 29 | #define CFGCHIP0_EDMA30TC1DBS_16 CFGCHIP0_EDMA30TC1DBS(0x0) | ||
| 30 | #define CFGCHIP0_EDMA30TC1DBS_32 CFGCHIP0_EDMA30TC1DBS(0x1) | ||
| 31 | #define CFGCHIP0_EDMA30TC1DBS_64 CFGCHIP0_EDMA30TC1DBS(0x2) | ||
| 32 | #define CFGCHIP0_EDMA30TC0DBS(n) ((n) << 0) | ||
| 33 | #define CFGCHIP0_EDMA30TC0DBS_MASK CFGCHIP0_EDMA30TC0DBS(0x3) | ||
| 34 | #define CFGCHIP0_EDMA30TC0DBS_16 CFGCHIP0_EDMA30TC0DBS(0x0) | ||
| 35 | #define CFGCHIP0_EDMA30TC0DBS_32 CFGCHIP0_EDMA30TC0DBS(0x1) | ||
| 36 | #define CFGCHIP0_EDMA30TC0DBS_64 CFGCHIP0_EDMA30TC0DBS(0x2) | ||
| 37 | |||
| 38 | /* CFGCHIP1 (eCAP/HPI/EDMA3_1/eHRPWM TBCLK/McASP0 AMUTEIN) register bits */ | ||
| 39 | #define CFGCHIP1_CAP2SRC(n) ((n) << 27) | ||
| 40 | #define CFGCHIP1_CAP2SRC_MASK CFGCHIP1_CAP2SRC(0x1f) | ||
| 41 | #define CFGCHIP1_CAP2SRC_ECAP_PIN CFGCHIP1_CAP2SRC(0x0) | ||
| 42 | #define CFGCHIP1_CAP2SRC_MCASP0_TX CFGCHIP1_CAP2SRC(0x1) | ||
| 43 | #define CFGCHIP1_CAP2SRC_MCASP0_RX CFGCHIP1_CAP2SRC(0x2) | ||
| 44 | #define CFGCHIP1_CAP2SRC_EMAC_C0_RX_THRESHOLD CFGCHIP1_CAP2SRC(0x7) | ||
| 45 | #define CFGCHIP1_CAP2SRC_EMAC_C0_RX CFGCHIP1_CAP2SRC(0x8) | ||
| 46 | #define CFGCHIP1_CAP2SRC_EMAC_C0_TX CFGCHIP1_CAP2SRC(0x9) | ||
| 47 | #define CFGCHIP1_CAP2SRC_EMAC_C0_MISC CFGCHIP1_CAP2SRC(0xa) | ||
| 48 | #define CFGCHIP1_CAP2SRC_EMAC_C1_RX_THRESHOLD CFGCHIP1_CAP2SRC(0xb) | ||
| 49 | #define CFGCHIP1_CAP2SRC_EMAC_C1_RX CFGCHIP1_CAP2SRC(0xc) | ||
| 50 | #define CFGCHIP1_CAP2SRC_EMAC_C1_TX CFGCHIP1_CAP2SRC(0xd) | ||
| 51 | #define CFGCHIP1_CAP2SRC_EMAC_C1_MISC CFGCHIP1_CAP2SRC(0xe) | ||
| 52 | #define CFGCHIP1_CAP2SRC_EMAC_C2_RX_THRESHOLD CFGCHIP1_CAP2SRC(0xf) | ||
| 53 | #define CFGCHIP1_CAP2SRC_EMAC_C2_RX CFGCHIP1_CAP2SRC(0x10) | ||
| 54 | #define CFGCHIP1_CAP2SRC_EMAC_C2_TX CFGCHIP1_CAP2SRC(0x11) | ||
| 55 | #define CFGCHIP1_CAP2SRC_EMAC_C2_MISC CFGCHIP1_CAP2SRC(0x12) | ||
| 56 | #define CFGCHIP1_CAP1SRC(n) ((n) << 22) | ||
| 57 | #define CFGCHIP1_CAP1SRC_MASK CFGCHIP1_CAP1SRC(0x1f) | ||
| 58 | #define CFGCHIP1_CAP1SRC_ECAP_PIN CFGCHIP1_CAP1SRC(0x0) | ||
| 59 | #define CFGCHIP1_CAP1SRC_MCASP0_TX CFGCHIP1_CAP1SRC(0x1) | ||
| 60 | #define CFGCHIP1_CAP1SRC_MCASP0_RX CFGCHIP1_CAP1SRC(0x2) | ||
| 61 | #define CFGCHIP1_CAP1SRC_EMAC_C0_RX_THRESHOLD CFGCHIP1_CAP1SRC(0x7) | ||
| 62 | #define CFGCHIP1_CAP1SRC_EMAC_C0_RX CFGCHIP1_CAP1SRC(0x8) | ||
| 63 | #define CFGCHIP1_CAP1SRC_EMAC_C0_TX CFGCHIP1_CAP1SRC(0x9) | ||
| 64 | #define CFGCHIP1_CAP1SRC_EMAC_C0_MISC CFGCHIP1_CAP1SRC(0xa) | ||
| 65 | #define CFGCHIP1_CAP1SRC_EMAC_C1_RX_THRESHOLD CFGCHIP1_CAP1SRC(0xb) | ||
| 66 | #define CFGCHIP1_CAP1SRC_EMAC_C1_RX CFGCHIP1_CAP1SRC(0xc) | ||
| 67 | #define CFGCHIP1_CAP1SRC_EMAC_C1_TX CFGCHIP1_CAP1SRC(0xd) | ||
| 68 | #define CFGCHIP1_CAP1SRC_EMAC_C1_MISC CFGCHIP1_CAP1SRC(0xe) | ||
| 69 | #define CFGCHIP1_CAP1SRC_EMAC_C2_RX_THRESHOLD CFGCHIP1_CAP1SRC(0xf) | ||
| 70 | #define CFGCHIP1_CAP1SRC_EMAC_C2_RX CFGCHIP1_CAP1SRC(0x10) | ||
| 71 | #define CFGCHIP1_CAP1SRC_EMAC_C2_TX CFGCHIP1_CAP1SRC(0x11) | ||
| 72 | #define CFGCHIP1_CAP1SRC_EMAC_C2_MISC CFGCHIP1_CAP1SRC(0x12) | ||
| 73 | #define CFGCHIP1_CAP0SRC(n) ((n) << 17) | ||
| 74 | #define CFGCHIP1_CAP0SRC_MASK CFGCHIP1_CAP0SRC(0x1f) | ||
| 75 | #define CFGCHIP1_CAP0SRC_ECAP_PIN CFGCHIP1_CAP0SRC(0x0) | ||
| 76 | #define CFGCHIP1_CAP0SRC_MCASP0_TX CFGCHIP1_CAP0SRC(0x1) | ||
| 77 | #define CFGCHIP1_CAP0SRC_MCASP0_RX CFGCHIP1_CAP0SRC(0x2) | ||
| 78 | #define CFGCHIP1_CAP0SRC_EMAC_C0_RX_THRESHOLD CFGCHIP1_CAP0SRC(0x7) | ||
| 79 | #define CFGCHIP1_CAP0SRC_EMAC_C0_RX CFGCHIP1_CAP0SRC(0x8) | ||
| 80 | #define CFGCHIP1_CAP0SRC_EMAC_C0_TX CFGCHIP1_CAP0SRC(0x9) | ||
| 81 | #define CFGCHIP1_CAP0SRC_EMAC_C0_MISC CFGCHIP1_CAP0SRC(0xa) | ||
| 82 | #define CFGCHIP1_CAP0SRC_EMAC_C1_RX_THRESHOLD CFGCHIP1_CAP0SRC(0xb) | ||
| 83 | #define CFGCHIP1_CAP0SRC_EMAC_C1_RX CFGCHIP1_CAP0SRC(0xc) | ||
| 84 | #define CFGCHIP1_CAP0SRC_EMAC_C1_TX CFGCHIP1_CAP0SRC(0xd) | ||
| 85 | #define CFGCHIP1_CAP0SRC_EMAC_C1_MISC CFGCHIP1_CAP0SRC(0xe) | ||
| 86 | #define CFGCHIP1_CAP0SRC_EMAC_C2_RX_THRESHOLD CFGCHIP1_CAP0SRC(0xf) | ||
| 87 | #define CFGCHIP1_CAP0SRC_EMAC_C2_RX CFGCHIP1_CAP0SRC(0x10) | ||
| 88 | #define CFGCHIP1_CAP0SRC_EMAC_C2_TX CFGCHIP1_CAP0SRC(0x11) | ||
| 89 | #define CFGCHIP1_CAP0SRC_EMAC_C2_MISC CFGCHIP1_CAP0SRC(0x12) | ||
| 90 | #define CFGCHIP1_HPIBYTEAD BIT(16) | ||
| 91 | #define CFGCHIP1_HPIENA BIT(15) | ||
| 92 | #define CFGCHIP0_EDMA31TC0DBS(n) ((n) << 13) | ||
| 93 | #define CFGCHIP0_EDMA31TC0DBS_MASK CFGCHIP0_EDMA31TC0DBS(0x3) | ||
| 94 | #define CFGCHIP0_EDMA31TC0DBS_16 CFGCHIP0_EDMA31TC0DBS(0x0) | ||
| 95 | #define CFGCHIP0_EDMA31TC0DBS_32 CFGCHIP0_EDMA31TC0DBS(0x1) | ||
| 96 | #define CFGCHIP0_EDMA31TC0DBS_64 CFGCHIP0_EDMA31TC0DBS(0x2) | ||
| 97 | #define CFGCHIP1_TBCLKSYNC BIT(12) | ||
| 98 | #define CFGCHIP1_AMUTESEL0(n) ((n) << 0) | ||
| 99 | #define CFGCHIP1_AMUTESEL0_MASK CFGCHIP1_AMUTESEL0(0xf) | ||
| 100 | #define CFGCHIP1_AMUTESEL0_LOW CFGCHIP1_AMUTESEL0(0x0) | ||
| 101 | #define CFGCHIP1_AMUTESEL0_BANK_0 CFGCHIP1_AMUTESEL0(0x1) | ||
| 102 | #define CFGCHIP1_AMUTESEL0_BANK_1 CFGCHIP1_AMUTESEL0(0x2) | ||
| 103 | #define CFGCHIP1_AMUTESEL0_BANK_2 CFGCHIP1_AMUTESEL0(0x3) | ||
| 104 | #define CFGCHIP1_AMUTESEL0_BANK_3 CFGCHIP1_AMUTESEL0(0x4) | ||
| 105 | #define CFGCHIP1_AMUTESEL0_BANK_4 CFGCHIP1_AMUTESEL0(0x5) | ||
| 106 | #define CFGCHIP1_AMUTESEL0_BANK_5 CFGCHIP1_AMUTESEL0(0x6) | ||
| 107 | #define CFGCHIP1_AMUTESEL0_BANK_6 CFGCHIP1_AMUTESEL0(0x7) | ||
| 108 | #define CFGCHIP1_AMUTESEL0_BANK_7 CFGCHIP1_AMUTESEL0(0x8) | ||
| 109 | |||
| 110 | /* CFGCHIP2 (USB PHY) register bits */ | ||
| 111 | #define CFGCHIP2_PHYCLKGD BIT(17) | ||
| 112 | #define CFGCHIP2_VBUSSENSE BIT(16) | ||
| 113 | #define CFGCHIP2_RESET BIT(15) | ||
| 114 | #define CFGCHIP2_OTGMODE(n) ((n) << 13) | ||
| 115 | #define CFGCHIP2_OTGMODE_MASK CFGCHIP2_OTGMODE(0x3) | ||
| 116 | #define CFGCHIP2_OTGMODE_NO_OVERRIDE CFGCHIP2_OTGMODE(0x0) | ||
| 117 | #define CFGCHIP2_OTGMODE_FORCE_HOST CFGCHIP2_OTGMODE(0x1) | ||
| 118 | #define CFGCHIP2_OTGMODE_FORCE_DEVICE CFGCHIP2_OTGMODE(0x2) | ||
| 119 | #define CFGCHIP2_OTGMODE_FORCE_HOST_VBUS_LOW CFGCHIP2_OTGMODE(0x3) | ||
| 120 | #define CFGCHIP2_USB1PHYCLKMUX BIT(12) | ||
| 121 | #define CFGCHIP2_USB2PHYCLKMUX BIT(11) | ||
| 122 | #define CFGCHIP2_PHYPWRDN BIT(10) | ||
| 123 | #define CFGCHIP2_OTGPWRDN BIT(9) | ||
| 124 | #define CFGCHIP2_DATPOL BIT(8) | ||
| 125 | #define CFGCHIP2_USB1SUSPENDM BIT(7) | ||
| 126 | #define CFGCHIP2_PHY_PLLON BIT(6) | ||
| 127 | #define CFGCHIP2_SESENDEN BIT(5) | ||
| 128 | #define CFGCHIP2_VBDTCTEN BIT(4) | ||
| 129 | #define CFGCHIP2_REFFREQ(n) ((n) << 0) | ||
| 130 | #define CFGCHIP2_REFFREQ_MASK CFGCHIP2_REFFREQ(0xf) | ||
| 131 | #define CFGCHIP2_REFFREQ_12MHZ CFGCHIP2_REFFREQ(0x1) | ||
| 132 | #define CFGCHIP2_REFFREQ_24MHZ CFGCHIP2_REFFREQ(0x2) | ||
| 133 | #define CFGCHIP2_REFFREQ_48MHZ CFGCHIP2_REFFREQ(0x3) | ||
| 134 | #define CFGCHIP2_REFFREQ_19_2MHZ CFGCHIP2_REFFREQ(0x4) | ||
| 135 | #define CFGCHIP2_REFFREQ_38_4MHZ CFGCHIP2_REFFREQ(0x5) | ||
| 136 | #define CFGCHIP2_REFFREQ_13MHZ CFGCHIP2_REFFREQ(0x6) | ||
| 137 | #define CFGCHIP2_REFFREQ_26MHZ CFGCHIP2_REFFREQ(0x7) | ||
| 138 | #define CFGCHIP2_REFFREQ_20MHZ CFGCHIP2_REFFREQ(0x8) | ||
| 139 | #define CFGCHIP2_REFFREQ_40MHZ CFGCHIP2_REFFREQ(0x9) | ||
| 140 | |||
| 141 | /* CFGCHIP3 (EMAC/uPP/PLL1/ASYNC3/PRU/DIV4.5/EMIFA) register bits */ | ||
| 142 | #define CFGCHIP3_RMII_SEL BIT(8) | ||
| 143 | #define CFGCHIP3_UPP_TX_CLKSRC BIT(6) | ||
| 144 | #define CFGCHIP3_PLL1_MASTER_LOCK BIT(5) | ||
| 145 | #define CFGCHIP3_ASYNC3_CLKSRC BIT(4) | ||
| 146 | #define CFGCHIP3_PRUEVTSEL BIT(3) | ||
| 147 | #define CFGCHIP3_DIV45PENA BIT(2) | ||
| 148 | #define CFGCHIP3_EMA_CLKSRC BIT(1) | ||
| 149 | |||
| 150 | /* CFGCHIP4 (McASP0 AMUNTEIN) register bits */ | ||
| 151 | #define CFGCHIP4_AMUTECLR0 BIT(0) | ||
| 152 | |||
| 153 | #endif /* __LINUX_MFD_DA8XX_CFGCHIP_H */ | ||
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h index 2567a87872b0..7f55b8b41032 100644 --- a/include/linux/mfd/ti_am335x_tscadc.h +++ b/include/linux/mfd/ti_am335x_tscadc.h | |||
| @@ -138,16 +138,16 @@ | |||
| 138 | /* | 138 | /* |
| 139 | * time in us for processing a single channel, calculated as follows: | 139 | * time in us for processing a single channel, calculated as follows: |
| 140 | * | 140 | * |
| 141 | * num cycles = open delay + (sample delay + conv time) * averaging | 141 | * max num cycles = open delay + (sample delay + conv time) * averaging |
| 142 | * | 142 | * |
| 143 | * num cycles: 152 + (1 + 13) * 16 = 376 | 143 | * max num cycles: 262143 + (255 + 13) * 16 = 266431 |
| 144 | * | 144 | * |
| 145 | * clock frequency: 26MHz / 8 = 3.25MHz | 145 | * clock frequency: 26MHz / 8 = 3.25MHz |
| 146 | * clock period: 1 / 3.25MHz = 308ns | 146 | * clock period: 1 / 3.25MHz = 308ns |
| 147 | * | 147 | * |
| 148 | * processing time: 376 * 308ns = 116us | 148 | * max processing time: 266431 * 308ns = 83ms(approx) |
| 149 | */ | 149 | */ |
| 150 | #define IDLE_TIMEOUT 116 /* microsec */ | 150 | #define IDLE_TIMEOUT 83 /* milliseconds */ |
| 151 | 151 | ||
| 152 | #define TSCADC_CELLS 2 | 152 | #define TSCADC_CELLS 2 |
| 153 | 153 | ||
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h index 21bc4557b67a..d1f9a581aca8 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h | |||
| @@ -6710,9 +6710,10 @@ struct mlx5_ifc_pude_reg_bits { | |||
| 6710 | }; | 6710 | }; |
| 6711 | 6711 | ||
| 6712 | struct mlx5_ifc_ptys_reg_bits { | 6712 | struct mlx5_ifc_ptys_reg_bits { |
| 6713 | u8 an_disable_cap[0x1]; | 6713 | u8 reserved_at_0[0x1]; |
| 6714 | u8 an_disable_admin[0x1]; | 6714 | u8 an_disable_admin[0x1]; |
| 6715 | u8 reserved_at_2[0x6]; | 6715 | u8 an_disable_cap[0x1]; |
| 6716 | u8 reserved_at_3[0x5]; | ||
| 6716 | u8 local_port[0x8]; | 6717 | u8 local_port[0x8]; |
| 6717 | u8 reserved_at_10[0xd]; | 6718 | u8 reserved_at_10[0xd]; |
| 6718 | u8 proto_mask[0x3]; | 6719 | u8 proto_mask[0x3]; |
diff --git a/include/linux/mm.h b/include/linux/mm.h index 08ed53eeedd5..ef815b9cd426 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
| @@ -2014,6 +2014,7 @@ extern void mm_drop_all_locks(struct mm_struct *mm); | |||
| 2014 | 2014 | ||
| 2015 | extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file); | 2015 | extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file); |
| 2016 | extern struct file *get_mm_exe_file(struct mm_struct *mm); | 2016 | extern struct file *get_mm_exe_file(struct mm_struct *mm); |
| 2017 | extern struct file *get_task_exe_file(struct task_struct *task); | ||
| 2017 | 2018 | ||
| 2018 | extern bool may_expand_vm(struct mm_struct *, vm_flags_t, unsigned long npages); | 2019 | extern bool may_expand_vm(struct mm_struct *, vm_flags_t, unsigned long npages); |
| 2019 | extern void vm_stat_account(struct mm_struct *, vm_flags_t, long npages); | 2020 | extern void vm_stat_account(struct mm_struct *, vm_flags_t, long npages); |
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index d572b78b65e1..7f2ae99e5daf 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
| @@ -828,9 +828,21 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long); | |||
| 828 | */ | 828 | */ |
| 829 | #define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones) | 829 | #define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones) |
| 830 | 830 | ||
| 831 | static inline int populated_zone(struct zone *zone) | 831 | /* |
| 832 | * Returns true if a zone has pages managed by the buddy allocator. | ||
| 833 | * All the reclaim decisions have to use this function rather than | ||
| 834 | * populated_zone(). If the whole zone is reserved then we can easily | ||
| 835 | * end up with populated_zone() && !managed_zone(). | ||
| 836 | */ | ||
| 837 | static inline bool managed_zone(struct zone *zone) | ||
| 838 | { | ||
| 839 | return zone->managed_pages; | ||
| 840 | } | ||
| 841 | |||
| 842 | /* Returns true if a zone has memory */ | ||
| 843 | static inline bool populated_zone(struct zone *zone) | ||
| 832 | { | 844 | { |
| 833 | return (!!zone->present_pages); | 845 | return zone->present_pages; |
| 834 | } | 846 | } |
| 835 | 847 | ||
| 836 | extern int movable_zone; | 848 | extern int movable_zone; |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3a788bf0affd..e8d79d4ebcfe 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
| @@ -3267,6 +3267,7 @@ static inline void napi_free_frags(struct napi_struct *napi) | |||
| 3267 | napi->skb = NULL; | 3267 | napi->skb = NULL; |
| 3268 | } | 3268 | } |
| 3269 | 3269 | ||
| 3270 | bool netdev_is_rx_handler_busy(struct net_device *dev); | ||
| 3270 | int netdev_rx_handler_register(struct net_device *dev, | 3271 | int netdev_rx_handler_register(struct net_device *dev, |
| 3271 | rx_handler_func_t *rx_handler, | 3272 | rx_handler_func_t *rx_handler, |
| 3272 | void *rx_handler_data); | 3273 | void *rx_handler_data); |
diff --git a/include/linux/netfilter/nfnetlink_acct.h b/include/linux/netfilter/nfnetlink_acct.h index 80ca889b164e..664da0048625 100644 --- a/include/linux/netfilter/nfnetlink_acct.h +++ b/include/linux/netfilter/nfnetlink_acct.h | |||
| @@ -15,6 +15,6 @@ struct nf_acct; | |||
| 15 | struct nf_acct *nfnl_acct_find_get(struct net *net, const char *filter_name); | 15 | struct nf_acct *nfnl_acct_find_get(struct net *net, const char *filter_name); |
| 16 | void nfnl_acct_put(struct nf_acct *acct); | 16 | void nfnl_acct_put(struct nf_acct *acct); |
| 17 | void nfnl_acct_update(const struct sk_buff *skb, struct nf_acct *nfacct); | 17 | void nfnl_acct_update(const struct sk_buff *skb, struct nf_acct *nfacct); |
| 18 | extern int nfnl_acct_overquota(const struct sk_buff *skb, | 18 | int nfnl_acct_overquota(struct net *net, const struct sk_buff *skb, |
| 19 | struct nf_acct *nfacct); | 19 | struct nf_acct *nfacct); |
| 20 | #endif /* _NFNL_ACCT_H */ | 20 | #endif /* _NFNL_ACCT_H */ |
diff --git a/include/linux/nvme.h b/include/linux/nvme.h index d8b37bab2887..7676557ce357 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h | |||
| @@ -794,7 +794,7 @@ struct nvmf_connect_command { | |||
| 794 | }; | 794 | }; |
| 795 | 795 | ||
| 796 | struct nvmf_connect_data { | 796 | struct nvmf_connect_data { |
| 797 | uuid_le hostid; | 797 | uuid_be hostid; |
| 798 | __le16 cntlid; | 798 | __le16 cntlid; |
| 799 | char resv4[238]; | 799 | char resv4[238]; |
| 800 | char subsysnqn[NVMF_NQN_FIELD_LEN]; | 800 | char subsysnqn[NVMF_NQN_FIELD_LEN]; |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 2599a980340f..0ab835965669 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
| @@ -683,15 +683,6 @@ struct pci_driver { | |||
| 683 | #define to_pci_driver(drv) container_of(drv, struct pci_driver, driver) | 683 | #define to_pci_driver(drv) container_of(drv, struct pci_driver, driver) |
| 684 | 684 | ||
| 685 | /** | 685 | /** |
| 686 | * DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table | ||
| 687 | * @_table: device table name | ||
| 688 | * | ||
| 689 | * This macro is deprecated and should not be used in new code. | ||
| 690 | */ | ||
| 691 | #define DEFINE_PCI_DEVICE_TABLE(_table) \ | ||
| 692 | const struct pci_device_id _table[] | ||
| 693 | |||
| 694 | /** | ||
| 695 | * PCI_DEVICE - macro used to describe a specific pci device | 686 | * PCI_DEVICE - macro used to describe a specific pci device |
| 696 | * @vend: the 16 bit PCI Vendor ID | 687 | * @vend: the 16 bit PCI Vendor ID |
| 697 | * @dev: the 16 bit PCI Device ID | 688 | * @dev: the 16 bit PCI Device ID |
| @@ -1251,10 +1242,12 @@ resource_size_t pcibios_iov_resource_alignment(struct pci_dev *dev, int resno); | |||
| 1251 | int pci_set_vga_state(struct pci_dev *pdev, bool decode, | 1242 | int pci_set_vga_state(struct pci_dev *pdev, bool decode, |
| 1252 | unsigned int command_bits, u32 flags); | 1243 | unsigned int command_bits, u32 flags); |
| 1253 | 1244 | ||
| 1254 | #define PCI_IRQ_NOLEGACY (1 << 0) /* don't use legacy interrupts */ | 1245 | #define PCI_IRQ_LEGACY (1 << 0) /* allow legacy interrupts */ |
| 1255 | #define PCI_IRQ_NOMSI (1 << 1) /* don't use MSI interrupts */ | 1246 | #define PCI_IRQ_MSI (1 << 1) /* allow MSI interrupts */ |
| 1256 | #define PCI_IRQ_NOMSIX (1 << 2) /* don't use MSI-X interrupts */ | 1247 | #define PCI_IRQ_MSIX (1 << 2) /* allow MSI-X interrupts */ |
| 1257 | #define PCI_IRQ_NOAFFINITY (1 << 3) /* don't auto-assign affinity */ | 1248 | #define PCI_IRQ_AFFINITY (1 << 3) /* auto-assign affinity */ |
| 1249 | #define PCI_IRQ_ALL_TYPES \ | ||
| 1250 | (PCI_IRQ_LEGACY | PCI_IRQ_MSI | PCI_IRQ_MSIX) | ||
| 1258 | 1251 | ||
| 1259 | /* kmem_cache style wrapper around pci_alloc_consistent() */ | 1252 | /* kmem_cache style wrapper around pci_alloc_consistent() */ |
| 1260 | 1253 | ||
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index 923266cd294a..48ec7651989b 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h | |||
| @@ -111,7 +111,6 @@ struct uart_8250_port { | |||
| 111 | * if no_console_suspend | 111 | * if no_console_suspend |
| 112 | */ | 112 | */ |
| 113 | unsigned char probe; | 113 | unsigned char probe; |
| 114 | struct mctrl_gpios *gpios; | ||
| 115 | #define UART_PROBE_RSA (1 << 0) | 114 | #define UART_PROBE_RSA (1 << 0) |
| 116 | 115 | ||
| 117 | /* | 116 | /* |
diff --git a/include/linux/smc91x.h b/include/linux/smc91x.h index 76199b75d584..e302c447e057 100644 --- a/include/linux/smc91x.h +++ b/include/linux/smc91x.h | |||
| @@ -1,6 +1,16 @@ | |||
| 1 | #ifndef __SMC91X_H__ | 1 | #ifndef __SMC91X_H__ |
| 2 | #define __SMC91X_H__ | 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 | #define SMC91X_USE_8BIT (1 << 0) | 14 | #define SMC91X_USE_8BIT (1 << 0) |
| 5 | #define SMC91X_USE_16BIT (1 << 1) | 15 | #define SMC91X_USE_16BIT (1 << 1) |
| 6 | #define SMC91X_USE_32BIT (1 << 2) | 16 | #define SMC91X_USE_32BIT (1 << 2) |
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 697e160c78d0..a4f7203a9017 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h | |||
| @@ -42,6 +42,8 @@ extern int proc_dostring(struct ctl_table *, int, | |||
| 42 | void __user *, size_t *, loff_t *); | 42 | void __user *, size_t *, loff_t *); |
| 43 | extern int proc_dointvec(struct ctl_table *, int, | 43 | extern int proc_dointvec(struct ctl_table *, int, |
| 44 | void __user *, size_t *, loff_t *); | 44 | void __user *, size_t *, loff_t *); |
| 45 | extern int proc_douintvec(struct ctl_table *, int, | ||
| 46 | void __user *, size_t *, loff_t *); | ||
| 45 | extern int proc_dointvec_minmax(struct ctl_table *, int, | 47 | extern int proc_dointvec_minmax(struct ctl_table *, int, |
| 46 | void __user *, size_t *, loff_t *); | 48 | void __user *, size_t *, loff_t *); |
| 47 | extern int proc_dointvec_jiffies(struct ctl_table *, int, | 49 | extern int proc_dointvec_jiffies(struct ctl_table *, int, |
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h index cbd8990e2e77..2b5b10eed74f 100644 --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h | |||
| @@ -118,10 +118,11 @@ static inline int arch_within_stack_frames(const void * const stack, | |||
| 118 | extern void __check_object_size(const void *ptr, unsigned long n, | 118 | extern void __check_object_size(const void *ptr, unsigned long n, |
| 119 | bool to_user); | 119 | bool to_user); |
| 120 | 120 | ||
| 121 | static inline void check_object_size(const void *ptr, unsigned long n, | 121 | static __always_inline void check_object_size(const void *ptr, unsigned long n, |
| 122 | bool to_user) | 122 | bool to_user) |
| 123 | { | 123 | { |
| 124 | __check_object_size(ptr, n, to_user); | 124 | if (!__builtin_constant_p(n)) |
| 125 | __check_object_size(ptr, n, to_user); | ||
| 125 | } | 126 | } |
| 126 | #else | 127 | #else |
| 127 | static inline void check_object_size(const void *ptr, unsigned long n, | 128 | static inline void check_object_size(const void *ptr, unsigned long n, |
diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 9b4c418bebd8..fd60eccb59a6 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h | |||
| @@ -52,7 +52,7 @@ struct unix_sock { | |||
| 52 | struct sock sk; | 52 | struct sock sk; |
| 53 | struct unix_address *addr; | 53 | struct unix_address *addr; |
| 54 | struct path path; | 54 | struct path path; |
| 55 | struct mutex readlock; | 55 | struct mutex iolock, bindlock; |
| 56 | struct sock *peer; | 56 | struct sock *peer; |
| 57 | struct list_head link; | 57 | struct list_head link; |
| 58 | atomic_long_t inflight; | 58 | atomic_long_t inflight; |
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 9c23f4d33e06..beb7610d64e9 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
| @@ -1102,6 +1102,7 @@ struct station_info { | |||
| 1102 | struct cfg80211_tid_stats pertid[IEEE80211_NUM_TIDS + 1]; | 1102 | struct cfg80211_tid_stats pertid[IEEE80211_NUM_TIDS + 1]; |
| 1103 | }; | 1103 | }; |
| 1104 | 1104 | ||
| 1105 | #if IS_ENABLED(CONFIG_CFG80211) | ||
| 1105 | /** | 1106 | /** |
| 1106 | * cfg80211_get_station - retrieve information about a given station | 1107 | * cfg80211_get_station - retrieve information about a given station |
| 1107 | * @dev: the device where the station is supposed to be connected to | 1108 | * @dev: the device where the station is supposed to be connected to |
| @@ -1114,6 +1115,14 @@ struct station_info { | |||
| 1114 | */ | 1115 | */ |
| 1115 | int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr, | 1116 | int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr, |
| 1116 | struct station_info *sinfo); | 1117 | struct station_info *sinfo); |
| 1118 | #else | ||
| 1119 | static inline int cfg80211_get_station(struct net_device *dev, | ||
| 1120 | const u8 *mac_addr, | ||
| 1121 | struct station_info *sinfo) | ||
| 1122 | { | ||
| 1123 | return -ENOENT; | ||
| 1124 | } | ||
| 1125 | #endif | ||
| 1117 | 1126 | ||
| 1118 | /** | 1127 | /** |
| 1119 | * enum monitor_flags - monitor flags | 1128 | * enum monitor_flags - monitor flags |
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index 4079fc18ffe4..7d4a72e75f33 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h | |||
| @@ -111,6 +111,7 @@ struct fib_info { | |||
| 111 | unsigned char fib_scope; | 111 | unsigned char fib_scope; |
| 112 | unsigned char fib_type; | 112 | unsigned char fib_type; |
| 113 | __be32 fib_prefsrc; | 113 | __be32 fib_prefsrc; |
| 114 | u32 fib_tb_id; | ||
| 114 | u32 fib_priority; | 115 | u32 fib_priority; |
| 115 | u32 *fib_metrics; | 116 | u32 *fib_metrics; |
| 116 | #define fib_mtu fib_metrics[RTAX_MTU-1] | 117 | #define fib_mtu fib_metrics[RTAX_MTU-1] |
| @@ -319,7 +320,7 @@ void fib_flush_external(struct net *net); | |||
| 319 | /* Exported by fib_semantics.c */ | 320 | /* Exported by fib_semantics.c */ |
| 320 | int ip_fib_check_default(__be32 gw, struct net_device *dev); | 321 | int ip_fib_check_default(__be32 gw, struct net_device *dev); |
| 321 | int fib_sync_down_dev(struct net_device *dev, unsigned long event, bool force); | 322 | int fib_sync_down_dev(struct net_device *dev, unsigned long event, bool force); |
| 322 | int fib_sync_down_addr(struct net *net, __be32 local); | 323 | int fib_sync_down_addr(struct net_device *dev, __be32 local); |
| 323 | int fib_sync_up(struct net_device *dev, unsigned int nh_flags); | 324 | int fib_sync_up(struct net_device *dev, unsigned int nh_flags); |
| 324 | 325 | ||
| 325 | extern u32 fib_multipath_secret __read_mostly; | 326 | extern u32 fib_multipath_secret __read_mostly; |
diff --git a/include/net/netfilter/nft_meta.h b/include/net/netfilter/nft_meta.h index d27588c8dbd9..1139cde0fdc5 100644 --- a/include/net/netfilter/nft_meta.h +++ b/include/net/netfilter/nft_meta.h | |||
| @@ -36,4 +36,8 @@ void nft_meta_set_eval(const struct nft_expr *expr, | |||
| 36 | void nft_meta_set_destroy(const struct nft_ctx *ctx, | 36 | void nft_meta_set_destroy(const struct nft_ctx *ctx, |
| 37 | const struct nft_expr *expr); | 37 | const struct nft_expr *expr); |
| 38 | 38 | ||
| 39 | int nft_meta_set_validate(const struct nft_ctx *ctx, | ||
| 40 | const struct nft_expr *expr, | ||
| 41 | const struct nft_data **data); | ||
| 42 | |||
| 39 | #endif | 43 | #endif |
diff --git a/include/net/netfilter/nft_reject.h b/include/net/netfilter/nft_reject.h index 60fa1530006b..02e28c529b29 100644 --- a/include/net/netfilter/nft_reject.h +++ b/include/net/netfilter/nft_reject.h | |||
| @@ -8,6 +8,10 @@ struct nft_reject { | |||
| 8 | 8 | ||
| 9 | extern const struct nla_policy nft_reject_policy[]; | 9 | extern const struct nla_policy nft_reject_policy[]; |
| 10 | 10 | ||
| 11 | int nft_reject_validate(const struct nft_ctx *ctx, | ||
| 12 | const struct nft_expr *expr, | ||
| 13 | const struct nft_data **data); | ||
| 14 | |||
| 11 | int nft_reject_init(const struct nft_ctx *ctx, | 15 | int nft_reject_init(const struct nft_ctx *ctx, |
| 12 | const struct nft_expr *expr, | 16 | const struct nft_expr *expr, |
| 13 | const struct nlattr * const tb[]); | 17 | const struct nlattr * const tb[]); |
diff --git a/include/net/tcp.h b/include/net/tcp.h index c00e7d51bb18..7717302cab91 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
| @@ -1523,6 +1523,8 @@ static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unli | |||
| 1523 | { | 1523 | { |
| 1524 | if (sk->sk_send_head == skb_unlinked) | 1524 | if (sk->sk_send_head == skb_unlinked) |
| 1525 | sk->sk_send_head = NULL; | 1525 | sk->sk_send_head = NULL; |
| 1526 | if (tcp_sk(sk)->highest_sack == skb_unlinked) | ||
| 1527 | tcp_sk(sk)->highest_sack = NULL; | ||
| 1526 | } | 1528 | } |
| 1527 | 1529 | ||
| 1528 | static inline void tcp_init_send_head(struct sock *sk) | 1530 | static inline void tcp_init_send_head(struct sock *sk) |
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 8e90dd28bb75..e1f96737c2a1 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
| @@ -2115,22 +2115,17 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata, | |||
| 2115 | size_t len) | 2115 | size_t len) |
| 2116 | { | 2116 | { |
| 2117 | const void __user *p = udata->inbuf + offset; | 2117 | const void __user *p = udata->inbuf + offset; |
| 2118 | bool ret = false; | 2118 | bool ret; |
| 2119 | u8 *buf; | 2119 | u8 *buf; |
| 2120 | 2120 | ||
| 2121 | if (len > USHRT_MAX) | 2121 | if (len > USHRT_MAX) |
| 2122 | return false; | 2122 | return false; |
| 2123 | 2123 | ||
| 2124 | buf = kmalloc(len, GFP_KERNEL); | 2124 | buf = memdup_user(p, len); |
| 2125 | if (!buf) | 2125 | if (IS_ERR(buf)) |
| 2126 | return false; | 2126 | return false; |
| 2127 | 2127 | ||
| 2128 | if (copy_from_user(buf, p, len)) | ||
| 2129 | goto free; | ||
| 2130 | |||
| 2131 | ret = !memchr_inv(buf, 0, len); | 2128 | ret = !memchr_inv(buf, 0, len); |
| 2132 | |||
| 2133 | free: | ||
| 2134 | kfree(buf); | 2129 | kfree(buf); |
| 2135 | return ret; | 2130 | return ret; |
| 2136 | } | 2131 | } |
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h index 13c0b2ba1b6c..73d870918939 100644 --- a/include/scsi/scsi_transport_sas.h +++ b/include/scsi/scsi_transport_sas.h | |||
| @@ -11,12 +11,12 @@ struct sas_rphy; | |||
| 11 | struct request; | 11 | struct request; |
| 12 | 12 | ||
| 13 | #if !IS_ENABLED(CONFIG_SCSI_SAS_ATTRS) | 13 | #if !IS_ENABLED(CONFIG_SCSI_SAS_ATTRS) |
| 14 | static inline int is_sas_attached(struct scsi_device *sdev) | 14 | static inline int scsi_is_sas_rphy(const struct device *sdev) |
| 15 | { | 15 | { |
| 16 | return 0; | 16 | return 0; |
| 17 | } | 17 | } |
| 18 | #else | 18 | #else |
| 19 | extern int is_sas_attached(struct scsi_device *sdev); | 19 | extern int scsi_is_sas_rphy(const struct device *); |
| 20 | #endif | 20 | #endif |
| 21 | 21 | ||
| 22 | static inline int sas_protocol_ata(enum sas_protocol proto) | 22 | static inline int sas_protocol_ata(enum sas_protocol proto) |
| @@ -202,7 +202,6 @@ extern int sas_rphy_add(struct sas_rphy *); | |||
| 202 | extern void sas_rphy_remove(struct sas_rphy *); | 202 | extern void sas_rphy_remove(struct sas_rphy *); |
| 203 | extern void sas_rphy_delete(struct sas_rphy *); | 203 | extern void sas_rphy_delete(struct sas_rphy *); |
| 204 | extern void sas_rphy_unlink(struct sas_rphy *); | 204 | extern void sas_rphy_unlink(struct sas_rphy *); |
| 205 | extern int scsi_is_sas_rphy(const struct device *); | ||
| 206 | 205 | ||
| 207 | struct sas_port *sas_port_alloc(struct device *, int); | 206 | struct sas_port *sas_port_alloc(struct device *, int); |
| 208 | struct sas_port *sas_port_alloc_num(struct device *); | 207 | struct sas_port *sas_port_alloc_num(struct device *); |
diff --git a/include/uapi/linux/atm_zatm.h b/include/uapi/linux/atm_zatm.h index 9c9c6ad55f14..5cd4d4d2dd1d 100644 --- a/include/uapi/linux/atm_zatm.h +++ b/include/uapi/linux/atm_zatm.h | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | 14 | ||
| 15 | #include <linux/atmapi.h> | 15 | #include <linux/atmapi.h> |
| 16 | #include <linux/atmioc.h> | 16 | #include <linux/atmioc.h> |
| 17 | #include <linux/time.h> | ||
| 17 | 18 | ||
| 18 | #define ZATM_GETPOOL _IOW('a',ATMIOC_SARPRV+1,struct atmif_sioc) | 19 | #define ZATM_GETPOOL _IOW('a',ATMIOC_SARPRV+1,struct atmif_sioc) |
| 19 | /* get pool statistics */ | 20 | /* get pool statistics */ |
diff --git a/include/uapi/linux/if_pppol2tp.h b/include/uapi/linux/if_pppol2tp.h index 163e8adac2d6..4bd1f55d6377 100644 --- a/include/uapi/linux/if_pppol2tp.h +++ b/include/uapi/linux/if_pppol2tp.h | |||
| @@ -16,7 +16,8 @@ | |||
| 16 | #define _UAPI__LINUX_IF_PPPOL2TP_H | 16 | #define _UAPI__LINUX_IF_PPPOL2TP_H |
| 17 | 17 | ||
| 18 | #include <linux/types.h> | 18 | #include <linux/types.h> |
| 19 | 19 | #include <linux/in.h> | |
| 20 | #include <linux/in6.h> | ||
| 20 | 21 | ||
| 21 | /* Structure used to connect() the socket to a particular tunnel UDP | 22 | /* Structure used to connect() the socket to a particular tunnel UDP |
| 22 | * socket over IPv4. | 23 | * socket over IPv4. |
diff --git a/include/uapi/linux/if_pppox.h b/include/uapi/linux/if_pppox.h index e128769331b5..d37bbb17a007 100644 --- a/include/uapi/linux/if_pppox.h +++ b/include/uapi/linux/if_pppox.h | |||
| @@ -21,8 +21,11 @@ | |||
| 21 | #include <asm/byteorder.h> | 21 | #include <asm/byteorder.h> |
| 22 | 22 | ||
| 23 | #include <linux/socket.h> | 23 | #include <linux/socket.h> |
| 24 | #include <linux/if.h> | ||
| 24 | #include <linux/if_ether.h> | 25 | #include <linux/if_ether.h> |
| 25 | #include <linux/if_pppol2tp.h> | 26 | #include <linux/if_pppol2tp.h> |
| 27 | #include <linux/in.h> | ||
| 28 | #include <linux/in6.h> | ||
| 26 | 29 | ||
| 27 | /* For user-space programs to pick up these definitions | 30 | /* For user-space programs to pick up these definitions |
| 28 | * which they wouldn't get otherwise without defining __KERNEL__ | 31 | * which they wouldn't get otherwise without defining __KERNEL__ |
diff --git a/include/uapi/linux/if_tunnel.h b/include/uapi/linux/if_tunnel.h index 1046f5515174..777b6cdb1b7b 100644 --- a/include/uapi/linux/if_tunnel.h +++ b/include/uapi/linux/if_tunnel.h | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | #define _UAPI_IF_TUNNEL_H_ | 2 | #define _UAPI_IF_TUNNEL_H_ |
| 3 | 3 | ||
| 4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
| 5 | #include <linux/if.h> | ||
| 6 | #include <linux/ip.h> | ||
| 7 | #include <linux/in6.h> | ||
| 5 | #include <asm/byteorder.h> | 8 | #include <asm/byteorder.h> |
| 6 | 9 | ||
| 7 | 10 | ||
diff --git a/include/uapi/linux/ipx.h b/include/uapi/linux/ipx.h index 3d48014cdd71..30f031db12f6 100644 --- a/include/uapi/linux/ipx.h +++ b/include/uapi/linux/ipx.h | |||
| @@ -1,11 +1,13 @@ | |||
| 1 | #ifndef _IPX_H_ | 1 | #ifndef _IPX_H_ |
| 2 | #define _IPX_H_ | 2 | #define _IPX_H_ |
| 3 | #include <linux/libc-compat.h> /* for compatibility with glibc netipx/ipx.h */ | ||
| 3 | #include <linux/types.h> | 4 | #include <linux/types.h> |
| 4 | #include <linux/sockios.h> | 5 | #include <linux/sockios.h> |
| 5 | #include <linux/socket.h> | 6 | #include <linux/socket.h> |
| 6 | #define IPX_NODE_LEN 6 | 7 | #define IPX_NODE_LEN 6 |
| 7 | #define IPX_MTU 576 | 8 | #define IPX_MTU 576 |
| 8 | 9 | ||
| 10 | #if __UAPI_DEF_SOCKADDR_IPX | ||
| 9 | struct sockaddr_ipx { | 11 | struct sockaddr_ipx { |
| 10 | __kernel_sa_family_t sipx_family; | 12 | __kernel_sa_family_t sipx_family; |
| 11 | __be16 sipx_port; | 13 | __be16 sipx_port; |
| @@ -14,6 +16,7 @@ struct sockaddr_ipx { | |||
| 14 | __u8 sipx_type; | 16 | __u8 sipx_type; |
| 15 | unsigned char sipx_zero; /* 16 byte fill */ | 17 | unsigned char sipx_zero; /* 16 byte fill */ |
| 16 | }; | 18 | }; |
| 19 | #endif /* __UAPI_DEF_SOCKADDR_IPX */ | ||
| 17 | 20 | ||
| 18 | /* | 21 | /* |
| 19 | * So we can fit the extra info for SIOCSIFADDR into the address nicely | 22 | * So we can fit the extra info for SIOCSIFADDR into the address nicely |
| @@ -23,12 +26,15 @@ struct sockaddr_ipx { | |||
| 23 | #define IPX_DLTITF 0 | 26 | #define IPX_DLTITF 0 |
| 24 | #define IPX_CRTITF 1 | 27 | #define IPX_CRTITF 1 |
| 25 | 28 | ||
| 29 | #if __UAPI_DEF_IPX_ROUTE_DEFINITION | ||
| 26 | struct ipx_route_definition { | 30 | struct ipx_route_definition { |
| 27 | __be32 ipx_network; | 31 | __be32 ipx_network; |
| 28 | __be32 ipx_router_network; | 32 | __be32 ipx_router_network; |
| 29 | unsigned char ipx_router_node[IPX_NODE_LEN]; | 33 | unsigned char ipx_router_node[IPX_NODE_LEN]; |
| 30 | }; | 34 | }; |
| 35 | #endif /* __UAPI_DEF_IPX_ROUTE_DEFINITION */ | ||
| 31 | 36 | ||
| 37 | #if __UAPI_DEF_IPX_INTERFACE_DEFINITION | ||
| 32 | struct ipx_interface_definition { | 38 | struct ipx_interface_definition { |
| 33 | __be32 ipx_network; | 39 | __be32 ipx_network; |
| 34 | unsigned char ipx_device[16]; | 40 | unsigned char ipx_device[16]; |
| @@ -45,16 +51,20 @@ struct ipx_interface_definition { | |||
| 45 | #define IPX_INTERNAL 2 | 51 | #define IPX_INTERNAL 2 |
| 46 | unsigned char ipx_node[IPX_NODE_LEN]; | 52 | unsigned char ipx_node[IPX_NODE_LEN]; |
| 47 | }; | 53 | }; |
| 48 | 54 | #endif /* __UAPI_DEF_IPX_INTERFACE_DEFINITION */ | |
| 55 | |||
| 56 | #if __UAPI_DEF_IPX_CONFIG_DATA | ||
| 49 | struct ipx_config_data { | 57 | struct ipx_config_data { |
| 50 | unsigned char ipxcfg_auto_select_primary; | 58 | unsigned char ipxcfg_auto_select_primary; |
| 51 | unsigned char ipxcfg_auto_create_interfaces; | 59 | unsigned char ipxcfg_auto_create_interfaces; |
| 52 | }; | 60 | }; |
| 61 | #endif /* __UAPI_DEF_IPX_CONFIG_DATA */ | ||
| 53 | 62 | ||
| 54 | /* | 63 | /* |
| 55 | * OLD Route Definition for backward compatibility. | 64 | * OLD Route Definition for backward compatibility. |
| 56 | */ | 65 | */ |
| 57 | 66 | ||
| 67 | #if __UAPI_DEF_IPX_ROUTE_DEF | ||
| 58 | struct ipx_route_def { | 68 | struct ipx_route_def { |
| 59 | __be32 ipx_network; | 69 | __be32 ipx_network; |
| 60 | __be32 ipx_router_network; | 70 | __be32 ipx_router_network; |
| @@ -67,6 +77,7 @@ struct ipx_route_def { | |||
| 67 | #define IPX_RT_BLUEBOOK 2 | 77 | #define IPX_RT_BLUEBOOK 2 |
| 68 | #define IPX_RT_ROUTED 1 | 78 | #define IPX_RT_ROUTED 1 |
| 69 | }; | 79 | }; |
| 80 | #endif /* __UAPI_DEF_IPX_ROUTE_DEF */ | ||
| 70 | 81 | ||
| 71 | #define SIOCAIPXITFCRT (SIOCPROTOPRIVATE) | 82 | #define SIOCAIPXITFCRT (SIOCPROTOPRIVATE) |
| 72 | #define SIOCAIPXPRISLT (SIOCPROTOPRIVATE + 1) | 83 | #define SIOCAIPXPRISLT (SIOCPROTOPRIVATE + 1) |
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h index e4f048ee7043..44b8a6bd5fe1 100644 --- a/include/uapi/linux/libc-compat.h +++ b/include/uapi/linux/libc-compat.h | |||
| @@ -139,6 +139,25 @@ | |||
| 139 | 139 | ||
| 140 | #endif /* _NETINET_IN_H */ | 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 | /* Definitions for xattr.h */ | 161 | /* Definitions for xattr.h */ |
| 143 | #if defined(_SYS_XATTR_H) | 162 | #if defined(_SYS_XATTR_H) |
| 144 | #define __UAPI_DEF_XATTR 0 | 163 | #define __UAPI_DEF_XATTR 0 |
| @@ -179,6 +198,13 @@ | |||
| 179 | #define __UAPI_DEF_IN6_PKTINFO 1 | 198 | #define __UAPI_DEF_IN6_PKTINFO 1 |
| 180 | #define __UAPI_DEF_IP6_MTUINFO 1 | 199 | #define __UAPI_DEF_IP6_MTUINFO 1 |
| 181 | 200 | ||
| 201 | /* Definitions for ipx.h */ | ||
| 202 | #define __UAPI_DEF_SOCKADDR_IPX 1 | ||
| 203 | #define __UAPI_DEF_IPX_ROUTE_DEFINITION 1 | ||
| 204 | #define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1 | ||
| 205 | #define __UAPI_DEF_IPX_CONFIG_DATA 1 | ||
| 206 | #define __UAPI_DEF_IPX_ROUTE_DEF 1 | ||
| 207 | |||
| 182 | /* Definitions for xattr.h */ | 208 | /* Definitions for xattr.h */ |
| 183 | #define __UAPI_DEF_XATTR 1 | 209 | #define __UAPI_DEF_XATTR 1 |
| 184 | 210 | ||
diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h index d95a3018f6a1..54c3b4f4aceb 100644 --- a/include/uapi/linux/openvswitch.h +++ b/include/uapi/linux/openvswitch.h | |||
| @@ -583,7 +583,7 @@ enum ovs_userspace_attr { | |||
| 583 | #define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1) | 583 | #define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1) |
| 584 | 584 | ||
| 585 | struct ovs_action_trunc { | 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,8 +632,8 @@ enum ovs_hash_alg { | |||
| 632 | * @hash_basis: basis used for computing hash. | 632 | * @hash_basis: basis used for computing hash. |
| 633 | */ | 633 | */ |
| 634 | struct ovs_action_hash { | 634 | struct ovs_action_hash { |
| 635 | uint32_t hash_alg; /* One of ovs_hash_alg. */ | 635 | __u32 hash_alg; /* One of ovs_hash_alg. */ |
| 636 | uint32_t hash_basis; | 636 | __u32 hash_basis; |
| 637 | }; | 637 | }; |
| 638 | 638 | ||
| 639 | /** | 639 | /** |
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h index 9a37c541822f..b5486e648607 100644 --- a/include/xen/xen-ops.h +++ b/include/xen/xen-ops.h | |||
| @@ -9,8 +9,8 @@ | |||
| 9 | 9 | ||
| 10 | DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu); | 10 | DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu); |
| 11 | 11 | ||
| 12 | DECLARE_PER_CPU(int, xen_vcpu_id); | 12 | DECLARE_PER_CPU(uint32_t, xen_vcpu_id); |
| 13 | static inline int xen_vcpu_nr(int cpu) | 13 | static inline uint32_t xen_vcpu_nr(int cpu) |
| 14 | { | 14 | { |
| 15 | return per_cpu(xen_vcpu_id, cpu); | 15 | return per_cpu(xen_vcpu_id, cpu); |
| 16 | } | 16 | } |
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c index d6709eb70970..0d302a87f21b 100644 --- a/kernel/audit_watch.c +++ b/kernel/audit_watch.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include <linux/file.h> | ||
| 22 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
| 23 | #include <linux/audit.h> | 24 | #include <linux/audit.h> |
| 24 | #include <linux/kthread.h> | 25 | #include <linux/kthread.h> |
| @@ -544,10 +545,11 @@ int audit_exe_compare(struct task_struct *tsk, struct audit_fsnotify_mark *mark) | |||
| 544 | unsigned long ino; | 545 | unsigned long ino; |
| 545 | dev_t dev; | 546 | dev_t dev; |
| 546 | 547 | ||
| 547 | rcu_read_lock(); | 548 | exe_file = get_task_exe_file(tsk); |
| 548 | exe_file = rcu_dereference(tsk->mm->exe_file); | 549 | if (!exe_file) |
| 550 | return 0; | ||
| 549 | ino = exe_file->f_inode->i_ino; | 551 | ino = exe_file->f_inode->i_ino; |
| 550 | dev = exe_file->f_inode->i_sb->s_dev; | 552 | dev = exe_file->f_inode->i_sb->s_dev; |
| 551 | rcu_read_unlock(); | 553 | fput(exe_file); |
| 552 | return audit_mark_compare(mark, ino, dev); | 554 | return audit_mark_compare(mark, ino, dev); |
| 553 | } | 555 | } |
diff --git a/kernel/configs/tiny.config b/kernel/configs/tiny.config index c2de56ab0fce..7fa0c4ae6394 100644 --- a/kernel/configs/tiny.config +++ b/kernel/configs/tiny.config | |||
| @@ -1,4 +1,12 @@ | |||
| 1 | # CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set | ||
| 1 | CONFIG_CC_OPTIMIZE_FOR_SIZE=y | 2 | CONFIG_CC_OPTIMIZE_FOR_SIZE=y |
| 3 | # CONFIG_KERNEL_GZIP is not set | ||
| 4 | # CONFIG_KERNEL_BZIP2 is not set | ||
| 5 | # CONFIG_KERNEL_LZMA is not set | ||
| 2 | CONFIG_KERNEL_XZ=y | 6 | CONFIG_KERNEL_XZ=y |
| 7 | # CONFIG_KERNEL_LZO is not set | ||
| 8 | # CONFIG_KERNEL_LZ4 is not set | ||
| 3 | CONFIG_OPTIMIZE_INLINING=y | 9 | CONFIG_OPTIMIZE_INLINING=y |
| 10 | # CONFIG_SLAB is not set | ||
| 11 | # CONFIG_SLUB is not set | ||
| 4 | CONFIG_SLOB=y | 12 | CONFIG_SLOB=y |
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index c7fd2778ed50..c27e53326bef 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
| @@ -2069,6 +2069,20 @@ static void cpuset_bind(struct cgroup_subsys_state *root_css) | |||
| 2069 | mutex_unlock(&cpuset_mutex); | 2069 | mutex_unlock(&cpuset_mutex); |
| 2070 | } | 2070 | } |
| 2071 | 2071 | ||
| 2072 | /* | ||
| 2073 | * Make sure the new task conform to the current state of its parent, | ||
| 2074 | * which could have been changed by cpuset just after it inherits the | ||
| 2075 | * state from the parent and before it sits on the cgroup's task list. | ||
| 2076 | */ | ||
| 2077 | void cpuset_fork(struct task_struct *task) | ||
| 2078 | { | ||
| 2079 | if (task_css_is_root(task, cpuset_cgrp_id)) | ||
| 2080 | return; | ||
| 2081 | |||
| 2082 | set_cpus_allowed_ptr(task, ¤t->cpus_allowed); | ||
| 2083 | task->mems_allowed = current->mems_allowed; | ||
| 2084 | } | ||
| 2085 | |||
| 2072 | struct cgroup_subsys cpuset_cgrp_subsys = { | 2086 | struct cgroup_subsys cpuset_cgrp_subsys = { |
| 2073 | .css_alloc = cpuset_css_alloc, | 2087 | .css_alloc = cpuset_css_alloc, |
| 2074 | .css_online = cpuset_css_online, | 2088 | .css_online = cpuset_css_online, |
| @@ -2079,6 +2093,7 @@ struct cgroup_subsys cpuset_cgrp_subsys = { | |||
| 2079 | .attach = cpuset_attach, | 2093 | .attach = cpuset_attach, |
| 2080 | .post_attach = cpuset_post_attach, | 2094 | .post_attach = cpuset_post_attach, |
| 2081 | .bind = cpuset_bind, | 2095 | .bind = cpuset_bind, |
| 2096 | .fork = cpuset_fork, | ||
| 2082 | .legacy_cftypes = files, | 2097 | .legacy_cftypes = files, |
| 2083 | .early_init = true, | 2098 | .early_init = true, |
| 2084 | }; | 2099 | }; |
diff --git a/kernel/events/core.c b/kernel/events/core.c index 5650f5317e0c..a54f2c2cdb20 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
| @@ -2496,11 +2496,11 @@ static int __perf_event_stop(void *info) | |||
| 2496 | return 0; | 2496 | return 0; |
| 2497 | } | 2497 | } |
| 2498 | 2498 | ||
| 2499 | static int perf_event_restart(struct perf_event *event) | 2499 | static int perf_event_stop(struct perf_event *event, int restart) |
| 2500 | { | 2500 | { |
| 2501 | struct stop_event_data sd = { | 2501 | struct stop_event_data sd = { |
| 2502 | .event = event, | 2502 | .event = event, |
| 2503 | .restart = 1, | 2503 | .restart = restart, |
| 2504 | }; | 2504 | }; |
| 2505 | int ret = 0; | 2505 | int ret = 0; |
| 2506 | 2506 | ||
| @@ -3549,10 +3549,18 @@ static int perf_event_read(struct perf_event *event, bool group) | |||
| 3549 | .group = group, | 3549 | .group = group, |
| 3550 | .ret = 0, | 3550 | .ret = 0, |
| 3551 | }; | 3551 | }; |
| 3552 | ret = smp_call_function_single(event->oncpu, __perf_event_read, &data, 1); | 3552 | /* |
| 3553 | /* The event must have been read from an online CPU: */ | 3553 | * Purposely ignore the smp_call_function_single() return |
| 3554 | WARN_ON_ONCE(ret); | 3554 | * value. |
| 3555 | ret = ret ? : data.ret; | 3555 | * |
| 3556 | * If event->oncpu isn't a valid CPU it means the event got | ||
| 3557 | * scheduled out and that will have updated the event count. | ||
| 3558 | * | ||
| 3559 | * Therefore, either way, we'll have an up-to-date event count | ||
| 3560 | * after this. | ||
| 3561 | */ | ||
| 3562 | (void)smp_call_function_single(event->oncpu, __perf_event_read, &data, 1); | ||
| 3563 | ret = data.ret; | ||
| 3556 | } else if (event->state == PERF_EVENT_STATE_INACTIVE) { | 3564 | } else if (event->state == PERF_EVENT_STATE_INACTIVE) { |
| 3557 | struct perf_event_context *ctx = event->ctx; | 3565 | struct perf_event_context *ctx = event->ctx; |
| 3558 | unsigned long flags; | 3566 | unsigned long flags; |
| @@ -4837,6 +4845,19 @@ static void ring_buffer_attach(struct perf_event *event, | |||
| 4837 | spin_unlock_irqrestore(&rb->event_lock, flags); | 4845 | spin_unlock_irqrestore(&rb->event_lock, flags); |
| 4838 | } | 4846 | } |
| 4839 | 4847 | ||
| 4848 | /* | ||
| 4849 | * Avoid racing with perf_mmap_close(AUX): stop the event | ||
| 4850 | * before swizzling the event::rb pointer; if it's getting | ||
| 4851 | * unmapped, its aux_mmap_count will be 0 and it won't | ||
| 4852 | * restart. See the comment in __perf_pmu_output_stop(). | ||
| 4853 | * | ||
| 4854 | * Data will inevitably be lost when set_output is done in | ||
| 4855 | * mid-air, but then again, whoever does it like this is | ||
| 4856 | * not in for the data anyway. | ||
| 4857 | */ | ||
| 4858 | if (has_aux(event)) | ||
| 4859 | perf_event_stop(event, 0); | ||
| 4860 | |||
| 4840 | rcu_assign_pointer(event->rb, rb); | 4861 | rcu_assign_pointer(event->rb, rb); |
| 4841 | 4862 | ||
| 4842 | if (old_rb) { | 4863 | if (old_rb) { |
| @@ -6112,7 +6133,7 @@ static void perf_event_addr_filters_exec(struct perf_event *event, void *data) | |||
| 6112 | raw_spin_unlock_irqrestore(&ifh->lock, flags); | 6133 | raw_spin_unlock_irqrestore(&ifh->lock, flags); |
| 6113 | 6134 | ||
| 6114 | if (restart) | 6135 | if (restart) |
| 6115 | perf_event_restart(event); | 6136 | perf_event_stop(event, 1); |
| 6116 | } | 6137 | } |
| 6117 | 6138 | ||
| 6118 | void perf_event_exec(void) | 6139 | void perf_event_exec(void) |
| @@ -6156,7 +6177,13 @@ static void __perf_event_output_stop(struct perf_event *event, void *data) | |||
| 6156 | 6177 | ||
| 6157 | /* | 6178 | /* |
| 6158 | * In case of inheritance, it will be the parent that links to the | 6179 | * In case of inheritance, it will be the parent that links to the |
| 6159 | * ring-buffer, but it will be the child that's actually using it: | 6180 | * ring-buffer, but it will be the child that's actually using it. |
| 6181 | * | ||
| 6182 | * We are using event::rb to determine if the event should be stopped, | ||
| 6183 | * however this may race with ring_buffer_attach() (through set_output), | ||
| 6184 | * which will make us skip the event that actually needs to be stopped. | ||
| 6185 | * So ring_buffer_attach() has to stop an aux event before re-assigning | ||
| 6186 | * its rb pointer. | ||
| 6160 | */ | 6187 | */ |
| 6161 | if (rcu_dereference(parent->rb) == rb) | 6188 | if (rcu_dereference(parent->rb) == rb) |
| 6162 | ro->err = __perf_event_stop(&sd); | 6189 | ro->err = __perf_event_stop(&sd); |
| @@ -6166,7 +6193,7 @@ static int __perf_pmu_output_stop(void *info) | |||
| 6166 | { | 6193 | { |
| 6167 | struct perf_event *event = info; | 6194 | struct perf_event *event = info; |
| 6168 | struct pmu *pmu = event->pmu; | 6195 | struct pmu *pmu = event->pmu; |
| 6169 | struct perf_cpu_context *cpuctx = get_cpu_ptr(pmu->pmu_cpu_context); | 6196 | struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context); |
| 6170 | struct remote_output ro = { | 6197 | struct remote_output ro = { |
| 6171 | .rb = event->rb, | 6198 | .rb = event->rb, |
| 6172 | }; | 6199 | }; |
| @@ -6670,7 +6697,7 @@ static void __perf_addr_filters_adjust(struct perf_event *event, void *data) | |||
| 6670 | raw_spin_unlock_irqrestore(&ifh->lock, flags); | 6697 | raw_spin_unlock_irqrestore(&ifh->lock, flags); |
| 6671 | 6698 | ||
| 6672 | if (restart) | 6699 | if (restart) |
| 6673 | perf_event_restart(event); | 6700 | perf_event_stop(event, 1); |
| 6674 | } | 6701 | } |
| 6675 | 6702 | ||
| 6676 | /* | 6703 | /* |
| @@ -7859,7 +7886,7 @@ static void perf_event_addr_filters_apply(struct perf_event *event) | |||
| 7859 | mmput(mm); | 7886 | mmput(mm); |
| 7860 | 7887 | ||
| 7861 | restart: | 7888 | restart: |
| 7862 | perf_event_restart(event); | 7889 | perf_event_stop(event, 1); |
| 7863 | } | 7890 | } |
| 7864 | 7891 | ||
| 7865 | /* | 7892 | /* |
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index ae9b90dc9a5a..257fa460b846 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c | |||
| @@ -330,15 +330,22 @@ void *perf_aux_output_begin(struct perf_output_handle *handle, | |||
| 330 | if (!rb) | 330 | if (!rb) |
| 331 | return NULL; | 331 | return NULL; |
| 332 | 332 | ||
| 333 | if (!rb_has_aux(rb) || !atomic_inc_not_zero(&rb->aux_refcount)) | 333 | if (!rb_has_aux(rb)) |
| 334 | goto err; | 334 | goto err; |
| 335 | 335 | ||
| 336 | /* | 336 | /* |
| 337 | * If rb::aux_mmap_count is zero (and rb_has_aux() above went through), | 337 | * If aux_mmap_count is zero, the aux buffer is in perf_mmap_close(), |
| 338 | * the aux buffer is in perf_mmap_close(), about to get freed. | 338 | * about to get freed, so we leave immediately. |
| 339 | * | ||
| 340 | * Checking rb::aux_mmap_count and rb::refcount has to be done in | ||
| 341 | * the same order, see perf_mmap_close. Otherwise we end up freeing | ||
| 342 | * aux pages in this path, which is a bug, because in_atomic(). | ||
| 339 | */ | 343 | */ |
| 340 | if (!atomic_read(&rb->aux_mmap_count)) | 344 | if (!atomic_read(&rb->aux_mmap_count)) |
| 341 | goto err_put; | 345 | goto err; |
| 346 | |||
| 347 | if (!atomic_inc_not_zero(&rb->aux_refcount)) | ||
| 348 | goto err; | ||
| 342 | 349 | ||
| 343 | /* | 350 | /* |
| 344 | * Nesting is not supported for AUX area, make sure nested | 351 | * Nesting is not supported for AUX area, make sure nested |
diff --git a/kernel/exit.c b/kernel/exit.c index 2f974ae042a6..091a78be3b09 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
| @@ -848,12 +848,7 @@ void do_exit(long code) | |||
| 848 | TASKS_RCU(preempt_enable()); | 848 | TASKS_RCU(preempt_enable()); |
| 849 | exit_notify(tsk, group_dead); | 849 | exit_notify(tsk, group_dead); |
| 850 | proc_exit_connector(tsk); | 850 | proc_exit_connector(tsk); |
| 851 | #ifdef CONFIG_NUMA | 851 | mpol_put_task_policy(tsk); |
| 852 | task_lock(tsk); | ||
| 853 | mpol_put(tsk->mempolicy); | ||
| 854 | tsk->mempolicy = NULL; | ||
| 855 | task_unlock(tsk); | ||
| 856 | #endif | ||
| 857 | #ifdef CONFIG_FUTEX | 852 | #ifdef CONFIG_FUTEX |
| 858 | if (unlikely(current->pi_state_cache)) | 853 | if (unlikely(current->pi_state_cache)) |
| 859 | kfree(current->pi_state_cache); | 854 | kfree(current->pi_state_cache); |
diff --git a/kernel/fork.c b/kernel/fork.c index 52e725d4a866..beb31725f7e2 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
| @@ -799,6 +799,29 @@ struct file *get_mm_exe_file(struct mm_struct *mm) | |||
| 799 | EXPORT_SYMBOL(get_mm_exe_file); | 799 | EXPORT_SYMBOL(get_mm_exe_file); |
| 800 | 800 | ||
| 801 | /** | 801 | /** |
| 802 | * get_task_exe_file - acquire a reference to the task's executable file | ||
| 803 | * | ||
| 804 | * Returns %NULL if task's mm (if any) has no associated executable file or | ||
| 805 | * this is a kernel thread with borrowed mm (see the comment above get_task_mm). | ||
| 806 | * User must release file via fput(). | ||
| 807 | */ | ||
| 808 | struct file *get_task_exe_file(struct task_struct *task) | ||
| 809 | { | ||
| 810 | struct file *exe_file = NULL; | ||
| 811 | struct mm_struct *mm; | ||
| 812 | |||
| 813 | task_lock(task); | ||
| 814 | mm = task->mm; | ||
| 815 | if (mm) { | ||
| 816 | if (!(task->flags & PF_KTHREAD)) | ||
| 817 | exe_file = get_mm_exe_file(mm); | ||
| 818 | } | ||
| 819 | task_unlock(task); | ||
| 820 | return exe_file; | ||
| 821 | } | ||
| 822 | EXPORT_SYMBOL(get_task_exe_file); | ||
| 823 | |||
| 824 | /** | ||
| 802 | * get_task_mm - acquire a reference to the task's mm | 825 | * get_task_mm - acquire a reference to the task's mm |
| 803 | * | 826 | * |
| 804 | * Returns %NULL if the task has no mm. Checks PF_KTHREAD (meaning | 827 | * Returns %NULL if the task has no mm. Checks PF_KTHREAD (meaning |
| @@ -913,14 +936,12 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm) | |||
| 913 | deactivate_mm(tsk, mm); | 936 | deactivate_mm(tsk, mm); |
| 914 | 937 | ||
| 915 | /* | 938 | /* |
| 916 | * If we're exiting normally, clear a user-space tid field if | 939 | * Signal userspace if we're not exiting with a core dump |
| 917 | * requested. We leave this alone when dying by signal, to leave | 940 | * because we want to leave the value intact for debugging |
| 918 | * the value intact in a core dump, and to save the unnecessary | 941 | * purposes. |
| 919 | * trouble, say, a killed vfork parent shouldn't touch this mm. | ||
| 920 | * Userland only wants this done for a sys_exit. | ||
| 921 | */ | 942 | */ |
| 922 | if (tsk->clear_child_tid) { | 943 | if (tsk->clear_child_tid) { |
| 923 | if (!(tsk->flags & PF_SIGNALED) && | 944 | if (!(tsk->signal->flags & SIGNAL_GROUP_COREDUMP) && |
| 924 | atomic_read(&mm->mm_users) > 1) { | 945 | atomic_read(&mm->mm_users) > 1) { |
| 925 | /* | 946 | /* |
| 926 | * We don't check the error code - if userspace has | 947 | * We don't check the error code - if userspace has |
| @@ -1404,7 +1425,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1404 | p->real_start_time = ktime_get_boot_ns(); | 1425 | p->real_start_time = ktime_get_boot_ns(); |
| 1405 | p->io_context = NULL; | 1426 | p->io_context = NULL; |
| 1406 | p->audit_context = NULL; | 1427 | p->audit_context = NULL; |
| 1407 | threadgroup_change_begin(current); | ||
| 1408 | cgroup_fork(p); | 1428 | cgroup_fork(p); |
| 1409 | #ifdef CONFIG_NUMA | 1429 | #ifdef CONFIG_NUMA |
| 1410 | p->mempolicy = mpol_dup(p->mempolicy); | 1430 | p->mempolicy = mpol_dup(p->mempolicy); |
| @@ -1556,6 +1576,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1556 | INIT_LIST_HEAD(&p->thread_group); | 1576 | INIT_LIST_HEAD(&p->thread_group); |
| 1557 | p->task_works = NULL; | 1577 | p->task_works = NULL; |
| 1558 | 1578 | ||
| 1579 | threadgroup_change_begin(current); | ||
| 1559 | /* | 1580 | /* |
| 1560 | * Ensure that the cgroup subsystem policies allow the new process to be | 1581 | * Ensure that the cgroup subsystem policies allow the new process to be |
| 1561 | * forked. It should be noted the the new process's css_set can be changed | 1582 | * forked. It should be noted the the new process's css_set can be changed |
| @@ -1656,6 +1677,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1656 | bad_fork_cancel_cgroup: | 1677 | bad_fork_cancel_cgroup: |
| 1657 | cgroup_cancel_fork(p); | 1678 | cgroup_cancel_fork(p); |
| 1658 | bad_fork_free_pid: | 1679 | bad_fork_free_pid: |
| 1680 | threadgroup_change_end(current); | ||
| 1659 | if (pid != &init_struct_pid) | 1681 | if (pid != &init_struct_pid) |
| 1660 | free_pid(pid); | 1682 | free_pid(pid); |
| 1661 | bad_fork_cleanup_thread: | 1683 | bad_fork_cleanup_thread: |
| @@ -1688,7 +1710,6 @@ bad_fork_cleanup_policy: | |||
| 1688 | mpol_put(p->mempolicy); | 1710 | mpol_put(p->mempolicy); |
| 1689 | bad_fork_cleanup_threadgroup_lock: | 1711 | bad_fork_cleanup_threadgroup_lock: |
| 1690 | #endif | 1712 | #endif |
| 1691 | threadgroup_change_end(current); | ||
| 1692 | delayacct_tsk_free(p); | 1713 | delayacct_tsk_free(p); |
| 1693 | bad_fork_cleanup_count: | 1714 | bad_fork_cleanup_count: |
| 1694 | atomic_dec(&p->cred->user->processes); | 1715 | atomic_dec(&p->cred->user->processes); |
diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index f68959341c0f..32f6cfcff212 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c | |||
| @@ -39,6 +39,7 @@ struct cpumask *irq_create_affinity_mask(unsigned int *nr_vecs) | |||
| 39 | return NULL; | 39 | return NULL; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | get_online_cpus(); | ||
| 42 | if (max_vecs >= num_online_cpus()) { | 43 | if (max_vecs >= num_online_cpus()) { |
| 43 | cpumask_copy(affinity_mask, cpu_online_mask); | 44 | cpumask_copy(affinity_mask, cpu_online_mask); |
| 44 | *nr_vecs = num_online_cpus(); | 45 | *nr_vecs = num_online_cpus(); |
| @@ -56,6 +57,7 @@ struct cpumask *irq_create_affinity_mask(unsigned int *nr_vecs) | |||
| 56 | } | 57 | } |
| 57 | *nr_vecs = vecs; | 58 | *nr_vecs = vecs; |
| 58 | } | 59 | } |
| 60 | put_online_cpus(); | ||
| 59 | 61 | ||
| 60 | return affinity_mask; | 62 | return affinity_mask; |
| 61 | } | 63 | } |
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index b4c1bc7c9ca2..637389088b3f 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c | |||
| @@ -820,6 +820,17 @@ __irq_do_set_handler(struct irq_desc *desc, irq_flow_handler_t handle, | |||
| 820 | desc->name = name; | 820 | desc->name = name; |
| 821 | 821 | ||
| 822 | if (handle != handle_bad_irq && is_chained) { | 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 | irq_settings_set_noprobe(desc); | 834 | irq_settings_set_noprobe(desc); |
| 824 | irq_settings_set_norequest(desc); | 835 | irq_settings_set_norequest(desc); |
| 825 | irq_settings_set_nothread(desc); | 836 | irq_settings_set_nothread(desc); |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 73a2b786b5e9..9530fcd27704 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
| @@ -1681,8 +1681,10 @@ int request_threaded_irq(unsigned int irq, irq_handler_t handler, | |||
| 1681 | action->dev_id = dev_id; | 1681 | action->dev_id = dev_id; |
| 1682 | 1682 | ||
| 1683 | retval = irq_chip_pm_get(&desc->irq_data); | 1683 | retval = irq_chip_pm_get(&desc->irq_data); |
| 1684 | if (retval < 0) | 1684 | if (retval < 0) { |
| 1685 | kfree(action); | ||
| 1685 | return retval; | 1686 | return retval; |
| 1687 | } | ||
| 1686 | 1688 | ||
| 1687 | chip_bus_lock(desc); | 1689 | chip_bus_lock(desc); |
| 1688 | retval = __setup_irq(irq, desc, action); | 1690 | retval = __setup_irq(irq, desc, action); |
| @@ -1985,8 +1987,10 @@ int request_percpu_irq(unsigned int irq, irq_handler_t handler, | |||
| 1985 | action->percpu_dev_id = dev_id; | 1987 | action->percpu_dev_id = dev_id; |
| 1986 | 1988 | ||
| 1987 | retval = irq_chip_pm_get(&desc->irq_data); | 1989 | retval = irq_chip_pm_get(&desc->irq_data); |
| 1988 | if (retval < 0) | 1990 | if (retval < 0) { |
| 1991 | kfree(action); | ||
| 1989 | return retval; | 1992 | return retval; |
| 1993 | } | ||
| 1990 | 1994 | ||
| 1991 | chip_bus_lock(desc); | 1995 | chip_bus_lock(desc); |
| 1992 | retval = __setup_irq(irq, desc, action); | 1996 | retval = __setup_irq(irq, desc, action); |
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 503bc2d348e5..037c321c5618 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c | |||
| @@ -887,7 +887,10 @@ int kexec_load_purgatory(struct kimage *image, unsigned long min, | |||
| 887 | return 0; | 887 | return 0; |
| 888 | out: | 888 | out: |
| 889 | vfree(pi->sechdrs); | 889 | vfree(pi->sechdrs); |
| 890 | pi->sechdrs = NULL; | ||
| 891 | |||
| 890 | vfree(pi->purgatory_buf); | 892 | vfree(pi->purgatory_buf); |
| 893 | pi->purgatory_buf = NULL; | ||
| 891 | return ret; | 894 | return ret; |
| 892 | } | 895 | } |
| 893 | 896 | ||
diff --git a/kernel/memremap.c b/kernel/memremap.c index 251d16b4cb41..b501e390bb34 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c | |||
| @@ -247,6 +247,7 @@ static void devm_memremap_pages_release(struct device *dev, void *data) | |||
| 247 | align_start = res->start & ~(SECTION_SIZE - 1); | 247 | align_start = res->start & ~(SECTION_SIZE - 1); |
| 248 | align_size = ALIGN(resource_size(res), SECTION_SIZE); | 248 | align_size = ALIGN(resource_size(res), SECTION_SIZE); |
| 249 | arch_remove_memory(align_start, align_size); | 249 | arch_remove_memory(align_start, align_size); |
| 250 | untrack_pfn(NULL, PHYS_PFN(align_start), align_size); | ||
| 250 | pgmap_radix_release(res); | 251 | pgmap_radix_release(res); |
| 251 | dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc, | 252 | dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc, |
| 252 | "%s: failed to free all reserved pages\n", __func__); | 253 | "%s: failed to free all reserved pages\n", __func__); |
| @@ -282,6 +283,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, | |||
| 282 | struct percpu_ref *ref, struct vmem_altmap *altmap) | 283 | struct percpu_ref *ref, struct vmem_altmap *altmap) |
| 283 | { | 284 | { |
| 284 | resource_size_t key, align_start, align_size, align_end; | 285 | resource_size_t key, align_start, align_size, align_end; |
| 286 | pgprot_t pgprot = PAGE_KERNEL; | ||
| 285 | struct dev_pagemap *pgmap; | 287 | struct dev_pagemap *pgmap; |
| 286 | struct page_map *page_map; | 288 | struct page_map *page_map; |
| 287 | int error, nid, is_ram; | 289 | int error, nid, is_ram; |
| @@ -351,6 +353,11 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, | |||
| 351 | if (nid < 0) | 353 | if (nid < 0) |
| 352 | nid = numa_mem_id(); | 354 | nid = numa_mem_id(); |
| 353 | 355 | ||
| 356 | error = track_pfn_remap(NULL, &pgprot, PHYS_PFN(align_start), 0, | ||
| 357 | align_size); | ||
| 358 | if (error) | ||
| 359 | goto err_pfn_remap; | ||
| 360 | |||
| 354 | error = arch_add_memory(nid, align_start, align_size, true); | 361 | error = arch_add_memory(nid, align_start, align_size, true); |
| 355 | if (error) | 362 | if (error) |
| 356 | goto err_add_memory; | 363 | goto err_add_memory; |
| @@ -371,6 +378,8 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, | |||
| 371 | return __va(res->start); | 378 | return __va(res->start); |
| 372 | 379 | ||
| 373 | err_add_memory: | 380 | err_add_memory: |
| 381 | untrack_pfn(NULL, PHYS_PFN(align_start), align_size); | ||
| 382 | err_pfn_remap: | ||
| 374 | err_radix: | 383 | err_radix: |
| 375 | pgmap_radix_release(res); | 384 | pgmap_radix_release(res); |
| 376 | devres_free(page_map); | 385 | devres_free(page_map); |
diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 97b0df71303e..168ff442ebde 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c | |||
| @@ -482,7 +482,16 @@ void pm_qos_update_request(struct pm_qos_request *req, | |||
| 482 | return; | 482 | return; |
| 483 | } | 483 | } |
| 484 | 484 | ||
| 485 | cancel_delayed_work_sync(&req->work); | 485 | /* |
| 486 | * This function may be called very early during boot, for example, | ||
| 487 | * from of_clk_init(), where irq needs to stay disabled. | ||
| 488 | * cancel_delayed_work_sync() assumes that irq is enabled on | ||
| 489 | * invocation and re-enables it on return. Avoid calling it until | ||
| 490 | * workqueue is initialized. | ||
| 491 | */ | ||
| 492 | if (keventd_up()) | ||
| 493 | cancel_delayed_work_sync(&req->work); | ||
| 494 | |||
| 486 | __pm_qos_update_request(req, new_value); | 495 | __pm_qos_update_request(req, new_value); |
| 487 | } | 496 | } |
| 488 | EXPORT_SYMBOL_GPL(pm_qos_update_request); | 497 | EXPORT_SYMBOL_GPL(pm_qos_update_request); |
diff --git a/kernel/printk/braille.c b/kernel/printk/braille.c index 276762f3a460..d5760c42f042 100644 --- a/kernel/printk/braille.c +++ b/kernel/printk/braille.c | |||
| @@ -9,10 +9,10 @@ | |||
| 9 | 9 | ||
| 10 | char *_braille_console_setup(char **str, char **brl_options) | 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 | *brl_options = ""; | 13 | *brl_options = ""; |
| 14 | *str += 4; | 14 | *str += 4; |
| 15 | } else if (!memcmp(str, "brl=", 4)) { | 15 | } else if (!strncmp(*str, "brl=", 4)) { |
| 16 | *brl_options = *str + 4; | 16 | *brl_options = *str + 4; |
| 17 | *str = strchr(*brl_options, ','); | 17 | *str = strchr(*brl_options, ','); |
| 18 | if (!*str) | 18 | if (!*str) |
diff --git a/kernel/printk/nmi.c b/kernel/printk/nmi.c index b69eb8a2876f..16bab471c7e2 100644 --- a/kernel/printk/nmi.c +++ b/kernel/printk/nmi.c | |||
| @@ -99,27 +99,33 @@ again: | |||
| 99 | return add; | 99 | return add; |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | /* | 102 | static void printk_nmi_flush_line(const char *text, int len) |
| 103 | * printk one line from the temporary buffer from @start index until | ||
| 104 | * and including the @end index. | ||
| 105 | */ | ||
| 106 | static void print_nmi_seq_line(struct nmi_seq_buf *s, int start, int end) | ||
| 107 | { | 103 | { |
| 108 | const char *buf = s->buffer + start; | ||
| 109 | |||
| 110 | /* | 104 | /* |
| 111 | * The buffers are flushed in NMI only on panic. The messages must | 105 | * The buffers are flushed in NMI only on panic. The messages must |
| 112 | * go only into the ring buffer at this stage. Consoles will get | 106 | * go only into the ring buffer at this stage. Consoles will get |
| 113 | * explicitly called later when a crashdump is not generated. | 107 | * explicitly called later when a crashdump is not generated. |
| 114 | */ | 108 | */ |
| 115 | if (in_nmi()) | 109 | if (in_nmi()) |
| 116 | printk_deferred("%.*s", (end - start) + 1, buf); | 110 | printk_deferred("%.*s", len, text); |
| 117 | else | 111 | else |
| 118 | printk("%.*s", (end - start) + 1, buf); | 112 | printk("%.*s", len, text); |
| 119 | 113 | ||
| 120 | } | 114 | } |
| 121 | 115 | ||
| 122 | /* | 116 | /* |
| 117 | * printk one line from the temporary buffer from @start index until | ||
| 118 | * and including the @end index. | ||
| 119 | */ | ||
| 120 | static void printk_nmi_flush_seq_line(struct nmi_seq_buf *s, | ||
| 121 | int start, int end) | ||
| 122 | { | ||
| 123 | const char *buf = s->buffer + start; | ||
| 124 | |||
| 125 | printk_nmi_flush_line(buf, (end - start) + 1); | ||
| 126 | } | ||
| 127 | |||
| 128 | /* | ||
| 123 | * Flush data from the associated per_CPU buffer. The function | 129 | * Flush data from the associated per_CPU buffer. The function |
| 124 | * can be called either via IRQ work or independently. | 130 | * can be called either via IRQ work or independently. |
| 125 | */ | 131 | */ |
| @@ -150,9 +156,11 @@ more: | |||
| 150 | * the buffer an unexpected way. If we printed something then | 156 | * the buffer an unexpected way. If we printed something then |
| 151 | * @len must only increase. | 157 | * @len must only increase. |
| 152 | */ | 158 | */ |
| 153 | if (i && i >= len) | 159 | if (i && i >= len) { |
| 154 | pr_err("printk_nmi_flush: internal error: i=%d >= len=%zu\n", | 160 | const char *msg = "printk_nmi_flush: internal error\n"; |
| 155 | i, len); | 161 | |
| 162 | printk_nmi_flush_line(msg, strlen(msg)); | ||
| 163 | } | ||
| 156 | 164 | ||
| 157 | if (!len) | 165 | if (!len) |
| 158 | goto out; /* Someone else has already flushed the buffer. */ | 166 | goto out; /* Someone else has already flushed the buffer. */ |
| @@ -166,14 +174,14 @@ more: | |||
| 166 | /* Print line by line. */ | 174 | /* Print line by line. */ |
| 167 | for (; i < size; i++) { | 175 | for (; i < size; i++) { |
| 168 | if (s->buffer[i] == '\n') { | 176 | if (s->buffer[i] == '\n') { |
| 169 | print_nmi_seq_line(s, last_i, i); | 177 | printk_nmi_flush_seq_line(s, last_i, i); |
| 170 | last_i = i + 1; | 178 | last_i = i + 1; |
| 171 | } | 179 | } |
| 172 | } | 180 | } |
| 173 | /* Check if there was a partial line. */ | 181 | /* Check if there was a partial line. */ |
| 174 | if (last_i < size) { | 182 | if (last_i < size) { |
| 175 | print_nmi_seq_line(s, last_i, size - 1); | 183 | printk_nmi_flush_seq_line(s, last_i, size - 1); |
| 176 | pr_cont("\n"); | 184 | printk_nmi_flush_line("\n", strlen("\n")); |
| 177 | } | 185 | } |
| 178 | 186 | ||
| 179 | /* | 187 | /* |
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 2a906f20fba7..44817c640e99 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
| @@ -2016,6 +2016,28 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) | |||
| 2016 | success = 1; /* we're going to change ->state */ | 2016 | success = 1; /* we're going to change ->state */ |
| 2017 | cpu = task_cpu(p); | 2017 | cpu = task_cpu(p); |
| 2018 | 2018 | ||
| 2019 | /* | ||
| 2020 | * Ensure we load p->on_rq _after_ p->state, otherwise it would | ||
| 2021 | * be possible to, falsely, observe p->on_rq == 0 and get stuck | ||
| 2022 | * in smp_cond_load_acquire() below. | ||
| 2023 | * | ||
| 2024 | * sched_ttwu_pending() try_to_wake_up() | ||
| 2025 | * [S] p->on_rq = 1; [L] P->state | ||
| 2026 | * UNLOCK rq->lock -----. | ||
| 2027 | * \ | ||
| 2028 | * +--- RMB | ||
| 2029 | * schedule() / | ||
| 2030 | * LOCK rq->lock -----' | ||
| 2031 | * UNLOCK rq->lock | ||
| 2032 | * | ||
| 2033 | * [task p] | ||
| 2034 | * [S] p->state = UNINTERRUPTIBLE [L] p->on_rq | ||
| 2035 | * | ||
| 2036 | * Pairs with the UNLOCK+LOCK on rq->lock from the | ||
| 2037 | * last wakeup of our task and the schedule that got our task | ||
| 2038 | * current. | ||
| 2039 | */ | ||
| 2040 | smp_rmb(); | ||
| 2019 | if (p->on_rq && ttwu_remote(p, wake_flags)) | 2041 | if (p->on_rq && ttwu_remote(p, wake_flags)) |
| 2020 | goto stat; | 2042 | goto stat; |
| 2021 | 2043 | ||
diff --git a/kernel/seccomp.c b/kernel/seccomp.c index ef6c6c3f9d8a..0db7c8a2afe2 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c | |||
| @@ -605,12 +605,16 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd, | |||
| 605 | ptrace_event(PTRACE_EVENT_SECCOMP, data); | 605 | ptrace_event(PTRACE_EVENT_SECCOMP, data); |
| 606 | /* | 606 | /* |
| 607 | * The delivery of a fatal signal during event | 607 | * The delivery of a fatal signal during event |
| 608 | * notification may silently skip tracer notification. | 608 | * notification may silently skip tracer notification, |
| 609 | * Terminating the task now avoids executing a system | 609 | * which could leave us with a potentially unmodified |
| 610 | * call that may not be intended. | 610 | * syscall that the tracer would have liked to have |
| 611 | * changed. Since the process is about to die, we just | ||
| 612 | * force the syscall to be skipped and let the signal | ||
| 613 | * kill the process and correctly handle any tracer exit | ||
| 614 | * notifications. | ||
| 611 | */ | 615 | */ |
| 612 | if (fatal_signal_pending(current)) | 616 | if (fatal_signal_pending(current)) |
| 613 | do_exit(SIGSYS); | 617 | goto skip; |
| 614 | /* Check if the tracer forced the syscall to be skipped. */ | 618 | /* Check if the tracer forced the syscall to be skipped. */ |
| 615 | this_syscall = syscall_get_nr(current, task_pt_regs(current)); | 619 | this_syscall = syscall_get_nr(current, task_pt_regs(current)); |
| 616 | if (this_syscall < 0) | 620 | if (this_syscall < 0) |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index b43d0b27c1fe..a13bbdaab47d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
| @@ -2140,6 +2140,21 @@ static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, | |||
| 2140 | return 0; | 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 | static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; | 2158 | static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; |
| 2144 | 2159 | ||
| 2145 | static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, | 2160 | static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, |
| @@ -2259,8 +2274,27 @@ static int do_proc_dointvec(struct ctl_table *table, int write, | |||
| 2259 | int proc_dointvec(struct ctl_table *table, int write, | 2274 | int proc_dointvec(struct ctl_table *table, int write, |
| 2260 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2275 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2261 | { | 2276 | { |
| 2262 | return do_proc_dointvec(table,write,buffer,lenp,ppos, | 2277 | return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); |
| 2263 | NULL,NULL); | 2278 | } |
| 2279 | |||
| 2280 | /** | ||
| 2281 | * proc_douintvec - read a vector of unsigned integers | ||
| 2282 | * @table: the sysctl table | ||
| 2283 | * @write: %TRUE if this is a write to the sysctl file | ||
| 2284 | * @buffer: the user buffer | ||
| 2285 | * @lenp: the size of the user buffer | ||
| 2286 | * @ppos: file position | ||
| 2287 | * | ||
| 2288 | * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer | ||
| 2289 | * values from/to the user buffer, treated as an ASCII string. | ||
| 2290 | * | ||
| 2291 | * Returns 0 on success. | ||
| 2292 | */ | ||
| 2293 | int proc_douintvec(struct ctl_table *table, int write, | ||
| 2294 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
| 2295 | { | ||
| 2296 | return do_proc_dointvec(table, write, buffer, lenp, ppos, | ||
| 2297 | do_proc_douintvec_conv, NULL); | ||
| 2264 | } | 2298 | } |
| 2265 | 2299 | ||
| 2266 | /* | 2300 | /* |
| @@ -2858,6 +2892,12 @@ int proc_dointvec(struct ctl_table *table, int write, | |||
| 2858 | return -ENOSYS; | 2892 | return -ENOSYS; |
| 2859 | } | 2893 | } |
| 2860 | 2894 | ||
| 2895 | int proc_douintvec(struct ctl_table *table, int write, | ||
| 2896 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
| 2897 | { | ||
| 2898 | return -ENOSYS; | ||
| 2899 | } | ||
| 2900 | |||
| 2861 | int proc_dointvec_minmax(struct ctl_table *table, int write, | 2901 | int proc_dointvec_minmax(struct ctl_table *table, int write, |
| 2862 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2902 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2863 | { | 2903 | { |
| @@ -2903,6 +2943,7 @@ int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, | |||
| 2903 | * exception granted :-) | 2943 | * exception granted :-) |
| 2904 | */ | 2944 | */ |
| 2905 | EXPORT_SYMBOL(proc_dointvec); | 2945 | EXPORT_SYMBOL(proc_dointvec); |
| 2946 | EXPORT_SYMBOL(proc_douintvec); | ||
| 2906 | EXPORT_SYMBOL(proc_dointvec_jiffies); | 2947 | EXPORT_SYMBOL(proc_dointvec_jiffies); |
| 2907 | EXPORT_SYMBOL(proc_dointvec_minmax); | 2948 | EXPORT_SYMBOL(proc_dointvec_minmax); |
| 2908 | EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); | 2949 | EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); |
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 204fdc86863d..2ec7c00228f3 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c | |||
| @@ -908,10 +908,11 @@ static void __tick_nohz_idle_enter(struct tick_sched *ts) | |||
| 908 | ktime_t now, expires; | 908 | ktime_t now, expires; |
| 909 | int cpu = smp_processor_id(); | 909 | int cpu = smp_processor_id(); |
| 910 | 910 | ||
| 911 | now = tick_nohz_start_idle(ts); | ||
| 912 | |||
| 911 | if (can_stop_idle_tick(cpu, ts)) { | 913 | if (can_stop_idle_tick(cpu, ts)) { |
| 912 | int was_stopped = ts->tick_stopped; | 914 | int was_stopped = ts->tick_stopped; |
| 913 | 915 | ||
| 914 | now = tick_nohz_start_idle(ts); | ||
| 915 | ts->idle_calls++; | 916 | ts->idle_calls++; |
| 916 | 917 | ||
| 917 | expires = tick_nohz_stop_sched_tick(ts, now, cpu); | 918 | expires = tick_nohz_stop_sched_tick(ts, now, cpu); |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 3b65746c7f15..e07fb093f819 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
| @@ -401,7 +401,10 @@ static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf) | |||
| 401 | do { | 401 | do { |
| 402 | seq = raw_read_seqcount_latch(&tkf->seq); | 402 | seq = raw_read_seqcount_latch(&tkf->seq); |
| 403 | tkr = tkf->base + (seq & 0x01); | 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 | } while (read_seqcount_retry(&tkf->seq, seq)); | 408 | } while (read_seqcount_retry(&tkf->seq, seq)); |
| 406 | 409 | ||
| 407 | return now; | 410 | return now; |
diff --git a/kernel/time/timekeeping_debug.c b/kernel/time/timekeeping_debug.c index f6bd65236712..107310a6f36f 100644 --- a/kernel/time/timekeeping_debug.c +++ b/kernel/time/timekeeping_debug.c | |||
| @@ -23,7 +23,9 @@ | |||
| 23 | 23 | ||
| 24 | #include "timekeeping_internal.h" | 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 | static int tk_debug_show_sleep_time(struct seq_file *s, void *data) | 30 | static int tk_debug_show_sleep_time(struct seq_file *s, void *data) |
| 29 | { | 31 | { |
| @@ -69,6 +71,9 @@ late_initcall(tk_debug_sleep_time_init); | |||
| 69 | 71 | ||
| 70 | void tk_debug_account_sleep_time(struct timespec64 *t) | 72 | void tk_debug_account_sleep_time(struct timespec64 *t) |
| 71 | { | 73 | { |
| 72 | sleep_time_bin[fls(t->tv_sec)]++; | 74 | /* Cap bin index so we don't overflow the array */ |
| 75 | int bin = min(fls(t->tv_sec), NUM_BINS-1); | ||
| 76 | |||
| 77 | sleep_time_bin[bin]++; | ||
| 73 | } | 78 | } |
| 74 | 79 | ||
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 7598e6ca817a..dbafc5df03f3 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
| @@ -223,7 +223,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, | |||
| 223 | what |= MASK_TC_BIT(op_flags, META); | 223 | what |= MASK_TC_BIT(op_flags, META); |
| 224 | what |= MASK_TC_BIT(op_flags, PREFLUSH); | 224 | what |= MASK_TC_BIT(op_flags, PREFLUSH); |
| 225 | what |= MASK_TC_BIT(op_flags, FUA); | 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 | what |= BLK_TC_ACT(BLK_TC_DISCARD); | 227 | what |= BLK_TC_ACT(BLK_TC_DISCARD); |
| 228 | if (op == REQ_OP_FLUSH) | 228 | if (op == REQ_OP_FLUSH) |
| 229 | what |= BLK_TC_ACT(BLK_TC_FLUSH); | 229 | what |= BLK_TC_ACT(BLK_TC_FLUSH); |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 2307d7c89dac..2e2cca509231 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -1686,24 +1686,6 @@ config LATENCYTOP | |||
| 1686 | Enable this option if you want to use the LatencyTOP tool | 1686 | Enable this option if you want to use the LatencyTOP tool |
| 1687 | to find out which userspace is blocking on what kernel operations. | 1687 | to find out which userspace is blocking on what kernel operations. |
| 1688 | 1688 | ||
| 1689 | config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS | ||
| 1690 | bool | ||
| 1691 | |||
| 1692 | config DEBUG_STRICT_USER_COPY_CHECKS | ||
| 1693 | bool "Strict user copy size checks" | ||
| 1694 | depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS | ||
| 1695 | depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING | ||
| 1696 | help | ||
| 1697 | Enabling this option turns a certain set of sanity checks for user | ||
| 1698 | copy operations into compile time failures. | ||
| 1699 | |||
| 1700 | The copy_from_user() etc checks are there to help test if there | ||
| 1701 | are sufficient security checks on the length argument of | ||
| 1702 | the copy operation, by having gcc prove that the argument is | ||
| 1703 | within bounds. | ||
| 1704 | |||
| 1705 | If unsure, say N. | ||
| 1706 | |||
| 1707 | source kernel/trace/Kconfig | 1689 | source kernel/trace/Kconfig |
| 1708 | 1690 | ||
| 1709 | menu "Runtime Testing" | 1691 | menu "Runtime Testing" |
diff --git a/lib/Makefile b/lib/Makefile index cfa68eb269e4..5dc77a8ec297 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
| @@ -24,7 +24,6 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ | |||
| 24 | is_single_threaded.o plist.o decompress.o kobject_uevent.o \ | 24 | is_single_threaded.o plist.o decompress.o kobject_uevent.o \ |
| 25 | earlycpio.o seq_buf.o nmi_backtrace.o nodemask.o | 25 | earlycpio.o seq_buf.o nmi_backtrace.o nodemask.o |
| 26 | 26 | ||
| 27 | obj-$(CONFIG_ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS) += usercopy.o | ||
| 28 | lib-$(CONFIG_MMU) += ioremap.o | 27 | lib-$(CONFIG_MMU) += ioremap.o |
| 29 | lib-$(CONFIG_SMP) += cpumask.o | 28 | lib-$(CONFIG_SMP) += cpumask.o |
| 30 | lib-$(CONFIG_HAS_DMA) += dma-noop.o | 29 | lib-$(CONFIG_HAS_DMA) += dma-noop.o |
diff --git a/lib/rhashtable.c b/lib/rhashtable.c index 5ba520b544d7..56054e541a0f 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c | |||
| @@ -77,17 +77,18 @@ static int alloc_bucket_locks(struct rhashtable *ht, struct bucket_table *tbl, | |||
| 77 | size = min_t(unsigned int, size, tbl->size >> 1); | 77 | size = min_t(unsigned int, size, tbl->size >> 1); |
| 78 | 78 | ||
| 79 | if (sizeof(spinlock_t) != 0) { | 79 | if (sizeof(spinlock_t) != 0) { |
| 80 | tbl->locks = NULL; | ||
| 80 | #ifdef CONFIG_NUMA | 81 | #ifdef CONFIG_NUMA |
| 81 | if (size * sizeof(spinlock_t) > PAGE_SIZE && | 82 | if (size * sizeof(spinlock_t) > PAGE_SIZE && |
| 82 | gfp == GFP_KERNEL) | 83 | gfp == GFP_KERNEL) |
| 83 | tbl->locks = vmalloc(size * sizeof(spinlock_t)); | 84 | tbl->locks = vmalloc(size * sizeof(spinlock_t)); |
| 84 | else | ||
| 85 | #endif | 85 | #endif |
| 86 | if (gfp != GFP_KERNEL) | 86 | if (gfp != GFP_KERNEL) |
| 87 | gfp |= __GFP_NOWARN | __GFP_NORETRY; | 87 | gfp |= __GFP_NOWARN | __GFP_NORETRY; |
| 88 | 88 | ||
| 89 | tbl->locks = kmalloc_array(size, sizeof(spinlock_t), | 89 | if (!tbl->locks) |
| 90 | gfp); | 90 | tbl->locks = kmalloc_array(size, sizeof(spinlock_t), |
| 91 | gfp); | ||
| 91 | if (!tbl->locks) | 92 | if (!tbl->locks) |
| 92 | return -ENOMEM; | 93 | return -ENOMEM; |
| 93 | for (i = 0; i < size; i++) | 94 | for (i = 0; i < size; i++) |
diff --git a/lib/test_hash.c b/lib/test_hash.c index 66c5fc8351e8..cac20c5fb304 100644 --- a/lib/test_hash.c +++ b/lib/test_hash.c | |||
| @@ -143,7 +143,7 @@ static int __init | |||
| 143 | test_hash_init(void) | 143 | test_hash_init(void) |
| 144 | { | 144 | { |
| 145 | char buf[SIZE+1]; | 145 | char buf[SIZE+1]; |
| 146 | u32 string_or = 0, hash_or[2][33] = { 0 }; | 146 | u32 string_or = 0, hash_or[2][33] = { { 0, } }; |
| 147 | unsigned tests = 0; | 147 | unsigned tests = 0; |
| 148 | unsigned long long h64 = 0; | 148 | unsigned long long h64 = 0; |
| 149 | int i, j; | 149 | int i, j; |
| @@ -219,21 +219,27 @@ test_hash_init(void) | |||
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | /* Issue notices about skipped tests. */ | 221 | /* Issue notices about skipped tests. */ |
| 222 | #ifndef HAVE_ARCH__HASH_32 | 222 | #ifdef HAVE_ARCH__HASH_32 |
| 223 | pr_info("__hash_32() has no arch implementation to test."); | 223 | #if HAVE_ARCH__HASH_32 != 1 |
| 224 | #elif HAVE_ARCH__HASH_32 != 1 | ||
| 225 | pr_info("__hash_32() is arch-specific; not compared to generic."); | 224 | pr_info("__hash_32() is arch-specific; not compared to generic."); |
| 226 | #endif | 225 | #endif |
| 227 | #ifndef HAVE_ARCH_HASH_32 | 226 | #else |
| 228 | pr_info("hash_32() has no arch implementation to test."); | 227 | pr_info("__hash_32() has no arch implementation to test."); |
| 229 | #elif HAVE_ARCH_HASH_32 != 1 | 228 | #endif |
| 229 | #ifdef HAVE_ARCH_HASH_32 | ||
| 230 | #if HAVE_ARCH_HASH_32 != 1 | ||
| 230 | pr_info("hash_32() is arch-specific; not compared to generic."); | 231 | pr_info("hash_32() is arch-specific; not compared to generic."); |
| 231 | #endif | 232 | #endif |
| 232 | #ifndef HAVE_ARCH_HASH_64 | 233 | #else |
| 233 | pr_info("hash_64() has no arch implementation to test."); | 234 | pr_info("hash_32() has no arch implementation to test."); |
| 234 | #elif HAVE_ARCH_HASH_64 != 1 | 235 | #endif |
| 236 | #ifdef HAVE_ARCH_HASH_64 | ||
| 237 | #if HAVE_ARCH_HASH_64 != 1 | ||
| 235 | pr_info("hash_64() is arch-specific; not compared to generic."); | 238 | pr_info("hash_64() is arch-specific; not compared to generic."); |
| 236 | #endif | 239 | #endif |
| 240 | #else | ||
| 241 | pr_info("hash_64() has no arch implementation to test."); | ||
| 242 | #endif | ||
| 237 | 243 | ||
| 238 | pr_notice("%u tests passed.", tests); | 244 | pr_notice("%u tests passed.", tests); |
| 239 | 245 | ||
diff --git a/lib/usercopy.c b/lib/usercopy.c deleted file mode 100644 index 4f5b1ddbcd25..000000000000 --- a/lib/usercopy.c +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | #include <linux/export.h> | ||
| 2 | #include <linux/bug.h> | ||
| 3 | #include <linux/uaccess.h> | ||
| 4 | |||
| 5 | void copy_from_user_overflow(void) | ||
| 6 | { | ||
| 7 | WARN(1, "Buffer overflow detected!\n"); | ||
| 8 | } | ||
| 9 | EXPORT_SYMBOL(copy_from_user_overflow); | ||
diff --git a/mm/Kconfig b/mm/Kconfig index 78a23c5c302d..be0ee11fa0d9 100644 --- a/mm/Kconfig +++ b/mm/Kconfig | |||
| @@ -262,7 +262,14 @@ config COMPACTION | |||
| 262 | select MIGRATION | 262 | select MIGRATION |
| 263 | depends on MMU | 263 | depends on MMU |
| 264 | help | 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 | # support for page migration | 275 | # support for page migration |
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 2373f0a7d340..a6abd76baa72 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
| @@ -1078,7 +1078,7 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma, | |||
| 1078 | goto out; | 1078 | goto out; |
| 1079 | 1079 | ||
| 1080 | page = pmd_page(*pmd); | 1080 | page = pmd_page(*pmd); |
| 1081 | VM_BUG_ON_PAGE(!PageHead(page), page); | 1081 | VM_BUG_ON_PAGE(!PageHead(page) && !is_zone_device_page(page), page); |
| 1082 | if (flags & FOLL_TOUCH) | 1082 | if (flags & FOLL_TOUCH) |
| 1083 | touch_pmd(vma, addr, pmd); | 1083 | touch_pmd(vma, addr, pmd); |
| 1084 | if ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) { | 1084 | if ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) { |
| @@ -1116,7 +1116,7 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma, | |||
| 1116 | } | 1116 | } |
| 1117 | skip_mlock: | 1117 | skip_mlock: |
| 1118 | page += (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT; | 1118 | page += (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT; |
| 1119 | VM_BUG_ON_PAGE(!PageCompound(page), page); | 1119 | VM_BUG_ON_PAGE(!PageCompound(page) && !is_zone_device_page(page), page); |
| 1120 | if (flags & FOLL_GET) | 1120 | if (flags & FOLL_GET) |
| 1121 | get_page(page); | 1121 | get_page(page); |
| 1122 | 1122 | ||
| @@ -1512,7 +1512,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, | |||
| 1512 | struct page *page; | 1512 | struct page *page; |
| 1513 | pgtable_t pgtable; | 1513 | pgtable_t pgtable; |
| 1514 | pmd_t _pmd; | 1514 | pmd_t _pmd; |
| 1515 | bool young, write, dirty; | 1515 | bool young, write, dirty, soft_dirty; |
| 1516 | unsigned long addr; | 1516 | unsigned long addr; |
| 1517 | int i; | 1517 | int i; |
| 1518 | 1518 | ||
| @@ -1546,6 +1546,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, | |||
| 1546 | write = pmd_write(*pmd); | 1546 | write = pmd_write(*pmd); |
| 1547 | young = pmd_young(*pmd); | 1547 | young = pmd_young(*pmd); |
| 1548 | dirty = pmd_dirty(*pmd); | 1548 | dirty = pmd_dirty(*pmd); |
| 1549 | soft_dirty = pmd_soft_dirty(*pmd); | ||
| 1549 | 1550 | ||
| 1550 | pmdp_huge_split_prepare(vma, haddr, pmd); | 1551 | pmdp_huge_split_prepare(vma, haddr, pmd); |
| 1551 | pgtable = pgtable_trans_huge_withdraw(mm, pmd); | 1552 | pgtable = pgtable_trans_huge_withdraw(mm, pmd); |
| @@ -1562,6 +1563,8 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, | |||
| 1562 | swp_entry_t swp_entry; | 1563 | swp_entry_t swp_entry; |
| 1563 | swp_entry = make_migration_entry(page + i, write); | 1564 | swp_entry = make_migration_entry(page + i, write); |
| 1564 | entry = swp_entry_to_pte(swp_entry); | 1565 | entry = swp_entry_to_pte(swp_entry); |
| 1566 | if (soft_dirty) | ||
| 1567 | entry = pte_swp_mksoft_dirty(entry); | ||
| 1565 | } else { | 1568 | } else { |
| 1566 | entry = mk_pte(page + i, vma->vm_page_prot); | 1569 | entry = mk_pte(page + i, vma->vm_page_prot); |
| 1567 | entry = maybe_mkwrite(entry, vma); | 1570 | entry = maybe_mkwrite(entry, vma); |
| @@ -1569,6 +1572,8 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, | |||
| 1569 | entry = pte_wrprotect(entry); | 1572 | entry = pte_wrprotect(entry); |
| 1570 | if (!young) | 1573 | if (!young) |
| 1571 | entry = pte_mkold(entry); | 1574 | entry = pte_mkold(entry); |
| 1575 | if (soft_dirty) | ||
| 1576 | entry = pte_mksoft_dirty(entry); | ||
| 1572 | } | 1577 | } |
| 1573 | if (dirty) | 1578 | if (dirty) |
| 1574 | SetPageDirty(page + i); | 1579 | SetPageDirty(page + i); |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2ff0289ad061..9a6a51a7c416 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
| @@ -4082,24 +4082,6 @@ static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n) | |||
| 4082 | atomic_add(n, &memcg->id.ref); | 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 | static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n) | 4085 | static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n) |
| 4104 | { | 4086 | { |
| 4105 | if (atomic_sub_and_test(n, &memcg->id.ref)) { | 4087 | if (atomic_sub_and_test(n, &memcg->id.ref)) { |
| @@ -5821,6 +5803,24 @@ static int __init mem_cgroup_init(void) | |||
| 5821 | subsys_initcall(mem_cgroup_init); | 5803 | subsys_initcall(mem_cgroup_init); |
| 5822 | 5804 | ||
| 5823 | #ifdef CONFIG_MEMCG_SWAP | 5805 | #ifdef CONFIG_MEMCG_SWAP |
| 5806 | static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg) | ||
| 5807 | { | ||
| 5808 | while (!atomic_inc_not_zero(&memcg->id.ref)) { | ||
| 5809 | /* | ||
| 5810 | * The root cgroup cannot be destroyed, so it's refcount must | ||
| 5811 | * always be >= 1. | ||
| 5812 | */ | ||
| 5813 | if (WARN_ON_ONCE(memcg == root_mem_cgroup)) { | ||
| 5814 | VM_BUG_ON(1); | ||
| 5815 | break; | ||
| 5816 | } | ||
| 5817 | memcg = parent_mem_cgroup(memcg); | ||
| 5818 | if (!memcg) | ||
| 5819 | memcg = root_mem_cgroup; | ||
| 5820 | } | ||
| 5821 | return memcg; | ||
| 5822 | } | ||
| 5823 | |||
| 5824 | /** | 5824 | /** |
| 5825 | * mem_cgroup_swapout - transfer a memsw charge to swap | 5825 | * mem_cgroup_swapout - transfer a memsw charge to swap |
| 5826 | * @page: page whose memsw charge to transfer | 5826 | * @page: page whose memsw charge to transfer |
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index d8c4e38fb5f4..2da72a5b6ecc 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
| @@ -2336,6 +2336,23 @@ out: | |||
| 2336 | return ret; | 2336 | return ret; |
| 2337 | } | 2337 | } |
| 2338 | 2338 | ||
| 2339 | /* | ||
| 2340 | * Drop the (possibly final) reference to task->mempolicy. It needs to be | ||
| 2341 | * dropped after task->mempolicy is set to NULL so that any allocation done as | ||
| 2342 | * part of its kmem_cache_free(), such as by KASAN, doesn't reference a freed | ||
| 2343 | * policy. | ||
| 2344 | */ | ||
| 2345 | void mpol_put_task_policy(struct task_struct *task) | ||
| 2346 | { | ||
| 2347 | struct mempolicy *pol; | ||
| 2348 | |||
| 2349 | task_lock(task); | ||
| 2350 | pol = task->mempolicy; | ||
| 2351 | task->mempolicy = NULL; | ||
| 2352 | task_unlock(task); | ||
| 2353 | mpol_put(pol); | ||
| 2354 | } | ||
| 2355 | |||
| 2339 | static void sp_delete(struct shared_policy *sp, struct sp_node *n) | 2356 | static void sp_delete(struct shared_policy *sp, struct sp_node *n) |
| 2340 | { | 2357 | { |
| 2341 | pr_debug("deleting %lx-l%lx\n", n->start, n->end); | 2358 | pr_debug("deleting %lx-l%lx\n", n->start, n->end); |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3fbe73a6fe4b..a2214c64ed3c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
| @@ -3137,54 +3137,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, | |||
| 3137 | return NULL; | 3137 | return NULL; |
| 3138 | } | 3138 | } |
| 3139 | 3139 | ||
| 3140 | static inline bool | ||
| 3141 | should_compact_retry(struct alloc_context *ac, int order, int alloc_flags, | ||
| 3142 | enum compact_result compact_result, | ||
| 3143 | enum compact_priority *compact_priority, | ||
| 3144 | int compaction_retries) | ||
| 3145 | { | ||
| 3146 | int max_retries = MAX_COMPACT_RETRIES; | ||
| 3147 | |||
| 3148 | if (!order) | ||
| 3149 | return false; | ||
| 3150 | |||
| 3151 | /* | ||
| 3152 | * compaction considers all the zone as desperately out of memory | ||
| 3153 | * so it doesn't really make much sense to retry except when the | ||
| 3154 | * failure could be caused by insufficient priority | ||
| 3155 | */ | ||
| 3156 | if (compaction_failed(compact_result)) { | ||
| 3157 | if (*compact_priority > MIN_COMPACT_PRIORITY) { | ||
| 3158 | (*compact_priority)--; | ||
| 3159 | return true; | ||
| 3160 | } | ||
| 3161 | return false; | ||
| 3162 | } | ||
| 3163 | |||
| 3164 | /* | ||
| 3165 | * make sure the compaction wasn't deferred or didn't bail out early | ||
| 3166 | * due to locks contention before we declare that we should give up. | ||
| 3167 | * But do not retry if the given zonelist is not suitable for | ||
| 3168 | * compaction. | ||
| 3169 | */ | ||
| 3170 | if (compaction_withdrawn(compact_result)) | ||
| 3171 | return compaction_zonelist_suitable(ac, order, alloc_flags); | ||
| 3172 | |||
| 3173 | /* | ||
| 3174 | * !costly requests are much more important than __GFP_REPEAT | ||
| 3175 | * costly ones because they are de facto nofail and invoke OOM | ||
| 3176 | * killer to move on while costly can fail and users are ready | ||
| 3177 | * to cope with that. 1/4 retries is rather arbitrary but we | ||
| 3178 | * would need much more detailed feedback from compaction to | ||
| 3179 | * make a better decision. | ||
| 3180 | */ | ||
| 3181 | if (order > PAGE_ALLOC_COSTLY_ORDER) | ||
| 3182 | max_retries /= 4; | ||
| 3183 | if (compaction_retries <= max_retries) | ||
| 3184 | return true; | ||
| 3185 | |||
| 3186 | return false; | ||
| 3187 | } | ||
| 3188 | #else | 3140 | #else |
| 3189 | static inline struct page * | 3141 | static inline struct page * |
| 3190 | __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, | 3142 | __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, |
| @@ -3195,6 +3147,8 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, | |||
| 3195 | return NULL; | 3147 | return NULL; |
| 3196 | } | 3148 | } |
| 3197 | 3149 | ||
| 3150 | #endif /* CONFIG_COMPACTION */ | ||
| 3151 | |||
| 3198 | static inline bool | 3152 | static inline bool |
| 3199 | should_compact_retry(struct alloc_context *ac, unsigned int order, int alloc_flags, | 3153 | should_compact_retry(struct alloc_context *ac, unsigned int order, int alloc_flags, |
| 3200 | enum compact_result compact_result, | 3154 | enum compact_result compact_result, |
| @@ -3221,7 +3175,6 @@ should_compact_retry(struct alloc_context *ac, unsigned int order, int alloc_fla | |||
| 3221 | } | 3175 | } |
| 3222 | return false; | 3176 | return false; |
| 3223 | } | 3177 | } |
| 3224 | #endif /* CONFIG_COMPACTION */ | ||
| 3225 | 3178 | ||
| 3226 | /* Perform direct synchronous page reclaim */ | 3179 | /* Perform direct synchronous page reclaim */ |
| 3227 | static int | 3180 | static int |
| @@ -4407,7 +4360,7 @@ static int build_zonelists_node(pg_data_t *pgdat, struct zonelist *zonelist, | |||
| 4407 | do { | 4360 | do { |
| 4408 | zone_type--; | 4361 | zone_type--; |
| 4409 | zone = pgdat->node_zones + zone_type; | 4362 | zone = pgdat->node_zones + zone_type; |
| 4410 | if (populated_zone(zone)) { | 4363 | if (managed_zone(zone)) { |
| 4411 | zoneref_set_zone(zone, | 4364 | zoneref_set_zone(zone, |
| 4412 | &zonelist->_zonerefs[nr_zones++]); | 4365 | &zonelist->_zonerefs[nr_zones++]); |
| 4413 | check_highest_zone(zone_type); | 4366 | check_highest_zone(zone_type); |
| @@ -4645,7 +4598,7 @@ static void build_zonelists_in_zone_order(pg_data_t *pgdat, int nr_nodes) | |||
| 4645 | for (j = 0; j < nr_nodes; j++) { | 4598 | for (j = 0; j < nr_nodes; j++) { |
| 4646 | node = node_order[j]; | 4599 | node = node_order[j]; |
| 4647 | z = &NODE_DATA(node)->node_zones[zone_type]; | 4600 | z = &NODE_DATA(node)->node_zones[zone_type]; |
| 4648 | if (populated_zone(z)) { | 4601 | if (managed_zone(z)) { |
| 4649 | zoneref_set_zone(z, | 4602 | zoneref_set_zone(z, |
| 4650 | &zonelist->_zonerefs[pos++]); | 4603 | &zonelist->_zonerefs[pos++]); |
| 4651 | check_highest_zone(zone_type); | 4604 | check_highest_zone(zone_type); |
diff --git a/mm/readahead.c b/mm/readahead.c index 65ec288dc057..c8a955b1297e 100644 --- a/mm/readahead.c +++ b/mm/readahead.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
| 11 | #include <linux/dax.h> | ||
| 11 | #include <linux/gfp.h> | 12 | #include <linux/gfp.h> |
| 12 | #include <linux/export.h> | 13 | #include <linux/export.h> |
| 13 | #include <linux/blkdev.h> | 14 | #include <linux/blkdev.h> |
| @@ -544,6 +545,14 @@ do_readahead(struct address_space *mapping, struct file *filp, | |||
| 544 | if (!mapping || !mapping->a_ops) | 545 | if (!mapping || !mapping->a_ops) |
| 545 | return -EINVAL; | 546 | return -EINVAL; |
| 546 | 547 | ||
| 548 | /* | ||
| 549 | * Readahead doesn't make sense for DAX inodes, but we don't want it | ||
| 550 | * to report a failure either. Instead, we just return success and | ||
| 551 | * don't do any work. | ||
| 552 | */ | ||
| 553 | if (dax_mapping(mapping)) | ||
| 554 | return 0; | ||
| 555 | |||
| 547 | return force_page_cache_readahead(mapping, filp, index, nr); | 556 | return force_page_cache_readahead(mapping, filp, index, nr); |
| 548 | } | 557 | } |
| 549 | 558 | ||
diff --git a/mm/usercopy.c b/mm/usercopy.c index 8ebae91a6b55..089328f2b920 100644 --- a/mm/usercopy.c +++ b/mm/usercopy.c | |||
| @@ -83,7 +83,7 @@ static bool overlaps(const void *ptr, unsigned long n, unsigned long low, | |||
| 83 | unsigned long check_high = check_low + n; | 83 | unsigned long check_high = check_low + n; |
| 84 | 84 | ||
| 85 | /* Does not overlap if entirely above or entirely below. */ | 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 | return false; | 87 | return false; |
| 88 | 88 | ||
| 89 | return true; | 89 | return true; |
| @@ -124,7 +124,7 @@ static inline const char *check_kernel_text_object(const void *ptr, | |||
| 124 | static inline const char *check_bogus_address(const void *ptr, unsigned long n) | 124 | static inline const char *check_bogus_address(const void *ptr, unsigned long n) |
| 125 | { | 125 | { |
| 126 | /* Reject if object wraps past end of memory. */ | 126 | /* Reject if object wraps past end of memory. */ |
| 127 | if (ptr + n < ptr) | 127 | if ((unsigned long)ptr + n < (unsigned long)ptr) |
| 128 | return "<wrapped address>"; | 128 | return "<wrapped address>"; |
| 129 | 129 | ||
| 130 | /* Reject if NULL or ZERO-allocation. */ | 130 | /* Reject if NULL or ZERO-allocation. */ |
| @@ -134,31 +134,16 @@ static inline const char *check_bogus_address(const void *ptr, unsigned long n) | |||
| 134 | return NULL; | 134 | return NULL; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | static inline const char *check_heap_object(const void *ptr, unsigned long n, | 137 | /* Checks for allocs that are marked in some way as spanning multiple pages. */ |
| 138 | bool to_user) | 138 | static inline const char *check_page_span(const void *ptr, unsigned long n, |
| 139 | struct page *page, bool to_user) | ||
| 139 | { | 140 | { |
| 140 | struct page *page, *endpage; | 141 | #ifdef CONFIG_HARDENED_USERCOPY_PAGESPAN |
| 141 | const void *end = ptr + n - 1; | 142 | const void *end = ptr + n - 1; |
| 143 | struct page *endpage; | ||
| 142 | bool is_reserved, is_cma; | 144 | bool is_reserved, is_cma; |
| 143 | 145 | ||
| 144 | /* | 146 | /* |
| 145 | * Some architectures (arm64) return true for virt_addr_valid() on | ||
| 146 | * vmalloced addresses. Work around this by checking for vmalloc | ||
| 147 | * first. | ||
| 148 | */ | ||
| 149 | if (is_vmalloc_addr(ptr)) | ||
| 150 | return NULL; | ||
| 151 | |||
| 152 | if (!virt_addr_valid(ptr)) | ||
| 153 | return NULL; | ||
| 154 | |||
| 155 | page = virt_to_head_page(ptr); | ||
| 156 | |||
| 157 | /* Check slab allocator for flags and size. */ | ||
| 158 | if (PageSlab(page)) | ||
| 159 | return __check_heap_object(ptr, n, page); | ||
| 160 | |||
| 161 | /* | ||
| 162 | * Sometimes the kernel data regions are not marked Reserved (see | 147 | * Sometimes the kernel data regions are not marked Reserved (see |
| 163 | * check below). And sometimes [_sdata,_edata) does not cover | 148 | * check below). And sometimes [_sdata,_edata) does not cover |
| 164 | * rodata and/or bss, so check each range explicitly. | 149 | * rodata and/or bss, so check each range explicitly. |
| @@ -186,7 +171,7 @@ static inline const char *check_heap_object(const void *ptr, unsigned long n, | |||
| 186 | ((unsigned long)end & (unsigned long)PAGE_MASK))) | 171 | ((unsigned long)end & (unsigned long)PAGE_MASK))) |
| 187 | return NULL; | 172 | return NULL; |
| 188 | 173 | ||
| 189 | /* Allow if start and end are inside the same compound page. */ | 174 | /* Allow if fully inside the same compound (__GFP_COMP) page. */ |
| 190 | endpage = virt_to_head_page(end); | 175 | endpage = virt_to_head_page(end); |
| 191 | if (likely(endpage == page)) | 176 | if (likely(endpage == page)) |
| 192 | return NULL; | 177 | return NULL; |
| @@ -199,20 +184,44 @@ static inline const char *check_heap_object(const void *ptr, unsigned long n, | |||
| 199 | is_reserved = PageReserved(page); | 184 | is_reserved = PageReserved(page); |
| 200 | is_cma = is_migrate_cma_page(page); | 185 | is_cma = is_migrate_cma_page(page); |
| 201 | if (!is_reserved && !is_cma) | 186 | if (!is_reserved && !is_cma) |
| 202 | goto reject; | 187 | return "<spans multiple pages>"; |
| 203 | 188 | ||
| 204 | for (ptr += PAGE_SIZE; ptr <= end; ptr += PAGE_SIZE) { | 189 | for (ptr += PAGE_SIZE; ptr <= end; ptr += PAGE_SIZE) { |
| 205 | page = virt_to_head_page(ptr); | 190 | page = virt_to_head_page(ptr); |
| 206 | if (is_reserved && !PageReserved(page)) | 191 | if (is_reserved && !PageReserved(page)) |
| 207 | goto reject; | 192 | return "<spans Reserved and non-Reserved pages>"; |
| 208 | if (is_cma && !is_migrate_cma_page(page)) | 193 | if (is_cma && !is_migrate_cma_page(page)) |
| 209 | goto reject; | 194 | return "<spans CMA and non-CMA pages>"; |
| 210 | } | 195 | } |
| 196 | #endif | ||
| 211 | 197 | ||
| 212 | return NULL; | 198 | return NULL; |
| 199 | } | ||
| 200 | |||
| 201 | static inline const char *check_heap_object(const void *ptr, unsigned long n, | ||
| 202 | bool to_user) | ||
| 203 | { | ||
| 204 | struct page *page; | ||
| 205 | |||
| 206 | /* | ||
| 207 | * Some architectures (arm64) return true for virt_addr_valid() on | ||
| 208 | * vmalloced addresses. Work around this by checking for vmalloc | ||
| 209 | * first. | ||
| 210 | */ | ||
| 211 | if (is_vmalloc_addr(ptr)) | ||
| 212 | return NULL; | ||
| 213 | |||
| 214 | if (!virt_addr_valid(ptr)) | ||
| 215 | return NULL; | ||
| 216 | |||
| 217 | page = virt_to_head_page(ptr); | ||
| 218 | |||
| 219 | /* Check slab allocator for flags and size. */ | ||
| 220 | if (PageSlab(page)) | ||
| 221 | return __check_heap_object(ptr, n, page); | ||
| 213 | 222 | ||
| 214 | reject: | 223 | /* Verify object does not incorrectly span multiple pages. */ |
| 215 | return "<spans multiple pages>"; | 224 | return check_page_span(ptr, n, page, to_user); |
| 216 | } | 225 | } |
| 217 | 226 | ||
| 218 | /* | 227 | /* |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 374d95d04178..b1e12a1ea9cf 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
| @@ -1665,7 +1665,7 @@ static bool inactive_reclaimable_pages(struct lruvec *lruvec, | |||
| 1665 | 1665 | ||
| 1666 | for (zid = sc->reclaim_idx; zid >= 0; zid--) { | 1666 | for (zid = sc->reclaim_idx; zid >= 0; zid--) { |
| 1667 | zone = &pgdat->node_zones[zid]; | 1667 | zone = &pgdat->node_zones[zid]; |
| 1668 | if (!populated_zone(zone)) | 1668 | if (!managed_zone(zone)) |
| 1669 | continue; | 1669 | continue; |
| 1670 | 1670 | ||
| 1671 | if (zone_page_state_snapshot(zone, NR_ZONE_LRU_BASE + | 1671 | if (zone_page_state_snapshot(zone, NR_ZONE_LRU_BASE + |
| @@ -2036,7 +2036,7 @@ static bool inactive_list_is_low(struct lruvec *lruvec, bool file, | |||
| 2036 | struct zone *zone = &pgdat->node_zones[zid]; | 2036 | struct zone *zone = &pgdat->node_zones[zid]; |
| 2037 | unsigned long inactive_zone, active_zone; | 2037 | unsigned long inactive_zone, active_zone; |
| 2038 | 2038 | ||
| 2039 | if (!populated_zone(zone)) | 2039 | if (!managed_zone(zone)) |
| 2040 | continue; | 2040 | continue; |
| 2041 | 2041 | ||
| 2042 | inactive_zone = zone_page_state(zone, | 2042 | inactive_zone = zone_page_state(zone, |
| @@ -2171,7 +2171,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg, | |||
| 2171 | 2171 | ||
| 2172 | for (z = 0; z < MAX_NR_ZONES; z++) { | 2172 | for (z = 0; z < MAX_NR_ZONES; z++) { |
| 2173 | struct zone *zone = &pgdat->node_zones[z]; | 2173 | struct zone *zone = &pgdat->node_zones[z]; |
| 2174 | if (!populated_zone(zone)) | 2174 | if (!managed_zone(zone)) |
| 2175 | continue; | 2175 | continue; |
| 2176 | 2176 | ||
| 2177 | total_high_wmark += high_wmark_pages(zone); | 2177 | total_high_wmark += high_wmark_pages(zone); |
| @@ -2510,7 +2510,7 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat, | |||
| 2510 | /* If compaction would go ahead or the allocation would succeed, stop */ | 2510 | /* If compaction would go ahead or the allocation would succeed, stop */ |
| 2511 | for (z = 0; z <= sc->reclaim_idx; z++) { | 2511 | for (z = 0; z <= sc->reclaim_idx; z++) { |
| 2512 | struct zone *zone = &pgdat->node_zones[z]; | 2512 | struct zone *zone = &pgdat->node_zones[z]; |
| 2513 | if (!populated_zone(zone)) | 2513 | if (!managed_zone(zone)) |
| 2514 | continue; | 2514 | continue; |
| 2515 | 2515 | ||
| 2516 | switch (compaction_suitable(zone, sc->order, 0, sc->reclaim_idx)) { | 2516 | switch (compaction_suitable(zone, sc->order, 0, sc->reclaim_idx)) { |
| @@ -2840,7 +2840,7 @@ static bool pfmemalloc_watermark_ok(pg_data_t *pgdat) | |||
| 2840 | 2840 | ||
| 2841 | for (i = 0; i <= ZONE_NORMAL; i++) { | 2841 | for (i = 0; i <= ZONE_NORMAL; i++) { |
| 2842 | zone = &pgdat->node_zones[i]; | 2842 | zone = &pgdat->node_zones[i]; |
| 2843 | if (!populated_zone(zone) || | 2843 | if (!managed_zone(zone) || |
| 2844 | pgdat_reclaimable_pages(pgdat) == 0) | 2844 | pgdat_reclaimable_pages(pgdat) == 0) |
| 2845 | continue; | 2845 | continue; |
| 2846 | 2846 | ||
| @@ -3141,7 +3141,7 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, int classzone_idx) | |||
| 3141 | for (i = 0; i <= classzone_idx; i++) { | 3141 | for (i = 0; i <= classzone_idx; i++) { |
| 3142 | struct zone *zone = pgdat->node_zones + i; | 3142 | struct zone *zone = pgdat->node_zones + i; |
| 3143 | 3143 | ||
| 3144 | if (!populated_zone(zone)) | 3144 | if (!managed_zone(zone)) |
| 3145 | continue; | 3145 | continue; |
| 3146 | 3146 | ||
| 3147 | if (!zone_balanced(zone, order, classzone_idx)) | 3147 | if (!zone_balanced(zone, order, classzone_idx)) |
| @@ -3169,7 +3169,7 @@ static bool kswapd_shrink_node(pg_data_t *pgdat, | |||
| 3169 | sc->nr_to_reclaim = 0; | 3169 | sc->nr_to_reclaim = 0; |
| 3170 | for (z = 0; z <= sc->reclaim_idx; z++) { | 3170 | for (z = 0; z <= sc->reclaim_idx; z++) { |
| 3171 | zone = pgdat->node_zones + z; | 3171 | zone = pgdat->node_zones + z; |
| 3172 | if (!populated_zone(zone)) | 3172 | if (!managed_zone(zone)) |
| 3173 | continue; | 3173 | continue; |
| 3174 | 3174 | ||
| 3175 | sc->nr_to_reclaim += max(high_wmark_pages(zone), SWAP_CLUSTER_MAX); | 3175 | sc->nr_to_reclaim += max(high_wmark_pages(zone), SWAP_CLUSTER_MAX); |
| @@ -3242,7 +3242,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) | |||
| 3242 | if (buffer_heads_over_limit) { | 3242 | if (buffer_heads_over_limit) { |
| 3243 | for (i = MAX_NR_ZONES - 1; i >= 0; i--) { | 3243 | for (i = MAX_NR_ZONES - 1; i >= 0; i--) { |
| 3244 | zone = pgdat->node_zones + i; | 3244 | zone = pgdat->node_zones + i; |
| 3245 | if (!populated_zone(zone)) | 3245 | if (!managed_zone(zone)) |
| 3246 | continue; | 3246 | continue; |
| 3247 | 3247 | ||
| 3248 | sc.reclaim_idx = i; | 3248 | sc.reclaim_idx = i; |
| @@ -3262,7 +3262,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) | |||
| 3262 | */ | 3262 | */ |
| 3263 | for (i = classzone_idx; i >= 0; i--) { | 3263 | for (i = classzone_idx; i >= 0; i--) { |
| 3264 | zone = pgdat->node_zones + i; | 3264 | zone = pgdat->node_zones + i; |
| 3265 | if (!populated_zone(zone)) | 3265 | if (!managed_zone(zone)) |
| 3266 | continue; | 3266 | continue; |
| 3267 | 3267 | ||
| 3268 | if (zone_balanced(zone, sc.order, classzone_idx)) | 3268 | if (zone_balanced(zone, sc.order, classzone_idx)) |
| @@ -3508,7 +3508,7 @@ void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx) | |||
| 3508 | pg_data_t *pgdat; | 3508 | pg_data_t *pgdat; |
| 3509 | int z; | 3509 | int z; |
| 3510 | 3510 | ||
| 3511 | if (!populated_zone(zone)) | 3511 | if (!managed_zone(zone)) |
| 3512 | return; | 3512 | return; |
| 3513 | 3513 | ||
| 3514 | if (!cpuset_zone_allowed(zone, GFP_KERNEL | __GFP_HARDWALL)) | 3514 | if (!cpuset_zone_allowed(zone, GFP_KERNEL | __GFP_HARDWALL)) |
| @@ -3522,7 +3522,7 @@ void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx) | |||
| 3522 | /* Only wake kswapd if all zones are unbalanced */ | 3522 | /* Only wake kswapd if all zones are unbalanced */ |
| 3523 | for (z = 0; z <= classzone_idx; z++) { | 3523 | for (z = 0; z <= classzone_idx; z++) { |
| 3524 | zone = pgdat->node_zones + z; | 3524 | zone = pgdat->node_zones + z; |
| 3525 | if (!populated_zone(zone)) | 3525 | if (!managed_zone(zone)) |
| 3526 | continue; | 3526 | continue; |
| 3527 | 3527 | ||
| 3528 | if (zone_balanced(zone, order, classzone_idx)) | 3528 | if (zone_balanced(zone, order, classzone_idx)) |
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index ece45e0683fd..0b5f729d08d2 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
| @@ -250,7 +250,7 @@ int bt_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, | |||
| 250 | 250 | ||
| 251 | skb_free_datagram(sk, skb); | 251 | skb_free_datagram(sk, skb); |
| 252 | 252 | ||
| 253 | if (msg->msg_flags & MSG_TRUNC) | 253 | if (flags & MSG_TRUNC) |
| 254 | copied = skblen; | 254 | copied = skblen; |
| 255 | 255 | ||
| 256 | return err ? : copied; | 256 | return err ? : copied; |
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index c045b3c54768..b0e23dfc5c34 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c | |||
| @@ -262,6 +262,8 @@ int __hci_req_sync(struct hci_dev *hdev, int (*func)(struct hci_request *req, | |||
| 262 | break; | 262 | break; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | kfree_skb(hdev->req_skb); | ||
| 266 | hdev->req_skb = NULL; | ||
| 265 | hdev->req_status = hdev->req_result = 0; | 267 | hdev->req_status = hdev->req_result = 0; |
| 266 | 268 | ||
| 267 | BT_DBG("%s end: err %d", hdev->name, err); | 269 | BT_DBG("%s end: err %d", hdev->name, err); |
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 6ef8a01a9ad4..96f04b7b9556 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
| @@ -1091,7 +1091,7 @@ static int hci_sock_recvmsg(struct socket *sock, struct msghdr *msg, | |||
| 1091 | 1091 | ||
| 1092 | skb_free_datagram(sk, skb); | 1092 | skb_free_datagram(sk, skb); |
| 1093 | 1093 | ||
| 1094 | if (msg->msg_flags & MSG_TRUNC) | 1094 | if (flags & MSG_TRUNC) |
| 1095 | copied = skblen; | 1095 | copied = skblen; |
| 1096 | 1096 | ||
| 1097 | return err ? : copied; | 1097 | return err ? : copied; |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 54ceb1f2cc9a..d4cad29b033f 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | #include <linux/debugfs.h> | 33 | #include <linux/debugfs.h> |
| 34 | #include <linux/crc16.h> | 34 | #include <linux/crc16.h> |
| 35 | #include <linux/filter.h> | ||
| 35 | 36 | ||
| 36 | #include <net/bluetooth/bluetooth.h> | 37 | #include <net/bluetooth/bluetooth.h> |
| 37 | #include <net/bluetooth/hci_core.h> | 38 | #include <net/bluetooth/hci_core.h> |
| @@ -5835,6 +5836,9 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, | |||
| 5835 | if (chan->sdu) | 5836 | if (chan->sdu) |
| 5836 | break; | 5837 | break; |
| 5837 | 5838 | ||
| 5839 | if (!pskb_may_pull(skb, L2CAP_SDULEN_SIZE)) | ||
| 5840 | break; | ||
| 5841 | |||
| 5838 | chan->sdu_len = get_unaligned_le16(skb->data); | 5842 | chan->sdu_len = get_unaligned_le16(skb->data); |
| 5839 | skb_pull(skb, L2CAP_SDULEN_SIZE); | 5843 | skb_pull(skb, L2CAP_SDULEN_SIZE); |
| 5840 | 5844 | ||
| @@ -6610,6 +6614,10 @@ static int l2cap_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) | |||
| 6610 | goto drop; | 6614 | goto drop; |
| 6611 | } | 6615 | } |
| 6612 | 6616 | ||
| 6617 | if ((chan->mode == L2CAP_MODE_ERTM || | ||
| 6618 | chan->mode == L2CAP_MODE_STREAMING) && sk_filter(chan->data, skb)) | ||
| 6619 | goto drop; | ||
| 6620 | |||
| 6613 | if (!control->sframe) { | 6621 | if (!control->sframe) { |
| 6614 | int err; | 6622 | int err; |
| 6615 | 6623 | ||
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 1842141baedb..a8ba752732c9 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
| @@ -1019,7 +1019,7 @@ static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg, | |||
| 1019 | goto done; | 1019 | goto done; |
| 1020 | 1020 | ||
| 1021 | if (pi->rx_busy_skb) { | 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 | pi->rx_busy_skb = NULL; | 1023 | pi->rx_busy_skb = NULL; |
| 1024 | else | 1024 | else |
| 1025 | goto done; | 1025 | goto done; |
| @@ -1270,7 +1270,17 @@ static int l2cap_sock_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb) | |||
| 1270 | goto done; | 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 | /* For ERTM, handle one skb that doesn't fit into the recv | 1285 | /* For ERTM, handle one skb that doesn't fit into the recv |
| 1276 | * buffer. This is important to do because the data frames | 1286 | * buffer. This is important to do because the data frames |
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index 8e486203d133..abe11f085479 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c | |||
| @@ -80,13 +80,10 @@ static void br_do_proxy_arp(struct sk_buff *skb, struct net_bridge *br, | |||
| 80 | 80 | ||
| 81 | BR_INPUT_SKB_CB(skb)->proxyarp_replied = false; | 81 | BR_INPUT_SKB_CB(skb)->proxyarp_replied = false; |
| 82 | 82 | ||
| 83 | if (dev->flags & IFF_NOARP) | 83 | if ((dev->flags & IFF_NOARP) || |
| 84 | !pskb_may_pull(skb, arp_hdr_len(dev))) | ||
| 84 | return; | 85 | return; |
| 85 | 86 | ||
| 86 | if (!pskb_may_pull(skb, arp_hdr_len(dev))) { | ||
| 87 | dev->stats.tx_dropped++; | ||
| 88 | return; | ||
| 89 | } | ||
| 90 | parp = arp_hdr(skb); | 87 | parp = arp_hdr(skb); |
| 91 | 88 | ||
| 92 | if (parp->ar_pro != htons(ETH_P_IP) || | 89 | if (parp->ar_pro != htons(ETH_P_IP) || |
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index a5423a1eec05..c5fea9393946 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c | |||
| @@ -1138,7 +1138,7 @@ static int br_ip6_multicast_mld2_report(struct net_bridge *br, | |||
| 1138 | } else { | 1138 | } else { |
| 1139 | err = br_ip6_multicast_add_group(br, port, | 1139 | err = br_ip6_multicast_add_group(br, port, |
| 1140 | &grec->grec_mca, vid); | 1140 | &grec->grec_mca, vid); |
| 1141 | if (!err) | 1141 | if (err) |
| 1142 | break; | 1142 | break; |
| 1143 | } | 1143 | } |
| 1144 | } | 1144 | } |
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index cceac5bb658f..0833c251aef7 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c | |||
| @@ -368,6 +368,8 @@ ebt_check_match(struct ebt_entry_match *m, struct xt_mtchk_param *par, | |||
| 368 | 368 | ||
| 369 | match = xt_find_match(NFPROTO_BRIDGE, m->u.name, 0); | 369 | match = xt_find_match(NFPROTO_BRIDGE, m->u.name, 0); |
| 370 | if (IS_ERR(match) || match->family != NFPROTO_BRIDGE) { | 370 | if (IS_ERR(match) || match->family != NFPROTO_BRIDGE) { |
| 371 | if (!IS_ERR(match)) | ||
| 372 | module_put(match->me); | ||
| 371 | request_module("ebt_%s", m->u.name); | 373 | request_module("ebt_%s", m->u.name); |
| 372 | match = xt_find_match(NFPROTO_BRIDGE, m->u.name, 0); | 374 | match = xt_find_match(NFPROTO_BRIDGE, m->u.name, 0); |
| 373 | } | 375 | } |
diff --git a/net/bridge/netfilter/nft_meta_bridge.c b/net/bridge/netfilter/nft_meta_bridge.c index 4b901d9f2e7c..ad47a921b701 100644 --- a/net/bridge/netfilter/nft_meta_bridge.c +++ b/net/bridge/netfilter/nft_meta_bridge.c | |||
| @@ -86,6 +86,7 @@ static const struct nft_expr_ops nft_meta_bridge_set_ops = { | |||
| 86 | .init = nft_meta_set_init, | 86 | .init = nft_meta_set_init, |
| 87 | .destroy = nft_meta_set_destroy, | 87 | .destroy = nft_meta_set_destroy, |
| 88 | .dump = nft_meta_set_dump, | 88 | .dump = nft_meta_set_dump, |
| 89 | .validate = nft_meta_set_validate, | ||
| 89 | }; | 90 | }; |
| 90 | 91 | ||
| 91 | static const struct nft_expr_ops * | 92 | static const struct nft_expr_ops * |
diff --git a/net/core/dev.c b/net/core/dev.c index dd6ce598de89..ea6312057a71 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
| @@ -3975,6 +3975,22 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret, | |||
| 3975 | } | 3975 | } |
| 3976 | 3976 | ||
| 3977 | /** | 3977 | /** |
| 3978 | * netdev_is_rx_handler_busy - check if receive handler is registered | ||
| 3979 | * @dev: device to check | ||
| 3980 | * | ||
| 3981 | * Check if a receive handler is already registered for a given device. | ||
| 3982 | * Return true if there one. | ||
| 3983 | * | ||
| 3984 | * The caller must hold the rtnl_mutex. | ||
| 3985 | */ | ||
| 3986 | bool netdev_is_rx_handler_busy(struct net_device *dev) | ||
| 3987 | { | ||
| 3988 | ASSERT_RTNL(); | ||
| 3989 | return dev && rtnl_dereference(dev->rx_handler); | ||
| 3990 | } | ||
| 3991 | EXPORT_SYMBOL_GPL(netdev_is_rx_handler_busy); | ||
| 3992 | |||
| 3993 | /** | ||
| 3978 | * netdev_rx_handler_register - register receive handler | 3994 | * netdev_rx_handler_register - register receive handler |
| 3979 | * @dev: device to register a handler for | 3995 | * @dev: device to register a handler for |
| 3980 | * @rx_handler: receive handler to register | 3996 | * @rx_handler: receive handler to register |
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 61ad43f61c5e..52742a02814f 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c | |||
| @@ -680,11 +680,13 @@ EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric); | |||
| 680 | void __skb_get_hash(struct sk_buff *skb) | 680 | void __skb_get_hash(struct sk_buff *skb) |
| 681 | { | 681 | { |
| 682 | struct flow_keys keys; | 682 | struct flow_keys keys; |
| 683 | u32 hash; | ||
| 683 | 684 | ||
| 684 | __flow_hash_secret_init(); | 685 | __flow_hash_secret_init(); |
| 685 | 686 | ||
| 686 | __skb_set_sw_hash(skb, ___skb_get_hash(skb, &keys, hashrnd), | 687 | hash = ___skb_get_hash(skb, &keys, hashrnd); |
| 687 | flow_keys_have_l4(&keys)); | 688 | |
| 689 | __skb_set_sw_hash(skb, hash, flow_keys_have_l4(&keys)); | ||
| 688 | } | 690 | } |
| 689 | EXPORT_SYMBOL(__skb_get_hash); | 691 | EXPORT_SYMBOL(__skb_get_hash); |
| 690 | 692 | ||
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 415e117967c7..062a67ca9a21 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
| @@ -2232,7 +2232,7 @@ static struct devinet_sysctl_table { | |||
| 2232 | }; | 2232 | }; |
| 2233 | 2233 | ||
| 2234 | static int __devinet_sysctl_register(struct net *net, char *dev_name, | 2234 | static int __devinet_sysctl_register(struct net *net, char *dev_name, |
| 2235 | struct ipv4_devconf *p) | 2235 | int ifindex, struct ipv4_devconf *p) |
| 2236 | { | 2236 | { |
| 2237 | int i; | 2237 | int i; |
| 2238 | struct devinet_sysctl_table *t; | 2238 | struct devinet_sysctl_table *t; |
| @@ -2255,6 +2255,8 @@ static int __devinet_sysctl_register(struct net *net, char *dev_name, | |||
| 2255 | goto free; | 2255 | goto free; |
| 2256 | 2256 | ||
| 2257 | p->sysctl = t; | 2257 | p->sysctl = t; |
| 2258 | |||
| 2259 | inet_netconf_notify_devconf(net, NETCONFA_ALL, ifindex, p); | ||
| 2258 | return 0; | 2260 | return 0; |
| 2259 | 2261 | ||
| 2260 | free: | 2262 | free: |
| @@ -2286,7 +2288,7 @@ static int devinet_sysctl_register(struct in_device *idev) | |||
| 2286 | if (err) | 2288 | if (err) |
| 2287 | return err; | 2289 | return err; |
| 2288 | err = __devinet_sysctl_register(dev_net(idev->dev), idev->dev->name, | 2290 | err = __devinet_sysctl_register(dev_net(idev->dev), idev->dev->name, |
| 2289 | &idev->cnf); | 2291 | idev->dev->ifindex, &idev->cnf); |
| 2290 | if (err) | 2292 | if (err) |
| 2291 | neigh_sysctl_unregister(idev->arp_parms); | 2293 | neigh_sysctl_unregister(idev->arp_parms); |
| 2292 | return err; | 2294 | return err; |
| @@ -2347,11 +2349,12 @@ static __net_init int devinet_init_net(struct net *net) | |||
| 2347 | } | 2349 | } |
| 2348 | 2350 | ||
| 2349 | #ifdef CONFIG_SYSCTL | 2351 | #ifdef CONFIG_SYSCTL |
| 2350 | err = __devinet_sysctl_register(net, "all", all); | 2352 | err = __devinet_sysctl_register(net, "all", NETCONFA_IFINDEX_ALL, all); |
| 2351 | if (err < 0) | 2353 | if (err < 0) |
| 2352 | goto err_reg_all; | 2354 | goto err_reg_all; |
| 2353 | 2355 | ||
| 2354 | err = __devinet_sysctl_register(net, "default", dflt); | 2356 | err = __devinet_sysctl_register(net, "default", |
| 2357 | NETCONFA_IFINDEX_DEFAULT, dflt); | ||
| 2355 | if (err < 0) | 2358 | if (err < 0) |
| 2356 | goto err_reg_dflt; | 2359 | goto err_reg_dflt; |
| 2357 | 2360 | ||
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index ef2ebeb89d0f..1b25daf8c7f1 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
| @@ -509,6 +509,7 @@ static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt, | |||
| 509 | if (!dev) | 509 | if (!dev) |
| 510 | return -ENODEV; | 510 | return -ENODEV; |
| 511 | cfg->fc_oif = dev->ifindex; | 511 | cfg->fc_oif = dev->ifindex; |
| 512 | cfg->fc_table = l3mdev_fib_table(dev); | ||
| 512 | if (colon) { | 513 | if (colon) { |
| 513 | struct in_ifaddr *ifa; | 514 | struct in_ifaddr *ifa; |
| 514 | struct in_device *in_dev = __in_dev_get_rtnl(dev); | 515 | struct in_device *in_dev = __in_dev_get_rtnl(dev); |
| @@ -1027,7 +1028,7 @@ no_promotions: | |||
| 1027 | * First of all, we scan fib_info list searching | 1028 | * First of all, we scan fib_info list searching |
| 1028 | * for stray nexthop entries, then ignite fib_flush. | 1029 | * for stray nexthop entries, then ignite fib_flush. |
| 1029 | */ | 1030 | */ |
| 1030 | if (fib_sync_down_addr(dev_net(dev), ifa->ifa_local)) | 1031 | if (fib_sync_down_addr(dev, ifa->ifa_local)) |
| 1031 | fib_flush(dev_net(dev)); | 1032 | fib_flush(dev_net(dev)); |
| 1032 | } | 1033 | } |
| 1033 | } | 1034 | } |
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 539fa264e67d..e9f56225e53f 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
| @@ -1057,6 +1057,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg) | |||
| 1057 | fi->fib_priority = cfg->fc_priority; | 1057 | fi->fib_priority = cfg->fc_priority; |
| 1058 | fi->fib_prefsrc = cfg->fc_prefsrc; | 1058 | fi->fib_prefsrc = cfg->fc_prefsrc; |
| 1059 | fi->fib_type = cfg->fc_type; | 1059 | fi->fib_type = cfg->fc_type; |
| 1060 | fi->fib_tb_id = cfg->fc_table; | ||
| 1060 | 1061 | ||
| 1061 | fi->fib_nhs = nhs; | 1062 | fi->fib_nhs = nhs; |
| 1062 | change_nexthops(fi) { | 1063 | change_nexthops(fi) { |
| @@ -1337,18 +1338,21 @@ nla_put_failure: | |||
| 1337 | * referring to it. | 1338 | * referring to it. |
| 1338 | * - device went down -> we must shutdown all nexthops going via it. | 1339 | * - device went down -> we must shutdown all nexthops going via it. |
| 1339 | */ | 1340 | */ |
| 1340 | int fib_sync_down_addr(struct net *net, __be32 local) | 1341 | int fib_sync_down_addr(struct net_device *dev, __be32 local) |
| 1341 | { | 1342 | { |
| 1342 | int ret = 0; | 1343 | int ret = 0; |
| 1343 | unsigned int hash = fib_laddr_hashfn(local); | 1344 | unsigned int hash = fib_laddr_hashfn(local); |
| 1344 | struct hlist_head *head = &fib_info_laddrhash[hash]; | 1345 | struct hlist_head *head = &fib_info_laddrhash[hash]; |
| 1346 | struct net *net = dev_net(dev); | ||
| 1347 | int tb_id = l3mdev_fib_table(dev); | ||
| 1345 | struct fib_info *fi; | 1348 | struct fib_info *fi; |
| 1346 | 1349 | ||
| 1347 | if (!fib_info_laddrhash || local == 0) | 1350 | if (!fib_info_laddrhash || local == 0) |
| 1348 | return 0; | 1351 | return 0; |
| 1349 | 1352 | ||
| 1350 | hlist_for_each_entry(fi, head, fib_lhash) { | 1353 | hlist_for_each_entry(fi, head, fib_lhash) { |
| 1351 | if (!net_eq(fi->fib_net, net)) | 1354 | if (!net_eq(fi->fib_net, net) || |
| 1355 | fi->fib_tb_id != tb_id) | ||
| 1352 | continue; | 1356 | continue; |
| 1353 | if (fi->fib_prefsrc == local) { | 1357 | if (fi->fib_prefsrc == local) { |
| 1354 | fi->fib_flags |= RTNH_F_DEAD; | 1358 | fi->fib_flags |= RTNH_F_DEAD; |
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index febca0f1008c..e2ffc2a5c7db 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
| @@ -249,7 +249,7 @@ static inline unsigned long get_index(t_key key, struct key_vector *kv) | |||
| 249 | * index into the parent's child array. That is, they will be used to find | 249 | * index into the parent's child array. That is, they will be used to find |
| 250 | * 'n' among tp's children. | 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 | * for the node n. | 253 | * for the node n. |
| 254 | * | 254 | * |
| 255 | * All the bits we have seen so far are significant to the node n. The rest | 255 | * All the bits we have seen so far are significant to the node n. The rest |
| @@ -258,7 +258,7 @@ static inline unsigned long get_index(t_key key, struct key_vector *kv) | |||
| 258 | * The bits from (n->pos) to (n->pos + n->bits - 1) - "C" - are the index into | 258 | * The bits from (n->pos) to (n->pos + n->bits - 1) - "C" - are the index into |
| 259 | * n's child array, and will of course be different for each child. | 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 | * at this point. | 262 | * at this point. |
| 263 | */ | 263 | */ |
| 264 | 264 | ||
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c index 9d847c302551..0f227db0e9ac 100644 --- a/net/ipv4/ip_tunnel_core.c +++ b/net/ipv4/ip_tunnel_core.c | |||
| @@ -73,9 +73,11 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb, | |||
| 73 | skb_dst_set(skb, &rt->dst); | 73 | skb_dst_set(skb, &rt->dst); |
| 74 | memset(IPCB(skb), 0, sizeof(*IPCB(skb))); | 74 | memset(IPCB(skb), 0, sizeof(*IPCB(skb))); |
| 75 | 75 | ||
| 76 | if (skb_iif && proto == IPPROTO_UDP) { | 76 | if (skb_iif && !(df & htons(IP_DF))) { |
| 77 | /* Arrived from an ingress interface and got udp encapuslated. | 77 | /* Arrived from an ingress interface, got encapsulated, with |
| 78 | * The encapsulated network segment length may exceed dst mtu. | 78 | * fragmentation of encapulating frames allowed. |
| 79 | * If skb is gso, the resulting encapsulated network segments | ||
| 80 | * may exceed dst mtu. | ||
| 79 | * Allow IP Fragmentation of segments. | 81 | * Allow IP Fragmentation of segments. |
| 80 | */ | 82 | */ |
| 81 | IPCB(skb)->flags |= IPSKB_FRAG_SEGS; | 83 | IPCB(skb)->flags |= IPSKB_FRAG_SEGS; |
diff --git a/net/ipv4/netfilter/nft_reject_ipv4.c b/net/ipv4/netfilter/nft_reject_ipv4.c index c24f41c816b3..2c2553b9026c 100644 --- a/net/ipv4/netfilter/nft_reject_ipv4.c +++ b/net/ipv4/netfilter/nft_reject_ipv4.c | |||
| @@ -46,6 +46,7 @@ static const struct nft_expr_ops nft_reject_ipv4_ops = { | |||
| 46 | .eval = nft_reject_ipv4_eval, | 46 | .eval = nft_reject_ipv4_eval, |
| 47 | .init = nft_reject_init, | 47 | .init = nft_reject_init, |
| 48 | .dump = nft_reject_dump, | 48 | .dump = nft_reject_dump, |
| 49 | .validate = nft_reject_validate, | ||
| 49 | }; | 50 | }; |
| 50 | 51 | ||
| 51 | static struct nft_expr_type nft_reject_ipv4_type __read_mostly = { | 52 | static struct nft_expr_type nft_reject_ipv4_type __read_mostly = { |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 032a96d78c99..ffbb218de520 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
| @@ -3193,7 +3193,6 @@ int tcp_abort(struct sock *sk, int err) | |||
| 3193 | local_bh_enable(); | 3193 | local_bh_enable(); |
| 3194 | return 0; | 3194 | return 0; |
| 3195 | } | 3195 | } |
| 3196 | sock_gen_put(sk); | ||
| 3197 | return -EOPNOTSUPP; | 3196 | return -EOPNOTSUPP; |
| 3198 | } | 3197 | } |
| 3199 | 3198 | ||
| @@ -3222,7 +3221,6 @@ int tcp_abort(struct sock *sk, int err) | |||
| 3222 | bh_unlock_sock(sk); | 3221 | bh_unlock_sock(sk); |
| 3223 | local_bh_enable(); | 3222 | local_bh_enable(); |
| 3224 | release_sock(sk); | 3223 | release_sock(sk); |
| 3225 | sock_put(sk); | ||
| 3226 | return 0; | 3224 | return 0; |
| 3227 | } | 3225 | } |
| 3228 | EXPORT_SYMBOL_GPL(tcp_abort); | 3226 | EXPORT_SYMBOL_GPL(tcp_abort); |
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c index 4d610934fb39..a748c74aa8b7 100644 --- a/net/ipv4/tcp_diag.c +++ b/net/ipv4/tcp_diag.c | |||
| @@ -54,11 +54,16 @@ static int tcp_diag_destroy(struct sk_buff *in_skb, | |||
| 54 | { | 54 | { |
| 55 | struct net *net = sock_net(in_skb->sk); | 55 | struct net *net = sock_net(in_skb->sk); |
| 56 | struct sock *sk = inet_diag_find_one_icsk(net, &tcp_hashinfo, req); | 56 | struct sock *sk = inet_diag_find_one_icsk(net, &tcp_hashinfo, req); |
| 57 | int err; | ||
| 57 | 58 | ||
| 58 | if (IS_ERR(sk)) | 59 | if (IS_ERR(sk)) |
| 59 | return PTR_ERR(sk); | 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 | #endif | 68 | #endif |
| 64 | 69 | ||
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c index 54d9f9b0120f..4e777a3243f9 100644 --- a/net/ipv4/tcp_fastopen.c +++ b/net/ipv4/tcp_fastopen.c | |||
| @@ -150,6 +150,7 @@ void tcp_fastopen_add_skb(struct sock *sk, struct sk_buff *skb) | |||
| 150 | tp->segs_in = 0; | 150 | tp->segs_in = 0; |
| 151 | tcp_segs_in(tp, skb); | 151 | tcp_segs_in(tp, skb); |
| 152 | __skb_pull(skb, tcp_hdrlen(skb)); | 152 | __skb_pull(skb, tcp_hdrlen(skb)); |
| 153 | sk_forced_mem_schedule(sk, skb->truesize); | ||
| 153 | skb_set_owner_r(skb, sk); | 154 | skb_set_owner_r(skb, sk); |
| 154 | 155 | ||
| 155 | TCP_SKB_CB(skb)->seq++; | 156 | TCP_SKB_CB(skb)->seq++; |
| @@ -226,6 +227,7 @@ static struct sock *tcp_fastopen_create_child(struct sock *sk, | |||
| 226 | tcp_fastopen_add_skb(child, skb); | 227 | tcp_fastopen_add_skb(child, skb); |
| 227 | 228 | ||
| 228 | tcp_rsk(req)->rcv_nxt = tp->rcv_nxt; | 229 | tcp_rsk(req)->rcv_nxt = tp->rcv_nxt; |
| 230 | tp->rcv_wup = tp->rcv_nxt; | ||
| 229 | /* tcp_conn_request() is sending the SYNACK, | 231 | /* tcp_conn_request() is sending the SYNACK, |
| 230 | * and queues the child into listener accept queue. | 232 | * and queues the child into listener accept queue. |
| 231 | */ | 233 | */ |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 32b048e524d6..7158d4f8dae4 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
| @@ -814,8 +814,14 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, | |||
| 814 | u32 seq = (sk->sk_state == TCP_LISTEN) ? tcp_rsk(req)->snt_isn + 1 : | 814 | u32 seq = (sk->sk_state == TCP_LISTEN) ? tcp_rsk(req)->snt_isn + 1 : |
| 815 | tcp_sk(sk)->snd_nxt; | 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 | tcp_v4_send_ack(sock_net(sk), skb, seq, | 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 | tcp_time_stamp, | 825 | tcp_time_stamp, |
| 820 | req->ts_recent, | 826 | req->ts_recent, |
| 821 | 0, | 827 | 0, |
diff --git a/net/ipv4/tcp_yeah.c b/net/ipv4/tcp_yeah.c index 028eb046ea40..9c5fc973267f 100644 --- a/net/ipv4/tcp_yeah.c +++ b/net/ipv4/tcp_yeah.c | |||
| @@ -76,7 +76,7 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, u32 acked) | |||
| 76 | if (!tcp_is_cwnd_limited(sk)) | 76 | if (!tcp_is_cwnd_limited(sk)) |
| 77 | return; | 77 | return; |
| 78 | 78 | ||
| 79 | if (tp->snd_cwnd <= tp->snd_ssthresh) | 79 | if (tcp_in_slow_start(tp)) |
| 80 | tcp_slow_start(tp, acked); | 80 | tcp_slow_start(tp, acked); |
| 81 | 81 | ||
| 82 | else if (!yeah->doing_reno_now) { | 82 | else if (!yeah->doing_reno_now) { |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index e61f7cd65d08..5fdcb8d108d4 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
| @@ -1182,13 +1182,13 @@ out: | |||
| 1182 | * @sk: socket | 1182 | * @sk: socket |
| 1183 | * | 1183 | * |
| 1184 | * Drops all bad checksum frames, until a valid one is found. | 1184 | * Drops all bad checksum frames, until a valid one is found. |
| 1185 | * Returns the length of found skb, or 0 if none is found. | 1185 | * Returns the length of found skb, or -1 if none is found. |
| 1186 | */ | 1186 | */ |
| 1187 | static unsigned int first_packet_length(struct sock *sk) | 1187 | static int first_packet_length(struct sock *sk) |
| 1188 | { | 1188 | { |
| 1189 | struct sk_buff_head list_kill, *rcvq = &sk->sk_receive_queue; | 1189 | struct sk_buff_head list_kill, *rcvq = &sk->sk_receive_queue; |
| 1190 | struct sk_buff *skb; | 1190 | struct sk_buff *skb; |
| 1191 | unsigned int res; | 1191 | int res; |
| 1192 | 1192 | ||
| 1193 | __skb_queue_head_init(&list_kill); | 1193 | __skb_queue_head_init(&list_kill); |
| 1194 | 1194 | ||
| @@ -1203,7 +1203,7 @@ static unsigned int first_packet_length(struct sock *sk) | |||
| 1203 | __skb_unlink(skb, rcvq); | 1203 | __skb_unlink(skb, rcvq); |
| 1204 | __skb_queue_tail(&list_kill, skb); | 1204 | __skb_queue_tail(&list_kill, skb); |
| 1205 | } | 1205 | } |
| 1206 | res = skb ? skb->len : 0; | 1206 | res = skb ? skb->len : -1; |
| 1207 | spin_unlock_bh(&rcvq->lock); | 1207 | spin_unlock_bh(&rcvq->lock); |
| 1208 | 1208 | ||
| 1209 | if (!skb_queue_empty(&list_kill)) { | 1209 | if (!skb_queue_empty(&list_kill)) { |
| @@ -1232,7 +1232,7 @@ int udp_ioctl(struct sock *sk, int cmd, unsigned long arg) | |||
| 1232 | 1232 | ||
| 1233 | case SIOCINQ: | 1233 | case SIOCINQ: |
| 1234 | { | 1234 | { |
| 1235 | unsigned int amount = first_packet_length(sk); | 1235 | int amount = max_t(int, 0, first_packet_length(sk)); |
| 1236 | 1236 | ||
| 1237 | return put_user(amount, (int __user *)arg); | 1237 | return put_user(amount, (int __user *)arg); |
| 1238 | } | 1238 | } |
| @@ -2184,7 +2184,7 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
| 2184 | 2184 | ||
| 2185 | /* Check for false positives due to checksum errors */ | 2185 | /* Check for false positives due to checksum errors */ |
| 2186 | if ((mask & POLLRDNORM) && !(file->f_flags & O_NONBLOCK) && | 2186 | if ((mask & POLLRDNORM) && !(file->f_flags & O_NONBLOCK) && |
| 2187 | !(sk->sk_shutdown & RCV_SHUTDOWN) && !first_packet_length(sk)) | 2187 | !(sk->sk_shutdown & RCV_SHUTDOWN) && first_packet_length(sk) == -1) |
| 2188 | mask &= ~(POLLIN | POLLRDNORM); | 2188 | mask &= ~(POLLIN | POLLRDNORM); |
| 2189 | 2189 | ||
| 2190 | return mask; | 2190 | return mask; |
| @@ -2216,7 +2216,6 @@ struct proto udp_prot = { | |||
| 2216 | .sysctl_wmem = &sysctl_udp_wmem_min, | 2216 | .sysctl_wmem = &sysctl_udp_wmem_min, |
| 2217 | .sysctl_rmem = &sysctl_udp_rmem_min, | 2217 | .sysctl_rmem = &sysctl_udp_rmem_min, |
| 2218 | .obj_size = sizeof(struct udp_sock), | 2218 | .obj_size = sizeof(struct udp_sock), |
| 2219 | .slab_flags = SLAB_DESTROY_BY_RCU, | ||
| 2220 | .h.udp_table = &udp_table, | 2219 | .h.udp_table = &udp_table, |
| 2221 | #ifdef CONFIG_COMPAT | 2220 | #ifdef CONFIG_COMPAT |
| 2222 | .compat_setsockopt = compat_udp_setsockopt, | 2221 | .compat_setsockopt = compat_udp_setsockopt, |
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index 3b3efbda48e1..2eea073e27ef 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c | |||
| @@ -55,7 +55,6 @@ struct proto udplite_prot = { | |||
| 55 | .unhash = udp_lib_unhash, | 55 | .unhash = udp_lib_unhash, |
| 56 | .get_port = udp_v4_get_port, | 56 | .get_port = udp_v4_get_port, |
| 57 | .obj_size = sizeof(struct udp_sock), | 57 | .obj_size = sizeof(struct udp_sock), |
| 58 | .slab_flags = SLAB_DESTROY_BY_RCU, | ||
| 59 | .h.udp_table = &udplite_table, | 58 | .h.udp_table = &udplite_table, |
| 60 | #ifdef CONFIG_COMPAT | 59 | #ifdef CONFIG_COMPAT |
| 61 | .compat_setsockopt = compat_udp_setsockopt, | 60 | .compat_setsockopt = compat_udp_setsockopt, |
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index b644a23c3db0..41f5b504a782 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c | |||
| @@ -29,7 +29,7 @@ static struct dst_entry *__xfrm4_dst_lookup(struct net *net, struct flowi4 *fl4, | |||
| 29 | memset(fl4, 0, sizeof(*fl4)); | 29 | memset(fl4, 0, sizeof(*fl4)); |
| 30 | fl4->daddr = daddr->a4; | 30 | fl4->daddr = daddr->a4; |
| 31 | fl4->flowi4_tos = tos; | 31 | fl4->flowi4_tos = tos; |
| 32 | fl4->flowi4_oif = oif; | 32 | fl4->flowi4_oif = l3mdev_master_ifindex_by_index(net, oif); |
| 33 | if (saddr) | 33 | if (saddr) |
| 34 | fl4->saddr = saddr->a4; | 34 | fl4->saddr = saddr->a4; |
| 35 | 35 | ||
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index df8425fcbc2c..2f1f5d439788 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
| @@ -778,7 +778,14 @@ static int addrconf_fixup_forwarding(struct ctl_table *table, int *p, int newf) | |||
| 778 | } | 778 | } |
| 779 | 779 | ||
| 780 | if (p == &net->ipv6.devconf_all->forwarding) { | 780 | if (p == &net->ipv6.devconf_all->forwarding) { |
| 781 | int old_dflt = net->ipv6.devconf_dflt->forwarding; | ||
| 782 | |||
| 781 | net->ipv6.devconf_dflt->forwarding = newf; | 783 | net->ipv6.devconf_dflt->forwarding = newf; |
| 784 | if ((!newf) ^ (!old_dflt)) | ||
| 785 | inet6_netconf_notify_devconf(net, NETCONFA_FORWARDING, | ||
| 786 | NETCONFA_IFINDEX_DEFAULT, | ||
| 787 | net->ipv6.devconf_dflt); | ||
| 788 | |||
| 782 | addrconf_forward_change(net, newf); | 789 | addrconf_forward_change(net, newf); |
| 783 | if ((!newf) ^ (!old)) | 790 | if ((!newf) ^ (!old)) |
| 784 | inet6_netconf_notify_devconf(net, NETCONFA_FORWARDING, | 791 | inet6_netconf_notify_devconf(net, NETCONFA_FORWARDING, |
| @@ -1872,7 +1879,6 @@ static int addrconf_dad_end(struct inet6_ifaddr *ifp) | |||
| 1872 | 1879 | ||
| 1873 | void addrconf_dad_failure(struct inet6_ifaddr *ifp) | 1880 | void addrconf_dad_failure(struct inet6_ifaddr *ifp) |
| 1874 | { | 1881 | { |
| 1875 | struct in6_addr addr; | ||
| 1876 | struct inet6_dev *idev = ifp->idev; | 1882 | struct inet6_dev *idev = ifp->idev; |
| 1877 | struct net *net = dev_net(ifp->idev->dev); | 1883 | struct net *net = dev_net(ifp->idev->dev); |
| 1878 | 1884 | ||
| @@ -1934,18 +1940,6 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp) | |||
| 1934 | in6_ifa_put(ifp2); | 1940 | in6_ifa_put(ifp2); |
| 1935 | lock_errdad: | 1941 | lock_errdad: |
| 1936 | spin_lock_bh(&ifp->lock); | 1942 | spin_lock_bh(&ifp->lock); |
| 1937 | } else if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) { | ||
| 1938 | addr.s6_addr32[0] = htonl(0xfe800000); | ||
| 1939 | addr.s6_addr32[1] = 0; | ||
| 1940 | |||
| 1941 | if (!ipv6_generate_eui64(addr.s6_addr + 8, idev->dev) && | ||
| 1942 | ipv6_addr_equal(&ifp->addr, &addr)) { | ||
| 1943 | /* DAD failed for link-local based on MAC address */ | ||
| 1944 | idev->cnf.disable_ipv6 = 1; | ||
| 1945 | |||
| 1946 | pr_info("%s: IPv6 being disabled!\n", | ||
| 1947 | ifp->idev->dev->name); | ||
| 1948 | } | ||
| 1949 | } | 1943 | } |
| 1950 | 1944 | ||
| 1951 | errdad: | 1945 | errdad: |
| @@ -1954,6 +1948,7 @@ errdad: | |||
| 1954 | spin_unlock_bh(&ifp->lock); | 1948 | spin_unlock_bh(&ifp->lock); |
| 1955 | 1949 | ||
| 1956 | addrconf_mod_dad_work(ifp, 0); | 1950 | addrconf_mod_dad_work(ifp, 0); |
| 1951 | in6_ifa_put(ifp); | ||
| 1957 | } | 1952 | } |
| 1958 | 1953 | ||
| 1959 | /* Join to solicited addr multicast group. | 1954 | /* Join to solicited addr multicast group. |
| @@ -3821,6 +3816,7 @@ static void addrconf_dad_work(struct work_struct *w) | |||
| 3821 | dad_work); | 3816 | dad_work); |
| 3822 | struct inet6_dev *idev = ifp->idev; | 3817 | struct inet6_dev *idev = ifp->idev; |
| 3823 | struct in6_addr mcaddr; | 3818 | struct in6_addr mcaddr; |
| 3819 | bool disable_ipv6 = false; | ||
| 3824 | 3820 | ||
| 3825 | enum { | 3821 | enum { |
| 3826 | DAD_PROCESS, | 3822 | DAD_PROCESS, |
| @@ -3837,6 +3833,24 @@ static void addrconf_dad_work(struct work_struct *w) | |||
| 3837 | } else if (ifp->state == INET6_IFADDR_STATE_ERRDAD) { | 3833 | } else if (ifp->state == INET6_IFADDR_STATE_ERRDAD) { |
| 3838 | action = DAD_ABORT; | 3834 | action = DAD_ABORT; |
| 3839 | ifp->state = INET6_IFADDR_STATE_POSTDAD; | 3835 | ifp->state = INET6_IFADDR_STATE_POSTDAD; |
| 3836 | |||
| 3837 | if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6 && | ||
| 3838 | !(ifp->flags & IFA_F_STABLE_PRIVACY)) { | ||
| 3839 | struct in6_addr addr; | ||
| 3840 | |||
| 3841 | addr.s6_addr32[0] = htonl(0xfe800000); | ||
| 3842 | addr.s6_addr32[1] = 0; | ||
| 3843 | |||
| 3844 | if (!ipv6_generate_eui64(addr.s6_addr + 8, idev->dev) && | ||
| 3845 | ipv6_addr_equal(&ifp->addr, &addr)) { | ||
| 3846 | /* DAD failed for link-local based on MAC */ | ||
| 3847 | idev->cnf.disable_ipv6 = 1; | ||
| 3848 | |||
| 3849 | pr_info("%s: IPv6 being disabled!\n", | ||
| 3850 | ifp->idev->dev->name); | ||
| 3851 | disable_ipv6 = true; | ||
| 3852 | } | ||
| 3853 | } | ||
| 3840 | } | 3854 | } |
| 3841 | spin_unlock_bh(&ifp->lock); | 3855 | spin_unlock_bh(&ifp->lock); |
| 3842 | 3856 | ||
| @@ -3844,7 +3858,10 @@ static void addrconf_dad_work(struct work_struct *w) | |||
| 3844 | addrconf_dad_begin(ifp); | 3858 | addrconf_dad_begin(ifp); |
| 3845 | goto out; | 3859 | goto out; |
| 3846 | } else if (action == DAD_ABORT) { | 3860 | } else if (action == DAD_ABORT) { |
| 3861 | in6_ifa_hold(ifp); | ||
| 3847 | addrconf_dad_stop(ifp, 1); | 3862 | addrconf_dad_stop(ifp, 1); |
| 3863 | if (disable_ipv6) | ||
| 3864 | addrconf_ifdown(idev->dev, 0); | ||
| 3848 | goto out; | 3865 | goto out; |
| 3849 | } | 3866 | } |
| 3850 | 3867 | ||
| @@ -6017,7 +6034,7 @@ static const struct ctl_table addrconf_sysctl[] = { | |||
| 6017 | static int __addrconf_sysctl_register(struct net *net, char *dev_name, | 6034 | static int __addrconf_sysctl_register(struct net *net, char *dev_name, |
| 6018 | struct inet6_dev *idev, struct ipv6_devconf *p) | 6035 | struct inet6_dev *idev, struct ipv6_devconf *p) |
| 6019 | { | 6036 | { |
| 6020 | int i; | 6037 | int i, ifindex; |
| 6021 | struct ctl_table *table; | 6038 | struct ctl_table *table; |
| 6022 | char path[sizeof("net/ipv6/conf/") + IFNAMSIZ]; | 6039 | char path[sizeof("net/ipv6/conf/") + IFNAMSIZ]; |
| 6023 | 6040 | ||
| @@ -6037,6 +6054,13 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name, | |||
| 6037 | if (!p->sysctl_header) | 6054 | if (!p->sysctl_header) |
| 6038 | goto free; | 6055 | goto free; |
| 6039 | 6056 | ||
| 6057 | if (!strcmp(dev_name, "all")) | ||
| 6058 | ifindex = NETCONFA_IFINDEX_ALL; | ||
| 6059 | else if (!strcmp(dev_name, "default")) | ||
| 6060 | ifindex = NETCONFA_IFINDEX_DEFAULT; | ||
| 6061 | else | ||
| 6062 | ifindex = idev->dev->ifindex; | ||
| 6063 | inet6_netconf_notify_devconf(net, NETCONFA_ALL, ifindex, p); | ||
| 6040 | return 0; | 6064 | return 0; |
| 6041 | 6065 | ||
| 6042 | free: | 6066 | free: |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 7b0481e3738f..888543debe4e 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
| @@ -1174,6 +1174,7 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1174 | encap_limit = t->parms.encap_limit; | 1174 | encap_limit = t->parms.encap_limit; |
| 1175 | 1175 | ||
| 1176 | memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6)); | 1176 | memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6)); |
| 1177 | fl6.flowi6_proto = IPPROTO_IPIP; | ||
| 1177 | 1178 | ||
| 1178 | dsfield = ipv4_get_dsfield(iph); | 1179 | dsfield = ipv4_get_dsfield(iph); |
| 1179 | 1180 | ||
| @@ -1233,6 +1234,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1233 | encap_limit = t->parms.encap_limit; | 1234 | encap_limit = t->parms.encap_limit; |
| 1234 | 1235 | ||
| 1235 | memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6)); | 1236 | memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6)); |
| 1237 | fl6.flowi6_proto = IPPROTO_IPV6; | ||
| 1236 | 1238 | ||
| 1237 | dsfield = ipv6_get_dsfield(ipv6h); | 1239 | dsfield = ipv6_get_dsfield(ipv6h); |
| 1238 | if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS) | 1240 | if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS) |
diff --git a/net/ipv6/netfilter/nft_reject_ipv6.c b/net/ipv6/netfilter/nft_reject_ipv6.c index 533cd5719c59..92bda9908bb9 100644 --- a/net/ipv6/netfilter/nft_reject_ipv6.c +++ b/net/ipv6/netfilter/nft_reject_ipv6.c | |||
| @@ -47,6 +47,7 @@ static const struct nft_expr_ops nft_reject_ipv6_ops = { | |||
| 47 | .eval = nft_reject_ipv6_eval, | 47 | .eval = nft_reject_ipv6_eval, |
| 48 | .init = nft_reject_init, | 48 | .init = nft_reject_init, |
| 49 | .dump = nft_reject_dump, | 49 | .dump = nft_reject_dump, |
| 50 | .validate = nft_reject_validate, | ||
| 50 | }; | 51 | }; |
| 51 | 52 | ||
| 52 | static struct nft_expr_type nft_reject_ipv6_type __read_mostly = { | 53 | static struct nft_expr_type nft_reject_ipv6_type __read_mostly = { |
diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c index 0900352c924c..0e983b694ee8 100644 --- a/net/ipv6/ping.c +++ b/net/ipv6/ping.c | |||
| @@ -126,8 +126,10 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) | |||
| 126 | rt = (struct rt6_info *) dst; | 126 | rt = (struct rt6_info *) dst; |
| 127 | 127 | ||
| 128 | np = inet6_sk(sk); | 128 | np = inet6_sk(sk); |
| 129 | if (!np) | 129 | if (!np) { |
| 130 | return -EBADF; | 130 | err = -EBADF; |
| 131 | goto dst_err_out; | ||
| 132 | } | ||
| 131 | 133 | ||
| 132 | if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) | 134 | if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) |
| 133 | fl6.flowi6_oif = np->mcast_oif; | 135 | fl6.flowi6_oif = np->mcast_oif; |
| @@ -163,6 +165,9 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) | |||
| 163 | } | 165 | } |
| 164 | release_sock(sk); | 166 | release_sock(sk); |
| 165 | 167 | ||
| 168 | dst_err_out: | ||
| 169 | dst_release(dst); | ||
| 170 | |||
| 166 | if (err) | 171 | if (err) |
| 167 | return err; | 172 | return err; |
| 168 | 173 | ||
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 33df8b8575cc..94f4f89d73e7 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
| @@ -944,9 +944,15 @@ static void tcp_v6_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, | |||
| 944 | /* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV | 944 | /* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV |
| 945 | * sk->sk_state == TCP_SYN_RECV -> for Fast Open. | 945 | * sk->sk_state == TCP_SYN_RECV -> for Fast Open. |
| 946 | */ | 946 | */ |
| 947 | /* RFC 7323 2.3 | ||
| 948 | * The window field (SEG.WND) of every outgoing segment, with the | ||
| 949 | * exception of <SYN> segments, MUST be right-shifted by | ||
| 950 | * Rcv.Wind.Shift bits: | ||
| 951 | */ | ||
| 947 | tcp_v6_send_ack(sk, skb, (sk->sk_state == TCP_LISTEN) ? | 952 | tcp_v6_send_ack(sk, skb, (sk->sk_state == TCP_LISTEN) ? |
| 948 | tcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt, | 953 | tcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt, |
| 949 | tcp_rsk(req)->rcv_nxt, req->rsk_rcv_wnd, | 954 | tcp_rsk(req)->rcv_nxt, |
| 955 | req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale, | ||
| 950 | tcp_time_stamp, req->ts_recent, sk->sk_bound_dev_if, | 956 | tcp_time_stamp, req->ts_recent, sk->sk_bound_dev_if, |
| 951 | tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr), | 957 | tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr), |
| 952 | 0, 0); | 958 | 0, 0); |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 81e2f98b958d..19ac3a1c308d 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
| @@ -1460,7 +1460,6 @@ struct proto udpv6_prot = { | |||
| 1460 | .sysctl_wmem = &sysctl_udp_wmem_min, | 1460 | .sysctl_wmem = &sysctl_udp_wmem_min, |
| 1461 | .sysctl_rmem = &sysctl_udp_rmem_min, | 1461 | .sysctl_rmem = &sysctl_udp_rmem_min, |
| 1462 | .obj_size = sizeof(struct udp6_sock), | 1462 | .obj_size = sizeof(struct udp6_sock), |
| 1463 | .slab_flags = SLAB_DESTROY_BY_RCU, | ||
| 1464 | .h.udp_table = &udp_table, | 1463 | .h.udp_table = &udp_table, |
| 1465 | #ifdef CONFIG_COMPAT | 1464 | #ifdef CONFIG_COMPAT |
| 1466 | .compat_setsockopt = compat_udpv6_setsockopt, | 1465 | .compat_setsockopt = compat_udpv6_setsockopt, |
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c index 9cf097e206e9..fd6ef414899b 100644 --- a/net/ipv6/udplite.c +++ b/net/ipv6/udplite.c | |||
| @@ -50,7 +50,6 @@ struct proto udplitev6_prot = { | |||
| 50 | .unhash = udp_lib_unhash, | 50 | .unhash = udp_lib_unhash, |
| 51 | .get_port = udp_v6_get_port, | 51 | .get_port = udp_v6_get_port, |
| 52 | .obj_size = sizeof(struct udp6_sock), | 52 | .obj_size = sizeof(struct udp6_sock), |
| 53 | .slab_flags = SLAB_DESTROY_BY_RCU, | ||
| 54 | .h.udp_table = &udplite_table, | 53 | .h.udp_table = &udplite_table, |
| 55 | #ifdef CONFIG_COMPAT | 54 | #ifdef CONFIG_COMPAT |
| 56 | .compat_setsockopt = compat_udpv6_setsockopt, | 55 | .compat_setsockopt = compat_udpv6_setsockopt, |
diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c index 0eaab1fa6be5..00a2d40677d6 100644 --- a/net/ipv6/xfrm6_input.c +++ b/net/ipv6/xfrm6_input.c | |||
| @@ -23,6 +23,7 @@ int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 23 | 23 | ||
| 24 | int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) | 24 | int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) |
| 25 | { | 25 | { |
| 26 | XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6 = NULL; | ||
| 26 | XFRM_SPI_SKB_CB(skb)->family = AF_INET6; | 27 | XFRM_SPI_SKB_CB(skb)->family = AF_INET6; |
| 27 | XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct ipv6hdr, daddr); | 28 | XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct ipv6hdr, daddr); |
| 28 | return xfrm_input(skb, nexthdr, spi, 0); | 29 | return xfrm_input(skb, nexthdr, spi, 0); |
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 6cc97003e4a9..70a86adad875 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
| @@ -36,7 +36,7 @@ static struct dst_entry *xfrm6_dst_lookup(struct net *net, int tos, int oif, | |||
| 36 | int err; | 36 | int err; |
| 37 | 37 | ||
| 38 | memset(&fl6, 0, sizeof(fl6)); | 38 | memset(&fl6, 0, sizeof(fl6)); |
| 39 | fl6.flowi6_oif = oif; | 39 | fl6.flowi6_oif = l3mdev_master_ifindex_by_index(net, oif); |
| 40 | fl6.flowi6_flags = FLOWI_FLAG_SKIP_NH_OIF; | 40 | fl6.flowi6_flags = FLOWI_FLAG_SKIP_NH_OIF; |
| 41 | memcpy(&fl6.daddr, daddr, sizeof(fl6.daddr)); | 41 | memcpy(&fl6.daddr, daddr, sizeof(fl6.daddr)); |
| 42 | if (saddr) | 42 | if (saddr) |
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index cb39e05b166c..411693288648 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <linux/socket.h> | 13 | #include <linux/socket.h> |
| 14 | #include <linux/uaccess.h> | 14 | #include <linux/uaccess.h> |
| 15 | #include <linux/workqueue.h> | 15 | #include <linux/workqueue.h> |
| 16 | #include <linux/syscalls.h> | ||
| 16 | #include <net/kcm.h> | 17 | #include <net/kcm.h> |
| 17 | #include <net/netns/generic.h> | 18 | #include <net/netns/generic.h> |
| 18 | #include <net/sock.h> | 19 | #include <net/sock.h> |
| @@ -2029,7 +2030,7 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
| 2029 | if (copy_to_user((void __user *)arg, &info, | 2030 | if (copy_to_user((void __user *)arg, &info, |
| 2030 | sizeof(info))) { | 2031 | sizeof(info))) { |
| 2031 | err = -EFAULT; | 2032 | err = -EFAULT; |
| 2032 | sock_release(newsock); | 2033 | sys_close(info.fd); |
| 2033 | } | 2034 | } |
| 2034 | } | 2035 | } |
| 2035 | 2036 | ||
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index 1e40dacaa137..a2ed3bda4ddc 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c | |||
| @@ -1855,6 +1855,9 @@ static __net_exit void l2tp_exit_net(struct net *net) | |||
| 1855 | (void)l2tp_tunnel_delete(tunnel); | 1855 | (void)l2tp_tunnel_delete(tunnel); |
| 1856 | } | 1856 | } |
| 1857 | rcu_read_unlock_bh(); | 1857 | rcu_read_unlock_bh(); |
| 1858 | |||
| 1859 | flush_workqueue(l2tp_wq); | ||
| 1860 | rcu_barrier(); | ||
| 1858 | } | 1861 | } |
| 1859 | 1862 | ||
| 1860 | static struct pernet_operations l2tp_net_ops = { | 1863 | static struct pernet_operations l2tp_net_ops = { |
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index d9560aa2dba3..232cb92033e8 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c | |||
| @@ -856,7 +856,7 @@ static int pppol2tp_getname(struct socket *sock, struct sockaddr *uaddr, | |||
| 856 | error = -ENOTCONN; | 856 | error = -ENOTCONN; |
| 857 | if (sk == NULL) | 857 | if (sk == NULL) |
| 858 | goto end; | 858 | goto end; |
| 859 | if (sk->sk_state != PPPOX_CONNECTED) | 859 | if (!(sk->sk_state & PPPOX_CONNECTED)) |
| 860 | goto end; | 860 | goto end; |
| 861 | 861 | ||
| 862 | error = -EBADF; | 862 | error = -EBADF; |
diff --git a/net/mac80211/tdls.c b/net/mac80211/tdls.c index b5d28f14b9cf..afca7d103684 100644 --- a/net/mac80211/tdls.c +++ b/net/mac80211/tdls.c | |||
| @@ -333,10 +333,11 @@ ieee80211_tdls_chandef_vht_upgrade(struct ieee80211_sub_if_data *sdata, | |||
| 333 | if (!uc.center_freq1) | 333 | if (!uc.center_freq1) |
| 334 | return; | 334 | return; |
| 335 | 335 | ||
| 336 | /* proceed to downgrade the chandef until usable or the same */ | 336 | /* proceed to downgrade the chandef until usable or the same as AP BW */ |
| 337 | while (uc.width > max_width || | 337 | while (uc.width > max_width || |
| 338 | !cfg80211_reg_can_beacon_relax(sdata->local->hw.wiphy, &uc, | 338 | (uc.width > sta->tdls_chandef.width && |
| 339 | sdata->wdev.iftype)) | 339 | !cfg80211_reg_can_beacon_relax(sdata->local->hw.wiphy, &uc, |
| 340 | sdata->wdev.iftype))) | ||
| 340 | ieee80211_chandef_downgrade(&uc); | 341 | ieee80211_chandef_downgrade(&uc); |
| 341 | 342 | ||
| 342 | if (!cfg80211_chandef_identical(&uc, &sta->tdls_chandef)) { | 343 | if (!cfg80211_chandef_identical(&uc, &sta->tdls_chandef)) { |
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index 958a1455ca7f..9f267c3ffb39 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c | |||
| @@ -205,6 +205,7 @@ static int ct_seq_show(struct seq_file *s, void *v) | |||
| 205 | struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(hash); | 205 | struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(hash); |
| 206 | const struct nf_conntrack_l3proto *l3proto; | 206 | const struct nf_conntrack_l3proto *l3proto; |
| 207 | const struct nf_conntrack_l4proto *l4proto; | 207 | const struct nf_conntrack_l4proto *l4proto; |
| 208 | struct net *net = seq_file_net(s); | ||
| 208 | int ret = 0; | 209 | int ret = 0; |
| 209 | 210 | ||
| 210 | NF_CT_ASSERT(ct); | 211 | NF_CT_ASSERT(ct); |
| @@ -215,6 +216,9 @@ static int ct_seq_show(struct seq_file *s, void *v) | |||
| 215 | if (NF_CT_DIRECTION(hash)) | 216 | if (NF_CT_DIRECTION(hash)) |
| 216 | goto release; | 217 | goto release; |
| 217 | 218 | ||
| 219 | if (!net_eq(nf_ct_net(ct), net)) | ||
| 220 | goto release; | ||
| 221 | |||
| 218 | l3proto = __nf_ct_l3proto_find(nf_ct_l3num(ct)); | 222 | l3proto = __nf_ct_l3proto_find(nf_ct_l3num(ct)); |
| 219 | NF_CT_ASSERT(l3proto); | 223 | NF_CT_ASSERT(l3proto); |
| 220 | l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct)); | 224 | l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct)); |
diff --git a/net/netfilter/nf_tables_netdev.c b/net/netfilter/nf_tables_netdev.c index 5eefe4a355c6..75d696f11045 100644 --- a/net/netfilter/nf_tables_netdev.c +++ b/net/netfilter/nf_tables_netdev.c | |||
| @@ -30,7 +30,6 @@ nft_netdev_set_pktinfo_ipv4(struct nft_pktinfo *pkt, | |||
| 30 | if (!iph) | 30 | if (!iph) |
| 31 | return; | 31 | return; |
| 32 | 32 | ||
| 33 | iph = ip_hdr(skb); | ||
| 34 | if (iph->ihl < 5 || iph->version != 4) | 33 | if (iph->ihl < 5 || iph->version != 4) |
| 35 | return; | 34 | return; |
| 36 | 35 | ||
diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c index 1b4de4bd6958..d44d89b56127 100644 --- a/net/netfilter/nfnetlink_acct.c +++ b/net/netfilter/nfnetlink_acct.c | |||
| @@ -326,14 +326,14 @@ static int nfnl_acct_try_del(struct nf_acct *cur) | |||
| 326 | { | 326 | { |
| 327 | int ret = 0; | 327 | int ret = 0; |
| 328 | 328 | ||
| 329 | /* we want to avoid races with nfnl_acct_find_get. */ | 329 | /* We want to avoid races with nfnl_acct_put. So only when the current |
| 330 | if (atomic_dec_and_test(&cur->refcnt)) { | 330 | * refcnt is 1, we decrease it to 0. |
| 331 | */ | ||
| 332 | if (atomic_cmpxchg(&cur->refcnt, 1, 0) == 1) { | ||
| 331 | /* We are protected by nfnl mutex. */ | 333 | /* We are protected by nfnl mutex. */ |
| 332 | list_del_rcu(&cur->head); | 334 | list_del_rcu(&cur->head); |
| 333 | kfree_rcu(cur, rcu_head); | 335 | kfree_rcu(cur, rcu_head); |
| 334 | } else { | 336 | } else { |
| 335 | /* still in use, restore reference counter. */ | ||
| 336 | atomic_inc(&cur->refcnt); | ||
| 337 | ret = -EBUSY; | 337 | ret = -EBUSY; |
| 338 | } | 338 | } |
| 339 | return ret; | 339 | return ret; |
| @@ -343,12 +343,12 @@ static int nfnl_acct_del(struct net *net, struct sock *nfnl, | |||
| 343 | struct sk_buff *skb, const struct nlmsghdr *nlh, | 343 | struct sk_buff *skb, const struct nlmsghdr *nlh, |
| 344 | const struct nlattr * const tb[]) | 344 | const struct nlattr * const tb[]) |
| 345 | { | 345 | { |
| 346 | char *acct_name; | 346 | struct nf_acct *cur, *tmp; |
| 347 | struct nf_acct *cur; | ||
| 348 | int ret = -ENOENT; | 347 | int ret = -ENOENT; |
| 348 | char *acct_name; | ||
| 349 | 349 | ||
| 350 | if (!tb[NFACCT_NAME]) { | 350 | if (!tb[NFACCT_NAME]) { |
| 351 | list_for_each_entry(cur, &net->nfnl_acct_list, head) | 351 | list_for_each_entry_safe(cur, tmp, &net->nfnl_acct_list, head) |
| 352 | nfnl_acct_try_del(cur); | 352 | nfnl_acct_try_del(cur); |
| 353 | 353 | ||
| 354 | return 0; | 354 | return 0; |
| @@ -443,7 +443,7 @@ void nfnl_acct_update(const struct sk_buff *skb, struct nf_acct *nfacct) | |||
| 443 | } | 443 | } |
| 444 | EXPORT_SYMBOL_GPL(nfnl_acct_update); | 444 | EXPORT_SYMBOL_GPL(nfnl_acct_update); |
| 445 | 445 | ||
| 446 | static void nfnl_overquota_report(struct nf_acct *nfacct) | 446 | static void nfnl_overquota_report(struct net *net, struct nf_acct *nfacct) |
| 447 | { | 447 | { |
| 448 | int ret; | 448 | int ret; |
| 449 | struct sk_buff *skb; | 449 | struct sk_buff *skb; |
| @@ -458,11 +458,12 @@ static void nfnl_overquota_report(struct nf_acct *nfacct) | |||
| 458 | kfree_skb(skb); | 458 | kfree_skb(skb); |
| 459 | return; | 459 | return; |
| 460 | } | 460 | } |
| 461 | netlink_broadcast(init_net.nfnl, skb, 0, NFNLGRP_ACCT_QUOTA, | 461 | netlink_broadcast(net->nfnl, skb, 0, NFNLGRP_ACCT_QUOTA, |
| 462 | GFP_ATOMIC); | 462 | GFP_ATOMIC); |
| 463 | } | 463 | } |
| 464 | 464 | ||
| 465 | int nfnl_acct_overquota(const struct sk_buff *skb, struct nf_acct *nfacct) | 465 | int nfnl_acct_overquota(struct net *net, const struct sk_buff *skb, |
| 466 | struct nf_acct *nfacct) | ||
| 466 | { | 467 | { |
| 467 | u64 now; | 468 | u64 now; |
| 468 | u64 *quota; | 469 | u64 *quota; |
| @@ -480,7 +481,7 @@ int nfnl_acct_overquota(const struct sk_buff *skb, struct nf_acct *nfacct) | |||
| 480 | 481 | ||
| 481 | if (now >= *quota && | 482 | if (now >= *quota && |
| 482 | !test_and_set_bit(NFACCT_OVERQUOTA_BIT, &nfacct->flags)) { | 483 | !test_and_set_bit(NFACCT_OVERQUOTA_BIT, &nfacct->flags)) { |
| 483 | nfnl_overquota_report(nfacct); | 484 | nfnl_overquota_report(net, nfacct); |
| 484 | } | 485 | } |
| 485 | 486 | ||
| 486 | return ret; | 487 | return ret; |
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c index 4cdcd969b64c..139e0867e56e 100644 --- a/net/netfilter/nfnetlink_cttimeout.c +++ b/net/netfilter/nfnetlink_cttimeout.c | |||
| @@ -98,31 +98,28 @@ static int cttimeout_new_timeout(struct net *net, struct sock *ctnl, | |||
| 98 | break; | 98 | break; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | l4proto = nf_ct_l4proto_find_get(l3num, l4num); | ||
| 102 | |||
| 103 | /* This protocol is not supportted, skip. */ | ||
| 104 | if (l4proto->l4proto != l4num) { | ||
| 105 | ret = -EOPNOTSUPP; | ||
| 106 | goto err_proto_put; | ||
| 107 | } | ||
| 108 | |||
| 109 | if (matching) { | 101 | if (matching) { |
| 110 | if (nlh->nlmsg_flags & NLM_F_REPLACE) { | 102 | if (nlh->nlmsg_flags & NLM_F_REPLACE) { |
| 111 | /* You cannot replace one timeout policy by another of | 103 | /* You cannot replace one timeout policy by another of |
| 112 | * different kind, sorry. | 104 | * different kind, sorry. |
| 113 | */ | 105 | */ |
| 114 | if (matching->l3num != l3num || | 106 | if (matching->l3num != l3num || |
| 115 | matching->l4proto->l4proto != l4num) { | 107 | matching->l4proto->l4proto != l4num) |
| 116 | ret = -EINVAL; | 108 | return -EINVAL; |
| 117 | goto err_proto_put; | 109 | |
| 118 | } | 110 | return ctnl_timeout_parse_policy(&matching->data, |
| 119 | 111 | matching->l4proto, net, | |
| 120 | ret = ctnl_timeout_parse_policy(&matching->data, | 112 | cda[CTA_TIMEOUT_DATA]); |
| 121 | l4proto, net, | ||
| 122 | cda[CTA_TIMEOUT_DATA]); | ||
| 123 | return ret; | ||
| 124 | } | 113 | } |
| 125 | ret = -EBUSY; | 114 | |
| 115 | return -EBUSY; | ||
| 116 | } | ||
| 117 | |||
| 118 | l4proto = nf_ct_l4proto_find_get(l3num, l4num); | ||
| 119 | |||
| 120 | /* This protocol is not supportted, skip. */ | ||
| 121 | if (l4proto->l4proto != l4num) { | ||
| 122 | ret = -EOPNOTSUPP; | ||
| 126 | goto err_proto_put; | 123 | goto err_proto_put; |
| 127 | } | 124 | } |
| 128 | 125 | ||
| @@ -305,7 +302,16 @@ static void ctnl_untimeout(struct net *net, struct ctnl_timeout *timeout) | |||
| 305 | const struct hlist_nulls_node *nn; | 302 | const struct hlist_nulls_node *nn; |
| 306 | unsigned int last_hsize; | 303 | unsigned int last_hsize; |
| 307 | spinlock_t *lock; | 304 | spinlock_t *lock; |
| 308 | int i; | 305 | int i, cpu; |
| 306 | |||
| 307 | for_each_possible_cpu(cpu) { | ||
| 308 | struct ct_pcpu *pcpu = per_cpu_ptr(net->ct.pcpu_lists, cpu); | ||
| 309 | |||
| 310 | spin_lock_bh(&pcpu->lock); | ||
| 311 | hlist_nulls_for_each_entry(h, nn, &pcpu->unconfirmed, hnnode) | ||
| 312 | untimeout(h, timeout); | ||
| 313 | spin_unlock_bh(&pcpu->lock); | ||
| 314 | } | ||
| 309 | 315 | ||
| 310 | local_bh_disable(); | 316 | local_bh_disable(); |
| 311 | restart: | 317 | restart: |
| @@ -330,16 +336,16 @@ static int ctnl_timeout_try_del(struct net *net, struct ctnl_timeout *timeout) | |||
| 330 | { | 336 | { |
| 331 | int ret = 0; | 337 | int ret = 0; |
| 332 | 338 | ||
| 333 | /* we want to avoid races with nf_ct_timeout_find_get. */ | 339 | /* We want to avoid races with ctnl_timeout_put. So only when the |
| 334 | if (atomic_dec_and_test(&timeout->refcnt)) { | 340 | * current refcnt is 1, we decrease it to 0. |
| 341 | */ | ||
| 342 | if (atomic_cmpxchg(&timeout->refcnt, 1, 0) == 1) { | ||
| 335 | /* We are protected by nfnl mutex. */ | 343 | /* We are protected by nfnl mutex. */ |
| 336 | list_del_rcu(&timeout->head); | 344 | list_del_rcu(&timeout->head); |
| 337 | nf_ct_l4proto_put(timeout->l4proto); | 345 | nf_ct_l4proto_put(timeout->l4proto); |
| 338 | ctnl_untimeout(net, timeout); | 346 | ctnl_untimeout(net, timeout); |
| 339 | kfree_rcu(timeout, rcu_head); | 347 | kfree_rcu(timeout, rcu_head); |
| 340 | } else { | 348 | } else { |
| 341 | /* still in use, restore reference counter. */ | ||
| 342 | atomic_inc(&timeout->refcnt); | ||
| 343 | ret = -EBUSY; | 349 | ret = -EBUSY; |
| 344 | } | 350 | } |
| 345 | return ret; | 351 | return ret; |
| @@ -350,12 +356,13 @@ static int cttimeout_del_timeout(struct net *net, struct sock *ctnl, | |||
| 350 | const struct nlmsghdr *nlh, | 356 | const struct nlmsghdr *nlh, |
| 351 | const struct nlattr * const cda[]) | 357 | const struct nlattr * const cda[]) |
| 352 | { | 358 | { |
| 353 | struct ctnl_timeout *cur; | 359 | struct ctnl_timeout *cur, *tmp; |
| 354 | int ret = -ENOENT; | 360 | int ret = -ENOENT; |
| 355 | char *name; | 361 | char *name; |
| 356 | 362 | ||
| 357 | if (!cda[CTA_TIMEOUT_NAME]) { | 363 | if (!cda[CTA_TIMEOUT_NAME]) { |
| 358 | list_for_each_entry(cur, &net->nfct_timeout_list, head) | 364 | list_for_each_entry_safe(cur, tmp, &net->nfct_timeout_list, |
| 365 | head) | ||
| 359 | ctnl_timeout_try_del(net, cur); | 366 | ctnl_timeout_try_del(net, cur); |
| 360 | 367 | ||
| 361 | return 0; | 368 | return 0; |
| @@ -543,7 +550,9 @@ err: | |||
| 543 | 550 | ||
| 544 | static void ctnl_timeout_put(struct ctnl_timeout *timeout) | 551 | static void ctnl_timeout_put(struct ctnl_timeout *timeout) |
| 545 | { | 552 | { |
| 546 | atomic_dec(&timeout->refcnt); | 553 | if (atomic_dec_and_test(&timeout->refcnt)) |
| 554 | kfree_rcu(timeout, rcu_head); | ||
| 555 | |||
| 547 | module_put(THIS_MODULE); | 556 | module_put(THIS_MODULE); |
| 548 | } | 557 | } |
| 549 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ | 558 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| @@ -591,7 +600,9 @@ static void __net_exit cttimeout_net_exit(struct net *net) | |||
| 591 | list_for_each_entry_safe(cur, tmp, &net->nfct_timeout_list, head) { | 600 | list_for_each_entry_safe(cur, tmp, &net->nfct_timeout_list, head) { |
| 592 | list_del_rcu(&cur->head); | 601 | list_del_rcu(&cur->head); |
| 593 | nf_ct_l4proto_put(cur->l4proto); | 602 | nf_ct_l4proto_put(cur->l4proto); |
| 594 | kfree_rcu(cur, rcu_head); | 603 | |
| 604 | if (atomic_dec_and_test(&cur->refcnt)) | ||
| 605 | kfree_rcu(cur, rcu_head); | ||
| 595 | } | 606 | } |
| 596 | } | 607 | } |
| 597 | 608 | ||
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c index cbcfdfb586a6..6577db524ef6 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c | |||
| @@ -1147,6 +1147,7 @@ MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_ULOG); | |||
| 1147 | MODULE_ALIAS_NF_LOGGER(AF_INET, 1); | 1147 | MODULE_ALIAS_NF_LOGGER(AF_INET, 1); |
| 1148 | MODULE_ALIAS_NF_LOGGER(AF_INET6, 1); | 1148 | MODULE_ALIAS_NF_LOGGER(AF_INET6, 1); |
| 1149 | MODULE_ALIAS_NF_LOGGER(AF_BRIDGE, 1); | 1149 | MODULE_ALIAS_NF_LOGGER(AF_BRIDGE, 1); |
| 1150 | MODULE_ALIAS_NF_LOGGER(3, 1); /* NFPROTO_ARP */ | ||
| 1150 | 1151 | ||
| 1151 | module_init(nfnetlink_log_init); | 1152 | module_init(nfnetlink_log_init); |
| 1152 | module_exit(nfnetlink_log_fini); | 1153 | module_exit(nfnetlink_log_fini); |
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c index 2863f3493038..8a6bc7630912 100644 --- a/net/netfilter/nft_meta.c +++ b/net/netfilter/nft_meta.c | |||
| @@ -291,10 +291,16 @@ int nft_meta_get_init(const struct nft_ctx *ctx, | |||
| 291 | } | 291 | } |
| 292 | EXPORT_SYMBOL_GPL(nft_meta_get_init); | 292 | EXPORT_SYMBOL_GPL(nft_meta_get_init); |
| 293 | 293 | ||
| 294 | static int nft_meta_set_init_pkttype(const struct nft_ctx *ctx) | 294 | int nft_meta_set_validate(const struct nft_ctx *ctx, |
| 295 | const struct nft_expr *expr, | ||
| 296 | const struct nft_data **data) | ||
| 295 | { | 297 | { |
| 298 | struct nft_meta *priv = nft_expr_priv(expr); | ||
| 296 | unsigned int hooks; | 299 | unsigned int hooks; |
| 297 | 300 | ||
| 301 | if (priv->key != NFT_META_PKTTYPE) | ||
| 302 | return 0; | ||
| 303 | |||
| 298 | switch (ctx->afi->family) { | 304 | switch (ctx->afi->family) { |
| 299 | case NFPROTO_BRIDGE: | 305 | case NFPROTO_BRIDGE: |
| 300 | hooks = 1 << NF_BR_PRE_ROUTING; | 306 | hooks = 1 << NF_BR_PRE_ROUTING; |
| @@ -308,6 +314,7 @@ static int nft_meta_set_init_pkttype(const struct nft_ctx *ctx) | |||
| 308 | 314 | ||
| 309 | return nft_chain_validate_hooks(ctx->chain, hooks); | 315 | return nft_chain_validate_hooks(ctx->chain, hooks); |
| 310 | } | 316 | } |
| 317 | EXPORT_SYMBOL_GPL(nft_meta_set_validate); | ||
| 311 | 318 | ||
| 312 | int nft_meta_set_init(const struct nft_ctx *ctx, | 319 | int nft_meta_set_init(const struct nft_ctx *ctx, |
| 313 | const struct nft_expr *expr, | 320 | const struct nft_expr *expr, |
| @@ -327,15 +334,16 @@ int nft_meta_set_init(const struct nft_ctx *ctx, | |||
| 327 | len = sizeof(u8); | 334 | len = sizeof(u8); |
| 328 | break; | 335 | break; |
| 329 | case NFT_META_PKTTYPE: | 336 | case NFT_META_PKTTYPE: |
| 330 | err = nft_meta_set_init_pkttype(ctx); | ||
| 331 | if (err) | ||
| 332 | return err; | ||
| 333 | len = sizeof(u8); | 337 | len = sizeof(u8); |
| 334 | break; | 338 | break; |
| 335 | default: | 339 | default: |
| 336 | return -EOPNOTSUPP; | 340 | return -EOPNOTSUPP; |
| 337 | } | 341 | } |
| 338 | 342 | ||
| 343 | err = nft_meta_set_validate(ctx, expr, NULL); | ||
| 344 | if (err < 0) | ||
| 345 | return err; | ||
| 346 | |||
| 339 | priv->sreg = nft_parse_register(tb[NFTA_META_SREG]); | 347 | priv->sreg = nft_parse_register(tb[NFTA_META_SREG]); |
| 340 | err = nft_validate_register_load(priv->sreg, len); | 348 | err = nft_validate_register_load(priv->sreg, len); |
| 341 | if (err < 0) | 349 | if (err < 0) |
| @@ -407,6 +415,7 @@ static const struct nft_expr_ops nft_meta_set_ops = { | |||
| 407 | .init = nft_meta_set_init, | 415 | .init = nft_meta_set_init, |
| 408 | .destroy = nft_meta_set_destroy, | 416 | .destroy = nft_meta_set_destroy, |
| 409 | .dump = nft_meta_set_dump, | 417 | .dump = nft_meta_set_dump, |
| 418 | .validate = nft_meta_set_validate, | ||
| 410 | }; | 419 | }; |
| 411 | 420 | ||
| 412 | static const struct nft_expr_ops * | 421 | static const struct nft_expr_ops * |
diff --git a/net/netfilter/nft_reject.c b/net/netfilter/nft_reject.c index 0522fc9bfb0a..c64de3f7379d 100644 --- a/net/netfilter/nft_reject.c +++ b/net/netfilter/nft_reject.c | |||
| @@ -26,11 +26,27 @@ const struct nla_policy nft_reject_policy[NFTA_REJECT_MAX + 1] = { | |||
| 26 | }; | 26 | }; |
| 27 | EXPORT_SYMBOL_GPL(nft_reject_policy); | 27 | EXPORT_SYMBOL_GPL(nft_reject_policy); |
| 28 | 28 | ||
| 29 | int nft_reject_validate(const struct nft_ctx *ctx, | ||
| 30 | const struct nft_expr *expr, | ||
| 31 | const struct nft_data **data) | ||
| 32 | { | ||
| 33 | return nft_chain_validate_hooks(ctx->chain, | ||
| 34 | (1 << NF_INET_LOCAL_IN) | | ||
| 35 | (1 << NF_INET_FORWARD) | | ||
| 36 | (1 << NF_INET_LOCAL_OUT)); | ||
| 37 | } | ||
| 38 | EXPORT_SYMBOL_GPL(nft_reject_validate); | ||
| 39 | |||
| 29 | int nft_reject_init(const struct nft_ctx *ctx, | 40 | int nft_reject_init(const struct nft_ctx *ctx, |
| 30 | const struct nft_expr *expr, | 41 | const struct nft_expr *expr, |
| 31 | const struct nlattr * const tb[]) | 42 | const struct nlattr * const tb[]) |
| 32 | { | 43 | { |
| 33 | struct nft_reject *priv = nft_expr_priv(expr); | 44 | struct nft_reject *priv = nft_expr_priv(expr); |
| 45 | int err; | ||
| 46 | |||
| 47 | err = nft_reject_validate(ctx, expr, NULL); | ||
| 48 | if (err < 0) | ||
| 49 | return err; | ||
| 34 | 50 | ||
| 35 | if (tb[NFTA_REJECT_TYPE] == NULL) | 51 | if (tb[NFTA_REJECT_TYPE] == NULL) |
| 36 | return -EINVAL; | 52 | return -EINVAL; |
diff --git a/net/netfilter/nft_reject_inet.c b/net/netfilter/nft_reject_inet.c index 759ca5248a3d..e79d9ca2ffee 100644 --- a/net/netfilter/nft_reject_inet.c +++ b/net/netfilter/nft_reject_inet.c | |||
| @@ -66,7 +66,11 @@ static int nft_reject_inet_init(const struct nft_ctx *ctx, | |||
| 66 | const struct nlattr * const tb[]) | 66 | const struct nlattr * const tb[]) |
| 67 | { | 67 | { |
| 68 | struct nft_reject *priv = nft_expr_priv(expr); | 68 | struct nft_reject *priv = nft_expr_priv(expr); |
| 69 | int icmp_code; | 69 | int icmp_code, err; |
| 70 | |||
| 71 | err = nft_reject_validate(ctx, expr, NULL); | ||
| 72 | if (err < 0) | ||
| 73 | return err; | ||
| 70 | 74 | ||
| 71 | if (tb[NFTA_REJECT_TYPE] == NULL) | 75 | if (tb[NFTA_REJECT_TYPE] == NULL) |
| 72 | return -EINVAL; | 76 | return -EINVAL; |
| @@ -124,6 +128,7 @@ static const struct nft_expr_ops nft_reject_inet_ops = { | |||
| 124 | .eval = nft_reject_inet_eval, | 128 | .eval = nft_reject_inet_eval, |
| 125 | .init = nft_reject_inet_init, | 129 | .init = nft_reject_inet_init, |
| 126 | .dump = nft_reject_inet_dump, | 130 | .dump = nft_reject_inet_dump, |
| 131 | .validate = nft_reject_validate, | ||
| 127 | }; | 132 | }; |
| 128 | 133 | ||
| 129 | static struct nft_expr_type nft_reject_inet_type __read_mostly = { | 134 | static struct nft_expr_type nft_reject_inet_type __read_mostly = { |
diff --git a/net/netfilter/xt_TPROXY.c b/net/netfilter/xt_TPROXY.c index 7f4414d26a66..663c4c3c9072 100644 --- a/net/netfilter/xt_TPROXY.c +++ b/net/netfilter/xt_TPROXY.c | |||
| @@ -127,6 +127,8 @@ nf_tproxy_get_sock_v4(struct net *net, struct sk_buff *skb, void *hp, | |||
| 127 | daddr, dport, | 127 | daddr, dport, |
| 128 | in->ifindex); | 128 | in->ifindex); |
| 129 | 129 | ||
| 130 | if (sk && !atomic_inc_not_zero(&sk->sk_refcnt)) | ||
| 131 | sk = NULL; | ||
| 130 | /* NOTE: we return listeners even if bound to | 132 | /* NOTE: we return listeners even if bound to |
| 131 | * 0.0.0.0, those are filtered out in | 133 | * 0.0.0.0, those are filtered out in |
| 132 | * xt_socket, since xt_TPROXY needs 0 bound | 134 | * xt_socket, since xt_TPROXY needs 0 bound |
| @@ -195,6 +197,8 @@ nf_tproxy_get_sock_v6(struct net *net, struct sk_buff *skb, int thoff, void *hp, | |||
| 195 | daddr, ntohs(dport), | 197 | daddr, ntohs(dport), |
| 196 | in->ifindex); | 198 | in->ifindex); |
| 197 | 199 | ||
| 200 | if (sk && !atomic_inc_not_zero(&sk->sk_refcnt)) | ||
| 201 | sk = NULL; | ||
| 198 | /* NOTE: we return listeners even if bound to | 202 | /* NOTE: we return listeners even if bound to |
| 199 | * 0.0.0.0, those are filtered out in | 203 | * 0.0.0.0, those are filtered out in |
| 200 | * xt_socket, since xt_TPROXY needs 0 bound | 204 | * xt_socket, since xt_TPROXY needs 0 bound |
diff --git a/net/netfilter/xt_nfacct.c b/net/netfilter/xt_nfacct.c index 3048a7e3a90a..cf327593852a 100644 --- a/net/netfilter/xt_nfacct.c +++ b/net/netfilter/xt_nfacct.c | |||
| @@ -26,7 +26,7 @@ static bool nfacct_mt(const struct sk_buff *skb, struct xt_action_param *par) | |||
| 26 | 26 | ||
| 27 | nfnl_acct_update(skb, info->nfacct); | 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 | return overquota == NFACCT_UNDERQUOTA ? false : true; | 31 | return overquota == NFACCT_UNDERQUOTA ? false : true; |
| 32 | } | 32 | } |
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c index 141a06eeb1e5..e87cd81315e1 100644 --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c | |||
| @@ -53,7 +53,7 @@ int ife_tlv_meta_encode(void *skbdata, u16 attrtype, u16 dlen, const void *dval) | |||
| 53 | u32 *tlv = (u32 *)(skbdata); | 53 | u32 *tlv = (u32 *)(skbdata); |
| 54 | u16 totlen = nla_total_size(dlen); /*alignment + hdr */ | 54 | u16 totlen = nla_total_size(dlen); /*alignment + hdr */ |
| 55 | char *dptr = (char *)tlv + NLA_HDRLEN; | 55 | char *dptr = (char *)tlv + NLA_HDRLEN; |
| 56 | u32 htlv = attrtype << 16 | totlen; | 56 | u32 htlv = attrtype << 16 | dlen; |
| 57 | 57 | ||
| 58 | *tlv = htonl(htlv); | 58 | *tlv = htonl(htlv); |
| 59 | memset(dptr, 0, totlen - NLA_HDRLEN); | 59 | memset(dptr, 0, totlen - NLA_HDRLEN); |
| @@ -135,7 +135,7 @@ EXPORT_SYMBOL_GPL(ife_release_meta_gen); | |||
| 135 | 135 | ||
| 136 | int ife_validate_meta_u32(void *val, int len) | 136 | int ife_validate_meta_u32(void *val, int len) |
| 137 | { | 137 | { |
| 138 | if (len == 4) | 138 | if (len == sizeof(u32)) |
| 139 | return 0; | 139 | return 0; |
| 140 | 140 | ||
| 141 | return -EINVAL; | 141 | return -EINVAL; |
| @@ -144,8 +144,8 @@ EXPORT_SYMBOL_GPL(ife_validate_meta_u32); | |||
| 144 | 144 | ||
| 145 | int ife_validate_meta_u16(void *val, int len) | 145 | int ife_validate_meta_u16(void *val, int len) |
| 146 | { | 146 | { |
| 147 | /* length will include padding */ | 147 | /* length will not include padding */ |
| 148 | if (len == NLA_ALIGN(2)) | 148 | if (len == sizeof(u16)) |
| 149 | return 0; | 149 | return 0; |
| 150 | 150 | ||
| 151 | return -EINVAL; | 151 | return -EINVAL; |
| @@ -652,12 +652,14 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a, | |||
| 652 | u8 *tlvdata = (u8 *)tlv; | 652 | u8 *tlvdata = (u8 *)tlv; |
| 653 | u16 mtype = tlv->type; | 653 | u16 mtype = tlv->type; |
| 654 | u16 mlen = tlv->len; | 654 | u16 mlen = tlv->len; |
| 655 | u16 alen; | ||
| 655 | 656 | ||
| 656 | mtype = ntohs(mtype); | 657 | mtype = ntohs(mtype); |
| 657 | mlen = ntohs(mlen); | 658 | mlen = ntohs(mlen); |
| 659 | alen = NLA_ALIGN(mlen); | ||
| 658 | 660 | ||
| 659 | if (find_decode_metaid(skb, ife, mtype, (mlen - 4), | 661 | if (find_decode_metaid(skb, ife, mtype, (mlen - NLA_HDRLEN), |
| 660 | (void *)(tlvdata + 4))) { | 662 | (void *)(tlvdata + NLA_HDRLEN))) { |
| 661 | /* abuse overlimits to count when we receive metadata | 663 | /* abuse overlimits to count when we receive metadata |
| 662 | * but dont have an ops for it | 664 | * but dont have an ops for it |
| 663 | */ | 665 | */ |
| @@ -666,8 +668,8 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a, | |||
| 666 | ife->tcf_qstats.overlimits++; | 668 | ife->tcf_qstats.overlimits++; |
| 667 | } | 669 | } |
| 668 | 670 | ||
| 669 | tlvdata += mlen; | 671 | tlvdata += alen; |
| 670 | ifehdrln -= mlen; | 672 | ifehdrln -= alen; |
| 671 | tlv = (struct meta_tlvhdr *)tlvdata; | 673 | tlv = (struct meta_tlvhdr *)tlvdata; |
| 672 | } | 674 | } |
| 673 | 675 | ||
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index e95b67cd5718..657c13362b19 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c | |||
| @@ -643,18 +643,19 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue, | |||
| 643 | struct Qdisc *sch; | 643 | struct Qdisc *sch; |
| 644 | 644 | ||
| 645 | if (!try_module_get(ops->owner)) | 645 | if (!try_module_get(ops->owner)) |
| 646 | goto errout; | 646 | return NULL; |
| 647 | 647 | ||
| 648 | sch = qdisc_alloc(dev_queue, ops); | 648 | sch = qdisc_alloc(dev_queue, ops); |
| 649 | if (IS_ERR(sch)) | 649 | if (IS_ERR(sch)) { |
| 650 | goto errout; | 650 | module_put(ops->owner); |
| 651 | return NULL; | ||
| 652 | } | ||
| 651 | sch->parent = parentid; | 653 | sch->parent = parentid; |
| 652 | 654 | ||
| 653 | if (!ops->init || ops->init(sch, NULL) == 0) | 655 | if (!ops->init || ops->init(sch, NULL) == 0) |
| 654 | return sch; | 656 | return sch; |
| 655 | 657 | ||
| 656 | qdisc_destroy(sch); | 658 | qdisc_destroy(sch); |
| 657 | errout: | ||
| 658 | return NULL; | 659 | return NULL; |
| 659 | } | 660 | } |
| 660 | EXPORT_SYMBOL(qdisc_create_dflt); | 661 | EXPORT_SYMBOL(qdisc_create_dflt); |
diff --git a/net/sctp/input.c b/net/sctp/input.c index c182db7d691f..69444d32ecda 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c | |||
| @@ -119,7 +119,13 @@ int sctp_rcv(struct sk_buff *skb) | |||
| 119 | skb_transport_offset(skb)) | 119 | skb_transport_offset(skb)) |
| 120 | goto discard_it; | 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 | goto discard_it; | 129 | goto discard_it; |
| 124 | 130 | ||
| 125 | /* Pull up the IP header. */ | 131 | /* Pull up the IP header. */ |
| @@ -1177,9 +1183,6 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net, | |||
| 1177 | if ((skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) | 1183 | if ((skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) |
| 1178 | return NULL; | 1184 | return NULL; |
| 1179 | 1185 | ||
| 1180 | if (skb_linearize(skb)) | ||
| 1181 | return NULL; | ||
| 1182 | |||
| 1183 | ch = (sctp_chunkhdr_t *) skb->data; | 1186 | ch = (sctp_chunkhdr_t *) skb->data; |
| 1184 | 1187 | ||
| 1185 | /* The code below will attempt to walk the chunk and extract | 1188 | /* The code below will attempt to walk the chunk and extract |
diff --git a/net/sctp/inqueue.c b/net/sctp/inqueue.c index c30ddb0f3190..6437aa97cfd7 100644 --- a/net/sctp/inqueue.c +++ b/net/sctp/inqueue.c | |||
| @@ -170,19 +170,6 @@ next_chunk: | |||
| 170 | 170 | ||
| 171 | chunk = list_entry(entry, struct sctp_chunk, list); | 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 | if ((skb_shinfo(chunk->skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) { | 173 | if ((skb_shinfo(chunk->skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) { |
| 187 | /* GSO-marked skbs but without frags, handle | 174 | /* GSO-marked skbs but without frags, handle |
| 188 | * them normally | 175 | * them normally |
diff --git a/net/sctp/output.c b/net/sctp/output.c index 1f1682b9a6a8..31b7bc35895d 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c | |||
| @@ -878,7 +878,7 @@ static sctp_xmit_t sctp_packet_will_fit(struct sctp_packet *packet, | |||
| 878 | struct sctp_chunk *chunk, | 878 | struct sctp_chunk *chunk, |
| 879 | u16 chunk_len) | 879 | u16 chunk_len) |
| 880 | { | 880 | { |
| 881 | size_t psize, pmtu; | 881 | size_t psize, pmtu, maxsize; |
| 882 | sctp_xmit_t retval = SCTP_XMIT_OK; | 882 | sctp_xmit_t retval = SCTP_XMIT_OK; |
| 883 | 883 | ||
| 884 | psize = packet->size; | 884 | psize = packet->size; |
| @@ -906,6 +906,17 @@ static sctp_xmit_t sctp_packet_will_fit(struct sctp_packet *packet, | |||
| 906 | goto out; | 906 | goto out; |
| 907 | } | 907 | } |
| 908 | 908 | ||
| 909 | /* Similarly, if this chunk was built before a PMTU | ||
| 910 | * reduction, we have to fragment it at IP level now. So | ||
| 911 | * if the packet already contains something, we need to | ||
| 912 | * flush. | ||
| 913 | */ | ||
| 914 | maxsize = pmtu - packet->overhead; | ||
| 915 | if (packet->auth) | ||
| 916 | maxsize -= WORD_ROUND(packet->auth->skb->len); | ||
| 917 | if (chunk_len > maxsize) | ||
| 918 | retval = SCTP_XMIT_PMTU_FULL; | ||
| 919 | |||
| 909 | /* It is also okay to fragment if the chunk we are | 920 | /* It is also okay to fragment if the chunk we are |
| 910 | * adding is a control chunk, but only if current packet | 921 | * adding is a control chunk, but only if current packet |
| 911 | * is not a GSO one otherwise it causes fragmentation of | 922 | * is not a GSO one otherwise it causes fragmentation of |
diff --git a/net/sctp/sctp_diag.c b/net/sctp/sctp_diag.c index bb691538adc8..f3508aa75815 100644 --- a/net/sctp/sctp_diag.c +++ b/net/sctp/sctp_diag.c | |||
| @@ -424,11 +424,13 @@ static int sctp_diag_dump_one(struct sk_buff *in_skb, | |||
| 424 | paddr.v4.sin_family = AF_INET; | 424 | paddr.v4.sin_family = AF_INET; |
| 425 | } else { | 425 | } else { |
| 426 | laddr.v6.sin6_port = req->id.idiag_sport; | 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 | laddr.v6.sin6_family = AF_INET6; | 429 | laddr.v6.sin6_family = AF_INET6; |
| 429 | 430 | ||
| 430 | paddr.v6.sin6_port = req->id.idiag_dport; | 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 | paddr.v6.sin6_family = AF_INET6; | 434 | paddr.v6.sin6_family = AF_INET6; |
| 433 | } | 435 | } |
| 434 | 436 | ||
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 1d281816f2bf..d8582028b346 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c | |||
| @@ -569,9 +569,10 @@ gss_svc_searchbyctx(struct cache_detail *cd, struct xdr_netobj *handle) | |||
| 569 | struct rsc *found; | 569 | struct rsc *found; |
| 570 | 570 | ||
| 571 | memset(&rsci, 0, sizeof(rsci)); | 571 | memset(&rsci, 0, sizeof(rsci)); |
| 572 | rsci.handle.data = handle->data; | 572 | if (dup_to_netobj(&rsci.handle, handle->data, handle->len)) |
| 573 | rsci.handle.len = handle->len; | 573 | return NULL; |
| 574 | found = rsc_lookup(cd, &rsci); | 574 | found = rsc_lookup(cd, &rsci); |
| 575 | rsc_free(&rsci); | ||
| 575 | if (!found) | 576 | if (!found) |
| 576 | return NULL; | 577 | return NULL; |
| 577 | if (cache_check(cd, &found->h, NULL)) | 578 | if (cache_check(cd, &found->h, NULL)) |
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 7f79fb7dc6a0..66f23b376fa0 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
| @@ -453,7 +453,7 @@ static struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args, | |||
| 453 | struct rpc_xprt_switch *xps; | 453 | struct rpc_xprt_switch *xps; |
| 454 | 454 | ||
| 455 | if (args->bc_xprt && args->bc_xprt->xpt_bc_xps) { | 455 | if (args->bc_xprt && args->bc_xprt->xpt_bc_xps) { |
| 456 | WARN_ON(args->protocol != XPRT_TRANSPORT_BC_TCP); | 456 | WARN_ON_ONCE(!(args->protocol & XPRT_TRANSPORT_BC)); |
| 457 | xps = args->bc_xprt->xpt_bc_xps; | 457 | xps = args->bc_xprt->xpt_bc_xps; |
| 458 | xprt_switch_get(xps); | 458 | xprt_switch_get(xps); |
| 459 | } else { | 459 | } else { |
| @@ -520,7 +520,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) | |||
| 520 | char servername[48]; | 520 | char servername[48]; |
| 521 | 521 | ||
| 522 | if (args->bc_xprt) { | 522 | if (args->bc_xprt) { |
| 523 | WARN_ON(args->protocol != XPRT_TRANSPORT_BC_TCP); | 523 | WARN_ON_ONCE(!(args->protocol & XPRT_TRANSPORT_BC)); |
| 524 | xprt = args->bc_xprt->xpt_bc_xprt; | 524 | xprt = args->bc_xprt->xpt_bc_xprt; |
| 525 | if (xprt) { | 525 | if (xprt) { |
| 526 | xprt_get(xprt); | 526 | xprt_get(xprt); |
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c index 536d0be3f61b..799cce6cbe45 100644 --- a/net/sunrpc/xprtrdma/verbs.c +++ b/net/sunrpc/xprtrdma/verbs.c | |||
| @@ -51,6 +51,7 @@ | |||
| 51 | #include <linux/slab.h> | 51 | #include <linux/slab.h> |
| 52 | #include <linux/prefetch.h> | 52 | #include <linux/prefetch.h> |
| 53 | #include <linux/sunrpc/addr.h> | 53 | #include <linux/sunrpc/addr.h> |
| 54 | #include <linux/sunrpc/svc_rdma.h> | ||
| 54 | #include <asm/bitops.h> | 55 | #include <asm/bitops.h> |
| 55 | #include <linux/module.h> /* try_module_get()/module_put() */ | 56 | #include <linux/module.h> /* try_module_get()/module_put() */ |
| 56 | 57 | ||
| @@ -923,7 +924,7 @@ rpcrdma_buffer_create(struct rpcrdma_xprt *r_xprt) | |||
| 923 | } | 924 | } |
| 924 | 925 | ||
| 925 | INIT_LIST_HEAD(&buf->rb_recv_bufs); | 926 | INIT_LIST_HEAD(&buf->rb_recv_bufs); |
| 926 | for (i = 0; i < buf->rb_max_requests; i++) { | 927 | for (i = 0; i < buf->rb_max_requests + RPCRDMA_MAX_BC_REQUESTS; i++) { |
| 927 | struct rpcrdma_rep *rep; | 928 | struct rpcrdma_rep *rep; |
| 928 | 929 | ||
| 929 | rep = rpcrdma_create_rep(r_xprt); | 930 | rep = rpcrdma_create_rep(r_xprt); |
| @@ -1018,6 +1019,7 @@ rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf) | |||
| 1018 | rep = rpcrdma_buffer_get_rep_locked(buf); | 1019 | rep = rpcrdma_buffer_get_rep_locked(buf); |
| 1019 | rpcrdma_destroy_rep(ia, rep); | 1020 | rpcrdma_destroy_rep(ia, rep); |
| 1020 | } | 1021 | } |
| 1022 | buf->rb_send_count = 0; | ||
| 1021 | 1023 | ||
| 1022 | spin_lock(&buf->rb_reqslock); | 1024 | spin_lock(&buf->rb_reqslock); |
| 1023 | while (!list_empty(&buf->rb_allreqs)) { | 1025 | while (!list_empty(&buf->rb_allreqs)) { |
| @@ -1032,6 +1034,7 @@ rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf) | |||
| 1032 | spin_lock(&buf->rb_reqslock); | 1034 | spin_lock(&buf->rb_reqslock); |
| 1033 | } | 1035 | } |
| 1034 | spin_unlock(&buf->rb_reqslock); | 1036 | spin_unlock(&buf->rb_reqslock); |
| 1037 | buf->rb_recv_count = 0; | ||
| 1035 | 1038 | ||
| 1036 | rpcrdma_destroy_mrs(buf); | 1039 | rpcrdma_destroy_mrs(buf); |
| 1037 | } | 1040 | } |
| @@ -1074,8 +1077,27 @@ rpcrdma_put_mw(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mw *mw) | |||
| 1074 | spin_unlock(&buf->rb_mwlock); | 1077 | spin_unlock(&buf->rb_mwlock); |
| 1075 | } | 1078 | } |
| 1076 | 1079 | ||
| 1080 | static struct rpcrdma_rep * | ||
| 1081 | rpcrdma_buffer_get_rep(struct rpcrdma_buffer *buffers) | ||
| 1082 | { | ||
| 1083 | /* If an RPC previously completed without a reply (say, a | ||
| 1084 | * credential problem or a soft timeout occurs) then hold off | ||
| 1085 | * on supplying more Receive buffers until the number of new | ||
| 1086 | * pending RPCs catches up to the number of posted Receives. | ||
| 1087 | */ | ||
| 1088 | if (unlikely(buffers->rb_send_count < buffers->rb_recv_count)) | ||
| 1089 | return NULL; | ||
| 1090 | |||
| 1091 | if (unlikely(list_empty(&buffers->rb_recv_bufs))) | ||
| 1092 | return NULL; | ||
| 1093 | buffers->rb_recv_count++; | ||
| 1094 | return rpcrdma_buffer_get_rep_locked(buffers); | ||
| 1095 | } | ||
| 1096 | |||
| 1077 | /* | 1097 | /* |
| 1078 | * Get a set of request/reply buffers. | 1098 | * Get a set of request/reply buffers. |
| 1099 | * | ||
| 1100 | * Reply buffer (if available) is attached to send buffer upon return. | ||
| 1079 | */ | 1101 | */ |
| 1080 | struct rpcrdma_req * | 1102 | struct rpcrdma_req * |
| 1081 | rpcrdma_buffer_get(struct rpcrdma_buffer *buffers) | 1103 | rpcrdma_buffer_get(struct rpcrdma_buffer *buffers) |
| @@ -1085,21 +1107,15 @@ rpcrdma_buffer_get(struct rpcrdma_buffer *buffers) | |||
| 1085 | spin_lock(&buffers->rb_lock); | 1107 | spin_lock(&buffers->rb_lock); |
| 1086 | if (list_empty(&buffers->rb_send_bufs)) | 1108 | if (list_empty(&buffers->rb_send_bufs)) |
| 1087 | goto out_reqbuf; | 1109 | goto out_reqbuf; |
| 1110 | buffers->rb_send_count++; | ||
| 1088 | req = rpcrdma_buffer_get_req_locked(buffers); | 1111 | req = rpcrdma_buffer_get_req_locked(buffers); |
| 1089 | if (list_empty(&buffers->rb_recv_bufs)) | 1112 | req->rl_reply = rpcrdma_buffer_get_rep(buffers); |
| 1090 | goto out_repbuf; | ||
| 1091 | req->rl_reply = rpcrdma_buffer_get_rep_locked(buffers); | ||
| 1092 | spin_unlock(&buffers->rb_lock); | 1113 | spin_unlock(&buffers->rb_lock); |
| 1093 | return req; | 1114 | return req; |
| 1094 | 1115 | ||
| 1095 | out_reqbuf: | 1116 | out_reqbuf: |
| 1096 | spin_unlock(&buffers->rb_lock); | 1117 | spin_unlock(&buffers->rb_lock); |
| 1097 | pr_warn("rpcrdma: out of request buffers (%p)\n", buffers); | 1118 | pr_warn("RPC: %s: out of request buffers\n", __func__); |
| 1098 | return NULL; | ||
| 1099 | out_repbuf: | ||
| 1100 | list_add(&req->rl_free, &buffers->rb_send_bufs); | ||
| 1101 | spin_unlock(&buffers->rb_lock); | ||
| 1102 | pr_warn("rpcrdma: out of reply buffers (%p)\n", buffers); | ||
| 1103 | return NULL; | 1119 | return NULL; |
| 1104 | } | 1120 | } |
| 1105 | 1121 | ||
| @@ -1117,9 +1133,12 @@ rpcrdma_buffer_put(struct rpcrdma_req *req) | |||
| 1117 | req->rl_reply = NULL; | 1133 | req->rl_reply = NULL; |
| 1118 | 1134 | ||
| 1119 | spin_lock(&buffers->rb_lock); | 1135 | spin_lock(&buffers->rb_lock); |
| 1136 | buffers->rb_send_count--; | ||
| 1120 | list_add_tail(&req->rl_free, &buffers->rb_send_bufs); | 1137 | list_add_tail(&req->rl_free, &buffers->rb_send_bufs); |
| 1121 | if (rep) | 1138 | if (rep) { |
| 1139 | buffers->rb_recv_count--; | ||
| 1122 | list_add_tail(&rep->rr_list, &buffers->rb_recv_bufs); | 1140 | list_add_tail(&rep->rr_list, &buffers->rb_recv_bufs); |
| 1141 | } | ||
| 1123 | spin_unlock(&buffers->rb_lock); | 1142 | spin_unlock(&buffers->rb_lock); |
| 1124 | } | 1143 | } |
| 1125 | 1144 | ||
| @@ -1133,8 +1152,7 @@ rpcrdma_recv_buffer_get(struct rpcrdma_req *req) | |||
| 1133 | struct rpcrdma_buffer *buffers = req->rl_buffer; | 1152 | struct rpcrdma_buffer *buffers = req->rl_buffer; |
| 1134 | 1153 | ||
| 1135 | spin_lock(&buffers->rb_lock); | 1154 | spin_lock(&buffers->rb_lock); |
| 1136 | if (!list_empty(&buffers->rb_recv_bufs)) | 1155 | req->rl_reply = rpcrdma_buffer_get_rep(buffers); |
| 1137 | req->rl_reply = rpcrdma_buffer_get_rep_locked(buffers); | ||
| 1138 | spin_unlock(&buffers->rb_lock); | 1156 | spin_unlock(&buffers->rb_lock); |
| 1139 | } | 1157 | } |
| 1140 | 1158 | ||
| @@ -1148,6 +1166,7 @@ rpcrdma_recv_buffer_put(struct rpcrdma_rep *rep) | |||
| 1148 | struct rpcrdma_buffer *buffers = &rep->rr_rxprt->rx_buf; | 1166 | struct rpcrdma_buffer *buffers = &rep->rr_rxprt->rx_buf; |
| 1149 | 1167 | ||
| 1150 | spin_lock(&buffers->rb_lock); | 1168 | spin_lock(&buffers->rb_lock); |
| 1169 | buffers->rb_recv_count--; | ||
| 1151 | list_add_tail(&rep->rr_list, &buffers->rb_recv_bufs); | 1170 | list_add_tail(&rep->rr_list, &buffers->rb_recv_bufs); |
| 1152 | spin_unlock(&buffers->rb_lock); | 1171 | spin_unlock(&buffers->rb_lock); |
| 1153 | } | 1172 | } |
diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h index 670fad57153a..a71b0f5897d8 100644 --- a/net/sunrpc/xprtrdma/xprt_rdma.h +++ b/net/sunrpc/xprtrdma/xprt_rdma.h | |||
| @@ -321,6 +321,7 @@ struct rpcrdma_buffer { | |||
| 321 | char *rb_pool; | 321 | char *rb_pool; |
| 322 | 322 | ||
| 323 | spinlock_t rb_lock; /* protect buf lists */ | 323 | spinlock_t rb_lock; /* protect buf lists */ |
| 324 | int rb_send_count, rb_recv_count; | ||
| 324 | struct list_head rb_send_bufs; | 325 | struct list_head rb_send_bufs; |
| 325 | struct list_head rb_recv_bufs; | 326 | struct list_head rb_recv_bufs; |
| 326 | u32 rb_max_requests; | 327 | u32 rb_max_requests; |
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 8ede3bc52481..bf168838a029 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
| @@ -1074,7 +1074,7 @@ static void xs_udp_data_receive(struct sock_xprt *transport) | |||
| 1074 | skb = skb_recv_datagram(sk, 0, 1, &err); | 1074 | skb = skb_recv_datagram(sk, 0, 1, &err); |
| 1075 | if (skb != NULL) { | 1075 | if (skb != NULL) { |
| 1076 | xs_udp_data_read_skb(&transport->xprt, sk, skb); | 1076 | xs_udp_data_read_skb(&transport->xprt, sk, skb); |
| 1077 | skb_free_datagram(sk, skb); | 1077 | skb_free_datagram_locked(sk, skb); |
| 1078 | continue; | 1078 | continue; |
| 1079 | } | 1079 | } |
| 1080 | if (!test_and_clear_bit(XPRT_SOCK_DATA_READY, &transport->sock_state)) | 1080 | if (!test_and_clear_bit(XPRT_SOCK_DATA_READY, &transport->sock_state)) |
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index 6b626a64b517..a04fe9be1c60 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c | |||
| @@ -62,6 +62,8 @@ static void publ_to_item(struct distr_item *i, struct publication *p) | |||
| 62 | 62 | ||
| 63 | /** | 63 | /** |
| 64 | * named_prepare_buf - allocate & initialize a publication message | 64 | * named_prepare_buf - allocate & initialize a publication message |
| 65 | * | ||
| 66 | * The buffer returned is of size INT_H_SIZE + payload size | ||
| 65 | */ | 67 | */ |
| 66 | static struct sk_buff *named_prepare_buf(struct net *net, u32 type, u32 size, | 68 | static struct sk_buff *named_prepare_buf(struct net *net, u32 type, u32 size, |
| 67 | u32 dest) | 69 | u32 dest) |
| @@ -141,9 +143,9 @@ static void named_distribute(struct net *net, struct sk_buff_head *list, | |||
| 141 | struct publication *publ; | 143 | struct publication *publ; |
| 142 | struct sk_buff *skb = NULL; | 144 | struct sk_buff *skb = NULL; |
| 143 | struct distr_item *item = NULL; | 145 | struct distr_item *item = NULL; |
| 144 | uint msg_dsz = (tipc_node_get_mtu(net, dnode, 0) / ITEM_SIZE) * | 146 | u32 msg_dsz = ((tipc_node_get_mtu(net, dnode, 0) - INT_H_SIZE) / |
| 145 | ITEM_SIZE; | 147 | ITEM_SIZE) * ITEM_SIZE; |
| 146 | uint msg_rem = msg_dsz; | 148 | u32 msg_rem = msg_dsz; |
| 147 | 149 | ||
| 148 | list_for_each_entry(publ, pls, local_list) { | 150 | list_for_each_entry(publ, pls, local_list) { |
| 149 | /* Prepare next buffer: */ | 151 | /* Prepare next buffer: */ |
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index b016c011970b..ae7e14cae085 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c | |||
| @@ -396,10 +396,13 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, | |||
| 396 | tuncfg.encap_destroy = NULL; | 396 | tuncfg.encap_destroy = NULL; |
| 397 | setup_udp_tunnel_sock(net, ub->ubsock, &tuncfg); | 397 | setup_udp_tunnel_sock(net, ub->ubsock, &tuncfg); |
| 398 | 398 | ||
| 399 | if (enable_mcast(ub, remote)) | 399 | err = enable_mcast(ub, remote); |
| 400 | if (err) | ||
| 400 | goto err; | 401 | goto err; |
| 401 | return 0; | 402 | return 0; |
| 402 | err: | 403 | err: |
| 404 | if (ub->ubsock) | ||
| 405 | udp_tunnel_sock_release(ub->ubsock); | ||
| 403 | kfree(ub); | 406 | kfree(ub); |
| 404 | return err; | 407 | return err; |
| 405 | } | 408 | } |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index f1dffe84f0d5..8309687a56b0 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
| @@ -661,11 +661,11 @@ static int unix_set_peek_off(struct sock *sk, int val) | |||
| 661 | { | 661 | { |
| 662 | struct unix_sock *u = unix_sk(sk); | 662 | struct unix_sock *u = unix_sk(sk); |
| 663 | 663 | ||
| 664 | if (mutex_lock_interruptible(&u->readlock)) | 664 | if (mutex_lock_interruptible(&u->iolock)) |
| 665 | return -EINTR; | 665 | return -EINTR; |
| 666 | 666 | ||
| 667 | sk->sk_peek_off = val; | 667 | sk->sk_peek_off = val; |
| 668 | mutex_unlock(&u->readlock); | 668 | mutex_unlock(&u->iolock); |
| 669 | 669 | ||
| 670 | return 0; | 670 | return 0; |
| 671 | } | 671 | } |
| @@ -779,7 +779,8 @@ static struct sock *unix_create1(struct net *net, struct socket *sock, int kern) | |||
| 779 | spin_lock_init(&u->lock); | 779 | spin_lock_init(&u->lock); |
| 780 | atomic_long_set(&u->inflight, 0); | 780 | atomic_long_set(&u->inflight, 0); |
| 781 | INIT_LIST_HEAD(&u->link); | 781 | INIT_LIST_HEAD(&u->link); |
| 782 | mutex_init(&u->readlock); /* single task reading lock */ | 782 | mutex_init(&u->iolock); /* single task reading lock */ |
| 783 | mutex_init(&u->bindlock); /* single task binding lock */ | ||
| 783 | init_waitqueue_head(&u->peer_wait); | 784 | init_waitqueue_head(&u->peer_wait); |
| 784 | init_waitqueue_func_entry(&u->peer_wake, unix_dgram_peer_wake_relay); | 785 | init_waitqueue_func_entry(&u->peer_wake, unix_dgram_peer_wake_relay); |
| 785 | unix_insert_socket(unix_sockets_unbound(sk), sk); | 786 | unix_insert_socket(unix_sockets_unbound(sk), sk); |
| @@ -848,7 +849,7 @@ static int unix_autobind(struct socket *sock) | |||
| 848 | int err; | 849 | int err; |
| 849 | unsigned int retries = 0; | 850 | unsigned int retries = 0; |
| 850 | 851 | ||
| 851 | err = mutex_lock_interruptible(&u->readlock); | 852 | err = mutex_lock_interruptible(&u->bindlock); |
| 852 | if (err) | 853 | if (err) |
| 853 | return err; | 854 | return err; |
| 854 | 855 | ||
| @@ -895,7 +896,7 @@ retry: | |||
| 895 | spin_unlock(&unix_table_lock); | 896 | spin_unlock(&unix_table_lock); |
| 896 | err = 0; | 897 | err = 0; |
| 897 | 898 | ||
| 898 | out: mutex_unlock(&u->readlock); | 899 | out: mutex_unlock(&u->bindlock); |
| 899 | return err; | 900 | return err; |
| 900 | } | 901 | } |
| 901 | 902 | ||
| @@ -954,20 +955,32 @@ fail: | |||
| 954 | return NULL; | 955 | return NULL; |
| 955 | } | 956 | } |
| 956 | 957 | ||
| 957 | static int unix_mknod(struct dentry *dentry, const struct path *path, umode_t mode, | 958 | static int unix_mknod(const char *sun_path, umode_t mode, struct path *res) |
| 958 | struct path *res) | ||
| 959 | { | 959 | { |
| 960 | int err; | 960 | struct dentry *dentry; |
| 961 | struct path path; | ||
| 962 | int err = 0; | ||
| 963 | /* | ||
| 964 | * Get the parent directory, calculate the hash for last | ||
| 965 | * component. | ||
| 966 | */ | ||
| 967 | dentry = kern_path_create(AT_FDCWD, sun_path, &path, 0); | ||
| 968 | err = PTR_ERR(dentry); | ||
| 969 | if (IS_ERR(dentry)) | ||
| 970 | return err; | ||
| 961 | 971 | ||
| 962 | err = security_path_mknod(path, dentry, mode, 0); | 972 | /* |
| 973 | * All right, let's create it. | ||
| 974 | */ | ||
| 975 | err = security_path_mknod(&path, dentry, mode, 0); | ||
| 963 | if (!err) { | 976 | if (!err) { |
| 964 | err = vfs_mknod(d_inode(path->dentry), dentry, mode, 0); | 977 | err = vfs_mknod(d_inode(path.dentry), dentry, mode, 0); |
| 965 | if (!err) { | 978 | if (!err) { |
| 966 | res->mnt = mntget(path->mnt); | 979 | res->mnt = mntget(path.mnt); |
| 967 | res->dentry = dget(dentry); | 980 | res->dentry = dget(dentry); |
| 968 | } | 981 | } |
| 969 | } | 982 | } |
| 970 | 983 | done_path_create(&path, dentry); | |
| 971 | return err; | 984 | return err; |
| 972 | } | 985 | } |
| 973 | 986 | ||
| @@ -978,12 +991,10 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
| 978 | struct unix_sock *u = unix_sk(sk); | 991 | struct unix_sock *u = unix_sk(sk); |
| 979 | struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr; | 992 | struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr; |
| 980 | char *sun_path = sunaddr->sun_path; | 993 | char *sun_path = sunaddr->sun_path; |
| 981 | int err, name_err; | 994 | int err; |
| 982 | unsigned int hash; | 995 | unsigned int hash; |
| 983 | struct unix_address *addr; | 996 | struct unix_address *addr; |
| 984 | struct hlist_head *list; | 997 | struct hlist_head *list; |
| 985 | struct path path; | ||
| 986 | struct dentry *dentry; | ||
| 987 | 998 | ||
| 988 | err = -EINVAL; | 999 | err = -EINVAL; |
| 989 | if (sunaddr->sun_family != AF_UNIX) | 1000 | if (sunaddr->sun_family != AF_UNIX) |
| @@ -999,34 +1010,14 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
| 999 | goto out; | 1010 | goto out; |
| 1000 | addr_len = err; | 1011 | addr_len = err; |
| 1001 | 1012 | ||
| 1002 | name_err = 0; | 1013 | err = mutex_lock_interruptible(&u->bindlock); |
| 1003 | dentry = NULL; | ||
| 1004 | if (sun_path[0]) { | ||
| 1005 | /* Get the parent directory, calculate the hash for last | ||
| 1006 | * component. | ||
| 1007 | */ | ||
| 1008 | dentry = kern_path_create(AT_FDCWD, sun_path, &path, 0); | ||
| 1009 | |||
| 1010 | if (IS_ERR(dentry)) { | ||
| 1011 | /* delay report until after 'already bound' check */ | ||
| 1012 | name_err = PTR_ERR(dentry); | ||
| 1013 | dentry = NULL; | ||
| 1014 | } | ||
| 1015 | } | ||
| 1016 | |||
| 1017 | err = mutex_lock_interruptible(&u->readlock); | ||
| 1018 | if (err) | 1014 | if (err) |
| 1019 | goto out_path; | 1015 | goto out; |
| 1020 | 1016 | ||
| 1021 | err = -EINVAL; | 1017 | err = -EINVAL; |
| 1022 | if (u->addr) | 1018 | if (u->addr) |
| 1023 | goto out_up; | 1019 | goto out_up; |
| 1024 | 1020 | ||
| 1025 | if (name_err) { | ||
| 1026 | err = name_err == -EEXIST ? -EADDRINUSE : name_err; | ||
| 1027 | goto out_up; | ||
| 1028 | } | ||
| 1029 | |||
| 1030 | err = -ENOMEM; | 1021 | err = -ENOMEM; |
| 1031 | addr = kmalloc(sizeof(*addr)+addr_len, GFP_KERNEL); | 1022 | addr = kmalloc(sizeof(*addr)+addr_len, GFP_KERNEL); |
| 1032 | if (!addr) | 1023 | if (!addr) |
| @@ -1037,11 +1028,11 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
| 1037 | addr->hash = hash ^ sk->sk_type; | 1028 | addr->hash = hash ^ sk->sk_type; |
| 1038 | atomic_set(&addr->refcnt, 1); | 1029 | atomic_set(&addr->refcnt, 1); |
| 1039 | 1030 | ||
| 1040 | if (dentry) { | 1031 | if (sun_path[0]) { |
| 1041 | struct path u_path; | 1032 | struct path path; |
| 1042 | umode_t mode = S_IFSOCK | | 1033 | umode_t mode = S_IFSOCK | |
| 1043 | (SOCK_INODE(sock)->i_mode & ~current_umask()); | 1034 | (SOCK_INODE(sock)->i_mode & ~current_umask()); |
| 1044 | err = unix_mknod(dentry, &path, mode, &u_path); | 1035 | err = unix_mknod(sun_path, mode, &path); |
| 1045 | if (err) { | 1036 | if (err) { |
| 1046 | if (err == -EEXIST) | 1037 | if (err == -EEXIST) |
| 1047 | err = -EADDRINUSE; | 1038 | err = -EADDRINUSE; |
| @@ -1049,9 +1040,9 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
| 1049 | goto out_up; | 1040 | goto out_up; |
| 1050 | } | 1041 | } |
| 1051 | addr->hash = UNIX_HASH_SIZE; | 1042 | addr->hash = UNIX_HASH_SIZE; |
| 1052 | hash = d_real_inode(dentry)->i_ino & (UNIX_HASH_SIZE - 1); | 1043 | hash = d_real_inode(path.dentry)->i_ino & (UNIX_HASH_SIZE - 1); |
| 1053 | spin_lock(&unix_table_lock); | 1044 | spin_lock(&unix_table_lock); |
| 1054 | u->path = u_path; | 1045 | u->path = path; |
| 1055 | list = &unix_socket_table[hash]; | 1046 | list = &unix_socket_table[hash]; |
| 1056 | } else { | 1047 | } else { |
| 1057 | spin_lock(&unix_table_lock); | 1048 | spin_lock(&unix_table_lock); |
| @@ -1073,11 +1064,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
| 1073 | out_unlock: | 1064 | out_unlock: |
| 1074 | spin_unlock(&unix_table_lock); | 1065 | spin_unlock(&unix_table_lock); |
| 1075 | out_up: | 1066 | out_up: |
| 1076 | mutex_unlock(&u->readlock); | 1067 | mutex_unlock(&u->bindlock); |
| 1077 | out_path: | ||
| 1078 | if (dentry) | ||
| 1079 | done_path_create(&path, dentry); | ||
| 1080 | |||
| 1081 | out: | 1068 | out: |
| 1082 | return err; | 1069 | return err; |
| 1083 | } | 1070 | } |
| @@ -1969,17 +1956,17 @@ static ssize_t unix_stream_sendpage(struct socket *socket, struct page *page, | |||
| 1969 | if (false) { | 1956 | if (false) { |
| 1970 | alloc_skb: | 1957 | alloc_skb: |
| 1971 | unix_state_unlock(other); | 1958 | unix_state_unlock(other); |
| 1972 | mutex_unlock(&unix_sk(other)->readlock); | 1959 | mutex_unlock(&unix_sk(other)->iolock); |
| 1973 | newskb = sock_alloc_send_pskb(sk, 0, 0, flags & MSG_DONTWAIT, | 1960 | newskb = sock_alloc_send_pskb(sk, 0, 0, flags & MSG_DONTWAIT, |
| 1974 | &err, 0); | 1961 | &err, 0); |
| 1975 | if (!newskb) | 1962 | if (!newskb) |
| 1976 | goto err; | 1963 | goto err; |
| 1977 | } | 1964 | } |
| 1978 | 1965 | ||
| 1979 | /* we must acquire readlock as we modify already present | 1966 | /* we must acquire iolock as we modify already present |
| 1980 | * skbs in the sk_receive_queue and mess with skb->len | 1967 | * skbs in the sk_receive_queue and mess with skb->len |
| 1981 | */ | 1968 | */ |
| 1982 | err = mutex_lock_interruptible(&unix_sk(other)->readlock); | 1969 | err = mutex_lock_interruptible(&unix_sk(other)->iolock); |
| 1983 | if (err) { | 1970 | if (err) { |
| 1984 | err = flags & MSG_DONTWAIT ? -EAGAIN : -ERESTARTSYS; | 1971 | err = flags & MSG_DONTWAIT ? -EAGAIN : -ERESTARTSYS; |
| 1985 | goto err; | 1972 | goto err; |
| @@ -2046,7 +2033,7 @@ alloc_skb: | |||
| 2046 | } | 2033 | } |
| 2047 | 2034 | ||
| 2048 | unix_state_unlock(other); | 2035 | unix_state_unlock(other); |
| 2049 | mutex_unlock(&unix_sk(other)->readlock); | 2036 | mutex_unlock(&unix_sk(other)->iolock); |
| 2050 | 2037 | ||
| 2051 | other->sk_data_ready(other); | 2038 | other->sk_data_ready(other); |
| 2052 | scm_destroy(&scm); | 2039 | scm_destroy(&scm); |
| @@ -2055,7 +2042,7 @@ alloc_skb: | |||
| 2055 | err_state_unlock: | 2042 | err_state_unlock: |
| 2056 | unix_state_unlock(other); | 2043 | unix_state_unlock(other); |
| 2057 | err_unlock: | 2044 | err_unlock: |
| 2058 | mutex_unlock(&unix_sk(other)->readlock); | 2045 | mutex_unlock(&unix_sk(other)->iolock); |
| 2059 | err: | 2046 | err: |
| 2060 | kfree_skb(newskb); | 2047 | kfree_skb(newskb); |
| 2061 | if (send_sigpipe && !(flags & MSG_NOSIGNAL)) | 2048 | if (send_sigpipe && !(flags & MSG_NOSIGNAL)) |
| @@ -2123,7 +2110,7 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, | |||
| 2123 | timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); | 2110 | timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); |
| 2124 | 2111 | ||
| 2125 | do { | 2112 | do { |
| 2126 | mutex_lock(&u->readlock); | 2113 | mutex_lock(&u->iolock); |
| 2127 | 2114 | ||
| 2128 | skip = sk_peek_offset(sk, flags); | 2115 | skip = sk_peek_offset(sk, flags); |
| 2129 | skb = __skb_try_recv_datagram(sk, flags, &peeked, &skip, &err, | 2116 | skb = __skb_try_recv_datagram(sk, flags, &peeked, &skip, &err, |
| @@ -2131,14 +2118,14 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, | |||
| 2131 | if (skb) | 2118 | if (skb) |
| 2132 | break; | 2119 | break; |
| 2133 | 2120 | ||
| 2134 | mutex_unlock(&u->readlock); | 2121 | mutex_unlock(&u->iolock); |
| 2135 | 2122 | ||
| 2136 | if (err != -EAGAIN) | 2123 | if (err != -EAGAIN) |
| 2137 | break; | 2124 | break; |
| 2138 | } while (timeo && | 2125 | } while (timeo && |
| 2139 | !__skb_wait_for_more_packets(sk, &err, &timeo, last)); | 2126 | !__skb_wait_for_more_packets(sk, &err, &timeo, last)); |
| 2140 | 2127 | ||
| 2141 | if (!skb) { /* implies readlock unlocked */ | 2128 | if (!skb) { /* implies iolock unlocked */ |
| 2142 | unix_state_lock(sk); | 2129 | unix_state_lock(sk); |
| 2143 | /* Signal EOF on disconnected non-blocking SEQPACKET socket. */ | 2130 | /* Signal EOF on disconnected non-blocking SEQPACKET socket. */ |
| 2144 | if (sk->sk_type == SOCK_SEQPACKET && err == -EAGAIN && | 2131 | if (sk->sk_type == SOCK_SEQPACKET && err == -EAGAIN && |
| @@ -2203,7 +2190,7 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, | |||
| 2203 | 2190 | ||
| 2204 | out_free: | 2191 | out_free: |
| 2205 | skb_free_datagram(sk, skb); | 2192 | skb_free_datagram(sk, skb); |
| 2206 | mutex_unlock(&u->readlock); | 2193 | mutex_unlock(&u->iolock); |
| 2207 | out: | 2194 | out: |
| 2208 | return err; | 2195 | return err; |
| 2209 | } | 2196 | } |
| @@ -2298,7 +2285,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state) | |||
| 2298 | /* Lock the socket to prevent queue disordering | 2285 | /* Lock the socket to prevent queue disordering |
| 2299 | * while sleeps in memcpy_tomsg | 2286 | * while sleeps in memcpy_tomsg |
| 2300 | */ | 2287 | */ |
| 2301 | mutex_lock(&u->readlock); | 2288 | mutex_lock(&u->iolock); |
| 2302 | 2289 | ||
| 2303 | if (flags & MSG_PEEK) | 2290 | if (flags & MSG_PEEK) |
| 2304 | skip = sk_peek_offset(sk, flags); | 2291 | skip = sk_peek_offset(sk, flags); |
| @@ -2340,7 +2327,7 @@ again: | |||
| 2340 | break; | 2327 | break; |
| 2341 | } | 2328 | } |
| 2342 | 2329 | ||
| 2343 | mutex_unlock(&u->readlock); | 2330 | mutex_unlock(&u->iolock); |
| 2344 | 2331 | ||
| 2345 | timeo = unix_stream_data_wait(sk, timeo, last, | 2332 | timeo = unix_stream_data_wait(sk, timeo, last, |
| 2346 | last_len); | 2333 | last_len); |
| @@ -2351,7 +2338,7 @@ again: | |||
| 2351 | goto out; | 2338 | goto out; |
| 2352 | } | 2339 | } |
| 2353 | 2340 | ||
| 2354 | mutex_lock(&u->readlock); | 2341 | mutex_lock(&u->iolock); |
| 2355 | goto redo; | 2342 | goto redo; |
| 2356 | unlock: | 2343 | unlock: |
| 2357 | unix_state_unlock(sk); | 2344 | unix_state_unlock(sk); |
| @@ -2454,7 +2441,7 @@ unlock: | |||
| 2454 | } | 2441 | } |
| 2455 | } while (size); | 2442 | } while (size); |
| 2456 | 2443 | ||
| 2457 | mutex_unlock(&u->readlock); | 2444 | mutex_unlock(&u->iolock); |
| 2458 | if (state->msg) | 2445 | if (state->msg) |
| 2459 | scm_recv(sock, state->msg, &scm, flags); | 2446 | scm_recv(sock, state->msg, &scm, flags); |
| 2460 | else | 2447 | else |
| @@ -2495,9 +2482,9 @@ static ssize_t skb_unix_socket_splice(struct sock *sk, | |||
| 2495 | int ret; | 2482 | int ret; |
| 2496 | struct unix_sock *u = unix_sk(sk); | 2483 | struct unix_sock *u = unix_sk(sk); |
| 2497 | 2484 | ||
| 2498 | mutex_unlock(&u->readlock); | 2485 | mutex_unlock(&u->iolock); |
| 2499 | ret = splice_to_pipe(pipe, spd); | 2486 | ret = splice_to_pipe(pipe, spd); |
| 2500 | mutex_lock(&u->readlock); | 2487 | mutex_lock(&u->iolock); |
| 2501 | 2488 | ||
| 2502 | return ret; | 2489 | return ret; |
| 2503 | } | 2490 | } |
diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c index dbb2738e356a..6250b1cfcde5 100644 --- a/net/wireless/wext-core.c +++ b/net/wireless/wext-core.c | |||
| @@ -958,29 +958,8 @@ static int wireless_process_ioctl(struct net *net, struct ifreq *ifr, | |||
| 958 | return private(dev, iwr, cmd, info, handler); | 958 | return private(dev, iwr, cmd, info, handler); |
| 959 | } | 959 | } |
| 960 | /* Old driver API : call driver ioctl handler */ | 960 | /* Old driver API : call driver ioctl handler */ |
| 961 | if (dev->netdev_ops->ndo_do_ioctl) { | 961 | if (dev->netdev_ops->ndo_do_ioctl) |
| 962 | #ifdef CONFIG_COMPAT | 962 | return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd); |
| 963 | if (info->flags & IW_REQUEST_FLAG_COMPAT) { | ||
| 964 | int ret = 0; | ||
| 965 | struct iwreq iwr_lcl; | ||
| 966 | struct compat_iw_point *iwp_compat = (void *) &iwr->u.data; | ||
| 967 | |||
| 968 | memcpy(&iwr_lcl, iwr, sizeof(struct iwreq)); | ||
| 969 | iwr_lcl.u.data.pointer = compat_ptr(iwp_compat->pointer); | ||
| 970 | iwr_lcl.u.data.length = iwp_compat->length; | ||
| 971 | iwr_lcl.u.data.flags = iwp_compat->flags; | ||
| 972 | |||
| 973 | ret = dev->netdev_ops->ndo_do_ioctl(dev, (void *) &iwr_lcl, cmd); | ||
| 974 | |||
| 975 | iwp_compat->pointer = ptr_to_compat(iwr_lcl.u.data.pointer); | ||
| 976 | iwp_compat->length = iwr_lcl.u.data.length; | ||
| 977 | iwp_compat->flags = iwr_lcl.u.data.flags; | ||
| 978 | |||
| 979 | return ret; | ||
| 980 | } else | ||
| 981 | #endif | ||
| 982 | return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd); | ||
| 983 | } | ||
| 984 | return -EOPNOTSUPP; | 963 | return -EOPNOTSUPP; |
| 985 | } | 964 | } |
| 986 | 965 | ||
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c index 1c4ad477ce93..6e3f0254d8a1 100644 --- a/net/xfrm/xfrm_input.c +++ b/net/xfrm/xfrm_input.c | |||
| @@ -207,15 +207,15 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) | |||
| 207 | family = XFRM_SPI_SKB_CB(skb)->family; | 207 | family = XFRM_SPI_SKB_CB(skb)->family; |
| 208 | 208 | ||
| 209 | /* if tunnel is present override skb->mark value with tunnel i_key */ | 209 | /* if tunnel is present override skb->mark value with tunnel i_key */ |
| 210 | if (XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4) { | 210 | switch (family) { |
| 211 | switch (family) { | 211 | case AF_INET: |
| 212 | case AF_INET: | 212 | if (XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4) |
| 213 | mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4->parms.i_key); | 213 | mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4->parms.i_key); |
| 214 | break; | 214 | break; |
| 215 | case AF_INET6: | 215 | case AF_INET6: |
| 216 | if (XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6) | ||
| 216 | mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6->parms.i_key); | 217 | mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6->parms.i_key); |
| 217 | break; | 218 | break; |
| 218 | } | ||
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | /* Allocate new secpath or COW existing one. */ | 221 | /* Allocate new secpath or COW existing one. */ |
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index b5e665b3cfb0..45f9cf97ea25 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
| @@ -626,6 +626,10 @@ static void xfrm_hash_rebuild(struct work_struct *work) | |||
| 626 | 626 | ||
| 627 | /* re-insert all policies by order of creation */ | 627 | /* re-insert all policies by order of creation */ |
| 628 | list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) { | 628 | list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) { |
| 629 | if (xfrm_policy_id2dir(policy->index) >= XFRM_POLICY_MAX) { | ||
| 630 | /* skip socket policies */ | ||
| 631 | continue; | ||
| 632 | } | ||
| 629 | newpos = NULL; | 633 | newpos = NULL; |
| 630 | chain = policy_hash_bysel(net, &policy->selector, | 634 | chain = policy_hash_bysel(net, &policy->selector, |
| 631 | policy->family, | 635 | policy->family, |
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index d516845e16e3..cb65d916a345 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
| @@ -896,7 +896,8 @@ static int xfrm_dump_sa_done(struct netlink_callback *cb) | |||
| 896 | struct sock *sk = cb->skb->sk; | 896 | struct sock *sk = cb->skb->sk; |
| 897 | struct net *net = sock_net(sk); | 897 | struct net *net = sock_net(sk); |
| 898 | 898 | ||
| 899 | xfrm_state_walk_done(walk, net); | 899 | if (cb->args[0]) |
| 900 | xfrm_state_walk_done(walk, net); | ||
| 900 | return 0; | 901 | return 0; |
| 901 | } | 902 | } |
| 902 | 903 | ||
| @@ -921,8 +922,6 @@ static int xfrm_dump_sa(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 921 | u8 proto = 0; | 922 | u8 proto = 0; |
| 922 | int err; | 923 | int err; |
| 923 | 924 | ||
| 924 | cb->args[0] = 1; | ||
| 925 | |||
| 926 | err = nlmsg_parse(cb->nlh, 0, attrs, XFRMA_MAX, | 925 | err = nlmsg_parse(cb->nlh, 0, attrs, XFRMA_MAX, |
| 927 | xfrma_policy); | 926 | xfrma_policy); |
| 928 | if (err < 0) | 927 | if (err < 0) |
| @@ -939,6 +938,7 @@ static int xfrm_dump_sa(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 939 | proto = nla_get_u8(attrs[XFRMA_PROTO]); | 938 | proto = nla_get_u8(attrs[XFRMA_PROTO]); |
| 940 | 939 | ||
| 941 | xfrm_state_walk_init(walk, proto, filter); | 940 | xfrm_state_walk_init(walk, proto, filter); |
| 941 | cb->args[0] = 1; | ||
| 942 | } | 942 | } |
| 943 | 943 | ||
| 944 | (void) xfrm_state_walk(net, walk, dump_one_state, &info); | 944 | (void) xfrm_state_walk(net, walk, dump_one_state, &info); |
| @@ -2051,9 +2051,6 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
| 2051 | if (up->hard) { | 2051 | if (up->hard) { |
| 2052 | xfrm_policy_delete(xp, p->dir); | 2052 | xfrm_policy_delete(xp, p->dir); |
| 2053 | xfrm_audit_policy_delete(xp, 1, true); | 2053 | xfrm_audit_policy_delete(xp, 1, true); |
| 2054 | } else { | ||
| 2055 | // reset the timers here? | ||
| 2056 | WARN(1, "Don't know what to do with soft policy expire\n"); | ||
| 2057 | } | 2054 | } |
| 2058 | km_policy_expired(xp, p->dir, up->hard, nlh->nlmsg_pid); | 2055 | km_policy_expired(xp, p->dir, up->hard, nlh->nlmsg_pid); |
| 2059 | 2056 | ||
| @@ -2117,7 +2114,7 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
| 2117 | 2114 | ||
| 2118 | err = verify_newpolicy_info(&ua->policy); | 2115 | err = verify_newpolicy_info(&ua->policy); |
| 2119 | if (err) | 2116 | if (err) |
| 2120 | goto bad_policy; | 2117 | goto free_state; |
| 2121 | 2118 | ||
| 2122 | /* build an XP */ | 2119 | /* build an XP */ |
| 2123 | xp = xfrm_policy_construct(net, &ua->policy, attrs, &err); | 2120 | xp = xfrm_policy_construct(net, &ua->policy, attrs, &err); |
| @@ -2149,8 +2146,6 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
| 2149 | 2146 | ||
| 2150 | return 0; | 2147 | return 0; |
| 2151 | 2148 | ||
| 2152 | bad_policy: | ||
| 2153 | WARN(1, "BAD policy passed\n"); | ||
| 2154 | free_state: | 2149 | free_state: |
| 2155 | kfree(x); | 2150 | kfree(x); |
| 2156 | nomem: | 2151 | nomem: |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4de3cc42fc50..206a6b346a8d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -3570,15 +3570,6 @@ sub process { | |||
| 3570 | } | 3570 | } |
| 3571 | } | 3571 | } |
| 3572 | 3572 | ||
| 3573 | # check for uses of DEFINE_PCI_DEVICE_TABLE | ||
| 3574 | if ($line =~ /\bDEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=/) { | ||
| 3575 | if (WARN("DEFINE_PCI_DEVICE_TABLE", | ||
| 3576 | "Prefer struct pci_device_id over deprecated DEFINE_PCI_DEVICE_TABLE\n" . $herecurr) && | ||
| 3577 | $fix) { | ||
| 3578 | $fixed[$fixlinenr] =~ s/\b(?:static\s+|)DEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=\s*/static const struct pci_device_id $1\[\] = /; | ||
| 3579 | } | ||
| 3580 | } | ||
| 3581 | |||
| 3582 | # check for new typedefs, only function parameters and sparse annotations | 3573 | # check for new typedefs, only function parameters and sparse annotations |
| 3583 | # make sense. | 3574 | # make sense. |
| 3584 | if ($line =~ /\btypedef\s/ && | 3575 | if ($line =~ /\btypedef\s/ && |
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 49a00d54b835..aed4511f0304 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl | |||
| @@ -2136,9 +2136,11 @@ sub vcs_file_exists { | |||
| 2136 | 2136 | ||
| 2137 | my $cmd = $VCS_cmds{"file_exists_cmd"}; | 2137 | my $cmd = $VCS_cmds{"file_exists_cmd"}; |
| 2138 | $cmd =~ s/(\$\w+)/$1/eeg; # interpolate $cmd | 2138 | $cmd =~ s/(\$\w+)/$1/eeg; # interpolate $cmd |
| 2139 | 2139 | $cmd .= " 2>&1"; | |
| 2140 | $exists = &{$VCS_cmds{"execute_cmd"}}($cmd); | 2140 | $exists = &{$VCS_cmds{"execute_cmd"}}($cmd); |
| 2141 | 2141 | ||
| 2142 | return 0 if ($? != 0); | ||
| 2143 | |||
| 2142 | return $exists; | 2144 | return $exists; |
| 2143 | } | 2145 | } |
| 2144 | 2146 | ||
diff --git a/scripts/package/builddeb b/scripts/package/builddeb index e1c09e2f9be7..8ea9fd2b6573 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb | |||
| @@ -332,7 +332,9 @@ if grep -q '^CONFIG_STACK_VALIDATION=y' $KCONFIG_CONFIG ; then | |||
| 332 | (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" | 332 | (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" |
| 333 | fi | 333 | fi |
| 334 | (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" | 334 | (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" |
| 335 | (cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles" | 335 | if grep -q '^CONFIG_GCC_PLUGINS=y' $KCONFIG_CONFIG ; then |
| 336 | (cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles" | ||
| 337 | fi | ||
| 336 | destdir=$kernel_headers_dir/usr/src/linux-headers-$version | 338 | destdir=$kernel_headers_dir/usr/src/linux-headers-$version |
| 337 | mkdir -p "$destdir" | 339 | mkdir -p "$destdir" |
| 338 | (cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -) | 340 | (cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -) |
diff --git a/scripts/tags.sh b/scripts/tags.sh index ed7eef24ef89..b3775a9604ea 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh | |||
| @@ -206,7 +206,6 @@ regex_c=( | |||
| 206 | '/\<DEFINE_PER_CPU_SHARED_ALIGNED([^,]*, *\([[:alnum:]_]*\)/\1/v/' | 206 | '/\<DEFINE_PER_CPU_SHARED_ALIGNED([^,]*, *\([[:alnum:]_]*\)/\1/v/' |
| 207 | '/\<DECLARE_WAIT_QUEUE_HEAD(\([[:alnum:]_]*\)/\1/v/' | 207 | '/\<DECLARE_WAIT_QUEUE_HEAD(\([[:alnum:]_]*\)/\1/v/' |
| 208 | '/\<DECLARE_\(TASKLET\|WORK\|DELAYED_WORK\)(\([[:alnum:]_]*\)/\2/v/' | 208 | '/\<DECLARE_\(TASKLET\|WORK\|DELAYED_WORK\)(\([[:alnum:]_]*\)/\2/v/' |
| 209 | '/\<DEFINE_PCI_DEVICE_TABLE(\([[:alnum:]_]*\)/\1/v/' | ||
| 210 | '/\(^\s\)OFFSET(\([[:alnum:]_]*\)/\2/v/' | 209 | '/\(^\s\)OFFSET(\([[:alnum:]_]*\)/\2/v/' |
| 211 | '/\(^\s\)DEFINE(\([[:alnum:]_]*\)/\2/v/' | 210 | '/\(^\s\)DEFINE(\([[:alnum:]_]*\)/\2/v/' |
| 212 | '/\<DEFINE_HASHTABLE(\([[:alnum:]_]*\)/\1/v/' | 211 | '/\<DEFINE_HASHTABLE(\([[:alnum:]_]*\)/\1/v/' |
diff --git a/security/Kconfig b/security/Kconfig index da10d9b573a4..118f4549404e 100644 --- a/security/Kconfig +++ b/security/Kconfig | |||
| @@ -147,6 +147,17 @@ config HARDENED_USERCOPY | |||
| 147 | or are part of the kernel text. This kills entire classes | 147 | or are part of the kernel text. This kills entire classes |
| 148 | of heap overflow exploits and similar kernel memory exposures. | 148 | of heap overflow exploits and similar kernel memory exposures. |
| 149 | 149 | ||
| 150 | config HARDENED_USERCOPY_PAGESPAN | ||
| 151 | bool "Refuse to copy allocations that span multiple pages" | ||
| 152 | depends on HARDENED_USERCOPY | ||
| 153 | depends on EXPERT | ||
| 154 | help | ||
| 155 | When a multi-page allocation is done without __GFP_COMP, | ||
| 156 | hardened usercopy will reject attempts to copy it. There are, | ||
| 157 | however, several cases of this in the kernel that have not all | ||
| 158 | been removed. This config is intended to be used only while | ||
| 159 | trying to find such users. | ||
| 160 | |||
| 150 | source security/selinux/Kconfig | 161 | source security/selinux/Kconfig |
| 151 | source security/smack/Kconfig | 162 | source security/smack/Kconfig |
| 152 | source security/tomoyo/Kconfig | 163 | source security/tomoyo/Kconfig |
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 795437b10082..b450a27588c8 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c | |||
| @@ -1633,11 +1633,13 @@ static int snd_rawmidi_dev_register(struct snd_device *device) | |||
| 1633 | return -EBUSY; | 1633 | return -EBUSY; |
| 1634 | } | 1634 | } |
| 1635 | list_add_tail(&rmidi->list, &snd_rawmidi_devices); | 1635 | list_add_tail(&rmidi->list, &snd_rawmidi_devices); |
| 1636 | mutex_unlock(®ister_mutex); | ||
| 1636 | err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, | 1637 | err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, |
| 1637 | rmidi->card, rmidi->device, | 1638 | rmidi->card, rmidi->device, |
| 1638 | &snd_rawmidi_f_ops, rmidi, &rmidi->dev); | 1639 | &snd_rawmidi_f_ops, rmidi, &rmidi->dev); |
| 1639 | if (err < 0) { | 1640 | if (err < 0) { |
| 1640 | rmidi_err(rmidi, "unable to register\n"); | 1641 | rmidi_err(rmidi, "unable to register\n"); |
| 1642 | mutex_lock(®ister_mutex); | ||
| 1641 | list_del(&rmidi->list); | 1643 | list_del(&rmidi->list); |
| 1642 | mutex_unlock(®ister_mutex); | 1644 | mutex_unlock(®ister_mutex); |
| 1643 | return err; | 1645 | return err; |
| @@ -1645,6 +1647,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device) | |||
| 1645 | if (rmidi->ops && rmidi->ops->dev_register && | 1647 | if (rmidi->ops && rmidi->ops->dev_register && |
| 1646 | (err = rmidi->ops->dev_register(rmidi)) < 0) { | 1648 | (err = rmidi->ops->dev_register(rmidi)) < 0) { |
| 1647 | snd_unregister_device(&rmidi->dev); | 1649 | snd_unregister_device(&rmidi->dev); |
| 1650 | mutex_lock(®ister_mutex); | ||
| 1648 | list_del(&rmidi->list); | 1651 | list_del(&rmidi->list); |
| 1649 | mutex_unlock(®ister_mutex); | 1652 | mutex_unlock(®ister_mutex); |
| 1650 | return err; | 1653 | return err; |
| @@ -1677,7 +1680,6 @@ static int snd_rawmidi_dev_register(struct snd_device *device) | |||
| 1677 | } | 1680 | } |
| 1678 | } | 1681 | } |
| 1679 | #endif /* CONFIG_SND_OSSEMUL */ | 1682 | #endif /* CONFIG_SND_OSSEMUL */ |
| 1680 | mutex_unlock(®ister_mutex); | ||
| 1681 | sprintf(name, "midi%d", rmidi->device); | 1683 | sprintf(name, "midi%d", rmidi->device); |
| 1682 | entry = snd_info_create_card_entry(rmidi->card, name, rmidi->card->proc_root); | 1684 | entry = snd_info_create_card_entry(rmidi->card, name, rmidi->card->proc_root); |
| 1683 | if (entry) { | 1685 | if (entry) { |
diff --git a/sound/core/timer.c b/sound/core/timer.c index 9a6157ea6881..fc144f43faa6 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c | |||
| @@ -35,6 +35,9 @@ | |||
| 35 | #include <sound/initval.h> | 35 | #include <sound/initval.h> |
| 36 | #include <linux/kmod.h> | 36 | #include <linux/kmod.h> |
| 37 | 37 | ||
| 38 | /* internal flags */ | ||
| 39 | #define SNDRV_TIMER_IFLG_PAUSED 0x00010000 | ||
| 40 | |||
| 38 | #if IS_ENABLED(CONFIG_SND_HRTIMER) | 41 | #if IS_ENABLED(CONFIG_SND_HRTIMER) |
| 39 | #define DEFAULT_TIMER_LIMIT 4 | 42 | #define DEFAULT_TIMER_LIMIT 4 |
| 40 | #else | 43 | #else |
| @@ -294,8 +297,21 @@ int snd_timer_open(struct snd_timer_instance **ti, | |||
| 294 | get_device(&timer->card->card_dev); | 297 | get_device(&timer->card->card_dev); |
| 295 | timeri->slave_class = tid->dev_sclass; | 298 | timeri->slave_class = tid->dev_sclass; |
| 296 | timeri->slave_id = slave_id; | 299 | timeri->slave_id = slave_id; |
| 297 | if (list_empty(&timer->open_list_head) && timer->hw.open) | 300 | |
| 298 | timer->hw.open(timer); | 301 | if (list_empty(&timer->open_list_head) && timer->hw.open) { |
| 302 | int err = timer->hw.open(timer); | ||
| 303 | if (err) { | ||
| 304 | kfree(timeri->owner); | ||
| 305 | kfree(timeri); | ||
| 306 | |||
| 307 | if (timer->card) | ||
| 308 | put_device(&timer->card->card_dev); | ||
| 309 | module_put(timer->module); | ||
| 310 | mutex_unlock(®ister_mutex); | ||
| 311 | return err; | ||
| 312 | } | ||
| 313 | } | ||
| 314 | |||
| 299 | list_add_tail(&timeri->open_list, &timer->open_list_head); | 315 | list_add_tail(&timeri->open_list, &timer->open_list_head); |
| 300 | snd_timer_check_master(timeri); | 316 | snd_timer_check_master(timeri); |
| 301 | mutex_unlock(®ister_mutex); | 317 | mutex_unlock(®ister_mutex); |
| @@ -526,6 +542,10 @@ static int snd_timer_stop1(struct snd_timer_instance *timeri, bool stop) | |||
| 526 | } | 542 | } |
| 527 | } | 543 | } |
| 528 | timeri->flags &= ~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START); | 544 | timeri->flags &= ~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START); |
| 545 | if (stop) | ||
| 546 | timeri->flags &= ~SNDRV_TIMER_IFLG_PAUSED; | ||
| 547 | else | ||
| 548 | timeri->flags |= SNDRV_TIMER_IFLG_PAUSED; | ||
| 529 | snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP : | 549 | snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP : |
| 530 | SNDRV_TIMER_EVENT_CONTINUE); | 550 | SNDRV_TIMER_EVENT_CONTINUE); |
| 531 | unlock: | 551 | unlock: |
| @@ -587,6 +607,10 @@ int snd_timer_stop(struct snd_timer_instance *timeri) | |||
| 587 | */ | 607 | */ |
| 588 | int snd_timer_continue(struct snd_timer_instance *timeri) | 608 | int snd_timer_continue(struct snd_timer_instance *timeri) |
| 589 | { | 609 | { |
| 610 | /* timer can continue only after pause */ | ||
| 611 | if (!(timeri->flags & SNDRV_TIMER_IFLG_PAUSED)) | ||
| 612 | return -EINVAL; | ||
| 613 | |||
| 590 | if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) | 614 | if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) |
| 591 | return snd_timer_start_slave(timeri, false); | 615 | return snd_timer_start_slave(timeri, false); |
| 592 | else | 616 | else |
| @@ -813,6 +837,7 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, | |||
| 813 | timer->tmr_subdevice = tid->subdevice; | 837 | timer->tmr_subdevice = tid->subdevice; |
| 814 | if (id) | 838 | if (id) |
| 815 | strlcpy(timer->id, id, sizeof(timer->id)); | 839 | strlcpy(timer->id, id, sizeof(timer->id)); |
| 840 | timer->sticks = 1; | ||
| 816 | INIT_LIST_HEAD(&timer->device_list); | 841 | INIT_LIST_HEAD(&timer->device_list); |
| 817 | INIT_LIST_HEAD(&timer->open_list_head); | 842 | INIT_LIST_HEAD(&timer->open_list_head); |
| 818 | INIT_LIST_HEAD(&timer->active_list_head); | 843 | INIT_LIST_HEAD(&timer->active_list_head); |
| @@ -1817,6 +1842,9 @@ static int snd_timer_user_continue(struct file *file) | |||
| 1817 | tu = file->private_data; | 1842 | tu = file->private_data; |
| 1818 | if (!tu->timeri) | 1843 | if (!tu->timeri) |
| 1819 | return -EBADFD; | 1844 | return -EBADFD; |
| 1845 | /* start timer instead of continue if it's not used before */ | ||
| 1846 | if (!(tu->timeri->flags & SNDRV_TIMER_IFLG_PAUSED)) | ||
| 1847 | return snd_timer_user_start(file); | ||
| 1820 | tu->timeri->lost = 0; | 1848 | tu->timeri->lost = 0; |
| 1821 | return (err = snd_timer_continue(tu->timeri)) < 0 ? err : 0; | 1849 | return (err = snd_timer_continue(tu->timeri)) < 0 ? err : 0; |
| 1822 | } | 1850 | } |
| @@ -1958,6 +1986,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, | |||
| 1958 | tu->qused--; | 1986 | tu->qused--; |
| 1959 | spin_unlock_irq(&tu->qlock); | 1987 | spin_unlock_irq(&tu->qlock); |
| 1960 | 1988 | ||
| 1989 | mutex_lock(&tu->ioctl_lock); | ||
| 1961 | if (tu->tread) { | 1990 | if (tu->tread) { |
| 1962 | if (copy_to_user(buffer, &tu->tqueue[qhead], | 1991 | if (copy_to_user(buffer, &tu->tqueue[qhead], |
| 1963 | sizeof(struct snd_timer_tread))) | 1992 | sizeof(struct snd_timer_tread))) |
| @@ -1967,6 +1996,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, | |||
| 1967 | sizeof(struct snd_timer_read))) | 1996 | sizeof(struct snd_timer_read))) |
| 1968 | err = -EFAULT; | 1997 | err = -EFAULT; |
| 1969 | } | 1998 | } |
| 1999 | mutex_unlock(&tu->ioctl_lock); | ||
| 1970 | 2000 | ||
| 1971 | spin_lock_irq(&tu->qlock); | 2001 | spin_lock_irq(&tu->qlock); |
| 1972 | if (err < 0) | 2002 | if (err < 0) |
diff --git a/sound/firewire/fireworks/fireworks.h b/sound/firewire/fireworks/fireworks.h index 03ed35237e2b..d73c12b8753d 100644 --- a/sound/firewire/fireworks/fireworks.h +++ b/sound/firewire/fireworks/fireworks.h | |||
| @@ -108,7 +108,6 @@ struct snd_efw { | |||
| 108 | u8 *resp_buf; | 108 | u8 *resp_buf; |
| 109 | u8 *pull_ptr; | 109 | u8 *pull_ptr; |
| 110 | u8 *push_ptr; | 110 | u8 *push_ptr; |
| 111 | unsigned int resp_queues; | ||
| 112 | }; | 111 | }; |
| 113 | 112 | ||
| 114 | int snd_efw_transaction_cmd(struct fw_unit *unit, | 113 | int snd_efw_transaction_cmd(struct fw_unit *unit, |
diff --git a/sound/firewire/fireworks/fireworks_hwdep.c b/sound/firewire/fireworks/fireworks_hwdep.c index 33df8655fe81..2e1d9a23920c 100644 --- a/sound/firewire/fireworks/fireworks_hwdep.c +++ b/sound/firewire/fireworks/fireworks_hwdep.c | |||
| @@ -25,6 +25,7 @@ hwdep_read_resp_buf(struct snd_efw *efw, char __user *buf, long remained, | |||
| 25 | { | 25 | { |
| 26 | unsigned int length, till_end, type; | 26 | unsigned int length, till_end, type; |
| 27 | struct snd_efw_transaction *t; | 27 | struct snd_efw_transaction *t; |
| 28 | u8 *pull_ptr; | ||
| 28 | long count = 0; | 29 | long count = 0; |
| 29 | 30 | ||
| 30 | if (remained < sizeof(type) + sizeof(struct snd_efw_transaction)) | 31 | if (remained < sizeof(type) + sizeof(struct snd_efw_transaction)) |
| @@ -38,8 +39,17 @@ hwdep_read_resp_buf(struct snd_efw *efw, char __user *buf, long remained, | |||
| 38 | buf += sizeof(type); | 39 | buf += sizeof(type); |
| 39 | 40 | ||
| 40 | /* write into buffer as many responses as possible */ | 41 | /* write into buffer as many responses as possible */ |
| 41 | while (efw->resp_queues > 0) { | 42 | spin_lock_irq(&efw->lock); |
| 42 | t = (struct snd_efw_transaction *)(efw->pull_ptr); | 43 | |
| 44 | /* | ||
| 45 | * When another task reaches here during this task's access to user | ||
| 46 | * space, it picks up current position in buffer and can read the same | ||
| 47 | * series of responses. | ||
| 48 | */ | ||
| 49 | pull_ptr = efw->pull_ptr; | ||
| 50 | |||
| 51 | while (efw->push_ptr != pull_ptr) { | ||
| 52 | t = (struct snd_efw_transaction *)(pull_ptr); | ||
| 43 | length = be32_to_cpu(t->length) * sizeof(__be32); | 53 | length = be32_to_cpu(t->length) * sizeof(__be32); |
| 44 | 54 | ||
| 45 | /* confirm enough space for this response */ | 55 | /* confirm enough space for this response */ |
| @@ -49,26 +59,39 @@ hwdep_read_resp_buf(struct snd_efw *efw, char __user *buf, long remained, | |||
| 49 | /* copy from ring buffer to user buffer */ | 59 | /* copy from ring buffer to user buffer */ |
| 50 | while (length > 0) { | 60 | while (length > 0) { |
| 51 | till_end = snd_efw_resp_buf_size - | 61 | till_end = snd_efw_resp_buf_size - |
| 52 | (unsigned int)(efw->pull_ptr - efw->resp_buf); | 62 | (unsigned int)(pull_ptr - efw->resp_buf); |
| 53 | till_end = min_t(unsigned int, length, till_end); | 63 | till_end = min_t(unsigned int, length, till_end); |
| 54 | 64 | ||
| 55 | if (copy_to_user(buf, efw->pull_ptr, till_end)) | 65 | spin_unlock_irq(&efw->lock); |
| 66 | |||
| 67 | if (copy_to_user(buf, pull_ptr, till_end)) | ||
| 56 | return -EFAULT; | 68 | return -EFAULT; |
| 57 | 69 | ||
| 58 | efw->pull_ptr += till_end; | 70 | spin_lock_irq(&efw->lock); |
| 59 | if (efw->pull_ptr >= efw->resp_buf + | 71 | |
| 60 | snd_efw_resp_buf_size) | 72 | pull_ptr += till_end; |
| 61 | efw->pull_ptr -= snd_efw_resp_buf_size; | 73 | if (pull_ptr >= efw->resp_buf + snd_efw_resp_buf_size) |
| 74 | pull_ptr -= snd_efw_resp_buf_size; | ||
| 62 | 75 | ||
| 63 | length -= till_end; | 76 | length -= till_end; |
| 64 | buf += till_end; | 77 | buf += till_end; |
| 65 | count += till_end; | 78 | count += till_end; |
| 66 | remained -= till_end; | 79 | remained -= till_end; |
| 67 | } | 80 | } |
| 68 | |||
| 69 | efw->resp_queues--; | ||
| 70 | } | 81 | } |
| 71 | 82 | ||
| 83 | /* | ||
| 84 | * All of tasks can read from the buffer nearly simultaneously, but the | ||
| 85 | * last position for each task is different depending on the length of | ||
| 86 | * given buffer. Here, for simplicity, a position of buffer is set by | ||
| 87 | * the latest task. It's better for a listening application to allow one | ||
| 88 | * thread to read from the buffer. Unless, each task can read different | ||
| 89 | * sequence of responses depending on variation of buffer length. | ||
| 90 | */ | ||
| 91 | efw->pull_ptr = pull_ptr; | ||
| 92 | |||
| 93 | spin_unlock_irq(&efw->lock); | ||
| 94 | |||
| 72 | return count; | 95 | return count; |
| 73 | } | 96 | } |
| 74 | 97 | ||
| @@ -76,14 +99,17 @@ static long | |||
| 76 | hwdep_read_locked(struct snd_efw *efw, char __user *buf, long count, | 99 | hwdep_read_locked(struct snd_efw *efw, char __user *buf, long count, |
| 77 | loff_t *offset) | 100 | loff_t *offset) |
| 78 | { | 101 | { |
| 79 | union snd_firewire_event event; | 102 | union snd_firewire_event event = { |
| 103 | .lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS, | ||
| 104 | }; | ||
| 80 | 105 | ||
| 81 | memset(&event, 0, sizeof(event)); | 106 | spin_lock_irq(&efw->lock); |
| 82 | 107 | ||
| 83 | event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; | ||
| 84 | event.lock_status.status = (efw->dev_lock_count > 0); | 108 | event.lock_status.status = (efw->dev_lock_count > 0); |
| 85 | efw->dev_lock_changed = false; | 109 | efw->dev_lock_changed = false; |
| 86 | 110 | ||
| 111 | spin_unlock_irq(&efw->lock); | ||
| 112 | |||
| 87 | count = min_t(long, count, sizeof(event.lock_status)); | 113 | count = min_t(long, count, sizeof(event.lock_status)); |
| 88 | 114 | ||
| 89 | if (copy_to_user(buf, &event, count)) | 115 | if (copy_to_user(buf, &event, count)) |
| @@ -98,10 +124,15 @@ hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, | |||
| 98 | { | 124 | { |
| 99 | struct snd_efw *efw = hwdep->private_data; | 125 | struct snd_efw *efw = hwdep->private_data; |
| 100 | DEFINE_WAIT(wait); | 126 | DEFINE_WAIT(wait); |
| 127 | bool dev_lock_changed; | ||
| 128 | bool queued; | ||
| 101 | 129 | ||
| 102 | spin_lock_irq(&efw->lock); | 130 | spin_lock_irq(&efw->lock); |
| 103 | 131 | ||
| 104 | while ((!efw->dev_lock_changed) && (efw->resp_queues == 0)) { | 132 | dev_lock_changed = efw->dev_lock_changed; |
| 133 | queued = efw->push_ptr != efw->pull_ptr; | ||
| 134 | |||
| 135 | while (!dev_lock_changed && !queued) { | ||
| 105 | prepare_to_wait(&efw->hwdep_wait, &wait, TASK_INTERRUPTIBLE); | 136 | prepare_to_wait(&efw->hwdep_wait, &wait, TASK_INTERRUPTIBLE); |
| 106 | spin_unlock_irq(&efw->lock); | 137 | spin_unlock_irq(&efw->lock); |
| 107 | schedule(); | 138 | schedule(); |
| @@ -109,15 +140,17 @@ hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, | |||
| 109 | if (signal_pending(current)) | 140 | if (signal_pending(current)) |
| 110 | return -ERESTARTSYS; | 141 | return -ERESTARTSYS; |
| 111 | spin_lock_irq(&efw->lock); | 142 | spin_lock_irq(&efw->lock); |
| 143 | dev_lock_changed = efw->dev_lock_changed; | ||
| 144 | queued = efw->push_ptr != efw->pull_ptr; | ||
| 112 | } | 145 | } |
| 113 | 146 | ||
| 114 | if (efw->dev_lock_changed) | 147 | spin_unlock_irq(&efw->lock); |
| 148 | |||
| 149 | if (dev_lock_changed) | ||
| 115 | count = hwdep_read_locked(efw, buf, count, offset); | 150 | count = hwdep_read_locked(efw, buf, count, offset); |
| 116 | else if (efw->resp_queues > 0) | 151 | else if (queued) |
| 117 | count = hwdep_read_resp_buf(efw, buf, count, offset); | 152 | count = hwdep_read_resp_buf(efw, buf, count, offset); |
| 118 | 153 | ||
| 119 | spin_unlock_irq(&efw->lock); | ||
| 120 | |||
| 121 | return count; | 154 | return count; |
| 122 | } | 155 | } |
| 123 | 156 | ||
| @@ -160,7 +193,7 @@ hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_table *wait) | |||
| 160 | poll_wait(file, &efw->hwdep_wait, wait); | 193 | poll_wait(file, &efw->hwdep_wait, wait); |
| 161 | 194 | ||
| 162 | spin_lock_irq(&efw->lock); | 195 | spin_lock_irq(&efw->lock); |
| 163 | if (efw->dev_lock_changed || (efw->resp_queues > 0)) | 196 | if (efw->dev_lock_changed || efw->pull_ptr != efw->push_ptr) |
| 164 | events = POLLIN | POLLRDNORM; | 197 | events = POLLIN | POLLRDNORM; |
| 165 | else | 198 | else |
| 166 | events = 0; | 199 | events = 0; |
diff --git a/sound/firewire/fireworks/fireworks_proc.c b/sound/firewire/fireworks/fireworks_proc.c index 0639dcb13f7d..beb0a0ffee57 100644 --- a/sound/firewire/fireworks/fireworks_proc.c +++ b/sound/firewire/fireworks/fireworks_proc.c | |||
| @@ -188,8 +188,8 @@ proc_read_queues_state(struct snd_info_entry *entry, | |||
| 188 | else | 188 | else |
| 189 | consumed = (unsigned int)(efw->push_ptr - efw->pull_ptr); | 189 | consumed = (unsigned int)(efw->push_ptr - efw->pull_ptr); |
| 190 | 190 | ||
| 191 | snd_iprintf(buffer, "%d %d/%d\n", | 191 | snd_iprintf(buffer, "%d/%d\n", |
| 192 | efw->resp_queues, consumed, snd_efw_resp_buf_size); | 192 | consumed, snd_efw_resp_buf_size); |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | static void | 195 | static void |
diff --git a/sound/firewire/fireworks/fireworks_transaction.c b/sound/firewire/fireworks/fireworks_transaction.c index f550808d1784..36a08ba51ec7 100644 --- a/sound/firewire/fireworks/fireworks_transaction.c +++ b/sound/firewire/fireworks/fireworks_transaction.c | |||
| @@ -121,11 +121,11 @@ copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode) | |||
| 121 | size_t capacity, till_end; | 121 | size_t capacity, till_end; |
| 122 | struct snd_efw_transaction *t; | 122 | struct snd_efw_transaction *t; |
| 123 | 123 | ||
| 124 | spin_lock_irq(&efw->lock); | ||
| 125 | |||
| 126 | t = (struct snd_efw_transaction *)data; | 124 | t = (struct snd_efw_transaction *)data; |
| 127 | length = min_t(size_t, be32_to_cpu(t->length) * sizeof(u32), length); | 125 | length = min_t(size_t, be32_to_cpu(t->length) * sizeof(u32), length); |
| 128 | 126 | ||
| 127 | spin_lock_irq(&efw->lock); | ||
| 128 | |||
| 129 | if (efw->push_ptr < efw->pull_ptr) | 129 | if (efw->push_ptr < efw->pull_ptr) |
| 130 | capacity = (unsigned int)(efw->pull_ptr - efw->push_ptr); | 130 | capacity = (unsigned int)(efw->pull_ptr - efw->push_ptr); |
| 131 | else | 131 | else |
| @@ -155,7 +155,6 @@ copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode) | |||
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | /* for hwdep */ | 157 | /* for hwdep */ |
| 158 | efw->resp_queues++; | ||
| 159 | wake_up(&efw->hwdep_wait); | 158 | wake_up(&efw->hwdep_wait); |
| 160 | 159 | ||
| 161 | *rcode = RCODE_COMPLETE; | 160 | *rcode = RCODE_COMPLETE; |
diff --git a/sound/firewire/tascam/tascam-hwdep.c b/sound/firewire/tascam/tascam-hwdep.c index 131267c3a042..106406cbfaa3 100644 --- a/sound/firewire/tascam/tascam-hwdep.c +++ b/sound/firewire/tascam/tascam-hwdep.c | |||
| @@ -16,31 +16,14 @@ | |||
| 16 | 16 | ||
| 17 | #include "tascam.h" | 17 | #include "tascam.h" |
| 18 | 18 | ||
| 19 | static long hwdep_read_locked(struct snd_tscm *tscm, char __user *buf, | ||
| 20 | long count) | ||
| 21 | { | ||
| 22 | union snd_firewire_event event; | ||
| 23 | |||
| 24 | memset(&event, 0, sizeof(event)); | ||
| 25 | |||
| 26 | event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; | ||
| 27 | event.lock_status.status = (tscm->dev_lock_count > 0); | ||
| 28 | tscm->dev_lock_changed = false; | ||
| 29 | |||
| 30 | count = min_t(long, count, sizeof(event.lock_status)); | ||
| 31 | |||
| 32 | if (copy_to_user(buf, &event, count)) | ||
| 33 | return -EFAULT; | ||
| 34 | |||
| 35 | return count; | ||
| 36 | } | ||
| 37 | |||
| 38 | static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, | 19 | static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, |
| 39 | loff_t *offset) | 20 | loff_t *offset) |
| 40 | { | 21 | { |
| 41 | struct snd_tscm *tscm = hwdep->private_data; | 22 | struct snd_tscm *tscm = hwdep->private_data; |
| 42 | DEFINE_WAIT(wait); | 23 | DEFINE_WAIT(wait); |
| 43 | union snd_firewire_event event; | 24 | union snd_firewire_event event = { |
| 25 | .lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS, | ||
| 26 | }; | ||
| 44 | 27 | ||
| 45 | spin_lock_irq(&tscm->lock); | 28 | spin_lock_irq(&tscm->lock); |
| 46 | 29 | ||
| @@ -54,10 +37,16 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, | |||
| 54 | spin_lock_irq(&tscm->lock); | 37 | spin_lock_irq(&tscm->lock); |
| 55 | } | 38 | } |
| 56 | 39 | ||
| 57 | memset(&event, 0, sizeof(event)); | 40 | event.lock_status.status = (tscm->dev_lock_count > 0); |
| 58 | count = hwdep_read_locked(tscm, buf, count); | 41 | tscm->dev_lock_changed = false; |
| 42 | |||
| 59 | spin_unlock_irq(&tscm->lock); | 43 | spin_unlock_irq(&tscm->lock); |
| 60 | 44 | ||
| 45 | count = min_t(long, count, sizeof(event.lock_status)); | ||
| 46 | |||
| 47 | if (copy_to_user(buf, &event, count)) | ||
| 48 | return -EFAULT; | ||
| 49 | |||
| 61 | return count; | 50 | return count; |
| 62 | } | 51 | } |
| 63 | 52 | ||
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 574b1b48996f..575cefd8cc4a 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
| @@ -4828,7 +4828,7 @@ enum { | |||
| 4828 | ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, | 4828 | ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, |
| 4829 | ALC292_FIXUP_TPT440_DOCK, | 4829 | ALC292_FIXUP_TPT440_DOCK, |
| 4830 | ALC292_FIXUP_TPT440, | 4830 | ALC292_FIXUP_TPT440, |
| 4831 | ALC283_FIXUP_BXBT2807_MIC, | 4831 | ALC283_FIXUP_HEADSET_MIC, |
| 4832 | ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED, | 4832 | ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED, |
| 4833 | ALC282_FIXUP_ASPIRE_V5_PINS, | 4833 | ALC282_FIXUP_ASPIRE_V5_PINS, |
| 4834 | ALC280_FIXUP_HP_GPIO4, | 4834 | ALC280_FIXUP_HP_GPIO4, |
| @@ -4855,6 +4855,7 @@ enum { | |||
| 4855 | ALC221_FIXUP_HP_FRONT_MIC, | 4855 | ALC221_FIXUP_HP_FRONT_MIC, |
| 4856 | ALC292_FIXUP_TPT460, | 4856 | ALC292_FIXUP_TPT460, |
| 4857 | ALC298_FIXUP_SPK_VOLUME, | 4857 | ALC298_FIXUP_SPK_VOLUME, |
| 4858 | ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER, | ||
| 4858 | }; | 4859 | }; |
| 4859 | 4860 | ||
| 4860 | static const struct hda_fixup alc269_fixups[] = { | 4861 | static const struct hda_fixup alc269_fixups[] = { |
| @@ -5321,7 +5322,7 @@ static const struct hda_fixup alc269_fixups[] = { | |||
| 5321 | .chained = true, | 5322 | .chained = true, |
| 5322 | .chain_id = ALC292_FIXUP_TPT440_DOCK, | 5323 | .chain_id = ALC292_FIXUP_TPT440_DOCK, |
| 5323 | }, | 5324 | }, |
| 5324 | [ALC283_FIXUP_BXBT2807_MIC] = { | 5325 | [ALC283_FIXUP_HEADSET_MIC] = { |
| 5325 | .type = HDA_FIXUP_PINS, | 5326 | .type = HDA_FIXUP_PINS, |
| 5326 | .v.pins = (const struct hda_pintbl[]) { | 5327 | .v.pins = (const struct hda_pintbl[]) { |
| 5327 | { 0x19, 0x04a110f0 }, | 5328 | { 0x19, 0x04a110f0 }, |
| @@ -5516,6 +5517,15 @@ static const struct hda_fixup alc269_fixups[] = { | |||
| 5516 | .chained = true, | 5517 | .chained = true, |
| 5517 | .chain_id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, | 5518 | .chain_id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, |
| 5518 | }, | 5519 | }, |
| 5520 | [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = { | ||
| 5521 | .type = HDA_FIXUP_PINS, | ||
| 5522 | .v.pins = (const struct hda_pintbl[]) { | ||
| 5523 | { 0x1b, 0x90170151 }, | ||
| 5524 | { } | ||
| 5525 | }, | ||
| 5526 | .chained = true, | ||
| 5527 | .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE | ||
| 5528 | }, | ||
| 5519 | }; | 5529 | }; |
| 5520 | 5530 | ||
| 5521 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { | 5531 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
| @@ -5560,6 +5570,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { | |||
| 5560 | SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), | 5570 | SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), |
| 5561 | SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), | 5571 | SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), |
| 5562 | SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), | 5572 | SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), |
| 5573 | SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER), | ||
| 5563 | SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE), | 5574 | SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE), |
| 5564 | SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), | 5575 | SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), |
| 5565 | SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME), | 5576 | SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME), |
| @@ -5651,7 +5662,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { | |||
| 5651 | SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN), | 5662 | SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN), |
| 5652 | SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), | 5663 | SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), |
| 5653 | SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC), | 5664 | 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), | 5665 | SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC), |
| 5666 | SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC), | ||
| 5655 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), | 5667 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 5656 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), | 5668 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 5657 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), | 5669 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| @@ -5894,6 +5906,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { | |||
| 5894 | {0x12, 0x90a60170}, | 5906 | {0x12, 0x90a60170}, |
| 5895 | {0x14, 0x90170120}, | 5907 | {0x14, 0x90170120}, |
| 5896 | {0x21, 0x02211030}), | 5908 | {0x21, 0x02211030}), |
| 5909 | SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell Inspiron 5468", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, | ||
| 5910 | {0x12, 0x90a60180}, | ||
| 5911 | {0x14, 0x90170120}, | ||
| 5912 | {0x21, 0x02211030}), | ||
| 5897 | SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, | 5913 | SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, |
| 5898 | ALC256_STANDARD_PINS), | 5914 | ALC256_STANDARD_PINS), |
| 5899 | SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4, | 5915 | SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4, |
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 54c09acd3fed..16e459aedffe 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c | |||
| @@ -299,8 +299,9 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream, | |||
| 299 | clk_enable(ssc_p->ssc->clk); | 299 | clk_enable(ssc_p->ssc->clk); |
| 300 | ssc_p->mck_rate = clk_get_rate(ssc_p->ssc->clk); | 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 */ | 302 | /* Reset the SSC unless initialized to keep it in a clean state */ |
| 303 | ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); | 303 | if (!ssc_p->initialized) |
| 304 | ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); | ||
| 304 | 305 | ||
| 305 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 306 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 306 | dir = 0; | 307 | dir = 0; |
diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index e5527bc570ae..bcf1834c5648 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c | |||
| @@ -1247,8 +1247,8 @@ static int da7213_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
| 1247 | return -EINVAL; | 1247 | return -EINVAL; |
| 1248 | } | 1248 | } |
| 1249 | 1249 | ||
| 1250 | /* By default only 32 BCLK per WCLK is supported */ | 1250 | /* By default only 64 BCLK per WCLK is supported */ |
| 1251 | dai_clk_mode |= DA7213_DAI_BCLKS_PER_WCLK_32; | 1251 | dai_clk_mode |= DA7213_DAI_BCLKS_PER_WCLK_64; |
| 1252 | 1252 | ||
| 1253 | snd_soc_write(codec, DA7213_DAI_CLK_MODE, dai_clk_mode); | 1253 | snd_soc_write(codec, DA7213_DAI_CLK_MODE, dai_clk_mode); |
| 1254 | snd_soc_update_bits(codec, DA7213_DAI_CTRL, DA7213_DAI_FORMAT_MASK, | 1254 | snd_soc_update_bits(codec, DA7213_DAI_CTRL, DA7213_DAI_FORMAT_MASK, |
diff --git a/sound/soc/codecs/max98371.c b/sound/soc/codecs/max98371.c index cf0a39bb631a..02352ed8961c 100644 --- a/sound/soc/codecs/max98371.c +++ b/sound/soc/codecs/max98371.c | |||
| @@ -412,6 +412,7 @@ static int max98371_i2c_remove(struct i2c_client *client) | |||
| 412 | 412 | ||
| 413 | static const struct i2c_device_id max98371_i2c_id[] = { | 413 | static const struct i2c_device_id max98371_i2c_id[] = { |
| 414 | { "max98371", 0 }, | 414 | { "max98371", 0 }, |
| 415 | { } | ||
| 415 | }; | 416 | }; |
| 416 | 417 | ||
| 417 | MODULE_DEVICE_TABLE(i2c, max98371_i2c_id); | 418 | MODULE_DEVICE_TABLE(i2c, max98371_i2c_id); |
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index 5c9707ac4bbf..2e59a85e360b 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c | |||
| @@ -212,31 +212,6 @@ static const unsigned short logtable[256] = { | |||
| 212 | 0xfa2f, 0xfaea, 0xfba5, 0xfc60, 0xfd1a, 0xfdd4, 0xfe8e, 0xff47 | 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 | * nau8825_sema_acquire - acquire the semaphore of nau88l25 | 216 | * nau8825_sema_acquire - acquire the semaphore of nau88l25 |
| 242 | * @nau8825: component to register the codec private data with | 217 | * @nau8825: component to register the codec private data with |
| @@ -250,19 +225,26 @@ static bool nau8825_dai_is_active(struct nau8825 *nau8825) | |||
| 250 | * Acquires the semaphore without jiffies. If no more tasks are allowed | 225 | * Acquires the semaphore without jiffies. If no more tasks are allowed |
| 251 | * to acquire the semaphore, calling this function will put the task to | 226 | * to acquire the semaphore, calling this function will put the task to |
| 252 | * sleep until the semaphore is released. | 227 | * sleep until the semaphore is released. |
| 253 | * It returns if the semaphore was acquired. | 228 | * If the semaphore is not released within the specified number of jiffies, |
| 229 | * this function returns -ETIME. | ||
| 230 | * If the sleep is interrupted by a signal, this function will return -EINTR. | ||
| 231 | * It returns 0 if the semaphore was acquired successfully. | ||
| 254 | */ | 232 | */ |
| 255 | static void nau8825_sema_acquire(struct nau8825 *nau8825, long timeout) | 233 | static int nau8825_sema_acquire(struct nau8825 *nau8825, long timeout) |
| 256 | { | 234 | { |
| 257 | int ret; | 235 | int ret; |
| 258 | 236 | ||
| 259 | if (timeout) | 237 | if (timeout) { |
| 260 | ret = down_timeout(&nau8825->xtalk_sem, timeout); | 238 | ret = down_timeout(&nau8825->xtalk_sem, timeout); |
| 261 | else | 239 | if (ret < 0) |
| 240 | dev_warn(nau8825->dev, "Acquire semaphone timeout\n"); | ||
| 241 | } else { | ||
| 262 | ret = down_interruptible(&nau8825->xtalk_sem); | 242 | ret = down_interruptible(&nau8825->xtalk_sem); |
| 243 | if (ret < 0) | ||
| 244 | dev_warn(nau8825->dev, "Acquire semaphone fail\n"); | ||
| 245 | } | ||
| 263 | 246 | ||
| 264 | if (ret < 0) | 247 | return ret; |
| 265 | dev_warn(nau8825->dev, "Acquire semaphone fail\n"); | ||
| 266 | } | 248 | } |
| 267 | 249 | ||
| 268 | /** | 250 | /** |
| @@ -1205,6 +1187,8 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream, | |||
| 1205 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | 1187 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); |
| 1206 | unsigned int val_len = 0; | 1188 | unsigned int val_len = 0; |
| 1207 | 1189 | ||
| 1190 | nau8825_sema_acquire(nau8825, 2 * HZ); | ||
| 1191 | |||
| 1208 | switch (params_width(params)) { | 1192 | switch (params_width(params)) { |
| 1209 | case 16: | 1193 | case 16: |
| 1210 | val_len |= NAU8825_I2S_DL_16; | 1194 | val_len |= NAU8825_I2S_DL_16; |
| @@ -1225,6 +1209,9 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream, | |||
| 1225 | regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL1, | 1209 | regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL1, |
| 1226 | NAU8825_I2S_DL_MASK, val_len); | 1210 | NAU8825_I2S_DL_MASK, val_len); |
| 1227 | 1211 | ||
| 1212 | /* Release the semaphone. */ | ||
| 1213 | nau8825_sema_release(nau8825); | ||
| 1214 | |||
| 1228 | return 0; | 1215 | return 0; |
| 1229 | } | 1216 | } |
| 1230 | 1217 | ||
| @@ -1234,6 +1221,8 @@ static int nau8825_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
| 1234 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | 1221 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); |
| 1235 | unsigned int ctrl1_val = 0, ctrl2_val = 0; | 1222 | unsigned int ctrl1_val = 0, ctrl2_val = 0; |
| 1236 | 1223 | ||
| 1224 | nau8825_sema_acquire(nau8825, 2 * HZ); | ||
| 1225 | |||
| 1237 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 1226 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 1238 | case SND_SOC_DAIFMT_CBM_CFM: | 1227 | case SND_SOC_DAIFMT_CBM_CFM: |
| 1239 | ctrl2_val |= NAU8825_I2S_MS_MASTER; | 1228 | ctrl2_val |= NAU8825_I2S_MS_MASTER; |
| @@ -1282,6 +1271,9 @@ static int nau8825_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
| 1282 | regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, | 1271 | regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, |
| 1283 | NAU8825_I2S_MS_MASK, ctrl2_val); | 1272 | NAU8825_I2S_MS_MASK, ctrl2_val); |
| 1284 | 1273 | ||
| 1274 | /* Release the semaphone. */ | ||
| 1275 | nau8825_sema_release(nau8825); | ||
| 1276 | |||
| 1285 | return 0; | 1277 | return 0; |
| 1286 | } | 1278 | } |
| 1287 | 1279 | ||
| @@ -1611,8 +1603,11 @@ static irqreturn_t nau8825_interrupt(int irq, void *data) | |||
| 1611 | * cess and restore changes if process | 1603 | * cess and restore changes if process |
| 1612 | * is ongoing when ejection. | 1604 | * is ongoing when ejection. |
| 1613 | */ | 1605 | */ |
| 1606 | int ret; | ||
| 1614 | nau8825->xtalk_protect = true; | 1607 | nau8825->xtalk_protect = true; |
| 1615 | nau8825_sema_acquire(nau8825, 0); | 1608 | ret = nau8825_sema_acquire(nau8825, 0); |
| 1609 | if (ret < 0) | ||
| 1610 | nau8825->xtalk_protect = false; | ||
| 1616 | } | 1611 | } |
| 1617 | /* Startup cross talk detection process */ | 1612 | /* Startup cross talk detection process */ |
| 1618 | nau8825->xtalk_state = NAU8825_XTALK_PREPARE; | 1613 | nau8825->xtalk_state = NAU8825_XTALK_PREPARE; |
| @@ -2238,23 +2233,14 @@ static int __maybe_unused nau8825_suspend(struct snd_soc_codec *codec) | |||
| 2238 | static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec) | 2233 | static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec) |
| 2239 | { | 2234 | { |
| 2240 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | 2235 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); |
| 2236 | int ret; | ||
| 2241 | 2237 | ||
| 2242 | regcache_cache_only(nau8825->regmap, false); | 2238 | regcache_cache_only(nau8825->regmap, false); |
| 2243 | regcache_sync(nau8825->regmap); | 2239 | regcache_sync(nau8825->regmap); |
| 2244 | if (nau8825_is_jack_inserted(nau8825->regmap)) { | 2240 | nau8825->xtalk_protect = true; |
| 2245 | /* If the jack is inserted, we need to check whether the play- | 2241 | ret = nau8825_sema_acquire(nau8825, 0); |
| 2246 | * back is active before suspend. If active, the driver has to | 2242 | if (ret < 0) |
| 2247 | * raise the protection for cross talk function to avoid the | 2243 | nau8825->xtalk_protect = false; |
| 2248 | * playback recovers before cross talk process finish. Other- | ||
| 2249 | * wise, the playback will be interfered by cross talk func- | ||
| 2250 | * tion. It is better to apply hardware related parameters | ||
| 2251 | * before starting playback or record. | ||
| 2252 | */ | ||
| 2253 | if (nau8825_dai_is_active(nau8825)) { | ||
| 2254 | nau8825->xtalk_protect = true; | ||
| 2255 | nau8825_sema_acquire(nau8825, 0); | ||
| 2256 | } | ||
| 2257 | } | ||
| 2258 | enable_irq(nau8825->irq); | 2244 | enable_irq(nau8825->irq); |
| 2259 | 2245 | ||
| 2260 | return 0; | 2246 | return 0; |
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index a67ea10f41a1..f2664396be6f 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c | |||
| @@ -581,7 +581,7 @@ static int wm2000_anc_transition(struct wm2000_priv *wm2000, | |||
| 581 | if (anc_transitions[i].dest == ANC_OFF) | 581 | if (anc_transitions[i].dest == ANC_OFF) |
| 582 | clk_disable_unprepare(wm2000->mclk); | 582 | clk_disable_unprepare(wm2000->mclk); |
| 583 | 583 | ||
| 584 | return ret; | 584 | return 0; |
| 585 | } | 585 | } |
| 586 | 586 | ||
| 587 | static int wm2000_anc_set_mode(struct wm2000_priv *wm2000) | 587 | static int wm2000_anc_set_mode(struct wm2000_priv *wm2000) |
diff --git a/sound/soc/generic/Makefile b/sound/soc/generic/Makefile index 45602ca8536e..2d53c8d70705 100644 --- a/sound/soc/generic/Makefile +++ b/sound/soc/generic/Makefile | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | obj-$(CONFIG_SND_SIMPLE_CARD_UTILS) := simple-card-utils.o | 1 | snd-soc-simple-card-utils-objs := simple-card-utils.o |
| 2 | |||
| 3 | snd-soc-simple-card-objs := simple-card.o | 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 | ||
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index d89a9a1b2471..9599de69a880 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | * it under the terms of the GNU General Public License version 2 as | 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
| 9 | */ | 9 | */ |
| 10 | #include <linux/module.h> | ||
| 10 | #include <linux/of.h> | 11 | #include <linux/of.h> |
| 11 | #include <sound/simple_card_utils.h> | 12 | #include <sound/simple_card_utils.h> |
| 12 | 13 | ||
| @@ -95,3 +96,8 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card, | |||
| 95 | return 0; | 96 | return 0; |
| 96 | } | 97 | } |
| 97 | EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name); | 98 | EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name); |
| 99 | |||
| 100 | /* Module information */ | ||
| 101 | MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>"); | ||
| 102 | MODULE_DESCRIPTION("ALSA SoC Simple Card Utils"); | ||
| 103 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/sound/soc/intel/skylake/skl-sst-utils.c b/sound/soc/intel/skylake/skl-sst-utils.c index 25fcb796bd86..ddcb52a51854 100644 --- a/sound/soc/intel/skylake/skl-sst-utils.c +++ b/sound/soc/intel/skylake/skl-sst-utils.c | |||
| @@ -123,6 +123,11 @@ int snd_skl_get_module_info(struct skl_sst *ctx, u8 *uuid, | |||
| 123 | 123 | ||
| 124 | uuid_mod = (uuid_le *)uuid; | 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 | list_for_each_entry(module, &ctx->uuid_list, list) { | 131 | list_for_each_entry(module, &ctx->uuid_list, list) { |
| 127 | if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) { | 132 | if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) { |
| 128 | dfw_config->module_id = module->id; | 133 | dfw_config->module_id = module->id; |
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index cd59536a761d..e3e764167765 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c | |||
| @@ -672,8 +672,10 @@ static int skl_probe(struct pci_dev *pci, | |||
| 672 | 672 | ||
| 673 | skl->nhlt = skl_nhlt_init(bus->dev); | 673 | skl->nhlt = skl_nhlt_init(bus->dev); |
| 674 | 674 | ||
| 675 | if (skl->nhlt == NULL) | 675 | if (skl->nhlt == NULL) { |
| 676 | err = -ENODEV; | ||
| 676 | goto out_free; | 677 | goto out_free; |
| 678 | } | ||
| 677 | 679 | ||
| 678 | skl_nhlt_update_topology_bin(skl); | 680 | skl_nhlt_update_topology_bin(skl); |
| 679 | 681 | ||
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index 0843a68f277c..f61b3b58083b 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c | |||
| @@ -38,10 +38,10 @@ | |||
| 38 | struct abe_twl6040 { | 38 | struct abe_twl6040 { |
| 39 | int jack_detection; /* board can detect jack events */ | 39 | int jack_detection; /* board can detect jack events */ |
| 40 | int mclk_freq; /* MCLK frequency speed for twl6040 */ | 40 | int mclk_freq; /* MCLK frequency speed for twl6040 */ |
| 41 | |||
| 42 | struct platform_device *dmic_codec_dev; | ||
| 43 | }; | 41 | }; |
| 44 | 42 | ||
| 43 | struct platform_device *dmic_codec_dev; | ||
| 44 | |||
| 45 | static int omap_abe_hw_params(struct snd_pcm_substream *substream, | 45 | static int omap_abe_hw_params(struct snd_pcm_substream *substream, |
| 46 | struct snd_pcm_hw_params *params) | 46 | struct snd_pcm_hw_params *params) |
| 47 | { | 47 | { |
| @@ -258,8 +258,6 @@ static int omap_abe_probe(struct platform_device *pdev) | |||
| 258 | if (priv == NULL) | 258 | if (priv == NULL) |
| 259 | return -ENOMEM; | 259 | return -ENOMEM; |
| 260 | 260 | ||
| 261 | priv->dmic_codec_dev = ERR_PTR(-EINVAL); | ||
| 262 | |||
| 263 | if (snd_soc_of_parse_card_name(card, "ti,model")) { | 261 | if (snd_soc_of_parse_card_name(card, "ti,model")) { |
| 264 | dev_err(&pdev->dev, "Card name is not provided\n"); | 262 | dev_err(&pdev->dev, "Card name is not provided\n"); |
| 265 | return -ENODEV; | 263 | return -ENODEV; |
| @@ -284,13 +282,6 @@ static int omap_abe_probe(struct platform_device *pdev) | |||
| 284 | num_links = 2; | 282 | num_links = 2; |
| 285 | abe_twl6040_dai_links[1].cpu_of_node = dai_node; | 283 | abe_twl6040_dai_links[1].cpu_of_node = dai_node; |
| 286 | abe_twl6040_dai_links[1].platform_of_node = dai_node; | 284 | abe_twl6040_dai_links[1].platform_of_node = dai_node; |
| 287 | |||
| 288 | priv->dmic_codec_dev = platform_device_register_simple( | ||
| 289 | "dmic-codec", -1, NULL, 0); | ||
| 290 | if (IS_ERR(priv->dmic_codec_dev)) { | ||
| 291 | dev_err(&pdev->dev, "Can't instantiate dmic-codec\n"); | ||
| 292 | return PTR_ERR(priv->dmic_codec_dev); | ||
| 293 | } | ||
| 294 | } else { | 285 | } else { |
| 295 | num_links = 1; | 286 | num_links = 1; |
| 296 | } | 287 | } |
| @@ -299,16 +290,14 @@ static int omap_abe_probe(struct platform_device *pdev) | |||
| 299 | of_property_read_u32(node, "ti,mclk-freq", &priv->mclk_freq); | 290 | of_property_read_u32(node, "ti,mclk-freq", &priv->mclk_freq); |
| 300 | if (!priv->mclk_freq) { | 291 | if (!priv->mclk_freq) { |
| 301 | dev_err(&pdev->dev, "MCLK frequency not provided\n"); | 292 | dev_err(&pdev->dev, "MCLK frequency not provided\n"); |
| 302 | ret = -EINVAL; | 293 | return -EINVAL; |
| 303 | goto err_unregister; | ||
| 304 | } | 294 | } |
| 305 | 295 | ||
| 306 | card->fully_routed = 1; | 296 | card->fully_routed = 1; |
| 307 | 297 | ||
| 308 | if (!priv->mclk_freq) { | 298 | if (!priv->mclk_freq) { |
| 309 | dev_err(&pdev->dev, "MCLK frequency missing\n"); | 299 | dev_err(&pdev->dev, "MCLK frequency missing\n"); |
| 310 | ret = -ENODEV; | 300 | return -ENODEV; |
| 311 | goto err_unregister; | ||
| 312 | } | 301 | } |
| 313 | 302 | ||
| 314 | card->dai_link = abe_twl6040_dai_links; | 303 | card->dai_link = abe_twl6040_dai_links; |
| @@ -317,17 +306,9 @@ static int omap_abe_probe(struct platform_device *pdev) | |||
| 317 | snd_soc_card_set_drvdata(card, priv); | 306 | snd_soc_card_set_drvdata(card, priv); |
| 318 | 307 | ||
| 319 | ret = snd_soc_register_card(card); | 308 | ret = snd_soc_register_card(card); |
| 320 | if (ret) { | 309 | if (ret) |
| 321 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | 310 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", |
| 322 | ret); | 311 | ret); |
| 323 | goto err_unregister; | ||
| 324 | } | ||
| 325 | |||
| 326 | return 0; | ||
| 327 | |||
| 328 | err_unregister: | ||
| 329 | if (!IS_ERR(priv->dmic_codec_dev)) | ||
| 330 | platform_device_unregister(priv->dmic_codec_dev); | ||
| 331 | 312 | ||
| 332 | return ret; | 313 | return ret; |
| 333 | } | 314 | } |
| @@ -335,13 +316,9 @@ err_unregister: | |||
| 335 | static int omap_abe_remove(struct platform_device *pdev) | 316 | static int omap_abe_remove(struct platform_device *pdev) |
| 336 | { | 317 | { |
| 337 | struct snd_soc_card *card = platform_get_drvdata(pdev); | 318 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
| 338 | struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card); | ||
| 339 | 319 | ||
| 340 | snd_soc_unregister_card(card); | 320 | snd_soc_unregister_card(card); |
| 341 | 321 | ||
| 342 | if (!IS_ERR(priv->dmic_codec_dev)) | ||
| 343 | platform_device_unregister(priv->dmic_codec_dev); | ||
| 344 | |||
| 345 | return 0; | 322 | return 0; |
| 346 | } | 323 | } |
| 347 | 324 | ||
| @@ -361,7 +338,33 @@ static struct platform_driver omap_abe_driver = { | |||
| 361 | .remove = omap_abe_remove, | 338 | .remove = omap_abe_remove, |
| 362 | }; | 339 | }; |
| 363 | 340 | ||
| 364 | module_platform_driver(omap_abe_driver); | 341 | static int __init omap_abe_init(void) |
| 342 | { | ||
| 343 | int ret; | ||
| 344 | |||
| 345 | dmic_codec_dev = platform_device_register_simple("dmic-codec", -1, NULL, | ||
| 346 | 0); | ||
| 347 | if (IS_ERR(dmic_codec_dev)) { | ||
| 348 | pr_err("%s: dmic-codec device registration failed\n", __func__); | ||
| 349 | return PTR_ERR(dmic_codec_dev); | ||
| 350 | } | ||
| 351 | |||
| 352 | ret = platform_driver_register(&omap_abe_driver); | ||
| 353 | if (ret) { | ||
| 354 | pr_err("%s: platform driver registration failed\n", __func__); | ||
| 355 | platform_device_unregister(dmic_codec_dev); | ||
| 356 | } | ||
| 357 | |||
| 358 | return ret; | ||
| 359 | } | ||
| 360 | module_init(omap_abe_init); | ||
| 361 | |||
| 362 | static void __exit omap_abe_exit(void) | ||
| 363 | { | ||
| 364 | platform_driver_unregister(&omap_abe_driver); | ||
| 365 | platform_device_unregister(dmic_codec_dev); | ||
| 366 | } | ||
| 367 | module_exit(omap_abe_exit); | ||
| 365 | 368 | ||
| 366 | MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>"); | 369 | MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>"); |
| 367 | MODULE_DESCRIPTION("ALSA SoC for OMAP boards with ABE and twl6040 codec"); | 370 | MODULE_DESCRIPTION("ALSA SoC for OMAP boards with ABE and twl6040 codec"); |
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index e7cdc51fd806..64609c77a79d 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c | |||
| @@ -31,7 +31,6 @@ | |||
| 31 | #include <linux/err.h> | 31 | #include <linux/err.h> |
| 32 | #include <linux/io.h> | 32 | #include <linux/io.h> |
| 33 | #include <linux/irq.h> | 33 | #include <linux/irq.h> |
| 34 | #include <linux/clk.h> | ||
| 35 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
| 36 | #include <linux/pm_runtime.h> | 35 | #include <linux/pm_runtime.h> |
| 37 | #include <linux/of_device.h> | 36 | #include <linux/of_device.h> |
| @@ -55,7 +54,6 @@ struct omap_mcpdm { | |||
| 55 | unsigned long phys_base; | 54 | unsigned long phys_base; |
| 56 | void __iomem *io_base; | 55 | void __iomem *io_base; |
| 57 | int irq; | 56 | int irq; |
| 58 | struct clk *pdmclk; | ||
| 59 | 57 | ||
| 60 | struct mutex mutex; | 58 | struct mutex mutex; |
| 61 | 59 | ||
| @@ -390,15 +388,14 @@ static int omap_mcpdm_probe(struct snd_soc_dai *dai) | |||
| 390 | struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); | 388 | struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); |
| 391 | int ret; | 389 | int ret; |
| 392 | 390 | ||
| 393 | clk_prepare_enable(mcpdm->pdmclk); | ||
| 394 | pm_runtime_enable(mcpdm->dev); | 391 | pm_runtime_enable(mcpdm->dev); |
| 395 | 392 | ||
| 396 | /* Disable lines while request is ongoing */ | 393 | /* Disable lines while request is ongoing */ |
| 397 | pm_runtime_get_sync(mcpdm->dev); | 394 | pm_runtime_get_sync(mcpdm->dev); |
| 398 | omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, 0x00); | 395 | omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, 0x00); |
| 399 | 396 | ||
| 400 | ret = devm_request_irq(mcpdm->dev, mcpdm->irq, omap_mcpdm_irq_handler, | 397 | ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler, 0, "McPDM", |
| 401 | 0, "McPDM", (void *)mcpdm); | 398 | (void *)mcpdm); |
| 402 | 399 | ||
| 403 | pm_runtime_put_sync(mcpdm->dev); | 400 | pm_runtime_put_sync(mcpdm->dev); |
| 404 | 401 | ||
| @@ -423,9 +420,9 @@ static int omap_mcpdm_remove(struct snd_soc_dai *dai) | |||
| 423 | { | 420 | { |
| 424 | struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); | 421 | struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); |
| 425 | 422 | ||
| 423 | free_irq(mcpdm->irq, (void *)mcpdm); | ||
| 426 | pm_runtime_disable(mcpdm->dev); | 424 | pm_runtime_disable(mcpdm->dev); |
| 427 | 425 | ||
| 428 | clk_disable_unprepare(mcpdm->pdmclk); | ||
| 429 | return 0; | 426 | return 0; |
| 430 | } | 427 | } |
| 431 | 428 | ||
| @@ -445,8 +442,6 @@ static int omap_mcpdm_suspend(struct snd_soc_dai *dai) | |||
| 445 | mcpdm->pm_active_count++; | 442 | mcpdm->pm_active_count++; |
| 446 | } | 443 | } |
| 447 | 444 | ||
| 448 | clk_disable_unprepare(mcpdm->pdmclk); | ||
| 449 | |||
| 450 | return 0; | 445 | return 0; |
| 451 | } | 446 | } |
| 452 | 447 | ||
| @@ -454,8 +449,6 @@ static int omap_mcpdm_resume(struct snd_soc_dai *dai) | |||
| 454 | { | 449 | { |
| 455 | struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); | 450 | struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); |
| 456 | 451 | ||
| 457 | clk_prepare_enable(mcpdm->pdmclk); | ||
| 458 | |||
| 459 | if (mcpdm->pm_active_count) { | 452 | if (mcpdm->pm_active_count) { |
| 460 | while (mcpdm->pm_active_count--) | 453 | while (mcpdm->pm_active_count--) |
| 461 | pm_runtime_get_sync(mcpdm->dev); | 454 | pm_runtime_get_sync(mcpdm->dev); |
| @@ -549,15 +542,6 @@ static int asoc_mcpdm_probe(struct platform_device *pdev) | |||
| 549 | 542 | ||
| 550 | mcpdm->dev = &pdev->dev; | 543 | mcpdm->dev = &pdev->dev; |
| 551 | 544 | ||
| 552 | mcpdm->pdmclk = devm_clk_get(&pdev->dev, "pdmclk"); | ||
| 553 | if (IS_ERR(mcpdm->pdmclk)) { | ||
| 554 | if (PTR_ERR(mcpdm->pdmclk) == -EPROBE_DEFER) | ||
| 555 | return -EPROBE_DEFER; | ||
| 556 | dev_warn(&pdev->dev, "Error getting pdmclk (%ld)!\n", | ||
| 557 | PTR_ERR(mcpdm->pdmclk)); | ||
| 558 | mcpdm->pdmclk = NULL; | ||
| 559 | } | ||
| 560 | |||
| 561 | ret = devm_snd_soc_register_component(&pdev->dev, | 545 | ret = devm_snd_soc_register_component(&pdev->dev, |
| 562 | &omap_mcpdm_component, | 546 | &omap_mcpdm_component, |
| 563 | &omap_mcpdm_dai, 1); | 547 | &omap_mcpdm_dai, 1); |
diff --git a/sound/soc/samsung/s3c24xx_uda134x.c b/sound/soc/samsung/s3c24xx_uda134x.c index 50849e137fc0..92e88bca386e 100644 --- a/sound/soc/samsung/s3c24xx_uda134x.c +++ b/sound/soc/samsung/s3c24xx_uda134x.c | |||
| @@ -58,10 +58,12 @@ static struct platform_device *s3c24xx_uda134x_snd_device; | |||
| 58 | 58 | ||
| 59 | static int s3c24xx_uda134x_startup(struct snd_pcm_substream *substream) | 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 | #ifdef ENFORCE_RATES | 63 | #ifdef ENFORCE_RATES |
| 63 | struct snd_pcm_runtime *runtime = substream->runtime; | 64 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 64 | #endif | 65 | #endif |
| 66 | int ret = 0; | ||
| 65 | 67 | ||
| 66 | mutex_lock(&clk_lock); | 68 | mutex_lock(&clk_lock); |
| 67 | pr_debug("%s %d\n", __func__, clk_users); | 69 | pr_debug("%s %d\n", __func__, clk_users); |
| @@ -71,8 +73,7 @@ static int s3c24xx_uda134x_startup(struct snd_pcm_substream *substream) | |||
| 71 | printk(KERN_ERR "%s cannot get xtal\n", __func__); | 73 | printk(KERN_ERR "%s cannot get xtal\n", __func__); |
| 72 | ret = PTR_ERR(xtal); | 74 | ret = PTR_ERR(xtal); |
| 73 | } else { | 75 | } else { |
| 74 | pclk = clk_get(&s3c24xx_uda134x_snd_device->dev, | 76 | pclk = clk_get(cpu_dai->dev, "iis"); |
| 75 | "pclk"); | ||
| 76 | if (IS_ERR(pclk)) { | 77 | if (IS_ERR(pclk)) { |
| 77 | printk(KERN_ERR "%s cannot get pclk\n", | 78 | printk(KERN_ERR "%s cannot get pclk\n", |
| 78 | __func__); | 79 | __func__); |
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index e39f916d0f2f..969a5169de25 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c | |||
| @@ -226,8 +226,12 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, | |||
| 226 | ifscr = 0; | 226 | ifscr = 0; |
| 227 | fsrate = 0; | 227 | fsrate = 0; |
| 228 | if (fin != fout) { | 228 | if (fin != fout) { |
| 229 | u64 n; | ||
| 230 | |||
| 229 | ifscr = 1; | 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 | /* |
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index d2df46c14c68..bf7b52fce597 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c | |||
| @@ -121,7 +121,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) | |||
| 121 | 121 | ||
| 122 | dpcm_be_disconnect(fe, stream); | 122 | dpcm_be_disconnect(fe, stream); |
| 123 | fe->dpcm[stream].runtime = NULL; | 123 | fe->dpcm[stream].runtime = NULL; |
| 124 | goto fe_err; | 124 | goto path_err; |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | dpcm_clear_pending_state(fe, stream); | 127 | dpcm_clear_pending_state(fe, stream); |
| @@ -136,6 +136,8 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) | |||
| 136 | 136 | ||
| 137 | return 0; | 137 | return 0; |
| 138 | 138 | ||
| 139 | path_err: | ||
| 140 | dpcm_path_put(&list); | ||
| 139 | fe_err: | 141 | fe_err: |
| 140 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown) | 142 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown) |
| 141 | fe->dai_link->compr_ops->shutdown(cstream); | 143 | fe->dai_link->compr_ops->shutdown(cstream); |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 16369cad4803..4afa8dba5e98 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
| @@ -1056,7 +1056,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, | |||
| 1056 | if (!rtd->platform) { | 1056 | if (!rtd->platform) { |
| 1057 | dev_err(card->dev, "ASoC: platform %s not registered\n", | 1057 | dev_err(card->dev, "ASoC: platform %s not registered\n", |
| 1058 | dai_link->platform_name); | 1058 | dai_link->platform_name); |
| 1059 | return -EPROBE_DEFER; | 1059 | goto _err_defer; |
| 1060 | } | 1060 | } |
| 1061 | 1061 | ||
| 1062 | soc_add_pcm_runtime(card, rtd); | 1062 | soc_add_pcm_runtime(card, rtd); |
| @@ -2083,14 +2083,13 @@ static int soc_cleanup_card_resources(struct snd_soc_card *card) | |||
| 2083 | /* remove auxiliary devices */ | 2083 | /* remove auxiliary devices */ |
| 2084 | soc_remove_aux_devices(card); | 2084 | soc_remove_aux_devices(card); |
| 2085 | 2085 | ||
| 2086 | snd_soc_dapm_free(&card->dapm); | ||
| 2086 | soc_cleanup_card_debugfs(card); | 2087 | soc_cleanup_card_debugfs(card); |
| 2087 | 2088 | ||
| 2088 | /* remove the card */ | 2089 | /* remove the card */ |
| 2089 | if (card->remove) | 2090 | if (card->remove) |
| 2090 | card->remove(card); | 2091 | card->remove(card); |
| 2091 | 2092 | ||
| 2092 | snd_soc_dapm_free(&card->dapm); | ||
| 2093 | |||
| 2094 | snd_card_free(card->snd_card); | 2093 | snd_card_free(card->snd_card); |
| 2095 | return 0; | 2094 | return 0; |
| 2096 | 2095 | ||
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 8698c26773b3..d908ff8f9755 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
| @@ -3493,6 +3493,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, | |||
| 3493 | const struct snd_soc_pcm_stream *config = w->params + w->params_select; | 3493 | const struct snd_soc_pcm_stream *config = w->params + w->params_select; |
| 3494 | struct snd_pcm_substream substream; | 3494 | struct snd_pcm_substream substream; |
| 3495 | struct snd_pcm_hw_params *params = NULL; | 3495 | struct snd_pcm_hw_params *params = NULL; |
| 3496 | struct snd_pcm_runtime *runtime = NULL; | ||
| 3496 | u64 fmt; | 3497 | u64 fmt; |
| 3497 | int ret; | 3498 | int ret; |
| 3498 | 3499 | ||
| @@ -3541,6 +3542,14 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, | |||
| 3541 | 3542 | ||
| 3542 | memset(&substream, 0, sizeof(substream)); | 3543 | memset(&substream, 0, sizeof(substream)); |
| 3543 | 3544 | ||
| 3545 | /* Allocate a dummy snd_pcm_runtime for startup() and other ops() */ | ||
| 3546 | runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); | ||
| 3547 | if (!runtime) { | ||
| 3548 | ret = -ENOMEM; | ||
| 3549 | goto out; | ||
| 3550 | } | ||
| 3551 | substream.runtime = runtime; | ||
| 3552 | |||
| 3544 | switch (event) { | 3553 | switch (event) { |
| 3545 | case SND_SOC_DAPM_PRE_PMU: | 3554 | case SND_SOC_DAPM_PRE_PMU: |
| 3546 | substream.stream = SNDRV_PCM_STREAM_CAPTURE; | 3555 | substream.stream = SNDRV_PCM_STREAM_CAPTURE; |
| @@ -3606,6 +3615,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, | |||
| 3606 | } | 3615 | } |
| 3607 | 3616 | ||
| 3608 | out: | 3617 | out: |
| 3618 | kfree(runtime); | ||
| 3609 | kfree(params); | 3619 | kfree(params); |
| 3610 | return ret; | 3620 | return ret; |
| 3611 | } | 3621 | } |
diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 204cc074adb9..41aa3355e920 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c | |||
| @@ -55,7 +55,6 @@ static int snd_line6_impulse_volume_put(struct snd_kcontrol *kcontrol, | |||
| 55 | err = line6_pcm_acquire(line6pcm, LINE6_STREAM_IMPULSE); | 55 | err = line6_pcm_acquire(line6pcm, LINE6_STREAM_IMPULSE); |
| 56 | if (err < 0) { | 56 | if (err < 0) { |
| 57 | line6pcm->impulse_volume = 0; | 57 | line6pcm->impulse_volume = 0; |
| 58 | line6_pcm_release(line6pcm, LINE6_STREAM_IMPULSE); | ||
| 59 | return err; | 58 | return err; |
| 60 | } | 59 | } |
| 61 | } else { | 60 | } else { |
| @@ -211,7 +210,9 @@ static void line6_stream_stop(struct snd_line6_pcm *line6pcm, int direction, | |||
| 211 | spin_lock_irqsave(&pstr->lock, flags); | 210 | spin_lock_irqsave(&pstr->lock, flags); |
| 212 | clear_bit(type, &pstr->running); | 211 | clear_bit(type, &pstr->running); |
| 213 | if (!pstr->running) { | 212 | if (!pstr->running) { |
| 213 | spin_unlock_irqrestore(&pstr->lock, flags); | ||
| 214 | line6_unlink_audio_urbs(line6pcm, pstr); | 214 | line6_unlink_audio_urbs(line6pcm, pstr); |
| 215 | spin_lock_irqsave(&pstr->lock, flags); | ||
| 215 | if (direction == SNDRV_PCM_STREAM_CAPTURE) { | 216 | if (direction == SNDRV_PCM_STREAM_CAPTURE) { |
| 216 | line6pcm->prev_fbuf = NULL; | 217 | line6pcm->prev_fbuf = NULL; |
| 217 | line6pcm->prev_fsize = 0; | 218 | line6pcm->prev_fsize = 0; |
diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index daf81d169a42..45dd34874f43 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c | |||
| @@ -244,8 +244,8 @@ static int pod_set_system_param_int(struct usb_line6_pod *pod, int value, | |||
| 244 | static ssize_t serial_number_show(struct device *dev, | 244 | static ssize_t serial_number_show(struct device *dev, |
| 245 | struct device_attribute *attr, char *buf) | 245 | struct device_attribute *attr, char *buf) |
| 246 | { | 246 | { |
| 247 | struct usb_interface *interface = to_usb_interface(dev); | 247 | struct snd_card *card = dev_to_snd_card(dev); |
| 248 | struct usb_line6_pod *pod = usb_get_intfdata(interface); | 248 | struct usb_line6_pod *pod = card->private_data; |
| 249 | 249 | ||
| 250 | return sprintf(buf, "%u\n", pod->serial_number); | 250 | return sprintf(buf, "%u\n", pod->serial_number); |
| 251 | } | 251 | } |
| @@ -256,8 +256,8 @@ static ssize_t serial_number_show(struct device *dev, | |||
| 256 | static ssize_t firmware_version_show(struct device *dev, | 256 | static ssize_t firmware_version_show(struct device *dev, |
| 257 | struct device_attribute *attr, char *buf) | 257 | struct device_attribute *attr, char *buf) |
| 258 | { | 258 | { |
| 259 | struct usb_interface *interface = to_usb_interface(dev); | 259 | struct snd_card *card = dev_to_snd_card(dev); |
| 260 | struct usb_line6_pod *pod = usb_get_intfdata(interface); | 260 | struct usb_line6_pod *pod = card->private_data; |
| 261 | 261 | ||
| 262 | return sprintf(buf, "%d.%02d\n", pod->firmware_version / 100, | 262 | return sprintf(buf, "%d.%02d\n", pod->firmware_version / 100, |
| 263 | pod->firmware_version % 100); | 263 | pod->firmware_version % 100); |
| @@ -269,8 +269,8 @@ static ssize_t firmware_version_show(struct device *dev, | |||
| 269 | static ssize_t device_id_show(struct device *dev, | 269 | static ssize_t device_id_show(struct device *dev, |
| 270 | struct device_attribute *attr, char *buf) | 270 | struct device_attribute *attr, char *buf) |
| 271 | { | 271 | { |
| 272 | struct usb_interface *interface = to_usb_interface(dev); | 272 | struct snd_card *card = dev_to_snd_card(dev); |
| 273 | struct usb_line6_pod *pod = usb_get_intfdata(interface); | 273 | struct usb_line6_pod *pod = card->private_data; |
| 274 | 274 | ||
| 275 | return sprintf(buf, "%d\n", pod->device_id); | 275 | return sprintf(buf, "%d\n", pod->device_id); |
| 276 | } | 276 | } |
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 6cf1f3597455..152292e5ee2b 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c | |||
| @@ -1141,6 +1141,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) | |||
| 1141 | case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */ | 1141 | case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */ |
| 1142 | case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */ | 1142 | case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */ |
| 1143 | case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ | 1143 | case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ |
| 1144 | case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */ | ||
| 1144 | case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */ | 1145 | case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */ |
| 1145 | case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */ | 1146 | case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */ |
| 1146 | case USB_ID(0x1de7, 0x0114): /* Phoenix Audio MT202pcs */ | 1147 | case USB_ID(0x1de7, 0x0114): /* Phoenix Audio MT202pcs */ |
diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c index 448ed96b3b4f..1c14c2595158 100644 --- a/tools/gpio/gpio-event-mon.c +++ b/tools/gpio/gpio-event-mon.c | |||
| @@ -1,5 +1,5 @@ | |||
| 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 | * Copyright (C) 2016 Linus Walleij | 4 | * Copyright (C) 2016 Linus Walleij |
| 5 | * | 5 | * |
diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c index 0e8a1f7a292d..f39c0e9c0d5c 100644 --- a/tools/iio/iio_generic_buffer.c +++ b/tools/iio/iio_generic_buffer.c | |||
| @@ -348,7 +348,7 @@ int main(int argc, char **argv) | |||
| 348 | int notrigger = 0; | 348 | int notrigger = 0; |
| 349 | char *dummy; | 349 | char *dummy; |
| 350 | 350 | ||
| 351 | struct iio_channel_info *channels; | 351 | struct iio_channel_info *channels = NULL; |
| 352 | 352 | ||
| 353 | register_cleanup(); | 353 | register_cleanup(); |
| 354 | 354 | ||
| @@ -456,7 +456,7 @@ int main(int argc, char **argv) | |||
| 456 | 456 | ||
| 457 | if (notrigger) { | 457 | if (notrigger) { |
| 458 | printf("trigger-less mode selected\n"); | 458 | printf("trigger-less mode selected\n"); |
| 459 | } if (trig_num >= 0) { | 459 | } else if (trig_num >= 0) { |
| 460 | char *trig_dev_name; | 460 | char *trig_dev_name; |
| 461 | ret = asprintf(&trig_dev_name, "%strigger%d", iio_dir, trig_num); | 461 | ret = asprintf(&trig_dev_name, "%strigger%d", iio_dir, trig_num); |
| 462 | if (ret < 0) { | 462 | if (ret < 0) { |
diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h index b96879477311..f436d2420a18 100644 --- a/tools/include/linux/string.h +++ b/tools/include/linux/string.h | |||
| @@ -8,7 +8,11 @@ void *memdup(const void *src, size_t len); | |||
| 8 | 8 | ||
| 9 | int strtobool(const char *s, bool *res); | 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 | extern size_t strlcpy(char *dest, const char *src, size_t size); | 16 | extern size_t strlcpy(char *dest, const char *src, size_t size); |
| 13 | #endif | 17 | #endif |
| 14 | 18 | ||
diff --git a/tools/lguest/lguest.c b/tools/lguest/lguest.c index d9836c5eb694..11c8d9bc762e 100644 --- a/tools/lguest/lguest.c +++ b/tools/lguest/lguest.c | |||
| @@ -3266,6 +3266,9 @@ int main(int argc, char *argv[]) | |||
| 3266 | } | 3266 | } |
| 3267 | } | 3267 | } |
| 3268 | 3268 | ||
| 3269 | /* If we exit via err(), this kills all the threads, restores tty. */ | ||
| 3270 | atexit(cleanup_devices); | ||
| 3271 | |||
| 3269 | /* We always have a console device, and it's always device 1. */ | 3272 | /* We always have a console device, and it's always device 1. */ |
| 3270 | setup_console(); | 3273 | setup_console(); |
| 3271 | 3274 | ||
| @@ -3369,9 +3372,6 @@ int main(int argc, char *argv[]) | |||
| 3369 | /* Ensure that we terminate if a device-servicing child dies. */ | 3372 | /* Ensure that we terminate if a device-servicing child dies. */ |
| 3370 | signal(SIGCHLD, kill_launcher); | 3373 | signal(SIGCHLD, kill_launcher); |
| 3371 | 3374 | ||
| 3372 | /* If we exit via err(), this kills all the threads, restores tty. */ | ||
| 3373 | atexit(cleanup_devices); | ||
| 3374 | |||
| 3375 | /* If requested, chroot to a directory */ | 3375 | /* If requested, chroot to a directory */ |
| 3376 | if (chroot_path) { | 3376 | if (chroot_path) { |
| 3377 | if (chroot(chroot_path) != 0) | 3377 | if (chroot(chroot_path) != 0) |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index d9b80ef881cd..21fd573106ed 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
| @@ -507,17 +507,17 @@ static int __perf_evsel__hw_cache_name(u64 config, char *bf, size_t size) | |||
| 507 | u8 op, result, type = (config >> 0) & 0xff; | 507 | u8 op, result, type = (config >> 0) & 0xff; |
| 508 | const char *err = "unknown-ext-hardware-cache-type"; | 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 | goto out_err; | 511 | goto out_err; |
| 512 | 512 | ||
| 513 | op = (config >> 8) & 0xff; | 513 | op = (config >> 8) & 0xff; |
| 514 | err = "unknown-ext-hardware-cache-op"; | 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 | goto out_err; | 516 | goto out_err; |
| 517 | 517 | ||
| 518 | result = (config >> 16) & 0xff; | 518 | result = (config >> 16) & 0xff; |
| 519 | err = "unknown-ext-hardware-cache-result"; | 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 | goto out_err; | 521 | goto out_err; |
| 522 | 522 | ||
| 523 | err = "invalid-cache"; | 523 | err = "invalid-cache"; |
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c index cf5e250bc78e..783a53fb7a4e 100644 --- a/tools/perf/util/unwind-libdw.c +++ b/tools/perf/util/unwind-libdw.c | |||
| @@ -66,7 +66,7 @@ static int entry(u64 ip, struct unwind_info *ui) | |||
| 66 | if (__report_module(&al, ip, ui)) | 66 | if (__report_module(&al, ip, ui)) |
| 67 | return -1; | 67 | return -1; |
| 68 | 68 | ||
| 69 | e->ip = ip; | 69 | e->ip = al.addr; |
| 70 | e->map = al.map; | 70 | e->map = al.map; |
| 71 | e->sym = al.sym; | 71 | e->sym = al.sym; |
| 72 | 72 | ||
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c index 97c0f8fc5561..20c2e5743903 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c | |||
| @@ -542,7 +542,7 @@ static int entry(u64 ip, struct thread *thread, | |||
| 542 | thread__find_addr_location(thread, PERF_RECORD_MISC_USER, | 542 | thread__find_addr_location(thread, PERF_RECORD_MISC_USER, |
| 543 | MAP__FUNCTION, ip, &al); | 543 | MAP__FUNCTION, ip, &al); |
| 544 | 544 | ||
| 545 | e.ip = ip; | 545 | e.ip = al.addr; |
| 546 | e.map = al.map; | 546 | e.map = al.map; |
| 547 | e.sym = al.sym; | 547 | e.sym = al.sym; |
| 548 | 548 | ||
diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 4fde8c7dfcfe..77e6ccf14901 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | static struct timecounter *timecounter; | 33 | static struct timecounter *timecounter; |
| 34 | static struct workqueue_struct *wqueue; | 34 | static struct workqueue_struct *wqueue; |
| 35 | static unsigned int host_vtimer_irq; | 35 | static unsigned int host_vtimer_irq; |
| 36 | static u32 host_vtimer_irq_flags; | ||
| 36 | 37 | ||
| 37 | void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu) | 38 | void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu) |
| 38 | { | 39 | { |
| @@ -365,7 +366,7 @@ void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu) | |||
| 365 | 366 | ||
| 366 | static void kvm_timer_init_interrupt(void *info) | 367 | static void kvm_timer_init_interrupt(void *info) |
| 367 | { | 368 | { |
| 368 | enable_percpu_irq(host_vtimer_irq, 0); | 369 | enable_percpu_irq(host_vtimer_irq, host_vtimer_irq_flags); |
| 369 | } | 370 | } |
| 370 | 371 | ||
| 371 | int kvm_arm_timer_set_reg(struct kvm_vcpu *vcpu, u64 regid, u64 value) | 372 | int kvm_arm_timer_set_reg(struct kvm_vcpu *vcpu, u64 regid, u64 value) |
| @@ -432,6 +433,14 @@ int kvm_timer_hyp_init(void) | |||
| 432 | } | 433 | } |
| 433 | host_vtimer_irq = info->virtual_irq; | 434 | host_vtimer_irq = info->virtual_irq; |
| 434 | 435 | ||
| 436 | host_vtimer_irq_flags = irq_get_trigger_type(host_vtimer_irq); | ||
| 437 | if (host_vtimer_irq_flags != IRQF_TRIGGER_HIGH && | ||
| 438 | host_vtimer_irq_flags != IRQF_TRIGGER_LOW) { | ||
| 439 | kvm_err("Invalid trigger for IRQ%d, assuming level low\n", | ||
| 440 | host_vtimer_irq); | ||
| 441 | host_vtimer_irq_flags = IRQF_TRIGGER_LOW; | ||
| 442 | } | ||
| 443 | |||
| 435 | err = request_percpu_irq(host_vtimer_irq, kvm_arch_timer_handler, | 444 | err = request_percpu_irq(host_vtimer_irq, kvm_arch_timer_handler, |
| 436 | "kvm guest timer", kvm_get_running_vcpus()); | 445 | "kvm guest timer", kvm_get_running_vcpus()); |
| 437 | if (err) { | 446 | if (err) { |
diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index 07411cf967b9..4660a7d04eea 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c | |||
| @@ -51,7 +51,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid) | |||
| 51 | 51 | ||
| 52 | irq = kzalloc(sizeof(struct vgic_irq), GFP_KERNEL); | 52 | irq = kzalloc(sizeof(struct vgic_irq), GFP_KERNEL); |
| 53 | if (!irq) | 53 | if (!irq) |
| 54 | return NULL; | 54 | return ERR_PTR(-ENOMEM); |
| 55 | 55 | ||
| 56 | INIT_LIST_HEAD(&irq->lpi_list); | 56 | INIT_LIST_HEAD(&irq->lpi_list); |
| 57 | INIT_LIST_HEAD(&irq->ap_list); | 57 | INIT_LIST_HEAD(&irq->ap_list); |
| @@ -441,39 +441,63 @@ static unsigned long vgic_mmio_read_its_idregs(struct kvm *kvm, | |||
| 441 | * Find the target VCPU and the LPI number for a given devid/eventid pair | 441 | * Find the target VCPU and the LPI number for a given devid/eventid pair |
| 442 | * and make this IRQ pending, possibly injecting it. | 442 | * and make this IRQ pending, possibly injecting it. |
| 443 | * Must be called with the its_lock mutex held. | 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, | 447 | static int vgic_its_trigger_msi(struct kvm *kvm, struct vgic_its *its, |
| 446 | u32 devid, u32 eventid) | 448 | u32 devid, u32 eventid) |
| 447 | { | 449 | { |
| 450 | struct kvm_vcpu *vcpu; | ||
| 448 | struct its_itte *itte; | 451 | struct its_itte *itte; |
| 449 | 452 | ||
| 450 | if (!its->enabled) | 453 | if (!its->enabled) |
| 451 | return; | 454 | return -EBUSY; |
| 452 | 455 | ||
| 453 | itte = find_itte(its, devid, eventid); | 456 | itte = find_itte(its, devid, eventid); |
| 454 | /* Triggering an unmapped IRQ gets silently dropped. */ | 457 | if (!itte || !its_is_collection_mapped(itte->collection)) |
| 455 | if (itte && its_is_collection_mapped(itte->collection)) { | 458 | return E_ITS_INT_UNMAPPED_INTERRUPT; |
| 456 | struct kvm_vcpu *vcpu; | 459 | |
| 457 | 460 | vcpu = kvm_get_vcpu(kvm, itte->collection->target_addr); | |
| 458 | vcpu = kvm_get_vcpu(kvm, itte->collection->target_addr); | 461 | if (!vcpu) |
| 459 | if (vcpu && vcpu->arch.vgic_cpu.lpis_enabled) { | 462 | return E_ITS_INT_UNMAPPED_INTERRUPT; |
| 460 | spin_lock(&itte->irq->irq_lock); | 463 | |
| 461 | itte->irq->pending = true; | 464 | if (!vcpu->arch.vgic_cpu.lpis_enabled) |
| 462 | vgic_queue_irq_unlock(kvm, itte->irq); | 465 | return -EBUSY; |
| 463 | } | 466 | |
| 464 | } | 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 | * Queries the KVM IO bus framework to get the ITS pointer from the given | 490 | * Queries the KVM IO bus framework to get the ITS pointer from the given |
| 469 | * doorbell address. | 491 | * doorbell address. |
| 470 | * We then call vgic_its_trigger_msi() with the decoded data. | 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 | int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi) | 495 | int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi) |
| 473 | { | 496 | { |
| 474 | u64 address; | 497 | u64 address; |
| 475 | struct kvm_io_device *kvm_io_dev; | 498 | struct kvm_io_device *kvm_io_dev; |
| 476 | struct vgic_io_device *iodev; | 499 | struct vgic_io_device *iodev; |
| 500 | int ret; | ||
| 477 | 501 | ||
| 478 | if (!vgic_has_its(kvm)) | 502 | if (!vgic_has_its(kvm)) |
| 479 | return -ENODEV; | 503 | return -ENODEV; |
| @@ -485,15 +509,28 @@ int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi) | |||
| 485 | 509 | ||
| 486 | kvm_io_dev = kvm_io_bus_get_dev(kvm, KVM_MMIO_BUS, address); | 510 | kvm_io_dev = kvm_io_bus_get_dev(kvm, KVM_MMIO_BUS, address); |
| 487 | if (!kvm_io_dev) | 511 | if (!kvm_io_dev) |
| 488 | return -ENODEV; | 512 | return -EINVAL; |
| 489 | 513 | ||
| 490 | iodev = container_of(kvm_io_dev, struct vgic_io_device, dev); | 514 | iodev = vgic_get_its_iodev(kvm_io_dev); |
| 515 | if (!iodev) | ||
| 516 | return -EINVAL; | ||
| 491 | 517 | ||
| 492 | mutex_lock(&iodev->its->its_lock); | 518 | mutex_lock(&iodev->its->its_lock); |
| 493 | vgic_its_trigger_msi(kvm, iodev->its, msi->devid, msi->data); | 519 | ret = vgic_its_trigger_msi(kvm, iodev->its, msi->devid, msi->data); |
| 494 | mutex_unlock(&iodev->its->its_lock); | 520 | mutex_unlock(&iodev->its->its_lock); |
| 495 | 521 | ||
| 496 | return 0; | 522 | if (ret < 0) |
| 523 | return ret; | ||
| 524 | |||
| 525 | /* | ||
| 526 | * KVM_SIGNAL_MSI demands a return value > 0 for success and 0 | ||
| 527 | * if the guest has blocked the MSI. So we map any LPI mapping | ||
| 528 | * related error to that. | ||
| 529 | */ | ||
| 530 | if (ret) | ||
| 531 | return 0; | ||
| 532 | else | ||
| 533 | return 1; | ||
| 497 | } | 534 | } |
| 498 | 535 | ||
| 499 | /* Requires the its_lock to be held. */ | 536 | /* Requires the its_lock to be held. */ |
| @@ -502,7 +539,8 @@ static void its_free_itte(struct kvm *kvm, struct its_itte *itte) | |||
| 502 | list_del(&itte->itte_list); | 539 | list_del(&itte->itte_list); |
| 503 | 540 | ||
| 504 | /* This put matches the get in vgic_add_lpi. */ | 541 | /* This put matches the get in vgic_add_lpi. */ |
| 505 | vgic_put_irq(kvm, itte->irq); | 542 | if (itte->irq) |
| 543 | vgic_put_irq(kvm, itte->irq); | ||
| 506 | 544 | ||
| 507 | kfree(itte); | 545 | kfree(itte); |
| 508 | } | 546 | } |
| @@ -697,6 +735,7 @@ static int vgic_its_cmd_handle_mapi(struct kvm *kvm, struct vgic_its *its, | |||
| 697 | struct its_device *device; | 735 | struct its_device *device; |
| 698 | struct its_collection *collection, *new_coll = NULL; | 736 | struct its_collection *collection, *new_coll = NULL; |
| 699 | int lpi_nr; | 737 | int lpi_nr; |
| 738 | struct vgic_irq *irq; | ||
| 700 | 739 | ||
| 701 | device = find_its_device(its, device_id); | 740 | device = find_its_device(its, device_id); |
| 702 | if (!device) | 741 | if (!device) |
| @@ -710,6 +749,10 @@ static int vgic_its_cmd_handle_mapi(struct kvm *kvm, struct vgic_its *its, | |||
| 710 | lpi_nr >= max_lpis_propbaser(kvm->arch.vgic.propbaser)) | 749 | lpi_nr >= max_lpis_propbaser(kvm->arch.vgic.propbaser)) |
| 711 | return E_ITS_MAPTI_PHYSICALID_OOR; | 750 | return E_ITS_MAPTI_PHYSICALID_OOR; |
| 712 | 751 | ||
| 752 | /* If there is an existing mapping, behavior is UNPREDICTABLE. */ | ||
| 753 | if (find_itte(its, device_id, event_id)) | ||
| 754 | return 0; | ||
| 755 | |||
| 713 | collection = find_collection(its, coll_id); | 756 | collection = find_collection(its, coll_id); |
| 714 | if (!collection) { | 757 | if (!collection) { |
| 715 | int ret = vgic_its_alloc_collection(its, &collection, coll_id); | 758 | int ret = vgic_its_alloc_collection(its, &collection, coll_id); |
| @@ -718,22 +761,28 @@ static int vgic_its_cmd_handle_mapi(struct kvm *kvm, struct vgic_its *its, | |||
| 718 | new_coll = collection; | 761 | new_coll = collection; |
| 719 | } | 762 | } |
| 720 | 763 | ||
| 721 | itte = find_itte(its, device_id, event_id); | 764 | itte = kzalloc(sizeof(struct its_itte), GFP_KERNEL); |
| 722 | if (!itte) { | 765 | if (!itte) { |
| 723 | itte = kzalloc(sizeof(struct its_itte), GFP_KERNEL); | 766 | if (new_coll) |
| 724 | if (!itte) { | 767 | vgic_its_free_collection(its, coll_id); |
| 725 | if (new_coll) | 768 | return -ENOMEM; |
| 726 | vgic_its_free_collection(its, coll_id); | ||
| 727 | return -ENOMEM; | ||
| 728 | } | ||
| 729 | |||
| 730 | itte->event_id = event_id; | ||
| 731 | list_add_tail(&itte->itte_list, &device->itt_head); | ||
| 732 | } | 769 | } |
| 733 | 770 | ||
| 771 | itte->event_id = event_id; | ||
| 772 | list_add_tail(&itte->itte_list, &device->itt_head); | ||
| 773 | |||
| 734 | itte->collection = collection; | 774 | itte->collection = collection; |
| 735 | itte->lpi = lpi_nr; | 775 | itte->lpi = lpi_nr; |
| 736 | itte->irq = vgic_add_lpi(kvm, lpi_nr); | 776 | |
| 777 | irq = vgic_add_lpi(kvm, lpi_nr); | ||
| 778 | if (IS_ERR(irq)) { | ||
| 779 | if (new_coll) | ||
| 780 | vgic_its_free_collection(its, coll_id); | ||
| 781 | its_free_itte(kvm, itte); | ||
| 782 | return PTR_ERR(irq); | ||
| 783 | } | ||
| 784 | itte->irq = irq; | ||
| 785 | |||
| 737 | update_affinity_itte(kvm, itte); | 786 | update_affinity_itte(kvm, itte); |
| 738 | 787 | ||
| 739 | /* | 788 | /* |
| @@ -981,9 +1030,7 @@ static int vgic_its_cmd_handle_int(struct kvm *kvm, struct vgic_its *its, | |||
| 981 | u32 msi_data = its_cmd_get_id(its_cmd); | 1030 | u32 msi_data = its_cmd_get_id(its_cmd); |
| 982 | u64 msi_devid = its_cmd_get_deviceid(its_cmd); | 1031 | u64 msi_devid = its_cmd_get_deviceid(its_cmd); |
| 983 | 1032 | ||
| 984 | vgic_its_trigger_msi(kvm, its, msi_devid, msi_data); | 1033 | return vgic_its_trigger_msi(kvm, its, msi_devid, msi_data); |
| 985 | |||
| 986 | return 0; | ||
| 987 | } | 1034 | } |
| 988 | 1035 | ||
| 989 | /* | 1036 | /* |
| @@ -1288,13 +1335,13 @@ void vgic_enable_lpis(struct kvm_vcpu *vcpu) | |||
| 1288 | its_sync_lpi_pending_table(vcpu); | 1335 | its_sync_lpi_pending_table(vcpu); |
| 1289 | } | 1336 | } |
| 1290 | 1337 | ||
| 1291 | static int vgic_its_init_its(struct kvm *kvm, struct vgic_its *its) | 1338 | static int vgic_register_its_iodev(struct kvm *kvm, struct vgic_its *its) |
| 1292 | { | 1339 | { |
| 1293 | struct vgic_io_device *iodev = &its->iodev; | 1340 | struct vgic_io_device *iodev = &its->iodev; |
| 1294 | int ret; | 1341 | int ret; |
| 1295 | 1342 | ||
| 1296 | if (its->initialized) | 1343 | if (!its->initialized) |
| 1297 | return 0; | 1344 | return -EBUSY; |
| 1298 | 1345 | ||
| 1299 | if (IS_VGIC_ADDR_UNDEF(its->vgic_its_base)) | 1346 | if (IS_VGIC_ADDR_UNDEF(its->vgic_its_base)) |
| 1300 | return -ENXIO; | 1347 | return -ENXIO; |
| @@ -1311,9 +1358,6 @@ static int vgic_its_init_its(struct kvm *kvm, struct vgic_its *its) | |||
| 1311 | KVM_VGIC_V3_ITS_SIZE, &iodev->dev); | 1358 | KVM_VGIC_V3_ITS_SIZE, &iodev->dev); |
| 1312 | mutex_unlock(&kvm->slots_lock); | 1359 | mutex_unlock(&kvm->slots_lock); |
| 1313 | 1360 | ||
| 1314 | if (!ret) | ||
| 1315 | its->initialized = true; | ||
| 1316 | |||
| 1317 | return ret; | 1361 | return ret; |
| 1318 | } | 1362 | } |
| 1319 | 1363 | ||
| @@ -1435,9 +1479,6 @@ static int vgic_its_set_attr(struct kvm_device *dev, | |||
| 1435 | if (type != KVM_VGIC_ITS_ADDR_TYPE) | 1479 | if (type != KVM_VGIC_ITS_ADDR_TYPE) |
| 1436 | return -ENODEV; | 1480 | return -ENODEV; |
| 1437 | 1481 | ||
| 1438 | if (its->initialized) | ||
| 1439 | return -EBUSY; | ||
| 1440 | |||
| 1441 | if (copy_from_user(&addr, uaddr, sizeof(addr))) | 1482 | if (copy_from_user(&addr, uaddr, sizeof(addr))) |
| 1442 | return -EFAULT; | 1483 | return -EFAULT; |
| 1443 | 1484 | ||
| @@ -1453,7 +1494,9 @@ static int vgic_its_set_attr(struct kvm_device *dev, | |||
| 1453 | case KVM_DEV_ARM_VGIC_GRP_CTRL: | 1494 | case KVM_DEV_ARM_VGIC_GRP_CTRL: |
| 1454 | switch (attr->attr) { | 1495 | switch (attr->attr) { |
| 1455 | case KVM_DEV_ARM_VGIC_CTRL_INIT: | 1496 | case KVM_DEV_ARM_VGIC_CTRL_INIT: |
| 1456 | return vgic_its_init_its(dev->kvm, its); | 1497 | its->initialized = true; |
| 1498 | |||
| 1499 | return 0; | ||
| 1457 | } | 1500 | } |
| 1458 | break; | 1501 | break; |
| 1459 | } | 1502 | } |
| @@ -1498,3 +1541,30 @@ int kvm_vgic_register_its_device(void) | |||
| 1498 | return kvm_register_device_ops(&kvm_arm_vgic_its_ops, | 1541 | return kvm_register_device_ops(&kvm_arm_vgic_its_ops, |
| 1499 | KVM_DEV_TYPE_ARM_VGIC_ITS); | 1542 | KVM_DEV_TYPE_ARM_VGIC_ITS); |
| 1500 | } | 1543 | } |
| 1544 | |||
| 1545 | /* | ||
| 1546 | * Registers all ITSes with the kvm_io_bus framework. | ||
| 1547 | * To follow the existing VGIC initialization sequence, this has to be | ||
| 1548 | * done as late as possible, just before the first VCPU runs. | ||
| 1549 | */ | ||
| 1550 | int vgic_register_its_iodevs(struct kvm *kvm) | ||
| 1551 | { | ||
| 1552 | struct kvm_device *dev; | ||
| 1553 | int ret = 0; | ||
| 1554 | |||
| 1555 | list_for_each_entry(dev, &kvm->devices, vm_node) { | ||
| 1556 | if (dev->ops != &kvm_arm_vgic_its_ops) | ||
| 1557 | continue; | ||
| 1558 | |||
| 1559 | ret = vgic_register_its_iodev(kvm, dev->private); | ||
| 1560 | if (ret) | ||
| 1561 | return ret; | ||
| 1562 | /* | ||
| 1563 | * We don't need to care about tearing down previously | ||
| 1564 | * registered ITSes, as the kvm_io_bus framework removes | ||
| 1565 | * them for us if the VM gets destroyed. | ||
| 1566 | */ | ||
| 1567 | } | ||
| 1568 | |||
| 1569 | return ret; | ||
| 1570 | } | ||
diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c index ff668e0dd586..90d81811fdda 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c | |||
| @@ -306,16 +306,19 @@ static void vgic_mmio_write_propbase(struct kvm_vcpu *vcpu, | |||
| 306 | { | 306 | { |
| 307 | struct vgic_dist *dist = &vcpu->kvm->arch.vgic; | 307 | struct vgic_dist *dist = &vcpu->kvm->arch.vgic; |
| 308 | struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; | 308 | struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; |
| 309 | u64 propbaser = dist->propbaser; | 309 | u64 old_propbaser, propbaser; |
| 310 | 310 | ||
| 311 | /* Storing a value with LPIs already enabled is undefined */ | 311 | /* Storing a value with LPIs already enabled is undefined */ |
| 312 | if (vgic_cpu->lpis_enabled) | 312 | if (vgic_cpu->lpis_enabled) |
| 313 | return; | 313 | return; |
| 314 | 314 | ||
| 315 | propbaser = update_64bit_reg(propbaser, addr & 4, len, val); | 315 | do { |
| 316 | propbaser = vgic_sanitise_propbaser(propbaser); | 316 | old_propbaser = dist->propbaser; |
| 317 | 317 | propbaser = old_propbaser; | |
| 318 | dist->propbaser = 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 | static unsigned long vgic_mmio_read_pendbase(struct kvm_vcpu *vcpu, | 324 | static unsigned long vgic_mmio_read_pendbase(struct kvm_vcpu *vcpu, |
| @@ -331,16 +334,19 @@ static void vgic_mmio_write_pendbase(struct kvm_vcpu *vcpu, | |||
| 331 | unsigned long val) | 334 | unsigned long val) |
| 332 | { | 335 | { |
| 333 | struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; | 336 | struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; |
| 334 | u64 pendbaser = vgic_cpu->pendbaser; | 337 | u64 old_pendbaser, pendbaser; |
| 335 | 338 | ||
| 336 | /* Storing a value with LPIs already enabled is undefined */ | 339 | /* Storing a value with LPIs already enabled is undefined */ |
| 337 | if (vgic_cpu->lpis_enabled) | 340 | if (vgic_cpu->lpis_enabled) |
| 338 | return; | 341 | return; |
| 339 | 342 | ||
| 340 | pendbaser = update_64bit_reg(pendbaser, addr & 4, len, val); | 343 | do { |
| 341 | pendbaser = vgic_sanitise_pendbaser(pendbaser); | 344 | old_pendbaser = vgic_cpu->pendbaser; |
| 342 | 345 | pendbaser = old_pendbaser; | |
| 343 | vgic_cpu->pendbaser = pendbaser; | 346 | pendbaser = update_64bit_reg(pendbaser, addr & 4, len, val); |
| 347 | pendbaser = vgic_sanitise_pendbaser(pendbaser); | ||
| 348 | } while (cmpxchg64(&vgic_cpu->pendbaser, old_pendbaser, | ||
| 349 | pendbaser) != old_pendbaser); | ||
| 344 | } | 350 | } |
| 345 | 351 | ||
| 346 | /* | 352 | /* |
diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c index 0506543df38a..9f0dae397d9c 100644 --- a/virt/kvm/arm/vgic/vgic-v3.c +++ b/virt/kvm/arm/vgic/vgic-v3.c | |||
| @@ -289,6 +289,14 @@ int vgic_v3_map_resources(struct kvm *kvm) | |||
| 289 | goto out; | 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 | dist->ready = true; | 300 | dist->ready = true; |
| 293 | 301 | ||
| 294 | out: | 302 | out: |
diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index e7aeac719e09..e83b7fe4baae 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c | |||
| @@ -117,17 +117,17 @@ static void vgic_irq_release(struct kref *ref) | |||
| 117 | 117 | ||
| 118 | void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq) | 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 | if (irq->intid < VGIC_MIN_LPI) | 122 | if (irq->intid < VGIC_MIN_LPI) |
| 123 | return; | 123 | return; |
| 124 | 124 | ||
| 125 | if (!kref_put(&irq->refcount, vgic_irq_release)) | 125 | spin_lock(&dist->lpi_list_lock); |
| 126 | if (!kref_put(&irq->refcount, vgic_irq_release)) { | ||
| 127 | spin_unlock(&dist->lpi_list_lock); | ||
| 126 | return; | 128 | return; |
| 129 | }; | ||
| 127 | 130 | ||
| 128 | dist = &kvm->arch.vgic; | ||
| 129 | |||
| 130 | spin_lock(&dist->lpi_list_lock); | ||
| 131 | list_del(&irq->lpi_list); | 131 | list_del(&irq->lpi_list); |
| 132 | dist->lpi_list_count--; | 132 | dist->lpi_list_count--; |
| 133 | spin_unlock(&dist->lpi_list_lock); | 133 | spin_unlock(&dist->lpi_list_lock); |
diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h index 1d8e21d5c13f..6c4625c46368 100644 --- a/virt/kvm/arm/vgic/vgic.h +++ b/virt/kvm/arm/vgic/vgic.h | |||
| @@ -84,6 +84,7 @@ void vgic_v3_enable(struct kvm_vcpu *vcpu); | |||
| 84 | int vgic_v3_probe(const struct gic_kvm_info *info); | 84 | int vgic_v3_probe(const struct gic_kvm_info *info); |
| 85 | int vgic_v3_map_resources(struct kvm *kvm); | 85 | int vgic_v3_map_resources(struct kvm *kvm); |
| 86 | int vgic_register_redist_iodevs(struct kvm *kvm, gpa_t dist_base_address); | 86 | int vgic_register_redist_iodevs(struct kvm *kvm, gpa_t dist_base_address); |
| 87 | int vgic_register_its_iodevs(struct kvm *kvm); | ||
| 87 | bool vgic_has_its(struct kvm *kvm); | 88 | bool vgic_has_its(struct kvm *kvm); |
| 88 | int kvm_vgic_register_its_device(void); | 89 | int kvm_vgic_register_its_device(void); |
| 89 | void vgic_enable_lpis(struct kvm_vcpu *vcpu); | 90 | void vgic_enable_lpis(struct kvm_vcpu *vcpu); |
| @@ -140,6 +141,11 @@ static inline int vgic_register_redist_iodevs(struct kvm *kvm, | |||
| 140 | return -ENODEV; | 141 | return -ENODEV; |
| 141 | } | 142 | } |
| 142 | 143 | ||
| 144 | static inline int vgic_register_its_iodevs(struct kvm *kvm) | ||
| 145 | { | ||
| 146 | return -ENODEV; | ||
| 147 | } | ||
| 148 | |||
| 143 | static inline bool vgic_has_its(struct kvm *kvm) | 149 | static inline bool vgic_has_its(struct kvm *kvm) |
| 144 | { | 150 | { |
| 145 | return false; | 151 | return false; |
