logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>

4.14.341-openela.patch (488475B)


  1. SPDX-FileCopyrightText: 1991-2024 kernel.org contributors
  2. SPDX-FileCopyrightText: 2023-2024 Open Enterprise Linux Association <kernel-lts@openela.org>
  3. SPDX-License-Identifier: GPL-2.0-only
  4. Patch kernel up to 4.14.341-openela
  5. diff --git Documentation/ABI/testing/sysfs-class-net-queues Documentation/ABI/testing/sysfs-class-net-queues
  6. index 0c0df91b1516..2734cd9ee43c 100644
  7. --- linux-4.14.336/Documentation/ABI/testing/sysfs-class-net-queues
  8. +++ linux-4.14.336/Documentation/ABI/testing/sysfs-class-net-queues
  9. @@ -1,4 +1,4 @@
  10. -What: /sys/class/<iface>/queues/rx-<queue>/rps_cpus
  11. +What: /sys/class/net/<iface>/queues/rx-<queue>/rps_cpus
  12. Date: March 2010
  13. KernelVersion: 2.6.35
  14. Contact: netdev@vger.kernel.org
  15. @@ -8,7 +8,7 @@ Description:
  16. network device queue. Possible values depend on the number
  17. of available CPU(s) in the system.
  18. -What: /sys/class/<iface>/queues/rx-<queue>/rps_flow_cnt
  19. +What: /sys/class/net/<iface>/queues/rx-<queue>/rps_flow_cnt
  20. Date: April 2010
  21. KernelVersion: 2.6.35
  22. Contact: netdev@vger.kernel.org
  23. @@ -16,7 +16,7 @@ Description:
  24. Number of Receive Packet Steering flows being currently
  25. processed by this particular network device receive queue.
  26. -What: /sys/class/<iface>/queues/tx-<queue>/tx_timeout
  27. +What: /sys/class/net/<iface>/queues/tx-<queue>/tx_timeout
  28. Date: November 2011
  29. KernelVersion: 3.3
  30. Contact: netdev@vger.kernel.org
  31. @@ -24,7 +24,7 @@ Description:
  32. Indicates the number of transmit timeout events seen by this
  33. network interface transmit queue.
  34. -What: /sys/class/<iface>/queues/tx-<queue>/tx_maxrate
  35. +What: /sys/class/net/<iface>/queues/tx-<queue>/tx_maxrate
  36. Date: March 2015
  37. KernelVersion: 4.1
  38. Contact: netdev@vger.kernel.org
  39. @@ -32,7 +32,7 @@ Description:
  40. A Mbps max-rate set for the queue, a value of zero means disabled,
  41. default is disabled.
  42. -What: /sys/class/<iface>/queues/tx-<queue>/xps_cpus
  43. +What: /sys/class/net/<iface>/queues/tx-<queue>/xps_cpus
  44. Date: November 2010
  45. KernelVersion: 2.6.38
  46. Contact: netdev@vger.kernel.org
  47. @@ -42,7 +42,7 @@ Description:
  48. network device transmit queue. Possible vaules depend on the
  49. number of available CPU(s) in the system.
  50. -What: /sys/class/<iface>/queues/tx-<queue>/byte_queue_limits/hold_time
  51. +What: /sys/class/net/<iface>/queues/tx-<queue>/byte_queue_limits/hold_time
  52. Date: November 2011
  53. KernelVersion: 3.3
  54. Contact: netdev@vger.kernel.org
  55. @@ -51,7 +51,7 @@ Description:
  56. of this particular network device transmit queue.
  57. Default value is 1000.
  58. -What: /sys/class/<iface>/queues/tx-<queue>/byte_queue_limits/inflight
  59. +What: /sys/class/net/<iface>/queues/tx-<queue>/byte_queue_limits/inflight
  60. Date: November 2011
  61. KernelVersion: 3.3
  62. Contact: netdev@vger.kernel.org
  63. @@ -59,7 +59,7 @@ Description:
  64. Indicates the number of bytes (objects) in flight on this
  65. network device transmit queue.
  66. -What: /sys/class/<iface>/queues/tx-<queue>/byte_queue_limits/limit
  67. +What: /sys/class/net/<iface>/queues/tx-<queue>/byte_queue_limits/limit
  68. Date: November 2011
  69. KernelVersion: 3.3
  70. Contact: netdev@vger.kernel.org
  71. @@ -68,7 +68,7 @@ Description:
  72. on this network device transmit queue. This value is clamped
  73. to be within the bounds defined by limit_max and limit_min.
  74. -What: /sys/class/<iface>/queues/tx-<queue>/byte_queue_limits/limit_max
  75. +What: /sys/class/net/<iface>/queues/tx-<queue>/byte_queue_limits/limit_max
  76. Date: November 2011
  77. KernelVersion: 3.3
  78. Contact: netdev@vger.kernel.org
  79. @@ -77,7 +77,7 @@ Description:
  80. queued on this network device transmit queue. See
  81. include/linux/dynamic_queue_limits.h for the default value.
  82. -What: /sys/class/<iface>/queues/tx-<queue>/byte_queue_limits/limit_min
  83. +What: /sys/class/net/<iface>/queues/tx-<queue>/byte_queue_limits/limit_min
  84. Date: November 2011
  85. KernelVersion: 3.3
  86. Contact: netdev@vger.kernel.org
  87. diff --git Documentation/ABI/testing/sysfs-class-net-statistics Documentation/ABI/testing/sysfs-class-net-statistics
  88. index 397118de7b5e..53e508c6936a 100644
  89. --- linux-4.14.336/Documentation/ABI/testing/sysfs-class-net-statistics
  90. +++ linux-4.14.336/Documentation/ABI/testing/sysfs-class-net-statistics
  91. @@ -1,4 +1,4 @@
  92. -What: /sys/class/<iface>/statistics/collisions
  93. +What: /sys/class/net/<iface>/statistics/collisions
  94. Date: April 2005
  95. KernelVersion: 2.6.12
  96. Contact: netdev@vger.kernel.org
  97. @@ -6,7 +6,7 @@ Description:
  98. Indicates the number of collisions seen by this network device.
  99. This value might not be relevant with all MAC layers.
  100. -What: /sys/class/<iface>/statistics/multicast
  101. +What: /sys/class/net/<iface>/statistics/multicast
  102. Date: April 2005
  103. KernelVersion: 2.6.12
  104. Contact: netdev@vger.kernel.org
  105. @@ -14,7 +14,7 @@ Description:
  106. Indicates the number of multicast packets received by this
  107. network device.
  108. -What: /sys/class/<iface>/statistics/rx_bytes
  109. +What: /sys/class/net/<iface>/statistics/rx_bytes
  110. Date: April 2005
  111. KernelVersion: 2.6.12
  112. Contact: netdev@vger.kernel.org
  113. @@ -23,7 +23,7 @@ Description:
  114. See the network driver for the exact meaning of when this
  115. value is incremented.
  116. -What: /sys/class/<iface>/statistics/rx_compressed
  117. +What: /sys/class/net/<iface>/statistics/rx_compressed
  118. Date: April 2005
  119. KernelVersion: 2.6.12
  120. Contact: netdev@vger.kernel.org
  121. @@ -32,7 +32,7 @@ Description:
  122. network device. This value might only be relevant for interfaces
  123. that support packet compression (e.g: PPP).
  124. -What: /sys/class/<iface>/statistics/rx_crc_errors
  125. +What: /sys/class/net/<iface>/statistics/rx_crc_errors
  126. Date: April 2005
  127. KernelVersion: 2.6.12
  128. Contact: netdev@vger.kernel.org
  129. @@ -41,7 +41,7 @@ Description:
  130. by this network device. Note that the specific meaning might
  131. depend on the MAC layer used by the interface.
  132. -What: /sys/class/<iface>/statistics/rx_dropped
  133. +What: /sys/class/net/<iface>/statistics/rx_dropped
  134. Date: April 2005
  135. KernelVersion: 2.6.12
  136. Contact: netdev@vger.kernel.org
  137. @@ -51,7 +51,15 @@ Description:
  138. packet processing. See the network driver for the exact
  139. meaning of this value.
  140. -What: /sys/class/<iface>/statistics/rx_fifo_errors
  141. +What: /sys/class/net/<iface>/statistics/rx_errors
  142. +Date: April 2005
  143. +KernelVersion: 2.6.12
  144. +Contact: netdev@vger.kernel.org
  145. +Description:
  146. + Indicates the number of receive errors on this network device.
  147. + See the network driver for the exact meaning of this value.
  148. +
  149. +What: /sys/class/net/<iface>/statistics/rx_fifo_errors
  150. Date: April 2005
  151. KernelVersion: 2.6.12
  152. Contact: netdev@vger.kernel.org
  153. @@ -60,7 +68,7 @@ Description:
  154. network device. See the network driver for the exact
  155. meaning of this value.
  156. -What: /sys/class/<iface>/statistics/rx_frame_errors
  157. +What: /sys/class/net/<iface>/statistics/rx_frame_errors
  158. Date: April 2005
  159. KernelVersion: 2.6.12
  160. Contact: netdev@vger.kernel.org
  161. @@ -70,7 +78,7 @@ Description:
  162. on the MAC layer protocol used. See the network driver for
  163. the exact meaning of this value.
  164. -What: /sys/class/<iface>/statistics/rx_length_errors
  165. +What: /sys/class/net/<iface>/statistics/rx_length_errors
  166. Date: April 2005
  167. KernelVersion: 2.6.12
  168. Contact: netdev@vger.kernel.org
  169. @@ -79,7 +87,7 @@ Description:
  170. error, oversized or undersized. See the network driver for the
  171. exact meaning of this value.
  172. -What: /sys/class/<iface>/statistics/rx_missed_errors
  173. +What: /sys/class/net/<iface>/statistics/rx_missed_errors
  174. Date: April 2005
  175. KernelVersion: 2.6.12
  176. Contact: netdev@vger.kernel.org
  177. @@ -88,7 +96,15 @@ Description:
  178. due to lack of capacity in the receive side. See the network
  179. driver for the exact meaning of this value.
  180. -What: /sys/class/<iface>/statistics/rx_over_errors
  181. +What: /sys/class/net/<iface>/statistics/rx_nohandler
  182. +Date: February 2016
  183. +KernelVersion: 4.6
  184. +Contact: netdev@vger.kernel.org
  185. +Description:
  186. + Indicates the number of received packets that were dropped on
  187. + an inactive device by the network core.
  188. +
  189. +What: /sys/class/net/<iface>/statistics/rx_over_errors
  190. Date: April 2005
  191. KernelVersion: 2.6.12
  192. Contact: netdev@vger.kernel.org
  193. @@ -98,7 +114,7 @@ Description:
  194. (e.g: larger than MTU). See the network driver for the exact
  195. meaning of this value.
  196. -What: /sys/class/<iface>/statistics/rx_packets
  197. +What: /sys/class/net/<iface>/statistics/rx_packets
  198. Date: April 2005
  199. KernelVersion: 2.6.12
  200. Contact: netdev@vger.kernel.org
  201. @@ -106,7 +122,7 @@ Description:
  202. Indicates the total number of good packets received by this
  203. network device.
  204. -What: /sys/class/<iface>/statistics/tx_aborted_errors
  205. +What: /sys/class/net/<iface>/statistics/tx_aborted_errors
  206. Date: April 2005
  207. KernelVersion: 2.6.12
  208. Contact: netdev@vger.kernel.org
  209. @@ -116,7 +132,7 @@ Description:
  210. a medium collision). See the network driver for the exact
  211. meaning of this value.
  212. -What: /sys/class/<iface>/statistics/tx_bytes
  213. +What: /sys/class/net/<iface>/statistics/tx_bytes
  214. Date: April 2005
  215. KernelVersion: 2.6.12
  216. Contact: netdev@vger.kernel.org
  217. @@ -127,7 +143,7 @@ Description:
  218. transmitted packets or all packets that have been queued for
  219. transmission.
  220. -What: /sys/class/<iface>/statistics/tx_carrier_errors
  221. +What: /sys/class/net/<iface>/statistics/tx_carrier_errors
  222. Date: April 2005
  223. KernelVersion: 2.6.12
  224. Contact: netdev@vger.kernel.org
  225. @@ -136,7 +152,7 @@ Description:
  226. because of carrier errors (e.g: physical link down). See the
  227. network driver for the exact meaning of this value.
  228. -What: /sys/class/<iface>/statistics/tx_compressed
  229. +What: /sys/class/net/<iface>/statistics/tx_compressed
  230. Date: April 2005
  231. KernelVersion: 2.6.12
  232. Contact: netdev@vger.kernel.org
  233. @@ -145,7 +161,7 @@ Description:
  234. this might only be relevant for devices that support
  235. compression (e.g: PPP).
  236. -What: /sys/class/<iface>/statistics/tx_dropped
  237. +What: /sys/class/net/<iface>/statistics/tx_dropped
  238. Date: April 2005
  239. KernelVersion: 2.6.12
  240. Contact: netdev@vger.kernel.org
  241. @@ -154,7 +170,7 @@ Description:
  242. See the driver for the exact reasons as to why the packets were
  243. dropped.
  244. -What: /sys/class/<iface>/statistics/tx_errors
  245. +What: /sys/class/net/<iface>/statistics/tx_errors
  246. Date: April 2005
  247. KernelVersion: 2.6.12
  248. Contact: netdev@vger.kernel.org
  249. @@ -163,7 +179,7 @@ Description:
  250. a network device. See the driver for the exact reasons as to
  251. why the packets were dropped.
  252. -What: /sys/class/<iface>/statistics/tx_fifo_errors
  253. +What: /sys/class/net/<iface>/statistics/tx_fifo_errors
  254. Date: April 2005
  255. KernelVersion: 2.6.12
  256. Contact: netdev@vger.kernel.org
  257. @@ -172,7 +188,7 @@ Description:
  258. FIFO error. See the driver for the exact reasons as to why the
  259. packets were dropped.
  260. -What: /sys/class/<iface>/statistics/tx_heartbeat_errors
  261. +What: /sys/class/net/<iface>/statistics/tx_heartbeat_errors
  262. Date: April 2005
  263. KernelVersion: 2.6.12
  264. Contact: netdev@vger.kernel.org
  265. @@ -181,7 +197,7 @@ Description:
  266. reported as heartbeat errors. See the driver for the exact
  267. reasons as to why the packets were dropped.
  268. -What: /sys/class/<iface>/statistics/tx_packets
  269. +What: /sys/class/net/<iface>/statistics/tx_packets
  270. Date: April 2005
  271. KernelVersion: 2.6.12
  272. Contact: netdev@vger.kernel.org
  273. @@ -190,7 +206,7 @@ Description:
  274. device. See the driver for whether this reports the number of all
  275. attempted or successful transmissions.
  276. -What: /sys/class/<iface>/statistics/tx_window_errors
  277. +What: /sys/class/net/<iface>/statistics/tx_window_errors
  278. Date: April 2005
  279. KernelVersion: 2.6.12
  280. Contact: netdev@vger.kernel.org
  281. diff --git Documentation/sound/soc/dapm.rst Documentation/sound/soc/dapm.rst
  282. index 8e44107933ab..c3154ce6e1b2 100644
  283. --- linux-4.14.336/Documentation/sound/soc/dapm.rst
  284. +++ linux-4.14.336/Documentation/sound/soc/dapm.rst
  285. @@ -234,7 +234,7 @@ corresponding soft power control. In this case it is necessary to create
  286. a virtual widget - a widget with no control bits e.g.
  287. ::
  288. - SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_DAPM_NOPM, 0, 0, NULL, 0),
  289. + SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
  290. This can be used to merge to signal paths together in software.
  291. diff --git Makefile Makefile
  292. index 3e5a7d98a1e3..0a53d6d980f7 100644
  293. --- linux-4.14.336/Makefile
  294. +++ linux-4.14.336/Makefile
  295. @@ -1,8 +1,8 @@
  296. # SPDX-License-Identifier: GPL-2.0
  297. VERSION = 4
  298. PATCHLEVEL = 14
  299. -SUBLEVEL = 336
  300. -EXTRAVERSION =
  301. +SUBLEVEL = 341
  302. +EXTRAVERSION = -openela
  303. NAME = Petit Gorille
  304. # *DOCUMENTATION*
  305. diff --git arch/arc/kernel/signal.c arch/arc/kernel/signal.c
  306. index 68901f6f18ba..c36e642eb1a0 100644
  307. --- linux-4.14.336/arch/arc/kernel/signal.c
  308. +++ linux-4.14.336/arch/arc/kernel/signal.c
  309. @@ -64,7 +64,7 @@ struct rt_sigframe {
  310. unsigned int sigret_magic;
  311. };
  312. -static int save_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs)
  313. +static int save_arcv2_regs(struct sigcontext __user *mctx, struct pt_regs *regs)
  314. {
  315. int err = 0;
  316. #ifndef CONFIG_ISA_ARCOMPACT
  317. @@ -77,12 +77,12 @@ static int save_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs)
  318. #else
  319. v2abi.r58 = v2abi.r59 = 0;
  320. #endif
  321. - err = __copy_to_user(&mctx->v2abi, &v2abi, sizeof(v2abi));
  322. + err = __copy_to_user(&mctx->v2abi, (void const *)&v2abi, sizeof(v2abi));
  323. #endif
  324. return err;
  325. }
  326. -static int restore_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs)
  327. +static int restore_arcv2_regs(struct sigcontext __user *mctx, struct pt_regs *regs)
  328. {
  329. int err = 0;
  330. #ifndef CONFIG_ISA_ARCOMPACT
  331. diff --git arch/arm/boot/dts/imx1-ads.dts arch/arm/boot/dts/imx1-ads.dts
  332. index 5ea28ee07cf4..c2ee0a6b74ac 100644
  333. --- linux-4.14.336/arch/arm/boot/dts/imx1-ads.dts
  334. +++ linux-4.14.336/arch/arm/boot/dts/imx1-ads.dts
  335. @@ -81,7 +81,7 @@
  336. pinctrl-0 = <&pinctrl_weim>;
  337. status = "okay";
  338. - nor: nor@0,0 {
  339. + nor: flash@0,0 {
  340. compatible = "cfi-flash";
  341. reg = <0 0x00000000 0x02000000>;
  342. bank-width = <4>;
  343. diff --git arch/arm/boot/dts/imx1-apf9328.dts arch/arm/boot/dts/imx1-apf9328.dts
  344. index e8b4b52c2418..001984de53ff 100644
  345. --- linux-4.14.336/arch/arm/boot/dts/imx1-apf9328.dts
  346. +++ linux-4.14.336/arch/arm/boot/dts/imx1-apf9328.dts
  347. @@ -50,7 +50,7 @@
  348. pinctrl-0 = <&pinctrl_weim>;
  349. status = "okay";
  350. - nor: nor@0,0 {
  351. + nor: flash@0,0 {
  352. compatible = "cfi-flash";
  353. reg = <0 0x00000000 0x02000000>;
  354. bank-width = <2>;
  355. diff --git arch/arm/boot/dts/imx1.dtsi arch/arm/boot/dts/imx1.dtsi
  356. index 38d712be5685..65e27c86468a 100644
  357. --- linux-4.14.336/arch/arm/boot/dts/imx1.dtsi
  358. +++ linux-4.14.336/arch/arm/boot/dts/imx1.dtsi
  359. @@ -269,9 +269,12 @@
  360. status = "disabled";
  361. };
  362. - esram: esram@00300000 {
  363. + esram: sram@300000 {
  364. compatible = "mmio-sram";
  365. reg = <0x00300000 0x20000>;
  366. + ranges = <0 0x00300000 0x20000>;
  367. + #address-cells = <1>;
  368. + #size-cells = <1>;
  369. };
  370. };
  371. };
  372. diff --git arch/arm/boot/dts/imx23-sansa.dts arch/arm/boot/dts/imx23-sansa.dts
  373. index 221fd55e967e..3e532f4c86a4 100644
  374. --- linux-4.14.336/arch/arm/boot/dts/imx23-sansa.dts
  375. +++ linux-4.14.336/arch/arm/boot/dts/imx23-sansa.dts
  376. @@ -174,10 +174,8 @@
  377. #address-cells = <1>;
  378. #size-cells = <0>;
  379. compatible = "i2c-gpio";
  380. - gpios = <
  381. - &gpio1 24 0 /* SDA */
  382. - &gpio1 22 0 /* SCL */
  383. - >;
  384. + sda-gpios = <&gpio1 24 0>;
  385. + scl-gpios = <&gpio1 22 0>;
  386. i2c-gpio,delay-us = <2>; /* ~100 kHz */
  387. };
  388. @@ -185,10 +183,8 @@
  389. #address-cells = <1>;
  390. #size-cells = <0>;
  391. compatible = "i2c-gpio";
  392. - gpios = <
  393. - &gpio0 31 0 /* SDA */
  394. - &gpio0 30 0 /* SCL */
  395. - >;
  396. + sda-gpios = <&gpio0 31 0>;
  397. + scl-gpios = <&gpio0 30 0>;
  398. i2c-gpio,delay-us = <2>; /* ~100 kHz */
  399. touch: touch@20 {
  400. diff --git arch/arm/boot/dts/imx23.dtsi arch/arm/boot/dts/imx23.dtsi
  401. index 10d57f9cbb42..7a1613258e6c 100644
  402. --- linux-4.14.336/arch/arm/boot/dts/imx23.dtsi
  403. +++ linux-4.14.336/arch/arm/boot/dts/imx23.dtsi
  404. @@ -413,7 +413,7 @@
  405. status = "disabled";
  406. };
  407. - dma_apbx: dma-apbx@80024000 {
  408. + dma_apbx: dma-controller@80024000 {
  409. compatible = "fsl,imx23-dma-apbx";
  410. reg = <0x80024000 0x2000>;
  411. interrupts = <7 5 9 26
  412. diff --git arch/arm/boot/dts/imx25-eukrea-cpuimx25.dtsi arch/arm/boot/dts/imx25-eukrea-cpuimx25.dtsi
  413. index d6f27641c0ef..8676a28f8b7a 100644
  414. --- linux-4.14.336/arch/arm/boot/dts/imx25-eukrea-cpuimx25.dtsi
  415. +++ linux-4.14.336/arch/arm/boot/dts/imx25-eukrea-cpuimx25.dtsi
  416. @@ -34,7 +34,7 @@
  417. pinctrl-0 = <&pinctrl_i2c1>;
  418. status = "okay";
  419. - pcf8563@51 {
  420. + rtc@51 {
  421. compatible = "nxp,pcf8563";
  422. reg = <0x51>;
  423. };
  424. diff --git arch/arm/boot/dts/imx27-apf27dev.dts arch/arm/boot/dts/imx27-apf27dev.dts
  425. index 5f84b598e0d0..167f21434fbf 100644
  426. --- linux-4.14.336/arch/arm/boot/dts/imx27-apf27dev.dts
  427. +++ linux-4.14.336/arch/arm/boot/dts/imx27-apf27dev.dts
  428. @@ -53,7 +53,7 @@
  429. pinctrl-names = "default";
  430. pinctrl-0 = <&pinctrl_gpio_leds>;
  431. - user {
  432. + led-user {
  433. label = "Heartbeat";
  434. gpios = <&gpio6 14 GPIO_ACTIVE_HIGH>;
  435. linux,default-trigger = "heartbeat";
  436. diff --git arch/arm/boot/dts/imx27-eukrea-cpuimx27.dtsi arch/arm/boot/dts/imx27-eukrea-cpuimx27.dtsi
  437. index 2cf896c505f9..546b0544f8c9 100644
  438. --- linux-4.14.336/arch/arm/boot/dts/imx27-eukrea-cpuimx27.dtsi
  439. +++ linux-4.14.336/arch/arm/boot/dts/imx27-eukrea-cpuimx27.dtsi
  440. @@ -45,7 +45,7 @@
  441. pinctrl-0 = <&pinctrl_i2c1>;
  442. status = "okay";
  443. - pcf8563@51 {
  444. + rtc@51 {
  445. compatible = "nxp,pcf8563";
  446. reg = <0x51>;
  447. };
  448. @@ -102,7 +102,7 @@
  449. &weim {
  450. status = "okay";
  451. - nor: nor@0,0 {
  452. + nor: flash@0,0 {
  453. #address-cells = <1>;
  454. #size-cells = <1>;
  455. compatible = "cfi-flash";
  456. diff --git arch/arm/boot/dts/imx27-phytec-phycore-som.dtsi arch/arm/boot/dts/imx27-phytec-phycore-som.dtsi
  457. index c973c5d91875..1cd3251d21e1 100644
  458. --- linux-4.14.336/arch/arm/boot/dts/imx27-phytec-phycore-som.dtsi
  459. +++ linux-4.14.336/arch/arm/boot/dts/imx27-phytec-phycore-som.dtsi
  460. @@ -326,7 +326,7 @@
  461. &weim {
  462. status = "okay";
  463. - nor: nor@0,0 {
  464. + nor: flash@0,0 {
  465. compatible = "cfi-flash";
  466. reg = <0 0x00000000 0x02000000>;
  467. bank-width = <2>;
  468. diff --git arch/arm/boot/dts/imx27.dtsi arch/arm/boot/dts/imx27.dtsi
  469. index 15d85f1f85fd..507159b5d1d4 100644
  470. --- linux-4.14.336/arch/arm/boot/dts/imx27.dtsi
  471. +++ linux-4.14.336/arch/arm/boot/dts/imx27.dtsi
  472. @@ -600,6 +600,9 @@
  473. iram: iram@ffff4c00 {
  474. compatible = "mmio-sram";
  475. reg = <0xffff4c00 0xb400>;
  476. + ranges = <0 0xffff4c00 0xb400>;
  477. + #address-cells = <1>;
  478. + #size-cells = <1>;
  479. };
  480. };
  481. };
  482. diff --git arch/arm/boot/dts/imx28.dtsi arch/arm/boot/dts/imx28.dtsi
  483. index 2f4ebe0318d3..e489c480f4c0 100644
  484. --- linux-4.14.336/arch/arm/boot/dts/imx28.dtsi
  485. +++ linux-4.14.336/arch/arm/boot/dts/imx28.dtsi
  486. @@ -985,7 +985,7 @@
  487. status = "disabled";
  488. };
  489. - dma_apbx: dma-apbx@80024000 {
  490. + dma_apbx: dma-controller@80024000 {
  491. compatible = "fsl,imx28-dma-apbx";
  492. reg = <0x80024000 0x2000>;
  493. interrupts = <78 79 66 0
  494. diff --git arch/arm/boot/dts/imx7s.dtsi arch/arm/boot/dts/imx7s.dtsi
  495. index 836550f2297a..1d158707b5de 100644
  496. --- linux-4.14.336/arch/arm/boot/dts/imx7s.dtsi
  497. +++ linux-4.14.336/arch/arm/boot/dts/imx7s.dtsi
  498. @@ -674,7 +674,7 @@
  499. };
  500. lcdif: lcdif@30730000 {
  501. - compatible = "fsl,imx7d-lcdif", "fsl,imx28-lcdif";
  502. + compatible = "fsl,imx7d-lcdif", "fsl,imx6sx-lcdif";
  503. reg = <0x30730000 0x10000>;
  504. interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
  505. clocks = <&clks IMX7D_LCDIF_PIXEL_ROOT_CLK>,
  506. @@ -1039,7 +1039,7 @@
  507. gpmi: gpmi-nand@33002000{
  508. compatible = "fsl,imx7d-gpmi-nand";
  509. #address-cells = <1>;
  510. - #size-cells = <1>;
  511. + #size-cells = <0>;
  512. reg = <0x33002000 0x2000>, <0x33004000 0x4000>;
  513. reg-names = "gpmi-nand", "bch";
  514. interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
  515. diff --git arch/arm/boot/dts/rk3036.dtsi arch/arm/boot/dts/rk3036.dtsi
  516. index 03cf0c84ac0a..b1ede7a1e8de 100644
  517. --- linux-4.14.336/arch/arm/boot/dts/rk3036.dtsi
  518. +++ linux-4.14.336/arch/arm/boot/dts/rk3036.dtsi
  519. @@ -353,12 +353,20 @@
  520. pinctrl-0 = <&hdmi_ctl>;
  521. status = "disabled";
  522. - hdmi_in: port {
  523. + ports {
  524. #address-cells = <1>;
  525. #size-cells = <0>;
  526. - hdmi_in_vop: endpoint@0 {
  527. +
  528. + hdmi_in: port@0 {
  529. reg = <0>;
  530. - remote-endpoint = <&vop_out_hdmi>;
  531. +
  532. + hdmi_in_vop: endpoint {
  533. + remote-endpoint = <&vop_out_hdmi>;
  534. + };
  535. + };
  536. +
  537. + hdmi_out: port@1 {
  538. + reg = <1>;
  539. };
  540. };
  541. };
  542. diff --git arch/mips/alchemy/devboards/db1200.c arch/mips/alchemy/devboards/db1200.c
  543. index ae81e05fcb2c..fe827f98ebf1 100644
  544. --- linux-4.14.336/arch/mips/alchemy/devboards/db1200.c
  545. +++ linux-4.14.336/arch/mips/alchemy/devboards/db1200.c
  546. @@ -858,7 +858,7 @@ int __init db1200_dev_setup(void)
  547. i2c_register_board_info(0, db1200_i2c_devs,
  548. ARRAY_SIZE(db1200_i2c_devs));
  549. spi_register_board_info(db1200_spi_devs,
  550. - ARRAY_SIZE(db1200_i2c_devs));
  551. + ARRAY_SIZE(db1200_spi_devs));
  552. /* SWITCHES: S6.8 I2C/SPI selector (OFF=I2C ON=SPI)
  553. * S6.7 AC97/I2S selector (OFF=AC97 ON=I2S)
  554. diff --git arch/mips/alchemy/devboards/db1550.c arch/mips/alchemy/devboards/db1550.c
  555. index 7d3dfaa10231..aaee46fe582f 100644
  556. --- linux-4.14.336/arch/mips/alchemy/devboards/db1550.c
  557. +++ linux-4.14.336/arch/mips/alchemy/devboards/db1550.c
  558. @@ -581,7 +581,7 @@ int __init db1550_dev_setup(void)
  559. i2c_register_board_info(0, db1550_i2c_devs,
  560. ARRAY_SIZE(db1550_i2c_devs));
  561. spi_register_board_info(db1550_spi_devs,
  562. - ARRAY_SIZE(db1550_i2c_devs));
  563. + ARRAY_SIZE(db1550_spi_devs));
  564. c = clk_get(NULL, "psc0_intclk");
  565. if (!IS_ERR(c)) {
  566. diff --git arch/mips/include/asm/checksum.h arch/mips/include/asm/checksum.h
  567. index 77cad232a1c6..d7f673a6ef6d 100644
  568. --- linux-4.14.336/arch/mips/include/asm/checksum.h
  569. +++ linux-4.14.336/arch/mips/include/asm/checksum.h
  570. @@ -276,7 +276,8 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
  571. " .set pop"
  572. : "=&r" (sum), "=&r" (tmp)
  573. : "r" (saddr), "r" (daddr),
  574. - "0" (htonl(len)), "r" (htonl(proto)), "r" (sum));
  575. + "0" (htonl(len)), "r" (htonl(proto)), "r" (sum)
  576. + : "memory");
  577. return csum_fold(sum);
  578. }
  579. diff --git arch/mips/kernel/elf.c arch/mips/kernel/elf.c
  580. index 731325a61a78..d7d0a4872389 100644
  581. --- linux-4.14.336/arch/mips/kernel/elf.c
  582. +++ linux-4.14.336/arch/mips/kernel/elf.c
  583. @@ -15,6 +15,7 @@
  584. #include <asm/cpu-features.h>
  585. #include <asm/cpu-info.h>
  586. +#include <asm/fpu.h>
  587. /* Whether to accept legacy-NaN and 2008-NaN user binaries. */
  588. bool mips_use_nan_legacy;
  589. @@ -311,6 +312,11 @@ void mips_set_personality_nan(struct arch_elf_state *state)
  590. struct cpuinfo_mips *c = &boot_cpu_data;
  591. struct task_struct *t = current;
  592. + /* Do this early so t->thread.fpu.fcr31 won't be clobbered in case
  593. + * we are preempted before the lose_fpu(0) in start_thread.
  594. + */
  595. + lose_fpu(0);
  596. +
  597. t->thread.fpu.fcr31 = c->fpu_csr31;
  598. switch (state->nan_2008) {
  599. case 0:
  600. diff --git arch/parisc/kernel/firmware.c arch/parisc/kernel/firmware.c
  601. index 906b7c882587..82f264621845 100644
  602. --- linux-4.14.336/arch/parisc/kernel/firmware.c
  603. +++ linux-4.14.336/arch/parisc/kernel/firmware.c
  604. @@ -127,10 +127,10 @@ static unsigned long f_extend(unsigned long address)
  605. #ifdef CONFIG_64BIT
  606. if(unlikely(parisc_narrow_firmware)) {
  607. if((address & 0xff000000) == 0xf0000000)
  608. - return 0xf0f0f0f000000000UL | (u32)address;
  609. + return (0xfffffff0UL << 32) | (u32)address;
  610. if((address & 0xf0000000) == 0xf0000000)
  611. - return 0xffffffff00000000UL | (u32)address;
  612. + return (0xffffffffUL << 32) | (u32)address;
  613. }
  614. #endif
  615. return address;
  616. diff --git arch/powerpc/Kconfig arch/powerpc/Kconfig
  617. index 3fcfa8534156..ff7a86090eac 100644
  618. --- linux-4.14.336/arch/powerpc/Kconfig
  619. +++ linux-4.14.336/arch/powerpc/Kconfig
  620. @@ -281,12 +281,10 @@ config ARCH_MAY_HAVE_PC_FDC
  621. config PPC_UDBG_16550
  622. bool
  623. - default n
  624. config GENERIC_TBSYNC
  625. bool
  626. default y if PPC32 && SMP
  627. - default n
  628. config AUDIT_ARCH
  629. bool
  630. @@ -305,13 +303,11 @@ config EPAPR_BOOT
  631. bool
  632. help
  633. Used to allow a board to specify it wants an ePAPR compliant wrapper.
  634. - default n
  635. config DEFAULT_UIMAGE
  636. bool
  637. help
  638. Used to allow a board to specify it wants a uImage built by default
  639. - default n
  640. config ARCH_HIBERNATION_POSSIBLE
  641. bool
  642. @@ -325,11 +321,9 @@ config ARCH_SUSPEND_POSSIBLE
  643. config PPC_DCR_NATIVE
  644. bool
  645. - default n
  646. config PPC_DCR_MMIO
  647. bool
  648. - default n
  649. config PPC_DCR
  650. bool
  651. @@ -340,7 +334,6 @@ config PPC_OF_PLATFORM_PCI
  652. bool
  653. depends on PCI
  654. depends on PPC64 # not supported on 32 bits yet
  655. - default n
  656. config ARCH_SUPPORTS_DEBUG_PAGEALLOC
  657. depends on PPC32 || PPC_STD_MMU_64
  658. @@ -449,14 +442,12 @@ config PPC_TRANSACTIONAL_MEM
  659. depends on SMP
  660. select ALTIVEC
  661. select VSX
  662. - default n
  663. ---help---
  664. Support user-mode Transactional Memory on POWERPC.
  665. config LD_HEAD_STUB_CATCH
  666. bool "Reserve 256 bytes to cope with linker stubs in HEAD text" if EXPERT
  667. depends on PPC64
  668. - default n
  669. help
  670. Very large kernels can cause linker branch stubs to be generated by
  671. code in head_64.S, which moves the head text sections out of their
  672. @@ -583,7 +574,6 @@ config RELOCATABLE
  673. config RELOCATABLE_TEST
  674. bool "Test relocatable kernel"
  675. depends on (PPC64 && RELOCATABLE)
  676. - default n
  677. help
  678. This runs the relocatable kernel at the address it was initially
  679. loaded at, which tends to be non-zero and therefore test the
  680. @@ -797,7 +787,6 @@ config PPC_SUBPAGE_PROT
  681. config PPC_COPRO_BASE
  682. bool
  683. - default n
  684. config SCHED_SMT
  685. bool "SMT (Hyperthreading) scheduler support"
  686. @@ -911,7 +900,6 @@ config PPC_INDIRECT_PCI
  687. bool
  688. depends on PCI
  689. default y if 40x || 44x
  690. - default n
  691. config EISA
  692. bool
  693. @@ -1008,7 +996,6 @@ source "drivers/pcmcia/Kconfig"
  694. config HAS_RAPIDIO
  695. bool
  696. - default n
  697. config RAPIDIO
  698. tristate "RapidIO support"
  699. @@ -1044,7 +1031,6 @@ endmenu
  700. config NONSTATIC_KERNEL
  701. bool
  702. - default n
  703. menu "Advanced setup"
  704. depends on PPC32
  705. diff --git arch/powerpc/Kconfig.debug arch/powerpc/Kconfig.debug
  706. index 6c60cc03a53c..a185e7c3fc9c 100644
  707. --- linux-4.14.336/arch/powerpc/Kconfig.debug
  708. +++ linux-4.14.336/arch/powerpc/Kconfig.debug
  709. @@ -5,7 +5,6 @@ source "lib/Kconfig.debug"
  710. config PPC_DISABLE_WERROR
  711. bool "Don't build arch/powerpc code with -Werror"
  712. - default n
  713. help
  714. This option tells the compiler NOT to build the code under
  715. arch/powerpc with the -Werror flag (which means warnings
  716. @@ -59,7 +58,6 @@ config PPC_EMULATED_STATS
  717. config CODE_PATCHING_SELFTEST
  718. bool "Run self-tests of the code-patching code"
  719. depends on DEBUG_KERNEL
  720. - default n
  721. config JUMP_LABEL_FEATURE_CHECKS
  722. bool "Enable use of jump label for cpu/mmu_has_feature()"
  723. @@ -73,7 +71,6 @@ config JUMP_LABEL_FEATURE_CHECKS
  724. config JUMP_LABEL_FEATURE_CHECK_DEBUG
  725. bool "Do extra check on feature fixup calls"
  726. depends on DEBUG_KERNEL && JUMP_LABEL_FEATURE_CHECKS
  727. - default n
  728. help
  729. This tries to catch incorrect usage of cpu_has_feature() and
  730. mmu_has_feature() in the code.
  731. @@ -83,12 +80,10 @@ config JUMP_LABEL_FEATURE_CHECK_DEBUG
  732. config FTR_FIXUP_SELFTEST
  733. bool "Run self-tests of the feature-fixup code"
  734. depends on DEBUG_KERNEL
  735. - default n
  736. config MSI_BITMAP_SELFTEST
  737. bool "Run self-tests of the MSI bitmap code"
  738. depends on DEBUG_KERNEL
  739. - default n
  740. config XMON
  741. bool "Include xmon kernel debugger"
  742. diff --git arch/powerpc/include/asm/mmu.h arch/powerpc/include/asm/mmu.h
  743. index 6364f5c2cc3e..2cc99f5dd703 100644
  744. --- linux-4.14.336/arch/powerpc/include/asm/mmu.h
  745. +++ linux-4.14.336/arch/powerpc/include/asm/mmu.h
  746. @@ -332,5 +332,9 @@ static inline void mmu_early_init_devtree(void) { }
  747. # include <asm/mmu-8xx.h>
  748. #endif
  749. +#if defined(CONFIG_FA_DUMP) || defined(CONFIG_PRESERVE_FA_DUMP)
  750. +#define __HAVE_ARCH_RESERVED_KERNEL_PAGES
  751. +#endif
  752. +
  753. #endif /* __KERNEL__ */
  754. #endif /* _ASM_POWERPC_MMU_H_ */
  755. diff --git arch/powerpc/include/asm/mmzone.h arch/powerpc/include/asm/mmzone.h
  756. index 91c69ff53a8a..50c2198c2c76 100644
  757. --- linux-4.14.336/arch/powerpc/include/asm/mmzone.h
  758. +++ linux-4.14.336/arch/powerpc/include/asm/mmzone.h
  759. @@ -42,9 +42,6 @@ u64 memory_hotplug_max(void);
  760. #else
  761. #define memory_hotplug_max() memblock_end_of_DRAM()
  762. #endif /* CONFIG_NEED_MULTIPLE_NODES */
  763. -#ifdef CONFIG_FA_DUMP
  764. -#define __HAVE_ARCH_RESERVED_KERNEL_PAGES
  765. -#endif
  766. #endif /* __KERNEL__ */
  767. #endif /* _ASM_MMZONE_H_ */
  768. diff --git arch/powerpc/kernel/traps.c arch/powerpc/kernel/traps.c
  769. index a507a6874d42..f70799febec4 100644
  770. --- linux-4.14.336/arch/powerpc/kernel/traps.c
  771. +++ linux-4.14.336/arch/powerpc/kernel/traps.c
  772. @@ -1070,10 +1070,12 @@ static int emulate_instruction(struct pt_regs *regs)
  773. return -EINVAL;
  774. }
  775. +#ifdef CONFIG_GENERIC_BUG
  776. int is_valid_bugaddr(unsigned long addr)
  777. {
  778. return is_kernel_addr(addr);
  779. }
  780. +#endif
  781. #ifdef CONFIG_MATH_EMULATION
  782. static int emulate_math(struct pt_regs *regs)
  783. diff --git arch/powerpc/lib/Makefile arch/powerpc/lib/Makefile
  784. index 00c34be4c604..41491eb517cc 100644
  785. --- linux-4.14.336/arch/powerpc/lib/Makefile
  786. +++ linux-4.14.336/arch/powerpc/lib/Makefile
  787. @@ -21,8 +21,8 @@ obj-$(CONFIG_PPC32) += div64.o copy_32.o crtsavres.o
  788. # 64-bit linker creates .sfpr on demand for final link (vmlinux),
  789. # so it is only needed for modules, and only for older linkers which
  790. # do not support --save-restore-funcs
  791. -ifeq ($(call ld-ifversion, -lt, 225000000, y),y)
  792. -extra-$(CONFIG_PPC64) += crtsavres.o
  793. +ifeq ($(call ld-ifversion, -lt, 225000000, y)$(CONFIG_PPC64),yy)
  794. +always += crtsavres.o
  795. endif
  796. obj64-y += copypage_64.o copyuser_64.o mem_64.o hweight_64.o \
  797. diff --git arch/powerpc/lib/sstep.c arch/powerpc/lib/sstep.c
  798. index e9bfd9751246..331f3d0cbeb2 100644
  799. --- linux-4.14.336/arch/powerpc/lib/sstep.c
  800. +++ linux-4.14.336/arch/powerpc/lib/sstep.c
  801. @@ -471,6 +471,8 @@ static int do_fp_load(struct instruction_op *op, unsigned long ea,
  802. } u;
  803. nb = GETSIZE(op->type);
  804. + if (nb > sizeof(u))
  805. + return -EINVAL;
  806. if (!address_ok(regs, ea, nb))
  807. return -EFAULT;
  808. rn = op->reg;
  809. @@ -521,6 +523,8 @@ static int do_fp_store(struct instruction_op *op, unsigned long ea,
  810. } u;
  811. nb = GETSIZE(op->type);
  812. + if (nb > sizeof(u))
  813. + return -EINVAL;
  814. if (!address_ok(regs, ea, nb))
  815. return -EFAULT;
  816. rn = op->reg;
  817. @@ -565,6 +569,9 @@ static nokprobe_inline int do_vec_load(int rn, unsigned long ea,
  818. u8 b[sizeof(__vector128)];
  819. } u = {};
  820. + if (size > sizeof(u))
  821. + return -EINVAL;
  822. +
  823. if (!address_ok(regs, ea & ~0xfUL, 16))
  824. return -EFAULT;
  825. /* align to multiple of size */
  826. @@ -592,6 +599,9 @@ static nokprobe_inline int do_vec_store(int rn, unsigned long ea,
  827. u8 b[sizeof(__vector128)];
  828. } u;
  829. + if (size > sizeof(u))
  830. + return -EINVAL;
  831. +
  832. if (!address_ok(regs, ea & ~0xfUL, 16))
  833. return -EFAULT;
  834. /* align to multiple of size */
  835. diff --git arch/powerpc/mm/init-common.c arch/powerpc/mm/init-common.c
  836. index eb8c6c8c4851..c8515de5292e 100644
  837. --- linux-4.14.336/arch/powerpc/mm/init-common.c
  838. +++ linux-4.14.336/arch/powerpc/mm/init-common.c
  839. @@ -65,7 +65,7 @@ void pgtable_cache_add(unsigned shift, void (*ctor)(void *))
  840. * as to leave enough 0 bits in the address to contain it. */
  841. unsigned long minalign = max(MAX_PGTABLE_INDEX_SIZE + 1,
  842. HUGEPD_SHIFT_MASK + 1);
  843. - struct kmem_cache *new;
  844. + struct kmem_cache *new = NULL;
  845. /* It would be nice if this was a BUILD_BUG_ON(), but at the
  846. * moment, gcc doesn't seem to recognize is_power_of_2 as a
  847. @@ -78,7 +78,8 @@ void pgtable_cache_add(unsigned shift, void (*ctor)(void *))
  848. align = max_t(unsigned long, align, minalign);
  849. name = kasprintf(GFP_KERNEL, "pgtable-2^%d", shift);
  850. - new = kmem_cache_create(name, table_size, align, 0, ctor);
  851. + if (name)
  852. + new = kmem_cache_create(name, table_size, align, 0, ctor);
  853. if (!new)
  854. panic("Could not allocate pgtable cache for order %d", shift);
  855. diff --git arch/powerpc/perf/imc-pmu.c arch/powerpc/perf/imc-pmu.c
  856. index a0b4c22d963a..0b785c6bdbbf 100644
  857. --- linux-4.14.336/arch/powerpc/perf/imc-pmu.c
  858. +++ linux-4.14.336/arch/powerpc/perf/imc-pmu.c
  859. @@ -246,6 +246,8 @@ static int update_events_in_group(struct device_node *node, struct imc_pmu *pmu)
  860. attr_group->attrs = attrs;
  861. do {
  862. ev_val_str = kasprintf(GFP_KERNEL, "event=0x%x", pmu->events[i]->value);
  863. + if (!ev_val_str)
  864. + continue;
  865. dev_str = device_str_attr_create(pmu->events[i]->name, ev_val_str);
  866. if (!dev_str)
  867. continue;
  868. @@ -253,6 +255,8 @@ static int update_events_in_group(struct device_node *node, struct imc_pmu *pmu)
  869. attrs[j++] = dev_str;
  870. if (pmu->events[i]->scale) {
  871. ev_scale_str = kasprintf(GFP_KERNEL, "%s.scale",pmu->events[i]->name);
  872. + if (!ev_scale_str)
  873. + continue;
  874. dev_str = device_str_attr_create(ev_scale_str, pmu->events[i]->scale);
  875. if (!dev_str)
  876. continue;
  877. @@ -262,6 +266,8 @@ static int update_events_in_group(struct device_node *node, struct imc_pmu *pmu)
  878. if (pmu->events[i]->unit) {
  879. ev_unit_str = kasprintf(GFP_KERNEL, "%s.unit",pmu->events[i]->name);
  880. + if (!ev_unit_str)
  881. + continue;
  882. dev_str = device_str_attr_create(ev_unit_str, pmu->events[i]->unit);
  883. if (!dev_str)
  884. continue;
  885. diff --git arch/powerpc/platforms/40x/Kconfig arch/powerpc/platforms/40x/Kconfig
  886. index 60254a321a91..2a9d66254ffc 100644
  887. --- linux-4.14.336/arch/powerpc/platforms/40x/Kconfig
  888. +++ linux-4.14.336/arch/powerpc/platforms/40x/Kconfig
  889. @@ -2,7 +2,6 @@
  890. config ACADIA
  891. bool "Acadia"
  892. depends on 40x
  893. - default n
  894. select PPC40x_SIMPLE
  895. select 405EZ
  896. help
  897. @@ -11,7 +10,6 @@ config ACADIA
  898. config EP405
  899. bool "EP405/EP405PC"
  900. depends on 40x
  901. - default n
  902. select 405GP
  903. select PCI
  904. help
  905. @@ -20,7 +18,6 @@ config EP405
  906. config HOTFOOT
  907. bool "Hotfoot"
  908. depends on 40x
  909. - default n
  910. select PPC40x_SIMPLE
  911. select PCI
  912. help
  913. @@ -29,7 +26,6 @@ config HOTFOOT
  914. config KILAUEA
  915. bool "Kilauea"
  916. depends on 40x
  917. - default n
  918. select 405EX
  919. select PPC40x_SIMPLE
  920. select PPC4xx_PCI_EXPRESS
  921. @@ -41,7 +37,6 @@ config KILAUEA
  922. config MAKALU
  923. bool "Makalu"
  924. depends on 40x
  925. - default n
  926. select 405EX
  927. select PCI
  928. select PPC4xx_PCI_EXPRESS
  929. @@ -62,7 +57,6 @@ config WALNUT
  930. config XILINX_VIRTEX_GENERIC_BOARD
  931. bool "Generic Xilinx Virtex board"
  932. depends on 40x
  933. - default n
  934. select XILINX_VIRTEX_II_PRO
  935. select XILINX_VIRTEX_4_FX
  936. select XILINX_INTC
  937. @@ -80,7 +74,6 @@ config XILINX_VIRTEX_GENERIC_BOARD
  938. config OBS600
  939. bool "OpenBlockS 600"
  940. depends on 40x
  941. - default n
  942. select 405EX
  943. select PPC40x_SIMPLE
  944. help
  945. @@ -90,7 +83,6 @@ config OBS600
  946. config PPC40x_SIMPLE
  947. bool "Simple PowerPC 40x board support"
  948. depends on 40x
  949. - default n
  950. help
  951. This option enables the simple PowerPC 40x platform support.
  952. @@ -156,7 +148,6 @@ config IBM405_ERR51
  953. config APM8018X
  954. bool "APM8018X"
  955. depends on 40x
  956. - default n
  957. select PPC40x_SIMPLE
  958. help
  959. This option enables support for the AppliedMicro APM8018X evaluation
  960. diff --git arch/powerpc/platforms/44x/Kconfig arch/powerpc/platforms/44x/Kconfig
  961. index a6011422b861..559577065af2 100644
  962. --- linux-4.14.336/arch/powerpc/platforms/44x/Kconfig
  963. +++ linux-4.14.336/arch/powerpc/platforms/44x/Kconfig
  964. @@ -2,7 +2,6 @@
  965. config PPC_47x
  966. bool "Support for 47x variant"
  967. depends on 44x
  968. - default n
  969. select MPIC
  970. help
  971. This option enables support for the 47x family of processors and is
  972. @@ -11,7 +10,6 @@ config PPC_47x
  973. config BAMBOO
  974. bool "Bamboo"
  975. depends on 44x
  976. - default n
  977. select PPC44x_SIMPLE
  978. select 440EP
  979. select PCI
  980. @@ -21,7 +19,6 @@ config BAMBOO
  981. config BLUESTONE
  982. bool "Bluestone"
  983. depends on 44x
  984. - default n
  985. select PPC44x_SIMPLE
  986. select APM821xx
  987. select PCI_MSI
  988. @@ -44,7 +41,6 @@ config EBONY
  989. config SAM440EP
  990. bool "Sam440ep"
  991. depends on 44x
  992. - default n
  993. select 440EP
  994. select PCI
  995. help
  996. @@ -53,7 +49,6 @@ config SAM440EP
  997. config SEQUOIA
  998. bool "Sequoia"
  999. depends on 44x
  1000. - default n
  1001. select PPC44x_SIMPLE
  1002. select 440EPX
  1003. help
  1004. @@ -62,7 +57,6 @@ config SEQUOIA
  1005. config TAISHAN
  1006. bool "Taishan"
  1007. depends on 44x
  1008. - default n
  1009. select PPC44x_SIMPLE
  1010. select 440GX
  1011. select PCI
  1012. @@ -73,7 +67,6 @@ config TAISHAN
  1013. config KATMAI
  1014. bool "Katmai"
  1015. depends on 44x
  1016. - default n
  1017. select PPC44x_SIMPLE
  1018. select 440SPe
  1019. select PCI
  1020. @@ -86,7 +79,6 @@ config KATMAI
  1021. config RAINIER
  1022. bool "Rainier"
  1023. depends on 44x
  1024. - default n
  1025. select PPC44x_SIMPLE
  1026. select 440GRX
  1027. select PCI
  1028. @@ -96,7 +88,6 @@ config RAINIER
  1029. config WARP
  1030. bool "PIKA Warp"
  1031. depends on 44x
  1032. - default n
  1033. select 440EP
  1034. help
  1035. This option enables support for the PIKA Warp(tm) Appliance. The Warp
  1036. @@ -109,7 +100,6 @@ config WARP
  1037. config ARCHES
  1038. bool "Arches"
  1039. depends on 44x
  1040. - default n
  1041. select PPC44x_SIMPLE
  1042. select 460EX # Odd since it uses 460GT but the effects are the same
  1043. select PCI
  1044. @@ -120,7 +110,6 @@ config ARCHES
  1045. config CANYONLANDS
  1046. bool "Canyonlands"
  1047. depends on 44x
  1048. - default n
  1049. select 460EX
  1050. select PCI
  1051. select PPC4xx_PCI_EXPRESS
  1052. @@ -134,7 +123,6 @@ config CANYONLANDS
  1053. config GLACIER
  1054. bool "Glacier"
  1055. depends on 44x
  1056. - default n
  1057. select PPC44x_SIMPLE
  1058. select 460EX # Odd since it uses 460GT but the effects are the same
  1059. select PCI
  1060. @@ -147,7 +135,6 @@ config GLACIER
  1061. config REDWOOD
  1062. bool "Redwood"
  1063. depends on 44x
  1064. - default n
  1065. select PPC44x_SIMPLE
  1066. select 460SX
  1067. select PCI
  1068. @@ -160,7 +147,6 @@ config REDWOOD
  1069. config EIGER
  1070. bool "Eiger"
  1071. depends on 44x
  1072. - default n
  1073. select PPC44x_SIMPLE
  1074. select 460SX
  1075. select PCI
  1076. @@ -172,7 +158,6 @@ config EIGER
  1077. config YOSEMITE
  1078. bool "Yosemite"
  1079. depends on 44x
  1080. - default n
  1081. select PPC44x_SIMPLE
  1082. select 440EP
  1083. select PCI
  1084. @@ -182,7 +167,6 @@ config YOSEMITE
  1085. config ISS4xx
  1086. bool "ISS 4xx Simulator"
  1087. depends on (44x || 40x)
  1088. - default n
  1089. select 405GP if 40x
  1090. select 440GP if 44x && !PPC_47x
  1091. select PPC_FPU
  1092. @@ -193,7 +177,7 @@ config ISS4xx
  1093. config CURRITUCK
  1094. bool "IBM Currituck (476fpe) Support"
  1095. depends on PPC_47x
  1096. - default n
  1097. + select I2C
  1098. select SWIOTLB
  1099. select 476FPE
  1100. select PPC4xx_PCI_EXPRESS
  1101. @@ -203,7 +187,6 @@ config CURRITUCK
  1102. config FSP2
  1103. bool "IBM FSP2 (476fpe) Support"
  1104. depends on PPC_47x
  1105. - default n
  1106. select 476FPE
  1107. select IBM_EMAC_EMAC4 if IBM_EMAC
  1108. select IBM_EMAC_RGMII if IBM_EMAC
  1109. @@ -215,7 +198,6 @@ config FSP2
  1110. config AKEBONO
  1111. bool "IBM Akebono (476gtr) Support"
  1112. depends on PPC_47x
  1113. - default n
  1114. select SWIOTLB
  1115. select 476FPE
  1116. select PPC4xx_PCI_EXPRESS
  1117. @@ -241,7 +223,6 @@ config AKEBONO
  1118. config ICON
  1119. bool "Icon"
  1120. depends on 44x
  1121. - default n
  1122. select PPC44x_SIMPLE
  1123. select 440SPe
  1124. select PCI
  1125. @@ -252,7 +233,6 @@ config ICON
  1126. config XILINX_VIRTEX440_GENERIC_BOARD
  1127. bool "Generic Xilinx Virtex 5 FXT board support"
  1128. depends on 44x
  1129. - default n
  1130. select XILINX_VIRTEX_5_FXT
  1131. select XILINX_INTC
  1132. help
  1133. @@ -280,7 +260,6 @@ config XILINX_ML510
  1134. config PPC44x_SIMPLE
  1135. bool "Simple PowerPC 44x board support"
  1136. depends on 44x
  1137. - default n
  1138. help
  1139. This option enables the simple PowerPC 44x platform support.
  1140. diff --git arch/powerpc/platforms/82xx/Kconfig arch/powerpc/platforms/82xx/Kconfig
  1141. index 6e04099361b9..1947a88bc69f 100644
  1142. --- linux-4.14.336/arch/powerpc/platforms/82xx/Kconfig
  1143. +++ linux-4.14.336/arch/powerpc/platforms/82xx/Kconfig
  1144. @@ -51,7 +51,6 @@ endif
  1145. config PQ2ADS
  1146. bool
  1147. - default n
  1148. config 8260
  1149. bool
  1150. diff --git arch/powerpc/platforms/Kconfig arch/powerpc/platforms/Kconfig
  1151. index e06ccba35133..7cf557c1e1b0 100644
  1152. --- linux-4.14.336/arch/powerpc/platforms/Kconfig
  1153. +++ linux-4.14.336/arch/powerpc/platforms/Kconfig
  1154. @@ -23,7 +23,6 @@ source "arch/powerpc/platforms/amigaone/Kconfig"
  1155. config KVM_GUEST
  1156. bool "KVM Guest support"
  1157. - default n
  1158. select EPAPR_PARAVIRT
  1159. ---help---
  1160. This option enables various optimizations for running under the KVM
  1161. @@ -34,7 +33,6 @@ config KVM_GUEST
  1162. config EPAPR_PARAVIRT
  1163. bool "ePAPR para-virtualization support"
  1164. - default n
  1165. help
  1166. Enables ePAPR para-virtualization support for guests.
  1167. @@ -74,7 +72,6 @@ config PPC_DT_CPU_FTRS
  1168. config UDBG_RTAS_CONSOLE
  1169. bool "RTAS based debug console"
  1170. depends on PPC_RTAS
  1171. - default n
  1172. config PPC_SMP_MUXED_IPI
  1173. bool
  1174. @@ -86,16 +83,13 @@ config PPC_SMP_MUXED_IPI
  1175. config IPIC
  1176. bool
  1177. - default n
  1178. config MPIC
  1179. bool
  1180. - default n
  1181. config MPIC_TIMER
  1182. bool "MPIC Global Timer"
  1183. depends on MPIC && FSL_SOC
  1184. - default n
  1185. help
  1186. The MPIC global timer is a hardware timer inside the
  1187. Freescale PIC complying with OpenPIC standard. When the
  1188. @@ -107,7 +101,6 @@ config MPIC_TIMER
  1189. config FSL_MPIC_TIMER_WAKEUP
  1190. tristate "Freescale MPIC global timer wakeup driver"
  1191. depends on FSL_SOC && MPIC_TIMER && PM
  1192. - default n
  1193. help
  1194. The driver provides a way to wake up the system by MPIC
  1195. timer.
  1196. @@ -115,43 +108,35 @@ config FSL_MPIC_TIMER_WAKEUP
  1197. config PPC_EPAPR_HV_PIC
  1198. bool
  1199. - default n
  1200. select EPAPR_PARAVIRT
  1201. config MPIC_WEIRD
  1202. bool
  1203. - default n
  1204. config MPIC_MSGR
  1205. bool "MPIC message register support"
  1206. depends on MPIC
  1207. - default n
  1208. help
  1209. Enables support for the MPIC message registers. These
  1210. registers are used for inter-processor communication.
  1211. config PPC_I8259
  1212. bool
  1213. - default n
  1214. config U3_DART
  1215. bool
  1216. depends on PPC64
  1217. - default n
  1218. config PPC_RTAS
  1219. bool
  1220. - default n
  1221. config RTAS_ERROR_LOGGING
  1222. bool
  1223. depends on PPC_RTAS
  1224. - default n
  1225. config PPC_RTAS_DAEMON
  1226. bool
  1227. depends on PPC_RTAS
  1228. - default n
  1229. config RTAS_PROC
  1230. bool "Proc interface to RTAS"
  1231. @@ -164,11 +149,9 @@ config RTAS_FLASH
  1232. config MMIO_NVRAM
  1233. bool
  1234. - default n
  1235. config MPIC_U3_HT_IRQS
  1236. bool
  1237. - default n
  1238. config MPIC_BROKEN_REGREAD
  1239. bool
  1240. @@ -187,15 +170,12 @@ config EEH
  1241. config PPC_MPC106
  1242. bool
  1243. - default n
  1244. config PPC_970_NAP
  1245. bool
  1246. - default n
  1247. config PPC_P7_NAP
  1248. bool
  1249. - default n
  1250. config PPC_INDIRECT_PIO
  1251. bool
  1252. @@ -301,7 +281,6 @@ config AXON_RAM
  1253. config FSL_ULI1575
  1254. bool
  1255. - default n
  1256. select GENERIC_ISA_DMA
  1257. help
  1258. Supports for the ULI1575 PCIe south bridge that exists on some
  1259. diff --git arch/powerpc/platforms/Kconfig.cputype arch/powerpc/platforms/Kconfig.cputype
  1260. index 3ce376b42330..267cc8f41cf1 100644
  1261. --- linux-4.14.336/arch/powerpc/platforms/Kconfig.cputype
  1262. +++ linux-4.14.336/arch/powerpc/platforms/Kconfig.cputype
  1263. @@ -1,7 +1,6 @@
  1264. # SPDX-License-Identifier: GPL-2.0
  1265. config PPC64
  1266. bool "64-bit kernel"
  1267. - default n
  1268. select ZLIB_DEFLATE
  1269. help
  1270. This option selects whether a 32-bit or a 64-bit kernel
  1271. @@ -326,7 +325,6 @@ config PPC_MM_SLICES
  1272. bool
  1273. default y if PPC_STD_MMU_64
  1274. default y if PPC_8xx && HUGETLB_PAGE
  1275. - default n
  1276. config PPC_HAVE_PMU_SUPPORT
  1277. bool
  1278. @@ -340,7 +338,6 @@ config PPC_PERF_CTRS
  1279. config FORCE_SMP
  1280. # Allow platforms to force SMP=y by selecting this
  1281. bool
  1282. - default n
  1283. select SMP
  1284. config SMP
  1285. @@ -381,7 +378,6 @@ config CHECK_CACHE_COHERENCY
  1286. config PPC_DOORBELL
  1287. bool
  1288. - default n
  1289. endmenu
  1290. diff --git arch/powerpc/platforms/cell/Kconfig arch/powerpc/platforms/cell/Kconfig
  1291. index 741a8fa8a3e6..3ad42075f1f4 100644
  1292. --- linux-4.14.336/arch/powerpc/platforms/cell/Kconfig
  1293. +++ linux-4.14.336/arch/powerpc/platforms/cell/Kconfig
  1294. @@ -1,7 +1,6 @@
  1295. # SPDX-License-Identifier: GPL-2.0
  1296. config PPC_CELL
  1297. bool
  1298. - default n
  1299. config PPC_CELL_COMMON
  1300. bool
  1301. @@ -22,7 +21,6 @@ config PPC_CELL_NATIVE
  1302. select IBM_EMAC_RGMII if IBM_EMAC
  1303. select IBM_EMAC_ZMII if IBM_EMAC #test only
  1304. select IBM_EMAC_TAH if IBM_EMAC #test only
  1305. - default n
  1306. config PPC_IBM_CELL_BLADE
  1307. bool "IBM Cell Blade"
  1308. @@ -55,7 +53,6 @@ config SPU_FS
  1309. config SPU_BASE
  1310. bool
  1311. - default n
  1312. select PPC_COPRO_BASE
  1313. config CBE_RAS
  1314. diff --git arch/powerpc/platforms/maple/Kconfig arch/powerpc/platforms/maple/Kconfig
  1315. index 376d0be36b66..2601fac50354 100644
  1316. --- linux-4.14.336/arch/powerpc/platforms/maple/Kconfig
  1317. +++ linux-4.14.336/arch/powerpc/platforms/maple/Kconfig
  1318. @@ -13,7 +13,6 @@ config PPC_MAPLE
  1319. select PPC_RTAS
  1320. select MMIO_NVRAM
  1321. select ATA_NONSTANDARD if ATA
  1322. - default n
  1323. help
  1324. This option enables support for the Maple 970FX Evaluation Board.
  1325. For more information, refer to <http://www.970eval.com>
  1326. diff --git arch/powerpc/platforms/pasemi/Kconfig arch/powerpc/platforms/pasemi/Kconfig
  1327. index d458a791d35b..98e3bc22bebc 100644
  1328. --- linux-4.14.336/arch/powerpc/platforms/pasemi/Kconfig
  1329. +++ linux-4.14.336/arch/powerpc/platforms/pasemi/Kconfig
  1330. @@ -2,7 +2,6 @@
  1331. config PPC_PASEMI
  1332. depends on PPC64 && PPC_BOOK3S && CPU_BIG_ENDIAN
  1333. bool "PA Semi SoC-based platforms"
  1334. - default n
  1335. select MPIC
  1336. select PCI
  1337. select PPC_UDBG_16550
  1338. diff --git arch/powerpc/platforms/powernv/Kconfig arch/powerpc/platforms/powernv/Kconfig
  1339. index f8dc98d3dc01..05ee7b65d40f 100644
  1340. --- linux-4.14.336/arch/powerpc/platforms/powernv/Kconfig
  1341. +++ linux-4.14.336/arch/powerpc/platforms/powernv/Kconfig
  1342. @@ -35,7 +35,6 @@ config OPAL_PRD
  1343. config PPC_MEMTRACE
  1344. bool "Enable removal of RAM from kernel mappings for tracing"
  1345. depends on PPC_POWERNV && MEMORY_HOTREMOVE
  1346. - default n
  1347. help
  1348. Enabling this option allows for the removal of memory (RAM)
  1349. from the kernel mappings to be used for hardware tracing.
  1350. diff --git arch/powerpc/platforms/powernv/opal-irqchip.c arch/powerpc/platforms/powernv/opal-irqchip.c
  1351. index ecdcba9d1220..bd37ff2d7bd2 100644
  1352. --- linux-4.14.336/arch/powerpc/platforms/powernv/opal-irqchip.c
  1353. +++ linux-4.14.336/arch/powerpc/platforms/powernv/opal-irqchip.c
  1354. @@ -253,6 +253,8 @@ int __init opal_event_init(void)
  1355. else
  1356. name = kasprintf(GFP_KERNEL, "opal");
  1357. + if (!name)
  1358. + continue;
  1359. /* Install interrupt handler */
  1360. rc = request_irq(virq, opal_interrupt, IRQF_TRIGGER_LOW,
  1361. name, NULL);
  1362. diff --git arch/powerpc/platforms/ps3/Kconfig arch/powerpc/platforms/ps3/Kconfig
  1363. index 6f7525555b19..24864b8aaf5d 100644
  1364. --- linux-4.14.336/arch/powerpc/platforms/ps3/Kconfig
  1365. +++ linux-4.14.336/arch/powerpc/platforms/ps3/Kconfig
  1366. @@ -49,7 +49,6 @@ config PS3_HTAB_SIZE
  1367. config PS3_DYNAMIC_DMA
  1368. depends on PPC_PS3
  1369. bool "PS3 Platform dynamic DMA page table management"
  1370. - default n
  1371. help
  1372. This option will enable kernel support to take advantage of the
  1373. per device dynamic DMA page table management provided by the Cell
  1374. @@ -89,7 +88,6 @@ config PS3_SYS_MANAGER
  1375. config PS3_REPOSITORY_WRITE
  1376. bool "PS3 Repository write support" if PS3_ADVANCED
  1377. depends on PPC_PS3
  1378. - default n
  1379. help
  1380. Enables support for writing to the PS3 System Repository.
  1381. diff --git arch/powerpc/platforms/pseries/Kconfig arch/powerpc/platforms/pseries/Kconfig
  1382. index 0c698fd6d491..39032d9b316c 100644
  1383. --- linux-4.14.336/arch/powerpc/platforms/pseries/Kconfig
  1384. +++ linux-4.14.336/arch/powerpc/platforms/pseries/Kconfig
  1385. @@ -28,7 +28,6 @@ config PPC_PSERIES
  1386. config PPC_SPLPAR
  1387. depends on PPC_PSERIES
  1388. bool "Support for shared-processor logical partitions"
  1389. - default n
  1390. help
  1391. Enabling this option will make the kernel run more efficiently
  1392. on logically-partitioned pSeries systems which use shared
  1393. @@ -99,7 +98,6 @@ config PPC_SMLPAR
  1394. bool "Support for shared-memory logical partitions"
  1395. depends on PPC_PSERIES
  1396. select LPARCFG
  1397. - default n
  1398. help
  1399. Select this option to enable shared memory partition support.
  1400. With this option a system running in an LPAR can be given more
  1401. diff --git arch/powerpc/platforms/pseries/hotplug-memory.c arch/powerpc/platforms/pseries/hotplug-memory.c
  1402. index 1a3cffdaa1e8..318772785547 100644
  1403. --- linux-4.14.336/arch/powerpc/platforms/pseries/hotplug-memory.c
  1404. +++ linux-4.14.336/arch/powerpc/platforms/pseries/hotplug-memory.c
  1405. @@ -573,7 +573,7 @@ static int dlpar_memory_remove_by_index(u32 drc_index, struct property *prop)
  1406. int lmb_found;
  1407. int i, rc;
  1408. - pr_info("Attempting to hot-remove LMB, drc index %x\n", drc_index);
  1409. + pr_debug("Attempting to hot-remove LMB, drc index %x\n", drc_index);
  1410. p = prop->value;
  1411. num_lmbs = *p++;
  1412. @@ -591,14 +591,15 @@ static int dlpar_memory_remove_by_index(u32 drc_index, struct property *prop)
  1413. }
  1414. }
  1415. - if (!lmb_found)
  1416. + if (!lmb_found) {
  1417. + pr_debug("Failed to look up LMB for drc index %x\n", drc_index);
  1418. rc = -EINVAL;
  1419. -
  1420. - if (rc)
  1421. - pr_info("Failed to hot-remove memory at %llx\n",
  1422. - lmbs[i].base_addr);
  1423. - else
  1424. - pr_info("Memory at %llx was hot-removed\n", lmbs[i].base_addr);
  1425. + } else if (rc) {
  1426. + pr_debug("Failed to hot-remove memory at %llx\n",
  1427. + lmbs[i].base_addr);
  1428. + } else {
  1429. + pr_debug("Memory at %llx was hot-removed\n", lmbs[i].base_addr);
  1430. + }
  1431. return rc;
  1432. }
  1433. @@ -875,8 +876,8 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add, struct property *prop)
  1434. if (!lmbs[i].reserved)
  1435. continue;
  1436. - pr_info("Memory at %llx (drc index %x) was hot-added\n",
  1437. - lmbs[i].base_addr, lmbs[i].drc_index);
  1438. + pr_debug("Memory at %llx (drc index %x) was hot-added\n",
  1439. + lmbs[i].base_addr, lmbs[i].drc_index);
  1440. lmbs[i].reserved = 0;
  1441. }
  1442. rc = 0;
  1443. diff --git arch/powerpc/sysdev/Kconfig arch/powerpc/sysdev/Kconfig
  1444. index bcef2ac56479..e0dbec780fe9 100644
  1445. --- linux-4.14.336/arch/powerpc/sysdev/Kconfig
  1446. +++ linux-4.14.336/arch/powerpc/sysdev/Kconfig
  1447. @@ -6,19 +6,16 @@
  1448. config PPC4xx_PCI_EXPRESS
  1449. bool
  1450. depends on PCI && 4xx
  1451. - default n
  1452. config PPC4xx_HSTA_MSI
  1453. bool
  1454. depends on PCI_MSI
  1455. depends on PCI && 4xx
  1456. - default n
  1457. config PPC4xx_MSI
  1458. bool
  1459. depends on PCI_MSI
  1460. depends on PCI && 4xx
  1461. - default n
  1462. config PPC_MSI_BITMAP
  1463. bool
  1464. @@ -37,11 +34,9 @@ config PPC_SCOM
  1465. config SCOM_DEBUGFS
  1466. bool "Expose SCOM controllers via debugfs"
  1467. depends on PPC_SCOM && DEBUG_FS
  1468. - default n
  1469. config GE_FPGA
  1470. bool
  1471. - default n
  1472. config FSL_CORENET_RCPM
  1473. bool
  1474. diff --git arch/powerpc/sysdev/xive/Kconfig arch/powerpc/sysdev/xive/Kconfig
  1475. index 70ee976e1de0..785c292d104b 100644
  1476. --- linux-4.14.336/arch/powerpc/sysdev/xive/Kconfig
  1477. +++ linux-4.14.336/arch/powerpc/sysdev/xive/Kconfig
  1478. @@ -1,17 +1,14 @@
  1479. # SPDX-License-Identifier: GPL-2.0
  1480. config PPC_XIVE
  1481. bool
  1482. - default n
  1483. select PPC_SMP_MUXED_IPI
  1484. select HARDIRQS_SW_RESEND
  1485. config PPC_XIVE_NATIVE
  1486. bool
  1487. - default n
  1488. select PPC_XIVE
  1489. depends on PPC_POWERNV
  1490. config PPC_XIVE_SPAPR
  1491. bool
  1492. - default n
  1493. select PPC_XIVE
  1494. diff --git arch/s390/kernel/ptrace.c arch/s390/kernel/ptrace.c
  1495. index 7c635e4328b8..60050ba8fa1d 100644
  1496. --- linux-4.14.336/arch/s390/kernel/ptrace.c
  1497. +++ linux-4.14.336/arch/s390/kernel/ptrace.c
  1498. @@ -411,6 +411,7 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data)
  1499. /*
  1500. * floating point control reg. is in the thread structure
  1501. */
  1502. + save_fpu_regs();
  1503. if ((unsigned int) data != 0 ||
  1504. test_fp_ctl(data >> (BITS_PER_LONG - 32)))
  1505. return -EINVAL;
  1506. @@ -771,6 +772,7 @@ static int __poke_user_compat(struct task_struct *child,
  1507. /*
  1508. * floating point control reg. is in the thread structure
  1509. */
  1510. + save_fpu_regs();
  1511. if (test_fp_ctl(tmp))
  1512. return -EINVAL;
  1513. child->thread.fpu.fpc = data;
  1514. @@ -999,9 +1001,7 @@ static int s390_fpregs_set(struct task_struct *target,
  1515. int rc = 0;
  1516. freg_t fprs[__NUM_FPRS];
  1517. - if (target == current)
  1518. - save_fpu_regs();
  1519. -
  1520. + save_fpu_regs();
  1521. if (MACHINE_HAS_VX)
  1522. convert_vx_to_fp(fprs, target->thread.fpu.vxrs);
  1523. else
  1524. diff --git arch/s390/kvm/kvm-s390.c arch/s390/kvm/kvm-s390.c
  1525. index 05bd51752845..ee822b451eb2 100644
  1526. --- linux-4.14.336/arch/s390/kvm/kvm-s390.c
  1527. +++ linux-4.14.336/arch/s390/kvm/kvm-s390.c
  1528. @@ -2788,8 +2788,6 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
  1529. int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
  1530. {
  1531. - if (test_fp_ctl(fpu->fpc))
  1532. - return -EINVAL;
  1533. vcpu->run->s.regs.fpc = fpu->fpc;
  1534. if (MACHINE_HAS_VX)
  1535. convert_fp_to_vx((__vector128 *) vcpu->run->s.regs.vrs,
  1536. diff --git arch/s390/pci/pci.c arch/s390/pci/pci.c
  1537. index 960c4a362d8c..cf6a0af76c8f 100644
  1538. --- linux-4.14.336/arch/s390/pci/pci.c
  1539. +++ linux-4.14.336/arch/s390/pci/pci.c
  1540. @@ -272,7 +272,7 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
  1541. /* combine single writes by using store-block insn */
  1542. void __iowrite64_copy(void __iomem *to, const void *from, size_t count)
  1543. {
  1544. - zpci_memcpy_toio(to, from, count);
  1545. + zpci_memcpy_toio(to, from, count * 8);
  1546. }
  1547. /* Create a virtual mapping cookie for a PCI BAR */
  1548. diff --git arch/um/drivers/net_kern.c arch/um/drivers/net_kern.c
  1549. index 1669240c7a25..f107c9598127 100644
  1550. --- linux-4.14.336/arch/um/drivers/net_kern.c
  1551. +++ linux-4.14.336/arch/um/drivers/net_kern.c
  1552. @@ -207,7 +207,7 @@ static int uml_net_close(struct net_device *dev)
  1553. return 0;
  1554. }
  1555. -static int uml_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
  1556. +static netdev_tx_t uml_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
  1557. {
  1558. struct uml_net_private *lp = netdev_priv(dev);
  1559. unsigned long flags;
  1560. diff --git arch/um/include/shared/kern_util.h arch/um/include/shared/kern_util.h
  1561. index 35ab97e4bb9b..f2da8347d5f5 100644
  1562. --- linux-4.14.336/arch/um/include/shared/kern_util.h
  1563. +++ linux-4.14.336/arch/um/include/shared/kern_util.h
  1564. @@ -49,7 +49,7 @@ extern void do_uml_exitcalls(void);
  1565. * Are we disallowed to sleep? Used to choose between GFP_KERNEL and
  1566. * GFP_ATOMIC.
  1567. */
  1568. -extern int __cant_sleep(void);
  1569. +extern int __uml_cant_sleep(void);
  1570. extern int get_current_pid(void);
  1571. extern int copy_from_user_proc(void *to, void *from, int size);
  1572. extern int cpu(void);
  1573. diff --git arch/um/kernel/process.c arch/um/kernel/process.c
  1574. index 691b83b10649..c9d09d04d19d 100644
  1575. --- linux-4.14.336/arch/um/kernel/process.c
  1576. +++ linux-4.14.336/arch/um/kernel/process.c
  1577. @@ -210,7 +210,7 @@ void arch_cpu_idle(void)
  1578. local_irq_enable();
  1579. }
  1580. -int __cant_sleep(void) {
  1581. +int __uml_cant_sleep(void) {
  1582. return in_atomic() || irqs_disabled() || in_interrupt();
  1583. /* Is in_interrupt() really needed? */
  1584. }
  1585. diff --git arch/um/os-Linux/helper.c arch/um/os-Linux/helper.c
  1586. index 3f02d4232812..53d450e4a53a 100644
  1587. --- linux-4.14.336/arch/um/os-Linux/helper.c
  1588. +++ linux-4.14.336/arch/um/os-Linux/helper.c
  1589. @@ -45,7 +45,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
  1590. unsigned long stack, sp;
  1591. int pid, fds[2], ret, n;
  1592. - stack = alloc_stack(0, __cant_sleep());
  1593. + stack = alloc_stack(0, __uml_cant_sleep());
  1594. if (stack == 0)
  1595. return -ENOMEM;
  1596. @@ -69,7 +69,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
  1597. data.pre_data = pre_data;
  1598. data.argv = argv;
  1599. data.fd = fds[1];
  1600. - data.buf = __cant_sleep() ? uml_kmalloc(PATH_MAX, UM_GFP_ATOMIC) :
  1601. + data.buf = __uml_cant_sleep() ? uml_kmalloc(PATH_MAX, UM_GFP_ATOMIC) :
  1602. uml_kmalloc(PATH_MAX, UM_GFP_KERNEL);
  1603. pid = clone(helper_child, (void *) sp, CLONE_VM, &data);
  1604. if (pid < 0) {
  1605. @@ -116,7 +116,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
  1606. unsigned long stack, sp;
  1607. int pid, status, err;
  1608. - stack = alloc_stack(0, __cant_sleep());
  1609. + stack = alloc_stack(0, __uml_cant_sleep());
  1610. if (stack == 0)
  1611. return -ENOMEM;
  1612. diff --git arch/um/os-Linux/util.c arch/um/os-Linux/util.c
  1613. index 8cc8b2617a67..0436cc9537e0 100644
  1614. --- linux-4.14.336/arch/um/os-Linux/util.c
  1615. +++ linux-4.14.336/arch/um/os-Linux/util.c
  1616. @@ -166,23 +166,38 @@ __uml_setup("quiet", quiet_cmd_param,
  1617. "quiet\n"
  1618. " Turns off information messages during boot.\n\n");
  1619. +/*
  1620. + * The os_info/os_warn functions will be called by helper threads. These
  1621. + * have a very limited stack size and using the libc formatting functions
  1622. + * may overflow the stack.
  1623. + * So pull in the kernel vscnprintf and use that instead with a fixed
  1624. + * on-stack buffer.
  1625. + */
  1626. +int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
  1627. +
  1628. void os_info(const char *fmt, ...)
  1629. {
  1630. + char buf[256];
  1631. va_list list;
  1632. + int len;
  1633. if (quiet_info)
  1634. return;
  1635. va_start(list, fmt);
  1636. - vfprintf(stderr, fmt, list);
  1637. + len = vscnprintf(buf, sizeof(buf), fmt, list);
  1638. + fwrite(buf, len, 1, stderr);
  1639. va_end(list);
  1640. }
  1641. void os_warn(const char *fmt, ...)
  1642. {
  1643. + char buf[256];
  1644. va_list list;
  1645. + int len;
  1646. va_start(list, fmt);
  1647. - vfprintf(stderr, fmt, list);
  1648. + len = vscnprintf(buf, sizeof(buf), fmt, list);
  1649. + fwrite(buf, len, 1, stderr);
  1650. va_end(list);
  1651. }
  1652. diff --git arch/x86/kernel/cpu/amd.c arch/x86/kernel/cpu/amd.c
  1653. index 96305270c435..9ffb0cc5aa01 100644
  1654. --- linux-4.14.336/arch/x86/kernel/cpu/amd.c
  1655. +++ linux-4.14.336/arch/x86/kernel/cpu/amd.c
  1656. @@ -198,15 +198,6 @@ static void init_amd_k6(struct cpuinfo_x86 *c)
  1657. return;
  1658. }
  1659. #endif
  1660. - /*
  1661. - * Work around Erratum 1386. The XSAVES instruction malfunctions in
  1662. - * certain circumstances on Zen1/2 uarch, and not all parts have had
  1663. - * updated microcode at the time of writing (March 2023).
  1664. - *
  1665. - * Affected parts all have no supervisor XSAVE states, meaning that
  1666. - * the XSAVEC instruction (which works fine) is equivalent.
  1667. - */
  1668. - clear_cpu_cap(c, X86_FEATURE_XSAVES);
  1669. }
  1670. static void init_amd_k7(struct cpuinfo_x86 *c)
  1671. @@ -880,6 +871,17 @@ static void init_amd_zn(struct cpuinfo_x86 *c)
  1672. if (c->x86 == 0x19 && !cpu_has(c, X86_FEATURE_BTC_NO))
  1673. set_cpu_cap(c, X86_FEATURE_BTC_NO);
  1674. }
  1675. +
  1676. + /*
  1677. + * Work around Erratum 1386. The XSAVES instruction malfunctions in
  1678. + * certain circumstances on Zen1/2 uarch, and not all parts have had
  1679. + * updated microcode at the time of writing (March 2023).
  1680. + *
  1681. + * Affected parts all have no supervisor XSAVE states, meaning that
  1682. + * the XSAVEC instruction (which works fine) is equivalent.
  1683. + */
  1684. + if (c->x86 == 0x17)
  1685. + clear_cpu_cap(c, X86_FEATURE_XSAVES);
  1686. }
  1687. static void init_amd(struct cpuinfo_x86 *c)
  1688. diff --git arch/x86/lib/misc.c arch/x86/lib/misc.c
  1689. index a018ec4fba53..c97be9a1430a 100644
  1690. --- linux-4.14.336/arch/x86/lib/misc.c
  1691. +++ linux-4.14.336/arch/x86/lib/misc.c
  1692. @@ -6,7 +6,7 @@
  1693. */
  1694. int num_digits(int val)
  1695. {
  1696. - int m = 10;
  1697. + long long m = 10;
  1698. int d = 1;
  1699. if (val < 0) {
  1700. diff --git arch/x86/mm/ident_map.c arch/x86/mm/ident_map.c
  1701. index 407fa1df470e..50c537a4554b 100644
  1702. --- linux-4.14.336/arch/x86/mm/ident_map.c
  1703. +++ linux-4.14.336/arch/x86/mm/ident_map.c
  1704. @@ -26,18 +26,31 @@ static int ident_pud_init(struct x86_mapping_info *info, pud_t *pud_page,
  1705. for (; addr < end; addr = next) {
  1706. pud_t *pud = pud_page + pud_index(addr);
  1707. pmd_t *pmd;
  1708. + bool use_gbpage;
  1709. next = (addr & PUD_MASK) + PUD_SIZE;
  1710. if (next > end)
  1711. next = end;
  1712. - if (info->direct_gbpages) {
  1713. - pud_t pudval;
  1714. + /* if this is already a gbpage, this portion is already mapped */
  1715. + if (pud_large(*pud))
  1716. + continue;
  1717. +
  1718. + /* Is using a gbpage allowed? */
  1719. + use_gbpage = info->direct_gbpages;
  1720. - if (pud_present(*pud))
  1721. - continue;
  1722. + /* Don't use gbpage if it maps more than the requested region. */
  1723. + /* at the begining: */
  1724. + use_gbpage &= ((addr & ~PUD_MASK) == 0);
  1725. + /* ... or at the end: */
  1726. + use_gbpage &= ((next & ~PUD_MASK) == 0);
  1727. +
  1728. + /* Never overwrite existing mappings */
  1729. + use_gbpage &= !pud_present(*pud);
  1730. +
  1731. + if (use_gbpage) {
  1732. + pud_t pudval;
  1733. - addr &= PUD_MASK;
  1734. pudval = __pud((addr - info->offset) | info->page_flag);
  1735. set_pud(pud, pudval);
  1736. continue;
  1737. diff --git block/bio.c block/bio.c
  1738. index 1eaf31976702..28e288243266 100644
  1739. --- linux-4.14.336/block/bio.c
  1740. +++ linux-4.14.336/block/bio.c
  1741. @@ -1723,7 +1723,7 @@ void bio_set_pages_dirty(struct bio *bio)
  1742. bio_for_each_segment_all(bvec, bio, i) {
  1743. struct page *page = bvec->bv_page;
  1744. - if (page && !PageCompound(page))
  1745. + if (page)
  1746. set_page_dirty_lock(page);
  1747. }
  1748. }
  1749. @@ -1790,7 +1790,7 @@ void bio_check_pages_dirty(struct bio *bio)
  1750. bio_for_each_segment_all(bvec, bio, i) {
  1751. struct page *page = bvec->bv_page;
  1752. - if (PageDirty(page) || PageCompound(page)) {
  1753. + if (PageDirty(page)) {
  1754. put_page(page);
  1755. bvec->bv_page = NULL;
  1756. } else {
  1757. diff --git crypto/af_alg.c crypto/af_alg.c
  1758. index da000a256e91..24de37ac9d27 100644
  1759. --- linux-4.14.336/crypto/af_alg.c
  1760. +++ linux-4.14.336/crypto/af_alg.c
  1761. @@ -1060,9 +1060,13 @@ EXPORT_SYMBOL_GPL(af_alg_sendpage);
  1762. void af_alg_free_resources(struct af_alg_async_req *areq)
  1763. {
  1764. struct sock *sk = areq->sk;
  1765. + struct af_alg_ctx *ctx;
  1766. af_alg_free_areq_sgls(areq);
  1767. sock_kfree_s(sk, areq, areq->areqlen);
  1768. +
  1769. + ctx = alg_sk(sk)->private;
  1770. + ctx->inflight = false;
  1771. }
  1772. EXPORT_SYMBOL_GPL(af_alg_free_resources);
  1773. @@ -1126,11 +1130,19 @@ EXPORT_SYMBOL_GPL(af_alg_poll);
  1774. struct af_alg_async_req *af_alg_alloc_areq(struct sock *sk,
  1775. unsigned int areqlen)
  1776. {
  1777. - struct af_alg_async_req *areq = sock_kmalloc(sk, areqlen, GFP_KERNEL);
  1778. + struct af_alg_ctx *ctx = alg_sk(sk)->private;
  1779. + struct af_alg_async_req *areq;
  1780. +
  1781. + /* Only one AIO request can be in flight. */
  1782. + if (ctx->inflight)
  1783. + return ERR_PTR(-EBUSY);
  1784. + areq = sock_kmalloc(sk, areqlen, GFP_KERNEL);
  1785. if (unlikely(!areq))
  1786. return ERR_PTR(-ENOMEM);
  1787. + ctx->inflight = true;
  1788. +
  1789. areq->areqlen = areqlen;
  1790. areq->sk = sk;
  1791. areq->last_rsgl = NULL;
  1792. diff --git crypto/algapi.c crypto/algapi.c
  1793. index 603d2d637209..8557aff7fb35 100644
  1794. --- linux-4.14.336/crypto/algapi.c
  1795. +++ linux-4.14.336/crypto/algapi.c
  1796. @@ -222,6 +222,7 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
  1797. }
  1798. if (!strcmp(q->cra_driver_name, alg->cra_name) ||
  1799. + !strcmp(q->cra_driver_name, alg->cra_driver_name) ||
  1800. !strcmp(q->cra_name, alg->cra_driver_name))
  1801. goto err;
  1802. }
  1803. diff --git crypto/scompress.c crypto/scompress.c
  1804. index 2075e2c4e7df..9baaf49f16bb 100644
  1805. --- linux-4.14.336/crypto/scompress.c
  1806. +++ linux-4.14.336/crypto/scompress.c
  1807. @@ -29,9 +29,17 @@
  1808. #include <crypto/internal/scompress.h>
  1809. #include "internal.h"
  1810. +struct scomp_scratch {
  1811. + spinlock_t lock;
  1812. + void *src;
  1813. + void *dst;
  1814. +};
  1815. +
  1816. +static DEFINE_PER_CPU(struct scomp_scratch, scomp_scratch) = {
  1817. + .lock = __SPIN_LOCK_UNLOCKED(scomp_scratch.lock),
  1818. +};
  1819. +
  1820. static const struct crypto_type crypto_scomp_type;
  1821. -static void * __percpu *scomp_src_scratches;
  1822. -static void * __percpu *scomp_dst_scratches;
  1823. static int scomp_scratch_users;
  1824. static DEFINE_MUTEX(scomp_lock);
  1825. @@ -65,76 +73,53 @@ static void crypto_scomp_show(struct seq_file *m, struct crypto_alg *alg)
  1826. seq_puts(m, "type : scomp\n");
  1827. }
  1828. -static void crypto_scomp_free_scratches(void * __percpu *scratches)
  1829. +static void crypto_scomp_free_scratches(void)
  1830. {
  1831. + struct scomp_scratch *scratch;
  1832. int i;
  1833. - if (!scratches)
  1834. - return;
  1835. -
  1836. - for_each_possible_cpu(i)
  1837. - vfree(*per_cpu_ptr(scratches, i));
  1838. + for_each_possible_cpu(i) {
  1839. + scratch = per_cpu_ptr(&scomp_scratch, i);
  1840. - free_percpu(scratches);
  1841. + vfree(scratch->src);
  1842. + vfree(scratch->dst);
  1843. + scratch->src = NULL;
  1844. + scratch->dst = NULL;
  1845. + }
  1846. }
  1847. -static void * __percpu *crypto_scomp_alloc_scratches(void)
  1848. +static int crypto_scomp_alloc_scratches(void)
  1849. {
  1850. - void * __percpu *scratches;
  1851. + struct scomp_scratch *scratch;
  1852. int i;
  1853. - scratches = alloc_percpu(void *);
  1854. - if (!scratches)
  1855. - return NULL;
  1856. -
  1857. for_each_possible_cpu(i) {
  1858. - void *scratch;
  1859. -
  1860. - scratch = vmalloc_node(SCOMP_SCRATCH_SIZE, cpu_to_node(i));
  1861. - if (!scratch)
  1862. - goto error;
  1863. - *per_cpu_ptr(scratches, i) = scratch;
  1864. - }
  1865. + void *mem;
  1866. - return scratches;
  1867. + scratch = per_cpu_ptr(&scomp_scratch, i);
  1868. -error:
  1869. - crypto_scomp_free_scratches(scratches);
  1870. - return NULL;
  1871. -}
  1872. -
  1873. -static void crypto_scomp_free_all_scratches(void)
  1874. -{
  1875. - if (!--scomp_scratch_users) {
  1876. - crypto_scomp_free_scratches(scomp_src_scratches);
  1877. - crypto_scomp_free_scratches(scomp_dst_scratches);
  1878. - scomp_src_scratches = NULL;
  1879. - scomp_dst_scratches = NULL;
  1880. - }
  1881. -}
  1882. -
  1883. -static int crypto_scomp_alloc_all_scratches(void)
  1884. -{
  1885. - if (!scomp_scratch_users++) {
  1886. - scomp_src_scratches = crypto_scomp_alloc_scratches();
  1887. - if (!scomp_src_scratches)
  1888. - return -ENOMEM;
  1889. - scomp_dst_scratches = crypto_scomp_alloc_scratches();
  1890. - if (!scomp_dst_scratches) {
  1891. - crypto_scomp_free_scratches(scomp_src_scratches);
  1892. - scomp_src_scratches = NULL;
  1893. - return -ENOMEM;
  1894. - }
  1895. + mem = vmalloc_node(SCOMP_SCRATCH_SIZE, cpu_to_node(i));
  1896. + if (!mem)
  1897. + goto error;
  1898. + scratch->src = mem;
  1899. + mem = vmalloc_node(SCOMP_SCRATCH_SIZE, cpu_to_node(i));
  1900. + if (!mem)
  1901. + goto error;
  1902. + scratch->dst = mem;
  1903. }
  1904. return 0;
  1905. +error:
  1906. + crypto_scomp_free_scratches();
  1907. + return -ENOMEM;
  1908. }
  1909. static int crypto_scomp_init_tfm(struct crypto_tfm *tfm)
  1910. {
  1911. - int ret;
  1912. + int ret = 0;
  1913. mutex_lock(&scomp_lock);
  1914. - ret = crypto_scomp_alloc_all_scratches();
  1915. + if (!scomp_scratch_users++)
  1916. + ret = crypto_scomp_alloc_scratches();
  1917. mutex_unlock(&scomp_lock);
  1918. return ret;
  1919. @@ -193,42 +178,47 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
  1920. void **tfm_ctx = acomp_tfm_ctx(tfm);
  1921. struct crypto_scomp *scomp = *tfm_ctx;
  1922. void **ctx = acomp_request_ctx(req);
  1923. - const int cpu = get_cpu();
  1924. - u8 *scratch_src = *per_cpu_ptr(scomp_src_scratches, cpu);
  1925. - u8 *scratch_dst = *per_cpu_ptr(scomp_dst_scratches, cpu);
  1926. + struct scomp_scratch *scratch;
  1927. + unsigned int dlen;
  1928. int ret;
  1929. - if (!req->src || !req->slen || req->slen > SCOMP_SCRATCH_SIZE) {
  1930. - ret = -EINVAL;
  1931. - goto out;
  1932. - }
  1933. + if (!req->src || !req->slen || req->slen > SCOMP_SCRATCH_SIZE)
  1934. + return -EINVAL;
  1935. - if (req->dst && !req->dlen) {
  1936. - ret = -EINVAL;
  1937. - goto out;
  1938. - }
  1939. + if (req->dst && !req->dlen)
  1940. + return -EINVAL;
  1941. if (!req->dlen || req->dlen > SCOMP_SCRATCH_SIZE)
  1942. req->dlen = SCOMP_SCRATCH_SIZE;
  1943. - scatterwalk_map_and_copy(scratch_src, req->src, 0, req->slen, 0);
  1944. + dlen = req->dlen;
  1945. +
  1946. + scratch = raw_cpu_ptr(&scomp_scratch);
  1947. + spin_lock(&scratch->lock);
  1948. +
  1949. + scatterwalk_map_and_copy(scratch->src, req->src, 0, req->slen, 0);
  1950. if (dir)
  1951. - ret = crypto_scomp_compress(scomp, scratch_src, req->slen,
  1952. - scratch_dst, &req->dlen, *ctx);
  1953. + ret = crypto_scomp_compress(scomp, scratch->src, req->slen,
  1954. + scratch->dst, &req->dlen, *ctx);
  1955. else
  1956. - ret = crypto_scomp_decompress(scomp, scratch_src, req->slen,
  1957. - scratch_dst, &req->dlen, *ctx);
  1958. + ret = crypto_scomp_decompress(scomp, scratch->src, req->slen,
  1959. + scratch->dst, &req->dlen, *ctx);
  1960. if (!ret) {
  1961. if (!req->dst) {
  1962. req->dst = crypto_scomp_sg_alloc(req->dlen, GFP_ATOMIC);
  1963. - if (!req->dst)
  1964. + if (!req->dst) {
  1965. + ret = -ENOMEM;
  1966. goto out;
  1967. + }
  1968. + } else if (req->dlen > dlen) {
  1969. + ret = -ENOSPC;
  1970. + goto out;
  1971. }
  1972. - scatterwalk_map_and_copy(scratch_dst, req->dst, 0, req->dlen,
  1973. + scatterwalk_map_and_copy(scratch->dst, req->dst, 0, req->dlen,
  1974. 1);
  1975. }
  1976. out:
  1977. - put_cpu();
  1978. + spin_unlock(&scratch->lock);
  1979. return ret;
  1980. }
  1981. @@ -249,7 +239,8 @@ static void crypto_exit_scomp_ops_async(struct crypto_tfm *tfm)
  1982. crypto_free_scomp(*ctx);
  1983. mutex_lock(&scomp_lock);
  1984. - crypto_scomp_free_all_scratches();
  1985. + if (!--scomp_scratch_users)
  1986. + crypto_scomp_free_scratches();
  1987. mutex_unlock(&scomp_lock);
  1988. }
  1989. diff --git drivers/acpi/acpi_extlog.c drivers/acpi/acpi_extlog.c
  1990. index e05309bc41cc..e148b0a28ec9 100644
  1991. --- linux-4.14.336/drivers/acpi/acpi_extlog.c
  1992. +++ linux-4.14.336/drivers/acpi/acpi_extlog.c
  1993. @@ -317,9 +317,10 @@ static void __exit extlog_exit(void)
  1994. {
  1995. edac_set_report_status(old_edac_report_status);
  1996. mce_unregister_decode_chain(&extlog_mce_dec);
  1997. - ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
  1998. - if (extlog_l1_addr)
  1999. + if (extlog_l1_addr) {
  2000. + ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
  2001. acpi_os_unmap_iomem(extlog_l1_addr, l1_size);
  2002. + }
  2003. if (elog_addr)
  2004. acpi_os_unmap_iomem(elog_addr, elog_size);
  2005. release_mem_region(elog_base, elog_size);
  2006. diff --git drivers/acpi/acpi_video.c drivers/acpi/acpi_video.c
  2007. index cc228e5ad2b3..d426ece23a70 100644
  2008. --- linux-4.14.336/drivers/acpi/acpi_video.c
  2009. +++ linux-4.14.336/drivers/acpi/acpi_video.c
  2010. @@ -581,6 +581,15 @@ static const struct dmi_system_id video_dmi_table[] = {
  2011. DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3350"),
  2012. },
  2013. },
  2014. + {
  2015. + .callback = video_set_report_key_events,
  2016. + .driver_data = (void *)((uintptr_t)REPORT_BRIGHTNESS_KEY_EVENTS),
  2017. + .ident = "COLORFUL X15 AT 23",
  2018. + .matches = {
  2019. + DMI_MATCH(DMI_SYS_VENDOR, "COLORFUL"),
  2020. + DMI_MATCH(DMI_PRODUCT_NAME, "X15 AT 23"),
  2021. + },
  2022. + },
  2023. /*
  2024. * Some machines change the brightness themselves when a brightness
  2025. * hotkey gets pressed, despite us telling them not to. In this case
  2026. @@ -1796,12 +1805,12 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
  2027. return;
  2028. count++;
  2029. - acpi_get_parent(device->dev->handle, &acpi_parent);
  2030. -
  2031. - pdev = acpi_get_pci_dev(acpi_parent);
  2032. - if (pdev) {
  2033. - parent = &pdev->dev;
  2034. - pci_dev_put(pdev);
  2035. + if (ACPI_SUCCESS(acpi_get_parent(device->dev->handle, &acpi_parent))) {
  2036. + pdev = acpi_get_pci_dev(acpi_parent);
  2037. + if (pdev) {
  2038. + parent = &pdev->dev;
  2039. + pci_dev_put(pdev);
  2040. + }
  2041. }
  2042. memset(&props, 0, sizeof(struct backlight_properties));
  2043. diff --git drivers/android/binder_alloc.c drivers/android/binder_alloc.c
  2044. index f7f0b71c9f68..08f31fa30648 100644
  2045. --- linux-4.14.336/drivers/android/binder_alloc.c
  2046. +++ linux-4.14.336/drivers/android/binder_alloc.c
  2047. @@ -284,7 +284,7 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
  2048. }
  2049. if (mm) {
  2050. up_write(&mm->mmap_sem);
  2051. - mmput(mm);
  2052. + mmput_async(mm);
  2053. }
  2054. return 0;
  2055. @@ -319,7 +319,7 @@ err_page_ptr_cleared:
  2056. err_no_vma:
  2057. if (mm) {
  2058. up_write(&mm->mmap_sem);
  2059. - mmput(mm);
  2060. + mmput_async(mm);
  2061. }
  2062. return vma ? -ENOMEM : -ESRCH;
  2063. }
  2064. @@ -389,17 +389,17 @@ struct binder_buffer *binder_alloc_new_buf_locked(struct binder_alloc *alloc,
  2065. alloc->pid, extra_buffers_size);
  2066. return ERR_PTR(-EINVAL);
  2067. }
  2068. - if (is_async &&
  2069. - alloc->free_async_space < size + sizeof(struct binder_buffer)) {
  2070. +
  2071. + /* Pad 0-size buffers so they get assigned unique addresses */
  2072. + size = max(size, sizeof(void *));
  2073. +
  2074. + if (is_async && alloc->free_async_space < size) {
  2075. binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
  2076. "%d: binder_alloc_buf size %zd failed, no async space left\n",
  2077. alloc->pid, size);
  2078. return ERR_PTR(-ENOSPC);
  2079. }
  2080. - /* Pad 0-size buffers so they get assigned unique addresses */
  2081. - size = max(size, sizeof(void *));
  2082. -
  2083. while (n) {
  2084. buffer = rb_entry(n, struct binder_buffer, rb_node);
  2085. BUG_ON(!buffer->free);
  2086. @@ -496,7 +496,7 @@ struct binder_buffer *binder_alloc_new_buf_locked(struct binder_alloc *alloc,
  2087. buffer->async_transaction = is_async;
  2088. buffer->extra_buffers_size = extra_buffers_size;
  2089. if (is_async) {
  2090. - alloc->free_async_space -= size + sizeof(struct binder_buffer);
  2091. + alloc->free_async_space -= size;
  2092. binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC,
  2093. "%d: binder_alloc_buf size %zd async free %zd\n",
  2094. alloc->pid, size, alloc->free_async_space);
  2095. @@ -523,7 +523,7 @@ err_alloc_buf_struct_failed:
  2096. * is the sum of the three given sizes (each rounded up to
  2097. * pointer-sized boundary)
  2098. *
  2099. - * Return: The allocated buffer or %NULL if error
  2100. + * Return: The allocated buffer or %ERR_PTR(-errno) if error
  2101. */
  2102. struct binder_buffer *binder_alloc_new_buf(struct binder_alloc *alloc,
  2103. size_t data_size,
  2104. @@ -619,8 +619,7 @@ static void binder_free_buf_locked(struct binder_alloc *alloc,
  2105. BUG_ON(buffer->data > alloc->buffer + alloc->buffer_size);
  2106. if (buffer->async_transaction) {
  2107. - alloc->free_async_space += buffer_size + sizeof(struct binder_buffer);
  2108. -
  2109. + alloc->free_async_space += buffer_size;
  2110. binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC,
  2111. "%d: binder_free_buf size %zd async free %zd\n",
  2112. alloc->pid, size, alloc->free_async_space);
  2113. diff --git drivers/ata/ahci.c drivers/ata/ahci.c
  2114. index 5b810a290b93..c2e5ef709acb 100644
  2115. --- linux-4.14.336/drivers/ata/ahci.c
  2116. +++ linux-4.14.336/drivers/ata/ahci.c
  2117. @@ -605,6 +605,11 @@ MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)");
  2118. static void ahci_pci_save_initial_config(struct pci_dev *pdev,
  2119. struct ahci_host_priv *hpriv)
  2120. {
  2121. + if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && pdev->device == 0x1166) {
  2122. + dev_info(&pdev->dev, "ASM1166 has only six ports\n");
  2123. + hpriv->saved_port_map = 0x3f;
  2124. + }
  2125. +
  2126. if (pdev->vendor == PCI_VENDOR_ID_JMICRON && pdev->device == 0x2361) {
  2127. dev_info(&pdev->dev, "JMB361 has only one port\n");
  2128. hpriv->force_port_map = 1;
  2129. diff --git drivers/atm/idt77252.c drivers/atm/idt77252.c
  2130. index e7a6b4903f9c..c777973f0ff3 100644
  2131. --- linux-4.14.336/drivers/atm/idt77252.c
  2132. +++ linux-4.14.336/drivers/atm/idt77252.c
  2133. @@ -2933,6 +2933,8 @@ open_card_ubr0(struct idt77252_dev *card)
  2134. vc->scq = alloc_scq(card, vc->class);
  2135. if (!vc->scq) {
  2136. printk("%s: can't get SCQ.\n", card->name);
  2137. + kfree(card->vcs[0]);
  2138. + card->vcs[0] = NULL;
  2139. return -ENOMEM;
  2140. }
  2141. diff --git drivers/base/core.c drivers/base/core.c
  2142. index e834087448a4..4f1ac622df06 100644
  2143. --- linux-4.14.336/drivers/base/core.c
  2144. +++ linux-4.14.336/drivers/base/core.c
  2145. @@ -3075,6 +3075,50 @@ define_dev_printk_level(_dev_info, KERN_INFO);
  2146. #endif
  2147. +/**
  2148. + * dev_err_probe - probe error check and log helper
  2149. + * @dev: the pointer to the struct device
  2150. + * @err: error value to test
  2151. + * @fmt: printf-style format string
  2152. + * @...: arguments as specified in the format string
  2153. + *
  2154. + * This helper implements common pattern present in probe functions for error
  2155. + * checking: print debug or error message depending if the error value is
  2156. + * -EPROBE_DEFER and propagate error upwards.
  2157. + * It replaces code sequence::
  2158. + * if (err != -EPROBE_DEFER)
  2159. + * dev_err(dev, ...);
  2160. + * else
  2161. + * dev_dbg(dev, ...);
  2162. + * return err;
  2163. + *
  2164. + * with::
  2165. + *
  2166. + * return dev_err_probe(dev, err, ...);
  2167. + *
  2168. + * Returns @err.
  2169. + *
  2170. + */
  2171. +int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
  2172. +{
  2173. + struct va_format vaf;
  2174. + va_list args;
  2175. +
  2176. + va_start(args, fmt);
  2177. + vaf.fmt = fmt;
  2178. + vaf.va = &args;
  2179. +
  2180. + if (err != -EPROBE_DEFER)
  2181. + dev_err(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
  2182. + else
  2183. + dev_dbg(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
  2184. +
  2185. + va_end(args);
  2186. +
  2187. + return err;
  2188. +}
  2189. +EXPORT_SYMBOL_GPL(dev_err_probe);
  2190. +
  2191. static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
  2192. {
  2193. return fwnode && !IS_ERR(fwnode->secondary);
  2194. diff --git drivers/base/power/domain.c drivers/base/power/domain.c
  2195. index 0f38df5856e1..a469fb4badf2 100644
  2196. --- linux-4.14.336/drivers/base/power/domain.c
  2197. +++ linux-4.14.336/drivers/base/power/domain.c
  2198. @@ -749,7 +749,7 @@ static int __init genpd_power_off_unused(void)
  2199. return 0;
  2200. }
  2201. -late_initcall(genpd_power_off_unused);
  2202. +late_initcall_sync(genpd_power_off_unused);
  2203. #if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_GENERIC_DOMAINS_OF)
  2204. diff --git drivers/block/virtio_blk.c drivers/block/virtio_blk.c
  2205. index 7e8f58c2f65b..2d3484a83fd7 100644
  2206. --- linux-4.14.336/drivers/block/virtio_blk.c
  2207. +++ linux-4.14.336/drivers/block/virtio_blk.c
  2208. @@ -930,14 +930,15 @@ static int virtblk_freeze(struct virtio_device *vdev)
  2209. {
  2210. struct virtio_blk *vblk = vdev->priv;
  2211. + /* Ensure no requests in virtqueues before deleting vqs. */
  2212. + blk_mq_freeze_queue(vblk->disk->queue);
  2213. +
  2214. /* Ensure we don't receive any more interrupts */
  2215. vdev->config->reset(vdev);
  2216. /* Make sure no work handler is accessing the device. */
  2217. flush_work(&vblk->config_work);
  2218. - blk_mq_quiesce_queue(vblk->disk->queue);
  2219. -
  2220. vdev->config->del_vqs(vdev);
  2221. kfree(vblk->vqs);
  2222. @@ -955,7 +956,7 @@ static int virtblk_restore(struct virtio_device *vdev)
  2223. virtio_device_ready(vdev);
  2224. - blk_mq_unquiesce_queue(vblk->disk->queue);
  2225. + blk_mq_unfreeze_queue(vblk->disk->queue);
  2226. return 0;
  2227. }
  2228. #endif
  2229. diff --git drivers/char/hw_random/core.c drivers/char/hw_random/core.c
  2230. index 303fd55f9be0..a12561fdd2f0 100644
  2231. --- linux-4.14.336/drivers/char/hw_random/core.c
  2232. +++ linux-4.14.336/drivers/char/hw_random/core.c
  2233. @@ -24,10 +24,13 @@
  2234. #include <linux/random.h>
  2235. #include <linux/sched.h>
  2236. #include <linux/slab.h>
  2237. +#include <linux/string.h>
  2238. #include <linux/uaccess.h>
  2239. #define RNG_MODULE_NAME "hw_random"
  2240. +#define RNG_BUFFER_SIZE (SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES)
  2241. +
  2242. static struct hwrng *current_rng;
  2243. /* the current rng has been explicitly chosen by user via sysfs */
  2244. static int cur_rng_set_by_user;
  2245. @@ -59,7 +62,7 @@ static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size,
  2246. static size_t rng_buffer_size(void)
  2247. {
  2248. - return SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES;
  2249. + return RNG_BUFFER_SIZE;
  2250. }
  2251. static void add_early_randomness(struct hwrng *rng)
  2252. @@ -202,6 +205,7 @@ static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size,
  2253. static ssize_t rng_dev_read(struct file *filp, char __user *buf,
  2254. size_t size, loff_t *offp)
  2255. {
  2256. + u8 buffer[RNG_BUFFER_SIZE];
  2257. ssize_t ret = 0;
  2258. int err = 0;
  2259. int bytes_read, len;
  2260. @@ -229,34 +233,37 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf,
  2261. if (bytes_read < 0) {
  2262. err = bytes_read;
  2263. goto out_unlock_reading;
  2264. + } else if (bytes_read == 0 &&
  2265. + (filp->f_flags & O_NONBLOCK)) {
  2266. + err = -EAGAIN;
  2267. + goto out_unlock_reading;
  2268. }
  2269. +
  2270. data_avail = bytes_read;
  2271. }
  2272. - if (!data_avail) {
  2273. - if (filp->f_flags & O_NONBLOCK) {
  2274. - err = -EAGAIN;
  2275. - goto out_unlock_reading;
  2276. - }
  2277. - } else {
  2278. - len = data_avail;
  2279. + len = data_avail;
  2280. + if (len) {
  2281. if (len > size)
  2282. len = size;
  2283. data_avail -= len;
  2284. - if (copy_to_user(buf + ret, rng_buffer + data_avail,
  2285. - len)) {
  2286. + memcpy(buffer, rng_buffer + data_avail, len);
  2287. + }
  2288. + mutex_unlock(&reading_mutex);
  2289. + put_rng(rng);
  2290. +
  2291. + if (len) {
  2292. + if (copy_to_user(buf + ret, buffer, len)) {
  2293. err = -EFAULT;
  2294. - goto out_unlock_reading;
  2295. + goto out;
  2296. }
  2297. size -= len;
  2298. ret += len;
  2299. }
  2300. - mutex_unlock(&reading_mutex);
  2301. - put_rng(rng);
  2302. if (need_resched())
  2303. schedule_timeout_interruptible(1);
  2304. @@ -267,6 +274,7 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf,
  2305. }
  2306. }
  2307. out:
  2308. + memzero_explicit(buffer, sizeof(buffer));
  2309. return ret ? : err;
  2310. out_unlock_reading:
  2311. diff --git drivers/clk/hisilicon/clk-hi3620.c drivers/clk/hisilicon/clk-hi3620.c
  2312. index fa0fba653898..7f49c7067028 100644
  2313. --- linux-4.14.336/drivers/clk/hisilicon/clk-hi3620.c
  2314. +++ linux-4.14.336/drivers/clk/hisilicon/clk-hi3620.c
  2315. @@ -481,8 +481,10 @@ static void __init hi3620_mmc_clk_init(struct device_node *node)
  2316. return;
  2317. clk_data->clks = kcalloc(num, sizeof(*clk_data->clks), GFP_KERNEL);
  2318. - if (!clk_data->clks)
  2319. + if (!clk_data->clks) {
  2320. + kfree(clk_data);
  2321. return;
  2322. + }
  2323. for (i = 0; i < num; i++) {
  2324. struct hisi_mmc_clock *mmc_clk = &hi3620_mmc_clks[i];
  2325. diff --git drivers/clk/mmp/clk-of-pxa168.c drivers/clk/mmp/clk-of-pxa168.c
  2326. index f110c02e83cb..9674c6c06dca 100644
  2327. --- linux-4.14.336/drivers/clk/mmp/clk-of-pxa168.c
  2328. +++ linux-4.14.336/drivers/clk/mmp/clk-of-pxa168.c
  2329. @@ -258,18 +258,21 @@ static void __init pxa168_clk_init(struct device_node *np)
  2330. pxa_unit->mpmu_base = of_iomap(np, 0);
  2331. if (!pxa_unit->mpmu_base) {
  2332. pr_err("failed to map mpmu registers\n");
  2333. + kfree(pxa_unit);
  2334. return;
  2335. }
  2336. pxa_unit->apmu_base = of_iomap(np, 1);
  2337. if (!pxa_unit->apmu_base) {
  2338. pr_err("failed to map apmu registers\n");
  2339. + kfree(pxa_unit);
  2340. return;
  2341. }
  2342. pxa_unit->apbc_base = of_iomap(np, 2);
  2343. if (!pxa_unit->apbc_base) {
  2344. pr_err("failed to map apbc registers\n");
  2345. + kfree(pxa_unit);
  2346. return;
  2347. }
  2348. diff --git drivers/clk/rockchip/clk-rk3128.c drivers/clk/rockchip/clk-rk3128.c
  2349. index 5970a50671b9..83c7eb18321f 100644
  2350. --- linux-4.14.336/drivers/clk/rockchip/clk-rk3128.c
  2351. +++ linux-4.14.336/drivers/clk/rockchip/clk-rk3128.c
  2352. @@ -497,7 +497,7 @@ static struct rockchip_clk_branch common_clk_branches[] __initdata = {
  2353. GATE(HCLK_I2S_2CH, "hclk_i2s_2ch", "hclk_peri", 0, RK2928_CLKGATE_CON(7), 2, GFLAGS),
  2354. GATE(0, "hclk_usb_peri", "hclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(9), 13, GFLAGS),
  2355. GATE(HCLK_HOST2, "hclk_host2", "hclk_peri", 0, RK2928_CLKGATE_CON(7), 3, GFLAGS),
  2356. - GATE(HCLK_OTG, "hclk_otg", "hclk_peri", 0, RK2928_CLKGATE_CON(3), 13, GFLAGS),
  2357. + GATE(HCLK_OTG, "hclk_otg", "hclk_peri", 0, RK2928_CLKGATE_CON(5), 13, GFLAGS),
  2358. GATE(0, "hclk_peri_ahb", "hclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(9), 14, GFLAGS),
  2359. GATE(HCLK_SPDIF, "hclk_spdif", "hclk_peri", 0, RK2928_CLKGATE_CON(10), 9, GFLAGS),
  2360. GATE(HCLK_TSP, "hclk_tsp", "hclk_peri", 0, RK2928_CLKGATE_CON(10), 12, GFLAGS),
  2361. diff --git drivers/crypto/ccp/ccp-ops.c drivers/crypto/ccp/ccp-ops.c
  2362. index 453d27d2a4ff..56c571370486 100644
  2363. --- linux-4.14.336/drivers/crypto/ccp/ccp-ops.c
  2364. +++ linux-4.14.336/drivers/crypto/ccp/ccp-ops.c
  2365. @@ -183,8 +183,11 @@ static int ccp_init_dm_workarea(struct ccp_dm_workarea *wa,
  2366. wa->dma.address = dma_map_single(wa->dev, wa->address, len,
  2367. dir);
  2368. - if (dma_mapping_error(wa->dev, wa->dma.address))
  2369. + if (dma_mapping_error(wa->dev, wa->dma.address)) {
  2370. + kfree(wa->address);
  2371. + wa->address = NULL;
  2372. return -ENOMEM;
  2373. + }
  2374. wa->dma.length = len;
  2375. }
  2376. diff --git drivers/crypto/sahara.c drivers/crypto/sahara.c
  2377. index 085c229eab1d..fdc9db6c0d5e 100644
  2378. --- linux-4.14.336/drivers/crypto/sahara.c
  2379. +++ linux-4.14.336/drivers/crypto/sahara.c
  2380. @@ -46,7 +46,6 @@
  2381. #define FLAGS_MODE_MASK 0x000f
  2382. #define FLAGS_ENCRYPT BIT(0)
  2383. #define FLAGS_CBC BIT(1)
  2384. -#define FLAGS_NEW_KEY BIT(3)
  2385. #define SAHARA_HDR_BASE 0x00800000
  2386. #define SAHARA_HDR_SKHA_ALG_AES 0
  2387. @@ -144,8 +143,6 @@ struct sahara_hw_link {
  2388. };
  2389. struct sahara_ctx {
  2390. - unsigned long flags;
  2391. -
  2392. /* AES-specific context */
  2393. int keylen;
  2394. u8 key[AES_KEYSIZE_128];
  2395. @@ -448,27 +445,24 @@ static int sahara_hw_descriptor_create(struct sahara_dev *dev)
  2396. int ret;
  2397. int i, j;
  2398. int idx = 0;
  2399. + u32 len;
  2400. - /* Copy new key if necessary */
  2401. - if (ctx->flags & FLAGS_NEW_KEY) {
  2402. - memcpy(dev->key_base, ctx->key, ctx->keylen);
  2403. - ctx->flags &= ~FLAGS_NEW_KEY;
  2404. + memcpy(dev->key_base, ctx->key, ctx->keylen);
  2405. - if (dev->flags & FLAGS_CBC) {
  2406. - dev->hw_desc[idx]->len1 = AES_BLOCK_SIZE;
  2407. - dev->hw_desc[idx]->p1 = dev->iv_phys_base;
  2408. - } else {
  2409. - dev->hw_desc[idx]->len1 = 0;
  2410. - dev->hw_desc[idx]->p1 = 0;
  2411. - }
  2412. - dev->hw_desc[idx]->len2 = ctx->keylen;
  2413. - dev->hw_desc[idx]->p2 = dev->key_phys_base;
  2414. - dev->hw_desc[idx]->next = dev->hw_phys_desc[1];
  2415. + if (dev->flags & FLAGS_CBC) {
  2416. + dev->hw_desc[idx]->len1 = AES_BLOCK_SIZE;
  2417. + dev->hw_desc[idx]->p1 = dev->iv_phys_base;
  2418. + } else {
  2419. + dev->hw_desc[idx]->len1 = 0;
  2420. + dev->hw_desc[idx]->p1 = 0;
  2421. + }
  2422. + dev->hw_desc[idx]->len2 = ctx->keylen;
  2423. + dev->hw_desc[idx]->p2 = dev->key_phys_base;
  2424. + dev->hw_desc[idx]->next = dev->hw_phys_desc[1];
  2425. + dev->hw_desc[idx]->hdr = sahara_aes_key_hdr(dev);
  2426. - dev->hw_desc[idx]->hdr = sahara_aes_key_hdr(dev);
  2427. + idx++;
  2428. - idx++;
  2429. - }
  2430. dev->nb_in_sg = sg_nents_for_len(dev->in_sg, dev->total);
  2431. if (dev->nb_in_sg < 0) {
  2432. @@ -490,24 +484,27 @@ static int sahara_hw_descriptor_create(struct sahara_dev *dev)
  2433. DMA_TO_DEVICE);
  2434. if (ret != dev->nb_in_sg) {
  2435. dev_err(dev->device, "couldn't map in sg\n");
  2436. - goto unmap_in;
  2437. + return -EINVAL;
  2438. }
  2439. +
  2440. ret = dma_map_sg(dev->device, dev->out_sg, dev->nb_out_sg,
  2441. DMA_FROM_DEVICE);
  2442. if (ret != dev->nb_out_sg) {
  2443. dev_err(dev->device, "couldn't map out sg\n");
  2444. - goto unmap_out;
  2445. + goto unmap_in;
  2446. }
  2447. /* Create input links */
  2448. dev->hw_desc[idx]->p1 = dev->hw_phys_link[0];
  2449. sg = dev->in_sg;
  2450. + len = dev->total;
  2451. for (i = 0; i < dev->nb_in_sg; i++) {
  2452. - dev->hw_link[i]->len = sg->length;
  2453. + dev->hw_link[i]->len = min(len, sg->length);
  2454. dev->hw_link[i]->p = sg->dma_address;
  2455. if (i == (dev->nb_in_sg - 1)) {
  2456. dev->hw_link[i]->next = 0;
  2457. } else {
  2458. + len -= min(len, sg->length);
  2459. dev->hw_link[i]->next = dev->hw_phys_link[i + 1];
  2460. sg = sg_next(sg);
  2461. }
  2462. @@ -516,12 +513,14 @@ static int sahara_hw_descriptor_create(struct sahara_dev *dev)
  2463. /* Create output links */
  2464. dev->hw_desc[idx]->p2 = dev->hw_phys_link[i];
  2465. sg = dev->out_sg;
  2466. + len = dev->total;
  2467. for (j = i; j < dev->nb_out_sg + i; j++) {
  2468. - dev->hw_link[j]->len = sg->length;
  2469. + dev->hw_link[j]->len = min(len, sg->length);
  2470. dev->hw_link[j]->p = sg->dma_address;
  2471. if (j == (dev->nb_out_sg + i - 1)) {
  2472. dev->hw_link[j]->next = 0;
  2473. } else {
  2474. + len -= min(len, sg->length);
  2475. dev->hw_link[j]->next = dev->hw_phys_link[j + 1];
  2476. sg = sg_next(sg);
  2477. }
  2478. @@ -540,9 +539,6 @@ static int sahara_hw_descriptor_create(struct sahara_dev *dev)
  2479. return 0;
  2480. -unmap_out:
  2481. - dma_unmap_sg(dev->device, dev->out_sg, dev->nb_out_sg,
  2482. - DMA_FROM_DEVICE);
  2483. unmap_in:
  2484. dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
  2485. DMA_TO_DEVICE);
  2486. @@ -587,16 +583,17 @@ static int sahara_aes_process(struct ablkcipher_request *req)
  2487. timeout = wait_for_completion_timeout(&dev->dma_completion,
  2488. msecs_to_jiffies(SAHARA_TIMEOUT_MS));
  2489. - if (!timeout) {
  2490. - dev_err(dev->device, "AES timeout\n");
  2491. - return -ETIMEDOUT;
  2492. - }
  2493. dma_unmap_sg(dev->device, dev->out_sg, dev->nb_out_sg,
  2494. DMA_FROM_DEVICE);
  2495. dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
  2496. DMA_TO_DEVICE);
  2497. + if (!timeout) {
  2498. + dev_err(dev->device, "AES timeout\n");
  2499. + return -ETIMEDOUT;
  2500. + }
  2501. +
  2502. return 0;
  2503. }
  2504. @@ -611,7 +608,6 @@ static int sahara_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
  2505. /* SAHARA only supports 128bit keys */
  2506. if (keylen == AES_KEYSIZE_128) {
  2507. memcpy(ctx->key, key, keylen);
  2508. - ctx->flags |= FLAGS_NEW_KEY;
  2509. return 0;
  2510. }
  2511. @@ -800,6 +796,7 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev,
  2512. int start)
  2513. {
  2514. struct scatterlist *sg;
  2515. + unsigned int len;
  2516. unsigned int i;
  2517. int ret;
  2518. @@ -821,12 +818,14 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev,
  2519. if (!ret)
  2520. return -EFAULT;
  2521. + len = rctx->total;
  2522. for (i = start; i < dev->nb_in_sg + start; i++) {
  2523. - dev->hw_link[i]->len = sg->length;
  2524. + dev->hw_link[i]->len = min(len, sg->length);
  2525. dev->hw_link[i]->p = sg->dma_address;
  2526. if (i == (dev->nb_in_sg + start - 1)) {
  2527. dev->hw_link[i]->next = 0;
  2528. } else {
  2529. + len -= min(len, sg->length);
  2530. dev->hw_link[i]->next = dev->hw_phys_link[i + 1];
  2531. sg = sg_next(sg);
  2532. }
  2533. @@ -907,24 +906,6 @@ static int sahara_sha_hw_context_descriptor_create(struct sahara_dev *dev,
  2534. return 0;
  2535. }
  2536. -static int sahara_walk_and_recalc(struct scatterlist *sg, unsigned int nbytes)
  2537. -{
  2538. - if (!sg || !sg->length)
  2539. - return nbytes;
  2540. -
  2541. - while (nbytes && sg) {
  2542. - if (nbytes <= sg->length) {
  2543. - sg->length = nbytes;
  2544. - sg_mark_end(sg);
  2545. - break;
  2546. - }
  2547. - nbytes -= sg->length;
  2548. - sg = sg_next(sg);
  2549. - }
  2550. -
  2551. - return nbytes;
  2552. -}
  2553. -
  2554. static int sahara_sha_prepare_request(struct ahash_request *req)
  2555. {
  2556. struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  2557. @@ -961,36 +942,20 @@ static int sahara_sha_prepare_request(struct ahash_request *req)
  2558. hash_later, 0);
  2559. }
  2560. - /* nbytes should now be multiple of blocksize */
  2561. - req->nbytes = req->nbytes - hash_later;
  2562. -
  2563. - sahara_walk_and_recalc(req->src, req->nbytes);
  2564. -
  2565. + rctx->total = len - hash_later;
  2566. /* have data from previous operation and current */
  2567. if (rctx->buf_cnt && req->nbytes) {
  2568. sg_init_table(rctx->in_sg_chain, 2);
  2569. sg_set_buf(rctx->in_sg_chain, rctx->rembuf, rctx->buf_cnt);
  2570. -
  2571. sg_chain(rctx->in_sg_chain, 2, req->src);
  2572. -
  2573. - rctx->total = req->nbytes + rctx->buf_cnt;
  2574. rctx->in_sg = rctx->in_sg_chain;
  2575. -
  2576. - req->src = rctx->in_sg_chain;
  2577. /* only data from previous operation */
  2578. } else if (rctx->buf_cnt) {
  2579. - if (req->src)
  2580. - rctx->in_sg = req->src;
  2581. - else
  2582. - rctx->in_sg = rctx->in_sg_chain;
  2583. - /* buf was copied into rembuf above */
  2584. + rctx->in_sg = rctx->in_sg_chain;
  2585. sg_init_one(rctx->in_sg, rctx->rembuf, rctx->buf_cnt);
  2586. - rctx->total = rctx->buf_cnt;
  2587. /* no data from previous operation */
  2588. } else {
  2589. rctx->in_sg = req->src;
  2590. - rctx->total = req->nbytes;
  2591. - req->src = rctx->in_sg;
  2592. }
  2593. /* on next call, we only have the remaining data in the buffer */
  2594. @@ -1011,7 +976,10 @@ static int sahara_sha_process(struct ahash_request *req)
  2595. return ret;
  2596. if (rctx->first) {
  2597. - sahara_sha_hw_data_descriptor_create(dev, rctx, req, 0);
  2598. + ret = sahara_sha_hw_data_descriptor_create(dev, rctx, req, 0);
  2599. + if (ret)
  2600. + return ret;
  2601. +
  2602. dev->hw_desc[0]->next = 0;
  2603. rctx->first = 0;
  2604. } else {
  2605. @@ -1019,7 +987,10 @@ static int sahara_sha_process(struct ahash_request *req)
  2606. sahara_sha_hw_context_descriptor_create(dev, rctx, req, 0);
  2607. dev->hw_desc[0]->next = dev->hw_phys_desc[1];
  2608. - sahara_sha_hw_data_descriptor_create(dev, rctx, req, 1);
  2609. + ret = sahara_sha_hw_data_descriptor_create(dev, rctx, req, 1);
  2610. + if (ret)
  2611. + return ret;
  2612. +
  2613. dev->hw_desc[1]->next = 0;
  2614. }
  2615. @@ -1032,18 +1003,19 @@ static int sahara_sha_process(struct ahash_request *req)
  2616. timeout = wait_for_completion_timeout(&dev->dma_completion,
  2617. msecs_to_jiffies(SAHARA_TIMEOUT_MS));
  2618. - if (!timeout) {
  2619. - dev_err(dev->device, "SHA timeout\n");
  2620. - return -ETIMEDOUT;
  2621. - }
  2622. if (rctx->sg_in_idx)
  2623. dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
  2624. DMA_TO_DEVICE);
  2625. + if (!timeout) {
  2626. + dev_err(dev->device, "SHA timeout\n");
  2627. + return -ETIMEDOUT;
  2628. + }
  2629. +
  2630. memcpy(rctx->context, dev->context_base, rctx->context_size);
  2631. - if (req->result)
  2632. + if (req->result && rctx->last)
  2633. memcpy(req->result, rctx->context, rctx->digest_size);
  2634. return 0;
  2635. @@ -1187,8 +1159,7 @@ static int sahara_sha_import(struct ahash_request *req, const void *in)
  2636. static int sahara_sha_cra_init(struct crypto_tfm *tfm)
  2637. {
  2638. crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
  2639. - sizeof(struct sahara_sha_reqctx) +
  2640. - SHA_BUFFER_LEN + SHA256_BLOCK_SIZE);
  2641. + sizeof(struct sahara_sha_reqctx));
  2642. return 0;
  2643. }
  2644. diff --git drivers/crypto/virtio/virtio_crypto_common.h drivers/crypto/virtio/virtio_crypto_common.h
  2645. index e976539a05d9..d8be210a07ec 100644
  2646. --- linux-4.14.336/drivers/crypto/virtio/virtio_crypto_common.h
  2647. +++ linux-4.14.336/drivers/crypto/virtio/virtio_crypto_common.h
  2648. @@ -22,6 +22,7 @@
  2649. #include <linux/virtio.h>
  2650. #include <linux/crypto.h>
  2651. #include <linux/spinlock.h>
  2652. +#include <linux/interrupt.h>
  2653. #include <crypto/aead.h>
  2654. #include <crypto/aes.h>
  2655. #include <crypto/authenc.h>
  2656. @@ -40,6 +41,7 @@ struct data_queue {
  2657. char name[32];
  2658. struct crypto_engine *engine;
  2659. + struct tasklet_struct done_task;
  2660. };
  2661. struct virtio_crypto {
  2662. diff --git drivers/crypto/virtio/virtio_crypto_core.c drivers/crypto/virtio/virtio_crypto_core.c
  2663. index ff1410a32c2b..e21dd216989f 100644
  2664. --- linux-4.14.336/drivers/crypto/virtio/virtio_crypto_core.c
  2665. +++ linux-4.14.336/drivers/crypto/virtio/virtio_crypto_core.c
  2666. @@ -34,27 +34,28 @@ virtcrypto_clear_request(struct virtio_crypto_request *vc_req)
  2667. }
  2668. }
  2669. -static void virtcrypto_dataq_callback(struct virtqueue *vq)
  2670. +static void virtcrypto_done_task(unsigned long data)
  2671. {
  2672. - struct virtio_crypto *vcrypto = vq->vdev->priv;
  2673. + struct data_queue *data_vq = (struct data_queue *)data;
  2674. + struct virtqueue *vq = data_vq->vq;
  2675. struct virtio_crypto_request *vc_req;
  2676. - unsigned long flags;
  2677. unsigned int len;
  2678. - unsigned int qid = vq->index;
  2679. - spin_lock_irqsave(&vcrypto->data_vq[qid].lock, flags);
  2680. do {
  2681. virtqueue_disable_cb(vq);
  2682. while ((vc_req = virtqueue_get_buf(vq, &len)) != NULL) {
  2683. - spin_unlock_irqrestore(
  2684. - &vcrypto->data_vq[qid].lock, flags);
  2685. if (vc_req->alg_cb)
  2686. vc_req->alg_cb(vc_req, len);
  2687. - spin_lock_irqsave(
  2688. - &vcrypto->data_vq[qid].lock, flags);
  2689. }
  2690. } while (!virtqueue_enable_cb(vq));
  2691. - spin_unlock_irqrestore(&vcrypto->data_vq[qid].lock, flags);
  2692. +}
  2693. +
  2694. +static void virtcrypto_dataq_callback(struct virtqueue *vq)
  2695. +{
  2696. + struct virtio_crypto *vcrypto = vq->vdev->priv;
  2697. + struct data_queue *dq = &vcrypto->data_vq[vq->index];
  2698. +
  2699. + tasklet_schedule(&dq->done_task);
  2700. }
  2701. static int virtcrypto_find_vqs(struct virtio_crypto *vi)
  2702. @@ -114,6 +115,8 @@ static int virtcrypto_find_vqs(struct virtio_crypto *vi)
  2703. vi->data_vq[i].engine->cipher_one_request =
  2704. virtio_crypto_ablkcipher_crypt_req;
  2705. + tasklet_init(&vi->data_vq[i].done_task, virtcrypto_done_task,
  2706. + (unsigned long)&vi->data_vq[i]);
  2707. }
  2708. kfree(names);
  2709. @@ -417,11 +420,14 @@ static void virtcrypto_free_unused_reqs(struct virtio_crypto *vcrypto)
  2710. static void virtcrypto_remove(struct virtio_device *vdev)
  2711. {
  2712. struct virtio_crypto *vcrypto = vdev->priv;
  2713. + int i;
  2714. dev_info(&vdev->dev, "Start virtcrypto_remove.\n");
  2715. if (virtcrypto_dev_started(vcrypto))
  2716. virtcrypto_dev_stop(vcrypto);
  2717. + for (i = 0; i < vcrypto->max_data_queues; i++)
  2718. + tasklet_kill(&vcrypto->data_vq[i].done_task);
  2719. vdev->config->reset(vdev);
  2720. virtcrypto_free_unused_reqs(vcrypto);
  2721. virtcrypto_clear_crypto_engines(vcrypto);
  2722. diff --git drivers/dma/sh/shdma.h drivers/dma/sh/shdma.h
  2723. index 2c0a969adc9f..35987a35a848 100644
  2724. --- linux-4.14.336/drivers/dma/sh/shdma.h
  2725. +++ linux-4.14.336/drivers/dma/sh/shdma.h
  2726. @@ -29,7 +29,7 @@ struct sh_dmae_chan {
  2727. const struct sh_dmae_slave_config *config; /* Slave DMA configuration */
  2728. int xmit_shift; /* log_2(bytes_per_xfer) */
  2729. void __iomem *base;
  2730. - char dev_id[16]; /* unique name per DMAC of channel */
  2731. + char dev_id[32]; /* unique name per DMAC of channel */
  2732. int pm_error;
  2733. dma_addr_t slave_addr;
  2734. };
  2735. diff --git drivers/edac/thunderx_edac.c drivers/edac/thunderx_edac.c
  2736. index dfefa39e9351..bc9ecc6c0573 100644
  2737. --- linux-4.14.336/drivers/edac/thunderx_edac.c
  2738. +++ linux-4.14.336/drivers/edac/thunderx_edac.c
  2739. @@ -1154,7 +1154,7 @@ static irqreturn_t thunderx_ocx_com_threaded_isr(int irq, void *irq_id)
  2740. decode_register(other, OCX_OTHER_SIZE,
  2741. ocx_com_errors, ctx->reg_com_int);
  2742. - strncat(msg, other, OCX_MESSAGE_SIZE);
  2743. + strlcat(msg, other, OCX_MESSAGE_SIZE);
  2744. for (lane = 0; lane < OCX_RX_LANES; lane++)
  2745. if (ctx->reg_com_int & BIT(lane)) {
  2746. @@ -1163,12 +1163,12 @@ static irqreturn_t thunderx_ocx_com_threaded_isr(int irq, void *irq_id)
  2747. lane, ctx->reg_lane_int[lane],
  2748. lane, ctx->reg_lane_stat11[lane]);
  2749. - strncat(msg, other, OCX_MESSAGE_SIZE);
  2750. + strlcat(msg, other, OCX_MESSAGE_SIZE);
  2751. decode_register(other, OCX_OTHER_SIZE,
  2752. ocx_lane_errors,
  2753. ctx->reg_lane_int[lane]);
  2754. - strncat(msg, other, OCX_MESSAGE_SIZE);
  2755. + strlcat(msg, other, OCX_MESSAGE_SIZE);
  2756. }
  2757. if (ctx->reg_com_int & OCX_COM_INT_CE)
  2758. @@ -1238,7 +1238,7 @@ static irqreturn_t thunderx_ocx_lnk_threaded_isr(int irq, void *irq_id)
  2759. decode_register(other, OCX_OTHER_SIZE,
  2760. ocx_com_link_errors, ctx->reg_com_link_int);
  2761. - strncat(msg, other, OCX_MESSAGE_SIZE);
  2762. + strlcat(msg, other, OCX_MESSAGE_SIZE);
  2763. if (ctx->reg_com_link_int & OCX_COM_LINK_INT_UE)
  2764. edac_device_handle_ue(ocx->edac_dev, 0, 0, msg);
  2765. @@ -1917,7 +1917,7 @@ static irqreturn_t thunderx_l2c_threaded_isr(int irq, void *irq_id)
  2766. decode_register(other, L2C_OTHER_SIZE, l2_errors, ctx->reg_int);
  2767. - strncat(msg, other, L2C_MESSAGE_SIZE);
  2768. + strlcat(msg, other, L2C_MESSAGE_SIZE);
  2769. if (ctx->reg_int & mask_ue)
  2770. edac_device_handle_ue(l2c->edac_dev, 0, 0, msg);
  2771. diff --git drivers/firewire/core-card.c drivers/firewire/core-card.c
  2772. index 11c634125c7d..0e6f96c0e395 100644
  2773. --- linux-4.14.336/drivers/firewire/core-card.c
  2774. +++ linux-4.14.336/drivers/firewire/core-card.c
  2775. @@ -442,7 +442,23 @@ static void bm_work(struct work_struct *work)
  2776. */
  2777. card->bm_generation = generation;
  2778. - if (root_device == NULL) {
  2779. + if (card->gap_count == 0) {
  2780. + /*
  2781. + * If self IDs have inconsistent gap counts, do a
  2782. + * bus reset ASAP. The config rom read might never
  2783. + * complete, so don't wait for it. However, still
  2784. + * send a PHY configuration packet prior to the
  2785. + * bus reset. The PHY configuration packet might
  2786. + * fail, but 1394-2008 8.4.5.2 explicitly permits
  2787. + * it in this case, so it should be safe to try.
  2788. + */
  2789. + new_root_id = local_id;
  2790. + /*
  2791. + * We must always send a bus reset if the gap count
  2792. + * is inconsistent, so bypass the 5-reset limit.
  2793. + */
  2794. + card->bm_retries = 0;
  2795. + } else if (root_device == NULL) {
  2796. /*
  2797. * Either link_on is false, or we failed to read the
  2798. * config rom. In either case, pick another root.
  2799. diff --git drivers/firewire/core-device.c drivers/firewire/core-device.c
  2800. index a293b39fd4ce..25c5de074525 100644
  2801. --- linux-4.14.336/drivers/firewire/core-device.c
  2802. +++ linux-4.14.336/drivers/firewire/core-device.c
  2803. @@ -113,10 +113,9 @@ static int textual_leaf_to_string(const u32 *block, char *buf, size_t size)
  2804. * @buf: where to put the string
  2805. * @size: size of @buf, in bytes
  2806. *
  2807. - * The string is taken from a minimal ASCII text descriptor leaf after
  2808. - * the immediate entry with @key. The string is zero-terminated.
  2809. - * An overlong string is silently truncated such that it and the
  2810. - * zero byte fit into @size.
  2811. + * The string is taken from a minimal ASCII text descriptor leaf just after the entry with the
  2812. + * @key. The string is zero-terminated. An overlong string is silently truncated such that it
  2813. + * and the zero byte fit into @size.
  2814. *
  2815. * Returns strlen(buf) or a negative error code.
  2816. */
  2817. diff --git drivers/firmware/efi/capsule-loader.c drivers/firmware/efi/capsule-loader.c
  2818. index 539825a17959..fa36bbdb9ca7 100644
  2819. --- linux-4.14.336/drivers/firmware/efi/capsule-loader.c
  2820. +++ linux-4.14.336/drivers/firmware/efi/capsule-loader.c
  2821. @@ -287,7 +287,7 @@ static int efi_capsule_open(struct inode *inode, struct file *file)
  2822. return -ENOMEM;
  2823. }
  2824. - cap_info->phys = kzalloc(sizeof(void *), GFP_KERNEL);
  2825. + cap_info->phys = kzalloc(sizeof(phys_addr_t), GFP_KERNEL);
  2826. if (!cap_info->phys) {
  2827. kfree(cap_info->pages);
  2828. kfree(cap_info);
  2829. diff --git drivers/firmware/ti_sci.c drivers/firmware/ti_sci.c
  2830. index dd677fc4578a..7ac5a8bd05c4 100644
  2831. --- linux-4.14.336/drivers/firmware/ti_sci.c
  2832. +++ linux-4.14.336/drivers/firmware/ti_sci.c
  2833. @@ -184,7 +184,7 @@ static int ti_sci_debugfs_create(struct platform_device *pdev,
  2834. {
  2835. struct device *dev = &pdev->dev;
  2836. struct resource *res;
  2837. - char debug_name[50] = "ti_sci_debug@";
  2838. + char debug_name[50];
  2839. /* Debug region is optional */
  2840. res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
  2841. @@ -201,10 +201,10 @@ static int ti_sci_debugfs_create(struct platform_device *pdev,
  2842. /* Setup NULL termination */
  2843. info->debug_buffer[info->debug_region_size] = 0;
  2844. - info->d = debugfs_create_file(strncat(debug_name, dev_name(dev),
  2845. - sizeof(debug_name) -
  2846. - sizeof("ti_sci_debug@")),
  2847. - 0444, NULL, info, &ti_sci_debug_fops);
  2848. + snprintf(debug_name, sizeof(debug_name), "ti_sci_debug@%s",
  2849. + dev_name(dev));
  2850. + info->d = debugfs_create_file(debug_name, 0444, NULL, info,
  2851. + &ti_sci_debug_fops);
  2852. if (IS_ERR(info->d))
  2853. return PTR_ERR(info->d);
  2854. diff --git drivers/gpio/gpio-74x164.c drivers/gpio/gpio-74x164.c
  2855. index 15a1f4b348c4..4043fe0c8247 100644
  2856. --- linux-4.14.336/drivers/gpio/gpio-74x164.c
  2857. +++ linux-4.14.336/drivers/gpio/gpio-74x164.c
  2858. @@ -133,8 +133,6 @@ static int gen_74x164_probe(struct spi_device *spi)
  2859. if (IS_ERR(chip->gpiod_oe))
  2860. return PTR_ERR(chip->gpiod_oe);
  2861. - gpiod_set_value_cansleep(chip->gpiod_oe, 1);
  2862. -
  2863. spi_set_drvdata(spi, chip);
  2864. chip->gpio_chip.label = spi->modalias;
  2865. @@ -159,6 +157,8 @@ static int gen_74x164_probe(struct spi_device *spi)
  2866. goto exit_destroy;
  2867. }
  2868. + gpiod_set_value_cansleep(chip->gpiod_oe, 1);
  2869. +
  2870. ret = gpiochip_add_data(&chip->gpio_chip, chip);
  2871. if (!ret)
  2872. return 0;
  2873. diff --git drivers/gpio/gpiolib-acpi.c drivers/gpio/gpiolib-acpi.c
  2874. index 713dc43024c9..a2d00b1ff117 100644
  2875. --- linux-4.14.336/drivers/gpio/gpiolib-acpi.c
  2876. +++ linux-4.14.336/drivers/gpio/gpiolib-acpi.c
  2877. @@ -1476,6 +1476,20 @@ static const struct dmi_system_id gpiolib_acpi_quirks[] = {
  2878. .ignore_wake = "INT33FF:01@0",
  2879. },
  2880. },
  2881. + {
  2882. + /*
  2883. + * Spurious wakeups from TP_ATTN# pin
  2884. + * Found in BIOS 0.35
  2885. + * https://gitlab.freedesktop.org/drm/amd/-/issues/3073
  2886. + */
  2887. + .matches = {
  2888. + DMI_MATCH(DMI_SYS_VENDOR, "GPD"),
  2889. + DMI_MATCH(DMI_PRODUCT_NAME, "G1619-04"),
  2890. + },
  2891. + .driver_data = &(struct acpi_gpiolib_dmi_quirk) {
  2892. + .ignore_wake = "PNP0C50:00@8",
  2893. + },
  2894. + },
  2895. {} /* Terminating entry */
  2896. };
  2897. diff --git drivers/gpu/drm/amd/amdgpu/amdgpu_device.c drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
  2898. index 076b22c44122..d7192b2a980c 100644
  2899. --- linux-4.14.336/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
  2900. +++ linux-4.14.336/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
  2901. @@ -701,6 +701,7 @@ static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
  2902. return true;
  2903. fw_ver = *((uint32_t *)adev->pm.fw->data + 69);
  2904. + release_firmware(adev->pm.fw);
  2905. if (fw_ver < 0x00160e00)
  2906. return true;
  2907. }
  2908. diff --git drivers/gpu/drm/amd/amdgpu/kv_dpm.c drivers/gpu/drm/amd/amdgpu/kv_dpm.c
  2909. index d99fb88341f4..a4c9a326e9f5 100644
  2910. --- linux-4.14.336/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
  2911. +++ linux-4.14.336/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
  2912. @@ -2718,10 +2718,8 @@ static int kv_parse_power_table(struct amdgpu_device *adev)
  2913. non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
  2914. &non_clock_info_array->nonClockInfo[non_clock_array_index];
  2915. ps = kzalloc(sizeof(struct kv_ps), GFP_KERNEL);
  2916. - if (ps == NULL) {
  2917. - kfree(adev->pm.dpm.ps);
  2918. + if (ps == NULL)
  2919. return -ENOMEM;
  2920. - }
  2921. adev->pm.dpm.ps[i].ps_priv = ps;
  2922. k = 0;
  2923. idx = (u8 *)&power_state->v2.clockInfoIndex[0];
  2924. diff --git drivers/gpu/drm/amd/amdgpu/si_dpm.c drivers/gpu/drm/amd/amdgpu/si_dpm.c
  2925. index 288ac692f536..5f80f44f5f67 100644
  2926. --- linux-4.14.336/drivers/gpu/drm/amd/amdgpu/si_dpm.c
  2927. +++ linux-4.14.336/drivers/gpu/drm/amd/amdgpu/si_dpm.c
  2928. @@ -7336,10 +7336,9 @@ static int si_dpm_init(struct amdgpu_device *adev)
  2929. adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
  2930. kzalloc(4 * sizeof(struct amdgpu_clock_voltage_dependency_entry), GFP_KERNEL);
  2931. - if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
  2932. - amdgpu_free_extended_power_table(adev);
  2933. + if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries)
  2934. return -ENOMEM;
  2935. - }
  2936. +
  2937. adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count = 4;
  2938. adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].clk = 0;
  2939. adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].v = 0;
  2940. diff --git drivers/gpu/drm/bridge/nxp-ptn3460.c drivers/gpu/drm/bridge/nxp-ptn3460.c
  2941. index d64a3283822a..4ea809891f64 100644
  2942. --- linux-4.14.336/drivers/gpu/drm/bridge/nxp-ptn3460.c
  2943. +++ linux-4.14.336/drivers/gpu/drm/bridge/nxp-ptn3460.c
  2944. @@ -64,13 +64,13 @@ static int ptn3460_read_bytes(struct ptn3460_bridge *ptn_bridge, char addr,
  2945. int ret;
  2946. ret = i2c_master_send(ptn_bridge->client, &addr, 1);
  2947. - if (ret <= 0) {
  2948. + if (ret < 0) {
  2949. DRM_ERROR("Failed to send i2c command, ret=%d\n", ret);
  2950. return ret;
  2951. }
  2952. ret = i2c_master_recv(ptn_bridge->client, buf, len);
  2953. - if (ret <= 0) {
  2954. + if (ret < 0) {
  2955. DRM_ERROR("Failed to recv i2c data, ret=%d\n", ret);
  2956. return ret;
  2957. }
  2958. @@ -88,7 +88,7 @@ static int ptn3460_write_byte(struct ptn3460_bridge *ptn_bridge, char addr,
  2959. buf[1] = val;
  2960. ret = i2c_master_send(ptn_bridge->client, buf, ARRAY_SIZE(buf));
  2961. - if (ret <= 0) {
  2962. + if (ret < 0) {
  2963. DRM_ERROR("Failed to send i2c command, ret=%d\n", ret);
  2964. return ret;
  2965. }
  2966. diff --git drivers/gpu/drm/drm_crtc.c drivers/gpu/drm/drm_crtc.c
  2967. index 5af25ce5bf7c..7e37b439ecae 100644
  2968. --- linux-4.14.336/drivers/gpu/drm/drm_crtc.c
  2969. +++ linux-4.14.336/drivers/gpu/drm/drm_crtc.c
  2970. @@ -556,8 +556,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
  2971. struct drm_mode_set set;
  2972. uint32_t __user *set_connectors_ptr;
  2973. struct drm_modeset_acquire_ctx ctx;
  2974. - int ret;
  2975. - int i;
  2976. + int ret, i, num_connectors = 0;
  2977. if (!drm_core_check_feature(dev, DRIVER_MODESET))
  2978. return -EINVAL;
  2979. @@ -692,6 +691,7 @@ retry:
  2980. connector->name);
  2981. connector_set[i] = connector;
  2982. + num_connectors++;
  2983. }
  2984. }
  2985. @@ -700,7 +700,7 @@ retry:
  2986. set.y = crtc_req->y;
  2987. set.mode = mode;
  2988. set.connectors = connector_set;
  2989. - set.num_connectors = crtc_req->count_connectors;
  2990. + set.num_connectors = num_connectors;
  2991. set.fb = fb;
  2992. ret = __drm_mode_set_config_internal(&set, &ctx);
  2993. @@ -709,7 +709,7 @@ out:
  2994. drm_framebuffer_put(fb);
  2995. if (connector_set) {
  2996. - for (i = 0; i < crtc_req->count_connectors; i++) {
  2997. + for (i = 0; i < num_connectors; i++) {
  2998. if (connector_set[i])
  2999. drm_connector_put(connector_set[i]);
  3000. }
  3001. diff --git drivers/gpu/drm/drm_drv.c drivers/gpu/drm/drm_drv.c
  3002. index 340440febf9a..384a060aa8a1 100644
  3003. --- linux-4.14.336/drivers/gpu/drm/drm_drv.c
  3004. +++ linux-4.14.336/drivers/gpu/drm/drm_drv.c
  3005. @@ -812,8 +812,11 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
  3006. goto err_minors;
  3007. }
  3008. - if (drm_core_check_feature(dev, DRIVER_MODESET))
  3009. - drm_modeset_register_all(dev);
  3010. + if (drm_core_check_feature(dev, DRIVER_MODESET)) {
  3011. + ret = drm_modeset_register_all(dev);
  3012. + if (ret)
  3013. + goto err_unload;
  3014. + }
  3015. ret = 0;
  3016. @@ -825,6 +828,9 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
  3017. goto out_unlock;
  3018. +err_unload:
  3019. + if (dev->driver->unload)
  3020. + dev->driver->unload(dev);
  3021. err_minors:
  3022. remove_compat_control_link(dev);
  3023. drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
  3024. diff --git drivers/gpu/drm/drm_file.c drivers/gpu/drm/drm_file.c
  3025. index 3cf07f5063ff..8705060c72b4 100644
  3026. --- linux-4.14.336/drivers/gpu/drm/drm_file.c
  3027. +++ linux-4.14.336/drivers/gpu/drm/drm_file.c
  3028. @@ -138,7 +138,7 @@ int drm_open(struct inode *inode, struct file *filp)
  3029. {
  3030. struct drm_device *dev;
  3031. struct drm_minor *minor;
  3032. - int retcode;
  3033. + int retcode = 0;
  3034. int need_setup = 0;
  3035. minor = drm_minor_acquire(iminor(inode));
  3036. diff --git drivers/gpu/drm/drm_framebuffer.c drivers/gpu/drm/drm_framebuffer.c
  3037. index af40189cdb60..d6476223a941 100644
  3038. --- linux-4.14.336/drivers/gpu/drm/drm_framebuffer.c
  3039. +++ linux-4.14.336/drivers/gpu/drm/drm_framebuffer.c
  3040. @@ -521,7 +521,7 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
  3041. struct drm_framebuffer *fb;
  3042. unsigned flags;
  3043. int num_clips;
  3044. - int ret;
  3045. + int ret = 0;
  3046. if (!drm_core_check_feature(dev, DRIVER_MODESET))
  3047. return -EINVAL;
  3048. diff --git drivers/gpu/drm/drm_mipi_dsi.c drivers/gpu/drm/drm_mipi_dsi.c
  3049. index 6995bee5ad0f..488e8e35c722 100644
  3050. --- linux-4.14.336/drivers/gpu/drm/drm_mipi_dsi.c
  3051. +++ linux-4.14.336/drivers/gpu/drm/drm_mipi_dsi.c
  3052. @@ -305,7 +305,8 @@ static int mipi_dsi_remove_device_fn(struct device *dev, void *priv)
  3053. {
  3054. struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
  3055. - mipi_dsi_detach(dsi);
  3056. + if (dsi->attached)
  3057. + mipi_dsi_detach(dsi);
  3058. mipi_dsi_device_unregister(dsi);
  3059. return 0;
  3060. @@ -328,11 +329,18 @@ EXPORT_SYMBOL(mipi_dsi_host_unregister);
  3061. int mipi_dsi_attach(struct mipi_dsi_device *dsi)
  3062. {
  3063. const struct mipi_dsi_host_ops *ops = dsi->host->ops;
  3064. + int ret;
  3065. if (!ops || !ops->attach)
  3066. return -ENOSYS;
  3067. - return ops->attach(dsi->host, dsi);
  3068. + ret = ops->attach(dsi->host, dsi);
  3069. + if (ret)
  3070. + return ret;
  3071. +
  3072. + dsi->attached = true;
  3073. +
  3074. + return 0;
  3075. }
  3076. EXPORT_SYMBOL(mipi_dsi_attach);
  3077. @@ -344,9 +352,14 @@ int mipi_dsi_detach(struct mipi_dsi_device *dsi)
  3078. {
  3079. const struct mipi_dsi_host_ops *ops = dsi->host->ops;
  3080. + if (WARN_ON(!dsi->attached))
  3081. + return -EINVAL;
  3082. +
  3083. if (!ops || !ops->detach)
  3084. return -ENOSYS;
  3085. + dsi->attached = false;
  3086. +
  3087. return ops->detach(dsi->host, dsi);
  3088. }
  3089. EXPORT_SYMBOL(mipi_dsi_detach);
  3090. diff --git drivers/gpu/drm/drm_plane.c drivers/gpu/drm/drm_plane.c
  3091. index 71186bf90760..5354dedaa608 100644
  3092. --- linux-4.14.336/drivers/gpu/drm/drm_plane.c
  3093. +++ linux-4.14.336/drivers/gpu/drm/drm_plane.c
  3094. @@ -1072,6 +1072,7 @@ retry:
  3095. out:
  3096. if (fb)
  3097. drm_framebuffer_put(fb);
  3098. + fb = NULL;
  3099. if (crtc->primary->old_fb)
  3100. drm_framebuffer_put(crtc->primary->old_fb);
  3101. crtc->primary->old_fb = NULL;
  3102. diff --git drivers/gpu/drm/exynos/exynos_drm_drv.c drivers/gpu/drm/exynos/exynos_drm_drv.c
  3103. index 82b72425a42f..707b4fdd94a7 100644
  3104. --- linux-4.14.336/drivers/gpu/drm/exynos/exynos_drm_drv.c
  3105. +++ linux-4.14.336/drivers/gpu/drm/exynos/exynos_drm_drv.c
  3106. @@ -407,6 +407,7 @@ err_mode_config_cleanup:
  3107. drm_release_iommu_mapping(drm);
  3108. err_free_private:
  3109. kfree(private);
  3110. + dev_set_drvdata(dev, NULL);
  3111. err_free_drm:
  3112. drm_dev_unref(drm);
  3113. @@ -423,6 +424,7 @@ static void exynos_drm_unbind(struct device *dev)
  3114. exynos_drm_fbdev_fini(drm);
  3115. drm_kms_helper_poll_fini(drm);
  3116. + drm_atomic_helper_shutdown(drm);
  3117. component_unbind_all(drm->dev, drm);
  3118. drm_mode_config_cleanup(drm);
  3119. @@ -460,9 +462,18 @@ static int exynos_drm_platform_remove(struct platform_device *pdev)
  3120. return 0;
  3121. }
  3122. +static void exynos_drm_platform_shutdown(struct platform_device *pdev)
  3123. +{
  3124. + struct drm_device *drm = platform_get_drvdata(pdev);
  3125. +
  3126. + if (drm)
  3127. + drm_atomic_helper_shutdown(drm);
  3128. +}
  3129. +
  3130. static struct platform_driver exynos_drm_platform_driver = {
  3131. .probe = exynos_drm_platform_probe,
  3132. .remove = exynos_drm_platform_remove,
  3133. + .shutdown = exynos_drm_platform_shutdown,
  3134. .driver = {
  3135. .name = "exynos-drm",
  3136. .pm = &exynos_drm_pm_ops,
  3137. diff --git drivers/gpu/drm/exynos/exynos_hdmi.c drivers/gpu/drm/exynos/exynos_hdmi.c
  3138. index 0109ff40b1db..3d79a7af8c86 100644
  3139. --- linux-4.14.336/drivers/gpu/drm/exynos/exynos_hdmi.c
  3140. +++ linux-4.14.336/drivers/gpu/drm/exynos/exynos_hdmi.c
  3141. @@ -1722,6 +1722,8 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data)
  3142. return ret;
  3143. crtc = exynos_drm_crtc_get_by_type(drm_dev, EXYNOS_DISPLAY_TYPE_HDMI);
  3144. + if (IS_ERR(crtc))
  3145. + return PTR_ERR(crtc);
  3146. crtc->pipe_clk = &hdata->phy_clk;
  3147. ret = hdmi_create_connector(encoder);
  3148. diff --git drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
  3149. index 47fa2aba1983..de0dac7b5d85 100644
  3150. --- linux-4.14.336/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
  3151. +++ linux-4.14.336/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
  3152. @@ -284,6 +284,7 @@ static void mdp4_crtc_atomic_disable(struct drm_crtc *crtc,
  3153. {
  3154. struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
  3155. struct mdp4_kms *mdp4_kms = get_kms(crtc);
  3156. + unsigned long flags;
  3157. DBG("%s", mdp4_crtc->name);
  3158. @@ -293,6 +294,14 @@ static void mdp4_crtc_atomic_disable(struct drm_crtc *crtc,
  3159. mdp_irq_unregister(&mdp4_kms->base, &mdp4_crtc->err);
  3160. mdp4_disable(mdp4_kms);
  3161. + if (crtc->state->event && !crtc->state->active) {
  3162. + WARN_ON(mdp4_crtc->event);
  3163. + spin_lock_irqsave(&mdp4_kms->dev->event_lock, flags);
  3164. + drm_crtc_send_vblank_event(crtc, crtc->state->event);
  3165. + crtc->state->event = NULL;
  3166. + spin_unlock_irqrestore(&mdp4_kms->dev->event_lock, flags);
  3167. + }
  3168. +
  3169. mdp4_crtc->enabled = false;
  3170. }
  3171. diff --git drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
  3172. index 4b571cc6bc70..6597def18627 100644
  3173. --- linux-4.14.336/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
  3174. +++ linux-4.14.336/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
  3175. @@ -154,11 +154,17 @@ shadow_fw_init(struct nvkm_bios *bios, const char *name)
  3176. return (void *)fw;
  3177. }
  3178. +static void
  3179. +shadow_fw_release(void *fw)
  3180. +{
  3181. + release_firmware(fw);
  3182. +}
  3183. +
  3184. static const struct nvbios_source
  3185. shadow_fw = {
  3186. .name = "firmware",
  3187. .init = shadow_fw_init,
  3188. - .fini = (void(*)(void *))release_firmware,
  3189. + .fini = shadow_fw_release,
  3190. .read = shadow_fw_read,
  3191. .rw = false,
  3192. };
  3193. diff --git drivers/gpu/drm/radeon/r100.c drivers/gpu/drm/radeon/r100.c
  3194. index a4929372090d..56e13bdd4bd0 100644
  3195. --- linux-4.14.336/drivers/gpu/drm/radeon/r100.c
  3196. +++ linux-4.14.336/drivers/gpu/drm/radeon/r100.c
  3197. @@ -2307,7 +2307,7 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track)
  3198. switch (prim_walk) {
  3199. case 1:
  3200. for (i = 0; i < track->num_arrays; i++) {
  3201. - size = track->arrays[i].esize * track->max_indx * 4;
  3202. + size = track->arrays[i].esize * track->max_indx * 4UL;
  3203. if (track->arrays[i].robj == NULL) {
  3204. DRM_ERROR("(PW %u) Vertex array %u no buffer "
  3205. "bound\n", prim_walk, i);
  3206. @@ -2326,7 +2326,7 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track)
  3207. break;
  3208. case 2:
  3209. for (i = 0; i < track->num_arrays; i++) {
  3210. - size = track->arrays[i].esize * (nverts - 1) * 4;
  3211. + size = track->arrays[i].esize * (nverts - 1) * 4UL;
  3212. if (track->arrays[i].robj == NULL) {
  3213. DRM_ERROR("(PW %u) Vertex array %u no buffer "
  3214. "bound\n", prim_walk, i);
  3215. diff --git drivers/gpu/drm/radeon/r600_cs.c drivers/gpu/drm/radeon/r600_cs.c
  3216. index 97fd58e97043..f478d88aea8f 100644
  3217. --- linux-4.14.336/drivers/gpu/drm/radeon/r600_cs.c
  3218. +++ linux-4.14.336/drivers/gpu/drm/radeon/r600_cs.c
  3219. @@ -1278,7 +1278,7 @@ static int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx)
  3220. return -EINVAL;
  3221. }
  3222. tmp = (reg - CB_COLOR0_BASE) / 4;
  3223. - track->cb_color_bo_offset[tmp] = radeon_get_ib_value(p, idx) << 8;
  3224. + track->cb_color_bo_offset[tmp] = (u64)radeon_get_ib_value(p, idx) << 8;
  3225. ib[idx] += (u32)((reloc->gpu_offset >> 8) & 0xffffffff);
  3226. track->cb_color_base_last[tmp] = ib[idx];
  3227. track->cb_color_bo[tmp] = reloc->robj;
  3228. @@ -1305,7 +1305,7 @@ static int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx)
  3229. "0x%04X\n", reg);
  3230. return -EINVAL;
  3231. }
  3232. - track->htile_offset = radeon_get_ib_value(p, idx) << 8;
  3233. + track->htile_offset = (u64)radeon_get_ib_value(p, idx) << 8;
  3234. ib[idx] += (u32)((reloc->gpu_offset >> 8) & 0xffffffff);
  3235. track->htile_bo = reloc->robj;
  3236. track->db_dirty = true;
  3237. diff --git drivers/gpu/drm/radeon/radeon_display.c drivers/gpu/drm/radeon/radeon_display.c
  3238. index 173439a8c881..620f301737a4 100644
  3239. --- linux-4.14.336/drivers/gpu/drm/radeon/radeon_display.c
  3240. +++ linux-4.14.336/drivers/gpu/drm/radeon/radeon_display.c
  3241. @@ -678,11 +678,16 @@ static void radeon_crtc_init(struct drm_device *dev, int index)
  3242. if (radeon_crtc == NULL)
  3243. return;
  3244. + radeon_crtc->flip_queue = alloc_workqueue("radeon-crtc", WQ_HIGHPRI, 0);
  3245. + if (!radeon_crtc->flip_queue) {
  3246. + kfree(radeon_crtc);
  3247. + return;
  3248. + }
  3249. +
  3250. drm_crtc_init(dev, &radeon_crtc->base, &radeon_crtc_funcs);
  3251. drm_mode_crtc_set_gamma_size(&radeon_crtc->base, 256);
  3252. radeon_crtc->crtc_id = index;
  3253. - radeon_crtc->flip_queue = alloc_workqueue("radeon-crtc", WQ_HIGHPRI, 0);
  3254. rdev->mode_info.crtcs[index] = radeon_crtc;
  3255. if (rdev->family >= CHIP_BONAIRE) {
  3256. diff --git drivers/gpu/drm/radeon/radeon_vm.c drivers/gpu/drm/radeon/radeon_vm.c
  3257. index e5c0e635e371..6f2133ff7c2c 100644
  3258. --- linux-4.14.336/drivers/gpu/drm/radeon/radeon_vm.c
  3259. +++ linux-4.14.336/drivers/gpu/drm/radeon/radeon_vm.c
  3260. @@ -1205,13 +1205,17 @@ int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm)
  3261. r = radeon_bo_create(rdev, pd_size, align, true,
  3262. RADEON_GEM_DOMAIN_VRAM, 0, NULL,
  3263. NULL, &vm->page_directory);
  3264. - if (r)
  3265. + if (r) {
  3266. + kfree(vm->page_tables);
  3267. + vm->page_tables = NULL;
  3268. return r;
  3269. -
  3270. + }
  3271. r = radeon_vm_clear_bo(rdev, vm->page_directory);
  3272. if (r) {
  3273. radeon_bo_unref(&vm->page_directory);
  3274. vm->page_directory = NULL;
  3275. + kfree(vm->page_tables);
  3276. + vm->page_tables = NULL;
  3277. return r;
  3278. }
  3279. diff --git drivers/gpu/drm/radeon/si.c drivers/gpu/drm/radeon/si.c
  3280. index 1144cafea9ac..6dc20e790556 100644
  3281. --- linux-4.14.336/drivers/gpu/drm/radeon/si.c
  3282. +++ linux-4.14.336/drivers/gpu/drm/radeon/si.c
  3283. @@ -3612,6 +3612,10 @@ static int si_cp_start(struct radeon_device *rdev)
  3284. for (i = RADEON_RING_TYPE_GFX_INDEX; i <= CAYMAN_RING_TYPE_CP2_INDEX; ++i) {
  3285. ring = &rdev->ring[i];
  3286. r = radeon_ring_lock(rdev, ring, 2);
  3287. + if (r) {
  3288. + DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r);
  3289. + return r;
  3290. + }
  3291. /* clear the compute context state */
  3292. radeon_ring_write(ring, PACKET3_COMPUTE(PACKET3_CLEAR_STATE, 0));
  3293. diff --git drivers/gpu/drm/radeon/sumo_dpm.c drivers/gpu/drm/radeon/sumo_dpm.c
  3294. index fd4804829e46..258cca4ae59b 100644
  3295. --- linux-4.14.336/drivers/gpu/drm/radeon/sumo_dpm.c
  3296. +++ linux-4.14.336/drivers/gpu/drm/radeon/sumo_dpm.c
  3297. @@ -1493,8 +1493,10 @@ static int sumo_parse_power_table(struct radeon_device *rdev)
  3298. non_clock_array_index = power_state->v2.nonClockInfoIndex;
  3299. non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
  3300. &non_clock_info_array->nonClockInfo[non_clock_array_index];
  3301. - if (!rdev->pm.power_state[i].clock_info)
  3302. + if (!rdev->pm.power_state[i].clock_info) {
  3303. + kfree(rdev->pm.dpm.ps);
  3304. return -EINVAL;
  3305. + }
  3306. ps = kzalloc(sizeof(struct sumo_ps), GFP_KERNEL);
  3307. if (ps == NULL) {
  3308. kfree(rdev->pm.dpm.ps);
  3309. diff --git drivers/gpu/drm/radeon/trinity_dpm.c drivers/gpu/drm/radeon/trinity_dpm.c
  3310. index 2ef7c4e5e495..8fcb7466bf8c 100644
  3311. --- linux-4.14.336/drivers/gpu/drm/radeon/trinity_dpm.c
  3312. +++ linux-4.14.336/drivers/gpu/drm/radeon/trinity_dpm.c
  3313. @@ -1768,8 +1768,10 @@ static int trinity_parse_power_table(struct radeon_device *rdev)
  3314. non_clock_array_index = power_state->v2.nonClockInfoIndex;
  3315. non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
  3316. &non_clock_info_array->nonClockInfo[non_clock_array_index];
  3317. - if (!rdev->pm.power_state[i].clock_info)
  3318. + if (!rdev->pm.power_state[i].clock_info) {
  3319. + kfree(rdev->pm.dpm.ps);
  3320. return -EINVAL;
  3321. + }
  3322. ps = kzalloc(sizeof(struct sumo_ps), GFP_KERNEL);
  3323. if (ps == NULL) {
  3324. kfree(rdev->pm.dpm.ps);
  3325. diff --git drivers/hid/hid-apple.c drivers/hid/hid-apple.c
  3326. index 80ecbf14d3c8..8ba8f76c92c0 100644
  3327. --- linux-4.14.336/drivers/hid/hid-apple.c
  3328. +++ linux-4.14.336/drivers/hid/hid-apple.c
  3329. @@ -54,6 +54,12 @@ MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\")
  3330. "(For people who want to keep Windows PC keyboard muscle memory. "
  3331. "[0] = as-is, Mac layout. 1 = swapped, Windows layout.)");
  3332. +static unsigned int swap_fn_leftctrl;
  3333. +module_param(swap_fn_leftctrl, uint, 0644);
  3334. +MODULE_PARM_DESC(swap_fn_leftctrl, "Swap the Fn and left Control keys. "
  3335. + "(For people who want to keep PC keyboard muscle memory. "
  3336. + "[0] = as-is, Mac layout, 1 = swapped, PC layout)");
  3337. +
  3338. struct apple_sc {
  3339. unsigned long quirks;
  3340. unsigned int fn_on;
  3341. @@ -67,6 +73,28 @@ struct apple_key_translation {
  3342. u8 flags;
  3343. };
  3344. +static const struct apple_key_translation apple2021_fn_keys[] = {
  3345. + { KEY_BACKSPACE, KEY_DELETE },
  3346. + { KEY_ENTER, KEY_INSERT },
  3347. + { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
  3348. + { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
  3349. + { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
  3350. + { KEY_F4, KEY_SEARCH, APPLE_FLAG_FKEY },
  3351. + { KEY_F5, KEY_MICMUTE, APPLE_FLAG_FKEY },
  3352. + { KEY_F6, KEY_SLEEP, APPLE_FLAG_FKEY },
  3353. + { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
  3354. + { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
  3355. + { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
  3356. + { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
  3357. + { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
  3358. + { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
  3359. + { KEY_UP, KEY_PAGEUP },
  3360. + { KEY_DOWN, KEY_PAGEDOWN },
  3361. + { KEY_LEFT, KEY_HOME },
  3362. + { KEY_RIGHT, KEY_END },
  3363. + { }
  3364. +};
  3365. +
  3366. static const struct apple_key_translation macbookair_fn_keys[] = {
  3367. { KEY_BACKSPACE, KEY_DELETE },
  3368. { KEY_ENTER, KEY_INSERT },
  3369. @@ -166,6 +194,11 @@ static const struct apple_key_translation swapped_option_cmd_keys[] = {
  3370. { }
  3371. };
  3372. +static const struct apple_key_translation swapped_fn_leftctrl_keys[] = {
  3373. + { KEY_FN, KEY_LEFTCTRL },
  3374. + { }
  3375. +};
  3376. +
  3377. static const struct apple_key_translation *apple_find_translation(
  3378. const struct apple_key_translation *table, u16 from)
  3379. {
  3380. @@ -187,14 +220,18 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
  3381. bool do_translate;
  3382. u16 code = 0;
  3383. - if (usage->code == KEY_FN) {
  3384. + u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN);
  3385. +
  3386. + if (usage->code == fn_keycode) {
  3387. asc->fn_on = !!value;
  3388. - input_event(input, usage->type, usage->code, value);
  3389. + input_event(input, usage->type, KEY_FN, value);
  3390. return 1;
  3391. }
  3392. if (fnmode) {
  3393. - if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
  3394. + if (hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021)
  3395. + table = apple2021_fn_keys;
  3396. + else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
  3397. hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
  3398. table = macbookair_fn_keys;
  3399. else if (hid->product < 0x21d || hid->product >= 0x300)
  3400. @@ -274,6 +311,14 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
  3401. }
  3402. }
  3403. + if (swap_fn_leftctrl) {
  3404. + trans = apple_find_translation(swapped_fn_leftctrl_keys, usage->code);
  3405. + if (trans) {
  3406. + input_event(input, usage->type, trans->to, value);
  3407. + return 1;
  3408. + }
  3409. + }
  3410. +
  3411. return 0;
  3412. }
  3413. @@ -344,6 +389,14 @@ static void apple_setup_input(struct input_dev *input)
  3414. for (trans = apple_iso_keyboard; trans->from; trans++)
  3415. set_bit(trans->to, input->keybit);
  3416. +
  3417. + for (trans = apple2021_fn_keys; trans->from; trans++)
  3418. + set_bit(trans->to, input->keybit);
  3419. +
  3420. + if (swap_fn_leftctrl) {
  3421. + for (trans = swapped_fn_leftctrl_keys; trans->from; trans++)
  3422. + set_bit(trans->to, input->keybit);
  3423. + }
  3424. }
  3425. static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
  3426. @@ -599,6 +652,10 @@ static const struct hid_device_id apple_devices[] = {
  3427. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  3428. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
  3429. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  3430. + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021),
  3431. + .driver_data = APPLE_HAS_FN },
  3432. + { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021),
  3433. + .driver_data = APPLE_HAS_FN },
  3434. { }
  3435. };
  3436. diff --git drivers/hid/hid-core.c drivers/hid/hid-core.c
  3437. index fe3824a6af5c..9bfae325a410 100644
  3438. --- linux-4.14.336/drivers/hid/hid-core.c
  3439. +++ linux-4.14.336/drivers/hid/hid-core.c
  3440. @@ -2063,6 +2063,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
  3441. { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI) },
  3442. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
  3443. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
  3444. + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021) },
  3445. #endif
  3446. #if IS_ENABLED(CONFIG_HID_APPLEIR)
  3447. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL) },
  3448. diff --git drivers/hid/hid-ids.h drivers/hid/hid-ids.h
  3449. index 26db838be5a2..1b89c9185c14 100644
  3450. --- linux-4.14.336/drivers/hid/hid-ids.h
  3451. +++ linux-4.14.336/drivers/hid/hid-ids.h
  3452. @@ -172,6 +172,7 @@
  3453. #define USB_DEVICE_ID_APPLE_IRCONTROL3 0x8241
  3454. #define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242
  3455. #define USB_DEVICE_ID_APPLE_IRCONTROL5 0x8243
  3456. +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 0x029c
  3457. #define USB_VENDOR_ID_ASUS 0x0486
  3458. #define USB_DEVICE_ID_ASUS_T91MT 0x0185
  3459. diff --git drivers/hid/wacom_sys.c drivers/hid/wacom_sys.c
  3460. index 3ca50505c78c..b4c25afb3a36 100644
  3461. --- linux-4.14.336/drivers/hid/wacom_sys.c
  3462. +++ linux-4.14.336/drivers/hid/wacom_sys.c
  3463. @@ -1920,7 +1920,7 @@ static int wacom_allocate_inputs(struct wacom *wacom)
  3464. return 0;
  3465. }
  3466. -static int wacom_register_inputs(struct wacom *wacom)
  3467. +static int wacom_setup_inputs(struct wacom *wacom)
  3468. {
  3469. struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
  3470. struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
  3471. @@ -1939,10 +1939,6 @@ static int wacom_register_inputs(struct wacom *wacom)
  3472. input_free_device(pen_input_dev);
  3473. wacom_wac->pen_input = NULL;
  3474. pen_input_dev = NULL;
  3475. - } else {
  3476. - error = input_register_device(pen_input_dev);
  3477. - if (error)
  3478. - goto fail;
  3479. }
  3480. error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac);
  3481. @@ -1951,10 +1947,6 @@ static int wacom_register_inputs(struct wacom *wacom)
  3482. input_free_device(touch_input_dev);
  3483. wacom_wac->touch_input = NULL;
  3484. touch_input_dev = NULL;
  3485. - } else {
  3486. - error = input_register_device(touch_input_dev);
  3487. - if (error)
  3488. - goto fail;
  3489. }
  3490. error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
  3491. @@ -1963,7 +1955,34 @@ static int wacom_register_inputs(struct wacom *wacom)
  3492. input_free_device(pad_input_dev);
  3493. wacom_wac->pad_input = NULL;
  3494. pad_input_dev = NULL;
  3495. - } else {
  3496. + }
  3497. +
  3498. + return 0;
  3499. +}
  3500. +
  3501. +static int wacom_register_inputs(struct wacom *wacom)
  3502. +{
  3503. + struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
  3504. + struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
  3505. + int error = 0;
  3506. +
  3507. + pen_input_dev = wacom_wac->pen_input;
  3508. + touch_input_dev = wacom_wac->touch_input;
  3509. + pad_input_dev = wacom_wac->pad_input;
  3510. +
  3511. + if (pen_input_dev) {
  3512. + error = input_register_device(pen_input_dev);
  3513. + if (error)
  3514. + goto fail;
  3515. + }
  3516. +
  3517. + if (touch_input_dev) {
  3518. + error = input_register_device(touch_input_dev);
  3519. + if (error)
  3520. + goto fail;
  3521. + }
  3522. +
  3523. + if (pad_input_dev) {
  3524. error = input_register_device(pad_input_dev);
  3525. if (error)
  3526. goto fail;
  3527. @@ -2213,6 +2232,20 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
  3528. goto fail;
  3529. }
  3530. + error = wacom_setup_inputs(wacom);
  3531. + if (error)
  3532. + goto fail;
  3533. +
  3534. + if (features->type == HID_GENERIC)
  3535. + connect_mask |= HID_CONNECT_DRIVER;
  3536. +
  3537. + /* Regular HID work starts now */
  3538. + error = hid_hw_start(hdev, connect_mask);
  3539. + if (error) {
  3540. + hid_err(hdev, "hw start failed\n");
  3541. + goto fail;
  3542. + }
  3543. +
  3544. error = wacom_register_inputs(wacom);
  3545. if (error)
  3546. goto fail;
  3547. @@ -2227,16 +2260,6 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
  3548. goto fail;
  3549. }
  3550. - if (features->type == HID_GENERIC)
  3551. - connect_mask |= HID_CONNECT_DRIVER;
  3552. -
  3553. - /* Regular HID work starts now */
  3554. - error = hid_hw_start(hdev, connect_mask);
  3555. - if (error) {
  3556. - hid_err(hdev, "hw start failed\n");
  3557. - goto fail;
  3558. - }
  3559. -
  3560. if (!wireless) {
  3561. /* Note that if query fails it is not a hard failure */
  3562. wacom_query_tablet_data(wacom);
  3563. diff --git drivers/hid/wacom_wac.c drivers/hid/wacom_wac.c
  3564. index 19a798eb395c..eb39c88b5eac 100644
  3565. --- linux-4.14.336/drivers/hid/wacom_wac.c
  3566. +++ linux-4.14.336/drivers/hid/wacom_wac.c
  3567. @@ -2317,7 +2317,14 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
  3568. wacom_wac->hid_data.tipswitch);
  3569. input_report_key(input, wacom_wac->tool[0], prox);
  3570. if (wacom_wac->serial[0]) {
  3571. - input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
  3572. + /*
  3573. + * xf86-input-wacom does not accept a serial number
  3574. + * of '0'. Report the low 32 bits if possible, but
  3575. + * if they are zero, report the upper ones instead.
  3576. + */
  3577. + __u32 serial_lo = wacom_wac->serial[0] & 0xFFFFFFFFu;
  3578. + __u32 serial_hi = wacom_wac->serial[0] >> 32;
  3579. + input_event(input, EV_MSC, MSC_SERIAL, (int)(serial_lo ? serial_lo : serial_hi));
  3580. input_report_abs(input, ABS_MISC, prox ? id : 0);
  3581. }
  3582. @@ -2389,8 +2396,8 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
  3583. {
  3584. struct hid_data *hid_data = &wacom_wac->hid_data;
  3585. bool mt = wacom_wac->features.touch_max > 1;
  3586. - bool prox = hid_data->tipswitch &&
  3587. - report_touch_events(wacom_wac);
  3588. + bool touch_down = hid_data->tipswitch && hid_data->confidence;
  3589. + bool prox = touch_down && report_touch_events(wacom_wac);
  3590. if (wacom_wac->shared->has_mute_touch_switch &&
  3591. !wacom_wac->shared->is_touch_on) {
  3592. @@ -2429,24 +2436,6 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
  3593. }
  3594. }
  3595. -static bool wacom_wac_slot_is_active(struct input_dev *dev, int key)
  3596. -{
  3597. - struct input_mt *mt = dev->mt;
  3598. - struct input_mt_slot *s;
  3599. -
  3600. - if (!mt)
  3601. - return false;
  3602. -
  3603. - for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
  3604. - if (s->key == key &&
  3605. - input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) {
  3606. - return true;
  3607. - }
  3608. - }
  3609. -
  3610. - return false;
  3611. -}
  3612. -
  3613. static void wacom_wac_finger_event(struct hid_device *hdev,
  3614. struct hid_field *field, struct hid_usage *usage, __s32 value)
  3615. {
  3616. @@ -2489,14 +2478,8 @@ static void wacom_wac_finger_event(struct hid_device *hdev,
  3617. if (usage->usage_index + 1 == field->report_count) {
  3618. - if (equivalent_usage == wacom_wac->hid_data.last_slot_field) {
  3619. - bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input,
  3620. - wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch;
  3621. -
  3622. - if (wacom_wac->hid_data.confidence || touch_removed) {
  3623. - wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
  3624. - }
  3625. - }
  3626. + if (equivalent_usage == wacom_wac->hid_data.last_slot_field)
  3627. + wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
  3628. }
  3629. }
  3630. diff --git drivers/hwmon/aspeed-pwm-tacho.c drivers/hwmon/aspeed-pwm-tacho.c
  3631. index e4337e9dda44..922c5930373b 100644
  3632. --- linux-4.14.336/drivers/hwmon/aspeed-pwm-tacho.c
  3633. +++ linux-4.14.336/drivers/hwmon/aspeed-pwm-tacho.c
  3634. @@ -195,6 +195,8 @@ struct aspeed_pwm_tacho_data {
  3635. u8 fan_tach_ch_source[16];
  3636. struct aspeed_cooling_device *cdev[8];
  3637. const struct attribute_group *groups[3];
  3638. + /* protects access to shared ASPEED_PTCR_RESULT */
  3639. + struct mutex tach_lock;
  3640. };
  3641. enum type { TYPEM, TYPEN, TYPEO };
  3642. @@ -529,6 +531,8 @@ static int aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv,
  3643. u8 fan_tach_ch_source, type, mode, both;
  3644. int ret;
  3645. + mutex_lock(&priv->tach_lock);
  3646. +
  3647. regmap_write(priv->regmap, ASPEED_PTCR_TRIGGER, 0);
  3648. regmap_write(priv->regmap, ASPEED_PTCR_TRIGGER, 0x1 << fan_tach_ch);
  3649. @@ -546,6 +550,8 @@ static int aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv,
  3650. ASPEED_RPM_STATUS_SLEEP_USEC,
  3651. usec);
  3652. + mutex_unlock(&priv->tach_lock);
  3653. +
  3654. /* return -ETIMEDOUT if we didn't get an answer. */
  3655. if (ret)
  3656. return ret;
  3657. @@ -929,6 +935,7 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev)
  3658. priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
  3659. if (!priv)
  3660. return -ENOMEM;
  3661. + mutex_init(&priv->tach_lock);
  3662. priv->regmap = devm_regmap_init(dev, NULL, (__force void *)regs,
  3663. &aspeed_pwm_tacho_regmap_config);
  3664. if (IS_ERR(priv->regmap))
  3665. diff --git drivers/hwmon/coretemp.c drivers/hwmon/coretemp.c
  3666. index 770bf76a5348..532cc7286cf0 100644
  3667. --- linux-4.14.336/drivers/hwmon/coretemp.c
  3668. +++ linux-4.14.336/drivers/hwmon/coretemp.c
  3669. @@ -53,7 +53,7 @@ MODULE_PARM_DESC(tjmax, "TjMax value in degrees Celsius");
  3670. #define PKG_SYSFS_ATTR_NO 1 /* Sysfs attribute for package temp */
  3671. #define BASE_SYSFS_ATTR_NO 2 /* Sysfs Base attr no for coretemp */
  3672. -#define NUM_REAL_CORES 128 /* Number of Real cores per cpu */
  3673. +#define NUM_REAL_CORES 512 /* Number of Real cores per cpu */
  3674. #define CORETEMP_NAME_LENGTH 19 /* String Length of attrs */
  3675. #define MAX_CORE_ATTRS 4 /* Maximum no of basic attrs */
  3676. #define TOTAL_ATTRS (MAX_CORE_ATTRS + 1)
  3677. diff --git drivers/hwtracing/coresight/coresight-etm4x.h drivers/hwtracing/coresight/coresight-etm4x.h
  3678. index b3b5ea7b7fb3..d48c40d8fc28 100644
  3679. --- linux-4.14.336/drivers/hwtracing/coresight/coresight-etm4x.h
  3680. +++ linux-4.14.336/drivers/hwtracing/coresight/coresight-etm4x.h
  3681. @@ -373,7 +373,7 @@ struct etmv4_drvdata {
  3682. u8 ctxid_size;
  3683. u8 vmid_size;
  3684. u8 ccsize;
  3685. - u8 ccitmin;
  3686. + u16 ccitmin;
  3687. u8 s_ex_level;
  3688. u8 ns_ex_level;
  3689. u8 q_support;
  3690. diff --git drivers/i2c/busses/i2c-s3c2410.c drivers/i2c/busses/i2c-s3c2410.c
  3691. index 911f8628128e..299d8f388d62 100644
  3692. --- linux-4.14.336/drivers/i2c/busses/i2c-s3c2410.c
  3693. +++ linux-4.14.336/drivers/i2c/busses/i2c-s3c2410.c
  3694. @@ -235,8 +235,17 @@ static bool is_ack(struct s3c24xx_i2c *i2c)
  3695. int tries;
  3696. for (tries = 50; tries; --tries) {
  3697. - if (readl(i2c->regs + S3C2410_IICCON)
  3698. - & S3C2410_IICCON_IRQPEND) {
  3699. + unsigned long tmp = readl(i2c->regs + S3C2410_IICCON);
  3700. +
  3701. + if (!(tmp & S3C2410_IICCON_ACKEN)) {
  3702. + /*
  3703. + * Wait a bit for the bus to stabilize,
  3704. + * delay estimated experimentally.
  3705. + */
  3706. + usleep_range(100, 200);
  3707. + return true;
  3708. + }
  3709. + if (tmp & S3C2410_IICCON_IRQPEND) {
  3710. if (!(readl(i2c->regs + S3C2410_IICSTAT)
  3711. & S3C2410_IICSTAT_LASTBIT))
  3712. return true;
  3713. @@ -289,16 +298,6 @@ static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
  3714. stat |= S3C2410_IICSTAT_START;
  3715. writel(stat, i2c->regs + S3C2410_IICSTAT);
  3716. -
  3717. - if (i2c->quirks & QUIRK_POLL) {
  3718. - while ((i2c->msg_num != 0) && is_ack(i2c)) {
  3719. - i2c_s3c_irq_nextbyte(i2c, stat);
  3720. - stat = readl(i2c->regs + S3C2410_IICSTAT);
  3721. -
  3722. - if (stat & S3C2410_IICSTAT_ARBITR)
  3723. - dev_err(i2c->dev, "deal with arbitration loss\n");
  3724. - }
  3725. - }
  3726. }
  3727. static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret)
  3728. @@ -705,7 +704,7 @@ static void s3c24xx_i2c_wait_idle(struct s3c24xx_i2c *i2c)
  3729. static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
  3730. struct i2c_msg *msgs, int num)
  3731. {
  3732. - unsigned long timeout;
  3733. + unsigned long timeout = 0;
  3734. int ret;
  3735. if (i2c->suspended)
  3736. @@ -728,16 +727,19 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
  3737. s3c24xx_i2c_message_start(i2c, msgs);
  3738. if (i2c->quirks & QUIRK_POLL) {
  3739. - ret = i2c->msg_idx;
  3740. + while ((i2c->msg_num != 0) && is_ack(i2c)) {
  3741. + unsigned long stat = readl(i2c->regs + S3C2410_IICSTAT);
  3742. - if (ret != num)
  3743. - dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret);
  3744. + i2c_s3c_irq_nextbyte(i2c, stat);
  3745. - goto out;
  3746. + stat = readl(i2c->regs + S3C2410_IICSTAT);
  3747. + if (stat & S3C2410_IICSTAT_ARBITR)
  3748. + dev_err(i2c->dev, "deal with arbitration loss\n");
  3749. + }
  3750. + } else {
  3751. + timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
  3752. }
  3753. - timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
  3754. -
  3755. ret = i2c->msg_idx;
  3756. /*
  3757. diff --git drivers/infiniband/hw/hfi1/pio.c drivers/infiniband/hw/hfi1/pio.c
  3758. index 07bf282fd8aa..162f4cb4851a 100644
  3759. --- linux-4.14.336/drivers/infiniband/hw/hfi1/pio.c
  3760. +++ linux-4.14.336/drivers/infiniband/hw/hfi1/pio.c
  3761. @@ -2133,7 +2133,7 @@ int init_credit_return(struct hfi1_devdata *dd)
  3762. "Unable to allocate credit return DMA range for NUMA %d\n",
  3763. i);
  3764. ret = -ENOMEM;
  3765. - goto done;
  3766. + goto free_cr_base;
  3767. }
  3768. }
  3769. set_dev_node(&dd->pcidev->dev, dd->node);
  3770. @@ -2141,6 +2141,10 @@ int init_credit_return(struct hfi1_devdata *dd)
  3771. ret = 0;
  3772. done:
  3773. return ret;
  3774. +
  3775. +free_cr_base:
  3776. + free_credit_return(dd);
  3777. + goto done;
  3778. }
  3779. void free_credit_return(struct hfi1_devdata *dd)
  3780. diff --git drivers/infiniband/hw/mthca/mthca_cmd.c drivers/infiniband/hw/mthca/mthca_cmd.c
  3781. index 419a2a20c047..7df5155cdb48 100644
  3782. --- linux-4.14.336/drivers/infiniband/hw/mthca/mthca_cmd.c
  3783. +++ linux-4.14.336/drivers/infiniband/hw/mthca/mthca_cmd.c
  3784. @@ -641,7 +641,7 @@ void mthca_free_mailbox(struct mthca_dev *dev, struct mthca_mailbox *mailbox)
  3785. int mthca_SYS_EN(struct mthca_dev *dev)
  3786. {
  3787. - u64 out;
  3788. + u64 out = 0;
  3789. int ret;
  3790. ret = mthca_cmd_imm(dev, 0, &out, 0, 0, CMD_SYS_EN, CMD_TIME_CLASS_D);
  3791. @@ -1961,7 +1961,7 @@ int mthca_WRITE_MGM(struct mthca_dev *dev, int index,
  3792. int mthca_MGID_HASH(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
  3793. u16 *hash)
  3794. {
  3795. - u64 imm;
  3796. + u64 imm = 0;
  3797. int err;
  3798. err = mthca_cmd_imm(dev, mailbox->dma, &imm, 0, 0, CMD_MGID_HASH,
  3799. diff --git drivers/infiniband/hw/mthca/mthca_main.c drivers/infiniband/hw/mthca/mthca_main.c
  3800. index ccf50dafce9c..66a85f757a2f 100644
  3801. --- linux-4.14.336/drivers/infiniband/hw/mthca/mthca_main.c
  3802. +++ linux-4.14.336/drivers/infiniband/hw/mthca/mthca_main.c
  3803. @@ -382,7 +382,7 @@ static int mthca_init_icm(struct mthca_dev *mdev,
  3804. struct mthca_init_hca_param *init_hca,
  3805. u64 icm_size)
  3806. {
  3807. - u64 aux_pages;
  3808. + u64 aux_pages = 0;
  3809. int err;
  3810. err = mthca_SET_ICM_SIZE(mdev, icm_size, &aux_pages);
  3811. diff --git drivers/infiniband/ulp/ipoib/ipoib_multicast.c drivers/infiniband/ulp/ipoib/ipoib_multicast.c
  3812. index 9b3f47ae2016..25d7d9219591 100644
  3813. --- linux-4.14.336/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
  3814. +++ linux-4.14.336/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
  3815. @@ -543,21 +543,18 @@ static int ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast)
  3816. /* SM supports sendonly-fullmember, otherwise fallback to full-member */
  3817. rec.join_state = SENDONLY_FULLMEMBER_JOIN;
  3818. }
  3819. - spin_unlock_irq(&priv->lock);
  3820. multicast = ib_sa_join_multicast(&ipoib_sa_client, priv->ca, priv->port,
  3821. - &rec, comp_mask, GFP_KERNEL,
  3822. + &rec, comp_mask, GFP_ATOMIC,
  3823. ipoib_mcast_join_complete, mcast);
  3824. - spin_lock_irq(&priv->lock);
  3825. if (IS_ERR(multicast)) {
  3826. ret = PTR_ERR(multicast);
  3827. ipoib_warn(priv, "ib_sa_join_multicast failed, status %d\n", ret);
  3828. /* Requeue this join task with a backoff delay */
  3829. __ipoib_mcast_schedule_join_thread(priv, mcast, 1);
  3830. clear_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags);
  3831. - spin_unlock_irq(&priv->lock);
  3832. complete(&mcast->done);
  3833. - spin_lock_irq(&priv->lock);
  3834. + return ret;
  3835. }
  3836. return 0;
  3837. }
  3838. diff --git drivers/infiniband/ulp/srpt/ib_srpt.c drivers/infiniband/ulp/srpt/ib_srpt.c
  3839. index 1446e1cc69ae..08343e6116d2 100644
  3840. --- linux-4.14.336/drivers/infiniband/ulp/srpt/ib_srpt.c
  3841. +++ linux-4.14.336/drivers/infiniband/ulp/srpt/ib_srpt.c
  3842. @@ -80,12 +80,16 @@ module_param(srpt_srq_size, int, 0444);
  3843. MODULE_PARM_DESC(srpt_srq_size,
  3844. "Shared receive queue (SRQ) size.");
  3845. +static int srpt_set_u64_x(const char *buffer, struct kernel_param *kp)
  3846. +{
  3847. + return kstrtou64(buffer, 16, (u64 *)kp->arg);
  3848. +}
  3849. static int srpt_get_u64_x(char *buffer, struct kernel_param *kp)
  3850. {
  3851. return sprintf(buffer, "0x%016llx", *(u64 *)kp->arg);
  3852. }
  3853. -module_param_call(srpt_service_guid, NULL, srpt_get_u64_x, &srpt_service_guid,
  3854. - 0444);
  3855. +module_param_call(srpt_service_guid, srpt_set_u64_x, srpt_get_u64_x,
  3856. + &srpt_service_guid, 0444);
  3857. MODULE_PARM_DESC(srpt_service_guid,
  3858. "Using this value for ioc_guid, id_ext, and cm_listen_id"
  3859. " instead of using the node_guid of the first HCA.");
  3860. @@ -196,8 +200,10 @@ static const char *get_ch_state_name(enum rdma_ch_state s)
  3861. /**
  3862. * srpt_qp_event() - QP event callback function.
  3863. */
  3864. -static void srpt_qp_event(struct ib_event *event, struct srpt_rdma_ch *ch)
  3865. +static void srpt_qp_event(struct ib_event *event, void *ptr)
  3866. {
  3867. + struct srpt_rdma_ch *ch = ptr;
  3868. +
  3869. pr_debug("QP event %d on cm_id=%p sess_name=%s state=%d\n",
  3870. event->event, ch->cm_id, ch->sess_name, ch->state);
  3871. @@ -1663,8 +1669,7 @@ retry:
  3872. }
  3873. qp_init->qp_context = (void *)ch;
  3874. - qp_init->event_handler
  3875. - = (void(*)(struct ib_event *, void*))srpt_qp_event;
  3876. + qp_init->event_handler = srpt_qp_event;
  3877. qp_init->send_cq = ch->cq;
  3878. qp_init->recv_cq = ch->cq;
  3879. qp_init->srq = sdev->srq;
  3880. diff --git drivers/input/joystick/xpad.c drivers/input/joystick/xpad.c
  3881. index 1dbe30335458..3fedc3688e8f 100644
  3882. --- linux-4.14.336/drivers/input/joystick/xpad.c
  3883. +++ linux-4.14.336/drivers/input/joystick/xpad.c
  3884. @@ -282,6 +282,7 @@ static const struct xpad_device {
  3885. { 0x146b, 0x0604, "Bigben Interactive DAIJA Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
  3886. { 0x1532, 0x0a00, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
  3887. { 0x1532, 0x0a03, "Razer Wildcat", 0, XTYPE_XBOXONE },
  3888. + { 0x1532, 0x0a29, "Razer Wolverine V2", 0, XTYPE_XBOXONE },
  3889. { 0x15e4, 0x3f00, "Power A Mini Pro Elite", 0, XTYPE_XBOX360 },
  3890. { 0x15e4, 0x3f0a, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
  3891. { 0x15e4, 0x3f10, "Batarang Xbox 360 controller", 0, XTYPE_XBOX360 },
  3892. diff --git drivers/input/keyboard/atkbd.c drivers/input/keyboard/atkbd.c
  3893. index 7e75835e220f..585bf7392539 100644
  3894. --- linux-4.14.336/drivers/input/keyboard/atkbd.c
  3895. +++ linux-4.14.336/drivers/input/keyboard/atkbd.c
  3896. @@ -717,6 +717,44 @@ static void atkbd_deactivate(struct atkbd *atkbd)
  3897. ps2dev->serio->phys);
  3898. }
  3899. +#ifdef CONFIG_X86
  3900. +static bool atkbd_is_portable_device(void)
  3901. +{
  3902. + static const char * const chassis_types[] = {
  3903. + "8", /* Portable */
  3904. + "9", /* Laptop */
  3905. + "10", /* Notebook */
  3906. + "14", /* Sub-Notebook */
  3907. + "31", /* Convertible */
  3908. + "32", /* Detachable */
  3909. + };
  3910. + int i;
  3911. +
  3912. + for (i = 0; i < ARRAY_SIZE(chassis_types); i++)
  3913. + if (dmi_match(DMI_CHASSIS_TYPE, chassis_types[i]))
  3914. + return true;
  3915. +
  3916. + return false;
  3917. +}
  3918. +
  3919. +/*
  3920. + * On many modern laptops ATKBD_CMD_GETID may cause problems, on these laptops
  3921. + * the controller is always in translated mode. In this mode mice/touchpads will
  3922. + * not work. So in this case simply assume a keyboard is connected to avoid
  3923. + * confusing some laptop keyboards.
  3924. + *
  3925. + * Skipping ATKBD_CMD_GETID ends up using a fake keyboard id. Using the standard
  3926. + * 0xab83 id is ok in translated mode, only atkbd_select_set() checks atkbd->id
  3927. + * and in translated mode that is a no-op.
  3928. + */
  3929. +static bool atkbd_skip_getid(struct atkbd *atkbd)
  3930. +{
  3931. + return atkbd->translated && atkbd_is_portable_device();
  3932. +}
  3933. +#else
  3934. +static inline bool atkbd_skip_getid(struct atkbd *atkbd) { return false; }
  3935. +#endif
  3936. +
  3937. /*
  3938. * atkbd_probe() probes for an AT keyboard on a serio port.
  3939. */
  3940. @@ -738,6 +776,11 @@ static int atkbd_probe(struct atkbd *atkbd)
  3941. "keyboard reset failed on %s\n",
  3942. ps2dev->serio->phys);
  3943. + if (atkbd_skip_getid(atkbd)) {
  3944. + atkbd->id = 0xab83;
  3945. + return 0;
  3946. + }
  3947. +
  3948. /*
  3949. * Then we check the keyboard ID. We should get 0xab83 under normal conditions.
  3950. * Some keyboards report different values, but the first byte is always 0xab or
  3951. @@ -749,9 +792,9 @@ static int atkbd_probe(struct atkbd *atkbd)
  3952. if (ps2_command(ps2dev, param, ATKBD_CMD_GETID)) {
  3953. /*
  3954. - * If the get ID command failed, we check if we can at least set the LEDs on
  3955. - * the keyboard. This should work on every keyboard out there. It also turns
  3956. - * the LEDs off, which we want anyway.
  3957. + * If the get ID command failed, we check if we can at least set
  3958. + * the LEDs on the keyboard. This should work on every keyboard out there.
  3959. + * It also turns the LEDs off, which we want anyway.
  3960. */
  3961. param[0] = 0;
  3962. if (ps2_command(ps2dev, param, ATKBD_CMD_SETLEDS))
  3963. diff --git drivers/irqchip/irq-brcmstb-l2.c drivers/irqchip/irq-brcmstb-l2.c
  3964. index b009b916a292..da8a426e9def 100644
  3965. --- linux-4.14.336/drivers/irqchip/irq-brcmstb-l2.c
  3966. +++ linux-4.14.336/drivers/irqchip/irq-brcmstb-l2.c
  3967. @@ -76,6 +76,9 @@ static void brcmstb_l2_intc_irq_handle(struct irq_desc *desc)
  3968. generic_handle_irq(irq_find_mapping(b->domain, irq));
  3969. } while (status);
  3970. out:
  3971. + /* Don't ack parent before all device writes are done */
  3972. + wmb();
  3973. +
  3974. chained_irq_exit(chip, desc);
  3975. }
  3976. diff --git drivers/leds/trigger/ledtrig-panic.c drivers/leds/trigger/ledtrig-panic.c
  3977. index d735526b9db4..2fc04418a87e 100644
  3978. --- linux-4.14.336/drivers/leds/trigger/ledtrig-panic.c
  3979. +++ linux-4.14.336/drivers/leds/trigger/ledtrig-panic.c
  3980. @@ -67,10 +67,13 @@ static long led_panic_blink(int state)
  3981. static int __init ledtrig_panic_init(void)
  3982. {
  3983. + led_trigger_register_simple("panic", &trigger);
  3984. + if (!trigger)
  3985. + return -ENOMEM;
  3986. +
  3987. atomic_notifier_chain_register(&panic_notifier_list,
  3988. &led_trigger_panic_nb);
  3989. - led_trigger_register_simple("panic", &trigger);
  3990. panic_blink = led_panic_blink;
  3991. return 0;
  3992. }
  3993. diff --git drivers/md/dm-crypt.c drivers/md/dm-crypt.c
  3994. index 7cc4281d5a79..966fb898f4b8 100644
  3995. --- linux-4.14.336/drivers/md/dm-crypt.c
  3996. +++ linux-4.14.336/drivers/md/dm-crypt.c
  3997. @@ -1742,6 +1742,12 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
  3998. io->ctx.bio_out = clone;
  3999. io->ctx.iter_out = clone->bi_iter;
  4000. + if (crypt_integrity_aead(cc)) {
  4001. + bio_copy_data(clone, io->base_bio);
  4002. + io->ctx.bio_in = clone;
  4003. + io->ctx.iter_in = clone->bi_iter;
  4004. + }
  4005. +
  4006. sector += bio_sectors(clone);
  4007. crypt_inc_pending(io);
  4008. diff --git drivers/md/md.c drivers/md/md.c
  4009. index 3c2364d0d88f..07da8d7569b5 100644
  4010. --- linux-4.14.336/drivers/md/md.c
  4011. +++ linux-4.14.336/drivers/md/md.c
  4012. @@ -1018,6 +1018,7 @@ struct super_type {
  4013. struct md_rdev *refdev,
  4014. int minor_version);
  4015. int (*validate_super)(struct mddev *mddev,
  4016. + struct md_rdev *freshest,
  4017. struct md_rdev *rdev);
  4018. void (*sync_super)(struct mddev *mddev,
  4019. struct md_rdev *rdev);
  4020. @@ -1144,8 +1145,9 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
  4021. /*
  4022. * validate_super for 0.90.0
  4023. + * note: we are not using "freshest" for 0.9 superblock
  4024. */
  4025. -static int super_90_validate(struct mddev *mddev, struct md_rdev *rdev)
  4026. +static int super_90_validate(struct mddev *mddev, struct md_rdev *freshest, struct md_rdev *rdev)
  4027. {
  4028. mdp_disk_t *desc;
  4029. mdp_super_t *sb = page_address(rdev->sb_page);
  4030. @@ -1649,7 +1651,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
  4031. return ret;
  4032. }
  4033. -static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
  4034. +static int super_1_validate(struct mddev *mddev, struct md_rdev *freshest, struct md_rdev *rdev)
  4035. {
  4036. struct mdp_superblock_1 *sb = page_address(rdev->sb_page);
  4037. __u64 ev1 = le64_to_cpu(sb->events);
  4038. @@ -1745,13 +1747,15 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
  4039. }
  4040. } else if (mddev->pers == NULL) {
  4041. /* Insist of good event counter while assembling, except for
  4042. - * spares (which don't need an event count) */
  4043. - ++ev1;
  4044. + * spares (which don't need an event count).
  4045. + * Similar to mdadm, we allow event counter difference of 1
  4046. + * from the freshest device.
  4047. + */
  4048. if (rdev->desc_nr >= 0 &&
  4049. rdev->desc_nr < le32_to_cpu(sb->max_dev) &&
  4050. (le16_to_cpu(sb->dev_roles[rdev->desc_nr]) < MD_DISK_ROLE_MAX ||
  4051. le16_to_cpu(sb->dev_roles[rdev->desc_nr]) == MD_DISK_ROLE_JOURNAL))
  4052. - if (ev1 < mddev->events)
  4053. + if (ev1 + 1 < mddev->events)
  4054. return -EINVAL;
  4055. } else if (mddev->bitmap) {
  4056. /* If adding to array with a bitmap, then we can accept an
  4057. @@ -1772,8 +1776,38 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
  4058. rdev->desc_nr >= le32_to_cpu(sb->max_dev)) {
  4059. role = MD_DISK_ROLE_SPARE;
  4060. rdev->desc_nr = -1;
  4061. - } else
  4062. + } else if (mddev->pers == NULL && freshest && ev1 < mddev->events) {
  4063. + /*
  4064. + * If we are assembling, and our event counter is smaller than the
  4065. + * highest event counter, we cannot trust our superblock about the role.
  4066. + * It could happen that our rdev was marked as Faulty, and all other
  4067. + * superblocks were updated with +1 event counter.
  4068. + * Then, before the next superblock update, which typically happens when
  4069. + * remove_and_add_spares() removes the device from the array, there was
  4070. + * a crash or reboot.
  4071. + * If we allow current rdev without consulting the freshest superblock,
  4072. + * we could cause data corruption.
  4073. + * Note that in this case our event counter is smaller by 1 than the
  4074. + * highest, otherwise, this rdev would not be allowed into array;
  4075. + * both kernel and mdadm allow event counter difference of 1.
  4076. + */
  4077. + struct mdp_superblock_1 *freshest_sb = page_address(freshest->sb_page);
  4078. + u32 freshest_max_dev = le32_to_cpu(freshest_sb->max_dev);
  4079. +
  4080. + if (rdev->desc_nr >= freshest_max_dev) {
  4081. + /* this is unexpected, better not proceed */
  4082. + pr_warn("md: %s: rdev[%pg]: desc_nr(%d) >= freshest(%pg)->sb->max_dev(%u)\n",
  4083. + mdname(mddev), rdev->bdev, rdev->desc_nr,
  4084. + freshest->bdev, freshest_max_dev);
  4085. + return -EUCLEAN;
  4086. + }
  4087. +
  4088. + role = le16_to_cpu(freshest_sb->dev_roles[rdev->desc_nr]);
  4089. + pr_debug("md: %s: rdev[%pg]: role=%d(0x%x) according to freshest %pg\n",
  4090. + mdname(mddev), rdev->bdev, role, role, freshest->bdev);
  4091. + } else {
  4092. role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]);
  4093. + }
  4094. switch(role) {
  4095. case MD_DISK_ROLE_SPARE: /* spare */
  4096. break;
  4097. @@ -2667,7 +2701,7 @@ static int add_bound_rdev(struct md_rdev *rdev)
  4098. * and should be added immediately.
  4099. */
  4100. super_types[mddev->major_version].
  4101. - validate_super(mddev, rdev);
  4102. + validate_super(mddev, NULL/*freshest*/, rdev);
  4103. if (add_journal)
  4104. mddev_suspend(mddev);
  4105. err = mddev->pers->hot_add_disk(mddev, rdev);
  4106. @@ -3569,7 +3603,7 @@ static void analyze_sbs(struct mddev *mddev)
  4107. }
  4108. super_types[mddev->major_version].
  4109. - validate_super(mddev, freshest);
  4110. + validate_super(mddev, NULL/*freshest*/, freshest);
  4111. i = 0;
  4112. rdev_for_each_safe(rdev, tmp, mddev) {
  4113. @@ -3584,7 +3618,7 @@ static void analyze_sbs(struct mddev *mddev)
  4114. }
  4115. if (rdev != freshest) {
  4116. if (super_types[mddev->major_version].
  4117. - validate_super(mddev, rdev)) {
  4118. + validate_super(mddev, freshest, rdev)) {
  4119. pr_warn("md: kicking non-fresh %s from array!\n",
  4120. bdevname(rdev->bdev,b));
  4121. md_kick_rdev_from_array(rdev);
  4122. @@ -6424,7 +6458,7 @@ static int add_new_disk(struct mddev *mddev, mdu_disk_info_t *info)
  4123. rdev->saved_raid_disk = rdev->raid_disk;
  4124. } else
  4125. super_types[mddev->major_version].
  4126. - validate_super(mddev, rdev);
  4127. + validate_super(mddev, NULL/*freshest*/, rdev);
  4128. if ((info->state & (1<<MD_DISK_SYNC)) &&
  4129. rdev->raid_disk != info->raid_disk) {
  4130. /* This was a hot-add request, but events doesn't
  4131. diff --git drivers/md/raid5.c drivers/md/raid5.c
  4132. index d2ac3d189410..6fca2df66550 100644
  4133. --- linux-4.14.336/drivers/md/raid5.c
  4134. +++ linux-4.14.336/drivers/md/raid5.c
  4135. @@ -44,7 +44,6 @@
  4136. */
  4137. #include <linux/blkdev.h>
  4138. -#include <linux/delay.h>
  4139. #include <linux/kthread.h>
  4140. #include <linux/raid/pq.h>
  4141. #include <linux/async_tx.h>
  4142. @@ -6309,18 +6308,7 @@ static void raid5d(struct md_thread *thread)
  4143. spin_unlock_irq(&conf->device_lock);
  4144. md_check_recovery(mddev);
  4145. spin_lock_irq(&conf->device_lock);
  4146. -
  4147. - /*
  4148. - * Waiting on MD_SB_CHANGE_PENDING below may deadlock
  4149. - * seeing md_check_recovery() is needed to clear
  4150. - * the flag when using mdmon.
  4151. - */
  4152. - continue;
  4153. }
  4154. -
  4155. - wait_event_lock_irq(mddev->sb_wait,
  4156. - !test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags),
  4157. - conf->device_lock);
  4158. }
  4159. pr_debug("%d stripes handled\n", handled);
  4160. diff --git drivers/media/dvb-core/dvbdev.c drivers/media/dvb-core/dvbdev.c
  4161. index 1b3a54520d68..0506179a7c86 100644
  4162. --- linux-4.14.336/drivers/media/dvb-core/dvbdev.c
  4163. +++ linux-4.14.336/drivers/media/dvb-core/dvbdev.c
  4164. @@ -90,6 +90,8 @@ static int dvb_device_open(struct inode *inode, struct file *file)
  4165. err = file->f_op->open(inode, file);
  4166. up_read(&minor_rwsem);
  4167. mutex_unlock(&dvbdev_mutex);
  4168. + if (err)
  4169. + dvb_device_put(dvbdev);
  4170. return err;
  4171. }
  4172. fail:
  4173. diff --git drivers/media/pci/ddbridge/ddbridge-main.c drivers/media/pci/ddbridge/ddbridge-main.c
  4174. index ccac7fe31336..13aab32f8048 100644
  4175. --- linux-4.14.336/drivers/media/pci/ddbridge/ddbridge-main.c
  4176. +++ linux-4.14.336/drivers/media/pci/ddbridge/ddbridge-main.c
  4177. @@ -265,7 +265,7 @@ fail:
  4178. ddb_unmap(dev);
  4179. pci_set_drvdata(pdev, NULL);
  4180. pci_disable_device(pdev);
  4181. - return -1;
  4182. + return stat;
  4183. }
  4184. /****************************************************************************/
  4185. diff --git drivers/media/usb/cx231xx/cx231xx-core.c drivers/media/usb/cx231xx/cx231xx-core.c
  4186. index f372ad3917a8..61fd934c0205 100644
  4187. --- linux-4.14.336/drivers/media/usb/cx231xx/cx231xx-core.c
  4188. +++ linux-4.14.336/drivers/media/usb/cx231xx/cx231xx-core.c
  4189. @@ -1038,6 +1038,7 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
  4190. if (!dev->video_mode.isoc_ctl.urb) {
  4191. dev_err(dev->dev,
  4192. "cannot alloc memory for usb buffers\n");
  4193. + kfree(dma_q->p_left_data);
  4194. return -ENOMEM;
  4195. }
  4196. @@ -1047,6 +1048,7 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
  4197. dev_err(dev->dev,
  4198. "cannot allocate memory for usbtransfer\n");
  4199. kfree(dev->video_mode.isoc_ctl.urb);
  4200. + kfree(dma_q->p_left_data);
  4201. return -ENOMEM;
  4202. }
  4203. diff --git drivers/media/usb/pvrusb2/pvrusb2-context.c drivers/media/usb/pvrusb2/pvrusb2-context.c
  4204. index d9e8481e9e28..9236463ba269 100644
  4205. --- linux-4.14.336/drivers/media/usb/pvrusb2/pvrusb2-context.c
  4206. +++ linux-4.14.336/drivers/media/usb/pvrusb2/pvrusb2-context.c
  4207. @@ -277,7 +277,8 @@ void pvr2_context_disconnect(struct pvr2_context *mp)
  4208. {
  4209. pvr2_hdw_disconnect(mp->hdw);
  4210. mp->disconnect_flag = !0;
  4211. - pvr2_context_notify(mp);
  4212. + if (!pvr2_context_shutok())
  4213. + pvr2_context_notify(mp);
  4214. }
  4215. diff --git drivers/media/usb/stk1160/stk1160-video.c drivers/media/usb/stk1160/stk1160-video.c
  4216. index ce8ebbe395a6..8a6cdbc36a08 100644
  4217. --- linux-4.14.336/drivers/media/usb/stk1160/stk1160-video.c
  4218. +++ linux-4.14.336/drivers/media/usb/stk1160/stk1160-video.c
  4219. @@ -117,8 +117,7 @@ void stk1160_copy_video(struct stk1160 *dev, u8 *src, int len)
  4220. /*
  4221. * TODO: These stk1160_dbg are very spammy!
  4222. - * We should 1) check why we are getting them
  4223. - * and 2) add ratelimit.
  4224. + * We should check why we are getting them.
  4225. *
  4226. * UPDATE: One of the reasons (the only one?) for getting these
  4227. * is incorrect standard (mismatch between expected and configured).
  4228. @@ -161,7 +160,7 @@ void stk1160_copy_video(struct stk1160 *dev, u8 *src, int len)
  4229. /* Let the bug hunt begin! sanity checks! */
  4230. if (lencopy < 0) {
  4231. - stk1160_dbg("copy skipped: negative lencopy\n");
  4232. + printk_ratelimited(KERN_DEBUG "copy skipped: negative lencopy\n");
  4233. return;
  4234. }
  4235. diff --git drivers/mfd/Kconfig drivers/mfd/Kconfig
  4236. index fc5e4fef89d2..7e90ed8fdb1c 100644
  4237. --- linux-4.14.336/drivers/mfd/Kconfig
  4238. +++ linux-4.14.336/drivers/mfd/Kconfig
  4239. @@ -1199,6 +1199,7 @@ config MFD_DAVINCI_VOICECODEC
  4240. config MFD_TI_AM335X_TSCADC
  4241. tristate "TI ADC / Touch Screen chip support"
  4242. + depends on ARCH_OMAP2PLUS || ARCH_K3 || COMPILE_TEST
  4243. select MFD_CORE
  4244. select REGMAP
  4245. select REGMAP_MMIO
  4246. diff --git drivers/mmc/core/mmc.c drivers/mmc/core/mmc.c
  4247. index 32bf0b47e339..69f0cc3a28bc 100644
  4248. --- linux-4.14.336/drivers/mmc/core/mmc.c
  4249. +++ linux-4.14.336/drivers/mmc/core/mmc.c
  4250. @@ -990,10 +990,12 @@ static int mmc_select_bus_width(struct mmc_card *card)
  4251. static unsigned ext_csd_bits[] = {
  4252. EXT_CSD_BUS_WIDTH_8,
  4253. EXT_CSD_BUS_WIDTH_4,
  4254. + EXT_CSD_BUS_WIDTH_1,
  4255. };
  4256. static unsigned bus_widths[] = {
  4257. MMC_BUS_WIDTH_8,
  4258. MMC_BUS_WIDTH_4,
  4259. + MMC_BUS_WIDTH_1,
  4260. };
  4261. struct mmc_host *host = card->host;
  4262. unsigned idx, bus_width = 0;
  4263. diff --git drivers/mtd/mtd_blkdevs.c drivers/mtd/mtd_blkdevs.c
  4264. index 9ec8f033ac5f..5a76e7c549ef 100644
  4265. --- linux-4.14.336/drivers/mtd/mtd_blkdevs.c
  4266. +++ linux-4.14.336/drivers/mtd/mtd_blkdevs.c
  4267. @@ -513,7 +513,7 @@ static void blktrans_notify_add(struct mtd_info *mtd)
  4268. {
  4269. struct mtd_blktrans_ops *tr;
  4270. - if (mtd->type == MTD_ABSENT)
  4271. + if (mtd->type == MTD_ABSENT || mtd->type == MTD_UBIVOLUME)
  4272. return;
  4273. list_for_each_entry(tr, &blktrans_majors, list)
  4274. @@ -556,7 +556,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
  4275. list_add(&tr->list, &blktrans_majors);
  4276. mtd_for_each_device(mtd)
  4277. - if (mtd->type != MTD_ABSENT)
  4278. + if (mtd->type != MTD_ABSENT && mtd->type != MTD_UBIVOLUME)
  4279. tr->add_mtd(tr, mtd);
  4280. mutex_unlock(&mtd_table_mutex);
  4281. diff --git drivers/mtd/nand/fsl_ifc_nand.c drivers/mtd/nand/fsl_ifc_nand.c
  4282. index 0d4928161439..be7d9eb7359c 100644
  4283. --- linux-4.14.336/drivers/mtd/nand/fsl_ifc_nand.c
  4284. +++ linux-4.14.336/drivers/mtd/nand/fsl_ifc_nand.c
  4285. @@ -33,7 +33,7 @@
  4286. #define ERR_BYTE 0xFF /* Value returned for read
  4287. bytes when read failed */
  4288. -#define IFC_TIMEOUT_MSECS 500 /* Maximum number of mSecs to wait
  4289. +#define IFC_TIMEOUT_MSECS 1000 /* Maximum timeout to wait
  4290. for IFC NAND Machine */
  4291. struct fsl_ifc_ctrl;
  4292. diff --git drivers/net/bonding/bond_alb.c drivers/net/bonding/bond_alb.c
  4293. index 4926c3e06e4e..6cd4e024b41d 100644
  4294. --- linux-4.14.336/drivers/net/bonding/bond_alb.c
  4295. +++ linux-4.14.336/drivers/net/bonding/bond_alb.c
  4296. @@ -988,7 +988,8 @@ static int alb_upper_dev_walk(struct net_device *upper, void *_data)
  4297. if (netif_is_macvlan(upper) && !strict_match) {
  4298. tags = bond_verify_device_path(bond->dev, upper, 0);
  4299. if (IS_ERR_OR_NULL(tags))
  4300. - BUG();
  4301. + return -ENOMEM;
  4302. +
  4303. alb_send_lp_vid(slave, upper->dev_addr,
  4304. tags[0].vlan_proto, tags[0].vlan_id);
  4305. kfree(tags);
  4306. diff --git drivers/net/ethernet/aquantia/atlantic/aq_nic.c drivers/net/ethernet/aquantia/atlantic/aq_nic.c
  4307. index 7a900f76c9ac..396c335909af 100644
  4308. --- linux-4.14.336/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
  4309. +++ linux-4.14.336/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
  4310. @@ -884,7 +884,6 @@ int aq_nic_set_link_ksettings(struct aq_nic_s *self,
  4311. default:
  4312. err = -1;
  4313. goto err_exit;
  4314. - break;
  4315. }
  4316. if (!(self->aq_hw_caps.link_speed_msk & rate)) {
  4317. err = -1;
  4318. diff --git drivers/net/ethernet/broadcom/bnxt/bnxt.c drivers/net/ethernet/broadcom/bnxt/bnxt.c
  4319. index ee438674d6cc..180a7ef588cf 100644
  4320. --- linux-4.14.336/drivers/net/ethernet/broadcom/bnxt/bnxt.c
  4321. +++ linux-4.14.336/drivers/net/ethernet/broadcom/bnxt/bnxt.c
  4322. @@ -7092,6 +7092,8 @@ static void bnxt_sp_task(struct work_struct *work)
  4323. bnxt_cfg_ntp_filters(bp);
  4324. if (test_and_clear_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event))
  4325. bnxt_hwrm_exec_fwd_req(bp);
  4326. + if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event))
  4327. + netdev_info(bp->dev, "Receive PF driver unload event!\n");
  4328. if (test_and_clear_bit(BNXT_VXLAN_ADD_PORT_SP_EVENT, &bp->sp_event)) {
  4329. bnxt_hwrm_tunnel_dst_port_alloc(
  4330. bp, bp->vxlan_port,
  4331. @@ -7583,8 +7585,6 @@ static void bnxt_cfg_ntp_filters(struct bnxt *bp)
  4332. }
  4333. }
  4334. }
  4335. - if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event))
  4336. - netdev_info(bp->dev, "Receive PF driver unload event!");
  4337. }
  4338. #else
  4339. diff --git drivers/net/ethernet/broadcom/tg3.c drivers/net/ethernet/broadcom/tg3.c
  4340. index dc27c81ad512..44556eea780b 100644
  4341. --- linux-4.14.336/drivers/net/ethernet/broadcom/tg3.c
  4342. +++ linux-4.14.336/drivers/net/ethernet/broadcom/tg3.c
  4343. @@ -6434,6 +6434,14 @@ static void tg3_dump_state(struct tg3 *tp)
  4344. int i;
  4345. u32 *regs;
  4346. + /* If it is a PCI error, all registers will be 0xffff,
  4347. + * we don't dump them out, just report the error and return
  4348. + */
  4349. + if (tp->pdev->error_state != pci_channel_io_normal) {
  4350. + netdev_err(tp->dev, "PCI channel ERROR!\n");
  4351. + return;
  4352. + }
  4353. +
  4354. regs = kzalloc(TG3_REG_BLK_SIZE, GFP_ATOMIC);
  4355. if (!regs)
  4356. return;
  4357. @@ -11168,7 +11176,8 @@ static void tg3_reset_task(struct work_struct *work)
  4358. rtnl_lock();
  4359. tg3_full_lock(tp, 0);
  4360. - if (tp->pcierr_recovery || !netif_running(tp->dev)) {
  4361. + if (tp->pcierr_recovery || !netif_running(tp->dev) ||
  4362. + tp->pdev->error_state != pci_channel_io_normal) {
  4363. tg3_flag_clear(tp, RESET_TASK_PENDING);
  4364. tg3_full_unlock(tp);
  4365. rtnl_unlock();
  4366. diff --git drivers/net/ethernet/cisco/enic/enic_ethtool.c drivers/net/ethernet/cisco/enic/enic_ethtool.c
  4367. index fd3980cc1e34..3280fbad5d5a 100644
  4368. --- linux-4.14.336/drivers/net/ethernet/cisco/enic/enic_ethtool.c
  4369. +++ linux-4.14.336/drivers/net/ethernet/cisco/enic/enic_ethtool.c
  4370. @@ -378,7 +378,6 @@ static int enic_grxclsrule(struct enic *enic, struct ethtool_rxnfc *cmd)
  4371. break;
  4372. default:
  4373. return -EINVAL;
  4374. - break;
  4375. }
  4376. fsp->h_u.tcp_ip4_spec.ip4src = flow_get_u32_src(&n->keys);
  4377. diff --git drivers/net/ethernet/freescale/fec_main.c drivers/net/ethernet/freescale/fec_main.c
  4378. index 1085f1d721b0..4b169890d301 100644
  4379. --- linux-4.14.336/drivers/net/ethernet/freescale/fec_main.c
  4380. +++ linux-4.14.336/drivers/net/ethernet/freescale/fec_main.c
  4381. @@ -1746,6 +1746,7 @@ static void fec_enet_adjust_link(struct net_device *ndev)
  4382. /* if any of the above changed restart the FEC */
  4383. if (status_change) {
  4384. + netif_stop_queue(ndev);
  4385. napi_disable(&fep->napi);
  4386. netif_tx_lock_bh(ndev);
  4387. fec_restart(ndev);
  4388. @@ -1755,6 +1756,7 @@ static void fec_enet_adjust_link(struct net_device *ndev)
  4389. }
  4390. } else {
  4391. if (fep->link) {
  4392. + netif_stop_queue(ndev);
  4393. napi_disable(&fep->napi);
  4394. netif_tx_lock_bh(ndev);
  4395. fec_stop(ndev);
  4396. diff --git drivers/net/ethernet/intel/i40e/i40e_main.c drivers/net/ethernet/intel/i40e/i40e_main.c
  4397. index a783ebb14db9..ec5da7cbf416 100644
  4398. --- linux-4.14.336/drivers/net/ethernet/intel/i40e/i40e_main.c
  4399. +++ linux-4.14.336/drivers/net/ethernet/intel/i40e/i40e_main.c
  4400. @@ -4708,7 +4708,7 @@ static int i40e_pf_wait_queues_disabled(struct i40e_pf *pf)
  4401. {
  4402. int v, ret = 0;
  4403. - for (v = 0; v < pf->hw.func_caps.num_vsis; v++) {
  4404. + for (v = 0; v < pf->num_alloc_vsi; v++) {
  4405. if (pf->vsi[v]) {
  4406. ret = i40e_vsi_wait_queues_disabled(pf->vsi[v]);
  4407. if (ret)
  4408. diff --git drivers/net/ethernet/intel/ixgbe/ixgbe_common.c drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
  4409. index 6b5662674c75..71583f8756c2 100644
  4410. --- linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
  4411. +++ linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
  4412. @@ -55,7 +55,7 @@ static s32 ixgbe_write_eeprom_buffer_bit_bang(struct ixgbe_hw *hw, u16 offset,
  4413. u16 words, u16 *data);
  4414. static s32 ixgbe_detect_eeprom_page_size_generic(struct ixgbe_hw *hw,
  4415. u16 offset);
  4416. -static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw);
  4417. +static s32 ixgbe_disable_pcie_primary(struct ixgbe_hw *hw);
  4418. /* Base table for registers values that change by MAC */
  4419. const u32 ixgbe_mvals_8259X[IXGBE_MVALS_IDX_LIMIT] = {
  4420. @@ -771,10 +771,10 @@ s32 ixgbe_stop_adapter_generic(struct ixgbe_hw *hw)
  4421. usleep_range(1000, 2000);
  4422. /*
  4423. - * Prevent the PCI-E bus from from hanging by disabling PCI-E master
  4424. + * Prevent the PCI-E bus from hanging by disabling PCI-E primary
  4425. * access and verify no pending requests
  4426. */
  4427. - return ixgbe_disable_pcie_master(hw);
  4428. + return ixgbe_disable_pcie_primary(hw);
  4429. }
  4430. /**
  4431. @@ -2530,15 +2530,15 @@ static u32 ixgbe_pcie_timeout_poll(struct ixgbe_hw *hw)
  4432. }
  4433. /**
  4434. - * ixgbe_disable_pcie_master - Disable PCI-express master access
  4435. + * ixgbe_disable_pcie_primary - Disable PCI-express primary access
  4436. * @hw: pointer to hardware structure
  4437. *
  4438. - * Disables PCI-Express master access and verifies there are no pending
  4439. - * requests. IXGBE_ERR_MASTER_REQUESTS_PENDING is returned if master disable
  4440. - * bit hasn't caused the master requests to be disabled, else 0
  4441. - * is returned signifying master requests disabled.
  4442. + * Disables PCI-Express primary access and verifies there are no pending
  4443. + * requests. IXGBE_ERR_PRIMARY_REQUESTS_PENDING is returned if primary disable
  4444. + * bit hasn't caused the primary requests to be disabled, else 0
  4445. + * is returned signifying primary requests disabled.
  4446. **/
  4447. -static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)
  4448. +static s32 ixgbe_disable_pcie_primary(struct ixgbe_hw *hw)
  4449. {
  4450. u32 i, poll;
  4451. u16 value;
  4452. @@ -2547,23 +2547,23 @@ static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)
  4453. IXGBE_WRITE_REG(hw, IXGBE_CTRL, IXGBE_CTRL_GIO_DIS);
  4454. /* Poll for bit to read as set */
  4455. - for (i = 0; i < IXGBE_PCI_MASTER_DISABLE_TIMEOUT; i++) {
  4456. + for (i = 0; i < IXGBE_PCI_PRIMARY_DISABLE_TIMEOUT; i++) {
  4457. if (IXGBE_READ_REG(hw, IXGBE_CTRL) & IXGBE_CTRL_GIO_DIS)
  4458. break;
  4459. usleep_range(100, 120);
  4460. }
  4461. - if (i >= IXGBE_PCI_MASTER_DISABLE_TIMEOUT) {
  4462. + if (i >= IXGBE_PCI_PRIMARY_DISABLE_TIMEOUT) {
  4463. hw_dbg(hw, "GIO disable did not set - requesting resets\n");
  4464. goto gio_disable_fail;
  4465. }
  4466. - /* Exit if master requests are blocked */
  4467. + /* Exit if primary requests are blocked */
  4468. if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO) ||
  4469. ixgbe_removed(hw->hw_addr))
  4470. return 0;
  4471. - /* Poll for master request bit to clear */
  4472. - for (i = 0; i < IXGBE_PCI_MASTER_DISABLE_TIMEOUT; i++) {
  4473. + /* Poll for primary request bit to clear */
  4474. + for (i = 0; i < IXGBE_PCI_PRIMARY_DISABLE_TIMEOUT; i++) {
  4475. udelay(100);
  4476. if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO))
  4477. return 0;
  4478. @@ -2571,13 +2571,13 @@ static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)
  4479. /*
  4480. * Two consecutive resets are required via CTRL.RST per datasheet
  4481. - * 5.2.5.3.2 Master Disable. We set a flag to inform the reset routine
  4482. - * of this need. The first reset prevents new master requests from
  4483. + * 5.2.5.3.2 Primary Disable. We set a flag to inform the reset routine
  4484. + * of this need. The first reset prevents new primary requests from
  4485. * being issued by our device. We then must wait 1usec or more for any
  4486. * remaining completions from the PCIe bus to trickle in, and then reset
  4487. * again to clear out any effects they may have had on our device.
  4488. */
  4489. - hw_dbg(hw, "GIO Master Disable bit didn't clear - requesting resets\n");
  4490. + hw_dbg(hw, "GIO Primary Disable bit didn't clear - requesting resets\n");
  4491. gio_disable_fail:
  4492. hw->mac.flags |= IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
  4493. @@ -2599,7 +2599,7 @@ gio_disable_fail:
  4494. }
  4495. hw_dbg(hw, "PCIe transaction pending bit also did not clear.\n");
  4496. - return IXGBE_ERR_MASTER_REQUESTS_PENDING;
  4497. + return IXGBE_ERR_PRIMARY_REQUESTS_PENDING;
  4498. }
  4499. /**
  4500. diff --git drivers/net/ethernet/intel/ixgbe/ixgbe_main.c drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
  4501. index ac9835e61602..ca9bdaed31c5 100644
  4502. --- linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
  4503. +++ linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
  4504. @@ -2660,7 +2660,6 @@ static void ixgbe_check_overtemp_subtask(struct ixgbe_adapter *adapter)
  4505. {
  4506. struct ixgbe_hw *hw = &adapter->hw;
  4507. u32 eicr = adapter->interrupt_event;
  4508. - s32 rc;
  4509. if (test_bit(__IXGBE_DOWN, &adapter->state))
  4510. return;
  4511. @@ -2694,14 +2693,13 @@ static void ixgbe_check_overtemp_subtask(struct ixgbe_adapter *adapter)
  4512. }
  4513. /* Check if this is not due to overtemp */
  4514. - if (hw->phy.ops.check_overtemp(hw) != IXGBE_ERR_OVERTEMP)
  4515. + if (!hw->phy.ops.check_overtemp(hw))
  4516. return;
  4517. break;
  4518. case IXGBE_DEV_ID_X550EM_A_1G_T:
  4519. case IXGBE_DEV_ID_X550EM_A_1G_T_L:
  4520. - rc = hw->phy.ops.check_overtemp(hw);
  4521. - if (rc != IXGBE_ERR_OVERTEMP)
  4522. + if (!hw->phy.ops.check_overtemp(hw))
  4523. return;
  4524. break;
  4525. default:
  4526. @@ -5690,8 +5688,8 @@ void ixgbe_reset(struct ixgbe_adapter *adapter)
  4527. case IXGBE_ERR_SFP_NOT_PRESENT:
  4528. case IXGBE_ERR_SFP_NOT_SUPPORTED:
  4529. break;
  4530. - case IXGBE_ERR_MASTER_REQUESTS_PENDING:
  4531. - e_dev_err("master disable timed out\n");
  4532. + case IXGBE_ERR_PRIMARY_REQUESTS_PENDING:
  4533. + e_dev_err("primary disable timed out\n");
  4534. break;
  4535. case IXGBE_ERR_EEPROM_VERSION:
  4536. /* We are running on a pre-production device, log a warning */
  4537. @@ -7636,7 +7634,7 @@ static void ixgbe_service_timer(unsigned long data)
  4538. static void ixgbe_phy_interrupt_subtask(struct ixgbe_adapter *adapter)
  4539. {
  4540. struct ixgbe_hw *hw = &adapter->hw;
  4541. - u32 status;
  4542. + bool overtemp;
  4543. if (!(adapter->flags2 & IXGBE_FLAG2_PHY_INTERRUPT))
  4544. return;
  4545. @@ -7646,11 +7644,9 @@ static void ixgbe_phy_interrupt_subtask(struct ixgbe_adapter *adapter)
  4546. if (!hw->phy.ops.handle_lasi)
  4547. return;
  4548. - status = hw->phy.ops.handle_lasi(&adapter->hw);
  4549. - if (status != IXGBE_ERR_OVERTEMP)
  4550. - return;
  4551. -
  4552. - e_crit(drv, "%s\n", ixgbe_overheat_msg);
  4553. + hw->phy.ops.handle_lasi(&adapter->hw, &overtemp);
  4554. + if (overtemp)
  4555. + e_crit(drv, "%s\n", ixgbe_overheat_msg);
  4556. }
  4557. static void ixgbe_reset_subtask(struct ixgbe_adapter *adapter)
  4558. diff --git drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
  4559. index 654a402f0e9e..09a7c0f4aa2a 100644
  4560. --- linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
  4561. +++ linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
  4562. @@ -429,8 +429,7 @@ s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
  4563. return status;
  4564. /* Don't reset PHY if it's shut down due to overtemp. */
  4565. - if (!hw->phy.reset_if_overtemp &&
  4566. - (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))
  4567. + if (!hw->phy.reset_if_overtemp && hw->phy.ops.check_overtemp(hw))
  4568. return 0;
  4569. /* Blocked by MNG FW so bail */
  4570. @@ -2329,22 +2328,24 @@ static void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw)
  4571. * @hw: pointer to hardware structure
  4572. *
  4573. * Checks if the LASI temp alarm status was triggered due to overtemp
  4574. + *
  4575. + * Return true when an overtemp event detected, otherwise false.
  4576. **/
  4577. -s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
  4578. +bool ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
  4579. {
  4580. u16 phy_data = 0;
  4581. + u32 status;
  4582. if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM)
  4583. - return 0;
  4584. + return false;
  4585. /* Check that the LASI temp alarm status was triggered */
  4586. - hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG,
  4587. - MDIO_MMD_PMAPMD, &phy_data);
  4588. -
  4589. - if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM))
  4590. - return 0;
  4591. + status = hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG,
  4592. + MDIO_MMD_PMAPMD, &phy_data);
  4593. + if (status)
  4594. + return false;
  4595. - return IXGBE_ERR_OVERTEMP;
  4596. + return !!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM);
  4597. }
  4598. /** ixgbe_set_copper_phy_power - Control power for copper phy
  4599. diff --git drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h
  4600. index 94df1d99be95..7002f0a534c7 100644
  4601. --- linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h
  4602. +++ linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h
  4603. @@ -178,7 +178,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw);
  4604. s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
  4605. u16 *list_offset,
  4606. u16 *data_offset);
  4607. -s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw);
  4608. +bool ixgbe_tn_check_overtemp(struct ixgbe_hw *hw);
  4609. s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
  4610. u8 dev_addr, u8 *data);
  4611. s32 ixgbe_read_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
  4612. diff --git drivers/net/ethernet/intel/ixgbe/ixgbe_type.h drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
  4613. index ffa0ee5cd0f5..93d18050284d 100644
  4614. --- linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
  4615. +++ linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
  4616. @@ -1227,7 +1227,7 @@ struct ixgbe_thermal_sensor_data {
  4617. #define IXGBE_PSRTYPE_RQPL_SHIFT 29
  4618. /* CTRL Bit Masks */
  4619. -#define IXGBE_CTRL_GIO_DIS 0x00000004 /* Global IO Master Disable bit */
  4620. +#define IXGBE_CTRL_GIO_DIS 0x00000004 /* Global IO Primary Disable bit */
  4621. #define IXGBE_CTRL_LNK_RST 0x00000008 /* Link Reset. Resets everything. */
  4622. #define IXGBE_CTRL_RST 0x04000000 /* Reset (SW) */
  4623. #define IXGBE_CTRL_RST_MASK (IXGBE_CTRL_LNK_RST | IXGBE_CTRL_RST)
  4624. @@ -1790,7 +1790,7 @@ enum {
  4625. /* STATUS Bit Masks */
  4626. #define IXGBE_STATUS_LAN_ID 0x0000000C /* LAN ID */
  4627. #define IXGBE_STATUS_LAN_ID_SHIFT 2 /* LAN ID Shift*/
  4628. -#define IXGBE_STATUS_GIO 0x00080000 /* GIO Master Enable Status */
  4629. +#define IXGBE_STATUS_GIO 0x00080000 /* GIO Primary Enable Status */
  4630. #define IXGBE_STATUS_LAN_ID_0 0x00000000 /* LAN ID 0 */
  4631. #define IXGBE_STATUS_LAN_ID_1 0x00000004 /* LAN ID 1 */
  4632. @@ -2172,8 +2172,8 @@ enum {
  4633. #define IXGBE_PCIDEVCTRL2_4_8s 0xd
  4634. #define IXGBE_PCIDEVCTRL2_17_34s 0xe
  4635. -/* Number of 100 microseconds we wait for PCI Express master disable */
  4636. -#define IXGBE_PCI_MASTER_DISABLE_TIMEOUT 800
  4637. +/* Number of 100 microseconds we wait for PCI Express primary disable */
  4638. +#define IXGBE_PCI_PRIMARY_DISABLE_TIMEOUT 800
  4639. /* RAH */
  4640. #define IXGBE_RAH_VIND_MASK 0x003C0000
  4641. @@ -3482,10 +3482,10 @@ struct ixgbe_phy_operations {
  4642. s32 (*read_i2c_sff8472)(struct ixgbe_hw *, u8 , u8 *);
  4643. s32 (*read_i2c_eeprom)(struct ixgbe_hw *, u8 , u8 *);
  4644. s32 (*write_i2c_eeprom)(struct ixgbe_hw *, u8, u8);
  4645. - s32 (*check_overtemp)(struct ixgbe_hw *);
  4646. + bool (*check_overtemp)(struct ixgbe_hw *);
  4647. s32 (*set_phy_power)(struct ixgbe_hw *, bool on);
  4648. s32 (*enter_lplu)(struct ixgbe_hw *);
  4649. - s32 (*handle_lasi)(struct ixgbe_hw *hw);
  4650. + s32 (*handle_lasi)(struct ixgbe_hw *hw, bool *);
  4651. s32 (*read_i2c_byte_unlocked)(struct ixgbe_hw *, u8 offset, u8 addr,
  4652. u8 *value);
  4653. s32 (*write_i2c_byte_unlocked)(struct ixgbe_hw *, u8 offset, u8 addr,
  4654. @@ -3651,7 +3651,7 @@ struct ixgbe_info {
  4655. #define IXGBE_ERR_ADAPTER_STOPPED -9
  4656. #define IXGBE_ERR_INVALID_MAC_ADDR -10
  4657. #define IXGBE_ERR_DEVICE_NOT_SUPPORTED -11
  4658. -#define IXGBE_ERR_MASTER_REQUESTS_PENDING -12
  4659. +#define IXGBE_ERR_PRIMARY_REQUESTS_PENDING -12
  4660. #define IXGBE_ERR_INVALID_LINK_SETTINGS -13
  4661. #define IXGBE_ERR_AUTONEG_NOT_COMPLETE -14
  4662. #define IXGBE_ERR_RESET_FAILED -15
  4663. diff --git drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
  4664. index 6ea0d6a5fb90..b5e4e78f86ee 100644
  4665. --- linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
  4666. +++ linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
  4667. @@ -375,7 +375,6 @@ static s32 ixgbe_calc_eeprom_checksum_X540(struct ixgbe_hw *hw)
  4668. if (ixgbe_read_eerd_generic(hw, pointer, &length)) {
  4669. hw_dbg(hw, "EEPROM read failed\n");
  4670. return IXGBE_ERR_EEPROM;
  4671. - break;
  4672. }
  4673. /* Skip pointer section if length is invalid. */
  4674. diff --git drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
  4675. index 10fa0e095ec3..f99596cf3d7e 100644
  4676. --- linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
  4677. +++ linux-4.14.336/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
  4678. @@ -620,8 +620,10 @@ static s32 ixgbe_setup_fw_link(struct ixgbe_hw *hw)
  4679. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_SETUP_LINK, &setup);
  4680. if (rc)
  4681. return rc;
  4682. +
  4683. if (setup[0] == FW_PHY_ACT_SETUP_LINK_RSP_DOWN)
  4684. - return IXGBE_ERR_OVERTEMP;
  4685. + return -EIO;
  4686. +
  4687. return 0;
  4688. }
  4689. @@ -735,7 +737,8 @@ static s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
  4690. error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
  4691. IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
  4692. hw_dbg(hw, "Failed to read, error %x\n", error);
  4693. - return IXGBE_ERR_PHY;
  4694. + ret = IXGBE_ERR_PHY;
  4695. + goto out;
  4696. }
  4697. if (!ret)
  4698. @@ -2314,18 +2317,18 @@ static s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
  4699. * @hw: pointer to hardware structure
  4700. * @lsc: pointer to boolean flag which indicates whether external Base T
  4701. * PHY interrupt is lsc
  4702. + * @is_overtemp: indicate whether an overtemp event encountered
  4703. *
  4704. * Determime if external Base T PHY interrupt cause is high temperature
  4705. * failure alarm or link status change.
  4706. - *
  4707. - * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
  4708. - * failure alarm, else return PHY access status.
  4709. **/
  4710. -static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
  4711. +static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc,
  4712. + bool *is_overtemp)
  4713. {
  4714. u32 status;
  4715. u16 reg;
  4716. + *is_overtemp = false;
  4717. *lsc = false;
  4718. /* Vendor alarm triggered */
  4719. @@ -2357,7 +2360,8 @@ static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
  4720. if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
  4721. /* power down the PHY in case the PHY FW didn't already */
  4722. ixgbe_set_copper_phy_power(hw, false);
  4723. - return IXGBE_ERR_OVERTEMP;
  4724. + *is_overtemp = true;
  4725. + return -EIO;
  4726. }
  4727. if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
  4728. /* device fault alarm triggered */
  4729. @@ -2371,7 +2375,8 @@ static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
  4730. if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
  4731. /* power down the PHY in case the PHY FW didn't */
  4732. ixgbe_set_copper_phy_power(hw, false);
  4733. - return IXGBE_ERR_OVERTEMP;
  4734. + *is_overtemp = true;
  4735. + return -EIO;
  4736. }
  4737. }
  4738. @@ -2407,12 +2412,12 @@ static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
  4739. **/
  4740. static s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
  4741. {
  4742. + bool lsc, overtemp;
  4743. u32 status;
  4744. u16 reg;
  4745. - bool lsc;
  4746. /* Clear interrupt flags */
  4747. - status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
  4748. + status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc, &overtemp);
  4749. /* Enable link status change alarm */
  4750. @@ -2491,21 +2496,20 @@ static s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
  4751. /**
  4752. * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
  4753. * @hw: pointer to hardware structure
  4754. + * @is_overtemp: indicate whether an overtemp event encountered
  4755. *
  4756. * Handle external Base T PHY interrupt. If high temperature
  4757. * failure alarm then return error, else if link status change
  4758. * then setup internal/external PHY link
  4759. - *
  4760. - * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
  4761. - * failure alarm, else return PHY access status.
  4762. **/
  4763. -static s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
  4764. +static s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw,
  4765. + bool *is_overtemp)
  4766. {
  4767. struct ixgbe_phy_info *phy = &hw->phy;
  4768. bool lsc;
  4769. u32 status;
  4770. - status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
  4771. + status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc, is_overtemp);
  4772. if (status)
  4773. return status;
  4774. @@ -3132,21 +3136,23 @@ static s32 ixgbe_reset_phy_fw(struct ixgbe_hw *hw)
  4775. /**
  4776. * ixgbe_check_overtemp_fw - Check firmware-controlled PHYs for overtemp
  4777. * @hw: pointer to hardware structure
  4778. + *
  4779. + * Return true when an overtemp event detected, otherwise false.
  4780. */
  4781. -static s32 ixgbe_check_overtemp_fw(struct ixgbe_hw *hw)
  4782. +static bool ixgbe_check_overtemp_fw(struct ixgbe_hw *hw)
  4783. {
  4784. u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
  4785. s32 rc;
  4786. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &store);
  4787. if (rc)
  4788. - return rc;
  4789. + return false;
  4790. if (store[0] & FW_PHY_ACT_GET_LINK_INFO_TEMP) {
  4791. ixgbe_shutdown_fw_phy(hw);
  4792. - return IXGBE_ERR_OVERTEMP;
  4793. + return true;
  4794. }
  4795. - return 0;
  4796. + return false;
  4797. }
  4798. /**
  4799. diff --git drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
  4800. index c567cff499d1..b8c7997ea52b 100644
  4801. --- linux-4.14.336/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
  4802. +++ linux-4.14.336/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
  4803. @@ -229,11 +229,13 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
  4804. ft->g = kcalloc(MLX5E_ARFS_NUM_GROUPS,
  4805. sizeof(*ft->g), GFP_KERNEL);
  4806. - in = kvzalloc(inlen, GFP_KERNEL);
  4807. - if (!in || !ft->g) {
  4808. - kvfree(ft->g);
  4809. - kvfree(in);
  4810. + if (!ft->g)
  4811. return -ENOMEM;
  4812. +
  4813. + in = kvzalloc(inlen, GFP_KERNEL);
  4814. + if (!in) {
  4815. + err = -ENOMEM;
  4816. + goto err_free_g;
  4817. }
  4818. mc = MLX5_ADDR_OF(create_flow_group_in, in, match_criteria);
  4819. @@ -253,7 +255,7 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
  4820. break;
  4821. default:
  4822. err = -EINVAL;
  4823. - goto out;
  4824. + goto err_free_in;
  4825. }
  4826. switch (type) {
  4827. @@ -275,7 +277,7 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
  4828. break;
  4829. default:
  4830. err = -EINVAL;
  4831. - goto out;
  4832. + goto err_free_in;
  4833. }
  4834. MLX5_SET_CFG(in, match_criteria_enable, MLX5_MATCH_OUTER_HEADERS);
  4835. @@ -284,7 +286,7 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
  4836. MLX5_SET_CFG(in, end_flow_index, ix - 1);
  4837. ft->g[ft->num_groups] = mlx5_create_flow_group(ft->t, in);
  4838. if (IS_ERR(ft->g[ft->num_groups]))
  4839. - goto err;
  4840. + goto err_clean_group;
  4841. ft->num_groups++;
  4842. memset(in, 0, inlen);
  4843. @@ -293,18 +295,20 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
  4844. MLX5_SET_CFG(in, end_flow_index, ix - 1);
  4845. ft->g[ft->num_groups] = mlx5_create_flow_group(ft->t, in);
  4846. if (IS_ERR(ft->g[ft->num_groups]))
  4847. - goto err;
  4848. + goto err_clean_group;
  4849. ft->num_groups++;
  4850. kvfree(in);
  4851. return 0;
  4852. -err:
  4853. +err_clean_group:
  4854. err = PTR_ERR(ft->g[ft->num_groups]);
  4855. ft->g[ft->num_groups] = NULL;
  4856. -out:
  4857. +err_free_in:
  4858. kvfree(in);
  4859. -
  4860. +err_free_g:
  4861. + kfree(ft->g);
  4862. + ft->g = NULL;
  4863. return err;
  4864. }
  4865. diff --git drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
  4866. index cd678323bacb..375c1c4ffc0c 100644
  4867. --- linux-4.14.336/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
  4868. +++ linux-4.14.336/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
  4869. @@ -571,11 +571,13 @@ static int enable_bars(struct nfp6000_pcie *nfp, u16 interface)
  4870. const u32 barcfg_msix_general =
  4871. NFP_PCIE_BAR_PCIE2CPP_MapType(
  4872. NFP_PCIE_BAR_PCIE2CPP_MapType_GENERAL) |
  4873. - NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT;
  4874. + NFP_PCIE_BAR_PCIE2CPP_LengthSelect(
  4875. + NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT);
  4876. const u32 barcfg_msix_xpb =
  4877. NFP_PCIE_BAR_PCIE2CPP_MapType(
  4878. NFP_PCIE_BAR_PCIE2CPP_MapType_BULK) |
  4879. - NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT |
  4880. + NFP_PCIE_BAR_PCIE2CPP_LengthSelect(
  4881. + NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT) |
  4882. NFP_PCIE_BAR_PCIE2CPP_Target_BaseAddress(
  4883. NFP_CPP_TARGET_ISLAND_XPB);
  4884. const u32 barcfg_explicit[4] = {
  4885. diff --git drivers/net/ethernet/qlogic/qla3xxx.c drivers/net/ethernet/qlogic/qla3xxx.c
  4886. index 6c8a591db713..bc3d268916b8 100644
  4887. --- linux-4.14.336/drivers/net/ethernet/qlogic/qla3xxx.c
  4888. +++ linux-4.14.336/drivers/net/ethernet/qlogic/qla3xxx.c
  4889. @@ -316,12 +316,11 @@ static void ql_release_to_lrg_buf_free_list(struct ql3_adapter *qdev,
  4890. * buffer
  4891. */
  4892. skb_reserve(lrg_buf_cb->skb, QL_HEADER_SPACE);
  4893. - map = pci_map_single(qdev->pdev,
  4894. + map = dma_map_single(&qdev->pdev->dev,
  4895. lrg_buf_cb->skb->data,
  4896. - qdev->lrg_buffer_len -
  4897. - QL_HEADER_SPACE,
  4898. - PCI_DMA_FROMDEVICE);
  4899. - err = pci_dma_mapping_error(qdev->pdev, map);
  4900. + qdev->lrg_buffer_len - QL_HEADER_SPACE,
  4901. + DMA_FROM_DEVICE);
  4902. + err = dma_mapping_error(&qdev->pdev->dev, map);
  4903. if (err) {
  4904. netdev_err(qdev->ndev,
  4905. "PCI mapping failed with error: %d\n",
  4906. @@ -1803,13 +1802,12 @@ static int ql_populate_free_queue(struct ql3_adapter *qdev)
  4907. * first buffer
  4908. */
  4909. skb_reserve(lrg_buf_cb->skb, QL_HEADER_SPACE);
  4910. - map = pci_map_single(qdev->pdev,
  4911. + map = dma_map_single(&qdev->pdev->dev,
  4912. lrg_buf_cb->skb->data,
  4913. - qdev->lrg_buffer_len -
  4914. - QL_HEADER_SPACE,
  4915. - PCI_DMA_FROMDEVICE);
  4916. + qdev->lrg_buffer_len - QL_HEADER_SPACE,
  4917. + DMA_FROM_DEVICE);
  4918. - err = pci_dma_mapping_error(qdev->pdev, map);
  4919. + err = dma_mapping_error(&qdev->pdev->dev, map);
  4920. if (err) {
  4921. netdev_err(qdev->ndev,
  4922. "PCI mapping failed with error: %d\n",
  4923. @@ -1944,18 +1942,16 @@ static void ql_process_mac_tx_intr(struct ql3_adapter *qdev,
  4924. goto invalid_seg_count;
  4925. }
  4926. - pci_unmap_single(qdev->pdev,
  4927. + dma_unmap_single(&qdev->pdev->dev,
  4928. dma_unmap_addr(&tx_cb->map[0], mapaddr),
  4929. - dma_unmap_len(&tx_cb->map[0], maplen),
  4930. - PCI_DMA_TODEVICE);
  4931. + dma_unmap_len(&tx_cb->map[0], maplen), DMA_TO_DEVICE);
  4932. tx_cb->seg_count--;
  4933. if (tx_cb->seg_count) {
  4934. for (i = 1; i < tx_cb->seg_count; i++) {
  4935. - pci_unmap_page(qdev->pdev,
  4936. - dma_unmap_addr(&tx_cb->map[i],
  4937. - mapaddr),
  4938. + dma_unmap_page(&qdev->pdev->dev,
  4939. + dma_unmap_addr(&tx_cb->map[i], mapaddr),
  4940. dma_unmap_len(&tx_cb->map[i], maplen),
  4941. - PCI_DMA_TODEVICE);
  4942. + DMA_TO_DEVICE);
  4943. }
  4944. }
  4945. qdev->ndev->stats.tx_packets++;
  4946. @@ -2022,10 +2018,9 @@ static void ql_process_mac_rx_intr(struct ql3_adapter *qdev,
  4947. qdev->ndev->stats.rx_bytes += length;
  4948. skb_put(skb, length);
  4949. - pci_unmap_single(qdev->pdev,
  4950. + dma_unmap_single(&qdev->pdev->dev,
  4951. dma_unmap_addr(lrg_buf_cb2, mapaddr),
  4952. - dma_unmap_len(lrg_buf_cb2, maplen),
  4953. - PCI_DMA_FROMDEVICE);
  4954. + dma_unmap_len(lrg_buf_cb2, maplen), DMA_FROM_DEVICE);
  4955. prefetch(skb->data);
  4956. skb_checksum_none_assert(skb);
  4957. skb->protocol = eth_type_trans(skb, qdev->ndev);
  4958. @@ -2068,10 +2063,9 @@ static void ql_process_macip_rx_intr(struct ql3_adapter *qdev,
  4959. skb2 = lrg_buf_cb2->skb;
  4960. skb_put(skb2, length); /* Just the second buffer length here. */
  4961. - pci_unmap_single(qdev->pdev,
  4962. + dma_unmap_single(&qdev->pdev->dev,
  4963. dma_unmap_addr(lrg_buf_cb2, mapaddr),
  4964. - dma_unmap_len(lrg_buf_cb2, maplen),
  4965. - PCI_DMA_FROMDEVICE);
  4966. + dma_unmap_len(lrg_buf_cb2, maplen), DMA_FROM_DEVICE);
  4967. prefetch(skb2->data);
  4968. skb_checksum_none_assert(skb2);
  4969. @@ -2320,9 +2314,9 @@ static int ql_send_map(struct ql3_adapter *qdev,
  4970. /*
  4971. * Map the skb buffer first.
  4972. */
  4973. - map = pci_map_single(qdev->pdev, skb->data, len, PCI_DMA_TODEVICE);
  4974. + map = dma_map_single(&qdev->pdev->dev, skb->data, len, DMA_TO_DEVICE);
  4975. - err = pci_dma_mapping_error(qdev->pdev, map);
  4976. + err = dma_mapping_error(&qdev->pdev->dev, map);
  4977. if (err) {
  4978. netdev_err(qdev->ndev, "PCI mapping failed with error: %d\n",
  4979. err);
  4980. @@ -2358,11 +2352,11 @@ static int ql_send_map(struct ql3_adapter *qdev,
  4981. (seg == 7 && seg_cnt > 8) ||
  4982. (seg == 12 && seg_cnt > 13) ||
  4983. (seg == 17 && seg_cnt > 18)) {
  4984. - map = pci_map_single(qdev->pdev, oal,
  4985. + map = dma_map_single(&qdev->pdev->dev, oal,
  4986. sizeof(struct oal),
  4987. - PCI_DMA_TODEVICE);
  4988. + DMA_TO_DEVICE);
  4989. - err = pci_dma_mapping_error(qdev->pdev, map);
  4990. + err = dma_mapping_error(&qdev->pdev->dev, map);
  4991. if (err) {
  4992. netdev_err(qdev->ndev,
  4993. "PCI mapping outbound address list with error: %d\n",
  4994. @@ -2424,24 +2418,24 @@ map_error:
  4995. (seg == 7 && seg_cnt > 8) ||
  4996. (seg == 12 && seg_cnt > 13) ||
  4997. (seg == 17 && seg_cnt > 18)) {
  4998. - pci_unmap_single(qdev->pdev,
  4999. - dma_unmap_addr(&tx_cb->map[seg], mapaddr),
  5000. - dma_unmap_len(&tx_cb->map[seg], maplen),
  5001. - PCI_DMA_TODEVICE);
  5002. + dma_unmap_single(&qdev->pdev->dev,
  5003. + dma_unmap_addr(&tx_cb->map[seg], mapaddr),
  5004. + dma_unmap_len(&tx_cb->map[seg], maplen),
  5005. + DMA_TO_DEVICE);
  5006. oal++;
  5007. seg++;
  5008. }
  5009. - pci_unmap_page(qdev->pdev,
  5010. + dma_unmap_page(&qdev->pdev->dev,
  5011. dma_unmap_addr(&tx_cb->map[seg], mapaddr),
  5012. dma_unmap_len(&tx_cb->map[seg], maplen),
  5013. - PCI_DMA_TODEVICE);
  5014. + DMA_TO_DEVICE);
  5015. }
  5016. - pci_unmap_single(qdev->pdev,
  5017. + dma_unmap_single(&qdev->pdev->dev,
  5018. dma_unmap_addr(&tx_cb->map[0], mapaddr),
  5019. dma_unmap_addr(&tx_cb->map[0], maplen),
  5020. - PCI_DMA_TODEVICE);
  5021. + DMA_TO_DEVICE);
  5022. return NETDEV_TX_BUSY;
  5023. @@ -2527,9 +2521,8 @@ static int ql_alloc_net_req_rsp_queues(struct ql3_adapter *qdev)
  5024. wmb();
  5025. qdev->req_q_virt_addr =
  5026. - pci_alloc_consistent(qdev->pdev,
  5027. - (size_t) qdev->req_q_size,
  5028. - &qdev->req_q_phy_addr);
  5029. + dma_alloc_coherent(&qdev->pdev->dev, (size_t)qdev->req_q_size,
  5030. + &qdev->req_q_phy_addr, GFP_KERNEL);
  5031. if ((qdev->req_q_virt_addr == NULL) ||
  5032. LS_64BITS(qdev->req_q_phy_addr) & (qdev->req_q_size - 1)) {
  5033. @@ -2538,16 +2531,14 @@ static int ql_alloc_net_req_rsp_queues(struct ql3_adapter *qdev)
  5034. }
  5035. qdev->rsp_q_virt_addr =
  5036. - pci_alloc_consistent(qdev->pdev,
  5037. - (size_t) qdev->rsp_q_size,
  5038. - &qdev->rsp_q_phy_addr);
  5039. + dma_alloc_coherent(&qdev->pdev->dev, (size_t)qdev->rsp_q_size,
  5040. + &qdev->rsp_q_phy_addr, GFP_KERNEL);
  5041. if ((qdev->rsp_q_virt_addr == NULL) ||
  5042. LS_64BITS(qdev->rsp_q_phy_addr) & (qdev->rsp_q_size - 1)) {
  5043. netdev_err(qdev->ndev, "rspQ allocation failed\n");
  5044. - pci_free_consistent(qdev->pdev, (size_t) qdev->req_q_size,
  5045. - qdev->req_q_virt_addr,
  5046. - qdev->req_q_phy_addr);
  5047. + dma_free_coherent(&qdev->pdev->dev, (size_t)qdev->req_q_size,
  5048. + qdev->req_q_virt_addr, qdev->req_q_phy_addr);
  5049. return -ENOMEM;
  5050. }
  5051. @@ -2563,15 +2554,13 @@ static void ql_free_net_req_rsp_queues(struct ql3_adapter *qdev)
  5052. return;
  5053. }
  5054. - pci_free_consistent(qdev->pdev,
  5055. - qdev->req_q_size,
  5056. - qdev->req_q_virt_addr, qdev->req_q_phy_addr);
  5057. + dma_free_coherent(&qdev->pdev->dev, qdev->req_q_size,
  5058. + qdev->req_q_virt_addr, qdev->req_q_phy_addr);
  5059. qdev->req_q_virt_addr = NULL;
  5060. - pci_free_consistent(qdev->pdev,
  5061. - qdev->rsp_q_size,
  5062. - qdev->rsp_q_virt_addr, qdev->rsp_q_phy_addr);
  5063. + dma_free_coherent(&qdev->pdev->dev, qdev->rsp_q_size,
  5064. + qdev->rsp_q_virt_addr, qdev->rsp_q_phy_addr);
  5065. qdev->rsp_q_virt_addr = NULL;
  5066. @@ -2595,12 +2584,13 @@ static int ql_alloc_buffer_queues(struct ql3_adapter *qdev)
  5067. return -ENOMEM;
  5068. qdev->lrg_buf_q_alloc_virt_addr =
  5069. - pci_alloc_consistent(qdev->pdev,
  5070. - qdev->lrg_buf_q_alloc_size,
  5071. - &qdev->lrg_buf_q_alloc_phy_addr);
  5072. + dma_alloc_coherent(&qdev->pdev->dev,
  5073. + qdev->lrg_buf_q_alloc_size,
  5074. + &qdev->lrg_buf_q_alloc_phy_addr, GFP_KERNEL);
  5075. if (qdev->lrg_buf_q_alloc_virt_addr == NULL) {
  5076. netdev_err(qdev->ndev, "lBufQ failed\n");
  5077. + kfree(qdev->lrg_buf);
  5078. return -ENOMEM;
  5079. }
  5080. qdev->lrg_buf_q_virt_addr = qdev->lrg_buf_q_alloc_virt_addr;
  5081. @@ -2615,15 +2605,17 @@ static int ql_alloc_buffer_queues(struct ql3_adapter *qdev)
  5082. qdev->small_buf_q_alloc_size = qdev->small_buf_q_size * 2;
  5083. qdev->small_buf_q_alloc_virt_addr =
  5084. - pci_alloc_consistent(qdev->pdev,
  5085. - qdev->small_buf_q_alloc_size,
  5086. - &qdev->small_buf_q_alloc_phy_addr);
  5087. + dma_alloc_coherent(&qdev->pdev->dev,
  5088. + qdev->small_buf_q_alloc_size,
  5089. + &qdev->small_buf_q_alloc_phy_addr, GFP_KERNEL);
  5090. if (qdev->small_buf_q_alloc_virt_addr == NULL) {
  5091. netdev_err(qdev->ndev, "Small Buffer Queue allocation failed\n");
  5092. - pci_free_consistent(qdev->pdev, qdev->lrg_buf_q_alloc_size,
  5093. - qdev->lrg_buf_q_alloc_virt_addr,
  5094. - qdev->lrg_buf_q_alloc_phy_addr);
  5095. + dma_free_coherent(&qdev->pdev->dev,
  5096. + qdev->lrg_buf_q_alloc_size,
  5097. + qdev->lrg_buf_q_alloc_virt_addr,
  5098. + qdev->lrg_buf_q_alloc_phy_addr);
  5099. + kfree(qdev->lrg_buf);
  5100. return -ENOMEM;
  5101. }
  5102. @@ -2640,17 +2632,15 @@ static void ql_free_buffer_queues(struct ql3_adapter *qdev)
  5103. return;
  5104. }
  5105. kfree(qdev->lrg_buf);
  5106. - pci_free_consistent(qdev->pdev,
  5107. - qdev->lrg_buf_q_alloc_size,
  5108. - qdev->lrg_buf_q_alloc_virt_addr,
  5109. - qdev->lrg_buf_q_alloc_phy_addr);
  5110. + dma_free_coherent(&qdev->pdev->dev, qdev->lrg_buf_q_alloc_size,
  5111. + qdev->lrg_buf_q_alloc_virt_addr,
  5112. + qdev->lrg_buf_q_alloc_phy_addr);
  5113. qdev->lrg_buf_q_virt_addr = NULL;
  5114. - pci_free_consistent(qdev->pdev,
  5115. - qdev->small_buf_q_alloc_size,
  5116. - qdev->small_buf_q_alloc_virt_addr,
  5117. - qdev->small_buf_q_alloc_phy_addr);
  5118. + dma_free_coherent(&qdev->pdev->dev, qdev->small_buf_q_alloc_size,
  5119. + qdev->small_buf_q_alloc_virt_addr,
  5120. + qdev->small_buf_q_alloc_phy_addr);
  5121. qdev->small_buf_q_virt_addr = NULL;
  5122. @@ -2668,9 +2658,9 @@ static int ql_alloc_small_buffers(struct ql3_adapter *qdev)
  5123. QL_SMALL_BUFFER_SIZE);
  5124. qdev->small_buf_virt_addr =
  5125. - pci_alloc_consistent(qdev->pdev,
  5126. - qdev->small_buf_total_size,
  5127. - &qdev->small_buf_phy_addr);
  5128. + dma_alloc_coherent(&qdev->pdev->dev,
  5129. + qdev->small_buf_total_size,
  5130. + &qdev->small_buf_phy_addr, GFP_KERNEL);
  5131. if (qdev->small_buf_virt_addr == NULL) {
  5132. netdev_err(qdev->ndev, "Failed to get small buffer memory\n");
  5133. @@ -2703,10 +2693,10 @@ static void ql_free_small_buffers(struct ql3_adapter *qdev)
  5134. return;
  5135. }
  5136. if (qdev->small_buf_virt_addr != NULL) {
  5137. - pci_free_consistent(qdev->pdev,
  5138. - qdev->small_buf_total_size,
  5139. - qdev->small_buf_virt_addr,
  5140. - qdev->small_buf_phy_addr);
  5141. + dma_free_coherent(&qdev->pdev->dev,
  5142. + qdev->small_buf_total_size,
  5143. + qdev->small_buf_virt_addr,
  5144. + qdev->small_buf_phy_addr);
  5145. qdev->small_buf_virt_addr = NULL;
  5146. }
  5147. @@ -2721,10 +2711,10 @@ static void ql_free_large_buffers(struct ql3_adapter *qdev)
  5148. lrg_buf_cb = &qdev->lrg_buf[i];
  5149. if (lrg_buf_cb->skb) {
  5150. dev_kfree_skb(lrg_buf_cb->skb);
  5151. - pci_unmap_single(qdev->pdev,
  5152. + dma_unmap_single(&qdev->pdev->dev,
  5153. dma_unmap_addr(lrg_buf_cb, mapaddr),
  5154. dma_unmap_len(lrg_buf_cb, maplen),
  5155. - PCI_DMA_FROMDEVICE);
  5156. + DMA_FROM_DEVICE);
  5157. memset(lrg_buf_cb, 0, sizeof(struct ql_rcv_buf_cb));
  5158. } else {
  5159. break;
  5160. @@ -2776,13 +2766,11 @@ static int ql_alloc_large_buffers(struct ql3_adapter *qdev)
  5161. * buffer
  5162. */
  5163. skb_reserve(skb, QL_HEADER_SPACE);
  5164. - map = pci_map_single(qdev->pdev,
  5165. - skb->data,
  5166. - qdev->lrg_buffer_len -
  5167. - QL_HEADER_SPACE,
  5168. - PCI_DMA_FROMDEVICE);
  5169. + map = dma_map_single(&qdev->pdev->dev, skb->data,
  5170. + qdev->lrg_buffer_len - QL_HEADER_SPACE,
  5171. + DMA_FROM_DEVICE);
  5172. - err = pci_dma_mapping_error(qdev->pdev, map);
  5173. + err = dma_mapping_error(&qdev->pdev->dev, map);
  5174. if (err) {
  5175. netdev_err(qdev->ndev,
  5176. "PCI mapping failed with error: %d\n",
  5177. @@ -2867,8 +2855,8 @@ static int ql_alloc_mem_resources(struct ql3_adapter *qdev)
  5178. * Network Completion Queue Producer Index Register
  5179. */
  5180. qdev->shadow_reg_virt_addr =
  5181. - pci_alloc_consistent(qdev->pdev,
  5182. - PAGE_SIZE, &qdev->shadow_reg_phy_addr);
  5183. + dma_alloc_coherent(&qdev->pdev->dev, PAGE_SIZE,
  5184. + &qdev->shadow_reg_phy_addr, GFP_KERNEL);
  5185. if (qdev->shadow_reg_virt_addr != NULL) {
  5186. qdev->preq_consumer_index = qdev->shadow_reg_virt_addr;
  5187. @@ -2923,10 +2911,9 @@ err_small_buffers:
  5188. err_buffer_queues:
  5189. ql_free_net_req_rsp_queues(qdev);
  5190. err_req_rsp:
  5191. - pci_free_consistent(qdev->pdev,
  5192. - PAGE_SIZE,
  5193. - qdev->shadow_reg_virt_addr,
  5194. - qdev->shadow_reg_phy_addr);
  5195. + dma_free_coherent(&qdev->pdev->dev, PAGE_SIZE,
  5196. + qdev->shadow_reg_virt_addr,
  5197. + qdev->shadow_reg_phy_addr);
  5198. return -ENOMEM;
  5199. }
  5200. @@ -2939,10 +2926,9 @@ static void ql_free_mem_resources(struct ql3_adapter *qdev)
  5201. ql_free_buffer_queues(qdev);
  5202. ql_free_net_req_rsp_queues(qdev);
  5203. if (qdev->shadow_reg_virt_addr != NULL) {
  5204. - pci_free_consistent(qdev->pdev,
  5205. - PAGE_SIZE,
  5206. - qdev->shadow_reg_virt_addr,
  5207. - qdev->shadow_reg_phy_addr);
  5208. + dma_free_coherent(&qdev->pdev->dev, PAGE_SIZE,
  5209. + qdev->shadow_reg_virt_addr,
  5210. + qdev->shadow_reg_phy_addr);
  5211. qdev->shadow_reg_virt_addr = NULL;
  5212. }
  5213. }
  5214. @@ -3643,18 +3629,15 @@ static void ql_reset_work(struct work_struct *work)
  5215. if (tx_cb->skb) {
  5216. netdev_printk(KERN_DEBUG, ndev,
  5217. "Freeing lost SKB\n");
  5218. - pci_unmap_single(qdev->pdev,
  5219. - dma_unmap_addr(&tx_cb->map[0],
  5220. - mapaddr),
  5221. - dma_unmap_len(&tx_cb->map[0], maplen),
  5222. - PCI_DMA_TODEVICE);
  5223. + dma_unmap_single(&qdev->pdev->dev,
  5224. + dma_unmap_addr(&tx_cb->map[0], mapaddr),
  5225. + dma_unmap_len(&tx_cb->map[0], maplen),
  5226. + DMA_TO_DEVICE);
  5227. for (j = 1; j < tx_cb->seg_count; j++) {
  5228. - pci_unmap_page(qdev->pdev,
  5229. - dma_unmap_addr(&tx_cb->map[j],
  5230. - mapaddr),
  5231. - dma_unmap_len(&tx_cb->map[j],
  5232. - maplen),
  5233. - PCI_DMA_TODEVICE);
  5234. + dma_unmap_page(&qdev->pdev->dev,
  5235. + dma_unmap_addr(&tx_cb->map[j], mapaddr),
  5236. + dma_unmap_len(&tx_cb->map[j], maplen),
  5237. + DMA_TO_DEVICE);
  5238. }
  5239. dev_kfree_skb(tx_cb->skb);
  5240. tx_cb->skb = NULL;
  5241. @@ -3786,13 +3769,10 @@ static int ql3xxx_probe(struct pci_dev *pdev,
  5242. pci_set_master(pdev);
  5243. - if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
  5244. + if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)))
  5245. pci_using_dac = 1;
  5246. - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
  5247. - } else if (!(err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))) {
  5248. + else if (!(err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))))
  5249. pci_using_dac = 0;
  5250. - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
  5251. - }
  5252. if (err) {
  5253. pr_err("%s no usable DMA configuration\n", pci_name(pdev));
  5254. diff --git drivers/net/ethernet/renesas/ravb_main.c drivers/net/ethernet/renesas/ravb_main.c
  5255. index b97d450214df..2190ed6b0081 100644
  5256. --- linux-4.14.336/drivers/net/ethernet/renesas/ravb_main.c
  5257. +++ linux-4.14.336/drivers/net/ethernet/renesas/ravb_main.c
  5258. @@ -1545,7 +1545,7 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
  5259. struct ravb_tstamp_skb *ts_skb;
  5260. struct ravb_tx_desc *desc;
  5261. unsigned long flags;
  5262. - u32 dma_addr;
  5263. + dma_addr_t dma_addr;
  5264. void *buffer;
  5265. u32 entry;
  5266. u32 len;
  5267. diff --git drivers/net/fjes/fjes_hw.c drivers/net/fjes/fjes_hw.c
  5268. index 9c652c04375b..c3fa8db69b9e 100644
  5269. --- linux-4.14.336/drivers/net/fjes/fjes_hw.c
  5270. +++ linux-4.14.336/drivers/net/fjes/fjes_hw.c
  5271. @@ -235,21 +235,25 @@ static int fjes_hw_setup(struct fjes_hw *hw)
  5272. mem_size = FJES_DEV_REQ_BUF_SIZE(hw->max_epid);
  5273. hw->hw_info.req_buf = kzalloc(mem_size, GFP_KERNEL);
  5274. - if (!(hw->hw_info.req_buf))
  5275. - return -ENOMEM;
  5276. + if (!(hw->hw_info.req_buf)) {
  5277. + result = -ENOMEM;
  5278. + goto free_ep_info;
  5279. + }
  5280. hw->hw_info.req_buf_size = mem_size;
  5281. mem_size = FJES_DEV_RES_BUF_SIZE(hw->max_epid);
  5282. hw->hw_info.res_buf = kzalloc(mem_size, GFP_KERNEL);
  5283. - if (!(hw->hw_info.res_buf))
  5284. - return -ENOMEM;
  5285. + if (!(hw->hw_info.res_buf)) {
  5286. + result = -ENOMEM;
  5287. + goto free_req_buf;
  5288. + }
  5289. hw->hw_info.res_buf_size = mem_size;
  5290. result = fjes_hw_alloc_shared_status_region(hw);
  5291. if (result)
  5292. - return result;
  5293. + goto free_res_buf;
  5294. hw->hw_info.buffer_share_bit = 0;
  5295. hw->hw_info.buffer_unshare_reserve_bit = 0;
  5296. @@ -260,11 +264,11 @@ static int fjes_hw_setup(struct fjes_hw *hw)
  5297. result = fjes_hw_alloc_epbuf(&buf_pair->tx);
  5298. if (result)
  5299. - return result;
  5300. + goto free_epbuf;
  5301. result = fjes_hw_alloc_epbuf(&buf_pair->rx);
  5302. if (result)
  5303. - return result;
  5304. + goto free_epbuf;
  5305. spin_lock_irqsave(&hw->rx_status_lock, flags);
  5306. fjes_hw_setup_epbuf(&buf_pair->tx, mac,
  5307. @@ -287,6 +291,25 @@ static int fjes_hw_setup(struct fjes_hw *hw)
  5308. fjes_hw_init_command_registers(hw, &param);
  5309. return 0;
  5310. +
  5311. +free_epbuf:
  5312. + for (epidx = 0; epidx < hw->max_epid ; epidx++) {
  5313. + if (epidx == hw->my_epid)
  5314. + continue;
  5315. + fjes_hw_free_epbuf(&hw->ep_shm_info[epidx].tx);
  5316. + fjes_hw_free_epbuf(&hw->ep_shm_info[epidx].rx);
  5317. + }
  5318. + fjes_hw_free_shared_status_region(hw);
  5319. +free_res_buf:
  5320. + kfree(hw->hw_info.res_buf);
  5321. + hw->hw_info.res_buf = NULL;
  5322. +free_req_buf:
  5323. + kfree(hw->hw_info.req_buf);
  5324. + hw->hw_info.req_buf = NULL;
  5325. +free_ep_info:
  5326. + kfree(hw->ep_shm_info);
  5327. + hw->ep_shm_info = NULL;
  5328. + return result;
  5329. }
  5330. static void fjes_hw_cleanup(struct fjes_hw *hw)
  5331. diff --git drivers/net/gtp.c drivers/net/gtp.c
  5332. index d7bf8212ff04..a222736c3117 100644
  5333. --- linux-4.14.336/drivers/net/gtp.c
  5334. +++ linux-4.14.336/drivers/net/gtp.c
  5335. @@ -1380,26 +1380,26 @@ static int __init gtp_init(void)
  5336. get_random_bytes(&gtp_h_initval, sizeof(gtp_h_initval));
  5337. - err = rtnl_link_register(&gtp_link_ops);
  5338. + err = register_pernet_subsys(&gtp_net_ops);
  5339. if (err < 0)
  5340. goto error_out;
  5341. - err = genl_register_family(&gtp_genl_family);
  5342. + err = rtnl_link_register(&gtp_link_ops);
  5343. if (err < 0)
  5344. - goto unreg_rtnl_link;
  5345. + goto unreg_pernet_subsys;
  5346. - err = register_pernet_subsys(&gtp_net_ops);
  5347. + err = genl_register_family(&gtp_genl_family);
  5348. if (err < 0)
  5349. - goto unreg_genl_family;
  5350. + goto unreg_rtnl_link;
  5351. pr_info("GTP module loaded (pdp ctx size %zd bytes)\n",
  5352. sizeof(struct pdp_ctx));
  5353. return 0;
  5354. -unreg_genl_family:
  5355. - genl_unregister_family(&gtp_genl_family);
  5356. unreg_rtnl_link:
  5357. rtnl_link_unregister(&gtp_link_ops);
  5358. +unreg_pernet_subsys:
  5359. + unregister_pernet_subsys(&gtp_net_ops);
  5360. error_out:
  5361. pr_err("error loading GTP module loaded\n");
  5362. return err;
  5363. diff --git drivers/net/ppp/ppp_async.c drivers/net/ppp/ppp_async.c
  5364. index 297a986e6653..4d981d9e0e38 100644
  5365. --- linux-4.14.336/drivers/net/ppp/ppp_async.c
  5366. +++ linux-4.14.336/drivers/net/ppp/ppp_async.c
  5367. @@ -474,6 +474,10 @@ ppp_async_ioctl(struct ppp_channel *chan, unsigned int cmd, unsigned long arg)
  5368. case PPPIOCSMRU:
  5369. if (get_user(val, p))
  5370. break;
  5371. + if (val > U16_MAX) {
  5372. + err = -EINVAL;
  5373. + break;
  5374. + }
  5375. if (val < PPP_MRU)
  5376. val = PPP_MRU;
  5377. ap->mru = val;
  5378. diff --git drivers/net/usb/ax88172a.c drivers/net/usb/ax88172a.c
  5379. index 909755ef71ac..5881620e4436 100644
  5380. --- linux-4.14.336/drivers/net/usb/ax88172a.c
  5381. +++ linux-4.14.336/drivers/net/usb/ax88172a.c
  5382. @@ -198,7 +198,9 @@ static int ax88172a_bind(struct usbnet *dev, struct usb_interface *intf)
  5383. u8 buf[ETH_ALEN];
  5384. struct ax88172a_private *priv;
  5385. - usbnet_get_endpoints(dev, intf);
  5386. + ret = usbnet_get_endpoints(dev, intf);
  5387. + if (ret)
  5388. + return ret;
  5389. priv = kzalloc(sizeof(*priv), GFP_KERNEL);
  5390. if (!priv)
  5391. diff --git drivers/net/usb/dm9601.c drivers/net/usb/dm9601.c
  5392. index 5aad26600b03..9b7db5fd9e08 100644
  5393. --- linux-4.14.336/drivers/net/usb/dm9601.c
  5394. +++ linux-4.14.336/drivers/net/usb/dm9601.c
  5395. @@ -231,7 +231,7 @@ static int dm9601_mdio_read(struct net_device *netdev, int phy_id, int loc)
  5396. err = dm_read_shared_word(dev, 1, loc, &res);
  5397. if (err < 0) {
  5398. netdev_err(dev->net, "MDIO read error: %d\n", err);
  5399. - return err;
  5400. + return 0;
  5401. }
  5402. netdev_dbg(dev->net,
  5403. diff --git drivers/net/usb/lan78xx.c drivers/net/usb/lan78xx.c
  5404. index d6a71c051ec1..171accb5ebbf 100644
  5405. --- linux-4.14.336/drivers/net/usb/lan78xx.c
  5406. +++ linux-4.14.336/drivers/net/usb/lan78xx.c
  5407. @@ -2450,7 +2450,8 @@ static int lan78xx_reset(struct lan78xx_net *dev)
  5408. if (dev->chipid == ID_REV_CHIP_ID_7801_)
  5409. buf &= ~MAC_CR_GMII_EN_;
  5410. - if (dev->chipid == ID_REV_CHIP_ID_7800_) {
  5411. + if (dev->chipid == ID_REV_CHIP_ID_7800_ ||
  5412. + dev->chipid == ID_REV_CHIP_ID_7850_) {
  5413. ret = lan78xx_read_raw_eeprom(dev, 0, 1, &sig);
  5414. if (!ret && sig != EEPROM_INDICATOR) {
  5415. /* Implies there is no external eeprom. Set mac speed */
  5416. diff --git drivers/net/virtio_net.c drivers/net/virtio_net.c
  5417. index 067ebdd0d589..8e1a3c523b09 100644
  5418. --- linux-4.14.336/drivers/net/virtio_net.c
  5419. +++ linux-4.14.336/drivers/net/virtio_net.c
  5420. @@ -2277,10 +2277,11 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
  5421. {
  5422. vq_callback_t **callbacks;
  5423. struct virtqueue **vqs;
  5424. - int ret = -ENOMEM;
  5425. - int i, total_vqs;
  5426. const char **names;
  5427. + int ret = -ENOMEM;
  5428. + int total_vqs;
  5429. bool *ctx;
  5430. + u16 i;
  5431. /* We expect 1 RX virtqueue followed by 1 TX virtqueue, followed by
  5432. * possible N-1 RX/TX queue pairs used in multiqueue mode, followed by
  5433. @@ -2317,8 +2318,8 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
  5434. for (i = 0; i < vi->max_queue_pairs; i++) {
  5435. callbacks[rxq2vq(i)] = skb_recv_done;
  5436. callbacks[txq2vq(i)] = skb_xmit_done;
  5437. - sprintf(vi->rq[i].name, "input.%d", i);
  5438. - sprintf(vi->sq[i].name, "output.%d", i);
  5439. + sprintf(vi->rq[i].name, "input.%u", i);
  5440. + sprintf(vi->sq[i].name, "output.%u", i);
  5441. names[rxq2vq(i)] = vi->rq[i].name;
  5442. names[txq2vq(i)] = vi->sq[i].name;
  5443. if (ctx)
  5444. diff --git drivers/net/wan/lmc/lmc_proto.c drivers/net/wan/lmc/lmc_proto.c
  5445. index f600075e84a2..7ae39a2b6340 100644
  5446. --- linux-4.14.336/drivers/net/wan/lmc/lmc_proto.c
  5447. +++ linux-4.14.336/drivers/net/wan/lmc/lmc_proto.c
  5448. @@ -103,17 +103,13 @@ __be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
  5449. switch(sc->if_type){
  5450. case LMC_PPP:
  5451. return hdlc_type_trans(skb, sc->lmc_device);
  5452. - break;
  5453. case LMC_NET:
  5454. return htons(ETH_P_802_2);
  5455. - break;
  5456. case LMC_RAW: /* Packet type for skbuff kind of useless */
  5457. return htons(ETH_P_802_2);
  5458. - break;
  5459. default:
  5460. printk(KERN_WARNING "%s: No protocol set for this interface, assuming 802.2 (which is wrong!!)\n", sc->name);
  5461. return htons(ETH_P_802_2);
  5462. - break;
  5463. }
  5464. lmc_trace(sc->lmc_device, "lmc_proto_tye out");
  5465. diff --git drivers/net/wireless/ath/ath9k/htc_drv_txrx.c drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
  5466. index e62ed7f42281..763521fca11d 100644
  5467. --- linux-4.14.336/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
  5468. +++ linux-4.14.336/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
  5469. @@ -647,9 +647,10 @@ void ath9k_htc_txstatus(struct ath9k_htc_priv *priv, void *wmi_event)
  5470. struct ath9k_htc_tx_event *tx_pend;
  5471. int i;
  5472. - for (i = 0; i < txs->cnt; i++) {
  5473. - WARN_ON(txs->cnt > HTC_MAX_TX_STATUS);
  5474. + if (WARN_ON_ONCE(txs->cnt > HTC_MAX_TX_STATUS))
  5475. + return;
  5476. + for (i = 0; i < txs->cnt; i++) {
  5477. __txs = &txs->txstatus[i];
  5478. skb = ath9k_htc_tx_get_packet(priv, __txs);
  5479. diff --git drivers/net/wireless/marvell/libertas/Kconfig drivers/net/wireless/marvell/libertas/Kconfig
  5480. index e6268ceacbf1..28985cdac541 100644
  5481. --- linux-4.14.336/drivers/net/wireless/marvell/libertas/Kconfig
  5482. +++ linux-4.14.336/drivers/net/wireless/marvell/libertas/Kconfig
  5483. @@ -1,8 +1,6 @@
  5484. config LIBERTAS
  5485. tristate "Marvell 8xxx Libertas WLAN driver support"
  5486. depends on CFG80211
  5487. - select WIRELESS_EXT
  5488. - select WEXT_SPY
  5489. select LIB80211
  5490. select FW_LOADER
  5491. ---help---
  5492. diff --git drivers/net/wireless/marvell/mwifiex/cfg80211.c drivers/net/wireless/marvell/mwifiex/cfg80211.c
  5493. index a88bddc38389..76205d6b2f9c 100644
  5494. --- linux-4.14.336/drivers/net/wireless/marvell/mwifiex/cfg80211.c
  5495. +++ linux-4.14.336/drivers/net/wireless/marvell/mwifiex/cfg80211.c
  5496. @@ -1940,6 +1940,8 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
  5497. mwifiex_set_sys_config_invalid_data(bss_cfg);
  5498. + memcpy(bss_cfg->mac_addr, priv->curr_addr, ETH_ALEN);
  5499. +
  5500. if (params->beacon_interval)
  5501. bss_cfg->beacon_period = params->beacon_interval;
  5502. if (params->dtim_period)
  5503. diff --git drivers/net/wireless/marvell/mwifiex/fw.h drivers/net/wireless/marvell/mwifiex/fw.h
  5504. index c802b73a15c5..99b40bc6e7a6 100644
  5505. --- linux-4.14.336/drivers/net/wireless/marvell/mwifiex/fw.h
  5506. +++ linux-4.14.336/drivers/net/wireless/marvell/mwifiex/fw.h
  5507. @@ -168,6 +168,7 @@ enum MWIFIEX_802_11_PRIVACY_FILTER {
  5508. #define TLV_TYPE_STA_MAC_ADDR (PROPRIETARY_TLV_BASE_ID + 32)
  5509. #define TLV_TYPE_BSSID (PROPRIETARY_TLV_BASE_ID + 35)
  5510. #define TLV_TYPE_CHANNELBANDLIST (PROPRIETARY_TLV_BASE_ID + 42)
  5511. +#define TLV_TYPE_UAP_MAC_ADDRESS (PROPRIETARY_TLV_BASE_ID + 43)
  5512. #define TLV_TYPE_UAP_BEACON_PERIOD (PROPRIETARY_TLV_BASE_ID + 44)
  5513. #define TLV_TYPE_UAP_DTIM_PERIOD (PROPRIETARY_TLV_BASE_ID + 45)
  5514. #define TLV_TYPE_UAP_BCAST_SSID (PROPRIETARY_TLV_BASE_ID + 48)
  5515. diff --git drivers/net/wireless/marvell/mwifiex/ioctl.h drivers/net/wireless/marvell/mwifiex/ioctl.h
  5516. index 0dd592ea6e83..96ff91655a77 100644
  5517. --- linux-4.14.336/drivers/net/wireless/marvell/mwifiex/ioctl.h
  5518. +++ linux-4.14.336/drivers/net/wireless/marvell/mwifiex/ioctl.h
  5519. @@ -119,6 +119,7 @@ struct mwifiex_uap_bss_param {
  5520. u8 qos_info;
  5521. u8 power_constraint;
  5522. struct mwifiex_types_wmm_info wmm_info;
  5523. + u8 mac_addr[ETH_ALEN];
  5524. };
  5525. enum {
  5526. diff --git drivers/net/wireless/marvell/mwifiex/uap_cmd.c drivers/net/wireless/marvell/mwifiex/uap_cmd.c
  5527. index 0939a8c8f3ab..1ab253c97c14 100644
  5528. --- linux-4.14.336/drivers/net/wireless/marvell/mwifiex/uap_cmd.c
  5529. +++ linux-4.14.336/drivers/net/wireless/marvell/mwifiex/uap_cmd.c
  5530. @@ -479,6 +479,7 @@ void mwifiex_config_uap_11d(struct mwifiex_private *priv,
  5531. static int
  5532. mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
  5533. {
  5534. + struct host_cmd_tlv_mac_addr *mac_tlv;
  5535. struct host_cmd_tlv_dtim_period *dtim_period;
  5536. struct host_cmd_tlv_beacon_period *beacon_period;
  5537. struct host_cmd_tlv_ssid *ssid;
  5538. @@ -498,6 +499,13 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
  5539. int i;
  5540. u16 cmd_size = *param_size;
  5541. + mac_tlv = (struct host_cmd_tlv_mac_addr *)tlv;
  5542. + mac_tlv->header.type = cpu_to_le16(TLV_TYPE_UAP_MAC_ADDRESS);
  5543. + mac_tlv->header.len = cpu_to_le16(ETH_ALEN);
  5544. + memcpy(mac_tlv->mac_addr, bss_cfg->mac_addr, ETH_ALEN);
  5545. + cmd_size += sizeof(struct host_cmd_tlv_mac_addr);
  5546. + tlv += sizeof(struct host_cmd_tlv_mac_addr);
  5547. +
  5548. if (bss_cfg->ssid.ssid_len) {
  5549. ssid = (struct host_cmd_tlv_ssid *)tlv;
  5550. ssid->header.type = cpu_to_le16(TLV_TYPE_UAP_SSID);
  5551. diff --git drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
  5552. index bfd704b17a44..9263a6a64788 100644
  5553. --- linux-4.14.336/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
  5554. +++ linux-4.14.336/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
  5555. @@ -6366,6 +6366,18 @@ static const struct usb_device_id dev_table[] = {
  5556. .driver_info = (unsigned long)&rtl8192eu_fops},
  5557. {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x818c, 0xff, 0xff, 0xff),
  5558. .driver_info = (unsigned long)&rtl8192eu_fops},
  5559. +/* D-Link DWA-131 rev C1 */
  5560. +{USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x3312, 0xff, 0xff, 0xff),
  5561. + .driver_info = (unsigned long)&rtl8192eu_fops},
  5562. +/* TP-Link TL-WN8200ND V2 */
  5563. +{USB_DEVICE_AND_INTERFACE_INFO(0x2357, 0x0126, 0xff, 0xff, 0xff),
  5564. + .driver_info = (unsigned long)&rtl8192eu_fops},
  5565. +/* Mercusys MW300UM */
  5566. +{USB_DEVICE_AND_INTERFACE_INFO(0x2c4e, 0x0100, 0xff, 0xff, 0xff),
  5567. + .driver_info = (unsigned long)&rtl8192eu_fops},
  5568. +/* Mercusys MW300UH */
  5569. +{USB_DEVICE_AND_INTERFACE_INFO(0x2c4e, 0x0104, 0xff, 0xff, 0xff),
  5570. + .driver_info = (unsigned long)&rtl8192eu_fops},
  5571. #endif
  5572. { }
  5573. };
  5574. diff --git drivers/net/wireless/realtek/rtlwifi/pci.c drivers/net/wireless/realtek/rtlwifi/pci.c
  5575. index ab74f3155854..b6c3a6d422ea 100644
  5576. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/pci.c
  5577. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/pci.c
  5578. @@ -194,21 +194,29 @@ static bool _rtl_pci_platform_switch_device_pci_aspm(
  5579. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  5580. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  5581. + value &= PCI_EXP_LNKCTL_ASPMC;
  5582. +
  5583. if (rtlhal->hw_type != HARDWARE_TYPE_RTL8192SE)
  5584. - value |= 0x40;
  5585. + value |= PCI_EXP_LNKCTL_CCC;
  5586. - pci_write_config_byte(rtlpci->pdev, 0x80, value);
  5587. + pcie_capability_clear_and_set_word(rtlpci->pdev, PCI_EXP_LNKCTL,
  5588. + PCI_EXP_LNKCTL_ASPMC | value,
  5589. + value);
  5590. return false;
  5591. }
  5592. -/*When we set 0x01 to enable clk request. Set 0x0 to disable clk req.*/
  5593. -static void _rtl_pci_switch_clk_req(struct ieee80211_hw *hw, u8 value)
  5594. +/* @value is PCI_EXP_LNKCTL_CLKREQ_EN or 0 to enable/disable clk request. */
  5595. +static void _rtl_pci_switch_clk_req(struct ieee80211_hw *hw, u16 value)
  5596. {
  5597. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  5598. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  5599. - pci_write_config_byte(rtlpci->pdev, 0x81, value);
  5600. + value &= PCI_EXP_LNKCTL_CLKREQ_EN;
  5601. +
  5602. + pcie_capability_clear_and_set_word(rtlpci->pdev, PCI_EXP_LNKCTL,
  5603. + PCI_EXP_LNKCTL_CLKREQ_EN,
  5604. + value);
  5605. if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE)
  5606. udelay(100);
  5607. @@ -222,11 +230,8 @@ static void rtl_pci_disable_aspm(struct ieee80211_hw *hw)
  5608. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  5609. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  5610. u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor;
  5611. - u8 num4bytes = pcipriv->ndis_adapter.num4bytes;
  5612. /*Retrieve original configuration settings. */
  5613. u8 linkctrl_reg = pcipriv->ndis_adapter.linkctrl_reg;
  5614. - u16 pcibridge_linkctrlreg = pcipriv->ndis_adapter.
  5615. - pcibridge_linkctrlreg;
  5616. u16 aspmlevel = 0;
  5617. u8 tmp_u1b = 0;
  5618. @@ -251,16 +256,8 @@ static void rtl_pci_disable_aspm(struct ieee80211_hw *hw)
  5619. /*Set corresponding value. */
  5620. aspmlevel |= BIT(0) | BIT(1);
  5621. linkctrl_reg &= ~aspmlevel;
  5622. - pcibridge_linkctrlreg &= ~(BIT(0) | BIT(1));
  5623. _rtl_pci_platform_switch_device_pci_aspm(hw, linkctrl_reg);
  5624. - udelay(50);
  5625. -
  5626. - /*4 Disable Pci Bridge ASPM */
  5627. - pci_write_config_byte(rtlpci->pdev, (num4bytes << 2),
  5628. - pcibridge_linkctrlreg);
  5629. -
  5630. - udelay(50);
  5631. }
  5632. /*
  5633. @@ -276,9 +273,7 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw)
  5634. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  5635. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  5636. u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor;
  5637. - u8 num4bytes = pcipriv->ndis_adapter.num4bytes;
  5638. u16 aspmlevel;
  5639. - u8 u_pcibridge_aspmsetting;
  5640. u8 u_device_aspmsetting;
  5641. if (!ppsc->support_aspm)
  5642. @@ -290,25 +285,6 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw)
  5643. return;
  5644. }
  5645. - /*4 Enable Pci Bridge ASPM */
  5646. -
  5647. - u_pcibridge_aspmsetting =
  5648. - pcipriv->ndis_adapter.pcibridge_linkctrlreg |
  5649. - rtlpci->const_hostpci_aspm_setting;
  5650. -
  5651. - if (pcibridge_vendor == PCI_BRIDGE_VENDOR_INTEL)
  5652. - u_pcibridge_aspmsetting &= ~BIT(0);
  5653. -
  5654. - pci_write_config_byte(rtlpci->pdev, (num4bytes << 2),
  5655. - u_pcibridge_aspmsetting);
  5656. -
  5657. - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
  5658. - "PlatformEnableASPM(): Write reg[%x] = %x\n",
  5659. - (pcipriv->ndis_adapter.pcibridge_pciehdr_offset + 0x10),
  5660. - u_pcibridge_aspmsetting);
  5661. -
  5662. - udelay(50);
  5663. -
  5664. /*Get ASPM level (with/without Clock Req) */
  5665. aspmlevel = rtlpci->const_devicepci_aspm_setting;
  5666. u_device_aspmsetting = pcipriv->ndis_adapter.linkctrl_reg;
  5667. @@ -322,7 +298,8 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw)
  5668. if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_CLK_REQ) {
  5669. _rtl_pci_switch_clk_req(hw, (ppsc->reg_rfps_level &
  5670. - RT_RF_OFF_LEVL_CLK_REQ) ? 1 : 0);
  5671. + RT_RF_OFF_LEVL_CLK_REQ) ?
  5672. + PCI_EXP_LNKCTL_CLKREQ_EN : 0);
  5673. RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_CLK_REQ);
  5674. }
  5675. udelay(100);
  5676. @@ -390,22 +367,6 @@ static bool rtl_pci_check_buddy_priv(struct ieee80211_hw *hw,
  5677. return find_buddy_priv;
  5678. }
  5679. -static void rtl_pci_get_linkcontrol_field(struct ieee80211_hw *hw)
  5680. -{
  5681. - struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
  5682. - struct rtl_pci *rtlpci = rtl_pcidev(pcipriv);
  5683. - u8 capabilityoffset = pcipriv->ndis_adapter.pcibridge_pciehdr_offset;
  5684. - u8 linkctrl_reg;
  5685. - u8 num4bbytes;
  5686. -
  5687. - num4bbytes = (capabilityoffset + 0x10) / 4;
  5688. -
  5689. - /*Read Link Control Register */
  5690. - pci_read_config_byte(rtlpci->pdev, (num4bbytes << 2), &linkctrl_reg);
  5691. -
  5692. - pcipriv->ndis_adapter.pcibridge_linkctrlreg = linkctrl_reg;
  5693. -}
  5694. -
  5695. static void rtl_pci_parse_configuration(struct pci_dev *pdev,
  5696. struct ieee80211_hw *hw)
  5697. {
  5698. @@ -2076,12 +2037,6 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
  5699. PCI_SLOT(bridge_pdev->devfn);
  5700. pcipriv->ndis_adapter.pcibridge_funcnum =
  5701. PCI_FUNC(bridge_pdev->devfn);
  5702. - pcipriv->ndis_adapter.pcibridge_pciehdr_offset =
  5703. - pci_pcie_cap(bridge_pdev);
  5704. - pcipriv->ndis_adapter.num4bytes =
  5705. - (pcipriv->ndis_adapter.pcibridge_pciehdr_offset + 0x10) / 4;
  5706. -
  5707. - rtl_pci_get_linkcontrol_field(hw);
  5708. if (pcipriv->ndis_adapter.pcibridge_vendor ==
  5709. PCI_BRIDGE_VENDOR_AMD) {
  5710. @@ -2098,13 +2053,11 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
  5711. pdev->vendor, pcipriv->ndis_adapter.linkctrl_reg);
  5712. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
  5713. - "pci_bridge busnumber:devnumber:funcnumber:vendor:pcie_cap:link_ctl_reg:amd %d:%d:%d:%x:%x:%x:%x\n",
  5714. + "pci_bridge busnumber:devnumber:funcnumber:vendor:amd %d:%d:%d:%x:%x\n",
  5715. pcipriv->ndis_adapter.pcibridge_busnum,
  5716. pcipriv->ndis_adapter.pcibridge_devnum,
  5717. pcipriv->ndis_adapter.pcibridge_funcnum,
  5718. pcibridge_vendors[pcipriv->ndis_adapter.pcibridge_vendor],
  5719. - pcipriv->ndis_adapter.pcibridge_pciehdr_offset,
  5720. - pcipriv->ndis_adapter.pcibridge_linkctrlreg,
  5721. pcipriv->ndis_adapter.amd_l1_patch);
  5722. rtl_pci_parse_configuration(pdev, hw);
  5723. diff --git drivers/net/wireless/realtek/rtlwifi/pci.h drivers/net/wireless/realtek/rtlwifi/pci.h
  5724. index d9039ea10ba4..19b7a57313da 100644
  5725. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/pci.h
  5726. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/pci.h
  5727. @@ -262,11 +262,6 @@ struct mp_adapter {
  5728. u16 pcibridge_vendorid;
  5729. u16 pcibridge_deviceid;
  5730. - u8 num4bytes;
  5731. -
  5732. - u8 pcibridge_pciehdr_offset;
  5733. - u8 pcibridge_linkctrlreg;
  5734. -
  5735. bool amd_l1_patch;
  5736. };
  5737. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c
  5738. index 14a256062614..44cabfa1ca27 100644
  5739. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c
  5740. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c
  5741. @@ -38,7 +38,6 @@ static u32 _rtl88e_phy_rf_serial_read(struct ieee80211_hw *hw,
  5742. static void _rtl88e_phy_rf_serial_write(struct ieee80211_hw *hw,
  5743. enum radio_path rfpath, u32 offset,
  5744. u32 data);
  5745. -static u32 _rtl88e_phy_calculate_bit_shift(u32 bitmask);
  5746. static bool _rtl88e_phy_bb8188e_config_parafile(struct ieee80211_hw *hw);
  5747. static bool _rtl88e_phy_config_mac_with_headerfile(struct ieee80211_hw *hw);
  5748. static bool phy_config_bb_with_headerfile(struct ieee80211_hw *hw,
  5749. @@ -68,7 +67,7 @@ u32 rtl88e_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
  5750. RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
  5751. "regaddr(%#x), bitmask(%#x)\n", regaddr, bitmask);
  5752. originalvalue = rtl_read_dword(rtlpriv, regaddr);
  5753. - bitshift = _rtl88e_phy_calculate_bit_shift(bitmask);
  5754. + bitshift = calculate_bit_shift(bitmask);
  5755. returnvalue = (originalvalue & bitmask) >> bitshift;
  5756. RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
  5757. @@ -91,7 +90,7 @@ void rtl88e_phy_set_bb_reg(struct ieee80211_hw *hw,
  5758. if (bitmask != MASKDWORD) {
  5759. originalvalue = rtl_read_dword(rtlpriv, regaddr);
  5760. - bitshift = _rtl88e_phy_calculate_bit_shift(bitmask);
  5761. + bitshift = calculate_bit_shift(bitmask);
  5762. data = ((originalvalue & (~bitmask)) | (data << bitshift));
  5763. }
  5764. @@ -117,7 +116,7 @@ u32 rtl88e_phy_query_rf_reg(struct ieee80211_hw *hw,
  5765. original_value = _rtl88e_phy_rf_serial_read(hw, rfpath, regaddr);
  5766. - bitshift = _rtl88e_phy_calculate_bit_shift(bitmask);
  5767. + bitshift = calculate_bit_shift(bitmask);
  5768. readback_value = (original_value & bitmask) >> bitshift;
  5769. spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags);
  5770. @@ -146,7 +145,7 @@ void rtl88e_phy_set_rf_reg(struct ieee80211_hw *hw,
  5771. original_value = _rtl88e_phy_rf_serial_read(hw,
  5772. rfpath,
  5773. regaddr);
  5774. - bitshift = _rtl88e_phy_calculate_bit_shift(bitmask);
  5775. + bitshift = calculate_bit_shift(bitmask);
  5776. data =
  5777. ((original_value & (~bitmask)) |
  5778. (data << bitshift));
  5779. @@ -232,17 +231,6 @@ static void _rtl88e_phy_rf_serial_write(struct ieee80211_hw *hw,
  5780. rfpath, pphyreg->rf3wire_offset, data_and_addr);
  5781. }
  5782. -static u32 _rtl88e_phy_calculate_bit_shift(u32 bitmask)
  5783. -{
  5784. - u32 i;
  5785. -
  5786. - for (i = 0; i <= 31; i++) {
  5787. - if (((bitmask >> i) & 0x1) == 1)
  5788. - break;
  5789. - }
  5790. - return i;
  5791. -}
  5792. -
  5793. bool rtl88e_phy_mac_config(struct ieee80211_hw *hw)
  5794. {
  5795. struct rtl_priv *rtlpriv = rtl_priv(hw);
  5796. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.c drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.c
  5797. index 7c6e5d91439d..bc2b3849828d 100644
  5798. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.c
  5799. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.c
  5800. @@ -39,7 +39,7 @@ u32 rtl92c_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
  5801. RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "regaddr(%#x), bitmask(%#x)\n",
  5802. regaddr, bitmask);
  5803. originalvalue = rtl_read_dword(rtlpriv, regaddr);
  5804. - bitshift = _rtl92c_phy_calculate_bit_shift(bitmask);
  5805. + bitshift = calculate_bit_shift(bitmask);
  5806. returnvalue = (originalvalue & bitmask) >> bitshift;
  5807. RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
  5808. @@ -62,7 +62,7 @@ void rtl92c_phy_set_bb_reg(struct ieee80211_hw *hw,
  5809. if (bitmask != MASKDWORD) {
  5810. originalvalue = rtl_read_dword(rtlpriv, regaddr);
  5811. - bitshift = _rtl92c_phy_calculate_bit_shift(bitmask);
  5812. + bitshift = calculate_bit_shift(bitmask);
  5813. data = ((originalvalue & (~bitmask)) | (data << bitshift));
  5814. }
  5815. @@ -165,18 +165,6 @@ void _rtl92c_phy_rf_serial_write(struct ieee80211_hw *hw,
  5816. }
  5817. EXPORT_SYMBOL(_rtl92c_phy_rf_serial_write);
  5818. -u32 _rtl92c_phy_calculate_bit_shift(u32 bitmask)
  5819. -{
  5820. - u32 i;
  5821. -
  5822. - for (i = 0; i <= 31; i++) {
  5823. - if (((bitmask >> i) & 0x1) == 1)
  5824. - break;
  5825. - }
  5826. - return i;
  5827. -}
  5828. -EXPORT_SYMBOL(_rtl92c_phy_calculate_bit_shift);
  5829. -
  5830. static void _rtl92c_phy_bb_config_1t(struct ieee80211_hw *hw)
  5831. {
  5832. rtl_set_bbreg(hw, RFPGA0_TXINFO, 0x3, 0x2);
  5833. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.h drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.h
  5834. index d11261e05a2e..76f574047c62 100644
  5835. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.h
  5836. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.h
  5837. @@ -218,7 +218,6 @@ bool rtl92c_phy_set_rf_power_state(struct ieee80211_hw *hw,
  5838. void rtl92ce_phy_set_rf_on(struct ieee80211_hw *hw);
  5839. void rtl92c_phy_set_io(struct ieee80211_hw *hw);
  5840. void rtl92c_bb_block_on(struct ieee80211_hw *hw);
  5841. -u32 _rtl92c_phy_calculate_bit_shift(u32 bitmask);
  5842. long _rtl92c_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw,
  5843. enum wireless_mode wirelessmode,
  5844. u8 txpwridx);
  5845. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.c drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.c
  5846. index 7c6d7fc1ef9a..9f478d8af804 100644
  5847. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.c
  5848. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.c
  5849. @@ -61,7 +61,7 @@ u32 rtl92c_phy_query_rf_reg(struct ieee80211_hw *hw,
  5850. rfpath, regaddr);
  5851. }
  5852. - bitshift = _rtl92c_phy_calculate_bit_shift(bitmask);
  5853. + bitshift = calculate_bit_shift(bitmask);
  5854. readback_value = (original_value & bitmask) >> bitshift;
  5855. spin_unlock(&rtlpriv->locks.rf_lock);
  5856. @@ -132,7 +132,7 @@ void rtl92ce_phy_set_rf_reg(struct ieee80211_hw *hw,
  5857. original_value = _rtl92c_phy_rf_serial_read(hw,
  5858. rfpath,
  5859. regaddr);
  5860. - bitshift = _rtl92c_phy_calculate_bit_shift(bitmask);
  5861. + bitshift = calculate_bit_shift(bitmask);
  5862. data =
  5863. ((original_value & (~bitmask)) |
  5864. (data << bitshift));
  5865. @@ -144,7 +144,7 @@ void rtl92ce_phy_set_rf_reg(struct ieee80211_hw *hw,
  5866. original_value = _rtl92c_phy_fw_rf_serial_read(hw,
  5867. rfpath,
  5868. regaddr);
  5869. - bitshift = _rtl92c_phy_calculate_bit_shift(bitmask);
  5870. + bitshift = calculate_bit_shift(bitmask);
  5871. data =
  5872. ((original_value & (~bitmask)) |
  5873. (data << bitshift));
  5874. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.h drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.h
  5875. index 93f3bc0197b4..e084a91e26d9 100644
  5876. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.h
  5877. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/phy.h
  5878. @@ -116,7 +116,6 @@ u32 _rtl92c_phy_rf_serial_read(struct ieee80211_hw *hw, enum radio_path rfpath,
  5879. u32 offset);
  5880. u32 _rtl92c_phy_fw_rf_serial_read(struct ieee80211_hw *hw,
  5881. enum radio_path rfpath, u32 offset);
  5882. -u32 _rtl92c_phy_calculate_bit_shift(u32 bitmask);
  5883. void _rtl92c_phy_rf_serial_write(struct ieee80211_hw *hw,
  5884. enum radio_path rfpath, u32 offset, u32 data);
  5885. void _rtl92c_phy_fw_rf_serial_write(struct ieee80211_hw *hw,
  5886. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8192cu/phy.c drivers/net/wireless/realtek/rtlwifi/rtl8192cu/phy.c
  5887. index f068dd5317a7..5a5476a2dc2f 100644
  5888. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/phy.c
  5889. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/phy.c
  5890. @@ -54,7 +54,7 @@ u32 rtl92cu_phy_query_rf_reg(struct ieee80211_hw *hw,
  5891. original_value = _rtl92c_phy_fw_rf_serial_read(hw,
  5892. rfpath, regaddr);
  5893. }
  5894. - bitshift = _rtl92c_phy_calculate_bit_shift(bitmask);
  5895. + bitshift = calculate_bit_shift(bitmask);
  5896. readback_value = (original_value & bitmask) >> bitshift;
  5897. RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
  5898. "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
  5899. @@ -78,7 +78,7 @@ void rtl92cu_phy_set_rf_reg(struct ieee80211_hw *hw,
  5900. original_value = _rtl92c_phy_rf_serial_read(hw,
  5901. rfpath,
  5902. regaddr);
  5903. - bitshift = _rtl92c_phy_calculate_bit_shift(bitmask);
  5904. + bitshift = calculate_bit_shift(bitmask);
  5905. data =
  5906. ((original_value & (~bitmask)) |
  5907. (data << bitshift));
  5908. @@ -89,7 +89,7 @@ void rtl92cu_phy_set_rf_reg(struct ieee80211_hw *hw,
  5909. original_value = _rtl92c_phy_fw_rf_serial_read(hw,
  5910. rfpath,
  5911. regaddr);
  5912. - bitshift = _rtl92c_phy_calculate_bit_shift(bitmask);
  5913. + bitshift = calculate_bit_shift(bitmask);
  5914. data =
  5915. ((original_value & (~bitmask)) |
  5916. (data << bitshift));
  5917. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c
  5918. index 53734250479c..2ee779614269 100644
  5919. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c
  5920. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c
  5921. @@ -182,17 +182,14 @@ static u32 targetchnl_2g[TARGET_CHNL_NUM_2G] = {
  5922. 25711, 25658, 25606, 25554, 25502, 25451, 25328
  5923. };
  5924. -static u32 _rtl92d_phy_calculate_bit_shift(u32 bitmask)
  5925. -{
  5926. - u32 i;
  5927. -
  5928. - for (i = 0; i <= 31; i++) {
  5929. - if (((bitmask >> i) & 0x1) == 1)
  5930. - break;
  5931. - }
  5932. -
  5933. - return i;
  5934. -}
  5935. +static const u8 channel_all[59] = {
  5936. + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  5937. + 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
  5938. + 60, 62, 64, 100, 102, 104, 106, 108, 110, 112,
  5939. + 114, 116, 118, 120, 122, 124, 126, 128, 130,
  5940. + 132, 134, 136, 138, 140, 149, 151, 153, 155,
  5941. + 157, 159, 161, 163, 165
  5942. +};
  5943. u32 rtl92d_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
  5944. {
  5945. @@ -216,7 +213,7 @@ u32 rtl92d_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
  5946. } else {
  5947. originalvalue = rtl_read_dword(rtlpriv, regaddr);
  5948. }
  5949. - bitshift = _rtl92d_phy_calculate_bit_shift(bitmask);
  5950. + bitshift = calculate_bit_shift(bitmask);
  5951. returnvalue = (originalvalue & bitmask) >> bitshift;
  5952. RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
  5953. "BBR MASK=0x%x Addr[0x%x]=0x%x\n",
  5954. @@ -248,7 +245,7 @@ void rtl92d_phy_set_bb_reg(struct ieee80211_hw *hw,
  5955. dbi_direct);
  5956. else
  5957. originalvalue = rtl_read_dword(rtlpriv, regaddr);
  5958. - bitshift = _rtl92d_phy_calculate_bit_shift(bitmask);
  5959. + bitshift = calculate_bit_shift(bitmask);
  5960. data = ((originalvalue & (~bitmask)) | (data << bitshift));
  5961. }
  5962. if (rtlhal->during_mac1init_radioa || rtlhal->during_mac0init_radiob)
  5963. @@ -336,7 +333,7 @@ u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw,
  5964. regaddr, rfpath, bitmask);
  5965. spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags);
  5966. original_value = _rtl92d_phy_rf_serial_read(hw, rfpath, regaddr);
  5967. - bitshift = _rtl92d_phy_calculate_bit_shift(bitmask);
  5968. + bitshift = calculate_bit_shift(bitmask);
  5969. readback_value = (original_value & bitmask) >> bitshift;
  5970. spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags);
  5971. RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
  5972. @@ -363,7 +360,7 @@ void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
  5973. if (bitmask != RFREG_OFFSET_MASK) {
  5974. original_value = _rtl92d_phy_rf_serial_read(hw,
  5975. rfpath, regaddr);
  5976. - bitshift = _rtl92d_phy_calculate_bit_shift(bitmask);
  5977. + bitshift = calculate_bit_shift(bitmask);
  5978. data = ((original_value & (~bitmask)) |
  5979. (data << bitshift));
  5980. }
  5981. @@ -1383,14 +1380,6 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel)
  5982. u8 rtl92d_get_rightchnlplace_for_iqk(u8 chnl)
  5983. {
  5984. - u8 channel_all[59] = {
  5985. - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  5986. - 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
  5987. - 60, 62, 64, 100, 102, 104, 106, 108, 110, 112,
  5988. - 114, 116, 118, 120, 122, 124, 126, 128, 130,
  5989. - 132, 134, 136, 138, 140, 149, 151, 153, 155,
  5990. - 157, 159, 161, 163, 165
  5991. - };
  5992. u8 place = chnl;
  5993. if (chnl > 14) {
  5994. @@ -3245,37 +3234,28 @@ void rtl92d_phy_config_macphymode_info(struct ieee80211_hw *hw)
  5995. u8 rtl92d_get_chnlgroup_fromarray(u8 chnl)
  5996. {
  5997. u8 group;
  5998. - u8 channel_info[59] = {
  5999. - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  6000. - 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56,
  6001. - 58, 60, 62, 64, 100, 102, 104, 106, 108,
  6002. - 110, 112, 114, 116, 118, 120, 122, 124,
  6003. - 126, 128, 130, 132, 134, 136, 138, 140,
  6004. - 149, 151, 153, 155, 157, 159, 161, 163,
  6005. - 165
  6006. - };
  6007. - if (channel_info[chnl] <= 3)
  6008. + if (channel_all[chnl] <= 3)
  6009. group = 0;
  6010. - else if (channel_info[chnl] <= 9)
  6011. + else if (channel_all[chnl] <= 9)
  6012. group = 1;
  6013. - else if (channel_info[chnl] <= 14)
  6014. + else if (channel_all[chnl] <= 14)
  6015. group = 2;
  6016. - else if (channel_info[chnl] <= 44)
  6017. + else if (channel_all[chnl] <= 44)
  6018. group = 3;
  6019. - else if (channel_info[chnl] <= 54)
  6020. + else if (channel_all[chnl] <= 54)
  6021. group = 4;
  6022. - else if (channel_info[chnl] <= 64)
  6023. + else if (channel_all[chnl] <= 64)
  6024. group = 5;
  6025. - else if (channel_info[chnl] <= 112)
  6026. + else if (channel_all[chnl] <= 112)
  6027. group = 6;
  6028. - else if (channel_info[chnl] <= 126)
  6029. + else if (channel_all[chnl] <= 126)
  6030. group = 7;
  6031. - else if (channel_info[chnl] <= 140)
  6032. + else if (channel_all[chnl] <= 140)
  6033. group = 8;
  6034. - else if (channel_info[chnl] <= 153)
  6035. + else if (channel_all[chnl] <= 153)
  6036. group = 9;
  6037. - else if (channel_info[chnl] <= 159)
  6038. + else if (channel_all[chnl] <= 159)
  6039. group = 10;
  6040. else
  6041. group = 11;
  6042. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8192ee/phy.c drivers/net/wireless/realtek/rtlwifi/rtl8192ee/phy.c
  6043. index 8b072ee8e0d5..9a3e88d6a570 100644
  6044. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/phy.c
  6045. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/phy.c
  6046. @@ -38,7 +38,6 @@ static u32 _rtl92ee_phy_rf_serial_read(struct ieee80211_hw *hw,
  6047. static void _rtl92ee_phy_rf_serial_write(struct ieee80211_hw *hw,
  6048. enum radio_path rfpath, u32 offset,
  6049. u32 data);
  6050. -static u32 _rtl92ee_phy_calculate_bit_shift(u32 bitmask);
  6051. static bool _rtl92ee_phy_bb8192ee_config_parafile(struct ieee80211_hw *hw);
  6052. static bool _rtl92ee_phy_config_mac_with_headerfile(struct ieee80211_hw *hw);
  6053. static bool phy_config_bb_with_hdr_file(struct ieee80211_hw *hw,
  6054. @@ -68,7 +67,7 @@ u32 rtl92ee_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
  6055. RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
  6056. "regaddr(%#x), bitmask(%#x)\n", regaddr, bitmask);
  6057. originalvalue = rtl_read_dword(rtlpriv, regaddr);
  6058. - bitshift = _rtl92ee_phy_calculate_bit_shift(bitmask);
  6059. + bitshift = calculate_bit_shift(bitmask);
  6060. returnvalue = (originalvalue & bitmask) >> bitshift;
  6061. RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
  6062. @@ -90,7 +89,7 @@ void rtl92ee_phy_set_bb_reg(struct ieee80211_hw *hw, u32 regaddr,
  6063. if (bitmask != MASKDWORD) {
  6064. originalvalue = rtl_read_dword(rtlpriv, regaddr);
  6065. - bitshift = _rtl92ee_phy_calculate_bit_shift(bitmask);
  6066. + bitshift = calculate_bit_shift(bitmask);
  6067. data = ((originalvalue & (~bitmask)) | (data << bitshift));
  6068. }
  6069. @@ -115,7 +114,7 @@ u32 rtl92ee_phy_query_rf_reg(struct ieee80211_hw *hw,
  6070. spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags);
  6071. original_value = _rtl92ee_phy_rf_serial_read(hw , rfpath, regaddr);
  6072. - bitshift = _rtl92ee_phy_calculate_bit_shift(bitmask);
  6073. + bitshift = calculate_bit_shift(bitmask);
  6074. readback_value = (original_value & bitmask) >> bitshift;
  6075. spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags);
  6076. @@ -143,7 +142,7 @@ void rtl92ee_phy_set_rf_reg(struct ieee80211_hw *hw,
  6077. if (bitmask != RFREG_OFFSET_MASK) {
  6078. original_value = _rtl92ee_phy_rf_serial_read(hw, rfpath, addr);
  6079. - bitshift = _rtl92ee_phy_calculate_bit_shift(bitmask);
  6080. + bitshift = calculate_bit_shift(bitmask);
  6081. data = (original_value & (~bitmask)) | (data << bitshift);
  6082. }
  6083. @@ -226,17 +225,6 @@ static void _rtl92ee_phy_rf_serial_write(struct ieee80211_hw *hw,
  6084. pphyreg->rf3wire_offset, data_and_addr);
  6085. }
  6086. -static u32 _rtl92ee_phy_calculate_bit_shift(u32 bitmask)
  6087. -{
  6088. - u32 i;
  6089. -
  6090. - for (i = 0; i <= 31; i++) {
  6091. - if (((bitmask >> i) & 0x1) == 1)
  6092. - break;
  6093. - }
  6094. - return i;
  6095. -}
  6096. -
  6097. bool rtl92ee_phy_mac_config(struct ieee80211_hw *hw)
  6098. {
  6099. return _rtl92ee_phy_config_mac_with_headerfile(hw);
  6100. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8192se/phy.c drivers/net/wireless/realtek/rtlwifi/rtl8192se/phy.c
  6101. index 86cb853f7169..0430a3b823d6 100644
  6102. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192se/phy.c
  6103. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8192se/phy.c
  6104. @@ -36,18 +36,6 @@
  6105. #include "hw.h"
  6106. #include "table.h"
  6107. -static u32 _rtl92s_phy_calculate_bit_shift(u32 bitmask)
  6108. -{
  6109. - u32 i;
  6110. -
  6111. - for (i = 0; i <= 31; i++) {
  6112. - if (((bitmask >> i) & 0x1) == 1)
  6113. - break;
  6114. - }
  6115. -
  6116. - return i;
  6117. -}
  6118. -
  6119. u32 rtl92s_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
  6120. {
  6121. struct rtl_priv *rtlpriv = rtl_priv(hw);
  6122. @@ -57,7 +45,7 @@ u32 rtl92s_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
  6123. regaddr, bitmask);
  6124. originalvalue = rtl_read_dword(rtlpriv, regaddr);
  6125. - bitshift = _rtl92s_phy_calculate_bit_shift(bitmask);
  6126. + bitshift = calculate_bit_shift(bitmask);
  6127. returnvalue = (originalvalue & bitmask) >> bitshift;
  6128. RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "BBR MASK=0x%x Addr[0x%x]=0x%x\n",
  6129. @@ -79,7 +67,7 @@ void rtl92s_phy_set_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask,
  6130. if (bitmask != MASKDWORD) {
  6131. originalvalue = rtl_read_dword(rtlpriv, regaddr);
  6132. - bitshift = _rtl92s_phy_calculate_bit_shift(bitmask);
  6133. + bitshift = calculate_bit_shift(bitmask);
  6134. data = ((originalvalue & (~bitmask)) | (data << bitshift));
  6135. }
  6136. @@ -187,7 +175,7 @@ u32 rtl92s_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
  6137. original_value = _rtl92s_phy_rf_serial_read(hw, rfpath, regaddr);
  6138. - bitshift = _rtl92s_phy_calculate_bit_shift(bitmask);
  6139. + bitshift = calculate_bit_shift(bitmask);
  6140. readback_value = (original_value & bitmask) >> bitshift;
  6141. spin_unlock(&rtlpriv->locks.rf_lock);
  6142. @@ -218,7 +206,7 @@ void rtl92s_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
  6143. if (bitmask != RFREG_OFFSET_MASK) {
  6144. original_value = _rtl92s_phy_rf_serial_read(hw, rfpath,
  6145. regaddr);
  6146. - bitshift = _rtl92s_phy_calculate_bit_shift(bitmask);
  6147. + bitshift = calculate_bit_shift(bitmask);
  6148. data = ((original_value & (~bitmask)) | (data << bitshift));
  6149. }
  6150. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c
  6151. index 5cf29f5a4b54..e6ac496e898e 100644
  6152. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c
  6153. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c
  6154. @@ -72,7 +72,7 @@ u32 rtl8723e_phy_query_rf_reg(struct ieee80211_hw *hw,
  6155. rfpath, regaddr);
  6156. }
  6157. - bitshift = rtl8723_phy_calculate_bit_shift(bitmask);
  6158. + bitshift = calculate_bit_shift(bitmask);
  6159. readback_value = (original_value & bitmask) >> bitshift;
  6160. spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags);
  6161. @@ -104,7 +104,7 @@ void rtl8723e_phy_set_rf_reg(struct ieee80211_hw *hw,
  6162. original_value = rtl8723_phy_rf_serial_read(hw,
  6163. rfpath,
  6164. regaddr);
  6165. - bitshift = rtl8723_phy_calculate_bit_shift(bitmask);
  6166. + bitshift = calculate_bit_shift(bitmask);
  6167. data =
  6168. ((original_value & (~bitmask)) |
  6169. (data << bitshift));
  6170. @@ -113,7 +113,7 @@ void rtl8723e_phy_set_rf_reg(struct ieee80211_hw *hw,
  6171. rtl8723_phy_rf_serial_write(hw, rfpath, regaddr, data);
  6172. } else {
  6173. if (bitmask != RFREG_OFFSET_MASK) {
  6174. - bitshift = rtl8723_phy_calculate_bit_shift(bitmask);
  6175. + bitshift = calculate_bit_shift(bitmask);
  6176. data =
  6177. ((original_value & (~bitmask)) |
  6178. (data << bitshift));
  6179. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c
  6180. index 9606641519e7..f1b42f9d6cd1 100644
  6181. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c
  6182. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c
  6183. @@ -63,7 +63,7 @@ u32 rtl8723be_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
  6184. spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags);
  6185. original_value = rtl8723_phy_rf_serial_read(hw, rfpath, regaddr);
  6186. - bitshift = rtl8723_phy_calculate_bit_shift(bitmask);
  6187. + bitshift = calculate_bit_shift(bitmask);
  6188. readback_value = (original_value & bitmask) >> bitshift;
  6189. spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags);
  6190. @@ -91,7 +91,7 @@ void rtl8723be_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path path,
  6191. if (bitmask != RFREG_OFFSET_MASK) {
  6192. original_value = rtl8723_phy_rf_serial_read(hw, path,
  6193. regaddr);
  6194. - bitshift = rtl8723_phy_calculate_bit_shift(bitmask);
  6195. + bitshift = calculate_bit_shift(bitmask);
  6196. data = ((original_value & (~bitmask)) |
  6197. (data << bitshift));
  6198. }
  6199. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8723com/phy_common.c drivers/net/wireless/realtek/rtlwifi/rtl8723com/phy_common.c
  6200. index 43d24e1ee5e6..af9cd74e09d4 100644
  6201. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8723com/phy_common.c
  6202. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8723com/phy_common.c
  6203. @@ -75,13 +75,9 @@ EXPORT_SYMBOL_GPL(rtl8723_phy_set_bb_reg);
  6204. u32 rtl8723_phy_calculate_bit_shift(u32 bitmask)
  6205. {
  6206. - u32 i;
  6207. + u32 i = ffs(bitmask);
  6208. - for (i = 0; i <= 31; i++) {
  6209. - if (((bitmask >> i) & 0x1) == 1)
  6210. - break;
  6211. - }
  6212. - return i;
  6213. + return i ? i - 1 : 32;
  6214. }
  6215. EXPORT_SYMBOL_GPL(rtl8723_phy_calculate_bit_shift);
  6216. diff --git drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
  6217. index 176deb2b5386..f96d823e7f14 100644
  6218. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
  6219. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
  6220. @@ -49,7 +49,13 @@ static u32 _rtl8821ae_phy_rf_serial_read(struct ieee80211_hw *hw,
  6221. static void _rtl8821ae_phy_rf_serial_write(struct ieee80211_hw *hw,
  6222. enum radio_path rfpath, u32 offset,
  6223. u32 data);
  6224. -static u32 _rtl8821ae_phy_calculate_bit_shift(u32 bitmask);
  6225. +static u32 _rtl8821ae_phy_calculate_bit_shift(u32 bitmask)
  6226. +{
  6227. + if (WARN_ON_ONCE(!bitmask))
  6228. + return 0;
  6229. +
  6230. + return __ffs(bitmask);
  6231. +}
  6232. static bool _rtl8821ae_phy_bb8821a_config_parafile(struct ieee80211_hw *hw);
  6233. /*static bool _rtl8812ae_phy_config_mac_with_headerfile(struct ieee80211_hw *hw);*/
  6234. static bool _rtl8821ae_phy_config_mac_with_headerfile(struct ieee80211_hw *hw);
  6235. @@ -296,17 +302,6 @@ static void _rtl8821ae_phy_rf_serial_write(struct ieee80211_hw *hw,
  6236. rfpath, pphyreg->rf3wire_offset, data_and_addr);
  6237. }
  6238. -static u32 _rtl8821ae_phy_calculate_bit_shift(u32 bitmask)
  6239. -{
  6240. - u32 i;
  6241. -
  6242. - for (i = 0; i <= 31; i++) {
  6243. - if (((bitmask >> i) & 0x1) == 1)
  6244. - break;
  6245. - }
  6246. - return i;
  6247. -}
  6248. -
  6249. bool rtl8821ae_phy_mac_config(struct ieee80211_hw *hw)
  6250. {
  6251. bool rtstatus = 0;
  6252. diff --git drivers/net/wireless/realtek/rtlwifi/wifi.h drivers/net/wireless/realtek/rtlwifi/wifi.h
  6253. index c73ce334ce6c..61f5b6fc1754 100644
  6254. --- linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/wifi.h
  6255. +++ linux-4.14.336/drivers/net/wireless/realtek/rtlwifi/wifi.h
  6256. @@ -3095,4 +3095,11 @@ static inline struct ieee80211_sta *rtl_find_sta(struct ieee80211_hw *hw,
  6257. return ieee80211_find_sta(mac->vif, mac_addr);
  6258. }
  6259. +static inline u32 calculate_bit_shift(u32 bitmask)
  6260. +{
  6261. + if (WARN_ON_ONCE(!bitmask))
  6262. + return 0;
  6263. +
  6264. + return __ffs(bitmask);
  6265. +}
  6266. #endif
  6267. diff --git drivers/net/xen-netback/netback.c drivers/net/xen-netback/netback.c
  6268. index 47e7e9aab9cf..901ddea37da6 100644
  6269. --- linux-4.14.336/drivers/net/xen-netback/netback.c
  6270. +++ linux-4.14.336/drivers/net/xen-netback/netback.c
  6271. @@ -97,13 +97,12 @@ module_param_named(hash_cache_size, xenvif_hash_cache_size, uint, 0644);
  6272. MODULE_PARM_DESC(hash_cache_size, "Number of flows in the hash cache");
  6273. static void xenvif_idx_release(struct xenvif_queue *queue, u16 pending_idx,
  6274. - u8 status);
  6275. + s8 status);
  6276. static void make_tx_response(struct xenvif_queue *queue,
  6277. - struct xen_netif_tx_request *txp,
  6278. + const struct xen_netif_tx_request *txp,
  6279. unsigned int extra_count,
  6280. - s8 st);
  6281. -static void push_tx_responses(struct xenvif_queue *queue);
  6282. + s8 status);
  6283. static void xenvif_idx_unmap(struct xenvif_queue *queue, u16 pending_idx);
  6284. @@ -201,13 +200,9 @@ static void xenvif_tx_err(struct xenvif_queue *queue,
  6285. unsigned int extra_count, RING_IDX end)
  6286. {
  6287. RING_IDX cons = queue->tx.req_cons;
  6288. - unsigned long flags;
  6289. do {
  6290. - spin_lock_irqsave(&queue->response_lock, flags);
  6291. make_tx_response(queue, txp, extra_count, XEN_NETIF_RSP_ERROR);
  6292. - push_tx_responses(queue);
  6293. - spin_unlock_irqrestore(&queue->response_lock, flags);
  6294. if (cons == end)
  6295. break;
  6296. RING_COPY_REQUEST(&queue->tx, cons++, txp);
  6297. @@ -456,12 +451,20 @@ static void xenvif_get_requests(struct xenvif_queue *queue,
  6298. }
  6299. for (shinfo->nr_frags = 0; nr_slots > 0 && shinfo->nr_frags < MAX_SKB_FRAGS;
  6300. - shinfo->nr_frags++, gop++, nr_slots--) {
  6301. + nr_slots--) {
  6302. + if (unlikely(!txp->size)) {
  6303. + make_tx_response(queue, txp, 0, XEN_NETIF_RSP_OKAY);
  6304. + ++txp;
  6305. + continue;
  6306. + }
  6307. +
  6308. index = pending_index(queue->pending_cons++);
  6309. pending_idx = queue->pending_ring[index];
  6310. xenvif_tx_create_map_op(queue, pending_idx, txp,
  6311. txp == first ? extra_count : 0, gop);
  6312. frag_set_pending_idx(&frags[shinfo->nr_frags], pending_idx);
  6313. + ++shinfo->nr_frags;
  6314. + ++gop;
  6315. if (txp == first)
  6316. txp = txfrags;
  6317. @@ -474,20 +477,33 @@ static void xenvif_get_requests(struct xenvif_queue *queue,
  6318. shinfo = skb_shinfo(nskb);
  6319. frags = shinfo->frags;
  6320. - for (shinfo->nr_frags = 0; shinfo->nr_frags < nr_slots;
  6321. - shinfo->nr_frags++, txp++, gop++) {
  6322. + for (shinfo->nr_frags = 0; shinfo->nr_frags < nr_slots; ++txp) {
  6323. + if (unlikely(!txp->size)) {
  6324. + make_tx_response(queue, txp, 0,
  6325. + XEN_NETIF_RSP_OKAY);
  6326. + continue;
  6327. + }
  6328. +
  6329. index = pending_index(queue->pending_cons++);
  6330. pending_idx = queue->pending_ring[index];
  6331. xenvif_tx_create_map_op(queue, pending_idx, txp, 0,
  6332. gop);
  6333. frag_set_pending_idx(&frags[shinfo->nr_frags],
  6334. pending_idx);
  6335. + ++shinfo->nr_frags;
  6336. + ++gop;
  6337. + }
  6338. +
  6339. + if (shinfo->nr_frags) {
  6340. + skb_shinfo(skb)->frag_list = nskb;
  6341. + nskb = NULL;
  6342. }
  6343. + }
  6344. - skb_shinfo(skb)->frag_list = nskb;
  6345. - } else if (nskb) {
  6346. + if (nskb) {
  6347. /* A frag_list skb was allocated but it is no longer needed
  6348. - * because enough slots were converted to copy ops above.
  6349. + * because enough slots were converted to copy ops above or some
  6350. + * were empty.
  6351. */
  6352. kfree_skb(nskb);
  6353. }
  6354. @@ -960,7 +976,6 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue,
  6355. (ret == 0) ?
  6356. XEN_NETIF_RSP_OKAY :
  6357. XEN_NETIF_RSP_ERROR);
  6358. - push_tx_responses(queue);
  6359. continue;
  6360. }
  6361. @@ -972,7 +987,6 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue,
  6362. make_tx_response(queue, &txreq, extra_count,
  6363. XEN_NETIF_RSP_OKAY);
  6364. - push_tx_responses(queue);
  6365. continue;
  6366. }
  6367. @@ -1398,8 +1412,35 @@ int xenvif_tx_action(struct xenvif_queue *queue, int budget)
  6368. return work_done;
  6369. }
  6370. +static void _make_tx_response(struct xenvif_queue *queue,
  6371. + const struct xen_netif_tx_request *txp,
  6372. + unsigned int extra_count,
  6373. + s8 status)
  6374. +{
  6375. + RING_IDX i = queue->tx.rsp_prod_pvt;
  6376. + struct xen_netif_tx_response *resp;
  6377. +
  6378. + resp = RING_GET_RESPONSE(&queue->tx, i);
  6379. + resp->id = txp->id;
  6380. + resp->status = status;
  6381. +
  6382. + while (extra_count-- != 0)
  6383. + RING_GET_RESPONSE(&queue->tx, ++i)->status = XEN_NETIF_RSP_NULL;
  6384. +
  6385. + queue->tx.rsp_prod_pvt = ++i;
  6386. +}
  6387. +
  6388. +static void push_tx_responses(struct xenvif_queue *queue)
  6389. +{
  6390. + int notify;
  6391. +
  6392. + RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&queue->tx, notify);
  6393. + if (notify)
  6394. + notify_remote_via_irq(queue->tx_irq);
  6395. +}
  6396. +
  6397. static void xenvif_idx_release(struct xenvif_queue *queue, u16 pending_idx,
  6398. - u8 status)
  6399. + s8 status)
  6400. {
  6401. struct pending_tx_info *pending_tx_info;
  6402. pending_ring_idx_t index;
  6403. @@ -1409,8 +1450,8 @@ static void xenvif_idx_release(struct xenvif_queue *queue, u16 pending_idx,
  6404. spin_lock_irqsave(&queue->response_lock, flags);
  6405. - make_tx_response(queue, &pending_tx_info->req,
  6406. - pending_tx_info->extra_count, status);
  6407. + _make_tx_response(queue, &pending_tx_info->req,
  6408. + pending_tx_info->extra_count, status);
  6409. /* Release the pending index before pusing the Tx response so
  6410. * its available before a new Tx request is pushed by the
  6411. @@ -1424,32 +1465,19 @@ static void xenvif_idx_release(struct xenvif_queue *queue, u16 pending_idx,
  6412. spin_unlock_irqrestore(&queue->response_lock, flags);
  6413. }
  6414. -
  6415. static void make_tx_response(struct xenvif_queue *queue,
  6416. - struct xen_netif_tx_request *txp,
  6417. + const struct xen_netif_tx_request *txp,
  6418. unsigned int extra_count,
  6419. - s8 st)
  6420. + s8 status)
  6421. {
  6422. - RING_IDX i = queue->tx.rsp_prod_pvt;
  6423. - struct xen_netif_tx_response *resp;
  6424. -
  6425. - resp = RING_GET_RESPONSE(&queue->tx, i);
  6426. - resp->id = txp->id;
  6427. - resp->status = st;
  6428. -
  6429. - while (extra_count-- != 0)
  6430. - RING_GET_RESPONSE(&queue->tx, ++i)->status = XEN_NETIF_RSP_NULL;
  6431. + unsigned long flags;
  6432. - queue->tx.rsp_prod_pvt = ++i;
  6433. -}
  6434. + spin_lock_irqsave(&queue->response_lock, flags);
  6435. -static void push_tx_responses(struct xenvif_queue *queue)
  6436. -{
  6437. - int notify;
  6438. + _make_tx_response(queue, txp, extra_count, status);
  6439. + push_tx_responses(queue);
  6440. - RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&queue->tx, notify);
  6441. - if (notify)
  6442. - notify_remote_via_irq(queue->tx_irq);
  6443. + spin_unlock_irqrestore(&queue->response_lock, flags);
  6444. }
  6445. static void xenvif_idx_unmap(struct xenvif_queue *queue, u16 pending_idx)
  6446. diff --git drivers/pci/host/pcie-mediatek.c drivers/pci/host/pcie-mediatek.c
  6447. index 60c3110b5151..6a47a6681f8d 100644
  6448. --- linux-4.14.336/drivers/pci/host/pcie-mediatek.c
  6449. +++ linux-4.14.336/drivers/pci/host/pcie-mediatek.c
  6450. @@ -628,6 +628,14 @@ static irqreturn_t mtk_pcie_intr_handler(int irq, void *data)
  6451. while ((status = readl(port->base + PCIE_INT_STATUS)) & MSI_STATUS) {
  6452. unsigned long imsi_status;
  6453. + /*
  6454. + * The interrupt status can be cleared even if the
  6455. + * MSI status remains pending. As such, given the
  6456. + * edge-triggered interrupt type, its status should
  6457. + * be cleared before being dispatched to the
  6458. + * handler of the underlying device.
  6459. + */
  6460. + writel(MSI_STATUS, port->base + PCIE_INT_STATUS);
  6461. while ((imsi_status = readl(port->base + PCIE_IMSI_STATUS))) {
  6462. for_each_set_bit(bit, &imsi_status, MTK_MSI_IRQS_NUM) {
  6463. /* Clear the MSI */
  6464. @@ -636,8 +644,6 @@ static irqreturn_t mtk_pcie_intr_handler(int irq, void *data)
  6465. generic_handle_irq(virq);
  6466. }
  6467. }
  6468. - /* Clear MSI interrupt status */
  6469. - writel(MSI_STATUS, port->base + PCIE_INT_STATUS);
  6470. }
  6471. }
  6472. diff --git drivers/pci/msi.c drivers/pci/msi.c
  6473. index bbddf492da9f..548045dda97c 100644
  6474. --- linux-4.14.336/drivers/pci/msi.c
  6475. +++ linux-4.14.336/drivers/pci/msi.c
  6476. @@ -1380,7 +1380,7 @@ irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev,
  6477. {
  6478. return (irq_hw_number_t)desc->msi_attrib.entry_nr |
  6479. PCI_DEVID(dev->bus->number, dev->devfn) << 11 |
  6480. - (pci_domain_nr(dev->bus) & 0xFFFFFFFF) << 27;
  6481. + ((irq_hw_number_t)(pci_domain_nr(dev->bus) & 0xFFFFFFFF)) << 27;
  6482. }
  6483. static inline bool pci_msi_desc_is_multi_msi(struct msi_desc *desc)
  6484. diff --git drivers/pci/quirks.c drivers/pci/quirks.c
  6485. index e32147929cf3..ef9303547484 100644
  6486. --- linux-4.14.336/drivers/pci/quirks.c
  6487. +++ linux-4.14.336/drivers/pci/quirks.c
  6488. @@ -441,10 +441,13 @@ static void quirk_amd_dwc_class(struct pci_dev *pdev)
  6489. {
  6490. u32 class = pdev->class;
  6491. - /* Use "USB Device (not host controller)" class */
  6492. - pdev->class = PCI_CLASS_SERIAL_USB_DEVICE;
  6493. - dev_info(&pdev->dev, "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n",
  6494. - class, pdev->class);
  6495. + if (class != PCI_CLASS_SERIAL_USB_DEVICE) {
  6496. + /* Use "USB Device (not host controller)" class */
  6497. + pdev->class = PCI_CLASS_SERIAL_USB_DEVICE;
  6498. + dev_info(&pdev->dev,
  6499. + "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n",
  6500. + class, pdev->class);
  6501. + }
  6502. }
  6503. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB,
  6504. quirk_amd_dwc_class);
  6505. @@ -3450,6 +3453,19 @@ static void quirk_no_pm_reset(struct pci_dev *dev)
  6506. DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_ATI, PCI_ANY_ID,
  6507. PCI_CLASS_DISPLAY_VGA, 8, quirk_no_pm_reset);
  6508. +/*
  6509. + * Spectrum-{1,2,3,4} devices report that a D3hot->D0 transition causes a reset
  6510. + * (i.e., they advertise NoSoftRst-). However, this transition does not have
  6511. + * any effect on the device: It continues to be operational and network ports
  6512. + * remain up. Advertising this support makes it seem as if a PM reset is viable
  6513. + * for these devices. Mark it as unavailable to skip it when testing reset
  6514. + * methods.
  6515. + */
  6516. +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MELLANOX, 0xcb84, quirk_no_pm_reset);
  6517. +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MELLANOX, 0xcf6c, quirk_no_pm_reset);
  6518. +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MELLANOX, 0xcf70, quirk_no_pm_reset);
  6519. +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MELLANOX, 0xcf80, quirk_no_pm_reset);
  6520. +
  6521. /*
  6522. * Thunderbolt controllers with broken MSI hotplug signaling:
  6523. * Entire 1st generation (Light Ridge, Eagle Ridge, Light Peak) and part
  6524. diff --git drivers/phy/ti/phy-omap-usb2.c drivers/phy/ti/phy-omap-usb2.c
  6525. index fe909fd8144f..ae94e1e66bcc 100644
  6526. --- linux-4.14.336/drivers/phy/ti/phy-omap-usb2.c
  6527. +++ linux-4.14.336/drivers/phy/ti/phy-omap-usb2.c
  6528. @@ -64,7 +64,7 @@ static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled)
  6529. {
  6530. struct omap_usb *phy = phy_to_omapusb(otg->usb_phy);
  6531. - if (!phy->comparator)
  6532. + if (!phy->comparator || !phy->comparator->set_vbus)
  6533. return -ENODEV;
  6534. return phy->comparator->set_vbus(phy->comparator, enabled);
  6535. @@ -74,7 +74,7 @@ static int omap_usb_start_srp(struct usb_otg *otg)
  6536. {
  6537. struct omap_usb *phy = phy_to_omapusb(otg->usb_phy);
  6538. - if (!phy->comparator)
  6539. + if (!phy->comparator || !phy->comparator->start_srp)
  6540. return -ENODEV;
  6541. return phy->comparator->start_srp(phy->comparator);
  6542. diff --git drivers/pnp/pnpacpi/rsparser.c drivers/pnp/pnpacpi/rsparser.c
  6543. index 43d8ed577e70..d8cee80e8df8 100644
  6544. --- linux-4.14.336/drivers/pnp/pnpacpi/rsparser.c
  6545. +++ linux-4.14.336/drivers/pnp/pnpacpi/rsparser.c
  6546. @@ -160,13 +160,13 @@ static int vendor_resource_matches(struct pnp_dev *dev,
  6547. static void pnpacpi_parse_allocated_vendor(struct pnp_dev *dev,
  6548. struct acpi_resource_vendor_typed *vendor)
  6549. {
  6550. - if (vendor_resource_matches(dev, vendor, &hp_ccsr_uuid, 16)) {
  6551. - u64 start, length;
  6552. + struct { u64 start, length; } range;
  6553. - memcpy(&start, vendor->byte_data, sizeof(start));
  6554. - memcpy(&length, vendor->byte_data + 8, sizeof(length));
  6555. -
  6556. - pnp_add_mem_resource(dev, start, start + length - 1, 0);
  6557. + if (vendor_resource_matches(dev, vendor, &hp_ccsr_uuid,
  6558. + sizeof(range))) {
  6559. + memcpy(&range, vendor->byte_data, sizeof(range));
  6560. + pnp_add_mem_resource(dev, range.start, range.start +
  6561. + range.length - 1, 0);
  6562. }
  6563. }
  6564. diff --git drivers/power/supply/bq27xxx_battery_i2c.c drivers/power/supply/bq27xxx_battery_i2c.c
  6565. index 426ce81333a5..3eb839405d3f 100644
  6566. --- linux-4.14.336/drivers/power/supply/bq27xxx_battery_i2c.c
  6567. +++ linux-4.14.336/drivers/power/supply/bq27xxx_battery_i2c.c
  6568. @@ -217,7 +217,9 @@ static int bq27xxx_battery_i2c_remove(struct i2c_client *client)
  6569. {
  6570. struct bq27xxx_device_info *di = i2c_get_clientdata(client);
  6571. - free_irq(client->irq, di);
  6572. + if (client->irq)
  6573. + free_irq(client->irq, di);
  6574. +
  6575. bq27xxx_battery_teardown(di);
  6576. mutex_lock(&battery_mutex);
  6577. diff --git drivers/regulator/pwm-regulator.c drivers/regulator/pwm-regulator.c
  6578. index a2fd140eff81..5faa5906ad69 100644
  6579. --- linux-4.14.336/drivers/regulator/pwm-regulator.c
  6580. +++ linux-4.14.336/drivers/regulator/pwm-regulator.c
  6581. @@ -164,6 +164,9 @@ static int pwm_regulator_get_voltage(struct regulator_dev *rdev)
  6582. pwm_get_state(drvdata->pwm, &pstate);
  6583. voltage = pwm_get_relative_duty_cycle(&pstate, duty_unit);
  6584. + if (voltage < min(max_uV_duty, min_uV_duty) ||
  6585. + voltage > max(max_uV_duty, min_uV_duty))
  6586. + return -ENOTRECOVERABLE;
  6587. /*
  6588. * The dutycycle for min_uV might be greater than the one for max_uV.
  6589. diff --git drivers/reset/hisilicon/hi6220_reset.c drivers/reset/hisilicon/hi6220_reset.c
  6590. index d5e5229308f2..d77a7ad7e57a 100644
  6591. --- linux-4.14.336/drivers/reset/hisilicon/hi6220_reset.c
  6592. +++ linux-4.14.336/drivers/reset/hisilicon/hi6220_reset.c
  6593. @@ -107,7 +107,7 @@ static int hi6220_reset_probe(struct platform_device *pdev)
  6594. if (!data)
  6595. return -ENOMEM;
  6596. - type = (enum hi6220_reset_ctrl_type)of_device_get_match_data(dev);
  6597. + type = (uintptr_t)of_device_get_match_data(dev);
  6598. regmap = syscon_node_to_regmap(np);
  6599. if (IS_ERR(regmap)) {
  6600. diff --git drivers/rpmsg/virtio_rpmsg_bus.c drivers/rpmsg/virtio_rpmsg_bus.c
  6601. index 82b83002fcba..5aeb976fb4ee 100644
  6602. --- linux-4.14.336/drivers/rpmsg/virtio_rpmsg_bus.c
  6603. +++ linux-4.14.336/drivers/rpmsg/virtio_rpmsg_bus.c
  6604. @@ -389,6 +389,7 @@ static void virtio_rpmsg_release_device(struct device *dev)
  6605. struct rpmsg_device *rpdev = to_rpmsg_device(dev);
  6606. struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);
  6607. + kfree(rpdev->driver_override);
  6608. kfree(vch);
  6609. }
  6610. diff --git drivers/s390/block/scm_blk.c drivers/s390/block/scm_blk.c
  6611. index 5c944ee76ec1..a37fd27258bd 100644
  6612. --- linux-4.14.336/drivers/s390/block/scm_blk.c
  6613. +++ linux-4.14.336/drivers/s390/block/scm_blk.c
  6614. @@ -17,6 +17,7 @@
  6615. #include <linux/genhd.h>
  6616. #include <linux/slab.h>
  6617. #include <linux/list.h>
  6618. +#include <linux/io.h>
  6619. #include <asm/eadm.h>
  6620. #include "scm_blk.h"
  6621. @@ -130,7 +131,7 @@ static void scm_request_done(struct scm_request *scmrq)
  6622. for (i = 0; i < nr_requests_per_io && scmrq->request[i]; i++) {
  6623. msb = &scmrq->aob->msb[i];
  6624. - aidaw = msb->data_addr;
  6625. + aidaw = (u64)phys_to_virt(msb->data_addr);
  6626. if ((msb->flags & MSB_FLAG_IDA) && aidaw &&
  6627. IS_ALIGNED(aidaw, PAGE_SIZE))
  6628. @@ -195,12 +196,12 @@ static int scm_request_prepare(struct scm_request *scmrq)
  6629. msb->scm_addr = scmdev->address + ((u64) blk_rq_pos(req) << 9);
  6630. msb->oc = (rq_data_dir(req) == READ) ? MSB_OC_READ : MSB_OC_WRITE;
  6631. msb->flags |= MSB_FLAG_IDA;
  6632. - msb->data_addr = (u64) aidaw;
  6633. + msb->data_addr = (u64)virt_to_phys(aidaw);
  6634. rq_for_each_segment(bv, req, iter) {
  6635. WARN_ON(bv.bv_offset);
  6636. msb->blk_count += bv.bv_len >> 12;
  6637. - aidaw->data_addr = (u64) page_address(bv.bv_page);
  6638. + aidaw->data_addr = virt_to_phys(page_address(bv.bv_page));
  6639. aidaw++;
  6640. }
  6641. diff --git drivers/s390/net/qeth_l3_main.c drivers/s390/net/qeth_l3_main.c
  6642. index 8bccfd686b73..7d9a64e2691a 100644
  6643. --- linux-4.14.336/drivers/s390/net/qeth_l3_main.c
  6644. +++ linux-4.14.336/drivers/s390/net/qeth_l3_main.c
  6645. @@ -364,9 +364,10 @@ static void qeth_l3_clear_ip_htable(struct qeth_card *card, int recover)
  6646. if (!recover) {
  6647. hash_del(&addr->hnode);
  6648. kfree(addr);
  6649. - continue;
  6650. + } else {
  6651. + /* prepare for recovery */
  6652. + addr->disp_flag = QETH_DISP_ADDR_ADD;
  6653. }
  6654. - addr->disp_flag = QETH_DISP_ADDR_ADD;
  6655. }
  6656. spin_unlock_bh(&card->ip_lock);
  6657. @@ -404,11 +405,13 @@ static void qeth_l3_recover_ip(struct qeth_card *card)
  6658. } else
  6659. rc = qeth_l3_register_addr_entry(card, addr);
  6660. - if (!rc) {
  6661. + if (!rc || rc == -EADDRINUSE || rc == -ENETDOWN) {
  6662. + /* keep it in the records */
  6663. addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING;
  6664. if (addr->ref_counter < 1)
  6665. qeth_l3_delete_ip(card, addr);
  6666. } else {
  6667. + /* bad address */
  6668. hash_del(&addr->hnode);
  6669. kfree(addr);
  6670. }
  6671. diff --git drivers/scsi/Kconfig drivers/scsi/Kconfig
  6672. index ba1bfb30a272..aeb73c170b3a 100644
  6673. --- linux-4.14.336/drivers/scsi/Kconfig
  6674. +++ linux-4.14.336/drivers/scsi/Kconfig
  6675. @@ -1394,7 +1394,7 @@ source "drivers/scsi/arm/Kconfig"
  6676. config JAZZ_ESP
  6677. bool "MIPS JAZZ FAS216 SCSI support"
  6678. - depends on MACH_JAZZ && SCSI
  6679. + depends on MACH_JAZZ && SCSI=y
  6680. select SCSI_SPI_ATTRS
  6681. help
  6682. This is the driver for the onboard SCSI host adapter of MIPS Magnum
  6683. diff --git drivers/scsi/fcoe/fcoe_ctlr.c drivers/scsi/fcoe/fcoe_ctlr.c
  6684. index 57826f7bb9f2..1c8fa41aa3ab 100644
  6685. --- linux-4.14.336/drivers/scsi/fcoe/fcoe_ctlr.c
  6686. +++ linux-4.14.336/drivers/scsi/fcoe/fcoe_ctlr.c
  6687. @@ -330,17 +330,16 @@ static void fcoe_ctlr_announce(struct fcoe_ctlr *fip)
  6688. {
  6689. struct fcoe_fcf *sel;
  6690. struct fcoe_fcf *fcf;
  6691. - unsigned long flags;
  6692. mutex_lock(&fip->ctlr_mutex);
  6693. - spin_lock_irqsave(&fip->ctlr_lock, flags);
  6694. + spin_lock_bh(&fip->ctlr_lock);
  6695. kfree_skb(fip->flogi_req);
  6696. fip->flogi_req = NULL;
  6697. list_for_each_entry(fcf, &fip->fcfs, list)
  6698. fcf->flogi_sent = 0;
  6699. - spin_unlock_irqrestore(&fip->ctlr_lock, flags);
  6700. + spin_unlock_bh(&fip->ctlr_lock);
  6701. sel = fip->sel_fcf;
  6702. if (sel && ether_addr_equal(sel->fcf_mac, fip->dest_addr))
  6703. @@ -710,7 +709,6 @@ int fcoe_ctlr_els_send(struct fcoe_ctlr *fip, struct fc_lport *lport,
  6704. {
  6705. struct fc_frame *fp;
  6706. struct fc_frame_header *fh;
  6707. - unsigned long flags;
  6708. u16 old_xid;
  6709. u8 op;
  6710. u8 mac[ETH_ALEN];
  6711. @@ -744,11 +742,11 @@ int fcoe_ctlr_els_send(struct fcoe_ctlr *fip, struct fc_lport *lport,
  6712. op = FIP_DT_FLOGI;
  6713. if (fip->mode == FIP_MODE_VN2VN)
  6714. break;
  6715. - spin_lock_irqsave(&fip->ctlr_lock, flags);
  6716. + spin_lock_bh(&fip->ctlr_lock);
  6717. kfree_skb(fip->flogi_req);
  6718. fip->flogi_req = skb;
  6719. fip->flogi_req_send = 1;
  6720. - spin_unlock_irqrestore(&fip->ctlr_lock, flags);
  6721. + spin_unlock_bh(&fip->ctlr_lock);
  6722. schedule_work(&fip->timer_work);
  6723. return -EINPROGRESS;
  6724. case ELS_FDISC:
  6725. @@ -1725,11 +1723,10 @@ static int fcoe_ctlr_flogi_send_locked(struct fcoe_ctlr *fip)
  6726. static int fcoe_ctlr_flogi_retry(struct fcoe_ctlr *fip)
  6727. {
  6728. struct fcoe_fcf *fcf;
  6729. - unsigned long flags;
  6730. int error;
  6731. mutex_lock(&fip->ctlr_mutex);
  6732. - spin_lock_irqsave(&fip->ctlr_lock, flags);
  6733. + spin_lock_bh(&fip->ctlr_lock);
  6734. LIBFCOE_FIP_DBG(fip, "re-sending FLOGI - reselect\n");
  6735. fcf = fcoe_ctlr_select(fip);
  6736. if (!fcf || fcf->flogi_sent) {
  6737. @@ -1740,7 +1737,7 @@ static int fcoe_ctlr_flogi_retry(struct fcoe_ctlr *fip)
  6738. fcoe_ctlr_solicit(fip, NULL);
  6739. error = fcoe_ctlr_flogi_send_locked(fip);
  6740. }
  6741. - spin_unlock_irqrestore(&fip->ctlr_lock, flags);
  6742. + spin_unlock_bh(&fip->ctlr_lock);
  6743. mutex_unlock(&fip->ctlr_mutex);
  6744. return error;
  6745. }
  6746. @@ -1757,9 +1754,8 @@ static int fcoe_ctlr_flogi_retry(struct fcoe_ctlr *fip)
  6747. static void fcoe_ctlr_flogi_send(struct fcoe_ctlr *fip)
  6748. {
  6749. struct fcoe_fcf *fcf;
  6750. - unsigned long flags;
  6751. - spin_lock_irqsave(&fip->ctlr_lock, flags);
  6752. + spin_lock_bh(&fip->ctlr_lock);
  6753. fcf = fip->sel_fcf;
  6754. if (!fcf || !fip->flogi_req_send)
  6755. goto unlock;
  6756. @@ -1786,7 +1782,7 @@ static void fcoe_ctlr_flogi_send(struct fcoe_ctlr *fip)
  6757. } else /* XXX */
  6758. LIBFCOE_FIP_DBG(fip, "No FCF selected - defer send\n");
  6759. unlock:
  6760. - spin_unlock_irqrestore(&fip->ctlr_lock, flags);
  6761. + spin_unlock_bh(&fip->ctlr_lock);
  6762. }
  6763. /**
  6764. diff --git drivers/scsi/isci/request.c drivers/scsi/isci/request.c
  6765. index 2f151708b59a..13ecf554762e 100644
  6766. --- linux-4.14.336/drivers/scsi/isci/request.c
  6767. +++ linux-4.14.336/drivers/scsi/isci/request.c
  6768. @@ -3398,7 +3398,7 @@ static enum sci_status isci_io_request_build(struct isci_host *ihost,
  6769. return SCI_FAILURE;
  6770. }
  6771. - return SCI_SUCCESS;
  6772. + return status;
  6773. }
  6774. static struct isci_request *isci_request_from_tag(struct isci_host *ihost, u16 tag)
  6775. diff --git drivers/scsi/libfc/fc_fcp.c drivers/scsi/libfc/fc_fcp.c
  6776. index 772c35a5c49e..72ceffc58112 100644
  6777. --- linux-4.14.336/drivers/scsi/libfc/fc_fcp.c
  6778. +++ linux-4.14.336/drivers/scsi/libfc/fc_fcp.c
  6779. @@ -283,6 +283,11 @@ static int fc_fcp_send_abort(struct fc_fcp_pkt *fsp)
  6780. if (!fsp->seq_ptr)
  6781. return -EINVAL;
  6782. + if (fsp->state & FC_SRB_ABORT_PENDING) {
  6783. + FC_FCP_DBG(fsp, "abort already pending\n");
  6784. + return -EBUSY;
  6785. + }
  6786. +
  6787. per_cpu_ptr(fsp->lp->stats, get_cpu())->FcpPktAborts++;
  6788. put_cpu();
  6789. @@ -1693,7 +1698,7 @@ static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
  6790. if (fsp->recov_retry++ < FC_MAX_RECOV_RETRY)
  6791. fc_fcp_rec(fsp);
  6792. else
  6793. - fc_fcp_recovery(fsp, FC_ERROR);
  6794. + fc_fcp_recovery(fsp, FC_TIMED_OUT);
  6795. break;
  6796. }
  6797. fc_fcp_unlock_pkt(fsp);
  6798. @@ -1711,11 +1716,12 @@ static void fc_fcp_recovery(struct fc_fcp_pkt *fsp, u8 code)
  6799. fsp->status_code = code;
  6800. fsp->cdb_status = 0;
  6801. fsp->io_status = 0;
  6802. - /*
  6803. - * if this fails then we let the scsi command timer fire and
  6804. - * scsi-ml escalate.
  6805. - */
  6806. - fc_fcp_send_abort(fsp);
  6807. + if (!fsp->cmd)
  6808. + /*
  6809. + * Only abort non-scsi commands; otherwise let the
  6810. + * scsi command timer fire and scsi-ml escalate.
  6811. + */
  6812. + fc_fcp_send_abort(fsp);
  6813. }
  6814. /**
  6815. diff --git drivers/scsi/lpfc/lpfc.h drivers/scsi/lpfc/lpfc.h
  6816. index 5fc41aa53ceb..97a2f6c6337c 100644
  6817. --- linux-4.14.336/drivers/scsi/lpfc/lpfc.h
  6818. +++ linux-4.14.336/drivers/scsi/lpfc/lpfc.h
  6819. @@ -31,6 +31,7 @@
  6820. struct lpfc_sli2_slim;
  6821. #define ELX_MODEL_NAME_SIZE 80
  6822. +#define ELX_FW_NAME_SIZE 84
  6823. #define LPFC_PCI_DEV_LP 0x1
  6824. #define LPFC_PCI_DEV_OC 0x2
  6825. diff --git drivers/scsi/lpfc/lpfc_init.c drivers/scsi/lpfc/lpfc_init.c
  6826. index 3e9574eede20..0f954853ccad 100644
  6827. --- linux-4.14.336/drivers/scsi/lpfc/lpfc_init.c
  6828. +++ linux-4.14.336/drivers/scsi/lpfc/lpfc_init.c
  6829. @@ -11086,7 +11086,7 @@ out:
  6830. int
  6831. lpfc_sli4_request_firmware_update(struct lpfc_hba *phba, uint8_t fw_upgrade)
  6832. {
  6833. - uint8_t file_name[ELX_MODEL_NAME_SIZE];
  6834. + char file_name[ELX_FW_NAME_SIZE] = {0};
  6835. int ret;
  6836. const struct firmware *fw;
  6837. @@ -11095,7 +11095,7 @@ lpfc_sli4_request_firmware_update(struct lpfc_hba *phba, uint8_t fw_upgrade)
  6838. LPFC_SLI_INTF_IF_TYPE_2)
  6839. return -EPERM;
  6840. - snprintf(file_name, ELX_MODEL_NAME_SIZE, "%s.grp", phba->ModelName);
  6841. + scnprintf(file_name, sizeof(file_name), "%s.grp", phba->ModelName);
  6842. if (fw_upgrade == INT_FW_UPGRADE) {
  6843. ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
  6844. diff --git drivers/spi/spi-ppc4xx.c drivers/spi/spi-ppc4xx.c
  6845. index 967d94844b30..58765a62fc15 100644
  6846. --- linux-4.14.336/drivers/spi/spi-ppc4xx.c
  6847. +++ linux-4.14.336/drivers/spi/spi-ppc4xx.c
  6848. @@ -173,10 +173,8 @@ static int spi_ppc4xx_setupxfer(struct spi_device *spi, struct spi_transfer *t)
  6849. int scr;
  6850. u8 cdm = 0;
  6851. u32 speed;
  6852. - u8 bits_per_word;
  6853. /* Start with the generic configuration for this device. */
  6854. - bits_per_word = spi->bits_per_word;
  6855. speed = spi->max_speed_hz;
  6856. /*
  6857. @@ -184,9 +182,6 @@ static int spi_ppc4xx_setupxfer(struct spi_device *spi, struct spi_transfer *t)
  6858. * the transfer to overwrite the generic configuration with zeros.
  6859. */
  6860. if (t) {
  6861. - if (t->bits_per_word)
  6862. - bits_per_word = t->bits_per_word;
  6863. -
  6864. if (t->speed_hz)
  6865. speed = min(t->speed_hz, spi->max_speed_hz);
  6866. }
  6867. diff --git drivers/staging/iio/impedance-analyzer/ad5933.c drivers/staging/iio/impedance-analyzer/ad5933.c
  6868. index 6d31001d1825..344053df0383 100644
  6869. --- linux-4.14.336/drivers/staging/iio/impedance-analyzer/ad5933.c
  6870. +++ linux-4.14.336/drivers/staging/iio/impedance-analyzer/ad5933.c
  6871. @@ -658,7 +658,7 @@ static void ad5933_work(struct work_struct *work)
  6872. struct ad5933_state, work.work);
  6873. struct iio_dev *indio_dev = i2c_get_clientdata(st->client);
  6874. __be16 buf[2];
  6875. - int val[2];
  6876. + u16 val[2];
  6877. unsigned char status;
  6878. int ret;
  6879. diff --git drivers/target/target_core_device.c drivers/target/target_core_device.c
  6880. index 907b06056f02..ccefa4eb9f1f 100644
  6881. --- linux-4.14.336/drivers/target/target_core_device.c
  6882. +++ linux-4.14.336/drivers/target/target_core_device.c
  6883. @@ -164,7 +164,6 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u64 unpacked_lun)
  6884. struct se_session *se_sess = se_cmd->se_sess;
  6885. struct se_node_acl *nacl = se_sess->se_node_acl;
  6886. struct se_tmr_req *se_tmr = se_cmd->se_tmr_req;
  6887. - unsigned long flags;
  6888. rcu_read_lock();
  6889. deve = target_nacl_find_deve(nacl, unpacked_lun);
  6890. @@ -195,10 +194,6 @@ out_unlock:
  6891. se_cmd->se_dev = rcu_dereference_raw(se_lun->lun_se_dev);
  6892. se_tmr->tmr_dev = rcu_dereference_raw(se_lun->lun_se_dev);
  6893. - spin_lock_irqsave(&se_tmr->tmr_dev->se_tmr_lock, flags);
  6894. - list_add_tail(&se_tmr->tmr_list, &se_tmr->tmr_dev->dev_tmr_list);
  6895. - spin_unlock_irqrestore(&se_tmr->tmr_dev->se_tmr_lock, flags);
  6896. -
  6897. return 0;
  6898. }
  6899. EXPORT_SYMBOL(transport_lookup_tmr_lun);
  6900. diff --git drivers/target/target_core_transport.c drivers/target/target_core_transport.c
  6901. index c20997bf314e..41ebdd629b9d 100644
  6902. --- linux-4.14.336/drivers/target/target_core_transport.c
  6903. +++ linux-4.14.336/drivers/target/target_core_transport.c
  6904. @@ -3424,6 +3424,10 @@ int transport_generic_handle_tmr(
  6905. unsigned long flags;
  6906. bool aborted = false;
  6907. + spin_lock_irqsave(&cmd->se_dev->se_tmr_lock, flags);
  6908. + list_add_tail(&cmd->se_tmr_req->tmr_list, &cmd->se_dev->dev_tmr_list);
  6909. + spin_unlock_irqrestore(&cmd->se_dev->se_tmr_lock, flags);
  6910. +
  6911. spin_lock_irqsave(&cmd->t_state_lock, flags);
  6912. if (cmd->transport_state & CMD_T_ABORTED) {
  6913. aborted = true;
  6914. diff --git drivers/tty/serial/imx.c drivers/tty/serial/imx.c
  6915. index 7fccf69931c5..6cfa6a908336 100644
  6916. --- linux-4.14.336/drivers/tty/serial/imx.c
  6917. +++ linux-4.14.336/drivers/tty/serial/imx.c
  6918. @@ -2215,7 +2215,7 @@ static int serial_imx_probe(struct platform_device *pdev)
  6919. /* For register access, we only need to enable the ipg clock. */
  6920. ret = clk_prepare_enable(sport->clk_ipg);
  6921. if (ret) {
  6922. - dev_err(&pdev->dev, "failed to enable per clk: %d\n", ret);
  6923. + dev_err(&pdev->dev, "failed to enable ipg clk: %d\n", ret);
  6924. return ret;
  6925. }
  6926. diff --git drivers/tty/serial/sc16is7xx.c drivers/tty/serial/sc16is7xx.c
  6927. index 73280d400eb2..3afaab69f0e2 100644
  6928. --- linux-4.14.336/drivers/tty/serial/sc16is7xx.c
  6929. +++ linux-4.14.336/drivers/tty/serial/sc16is7xx.c
  6930. @@ -29,6 +29,7 @@
  6931. #include <linux/tty_flip.h>
  6932. #include <linux/spi/spi.h>
  6933. #include <linux/uaccess.h>
  6934. +#include <linux/units.h>
  6935. #include <uapi/linux/sched/types.h>
  6936. #define SC16IS7XX_NAME "sc16is7xx"
  6937. @@ -1401,9 +1402,12 @@ static int sc16is7xx_spi_probe(struct spi_device *spi)
  6938. /* Setup SPI bus */
  6939. spi->bits_per_word = 8;
  6940. - /* only supports mode 0 on SC16IS762 */
  6941. + /* For all variants, only mode 0 is supported */
  6942. + if ((spi->mode & SPI_MODE_X_MASK) != SPI_MODE_0)
  6943. + return dev_err_probe(&spi->dev, -EINVAL, "Unsupported SPI mode\n");
  6944. +
  6945. spi->mode = spi->mode ? : SPI_MODE_0;
  6946. - spi->max_speed_hz = spi->max_speed_hz ? : 15000000;
  6947. + spi->max_speed_hz = spi->max_speed_hz ? : 4 * HZ_PER_MHZ;
  6948. ret = spi_setup(spi);
  6949. if (ret)
  6950. return ret;
  6951. diff --git drivers/uio/uio.c drivers/uio/uio.c
  6952. index be33a5ce3d8e..3ebea6388220 100644
  6953. --- linux-4.14.336/drivers/uio/uio.c
  6954. +++ linux-4.14.336/drivers/uio/uio.c
  6955. @@ -465,13 +465,13 @@ static int uio_open(struct inode *inode, struct file *filep)
  6956. mutex_lock(&minor_lock);
  6957. idev = idr_find(&uio_idr, iminor(inode));
  6958. - mutex_unlock(&minor_lock);
  6959. if (!idev) {
  6960. ret = -ENODEV;
  6961. + mutex_unlock(&minor_lock);
  6962. goto out;
  6963. }
  6964. -
  6965. get_device(&idev->dev);
  6966. + mutex_unlock(&minor_lock);
  6967. if (!try_module_get(idev->owner)) {
  6968. ret = -ENODEV;
  6969. @@ -1020,9 +1020,8 @@ void uio_unregister_device(struct uio_info *info)
  6970. idev->info = NULL;
  6971. mutex_unlock(&idev->info_lock);
  6972. - device_unregister(&idev->dev);
  6973. -
  6974. uio_free_minor(minor);
  6975. + device_unregister(&idev->dev);
  6976. return;
  6977. }
  6978. diff --git drivers/usb/chipidea/core.c drivers/usb/chipidea/core.c
  6979. index 4cacb91c4729..a4880b137f1b 100644
  6980. --- linux-4.14.336/drivers/usb/chipidea/core.c
  6981. +++ linux-4.14.336/drivers/usb/chipidea/core.c
  6982. @@ -542,6 +542,13 @@ static irqreturn_t ci_irq_handler(int irq, void *data)
  6983. u32 otgsc = 0;
  6984. if (ci->in_lpm) {
  6985. + /*
  6986. + * If we already have a wakeup irq pending there,
  6987. + * let's just return to wait resume finished firstly.
  6988. + */
  6989. + if (ci->wakeup_int)
  6990. + return IRQ_HANDLED;
  6991. +
  6992. disable_irq_nosync(irq);
  6993. ci->wakeup_int = true;
  6994. pm_runtime_get(ci->dev);
  6995. diff --git drivers/usb/core/hub.c drivers/usb/core/hub.c
  6996. index 4a0765bca8e7..afe3a46a0d2d 100644
  6997. --- linux-4.14.336/drivers/usb/core/hub.c
  6998. +++ linux-4.14.336/drivers/usb/core/hub.c
  6999. @@ -43,8 +43,8 @@
  7000. #define USB_VENDOR_TEXAS_INSTRUMENTS 0x0451
  7001. #define USB_PRODUCT_TUSB8041_USB3 0x8140
  7002. #define USB_PRODUCT_TUSB8041_USB2 0x8142
  7003. -#define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01
  7004. -#define HUB_QUIRK_DISABLE_AUTOSUSPEND 0x02
  7005. +#define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND BIT(0)
  7006. +#define HUB_QUIRK_DISABLE_AUTOSUSPEND BIT(1)
  7007. /* Protect struct usb_device->state and ->children members
  7008. * Note: Both are also protected by ->dev.sem, except that ->state can
  7009. @@ -2308,17 +2308,25 @@ static int usb_enumerate_device_otg(struct usb_device *udev)
  7010. }
  7011. } else if (desc->bLength == sizeof
  7012. (struct usb_otg_descriptor)) {
  7013. - /* Set a_alt_hnp_support for legacy otg device */
  7014. - err = usb_control_msg(udev,
  7015. - usb_sndctrlpipe(udev, 0),
  7016. - USB_REQ_SET_FEATURE, 0,
  7017. - USB_DEVICE_A_ALT_HNP_SUPPORT,
  7018. - 0, NULL, 0,
  7019. - USB_CTRL_SET_TIMEOUT);
  7020. - if (err < 0)
  7021. - dev_err(&udev->dev,
  7022. - "set a_alt_hnp_support failed: %d\n",
  7023. - err);
  7024. + /*
  7025. + * We are operating on a legacy OTP device
  7026. + * These should be told that they are operating
  7027. + * on the wrong port if we have another port that does
  7028. + * support HNP
  7029. + */
  7030. + if (bus->otg_port != 0) {
  7031. + /* Set a_alt_hnp_support for legacy otg device */
  7032. + err = usb_control_msg(udev,
  7033. + usb_sndctrlpipe(udev, 0),
  7034. + USB_REQ_SET_FEATURE, 0,
  7035. + USB_DEVICE_A_ALT_HNP_SUPPORT,
  7036. + 0, NULL, 0,
  7037. + USB_CTRL_SET_TIMEOUT);
  7038. + if (err < 0)
  7039. + dev_err(&udev->dev,
  7040. + "set a_alt_hnp_support failed: %d\n",
  7041. + err);
  7042. + }
  7043. }
  7044. }
  7045. #endif
  7046. diff --git drivers/usb/dwc3/ep0.c drivers/usb/dwc3/ep0.c
  7047. index 17bc5b958ea0..f3f9fca246b8 100644
  7048. --- linux-4.14.336/drivers/usb/dwc3/ep0.c
  7049. +++ linux-4.14.336/drivers/usb/dwc3/ep0.c
  7050. @@ -246,7 +246,10 @@ static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc)
  7051. struct dwc3_request *req;
  7052. req = next_request(&dep->pending_list);
  7053. - dwc3_gadget_giveback(dep, req, -ECONNRESET);
  7054. + if (!dwc->connected)
  7055. + dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
  7056. + else
  7057. + dwc3_gadget_giveback(dep, req, -ECONNRESET);
  7058. }
  7059. dwc->ep0state = EP0_SETUP_PHASE;
  7060. diff --git drivers/usb/gadget/function/f_mass_storage.c drivers/usb/gadget/function/f_mass_storage.c
  7061. index 6aee3cf50c74..43bceee1d6c7 100644
  7062. --- linux-4.14.336/drivers/usb/gadget/function/f_mass_storage.c
  7063. +++ linux-4.14.336/drivers/usb/gadget/function/f_mass_storage.c
  7064. @@ -576,21 +576,37 @@ static int start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
  7065. static bool start_in_transfer(struct fsg_common *common, struct fsg_buffhd *bh)
  7066. {
  7067. + int rc;
  7068. +
  7069. if (!fsg_is_set(common))
  7070. return false;
  7071. bh->state = BUF_STATE_SENDING;
  7072. - if (start_transfer(common->fsg, common->fsg->bulk_in, bh->inreq))
  7073. + rc = start_transfer(common->fsg, common->fsg->bulk_in, bh->inreq);
  7074. + if (rc) {
  7075. bh->state = BUF_STATE_EMPTY;
  7076. + if (rc == -ESHUTDOWN) {
  7077. + common->running = 0;
  7078. + return false;
  7079. + }
  7080. + }
  7081. return true;
  7082. }
  7083. static bool start_out_transfer(struct fsg_common *common, struct fsg_buffhd *bh)
  7084. {
  7085. + int rc;
  7086. +
  7087. if (!fsg_is_set(common))
  7088. return false;
  7089. bh->state = BUF_STATE_RECEIVING;
  7090. - if (start_transfer(common->fsg, common->fsg->bulk_out, bh->outreq))
  7091. + rc = start_transfer(common->fsg, common->fsg->bulk_out, bh->outreq);
  7092. + if (rc) {
  7093. bh->state = BUF_STATE_FULL;
  7094. + if (rc == -ESHUTDOWN) {
  7095. + common->running = 0;
  7096. + return false;
  7097. + }
  7098. + }
  7099. return true;
  7100. }
  7101. diff --git drivers/usb/gadget/function/f_ncm.c drivers/usb/gadget/function/f_ncm.c
  7102. index 47d1f4e960cb..9a75e4c49976 100644
  7103. --- linux-4.14.336/drivers/usb/gadget/function/f_ncm.c
  7104. +++ linux-4.14.336/drivers/usb/gadget/function/f_ncm.c
  7105. @@ -1370,7 +1370,15 @@ parse_ntb:
  7106. "Parsed NTB with %d frames\n", dgram_counter);
  7107. to_process -= block_len;
  7108. - if (to_process != 0) {
  7109. +
  7110. + /*
  7111. + * Windows NCM driver avoids USB ZLPs by adding a 1-byte
  7112. + * zero pad as needed.
  7113. + */
  7114. + if (to_process == 1 &&
  7115. + (*(unsigned char *)(ntb_ptr + block_len) == 0x00)) {
  7116. + to_process--;
  7117. + } else if (to_process > 0) {
  7118. ntb_ptr = (unsigned char *)(ntb_ptr + block_len);
  7119. goto parse_ntb;
  7120. }
  7121. diff --git drivers/usb/mon/mon_bin.c drivers/usb/mon/mon_bin.c
  7122. index a6da9b72f46b..21b184d2170a 100644
  7123. --- linux-4.14.336/drivers/usb/mon/mon_bin.c
  7124. +++ linux-4.14.336/drivers/usb/mon/mon_bin.c
  7125. @@ -1246,14 +1246,19 @@ static int mon_bin_vma_fault(struct vm_fault *vmf)
  7126. struct mon_reader_bin *rp = vmf->vma->vm_private_data;
  7127. unsigned long offset, chunk_idx;
  7128. struct page *pageptr;
  7129. + unsigned long flags;
  7130. + spin_lock_irqsave(&rp->b_lock, flags);
  7131. offset = vmf->pgoff << PAGE_SHIFT;
  7132. - if (offset >= rp->b_size)
  7133. + if (offset >= rp->b_size) {
  7134. + spin_unlock_irqrestore(&rp->b_lock, flags);
  7135. return VM_FAULT_SIGBUS;
  7136. + }
  7137. chunk_idx = offset / CHUNK_SIZE;
  7138. pageptr = rp->b_vec[chunk_idx].pg;
  7139. get_page(pageptr);
  7140. vmf->page = pageptr;
  7141. + spin_unlock_irqrestore(&rp->b_lock, flags);
  7142. return 0;
  7143. }
  7144. diff --git drivers/usb/phy/phy-mxs-usb.c drivers/usb/phy/phy-mxs-usb.c
  7145. index 6e462a8d8309..bbfdd926bc70 100644
  7146. --- linux-4.14.336/drivers/usb/phy/phy-mxs-usb.c
  7147. +++ linux-4.14.336/drivers/usb/phy/phy-mxs-usb.c
  7148. @@ -303,8 +303,7 @@ static void __mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool disconnect)
  7149. static bool mxs_phy_is_otg_host(struct mxs_phy *mxs_phy)
  7150. {
  7151. - return IS_ENABLED(CONFIG_USB_OTG) &&
  7152. - mxs_phy->phy.last_event == USB_EVENT_ID;
  7153. + return mxs_phy->phy.last_event == USB_EVENT_ID;
  7154. }
  7155. static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
  7156. diff --git drivers/usb/serial/cp210x.c drivers/usb/serial/cp210x.c
  7157. index df524ce8c050..4158432fc16f 100644
  7158. --- linux-4.14.336/drivers/usb/serial/cp210x.c
  7159. +++ linux-4.14.336/drivers/usb/serial/cp210x.c
  7160. @@ -150,6 +150,7 @@ static const struct usb_device_id id_table[] = {
  7161. { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */
  7162. { USB_DEVICE(0x10C4, 0x8664) }, /* AC-Services CAN-IF */
  7163. { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */
  7164. + { USB_DEVICE(0x10C4, 0x87ED) }, /* IMST USB-Stick for Smart Meter */
  7165. { USB_DEVICE(0x10C4, 0x8856) }, /* CEL EM357 ZigBee USB Stick - LR */
  7166. { USB_DEVICE(0x10C4, 0x8857) }, /* CEL EM357 ZigBee USB Stick */
  7167. { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */
  7168. diff --git drivers/usb/serial/option.c drivers/usb/serial/option.c
  7169. index 902bbe52a1d6..8744d91de155 100644
  7170. --- linux-4.14.336/drivers/usb/serial/option.c
  7171. +++ linux-4.14.336/drivers/usb/serial/option.c
  7172. @@ -2271,6 +2271,7 @@ static const struct usb_device_id option_ids[] = {
  7173. { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0111, 0xff) }, /* Fibocom FM160 (MBIM mode) */
  7174. { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x01a0, 0xff) }, /* Fibocom NL668-AM/NL652-EU (laptop MBIM) */
  7175. { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x01a2, 0xff) }, /* Fibocom FM101-GL (laptop MBIM) */
  7176. + { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x01a3, 0xff) }, /* Fibocom FM101-GL (laptop MBIM) */
  7177. { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x01a4, 0xff), /* Fibocom FM101-GL (laptop MBIM) */
  7178. .driver_info = RSVD(4) },
  7179. { USB_DEVICE_INTERFACE_CLASS(0x2df3, 0x9d03, 0xff) }, /* LongSung M5710 */
  7180. diff --git drivers/usb/serial/qcserial.c drivers/usb/serial/qcserial.c
  7181. index 6ea6cbbebfba..03dc86977e6d 100644
  7182. --- linux-4.14.336/drivers/usb/serial/qcserial.c
  7183. +++ linux-4.14.336/drivers/usb/serial/qcserial.c
  7184. @@ -188,6 +188,8 @@ static const struct usb_device_id id_table[] = {
  7185. {DEVICE_SWI(0x413c, 0x81d0)}, /* Dell Wireless 5819 */
  7186. {DEVICE_SWI(0x413c, 0x81d1)}, /* Dell Wireless 5818 */
  7187. {DEVICE_SWI(0x413c, 0x81d2)}, /* Dell Wireless 5818 */
  7188. + {DEVICE_SWI(0x413c, 0x8217)}, /* Dell Wireless DW5826e */
  7189. + {DEVICE_SWI(0x413c, 0x8218)}, /* Dell Wireless DW5826e QDL */
  7190. /* Huawei devices */
  7191. {DEVICE_HWI(0x03f0, 0x581d)}, /* HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e) */
  7192. diff --git drivers/vhost/vhost.c drivers/vhost/vhost.c
  7193. index 93cdeb516594..03eb2941ff6c 100644
  7194. --- linux-4.14.336/drivers/vhost/vhost.c
  7195. +++ linux-4.14.336/drivers/vhost/vhost.c
  7196. @@ -2483,12 +2483,11 @@ EXPORT_SYMBOL_GPL(vhost_disable_notify);
  7197. /* Create a new message. */
  7198. struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type)
  7199. {
  7200. - struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL);
  7201. + /* Make sure all padding within the structure is initialized. */
  7202. + struct vhost_msg_node *node = kzalloc(sizeof(*node), GFP_KERNEL);
  7203. if (!node)
  7204. return NULL;
  7205. - /* Make sure all padding within the structure is initialized. */
  7206. - memset(&node->msg, 0, sizeof node->msg);
  7207. node->vq = vq;
  7208. node->msg.type = type;
  7209. return node;
  7210. diff --git drivers/video/fbdev/core/fb_defio.c drivers/video/fbdev/core/fb_defio.c
  7211. index 487d5e336e1b..36972138340d 100644
  7212. --- linux-4.14.336/drivers/video/fbdev/core/fb_defio.c
  7213. +++ linux-4.14.336/drivers/video/fbdev/core/fb_defio.c
  7214. @@ -78,11 +78,7 @@ int fb_deferred_io_fsync(struct file *file, loff_t start, loff_t end, int datasy
  7215. return 0;
  7216. inode_lock(inode);
  7217. - /* Kill off the delayed work */
  7218. - cancel_delayed_work_sync(&info->deferred_work);
  7219. -
  7220. - /* Run it immediately */
  7221. - schedule_delayed_work(&info->deferred_work, 0);
  7222. + flush_delayed_work(&info->deferred_work);
  7223. inode_unlock(inode);
  7224. return 0;
  7225. diff --git drivers/video/fbdev/savage/savagefb_driver.c drivers/video/fbdev/savage/savagefb_driver.c
  7226. index c20468362f11..a4f15b9de2b6 100644
  7227. --- linux-4.14.336/drivers/video/fbdev/savage/savagefb_driver.c
  7228. +++ linux-4.14.336/drivers/video/fbdev/savage/savagefb_driver.c
  7229. @@ -869,6 +869,9 @@ static int savagefb_check_var(struct fb_var_screeninfo *var,
  7230. DBG("savagefb_check_var");
  7231. + if (!var->pixclock)
  7232. + return -EINVAL;
  7233. +
  7234. var->transp.offset = 0;
  7235. var->transp.length = 0;
  7236. switch (var->bits_per_pixel) {
  7237. diff --git drivers/video/fbdev/sis/sis_main.c drivers/video/fbdev/sis/sis_main.c
  7238. index e92303823a4b..9575a481eeaf 100644
  7239. --- linux-4.14.336/drivers/video/fbdev/sis/sis_main.c
  7240. +++ linux-4.14.336/drivers/video/fbdev/sis/sis_main.c
  7241. @@ -1437,6 +1437,8 @@ sisfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
  7242. vtotal = var->upper_margin + var->lower_margin + var->vsync_len;
  7243. + if (!var->pixclock)
  7244. + return -EINVAL;
  7245. pixclock = var->pixclock;
  7246. if((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) {
  7247. diff --git drivers/watchdog/bcm2835_wdt.c drivers/watchdog/bcm2835_wdt.c
  7248. index adb699145a07..4e653e71e232 100644
  7249. --- linux-4.14.336/drivers/watchdog/bcm2835_wdt.c
  7250. +++ linux-4.14.336/drivers/watchdog/bcm2835_wdt.c
  7251. @@ -44,6 +44,7 @@
  7252. #define SECS_TO_WDOG_TICKS(x) ((x) << 16)
  7253. #define WDOG_TICKS_TO_SECS(x) ((x) >> 16)
  7254. +#define WDOG_TICKS_TO_MSECS(x) ((x) * 1000 >> 16)
  7255. struct bcm2835_wdt {
  7256. void __iomem *base;
  7257. @@ -140,7 +141,7 @@ static struct watchdog_device bcm2835_wdt_wdd = {
  7258. .info = &bcm2835_wdt_info,
  7259. .ops = &bcm2835_wdt_ops,
  7260. .min_timeout = 1,
  7261. - .max_timeout = WDOG_TICKS_TO_SECS(PM_WDOG_TIME_SET),
  7262. + .max_hw_heartbeat_ms = WDOG_TICKS_TO_MSECS(PM_WDOG_TIME_SET),
  7263. .timeout = WDOG_TICKS_TO_SECS(PM_WDOG_TIME_SET),
  7264. };
  7265. diff --git drivers/watchdog/watchdog_dev.c drivers/watchdog/watchdog_dev.c
  7266. index 337ca3690d62..d26fb9016a9f 100644
  7267. --- linux-4.14.336/drivers/watchdog/watchdog_dev.c
  7268. +++ linux-4.14.336/drivers/watchdog/watchdog_dev.c
  7269. @@ -956,6 +956,7 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
  7270. /* Fill in the data structures */
  7271. cdev_init(&wd_data->cdev, &watchdog_fops);
  7272. + wd_data->cdev.owner = wdd->ops->owner;
  7273. /* Add the device */
  7274. err = cdev_device_add(&wd_data->cdev, &wd_data->dev);
  7275. @@ -970,8 +971,6 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
  7276. return err;
  7277. }
  7278. - wd_data->cdev.owner = wdd->ops->owner;
  7279. -
  7280. /* Record time of most recent heartbeat as 'just before now'. */
  7281. wd_data->last_hw_keepalive = jiffies - 1;
  7282. diff --git fs/aio.c fs/aio.c
  7283. index 2eb3dba5ed16..816f1443626b 100644
  7284. --- linux-4.14.336/fs/aio.c
  7285. +++ linux-4.14.336/fs/aio.c
  7286. @@ -562,6 +562,13 @@ void kiocb_set_cancel_fn(struct kiocb *iocb, kiocb_cancel_fn *cancel)
  7287. struct kioctx *ctx = req->ki_ctx;
  7288. unsigned long flags;
  7289. + /*
  7290. + * kiocb didn't come from aio or is neither a read nor a write, hence
  7291. + * ignore it.
  7292. + */
  7293. + if (!(iocb->ki_flags & IOCB_AIO_RW))
  7294. + return;
  7295. +
  7296. spin_lock_irqsave(&ctx->ctx_lock, flags);
  7297. if (!req->ki_list.next)
  7298. @@ -1601,7 +1608,7 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
  7299. }
  7300. req->common.ki_pos = iocb->aio_offset;
  7301. req->common.ki_complete = aio_complete;
  7302. - req->common.ki_flags = iocb_flags(req->common.ki_filp);
  7303. + req->common.ki_flags = iocb_flags(req->common.ki_filp) | IOCB_AIO_RW;
  7304. req->common.ki_hint = file_write_hint(file);
  7305. if (iocb->aio_flags & IOCB_FLAG_RESFD) {
  7306. diff --git fs/btrfs/dev-replace.c fs/btrfs/dev-replace.c
  7307. index f1e9dd246ab0..3238bd9c0d39 100644
  7308. --- linux-4.14.336/fs/btrfs/dev-replace.c
  7309. +++ linux-4.14.336/fs/btrfs/dev-replace.c
  7310. @@ -426,6 +426,23 @@ leave:
  7311. return ret;
  7312. }
  7313. +static int btrfs_check_replace_dev_names(struct btrfs_ioctl_dev_replace_args *args)
  7314. +{
  7315. + if (args->start.srcdevid == 0) {
  7316. + if (memchr(args->start.srcdev_name, 0,
  7317. + sizeof(args->start.srcdev_name)) == NULL)
  7318. + return -ENAMETOOLONG;
  7319. + } else {
  7320. + args->start.srcdev_name[0] = 0;
  7321. + }
  7322. +
  7323. + if (memchr(args->start.tgtdev_name, 0,
  7324. + sizeof(args->start.tgtdev_name)) == NULL)
  7325. + return -ENAMETOOLONG;
  7326. +
  7327. + return 0;
  7328. +}
  7329. +
  7330. int btrfs_dev_replace_by_ioctl(struct btrfs_fs_info *fs_info,
  7331. struct btrfs_ioctl_dev_replace_args *args)
  7332. {
  7333. @@ -438,10 +455,9 @@ int btrfs_dev_replace_by_ioctl(struct btrfs_fs_info *fs_info,
  7334. default:
  7335. return -EINVAL;
  7336. }
  7337. -
  7338. - if ((args->start.srcdevid == 0 && args->start.srcdev_name[0] == '\0') ||
  7339. - args->start.tgtdev_name[0] == '\0')
  7340. - return -EINVAL;
  7341. + ret = btrfs_check_replace_dev_names(args);
  7342. + if (ret < 0)
  7343. + return ret;
  7344. ret = btrfs_dev_replace_start(fs_info, args->start.tgtdev_name,
  7345. args->start.srcdevid,
  7346. diff --git fs/btrfs/extent-tree.c fs/btrfs/extent-tree.c
  7347. index deb01e59da02..6741710a149e 100644
  7348. --- linux-4.14.336/fs/btrfs/extent-tree.c
  7349. +++ linux-4.14.336/fs/btrfs/extent-tree.c
  7350. @@ -2070,7 +2070,8 @@ static int btrfs_issue_discard(struct block_device *bdev, u64 start, u64 len,
  7351. u64 bytes_left, end;
  7352. u64 aligned_start = ALIGN(start, 1 << 9);
  7353. - if (WARN_ON(start != aligned_start)) {
  7354. + /* Adjust the range to be aligned to 512B sectors if necessary. */
  7355. + if (start != aligned_start) {
  7356. len -= aligned_start - start;
  7357. len = round_down(len, 1 << 9);
  7358. start = aligned_start;
  7359. diff --git fs/btrfs/ioctl.c fs/btrfs/ioctl.c
  7360. index 93b83dc298ac..c8bc8cf5a41f 100644
  7361. --- linux-4.14.336/fs/btrfs/ioctl.c
  7362. +++ linux-4.14.336/fs/btrfs/ioctl.c
  7363. @@ -2668,6 +2668,10 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp)
  7364. kfree(range);
  7365. goto out;
  7366. }
  7367. + if (range->flags & ~BTRFS_DEFRAG_RANGE_FLAGS_SUPP) {
  7368. + ret = -EOPNOTSUPP;
  7369. + goto out;
  7370. + }
  7371. /* compression requires us to start the IO */
  7372. if ((range->flags & BTRFS_DEFRAG_RANGE_COMPRESS)) {
  7373. range->flags |= BTRFS_DEFRAG_RANGE_START_IO;
  7374. diff --git fs/btrfs/send.c fs/btrfs/send.c
  7375. index f2cb7fec7547..fa9797f8501e 100644
  7376. --- linux-4.14.336/fs/btrfs/send.c
  7377. +++ linux-4.14.336/fs/btrfs/send.c
  7378. @@ -6662,7 +6662,7 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
  7379. }
  7380. if (arg->flags & ~BTRFS_SEND_FLAG_MASK) {
  7381. - ret = -EINVAL;
  7382. + ret = -EOPNOTSUPP;
  7383. goto out;
  7384. }
  7385. diff --git fs/cachefiles/bind.c fs/cachefiles/bind.c
  7386. index d9f001078e08..5aa9f4578f3e 100644
  7387. --- linux-4.14.336/fs/cachefiles/bind.c
  7388. +++ linux-4.14.336/fs/cachefiles/bind.c
  7389. @@ -248,6 +248,8 @@ error_open_root:
  7390. kmem_cache_free(cachefiles_object_jar, fsdef);
  7391. error_root_object:
  7392. cachefiles_end_secure(cache, saved_cred);
  7393. + put_cred(cache->cache_cred);
  7394. + cache->cache_cred = NULL;
  7395. pr_err("Failed to register: %d\n", ret);
  7396. return ret;
  7397. }
  7398. @@ -268,6 +270,7 @@ void cachefiles_daemon_unbind(struct cachefiles_cache *cache)
  7399. dput(cache->graveyard);
  7400. mntput(cache->mnt);
  7401. + put_cred(cache->cache_cred);
  7402. kfree(cache->rootdirname);
  7403. kfree(cache->secctx);
  7404. diff --git fs/ceph/caps.c fs/ceph/caps.c
  7405. index e36786f574b8..b84ce90953c6 100644
  7406. --- linux-4.14.336/fs/ceph/caps.c
  7407. +++ linux-4.14.336/fs/ceph/caps.c
  7408. @@ -4026,12 +4026,14 @@ int ceph_encode_dentry_release(void **p, struct dentry *dentry,
  7409. struct inode *dir,
  7410. int mds, int drop, int unless)
  7411. {
  7412. - struct dentry *parent = NULL;
  7413. struct ceph_mds_request_release *rel = *p;
  7414. struct ceph_dentry_info *di = ceph_dentry(dentry);
  7415. int force = 0;
  7416. int ret;
  7417. + /* This shouldn't happen */
  7418. + BUG_ON(!dir);
  7419. +
  7420. /*
  7421. * force an record for the directory caps if we have a dentry lease.
  7422. * this is racy (can't take i_ceph_lock and d_lock together), but it
  7423. @@ -4041,14 +4043,9 @@ int ceph_encode_dentry_release(void **p, struct dentry *dentry,
  7424. spin_lock(&dentry->d_lock);
  7425. if (di->lease_session && di->lease_session->s_mds == mds)
  7426. force = 1;
  7427. - if (!dir) {
  7428. - parent = dget(dentry->d_parent);
  7429. - dir = d_inode(parent);
  7430. - }
  7431. spin_unlock(&dentry->d_lock);
  7432. ret = ceph_encode_inode_release(p, dir, mds, drop, unless, force);
  7433. - dput(parent);
  7434. spin_lock(&dentry->d_lock);
  7435. if (ret && di->lease_session && di->lease_session->s_mds == mds) {
  7436. diff --git fs/compat_ioctl.c fs/compat_ioctl.c
  7437. index f445bc9cdc94..74e8507419d7 100644
  7438. --- linux-4.14.336/fs/compat_ioctl.c
  7439. +++ linux-4.14.336/fs/compat_ioctl.c
  7440. @@ -1546,8 +1546,7 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
  7441. if (!f.file)
  7442. goto out;
  7443. - /* RED-PEN how should LSM module know it's handling 32bit? */
  7444. - error = security_file_ioctl(f.file, cmd, arg);
  7445. + error = security_file_ioctl_compat(f.file, cmd, arg);
  7446. if (error)
  7447. goto out_fput;
  7448. diff --git fs/dcache.c fs/dcache.c
  7449. index 9ac1290ae44f..5a9a773ece54 100644
  7450. --- linux-4.14.336/fs/dcache.c
  7451. +++ linux-4.14.336/fs/dcache.c
  7452. @@ -709,12 +709,12 @@ static inline bool fast_dput(struct dentry *dentry)
  7453. */
  7454. if (unlikely(ret < 0)) {
  7455. spin_lock(&dentry->d_lock);
  7456. - if (dentry->d_lockref.count > 1) {
  7457. - dentry->d_lockref.count--;
  7458. + if (WARN_ON_ONCE(dentry->d_lockref.count <= 0)) {
  7459. spin_unlock(&dentry->d_lock);
  7460. return 1;
  7461. }
  7462. - return 0;
  7463. + dentry->d_lockref.count--;
  7464. + goto locked;
  7465. }
  7466. /*
  7467. @@ -765,6 +765,7 @@ static inline bool fast_dput(struct dentry *dentry)
  7468. * else could have killed it and marked it dead. Either way, we
  7469. * don't need to do anything else.
  7470. */
  7471. +locked:
  7472. if (dentry->d_lockref.count) {
  7473. spin_unlock(&dentry->d_lock);
  7474. return 1;
  7475. diff --git fs/ext4/mballoc.c fs/ext4/mballoc.c
  7476. index 91d1de198fed..64ce26ec9c68 100644
  7477. --- linux-4.14.336/fs/ext4/mballoc.c
  7478. +++ linux-4.14.336/fs/ext4/mballoc.c
  7479. @@ -1817,6 +1817,9 @@ int ext4_mb_try_best_found(struct ext4_allocation_context *ac,
  7480. return err;
  7481. ext4_lock_group(ac->ac_sb, group);
  7482. + if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info)))
  7483. + goto out;
  7484. +
  7485. max = mb_find_extent(e4b, ex.fe_start, ex.fe_len, &ex);
  7486. if (max > 0) {
  7487. @@ -1824,6 +1827,7 @@ int ext4_mb_try_best_found(struct ext4_allocation_context *ac,
  7488. ext4_mb_use_best_found(ac, e4b);
  7489. }
  7490. +out:
  7491. ext4_unlock_group(ac->ac_sb, group);
  7492. ext4_mb_unload_buddy(e4b);
  7493. @@ -1850,12 +1854,10 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac,
  7494. if (err)
  7495. return err;
  7496. - if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) {
  7497. - ext4_mb_unload_buddy(e4b);
  7498. - return 0;
  7499. - }
  7500. -
  7501. ext4_lock_group(ac->ac_sb, group);
  7502. + if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info)))
  7503. + goto out;
  7504. +
  7505. max = mb_find_extent(e4b, ac->ac_g_ex.fe_start,
  7506. ac->ac_g_ex.fe_len, &ex);
  7507. ex.fe_logical = 0xDEADFA11; /* debug value */
  7508. @@ -1888,6 +1890,7 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac,
  7509. ac->ac_b_ex = ex;
  7510. ext4_mb_use_best_found(ac, e4b);
  7511. }
  7512. +out:
  7513. ext4_unlock_group(ac->ac_sb, group);
  7514. ext4_mb_unload_buddy(e4b);
  7515. diff --git fs/ext4/move_extent.c fs/ext4/move_extent.c
  7516. index ef60f2e92da6..a10c560405b2 100644
  7517. --- linux-4.14.336/fs/ext4/move_extent.c
  7518. +++ linux-4.14.336/fs/ext4/move_extent.c
  7519. @@ -628,6 +628,7 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk,
  7520. goto out;
  7521. o_end = o_start + len;
  7522. + *moved_len = 0;
  7523. while (o_start < o_end) {
  7524. struct ext4_extent *ex;
  7525. ext4_lblk_t cur_blk, next_blk;
  7526. @@ -683,7 +684,7 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk,
  7527. */
  7528. ext4_double_up_write_data_sem(orig_inode, donor_inode);
  7529. /* Swap original branches with new branches */
  7530. - move_extent_per_page(o_filp, donor_inode,
  7531. + *moved_len += move_extent_per_page(o_filp, donor_inode,
  7532. orig_page_index, donor_page_index,
  7533. offset_in_page, cur_len,
  7534. unwritten, &ret);
  7535. @@ -693,9 +694,6 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk,
  7536. o_start += cur_len;
  7537. d_start += cur_len;
  7538. }
  7539. - *moved_len = o_start - orig_blk;
  7540. - if (*moved_len > len)
  7541. - *moved_len = len;
  7542. out:
  7543. if (*moved_len) {
  7544. diff --git fs/ext4/resize.c fs/ext4/resize.c
  7545. index f0b27be5892a..47ecf0826899 100644
  7546. --- linux-4.14.336/fs/ext4/resize.c
  7547. +++ linux-4.14.336/fs/ext4/resize.c
  7548. @@ -237,7 +237,7 @@ struct ext4_new_flex_group_data {
  7549. *
  7550. * Returns NULL on failure otherwise address of the allocated structure.
  7551. */
  7552. -static struct ext4_new_flex_group_data *alloc_flex_gd(unsigned long flexbg_size)
  7553. +static struct ext4_new_flex_group_data *alloc_flex_gd(unsigned int flexbg_size)
  7554. {
  7555. struct ext4_new_flex_group_data *flex_gd;
  7556. @@ -290,7 +290,7 @@ static void free_flex_gd(struct ext4_new_flex_group_data *flex_gd)
  7557. */
  7558. static int ext4_alloc_group_tables(struct super_block *sb,
  7559. struct ext4_new_flex_group_data *flex_gd,
  7560. - int flexbg_size)
  7561. + unsigned int flexbg_size)
  7562. {
  7563. struct ext4_new_group_data *group_data = flex_gd->groups;
  7564. ext4_fsblk_t start_blk;
  7565. @@ -383,12 +383,12 @@ next_group:
  7566. group = group_data[0].group;
  7567. printk(KERN_DEBUG "EXT4-fs: adding a flex group with "
  7568. - "%d groups, flexbg size is %d:\n", flex_gd->count,
  7569. + "%u groups, flexbg size is %u:\n", flex_gd->count,
  7570. flexbg_size);
  7571. for (i = 0; i < flex_gd->count; i++) {
  7572. printk(KERN_DEBUG "adding %s group %u: %u "
  7573. - "blocks (%d free)\n",
  7574. + "blocks (%u free)\n",
  7575. ext4_bg_has_super(sb, group + i) ? "normal" :
  7576. "no-super", group + i,
  7577. group_data[i].blocks_count,
  7578. @@ -1558,7 +1558,7 @@ exit:
  7579. static int ext4_setup_next_flex_gd(struct super_block *sb,
  7580. struct ext4_new_flex_group_data *flex_gd,
  7581. ext4_fsblk_t n_blocks_count,
  7582. - unsigned long flexbg_size)
  7583. + unsigned int flexbg_size)
  7584. {
  7585. struct ext4_super_block *es = EXT4_SB(sb)->s_es;
  7586. struct ext4_new_group_data *group_data = flex_gd->groups;
  7587. @@ -1935,8 +1935,9 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count)
  7588. ext4_fsblk_t o_blocks_count;
  7589. ext4_fsblk_t n_blocks_count_retry = 0;
  7590. unsigned long last_update_time = 0;
  7591. - int err = 0, flexbg_size = 1 << sbi->s_log_groups_per_flex;
  7592. + int err = 0;
  7593. int meta_bg;
  7594. + unsigned int flexbg_size = ext4_flex_bg_size(sbi);
  7595. /* See if the device is actually as big as what was requested */
  7596. bh = sb_bread(sb, n_blocks_count - 1);
  7597. diff --git fs/f2fs/namei.c fs/f2fs/namei.c
  7598. index 9fb98fce7096..eb9db586c01d 100644
  7599. --- linux-4.14.336/fs/f2fs/namei.c
  7600. +++ linux-4.14.336/fs/f2fs/namei.c
  7601. @@ -882,7 +882,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
  7602. }
  7603. if (old_dir_entry) {
  7604. - if (old_dir != new_dir && !whiteout) {
  7605. + if (old_dir != new_dir) {
  7606. f2fs_set_link(old_inode, old_dir_entry,
  7607. old_dir_page, new_dir);
  7608. } else {
  7609. diff --git fs/f2fs/xattr.c fs/f2fs/xattr.c
  7610. index b3c64ab0d5a5..f52c01804f81 100644
  7611. --- linux-4.14.336/fs/f2fs/xattr.c
  7612. +++ linux-4.14.336/fs/f2fs/xattr.c
  7613. @@ -695,6 +695,12 @@ static int __f2fs_setxattr(struct inode *inode, int index,
  7614. memcpy(pval, value, size);
  7615. last->e_value_size = cpu_to_le16(size);
  7616. new_hsize += newsize;
  7617. + /*
  7618. + * Explicitly add the null terminator. The unused xattr space
  7619. + * is supposed to always be zeroed, which would make this
  7620. + * unnecessary, but don't depend on that.
  7621. + */
  7622. + *(u32 *)((u8 *)last + newsize) = 0;
  7623. }
  7624. error = write_all_xattrs(inode, new_hsize, base_addr, ipage);
  7625. diff --git fs/fuse/dir.c fs/fuse/dir.c
  7626. index 8e5125904762..bd602b7e8e46 100644
  7627. --- linux-4.14.336/fs/fuse/dir.c
  7628. +++ linux-4.14.336/fs/fuse/dir.c
  7629. @@ -1299,8 +1299,16 @@ retry:
  7630. dput(dentry);
  7631. dentry = alias;
  7632. }
  7633. - if (IS_ERR(dentry))
  7634. + if (IS_ERR(dentry)) {
  7635. + if (!IS_ERR(inode)) {
  7636. + struct fuse_inode *fi = get_fuse_inode(inode);
  7637. +
  7638. + spin_lock(&fc->lock);
  7639. + fi->nlookup--;
  7640. + spin_unlock(&fc->lock);
  7641. + }
  7642. return PTR_ERR(dentry);
  7643. + }
  7644. }
  7645. if (fc->readdirplus_auto)
  7646. set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state);
  7647. diff --git fs/jbd2/journal.c fs/jbd2/journal.c
  7648. index 93a466cf58ba..ee114f0b625a 100644
  7649. --- linux-4.14.336/fs/jbd2/journal.c
  7650. +++ linux-4.14.336/fs/jbd2/journal.c
  7651. @@ -1361,9 +1361,11 @@ static int jbd2_write_superblock(journal_t *journal, int write_flags)
  7652. return -EIO;
  7653. }
  7654. - trace_jbd2_write_superblock(journal, write_flags);
  7655. if (!(journal->j_flags & JBD2_BARRIER))
  7656. write_flags &= ~(REQ_FUA | REQ_PREFLUSH);
  7657. +
  7658. + trace_jbd2_write_superblock(journal, write_flags);
  7659. +
  7660. if (buffer_write_io_error(bh)) {
  7661. /*
  7662. * Oh, dear. A previous attempt to write the journal
  7663. diff --git fs/jfs/jfs_dmap.c fs/jfs/jfs_dmap.c
  7664. index ed7989d7b2ba..6c6efb5a168b 100644
  7665. --- linux-4.14.336/fs/jfs/jfs_dmap.c
  7666. +++ linux-4.14.336/fs/jfs/jfs_dmap.c
  7667. @@ -76,10 +76,10 @@
  7668. */
  7669. static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
  7670. int nblocks);
  7671. -static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval);
  7672. -static int dbBackSplit(dmtree_t * tp, int leafno);
  7673. -static int dbJoin(dmtree_t * tp, int leafno, int newval);
  7674. -static void dbAdjTree(dmtree_t * tp, int leafno, int newval);
  7675. +static void dbSplit(dmtree_t *tp, int leafno, int splitsz, int newval, bool is_ctl);
  7676. +static int dbBackSplit(dmtree_t *tp, int leafno, bool is_ctl);
  7677. +static int dbJoin(dmtree_t *tp, int leafno, int newval, bool is_ctl);
  7678. +static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl);
  7679. static int dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc,
  7680. int level);
  7681. static int dbAllocAny(struct bmap * bmp, s64 nblocks, int l2nb, s64 * results);
  7682. @@ -2184,7 +2184,7 @@ static int dbFreeDmap(struct bmap * bmp, struct dmap * dp, s64 blkno,
  7683. * system.
  7684. */
  7685. if (dp->tree.stree[word] == NOFREE)
  7686. - dbBackSplit((dmtree_t *) & dp->tree, word);
  7687. + dbBackSplit((dmtree_t *)&dp->tree, word, false);
  7688. dbAllocBits(bmp, dp, blkno, nblocks);
  7689. }
  7690. @@ -2270,7 +2270,7 @@ static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
  7691. * the binary system of the leaves if need be.
  7692. */
  7693. dbSplit(tp, word, BUDMIN,
  7694. - dbMaxBud((u8 *) & dp->wmap[word]));
  7695. + dbMaxBud((u8 *)&dp->wmap[word]), false);
  7696. word += 1;
  7697. } else {
  7698. @@ -2310,7 +2310,7 @@ static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
  7699. * system of the leaves to reflect the current
  7700. * allocation (size).
  7701. */
  7702. - dbSplit(tp, word, size, NOFREE);
  7703. + dbSplit(tp, word, size, NOFREE, false);
  7704. /* get the number of dmap words handled */
  7705. nw = BUDSIZE(size, BUDMIN);
  7706. @@ -2417,7 +2417,7 @@ static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
  7707. /* update the leaf for this dmap word.
  7708. */
  7709. rc = dbJoin(tp, word,
  7710. - dbMaxBud((u8 *) & dp->wmap[word]));
  7711. + dbMaxBud((u8 *)&dp->wmap[word]), false);
  7712. if (rc)
  7713. return rc;
  7714. @@ -2450,7 +2450,7 @@ static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
  7715. /* update the leaf.
  7716. */
  7717. - rc = dbJoin(tp, word, size);
  7718. + rc = dbJoin(tp, word, size, false);
  7719. if (rc)
  7720. return rc;
  7721. @@ -2602,14 +2602,14 @@ dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, int level)
  7722. * that it is at the front of a binary buddy system.
  7723. */
  7724. if (oldval == NOFREE) {
  7725. - rc = dbBackSplit((dmtree_t *) dcp, leafno);
  7726. + rc = dbBackSplit((dmtree_t *)dcp, leafno, true);
  7727. if (rc)
  7728. return rc;
  7729. oldval = dcp->stree[ti];
  7730. }
  7731. - dbSplit((dmtree_t *) dcp, leafno, dcp->budmin, newval);
  7732. + dbSplit((dmtree_t *) dcp, leafno, dcp->budmin, newval, true);
  7733. } else {
  7734. - rc = dbJoin((dmtree_t *) dcp, leafno, newval);
  7735. + rc = dbJoin((dmtree_t *) dcp, leafno, newval, true);
  7736. if (rc)
  7737. return rc;
  7738. }
  7739. @@ -2638,7 +2638,7 @@ dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, int level)
  7740. */
  7741. if (alloc) {
  7742. dbJoin((dmtree_t *) dcp, leafno,
  7743. - oldval);
  7744. + oldval, true);
  7745. } else {
  7746. /* the dbJoin() above might have
  7747. * caused a larger binary buddy system
  7748. @@ -2648,9 +2648,9 @@ dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, int level)
  7749. */
  7750. if (dcp->stree[ti] == NOFREE)
  7751. dbBackSplit((dmtree_t *)
  7752. - dcp, leafno);
  7753. + dcp, leafno, true);
  7754. dbSplit((dmtree_t *) dcp, leafno,
  7755. - dcp->budmin, oldval);
  7756. + dcp->budmin, oldval, true);
  7757. }
  7758. /* release the buffer and return the error.
  7759. @@ -2698,7 +2698,7 @@ dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, int level)
  7760. *
  7761. * serialization: IREAD_LOCK(ipbmap) or IWRITE_LOCK(ipbmap) held on entry/exit;
  7762. */
  7763. -static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval)
  7764. +static void dbSplit(dmtree_t *tp, int leafno, int splitsz, int newval, bool is_ctl)
  7765. {
  7766. int budsz;
  7767. int cursz;
  7768. @@ -2720,7 +2720,7 @@ static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval)
  7769. while (cursz >= splitsz) {
  7770. /* update the buddy's leaf with its new value.
  7771. */
  7772. - dbAdjTree(tp, leafno ^ budsz, cursz);
  7773. + dbAdjTree(tp, leafno ^ budsz, cursz, is_ctl);
  7774. /* on to the next size and buddy.
  7775. */
  7776. @@ -2732,7 +2732,7 @@ static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval)
  7777. /* adjust the dmap tree to reflect the specified leaf's new
  7778. * value.
  7779. */
  7780. - dbAdjTree(tp, leafno, newval);
  7781. + dbAdjTree(tp, leafno, newval, is_ctl);
  7782. }
  7783. @@ -2763,7 +2763,7 @@ static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval)
  7784. *
  7785. * serialization: IREAD_LOCK(ipbmap) or IWRITE_LOCK(ipbmap) held on entry/exit;
  7786. */
  7787. -static int dbBackSplit(dmtree_t * tp, int leafno)
  7788. +static int dbBackSplit(dmtree_t *tp, int leafno, bool is_ctl)
  7789. {
  7790. int budsz, bud, w, bsz, size;
  7791. int cursz;
  7792. @@ -2814,7 +2814,7 @@ static int dbBackSplit(dmtree_t * tp, int leafno)
  7793. * system in two.
  7794. */
  7795. cursz = leaf[bud] - 1;
  7796. - dbSplit(tp, bud, cursz, cursz);
  7797. + dbSplit(tp, bud, cursz, cursz, is_ctl);
  7798. break;
  7799. }
  7800. }
  7801. @@ -2842,7 +2842,7 @@ static int dbBackSplit(dmtree_t * tp, int leafno)
  7802. *
  7803. * RETURN VALUES: none
  7804. */
  7805. -static int dbJoin(dmtree_t * tp, int leafno, int newval)
  7806. +static int dbJoin(dmtree_t *tp, int leafno, int newval, bool is_ctl)
  7807. {
  7808. int budsz, buddy;
  7809. s8 *leaf;
  7810. @@ -2897,12 +2897,12 @@ static int dbJoin(dmtree_t * tp, int leafno, int newval)
  7811. if (leafno < buddy) {
  7812. /* leafno is the left buddy.
  7813. */
  7814. - dbAdjTree(tp, buddy, NOFREE);
  7815. + dbAdjTree(tp, buddy, NOFREE, is_ctl);
  7816. } else {
  7817. /* buddy is the left buddy and becomes
  7818. * leafno.
  7819. */
  7820. - dbAdjTree(tp, leafno, NOFREE);
  7821. + dbAdjTree(tp, leafno, NOFREE, is_ctl);
  7822. leafno = buddy;
  7823. }
  7824. @@ -2915,7 +2915,7 @@ static int dbJoin(dmtree_t * tp, int leafno, int newval)
  7825. /* update the leaf value.
  7826. */
  7827. - dbAdjTree(tp, leafno, newval);
  7828. + dbAdjTree(tp, leafno, newval, is_ctl);
  7829. return 0;
  7830. }
  7831. @@ -2936,15 +2936,20 @@ static int dbJoin(dmtree_t * tp, int leafno, int newval)
  7832. *
  7833. * RETURN VALUES: none
  7834. */
  7835. -static void dbAdjTree(dmtree_t * tp, int leafno, int newval)
  7836. +static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl)
  7837. {
  7838. int lp, pp, k;
  7839. - int max;
  7840. + int max, size;
  7841. +
  7842. + size = is_ctl ? CTLTREESIZE : TREESIZE;
  7843. /* pick up the index of the leaf for this leafno.
  7844. */
  7845. lp = leafno + le32_to_cpu(tp->dmt_leafidx);
  7846. + if (WARN_ON_ONCE(lp >= size || lp < 0))
  7847. + return;
  7848. +
  7849. /* is the current value the same as the old value ? if so,
  7850. * there is nothing to do.
  7851. */
  7852. diff --git fs/jfs/jfs_dtree.c fs/jfs/jfs_dtree.c
  7853. index de2bcb36e079..14a16bb906e8 100644
  7854. --- linux-4.14.336/fs/jfs/jfs_dtree.c
  7855. +++ linux-4.14.336/fs/jfs/jfs_dtree.c
  7856. @@ -645,6 +645,11 @@ int dtSearch(struct inode *ip, struct component_name * key, ino_t * data,
  7857. for (base = 0, lim = p->header.nextindex; lim; lim >>= 1) {
  7858. index = base + (lim >> 1);
  7859. + if (stbl[index] < 0) {
  7860. + rc = -EIO;
  7861. + goto out;
  7862. + }
  7863. +
  7864. if (p->header.flag & BT_LEAF) {
  7865. /* uppercase leaf name to compare */
  7866. cmp =
  7867. @@ -1982,7 +1987,7 @@ static int dtSplitRoot(tid_t tid,
  7868. do {
  7869. f = &rp->slot[fsi];
  7870. fsi = f->next;
  7871. - } while (fsi != -1);
  7872. + } while (fsi >= 0);
  7873. f->next = n;
  7874. }
  7875. diff --git fs/jfs/jfs_imap.c fs/jfs/jfs_imap.c
  7876. index 131dce5316ac..5cdcf68a4803 100644
  7877. --- linux-4.14.336/fs/jfs/jfs_imap.c
  7878. +++ linux-4.14.336/fs/jfs/jfs_imap.c
  7879. @@ -2200,6 +2200,9 @@ static int diNewExt(struct inomap * imap, struct iag * iagp, int extno)
  7880. /* get the ag and iag numbers for this iag.
  7881. */
  7882. agno = BLKTOAG(le64_to_cpu(iagp->agstart), sbi);
  7883. + if (agno >= MAXAG || agno < 0)
  7884. + return -EIO;
  7885. +
  7886. iagno = le32_to_cpu(iagp->iagnum);
  7887. /* check if this is the last free extent within the
  7888. diff --git fs/jfs/jfs_mount.c fs/jfs/jfs_mount.c
  7889. index f1a705d15904..97d91c1686b8 100644
  7890. --- linux-4.14.336/fs/jfs/jfs_mount.c
  7891. +++ linux-4.14.336/fs/jfs/jfs_mount.c
  7892. @@ -184,15 +184,15 @@ int jfs_mount(struct super_block *sb)
  7893. }
  7894. jfs_info("jfs_mount: ipimap:0x%p", ipimap);
  7895. - /* map further access of per fileset inodes by the fileset inode */
  7896. - sbi->ipimap = ipimap;
  7897. -
  7898. /* initialize fileset inode allocation map */
  7899. if ((rc = diMount(ipimap))) {
  7900. jfs_err("jfs_mount: diMount failed w/rc = %d", rc);
  7901. goto err_ipimap;
  7902. }
  7903. + /* map further access of per fileset inodes by the fileset inode */
  7904. + sbi->ipimap = ipimap;
  7905. +
  7906. return rc;
  7907. /*
  7908. diff --git fs/nfs/nfs4proc.c fs/nfs/nfs4proc.c
  7909. index ff41d726f758..77c207a0fb81 100644
  7910. --- linux-4.14.336/fs/nfs/nfs4proc.c
  7911. +++ linux-4.14.336/fs/nfs/nfs4proc.c
  7912. @@ -161,6 +161,7 @@ static int nfs4_map_errors(int err)
  7913. case -NFS4ERR_RESOURCE:
  7914. case -NFS4ERR_LAYOUTTRYLATER:
  7915. case -NFS4ERR_RECALLCONFLICT:
  7916. + case -NFS4ERR_RETURNCONFLICT:
  7917. return -EREMOTEIO;
  7918. case -NFS4ERR_WRONGSEC:
  7919. case -NFS4ERR_WRONG_CRED:
  7920. @@ -472,6 +473,7 @@ static int nfs4_do_handle_exception(struct nfs_server *server,
  7921. case -NFS4ERR_GRACE:
  7922. case -NFS4ERR_LAYOUTTRYLATER:
  7923. case -NFS4ERR_RECALLCONFLICT:
  7924. + case -NFS4ERR_RETURNCONFLICT:
  7925. exception->delay = 1;
  7926. return 0;
  7927. @@ -8540,6 +8542,7 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
  7928. status = -EBUSY;
  7929. break;
  7930. case -NFS4ERR_RECALLCONFLICT:
  7931. + case -NFS4ERR_RETURNCONFLICT:
  7932. status = -ERECALLCONFLICT;
  7933. break;
  7934. case -NFS4ERR_DELEG_REVOKED:
  7935. diff --git fs/nfsd/nfs4state.c fs/nfsd/nfs4state.c
  7936. index 2adbf471d107..6720c82ac351 100644
  7937. --- linux-4.14.336/fs/nfsd/nfs4state.c
  7938. +++ linux-4.14.336/fs/nfsd/nfs4state.c
  7939. @@ -6351,12 +6351,16 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
  7940. if (sop->so_is_open_owner || !same_owner_str(sop, owner))
  7941. continue;
  7942. - if (atomic_read(&sop->so_count) != 1) {
  7943. - spin_unlock(&clp->cl_lock);
  7944. - return nfserr_locks_held;
  7945. + /* see if there are still any locks associated with it */
  7946. + lo = lockowner(sop);
  7947. + list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) {
  7948. + if (check_for_locks(stp->st_stid.sc_file, lo)) {
  7949. + status = nfserr_locks_held;
  7950. + spin_unlock(&clp->cl_lock);
  7951. + return status;
  7952. + }
  7953. }
  7954. - lo = lockowner(sop);
  7955. nfs4_get_stateowner(sop);
  7956. break;
  7957. }
  7958. diff --git fs/nilfs2/dat.c fs/nilfs2/dat.c
  7959. index 185db3c3033b..63bd20032fa7 100644
  7960. --- linux-4.14.336/fs/nilfs2/dat.c
  7961. +++ linux-4.14.336/fs/nilfs2/dat.c
  7962. @@ -49,8 +49,21 @@ static inline struct nilfs_dat_info *NILFS_DAT_I(struct inode *dat)
  7963. static int nilfs_dat_prepare_entry(struct inode *dat,
  7964. struct nilfs_palloc_req *req, int create)
  7965. {
  7966. - return nilfs_palloc_get_entry_block(dat, req->pr_entry_nr,
  7967. - create, &req->pr_entry_bh);
  7968. + int ret;
  7969. +
  7970. + ret = nilfs_palloc_get_entry_block(dat, req->pr_entry_nr,
  7971. + create, &req->pr_entry_bh);
  7972. + if (unlikely(ret == -ENOENT)) {
  7973. + nilfs_msg(dat->i_sb, KERN_ERR,
  7974. + "DAT doesn't have a block to manage vblocknr = %llu",
  7975. + (unsigned long long)req->pr_entry_nr);
  7976. + /*
  7977. + * Return internal code -EINVAL to notify bmap layer of
  7978. + * metadata corruption.
  7979. + */
  7980. + ret = -EINVAL;
  7981. + }
  7982. + return ret;
  7983. }
  7984. static void nilfs_dat_commit_entry(struct inode *dat,
  7985. @@ -132,11 +145,7 @@ static void nilfs_dat_commit_free(struct inode *dat,
  7986. int nilfs_dat_prepare_start(struct inode *dat, struct nilfs_palloc_req *req)
  7987. {
  7988. - int ret;
  7989. -
  7990. - ret = nilfs_dat_prepare_entry(dat, req, 0);
  7991. - WARN_ON(ret == -ENOENT);
  7992. - return ret;
  7993. + return nilfs_dat_prepare_entry(dat, req, 0);
  7994. }
  7995. void nilfs_dat_commit_start(struct inode *dat, struct nilfs_palloc_req *req,
  7996. @@ -163,10 +172,8 @@ int nilfs_dat_prepare_end(struct inode *dat, struct nilfs_palloc_req *req)
  7997. int ret;
  7998. ret = nilfs_dat_prepare_entry(dat, req, 0);
  7999. - if (ret < 0) {
  8000. - WARN_ON(ret == -ENOENT);
  8001. + if (ret < 0)
  8002. return ret;
  8003. - }
  8004. kaddr = kmap_atomic(req->pr_entry_bh->b_page);
  8005. entry = nilfs_palloc_block_get_entry(dat, req->pr_entry_nr,
  8006. diff --git fs/nilfs2/file.c fs/nilfs2/file.c
  8007. index c5fa3dee72fc..43501da7ef66 100644
  8008. --- linux-4.14.336/fs/nilfs2/file.c
  8009. +++ linux-4.14.336/fs/nilfs2/file.c
  8010. @@ -114,7 +114,13 @@ static int nilfs_page_mkwrite(struct vm_fault *vmf)
  8011. nilfs_transaction_commit(inode->i_sb);
  8012. mapped:
  8013. - wait_for_stable_page(page);
  8014. + /*
  8015. + * Since checksumming including data blocks is performed to determine
  8016. + * the validity of the log to be written and used for recovery, it is
  8017. + * necessary to wait for writeback to finish here, regardless of the
  8018. + * stable write requirement of the backing device.
  8019. + */
  8020. + wait_on_page_writeback(page);
  8021. out:
  8022. sb_end_pagefault(inode->i_sb);
  8023. return block_page_mkwrite_return(ret);
  8024. diff --git fs/nilfs2/recovery.c fs/nilfs2/recovery.c
  8025. index 5139efed1888..cff597333afe 100644
  8026. --- linux-4.14.336/fs/nilfs2/recovery.c
  8027. +++ linux-4.14.336/fs/nilfs2/recovery.c
  8028. @@ -481,9 +481,10 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
  8029. static int nilfs_recovery_copy_block(struct the_nilfs *nilfs,
  8030. struct nilfs_recovery_block *rb,
  8031. - struct page *page)
  8032. + loff_t pos, struct page *page)
  8033. {
  8034. struct buffer_head *bh_org;
  8035. + size_t from = pos & ~PAGE_MASK;
  8036. void *kaddr;
  8037. bh_org = __bread(nilfs->ns_bdev, rb->blocknr, nilfs->ns_blocksize);
  8038. @@ -491,7 +492,7 @@ static int nilfs_recovery_copy_block(struct the_nilfs *nilfs,
  8039. return -EIO;
  8040. kaddr = kmap_atomic(page);
  8041. - memcpy(kaddr + bh_offset(bh_org), bh_org->b_data, bh_org->b_size);
  8042. + memcpy(kaddr + from, bh_org->b_data, bh_org->b_size);
  8043. kunmap_atomic(kaddr);
  8044. brelse(bh_org);
  8045. return 0;
  8046. @@ -530,7 +531,7 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
  8047. goto failed_inode;
  8048. }
  8049. - err = nilfs_recovery_copy_block(nilfs, rb, page);
  8050. + err = nilfs_recovery_copy_block(nilfs, rb, pos, page);
  8051. if (unlikely(err))
  8052. goto failed_page;
  8053. diff --git fs/nilfs2/segment.c fs/nilfs2/segment.c
  8054. index ca4b1675c147..b9fd60e07701 100644
  8055. --- linux-4.14.336/fs/nilfs2/segment.c
  8056. +++ linux-4.14.336/fs/nilfs2/segment.c
  8057. @@ -1715,7 +1715,6 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci)
  8058. list_for_each_entry(bh, &segbuf->sb_payload_buffers,
  8059. b_assoc_buffers) {
  8060. - set_buffer_async_write(bh);
  8061. if (bh == segbuf->sb_super_root) {
  8062. if (bh->b_page != bd_page) {
  8063. lock_page(bd_page);
  8064. @@ -1726,6 +1725,7 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci)
  8065. }
  8066. break;
  8067. }
  8068. + set_buffer_async_write(bh);
  8069. if (bh->b_page != fs_page) {
  8070. nilfs_begin_page_io(fs_page);
  8071. fs_page = bh->b_page;
  8072. @@ -1811,7 +1811,6 @@ static void nilfs_abort_logs(struct list_head *logs, int err)
  8073. list_for_each_entry(bh, &segbuf->sb_payload_buffers,
  8074. b_assoc_buffers) {
  8075. - clear_buffer_async_write(bh);
  8076. if (bh == segbuf->sb_super_root) {
  8077. clear_buffer_uptodate(bh);
  8078. if (bh->b_page != bd_page) {
  8079. @@ -1820,6 +1819,7 @@ static void nilfs_abort_logs(struct list_head *logs, int err)
  8080. }
  8081. break;
  8082. }
  8083. + clear_buffer_async_write(bh);
  8084. if (bh->b_page != fs_page) {
  8085. nilfs_end_page_io(fs_page, err);
  8086. fs_page = bh->b_page;
  8087. @@ -1907,8 +1907,9 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
  8088. BIT(BH_Delay) | BIT(BH_NILFS_Volatile) |
  8089. BIT(BH_NILFS_Redirected));
  8090. - set_mask_bits(&bh->b_state, clear_bits, set_bits);
  8091. if (bh == segbuf->sb_super_root) {
  8092. + set_buffer_uptodate(bh);
  8093. + clear_buffer_dirty(bh);
  8094. if (bh->b_page != bd_page) {
  8095. end_page_writeback(bd_page);
  8096. bd_page = bh->b_page;
  8097. @@ -1916,6 +1917,7 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
  8098. update_sr = true;
  8099. break;
  8100. }
  8101. + set_mask_bits(&bh->b_state, clear_bits, set_bits);
  8102. if (bh->b_page != fs_page) {
  8103. nilfs_end_page_io(fs_page, 0);
  8104. fs_page = bh->b_page;
  8105. diff --git fs/pstore/ram.c fs/pstore/ram.c
  8106. index dc5a40058c2f..bbd90fef7fcd 100644
  8107. --- linux-4.14.336/fs/pstore/ram.c
  8108. +++ linux-4.14.336/fs/pstore/ram.c
  8109. @@ -586,6 +586,7 @@ static int ramoops_init_przs(const char *name,
  8110. }
  8111. zone_sz = mem_sz / *cnt;
  8112. + zone_sz = ALIGN_DOWN(zone_sz, 2);
  8113. if (!zone_sz) {
  8114. dev_err(dev, "%s zone size == 0\n", name);
  8115. goto fail;
  8116. diff --git fs/pstore/ram_core.c fs/pstore/ram_core.c
  8117. index 58ac4e1a61a3..a323ed939aa8 100644
  8118. --- linux-4.14.336/fs/pstore/ram_core.c
  8119. +++ linux-4.14.336/fs/pstore/ram_core.c
  8120. @@ -190,7 +190,7 @@ static int persistent_ram_init_ecc(struct persistent_ram_zone *prz,
  8121. {
  8122. int numerr;
  8123. struct persistent_ram_buffer *buffer = prz->buffer;
  8124. - int ecc_blocks;
  8125. + size_t ecc_blocks;
  8126. size_t ecc_total;
  8127. if (!ecc_info || !ecc_info->ecc_size)
  8128. diff --git include/crypto/if_alg.h include/crypto/if_alg.h
  8129. index 2ea6a95ca825..f803dc8c45ad 100644
  8130. --- linux-4.14.336/include/crypto/if_alg.h
  8131. +++ linux-4.14.336/include/crypto/if_alg.h
  8132. @@ -146,6 +146,7 @@ struct af_alg_async_req {
  8133. * @enc: Cryptographic operation to be performed when
  8134. * recvmsg is invoked.
  8135. * @len: Length of memory allocated for this data structure.
  8136. + * @inflight: Non-zero when AIO requests are in flight.
  8137. */
  8138. struct af_alg_ctx {
  8139. struct list_head tsgl_list;
  8140. @@ -163,6 +164,8 @@ struct af_alg_ctx {
  8141. bool enc;
  8142. unsigned int len;
  8143. +
  8144. + unsigned int inflight;
  8145. };
  8146. int af_alg_register_type(const struct af_alg_type *type);
  8147. diff --git include/drm/drm_bridge.h include/drm/drm_bridge.h
  8148. index 6522d4cbc9d9..bfbd38c0b609 100644
  8149. --- linux-4.14.336/include/drm/drm_bridge.h
  8150. +++ linux-4.14.336/include/drm/drm_bridge.h
  8151. @@ -161,7 +161,7 @@ struct drm_bridge_funcs {
  8152. * or &drm_encoder_helper_funcs.dpms hook.
  8153. *
  8154. * The bridge must assume that the display pipe (i.e. clocks and timing
  8155. - * singals) feeding it is no longer running when this callback is
  8156. + * signals) feeding it is no longer running when this callback is
  8157. * called.
  8158. *
  8159. * The post_disable callback is optional.
  8160. diff --git include/drm/drm_mipi_dsi.h include/drm/drm_mipi_dsi.h
  8161. index 689f615471ab..a059f1d968b7 100644
  8162. --- linux-4.14.336/include/drm/drm_mipi_dsi.h
  8163. +++ linux-4.14.336/include/drm/drm_mipi_dsi.h
  8164. @@ -163,6 +163,7 @@ struct mipi_dsi_device_info {
  8165. * struct mipi_dsi_device - DSI peripheral device
  8166. * @host: DSI host for this peripheral
  8167. * @dev: driver model device node for this peripheral
  8168. + * @attached: the DSI device has been successfully attached
  8169. * @name: DSI peripheral chip type
  8170. * @channel: virtual channel assigned to the peripheral
  8171. * @format: pixel format for video mode
  8172. @@ -172,6 +173,7 @@ struct mipi_dsi_device_info {
  8173. struct mipi_dsi_device {
  8174. struct mipi_dsi_host *host;
  8175. struct device dev;
  8176. + bool attached;
  8177. char name[DSI_DEV_NAME_SIZE];
  8178. unsigned int channel;
  8179. diff --git include/linux/bpf.h include/linux/bpf.h
  8180. index 3aa05ea79ba1..0d7a61df056b 100644
  8181. --- linux-4.14.336/include/linux/bpf.h
  8182. +++ linux-4.14.336/include/linux/bpf.h
  8183. @@ -38,7 +38,11 @@ struct bpf_map_ops {
  8184. /* funcs called by prog_array and perf_event_array map */
  8185. void *(*map_fd_get_ptr)(struct bpf_map *map, struct file *map_file,
  8186. int fd);
  8187. - void (*map_fd_put_ptr)(void *ptr);
  8188. + /* If need_defer is true, the implementation should guarantee that
  8189. + * the to-be-put element is still alive before the bpf program, which
  8190. + * may manipulate it, exists.
  8191. + */
  8192. + void (*map_fd_put_ptr)(struct bpf_map *map, void *ptr, bool need_defer);
  8193. u32 (*map_gen_lookup)(struct bpf_map *map, struct bpf_insn *insn_buf);
  8194. u32 (*map_fd_sys_lookup_elem)(void *ptr);
  8195. };
  8196. diff --git include/linux/device.h include/linux/device.h
  8197. index 65e06a066b67..27b70b810463 100644
  8198. --- linux-4.14.336/include/linux/device.h
  8199. +++ linux-4.14.336/include/linux/device.h
  8200. @@ -1474,6 +1474,9 @@ do { \
  8201. WARN_ONCE(condition, "%s %s: " format, \
  8202. dev_driver_string(dev), dev_name(dev), ## arg)
  8203. +extern __printf(3, 4)
  8204. +int dev_err_probe(const struct device *dev, int err, const char *fmt, ...);
  8205. +
  8206. /* Create alias, so I can be autoloaded. */
  8207. #define MODULE_ALIAS_CHARDEV(major,minor) \
  8208. MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
  8209. diff --git include/linux/dmaengine.h include/linux/dmaengine.h
  8210. index 8089e28539f1..d5a7d320e05c 100644
  8211. --- linux-4.14.336/include/linux/dmaengine.h
  8212. +++ linux-4.14.336/include/linux/dmaengine.h
  8213. @@ -816,7 +816,8 @@ static inline int dmaengine_slave_config(struct dma_chan *chan,
  8214. static inline bool is_slave_direction(enum dma_transfer_direction direction)
  8215. {
  8216. - return (direction == DMA_MEM_TO_DEV) || (direction == DMA_DEV_TO_MEM);
  8217. + return (direction == DMA_MEM_TO_DEV) || (direction == DMA_DEV_TO_MEM) ||
  8218. + (direction == DMA_DEV_TO_DEV);
  8219. }
  8220. static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_single(
  8221. diff --git include/linux/fs.h include/linux/fs.h
  8222. index ff0a992846a3..bd6072556269 100644
  8223. --- linux-4.14.336/include/linux/fs.h
  8224. +++ linux-4.14.336/include/linux/fs.h
  8225. @@ -296,6 +296,8 @@ enum rw_hint {
  8226. #define IOCB_SYNC (1 << 5)
  8227. #define IOCB_WRITE (1 << 6)
  8228. #define IOCB_NOWAIT (1 << 7)
  8229. +/* kiocb is a read or write operation submitted by fs/aio.c. */
  8230. +#define IOCB_AIO_RW (1 << 23)
  8231. struct kiocb {
  8232. struct file *ki_filp;
  8233. diff --git include/linux/lsm_hooks.h include/linux/lsm_hooks.h
  8234. index 569debc49f3d..28ff40daccff 100644
  8235. --- linux-4.14.336/include/linux/lsm_hooks.h
  8236. +++ linux-4.14.336/include/linux/lsm_hooks.h
  8237. @@ -466,6 +466,12 @@
  8238. * simple integer value. When @arg represents a user space pointer, it
  8239. * should never be used by the security module.
  8240. * Return 0 if permission is granted.
  8241. + * @file_ioctl_compat:
  8242. + * @file contains the file structure.
  8243. + * @cmd contains the operation to perform.
  8244. + * @arg contains the operational arguments.
  8245. + * Check permission for a compat ioctl operation on @file.
  8246. + * Return 0 if permission is granted.
  8247. * @mmap_addr :
  8248. * Check permissions for a mmap operation at @addr.
  8249. * @addr contains virtual address that will be used for the operation.
  8250. @@ -1486,6 +1492,8 @@ union security_list_options {
  8251. void (*file_free_security)(struct file *file);
  8252. int (*file_ioctl)(struct file *file, unsigned int cmd,
  8253. unsigned long arg);
  8254. + int (*file_ioctl_compat)(struct file *file, unsigned int cmd,
  8255. + unsigned long arg);
  8256. int (*mmap_addr)(unsigned long addr);
  8257. int (*mmap_file)(struct file *file, unsigned long reqprot,
  8258. unsigned long prot, unsigned long flags);
  8259. @@ -1764,6 +1772,7 @@ struct security_hook_heads {
  8260. struct list_head file_alloc_security;
  8261. struct list_head file_free_security;
  8262. struct list_head file_ioctl;
  8263. + struct list_head file_ioctl_compat;
  8264. struct list_head mmap_addr;
  8265. struct list_head mmap_file;
  8266. struct list_head file_mprotect;
  8267. diff --git include/linux/pci_ids.h include/linux/pci_ids.h
  8268. index 83f576d45d78..c977e636a1dd 100644
  8269. --- linux-4.14.336/include/linux/pci_ids.h
  8270. +++ linux-4.14.336/include/linux/pci_ids.h
  8271. @@ -2953,6 +2953,7 @@
  8272. #define PCI_DEVICE_ID_INTEL_82443GX_0 0x71a0
  8273. #define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2
  8274. #define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601
  8275. +#define PCI_DEVICE_ID_INTEL_HDA_ARL 0x7728
  8276. #define PCI_DEVICE_ID_INTEL_SCH_LPC 0x8119
  8277. #define PCI_DEVICE_ID_INTEL_SCH_IDE 0x811a
  8278. #define PCI_DEVICE_ID_INTEL_E6XX_CU 0x8183
  8279. diff --git include/linux/security.h include/linux/security.h
  8280. index 1c8968a267c2..cf77cd971795 100644
  8281. --- linux-4.14.336/include/linux/security.h
  8282. +++ linux-4.14.336/include/linux/security.h
  8283. @@ -306,6 +306,8 @@ int security_file_permission(struct file *file, int mask);
  8284. int security_file_alloc(struct file *file);
  8285. void security_file_free(struct file *file);
  8286. int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
  8287. +int security_file_ioctl_compat(struct file *file, unsigned int cmd,
  8288. + unsigned long arg);
  8289. int security_mmap_file(struct file *file, unsigned long prot,
  8290. unsigned long flags);
  8291. int security_mmap_addr(unsigned long addr);
  8292. @@ -827,6 +829,13 @@ static inline int security_file_ioctl(struct file *file, unsigned int cmd,
  8293. return 0;
  8294. }
  8295. +static inline int security_file_ioctl_compat(struct file *file,
  8296. + unsigned int cmd,
  8297. + unsigned long arg)
  8298. +{
  8299. + return 0;
  8300. +}
  8301. +
  8302. static inline int security_mmap_file(struct file *file, unsigned long prot,
  8303. unsigned long flags)
  8304. {
  8305. diff --git include/linux/spi/spi.h include/linux/spi/spi.h
  8306. index a8f6606dd498..5c7741ca3b99 100644
  8307. --- linux-4.14.336/include/linux/spi/spi.h
  8308. +++ linux-4.14.336/include/linux/spi/spi.h
  8309. @@ -153,6 +153,7 @@ struct spi_device {
  8310. #define SPI_MODE_1 (0|SPI_CPHA)
  8311. #define SPI_MODE_2 (SPI_CPOL|0)
  8312. #define SPI_MODE_3 (SPI_CPOL|SPI_CPHA)
  8313. +#define SPI_MODE_X_MASK (SPI_CPOL|SPI_CPHA)
  8314. #define SPI_CS_HIGH 0x04 /* chipselect active high? */
  8315. #define SPI_LSB_FIRST 0x08 /* per-word bits-on-wire */
  8316. #define SPI_3WIRE 0x10 /* SI/SO signals shared */
  8317. diff --git include/linux/units.h include/linux/units.h
  8318. new file mode 100644
  8319. index 000000000000..a0af6d2ef4e5
  8320. --- linux-4.14.336//dev/null
  8321. +++ linux-4.14.336/include/linux/units.h
  8322. @@ -0,0 +1,92 @@
  8323. +/* SPDX-License-Identifier: GPL-2.0 */
  8324. +#ifndef _LINUX_UNITS_H
  8325. +#define _LINUX_UNITS_H
  8326. +
  8327. +#include <linux/kernel.h>
  8328. +
  8329. +#define HZ_PER_KHZ 1000UL
  8330. +#define KHZ_PER_MHZ 1000UL
  8331. +#define HZ_PER_MHZ 1000000UL
  8332. +
  8333. +#define MILLIWATT_PER_WATT 1000UL
  8334. +#define MICROWATT_PER_MILLIWATT 1000UL
  8335. +#define MICROWATT_PER_WATT 1000000UL
  8336. +
  8337. +#define ABSOLUTE_ZERO_MILLICELSIUS -273150
  8338. +
  8339. +static inline long milli_kelvin_to_millicelsius(long t)
  8340. +{
  8341. + return t + ABSOLUTE_ZERO_MILLICELSIUS;
  8342. +}
  8343. +
  8344. +static inline long millicelsius_to_milli_kelvin(long t)
  8345. +{
  8346. + return t - ABSOLUTE_ZERO_MILLICELSIUS;
  8347. +}
  8348. +
  8349. +#define MILLIDEGREE_PER_DEGREE 1000
  8350. +#define MILLIDEGREE_PER_DECIDEGREE 100
  8351. +
  8352. +static inline long kelvin_to_millicelsius(long t)
  8353. +{
  8354. + return milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DEGREE);
  8355. +}
  8356. +
  8357. +static inline long millicelsius_to_kelvin(long t)
  8358. +{
  8359. + t = millicelsius_to_milli_kelvin(t);
  8360. +
  8361. + return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DEGREE);
  8362. +}
  8363. +
  8364. +static inline long deci_kelvin_to_celsius(long t)
  8365. +{
  8366. + t = milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DECIDEGREE);
  8367. +
  8368. + return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DEGREE);
  8369. +}
  8370. +
  8371. +static inline long celsius_to_deci_kelvin(long t)
  8372. +{
  8373. + t = millicelsius_to_milli_kelvin(t * MILLIDEGREE_PER_DEGREE);
  8374. +
  8375. + return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DECIDEGREE);
  8376. +}
  8377. +
  8378. +/**
  8379. + * deci_kelvin_to_millicelsius_with_offset - convert Kelvin to Celsius
  8380. + * @t: temperature value in decidegrees Kelvin
  8381. + * @offset: difference between Kelvin and Celsius in millidegrees
  8382. + *
  8383. + * Return: temperature value in millidegrees Celsius
  8384. + */
  8385. +static inline long deci_kelvin_to_millicelsius_with_offset(long t, long offset)
  8386. +{
  8387. + return t * MILLIDEGREE_PER_DECIDEGREE - offset;
  8388. +}
  8389. +
  8390. +static inline long deci_kelvin_to_millicelsius(long t)
  8391. +{
  8392. + return milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DECIDEGREE);
  8393. +}
  8394. +
  8395. +static inline long millicelsius_to_deci_kelvin(long t)
  8396. +{
  8397. + t = millicelsius_to_milli_kelvin(t);
  8398. +
  8399. + return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DECIDEGREE);
  8400. +}
  8401. +
  8402. +static inline long kelvin_to_celsius(long t)
  8403. +{
  8404. + return t + DIV_ROUND_CLOSEST(ABSOLUTE_ZERO_MILLICELSIUS,
  8405. + MILLIDEGREE_PER_DEGREE);
  8406. +}
  8407. +
  8408. +static inline long celsius_to_kelvin(long t)
  8409. +{
  8410. + return t - DIV_ROUND_CLOSEST(ABSOLUTE_ZERO_MILLICELSIUS,
  8411. + MILLIDEGREE_PER_DEGREE);
  8412. +}
  8413. +
  8414. +#endif /* _LINUX_UNITS_H */
  8415. diff --git include/net/af_unix.h include/net/af_unix.h
  8416. index 7ec1cdb66be8..e514508bdc92 100644
  8417. --- linux-4.14.336/include/net/af_unix.h
  8418. +++ linux-4.14.336/include/net/af_unix.h
  8419. @@ -43,12 +43,6 @@ struct unix_skb_parms {
  8420. #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))
  8421. -#define unix_state_lock(s) spin_lock(&unix_sk(s)->lock)
  8422. -#define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock)
  8423. -#define unix_state_lock_nested(s) \
  8424. - spin_lock_nested(&unix_sk(s)->lock, \
  8425. - SINGLE_DEPTH_NESTING)
  8426. -
  8427. /* The AF_UNIX socket */
  8428. struct unix_sock {
  8429. /* WARNING: sk has to be the first member */
  8430. @@ -72,6 +66,20 @@ static inline struct unix_sock *unix_sk(const struct sock *sk)
  8431. return (struct unix_sock *)sk;
  8432. }
  8433. +#define unix_state_lock(s) spin_lock(&unix_sk(s)->lock)
  8434. +#define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock)
  8435. +enum unix_socket_lock_class {
  8436. + U_LOCK_NORMAL,
  8437. + U_LOCK_SECOND, /* for double locking, see unix_state_double_lock(). */
  8438. + U_LOCK_DIAG, /* used while dumping icons, see sk_diag_dump_icons(). */
  8439. +};
  8440. +
  8441. +static inline void unix_state_lock_nested(struct sock *sk,
  8442. + enum unix_socket_lock_class subclass)
  8443. +{
  8444. + spin_lock_nested(&unix_sk(sk)->lock, subclass);
  8445. +}
  8446. +
  8447. #define peer_wait peer_wq.wait
  8448. long unix_inq_len(struct sock *sk);
  8449. diff --git include/net/bluetooth/hci_core.h include/net/bluetooth/hci_core.h
  8450. index 8f899ad4a754..bac3d79139b2 100644
  8451. --- linux-4.14.336/include/net/bluetooth/hci_core.h
  8452. +++ linux-4.14.336/include/net/bluetooth/hci_core.h
  8453. @@ -647,7 +647,6 @@ void hci_inquiry_cache_flush(struct hci_dev *hdev);
  8454. /* ----- HCI Connections ----- */
  8455. enum {
  8456. HCI_CONN_AUTH_PEND,
  8457. - HCI_CONN_REAUTH_PEND,
  8458. HCI_CONN_ENCRYPT_PEND,
  8459. HCI_CONN_RSWITCH_PEND,
  8460. HCI_CONN_MODE_CHANGE_PEND,
  8461. diff --git include/net/dst_ops.h include/net/dst_ops.h
  8462. index 443863c7b8da..632086b2f644 100644
  8463. --- linux-4.14.336/include/net/dst_ops.h
  8464. +++ linux-4.14.336/include/net/dst_ops.h
  8465. @@ -16,7 +16,7 @@ struct dst_ops {
  8466. unsigned short family;
  8467. unsigned int gc_thresh;
  8468. - int (*gc)(struct dst_ops *ops);
  8469. + void (*gc)(struct dst_ops *ops);
  8470. struct dst_entry * (*check)(struct dst_entry *, __u32 cookie);
  8471. unsigned int (*default_advmss)(const struct dst_entry *);
  8472. unsigned int (*mtu)(const struct dst_entry *);
  8473. @@ -53,9 +53,11 @@ static inline int dst_entries_get_slow(struct dst_ops *dst)
  8474. return percpu_counter_sum_positive(&dst->pcpuc_entries);
  8475. }
  8476. +#define DST_PERCPU_COUNTER_BATCH 32
  8477. static inline void dst_entries_add(struct dst_ops *dst, int val)
  8478. {
  8479. - percpu_counter_add(&dst->pcpuc_entries, val);
  8480. + percpu_counter_add_batch(&dst->pcpuc_entries, val,
  8481. + DST_PERCPU_COUNTER_BATCH);
  8482. }
  8483. static inline int dst_entries_init(struct dst_ops *dst)
  8484. diff --git include/net/llc_pdu.h include/net/llc_pdu.h
  8485. index 49aa79c7b278..581cd37aa98b 100644
  8486. --- linux-4.14.336/include/net/llc_pdu.h
  8487. +++ linux-4.14.336/include/net/llc_pdu.h
  8488. @@ -262,8 +262,7 @@ static inline void llc_pdu_header_init(struct sk_buff *skb, u8 type,
  8489. */
  8490. static inline void llc_pdu_decode_sa(struct sk_buff *skb, u8 *sa)
  8491. {
  8492. - if (skb->protocol == htons(ETH_P_802_2))
  8493. - memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN);
  8494. + memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN);
  8495. }
  8496. /**
  8497. @@ -275,8 +274,7 @@ static inline void llc_pdu_decode_sa(struct sk_buff *skb, u8 *sa)
  8498. */
  8499. static inline void llc_pdu_decode_da(struct sk_buff *skb, u8 *da)
  8500. {
  8501. - if (skb->protocol == htons(ETH_P_802_2))
  8502. - memcpy(da, eth_hdr(skb)->h_dest, ETH_ALEN);
  8503. + memcpy(da, eth_hdr(skb)->h_dest, ETH_ALEN);
  8504. }
  8505. /**
  8506. diff --git include/net/netns/ipv6.h include/net/netns/ipv6.h
  8507. index c004d051c2d3..290ca18589ee 100644
  8508. --- linux-4.14.336/include/net/netns/ipv6.h
  8509. +++ linux-4.14.336/include/net/netns/ipv6.h
  8510. @@ -64,8 +64,8 @@ struct netns_ipv6 {
  8511. struct dst_ops ip6_dst_ops;
  8512. rwlock_t fib6_walker_lock;
  8513. spinlock_t fib6_gc_lock;
  8514. - unsigned int ip6_rt_gc_expire;
  8515. - unsigned long ip6_rt_last_gc;
  8516. + atomic_t ip6_rt_gc_expire;
  8517. + unsigned long ip6_rt_last_gc;
  8518. #ifdef CONFIG_IPV6_MULTIPLE_TABLES
  8519. bool fib6_has_custom_rules;
  8520. struct rt6_info *ip6_prohibit_entry;
  8521. diff --git include/uapi/linux/btrfs.h include/uapi/linux/btrfs.h
  8522. index 86d2a52b4665..ee7a34c237a5 100644
  8523. --- linux-4.14.336/include/uapi/linux/btrfs.h
  8524. +++ linux-4.14.336/include/uapi/linux/btrfs.h
  8525. @@ -522,6 +522,9 @@ struct btrfs_ioctl_clone_range_args {
  8526. */
  8527. #define BTRFS_DEFRAG_RANGE_COMPRESS 1
  8528. #define BTRFS_DEFRAG_RANGE_START_IO 2
  8529. +#define BTRFS_DEFRAG_RANGE_FLAGS_SUPP (BTRFS_DEFRAG_RANGE_COMPRESS | \
  8530. + BTRFS_DEFRAG_RANGE_START_IO)
  8531. +
  8532. struct btrfs_ioctl_defrag_range_args {
  8533. /* start of the defrag operation */
  8534. __u64 start;
  8535. diff --git include/uapi/linux/netfilter/nf_tables.h include/uapi/linux/netfilter/nf_tables.h
  8536. index c7bb18ea4962..835e9f345f35 100644
  8537. --- linux-4.14.336/include/uapi/linux/netfilter/nf_tables.h
  8538. +++ linux-4.14.336/include/uapi/linux/netfilter/nf_tables.h
  8539. @@ -229,9 +229,11 @@ enum nft_rule_attributes {
  8540. /**
  8541. * enum nft_rule_compat_flags - nf_tables rule compat flags
  8542. *
  8543. + * @NFT_RULE_COMPAT_F_UNUSED: unused
  8544. * @NFT_RULE_COMPAT_F_INV: invert the check result
  8545. */
  8546. enum nft_rule_compat_flags {
  8547. + NFT_RULE_COMPAT_F_UNUSED = (1 << 0),
  8548. NFT_RULE_COMPAT_F_INV = (1 << 1),
  8549. NFT_RULE_COMPAT_F_MASK = NFT_RULE_COMPAT_F_INV,
  8550. };
  8551. diff --git kernel/audit.c kernel/audit.c
  8552. index b694a265533f..819bdf0b6e5f 100644
  8553. --- linux-4.14.336/kernel/audit.c
  8554. +++ linux-4.14.336/kernel/audit.c
  8555. @@ -458,15 +458,19 @@ static int audit_set_failure(u32 state)
  8556. * @pid: auditd PID
  8557. * @portid: auditd netlink portid
  8558. * @net: auditd network namespace pointer
  8559. + * @skb: the netlink command from the audit daemon
  8560. + * @ack: netlink ack flag, cleared if ack'd here
  8561. *
  8562. * Description:
  8563. * This function will obtain and drop network namespace references as
  8564. * necessary. Returns zero on success, negative values on failure.
  8565. */
  8566. -static int auditd_set(struct pid *pid, u32 portid, struct net *net)
  8567. +static int auditd_set(struct pid *pid, u32 portid, struct net *net,
  8568. + struct sk_buff *skb, bool *ack)
  8569. {
  8570. unsigned long flags;
  8571. struct auditd_connection *ac_old, *ac_new;
  8572. + struct nlmsghdr *nlh;
  8573. if (!pid || !net)
  8574. return -EINVAL;
  8575. @@ -478,6 +482,13 @@ static int auditd_set(struct pid *pid, u32 portid, struct net *net)
  8576. ac_new->portid = portid;
  8577. ac_new->net = get_net(net);
  8578. + /* send the ack now to avoid a race with the queue backlog */
  8579. + if (*ack) {
  8580. + nlh = nlmsg_hdr(skb);
  8581. + netlink_ack(skb, nlh, 0, NULL);
  8582. + *ack = false;
  8583. + }
  8584. +
  8585. spin_lock_irqsave(&auditd_conn_lock, flags);
  8586. ac_old = rcu_dereference_protected(auditd_conn,
  8587. lockdep_is_held(&auditd_conn_lock));
  8588. @@ -1165,7 +1176,8 @@ static int audit_replace(struct pid *pid)
  8589. return auditd_send_unicast_skb(skb);
  8590. }
  8591. -static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
  8592. +static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
  8593. + bool *ack)
  8594. {
  8595. u32 seq;
  8596. void *data;
  8597. @@ -1257,7 +1269,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
  8598. /* register a new auditd connection */
  8599. err = auditd_set(req_pid,
  8600. NETLINK_CB(skb).portid,
  8601. - sock_net(NETLINK_CB(skb).sk));
  8602. + sock_net(NETLINK_CB(skb).sk),
  8603. + skb, ack);
  8604. if (audit_enabled != AUDIT_OFF)
  8605. audit_log_config_change("audit_pid",
  8606. new_pid,
  8607. @@ -1490,9 +1503,10 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
  8608. * Parse the provided skb and deal with any messages that may be present,
  8609. * malformed skbs are discarded.
  8610. */
  8611. -static void audit_receive(struct sk_buff *skb)
  8612. +static void audit_receive(struct sk_buff *skb)
  8613. {
  8614. struct nlmsghdr *nlh;
  8615. + bool ack;
  8616. /*
  8617. * len MUST be signed for nlmsg_next to be able to dec it below 0
  8618. * if the nlmsg_len was not aligned
  8619. @@ -1505,9 +1519,12 @@ static void audit_receive(struct sk_buff *skb)
  8620. mutex_lock(&audit_cmd_mutex);
  8621. while (nlmsg_ok(nlh, len)) {
  8622. - err = audit_receive_msg(skb, nlh);
  8623. - /* if err or if this message says it wants a response */
  8624. - if (err || (nlh->nlmsg_flags & NLM_F_ACK))
  8625. + ack = nlh->nlmsg_flags & NLM_F_ACK;
  8626. + err = audit_receive_msg(skb, nlh, &ack);
  8627. +
  8628. + /* send an ack if the user asked for one and audit_receive_msg
  8629. + * didn't already do it, or if there was an error. */
  8630. + if (ack || err)
  8631. netlink_ack(skb, nlh, err, NULL);
  8632. nlh = nlmsg_next(nlh, &len);
  8633. diff --git kernel/bpf/arraymap.c kernel/bpf/arraymap.c
  8634. index a8f55ea4146b..3291c856cea9 100644
  8635. --- linux-4.14.336/kernel/bpf/arraymap.c
  8636. +++ linux-4.14.336/kernel/bpf/arraymap.c
  8637. @@ -416,7 +416,7 @@ int bpf_fd_array_map_update_elem(struct bpf_map *map, struct file *map_file,
  8638. old_ptr = xchg(array->ptrs + index, new_ptr);
  8639. if (old_ptr)
  8640. - map->ops->map_fd_put_ptr(old_ptr);
  8641. + map->ops->map_fd_put_ptr(map, old_ptr, true);
  8642. return 0;
  8643. }
  8644. @@ -432,7 +432,7 @@ static int fd_array_map_delete_elem(struct bpf_map *map, void *key)
  8645. old_ptr = xchg(array->ptrs + index, NULL);
  8646. if (old_ptr) {
  8647. - map->ops->map_fd_put_ptr(old_ptr);
  8648. + map->ops->map_fd_put_ptr(map, old_ptr, true);
  8649. return 0;
  8650. } else {
  8651. return -ENOENT;
  8652. @@ -456,8 +456,9 @@ static void *prog_fd_array_get_ptr(struct bpf_map *map,
  8653. return prog;
  8654. }
  8655. -static void prog_fd_array_put_ptr(void *ptr)
  8656. +static void prog_fd_array_put_ptr(struct bpf_map *map, void *ptr, bool need_defer)
  8657. {
  8658. + /* bpf_prog is freed after one RCU or tasks trace grace period */
  8659. bpf_prog_put(ptr);
  8660. }
  8661. @@ -543,8 +544,9 @@ err_out:
  8662. return ee;
  8663. }
  8664. -static void perf_event_fd_array_put_ptr(void *ptr)
  8665. +static void perf_event_fd_array_put_ptr(struct bpf_map *map, void *ptr, bool need_defer)
  8666. {
  8667. + /* bpf_perf_event is freed after one RCU grace period */
  8668. bpf_event_entry_free_rcu(ptr);
  8669. }
  8670. @@ -583,7 +585,7 @@ static void *cgroup_fd_array_get_ptr(struct bpf_map *map,
  8671. return cgroup_get_from_fd(fd);
  8672. }
  8673. -static void cgroup_fd_array_put_ptr(void *ptr)
  8674. +static void cgroup_fd_array_put_ptr(struct bpf_map *map, void *ptr, bool need_defer)
  8675. {
  8676. /* cgroup_put free cgrp after a rcu grace period */
  8677. cgroup_put(ptr);
  8678. diff --git kernel/bpf/hashtab.c kernel/bpf/hashtab.c
  8679. index ecc58137525b..db2c3e019daf 100644
  8680. --- linux-4.14.336/kernel/bpf/hashtab.c
  8681. +++ linux-4.14.336/kernel/bpf/hashtab.c
  8682. @@ -655,7 +655,7 @@ static void htab_put_fd_value(struct bpf_htab *htab, struct htab_elem *l)
  8683. if (map->ops->map_fd_put_ptr) {
  8684. ptr = fd_htab_map_get_ptr(map, l);
  8685. - map->ops->map_fd_put_ptr(ptr);
  8686. + map->ops->map_fd_put_ptr(map, ptr, true);
  8687. }
  8688. }
  8689. @@ -1288,7 +1288,7 @@ static void fd_htab_map_free(struct bpf_map *map)
  8690. hlist_nulls_for_each_entry_safe(l, n, head, hash_node) {
  8691. void *ptr = fd_htab_map_get_ptr(map, l);
  8692. - map->ops->map_fd_put_ptr(ptr);
  8693. + map->ops->map_fd_put_ptr(map, ptr, false);
  8694. }
  8695. }
  8696. @@ -1329,7 +1329,7 @@ int bpf_fd_htab_map_update_elem(struct bpf_map *map, struct file *map_file,
  8697. ret = htab_map_update_elem(map, key, &ptr, map_flags);
  8698. if (ret)
  8699. - map->ops->map_fd_put_ptr(ptr);
  8700. + map->ops->map_fd_put_ptr(map, ptr, false);
  8701. return ret;
  8702. }
  8703. diff --git kernel/bpf/lpm_trie.c kernel/bpf/lpm_trie.c
  8704. index c28c584b734e..ef324c9c1eca 100644
  8705. --- linux-4.14.336/kernel/bpf/lpm_trie.c
  8706. +++ linux-4.14.336/kernel/bpf/lpm_trie.c
  8707. @@ -192,6 +192,9 @@ static void *trie_lookup_elem(struct bpf_map *map, void *_key)
  8708. struct lpm_trie_node *node, *found = NULL;
  8709. struct bpf_lpm_trie_key *key = _key;
  8710. + if (key->prefixlen > trie->max_prefixlen)
  8711. + return NULL;
  8712. +
  8713. /* Start walking the trie from the root node ... */
  8714. for (node = rcu_dereference(trie->root); node;) {
  8715. diff --git kernel/bpf/map_in_map.c kernel/bpf/map_in_map.c
  8716. index c0c494b7647b..1878aace6a5c 100644
  8717. --- linux-4.14.336/kernel/bpf/map_in_map.c
  8718. +++ linux-4.14.336/kernel/bpf/map_in_map.c
  8719. @@ -101,7 +101,7 @@ void *bpf_map_fd_get_ptr(struct bpf_map *map,
  8720. return inner_map;
  8721. }
  8722. -void bpf_map_fd_put_ptr(void *ptr)
  8723. +void bpf_map_fd_put_ptr(struct bpf_map *map, void *ptr, bool need_defer)
  8724. {
  8725. /* ptr->ops->map_free() has to go through one
  8726. * rcu grace period by itself.
  8727. diff --git kernel/bpf/map_in_map.h kernel/bpf/map_in_map.h
  8728. index 6183db9ec08c..1e652a7bf60e 100644
  8729. --- linux-4.14.336/kernel/bpf/map_in_map.h
  8730. +++ linux-4.14.336/kernel/bpf/map_in_map.h
  8731. @@ -18,7 +18,7 @@ bool bpf_map_meta_equal(const struct bpf_map *meta0,
  8732. const struct bpf_map *meta1);
  8733. void *bpf_map_fd_get_ptr(struct bpf_map *map, struct file *map_file,
  8734. int ufd);
  8735. -void bpf_map_fd_put_ptr(void *ptr);
  8736. +void bpf_map_fd_put_ptr(struct bpf_map *map, void *ptr, bool need_defer);
  8737. u32 bpf_map_fd_sys_lookup_elem(void *ptr);
  8738. #endif
  8739. diff --git kernel/debug/kdb/kdb_main.c kernel/debug/kdb/kdb_main.c
  8740. index 15d902daeef6..01a4312ede49 100644
  8741. --- linux-4.14.336/kernel/debug/kdb/kdb_main.c
  8742. +++ linux-4.14.336/kernel/debug/kdb/kdb_main.c
  8743. @@ -399,6 +399,13 @@ int kdb_set(int argc, const char **argv)
  8744. if (argc != 2)
  8745. return KDB_ARGCOUNT;
  8746. + /*
  8747. + * Censor sensitive variables
  8748. + */
  8749. + if (strcmp(argv[1], "PROMPT") == 0 &&
  8750. + !kdb_check_flags(KDB_ENABLE_MEM_READ, kdb_cmd_enabled, false))
  8751. + return KDB_NOPERM;
  8752. +
  8753. /*
  8754. * Check for internal variables
  8755. */
  8756. @@ -1289,14 +1296,9 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
  8757. *(cmd_hist[cmd_head]) = '\0';
  8758. do_full_getstr:
  8759. -#if defined(CONFIG_SMP)
  8760. + /* PROMPT can only be set if we have MEM_READ permission. */
  8761. snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"),
  8762. raw_smp_processor_id());
  8763. -#else
  8764. - snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"));
  8765. -#endif
  8766. - if (defcmd_in_progress)
  8767. - strncat(kdb_prompt_str, "[defcmd]", CMD_BUFLEN);
  8768. /*
  8769. * Fetch command from keyboard
  8770. diff --git kernel/power/swap.c kernel/power/swap.c
  8771. index 8b37085a6690..b62a56de91d6 100644
  8772. --- linux-4.14.336/kernel/power/swap.c
  8773. +++ linux-4.14.336/kernel/power/swap.c
  8774. @@ -595,11 +595,11 @@ static int crc32_threadfn(void *data)
  8775. unsigned i;
  8776. while (1) {
  8777. - wait_event(d->go, atomic_read(&d->ready) ||
  8778. + wait_event(d->go, atomic_read_acquire(&d->ready) ||
  8779. kthread_should_stop());
  8780. if (kthread_should_stop()) {
  8781. d->thr = NULL;
  8782. - atomic_set(&d->stop, 1);
  8783. + atomic_set_release(&d->stop, 1);
  8784. wake_up(&d->done);
  8785. break;
  8786. }
  8787. @@ -608,7 +608,7 @@ static int crc32_threadfn(void *data)
  8788. for (i = 0; i < d->run_threads; i++)
  8789. *d->crc32 = crc32_le(*d->crc32,
  8790. d->unc[i], *d->unc_len[i]);
  8791. - atomic_set(&d->stop, 1);
  8792. + atomic_set_release(&d->stop, 1);
  8793. wake_up(&d->done);
  8794. }
  8795. return 0;
  8796. @@ -638,12 +638,12 @@ static int lzo_compress_threadfn(void *data)
  8797. struct cmp_data *d = data;
  8798. while (1) {
  8799. - wait_event(d->go, atomic_read(&d->ready) ||
  8800. + wait_event(d->go, atomic_read_acquire(&d->ready) ||
  8801. kthread_should_stop());
  8802. if (kthread_should_stop()) {
  8803. d->thr = NULL;
  8804. d->ret = -1;
  8805. - atomic_set(&d->stop, 1);
  8806. + atomic_set_release(&d->stop, 1);
  8807. wake_up(&d->done);
  8808. break;
  8809. }
  8810. @@ -652,7 +652,7 @@ static int lzo_compress_threadfn(void *data)
  8811. d->ret = lzo1x_1_compress(d->unc, d->unc_len,
  8812. d->cmp + LZO_HEADER, &d->cmp_len,
  8813. d->wrk);
  8814. - atomic_set(&d->stop, 1);
  8815. + atomic_set_release(&d->stop, 1);
  8816. wake_up(&d->done);
  8817. }
  8818. return 0;
  8819. @@ -794,7 +794,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
  8820. data[thr].unc_len = off;
  8821. - atomic_set(&data[thr].ready, 1);
  8822. + atomic_set_release(&data[thr].ready, 1);
  8823. wake_up(&data[thr].go);
  8824. }
  8825. @@ -802,12 +802,12 @@ static int save_image_lzo(struct swap_map_handle *handle,
  8826. break;
  8827. crc->run_threads = thr;
  8828. - atomic_set(&crc->ready, 1);
  8829. + atomic_set_release(&crc->ready, 1);
  8830. wake_up(&crc->go);
  8831. for (run_threads = thr, thr = 0; thr < run_threads; thr++) {
  8832. wait_event(data[thr].done,
  8833. - atomic_read(&data[thr].stop));
  8834. + atomic_read_acquire(&data[thr].stop));
  8835. atomic_set(&data[thr].stop, 0);
  8836. ret = data[thr].ret;
  8837. @@ -847,7 +847,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
  8838. }
  8839. }
  8840. - wait_event(crc->done, atomic_read(&crc->stop));
  8841. + wait_event(crc->done, atomic_read_acquire(&crc->stop));
  8842. atomic_set(&crc->stop, 0);
  8843. }
  8844. @@ -1129,12 +1129,12 @@ static int lzo_decompress_threadfn(void *data)
  8845. struct dec_data *d = data;
  8846. while (1) {
  8847. - wait_event(d->go, atomic_read(&d->ready) ||
  8848. + wait_event(d->go, atomic_read_acquire(&d->ready) ||
  8849. kthread_should_stop());
  8850. if (kthread_should_stop()) {
  8851. d->thr = NULL;
  8852. d->ret = -1;
  8853. - atomic_set(&d->stop, 1);
  8854. + atomic_set_release(&d->stop, 1);
  8855. wake_up(&d->done);
  8856. break;
  8857. }
  8858. @@ -1147,7 +1147,7 @@ static int lzo_decompress_threadfn(void *data)
  8859. flush_icache_range((unsigned long)d->unc,
  8860. (unsigned long)d->unc + d->unc_len);
  8861. - atomic_set(&d->stop, 1);
  8862. + atomic_set_release(&d->stop, 1);
  8863. wake_up(&d->done);
  8864. }
  8865. return 0;
  8866. @@ -1338,7 +1338,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
  8867. }
  8868. if (crc->run_threads) {
  8869. - wait_event(crc->done, atomic_read(&crc->stop));
  8870. + wait_event(crc->done, atomic_read_acquire(&crc->stop));
  8871. atomic_set(&crc->stop, 0);
  8872. crc->run_threads = 0;
  8873. }
  8874. @@ -1375,7 +1375,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
  8875. pg = 0;
  8876. }
  8877. - atomic_set(&data[thr].ready, 1);
  8878. + atomic_set_release(&data[thr].ready, 1);
  8879. wake_up(&data[thr].go);
  8880. }
  8881. @@ -1394,7 +1394,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
  8882. for (run_threads = thr, thr = 0; thr < run_threads; thr++) {
  8883. wait_event(data[thr].done,
  8884. - atomic_read(&data[thr].stop));
  8885. + atomic_read_acquire(&data[thr].stop));
  8886. atomic_set(&data[thr].stop, 0);
  8887. ret = data[thr].ret;
  8888. @@ -1429,7 +1429,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
  8889. ret = snapshot_write_next(snapshot);
  8890. if (ret <= 0) {
  8891. crc->run_threads = thr + 1;
  8892. - atomic_set(&crc->ready, 1);
  8893. + atomic_set_release(&crc->ready, 1);
  8894. wake_up(&crc->go);
  8895. goto out_finish;
  8896. }
  8897. @@ -1437,13 +1437,13 @@ static int load_image_lzo(struct swap_map_handle *handle,
  8898. }
  8899. crc->run_threads = thr;
  8900. - atomic_set(&crc->ready, 1);
  8901. + atomic_set_release(&crc->ready, 1);
  8902. wake_up(&crc->go);
  8903. }
  8904. out_finish:
  8905. if (crc->run_threads) {
  8906. - wait_event(crc->done, atomic_read(&crc->stop));
  8907. + wait_event(crc->done, atomic_read_acquire(&crc->stop));
  8908. atomic_set(&crc->stop, 0);
  8909. }
  8910. stop = ktime_get();
  8911. diff --git kernel/sched/membarrier.c kernel/sched/membarrier.c
  8912. index 9bcbacba82a8..d936a130814e 100644
  8913. --- linux-4.14.336/kernel/sched/membarrier.c
  8914. +++ linux-4.14.336/kernel/sched/membarrier.c
  8915. @@ -30,6 +30,8 @@
  8916. (MEMBARRIER_CMD_SHARED | MEMBARRIER_CMD_PRIVATE_EXPEDITED \
  8917. | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED)
  8918. +static DEFINE_MUTEX(membarrier_ipi_mutex);
  8919. +
  8920. static void ipi_mb(void *info)
  8921. {
  8922. smp_mb(); /* IPIs should be serializing but paranoid. */
  8923. @@ -64,6 +66,7 @@ static int membarrier_private_expedited(void)
  8924. fallback = true;
  8925. }
  8926. + mutex_lock(&membarrier_ipi_mutex);
  8927. cpus_read_lock();
  8928. for_each_online_cpu(cpu) {
  8929. struct task_struct *p;
  8930. @@ -102,6 +105,7 @@ static int membarrier_private_expedited(void)
  8931. * rq->curr modification in scheduler.
  8932. */
  8933. smp_mb(); /* exit from system call is not a mb */
  8934. + mutex_unlock(&membarrier_ipi_mutex);
  8935. return 0;
  8936. }
  8937. diff --git kernel/sched/rt.c kernel/sched/rt.c
  8938. index c093bb0f52eb..85cc7ab4f38d 100644
  8939. --- linux-4.14.336/kernel/sched/rt.c
  8940. +++ linux-4.14.336/kernel/sched/rt.c
  8941. @@ -10,7 +10,7 @@
  8942. #include <linux/irq_work.h>
  8943. int sched_rr_timeslice = RR_TIMESLICE;
  8944. -int sysctl_sched_rr_timeslice = (MSEC_PER_SEC / HZ) * RR_TIMESLICE;
  8945. +int sysctl_sched_rr_timeslice = (MSEC_PER_SEC * RR_TIMESLICE) / HZ;
  8946. static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun);
  8947. @@ -2626,9 +2626,6 @@ static int sched_rt_global_constraints(void)
  8948. static int sched_rt_global_validate(void)
  8949. {
  8950. - if (sysctl_sched_rt_period <= 0)
  8951. - return -EINVAL;
  8952. -
  8953. if ((sysctl_sched_rt_runtime != RUNTIME_INF) &&
  8954. (sysctl_sched_rt_runtime > sysctl_sched_rt_period))
  8955. return -EINVAL;
  8956. @@ -2658,7 +2655,7 @@ int sched_rt_handler(struct ctl_table *table, int write,
  8957. old_period = sysctl_sched_rt_period;
  8958. old_runtime = sysctl_sched_rt_runtime;
  8959. - ret = proc_dointvec(table, write, buffer, lenp, ppos);
  8960. + ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
  8961. if (!ret && write) {
  8962. ret = sched_rt_global_validate();
  8963. @@ -2703,6 +2700,9 @@ int sched_rr_handler(struct ctl_table *table, int write,
  8964. sched_rr_timeslice =
  8965. sysctl_sched_rr_timeslice <= 0 ? RR_TIMESLICE :
  8966. msecs_to_jiffies(sysctl_sched_rr_timeslice);
  8967. +
  8968. + if (sysctl_sched_rr_timeslice <= 0)
  8969. + sysctl_sched_rr_timeslice = jiffies_to_msecs(RR_TIMESLICE);
  8970. }
  8971. mutex_unlock(&mutex);
  8972. return ret;
  8973. diff --git kernel/sysctl.c kernel/sysctl.c
  8974. index de4a197570b1..5bee2eb28ff6 100644
  8975. --- linux-4.14.336/kernel/sysctl.c
  8976. +++ linux-4.14.336/kernel/sysctl.c
  8977. @@ -124,6 +124,7 @@ static int zero;
  8978. static int __maybe_unused one = 1;
  8979. static int __maybe_unused two = 2;
  8980. static int __maybe_unused four = 4;
  8981. +static int int_max = INT_MAX;
  8982. static unsigned long zero_ul;
  8983. static unsigned long one_ul = 1;
  8984. static unsigned long long_max = LONG_MAX;
  8985. @@ -460,6 +461,8 @@ static struct ctl_table kern_table[] = {
  8986. .maxlen = sizeof(unsigned int),
  8987. .mode = 0644,
  8988. .proc_handler = sched_rt_handler,
  8989. + .extra1 = &one,
  8990. + .extra2 = &int_max,
  8991. },
  8992. {
  8993. .procname = "sched_rt_runtime_us",
  8994. @@ -467,6 +470,8 @@ static struct ctl_table kern_table[] = {
  8995. .maxlen = sizeof(int),
  8996. .mode = 0644,
  8997. .proc_handler = sched_rt_handler,
  8998. + .extra1 = &neg_one,
  8999. + .extra2 = &int_max,
  9000. },
  9001. {
  9002. .procname = "sched_rr_timeslice_ms",
  9003. diff --git kernel/time/tick-sched.c kernel/time/tick-sched.c
  9004. index 3c7b400512eb..387de1b6dd93 100644
  9005. --- linux-4.14.336/kernel/time/tick-sched.c
  9006. +++ linux-4.14.336/kernel/time/tick-sched.c
  9007. @@ -1278,13 +1278,23 @@ void tick_setup_sched_timer(void)
  9008. void tick_cancel_sched_timer(int cpu)
  9009. {
  9010. struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
  9011. + ktime_t idle_sleeptime, iowait_sleeptime;
  9012. + unsigned long idle_calls, idle_sleeps;
  9013. # ifdef CONFIG_HIGH_RES_TIMERS
  9014. if (ts->sched_timer.base)
  9015. hrtimer_cancel(&ts->sched_timer);
  9016. # endif
  9017. + idle_sleeptime = ts->idle_sleeptime;
  9018. + iowait_sleeptime = ts->iowait_sleeptime;
  9019. + idle_calls = ts->idle_calls;
  9020. + idle_sleeps = ts->idle_sleeps;
  9021. memset(ts, 0, sizeof(*ts));
  9022. + ts->idle_sleeptime = idle_sleeptime;
  9023. + ts->iowait_sleeptime = iowait_sleeptime;
  9024. + ts->idle_calls = idle_calls;
  9025. + ts->idle_sleeps = idle_sleeps;
  9026. }
  9027. #endif
  9028. diff --git kernel/trace/ring_buffer.c kernel/trace/ring_buffer.c
  9029. index 3fc09d765f2a..8c09e8ca1561 100644
  9030. --- linux-4.14.336/kernel/trace/ring_buffer.c
  9031. +++ linux-4.14.336/kernel/trace/ring_buffer.c
  9032. @@ -2776,6 +2776,12 @@ rb_reserve_next_event(struct ring_buffer *buffer,
  9033. int nr_loops = 0;
  9034. u64 diff;
  9035. + /* ring buffer does cmpxchg, make sure it is safe in NMI context */
  9036. + if (!IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG) &&
  9037. + (unlikely(in_nmi()))) {
  9038. + return NULL;
  9039. + }
  9040. +
  9041. rb_start_commit(cpu_buffer);
  9042. #ifdef CONFIG_RING_BUFFER_ALLOW_SWAP
  9043. diff --git kernel/trace/trace.c kernel/trace/trace.c
  9044. index c5fe020336be..755d6146c738 100644
  9045. --- linux-4.14.336/kernel/trace/trace.c
  9046. +++ linux-4.14.336/kernel/trace/trace.c
  9047. @@ -3826,7 +3826,11 @@ static int s_show(struct seq_file *m, void *v)
  9048. iter->leftover = ret;
  9049. } else {
  9050. - print_trace_line(iter);
  9051. + ret = print_trace_line(iter);
  9052. + if (ret == TRACE_TYPE_PARTIAL_LINE) {
  9053. + iter->seq.full = 0;
  9054. + trace_seq_puts(&iter->seq, "[LINE TOO BIG]\n");
  9055. + }
  9056. ret = trace_print_seq(m, &iter->seq);
  9057. /*
  9058. * If we overflow the seq_file buffer, then it will
  9059. diff --git kernel/trace/trace_events_trigger.c kernel/trace/trace_events_trigger.c
  9060. index 40c1a2dd48f0..871ea0fa78bb 100644
  9061. --- linux-4.14.336/kernel/trace/trace_events_trigger.c
  9062. +++ linux-4.14.336/kernel/trace/trace_events_trigger.c
  9063. @@ -1127,8 +1127,10 @@ register_snapshot_trigger(char *glob, struct event_trigger_ops *ops,
  9064. struct event_trigger_data *data,
  9065. struct trace_event_file *file)
  9066. {
  9067. - if (tracing_alloc_snapshot_instance(file->tr) != 0)
  9068. - return 0;
  9069. + int ret = tracing_alloc_snapshot_instance(file->tr);
  9070. +
  9071. + if (ret < 0)
  9072. + return ret;
  9073. return register_trigger(glob, ops, data, file);
  9074. }
  9075. diff --git kernel/trace/trace_output.c kernel/trace/trace_output.c
  9076. index e3ab66e6fd85..3ca9ddfef2b8 100644
  9077. --- linux-4.14.336/kernel/trace/trace_output.c
  9078. +++ linux-4.14.336/kernel/trace/trace_output.c
  9079. @@ -1319,11 +1319,12 @@ static enum print_line_t trace_print_print(struct trace_iterator *iter,
  9080. {
  9081. struct print_entry *field;
  9082. struct trace_seq *s = &iter->seq;
  9083. + int max = iter->ent_size - offsetof(struct print_entry, buf);
  9084. trace_assign_type(field, iter->ent);
  9085. seq_print_ip_sym(s, field->ip, flags);
  9086. - trace_seq_printf(s, ": %s", field->buf);
  9087. + trace_seq_printf(s, ": %.*s", max, field->buf);
  9088. return trace_handle_return(s);
  9089. }
  9090. @@ -1332,10 +1333,11 @@ static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags,
  9091. struct trace_event *event)
  9092. {
  9093. struct print_entry *field;
  9094. + int max = iter->ent_size - offsetof(struct print_entry, buf);
  9095. trace_assign_type(field, iter->ent);
  9096. - trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf);
  9097. + trace_seq_printf(&iter->seq, "# %lx %.*s", field->ip, max, field->buf);
  9098. return trace_handle_return(&iter->seq);
  9099. }
  9100. diff --git mm/memcontrol.c mm/memcontrol.c
  9101. index 22d13c98e274..e6a351e69ac3 100644
  9102. --- linux-4.14.336/mm/memcontrol.c
  9103. +++ linux-4.14.336/mm/memcontrol.c
  9104. @@ -1747,6 +1747,9 @@ static void drain_stock(struct memcg_stock_pcp *stock)
  9105. {
  9106. struct mem_cgroup *old = stock->cached;
  9107. + if (!old)
  9108. + return;
  9109. +
  9110. if (stock->nr_pages) {
  9111. page_counter_uncharge(&old->memory, stock->nr_pages);
  9112. if (do_memsw_account())
  9113. @@ -1754,6 +1757,8 @@ static void drain_stock(struct memcg_stock_pcp *stock)
  9114. css_put_many(&old->css, stock->nr_pages);
  9115. stock->nr_pages = 0;
  9116. }
  9117. +
  9118. + css_put(&old->css);
  9119. stock->cached = NULL;
  9120. }
  9121. @@ -1789,6 +1794,7 @@ static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
  9122. stock = this_cpu_ptr(&memcg_stock);
  9123. if (stock->cached != memcg) { /* reset if necessary */
  9124. drain_stock(stock);
  9125. + css_get(&memcg->css);
  9126. stock->cached = memcg;
  9127. }
  9128. stock->nr_pages += nr_pages;
  9129. @@ -1820,21 +1826,22 @@ static void drain_all_stock(struct mem_cgroup *root_memcg)
  9130. for_each_online_cpu(cpu) {
  9131. struct memcg_stock_pcp *stock = &per_cpu(memcg_stock, cpu);
  9132. struct mem_cgroup *memcg;
  9133. + bool flush = false;
  9134. + rcu_read_lock();
  9135. memcg = stock->cached;
  9136. - if (!memcg || !stock->nr_pages || !css_tryget(&memcg->css))
  9137. - continue;
  9138. - if (!mem_cgroup_is_descendant(memcg, root_memcg)) {
  9139. - css_put(&memcg->css);
  9140. - continue;
  9141. - }
  9142. - if (!test_and_set_bit(FLUSHING_CACHED_CHARGE, &stock->flags)) {
  9143. + if (memcg && stock->nr_pages &&
  9144. + mem_cgroup_is_descendant(memcg, root_memcg))
  9145. + flush = true;
  9146. + rcu_read_unlock();
  9147. +
  9148. + if (flush &&
  9149. + !test_and_set_bit(FLUSHING_CACHED_CHARGE, &stock->flags)) {
  9150. if (cpu == curcpu)
  9151. drain_local_stock(&stock->work);
  9152. else
  9153. schedule_work_on(cpu, &stock->work);
  9154. }
  9155. - css_put(&memcg->css);
  9156. }
  9157. put_cpu();
  9158. mutex_unlock(&percpu_charge_mutex);
  9159. diff --git mm/memory-failure.c mm/memory-failure.c
  9160. index e7827b9e6397..e179ffa15026 100644
  9161. --- linux-4.14.336/mm/memory-failure.c
  9162. +++ linux-4.14.336/mm/memory-failure.c
  9163. @@ -952,7 +952,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
  9164. * This check implies we don't kill processes if their pages
  9165. * are in the swap cache early. Those are always late kills.
  9166. */
  9167. - if (!page_mapped(hpage))
  9168. + if (!page_mapped(p))
  9169. return true;
  9170. if (PageKsm(p)) {
  9171. @@ -996,10 +996,10 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
  9172. if (kill)
  9173. collect_procs(hpage, &tokill, flags & MF_ACTION_REQUIRED);
  9174. - unmap_success = try_to_unmap(hpage, ttu);
  9175. + unmap_success = try_to_unmap(p, ttu);
  9176. if (!unmap_success)
  9177. pr_err("Memory failure: %#lx: failed to unmap page (mapcount=%d)\n",
  9178. - pfn, page_mapcount(hpage));
  9179. + pfn, page_mapcount(p));
  9180. /*
  9181. * try_to_unmap() might put mlocked page in lru cache, so call
  9182. diff --git mm/memory.c mm/memory.c
  9183. index 0136af15ba18..aa0c46997ce8 100644
  9184. --- linux-4.14.336/mm/memory.c
  9185. +++ linux-4.14.336/mm/memory.c
  9186. @@ -2958,8 +2958,8 @@ void unmap_mapping_range(struct address_space *mapping,
  9187. loff_t const holebegin, loff_t const holelen, int even_cows)
  9188. {
  9189. struct zap_details details = { };
  9190. - pgoff_t hba = holebegin >> PAGE_SHIFT;
  9191. - pgoff_t hlen = (holelen + PAGE_SIZE - 1) >> PAGE_SHIFT;
  9192. + pgoff_t hba = (pgoff_t)(holebegin) >> PAGE_SHIFT;
  9193. + pgoff_t hlen = ((pgoff_t)(holelen) + PAGE_SIZE - 1) >> PAGE_SHIFT;
  9194. /* Check for overflow. */
  9195. if (sizeof(holelen) > sizeof(hlen)) {
  9196. diff --git mm/page-writeback.c mm/page-writeback.c
  9197. index 29f9980c13ac..2193086847b3 100644
  9198. --- linux-4.14.336/mm/page-writeback.c
  9199. +++ linux-4.14.336/mm/page-writeback.c
  9200. @@ -1531,7 +1531,7 @@ static inline void wb_dirty_limits(struct dirty_throttle_control *dtc)
  9201. */
  9202. dtc->wb_thresh = __wb_calc_thresh(dtc);
  9203. dtc->wb_bg_thresh = dtc->thresh ?
  9204. - div_u64((u64)dtc->wb_thresh * dtc->bg_thresh, dtc->thresh) : 0;
  9205. + div64_u64(dtc->wb_thresh * dtc->bg_thresh, dtc->thresh) : 0;
  9206. /*
  9207. * In order to avoid the stacked BDI deadlock we need
  9208. diff --git net/8021q/vlan_netlink.c net/8021q/vlan_netlink.c
  9209. index fdf39dd5e755..aad09715ac49 100644
  9210. --- linux-4.14.336/net/8021q/vlan_netlink.c
  9211. +++ linux-4.14.336/net/8021q/vlan_netlink.c
  9212. @@ -105,12 +105,16 @@ static int vlan_changelink(struct net_device *dev, struct nlattr *tb[],
  9213. }
  9214. if (data[IFLA_VLAN_INGRESS_QOS]) {
  9215. nla_for_each_nested(attr, data[IFLA_VLAN_INGRESS_QOS], rem) {
  9216. + if (nla_type(attr) != IFLA_VLAN_QOS_MAPPING)
  9217. + continue;
  9218. m = nla_data(attr);
  9219. vlan_dev_set_ingress_priority(dev, m->to, m->from);
  9220. }
  9221. }
  9222. if (data[IFLA_VLAN_EGRESS_QOS]) {
  9223. nla_for_each_nested(attr, data[IFLA_VLAN_EGRESS_QOS], rem) {
  9224. + if (nla_type(attr) != IFLA_VLAN_QOS_MAPPING)
  9225. + continue;
  9226. m = nla_data(attr);
  9227. err = vlan_dev_set_egress_priority(dev, m->from, m->to);
  9228. if (err)
  9229. diff --git net/bluetooth/hci_conn.c net/bluetooth/hci_conn.c
  9230. index ce4bbc426946..017abffccc15 100644
  9231. --- linux-4.14.336/net/bluetooth/hci_conn.c
  9232. +++ linux-4.14.336/net/bluetooth/hci_conn.c
  9233. @@ -1221,12 +1221,10 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
  9234. hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED,
  9235. sizeof(cp), &cp);
  9236. - /* If we're already encrypted set the REAUTH_PEND flag,
  9237. - * otherwise set the ENCRYPT_PEND.
  9238. + /* Set the ENCRYPT_PEND to trigger encryption after
  9239. + * authentication.
  9240. */
  9241. - if (test_bit(HCI_CONN_ENCRYPT, &conn->flags))
  9242. - set_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
  9243. - else
  9244. + if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags))
  9245. set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
  9246. }
  9247. diff --git net/bluetooth/hci_core.c net/bluetooth/hci_core.c
  9248. index 2bf0bdee7186..8faecd94bf5a 100644
  9249. --- linux-4.14.336/net/bluetooth/hci_core.c
  9250. +++ linux-4.14.336/net/bluetooth/hci_core.c
  9251. @@ -2167,6 +2167,7 @@ static void hci_error_reset(struct work_struct *work)
  9252. {
  9253. struct hci_dev *hdev = container_of(work, struct hci_dev, error_reset);
  9254. + hci_dev_hold(hdev);
  9255. BT_DBG("%s", hdev->name);
  9256. if (hdev->hw_error)
  9257. @@ -2175,10 +2176,10 @@ static void hci_error_reset(struct work_struct *work)
  9258. BT_ERR("%s hardware error 0x%2.2x", hdev->name,
  9259. hdev->hw_error_code);
  9260. - if (hci_dev_do_close(hdev))
  9261. - return;
  9262. + if (!hci_dev_do_close(hdev))
  9263. + hci_dev_do_open(hdev);
  9264. - hci_dev_do_open(hdev);
  9265. + hci_dev_put(hdev);
  9266. }
  9267. void hci_uuids_clear(struct hci_dev *hdev)
  9268. diff --git net/bluetooth/hci_event.c net/bluetooth/hci_event.c
  9269. index 07605fcc9091..987ba33375c9 100644
  9270. --- linux-4.14.336/net/bluetooth/hci_event.c
  9271. +++ linux-4.14.336/net/bluetooth/hci_event.c
  9272. @@ -2459,14 +2459,8 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
  9273. if (!ev->status) {
  9274. clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags);
  9275. -
  9276. - if (!hci_conn_ssp_enabled(conn) &&
  9277. - test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) {
  9278. - BT_INFO("re-auth of legacy device is not possible.");
  9279. - } else {
  9280. - set_bit(HCI_CONN_AUTH, &conn->flags);
  9281. - conn->sec_level = conn->pending_sec_level;
  9282. - }
  9283. + set_bit(HCI_CONN_AUTH, &conn->flags);
  9284. + conn->sec_level = conn->pending_sec_level;
  9285. } else {
  9286. if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING)
  9287. set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags);
  9288. @@ -2475,7 +2469,6 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
  9289. }
  9290. clear_bit(HCI_CONN_AUTH_PEND, &conn->flags);
  9291. - clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
  9292. if (conn->state == BT_CONFIG) {
  9293. if (!ev->status && hci_conn_ssp_enabled(conn)) {
  9294. @@ -4022,9 +4015,12 @@ static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
  9295. hci_dev_lock(hdev);
  9296. conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
  9297. - if (!conn || !hci_conn_ssp_enabled(conn))
  9298. + if (!conn || !hci_dev_test_flag(hdev, HCI_SSP_ENABLED))
  9299. goto unlock;
  9300. + /* Assume remote supports SSP since it has triggered this event */
  9301. + set_bit(HCI_CONN_SSP_ENABLED, &conn->flags);
  9302. +
  9303. hci_conn_hold(conn);
  9304. if (!hci_dev_test_flag(hdev, HCI_MGMT))
  9305. @@ -5148,6 +5144,10 @@ static void hci_le_remote_conn_param_req_evt(struct hci_dev *hdev,
  9306. return send_conn_param_neg_reply(hdev, handle,
  9307. HCI_ERROR_UNKNOWN_CONN_ID);
  9308. + if (max > hcon->le_conn_max_interval)
  9309. + return send_conn_param_neg_reply(hdev, handle,
  9310. + HCI_ERROR_INVALID_LL_PARAMS);
  9311. +
  9312. if (hci_check_conn_params(min, max, latency, timeout))
  9313. return send_conn_param_neg_reply(hdev, handle,
  9314. HCI_ERROR_INVALID_LL_PARAMS);
  9315. diff --git net/bluetooth/l2cap_core.c net/bluetooth/l2cap_core.c
  9316. index 6bae68b5d439..e52657f05f78 100644
  9317. --- linux-4.14.336/net/bluetooth/l2cap_core.c
  9318. +++ linux-4.14.336/net/bluetooth/l2cap_core.c
  9319. @@ -5313,7 +5313,13 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
  9320. memset(&rsp, 0, sizeof(rsp));
  9321. - err = hci_check_conn_params(min, max, latency, to_multiplier);
  9322. + if (max > hcon->le_conn_max_interval) {
  9323. + BT_DBG("requested connection interval exceeds current bounds.");
  9324. + err = -EINVAL;
  9325. + } else {
  9326. + err = hci_check_conn_params(min, max, latency, to_multiplier);
  9327. + }
  9328. +
  9329. if (err)
  9330. rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_REJECTED);
  9331. else
  9332. diff --git net/core/dst.c net/core/dst.c
  9333. index a6c47da7d0f8..2d121958d5b0 100644
  9334. --- linux-4.14.336/net/core/dst.c
  9335. +++ linux-4.14.336/net/core/dst.c
  9336. @@ -99,10 +99,10 @@ void *dst_alloc(struct dst_ops *ops, struct net_device *dev,
  9337. {
  9338. struct dst_entry *dst;
  9339. - if (ops->gc && dst_entries_get_fast(ops) > ops->gc_thresh) {
  9340. - if (ops->gc(ops))
  9341. - return NULL;
  9342. - }
  9343. + if (ops->gc &&
  9344. + !(flags & DST_NOCOUNT) &&
  9345. + dst_entries_get_fast(ops) > ops->gc_thresh)
  9346. + ops->gc(ops);
  9347. dst = kmem_cache_alloc(ops->kmem_cachep, GFP_ATOMIC);
  9348. if (!dst)
  9349. diff --git net/ipv4/af_inet.c net/ipv4/af_inet.c
  9350. index 1eee002b12d2..5feb84c43564 100644
  9351. --- linux-4.14.336/net/ipv4/af_inet.c
  9352. +++ linux-4.14.336/net/ipv4/af_inet.c
  9353. @@ -1480,10 +1480,12 @@ EXPORT_SYMBOL(inet_current_timestamp);
  9354. int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)
  9355. {
  9356. - if (sk->sk_family == AF_INET)
  9357. + unsigned int family = READ_ONCE(sk->sk_family);
  9358. +
  9359. + if (family == AF_INET)
  9360. return ip_recv_error(sk, msg, len, addr_len);
  9361. #if IS_ENABLED(CONFIG_IPV6)
  9362. - if (sk->sk_family == AF_INET6)
  9363. + if (family == AF_INET6)
  9364. return pingv6_ops.ipv6_recv_error(sk, msg, len, addr_len);
  9365. #endif
  9366. return -EINVAL;
  9367. diff --git net/ipv4/ip_output.c net/ipv4/ip_output.c
  9368. index c242c412dabc..947655e4ab5c 100644
  9369. --- linux-4.14.336/net/ipv4/ip_output.c
  9370. +++ linux-4.14.336/net/ipv4/ip_output.c
  9371. @@ -1114,6 +1114,16 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork,
  9372. struct ip_options_rcu *opt;
  9373. struct rtable *rt;
  9374. + rt = *rtp;
  9375. + if (unlikely(!rt))
  9376. + return -EFAULT;
  9377. +
  9378. + cork->fragsize = ip_sk_use_pmtu(sk) ?
  9379. + dst_mtu(&rt->dst) : READ_ONCE(rt->dst.dev->mtu);
  9380. +
  9381. + if (!inetdev_valid_mtu(cork->fragsize))
  9382. + return -ENETUNREACH;
  9383. +
  9384. /*
  9385. * setup for corking.
  9386. */
  9387. @@ -1129,15 +1139,6 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork,
  9388. cork->flags |= IPCORK_OPT;
  9389. cork->addr = ipc->addr;
  9390. }
  9391. - rt = *rtp;
  9392. - if (unlikely(!rt))
  9393. - return -EFAULT;
  9394. -
  9395. - cork->fragsize = ip_sk_use_pmtu(sk) ?
  9396. - dst_mtu(&rt->dst) : READ_ONCE(rt->dst.dev->mtu);
  9397. -
  9398. - if (!inetdev_valid_mtu(cork->fragsize))
  9399. - return -ENETUNREACH;
  9400. cork->dst = &rt->dst;
  9401. /* We stole this route, caller should not release it. */
  9402. diff --git net/ipv4/tcp.c net/ipv4/tcp.c
  9403. index 0859f968c9b2..eb5458cbdc1c 100644
  9404. --- linux-4.14.336/net/ipv4/tcp.c
  9405. +++ linux-4.14.336/net/ipv4/tcp.c
  9406. @@ -701,6 +701,7 @@ static void tcp_push(struct sock *sk, int flags, int mss_now,
  9407. if (!test_bit(TSQ_THROTTLED, &sk->sk_tsq_flags)) {
  9408. NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPAUTOCORKING);
  9409. set_bit(TSQ_THROTTLED, &sk->sk_tsq_flags);
  9410. + smp_mb__after_atomic();
  9411. }
  9412. /* It is possible TX completion already happened
  9413. * before we set TSQ_THROTTLED.
  9414. diff --git net/ipv6/addrconf_core.c net/ipv6/addrconf_core.c
  9415. index e6c5a4b5921d..f5a267972c57 100644
  9416. --- linux-4.14.336/net/ipv6/addrconf_core.c
  9417. +++ linux-4.14.336/net/ipv6/addrconf_core.c
  9418. @@ -140,19 +140,26 @@ const struct ipv6_stub *ipv6_stub __read_mostly = &(struct ipv6_stub) {
  9419. EXPORT_SYMBOL_GPL(ipv6_stub);
  9420. /* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */
  9421. -const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
  9422. +const struct in6_addr in6addr_loopback __aligned(BITS_PER_LONG/8)
  9423. + = IN6ADDR_LOOPBACK_INIT;
  9424. EXPORT_SYMBOL(in6addr_loopback);
  9425. -const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
  9426. +const struct in6_addr in6addr_any __aligned(BITS_PER_LONG/8)
  9427. + = IN6ADDR_ANY_INIT;
  9428. EXPORT_SYMBOL(in6addr_any);
  9429. -const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
  9430. +const struct in6_addr in6addr_linklocal_allnodes __aligned(BITS_PER_LONG/8)
  9431. + = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
  9432. EXPORT_SYMBOL(in6addr_linklocal_allnodes);
  9433. -const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
  9434. +const struct in6_addr in6addr_linklocal_allrouters __aligned(BITS_PER_LONG/8)
  9435. + = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
  9436. EXPORT_SYMBOL(in6addr_linklocal_allrouters);
  9437. -const struct in6_addr in6addr_interfacelocal_allnodes = IN6ADDR_INTERFACELOCAL_ALLNODES_INIT;
  9438. +const struct in6_addr in6addr_interfacelocal_allnodes __aligned(BITS_PER_LONG/8)
  9439. + = IN6ADDR_INTERFACELOCAL_ALLNODES_INIT;
  9440. EXPORT_SYMBOL(in6addr_interfacelocal_allnodes);
  9441. -const struct in6_addr in6addr_interfacelocal_allrouters = IN6ADDR_INTERFACELOCAL_ALLROUTERS_INIT;
  9442. +const struct in6_addr in6addr_interfacelocal_allrouters __aligned(BITS_PER_LONG/8)
  9443. + = IN6ADDR_INTERFACELOCAL_ALLROUTERS_INIT;
  9444. EXPORT_SYMBOL(in6addr_interfacelocal_allrouters);
  9445. -const struct in6_addr in6addr_sitelocal_allrouters = IN6ADDR_SITELOCAL_ALLROUTERS_INIT;
  9446. +const struct in6_addr in6addr_sitelocal_allrouters __aligned(BITS_PER_LONG/8)
  9447. + = IN6ADDR_SITELOCAL_ALLROUTERS_INIT;
  9448. EXPORT_SYMBOL(in6addr_sitelocal_allrouters);
  9449. static void snmp6_free_dev(struct inet6_dev *idev)
  9450. diff --git net/ipv6/ip6_tunnel.c net/ipv6/ip6_tunnel.c
  9451. index d59bf0da2912..cfe3a72a1159 100644
  9452. --- linux-4.14.336/net/ipv6/ip6_tunnel.c
  9453. +++ linux-4.14.336/net/ipv6/ip6_tunnel.c
  9454. @@ -404,7 +404,7 @@ __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw)
  9455. const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)raw;
  9456. unsigned int nhoff = raw - skb->data;
  9457. unsigned int off = nhoff + sizeof(*ipv6h);
  9458. - u8 next, nexthdr = ipv6h->nexthdr;
  9459. + u8 nexthdr = ipv6h->nexthdr;
  9460. while (ipv6_ext_hdr(nexthdr) && nexthdr != NEXTHDR_NONE) {
  9461. struct ipv6_opt_hdr *hdr;
  9462. @@ -415,25 +415,25 @@ __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw)
  9463. hdr = (struct ipv6_opt_hdr *)(skb->data + off);
  9464. if (nexthdr == NEXTHDR_FRAGMENT) {
  9465. - struct frag_hdr *frag_hdr = (struct frag_hdr *) hdr;
  9466. - if (frag_hdr->frag_off)
  9467. - break;
  9468. optlen = 8;
  9469. } else if (nexthdr == NEXTHDR_AUTH) {
  9470. optlen = (hdr->hdrlen + 2) << 2;
  9471. } else {
  9472. optlen = ipv6_optlen(hdr);
  9473. }
  9474. - /* cache hdr->nexthdr, since pskb_may_pull() might
  9475. - * invalidate hdr
  9476. - */
  9477. - next = hdr->nexthdr;
  9478. - if (nexthdr == NEXTHDR_DEST) {
  9479. - u16 i = 2;
  9480. - /* Remember : hdr is no longer valid at this point. */
  9481. - if (!pskb_may_pull(skb, off + optlen))
  9482. + if (!pskb_may_pull(skb, off + optlen))
  9483. + break;
  9484. +
  9485. + hdr = (struct ipv6_opt_hdr *)(skb->data + off);
  9486. + if (nexthdr == NEXTHDR_FRAGMENT) {
  9487. + struct frag_hdr *frag_hdr = (struct frag_hdr *)hdr;
  9488. +
  9489. + if (frag_hdr->frag_off)
  9490. break;
  9491. + }
  9492. + if (nexthdr == NEXTHDR_DEST) {
  9493. + u16 i = 2;
  9494. while (1) {
  9495. struct ipv6_tlv_tnl_enc_lim *tel;
  9496. @@ -454,7 +454,7 @@ __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw)
  9497. i++;
  9498. }
  9499. }
  9500. - nexthdr = next;
  9501. + nexthdr = hdr->nexthdr;
  9502. off += optlen;
  9503. }
  9504. return 0;
  9505. diff --git net/ipv6/route.c net/ipv6/route.c
  9506. index 79b67f8048b5..6e4d31524268 100644
  9507. --- linux-4.14.336/net/ipv6/route.c
  9508. +++ linux-4.14.336/net/ipv6/route.c
  9509. @@ -85,7 +85,7 @@ static struct dst_entry *ip6_negative_advice(struct dst_entry *);
  9510. static void ip6_dst_destroy(struct dst_entry *);
  9511. static void ip6_dst_ifdown(struct dst_entry *,
  9512. struct net_device *dev, int how);
  9513. -static int ip6_dst_gc(struct dst_ops *ops);
  9514. +static void ip6_dst_gc(struct dst_ops *ops);
  9515. static int ip6_pkt_discard(struct sk_buff *skb);
  9516. static int ip6_pkt_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb);
  9517. @@ -1792,29 +1792,30 @@ out:
  9518. return dst;
  9519. }
  9520. -static int ip6_dst_gc(struct dst_ops *ops)
  9521. +static void ip6_dst_gc(struct dst_ops *ops)
  9522. {
  9523. struct net *net = container_of(ops, struct net, ipv6.ip6_dst_ops);
  9524. int rt_min_interval = net->ipv6.sysctl.ip6_rt_gc_min_interval;
  9525. - int rt_max_size = net->ipv6.sysctl.ip6_rt_max_size;
  9526. int rt_elasticity = net->ipv6.sysctl.ip6_rt_gc_elasticity;
  9527. int rt_gc_timeout = net->ipv6.sysctl.ip6_rt_gc_timeout;
  9528. unsigned long rt_last_gc = net->ipv6.ip6_rt_last_gc;
  9529. + unsigned int val;
  9530. int entries;
  9531. entries = dst_entries_get_fast(ops);
  9532. - if (time_after(rt_last_gc + rt_min_interval, jiffies) &&
  9533. - entries <= rt_max_size)
  9534. + if (entries > ops->gc_thresh)
  9535. + entries = dst_entries_get_slow(ops);
  9536. +
  9537. + if (time_after(rt_last_gc + rt_min_interval, jiffies))
  9538. goto out;
  9539. - net->ipv6.ip6_rt_gc_expire++;
  9540. - fib6_run_gc(net->ipv6.ip6_rt_gc_expire, net, true);
  9541. + fib6_run_gc(atomic_inc_return(&net->ipv6.ip6_rt_gc_expire), net, true);
  9542. entries = dst_entries_get_slow(ops);
  9543. if (entries < ops->gc_thresh)
  9544. - net->ipv6.ip6_rt_gc_expire = rt_gc_timeout>>1;
  9545. + atomic_set(&net->ipv6.ip6_rt_gc_expire, rt_gc_timeout >> 1);
  9546. out:
  9547. - net->ipv6.ip6_rt_gc_expire -= net->ipv6.ip6_rt_gc_expire>>rt_elasticity;
  9548. - return entries > rt_max_size;
  9549. + val = atomic_read(&net->ipv6.ip6_rt_gc_expire);
  9550. + atomic_set(&net->ipv6.ip6_rt_gc_expire, val - (val >> rt_elasticity));
  9551. }
  9552. static int ip6_convert_metrics(struct mx6_config *mxc,
  9553. @@ -4091,7 +4092,7 @@ static int __net_init ip6_route_net_init(struct net *net)
  9554. #endif
  9555. net->ipv6.sysctl.flush_delay = 0;
  9556. - net->ipv6.sysctl.ip6_rt_max_size = 4096;
  9557. + net->ipv6.sysctl.ip6_rt_max_size = INT_MAX;
  9558. net->ipv6.sysctl.ip6_rt_gc_min_interval = HZ / 2;
  9559. net->ipv6.sysctl.ip6_rt_gc_timeout = 60*HZ;
  9560. net->ipv6.sysctl.ip6_rt_gc_interval = 30*HZ;
  9561. @@ -4099,7 +4100,7 @@ static int __net_init ip6_route_net_init(struct net *net)
  9562. net->ipv6.sysctl.ip6_rt_mtu_expires = 10*60*HZ;
  9563. net->ipv6.sysctl.ip6_rt_min_advmss = IPV6_MIN_MTU - 20 - 40;
  9564. - net->ipv6.ip6_rt_gc_expire = 30*HZ;
  9565. + atomic_set(&net->ipv6.ip6_rt_gc_expire, 30*HZ);
  9566. ret = 0;
  9567. out:
  9568. diff --git net/ipv6/seg6.c net/ipv6/seg6.c
  9569. index 9c45165fe79b..b785bf569049 100644
  9570. --- linux-4.14.336/net/ipv6/seg6.c
  9571. +++ linux-4.14.336/net/ipv6/seg6.c
  9572. @@ -447,22 +447,24 @@ int __init seg6_init(void)
  9573. {
  9574. int err = -ENOMEM;
  9575. - err = genl_register_family(&seg6_genl_family);
  9576. + err = register_pernet_subsys(&ip6_segments_ops);
  9577. if (err)
  9578. goto out;
  9579. - err = register_pernet_subsys(&ip6_segments_ops);
  9580. + err = genl_register_family(&seg6_genl_family);
  9581. if (err)
  9582. - goto out_unregister_genl;
  9583. + goto out_unregister_pernet;
  9584. #ifdef CONFIG_IPV6_SEG6_LWTUNNEL
  9585. err = seg6_iptunnel_init();
  9586. if (err)
  9587. - goto out_unregister_pernet;
  9588. + goto out_unregister_genl;
  9589. err = seg6_local_init();
  9590. - if (err)
  9591. - goto out_unregister_pernet;
  9592. + if (err) {
  9593. + seg6_iptunnel_exit();
  9594. + goto out_unregister_genl;
  9595. + }
  9596. #endif
  9597. #ifdef CONFIG_IPV6_SEG6_HMAC
  9598. @@ -483,11 +485,11 @@ out_unregister_iptun:
  9599. #endif
  9600. #endif
  9601. #ifdef CONFIG_IPV6_SEG6_LWTUNNEL
  9602. -out_unregister_pernet:
  9603. - unregister_pernet_subsys(&ip6_segments_ops);
  9604. -#endif
  9605. out_unregister_genl:
  9606. genl_unregister_family(&seg6_genl_family);
  9607. +#endif
  9608. +out_unregister_pernet:
  9609. + unregister_pernet_subsys(&ip6_segments_ops);
  9610. goto out;
  9611. }
  9612. diff --git net/iucv/af_iucv.c net/iucv/af_iucv.c
  9613. index 07e397a5edc6..d7dd92274957 100644
  9614. --- linux-4.14.336/net/iucv/af_iucv.c
  9615. +++ linux-4.14.336/net/iucv/af_iucv.c
  9616. @@ -2458,7 +2458,7 @@ static int __init afiucv_init(void)
  9617. {
  9618. int err;
  9619. - if (MACHINE_IS_VM) {
  9620. + if (MACHINE_IS_VM && IS_ENABLED(CONFIG_IUCV)) {
  9621. cpcmd("QUERY USERID", iucv_userid, sizeof(iucv_userid), &err);
  9622. if (unlikely(err)) {
  9623. WARN_ON(err);
  9624. @@ -2466,11 +2466,7 @@ static int __init afiucv_init(void)
  9625. goto out;
  9626. }
  9627. - pr_iucv = try_then_request_module(symbol_get(iucv_if), "iucv");
  9628. - if (!pr_iucv) {
  9629. - printk(KERN_WARNING "iucv_if lookup failed\n");
  9630. - memset(&iucv_userid, 0, sizeof(iucv_userid));
  9631. - }
  9632. + pr_iucv = &iucv_if;
  9633. } else {
  9634. memset(&iucv_userid, 0, sizeof(iucv_userid));
  9635. pr_iucv = NULL;
  9636. @@ -2504,17 +2500,13 @@ out_sock:
  9637. out_proto:
  9638. proto_unregister(&iucv_proto);
  9639. out:
  9640. - if (pr_iucv)
  9641. - symbol_put(iucv_if);
  9642. return err;
  9643. }
  9644. static void __exit afiucv_exit(void)
  9645. {
  9646. - if (pr_iucv) {
  9647. + if (pr_iucv)
  9648. afiucv_iucv_exit();
  9649. - symbol_put(iucv_if);
  9650. - }
  9651. unregister_netdevice_notifier(&afiucv_netdev_notifier);
  9652. dev_remove_pack(&iucv_packet_type);
  9653. diff --git net/l2tp/l2tp_ip6.c net/l2tp/l2tp_ip6.c
  9654. index d797708a1a5e..4a5f6ca12342 100644
  9655. --- linux-4.14.336/net/l2tp/l2tp_ip6.c
  9656. +++ linux-4.14.336/net/l2tp/l2tp_ip6.c
  9657. @@ -658,7 +658,7 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
  9658. back_from_confirm:
  9659. lock_sock(sk);
  9660. - ulen = len + skb_queue_empty(&sk->sk_write_queue) ? transhdrlen : 0;
  9661. + ulen = len + (skb_queue_empty(&sk->sk_write_queue) ? transhdrlen : 0);
  9662. err = ip6_append_data(sk, ip_generic_getfrag, msg,
  9663. ulen, transhdrlen, &ipc6,
  9664. &fl6, (struct rt6_info *)dst,
  9665. diff --git net/llc/af_llc.c net/llc/af_llc.c
  9666. index 1e20b719fb3c..727af511297c 100644
  9667. --- linux-4.14.336/net/llc/af_llc.c
  9668. +++ linux-4.14.336/net/llc/af_llc.c
  9669. @@ -227,6 +227,8 @@ static int llc_ui_release(struct socket *sock)
  9670. if (llc->dev)
  9671. dev_put(llc->dev);
  9672. sock_put(sk);
  9673. + sock_orphan(sk);
  9674. + sock->sk = NULL;
  9675. llc_sk_free(sk);
  9676. out:
  9677. return 0;
  9678. @@ -926,14 +928,15 @@ copy_uaddr:
  9679. */
  9680. static int llc_ui_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
  9681. {
  9682. + DECLARE_SOCKADDR(struct sockaddr_llc *, addr, msg->msg_name);
  9683. struct sock *sk = sock->sk;
  9684. struct llc_sock *llc = llc_sk(sk);
  9685. - DECLARE_SOCKADDR(struct sockaddr_llc *, addr, msg->msg_name);
  9686. int flags = msg->msg_flags;
  9687. int noblock = flags & MSG_DONTWAIT;
  9688. + int rc = -EINVAL, copied = 0, hdrlen, hh_len;
  9689. struct sk_buff *skb = NULL;
  9690. + struct net_device *dev;
  9691. size_t size = 0;
  9692. - int rc = -EINVAL, copied = 0, hdrlen;
  9693. dprintk("%s: sending from %02X to %02X\n", __func__,
  9694. llc->laddr.lsap, llc->daddr.lsap);
  9695. @@ -953,22 +956,29 @@ static int llc_ui_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
  9696. if (rc)
  9697. goto out;
  9698. }
  9699. - hdrlen = llc->dev->hard_header_len + llc_ui_header_len(sk, addr);
  9700. + dev = llc->dev;
  9701. + hh_len = LL_RESERVED_SPACE(dev);
  9702. + hdrlen = llc_ui_header_len(sk, addr);
  9703. size = hdrlen + len;
  9704. - if (size > llc->dev->mtu)
  9705. - size = llc->dev->mtu;
  9706. + size = min_t(size_t, size, READ_ONCE(dev->mtu));
  9707. copied = size - hdrlen;
  9708. rc = -EINVAL;
  9709. if (copied < 0)
  9710. goto out;
  9711. release_sock(sk);
  9712. - skb = sock_alloc_send_skb(sk, size, noblock, &rc);
  9713. + skb = sock_alloc_send_skb(sk, hh_len + size, noblock, &rc);
  9714. lock_sock(sk);
  9715. if (!skb)
  9716. goto out;
  9717. - skb->dev = llc->dev;
  9718. + if (sock_flag(sk, SOCK_ZAPPED) ||
  9719. + llc->dev != dev ||
  9720. + hdrlen != llc_ui_header_len(sk, addr) ||
  9721. + hh_len != LL_RESERVED_SPACE(dev) ||
  9722. + size > READ_ONCE(dev->mtu))
  9723. + goto out;
  9724. + skb->dev = dev;
  9725. skb->protocol = llc_proto_type(addr->sllc_arphrd);
  9726. - skb_reserve(skb, hdrlen);
  9727. + skb_reserve(skb, hh_len + hdrlen);
  9728. rc = memcpy_from_msg(skb_put(skb, copied), msg, copied);
  9729. if (rc)
  9730. goto out;
  9731. diff --git net/llc/llc_core.c net/llc/llc_core.c
  9732. index 64d4bef04e73..4900a27b5176 100644
  9733. --- linux-4.14.336/net/llc/llc_core.c
  9734. +++ linux-4.14.336/net/llc/llc_core.c
  9735. @@ -135,22 +135,15 @@ static struct packet_type llc_packet_type __read_mostly = {
  9736. .func = llc_rcv,
  9737. };
  9738. -static struct packet_type llc_tr_packet_type __read_mostly = {
  9739. - .type = cpu_to_be16(ETH_P_TR_802_2),
  9740. - .func = llc_rcv,
  9741. -};
  9742. -
  9743. static int __init llc_init(void)
  9744. {
  9745. dev_add_pack(&llc_packet_type);
  9746. - dev_add_pack(&llc_tr_packet_type);
  9747. return 0;
  9748. }
  9749. static void __exit llc_exit(void)
  9750. {
  9751. dev_remove_pack(&llc_packet_type);
  9752. - dev_remove_pack(&llc_tr_packet_type);
  9753. }
  9754. module_init(llc_init);
  9755. diff --git net/mac80211/sta_info.c net/mac80211/sta_info.c
  9756. index 4e406cd11573..f2663c0a1e6f 100644
  9757. --- linux-4.14.336/net/mac80211/sta_info.c
  9758. +++ linux-4.14.336/net/mac80211/sta_info.c
  9759. @@ -602,6 +602,8 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU)
  9760. if (ieee80211_vif_is_mesh(&sdata->vif))
  9761. mesh_accept_plinks_update(sdata);
  9762. + ieee80211_check_fast_xmit(sta);
  9763. +
  9764. return 0;
  9765. out_remove:
  9766. sta_info_hash_del(local, sta);
  9767. diff --git net/mac80211/tx.c net/mac80211/tx.c
  9768. index 3914214dee05..995b0f444351 100644
  9769. --- linux-4.14.336/net/mac80211/tx.c
  9770. +++ linux-4.14.336/net/mac80211/tx.c
  9771. @@ -2808,7 +2808,7 @@ void ieee80211_check_fast_xmit(struct sta_info *sta)
  9772. sdata->vif.type == NL80211_IFTYPE_STATION)
  9773. goto out;
  9774. - if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED))
  9775. + if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED) || !sta->uploaded)
  9776. goto out;
  9777. if (test_sta_flag(sta, WLAN_STA_PS_STA) ||
  9778. diff --git net/ncsi/internal.h net/ncsi/internal.h
  9779. index 8055e3965cef..2477caf9c967 100644
  9780. --- linux-4.14.336/net/ncsi/internal.h
  9781. +++ linux-4.14.336/net/ncsi/internal.h
  9782. @@ -69,9 +69,12 @@ enum {
  9783. };
  9784. struct ncsi_channel_version {
  9785. - u32 version; /* Supported BCD encoded NCSI version */
  9786. - u32 alpha2; /* Supported BCD encoded NCSI version */
  9787. - u8 fw_name[12]; /* Firware name string */
  9788. + u8 major; /* NCSI version major */
  9789. + u8 minor; /* NCSI version minor */
  9790. + u8 update; /* NCSI version update */
  9791. + char alpha1; /* NCSI version alpha1 */
  9792. + char alpha2; /* NCSI version alpha2 */
  9793. + u8 fw_name[12]; /* Firmware name string */
  9794. u32 fw_version; /* Firmware version */
  9795. u16 pci_ids[4]; /* PCI identification */
  9796. u32 mf_id; /* Manufacture ID */
  9797. diff --git net/ncsi/ncsi-netlink.c net/ncsi/ncsi-netlink.c
  9798. index 9073911ac97b..5c88201ec9d8 100644
  9799. --- linux-4.14.336/net/ncsi/ncsi-netlink.c
  9800. +++ linux-4.14.336/net/ncsi/ncsi-netlink.c
  9801. @@ -71,8 +71,8 @@ static int ncsi_write_channel_info(struct sk_buff *skb,
  9802. if (ndp->force_channel == nc)
  9803. nla_put_flag(skb, NCSI_CHANNEL_ATTR_FORCED);
  9804. - nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MAJOR, nc->version.version);
  9805. - nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MINOR, nc->version.alpha2);
  9806. + nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MAJOR, nc->version.major);
  9807. + nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MINOR, nc->version.minor);
  9808. nla_put_string(skb, NCSI_CHANNEL_ATTR_VERSION_STR, nc->version.fw_name);
  9809. vid_nest = nla_nest_start(skb, NCSI_CHANNEL_ATTR_VLAN_LIST);
  9810. diff --git net/ncsi/ncsi-pkt.h net/ncsi/ncsi-pkt.h
  9811. index 91b4b66438df..0bf62b4883d4 100644
  9812. --- linux-4.14.336/net/ncsi/ncsi-pkt.h
  9813. +++ linux-4.14.336/net/ncsi/ncsi-pkt.h
  9814. @@ -164,9 +164,12 @@ struct ncsi_rsp_gls_pkt {
  9815. /* Get Version ID */
  9816. struct ncsi_rsp_gvi_pkt {
  9817. struct ncsi_rsp_pkt_hdr rsp; /* Response header */
  9818. - __be32 ncsi_version; /* NCSI version */
  9819. + unsigned char major; /* NCSI version major */
  9820. + unsigned char minor; /* NCSI version minor */
  9821. + unsigned char update; /* NCSI version update */
  9822. + unsigned char alpha1; /* NCSI version alpha1 */
  9823. unsigned char reserved[3]; /* Reserved */
  9824. - unsigned char alpha2; /* NCSI version */
  9825. + unsigned char alpha2; /* NCSI version alpha2 */
  9826. unsigned char fw_name[12]; /* f/w name string */
  9827. __be32 fw_version; /* f/w version */
  9828. __be16 pci_ids[4]; /* PCI IDs */
  9829. diff --git net/ncsi/ncsi-rsp.c net/ncsi/ncsi-rsp.c
  9830. index 42878d843c3c..1ae1de24b202 100644
  9831. --- linux-4.14.336/net/ncsi/ncsi-rsp.c
  9832. +++ linux-4.14.336/net/ncsi/ncsi-rsp.c
  9833. @@ -20,6 +20,19 @@
  9834. #include "internal.h"
  9835. #include "ncsi-pkt.h"
  9836. +/* Nibbles within [0xA, 0xF] add zero "0" to the returned value.
  9837. + * Optional fields (encoded as 0xFF) will default to zero.
  9838. + */
  9839. +static u8 decode_bcd_u8(u8 x)
  9840. +{
  9841. + int lo = x & 0xF;
  9842. + int hi = x >> 4;
  9843. +
  9844. + lo = lo < 0xA ? lo : 0;
  9845. + hi = hi < 0xA ? hi : 0;
  9846. + return lo + hi * 10;
  9847. +}
  9848. +
  9849. static int ncsi_validate_rsp_pkt(struct ncsi_request *nr,
  9850. unsigned short payload)
  9851. {
  9852. @@ -610,9 +623,18 @@ static int ncsi_rsp_handler_gvi(struct ncsi_request *nr)
  9853. if (!nc)
  9854. return -ENODEV;
  9855. - /* Update to channel's version info */
  9856. + /* Update channel's version info
  9857. + *
  9858. + * Major, minor, and update fields are supposed to be
  9859. + * unsigned integers encoded as packed BCD.
  9860. + *
  9861. + * Alpha1 and alpha2 are ISO/IEC 8859-1 characters.
  9862. + */
  9863. ncv = &nc->version;
  9864. - ncv->version = ntohl(rsp->ncsi_version);
  9865. + ncv->major = decode_bcd_u8(rsp->major);
  9866. + ncv->minor = decode_bcd_u8(rsp->minor);
  9867. + ncv->update = decode_bcd_u8(rsp->update);
  9868. + ncv->alpha1 = rsp->alpha1;
  9869. ncv->alpha2 = rsp->alpha2;
  9870. memcpy(ncv->fw_name, rsp->fw_name, 12);
  9871. ncv->fw_version = ntohl(rsp->fw_version);
  9872. diff --git net/netfilter/ipvs/ip_vs_xmit.c net/netfilter/ipvs/ip_vs_xmit.c
  9873. index 97d411033f8a..8792cad28e29 100644
  9874. --- linux-4.14.336/net/netfilter/ipvs/ip_vs_xmit.c
  9875. +++ linux-4.14.336/net/netfilter/ipvs/ip_vs_xmit.c
  9876. @@ -270,8 +270,8 @@ static inline bool decrement_ttl(struct netns_ipvs *ipvs,
  9877. skb->dev = dst->dev;
  9878. icmpv6_send(skb, ICMPV6_TIME_EXCEED,
  9879. ICMPV6_EXC_HOPLIMIT, 0);
  9880. - __IP6_INC_STATS(net, ip6_dst_idev(dst),
  9881. - IPSTATS_MIB_INHDRERRORS);
  9882. + IP6_INC_STATS(net, ip6_dst_idev(dst),
  9883. + IPSTATS_MIB_INHDRERRORS);
  9884. return false;
  9885. }
  9886. @@ -286,7 +286,7 @@ static inline bool decrement_ttl(struct netns_ipvs *ipvs,
  9887. {
  9888. if (ip_hdr(skb)->ttl <= 1) {
  9889. /* Tell the sender its packet died... */
  9890. - __IP_INC_STATS(net, IPSTATS_MIB_INHDRERRORS);
  9891. + IP_INC_STATS(net, IPSTATS_MIB_INHDRERRORS);
  9892. icmp_send(skb, ICMP_TIME_EXCEEDED, ICMP_EXC_TTL, 0);
  9893. return false;
  9894. }
  9895. diff --git net/netfilter/nf_log.c net/netfilter/nf_log.c
  9896. index cdc744aa5889..a16156598905 100644
  9897. --- linux-4.14.336/net/netfilter/nf_log.c
  9898. +++ linux-4.14.336/net/netfilter/nf_log.c
  9899. @@ -202,11 +202,12 @@ void nf_logger_put(int pf, enum nf_log_type type)
  9900. return;
  9901. }
  9902. - BUG_ON(loggers[pf][type] == NULL);
  9903. -
  9904. rcu_read_lock();
  9905. logger = rcu_dereference(loggers[pf][type]);
  9906. - module_put(logger->me);
  9907. + if (!logger)
  9908. + WARN_ON_ONCE(1);
  9909. + else
  9910. + module_put(logger->me);
  9911. rcu_read_unlock();
  9912. }
  9913. EXPORT_SYMBOL_GPL(nf_logger_put);
  9914. diff --git net/netfilter/nf_tables_api.c net/netfilter/nf_tables_api.c
  9915. index 27c24c99d23b..407346ba89d4 100644
  9916. --- linux-4.14.336/net/netfilter/nf_tables_api.c
  9917. +++ linux-4.14.336/net/netfilter/nf_tables_api.c
  9918. @@ -22,6 +22,8 @@
  9919. #include <net/net_namespace.h>
  9920. #include <net/sock.h>
  9921. +#define NFT_SET_MAX_ANONLEN 16
  9922. +
  9923. static LIST_HEAD(nf_tables_expressions);
  9924. static LIST_HEAD(nf_tables_objects);
  9925. @@ -744,6 +746,30 @@ err:
  9926. return ret;
  9927. }
  9928. +static bool nft_supported_family(u8 family)
  9929. +{
  9930. + return false
  9931. +#ifdef CONFIG_NF_TABLES_INET
  9932. + || family == NFPROTO_INET
  9933. +#endif
  9934. +#ifdef CONFIG_NF_TABLES_IPV4
  9935. + || family == NFPROTO_IPV4
  9936. +#endif
  9937. +#ifdef CONFIG_NF_TABLES_ARP
  9938. + || family == NFPROTO_ARP
  9939. +#endif
  9940. +#ifdef CONFIG_NF_TABLES_NETDEV
  9941. + || family == NFPROTO_NETDEV
  9942. +#endif
  9943. +#if IS_ENABLED(CONFIG_NF_TABLES_BRIDGE)
  9944. + || family == NFPROTO_BRIDGE
  9945. +#endif
  9946. +#ifdef CONFIG_NF_TABLES_IPV6
  9947. + || family == NFPROTO_IPV6
  9948. +#endif
  9949. + ;
  9950. +}
  9951. +
  9952. static int nf_tables_newtable(struct net *net, struct sock *nlsk,
  9953. struct sk_buff *skb, const struct nlmsghdr *nlh,
  9954. const struct nlattr * const nla[],
  9955. @@ -759,6 +785,9 @@ static int nf_tables_newtable(struct net *net, struct sock *nlsk,
  9956. struct nft_ctx ctx;
  9957. int err;
  9958. + if (!nft_supported_family(family))
  9959. + return -EOPNOTSUPP;
  9960. +
  9961. afi = nf_tables_afinfo_lookup(net, family, true);
  9962. if (IS_ERR(afi))
  9963. return PTR_ERR(afi);
  9964. @@ -2817,6 +2846,9 @@ static int nf_tables_set_alloc_name(struct nft_ctx *ctx, struct nft_set *set,
  9965. if (p[1] != 'd' || strchr(p + 2, '%'))
  9966. return -EINVAL;
  9967. + if (strnlen(name, NFT_SET_MAX_ANONLEN) >= NFT_SET_MAX_ANONLEN)
  9968. + return -EINVAL;
  9969. +
  9970. inuse = (unsigned long *)get_zeroed_page(GFP_KERNEL);
  9971. if (inuse == NULL)
  9972. return -ENOMEM;
  9973. @@ -5889,16 +5921,10 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
  9974. data->verdict.code = ntohl(nla_get_be32(tb[NFTA_VERDICT_CODE]));
  9975. switch (data->verdict.code) {
  9976. - default:
  9977. - switch (data->verdict.code & NF_VERDICT_MASK) {
  9978. - case NF_ACCEPT:
  9979. - case NF_DROP:
  9980. - case NF_QUEUE:
  9981. - break;
  9982. - default:
  9983. - return -EINVAL;
  9984. - }
  9985. - /* fall through */
  9986. + case NF_ACCEPT:
  9987. + case NF_DROP:
  9988. + case NF_QUEUE:
  9989. + break;
  9990. case NFT_CONTINUE:
  9991. case NFT_BREAK:
  9992. case NFT_RETURN:
  9993. @@ -5918,6 +5944,8 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
  9994. data->verdict.chain = chain;
  9995. break;
  9996. + default:
  9997. + return -EINVAL;
  9998. }
  9999. desc->len = sizeof(data->verdict);
  10000. diff --git net/netfilter/nft_byteorder.c net/netfilter/nft_byteorder.c
  10001. index dba16126c7ee..8c4ee49a80fb 100644
  10002. --- linux-4.14.336/net/netfilter/nft_byteorder.c
  10003. +++ linux-4.14.336/net/netfilter/nft_byteorder.c
  10004. @@ -41,19 +41,20 @@ static void nft_byteorder_eval(const struct nft_expr *expr,
  10005. switch (priv->size) {
  10006. case 8: {
  10007. + u64 *dst64 = (void *)dst;
  10008. u64 src64;
  10009. switch (priv->op) {
  10010. case NFT_BYTEORDER_NTOH:
  10011. for (i = 0; i < priv->len / 8; i++) {
  10012. src64 = get_unaligned((u64 *)&src[i]);
  10013. - put_unaligned_be64(src64, &dst[i]);
  10014. + put_unaligned_be64(src64, &dst64[i]);
  10015. }
  10016. break;
  10017. case NFT_BYTEORDER_HTON:
  10018. for (i = 0; i < priv->len / 8; i++) {
  10019. src64 = get_unaligned_be64(&src[i]);
  10020. - put_unaligned(src64, (u64 *)&dst[i]);
  10021. + put_unaligned(src64, &dst64[i]);
  10022. }
  10023. break;
  10024. }
  10025. diff --git net/netfilter/nft_compat.c net/netfilter/nft_compat.c
  10026. index 8281656808ae..b87b7338266c 100644
  10027. --- linux-4.14.336/net/netfilter/nft_compat.c
  10028. +++ linux-4.14.336/net/netfilter/nft_compat.c
  10029. @@ -214,6 +214,7 @@ static const struct nla_policy nft_rule_compat_policy[NFTA_RULE_COMPAT_MAX + 1]
  10030. static int nft_parse_compat(const struct nlattr *attr, u16 *proto, bool *inv)
  10031. {
  10032. struct nlattr *tb[NFTA_RULE_COMPAT_MAX+1];
  10033. + u32 l4proto;
  10034. u32 flags;
  10035. int err;
  10036. @@ -226,12 +227,18 @@ static int nft_parse_compat(const struct nlattr *attr, u16 *proto, bool *inv)
  10037. return -EINVAL;
  10038. flags = ntohl(nla_get_be32(tb[NFTA_RULE_COMPAT_FLAGS]));
  10039. - if (flags & ~NFT_RULE_COMPAT_F_MASK)
  10040. + if (flags & NFT_RULE_COMPAT_F_UNUSED ||
  10041. + flags & ~NFT_RULE_COMPAT_F_MASK)
  10042. return -EINVAL;
  10043. if (flags & NFT_RULE_COMPAT_F_INV)
  10044. *inv = true;
  10045. - *proto = ntohl(nla_get_be32(tb[NFTA_RULE_COMPAT_PROTO]));
  10046. + l4proto = ntohl(nla_get_be32(tb[NFTA_RULE_COMPAT_PROTO]));
  10047. + if (l4proto > U16_MAX)
  10048. + return -EINVAL;
  10049. +
  10050. + *proto = l4proto;
  10051. +
  10052. return 0;
  10053. }
  10054. diff --git net/netlabel/netlabel_calipso.c net/netlabel/netlabel_calipso.c
  10055. index d177dd066504..e0d63fb927bd 100644
  10056. --- linux-4.14.336/net/netlabel/netlabel_calipso.c
  10057. +++ linux-4.14.336/net/netlabel/netlabel_calipso.c
  10058. @@ -68,6 +68,28 @@ static const struct nla_policy calipso_genl_policy[NLBL_CALIPSO_A_MAX + 1] = {
  10059. [NLBL_CALIPSO_A_MTYPE] = { .type = NLA_U32 },
  10060. };
  10061. +static const struct netlbl_calipso_ops *calipso_ops;
  10062. +
  10063. +/**
  10064. + * netlbl_calipso_ops_register - Register the CALIPSO operations
  10065. + * @ops: ops to register
  10066. + *
  10067. + * Description:
  10068. + * Register the CALIPSO packet engine operations.
  10069. + *
  10070. + */
  10071. +const struct netlbl_calipso_ops *
  10072. +netlbl_calipso_ops_register(const struct netlbl_calipso_ops *ops)
  10073. +{
  10074. + return xchg(&calipso_ops, ops);
  10075. +}
  10076. +EXPORT_SYMBOL(netlbl_calipso_ops_register);
  10077. +
  10078. +static const struct netlbl_calipso_ops *netlbl_calipso_ops_get(void)
  10079. +{
  10080. + return ACCESS_ONCE(calipso_ops);
  10081. +}
  10082. +
  10083. /* NetLabel Command Handlers
  10084. */
  10085. /**
  10086. @@ -110,16 +132,19 @@ static int netlbl_calipso_add_pass(struct genl_info *info,
  10087. *
  10088. */
  10089. static int netlbl_calipso_add(struct sk_buff *skb, struct genl_info *info)
  10090. -
  10091. {
  10092. int ret_val = -EINVAL;
  10093. struct netlbl_audit audit_info;
  10094. + const struct netlbl_calipso_ops *ops = netlbl_calipso_ops_get();
  10095. if (!info->attrs[NLBL_CALIPSO_A_DOI] ||
  10096. !info->attrs[NLBL_CALIPSO_A_MTYPE])
  10097. return -EINVAL;
  10098. - netlbl_netlink_auditinfo(skb, &audit_info);
  10099. + if (!ops)
  10100. + return -EOPNOTSUPP;
  10101. +
  10102. + netlbl_netlink_auditinfo(&audit_info);
  10103. switch (nla_get_u32(info->attrs[NLBL_CALIPSO_A_MTYPE])) {
  10104. case CALIPSO_MAP_PASS:
  10105. ret_val = netlbl_calipso_add_pass(info, &audit_info);
  10106. @@ -301,7 +326,7 @@ static int netlbl_calipso_remove(struct sk_buff *skb, struct genl_info *info)
  10107. if (!info->attrs[NLBL_CALIPSO_A_DOI])
  10108. return -EINVAL;
  10109. - netlbl_netlink_auditinfo(skb, &audit_info);
  10110. + netlbl_netlink_auditinfo(&audit_info);
  10111. cb_arg.doi = nla_get_u32(info->attrs[NLBL_CALIPSO_A_DOI]);
  10112. cb_arg.audit_info = &audit_info;
  10113. ret_val = netlbl_domhsh_walk(&skip_bkt, &skip_chain,
  10114. @@ -375,27 +400,6 @@ int __init netlbl_calipso_genl_init(void)
  10115. return genl_register_family(&netlbl_calipso_gnl_family);
  10116. }
  10117. -static const struct netlbl_calipso_ops *calipso_ops;
  10118. -
  10119. -/**
  10120. - * netlbl_calipso_ops_register - Register the CALIPSO operations
  10121. - *
  10122. - * Description:
  10123. - * Register the CALIPSO packet engine operations.
  10124. - *
  10125. - */
  10126. -const struct netlbl_calipso_ops *
  10127. -netlbl_calipso_ops_register(const struct netlbl_calipso_ops *ops)
  10128. -{
  10129. - return xchg(&calipso_ops, ops);
  10130. -}
  10131. -EXPORT_SYMBOL(netlbl_calipso_ops_register);
  10132. -
  10133. -static const struct netlbl_calipso_ops *netlbl_calipso_ops_get(void)
  10134. -{
  10135. - return ACCESS_ONCE(calipso_ops);
  10136. -}
  10137. -
  10138. /**
  10139. * calipso_doi_add - Add a new DOI to the CALIPSO protocol engine
  10140. * @doi_def: the DOI structure
  10141. diff --git net/netlabel/netlabel_cipso_v4.c net/netlabel/netlabel_cipso_v4.c
  10142. index e252f62bb8c2..a0a145db3fc7 100644
  10143. --- linux-4.14.336/net/netlabel/netlabel_cipso_v4.c
  10144. +++ linux-4.14.336/net/netlabel/netlabel_cipso_v4.c
  10145. @@ -420,7 +420,7 @@ static int netlbl_cipsov4_add(struct sk_buff *skb, struct genl_info *info)
  10146. !info->attrs[NLBL_CIPSOV4_A_MTYPE])
  10147. return -EINVAL;
  10148. - netlbl_netlink_auditinfo(skb, &audit_info);
  10149. + netlbl_netlink_auditinfo(&audit_info);
  10150. switch (nla_get_u32(info->attrs[NLBL_CIPSOV4_A_MTYPE])) {
  10151. case CIPSO_V4_MAP_TRANS:
  10152. ret_val = netlbl_cipsov4_add_std(info, &audit_info);
  10153. @@ -715,7 +715,7 @@ static int netlbl_cipsov4_remove(struct sk_buff *skb, struct genl_info *info)
  10154. if (!info->attrs[NLBL_CIPSOV4_A_DOI])
  10155. return -EINVAL;
  10156. - netlbl_netlink_auditinfo(skb, &audit_info);
  10157. + netlbl_netlink_auditinfo(&audit_info);
  10158. cb_arg.doi = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_DOI]);
  10159. cb_arg.audit_info = &audit_info;
  10160. ret_val = netlbl_domhsh_walk(&skip_bkt, &skip_chain,
  10161. diff --git net/netlabel/netlabel_mgmt.c net/netlabel/netlabel_mgmt.c
  10162. index 71ba69cb50c9..43c51242dcd2 100644
  10163. --- linux-4.14.336/net/netlabel/netlabel_mgmt.c
  10164. +++ linux-4.14.336/net/netlabel/netlabel_mgmt.c
  10165. @@ -447,7 +447,7 @@ static int netlbl_mgmt_add(struct sk_buff *skb, struct genl_info *info)
  10166. (info->attrs[NLBL_MGMT_A_IPV6MASK] != NULL)))
  10167. return -EINVAL;
  10168. - netlbl_netlink_auditinfo(skb, &audit_info);
  10169. + netlbl_netlink_auditinfo(&audit_info);
  10170. return netlbl_mgmt_add_common(info, &audit_info);
  10171. }
  10172. @@ -470,7 +470,7 @@ static int netlbl_mgmt_remove(struct sk_buff *skb, struct genl_info *info)
  10173. if (!info->attrs[NLBL_MGMT_A_DOMAIN])
  10174. return -EINVAL;
  10175. - netlbl_netlink_auditinfo(skb, &audit_info);
  10176. + netlbl_netlink_auditinfo(&audit_info);
  10177. domain = nla_data(info->attrs[NLBL_MGMT_A_DOMAIN]);
  10178. return netlbl_domhsh_remove(domain, AF_UNSPEC, &audit_info);
  10179. @@ -570,7 +570,7 @@ static int netlbl_mgmt_adddef(struct sk_buff *skb, struct genl_info *info)
  10180. (info->attrs[NLBL_MGMT_A_IPV6MASK] != NULL)))
  10181. return -EINVAL;
  10182. - netlbl_netlink_auditinfo(skb, &audit_info);
  10183. + netlbl_netlink_auditinfo(&audit_info);
  10184. return netlbl_mgmt_add_common(info, &audit_info);
  10185. }
  10186. @@ -589,7 +589,7 @@ static int netlbl_mgmt_removedef(struct sk_buff *skb, struct genl_info *info)
  10187. {
  10188. struct netlbl_audit audit_info;
  10189. - netlbl_netlink_auditinfo(skb, &audit_info);
  10190. + netlbl_netlink_auditinfo(&audit_info);
  10191. return netlbl_domhsh_remove_default(AF_UNSPEC, &audit_info);
  10192. }
  10193. diff --git net/netlabel/netlabel_unlabeled.c net/netlabel/netlabel_unlabeled.c
  10194. index 0067f472367b..ff52ff2278ed 100644
  10195. --- linux-4.14.336/net/netlabel/netlabel_unlabeled.c
  10196. +++ linux-4.14.336/net/netlabel/netlabel_unlabeled.c
  10197. @@ -827,7 +827,7 @@ static int netlbl_unlabel_accept(struct sk_buff *skb, struct genl_info *info)
  10198. if (info->attrs[NLBL_UNLABEL_A_ACPTFLG]) {
  10199. value = nla_get_u8(info->attrs[NLBL_UNLABEL_A_ACPTFLG]);
  10200. if (value == 1 || value == 0) {
  10201. - netlbl_netlink_auditinfo(skb, &audit_info);
  10202. + netlbl_netlink_auditinfo(&audit_info);
  10203. netlbl_unlabel_acceptflg_set(value, &audit_info);
  10204. return 0;
  10205. }
  10206. @@ -910,7 +910,7 @@ static int netlbl_unlabel_staticadd(struct sk_buff *skb,
  10207. !info->attrs[NLBL_UNLABEL_A_IPV6MASK])))
  10208. return -EINVAL;
  10209. - netlbl_netlink_auditinfo(skb, &audit_info);
  10210. + netlbl_netlink_auditinfo(&audit_info);
  10211. ret_val = netlbl_unlabel_addrinfo_get(info, &addr, &mask, &addr_len);
  10212. if (ret_val != 0)
  10213. @@ -960,7 +960,7 @@ static int netlbl_unlabel_staticadddef(struct sk_buff *skb,
  10214. !info->attrs[NLBL_UNLABEL_A_IPV6MASK])))
  10215. return -EINVAL;
  10216. - netlbl_netlink_auditinfo(skb, &audit_info);
  10217. + netlbl_netlink_auditinfo(&audit_info);
  10218. ret_val = netlbl_unlabel_addrinfo_get(info, &addr, &mask, &addr_len);
  10219. if (ret_val != 0)
  10220. @@ -1007,7 +1007,7 @@ static int netlbl_unlabel_staticremove(struct sk_buff *skb,
  10221. !info->attrs[NLBL_UNLABEL_A_IPV6MASK])))
  10222. return -EINVAL;
  10223. - netlbl_netlink_auditinfo(skb, &audit_info);
  10224. + netlbl_netlink_auditinfo(&audit_info);
  10225. ret_val = netlbl_unlabel_addrinfo_get(info, &addr, &mask, &addr_len);
  10226. if (ret_val != 0)
  10227. @@ -1047,7 +1047,7 @@ static int netlbl_unlabel_staticremovedef(struct sk_buff *skb,
  10228. !info->attrs[NLBL_UNLABEL_A_IPV6MASK])))
  10229. return -EINVAL;
  10230. - netlbl_netlink_auditinfo(skb, &audit_info);
  10231. + netlbl_netlink_auditinfo(&audit_info);
  10232. ret_val = netlbl_unlabel_addrinfo_get(info, &addr, &mask, &addr_len);
  10233. if (ret_val != 0)
  10234. diff --git net/netlabel/netlabel_user.h net/netlabel/netlabel_user.h
  10235. index 4a397cde1a48..2c608677b43b 100644
  10236. --- linux-4.14.336/net/netlabel/netlabel_user.h
  10237. +++ linux-4.14.336/net/netlabel/netlabel_user.h
  10238. @@ -42,11 +42,9 @@
  10239. /**
  10240. * netlbl_netlink_auditinfo - Fetch the audit information from a NETLINK msg
  10241. - * @skb: the packet
  10242. * @audit_info: NetLabel audit information
  10243. */
  10244. -static inline void netlbl_netlink_auditinfo(struct sk_buff *skb,
  10245. - struct netlbl_audit *audit_info)
  10246. +static inline void netlbl_netlink_auditinfo(struct netlbl_audit *audit_info)
  10247. {
  10248. security_task_getsecid(current, &audit_info->secid);
  10249. audit_info->loginuid = audit_get_loginuid(current);
  10250. diff --git net/netlink/af_netlink.c net/netlink/af_netlink.c
  10251. index 89ece1f093e2..ee42244aada1 100644
  10252. --- linux-4.14.336/net/netlink/af_netlink.c
  10253. +++ linux-4.14.336/net/netlink/af_netlink.c
  10254. @@ -162,7 +162,7 @@ static inline u32 netlink_group_mask(u32 group)
  10255. static struct sk_buff *netlink_to_full_skb(const struct sk_buff *skb,
  10256. gfp_t gfp_mask)
  10257. {
  10258. - unsigned int len = skb_end_offset(skb);
  10259. + unsigned int len = skb->len;
  10260. struct sk_buff *new;
  10261. new = alloc_skb(len, gfp_mask);
  10262. @@ -342,7 +342,7 @@ static void netlink_skb_destructor(struct sk_buff *skb)
  10263. if (is_vmalloc_addr(skb->head)) {
  10264. if (!skb->cloned ||
  10265. !atomic_dec_return(&(skb_shinfo(skb)->dataref)))
  10266. - vfree(skb->head);
  10267. + vfree_atomic(skb->head);
  10268. skb->head = NULL;
  10269. }
  10270. diff --git net/nfc/nci/core.c net/nfc/nci/core.c
  10271. index d42c603dd635..2d9934dbbead 100644
  10272. --- linux-4.14.336/net/nfc/nci/core.c
  10273. +++ linux-4.14.336/net/nfc/nci/core.c
  10274. @@ -1209,6 +1209,10 @@ void nci_free_device(struct nci_dev *ndev)
  10275. {
  10276. nfc_free_device(ndev->nfc_dev);
  10277. nci_hci_deallocate(ndev);
  10278. +
  10279. + /* drop partial rx data packet if present */
  10280. + if (ndev->rx_data_reassembly)
  10281. + kfree_skb(ndev->rx_data_reassembly);
  10282. kfree(ndev);
  10283. }
  10284. EXPORT_SYMBOL(nci_free_device);
  10285. diff --git net/packet/af_packet.c net/packet/af_packet.c
  10286. index ea29453fcf7a..6a02cf8d7141 100644
  10287. --- linux-4.14.336/net/packet/af_packet.c
  10288. +++ linux-4.14.336/net/packet/af_packet.c
  10289. @@ -1890,7 +1890,7 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev,
  10290. */
  10291. spkt->spkt_family = dev->type;
  10292. - strlcpy(spkt->spkt_device, dev->name, sizeof(spkt->spkt_device));
  10293. + strscpy(spkt->spkt_device, dev->name, sizeof(spkt->spkt_device));
  10294. spkt->spkt_protocol = skb->protocol;
  10295. /*
  10296. @@ -3537,7 +3537,7 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr,
  10297. rcu_read_lock();
  10298. dev = dev_get_by_index_rcu(sock_net(sk), READ_ONCE(pkt_sk(sk)->ifindex));
  10299. if (dev)
  10300. - strlcpy(uaddr->sa_data, dev->name, sizeof(uaddr->sa_data));
  10301. + strscpy(uaddr->sa_data, dev->name, sizeof(uaddr->sa_data));
  10302. rcu_read_unlock();
  10303. *uaddr_len = sizeof(*uaddr);
  10304. diff --git net/rds/af_rds.c net/rds/af_rds.c
  10305. index b405f77d664c..2628c1d3844e 100644
  10306. --- linux-4.14.336/net/rds/af_rds.c
  10307. +++ linux-4.14.336/net/rds/af_rds.c
  10308. @@ -315,7 +315,7 @@ static int rds_recv_track_latency(struct rds_sock *rs, char __user *optval,
  10309. rs->rs_rx_traces = trace.rx_traces;
  10310. for (i = 0; i < rs->rs_rx_traces; i++) {
  10311. - if (trace.rx_trace_pos[i] > RDS_MSG_RX_DGRAM_TRACE_MAX) {
  10312. + if (trace.rx_trace_pos[i] >= RDS_MSG_RX_DGRAM_TRACE_MAX) {
  10313. rs->rs_rx_traces = 0;
  10314. return -EFAULT;
  10315. }
  10316. diff --git net/rxrpc/conn_event.c net/rxrpc/conn_event.c
  10317. index 2432c118397f..8d14aebae621 100644
  10318. --- linux-4.14.336/net/rxrpc/conn_event.c
  10319. +++ linux-4.14.336/net/rxrpc/conn_event.c
  10320. @@ -48,6 +48,14 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
  10321. _enter("%d", conn->debug_id);
  10322. + if (sp && sp->hdr.type == RXRPC_PACKET_TYPE_ACK) {
  10323. + if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),
  10324. + &pkt.ack, sizeof(pkt.ack)) < 0)
  10325. + return;
  10326. + if (pkt.ack.reason == RXRPC_ACK_PING_RESPONSE)
  10327. + return;
  10328. + }
  10329. +
  10330. chan = &conn->channels[sp->hdr.cid & RXRPC_CHANNELMASK];
  10331. /* If the last call got moved on whilst we were waiting to run, just
  10332. diff --git net/rxrpc/conn_service.c net/rxrpc/conn_service.c
  10333. index f6fcdb3130a1..7c5745997cd4 100644
  10334. --- linux-4.14.336/net/rxrpc/conn_service.c
  10335. +++ linux-4.14.336/net/rxrpc/conn_service.c
  10336. @@ -29,7 +29,7 @@ struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *peer,
  10337. struct rxrpc_conn_proto k;
  10338. struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
  10339. struct rb_node *p;
  10340. - unsigned int seq = 0;
  10341. + unsigned int seq = 1;
  10342. k.epoch = sp->hdr.epoch;
  10343. k.cid = sp->hdr.cid & RXRPC_CIDMASK;
  10344. @@ -39,6 +39,7 @@ struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *peer,
  10345. * under just the RCU read lock, so we have to check for
  10346. * changes.
  10347. */
  10348. + seq++; /* 2 on the 1st/lockless path, otherwise odd */
  10349. read_seqbegin_or_lock(&peer->service_conn_lock, &seq);
  10350. p = rcu_dereference_raw(peer->service_conns.rb_node);
  10351. diff --git net/sched/Kconfig net/sched/Kconfig
  10352. index 782114a230ae..1a3ee928c57c 100644
  10353. --- linux-4.14.336/net/sched/Kconfig
  10354. +++ linux-4.14.336/net/sched/Kconfig
  10355. @@ -44,23 +44,6 @@ if NET_SCHED
  10356. comment "Queueing/Scheduling"
  10357. -config NET_SCH_CBQ
  10358. - tristate "Class Based Queueing (CBQ)"
  10359. - ---help---
  10360. - Say Y here if you want to use the Class-Based Queueing (CBQ) packet
  10361. - scheduling algorithm. This algorithm classifies the waiting packets
  10362. - into a tree-like hierarchy of classes; the leaves of this tree are
  10363. - in turn scheduled by separate algorithms.
  10364. -
  10365. - See the top of <file:net/sched/sch_cbq.c> for more details.
  10366. -
  10367. - CBQ is a commonly used scheduler, so if you're unsure, you should
  10368. - say Y here. Then say Y to all the queueing algorithms below that you
  10369. - want to use as leaf disciplines.
  10370. -
  10371. - To compile this code as a module, choose M here: the
  10372. - module will be called sch_cbq.
  10373. -
  10374. config NET_SCH_HTB
  10375. tristate "Hierarchical Token Bucket (HTB)"
  10376. ---help---
  10377. @@ -84,20 +67,6 @@ config NET_SCH_HFSC
  10378. To compile this code as a module, choose M here: the
  10379. module will be called sch_hfsc.
  10380. -config NET_SCH_ATM
  10381. - tristate "ATM Virtual Circuits (ATM)"
  10382. - depends on ATM
  10383. - ---help---
  10384. - Say Y here if you want to use the ATM pseudo-scheduler. This
  10385. - provides a framework for invoking classifiers, which in turn
  10386. - select classes of this queuing discipline. Each class maps
  10387. - the flow(s) it is handling to a given virtual circuit.
  10388. -
  10389. - See the top of <file:net/sched/sch_atm.c> for more details.
  10390. -
  10391. - To compile this code as a module, choose M here: the
  10392. - module will be called sch_atm.
  10393. -
  10394. config NET_SCH_PRIO
  10395. tristate "Multi Band Priority Queueing (PRIO)"
  10396. ---help---
  10397. @@ -183,17 +152,6 @@ config NET_SCH_GRED
  10398. To compile this code as a module, choose M here: the
  10399. module will be called sch_gred.
  10400. -config NET_SCH_DSMARK
  10401. - tristate "Differentiated Services marker (DSMARK)"
  10402. - ---help---
  10403. - Say Y if you want to schedule packets according to the
  10404. - Differentiated Services architecture proposed in RFC 2475.
  10405. - Technical information on this method, with pointers to associated
  10406. - RFCs, is available at <http://www.gta.ufrj.br/diffserv/>.
  10407. -
  10408. - To compile this code as a module, choose M here: the
  10409. - module will be called sch_dsmark.
  10410. -
  10411. config NET_SCH_NETEM
  10412. tristate "Network emulator (NETEM)"
  10413. ---help---
  10414. diff --git net/sched/Makefile net/sched/Makefile
  10415. index c156c182f546..b2c2cea1fd91 100644
  10416. --- linux-4.14.336/net/sched/Makefile
  10417. +++ linux-4.14.336/net/sched/Makefile
  10418. @@ -28,20 +28,17 @@ obj-$(CONFIG_NET_IFE_SKBPRIO) += act_meta_skbprio.o
  10419. obj-$(CONFIG_NET_IFE_SKBTCINDEX) += act_meta_skbtcindex.o
  10420. obj-$(CONFIG_NET_ACT_TUNNEL_KEY)+= act_tunnel_key.o
  10421. obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o
  10422. -obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
  10423. obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
  10424. obj-$(CONFIG_NET_SCH_HFSC) += sch_hfsc.o
  10425. obj-$(CONFIG_NET_SCH_RED) += sch_red.o
  10426. obj-$(CONFIG_NET_SCH_GRED) += sch_gred.o
  10427. obj-$(CONFIG_NET_SCH_INGRESS) += sch_ingress.o
  10428. -obj-$(CONFIG_NET_SCH_DSMARK) += sch_dsmark.o
  10429. obj-$(CONFIG_NET_SCH_SFB) += sch_sfb.o
  10430. obj-$(CONFIG_NET_SCH_SFQ) += sch_sfq.o
  10431. obj-$(CONFIG_NET_SCH_TBF) += sch_tbf.o
  10432. obj-$(CONFIG_NET_SCH_TEQL) += sch_teql.o
  10433. obj-$(CONFIG_NET_SCH_PRIO) += sch_prio.o
  10434. obj-$(CONFIG_NET_SCH_MULTIQ) += sch_multiq.o
  10435. -obj-$(CONFIG_NET_SCH_ATM) += sch_atm.o
  10436. obj-$(CONFIG_NET_SCH_NETEM) += sch_netem.o
  10437. obj-$(CONFIG_NET_SCH_DRR) += sch_drr.o
  10438. obj-$(CONFIG_NET_SCH_PLUG) += sch_plug.o
  10439. diff --git net/sched/sch_atm.c net/sched/sch_atm.c
  10440. deleted file mode 100644
  10441. index 184ce9050457..000000000000
  10442. --- linux-4.14.336/net/sched/sch_atm.c
  10443. +++ linux-4.14.336//dev/null
  10444. @@ -1,701 +0,0 @@
  10445. -/* net/sched/sch_atm.c - ATM VC selection "queueing discipline" */
  10446. -
  10447. -/* Written 1998-2000 by Werner Almesberger, EPFL ICA */
  10448. -
  10449. -#include <linux/module.h>
  10450. -#include <linux/slab.h>
  10451. -#include <linux/init.h>
  10452. -#include <linux/interrupt.h>
  10453. -#include <linux/string.h>
  10454. -#include <linux/errno.h>
  10455. -#include <linux/skbuff.h>
  10456. -#include <linux/atmdev.h>
  10457. -#include <linux/atmclip.h>
  10458. -#include <linux/rtnetlink.h>
  10459. -#include <linux/file.h> /* for fput */
  10460. -#include <net/netlink.h>
  10461. -#include <net/pkt_sched.h>
  10462. -#include <net/pkt_cls.h>
  10463. -
  10464. -/*
  10465. - * The ATM queuing discipline provides a framework for invoking classifiers
  10466. - * (aka "filters"), which in turn select classes of this queuing discipline.
  10467. - * Each class maps the flow(s) it is handling to a given VC. Multiple classes
  10468. - * may share the same VC.
  10469. - *
  10470. - * When creating a class, VCs are specified by passing the number of the open
  10471. - * socket descriptor by which the calling process references the VC. The kernel
  10472. - * keeps the VC open at least until all classes using it are removed.
  10473. - *
  10474. - * In this file, most functions are named atm_tc_* to avoid confusion with all
  10475. - * the atm_* in net/atm. This naming convention differs from what's used in the
  10476. - * rest of net/sched.
  10477. - *
  10478. - * Known bugs:
  10479. - * - sometimes messes up the IP stack
  10480. - * - any manipulations besides the few operations described in the README, are
  10481. - * untested and likely to crash the system
  10482. - * - should lock the flow while there is data in the queue (?)
  10483. - */
  10484. -
  10485. -#define VCC2FLOW(vcc) ((struct atm_flow_data *) ((vcc)->user_back))
  10486. -
  10487. -struct atm_flow_data {
  10488. - struct Qdisc_class_common common;
  10489. - struct Qdisc *q; /* FIFO, TBF, etc. */
  10490. - struct tcf_proto __rcu *filter_list;
  10491. - struct tcf_block *block;
  10492. - struct atm_vcc *vcc; /* VCC; NULL if VCC is closed */
  10493. - void (*old_pop)(struct atm_vcc *vcc,
  10494. - struct sk_buff *skb); /* chaining */
  10495. - struct atm_qdisc_data *parent; /* parent qdisc */
  10496. - struct socket *sock; /* for closing */
  10497. - int ref; /* reference count */
  10498. - struct gnet_stats_basic_packed bstats;
  10499. - struct gnet_stats_queue qstats;
  10500. - struct list_head list;
  10501. - struct atm_flow_data *excess; /* flow for excess traffic;
  10502. - NULL to set CLP instead */
  10503. - int hdr_len;
  10504. - unsigned char hdr[0]; /* header data; MUST BE LAST */
  10505. -};
  10506. -
  10507. -struct atm_qdisc_data {
  10508. - struct atm_flow_data link; /* unclassified skbs go here */
  10509. - struct list_head flows; /* NB: "link" is also on this
  10510. - list */
  10511. - struct tasklet_struct task; /* dequeue tasklet */
  10512. -};
  10513. -
  10514. -/* ------------------------- Class/flow operations ------------------------- */
  10515. -
  10516. -static inline struct atm_flow_data *lookup_flow(struct Qdisc *sch, u32 classid)
  10517. -{
  10518. - struct atm_qdisc_data *p = qdisc_priv(sch);
  10519. - struct atm_flow_data *flow;
  10520. -
  10521. - list_for_each_entry(flow, &p->flows, list) {
  10522. - if (flow->common.classid == classid)
  10523. - return flow;
  10524. - }
  10525. - return NULL;
  10526. -}
  10527. -
  10528. -static int atm_tc_graft(struct Qdisc *sch, unsigned long arg,
  10529. - struct Qdisc *new, struct Qdisc **old)
  10530. -{
  10531. - struct atm_qdisc_data *p = qdisc_priv(sch);
  10532. - struct atm_flow_data *flow = (struct atm_flow_data *)arg;
  10533. -
  10534. - pr_debug("atm_tc_graft(sch %p,[qdisc %p],flow %p,new %p,old %p)\n",
  10535. - sch, p, flow, new, old);
  10536. - if (list_empty(&flow->list))
  10537. - return -EINVAL;
  10538. - if (!new)
  10539. - new = &noop_qdisc;
  10540. - *old = flow->q;
  10541. - flow->q = new;
  10542. - if (*old)
  10543. - qdisc_reset(*old);
  10544. - return 0;
  10545. -}
  10546. -
  10547. -static struct Qdisc *atm_tc_leaf(struct Qdisc *sch, unsigned long cl)
  10548. -{
  10549. - struct atm_flow_data *flow = (struct atm_flow_data *)cl;
  10550. -
  10551. - pr_debug("atm_tc_leaf(sch %p,flow %p)\n", sch, flow);
  10552. - return flow ? flow->q : NULL;
  10553. -}
  10554. -
  10555. -static unsigned long atm_tc_find(struct Qdisc *sch, u32 classid)
  10556. -{
  10557. - struct atm_qdisc_data *p __maybe_unused = qdisc_priv(sch);
  10558. - struct atm_flow_data *flow;
  10559. -
  10560. - pr_debug("%s(sch %p,[qdisc %p],classid %x)\n", __func__, sch, p, classid);
  10561. - flow = lookup_flow(sch, classid);
  10562. - pr_debug("%s: flow %p\n", __func__, flow);
  10563. - return (unsigned long)flow;
  10564. -}
  10565. -
  10566. -static unsigned long atm_tc_bind_filter(struct Qdisc *sch,
  10567. - unsigned long parent, u32 classid)
  10568. -{
  10569. - struct atm_qdisc_data *p __maybe_unused = qdisc_priv(sch);
  10570. - struct atm_flow_data *flow;
  10571. -
  10572. - pr_debug("%s(sch %p,[qdisc %p],classid %x)\n", __func__, sch, p, classid);
  10573. - flow = lookup_flow(sch, classid);
  10574. - if (flow)
  10575. - flow->ref++;
  10576. - pr_debug("%s: flow %p\n", __func__, flow);
  10577. - return (unsigned long)flow;
  10578. -}
  10579. -
  10580. -/*
  10581. - * atm_tc_put handles all destructions, including the ones that are explicitly
  10582. - * requested (atm_tc_destroy, etc.). The assumption here is that we never drop
  10583. - * anything that still seems to be in use.
  10584. - */
  10585. -static void atm_tc_put(struct Qdisc *sch, unsigned long cl)
  10586. -{
  10587. - struct atm_qdisc_data *p = qdisc_priv(sch);
  10588. - struct atm_flow_data *flow = (struct atm_flow_data *)cl;
  10589. -
  10590. - pr_debug("atm_tc_put(sch %p,[qdisc %p],flow %p)\n", sch, p, flow);
  10591. - if (--flow->ref)
  10592. - return;
  10593. - pr_debug("atm_tc_put: destroying\n");
  10594. - list_del_init(&flow->list);
  10595. - pr_debug("atm_tc_put: qdisc %p\n", flow->q);
  10596. - qdisc_destroy(flow->q);
  10597. - tcf_block_put(flow->block);
  10598. - if (flow->sock) {
  10599. - pr_debug("atm_tc_put: f_count %ld\n",
  10600. - file_count(flow->sock->file));
  10601. - flow->vcc->pop = flow->old_pop;
  10602. - sockfd_put(flow->sock);
  10603. - }
  10604. - if (flow->excess)
  10605. - atm_tc_put(sch, (unsigned long)flow->excess);
  10606. - if (flow != &p->link)
  10607. - kfree(flow);
  10608. - /*
  10609. - * If flow == &p->link, the qdisc no longer works at this point and
  10610. - * needs to be removed. (By the caller of atm_tc_put.)
  10611. - */
  10612. -}
  10613. -
  10614. -static void sch_atm_pop(struct atm_vcc *vcc, struct sk_buff *skb)
  10615. -{
  10616. - struct atm_qdisc_data *p = VCC2FLOW(vcc)->parent;
  10617. -
  10618. - pr_debug("sch_atm_pop(vcc %p,skb %p,[qdisc %p])\n", vcc, skb, p);
  10619. - VCC2FLOW(vcc)->old_pop(vcc, skb);
  10620. - tasklet_schedule(&p->task);
  10621. -}
  10622. -
  10623. -static const u8 llc_oui_ip[] = {
  10624. - 0xaa, /* DSAP: non-ISO */
  10625. - 0xaa, /* SSAP: non-ISO */
  10626. - 0x03, /* Ctrl: Unnumbered Information Command PDU */
  10627. - 0x00, /* OUI: EtherType */
  10628. - 0x00, 0x00,
  10629. - 0x08, 0x00
  10630. -}; /* Ethertype IP (0800) */
  10631. -
  10632. -static const struct nla_policy atm_policy[TCA_ATM_MAX + 1] = {
  10633. - [TCA_ATM_FD] = { .type = NLA_U32 },
  10634. - [TCA_ATM_EXCESS] = { .type = NLA_U32 },
  10635. -};
  10636. -
  10637. -static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
  10638. - struct nlattr **tca, unsigned long *arg)
  10639. -{
  10640. - struct atm_qdisc_data *p = qdisc_priv(sch);
  10641. - struct atm_flow_data *flow = (struct atm_flow_data *)*arg;
  10642. - struct atm_flow_data *excess = NULL;
  10643. - struct nlattr *opt = tca[TCA_OPTIONS];
  10644. - struct nlattr *tb[TCA_ATM_MAX + 1];
  10645. - struct socket *sock;
  10646. - int fd, error, hdr_len;
  10647. - void *hdr;
  10648. -
  10649. - pr_debug("atm_tc_change(sch %p,[qdisc %p],classid %x,parent %x,"
  10650. - "flow %p,opt %p)\n", sch, p, classid, parent, flow, opt);
  10651. - /*
  10652. - * The concept of parents doesn't apply for this qdisc.
  10653. - */
  10654. - if (parent && parent != TC_H_ROOT && parent != sch->handle)
  10655. - return -EINVAL;
  10656. - /*
  10657. - * ATM classes cannot be changed. In order to change properties of the
  10658. - * ATM connection, that socket needs to be modified directly (via the
  10659. - * native ATM API. In order to send a flow to a different VC, the old
  10660. - * class needs to be removed and a new one added. (This may be changed
  10661. - * later.)
  10662. - */
  10663. - if (flow)
  10664. - return -EBUSY;
  10665. - if (opt == NULL)
  10666. - return -EINVAL;
  10667. -
  10668. - error = nla_parse_nested(tb, TCA_ATM_MAX, opt, atm_policy, NULL);
  10669. - if (error < 0)
  10670. - return error;
  10671. -
  10672. - if (!tb[TCA_ATM_FD])
  10673. - return -EINVAL;
  10674. - fd = nla_get_u32(tb[TCA_ATM_FD]);
  10675. - pr_debug("atm_tc_change: fd %d\n", fd);
  10676. - if (tb[TCA_ATM_HDR]) {
  10677. - hdr_len = nla_len(tb[TCA_ATM_HDR]);
  10678. - hdr = nla_data(tb[TCA_ATM_HDR]);
  10679. - } else {
  10680. - hdr_len = RFC1483LLC_LEN;
  10681. - hdr = NULL; /* default LLC/SNAP for IP */
  10682. - }
  10683. - if (!tb[TCA_ATM_EXCESS])
  10684. - excess = NULL;
  10685. - else {
  10686. - excess = (struct atm_flow_data *)
  10687. - atm_tc_find(sch, nla_get_u32(tb[TCA_ATM_EXCESS]));
  10688. - if (!excess)
  10689. - return -ENOENT;
  10690. - }
  10691. - pr_debug("atm_tc_change: type %d, payload %d, hdr_len %d\n",
  10692. - opt->nla_type, nla_len(opt), hdr_len);
  10693. - sock = sockfd_lookup(fd, &error);
  10694. - if (!sock)
  10695. - return error; /* f_count++ */
  10696. - pr_debug("atm_tc_change: f_count %ld\n", file_count(sock->file));
  10697. - if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) {
  10698. - error = -EPROTOTYPE;
  10699. - goto err_out;
  10700. - }
  10701. - /* @@@ should check if the socket is really operational or we'll crash
  10702. - on vcc->send */
  10703. - if (classid) {
  10704. - if (TC_H_MAJ(classid ^ sch->handle)) {
  10705. - pr_debug("atm_tc_change: classid mismatch\n");
  10706. - error = -EINVAL;
  10707. - goto err_out;
  10708. - }
  10709. - } else {
  10710. - int i;
  10711. - unsigned long cl;
  10712. -
  10713. - for (i = 1; i < 0x8000; i++) {
  10714. - classid = TC_H_MAKE(sch->handle, 0x8000 | i);
  10715. - cl = atm_tc_find(sch, classid);
  10716. - if (!cl)
  10717. - break;
  10718. - }
  10719. - }
  10720. - pr_debug("atm_tc_change: new id %x\n", classid);
  10721. - flow = kzalloc(sizeof(struct atm_flow_data) + hdr_len, GFP_KERNEL);
  10722. - pr_debug("atm_tc_change: flow %p\n", flow);
  10723. - if (!flow) {
  10724. - error = -ENOBUFS;
  10725. - goto err_out;
  10726. - }
  10727. -
  10728. - error = tcf_block_get(&flow->block, &flow->filter_list);
  10729. - if (error) {
  10730. - kfree(flow);
  10731. - goto err_out;
  10732. - }
  10733. -
  10734. - flow->q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, classid);
  10735. - if (!flow->q)
  10736. - flow->q = &noop_qdisc;
  10737. - pr_debug("atm_tc_change: qdisc %p\n", flow->q);
  10738. - flow->sock = sock;
  10739. - flow->vcc = ATM_SD(sock); /* speedup */
  10740. - flow->vcc->user_back = flow;
  10741. - pr_debug("atm_tc_change: vcc %p\n", flow->vcc);
  10742. - flow->old_pop = flow->vcc->pop;
  10743. - flow->parent = p;
  10744. - flow->vcc->pop = sch_atm_pop;
  10745. - flow->common.classid = classid;
  10746. - flow->ref = 1;
  10747. - flow->excess = excess;
  10748. - list_add(&flow->list, &p->link.list);
  10749. - flow->hdr_len = hdr_len;
  10750. - if (hdr)
  10751. - memcpy(flow->hdr, hdr, hdr_len);
  10752. - else
  10753. - memcpy(flow->hdr, llc_oui_ip, sizeof(llc_oui_ip));
  10754. - *arg = (unsigned long)flow;
  10755. - return 0;
  10756. -err_out:
  10757. - sockfd_put(sock);
  10758. - return error;
  10759. -}
  10760. -
  10761. -static int atm_tc_delete(struct Qdisc *sch, unsigned long arg)
  10762. -{
  10763. - struct atm_qdisc_data *p = qdisc_priv(sch);
  10764. - struct atm_flow_data *flow = (struct atm_flow_data *)arg;
  10765. -
  10766. - pr_debug("atm_tc_delete(sch %p,[qdisc %p],flow %p)\n", sch, p, flow);
  10767. - if (list_empty(&flow->list))
  10768. - return -EINVAL;
  10769. - if (rcu_access_pointer(flow->filter_list) || flow == &p->link)
  10770. - return -EBUSY;
  10771. - /*
  10772. - * Reference count must be 2: one for "keepalive" (set at class
  10773. - * creation), and one for the reference held when calling delete.
  10774. - */
  10775. - if (flow->ref < 2) {
  10776. - pr_err("atm_tc_delete: flow->ref == %d\n", flow->ref);
  10777. - return -EINVAL;
  10778. - }
  10779. - if (flow->ref > 2)
  10780. - return -EBUSY; /* catch references via excess, etc. */
  10781. - atm_tc_put(sch, arg);
  10782. - return 0;
  10783. -}
  10784. -
  10785. -static void atm_tc_walk(struct Qdisc *sch, struct qdisc_walker *walker)
  10786. -{
  10787. - struct atm_qdisc_data *p = qdisc_priv(sch);
  10788. - struct atm_flow_data *flow;
  10789. -
  10790. - pr_debug("atm_tc_walk(sch %p,[qdisc %p],walker %p)\n", sch, p, walker);
  10791. - if (walker->stop)
  10792. - return;
  10793. - list_for_each_entry(flow, &p->flows, list) {
  10794. - if (walker->count >= walker->skip &&
  10795. - walker->fn(sch, (unsigned long)flow, walker) < 0) {
  10796. - walker->stop = 1;
  10797. - break;
  10798. - }
  10799. - walker->count++;
  10800. - }
  10801. -}
  10802. -
  10803. -static struct tcf_block *atm_tc_tcf_block(struct Qdisc *sch, unsigned long cl)
  10804. -{
  10805. - struct atm_qdisc_data *p = qdisc_priv(sch);
  10806. - struct atm_flow_data *flow = (struct atm_flow_data *)cl;
  10807. -
  10808. - pr_debug("atm_tc_find_tcf(sch %p,[qdisc %p],flow %p)\n", sch, p, flow);
  10809. - return flow ? flow->block : p->link.block;
  10810. -}
  10811. -
  10812. -/* --------------------------- Qdisc operations ---------------------------- */
  10813. -
  10814. -static int atm_tc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
  10815. - struct sk_buff **to_free)
  10816. -{
  10817. - struct atm_qdisc_data *p = qdisc_priv(sch);
  10818. - struct atm_flow_data *flow;
  10819. - struct tcf_result res;
  10820. - int result;
  10821. - int ret = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
  10822. -
  10823. - pr_debug("atm_tc_enqueue(skb %p,sch %p,[qdisc %p])\n", skb, sch, p);
  10824. - result = TC_ACT_OK; /* be nice to gcc */
  10825. - flow = NULL;
  10826. - if (TC_H_MAJ(skb->priority) != sch->handle ||
  10827. - !(flow = (struct atm_flow_data *)atm_tc_find(sch, skb->priority))) {
  10828. - struct tcf_proto *fl;
  10829. -
  10830. - list_for_each_entry(flow, &p->flows, list) {
  10831. - fl = rcu_dereference_bh(flow->filter_list);
  10832. - if (fl) {
  10833. - result = tcf_classify(skb, fl, &res, true);
  10834. - if (result < 0)
  10835. - continue;
  10836. - if (result == TC_ACT_SHOT)
  10837. - goto done;
  10838. -
  10839. - flow = (struct atm_flow_data *)res.class;
  10840. - if (!flow)
  10841. - flow = lookup_flow(sch, res.classid);
  10842. - goto drop;
  10843. - }
  10844. - }
  10845. - flow = NULL;
  10846. -done:
  10847. - ;
  10848. - }
  10849. - if (!flow) {
  10850. - flow = &p->link;
  10851. - } else {
  10852. - if (flow->vcc)
  10853. - ATM_SKB(skb)->atm_options = flow->vcc->atm_options;
  10854. - /*@@@ looks good ... but it's not supposed to work :-) */
  10855. -#ifdef CONFIG_NET_CLS_ACT
  10856. - switch (result) {
  10857. - case TC_ACT_QUEUED:
  10858. - case TC_ACT_STOLEN:
  10859. - case TC_ACT_TRAP:
  10860. - __qdisc_drop(skb, to_free);
  10861. - return NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
  10862. - case TC_ACT_SHOT:
  10863. - __qdisc_drop(skb, to_free);
  10864. - goto drop;
  10865. - case TC_ACT_RECLASSIFY:
  10866. - if (flow->excess)
  10867. - flow = flow->excess;
  10868. - else
  10869. - ATM_SKB(skb)->atm_options |= ATM_ATMOPT_CLP;
  10870. - break;
  10871. - }
  10872. -#endif
  10873. - }
  10874. -
  10875. - ret = qdisc_enqueue(skb, flow->q, to_free);
  10876. - if (ret != NET_XMIT_SUCCESS) {
  10877. -drop: __maybe_unused
  10878. - if (net_xmit_drop_count(ret)) {
  10879. - qdisc_qstats_drop(sch);
  10880. - if (flow)
  10881. - flow->qstats.drops++;
  10882. - }
  10883. - return ret;
  10884. - }
  10885. - /*
  10886. - * Okay, this may seem weird. We pretend we've dropped the packet if
  10887. - * it goes via ATM. The reason for this is that the outer qdisc
  10888. - * expects to be able to q->dequeue the packet later on if we return
  10889. - * success at this place. Also, sch->q.qdisc needs to reflect whether
  10890. - * there is a packet egligible for dequeuing or not. Note that the
  10891. - * statistics of the outer qdisc are necessarily wrong because of all
  10892. - * this. There's currently no correct solution for this.
  10893. - */
  10894. - if (flow == &p->link) {
  10895. - sch->q.qlen++;
  10896. - return NET_XMIT_SUCCESS;
  10897. - }
  10898. - tasklet_schedule(&p->task);
  10899. - return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
  10900. -}
  10901. -
  10902. -/*
  10903. - * Dequeue packets and send them over ATM. Note that we quite deliberately
  10904. - * avoid checking net_device's flow control here, simply because sch_atm
  10905. - * uses its own channels, which have nothing to do with any CLIP/LANE/or
  10906. - * non-ATM interfaces.
  10907. - */
  10908. -
  10909. -static void sch_atm_dequeue(unsigned long data)
  10910. -{
  10911. - struct Qdisc *sch = (struct Qdisc *)data;
  10912. - struct atm_qdisc_data *p = qdisc_priv(sch);
  10913. - struct atm_flow_data *flow;
  10914. - struct sk_buff *skb;
  10915. -
  10916. - pr_debug("sch_atm_dequeue(sch %p,[qdisc %p])\n", sch, p);
  10917. - list_for_each_entry(flow, &p->flows, list) {
  10918. - if (flow == &p->link)
  10919. - continue;
  10920. - /*
  10921. - * If traffic is properly shaped, this won't generate nasty
  10922. - * little bursts. Otherwise, it may ... (but that's okay)
  10923. - */
  10924. - while ((skb = flow->q->ops->peek(flow->q))) {
  10925. - if (!atm_may_send(flow->vcc, skb->truesize))
  10926. - break;
  10927. -
  10928. - skb = qdisc_dequeue_peeked(flow->q);
  10929. - if (unlikely(!skb))
  10930. - break;
  10931. -
  10932. - qdisc_bstats_update(sch, skb);
  10933. - bstats_update(&flow->bstats, skb);
  10934. - pr_debug("atm_tc_dequeue: sending on class %p\n", flow);
  10935. - /* remove any LL header somebody else has attached */
  10936. - skb_pull(skb, skb_network_offset(skb));
  10937. - if (skb_headroom(skb) < flow->hdr_len) {
  10938. - struct sk_buff *new;
  10939. -
  10940. - new = skb_realloc_headroom(skb, flow->hdr_len);
  10941. - dev_kfree_skb(skb);
  10942. - if (!new)
  10943. - continue;
  10944. - skb = new;
  10945. - }
  10946. - pr_debug("sch_atm_dequeue: ip %p, data %p\n",
  10947. - skb_network_header(skb), skb->data);
  10948. - ATM_SKB(skb)->vcc = flow->vcc;
  10949. - memcpy(skb_push(skb, flow->hdr_len), flow->hdr,
  10950. - flow->hdr_len);
  10951. - refcount_add(skb->truesize,
  10952. - &sk_atm(flow->vcc)->sk_wmem_alloc);
  10953. - /* atm.atm_options are already set by atm_tc_enqueue */
  10954. - flow->vcc->send(flow->vcc, skb);
  10955. - }
  10956. - }
  10957. -}
  10958. -
  10959. -static struct sk_buff *atm_tc_dequeue(struct Qdisc *sch)
  10960. -{
  10961. - struct atm_qdisc_data *p = qdisc_priv(sch);
  10962. - struct sk_buff *skb;
  10963. -
  10964. - pr_debug("atm_tc_dequeue(sch %p,[qdisc %p])\n", sch, p);
  10965. - tasklet_schedule(&p->task);
  10966. - skb = qdisc_dequeue_peeked(p->link.q);
  10967. - if (skb)
  10968. - sch->q.qlen--;
  10969. - return skb;
  10970. -}
  10971. -
  10972. -static struct sk_buff *atm_tc_peek(struct Qdisc *sch)
  10973. -{
  10974. - struct atm_qdisc_data *p = qdisc_priv(sch);
  10975. -
  10976. - pr_debug("atm_tc_peek(sch %p,[qdisc %p])\n", sch, p);
  10977. -
  10978. - return p->link.q->ops->peek(p->link.q);
  10979. -}
  10980. -
  10981. -static int atm_tc_init(struct Qdisc *sch, struct nlattr *opt)
  10982. -{
  10983. - struct atm_qdisc_data *p = qdisc_priv(sch);
  10984. - int err;
  10985. -
  10986. - pr_debug("atm_tc_init(sch %p,[qdisc %p],opt %p)\n", sch, p, opt);
  10987. - INIT_LIST_HEAD(&p->flows);
  10988. - INIT_LIST_HEAD(&p->link.list);
  10989. - list_add(&p->link.list, &p->flows);
  10990. - p->link.q = qdisc_create_dflt(sch->dev_queue,
  10991. - &pfifo_qdisc_ops, sch->handle);
  10992. - if (!p->link.q)
  10993. - p->link.q = &noop_qdisc;
  10994. - pr_debug("atm_tc_init: link (%p) qdisc %p\n", &p->link, p->link.q);
  10995. - p->link.vcc = NULL;
  10996. - p->link.sock = NULL;
  10997. - p->link.common.classid = sch->handle;
  10998. - p->link.ref = 1;
  10999. -
  11000. - err = tcf_block_get(&p->link.block, &p->link.filter_list);
  11001. - if (err)
  11002. - return err;
  11003. -
  11004. - tasklet_init(&p->task, sch_atm_dequeue, (unsigned long)sch);
  11005. - return 0;
  11006. -}
  11007. -
  11008. -static void atm_tc_reset(struct Qdisc *sch)
  11009. -{
  11010. - struct atm_qdisc_data *p = qdisc_priv(sch);
  11011. - struct atm_flow_data *flow;
  11012. -
  11013. - pr_debug("atm_tc_reset(sch %p,[qdisc %p])\n", sch, p);
  11014. - list_for_each_entry(flow, &p->flows, list)
  11015. - qdisc_reset(flow->q);
  11016. - sch->q.qlen = 0;
  11017. -}
  11018. -
  11019. -static void atm_tc_destroy(struct Qdisc *sch)
  11020. -{
  11021. - struct atm_qdisc_data *p = qdisc_priv(sch);
  11022. - struct atm_flow_data *flow, *tmp;
  11023. -
  11024. - pr_debug("atm_tc_destroy(sch %p,[qdisc %p])\n", sch, p);
  11025. - list_for_each_entry(flow, &p->flows, list) {
  11026. - tcf_block_put(flow->block);
  11027. - flow->block = NULL;
  11028. - }
  11029. -
  11030. - list_for_each_entry_safe(flow, tmp, &p->flows, list) {
  11031. - if (flow->ref > 1)
  11032. - pr_err("atm_destroy: %p->ref = %d\n", flow, flow->ref);
  11033. - atm_tc_put(sch, (unsigned long)flow);
  11034. - }
  11035. - tasklet_kill(&p->task);
  11036. -}
  11037. -
  11038. -static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl,
  11039. - struct sk_buff *skb, struct tcmsg *tcm)
  11040. -{
  11041. - struct atm_qdisc_data *p = qdisc_priv(sch);
  11042. - struct atm_flow_data *flow = (struct atm_flow_data *)cl;
  11043. - struct nlattr *nest;
  11044. -
  11045. - pr_debug("atm_tc_dump_class(sch %p,[qdisc %p],flow %p,skb %p,tcm %p)\n",
  11046. - sch, p, flow, skb, tcm);
  11047. - if (list_empty(&flow->list))
  11048. - return -EINVAL;
  11049. - tcm->tcm_handle = flow->common.classid;
  11050. - tcm->tcm_info = flow->q->handle;
  11051. -
  11052. - nest = nla_nest_start(skb, TCA_OPTIONS);
  11053. - if (nest == NULL)
  11054. - goto nla_put_failure;
  11055. -
  11056. - if (nla_put(skb, TCA_ATM_HDR, flow->hdr_len, flow->hdr))
  11057. - goto nla_put_failure;
  11058. - if (flow->vcc) {
  11059. - struct sockaddr_atmpvc pvc;
  11060. - int state;
  11061. -
  11062. - memset(&pvc, 0, sizeof(pvc));
  11063. - pvc.sap_family = AF_ATMPVC;
  11064. - pvc.sap_addr.itf = flow->vcc->dev ? flow->vcc->dev->number : -1;
  11065. - pvc.sap_addr.vpi = flow->vcc->vpi;
  11066. - pvc.sap_addr.vci = flow->vcc->vci;
  11067. - if (nla_put(skb, TCA_ATM_ADDR, sizeof(pvc), &pvc))
  11068. - goto nla_put_failure;
  11069. - state = ATM_VF2VS(flow->vcc->flags);
  11070. - if (nla_put_u32(skb, TCA_ATM_STATE, state))
  11071. - goto nla_put_failure;
  11072. - }
  11073. - if (flow->excess) {
  11074. - if (nla_put_u32(skb, TCA_ATM_EXCESS, flow->common.classid))
  11075. - goto nla_put_failure;
  11076. - } else {
  11077. - if (nla_put_u32(skb, TCA_ATM_EXCESS, 0))
  11078. - goto nla_put_failure;
  11079. - }
  11080. - return nla_nest_end(skb, nest);
  11081. -
  11082. -nla_put_failure:
  11083. - nla_nest_cancel(skb, nest);
  11084. - return -1;
  11085. -}
  11086. -static int
  11087. -atm_tc_dump_class_stats(struct Qdisc *sch, unsigned long arg,
  11088. - struct gnet_dump *d)
  11089. -{
  11090. - struct atm_flow_data *flow = (struct atm_flow_data *)arg;
  11091. -
  11092. - if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch),
  11093. - d, NULL, &flow->bstats) < 0 ||
  11094. - gnet_stats_copy_queue(d, NULL, &flow->qstats, flow->q->q.qlen) < 0)
  11095. - return -1;
  11096. -
  11097. - return 0;
  11098. -}
  11099. -
  11100. -static int atm_tc_dump(struct Qdisc *sch, struct sk_buff *skb)
  11101. -{
  11102. - return 0;
  11103. -}
  11104. -
  11105. -static const struct Qdisc_class_ops atm_class_ops = {
  11106. - .graft = atm_tc_graft,
  11107. - .leaf = atm_tc_leaf,
  11108. - .find = atm_tc_find,
  11109. - .change = atm_tc_change,
  11110. - .delete = atm_tc_delete,
  11111. - .walk = atm_tc_walk,
  11112. - .tcf_block = atm_tc_tcf_block,
  11113. - .bind_tcf = atm_tc_bind_filter,
  11114. - .unbind_tcf = atm_tc_put,
  11115. - .dump = atm_tc_dump_class,
  11116. - .dump_stats = atm_tc_dump_class_stats,
  11117. -};
  11118. -
  11119. -static struct Qdisc_ops atm_qdisc_ops __read_mostly = {
  11120. - .cl_ops = &atm_class_ops,
  11121. - .id = "atm",
  11122. - .priv_size = sizeof(struct atm_qdisc_data),
  11123. - .enqueue = atm_tc_enqueue,
  11124. - .dequeue = atm_tc_dequeue,
  11125. - .peek = atm_tc_peek,
  11126. - .init = atm_tc_init,
  11127. - .reset = atm_tc_reset,
  11128. - .destroy = atm_tc_destroy,
  11129. - .dump = atm_tc_dump,
  11130. - .owner = THIS_MODULE,
  11131. -};
  11132. -
  11133. -static int __init atm_init(void)
  11134. -{
  11135. - return register_qdisc(&atm_qdisc_ops);
  11136. -}
  11137. -
  11138. -static void __exit atm_exit(void)
  11139. -{
  11140. - unregister_qdisc(&atm_qdisc_ops);
  11141. -}
  11142. -
  11143. -module_init(atm_init)
  11144. -module_exit(atm_exit)
  11145. -MODULE_LICENSE("GPL");
  11146. diff --git net/sched/sch_cbq.c net/sched/sch_cbq.c
  11147. deleted file mode 100644
  11148. index 92ff508367e8..000000000000
  11149. --- linux-4.14.336/net/sched/sch_cbq.c
  11150. +++ linux-4.14.336//dev/null
  11151. @@ -1,1794 +0,0 @@
  11152. -/*
  11153. - * net/sched/sch_cbq.c Class-Based Queueing discipline.
  11154. - *
  11155. - * This program is free software; you can redistribute it and/or
  11156. - * modify it under the terms of the GNU General Public License
  11157. - * as published by the Free Software Foundation; either version
  11158. - * 2 of the License, or (at your option) any later version.
  11159. - *
  11160. - * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
  11161. - *
  11162. - */
  11163. -
  11164. -#include <linux/module.h>
  11165. -#include <linux/slab.h>
  11166. -#include <linux/types.h>
  11167. -#include <linux/kernel.h>
  11168. -#include <linux/string.h>
  11169. -#include <linux/errno.h>
  11170. -#include <linux/skbuff.h>
  11171. -#include <net/netlink.h>
  11172. -#include <net/pkt_sched.h>
  11173. -#include <net/pkt_cls.h>
  11174. -
  11175. -
  11176. -/* Class-Based Queueing (CBQ) algorithm.
  11177. - =======================================
  11178. -
  11179. - Sources: [1] Sally Floyd and Van Jacobson, "Link-sharing and Resource
  11180. - Management Models for Packet Networks",
  11181. - IEEE/ACM Transactions on Networking, Vol.3, No.4, 1995
  11182. -
  11183. - [2] Sally Floyd, "Notes on CBQ and Guaranteed Service", 1995
  11184. -
  11185. - [3] Sally Floyd, "Notes on Class-Based Queueing: Setting
  11186. - Parameters", 1996
  11187. -
  11188. - [4] Sally Floyd and Michael Speer, "Experimental Results
  11189. - for Class-Based Queueing", 1998, not published.
  11190. -
  11191. - -----------------------------------------------------------------------
  11192. -
  11193. - Algorithm skeleton was taken from NS simulator cbq.cc.
  11194. - If someone wants to check this code against the LBL version,
  11195. - he should take into account that ONLY the skeleton was borrowed,
  11196. - the implementation is different. Particularly:
  11197. -
  11198. - --- The WRR algorithm is different. Our version looks more
  11199. - reasonable (I hope) and works when quanta are allowed to be
  11200. - less than MTU, which is always the case when real time classes
  11201. - have small rates. Note, that the statement of [3] is
  11202. - incomplete, delay may actually be estimated even if class
  11203. - per-round allotment is less than MTU. Namely, if per-round
  11204. - allotment is W*r_i, and r_1+...+r_k = r < 1
  11205. -
  11206. - delay_i <= ([MTU/(W*r_i)]*W*r + W*r + k*MTU)/B
  11207. -
  11208. - In the worst case we have IntServ estimate with D = W*r+k*MTU
  11209. - and C = MTU*r. The proof (if correct at all) is trivial.
  11210. -
  11211. -
  11212. - --- It seems that cbq-2.0 is not very accurate. At least, I cannot
  11213. - interpret some places, which look like wrong translations
  11214. - from NS. Anyone is advised to find these differences
  11215. - and explain to me, why I am wrong 8).
  11216. -
  11217. - --- Linux has no EOI event, so that we cannot estimate true class
  11218. - idle time. Workaround is to consider the next dequeue event
  11219. - as sign that previous packet is finished. This is wrong because of
  11220. - internal device queueing, but on a permanently loaded link it is true.
  11221. - Moreover, combined with clock integrator, this scheme looks
  11222. - very close to an ideal solution. */
  11223. -
  11224. -struct cbq_sched_data;
  11225. -
  11226. -
  11227. -struct cbq_class {
  11228. - struct Qdisc_class_common common;
  11229. - struct cbq_class *next_alive; /* next class with backlog in this priority band */
  11230. -
  11231. -/* Parameters */
  11232. - unsigned char priority; /* class priority */
  11233. - unsigned char priority2; /* priority to be used after overlimit */
  11234. - unsigned char ewma_log; /* time constant for idle time calculation */
  11235. -
  11236. - u32 defmap;
  11237. -
  11238. - /* Link-sharing scheduler parameters */
  11239. - long maxidle; /* Class parameters: see below. */
  11240. - long offtime;
  11241. - long minidle;
  11242. - u32 avpkt;
  11243. - struct qdisc_rate_table *R_tab;
  11244. -
  11245. - /* General scheduler (WRR) parameters */
  11246. - long allot;
  11247. - long quantum; /* Allotment per WRR round */
  11248. - long weight; /* Relative allotment: see below */
  11249. -
  11250. - struct Qdisc *qdisc; /* Ptr to CBQ discipline */
  11251. - struct cbq_class *split; /* Ptr to split node */
  11252. - struct cbq_class *share; /* Ptr to LS parent in the class tree */
  11253. - struct cbq_class *tparent; /* Ptr to tree parent in the class tree */
  11254. - struct cbq_class *borrow; /* NULL if class is bandwidth limited;
  11255. - parent otherwise */
  11256. - struct cbq_class *sibling; /* Sibling chain */
  11257. - struct cbq_class *children; /* Pointer to children chain */
  11258. -
  11259. - struct Qdisc *q; /* Elementary queueing discipline */
  11260. -
  11261. -
  11262. -/* Variables */
  11263. - unsigned char cpriority; /* Effective priority */
  11264. - unsigned char delayed;
  11265. - unsigned char level; /* level of the class in hierarchy:
  11266. - 0 for leaf classes, and maximal
  11267. - level of children + 1 for nodes.
  11268. - */
  11269. -
  11270. - psched_time_t last; /* Last end of service */
  11271. - psched_time_t undertime;
  11272. - long avgidle;
  11273. - long deficit; /* Saved deficit for WRR */
  11274. - psched_time_t penalized;
  11275. - struct gnet_stats_basic_packed bstats;
  11276. - struct gnet_stats_queue qstats;
  11277. - struct net_rate_estimator __rcu *rate_est;
  11278. - struct tc_cbq_xstats xstats;
  11279. -
  11280. - struct tcf_proto __rcu *filter_list;
  11281. - struct tcf_block *block;
  11282. -
  11283. - int filters;
  11284. -
  11285. - struct cbq_class *defaults[TC_PRIO_MAX + 1];
  11286. -};
  11287. -
  11288. -struct cbq_sched_data {
  11289. - struct Qdisc_class_hash clhash; /* Hash table of all classes */
  11290. - int nclasses[TC_CBQ_MAXPRIO + 1];
  11291. - unsigned int quanta[TC_CBQ_MAXPRIO + 1];
  11292. -
  11293. - struct cbq_class link;
  11294. -
  11295. - unsigned int activemask;
  11296. - struct cbq_class *active[TC_CBQ_MAXPRIO + 1]; /* List of all classes
  11297. - with backlog */
  11298. -
  11299. -#ifdef CONFIG_NET_CLS_ACT
  11300. - struct cbq_class *rx_class;
  11301. -#endif
  11302. - struct cbq_class *tx_class;
  11303. - struct cbq_class *tx_borrowed;
  11304. - int tx_len;
  11305. - psched_time_t now; /* Cached timestamp */
  11306. - unsigned int pmask;
  11307. -
  11308. - struct hrtimer delay_timer;
  11309. - struct qdisc_watchdog watchdog; /* Watchdog timer,
  11310. - started when CBQ has
  11311. - backlog, but cannot
  11312. - transmit just now */
  11313. - psched_tdiff_t wd_expires;
  11314. - int toplevel;
  11315. - u32 hgenerator;
  11316. -};
  11317. -
  11318. -
  11319. -#define L2T(cl, len) qdisc_l2t((cl)->R_tab, len)
  11320. -
  11321. -static inline struct cbq_class *
  11322. -cbq_class_lookup(struct cbq_sched_data *q, u32 classid)
  11323. -{
  11324. - struct Qdisc_class_common *clc;
  11325. -
  11326. - clc = qdisc_class_find(&q->clhash, classid);
  11327. - if (clc == NULL)
  11328. - return NULL;
  11329. - return container_of(clc, struct cbq_class, common);
  11330. -}
  11331. -
  11332. -#ifdef CONFIG_NET_CLS_ACT
  11333. -
  11334. -static struct cbq_class *
  11335. -cbq_reclassify(struct sk_buff *skb, struct cbq_class *this)
  11336. -{
  11337. - struct cbq_class *cl;
  11338. -
  11339. - for (cl = this->tparent; cl; cl = cl->tparent) {
  11340. - struct cbq_class *new = cl->defaults[TC_PRIO_BESTEFFORT];
  11341. -
  11342. - if (new != NULL && new != this)
  11343. - return new;
  11344. - }
  11345. - return NULL;
  11346. -}
  11347. -
  11348. -#endif
  11349. -
  11350. -/* Classify packet. The procedure is pretty complicated, but
  11351. - * it allows us to combine link sharing and priority scheduling
  11352. - * transparently.
  11353. - *
  11354. - * Namely, you can put link sharing rules (f.e. route based) at root of CBQ,
  11355. - * so that it resolves to split nodes. Then packets are classified
  11356. - * by logical priority, or a more specific classifier may be attached
  11357. - * to the split node.
  11358. - */
  11359. -
  11360. -static struct cbq_class *
  11361. -cbq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
  11362. -{
  11363. - struct cbq_sched_data *q = qdisc_priv(sch);
  11364. - struct cbq_class *head = &q->link;
  11365. - struct cbq_class **defmap;
  11366. - struct cbq_class *cl = NULL;
  11367. - u32 prio = skb->priority;
  11368. - struct tcf_proto *fl;
  11369. - struct tcf_result res;
  11370. -
  11371. - /*
  11372. - * Step 1. If skb->priority points to one of our classes, use it.
  11373. - */
  11374. - if (TC_H_MAJ(prio ^ sch->handle) == 0 &&
  11375. - (cl = cbq_class_lookup(q, prio)) != NULL)
  11376. - return cl;
  11377. -
  11378. - *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
  11379. - for (;;) {
  11380. - int result = 0;
  11381. - defmap = head->defaults;
  11382. -
  11383. - fl = rcu_dereference_bh(head->filter_list);
  11384. - /*
  11385. - * Step 2+n. Apply classifier.
  11386. - */
  11387. - result = tcf_classify(skb, fl, &res, true);
  11388. - if (!fl || result < 0)
  11389. - goto fallback;
  11390. - if (result == TC_ACT_SHOT)
  11391. - return NULL;
  11392. -
  11393. - cl = (void *)res.class;
  11394. - if (!cl) {
  11395. - if (TC_H_MAJ(res.classid))
  11396. - cl = cbq_class_lookup(q, res.classid);
  11397. - else if ((cl = defmap[res.classid & TC_PRIO_MAX]) == NULL)
  11398. - cl = defmap[TC_PRIO_BESTEFFORT];
  11399. -
  11400. - if (cl == NULL)
  11401. - goto fallback;
  11402. - }
  11403. - if (cl->level >= head->level)
  11404. - goto fallback;
  11405. -#ifdef CONFIG_NET_CLS_ACT
  11406. - switch (result) {
  11407. - case TC_ACT_QUEUED:
  11408. - case TC_ACT_STOLEN:
  11409. - case TC_ACT_TRAP:
  11410. - *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
  11411. - case TC_ACT_RECLASSIFY:
  11412. - return cbq_reclassify(skb, cl);
  11413. - }
  11414. -#endif
  11415. - if (cl->level == 0)
  11416. - return cl;
  11417. -
  11418. - /*
  11419. - * Step 3+n. If classifier selected a link sharing class,
  11420. - * apply agency specific classifier.
  11421. - * Repeat this procdure until we hit a leaf node.
  11422. - */
  11423. - head = cl;
  11424. - }
  11425. -
  11426. -fallback:
  11427. - cl = head;
  11428. -
  11429. - /*
  11430. - * Step 4. No success...
  11431. - */
  11432. - if (TC_H_MAJ(prio) == 0 &&
  11433. - !(cl = head->defaults[prio & TC_PRIO_MAX]) &&
  11434. - !(cl = head->defaults[TC_PRIO_BESTEFFORT]))
  11435. - return head;
  11436. -
  11437. - return cl;
  11438. -}
  11439. -
  11440. -/*
  11441. - * A packet has just been enqueued on the empty class.
  11442. - * cbq_activate_class adds it to the tail of active class list
  11443. - * of its priority band.
  11444. - */
  11445. -
  11446. -static inline void cbq_activate_class(struct cbq_class *cl)
  11447. -{
  11448. - struct cbq_sched_data *q = qdisc_priv(cl->qdisc);
  11449. - int prio = cl->cpriority;
  11450. - struct cbq_class *cl_tail;
  11451. -
  11452. - cl_tail = q->active[prio];
  11453. - q->active[prio] = cl;
  11454. -
  11455. - if (cl_tail != NULL) {
  11456. - cl->next_alive = cl_tail->next_alive;
  11457. - cl_tail->next_alive = cl;
  11458. - } else {
  11459. - cl->next_alive = cl;
  11460. - q->activemask |= (1<<prio);
  11461. - }
  11462. -}
  11463. -
  11464. -/*
  11465. - * Unlink class from active chain.
  11466. - * Note that this same procedure is done directly in cbq_dequeue*
  11467. - * during round-robin procedure.
  11468. - */
  11469. -
  11470. -static void cbq_deactivate_class(struct cbq_class *this)
  11471. -{
  11472. - struct cbq_sched_data *q = qdisc_priv(this->qdisc);
  11473. - int prio = this->cpriority;
  11474. - struct cbq_class *cl;
  11475. - struct cbq_class *cl_prev = q->active[prio];
  11476. -
  11477. - do {
  11478. - cl = cl_prev->next_alive;
  11479. - if (cl == this) {
  11480. - cl_prev->next_alive = cl->next_alive;
  11481. - cl->next_alive = NULL;
  11482. -
  11483. - if (cl == q->active[prio]) {
  11484. - q->active[prio] = cl_prev;
  11485. - if (cl == q->active[prio]) {
  11486. - q->active[prio] = NULL;
  11487. - q->activemask &= ~(1<<prio);
  11488. - return;
  11489. - }
  11490. - }
  11491. - return;
  11492. - }
  11493. - } while ((cl_prev = cl) != q->active[prio]);
  11494. -}
  11495. -
  11496. -static void
  11497. -cbq_mark_toplevel(struct cbq_sched_data *q, struct cbq_class *cl)
  11498. -{
  11499. - int toplevel = q->toplevel;
  11500. -
  11501. - if (toplevel > cl->level) {
  11502. - psched_time_t now = psched_get_time();
  11503. -
  11504. - do {
  11505. - if (cl->undertime < now) {
  11506. - q->toplevel = cl->level;
  11507. - return;
  11508. - }
  11509. - } while ((cl = cl->borrow) != NULL && toplevel > cl->level);
  11510. - }
  11511. -}
  11512. -
  11513. -static int
  11514. -cbq_enqueue(struct sk_buff *skb, struct Qdisc *sch,
  11515. - struct sk_buff **to_free)
  11516. -{
  11517. - struct cbq_sched_data *q = qdisc_priv(sch);
  11518. - int ret;
  11519. - struct cbq_class *cl = cbq_classify(skb, sch, &ret);
  11520. -
  11521. -#ifdef CONFIG_NET_CLS_ACT
  11522. - q->rx_class = cl;
  11523. -#endif
  11524. - if (cl == NULL) {
  11525. - if (ret & __NET_XMIT_BYPASS)
  11526. - qdisc_qstats_drop(sch);
  11527. - __qdisc_drop(skb, to_free);
  11528. - return ret;
  11529. - }
  11530. -
  11531. - ret = qdisc_enqueue(skb, cl->q, to_free);
  11532. - if (ret == NET_XMIT_SUCCESS) {
  11533. - sch->q.qlen++;
  11534. - cbq_mark_toplevel(q, cl);
  11535. - if (!cl->next_alive)
  11536. - cbq_activate_class(cl);
  11537. - return ret;
  11538. - }
  11539. -
  11540. - if (net_xmit_drop_count(ret)) {
  11541. - qdisc_qstats_drop(sch);
  11542. - cbq_mark_toplevel(q, cl);
  11543. - cl->qstats.drops++;
  11544. - }
  11545. - return ret;
  11546. -}
  11547. -
  11548. -/* Overlimit action: penalize leaf class by adding offtime */
  11549. -static void cbq_overlimit(struct cbq_class *cl)
  11550. -{
  11551. - struct cbq_sched_data *q = qdisc_priv(cl->qdisc);
  11552. - psched_tdiff_t delay = cl->undertime - q->now;
  11553. -
  11554. - if (!cl->delayed) {
  11555. - delay += cl->offtime;
  11556. -
  11557. - /*
  11558. - * Class goes to sleep, so that it will have no
  11559. - * chance to work avgidle. Let's forgive it 8)
  11560. - *
  11561. - * BTW cbq-2.0 has a crap in this
  11562. - * place, apparently they forgot to shift it by cl->ewma_log.
  11563. - */
  11564. - if (cl->avgidle < 0)
  11565. - delay -= (-cl->avgidle) - ((-cl->avgidle) >> cl->ewma_log);
  11566. - if (cl->avgidle < cl->minidle)
  11567. - cl->avgidle = cl->minidle;
  11568. - if (delay <= 0)
  11569. - delay = 1;
  11570. - cl->undertime = q->now + delay;
  11571. -
  11572. - cl->xstats.overactions++;
  11573. - cl->delayed = 1;
  11574. - }
  11575. - if (q->wd_expires == 0 || q->wd_expires > delay)
  11576. - q->wd_expires = delay;
  11577. -
  11578. - /* Dirty work! We must schedule wakeups based on
  11579. - * real available rate, rather than leaf rate,
  11580. - * which may be tiny (even zero).
  11581. - */
  11582. - if (q->toplevel == TC_CBQ_MAXLEVEL) {
  11583. - struct cbq_class *b;
  11584. - psched_tdiff_t base_delay = q->wd_expires;
  11585. -
  11586. - for (b = cl->borrow; b; b = b->borrow) {
  11587. - delay = b->undertime - q->now;
  11588. - if (delay < base_delay) {
  11589. - if (delay <= 0)
  11590. - delay = 1;
  11591. - base_delay = delay;
  11592. - }
  11593. - }
  11594. -
  11595. - q->wd_expires = base_delay;
  11596. - }
  11597. -}
  11598. -
  11599. -static psched_tdiff_t cbq_undelay_prio(struct cbq_sched_data *q, int prio,
  11600. - psched_time_t now)
  11601. -{
  11602. - struct cbq_class *cl;
  11603. - struct cbq_class *cl_prev = q->active[prio];
  11604. - psched_time_t sched = now;
  11605. -
  11606. - if (cl_prev == NULL)
  11607. - return 0;
  11608. -
  11609. - do {
  11610. - cl = cl_prev->next_alive;
  11611. - if (now - cl->penalized > 0) {
  11612. - cl_prev->next_alive = cl->next_alive;
  11613. - cl->next_alive = NULL;
  11614. - cl->cpriority = cl->priority;
  11615. - cl->delayed = 0;
  11616. - cbq_activate_class(cl);
  11617. -
  11618. - if (cl == q->active[prio]) {
  11619. - q->active[prio] = cl_prev;
  11620. - if (cl == q->active[prio]) {
  11621. - q->active[prio] = NULL;
  11622. - return 0;
  11623. - }
  11624. - }
  11625. -
  11626. - cl = cl_prev->next_alive;
  11627. - } else if (sched - cl->penalized > 0)
  11628. - sched = cl->penalized;
  11629. - } while ((cl_prev = cl) != q->active[prio]);
  11630. -
  11631. - return sched - now;
  11632. -}
  11633. -
  11634. -static enum hrtimer_restart cbq_undelay(struct hrtimer *timer)
  11635. -{
  11636. - struct cbq_sched_data *q = container_of(timer, struct cbq_sched_data,
  11637. - delay_timer);
  11638. - struct Qdisc *sch = q->watchdog.qdisc;
  11639. - psched_time_t now;
  11640. - psched_tdiff_t delay = 0;
  11641. - unsigned int pmask;
  11642. -
  11643. - now = psched_get_time();
  11644. -
  11645. - pmask = q->pmask;
  11646. - q->pmask = 0;
  11647. -
  11648. - while (pmask) {
  11649. - int prio = ffz(~pmask);
  11650. - psched_tdiff_t tmp;
  11651. -
  11652. - pmask &= ~(1<<prio);
  11653. -
  11654. - tmp = cbq_undelay_prio(q, prio, now);
  11655. - if (tmp > 0) {
  11656. - q->pmask |= 1<<prio;
  11657. - if (tmp < delay || delay == 0)
  11658. - delay = tmp;
  11659. - }
  11660. - }
  11661. -
  11662. - if (delay) {
  11663. - ktime_t time;
  11664. -
  11665. - time = 0;
  11666. - time = ktime_add_ns(time, PSCHED_TICKS2NS(now + delay));
  11667. - hrtimer_start(&q->delay_timer, time, HRTIMER_MODE_ABS_PINNED);
  11668. - }
  11669. -
  11670. - __netif_schedule(qdisc_root(sch));
  11671. - return HRTIMER_NORESTART;
  11672. -}
  11673. -
  11674. -/*
  11675. - * It is mission critical procedure.
  11676. - *
  11677. - * We "regenerate" toplevel cutoff, if transmitting class
  11678. - * has backlog and it is not regulated. It is not part of
  11679. - * original CBQ description, but looks more reasonable.
  11680. - * Probably, it is wrong. This question needs further investigation.
  11681. - */
  11682. -
  11683. -static inline void
  11684. -cbq_update_toplevel(struct cbq_sched_data *q, struct cbq_class *cl,
  11685. - struct cbq_class *borrowed)
  11686. -{
  11687. - if (cl && q->toplevel >= borrowed->level) {
  11688. - if (cl->q->q.qlen > 1) {
  11689. - do {
  11690. - if (borrowed->undertime == PSCHED_PASTPERFECT) {
  11691. - q->toplevel = borrowed->level;
  11692. - return;
  11693. - }
  11694. - } while ((borrowed = borrowed->borrow) != NULL);
  11695. - }
  11696. -#if 0
  11697. - /* It is not necessary now. Uncommenting it
  11698. - will save CPU cycles, but decrease fairness.
  11699. - */
  11700. - q->toplevel = TC_CBQ_MAXLEVEL;
  11701. -#endif
  11702. - }
  11703. -}
  11704. -
  11705. -static void
  11706. -cbq_update(struct cbq_sched_data *q)
  11707. -{
  11708. - struct cbq_class *this = q->tx_class;
  11709. - struct cbq_class *cl = this;
  11710. - int len = q->tx_len;
  11711. - psched_time_t now;
  11712. -
  11713. - q->tx_class = NULL;
  11714. - /* Time integrator. We calculate EOS time
  11715. - * by adding expected packet transmission time.
  11716. - */
  11717. - now = q->now + L2T(&q->link, len);
  11718. -
  11719. - for ( ; cl; cl = cl->share) {
  11720. - long avgidle = cl->avgidle;
  11721. - long idle;
  11722. -
  11723. - cl->bstats.packets++;
  11724. - cl->bstats.bytes += len;
  11725. -
  11726. - /*
  11727. - * (now - last) is total time between packet right edges.
  11728. - * (last_pktlen/rate) is "virtual" busy time, so that
  11729. - *
  11730. - * idle = (now - last) - last_pktlen/rate
  11731. - */
  11732. -
  11733. - idle = now - cl->last;
  11734. - if ((unsigned long)idle > 128*1024*1024) {
  11735. - avgidle = cl->maxidle;
  11736. - } else {
  11737. - idle -= L2T(cl, len);
  11738. -
  11739. - /* true_avgidle := (1-W)*true_avgidle + W*idle,
  11740. - * where W=2^{-ewma_log}. But cl->avgidle is scaled:
  11741. - * cl->avgidle == true_avgidle/W,
  11742. - * hence:
  11743. - */
  11744. - avgidle += idle - (avgidle>>cl->ewma_log);
  11745. - }
  11746. -
  11747. - if (avgidle <= 0) {
  11748. - /* Overlimit or at-limit */
  11749. -
  11750. - if (avgidle < cl->minidle)
  11751. - avgidle = cl->minidle;
  11752. -
  11753. - cl->avgidle = avgidle;
  11754. -
  11755. - /* Calculate expected time, when this class
  11756. - * will be allowed to send.
  11757. - * It will occur, when:
  11758. - * (1-W)*true_avgidle + W*delay = 0, i.e.
  11759. - * idle = (1/W - 1)*(-true_avgidle)
  11760. - * or
  11761. - * idle = (1 - W)*(-cl->avgidle);
  11762. - */
  11763. - idle = (-avgidle) - ((-avgidle) >> cl->ewma_log);
  11764. -
  11765. - /*
  11766. - * That is not all.
  11767. - * To maintain the rate allocated to the class,
  11768. - * we add to undertime virtual clock,
  11769. - * necessary to complete transmitted packet.
  11770. - * (len/phys_bandwidth has been already passed
  11771. - * to the moment of cbq_update)
  11772. - */
  11773. -
  11774. - idle -= L2T(&q->link, len);
  11775. - idle += L2T(cl, len);
  11776. -
  11777. - cl->undertime = now + idle;
  11778. - } else {
  11779. - /* Underlimit */
  11780. -
  11781. - cl->undertime = PSCHED_PASTPERFECT;
  11782. - if (avgidle > cl->maxidle)
  11783. - cl->avgidle = cl->maxidle;
  11784. - else
  11785. - cl->avgidle = avgidle;
  11786. - }
  11787. - if ((s64)(now - cl->last) > 0)
  11788. - cl->last = now;
  11789. - }
  11790. -
  11791. - cbq_update_toplevel(q, this, q->tx_borrowed);
  11792. -}
  11793. -
  11794. -static inline struct cbq_class *
  11795. -cbq_under_limit(struct cbq_class *cl)
  11796. -{
  11797. - struct cbq_sched_data *q = qdisc_priv(cl->qdisc);
  11798. - struct cbq_class *this_cl = cl;
  11799. -
  11800. - if (cl->tparent == NULL)
  11801. - return cl;
  11802. -
  11803. - if (cl->undertime == PSCHED_PASTPERFECT || q->now >= cl->undertime) {
  11804. - cl->delayed = 0;
  11805. - return cl;
  11806. - }
  11807. -
  11808. - do {
  11809. - /* It is very suspicious place. Now overlimit
  11810. - * action is generated for not bounded classes
  11811. - * only if link is completely congested.
  11812. - * Though it is in agree with ancestor-only paradigm,
  11813. - * it looks very stupid. Particularly,
  11814. - * it means that this chunk of code will either
  11815. - * never be called or result in strong amplification
  11816. - * of burstiness. Dangerous, silly, and, however,
  11817. - * no another solution exists.
  11818. - */
  11819. - cl = cl->borrow;
  11820. - if (!cl) {
  11821. - this_cl->qstats.overlimits++;
  11822. - cbq_overlimit(this_cl);
  11823. - return NULL;
  11824. - }
  11825. - if (cl->level > q->toplevel)
  11826. - return NULL;
  11827. - } while (cl->undertime != PSCHED_PASTPERFECT && q->now < cl->undertime);
  11828. -
  11829. - cl->delayed = 0;
  11830. - return cl;
  11831. -}
  11832. -
  11833. -static inline struct sk_buff *
  11834. -cbq_dequeue_prio(struct Qdisc *sch, int prio)
  11835. -{
  11836. - struct cbq_sched_data *q = qdisc_priv(sch);
  11837. - struct cbq_class *cl_tail, *cl_prev, *cl;
  11838. - struct sk_buff *skb;
  11839. - int deficit;
  11840. -
  11841. - cl_tail = cl_prev = q->active[prio];
  11842. - cl = cl_prev->next_alive;
  11843. -
  11844. - do {
  11845. - deficit = 0;
  11846. -
  11847. - /* Start round */
  11848. - do {
  11849. - struct cbq_class *borrow = cl;
  11850. -
  11851. - if (cl->q->q.qlen &&
  11852. - (borrow = cbq_under_limit(cl)) == NULL)
  11853. - goto skip_class;
  11854. -
  11855. - if (cl->deficit <= 0) {
  11856. - /* Class exhausted its allotment per
  11857. - * this round. Switch to the next one.
  11858. - */
  11859. - deficit = 1;
  11860. - cl->deficit += cl->quantum;
  11861. - goto next_class;
  11862. - }
  11863. -
  11864. - skb = cl->q->dequeue(cl->q);
  11865. -
  11866. - /* Class did not give us any skb :-(
  11867. - * It could occur even if cl->q->q.qlen != 0
  11868. - * f.e. if cl->q == "tbf"
  11869. - */
  11870. - if (skb == NULL)
  11871. - goto skip_class;
  11872. -
  11873. - cl->deficit -= qdisc_pkt_len(skb);
  11874. - q->tx_class = cl;
  11875. - q->tx_borrowed = borrow;
  11876. - if (borrow != cl) {
  11877. -#ifndef CBQ_XSTATS_BORROWS_BYTES
  11878. - borrow->xstats.borrows++;
  11879. - cl->xstats.borrows++;
  11880. -#else
  11881. - borrow->xstats.borrows += qdisc_pkt_len(skb);
  11882. - cl->xstats.borrows += qdisc_pkt_len(skb);
  11883. -#endif
  11884. - }
  11885. - q->tx_len = qdisc_pkt_len(skb);
  11886. -
  11887. - if (cl->deficit <= 0) {
  11888. - q->active[prio] = cl;
  11889. - cl = cl->next_alive;
  11890. - cl->deficit += cl->quantum;
  11891. - }
  11892. - return skb;
  11893. -
  11894. -skip_class:
  11895. - if (cl->q->q.qlen == 0 || prio != cl->cpriority) {
  11896. - /* Class is empty or penalized.
  11897. - * Unlink it from active chain.
  11898. - */
  11899. - cl_prev->next_alive = cl->next_alive;
  11900. - cl->next_alive = NULL;
  11901. -
  11902. - /* Did cl_tail point to it? */
  11903. - if (cl == cl_tail) {
  11904. - /* Repair it! */
  11905. - cl_tail = cl_prev;
  11906. -
  11907. - /* Was it the last class in this band? */
  11908. - if (cl == cl_tail) {
  11909. - /* Kill the band! */
  11910. - q->active[prio] = NULL;
  11911. - q->activemask &= ~(1<<prio);
  11912. - if (cl->q->q.qlen)
  11913. - cbq_activate_class(cl);
  11914. - return NULL;
  11915. - }
  11916. -
  11917. - q->active[prio] = cl_tail;
  11918. - }
  11919. - if (cl->q->q.qlen)
  11920. - cbq_activate_class(cl);
  11921. -
  11922. - cl = cl_prev;
  11923. - }
  11924. -
  11925. -next_class:
  11926. - cl_prev = cl;
  11927. - cl = cl->next_alive;
  11928. - } while (cl_prev != cl_tail);
  11929. - } while (deficit);
  11930. -
  11931. - q->active[prio] = cl_prev;
  11932. -
  11933. - return NULL;
  11934. -}
  11935. -
  11936. -static inline struct sk_buff *
  11937. -cbq_dequeue_1(struct Qdisc *sch)
  11938. -{
  11939. - struct cbq_sched_data *q = qdisc_priv(sch);
  11940. - struct sk_buff *skb;
  11941. - unsigned int activemask;
  11942. -
  11943. - activemask = q->activemask & 0xFF;
  11944. - while (activemask) {
  11945. - int prio = ffz(~activemask);
  11946. - activemask &= ~(1<<prio);
  11947. - skb = cbq_dequeue_prio(sch, prio);
  11948. - if (skb)
  11949. - return skb;
  11950. - }
  11951. - return NULL;
  11952. -}
  11953. -
  11954. -static struct sk_buff *
  11955. -cbq_dequeue(struct Qdisc *sch)
  11956. -{
  11957. - struct sk_buff *skb;
  11958. - struct cbq_sched_data *q = qdisc_priv(sch);
  11959. - psched_time_t now;
  11960. -
  11961. - now = psched_get_time();
  11962. -
  11963. - if (q->tx_class)
  11964. - cbq_update(q);
  11965. -
  11966. - q->now = now;
  11967. -
  11968. - for (;;) {
  11969. - q->wd_expires = 0;
  11970. -
  11971. - skb = cbq_dequeue_1(sch);
  11972. - if (skb) {
  11973. - qdisc_bstats_update(sch, skb);
  11974. - sch->q.qlen--;
  11975. - return skb;
  11976. - }
  11977. -
  11978. - /* All the classes are overlimit.
  11979. - *
  11980. - * It is possible, if:
  11981. - *
  11982. - * 1. Scheduler is empty.
  11983. - * 2. Toplevel cutoff inhibited borrowing.
  11984. - * 3. Root class is overlimit.
  11985. - *
  11986. - * Reset 2d and 3d conditions and retry.
  11987. - *
  11988. - * Note, that NS and cbq-2.0 are buggy, peeking
  11989. - * an arbitrary class is appropriate for ancestor-only
  11990. - * sharing, but not for toplevel algorithm.
  11991. - *
  11992. - * Our version is better, but slower, because it requires
  11993. - * two passes, but it is unavoidable with top-level sharing.
  11994. - */
  11995. -
  11996. - if (q->toplevel == TC_CBQ_MAXLEVEL &&
  11997. - q->link.undertime == PSCHED_PASTPERFECT)
  11998. - break;
  11999. -
  12000. - q->toplevel = TC_CBQ_MAXLEVEL;
  12001. - q->link.undertime = PSCHED_PASTPERFECT;
  12002. - }
  12003. -
  12004. - /* No packets in scheduler or nobody wants to give them to us :-(
  12005. - * Sigh... start watchdog timer in the last case.
  12006. - */
  12007. -
  12008. - if (sch->q.qlen) {
  12009. - qdisc_qstats_overlimit(sch);
  12010. - if (q->wd_expires)
  12011. - qdisc_watchdog_schedule(&q->watchdog,
  12012. - now + q->wd_expires);
  12013. - }
  12014. - return NULL;
  12015. -}
  12016. -
  12017. -/* CBQ class maintanance routines */
  12018. -
  12019. -static void cbq_adjust_levels(struct cbq_class *this)
  12020. -{
  12021. - if (this == NULL)
  12022. - return;
  12023. -
  12024. - do {
  12025. - int level = 0;
  12026. - struct cbq_class *cl;
  12027. -
  12028. - cl = this->children;
  12029. - if (cl) {
  12030. - do {
  12031. - if (cl->level > level)
  12032. - level = cl->level;
  12033. - } while ((cl = cl->sibling) != this->children);
  12034. - }
  12035. - this->level = level + 1;
  12036. - } while ((this = this->tparent) != NULL);
  12037. -}
  12038. -
  12039. -static void cbq_normalize_quanta(struct cbq_sched_data *q, int prio)
  12040. -{
  12041. - struct cbq_class *cl;
  12042. - unsigned int h;
  12043. -
  12044. - if (q->quanta[prio] == 0)
  12045. - return;
  12046. -
  12047. - for (h = 0; h < q->clhash.hashsize; h++) {
  12048. - hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode) {
  12049. - /* BUGGGG... Beware! This expression suffer of
  12050. - * arithmetic overflows!
  12051. - */
  12052. - if (cl->priority == prio) {
  12053. - cl->quantum = (cl->weight*cl->allot*q->nclasses[prio])/
  12054. - q->quanta[prio];
  12055. - }
  12056. - if (cl->quantum <= 0 ||
  12057. - cl->quantum > 32*qdisc_dev(cl->qdisc)->mtu) {
  12058. - pr_warn("CBQ: class %08x has bad quantum==%ld, repaired.\n",
  12059. - cl->common.classid, cl->quantum);
  12060. - cl->quantum = qdisc_dev(cl->qdisc)->mtu/2 + 1;
  12061. - }
  12062. - }
  12063. - }
  12064. -}
  12065. -
  12066. -static void cbq_sync_defmap(struct cbq_class *cl)
  12067. -{
  12068. - struct cbq_sched_data *q = qdisc_priv(cl->qdisc);
  12069. - struct cbq_class *split = cl->split;
  12070. - unsigned int h;
  12071. - int i;
  12072. -
  12073. - if (split == NULL)
  12074. - return;
  12075. -
  12076. - for (i = 0; i <= TC_PRIO_MAX; i++) {
  12077. - if (split->defaults[i] == cl && !(cl->defmap & (1<<i)))
  12078. - split->defaults[i] = NULL;
  12079. - }
  12080. -
  12081. - for (i = 0; i <= TC_PRIO_MAX; i++) {
  12082. - int level = split->level;
  12083. -
  12084. - if (split->defaults[i])
  12085. - continue;
  12086. -
  12087. - for (h = 0; h < q->clhash.hashsize; h++) {
  12088. - struct cbq_class *c;
  12089. -
  12090. - hlist_for_each_entry(c, &q->clhash.hash[h],
  12091. - common.hnode) {
  12092. - if (c->split == split && c->level < level &&
  12093. - c->defmap & (1<<i)) {
  12094. - split->defaults[i] = c;
  12095. - level = c->level;
  12096. - }
  12097. - }
  12098. - }
  12099. - }
  12100. -}
  12101. -
  12102. -static void cbq_change_defmap(struct cbq_class *cl, u32 splitid, u32 def, u32 mask)
  12103. -{
  12104. - struct cbq_class *split = NULL;
  12105. -
  12106. - if (splitid == 0) {
  12107. - split = cl->split;
  12108. - if (!split)
  12109. - return;
  12110. - splitid = split->common.classid;
  12111. - }
  12112. -
  12113. - if (split == NULL || split->common.classid != splitid) {
  12114. - for (split = cl->tparent; split; split = split->tparent)
  12115. - if (split->common.classid == splitid)
  12116. - break;
  12117. - }
  12118. -
  12119. - if (split == NULL)
  12120. - return;
  12121. -
  12122. - if (cl->split != split) {
  12123. - cl->defmap = 0;
  12124. - cbq_sync_defmap(cl);
  12125. - cl->split = split;
  12126. - cl->defmap = def & mask;
  12127. - } else
  12128. - cl->defmap = (cl->defmap & ~mask) | (def & mask);
  12129. -
  12130. - cbq_sync_defmap(cl);
  12131. -}
  12132. -
  12133. -static void cbq_unlink_class(struct cbq_class *this)
  12134. -{
  12135. - struct cbq_class *cl, **clp;
  12136. - struct cbq_sched_data *q = qdisc_priv(this->qdisc);
  12137. -
  12138. - qdisc_class_hash_remove(&q->clhash, &this->common);
  12139. -
  12140. - if (this->tparent) {
  12141. - clp = &this->sibling;
  12142. - cl = *clp;
  12143. - do {
  12144. - if (cl == this) {
  12145. - *clp = cl->sibling;
  12146. - break;
  12147. - }
  12148. - clp = &cl->sibling;
  12149. - } while ((cl = *clp) != this->sibling);
  12150. -
  12151. - if (this->tparent->children == this) {
  12152. - this->tparent->children = this->sibling;
  12153. - if (this->sibling == this)
  12154. - this->tparent->children = NULL;
  12155. - }
  12156. - } else {
  12157. - WARN_ON(this->sibling != this);
  12158. - }
  12159. -}
  12160. -
  12161. -static void cbq_link_class(struct cbq_class *this)
  12162. -{
  12163. - struct cbq_sched_data *q = qdisc_priv(this->qdisc);
  12164. - struct cbq_class *parent = this->tparent;
  12165. -
  12166. - this->sibling = this;
  12167. - qdisc_class_hash_insert(&q->clhash, &this->common);
  12168. -
  12169. - if (parent == NULL)
  12170. - return;
  12171. -
  12172. - if (parent->children == NULL) {
  12173. - parent->children = this;
  12174. - } else {
  12175. - this->sibling = parent->children->sibling;
  12176. - parent->children->sibling = this;
  12177. - }
  12178. -}
  12179. -
  12180. -static void
  12181. -cbq_reset(struct Qdisc *sch)
  12182. -{
  12183. - struct cbq_sched_data *q = qdisc_priv(sch);
  12184. - struct cbq_class *cl;
  12185. - int prio;
  12186. - unsigned int h;
  12187. -
  12188. - q->activemask = 0;
  12189. - q->pmask = 0;
  12190. - q->tx_class = NULL;
  12191. - q->tx_borrowed = NULL;
  12192. - qdisc_watchdog_cancel(&q->watchdog);
  12193. - hrtimer_cancel(&q->delay_timer);
  12194. - q->toplevel = TC_CBQ_MAXLEVEL;
  12195. - q->now = psched_get_time();
  12196. -
  12197. - for (prio = 0; prio <= TC_CBQ_MAXPRIO; prio++)
  12198. - q->active[prio] = NULL;
  12199. -
  12200. - for (h = 0; h < q->clhash.hashsize; h++) {
  12201. - hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode) {
  12202. - qdisc_reset(cl->q);
  12203. -
  12204. - cl->next_alive = NULL;
  12205. - cl->undertime = PSCHED_PASTPERFECT;
  12206. - cl->avgidle = cl->maxidle;
  12207. - cl->deficit = cl->quantum;
  12208. - cl->cpriority = cl->priority;
  12209. - }
  12210. - }
  12211. - sch->q.qlen = 0;
  12212. -}
  12213. -
  12214. -
  12215. -static int cbq_set_lss(struct cbq_class *cl, struct tc_cbq_lssopt *lss)
  12216. -{
  12217. - if (lss->change & TCF_CBQ_LSS_FLAGS) {
  12218. - cl->share = (lss->flags & TCF_CBQ_LSS_ISOLATED) ? NULL : cl->tparent;
  12219. - cl->borrow = (lss->flags & TCF_CBQ_LSS_BOUNDED) ? NULL : cl->tparent;
  12220. - }
  12221. - if (lss->change & TCF_CBQ_LSS_EWMA)
  12222. - cl->ewma_log = lss->ewma_log;
  12223. - if (lss->change & TCF_CBQ_LSS_AVPKT)
  12224. - cl->avpkt = lss->avpkt;
  12225. - if (lss->change & TCF_CBQ_LSS_MINIDLE)
  12226. - cl->minidle = -(long)lss->minidle;
  12227. - if (lss->change & TCF_CBQ_LSS_MAXIDLE) {
  12228. - cl->maxidle = lss->maxidle;
  12229. - cl->avgidle = lss->maxidle;
  12230. - }
  12231. - if (lss->change & TCF_CBQ_LSS_OFFTIME)
  12232. - cl->offtime = lss->offtime;
  12233. - return 0;
  12234. -}
  12235. -
  12236. -static void cbq_rmprio(struct cbq_sched_data *q, struct cbq_class *cl)
  12237. -{
  12238. - q->nclasses[cl->priority]--;
  12239. - q->quanta[cl->priority] -= cl->weight;
  12240. - cbq_normalize_quanta(q, cl->priority);
  12241. -}
  12242. -
  12243. -static void cbq_addprio(struct cbq_sched_data *q, struct cbq_class *cl)
  12244. -{
  12245. - q->nclasses[cl->priority]++;
  12246. - q->quanta[cl->priority] += cl->weight;
  12247. - cbq_normalize_quanta(q, cl->priority);
  12248. -}
  12249. -
  12250. -static int cbq_set_wrr(struct cbq_class *cl, struct tc_cbq_wrropt *wrr)
  12251. -{
  12252. - struct cbq_sched_data *q = qdisc_priv(cl->qdisc);
  12253. -
  12254. - if (wrr->allot)
  12255. - cl->allot = wrr->allot;
  12256. - if (wrr->weight)
  12257. - cl->weight = wrr->weight;
  12258. - if (wrr->priority) {
  12259. - cl->priority = wrr->priority - 1;
  12260. - cl->cpriority = cl->priority;
  12261. - if (cl->priority >= cl->priority2)
  12262. - cl->priority2 = TC_CBQ_MAXPRIO - 1;
  12263. - }
  12264. -
  12265. - cbq_addprio(q, cl);
  12266. - return 0;
  12267. -}
  12268. -
  12269. -static int cbq_set_fopt(struct cbq_class *cl, struct tc_cbq_fopt *fopt)
  12270. -{
  12271. - cbq_change_defmap(cl, fopt->split, fopt->defmap, fopt->defchange);
  12272. - return 0;
  12273. -}
  12274. -
  12275. -static const struct nla_policy cbq_policy[TCA_CBQ_MAX + 1] = {
  12276. - [TCA_CBQ_LSSOPT] = { .len = sizeof(struct tc_cbq_lssopt) },
  12277. - [TCA_CBQ_WRROPT] = { .len = sizeof(struct tc_cbq_wrropt) },
  12278. - [TCA_CBQ_FOPT] = { .len = sizeof(struct tc_cbq_fopt) },
  12279. - [TCA_CBQ_OVL_STRATEGY] = { .len = sizeof(struct tc_cbq_ovl) },
  12280. - [TCA_CBQ_RATE] = { .len = sizeof(struct tc_ratespec) },
  12281. - [TCA_CBQ_RTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE },
  12282. - [TCA_CBQ_POLICE] = { .len = sizeof(struct tc_cbq_police) },
  12283. -};
  12284. -
  12285. -static int cbq_opt_parse(struct nlattr *tb[TCA_CBQ_MAX + 1], struct nlattr *opt)
  12286. -{
  12287. - int err;
  12288. -
  12289. - if (!opt)
  12290. - return -EINVAL;
  12291. -
  12292. - err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, cbq_policy, NULL);
  12293. - if (err < 0)
  12294. - return err;
  12295. -
  12296. - if (tb[TCA_CBQ_WRROPT]) {
  12297. - const struct tc_cbq_wrropt *wrr = nla_data(tb[TCA_CBQ_WRROPT]);
  12298. -
  12299. - if (wrr->priority > TC_CBQ_MAXPRIO)
  12300. - err = -EINVAL;
  12301. - }
  12302. - return err;
  12303. -}
  12304. -
  12305. -static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
  12306. -{
  12307. - struct cbq_sched_data *q = qdisc_priv(sch);
  12308. - struct nlattr *tb[TCA_CBQ_MAX + 1];
  12309. - struct tc_ratespec *r;
  12310. - int err;
  12311. -
  12312. - qdisc_watchdog_init(&q->watchdog, sch);
  12313. - hrtimer_init(&q->delay_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED);
  12314. - q->delay_timer.function = cbq_undelay;
  12315. -
  12316. - err = cbq_opt_parse(tb, opt);
  12317. - if (err < 0)
  12318. - return err;
  12319. -
  12320. - if (tb[TCA_CBQ_RTAB] == NULL || tb[TCA_CBQ_RATE] == NULL)
  12321. - return -EINVAL;
  12322. -
  12323. - r = nla_data(tb[TCA_CBQ_RATE]);
  12324. -
  12325. - if ((q->link.R_tab = qdisc_get_rtab(r, tb[TCA_CBQ_RTAB])) == NULL)
  12326. - return -EINVAL;
  12327. -
  12328. - err = tcf_block_get(&q->link.block, &q->link.filter_list);
  12329. - if (err)
  12330. - goto put_rtab;
  12331. -
  12332. - err = qdisc_class_hash_init(&q->clhash);
  12333. - if (err < 0)
  12334. - goto put_block;
  12335. -
  12336. - q->link.sibling = &q->link;
  12337. - q->link.common.classid = sch->handle;
  12338. - q->link.qdisc = sch;
  12339. - q->link.q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops,
  12340. - sch->handle);
  12341. - if (!q->link.q)
  12342. - q->link.q = &noop_qdisc;
  12343. - else
  12344. - qdisc_hash_add(q->link.q, true);
  12345. -
  12346. - q->link.priority = TC_CBQ_MAXPRIO - 1;
  12347. - q->link.priority2 = TC_CBQ_MAXPRIO - 1;
  12348. - q->link.cpriority = TC_CBQ_MAXPRIO - 1;
  12349. - q->link.allot = psched_mtu(qdisc_dev(sch));
  12350. - q->link.quantum = q->link.allot;
  12351. - q->link.weight = q->link.R_tab->rate.rate;
  12352. -
  12353. - q->link.ewma_log = TC_CBQ_DEF_EWMA;
  12354. - q->link.avpkt = q->link.allot/2;
  12355. - q->link.minidle = -0x7FFFFFFF;
  12356. -
  12357. - q->toplevel = TC_CBQ_MAXLEVEL;
  12358. - q->now = psched_get_time();
  12359. -
  12360. - cbq_link_class(&q->link);
  12361. -
  12362. - if (tb[TCA_CBQ_LSSOPT])
  12363. - cbq_set_lss(&q->link, nla_data(tb[TCA_CBQ_LSSOPT]));
  12364. -
  12365. - cbq_addprio(q, &q->link);
  12366. - return 0;
  12367. -
  12368. -put_block:
  12369. - tcf_block_put(q->link.block);
  12370. -
  12371. -put_rtab:
  12372. - qdisc_put_rtab(q->link.R_tab);
  12373. - return err;
  12374. -}
  12375. -
  12376. -static int cbq_dump_rate(struct sk_buff *skb, struct cbq_class *cl)
  12377. -{
  12378. - unsigned char *b = skb_tail_pointer(skb);
  12379. -
  12380. - if (nla_put(skb, TCA_CBQ_RATE, sizeof(cl->R_tab->rate), &cl->R_tab->rate))
  12381. - goto nla_put_failure;
  12382. - return skb->len;
  12383. -
  12384. -nla_put_failure:
  12385. - nlmsg_trim(skb, b);
  12386. - return -1;
  12387. -}
  12388. -
  12389. -static int cbq_dump_lss(struct sk_buff *skb, struct cbq_class *cl)
  12390. -{
  12391. - unsigned char *b = skb_tail_pointer(skb);
  12392. - struct tc_cbq_lssopt opt;
  12393. -
  12394. - opt.flags = 0;
  12395. - if (cl->borrow == NULL)
  12396. - opt.flags |= TCF_CBQ_LSS_BOUNDED;
  12397. - if (cl->share == NULL)
  12398. - opt.flags |= TCF_CBQ_LSS_ISOLATED;
  12399. - opt.ewma_log = cl->ewma_log;
  12400. - opt.level = cl->level;
  12401. - opt.avpkt = cl->avpkt;
  12402. - opt.maxidle = cl->maxidle;
  12403. - opt.minidle = (u32)(-cl->minidle);
  12404. - opt.offtime = cl->offtime;
  12405. - opt.change = ~0;
  12406. - if (nla_put(skb, TCA_CBQ_LSSOPT, sizeof(opt), &opt))
  12407. - goto nla_put_failure;
  12408. - return skb->len;
  12409. -
  12410. -nla_put_failure:
  12411. - nlmsg_trim(skb, b);
  12412. - return -1;
  12413. -}
  12414. -
  12415. -static int cbq_dump_wrr(struct sk_buff *skb, struct cbq_class *cl)
  12416. -{
  12417. - unsigned char *b = skb_tail_pointer(skb);
  12418. - struct tc_cbq_wrropt opt;
  12419. -
  12420. - memset(&opt, 0, sizeof(opt));
  12421. - opt.flags = 0;
  12422. - opt.allot = cl->allot;
  12423. - opt.priority = cl->priority + 1;
  12424. - opt.cpriority = cl->cpriority + 1;
  12425. - opt.weight = cl->weight;
  12426. - if (nla_put(skb, TCA_CBQ_WRROPT, sizeof(opt), &opt))
  12427. - goto nla_put_failure;
  12428. - return skb->len;
  12429. -
  12430. -nla_put_failure:
  12431. - nlmsg_trim(skb, b);
  12432. - return -1;
  12433. -}
  12434. -
  12435. -static int cbq_dump_fopt(struct sk_buff *skb, struct cbq_class *cl)
  12436. -{
  12437. - unsigned char *b = skb_tail_pointer(skb);
  12438. - struct tc_cbq_fopt opt;
  12439. -
  12440. - if (cl->split || cl->defmap) {
  12441. - opt.split = cl->split ? cl->split->common.classid : 0;
  12442. - opt.defmap = cl->defmap;
  12443. - opt.defchange = ~0;
  12444. - if (nla_put(skb, TCA_CBQ_FOPT, sizeof(opt), &opt))
  12445. - goto nla_put_failure;
  12446. - }
  12447. - return skb->len;
  12448. -
  12449. -nla_put_failure:
  12450. - nlmsg_trim(skb, b);
  12451. - return -1;
  12452. -}
  12453. -
  12454. -static int cbq_dump_attr(struct sk_buff *skb, struct cbq_class *cl)
  12455. -{
  12456. - if (cbq_dump_lss(skb, cl) < 0 ||
  12457. - cbq_dump_rate(skb, cl) < 0 ||
  12458. - cbq_dump_wrr(skb, cl) < 0 ||
  12459. - cbq_dump_fopt(skb, cl) < 0)
  12460. - return -1;
  12461. - return 0;
  12462. -}
  12463. -
  12464. -static int cbq_dump(struct Qdisc *sch, struct sk_buff *skb)
  12465. -{
  12466. - struct cbq_sched_data *q = qdisc_priv(sch);
  12467. - struct nlattr *nest;
  12468. -
  12469. - nest = nla_nest_start(skb, TCA_OPTIONS);
  12470. - if (nest == NULL)
  12471. - goto nla_put_failure;
  12472. - if (cbq_dump_attr(skb, &q->link) < 0)
  12473. - goto nla_put_failure;
  12474. - return nla_nest_end(skb, nest);
  12475. -
  12476. -nla_put_failure:
  12477. - nla_nest_cancel(skb, nest);
  12478. - return -1;
  12479. -}
  12480. -
  12481. -static int
  12482. -cbq_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
  12483. -{
  12484. - struct cbq_sched_data *q = qdisc_priv(sch);
  12485. -
  12486. - q->link.xstats.avgidle = q->link.avgidle;
  12487. - return gnet_stats_copy_app(d, &q->link.xstats, sizeof(q->link.xstats));
  12488. -}
  12489. -
  12490. -static int
  12491. -cbq_dump_class(struct Qdisc *sch, unsigned long arg,
  12492. - struct sk_buff *skb, struct tcmsg *tcm)
  12493. -{
  12494. - struct cbq_class *cl = (struct cbq_class *)arg;
  12495. - struct nlattr *nest;
  12496. -
  12497. - if (cl->tparent)
  12498. - tcm->tcm_parent = cl->tparent->common.classid;
  12499. - else
  12500. - tcm->tcm_parent = TC_H_ROOT;
  12501. - tcm->tcm_handle = cl->common.classid;
  12502. - tcm->tcm_info = cl->q->handle;
  12503. -
  12504. - nest = nla_nest_start(skb, TCA_OPTIONS);
  12505. - if (nest == NULL)
  12506. - goto nla_put_failure;
  12507. - if (cbq_dump_attr(skb, cl) < 0)
  12508. - goto nla_put_failure;
  12509. - return nla_nest_end(skb, nest);
  12510. -
  12511. -nla_put_failure:
  12512. - nla_nest_cancel(skb, nest);
  12513. - return -1;
  12514. -}
  12515. -
  12516. -static int
  12517. -cbq_dump_class_stats(struct Qdisc *sch, unsigned long arg,
  12518. - struct gnet_dump *d)
  12519. -{
  12520. - struct cbq_sched_data *q = qdisc_priv(sch);
  12521. - struct cbq_class *cl = (struct cbq_class *)arg;
  12522. -
  12523. - cl->xstats.avgidle = cl->avgidle;
  12524. - cl->xstats.undertime = 0;
  12525. -
  12526. - if (cl->undertime != PSCHED_PASTPERFECT)
  12527. - cl->xstats.undertime = cl->undertime - q->now;
  12528. -
  12529. - if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch),
  12530. - d, NULL, &cl->bstats) < 0 ||
  12531. - gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 ||
  12532. - gnet_stats_copy_queue(d, NULL, &cl->qstats, cl->q->q.qlen) < 0)
  12533. - return -1;
  12534. -
  12535. - return gnet_stats_copy_app(d, &cl->xstats, sizeof(cl->xstats));
  12536. -}
  12537. -
  12538. -static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
  12539. - struct Qdisc **old)
  12540. -{
  12541. - struct cbq_class *cl = (struct cbq_class *)arg;
  12542. -
  12543. - if (new == NULL) {
  12544. - new = qdisc_create_dflt(sch->dev_queue,
  12545. - &pfifo_qdisc_ops, cl->common.classid);
  12546. - if (new == NULL)
  12547. - return -ENOBUFS;
  12548. - }
  12549. -
  12550. - *old = qdisc_replace(sch, new, &cl->q);
  12551. - return 0;
  12552. -}
  12553. -
  12554. -static struct Qdisc *cbq_leaf(struct Qdisc *sch, unsigned long arg)
  12555. -{
  12556. - struct cbq_class *cl = (struct cbq_class *)arg;
  12557. -
  12558. - return cl->q;
  12559. -}
  12560. -
  12561. -static void cbq_qlen_notify(struct Qdisc *sch, unsigned long arg)
  12562. -{
  12563. - struct cbq_class *cl = (struct cbq_class *)arg;
  12564. -
  12565. - cbq_deactivate_class(cl);
  12566. -}
  12567. -
  12568. -static unsigned long cbq_find(struct Qdisc *sch, u32 classid)
  12569. -{
  12570. - struct cbq_sched_data *q = qdisc_priv(sch);
  12571. -
  12572. - return (unsigned long)cbq_class_lookup(q, classid);
  12573. -}
  12574. -
  12575. -static void cbq_destroy_class(struct Qdisc *sch, struct cbq_class *cl)
  12576. -{
  12577. - struct cbq_sched_data *q = qdisc_priv(sch);
  12578. -
  12579. - WARN_ON(cl->filters);
  12580. -
  12581. - tcf_block_put(cl->block);
  12582. - qdisc_destroy(cl->q);
  12583. - qdisc_put_rtab(cl->R_tab);
  12584. - gen_kill_estimator(&cl->rate_est);
  12585. - if (cl != &q->link)
  12586. - kfree(cl);
  12587. -}
  12588. -
  12589. -static void cbq_destroy(struct Qdisc *sch)
  12590. -{
  12591. - struct cbq_sched_data *q = qdisc_priv(sch);
  12592. - struct hlist_node *next;
  12593. - struct cbq_class *cl;
  12594. - unsigned int h;
  12595. -
  12596. -#ifdef CONFIG_NET_CLS_ACT
  12597. - q->rx_class = NULL;
  12598. -#endif
  12599. - /*
  12600. - * Filters must be destroyed first because we don't destroy the
  12601. - * classes from root to leafs which means that filters can still
  12602. - * be bound to classes which have been destroyed already. --TGR '04
  12603. - */
  12604. - for (h = 0; h < q->clhash.hashsize; h++) {
  12605. - hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode) {
  12606. - tcf_block_put(cl->block);
  12607. - cl->block = NULL;
  12608. - }
  12609. - }
  12610. - for (h = 0; h < q->clhash.hashsize; h++) {
  12611. - hlist_for_each_entry_safe(cl, next, &q->clhash.hash[h],
  12612. - common.hnode)
  12613. - cbq_destroy_class(sch, cl);
  12614. - }
  12615. - qdisc_class_hash_destroy(&q->clhash);
  12616. -}
  12617. -
  12618. -static int
  12619. -cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **tca,
  12620. - unsigned long *arg)
  12621. -{
  12622. - int err;
  12623. - struct cbq_sched_data *q = qdisc_priv(sch);
  12624. - struct cbq_class *cl = (struct cbq_class *)*arg;
  12625. - struct nlattr *opt = tca[TCA_OPTIONS];
  12626. - struct nlattr *tb[TCA_CBQ_MAX + 1];
  12627. - struct cbq_class *parent;
  12628. - struct qdisc_rate_table *rtab = NULL;
  12629. -
  12630. - err = cbq_opt_parse(tb, opt);
  12631. - if (err < 0)
  12632. - return err;
  12633. -
  12634. - if (tb[TCA_CBQ_OVL_STRATEGY] || tb[TCA_CBQ_POLICE])
  12635. - return -EOPNOTSUPP;
  12636. -
  12637. - if (cl) {
  12638. - /* Check parent */
  12639. - if (parentid) {
  12640. - if (cl->tparent &&
  12641. - cl->tparent->common.classid != parentid)
  12642. - return -EINVAL;
  12643. - if (!cl->tparent && parentid != TC_H_ROOT)
  12644. - return -EINVAL;
  12645. - }
  12646. -
  12647. - if (tb[TCA_CBQ_RATE]) {
  12648. - rtab = qdisc_get_rtab(nla_data(tb[TCA_CBQ_RATE]),
  12649. - tb[TCA_CBQ_RTAB]);
  12650. - if (rtab == NULL)
  12651. - return -EINVAL;
  12652. - }
  12653. -
  12654. - if (tca[TCA_RATE]) {
  12655. - err = gen_replace_estimator(&cl->bstats, NULL,
  12656. - &cl->rate_est,
  12657. - NULL,
  12658. - qdisc_root_sleeping_running(sch),
  12659. - tca[TCA_RATE]);
  12660. - if (err) {
  12661. - qdisc_put_rtab(rtab);
  12662. - return err;
  12663. - }
  12664. - }
  12665. -
  12666. - /* Change class parameters */
  12667. - sch_tree_lock(sch);
  12668. -
  12669. - if (cl->next_alive != NULL)
  12670. - cbq_deactivate_class(cl);
  12671. -
  12672. - if (rtab) {
  12673. - qdisc_put_rtab(cl->R_tab);
  12674. - cl->R_tab = rtab;
  12675. - }
  12676. -
  12677. - if (tb[TCA_CBQ_LSSOPT])
  12678. - cbq_set_lss(cl, nla_data(tb[TCA_CBQ_LSSOPT]));
  12679. -
  12680. - if (tb[TCA_CBQ_WRROPT]) {
  12681. - cbq_rmprio(q, cl);
  12682. - cbq_set_wrr(cl, nla_data(tb[TCA_CBQ_WRROPT]));
  12683. - }
  12684. -
  12685. - if (tb[TCA_CBQ_FOPT])
  12686. - cbq_set_fopt(cl, nla_data(tb[TCA_CBQ_FOPT]));
  12687. -
  12688. - if (cl->q->q.qlen)
  12689. - cbq_activate_class(cl);
  12690. -
  12691. - sch_tree_unlock(sch);
  12692. -
  12693. - return 0;
  12694. - }
  12695. -
  12696. - if (parentid == TC_H_ROOT)
  12697. - return -EINVAL;
  12698. -
  12699. - if (tb[TCA_CBQ_WRROPT] == NULL || tb[TCA_CBQ_RATE] == NULL ||
  12700. - tb[TCA_CBQ_LSSOPT] == NULL)
  12701. - return -EINVAL;
  12702. -
  12703. - rtab = qdisc_get_rtab(nla_data(tb[TCA_CBQ_RATE]), tb[TCA_CBQ_RTAB]);
  12704. - if (rtab == NULL)
  12705. - return -EINVAL;
  12706. -
  12707. - if (classid) {
  12708. - err = -EINVAL;
  12709. - if (TC_H_MAJ(classid ^ sch->handle) ||
  12710. - cbq_class_lookup(q, classid))
  12711. - goto failure;
  12712. - } else {
  12713. - int i;
  12714. - classid = TC_H_MAKE(sch->handle, 0x8000);
  12715. -
  12716. - for (i = 0; i < 0x8000; i++) {
  12717. - if (++q->hgenerator >= 0x8000)
  12718. - q->hgenerator = 1;
  12719. - if (cbq_class_lookup(q, classid|q->hgenerator) == NULL)
  12720. - break;
  12721. - }
  12722. - err = -ENOSR;
  12723. - if (i >= 0x8000)
  12724. - goto failure;
  12725. - classid = classid|q->hgenerator;
  12726. - }
  12727. -
  12728. - parent = &q->link;
  12729. - if (parentid) {
  12730. - parent = cbq_class_lookup(q, parentid);
  12731. - err = -EINVAL;
  12732. - if (parent == NULL)
  12733. - goto failure;
  12734. - }
  12735. -
  12736. - err = -ENOBUFS;
  12737. - cl = kzalloc(sizeof(*cl), GFP_KERNEL);
  12738. - if (cl == NULL)
  12739. - goto failure;
  12740. -
  12741. - err = tcf_block_get(&cl->block, &cl->filter_list);
  12742. - if (err) {
  12743. - kfree(cl);
  12744. - goto failure;
  12745. - }
  12746. -
  12747. - if (tca[TCA_RATE]) {
  12748. - err = gen_new_estimator(&cl->bstats, NULL, &cl->rate_est,
  12749. - NULL,
  12750. - qdisc_root_sleeping_running(sch),
  12751. - tca[TCA_RATE]);
  12752. - if (err) {
  12753. - tcf_block_put(cl->block);
  12754. - kfree(cl);
  12755. - goto failure;
  12756. - }
  12757. - }
  12758. -
  12759. - cl->R_tab = rtab;
  12760. - rtab = NULL;
  12761. - cl->q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, classid);
  12762. - if (!cl->q)
  12763. - cl->q = &noop_qdisc;
  12764. - else
  12765. - qdisc_hash_add(cl->q, true);
  12766. -
  12767. - cl->common.classid = classid;
  12768. - cl->tparent = parent;
  12769. - cl->qdisc = sch;
  12770. - cl->allot = parent->allot;
  12771. - cl->quantum = cl->allot;
  12772. - cl->weight = cl->R_tab->rate.rate;
  12773. -
  12774. - sch_tree_lock(sch);
  12775. - cbq_link_class(cl);
  12776. - cl->borrow = cl->tparent;
  12777. - if (cl->tparent != &q->link)
  12778. - cl->share = cl->tparent;
  12779. - cbq_adjust_levels(parent);
  12780. - cl->minidle = -0x7FFFFFFF;
  12781. - cbq_set_lss(cl, nla_data(tb[TCA_CBQ_LSSOPT]));
  12782. - cbq_set_wrr(cl, nla_data(tb[TCA_CBQ_WRROPT]));
  12783. - if (cl->ewma_log == 0)
  12784. - cl->ewma_log = q->link.ewma_log;
  12785. - if (cl->maxidle == 0)
  12786. - cl->maxidle = q->link.maxidle;
  12787. - if (cl->avpkt == 0)
  12788. - cl->avpkt = q->link.avpkt;
  12789. - if (tb[TCA_CBQ_FOPT])
  12790. - cbq_set_fopt(cl, nla_data(tb[TCA_CBQ_FOPT]));
  12791. - sch_tree_unlock(sch);
  12792. -
  12793. - qdisc_class_hash_grow(sch, &q->clhash);
  12794. -
  12795. - *arg = (unsigned long)cl;
  12796. - return 0;
  12797. -
  12798. -failure:
  12799. - qdisc_put_rtab(rtab);
  12800. - return err;
  12801. -}
  12802. -
  12803. -static int cbq_delete(struct Qdisc *sch, unsigned long arg)
  12804. -{
  12805. - struct cbq_sched_data *q = qdisc_priv(sch);
  12806. - struct cbq_class *cl = (struct cbq_class *)arg;
  12807. - unsigned int qlen, backlog;
  12808. -
  12809. - if (cl->filters || cl->children || cl == &q->link)
  12810. - return -EBUSY;
  12811. -
  12812. - sch_tree_lock(sch);
  12813. -
  12814. - qlen = cl->q->q.qlen;
  12815. - backlog = cl->q->qstats.backlog;
  12816. - qdisc_reset(cl->q);
  12817. - qdisc_tree_reduce_backlog(cl->q, qlen, backlog);
  12818. -
  12819. - if (cl->next_alive)
  12820. - cbq_deactivate_class(cl);
  12821. -
  12822. - if (q->tx_borrowed == cl)
  12823. - q->tx_borrowed = q->tx_class;
  12824. - if (q->tx_class == cl) {
  12825. - q->tx_class = NULL;
  12826. - q->tx_borrowed = NULL;
  12827. - }
  12828. -#ifdef CONFIG_NET_CLS_ACT
  12829. - if (q->rx_class == cl)
  12830. - q->rx_class = NULL;
  12831. -#endif
  12832. -
  12833. - cbq_unlink_class(cl);
  12834. - cbq_adjust_levels(cl->tparent);
  12835. - cl->defmap = 0;
  12836. - cbq_sync_defmap(cl);
  12837. -
  12838. - cbq_rmprio(q, cl);
  12839. - sch_tree_unlock(sch);
  12840. -
  12841. - cbq_destroy_class(sch, cl);
  12842. - return 0;
  12843. -}
  12844. -
  12845. -static struct tcf_block *cbq_tcf_block(struct Qdisc *sch, unsigned long arg)
  12846. -{
  12847. - struct cbq_sched_data *q = qdisc_priv(sch);
  12848. - struct cbq_class *cl = (struct cbq_class *)arg;
  12849. -
  12850. - if (cl == NULL)
  12851. - cl = &q->link;
  12852. -
  12853. - return cl->block;
  12854. -}
  12855. -
  12856. -static unsigned long cbq_bind_filter(struct Qdisc *sch, unsigned long parent,
  12857. - u32 classid)
  12858. -{
  12859. - struct cbq_sched_data *q = qdisc_priv(sch);
  12860. - struct cbq_class *p = (struct cbq_class *)parent;
  12861. - struct cbq_class *cl = cbq_class_lookup(q, classid);
  12862. -
  12863. - if (cl) {
  12864. - if (p && p->level <= cl->level)
  12865. - return 0;
  12866. - cl->filters++;
  12867. - return (unsigned long)cl;
  12868. - }
  12869. - return 0;
  12870. -}
  12871. -
  12872. -static void cbq_unbind_filter(struct Qdisc *sch, unsigned long arg)
  12873. -{
  12874. - struct cbq_class *cl = (struct cbq_class *)arg;
  12875. -
  12876. - cl->filters--;
  12877. -}
  12878. -
  12879. -static void cbq_walk(struct Qdisc *sch, struct qdisc_walker *arg)
  12880. -{
  12881. - struct cbq_sched_data *q = qdisc_priv(sch);
  12882. - struct cbq_class *cl;
  12883. - unsigned int h;
  12884. -
  12885. - if (arg->stop)
  12886. - return;
  12887. -
  12888. - for (h = 0; h < q->clhash.hashsize; h++) {
  12889. - hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode) {
  12890. - if (arg->count < arg->skip) {
  12891. - arg->count++;
  12892. - continue;
  12893. - }
  12894. - if (arg->fn(sch, (unsigned long)cl, arg) < 0) {
  12895. - arg->stop = 1;
  12896. - return;
  12897. - }
  12898. - arg->count++;
  12899. - }
  12900. - }
  12901. -}
  12902. -
  12903. -static const struct Qdisc_class_ops cbq_class_ops = {
  12904. - .graft = cbq_graft,
  12905. - .leaf = cbq_leaf,
  12906. - .qlen_notify = cbq_qlen_notify,
  12907. - .find = cbq_find,
  12908. - .change = cbq_change_class,
  12909. - .delete = cbq_delete,
  12910. - .walk = cbq_walk,
  12911. - .tcf_block = cbq_tcf_block,
  12912. - .bind_tcf = cbq_bind_filter,
  12913. - .unbind_tcf = cbq_unbind_filter,
  12914. - .dump = cbq_dump_class,
  12915. - .dump_stats = cbq_dump_class_stats,
  12916. -};
  12917. -
  12918. -static struct Qdisc_ops cbq_qdisc_ops __read_mostly = {
  12919. - .next = NULL,
  12920. - .cl_ops = &cbq_class_ops,
  12921. - .id = "cbq",
  12922. - .priv_size = sizeof(struct cbq_sched_data),
  12923. - .enqueue = cbq_enqueue,
  12924. - .dequeue = cbq_dequeue,
  12925. - .peek = qdisc_peek_dequeued,
  12926. - .init = cbq_init,
  12927. - .reset = cbq_reset,
  12928. - .destroy = cbq_destroy,
  12929. - .change = NULL,
  12930. - .dump = cbq_dump,
  12931. - .dump_stats = cbq_dump_stats,
  12932. - .owner = THIS_MODULE,
  12933. -};
  12934. -
  12935. -static int __init cbq_module_init(void)
  12936. -{
  12937. - return register_qdisc(&cbq_qdisc_ops);
  12938. -}
  12939. -static void __exit cbq_module_exit(void)
  12940. -{
  12941. - unregister_qdisc(&cbq_qdisc_ops);
  12942. -}
  12943. -module_init(cbq_module_init)
  12944. -module_exit(cbq_module_exit)
  12945. -MODULE_LICENSE("GPL");
  12946. diff --git net/sched/sch_dsmark.c net/sched/sch_dsmark.c
  12947. deleted file mode 100644
  12948. index b972d50828ca..000000000000
  12949. --- linux-4.14.336/net/sched/sch_dsmark.c
  12950. +++ linux-4.14.336//dev/null
  12951. @@ -1,514 +0,0 @@
  12952. -/* net/sched/sch_dsmark.c - Differentiated Services field marker */
  12953. -
  12954. -/* Written 1998-2000 by Werner Almesberger, EPFL ICA */
  12955. -
  12956. -
  12957. -#include <linux/module.h>
  12958. -#include <linux/init.h>
  12959. -#include <linux/slab.h>
  12960. -#include <linux/types.h>
  12961. -#include <linux/string.h>
  12962. -#include <linux/errno.h>
  12963. -#include <linux/skbuff.h>
  12964. -#include <linux/rtnetlink.h>
  12965. -#include <linux/bitops.h>
  12966. -#include <net/pkt_sched.h>
  12967. -#include <net/pkt_cls.h>
  12968. -#include <net/dsfield.h>
  12969. -#include <net/inet_ecn.h>
  12970. -#include <asm/byteorder.h>
  12971. -
  12972. -/*
  12973. - * classid class marking
  12974. - * ------- ----- -------
  12975. - * n/a 0 n/a
  12976. - * x:0 1 use entry [0]
  12977. - * ... ... ...
  12978. - * x:y y>0 y+1 use entry [y]
  12979. - * ... ... ...
  12980. - * x:indices-1 indices use entry [indices-1]
  12981. - * ... ... ...
  12982. - * x:y y+1 use entry [y & (indices-1)]
  12983. - * ... ... ...
  12984. - * 0xffff 0x10000 use entry [indices-1]
  12985. - */
  12986. -
  12987. -
  12988. -#define NO_DEFAULT_INDEX (1 << 16)
  12989. -
  12990. -struct mask_value {
  12991. - u8 mask;
  12992. - u8 value;
  12993. -};
  12994. -
  12995. -struct dsmark_qdisc_data {
  12996. - struct Qdisc *q;
  12997. - struct tcf_proto __rcu *filter_list;
  12998. - struct tcf_block *block;
  12999. - struct mask_value *mv;
  13000. - u16 indices;
  13001. - u8 set_tc_index;
  13002. - u32 default_index; /* index range is 0...0xffff */
  13003. -#define DSMARK_EMBEDDED_SZ 16
  13004. - struct mask_value embedded[DSMARK_EMBEDDED_SZ];
  13005. -};
  13006. -
  13007. -static inline int dsmark_valid_index(struct dsmark_qdisc_data *p, u16 index)
  13008. -{
  13009. - return index <= p->indices && index > 0;
  13010. -}
  13011. -
  13012. -/* ------------------------- Class/flow operations ------------------------- */
  13013. -
  13014. -static int dsmark_graft(struct Qdisc *sch, unsigned long arg,
  13015. - struct Qdisc *new, struct Qdisc **old)
  13016. -{
  13017. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13018. -
  13019. - pr_debug("%s(sch %p,[qdisc %p],new %p,old %p)\n",
  13020. - __func__, sch, p, new, old);
  13021. -
  13022. - if (new == NULL) {
  13023. - new = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops,
  13024. - sch->handle);
  13025. - if (new == NULL)
  13026. - new = &noop_qdisc;
  13027. - }
  13028. -
  13029. - *old = qdisc_replace(sch, new, &p->q);
  13030. - return 0;
  13031. -}
  13032. -
  13033. -static struct Qdisc *dsmark_leaf(struct Qdisc *sch, unsigned long arg)
  13034. -{
  13035. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13036. - return p->q;
  13037. -}
  13038. -
  13039. -static unsigned long dsmark_find(struct Qdisc *sch, u32 classid)
  13040. -{
  13041. - return TC_H_MIN(classid) + 1;
  13042. -}
  13043. -
  13044. -static unsigned long dsmark_bind_filter(struct Qdisc *sch,
  13045. - unsigned long parent, u32 classid)
  13046. -{
  13047. - pr_debug("%s(sch %p,[qdisc %p],classid %x)\n",
  13048. - __func__, sch, qdisc_priv(sch), classid);
  13049. -
  13050. - return dsmark_find(sch, classid);
  13051. -}
  13052. -
  13053. -static void dsmark_unbind_filter(struct Qdisc *sch, unsigned long cl)
  13054. -{
  13055. -}
  13056. -
  13057. -static const struct nla_policy dsmark_policy[TCA_DSMARK_MAX + 1] = {
  13058. - [TCA_DSMARK_INDICES] = { .type = NLA_U16 },
  13059. - [TCA_DSMARK_DEFAULT_INDEX] = { .type = NLA_U16 },
  13060. - [TCA_DSMARK_SET_TC_INDEX] = { .type = NLA_FLAG },
  13061. - [TCA_DSMARK_MASK] = { .type = NLA_U8 },
  13062. - [TCA_DSMARK_VALUE] = { .type = NLA_U8 },
  13063. -};
  13064. -
  13065. -static int dsmark_change(struct Qdisc *sch, u32 classid, u32 parent,
  13066. - struct nlattr **tca, unsigned long *arg)
  13067. -{
  13068. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13069. - struct nlattr *opt = tca[TCA_OPTIONS];
  13070. - struct nlattr *tb[TCA_DSMARK_MAX + 1];
  13071. - int err = -EINVAL;
  13072. -
  13073. - pr_debug("%s(sch %p,[qdisc %p],classid %x,parent %x), arg 0x%lx\n",
  13074. - __func__, sch, p, classid, parent, *arg);
  13075. -
  13076. - if (!dsmark_valid_index(p, *arg)) {
  13077. - err = -ENOENT;
  13078. - goto errout;
  13079. - }
  13080. -
  13081. - if (!opt)
  13082. - goto errout;
  13083. -
  13084. - err = nla_parse_nested(tb, TCA_DSMARK_MAX, opt, dsmark_policy, NULL);
  13085. - if (err < 0)
  13086. - goto errout;
  13087. -
  13088. - if (tb[TCA_DSMARK_VALUE])
  13089. - p->mv[*arg - 1].value = nla_get_u8(tb[TCA_DSMARK_VALUE]);
  13090. -
  13091. - if (tb[TCA_DSMARK_MASK])
  13092. - p->mv[*arg - 1].mask = nla_get_u8(tb[TCA_DSMARK_MASK]);
  13093. -
  13094. - err = 0;
  13095. -
  13096. -errout:
  13097. - return err;
  13098. -}
  13099. -
  13100. -static int dsmark_delete(struct Qdisc *sch, unsigned long arg)
  13101. -{
  13102. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13103. -
  13104. - if (!dsmark_valid_index(p, arg))
  13105. - return -EINVAL;
  13106. -
  13107. - p->mv[arg - 1].mask = 0xff;
  13108. - p->mv[arg - 1].value = 0;
  13109. -
  13110. - return 0;
  13111. -}
  13112. -
  13113. -static void dsmark_walk(struct Qdisc *sch, struct qdisc_walker *walker)
  13114. -{
  13115. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13116. - int i;
  13117. -
  13118. - pr_debug("%s(sch %p,[qdisc %p],walker %p)\n",
  13119. - __func__, sch, p, walker);
  13120. -
  13121. - if (walker->stop)
  13122. - return;
  13123. -
  13124. - for (i = 0; i < p->indices; i++) {
  13125. - if (p->mv[i].mask == 0xff && !p->mv[i].value)
  13126. - goto ignore;
  13127. - if (walker->count >= walker->skip) {
  13128. - if (walker->fn(sch, i + 1, walker) < 0) {
  13129. - walker->stop = 1;
  13130. - break;
  13131. - }
  13132. - }
  13133. -ignore:
  13134. - walker->count++;
  13135. - }
  13136. -}
  13137. -
  13138. -static struct tcf_block *dsmark_tcf_block(struct Qdisc *sch, unsigned long cl)
  13139. -{
  13140. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13141. -
  13142. - return p->block;
  13143. -}
  13144. -
  13145. -/* --------------------------- Qdisc operations ---------------------------- */
  13146. -
  13147. -static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch,
  13148. - struct sk_buff **to_free)
  13149. -{
  13150. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13151. - int err;
  13152. -
  13153. - pr_debug("%s(skb %p,sch %p,[qdisc %p])\n", __func__, skb, sch, p);
  13154. -
  13155. - if (p->set_tc_index) {
  13156. - int wlen = skb_network_offset(skb);
  13157. -
  13158. - switch (tc_skb_protocol(skb)) {
  13159. - case htons(ETH_P_IP):
  13160. - wlen += sizeof(struct iphdr);
  13161. - if (!pskb_may_pull(skb, wlen) ||
  13162. - skb_try_make_writable(skb, wlen))
  13163. - goto drop;
  13164. -
  13165. - skb->tc_index = ipv4_get_dsfield(ip_hdr(skb))
  13166. - & ~INET_ECN_MASK;
  13167. - break;
  13168. -
  13169. - case htons(ETH_P_IPV6):
  13170. - wlen += sizeof(struct ipv6hdr);
  13171. - if (!pskb_may_pull(skb, wlen) ||
  13172. - skb_try_make_writable(skb, wlen))
  13173. - goto drop;
  13174. -
  13175. - skb->tc_index = ipv6_get_dsfield(ipv6_hdr(skb))
  13176. - & ~INET_ECN_MASK;
  13177. - break;
  13178. - default:
  13179. - skb->tc_index = 0;
  13180. - break;
  13181. - }
  13182. - }
  13183. -
  13184. - if (TC_H_MAJ(skb->priority) == sch->handle)
  13185. - skb->tc_index = TC_H_MIN(skb->priority);
  13186. - else {
  13187. - struct tcf_result res;
  13188. - struct tcf_proto *fl = rcu_dereference_bh(p->filter_list);
  13189. - int result = tcf_classify(skb, fl, &res, false);
  13190. -
  13191. - pr_debug("result %d class 0x%04x\n", result, res.classid);
  13192. -
  13193. - switch (result) {
  13194. -#ifdef CONFIG_NET_CLS_ACT
  13195. - case TC_ACT_QUEUED:
  13196. - case TC_ACT_STOLEN:
  13197. - case TC_ACT_TRAP:
  13198. - __qdisc_drop(skb, to_free);
  13199. - return NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
  13200. -
  13201. - case TC_ACT_SHOT:
  13202. - goto drop;
  13203. -#endif
  13204. - case TC_ACT_OK:
  13205. - skb->tc_index = TC_H_MIN(res.classid);
  13206. - break;
  13207. -
  13208. - default:
  13209. - if (p->default_index != NO_DEFAULT_INDEX)
  13210. - skb->tc_index = p->default_index;
  13211. - break;
  13212. - }
  13213. - }
  13214. -
  13215. - err = qdisc_enqueue(skb, p->q, to_free);
  13216. - if (err != NET_XMIT_SUCCESS) {
  13217. - if (net_xmit_drop_count(err))
  13218. - qdisc_qstats_drop(sch);
  13219. - return err;
  13220. - }
  13221. -
  13222. - qdisc_qstats_backlog_inc(sch, skb);
  13223. - sch->q.qlen++;
  13224. -
  13225. - return NET_XMIT_SUCCESS;
  13226. -
  13227. -drop:
  13228. - qdisc_drop(skb, sch, to_free);
  13229. - return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
  13230. -}
  13231. -
  13232. -static struct sk_buff *dsmark_dequeue(struct Qdisc *sch)
  13233. -{
  13234. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13235. - struct sk_buff *skb;
  13236. - u32 index;
  13237. -
  13238. - pr_debug("%s(sch %p,[qdisc %p])\n", __func__, sch, p);
  13239. -
  13240. - skb = qdisc_dequeue_peeked(p->q);
  13241. - if (skb == NULL)
  13242. - return NULL;
  13243. -
  13244. - qdisc_bstats_update(sch, skb);
  13245. - qdisc_qstats_backlog_dec(sch, skb);
  13246. - sch->q.qlen--;
  13247. -
  13248. - index = skb->tc_index & (p->indices - 1);
  13249. - pr_debug("index %d->%d\n", skb->tc_index, index);
  13250. -
  13251. - switch (tc_skb_protocol(skb)) {
  13252. - case htons(ETH_P_IP):
  13253. - ipv4_change_dsfield(ip_hdr(skb), p->mv[index].mask,
  13254. - p->mv[index].value);
  13255. - break;
  13256. - case htons(ETH_P_IPV6):
  13257. - ipv6_change_dsfield(ipv6_hdr(skb), p->mv[index].mask,
  13258. - p->mv[index].value);
  13259. - break;
  13260. - default:
  13261. - /*
  13262. - * Only complain if a change was actually attempted.
  13263. - * This way, we can send non-IP traffic through dsmark
  13264. - * and don't need yet another qdisc as a bypass.
  13265. - */
  13266. - if (p->mv[index].mask != 0xff || p->mv[index].value)
  13267. - pr_warn("%s: unsupported protocol %d\n",
  13268. - __func__, ntohs(tc_skb_protocol(skb)));
  13269. - break;
  13270. - }
  13271. -
  13272. - return skb;
  13273. -}
  13274. -
  13275. -static struct sk_buff *dsmark_peek(struct Qdisc *sch)
  13276. -{
  13277. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13278. -
  13279. - pr_debug("%s(sch %p,[qdisc %p])\n", __func__, sch, p);
  13280. -
  13281. - return p->q->ops->peek(p->q);
  13282. -}
  13283. -
  13284. -static int dsmark_init(struct Qdisc *sch, struct nlattr *opt)
  13285. -{
  13286. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13287. - struct nlattr *tb[TCA_DSMARK_MAX + 1];
  13288. - int err = -EINVAL;
  13289. - u32 default_index = NO_DEFAULT_INDEX;
  13290. - u16 indices;
  13291. - int i;
  13292. -
  13293. - pr_debug("%s(sch %p,[qdisc %p],opt %p)\n", __func__, sch, p, opt);
  13294. -
  13295. - if (!opt)
  13296. - goto errout;
  13297. -
  13298. - err = tcf_block_get(&p->block, &p->filter_list);
  13299. - if (err)
  13300. - return err;
  13301. -
  13302. - err = nla_parse_nested(tb, TCA_DSMARK_MAX, opt, dsmark_policy, NULL);
  13303. - if (err < 0)
  13304. - goto errout;
  13305. -
  13306. - err = -EINVAL;
  13307. - if (!tb[TCA_DSMARK_INDICES])
  13308. - goto errout;
  13309. - indices = nla_get_u16(tb[TCA_DSMARK_INDICES]);
  13310. -
  13311. - if (hweight32(indices) != 1)
  13312. - goto errout;
  13313. -
  13314. - if (tb[TCA_DSMARK_DEFAULT_INDEX])
  13315. - default_index = nla_get_u16(tb[TCA_DSMARK_DEFAULT_INDEX]);
  13316. -
  13317. - if (indices <= DSMARK_EMBEDDED_SZ)
  13318. - p->mv = p->embedded;
  13319. - else
  13320. - p->mv = kmalloc_array(indices, sizeof(*p->mv), GFP_KERNEL);
  13321. - if (!p->mv) {
  13322. - err = -ENOMEM;
  13323. - goto errout;
  13324. - }
  13325. - for (i = 0; i < indices; i++) {
  13326. - p->mv[i].mask = 0xff;
  13327. - p->mv[i].value = 0;
  13328. - }
  13329. - p->indices = indices;
  13330. - p->default_index = default_index;
  13331. - p->set_tc_index = nla_get_flag(tb[TCA_DSMARK_SET_TC_INDEX]);
  13332. -
  13333. - p->q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, sch->handle);
  13334. - if (p->q == NULL)
  13335. - p->q = &noop_qdisc;
  13336. - else
  13337. - qdisc_hash_add(p->q, true);
  13338. -
  13339. - pr_debug("%s: qdisc %p\n", __func__, p->q);
  13340. -
  13341. - err = 0;
  13342. -errout:
  13343. - return err;
  13344. -}
  13345. -
  13346. -static void dsmark_reset(struct Qdisc *sch)
  13347. -{
  13348. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13349. -
  13350. - pr_debug("%s(sch %p,[qdisc %p])\n", __func__, sch, p);
  13351. - if (p->q)
  13352. - qdisc_reset(p->q);
  13353. - sch->qstats.backlog = 0;
  13354. - sch->q.qlen = 0;
  13355. -}
  13356. -
  13357. -static void dsmark_destroy(struct Qdisc *sch)
  13358. -{
  13359. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13360. -
  13361. - pr_debug("%s(sch %p,[qdisc %p])\n", __func__, sch, p);
  13362. -
  13363. - tcf_block_put(p->block);
  13364. - qdisc_destroy(p->q);
  13365. - if (p->mv != p->embedded)
  13366. - kfree(p->mv);
  13367. -}
  13368. -
  13369. -static int dsmark_dump_class(struct Qdisc *sch, unsigned long cl,
  13370. - struct sk_buff *skb, struct tcmsg *tcm)
  13371. -{
  13372. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13373. - struct nlattr *opts = NULL;
  13374. -
  13375. - pr_debug("%s(sch %p,[qdisc %p],class %ld\n", __func__, sch, p, cl);
  13376. -
  13377. - if (!dsmark_valid_index(p, cl))
  13378. - return -EINVAL;
  13379. -
  13380. - tcm->tcm_handle = TC_H_MAKE(TC_H_MAJ(sch->handle), cl - 1);
  13381. - tcm->tcm_info = p->q->handle;
  13382. -
  13383. - opts = nla_nest_start(skb, TCA_OPTIONS);
  13384. - if (opts == NULL)
  13385. - goto nla_put_failure;
  13386. - if (nla_put_u8(skb, TCA_DSMARK_MASK, p->mv[cl - 1].mask) ||
  13387. - nla_put_u8(skb, TCA_DSMARK_VALUE, p->mv[cl - 1].value))
  13388. - goto nla_put_failure;
  13389. -
  13390. - return nla_nest_end(skb, opts);
  13391. -
  13392. -nla_put_failure:
  13393. - nla_nest_cancel(skb, opts);
  13394. - return -EMSGSIZE;
  13395. -}
  13396. -
  13397. -static int dsmark_dump(struct Qdisc *sch, struct sk_buff *skb)
  13398. -{
  13399. - struct dsmark_qdisc_data *p = qdisc_priv(sch);
  13400. - struct nlattr *opts = NULL;
  13401. -
  13402. - opts = nla_nest_start(skb, TCA_OPTIONS);
  13403. - if (opts == NULL)
  13404. - goto nla_put_failure;
  13405. - if (nla_put_u16(skb, TCA_DSMARK_INDICES, p->indices))
  13406. - goto nla_put_failure;
  13407. -
  13408. - if (p->default_index != NO_DEFAULT_INDEX &&
  13409. - nla_put_u16(skb, TCA_DSMARK_DEFAULT_INDEX, p->default_index))
  13410. - goto nla_put_failure;
  13411. -
  13412. - if (p->set_tc_index &&
  13413. - nla_put_flag(skb, TCA_DSMARK_SET_TC_INDEX))
  13414. - goto nla_put_failure;
  13415. -
  13416. - return nla_nest_end(skb, opts);
  13417. -
  13418. -nla_put_failure:
  13419. - nla_nest_cancel(skb, opts);
  13420. - return -EMSGSIZE;
  13421. -}
  13422. -
  13423. -static const struct Qdisc_class_ops dsmark_class_ops = {
  13424. - .graft = dsmark_graft,
  13425. - .leaf = dsmark_leaf,
  13426. - .find = dsmark_find,
  13427. - .change = dsmark_change,
  13428. - .delete = dsmark_delete,
  13429. - .walk = dsmark_walk,
  13430. - .tcf_block = dsmark_tcf_block,
  13431. - .bind_tcf = dsmark_bind_filter,
  13432. - .unbind_tcf = dsmark_unbind_filter,
  13433. - .dump = dsmark_dump_class,
  13434. -};
  13435. -
  13436. -static struct Qdisc_ops dsmark_qdisc_ops __read_mostly = {
  13437. - .next = NULL,
  13438. - .cl_ops = &dsmark_class_ops,
  13439. - .id = "dsmark",
  13440. - .priv_size = sizeof(struct dsmark_qdisc_data),
  13441. - .enqueue = dsmark_enqueue,
  13442. - .dequeue = dsmark_dequeue,
  13443. - .peek = dsmark_peek,
  13444. - .init = dsmark_init,
  13445. - .reset = dsmark_reset,
  13446. - .destroy = dsmark_destroy,
  13447. - .change = NULL,
  13448. - .dump = dsmark_dump,
  13449. - .owner = THIS_MODULE,
  13450. -};
  13451. -
  13452. -static int __init dsmark_module_init(void)
  13453. -{
  13454. - return register_qdisc(&dsmark_qdisc_ops);
  13455. -}
  13456. -
  13457. -static void __exit dsmark_module_exit(void)
  13458. -{
  13459. - unregister_qdisc(&dsmark_qdisc_ops);
  13460. -}
  13461. -
  13462. -module_init(dsmark_module_init)
  13463. -module_exit(dsmark_module_exit)
  13464. -
  13465. -MODULE_LICENSE("GPL");
  13466. diff --git net/sunrpc/xprtmultipath.c net/sunrpc/xprtmultipath.c
  13467. index e2d64c7138c3..699d5ba128fa 100644
  13468. --- linux-4.14.336/net/sunrpc/xprtmultipath.c
  13469. +++ linux-4.14.336/net/sunrpc/xprtmultipath.c
  13470. @@ -235,8 +235,9 @@ struct rpc_xprt *xprt_iter_current_entry(struct rpc_xprt_iter *xpi)
  13471. return xprt_switch_find_current_entry(head, xpi->xpi_cursor);
  13472. }
  13473. -bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
  13474. - const struct sockaddr *sap)
  13475. +static
  13476. +bool __rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
  13477. + const struct sockaddr *sap)
  13478. {
  13479. struct list_head *head;
  13480. struct rpc_xprt *pos;
  13481. @@ -255,6 +256,18 @@ bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
  13482. return false;
  13483. }
  13484. +bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
  13485. + const struct sockaddr *sap)
  13486. +{
  13487. + bool res;
  13488. +
  13489. + rcu_read_lock();
  13490. + res = __rpc_xprt_switch_has_addr(xps, sap);
  13491. + rcu_read_unlock();
  13492. +
  13493. + return res;
  13494. +}
  13495. +
  13496. static
  13497. struct rpc_xprt *xprt_switch_find_next_entry(struct list_head *head,
  13498. const struct rpc_xprt *cur)
  13499. diff --git net/tipc/bearer.c net/tipc/bearer.c
  13500. index 506cbd1b2223..db21e00806f5 100644
  13501. --- linux-4.14.336/net/tipc/bearer.c
  13502. +++ linux-4.14.336/net/tipc/bearer.c
  13503. @@ -931,6 +931,12 @@ int tipc_nl_bearer_add(struct sk_buff *skb, struct genl_info *info)
  13504. #ifdef CONFIG_TIPC_MEDIA_UDP
  13505. if (attrs[TIPC_NLA_BEARER_UDP_OPTS]) {
  13506. + if (b->media->type_id != TIPC_MEDIA_TYPE_UDP) {
  13507. + rtnl_unlock();
  13508. + NL_SET_ERR_MSG(info->extack, "UDP option is unsupported");
  13509. + return -EINVAL;
  13510. + }
  13511. +
  13512. err = tipc_udp_nl_bearer_add(b,
  13513. attrs[TIPC_NLA_BEARER_UDP_OPTS]);
  13514. if (err) {
  13515. diff --git net/unix/af_unix.c net/unix/af_unix.c
  13516. index 8d25d50f916e..b1855778acd0 100644
  13517. --- linux-4.14.336/net/unix/af_unix.c
  13518. +++ linux-4.14.336/net/unix/af_unix.c
  13519. @@ -1127,13 +1127,11 @@ static void unix_state_double_lock(struct sock *sk1, struct sock *sk2)
  13520. unix_state_lock(sk1);
  13521. return;
  13522. }
  13523. - if (sk1 < sk2) {
  13524. - unix_state_lock(sk1);
  13525. - unix_state_lock_nested(sk2);
  13526. - } else {
  13527. - unix_state_lock(sk2);
  13528. - unix_state_lock_nested(sk1);
  13529. - }
  13530. + if (sk1 > sk2)
  13531. + swap(sk1, sk2);
  13532. +
  13533. + unix_state_lock(sk1);
  13534. + unix_state_lock_nested(sk2, U_LOCK_SECOND);
  13535. }
  13536. static void unix_state_double_unlock(struct sock *sk1, struct sock *sk2)
  13537. @@ -1352,7 +1350,7 @@ restart:
  13538. goto out_unlock;
  13539. }
  13540. - unix_state_lock_nested(sk);
  13541. + unix_state_lock_nested(sk, U_LOCK_SECOND);
  13542. if (sk->sk_state != st) {
  13543. unix_state_unlock(sk);
  13544. diff --git net/unix/diag.c net/unix/diag.c
  13545. index 3183d9b8ab33..d6ceac688def 100644
  13546. --- linux-4.14.336/net/unix/diag.c
  13547. +++ linux-4.14.336/net/unix/diag.c
  13548. @@ -80,7 +80,7 @@ static int sk_diag_dump_icons(struct sock *sk, struct sk_buff *nlskb)
  13549. * queue lock. With the other's queue locked it's
  13550. * OK to lock the state.
  13551. */
  13552. - unix_state_lock_nested(req);
  13553. + unix_state_lock_nested(req, U_LOCK_DIAG);
  13554. peer = unix_sk(req)->peer;
  13555. buf[i++] = (peer ? sock_i_ino(peer) : 0);
  13556. unix_state_unlock(req);
  13557. diff --git net/wireless/nl80211.c net/wireless/nl80211.c
  13558. index b4b564182db0..4f43f4dfb996 100644
  13559. --- linux-4.14.336/net/wireless/nl80211.c
  13560. +++ linux-4.14.336/net/wireless/nl80211.c
  13561. @@ -2717,6 +2717,7 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback *
  13562. if_idx++;
  13563. }
  13564. + if_start = 0;
  13565. wp_idx++;
  13566. }
  13567. out:
  13568. @@ -2896,6 +2897,8 @@ static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info)
  13569. if (ntype != NL80211_IFTYPE_MESH_POINT)
  13570. return -EINVAL;
  13571. + if (otype != NL80211_IFTYPE_MESH_POINT)
  13572. + return -EINVAL;
  13573. if (netif_running(dev))
  13574. return -EBUSY;
  13575. diff --git net/wireless/scan.c net/wireless/scan.c
  13576. index 8bbcdcf5c829..88fe0e8e8b18 100644
  13577. --- linux-4.14.336/net/wireless/scan.c
  13578. +++ linux-4.14.336/net/wireless/scan.c
  13579. @@ -1015,8 +1015,12 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev,
  13580. list_add(&new->hidden_list,
  13581. &hidden->hidden_list);
  13582. hidden->refcount++;
  13583. +
  13584. + ies = (void *)rcu_access_pointer(new->pub.beacon_ies);
  13585. rcu_assign_pointer(new->pub.beacon_ies,
  13586. hidden->pub.beacon_ies);
  13587. + if (ies)
  13588. + kfree_rcu(ies, rcu_head);
  13589. }
  13590. } else {
  13591. /*
  13592. diff --git security/apparmor/policy_unpack.c security/apparmor/policy_unpack.c
  13593. index 2cef8d4404cc..4f41aa6ff897 100644
  13594. --- linux-4.14.336/security/apparmor/policy_unpack.c
  13595. +++ linux-4.14.336/security/apparmor/policy_unpack.c
  13596. @@ -604,6 +604,10 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
  13597. tmpname = aa_splitn_fqname(name, strlen(name), &tmpns, &ns_len);
  13598. if (tmpns) {
  13599. + if (!tmpname) {
  13600. + info = "empty profile name";
  13601. + goto fail;
  13602. + }
  13603. *ns_name = kstrndup(tmpns, ns_len, GFP_KERNEL);
  13604. if (!*ns_name) {
  13605. info = "out of memory";
  13606. diff --git security/security.c security/security.c
  13607. index b5e3d7a91b33..90c2094380e2 100644
  13608. --- linux-4.14.336/security/security.c
  13609. +++ linux-4.14.336/security/security.c
  13610. @@ -884,6 +884,23 @@ int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  13611. return call_int_hook(file_ioctl, 0, file, cmd, arg);
  13612. }
  13613. +/**
  13614. + * security_file_ioctl_compat() - Check if an ioctl is allowed in compat mode
  13615. + * @file: associated file
  13616. + * @cmd: ioctl cmd
  13617. + * @arg: ioctl arguments
  13618. + *
  13619. + * Compat version of security_file_ioctl() that correctly handles 32-bit
  13620. + * processes running on 64-bit kernels.
  13621. + *
  13622. + * Return: Returns 0 if permission is granted.
  13623. + */
  13624. +int security_file_ioctl_compat(struct file *file, unsigned int cmd,
  13625. + unsigned long arg)
  13626. +{
  13627. + return call_int_hook(file_ioctl_compat, 0, file, cmd, arg);
  13628. +}
  13629. +
  13630. static inline unsigned long mmap_prot(struct file *file, unsigned long prot)
  13631. {
  13632. /*
  13633. diff --git security/selinux/hooks.c security/selinux/hooks.c
  13634. index 38a4db1f3aaa..a1613e22a734 100644
  13635. --- linux-4.14.336/security/selinux/hooks.c
  13636. +++ linux-4.14.336/security/selinux/hooks.c
  13637. @@ -3571,6 +3571,33 @@ static int selinux_file_ioctl(struct file *file, unsigned int cmd,
  13638. return error;
  13639. }
  13640. +static int selinux_file_ioctl_compat(struct file *file, unsigned int cmd,
  13641. + unsigned long arg)
  13642. +{
  13643. + /*
  13644. + * If we are in a 64-bit kernel running 32-bit userspace, we need to
  13645. + * make sure we don't compare 32-bit flags to 64-bit flags.
  13646. + */
  13647. + switch (cmd) {
  13648. + case FS_IOC32_GETFLAGS:
  13649. + cmd = FS_IOC_GETFLAGS;
  13650. + break;
  13651. + case FS_IOC32_SETFLAGS:
  13652. + cmd = FS_IOC_SETFLAGS;
  13653. + break;
  13654. + case FS_IOC32_GETVERSION:
  13655. + cmd = FS_IOC_GETVERSION;
  13656. + break;
  13657. + case FS_IOC32_SETVERSION:
  13658. + cmd = FS_IOC_SETVERSION;
  13659. + break;
  13660. + default:
  13661. + break;
  13662. + }
  13663. +
  13664. + return selinux_file_ioctl(file, cmd, arg);
  13665. +}
  13666. +
  13667. static int default_noexec;
  13668. static int file_map_prot_check(struct file *file, unsigned long prot, int shared)
  13669. @@ -6377,6 +6404,7 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
  13670. LSM_HOOK_INIT(file_alloc_security, selinux_file_alloc_security),
  13671. LSM_HOOK_INIT(file_free_security, selinux_file_free_security),
  13672. LSM_HOOK_INIT(file_ioctl, selinux_file_ioctl),
  13673. + LSM_HOOK_INIT(file_ioctl_compat, selinux_file_ioctl_compat),
  13674. LSM_HOOK_INIT(mmap_file, selinux_mmap_file),
  13675. LSM_HOOK_INIT(mmap_addr, selinux_mmap_addr),
  13676. LSM_HOOK_INIT(file_mprotect, selinux_file_mprotect),
  13677. diff --git security/smack/smack_lsm.c security/smack/smack_lsm.c
  13678. index fe070669dc18..a6e81ef73b42 100644
  13679. --- linux-4.14.336/security/smack/smack_lsm.c
  13680. +++ linux-4.14.336/security/smack/smack_lsm.c
  13681. @@ -4651,6 +4651,7 @@ static struct security_hook_list smack_hooks[] __lsm_ro_after_init = {
  13682. LSM_HOOK_INIT(file_alloc_security, smack_file_alloc_security),
  13683. LSM_HOOK_INIT(file_free_security, smack_file_free_security),
  13684. LSM_HOOK_INIT(file_ioctl, smack_file_ioctl),
  13685. + LSM_HOOK_INIT(file_ioctl_compat, smack_file_ioctl),
  13686. LSM_HOOK_INIT(file_lock, smack_file_lock),
  13687. LSM_HOOK_INIT(file_fcntl, smack_file_fcntl),
  13688. LSM_HOOK_INIT(mmap_file, smack_mmap_file),
  13689. diff --git security/tomoyo/tomoyo.c security/tomoyo/tomoyo.c
  13690. index 213b8c593668..195f9b706926 100644
  13691. --- linux-4.14.336/security/tomoyo/tomoyo.c
  13692. +++ linux-4.14.336/security/tomoyo/tomoyo.c
  13693. @@ -516,6 +516,7 @@ static struct security_hook_list tomoyo_hooks[] __lsm_ro_after_init = {
  13694. LSM_HOOK_INIT(path_rename, tomoyo_path_rename),
  13695. LSM_HOOK_INIT(inode_getattr, tomoyo_inode_getattr),
  13696. LSM_HOOK_INIT(file_ioctl, tomoyo_file_ioctl),
  13697. + LSM_HOOK_INIT(file_ioctl_compat, tomoyo_file_ioctl),
  13698. LSM_HOOK_INIT(path_chmod, tomoyo_path_chmod),
  13699. LSM_HOOK_INIT(path_chown, tomoyo_path_chown),
  13700. LSM_HOOK_INIT(path_chroot, tomoyo_path_chroot),
  13701. diff --git sound/core/Makefile sound/core/Makefile
  13702. index ee4a4a6b99ba..753bf1a0dbf3 100644
  13703. --- linux-4.14.336/sound/core/Makefile
  13704. +++ linux-4.14.336/sound/core/Makefile
  13705. @@ -30,7 +30,6 @@ snd-pcm-dmaengine-objs := pcm_dmaengine.o
  13706. snd-rawmidi-objs := rawmidi.o
  13707. snd-timer-objs := timer.o
  13708. snd-hrtimer-objs := hrtimer.o
  13709. -snd-rtctimer-objs := rtctimer.o
  13710. snd-hwdep-objs := hwdep.o
  13711. snd-seq-device-objs := seq_device.o
  13712. diff --git sound/pci/hda/hda_intel.c sound/pci/hda/hda_intel.c
  13713. index 978719fc4cd3..bb76b9c26da8 100644
  13714. --- linux-4.14.336/sound/pci/hda/hda_intel.c
  13715. +++ linux-4.14.336/sound/pci/hda/hda_intel.c
  13716. @@ -2545,6 +2545,12 @@ static const struct pci_device_id azx_ids[] = {
  13717. /* Cannonlake */
  13718. { PCI_DEVICE(0x8086, 0x9dc8),
  13719. .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
  13720. + /* Icelake */
  13721. + { PCI_DEVICE(0x8086, 0x34c8),
  13722. + .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
  13723. + /* Arrow Lake */
  13724. + { PCI_DEVICE(0x8086, 0x7728),
  13725. + .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
  13726. /* Broxton-P(Apollolake) */
  13727. { PCI_DEVICE(0x8086, 0x5a98),
  13728. .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_BROXTON },
  13729. diff --git sound/pci/hda/patch_conexant.c sound/pci/hda/patch_conexant.c
  13730. index 9263cb56df7d..6215d85428c7 100644
  13731. --- linux-4.14.336/sound/pci/hda/patch_conexant.c
  13732. +++ linux-4.14.336/sound/pci/hda/patch_conexant.c
  13733. @@ -263,6 +263,7 @@ enum {
  13734. CXT_FIXUP_MUTE_LED_GPIO,
  13735. CXT_FIXUP_HEADSET_MIC,
  13736. CXT_FIXUP_HP_MIC_NO_PRESENCE,
  13737. + CXT_PINCFG_SWS_JS201D,
  13738. };
  13739. /* for hda_fixup_thinkpad_acpi() */
  13740. @@ -754,6 +755,17 @@ static const struct hda_pintbl cxt_pincfg_lemote[] = {
  13741. {}
  13742. };
  13743. +/* SuoWoSi/South-holding JS201D with sn6140 */
  13744. +static const struct hda_pintbl cxt_pincfg_sws_js201d[] = {
  13745. + { 0x16, 0x03211040 }, /* hp out */
  13746. + { 0x17, 0x91170110 }, /* SPK/Class_D */
  13747. + { 0x18, 0x95a70130 }, /* Internal mic */
  13748. + { 0x19, 0x03a11020 }, /* Headset Mic */
  13749. + { 0x1a, 0x40f001f0 }, /* Not used */
  13750. + { 0x21, 0x40f001f0 }, /* Not used */
  13751. + {}
  13752. +};
  13753. +
  13754. static const struct hda_fixup cxt_fixups[] = {
  13755. [CXT_PINCFG_LENOVO_X200] = {
  13756. .type = HDA_FIXUP_PINS,
  13757. @@ -905,6 +917,10 @@ static const struct hda_fixup cxt_fixups[] = {
  13758. .chained = true,
  13759. .chain_id = CXT_FIXUP_HEADSET_MIC,
  13760. },
  13761. + [CXT_PINCFG_SWS_JS201D] = {
  13762. + .type = HDA_FIXUP_PINS,
  13763. + .v.pins = cxt_pincfg_sws_js201d,
  13764. + },
  13765. };
  13766. static const struct snd_pci_quirk cxt5045_fixups[] = {
  13767. @@ -973,6 +989,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
  13768. SND_PCI_QUIRK(0x103c, 0x8402, "HP ProBook 645 G4", CXT_FIXUP_MUTE_LED_GPIO),
  13769. SND_PCI_QUIRK(0x103c, 0x8455, "HP Z2 G4", CXT_FIXUP_HP_MIC_NO_PRESENCE),
  13770. SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN),
  13771. + SND_PCI_QUIRK(0x14f1, 0x0265, "SWS JS201D", CXT_PINCFG_SWS_JS201D),
  13772. SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO),
  13773. SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410),
  13774. SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410),
  13775. @@ -1011,6 +1028,7 @@ static const struct hda_model_fixup cxt5066_fixup_models[] = {
  13776. { .id = CXT_FIXUP_HP_DOCK, .name = "hp-dock" },
  13777. { .id = CXT_FIXUP_MUTE_LED_GPIO, .name = "mute-led-gpio" },
  13778. { .id = CXT_PINCFG_LENOVO_NOTEBOOK, .name = "lenovo-20149" },
  13779. + { .id = CXT_PINCFG_SWS_JS201D, .name = "sws-js201d" },
  13780. {}
  13781. };
  13782. diff --git sound/pci/oxygen/oxygen_mixer.c sound/pci/oxygen/oxygen_mixer.c
  13783. index 4ca12665ff73..64a82688d7fb 100644
  13784. --- linux-4.14.336/sound/pci/oxygen/oxygen_mixer.c
  13785. +++ linux-4.14.336/sound/pci/oxygen/oxygen_mixer.c
  13786. @@ -730,7 +730,7 @@ static int ac97_fp_rec_volume_put(struct snd_kcontrol *ctl,
  13787. oldreg = oxygen_read_ac97(chip, 1, AC97_REC_GAIN);
  13788. newreg = oldreg & ~0x0707;
  13789. newreg = newreg | (value->value.integer.value[0] & 7);
  13790. - newreg = newreg | ((value->value.integer.value[0] & 7) << 8);
  13791. + newreg = newreg | ((value->value.integer.value[1] & 7) << 8);
  13792. change = newreg != oldreg;
  13793. if (change)
  13794. oxygen_write_ac97(chip, 1, AC97_REC_GAIN, newreg);
  13795. diff --git sound/soc/codecs/cs35l33.c sound/soc/codecs/cs35l33.c
  13796. index e2c1194ea61a..32048c4c7e71 100644
  13797. --- linux-4.14.336/sound/soc/codecs/cs35l33.c
  13798. +++ linux-4.14.336/sound/soc/codecs/cs35l33.c
  13799. @@ -26,13 +26,11 @@
  13800. #include <sound/soc-dapm.h>
  13801. #include <sound/initval.h>
  13802. #include <sound/tlv.h>
  13803. -#include <linux/gpio.h>
  13804. #include <linux/gpio/consumer.h>
  13805. #include <sound/cs35l33.h>
  13806. #include <linux/pm_runtime.h>
  13807. #include <linux/regulator/consumer.h>
  13808. #include <linux/regulator/machine.h>
  13809. -#include <linux/of_gpio.h>
  13810. #include <linux/of.h>
  13811. #include <linux/of_device.h>
  13812. #include <linux/of_irq.h>
  13813. @@ -1173,7 +1171,7 @@ static int cs35l33_i2c_probe(struct i2c_client *i2c_client,
  13814. /* We could issue !RST or skip it based on AMP topology */
  13815. cs35l33->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev,
  13816. - "reset-gpios", GPIOD_OUT_HIGH);
  13817. + "reset", GPIOD_OUT_HIGH);
  13818. if (IS_ERR(cs35l33->reset_gpio)) {
  13819. dev_err(&i2c_client->dev, "%s ERROR: Can't get reset GPIO\n",
  13820. __func__);
  13821. diff --git sound/soc/codecs/cs35l34.c sound/soc/codecs/cs35l34.c
  13822. index 1e05026bedca..8a0ca34d828e 100644
  13823. --- linux-4.14.336/sound/soc/codecs/cs35l34.c
  13824. +++ linux-4.14.336/sound/soc/codecs/cs35l34.c
  13825. @@ -24,14 +24,12 @@
  13826. #include <linux/regulator/machine.h>
  13827. #include <linux/pm_runtime.h>
  13828. #include <linux/of_device.h>
  13829. -#include <linux/of_gpio.h>
  13830. #include <linux/of_irq.h>
  13831. #include <sound/core.h>
  13832. #include <sound/pcm.h>
  13833. #include <sound/pcm_params.h>
  13834. #include <sound/soc.h>
  13835. #include <sound/soc-dapm.h>
  13836. -#include <linux/gpio.h>
  13837. #include <linux/gpio/consumer.h>
  13838. #include <sound/initval.h>
  13839. #include <sound/tlv.h>
  13840. @@ -1068,7 +1066,7 @@ static int cs35l34_i2c_probe(struct i2c_client *i2c_client,
  13841. dev_err(&i2c_client->dev, "Failed to request IRQ: %d\n", ret);
  13842. cs35l34->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev,
  13843. - "reset-gpios", GPIOD_OUT_LOW);
  13844. + "reset", GPIOD_OUT_LOW);
  13845. if (IS_ERR(cs35l34->reset_gpio))
  13846. return PTR_ERR(cs35l34->reset_gpio);
  13847. diff --git sound/soc/codecs/cs43130.c sound/soc/codecs/cs43130.c
  13848. index 643e37fc218e..ad5d527e6e52 100644
  13849. --- linux-4.14.336/sound/soc/codecs/cs43130.c
  13850. +++ linux-4.14.336/sound/soc/codecs/cs43130.c
  13851. @@ -581,7 +581,7 @@ static int cs43130_set_sp_fmt(int dai_id, unsigned int bitwidth_sclk,
  13852. break;
  13853. case SND_SOC_DAIFMT_LEFT_J:
  13854. hi_size = bitwidth_sclk;
  13855. - frm_delay = 2;
  13856. + frm_delay = 0;
  13857. frm_phase = 1;
  13858. break;
  13859. case SND_SOC_DAIFMT_DSP_A:
  13860. @@ -1675,7 +1675,7 @@ static ssize_t cs43130_show_dc_r(struct device *dev,
  13861. return cs43130_show_dc(dev, buf, HP_RIGHT);
  13862. }
  13863. -static u16 const cs43130_ac_freq[CS43130_AC_FREQ] = {
  13864. +static const u16 cs43130_ac_freq[CS43130_AC_FREQ] = {
  13865. 24,
  13866. 43,
  13867. 93,
  13868. @@ -2351,7 +2351,7 @@ static const struct regmap_config cs43130_regmap = {
  13869. .use_single_rw = true, /* needed for regcache_sync */
  13870. };
  13871. -static u16 const cs43130_dc_threshold[CS43130_DC_THRESHOLD] = {
  13872. +static const u16 cs43130_dc_threshold[CS43130_DC_THRESHOLD] = {
  13873. 50,
  13874. 120,
  13875. };
  13876. diff --git sound/soc/codecs/da7219-aad.c sound/soc/codecs/da7219-aad.c
  13877. index 793c8768f7c4..5a31a4db1e23 100644
  13878. --- linux-4.14.336/sound/soc/codecs/da7219-aad.c
  13879. +++ linux-4.14.336/sound/soc/codecs/da7219-aad.c
  13880. @@ -650,7 +650,7 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod
  13881. aad_pdata->mic_det_thr =
  13882. da7219_aad_fw_mic_det_thr(codec, fw_val32);
  13883. else
  13884. - aad_pdata->mic_det_thr = DA7219_AAD_MIC_DET_THR_500_OHMS;
  13885. + aad_pdata->mic_det_thr = DA7219_AAD_MIC_DET_THR_200_OHMS;
  13886. if (fwnode_property_read_u32(aad_np, "dlg,jack-ins-deb", &fw_val32) >= 0)
  13887. aad_pdata->jack_ins_deb =
  13888. diff --git sound/soc/codecs/rt5645.c sound/soc/codecs/rt5645.c
  13889. index 822c42101c3f..536a33820265 100644
  13890. --- linux-4.14.336/sound/soc/codecs/rt5645.c
  13891. +++ linux-4.14.336/sound/soc/codecs/rt5645.c
  13892. @@ -417,6 +417,7 @@ struct rt5645_priv {
  13893. struct regulator_bulk_data supplies[ARRAY_SIZE(rt5645_supply_names)];
  13894. struct rt5645_eq_param_s *eq_param;
  13895. struct timer_list btn_check_timer;
  13896. + struct mutex jd_mutex;
  13897. int codec_type;
  13898. int sysclk;
  13899. @@ -3158,6 +3159,8 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert)
  13900. rt5645_enable_push_button_irq(codec, true);
  13901. }
  13902. } else {
  13903. + if (rt5645->en_button_func)
  13904. + rt5645_enable_push_button_irq(codec, false);
  13905. snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
  13906. snd_soc_dapm_sync(dapm);
  13907. rt5645->jack_type = SND_JACK_HEADPHONE;
  13908. @@ -3238,6 +3241,8 @@ static void rt5645_jack_detect_work(struct work_struct *work)
  13909. if (!rt5645->codec)
  13910. return;
  13911. + mutex_lock(&rt5645->jd_mutex);
  13912. +
  13913. switch (rt5645->pdata.jd_mode) {
  13914. case 0: /* Not using rt5645 JD */
  13915. if (rt5645->gpiod_hp_det) {
  13916. @@ -3250,6 +3255,7 @@ static void rt5645_jack_detect_work(struct work_struct *work)
  13917. report, SND_JACK_HEADPHONE);
  13918. snd_soc_jack_report(rt5645->mic_jack,
  13919. report, SND_JACK_MICROPHONE);
  13920. + mutex_unlock(&rt5645->jd_mutex);
  13921. return;
  13922. default: /* read rt5645 jd1_1 status */
  13923. val = snd_soc_read(rt5645->codec, RT5645_INT_IRQ_ST) & 0x1000;
  13924. @@ -3259,7 +3265,7 @@ static void rt5645_jack_detect_work(struct work_struct *work)
  13925. if (!val && (rt5645->jack_type == 0)) { /* jack in */
  13926. report = rt5645_jack_detect(rt5645->codec, 1);
  13927. - } else if (!val && rt5645->jack_type != 0) {
  13928. + } else if (!val && rt5645->jack_type == SND_JACK_HEADSET) {
  13929. /* for push button and jack out */
  13930. btn_type = 0;
  13931. if (snd_soc_read(rt5645->codec, RT5645_INT_IRQ_ST) & 0x4) {
  13932. @@ -3315,6 +3321,8 @@ static void rt5645_jack_detect_work(struct work_struct *work)
  13933. rt5645_jack_detect(rt5645->codec, 0);
  13934. }
  13935. + mutex_unlock(&rt5645->jd_mutex);
  13936. +
  13937. snd_soc_jack_report(rt5645->hp_jack, report, SND_JACK_HEADPHONE);
  13938. snd_soc_jack_report(rt5645->mic_jack, report, SND_JACK_MICROPHONE);
  13939. if (rt5645->en_button_func)
  13940. @@ -3939,6 +3947,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
  13941. setup_timer(&rt5645->btn_check_timer,
  13942. rt5645_btn_check_callback, (unsigned long)rt5645);
  13943. + mutex_init(&rt5645->jd_mutex);
  13944. INIT_DELAYED_WORK(&rt5645->jack_detect_work, rt5645_jack_detect_work);
  13945. INIT_DELAYED_WORK(&rt5645->rcclock_work, rt5645_rcclock_work);
  13946. diff --git tools/lib/subcmd/help.c tools/lib/subcmd/help.c
  13947. index 2859f107abc8..4260c8b4257b 100644
  13948. --- linux-4.14.336/tools/lib/subcmd/help.c
  13949. +++ linux-4.14.336/tools/lib/subcmd/help.c
  13950. @@ -50,11 +50,21 @@ void uniq(struct cmdnames *cmds)
  13951. if (!cmds->cnt)
  13952. return;
  13953. - for (i = j = 1; i < cmds->cnt; i++)
  13954. - if (strcmp(cmds->names[i]->name, cmds->names[i-1]->name))
  13955. - cmds->names[j++] = cmds->names[i];
  13956. -
  13957. + for (i = 1; i < cmds->cnt; i++) {
  13958. + if (!strcmp(cmds->names[i]->name, cmds->names[i-1]->name))
  13959. + zfree(&cmds->names[i - 1]);
  13960. + }
  13961. + for (i = 0, j = 0; i < cmds->cnt; i++) {
  13962. + if (cmds->names[i]) {
  13963. + if (i == j)
  13964. + j++;
  13965. + else
  13966. + cmds->names[j++] = cmds->names[i];
  13967. + }
  13968. + }
  13969. cmds->cnt = j;
  13970. + while (j < i)
  13971. + cmds->names[j++] = NULL;
  13972. }
  13973. void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
  13974. diff --git tools/testing/selftests/powerpc/math/fpu_preempt.c tools/testing/selftests/powerpc/math/fpu_preempt.c
  13975. index 0f85b79d883d..c91f3b36e884 100644
  13976. --- linux-4.14.336/tools/testing/selftests/powerpc/math/fpu_preempt.c
  13977. +++ linux-4.14.336/tools/testing/selftests/powerpc/math/fpu_preempt.c
  13978. @@ -41,19 +41,20 @@ __thread double darray[] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0,
  13979. int threads_starting;
  13980. int running;
  13981. -extern void preempt_fpu(double *darray, int *threads_starting, int *running);
  13982. +extern int preempt_fpu(double *darray, int *threads_starting, int *running);
  13983. void *preempt_fpu_c(void *p)
  13984. {
  13985. + long rc;
  13986. int i;
  13987. +
  13988. srand(pthread_self());
  13989. for (i = 0; i < 21; i++)
  13990. darray[i] = rand();
  13991. - /* Test failed if it ever returns */
  13992. - preempt_fpu(darray, &threads_starting, &running);
  13993. + rc = preempt_fpu(darray, &threads_starting, &running);
  13994. - return p;
  13995. + return (void *)rc;
  13996. }
  13997. int test_preempt_fpu(void)
  13998. diff --git tools/testing/selftests/powerpc/math/vmx_preempt.c tools/testing/selftests/powerpc/math/vmx_preempt.c
  13999. index 9ef376c55b13..7ba95ceaaa50 100644
  14000. --- linux-4.14.336/tools/testing/selftests/powerpc/math/vmx_preempt.c
  14001. +++ linux-4.14.336/tools/testing/selftests/powerpc/math/vmx_preempt.c
  14002. @@ -41,19 +41,21 @@ __thread vector int varray[] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10,11,12},
  14003. int threads_starting;
  14004. int running;
  14005. -extern void preempt_vmx(vector int *varray, int *threads_starting, int *running);
  14006. +extern int preempt_vmx(vector int *varray, int *threads_starting, int *running);
  14007. void *preempt_vmx_c(void *p)
  14008. {
  14009. int i, j;
  14010. + long rc;
  14011. +
  14012. srand(pthread_self());
  14013. for (i = 0; i < 12; i++)
  14014. for (j = 0; j < 4; j++)
  14015. varray[i][j] = rand();
  14016. - /* Test fails if it ever returns */
  14017. - preempt_vmx(varray, &threads_starting, &running);
  14018. - return p;
  14019. + rc = preempt_vmx(varray, &threads_starting, &running);
  14020. +
  14021. + return (void *)rc;
  14022. }
  14023. int test_preempt_vmx(void)
  14024. diff --git virt/kvm/arm/vgic/vgic-its.c virt/kvm/arm/vgic/vgic-its.c
  14025. index fd25c2161060..a4398f58a830 100644
  14026. --- linux-4.14.336/virt/kvm/arm/vgic/vgic-its.c
  14027. +++ linux-4.14.336/virt/kvm/arm/vgic/vgic-its.c
  14028. @@ -424,6 +424,9 @@ static int its_sync_lpi_pending_table(struct kvm_vcpu *vcpu)
  14029. }
  14030. irq = vgic_get_irq(vcpu->kvm, NULL, intids[i]);
  14031. + if (!irq)
  14032. + continue;
  14033. +
  14034. spin_lock(&irq->irq_lock);
  14035. irq->pending_latch = pendmask & (1U << bit_nr);
  14036. vgic_queue_irq_unlock(vcpu->kvm, irq);