History

Merge branch 'perf/urgent' into perf/core, to pick up fixes before adding more changes

Ingo Molnar committed 11 years ago

Commit 40a2ea12 parents a897b5f 1966764604 files · +7404 −4090Browse files

Unified · Split

604 files
  1. .mailmap +1 −0
  2. Documentation/devicetree/bindings/arm/cpus.txt +1 −0
  3. Documentation/devicetree/bindings/dma/apm-xgene-dma.txt +1 −1
  4. Documentation/devicetree/bindings/phy/ti-phy.txt +16 −0
  5. Documentation/devicetree/bindings/sound/mt8173-max98090.txt +2 −0
  6. Documentation/devicetree/bindings/sound/mt8173-rt5650-rt5676.txt +2 −0
  7. Documentation/devicetree/bindings/spi/spi-ath79.txt +3 −3
  8. Documentation/hwmon/nct7904 +2 −2
  9. Documentation/input/alps.txt +4 −2
  10. Documentation/target/tcm_mod_builder.py +14 −7
  11. MAINTAINERS +14 −1
  12. Makefile +8 −3
  13. arch/arc/Kconfig +11 −2
  14. arch/arc/Makefile +9 −1
  15. arch/arc/include/asm/arcregs.h +3 −4
  16. arch/arc/include/asm/atomic.h +55 −23
  17. arch/arc/include/asm/ptrace.h +27 −27
  18. arch/arc/include/asm/spinlock.h +523 −15
  19. arch/arc/include/asm/spinlock_types.h +2 −0
  20. arch/arc/include/uapi/asm/ptrace.h +10 −10
  21. arch/arc/kernel/setup.c +11 −1
  22. arch/arc/kernel/time.c +15 −25
  23. arch/arc/lib/memcpy-archs.S +1 −1
  24. arch/arc/lib/memset-archs.S +36 −7
  25. arch/arc/plat-axs10x/axs10x.c +15 −0
  26. arch/arm/boot/dts/dra7.dtsi +2 −1
  27. arch/arm/boot/dts/exynos3250.dtsi +1 −1
  28. arch/arm/boot/dts/exynos4210-origen.dts +4 −0
  29. arch/arm/boot/dts/exynos4210-trats.dts +4 −0
  30. arch/arm/boot/dts/exynos4210-universal_c210.dts +4 −0
  31. arch/arm/boot/dts/exynos4210.dtsi +12 −0
  32. arch/arm/boot/dts/imx35.dtsi +4 −4
  33. arch/arm/boot/dts/imx6qdl.dtsi +4 −4
  34. arch/arm/boot/dts/k2e-clocks.dtsi +2 −3
  35. arch/arm/boot/dts/k2e.dtsi +11 −4
  36. arch/arm/boot/dts/k2hk-clocks.dtsi +2 −3
  37. arch/arm/boot/dts/k2hk.dtsi +11 −0
  38. arch/arm/boot/dts/k2l-clocks.dtsi +2 −3
  39. arch/arm/boot/dts/k2l.dtsi +11 −5
  40. arch/arm/boot/dts/keystone.dtsi +0 −11
  41. arch/arm/boot/dts/omap2430.dtsi +2 −1
  42. arch/arm/boot/dts/omap4.dtsi +2 −1
  43. arch/arm/boot/dts/omap5.dtsi +2 −1
  44. arch/arm/boot/dts/ste-dbx5x0.dtsi +27 −26
  45. arch/arm/boot/dts/ste-nomadik-nhk15.dts +1 −0
  46. arch/arm/boot/dts/ste-nomadik-s8815.dts +4 −0
  47. arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +1 −0
  48. arch/arm/kernel/entry-common.S +1 −0
  49. arch/arm/kernel/head.S +3 −0
  50. arch/arm/kernel/vdso.c +3 −4
  51. arch/arm/mach-exynos/pm_domains.c +1 −2
  52. arch/arm/mach-omap2/omap_hwmod.c +16 −8
  53. arch/arm/mach-omap2/omap_hwmod_7xx_data.c +2 −3
  54. arch/arm/vdso/Makefile +1 −1
  55. arch/arm64/boot/dts/apm/apm-storm.dtsi +1 −1
  56. arch/arm64/kernel/efi.c +2 −2
  57. arch/arm64/kernel/signal32.c +2 −3
  58. arch/arm64/kernel/vdso.c +3 −4
  59. arch/avr32/mach-at32ap/clock.c +19 −1
  60. arch/mips/Kconfig +0 −1
  61. arch/mips/ath79/setup.c +1 −0
  62. arch/mips/cavium-octeon/smp.c +1 −1
  63. arch/mips/include/asm/mach-bcm63xx/dma-coherence.h +0 −10
  64. arch/mips/include/asm/pgtable.h +31 −0
  65. arch/mips/include/asm/smp.h +0 −2
  66. arch/mips/include/asm/stackframe.h +25 −0
  67. arch/mips/kernel/mips-mt-fpaff.c +3 −2
  68. arch/mips/kernel/prom.c +1 −1
  69. arch/mips/kernel/relocate_kernel.S +4 −4
  70. arch/mips/kernel/scall64-64.S +1 −1
  71. arch/mips/kernel/scall64-n32.S +1 −1
  72. arch/mips/kernel/signal32.c +0 −2
  73. arch/mips/kernel/smp-bmips.c +2 −2
  74. arch/mips/kernel/smp.c +0 −10
  75. arch/mips/kernel/traps.c +13 −0
  76. arch/mips/kernel/unaligned.c +1 −1
  77. arch/mips/lantiq/irq.c +2 −1
  78. arch/mips/loongson64/loongson-3/smp.c +5 −2
  79. arch/mips/mm/cache.c +4 −4
  80. arch/mips/mm/fault.c +2 −1
  81. arch/mips/mti-malta/malta-int.c +1 −1
  82. arch/mips/mti-malta/malta-time.c +10 −6
  83. arch/mips/mti-sead3/sead3-time.c +1 −0
  84. arch/mips/netlogic/common/smp.c +1 −1
  85. arch/mips/paravirt/paravirt-smp.c +1 −1
  86. arch/mips/pistachio/time.c +1 −0
  87. arch/mips/pmcs-msp71xx/msp_smp.c +1 −1
  88. arch/mips/ralink/irq.c +1 −0
  89. arch/mips/sgi-ip27/ip27-irq.c +6 −2
  90. arch/mips/sibyte/bcm1480/smp.c +5 −4
  91. arch/mips/sibyte/sb1250/smp.c +5 −2
  92. arch/powerpc/kernel/signal_32.c +0 −2
  93. arch/powerpc/platforms/powernv/eeh-powernv.c +1 −1
  94. arch/powerpc/platforms/powernv/pci-ioda.c +6 −5
  95. arch/s390/kernel/cache.c +2 −0
  96. arch/s390/kvm/kvm-s390.c +2 −2
  97. arch/s390/net/bpf_jit_comp.c +7 −7
  98. arch/sparc/include/asm/visasm.h +5 −11
  99. arch/sparc/lib/NG4memcpy.S +4 −1
  100. arch/sparc/lib/VISsave.S +2 −65
  101. arch/sparc/lib/ksyms.c +0 −4
  102. arch/tile/kernel/compat_signal.c +0 −2
  103. arch/x86/boot/compressed/eboot.c +4 −0
  104. arch/x86/entry/entry_64_compat.S +2 −1
  105. arch/x86/include/asm/desc.h +0 −15
  106. arch/x86/include/asm/mmu.h +1 −2
  107. arch/x86/include/asm/mmu_context.h +49 −5
  108. arch/x86/include/asm/sigcontext.h +3 −3
  109. arch/x86/include/uapi/asm/sigcontext.h +3 −18
  110. arch/x86/kernel/apic/io_apic.c +1 −1
  111. arch/x86/kernel/cpu/common.c +2 −2
  112. arch/x86/kernel/cpu/perf_event.c +8 −4
  113. arch/x86/kernel/ldt.c +142 −120
  114. arch/x86/kernel/process_64.c +2 −2
  115. arch/x86/kernel/signal.c +11 −15
  116. arch/x86/kernel/step.c +5 −3
  117. arch/x86/kvm/mtrr.c +4 −4
  118. arch/x86/kvm/x86.c +6 −1
  119. arch/x86/math-emu/fpu_entry.c +1 −2
  120. arch/x86/math-emu/fpu_system.h +18 −3
  121. arch/x86/math-emu/get_address.c +1 −2
  122. arch/x86/net/bpf_jit_comp.c +4 −4
  123. arch/x86/platform/efi/efi.c +5 −0
  124. arch/x86/power/cpu.c +2 −1
  125. arch/x86/xen/Makefile +2 −2
  126. arch/x86/xen/enlighten.c +40 −0
  127. arch/x86/xen/xen-ops.h +2 −4
  128. block/blk-settings.c +2 −2
  129. crypto/authencesn.c +12 −32
  130. drivers/acpi/device_pm.c +1 −1
  131. drivers/ata/ahci_brcmstb.c +4 −2
  132. drivers/ata/libata-core.c +3 −21
  133. drivers/ata/libata-eh.c +2 −103
  134. drivers/ata/libata-scsi.c +2 −19
  135. drivers/ata/libata.h +1 −5
  136. drivers/ata/sata_sx4.c +12 −4
  137. drivers/base/regmap/regcache-rbtree.c +14 −5
  138. drivers/block/rbd.c +17 −5
  139. drivers/block/xen-blkback/blkback.c +2 −2
  140. drivers/block/xen-blkfront.c +72 −56
  141. drivers/block/zram/zram_drv.c +2 −4
  142. drivers/char/hw_random/core.c +1 −1
  143. drivers/clk/pxa/clk-pxa3xx.c +1 −1
  144. drivers/clocksource/sh_cmt.c +6 −0
  145. drivers/cpufreq/cpufreq.c +55 −53
  146. drivers/cpufreq/intel_pstate.c +1 −0
  147. drivers/cpufreq/loongson2_cpufreq.c +1 −1
  148. drivers/crypto/caam/caamhash.c +4 −3
  149. drivers/crypto/ixp4xx_crypto.c +0 −1
  150. drivers/crypto/nx/nx-sha256.c +16 −11
  151. drivers/crypto/nx/nx-sha512.c +16 −12
  152. drivers/crypto/qat/qat_common/qat_algs.c +16 −8
  153. drivers/dma/at_hdmac.c +87 −45
  154. drivers/dma/at_hdmac_regs.h +1 −2
  155. drivers/dma/at_xdmac.c +14 −12
  156. drivers/dma/dmaengine.c +4 −0
  157. drivers/dma/mv_xor.c +5 −4
  158. drivers/dma/pl330.c +2 −1
  159. drivers/dma/virt-dma.c +6 −13
  160. drivers/dma/virt-dma.h +1 −12
  161. drivers/dma/xgene-dma.c +3 −0
  162. drivers/edac/ppc4xx_edac.c +1 −1
  163. drivers/extcon/extcon-palmas.c +0 −13
  164. drivers/extcon/extcon.c +44 −17
  165. drivers/firmware/efi/efi.c +5 −0
  166. drivers/gpu/drm/amd/amdgpu/amdgpu.h +11 −1
  167. drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +22 −16
  168. drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +5 −3
  169. drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +8 −8
  170. drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +10 −9
  171. drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +14 −3
  172. drivers/gpu/drm/amd/amdgpu/cik_sdma.c +1 −0
  173. drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +42 −12
  174. drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +60 −25
  175. drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +4 −2
  176. drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +4 −2
  177. drivers/gpu/drm/drm_atomic_helper.c +9 −1
  178. drivers/gpu/drm/drm_dp_mst_topology.c +13 −7
  179. drivers/gpu/drm/drm_irq.c +1 −1
  180. drivers/gpu/drm/exynos/exynos_drm_fimc.c +0 −1
  181. drivers/gpu/drm/exynos/exynos_drm_gsc.c +2 −4
  182. drivers/gpu/drm/exynos/exynos_hdmi.c +6 −1
  183. drivers/gpu/drm/exynos/exynos_mixer.c +14 −7
  184. drivers/gpu/drm/i2c/tda998x_drv.c +2 −2
  185. drivers/gpu/drm/i915/i915_drv.h +8 −9
  186. drivers/gpu/drm/i915/i915_gem_gtt.c +11 −0
  187. drivers/gpu/drm/i915/i915_gem_tiling.c +4 −1
  188. drivers/gpu/drm/i915/intel_atomic.c +8 −37
  189. drivers/gpu/drm/i915/intel_bios.c +23 −4
  190. drivers/gpu/drm/i915/intel_display.c +15 −44
  191. drivers/gpu/drm/i915/intel_dp_mst.c +11 −0
  192. drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c +3 −1
  193. drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +13 −0
  194. drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h +2 −0
  195. drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +14 −19
  196. drivers/gpu/drm/msm/mdp/mdp5/mdp5_smp.c +74 −13
  197. drivers/gpu/drm/msm/mdp/mdp5/mdp5_smp.h +1 −0
  198. drivers/gpu/drm/msm/msm_atomic.c +2 −6
  199. drivers/gpu/drm/msm/msm_drv.c +9 −4
  200. drivers/gpu/drm/msm/msm_drv.h +2 −2
  201. drivers/gpu/drm/msm/msm_gem.c +1 −1
  202. drivers/gpu/drm/msm/msm_gem_prime.c +6 −2
  203. drivers/gpu/drm/nouveau/nouveau_drm.c +3 −0
  204. drivers/gpu/drm/nouveau/nouveau_platform.c +16 −0
  205. drivers/gpu/drm/nouveau/nouveau_ttm.c +9 −0
  206. drivers/gpu/drm/nouveau/nv04_fbcon.c +1 −1
  207. drivers/gpu/drm/nouveau/nv50_display.c +1 −1
  208. drivers/gpu/drm/nouveau/nv50_fbcon.c +2 −1
  209. drivers/gpu/drm/nouveau/nvc0_fbcon.c +1 −1
  210. drivers/gpu/drm/nouveau/nvkm/engine/disp/gf110.c +1 −1
  211. drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c +38 −1
  212. drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h +1 −0
  213. drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c +8 −6
  214. drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c +40 −0
  215. drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c +2 −1
  216. drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk20a.c +8 −0
  217. drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv04.c +8 −0
  218. drivers/gpu/drm/radeon/atombios_encoders.c +1 −2
  219. drivers/gpu/drm/radeon/dce6_afmt.c +28 −34
  220. drivers/gpu/drm/radeon/radeon_audio.c +97 −107
  221. drivers/gpu/drm/radeon/radeon_audio.h +2 −1
  222. drivers/gpu/drm/radeon/radeon_combios.c +6 −1
  223. drivers/gpu/drm/radeon/radeon_connectors.c +14 −4
  224. drivers/gpu/drm/radeon/radeon_mode.h +1 −1
  225. drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +2 −2
  226. drivers/hid/hid-apple.c +6 −0
  227. drivers/hid/hid-core.c +6 −0
  228. drivers/hid/hid-ids.h +3 −0
  229. drivers/hid/hid-input.c +5 −2
  230. drivers/hid/hid-uclogic.c +1 −1
  231. drivers/hid/wacom_sys.c +37 −33
  232. drivers/hwmon/dell-smm-hwmon.c +17 −1
  233. drivers/hwmon/g762.c +1 −0
  234. drivers/hwmon/nct7802.c +1 −1
  235. drivers/hwmon/nct7904.c +30 −28
  236. drivers/i2c/busses/i2c-bfin-twi.c +2 −2
  237. drivers/i2c/busses/i2c-omap.c +11 −0
  238. drivers/i2c/i2c-core.c +17 −7
  239. drivers/i2c/i2c-slave-eeprom.c +0 −6
  240. drivers/infiniband/hw/cxgb3/iwch_provider.c +4 −0
  241. drivers/infiniband/hw/cxgb4/cq.c +1 −1
  242. drivers/infiniband/hw/ocrdma/ocrdma.h +34 −19
  243. drivers/infiniband/hw/ocrdma/ocrdma_abi.h +34 −19
  244. drivers/infiniband/hw/ocrdma/ocrdma_ah.c +34 −19
  245. drivers/infiniband/hw/ocrdma/ocrdma_ah.h +34 −19
  246. drivers/infiniband/hw/ocrdma/ocrdma_hw.c +34 −19
  247. drivers/infiniband/hw/ocrdma/ocrdma_hw.h +34 −19
  248. drivers/infiniband/hw/ocrdma/ocrdma_main.c +35 −20
  249. drivers/infiniband/hw/ocrdma/ocrdma_sli.h +34 −19
  250. drivers/infiniband/hw/ocrdma/ocrdma_stats.c +34 −19
  251. drivers/infiniband/hw/ocrdma/ocrdma_stats.h +34 −19
  252. drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +34 −19
  253. drivers/infiniband/hw/ocrdma/ocrdma_verbs.h +34 −19
  254. drivers/infiniband/ulp/ipoib/ipoib_verbs.c +2 −1
  255. drivers/infiniband/ulp/isert/ib_isert.c +11 −5
  256. drivers/input/joystick/turbografx.c +1 −1
  257. drivers/input/misc/axp20x-pek.c +1 −0
  258. drivers/input/misc/twl4030-vibra.c +2 −1
  259. drivers/input/mouse/alps.c +6 −2
  260. drivers/input/mouse/bcm5974.c +112 −53
  261. drivers/input/mouse/elantech.c +20 −2
  262. drivers/input/mouse/elantech.h +1 −0
  263. drivers/input/mouse/synaptics.c +2 −2
  264. drivers/input/touchscreen/zforce_ts.c +1 −1
  265. drivers/iommu/amd_iommu.c +29 −69
  266. drivers/iommu/amd_iommu_init.c +1 −9
  267. drivers/iommu/amd_iommu_v2.c +21 −3
  268. drivers/irqchip/irq-mips-gic.c +1 −1
  269. drivers/macintosh/ans-lcd.c +1 −1
  270. drivers/md/Kconfig +1 −1
  271. drivers/md/dm-cache-policy-mq.c +0 −2
  272. drivers/md/dm-cache-policy-smq.c +3 −1
  273. drivers/md/dm-cache-target.c +4 −3
  274. drivers/md/dm-thin-metadata.c +2 −2
  275. drivers/md/dm-thin.c +8 −3
  276. drivers/md/dm.c +10 −17
  277. drivers/md/md.c +1 −1
  278. drivers/md/persistent-data/dm-btree-internal.h +6 −0
  279. drivers/md/persistent-data/dm-btree-remove.c +7 −10
  280. drivers/md/persistent-data/dm-btree-spine.c +37 −0
  281. drivers/md/persistent-data/dm-btree.c +1 −6
  282. drivers/md/raid1.c +6 −4
  283. drivers/md/raid5.c +3 −2
  284. drivers/memory/omap-gpmc.c +6 −0
  285. drivers/mfd/Kconfig +1 −1
  286. drivers/mfd/arizona-core.c +7 −9
  287. drivers/misc/eeprom/at24.c +0 −3
  288. drivers/net/bonding/bond_main.c +1 −0
  289. drivers/net/ethernet/3com/3c59x.c +8 −9
  290. drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +1 −1
  291. drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +16 −0
  292. drivers/net/ethernet/brocade/bna/bnad.c +1 −1
  293. drivers/net/ethernet/cadence/macb.c +83 −42
  294. drivers/net/ethernet/cadence/macb.h +14 −20
  295. drivers/net/ethernet/cavium/Kconfig +0 −3
  296. drivers/net/ethernet/cavium/thunder/nic.h +11 −1
  297. drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c +16 −10
  298. drivers/net/ethernet/cavium/thunder/nicvf_main.c +39 −16
  299. drivers/net/ethernet/cavium/thunder/nicvf_queues.c +11 −6
  300. drivers/net/ethernet/cavium/thunder/nicvf_queues.h +11 −3
  301. drivers/net/ethernet/cavium/thunder/thunder_bgx.c +4 −1
  302. drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +2 −1
  303. drivers/net/ethernet/emulex/benet/be_cmds.h +5 −0
  304. drivers/net/ethernet/emulex/benet/be_main.c +120 −67
  305. drivers/net/ethernet/freescale/fec.h +1 −0
  306. drivers/net/ethernet/freescale/fec_main.c +81 −18
  307. drivers/net/ethernet/freescale/fec_ptp.c +10 −0
  308. drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +2 −1
  309. drivers/net/ethernet/freescale/fs_enet/mac-fec.c +1 −1
  310. drivers/net/ethernet/freescale/gianfar.c +32 −72
  311. drivers/net/ethernet/freescale/gianfar.h +0 −3
  312. drivers/net/ethernet/freescale/gianfar_ethtool.c +5 −345
  313. drivers/net/ethernet/marvell/mvpp2.c +167 −77
  314. drivers/net/ethernet/mellanox/mlx4/cmd.c +15 −2
  315. drivers/net/ethernet/mellanox/mlx4/en_rx.c +0 −1
  316. drivers/net/ethernet/mellanox/mlx4/eq.c +2 −2
  317. drivers/net/ethernet/mellanox/mlx4/main.c +5 −0
  318. drivers/net/ethernet/mellanox/mlx5/core/main.c +2 −0
  319. drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c +1 −1
  320. drivers/net/ethernet/realtek/r8169.c +3 −1
  321. drivers/net/ethernet/rocker/rocker.c +1 −0
  322. drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c +2 −2
  323. drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +4 −0
  324. drivers/net/ethernet/sun/niu.c +1 −3
  325. drivers/net/ethernet/ti/netcp.h +1 −1
  326. drivers/net/ethernet/ti/netcp_core.c +24 −25
  327. drivers/net/ethernet/ti/netcp_ethss.c +37 −30
  328. drivers/net/ethernet/ti/netcp_sgmii.c +28 −2
  329. drivers/net/hamradio/mkiss.c +4 −3
  330. drivers/net/macvtap.c +7 −0
  331. drivers/net/ntb_netdev.c +8 −1
  332. drivers/net/usb/r8152.c +137 −52
  333. drivers/net/virtio_net.c +2 −2
  334. drivers/net/wan/cosa.c +2 −1
  335. drivers/net/wireless/b43/tables_nphy.c +1 −1
  336. drivers/net/wireless/iwlwifi/mvm/scan.c +1 −1
  337. drivers/net/wireless/iwlwifi/pcie/trans.c +19 −3
  338. drivers/net/wireless/iwlwifi/pcie/tx.c +13 −2
  339. drivers/net/wireless/rsi/rsi_91x_sdio_ops.c +7 −1
  340. drivers/net/wireless/rsi/rsi_91x_usb_ops.c +4 −0
  341. drivers/net/wireless/rtlwifi/core.c +5 −2
  342. drivers/net/wireless/rtlwifi/rtl8723be/sw.c +1 −0
  343. drivers/net/xen-netback/interface.c +6 −0
  344. drivers/net/xen-netback/netback.c +33 −29
  345. drivers/ntb/ntb.c +1 −1
  346. drivers/ntb/ntb_transport.c +124 −77
  347. drivers/of/Kconfig +1 −1
  348. drivers/of/unittest.c +0 −3
  349. drivers/phy/phy-sun4i-usb.c +1 −0
  350. drivers/phy/phy-ti-pipe3.c +55 −6
  351. drivers/platform/chrome/Kconfig +0 −1
  352. drivers/scsi/ipr.c +18 −10
  353. drivers/scsi/ipr.h +1 −0
  354. drivers/scsi/libfc/fc_exch.c +4 −4
  355. drivers/scsi/libfc/fc_fcp.c +17 −2
  356. drivers/scsi/libiscsi.c +2 −23
  357. drivers/scsi/qla2xxx/qla_attr.c +1 −1
  358. drivers/scsi/qla2xxx/qla_dbg.c +3 −3
  359. drivers/scsi/qla2xxx/qla_def.h +16 −4
  360. drivers/scsi/qla2xxx/qla_init.c +150 −40
  361. drivers/scsi/qla2xxx/qla_iocb.c +3 −0
  362. drivers/scsi/qla2xxx/qla_mbx.c +4 −3
  363. drivers/scsi/qla2xxx/qla_os.c +10 −2
  364. drivers/scsi/qla2xxx/qla_sup.c +1 −1
  365. drivers/scsi/qla2xxx/qla_target.c +692 −71
  366. drivers/scsi/qla2xxx/qla_target.h +61 −11
  367. drivers/scsi/qla2xxx/tcm_qla2xxx.c +9 −19
  368. drivers/scsi/scsi_error.c +1 −32
  369. drivers/scsi/scsi_lib.c +3 −3
  370. drivers/scsi/sd.c +3 −3
  371. drivers/staging/comedi/drivers/das1800.c +1 −0
  372. drivers/staging/lustre/lustre/obdclass/debug.c +1 −1
  373. drivers/staging/vt6655/device_main.c +3 −2
  374. drivers/target/iscsi/iscsi_target.c +39 −9
  375. drivers/target/iscsi/iscsi_target_login.c +17 −28
  376. drivers/target/iscsi/iscsi_target_login.h +2 −1
  377. drivers/target/iscsi/iscsi_target_nego.c +33 −1
  378. drivers/target/target_core_configfs.c +28 −12
  379. drivers/target/target_core_pr.c +1 −1
  380. drivers/target/target_core_rd.c +1 −0
  381. drivers/target/target_core_spc.c +8 −1
  382. drivers/thermal/hisi_thermal.c +0 −1
  383. drivers/thermal/power_allocator.c +16 −10
  384. drivers/thermal/samsung/Kconfig +1 −1
  385. drivers/thermal/samsung/exynos_tmu.c +2 −3
  386. drivers/thermal/thermal_core.c +1 −0
  387. drivers/usb/chipidea/core.c +12 −1
  388. drivers/usb/chipidea/host.c +5 −2
  389. drivers/usb/chipidea/host.h +6 −0
  390. drivers/usb/gadget/function/f_hid.c +4 −0
  391. drivers/usb/gadget/function/f_printer.c +9 −1
  392. drivers/usb/gadget/function/f_uac2.c +2 −2
  393. drivers/usb/gadget/udc/bdc/bdc_ep.c +1 −1
  394. drivers/usb/gadget/udc/udc-core.c +1 −0
  395. drivers/usb/host/xhci-mem.c +2 −1
  396. drivers/usb/host/xhci-ring.c +1 −1
  397. drivers/usb/serial/option.c +2 −0
  398. drivers/usb/serial/qcserial.c +1 −1
  399. drivers/usb/serial/sierra.c +1 −0
  400. drivers/vfio/vfio.c +54 −37
  401. drivers/vhost/vhost.c +2 −4
  402. drivers/video/console/fbcon.c +2 −1
  403. drivers/video/fbdev/Kconfig +1 −1
  404. drivers/video/fbdev/omap2/dss/dss-of.c +3 −1
  405. drivers/video/fbdev/pxa3xx-gcu.c +2 −2
  406. drivers/video/of_videomode.c +1 −3
  407. drivers/virtio/virtio_input.c +4 −0
  408. drivers/xen/balloon.c +7 −8
  409. drivers/xen/gntdev.c +2 −0
  410. drivers/xen/xenbus/xenbus_client.c +3 −1
  411. fs/btrfs/dev-replace.c +1 −1
  412. fs/btrfs/disk-io.c +2 −1
  413. fs/btrfs/extent-tree.c +18 −0
  414. fs/btrfs/qgroup.c +5 −0
  415. fs/btrfs/transaction.c +2 −1
  416. fs/ceph/caps.c +5 −17
  417. fs/ceph/locks.c +1 −1
  418. fs/ceph/super.h +0 −1
  419. fs/dax.c +12 −2
  420. fs/dcache.c +3 −10
  421. fs/f2fs/data.c +0 −2
  422. fs/f2fs/file.c +4 −3
  423. fs/f2fs/gc.c +21 −9
  424. fs/f2fs/inline.c +2 −0
  425. fs/f2fs/segment.c +1 −0
  426. fs/file_table.c +15 −9
  427. fs/fuse/dev.c +9 −1
  428. fs/hugetlbfs/inode.c +2 −0
  429. fs/namei.c +7 −2
  430. fs/nfs/client.c +1 −1
  431. fs/nfs/flexfilelayout/flexfilelayout.c +1 −1
  432. fs/nfs/inode.c +8 −7
  433. fs/nfs/internal.h +21 −0
  434. fs/nfs/nfs42proc.c +18 −1
  435. fs/nfs/nfs4proc.c +21 −15
  436. fs/nfs/nfs4state.c +20 −9
  437. fs/nfs/pagelist.c +4 −3
  438. fs/nfs/pnfs.c +57 −44
  439. fs/nfs/write.c +9 −6
  440. fs/nfsd/nfs4layouts.c +1 −0
  441. fs/nfsd/nfs4state.c +6 −6
  442. fs/nfsd/nfs4xdr.c +6 −5
  443. fs/notify/mark.c +25 −5
  444. fs/ocfs2/aops.c +2 −2
  445. fs/ocfs2/dlmglue.c +7 −3
  446. fs/signalfd.c +3 −2
  447. fs/xfs/libxfs/xfs_attr_remote.c +34 −10
  448. fs/xfs/xfs_file.c +15 −6
  449. fs/xfs/xfs_log_recover.c +8 −3
  450. include/drm/drmP.h +1 −1
  451. include/drm/drm_crtc.h +0 −2
  452. include/drm/drm_crtc_helper.h +3 −0
  453. include/drm/drm_pciids.h +1 −0
  454. include/linux/ata.h +0 −18
  455. include/linux/cpufreq.h +1 −0
  456. include/linux/fs.h +3 −2
  457. include/linux/nfs_fs.h +5 −2
  458. include/linux/nfs_fs_sb.h +1 −1
  459. include/linux/of_device.h +1 −1
  460. include/linux/page-flags.h +7 −3
  461. include/linux/platform_data/macb.h +11 −3
  462. include/linux/skbuff.h +3 −3
  463. include/net/act_api.h +7 −1
  464. include/net/inet_frag.h +11 −6
  465. include/net/ip_fib.h +1 −2
  466. include/net/netfilter/nf_conntrack.h +1 −1
  467. include/net/netns/conntrack.h +0 −1
  468. include/net/sock.h +1 −1
  469. include/scsi/scsi_eh.h +0 −1
  470. include/target/iscsi/iscsi_target_core.h +1 −0
  471. include/uapi/drm/amdgpu_drm.h +1 −1
  472. include/uapi/drm/radeon_drm.h +1 −1
  473. include/uapi/linux/pci_regs.h +1 −0
  474. include/uapi/sound/asoc.h +26 −13
  475. init/main.c +1 −1
  476. ipc/mqueue.c +0 −5
  477. ipc/sem.c +35 −12
  478. ipc/shm.c +1 −1
  479. kernel/cpuset.c +1 −1
  480. kernel/kthread.c +4 −0
  481. kernel/locking/qspinlock_paravirt.h +10 −1
  482. kernel/module.c +6 −2
  483. kernel/signal.c +8 −5
  484. lib/iommu-common.c +1 −1
  485. mm/cma.h +1 −1
  486. mm/huge_memory.c +1 −6
  487. mm/kasan/kasan.c +1 −1
  488. mm/kasan/report.c +1 −1
  489. mm/memory-failure.c +31 −23
  490. mm/memory_hotplug.c +12 −1
  491. mm/migrate.c +6 −2
  492. mm/page-writeback.c +2 −2
  493. mm/page_alloc.c +38 −15
  494. mm/shmem.c +2 −2
  495. mm/slab_common.c +1 −2
  496. mm/vmscan.c +6 −10
  497. net/batman-adv/distributed-arp-table.c +13 −5
  498. net/batman-adv/gateway_client.c +2 −0
  499. net/batman-adv/soft-interface.c +3 −0
  500. net/batman-adv/translation-table.c +24 −5
  501. net/bluetooth/mgmt.c +1 −1
  502. net/bluetooth/smp.c +4 −0
  503. net/bridge/br_forward.c +22 −7
  504. net/bridge/br_mdb.c +1 −0
  505. net/bridge/br_multicast.c +26 −24
  506. net/bridge/br_netlink.c +13 −1
  507. net/bridge/br_stp.c +3 −2
  508. net/bridge/br_stp_if.c +12 −1
  509. net/bridge/br_stp_timer.c +3 −1
  510. net/core/datagram.c +7 −6
  511. net/core/netclassid_cgroup.c +2 −1
  512. net/core/pktgen.c +0 −3
  513. net/core/request_sock.c +7 −1
  514. net/core/sock.c +5 −3
  515. net/dccp/proto.c +1 −1
  516. net/dsa/slave.c +2 −1
  517. net/ieee802154/6lowpan/reassembly.c +3 −3
  518. net/ipv4/arp.c +9 −7
  519. net/ipv4/devinet.c +0 −1
  520. net/ipv4/fib_lookup.h +1 −0
  521. net/ipv4/fib_semantics.c +30 −11
  522. net/ipv4/fib_trie.c +2 −5
  523. net/ipv4/inet_connection_sock.c +1 −1
  524. net/ipv4/inet_fragment.c +15 −25
  525. net/ipv4/ip_fragment.c +6 −6
  526. net/ipv4/netfilter/ipt_SYNPROXY.c +2 −1
  527. net/ipv4/route.c +1 −1
  528. net/ipv4/tcp.c +7 −4
  529. net/ipv4/tcp_ipv4.c +1 −1
  530. net/ipv4/udp.c +10 −3
  531. net/ipv6/ndisc.c +6 −0
  532. net/ipv6/netfilter/ip6t_SYNPROXY.c +11 −8
  533. net/ipv6/netfilter/nf_conntrack_reasm.c +3 −3
  534. net/ipv6/reassembly.c +4 −4
  535. net/ipv6/route.c +4 −2
  536. net/ipv6/tcp_ipv6.c +1 −1
  537. net/llc/af_llc.c +2 −2
  538. net/netfilter/ipvs/ip_vs_core.c +14 −2
  539. net/netfilter/ipvs/ip_vs_ctl.c +49 −29
  540. net/netfilter/ipvs/ip_vs_sched.c +6 −6
  541. net/netfilter/ipvs/ip_vs_sync.c +1 −1
  542. net/netfilter/ipvs/ip_vs_xmit.c +40 −1
  543. net/netfilter/nf_conntrack_core.c +45 −26
  544. net/netfilter/nf_conntrack_expect.c +2 −1
  545. net/netfilter/nf_conntrack_netlink.c +0 −5
  546. net/netfilter/nf_synproxy_core.c +4 −7
  547. net/netfilter/xt_CT.c +6 −7
  548. net/netfilter/xt_IDLETIMER.c +1 −0
  549. net/netlink/af_netlink.c +5 −0
  550. net/openvswitch/actions.c +12 −4
  551. net/packet/af_packet.c +5 −6
  552. net/rds/info.c +1 −1
  553. net/sched/act_api.c +6 −5
  554. net/sched/act_bpf.c +35 −18
  555. net/sched/act_mirred.c +2 −0
  556. net/sched/act_pedit.c +2 −3
  557. net/sched/sch_choke.c +13 −0
  558. net/sched/sch_fq_codel.c +19 −3
  559. net/sched/sch_plug.c +1 −0
  560. net/sctp/socket.c +0 −6
  561. net/sunrpc/backchannel_rqst.c +3 −3
  562. net/sunrpc/clnt.c +3 −2
  563. net/sunrpc/xprtsock.c +17 −8
  564. scripts/kconfig/streamline_config.pl +1 −1
  565. security/keys/keyring.c +5 −3
  566. security/yama/yama_lsm.c +1 −0
  567. sound/firewire/amdtp.c +3 −2
  568. sound/firewire/amdtp.h +2 −0
  569. sound/firewire/fireworks/fireworks.c +8 −0
  570. sound/firewire/fireworks/fireworks.h +1 −0
  571. sound/firewire/fireworks/fireworks_stream.c +9 −0
  572. sound/hda/ext/hdac_ext_controller.c +0 −6
  573. sound/hda/ext/hdac_ext_stream.c +1 −1
  574. sound/pci/hda/hda_intel.c +3 −3
  575. sound/pci/hda/patch_cirrus.c +1 −3
  576. sound/pci/hda/patch_realtek.c +36 −5
  577. sound/pci/hda/patch_sigmatel.c +2 −1
  578. sound/pci/oxygen/oxygen_mixer.c +1 −1
  579. sound/soc/codecs/cs4265.c +5 −5
  580. sound/soc/codecs/pcm1681.c +1 −1
  581. sound/soc/codecs/rt5645.c +5 −0
  582. sound/soc/codecs/rt5645.h +4 −0
  583. sound/soc/codecs/sgtl5000.h +1 −1
  584. sound/soc/codecs/ssm4567.c +7 −1
  585. sound/soc/fsl/fsl_ssi.c +1 −1
  586. sound/soc/intel/Makefile +1 −1
  587. sound/soc/intel/atom/sst/sst_drv_interface.c +7 −7
  588. sound/soc/intel/baytrail/sst-baytrail-ipc.c +2 −0
  589. sound/soc/intel/boards/cht_bsw_max98090_ti.c +2 −2
  590. sound/soc/intel/haswell/sst-haswell-ipc.c +2 −0
  591. sound/soc/mediatek/mt8173-max98090.c +13 −4
  592. sound/soc/mediatek/mt8173-rt5650-rt5676.c +15 −4
  593. sound/soc/mediatek/mtk-afe-pcm.c +2 −0
  594. sound/soc/soc-core.c +1 −0
  595. sound/soc/soc-dapm.c +18 −17
  596. sound/soc/soc-topology.c +43 −19
  597. sound/soc/zte/zx296702-i2s.c +2 −2
  598. sound/soc/zte/zx296702-spdif.c +2 −2
  599. sound/usb/mixer_maps.c +24 −0
  600. tools/perf/builtin-record.c +11 −0
  601. tools/perf/builtin-top.c +2 −2
  602. tools/perf/util/machine.c +18 −2
  603. tools/perf/util/thread.c +6 −0
  604. tools/testing/selftests/futex/functional/futex_requeue_pi_signal_restart.c +1 −1
.mailmap+1−0
@@ -17,6 +17,7 @@ Aleksey Gorelov <aleksey_gorelov@phoenix.com> · 16 unmodified lines
1717 Al Viro <viro@ftp.linux.org.uk>
1818 Al Viro <viro@zenIV.linux.org.uk>
1919 Andreas Herrmann <aherrman@de.ibm.com>
20+Andrey Ryabinin <ryabinin.a.a@gmail.com> <a.ryabinin@samsung.com>
2021 Andrew Morton <akpm@linux-foundation.org>
2122 Andrew Vasquez <andrew.vasquez@qlogic.com>
2223 Andy Adamson <andros@citi.umich.edu>
Documentation/devicetree/bindings/arm/cpus.txt+1−0
@@ -199,6 +199,7 @@ nodes to be present and contain the properties described below. · 198 unmodified lines
199199 "qcom,kpss-acc-v1"
200200 "qcom,kpss-acc-v2"
201201 "rockchip,rk3066-smp"
202+ "ste,dbx500-smp"
202203
203204 - cpu-release-addr
204205 Usage: required for systems that have an "enable-method"
Documentation/devicetree/bindings/dma/apm-xgene-dma.txt+1−1
@@ -35,7 +35,7 @@ Example: · 34 unmodified lines
3535 device_type = "dma";
3636 reg = <0x0 0x1f270000 0x0 0x10000>,
3737 <0x0 0x1f200000 0x0 0x10000>,
38− <0x0 0x1b008000 0x0 0x2000>,
38+ <0x0 0x1b000000 0x0 0x400000>,
3939 <0x0 0x1054a000 0x0 0x100>;
4040 interrupts = <0x0 0x82 0x4>,
4141 <0x0 0xb8 0x4>,
Documentation/devicetree/bindings/phy/ti-phy.txt+16−0
@@ -82,6 +82,9 @@ Optional properties: · 81 unmodified lines
8282 - id: If there are multiple instance of the same type, in order to
8383 differentiate between each instance "id" can be used (e.g., multi-lane PCIe
8484 PHY). If "id" is not provided, it is set to default value of '1'.
85+ - syscon-pllreset: Handle to system control region that contains the
86+ CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0
87+ register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy.
8588
8689 This is usually a subnode of ocp2scp to which it is connected.
8790
@@ -100,3 +103,16 @@ usb3phy@4a084400 { · 12 unmodified lines
100103 "sysclk",
101104 "refclk";
102105 };
106+
107+sata_phy: phy@4A096000 {
108+ compatible = "ti,phy-pipe3-sata";
109+ reg = <0x4A096000 0x80>, /* phy_rx */
110+ <0x4A096400 0x64>, /* phy_tx */
111+ <0x4A096800 0x40>; /* pll_ctrl */
112+ reg-names = "phy_rx", "phy_tx", "pll_ctrl";
113+ ctrl-module = <&omap_control_sata>;
114+ clocks = <&sys_clkin1>, <&sata_ref_clk>;
115+ clock-names = "sysclk", "refclk";
116+ syscon-pllreset = <&scm_conf 0x3fc>;
117+ #phy-cells = <0>;
118+};
Documentation/devicetree/bindings/sound/mt8173-max98090.txt+2−0
@@ -3,11 +3,13 @@ MT8173 with MAX98090 CODEC · 2 unmodified lines
33 Required properties:
44 - compatible : "mediatek,mt8173-max98090"
55 - mediatek,audio-codec: the phandle of the MAX98090 audio codec
6+- mediatek,platform: the phandle of MT8173 ASoC platform
67
78 Example:
89
910 sound {
1011 compatible = "mediatek,mt8173-max98090";
1112 mediatek,audio-codec = <&max98090>;
13+ mediatek,platform = <&afe>;
1214 };
1315
Documentation/devicetree/bindings/sound/mt8173-rt5650-rt5676.txt+2−0
@@ -3,11 +3,13 @@ MT8173 with RT5650 RT5676 CODECS · 2 unmodified lines
33 Required properties:
44 - compatible : "mediatek,mt8173-rt5650-rt5676"
55 - mediatek,audio-codec: the phandles of rt5650 and rt5676 codecs
6+- mediatek,platform: the phandle of MT8173 ASoC platform
67
78 Example:
89
910 sound {
1011 compatible = "mediatek,mt8173-rt5650-rt5676";
1112 mediatek,audio-codec = <&rt5650 &rt5676>;
13+ mediatek,platform = <&afe>;
1214 };
1315
Documentation/devicetree/bindings/spi/spi-ath79.txt+3−3
@@ -3,7 +3,7 @@ Binding for Qualcomm Atheros AR7xxx/AR9xxx SPI controller · 2 unmodified lines
33 Required properties:
44 - compatible: has to be "qca,<soc-type>-spi", "qca,ar7100-spi" as fallback.
55 - reg: Base address and size of the controllers memory area
6−- clocks: phandle to the AHB clock.
6+- clocks: phandle of the AHB clock.
77 - clock-names: has to be "ahb".
88 - #address-cells: <1>, as required by generic SPI binding.
99 - #size-cells: <0>, also as required by generic SPI binding.
@@ -12,9 +12,9 @@ Child nodes as per the generic SPI binding. · 2 unmodified lines
1212
1313 Example:
1414
15− spi@1F000000 {
15+ spi@1f000000 {
1616 compatible = "qca,ar9132-spi", "qca,ar7100-spi";
17− reg = <0x1F000000 0x10>;
17+ reg = <0x1f000000 0x10>;
1818
1919 clocks = <&pll 2>;
2020 clock-names = "ahb";
Documentation/hwmon/nct7904+2−2
@@ -35,11 +35,11 @@ temp1_input Local temperature (1/1000 degree, · 34 unmodified lines
3535 temp[2-9]_input CPU temperatures (1/1000 degree,
3636 0.125 degree resolution)
3737
38−fan[1-4]_mode R/W, 0/1 for manual or SmartFan mode
38+pwm[1-4]_enable R/W, 1/2 for manual or SmartFan mode
3939 Setting SmartFan mode is supported only if it has been
4040 previously configured by BIOS (or configuration EEPROM)
4141
42−fan[1-4]_pwm R/O in SmartFan mode, R/W in manual control mode
42+pwm[1-4] R/O in SmartFan mode, R/W in manual control mode
4343
4444 The driver checks sensor control registers and does not export the sensors
4545 that are not enabled. Anyway, a sensor that is enabled may actually be not
Documentation/input/alps.txt+4−2
@@ -119,8 +119,10 @@ ALPS Absolute Mode - Protocol Version 2 · 118 unmodified lines
119119 byte 5: 0 z6 z5 z4 z3 z2 z1 z0
120120
121121 Protocol Version 2 DualPoint devices send standard PS/2 mouse packets for
122−the DualPoint Stick. For non interleaved dualpoint devices the pointingstick
123−buttons get reported separately in the PSM, PSR and PSL bits.
122+the DualPoint Stick. The M, R and L bits signal the combined status of both
123+the pointingstick and touchpad buttons, except for Dell dualpoint devices
124+where the pointingstick buttons get reported separately in the PSM, PSR
125+and PSL bits.
124126
125127 Dualpoint device -- interleaved packet format
126128 ---------------------------------------------
Documentation/target/tcm_mod_builder.py+14−7
@@ -199,7 +199,8 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name): · 198 unmodified lines
199199 buf += "#include <linux/string.h>\n"
200200 buf += "#include <linux/configfs.h>\n"
201201 buf += "#include <linux/ctype.h>\n"
202− buf += "#include <asm/unaligned.h>\n\n"
202+ buf += "#include <asm/unaligned.h>\n"
203+ buf += "#include <scsi/scsi_proto.h>\n\n"
203204 buf += "#include <target/target_core_base.h>\n"
204205 buf += "#include <target/target_core_fabric.h>\n"
205206 buf += "#include <target/target_core_fabric_configfs.h>\n"
@@ -230,8 +231,14 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name): · 24 unmodified lines
230231 buf += " }\n"
231232 buf += " tpg->" + fabric_mod_port + " = " + fabric_mod_port + ";\n"
232233 buf += " tpg->" + fabric_mod_port + "_tpgt = tpgt;\n\n"
233− buf += " ret = core_tpg_register(&" + fabric_mod_name + "_ops, wwn,\n"
234− buf += " &tpg->se_tpg, SCSI_PROTOCOL_SAS);\n"
234+
235+ if proto_ident == "FC":
236+ buf += " ret = core_tpg_register(wwn, &tpg->se_tpg, SCSI_PROTOCOL_FCP);\n"
237+ elif proto_ident == "SAS":
238+ buf += " ret = core_tpg_register(wwn, &tpg->se_tpg, SCSI_PROTOCOL_SAS);\n"
239+ elif proto_ident == "iSCSI":
240+ buf += " ret = core_tpg_register(wwn, &tpg->se_tpg, SCSI_PROTOCOL_ISCSI);\n"
241+
235242 buf += " if (ret < 0) {\n"
236243 buf += " kfree(tpg);\n"
237244 buf += " return NULL;\n"
@@ -292,7 +299,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name): · 54 unmodified lines
292299
293300 buf += "static const struct target_core_fabric_ops " + fabric_mod_name + "_ops = {\n"
294301 buf += " .module = THIS_MODULE,\n"
295− buf += " .name = " + fabric_mod_name + ",\n"
302+ buf += " .name = \"" + fabric_mod_name + "\",\n"
296303 buf += " .get_fabric_name = " + fabric_mod_name + "_get_fabric_name,\n"
297304 buf += " .tpg_get_wwn = " + fabric_mod_name + "_get_fabric_wwn,\n"
298305 buf += " .tpg_get_tag = " + fabric_mod_name + "_get_tag,\n"
@@ -322,17 +329,17 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name): · 23 unmodified lines
322329 buf += " .fabric_make_tpg = " + fabric_mod_name + "_make_tpg,\n"
323330 buf += " .fabric_drop_tpg = " + fabric_mod_name + "_drop_tpg,\n"
324331 buf += "\n"
325− buf += " .tfc_wwn_attrs = " + fabric_mod_name + "_wwn_attrs;\n"
332+ buf += " .tfc_wwn_attrs = " + fabric_mod_name + "_wwn_attrs,\n"
326333 buf += "};\n\n"
327334
328335 buf += "static int __init " + fabric_mod_name + "_init(void)\n"
329336 buf += "{\n"
330− buf += " return target_register_template(" + fabric_mod_name + "_ops);\n"
337+ buf += " return target_register_template(&" + fabric_mod_name + "_ops);\n"
331338 buf += "};\n\n"
332339
333340 buf += "static void __exit " + fabric_mod_name + "_exit(void)\n"
334341 buf += "{\n"
335− buf += " target_unregister_template(" + fabric_mod_name + "_ops);\n"
342+ buf += " target_unregister_template(&" + fabric_mod_name + "_ops);\n"
336343 buf += "};\n\n"
337344
338345 buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n"
MAINTAINERS+14−1
@@ -3587,6 +3587,15 @@ S: Maintained · 3586 unmodified lines
35873587 F: drivers/gpu/drm/rockchip/
35883588 F: Documentation/devicetree/bindings/video/rockchip*
35893589
3590+DRM DRIVERS FOR STI
3591+M: Benjamin Gaignard <benjamin.gaignard@linaro.org>
3592+M: Vincent Abriou <vincent.abriou@st.com>
3593+L: dri-devel@lists.freedesktop.org
3594+T: git http://git.linaro.org/people/benjamin.gaignard/kernel.git
3595+S: Maintained
3596+F: drivers/gpu/drm/sti
3597+F: Documentation/devicetree/bindings/gpu/st,stih4xx.txt
3598+
35903599 DSBR100 USB FM RADIO DRIVER
35913600 M: Alexey Klimov <klimov.linux@gmail.com>
35923601 L: linux-media@vger.kernel.org
@@ -5600,6 +5609,7 @@ F: kernel/irq/ · 2007 unmodified lines
56005609 IRQCHIP DRIVERS
56015610 M: Thomas Gleixner <tglx@linutronix.de>
56025611 M: Jason Cooper <jason@lakedaemon.net>
5612+M: Marc Zyngier <marc.zyngier@arm.com>
56035613 L: linux-kernel@vger.kernel.org
56045614 S: Maintained
56055615 T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core
@@ -5608,11 +5618,14 @@ F: Documentation/devicetree/bindings/interrupt-controller/ · 2 unmodified lines
56085618 F: drivers/irqchip/
56095619
56105620 IRQ DOMAINS (IRQ NUMBER MAPPING LIBRARY)
5611−M: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5621+M: Jiang Liu <jiang.liu@linux.intel.com>
5622+M: Marc Zyngier <marc.zyngier@arm.com>
56125623 S: Maintained
5624+T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core
56135625 F: Documentation/IRQ-domain.txt
56145626 F: include/linux/irqdomain.h
56155627 F: kernel/irq/irqdomain.c
5628+F: kernel/irq/msi.c
56165629
56175630 ISAPNP
56185631 M: Jaroslav Kysela <perex@perex.cz>
Makefile+8−3
@@ -1,7 +1,7 @@
11 VERSION = 4
22 PATCHLEVEL = 2
33 SUBLEVEL = 0
4−EXTRAVERSION = -rc4
4+EXTRAVERSION = -rc7
55 NAME = Hurr durr I'ma sheep
66
77 # *DOCUMENTATION*
@@ -597,6 +597,11 @@ endif # $(dot-config) · 589 unmodified lines
597597 # Defaults to vmlinux, but the arch makefile usually adds further targets
598598 all: vmlinux
599599
600+# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
601+# values of the respective KBUILD_* variables
602+ARCH_CPPFLAGS :=
603+ARCH_AFLAGS :=
604+ARCH_CFLAGS :=
600605 include arch/$(SRCARCH)/Makefile
601606
602607 KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
@@ -848,10 +853,10 @@ export mod_strip_cmd · 245 unmodified lines
848853 mod_compress_cmd = true
849854 ifdef CONFIG_MODULE_COMPRESS
850855 ifdef CONFIG_MODULE_COMPRESS_GZIP
851− mod_compress_cmd = gzip -n
856+ mod_compress_cmd = gzip -n -f
852857 endif # CONFIG_MODULE_COMPRESS_GZIP
853858 ifdef CONFIG_MODULE_COMPRESS_XZ
854− mod_compress_cmd = xz
859+ mod_compress_cmd = xz -f
855860 endif # CONFIG_MODULE_COMPRESS_XZ
856861 endif # CONFIG_MODULE_COMPRESS
857862 export mod_compress_cmd
arch/arc/Kconfig+11−2
@@ -313,11 +313,11 @@ config ARC_PAGE_SIZE_8K · 312 unmodified lines
313313
314314 config ARC_PAGE_SIZE_16K
315315 bool "16KB"
316− depends on ARC_MMU_V3
316+ depends on ARC_MMU_V3 || ARC_MMU_V4
317317
318318 config ARC_PAGE_SIZE_4K
319319 bool "4KB"
320− depends on ARC_MMU_V3
320+ depends on ARC_MMU_V3 || ARC_MMU_V4
321321
322322 endchoice
323323
@@ -365,6 +365,11 @@ config ARC_HAS_LLSC · 41 unmodified lines
365365 default y
366366 depends on !ARC_CANT_LLSC
367367
368+config ARC_STAR_9000923308
369+ bool "Workaround for llock/scond livelock"
370+ default y
371+ depends on ISA_ARCV2 && SMP && ARC_HAS_LLSC
372+
368373 config ARC_HAS_SWAPE
369374 bool "Insn: SWAPE (endian-swap)"
370375 default y
@@ -379,6 +384,10 @@ config ARC_HAS_LL64 · 8 unmodified lines
379384 dest operands with 2 possible source operands.
380385 default y
381386
387+config ARC_HAS_DIV_REM
388+ bool "Insn: div, divu, rem, remu"
389+ default y
390+
382391 config ARC_HAS_RTC
383392 bool "Local 64-bit r/o cycle counter"
384393 default n
arch/arc/Makefile+9−1
@@ -36,8 +36,16 @@ cflags-$(atleast_gcc44) += -fsection-anchors · 35 unmodified lines
3636 cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock
3737 cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape
3838
39+ifdef CONFIG_ISA_ARCV2
40+
3941 ifndef CONFIG_ARC_HAS_LL64
40−cflags-$(CONFIG_ISA_ARCV2) += -mno-ll64
42+cflags-y += -mno-ll64
43+endif
44+
45+ifndef CONFIG_ARC_HAS_DIV_REM
46+cflags-y += -mno-div-rem
47+endif
48+
4149 endif
4250
4351 cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables
arch/arc/include/asm/arcregs.h+3−4
@@ -89,11 +89,10 @@ · 88 unmodified lines
8989 #define ECR_C_BIT_DTLB_LD_MISS 8
9090 #define ECR_C_BIT_DTLB_ST_MISS 9
9191
92−
9392 /* Auxiliary registers */
9493 #define AUX_IDENTITY 4
9594 #define AUX_INTR_VEC_BASE 0x25
96−
95+#define AUX_NON_VOL 0x5e
9796
9897 /*
9998 * Floating Pt Registers
@@ -240,9 +239,9 @@ struct bcr_extn_xymem { · 140 unmodified lines
240239
241240 struct bcr_perip {
242241 #ifdef CONFIG_CPU_BIG_ENDIAN
243− unsigned int start:8, pad2:8, sz:8, pad:8;
242+ unsigned int start:8, pad2:8, sz:8, ver:8;
244243 #else
245− unsigned int pad:8, sz:8, pad2:8, start:8;
244+ unsigned int ver:8, sz:8, pad2:8, start:8;
246245 #endif
247246 };
248247
arch/arc/include/asm/atomic.h+55−23
@@ -23,33 +23,60 @@ · 22 unmodified lines
2323
2424 #define atomic_set(v, i) (((v)->counter) = (i))
2525
26−#ifdef CONFIG_ISA_ARCV2
27−#define PREFETCHW " prefetchw [%1] \n"
28−#else
29−#define PREFETCHW
26+#ifdef CONFIG_ARC_STAR_9000923308
27+
28+#define SCOND_FAIL_RETRY_VAR_DEF \
29+ unsigned int delay = 1, tmp; \
30+
31+#define SCOND_FAIL_RETRY_ASM \
32+ " bz 4f \n" \
33+ " ; --- scond fail delay --- \n" \
34+ " mov %[tmp], %[delay] \n" /* tmp = delay */ \
35+ "2: brne.d %[tmp], 0, 2b \n" /* while (tmp != 0) */ \
36+ " sub %[tmp], %[tmp], 1 \n" /* tmp-- */ \
37+ " rol %[delay], %[delay] \n" /* delay *= 2 */ \
38+ " b 1b \n" /* start over */ \
39+ "4: ; --- success --- \n" \
40+
41+#define SCOND_FAIL_RETRY_VARS \
42+ ,[delay] "+&r" (delay),[tmp] "=&r" (tmp) \
43+
44+#else /* !CONFIG_ARC_STAR_9000923308 */
45+
46+#define SCOND_FAIL_RETRY_VAR_DEF
47+
48+#define SCOND_FAIL_RETRY_ASM \
49+ " bnz 1b \n" \
50+
51+#define SCOND_FAIL_RETRY_VARS
52+
3053 #endif
3154
3255 #define ATOMIC_OP(op, c_op, asm_op) \
3356 static inline void atomic_##op(int i, atomic_t *v) \
3457 { \
35− unsigned int temp; \
58+ unsigned int val; \
59+ SCOND_FAIL_RETRY_VAR_DEF \
3660 \
3761 __asm__ __volatile__( \
38− "1: \n" \
39− PREFETCHW \
40− " llock %0, [%1] \n" \
41− " " #asm_op " %0, %0, %2 \n" \
42− " scond %0, [%1] \n" \
43− " bnz 1b \n" \
44− : "=&r"(temp) /* Early clobber, to prevent reg reuse */ \
45− : "r"(&v->counter), "ir"(i) \
62+ "1: llock %[val], [%[ctr]] \n" \
63+ " " #asm_op " %[val], %[val], %[i] \n" \
64+ " scond %[val], [%[ctr]] \n" \
65+ " \n" \
66+ SCOND_FAIL_RETRY_ASM \
67+ \
68+ : [val] "=&r" (val) /* Early clobber to prevent reg reuse */ \
69+ SCOND_FAIL_RETRY_VARS \
70+ : [ctr] "r" (&v->counter), /* Not "m": llock only supports reg direct addr mode */ \
71+ [i] "ir" (i) \
4672 : "cc"); \
4773 } \
4874
4975 #define ATOMIC_OP_RETURN(op, c_op, asm_op) \
5076 static inline int atomic_##op##_return(int i, atomic_t *v) \
5177 { \
52− unsigned int temp; \
78+ unsigned int val; \
79+ SCOND_FAIL_RETRY_VAR_DEF \
5380 \
5481 /* \
5582 * Explicit full memory barrier needed before/after as \
@@ -58,19 +85,21 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \ · 2 unmodified lines
5885 smp_mb(); \
5986 \
6087 __asm__ __volatile__( \
61− "1: \n" \
62− PREFETCHW \
63− " llock %0, [%1] \n" \
64− " " #asm_op " %0, %0, %2 \n" \
65− " scond %0, [%1] \n" \
66− " bnz 1b \n" \
67− : "=&r"(temp) \
68− : "r"(&v->counter), "ir"(i) \
88+ "1: llock %[val], [%[ctr]] \n" \
89+ " " #asm_op " %[val], %[val], %[i] \n" \
90+ " scond %[val], [%[ctr]] \n" \
91+ " \n" \
92+ SCOND_FAIL_RETRY_ASM \
93+ \
94+ : [val] "=&r" (val) \
95+ SCOND_FAIL_RETRY_VARS \
96+ : [ctr] "r" (&v->counter), \
97+ [i] "ir" (i) \
6998 : "cc"); \
7099 \
71100 smp_mb(); \
72101 \
73− return temp; \
102+ return val; \
74103 }
75104
76105 #else /* !CONFIG_ARC_HAS_LLSC */
@@ -150,6 +179,9 @@ ATOMIC_OP(and, &=, and) · 73 unmodified lines
150179 #undef ATOMIC_OPS
151180 #undef ATOMIC_OP_RETURN
152181 #undef ATOMIC_OP
182+#undef SCOND_FAIL_RETRY_VAR_DEF
183+#undef SCOND_FAIL_RETRY_ASM
184+#undef SCOND_FAIL_RETRY_VARS
153185
154186 /**
155187 * __atomic_add_unless - add unless the number is a given value
arch/arc/include/asm/ptrace.h+27−27
@@ -20,20 +20,20 @@ · 19 unmodified lines
2020 struct pt_regs {
2121
2222 /* Real registers */
23− long bta; /* bta_l1, bta_l2, erbta */
23+ unsigned long bta; /* bta_l1, bta_l2, erbta */
2424
25− long lp_start, lp_end, lp_count;
25+ unsigned long lp_start, lp_end, lp_count;
2626
27− long status32; /* status32_l1, status32_l2, erstatus */
28− long ret; /* ilink1, ilink2 or eret */
29− long blink;
30− long fp;
31− long r26; /* gp */
27+ unsigned long status32; /* status32_l1, status32_l2, erstatus */
28+ unsigned long ret; /* ilink1, ilink2 or eret */
29+ unsigned long blink;
30+ unsigned long fp;
31+ unsigned long r26; /* gp */
3232
33− long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0;
33+ unsigned long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0;
3434
35− long sp; /* user/kernel sp depending on where we came from */
36− long orig_r0;
35+ unsigned long sp; /* User/Kernel depending on where we came from */
36+ unsigned long orig_r0;
3737
3838 /*
3939 * To distinguish bet excp, syscall, irq
@@ -55,13 +55,13 @@ struct pt_regs { · 15 unmodified lines
5555 unsigned long event;
5656 };
5757
58− long user_r25;
58+ unsigned long user_r25;
5959 };
6060 #else
6161
6262 struct pt_regs {
6363
64− long orig_r0;
64+ unsigned long orig_r0;
6565
6666 union {
6767 struct {
@@ -76,26 +76,26 @@ struct pt_regs { · 8 unmodified lines
7676 unsigned long event;
7777 };
7878
79− long bta; /* bta_l1, bta_l2, erbta */
79+ unsigned long bta; /* bta_l1, bta_l2, erbta */
8080
81− long user_r25;
81+ unsigned long user_r25;
8282
83− long r26; /* gp */
84− long fp;
85− long sp; /* user/kernel sp depending on where we came from */
83+ unsigned long r26; /* gp */
84+ unsigned long fp;
85+ unsigned long sp; /* user/kernel sp depending on where we came from */
8686
87− long r12;
87+ unsigned long r12;
8888
8989 /*------- Below list auto saved by h/w -----------*/
90− long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11;
90+ unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11;
9191
92− long blink;
93− long lp_end, lp_start, lp_count;
92+ unsigned long blink;
93+ unsigned long lp_end, lp_start, lp_count;
9494
95− long ei, ldi, jli;
95+ unsigned long ei, ldi, jli;
9696
97− long ret;
98− long status32;
97+ unsigned long ret;
98+ unsigned long status32;
9999 };
100100
101101 #endif
@@ -103,10 +103,10 @@ struct pt_regs { · 1 unmodified line
103103 /* Callee saved registers - need to be saved only when you are scheduled out */
104104
105105 struct callee_regs {
106− long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13;
106+ unsigned long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13;
107107 };
108108
109−#define instruction_pointer(regs) (unsigned long)((regs)->ret)
109+#define instruction_pointer(regs) ((regs)->ret)
110110 #define profile_pc(regs) instruction_pointer(regs)
111111
112112 /* return 1 if user mode or 0 if kernel mode */
@@ -142,7 +142,7 @@ struct callee_regs { · 29 unmodified lines
142142
143143 static inline long regs_return_value(struct pt_regs *regs)
144144 {
145− return regs->r0;
145+ return (long)regs->r0;
146146 }
147147
148148 #endif /* !__ASSEMBLY__ */
arch/arc/include/asm/spinlock.h+523−15
@@ -18,9 +18,518 @@ · 17 unmodified lines
1818 #define arch_spin_unlock_wait(x) \
1919 do { while (arch_spin_is_locked(x)) cpu_relax(); } while (0)
2020
21+#ifdef CONFIG_ARC_HAS_LLSC
22+
23+/*
24+ * A normal LLOCK/SCOND based system, w/o need for livelock workaround
25+ */
26+#ifndef CONFIG_ARC_STAR_9000923308
27+
2128 static inline void arch_spin_lock(arch_spinlock_t *lock)
2229 {
23− unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__;
30+ unsigned int val;
31+
32+ smp_mb();
33+
34+ __asm__ __volatile__(
35+ "1: llock %[val], [%[slock]] \n"
36+ " breq %[val], %[LOCKED], 1b \n" /* spin while LOCKED */
37+ " scond %[LOCKED], [%[slock]] \n" /* acquire */
38+ " bnz 1b \n"
39+ " \n"
40+ : [val] "=&r" (val)
41+ : [slock] "r" (&(lock->slock)),
42+ [LOCKED] "r" (__ARCH_SPIN_LOCK_LOCKED__)
43+ : "memory", "cc");
44+
45+ smp_mb();
46+}
47+
48+/* 1 - lock taken successfully */
49+static inline int arch_spin_trylock(arch_spinlock_t *lock)
50+{
51+ unsigned int val, got_it = 0;
52+
53+ smp_mb();
54+
55+ __asm__ __volatile__(
56+ "1: llock %[val], [%[slock]] \n"
57+ " breq %[val], %[LOCKED], 4f \n" /* already LOCKED, just bail */
58+ " scond %[LOCKED], [%[slock]] \n" /* acquire */
59+ " bnz 1b \n"
60+ " mov %[got_it], 1 \n"
61+ "4: \n"
62+ " \n"
63+ : [val] "=&r" (val),
64+ [got_it] "+&r" (got_it)
65+ : [slock] "r" (&(lock->slock)),
66+ [LOCKED] "r" (__ARCH_SPIN_LOCK_LOCKED__)
67+ : "memory", "cc");
68+
69+ smp_mb();
70+
71+ return got_it;
72+}
73+
74+static inline void arch_spin_unlock(arch_spinlock_t *lock)
75+{
76+ smp_mb();
77+
78+ lock->slock = __ARCH_SPIN_LOCK_UNLOCKED__;
79+
80+ smp_mb();
81+}
82+
83+/*
84+ * Read-write spinlocks, allowing multiple readers but only one writer.
85+ * Unfair locking as Writers could be starved indefinitely by Reader(s)
86+ */
87+
88+static inline void arch_read_lock(arch_rwlock_t *rw)
89+{
90+ unsigned int val;
91+
92+ smp_mb();
93+
94+ /*
95+ * zero means writer holds the lock exclusively, deny Reader.
96+ * Otherwise grant lock to first/subseq reader
97+ *
98+ * if (rw->counter > 0) {
99+ * rw->counter--;
100+ * ret = 1;
101+ * }
102+ */
103+
104+ __asm__ __volatile__(
105+ "1: llock %[val], [%[rwlock]] \n"
106+ " brls %[val], %[WR_LOCKED], 1b\n" /* <= 0: spin while write locked */
107+ " sub %[val], %[val], 1 \n" /* reader lock */
108+ " scond %[val], [%[rwlock]] \n"
109+ " bnz 1b \n"
110+ " \n"
111+ : [val] "=&r" (val)
112+ : [rwlock] "r" (&(rw->counter)),
113+ [WR_LOCKED] "ir" (0)
114+ : "memory", "cc");
115+
116+ smp_mb();
117+}
118+
119+/* 1 - lock taken successfully */
120+static inline int arch_read_trylock(arch_rwlock_t *rw)
121+{
122+ unsigned int val, got_it = 0;
123+
124+ smp_mb();
125+
126+ __asm__ __volatile__(
127+ "1: llock %[val], [%[rwlock]] \n"
128+ " brls %[val], %[WR_LOCKED], 4f\n" /* <= 0: already write locked, bail */
129+ " sub %[val], %[val], 1 \n" /* counter-- */
130+ " scond %[val], [%[rwlock]] \n"
131+ " bnz 1b \n" /* retry if collided with someone */
132+ " mov %[got_it], 1 \n"
133+ " \n"
134+ "4: ; --- done --- \n"
135+
136+ : [val] "=&r" (val),
137+ [got_it] "+&r" (got_it)
138+ : [rwlock] "r" (&(rw->counter)),
139+ [WR_LOCKED] "ir" (0)
140+ : "memory", "cc");
141+
142+ smp_mb();
143+
144+ return got_it;
145+}
146+
147+static inline void arch_write_lock(arch_rwlock_t *rw)
148+{
149+ unsigned int val;
150+
151+ smp_mb();
152+
153+ /*
154+ * If reader(s) hold lock (lock < __ARCH_RW_LOCK_UNLOCKED__),
155+ * deny writer. Otherwise if unlocked grant to writer
156+ * Hence the claim that Linux rwlocks are unfair to writers.
157+ * (can be starved for an indefinite time by readers).
158+ *
159+ * if (rw->counter == __ARCH_RW_LOCK_UNLOCKED__) {
160+ * rw->counter = 0;
161+ * ret = 1;
162+ * }
163+ */
164+
165+ __asm__ __volatile__(
166+ "1: llock %[val], [%[rwlock]] \n"
167+ " brne %[val], %[UNLOCKED], 1b \n" /* while !UNLOCKED spin */
168+ " mov %[val], %[WR_LOCKED] \n"
169+ " scond %[val], [%[rwlock]] \n"
170+ " bnz 1b \n"
171+ " \n"
172+ : [val] "=&r" (val)
173+ : [rwlock] "r" (&(rw->counter)),
174+ [UNLOCKED] "ir" (__ARCH_RW_LOCK_UNLOCKED__),
175+ [WR_LOCKED] "ir" (0)
176+ : "memory", "cc");
177+
178+ smp_mb();
179+}
180+
181+/* 1 - lock taken successfully */
182+static inline int arch_write_trylock(arch_rwlock_t *rw)
183+{
184+ unsigned int val, got_it = 0;
185+
186+ smp_mb();
187+
188+ __asm__ __volatile__(
189+ "1: llock %[val], [%[rwlock]] \n"
190+ " brne %[val], %[UNLOCKED], 4f \n" /* !UNLOCKED, bail */
191+ " mov %[val], %[WR_LOCKED] \n"
192+ " scond %[val], [%[rwlock]] \n"
193+ " bnz 1b \n" /* retry if collided with someone */
194+ " mov %[got_it], 1 \n"
195+ " \n"
196+ "4: ; --- done --- \n"
197+
198+ : [val] "=&r" (val),
199+ [got_it] "+&r" (got_it)
200+ : [rwlock] "r" (&(rw->counter)),
201+ [UNLOCKED] "ir" (__ARCH_RW_LOCK_UNLOCKED__),
202+ [WR_LOCKED] "ir" (0)
203+ : "memory", "cc");
204+
205+ smp_mb();
206+
207+ return got_it;
208+}
209+
210+static inline void arch_read_unlock(arch_rwlock_t *rw)
211+{
212+ unsigned int val;
213+
214+ smp_mb();
215+
216+ /*
217+ * rw->counter++;
218+ */
219+ __asm__ __volatile__(
220+ "1: llock %[val], [%[rwlock]] \n"
221+ " add %[val], %[val], 1 \n"
222+ " scond %[val], [%[rwlock]] \n"
223+ " bnz 1b \n"
224+ " \n"
225+ : [val] "=&r" (val)
226+ : [rwlock] "r" (&(rw->counter))
227+ : "memory", "cc");
228+
229+ smp_mb();
230+}
231+
232+static inline void arch_write_unlock(arch_rwlock_t *rw)
233+{
234+ smp_mb();
235+
236+ rw->counter = __ARCH_RW_LOCK_UNLOCKED__;
237+
238+ smp_mb();
239+}
240+
241+#else /* CONFIG_ARC_STAR_9000923308 */
242+
243+/*
244+ * HS38x4 could get into a LLOCK/SCOND livelock in case of multiple overlapping
245+ * coherency transactions in the SCU. The exclusive line state keeps rotating
246+ * among contenting cores leading to a never ending cycle. So break the cycle
247+ * by deferring the retry of failed exclusive access (SCOND). The actual delay
248+ * needed is function of number of contending cores as well as the unrelated
249+ * coherency traffic from other cores. To keep the code simple, start off with
250+ * small delay of 1 which would suffice most cases and in case of contention
251+ * double the delay. Eventually the delay is sufficient such that the coherency
252+ * pipeline is drained, thus a subsequent exclusive access would succeed.
253+ */
254+
255+#define SCOND_FAIL_RETRY_VAR_DEF \
256+ unsigned int delay, tmp; \
257+
258+#define SCOND_FAIL_RETRY_ASM \
259+ " ; --- scond fail delay --- \n" \
260+ " mov %[tmp], %[delay] \n" /* tmp = delay */ \
261+ "2: brne.d %[tmp], 0, 2b \n" /* while (tmp != 0) */ \
262+ " sub %[tmp], %[tmp], 1 \n" /* tmp-- */ \
263+ " rol %[delay], %[delay] \n" /* delay *= 2 */ \
264+ " b 1b \n" /* start over */ \
265+ " \n" \
266+ "4: ; --- done --- \n" \
267+
268+#define SCOND_FAIL_RETRY_VARS \
269+ ,[delay] "=&r" (delay), [tmp] "=&r" (tmp) \
270+
271+static inline void arch_spin_lock(arch_spinlock_t *lock)
272+{
273+ unsigned int val;
274+ SCOND_FAIL_RETRY_VAR_DEF;
275+
276+ smp_mb();
277+
278+ __asm__ __volatile__(
279+ "0: mov %[delay], 1 \n"
280+ "1: llock %[val], [%[slock]] \n"
281+ " breq %[val], %[LOCKED], 0b \n" /* spin while LOCKED */
282+ " scond %[LOCKED], [%[slock]] \n" /* acquire */
283+ " bz 4f \n" /* done */
284+ " \n"
285+ SCOND_FAIL_RETRY_ASM
286+
287+ : [val] "=&r" (val)
288+ SCOND_FAIL_RETRY_VARS
289+ : [slock] "r" (&(lock->slock)),
290+ [LOCKED] "r" (__ARCH_SPIN_LOCK_LOCKED__)
291+ : "memory", "cc");
292+
293+ smp_mb();
294+}
295+
296+/* 1 - lock taken successfully */
297+static inline int arch_spin_trylock(arch_spinlock_t *lock)
298+{
299+ unsigned int val, got_it = 0;
300+ SCOND_FAIL_RETRY_VAR_DEF;
301+
302+ smp_mb();
303+
304+ __asm__ __volatile__(
305+ "0: mov %[delay], 1 \n"
306+ "1: llock %[val], [%[slock]] \n"
307+ " breq %[val], %[LOCKED], 4f \n" /* already LOCKED, just bail */
308+ " scond %[LOCKED], [%[slock]] \n" /* acquire */
309+ " bz.d 4f \n"
310+ " mov.z %[got_it], 1 \n" /* got it */
311+ " \n"
312+ SCOND_FAIL_RETRY_ASM
313+
314+ : [val] "=&r" (val),
315+ [got_it] "+&r" (got_it)
316+ SCOND_FAIL_RETRY_VARS
317+ : [slock] "r" (&(lock->slock)),
318+ [LOCKED] "r" (__ARCH_SPIN_LOCK_LOCKED__)
319+ : "memory", "cc");
320+
321+ smp_mb();
322+
323+ return got_it;
324+}
325+
326+static inline void arch_spin_unlock(arch_spinlock_t *lock)
327+{
328+ smp_mb();
329+
330+ lock->slock = __ARCH_SPIN_LOCK_UNLOCKED__;
331+
332+ smp_mb();
333+}
334+
335+/*
336+ * Read-write spinlocks, allowing multiple readers but only one writer.
337+ * Unfair locking as Writers could be starved indefinitely by Reader(s)
338+ */
339+
340+static inline void arch_read_lock(arch_rwlock_t *rw)
341+{
342+ unsigned int val;
343+ SCOND_FAIL_RETRY_VAR_DEF;
344+
345+ smp_mb();
346+
347+ /*
348+ * zero means writer holds the lock exclusively, deny Reader.
349+ * Otherwise grant lock to first/subseq reader
350+ *
351+ * if (rw->counter > 0) {
352+ * rw->counter--;
353+ * ret = 1;
354+ * }
355+ */
356+
357+ __asm__ __volatile__(
358+ "0: mov %[delay], 1 \n"
359+ "1: llock %[val], [%[rwlock]] \n"
360+ " brls %[val], %[WR_LOCKED], 0b\n" /* <= 0: spin while write locked */
361+ " sub %[val], %[val], 1 \n" /* reader lock */
362+ " scond %[val], [%[rwlock]] \n"
363+ " bz 4f \n" /* done */
364+ " \n"
365+ SCOND_FAIL_RETRY_ASM
366+
367+ : [val] "=&r" (val)
368+ SCOND_FAIL_RETRY_VARS
369+ : [rwlock] "r" (&(rw->counter)),
370+ [WR_LOCKED] "ir" (0)
371+ : "memory", "cc");
372+
373+ smp_mb();
374+}
375+
376+/* 1 - lock taken successfully */
377+static inline int arch_read_trylock(arch_rwlock_t *rw)
378+{
379+ unsigned int val, got_it = 0;
380+ SCOND_FAIL_RETRY_VAR_DEF;
381+
382+ smp_mb();
383+
384+ __asm__ __volatile__(
385+ "0: mov %[delay], 1 \n"
386+ "1: llock %[val], [%[rwlock]] \n"
387+ " brls %[val], %[WR_LOCKED], 4f\n" /* <= 0: already write locked, bail */
388+ " sub %[val], %[val], 1 \n" /* counter-- */
389+ " scond %[val], [%[rwlock]] \n"
390+ " bz.d 4f \n"
391+ " mov.z %[got_it], 1 \n" /* got it */
392+ " \n"
393+ SCOND_FAIL_RETRY_ASM
394+
395+ : [val] "=&r" (val),
396+ [got_it] "+&r" (got_it)
397+ SCOND_FAIL_RETRY_VARS
398+ : [rwlock] "r" (&(rw->counter)),
399+ [WR_LOCKED] "ir" (0)
400+ : "memory", "cc");
401+
402+ smp_mb();
403+
404+ return got_it;
405+}
406+
407+static inline void arch_write_lock(arch_rwlock_t *rw)
408+{
409+ unsigned int val;
410+ SCOND_FAIL_RETRY_VAR_DEF;
411+
412+ smp_mb();
413+
414+ /*
415+ * If reader(s) hold lock (lock < __ARCH_RW_LOCK_UNLOCKED__),
416+ * deny writer. Otherwise if unlocked grant to writer
417+ * Hence the claim that Linux rwlocks are unfair to writers.
418+ * (can be starved for an indefinite time by readers).
419+ *
420+ * if (rw->counter == __ARCH_RW_LOCK_UNLOCKED__) {
421+ * rw->counter = 0;
422+ * ret = 1;
423+ * }
424+ */
425+
426+ __asm__ __volatile__(
427+ "0: mov %[delay], 1 \n"
428+ "1: llock %[val], [%[rwlock]] \n"
429+ " brne %[val], %[UNLOCKED], 0b \n" /* while !UNLOCKED spin */
430+ " mov %[val], %[WR_LOCKED] \n"
431+ " scond %[val], [%[rwlock]] \n"
432+ " bz 4f \n"
433+ " \n"
434+ SCOND_FAIL_RETRY_ASM
435+
436+ : [val] "=&r" (val)
437+ SCOND_FAIL_RETRY_VARS
438+ : [rwlock] "r" (&(rw->counter)),
439+ [UNLOCKED] "ir" (__ARCH_RW_LOCK_UNLOCKED__),
440+ [WR_LOCKED] "ir" (0)
441+ : "memory", "cc");
442+
443+ smp_mb();
444+}
445+
446+/* 1 - lock taken successfully */
447+static inline int arch_write_trylock(arch_rwlock_t *rw)
448+{
449+ unsigned int val, got_it = 0;
450+ SCOND_FAIL_RETRY_VAR_DEF;
451+
452+ smp_mb();
453+
454+ __asm__ __volatile__(
455+ "0: mov %[delay], 1 \n"
456+ "1: llock %[val], [%[rwlock]] \n"
457+ " brne %[val], %[UNLOCKED], 4f \n" /* !UNLOCKED, bail */
458+ " mov %[val], %[WR_LOCKED] \n"
459+ " scond %[val], [%[rwlock]] \n"
460+ " bz.d 4f \n"
461+ " mov.z %[got_it], 1 \n" /* got it */
462+ " \n"
463+ SCOND_FAIL_RETRY_ASM
464+
465+ : [val] "=&r" (val),
466+ [got_it] "+&r" (got_it)
467+ SCOND_FAIL_RETRY_VARS
468+ : [rwlock] "r" (&(rw->counter)),
469+ [UNLOCKED] "ir" (__ARCH_RW_LOCK_UNLOCKED__),
470+ [WR_LOCKED] "ir" (0)
471+ : "memory", "cc");
472+
473+ smp_mb();
474+
475+ return got_it;
476+}
477+
478+static inline void arch_read_unlock(arch_rwlock_t *rw)
479+{
480+ unsigned int val;
481+
482+ smp_mb();
483+
484+ /*
485+ * rw->counter++;
486+ */
487+ __asm__ __volatile__(
488+ "1: llock %[val], [%[rwlock]] \n"
489+ " add %[val], %[val], 1 \n"
490+ " scond %[val], [%[rwlock]] \n"
491+ " bnz 1b \n"
492+ " \n"
493+ : [val] "=&r" (val)
494+ : [rwlock] "r" (&(rw->counter))
495+ : "memory", "cc");
496+
497+ smp_mb();
498+}
499+
500+static inline void arch_write_unlock(arch_rwlock_t *rw)
501+{
502+ unsigned int val;
503+
504+ smp_mb();
505+
506+ /*
507+ * rw->counter = __ARCH_RW_LOCK_UNLOCKED__;
508+ */
509+ __asm__ __volatile__(
510+ "1: llock %[val], [%[rwlock]] \n"
511+ " scond %[UNLOCKED], [%[rwlock]]\n"
512+ " bnz 1b \n"
513+ " \n"
514+ : [val] "=&r" (val)
515+ : [rwlock] "r" (&(rw->counter)),
516+ [UNLOCKED] "r" (__ARCH_RW_LOCK_UNLOCKED__)
517+ : "memory", "cc");
518+
519+ smp_mb();
520+}
521+
522+#undef SCOND_FAIL_RETRY_VAR_DEF
523+#undef SCOND_FAIL_RETRY_ASM
524+#undef SCOND_FAIL_RETRY_VARS
525+
526+#endif /* CONFIG_ARC_STAR_9000923308 */
527+
528+#else /* !CONFIG_ARC_HAS_LLSC */
529+
530+static inline void arch_spin_lock(arch_spinlock_t *lock)
531+{
532+ unsigned int val = __ARCH_SPIN_LOCK_LOCKED__;
24533
25534 /*
26535 * This smp_mb() is technically superfluous, we only need the one
@@ -33,7 +542,7 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) · 6 unmodified lines
33542 __asm__ __volatile__(
34543 "1: ex %0, [%1] \n"
35544 " breq %0, %2, 1b \n"
36− : "+&r" (tmp)
545+ : "+&r" (val)
37546 : "r"(&(lock->slock)), "ir"(__ARCH_SPIN_LOCK_LOCKED__)
38547 : "memory");
39548
@@ -48,26 +557,27 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) · 8 unmodified lines
48557 smp_mb();
49558 }
50559
560+/* 1 - lock taken successfully */
51561 static inline int arch_spin_trylock(arch_spinlock_t *lock)
52562 {
53− unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__;
563+ unsigned int val = __ARCH_SPIN_LOCK_LOCKED__;
54564
55565 smp_mb();
56566
57567 __asm__ __volatile__(
58568 "1: ex %0, [%1] \n"
59− : "+r" (tmp)
569+ : "+r" (val)
60570 : "r"(&(lock->slock))
61571 : "memory");
62572
63573 smp_mb();
64574
65− return (tmp == __ARCH_SPIN_LOCK_UNLOCKED__);
575+ return (val == __ARCH_SPIN_LOCK_UNLOCKED__);
66576 }
67577
68578 static inline void arch_spin_unlock(arch_spinlock_t *lock)
69579 {
70− unsigned int tmp = __ARCH_SPIN_LOCK_UNLOCKED__;
580+ unsigned int val = __ARCH_SPIN_LOCK_UNLOCKED__;
71581
72582 /*
73583 * RELEASE barrier: given the instructions avail on ARCv2, full barrier
@@ -77,7 +587,7 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock) · 3 unmodified lines
77587
78588 __asm__ __volatile__(
79589 " ex %0, [%1] \n"
80− : "+r" (tmp)
590+ : "+r" (val)
81591 : "r"(&(lock->slock))
82592 : "memory");
83593
@@ -90,19 +600,12 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock) · 6 unmodified lines
90600
91601 /*
92602 * Read-write spinlocks, allowing multiple readers but only one writer.
603+ * Unfair locking as Writers could be starved indefinitely by Reader(s)
93604 *
94605 * The spinlock itself is contained in @counter and access to it is
95606 * serialized with @lock_mutex.
96− *
97− * Unfair locking as Writers could be starved indefinitely by Reader(s)
98607 */
99608
100−/* Would read_trylock() succeed? */
101−#define arch_read_can_lock(x) ((x)->counter > 0)
102−
103−/* Would write_trylock() succeed? */
104−#define arch_write_can_lock(x) ((x)->counter == __ARCH_RW_LOCK_UNLOCKED__)
105−
106609 /* 1 - lock taken successfully */
107610 static inline int arch_read_trylock(arch_rwlock_t *rw)
108611 {
@@ -173,6 +676,11 @@ static inline void arch_write_unlock(arch_rwlock_t *rw) · 64 unmodified lines
173676 arch_spin_unlock(&(rw->lock_mutex));
174677 }
175678
679+#endif
680+
681+#define arch_read_can_lock(x) ((x)->counter > 0)
682+#define arch_write_can_lock(x) ((x)->counter == __ARCH_RW_LOCK_UNLOCKED__)
683+
176684 #define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
177685 #define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
178686
arch/arc/include/asm/spinlock_types.h+2−0
@@ -26,7 +26,9 @@ typedef struct { · 25 unmodified lines
2626 */
2727 typedef struct {
2828 volatile unsigned int counter;
29+#ifndef CONFIG_ARC_HAS_LLSC
2930 arch_spinlock_t lock_mutex;
31+#endif
3032 } arch_rwlock_t;
3133
3234 #define __ARCH_RW_LOCK_UNLOCKED__ 0x01000000
arch/arc/include/uapi/asm/ptrace.h+10−10
@@ -32,20 +32,20 @@ · 31 unmodified lines
3232 */
3333 struct user_regs_struct {
3434
35− long pad;
35+ unsigned long pad;
3636 struct {
37− long bta, lp_start, lp_end, lp_count;
38− long status32, ret, blink, fp, gp;
39− long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0;
40− long sp;
37+ unsigned long bta, lp_start, lp_end, lp_count;
38+ unsigned long status32, ret, blink, fp, gp;
39+ unsigned long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0;
40+ unsigned long sp;
4141 } scratch;
42− long pad2;
42+ unsigned long pad2;
4343 struct {
44− long r25, r24, r23, r22, r21, r20;
45− long r19, r18, r17, r16, r15, r14, r13;
44+ unsigned long r25, r24, r23, r22, r21, r20;
45+ unsigned long r19, r18, r17, r16, r15, r14, r13;
4646 } callee;
47− long efa; /* break pt addr, for break points in delay slots */
48− long stop_pc; /* give dbg stop_pc after ensuring brkpt trap */
47+ unsigned long efa; /* break pt addr, for break points in delay slots */
48+ unsigned long stop_pc; /* give dbg stop_pc after ensuring brkpt trap */
4949 };
5050 #endif /* !__ASSEMBLY__ */
5151
arch/arc/kernel/setup.c+11−1
@@ -47,6 +47,7 @@ static void read_arc_build_cfg_regs(void) · 46 unmodified lines
4747 struct bcr_perip uncached_space;
4848 struct bcr_generic bcr;
4949 struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
50+ unsigned long perip_space;
5051 FIX_PTR(cpu);
5152
5253 READ_BCR(AUX_IDENTITY, cpu->core);
@@ -56,7 +57,12 @@ static void read_arc_build_cfg_regs(void) · 3 unmodified lines
5657 cpu->vec_base = read_aux_reg(AUX_INTR_VEC_BASE);
5758
5859 READ_BCR(ARC_REG_D_UNCACH_BCR, uncached_space);
59− BUG_ON((uncached_space.start << 24) != ARC_UNCACHED_ADDR_SPACE);
60+ if (uncached_space.ver < 3)
61+ perip_space = uncached_space.start << 24;
62+ else
63+ perip_space = read_aux_reg(AUX_NON_VOL) & 0xF0000000;
64+
65+ BUG_ON(perip_space != ARC_UNCACHED_ADDR_SPACE);
6066
6167 READ_BCR(ARC_REG_MUL_BCR, cpu->extn_mpy);
6268
@@ -330,6 +336,10 @@ static void arc_chk_core_config(void) · 267 unmodified lines
330336 pr_warn("CONFIG_ARC_FPU_SAVE_RESTORE needed for working apps\n");
331337 else if (!cpu->extn.fpu_dp && fpu_enabled)
332338 panic("FPU non-existent, disable CONFIG_ARC_FPU_SAVE_RESTORE\n");
339+
340+ if (is_isa_arcv2() && IS_ENABLED(CONFIG_SMP) && cpu->isa.atomic &&
341+ !IS_ENABLED(CONFIG_ARC_STAR_9000923308))
342+ panic("llock/scond livelock workaround missing\n");
333343 }
334344
335345 /*
arch/arc/kernel/time.c+15−25
@@ -203,34 +203,24 @@ static int arc_clkevent_set_next_event(unsigned long delta, · 202 unmodified lines
203203 return 0;
204204 }
205205
206−static void arc_clkevent_set_mode(enum clock_event_mode mode,
207− struct clock_event_device *dev)
206+static int arc_clkevent_set_periodic(struct clock_event_device *dev)
208207 {
209− switch (mode) {
210− case CLOCK_EVT_MODE_PERIODIC:
211− /*
212− * At X Hz, 1 sec = 1000ms -> X cycles;
213− * 10ms -> X / 100 cycles
214− */
215− arc_timer_event_setup(arc_get_core_freq() / HZ);
216− break;
217− case CLOCK_EVT_MODE_ONESHOT:
218− break;
219− default:
220− break;
221− }
222−
223− return;
208+ /*
209+ * At X Hz, 1 sec = 1000ms -> X cycles;
210+ * 10ms -> X / 100 cycles
211+ */
212+ arc_timer_event_setup(arc_get_core_freq() / HZ);
213+ return 0;
224214 }
225215
226216 static DEFINE_PER_CPU(struct clock_event_device, arc_clockevent_device) = {
227− .name = "ARC Timer0",
228− .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC,
229− .mode = CLOCK_EVT_MODE_UNUSED,
230− .rating = 300,
231− .irq = TIMER0_IRQ, /* hardwired, no need for resources */
232− .set_next_event = arc_clkevent_set_next_event,
233− .set_mode = arc_clkevent_set_mode,
217+ .name = "ARC Timer0",
218+ .features = CLOCK_EVT_FEAT_ONESHOT |
219+ CLOCK_EVT_FEAT_PERIODIC,
220+ .rating = 300,
221+ .irq = TIMER0_IRQ, /* hardwired, no need for resources */
222+ .set_next_event = arc_clkevent_set_next_event,
223+ .set_state_periodic = arc_clkevent_set_periodic,
234224 };
235225
236226 static irqreturn_t timer_irq_handler(int irq, void *dev_id)
@@ -240,7 +230,7 @@ static irqreturn_t timer_irq_handler(int irq, void *dev_id) · 3 unmodified lines
240230 * irq_set_chip_and_handler() asked for handle_percpu_devid_irq()
241231 */
242232 struct clock_event_device *evt = this_cpu_ptr(&arc_clockevent_device);
243− int irq_reenable = evt->mode == CLOCK_EVT_MODE_PERIODIC;
233+ int irq_reenable = clockevent_state_periodic(evt);
244234
245235 /*
246236 * Any write to CTRL reg ACks the interrupt, we rewrite the
arch/arc/lib/memcpy-archs.S+1−1
@@ -206,7 +206,7 @@ unalignedOffby3: · 205 unmodified lines
206206 ld.ab r6, [r1, 4]
207207 prefetch [r1, 28] ;Prefetch the next read location
208208 ld.ab r8, [r1,4]
209− prefetch [r3, 32] ;Prefetch the next write location
209+ prefetchw [r3, 32] ;Prefetch the next write location
210210
211211 SHIFT_1 (r7, r6, 8)
212212 or r7, r7, r5
arch/arc/lib/memset-archs.S+36−7
@@ -10,12 +10,6 @@ · 9 unmodified lines
1010
1111 #undef PREALLOC_NOT_AVAIL
1212
13−#ifdef PREALLOC_NOT_AVAIL
14−#define PREWRITE(A,B) prefetchw [(A),(B)]
15−#else
16−#define PREWRITE(A,B) prealloc [(A),(B)]
17−#endif
18−
1913 ENTRY(memset)
2014 prefetchw [r0] ; Prefetch the write location
2115 mov.f 0, r2
@@ -51,9 +45,15 @@ ENTRY(memset) · 29 unmodified lines
5145
5246 ;;; Convert len to Dwords, unfold x8
5347 lsr.f lp_count, lp_count, 6
48+
5449 lpnz @.Lset64bytes
5550 ;; LOOP START
56− PREWRITE(r3, 64) ;Prefetch the next write location
51+#ifdef PREALLOC_NOT_AVAIL
52+ prefetchw [r3, 64] ;Prefetch the next write location
53+#else
54+ prealloc [r3, 64]
55+#endif
56+#ifdef CONFIG_ARC_HAS_LL64
5757 std.ab r4, [r3, 8]
5858 std.ab r4, [r3, 8]
5959 std.ab r4, [r3, 8]
@@ -62,16 +62,45 @@ ENTRY(memset) · 2 unmodified lines
6262 std.ab r4, [r3, 8]
6363 std.ab r4, [r3, 8]
6464 std.ab r4, [r3, 8]
65+#else
66+ st.ab r4, [r3, 4]
67+ st.ab r4, [r3, 4]
68+ st.ab r4, [r3, 4]
69+ st.ab r4, [r3, 4]
70+ st.ab r4, [r3, 4]
71+ st.ab r4, [r3, 4]
72+ st.ab r4, [r3, 4]
73+ st.ab r4, [r3, 4]
74+ st.ab r4, [r3, 4]
75+ st.ab r4, [r3, 4]
76+ st.ab r4, [r3, 4]
77+ st.ab r4, [r3, 4]
78+ st.ab r4, [r3, 4]
79+ st.ab r4, [r3, 4]
80+ st.ab r4, [r3, 4]
81+ st.ab r4, [r3, 4]
82+#endif
6583 .Lset64bytes:
6684
6785 lsr.f lp_count, r2, 5 ;Last remaining max 124 bytes
6886 lpnz .Lset32bytes
6987 ;; LOOP START
7088 prefetchw [r3, 32] ;Prefetch the next write location
89+#ifdef CONFIG_ARC_HAS_LL64
7190 std.ab r4, [r3, 8]
7291 std.ab r4, [r3, 8]
7392 std.ab r4, [r3, 8]
7493 std.ab r4, [r3, 8]
94+#else
95+ st.ab r4, [r3, 4]
96+ st.ab r4, [r3, 4]
97+ st.ab r4, [r3, 4]
98+ st.ab r4, [r3, 4]
99+ st.ab r4, [r3, 4]
100+ st.ab r4, [r3, 4]
101+ st.ab r4, [r3, 4]
102+ st.ab r4, [r3, 4]
103+#endif
75104 .Lset32bytes:
76105
77106 and.f lp_count, r2, 0x1F ;Last remaining 31 bytes
arch/arc/plat-axs10x/axs10x.c+15−0
@@ -389,6 +389,21 @@ axs103_set_freq(unsigned int id, unsigned int fd, unsigned int od) · 388 unmodified lines
389389
390390 static void __init axs103_early_init(void)
391391 {
392+ /*
393+ * AXS103 configurations for SMP/QUAD configurations share device tree
394+ * which defaults to 90 MHz. However recent failures of Quad config
395+ * revealed P&R timing violations so clamp it down to safe 50 MHz
396+ * Instead of duplicating defconfig/DT for SMP/QUAD, add a small hack
397+ *
398+ * This hack is really hacky as of now. Fix it properly by getting the
399+ * number of cores as return value of platform's early SMP callback
400+ */
401+#ifdef CONFIG_ARC_MCIP
402+ unsigned int num_cores = (read_aux_reg(ARC_REG_MCIP_BCR) >> 16) & 0x3F;
403+ if (num_cores > 2)
404+ arc_set_core_freq(50 * 1000000);
405+#endif
406+
392407 switch (arc_get_core_freq()/1000000) {
393408 case 33:
394409 axs103_set_freq(1, 1, 1);
arch/arm/boot/dts/dra7.dtsi+2−1
@@ -116,7 +116,7 @@ · 115 unmodified lines
116116 ranges = <0 0x2000 0x2000>;
117117
118118 scm_conf: scm_conf@0 {
119− compatible = "syscon";
119+ compatible = "syscon", "simple-bus";
120120 reg = <0x0 0x1400>;
121121 #address-cells = <1>;
122122 #size-cells = <1>;
@@ -1140,6 +1140,7 @@ · 1017 unmodified lines
11401140 ctrl-module = <&omap_control_sata>;
11411141 clocks = <&sys_clkin1>, <&sata_ref_clk>;
11421142 clock-names = "sysclk", "refclk";
1143+ syscon-pllreset = <&scm_conf 0x3fc>;
11431144 #phy-cells = <0>;
11441145 };
11451146
arch/arm/boot/dts/exynos3250.dtsi+1−1
@@ -138,8 +138,8 @@ · 137 unmodified lines
138138
139139 mipi_phy: video-phy@10020710 {
140140 compatible = "samsung,s5pv210-mipi-video-phy";
141− reg = <0x10020710 8>;
142141 #phy-cells = <1>;
142+ syscon = <&pmu_system_controller>;
143143 };
144144
145145 pd_cam: cam-power-domain@10023C00 {
arch/arm/boot/dts/exynos4210-origen.dts+4−0
@@ -127,6 +127,10 @@ · 126 unmodified lines
127127 };
128128 };
129129
130+&cpu0 {
131+ cpu0-supply = <&buck1_reg>;
132+};
133+
130134 &fimd {
131135 pinctrl-0 = <&lcd_en &lcd_clk &lcd_data24 &pwm0_out>;
132136 pinctrl-names = "default";
arch/arm/boot/dts/exynos4210-trats.dts+4−0
@@ -188,6 +188,10 @@ · 187 unmodified lines
188188 };
189189 };
190190
191+&cpu0 {
192+ cpu0-supply = <&varm_breg>;
193+};
194+
191195 &dsi_0 {
192196 vddcore-supply = <&vusb_reg>;
193197 vddio-supply = <&vmipi_reg>;
arch/arm/boot/dts/exynos4210-universal_c210.dts+4−0
@@ -548,6 +548,10 @@ · 547 unmodified lines
548548 };
549549 };
550550
551+&cpu0 {
552+ cpu0-supply = <&vdd_arm_reg>;
553+};
554+
551555 &pinctrl_1 {
552556 hdmi_hpd: hdmi-hpd {
553557 samsung,pins = "gpx3-7";
arch/arm/boot/dts/exynos4210.dtsi+12−0
@@ -40,6 +40,18 @@ · 39 unmodified lines
4040 device_type = "cpu";
4141 compatible = "arm,cortex-a9";
4242 reg = <0x900>;
43+ clocks = <&clock CLK_ARM_CLK>;
44+ clock-names = "cpu";
45+ clock-latency = <160000>;
46+
47+ operating-points = <
48+ 1200000 1250000
49+ 1000000 1150000
50+ 800000 1075000
51+ 500000 975000
52+ 400000 975000
53+ 200000 950000
54+ >;
4355 cooling-min-level = <4>;
4456 cooling-max-level = <2>;
4557 #cooling-cells = <2>; /* min followed by max */
arch/arm/boot/dts/imx35.dtsi+4−4
@@ -286,8 +286,8 @@ · 285 unmodified lines
286286 can1: can@53fe4000 {
287287 compatible = "fsl,imx35-flexcan", "fsl,p1010-flexcan";
288288 reg = <0x53fe4000 0x1000>;
289− clocks = <&clks 33>;
290− clock-names = "ipg";
289+ clocks = <&clks 33>, <&clks 33>;
290+ clock-names = "ipg", "per";
291291 interrupts = <43>;
292292 status = "disabled";
293293 };
@@ -295,8 +295,8 @@ · 1 unmodified line
295295 can2: can@53fe8000 {
296296 compatible = "fsl,imx35-flexcan", "fsl,p1010-flexcan";
297297 reg = <0x53fe8000 0x1000>;
298− clocks = <&clks 34>;
299− clock-names = "ipg";
298+ clocks = <&clks 34>, <&clks 34>;
299+ clock-names = "ipg", "per";
300300 interrupts = <44>;
301301 status = "disabled";
302302 };
arch/arm/boot/dts/imx6qdl.dtsi+4−4
@@ -181,10 +181,10 @@ · 180 unmodified lines
181181 interrupt-names = "msi";
182182 #interrupt-cells = <1>;
183183 interrupt-map-mask = <0 0 0 0x7>;
184− interrupt-map = <0 0 0 1 &intc GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>,
185− <0 0 0 2 &intc GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
186− <0 0 0 3 &intc GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
187− <0 0 0 4 &intc GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;
184+ interrupt-map = <0 0 0 1 &gpc GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>,
185+ <0 0 0 2 &gpc GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
186+ <0 0 0 3 &gpc GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
187+ <0 0 0 4 &gpc GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;
188188 clocks = <&clks IMX6QDL_CLK_PCIE_AXI>,
189189 <&clks IMX6QDL_CLK_LVDS1_GATE>,
190190 <&clks IMX6QDL_CLK_PCIE_REF_125M>;
arch/arm/boot/dts/k2e-clocks.dtsi+2−3
@@ -13,9 +13,8 @@ clocks { · 12 unmodified lines
1313 #clock-cells = <0>;
1414 compatible = "ti,keystone,main-pll-clock";
1515 clocks = <&refclksys>;
16− reg = <0x02620350 4>, <0x02310110 4>;
17− reg-names = "control", "multiplier";
18− fixed-postdiv = <2>;
16+ reg = <0x02620350 4>, <0x02310110 4>, <0x02310108 4>;
17+ reg-names = "control", "multiplier", "post-divider";
1918 };
2019
2120 papllclk: papllclk@2620358 {
arch/arm/boot/dts/k2e.dtsi+11−4
@@ -131,10 +131,17 @@ · 130 unmodified lines
131131 <GIC_SPI 376 IRQ_TYPE_EDGE_RISING>;
132132 };
133133 };
134+
135+ mdio: mdio@24200f00 {
136+ compatible = "ti,keystone_mdio", "ti,davinci_mdio";
137+ #address-cells = <1>;
138+ #size-cells = <0>;
139+ reg = <0x24200f00 0x100>;
140+ status = "disabled";
141+ clocks = <&clkcpgmac>;
142+ clock-names = "fck";
143+ bus_freq = <2500000>;
144+ };
134145 /include/ "k2e-netcp.dtsi"
135146 };
136147 };
137−
138−&mdio {
139− reg = <0x24200f00 0x100>;
140−};
arch/arm/boot/dts/k2hk-clocks.dtsi+2−3
@@ -22,9 +22,8 @@ clocks { · 21 unmodified lines
2222 #clock-cells = <0>;
2323 compatible = "ti,keystone,main-pll-clock";
2424 clocks = <&refclksys>;
25− reg = <0x02620350 4>, <0x02310110 4>;
26− reg-names = "control", "multiplier";
27− fixed-postdiv = <2>;
25+ reg = <0x02620350 4>, <0x02310110 4>, <0x02310108 4>;
26+ reg-names = "control", "multiplier", "post-divider";
2827 };
2928
3029 papllclk: papllclk@2620358 {
arch/arm/boot/dts/k2hk.dtsi+11−0
@@ -98,6 +98,17 @@ · 97 unmodified lines
9898 #gpio-cells = <2>;
9999 gpio,syscon-dev = <&devctrl 0x25c>;
100100 };
101+
102+ mdio: mdio@02090300 {
103+ compatible = "ti,keystone_mdio", "ti,davinci_mdio";
104+ #address-cells = <1>;
105+ #size-cells = <0>;
106+ reg = <0x02090300 0x100>;
107+ status = "disabled";
108+ clocks = <&clkcpgmac>;
109+ clock-names = "fck";
110+ bus_freq = <2500000>;
111+ };
101112 /include/ "k2hk-netcp.dtsi"
102113 };
103114 };
arch/arm/boot/dts/k2l-clocks.dtsi+2−3
@@ -22,9 +22,8 @@ clocks { · 21 unmodified lines
2222 #clock-cells = <0>;
2323 compatible = "ti,keystone,main-pll-clock";
2424 clocks = <&refclksys>;
25− reg = <0x02620350 4>, <0x02310110 4>;
26− reg-names = "control", "multiplier";
27− fixed-postdiv = <2>;
25+ reg = <0x02620350 4>, <0x02310110 4>, <0x02310108 4>;
26+ reg-names = "control", "multiplier", "post-divider";
2827 };
2928
3029 papllclk: papllclk@2620358 {
arch/arm/boot/dts/k2l.dtsi+11−5
@@ -29,7 +29,6 @@ · 28 unmodified lines
2929 };
3030
3131 soc {
32−
3332 /include/ "k2l-clocks.dtsi"
3433
3534 uart2: serial@02348400 {
@@ -79,6 +78,17 @@ · 43 unmodified lines
7978 #gpio-cells = <2>;
8079 gpio,syscon-dev = <&devctrl 0x24c>;
8180 };
81+
82+ mdio: mdio@26200f00 {
83+ compatible = "ti,keystone_mdio", "ti,davinci_mdio";
84+ #address-cells = <1>;
85+ #size-cells = <0>;
86+ reg = <0x26200f00 0x100>;
87+ status = "disabled";
88+ clocks = <&clkcpgmac>;
89+ clock-names = "fck";
90+ bus_freq = <2500000>;
91+ };
8292 /include/ "k2l-netcp.dtsi"
8393 };
8494 };
@@ -96,7 +106,3 @@ · 11 unmodified lines
96106 /* Pin muxed. Enabled and configured by Bootloader */
97107 status = "disabled";
98108 };
99−
100−&mdio {
101− reg = <0x26200f00 0x100>;
102−};
arch/arm/boot/dts/keystone.dtsi+0−11
@@ -267,17 +267,6 @@ · 266 unmodified lines
267267 1 0 0x21000A00 0x00000100>;
268268 };
269269
270− mdio: mdio@02090300 {
271− compatible = "ti,keystone_mdio", "ti,davinci_mdio";
272− #address-cells = <1>;
273− #size-cells = <0>;
274− reg = <0x02090300 0x100>;
275− status = "disabled";
276− clocks = <&clkpa>;
277− clock-names = "fck";
278− bus_freq = <2500000>;
279− };
280−
281270 kirq0: keystone_irq@26202a0 {
282271 compatible = "ti,keystone-irq";
283272 interrupts = <GIC_SPI 4 IRQ_TYPE_EDGE_RISING>;
arch/arm/boot/dts/omap2430.dtsi+2−1
@@ -51,7 +51,8 @@ · 50 unmodified lines
5151 };
5252
5353 scm_conf: scm_conf@270 {
54− compatible = "syscon";
54+ compatible = "syscon",
55+ "simple-bus";
5556 reg = <0x270 0x240>;
5657 #address-cells = <1>;
5758 #size-cells = <1>;
arch/arm/boot/dts/omap4.dtsi+2−1
@@ -191,7 +191,8 @@ · 190 unmodified lines
191191 };
192192
193193 omap4_padconf_global: omap4_padconf_global@5a0 {
194− compatible = "syscon";
194+ compatible = "syscon",
195+ "simple-bus";
195196 reg = <0x5a0 0x170>;
196197 #address-cells = <1>;
197198 #size-cells = <1>;
arch/arm/boot/dts/omap5.dtsi+2−1
@@ -180,7 +180,8 @@ · 179 unmodified lines
180180 };
181181
182182 omap5_padconf_global: omap5_padconf_global@5a0 {
183− compatible = "syscon";
183+ compatible = "syscon",
184+ "simple-bus";
184185 reg = <0x5a0 0xec>;
185186 #address-cells = <1>;
186187 #size-cells = <1>;
arch/arm/boot/dts/ste-dbx5x0.dtsi+27−26
@@ -15,6 +15,33 @@ · 14 unmodified lines
1515 #include "skeleton.dtsi"
1616
1717 / {
18+ cpus {
19+ #address-cells = <1>;
20+ #size-cells = <0>;
21+ enable-method = "ste,dbx500-smp";
22+
23+ cpu-map {
24+ cluster0 {
25+ core0 {
26+ cpu = <&CPU0>;
27+ };
28+ core1 {
29+ cpu = <&CPU1>;
30+ };
31+ };
32+ };
33+ CPU0: cpu@300 {
34+ device_type = "cpu";
35+ compatible = "arm,cortex-a9";
36+ reg = <0x300>;
37+ };
38+ CPU1: cpu@301 {
39+ device_type = "cpu";
40+ compatible = "arm,cortex-a9";
41+ reg = <0x301>;
42+ };
43+ };
44+
1845 soc {
1946 #address-cells = <1>;
2047 #size-cells = <1>;
@@ -22,32 +49,6 @@ · 1 unmodified line
2249 interrupt-parent = <&intc>;
2350 ranges;
2451
25− cpus {
26− #address-cells = <1>;
27− #size-cells = <0>;
28−
29− cpu-map {
30− cluster0 {
31− core0 {
32− cpu = <&CPU0>;
33− };
34− core1 {
35− cpu = <&CPU1>;
36− };
37− };
38− };
39− CPU0: cpu@0 {
40− device_type = "cpu";
41− compatible = "arm,cortex-a9";
42− reg = <0>;
43− };
44− CPU1: cpu@1 {
45− device_type = "cpu";
46− compatible = "arm,cortex-a9";
47− reg = <1>;
48− };
49− };
50−
5152 ptm@801ae000 {
5253 compatible = "arm,coresight-etm3x", "arm,primecell";
5354 reg = <0x801ae000 0x1000>;
arch/arm/boot/dts/ste-nomadik-nhk15.dts+1−0
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717 };
1818
1919 aliases {
20+ serial1 = &uart1;
2021 stmpe-i2c0 = &stmpe0;
2122 stmpe-i2c1 = &stmpe1;
2223 };
arch/arm/boot/dts/ste-nomadik-s8815.dts+4−0
@@ -15,6 +15,10 @@ · 14 unmodified lines
1515 bootargs = "root=/dev/ram0 console=ttyAMA1,115200n8 earlyprintk";
1616 };
1717
18+ aliases {
19+ serial1 = &uart1;
20+ };
21+
1822 src@101e0000 {
1923 /* These chrystal drivers are not used on this board */
2024 disable-sxtalo;
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi+1−0
@@ -757,6 +757,7 @@ · 756 unmodified lines
757757 clock-names = "uartclk", "apb_pclk";
758758 pinctrl-names = "default";
759759 pinctrl-0 = <&uart0_default_mux>;
760+ status = "disabled";
760761 };
761762
762763 uart1: uart@101fb000 {
arch/arm/kernel/entry-common.S+1−0
@@ -61,6 +61,7 @@ work_pending: · 60 unmodified lines
6161 movlt scno, #(__NR_restart_syscall - __NR_SYSCALL_BASE)
6262 ldmia sp, {r0 - r6} @ have to reload r0 - r6
6363 b local_restart @ ... and off we go
64+ENDPROC(ret_fast_syscall)
6465
6566 /*
6667 * "slow" syscall return path. "why" tells us if this was a real syscall.
arch/arm/kernel/head.S+3−0
@@ -399,6 +399,9 @@ ENTRY(secondary_startup) · 398 unmodified lines
399399 sub lr, r4, r5 @ mmu has been enabled
400400 add r3, r7, lr
401401 ldrd r4, [r3, #0] @ get secondary_data.pgdir
402+ARM_BE8(eor r4, r4, r5) @ Swap r5 and r4 in BE:
403+ARM_BE8(eor r5, r4, r5) @ it can be done in 3 steps
404+ARM_BE8(eor r4, r4, r5) @ without using a temp reg.
402405 ldr r8, [r3, #8] @ get secondary_data.swapper_pg_dir
403406 badr lr, __enable_mmu @ return address
404407 mov r13, r12 @ __secondary_switched address
arch/arm/kernel/vdso.c+3−4
@@ -296,7 +296,6 @@ static bool tk_is_cntvct(const struct timekeeper *tk) · 295 unmodified lines
296296 */
297297 void update_vsyscall(struct timekeeper *tk)
298298 {
299− struct timespec xtime_coarse;
300299 struct timespec64 *wtm = &tk->wall_to_monotonic;
301300
302301 if (!cntvct_ok) {
@@ -308,10 +307,10 @@ void update_vsyscall(struct timekeeper *tk) · 5 unmodified lines
308307
309308 vdso_write_begin(vdso_data);
310309
311− xtime_coarse = __current_kernel_time();
312310 vdso_data->tk_is_cntvct = tk_is_cntvct(tk);
313− vdso_data->xtime_coarse_sec = xtime_coarse.tv_sec;
314− vdso_data->xtime_coarse_nsec = xtime_coarse.tv_nsec;
311+ vdso_data->xtime_coarse_sec = tk->xtime_sec;
312+ vdso_data->xtime_coarse_nsec = (u32)(tk->tkr_mono.xtime_nsec >>
313+ tk->tkr_mono.shift);
315314 vdso_data->wtm_clock_sec = wtm->tv_sec;
316315 vdso_data->wtm_clock_nsec = wtm->tv_nsec;
317316
arch/arm/mach-exynos/pm_domains.c+1−2
@@ -146,9 +146,8 @@ static __init int exynos4_pm_init_power_domain(void) · 145 unmodified lines
146146 pd->base = of_iomap(np, 0);
147147 if (!pd->base) {
148148 pr_warn("%s: failed to map memory\n", __func__);
149− kfree(pd->pd.name);
149+ kfree_const(pd->pd.name);
150150 kfree(pd);
151− of_node_put(np);
152151 continue;
153152 }
154153
arch/arm/mach-omap2/omap_hwmod.c+16−8
@@ -2373,6 +2373,9 @@ static int of_dev_hwmod_lookup(struct device_node *np, · 2372 unmodified lines
23732373 * registers. This address is needed early so the OCP registers that
23742374 * are part of the device's address space can be ioremapped properly.
23752375 *
2376+ * If SYSC access is not needed, the registers will not be remapped
2377+ * and non-availability of MPU access is not treated as an error.
2378+ *
23762379 * Returns 0 on success, -EINVAL if an invalid hwmod is passed, and
23772380 * -ENXIO on absent or invalid register target address space.
23782381 */
@@ -2387,6 +2390,11 @@ static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data, · 8 unmodified lines
23872390
23882391 _save_mpu_port_index(oh);
23892392
2393+ /* if we don't need sysc access we don't need to ioremap */
2394+ if (!oh->class->sysc)
2395+ return 0;
2396+
2397+ /* we can't continue without MPU PORT if we need sysc access */
23902398 if (oh->_int_flags & _HWMOD_NO_MPU_PORT)
23912399 return -ENXIO;
23922400
@@ -2396,8 +2404,10 @@ static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data, · 3 unmodified lines
23962404 oh->name);
23972405
23982406 /* Extract the IO space from device tree blob */
2399− if (!np)
2407+ if (!np) {
2408+ pr_err("omap_hwmod: %s: no dt node\n", oh->name);
24002409 return -ENXIO;
2410+ }
24012411
24022412 va_start = of_iomap(np, index + oh->mpu_rt_idx);
24032413 } else {
@@ -2456,13 +2466,11 @@ static int __init _init(struct omap_hwmod *oh, void *data) · 52 unmodified lines
24562466 oh->name, np->name);
24572467 }
24582468
2459− if (oh->class->sysc) {
2460− r = _init_mpu_rt_base(oh, NULL, index, np);
2461− if (r < 0) {
2462− WARN(1, "omap_hwmod: %s: doesn't have mpu register target base\n",
2463− oh->name);
2464− return 0;
2465− }
2469+ r = _init_mpu_rt_base(oh, NULL, index, np);
2470+ if (r < 0) {
2471+ WARN(1, "omap_hwmod: %s: doesn't have mpu register target base\n",
2472+ oh->name);
2473+ return 0;
24662474 }
24672475
24682476 r = _init_clocks(oh, NULL);
arch/arm/mach-omap2/omap_hwmod_7xx_data.c+2−3
@@ -827,8 +827,7 @@ static struct omap_hwmod_class_sysconfig dra7xx_gpmc_sysc = { · 826 unmodified lines
827827 .syss_offs = 0x0014,
828828 .sysc_flags = (SYSC_HAS_AUTOIDLE | SYSC_HAS_SIDLEMODE |
829829 SYSC_HAS_SOFTRESET | SYSS_HAS_RESET_STATUS),
830− .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
831− SIDLE_SMART_WKUP),
830+ .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
832831 .sysc_fields = &omap_hwmod_sysc_type1,
833832 };
834833
@@ -844,7 +843,7 @@ static struct omap_hwmod dra7xx_gpmc_hwmod = { · 9 unmodified lines
844843 .class = &dra7xx_gpmc_hwmod_class,
845844 .clkdm_name = "l3main1_clkdm",
846845 /* Skip reset for CONFIG_OMAP_GPMC_DEBUG for bootloader timings */
847− .flags = HWMOD_SWSUP_SIDLE | DEBUG_OMAP_GPMC_HWMOD_FLAGS,
846+ .flags = DEBUG_OMAP_GPMC_HWMOD_FLAGS,
848847 .main_clk = "l3_iclk_div",
849848 .prcm = {
850849 .omap4 = {
arch/arm/vdso/Makefile+1−1
@@ -14,7 +14,7 @@ VDSO_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 · 13 unmodified lines
1414 VDSO_LDFLAGS += -nostdlib -shared
1515 VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
1616 VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--build-id)
17−VDSO_LDFLAGS += $(call cc-option, -fuse-ld=bfd)
17+VDSO_LDFLAGS += $(call cc-ldoption, -fuse-ld=bfd)
1818
1919 obj-$(CONFIG_VDSO) += vdso.o
2020 extra-$(CONFIG_VDSO) += vdso.lds
arch/arm64/boot/dts/apm/apm-storm.dtsi+1−1
@@ -823,7 +823,7 @@ · 822 unmodified lines
823823 device_type = "dma";
824824 reg = <0x0 0x1f270000 0x0 0x10000>,
825825 <0x0 0x1f200000 0x0 0x10000>,
826− <0x0 0x1b008000 0x0 0x2000>,
826+ <0x0 0x1b000000 0x0 0x400000>,
827827 <0x0 0x1054a000 0x0 0x100>;
828828 interrupts = <0x0 0x82 0x4>,
829829 <0x0 0xb8 0x4>,
arch/arm64/kernel/efi.c+2−2
@@ -122,12 +122,12 @@ static int __init uefi_init(void) · 121 unmodified lines
122122
123123 /* Show what we know for posterity */
124124 c16 = early_memremap(efi_to_phys(efi.systab->fw_vendor),
125− sizeof(vendor));
125+ sizeof(vendor) * sizeof(efi_char16_t));
126126 if (c16) {
127127 for (i = 0; i < (int) sizeof(vendor) - 1 && *c16; ++i)
128128 vendor[i] = c16[i];
129129 vendor[i] = '\0';
130− early_memunmap(c16, sizeof(vendor));
130+ early_memunmap(c16, sizeof(vendor) * sizeof(efi_char16_t));
131131 }
132132
133133 pr_info("EFI v%u.%.02u by %s\n",
arch/arm64/kernel/signal32.c+2−3
@@ -168,7 +168,8 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from) · 167 unmodified lines
168168 * Other callers might not initialize the si_lsb field,
169169 * so check explicitely for the right codes here.
170170 */
171− if (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO)
171+ if (from->si_signo == SIGBUS &&
172+ (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO))
172173 err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb);
173174 #endif
174175 break;
@@ -201,8 +202,6 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from) · 26 unmodified lines
201202
202203 int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
203204 {
204− memset(to, 0, sizeof *to);
205−
206205 if (copy_from_user(to, from, __ARCH_SI_PREAMBLE_SIZE) ||
207206 copy_from_user(to->_sifields._pad,
208207 from->_sifields._pad, SI_PAD_SIZE))
arch/arm64/kernel/vdso.c+3−4
@@ -199,16 +199,15 @@ up_fail: · 198 unmodified lines
199199 */
200200 void update_vsyscall(struct timekeeper *tk)
201201 {
202− struct timespec xtime_coarse;
203202 u32 use_syscall = strcmp(tk->tkr_mono.clock->name, "arch_sys_counter");
204203
205204 ++vdso_data->tb_seq_count;
206205 smp_wmb();
207206
208− xtime_coarse = __current_kernel_time();
209207 vdso_data->use_syscall = use_syscall;
210− vdso_data->xtime_coarse_sec = xtime_coarse.tv_sec;
211− vdso_data->xtime_coarse_nsec = xtime_coarse.tv_nsec;
208+ vdso_data->xtime_coarse_sec = tk->xtime_sec;
209+ vdso_data->xtime_coarse_nsec = tk->tkr_mono.xtime_nsec >>
210+ tk->tkr_mono.shift;
212211 vdso_data->wtm_clock_sec = tk->wall_to_monotonic.tv_sec;
213212 vdso_data->wtm_clock_nsec = tk->wall_to_monotonic.tv_nsec;
214213
arch/avr32/mach-at32ap/clock.c+19−1
@@ -80,6 +80,9 @@ int clk_enable(struct clk *clk) · 79 unmodified lines
8080 {
8181 unsigned long flags;
8282
83+ if (!clk)
84+ return 0;
85+
8386 spin_lock_irqsave(&clk_lock, flags);
8487 __clk_enable(clk);
8588 spin_unlock_irqrestore(&clk_lock, flags);
@@ -106,6 +109,9 @@ void clk_disable(struct clk *clk) · 20 unmodified lines
106109 {
107110 unsigned long flags;
108111
112+ if (IS_ERR_OR_NULL(clk))
113+ return;
114+
109115 spin_lock_irqsave(&clk_lock, flags);
110116 __clk_disable(clk);
111117 spin_unlock_irqrestore(&clk_lock, flags);
@@ -117,6 +123,9 @@ unsigned long clk_get_rate(struct clk *clk) · 5 unmodified lines
117123 unsigned long flags;
118124 unsigned long rate;
119125
126+ if (!clk)
127+ return 0;
128+
120129 spin_lock_irqsave(&clk_lock, flags);
121130 rate = clk->get_rate(clk);
122131 spin_unlock_irqrestore(&clk_lock, flags);
@@ -129,6 +138,9 @@ long clk_round_rate(struct clk *clk, unsigned long rate) · 6 unmodified lines
129138 {
130139 unsigned long flags, actual_rate;
131140
141+ if (!clk)
142+ return 0;
143+
132144 if (!clk->set_rate)
133145 return -ENOSYS;
134146
@@ -145,6 +157,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate) · 10 unmodified lines
145157 unsigned long flags;
146158 long ret;
147159
160+ if (!clk)
161+ return 0;
162+
148163 if (!clk->set_rate)
149164 return -ENOSYS;
150165
@@ -161,6 +176,9 @@ int clk_set_parent(struct clk *clk, struct clk *parent) · 10 unmodified lines
161176 unsigned long flags;
162177 int ret;
163178
179+ if (!clk)
180+ return 0;
181+
164182 if (!clk->set_parent)
165183 return -ENOSYS;
166184
@@ -174,7 +192,7 @@ EXPORT_SYMBOL(clk_set_parent); · 7 unmodified lines
174192
175193 struct clk *clk_get_parent(struct clk *clk)
176194 {
177− return clk->parent;
195+ return !clk ? NULL : clk->parent;
178196 }
179197 EXPORT_SYMBOL(clk_get_parent);
180198
arch/mips/Kconfig+0−1
@@ -151,7 +151,6 @@ config BMIPS_GENERIC · 150 unmodified lines
151151 select BCM7120_L2_IRQ
152152 select BRCMSTB_L2_IRQ
153153 select IRQ_MIPS_CPU
154− select RAW_IRQ_ACCESSORS
155154 select DMA_NONCOHERENT
156155 select SYS_SUPPORTS_32BIT_KERNEL
157156 select SYS_SUPPORTS_LITTLE_ENDIAN
arch/mips/ath79/setup.c+1−0
@@ -190,6 +190,7 @@ int get_c0_perfcount_int(void) · 189 unmodified lines
190190 {
191191 return ATH79_MISC_IRQ(5);
192192 }
193+EXPORT_SYMBOL_GPL(get_c0_perfcount_int);
193194
194195 unsigned int get_c0_compare_int(void)
195196 {
arch/mips/cavium-octeon/smp.c+1−1
@@ -42,7 +42,7 @@ static irqreturn_t mailbox_interrupt(int irq, void *dev_id) · 41 unmodified lines
4242 cvmx_write_csr(CVMX_CIU_MBOX_CLRX(coreid), action);
4343
4444 if (action & SMP_CALL_FUNCTION)
45− smp_call_function_interrupt();
45+ generic_smp_call_function_interrupt();
4646 if (action & SMP_RESCHEDULE_YOURSELF)
4747 scheduler_ipi();
4848
arch/mips/include/asm/mach-bcm63xx/dma-coherence.h+0−10
@@ -1,10 +0,0 @@
1−#ifndef __ASM_MACH_BCM63XX_DMA_COHERENCE_H
2−#define __ASM_MACH_BCM63XX_DMA_COHERENCE_H
3−
4−#include <asm/bmips.h>
5−
6−#define plat_post_dma_flush bmips_post_dma_flush
7−
8−#include <asm/mach-generic/dma-coherence.h>
9−
10−#endif /* __ASM_MACH_BCM63XX_DMA_COHERENCE_H */
arch/mips/include/asm/pgtable.h+31−0
@@ -182,8 +182,39 @@ static inline void set_pte(pte_t *ptep, pte_t pteval) · 181 unmodified lines
182182 * Make sure the buddy is global too (if it's !none,
183183 * it better already be global)
184184 */
185+#ifdef CONFIG_SMP
186+ /*
187+ * For SMP, multiple CPUs can race, so we need to do
188+ * this atomically.
189+ */
190+#ifdef CONFIG_64BIT
191+#define LL_INSN "lld"
192+#define SC_INSN "scd"
193+#else /* CONFIG_32BIT */
194+#define LL_INSN "ll"
195+#define SC_INSN "sc"
196+#endif
197+ unsigned long page_global = _PAGE_GLOBAL;
198+ unsigned long tmp;
199+
200+ __asm__ __volatile__ (
201+ " .set push\n"
202+ " .set noreorder\n"
203+ "1: " LL_INSN " %[tmp], %[buddy]\n"
204+ " bnez %[tmp], 2f\n"
205+ " or %[tmp], %[tmp], %[global]\n"
206+ " " SC_INSN " %[tmp], %[buddy]\n"
207+ " beqz %[tmp], 1b\n"
208+ " nop\n"
209+ "2:\n"
210+ " .set pop"
211+ : [buddy] "+m" (buddy->pte),
212+ [tmp] "=&r" (tmp)
213+ : [global] "r" (page_global));
214+#else /* !CONFIG_SMP */
185215 if (pte_none(*buddy))
186216 pte_val(*buddy) = pte_val(*buddy) | _PAGE_GLOBAL;
217+#endif /* CONFIG_SMP */
187218 }
188219 #endif
189220 }
arch/mips/include/asm/smp.h+0−2
@@ -83,8 +83,6 @@ static inline void __cpu_die(unsigned int cpu) · 82 unmodified lines
8383 extern void play_dead(void);
8484 #endif
8585
86−extern asmlinkage void smp_call_function_interrupt(void);
87−
8886 static inline void arch_send_call_function_single_ipi(int cpu)
8987 {
9088 extern struct plat_smp_ops *mp_ops; /* private */
arch/mips/include/asm/stackframe.h+25−0
@@ -152,6 +152,31 @@ · 151 unmodified lines
152152 .set noreorder
153153 bltz k0, 8f
154154 move k1, sp
155+#ifdef CONFIG_EVA
156+ /*
157+ * Flush interAptiv's Return Prediction Stack (RPS) by writing
158+ * EntryHi. Toggling Config7.RPS is slower and less portable.
159+ *
160+ * The RPS isn't automatically flushed when exceptions are
161+ * taken, which can result in kernel mode speculative accesses
162+ * to user addresses if the RPS mispredicts. That's harmless
163+ * when user and kernel share the same address space, but with
164+ * EVA the same user segments may be unmapped to kernel mode,
165+ * even containing sensitive MMIO regions or invalid memory.
166+ *
167+ * This can happen when the kernel sets the return address to
168+ * ret_from_* and jr's to the exception handler, which looks
169+ * more like a tail call than a function call. If nested calls
170+ * don't evict the last user address in the RPS, it will
171+ * mispredict the return and fetch from a user controlled
172+ * address into the icache.
173+ *
174+ * More recent EVA-capable cores with MAAR to restrict
175+ * speculative accesses aren't affected.
176+ */
177+ MFC0 k0, CP0_ENTRYHI
178+ MTC0 k0, CP0_ENTRYHI
179+#endif
155180 .set reorder
156181 /* Called from user mode, new stack. */
157182 get_saved_sp
arch/mips/kernel/mips-mt-fpaff.c+3−2
@@ -154,7 +154,7 @@ asmlinkage long mipsmt_sys_sched_getaffinity(pid_t pid, unsigned int len, · 153 unmodified lines
154154 unsigned long __user *user_mask_ptr)
155155 {
156156 unsigned int real_len;
157− cpumask_t mask;
157+ cpumask_t allowed, mask;
158158 int retval;
159159 struct task_struct *p;
160160
@@ -173,7 +173,8 @@ asmlinkage long mipsmt_sys_sched_getaffinity(pid_t pid, unsigned int len, · 12 unmodified lines
173173 if (retval)
174174 goto out_unlock;
175175
176− cpumask_and(&mask, &p->thread.user_cpus_allowed, cpu_possible_mask);
176+ cpumask_or(&allowed, &p->thread.user_cpus_allowed, &p->cpus_allowed);
177+ cpumask_and(&mask, &allowed, cpu_active_mask);
177178
178179 out_unlock:
179180 read_unlock(&tasklist_lock);
arch/mips/kernel/prom.c+1−1
@@ -38,7 +38,7 @@ char *mips_get_machine_name(void) · 37 unmodified lines
3838 return mips_machine_name;
3939 }
4040
41−#ifdef CONFIG_OF
41+#ifdef CONFIG_USE_OF
4242 void __init early_init_dt_add_memory_arch(u64 base, u64 size)
4343 {
4444 return add_memory_region(base, size, BOOT_MEM_RAM);
arch/mips/kernel/relocate_kernel.S+4−4
@@ -24,7 +24,7 @@ LEAF(relocate_new_kernel) · 23 unmodified lines
2424
2525 process_entry:
2626 PTR_L s2, (s0)
27− PTR_ADD s0, s0, SZREG
27+ PTR_ADDIU s0, s0, SZREG
2828
2929 /*
3030 * In case of a kdump/crash kernel, the indirection page is not
@@ -61,9 +61,9 @@ copy_word: · 30 unmodified lines
6161 /* copy page word by word */
6262 REG_L s5, (s2)
6363 REG_S s5, (s4)
64− PTR_ADD s4, s4, SZREG
65− PTR_ADD s2, s2, SZREG
66− LONG_SUB s6, s6, 1
64+ PTR_ADDIU s4, s4, SZREG
65+ PTR_ADDIU s2, s2, SZREG
66+ LONG_ADDIU s6, s6, -1
6767 beq s6, zero, process_entry
6868 b copy_word
6969 b process_entry
arch/mips/kernel/scall64-64.S+1−1
@@ -80,7 +80,7 @@ syscall_trace_entry: · 79 unmodified lines
8080 SAVE_STATIC
8181 move s0, t2
8282 move a0, sp
83− daddiu a1, v0, __NR_64_Linux
83+ move a1, v0
8484 jal syscall_trace_enter
8585
8686 bltz v0, 2f # seccomp failed? Skip syscall
arch/mips/kernel/scall64-n32.S+1−1
@@ -72,7 +72,7 @@ n32_syscall_trace_entry: · 71 unmodified lines
7272 SAVE_STATIC
7373 move s0, t2
7474 move a0, sp
75− daddiu a1, v0, __NR_N32_Linux
75+ move a1, v0
7676 jal syscall_trace_enter
7777
7878 bltz v0, 2f # seccomp failed? Skip syscall
arch/mips/kernel/signal32.c+0−2
@@ -409,8 +409,6 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from) · 408 unmodified lines
409409
410410 int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
411411 {
412− memset(to, 0, sizeof *to);
413−
414412 if (copy_from_user(to, from, 3*sizeof(int)) ||
415413 copy_from_user(to->_sifields._pad,
416414 from->_sifields._pad, SI_PAD_SIZE32))
arch/mips/kernel/smp-bmips.c+2−2
@@ -284,7 +284,7 @@ static irqreturn_t bmips5000_ipi_interrupt(int irq, void *dev_id) · 283 unmodified lines
284284 if (action == 0)
285285 scheduler_ipi();
286286 else
287− smp_call_function_interrupt();
287+ generic_smp_call_function_interrupt();
288288
289289 return IRQ_HANDLED;
290290 }
@@ -336,7 +336,7 @@ static irqreturn_t bmips43xx_ipi_interrupt(int irq, void *dev_id) · 45 unmodified lines
336336 if (action & SMP_RESCHEDULE_YOURSELF)
337337 scheduler_ipi();
338338 if (action & SMP_CALL_FUNCTION)
339− smp_call_function_interrupt();
339+ generic_smp_call_function_interrupt();
340340
341341 return IRQ_HANDLED;
342342 }
arch/mips/kernel/smp.c+0−10
@@ -192,16 +192,6 @@ asmlinkage void start_secondary(void) · 191 unmodified lines
192192 cpu_startup_entry(CPUHP_ONLINE);
193193 }
194194
195−/*
196− * Call into both interrupt handlers, as we share the IPI for them
197− */
198−void __irq_entry smp_call_function_interrupt(void)
199−{
200− irq_enter();
201− generic_smp_call_function_interrupt();
202− irq_exit();
203−}
204−
205195 static void stop_this_cpu(void *dummy)
206196 {
207197 /*
arch/mips/kernel/traps.c+13−0
@@ -192,6 +192,7 @@ static void show_stacktrace(struct task_struct *task, · 191 unmodified lines
192192 void show_stack(struct task_struct *task, unsigned long *sp)
193193 {
194194 struct pt_regs regs;
195+ mm_segment_t old_fs = get_fs();
195196 if (sp) {
196197 regs.regs[29] = (unsigned long)sp;
197198 regs.regs[31] = 0;
@@ -210,7 +211,13 @@ void show_stack(struct task_struct *task, unsigned long *sp) · 12 unmodified lines
210211 prepare_frametrace(&regs);
211212 }
212213 }
214+ /*
215+ * show_stack() deals exclusively with kernel mode, so be sure to access
216+ * the stack in the kernel (not user) address space.
217+ */
218+ set_fs(KERNEL_DS);
213219 show_stacktrace(task, &regs);
220+ set_fs(old_fs);
214221 }
215222
216223 static void show_code(unsigned int __user *pc)
@@ -1519,6 +1526,7 @@ asmlinkage void do_mcheck(struct pt_regs *regs) · 1302 unmodified lines
15191526 const int field = 2 * sizeof(unsigned long);
15201527 int multi_match = regs->cp0_status & ST0_TS;
15211528 enum ctx_state prev_state;
1529+ mm_segment_t old_fs = get_fs();
15221530
15231531 prev_state = exception_enter();
15241532 show_regs(regs);
@@ -1540,8 +1548,13 @@ asmlinkage void do_mcheck(struct pt_regs *regs) · 15 unmodified lines
15401548 dump_tlb_all();
15411549 }
15421550
1551+ if (!user_mode(regs))
1552+ set_fs(KERNEL_DS);
1553+
15431554 show_code((unsigned int __user *) regs->cp0_epc);
15441555
1556+ set_fs(old_fs);
1557+
15451558 /*
15461559 * Some chips may have other causes of machine check (e.g. SB1
15471560 * graduation timer)
arch/mips/kernel/unaligned.c+1−1
@@ -438,7 +438,7 @@ do { \ · 437 unmodified lines
438438 : "memory"); \
439439 } while(0)
440440
441−#define StoreDW(addr, value, res) \
441+#define _StoreDW(addr, value, res) \
442442 do { \
443443 __asm__ __volatile__ ( \
444444 ".set\tpush\n\t" \
arch/mips/lantiq/irq.c+2−1
@@ -293,7 +293,7 @@ static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id) · 292 unmodified lines
293293
294294 static irqreturn_t ipi_call_interrupt(int irq, void *dev_id)
295295 {
296− smp_call_function_interrupt();
296+ generic_smp_call_function_interrupt();
297297 return IRQ_HANDLED;
298298 }
299299
@@ -466,6 +466,7 @@ int get_c0_perfcount_int(void) · 166 unmodified lines
466466 {
467467 return ltq_perfcount_irq;
468468 }
469+EXPORT_SYMBOL_GPL(get_c0_perfcount_int);
469470
470471 unsigned int get_c0_compare_int(void)
471472 {
arch/mips/loongson64/loongson-3/smp.c+5−2
@@ -266,8 +266,11 @@ void loongson3_ipi_interrupt(struct pt_regs *regs) · 265 unmodified lines
266266 if (action & SMP_RESCHEDULE_YOURSELF)
267267 scheduler_ipi();
268268
269− if (action & SMP_CALL_FUNCTION)
270− smp_call_function_interrupt();
269+ if (action & SMP_CALL_FUNCTION) {
270+ irq_enter();
271+ generic_smp_call_function_interrupt();
272+ irq_exit();
273+ }
271274
272275 if (action & SMP_ASK_C0COUNT) {
273276 BUG_ON(cpu != 0);
arch/mips/mm/cache.c+4−4
@@ -160,18 +160,18 @@ static inline void setup_protection_map(void) · 159 unmodified lines
160160 protection_map[1] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC);
161161 protection_map[2] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ);
162162 protection_map[3] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC);
163− protection_map[4] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_READ);
163+ protection_map[4] = __pgprot(_page_cachable_default | _PAGE_PRESENT);
164164 protection_map[5] = __pgprot(_page_cachable_default | _PAGE_PRESENT);
165− protection_map[6] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_READ);
165+ protection_map[6] = __pgprot(_page_cachable_default | _PAGE_PRESENT);
166166 protection_map[7] = __pgprot(_page_cachable_default | _PAGE_PRESENT);
167167
168168 protection_map[8] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ);
169169 protection_map[9] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC);
170170 protection_map[10] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE | _PAGE_NO_READ);
171171 protection_map[11] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE);
172− protection_map[12] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_READ);
172+ protection_map[12] = __pgprot(_page_cachable_default | _PAGE_PRESENT);
173173 protection_map[13] = __pgprot(_page_cachable_default | _PAGE_PRESENT);
174− protection_map[14] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_WRITE | _PAGE_NO_READ);
174+ protection_map[14] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_WRITE);
175175 protection_map[15] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_WRITE);
176176
177177 } else {
arch/mips/mm/fault.c+2−1
@@ -133,7 +133,8 @@ good_area: · 132 unmodified lines
133133 #endif
134134 goto bad_area;
135135 }
136− if (!(vma->vm_flags & VM_READ)) {
136+ if (!(vma->vm_flags & VM_READ) &&
137+ exception_epc(regs) != address) {
137138 #if 0
138139 pr_notice("Cpu%d[%s:%d:%0*lx:%ld:%0*lx] RI violation\n",
139140 raw_smp_processor_id(),
arch/mips/mti-malta/malta-int.c+1−1
@@ -222,7 +222,7 @@ static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id) · 221 unmodified lines
222222
223223 static irqreturn_t ipi_call_interrupt(int irq, void *dev_id)
224224 {
225− smp_call_function_interrupt();
225+ generic_smp_call_function_interrupt();
226226
227227 return IRQ_HANDLED;
228228 }
arch/mips/mti-malta/malta-time.c+10−6
@@ -154,6 +154,7 @@ int get_c0_perfcount_int(void) · 153 unmodified lines
154154
155155 return mips_cpu_perf_irq;
156156 }
157+EXPORT_SYMBOL_GPL(get_c0_perfcount_int);
157158
158159 unsigned int get_c0_compare_int(void)
159160 {
@@ -171,14 +172,17 @@ unsigned int get_c0_compare_int(void) · 11 unmodified lines
171172
172173 static void __init init_rtc(void)
173174 {
174− /* stop the clock whilst setting it up */
175− CMOS_WRITE(RTC_SET | RTC_24H, RTC_CONTROL);
175+ unsigned char freq, ctrl;
176176
177− /* 32KHz time base */
178− CMOS_WRITE(RTC_REF_CLCK_32KHZ, RTC_FREQ_SELECT);
177+ /* Set 32KHz time base if not already set */
178+ freq = CMOS_READ(RTC_FREQ_SELECT);
179+ if ((freq & RTC_DIV_CTL) != RTC_REF_CLCK_32KHZ)
180+ CMOS_WRITE(RTC_REF_CLCK_32KHZ, RTC_FREQ_SELECT);
179181
180− /* start the clock */
181− CMOS_WRITE(RTC_24H, RTC_CONTROL);
182+ /* Ensure SET bit is clear so RTC can run */
183+ ctrl = CMOS_READ(RTC_CONTROL);
184+ if (ctrl & RTC_SET)
185+ CMOS_WRITE(ctrl & ~RTC_SET, RTC_CONTROL);
182186 }
183187
184188 void __init plat_time_init(void)
arch/mips/mti-sead3/sead3-time.c+1−0
@@ -77,6 +77,7 @@ int get_c0_perfcount_int(void) · 76 unmodified lines
7777 return MIPS_CPU_IRQ_BASE + cp0_perfcount_irq;
7878 return -1;
7979 }
80+EXPORT_SYMBOL_GPL(get_c0_perfcount_int);
8081
8182 unsigned int get_c0_compare_int(void)
8283 {
arch/mips/netlogic/common/smp.c+1−1
@@ -86,7 +86,7 @@ void nlm_smp_function_ipi_handler(unsigned int irq, struct irq_desc *desc) · 85 unmodified lines
8686 {
8787 clear_c0_eimr(irq);
8888 ack_c0_eirr(irq);
89− smp_call_function_interrupt();
89+ generic_smp_call_function_interrupt();
9090 set_c0_eimr(irq);
9191 }
9292
arch/mips/paravirt/paravirt-smp.c+1−1
@@ -114,7 +114,7 @@ static irqreturn_t paravirt_reched_interrupt(int irq, void *dev_id) · 113 unmodified lines
114114
115115 static irqreturn_t paravirt_function_interrupt(int irq, void *dev_id)
116116 {
117− smp_call_function_interrupt();
117+ generic_smp_call_function_interrupt();
118118 return IRQ_HANDLED;
119119 }
120120
arch/mips/pistachio/time.c+1−0
@@ -26,6 +26,7 @@ int get_c0_perfcount_int(void) · 25 unmodified lines
2626 {
2727 return gic_get_c0_perfcount_int();
2828 }
29+EXPORT_SYMBOL_GPL(get_c0_perfcount_int);
2930
3031 int get_c0_fdc_int(void)
3132 {
arch/mips/pmcs-msp71xx/msp_smp.c+1−1
@@ -44,7 +44,7 @@ static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id) · 43 unmodified lines
4444
4545 static irqreturn_t ipi_call_interrupt(int irq, void *dev_id)
4646 {
47− smp_call_function_interrupt();
47+ generic_smp_call_function_interrupt();
4848
4949 return IRQ_HANDLED;
5050 }
arch/mips/ralink/irq.c+1−0
@@ -89,6 +89,7 @@ int get_c0_perfcount_int(void) · 88 unmodified lines
8989 {
9090 return rt_perfcount_irq;
9191 }
92+EXPORT_SYMBOL_GPL(get_c0_perfcount_int);
9293
9394 unsigned int get_c0_compare_int(void)
9495 {
arch/mips/sgi-ip27/ip27-irq.c+6−2
@@ -107,10 +107,14 @@ static void ip27_do_irq_mask0(void) · 106 unmodified lines
107107 scheduler_ipi();
108108 } else if (pend0 & (1UL << CPU_CALL_A_IRQ)) {
109109 LOCAL_HUB_CLR_INTR(CPU_CALL_A_IRQ);
110− smp_call_function_interrupt();
110+ irq_enter();
111+ generic_smp_call_function_interrupt();
112+ irq_exit();
111113 } else if (pend0 & (1UL << CPU_CALL_B_IRQ)) {
112114 LOCAL_HUB_CLR_INTR(CPU_CALL_B_IRQ);
113− smp_call_function_interrupt();
115+ irq_enter();
116+ generic_smp_call_function_interrupt();
117+ irq_exit();
114118 } else
115119 #endif
116120 {
arch/mips/sibyte/bcm1480/smp.c+5−4
@@ -29,8 +29,6 @@ · 28 unmodified lines
2929 #include <asm/sibyte/bcm1480_regs.h>
3030 #include <asm/sibyte/bcm1480_int.h>
3131
32−extern void smp_call_function_interrupt(void);
33−
3432 /*
3533 * These are routines for dealing with the bcm1480 smp capabilities
3634 * independent of board/firmware
@@ -184,6 +182,9 @@ void bcm1480_mailbox_interrupt(void) · 147 unmodified lines
184182 if (action & SMP_RESCHEDULE_YOURSELF)
185183 scheduler_ipi();
186184
187− if (action & SMP_CALL_FUNCTION)
188− smp_call_function_interrupt();
185+ if (action & SMP_CALL_FUNCTION) {
186+ irq_enter();
187+ generic_smp_call_function_interrupt();
188+ irq_exit();
189+ }
189190 }
arch/mips/sibyte/sb1250/smp.c+5−2
@@ -172,6 +172,9 @@ void sb1250_mailbox_interrupt(void) · 171 unmodified lines
172172 if (action & SMP_RESCHEDULE_YOURSELF)
173173 scheduler_ipi();
174174
175− if (action & SMP_CALL_FUNCTION)
176− smp_call_function_interrupt();
175+ if (action & SMP_CALL_FUNCTION) {
176+ irq_enter();
177+ generic_smp_call_function_interrupt();
178+ irq_exit();
179+ }
177180 }
arch/powerpc/kernel/signal_32.c+0−2
@@ -966,8 +966,6 @@ int copy_siginfo_to_user32(struct compat_siginfo __user *d, const siginfo_t *s) · 965 unmodified lines
966966
967967 int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from)
968968 {
969− memset(to, 0, sizeof *to);
970−
971969 if (copy_from_user(to, from, 3*sizeof(int)) ||
972970 copy_from_user(to->_sifields._pad,
973971 from->_sifields._pad, SI_PAD_SIZE32))
arch/powerpc/platforms/powernv/eeh-powernv.c+1−1
@@ -1478,7 +1478,7 @@ static int pnv_eeh_next_error(struct eeh_pe **pe) · 1477 unmodified lines
14781478 }
14791479
14801480 /* Unmask the event */
1481− if (eeh_enabled())
1481+ if (ret == EEH_NEXT_ERR_NONE && eeh_enabled())
14821482 enable_irq(eeh_event_irq);
14831483
14841484 return ret;
arch/powerpc/platforms/powernv/pci-ioda.c+6−5
@@ -2220,7 +2220,7 @@ static void pnv_pci_ioda_setup_opal_tce_kill(struct pnv_phb *phb) · 2219 unmodified lines
22202220
22212221 static __be64 *pnv_pci_ioda2_table_do_alloc_pages(int nid, unsigned shift,
22222222 unsigned levels, unsigned long limit,
2223− unsigned long *current_offset)
2223+ unsigned long *current_offset, unsigned long *total_allocated)
22242224 {
22252225 struct page *tce_mem = NULL;
22262226 __be64 *addr, *tmp;
@@ -2236,6 +2236,7 @@ static __be64 *pnv_pci_ioda2_table_do_alloc_pages(int nid, unsigned shift, · 9 unmodified lines
22362236 }
22372237 addr = page_address(tce_mem);
22382238 memset(addr, 0, allocated);
2239+ *total_allocated += allocated;
22392240
22402241 --levels;
22412242 if (!levels) {
@@ -2245,7 +2246,7 @@ static __be64 *pnv_pci_ioda2_table_do_alloc_pages(int nid, unsigned shift, · 3 unmodified lines
22452246
22462247 for (i = 0; i < entries; ++i) {
22472248 tmp = pnv_pci_ioda2_table_do_alloc_pages(nid, shift,
2248− levels, limit, current_offset);
2249+ levels, limit, current_offset, total_allocated);
22492250 if (!tmp)
22502251 break;
22512252
@@ -2267,7 +2268,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset, · 15 unmodified lines
22672268 struct iommu_table *tbl)
22682269 {
22692270 void *addr;
2270− unsigned long offset = 0, level_shift;
2271+ unsigned long offset = 0, level_shift, total_allocated = 0;
22712272 const unsigned window_shift = ilog2(window_size);
22722273 unsigned entries_shift = window_shift - page_shift;
22732274 unsigned table_shift = max_t(unsigned, entries_shift + 3, PAGE_SHIFT);
@@ -2286,7 +2287,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset, · 12 unmodified lines
22862287
22872288 /* Allocate TCE table */
22882289 addr = pnv_pci_ioda2_table_do_alloc_pages(nid, level_shift,
2289− levels, tce_table_size, &offset);
2290+ levels, tce_table_size, &offset, &total_allocated);
22902291
22912292 /* addr==NULL means that the first level allocation failed */
22922293 if (!addr)
@@ -2308,7 +2309,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset, · 15 unmodified lines
23082309 page_shift);
23092310 tbl->it_level_size = 1ULL << (level_shift - 3);
23102311 tbl->it_indirect_levels = levels - 1;
2311− tbl->it_allocated_size = offset;
2312+ tbl->it_allocated_size = total_allocated;
23122313
23132314 pr_devel("Created TCE table: ws=%08llx ts=%lx @%08llx\n",
23142315 window_size, tce_table_size, bus_offset);
arch/s390/kernel/cache.c+2−0
@@ -138,6 +138,8 @@ int init_cache_level(unsigned int cpu) · 137 unmodified lines
138138 union cache_topology ct;
139139 enum cache_type ctype;
140140
141+ if (!test_facility(34))
142+ return -EOPNOTSUPP;
141143 if (!this_cpu_ci)
142144 return -EINVAL;
143145 ct.raw = ecag(EXTRACT_TOPOLOGY, 0, 0);
arch/s390/kvm/kvm-s390.c+2−2
@@ -1742,10 +1742,10 @@ static bool ibs_enabled(struct kvm_vcpu *vcpu) · 1741 unmodified lines
17421742
17431743 static int kvm_s390_handle_requests(struct kvm_vcpu *vcpu)
17441744 {
1745− if (!vcpu->requests)
1746− return 0;
17471745 retry:
17481746 kvm_s390_vcpu_request_handled(vcpu);
1747+ if (!vcpu->requests)
1748+ return 0;
17491749 /*
17501750 * We use MMU_RELOAD just to re-arm the ipte notifier for the
17511751 * guest prefix page. gmap_ipte_notify will wait on the ptl lock.
arch/s390/net/bpf_jit_comp.c+7−7
@@ -448,13 +448,13 @@ static void bpf_jit_prologue(struct bpf_jit *jit) · 447 unmodified lines
448448 EMIT6_DISP_LH(0xe3000000, 0x0004, REG_SKB_DATA, REG_0,
449449 BPF_REG_1, offsetof(struct sk_buff, data));
450450 }
451− /* BPF compatibility: clear A (%b7) and X (%b8) registers */
452− if (REG_SEEN(BPF_REG_7))
453− /* lghi %b7,0 */
454− EMIT4_IMM(0xa7090000, BPF_REG_7, 0);
455− if (REG_SEEN(BPF_REG_8))
456− /* lghi %b8,0 */
457− EMIT4_IMM(0xa7090000, BPF_REG_8, 0);
451+ /* BPF compatibility: clear A (%b0) and X (%b7) registers */
452+ if (REG_SEEN(BPF_REG_A))
453+ /* lghi %ba,0 */
454+ EMIT4_IMM(0xa7090000, BPF_REG_A, 0);
455+ if (REG_SEEN(BPF_REG_X))
456+ /* lghi %bx,0 */
457+ EMIT4_IMM(0xa7090000, BPF_REG_X, 0);
458458 }
459459
460460 /*
arch/sparc/include/asm/visasm.h+5−11
@@ -28,16 +28,10 @@ · 27 unmodified lines
2828 * Must preserve %o5 between VISEntryHalf and VISExitHalf */
2929
3030 #define VISEntryHalf \
31− rd %fprs, %o5; \
32− andcc %o5, FPRS_FEF, %g0; \
33− be,pt %icc, 297f; \
34− sethi %hi(298f), %g7; \
35− sethi %hi(VISenterhalf), %g1; \
36− jmpl %g1 + %lo(VISenterhalf), %g0; \
37− or %g7, %lo(298f), %g7; \
38− clr %o5; \
39−297: wr %o5, FPRS_FEF, %fprs; \
40−298:
31+ VISEntry
32+
33+#define VISExitHalf \
34+ VISExit
4135
4236 #define VISEntryHalfFast(fail_label) \
4337 rd %fprs, %o5; \
@@ -47,7 +41,7 @@ · 3 unmodified lines
4741 ba,a,pt %xcc, fail_label; \
4842 297: wr %o5, FPRS_FEF, %fprs;
4943
50−#define VISExitHalf \
44+#define VISExitHalfFast \
5145 wr %o5, 0, %fprs;
5246
5347 #ifndef __ASSEMBLY__
arch/sparc/lib/NG4memcpy.S+4−1
@@ -240,8 +240,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 239 unmodified lines
240240 add %o0, 0x40, %o0
241241 bne,pt %icc, 1b
242242 LOAD(prefetch, %g1 + 0x200, #n_reads_strong)
243+#ifdef NON_USER_COPY
244+ VISExitHalfFast
245+#else
243246 VISExitHalf
244−
247+#endif
245248 brz,pn %o2, .Lexit
246249 cmp %o2, 19
247250 ble,pn %icc, .Lsmall_unaligned
arch/sparc/lib/VISsave.S+2−65
@@ -44,9 +44,8 @@ vis1: ldub [%g6 + TI_FPSAVED], %g3 · 43 unmodified lines
4444
4545 stx %g3, [%g6 + TI_GSR]
4646 2: add %g6, %g1, %g3
47− cmp %o5, FPRS_DU
48− be,pn %icc, 6f
49− sll %g1, 3, %g1
47+ mov FPRS_DU | FPRS_DL | FPRS_FEF, %o5
48+ sll %g1, 3, %g1
5049 stb %o5, [%g3 + TI_FPSAVED]
5150 rd %gsr, %g2
5251 add %g6, %g1, %g3
@@ -80,65 +79,3 @@ vis1: ldub [%g6 + TI_FPSAVED], %g3 · 27 unmodified lines
8079 .align 32
8180 80: jmpl %g7 + %g0, %g0
8281 nop
83−
84−6: ldub [%g3 + TI_FPSAVED], %o5
85− or %o5, FPRS_DU, %o5
86− add %g6, TI_FPREGS+0x80, %g2
87− stb %o5, [%g3 + TI_FPSAVED]
88−
89− sll %g1, 5, %g1
90− add %g6, TI_FPREGS+0xc0, %g3
91− wr %g0, FPRS_FEF, %fprs
92− membar #Sync
93− stda %f32, [%g2 + %g1] ASI_BLK_P
94− stda %f48, [%g3 + %g1] ASI_BLK_P
95− membar #Sync
96− ba,pt %xcc, 80f
97− nop
98−
99− .align 32
100−80: jmpl %g7 + %g0, %g0
101− nop
102−
103− .align 32
104−VISenterhalf:
105− ldub [%g6 + TI_FPDEPTH], %g1
106− brnz,a,pn %g1, 1f
107− cmp %g1, 1
108− stb %g0, [%g6 + TI_FPSAVED]
109− stx %fsr, [%g6 + TI_XFSR]
110− clr %o5
111− jmpl %g7 + %g0, %g0
112− wr %g0, FPRS_FEF, %fprs
113−
114−1: bne,pn %icc, 2f
115− srl %g1, 1, %g1
116− ba,pt %xcc, vis1
117− sub %g7, 8, %g7
118−2: addcc %g6, %g1, %g3
119− sll %g1, 3, %g1
120− andn %o5, FPRS_DU, %g2
121− stb %g2, [%g3 + TI_FPSAVED]
122−
123− rd %gsr, %g2
124− add %g6, %g1, %g3
125− stx %g2, [%g3 + TI_GSR]
126− add %g6, %g1, %g2
127− stx %fsr, [%g2 + TI_XFSR]
128− sll %g1, 5, %g1
129−3: andcc %o5, FPRS_DL, %g0
130− be,pn %icc, 4f
131− add %g6, TI_FPREGS, %g2
132−
133− add %g6, TI_FPREGS+0x40, %g3
134− membar #Sync
135− stda %f0, [%g2 + %g1] ASI_BLK_P
136− stda %f16, [%g3 + %g1] ASI_BLK_P
137− membar #Sync
138− ba,pt %xcc, 4f
139− nop
140−
141− .align 32
142−4: and %o5, FPRS_DU, %o5
143− jmpl %g7 + %g0, %g0
144− wr %o5, FPRS_FEF, %fprs
arch/sparc/lib/ksyms.c+0−4
@@ -135,10 +135,6 @@ EXPORT_SYMBOL(copy_user_page); · 134 unmodified lines
135135 void VISenter(void);
136136 EXPORT_SYMBOL(VISenter);
137137
138−/* CRYPTO code needs this */
139−void VISenterhalf(void);
140−EXPORT_SYMBOL(VISenterhalf);
141−
142138 extern void xor_vis_2(unsigned long, unsigned long *, unsigned long *);
143139 extern void xor_vis_3(unsigned long, unsigned long *, unsigned long *,
144140 unsigned long *);
arch/tile/kernel/compat_signal.c+0−2
@@ -113,8 +113,6 @@ int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from) · 112 unmodified lines
113113 if (!access_ok(VERIFY_READ, from, sizeof(struct compat_siginfo)))
114114 return -EFAULT;
115115
116− memset(to, 0, sizeof(*to));
117−
118116 err = __get_user(to->si_signo, &from->si_signo);
119117 err |= __get_user(to->si_errno, &from->si_errno);
120118 err |= __get_user(to->si_code, &from->si_code);
arch/x86/boot/compressed/eboot.c+4−0
@@ -1193,6 +1193,10 @@ static efi_status_t setup_e820(struct boot_params *params, · 1192 unmodified lines
11931193 unsigned int e820_type = 0;
11941194 unsigned long m = efi->efi_memmap;
11951195
1196+#ifdef CONFIG_X86_64
1197+ m |= (u64)efi->efi_memmap_hi << 32;
1198+#endif
1199+
11961200 d = (efi_memory_desc_t *)(m + (i * efi->efi_memdesc_size));
11971201 switch (d->type) {
11981202 case EFI_RESERVED_TYPE:
arch/x86/entry/entry_64_compat.S+2−1
@@ -140,6 +140,7 @@ sysexit_from_sys_call: · 139 unmodified lines
140140 */
141141 andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
142142 movl RIP(%rsp), %ecx /* User %eip */
143+ movq RAX(%rsp), %rax
143144 RESTORE_RSI_RDI
144145 xorl %edx, %edx /* Do not leak kernel information */
145146 xorq %r8, %r8
@@ -219,7 +220,6 @@ sysexit_from_sys_call: · 73 unmodified lines
219220 1: setbe %al /* 1 if error, 0 if not */
220221 movzbl %al, %edi /* zero-extend that into %edi */
221222 call __audit_syscall_exit
222− movq RAX(%rsp), %rax /* reload syscall return value */
223223 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %edi
224224 DISABLE_INTERRUPTS(CLBR_NONE)
225225 TRACE_IRQS_OFF
@@ -368,6 +368,7 @@ sysretl_from_sys_call: · 142 unmodified lines
368368 RESTORE_RSI_RDI_RDX
369369 movl RIP(%rsp), %ecx
370370 movl EFLAGS(%rsp), %r11d
371+ movq RAX(%rsp), %rax
371372 xorq %r10, %r10
372373 xorq %r9, %r9
373374 xorq %r8, %r8
arch/x86/include/asm/desc.h+0−15
@@ -280,21 +280,6 @@ static inline void clear_LDT(void) · 279 unmodified lines
280280 set_ldt(NULL, 0);
281281 }
282282
283−/*
284− * load one particular LDT into the current CPU
285− */
286−static inline void load_LDT_nolock(mm_context_t *pc)
287−{
288− set_ldt(pc->ldt, pc->size);
289−}
290−
291−static inline void load_LDT(mm_context_t *pc)
292−{
293− preempt_disable();
294− load_LDT_nolock(pc);
295− preempt_enable();
296−}
297−
298283 static inline unsigned long get_desc_base(const struct desc_struct *desc)
299284 {
300285 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
arch/x86/include/asm/mmu.h+1−2
@@ -9,8 +9,7 @@ · 8 unmodified lines
99 * we put the segment information here.
1010 */
1111 typedef struct {
12− void *ldt;
13− int size;
12+ struct ldt_struct *ldt;
1413
1514 #ifdef CONFIG_X86_64
1615 /* True if mm supports a task running in 32 bit compatibility mode. */
arch/x86/include/asm/mmu_context.h+49−5
@@ -33,6 +33,50 @@ static inline void load_mm_cr4(struct mm_struct *mm) · 32 unmodified lines
3333 static inline void load_mm_cr4(struct mm_struct *mm) {}
3434 #endif
3535
36+/*
37+ * ldt_structs can be allocated, used, and freed, but they are never
38+ * modified while live.
39+ */
40+struct ldt_struct {
41+ /*
42+ * Xen requires page-aligned LDTs with special permissions. This is
43+ * needed to prevent us from installing evil descriptors such as
44+ * call gates. On native, we could merge the ldt_struct and LDT
45+ * allocations, but it's not worth trying to optimize.
46+ */
47+ struct desc_struct *entries;
48+ int size;
49+};
50+
51+static inline void load_mm_ldt(struct mm_struct *mm)
52+{
53+ struct ldt_struct *ldt;
54+
55+ /* lockless_dereference synchronizes with smp_store_release */
56+ ldt = lockless_dereference(mm->context.ldt);
57+
58+ /*
59+ * Any change to mm->context.ldt is followed by an IPI to all
60+ * CPUs with the mm active. The LDT will not be freed until
61+ * after the IPI is handled by all such CPUs. This means that,
62+ * if the ldt_struct changes before we return, the values we see
63+ * will be safe, and the new values will be loaded before we run
64+ * any user code.
65+ *
66+ * NB: don't try to convert this to use RCU without extreme care.
67+ * We would still need IRQs off, because we don't want to change
68+ * the local LDT after an IPI loaded a newer value than the one
69+ * that we can see.
70+ */
71+
72+ if (unlikely(ldt))
73+ set_ldt(ldt->entries, ldt->size);
74+ else
75+ clear_LDT();
76+
77+ DEBUG_LOCKS_WARN_ON(preemptible());
78+}
79+
3680 /*
3781 * Used for LDT copy/destruction.
3882 */
@@ -78,12 +122,12 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, · 39 unmodified lines
78122 * was called and then modify_ldt changed
79123 * prev->context.ldt but suppressed an IPI to this CPU.
80124 * In this case, prev->context.ldt != NULL, because we
81− * never free an LDT while the mm still exists. That
82− * means that next->context.ldt != prev->context.ldt,
83− * because mms never share an LDT.
125+ * never set context.ldt to NULL while the mm still
126+ * exists. That means that next->context.ldt !=
127+ * prev->context.ldt, because mms never share an LDT.
84128 */
85129 if (unlikely(prev->context.ldt != next->context.ldt))
86− load_LDT_nolock(&next->context);
130+ load_mm_ldt(next);
87131 }
88132 #ifdef CONFIG_SMP
89133 else {
@@ -106,7 +150,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, · 16 unmodified lines
106150 load_cr3(next->pgd);
107151 trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL);
108152 load_mm_cr4(next);
109− load_LDT_nolock(&next->context);
153+ load_mm_ldt(next);
110154 }
111155 }
112156 #endif
arch/x86/include/asm/sigcontext.h+3−3
@@ -57,9 +57,9 @@ struct sigcontext { · 56 unmodified lines
5757 unsigned long ip;
5858 unsigned long flags;
5959 unsigned short cs;
60− unsigned short __pad2; /* Was called gs, but was always zero. */
61− unsigned short __pad1; /* Was called fs, but was always zero. */
62− unsigned short ss;
60+ unsigned short gs;
61+ unsigned short fs;
62+ unsigned short __pad0;
6363 unsigned long err;
6464 unsigned long trapno;
6565 unsigned long oldmask;
arch/x86/include/uapi/asm/sigcontext.h+3−18
@@ -177,24 +177,9 @@ struct sigcontext { · 176 unmodified lines
177177 __u64 rip;
178178 __u64 eflags; /* RFLAGS */
179179 __u16 cs;
180−
181− /*
182− * Prior to 2.5.64 ("[PATCH] x86-64 updates for 2.5.64-bk3"),
183− * Linux saved and restored fs and gs in these slots. This
184− * was counterproductive, as fsbase and gsbase were never
185− * saved, so arch_prctl was presumably unreliable.
186− *
187− * If these slots are ever needed for any other purpose, there
188− * is some risk that very old 64-bit binaries could get
189− * confused. I doubt that many such binaries still work,
190− * though, since the same patch in 2.5.64 also removed the
191− * 64-bit set_thread_area syscall, so it appears that there is
192− * no TLS API that works in both pre- and post-2.5.64 kernels.
193− */
194− __u16 __pad2; /* Was gs. */
195− __u16 __pad1; /* Was fs. */
196−
197− __u16 ss;
180+ __u16 gs;
181+ __u16 fs;
182+ __u16 __pad0;
198183 __u64 err;
199184 __u64 trapno;
200185 __u64 oldmask;
arch/x86/kernel/apic/io_apic.c+1−1
@@ -943,7 +943,7 @@ static bool mp_check_pin_attr(int irq, struct irq_alloc_info *info) · 942 unmodified lines
943943 */
944944 if (irq < nr_legacy_irqs() && data->count == 1) {
945945 if (info->ioapic_trigger != data->trigger)
946− mp_register_handler(irq, data->trigger);
946+ mp_register_handler(irq, info->ioapic_trigger);
947947 data->entry.trigger = data->trigger = info->ioapic_trigger;
948948 data->entry.polarity = data->polarity = info->ioapic_polarity;
949949 }
arch/x86/kernel/cpu/common.c+2−2
@@ -1410,7 +1410,7 @@ void cpu_init(void) · 1409 unmodified lines
14101410 load_sp0(t, &current->thread);
14111411 set_tss_desc(cpu, t);
14121412 load_TR_desc();
1413− load_LDT(&init_mm.context);
1413+ load_mm_ldt(&init_mm);
14141414
14151415 clear_all_debug_regs();
14161416 dbg_restore_debug_regs();
@@ -1459,7 +1459,7 @@ void cpu_init(void) · 42 unmodified lines
14591459 load_sp0(t, thread);
14601460 set_tss_desc(cpu, t);
14611461 load_TR_desc();
1462− load_LDT(&init_mm.context);
1462+ load_mm_ldt(&init_mm);
14631463
14641464 t->x86_tss.io_bitmap_base = offsetof(struct tss_struct, io_bitmap);
14651465
arch/x86/kernel/cpu/perf_event.c+8−4
@@ -2179,21 +2179,25 @@ static unsigned long get_segment_base(unsigned int segment) · 2178 unmodified lines
21792179 int idx = segment >> 3;
21802180
21812181 if ((segment & SEGMENT_TI_MASK) == SEGMENT_LDT) {
2182+ struct ldt_struct *ldt;
2183+
21822184 if (idx > LDT_ENTRIES)
21832185 return 0;
21842186
2185− if (idx > current->active_mm->context.size)
2187+ /* IRQs are off, so this synchronizes with smp_store_release */
2188+ ldt = lockless_dereference(current->active_mm->context.ldt);
2189+ if (!ldt || idx > ldt->size)
21862190 return 0;
21872191
2188− desc = current->active_mm->context.ldt;
2192+ desc = &ldt->entries[idx];
21892193 } else {
21902194 if (idx > GDT_ENTRIES)
21912195 return 0;
21922196
2193− desc = raw_cpu_ptr(gdt_page.gdt);
2197+ desc = raw_cpu_ptr(gdt_page.gdt) + idx;
21942198 }
21952199
2196− return get_desc_base(desc + idx);
2200+ return get_desc_base(desc);
21972201 }
21982202
21992203 #ifdef CONFIG_COMPAT
arch/x86/kernel/ldt.c+142−120
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #include <linux/string.h>
1313 #include <linux/mm.h>
1414 #include <linux/smp.h>
15+#include <linux/slab.h>
1516 #include <linux/vmalloc.h>
1617 #include <linux/uaccess.h>
1718
@@ -20,82 +21,82 @@ · 2 unmodified lines
2021 #include <asm/mmu_context.h>
2122 #include <asm/syscalls.h>
2223
23−#ifdef CONFIG_SMP
24+/* context.lock is held for us, so we don't need any locking. */
2425 static void flush_ldt(void *current_mm)
2526 {
26− if (current->active_mm == current_mm)
27− load_LDT(&current->active_mm->context);
27+ mm_context_t *pc;
28+
29+ if (current->active_mm != current_mm)
30+ return;
31+
32+ pc = &current->active_mm->context;
33+ set_ldt(pc->ldt->entries, pc->ldt->size);
2834 }
29−#endif
3035
31−static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
36+/* The caller must call finalize_ldt_struct on the result. LDT starts zeroed. */
37+static struct ldt_struct *alloc_ldt_struct(int size)
3238 {
33− void *oldldt, *newldt;
34− int oldsize;
35−
36− if (mincount <= pc->size)
37− return 0;
38− oldsize = pc->size;
39− mincount = (mincount + (PAGE_SIZE / LDT_ENTRY_SIZE - 1)) &
40− (~(PAGE_SIZE / LDT_ENTRY_SIZE - 1));
41− if (mincount * LDT_ENTRY_SIZE > PAGE_SIZE)
42− newldt = vmalloc(mincount * LDT_ENTRY_SIZE);
39+ struct ldt_struct *new_ldt;
40+ int alloc_size;
41+
42+ if (size > LDT_ENTRIES)
43+ return NULL;
44+
45+ new_ldt = kmalloc(sizeof(struct ldt_struct), GFP_KERNEL);
46+ if (!new_ldt)
47+ return NULL;
48+
49+ BUILD_BUG_ON(LDT_ENTRY_SIZE != sizeof(struct desc_struct));
50+ alloc_size = size * LDT_ENTRY_SIZE;
51+
52+ /*
53+ * Xen is very picky: it requires a page-aligned LDT that has no
54+ * trailing nonzero bytes in any page that contains LDT descriptors.
55+ * Keep it simple: zero the whole allocation and never allocate less
56+ * than PAGE_SIZE.
57+ */
58+ if (alloc_size > PAGE_SIZE)
59+ new_ldt->entries = vzalloc(alloc_size);
4360 else
44− newldt = (void *)__get_free_page(GFP_KERNEL);
45−
46− if (!newldt)
47− return -ENOMEM;
61+ new_ldt->entries = kzalloc(PAGE_SIZE, GFP_KERNEL);
4862
49− if (oldsize)
50− memcpy(newldt, pc->ldt, oldsize * LDT_ENTRY_SIZE);
51− oldldt = pc->ldt;
52− memset(newldt + oldsize * LDT_ENTRY_SIZE, 0,
53− (mincount - oldsize) * LDT_ENTRY_SIZE);
63+ if (!new_ldt->entries) {
64+ kfree(new_ldt);
65+ return NULL;
66+ }
5467
55− paravirt_alloc_ldt(newldt, mincount);
68+ new_ldt->size = size;
69+ return new_ldt;
70+}
5671
57−#ifdef CONFIG_X86_64
58− /* CHECKME: Do we really need this ? */
59− wmb();
60−#endif
61− pc->ldt = newldt;
62− wmb();
63− pc->size = mincount;
64− wmb();
65−
66− if (reload) {
67−#ifdef CONFIG_SMP
68− preempt_disable();
69− load_LDT(pc);
70− if (!cpumask_equal(mm_cpumask(current->mm),
71− cpumask_of(smp_processor_id())))
72− smp_call_function(flush_ldt, current->mm, 1);
73− preempt_enable();
74−#else
75− load_LDT(pc);
76−#endif
77− }
78− if (oldsize) {
79− paravirt_free_ldt(oldldt, oldsize);
80− if (oldsize * LDT_ENTRY_SIZE > PAGE_SIZE)
81− vfree(oldldt);
82− else
83− put_page(virt_to_page(oldldt));
84− }
85− return 0;
72+/* After calling this, the LDT is immutable. */
73+static void finalize_ldt_struct(struct ldt_struct *ldt)
74+{
75+ paravirt_alloc_ldt(ldt->entries, ldt->size);
8676 }
8777
88−static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
78+/* context.lock is held */
79+static void install_ldt(struct mm_struct *current_mm,
80+ struct ldt_struct *ldt)
8981 {
90− int err = alloc_ldt(new, old->size, 0);
91− int i;
82+ /* Synchronizes with lockless_dereference in load_mm_ldt. */
83+ smp_store_release(&current_mm->context.ldt, ldt);
84+
85+ /* Activate the LDT for all CPUs using current_mm. */
86+ on_each_cpu_mask(mm_cpumask(current_mm), flush_ldt, current_mm, true);
87+}
9288
93− if (err < 0)
94− return err;
89+static void free_ldt_struct(struct ldt_struct *ldt)
90+{
91+ if (likely(!ldt))
92+ return;
9593
96− for (i = 0; i < old->size; i++)
97− write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
98− return 0;
94+ paravirt_free_ldt(ldt->entries, ldt->size);
95+ if (ldt->size * LDT_ENTRY_SIZE > PAGE_SIZE)
96+ vfree(ldt->entries);
97+ else
98+ kfree(ldt->entries);
99+ kfree(ldt);
99100 }
100101
101102 /*
@@ -104,17 +105,37 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old) · 2 unmodified lines
104105 */
105106 int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
106107 {
108+ struct ldt_struct *new_ldt;
107109 struct mm_struct *old_mm;
108110 int retval = 0;
109111
110112 mutex_init(&mm->context.lock);
111− mm->context.size = 0;
112113 old_mm = current->mm;
113− if (old_mm && old_mm->context.size > 0) {
114− mutex_lock(&old_mm->context.lock);
115− retval = copy_ldt(&mm->context, &old_mm->context);
116− mutex_unlock(&old_mm->context.lock);
114+ if (!old_mm) {
115+ mm->context.ldt = NULL;
116+ return 0;
117117 }
118+
119+ mutex_lock(&old_mm->context.lock);
120+ if (!old_mm->context.ldt) {
121+ mm->context.ldt = NULL;
122+ goto out_unlock;
123+ }
124+
125+ new_ldt = alloc_ldt_struct(old_mm->context.ldt->size);
126+ if (!new_ldt) {
127+ retval = -ENOMEM;
128+ goto out_unlock;
129+ }
130+
131+ memcpy(new_ldt->entries, old_mm->context.ldt->entries,
132+ new_ldt->size * LDT_ENTRY_SIZE);
133+ finalize_ldt_struct(new_ldt);
134+
135+ mm->context.ldt = new_ldt;
136+
137+out_unlock:
138+ mutex_unlock(&old_mm->context.lock);
118139 return retval;
119140 }
120141
@@ -125,53 +146,47 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm) · 4 unmodified lines
125146 */
126147 void destroy_context(struct mm_struct *mm)
127148 {
128− if (mm->context.size) {
129−#ifdef CONFIG_X86_32
130− /* CHECKME: Can this ever happen ? */
131− if (mm == current->active_mm)
132− clear_LDT();
133−#endif
134− paravirt_free_ldt(mm->context.ldt, mm->context.size);
135− if (mm->context.size * LDT_ENTRY_SIZE > PAGE_SIZE)
136− vfree(mm->context.ldt);
137− else
138− put_page(virt_to_page(mm->context.ldt));
139− mm->context.size = 0;
140− }
149+ free_ldt_struct(mm->context.ldt);
150+ mm->context.ldt = NULL;
141151 }
142152
143153 static int read_ldt(void __user *ptr, unsigned long bytecount)
144154 {
145− int err;
155+ int retval;
146156 unsigned long size;
147157 struct mm_struct *mm = current->mm;
148158
149− if (!mm->context.size)
150− return 0;
159+ mutex_lock(&mm->context.lock);
160+
161+ if (!mm->context.ldt) {
162+ retval = 0;
163+ goto out_unlock;
164+ }
165+
151166 if (bytecount > LDT_ENTRY_SIZE * LDT_ENTRIES)
152167 bytecount = LDT_ENTRY_SIZE * LDT_ENTRIES;
153168
154− mutex_lock(&mm->context.lock);
155− size = mm->context.size * LDT_ENTRY_SIZE;
169+ size = mm->context.ldt->size * LDT_ENTRY_SIZE;
156170 if (size > bytecount)
157171 size = bytecount;
158172
159− err = 0;
160− if (copy_to_user(ptr, mm->context.ldt, size))
161− err = -EFAULT;
162− mutex_unlock(&mm->context.lock);
163− if (err < 0)
164− goto error_return;
173+ if (copy_to_user(ptr, mm->context.ldt->entries, size)) {
174+ retval = -EFAULT;
175+ goto out_unlock;
176+ }
177+
165178 if (size != bytecount) {
166− /* zero-fill the rest */
167− if (clear_user(ptr + size, bytecount - size) != 0) {
168− err = -EFAULT;
169− goto error_return;
179+ /* Zero-fill the rest and pretend we read bytecount bytes. */
180+ if (clear_user(ptr + size, bytecount - size)) {
181+ retval = -EFAULT;
182+ goto out_unlock;
170183 }
171184 }
172− return bytecount;
173−error_return:
174− return err;
185+ retval = bytecount;
186+
187+out_unlock:
188+ mutex_unlock(&mm->context.lock);
189+ return retval;
175190 }
176191
177192 static int read_default_ldt(void __user *ptr, unsigned long bytecount)
@@ -195,6 +210,8 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode) · 17 unmodified lines
195210 struct desc_struct ldt;
196211 int error;
197212 struct user_desc ldt_info;
213+ int oldsize, newsize;
214+ struct ldt_struct *new_ldt, *old_ldt;
198215
199216 error = -EINVAL;
200217 if (bytecount != sizeof(ldt_info))
@@ -213,34 +230,39 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode) · 12 unmodified lines
213230 goto out;
214231 }
215232
216− mutex_lock(&mm->context.lock);
217− if (ldt_info.entry_number >= mm->context.size) {
218− error = alloc_ldt(&current->mm->context,
219− ldt_info.entry_number + 1, 1);
220− if (error < 0)
221− goto out_unlock;
222− }
223−
224− /* Allow LDTs to be cleared by the user. */
225− if (ldt_info.base_addr == 0 && ldt_info.limit == 0) {
226− if (oldmode || LDT_empty(&ldt_info)) {
227− memset(&ldt, 0, sizeof(ldt));
228− goto install;
233+ if ((oldmode && !ldt_info.base_addr && !ldt_info.limit) ||
234+ LDT_empty(&ldt_info)) {
235+ /* The user wants to clear the entry. */
236+ memset(&ldt, 0, sizeof(ldt));
237+ } else {
238+ if (!IS_ENABLED(CONFIG_X86_16BIT) && !ldt_info.seg_32bit) {
239+ error = -EINVAL;
240+ goto out;
229241 }
242+
243+ fill_ldt(&ldt, &ldt_info);
244+ if (oldmode)
245+ ldt.avl = 0;
230246 }
231247
232− if (!IS_ENABLED(CONFIG_X86_16BIT) && !ldt_info.seg_32bit) {
233− error = -EINVAL;
248+ mutex_lock(&mm->context.lock);
249+
250+ old_ldt = mm->context.ldt;
251+ oldsize = old_ldt ? old_ldt->size : 0;
252+ newsize = max((int)(ldt_info.entry_number + 1), oldsize);
253+
254+ error = -ENOMEM;
255+ new_ldt = alloc_ldt_struct(newsize);
256+ if (!new_ldt)
234257 goto out_unlock;
235− }
236258
237− fill_ldt(&ldt, &ldt_info);
238− if (oldmode)
239− ldt.avl = 0;
259+ if (old_ldt)
260+ memcpy(new_ldt->entries, old_ldt->entries, oldsize * LDT_ENTRY_SIZE);
261+ new_ldt->entries[ldt_info.entry_number] = ldt;
262+ finalize_ldt_struct(new_ldt);
240263
241− /* Install the new entry ... */
242−install:
243− write_ldt_entry(mm->context.ldt, ldt_info.entry_number, &ldt);
264+ install_ldt(mm, new_ldt);
265+ free_ldt_struct(old_ldt);
244266 error = 0;
245267
246268 out_unlock:
arch/x86/kernel/process_64.c+2−2
@@ -121,11 +121,11 @@ void __show_regs(struct pt_regs *regs, int all) · 120 unmodified lines
121121 void release_thread(struct task_struct *dead_task)
122122 {
123123 if (dead_task->mm) {
124− if (dead_task->mm->context.size) {
124+ if (dead_task->mm->context.ldt) {
125125 pr_warn("WARNING: dead process %s still has LDT? <%p/%d>\n",
126126 dead_task->comm,
127127 dead_task->mm->context.ldt,
128− dead_task->mm->context.size);
128+ dead_task->mm->context.ldt->size);
129129 BUG();
130130 }
131131 }
arch/x86/kernel/signal.c+11−15
@@ -93,8 +93,15 @@ int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) · 92 unmodified lines
9393 COPY(r15);
9494 #endif /* CONFIG_X86_64 */
9595
96+#ifdef CONFIG_X86_32
9697 COPY_SEG_CPL3(cs);
9798 COPY_SEG_CPL3(ss);
99+#else /* !CONFIG_X86_32 */
100+ /* Kernel saves and restores only the CS segment register on signals,
101+ * which is the bare minimum needed to allow mixed 32/64-bit code.
102+ * App's signal handler can save/restore other segments if needed. */
103+ COPY_SEG_CPL3(cs);
104+#endif /* CONFIG_X86_32 */
98105
99106 get_user_ex(tmpflags, &sc->flags);
100107 regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
@@ -154,9 +161,8 @@ int setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate, · 53 unmodified lines
154161 #else /* !CONFIG_X86_32 */
155162 put_user_ex(regs->flags, &sc->flags);
156163 put_user_ex(regs->cs, &sc->cs);
157− put_user_ex(0, &sc->__pad2);
158− put_user_ex(0, &sc->__pad1);
159− put_user_ex(regs->ss, &sc->ss);
164+ put_user_ex(0, &sc->gs);
165+ put_user_ex(0, &sc->fs);
160166 #endif /* CONFIG_X86_32 */
161167
162168 put_user_ex(fpstate, &sc->fpstate);
@@ -451,19 +457,9 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig, · 288 unmodified lines
451457
452458 regs->sp = (unsigned long)frame;
453459
454− /*
455− * Set up the CS and SS registers to run signal handlers in
456− * 64-bit mode, even if the handler happens to be interrupting
457− * 32-bit or 16-bit code.
458− *
459− * SS is subtle. In 64-bit mode, we don't need any particular
460− * SS descriptor, but we do need SS to be valid. It's possible
461− * that the old SS is entirely bogus -- this can happen if the
462− * signal we're trying to deliver is #GP or #SS caused by a bad
463− * SS value.
464− */
460+ /* Set up the CS register to run signal handlers in 64-bit mode,
461+ even if the handler happens to be interrupting 32-bit code. */
465462 regs->cs = __USER_CS;
466− regs->ss = __USER_DS;
467463
468464 return 0;
469465 }
arch/x86/kernel/step.c+5−3
@@ -5,6 +5,7 @@ · 4 unmodified lines
55 #include <linux/mm.h>
66 #include <linux/ptrace.h>
77 #include <asm/desc.h>
8+#include <asm/mmu_context.h>
89
910 unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs)
1011 {
@@ -27,13 +28,14 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re · 16 unmodified lines
2728 struct desc_struct *desc;
2829 unsigned long base;
2930
30− seg &= ~7UL;
31+ seg >>= 3;
3132
3233 mutex_lock(&child->mm->context.lock);
33− if (unlikely((seg >> 3) >= child->mm->context.size))
34+ if (unlikely(!child->mm->context.ldt ||
35+ seg >= child->mm->context.ldt->size))
3436 addr = -1L; /* bogus selector, access would fault */
3537 else {
36− desc = child->mm->context.ldt + seg;
38+ desc = &child->mm->context.ldt->entries[seg];
3739 base = get_desc_base(desc);
3840
3941 /* 16-bit code segment? */
arch/x86/kvm/mtrr.c+4−4
@@ -672,16 +672,16 @@ u8 kvm_mtrr_get_guest_memory_type(struct kvm_vcpu *vcpu, gfn_t gfn) · 671 unmodified lines
672672 if (iter.mtrr_disabled)
673673 return mtrr_disabled_type();
674674
675+ /* not contained in any MTRRs. */
676+ if (type == -1)
677+ return mtrr_default_type(mtrr_state);
678+
675679 /*
676680 * We just check one page, partially covered by MTRRs is
677681 * impossible.
678682 */
679683 WARN_ON(iter.partial_map);
680684
681− /* not contained in any MTRRs. */
682− if (type == -1)
683− return mtrr_default_type(mtrr_state);
684−
685685 return type;
686686 }
687687 EXPORT_SYMBOL_GPL(kvm_mtrr_get_guest_memory_type);
arch/x86/kvm/x86.c+6−1
@@ -2105,7 +2105,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) · 2104 unmodified lines
21052105 if (guest_cpuid_has_tsc_adjust(vcpu)) {
21062106 if (!msr_info->host_initiated) {
21072107 s64 adj = data - vcpu->arch.ia32_tsc_adjust_msr;
2108− kvm_x86_ops->adjust_tsc_offset(vcpu, adj, true);
2108+ adjust_tsc_offset_guest(vcpu, adj);
21092109 }
21102110 vcpu->arch.ia32_tsc_adjust_msr = data;
21112111 }
@@ -6327,6 +6327,7 @@ static void process_smi_save_state_64(struct kvm_vcpu *vcpu, char *buf) · 4215 unmodified lines
63276327 static void process_smi(struct kvm_vcpu *vcpu)
63286328 {
63296329 struct kvm_segment cs, ds;
6330+ struct desc_ptr dt;
63306331 char buf[512];
63316332 u32 cr0;
63326333
@@ -6359,6 +6360,10 @@ static void process_smi(struct kvm_vcpu *vcpu) · 26 unmodified lines
63596360
63606361 kvm_x86_ops->set_cr4(vcpu, 0);
63616362
6363+ /* Undocumented: IDT limit is set to zero on entry to SMM. */
6364+ dt.address = dt.size = 0;
6365+ kvm_x86_ops->set_idt(vcpu, &dt);
6366+
63626367 __kvm_set_dr(vcpu, 7, DR7_FIXED_1);
63636368
63646369 cs.selector = (vcpu->arch.smbase >> 4) & 0xffff;
arch/x86/math-emu/fpu_entry.c+1−2
@@ -29,7 +29,6 @@ · 28 unmodified lines
2929
3030 #include <asm/uaccess.h>
3131 #include <asm/traps.h>
32−#include <asm/desc.h>
3332 #include <asm/user.h>
3433 #include <asm/fpu/internal.h>
3534
@@ -181,7 +180,7 @@ void math_emulate(struct math_emu_info *info) · 145 unmodified lines
181180 math_abort(FPU_info, SIGILL);
182181 }
183182
184− code_descriptor = LDT_DESCRIPTOR(FPU_CS);
183+ code_descriptor = FPU_get_ldt_descriptor(FPU_CS);
185184 if (SEG_D_SIZE(code_descriptor)) {
186185 /* The above test may be wrong, the book is not clear */
187186 /* Segmented 32 bit protected mode */
arch/x86/math-emu/fpu_system.h+18−3
@@ -16,9 +16,24 @@ · 15 unmodified lines
1616 #include <linux/kernel.h>
1717 #include <linux/mm.h>
1818
19−/* s is always from a cpu register, and the cpu does bounds checking
20− * during register load --> no further bounds checks needed */
21−#define LDT_DESCRIPTOR(s) (((struct desc_struct *)current->mm->context.ldt)[(s) >> 3])
19+#include <asm/desc.h>
20+#include <asm/mmu_context.h>
21+
22+static inline struct desc_struct FPU_get_ldt_descriptor(unsigned seg)
23+{
24+ static struct desc_struct zero_desc;
25+ struct desc_struct ret = zero_desc;
26+
27+#ifdef CONFIG_MODIFY_LDT_SYSCALL
28+ seg >>= 3;
29+ mutex_lock(&current->mm->context.lock);
30+ if (current->mm->context.ldt && seg < current->mm->context.ldt->size)
31+ ret = current->mm->context.ldt->entries[seg];
32+ mutex_unlock(&current->mm->context.lock);
33+#endif
34+ return ret;
35+}
36+
2237 #define SEG_D_SIZE(x) ((x).b & (3 << 21))
2338 #define SEG_G_BIT(x) ((x).b & (1 << 23))
2439 #define SEG_GRANULARITY(x) (((x).b & (1 << 23)) ? 4096 : 1)
arch/x86/math-emu/get_address.c+1−2
@@ -20,7 +20,6 @@ · 19 unmodified lines
2020 #include <linux/stddef.h>
2121
2222 #include <asm/uaccess.h>
23−#include <asm/desc.h>
2423
2524 #include "fpu_system.h"
2625 #include "exception.h"
@@ -158,7 +157,7 @@ static long pm_address(u_char FPU_modrm, u_char segment, · 131 unmodified lines
158157 addr->selector = PM_REG_(segment);
159158 }
160159
161− descriptor = LDT_DESCRIPTOR(PM_REG_(segment));
160+ descriptor = FPU_get_ldt_descriptor(addr->selector);
162161 base_address = SEG_BASE_ADDR(descriptor);
163162 address = base_address + offset;
164163 limit = base_address
arch/x86/net/bpf_jit_comp.c+4−4
@@ -269,7 +269,7 @@ static void emit_bpf_tail_call(u8 **pprog) · 268 unmodified lines
269269 EMIT4(0x48, 0x8B, 0x46, /* mov rax, qword ptr [rsi + 16] */
270270 offsetof(struct bpf_array, map.max_entries));
271271 EMIT3(0x48, 0x39, 0xD0); /* cmp rax, rdx */
272−#define OFFSET1 44 /* number of bytes to jump */
272+#define OFFSET1 47 /* number of bytes to jump */
273273 EMIT2(X86_JBE, OFFSET1); /* jbe out */
274274 label1 = cnt;
275275
@@ -278,15 +278,15 @@ static void emit_bpf_tail_call(u8 **pprog) · 2 unmodified lines
278278 */
279279 EMIT2_off32(0x8B, 0x85, -STACKSIZE + 36); /* mov eax, dword ptr [rbp - 516] */
280280 EMIT3(0x83, 0xF8, MAX_TAIL_CALL_CNT); /* cmp eax, MAX_TAIL_CALL_CNT */
281−#define OFFSET2 33
281+#define OFFSET2 36
282282 EMIT2(X86_JA, OFFSET2); /* ja out */
283283 label2 = cnt;
284284 EMIT3(0x83, 0xC0, 0x01); /* add eax, 1 */
285285 EMIT2_off32(0x89, 0x85, -STACKSIZE + 36); /* mov dword ptr [rbp - 516], eax */
286286
287287 /* prog = array->prog[index]; */
288− EMIT4(0x48, 0x8D, 0x44, 0xD6); /* lea rax, [rsi + rdx * 8 + 0x50] */
289− EMIT1(offsetof(struct bpf_array, prog));
288+ EMIT4_off32(0x48, 0x8D, 0x84, 0xD6, /* lea rax, [rsi + rdx * 8 + offsetof(...)] */
289+ offsetof(struct bpf_array, prog));
290290 EMIT3(0x48, 0x8B, 0x00); /* mov rax, qword ptr [rax] */
291291
292292 /* if (prog == NULL)
arch/x86/platform/efi/efi.c+5−0
@@ -972,6 +972,11 @@ u64 efi_mem_attributes(unsigned long phys_addr) · 971 unmodified lines
972972
973973 static int __init arch_parse_efi_cmdline(char *str)
974974 {
975+ if (!str) {
976+ pr_warn("need at least one option\n");
977+ return -EINVAL;
978+ }
979+
975980 if (parse_option_str(str, "old_map"))
976981 set_bit(EFI_OLD_MEMMAP, &efi.flags);
977982 if (parse_option_str(str, "debug"))
arch/x86/power/cpu.c+2−1
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 #include <asm/fpu/internal.h>
2323 #include <asm/debugreg.h>
2424 #include <asm/cpu.h>
25+#include <asm/mmu_context.h>
2526
2627 #ifdef CONFIG_X86_32
2728 __visible unsigned long saved_context_ebx;
@@ -153,7 +154,7 @@ static void fix_processor_context(void) · 125 unmodified lines
153154 syscall_init(); /* This sets MSR_*STAR and related */
154155 #endif
155156 load_TR_desc(); /* This does ltr */
156− load_LDT(&current->active_mm->context); /* This does lldt */
157+ load_mm_ldt(current->active_mm); /* This does lldt */
157158
158159 fpu__resume_cpu();
159160 }
arch/x86/xen/Makefile+2−2
@@ -13,13 +13,13 @@ CFLAGS_mmu.o := $(nostackp) · 12 unmodified lines
1313 obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \
1414 time.o xen-asm.o xen-asm_$(BITS).o \
1515 grant-table.o suspend.o platform-pci-unplug.o \
16− p2m.o
16+ p2m.o apic.o
1717
1818 obj-$(CONFIG_EVENT_TRACING) += trace.o
1919
2020 obj-$(CONFIG_SMP) += smp.o
2121 obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o
2222 obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o
23−obj-$(CONFIG_XEN_DOM0) += apic.o vga.o
23+obj-$(CONFIG_XEN_DOM0) += vga.o
2424 obj-$(CONFIG_SWIOTLB_XEN) += pci-swiotlb-xen.o
2525 obj-$(CONFIG_XEN_EFI) += efi.o
arch/x86/xen/enlighten.c+40−0
@@ -483,6 +483,7 @@ static void set_aliased_prot(void *v, pgprot_t prot) · 482 unmodified lines
483483 pte_t pte;
484484 unsigned long pfn;
485485 struct page *page;
486+ unsigned char dummy;
486487
487488 ptep = lookup_address((unsigned long)v, &level);
488489 BUG_ON(ptep == NULL);
@@ -492,6 +493,32 @@ static void set_aliased_prot(void *v, pgprot_t prot) · 3 unmodified lines
492493
493494 pte = pfn_pte(pfn, prot);
494495
496+ /*
497+ * Careful: update_va_mapping() will fail if the virtual address
498+ * we're poking isn't populated in the page tables. We don't
499+ * need to worry about the direct map (that's always in the page
500+ * tables), but we need to be careful about vmap space. In
501+ * particular, the top level page table can lazily propagate
502+ * entries between processes, so if we've switched mms since we
503+ * vmapped the target in the first place, we might not have the
504+ * top-level page table entry populated.
505+ *
506+ * We disable preemption because we want the same mm active when
507+ * we probe the target and when we issue the hypercall. We'll
508+ * have the same nominal mm, but if we're a kernel thread, lazy
509+ * mm dropping could change our pgd.
510+ *
511+ * Out of an abundance of caution, this uses __get_user() to fault
512+ * in the target address just in case there's some obscure case
513+ * in which the target address isn't readable.
514+ */
515+
516+ preempt_disable();
517+
518+ pagefault_disable(); /* Avoid warnings due to being atomic. */
519+ __get_user(dummy, (unsigned char __user __force *)v);
520+ pagefault_enable();
521+
495522 if (HYPERVISOR_update_va_mapping((unsigned long)v, pte, 0))
496523 BUG();
497524
@@ -503,6 +530,8 @@ static void set_aliased_prot(void *v, pgprot_t prot) · 5 unmodified lines
503530 BUG();
504531 } else
505532 kmap_flush_unused();
533+
534+ preempt_enable();
506535 }
507536
508537 static void xen_alloc_ldt(struct desc_struct *ldt, unsigned entries)
@@ -510,6 +539,17 @@ static void xen_alloc_ldt(struct desc_struct *ldt, unsigned entries) · 1 unmodified line
510539 const unsigned entries_per_page = PAGE_SIZE / LDT_ENTRY_SIZE;
511540 int i;
512541
542+ /*
543+ * We need to mark the all aliases of the LDT pages RO. We
544+ * don't need to call vm_flush_aliases(), though, since that's
545+ * only responsible for flushing aliases out the TLBs, not the
546+ * page tables, and Xen will flush the TLB for us if needed.
547+ *
548+ * To avoid confusing future readers: none of this is necessary
549+ * to load the LDT. The hypervisor only checks this when the
550+ * LDT is faulted in due to subsequent descriptor access.
551+ */
552+
513553 for(i = 0; i < entries; i += entries_per_page)
514554 set_aliased_prot(ldt + i, PAGE_KERNEL_RO);
515555 }
arch/x86/xen/xen-ops.h+2−4
@@ -101,17 +101,15 @@ struct dom0_vga_console_info; · 100 unmodified lines
101101
102102 #ifdef CONFIG_XEN_DOM0
103103 void __init xen_init_vga(const struct dom0_vga_console_info *, size_t size);
104−void __init xen_init_apic(void);
105104 #else
106105 static inline void __init xen_init_vga(const struct dom0_vga_console_info *info,
107106 size_t size)
108107 {
109108 }
110−static inline void __init xen_init_apic(void)
111−{
112−}
113109 #endif
114110
111+void __init xen_init_apic(void);
112+
115113 #ifdef CONFIG_XEN_EFI
116114 extern void xen_efi_init(void);
117115 #else
block/blk-settings.c+2−2
@@ -241,8 +241,8 @@ EXPORT_SYMBOL(blk_queue_bounce_limit); · 240 unmodified lines
241241 * Description:
242242 * Enables a low level driver to set a hard upper limit,
243243 * max_hw_sectors, on the size of requests. max_hw_sectors is set by
244− * the device driver based upon the combined capabilities of I/O
245− * controller and storage device.
244+ * the device driver based upon the capabilities of the I/O
245+ * controller.
246246 *
247247 * max_sectors is a soft limit imposed by the block layer for
248248 * filesystem type requests. This value can be overridden on a
crypto/authencesn.c+12−32
@@ -393,8 +393,6 @@ static int crypto_authenc_esn_genicv(struct aead_request *req, u8 *iv, · 392 unmodified lines
393393 struct scatterlist *cipher = areq_ctx->cipher;
394394 struct scatterlist *hsg = areq_ctx->hsg;
395395 struct scatterlist *tsg = areq_ctx->tsg;
396− struct scatterlist *assoc1;
397− struct scatterlist *assoc2;
398396 unsigned int ivsize = crypto_aead_ivsize(authenc_esn);
399397 unsigned int cryptlen = req->cryptlen;
400398 struct page *dstp;
@@ -412,27 +410,19 @@ static int crypto_authenc_esn_genicv(struct aead_request *req, u8 *iv, · 11 unmodified lines
412410 cryptlen += ivsize;
413411 }
414412
415− if (sg_is_last(assoc))
416− return -EINVAL;
417−
418− assoc1 = assoc + 1;
419− if (sg_is_last(assoc1))
420− return -EINVAL;
421−
422− assoc2 = assoc + 2;
423− if (!sg_is_last(assoc2))
413+ if (assoc->length < 12)
424414 return -EINVAL;
425415
426416 sg_init_table(hsg, 2);
427− sg_set_page(hsg, sg_page(assoc), assoc->length, assoc->offset);
428− sg_set_page(hsg + 1, sg_page(assoc2), assoc2->length, assoc2->offset);
417+ sg_set_page(hsg, sg_page(assoc), 4, assoc->offset);
418+ sg_set_page(hsg + 1, sg_page(assoc), 4, assoc->offset + 8);
429419
430420 sg_init_table(tsg, 1);
431− sg_set_page(tsg, sg_page(assoc1), assoc1->length, assoc1->offset);
421+ sg_set_page(tsg, sg_page(assoc), 4, assoc->offset + 4);
432422
433423 areq_ctx->cryptlen = cryptlen;
434− areq_ctx->headlen = assoc->length + assoc2->length;
435− areq_ctx->trailen = assoc1->length;
424+ areq_ctx->headlen = 8;
425+ areq_ctx->trailen = 4;
436426 areq_ctx->sg = dst;
437427
438428 areq_ctx->complete = authenc_esn_geniv_ahash_done;
@@ -563,8 +553,6 @@ static int crypto_authenc_esn_iverify(struct aead_request *req, u8 *iv, · 124 unmodified lines
563553 struct scatterlist *cipher = areq_ctx->cipher;
564554 struct scatterlist *hsg = areq_ctx->hsg;
565555 struct scatterlist *tsg = areq_ctx->tsg;
566− struct scatterlist *assoc1;
567− struct scatterlist *assoc2;
568556 unsigned int ivsize = crypto_aead_ivsize(authenc_esn);
569557 struct page *srcp;
570558 u8 *vsrc;
@@ -580,27 +568,19 @@ static int crypto_authenc_esn_iverify(struct aead_request *req, u8 *iv, · 9 unmodified lines
580568 cryptlen += ivsize;
581569 }
582570
583− if (sg_is_last(assoc))
584− return -EINVAL;
585−
586− assoc1 = assoc + 1;
587− if (sg_is_last(assoc1))
588− return -EINVAL;
589−
590− assoc2 = assoc + 2;
591− if (!sg_is_last(assoc2))
571+ if (assoc->length < 12)
592572 return -EINVAL;
593573
594574 sg_init_table(hsg, 2);
595− sg_set_page(hsg, sg_page(assoc), assoc->length, assoc->offset);
596− sg_set_page(hsg + 1, sg_page(assoc2), assoc2->length, assoc2->offset);
575+ sg_set_page(hsg, sg_page(assoc), 4, assoc->offset);
576+ sg_set_page(hsg + 1, sg_page(assoc), 4, assoc->offset + 8);
597577
598578 sg_init_table(tsg, 1);
599− sg_set_page(tsg, sg_page(assoc1), assoc1->length, assoc1->offset);
579+ sg_set_page(tsg, sg_page(assoc), 4, assoc->offset + 4);
600580
601581 areq_ctx->cryptlen = cryptlen;
602− areq_ctx->headlen = assoc->length + assoc2->length;
603− areq_ctx->trailen = assoc1->length;
582+ areq_ctx->headlen = 8;
583+ areq_ctx->trailen = 4;
604584 areq_ctx->sg = src;
605585
606586 areq_ctx->complete = authenc_esn_verify_ahash_done;
drivers/acpi/device_pm.c+1−1
@@ -231,7 +231,7 @@ int acpi_device_set_power(struct acpi_device *device, int state) · 230 unmodified lines
231231 dev_warn(&device->dev, "Failed to change power state to %s\n",
232232 acpi_power_state_string(state));
233233 } else {
234− device->power.state = state;
234+ device->power.state = target_state;
235235 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
236236 "Device [%s] transitioned to %s\n",
237237 device->pnp.bus_id,
drivers/ata/ahci_brcmstb.c+4−2
@@ -92,7 +92,7 @@ static inline u32 brcm_sata_readreg(void __iomem *addr) · 91 unmodified lines
9292 * Other architectures (e.g., ARM) either do not support big endian, or
9393 * else leave I/O in little endian mode.
9494 */
95− if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN))
95+ if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
9696 return __raw_readl(addr);
9797 else
9898 return readl_relaxed(addr);
@@ -101,7 +101,7 @@ static inline u32 brcm_sata_readreg(void __iomem *addr) · 2 unmodified lines
101101 static inline void brcm_sata_writereg(u32 val, void __iomem *addr)
102102 {
103103 /* See brcm_sata_readreg() comments */
104− if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN))
104+ if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
105105 __raw_writel(val, addr);
106106 else
107107 writel_relaxed(val, addr);
@@ -209,6 +209,7 @@ static void brcm_sata_init(struct brcm_ahci_priv *priv) · 101 unmodified lines
209209 priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL);
210210 }
211211
212+#ifdef CONFIG_PM_SLEEP
212213 static int brcm_ahci_suspend(struct device *dev)
213214 {
214215 struct ata_host *host = dev_get_drvdata(dev);
@@ -231,6 +232,7 @@ static int brcm_ahci_resume(struct device *dev) · 16 unmodified lines
231232 brcm_sata_phys_enable(priv);
232233 return ahci_platform_resume(dev);
233234 }
235+#endif
234236
235237 static struct scsi_host_template ahci_platform_sht = {
236238 AHCI_SHT(DRV_NAME),
drivers/ata/libata-core.c+3−21
@@ -694,11 +694,11 @@ static int ata_rwcmd_protocol(struct ata_taskfile *tf, struct ata_device *dev) · 693 unmodified lines
694694 * RETURNS:
695695 * Block address read from @tf.
696696 */
697−u64 ata_tf_read_block(const struct ata_taskfile *tf, struct ata_device *dev)
697+u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev)
698698 {
699699 u64 block = 0;
700700
701− if (!dev || tf->flags & ATA_TFLAG_LBA) {
701+ if (tf->flags & ATA_TFLAG_LBA) {
702702 if (tf->flags & ATA_TFLAG_LBA48) {
703703 block |= (u64)tf->hob_lbah << 40;
704704 block |= (u64)tf->hob_lbam << 32;
@@ -2147,24 +2147,6 @@ static int ata_dev_config_ncq(struct ata_device *dev, · 1442 unmodified lines
21472147 return 0;
21482148 }
21492149
2150−static void ata_dev_config_sense_reporting(struct ata_device *dev)
2151−{
2152− unsigned int err_mask;
2153−
2154− if (!ata_id_has_sense_reporting(dev->id))
2155− return;
2156−
2157− if (ata_id_sense_reporting_enabled(dev->id))
2158− return;
2159−
2160− err_mask = ata_dev_set_feature(dev, SETFEATURE_SENSE_DATA, 0x1);
2161− if (err_mask) {
2162− ata_dev_dbg(dev,
2163− "failed to enable Sense Data Reporting, Emask 0x%x\n",
2164− err_mask);
2165− }
2166−}
2167−
21682150 /**
21692151 * ata_dev_configure - Configure the specified ATA/ATAPI device
21702152 * @dev: Target device to configure
@@ -2387,7 +2369,7 @@ int ata_dev_configure(struct ata_device *dev) · 216 unmodified lines
23872369 dev->devslp_timing[i] = sata_setting[j];
23882370 }
23892371 }
2390− ata_dev_config_sense_reporting(dev);
2372+
23912373 dev->cdb_len = 16;
23922374 }
23932375
drivers/ata/libata-eh.c+2−103
@@ -1592,8 +1592,6 @@ static int ata_eh_read_log_10h(struct ata_device *dev, · 1591 unmodified lines
15921592 tf->hob_lbah = buf[10];
15931593 tf->nsect = buf[12];
15941594 tf->hob_nsect = buf[13];
1595− if (ata_id_has_ncq_autosense(dev->id))
1596− tf->auxiliary = buf[14] << 16 | buf[15] << 8 | buf[16];
15971595
15981596 return 0;
15991597 }
@@ -1629,70 +1627,6 @@ unsigned int atapi_eh_tur(struct ata_device *dev, u8 *r_sense_key) · 29 unmodified lines
16291627 return err_mask;
16301628 }
16311629
1632−/**
1633− * ata_eh_request_sense - perform REQUEST_SENSE_DATA_EXT
1634− * @dev: device to perform REQUEST_SENSE_SENSE_DATA_EXT to
1635− * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long)
1636− * @dfl_sense_key: default sense key to use
1637− *
1638− * Perform REQUEST_SENSE_DATA_EXT after the device reported CHECK
1639− * SENSE. This function is EH helper.
1640− *
1641− * LOCKING:
1642− * Kernel thread context (may sleep).
1643− *
1644− * RETURNS:
1645− * encoded sense data on success, 0 on failure or if sense data
1646− * is not available.
1647− */
1648−static u32 ata_eh_request_sense(struct ata_queued_cmd *qc,
1649− struct scsi_cmnd *cmd)
1650−{
1651− struct ata_device *dev = qc->dev;
1652− struct ata_taskfile tf;
1653− unsigned int err_mask;
1654−
1655− if (!cmd)
1656− return 0;
1657−
1658− DPRINTK("ATA request sense\n");
1659− ata_dev_warn(dev, "request sense\n");
1660− if (!ata_id_sense_reporting_enabled(dev->id)) {
1661− ata_dev_warn(qc->dev, "sense data reporting disabled\n");
1662− return 0;
1663− }
1664− ata_tf_init(dev, &tf);
1665−
1666− tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
1667− tf.flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
1668− tf.command = ATA_CMD_REQ_SENSE_DATA;
1669− tf.protocol = ATA_PROT_NODATA;
1670−
1671− err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
1672− /*
1673− * ACS-4 states:
1674− * The device may set the SENSE DATA AVAILABLE bit to one in the
1675− * STATUS field and clear the ERROR bit to zero in the STATUS field
1676− * to indicate that the command returned completion without an error
1677− * and the sense data described in table 306 is available.
1678− *
1679− * IOW the 'ATA_SENSE' bit might not be set even though valid
1680− * sense data is available.
1681− * So check for both.
1682− */
1683− if ((tf.command & ATA_SENSE) ||
1684− tf.lbah != 0 || tf.lbam != 0 || tf.lbal != 0) {
1685− ata_scsi_set_sense(cmd, tf.lbah, tf.lbam, tf.lbal);
1686− qc->flags |= ATA_QCFLAG_SENSE_VALID;
1687− ata_dev_warn(dev, "sense data %02x/%02x/%02x\n",
1688− tf.lbah, tf.lbam, tf.lbal);
1689− } else {
1690− ata_dev_warn(dev, "request sense failed stat %02x emask %x\n",
1691− tf.command, err_mask);
1692− }
1693− return err_mask;
1694−}
1695−
16961630 /**
16971631 * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE
16981632 * @dev: device to perform REQUEST_SENSE to
@@ -1855,19 +1789,6 @@ void ata_eh_analyze_ncq_error(struct ata_link *link) · 156 unmodified lines
18551789 memcpy(&qc->result_tf, &tf, sizeof(tf));
18561790 qc->result_tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
18571791 qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ;
1858− if (qc->result_tf.auxiliary) {
1859− char sense_key, asc, ascq;
1860−
1861− sense_key = (qc->result_tf.auxiliary >> 16) & 0xff;
1862− asc = (qc->result_tf.auxiliary >> 8) & 0xff;
1863− ascq = qc->result_tf.auxiliary & 0xff;
1864− ata_dev_dbg(dev, "NCQ Autosense %02x/%02x/%02x\n",
1865− sense_key, asc, ascq);
1866− ata_scsi_set_sense(qc->scsicmd, sense_key, asc, ascq);
1867− ata_scsi_set_sense_information(qc->scsicmd, &qc->result_tf);
1868− qc->flags |= ATA_QCFLAG_SENSE_VALID;
1869− }
1870−
18711792 ehc->i.err_mask &= ~AC_ERR_DEV;
18721793 }
18731794
@@ -1897,27 +1818,6 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc, · 23 unmodified lines
18971818 return ATA_EH_RESET;
18981819 }
18991820
1900− /*
1901− * Sense data reporting does not work if the
1902− * device fault bit is set.
1903− */
1904− if ((stat & ATA_SENSE) && !(stat & ATA_DF) &&
1905− !(qc->flags & ATA_QCFLAG_SENSE_VALID)) {
1906− if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) {
1907− tmp = ata_eh_request_sense(qc, qc->scsicmd);
1908− if (tmp)
1909− qc->err_mask |= tmp;
1910− else
1911− ata_scsi_set_sense_information(qc->scsicmd, tf);
1912− } else {
1913− ata_dev_warn(qc->dev, "sense data available but port frozen\n");
1914− }
1915− }
1916−
1917− /* Set by NCQ autosense or request sense above */
1918− if (qc->flags & ATA_QCFLAG_SENSE_VALID)
1919− return 0;
1920−
19211821 if (stat & (ATA_ERR | ATA_DF))
19221822 qc->err_mask |= AC_ERR_DEV;
19231823 else
@@ -2661,15 +2561,14 @@ static void ata_eh_link_report(struct ata_link *link) · 737 unmodified lines
26612561
26622562 #ifdef CONFIG_ATA_VERBOSE_ERROR
26632563 if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ |
2664− ATA_SENSE | ATA_ERR)) {
2564+ ATA_ERR)) {
26652565 if (res->command & ATA_BUSY)
26662566 ata_dev_err(qc->dev, "status: { Busy }\n");
26672567 else
2668− ata_dev_err(qc->dev, "status: { %s%s%s%s%s}\n",
2568+ ata_dev_err(qc->dev, "status: { %s%s%s%s}\n",
26692569 res->command & ATA_DRDY ? "DRDY " : "",
26702570 res->command & ATA_DF ? "DF " : "",
26712571 res->command & ATA_DRQ ? "DRQ " : "",
2672− res->command & ATA_SENSE ? "SENSE " : "",
26732572 res->command & ATA_ERR ? "ERR " : "");
26742573 }
26752574
drivers/ata/libata-scsi.c+2−19
@@ -270,28 +270,13 @@ DEVICE_ATTR(unload_heads, S_IRUGO | S_IWUSR, · 269 unmodified lines
270270 ata_scsi_park_show, ata_scsi_park_store);
271271 EXPORT_SYMBOL_GPL(dev_attr_unload_heads);
272272
273−void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq)
273+static void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq)
274274 {
275− if (!cmd)
276− return;
277−
278275 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
279276
280277 scsi_build_sense_buffer(0, cmd->sense_buffer, sk, asc, ascq);
281278 }
282279
283−void ata_scsi_set_sense_information(struct scsi_cmnd *cmd,
284− const struct ata_taskfile *tf)
285−{
286− u64 information;
287−
288− if (!cmd)
289− return;
290−
291− information = ata_tf_read_block(tf, NULL);
292− scsi_set_sense_information(cmd->sense_buffer, information);
293−}
294−
295280 static ssize_t
296281 ata_scsi_em_message_store(struct device *dev, struct device_attribute *attr,
297282 const char *buf, size_t count)
@@ -1792,9 +1777,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) · 1494 unmodified lines
17921777 ((cdb[2] & 0x20) || need_sense)) {
17931778 ata_gen_passthru_sense(qc);
17941779 } else {
1795− if (qc->flags & ATA_QCFLAG_SENSE_VALID) {
1796− cmd->result = SAM_STAT_CHECK_CONDITION;
1797− } else if (!need_sense) {
1780+ if (!need_sense) {
17981781 cmd->result = SAM_STAT_GOOD;
17991782 } else {
18001783 /* TODO: decide which descriptor format to use
drivers/ata/libata.h+1−5
@@ -67,8 +67,7 @@ extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag); · 66 unmodified lines
6767 extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
6868 u64 block, u32 n_block, unsigned int tf_flags,
6969 unsigned int tag);
70−extern u64 ata_tf_read_block(const struct ata_taskfile *tf,
71− struct ata_device *dev);
70+extern u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev);
7271 extern unsigned ata_exec_internal(struct ata_device *dev,
7372 struct ata_taskfile *tf, const u8 *cdb,
7473 int dma_dir, void *buf, unsigned int buflen,
@@ -138,9 +137,6 @@ extern int ata_scsi_add_hosts(struct ata_host *host, · 63 unmodified lines
138137 struct scsi_host_template *sht);
139138 extern void ata_scsi_scan_host(struct ata_port *ap, int sync);
140139 extern int ata_scsi_offline_dev(struct ata_device *dev);
141−extern void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq);
142−extern void ata_scsi_set_sense_information(struct scsi_cmnd *cmd,
143− const struct ata_taskfile *tf);
144140 extern void ata_scsi_media_change_notify(struct ata_device *dev);
145141 extern void ata_scsi_hotplug(struct work_struct *work);
146142 extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
drivers/ata/sata_sx4.c+12−4
@@ -1238,8 +1238,12 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host) · 1237 unmodified lines
12381238 readl(mmio + PDC_SDRAM_CONTROL);
12391239
12401240 /* Turn on for ECC */
1241− pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1242− PDC_DIMM_SPD_TYPE, &spd0);
1241+ if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1242+ PDC_DIMM_SPD_TYPE, &spd0)) {
1243+ pr_err("Failed in i2c read: device=%#x, subaddr=%#x\n",
1244+ PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
1245+ return 1;
1246+ }
12431247 if (spd0 == 0x02) {
12441248 data |= (0x01 << 16);
12451249 writel(data, mmio + PDC_SDRAM_CONTROL);
@@ -1380,8 +1384,12 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host) · 134 unmodified lines
13801384
13811385 /* ECC initiliazation. */
13821386
1383− pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1384− PDC_DIMM_SPD_TYPE, &spd0);
1387+ if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1388+ PDC_DIMM_SPD_TYPE, &spd0)) {
1389+ pr_err("Failed in i2c read: device=%#x, subaddr=%#x\n",
1390+ PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
1391+ return 1;
1392+ }
13851393 if (spd0 == 0x02) {
13861394 void *buf;
13871395 VPRINTK("Start ECC initialization\n");
drivers/base/regmap/regcache-rbtree.c+14−5
@@ -296,11 +296,20 @@ static int regcache_rbtree_insert_to_block(struct regmap *map, · 295 unmodified lines
296296 if (!blk)
297297 return -ENOMEM;
298298
299− present = krealloc(rbnode->cache_present,
300− BITS_TO_LONGS(blklen) * sizeof(*present), GFP_KERNEL);
301− if (!present) {
302− kfree(blk);
303− return -ENOMEM;
299+ if (BITS_TO_LONGS(blklen) > BITS_TO_LONGS(rbnode->blklen)) {
300+ present = krealloc(rbnode->cache_present,
301+ BITS_TO_LONGS(blklen) * sizeof(*present),
302+ GFP_KERNEL);
303+ if (!present) {
304+ kfree(blk);
305+ return -ENOMEM;
306+ }
307+
308+ memset(present + BITS_TO_LONGS(rbnode->blklen), 0,
309+ (BITS_TO_LONGS(blklen) - BITS_TO_LONGS(rbnode->blklen))
310+ * sizeof(*present));
311+ } else {
312+ present = rbnode->cache_present;
304313 }
305314
306315 /* insert the register value in the correct place in the rbnode block */
drivers/block/rbd.c+17−5
@@ -523,6 +523,7 @@ void rbd_warn(struct rbd_device *rbd_dev, const char *fmt, ...) · 522 unmodified lines
523523 # define rbd_assert(expr) ((void) 0)
524524 #endif /* !RBD_DEBUG */
525525
526+static void rbd_osd_copyup_callback(struct rbd_obj_request *obj_request);
526527 static int rbd_img_obj_request_submit(struct rbd_obj_request *obj_request);
527528 static void rbd_img_parent_read(struct rbd_obj_request *obj_request);
528529 static void rbd_dev_remove_parent(struct rbd_device *rbd_dev);
@@ -1818,6 +1819,16 @@ static void rbd_osd_stat_callback(struct rbd_obj_request *obj_request) · 1289 unmodified lines
18181819 obj_request_done_set(obj_request);
18191820 }
18201821
1822+static void rbd_osd_call_callback(struct rbd_obj_request *obj_request)
1823+{
1824+ dout("%s: obj %p\n", __func__, obj_request);
1825+
1826+ if (obj_request_img_data_test(obj_request))
1827+ rbd_osd_copyup_callback(obj_request);
1828+ else
1829+ obj_request_done_set(obj_request);
1830+}
1831+
18211832 static void rbd_osd_req_callback(struct ceph_osd_request *osd_req,
18221833 struct ceph_msg *msg)
18231834 {
@@ -1866,6 +1877,8 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, · 42 unmodified lines
18661877 rbd_osd_discard_callback(obj_request);
18671878 break;
18681879 case CEPH_OSD_OP_CALL:
1880+ rbd_osd_call_callback(obj_request);
1881+ break;
18691882 case CEPH_OSD_OP_NOTIFY_ACK:
18701883 case CEPH_OSD_OP_WATCH:
18711884 rbd_osd_trivial_callback(obj_request);
@@ -2530,13 +2543,15 @@ out_unwind: · 658 unmodified lines
25302543 }
25312544
25322545 static void
2533−rbd_img_obj_copyup_callback(struct rbd_obj_request *obj_request)
2546+rbd_osd_copyup_callback(struct rbd_obj_request *obj_request)
25342547 {
25352548 struct rbd_img_request *img_request;
25362549 struct rbd_device *rbd_dev;
25372550 struct page **pages;
25382551 u32 page_count;
25392552
2553+ dout("%s: obj %p\n", __func__, obj_request);
2554+
25402555 rbd_assert(obj_request->type == OBJ_REQUEST_BIO ||
25412556 obj_request->type == OBJ_REQUEST_NODATA);
25422557 rbd_assert(obj_request_img_data_test(obj_request));
@@ -2563,9 +2578,7 @@ rbd_img_obj_copyup_callback(struct rbd_obj_request *obj_request) · 20 unmodified lines
25632578 if (!obj_request->result)
25642579 obj_request->xferred = obj_request->length;
25652580
2566− /* Finish up with the normal image object callback */
2567−
2568− rbd_img_obj_callback(obj_request);
2581+ obj_request_done_set(obj_request);
25692582 }
25702583
25712584 static void
@@ -2650,7 +2663,6 @@ rbd_img_obj_parent_read_full_callback(struct rbd_img_request *img_request) · 78 unmodified lines
26502663
26512664 /* All set, send it off. */
26522665
2653− orig_request->callback = rbd_img_obj_copyup_callback;
26542666 osdc = &rbd_dev->rbd_client->client->osdc;
26552667 img_result = rbd_obj_request_submit(osdc, orig_request);
26562668 if (!img_result)
drivers/block/xen-blkback/blkback.c+2−2
@@ -369,8 +369,8 @@ static void purge_persistent_gnt(struct xen_blkif *blkif) · 368 unmodified lines
369369 return;
370370 }
371371
372− if (work_pending(&blkif->persistent_purge_work)) {
373− pr_alert_ratelimited("Scheduled work from previous purge is still pending, cannot purge list\n");
372+ if (work_busy(&blkif->persistent_purge_work)) {
373+ pr_alert_ratelimited("Scheduled work from previous purge is still busy, cannot purge list\n");
374374 return;
375375 }
376376
drivers/block/xen-blkfront.c+72−56
@@ -179,6 +179,7 @@ static DEFINE_SPINLOCK(minor_lock); · 178 unmodified lines
179179 ((_segs + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
180180
181181 static int blkfront_setup_indirect(struct blkfront_info *info);
182+static int blkfront_gather_backend_features(struct blkfront_info *info);
182183
183184 static int get_id_from_freelist(struct blkfront_info *info)
184185 {
@@ -1128,8 +1129,10 @@ static void blkif_completion(struct blk_shadow *s, struct blkfront_info *info, · 943 unmodified lines
11281129 * Add the used indirect page back to the list of
11291130 * available pages for indirect grefs.
11301131 */
1131− indirect_page = pfn_to_page(s->indirect_grants[i]->pfn);
1132− list_add(&indirect_page->lru, &info->indirect_pages);
1132+ if (!info->feature_persistent) {
1133+ indirect_page = pfn_to_page(s->indirect_grants[i]->pfn);
1134+ list_add(&indirect_page->lru, &info->indirect_pages);
1135+ }
11331136 s->indirect_grants[i]->gref = GRANT_INVALID_REF;
11341137 list_add_tail(&s->indirect_grants[i]->node, &info->grants);
11351138 }
@@ -1519,7 +1522,7 @@ static int blkif_recover(struct blkfront_info *info) · 383 unmodified lines
15191522 info->shadow_free = info->ring.req_prod_pvt;
15201523 info->shadow[BLK_RING_SIZE(info)-1].req.u.rw.id = 0x0fffffff;
15211524
1522− rc = blkfront_setup_indirect(info);
1525+ rc = blkfront_gather_backend_features(info);
15231526 if (rc) {
15241527 kfree(copy);
15251528 return rc;
@@ -1720,20 +1723,13 @@ static void blkfront_setup_discard(struct blkfront_info *info) · 194 unmodified lines
17201723
17211724 static int blkfront_setup_indirect(struct blkfront_info *info)
17221725 {
1723− unsigned int indirect_segments, segs;
1726+ unsigned int segs;
17241727 int err, i;
17251728
1726− err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
1727− "feature-max-indirect-segments", "%u", &indirect_segments,
1728− NULL);
1729− if (err) {
1730− info->max_indirect_segments = 0;
1729+ if (info->max_indirect_segments == 0)
17311730 segs = BLKIF_MAX_SEGMENTS_PER_REQUEST;
1732− } else {
1733− info->max_indirect_segments = min(indirect_segments,
1734− xen_blkif_max_segments);
1731+ else
17351732 segs = info->max_indirect_segments;
1736− }
17371733
17381734 err = fill_grant_buffer(info, (segs + INDIRECT_GREFS(segs)) * BLK_RING_SIZE(info));
17391735 if (err)
@@ -1796,6 +1792,68 @@ out_of_memory: · 56 unmodified lines
17961792 return -ENOMEM;
17971793 }
17981794
1795+/*
1796+ * Gather all backend feature-*
1797+ */
1798+static int blkfront_gather_backend_features(struct blkfront_info *info)
1799+{
1800+ int err;
1801+ int barrier, flush, discard, persistent;
1802+ unsigned int indirect_segments;
1803+
1804+ info->feature_flush = 0;
1805+
1806+ err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
1807+ "feature-barrier", "%d", &barrier,
1808+ NULL);
1809+
1810+ /*
1811+ * If there's no "feature-barrier" defined, then it means
1812+ * we're dealing with a very old backend which writes
1813+ * synchronously; nothing to do.
1814+ *
1815+ * If there are barriers, then we use flush.
1816+ */
1817+ if (!err && barrier)
1818+ info->feature_flush = REQ_FLUSH | REQ_FUA;
1819+ /*
1820+ * And if there is "feature-flush-cache" use that above
1821+ * barriers.
1822+ */
1823+ err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
1824+ "feature-flush-cache", "%d", &flush,
1825+ NULL);
1826+
1827+ if (!err && flush)
1828+ info->feature_flush = REQ_FLUSH;
1829+
1830+ err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
1831+ "feature-discard", "%d", &discard,
1832+ NULL);
1833+
1834+ if (!err && discard)
1835+ blkfront_setup_discard(info);
1836+
1837+ err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
1838+ "feature-persistent", "%u", &persistent,
1839+ NULL);
1840+ if (err)
1841+ info->feature_persistent = 0;
1842+ else
1843+ info->feature_persistent = persistent;
1844+
1845+ err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
1846+ "feature-max-indirect-segments", "%u", &indirect_segments,
1847+ NULL);
1848+ if (err)
1849+ info->max_indirect_segments = 0;
1850+ else
1851+ info->max_indirect_segments = min(indirect_segments,
1852+ xen_blkif_max_segments);
1853+
1854+ return blkfront_setup_indirect(info);
1855+}
1856+
17991857 /*
18001858 * Invoked when the backend is finally 'ready' (and has told produced
18011859 * the details about the physical device - #sectors, size, etc).
@@ -1807,7 +1865,6 @@ static void blkfront_connect(struct blkfront_info *info) · 5 unmodified lines
18071865 unsigned int physical_sector_size;
18081866 unsigned int binfo;
18091867 int err;
1810− int barrier, flush, discard, persistent;
18111868
18121869 switch (info->connected) {
18131870 case BLKIF_STATE_CONNECTED:
@@ -1864,48 +1921,7 @@ static void blkfront_connect(struct blkfront_info *info) · 50 unmodified lines
18641921 if (err != 1)
18651922 physical_sector_size = sector_size;
18661923
1867− info->feature_flush = 0;
1868−
1869− err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
1870− "feature-barrier", "%d", &barrier,
1871− NULL);
1872−
1873− /*
1874− * If there's no "feature-barrier" defined, then it means
1875− * we're dealing with a very old backend which writes
1876− * synchronously; nothing to do.
1877− *
1878− * If there are barriers, then we use flush.
1879− */
1880− if (!err && barrier)
1881− info->feature_flush = REQ_FLUSH | REQ_FUA;
1882− /*
1883− * And if there is "feature-flush-cache" use that above
1884− * barriers.
1885− */
1886− err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
1887− "feature-flush-cache", "%d", &flush,
1888− NULL);
1889−
1890− if (!err && flush)
1891− info->feature_flush = REQ_FLUSH;
1892−
1893− err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
1894− "feature-discard", "%d", &discard,
1895− NULL);
1896−
1897− if (!err && discard)
1898− blkfront_setup_discard(info);
1899−
1900− err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
1901− "feature-persistent", "%u", &persistent,
1902− NULL);
1903− if (err)
1904− info->feature_persistent = 0;
1905− else
1906− info->feature_persistent = persistent;
1907−
1908− err = blkfront_setup_indirect(info);
1924+ err = blkfront_gather_backend_features(info);
19091925 if (err) {
19101926 xenbus_dev_fatal(info->xbdev, err, "setup_indirect at %s",
19111927 info->xbdev->otherend);
drivers/block/zram/zram_drv.c+2−4
@@ -496,10 +496,9 @@ static void zram_meta_free(struct zram_meta *meta, u64 disksize) · 495 unmodified lines
496496 kfree(meta);
497497 }
498498
499−static struct zram_meta *zram_meta_alloc(int device_id, u64 disksize)
499+static struct zram_meta *zram_meta_alloc(char *pool_name, u64 disksize)
500500 {
501501 size_t num_pages;
502− char pool_name[8];
503502 struct zram_meta *meta = kmalloc(sizeof(*meta), GFP_KERNEL);
504503
505504 if (!meta)
@@ -512,7 +511,6 @@ static struct zram_meta *zram_meta_alloc(int device_id, u64 disksize) · 6 unmodified lines
512511 goto out_error;
513512 }
514513
515− snprintf(pool_name, sizeof(pool_name), "zram%d", device_id);
516514 meta->mem_pool = zs_create_pool(pool_name, GFP_NOIO | __GFP_HIGHMEM);
517515 if (!meta->mem_pool) {
518516 pr_err("Error creating memory pool\n");
@@ -1031,7 +1029,7 @@ static ssize_t disksize_store(struct device *dev, · 512 unmodified lines
10311029 return -EINVAL;
10321030
10331031 disksize = PAGE_ALIGN(disksize);
1034− meta = zram_meta_alloc(zram->disk->first_minor, disksize);
1032+ meta = zram_meta_alloc(zram->disk->disk_name, disksize);
10351033 if (!meta)
10361034 return -ENOMEM;
10371035
drivers/char/hw_random/core.c+1−1
@@ -429,7 +429,7 @@ static int hwrng_fillfn(void *unused) · 428 unmodified lines
429429 static void start_khwrngd(void)
430430 {
431431 hwrng_fill = kthread_run(hwrng_fillfn, NULL, "hwrng");
432− if (hwrng_fill == ERR_PTR(-ENOMEM)) {
432+ if (IS_ERR(hwrng_fill)) {
433433 pr_err("hwrng_fill thread creation failed");
434434 hwrng_fill = NULL;
435435 }
drivers/clk/pxa/clk-pxa3xx.c+1−1
@@ -126,7 +126,7 @@ PARENTS(pxa3xx_ac97_bus) = { "ring_osc_60mhz", "ac97" }; · 125 unmodified lines
126126 PARENTS(pxa3xx_sbus) = { "ring_osc_60mhz", "system_bus" };
127127 PARENTS(pxa3xx_smemcbus) = { "ring_osc_60mhz", "smemc" };
128128
129−#define CKEN_AB(bit) ((CKEN_ ## bit > 31) ? &CKENA : &CKENB)
129+#define CKEN_AB(bit) ((CKEN_ ## bit > 31) ? &CKENB : &CKENA)
130130 #define PXA3XX_CKEN(dev_id, con_id, parents, mult_lp, div_lp, mult_hp, \
131131 div_hp, bit, is_lp, flags) \
132132 PXA_CKEN(dev_id, con_id, bit, parents, mult_lp, div_lp, \
drivers/clocksource/sh_cmt.c+6−0
@@ -661,6 +661,9 @@ static void sh_cmt_clocksource_suspend(struct clocksource *cs) · 660 unmodified lines
661661 {
662662 struct sh_cmt_channel *ch = cs_to_sh_cmt(cs);
663663
664+ if (!ch->cs_enabled)
665+ return;
666+
664667 sh_cmt_stop(ch, FLAG_CLOCKSOURCE);
665668 pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev);
666669 }
@@ -669,6 +672,9 @@ static void sh_cmt_clocksource_resume(struct clocksource *cs) · 2 unmodified lines
669672 {
670673 struct sh_cmt_channel *ch = cs_to_sh_cmt(cs);
671674
675+ if (!ch->cs_enabled)
676+ return;
677+
672678 pm_genpd_syscore_poweron(&ch->cmt->pdev->dev);
673679 sh_cmt_start(ch, FLAG_CLOCKSOURCE);
674680 }
drivers/cpufreq/cpufreq.c+55−53
@@ -1002,7 +1002,7 @@ static int cpufreq_add_dev_symlink(struct cpufreq_policy *policy) · 1001 unmodified lines
10021002 int ret = 0;
10031003
10041004 /* Some related CPUs might not be present (physically hotplugged) */
1005− for_each_cpu_and(j, policy->related_cpus, cpu_present_mask) {
1005+ for_each_cpu(j, policy->real_cpus) {
10061006 if (j == policy->kobj_cpu)
10071007 continue;
10081008
@@ -1019,7 +1019,7 @@ static void cpufreq_remove_dev_symlink(struct cpufreq_policy *policy) · 10 unmodified lines
10191019 unsigned int j;
10201020
10211021 /* Some related CPUs might not be present (physically hotplugged) */
1022− for_each_cpu_and(j, policy->related_cpus, cpu_present_mask) {
1022+ for_each_cpu(j, policy->real_cpus) {
10231023 if (j == policy->kobj_cpu)
10241024 continue;
10251025
@@ -1163,11 +1163,14 @@ static struct cpufreq_policy *cpufreq_policy_alloc(struct device *dev) · 137 unmodified lines
11631163 if (!zalloc_cpumask_var(&policy->related_cpus, GFP_KERNEL))
11641164 goto err_free_cpumask;
11651165
1166+ if (!zalloc_cpumask_var(&policy->real_cpus, GFP_KERNEL))
1167+ goto err_free_rcpumask;
1168+
11661169 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, &dev->kobj,
11671170 "cpufreq");
11681171 if (ret) {
11691172 pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret);
1170− goto err_free_rcpumask;
1173+ goto err_free_real_cpus;
11711174 }
11721175
11731176 INIT_LIST_HEAD(&policy->policy_list);
@@ -1184,6 +1187,8 @@ static struct cpufreq_policy *cpufreq_policy_alloc(struct device *dev) · 10 unmodified lines
11841187
11851188 return policy;
11861189
1190+err_free_real_cpus:
1191+ free_cpumask_var(policy->real_cpus);
11871192 err_free_rcpumask:
11881193 free_cpumask_var(policy->related_cpus);
11891194 err_free_cpumask:
@@ -1234,6 +1239,7 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy, bool notify) · 44 unmodified lines
12341239 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
12351240
12361241 cpufreq_policy_put_kobj(policy, notify);
1242+ free_cpumask_var(policy->real_cpus);
12371243 free_cpumask_var(policy->related_cpus);
12381244 free_cpumask_var(policy->cpus);
12391245 kfree(policy);
@@ -1258,14 +1264,17 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) · 18 unmodified lines
12581264
12591265 pr_debug("adding CPU %u\n", cpu);
12601266
1261− /*
1262− * Only possible if 'cpu' wasn't physically present earlier and we are
1263− * here from subsys_interface add callback. A hotplug notifier will
1264− * follow and we will handle it like logical CPU hotplug then. For now,
1265− * just create the sysfs link.
1266− */
1267− if (cpu_is_offline(cpu))
1268− return add_cpu_dev_symlink(per_cpu(cpufreq_cpu_data, cpu), cpu);
1267+ if (cpu_is_offline(cpu)) {
1268+ /*
1269+ * Only possible if we are here from the subsys_interface add
1270+ * callback. A hotplug notifier will follow and we will handle
1271+ * it as CPU online then. For now, just create the sysfs link,
1272+ * unless there is no policy or the link is already present.
1273+ */
1274+ policy = per_cpu(cpufreq_cpu_data, cpu);
1275+ return policy && !cpumask_test_and_set_cpu(cpu, policy->real_cpus)
1276+ ? add_cpu_dev_symlink(policy, cpu) : 0;
1277+ }
12691278
12701279 if (!down_read_trylock(&cpufreq_rwsem))
12711280 return 0;
@@ -1307,6 +1316,10 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) · 35 unmodified lines
13071316 /* related cpus should atleast have policy->cpus */
13081317 cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus);
13091318
1319+ /* Remember which CPUs have been present at the policy creation time. */
1320+ if (!recover_policy)
1321+ cpumask_and(policy->real_cpus, policy->cpus, cpu_present_mask);
1322+
13101323 /*
13111324 * affected cpus must always be the one, which are online. We aren't
13121325 * managing offline cpus here.
@@ -1420,8 +1433,7 @@ nomem_out: · 107 unmodified lines
14201433 return ret;
14211434 }
14221435
1423−static int __cpufreq_remove_dev_prepare(struct device *dev,
1424− struct subsys_interface *sif)
1436+static int __cpufreq_remove_dev_prepare(struct device *dev)
14251437 {
14261438 unsigned int cpu = dev->id;
14271439 int ret = 0;
@@ -1437,10 +1449,8 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, · 9 unmodified lines
14371449
14381450 if (has_target()) {
14391451 ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
1440− if (ret) {
1452+ if (ret)
14411453 pr_err("%s: Failed to stop governor\n", __func__);
1442− return ret;
1443− }
14441454 }
14451455
14461456 down_write(&policy->rwsem);
@@ -1473,8 +1483,7 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, · 26 unmodified lines
14731483 return ret;
14741484 }
14751485
1476−static int __cpufreq_remove_dev_finish(struct device *dev,
1477− struct subsys_interface *sif)
1486+static int __cpufreq_remove_dev_finish(struct device *dev)
14781487 {
14791488 unsigned int cpu = dev->id;
14801489 int ret;
@@ -1492,10 +1501,8 @@ static int __cpufreq_remove_dev_finish(struct device *dev, · 11 unmodified lines
14921501 /* If cpu is last user of policy, free policy */
14931502 if (has_target()) {
14941503 ret = __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
1495− if (ret) {
1504+ if (ret)
14961505 pr_err("%s: Failed to exit governor\n", __func__);
1497− return ret;
1498− }
14991506 }
15001507
15011508 /*
@@ -1506,10 +1513,6 @@ static int __cpufreq_remove_dev_finish(struct device *dev, · 4 unmodified lines
15061513 if (cpufreq_driver->exit)
15071514 cpufreq_driver->exit(policy);
15081515
1509− /* Free the policy only if the driver is getting removed. */
1510− if (sif)
1511− cpufreq_policy_free(policy, true);
1512−
15131516 return 0;
15141517 }
15151518
@@ -1521,42 +1524,41 @@ static int __cpufreq_remove_dev_finish(struct device *dev, · 5 unmodified lines
15211524 static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
15221525 {
15231526 unsigned int cpu = dev->id;
1524− int ret;
1525−
1526− /*
1527− * Only possible if 'cpu' is getting physically removed now. A hotplug
1528− * notifier should have already been called and we just need to remove
1529− * link or free policy here.
1530− */
1531− if (cpu_is_offline(cpu)) {
1532− struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);
1533− struct cpumask mask;
1527+ struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);
15341528
1535− if (!policy)
1536− return 0;
1529+ if (!policy)
1530+ return 0;
15371531
1538− cpumask_copy(&mask, policy->related_cpus);
1539− cpumask_clear_cpu(cpu, &mask);
1532+ if (cpu_online(cpu)) {
1533+ __cpufreq_remove_dev_prepare(dev);
1534+ __cpufreq_remove_dev_finish(dev);
1535+ }
15401536
1541− /*
1542− * Free policy only if all policy->related_cpus are removed
1543− * physically.
1544− */
1545− if (cpumask_intersects(&mask, cpu_present_mask)) {
1546− remove_cpu_dev_symlink(policy, cpu);
1547− return 0;
1548− }
1537+ cpumask_clear_cpu(cpu, policy->real_cpus);
15491538
1539+ if (cpumask_empty(policy->real_cpus)) {
15501540 cpufreq_policy_free(policy, true);
15511541 return 0;
15521542 }
15531543
1554− ret = __cpufreq_remove_dev_prepare(dev, sif);
1544+ if (cpu != policy->kobj_cpu) {
1545+ remove_cpu_dev_symlink(policy, cpu);
1546+ } else {
1547+ /*
1548+ * The CPU owning the policy object is going away. Move it to
1549+ * another suitable CPU.
1550+ */
1551+ unsigned int new_cpu = cpumask_first(policy->real_cpus);
1552+ struct device *new_dev = get_cpu_device(new_cpu);
1553+
1554+ dev_dbg(dev, "%s: Moving policy object to CPU%u\n", __func__, new_cpu);
15551555
1556− if (!ret)
1557− ret = __cpufreq_remove_dev_finish(dev, sif);
1556+ sysfs_remove_link(&new_dev->kobj, "cpufreq");
1557+ policy->kobj_cpu = new_cpu;
1558+ WARN_ON(kobject_move(&policy->kobj, &new_dev->kobj));
1559+ }
15581560
1559− return ret;
1561+ return 0;
15601562 }
15611563
15621564 static void handle_update(struct work_struct *work)
@@ -2395,11 +2397,11 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb, · 832 unmodified lines
23952397 break;
23962398
23972399 case CPU_DOWN_PREPARE:
2398− __cpufreq_remove_dev_prepare(dev, NULL);
2400+ __cpufreq_remove_dev_prepare(dev);
23992401 break;
24002402
24012403 case CPU_POST_DEAD:
2402− __cpufreq_remove_dev_finish(dev, NULL);
2404+ __cpufreq_remove_dev_finish(dev);
24032405 break;
24042406
24052407 case CPU_DOWN_FAILED:
drivers/cpufreq/intel_pstate.c+1−0
@@ -681,6 +681,7 @@ static struct cpu_defaults knl_params = { · 680 unmodified lines
681681 .get_max = core_get_max_pstate,
682682 .get_min = core_get_min_pstate,
683683 .get_turbo = knl_get_turbo_pstate,
684+ .get_scaling = core_get_scaling,
684685 .set = core_set_pstate,
685686 },
686687 };
drivers/cpufreq/loongson2_cpufreq.c+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020 #include <asm/clock.h>
2121 #include <asm/idle.h>
2222
23−#include <asm/mach-loongson/loongson.h>
23+#include <asm/mach-loongson64/loongson.h>
2424
2525 static uint nowait;
2626
drivers/crypto/caam/caamhash.c+4−3
@@ -909,13 +909,14 @@ static int ahash_final_ctx(struct ahash_request *req) · 908 unmodified lines
909909 state->buflen_1;
910910 u32 *sh_desc = ctx->sh_desc_fin, *desc;
911911 dma_addr_t ptr = ctx->sh_desc_fin_dma;
912− int sec4_sg_bytes;
912+ int sec4_sg_bytes, sec4_sg_src_index;
913913 int digestsize = crypto_ahash_digestsize(ahash);
914914 struct ahash_edesc *edesc;
915915 int ret = 0;
916916 int sh_len;
917917
918− sec4_sg_bytes = (1 + (buflen ? 1 : 0)) * sizeof(struct sec4_sg_entry);
918+ sec4_sg_src_index = 1 + (buflen ? 1 : 0);
919+ sec4_sg_bytes = sec4_sg_src_index * sizeof(struct sec4_sg_entry);
919920
920921 /* allocate space for base edesc and hw desc commands, link tables */
921922 edesc = kmalloc(sizeof(struct ahash_edesc) + DESC_JOB_IO_LEN +
@@ -942,7 +943,7 @@ static int ahash_final_ctx(struct ahash_request *req) · 20 unmodified lines
942943 state->buf_dma = try_buf_map_to_sec4_sg(jrdev, edesc->sec4_sg + 1,
943944 buf, state->buf_dma, buflen,
944945 last_buflen);
945− (edesc->sec4_sg + sec4_sg_bytes - 1)->len |= SEC4_SG_LEN_FIN;
946+ (edesc->sec4_sg + sec4_sg_src_index - 1)->len |= SEC4_SG_LEN_FIN;
946947
947948 edesc->sec4_sg_dma = dma_map_single(jrdev, edesc->sec4_sg,
948949 sec4_sg_bytes, DMA_TO_DEVICE);
drivers/crypto/ixp4xx_crypto.c+0−1
@@ -905,7 +905,6 @@ static int ablk_perform(struct ablkcipher_request *req, int encrypt) · 904 unmodified lines
905905 crypt->mode |= NPE_OP_NOT_IN_PLACE;
906906 /* This was never tested by Intel
907907 * for more than one dst buffer, I think. */
908− BUG_ON(req->dst->length < nbytes);
909908 req_ctx->dst = NULL;
910909 if (!chainup_buffers(dev, req->dst, nbytes, &dst_hook,
911910 flags, DMA_FROM_DEVICE))
drivers/crypto/nx/nx-sha256.c+16−11
@@ -71,7 +71,6 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data, · 70 unmodified lines
7171 struct sha256_state *sctx = shash_desc_ctx(desc);
7272 struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
7373 struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb;
74− struct nx_sg *in_sg;
7574 struct nx_sg *out_sg;
7675 u64 to_process = 0, leftover, total;
7776 unsigned long irq_flags;
@@ -97,7 +96,6 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data, · 19 unmodified lines
9796 NX_CPB_FDM(csbcpb) |= NX_FDM_INTERMEDIATE;
9897 NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION;
9998
100− in_sg = nx_ctx->in_sg;
10199 max_sg_len = min_t(u64, nx_ctx->ap->sglen,
102100 nx_driver.of.max_sg_len/sizeof(struct nx_sg));
103101 max_sg_len = min_t(u64, max_sg_len,
@@ -114,17 +112,12 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data, · 10 unmodified lines
114112 }
115113
116114 do {
117− /*
118− * to_process: the SHA256_BLOCK_SIZE data chunk to process in
119− * this update. This value is also restricted by the sg list
120− * limits.
121− */
122− to_process = total - to_process;
123− to_process = to_process & ~(SHA256_BLOCK_SIZE - 1);
115+ int used_sgs = 0;
116+ struct nx_sg *in_sg = nx_ctx->in_sg;
124117
125118 if (buf_len) {
126119 data_len = buf_len;
127− in_sg = nx_build_sg_list(nx_ctx->in_sg,
120+ in_sg = nx_build_sg_list(in_sg,
128121 (u8 *) sctx->buf,
129122 &data_len,
130123 max_sg_len);
@@ -133,15 +126,27 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data, · 2 unmodified lines
133126 rc = -EINVAL;
134127 goto out;
135128 }
129+ used_sgs = in_sg - nx_ctx->in_sg;
136130 }
137131
132+ /* to_process: SHA256_BLOCK_SIZE aligned chunk to be
133+ * processed in this iteration. This value is restricted
134+ * by sg list limits and number of sgs we already used
135+ * for leftover data. (see above)
136+ * In ideal case, we could allow NX_PAGE_SIZE * max_sg_len,
137+ * but because data may not be aligned, we need to account
138+ * for that too. */
139+ to_process = min_t(u64, total,
140+ (max_sg_len - 1 - used_sgs) * NX_PAGE_SIZE);
141+ to_process = to_process & ~(SHA256_BLOCK_SIZE - 1);
142+
138143 data_len = to_process - buf_len;
139144 in_sg = nx_build_sg_list(in_sg, (u8 *) data,
140145 &data_len, max_sg_len);
141146
142147 nx_ctx->op.inlen = (nx_ctx->in_sg - in_sg) * sizeof(struct nx_sg);
143148
144− to_process = (data_len + buf_len);
149+ to_process = data_len + buf_len;
145150 leftover = total - to_process;
146151
147152 /*
drivers/crypto/nx/nx-sha512.c+16−12
@@ -71,7 +71,6 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data, · 70 unmodified lines
7171 struct sha512_state *sctx = shash_desc_ctx(desc);
7272 struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
7373 struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb;
74− struct nx_sg *in_sg;
7574 struct nx_sg *out_sg;
7675 u64 to_process, leftover = 0, total;
7776 unsigned long irq_flags;
@@ -97,7 +96,6 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data, · 19 unmodified lines
9796 NX_CPB_FDM(csbcpb) |= NX_FDM_INTERMEDIATE;
9897 NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION;
9998
100− in_sg = nx_ctx->in_sg;
10199 max_sg_len = min_t(u64, nx_ctx->ap->sglen,
102100 nx_driver.of.max_sg_len/sizeof(struct nx_sg));
103101 max_sg_len = min_t(u64, max_sg_len,
@@ -114,18 +112,12 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data, · 10 unmodified lines
114112 }
115113
116114 do {
117− /*
118− * to_process: the SHA512_BLOCK_SIZE data chunk to process in
119− * this update. This value is also restricted by the sg list
120− * limits.
121− */
122− to_process = total - leftover;
123− to_process = to_process & ~(SHA512_BLOCK_SIZE - 1);
124− leftover = total - to_process;
115+ int used_sgs = 0;
116+ struct nx_sg *in_sg = nx_ctx->in_sg;
125117
126118 if (buf_len) {
127119 data_len = buf_len;
128− in_sg = nx_build_sg_list(nx_ctx->in_sg,
120+ in_sg = nx_build_sg_list(in_sg,
129121 (u8 *) sctx->buf,
130122 &data_len, max_sg_len);
131123
@@ -133,8 +125,20 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data, · 1 unmodified line
133125 rc = -EINVAL;
134126 goto out;
135127 }
128+ used_sgs = in_sg - nx_ctx->in_sg;
136129 }
137130
131+ /* to_process: SHA512_BLOCK_SIZE aligned chunk to be
132+ * processed in this iteration. This value is restricted
133+ * by sg list limits and number of sgs we already used
134+ * for leftover data. (see above)
135+ * In ideal case, we could allow NX_PAGE_SIZE * max_sg_len,
136+ * but because data may not be aligned, we need to account
137+ * for that too. */
138+ to_process = min_t(u64, total,
139+ (max_sg_len - 1 - used_sgs) * NX_PAGE_SIZE);
140+ to_process = to_process & ~(SHA512_BLOCK_SIZE - 1);
141+
138142 data_len = to_process - buf_len;
139143 in_sg = nx_build_sg_list(in_sg, (u8 *) data,
140144 &data_len, max_sg_len);
@@ -146,7 +150,7 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data, · 5 unmodified lines
146150 goto out;
147151 }
148152
149− to_process = (data_len + buf_len);
153+ to_process = data_len + buf_len;
150154 leftover = total - to_process;
151155
152156 /*
drivers/crypto/qat/qat_common/qat_algs.c+16−8
@@ -73,7 +73,8 @@ · 72 unmodified lines
7373 ICP_QAT_HW_CIPHER_KEY_CONVERT, \
7474 ICP_QAT_HW_CIPHER_DECRYPT)
7575
76−static atomic_t active_dev;
76+static DEFINE_MUTEX(algs_lock);
77+static unsigned int active_devs;
7778
7879 struct qat_alg_buf {
7980 uint32_t len;
@@ -1280,7 +1281,10 @@ static struct crypto_alg qat_algs[] = { { · 1200 unmodified lines
12801281
12811282 int qat_algs_register(void)
12821283 {
1283− if (atomic_add_return(1, &active_dev) == 1) {
1284+ int ret = 0;
1285+
1286+ mutex_lock(&algs_lock);
1287+ if (++active_devs == 1) {
12841288 int i;
12851289
12861290 for (i = 0; i < ARRAY_SIZE(qat_algs); i++)
@@ -1289,21 +1293,25 @@ int qat_algs_register(void) · 2 unmodified lines
12891293 CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC :
12901294 CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC;
12911295
1292− return crypto_register_algs(qat_algs, ARRAY_SIZE(qat_algs));
1296+ ret = crypto_register_algs(qat_algs, ARRAY_SIZE(qat_algs));
12931297 }
1294− return 0;
1298+ mutex_unlock(&algs_lock);
1299+ return ret;
12951300 }
12961301
12971302 int qat_algs_unregister(void)
12981303 {
1299− if (atomic_sub_return(1, &active_dev) == 0)
1300− return crypto_unregister_algs(qat_algs, ARRAY_SIZE(qat_algs));
1301− return 0;
1304+ int ret = 0;
1305+
1306+ mutex_lock(&algs_lock);
1307+ if (--active_devs == 0)
1308+ ret = crypto_unregister_algs(qat_algs, ARRAY_SIZE(qat_algs));
1309+ mutex_unlock(&algs_lock);
1310+ return ret;
13021311 }
13031312
13041313 int qat_algs_init(void)
13051314 {
1306− atomic_set(&active_dev, 0);
13071315 crypto_get_default_rng();
13081316 return 0;
13091317 }
drivers/dma/at_hdmac.c+87−45
@@ -48,6 +48,8 @@ · 47 unmodified lines
4848 BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |\
4949 BIT(DMA_SLAVE_BUSWIDTH_4_BYTES))
5050
51+#define ATC_MAX_DSCR_TRIALS 10
52+
5153 /*
5254 * Initial number of descriptors to allocate for each channel. This could
5355 * be increased during dma usage.
@@ -285,28 +287,19 @@ static struct at_desc *atc_get_desc_by_cookie(struct at_dma_chan *atchan, · 231 unmodified lines
285287 *
286288 * @current_len: the number of bytes left before reading CTRLA
287289 * @ctrla: the value of CTRLA
288− * @desc: the descriptor containing the transfer width
289290 */
290−static inline int atc_calc_bytes_left(int current_len, u32 ctrla,
291− struct at_desc *desc)
291+static inline int atc_calc_bytes_left(int current_len, u32 ctrla)
292292 {
293− return current_len - ((ctrla & ATC_BTSIZE_MAX) << desc->tx_width);
294−}
293+ u32 btsize = (ctrla & ATC_BTSIZE_MAX);
294+ u32 src_width = ATC_REG_TO_SRC_WIDTH(ctrla);
295295
296−/**
297− * atc_calc_bytes_left_from_reg - calculates the number of bytes left according
298− * to the current value of CTRLA.
299− *
300− * @current_len: the number of bytes left before reading CTRLA
301− * @atchan: the channel to read CTRLA for
302− * @desc: the descriptor containing the transfer width
303− */
304−static inline int atc_calc_bytes_left_from_reg(int current_len,
305− struct at_dma_chan *atchan, struct at_desc *desc)
306−{
307− u32 ctrla = channel_readl(atchan, CTRLA);
308−
309− return atc_calc_bytes_left(current_len, ctrla, desc);
296+ /*
297+ * According to the datasheet, when reading the Control A Register
298+ * (ctrla), the Buffer Transfer Size (btsize) bitfield refers to the
299+ * number of transfers completed on the Source Interface.
300+ * So btsize is always a number of source width transfers.
301+ */
302+ return current_len - (btsize << src_width);
310303 }
311304
312305 /**
@@ -320,7 +313,7 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie) · 7 unmodified lines
320313 struct at_desc *desc_first = atc_first_active(atchan);
321314 struct at_desc *desc;
322315 int ret;
323− u32 ctrla, dscr;
316+ u32 ctrla, dscr, trials;
324317
325318 /*
326319 * If the cookie doesn't match to the currently running transfer then
@@ -346,15 +339,82 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie) · 19 unmodified lines
346339 * the channel's DSCR register and compare it against the value
347340 * of the hardware linked list structure of each child
348341 * descriptor.
342+ *
343+ * The CTRLA register provides us with the amount of data
344+ * already read from the source for the current child
345+ * descriptor. So we can compute a more accurate residue by also
346+ * removing the number of bytes corresponding to this amount of
347+ * data.
348+ *
349+ * However, the DSCR and CTRLA registers cannot be read both
350+ * atomically. Hence a race condition may occur: the first read
351+ * register may refer to one child descriptor whereas the second
352+ * read may refer to a later child descriptor in the list
353+ * because of the DMA transfer progression inbetween the two
354+ * reads.
355+ *
356+ * One solution could have been to pause the DMA transfer, read
357+ * the DSCR and CTRLA then resume the DMA transfer. Nonetheless,
358+ * this approach presents some drawbacks:
359+ * - If the DMA transfer is paused, RX overruns or TX underruns
360+ * are more likey to occur depending on the system latency.
361+ * Taking the USART driver as an example, it uses a cyclic DMA
362+ * transfer to read data from the Receive Holding Register
363+ * (RHR) to avoid RX overruns since the RHR is not protected
364+ * by any FIFO on most Atmel SoCs. So pausing the DMA transfer
365+ * to compute the residue would break the USART driver design.
366+ * - The atc_pause() function masks interrupts but we'd rather
367+ * avoid to do so for system latency purpose.
368+ *
369+ * Then we'd rather use another solution: the DSCR is read a
370+ * first time, the CTRLA is read in turn, next the DSCR is read
371+ * a second time. If the two consecutive read values of the DSCR
372+ * are the same then we assume both refers to the very same
373+ * child descriptor as well as the CTRLA value read inbetween
374+ * does. For cyclic tranfers, the assumption is that a full loop
375+ * is "not so fast".
376+ * If the two DSCR values are different, we read again the CTRLA
377+ * then the DSCR till two consecutive read values from DSCR are
378+ * equal or till the maxium trials is reach.
379+ * This algorithm is very unlikely not to find a stable value for
380+ * DSCR.
349381 */
350382
351− ctrla = channel_readl(atchan, CTRLA);
352− rmb(); /* ensure CTRLA is read before DSCR */
353383 dscr = channel_readl(atchan, DSCR);
384+ rmb(); /* ensure DSCR is read before CTRLA */
385+ ctrla = channel_readl(atchan, CTRLA);
386+ for (trials = 0; trials < ATC_MAX_DSCR_TRIALS; ++trials) {
387+ u32 new_dscr;
388+
389+ rmb(); /* ensure DSCR is read after CTRLA */
390+ new_dscr = channel_readl(atchan, DSCR);
391+
392+ /*
393+ * If the DSCR register value has not changed inside the
394+ * DMA controller since the previous read, we assume
395+ * that both the dscr and ctrla values refers to the
396+ * very same descriptor.
397+ */
398+ if (likely(new_dscr == dscr))
399+ break;
400+
401+ /*
402+ * DSCR has changed inside the DMA controller, so the
403+ * previouly read value of CTRLA may refer to an already
404+ * processed descriptor hence could be outdated.
405+ * We need to update ctrla to match the current
406+ * descriptor.
407+ */
408+ dscr = new_dscr;
409+ rmb(); /* ensure DSCR is read before CTRLA */
410+ ctrla = channel_readl(atchan, CTRLA);
411+ }
412+ if (unlikely(trials >= ATC_MAX_DSCR_TRIALS))
413+ return -ETIMEDOUT;
354414
355415 /* for the first descriptor we can be more accurate */
356416 if (desc_first->lli.dscr == dscr)
357− return atc_calc_bytes_left(ret, ctrla, desc_first);
417+ return atc_calc_bytes_left(ret, ctrla);
358418
359419 ret -= desc_first->len;
360420 list_for_each_entry(desc, &desc_first->tx_list, desc_node) {
@@ -365,16 +425,14 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie) · 4 unmodified lines
365425 }
366426
367427 /*
368− * For the last descriptor in the chain we can calculate
428+ * For the current descriptor in the chain we can calculate
369429 * the remaining bytes using the channel's register.
370− * Note that the transfer width of the first and last
371− * descriptor may differ.
372430 */
373− if (!desc->lli.dscr)
374− ret = atc_calc_bytes_left_from_reg(ret, atchan, desc);
431+ ret = atc_calc_bytes_left(ret, ctrla);
375432 } else {
376433 /* single transfer */
377− ret = atc_calc_bytes_left_from_reg(ret, atchan, desc_first);
434+ ctrla = channel_readl(atchan, CTRLA);
435+ ret = atc_calc_bytes_left(ret, ctrla);
378436 }
379437
380438 return ret;
@@ -726,7 +784,6 @@ atc_prep_dma_interleaved(struct dma_chan *chan, · 345 unmodified lines
726784
727785 desc->txd.cookie = -EBUSY;
728786 desc->total_len = desc->len = len;
729− desc->tx_width = dwidth;
730787
731788 /* set end-of-link to the last link descriptor of list*/
732789 set_desc_eol(desc);
@@ -804,10 +861,6 @@ atc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, · 71 unmodified lines
804861 first->txd.cookie = -EBUSY;
805862 first->total_len = len;
806863
807− /* set transfer width for the calculation of the residue */
808− first->tx_width = src_width;
809− prev->tx_width = src_width;
810−
811864 /* set end-of-link to the last link descriptor of list*/
812865 set_desc_eol(desc);
813866
@@ -956,10 +1009,6 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, · 142 unmodified lines
9561009 first->txd.cookie = -EBUSY;
9571010 first->total_len = total_len;
9581011
959− /* set transfer width for the calculation of the residue */
960− first->tx_width = reg_width;
961− prev->tx_width = reg_width;
962−
9631012 /* first link descriptor of list is responsible of flags */
9641013 first->txd.flags = flags; /* client is in control of this ack */
9651014
@@ -1077,12 +1126,6 @@ atc_prep_dma_sg(struct dma_chan *chan, · 111 unmodified lines
10771126 desc->txd.cookie = 0;
10781127 desc->len = len;
10791128
1080− /*
1081− * Although we only need the transfer width for the first and
1082− * the last descriptor, its easier to set it to all descriptors.
1083− */
1084− desc->tx_width = src_width;
1085−
10861129 atc_desc_chain(&first, &prev, desc);
10871130
10881131 /* update the lengths and addresses for the next loop cycle */
@@ -1256,7 +1299,6 @@ atc_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, · 167 unmodified lines
12561299 /* First descriptor of the chain embedds additional information */
12571300 first->txd.cookie = -EBUSY;
12581301 first->total_len = buf_len;
1259− first->tx_width = reg_width;
12601302
12611303 return &first->txd;
12621304
drivers/dma/at_hdmac_regs.h+1−2
@@ -112,6 +112,7 @@ · 111 unmodified lines
112112 #define ATC_SRC_WIDTH_BYTE (0x0 << 24)
113113 #define ATC_SRC_WIDTH_HALFWORD (0x1 << 24)
114114 #define ATC_SRC_WIDTH_WORD (0x2 << 24)
115+#define ATC_REG_TO_SRC_WIDTH(r) (((r) >> 24) & 0x3)
115116 #define ATC_DST_WIDTH_MASK (0x3 << 28) /* Destination Single Transfer Size */
116117 #define ATC_DST_WIDTH(x) ((x) << 28)
117118 #define ATC_DST_WIDTH_BYTE (0x0 << 28)
@@ -182,7 +183,6 @@ struct at_lli { · 64 unmodified lines
182183 * @txd: support for the async_tx api
183184 * @desc_node: node on the channed descriptors list
184185 * @len: descriptor byte count
185− * @tx_width: transfer width
186186 * @total_len: total transaction byte count
187187 */
188188 struct at_desc {
@@ -194,7 +194,6 @@ struct at_desc { · 5 unmodified lines
194194 struct dma_async_tx_descriptor txd;
195195 struct list_head desc_node;
196196 size_t len;
197− u32 tx_width;
198197 size_t total_len;
199198
200199 /* Interleaved data */
drivers/dma/at_xdmac.c+14−12
@@ -359,18 +359,19 @@ static void at_xdmac_start_xfer(struct at_xdmac_chan *atchan, · 358 unmodified lines
359359 * descriptor view 2 since some fields of the configuration register
360360 * depend on transfer size and src/dest addresses.
361361 */
362− if (at_xdmac_chan_is_cyclic(atchan)) {
362+ if (at_xdmac_chan_is_cyclic(atchan))
363363 reg = AT_XDMAC_CNDC_NDVIEW_NDV1;
364− at_xdmac_chan_write(atchan, AT_XDMAC_CC, first->lld.mbr_cfg);
365− } else if (first->lld.mbr_ubc & AT_XDMAC_MBR_UBC_NDV3) {
364+ else if (first->lld.mbr_ubc & AT_XDMAC_MBR_UBC_NDV3)
366365 reg = AT_XDMAC_CNDC_NDVIEW_NDV3;
367− } else {
368− /*
369− * No need to write AT_XDMAC_CC reg, it will be done when the
370− * descriptor is fecthed.
371− */
366+ else
372367 reg = AT_XDMAC_CNDC_NDVIEW_NDV2;
373− }
368+ /*
369+ * Even if the register will be updated from the configuration in the
370+ * descriptor when using view 2 or higher, the PROT bit won't be set
371+ * properly. This bit can be modified only by using the channel
372+ * configuration register.
373+ */
374+ at_xdmac_chan_write(atchan, AT_XDMAC_CC, first->lld.mbr_cfg);
374375
375376 reg |= AT_XDMAC_CNDC_NDDUP
376377 | AT_XDMAC_CNDC_NDSUP
@@ -681,15 +682,16 @@ at_xdmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, · 304 unmodified lines
681682 desc->lld.mbr_sa = mem;
682683 desc->lld.mbr_da = atchan->sconfig.dst_addr;
683684 }
684− desc->lld.mbr_cfg = atchan->cfg;
685− dwidth = at_xdmac_get_dwidth(desc->lld.mbr_cfg);
685+ dwidth = at_xdmac_get_dwidth(atchan->cfg);
686686 fixed_dwidth = IS_ALIGNED(len, 1 << dwidth)
687− ? at_xdmac_get_dwidth(desc->lld.mbr_cfg)
687+ ? dwidth
688688 : AT_XDMAC_CC_DWIDTH_BYTE;
689689 desc->lld.mbr_ubc = AT_XDMAC_MBR_UBC_NDV2 /* next descriptor view */
690690 | AT_XDMAC_MBR_UBC_NDEN /* next descriptor dst parameter update */
691691 | AT_XDMAC_MBR_UBC_NSEN /* next descriptor src parameter update */
692692 | (len >> fixed_dwidth); /* microblock length */
693+ desc->lld.mbr_cfg = (atchan->cfg & ~AT_XDMAC_CC_DWIDTH_MASK) |
694+ AT_XDMAC_CC_DWIDTH(fixed_dwidth);
693695 dev_dbg(chan2dev(chan),
694696 "%s: lld: mbr_sa=%pad, mbr_da=%pad, mbr_ubc=0x%08x\n",
695697 __func__, &desc->lld.mbr_sa, &desc->lld.mbr_da, desc->lld.mbr_ubc);
drivers/dma/dmaengine.c+4−0
@@ -689,6 +689,10 @@ struct dma_chan *dma_request_slave_channel(struct device *dev, · 688 unmodified lines
689689 struct dma_chan *ch = dma_request_slave_channel_reason(dev, name);
690690 if (IS_ERR(ch))
691691 return NULL;
692+
693+ dma_cap_set(DMA_PRIVATE, ch->device->cap_mask);
694+ ch->device->privatecnt++;
695+
692696 return ch;
693697 }
694698 EXPORT_SYMBOL_GPL(dma_request_slave_channel);
drivers/dma/mv_xor.c+5−4
@@ -162,10 +162,11 @@ static void mv_chan_set_mode(struct mv_xor_chan *chan, · 161 unmodified lines
162162 config &= ~0x7;
163163 config |= op_mode;
164164
165− if (IS_ENABLED(__BIG_ENDIAN))
166− config |= XOR_DESCRIPTOR_SWAP;
167− else
168− config &= ~XOR_DESCRIPTOR_SWAP;
165+#if defined(__BIG_ENDIAN)
166+ config |= XOR_DESCRIPTOR_SWAP;
167+#else
168+ config &= ~XOR_DESCRIPTOR_SWAP;
169+#endif
169170
170171 writel_relaxed(config, XOR_CONFIG(chan));
171172 chan->current_type = type;
drivers/dma/pl330.c+2−1
@@ -2328,7 +2328,7 @@ static dma_cookie_t pl330_tx_submit(struct dma_async_tx_descriptor *tx) · 2327 unmodified lines
23282328 desc->txd.callback = last->txd.callback;
23292329 desc->txd.callback_param = last->txd.callback_param;
23302330 }
2331− last->last = false;
2331+ desc->last = false;
23322332
23332333 dma_cookie_assign(&desc->txd);
23342334
@@ -2623,6 +2623,7 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, · 288 unmodified lines
26232623 desc->rqcfg.brst_len = 1;
26242624
26252625 desc->rqcfg.brst_len = get_burst_len(desc, len);
2626+ desc->bytes_requested = len;
26262627
26272628 desc->txd.flags = flags;
26282629
drivers/dma/virt-dma.c+6−13
@@ -29,7 +29,7 @@ dma_cookie_t vchan_tx_submit(struct dma_async_tx_descriptor *tx) · 28 unmodified lines
2929 spin_lock_irqsave(&vc->lock, flags);
3030 cookie = dma_cookie_assign(tx);
3131
32− list_move_tail(&vd->node, &vc->desc_submitted);
32+ list_add_tail(&vd->node, &vc->desc_submitted);
3333 spin_unlock_irqrestore(&vc->lock, flags);
3434
3535 dev_dbg(vc->chan.device->dev, "vchan %p: txd %p[%x]: submitted\n",
@@ -83,10 +83,8 @@ static void vchan_complete(unsigned long arg) · 47 unmodified lines
8383 cb_data = vd->tx.callback_param;
8484
8585 list_del(&vd->node);
86− if (async_tx_test_ack(&vd->tx))
87− list_add(&vd->node, &vc->desc_allocated);
88− else
89− vc->desc_free(vd);
86+
87+ vc->desc_free(vd);
9088
9189 if (cb)
9290 cb(cb_data);
@@ -98,13 +96,9 @@ void vchan_dma_desc_free_list(struct virt_dma_chan *vc, struct list_head *head) · 5 unmodified lines
9896 while (!list_empty(head)) {
9997 struct virt_dma_desc *vd = list_first_entry(head,
10098 struct virt_dma_desc, node);
101− if (async_tx_test_ack(&vd->tx)) {
102− list_move_tail(&vd->node, &vc->desc_allocated);
103− } else {
104− dev_dbg(vc->chan.device->dev, "txd %p: freeing\n", vd);
105− list_del(&vd->node);
106− vc->desc_free(vd);
107− }
99+ list_del(&vd->node);
100+ dev_dbg(vc->chan.device->dev, "txd %p: freeing\n", vd);
101+ vc->desc_free(vd);
108102 }
109103 }
110104 EXPORT_SYMBOL_GPL(vchan_dma_desc_free_list);
@@ -114,7 +108,6 @@ void vchan_init(struct virt_dma_chan *vc, struct dma_device *dmadev) · 3 unmodified lines
114108 dma_cookie_init(&vc->chan);
115109
116110 spin_lock_init(&vc->lock);
117− INIT_LIST_HEAD(&vc->desc_allocated);
118111 INIT_LIST_HEAD(&vc->desc_submitted);
119112 INIT_LIST_HEAD(&vc->desc_issued);
120113 INIT_LIST_HEAD(&vc->desc_completed);
drivers/dma/virt-dma.h+1−12
@@ -29,7 +29,6 @@ struct virt_dma_chan { · 28 unmodified lines
2929 spinlock_t lock;
3030
3131 /* protected by vc.lock */
32− struct list_head desc_allocated;
3332 struct list_head desc_submitted;
3433 struct list_head desc_issued;
3534 struct list_head desc_completed;
@@ -56,16 +55,11 @@ static inline struct dma_async_tx_descriptor *vchan_tx_prep(struct virt_dma_chan · 20 unmodified lines
5655 struct virt_dma_desc *vd, unsigned long tx_flags)
5756 {
5857 extern dma_cookie_t vchan_tx_submit(struct dma_async_tx_descriptor *);
59− unsigned long flags;
6058
6159 dma_async_tx_descriptor_init(&vd->tx, &vc->chan);
6260 vd->tx.flags = tx_flags;
6361 vd->tx.tx_submit = vchan_tx_submit;
6462
65− spin_lock_irqsave(&vc->lock, flags);
66− list_add_tail(&vd->node, &vc->desc_allocated);
67− spin_unlock_irqrestore(&vc->lock, flags);
68−
6963 return &vd->tx;
7064 }
7165
@@ -128,8 +122,7 @@ static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc) · 56 unmodified lines
128122 }
129123
130124 /**
131− * vchan_get_all_descriptors - obtain all allocated, submitted and issued
132− * descriptors
125+ * vchan_get_all_descriptors - obtain all submitted and issued descriptors
133126 * vc: virtual channel to get descriptors from
134127 * head: list of descriptors found
135128 *
@@ -141,7 +134,6 @@ static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc) · 5 unmodified lines
141134 static inline void vchan_get_all_descriptors(struct virt_dma_chan *vc,
142135 struct list_head *head)
143136 {
144− list_splice_tail_init(&vc->desc_allocated, head);
145137 list_splice_tail_init(&vc->desc_submitted, head);
146138 list_splice_tail_init(&vc->desc_issued, head);
147139 list_splice_tail_init(&vc->desc_completed, head);
@@ -149,14 +141,11 @@ static inline void vchan_get_all_descriptors(struct virt_dma_chan *vc, · 1 unmodified line
149141
150142 static inline void vchan_free_chan_resources(struct virt_dma_chan *vc)
151143 {
152− struct virt_dma_desc *vd;
153144 unsigned long flags;
154145 LIST_HEAD(head);
155146
156147 spin_lock_irqsave(&vc->lock, flags);
157148 vchan_get_all_descriptors(vc, &head);
158− list_for_each_entry(vd, &head, node)
159− async_tx_clear_ack(&vd->tx);
160149 spin_unlock_irqrestore(&vc->lock, flags);
161150
162151 vchan_dma_desc_free_list(vc, &head);
drivers/dma/xgene-dma.c+3−0
@@ -111,6 +111,7 @@ · 110 unmodified lines
111111 #define XGENE_DMA_MEM_RAM_SHUTDOWN 0xD070
112112 #define XGENE_DMA_BLK_MEM_RDY 0xD074
113113 #define XGENE_DMA_BLK_MEM_RDY_VAL 0xFFFFFFFF
114+#define XGENE_DMA_RING_CMD_SM_OFFSET 0x8000
114115
115116 /* X-Gene SoC EFUSE csr register and bit defination */
116117 #define XGENE_SOC_JTAG1_SHADOW 0x18
@@ -1887,6 +1888,8 @@ static int xgene_dma_get_resources(struct platform_device *pdev, · 1770 unmodified lines
18871888 return -ENOMEM;
18881889 }
18891890
1891+ pdma->csr_ring_cmd += XGENE_DMA_RING_CMD_SM_OFFSET;
1892+
18901893 /* Get efuse csr region */
18911894 res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
18921895 if (!res) {
drivers/edac/ppc4xx_edac.c+1−1
@@ -920,7 +920,7 @@ static int ppc4xx_edac_init_csrows(struct mem_ctl_info *mci, u32 mcopt1) · 919 unmodified lines
920920 */
921921
922922 for (row = 0; row < mci->nr_csrows; row++) {
923− struct csrow_info *csi = &mci->csrows[row];
923+ struct csrow_info *csi = mci->csrows[row];
924924
925925 /*
926926 * Get the configuration settings for this
drivers/extcon/extcon-palmas.c+0−13
@@ -200,7 +200,6 @@ static int palmas_usb_probe(struct platform_device *pdev) · 199 unmodified lines
200200 status = devm_extcon_dev_register(&pdev->dev, palmas_usb->edev);
201201 if (status) {
202202 dev_err(&pdev->dev, "failed to register extcon device\n");
203− kfree(palmas_usb->edev->name);
204203 return status;
205204 }
206205
@@ -214,7 +213,6 @@ static int palmas_usb_probe(struct platform_device *pdev) · 7 unmodified lines
214213 if (status < 0) {
215214 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
216215 palmas_usb->id_irq, status);
217− kfree(palmas_usb->edev->name);
218216 return status;
219217 }
220218 }
@@ -229,7 +227,6 @@ static int palmas_usb_probe(struct platform_device *pdev) · 8 unmodified lines
229227 if (status < 0) {
230228 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
231229 palmas_usb->vbus_irq, status);
232− kfree(palmas_usb->edev->name);
233230 return status;
234231 }
235232 }
@@ -239,15 +236,6 @@ static int palmas_usb_probe(struct platform_device *pdev) · 3 unmodified lines
239236 return 0;
240237 }
241238
242−static int palmas_usb_remove(struct platform_device *pdev)
243−{
244− struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
245−
246− kfree(palmas_usb->edev->name);
247−
248− return 0;
249−}
250−
251239 #ifdef CONFIG_PM_SLEEP
252240 static int palmas_usb_suspend(struct device *dev)
253241 {
@@ -288,7 +276,6 @@ static const struct of_device_id of_palmas_match_tbl[] = { · 34 unmodified lines
288276
289277 static struct platform_driver palmas_usb_driver = {
290278 .probe = palmas_usb_probe,
291− .remove = palmas_usb_remove,
292279 .driver = {
293280 .name = "palmas-usb",
294281 .of_match_table = of_palmas_match_tbl,
drivers/extcon/extcon.c+44−17
@@ -124,25 +124,35 @@ static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id · 123 unmodified lines
124124 return -EINVAL;
125125 }
126126
127−static int find_cable_index_by_name(struct extcon_dev *edev, const char *name)
127+static int find_cable_id_by_name(struct extcon_dev *edev, const char *name)
128128 {
129− unsigned int id = EXTCON_NONE;
129+ unsigned int id = -EINVAL;
130130 int i = 0;
131131
132− if (edev->max_supported == 0)
133− return -EINVAL;
134−
135− /* Find the the number of extcon cable */
132+ /* Find the id of extcon cable */
136133 while (extcon_name[i]) {
137134 if (!strncmp(extcon_name[i], name, CABLE_NAME_MAX)) {
138135 id = i;
139136 break;
140137 }
138+ i++;
141139 }
142140
143− if (id == EXTCON_NONE)
141+ return id;
142+}
143+
144+static int find_cable_index_by_name(struct extcon_dev *edev, const char *name)
145+{
146+ unsigned int id;
147+
148+ if (edev->max_supported == 0)
144149 return -EINVAL;
145150
151+ /* Find the the number of extcon cable */
152+ id = find_cable_id_by_name(edev, name);
153+ if (id < 0)
154+ return id;
155+
146156 return find_cable_index_by_id(edev, id);
147157 }
148158
@@ -228,9 +238,11 @@ static ssize_t cable_state_show(struct device *dev, · 79 unmodified lines
228238 struct extcon_cable *cable = container_of(attr, struct extcon_cable,
229239 attr_state);
230240
241+ int i = cable->cable_index;
242+
231243 return sprintf(buf, "%d\n",
232244 extcon_get_cable_state_(cable->edev,
233− cable->cable_index));
245+ cable->edev->supported_cable[i]));
234246 }
235247
236248 /**
@@ -263,20 +275,25 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) · 26 unmodified lines
263275 spin_lock_irqsave(&edev->lock, flags);
264276
265277 if (edev->state != ((edev->state & ~mask) | (state & mask))) {
278+ u32 old_state;
279+
266280 if (check_mutually_exclusive(edev, (edev->state & ~mask) |
267281 (state & mask))) {
268282 spin_unlock_irqrestore(&edev->lock, flags);
269283 return -EPERM;
270284 }
271285
272− for (index = 0; index < edev->max_supported; index++) {
273− if (is_extcon_changed(edev->state, state, index, &attached))
274− raw_notifier_call_chain(&edev->nh[index], attached, edev);
275− }
276−
286+ old_state = edev->state;
277287 edev->state &= ~mask;
278288 edev->state |= state & mask;
279289
290+ for (index = 0; index < edev->max_supported; index++) {
291+ if (is_extcon_changed(old_state, edev->state, index,
292+ &attached))
293+ raw_notifier_call_chain(&edev->nh[index],
294+ attached, edev);
295+ }
296+
280297 /* This could be in interrupt handler */
281298 prop_buf = (char *)get_zeroed_page(GFP_ATOMIC);
282299 if (prop_buf) {
@@ -361,8 +378,13 @@ EXPORT_SYMBOL_GPL(extcon_get_cable_state_); · 78 unmodified lines
361378 */
362379 int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name)
363380 {
364− return extcon_get_cable_state_(edev, find_cable_index_by_name
365− (edev, cable_name));
381+ unsigned int id;
382+
383+ id = find_cable_id_by_name(edev, cable_name);
384+ if (id < 0)
385+ return id;
386+
387+ return extcon_get_cable_state_(edev, id);
366388 }
367389 EXPORT_SYMBOL_GPL(extcon_get_cable_state);
368390
@@ -404,8 +426,13 @@ EXPORT_SYMBOL_GPL(extcon_set_cable_state_); · 35 unmodified lines
404426 int extcon_set_cable_state(struct extcon_dev *edev,
405427 const char *cable_name, bool cable_state)
406428 {
407− return extcon_set_cable_state_(edev, find_cable_index_by_name
408− (edev, cable_name), cable_state);
429+ unsigned int id;
430+
431+ id = find_cable_id_by_name(edev, cable_name);
432+ if (id < 0)
433+ return id;
434+
435+ return extcon_set_cable_state_(edev, id, cable_state);
409436 }
410437 EXPORT_SYMBOL_GPL(extcon_set_cable_state);
411438
drivers/firmware/efi/efi.c+5−0
@@ -58,6 +58,11 @@ bool efi_runtime_disabled(void) · 57 unmodified lines
5858
5959 static int __init parse_efi_cmdline(char *str)
6060 {
61+ if (!str) {
62+ pr_warn("need at least one option\n");
63+ return -EINVAL;
64+ }
65+
6166 if (parse_option_str(str, "noruntime"))
6267 disable_runtime = true;
6368
drivers/gpu/drm/amd/amdgpu/amdgpu.h+11−1
@@ -1130,6 +1130,9 @@ struct amdgpu_gfx { · 1129 unmodified lines
11301130 uint32_t me_feature_version;
11311131 uint32_t ce_feature_version;
11321132 uint32_t pfp_feature_version;
1133+ uint32_t rlc_feature_version;
1134+ uint32_t mec_feature_version;
1135+ uint32_t mec2_feature_version;
11331136 struct amdgpu_ring gfx_ring[AMDGPU_MAX_GFX_RINGS];
11341137 unsigned num_gfx_rings;
11351138 struct amdgpu_ring compute_ring[AMDGPU_MAX_COMPUTE_RINGS];
@@ -1639,6 +1642,7 @@ struct amdgpu_sdma { · 503 unmodified lines
16391642 /* SDMA firmware */
16401643 const struct firmware *fw;
16411644 uint32_t fw_version;
1645+ uint32_t feature_version;
16421646
16431647 struct amdgpu_ring ring;
16441648 };
@@ -1866,6 +1870,12 @@ typedef void (*amdgpu_wreg_t)(struct amdgpu_device*, uint32_t, uint32_t); · 221 unmodified lines
18661870 typedef uint32_t (*amdgpu_block_rreg_t)(struct amdgpu_device*, uint32_t, uint32_t);
18671871 typedef void (*amdgpu_block_wreg_t)(struct amdgpu_device*, uint32_t, uint32_t, uint32_t);
18681872
1873+struct amdgpu_ip_block_status {
1874+ bool valid;
1875+ bool sw;
1876+ bool hw;
1877+};
1878+
18691879 struct amdgpu_device {
18701880 struct device *dev;
18711881 struct drm_device *ddev;
@@ -2008,7 +2018,7 @@ struct amdgpu_device { · 136 unmodified lines
20082018
20092019 const struct amdgpu_ip_block_version *ip_blocks;
20102020 int num_ip_blocks;
2011− bool *ip_block_enabled;
2021+ struct amdgpu_ip_block_status *ip_block_status;
20122022 struct mutex mn_lock;
20132023 DECLARE_HASHTABLE(mn_hash, 7);
20142024
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c+22−16
@@ -1191,8 +1191,9 @@ static int amdgpu_early_init(struct amdgpu_device *adev) · 1190 unmodified lines
11911191 return -EINVAL;
11921192 }
11931193
1194− adev->ip_block_enabled = kcalloc(adev->num_ip_blocks, sizeof(bool), GFP_KERNEL);
1195− if (adev->ip_block_enabled == NULL)
1194+ adev->ip_block_status = kcalloc(adev->num_ip_blocks,
1195+ sizeof(struct amdgpu_ip_block_status), GFP_KERNEL);
1196+ if (adev->ip_block_status == NULL)
11961197 return -ENOMEM;
11971198
11981199 if (adev->ip_blocks == NULL) {
@@ -1203,18 +1204,18 @@ static int amdgpu_early_init(struct amdgpu_device *adev) · 4 unmodified lines
12031204 for (i = 0; i < adev->num_ip_blocks; i++) {
12041205 if ((amdgpu_ip_block_mask & (1 << i)) == 0) {
12051206 DRM_ERROR("disabled ip block: %d\n", i);
1206− adev->ip_block_enabled[i] = false;
1207+ adev->ip_block_status[i].valid = false;
12071208 } else {
12081209 if (adev->ip_blocks[i].funcs->early_init) {
12091210 r = adev->ip_blocks[i].funcs->early_init((void *)adev);
12101211 if (r == -ENOENT)
1211− adev->ip_block_enabled[i] = false;
1212+ adev->ip_block_status[i].valid = false;
12121213 else if (r)
12131214 return r;
12141215 else
1215− adev->ip_block_enabled[i] = true;
1216+ adev->ip_block_status[i].valid = true;
12161217 } else {
1217− adev->ip_block_enabled[i] = true;
1218+ adev->ip_block_status[i].valid = true;
12181219 }
12191220 }
12201221 }
@@ -1227,11 +1228,12 @@ static int amdgpu_init(struct amdgpu_device *adev) · 6 unmodified lines
12271228 int i, r;
12281229
12291230 for (i = 0; i < adev->num_ip_blocks; i++) {
1230− if (!adev->ip_block_enabled[i])
1231+ if (!adev->ip_block_status[i].valid)
12311232 continue;
12321233 r = adev->ip_blocks[i].funcs->sw_init((void *)adev);
12331234 if (r)
12341235 return r;
1236+ adev->ip_block_status[i].sw = true;
12351237 /* need to do gmc hw init early so we can allocate gpu mem */
12361238 if (adev->ip_blocks[i].type == AMD_IP_BLOCK_TYPE_GMC) {
12371239 r = amdgpu_vram_scratch_init(adev);
@@ -1243,11 +1245,12 @@ static int amdgpu_init(struct amdgpu_device *adev) · 5 unmodified lines
12431245 r = amdgpu_wb_init(adev);
12441246 if (r)
12451247 return r;
1248+ adev->ip_block_status[i].hw = true;
12461249 }
12471250 }
12481251
12491252 for (i = 0; i < adev->num_ip_blocks; i++) {
1250− if (!adev->ip_block_enabled[i])
1253+ if (!adev->ip_block_status[i].sw)
12511254 continue;
12521255 /* gmc hw init is done early */
12531256 if (adev->ip_blocks[i].type == AMD_IP_BLOCK_TYPE_GMC)
@@ -1255,6 +1258,7 @@ static int amdgpu_init(struct amdgpu_device *adev) · 1 unmodified line
12551258 r = adev->ip_blocks[i].funcs->hw_init((void *)adev);
12561259 if (r)
12571260 return r;
1261+ adev->ip_block_status[i].hw = true;
12581262 }
12591263
12601264 return 0;
@@ -1265,7 +1269,7 @@ static int amdgpu_late_init(struct amdgpu_device *adev) · 4 unmodified lines
12651269 int i = 0, r;
12661270
12671271 for (i = 0; i < adev->num_ip_blocks; i++) {
1268− if (!adev->ip_block_enabled[i])
1272+ if (!adev->ip_block_status[i].valid)
12691273 continue;
12701274 /* enable clockgating to save power */
12711275 r = adev->ip_blocks[i].funcs->set_clockgating_state((void *)adev,
@@ -1287,7 +1291,7 @@ static int amdgpu_fini(struct amdgpu_device *adev) · 15 unmodified lines
12871291 int i, r;
12881292
12891293 for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
1290− if (!adev->ip_block_enabled[i])
1294+ if (!adev->ip_block_status[i].hw)
12911295 continue;
12921296 if (adev->ip_blocks[i].type == AMD_IP_BLOCK_TYPE_GMC) {
12931297 amdgpu_wb_fini(adev);
@@ -1300,14 +1304,16 @@ static int amdgpu_fini(struct amdgpu_device *adev) · 6 unmodified lines
13001304 return r;
13011305 r = adev->ip_blocks[i].funcs->hw_fini((void *)adev);
13021306 /* XXX handle errors */
1307+ adev->ip_block_status[i].hw = false;
13031308 }
13041309
13051310 for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
1306− if (!adev->ip_block_enabled[i])
1311+ if (!adev->ip_block_status[i].sw)
13071312 continue;
13081313 r = adev->ip_blocks[i].funcs->sw_fini((void *)adev);
13091314 /* XXX handle errors */
1310− adev->ip_block_enabled[i] = false;
1315+ adev->ip_block_status[i].sw = false;
1316+ adev->ip_block_status[i].valid = false;
13111317 }
13121318
13131319 return 0;
@@ -1318,7 +1324,7 @@ static int amdgpu_suspend(struct amdgpu_device *adev) · 4 unmodified lines
13181324 int i, r;
13191325
13201326 for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
1321− if (!adev->ip_block_enabled[i])
1327+ if (!adev->ip_block_status[i].valid)
13221328 continue;
13231329 /* ungate blocks so that suspend can properly shut them down */
13241330 r = adev->ip_blocks[i].funcs->set_clockgating_state((void *)adev,
@@ -1336,7 +1342,7 @@ static int amdgpu_resume(struct amdgpu_device *adev) · 11 unmodified lines
13361342 int i, r;
13371343
13381344 for (i = 0; i < adev->num_ip_blocks; i++) {
1339− if (!adev->ip_block_enabled[i])
1345+ if (!adev->ip_block_status[i].valid)
13401346 continue;
13411347 r = adev->ip_blocks[i].funcs->resume(adev);
13421348 if (r)
@@ -1582,8 +1588,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev) · 239 unmodified lines
15821588 amdgpu_fence_driver_fini(adev);
15831589 amdgpu_fbdev_fini(adev);
15841590 r = amdgpu_fini(adev);
1585− kfree(adev->ip_block_enabled);
1586− adev->ip_block_enabled = NULL;
1591+ kfree(adev->ip_block_status);
1592+ adev->ip_block_status = NULL;
15871593 adev->accel_working = false;
15881594 /* free i2c buses */
15891595 amdgpu_i2c_fini(adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c+5−3
@@ -449,7 +449,7 @@ out: · 448 unmodified lines
449449 * vital here, so they are not reported back to userspace.
450450 */
451451 static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
452− struct amdgpu_bo_va *bo_va)
452+ struct amdgpu_bo_va *bo_va, uint32_t operation)
453453 {
454454 struct ttm_validate_buffer tv, *entry;
455455 struct amdgpu_bo_list_entry *vm_bos;
@@ -485,7 +485,9 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, · 29 unmodified lines
485485 if (r)
486486 goto error_unlock;
487487
488− r = amdgpu_vm_bo_update(adev, bo_va, &bo_va->bo->tbo.mem);
488+
489+ if (operation == AMDGPU_VA_OP_MAP)
490+ r = amdgpu_vm_bo_update(adev, bo_va, &bo_va->bo->tbo.mem);
489491
490492 error_unlock:
491493 mutex_unlock(&bo_va->vm->mutex);
@@ -580,7 +582,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, · 88 unmodified lines
580582 }
581583
582584 if (!r && !(args->flags & AMDGPU_VM_DELAY_UPDATE))
583− amdgpu_gem_va_update_vm(adev, bo_va);
585+ amdgpu_gem_va_update_vm(adev, bo_va, args->operation);
584586
585587 drm_gem_object_unreference_unlocked(gobj);
586588 return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c+8−8
@@ -180,16 +180,16 @@ int amdgpu_ib_schedule(struct amdgpu_device *adev, unsigned num_ibs, · 179 unmodified lines
180180 if (vm) {
181181 /* do context switch */
182182 amdgpu_vm_flush(ring, vm, ib->sync.last_vm_update);
183− }
184183
185− if (vm && ring->funcs->emit_gds_switch)
186− amdgpu_ring_emit_gds_switch(ring, ib->vm->ids[ring->idx].id,
187− ib->gds_base, ib->gds_size,
188− ib->gws_base, ib->gws_size,
189− ib->oa_base, ib->oa_size);
184+ if (ring->funcs->emit_gds_switch)
185+ amdgpu_ring_emit_gds_switch(ring, ib->vm->ids[ring->idx].id,
186+ ib->gds_base, ib->gds_size,
187+ ib->gws_base, ib->gws_size,
188+ ib->oa_base, ib->oa_size);
190189
191− if (ring->funcs->emit_hdp_flush)
192− amdgpu_ring_emit_hdp_flush(ring);
190+ if (ring->funcs->emit_hdp_flush)
191+ amdgpu_ring_emit_hdp_flush(ring);
192+ }
193193
194194 old_ctx = ring->current_ctx;
195195 for (i = 0; i < num_ibs; ++i) {
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c+10−9
@@ -235,7 +235,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · 234 unmodified lines
235235
236236 for (i = 0; i < adev->num_ip_blocks; i++) {
237237 if (adev->ip_blocks[i].type == type &&
238− adev->ip_block_enabled[i]) {
238+ adev->ip_block_status[i].valid) {
239239 ip.hw_ip_version_major = adev->ip_blocks[i].major;
240240 ip.hw_ip_version_minor = adev->ip_blocks[i].minor;
241241 ip.capabilities_flags = 0;
@@ -274,7 +274,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · 32 unmodified lines
274274
275275 for (i = 0; i < adev->num_ip_blocks; i++)
276276 if (adev->ip_blocks[i].type == type &&
277− adev->ip_block_enabled[i] &&
277+ adev->ip_block_status[i].valid &&
278278 count < AMDGPU_HW_IP_INSTANCE_MAX_COUNT)
279279 count++;
280280
@@ -317,16 +317,17 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · 36 unmodified lines
317317 break;
318318 case AMDGPU_INFO_FW_GFX_RLC:
319319 fw_info.ver = adev->gfx.rlc_fw_version;
320− fw_info.feature = 0;
320+ fw_info.feature = adev->gfx.rlc_feature_version;
321321 break;
322322 case AMDGPU_INFO_FW_GFX_MEC:
323− if (info->query_fw.index == 0)
323+ if (info->query_fw.index == 0) {
324324 fw_info.ver = adev->gfx.mec_fw_version;
325− else if (info->query_fw.index == 1)
325+ fw_info.feature = adev->gfx.mec_feature_version;
326+ } else if (info->query_fw.index == 1) {
326327 fw_info.ver = adev->gfx.mec2_fw_version;
327− else
328+ fw_info.feature = adev->gfx.mec2_feature_version;
329+ } else
328330 return -EINVAL;
329− fw_info.feature = 0;
330331 break;
331332 case AMDGPU_INFO_FW_SMC:
332333 fw_info.ver = adev->pm.fw_version;
@@ -336,7 +337,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · 3 unmodified lines
336337 if (info->query_fw.index >= 2)
337338 return -EINVAL;
338339 fw_info.ver = adev->sdma[info->query_fw.index].fw_version;
339− fw_info.feature = 0;
340+ fw_info.feature = adev->sdma[info->query_fw.index].feature_version;
340341 break;
341342 default:
342343 return -EINVAL;
@@ -416,7 +417,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · 73 unmodified lines
416417 return n ? -EFAULT : 0;
417418 }
418419 case AMDGPU_INFO_DEV_INFO: {
419− struct drm_amdgpu_info_device dev_info;
420+ struct drm_amdgpu_info_device dev_info = {};
420421 struct amdgpu_cu_info cu_info;
421422
422423 dev_info.device_id = dev->pdev->device;
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c+14−3
@@ -374,7 +374,7 @@ static int amdgpu_uvd_cs_msg_decode(uint32_t *msg, unsigned buf_sizes[]) · 373 unmodified lines
374374 unsigned height_in_mb = ALIGN(height / 16, 2);
375375 unsigned fs_in_mb = width_in_mb * height_in_mb;
376376
377− unsigned image_size, tmp, min_dpb_size, num_dpb_buffer;
377+ unsigned image_size, tmp, min_dpb_size, num_dpb_buffer, min_ctx_size;
378378
379379 image_size = width * height;
380380 image_size += image_size / 2;
@@ -466,6 +466,8 @@ static int amdgpu_uvd_cs_msg_decode(uint32_t *msg, unsigned buf_sizes[]) · 85 unmodified lines
466466
467467 num_dpb_buffer = (le32_to_cpu(msg[59]) & 0xff) + 2;
468468 min_dpb_size = image_size * num_dpb_buffer;
469+ min_ctx_size = ((width + 255) / 16) * ((height + 255) / 16)
470+ * 16 * num_dpb_buffer + 52 * 1024;
469471 break;
470472
471473 default:
@@ -486,6 +488,7 @@ static int amdgpu_uvd_cs_msg_decode(uint32_t *msg, unsigned buf_sizes[]) · 14 unmodified lines
486488
487489 buf_sizes[0x1] = dpb_size;
488490 buf_sizes[0x2] = image_size;
491+ buf_sizes[0x4] = min_ctx_size;
489492 return 0;
490493 }
491494
@@ -628,6 +631,13 @@ static int amdgpu_uvd_cs_pass2(struct amdgpu_uvd_cs_ctx *ctx) · 136 unmodified lines
628631 return -EINVAL;
629632 }
630633
634+ } else if (cmd == 0x206) {
635+ if ((end - start) < ctx->buf_sizes[4]) {
636+ DRM_ERROR("buffer (%d) to small (%d / %d)!\n", cmd,
637+ (unsigned)(end - start),
638+ ctx->buf_sizes[4]);
639+ return -EINVAL;
640+ }
631641 } else if ((cmd != 0x100) && (cmd != 0x204)) {
632642 DRM_ERROR("invalid UVD command %X!\n", cmd);
633643 return -EINVAL;
@@ -755,9 +765,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx) · 121 unmodified lines
755765 struct amdgpu_uvd_cs_ctx ctx = {};
756766 unsigned buf_sizes[] = {
757767 [0x00000000] = 2048,
758− [0x00000001] = 32 * 1024 * 1024,
759− [0x00000002] = 2048 * 1152 * 3,
768+ [0x00000001] = 0xFFFFFFFF,
769+ [0x00000002] = 0xFFFFFFFF,
760770 [0x00000003] = 2048,
771+ [0x00000004] = 0xFFFFFFFF,
761772 };
762773 struct amdgpu_ib *ib = &parser->ibs[ib_idx];
763774 int r;
drivers/gpu/drm/amd/amdgpu/cik_sdma.c+1−0
@@ -500,6 +500,7 @@ static int cik_sdma_load_microcode(struct amdgpu_device *adev) · 499 unmodified lines
500500 amdgpu_ucode_print_sdma_hdr(&hdr->header);
501501 fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4;
502502 adev->sdma[i].fw_version = le32_to_cpu(hdr->header.ucode_version);
503+ adev->sdma[i].feature_version = le32_to_cpu(hdr->ucode_feature_version);
503504 fw_data = (const __le32 *)
504505 (adev->sdma[i].fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes));
505506 WREG32(mmSDMA0_UCODE_ADDR + sdma_offsets[i], 0);
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c+42−12
@@ -2561,7 +2561,7 @@ static bool gfx_v7_0_ring_emit_semaphore(struct amdgpu_ring *ring, · 2560 unmodified lines
25612561 * sheduling on the ring. This function schedules the IB
25622562 * on the gfx ring for execution by the GPU.
25632563 */
2564−static void gfx_v7_0_ring_emit_ib(struct amdgpu_ring *ring,
2564+static void gfx_v7_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
25652565 struct amdgpu_ib *ib)
25662566 {
25672567 bool need_ctx_switch = ring->current_ctx != ib->ctx;
@@ -2569,15 +2569,10 @@ static void gfx_v7_0_ring_emit_ib(struct amdgpu_ring *ring, · 1 unmodified line
25692569 u32 next_rptr = ring->wptr + 5;
25702570
25712571 /* drop the CE preamble IB for the same context */
2572− if ((ring->type == AMDGPU_RING_TYPE_GFX) &&
2573− (ib->flags & AMDGPU_IB_FLAG_PREAMBLE) &&
2574− !need_ctx_switch)
2572+ if ((ib->flags & AMDGPU_IB_FLAG_PREAMBLE) && !need_ctx_switch)
25752573 return;
25762574
2577− if (ring->type == AMDGPU_RING_TYPE_COMPUTE)
2578− control |= INDIRECT_BUFFER_VALID;
2579−
2580− if (need_ctx_switch && ring->type == AMDGPU_RING_TYPE_GFX)
2575+ if (need_ctx_switch)
25812576 next_rptr += 2;
25822577
25832578 next_rptr += 4;
@@ -2588,7 +2583,7 @@ static void gfx_v7_0_ring_emit_ib(struct amdgpu_ring *ring, · 4 unmodified lines
25882583 amdgpu_ring_write(ring, next_rptr);
25892584
25902585 /* insert SWITCH_BUFFER packet before first IB in the ring frame */
2591− if (need_ctx_switch && ring->type == AMDGPU_RING_TYPE_GFX) {
2586+ if (need_ctx_switch) {
25922587 amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
25932588 amdgpu_ring_write(ring, 0);
25942589 }
@@ -2611,6 +2606,35 @@ static void gfx_v7_0_ring_emit_ib(struct amdgpu_ring *ring, · 16 unmodified lines
26112606 amdgpu_ring_write(ring, control);
26122607 }
26132608
2609+static void gfx_v7_0_ring_emit_ib_compute(struct amdgpu_ring *ring,
2610+ struct amdgpu_ib *ib)
2611+{
2612+ u32 header, control = 0;
2613+ u32 next_rptr = ring->wptr + 5;
2614+
2615+ control |= INDIRECT_BUFFER_VALID;
2616+ next_rptr += 4;
2617+ amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
2618+ amdgpu_ring_write(ring, WRITE_DATA_DST_SEL(5) | WR_CONFIRM);
2619+ amdgpu_ring_write(ring, ring->next_rptr_gpu_addr & 0xfffffffc);
2620+ amdgpu_ring_write(ring, upper_32_bits(ring->next_rptr_gpu_addr) & 0xffffffff);
2621+ amdgpu_ring_write(ring, next_rptr);
2622+
2623+ header = PACKET3(PACKET3_INDIRECT_BUFFER, 2);
2624+
2625+ control |= ib->length_dw |
2626+ (ib->vm ? (ib->vm->ids[ring->idx].id << 24) : 0);
2627+
2628+ amdgpu_ring_write(ring, header);
2629+ amdgpu_ring_write(ring,
2630+#ifdef __BIG_ENDIAN
2631+ (2 << 0) |
2632+#endif
2633+ (ib->gpu_addr & 0xFFFFFFFC));
2634+ amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFFFF);
2635+ amdgpu_ring_write(ring, control);
2636+}
2637+
26142638 /**
26152639 * gfx_v7_0_ring_test_ib - basic ring IB test
26162640 *
@@ -3056,6 +3080,8 @@ static int gfx_v7_0_cp_compute_load_microcode(struct amdgpu_device *adev) · 439 unmodified lines
30563080 mec_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data;
30573081 amdgpu_ucode_print_gfx_hdr(&mec_hdr->header);
30583082 adev->gfx.mec_fw_version = le32_to_cpu(mec_hdr->header.ucode_version);
3083+ adev->gfx.mec_feature_version = le32_to_cpu(
3084+ mec_hdr->ucode_feature_version);
30593085
30603086 gfx_v7_0_cp_compute_enable(adev, false);
30613087
@@ -3078,6 +3104,8 @@ static int gfx_v7_0_cp_compute_load_microcode(struct amdgpu_device *adev) · 16 unmodified lines
30783104 mec2_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec2_fw->data;
30793105 amdgpu_ucode_print_gfx_hdr(&mec2_hdr->header);
30803106 adev->gfx.mec2_fw_version = le32_to_cpu(mec2_hdr->header.ucode_version);
3107+ adev->gfx.mec2_feature_version = le32_to_cpu(
3108+ mec2_hdr->ucode_feature_version);
30813109
30823110 /* MEC2 */
30833111 fw_data = (const __le32 *)
@@ -4042,6 +4070,8 @@ static int gfx_v7_0_rlc_resume(struct amdgpu_device *adev) · 958 unmodified lines
40424070 hdr = (const struct rlc_firmware_header_v1_0 *)adev->gfx.rlc_fw->data;
40434071 amdgpu_ucode_print_rlc_hdr(&hdr->header);
40444072 adev->gfx.rlc_fw_version = le32_to_cpu(hdr->header.ucode_version);
4073+ adev->gfx.rlc_feature_version = le32_to_cpu(
4074+ hdr->ucode_feature_version);
40454075
40464076 gfx_v7_0_rlc_stop(adev);
40474077
@@ -5098,7 +5128,7 @@ static void gfx_v7_0_print_status(void *handle) · 1050 unmodified lines
50985128 dev_info(adev->dev, " CP_HPD_EOP_CONTROL=0x%08X\n",
50995129 RREG32(mmCP_HPD_EOP_CONTROL));
51005130
5101− for (queue = 0; queue < 8; i++) {
5131+ for (queue = 0; queue < 8; queue++) {
51025132 cik_srbm_select(adev, me, pipe, queue, 0);
51035133 dev_info(adev->dev, " queue: %d\n", queue);
51045134 dev_info(adev->dev, " CP_PQ_WPTR_POLL_CNTL=0x%08X\n",
@@ -5555,7 +5585,7 @@ static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_gfx = { · 450 unmodified lines
55555585 .get_wptr = gfx_v7_0_ring_get_wptr_gfx,
55565586 .set_wptr = gfx_v7_0_ring_set_wptr_gfx,
55575587 .parse_cs = NULL,
5558− .emit_ib = gfx_v7_0_ring_emit_ib,
5588+ .emit_ib = gfx_v7_0_ring_emit_ib_gfx,
55595589 .emit_fence = gfx_v7_0_ring_emit_fence_gfx,
55605590 .emit_semaphore = gfx_v7_0_ring_emit_semaphore,
55615591 .emit_vm_flush = gfx_v7_0_ring_emit_vm_flush,
@@ -5571,7 +5601,7 @@ static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute = { · 9 unmodified lines
55715601 .get_wptr = gfx_v7_0_ring_get_wptr_compute,
55725602 .set_wptr = gfx_v7_0_ring_set_wptr_compute,
55735603 .parse_cs = NULL,
5574− .emit_ib = gfx_v7_0_ring_emit_ib,
5604+ .emit_ib = gfx_v7_0_ring_emit_ib_compute,
55755605 .emit_fence = gfx_v7_0_ring_emit_fence_compute,
55765606 .emit_semaphore = gfx_v7_0_ring_emit_semaphore,
55775607 .emit_vm_flush = gfx_v7_0_ring_emit_vm_flush,
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c+60−25
@@ -587,6 +587,7 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 586 unmodified lines
587587 int err;
588588 struct amdgpu_firmware_info *info = NULL;
589589 const struct common_firmware_header *header = NULL;
590+ const struct gfx_firmware_header_v1_0 *cp_hdr;
590591
591592 DRM_DEBUG("\n");
592593
@@ -611,6 +612,9 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 18 unmodified lines
611612 err = amdgpu_ucode_validate(adev->gfx.pfp_fw);
612613 if (err)
613614 goto out;
615+ cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data;
616+ adev->gfx.pfp_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
617+ adev->gfx.pfp_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
614618
615619 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me.bin", chip_name);
616620 err = request_firmware(&adev->gfx.me_fw, fw_name, adev->dev);
@@ -619,6 +623,9 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 2 unmodified lines
619623 err = amdgpu_ucode_validate(adev->gfx.me_fw);
620624 if (err)
621625 goto out;
626+ cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data;
627+ adev->gfx.me_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
628+ adev->gfx.me_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
622629
623630 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce.bin", chip_name);
624631 err = request_firmware(&adev->gfx.ce_fw, fw_name, adev->dev);
@@ -627,12 +634,18 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 2 unmodified lines
627634 err = amdgpu_ucode_validate(adev->gfx.ce_fw);
628635 if (err)
629636 goto out;
637+ cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data;
638+ adev->gfx.ce_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
639+ adev->gfx.ce_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
630640
631641 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", chip_name);
632642 err = request_firmware(&adev->gfx.rlc_fw, fw_name, adev->dev);
633643 if (err)
634644 goto out;
635645 err = amdgpu_ucode_validate(adev->gfx.rlc_fw);
646+ cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.rlc_fw->data;
647+ adev->gfx.rlc_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
648+ adev->gfx.rlc_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
636649
637650 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name);
638651 err = request_firmware(&adev->gfx.mec_fw, fw_name, adev->dev);
@@ -641,6 +654,9 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 2 unmodified lines
641654 err = amdgpu_ucode_validate(adev->gfx.mec_fw);
642655 if (err)
643656 goto out;
657+ cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data;
658+ adev->gfx.mec_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
659+ adev->gfx.mec_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
644660
645661 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec2.bin", chip_name);
646662 err = request_firmware(&adev->gfx.mec2_fw, fw_name, adev->dev);
@@ -648,6 +664,12 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 1 unmodified line
648664 err = amdgpu_ucode_validate(adev->gfx.mec2_fw);
649665 if (err)
650666 goto out;
667+ cp_hdr = (const struct gfx_firmware_header_v1_0 *)
668+ adev->gfx.mec2_fw->data;
669+ adev->gfx.mec2_fw_version = le32_to_cpu(
670+ cp_hdr->header.ucode_version);
671+ adev->gfx.mec2_feature_version = le32_to_cpu(
672+ cp_hdr->ucode_feature_version);
651673 } else {
652674 err = 0;
653675 adev->gfx.mec2_fw = NULL;
@@ -1983,6 +2005,7 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) · 1329 unmodified lines
19832005 adev->gfx.config.max_shader_engines = 1;
19842006 adev->gfx.config.max_tile_pipes = 2;
19852007 adev->gfx.config.max_sh_per_se = 1;
2008+ adev->gfx.config.max_backends_per_se = 2;
19862009
19872010 switch (adev->pdev->revision) {
19882011 case 0xc4:
@@ -1991,7 +2014,6 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) · 2 unmodified lines
19912014 case 0xcc:
19922015 /* B10 */
19932016 adev->gfx.config.max_cu_per_sh = 8;
1994− adev->gfx.config.max_backends_per_se = 2;
19952017 break;
19962018 case 0xc5:
19972019 case 0x81:
@@ -2000,14 +2022,12 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) · 2 unmodified lines
20002022 case 0xcd:
20012023 /* B8 */
20022024 adev->gfx.config.max_cu_per_sh = 6;
2003− adev->gfx.config.max_backends_per_se = 2;
20042025 break;
20052026 case 0xc6:
20062027 case 0xca:
20072028 case 0xce:
20082029 /* B6 */
20092030 adev->gfx.config.max_cu_per_sh = 6;
2010− adev->gfx.config.max_backends_per_se = 2;
20112031 break;
20122032 case 0xc7:
20132033 case 0x87:
@@ -2015,7 +2035,6 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) · 1 unmodified line
20152035 default:
20162036 /* B4 */
20172037 adev->gfx.config.max_cu_per_sh = 4;
2018− adev->gfx.config.max_backends_per_se = 1;
20192038 break;
20202039 }
20212040
@@ -2275,7 +2294,6 @@ static int gfx_v8_0_rlc_load_microcode(struct amdgpu_device *adev) · 253 unmodified lines
22752294
22762295 hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data;
22772296 amdgpu_ucode_print_rlc_hdr(&hdr->header);
2278− adev->gfx.rlc_fw_version = le32_to_cpu(hdr->header.ucode_version);
22792297
22802298 fw_data = (const __le32 *)(adev->gfx.rlc_fw->data +
22812299 le32_to_cpu(hdr->header.ucode_array_offset_bytes));
@@ -2361,12 +2379,6 @@ static int gfx_v8_0_cp_gfx_load_microcode(struct amdgpu_device *adev) · 79 unmodified lines
23612379 amdgpu_ucode_print_gfx_hdr(&pfp_hdr->header);
23622380 amdgpu_ucode_print_gfx_hdr(&ce_hdr->header);
23632381 amdgpu_ucode_print_gfx_hdr(&me_hdr->header);
2364− adev->gfx.pfp_fw_version = le32_to_cpu(pfp_hdr->header.ucode_version);
2365− adev->gfx.ce_fw_version = le32_to_cpu(ce_hdr->header.ucode_version);
2366− adev->gfx.me_fw_version = le32_to_cpu(me_hdr->header.ucode_version);
2367− adev->gfx.me_feature_version = le32_to_cpu(me_hdr->ucode_feature_version);
2368− adev->gfx.ce_feature_version = le32_to_cpu(ce_hdr->ucode_feature_version);
2369− adev->gfx.pfp_feature_version = le32_to_cpu(pfp_hdr->ucode_feature_version);
23702382
23712383 gfx_v8_0_cp_gfx_enable(adev, false);
23722384
@@ -2622,7 +2634,6 @@ static int gfx_v8_0_cp_compute_load_microcode(struct amdgpu_device *adev) · 249 unmodified lines
26222634
26232635 mec_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data;
26242636 amdgpu_ucode_print_gfx_hdr(&mec_hdr->header);
2625− adev->gfx.mec_fw_version = le32_to_cpu(mec_hdr->header.ucode_version);
26262637
26272638 fw_data = (const __le32 *)
26282639 (adev->gfx.mec_fw->data +
@@ -2641,7 +2652,6 @@ static int gfx_v8_0_cp_compute_load_microcode(struct amdgpu_device *adev) · 12 unmodified lines
26412652
26422653 mec2_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec2_fw->data;
26432654 amdgpu_ucode_print_gfx_hdr(&mec2_hdr->header);
2644− adev->gfx.mec2_fw_version = le32_to_cpu(mec2_hdr->header.ucode_version);
26452655
26462656 fw_data = (const __le32 *)
26472657 (adev->gfx.mec2_fw->data +
@@ -3125,7 +3135,7 @@ static int gfx_v8_0_cp_compute_resume(struct amdgpu_device *adev) · 477 unmodified lines
31253135 WREG32(mmCP_MEC_DOORBELL_RANGE_LOWER,
31263136 AMDGPU_DOORBELL_KIQ << 2);
31273137 WREG32(mmCP_MEC_DOORBELL_RANGE_UPPER,
3128− 0x7FFFF << 2);
3138+ AMDGPU_DOORBELL_MEC_RING7 << 2);
31293139 }
31303140 tmp = RREG32(mmCP_HQD_PQ_DOORBELL_CONTROL);
31313141 tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
@@ -3753,7 +3763,7 @@ static void gfx_v8_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) · 621 unmodified lines
37533763 amdgpu_ring_write(ring, 0x20); /* poll interval */
37543764 }
37553765
3756−static void gfx_v8_0_ring_emit_ib(struct amdgpu_ring *ring,
3766+static void gfx_v8_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
37573767 struct amdgpu_ib *ib)
37583768 {
37593769 bool need_ctx_switch = ring->current_ctx != ib->ctx;
@@ -3761,15 +3771,10 @@ static void gfx_v8_0_ring_emit_ib(struct amdgpu_ring *ring, · 1 unmodified line
37613771 u32 next_rptr = ring->wptr + 5;
37623772
37633773 /* drop the CE preamble IB for the same context */
3764− if ((ring->type == AMDGPU_RING_TYPE_GFX) &&
3765− (ib->flags & AMDGPU_IB_FLAG_PREAMBLE) &&
3766− !need_ctx_switch)
3774+ if ((ib->flags & AMDGPU_IB_FLAG_PREAMBLE) && !need_ctx_switch)
37673775 return;
37683776
3769− if (ring->type == AMDGPU_RING_TYPE_COMPUTE)
3770− control |= INDIRECT_BUFFER_VALID;
3771−
3772− if (need_ctx_switch && ring->type == AMDGPU_RING_TYPE_GFX)
3777+ if (need_ctx_switch)
37733778 next_rptr += 2;
37743779
37753780 next_rptr += 4;
@@ -3780,7 +3785,7 @@ static void gfx_v8_0_ring_emit_ib(struct amdgpu_ring *ring, · 4 unmodified lines
37803785 amdgpu_ring_write(ring, next_rptr);
37813786
37823787 /* insert SWITCH_BUFFER packet before first IB in the ring frame */
3783− if (need_ctx_switch && ring->type == AMDGPU_RING_TYPE_GFX) {
3788+ if (need_ctx_switch) {
37843789 amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
37853790 amdgpu_ring_write(ring, 0);
37863791 }
@@ -3803,6 +3808,36 @@ static void gfx_v8_0_ring_emit_ib(struct amdgpu_ring *ring, · 16 unmodified lines
38033808 amdgpu_ring_write(ring, control);
38043809 }
38053810
3811+static void gfx_v8_0_ring_emit_ib_compute(struct amdgpu_ring *ring,
3812+ struct amdgpu_ib *ib)
3813+{
3814+ u32 header, control = 0;
3815+ u32 next_rptr = ring->wptr + 5;
3816+
3817+ control |= INDIRECT_BUFFER_VALID;
3818+
3819+ next_rptr += 4;
3820+ amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
3821+ amdgpu_ring_write(ring, WRITE_DATA_DST_SEL(5) | WR_CONFIRM);
3822+ amdgpu_ring_write(ring, ring->next_rptr_gpu_addr & 0xfffffffc);
3823+ amdgpu_ring_write(ring, upper_32_bits(ring->next_rptr_gpu_addr) & 0xffffffff);
3824+ amdgpu_ring_write(ring, next_rptr);
3825+
3826+ header = PACKET3(PACKET3_INDIRECT_BUFFER, 2);
3827+
3828+ control |= ib->length_dw |
3829+ (ib->vm ? (ib->vm->ids[ring->idx].id << 24) : 0);
3830+
3831+ amdgpu_ring_write(ring, header);
3832+ amdgpu_ring_write(ring,
3833+#ifdef __BIG_ENDIAN
3834+ (2 << 0) |
3835+#endif
3836+ (ib->gpu_addr & 0xFFFFFFFC));
3837+ amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFFFF);
3838+ amdgpu_ring_write(ring, control);
3839+}
3840+
38063841 static void gfx_v8_0_ring_emit_fence_gfx(struct amdgpu_ring *ring, u64 addr,
38073842 u64 seq, unsigned flags)
38083843 {
@@ -4224,7 +4259,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = { · 415 unmodified lines
42244259 .get_wptr = gfx_v8_0_ring_get_wptr_gfx,
42254260 .set_wptr = gfx_v8_0_ring_set_wptr_gfx,
42264261 .parse_cs = NULL,
4227− .emit_ib = gfx_v8_0_ring_emit_ib,
4262+ .emit_ib = gfx_v8_0_ring_emit_ib_gfx,
42284263 .emit_fence = gfx_v8_0_ring_emit_fence_gfx,
42294264 .emit_semaphore = gfx_v8_0_ring_emit_semaphore,
42304265 .emit_vm_flush = gfx_v8_0_ring_emit_vm_flush,
@@ -4240,7 +4275,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = { · 9 unmodified lines
42404275 .get_wptr = gfx_v8_0_ring_get_wptr_compute,
42414276 .set_wptr = gfx_v8_0_ring_set_wptr_compute,
42424277 .parse_cs = NULL,
4243− .emit_ib = gfx_v8_0_ring_emit_ib,
4278+ .emit_ib = gfx_v8_0_ring_emit_ib_compute,
42444279 .emit_fence = gfx_v8_0_ring_emit_fence_compute,
42454280 .emit_semaphore = gfx_v8_0_ring_emit_semaphore,
42464281 .emit_vm_flush = gfx_v8_0_ring_emit_vm_flush,
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c+4−2
@@ -121,6 +121,7 @@ static int sdma_v2_4_init_microcode(struct amdgpu_device *adev) · 120 unmodified lines
121121 int err, i;
122122 struct amdgpu_firmware_info *info = NULL;
123123 const struct common_firmware_header *header = NULL;
124+ const struct sdma_firmware_header_v1_0 *hdr;
124125
125126 DRM_DEBUG("\n");
126127
@@ -142,6 +143,9 @@ static int sdma_v2_4_init_microcode(struct amdgpu_device *adev) · 15 unmodified lines
142143 err = amdgpu_ucode_validate(adev->sdma[i].fw);
143144 if (err)
144145 goto out;
146+ hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma[i].fw->data;
147+ adev->sdma[i].fw_version = le32_to_cpu(hdr->header.ucode_version);
148+ adev->sdma[i].feature_version = le32_to_cpu(hdr->ucode_feature_version);
145149
146150 if (adev->firmware.smu_load) {
147151 info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i];
@@ -541,8 +545,6 @@ static int sdma_v2_4_load_microcode(struct amdgpu_device *adev) · 393 unmodified lines
541545 hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma[i].fw->data;
542546 amdgpu_ucode_print_sdma_hdr(&hdr->header);
543547 fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4;
544− adev->sdma[i].fw_version = le32_to_cpu(hdr->header.ucode_version);
545−
546548 fw_data = (const __le32 *)
547549 (adev->sdma[i].fw->data +
548550 le32_to_cpu(hdr->header.ucode_array_offset_bytes));
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c+4−2
@@ -159,6 +159,7 @@ static int sdma_v3_0_init_microcode(struct amdgpu_device *adev) · 158 unmodified lines
159159 int err, i;
160160 struct amdgpu_firmware_info *info = NULL;
161161 const struct common_firmware_header *header = NULL;
162+ const struct sdma_firmware_header_v1_0 *hdr;
162163
163164 DRM_DEBUG("\n");
164165
@@ -183,6 +184,9 @@ static int sdma_v3_0_init_microcode(struct amdgpu_device *adev) · 18 unmodified lines
183184 err = amdgpu_ucode_validate(adev->sdma[i].fw);
184185 if (err)
185186 goto out;
187+ hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma[i].fw->data;
188+ adev->sdma[i].fw_version = le32_to_cpu(hdr->header.ucode_version);
189+ adev->sdma[i].feature_version = le32_to_cpu(hdr->ucode_feature_version);
186190
187191 if (adev->firmware.smu_load) {
188192 info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i];
@@ -630,8 +634,6 @@ static int sdma_v3_0_load_microcode(struct amdgpu_device *adev) · 441 unmodified lines
630634 hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma[i].fw->data;
631635 amdgpu_ucode_print_sdma_hdr(&hdr->header);
632636 fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4;
633− adev->sdma[i].fw_version = le32_to_cpu(hdr->header.ucode_version);
634−
635637 fw_data = (const __le32 *)
636638 (adev->sdma[i].fw->data +
637639 le32_to_cpu(hdr->header.ucode_array_offset_bytes));
drivers/gpu/drm/drm_atomic_helper.c+9−1
@@ -196,7 +196,12 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx) · 195 unmodified lines
196196 }
197197
198198 funcs = connector->helper_private;
199− new_encoder = funcs->best_encoder(connector);
199+
200+ if (funcs->atomic_best_encoder)
201+ new_encoder = funcs->atomic_best_encoder(connector,
202+ connector_state);
203+ else
204+ new_encoder = funcs->best_encoder(connector);
200205
201206 if (!new_encoder) {
202207 DRM_DEBUG_ATOMIC("No suitable encoder found for [CONNECTOR:%d:%s]\n",
@@ -229,6 +234,9 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx) · 26 unmodified lines
229234 }
230235 }
231236
237+ if (WARN_ON(!connector_state->crtc))
238+ return -EINVAL;
239+
232240 connector_state->best_encoder = new_encoder;
233241 idx = drm_crtc_index(connector_state->crtc);
234242
drivers/gpu/drm/drm_dp_mst_topology.c+13−7
@@ -873,9 +873,10 @@ static void drm_dp_destroy_port(struct kref *kref) · 872 unmodified lines
873873 from an EDID retrieval */
874874 if (port->connector) {
875875 mutex_lock(&mgr->destroy_connector_lock);
876− list_add(&port->connector->destroy_list, &mgr->destroy_connector_list);
876+ list_add(&port->next, &mgr->destroy_connector_list);
877877 mutex_unlock(&mgr->destroy_connector_lock);
878878 schedule_work(&mgr->destroy_connector_work);
879+ return;
879880 }
880881 drm_dp_port_teardown_pdt(port, port->pdt);
881882
@@ -1294,7 +1295,6 @@ retry: · 412 unmodified lines
12941295 goto retry;
12951296 }
12961297 DRM_DEBUG_KMS("failed to dpcd write %d %d\n", tosend, ret);
1297− WARN(1, "fail\n");
12981298
12991299 return -EIO;
13001300 }
@@ -2660,7 +2660,7 @@ static void drm_dp_tx_work(struct work_struct *work) · 1359 unmodified lines
26602660 static void drm_dp_destroy_connector_work(struct work_struct *work)
26612661 {
26622662 struct drm_dp_mst_topology_mgr *mgr = container_of(work, struct drm_dp_mst_topology_mgr, destroy_connector_work);
2663− struct drm_connector *connector;
2663+ struct drm_dp_mst_port *port;
26642664
26652665 /*
26662666 * Not a regular list traverse as we have to drop the destroy
@@ -2669,15 +2669,21 @@ static void drm_dp_destroy_connector_work(struct work_struct *work) · 2 unmodified lines
26692669 */
26702670 for (;;) {
26712671 mutex_lock(&mgr->destroy_connector_lock);
2672− connector = list_first_entry_or_null(&mgr->destroy_connector_list, struct drm_connector, destroy_list);
2673− if (!connector) {
2672+ port = list_first_entry_or_null(&mgr->destroy_connector_list, struct drm_dp_mst_port, next);
2673+ if (!port) {
26742674 mutex_unlock(&mgr->destroy_connector_lock);
26752675 break;
26762676 }
2677− list_del(&connector->destroy_list);
2677+ list_del(&port->next);
26782678 mutex_unlock(&mgr->destroy_connector_lock);
26792679
2680− mgr->cbs->destroy_connector(mgr, connector);
2680+ mgr->cbs->destroy_connector(mgr, port->connector);
2681+
2682+ drm_dp_port_teardown_pdt(port, port->pdt);
2683+
2684+ if (!port->input && port->vcpi.vcpi > 0)
2685+ drm_dp_mst_put_payload_id(mgr, port->vcpi.vcpi);
2686+ kfree(port);
26812687 }
26822688 }
26832689
drivers/gpu/drm/drm_irq.c+1−1
@@ -75,7 +75,7 @@ module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600) · 74 unmodified lines
7575 module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600);
7676
7777 static void store_vblank(struct drm_device *dev, int crtc,
78− unsigned vblank_count_inc,
78+ u32 vblank_count_inc,
7979 struct timeval *t_vblank)
8080 {
8181 struct drm_vblank_crtc *vblank = &dev->vblank[crtc];
drivers/gpu/drm/exynos/exynos_drm_fimc.c+0−1
@@ -1745,7 +1745,6 @@ static int fimc_probe(struct platform_device *pdev) · 1744 unmodified lines
17451745 spin_lock_init(&ctx->lock);
17461746 platform_set_drvdata(pdev, ctx);
17471747
1748− pm_runtime_set_active(dev);
17491748 pm_runtime_enable(dev);
17501749
17511750 ret = exynos_drm_ippdrv_register(ippdrv);
drivers/gpu/drm/exynos/exynos_drm_gsc.c+2−4
@@ -593,8 +593,7 @@ static int gsc_src_set_transf(struct device *dev, · 592 unmodified lines
593593
594594 gsc_write(cfg, GSC_IN_CON);
595595
596− ctx->rotation = cfg &
597− (GSC_IN_ROT_90 | GSC_IN_ROT_270) ? 1 : 0;
596+ ctx->rotation = (cfg & GSC_IN_ROT_90) ? 1 : 0;
598597 *swap = ctx->rotation;
599598
600599 return 0;
@@ -857,8 +856,7 @@ static int gsc_dst_set_transf(struct device *dev, · 256 unmodified lines
857856
858857 gsc_write(cfg, GSC_IN_CON);
859858
860− ctx->rotation = cfg &
861− (GSC_IN_ROT_90 | GSC_IN_ROT_270) ? 1 : 0;
859+ ctx->rotation = (cfg & GSC_IN_ROT_90) ? 1 : 0;
862860 *swap = ctx->rotation;
863861
864862 return 0;
drivers/gpu/drm/exynos/exynos_hdmi.c+6−1
@@ -1064,6 +1064,7 @@ static int hdmi_get_modes(struct drm_connector *connector) · 1063 unmodified lines
10641064 {
10651065 struct hdmi_context *hdata = ctx_from_connector(connector);
10661066 struct edid *edid;
1067+ int ret;
10671068
10681069 if (!hdata->ddc_adpt)
10691070 return -ENODEV;
@@ -1079,7 +1080,11 @@ static int hdmi_get_modes(struct drm_connector *connector) · 9 unmodified lines
10791080
10801081 drm_mode_connector_update_edid_property(connector, edid);
10811082
1082− return drm_add_edid_modes(connector, edid);
1083+ ret = drm_add_edid_modes(connector, edid);
1084+
1085+ kfree(edid);
1086+
1087+ return ret;
10831088 }
10841089
10851090 static int hdmi_find_phy_conf(struct hdmi_context *hdata, u32 pixel_clock)
drivers/gpu/drm/exynos/exynos_mixer.c+14−7
@@ -718,6 +718,10 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg) · 717 unmodified lines
718718
719719 /* handling VSYNC */
720720 if (val & MXR_INT_STATUS_VSYNC) {
721+ /* vsync interrupt use different bit for read and clear */
722+ val |= MXR_INT_CLEAR_VSYNC;
723+ val &= ~MXR_INT_STATUS_VSYNC;
724+
721725 /* interlace scan need to check shadow register */
722726 if (ctx->interlace) {
723727 base = mixer_reg_read(res, MXR_GRAPHIC_BASE(0));
@@ -743,11 +747,6 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg) · 19 unmodified lines
743747
744748 out:
745749 /* clear interrupts */
746− if (~val & MXR_INT_EN_VSYNC) {
747− /* vsync interrupt use different bit for read and clear */
748− val &= ~MXR_INT_EN_VSYNC;
749− val |= MXR_INT_CLEAR_VSYNC;
750− }
751750 mixer_reg_write(res, MXR_INT_STATUS, val);
752751
753752 spin_unlock(&res->reg_slock);
@@ -907,8 +906,8 @@ static int mixer_enable_vblank(struct exynos_drm_crtc *crtc) · 153 unmodified lines
907906 }
908907
909908 /* enable vsync interrupt */
910− mixer_reg_writemask(res, MXR_INT_EN, MXR_INT_EN_VSYNC,
911− MXR_INT_EN_VSYNC);
909+ mixer_reg_writemask(res, MXR_INT_STATUS, ~0, MXR_INT_CLEAR_VSYNC);
910+ mixer_reg_writemask(res, MXR_INT_EN, ~0, MXR_INT_EN_VSYNC);
912911
913912 return 0;
914913 }
@@ -918,7 +917,13 @@ static void mixer_disable_vblank(struct exynos_drm_crtc *crtc) · 3 unmodified lines
918917 struct mixer_context *mixer_ctx = crtc->ctx;
919918 struct mixer_resources *res = &mixer_ctx->mixer_res;
920919
920+ if (!mixer_ctx->powered) {
921+ mixer_ctx->int_en &= MXR_INT_EN_VSYNC;
922+ return;
923+ }
924+
921925 /* disable vsync interrupt */
926+ mixer_reg_writemask(res, MXR_INT_STATUS, ~0, MXR_INT_CLEAR_VSYNC);
922927 mixer_reg_writemask(res, MXR_INT_EN, 0, MXR_INT_EN_VSYNC);
923928 }
924929
@@ -1047,6 +1052,8 @@ static void mixer_enable(struct exynos_drm_crtc *crtc) · 122 unmodified lines
10471052
10481053 mixer_reg_writemask(res, MXR_STATUS, ~0, MXR_STATUS_SOFT_RESET);
10491054
1055+ if (ctx->int_en & MXR_INT_EN_VSYNC)
1056+ mixer_reg_writemask(res, MXR_INT_STATUS, ~0, MXR_INT_CLEAR_VSYNC);
10501057 mixer_reg_write(res, MXR_INT_EN, ctx->int_en);
10511058 mixer_win_reset(ctx);
10521059 }
drivers/gpu/drm/i2c/tda998x_drv.c+2−2
@@ -606,8 +606,6 @@ static void · 605 unmodified lines
606606 tda998x_write_if(struct tda998x_priv *priv, uint8_t bit, uint16_t addr,
607607 uint8_t *buf, size_t size)
608608 {
609− buf[PB(0)] = tda998x_cksum(buf, size);
610−
611609 reg_clear(priv, REG_DIP_IF_FLAGS, bit);
612610 reg_write_range(priv, addr, buf, size);
613611 reg_set(priv, REG_DIP_IF_FLAGS, bit);
@@ -627,6 +625,8 @@ tda998x_write_aif(struct tda998x_priv *priv, struct tda998x_encoder_params *p) · 13 unmodified lines
627625 buf[PB(4)] = p->audio_frame[4];
628626 buf[PB(5)] = p->audio_frame[5] & 0xf8; /* DM_INH + LSV */
629627
628+ buf[PB(0)] = tda998x_cksum(buf, sizeof(buf));
629+
630630 tda998x_write_if(priv, DIP_IF_FLAGS_IF4, REG_IF4_HB0, buf,
631631 sizeof(buf));
632632 }
drivers/gpu/drm/i915/i915_drv.h+8−9
@@ -3303,15 +3303,14 @@ int intel_freq_opcode(struct drm_i915_private *dev_priv, int val); · 3302 unmodified lines
33033303 #define I915_READ64(reg) dev_priv->uncore.funcs.mmio_readq(dev_priv, (reg), true)
33043304
33053305 #define I915_READ64_2x32(lower_reg, upper_reg) ({ \
3306− u32 upper = I915_READ(upper_reg); \
3307− u32 lower = I915_READ(lower_reg); \
3308− u32 tmp = I915_READ(upper_reg); \
3309− if (upper != tmp) { \
3310− upper = tmp; \
3311− lower = I915_READ(lower_reg); \
3312− WARN_ON(I915_READ(upper_reg) != upper); \
3313− } \
3314− (u64)upper << 32 | lower; })
3306+ u32 upper, lower, tmp; \
3307+ tmp = I915_READ(upper_reg); \
3308+ do { \
3309+ upper = tmp; \
3310+ lower = I915_READ(lower_reg); \
3311+ tmp = I915_READ(upper_reg); \
3312+ } while (upper != tmp); \
3313+ (u64)upper << 32 | lower; })
33153314
33163315 #define POSTING_READ(reg) (void)I915_READ_NOTRACE(reg)
33173316 #define POSTING_READ16(reg) (void)I915_READ16_NOTRACE(reg)
drivers/gpu/drm/i915/i915_gem_gtt.c+11−0
@@ -1923,6 +1923,17 @@ static int ggtt_bind_vma(struct i915_vma *vma, · 1922 unmodified lines
19231923 vma->vm->insert_entries(vma->vm, pages,
19241924 vma->node.start,
19251925 cache_level, pte_flags);
1926+
1927+ /* Note the inconsistency here is due to absence of the
1928+ * aliasing ppgtt on gen4 and earlier. Though we always
1929+ * request PIN_USER for execbuffer (translated to LOCAL_BIND),
1930+ * without the appgtt, we cannot honour that request and so
1931+ * must substitute it with a global binding. Since we do this
1932+ * behind the upper layers back, we need to explicitly set
1933+ * the bound flag ourselves.
1934+ */
1935+ vma->bound |= GLOBAL_BIND;
1936+
19261937 }
19271938
19281939 if (dev_priv->mm.aliasing_ppgtt && flags & LOCAL_BIND) {
drivers/gpu/drm/i915/i915_gem_tiling.c+4−1
@@ -464,7 +464,10 @@ i915_gem_get_tiling(struct drm_device *dev, void *data, · 463 unmodified lines
464464 }
465465
466466 /* Hide bit 17 from the user -- see comment in i915_gem_set_tiling */
467− args->phys_swizzle_mode = args->swizzle_mode;
467+ if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES)
468+ args->phys_swizzle_mode = I915_BIT_6_SWIZZLE_UNKNOWN;
469+ else
470+ args->phys_swizzle_mode = args->swizzle_mode;
468471 if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_17)
469472 args->swizzle_mode = I915_BIT_6_SWIZZLE_9;
470473 if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_10_17)
drivers/gpu/drm/i915/intel_atomic.c+8−37
@@ -129,8 +129,9 @@ int intel_atomic_commit(struct drm_device *dev, · 128 unmodified lines
129129 struct drm_atomic_state *state,
130130 bool async)
131131 {
132− int ret;
133− int i;
132+ struct drm_crtc_state *crtc_state;
133+ struct drm_crtc *crtc;
134+ int ret, i;
134135
135136 if (async) {
136137 DRM_DEBUG_KMS("i915 does not yet support async commit\n");
@@ -142,48 +143,18 @@ int intel_atomic_commit(struct drm_device *dev, · 5 unmodified lines
142143 return ret;
143144
144145 /* Point of no return */
145−
146− /*
147− * FIXME: The proper sequence here will eventually be:
148− *
149− * drm_atomic_helper_swap_state(dev, state)
150− * drm_atomic_helper_commit_modeset_disables(dev, state);
151− * drm_atomic_helper_commit_planes(dev, state);
152− * drm_atomic_helper_commit_modeset_enables(dev, state);
153− * drm_atomic_helper_wait_for_vblanks(dev, state);
154− * drm_atomic_helper_cleanup_planes(dev, state);
155− * drm_atomic_state_free(state);
156− *
157− * once we have full atomic modeset. For now, just manually update
158− * plane states to avoid clobbering good states with dummy states
159− * while nuclear pageflipping.
160− */
161− for (i = 0; i < dev->mode_config.num_total_plane; i++) {
162− struct drm_plane *plane = state->planes[i];
163−
164− if (!plane)
165− continue;
166−
167− plane->state->state = state;
168− swap(state->plane_states[i], plane->state);
169− plane->state->state = NULL;
170− }
146+ drm_atomic_helper_swap_state(dev, state);
171147
172148 /* swap crtc_scaler_state */
173− for (i = 0; i < dev->mode_config.num_crtc; i++) {
174− struct drm_crtc *crtc = state->crtcs[i];
175− if (!crtc) {
176− continue;
177− }
178−
179− to_intel_crtc(crtc)->config->scaler_state =
180− to_intel_crtc_state(state->crtc_states[i])->scaler_state;
149+ for_each_crtc_in_state(state, crtc, crtc_state, i) {
150+ to_intel_crtc(crtc)->config = to_intel_crtc_state(crtc->state);
181151
182152 if (INTEL_INFO(dev)->gen >= 9)
183153 skl_detach_scalers(to_intel_crtc(crtc));
154+
155+ drm_atomic_helper_commit_planes_on_crtc(crtc_state);
184156 }
185157
186− drm_atomic_helper_commit_planes(dev, state);
187158 drm_atomic_helper_wait_for_vblanks(dev, state);
188159 drm_atomic_helper_cleanup_planes(dev, state);
189160 drm_atomic_state_free(state);
drivers/gpu/drm/i915/intel_bios.c+23−4
@@ -1075,15 +1075,34 @@ parse_device_mapping(struct drm_i915_private *dev_priv, · 1074 unmodified lines
10751075 const union child_device_config *p_child;
10761076 union child_device_config *child_dev_ptr;
10771077 int i, child_device_num, count;
1078− u16 block_size;
1078+ u8 expected_size;
1079+ u16 block_size;
10791080
10801081 p_defs = find_section(bdb, BDB_GENERAL_DEFINITIONS);
10811082 if (!p_defs) {
10821083 DRM_DEBUG_KMS("No general definition block is found, no devices defined.\n");
10831084 return;
10841085 }
1085− if (p_defs->child_dev_size < sizeof(*p_child)) {
1086− DRM_ERROR("General definiton block child device size is too small.\n");
1086+ if (bdb->version < 195) {
1087+ expected_size = 33;
1088+ } else if (bdb->version == 195) {
1089+ expected_size = 37;
1090+ } else if (bdb->version <= 197) {
1091+ expected_size = 38;
1092+ } else {
1093+ expected_size = 38;
1094+ DRM_DEBUG_DRIVER("Expected child_device_config size for BDB version %u not known; assuming %u\n",
1095+ expected_size, bdb->version);
1096+ }
1097+
1098+ if (expected_size > sizeof(*p_child)) {
1099+ DRM_ERROR("child_device_config cannot fit in p_child\n");
1100+ return;
1101+ }
1102+
1103+ if (p_defs->child_dev_size != expected_size) {
1104+ DRM_ERROR("Size mismatch; child_device_config size=%u (expected %u); bdb->version: %u\n",
1105+ p_defs->child_dev_size, expected_size, bdb->version);
10871106 return;
10881107 }
10891108 /* get the block size of general definitions */
@@ -1130,7 +1149,7 @@ parse_device_mapping(struct drm_i915_private *dev_priv, · 40 unmodified lines
11301149
11311150 child_dev_ptr = dev_priv->vbt.child_dev + count;
11321151 count++;
1133− memcpy(child_dev_ptr, p_child, sizeof(*p_child));
1152+ memcpy(child_dev_ptr, p_child, p_defs->child_dev_size);
11341153 }
11351154 return;
11361155 }
drivers/gpu/drm/i915/intel_display.c+15−44
@@ -11826,7 +11826,9 @@ encoder_retry: · 11825 unmodified lines
1182611826 goto encoder_retry;
1182711827 }
1182811828
11829− pipe_config->dither = pipe_config->pipe_bpp != base_bpp;
11829+ /* Dithering seems to not pass-through bits correctly when it should, so
11830+ * only enable it on 6bpc panels. */
11831+ pipe_config->dither = pipe_config->pipe_bpp == 6*3;
1183011832 DRM_DEBUG_KMS("plane bpp: %i, pipe bpp: %i, dithering: %i\n",
1183111833 base_bpp, pipe_config->pipe_bpp, pipe_config->dither);
1183211834
@@ -12624,17 +12626,17 @@ static int __intel_set_mode(struct drm_crtc *modeset_crtc, · 791 unmodified lines
1262412626
1262512627 modeset_update_crtc_power_domains(state);
1262612628
12627− drm_atomic_helper_commit_planes(dev, state);
12628−
1262912629 /* Now enable the clocks, plane, pipe, and connectors that we set up. */
1263012630 for_each_crtc_in_state(state, crtc, crtc_state, i) {
12631− if (!needs_modeset(crtc->state) || !crtc->state->enable)
12631+ if (!needs_modeset(crtc->state) || !crtc->state->enable) {
12632+ drm_atomic_helper_commit_planes_on_crtc(crtc_state);
1263212633 continue;
12634+ }
1263312635
1263412636 update_scanline_offset(to_intel_crtc(crtc));
1263512637
1263612638 dev_priv->display.crtc_enable(crtc);
12637− intel_crtc_enable_planes(crtc);
12639+ drm_atomic_helper_commit_planes_on_crtc(crtc_state);
1263812640 }
1263912641
1264012642 /* FIXME: add subpixel order */
@@ -12891,20 +12893,11 @@ intel_modeset_stage_output_state(struct drm_device *dev, · 250 unmodified lines
1289112893 return 0;
1289212894 }
1289312895
12894−static bool primary_plane_visible(struct drm_crtc *crtc)
12895−{
12896− struct intel_plane_state *plane_state =
12897− to_intel_plane_state(crtc->primary->state);
12898−
12899− return plane_state->visible;
12900−}
12901−
1290212896 static int intel_crtc_set_config(struct drm_mode_set *set)
1290312897 {
1290412898 struct drm_device *dev;
1290512899 struct drm_atomic_state *state = NULL;
1290612900 struct intel_crtc_state *pipe_config;
12907− bool primary_plane_was_visible;
1290812901 int ret;
1290912902
1291012903 BUG_ON(!set);
@@ -12943,38 +12936,8 @@ static int intel_crtc_set_config(struct drm_mode_set *set) · 32 unmodified lines
1294312936
1294412937 intel_update_pipe_size(to_intel_crtc(set->crtc));
1294512938
12946− primary_plane_was_visible = primary_plane_visible(set->crtc);
12947−
1294812939 ret = intel_set_mode_with_config(set->crtc, pipe_config, true);
1294912940
12950− if (ret == 0 &&
12951− pipe_config->base.enable &&
12952− pipe_config->base.planes_changed &&
12953− !needs_modeset(&pipe_config->base)) {
12954− struct intel_crtc *intel_crtc = to_intel_crtc(set->crtc);
12955−
12956− /*
12957− * We need to make sure the primary plane is re-enabled if it
12958− * has previously been turned off.
12959− */
12960− if (ret == 0 && !primary_plane_was_visible &&
12961− primary_plane_visible(set->crtc)) {
12962− WARN_ON(!intel_crtc->active);
12963− intel_post_enable_primary(set->crtc);
12964− }
12965−
12966− /*
12967− * In the fastboot case this may be our only check of the
12968− * state after boot. It would be better to only do it on
12969− * the first update, but we don't have a nice way of doing that
12970− * (and really, set_config isn't used much for high freq page
12971− * flipping, so increasing its cost here shouldn't be a big
12972− * deal).
12973− */
12974− if (i915.fastboot && ret == 0)
12975− intel_modeset_check_state(set->crtc->dev);
12976− }
12977−
1297812941 if (ret) {
1297912942 DRM_DEBUG_KMS("failed to set mode on [CRTC:%d], err = %d\n",
1298012943 set->crtc->base.id, ret);
@@ -13305,6 +13268,9 @@ intel_check_primary_plane(struct drm_plane *plane, · 324 unmodified lines
1330513268 */
1330613269 if (IS_BROADWELL(dev))
1330713270 intel_crtc->atomic.wait_vblank = true;
13271+
13272+ if (crtc_state)
13273+ intel_crtc->atomic.post_enable_primary = true;
1330813274 }
1330913275
1331013276 /*
@@ -13317,6 +13283,10 @@ intel_check_primary_plane(struct drm_plane *plane, · 6 unmodified lines
1331713283 if (!state->visible || !fb)
1331813284 intel_crtc->atomic.disable_ips = true;
1331913285
13286+ if (!state->visible && old_state->visible &&
13287+ crtc_state && !needs_modeset(&crtc_state->base))
13288+ intel_crtc->atomic.pre_disable_primary = true;
13289+
1332013290 intel_crtc->atomic.fb_bits |=
1332113291 INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe);
1332213292
@@ -15034,6 +15004,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) · 1711 unmodified lines
1503415004 struct intel_plane_state *plane_state;
1503515005
1503615006 memset(crtc->config, 0, sizeof(*crtc->config));
15007+ crtc->config->base.crtc = &crtc->base;
1503715008
1503815009 crtc->config->quirks |= PIPE_CONFIG_QUIRK_INHERITED_MODE;
1503915010
drivers/gpu/drm/i915/intel_dp_mst.c+11−0
@@ -357,6 +357,16 @@ intel_dp_mst_mode_valid(struct drm_connector *connector, · 356 unmodified lines
357357 return MODE_OK;
358358 }
359359
360+static struct drm_encoder *intel_mst_atomic_best_encoder(struct drm_connector *connector,
361+ struct drm_connector_state *state)
362+{
363+ struct intel_connector *intel_connector = to_intel_connector(connector);
364+ struct intel_dp *intel_dp = intel_connector->mst_port;
365+ struct intel_crtc *crtc = to_intel_crtc(state->crtc);
366+
367+ return &intel_dp->mst_encoders[crtc->pipe]->base.base;
368+}
369+
360370 static struct drm_encoder *intel_mst_best_encoder(struct drm_connector *connector)
361371 {
362372 struct intel_connector *intel_connector = to_intel_connector(connector);
@@ -367,6 +377,7 @@ static struct drm_encoder *intel_mst_best_encoder(struct drm_connector *connecto · 4 unmodified lines
367377 static const struct drm_connector_helper_funcs intel_dp_mst_connector_helper_funcs = {
368378 .get_modes = intel_dp_mst_get_modes,
369379 .mode_valid = intel_dp_mst_mode_valid,
380+ .atomic_best_encoder = intel_mst_atomic_best_encoder,
370381 .best_encoder = intel_mst_best_encoder,
371382 };
372383
drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c+3−1
@@ -220,13 +220,15 @@ static int mdp4_plane_mode_set(struct drm_plane *plane, · 219 unmodified lines
220220 uint32_t op_mode = 0;
221221 uint32_t phasex_step = MDP4_VG_PHASE_STEP_DEFAULT;
222222 uint32_t phasey_step = MDP4_VG_PHASE_STEP_DEFAULT;
223− enum mdp4_frame_format frame_type = mdp4_get_frame_format(fb);
223+ enum mdp4_frame_format frame_type;
224224
225225 if (!(crtc && fb)) {
226226 DBG("%s: disabled!", mdp4_plane->name);
227227 return 0;
228228 }
229229
230+ frame_type = mdp4_get_frame_format(fb);
231+
230232 /* src values are in Q16 fixed point, convert to integer: */
231233 src_x = src_x >> 16;
232234 src_y = src_y >> 16;
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c+13−0
@@ -76,7 +76,20 @@ static void mdp5_prepare_commit(struct msm_kms *kms, struct drm_atomic_state *st · 75 unmodified lines
7676
7777 static void mdp5_complete_commit(struct msm_kms *kms, struct drm_atomic_state *state)
7878 {
79+ int i;
7980 struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
81+ int nplanes = mdp5_kms->dev->mode_config.num_total_plane;
82+
83+ for (i = 0; i < nplanes; i++) {
84+ struct drm_plane *plane = state->planes[i];
85+ struct drm_plane_state *plane_state = state->plane_states[i];
86+
87+ if (!plane)
88+ continue;
89+
90+ mdp5_plane_complete_commit(plane, plane_state);
91+ }
92+
8093 mdp5_disable(mdp5_kms);
8194 }
8295
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h+2−0
@@ -227,6 +227,8 @@ void mdp5_plane_install_properties(struct drm_plane *plane, · 226 unmodified lines
227227 struct drm_mode_object *obj);
228228 uint32_t mdp5_plane_get_flush(struct drm_plane *plane);
229229 void mdp5_plane_complete_flip(struct drm_plane *plane);
230+void mdp5_plane_complete_commit(struct drm_plane *plane,
231+ struct drm_plane_state *state);
230232 enum mdp5_pipe mdp5_plane_pipe(struct drm_plane *plane);
231233 struct drm_plane *mdp5_plane_init(struct drm_device *dev,
232234 enum mdp5_pipe pipe, bool private_plane, uint32_t reg_offset);
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c+14−19
@@ -31,8 +31,6 @@ struct mdp5_plane { · 30 unmodified lines
3131
3232 uint32_t nformats;
3333 uint32_t formats[32];
34−
35− bool enabled;
3634 };
3735 #define to_mdp5_plane(x) container_of(x, struct mdp5_plane, base)
3836
@@ -56,22 +54,6 @@ static bool plane_enabled(struct drm_plane_state *state) · 17 unmodified lines
5654 return state->fb && state->crtc;
5755 }
5856
59−static int mdp5_plane_disable(struct drm_plane *plane)
60−{
61− struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
62− struct mdp5_kms *mdp5_kms = get_kms(plane);
63− enum mdp5_pipe pipe = mdp5_plane->pipe;
64−
65− DBG("%s: disable", mdp5_plane->name);
66−
67− if (mdp5_kms) {
68− /* Release the memory we requested earlier from the SMP: */
69− mdp5_smp_release(mdp5_kms->smp, pipe);
70− }
71−
72− return 0;
73−}
74−
7557 static void mdp5_plane_destroy(struct drm_plane *plane)
7658 {
7759 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
@@ -224,7 +206,6 @@ static void mdp5_plane_atomic_update(struct drm_plane *plane, · 146 unmodified lines
224206
225207 if (!plane_enabled(state)) {
226208 to_mdp5_plane_state(state)->pending = true;
227− mdp5_plane_disable(plane);
228209 } else if (to_mdp5_plane_state(state)->mode_changed) {
229210 int ret;
230211 to_mdp5_plane_state(state)->pending = true;
@@ -602,6 +583,20 @@ uint32_t mdp5_plane_get_flush(struct drm_plane *plane) · 371 unmodified lines
602583 return mdp5_plane->flush_mask;
603584 }
604585
586+/* called after vsync in thread context */
587+void mdp5_plane_complete_commit(struct drm_plane *plane,
588+ struct drm_plane_state *state)
589+{
590+ struct mdp5_kms *mdp5_kms = get_kms(plane);
591+ struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
592+ enum mdp5_pipe pipe = mdp5_plane->pipe;
593+
594+ if (!plane_enabled(plane->state)) {
595+ DBG("%s: free SMP", mdp5_plane->name);
596+ mdp5_smp_release(mdp5_kms->smp, pipe);
597+ }
598+}
599+
605600 /* initialize plane */
606601 struct drm_plane *mdp5_plane_init(struct drm_device *dev,
607602 enum mdp5_pipe pipe, bool private_plane, uint32_t reg_offset)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_smp.c+74−13
@@ -34,22 +34,44 @@ · 33 unmodified lines
3434 * and CANNOT be re-allocated (eg: MMB0 and MMB1 both tied to RGB0).
3535 *
3636 * For each block that can be dynamically allocated, it can be either
37− * free, or pending/in-use by a client. The updates happen in three steps:
37+ * free:
38+ * The block is free.
39+ *
40+ * pending:
41+ * The block is allocated to some client and not free.
42+ *
43+ * configured:
44+ * The block is allocated to some client, and assigned to that
45+ * client in MDP5_MDP_SMP_ALLOC registers.
46+ *
47+ * inuse:
48+ * The block is being actively used by a client.
49+ *
50+ * The updates happen in the following steps:
3851 *
3952 * 1) mdp5_smp_request():
4053 * When plane scanout is setup, calculate required number of
41− * blocks needed per client, and request. Blocks not inuse or
42− * pending by any other client are added to client's pending
43− * set.
54+ * blocks needed per client, and request. Blocks neither inuse nor
55+ * configured nor pending by any other client are added to client's
56+ * pending set.
57+ * For shrinking, blocks in pending but not in configured can be freed
58+ * directly, but those already in configured will be freed later by
59+ * mdp5_smp_commit.
4460 *
4561 * 2) mdp5_smp_configure():
4662 * As hw is programmed, before FLUSH, MDP5_MDP_SMP_ALLOC registers
4763 * are configured for the union(pending, inuse)
64+ * Current pending is copied to configured.
65+ * It is assumed that mdp5_smp_request and mdp5_smp_configure not run
66+ * concurrently for the same pipe.
4867 *
4968 * 3) mdp5_smp_commit():
50− * After next vblank, copy pending -> inuse. Optionally update
69+ * After next vblank, copy configured -> inuse. Optionally update
5170 * MDP5_SMP_ALLOC registers if there are newly unused blocks
5271 *
72+ * 4) mdp5_smp_release():
73+ * Must be called after the pipe is disabled and no longer uses any SMB
74+ *
5375 * On the next vblank after changes have been committed to hw, the
5476 * client's pending blocks become it's in-use blocks (and no-longer
5577 * in-use blocks become available to other clients).
@@ -77,6 +99,9 @@ struct mdp5_smp { · 21 unmodified lines
7799 struct mdp5_client_smp_state client_state[MAX_CLIENTS];
78100 };
79101
102+static void update_smp_state(struct mdp5_smp *smp,
103+ u32 cid, mdp5_smp_state_t *assigned);
104+
80105 static inline
81106 struct mdp5_kms *get_kms(struct mdp5_smp *smp)
82107 {
@@ -149,7 +174,12 @@ static int smp_request_block(struct mdp5_smp *smp, · 66 unmodified lines
149174 for (i = cur_nblks; i > nblks; i--) {
150175 int blk = find_first_bit(ps->pending, cnt);
151176 clear_bit(blk, ps->pending);
152− /* don't clear in global smp_state until _commit() */
177+
178+ /* clear in global smp_state if not in configured
179+ * otherwise until _commit()
180+ */
181+ if (!test_bit(blk, ps->configured))
182+ clear_bit(blk, smp->state);
153183 }
154184 }
155185
@@ -223,10 +253,33 @@ int mdp5_smp_request(struct mdp5_smp *smp, enum mdp5_pipe pipe, u32 fmt, u32 wid · 67 unmodified lines
223253 /* Release SMP blocks for all clients of the pipe */
224254 void mdp5_smp_release(struct mdp5_smp *smp, enum mdp5_pipe pipe)
225255 {
226− int i, nblks;
256+ int i;
257+ unsigned long flags;
258+ int cnt = smp->blk_cnt;
259+
260+ for (i = 0; i < pipe2nclients(pipe); i++) {
261+ mdp5_smp_state_t assigned;
262+ u32 cid = pipe2client(pipe, i);
263+ struct mdp5_client_smp_state *ps = &smp->client_state[cid];
264+
265+ spin_lock_irqsave(&smp->state_lock, flags);
266+
267+ /* clear hw assignment */
268+ bitmap_or(assigned, ps->inuse, ps->configured, cnt);
269+ update_smp_state(smp, CID_UNUSED, &assigned);
270+
271+ /* free to global pool */
272+ bitmap_andnot(smp->state, smp->state, ps->pending, cnt);
273+ bitmap_andnot(smp->state, smp->state, assigned, cnt);
274+
275+ /* clear client's infor */
276+ bitmap_zero(ps->pending, cnt);
277+ bitmap_zero(ps->configured, cnt);
278+ bitmap_zero(ps->inuse, cnt);
279+
280+ spin_unlock_irqrestore(&smp->state_lock, flags);
281+ }
227282
228− for (i = 0, nblks = 0; i < pipe2nclients(pipe); i++)
229− smp_request_block(smp, pipe2client(pipe, i), 0);
230283 set_fifo_thresholds(smp, pipe, 0);
231284 }
232285
@@ -274,12 +327,20 @@ void mdp5_smp_configure(struct mdp5_smp *smp, enum mdp5_pipe pipe) · 41 unmodified lines
274327 u32 cid = pipe2client(pipe, i);
275328 struct mdp5_client_smp_state *ps = &smp->client_state[cid];
276329
277− bitmap_or(assigned, ps->inuse, ps->pending, cnt);
330+ /*
331+ * if vblank has not happened since last smp_configure
332+ * skip the configure for now
333+ */
334+ if (!bitmap_equal(ps->inuse, ps->configured, cnt))
335+ continue;
336+
337+ bitmap_copy(ps->configured, ps->pending, cnt);
338+ bitmap_or(assigned, ps->inuse, ps->configured, cnt);
278339 update_smp_state(smp, cid, &assigned);
279340 }
280341 }
281342
282−/* step #3: after vblank, copy pending -> inuse: */
343+/* step #3: after vblank, copy configured -> inuse: */
283344 void mdp5_smp_commit(struct mdp5_smp *smp, enum mdp5_pipe pipe)
284345 {
285346 int cnt = smp->blk_cnt;
@@ -295,7 +356,7 @@ void mdp5_smp_commit(struct mdp5_smp *smp, enum mdp5_pipe pipe) · 9 unmodified lines
295356 * using, which can be released and made available to other
296357 * clients:
297358 */
298− if (bitmap_andnot(released, ps->inuse, ps->pending, cnt)) {
359+ if (bitmap_andnot(released, ps->inuse, ps->configured, cnt)) {
299360 unsigned long flags;
300361
301362 spin_lock_irqsave(&smp->state_lock, flags);
@@ -306,7 +367,7 @@ void mdp5_smp_commit(struct mdp5_smp *smp, enum mdp5_pipe pipe) · 4 unmodified lines
306367 update_smp_state(smp, CID_UNUSED, &released);
307368 }
308369
309− bitmap_copy(ps->inuse, ps->pending, cnt);
370+ bitmap_copy(ps->inuse, ps->configured, cnt);
310371 }
311372 }
312373
drivers/gpu/drm/msm/mdp/mdp5/mdp5_smp.h+1−0
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323
2424 struct mdp5_client_smp_state {
2525 mdp5_smp_state_t inuse;
26+ mdp5_smp_state_t configured;
2627 mdp5_smp_state_t pending;
2728 };
2829
drivers/gpu/drm/msm/msm_atomic.c+2−6
@@ -283,12 +283,8 @@ int msm_atomic_commit(struct drm_device *dev, · 282 unmodified lines
283283
284284 timeout = ktime_add_ms(ktime_get(), 1000);
285285
286− ret = msm_wait_fence_interruptable(dev, c->fence, &timeout);
287− if (ret) {
288− WARN_ON(ret); // TODO unswap state back? or??
289− commit_destroy(c);
290− return ret;
291− }
286+ /* uninterruptible wait */
287+ msm_wait_fence(dev, c->fence, &timeout, false);
292288
293289 complete_commit(c);
294290
drivers/gpu/drm/msm/msm_drv.c+9−4
@@ -637,8 +637,8 @@ static void msm_debugfs_cleanup(struct drm_minor *minor) · 636 unmodified lines
637637 * Fences:
638638 */
639639
640−int msm_wait_fence_interruptable(struct drm_device *dev, uint32_t fence,
641− ktime_t *timeout)
640+int msm_wait_fence(struct drm_device *dev, uint32_t fence,
641+ ktime_t *timeout , bool interruptible)
642642 {
643643 struct msm_drm_private *priv = dev->dev_private;
644644 int ret;
@@ -667,7 +667,12 @@ int msm_wait_fence_interruptable(struct drm_device *dev, uint32_t fence, · 22 unmodified lines
667667 remaining_jiffies = timespec_to_jiffies(&ts);
668668 }
669669
670− ret = wait_event_interruptible_timeout(priv->fence_event,
670+ if (interruptible)
671+ ret = wait_event_interruptible_timeout(priv->fence_event,
672+ fence_completed(dev, fence),
673+ remaining_jiffies);
674+ else
675+ ret = wait_event_timeout(priv->fence_event,
671676 fence_completed(dev, fence),
672677 remaining_jiffies);
673678
@@ -853,7 +858,7 @@ static int msm_ioctl_wait_fence(struct drm_device *dev, void *data, · 179 unmodified lines
853858 return -EINVAL;
854859 }
855860
856− return msm_wait_fence_interruptable(dev, args->fence, &timeout);
861+ return msm_wait_fence(dev, args->fence, &timeout, true);
857862 }
858863
859864 static const struct drm_ioctl_desc msm_ioctls[] = {
drivers/gpu/drm/msm/msm_drv.h+2−2
@@ -164,8 +164,8 @@ int msm_atomic_commit(struct drm_device *dev, · 163 unmodified lines
164164
165165 int msm_register_mmu(struct drm_device *dev, struct msm_mmu *mmu);
166166
167−int msm_wait_fence_interruptable(struct drm_device *dev, uint32_t fence,
168− ktime_t *timeout);
167+int msm_wait_fence(struct drm_device *dev, uint32_t fence,
168+ ktime_t *timeout, bool interruptible);
169169 int msm_queue_fence_cb(struct drm_device *dev,
170170 struct msm_fence_cb *cb, uint32_t fence);
171171 void msm_update_fence(struct drm_device *dev, uint32_t fence);
drivers/gpu/drm/msm/msm_gem.c+1−1
@@ -460,7 +460,7 @@ int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout) · 459 unmodified lines
460460 if (op & MSM_PREP_NOSYNC)
461461 timeout = NULL;
462462
463− ret = msm_wait_fence_interruptable(dev, fence, timeout);
463+ ret = msm_wait_fence(dev, fence, timeout, true);
464464 }
465465
466466 /* TODO cache maintenance */
drivers/gpu/drm/msm/msm_gem_prime.c+6−2
@@ -23,8 +23,12 @@ · 22 unmodified lines
2323 struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj)
2424 {
2525 struct msm_gem_object *msm_obj = to_msm_bo(obj);
26− BUG_ON(!msm_obj->sgt); /* should have already pinned! */
27− return msm_obj->sgt;
26+ int npages = obj->size >> PAGE_SHIFT;
27+
28+ if (WARN_ON(!msm_obj->pages)) /* should have already pinned! */
29+ return NULL;
30+
31+ return drm_prime_pages_to_sg(msm_obj->pages, npages);
2832 }
2933
3034 void *msm_gem_prime_vmap(struct drm_gem_object *obj)
drivers/gpu/drm/nouveau/nouveau_drm.c+3−0
@@ -128,6 +128,7 @@ nouveau_cli_destroy(struct nouveau_cli *cli) · 127 unmodified lines
128128 nvkm_vm_ref(NULL, &nvxx_client(&cli->base)->vm, NULL);
129129 nvif_client_fini(&cli->base);
130130 usif_client_fini(cli);
131+ kfree(cli);
131132 }
132133
133134 static void
@@ -865,8 +866,10 @@ nouveau_drm_preclose(struct drm_device *dev, struct drm_file *fpriv) · 731 unmodified lines
865866
866867 pm_runtime_get_sync(dev->dev);
867868
869+ mutex_lock(&cli->mutex);
868870 if (cli->abi16)
869871 nouveau_abi16_fini(cli->abi16);
872+ mutex_unlock(&cli->mutex);
870873
871874 mutex_lock(&drm->client.mutex);
872875 list_del(&cli->head);
drivers/gpu/drm/nouveau/nouveau_platform.c+16−0
@@ -92,6 +92,8 @@ static int nouveau_platform_power_down(struct nouveau_platform_gpu *gpu) · 91 unmodified lines
9292 return 0;
9393 }
9494
95+#if IS_ENABLED(CONFIG_IOMMU_API)
96+
9597 static void nouveau_platform_probe_iommu(struct device *dev,
9698 struct nouveau_platform_gpu *gpu)
9799 {
@@ -158,6 +160,20 @@ static void nouveau_platform_remove_iommu(struct device *dev, · 60 unmodified lines
158160 }
159161 }
160162
163+#else
164+
165+static void nouveau_platform_probe_iommu(struct device *dev,
166+ struct nouveau_platform_gpu *gpu)
167+{
168+}
169+
170+static void nouveau_platform_remove_iommu(struct device *dev,
171+ struct nouveau_platform_gpu *gpu)
172+{
173+}
174+
175+#endif
176+
161177 static int nouveau_platform_probe(struct platform_device *pdev)
162178 {
163179 struct nouveau_platform_gpu *gpu;
drivers/gpu/drm/nouveau/nouveau_ttm.c+9−0
@@ -175,15 +175,24 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man, · 174 unmodified lines
175175 node->page_shift = 12;
176176
177177 switch (drm->device.info.family) {
178+ case NV_DEVICE_INFO_V0_TNT:
179+ case NV_DEVICE_INFO_V0_CELSIUS:
180+ case NV_DEVICE_INFO_V0_KELVIN:
181+ case NV_DEVICE_INFO_V0_RANKINE:
182+ case NV_DEVICE_INFO_V0_CURIE:
183+ break;
178184 case NV_DEVICE_INFO_V0_TESLA:
179185 if (drm->device.info.chipset != 0x50)
180186 node->memtype = (nvbo->tile_flags & 0x7f00) >> 8;
181187 break;
182188 case NV_DEVICE_INFO_V0_FERMI:
183189 case NV_DEVICE_INFO_V0_KEPLER:
190+ case NV_DEVICE_INFO_V0_MAXWELL:
184191 node->memtype = (nvbo->tile_flags & 0xff00) >> 8;
185192 break;
186193 default:
194+ NV_WARN(drm, "%s: unhandled family type %x\n", __func__,
195+ drm->device.info.family);
187196 break;
188197 }
189198
drivers/gpu/drm/nouveau/nv04_fbcon.c+1−1
@@ -203,7 +203,7 @@ nv04_fbcon_accel_init(struct fb_info *info) · 202 unmodified lines
203203 if (ret)
204204 return ret;
205205
206− if (RING_SPACE(chan, 49)) {
206+ if (RING_SPACE(chan, 49 + (device->info.chipset >= 0x11 ? 4 : 0))) {
207207 nouveau_fbcon_gpu_lockup(info);
208208 return 0;
209209 }
drivers/gpu/drm/nouveau/nv50_display.c+1−1
@@ -979,7 +979,7 @@ nv50_crtc_cursor_show_hide(struct nouveau_crtc *nv_crtc, bool show, bool update) · 978 unmodified lines
979979 {
980980 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev);
981981
982− if (show && nv_crtc->cursor.nvbo)
982+ if (show && nv_crtc->cursor.nvbo && nv_crtc->base.enabled)
983983 nv50_crtc_cursor_show(nv_crtc);
984984 else
985985 nv50_crtc_cursor_hide(nv_crtc);
drivers/gpu/drm/nouveau/nv50_fbcon.c+2−1
@@ -188,7 +188,7 @@ nv50_fbcon_accel_init(struct fb_info *info) · 187 unmodified lines
188188 if (ret)
189189 return ret;
190190
191− ret = RING_SPACE(chan, 59);
191+ ret = RING_SPACE(chan, 58);
192192 if (ret) {
193193 nouveau_fbcon_gpu_lockup(info);
194194 return ret;
@@ -252,6 +252,7 @@ nv50_fbcon_accel_init(struct fb_info *info) · 57 unmodified lines
252252 OUT_RING(chan, info->var.yres_virtual);
253253 OUT_RING(chan, upper_32_bits(fb->vma.offset));
254254 OUT_RING(chan, lower_32_bits(fb->vma.offset));
255+ FIRE_RING(chan);
255256
256257 return 0;
257258 }
drivers/gpu/drm/nouveau/nvc0_fbcon.c+1−1
@@ -188,7 +188,7 @@ nvc0_fbcon_accel_init(struct fb_info *info) · 187 unmodified lines
188188 return -EINVAL;
189189 }
190190
191− ret = RING_SPACE(chan, 60);
191+ ret = RING_SPACE(chan, 58);
192192 if (ret) {
193193 WARN_ON(1);
194194 nouveau_fbcon_gpu_lockup(info);
drivers/gpu/drm/nouveau/nvkm/engine/disp/gf110.c+1−1
@@ -809,7 +809,7 @@ exec_lookup(struct nv50_disp_priv *priv, int head, int or, u32 ctrl, · 808 unmodified lines
809809 case 0x00000900: type = DCB_OUTPUT_DP; mask = 2; break;
810810 default:
811811 nv_error(priv, "unknown SOR mc 0x%08x\n", ctrl);
812− return 0x0000;
812+ return NULL;
813813 }
814814 }
815815
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c+38−1
@@ -663,6 +663,37 @@ gf100_gr_zbc_init(struct gf100_gr_priv *priv) · 662 unmodified lines
663663 gf100_gr_zbc_clear_depth(priv, index);
664664 }
665665
666+/**
667+ * Wait until GR goes idle. GR is considered idle if it is disabled by the
668+ * MC (0x200) register, or GR is not busy and a context switch is not in
669+ * progress.
670+ */
671+int
672+gf100_gr_wait_idle(struct gf100_gr_priv *priv)
673+{
674+ unsigned long end_jiffies = jiffies + msecs_to_jiffies(2000);
675+ bool gr_enabled, ctxsw_active, gr_busy;
676+
677+ do {
678+ /*
679+ * required to make sure FIFO_ENGINE_STATUS (0x2640) is
680+ * up-to-date
681+ */
682+ nv_rd32(priv, 0x400700);
683+
684+ gr_enabled = nv_rd32(priv, 0x200) & 0x1000;
685+ ctxsw_active = nv_rd32(priv, 0x2640) & 0x8000;
686+ gr_busy = nv_rd32(priv, 0x40060c) & 0x1;
687+
688+ if (!gr_enabled || (!gr_busy && !ctxsw_active))
689+ return 0;
690+ } while (time_before(jiffies, end_jiffies));
691+
692+ nv_error(priv, "wait for idle timeout (en: %d, ctxsw: %d, busy: %d)\n",
693+ gr_enabled, ctxsw_active, gr_busy);
694+ return -EAGAIN;
695+}
696+
666697 void
667698 gf100_gr_mmio(struct gf100_gr_priv *priv, const struct gf100_gr_pack *p)
668699 {
@@ -699,7 +730,13 @@ gf100_gr_icmd(struct gf100_gr_priv *priv, const struct gf100_gr_pack *p) · 30 unmodified lines
699730
700731 while (addr < next) {
701732 nv_wr32(priv, 0x400200, addr);
702− nv_wait(priv, 0x400700, 0x00000002, 0x00000000);
733+ /**
734+ * Wait for GR to go idle after submitting a
735+ * GO_IDLE bundle
736+ */
737+ if ((addr & 0xffff) == 0xe100)
738+ gf100_gr_wait_idle(priv);
739+ nv_wait(priv, 0x400700, 0x00000004, 0x00000000);
703740 addr += init->pitch;
704741 }
705742 }
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h+1−0
@@ -181,6 +181,7 @@ struct gf100_gr_oclass { · 180 unmodified lines
181181 int ppc_nr;
182182 };
183183
184+int gf100_gr_wait_idle(struct gf100_gr_priv *);
184185 void gf100_gr_mmio(struct gf100_gr_priv *, const struct gf100_gr_pack *);
185186 void gf100_gr_icmd(struct gf100_gr_priv *, const struct gf100_gr_pack *);
186187 void gf100_gr_mthd(struct gf100_gr_priv *, const struct gf100_gr_pack *);
drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c+8−6
@@ -332,9 +332,12 @@ static void · 331 unmodified lines
332332 nvkm_perfctx_dtor(struct nvkm_object *object)
333333 {
334334 struct nvkm_pm *ppm = (void *)object->engine;
335+ struct nvkm_perfctx *ctx = (void *)object;
336+
335337 mutex_lock(&nv_subdev(ppm)->mutex);
336− nvkm_engctx_destroy(&ppm->context->base);
337− ppm->context = NULL;
338+ nvkm_engctx_destroy(&ctx->base);
339+ if (ppm->context == ctx)
340+ ppm->context = NULL;
338341 mutex_unlock(&nv_subdev(ppm)->mutex);
339342 }
340343
@@ -355,12 +358,11 @@ nvkm_perfctx_ctor(struct nvkm_object *parent, struct nvkm_object *engine, · 14 unmodified lines
355358 mutex_lock(&nv_subdev(ppm)->mutex);
356359 if (ppm->context == NULL)
357360 ppm->context = ctx;
358− mutex_unlock(&nv_subdev(ppm)->mutex);
359−
360361 if (ctx != ppm->context)
361− return -EBUSY;
362+ ret = -EBUSY;
363+ mutex_unlock(&nv_subdev(ppm)->mutex);
362364
363− return 0;
365+ return ret;
364366 }
365367
366368 struct nvkm_oclass
drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c+40−0
@@ -1284,6 +1284,44 @@ init_zm_reg_sequence(struct nvbios_init *init) · 1283 unmodified lines
12841284 }
12851285 }
12861286
1287+/**
1288+ * INIT_PLL_INDIRECT - opcode 0x59
1289+ *
1290+ */
1291+static void
1292+init_pll_indirect(struct nvbios_init *init)
1293+{
1294+ struct nvkm_bios *bios = init->bios;
1295+ u32 reg = nv_ro32(bios, init->offset + 1);
1296+ u16 addr = nv_ro16(bios, init->offset + 5);
1297+ u32 freq = (u32)nv_ro16(bios, addr) * 1000;
1298+
1299+ trace("PLL_INDIRECT\tR[0x%06x] =PLL= VBIOS[%04x] = %dkHz\n",
1300+ reg, addr, freq);
1301+ init->offset += 7;
1302+
1303+ init_prog_pll(init, reg, freq);
1304+}
1305+
1306+/**
1307+ * INIT_ZM_REG_INDIRECT - opcode 0x5a
1308+ *
1309+ */
1310+static void
1311+init_zm_reg_indirect(struct nvbios_init *init)
1312+{
1313+ struct nvkm_bios *bios = init->bios;
1314+ u32 reg = nv_ro32(bios, init->offset + 1);
1315+ u16 addr = nv_ro16(bios, init->offset + 5);
1316+ u32 data = nv_ro32(bios, addr);
1317+
1318+ trace("ZM_REG_INDIRECT\tR[0x%06x] = VBIOS[0x%04x] = 0x%08x\n",
1319+ reg, addr, data);
1320+ init->offset += 7;
1321+
1322+ init_wr32(init, addr, data);
1323+}
1324+
12871325 /**
12881326 * INIT_SUB_DIRECT - opcode 0x5b
12891327 *
@@ -2145,6 +2183,8 @@ static struct nvbios_init_opcode { · 855 unmodified lines
21452183 [0x56] = { init_condition_time },
21462184 [0x57] = { init_ltime },
21472185 [0x58] = { init_zm_reg_sequence },
2186+ [0x59] = { init_pll_indirect },
2187+ [0x5a] = { init_zm_reg_indirect },
21482188 [0x5b] = { init_sub_direct },
21492189 [0x5c] = { init_jump },
21502190 [0x5e] = { init_i2c_if },
drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c+2−1
@@ -180,7 +180,8 @@ gt215_clk_info(struct nvkm_clk *clock, int clk, u32 khz, · 179 unmodified lines
180180 struct gt215_clk_info *info)
181181 {
182182 struct gt215_clk_priv *priv = (void *)clock;
183− u32 oclk, sclk, sdiv, diff;
183+ u32 oclk, sclk, sdiv;
184+ s32 diff;
184185
185186 info->clk = 0;
186187
drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk20a.c+8−0
@@ -38,6 +38,14 @@ gk20a_ibus_init_priv_ring(struct gk20a_ibus_priv *priv) · 37 unmodified lines
3838 nv_wr32(priv, 0x12004c, 0x4);
3939 nv_wr32(priv, 0x122204, 0x2);
4040 nv_rd32(priv, 0x122204);
41+
42+ /*
43+ * Bug: increase clock timeout to avoid operation failure at high
44+ * gpcclk rate.
45+ */
46+ nv_wr32(priv, 0x122354, 0x800);
47+ nv_wr32(priv, 0x128328, 0x800);
48+ nv_wr32(priv, 0x124320, 0x800);
4149 }
4250
4351 static void
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv04.c+8−0
@@ -50,7 +50,12 @@ nv04_instobj_dtor(struct nvkm_object *object) · 49 unmodified lines
5050 {
5151 struct nv04_instmem_priv *priv = (void *)nvkm_instmem(object);
5252 struct nv04_instobj_priv *node = (void *)object;
53+ struct nvkm_subdev *subdev = (void *)priv;
54+
55+ mutex_lock(&subdev->mutex);
5356 nvkm_mm_free(&priv->heap, &node->mem);
57+ mutex_unlock(&subdev->mutex);
58+
5459 nvkm_instobj_destroy(&node->base);
5560 }
5661
@@ -62,6 +67,7 @@ nv04_instobj_ctor(struct nvkm_object *parent, struct nvkm_object *engine, · 5 unmodified lines
6267 struct nv04_instmem_priv *priv = (void *)nvkm_instmem(parent);
6368 struct nv04_instobj_priv *node;
6469 struct nvkm_instobj_args *args = data;
70+ struct nvkm_subdev *subdev = (void *)priv;
6571 int ret;
6672
6773 if (!args->align)
@@ -72,8 +78,10 @@ nv04_instobj_ctor(struct nvkm_object *parent, struct nvkm_object *engine, · 4 unmodified lines
7278 if (ret)
7379 return ret;
7480
81+ mutex_lock(&subdev->mutex);
7582 ret = nvkm_mm_head(&priv->heap, 0, 1, args->size, args->size,
7683 args->align, &node->mem);
84+ mutex_unlock(&subdev->mutex);
7785 if (ret)
7886 return ret;
7987
drivers/gpu/drm/radeon/atombios_encoders.c+1−2
@@ -2299,8 +2299,7 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder, · 2298 unmodified lines
22992299 encoder_mode = atombios_get_encoder_mode(encoder);
23002300 if (connector && (radeon_audio != 0) &&
23012301 ((encoder_mode == ATOM_ENCODER_MODE_HDMI) ||
2302− (ENCODER_MODE_IS_DP(encoder_mode) &&
2303− drm_detect_monitor_audio(radeon_connector_edid(connector)))))
2302+ ENCODER_MODE_IS_DP(encoder_mode)))
23042303 radeon_audio_mode_set(encoder, adjusted_mode);
23052304 }
23062305
drivers/gpu/drm/radeon/dce6_afmt.c+28−34
@@ -93,30 +93,26 @@ void dce6_afmt_select_pin(struct drm_encoder *encoder) · 92 unmodified lines
9393 struct radeon_device *rdev = encoder->dev->dev_private;
9494 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
9595 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
96− u32 offset;
9796
98− if (!dig || !dig->afmt || !dig->afmt->pin)
97+ if (!dig || !dig->afmt || !dig->pin)
9998 return;
10099
101− offset = dig->afmt->offset;
102−
103− WREG32(AFMT_AUDIO_SRC_CONTROL + offset,
104− AFMT_AUDIO_SRC_SELECT(dig->afmt->pin->id));
100+ WREG32(AFMT_AUDIO_SRC_CONTROL + dig->afmt->offset,
101+ AFMT_AUDIO_SRC_SELECT(dig->pin->id));
105102 }
106103
107104 void dce6_afmt_write_latency_fields(struct drm_encoder *encoder,
108− struct drm_connector *connector, struct drm_display_mode *mode)
105+ struct drm_connector *connector,
106+ struct drm_display_mode *mode)
109107 {
110108 struct radeon_device *rdev = encoder->dev->dev_private;
111109 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
112110 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
113− u32 tmp = 0, offset;
111+ u32 tmp = 0;
114112
115− if (!dig || !dig->afmt || !dig->afmt->pin)
113+ if (!dig || !dig->afmt || !dig->pin)
116114 return;
117115
118− offset = dig->afmt->pin->offset;
119−
120116 if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
121117 if (connector->latency_present[1])
122118 tmp = VIDEO_LIPSYNC(connector->video_latency[1]) |
@@ -130,24 +126,24 @@ void dce6_afmt_write_latency_fields(struct drm_encoder *encoder, · 7 unmodified lines
130126 else
131127 tmp = VIDEO_LIPSYNC(0) | AUDIO_LIPSYNC(0);
132128 }
133− WREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC, tmp);
129+ WREG32_ENDPOINT(dig->pin->offset,
130+ AZ_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC, tmp);
134131 }
135132
136133 void dce6_afmt_hdmi_write_speaker_allocation(struct drm_encoder *encoder,
137− u8 *sadb, int sad_count)
134+ u8 *sadb, int sad_count)
138135 {
139136 struct radeon_device *rdev = encoder->dev->dev_private;
140137 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
141138 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
142− u32 offset, tmp;
139+ u32 tmp;
143140
144− if (!dig || !dig->afmt || !dig->afmt->pin)
141+ if (!dig || !dig->afmt || !dig->pin)
145142 return;
146143
147− offset = dig->afmt->pin->offset;
148−
149144 /* program the speaker allocation */
150− tmp = RREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER);
145+ tmp = RREG32_ENDPOINT(dig->pin->offset,
146+ AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER);
151147 tmp &= ~(DP_CONNECTION | SPEAKER_ALLOCATION_MASK);
152148 /* set HDMI mode */
153149 tmp |= HDMI_CONNECTION;
@@ -155,24 +151,24 @@ void dce6_afmt_hdmi_write_speaker_allocation(struct drm_encoder *encoder, · 1 unmodified line
155151 tmp |= SPEAKER_ALLOCATION(sadb[0]);
156152 else
157153 tmp |= SPEAKER_ALLOCATION(5); /* stereo */
158− WREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER, tmp);
154+ WREG32_ENDPOINT(dig->pin->offset,
155+ AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER, tmp);
159156 }
160157
161158 void dce6_afmt_dp_write_speaker_allocation(struct drm_encoder *encoder,
162− u8 *sadb, int sad_count)
159+ u8 *sadb, int sad_count)
163160 {
164161 struct radeon_device *rdev = encoder->dev->dev_private;
165162 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
166163 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
167− u32 offset, tmp;
164+ u32 tmp;
168165
169− if (!dig || !dig->afmt || !dig->afmt->pin)
166+ if (!dig || !dig->afmt || !dig->pin)
170167 return;
171168
172− offset = dig->afmt->pin->offset;
173−
174169 /* program the speaker allocation */
175− tmp = RREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER);
170+ tmp = RREG32_ENDPOINT(dig->pin->offset,
171+ AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER);
176172 tmp &= ~(HDMI_CONNECTION | SPEAKER_ALLOCATION_MASK);
177173 /* set DP mode */
178174 tmp |= DP_CONNECTION;
@@ -180,13 +176,13 @@ void dce6_afmt_dp_write_speaker_allocation(struct drm_encoder *encoder, · 1 unmodified line
180176 tmp |= SPEAKER_ALLOCATION(sadb[0]);
181177 else
182178 tmp |= SPEAKER_ALLOCATION(5); /* stereo */
183− WREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER, tmp);
179+ WREG32_ENDPOINT(dig->pin->offset,
180+ AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER, tmp);
184181 }
185182
186183 void dce6_afmt_write_sad_regs(struct drm_encoder *encoder,
187− struct cea_sad *sads, int sad_count)
184+ struct cea_sad *sads, int sad_count)
188185 {
189− u32 offset;
190186 int i;
191187 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
192188 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
@@ -206,11 +202,9 @@ void dce6_afmt_write_sad_regs(struct drm_encoder *encoder, · 13 unmodified lines
206202 { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO },
207203 };
208204
209− if (!dig || !dig->afmt || !dig->afmt->pin)
205+ if (!dig || !dig->afmt || !dig->pin)
210206 return;
211207
212− offset = dig->afmt->pin->offset;
213−
214208 for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) {
215209 u32 value = 0;
216210 u8 stereo_freqs = 0;
@@ -237,7 +231,7 @@ void dce6_afmt_write_sad_regs(struct drm_encoder *encoder, · 20 unmodified lines
237231
238232 value |= SUPPORTED_FREQUENCIES_STEREO(stereo_freqs);
239233
240− WREG32_ENDPOINT(offset, eld_reg_to_type[i][0], value);
234+ WREG32_ENDPOINT(dig->pin->offset, eld_reg_to_type[i][0], value);
241235 }
242236 }
243237
@@ -253,7 +247,7 @@ void dce6_audio_enable(struct radeon_device *rdev, · 9 unmodified lines
253247 }
254248
255249 void dce6_hdmi_audio_set_dto(struct radeon_device *rdev,
256− struct radeon_crtc *crtc, unsigned int clock)
250+ struct radeon_crtc *crtc, unsigned int clock)
257251 {
258252 /* Two dtos; generally use dto0 for HDMI */
259253 u32 value = 0;
@@ -272,7 +266,7 @@ void dce6_hdmi_audio_set_dto(struct radeon_device *rdev, · 12 unmodified lines
272266 }
273267
274268 void dce6_dp_audio_set_dto(struct radeon_device *rdev,
275− struct radeon_crtc *crtc, unsigned int clock)
269+ struct radeon_crtc *crtc, unsigned int clock)
276270 {
277271 /* Two dtos; generally use dto1 for DP */
278272 u32 value = 0;
drivers/gpu/drm/radeon/radeon_audio.c+97−107
@@ -245,6 +245,28 @@ static struct radeon_audio_funcs dce6_dp_funcs = { · 244 unmodified lines
245245 static void radeon_audio_enable(struct radeon_device *rdev,
246246 struct r600_audio_pin *pin, u8 enable_mask)
247247 {
248+ struct drm_encoder *encoder;
249+ struct radeon_encoder *radeon_encoder;
250+ struct radeon_encoder_atom_dig *dig;
251+ int pin_count = 0;
252+
253+ if (!pin)
254+ return;
255+
256+ if (rdev->mode_info.mode_config_initialized) {
257+ list_for_each_entry(encoder, &rdev->ddev->mode_config.encoder_list, head) {
258+ if (radeon_encoder_is_digital(encoder)) {
259+ radeon_encoder = to_radeon_encoder(encoder);
260+ dig = radeon_encoder->enc_priv;
261+ if (dig->pin == pin)
262+ pin_count++;
263+ }
264+ }
265+
266+ if ((pin_count > 1) && (enable_mask == 0))
267+ return;
268+ }
269+
248270 if (rdev->audio.funcs->enable)
249271 rdev->audio.funcs->enable(rdev, pin, enable_mask);
250272 }
@@ -336,24 +358,13 @@ void radeon_audio_endpoint_wreg(struct radeon_device *rdev, u32 offset, · 85 unmodified lines
336358
337359 static void radeon_audio_write_sad_regs(struct drm_encoder *encoder)
338360 {
339− struct radeon_encoder *radeon_encoder;
340− struct drm_connector *connector;
341− struct radeon_connector *radeon_connector = NULL;
361+ struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
362+ struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
342363 struct cea_sad *sads;
343364 int sad_count;
344365
345− list_for_each_entry(connector,
346− &encoder->dev->mode_config.connector_list, head) {
347− if (connector->encoder == encoder) {
348− radeon_connector = to_radeon_connector(connector);
349− break;
350− }
351− }
352−
353− if (!radeon_connector) {
354− DRM_ERROR("Couldn't find encoder's connector\n");
366+ if (!connector)
355367 return;
356− }
357368
358369 sad_count = drm_edid_to_sad(radeon_connector_edid(connector), &sads);
359370 if (sad_count <= 0) {
@@ -362,8 +373,6 @@ static void radeon_audio_write_sad_regs(struct drm_encoder *encoder) · 2 unmodified lines
362373 }
363374 BUG_ON(!sads);
364375
365− radeon_encoder = to_radeon_encoder(encoder);
366−
367376 if (radeon_encoder->audio && radeon_encoder->audio->write_sad_regs)
368377 radeon_encoder->audio->write_sad_regs(encoder, sads, sad_count);
369378
@@ -372,27 +381,16 @@ static void radeon_audio_write_sad_regs(struct drm_encoder *encoder) · 2 unmodified lines
372381
373382 static void radeon_audio_write_speaker_allocation(struct drm_encoder *encoder)
374383 {
384+ struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
375385 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
376− struct drm_connector *connector;
377− struct radeon_connector *radeon_connector = NULL;
378386 u8 *sadb = NULL;
379387 int sad_count;
380388
381− list_for_each_entry(connector,
382− &encoder->dev->mode_config.connector_list, head) {
383− if (connector->encoder == encoder) {
384− radeon_connector = to_radeon_connector(connector);
385− break;
386− }
387− }
388−
389− if (!radeon_connector) {
390− DRM_ERROR("Couldn't find encoder's connector\n");
389+ if (!connector)
391390 return;
392− }
393391
394− sad_count = drm_edid_to_speaker_allocation(
395− radeon_connector_edid(connector), &sadb);
392+ sad_count = drm_edid_to_speaker_allocation(radeon_connector_edid(connector),
393+ &sadb);
396394 if (sad_count < 0) {
397395 DRM_DEBUG("Couldn't read Speaker Allocation Data Block: %d\n",
398396 sad_count);
@@ -406,26 +404,13 @@ static void radeon_audio_write_speaker_allocation(struct drm_encoder *encoder) · 7 unmodified lines
406404 }
407405
408406 static void radeon_audio_write_latency_fields(struct drm_encoder *encoder,
409− struct drm_display_mode *mode)
407+ struct drm_display_mode *mode)
410408 {
411− struct radeon_encoder *radeon_encoder;
412− struct drm_connector *connector;
413− struct radeon_connector *radeon_connector = 0;
414−
415− list_for_each_entry(connector,
416− &encoder->dev->mode_config.connector_list, head) {
417− if (connector->encoder == encoder) {
418− radeon_connector = to_radeon_connector(connector);
419− break;
420− }
421− }
409+ struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
410+ struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
422411
423− if (!radeon_connector) {
424− DRM_ERROR("Couldn't find encoder's connector\n");
412+ if (!connector)
425413 return;
426− }
427−
428− radeon_encoder = to_radeon_encoder(encoder);
429414
430415 if (radeon_encoder->audio && radeon_encoder->audio->write_latency_fields)
431416 radeon_encoder->audio->write_latency_fields(encoder, connector, mode);
@@ -451,29 +436,23 @@ static void radeon_audio_select_pin(struct drm_encoder *encoder) · 19 unmodified lines
451436 }
452437
453438 void radeon_audio_detect(struct drm_connector *connector,
439+ struct drm_encoder *encoder,
454440 enum drm_connector_status status)
455441 {
456− struct radeon_device *rdev;
457− struct radeon_encoder *radeon_encoder;
442+ struct drm_device *dev = connector->dev;
443+ struct radeon_device *rdev = dev->dev_private;
444+ struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
458445 struct radeon_encoder_atom_dig *dig;
459446
460− if (!connector || !connector->encoder)
447+ if (!radeon_audio_chipset_supported(rdev))
461448 return;
462449
463− rdev = connector->encoder->dev->dev_private;
464−
465− if (!radeon_audio_chipset_supported(rdev))
450+ if (!radeon_encoder_is_digital(encoder))
466451 return;
467452
468− radeon_encoder = to_radeon_encoder(connector->encoder);
469453 dig = radeon_encoder->enc_priv;
470454
471455 if (status == connector_status_connected) {
472− if (!drm_detect_monitor_audio(radeon_connector_edid(connector))) {
473− radeon_encoder->audio = NULL;
474− return;
475− }
476−
477456 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
478457 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
479458
@@ -486,11 +465,17 @@ void radeon_audio_detect(struct drm_connector *connector, · 6 unmodified lines
486465 radeon_encoder->audio = rdev->audio.hdmi_funcs;
487466 }
488467
489− dig->afmt->pin = radeon_audio_get_pin(connector->encoder);
490− radeon_audio_enable(rdev, dig->afmt->pin, 0xf);
468+ if (drm_detect_monitor_audio(radeon_connector_edid(connector))) {
469+ if (!dig->pin)
470+ dig->pin = radeon_audio_get_pin(encoder);
471+ radeon_audio_enable(rdev, dig->pin, 0xf);
472+ } else {
473+ radeon_audio_enable(rdev, dig->pin, 0);
474+ dig->pin = NULL;
475+ }
491476 } else {
492− radeon_audio_enable(rdev, dig->afmt->pin, 0);
493− dig->afmt->pin = NULL;
477+ radeon_audio_enable(rdev, dig->pin, 0);
478+ dig->pin = NULL;
494479 }
495480 }
496481
@@ -518,29 +503,18 @@ static void radeon_audio_set_dto(struct drm_encoder *encoder, unsigned int clock · 21 unmodified lines
518503 }
519504
520505 static int radeon_audio_set_avi_packet(struct drm_encoder *encoder,
521− struct drm_display_mode *mode)
506+ struct drm_display_mode *mode)
522507 {
523508 struct radeon_device *rdev = encoder->dev->dev_private;
524509 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
525510 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
526− struct drm_connector *connector;
527− struct radeon_connector *radeon_connector = NULL;
511+ struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
528512 u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AVI_INFOFRAME_SIZE];
529513 struct hdmi_avi_infoframe frame;
530514 int err;
531515
532− list_for_each_entry(connector,
533− &encoder->dev->mode_config.connector_list, head) {
534− if (connector->encoder == encoder) {
535− radeon_connector = to_radeon_connector(connector);
536− break;
537− }
538− }
539−
540− if (!radeon_connector) {
541− DRM_ERROR("Couldn't find encoder's connector\n");
542− return -ENOENT;
543− }
516+ if (!connector)
517+ return -EINVAL;
544518
545519 err = drm_hdmi_avi_infoframe_from_display_mode(&frame, mode);
546520 if (err < 0) {
@@ -563,8 +537,8 @@ static int radeon_audio_set_avi_packet(struct drm_encoder *encoder, · 16 unmodified lines
563537 return err;
564538 }
565539
566− if (dig && dig->afmt &&
567− radeon_encoder->audio && radeon_encoder->audio->set_avi_packet)
540+ if (dig && dig->afmt && radeon_encoder->audio &&
541+ radeon_encoder->audio->set_avi_packet)
568542 radeon_encoder->audio->set_avi_packet(rdev, dig->afmt->offset,
569543 buffer, sizeof(buffer));
570544
@@ -722,30 +696,41 @@ static void radeon_audio_hdmi_mode_set(struct drm_encoder *encoder, · 151 unmodified lines
722696 {
723697 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
724698 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
699+ struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
725700
726701 if (!dig || !dig->afmt)
727702 return;
728703
729− radeon_audio_set_mute(encoder, true);
704+ if (!connector)
705+ return;
730706
731− radeon_audio_write_speaker_allocation(encoder);
732− radeon_audio_write_sad_regs(encoder);
733− radeon_audio_write_latency_fields(encoder, mode);
734− radeon_audio_set_dto(encoder, mode->clock);
735− radeon_audio_set_vbi_packet(encoder);
736− radeon_hdmi_set_color_depth(encoder);
737− radeon_audio_update_acr(encoder, mode->clock);
738− radeon_audio_set_audio_packet(encoder);
739− radeon_audio_select_pin(encoder);
707+ if (drm_detect_monitor_audio(radeon_connector_edid(connector))) {
708+ radeon_audio_set_mute(encoder, true);
740709
741− if (radeon_audio_set_avi_packet(encoder, mode) < 0)
742− return;
710+ radeon_audio_write_speaker_allocation(encoder);
711+ radeon_audio_write_sad_regs(encoder);
712+ radeon_audio_write_latency_fields(encoder, mode);
713+ radeon_audio_set_dto(encoder, mode->clock);
714+ radeon_audio_set_vbi_packet(encoder);
715+ radeon_hdmi_set_color_depth(encoder);
716+ radeon_audio_update_acr(encoder, mode->clock);
717+ radeon_audio_set_audio_packet(encoder);
718+ radeon_audio_select_pin(encoder);
719+
720+ if (radeon_audio_set_avi_packet(encoder, mode) < 0)
721+ return;
743722
744− radeon_audio_set_mute(encoder, false);
723+ radeon_audio_set_mute(encoder, false);
724+ } else {
725+ radeon_hdmi_set_color_depth(encoder);
726+
727+ if (radeon_audio_set_avi_packet(encoder, mode) < 0)
728+ return;
729+ }
745730 }
746731
747732 static void radeon_audio_dp_mode_set(struct drm_encoder *encoder,
748− struct drm_display_mode *mode)
733+ struct drm_display_mode *mode)
749734 {
750735 struct drm_device *dev = encoder->dev;
751736 struct radeon_device *rdev = dev->dev_private;
@@ -759,22 +744,27 @@ static void radeon_audio_dp_mode_set(struct drm_encoder *encoder, · 7 unmodified lines
759744 if (!dig || !dig->afmt)
760745 return;
761746
762− radeon_audio_write_speaker_allocation(encoder);
763− radeon_audio_write_sad_regs(encoder);
764− radeon_audio_write_latency_fields(encoder, mode);
765− if (rdev->clock.dp_extclk || ASIC_IS_DCE5(rdev))
766− radeon_audio_set_dto(encoder, rdev->clock.default_dispclk * 10);
767− else
768− radeon_audio_set_dto(encoder, dig_connector->dp_clock);
769− radeon_audio_set_audio_packet(encoder);
770− radeon_audio_select_pin(encoder);
771−
772− if (radeon_audio_set_avi_packet(encoder, mode) < 0)
747+ if (!connector)
773748 return;
749+
750+ if (drm_detect_monitor_audio(radeon_connector_edid(connector))) {
751+ radeon_audio_write_speaker_allocation(encoder);
752+ radeon_audio_write_sad_regs(encoder);
753+ radeon_audio_write_latency_fields(encoder, mode);
754+ if (rdev->clock.dp_extclk || ASIC_IS_DCE5(rdev))
755+ radeon_audio_set_dto(encoder, rdev->clock.default_dispclk * 10);
756+ else
757+ radeon_audio_set_dto(encoder, dig_connector->dp_clock);
758+ radeon_audio_set_audio_packet(encoder);
759+ radeon_audio_select_pin(encoder);
760+
761+ if (radeon_audio_set_avi_packet(encoder, mode) < 0)
762+ return;
763+ }
774764 }
775765
776766 void radeon_audio_mode_set(struct drm_encoder *encoder,
777− struct drm_display_mode *mode)
767+ struct drm_display_mode *mode)
778768 {
779769 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
780770
drivers/gpu/drm/radeon/radeon_audio.h+2−1
@@ -68,7 +68,8 @@ struct radeon_audio_funcs · 67 unmodified lines
6868
6969 int radeon_audio_init(struct radeon_device *rdev);
7070 void radeon_audio_detect(struct drm_connector *connector,
71− enum drm_connector_status status);
71+ struct drm_encoder *encoder,
72+ enum drm_connector_status status);
7273 u32 radeon_audio_endpoint_rreg(struct radeon_device *rdev,
7374 u32 offset, u32 reg);
7475 void radeon_audio_endpoint_wreg(struct radeon_device *rdev,
drivers/gpu/drm/radeon/radeon_combios.c+6−1
@@ -1255,10 +1255,15 @@ struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder · 1254 unmodified lines
12551255
12561256 if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) &&
12571257 (RBIOS16(tmp + 2) == lvds->native_mode.vdisplay)) {
1258+ u32 hss = (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8;
1259+
1260+ if (hss > lvds->native_mode.hdisplay)
1261+ hss = (10 - 1) * 8;
1262+
12581263 lvds->native_mode.htotal = lvds->native_mode.hdisplay +
12591264 (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8;
12601265 lvds->native_mode.hsync_start = lvds->native_mode.hdisplay +
1261− (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8;
1266+ hss;
12621267 lvds->native_mode.hsync_end = lvds->native_mode.hsync_start +
12631268 (RBIOS8(tmp + 23) * 8);
12641269
drivers/gpu/drm/radeon/radeon_connectors.c+14−4
@@ -1379,8 +1379,16 @@ out: · 1378 unmodified lines
13791379 /* updated in get modes as well since we need to know if it's analog or digital */
13801380 radeon_connector_update_scratch_regs(connector, ret);
13811381
1382− if (radeon_audio != 0)
1383− radeon_audio_detect(connector, ret);
1382+ if ((radeon_audio != 0) && radeon_connector->use_digital) {
1383+ const struct drm_connector_helper_funcs *connector_funcs =
1384+ connector->helper_private;
1385+
1386+ encoder = connector_funcs->best_encoder(connector);
1387+ if (encoder && (encoder->encoder_type == DRM_MODE_ENCODER_TMDS)) {
1388+ radeon_connector_get_edid(connector);
1389+ radeon_audio_detect(connector, encoder, ret);
1390+ }
1391+ }
13841392
13851393 exit:
13861394 pm_runtime_mark_last_busy(connector->dev->dev);
@@ -1717,8 +1725,10 @@ radeon_dp_detect(struct drm_connector *connector, bool force) · 330 unmodified lines
17171725
17181726 radeon_connector_update_scratch_regs(connector, ret);
17191727
1720− if (radeon_audio != 0)
1721− radeon_audio_detect(connector, ret);
1728+ if ((radeon_audio != 0) && encoder) {
1729+ radeon_connector_get_edid(connector);
1730+ radeon_audio_detect(connector, encoder, ret);
1731+ }
17221732
17231733 out:
17241734 pm_runtime_mark_last_busy(connector->dev->dev);
drivers/gpu/drm/radeon/radeon_mode.h+1−1
@@ -237,7 +237,6 @@ struct radeon_afmt { · 236 unmodified lines
237237 int offset;
238238 bool last_buffer_filled_status;
239239 int id;
240− struct r600_audio_pin *pin;
241240 };
242241
243242 struct radeon_mode_info {
@@ -439,6 +438,7 @@ struct radeon_encoder_atom_dig { · 195 unmodified lines
439438 uint8_t backlight_level;
440439 int panel_mode;
441440 struct radeon_afmt *afmt;
441+ struct r600_audio_pin *pin;
442442 int active_mst_links;
443443 };
444444
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c+2−2
@@ -2492,7 +2492,7 @@ int vmw_execbuf_process(struct drm_file *file_priv, · 2491 unmodified lines
24922492 ret = ttm_eu_reserve_buffers(&ticket, &sw_context->validate_nodes,
24932493 true, NULL);
24942494 if (unlikely(ret != 0))
2495− goto out_err;
2495+ goto out_err_nores;
24962496
24972497 ret = vmw_validate_buffers(dev_priv, sw_context);
24982498 if (unlikely(ret != 0))
@@ -2536,6 +2536,7 @@ int vmw_execbuf_process(struct drm_file *file_priv, · 37 unmodified lines
25362536 vmw_resource_relocations_free(&sw_context->res_relocations);
25372537
25382538 vmw_fifo_commit(dev_priv, command_size);
2539+ mutex_unlock(&dev_priv->binding_mutex);
25392540
25402541 vmw_query_bo_switch_commit(dev_priv, sw_context);
25412542 ret = vmw_execbuf_fence_commands(file_priv, dev_priv,
@@ -2551,7 +2552,6 @@ int vmw_execbuf_process(struct drm_file *file_priv, · 9 unmodified lines
25512552 DRM_ERROR("Fence submission error. Syncing.\n");
25522553
25532554 vmw_resource_list_unreserve(&sw_context->resource_list, false);
2554− mutex_unlock(&dev_priv->binding_mutex);
25552555
25562556 ttm_eu_fence_buffer_objects(&ticket, &sw_context->validate_nodes,
25572557 (void *) fence);
drivers/hid/hid-apple.c+6−0
@@ -546,6 +546,12 @@ static const struct hid_device_id apple_devices[] = { · 545 unmodified lines
546546 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
547547 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
548548 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
549+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI),
550+ .driver_data = APPLE_HAS_FN },
551+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO),
552+ .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
553+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
554+ .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
549555 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
550556 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
551557 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
drivers/hid/hid-core.c+6−0
@@ -1782,6 +1782,9 @@ static const struct hid_device_id hid_have_special_driver[] = { · 1781 unmodified lines
17821782 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI) },
17831783 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO) },
17841784 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS) },
1785+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI) },
1786+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) },
1787+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
17851788 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
17861789 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
17871790 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
@@ -2463,6 +2466,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = { · 675 unmodified lines
24632466 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI) },
24642467 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO) },
24652468 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS) },
2469+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI) },
2470+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) },
2471+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
24662472 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
24672473 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
24682474 { }
drivers/hid/hid-ids.h+3−0
@@ -142,6 +142,9 @@ · 141 unmodified lines
142142 #define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290
143143 #define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291
144144 #define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292
145+#define USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI 0x0272
146+#define USB_DEVICE_ID_APPLE_WELLSPRING9_ISO 0x0273
147+#define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS 0x0274
145148 #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
146149 #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
147150 #define USB_DEVICE_ID_APPLE_IRCONTROL 0x8240
drivers/hid/hid-input.c+5−2
@@ -462,12 +462,15 @@ out: · 461 unmodified lines
462462
463463 static void hidinput_cleanup_battery(struct hid_device *dev)
464464 {
465+ const struct power_supply_desc *psy_desc;
466+
465467 if (!dev->battery)
466468 return;
467469
470+ psy_desc = dev->battery->desc;
468471 power_supply_unregister(dev->battery);
469− kfree(dev->battery->desc->name);
470− kfree(dev->battery->desc);
472+ kfree(psy_desc->name);
473+ kfree(psy_desc);
471474 dev->battery = NULL;
472475 }
473476 #else /* !CONFIG_HID_BATTERY_STRENGTH */
drivers/hid/hid-uclogic.c+1−1
@@ -858,7 +858,7 @@ static int uclogic_tablet_enable(struct hid_device *hdev) · 857 unmodified lines
858858 for (p = drvdata->rdesc;
859859 p <= drvdata->rdesc + drvdata->rsize - 4;) {
860860 if (p[0] == 0xFE && p[1] == 0xED && p[2] == 0x1D &&
861− p[3] < sizeof(params)) {
861+ p[3] < ARRAY_SIZE(params)) {
862862 v = params[p[3]];
863863 put_unaligned(cpu_to_le32(v), (s32 *)p);
864864 p += 4;
drivers/hid/wacom_sys.c+37−33
@@ -1284,6 +1284,39 @@ fail_register_pen_input: · 1283 unmodified lines
12841284 return error;
12851285 }
12861286
1287+/*
1288+ * Not all devices report physical dimensions from HID.
1289+ * Compute the default from hardcoded logical dimension
1290+ * and resolution before driver overwrites them.
1291+ */
1292+static void wacom_set_default_phy(struct wacom_features *features)
1293+{
1294+ if (features->x_resolution) {
1295+ features->x_phy = (features->x_max * 100) /
1296+ features->x_resolution;
1297+ features->y_phy = (features->y_max * 100) /
1298+ features->y_resolution;
1299+ }
1300+}
1301+
1302+static void wacom_calculate_res(struct wacom_features *features)
1303+{
1304+ /* set unit to "100th of a mm" for devices not reported by HID */
1305+ if (!features->unit) {
1306+ features->unit = 0x11;
1307+ features->unitExpo = -3;
1308+ }
1309+
1310+ features->x_resolution = wacom_calc_hid_res(features->x_max,
1311+ features->x_phy,
1312+ features->unit,
1313+ features->unitExpo);
1314+ features->y_resolution = wacom_calc_hid_res(features->y_max,
1315+ features->y_phy,
1316+ features->unit,
1317+ features->unitExpo);
1318+}
1319+
12871320 static void wacom_wireless_work(struct work_struct *work)
12881321 {
12891322 struct wacom *wacom = container_of(work, struct wacom, work);
@@ -1341,6 +1374,8 @@ static void wacom_wireless_work(struct work_struct *work) · 51 unmodified lines
13411374 if (wacom_wac1->features.type != INTUOSHT &&
13421375 wacom_wac1->features.type != BAMBOO_PT)
13431376 wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD;
1377+ wacom_set_default_phy(&wacom_wac1->features);
1378+ wacom_calculate_res(&wacom_wac1->features);
13441379 snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen",
13451380 wacom_wac1->features.name);
13461381 snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
@@ -1359,7 +1394,9 @@ static void wacom_wireless_work(struct work_struct *work) · 12 unmodified lines
13591394 wacom_wac2->features =
13601395 *((struct wacom_features *)id->driver_data);
13611396 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
1397+ wacom_set_default_phy(&wacom_wac2->features);
13621398 wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
1399+ wacom_calculate_res(&wacom_wac2->features);
13631400 snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX,
13641401 "%s (WL) Finger",wacom_wac2->features.name);
13651402 snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
@@ -1407,39 +1444,6 @@ void wacom_battery_work(struct work_struct *work) · 41 unmodified lines
14071444 }
14081445 }
14091446
1410−/*
1411− * Not all devices report physical dimensions from HID.
1412− * Compute the default from hardcoded logical dimension
1413− * and resolution before driver overwrites them.
1414− */
1415−static void wacom_set_default_phy(struct wacom_features *features)
1416−{
1417− if (features->x_resolution) {
1418− features->x_phy = (features->x_max * 100) /
1419− features->x_resolution;
1420− features->y_phy = (features->y_max * 100) /
1421− features->y_resolution;
1422− }
1423−}
1424−
1425−static void wacom_calculate_res(struct wacom_features *features)
1426−{
1427− /* set unit to "100th of a mm" for devices not reported by HID */
1428− if (!features->unit) {
1429− features->unit = 0x11;
1430− features->unitExpo = -3;
1431− }
1432−
1433− features->x_resolution = wacom_calc_hid_res(features->x_max,
1434− features->x_phy,
1435− features->unit,
1436− features->unitExpo);
1437− features->y_resolution = wacom_calc_hid_res(features->y_max,
1438− features->y_phy,
1439− features->unit,
1440− features->unitExpo);
1441−}
1442−
14431447 static size_t wacom_compute_pktlen(struct hid_device *hdev)
14441448 {
14451449 struct hid_report_enum *report_enum;
drivers/hwmon/dell-smm-hwmon.c+17−1
@@ -929,6 +929,21 @@ static struct dmi_system_id i8k_dmi_table[] __initdata = { · 928 unmodified lines
929929
930930 MODULE_DEVICE_TABLE(dmi, i8k_dmi_table);
931931
932+static struct dmi_system_id i8k_blacklist_dmi_table[] __initdata = {
933+ {
934+ /*
935+ * CPU fan speed going up and down on Dell Studio XPS 8100
936+ * for unknown reasons.
937+ */
938+ .ident = "Dell Studio XPS 8100",
939+ .matches = {
940+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
941+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Studio XPS 8100"),
942+ },
943+ },
944+ { }
945+};
946+
932947 /*
933948 * Probe for the presence of a supported laptop.
934949 */
@@ -940,7 +955,8 @@ static int __init i8k_probe(void) · 5 unmodified lines
940955 /*
941956 * Get DMI information
942957 */
943− if (!dmi_check_system(i8k_dmi_table)) {
958+ if (!dmi_check_system(i8k_dmi_table) ||
959+ dmi_check_system(i8k_blacklist_dmi_table)) {
944960 if (!ignore_dmi && !force)
945961 return -ENODEV;
946962
drivers/hwmon/g762.c+1−0
@@ -582,6 +582,7 @@ static const struct of_device_id g762_dt_match[] = { · 581 unmodified lines
582582 { .compatible = "gmt,g763" },
583583 { },
584584 };
585+MODULE_DEVICE_TABLE(of, g762_dt_match);
585586
586587 /*
587588 * Grab clock (a required property), enable it, get (fixed) clock frequency
drivers/hwmon/nct7802.c+1−1
@@ -195,7 +195,7 @@ abort: · 194 unmodified lines
195195 }
196196
197197 static int nct7802_write_voltage(struct nct7802_data *data, int nr, int index,
198− unsigned int voltage)
198+ unsigned long voltage)
199199 {
200200 int shift = 8 - REG_VOLTAGE_LIMIT_MSB_SHIFT[index - 1][nr];
201201 int err;
drivers/hwmon/nct7904.c+30−28
@@ -412,8 +412,9 @@ static ssize_t show_pwm(struct device *dev, · 411 unmodified lines
412412 return sprintf(buf, "%d\n", val);
413413 }
414414
415−static ssize_t store_mode(struct device *dev, struct device_attribute *devattr,
416− const char *buf, size_t count)
415+static ssize_t store_enable(struct device *dev,
416+ struct device_attribute *devattr,
417+ const char *buf, size_t count)
417418 {
418419 int index = to_sensor_dev_attr(devattr)->index;
419420 struct nct7904_data *data = dev_get_drvdata(dev);
@@ -422,18 +423,18 @@ static ssize_t store_mode(struct device *dev, struct device_attribute *devattr, · 2 unmodified lines
422423
423424 if (kstrtoul(buf, 10, &val) < 0)
424425 return -EINVAL;
425− if (val > 1 || (val && !data->fan_mode[index]))
426+ if (val < 1 || val > 2 || (val == 2 && !data->fan_mode[index]))
426427 return -EINVAL;
427428
428429 ret = nct7904_write_reg(data, BANK_3, FANCTL1_FMR_REG + index,
429− val ? data->fan_mode[index] : 0);
430+ val == 2 ? data->fan_mode[index] : 0);
430431
431432 return ret ? ret : count;
432433 }
433434
434−/* Return 0 for manual mode or 1 for SmartFan mode */
435−static ssize_t show_mode(struct device *dev,
436− struct device_attribute *devattr, char *buf)
435+/* Return 1 for manual mode or 2 for SmartFan mode */
436+static ssize_t show_enable(struct device *dev,
437+ struct device_attribute *devattr, char *buf)
437438 {
438439 int index = to_sensor_dev_attr(devattr)->index;
439440 struct nct7904_data *data = dev_get_drvdata(dev);
@@ -443,36 +444,36 @@ static ssize_t show_mode(struct device *dev, · 3 unmodified lines
443444 if (val < 0)
444445 return val;
445446
446− return sprintf(buf, "%d\n", val ? 1 : 0);
447+ return sprintf(buf, "%d\n", val ? 2 : 1);
447448 }
448449
449450 /* 2 attributes per channel: pwm and mode */
450−static SENSOR_DEVICE_ATTR(fan1_pwm, S_IRUGO | S_IWUSR,
451+static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR,
451452 show_pwm, store_pwm, 0);
452−static SENSOR_DEVICE_ATTR(fan1_mode, S_IRUGO | S_IWUSR,
453− show_mode, store_mode, 0);
454−static SENSOR_DEVICE_ATTR(fan2_pwm, S_IRUGO | S_IWUSR,
453+static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
454+ show_enable, store_enable, 0);
455+static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR,
455456 show_pwm, store_pwm, 1);
456−static SENSOR_DEVICE_ATTR(fan2_mode, S_IRUGO | S_IWUSR,
457− show_mode, store_mode, 1);
458−static SENSOR_DEVICE_ATTR(fan3_pwm, S_IRUGO | S_IWUSR,
457+static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR,
458+ show_enable, store_enable, 1);
459+static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR,
459460 show_pwm, store_pwm, 2);
460−static SENSOR_DEVICE_ATTR(fan3_mode, S_IRUGO | S_IWUSR,
461− show_mode, store_mode, 2);
462−static SENSOR_DEVICE_ATTR(fan4_pwm, S_IRUGO | S_IWUSR,
461+static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR,
462+ show_enable, store_enable, 2);
463+static SENSOR_DEVICE_ATTR(pwm4, S_IRUGO | S_IWUSR,
463464 show_pwm, store_pwm, 3);
464−static SENSOR_DEVICE_ATTR(fan4_mode, S_IRUGO | S_IWUSR,
465− show_mode, store_mode, 3);
465+static SENSOR_DEVICE_ATTR(pwm4_enable, S_IRUGO | S_IWUSR,
466+ show_enable, store_enable, 3);
466467
467468 static struct attribute *nct7904_fanctl_attrs[] = {
468− &sensor_dev_attr_fan1_pwm.dev_attr.attr,
469− &sensor_dev_attr_fan1_mode.dev_attr.attr,
470− &sensor_dev_attr_fan2_pwm.dev_attr.attr,
471− &sensor_dev_attr_fan2_mode.dev_attr.attr,
472− &sensor_dev_attr_fan3_pwm.dev_attr.attr,
473− &sensor_dev_attr_fan3_mode.dev_attr.attr,
474− &sensor_dev_attr_fan4_pwm.dev_attr.attr,
475− &sensor_dev_attr_fan4_mode.dev_attr.attr,
469+ &sensor_dev_attr_pwm1.dev_attr.attr,
470+ &sensor_dev_attr_pwm1_enable.dev_attr.attr,
471+ &sensor_dev_attr_pwm2.dev_attr.attr,
472+ &sensor_dev_attr_pwm2_enable.dev_attr.attr,
473+ &sensor_dev_attr_pwm3.dev_attr.attr,
474+ &sensor_dev_attr_pwm3_enable.dev_attr.attr,
475+ &sensor_dev_attr_pwm4.dev_attr.attr,
476+ &sensor_dev_attr_pwm4_enable.dev_attr.attr,
476477 NULL
477478 };
478479
@@ -574,6 +575,7 @@ static const struct i2c_device_id nct7904_id[] = { · 95 unmodified lines
574575 {"nct7904", 0},
575576 {}
576577 };
578+MODULE_DEVICE_TABLE(i2c, nct7904_id);
577579
578580 static struct i2c_driver nct7904_driver = {
579581 .class = I2C_CLASS_HWMON,
drivers/i2c/busses/i2c-bfin-twi.c+2−2
@@ -692,7 +692,7 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev) · 691 unmodified lines
692692
693693 platform_set_drvdata(pdev, iface);
694694
695− dev_info(&pdev->dev, "Blackfin BF5xx on-chip I2C TWI Contoller, "
695+ dev_info(&pdev->dev, "Blackfin BF5xx on-chip I2C TWI Controller, "
696696 "regs_base@%p\n", iface->regs_base);
697697
698698 return 0;
@@ -735,6 +735,6 @@ subsys_initcall(i2c_bfin_twi_init); · 36 unmodified lines
735735 module_exit(i2c_bfin_twi_exit);
736736
737737 MODULE_AUTHOR("Bryan Wu, Sonic Zhang");
738−MODULE_DESCRIPTION("Blackfin BF5xx on-chip I2C TWI Contoller Driver");
738+MODULE_DESCRIPTION("Blackfin BF5xx on-chip I2C TWI Controller Driver");
739739 MODULE_LICENSE("GPL");
740740 MODULE_ALIAS("platform:i2c-bfin-twi");
drivers/i2c/busses/i2c-omap.c+11−0
@@ -1247,7 +1247,14 @@ static void omap_i2c_prepare_recovery(struct i2c_adapter *adap) · 1246 unmodified lines
12471247 u32 reg;
12481248
12491249 reg = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG);
1250+ /* enable test mode */
12501251 reg |= OMAP_I2C_SYSTEST_ST_EN;
1252+ /* select SDA/SCL IO mode */
1253+ reg |= 3 << OMAP_I2C_SYSTEST_TMODE_SHIFT;
1254+ /* set SCL to high-impedance state (reset value is 0) */
1255+ reg |= OMAP_I2C_SYSTEST_SCL_O;
1256+ /* set SDA to high-impedance state (reset value is 0) */
1257+ reg |= OMAP_I2C_SYSTEST_SDA_O;
12511258 omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, reg);
12521259 }
12531260
@@ -1257,7 +1264,11 @@ static void omap_i2c_unprepare_recovery(struct i2c_adapter *adap) · 3 unmodified lines
12571264 u32 reg;
12581265
12591266 reg = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG);
1267+ /* restore reset values */
12601268 reg &= ~OMAP_I2C_SYSTEST_ST_EN;
1269+ reg &= ~OMAP_I2C_SYSTEST_TMODE_MASK;
1270+ reg &= ~OMAP_I2C_SYSTEST_SCL_O;
1271+ reg &= ~OMAP_I2C_SYSTEST_SDA_O;
12611272 omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, reg);
12621273 }
12631274
drivers/i2c/i2c-core.c+17−7
@@ -567,6 +567,9 @@ static int i2c_generic_recovery(struct i2c_adapter *adap) · 566 unmodified lines
567567 if (bri->prepare_recovery)
568568 bri->prepare_recovery(adap);
569569
570+ bri->set_scl(adap, val);
571+ ndelay(RECOVERY_NDELAY);
572+
570573 /*
571574 * By this time SCL is high, as we need to give 9 falling-rising edges
572575 */
@@ -597,7 +600,6 @@ static int i2c_generic_recovery(struct i2c_adapter *adap) · 24 unmodified lines
597600
598601 int i2c_generic_scl_recovery(struct i2c_adapter *adap)
599602 {
600− adap->bus_recovery_info->set_scl(adap, 1);
601603 return i2c_generic_recovery(adap);
602604 }
603605 EXPORT_SYMBOL_GPL(i2c_generic_scl_recovery);
@@ -1338,13 +1340,17 @@ static int of_dev_node_match(struct device *dev, void *data) · 734 unmodified lines
13381340 struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
13391341 {
13401342 struct device *dev;
1343+ struct i2c_client *client;
13411344
1342− dev = bus_find_device(&i2c_bus_type, NULL, node,
1343− of_dev_node_match);
1345+ dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match);
13441346 if (!dev)
13451347 return NULL;
13461348
1347− return i2c_verify_client(dev);
1349+ client = i2c_verify_client(dev);
1350+ if (!client)
1351+ put_device(dev);
1352+
1353+ return client;
13481354 }
13491355 EXPORT_SYMBOL(of_find_i2c_device_by_node);
13501356
@@ -1352,13 +1358,17 @@ EXPORT_SYMBOL(of_find_i2c_device_by_node); · 1 unmodified line
13521358 struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
13531359 {
13541360 struct device *dev;
1361+ struct i2c_adapter *adapter;
13551362
1356− dev = bus_find_device(&i2c_bus_type, NULL, node,
1357− of_dev_node_match);
1363+ dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match);
13581364 if (!dev)
13591365 return NULL;
13601366
1361− return i2c_verify_adapter(dev);
1367+ adapter = i2c_verify_adapter(dev);
1368+ if (!adapter)
1369+ put_device(dev);
1370+
1371+ return adapter;
13621372 }
13631373 EXPORT_SYMBOL(of_find_i2c_adapter_by_node);
13641374 #else
drivers/i2c/i2c-slave-eeprom.c+0−6
@@ -80,9 +80,6 @@ static ssize_t i2c_slave_eeprom_bin_read(struct file *filp, struct kobject *kobj · 79 unmodified lines
8080 struct eeprom_data *eeprom;
8181 unsigned long flags;
8282
83− if (off + count > attr->size)
84− return -EFBIG;
85−
8683 eeprom = dev_get_drvdata(container_of(kobj, struct device, kobj));
8784
8885 spin_lock_irqsave(&eeprom->buffer_lock, flags);
@@ -98,9 +95,6 @@ static ssize_t i2c_slave_eeprom_bin_write(struct file *filp, struct kobject *kob · 9 unmodified lines
9895 struct eeprom_data *eeprom;
9996 unsigned long flags;
10097
101− if (off + count > attr->size)
102− return -EFBIG;
103−
10498 eeprom = dev_get_drvdata(container_of(kobj, struct device, kobj));
10599
106100 spin_lock_irqsave(&eeprom->buffer_lock, flags);
drivers/infiniband/hw/cxgb3/iwch_provider.c+4−0
@@ -736,6 +736,10 @@ static struct ib_mr *iwch_get_dma_mr(struct ib_pd *pd, int acc) · 735 unmodified lines
736736 /*
737737 * T3 only supports 32 bits of size.
738738 */
739+ if (sizeof(phys_addr_t) > 4) {
740+ pr_warn_once(MOD "Cannot support dma_mrs on this platform.\n");
741+ return ERR_PTR(-ENOTSUPP);
742+ }
739743 bl.size = 0xffffffff;
740744 bl.addr = 0;
741745 kva = 0;
drivers/infiniband/hw/cxgb4/cq.c+1−1
@@ -814,7 +814,7 @@ static int c4iw_poll_cq_one(struct c4iw_cq *chp, struct ib_wc *wc) · 813 unmodified lines
814814 printk(KERN_ERR MOD
815815 "Unexpected cqe_status 0x%x for QPID=0x%0x\n",
816816 CQE_STATUS(&cqe), CQE_QPID(&cqe));
817− ret = -EINVAL;
817+ wc->status = IB_WC_FATAL_ERR;
818818 }
819819 }
820820 out:
drivers/infiniband/hw/ocrdma/ocrdma.h+34−19
@@ -1,21 +1,36 @@
1−/*******************************************************************
2− * This file is part of the Emulex RoCE Device Driver for *
3− * RoCE (RDMA over Converged Ethernet) adapters. *
4− * Copyright (C) 2008-2012 Emulex. All rights reserved. *
5− * EMULEX and SLI are trademarks of Emulex. *
6− * www.emulex.com *
7− * *
8− * This program is free software; you can redistribute it and/or *
9− * modify it under the terms of version 2 of the GNU General *
10− * Public License as published by the Free Software Foundation. *
11− * This program is distributed in the hope that it will be useful. *
12− * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13− * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14− * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15− * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16− * TO BE LEGALLY INVALID. See the GNU General Public License for *
17− * more details, a copy of which can be found in the file COPYING *
18− * included with this package. *
1+/* This file is part of the Emulex RoCE Device Driver for
2+ * RoCE (RDMA over Converged Ethernet) adapters.
3+ * Copyright (C) 2012-2015 Emulex. All rights reserved.
4+ * EMULEX and SLI are trademarks of Emulex.
5+ * www.emulex.com
6+ *
7+ * This software is available to you under a choice of one of two licenses.
8+ * You may choose to be licensed under the terms of the GNU General Public
9+ * License (GPL) Version 2, available from the file COPYING in the main
10+ * directory of this source tree, or the BSD license below:
11+ *
12+ * Redistribution and use in source and binary forms, with or without
13+ * modification, are permitted provided that the following conditions
14+ * are met:
15+ *
16+ * - Redistributions of source code must retain the above copyright notice,
17+ * this list of conditions and the following disclaimer.
18+ *
19+ * - Redistributions in binary form must reproduce the above copyright
20+ * notice, this list of conditions and the following disclaimer in
21+ * the documentation and/or other materials provided with the distribution.
22+ *
23+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 *
2035 * Contact Information:
2136 * linux-drivers@emulex.com
@@ -23,7 +38,7 @@ · 1 unmodified line
2338 * Emulex
2439 * 3333 Susan Street
2540 * Costa Mesa, CA 92626
26− *******************************************************************/
41+ */
2742
2843 #ifndef __OCRDMA_H__
2944 #define __OCRDMA_H__
drivers/infiniband/hw/ocrdma/ocrdma_abi.h+34−19
@@ -1,21 +1,36 @@
1−/*******************************************************************
2− * This file is part of the Emulex RoCE Device Driver for *
3− * RoCE (RDMA over Converged Ethernet) adapters. *
4− * Copyright (C) 2008-2012 Emulex. All rights reserved. *
5− * EMULEX and SLI are trademarks of Emulex. *
6− * www.emulex.com *
7− * *
8− * This program is free software; you can redistribute it and/or *
9− * modify it under the terms of version 2 of the GNU General *
10− * Public License as published by the Free Software Foundation. *
11− * This program is distributed in the hope that it will be useful. *
12− * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13− * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14− * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15− * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16− * TO BE LEGALLY INVALID. See the GNU General Public License for *
17− * more details, a copy of which can be found in the file COPYING *
18− * included with this package. *
1+/* This file is part of the Emulex RoCE Device Driver for
2+ * RoCE (RDMA over Converged Ethernet) adapters.
3+ * Copyright (C) 2012-2015 Emulex. All rights reserved.
4+ * EMULEX and SLI are trademarks of Emulex.
5+ * www.emulex.com
6+ *
7+ * This software is available to you under a choice of one of two licenses.
8+ * You may choose to be licensed under the terms of the GNU General Public
9+ * License (GPL) Version 2, available from the file COPYING in the main
10+ * directory of this source tree, or the BSD license below:
11+ *
12+ * Redistribution and use in source and binary forms, with or without
13+ * modification, are permitted provided that the following conditions
14+ * are met:
15+ *
16+ * - Redistributions of source code must retain the above copyright notice,
17+ * this list of conditions and the following disclaimer.
18+ *
19+ * - Redistributions in binary form must reproduce the above copyright
20+ * notice, this list of conditions and the following disclaimer in
21+ * the documentation and/or other materials provided with the distribution.
22+ *
23+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 *
2035 * Contact Information:
2136 * linux-drivers@emulex.com
@@ -23,7 +38,7 @@ · 1 unmodified line
2338 * Emulex
2439 * 3333 Susan Street
2540 * Costa Mesa, CA 92626
26− *******************************************************************/
41+ */
2742
2843 #ifndef __OCRDMA_ABI_H__
2944 #define __OCRDMA_ABI_H__
drivers/infiniband/hw/ocrdma/ocrdma_ah.c+34−19
@@ -1,21 +1,36 @@
1−/*******************************************************************
2− * This file is part of the Emulex RoCE Device Driver for *
3− * RoCE (RDMA over Converged Ethernet) adapters. *
4− * Copyright (C) 2008-2012 Emulex. All rights reserved. *
5− * EMULEX and SLI are trademarks of Emulex. *
6− * www.emulex.com *
7− * *
8− * This program is free software; you can redistribute it and/or *
9− * modify it under the terms of version 2 of the GNU General *
10− * Public License as published by the Free Software Foundation. *
11− * This program is distributed in the hope that it will be useful. *
12− * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13− * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14− * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15− * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16− * TO BE LEGALLY INVALID. See the GNU General Public License for *
17− * more details, a copy of which can be found in the file COPYING *
18− * included with this package. *
1+/* This file is part of the Emulex RoCE Device Driver for
2+ * RoCE (RDMA over Converged Ethernet) adapters.
3+ * Copyright (C) 2012-2015 Emulex. All rights reserved.
4+ * EMULEX and SLI are trademarks of Emulex.
5+ * www.emulex.com
6+ *
7+ * This software is available to you under a choice of one of two licenses.
8+ * You may choose to be licensed under the terms of the GNU General Public
9+ * License (GPL) Version 2, available from the file COPYING in the main
10+ * directory of this source tree, or the BSD license below:
11+ *
12+ * Redistribution and use in source and binary forms, with or without
13+ * modification, are permitted provided that the following conditions
14+ * are met:
15+ *
16+ * - Redistributions of source code must retain the above copyright notice,
17+ * this list of conditions and the following disclaimer.
18+ *
19+ * - Redistributions in binary form must reproduce the above copyright
20+ * notice, this list of conditions and the following disclaimer in
21+ * the documentation and/or other materials provided with the distribution.
22+ *
23+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 *
2035 * Contact Information:
2136 * linux-drivers@emulex.com
@@ -23,7 +38,7 @@ · 1 unmodified line
2338 * Emulex
2439 * 3333 Susan Street
2540 * Costa Mesa, CA 92626
26− *******************************************************************/
41+ */
2742
2843 #include <net/neighbour.h>
2944 #include <net/netevent.h>
drivers/infiniband/hw/ocrdma/ocrdma_ah.h+34−19
@@ -1,21 +1,36 @@
1−/*******************************************************************
2− * This file is part of the Emulex RoCE Device Driver for *
3− * RoCE (RDMA over Converged Ethernet) adapters. *
4− * Copyright (C) 2008-2012 Emulex. All rights reserved. *
5− * EMULEX and SLI are trademarks of Emulex. *
6− * www.emulex.com *
7− * *
8− * This program is free software; you can redistribute it and/or *
9− * modify it under the terms of version 2 of the GNU General *
10− * Public License as published by the Free Software Foundation. *
11− * This program is distributed in the hope that it will be useful. *
12− * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13− * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14− * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15− * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16− * TO BE LEGALLY INVALID. See the GNU General Public License for *
17− * more details, a copy of which can be found in the file COPYING *
18− * included with this package. *
1+/* This file is part of the Emulex RoCE Device Driver for
2+ * RoCE (RDMA over Converged Ethernet) adapters.
3+ * Copyright (C) 2012-2015 Emulex. All rights reserved.
4+ * EMULEX and SLI are trademarks of Emulex.
5+ * www.emulex.com
6+ *
7+ * This software is available to you under a choice of one of two licenses.
8+ * You may choose to be licensed under the terms of the GNU General Public
9+ * License (GPL) Version 2, available from the file COPYING in the main
10+ * directory of this source tree, or the BSD license below:
11+ *
12+ * Redistribution and use in source and binary forms, with or without
13+ * modification, are permitted provided that the following conditions
14+ * are met:
15+ *
16+ * - Redistributions of source code must retain the above copyright notice,
17+ * this list of conditions and the following disclaimer.
18+ *
19+ * - Redistributions in binary form must reproduce the above copyright
20+ * notice, this list of conditions and the following disclaimer in
21+ * the documentation and/or other materials provided with the distribution.
22+ *
23+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 *
2035 * Contact Information:
2136 * linux-drivers@emulex.com
@@ -23,7 +38,7 @@ · 1 unmodified line
2338 * Emulex
2439 * 3333 Susan Street
2540 * Costa Mesa, CA 92626
26− *******************************************************************/
41+ */
2742
2843 #ifndef __OCRDMA_AH_H__
2944 #define __OCRDMA_AH_H__
drivers/infiniband/hw/ocrdma/ocrdma_hw.c+34−19
@@ -1,21 +1,36 @@
1−/*******************************************************************
2− * This file is part of the Emulex RoCE Device Driver for *
3− * RoCE (RDMA over Converged Ethernet) CNA Adapters. *
4− * Copyright (C) 2008-2012 Emulex. All rights reserved. *
5− * EMULEX and SLI are trademarks of Emulex. *
6− * www.emulex.com *
7− * *
8− * This program is free software; you can redistribute it and/or *
9− * modify it under the terms of version 2 of the GNU General *
10− * Public License as published by the Free Software Foundation. *
11− * This program is distributed in the hope that it will be useful. *
12− * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13− * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14− * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15− * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16− * TO BE LEGALLY INVALID. See the GNU General Public License for *
17− * more details, a copy of which can be found in the file COPYING *
18− * included with this package. *
1+/* This file is part of the Emulex RoCE Device Driver for
2+ * RoCE (RDMA over Converged Ethernet) adapters.
3+ * Copyright (C) 2012-2015 Emulex. All rights reserved.
4+ * EMULEX and SLI are trademarks of Emulex.
5+ * www.emulex.com
6+ *
7+ * This software is available to you under a choice of one of two licenses.
8+ * You may choose to be licensed under the terms of the GNU General Public
9+ * License (GPL) Version 2, available from the file COPYING in the main
10+ * directory of this source tree, or the BSD license below:
11+ *
12+ * Redistribution and use in source and binary forms, with or without
13+ * modification, are permitted provided that the following conditions
14+ * are met:
15+ *
16+ * - Redistributions of source code must retain the above copyright notice,
17+ * this list of conditions and the following disclaimer.
18+ *
19+ * - Redistributions in binary form must reproduce the above copyright
20+ * notice, this list of conditions and the following disclaimer in
21+ * the documentation and/or other materials provided with the distribution.
22+ *
23+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 *
2035 * Contact Information:
2136 * linux-drivers@emulex.com
@@ -23,7 +38,7 @@ · 1 unmodified line
2338 * Emulex
2439 * 3333 Susan Street
2540 * Costa Mesa, CA 92626
26− *******************************************************************/
41+ */
2742
2843 #include <linux/sched.h>
2944 #include <linux/interrupt.h>
drivers/infiniband/hw/ocrdma/ocrdma_hw.h+34−19
@@ -1,21 +1,36 @@
1−/*******************************************************************
2− * This file is part of the Emulex RoCE Device Driver for *
3− * RoCE (RDMA over Converged Ethernet) CNA Adapters. *
4− * Copyright (C) 2008-2012 Emulex. All rights reserved. *
5− * EMULEX and SLI are trademarks of Emulex. *
6− * www.emulex.com *
7− * *
8− * This program is free software; you can redistribute it and/or *
9− * modify it under the terms of version 2 of the GNU General *
10− * Public License as published by the Free Software Foundation. *
11− * This program is distributed in the hope that it will be useful. *
12− * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13− * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14− * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15− * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16− * TO BE LEGALLY INVALID. See the GNU General Public License for *
17− * more details, a copy of which can be found in the file COPYING *
18− * included with this package. *
1+/* This file is part of the Emulex RoCE Device Driver for
2+ * RoCE (RDMA over Converged Ethernet) adapters.
3+ * Copyright (C) 2012-2015 Emulex. All rights reserved.
4+ * EMULEX and SLI are trademarks of Emulex.
5+ * www.emulex.com
6+ *
7+ * This software is available to you under a choice of one of two licenses.
8+ * You may choose to be licensed under the terms of the GNU General Public
9+ * License (GPL) Version 2, available from the file COPYING in the main
10+ * directory of this source tree, or the BSD license below:
11+ *
12+ * Redistribution and use in source and binary forms, with or without
13+ * modification, are permitted provided that the following conditions
14+ * are met:
15+ *
16+ * - Redistributions of source code must retain the above copyright notice,
17+ * this list of conditions and the following disclaimer.
18+ *
19+ * - Redistributions in binary form must reproduce the above copyright
20+ * notice, this list of conditions and the following disclaimer in
21+ * the documentation and/or other materials provided with the distribution.
22+ *
23+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 *
2035 * Contact Information:
2136 * linux-drivers@emulex.com
@@ -23,7 +38,7 @@ · 1 unmodified line
2338 * Emulex
2439 * 3333 Susan Street
2540 * Costa Mesa, CA 92626
26− *******************************************************************/
41+ */
2742
2843 #ifndef __OCRDMA_HW_H__
2944 #define __OCRDMA_HW_H__
drivers/infiniband/hw/ocrdma/ocrdma_main.c+35−20
@@ -1,21 +1,36 @@
1−/*******************************************************************
2− * This file is part of the Emulex RoCE Device Driver for *
3− * RoCE (RDMA over Converged Ethernet) adapters. *
4− * Copyright (C) 2008-2012 Emulex. All rights reserved. *
5− * EMULEX and SLI are trademarks of Emulex. *
6− * www.emulex.com *
7− * *
8− * This program is free software; you can redistribute it and/or *
9− * modify it under the terms of version 2 of the GNU General *
10− * Public License as published by the Free Software Foundation. *
11− * This program is distributed in the hope that it will be useful. *
12− * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13− * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14− * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15− * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16− * TO BE LEGALLY INVALID. See the GNU General Public License for *
17− * more details, a copy of which can be found in the file COPYING *
18− * included with this package. *
1+/* This file is part of the Emulex RoCE Device Driver for
2+ * RoCE (RDMA over Converged Ethernet) adapters.
3+ * Copyright (C) 2012-2015 Emulex. All rights reserved.
4+ * EMULEX and SLI are trademarks of Emulex.
5+ * www.emulex.com
6+ *
7+ * This software is available to you under a choice of one of two licenses.
8+ * You may choose to be licensed under the terms of the GNU General Public
9+ * License (GPL) Version 2, available from the file COPYING in the main
10+ * directory of this source tree, or the BSD license below:
11+ *
12+ * Redistribution and use in source and binary forms, with or without
13+ * modification, are permitted provided that the following conditions
14+ * are met:
15+ *
16+ * - Redistributions of source code must retain the above copyright notice,
17+ * this list of conditions and the following disclaimer.
18+ *
19+ * - Redistributions in binary form must reproduce the above copyright
20+ * notice, this list of conditions and the following disclaimer in
21+ * the documentation and/or other materials provided with the distribution.
22+ *
23+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 *
2035 * Contact Information:
2136 * linux-drivers@emulex.com
@@ -23,7 +38,7 @@ · 1 unmodified line
2338 * Emulex
2439 * 3333 Susan Street
2540 * Costa Mesa, CA 92626
26− *******************************************************************/
41+ */
2742
2843 #include <linux/module.h>
2944 #include <linux/idr.h>
@@ -46,7 +61,7 @@ · 16 unmodified lines
4661 MODULE_VERSION(OCRDMA_ROCE_DRV_VERSION);
4762 MODULE_DESCRIPTION(OCRDMA_ROCE_DRV_DESC " " OCRDMA_ROCE_DRV_VERSION);
4863 MODULE_AUTHOR("Emulex Corporation");
49−MODULE_LICENSE("GPL");
64+MODULE_LICENSE("Dual BSD/GPL");
5065
5166 static LIST_HEAD(ocrdma_dev_list);
5267 static DEFINE_SPINLOCK(ocrdma_devlist_lock);
drivers/infiniband/hw/ocrdma/ocrdma_sli.h+34−19
@@ -1,21 +1,36 @@
1−/*******************************************************************
2− * This file is part of the Emulex RoCE Device Driver for *
3− * RoCE (RDMA over Converged Ethernet) adapters. *
4− * Copyright (C) 2008-2012 Emulex. All rights reserved. *
5− * EMULEX and SLI are trademarks of Emulex. *
6− * www.emulex.com *
7− * *
8− * This program is free software; you can redistribute it and/or *
9− * modify it under the terms of version 2 of the GNU General *
10− * Public License as published by the Free Software Foundation. *
11− * This program is distributed in the hope that it will be useful. *
12− * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13− * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14− * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15− * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16− * TO BE LEGALLY INVALID. See the GNU General Public License for *
17− * more details, a copy of which can be found in the file COPYING *
18− * included with this package. *
1+/* This file is part of the Emulex RoCE Device Driver for
2+ * RoCE (RDMA over Converged Ethernet) adapters.
3+ * Copyright (C) 2012-2015 Emulex. All rights reserved.
4+ * EMULEX and SLI are trademarks of Emulex.
5+ * www.emulex.com
6+ *
7+ * This software is available to you under a choice of one of two licenses.
8+ * You may choose to be licensed under the terms of the GNU General Public
9+ * License (GPL) Version 2, available from the file COPYING in the main
10+ * directory of this source tree, or the BSD license below:
11+ *
12+ * Redistribution and use in source and binary forms, with or without
13+ * modification, are permitted provided that the following conditions
14+ * are met:
15+ *
16+ * - Redistributions of source code must retain the above copyright notice,
17+ * this list of conditions and the following disclaimer.
18+ *
19+ * - Redistributions in binary form must reproduce the above copyright
20+ * notice, this list of conditions and the following disclaimer in
21+ * the documentation and/or other materials provided with the distribution.
22+ *
23+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 *
2035 * Contact Information:
2136 * linux-drivers@emulex.com
@@ -23,7 +38,7 @@ · 1 unmodified line
2338 * Emulex
2439 * 3333 Susan Street
2540 * Costa Mesa, CA 92626
26− *******************************************************************/
41+ */
2742
2843 #ifndef __OCRDMA_SLI_H__
2944 #define __OCRDMA_SLI_H__
drivers/infiniband/hw/ocrdma/ocrdma_stats.c+34−19
@@ -1,21 +1,36 @@
1−/*******************************************************************
2− * This file is part of the Emulex RoCE Device Driver for *
3− * RoCE (RDMA over Converged Ethernet) adapters. *
4− * Copyright (C) 2008-2014 Emulex. All rights reserved. *
5− * EMULEX and SLI are trademarks of Emulex. *
6− * www.emulex.com *
7− * *
8− * This program is free software; you can redistribute it and/or *
9− * modify it under the terms of version 2 of the GNU General *
10− * Public License as published by the Free Software Foundation. *
11− * This program is distributed in the hope that it will be useful. *
12− * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13− * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14− * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15− * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16− * TO BE LEGALLY INVALID. See the GNU General Public License for *
17− * more details, a copy of which can be found in the file COPYING *
18− * included with this package. *
1+/* This file is part of the Emulex RoCE Device Driver for
2+ * RoCE (RDMA over Converged Ethernet) adapters.
3+ * Copyright (C) 2012-2015 Emulex. All rights reserved.
4+ * EMULEX and SLI are trademarks of Emulex.
5+ * www.emulex.com
6+ *
7+ * This software is available to you under a choice of one of two licenses.
8+ * You may choose to be licensed under the terms of the GNU General Public
9+ * License (GPL) Version 2, available from the file COPYING in the main
10+ * directory of this source tree, or the BSD license below:
11+ *
12+ * Redistribution and use in source and binary forms, with or without
13+ * modification, are permitted provided that the following conditions
14+ * are met:
15+ *
16+ * - Redistributions of source code must retain the above copyright notice,
17+ * this list of conditions and the following disclaimer.
18+ *
19+ * - Redistributions in binary form must reproduce the above copyright
20+ * notice, this list of conditions and the following disclaimer in
21+ * the documentation and/or other materials provided with the distribution.
22+ *
23+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 *
2035 * Contact Information:
2136 * linux-drivers@emulex.com
@@ -23,7 +38,7 @@ · 1 unmodified line
2338 * Emulex
2439 * 3333 Susan Street
2540 * Costa Mesa, CA 92626
26− *******************************************************************/
41+ */
2742
2843 #include <rdma/ib_addr.h>
2944 #include <rdma/ib_pma.h>
drivers/infiniband/hw/ocrdma/ocrdma_stats.h+34−19
@@ -1,21 +1,36 @@
1−/*******************************************************************
2− * This file is part of the Emulex RoCE Device Driver for *
3− * RoCE (RDMA over Converged Ethernet) adapters. *
4− * Copyright (C) 2008-2014 Emulex. All rights reserved. *
5− * EMULEX and SLI are trademarks of Emulex. *
6− * www.emulex.com *
7− * *
8− * This program is free software; you can redistribute it and/or *
9− * modify it under the terms of version 2 of the GNU General *
10− * Public License as published by the Free Software Foundation. *
11− * This program is distributed in the hope that it will be useful. *
12− * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13− * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14− * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15− * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16− * TO BE LEGALLY INVALID. See the GNU General Public License for *
17− * more details, a copy of which can be found in the file COPYING *
18− * included with this package. *
1+/* This file is part of the Emulex RoCE Device Driver for
2+ * RoCE (RDMA over Converged Ethernet) adapters.
3+ * Copyright (C) 2012-2015 Emulex. All rights reserved.
4+ * EMULEX and SLI are trademarks of Emulex.
5+ * www.emulex.com
6+ *
7+ * This software is available to you under a choice of one of two licenses.
8+ * You may choose to be licensed under the terms of the GNU General Public
9+ * License (GPL) Version 2, available from the file COPYING in the main
10+ * directory of this source tree, or the BSD license below:
11+ *
12+ * Redistribution and use in source and binary forms, with or without
13+ * modification, are permitted provided that the following conditions
14+ * are met:
15+ *
16+ * - Redistributions of source code must retain the above copyright notice,
17+ * this list of conditions and the following disclaimer.
18+ *
19+ * - Redistributions in binary form must reproduce the above copyright
20+ * notice, this list of conditions and the following disclaimer in
21+ * the documentation and/or other materials provided with the distribution.
22+ *
23+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 *
2035 * Contact Information:
2136 * linux-drivers@emulex.com
@@ -23,7 +38,7 @@ · 1 unmodified line
2338 * Emulex
2439 * 3333 Susan Street
2540 * Costa Mesa, CA 92626
26− *******************************************************************/
41+ */
2742
2843 #ifndef __OCRDMA_STATS_H__
2944 #define __OCRDMA_STATS_H__
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c+34−19
@@ -1,21 +1,36 @@
1−/*******************************************************************
2− * This file is part of the Emulex RoCE Device Driver for *
3− * RoCE (RDMA over Converged Ethernet) adapters. *
4− * Copyright (C) 2008-2012 Emulex. All rights reserved. *
5− * EMULEX and SLI are trademarks of Emulex. *
6− * www.emulex.com *
7− * *
8− * This program is free software; you can redistribute it and/or *
9− * modify it under the terms of version 2 of the GNU General *
10− * Public License as published by the Free Software Foundation. *
11− * This program is distributed in the hope that it will be useful. *
12− * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13− * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14− * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15− * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16− * TO BE LEGALLY INVALID. See the GNU General Public License for *
17− * more details, a copy of which can be found in the file COPYING *
18− * included with this package. *
1+/* This file is part of the Emulex RoCE Device Driver for
2+ * RoCE (RDMA over Converged Ethernet) adapters.
3+ * Copyright (C) 2012-2015 Emulex. All rights reserved.
4+ * EMULEX and SLI are trademarks of Emulex.
5+ * www.emulex.com
6+ *
7+ * This software is available to you under a choice of one of two licenses.
8+ * You may choose to be licensed under the terms of the GNU General Public
9+ * License (GPL) Version 2, available from the file COPYING in the main
10+ * directory of this source tree, or the BSD license below:
11+ *
12+ * Redistribution and use in source and binary forms, with or without
13+ * modification, are permitted provided that the following conditions
14+ * are met:
15+ *
16+ * - Redistributions of source code must retain the above copyright notice,
17+ * this list of conditions and the following disclaimer.
18+ *
19+ * - Redistributions in binary form must reproduce the above copyright
20+ * notice, this list of conditions and the following disclaimer in
21+ * the documentation and/or other materials provided with the distribution.
22+ *
23+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 *
2035 * Contact Information:
2136 * linux-drivers@emulex.com
@@ -23,7 +38,7 @@ · 1 unmodified line
2338 * Emulex
2439 * 3333 Susan Street
2540 * Costa Mesa, CA 92626
26− *******************************************************************/
41+ */
2742
2843 #include <linux/dma-mapping.h>
2944 #include <rdma/ib_verbs.h>
drivers/infiniband/hw/ocrdma/ocrdma_verbs.h+34−19
@@ -1,21 +1,36 @@
1−/*******************************************************************
2− * This file is part of the Emulex RoCE Device Driver for *
3− * RoCE (RDMA over Converged Ethernet) adapters. *
4− * Copyright (C) 2008-2012 Emulex. All rights reserved. *
5− * EMULEX and SLI are trademarks of Emulex. *
6− * www.emulex.com *
7− * *
8− * This program is free software; you can redistribute it and/or *
9− * modify it under the terms of version 2 of the GNU General *
10− * Public License as published by the Free Software Foundation. *
11− * This program is distributed in the hope that it will be useful. *
12− * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13− * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14− * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15− * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16− * TO BE LEGALLY INVALID. See the GNU General Public License for *
17− * more details, a copy of which can be found in the file COPYING *
18− * included with this package. *
1+/* This file is part of the Emulex RoCE Device Driver for
2+ * RoCE (RDMA over Converged Ethernet) adapters.
3+ * Copyright (C) 2012-2015 Emulex. All rights reserved.
4+ * EMULEX and SLI are trademarks of Emulex.
5+ * www.emulex.com
6+ *
7+ * This software is available to you under a choice of one of two licenses.
8+ * You may choose to be licensed under the terms of the GNU General Public
9+ * License (GPL) Version 2, available from the file COPYING in the main
10+ * directory of this source tree, or the BSD license below:
11+ *
12+ * Redistribution and use in source and binary forms, with or without
13+ * modification, are permitted provided that the following conditions
14+ * are met:
15+ *
16+ * - Redistributions of source code must retain the above copyright notice,
17+ * this list of conditions and the following disclaimer.
18+ *
19+ * - Redistributions in binary form must reproduce the above copyright
20+ * notice, this list of conditions and the following disclaimer in
21+ * the documentation and/or other materials provided with the distribution.
22+ *
23+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
25+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 *
2035 * Contact Information:
2136 * linux-drivers@emulex.com
@@ -23,7 +38,7 @@ · 1 unmodified line
2338 * Emulex
2439 * 3333 Susan Street
2540 * Costa Mesa, CA 92626
26− *******************************************************************/
41+ */
2742
2843 #ifndef __OCRDMA_VERBS_H__
2944 #define __OCRDMA_VERBS_H__
drivers/infiniband/ulp/ipoib/ipoib_verbs.c+2−1
@@ -177,7 +177,8 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca) · 176 unmodified lines
177177 else
178178 size += ipoib_recvq_size * ipoib_max_conn_qp;
179179 } else
180− goto out_free_wq;
180+ if (ret != -ENOSYS)
181+ goto out_free_wq;
181182
182183 cq_attr.cqe = size;
183184 priv->recv_cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL,
drivers/infiniband/ulp/isert/ib_isert.c+11−5
@@ -775,6 +775,17 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) · 774 unmodified lines
775775 ret = isert_rdma_post_recvl(isert_conn);
776776 if (ret)
777777 goto out_conn_dev;
778+ /*
779+ * Obtain the second reference now before isert_rdma_accept() to
780+ * ensure that any initiator generated REJECT CM event that occurs
781+ * asynchronously won't drop the last reference until the error path
782+ * in iscsi_target_login_sess_out() does it's ->iscsit_free_conn() ->
783+ * isert_free_conn() -> isert_put_conn() -> kref_put().
784+ */
785+ if (!kref_get_unless_zero(&isert_conn->kref)) {
786+ isert_warn("conn %p connect_release is running\n", isert_conn);
787+ goto out_conn_dev;
788+ }
778789
779790 ret = isert_rdma_accept(isert_conn);
780791 if (ret)
@@ -836,11 +847,6 @@ isert_connected_handler(struct rdma_cm_id *cma_id) · 55 unmodified lines
836847
837848 isert_info("conn %p\n", isert_conn);
838849
839− if (!kref_get_unless_zero(&isert_conn->kref)) {
840− isert_warn("conn %p connect_release is running\n", isert_conn);
841− return;
842− }
843−
844850 mutex_lock(&isert_conn->mutex);
845851 if (isert_conn->state != ISER_CONN_FULL_FEATURE)
846852 isert_conn->state = ISER_CONN_UP;
drivers/input/joystick/turbografx.c+1−1
@@ -196,7 +196,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) · 195 unmodified lines
196196 if (n_buttons[i] < 1)
197197 continue;
198198
199− if (n_buttons[i] > 6) {
199+ if (n_buttons[i] > ARRAY_SIZE(tgfx_buttons)) {
200200 printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]);
201201 err = -EINVAL;
202202 goto err_unreg_devs;
drivers/input/misc/axp20x-pek.c+1−0
@@ -292,3 +292,4 @@ module_platform_driver(axp20x_pek_driver); · 291 unmodified lines
292292 MODULE_DESCRIPTION("axp20x Power Button");
293293 MODULE_AUTHOR("Carlo Caione <carlo@caione.org>");
294294 MODULE_LICENSE("GPL");
295+MODULE_ALIAS("platform:axp20x-pek");
drivers/input/misc/twl4030-vibra.c+2−1
@@ -183,7 +183,8 @@ static bool twl4030_vibra_check_coexist(struct twl4030_vibra_data *pdata, · 182 unmodified lines
183183 if (pdata && pdata->coexist)
184184 return true;
185185
186− if (of_find_node_by_name(node, "codec")) {
186+ node = of_find_node_by_name(node, "codec");
187+ if (node) {
187188 of_node_put(node);
188189 return true;
189190 }
drivers/input/mouse/alps.c+6−2
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 #include <linux/input/mt.h>
2121 #include <linux/serio.h>
2222 #include <linux/libps2.h>
23+#include <linux/dmi.h>
2324
2425 #include "psmouse.h"
2526 #include "alps.h"
@@ -99,6 +100,7 @@ static const struct alps_nibble_commands alps_v6_nibble_commands[] = { · 73 unmodified lines
99100 #define ALPS_FOUR_BUTTONS 0x40 /* 4 direction button present */
100101 #define ALPS_PS2_INTERLEAVED 0x80 /* 3-byte PS/2 packet interleaved with
101102 6-byte ALPS packet */
103+#define ALPS_DELL 0x100 /* device is a Dell laptop */
102104 #define ALPS_BUTTONPAD 0x200 /* device is a clickpad */
103105
104106 static const struct alps_model_info alps_model_data[] = {
@@ -251,9 +253,9 @@ static void alps_process_packet_v1_v2(struct psmouse *psmouse) · 146 unmodified lines
251253 return;
252254 }
253255
254− /* Non interleaved V2 dualpoint has separate stick button bits */
256+ /* Dell non interleaved V2 dualpoint has separate stick button bits */
255257 if (priv->proto_version == ALPS_PROTO_V2 &&
256− priv->flags == (ALPS_PASS | ALPS_DUALPOINT)) {
258+ priv->flags == (ALPS_DELL | ALPS_PASS | ALPS_DUALPOINT)) {
257259 left |= packet[0] & 1;
258260 right |= packet[0] & 2;
259261 middle |= packet[0] & 4;
@@ -2550,6 +2552,8 @@ static int alps_set_protocol(struct psmouse *psmouse, · 2290 unmodified lines
25502552 priv->byte0 = protocol->byte0;
25512553 priv->mask0 = protocol->mask0;
25522554 priv->flags = protocol->flags;
2555+ if (dmi_name_in_vendors("Dell"))
2556+ priv->flags |= ALPS_DELL;
25532557
25542558 priv->x_max = 2000;
25552559 priv->y_max = 1400;
drivers/input/mouse/bcm5974.c+112−53
@@ -2,6 +2,7 @@ · 1 unmodified line
22 * Apple USB BCM5974 (Macbook Air and Penryn Macbook Pro) multitouch driver
33 *
44 * Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se)
5+ * Copyright (C) 2015 John Horan (knasher@gmail.com)
56 *
67 * The USB initialization and package decoding was made by
78 * Scott Shawcroft as part of the touchd user-space driver project:
@@ -91,6 +92,10 @@ · 83 unmodified lines
9192 #define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290
9293 #define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291
9394 #define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292
95+/* MacbookPro12,1 (2015) */
96+#define USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI 0x0272
97+#define USB_DEVICE_ID_APPLE_WELLSPRING9_ISO 0x0273
98+#define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS 0x0274
9499
95100 #define BCM5974_DEVICE(prod) { \
96101 .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
@@ -152,6 +157,10 @@ static const struct usb_device_id bcm5974_table[] = { · 55 unmodified lines
152157 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI),
153158 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING8_ISO),
154159 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
160+ /* MacbookPro12,1 */
161+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI),
162+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_ISO),
163+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
155164 /* Terminating entry */
156165 {}
157166 };
@@ -180,21 +189,47 @@ struct bt_data { · 22 unmodified lines
180189 enum tp_type {
181190 TYPE1, /* plain trackpad */
182191 TYPE2, /* button integrated in trackpad */
183− TYPE3 /* additional header fields since June 2013 */
192+ TYPE3, /* additional header fields since June 2013 */
193+ TYPE4 /* additional header field for pressure data */
184194 };
185195
186196 /* trackpad finger data offsets, le16-aligned */
187−#define FINGER_TYPE1 (13 * sizeof(__le16))
188−#define FINGER_TYPE2 (15 * sizeof(__le16))
189−#define FINGER_TYPE3 (19 * sizeof(__le16))
197+#define HEADER_TYPE1 (13 * sizeof(__le16))
198+#define HEADER_TYPE2 (15 * sizeof(__le16))
199+#define HEADER_TYPE3 (19 * sizeof(__le16))
200+#define HEADER_TYPE4 (23 * sizeof(__le16))
190201
191202 /* trackpad button data offsets */
203+#define BUTTON_TYPE1 0
192204 #define BUTTON_TYPE2 15
193205 #define BUTTON_TYPE3 23
206+#define BUTTON_TYPE4 31
194207
195208 /* list of device capability bits */
196209 #define HAS_INTEGRATED_BUTTON 1
197210
211+/* trackpad finger data block size */
212+#define FSIZE_TYPE1 (14 * sizeof(__le16))
213+#define FSIZE_TYPE2 (14 * sizeof(__le16))
214+#define FSIZE_TYPE3 (14 * sizeof(__le16))
215+#define FSIZE_TYPE4 (15 * sizeof(__le16))
216+
217+/* offset from header to finger struct */
218+#define DELTA_TYPE1 (0 * sizeof(__le16))
219+#define DELTA_TYPE2 (0 * sizeof(__le16))
220+#define DELTA_TYPE3 (0 * sizeof(__le16))
221+#define DELTA_TYPE4 (1 * sizeof(__le16))
222+
223+/* usb control message mode switch data */
224+#define USBMSG_TYPE1 8, 0x300, 0, 0, 0x1, 0x8
225+#define USBMSG_TYPE2 8, 0x300, 0, 0, 0x1, 0x8
226+#define USBMSG_TYPE3 8, 0x300, 0, 0, 0x1, 0x8
227+#define USBMSG_TYPE4 2, 0x302, 2, 1, 0x1, 0x0
228+
229+/* Wellspring initialization constants */
230+#define BCM5974_WELLSPRING_MODE_READ_REQUEST_ID 1
231+#define BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID 9
232+
198233 /* trackpad finger structure, le16-aligned */
199234 struct tp_finger {
200235 __le16 origin; /* zero when switching track finger */
@@ -207,14 +242,13 @@ struct tp_finger { · 6 unmodified lines
207242 __le16 orientation; /* 16384 when point, else 15 bit angle */
208243 __le16 touch_major; /* touch area, major axis */
209244 __le16 touch_minor; /* touch area, minor axis */
210− __le16 unused[3]; /* zeros */
245+ __le16 unused[2]; /* zeros */
246+ __le16 pressure; /* pressure on forcetouch touchpad */
211247 __le16 multi; /* one finger: varies, more fingers: constant */
212248 } __attribute__((packed,aligned(2)));
213249
214250 /* trackpad finger data size, empirically at least ten fingers */
215251 #define MAX_FINGERS 16
216−#define SIZEOF_FINGER sizeof(struct tp_finger)
217−#define SIZEOF_ALL_FINGERS (MAX_FINGERS * SIZEOF_FINGER)
218252 #define MAX_FINGER_ORIENTATION 16384
219253
220254 /* device-specific parameters */
@@ -232,8 +266,17 @@ struct bcm5974_config { · 11 unmodified lines
232266 int bt_datalen; /* data length of the button interface */
233267 int tp_ep; /* the endpoint of the trackpad interface */
234268 enum tp_type tp_type; /* type of trackpad interface */
235− int tp_offset; /* offset to trackpad finger data */
269+ int tp_header; /* bytes in header block */
236270 int tp_datalen; /* data length of the trackpad interface */
271+ int tp_button; /* offset to button data */
272+ int tp_fsize; /* bytes in single finger block */
273+ int tp_delta; /* offset from header to finger struct */
274+ int um_size; /* usb control message length */
275+ int um_req_val; /* usb control message value */
276+ int um_req_idx; /* usb control message index */
277+ int um_switch_idx; /* usb control message mode switch index */
278+ int um_switch_on; /* usb control message mode switch on */
279+ int um_switch_off; /* usb control message mode switch off */
237280 struct bcm5974_param p; /* finger pressure limits */
238281 struct bcm5974_param w; /* finger width limits */
239282 struct bcm5974_param x; /* horizontal limits */
@@ -259,6 +302,24 @@ struct bcm5974 { · 19 unmodified lines
259302 int slots[MAX_FINGERS]; /* slot assignments */
260303 };
261304
305+/* trackpad finger block data, le16-aligned */
306+static const struct tp_finger *get_tp_finger(const struct bcm5974 *dev, int i)
307+{
308+ const struct bcm5974_config *c = &dev->cfg;
309+ u8 *f_base = dev->tp_data + c->tp_header + c->tp_delta;
310+
311+ return (const struct tp_finger *)(f_base + i * c->tp_fsize);
312+}
313+
314+#define DATAFORMAT(type) \
315+ type, \
316+ HEADER_##type, \
317+ HEADER_##type + (MAX_FINGERS) * (FSIZE_##type), \
318+ BUTTON_##type, \
319+ FSIZE_##type, \
320+ DELTA_##type, \
321+ USBMSG_##type
322+
262323 /* logical signal quality */
263324 #define SN_PRESSURE 45 /* pressure signal-to-noise ratio */
264325 #define SN_WIDTH 25 /* width signal-to-noise ratio */
@@ -273,7 +334,7 @@ static const struct bcm5974_config bcm5974_config_table[] = { · 8 unmodified lines
273334 USB_DEVICE_ID_APPLE_WELLSPRING_JIS,
274335 0,
275336 0x84, sizeof(struct bt_data),
276− 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS,
337+ 0x81, DATAFORMAT(TYPE1),
277338 { SN_PRESSURE, 0, 256 },
278339 { SN_WIDTH, 0, 2048 },
279340 { SN_COORD, -4824, 5342 },
@@ -286,7 +347,7 @@ static const struct bcm5974_config bcm5974_config_table[] = { · 6 unmodified lines
286347 USB_DEVICE_ID_APPLE_WELLSPRING2_JIS,
287348 0,
288349 0x84, sizeof(struct bt_data),
289− 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS,
350+ 0x81, DATAFORMAT(TYPE1),
290351 { SN_PRESSURE, 0, 256 },
291352 { SN_WIDTH, 0, 2048 },
292353 { SN_COORD, -4824, 4824 },
@@ -299,7 +360,7 @@ static const struct bcm5974_config bcm5974_config_table[] = { · 6 unmodified lines
299360 USB_DEVICE_ID_APPLE_WELLSPRING3_JIS,
300361 HAS_INTEGRATED_BUTTON,
301362 0x84, sizeof(struct bt_data),
302− 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
363+ 0x81, DATAFORMAT(TYPE2),
303364 { SN_PRESSURE, 0, 300 },
304365 { SN_WIDTH, 0, 2048 },
305366 { SN_COORD, -4460, 5166 },
@@ -312,7 +373,7 @@ static const struct bcm5974_config bcm5974_config_table[] = { · 6 unmodified lines
312373 USB_DEVICE_ID_APPLE_WELLSPRING4_JIS,
313374 HAS_INTEGRATED_BUTTON,
314375 0x84, sizeof(struct bt_data),
315− 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
376+ 0x81, DATAFORMAT(TYPE2),
316377 { SN_PRESSURE, 0, 300 },
317378 { SN_WIDTH, 0, 2048 },
318379 { SN_COORD, -4620, 5140 },
@@ -325,7 +386,7 @@ static const struct bcm5974_config bcm5974_config_table[] = { · 6 unmodified lines
325386 USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS,
326387 HAS_INTEGRATED_BUTTON,
327388 0x84, sizeof(struct bt_data),
328− 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
389+ 0x81, DATAFORMAT(TYPE2),
329390 { SN_PRESSURE, 0, 300 },
330391 { SN_WIDTH, 0, 2048 },
331392 { SN_COORD, -4616, 5112 },
@@ -338,7 +399,7 @@ static const struct bcm5974_config bcm5974_config_table[] = { · 6 unmodified lines
338399 USB_DEVICE_ID_APPLE_WELLSPRING5_JIS,
339400 HAS_INTEGRATED_BUTTON,
340401 0x84, sizeof(struct bt_data),
341− 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
402+ 0x81, DATAFORMAT(TYPE2),
342403 { SN_PRESSURE, 0, 300 },
343404 { SN_WIDTH, 0, 2048 },
344405 { SN_COORD, -4415, 5050 },
@@ -351,7 +412,7 @@ static const struct bcm5974_config bcm5974_config_table[] = { · 6 unmodified lines
351412 USB_DEVICE_ID_APPLE_WELLSPRING6_JIS,
352413 HAS_INTEGRATED_BUTTON,
353414 0x84, sizeof(struct bt_data),
354− 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
415+ 0x81, DATAFORMAT(TYPE2),
355416 { SN_PRESSURE, 0, 300 },
356417 { SN_WIDTH, 0, 2048 },
357418 { SN_COORD, -4620, 5140 },
@@ -364,7 +425,7 @@ static const struct bcm5974_config bcm5974_config_table[] = { · 6 unmodified lines
364425 USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS,
365426 HAS_INTEGRATED_BUTTON,
366427 0x84, sizeof(struct bt_data),
367− 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
428+ 0x81, DATAFORMAT(TYPE2),
368429 { SN_PRESSURE, 0, 300 },
369430 { SN_WIDTH, 0, 2048 },
370431 { SN_COORD, -4750, 5280 },
@@ -377,7 +438,7 @@ static const struct bcm5974_config bcm5974_config_table[] = { · 6 unmodified lines
377438 USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS,
378439 HAS_INTEGRATED_BUTTON,
379440 0x84, sizeof(struct bt_data),
380− 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
441+ 0x81, DATAFORMAT(TYPE2),
381442 { SN_PRESSURE, 0, 300 },
382443 { SN_WIDTH, 0, 2048 },
383444 { SN_COORD, -4620, 5140 },
@@ -390,7 +451,7 @@ static const struct bcm5974_config bcm5974_config_table[] = { · 6 unmodified lines
390451 USB_DEVICE_ID_APPLE_WELLSPRING7_JIS,
391452 HAS_INTEGRATED_BUTTON,
392453 0x84, sizeof(struct bt_data),
393− 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
454+ 0x81, DATAFORMAT(TYPE2),
394455 { SN_PRESSURE, 0, 300 },
395456 { SN_WIDTH, 0, 2048 },
396457 { SN_COORD, -4750, 5280 },
@@ -403,7 +464,7 @@ static const struct bcm5974_config bcm5974_config_table[] = { · 6 unmodified lines
403464 USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS,
404465 HAS_INTEGRATED_BUTTON,
405466 0x84, sizeof(struct bt_data),
406− 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
467+ 0x81, DATAFORMAT(TYPE2),
407468 { SN_PRESSURE, 0, 300 },
408469 { SN_WIDTH, 0, 2048 },
409470 { SN_COORD, -4750, 5280 },
@@ -416,13 +477,26 @@ static const struct bcm5974_config bcm5974_config_table[] = { · 6 unmodified lines
416477 USB_DEVICE_ID_APPLE_WELLSPRING8_JIS,
417478 HAS_INTEGRATED_BUTTON,
418479 0, sizeof(struct bt_data),
419− 0x83, TYPE3, FINGER_TYPE3, FINGER_TYPE3 + SIZEOF_ALL_FINGERS,
480+ 0x83, DATAFORMAT(TYPE3),
420481 { SN_PRESSURE, 0, 300 },
421482 { SN_WIDTH, 0, 2048 },
422483 { SN_COORD, -4620, 5140 },
423484 { SN_COORD, -150, 6600 },
424485 { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
425486 },
487+ {
488+ USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI,
489+ USB_DEVICE_ID_APPLE_WELLSPRING9_ISO,
490+ USB_DEVICE_ID_APPLE_WELLSPRING9_JIS,
491+ HAS_INTEGRATED_BUTTON,
492+ 0, sizeof(struct bt_data),
493+ 0x83, DATAFORMAT(TYPE4),
494+ { SN_PRESSURE, 0, 300 },
495+ { SN_WIDTH, 0, 2048 },
496+ { SN_COORD, -4828, 5345 },
497+ { SN_COORD, -203, 6803 },
498+ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
499+ },
426500 {}
427501 };
428502
@@ -549,19 +623,18 @@ static int report_tp_state(struct bcm5974 *dev, int size) · 120 unmodified lines
549623 struct input_dev *input = dev->input;
550624 int raw_n, i, n = 0;
551625
552− if (size < c->tp_offset || (size - c->tp_offset) % SIZEOF_FINGER != 0)
626+ if (size < c->tp_header || (size - c->tp_header) % c->tp_fsize != 0)
553627 return -EIO;
554628
555− /* finger data, le16-aligned */
556− f = (const struct tp_finger *)(dev->tp_data + c->tp_offset);
557− raw_n = (size - c->tp_offset) / SIZEOF_FINGER;
629+ raw_n = (size - c->tp_header) / c->tp_fsize;
558630
559631 for (i = 0; i < raw_n; i++) {
560− if (raw2int(f[i].touch_major) == 0)
632+ f = get_tp_finger(dev, i);
633+ if (raw2int(f->touch_major) == 0)
561634 continue;
562− dev->pos[n].x = raw2int(f[i].abs_x);
563− dev->pos[n].y = c->y.min + c->y.max - raw2int(f[i].abs_y);
564− dev->index[n++] = &f[i];
635+ dev->pos[n].x = raw2int(f->abs_x);
636+ dev->pos[n].y = c->y.min + c->y.max - raw2int(f->abs_y);
637+ dev->index[n++] = f;
565638 }
566639
567640 input_mt_assign_slots(input, dev->slots, dev->pos, n, 0);
@@ -572,32 +645,22 @@ static int report_tp_state(struct bcm5974 *dev, int size) · 4 unmodified lines
572645
573646 input_mt_sync_frame(input);
574647
575− report_synaptics_data(input, c, f, raw_n);
648+ report_synaptics_data(input, c, get_tp_finger(dev, 0), raw_n);
576649
577− /* type 2 reports button events via ibt only */
578− if (c->tp_type == TYPE2) {
579− int ibt = raw2int(dev->tp_data[BUTTON_TYPE2]);
650+ /* later types report button events via integrated button only */
651+ if (c->caps & HAS_INTEGRATED_BUTTON) {
652+ int ibt = raw2int(dev->tp_data[c->tp_button]);
580653 input_report_key(input, BTN_LEFT, ibt);
581654 }
582655
583− if (c->tp_type == TYPE3)
584− input_report_key(input, BTN_LEFT, dev->tp_data[BUTTON_TYPE3]);
585−
586656 input_sync(input);
587657
588658 return 0;
589659 }
590660
591−/* Wellspring initialization constants */
592−#define BCM5974_WELLSPRING_MODE_READ_REQUEST_ID 1
593−#define BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID 9
594−#define BCM5974_WELLSPRING_MODE_REQUEST_VALUE 0x300
595−#define BCM5974_WELLSPRING_MODE_REQUEST_INDEX 0
596−#define BCM5974_WELLSPRING_MODE_VENDOR_VALUE 0x01
597−#define BCM5974_WELLSPRING_MODE_NORMAL_VALUE 0x08
598−
599661 static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on)
600662 {
663+ const struct bcm5974_config *c = &dev->cfg;
601664 int retval = 0, size;
602665 char *data;
603666
@@ -605,7 +668,7 @@ static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on) · 1 unmodified line
605668 if (dev->cfg.tp_type == TYPE3)
606669 return 0;
607670
608− data = kmalloc(8, GFP_KERNEL);
671+ data = kmalloc(c->um_size, GFP_KERNEL);
609672 if (!data) {
610673 dev_err(&dev->intf->dev, "out of memory\n");
611674 retval = -ENOMEM;
@@ -616,28 +679,24 @@ static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on) · 4 unmodified lines
616679 size = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
617680 BCM5974_WELLSPRING_MODE_READ_REQUEST_ID,
618681 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
619− BCM5974_WELLSPRING_MODE_REQUEST_VALUE,
620− BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000);
682+ c->um_req_val, c->um_req_idx, data, c->um_size, 5000);
621683
622− if (size != 8) {
684+ if (size != c->um_size) {
623685 dev_err(&dev->intf->dev, "could not read from device\n");
624686 retval = -EIO;
625687 goto out;
626688 }
627689
628690 /* apply the mode switch */
629− data[0] = on ?
630− BCM5974_WELLSPRING_MODE_VENDOR_VALUE :
631− BCM5974_WELLSPRING_MODE_NORMAL_VALUE;
691+ data[c->um_switch_idx] = on ? c->um_switch_on : c->um_switch_off;
632692
633693 /* write configuration */
634694 size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
635695 BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID,
636696 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
637− BCM5974_WELLSPRING_MODE_REQUEST_VALUE,
638− BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000);
697+ c->um_req_val, c->um_req_idx, data, c->um_size, 5000);
639698
640− if (size != 8) {
699+ if (size != c->um_size) {
641700 dev_err(&dev->intf->dev, "could not write to device\n");
642701 retval = -EIO;
643702 goto out;
drivers/input/mouse/elantech.c+20−2
@@ -783,19 +783,26 @@ static int elantech_packet_check_v4(struct psmouse *psmouse) · 782 unmodified lines
783783 struct elantech_data *etd = psmouse->private;
784784 unsigned char *packet = psmouse->packet;
785785 unsigned char packet_type = packet[3] & 0x03;
786+ unsigned int ic_version;
786787 bool sanity_check;
787788
788789 if (etd->tp_dev && (packet[3] & 0x0f) == 0x06)
789790 return PACKET_TRACKPOINT;
790791
792+ /* This represents the version of IC body. */
793+ ic_version = (etd->fw_version & 0x0f0000) >> 16;
794+
791795 /*
792796 * Sanity check based on the constant bits of a packet.
793797 * The constant bits change depending on the value of
794− * the hardware flag 'crc_enabled' but are the same for
795− * every packet, regardless of the type.
798+ * the hardware flag 'crc_enabled' and the version of
799+ * the IC body, but are the same for every packet,
800+ * regardless of the type.
796801 */
797802 if (etd->crc_enabled)
798803 sanity_check = ((packet[3] & 0x08) == 0x00);
804+ else if (ic_version == 7 && etd->samples[1] == 0x2A)
805+ sanity_check = ((packet[3] & 0x1c) == 0x10);
799806 else
800807 sanity_check = ((packet[0] & 0x0c) == 0x04 &&
801808 (packet[3] & 0x1c) == 0x10);
@@ -1116,6 +1123,7 @@ static int elantech_get_resolution_v4(struct psmouse *psmouse, · 314 unmodified lines
11161123 * Avatar AVIU-145A2 0x361f00 ? clickpad
11171124 * Fujitsu LIFEBOOK E544 0x470f00 d0, 12, 09 2 hw buttons
11181125 * Fujitsu LIFEBOOK E554 0x570f01 40, 14, 0c 2 hw buttons
1126+ * Fujitsu T725 0x470f01 05, 12, 09 2 hw buttons
11191127 * Fujitsu H730 0x570f00 c0, 14, 0c 3 hw buttons (**)
11201128 * Gigabyte U2442 0x450f01 58, 17, 0c 2 hw buttons
11211129 * Lenovo L430 0x350f02 b9, 15, 0c 2 hw buttons (*)
@@ -1651,6 +1659,16 @@ int elantech_init(struct psmouse *psmouse) · 529 unmodified lines
16511659 etd->capabilities[0], etd->capabilities[1],
16521660 etd->capabilities[2]);
16531661
1662+ if (etd->hw_version != 1) {
1663+ if (etd->send_cmd(psmouse, ETP_SAMPLE_QUERY, etd->samples)) {
1664+ psmouse_err(psmouse, "failed to query sample data\n");
1665+ goto init_fail;
1666+ }
1667+ psmouse_info(psmouse,
1668+ "Elan sample query result %02x, %02x, %02x\n",
1669+ etd->samples[0], etd->samples[1], etd->samples[2]);
1670+ }
1671+
16541672 if (elantech_set_absolute_mode(psmouse)) {
16551673 psmouse_err(psmouse,
16561674 "failed to put touchpad into absolute mode.\n");
drivers/input/mouse/elantech.h+1−0
@@ -129,6 +129,7 @@ struct elantech_data { · 128 unmodified lines
129129 unsigned char reg_26;
130130 unsigned char debug;
131131 unsigned char capabilities[3];
132+ unsigned char samples[3];
132133 bool paritycheck;
133134 bool jumpy_cursor;
134135 bool reports_pressure;
drivers/input/mouse/synaptics.c+2−2
@@ -1484,12 +1484,12 @@ static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode) · 1483 unmodified lines
14841484 priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;
14851485
14861486 psmouse_info(psmouse,
1487− "Touchpad model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx, board id: %lu, fw id: %lu\n",
1487+ "Touchpad model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx/%#lx, board id: %lu, fw id: %lu\n",
14881488 SYN_ID_MODEL(priv->identity),
14891489 SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity),
14901490 priv->model_id,
14911491 priv->capabilities, priv->ext_cap, priv->ext_cap_0c,
1492− priv->board_id, priv->firmware_id);
1492+ priv->ext_cap_10, priv->board_id, priv->firmware_id);
14931493
14941494 set_input_params(psmouse, priv);
14951495
drivers/input/touchscreen/zforce_ts.c+1−1
@@ -429,7 +429,7 @@ static int zforce_read_packet(struct zforce_ts *ts, u8 *buf) · 428 unmodified lines
429429 goto unlock;
430430 }
431431
432− if (buf[PAYLOAD_LENGTH] == 0 || buf[PAYLOAD_LENGTH] > FRAME_MAXSIZE) {
432+ if (buf[PAYLOAD_LENGTH] == 0) {
433433 dev_err(&client->dev, "invalid payload length: %d\n",
434434 buf[PAYLOAD_LENGTH]);
435435 ret = -EIO;
drivers/iommu/amd_iommu.c+29−69
@@ -76,8 +76,6 @@ LIST_HEAD(hpet_map); · 75 unmodified lines
7676 * Domain for untranslated devices - only allocated
7777 * if iommu=pt passed on kernel cmd line.
7878 */
79−static struct protection_domain *pt_domain;
80−
8179 static const struct iommu_ops amd_iommu_ops;
8280
8381 static ATOMIC_NOTIFIER_HEAD(ppr_notifier);
@@ -96,7 +94,7 @@ struct iommu_dev_data { · 12 unmodified lines
9694 struct protection_domain *domain; /* Domain the device is bound to */
9795 u16 devid; /* PCI Device ID */
9896 bool iommu_v2; /* Device can make use of IOMMUv2 */
99− bool passthrough; /* Default for device is pt_domain */
97+ bool passthrough; /* Device is identity mapped */
10098 struct {
10199 bool enabled;
102100 int qdep;
@@ -116,7 +114,6 @@ struct iommu_cmd { · 13 unmodified lines
116114 struct kmem_cache *amd_iommu_irq_cache;
117115
118116 static void update_domain(struct protection_domain *domain);
119−static int alloc_passthrough_domain(void);
120117 static int protection_domain_init(struct protection_domain *domain);
121118
122119 /****************************************************************************
@@ -2167,15 +2164,17 @@ static int attach_device(struct device *dev, · 2044 unmodified lines
21672164 dev_data = get_dev_data(dev);
21682165
21692166 if (domain->flags & PD_IOMMUV2_MASK) {
2170− if (!dev_data->iommu_v2 || !dev_data->passthrough)
2167+ if (!dev_data->passthrough)
21712168 return -EINVAL;
21722169
2173− if (pdev_iommuv2_enable(pdev) != 0)
2174− return -EINVAL;
2170+ if (dev_data->iommu_v2) {
2171+ if (pdev_iommuv2_enable(pdev) != 0)
2172+ return -EINVAL;
21752173
2176− dev_data->ats.enabled = true;
2177− dev_data->ats.qdep = pci_ats_queue_depth(pdev);
2178− dev_data->pri_tlp = pci_pri_tlp_required(pdev);
2174+ dev_data->ats.enabled = true;
2175+ dev_data->ats.qdep = pci_ats_queue_depth(pdev);
2176+ dev_data->pri_tlp = pci_pri_tlp_required(pdev);
2177+ }
21792178 } else if (amd_iommu_iotlb_sup &&
21802179 pci_enable_ats(pdev, PAGE_SHIFT) == 0) {
21812180 dev_data->ats.enabled = true;
@@ -2221,15 +2220,6 @@ static void __detach_device(struct iommu_dev_data *dev_data) · 39 unmodified lines
22212220 do_detach(head);
22222221
22232222 spin_unlock_irqrestore(&domain->lock, flags);
2224−
2225− /*
2226− * If we run in passthrough mode the device must be assigned to the
2227− * passthrough domain if it is detached from any other domain.
2228− * Make sure we can deassign from the pt_domain itself.
2229− */
2230− if (dev_data->passthrough &&
2231− (dev_data->domain == NULL && domain != pt_domain))
2232− __attach_device(dev_data, pt_domain);
22332223 }
22342224
22352225 /*
@@ -2249,7 +2239,7 @@ static void detach_device(struct device *dev) · 13 unmodified lines
22492239 __detach_device(dev_data);
22502240 write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
22512241
2252− if (domain->flags & PD_IOMMUV2_MASK)
2242+ if (domain->flags & PD_IOMMUV2_MASK && dev_data->iommu_v2)
22532243 pdev_iommuv2_disable(to_pci_dev(dev));
22542244 else if (dev_data->ats.enabled)
22552245 pci_disable_ats(to_pci_dev(dev));
@@ -2287,17 +2277,15 @@ static int amd_iommu_add_device(struct device *dev) · 31 unmodified lines
22872277
22882278 BUG_ON(!dev_data);
22892279
2290− if (dev_data->iommu_v2)
2280+ if (iommu_pass_through || dev_data->iommu_v2)
22912281 iommu_request_dm_for_dev(dev);
22922282
22932283 /* Domains are initialized for this device - have a look what we ended up with */
22942284 domain = iommu_get_domain_for_dev(dev);
2295− if (domain->type == IOMMU_DOMAIN_IDENTITY) {
2285+ if (domain->type == IOMMU_DOMAIN_IDENTITY)
22962286 dev_data->passthrough = true;
2297− dev->archdata.dma_ops = &nommu_dma_ops;
2298− } else {
2287+ else
22992288 dev->archdata.dma_ops = &amd_iommu_dma_ops;
2300− }
23012289
23022290 out:
23032291 iommu_completion_wait(iommu);
@@ -2862,8 +2850,17 @@ int __init amd_iommu_init_api(void) · 558 unmodified lines
28622850
28632851 int __init amd_iommu_init_dma_ops(void)
28642852 {
2853+ swiotlb = iommu_pass_through ? 1 : 0;
28652854 iommu_detected = 1;
2866− swiotlb = 0;
2855+
2856+ /*
2857+ * In case we don't initialize SWIOTLB (actually the common case
2858+ * when AMD IOMMU is enabled), make sure there are global
2859+ * dma_ops set as a fall-back for devices not handled by this
2860+ * driver (for example non-PCI devices).
2861+ */
2862+ if (!swiotlb)
2863+ dma_ops = &nommu_dma_ops;
28672864
28682865 amd_iommu_stats_init();
28692866
@@ -2947,21 +2944,6 @@ out_err: · 77 unmodified lines
29472944 return NULL;
29482945 }
29492946
2950−static int alloc_passthrough_domain(void)
2951−{
2952− if (pt_domain != NULL)
2953− return 0;
2954−
2955− /* allocate passthrough domain */
2956− pt_domain = protection_domain_alloc();
2957− if (!pt_domain)
2958− return -ENOMEM;
2959−
2960− pt_domain->mode = PAGE_MODE_NONE;
2961−
2962− return 0;
2963−}
2964−
29652947 static struct iommu_domain *amd_iommu_domain_alloc(unsigned type)
29662948 {
29672949 struct protection_domain *pdomain;
@@ -3222,33 +3204,6 @@ static const struct iommu_ops amd_iommu_ops = { · 254 unmodified lines
32223204 *
32233205 *****************************************************************************/
32243206
3225−int __init amd_iommu_init_passthrough(void)
3226−{
3227− struct iommu_dev_data *dev_data;
3228− struct pci_dev *dev = NULL;
3229− int ret;
3230−
3231− ret = alloc_passthrough_domain();
3232− if (ret)
3233− return ret;
3234−
3235− for_each_pci_dev(dev) {
3236− if (!check_device(&dev->dev))
3237− continue;
3238−
3239− dev_data = get_dev_data(&dev->dev);
3240− dev_data->passthrough = true;
3241−
3242− attach_device(&dev->dev, pt_domain);
3243− }
3244−
3245− amd_iommu_stats_init();
3246−
3247− pr_info("AMD-Vi: Initialized for Passthrough Mode\n");
3248−
3249− return 0;
3250−}
3251−
32523207 /* IOMMUv2 specific functions */
32533208 int amd_iommu_register_ppr_notifier(struct notifier_block *nb)
32543209 {
@@ -3363,7 +3318,12 @@ static int __flush_pasid(struct protection_domain *domain, int pasid, · 108 unmodified lines
33633318 struct amd_iommu *iommu;
33643319 int qdep;
33653320
3366− BUG_ON(!dev_data->ats.enabled);
3321+ /*
3322+ There might be non-IOMMUv2 capable devices in an IOMMUv2
3323+ * domain.
3324+ */
3325+ if (!dev_data->ats.enabled)
3326+ continue;
33673327
33683328 qdep = dev_data->ats.qdep;
33693329 iommu = amd_iommu_rlookup_table[dev_data->devid];
drivers/iommu/amd_iommu_init.c+1−9
@@ -2026,14 +2026,6 @@ static bool detect_ivrs(void) · 2025 unmodified lines
20262026 return true;
20272027 }
20282028
2029−static int amd_iommu_init_dma(void)
2030−{
2031− if (iommu_pass_through)
2032− return amd_iommu_init_passthrough();
2033− else
2034− return amd_iommu_init_dma_ops();
2035−}
2036−
20372029 /****************************************************************************
20382030 *
20392031 * AMD IOMMU Initialization State Machine
@@ -2073,7 +2065,7 @@ static int __init state_next(void) · 33 unmodified lines
20732065 init_state = ret ? IOMMU_INIT_ERROR : IOMMU_INTERRUPTS_EN;
20742066 break;
20752067 case IOMMU_INTERRUPTS_EN:
2076− ret = amd_iommu_init_dma();
2068+ ret = amd_iommu_init_dma_ops();
20772069 init_state = ret ? IOMMU_INIT_ERROR : IOMMU_DMA_OPS;
20782070 break;
20792071 case IOMMU_DMA_OPS:
drivers/iommu/amd_iommu_v2.c+21−3
@@ -132,11 +132,19 @@ static struct device_state *get_device_state(u16 devid) · 131 unmodified lines
132132
133133 static void free_device_state(struct device_state *dev_state)
134134 {
135+ struct iommu_group *group;
136+
135137 /*
136138 * First detach device from domain - No more PRI requests will arrive
137139 * from that device after it is unbound from the IOMMUv2 domain.
138140 */
139− iommu_detach_device(dev_state->domain, &dev_state->pdev->dev);
141+ group = iommu_group_get(&dev_state->pdev->dev);
142+ if (WARN_ON(!group))
143+ return;
144+
145+ iommu_detach_group(dev_state->domain, group);
146+
147+ iommu_group_put(group);
140148
141149 /* Everything is down now, free the IOMMUv2 domain */
142150 iommu_domain_free(dev_state->domain);
@@ -731,6 +739,7 @@ EXPORT_SYMBOL(amd_iommu_unbind_pasid); · 588 unmodified lines
731739 int amd_iommu_init_device(struct pci_dev *pdev, int pasids)
732740 {
733741 struct device_state *dev_state;
742+ struct iommu_group *group;
734743 unsigned long flags;
735744 int ret, tmp;
736745 u16 devid;
@@ -776,10 +785,16 @@ int amd_iommu_init_device(struct pci_dev *pdev, int pasids) · 39 unmodified lines
776785 if (ret)
777786 goto out_free_domain;
778787
779− ret = iommu_attach_device(dev_state->domain, &pdev->dev);
780− if (ret != 0)
788+ group = iommu_group_get(&pdev->dev);
789+ if (!group)
781790 goto out_free_domain;
782791
792+ ret = iommu_attach_group(dev_state->domain, group);
793+ if (ret != 0)
794+ goto out_drop_group;
795+
796+ iommu_group_put(group);
797+
783798 spin_lock_irqsave(&state_lock, flags);
784799
785800 if (__get_device_state(devid) != NULL) {
@@ -794,6 +809,9 @@ int amd_iommu_init_device(struct pci_dev *pdev, int pasids) · 8 unmodified lines
794809
795810 return 0;
796811
812+out_drop_group:
813+ iommu_group_put(group);
814+
797815 out_free_domain:
798816 iommu_domain_free(dev_state->domain);
799817
drivers/irqchip/irq-mips-gic.c+1−1
@@ -538,7 +538,7 @@ static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id) · 537 unmodified lines
538538
539539 static irqreturn_t ipi_call_interrupt(int irq, void *dev_id)
540540 {
541− smp_call_function_interrupt();
541+ generic_smp_call_function_interrupt();
542542
543543 return IRQ_HANDLED;
544544 }
drivers/macintosh/ans-lcd.c+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 #include <linux/kernel.h>
88 #include <linux/miscdevice.h>
99 #include <linux/fcntl.h>
10−#include <linux/init.h>
10+#include <linux/module.h>
1111 #include <linux/delay.h>
1212 #include <linux/fs.h>
1313
drivers/md/Kconfig+1−1
@@ -259,7 +259,7 @@ config DM_CRYPT · 258 unmodified lines
259259 the ciphers you're going to use in the cryptoapi configuration.
260260
261261 For further information on dm-crypt and userspace tools see:
262− <http://code.google.com/p/cryptsetup/wiki/DMCrypt>
262+ <https://gitlab.com/cryptsetup/cryptsetup/wikis/DMCrypt>
263263
264264 To compile this code as a module, choose M here: the module will
265265 be called dm-crypt.
drivers/md/dm-cache-policy-mq.c+0−2
@@ -1471,5 +1471,3 @@ module_exit(mq_exit); · 1470 unmodified lines
14711471 MODULE_AUTHOR("Joe Thornber <dm-devel@redhat.com>");
14721472 MODULE_LICENSE("GPL");
14731473 MODULE_DESCRIPTION("mq cache policy");
1474−
1475−MODULE_ALIAS("dm-cache-default");
drivers/md/dm-cache-policy-smq.c+3−1
@@ -1686,7 +1686,7 @@ static struct dm_cache_policy *smq_create(dm_cblock_t cache_size, · 1685 unmodified lines
16861686
16871687 if (from_cblock(cache_size)) {
16881688 mq->cache_hit_bits = alloc_bitset(from_cblock(cache_size));
1689− if (!mq->cache_hit_bits && mq->cache_hit_bits) {
1689+ if (!mq->cache_hit_bits) {
16901690 DMERR("couldn't allocate cache hit bitset");
16911691 goto bad_cache_hit_bits;
16921692 }
@@ -1789,3 +1789,5 @@ module_exit(smq_exit); · 96 unmodified lines
17891789 MODULE_AUTHOR("Joe Thornber <dm-devel@redhat.com>");
17901790 MODULE_LICENSE("GPL");
17911791 MODULE_DESCRIPTION("smq cache policy");
1792+
1793+MODULE_ALIAS("dm-cache-default");
drivers/md/dm-cache-target.c+4−3
@@ -424,6 +424,7 @@ static void free_migration(struct dm_cache_migration *mg) · 423 unmodified lines
424424 wake_up(&cache->migration_wait);
425425
426426 mempool_free(mg, cache->migration_pool);
427+ wake_worker(cache);
427428 }
428429
429430 static int prealloc_data_structs(struct cache *cache, struct prealloc *p)
@@ -1966,6 +1967,7 @@ static void process_deferred_bios(struct cache *cache) · 1536 unmodified lines
19661967 * this bio might require one, we pause until there are some
19671968 * prepared mappings to process.
19681969 */
1970+ prealloc_used = true;
19691971 if (prealloc_data_structs(cache, &structs)) {
19701972 spin_lock_irqsave(&cache->lock, flags);
19711973 bio_list_merge(&cache->deferred_bios, &bios);
@@ -1981,7 +1983,6 @@ static void process_deferred_bios(struct cache *cache) · 9 unmodified lines
19811983 process_discard_bio(cache, &structs, bio);
19821984 else
19831985 process_bio(cache, &structs, bio);
1984− prealloc_used = true;
19851986 }
19861987
19871988 if (prealloc_used)
@@ -2010,6 +2011,7 @@ static void process_deferred_cells(struct cache *cache) · 22 unmodified lines
20102011 * this bio might require one, we pause until there are some
20112012 * prepared mappings to process.
20122013 */
2014+ prealloc_used = true;
20132015 if (prealloc_data_structs(cache, &structs)) {
20142016 spin_lock_irqsave(&cache->lock, flags);
20152017 list_splice(&cells, &cache->deferred_cells);
@@ -2018,7 +2020,6 @@ static void process_deferred_cells(struct cache *cache) · 2 unmodified lines
20182020 }
20192021
20202022 process_cell(cache, &structs, cell);
2021− prealloc_used = true;
20222023 }
20232024
20242025 if (prealloc_used)
@@ -2080,6 +2081,7 @@ static void writeback_some_dirty_blocks(struct cache *cache) · 55 unmodified lines
20802081 if (policy_writeback_work(cache->policy, &oblock, &cblock, busy))
20812082 break; /* no work to do */
20822083
2084+ prealloc_used = true;
20832085 if (prealloc_data_structs(cache, &structs) ||
20842086 get_cell(cache, oblock, &structs, &old_ocell)) {
20852087 policy_set_dirty(cache->policy, oblock);
@@ -2087,7 +2089,6 @@ static void writeback_some_dirty_blocks(struct cache *cache) · 1 unmodified line
20872089 }
20882090
20892091 writeback(cache, &structs, oblock, cblock, old_ocell);
2090− prealloc_used = true;
20912092 }
20922093
20932094 if (prealloc_used)
drivers/md/dm-thin-metadata.c+2−2
@@ -1293,8 +1293,8 @@ static int __release_metadata_snap(struct dm_pool_metadata *pmd) · 1292 unmodified lines
12931293 return r;
12941294
12951295 disk_super = dm_block_data(copy);
1296− dm_sm_dec_block(pmd->metadata_sm, le64_to_cpu(disk_super->data_mapping_root));
1297− dm_sm_dec_block(pmd->metadata_sm, le64_to_cpu(disk_super->device_details_root));
1296+ dm_btree_del(&pmd->info, le64_to_cpu(disk_super->data_mapping_root));
1297+ dm_btree_del(&pmd->details_info, le64_to_cpu(disk_super->device_details_root));
12981298 dm_sm_dec_block(pmd->metadata_sm, held_root);
12991299
13001300 return dm_tm_unlock(pmd->tm, copy);
drivers/md/dm-thin.c+8−3
@@ -666,16 +666,21 @@ static void requeue_io(struct thin_c *tc) · 665 unmodified lines
666666 requeue_deferred_cells(tc);
667667 }
668668
669−static void error_retry_list(struct pool *pool)
669+static void error_retry_list_with_code(struct pool *pool, int error)
670670 {
671671 struct thin_c *tc;
672672
673673 rcu_read_lock();
674674 list_for_each_entry_rcu(tc, &pool->active_thins, list)
675− error_thin_bio_list(tc, &tc->retry_on_resume_list, -EIO);
675+ error_thin_bio_list(tc, &tc->retry_on_resume_list, error);
676676 rcu_read_unlock();
677677 }
678678
679+static void error_retry_list(struct pool *pool)
680+{
681+ return error_retry_list_with_code(pool, -EIO);
682+}
683+
679684 /*
680685 * This section of code contains the logic for processing a thin device's IO.
681686 * Much of the code depends on pool object resources (lists, workqueues, etc)
@@ -2297,7 +2302,7 @@ static void do_no_space_timeout(struct work_struct *ws) · 1615 unmodified lines
22972302 if (get_pool_mode(pool) == PM_OUT_OF_DATA_SPACE && !pool->pf.error_if_no_space) {
22982303 pool->pf.error_if_no_space = true;
22992304 notify_of_pool_mode_change_to_oods(pool);
2300− error_retry_list(pool);
2305+ error_retry_list_with_code(pool, -ENOSPC);
23012306 }
23022307 }
23032308
drivers/md/dm.c+10−17
@@ -1729,7 +1729,8 @@ static int dm_merge_bvec(struct request_queue *q, · 1728 unmodified lines
17291729 struct mapped_device *md = q->queuedata;
17301730 struct dm_table *map = dm_get_live_table_fast(md);
17311731 struct dm_target *ti;
1732− sector_t max_sectors, max_size = 0;
1732+ sector_t max_sectors;
1733+ int max_size = 0;
17331734
17341735 if (unlikely(!map))
17351736 goto out;
@@ -1742,18 +1743,10 @@ static int dm_merge_bvec(struct request_queue *q, · 6 unmodified lines
17421743 * Find maximum amount of I/O that won't need splitting
17431744 */
17441745 max_sectors = min(max_io_len(bvm->bi_sector, ti),
1745− (sector_t) queue_max_sectors(q));
1746+ (sector_t) BIO_MAX_SECTORS);
17461747 max_size = (max_sectors << SECTOR_SHIFT) - bvm->bi_size;
1747−
1748− /*
1749− * FIXME: this stop-gap fix _must_ be cleaned up (by passing a sector_t
1750− * to the targets' merge function since it holds sectors not bytes).
1751− * Just doing this as an interim fix for stable@ because the more
1752− * comprehensive cleanup of switching to sector_t will impact every
1753− * DM target that implements a ->merge hook.
1754− */
1755− if (max_size > INT_MAX)
1756− max_size = INT_MAX;
1748+ if (max_size < 0)
1749+ max_size = 0;
17571750
17581751 /*
17591752 * merge_bvec_fn() returns number of bytes
@@ -1761,13 +1754,13 @@ static int dm_merge_bvec(struct request_queue *q, · 1 unmodified line
17611754 * max is precomputed maximal io size
17621755 */
17631756 if (max_size && ti->type->merge)
1764− max_size = ti->type->merge(ti, bvm, biovec, (int) max_size);
1757+ max_size = ti->type->merge(ti, bvm, biovec, max_size);
17651758 /*
17661759 * If the target doesn't support merge method and some of the devices
1767− * provided their merge_bvec method (we know this by looking for the
1768− * max_hw_sectors that dm_set_device_limits may set), then we can't
1769− * allow bios with multiple vector entries. So always set max_size
1770− * to 0, and the code below allows just one page.
1760+ * provided their merge_bvec method (we know this by looking at
1761+ * queue_max_hw_sectors), then we can't allow bios with multiple vector
1762+ * entries. So always set max_size to 0, and the code below allows
1763+ * just one page.
17711764 */
17721765 else if (queue_max_hw_sectors(q) <= PAGE_SIZE >> 9)
17731766 max_size = 0;
drivers/md/md.c+1−1
@@ -5759,7 +5759,7 @@ static int get_bitmap_file(struct mddev *mddev, void __user * arg) · 5758 unmodified lines
57595759 char *ptr;
57605760 int err;
57615761
5762− file = kmalloc(sizeof(*file), GFP_NOIO);
5762+ file = kzalloc(sizeof(*file), GFP_NOIO);
57635763 if (!file)
57645764 return -ENOMEM;
57655765
drivers/md/persistent-data/dm-btree-internal.h+6−0
@@ -138,4 +138,10 @@ int lower_bound(struct btree_node *n, uint64_t key); · 137 unmodified lines
138138
139139 extern struct dm_block_validator btree_node_validator;
140140
141+/*
142+ * Value type for upper levels of multi-level btrees.
143+ */
144+extern void init_le64_type(struct dm_transaction_manager *tm,
145+ struct dm_btree_value_type *vt);
146+
141147 #endif /* DM_BTREE_INTERNAL_H */
drivers/md/persistent-data/dm-btree-remove.c+7−10
@@ -544,14 +544,6 @@ static int remove_raw(struct shadow_spine *s, struct dm_btree_info *info, · 543 unmodified lines
544544 return r;
545545 }
546546
547−static struct dm_btree_value_type le64_type = {
548− .context = NULL,
549− .size = sizeof(__le64),
550− .inc = NULL,
551− .dec = NULL,
552− .equal = NULL
553−};
554−
555547 int dm_btree_remove(struct dm_btree_info *info, dm_block_t root,
556548 uint64_t *keys, dm_block_t *new_root)
557549 {
@@ -559,12 +551,14 @@ int dm_btree_remove(struct dm_btree_info *info, dm_block_t root, · 1 unmodified line
559551 int index = 0, r = 0;
560552 struct shadow_spine spine;
561553 struct btree_node *n;
554+ struct dm_btree_value_type le64_vt;
562555
556+ init_le64_type(info->tm, &le64_vt);
563557 init_shadow_spine(&spine, info);
564558 for (level = 0; level < info->levels; level++) {
565559 r = remove_raw(&spine, info,
566560 (level == last_level ?
567− &info->value_type : &le64_type),
561+ &info->value_type : &le64_vt),
568562 root, keys[level], (unsigned *)&index);
569563 if (r < 0)
570564 break;
@@ -654,11 +648,13 @@ static int remove_one(struct dm_btree_info *info, dm_block_t root, · 83 unmodified lines
654648 int index = 0, r = 0;
655649 struct shadow_spine spine;
656650 struct btree_node *n;
651+ struct dm_btree_value_type le64_vt;
657652 uint64_t k;
658653
654+ init_le64_type(info->tm, &le64_vt);
659655 init_shadow_spine(&spine, info);
660656 for (level = 0; level < last_level; level++) {
661− r = remove_raw(&spine, info, &le64_type,
657+ r = remove_raw(&spine, info, &le64_vt,
662658 root, keys[level], (unsigned *) &index);
663659 if (r < 0)
664660 goto out;
@@ -689,6 +685,7 @@ static int remove_one(struct dm_btree_info *info, dm_block_t root, · 24 unmodified lines
689685 value_ptr(n, index));
690686
691687 delete_at(n, index);
688+ keys[last_level] = k + 1ull;
692689
693690 } else
694691 r = -ENODATA;
drivers/md/persistent-data/dm-btree-spine.c+37−0
@@ -249,3 +249,40 @@ int shadow_root(struct shadow_spine *s) · 248 unmodified lines
249249 {
250250 return s->root;
251251 }
252+
253+static void le64_inc(void *context, const void *value_le)
254+{
255+ struct dm_transaction_manager *tm = context;
256+ __le64 v_le;
257+
258+ memcpy(&v_le, value_le, sizeof(v_le));
259+ dm_tm_inc(tm, le64_to_cpu(v_le));
260+}
261+
262+static void le64_dec(void *context, const void *value_le)
263+{
264+ struct dm_transaction_manager *tm = context;
265+ __le64 v_le;
266+
267+ memcpy(&v_le, value_le, sizeof(v_le));
268+ dm_tm_dec(tm, le64_to_cpu(v_le));
269+}
270+
271+static int le64_equal(void *context, const void *value1_le, const void *value2_le)
272+{
273+ __le64 v1_le, v2_le;
274+
275+ memcpy(&v1_le, value1_le, sizeof(v1_le));
276+ memcpy(&v2_le, value2_le, sizeof(v2_le));
277+ return v1_le == v2_le;
278+}
279+
280+void init_le64_type(struct dm_transaction_manager *tm,
281+ struct dm_btree_value_type *vt)
282+{
283+ vt->context = tm;
284+ vt->size = sizeof(__le64);
285+ vt->inc = le64_inc;
286+ vt->dec = le64_dec;
287+ vt->equal = le64_equal;
288+}
drivers/md/persistent-data/dm-btree.c+1−6
@@ -667,12 +667,7 @@ static int insert(struct dm_btree_info *info, dm_block_t root, · 666 unmodified lines
667667 struct btree_node *n;
668668 struct dm_btree_value_type le64_type;
669669
670− le64_type.context = NULL;
671− le64_type.size = sizeof(__le64);
672− le64_type.inc = NULL;
673− le64_type.dec = NULL;
674− le64_type.equal = NULL;
675−
670+ init_le64_type(info->tm, &le64_type);
676671 init_shadow_spine(&spine, info);
677672
678673 for (level = 0; level < (info->levels - 1); level++) {
drivers/md/raid1.c+6−4
@@ -1476,6 +1476,7 @@ static void error(struct mddev *mddev, struct md_rdev *rdev) · 1475 unmodified lines
14761476 {
14771477 char b[BDEVNAME_SIZE];
14781478 struct r1conf *conf = mddev->private;
1479+ unsigned long flags;
14791480
14801481 /*
14811482 * If it is not operational, then we have already marked it as dead
@@ -1495,14 +1496,13 @@ static void error(struct mddev *mddev, struct md_rdev *rdev) · 13 unmodified lines
14951496 return;
14961497 }
14971498 set_bit(Blocked, &rdev->flags);
1499+ spin_lock_irqsave(&conf->device_lock, flags);
14981500 if (test_and_clear_bit(In_sync, &rdev->flags)) {
1499− unsigned long flags;
1500− spin_lock_irqsave(&conf->device_lock, flags);
15011501 mddev->degraded++;
15021502 set_bit(Faulty, &rdev->flags);
1503− spin_unlock_irqrestore(&conf->device_lock, flags);
15041503 } else
15051504 set_bit(Faulty, &rdev->flags);
1505+ spin_unlock_irqrestore(&conf->device_lock, flags);
15061506 /*
15071507 * if recovery is running, make sure it aborts.
15081508 */
@@ -1568,7 +1568,10 @@ static int raid1_spare_active(struct mddev *mddev) · 59 unmodified lines
15681568 * Find all failed disks within the RAID1 configuration
15691569 * and mark them readable.
15701570 * Called under mddev lock, so rcu protection not needed.
1571+ * device_lock used to avoid races with raid1_end_read_request
1572+ * which expects 'In_sync' flags and ->degraded to be consistent.
15711573 */
1574+ spin_lock_irqsave(&conf->device_lock, flags);
15721575 for (i = 0; i < conf->raid_disks; i++) {
15731576 struct md_rdev *rdev = conf->mirrors[i].rdev;
15741577 struct md_rdev *repl = conf->mirrors[conf->raid_disks + i].rdev;
@@ -1599,7 +1602,6 @@ static int raid1_spare_active(struct mddev *mddev) · 24 unmodified lines
15991602 sysfs_notify_dirent_safe(rdev->sysfs_state);
16001603 }
16011604 }
1602− spin_lock_irqsave(&conf->device_lock, flags);
16031605 mddev->degraded -= count;
16041606 spin_unlock_irqrestore(&conf->device_lock, flags);
16051607
drivers/md/raid5.c+3−2
@@ -2256,7 +2256,7 @@ static int resize_stripes(struct r5conf *conf, int newsize) · 2255 unmodified lines
22562256 static int drop_one_stripe(struct r5conf *conf)
22572257 {
22582258 struct stripe_head *sh;
2259− int hash = (conf->max_nr_stripes - 1) % NR_STRIPE_HASH_LOCKS;
2259+ int hash = (conf->max_nr_stripes - 1) & STRIPE_HASH_LOCKS_MASK;
22602260
22612261 spin_lock_irq(conf->hash_locks + hash);
22622262 sh = get_free_stripe(conf, hash);
@@ -6388,7 +6388,8 @@ static unsigned long raid5_cache_scan(struct shrinker *shrink, · 4125 unmodified lines
63886388
63896389 if (mutex_trylock(&conf->cache_size_mutex)) {
63906390 ret= 0;
6391− while (ret < sc->nr_to_scan) {
6391+ while (ret < sc->nr_to_scan &&
6392+ conf->max_nr_stripes > conf->min_nr_stripes) {
63926393 if (drop_one_stripe(conf) == 0) {
63936394 ret = SHRINK_STOP;
63946395 break;
drivers/memory/omap-gpmc.c+6−0
@@ -2245,6 +2245,9 @@ void omap3_gpmc_save_context(void) · 2244 unmodified lines
22452245 {
22462246 int i;
22472247
2248+ if (!gpmc_base)
2249+ return;
2250+
22482251 gpmc_context.sysconfig = gpmc_read_reg(GPMC_SYSCONFIG);
22492252 gpmc_context.irqenable = gpmc_read_reg(GPMC_IRQENABLE);
22502253 gpmc_context.timeout_ctrl = gpmc_read_reg(GPMC_TIMEOUT_CONTROL);
@@ -2277,6 +2280,9 @@ void omap3_gpmc_restore_context(void) · 26 unmodified lines
22772280 {
22782281 int i;
22792282
2283+ if (!gpmc_base)
2284+ return;
2285+
22802286 gpmc_write_reg(GPMC_SYSCONFIG, gpmc_context.sysconfig);
22812287 gpmc_write_reg(GPMC_IRQENABLE, gpmc_context.irqenable);
22822288 gpmc_write_reg(GPMC_TIMEOUT_CONTROL, gpmc_context.timeout_ctrl);
drivers/mfd/Kconfig+1−1
@@ -115,7 +115,7 @@ config MFD_CROS_EC_I2C · 114 unmodified lines
115115
116116 config MFD_CROS_EC_SPI
117117 tristate "ChromeOS Embedded Controller (SPI)"
118− depends on MFD_CROS_EC && CROS_EC_PROTO && SPI && OF
118+ depends on MFD_CROS_EC && CROS_EC_PROTO && SPI
119119
120120 ---help---
121121 If you say Y here, you get support for talking to the ChromeOS EC
drivers/mfd/arizona-core.c+7−9
@@ -651,7 +651,7 @@ static int arizona_runtime_suspend(struct device *dev) · 650 unmodified lines
651651
652652 arizona->has_fully_powered_off = true;
653653
654− disable_irq(arizona->irq);
654+ disable_irq_nosync(arizona->irq);
655655 arizona_enable_reset(arizona);
656656 regulator_bulk_disable(arizona->num_core_supplies,
657657 arizona->core_supplies);
@@ -1141,10 +1141,6 @@ int arizona_dev_init(struct arizona *arizona) · 483 unmodified lines
11411141 arizona->pdata.gpio_defaults[i]);
11421142 }
11431143
1144− pm_runtime_set_autosuspend_delay(arizona->dev, 100);
1145− pm_runtime_use_autosuspend(arizona->dev);
1146− pm_runtime_enable(arizona->dev);
1147−
11481144 /* Chip default */
11491145 if (!arizona->pdata.clk32k_src)
11501146 arizona->pdata.clk32k_src = ARIZONA_32KZ_MCLK2;
@@ -1245,11 +1241,17 @@ int arizona_dev_init(struct arizona *arizona) · 94 unmodified lines
12451241 arizona->pdata.spk_fmt[i]);
12461242 }
12471243
1244+ pm_runtime_set_active(arizona->dev);
1245+ pm_runtime_enable(arizona->dev);
1246+
12481247 /* Set up for interrupts */
12491248 ret = arizona_irq_init(arizona);
12501249 if (ret != 0)
12511250 goto err_reset;
12521251
1252+ pm_runtime_set_autosuspend_delay(arizona->dev, 100);
1253+ pm_runtime_use_autosuspend(arizona->dev);
1254+
12531255 arizona_request_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, "CLKGEN error",
12541256 arizona_clkgen_err, arizona);
12551257 arizona_request_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, "Overclocked",
@@ -1278,10 +1280,6 @@ int arizona_dev_init(struct arizona *arizona) · 22 unmodified lines
12781280 goto err_irq;
12791281 }
12801282
1281−#ifdef CONFIG_PM
1282− regulator_disable(arizona->dcvdd);
1283−#endif
1284−
12851283 return 0;
12861284
12871285 err_irq:
drivers/misc/eeprom/at24.c+0−3
@@ -438,9 +438,6 @@ static ssize_t at24_bin_write(struct file *filp, struct kobject *kobj, · 437 unmodified lines
438438 {
439439 struct at24_data *at24;
440440
441− if (unlikely(off >= attr->size))
442− return -EFBIG;
443−
444441 at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
445442 return at24_write(at24, buf, off, count);
446443 }
drivers/net/bonding/bond_main.c+1−0
@@ -786,6 +786,7 @@ static bool bond_should_notify_peers(struct bonding *bond) · 785 unmodified lines
786786 slave ? slave->dev->name : "NULL");
787787
788788 if (!slave || !bond->send_peer_notif ||
789+ !netif_carrier_ok(bond->dev) ||
789790 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state))
790791 return false;
791792
drivers/net/ethernet/3com/3c59x.c+8−9
@@ -1763,16 +1763,9 @@ vortex_open(struct net_device *dev) · 1762 unmodified lines
17631763 vp->rx_ring[i].addr = cpu_to_le32(pci_map_single(VORTEX_PCI(vp), skb->data, PKT_BUF_SZ, PCI_DMA_FROMDEVICE));
17641764 }
17651765 if (i != RX_RING_SIZE) {
1766− int j;
17671766 pr_emerg("%s: no memory for rx ring\n", dev->name);
1768− for (j = 0; j < i; j++) {
1769− if (vp->rx_skbuff[j]) {
1770− dev_kfree_skb(vp->rx_skbuff[j]);
1771− vp->rx_skbuff[j] = NULL;
1772− }
1773− }
17741767 retval = -ENOMEM;
1775− goto err_free_irq;
1768+ goto err_free_skb;
17761769 }
17771770 /* Wrap the ring. */
17781771 vp->rx_ring[i-1].next = cpu_to_le32(vp->rx_ring_dma);
@@ -1782,7 +1775,13 @@ vortex_open(struct net_device *dev) · 3 unmodified lines
17821775 if (!retval)
17831776 goto out;
17841777
1785−err_free_irq:
1778+err_free_skb:
1779+ for (i = 0; i < RX_RING_SIZE; i++) {
1780+ if (vp->rx_skbuff[i]) {
1781+ dev_kfree_skb(vp->rx_skbuff[i]);
1782+ vp->rx_skbuff[i] = NULL;
1783+ }
1784+ }
17861785 free_irq(dev->irq, dev);
17871786 err:
17881787 if (vortex_debug > 1)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c+1−1
@@ -262,9 +262,9 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata, · 261 unmodified lines
262262 if (likely(skb)) {
263263 (*pkts_compl)++;
264264 (*bytes_compl) += skb->len;
265+ dev_kfree_skb_any(skb);
265266 }
266267
267− dev_kfree_skb_any(skb);
268268 tx_buf->first_bd = 0;
269269 tx_buf->skb = NULL;
270270
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c+16−0
@@ -1718,6 +1718,22 @@ static int bnx2x_nvram_write(struct bnx2x *bp, u32 offset, u8 *data_buf, · 1717 unmodified lines
17181718 offset += sizeof(u32);
17191719 data_buf += sizeof(u32);
17201720 written_so_far += sizeof(u32);
1721+
1722+ /* At end of each 4Kb page, release nvram lock to allow MFW
1723+ * chance to take it for its own use.
1724+ */
1725+ if ((cmd_flags & MCPR_NVM_COMMAND_LAST) &&
1726+ (written_so_far < buf_size)) {
1727+ DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
1728+ "Releasing NVM lock after offset 0x%x\n",
1729+ (u32)(offset - sizeof(u32)));
1730+ bnx2x_release_nvram_lock(bp);
1731+ usleep_range(1000, 2000);
1732+ rc = bnx2x_acquire_nvram_lock(bp);
1733+ if (rc)
1734+ return rc;
1735+ }
1736+
17211737 cmd_flags = 0;
17221738 }
17231739
drivers/net/ethernet/brocade/bna/bnad.c+1−1
@@ -676,6 +676,7 @@ bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget) · 675 unmodified lines
676676 if (!next_cmpl->valid)
677677 break;
678678 }
679+ packets++;
679680
680681 /* TODO: BNA_CQ_EF_LOCAL ? */
681682 if (unlikely(flags & (BNA_CQ_EF_MAC_ERROR |
@@ -692,7 +693,6 @@ bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget) · 10 unmodified lines
692693 else
693694 bnad_cq_setup_skb_frags(rcb, skb, sop_ci, nvecs, len);
694695
695− packets++;
696696 rcb->rxq->rx_packets++;
697697 rcb->rxq->rx_bytes += totlen;
698698 ccb->bytes_per_intr += totlen;
drivers/net/ethernet/cadence/macb.c+83−42
@@ -104,6 +104,57 @@ static void *macb_rx_buffer(struct macb *bp, unsigned int index) · 103 unmodified lines
104104 return bp->rx_buffers + bp->rx_buffer_size * macb_rx_ring_wrap(index);
105105 }
106106
107+/* I/O accessors */
108+static u32 hw_readl_native(struct macb *bp, int offset)
109+{
110+ return __raw_readl(bp->regs + offset);
111+}
112+
113+static void hw_writel_native(struct macb *bp, int offset, u32 value)
114+{
115+ __raw_writel(value, bp->regs + offset);
116+}
117+
118+static u32 hw_readl(struct macb *bp, int offset)
119+{
120+ return readl_relaxed(bp->regs + offset);
121+}
122+
123+static void hw_writel(struct macb *bp, int offset, u32 value)
124+{
125+ writel_relaxed(value, bp->regs + offset);
126+}
127+
128+/*
129+ * Find the CPU endianness by using the loopback bit of NCR register. When the
130+ * CPU is in big endian we need to program swaped mode for management
131+ * descriptor access.
132+ */
133+static bool hw_is_native_io(void __iomem *addr)
134+{
135+ u32 value = MACB_BIT(LLB);
136+
137+ __raw_writel(value, addr + MACB_NCR);
138+ value = __raw_readl(addr + MACB_NCR);
139+
140+ /* Write 0 back to disable everything */
141+ __raw_writel(0, addr + MACB_NCR);
142+
143+ return value == MACB_BIT(LLB);
144+}
145+
146+static bool hw_is_gem(void __iomem *addr, bool native_io)
147+{
148+ u32 id;
149+
150+ if (native_io)
151+ id = __raw_readl(addr + MACB_MID);
152+ else
153+ id = readl_relaxed(addr + MACB_MID);
154+
155+ return MACB_BFEXT(IDNUM, id) >= 0x2;
156+}
157+
107158 static void macb_set_hwaddr(struct macb *bp)
108159 {
109160 u32 bottom;
@@ -160,7 +211,7 @@ static void macb_get_hwaddr(struct macb *bp) · 50 unmodified lines
160211 }
161212 }
162213
163− netdev_info(bp->dev, "invalid hw address, using random\n");
214+ dev_info(&bp->pdev->dev, "invalid hw address, using random\n");
164215 eth_hw_addr_random(bp->dev);
165216 }
166217
@@ -252,7 +303,6 @@ static void macb_handle_link_change(struct net_device *dev) · 85 unmodified lines
252303 struct macb *bp = netdev_priv(dev);
253304 struct phy_device *phydev = bp->phy_dev;
254305 unsigned long flags;
255−
256306 int status_change = 0;
257307
258308 spin_lock_irqsave(&bp->lock, flags);
@@ -449,14 +499,14 @@ err_out: · 190 unmodified lines
449499
450500 static void macb_update_stats(struct macb *bp)
451501 {
452− u32 __iomem *reg = bp->regs + MACB_PFR;
453502 u32 *p = &bp->hw_stats.macb.rx_pause_frames;
454503 u32 *end = &bp->hw_stats.macb.tx_pause_frames + 1;
504+ int offset = MACB_PFR;
455505
456506 WARN_ON((unsigned long)(end - p - 1) != (MACB_TPF - MACB_PFR) / 4);
457507
458− for(; p < end; p++, reg++)
459− *p += readl_relaxed(reg);
508+ for(; p < end; p++, offset += 4)
509+ *p += bp->macb_reg_readl(bp, offset);
460510 }
461511
462512 static int macb_halt_tx(struct macb *bp)
@@ -1107,12 +1157,6 @@ static void macb_poll_controller(struct net_device *dev) · 644 unmodified lines
11071157 }
11081158 #endif
11091159
1110−static inline unsigned int macb_count_tx_descriptors(struct macb *bp,
1111− unsigned int len)
1112−{
1113− return (len + bp->max_tx_length - 1) / bp->max_tx_length;
1114−}
1115−
11161160 static unsigned int macb_tx_map(struct macb *bp,
11171161 struct macb_queue *queue,
11181162 struct sk_buff *skb)
@@ -1263,11 +1307,11 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) · 144 unmodified lines
12631307 * socket buffer: skb fragments of jumbo frames may need to be
12641308 * splitted into many buffer descriptors.
12651309 */
1266− count = macb_count_tx_descriptors(bp, skb_headlen(skb));
1310+ count = DIV_ROUND_UP(skb_headlen(skb), bp->max_tx_length);
12671311 nr_frags = skb_shinfo(skb)->nr_frags;
12681312 for (f = 0; f < nr_frags; f++) {
12691313 frag_size = skb_frag_size(&skb_shinfo(skb)->frags[f]);
1270− count += macb_count_tx_descriptors(bp, frag_size);
1314+ count += DIV_ROUND_UP(frag_size, bp->max_tx_length);
12711315 }
12721316
12731317 spin_lock_irqsave(&bp->lock, flags);
@@ -1603,7 +1647,6 @@ static u32 macb_dbw(struct macb *bp) · 329 unmodified lines
16031647 static void macb_configure_dma(struct macb *bp)
16041648 {
16051649 u32 dmacfg;
1606− u32 tmp, ncr;
16071650
16081651 if (macb_is_gem(bp)) {
16091652 dmacfg = gem_readl(bp, DMACFG) & ~GEM_BF(RXBS, -1L);
@@ -1613,22 +1656,11 @@ static void macb_configure_dma(struct macb *bp) · 3 unmodified lines
16131656 dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L);
16141657 dmacfg &= ~GEM_BIT(ENDIA_PKT);
16151658
1616− /* Find the CPU endianness by using the loopback bit of net_ctrl
1617− * register. save it first. When the CPU is in big endian we
1618− * need to program swaped mode for management descriptor access.
1619− */
1620− ncr = macb_readl(bp, NCR);
1621− __raw_writel(MACB_BIT(LLB), bp->regs + MACB_NCR);
1622− tmp = __raw_readl(bp->regs + MACB_NCR);
1623−
1624− if (tmp == MACB_BIT(LLB))
1659+ if (bp->native_io)
16251660 dmacfg &= ~GEM_BIT(ENDIA_DESC);
16261661 else
16271662 dmacfg |= GEM_BIT(ENDIA_DESC); /* CPU in big endian */
16281663
1629− /* Restore net_ctrl */
1630− macb_writel(bp, NCR, ncr);
1631−
16321664 if (bp->dev->features & NETIF_F_HW_CSUM)
16331665 dmacfg |= GEM_BIT(TXCOEN);
16341666 else
@@ -1897,19 +1929,19 @@ static int macb_change_mtu(struct net_device *dev, int new_mtu) · 262 unmodified lines
18971929
18981930 static void gem_update_stats(struct macb *bp)
18991931 {
1900− int i;
1932+ unsigned int i;
19011933 u32 *p = &bp->hw_stats.gem.tx_octets_31_0;
19021934
19031935 for (i = 0; i < GEM_STATS_LEN; ++i, ++p) {
19041936 u32 offset = gem_statistics[i].offset;
1905− u64 val = readl_relaxed(bp->regs + offset);
1937+ u64 val = bp->macb_reg_readl(bp, offset);
19061938
19071939 bp->ethtool_stats[i] += val;
19081940 *p += val;
19091941
19101942 if (offset == GEM_OCTTXL || offset == GEM_OCTRXL) {
19111943 /* Add GEM_OCTTXH, GEM_OCTRXH */
1912− val = readl_relaxed(bp->regs + offset + 4);
1944+ val = bp->macb_reg_readl(bp, offset + 4);
19131945 bp->ethtool_stats[i] += ((u64)val) << 32;
19141946 *(++p) += val;
19151947 }
@@ -1976,7 +2008,7 @@ static int gem_get_sset_count(struct net_device *dev, int sset) · 60 unmodified lines
19762008
19772009 static void gem_get_ethtool_strings(struct net_device *dev, u32 sset, u8 *p)
19782010 {
1979− int i;
2011+ unsigned int i;
19802012
19812013 switch (sset) {
19822014 case ETH_SS_STATS:
@@ -2190,7 +2222,7 @@ static void macb_configure_caps(struct macb *bp, const struct macb_config *dt_co · 207 unmodified lines
21902222 if (dt_conf)
21912223 bp->caps = dt_conf->caps;
21922224
2193− if (macb_is_gem_hw(bp->regs)) {
2225+ if (hw_is_gem(bp->regs, bp->native_io)) {
21942226 bp->caps |= MACB_CAPS_MACB_IS_GEM;
21952227
21962228 dcfg = gem_readl(bp, DCFG1);
@@ -2201,10 +2233,11 @@ static void macb_configure_caps(struct macb *bp, const struct macb_config *dt_co · 4 unmodified lines
22012233 bp->caps |= MACB_CAPS_FIFO_MODE;
22022234 }
22032235
2204− netdev_dbg(bp->dev, "Cadence caps 0x%08x\n", bp->caps);
2236+ dev_dbg(&bp->pdev->dev, "Cadence caps 0x%08x\n", bp->caps);
22052237 }
22062238
22072239 static void macb_probe_queues(void __iomem *mem,
2240+ bool native_io,
22082241 unsigned int *queue_mask,
22092242 unsigned int *num_queues)
22102243 {
@@ -2219,7 +2252,7 @@ static void macb_probe_queues(void __iomem *mem, · 8 unmodified lines
22192252 * we are early in the probe process and don't have the
22202253 * MACB_CAPS_MACB_IS_GEM flag positioned
22212254 */
2222− if (!macb_is_gem_hw(mem))
2255+ if (!hw_is_gem(mem, native_io))
22232256 return;
22242257
22252258 /* bit 0 is never set but queue 0 always exists */
@@ -2786,6 +2819,7 @@ static int macb_probe(struct platform_device *pdev) · 560 unmodified lines
27862819 struct clk *pclk, *hclk, *tx_clk;
27872820 unsigned int queue_mask, num_queues;
27882821 struct macb_platform_data *pdata;
2822+ bool native_io;
27892823 struct phy_device *phydev;
27902824 struct net_device *dev;
27912825 struct resource *regs;
@@ -2794,6 +2828,11 @@ static int macb_probe(struct platform_device *pdev) · 2 unmodified lines
27942828 struct macb *bp;
27952829 int err;
27962830
2831+ regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2832+ mem = devm_ioremap_resource(&pdev->dev, regs);
2833+ if (IS_ERR(mem))
2834+ return PTR_ERR(mem);
2835+
27972836 if (np) {
27982837 const struct of_device_id *match;
27992838
@@ -2809,14 +2848,9 @@ static int macb_probe(struct platform_device *pdev) · 9 unmodified lines
28092848 if (err)
28102849 return err;
28112850
2812− regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2813− mem = devm_ioremap_resource(&pdev->dev, regs);
2814− if (IS_ERR(mem)) {
2815− err = PTR_ERR(mem);
2816− goto err_disable_clocks;
2817− }
2851+ native_io = hw_is_native_io(mem);
28182852
2819− macb_probe_queues(mem, &queue_mask, &num_queues);
2853+ macb_probe_queues(mem, native_io, &queue_mask, &num_queues);
28202854 dev = alloc_etherdev_mq(sizeof(*bp), num_queues);
28212855 if (!dev) {
28222856 err = -ENOMEM;
@@ -2831,6 +2865,14 @@ static int macb_probe(struct platform_device *pdev) · 8 unmodified lines
28312865 bp->pdev = pdev;
28322866 bp->dev = dev;
28332867 bp->regs = mem;
2868+ bp->native_io = native_io;
2869+ if (native_io) {
2870+ bp->macb_reg_readl = hw_readl_native;
2871+ bp->macb_reg_writel = hw_writel_native;
2872+ } else {
2873+ bp->macb_reg_readl = hw_readl;
2874+ bp->macb_reg_writel = hw_writel;
2875+ }
28342876 bp->num_queues = num_queues;
28352877 bp->queue_mask = queue_mask;
28362878 if (macb_config)
@@ -2838,9 +2880,8 @@ static int macb_probe(struct platform_device *pdev) · 1 unmodified line
28382880 bp->pclk = pclk;
28392881 bp->hclk = hclk;
28402882 bp->tx_clk = tx_clk;
2841− if (macb_config->jumbo_max_len) {
2883+ if (macb_config)
28422884 bp->jumbo_max_len = macb_config->jumbo_max_len;
2843− }
28442885
28452886 spin_lock_init(&bp->lock);
28462887
drivers/net/ethernet/cadence/macb.h+14−20
@@ -429,18 +429,12 @@ · 428 unmodified lines
429429 | GEM_BF(name, value))
430430
431431 /* Register access macros */
432−#define macb_readl(port,reg) \
433− readl_relaxed((port)->regs + MACB_##reg)
434−#define macb_writel(port,reg,value) \
435− writel_relaxed((value), (port)->regs + MACB_##reg)
436−#define gem_readl(port, reg) \
437− readl_relaxed((port)->regs + GEM_##reg)
438−#define gem_writel(port, reg, value) \
439− writel_relaxed((value), (port)->regs + GEM_##reg)
440−#define queue_readl(queue, reg) \
441− readl_relaxed((queue)->bp->regs + (queue)->reg)
442−#define queue_writel(queue, reg, value) \
443− writel_relaxed((value), (queue)->bp->regs + (queue)->reg)
432+#define macb_readl(port, reg) (port)->macb_reg_readl((port), MACB_##reg)
433+#define macb_writel(port, reg, value) (port)->macb_reg_writel((port), MACB_##reg, (value))
434+#define gem_readl(port, reg) (port)->macb_reg_readl((port), GEM_##reg)
435+#define gem_writel(port, reg, value) (port)->macb_reg_writel((port), GEM_##reg, (value))
436+#define queue_readl(queue, reg) (queue)->bp->macb_reg_readl((queue)->bp, (queue)->reg)
437+#define queue_writel(queue, reg, value) (queue)->bp->macb_reg_writel((queue)->bp, (queue)->reg, (value))
444438
445439 /* Conditional GEM/MACB macros. These perform the operation to the correct
446440 * register dependent on whether the device is a GEM or a MACB. For registers
@@ -785,6 +779,11 @@ struct macb_queue { · 338 unmodified lines
785779
786780 struct macb {
787781 void __iomem *regs;
782+ bool native_io;
783+
784+ /* hardware IO accessors */
785+ u32 (*macb_reg_readl)(struct macb *bp, int offset);
786+ void (*macb_reg_writel)(struct macb *bp, int offset, u32 value);
788787
789788 unsigned int rx_tail;
790789 unsigned int rx_prepared_head;
@@ -817,9 +816,9 @@ struct macb { · 26 unmodified lines
817816
818817 struct mii_bus *mii_bus;
819818 struct phy_device *phy_dev;
820− unsigned int link;
821− unsigned int speed;
822− unsigned int duplex;
819+ int link;
820+ int speed;
821+ int duplex;
823822
824823 u32 caps;
825824 unsigned int dma_burst_length;
@@ -843,9 +842,4 @@ static inline bool macb_is_gem(struct macb *bp) · 17 unmodified lines
843842 return !!(bp->caps & MACB_CAPS_MACB_IS_GEM);
844843 }
845844
846−static inline bool macb_is_gem_hw(void __iomem *addr)
847−{
848− return !!(MACB_BFEXT(IDNUM, readl_relaxed(addr + MACB_MID)) >= 0x2);
849−}
850−
851845 #endif /* _MACB_H */
drivers/net/ethernet/cavium/Kconfig+0−3
@@ -16,7 +16,6 @@ if NET_VENDOR_CAVIUM · 15 unmodified lines
1616 config THUNDER_NIC_PF
1717 tristate "Thunder Physical function driver"
1818 depends on 64BIT
19− default ARCH_THUNDER
2019 select THUNDER_NIC_BGX
2120 ---help---
2221 This driver supports Thunder's NIC physical function.
@@ -29,14 +28,12 @@ config THUNDER_NIC_PF · 6 unmodified lines
2928 config THUNDER_NIC_VF
3029 tristate "Thunder Virtual function driver"
3130 depends on 64BIT
32− default ARCH_THUNDER
3331 ---help---
3432 This driver supports Thunder's NIC virtual function
3533
3634 config THUNDER_NIC_BGX
3735 tristate "Thunder MAC interface driver (BGX)"
3836 depends on 64BIT
39− default ARCH_THUNDER
4037 ---help---
4138 This driver supports programming and controlling of MAC
4239 interface from NIC physical function driver.
drivers/net/ethernet/cavium/thunder/nic.h+11−1
@@ -125,6 +125,15 @@ · 124 unmodified lines
125125 */
126126 #define NICPF_CLK_PER_INT_TICK 2
127127
128+/* Time to wait before we decide that a SQ is stuck.
129+ *
130+ * Since both pkt rx and tx notifications are done with same CQ,
131+ * when packets are being received at very high rate (eg: L2 forwarding)
132+ * then freeing transmitted skbs will be delayed and watchdog
133+ * will kick in, resetting interface. Hence keeping this value high.
134+ */
135+#define NICVF_TX_TIMEOUT (50 * HZ)
136+
128137 struct nicvf_cq_poll {
129138 u8 cq_idx; /* Completion queue index */
130139 struct napi_struct napi;
@@ -216,8 +225,9 @@ struct nicvf_drv_stats { · 85 unmodified lines
216225 /* Tx */
217226 u64 tx_frames_ok;
218227 u64 tx_drops;
219− u64 tx_busy;
220228 u64 tx_tso;
229+ u64 txq_stop;
230+ u64 txq_wake;
221231 };
222232
223233 struct nicvf {
drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c+16−10
@@ -66,9 +66,10 @@ static const struct nicvf_stat nicvf_drv_stats[] = { · 65 unmodified lines
6666 NICVF_DRV_STAT(rx_frames_jumbo),
6767 NICVF_DRV_STAT(rx_drops),
6868 NICVF_DRV_STAT(tx_frames_ok),
69− NICVF_DRV_STAT(tx_busy),
7069 NICVF_DRV_STAT(tx_tso),
7170 NICVF_DRV_STAT(tx_drops),
71+ NICVF_DRV_STAT(txq_stop),
72+ NICVF_DRV_STAT(txq_wake),
7273 };
7374
7475 static const struct nicvf_stat nicvf_queue_stats[] = {
@@ -126,6 +127,7 @@ static void nicvf_set_msglevel(struct net_device *netdev, u32 lvl) · 51 unmodified lines
126127
127128 static void nicvf_get_strings(struct net_device *netdev, u32 sset, u8 *data)
128129 {
130+ struct nicvf *nic = netdev_priv(netdev);
129131 int stats, qidx;
130132
131133 if (sset != ETH_SS_STATS)
@@ -141,7 +143,7 @@ static void nicvf_get_strings(struct net_device *netdev, u32 sset, u8 *data) · 9 unmodified lines
141143 data += ETH_GSTRING_LEN;
142144 }
143145
144− for (qidx = 0; qidx < MAX_RCV_QUEUES_PER_QS; qidx++) {
146+ for (qidx = 0; qidx < nic->qs->rq_cnt; qidx++) {
145147 for (stats = 0; stats < nicvf_n_queue_stats; stats++) {
146148 sprintf(data, "rxq%d: %s", qidx,
147149 nicvf_queue_stats[stats].name);
@@ -149,7 +151,7 @@ static void nicvf_get_strings(struct net_device *netdev, u32 sset, u8 *data) · 1 unmodified line
149151 }
150152 }
151153
152− for (qidx = 0; qidx < MAX_SND_QUEUES_PER_QS; qidx++) {
154+ for (qidx = 0; qidx < nic->qs->sq_cnt; qidx++) {
153155 for (stats = 0; stats < nicvf_n_queue_stats; stats++) {
154156 sprintf(data, "txq%d: %s", qidx,
155157 nicvf_queue_stats[stats].name);
@@ -170,12 +172,14 @@ static void nicvf_get_strings(struct net_device *netdev, u32 sset, u8 *data) · 14 unmodified lines
170172
171173 static int nicvf_get_sset_count(struct net_device *netdev, int sset)
172174 {
175+ struct nicvf *nic = netdev_priv(netdev);
176+
173177 if (sset != ETH_SS_STATS)
174178 return -EINVAL;
175179
176180 return nicvf_n_hw_stats + nicvf_n_drv_stats +
177181 (nicvf_n_queue_stats *
178− (MAX_RCV_QUEUES_PER_QS + MAX_SND_QUEUES_PER_QS)) +
182+ (nic->qs->rq_cnt + nic->qs->sq_cnt)) +
179183 BGX_RX_STATS_COUNT + BGX_TX_STATS_COUNT;
180184 }
181185
@@ -197,13 +201,13 @@ static void nicvf_get_ethtool_stats(struct net_device *netdev, · 15 unmodified lines
197201 *(data++) = ((u64 *)&nic->drv_stats)
198202 [nicvf_drv_stats[stat].index];
199203
200− for (qidx = 0; qidx < MAX_RCV_QUEUES_PER_QS; qidx++) {
204+ for (qidx = 0; qidx < nic->qs->rq_cnt; qidx++) {
201205 for (stat = 0; stat < nicvf_n_queue_stats; stat++)
202206 *(data++) = ((u64 *)&nic->qs->rq[qidx].stats)
203207 [nicvf_queue_stats[stat].index];
204208 }
205209
206− for (qidx = 0; qidx < MAX_SND_QUEUES_PER_QS; qidx++) {
210+ for (qidx = 0; qidx < nic->qs->sq_cnt; qidx++) {
207211 for (stat = 0; stat < nicvf_n_queue_stats; stat++)
208212 *(data++) = ((u64 *)&nic->qs->sq[qidx].stats)
209213 [nicvf_queue_stats[stat].index];
@@ -543,6 +547,7 @@ static int nicvf_set_channels(struct net_device *dev, · 333 unmodified lines
543547 {
544548 struct nicvf *nic = netdev_priv(dev);
545549 int err = 0;
550+ bool if_up = netif_running(dev);
546551
547552 if (!channel->rx_count || !channel->tx_count)
548553 return -EINVAL;
@@ -551,6 +556,9 @@ static int nicvf_set_channels(struct net_device *dev, · 2 unmodified lines
551556 if (channel->tx_count > MAX_SND_QUEUES_PER_QS)
552557 return -EINVAL;
553558
559+ if (if_up)
560+ nicvf_stop(dev);
561+
554562 nic->qs->rq_cnt = channel->rx_count;
555563 nic->qs->sq_cnt = channel->tx_count;
556564 nic->qs->cq_cnt = max(nic->qs->rq_cnt, nic->qs->sq_cnt);
@@ -559,11 +567,9 @@ static int nicvf_set_channels(struct net_device *dev, · 2 unmodified lines
559567 if (err)
560568 return err;
561569
562− if (!netif_running(dev))
563− return err;
570+ if (if_up)
571+ nicvf_open(dev);
564572
565− nicvf_stop(dev);
566− nicvf_open(dev);
567573 netdev_info(dev, "Setting num Tx rings to %d, Rx rings to %d success\n",
568574 nic->qs->sq_cnt, nic->qs->rq_cnt);
569575
drivers/net/ethernet/cavium/thunder/nicvf_main.c+39−16
@@ -234,7 +234,7 @@ static void nicvf_handle_mbx_intr(struct nicvf *nic) · 233 unmodified lines
234234 nic->duplex == DUPLEX_FULL ?
235235 "Full duplex" : "Half duplex");
236236 netif_carrier_on(nic->netdev);
237− netif_tx_wake_all_queues(nic->netdev);
237+ netif_tx_start_all_queues(nic->netdev);
238238 } else {
239239 netdev_info(nic->netdev, "%s: Link is Down\n",
240240 nic->netdev->name);
@@ -425,6 +425,7 @@ static void nicvf_snd_pkt_handler(struct net_device *netdev, · 184 unmodified lines
425425 if (skb) {
426426 prefetch(skb);
427427 dev_consume_skb_any(skb);
428+ sq->skbuff[cqe_tx->sqe_ptr] = (u64)NULL;
428429 }
429430 }
430431
@@ -476,12 +477,13 @@ static void nicvf_rcv_pkt_handler(struct net_device *netdev, · 45 unmodified lines
476477 static int nicvf_cq_intr_handler(struct net_device *netdev, u8 cq_idx,
477478 struct napi_struct *napi, int budget)
478479 {
479− int processed_cqe, work_done = 0;
480+ int processed_cqe, work_done = 0, tx_done = 0;
480481 int cqe_count, cqe_head;
481482 struct nicvf *nic = netdev_priv(netdev);
482483 struct queue_set *qs = nic->qs;
483484 struct cmp_queue *cq = &qs->cq[cq_idx];
484485 struct cqe_rx_t *cq_desc;
486+ struct netdev_queue *txq;
485487
486488 spin_lock_bh(&cq->lock);
487489 loop:
@@ -496,8 +498,8 @@ loop: · 8 unmodified lines
496498 cqe_head = nicvf_queue_reg_read(nic, NIC_QSET_CQ_0_7_HEAD, cq_idx) >> 9;
497499 cqe_head &= 0xFFFF;
498500
499− netdev_dbg(nic->netdev, "%s cqe_count %d cqe_head %d\n",
500− __func__, cqe_count, cqe_head);
501+ netdev_dbg(nic->netdev, "%s CQ%d cqe_count %d cqe_head %d\n",
502+ __func__, cq_idx, cqe_count, cqe_head);
501503 while (processed_cqe < cqe_count) {
502504 /* Get the CQ descriptor */
503505 cq_desc = (struct cqe_rx_t *)GET_CQ_DESC(cq, cqe_head);
@@ -511,8 +513,8 @@ loop: · 7 unmodified lines
511513 break;
512514 }
513515
514− netdev_dbg(nic->netdev, "cq_desc->cqe_type %d\n",
515− cq_desc->cqe_type);
516+ netdev_dbg(nic->netdev, "CQ%d cq_desc->cqe_type %d\n",
517+ cq_idx, cq_desc->cqe_type);
516518 switch (cq_desc->cqe_type) {
517519 case CQE_TYPE_RX:
518520 nicvf_rcv_pkt_handler(netdev, napi, cq,
@@ -522,6 +524,7 @@ loop: · 3 unmodified lines
522524 case CQE_TYPE_SEND:
523525 nicvf_snd_pkt_handler(netdev, cq,
524526 (void *)cq_desc, CQE_TYPE_SEND);
527+ tx_done++;
525528 break;
526529 case CQE_TYPE_INVALID:
527530 case CQE_TYPE_RX_SPLIT:
@@ -532,8 +535,9 @@ loop: · 4 unmodified lines
532535 }
533536 processed_cqe++;
534537 }
535− netdev_dbg(nic->netdev, "%s processed_cqe %d work_done %d budget %d\n",
536− __func__, processed_cqe, work_done, budget);
538+ netdev_dbg(nic->netdev,
539+ "%s CQ%d processed_cqe %d work_done %d budget %d\n",
540+ __func__, cq_idx, processed_cqe, work_done, budget);
537541
538542 /* Ring doorbell to inform H/W to reuse processed CQEs */
539543 nicvf_queue_reg_write(nic, NIC_QSET_CQ_0_7_DOOR,
@@ -543,6 +547,19 @@ loop: · 3 unmodified lines
543547 goto loop;
544548
545549 done:
550+ /* Wakeup TXQ if its stopped earlier due to SQ full */
551+ if (tx_done) {
552+ txq = netdev_get_tx_queue(netdev, cq_idx);
553+ if (netif_tx_queue_stopped(txq)) {
554+ netif_tx_start_queue(txq);
555+ nic->drv_stats.txq_wake++;
556+ if (netif_msg_tx_err(nic))
557+ netdev_warn(netdev,
558+ "%s: Transmit queue wakeup SQ%d\n",
559+ netdev->name, cq_idx);
560+ }
561+ }
562+
546563 spin_unlock_bh(&cq->lock);
547564 return work_done;
548565 }
@@ -554,15 +571,10 @@ static int nicvf_poll(struct napi_struct *napi, int budget) · 5 unmodified lines
554571 struct net_device *netdev = napi->dev;
555572 struct nicvf *nic = netdev_priv(netdev);
556573 struct nicvf_cq_poll *cq;
557− struct netdev_queue *txq;
558574
559575 cq = container_of(napi, struct nicvf_cq_poll, napi);
560576 work_done = nicvf_cq_intr_handler(netdev, cq->cq_idx, napi, budget);
561577
562− txq = netdev_get_tx_queue(netdev, cq->cq_idx);
563− if (netif_tx_queue_stopped(txq))
564− netif_tx_wake_queue(txq);
565−
566578 if (work_done < budget) {
567579 /* Slow packet rate, exit polling */
568580 napi_complete(napi);
@@ -833,9 +845,9 @@ static netdev_tx_t nicvf_xmit(struct sk_buff *skb, struct net_device *netdev) · 264 unmodified lines
833845 return NETDEV_TX_OK;
834846 }
835847
836− if (!nicvf_sq_append_skb(nic, skb) && !netif_tx_queue_stopped(txq)) {
848+ if (!netif_tx_queue_stopped(txq) && !nicvf_sq_append_skb(nic, skb)) {
837849 netif_tx_stop_queue(txq);
838− nic->drv_stats.tx_busy++;
850+ nic->drv_stats.txq_stop++;
839851 if (netif_msg_tx_err(nic))
840852 netdev_warn(netdev,
841853 "%s: Transmit ring full, stopping SQ%d\n",
@@ -859,7 +871,6 @@ int nicvf_stop(struct net_device *netdev) · 17 unmodified lines
859871 nicvf_send_msg_to_pf(nic, &mbx);
860872
861873 netif_carrier_off(netdev);
862− netif_tx_disable(netdev);
863874
864875 /* Disable RBDR & QS error interrupts */
865876 for (qidx = 0; qidx < qs->rbdr_cnt; qidx++) {
@@ -894,6 +905,8 @@ int nicvf_stop(struct net_device *netdev) · 28 unmodified lines
894905 kfree(cq_poll);
895906 }
896907
908+ netif_tx_disable(netdev);
909+
897910 /* Free resources */
898911 nicvf_config_data_transfer(nic, false);
899912
@@ -988,6 +1001,9 @@ int nicvf_open(struct net_device *netdev) · 88 unmodified lines
9881001 for (qidx = 0; qidx < qs->rbdr_cnt; qidx++)
9891002 nicvf_enable_intr(nic, NICVF_INTR_RBDR, qidx);
9901003
1004+ nic->drv_stats.txq_stop = 0;
1005+ nic->drv_stats.txq_wake = 0;
1006+
9911007 netif_carrier_on(netdev);
9921008 netif_tx_start_all_queues(netdev);
9931009
@@ -1278,6 +1294,7 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 284 unmodified lines
12781294 netdev->hw_features = netdev->features;
12791295
12801296 netdev->netdev_ops = &nicvf_netdev_ops;
1297+ netdev->watchdog_timeo = NICVF_TX_TIMEOUT;
12811298
12821299 INIT_WORK(&nic->reset_task, nicvf_reset_task);
12831300
@@ -1318,11 +1335,17 @@ static void nicvf_remove(struct pci_dev *pdev) · 34 unmodified lines
13181335 pci_disable_device(pdev);
13191336 }
13201337
1338+static void nicvf_shutdown(struct pci_dev *pdev)
1339+{
1340+ nicvf_remove(pdev);
1341+}
1342+
13211343 static struct pci_driver nicvf_driver = {
13221344 .name = DRV_NAME,
13231345 .id_table = nicvf_id_table,
13241346 .probe = nicvf_probe,
13251347 .remove = nicvf_remove,
1348+ .shutdown = nicvf_shutdown,
13261349 };
13271350
13281351 static int __init nicvf_init_module(void)
drivers/net/ethernet/cavium/thunder/nicvf_queues.c+11−6
@@ -103,9 +103,11 @@ static inline int nicvf_alloc_rcv_buffer(struct nicvf *nic, gfp_t gfp, · 102 unmodified lines
103103
104104 /* Allocate a new page */
105105 if (!nic->rb_page) {
106− nic->rb_page = alloc_pages(gfp | __GFP_COMP, order);
106+ nic->rb_page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN,
107+ order);
107108 if (!nic->rb_page) {
108− netdev_err(nic->netdev, "Failed to allocate new rcv buffer\n");
109+ netdev_err(nic->netdev,
110+ "Failed to allocate new rcv buffer\n");
109111 return -ENOMEM;
110112 }
111113 nic->rb_page_offset = 0;
@@ -382,7 +384,8 @@ static void nicvf_free_snd_queue(struct nicvf *nic, struct snd_queue *sq) · 270 unmodified lines
382384 return;
383385
384386 if (sq->tso_hdrs)
385− dma_free_coherent(&nic->pdev->dev, sq->dmem.q_len,
387+ dma_free_coherent(&nic->pdev->dev,
388+ sq->dmem.q_len * TSO_HEADER_SIZE,
386389 sq->tso_hdrs, sq->tso_hdrs_phys);
387390
388391 kfree(sq->skbuff);
@@ -863,10 +866,11 @@ void nicvf_sq_free_used_descs(struct net_device *netdev, struct snd_queue *sq, · 474 unmodified lines
863866 continue;
864867 }
865868 skb = (struct sk_buff *)sq->skbuff[sq->head];
869+ if (skb)
870+ dev_kfree_skb_any(skb);
866871 atomic64_add(1, (atomic64_t *)&netdev->stats.tx_packets);
867872 atomic64_add(hdr->tot_len,
868873 (atomic64_t *)&netdev->stats.tx_bytes);
869− dev_kfree_skb_any(skb);
870874 nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1);
871875 }
872876 }
@@ -992,7 +996,7 @@ static inline void nicvf_sq_add_gather_subdesc(struct snd_queue *sq, int qentry, · 119 unmodified lines
992996
993997 memset(gather, 0, SND_QUEUE_DESC_SIZE);
994998 gather->subdesc_type = SQ_DESC_TYPE_GATHER;
995− gather->ld_type = NIC_SEND_LD_TYPE_E_LDWB;
999+ gather->ld_type = NIC_SEND_LD_TYPE_E_LDD;
9961000 gather->size = size;
9971001 gather->addr = data;
9981002 }
@@ -1048,7 +1052,7 @@ static int nicvf_sq_append_tso(struct nicvf *nic, struct snd_queue *sq, · 49 unmodified lines
10481052 }
10491053 nicvf_sq_add_hdr_subdesc(sq, hdr_qentry,
10501054 seg_subdescs - 1, skb, seg_len);
1051− sq->skbuff[hdr_qentry] = 0;
1055+ sq->skbuff[hdr_qentry] = (u64)NULL;
10521056 qentry = nicvf_get_nxt_sqentry(sq, qentry);
10531057
10541058 desc_cnt += seg_subdescs;
@@ -1062,6 +1066,7 @@ static int nicvf_sq_append_tso(struct nicvf *nic, struct snd_queue *sq, · 7 unmodified lines
10621066 /* Inform HW to xmit all TSO segments */
10631067 nicvf_queue_reg_write(nic, NIC_QSET_SQ_0_7_DOOR,
10641068 skb_get_queue_mapping(skb), desc_cnt);
1069+ nic->drv_stats.tx_tso++;
10651070 return 1;
10661071 }
10671072
drivers/net/ethernet/cavium/thunder/nicvf_queues.h+11−3
@@ -62,7 +62,7 @@ · 61 unmodified lines
6262 #define SND_QUEUE_CNT 8
6363 #define CMP_QUEUE_CNT 8 /* Max of RCV and SND qcount */
6464
65−#define SND_QSIZE SND_QUEUE_SIZE4
65+#define SND_QSIZE SND_QUEUE_SIZE2
6666 #define SND_QUEUE_LEN (1ULL << (SND_QSIZE + 10))
6767 #define MAX_SND_QUEUE_LEN (1ULL << (SND_QUEUE_SIZE6 + 10))
6868 #define SND_QUEUE_THRESH 2ULL
@@ -70,7 +70,10 @@ · 1 unmodified line
7070 /* Since timestamp not enabled, otherwise 2 */
7171 #define MAX_CQE_PER_PKT_XMIT 1
7272
73−#define CMP_QSIZE CMP_QUEUE_SIZE4
73+/* Keep CQ and SQ sizes same, if timestamping
74+ * is enabled this equation will change.
75+ */
76+#define CMP_QSIZE CMP_QUEUE_SIZE2
7477 #define CMP_QUEUE_LEN (1ULL << (CMP_QSIZE + 10))
7578 #define CMP_QUEUE_CQE_THRESH 0
7679 #define CMP_QUEUE_TIMER_THRESH 220 /* 10usec */
@@ -87,7 +90,12 @@ · 10 unmodified lines
8790
8891 #define MAX_CQES_FOR_TX ((SND_QUEUE_LEN / MIN_SQ_DESC_PER_PKT_XMIT) * \
8992 MAX_CQE_PER_PKT_XMIT)
90−#define RQ_CQ_DROP ((CMP_QUEUE_LEN - MAX_CQES_FOR_TX) / 256)
93+/* Calculate number of CQEs to reserve for all SQEs.
94+ * Its 1/256th level of CQ size.
95+ * '+ 1' to account for pipelining
96+ */
97+#define RQ_CQ_DROP ((256 / (CMP_QUEUE_LEN / \
98+ (CMP_QUEUE_LEN - MAX_CQES_FOR_TX))) + 1)
9199
92100 /* Descriptor size in bytes */
93101 #define SND_QUEUE_DESC_SIZE 16
drivers/net/ethernet/cavium/thunder/thunder_bgx.c+4−1
@@ -673,7 +673,10 @@ static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid) · 672 unmodified lines
673673 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cmrx_cfg);
674674 bgx_flush_dmac_addrs(bgx, lmacid);
675675
676− if (lmac->phydev)
676+ if ((bgx->lmac_type != BGX_MODE_XFI) &&
677+ (bgx->lmac_type != BGX_MODE_XLAUI) &&
678+ (bgx->lmac_type != BGX_MODE_40G_KR) &&
679+ (bgx->lmac_type != BGX_MODE_10G_KR) && lmac->phydev)
677680 phy_disconnect(lmac->phydev);
678681
679682 lmac->phydev = NULL;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c+2−1
@@ -2332,10 +2332,11 @@ int t4_setup_debugfs(struct adapter *adap) · 2331 unmodified lines
23322332 EXT_MEM1_SIZE_G(size));
23332333 }
23342334 } else {
2335− if (i & EXT_MEM_ENABLE_F)
2335+ if (i & EXT_MEM_ENABLE_F) {
23362336 size = t4_read_reg(adap, MA_EXT_MEMORY_BAR_A);
23372337 add_debugfs_mem(adap, "mc", MEM_MC,
23382338 EXT_MEM_SIZE_G(size));
2339+ }
23392340 }
23402341
23412342 de = debugfs_create_file_size("flash", S_IRUSR, adap->debugfs_root, adap,
drivers/net/ethernet/emulex/benet/be_cmds.h+5−0
@@ -620,6 +620,11 @@ enum be_if_flags { · 619 unmodified lines
620620 BE_IF_FLAGS_VLAN_PROMISCUOUS |\
621621 BE_IF_FLAGS_MCAST_PROMISCUOUS)
622622
623+#define BE_IF_EN_FLAGS (BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_PASS_L3L4_ERRORS |\
624+ BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_UNTAGGED)
625+
626+#define BE_IF_ALL_FILT_FLAGS (BE_IF_EN_FLAGS | BE_IF_FLAGS_ALL_PROMISCUOUS)
627+
623628 /* An RX interface is an object with one or more MAC addresses and
624629 * filtering capabilities. */
625630 struct be_cmd_req_if_create {
drivers/net/ethernet/emulex/benet/be_main.c+120−67
@@ -273,6 +273,10 @@ static int be_mac_addr_set(struct net_device *netdev, void *p) · 272 unmodified lines
273273 if (ether_addr_equal(addr->sa_data, netdev->dev_addr))
274274 return 0;
275275
276+ /* if device is not running, copy MAC to netdev->dev_addr */
277+ if (!netif_running(netdev))
278+ goto done;
279+
276280 /* The PMAC_ADD cmd may fail if the VF doesn't have FILTMGMT
277281 * privilege or if PF did not provision the new MAC address.
278282 * On BE3, this cmd will always fail if the VF doesn't have the
@@ -307,9 +311,9 @@ static int be_mac_addr_set(struct net_device *netdev, void *p) · 28 unmodified lines
307311 status = -EPERM;
308312 goto err;
309313 }
310−
311− memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
312− dev_info(dev, "MAC address changed to %pM\n", mac);
314+done:
315+ ether_addr_copy(netdev->dev_addr, addr->sa_data);
316+ dev_info(dev, "MAC address changed to %pM\n", addr->sa_data);
313317 return 0;
314318 err:
315319 dev_warn(dev, "MAC address change to %pM failed\n", addr->sa_data);
@@ -2447,10 +2451,24 @@ static void be_eq_clean(struct be_eq_obj *eqo) · 2131 unmodified lines
24472451 be_eq_notify(eqo->adapter, eqo->q.id, false, true, num, 0);
24482452 }
24492453
2450−static void be_rx_cq_clean(struct be_rx_obj *rxo)
2454+/* Free posted rx buffers that were not used */
2455+static void be_rxq_clean(struct be_rx_obj *rxo)
24512456 {
2452− struct be_rx_page_info *page_info;
24532457 struct be_queue_info *rxq = &rxo->q;
2458+ struct be_rx_page_info *page_info;
2459+
2460+ while (atomic_read(&rxq->used) > 0) {
2461+ page_info = get_rx_page_info(rxo);
2462+ put_page(page_info->page);
2463+ memset(page_info, 0, sizeof(*page_info));
2464+ }
2465+ BUG_ON(atomic_read(&rxq->used));
2466+ rxq->tail = 0;
2467+ rxq->head = 0;
2468+}
2469+
2470+static void be_rx_cq_clean(struct be_rx_obj *rxo)
2471+{
24542472 struct be_queue_info *rx_cq = &rxo->cq;
24552473 struct be_rx_compl_info *rxcp;
24562474 struct be_adapter *adapter = rxo->adapter;
@@ -2487,16 +2505,6 @@ static void be_rx_cq_clean(struct be_rx_obj *rxo) · 30 unmodified lines
24872505
24882506 /* After cleanup, leave the CQ in unarmed state */
24892507 be_cq_notify(adapter, rx_cq->id, false, 0);
2490−
2491− /* Then free posted rx buffers that were not used */
2492− while (atomic_read(&rxq->used) > 0) {
2493− page_info = get_rx_page_info(rxo);
2494− put_page(page_info->page);
2495− memset(page_info, 0, sizeof(*page_info));
2496− }
2497− BUG_ON(atomic_read(&rxq->used));
2498− rxq->tail = 0;
2499− rxq->head = 0;
25002508 }
25012509
25022510 static void be_tx_compl_clean(struct be_adapter *adapter)
@@ -2576,8 +2584,8 @@ static void be_evt_queues_destroy(struct be_adapter *adapter) · 73 unmodified lines
25762584 be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ);
25772585 napi_hash_del(&eqo->napi);
25782586 netif_napi_del(&eqo->napi);
2587+ free_cpumask_var(eqo->affinity_mask);
25792588 }
2580− free_cpumask_var(eqo->affinity_mask);
25812589 be_queue_free(adapter, &eqo->q);
25822590 }
25832591 }
@@ -2594,13 +2602,7 @@ static int be_evt_queues_create(struct be_adapter *adapter) · 10 unmodified lines
25942602
25952603 for_all_evt_queues(adapter, eqo, i) {
25962604 int numa_node = dev_to_node(&adapter->pdev->dev);
2597− if (!zalloc_cpumask_var(&eqo->affinity_mask, GFP_KERNEL))
2598− return -ENOMEM;
2599− cpumask_set_cpu(cpumask_local_spread(i, numa_node),
2600− eqo->affinity_mask);
2601− netif_napi_add(adapter->netdev, &eqo->napi, be_poll,
2602− BE_NAPI_WEIGHT);
2603− napi_hash_add(&eqo->napi);
2605+
26042606 aic = &adapter->aic_obj[i];
26052607 eqo->adapter = adapter;
26062608 eqo->idx = i;
@@ -2616,6 +2618,14 @@ static int be_evt_queues_create(struct be_adapter *adapter) · 9 unmodified lines
26162618 rc = be_cmd_eq_create(adapter, eqo);
26172619 if (rc)
26182620 return rc;
2621+
2622+ if (!zalloc_cpumask_var(&eqo->affinity_mask, GFP_KERNEL))
2623+ return -ENOMEM;
2624+ cpumask_set_cpu(cpumask_local_spread(i, numa_node),
2625+ eqo->affinity_mask);
2626+ netif_napi_add(adapter->netdev, &eqo->napi, be_poll,
2627+ BE_NAPI_WEIGHT);
2628+ napi_hash_add(&eqo->napi);
26192629 }
26202630 return 0;
26212631 }
@@ -3354,13 +3364,54 @@ static void be_rx_qs_destroy(struct be_adapter *adapter) · 732 unmodified lines
33543364 for_all_rx_queues(adapter, rxo, i) {
33553365 q = &rxo->q;
33563366 if (q->created) {
3367+ /* If RXQs are destroyed while in an "out of buffer"
3368+ * state, there is a possibility of an HW stall on
3369+ * Lancer. So, post 64 buffers to each queue to relieve
3370+ * the "out of buffer" condition.
3371+ * Make sure there's space in the RXQ before posting.
3372+ */
3373+ if (lancer_chip(adapter)) {
3374+ be_rx_cq_clean(rxo);
3375+ if (atomic_read(&q->used) == 0)
3376+ be_post_rx_frags(rxo, GFP_KERNEL,
3377+ MAX_RX_POST);
3378+ }
3379+
33573380 be_cmd_rxq_destroy(adapter, q);
33583381 be_rx_cq_clean(rxo);
3382+ be_rxq_clean(rxo);
33593383 }
33603384 be_queue_free(adapter, q);
33613385 }
33623386 }
33633387
3388+static void be_disable_if_filters(struct be_adapter *adapter)
3389+{
3390+ be_cmd_pmac_del(adapter, adapter->if_handle,
3391+ adapter->pmac_id[0], 0);
3392+
3393+ be_clear_uc_list(adapter);
3394+
3395+ /* The IFACE flags are enabled in the open path and cleared
3396+ * in the close path. When a VF gets detached from the host and
3397+ * assigned to a VM the following happens:
3398+ * - VF's IFACE flags get cleared in the detach path
3399+ * - IFACE create is issued by the VF in the attach path
3400+ * Due to a bug in the BE3/Skyhawk-R FW
3401+ * (Lancer FW doesn't have the bug), the IFACE capability flags
3402+ * specified along with the IFACE create cmd issued by a VF are not
3403+ * honoured by FW. As a consequence, if a *new* driver
3404+ * (that enables/disables IFACE flags in open/close)
3405+ * is loaded in the host and an *old* driver is * used by a VM/VF,
3406+ * the IFACE gets created *without* the needed flags.
3407+ * To avoid this, disable RX-filter flags only for Lancer.
3408+ */
3409+ if (lancer_chip(adapter)) {
3410+ be_cmd_rx_filter(adapter, BE_IF_ALL_FILT_FLAGS, OFF);
3411+ adapter->if_flags &= ~BE_IF_ALL_FILT_FLAGS;
3412+ }
3413+}
3414+
33643415 static int be_close(struct net_device *netdev)
33653416 {
33663417 struct be_adapter *adapter = netdev_priv(netdev);
@@ -3373,6 +3424,8 @@ static int be_close(struct net_device *netdev) · 6 unmodified lines
33733424 if (!(adapter->flags & BE_FLAGS_SETUP_DONE))
33743425 return 0;
33753426
3427+ be_disable_if_filters(adapter);
3428+
33763429 be_roce_dev_close(adapter);
33773430
33783431 if (adapter->flags & BE_FLAGS_NAPI_ENABLED) {
@@ -3392,7 +3445,6 @@ static int be_close(struct net_device *netdev) · 13 unmodified lines
33923445 be_tx_compl_clean(adapter);
33933446
33943447 be_rx_qs_destroy(adapter);
3395− be_clear_uc_list(adapter);
33963448
33973449 for_all_evt_queues(adapter, eqo, i) {
33983450 if (msix_enabled(adapter))
@@ -3477,6 +3529,31 @@ static int be_rx_qs_create(struct be_adapter *adapter) · 78 unmodified lines
34773529 return 0;
34783530 }
34793531
3532+static int be_enable_if_filters(struct be_adapter *adapter)
3533+{
3534+ int status;
3535+
3536+ status = be_cmd_rx_filter(adapter, BE_IF_EN_FLAGS, ON);
3537+ if (status)
3538+ return status;
3539+
3540+ /* For BE3 VFs, the PF programs the initial MAC address */
3541+ if (!(BEx_chip(adapter) && be_virtfn(adapter))) {
3542+ status = be_cmd_pmac_add(adapter, adapter->netdev->dev_addr,
3543+ adapter->if_handle,
3544+ &adapter->pmac_id[0], 0);
3545+ if (status)
3546+ return status;
3547+ }
3548+
3549+ if (adapter->vlans_added)
3550+ be_vid_config(adapter);
3551+
3552+ be_set_rx_mode(adapter->netdev);
3553+
3554+ return 0;
3555+}
3556+
34803557 static int be_open(struct net_device *netdev)
34813558 {
34823559 struct be_adapter *adapter = netdev_priv(netdev);
@@ -3490,6 +3567,10 @@ static int be_open(struct net_device *netdev) · 7 unmodified lines
34903567 if (status)
34913568 goto err;
34923569
3570+ status = be_enable_if_filters(adapter);
3571+ if (status)
3572+ goto err;
3573+
34933574 status = be_irq_register(adapter);
34943575 if (status)
34953576 goto err;
@@ -3686,16 +3767,6 @@ static void be_cancel_err_detection(struct be_adapter *adapter) · 190 unmodified lines
36863767 }
36873768 }
36883769
3689−static void be_mac_clear(struct be_adapter *adapter)
3690−{
3691− if (adapter->pmac_id) {
3692− be_cmd_pmac_del(adapter, adapter->if_handle,
3693− adapter->pmac_id[0], 0);
3694− kfree(adapter->pmac_id);
3695− adapter->pmac_id = NULL;
3696− }
3697−}
3698−
36993770 #ifdef CONFIG_BE2NET_VXLAN
37003771 static void be_disable_vxlan_offloads(struct be_adapter *adapter)
37013772 {
@@ -3770,8 +3841,8 @@ static int be_clear(struct be_adapter *adapter) · 68 unmodified lines
37703841 #ifdef CONFIG_BE2NET_VXLAN
37713842 be_disable_vxlan_offloads(adapter);
37723843 #endif
3773− /* delete the primary mac along with the uc-mac list */
3774− be_mac_clear(adapter);
3844+ kfree(adapter->pmac_id);
3845+ adapter->pmac_id = NULL;
37753846
37763847 be_cmd_if_destroy(adapter, adapter->if_handle, 0);
37773848
@@ -3782,25 +3853,11 @@ static int be_clear(struct be_adapter *adapter) · 4 unmodified lines
37823853 return 0;
37833854 }
37843855
3785−static int be_if_create(struct be_adapter *adapter, u32 *if_handle,
3786− u32 cap_flags, u32 vf)
3787−{
3788− u32 en_flags;
3789−
3790− en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
3791− BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS |
3792− BE_IF_FLAGS_RSS | BE_IF_FLAGS_DEFQ_RSS;
3793−
3794− en_flags &= cap_flags;
3795−
3796− return be_cmd_if_create(adapter, cap_flags, en_flags, if_handle, vf);
3797−}
3798−
37993856 static int be_vfs_if_create(struct be_adapter *adapter)
38003857 {
38013858 struct be_resources res = {0};
3859+ u32 cap_flags, en_flags, vf;
38023860 struct be_vf_cfg *vf_cfg;
3803− u32 cap_flags, vf;
38043861 int status;
38053862
38063863 /* If a FW profile exists, then cap_flags are updated */
@@ -3821,8 +3878,12 @@ static int be_vfs_if_create(struct be_adapter *adapter) · 14 unmodified lines
38213878 }
38223879 }
38233880
3824− status = be_if_create(adapter, &vf_cfg->if_handle,
3825− cap_flags, vf + 1);
3881+ en_flags = cap_flags & (BE_IF_FLAGS_UNTAGGED |
3882+ BE_IF_FLAGS_BROADCAST |
3883+ BE_IF_FLAGS_MULTICAST |
3884+ BE_IF_FLAGS_PASS_L3L4_ERRORS);
3885+ status = be_cmd_if_create(adapter, cap_flags, en_flags,
3886+ &vf_cfg->if_handle, vf + 1);
38263887 if (status)
38273888 return status;
38283889 }
@@ -4194,15 +4255,8 @@ static int be_mac_setup(struct be_adapter *adapter) · 365 unmodified lines
41944255
41954256 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN);
41964257 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN);
4197− } else {
4198− /* Maybe the HW was reset; dev_addr must be re-programmed */
4199− memcpy(mac, adapter->netdev->dev_addr, ETH_ALEN);
42004258 }
42014259
4202− /* For BE3-R VFs, the PF programs the initial MAC address */
4203− if (!(BEx_chip(adapter) && be_virtfn(adapter)))
4204− be_cmd_pmac_add(adapter, mac, adapter->if_handle,
4205− &adapter->pmac_id[0], 0);
42064260 return 0;
42074261 }
42084262
@@ -4342,6 +4396,7 @@ static int be_func_init(struct be_adapter *adapter) · 133 unmodified lines
43424396 static int be_setup(struct be_adapter *adapter)
43434397 {
43444398 struct device *dev = &adapter->pdev->dev;
4399+ u32 en_flags;
43454400 int status;
43464401
43474402 status = be_func_init(adapter);
@@ -4364,8 +4419,11 @@ static int be_setup(struct be_adapter *adapter) · 16 unmodified lines
43644419 if (status)
43654420 goto err;
43664421
4367− status = be_if_create(adapter, &adapter->if_handle,
4368− be_if_cap_flags(adapter), 0);
4422+ /* will enable all the needed filter flags in be_open() */
4423+ en_flags = BE_IF_FLAGS_RSS | BE_IF_FLAGS_DEFQ_RSS;
4424+ en_flags = en_flags & be_if_cap_flags(adapter);
4425+ status = be_cmd_if_create(adapter, be_if_cap_flags(adapter), en_flags,
4426+ &adapter->if_handle, 0);
43694427 if (status)
43704428 goto err;
43714429
@@ -4391,11 +4449,6 @@ static int be_setup(struct be_adapter *adapter) · 19 unmodified lines
43914449 dev_err(dev, "Please upgrade firmware to version >= 4.0\n");
43924450 }
43934451
4394− if (adapter->vlans_added)
4395− be_vid_config(adapter);
4396−
4397− be_set_rx_mode(adapter->netdev);
4398−
43994452 status = be_cmd_set_flow_control(adapter, adapter->tx_fc,
44004453 adapter->rx_fc);
44014454 if (status)
drivers/net/ethernet/freescale/fec.h+1−0
@@ -562,6 +562,7 @@ struct fec_enet_private { · 561 unmodified lines
562562 };
563563
564564 void fec_ptp_init(struct platform_device *pdev);
565+void fec_ptp_stop(struct platform_device *pdev);
565566 void fec_ptp_start_cyclecounter(struct net_device *ndev);
566567 int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr);
567568 int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr);
drivers/net/ethernet/freescale/fec_main.c+81−18
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include <linux/module.h>
2525 #include <linux/kernel.h>
2626 #include <linux/string.h>
27+#include <linux/pm_runtime.h>
2728 #include <linux/ptrace.h>
2829 #include <linux/errno.h>
2930 #include <linux/ioport.h>
@@ -77,6 +78,7 @@ static void fec_enet_itr_coal_init(struct net_device *ndev); · 47 unmodified lines
7778 #define FEC_ENET_RAEM_V 0x8
7879 #define FEC_ENET_RAFL_V 0x8
7980 #define FEC_ENET_OPD_V 0xFFF0
81+#define FEC_MDIO_PM_TIMEOUT 100 /* ms */
8082
8183 static struct platform_device_id fec_devtype[] = {
8284 {
@@ -1767,7 +1769,13 @@ static void fec_enet_adjust_link(struct net_device *ndev) · 1684 unmodified lines
17671769 static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
17681770 {
17691771 struct fec_enet_private *fep = bus->priv;
1772+ struct device *dev = &fep->pdev->dev;
17701773 unsigned long time_left;
1774+ int ret = 0;
1775+
1776+ ret = pm_runtime_get_sync(dev);
1777+ if (IS_ERR_VALUE(ret))
1778+ return ret;
17711779
17721780 fep->mii_timeout = 0;
17731781 init_completion(&fep->mdio_done);
@@ -1783,18 +1791,30 @@ static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum) · 9 unmodified lines
17831791 if (time_left == 0) {
17841792 fep->mii_timeout = 1;
17851793 netdev_err(fep->netdev, "MDIO read timeout\n");
1786− return -ETIMEDOUT;
1794+ ret = -ETIMEDOUT;
1795+ goto out;
17871796 }
17881797
1789− /* return value */
1790− return FEC_MMFR_DATA(readl(fep->hwp + FEC_MII_DATA));
1798+ ret = FEC_MMFR_DATA(readl(fep->hwp + FEC_MII_DATA));
1799+
1800+out:
1801+ pm_runtime_mark_last_busy(dev);
1802+ pm_runtime_put_autosuspend(dev);
1803+
1804+ return ret;
17911805 }
17921806
17931807 static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
17941808 u16 value)
17951809 {
17961810 struct fec_enet_private *fep = bus->priv;
1811+ struct device *dev = &fep->pdev->dev;
17971812 unsigned long time_left;
1813+ int ret = 0;
1814+
1815+ ret = pm_runtime_get_sync(dev);
1816+ if (IS_ERR_VALUE(ret))
1817+ return ret;
17981818
17991819 fep->mii_timeout = 0;
18001820 init_completion(&fep->mdio_done);
@@ -1811,10 +1831,13 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum, · 10 unmodified lines
18111831 if (time_left == 0) {
18121832 fep->mii_timeout = 1;
18131833 netdev_err(fep->netdev, "MDIO write timeout\n");
1814− return -ETIMEDOUT;
1834+ ret = -ETIMEDOUT;
18151835 }
18161836
1817− return 0;
1837+ pm_runtime_mark_last_busy(dev);
1838+ pm_runtime_put_autosuspend(dev);
1839+
1840+ return ret;
18181841 }
18191842
18201843 static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
@@ -1826,9 +1849,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) · 5 unmodified lines
18261849 ret = clk_prepare_enable(fep->clk_ahb);
18271850 if (ret)
18281851 return ret;
1829− ret = clk_prepare_enable(fep->clk_ipg);
1830− if (ret)
1831− goto failed_clk_ipg;
18321852 if (fep->clk_enet_out) {
18331853 ret = clk_prepare_enable(fep->clk_enet_out);
18341854 if (ret)
@@ -1852,7 +1872,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) · 17 unmodified lines
18521872 }
18531873 } else {
18541874 clk_disable_unprepare(fep->clk_ahb);
1855− clk_disable_unprepare(fep->clk_ipg);
18561875 if (fep->clk_enet_out)
18571876 clk_disable_unprepare(fep->clk_enet_out);
18581877 if (fep->clk_ptp) {
@@ -1874,8 +1893,6 @@ failed_clk_ptp: · 15 unmodified lines
18741893 if (fep->clk_enet_out)
18751894 clk_disable_unprepare(fep->clk_enet_out);
18761895 failed_clk_enet_out:
1877− clk_disable_unprepare(fep->clk_ipg);
1878−failed_clk_ipg:
18791896 clk_disable_unprepare(fep->clk_ahb);
18801897
18811898 return ret;
@@ -2847,10 +2864,14 @@ fec_enet_open(struct net_device *ndev) · 965 unmodified lines
28472864 struct fec_enet_private *fep = netdev_priv(ndev);
28482865 int ret;
28492866
2867+ ret = pm_runtime_get_sync(&fep->pdev->dev);
2868+ if (IS_ERR_VALUE(ret))
2869+ return ret;
2870+
28502871 pinctrl_pm_select_default_state(&fep->pdev->dev);
28512872 ret = fec_enet_clk_enable(ndev, true);
28522873 if (ret)
2853− return ret;
2874+ goto clk_enable;
28542875
28552876 /* I should reset the ring buffers here, but I don't yet know
28562877 * a simple way to do that.
@@ -2881,6 +2902,9 @@ err_enet_mii_probe: · 24 unmodified lines
28812902 fec_enet_free_buffers(ndev);
28822903 err_enet_alloc:
28832904 fec_enet_clk_enable(ndev, false);
2905+clk_enable:
2906+ pm_runtime_mark_last_busy(&fep->pdev->dev);
2907+ pm_runtime_put_autosuspend(&fep->pdev->dev);
28842908 pinctrl_pm_select_sleep_state(&fep->pdev->dev);
28852909 return ret;
28862910 }
@@ -2903,6 +2927,9 @@ fec_enet_close(struct net_device *ndev) · 16 unmodified lines
29032927
29042928 fec_enet_clk_enable(ndev, false);
29052929 pinctrl_pm_select_sleep_state(&fep->pdev->dev);
2930+ pm_runtime_mark_last_busy(&fep->pdev->dev);
2931+ pm_runtime_put_autosuspend(&fep->pdev->dev);
2932+
29062933 fec_enet_free_buffers(ndev);
29072934
29082935 return 0;
@@ -3115,8 +3142,8 @@ static int fec_enet_init(struct net_device *ndev) · 206 unmodified lines
31153142 fep->bufdesc_size;
31163143
31173144 /* Allocate memory for buffer descriptors. */
3118− cbd_base = dma_alloc_coherent(NULL, bd_size, &bd_dma,
3119− GFP_KERNEL);
3145+ cbd_base = dmam_alloc_coherent(&fep->pdev->dev, bd_size, &bd_dma,
3146+ GFP_KERNEL);
31203147 if (!cbd_base) {
31213148 return -ENOMEM;
31223149 }
@@ -3388,6 +3415,10 @@ fec_probe(struct platform_device *pdev) · 265 unmodified lines
33883415 if (ret)
33893416 goto failed_clk;
33903417
3418+ ret = clk_prepare_enable(fep->clk_ipg);
3419+ if (ret)
3420+ goto failed_clk_ipg;
3421+
33913422 fep->reg_phy = devm_regulator_get(&pdev->dev, "phy");
33923423 if (!IS_ERR(fep->reg_phy)) {
33933424 ret = regulator_enable(fep->reg_phy);
@@ -3400,6 +3431,12 @@ fec_probe(struct platform_device *pdev) · 6 unmodified lines
34003431 fep->reg_phy = NULL;
34013432 }
34023433
3434+ pm_runtime_set_autosuspend_delay(&pdev->dev, FEC_MDIO_PM_TIMEOUT);
3435+ pm_runtime_use_autosuspend(&pdev->dev);
3436+ pm_runtime_get_noresume(&pdev->dev);
3437+ pm_runtime_set_active(&pdev->dev);
3438+ pm_runtime_enable(&pdev->dev);
3439+
34033440 fec_reset_phy(pdev);
34043441
34053442 if (fep->bufdesc_ex)
@@ -3447,6 +3484,10 @@ fec_probe(struct platform_device *pdev) · 41 unmodified lines
34473484
34483485 fep->rx_copybreak = COPYBREAK_DEFAULT;
34493486 INIT_WORK(&fep->tx_timeout_work, fec_enet_timeout_work);
3487+
3488+ pm_runtime_mark_last_busy(&pdev->dev);
3489+ pm_runtime_put_autosuspend(&pdev->dev);
3490+
34503491 return 0;
34513492
34523493 failed_register:
@@ -3454,9 +3495,12 @@ failed_register: · 1 unmodified line
34543495 failed_mii_init:
34553496 failed_irq:
34563497 failed_init:
3498+ fec_ptp_stop(pdev);
34573499 if (fep->reg_phy)
34583500 regulator_disable(fep->reg_phy);
34593501 failed_regulator:
3502+ clk_disable_unprepare(fep->clk_ipg);
3503+failed_clk_ipg:
34603504 fec_enet_clk_enable(ndev, false);
34613505 failed_clk:
34623506 failed_phy:
@@ -3473,14 +3517,12 @@ fec_drv_remove(struct platform_device *pdev) · 10 unmodified lines
34733517 struct net_device *ndev = platform_get_drvdata(pdev);
34743518 struct fec_enet_private *fep = netdev_priv(ndev);
34753519
3476− cancel_delayed_work_sync(&fep->time_keep);
34773520 cancel_work_sync(&fep->tx_timeout_work);
3521+ fec_ptp_stop(pdev);
34783522 unregister_netdev(ndev);
34793523 fec_enet_mii_remove(fep);
34803524 if (fep->reg_phy)
34813525 regulator_disable(fep->reg_phy);
3482− if (fep->ptp_clock)
3483− ptp_clock_unregister(fep->ptp_clock);
34843526 of_node_put(fep->phy_node);
34853527 free_netdev(ndev);
34863528
@@ -3568,7 +3610,28 @@ failed_clk: · 81 unmodified lines
35683610 return ret;
35693611 }
35703612
3571−static SIMPLE_DEV_PM_OPS(fec_pm_ops, fec_suspend, fec_resume);
3613+static int __maybe_unused fec_runtime_suspend(struct device *dev)
3614+{
3615+ struct net_device *ndev = dev_get_drvdata(dev);
3616+ struct fec_enet_private *fep = netdev_priv(ndev);
3617+
3618+ clk_disable_unprepare(fep->clk_ipg);
3619+
3620+ return 0;
3621+}
3622+
3623+static int __maybe_unused fec_runtime_resume(struct device *dev)
3624+{
3625+ struct net_device *ndev = dev_get_drvdata(dev);
3626+ struct fec_enet_private *fep = netdev_priv(ndev);
3627+
3628+ return clk_prepare_enable(fep->clk_ipg);
3629+}
3630+
3631+static const struct dev_pm_ops fec_pm_ops = {
3632+ SET_SYSTEM_SLEEP_PM_OPS(fec_suspend, fec_resume)
3633+ SET_RUNTIME_PM_OPS(fec_runtime_suspend, fec_runtime_resume, NULL)
3634+};
35723635
35733636 static struct platform_driver fec_driver = {
35743637 .driver = {
drivers/net/ethernet/freescale/fec_ptp.c+10−0
@@ -604,6 +604,16 @@ void fec_ptp_init(struct platform_device *pdev) · 603 unmodified lines
604604 schedule_delayed_work(&fep->time_keep, HZ);
605605 }
606606
607+void fec_ptp_stop(struct platform_device *pdev)
608+{
609+ struct net_device *ndev = platform_get_drvdata(pdev);
610+ struct fec_enet_private *fep = netdev_priv(ndev);
611+
612+ cancel_delayed_work_sync(&fep->time_keep);
613+ if (fep->ptp_clock)
614+ ptp_clock_unregister(fep->ptp_clock);
615+}
616+
607617 /**
608618 * fec_ptp_check_pps_event
609619 * @fep: the fec_enet_private structure handle
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c+2−1
@@ -586,7 +586,8 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) · 585 unmodified lines
586586 frag = skb_shinfo(skb)->frags;
587587 while (nr_frags) {
588588 CBDC_SC(bdp,
589− BD_ENET_TX_STATS | BD_ENET_TX_LAST | BD_ENET_TX_TC);
589+ BD_ENET_TX_STATS | BD_ENET_TX_INTR | BD_ENET_TX_LAST |
590+ BD_ENET_TX_TC);
590591 CBDS_SC(bdp, BD_ENET_TX_READY);
591592
592593 if ((CBDR_SC(bdp) & BD_ENET_TX_WRAP) == 0)
drivers/net/ethernet/freescale/fs_enet/mac-fec.c+1−1
@@ -110,7 +110,7 @@ static int do_pd_setup(struct fs_enet_private *fep) · 109 unmodified lines
110110 }
111111
112112 #define FEC_NAPI_RX_EVENT_MSK (FEC_ENET_RXF | FEC_ENET_RXB)
113−#define FEC_NAPI_TX_EVENT_MSK (FEC_ENET_TXF | FEC_ENET_TXB)
113+#define FEC_NAPI_TX_EVENT_MSK (FEC_ENET_TXF)
114114 #define FEC_RX_EVENT (FEC_ENET_RXF)
115115 #define FEC_TX_EVENT (FEC_ENET_TXF)
116116 #define FEC_ERR_EVENT_MSK (FEC_ENET_HBERR | FEC_ENET_BABR | \
drivers/net/ethernet/freescale/gianfar.c+32−72
@@ -565,22 +565,6 @@ static void gfar_ints_enable(struct gfar_private *priv) · 564 unmodified lines
565565 }
566566 }
567567
568−static void lock_tx_qs(struct gfar_private *priv)
569−{
570− int i;
571−
572− for (i = 0; i < priv->num_tx_queues; i++)
573− spin_lock(&priv->tx_queue[i]->txlock);
574−}
575−
576−static void unlock_tx_qs(struct gfar_private *priv)
577−{
578− int i;
579−
580− for (i = 0; i < priv->num_tx_queues; i++)
581− spin_unlock(&priv->tx_queue[i]->txlock);
582−}
583−
584568 static int gfar_alloc_tx_queues(struct gfar_private *priv)
585569 {
586570 int i;
@@ -1376,7 +1360,6 @@ static int gfar_probe(struct platform_device *ofdev) · 789 unmodified lines
13761360 priv->dev = &ofdev->dev;
13771361 SET_NETDEV_DEV(dev, &ofdev->dev);
13781362
1379− spin_lock_init(&priv->bflock);
13801363 INIT_WORK(&priv->reset_task, gfar_reset_task);
13811364
13821365 platform_set_drvdata(ofdev, priv);
@@ -1470,9 +1453,8 @@ static int gfar_probe(struct platform_device *ofdev) · 87 unmodified lines
14701453 goto register_fail;
14711454 }
14721455
1473− device_init_wakeup(&dev->dev,
1474− priv->device_flags &
1475− FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
1456+ device_set_wakeup_capable(&dev->dev, priv->device_flags &
1457+ FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
14761458
14771459 /* fill out IRQ number and name fields */
14781460 for (i = 0; i < priv->num_grps; i++) {
@@ -1540,48 +1522,37 @@ static int gfar_suspend(struct device *dev) · 61 unmodified lines
15401522 struct gfar_private *priv = dev_get_drvdata(dev);
15411523 struct net_device *ndev = priv->ndev;
15421524 struct gfar __iomem *regs = priv->gfargrp[0].regs;
1543− unsigned long flags;
15441525 u32 tempval;
1545−
15461526 int magic_packet = priv->wol_en &&
15471527 (priv->device_flags &
15481528 FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
15491529
1530+ if (!netif_running(ndev))
1531+ return 0;
1532+
1533+ disable_napi(priv);
1534+ netif_tx_lock(ndev);
15501535 netif_device_detach(ndev);
1536+ netif_tx_unlock(ndev);
15511537
1552− if (netif_running(ndev)) {
1538+ gfar_halt(priv);
15531539
1554− local_irq_save(flags);
1555− lock_tx_qs(priv);
1540+ if (magic_packet) {
1541+ /* Enable interrupt on Magic Packet */
1542+ gfar_write(&regs->imask, IMASK_MAG);
15561543
1557− gfar_halt_nodisable(priv);
1544+ /* Enable Magic Packet mode */
1545+ tempval = gfar_read(&regs->maccfg2);
1546+ tempval |= MACCFG2_MPEN;
1547+ gfar_write(&regs->maccfg2, tempval);
15581548
1559− /* Disable Tx, and Rx if wake-on-LAN is disabled. */
1549+ /* re-enable the Rx block */
15601550 tempval = gfar_read(&regs->maccfg1);
1561−
1562− tempval &= ~MACCFG1_TX_EN;
1563−
1564− if (!magic_packet)
1565− tempval &= ~MACCFG1_RX_EN;
1566−
1551+ tempval |= MACCFG1_RX_EN;
15671552 gfar_write(&regs->maccfg1, tempval);
15681553
1569− unlock_tx_qs(priv);
1570− local_irq_restore(flags);
1571−
1572− disable_napi(priv);
1573−
1574− if (magic_packet) {
1575− /* Enable interrupt on Magic Packet */
1576− gfar_write(&regs->imask, IMASK_MAG);
1577−
1578− /* Enable Magic Packet mode */
1579− tempval = gfar_read(&regs->maccfg2);
1580− tempval |= MACCFG2_MPEN;
1581− gfar_write(&regs->maccfg2, tempval);
1582− } else {
1583− phy_stop(priv->phydev);
1584− }
1554+ } else {
1555+ phy_stop(priv->phydev);
15851556 }
15861557
15871558 return 0;
@@ -1592,37 +1563,26 @@ static int gfar_resume(struct device *dev) · 4 unmodified lines
15921563 struct gfar_private *priv = dev_get_drvdata(dev);
15931564 struct net_device *ndev = priv->ndev;
15941565 struct gfar __iomem *regs = priv->gfargrp[0].regs;
1595− unsigned long flags;
15961566 u32 tempval;
15971567 int magic_packet = priv->wol_en &&
15981568 (priv->device_flags &
15991569 FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
16001570
1601− if (!netif_running(ndev)) {
1602− netif_device_attach(ndev);
1571+ if (!netif_running(ndev))
16031572 return 0;
1604− }
16051573
1606− if (!magic_packet && priv->phydev)
1574+ if (magic_packet) {
1575+ /* Disable Magic Packet mode */
1576+ tempval = gfar_read(&regs->maccfg2);
1577+ tempval &= ~MACCFG2_MPEN;
1578+ gfar_write(&regs->maccfg2, tempval);
1579+ } else {
16071580 phy_start(priv->phydev);
1608−
1609− /* Disable Magic Packet mode, in case something
1610− * else woke us up.
1611− */
1612− local_irq_save(flags);
1613− lock_tx_qs(priv);
1614−
1615− tempval = gfar_read(&regs->maccfg2);
1616− tempval &= ~MACCFG2_MPEN;
1617− gfar_write(&regs->maccfg2, tempval);
1581+ }
16181582
16191583 gfar_start(priv);
16201584
1621− unlock_tx_qs(priv);
1622− local_irq_restore(flags);
1623−
16241585 netif_device_attach(ndev);
1625−
16261586 enable_napi(priv);
16271587
16281588 return 0;
@@ -2045,7 +2005,8 @@ static int register_grp_irqs(struct gfar_priv_grp *grp) · 416 unmodified lines
20452005 /* Install our interrupt handlers for Error,
20462006 * Transmit, and Receive
20472007 */
2048− err = request_irq(gfar_irq(grp, ER)->irq, gfar_error, 0,
2008+ err = request_irq(gfar_irq(grp, ER)->irq, gfar_error,
2009+ IRQF_NO_SUSPEND,
20492010 gfar_irq(grp, ER)->name, grp);
20502011 if (err < 0) {
20512012 netif_err(priv, intr, dev, "Can't get IRQ %d\n",
@@ -2068,7 +2029,8 @@ static int register_grp_irqs(struct gfar_priv_grp *grp) · 16 unmodified lines
20682029 goto rx_irq_fail;
20692030 }
20702031 } else {
2071− err = request_irq(gfar_irq(grp, TX)->irq, gfar_interrupt, 0,
2032+ err = request_irq(gfar_irq(grp, TX)->irq, gfar_interrupt,
2033+ IRQF_NO_SUSPEND,
20722034 gfar_irq(grp, TX)->name, grp);
20732035 if (err < 0) {
20742036 netif_err(priv, intr, dev, "Can't get IRQ %d\n",
@@ -2169,8 +2131,6 @@ static int gfar_enet_open(struct net_device *dev) · 94 unmodified lines
21692131 if (err)
21702132 return err;
21712133
2172− device_set_wakeup_enable(&dev->dev, priv->wol_en);
2173−
21742134 return err;
21752135 }
21762136
drivers/net/ethernet/freescale/gianfar.h+0−3
@@ -1145,9 +1145,6 @@ struct gfar_private { · 1144 unmodified lines
11451145 int oldduplex;
11461146 int oldlink;
11471147
1148− /* Bitfield update lock */
1149− spinlock_t bflock;
1150−
11511148 uint32_t msg_enable;
11521149
11531150 struct work_struct reset_task;
drivers/net/ethernet/freescale/gianfar_ethtool.c+5−345
@@ -653,7 +653,6 @@ static void gfar_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) · 652 unmodified lines
653653 static int gfar_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
654654 {
655655 struct gfar_private *priv = netdev_priv(dev);
656− unsigned long flags;
657656
658657 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) &&
659658 wol->wolopts != 0)
@@ -664,9 +663,7 @@ static int gfar_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) · 4 unmodified lines
664663
665664 device_set_wakeup_enable(&dev->dev, wol->wolopts & WAKE_MAGIC);
666665
667− spin_lock_irqsave(&priv->bflock, flags);
668− priv->wol_en = !!device_may_wakeup(&dev->dev);
669− spin_unlock_irqrestore(&priv->bflock, flags);
666+ priv->wol_en = !!device_may_wakeup(&dev->dev);
670667
671668 return 0;
672669 }
@@ -903,27 +900,6 @@ static int gfar_check_filer_hardware(struct gfar_private *priv) · 230 unmodified lines
903900 return 0;
904901 }
905902
906−static int gfar_comp_asc(const void *a, const void *b)
907−{
908− return memcmp(a, b, 4);
909−}
910−
911−static int gfar_comp_desc(const void *a, const void *b)
912−{
913− return -memcmp(a, b, 4);
914−}
915−
916−static void gfar_swap(void *a, void *b, int size)
917−{
918− u32 *_a = a;
919− u32 *_b = b;
920−
921− swap(_a[0], _b[0]);
922− swap(_a[1], _b[1]);
923− swap(_a[2], _b[2]);
924− swap(_a[3], _b[3]);
925−}
926−
927903 /* Write a mask to filer cache */
928904 static void gfar_set_mask(u32 mask, struct filer_table *tab)
929905 {
@@ -1273,310 +1249,6 @@ static int gfar_convert_to_filer(struct ethtool_rx_flow_spec *rule, · 343 unmodified lines
12731249 return 0;
12741250 }
12751251
1276−/* Copy size filer entries */
1277−static void gfar_copy_filer_entries(struct gfar_filer_entry dst[0],
1278− struct gfar_filer_entry src[0], s32 size)
1279−{
1280− while (size > 0) {
1281− size--;
1282− dst[size].ctrl = src[size].ctrl;
1283− dst[size].prop = src[size].prop;
1284− }
1285−}
1286−
1287−/* Delete the contents of the filer-table between start and end
1288− * and collapse them
1289− */
1290−static int gfar_trim_filer_entries(u32 begin, u32 end, struct filer_table *tab)
1291−{
1292− int length;
1293−
1294− if (end > MAX_FILER_CACHE_IDX || end < begin)
1295− return -EINVAL;
1296−
1297− end++;
1298− length = end - begin;
1299−
1300− /* Copy */
1301− while (end < tab->index) {
1302− tab->fe[begin].ctrl = tab->fe[end].ctrl;
1303− tab->fe[begin++].prop = tab->fe[end++].prop;
1304−
1305− }
1306− /* Fill up with don't cares */
1307− while (begin < tab->index) {
1308− tab->fe[begin].ctrl = 0x60;
1309− tab->fe[begin].prop = 0xFFFFFFFF;
1310− begin++;
1311− }
1312−
1313− tab->index -= length;
1314− return 0;
1315−}
1316−
1317−/* Make space on the wanted location */
1318−static int gfar_expand_filer_entries(u32 begin, u32 length,
1319− struct filer_table *tab)
1320−{
1321− if (length == 0 || length + tab->index > MAX_FILER_CACHE_IDX ||
1322− begin > MAX_FILER_CACHE_IDX)
1323− return -EINVAL;
1324−
1325− gfar_copy_filer_entries(&(tab->fe[begin + length]), &(tab->fe[begin]),
1326− tab->index - length + 1);
1327−
1328− tab->index += length;
1329− return 0;
1330−}
1331−
1332−static int gfar_get_next_cluster_start(int start, struct filer_table *tab)
1333−{
1334− for (; (start < tab->index) && (start < MAX_FILER_CACHE_IDX - 1);
1335− start++) {
1336− if ((tab->fe[start].ctrl & (RQFCR_AND | RQFCR_CLE)) ==
1337− (RQFCR_AND | RQFCR_CLE))
1338− return start;
1339− }
1340− return -1;
1341−}
1342−
1343−static int gfar_get_next_cluster_end(int start, struct filer_table *tab)
1344−{
1345− for (; (start < tab->index) && (start < MAX_FILER_CACHE_IDX - 1);
1346− start++) {
1347− if ((tab->fe[start].ctrl & (RQFCR_AND | RQFCR_CLE)) ==
1348− (RQFCR_CLE))
1349− return start;
1350− }
1351− return -1;
1352−}
1353−
1354−/* Uses hardwares clustering option to reduce
1355− * the number of filer table entries
1356− */
1357−static void gfar_cluster_filer(struct filer_table *tab)
1358−{
1359− s32 i = -1, j, iend, jend;
1360−
1361− while ((i = gfar_get_next_cluster_start(++i, tab)) != -1) {
1362− j = i;
1363− while ((j = gfar_get_next_cluster_start(++j, tab)) != -1) {
1364− /* The cluster entries self and the previous one
1365− * (a mask) must be identical!
1366− */
1367− if (tab->fe[i].ctrl != tab->fe[j].ctrl)
1368− break;
1369− if (tab->fe[i].prop != tab->fe[j].prop)
1370− break;
1371− if (tab->fe[i - 1].ctrl != tab->fe[j - 1].ctrl)
1372− break;
1373− if (tab->fe[i - 1].prop != tab->fe[j - 1].prop)
1374− break;
1375− iend = gfar_get_next_cluster_end(i, tab);
1376− jend = gfar_get_next_cluster_end(j, tab);
1377− if (jend == -1 || iend == -1)
1378− break;
1379−
1380− /* First we make some free space, where our cluster
1381− * element should be. Then we copy it there and finally
1382− * delete in from its old location.
1383− */
1384− if (gfar_expand_filer_entries(iend, (jend - j), tab) ==
1385− -EINVAL)
1386− break;
1387−
1388− gfar_copy_filer_entries(&(tab->fe[iend + 1]),
1389− &(tab->fe[jend + 1]), jend - j);
1390−
1391− if (gfar_trim_filer_entries(jend - 1,
1392− jend + (jend - j),
1393− tab) == -EINVAL)
1394− return;
1395−
1396− /* Mask out cluster bit */
1397− tab->fe[iend].ctrl &= ~(RQFCR_CLE);
1398− }
1399− }
1400−}
1401−
1402−/* Swaps the masked bits of a1<>a2 and b1<>b2 */
1403−static void gfar_swap_bits(struct gfar_filer_entry *a1,
1404− struct gfar_filer_entry *a2,
1405− struct gfar_filer_entry *b1,
1406− struct gfar_filer_entry *b2, u32 mask)
1407−{
1408− u32 temp[4];
1409− temp[0] = a1->ctrl & mask;
1410− temp[1] = a2->ctrl & mask;
1411− temp[2] = b1->ctrl & mask;
1412− temp[3] = b2->ctrl & mask;
1413−
1414− a1->ctrl &= ~mask;
1415− a2->ctrl &= ~mask;
1416− b1->ctrl &= ~mask;
1417− b2->ctrl &= ~mask;
1418−
1419− a1->ctrl |= temp[1];
1420− a2->ctrl |= temp[0];
1421− b1->ctrl |= temp[3];
1422− b2->ctrl |= temp[2];
1423−}
1424−
1425−/* Generate a list consisting of masks values with their start and
1426− * end of validity and block as indicator for parts belonging
1427− * together (glued by ANDs) in mask_table
1428− */
1429−static u32 gfar_generate_mask_table(struct gfar_mask_entry *mask_table,
1430− struct filer_table *tab)
1431−{
1432− u32 i, and_index = 0, block_index = 1;
1433−
1434− for (i = 0; i < tab->index; i++) {
1435−
1436− /* LSByte of control = 0 sets a mask */
1437− if (!(tab->fe[i].ctrl & 0xF)) {
1438− mask_table[and_index].mask = tab->fe[i].prop;
1439− mask_table[and_index].start = i;
1440− mask_table[and_index].block = block_index;
1441− if (and_index >= 1)
1442− mask_table[and_index - 1].end = i - 1;
1443− and_index++;
1444− }
1445− /* cluster starts and ends will be separated because they should
1446− * hold their position
1447− */
1448− if (tab->fe[i].ctrl & RQFCR_CLE)
1449− block_index++;
1450− /* A not set AND indicates the end of a depended block */
1451− if (!(tab->fe[i].ctrl & RQFCR_AND))
1452− block_index++;
1453− }
1454−
1455− mask_table[and_index - 1].end = i - 1;
1456−
1457− return and_index;
1458−}
1459−
1460−/* Sorts the entries of mask_table by the values of the masks.
1461− * Important: The 0xFF80 flags of the first and last entry of a
1462− * block must hold their position (which queue, CLusterEnable, ReJEct,
1463− * AND)
1464− */
1465−static void gfar_sort_mask_table(struct gfar_mask_entry *mask_table,
1466− struct filer_table *temp_table, u32 and_index)
1467−{
1468− /* Pointer to compare function (_asc or _desc) */
1469− int (*gfar_comp)(const void *, const void *);
1470−
1471− u32 i, size = 0, start = 0, prev = 1;
1472− u32 old_first, old_last, new_first, new_last;
1473−
1474− gfar_comp = &gfar_comp_desc;
1475−
1476− for (i = 0; i < and_index; i++) {
1477− if (prev != mask_table[i].block) {
1478− old_first = mask_table[start].start + 1;
1479− old_last = mask_table[i - 1].end;
1480− sort(mask_table + start, size,
1481− sizeof(struct gfar_mask_entry),
1482− gfar_comp, &gfar_swap);
1483−
1484− /* Toggle order for every block. This makes the
1485− * thing more efficient!
1486− */
1487− if (gfar_comp == gfar_comp_desc)
1488− gfar_comp = &gfar_comp_asc;
1489− else
1490− gfar_comp = &gfar_comp_desc;
1491−
1492− new_first = mask_table[start].start + 1;
1493− new_last = mask_table[i - 1].end;
1494−
1495− gfar_swap_bits(&temp_table->fe[new_first],
1496− &temp_table->fe[old_first],
1497− &temp_table->fe[new_last],
1498− &temp_table->fe[old_last],
1499− RQFCR_QUEUE | RQFCR_CLE |
1500− RQFCR_RJE | RQFCR_AND);
1501−
1502− start = i;
1503− size = 0;
1504− }
1505− size++;
1506− prev = mask_table[i].block;
1507− }
1508−}
1509−
1510−/* Reduces the number of masks needed in the filer table to save entries
1511− * This is done by sorting the masks of a depended block. A depended block is
1512− * identified by gluing ANDs or CLE. The sorting order toggles after every
1513− * block. Of course entries in scope of a mask must change their location with
1514− * it.
1515− */
1516−static int gfar_optimize_filer_masks(struct filer_table *tab)
1517−{
1518− struct filer_table *temp_table;
1519− struct gfar_mask_entry *mask_table;
1520−
1521− u32 and_index = 0, previous_mask = 0, i = 0, j = 0, size = 0;
1522− s32 ret = 0;
1523−
1524− /* We need a copy of the filer table because
1525− * we want to change its order
1526− */
1527− temp_table = kmemdup(tab, sizeof(*temp_table), GFP_KERNEL);
1528− if (temp_table == NULL)
1529− return -ENOMEM;
1530−
1531− mask_table = kcalloc(MAX_FILER_CACHE_IDX / 2 + 1,
1532− sizeof(struct gfar_mask_entry), GFP_KERNEL);
1533−
1534− if (mask_table == NULL) {
1535− ret = -ENOMEM;
1536− goto end;
1537− }
1538−
1539− and_index = gfar_generate_mask_table(mask_table, tab);
1540−
1541− gfar_sort_mask_table(mask_table, temp_table, and_index);
1542−
1543− /* Now we can copy the data from our duplicated filer table to
1544− * the real one in the order the mask table says
1545− */
1546− for (i = 0; i < and_index; i++) {
1547− size = mask_table[i].end - mask_table[i].start + 1;
1548− gfar_copy_filer_entries(&(tab->fe[j]),
1549− &(temp_table->fe[mask_table[i].start]), size);
1550− j += size;
1551− }
1552−
1553− /* And finally we just have to check for duplicated masks and drop the
1554− * second ones
1555− */
1556− for (i = 0; i < tab->index && i < MAX_FILER_CACHE_IDX; i++) {
1557− if (tab->fe[i].ctrl == 0x80) {
1558− previous_mask = i++;
1559− break;
1560− }
1561− }
1562− for (; i < tab->index && i < MAX_FILER_CACHE_IDX; i++) {
1563− if (tab->fe[i].ctrl == 0x80) {
1564− if (tab->fe[i].prop == tab->fe[previous_mask].prop) {
1565− /* Two identical ones found!
1566− * So drop the second one!
1567− */
1568− gfar_trim_filer_entries(i, i, tab);
1569− } else
1570− /* Not identical! */
1571− previous_mask = i;
1572− }
1573− }
1574−
1575− kfree(mask_table);
1576−end: kfree(temp_table);
1577− return ret;
1578−}
1579−
15801252 /* Write the bit-pattern from software's buffer to hardware registers */
15811253 static int gfar_write_filer_table(struct gfar_private *priv,
15821254 struct filer_table *tab)
@@ -1586,11 +1258,10 @@ static int gfar_write_filer_table(struct gfar_private *priv, · 3 unmodified lines
15861258 return -EBUSY;
15871259
15881260 /* Fill regular entries */
1589− for (; i < MAX_FILER_IDX - 1 && (tab->fe[i].ctrl | tab->fe[i].prop);
1590− i++)
1261+ for (; i < MAX_FILER_IDX && (tab->fe[i].ctrl | tab->fe[i].prop); i++)
15911262 gfar_write_filer(priv, i, tab->fe[i].ctrl, tab->fe[i].prop);
15921263 /* Fill the rest with fall-troughs */
1593− for (; i < MAX_FILER_IDX - 1; i++)
1264+ for (; i < MAX_FILER_IDX; i++)
15941265 gfar_write_filer(priv, i, 0x60, 0xFFFFFFFF);
15951266 /* Last entry must be default accept
15961267 * because that's what people expect
@@ -1624,7 +1295,6 @@ static int gfar_process_filer_changes(struct gfar_private *priv) · 27 unmodified lines
16241295 {
16251296 struct ethtool_flow_spec_container *j;
16261297 struct filer_table *tab;
1627− s32 i = 0;
16281298 s32 ret = 0;
16291299
16301300 /* So index is set to zero, too! */
@@ -1649,17 +1319,6 @@ static int gfar_process_filer_changes(struct gfar_private *priv) · 18 unmodified lines
16491319 }
16501320 }
16511321
1652− i = tab->index;
1653−
1654− /* Optimizations to save entries */
1655− gfar_cluster_filer(tab);
1656− gfar_optimize_filer_masks(tab);
1657−
1658− pr_debug("\tSummary:\n"
1659− "\tData on hardware: %d\n"
1660− "\tCompression rate: %d%%\n",
1661− tab->index, 100 - (100 * tab->index) / i);
1662−
16631322 /* Write everything to hardware */
16641323 ret = gfar_write_filer_table(priv, tab);
16651324 if (ret == -EBUSY) {
@@ -1725,13 +1384,14 @@ static int gfar_add_cls(struct gfar_private *priv, · 59 unmodified lines
17251384 }
17261385
17271386 process:
1387+ priv->rx_list.count++;
17281388 ret = gfar_process_filer_changes(priv);
17291389 if (ret)
17301390 goto clean_list;
1731− priv->rx_list.count++;
17321391 return ret;
17331392
17341393 clean_list:
1394+ priv->rx_list.count--;
17351395 list_del(&temp->list);
17361396 clean_mem:
17371397 kfree(temp);
drivers/net/ethernet/marvell/mvpp2.c+167−77
@@ -27,6 +27,8 @@ · 26 unmodified lines
2727 #include <linux/of_address.h>
2828 #include <linux/phy.h>
2929 #include <linux/clk.h>
30+#include <linux/hrtimer.h>
31+#include <linux/ktime.h>
3032 #include <uapi/linux/ppp_defs.h>
3133 #include <net/ip.h>
3234 #include <net/ipv6.h>
@@ -299,6 +301,7 @@ · 266 unmodified lines
299301
300302 /* Coalescing */
301303 #define MVPP2_TXDONE_COAL_PKTS_THRESH 15
304+#define MVPP2_TXDONE_HRTIMER_PERIOD_NS 1000000UL
302305 #define MVPP2_RX_COAL_PKTS 32
303306 #define MVPP2_RX_COAL_USEC 100
304307
@@ -660,6 +663,14 @@ struct mvpp2_pcpu_stats { · 355 unmodified lines
660663 u64 tx_bytes;
661664 };
662665
666+/* Per-CPU port control */
667+struct mvpp2_port_pcpu {
668+ struct hrtimer tx_done_timer;
669+ bool timer_scheduled;
670+ /* Tasklet for egress finalization */
671+ struct tasklet_struct tx_done_tasklet;
672+};
673+
663674 struct mvpp2_port {
664675 u8 id;
665676
@@ -679,6 +690,9 @@ struct mvpp2_port { · 13 unmodified lines
679690 u32 pending_cause_rx;
680691 struct napi_struct napi;
681692
693+ /* Per-CPU port control */
694+ struct mvpp2_port_pcpu __percpu *pcpu;
695+
682696 /* Flags */
683697 unsigned long flags;
684698
@@ -776,6 +790,9 @@ struct mvpp2_txq_pcpu { · 91 unmodified lines
776790 /* Array of transmitted skb */
777791 struct sk_buff **tx_skb;
778792
793+ /* Array of transmitted buffers' physical addresses */
794+ dma_addr_t *tx_buffs;
795+
779796 /* Index of last TX DMA descriptor that was inserted */
780797 int txq_put_index;
781798
@@ -913,8 +930,6 @@ struct mvpp2_bm_pool { · 131 unmodified lines
913930 /* Occupied buffers indicator */
914931 atomic_t in_use;
915932 int in_use_thresh;
916−
917− spinlock_t lock;
918933 };
919934
920935 struct mvpp2_buff_hdr {
@@ -963,9 +978,13 @@ static void mvpp2_txq_inc_get(struct mvpp2_txq_pcpu *txq_pcpu) · 42 unmodified lines
963978 }
964979
965980 static void mvpp2_txq_inc_put(struct mvpp2_txq_pcpu *txq_pcpu,
966− struct sk_buff *skb)
981+ struct sk_buff *skb,
982+ struct mvpp2_tx_desc *tx_desc)
967983 {
968984 txq_pcpu->tx_skb[txq_pcpu->txq_put_index] = skb;
985+ if (skb)
986+ txq_pcpu->tx_buffs[txq_pcpu->txq_put_index] =
987+ tx_desc->buf_phys_addr;
969988 txq_pcpu->txq_put_index++;
970989 if (txq_pcpu->txq_put_index == txq_pcpu->size)
971990 txq_pcpu->txq_put_index = 0;
@@ -3376,7 +3395,6 @@ static int mvpp2_bm_pool_create(struct platform_device *pdev, · 2404 unmodified lines
33763395 bm_pool->pkt_size = 0;
33773396 bm_pool->buf_num = 0;
33783397 atomic_set(&bm_pool->in_use, 0);
3379− spin_lock_init(&bm_pool->lock);
33803398
33813399 return 0;
33823400 }
@@ -3647,7 +3665,6 @@ static struct mvpp2_bm_pool * · 264 unmodified lines
36473665 mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type,
36483666 int pkt_size)
36493667 {
3650− unsigned long flags = 0;
36513668 struct mvpp2_bm_pool *new_pool = &port->priv->bm_pools[pool];
36523669 int num;
36533670
@@ -3656,8 +3673,6 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, · 2 unmodified lines
36563673 return NULL;
36573674 }
36583675
3659− spin_lock_irqsave(&new_pool->lock, flags);
3660−
36613676 if (new_pool->type == MVPP2_BM_FREE)
36623677 new_pool->type = type;
36633678
@@ -3686,8 +3701,6 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, · 22 unmodified lines
36863701 if (num != pkts_num) {
36873702 WARN(1, "pool %d: %d of %d allocated\n",
36883703 new_pool->id, num, pkts_num);
3689− /* We need to undo the bufs_add() allocations */
3690− spin_unlock_irqrestore(&new_pool->lock, flags);
36913704 return NULL;
36923705 }
36933706 }
@@ -3695,15 +3708,12 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, · 1 unmodified line
36953708 mvpp2_bm_pool_bufsize_set(port->priv, new_pool,
36963709 MVPP2_RX_BUF_SIZE(new_pool->pkt_size));
36973710
3698− spin_unlock_irqrestore(&new_pool->lock, flags);
3699−
37003711 return new_pool;
37013712 }
37023713
37033714 /* Initialize pools for swf */
37043715 static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port)
37053716 {
3706− unsigned long flags = 0;
37073717 int rxq;
37083718
37093719 if (!port->pool_long) {
@@ -3714,9 +3724,7 @@ static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port) · 4 unmodified lines
37143724 if (!port->pool_long)
37153725 return -ENOMEM;
37163726
3717− spin_lock_irqsave(&port->pool_long->lock, flags);
37183727 port->pool_long->port_map |= (1 << port->id);
3719− spin_unlock_irqrestore(&port->pool_long->lock, flags);
37203728
37213729 for (rxq = 0; rxq < rxq_number; rxq++)
37223730 mvpp2_rxq_long_pool_set(port, rxq, port->pool_long->id);
@@ -3730,9 +3738,7 @@ static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port) · 7 unmodified lines
37303738 if (!port->pool_short)
37313739 return -ENOMEM;
37323740
3733− spin_lock_irqsave(&port->pool_short->lock, flags);
37343741 port->pool_short->port_map |= (1 << port->id);
3735− spin_unlock_irqrestore(&port->pool_short->lock, flags);
37363742
37373743 for (rxq = 0; rxq < rxq_number; rxq++)
37383744 mvpp2_rxq_short_pool_set(port, rxq,
@@ -3806,7 +3812,6 @@ static void mvpp2_interrupts_unmask(void *arg) · 67 unmodified lines
38063812
38073813 mvpp2_write(port->priv, MVPP2_ISR_RX_TX_MASK_REG(port->id),
38083814 (MVPP2_CAUSE_MISC_SUM_MASK |
3809− MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK |
38103815 MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK));
38113816 }
38123817
@@ -4382,23 +4387,6 @@ static void mvpp2_rx_time_coal_set(struct mvpp2_port *port, · 569 unmodified lines
43824387 rxq->time_coal = usec;
43834388 }
43844389
4385−/* Set threshold for TX_DONE pkts coalescing */
4386−static void mvpp2_tx_done_pkts_coal_set(void *arg)
4387−{
4388− struct mvpp2_port *port = arg;
4389− int queue;
4390− u32 val;
4391−
4392− for (queue = 0; queue < txq_number; queue++) {
4393− struct mvpp2_tx_queue *txq = port->txqs[queue];
4394−
4395− val = (txq->done_pkts_coal << MVPP2_TRANSMITTED_THRESH_OFFSET) &
4396− MVPP2_TRANSMITTED_THRESH_MASK;
4397− mvpp2_write(port->priv, MVPP2_TXQ_NUM_REG, txq->id);
4398− mvpp2_write(port->priv, MVPP2_TXQ_THRESH_REG, val);
4399− }
4400−}
4401−
44024390 /* Free Tx queue skbuffs */
44034391 static void mvpp2_txq_bufs_free(struct mvpp2_port *port,
44044392 struct mvpp2_tx_queue *txq,
@@ -4407,8 +4395,8 @@ static void mvpp2_txq_bufs_free(struct mvpp2_port *port, · 2 unmodified lines
44074395 int i;
44084396
44094397 for (i = 0; i < num; i++) {
4410− struct mvpp2_tx_desc *tx_desc = txq->descs +
4411− txq_pcpu->txq_get_index;
4398+ dma_addr_t buf_phys_addr =
4399+ txq_pcpu->tx_buffs[txq_pcpu->txq_get_index];
44124400 struct sk_buff *skb = txq_pcpu->tx_skb[txq_pcpu->txq_get_index];
44134401
44144402 mvpp2_txq_inc_get(txq_pcpu);
@@ -4416,8 +4404,8 @@ static void mvpp2_txq_bufs_free(struct mvpp2_port *port, · 1 unmodified line
44164404 if (!skb)
44174405 continue;
44184406
4419− dma_unmap_single(port->dev->dev.parent, tx_desc->buf_phys_addr,
4420− tx_desc->data_size, DMA_TO_DEVICE);
4407+ dma_unmap_single(port->dev->dev.parent, buf_phys_addr,
4408+ skb_headlen(skb), DMA_TO_DEVICE);
44214409 dev_kfree_skb_any(skb);
44224410 }
44234411 }
@@ -4433,7 +4421,7 @@ static inline struct mvpp2_rx_queue *mvpp2_get_rx_queue(struct mvpp2_port *port, · 9 unmodified lines
44334421 static inline struct mvpp2_tx_queue *mvpp2_get_tx_queue(struct mvpp2_port *port,
44344422 u32 cause)
44354423 {
4436− int queue = fls(cause >> 16) - 1;
4424+ int queue = fls(cause) - 1;
44374425
44384426 return port->txqs[queue];
44394427 }
@@ -4460,6 +4448,29 @@ static void mvpp2_txq_done(struct mvpp2_port *port, struct mvpp2_tx_queue *txq, · 20 unmodified lines
44604448 netif_tx_wake_queue(nq);
44614449 }
44624450
4451+static unsigned int mvpp2_tx_done(struct mvpp2_port *port, u32 cause)
4452+{
4453+ struct mvpp2_tx_queue *txq;
4454+ struct mvpp2_txq_pcpu *txq_pcpu;
4455+ unsigned int tx_todo = 0;
4456+
4457+ while (cause) {
4458+ txq = mvpp2_get_tx_queue(port, cause);
4459+ if (!txq)
4460+ break;
4461+
4462+ txq_pcpu = this_cpu_ptr(txq->pcpu);
4463+
4464+ if (txq_pcpu->count) {
4465+ mvpp2_txq_done(port, txq, txq_pcpu);
4466+ tx_todo += txq_pcpu->count;
4467+ }
4468+
4469+ cause &= ~(1 << txq->log_id);
4470+ }
4471+ return tx_todo;
4472+}
4473+
44634474 /* Rx/Tx queue initialization/cleanup methods */
44644475
44654476 /* Allocate and initialize descriptors for aggr TXQ */
@@ -4649,12 +4660,13 @@ static int mvpp2_txq_init(struct mvpp2_port *port, · 183 unmodified lines
46494660 txq_pcpu->tx_skb = kmalloc(txq_pcpu->size *
46504661 sizeof(*txq_pcpu->tx_skb),
46514662 GFP_KERNEL);
4652− if (!txq_pcpu->tx_skb) {
4653− dma_free_coherent(port->dev->dev.parent,
4654− txq->size * MVPP2_DESC_ALIGNED_SIZE,
4655− txq->descs, txq->descs_phys);
4656− return -ENOMEM;
4657− }
4663+ if (!txq_pcpu->tx_skb)
4664+ goto error;
4665+
4666+ txq_pcpu->tx_buffs = kmalloc(txq_pcpu->size *
4667+ sizeof(dma_addr_t), GFP_KERNEL);
4668+ if (!txq_pcpu->tx_buffs)
4669+ goto error;
46584670
46594671 txq_pcpu->count = 0;
46604672 txq_pcpu->reserved_num = 0;
@@ -4663,6 +4675,19 @@ static int mvpp2_txq_init(struct mvpp2_port *port, · 2 unmodified lines
46634675 }
46644676
46654677 return 0;
4678+
4679+error:
4680+ for_each_present_cpu(cpu) {
4681+ txq_pcpu = per_cpu_ptr(txq->pcpu, cpu);
4682+ kfree(txq_pcpu->tx_skb);
4683+ kfree(txq_pcpu->tx_buffs);
4684+ }
4685+
4686+ dma_free_coherent(port->dev->dev.parent,
4687+ txq->size * MVPP2_DESC_ALIGNED_SIZE,
4688+ txq->descs, txq->descs_phys);
4689+
4690+ return -ENOMEM;
46664691 }
46674692
46684693 /* Free allocated TXQ resources */
@@ -4675,6 +4700,7 @@ static void mvpp2_txq_deinit(struct mvpp2_port *port, · 6 unmodified lines
46754700 for_each_present_cpu(cpu) {
46764701 txq_pcpu = per_cpu_ptr(txq->pcpu, cpu);
46774702 kfree(txq_pcpu->tx_skb);
4703+ kfree(txq_pcpu->tx_buffs);
46784704 }
46794705
46804706 if (txq->descs)
@@ -4805,7 +4831,6 @@ static int mvpp2_setup_txqs(struct mvpp2_port *port) · 124 unmodified lines
48054831 goto err_cleanup;
48064832 }
48074833
4808− on_each_cpu(mvpp2_tx_done_pkts_coal_set, port, 1);
48094834 on_each_cpu(mvpp2_txq_sent_counter_clear, port, 1);
48104835 return 0;
48114836
@@ -4887,6 +4912,49 @@ static void mvpp2_link_event(struct net_device *dev) · 75 unmodified lines
48874912 }
48884913 }
48894914
4915+static void mvpp2_timer_set(struct mvpp2_port_pcpu *port_pcpu)
4916+{
4917+ ktime_t interval;
4918+
4919+ if (!port_pcpu->timer_scheduled) {
4920+ port_pcpu->timer_scheduled = true;
4921+ interval = ktime_set(0, MVPP2_TXDONE_HRTIMER_PERIOD_NS);
4922+ hrtimer_start(&port_pcpu->tx_done_timer, interval,
4923+ HRTIMER_MODE_REL_PINNED);
4924+ }
4925+}
4926+
4927+static void mvpp2_tx_proc_cb(unsigned long data)
4928+{
4929+ struct net_device *dev = (struct net_device *)data;
4930+ struct mvpp2_port *port = netdev_priv(dev);
4931+ struct mvpp2_port_pcpu *port_pcpu = this_cpu_ptr(port->pcpu);
4932+ unsigned int tx_todo, cause;
4933+
4934+ if (!netif_running(dev))
4935+ return;
4936+ port_pcpu->timer_scheduled = false;
4937+
4938+ /* Process all the Tx queues */
4939+ cause = (1 << txq_number) - 1;
4940+ tx_todo = mvpp2_tx_done(port, cause);
4941+
4942+ /* Set the timer in case not all the packets were processed */
4943+ if (tx_todo)
4944+ mvpp2_timer_set(port_pcpu);
4945+}
4946+
4947+static enum hrtimer_restart mvpp2_hr_timer_cb(struct hrtimer *timer)
4948+{
4949+ struct mvpp2_port_pcpu *port_pcpu = container_of(timer,
4950+ struct mvpp2_port_pcpu,
4951+ tx_done_timer);
4952+
4953+ tasklet_schedule(&port_pcpu->tx_done_tasklet);
4954+
4955+ return HRTIMER_NORESTART;
4956+}
4957+
48904958 /* Main RX/TX processing routines */
48914959
48924960 /* Display more error info */
@@ -5144,11 +5212,11 @@ static int mvpp2_tx_frag_process(struct mvpp2_port *port, struct sk_buff *skb, · 251 unmodified lines
51445212 if (i == (skb_shinfo(skb)->nr_frags - 1)) {
51455213 /* Last descriptor */
51465214 tx_desc->command = MVPP2_TXD_L_DESC;
5147− mvpp2_txq_inc_put(txq_pcpu, skb);
5215+ mvpp2_txq_inc_put(txq_pcpu, skb, tx_desc);
51485216 } else {
51495217 /* Descriptor in the middle: Not First, Not Last */
51505218 tx_desc->command = 0;
5151− mvpp2_txq_inc_put(txq_pcpu, NULL);
5219+ mvpp2_txq_inc_put(txq_pcpu, NULL, tx_desc);
51525220 }
51535221 }
51545222
@@ -5214,12 +5282,12 @@ static int mvpp2_tx(struct sk_buff *skb, struct net_device *dev) · 59 unmodified lines
52145282 /* First and Last descriptor */
52155283 tx_cmd |= MVPP2_TXD_F_DESC | MVPP2_TXD_L_DESC;
52165284 tx_desc->command = tx_cmd;
5217− mvpp2_txq_inc_put(txq_pcpu, skb);
5285+ mvpp2_txq_inc_put(txq_pcpu, skb, tx_desc);
52185286 } else {
52195287 /* First but not Last */
52205288 tx_cmd |= MVPP2_TXD_F_DESC | MVPP2_TXD_PADDING_DISABLE;
52215289 tx_desc->command = tx_cmd;
5222− mvpp2_txq_inc_put(txq_pcpu, NULL);
5290+ mvpp2_txq_inc_put(txq_pcpu, NULL, tx_desc);
52235291
52245292 /* Continue with other skb fragments */
52255293 if (mvpp2_tx_frag_process(port, skb, aggr_txq, txq)) {
@@ -5255,6 +5323,17 @@ out: · 29 unmodified lines
52555323 dev_kfree_skb_any(skb);
52565324 }
52575325
5326+ /* Finalize TX processing */
5327+ if (txq_pcpu->count >= txq->done_pkts_coal)
5328+ mvpp2_txq_done(port, txq, txq_pcpu);
5329+
5330+ /* Set the timer in case not all frags were processed */
5331+ if (txq_pcpu->count <= frags && txq_pcpu->count > 0) {
5332+ struct mvpp2_port_pcpu *port_pcpu = this_cpu_ptr(port->pcpu);
5333+
5334+ mvpp2_timer_set(port_pcpu);
5335+ }
5336+
52585337 return NETDEV_TX_OK;
52595338 }
52605339
@@ -5268,10 +5347,11 @@ static inline void mvpp2_cause_error(struct net_device *dev, int cause) · 7 unmodified lines
52685347 netdev_err(dev, "tx fifo underrun error\n");
52695348 }
52705349
5271−static void mvpp2_txq_done_percpu(void *arg)
5350+static int mvpp2_poll(struct napi_struct *napi, int budget)
52725351 {
5273− struct mvpp2_port *port = arg;
5274− u32 cause_rx_tx, cause_tx, cause_misc;
5352+ u32 cause_rx_tx, cause_rx, cause_misc;
5353+ int rx_done = 0;
5354+ struct mvpp2_port *port = netdev_priv(napi->dev);
52755355
52765356 /* Rx/Tx cause register
52775357 *
@@ -5285,7 +5365,7 @@ static void mvpp2_txq_done_percpu(void *arg) · 7 unmodified lines
52855365 */
52865366 cause_rx_tx = mvpp2_read(port->priv,
52875367 MVPP2_ISR_RX_TX_CAUSE_REG(port->id));
5288− cause_tx = cause_rx_tx & MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK;
5368+ cause_rx_tx &= ~MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK;
52895369 cause_misc = cause_rx_tx & MVPP2_CAUSE_MISC_SUM_MASK;
52905370
52915371 if (cause_misc) {
@@ -5297,26 +5377,6 @@ static void mvpp2_txq_done_percpu(void *arg) · 5 unmodified lines
52975377 cause_rx_tx & ~MVPP2_CAUSE_MISC_SUM_MASK);
52985378 }
52995379
5300− /* Release TX descriptors */
5301− if (cause_tx) {
5302− struct mvpp2_tx_queue *txq = mvpp2_get_tx_queue(port, cause_tx);
5303− struct mvpp2_txq_pcpu *txq_pcpu = this_cpu_ptr(txq->pcpu);
5304−
5305− if (txq_pcpu->count)
5306− mvpp2_txq_done(port, txq, txq_pcpu);
5307− }
5308−}
5309−
5310−static int mvpp2_poll(struct napi_struct *napi, int budget)
5311−{
5312− u32 cause_rx_tx, cause_rx;
5313− int rx_done = 0;
5314− struct mvpp2_port *port = netdev_priv(napi->dev);
5315−
5316− on_each_cpu(mvpp2_txq_done_percpu, port, 1);
5317−
5318− cause_rx_tx = mvpp2_read(port->priv,
5319− MVPP2_ISR_RX_TX_CAUSE_REG(port->id));
53205380 cause_rx = cause_rx_tx & MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK;
53215381
53225382 /* Process RX packets */
@@ -5561,6 +5621,8 @@ err_cleanup_rxqs: · 238 unmodified lines
55615621 static int mvpp2_stop(struct net_device *dev)
55625622 {
55635623 struct mvpp2_port *port = netdev_priv(dev);
5624+ struct mvpp2_port_pcpu *port_pcpu;
5625+ int cpu;
55645626
55655627 mvpp2_stop_dev(port);
55665628 mvpp2_phy_disconnect(port);
@@ -5569,6 +5631,13 @@ static int mvpp2_stop(struct net_device *dev) · 2 unmodified lines
55695631 on_each_cpu(mvpp2_interrupts_mask, port, 1);
55705632
55715633 free_irq(port->irq, port);
5634+ for_each_present_cpu(cpu) {
5635+ port_pcpu = per_cpu_ptr(port->pcpu, cpu);
5636+
5637+ hrtimer_cancel(&port_pcpu->tx_done_timer);
5638+ port_pcpu->timer_scheduled = false;
5639+ tasklet_kill(&port_pcpu->tx_done_tasklet);
5640+ }
55725641 mvpp2_cleanup_rxqs(port);
55735642 mvpp2_cleanup_txqs(port);
55745643
@@ -5784,7 +5853,6 @@ static int mvpp2_ethtool_set_coalesce(struct net_device *dev, · 209 unmodified lines
57845853 txq->done_pkts_coal = c->tx_max_coalesced_frames;
57855854 }
57865855
5787− on_each_cpu(mvpp2_tx_done_pkts_coal_set, port, 1);
57885856 return 0;
57895857 }
57905858
@@ -6035,6 +6103,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, · 244 unmodified lines
60356103 {
60366104 struct device_node *phy_node;
60376105 struct mvpp2_port *port;
6106+ struct mvpp2_port_pcpu *port_pcpu;
60386107 struct net_device *dev;
60396108 struct resource *res;
60406109 const char *dt_mac_addr;
@@ -6044,7 +6113,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, · 3 unmodified lines
60446113 int features;
60456114 int phy_mode;
60466115 int priv_common_regs_num = 2;
6047− int err, i;
6116+ int err, i, cpu;
60486117
60496118 dev = alloc_etherdev_mqs(sizeof(struct mvpp2_port), txq_number,
60506119 rxq_number);
@@ -6135,6 +6204,24 @@ static int mvpp2_port_probe(struct platform_device *pdev, · 84 unmodified lines
61356204 }
61366205 mvpp2_port_power_up(port);
61376206
6207+ port->pcpu = alloc_percpu(struct mvpp2_port_pcpu);
6208+ if (!port->pcpu) {
6209+ err = -ENOMEM;
6210+ goto err_free_txq_pcpu;
6211+ }
6212+
6213+ for_each_present_cpu(cpu) {
6214+ port_pcpu = per_cpu_ptr(port->pcpu, cpu);
6215+
6216+ hrtimer_init(&port_pcpu->tx_done_timer, CLOCK_MONOTONIC,
6217+ HRTIMER_MODE_REL_PINNED);
6218+ port_pcpu->tx_done_timer.function = mvpp2_hr_timer_cb;
6219+ port_pcpu->timer_scheduled = false;
6220+
6221+ tasklet_init(&port_pcpu->tx_done_tasklet, mvpp2_tx_proc_cb,
6222+ (unsigned long)dev);
6223+ }
6224+
61386225 netif_napi_add(dev, &port->napi, mvpp2_poll, NAPI_POLL_WEIGHT);
61396226 features = NETIF_F_SG | NETIF_F_IP_CSUM;
61406227 dev->features = features | NETIF_F_RXCSUM;
@@ -6144,7 +6231,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, · 3 unmodified lines
61446231 err = register_netdev(dev);
61456232 if (err < 0) {
61466233 dev_err(&pdev->dev, "failed to register netdev\n");
6147− goto err_free_txq_pcpu;
6234+ goto err_free_port_pcpu;
61486235 }
61496236 netdev_info(dev, "Using %s mac address %pM\n", mac_from, dev->dev_addr);
61506237
@@ -6153,6 +6240,8 @@ static int mvpp2_port_probe(struct platform_device *pdev, · 2 unmodified lines
61536240 priv->port_list[id] = port;
61546241 return 0;
61556242
6243+err_free_port_pcpu:
6244+ free_percpu(port->pcpu);
61566245 err_free_txq_pcpu:
61576246 for (i = 0; i < txq_number; i++)
61586247 free_percpu(port->txqs[i]->pcpu);
@@ -6171,6 +6260,7 @@ static void mvpp2_port_remove(struct mvpp2_port *port) · 12 unmodified lines
61716260 int i;
61726261
61736262 unregister_netdev(port->dev);
6263+ free_percpu(port->pcpu);
61746264 free_percpu(port->stats);
61756265 for (i = 0; i < txq_number; i++)
61766266 free_percpu(port->txqs[i]->pcpu);
drivers/net/ethernet/mellanox/mlx4/cmd.c+15−2
@@ -686,6 +686,7 @@ static int mlx4_cmd_wait(struct mlx4_dev *dev, u64 in_param, u64 *out_param, · 685 unmodified lines
686686 {
687687 struct mlx4_cmd *cmd = &mlx4_priv(dev)->cmd;
688688 struct mlx4_cmd_context *context;
689+ long ret_wait;
689690 int err = 0;
690691
691692 down(&cmd->event_sem);
@@ -711,8 +712,20 @@ static int mlx4_cmd_wait(struct mlx4_dev *dev, u64 in_param, u64 *out_param, · 19 unmodified lines
711712 if (err)
712713 goto out_reset;
713714
714− if (!wait_for_completion_timeout(&context->done,
715− msecs_to_jiffies(timeout))) {
715+ if (op == MLX4_CMD_SENSE_PORT) {
716+ ret_wait =
717+ wait_for_completion_interruptible_timeout(&context->done,
718+ msecs_to_jiffies(timeout));
719+ if (ret_wait < 0) {
720+ context->fw_status = 0;
721+ context->out_param = 0;
722+ context->result = 0;
723+ }
724+ } else {
725+ ret_wait = (long)wait_for_completion_timeout(&context->done,
726+ msecs_to_jiffies(timeout));
727+ }
728+ if (!ret_wait) {
716729 mlx4_warn(dev, "command 0x%x timed out (go bit not cleared)\n",
717730 op);
718731 if (op == MLX4_CMD_NOP) {
drivers/net/ethernet/mellanox/mlx4/en_rx.c+0−1
@@ -246,7 +246,6 @@ static int mlx4_en_prepare_rx_desc(struct mlx4_en_priv *priv, · 245 unmodified lines
246246
247247 static inline bool mlx4_en_is_ring_empty(struct mlx4_en_rx_ring *ring)
248248 {
249− BUG_ON((u32)(ring->prod - ring->cons) > ring->actual_size);
250249 return ring->prod == ring->cons;
251250 }
252251
drivers/net/ethernet/mellanox/mlx4/eq.c+2−2
@@ -601,7 +601,7 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq) · 600 unmodified lines
601601 continue;
602602 mlx4_dbg(dev, "%s: Sending MLX4_PORT_CHANGE_SUBTYPE_DOWN to slave: %d, port:%d\n",
603603 __func__, i, port);
604− s_info = &priv->mfunc.master.vf_oper[slave].vport[port].state;
604+ s_info = &priv->mfunc.master.vf_oper[i].vport[port].state;
605605 if (IFLA_VF_LINK_STATE_AUTO == s_info->link_state) {
606606 eqe->event.port_change.port =
607607 cpu_to_be32(
@@ -640,7 +640,7 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq) · 32 unmodified lines
640640 continue;
641641 if (i == mlx4_master_func_num(dev))
642642 continue;
643− s_info = &priv->mfunc.master.vf_oper[slave].vport[port].state;
643+ s_info = &priv->mfunc.master.vf_oper[i].vport[port].state;
644644 if (IFLA_VF_LINK_STATE_AUTO == s_info->link_state) {
645645 eqe->event.port_change.port =
646646 cpu_to_be32(
drivers/net/ethernet/mellanox/mlx4/main.c+5−0
@@ -2273,6 +2273,11 @@ static int mlx4_allocate_default_counters(struct mlx4_dev *dev) · 2272 unmodified lines
22732273 } else if (err == -ENOENT) {
22742274 err = 0;
22752275 continue;
2276+ } else if (mlx4_is_slave(dev) && err == -EINVAL) {
2277+ priv->def_counter[port] = MLX4_SINK_COUNTER_INDEX(dev);
2278+ mlx4_warn(dev, "can't allocate counter from old PF driver, using index %d\n",
2279+ MLX4_SINK_COUNTER_INDEX(dev));
2280+ err = 0;
22762281 } else {
22772282 mlx4_err(dev, "%s: failed to allocate default counter port %d err %d\n",
22782283 __func__, port + 1, err);
drivers/net/ethernet/mellanox/mlx5/core/main.c+2−0
@@ -391,6 +391,8 @@ static int handle_hca_cap(struct mlx5_core_dev *dev) · 390 unmodified lines
391391 /* disable cmdif checksum */
392392 MLX5_SET(cmd_hca_cap, set_hca_cap, cmdif_checksum, 0);
393393
394+ MLX5_SET(cmd_hca_cap, set_hca_cap, log_uar_page_sz, PAGE_SHIFT - 12);
395+
394396 err = set_caps(dev, set_ctx, set_sz);
395397
396398 query_ex:
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c+1−1
@@ -1415,7 +1415,7 @@ static int qlcnic_83xx_copy_fw_file(struct qlcnic_adapter *adapter) · 1414 unmodified lines
14151415 if (fw->size & 0xF) {
14161416 addr = dest + size;
14171417 for (i = 0; i < (fw->size & 0xF); i++)
1418− data[i] = temp[size + i];
1418+ data[i] = ((u8 *)temp)[size + i];
14191419 for (; i < 16; i++)
14201420 data[i] = 0;
14211421 ret = qlcnic_ms_mem_write128(adapter, addr,
drivers/net/ethernet/realtek/r8169.c+3−1
@@ -4875,10 +4875,12 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp) · 4874 unmodified lines
48754875 case RTL_GIGA_MAC_VER_46:
48764876 case RTL_GIGA_MAC_VER_47:
48774877 case RTL_GIGA_MAC_VER_48:
4878+ RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF);
4879+ break;
48784880 case RTL_GIGA_MAC_VER_49:
48794881 case RTL_GIGA_MAC_VER_50:
48804882 case RTL_GIGA_MAC_VER_51:
4881− RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF);
4883+ RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF);
48824884 break;
48834885 default:
48844886 RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST);
drivers/net/ethernet/rocker/rocker.c+1−0
@@ -4821,6 +4821,7 @@ static void rocker_remove_ports(const struct rocker *rocker) · 4820 unmodified lines
48214821 rocker_port_ig_tbl(rocker_port, SWITCHDEV_TRANS_NONE,
48224822 ROCKER_OP_FLAG_REMOVE);
48234823 unregister_netdev(rocker_port->dev);
4824+ free_netdev(rocker_port->dev);
48244825 }
48254826 kfree(rocker->ports);
48264827 }
drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c+2−2
@@ -42,7 +42,7 @@ · 41 unmodified lines
4242 #define NSS_COMMON_CLK_DIV_MASK 0x7f
4343
4444 #define NSS_COMMON_CLK_SRC_CTRL 0x14
45−#define NSS_COMMON_CLK_SRC_CTRL_OFFSET(x) (1 << x)
45+#define NSS_COMMON_CLK_SRC_CTRL_OFFSET(x) (x)
4646 /* Mode is coded on 1 bit but is different depending on the MAC ID:
4747 * MAC0: QSGMII=0 RGMII=1
4848 * MAC1: QSGMII=0 SGMII=0 RGMII=1
@@ -291,7 +291,7 @@ static void *ipq806x_gmac_setup(struct platform_device *pdev) · 242 unmodified lines
291291
292292 /* Configure the clock src according to the mode */
293293 regmap_read(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, &val);
294− val &= ~NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id);
294+ val &= ~(1 << NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id));
295295 switch (gmac->phy_mode) {
296296 case PHY_INTERFACE_MODE_RGMII:
297297 val |= NSS_COMMON_CLK_SRC_CTRL_RGMII(gmac->id) <<
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c+4−0
@@ -413,3 +413,7 @@ static int stmmac_pltfr_resume(struct device *dev) · 412 unmodified lines
413413 SIMPLE_DEV_PM_OPS(stmmac_pltfr_pm_ops, stmmac_pltfr_suspend,
414414 stmmac_pltfr_resume);
415415 EXPORT_SYMBOL_GPL(stmmac_pltfr_pm_ops);
416+
417+MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet platform support");
418+MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>");
419+MODULE_LICENSE("GPL");
drivers/net/ethernet/sun/niu.c+1−3
@@ -6658,10 +6658,8 @@ static netdev_tx_t niu_start_xmit(struct sk_buff *skb, · 6657 unmodified lines
66586658 struct sk_buff *skb_new;
66596659
66606660 skb_new = skb_realloc_headroom(skb, len);
6661− if (!skb_new) {
6662− rp->tx_errors++;
6661+ if (!skb_new)
66636662 goto out_drop;
6664− }
66656663 kfree_skb(skb);
66666664 skb = skb_new;
66676665 } else
drivers/net/ethernet/ti/netcp.h+1−1
@@ -85,7 +85,6 @@ struct netcp_intf { · 84 unmodified lines
8585 struct list_head rxhook_list_head;
8686 unsigned int rx_queue_id;
8787 void *rx_fdq[KNAV_DMA_FDQ_PER_CHAN];
88− u32 rx_buffer_sizes[KNAV_DMA_FDQ_PER_CHAN];
8988 struct napi_struct rx_napi;
9089 struct napi_struct tx_napi;
9190
@@ -223,6 +222,7 @@ void *netcp_device_find_module(struct netcp_device *netcp_device, · 131 unmodified lines
223222
224223 /* SGMII functions */
225224 int netcp_sgmii_reset(void __iomem *sgmii_ofs, int port);
225+bool netcp_sgmii_rtreset(void __iomem *sgmii_ofs, int port, bool set);
226226 int netcp_sgmii_get_port_link(void __iomem *sgmii_ofs, int port);
227227 int netcp_sgmii_config(void __iomem *sgmii_ofs, int port, u32 interface);
228228
drivers/net/ethernet/ti/netcp_core.c+24−25
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #define NETCP_SOP_OFFSET (NET_IP_ALIGN + NET_SKB_PAD)
3535 #define NETCP_NAPI_WEIGHT 64
3636 #define NETCP_TX_TIMEOUT (5 * HZ)
37+#define NETCP_PACKET_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN)
3738 #define NETCP_MIN_PACKET_SIZE ETH_ZLEN
3839 #define NETCP_MAX_MCAST_ADDR 16
3940
@@ -804,30 +805,28 @@ static void netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq) · 764 unmodified lines
804805 if (likely(fdq == 0)) {
805806 unsigned int primary_buf_len;
806807 /* Allocate a primary receive queue entry */
807− buf_len = netcp->rx_buffer_sizes[0] + NETCP_SOP_OFFSET;
808+ buf_len = NETCP_PACKET_SIZE + NETCP_SOP_OFFSET;
808809 primary_buf_len = SKB_DATA_ALIGN(buf_len) +
809810 SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
810811
811− if (primary_buf_len <= PAGE_SIZE) {
812− bufptr = netdev_alloc_frag(primary_buf_len);
813− pad[1] = primary_buf_len;
814− } else {
815− bufptr = kmalloc(primary_buf_len, GFP_ATOMIC |
816− GFP_DMA32 | __GFP_COLD);
817− pad[1] = 0;
818− }
812+ bufptr = netdev_alloc_frag(primary_buf_len);
813+ pad[1] = primary_buf_len;
819814
820815 if (unlikely(!bufptr)) {
821− dev_warn_ratelimited(netcp->ndev_dev, "Primary RX buffer alloc failed\n");
816+ dev_warn_ratelimited(netcp->ndev_dev,
817+ "Primary RX buffer alloc failed\n");
822818 goto fail;
823819 }
824820 dma = dma_map_single(netcp->dev, bufptr, buf_len,
825821 DMA_TO_DEVICE);
822+ if (unlikely(dma_mapping_error(netcp->dev, dma)))
823+ goto fail;
824+
826825 pad[0] = (u32)bufptr;
827826
828827 } else {
829828 /* Allocate a secondary receive queue entry */
830− page = alloc_page(GFP_ATOMIC | GFP_DMA32 | __GFP_COLD);
829+ page = alloc_page(GFP_ATOMIC | GFP_DMA | __GFP_COLD);
831830 if (unlikely(!page)) {
832831 dev_warn_ratelimited(netcp->ndev_dev, "Secondary page alloc failed\n");
833832 goto fail;
@@ -1010,7 +1009,7 @@ netcp_tx_map_skb(struct sk_buff *skb, struct netcp_intf *netcp) · 176 unmodified lines
10101009
10111010 /* Map the linear buffer */
10121011 dma_addr = dma_map_single(dev, skb->data, pkt_len, DMA_TO_DEVICE);
1013− if (unlikely(!dma_addr)) {
1012+ if (unlikely(dma_mapping_error(dev, dma_addr))) {
10141013 dev_err(netcp->ndev_dev, "Failed to map skb buffer\n");
10151014 return NULL;
10161015 }
@@ -1546,8 +1545,8 @@ static int netcp_setup_navigator_resources(struct net_device *ndev) · 529 unmodified lines
15461545 knav_queue_disable_notify(netcp->rx_queue);
15471546
15481547 /* open Rx FDQs */
1549− for (i = 0; i < KNAV_DMA_FDQ_PER_CHAN &&
1550− netcp->rx_queue_depths[i] && netcp->rx_buffer_sizes[i]; ++i) {
1548+ for (i = 0; i < KNAV_DMA_FDQ_PER_CHAN && netcp->rx_queue_depths[i];
1549+ ++i) {
15511550 snprintf(name, sizeof(name), "rx-fdq-%s-%d", ndev->name, i);
15521551 netcp->rx_fdq[i] = knav_queue_open(name, KNAV_QUEUE_GP, 0);
15531552 if (IS_ERR_OR_NULL(netcp->rx_fdq[i])) {
@@ -1941,14 +1940,6 @@ static int netcp_create_interface(struct netcp_device *netcp_device, · 387 unmodified lines
19411940 netcp->rx_queue_depths[0] = 128;
19421941 }
19431942
1944− ret = of_property_read_u32_array(node_interface, "rx-buffer-size",
1945− netcp->rx_buffer_sizes,
1946− KNAV_DMA_FDQ_PER_CHAN);
1947− if (ret) {
1948− dev_err(dev, "missing \"rx-buffer-size\" parameter\n");
1949− netcp->rx_buffer_sizes[0] = 1536;
1950− }
1951−
19521943 ret = of_property_read_u32_array(node_interface, "rx-pool", temp, 2);
19531944 if (ret < 0) {
19541945 dev_err(dev, "missing \"rx-pool\" parameter\n");
@@ -2112,6 +2103,7 @@ probe_quit: · 157 unmodified lines
21122103 static int netcp_remove(struct platform_device *pdev)
21132104 {
21142105 struct netcp_device *netcp_device = platform_get_drvdata(pdev);
2106+ struct netcp_intf *netcp_intf, *netcp_tmp;
21152107 struct netcp_inst_modpriv *inst_modpriv, *tmp;
21162108 struct netcp_module *module;
21172109
@@ -2123,10 +2115,17 @@ static int netcp_remove(struct platform_device *pdev) · 5 unmodified lines
21232115 list_del(&inst_modpriv->inst_list);
21242116 kfree(inst_modpriv);
21252117 }
2126− WARN(!list_empty(&netcp_device->interface_head), "%s interface list not empty!\n",
2127− pdev->name);
21282118
2129− devm_kfree(&pdev->dev, netcp_device);
2119+ /* now that all modules are removed, clean up the interfaces */
2120+ list_for_each_entry_safe(netcp_intf, netcp_tmp,
2121+ &netcp_device->interface_head,
2122+ interface_list) {
2123+ netcp_delete_interface(netcp_device, netcp_intf->ndev);
2124+ }
2125+
2126+ WARN(!list_empty(&netcp_device->interface_head),
2127+ "%s interface list not empty!\n", pdev->name);
2128+
21302129 pm_runtime_put_sync(&pdev->dev);
21312130 pm_runtime_disable(&pdev->dev);
21322131 platform_set_drvdata(pdev, NULL);
drivers/net/ethernet/ti/netcp_ethss.c+37−30
@@ -1901,11 +1901,28 @@ static void gbe_port_config(struct gbe_priv *gbe_dev, struct gbe_slave *slave, · 1900 unmodified lines
19011901 writel(slave->mac_control, GBE_REG_ADDR(slave, emac_regs, mac_control));
19021902 }
19031903
1904+static void gbe_sgmii_rtreset(struct gbe_priv *priv,
1905+ struct gbe_slave *slave, bool set)
1906+{
1907+ void __iomem *sgmii_port_regs;
1908+
1909+ if (SLAVE_LINK_IS_XGMII(slave))
1910+ return;
1911+
1912+ if ((priv->ss_version == GBE_SS_VERSION_14) && (slave->slave_num >= 2))
1913+ sgmii_port_regs = priv->sgmii_port34_regs;
1914+ else
1915+ sgmii_port_regs = priv->sgmii_port_regs;
1916+
1917+ netcp_sgmii_rtreset(sgmii_port_regs, slave->slave_num, set);
1918+}
1919+
19041920 static void gbe_slave_stop(struct gbe_intf *intf)
19051921 {
19061922 struct gbe_priv *gbe_dev = intf->gbe_dev;
19071923 struct gbe_slave *slave = intf->slave;
19081924
1925+ gbe_sgmii_rtreset(gbe_dev, slave, true);
19091926 gbe_port_reset(slave);
19101927 /* Disable forwarding */
19111928 cpsw_ale_control_set(gbe_dev->ale, slave->port_num,
@@ -1947,6 +1964,7 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf) · 35 unmodified lines
19471964
19481965 gbe_sgmii_config(priv, slave);
19491966 gbe_port_reset(slave);
1967+ gbe_sgmii_rtreset(priv, slave, false);
19501968 gbe_port_config(priv, slave, priv->rx_packet_max);
19511969 gbe_set_slave_mac(slave, gbe_intf);
19521970 /* enable forwarding */
@@ -2490,10 +2508,9 @@ static void free_secondary_ports(struct gbe_priv *gbe_dev) · 537 unmodified lines
24902508 {
24912509 struct gbe_slave *slave;
24922510
2493− for (;;) {
2511+ while (!list_empty(&gbe_dev->secondary_slaves)) {
24942512 slave = first_sec_slave(gbe_dev);
2495− if (!slave)
2496− break;
2513+
24972514 if (slave->phy)
24982515 phy_disconnect(slave->phy);
24992516 list_del(&slave->slave_list);
@@ -2839,14 +2856,13 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, · 339 unmodified lines
28392856 &gbe_dev->dma_chan_name);
28402857 if (ret < 0) {
28412858 dev_err(dev, "missing \"tx-channel\" parameter\n");
2842− ret = -ENODEV;
2843− goto quit;
2859+ return -EINVAL;
28442860 }
28452861
28462862 if (!strcmp(node->name, "gbe")) {
28472863 ret = get_gbe_resource_version(gbe_dev, node);
28482864 if (ret)
2849− goto quit;
2865+ return ret;
28502866
28512867 dev_dbg(dev, "ss_version: 0x%08x\n", gbe_dev->ss_version);
28522868
@@ -2857,22 +2873,20 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, · 4 unmodified lines
28572873 else
28582874 ret = -ENODEV;
28592875
2860− if (ret)
2861− goto quit;
28622876 } else if (!strcmp(node->name, "xgbe")) {
28632877 ret = set_xgbe_ethss10_priv(gbe_dev, node);
28642878 if (ret)
2865− goto quit;
2879+ return ret;
28662880 ret = netcp_xgbe_serdes_init(gbe_dev->xgbe_serdes_regs,
28672881 gbe_dev->ss_regs);
2868− if (ret)
2869− goto quit;
28702882 } else {
28712883 dev_err(dev, "unknown GBE node(%s)\n", node->name);
28722884 ret = -ENODEV;
2873− goto quit;
28742885 }
28752886
2887+ if (ret)
2888+ return ret;
2889+
28762890 interfaces = of_get_child_by_name(node, "interfaces");
28772891 if (!interfaces)
28782892 dev_err(dev, "could not find interfaces\n");
@@ -2880,11 +2894,11 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, · 1 unmodified line
28802894 ret = netcp_txpipe_init(&gbe_dev->tx_pipe, netcp_device,
28812895 gbe_dev->dma_chan_name, gbe_dev->tx_queue_id);
28822896 if (ret)
2883− goto quit;
2897+ return ret;
28842898
28852899 ret = netcp_txpipe_open(&gbe_dev->tx_pipe);
28862900 if (ret)
2887− goto quit;
2901+ return ret;
28882902
28892903 /* Create network interfaces */
28902904 INIT_LIST_HEAD(&gbe_dev->gbe_intf_head);
@@ -2899,6 +2913,7 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, · 8 unmodified lines
28992913 if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves)
29002914 break;
29012915 }
2916+ of_node_put(interfaces);
29022917
29032918 if (!gbe_dev->num_slaves)
29042919 dev_warn(dev, "No network interface configured\n");
@@ -2911,9 +2926,10 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, · 6 unmodified lines
29112926 of_node_put(secondary_ports);
29122927
29132928 if (!gbe_dev->num_slaves) {
2914− dev_err(dev, "No network interface or secondary ports configured\n");
2929+ dev_err(dev,
2930+ "No network interface or secondary ports configured\n");
29152931 ret = -ENODEV;
2916− goto quit;
2932+ goto free_sec_ports;
29172933 }
29182934
29192935 memset(&ale_params, 0, sizeof(ale_params));
@@ -2927,7 +2943,7 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, · 7 unmodified lines
29272943 if (!gbe_dev->ale) {
29282944 dev_err(gbe_dev->dev, "error initializing ale engine\n");
29292945 ret = -ENODEV;
2930− goto quit;
2946+ goto free_sec_ports;
29312947 } else {
29322948 dev_dbg(gbe_dev->dev, "Created a gbe ale engine\n");
29332949 }
@@ -2943,14 +2959,8 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, · 9 unmodified lines
29432959 *inst_priv = gbe_dev;
29442960 return 0;
29452961
2946−quit:
2947− if (gbe_dev->hw_stats)
2948− devm_kfree(dev, gbe_dev->hw_stats);
2949− cpsw_ale_destroy(gbe_dev->ale);
2950− if (gbe_dev->ss_regs)
2951− devm_iounmap(dev, gbe_dev->ss_regs);
2952− of_node_put(interfaces);
2953− devm_kfree(dev, gbe_dev);
2962+free_sec_ports:
2963+ free_secondary_ports(gbe_dev);
29542964 return ret;
29552965 }
29562966
@@ -3023,12 +3033,9 @@ static int gbe_remove(struct netcp_device *netcp_device, void *inst_priv) · 66 unmodified lines
30233033 free_secondary_ports(gbe_dev);
30243034
30253035 if (!list_empty(&gbe_dev->gbe_intf_head))
3026− dev_alert(gbe_dev->dev, "unreleased ethss interfaces present\n");
3036+ dev_alert(gbe_dev->dev,
3037+ "unreleased ethss interfaces present\n");
30273038
3028− devm_kfree(gbe_dev->dev, gbe_dev->hw_stats);
3029− devm_iounmap(gbe_dev->dev, gbe_dev->ss_regs);
3030− memset(gbe_dev, 0x00, sizeof(*gbe_dev));
3031− devm_kfree(gbe_dev->dev, gbe_dev);
30323039 return 0;
30333040 }
30343041
drivers/net/ethernet/ti/netcp_sgmii.c+28−2
@@ -18,6 +18,9 @@ · 17 unmodified lines
1818
1919 #include "netcp.h"
2020
21+#define SGMII_SRESET_RESET BIT(0)
22+#define SGMII_SRESET_RTRESET BIT(1)
23+
2124 #define SGMII_REG_STATUS_LOCK BIT(4)
2225 #define SGMII_REG_STATUS_LINK BIT(0)
2326 #define SGMII_REG_STATUS_AUTONEG BIT(2)
@@ -51,12 +54,35 @@ static void sgmii_write_reg_bit(void __iomem *base, int reg, u32 val) · 27 unmodified lines
5154 int netcp_sgmii_reset(void __iomem *sgmii_ofs, int port)
5255 {
5356 /* Soft reset */
54− sgmii_write_reg_bit(sgmii_ofs, SGMII_SRESET_REG(port), 0x1);
55− while (sgmii_read_reg(sgmii_ofs, SGMII_SRESET_REG(port)) != 0x0)
57+ sgmii_write_reg_bit(sgmii_ofs, SGMII_SRESET_REG(port),
58+ SGMII_SRESET_RESET);
59+
60+ while ((sgmii_read_reg(sgmii_ofs, SGMII_SRESET_REG(port)) &
61+ SGMII_SRESET_RESET) != 0x0)
5662 ;
63+
5764 return 0;
5865 }
5966
67+/* port is 0 based */
68+bool netcp_sgmii_rtreset(void __iomem *sgmii_ofs, int port, bool set)
69+{
70+ u32 reg;
71+ bool oldval;
72+
73+ /* Initiate a soft reset */
74+ reg = sgmii_read_reg(sgmii_ofs, SGMII_SRESET_REG(port));
75+ oldval = (reg & SGMII_SRESET_RTRESET) != 0x0;
76+ if (set)
77+ reg |= SGMII_SRESET_RTRESET;
78+ else
79+ reg &= ~SGMII_SRESET_RTRESET;
80+ sgmii_write_reg(sgmii_ofs, SGMII_SRESET_REG(port), reg);
81+ wmb();
82+
83+ return oldval;
84+}
85+
6086 int netcp_sgmii_get_port_link(void __iomem *sgmii_ofs, int port)
6187 {
6288 u32 status = 0, link = 0;
drivers/net/hamradio/mkiss.c+4−3
@@ -728,11 +728,12 @@ static int mkiss_open(struct tty_struct *tty) · 727 unmodified lines
728728 dev->type = ARPHRD_AX25;
729729
730730 /* Perform the low-level AX25 initialization. */
731− if ((err = ax_open(ax->dev))) {
731+ err = ax_open(ax->dev);
732+ if (err)
732733 goto out_free_netdev;
733− }
734734
735− if (register_netdev(dev))
735+ err = register_netdev(dev);
736+ if (err)
736737 goto out_free_buffers;
737738
738739 /* after register_netdev() - because else printk smashes the kernel */
drivers/net/macvtap.c+7−0
@@ -719,6 +719,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, · 718 unmodified lines
719719 struct virtio_net_hdr vnet_hdr = { 0 };
720720 int vnet_hdr_len = 0;
721721 int copylen = 0;
722+ int depth;
722723 bool zerocopy = false;
723724 size_t linear;
724725 ssize_t n;
@@ -804,6 +805,12 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, · 79 unmodified lines
804805
805806 skb_probe_transport_header(skb, ETH_HLEN);
806807
808+ /* Move network header to the right position for VLAN tagged packets */
809+ if ((skb->protocol == htons(ETH_P_8021Q) ||
810+ skb->protocol == htons(ETH_P_8021AD)) &&
811+ __vlan_get_protocol(skb, skb->protocol, &depth) != 0)
812+ skb_set_network_header(skb, depth);
813+
807814 rcu_read_lock();
808815 vlan = rcu_dereference(q->vlan);
809816 /* copy skb_ubuf_info for callback when skb has no error */
drivers/net/ntb_netdev.c+8−1
@@ -102,6 +102,12 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data, · 101 unmodified lines
102102
103103 netdev_dbg(ndev, "%s: %d byte payload received\n", __func__, len);
104104
105+ if (len < 0) {
106+ ndev->stats.rx_errors++;
107+ ndev->stats.rx_length_errors++;
108+ goto enqueue_again;
109+ }
110+
105111 skb_put(skb, len);
106112 skb->protocol = eth_type_trans(skb, ndev);
107113 skb->ip_summed = CHECKSUM_NONE;
@@ -121,6 +127,7 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data, · 13 unmodified lines
121127 return;
122128 }
123129
130+enqueue_again:
124131 rc = ntb_transport_rx_enqueue(qp, skb, skb->data, ndev->mtu + ETH_HLEN);
125132 if (rc) {
126133 dev_kfree_skb(skb);
@@ -184,7 +191,7 @@ static int ntb_netdev_open(struct net_device *ndev) · 57 unmodified lines
184191
185192 rc = ntb_transport_rx_enqueue(dev->qp, skb, skb->data,
186193 ndev->mtu + ETH_HLEN);
187− if (rc == -EINVAL) {
194+ if (rc) {
188195 dev_kfree_skb(skb);
189196 goto err;
190197 }
drivers/net/usb/r8152.c+137−52
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 #include <linux/usb/cdc.h>
2828
2929 /* Version Information */
30−#define DRIVER_VERSION "v1.08.0 (2015/01/13)"
30+#define DRIVER_VERSION "v1.08.1 (2015/07/28)"
3131 #define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>"
3232 #define DRIVER_DESC "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters"
3333 #define MODULENAME "r8152"
@@ -1902,11 +1902,10 @@ static void rtl_drop_queued_tx(struct r8152 *tp) · 1868 unmodified lines
19021902 static void rtl8152_tx_timeout(struct net_device *netdev)
19031903 {
19041904 struct r8152 *tp = netdev_priv(netdev);
1905− int i;
19061905
19071906 netif_warn(tp, tx_err, netdev, "Tx timeout\n");
1908− for (i = 0; i < RTL8152_MAX_TX; i++)
1909− usb_unlink_urb(tp->tx_info[i].urb);
1907+
1908+ usb_queue_reset_device(tp->intf);
19101909 }
19111910
19121911 static void rtl8152_set_rx_mode(struct net_device *netdev)
@@ -2075,7 +2074,6 @@ static int rtl_start_rx(struct r8152 *tp) · 162 unmodified lines
20752074 {
20762075 int i, ret = 0;
20772076
2078− napi_disable(&tp->napi);
20792077 INIT_LIST_HEAD(&tp->rx_done);
20802078 for (i = 0; i < RTL8152_MAX_RX; i++) {
20812079 INIT_LIST_HEAD(&tp->rx_info[i].list);
@@ -2083,7 +2081,6 @@ static int rtl_start_rx(struct r8152 *tp) · 1 unmodified line
20832081 if (ret)
20842082 break;
20852083 }
2086− napi_enable(&tp->napi);
20872084
20882085 if (ret && ++i < RTL8152_MAX_RX) {
20892086 struct list_head rx_queue;
@@ -2166,6 +2163,7 @@ static int rtl8153_enable(struct r8152 *tp) · 76 unmodified lines
21662163 if (test_bit(RTL8152_UNPLUG, &tp->flags))
21672164 return -ENODEV;
21682165
2166+ usb_disable_lpm(tp->udev);
21692167 set_tx_qlen(tp);
21702168 rtl_set_eee_plus(tp);
21712169 r8153_set_rx_early_timeout(tp);
@@ -2337,11 +2335,61 @@ static void __rtl_set_wol(struct r8152 *tp, u32 wolopts) · 165 unmodified lines
23372335 device_set_wakeup_enable(&tp->udev->dev, false);
23382336 }
23392337
2338+static void r8153_u1u2en(struct r8152 *tp, bool enable)
2339+{
2340+ u8 u1u2[8];
2341+
2342+ if (enable)
2343+ memset(u1u2, 0xff, sizeof(u1u2));
2344+ else
2345+ memset(u1u2, 0x00, sizeof(u1u2));
2346+
2347+ usb_ocp_write(tp, USB_TOLERANCE, BYTE_EN_SIX_BYTES, sizeof(u1u2), u1u2);
2348+}
2349+
2350+static void r8153_u2p3en(struct r8152 *tp, bool enable)
2351+{
2352+ u32 ocp_data;
2353+
2354+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_U2P3_CTRL);
2355+ if (enable && tp->version != RTL_VER_03 && tp->version != RTL_VER_04)
2356+ ocp_data |= U2P3_ENABLE;
2357+ else
2358+ ocp_data &= ~U2P3_ENABLE;
2359+ ocp_write_word(tp, MCU_TYPE_USB, USB_U2P3_CTRL, ocp_data);
2360+}
2361+
2362+static void r8153_power_cut_en(struct r8152 *tp, bool enable)
2363+{
2364+ u32 ocp_data;
2365+
2366+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_POWER_CUT);
2367+ if (enable)
2368+ ocp_data |= PWR_EN | PHASE2_EN;
2369+ else
2370+ ocp_data &= ~(PWR_EN | PHASE2_EN);
2371+ ocp_write_word(tp, MCU_TYPE_USB, USB_POWER_CUT, ocp_data);
2372+
2373+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_MISC_0);
2374+ ocp_data &= ~PCUT_STATUS;
2375+ ocp_write_word(tp, MCU_TYPE_USB, USB_MISC_0, ocp_data);
2376+}
2377+
2378+static bool rtl_can_wakeup(struct r8152 *tp)
2379+{
2380+ struct usb_device *udev = tp->udev;
2381+
2382+ return (udev->actconfig->desc.bmAttributes & USB_CONFIG_ATT_WAKEUP);
2383+}
2384+
23402385 static void rtl_runtime_suspend_enable(struct r8152 *tp, bool enable)
23412386 {
23422387 if (enable) {
23432388 u32 ocp_data;
23442389
2390+ r8153_u1u2en(tp, false);
2391+ r8153_u2p3en(tp, false);
2392+
23452393 __rtl_set_wol(tp, WAKE_ANY);
23462394
23472395 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_CONFIG);
@@ -2353,6 +2401,8 @@ static void rtl_runtime_suspend_enable(struct r8152 *tp, bool enable) · 5 unmodified lines
23532401 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML);
23542402 } else {
23552403 __rtl_set_wol(tp, tp->saved_wolopts);
2404+ r8153_u2p3en(tp, true);
2405+ r8153_u1u2en(tp, true);
23562406 }
23572407 }
23582408
@@ -2599,46 +2649,6 @@ static void r8153_hw_phy_cfg(struct r8152 *tp) · 240 unmodified lines
25992649 set_bit(PHY_RESET, &tp->flags);
26002650 }
26012651
2602−static void r8153_u1u2en(struct r8152 *tp, bool enable)
2603−{
2604− u8 u1u2[8];
2605−
2606− if (enable)
2607− memset(u1u2, 0xff, sizeof(u1u2));
2608− else
2609− memset(u1u2, 0x00, sizeof(u1u2));
2610−
2611− usb_ocp_write(tp, USB_TOLERANCE, BYTE_EN_SIX_BYTES, sizeof(u1u2), u1u2);
2612−}
2613−
2614−static void r8153_u2p3en(struct r8152 *tp, bool enable)
2615−{
2616− u32 ocp_data;
2617−
2618− ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_U2P3_CTRL);
2619− if (enable)
2620− ocp_data |= U2P3_ENABLE;
2621− else
2622− ocp_data &= ~U2P3_ENABLE;
2623− ocp_write_word(tp, MCU_TYPE_USB, USB_U2P3_CTRL, ocp_data);
2624−}
2625−
2626−static void r8153_power_cut_en(struct r8152 *tp, bool enable)
2627−{
2628− u32 ocp_data;
2629−
2630− ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_POWER_CUT);
2631− if (enable)
2632− ocp_data |= PWR_EN | PHASE2_EN;
2633− else
2634− ocp_data &= ~(PWR_EN | PHASE2_EN);
2635− ocp_write_word(tp, MCU_TYPE_USB, USB_POWER_CUT, ocp_data);
2636−
2637− ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_MISC_0);
2638− ocp_data &= ~PCUT_STATUS;
2639− ocp_write_word(tp, MCU_TYPE_USB, USB_MISC_0, ocp_data);
2640−}
2641−
26422652 static void r8153_first_init(struct r8152 *tp)
26432653 {
26442654 u32 ocp_data;
@@ -2781,6 +2791,7 @@ static void rtl8153_disable(struct r8152 *tp) · 136 unmodified lines
27812791 r8153_disable_aldps(tp);
27822792 rtl_disable(tp);
27832793 r8153_enable_aldps(tp);
2794+ usb_enable_lpm(tp->udev);
27842795 }
27852796
27862797 static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex)
@@ -2901,9 +2912,13 @@ static void rtl8153_up(struct r8152 *tp) · 114 unmodified lines
29012912 if (test_bit(RTL8152_UNPLUG, &tp->flags))
29022913 return;
29032914
2915+ r8153_u1u2en(tp, false);
29042916 r8153_disable_aldps(tp);
29052917 r8153_first_init(tp);
29062918 r8153_enable_aldps(tp);
2919+ r8153_u2p3en(tp, true);
2920+ r8153_u1u2en(tp, true);
2921+ usb_enable_lpm(tp->udev);
29072922 }
29082923
29092924 static void rtl8153_down(struct r8152 *tp)
@@ -2914,6 +2929,7 @@ static void rtl8153_down(struct r8152 *tp) · 4 unmodified lines
29142929 }
29152930
29162931 r8153_u1u2en(tp, false);
2932+ r8153_u2p3en(tp, false);
29172933 r8153_power_cut_en(tp, false);
29182934 r8153_disable_aldps(tp);
29192935 r8153_enter_oob(tp);
@@ -2932,8 +2948,10 @@ static void set_carrier(struct r8152 *tp) · 12 unmodified lines
29322948 if (!netif_carrier_ok(netdev)) {
29332949 tp->rtl_ops.enable(tp);
29342950 set_bit(RTL8152_SET_RX_MODE, &tp->flags);
2951+ napi_disable(&tp->napi);
29352952 netif_carrier_on(netdev);
29362953 rtl_start_rx(tp);
2954+ napi_enable(&tp->napi);
29372955 }
29382956 } else {
29392957 if (netif_carrier_ok(netdev)) {
@@ -3252,6 +3270,7 @@ static void r8153_init(struct r8152 *tp) · 312 unmodified lines
32523270 msleep(20);
32533271 }
32543272
3273+ usb_disable_lpm(tp->udev);
32553274 r8153_u2p3en(tp, false);
32563275
32573276 if (tp->version == RTL_VER_04) {
@@ -3319,6 +3338,59 @@ static void r8153_init(struct r8152 *tp) · 61 unmodified lines
33193338 r8153_enable_aldps(tp);
33203339 r8152b_enable_fc(tp);
33213340 rtl_tally_reset(tp);
3341+ r8153_u2p3en(tp, true);
3342+}
3343+
3344+static int rtl8152_pre_reset(struct usb_interface *intf)
3345+{
3346+ struct r8152 *tp = usb_get_intfdata(intf);
3347+ struct net_device *netdev;
3348+
3349+ if (!tp)
3350+ return 0;
3351+
3352+ netdev = tp->netdev;
3353+ if (!netif_running(netdev))
3354+ return 0;
3355+
3356+ napi_disable(&tp->napi);
3357+ clear_bit(WORK_ENABLE, &tp->flags);
3358+ usb_kill_urb(tp->intr_urb);
3359+ cancel_delayed_work_sync(&tp->schedule);
3360+ if (netif_carrier_ok(netdev)) {
3361+ netif_stop_queue(netdev);
3362+ mutex_lock(&tp->control);
3363+ tp->rtl_ops.disable(tp);
3364+ mutex_unlock(&tp->control);
3365+ }
3366+
3367+ return 0;
3368+}
3369+
3370+static int rtl8152_post_reset(struct usb_interface *intf)
3371+{
3372+ struct r8152 *tp = usb_get_intfdata(intf);
3373+ struct net_device *netdev;
3374+
3375+ if (!tp)
3376+ return 0;
3377+
3378+ netdev = tp->netdev;
3379+ if (!netif_running(netdev))
3380+ return 0;
3381+
3382+ set_bit(WORK_ENABLE, &tp->flags);
3383+ if (netif_carrier_ok(netdev)) {
3384+ mutex_lock(&tp->control);
3385+ tp->rtl_ops.enable(tp);
3386+ rtl8152_set_rx_mode(netdev);
3387+ mutex_unlock(&tp->control);
3388+ netif_wake_queue(netdev);
3389+ }
3390+
3391+ napi_enable(&tp->napi);
3392+
3393+ return 0;
33223394 }
33233395
33243396 static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
@@ -3374,9 +3446,11 @@ static int rtl8152_resume(struct usb_interface *intf) · 49 unmodified lines
33743446 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
33753447 rtl_runtime_suspend_enable(tp, false);
33763448 clear_bit(SELECTIVE_SUSPEND, &tp->flags);
3449+ napi_disable(&tp->napi);
33773450 set_bit(WORK_ENABLE, &tp->flags);
33783451 if (netif_carrier_ok(tp->netdev))
33793452 rtl_start_rx(tp);
3453+ napi_enable(&tp->napi);
33803454 } else {
33813455 tp->rtl_ops.up(tp);
33823456 rtl8152_set_speed(tp, AUTONEG_ENABLE,
@@ -3403,12 +3477,15 @@ static void rtl8152_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) · 20 unmodified lines
34033477 if (usb_autopm_get_interface(tp->intf) < 0)
34043478 return;
34053479
3406− mutex_lock(&tp->control);
3407−
3408− wol->supported = WAKE_ANY;
3409− wol->wolopts = __rtl_get_wol(tp);
3410−
3411− mutex_unlock(&tp->control);
3480+ if (!rtl_can_wakeup(tp)) {
3481+ wol->supported = 0;
3482+ wol->wolopts = 0;
3483+ } else {
3484+ mutex_lock(&tp->control);
3485+ wol->supported = WAKE_ANY;
3486+ wol->wolopts = __rtl_get_wol(tp);
3487+ mutex_unlock(&tp->control);
3488+ }
34123489
34133490 usb_autopm_put_interface(tp->intf);
34143491 }
@@ -3418,6 +3495,9 @@ static int rtl8152_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) · 3 unmodified lines
34183495 struct r8152 *tp = netdev_priv(dev);
34193496 int ret;
34203497
3498+ if (!rtl_can_wakeup(tp))
3499+ return -EOPNOTSUPP;
3500+
34213501 ret = usb_autopm_get_interface(tp->intf);
34223502 if (ret < 0)
34233503 goto out_set_wol;
@@ -4059,6 +4139,9 @@ static int rtl8152_probe(struct usb_interface *intf, · 635 unmodified lines
40594139 goto out1;
40604140 }
40614141
4142+ if (!rtl_can_wakeup(tp))
4143+ __rtl_set_wol(tp, 0);
4144+
40624145 tp->saved_wolopts = __rtl_get_wol(tp);
40634146 if (tp->saved_wolopts)
40644147 device_set_wakeup_enable(&udev->dev, true);
@@ -4132,6 +4215,8 @@ static struct usb_driver rtl8152_driver = { · 67 unmodified lines
41324215 .suspend = rtl8152_suspend,
41334216 .resume = rtl8152_resume,
41344217 .reset_resume = rtl8152_resume,
4218+ .pre_reset = rtl8152_pre_reset,
4219+ .post_reset = rtl8152_post_reset,
41354220 .supports_autosuspend = 1,
41364221 .disable_hub_initiated_lpm = 1,
41374222 };
drivers/net/virtio_net.c+2−2
@@ -1756,9 +1756,9 @@ static int virtnet_probe(struct virtio_device *vdev) · 1755 unmodified lines
17561756 /* Do we support "hardware" checksums? */
17571757 if (virtio_has_feature(vdev, VIRTIO_NET_F_CSUM)) {
17581758 /* This opens up the world of extra features. */
1759− dev->hw_features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
1759+ dev->hw_features |= NETIF_F_HW_CSUM | NETIF_F_SG;
17601760 if (csum)
1761− dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
1761+ dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
17621762
17631763 if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
17641764 dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO
drivers/net/wan/cosa.c+2−1
@@ -589,7 +589,8 @@ static int cosa_probe(int base, int irq, int dma) · 588 unmodified lines
589589 chan->netdev->base_addr = chan->cosa->datareg;
590590 chan->netdev->irq = chan->cosa->irq;
591591 chan->netdev->dma = chan->cosa->dma;
592− if (register_hdlc_device(chan->netdev)) {
592+ err = register_hdlc_device(chan->netdev);
593+ if (err) {
593594 netdev_warn(chan->netdev,
594595 "register_hdlc_device() failed\n");
595596 free_netdev(chan->netdev);
drivers/net/wireless/b43/tables_nphy.c+1−1
@@ -3728,7 +3728,7 @@ const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev) · 3727 unmodified lines
37283728 switch (phy->rev) {
37293729 case 6:
37303730 case 5:
3731− if (sprom->fem.ghz5.extpa_gain == 3)
3731+ if (sprom->fem.ghz2.extpa_gain == 3)
37323732 return b43_ntab_tx_gain_epa_rev3_hi_pwr_2g;
37333733 /* fall through */
37343734 case 4:
drivers/net/wireless/iwlwifi/mvm/scan.c+1−1
@@ -1023,7 +1023,7 @@ static void iwl_mvm_scan_umac_dwell(struct iwl_mvm *mvm, · 1022 unmodified lines
10231023 cmd->scan_priority =
10241024 iwl_mvm_scan_priority(mvm, IWL_SCAN_PRIORITY_EXT_6);
10251025
1026− if (iwl_mvm_scan_total_iterations(params) == 0)
1026+ if (iwl_mvm_scan_total_iterations(params) == 1)
10271027 cmd->ooc_priority =
10281028 iwl_mvm_scan_priority(mvm, IWL_SCAN_PRIORITY_EXT_6);
10291029 else
drivers/net/wireless/iwlwifi/pcie/trans.c+19−3
@@ -478,10 +478,16 @@ static void iwl_pcie_apm_stop(struct iwl_trans *trans, bool op_mode_leave) · 477 unmodified lines
478478 if (trans->cfg->device_family == IWL_DEVICE_FAMILY_7000)
479479 iwl_set_bits_prph(trans, APMG_PCIDEV_STT_REG,
480480 APMG_PCIDEV_STT_VAL_WAKE_ME);
481− else if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000)
481+ else if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000) {
482+ iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG,
483+ CSR_RESET_LINK_PWR_MGMT_DISABLED);
482484 iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,
483485 CSR_HW_IF_CONFIG_REG_PREPARE |
484486 CSR_HW_IF_CONFIG_REG_ENABLE_PME);
487+ mdelay(1);
488+ iwl_clear_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG,
489+ CSR_RESET_LINK_PWR_MGMT_DISABLED);
490+ }
485491 mdelay(5);
486492 }
487493
@@ -575,6 +581,10 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) · 87 unmodified lines
575581 if (ret >= 0)
576582 return 0;
577583
584+ iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG,
585+ CSR_RESET_LINK_PWR_MGMT_DISABLED);
586+ msleep(1);
587+
578588 for (iter = 0; iter < 10; iter++) {
579589 /* If HW is not ready, prepare the conditions to check again */
580590 iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,
@@ -582,8 +592,10 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) · 1 unmodified line
582592
583593 do {
584594 ret = iwl_pcie_set_hw_ready(trans);
585− if (ret >= 0)
586− return 0;
595+ if (ret >= 0) {
596+ ret = 0;
597+ goto out;
598+ }
587599
588600 usleep_range(200, 1000);
589601 t += 200;
@@ -593,6 +605,10 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) · 3 unmodified lines
593605
594606 IWL_ERR(trans, "Couldn't prepare the card\n");
595607
608+out:
609+ iwl_clear_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG,
610+ CSR_RESET_LINK_PWR_MGMT_DISABLED);
611+
596612 return ret;
597613 }
598614
drivers/net/wireless/iwlwifi/pcie/tx.c+13−2
@@ -1875,8 +1875,19 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, · 1874 unmodified lines
18751875
18761876 /* start timer if queue currently empty */
18771877 if (q->read_ptr == q->write_ptr) {
1878− if (txq->wd_timeout)
1879− mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout);
1878+ if (txq->wd_timeout) {
1879+ /*
1880+ * If the TXQ is active, then set the timer, if not,
1881+ * set the timer in remainder so that the timer will
1882+ * be armed with the right value when the station will
1883+ * wake up.
1884+ */
1885+ if (!txq->frozen)
1886+ mod_timer(&txq->stuck_timer,
1887+ jiffies + txq->wd_timeout);
1888+ else
1889+ txq->frozen_expiry_remainder = txq->wd_timeout;
1890+ }
18801891 IWL_DEBUG_RPM(trans, "Q: %d first tx - take ref\n", q->id);
18811892 iwl_trans_pcie_ref(trans);
18821893 }
drivers/net/wireless/rsi/rsi_91x_sdio_ops.c+7−1
@@ -172,6 +172,7 @@ static int rsi_load_ta_instructions(struct rsi_common *common) · 171 unmodified lines
172172 (struct rsi_91x_sdiodev *)adapter->rsi_dev;
173173 u32 len;
174174 u32 num_blocks;
175+ const u8 *fw;
175176 const struct firmware *fw_entry = NULL;
176177 u32 block_size = dev->tx_blk_size;
177178 int status = 0;
@@ -200,6 +201,10 @@ static int rsi_load_ta_instructions(struct rsi_common *common) · 22 unmodified lines
200201 return status;
201202 }
202203
204+ /* Copy firmware into DMA-accessible memory */
205+ fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
206+ if (!fw)
207+ return -ENOMEM;
203208 len = fw_entry->size;
204209
205210 if (len % 4)
@@ -210,7 +215,8 @@ static int rsi_load_ta_instructions(struct rsi_common *common) · 4 unmodified lines
210215 rsi_dbg(INIT_ZONE, "%s: Instruction size:%d\n", __func__, len);
211216 rsi_dbg(INIT_ZONE, "%s: num blocks: %d\n", __func__, num_blocks);
212217
213− status = rsi_copy_to_card(common, fw_entry->data, len, num_blocks);
218+ status = rsi_copy_to_card(common, fw, len, num_blocks);
219+ kfree(fw);
214220 release_firmware(fw_entry);
215221 return status;
216222 }
drivers/net/wireless/rsi/rsi_91x_usb_ops.c+4−0
@@ -146,7 +146,10 @@ static int rsi_load_ta_instructions(struct rsi_common *common) · 145 unmodified lines
146146 return status;
147147 }
148148
149+ /* Copy firmware into DMA-accessible memory */
149150 fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
151+ if (!fw)
152+ return -ENOMEM;
150153 len = fw_entry->size;
151154
152155 if (len % 4)
@@ -158,6 +161,7 @@ static int rsi_load_ta_instructions(struct rsi_common *common) · 5 unmodified lines
158161 rsi_dbg(INIT_ZONE, "%s: num blocks: %d\n", __func__, num_blocks);
159162
160163 status = rsi_copy_to_card(common, fw, len, num_blocks);
164+ kfree(fw);
161165 release_firmware(fw_entry);
162166 return status;
163167 }
drivers/net/wireless/rtlwifi/core.c+5−2
@@ -1015,9 +1015,12 @@ static void send_beacon_frame(struct ieee80211_hw *hw, · 1014 unmodified lines
10151015 {
10161016 struct rtl_priv *rtlpriv = rtl_priv(hw);
10171017 struct sk_buff *skb = ieee80211_beacon_get(hw, vif);
1018+ struct rtl_tcb_desc tcb_desc;
10181019
1019− if (skb)
1020− rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, NULL);
1020+ if (skb) {
1021+ memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
1022+ rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, &tcb_desc);
1023+ }
10211024 }
10221025
10231026 static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
drivers/net/wireless/rtlwifi/rtl8723be/sw.c+1−0
@@ -385,6 +385,7 @@ module_param_named(debug, rtl8723be_mod_params.debug, int, 0444); · 384 unmodified lines
385385 module_param_named(ips, rtl8723be_mod_params.inactiveps, bool, 0444);
386386 module_param_named(swlps, rtl8723be_mod_params.swctrl_lps, bool, 0444);
387387 module_param_named(fwlps, rtl8723be_mod_params.fwctrl_lps, bool, 0444);
388+module_param_named(msi, rtl8723be_mod_params.msi_support, bool, 0444);
388389 module_param_named(disable_watchdog, rtl8723be_mod_params.disable_watchdog,
389390 bool, 0444);
390391 MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n");
drivers/net/xen-netback/interface.c+6−0
@@ -61,6 +61,12 @@ void xenvif_skb_zerocopy_prepare(struct xenvif_queue *queue, · 60 unmodified lines
6161 void xenvif_skb_zerocopy_complete(struct xenvif_queue *queue)
6262 {
6363 atomic_dec(&queue->inflight_packets);
64+
65+ /* Wake the dealloc thread _after_ decrementing inflight_packets so
66+ * that if kthread_stop() has already been called, the dealloc thread
67+ * does not wait forever with nothing to wake it.
68+ */
69+ wake_up(&queue->dealloc_wq);
6470 }
6571
6672 int xenvif_schedulable(struct xenvif *vif)
drivers/net/xen-netback/netback.c+33−29
@@ -810,23 +810,17 @@ static inline struct sk_buff *xenvif_alloc_skb(unsigned int size) · 809 unmodified lines
810810 static struct gnttab_map_grant_ref *xenvif_get_requests(struct xenvif_queue *queue,
811811 struct sk_buff *skb,
812812 struct xen_netif_tx_request *txp,
813− struct gnttab_map_grant_ref *gop)
813+ struct gnttab_map_grant_ref *gop,
814+ unsigned int frag_overflow,
815+ struct sk_buff *nskb)
814816 {
815817 struct skb_shared_info *shinfo = skb_shinfo(skb);
816818 skb_frag_t *frags = shinfo->frags;
817819 u16 pending_idx = XENVIF_TX_CB(skb)->pending_idx;
818820 int start;
819821 pending_ring_idx_t index;
820− unsigned int nr_slots, frag_overflow = 0;
822+ unsigned int nr_slots;
821823
822− /* At this point shinfo->nr_frags is in fact the number of
823− * slots, which can be as large as XEN_NETBK_LEGACY_SLOTS_MAX.
824− */
825− if (shinfo->nr_frags > MAX_SKB_FRAGS) {
826− frag_overflow = shinfo->nr_frags - MAX_SKB_FRAGS;
827− BUG_ON(frag_overflow > MAX_SKB_FRAGS);
828− shinfo->nr_frags = MAX_SKB_FRAGS;
829− }
830824 nr_slots = shinfo->nr_frags;
831825
832826 /* Skip first skb fragment if it is on same page as header fragment. */
@@ -841,13 +835,6 @@ static struct gnttab_map_grant_ref *xenvif_get_requests(struct xenvif_queue *que · 8 unmodified lines
841835 }
842836
843837 if (frag_overflow) {
844− struct sk_buff *nskb = xenvif_alloc_skb(0);
845− if (unlikely(nskb == NULL)) {
846− if (net_ratelimit())
847− netdev_err(queue->vif->dev,
848− "Can't allocate the frag_list skb.\n");
849− return NULL;
850− }
851838
852839 shinfo = skb_shinfo(nskb);
853840 frags = shinfo->frags;
@@ -1175,9 +1162,10 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, · 321 unmodified lines
11751162 unsigned *copy_ops,
11761163 unsigned *map_ops)
11771164 {
1178− struct gnttab_map_grant_ref *gop = queue->tx_map_ops, *request_gop;
1179− struct sk_buff *skb;
1165+ struct gnttab_map_grant_ref *gop = queue->tx_map_ops;
1166+ struct sk_buff *skb, *nskb;
11801167 int ret;
1168+ unsigned int frag_overflow;
11811169
11821170 while (skb_queue_len(&queue->tx_queue) < budget) {
11831171 struct xen_netif_tx_request txreq;
@@ -1265,6 +1253,29 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, · 81 unmodified lines
12651253 break;
12661254 }
12671255
1256+ skb_shinfo(skb)->nr_frags = ret;
1257+ if (data_len < txreq.size)
1258+ skb_shinfo(skb)->nr_frags++;
1259+ /* At this point shinfo->nr_frags is in fact the number of
1260+ * slots, which can be as large as XEN_NETBK_LEGACY_SLOTS_MAX.
1261+ */
1262+ frag_overflow = 0;
1263+ nskb = NULL;
1264+ if (skb_shinfo(skb)->nr_frags > MAX_SKB_FRAGS) {
1265+ frag_overflow = skb_shinfo(skb)->nr_frags - MAX_SKB_FRAGS;
1266+ BUG_ON(frag_overflow > MAX_SKB_FRAGS);
1267+ skb_shinfo(skb)->nr_frags = MAX_SKB_FRAGS;
1268+ nskb = xenvif_alloc_skb(0);
1269+ if (unlikely(nskb == NULL)) {
1270+ kfree_skb(skb);
1271+ xenvif_tx_err(queue, &txreq, idx);
1272+ if (net_ratelimit())
1273+ netdev_err(queue->vif->dev,
1274+ "Can't allocate the frag_list skb.\n");
1275+ break;
1276+ }
1277+ }
1278+
12681279 if (extras[XEN_NETIF_EXTRA_TYPE_GSO - 1].type) {
12691280 struct xen_netif_extra_info *gso;
12701281 gso = &extras[XEN_NETIF_EXTRA_TYPE_GSO - 1];
@@ -1272,6 +1283,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, · 1 unmodified line
12721283 if (xenvif_set_skb_gso(queue->vif, skb, gso)) {
12731284 /* Failure in xenvif_set_skb_gso is fatal. */
12741285 kfree_skb(skb);
1286+ kfree_skb(nskb);
12751287 break;
12761288 }
12771289 }
@@ -1294,9 +1306,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, · 16 unmodified lines
12941306
12951307 (*copy_ops)++;
12961308
1297− skb_shinfo(skb)->nr_frags = ret;
12981309 if (data_len < txreq.size) {
1299− skb_shinfo(skb)->nr_frags++;
13001310 frag_set_pending_idx(&skb_shinfo(skb)->frags[0],
13011311 pending_idx);
13021312 xenvif_tx_create_map_op(queue, pending_idx, &txreq, gop);
@@ -1310,13 +1320,8 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, · 7 unmodified lines
13101320
13111321 queue->pending_cons++;
13121322
1313− request_gop = xenvif_get_requests(queue, skb, txfrags, gop);
1314− if (request_gop == NULL) {
1315− kfree_skb(skb);
1316− xenvif_tx_err(queue, &txreq, idx);
1317− break;
1318− }
1319− gop = request_gop;
1323+ gop = xenvif_get_requests(queue, skb, txfrags, gop,
1324+ frag_overflow, nskb);
13201325
13211326 __skb_queue_tail(&queue->tx_queue, skb);
13221327
@@ -1536,7 +1541,6 @@ void xenvif_zerocopy_callback(struct ubuf_info *ubuf, bool zerocopy_success) · 213 unmodified lines
15361541 smp_wmb();
15371542 queue->dealloc_prod++;
15381543 } while (ubuf);
1539− wake_up(&queue->dealloc_wq);
15401544 spin_unlock_irqrestore(&queue->callback_lock, flags);
15411545
15421546 if (likely(zerocopy_success))
drivers/ntb/ntb.c+1−1
@@ -114,7 +114,7 @@ int ntb_register_device(struct ntb_dev *ntb) · 113 unmodified lines
114114 ntb->dev.bus = &ntb_bus;
115115 ntb->dev.parent = &ntb->pdev->dev;
116116 ntb->dev.release = ntb_dev_release;
117− dev_set_name(&ntb->dev, pci_name(ntb->pdev));
117+ dev_set_name(&ntb->dev, "%s", pci_name(ntb->pdev));
118118
119119 ntb->ctx = NULL;
120120 ntb->ctx_ops = NULL;
drivers/ntb/ntb_transport.c+124−77
@@ -142,10 +142,11 @@ struct ntb_transport_qp { · 141 unmodified lines
142142
143143 void (*rx_handler)(struct ntb_transport_qp *qp, void *qp_data,
144144 void *data, int len);
145+ struct list_head rx_post_q;
145146 struct list_head rx_pend_q;
146147 struct list_head rx_free_q;
147− spinlock_t ntb_rx_pend_q_lock;
148− spinlock_t ntb_rx_free_q_lock;
148+ /* ntb_rx_q_lock: synchronize access to rx_XXXX_q */
149+ spinlock_t ntb_rx_q_lock;
149150 void *rx_buff;
150151 unsigned int rx_index;
151152 unsigned int rx_max_entry;
@@ -211,6 +212,8 @@ struct ntb_transport_ctx { · 59 unmodified lines
211212 bool link_is_up;
212213 struct delayed_work link_work;
213214 struct work_struct link_cleanup;
215+
216+ struct dentry *debugfs_node_dir;
214217 };
215218
216219 enum {
@@ -436,13 +439,17 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count, · 219 unmodified lines
436439 char *buf;
437440 ssize_t ret, out_offset, out_count;
438441
442+ qp = filp->private_data;
443+
444+ if (!qp || !qp->link_is_up)
445+ return 0;
446+
439447 out_count = 1000;
440448
441449 buf = kmalloc(out_count, GFP_KERNEL);
442450 if (!buf)
443451 return -ENOMEM;
444452
445− qp = filp->private_data;
446453 out_offset = 0;
447454 out_offset += snprintf(buf + out_offset, out_count - out_offset,
448455 "NTB QP stats\n");
@@ -534,6 +541,27 @@ out: · 85 unmodified lines
534541 return entry;
535542 }
536543
544+static struct ntb_queue_entry *ntb_list_mv(spinlock_t *lock,
545+ struct list_head *list,
546+ struct list_head *to_list)
547+{
548+ struct ntb_queue_entry *entry;
549+ unsigned long flags;
550+
551+ spin_lock_irqsave(lock, flags);
552+
553+ if (list_empty(list)) {
554+ entry = NULL;
555+ } else {
556+ entry = list_first_entry(list, struct ntb_queue_entry, entry);
557+ list_move_tail(&entry->entry, to_list);
558+ }
559+
560+ spin_unlock_irqrestore(lock, flags);
561+
562+ return entry;
563+}
564+
537565 static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt,
538566 unsigned int qp_num)
539567 {
@@ -601,13 +629,16 @@ static void ntb_free_mw(struct ntb_transport_ctx *nt, int num_mw) · 61 unmodified lines
601629 }
602630
603631 static int ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw,
604− unsigned int size)
632+ resource_size_t size)
605633 {
606634 struct ntb_transport_mw *mw = &nt->mw_vec[num_mw];
607635 struct pci_dev *pdev = nt->ndev->pdev;
608− unsigned int xlat_size, buff_size;
636+ size_t xlat_size, buff_size;
609637 int rc;
610638
639+ if (!size)
640+ return -EINVAL;
641+
611642 xlat_size = round_up(size, mw->xlat_align_size);
612643 buff_size = round_up(size, mw->xlat_align);
613644
@@ -627,7 +658,7 @@ static int ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw, · 13 unmodified lines
627658 if (!mw->virt_addr) {
628659 mw->xlat_size = 0;
629660 mw->buff_size = 0;
630− dev_err(&pdev->dev, "Unable to alloc MW buff of size %d\n",
661+ dev_err(&pdev->dev, "Unable to alloc MW buff of size %zu\n",
631662 buff_size);
632663 return -ENOMEM;
633664 }
@@ -867,6 +898,8 @@ static void ntb_qp_link_work(struct work_struct *work) · 233 unmodified lines
867898
868899 if (qp->event_handler)
869900 qp->event_handler(qp->cb_data, qp->link_is_up);
901+
902+ tasklet_schedule(&qp->rxc_db_work);
870903 } else if (nt->link_is_up)
871904 schedule_delayed_work(&qp->link_work,
872905 msecs_to_jiffies(NTB_LINK_DOWN_TIMEOUT));
@@ -923,12 +956,12 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt, · 50 unmodified lines
923956 qp->tx_max_frame = min(transport_mtu, tx_size / 2);
924957 qp->tx_max_entry = tx_size / qp->tx_max_frame;
925958
926− if (nt_debugfs_dir) {
959+ if (nt->debugfs_node_dir) {
927960 char debugfs_name[4];
928961
929962 snprintf(debugfs_name, 4, "qp%d", qp_num);
930963 qp->debugfs_dir = debugfs_create_dir(debugfs_name,
931− nt_debugfs_dir);
964+ nt->debugfs_node_dir);
932965
933966 qp->debugfs_stats = debugfs_create_file("stats", S_IRUSR,
934967 qp->debugfs_dir, qp,
@@ -941,10 +974,10 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt, · 6 unmodified lines
941974 INIT_DELAYED_WORK(&qp->link_work, ntb_qp_link_work);
942975 INIT_WORK(&qp->link_cleanup, ntb_qp_link_cleanup_work);
943976
944− spin_lock_init(&qp->ntb_rx_pend_q_lock);
945− spin_lock_init(&qp->ntb_rx_free_q_lock);
977+ spin_lock_init(&qp->ntb_rx_q_lock);
946978 spin_lock_init(&qp->ntb_tx_free_q_lock);
947979
980+ INIT_LIST_HEAD(&qp->rx_post_q);
948981 INIT_LIST_HEAD(&qp->rx_pend_q);
949982 INIT_LIST_HEAD(&qp->rx_free_q);
950983 INIT_LIST_HEAD(&qp->tx_free_q);
@@ -1031,6 +1064,12 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) · 80 unmodified lines
10311064 goto err2;
10321065 }
10331066
1067+ if (nt_debugfs_dir) {
1068+ nt->debugfs_node_dir =
1069+ debugfs_create_dir(pci_name(ndev->pdev),
1070+ nt_debugfs_dir);
1071+ }
1072+
10341073 for (i = 0; i < qp_count; i++) {
10351074 rc = ntb_transport_init_queue(nt, i);
10361075 if (rc)
@@ -1107,22 +1146,47 @@ static void ntb_transport_free(struct ntb_client *self, struct ntb_dev *ndev) · 70 unmodified lines
11071146 kfree(nt);
11081147 }
11091148
1110−static void ntb_rx_copy_callback(void *data)
1149+static void ntb_complete_rxc(struct ntb_transport_qp *qp)
11111150 {
1112− struct ntb_queue_entry *entry = data;
1113− struct ntb_transport_qp *qp = entry->qp;
1114− void *cb_data = entry->cb_data;
1115− unsigned int len = entry->len;
1116− struct ntb_payload_header *hdr = entry->rx_hdr;
1151+ struct ntb_queue_entry *entry;
1152+ void *cb_data;
1153+ unsigned int len;
1154+ unsigned long irqflags;
1155+
1156+ spin_lock_irqsave(&qp->ntb_rx_q_lock, irqflags);
1157+
1158+ while (!list_empty(&qp->rx_post_q)) {
1159+ entry = list_first_entry(&qp->rx_post_q,
1160+ struct ntb_queue_entry, entry);
1161+ if (!(entry->flags & DESC_DONE_FLAG))
1162+ break;
1163+
1164+ entry->rx_hdr->flags = 0;
1165+ iowrite32(entry->index, &qp->rx_info->entry);
11171166
1118− hdr->flags = 0;
1167+ cb_data = entry->cb_data;
1168+ len = entry->len;
11191169
1120− iowrite32(entry->index, &qp->rx_info->entry);
1170+ list_move_tail(&entry->entry, &qp->rx_free_q);
11211171
1122− ntb_list_add(&qp->ntb_rx_free_q_lock, &entry->entry, &qp->rx_free_q);
1172+ spin_unlock_irqrestore(&qp->ntb_rx_q_lock, irqflags);
11231173
1124− if (qp->rx_handler && qp->client_ready)
1125− qp->rx_handler(qp, qp->cb_data, cb_data, len);
1174+ if (qp->rx_handler && qp->client_ready)
1175+ qp->rx_handler(qp, qp->cb_data, cb_data, len);
1176+
1177+ spin_lock_irqsave(&qp->ntb_rx_q_lock, irqflags);
1178+ }
1179+
1180+ spin_unlock_irqrestore(&qp->ntb_rx_q_lock, irqflags);
1181+}
1182+
1183+static void ntb_rx_copy_callback(void *data)
1184+{
1185+ struct ntb_queue_entry *entry = data;
1186+
1187+ entry->flags |= DESC_DONE_FLAG;
1188+
1189+ ntb_complete_rxc(entry->qp);
11261190 }
11271191
11281192 static void ntb_memcpy_rx(struct ntb_queue_entry *entry, void *offset)
@@ -1138,19 +1202,18 @@ static void ntb_memcpy_rx(struct ntb_queue_entry *entry, void *offset) · 9 unmodified lines
11381202 ntb_rx_copy_callback(entry);
11391203 }
11401204
1141−static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,
1142− size_t len)
1205+static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset)
11431206 {
11441207 struct dma_async_tx_descriptor *txd;
11451208 struct ntb_transport_qp *qp = entry->qp;
11461209 struct dma_chan *chan = qp->dma_chan;
11471210 struct dma_device *device;
1148− size_t pay_off, buff_off;
1211+ size_t pay_off, buff_off, len;
11491212 struct dmaengine_unmap_data *unmap;
11501213 dma_cookie_t cookie;
11511214 void *buf = entry->buf;
11521215
1153− entry->len = len;
1216+ len = entry->len;
11541217
11551218 if (!chan)
11561219 goto err;
@@ -1226,7 +1289,6 @@ static int ntb_process_rxc(struct ntb_transport_qp *qp) · 69 unmodified lines
12261289 struct ntb_payload_header *hdr;
12271290 struct ntb_queue_entry *entry;
12281291 void *offset;
1229− int rc;
12301292
12311293 offset = qp->rx_buff + qp->rx_max_frame * qp->rx_index;
12321294 hdr = offset + qp->rx_max_frame - sizeof(struct ntb_payload_header);
@@ -1255,65 +1317,43 @@ static int ntb_process_rxc(struct ntb_transport_qp *qp) · 22 unmodified lines
12551317 return -EIO;
12561318 }
12571319
1258− entry = ntb_list_rm(&qp->ntb_rx_pend_q_lock, &qp->rx_pend_q);
1320+ entry = ntb_list_mv(&qp->ntb_rx_q_lock, &qp->rx_pend_q, &qp->rx_post_q);
12591321 if (!entry) {
12601322 dev_dbg(&qp->ndev->pdev->dev, "no receive buffer\n");
12611323 qp->rx_err_no_buf++;
1262−
1263− rc = -ENOMEM;
1264− goto err;
1324+ return -EAGAIN;
12651325 }
12661326
1327+ entry->rx_hdr = hdr;
1328+ entry->index = qp->rx_index;
1329+
12671330 if (hdr->len > entry->len) {
12681331 dev_dbg(&qp->ndev->pdev->dev,
12691332 "receive buffer overflow! Wanted %d got %d\n",
12701333 hdr->len, entry->len);
12711334 qp->rx_err_oflow++;
12721335
1273− rc = -EIO;
1274− goto err;
1275− }
1336+ entry->len = -EIO;
1337+ entry->flags |= DESC_DONE_FLAG;
12761338
1277− dev_dbg(&qp->ndev->pdev->dev,
1278− "RX OK index %u ver %u size %d into buf size %d\n",
1279− qp->rx_index, hdr->ver, hdr->len, entry->len);
1339+ ntb_complete_rxc(qp);
1340+ } else {
1341+ dev_dbg(&qp->ndev->pdev->dev,
1342+ "RX OK index %u ver %u size %d into buf size %d\n",
1343+ qp->rx_index, hdr->ver, hdr->len, entry->len);
12801344
1281− qp->rx_bytes += hdr->len;
1282− qp->rx_pkts++;
1345+ qp->rx_bytes += hdr->len;
1346+ qp->rx_pkts++;
12831347
1284− entry->index = qp->rx_index;
1285− entry->rx_hdr = hdr;
1348+ entry->len = hdr->len;
12861349
1287− ntb_async_rx(entry, offset, hdr->len);
1350+ ntb_async_rx(entry, offset);
1351+ }
12881352
12891353 qp->rx_index++;
12901354 qp->rx_index %= qp->rx_max_entry;
12911355
12921356 return 0;
1293−
1294−err:
1295− /* FIXME: if this syncrhonous update of the rx_index gets ahead of
1296− * asyncrhonous ntb_rx_copy_callback of previous entry, there are three
1297− * scenarios:
1298− *
1299− * 1) The peer might miss this update, but observe the update
1300− * from the memcpy completion callback. In this case, the buffer will
1301− * not be freed on the peer to be reused for a different packet. The
1302− * successful rx of a later packet would clear the condition, but the
1303− * condition could persist if several rx fail in a row.
1304− *
1305− * 2) The peer may observe this update before the asyncrhonous copy of
1306− * prior packets is completed. The peer may overwrite the buffers of
1307− * the prior packets before they are copied.
1308− *
1309− * 3) Both: the peer may observe the update, and then observe the index
1310− * decrement by the asynchronous completion callback. Who knows what
1311− * badness that will cause.
1312− */
1313− hdr->flags = 0;
1314− iowrite32(qp->rx_index, &qp->rx_info->entry);
1315−
1316− return rc;
13171357 }
13181358
13191359 static void ntb_transport_rxc_db(unsigned long data)
@@ -1333,7 +1373,7 @@ static void ntb_transport_rxc_db(unsigned long data) · 13 unmodified lines
13331373 break;
13341374 }
13351375
1336− if (qp->dma_chan)
1376+ if (i && qp->dma_chan)
13371377 dma_async_issue_pending(qp->dma_chan);
13381378
13391379 if (i == qp->rx_max_entry) {
@@ -1609,7 +1649,7 @@ ntb_transport_create_queue(void *data, struct device *client_dev, · 269 unmodified lines
16091649 goto err1;
16101650
16111651 entry->qp = qp;
1612− ntb_list_add(&qp->ntb_rx_free_q_lock, &entry->entry,
1652+ ntb_list_add(&qp->ntb_rx_q_lock, &entry->entry,
16131653 &qp->rx_free_q);
16141654 }
16151655
@@ -1634,7 +1674,7 @@ err2: · 18 unmodified lines
16341674 while ((entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q)))
16351675 kfree(entry);
16361676 err1:
1637− while ((entry = ntb_list_rm(&qp->ntb_rx_free_q_lock, &qp->rx_free_q)))
1677+ while ((entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_free_q)))
16381678 kfree(entry);
16391679 if (qp->dma_chan)
16401680 dma_release_channel(qp->dma_chan);
@@ -1652,7 +1692,6 @@ EXPORT_SYMBOL_GPL(ntb_transport_create_queue); · 11 unmodified lines
16521692 */
16531693 void ntb_transport_free_queue(struct ntb_transport_qp *qp)
16541694 {
1655− struct ntb_transport_ctx *nt = qp->transport;
16561695 struct pci_dev *pdev;
16571696 struct ntb_queue_entry *entry;
16581697 u64 qp_bit;
@@ -1689,18 +1728,23 @@ void ntb_transport_free_queue(struct ntb_transport_qp *qp) · 30 unmodified lines
16891728 qp->tx_handler = NULL;
16901729 qp->event_handler = NULL;
16911730
1692− while ((entry = ntb_list_rm(&qp->ntb_rx_free_q_lock, &qp->rx_free_q)))
1731+ while ((entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_free_q)))
16931732 kfree(entry);
16941733
1695− while ((entry = ntb_list_rm(&qp->ntb_rx_pend_q_lock, &qp->rx_pend_q))) {
1696− dev_warn(&pdev->dev, "Freeing item from a non-empty queue\n");
1734+ while ((entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_pend_q))) {
1735+ dev_warn(&pdev->dev, "Freeing item from non-empty rx_pend_q\n");
1736+ kfree(entry);
1737+ }
1738+
1739+ while ((entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_post_q))) {
1740+ dev_warn(&pdev->dev, "Freeing item from non-empty rx_post_q\n");
16971741 kfree(entry);
16981742 }
16991743
17001744 while ((entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q)))
17011745 kfree(entry);
17021746
1703− nt->qp_bitmap_free |= qp_bit;
1747+ qp->transport->qp_bitmap_free |= qp_bit;
17041748
17051749 dev_info(&pdev->dev, "NTB Transport QP %d freed\n", qp->qp_num);
17061750 }
@@ -1724,14 +1768,14 @@ void *ntb_transport_rx_remove(struct ntb_transport_qp *qp, unsigned int *len) · 17 unmodified lines
17241768 if (!qp || qp->client_ready)
17251769 return NULL;
17261770
1727− entry = ntb_list_rm(&qp->ntb_rx_pend_q_lock, &qp->rx_pend_q);
1771+ entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_pend_q);
17281772 if (!entry)
17291773 return NULL;
17301774
17311775 buf = entry->cb_data;
17321776 *len = entry->len;
17331777
1734− ntb_list_add(&qp->ntb_rx_free_q_lock, &entry->entry, &qp->rx_free_q);
1778+ ntb_list_add(&qp->ntb_rx_q_lock, &entry->entry, &qp->rx_free_q);
17351779
17361780 return buf;
17371781 }
@@ -1757,15 +1801,18 @@ int ntb_transport_rx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data, · 19 unmodified lines
17571801 if (!qp)
17581802 return -EINVAL;
17591803
1760− entry = ntb_list_rm(&qp->ntb_rx_free_q_lock, &qp->rx_free_q);
1804+ entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_free_q);
17611805 if (!entry)
17621806 return -ENOMEM;
17631807
17641808 entry->cb_data = cb;
17651809 entry->buf = data;
17661810 entry->len = len;
1811+ entry->flags = 0;
1812+
1813+ ntb_list_add(&qp->ntb_rx_q_lock, &entry->entry, &qp->rx_pend_q);
17671814
1768− ntb_list_add(&qp->ntb_rx_pend_q_lock, &entry->entry, &qp->rx_pend_q);
1815+ tasklet_schedule(&qp->rxc_db_work);
17691816
17701817 return 0;
17711818 }
drivers/of/Kconfig+1−1
@@ -47,7 +47,7 @@ config OF_DYNAMIC · 46 unmodified lines
4747
4848 config OF_ADDRESS
4949 def_bool y
50− depends on !SPARC
50+ depends on !SPARC && HAS_IOMEM
5151 select OF_ADDRESS_PCI if PCI
5252
5353 config OF_ADDRESS_PCI
drivers/of/unittest.c+0−3
@@ -979,7 +979,6 @@ static struct platform_driver unittest_driver = { · 978 unmodified lines
979979 .remove = unittest_remove,
980980 .driver = {
981981 .name = "unittest",
982− .owner = THIS_MODULE,
983982 .of_match_table = of_match_ptr(unittest_match),
984983 },
985984 };
@@ -1666,7 +1665,6 @@ static const struct i2c_device_id unittest_i2c_dev_id[] = { · 680 unmodified lines
16661665 static struct i2c_driver unittest_i2c_dev_driver = {
16671666 .driver = {
16681667 .name = "unittest-i2c-dev",
1669− .owner = THIS_MODULE,
16701668 },
16711669 .probe = unittest_i2c_dev_probe,
16721670 .remove = unittest_i2c_dev_remove,
@@ -1761,7 +1759,6 @@ static const struct i2c_device_id unittest_i2c_mux_id[] = { · 88 unmodified lines
17611759 static struct i2c_driver unittest_i2c_mux_driver = {
17621760 .driver = {
17631761 .name = "unittest-i2c-mux",
1764− .owner = THIS_MODULE,
17651762 },
17661763 .probe = unittest_i2c_mux_probe,
17671764 .remove = unittest_i2c_mux_remove,
drivers/phy/phy-sun4i-usb.c+1−0
@@ -212,6 +212,7 @@ void sun4i_usb_phy_set_squelch_detect(struct phy *_phy, bool enabled) · 211 unmodified lines
212212
213213 sun4i_usb_phy_write(phy, PHY_SQUELCH_DETECT, enabled ? 0 : 2, 2);
214214 }
215+EXPORT_SYMBOL_GPL(sun4i_usb_phy_set_squelch_detect);
215216
216217 static struct phy_ops sun4i_usb_phy_ops = {
217218 .init = sun4i_usb_phy_init,
drivers/phy/phy-ti-pipe3.c+55−6
@@ -28,6 +28,8 @@ · 27 unmodified lines
2828 #include <linux/delay.h>
2929 #include <linux/phy/omap_control_phy.h>
3030 #include <linux/of_platform.h>
31+#include <linux/mfd/syscon.h>
32+#include <linux/regmap.h>
3133
3234 #define PLL_STATUS 0x00000004
3335 #define PLL_GO 0x00000008
@@ -52,6 +54,8 @@ · 18 unmodified lines
5254 #define PLL_LOCK 0x2
5355 #define PLL_IDLE 0x1
5456
57+#define SATA_PLL_SOFT_RESET BIT(18)
58+
5559 /*
5660 * This is an Empirical value that works, need to confirm the actual
5761 * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status
@@ -82,6 +86,9 @@ struct ti_pipe3 { · 24 unmodified lines
8286 struct clk *refclk;
8387 struct clk *div_clk;
8488 struct pipe3_dpll_map *dpll_map;
89+ struct regmap *dpll_reset_syscon; /* ctrl. reg. acces */
90+ unsigned int dpll_reset_reg; /* reg. index within syscon */
91+ bool sata_refclk_enabled;
8592 };
8693
8794 static struct pipe3_dpll_map dpll_map_usb[] = {
@@ -249,8 +256,11 @@ static int ti_pipe3_exit(struct phy *x) · 161 unmodified lines
249256 u32 val;
250257 unsigned long timeout;
251258
252− /* SATA DPLL can't be powered down due to Errata i783 */
253− if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata"))
259+ /* If dpll_reset_syscon is not present we wont power down SATA DPLL
260+ * due to Errata i783
261+ */
262+ if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata") &&
263+ !phy->dpll_reset_syscon)
254264 return 0;
255265
256266 /* PCIe doesn't have internal DPLL */
@@ -276,6 +286,14 @@ static int ti_pipe3_exit(struct phy *x) · 19 unmodified lines
276286 }
277287 }
278288
289+ /* i783: SATA needs control bit toggle after PLL unlock */
290+ if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata")) {
291+ regmap_update_bits(phy->dpll_reset_syscon, phy->dpll_reset_reg,
292+ SATA_PLL_SOFT_RESET, SATA_PLL_SOFT_RESET);
293+ regmap_update_bits(phy->dpll_reset_syscon, phy->dpll_reset_reg,
294+ SATA_PLL_SOFT_RESET, 0);
295+ }
296+
279297 ti_pipe3_disable_clocks(phy);
280298
281299 return 0;
@@ -350,6 +368,21 @@ static int ti_pipe3_probe(struct platform_device *pdev) · 68 unmodified lines
350368 }
351369 } else {
352370 phy->wkupclk = ERR_PTR(-ENODEV);
371+ phy->dpll_reset_syscon = syscon_regmap_lookup_by_phandle(node,
372+ "syscon-pllreset");
373+ if (IS_ERR(phy->dpll_reset_syscon)) {
374+ dev_info(&pdev->dev,
375+ "can't get syscon-pllreset, sata dpll won't idle\n");
376+ phy->dpll_reset_syscon = NULL;
377+ } else {
378+ if (of_property_read_u32_index(node,
379+ "syscon-pllreset", 1,
380+ &phy->dpll_reset_reg)) {
381+ dev_err(&pdev->dev,
382+ "couldn't get pllreset reg. offset\n");
383+ return -EINVAL;
384+ }
385+ }
353386 }
354387
355388 if (of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
@@ -402,10 +435,16 @@ static int ti_pipe3_probe(struct platform_device *pdev) · 46 unmodified lines
402435
403436 platform_set_drvdata(pdev, phy);
404437 pm_runtime_enable(phy->dev);
405− /* Prevent auto-disable of refclk for SATA PHY due to Errata i783 */
406− if (of_device_is_compatible(node, "ti,phy-pipe3-sata"))
407− if (!IS_ERR(phy->refclk))
438+
439+ /*
440+ * Prevent auto-disable of refclk for SATA PHY due to Errata i783
441+ */
442+ if (of_device_is_compatible(node, "ti,phy-pipe3-sata")) {
443+ if (!IS_ERR(phy->refclk)) {
408444 clk_prepare_enable(phy->refclk);
445+ phy->sata_refclk_enabled = true;
446+ }
447+ }
409448
410449 generic_phy = devm_phy_create(phy->dev, NULL, &ops);
411450 if (IS_ERR(generic_phy))
@@ -472,8 +511,18 @@ static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy) · 60 unmodified lines
472511 {
473512 if (!IS_ERR(phy->wkupclk))
474513 clk_disable_unprepare(phy->wkupclk);
475− if (!IS_ERR(phy->refclk))
514+ if (!IS_ERR(phy->refclk)) {
476515 clk_disable_unprepare(phy->refclk);
516+ /*
517+ * SATA refclk needs an additional disable as we left it
518+ * on in probe to avoid Errata i783
519+ */
520+ if (phy->sata_refclk_enabled) {
521+ clk_disable_unprepare(phy->refclk);
522+ phy->sata_refclk_enabled = false;
523+ }
524+ }
525+
477526 if (!IS_ERR(phy->div_clk))
478527 clk_disable_unprepare(phy->div_clk);
479528 }
drivers/platform/chrome/Kconfig+0−1
@@ -4,7 +4,6 @@ · 3 unmodified lines
44
55 menuconfig CHROME_PLATFORMS
66 bool "Platform support for Chrome hardware"
7− depends on X86 || ARM
87 ---help---
98 Say Y here to get to see options for platform support for
109 various Chromebooks and Chromeboxes. This option alone does
drivers/scsi/ipr.c+18−10
@@ -599,9 +599,10 @@ static void ipr_trc_hook(struct ipr_cmnd *ipr_cmd, · 598 unmodified lines
599599 {
600600 struct ipr_trace_entry *trace_entry;
601601 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
602+ unsigned int trace_index;
602603
603− trace_entry = &ioa_cfg->trace[atomic_add_return
604− (1, &ioa_cfg->trace_index)%IPR_NUM_TRACE_ENTRIES];
604+ trace_index = atomic_add_return(1, &ioa_cfg->trace_index) & IPR_TRACE_INDEX_MASK;
605+ trace_entry = &ioa_cfg->trace[trace_index];
605606 trace_entry->time = jiffies;
606607 trace_entry->op_code = ipr_cmd->ioarcb.cmd_pkt.cdb[0];
607608 trace_entry->type = type;
@@ -1051,10 +1052,15 @@ static void ipr_send_blocking_cmd(struct ipr_cmnd *ipr_cmd, · 443 unmodified lines
10511052
10521053 static int ipr_get_hrrq_index(struct ipr_ioa_cfg *ioa_cfg)
10531054 {
1055+ unsigned int hrrq;
1056+
10541057 if (ioa_cfg->hrrq_num == 1)
1055− return 0;
1056− else
1057− return (atomic_add_return(1, &ioa_cfg->hrrq_index) % (ioa_cfg->hrrq_num - 1)) + 1;
1058+ hrrq = 0;
1059+ else {
1060+ hrrq = atomic_add_return(1, &ioa_cfg->hrrq_index);
1061+ hrrq = (hrrq % (ioa_cfg->hrrq_num - 1)) + 1;
1062+ }
1063+ return hrrq;
10581064 }
10591065
10601066 /**
@@ -6263,21 +6269,23 @@ static void ipr_scsi_done(struct ipr_cmnd *ipr_cmd) · 5202 unmodified lines
62636269 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
62646270 struct scsi_cmnd *scsi_cmd = ipr_cmd->scsi_cmd;
62656271 u32 ioasc = be32_to_cpu(ipr_cmd->s.ioasa.hdr.ioasc);
6266− unsigned long hrrq_flags;
6272+ unsigned long lock_flags;
62676273
62686274 scsi_set_resid(scsi_cmd, be32_to_cpu(ipr_cmd->s.ioasa.hdr.residual_data_len));
62696275
62706276 if (likely(IPR_IOASC_SENSE_KEY(ioasc) == 0)) {
62716277 scsi_dma_unmap(scsi_cmd);
62726278
6273− spin_lock_irqsave(ipr_cmd->hrrq->lock, hrrq_flags);
6279+ spin_lock_irqsave(ipr_cmd->hrrq->lock, lock_flags);
62746280 list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
62756281 scsi_cmd->scsi_done(scsi_cmd);
6276− spin_unlock_irqrestore(ipr_cmd->hrrq->lock, hrrq_flags);
6282+ spin_unlock_irqrestore(ipr_cmd->hrrq->lock, lock_flags);
62776283 } else {
6278− spin_lock_irqsave(ipr_cmd->hrrq->lock, hrrq_flags);
6284+ spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
6285+ spin_lock(&ipr_cmd->hrrq->_lock);
62796286 ipr_erp_start(ioa_cfg, ipr_cmd);
6280− spin_unlock_irqrestore(ipr_cmd->hrrq->lock, hrrq_flags);
6287+ spin_unlock(&ipr_cmd->hrrq->_lock);
6288+ spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
62816289 }
62826290 }
62836291
drivers/scsi/ipr.h+1−0
@@ -1486,6 +1486,7 @@ struct ipr_ioa_cfg { · 1485 unmodified lines
14861486
14871487 #define IPR_NUM_TRACE_INDEX_BITS 8
14881488 #define IPR_NUM_TRACE_ENTRIES (1 << IPR_NUM_TRACE_INDEX_BITS)
1489+#define IPR_TRACE_INDEX_MASK (IPR_NUM_TRACE_ENTRIES - 1)
14891490 #define IPR_TRACE_SIZE (sizeof(struct ipr_trace_entry) * IPR_NUM_TRACE_ENTRIES)
14901491 char trace_start[8];
14911492 #define IPR_TRACE_START_LABEL "trace"
drivers/scsi/libfc/fc_exch.c+4−4
@@ -733,8 +733,6 @@ static bool fc_invoke_resp(struct fc_exch *ep, struct fc_seq *sp, · 732 unmodified lines
733733 if (resp) {
734734 resp(sp, fp, arg);
735735 res = true;
736− } else if (!IS_ERR(fp)) {
737− fc_frame_free(fp);
738736 }
739737
740738 spin_lock_bh(&ep->ex_lock);
@@ -1596,7 +1594,8 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp) · 855 unmodified lines
15961594 * If new exch resp handler is valid then call that
15971595 * first.
15981596 */
1599− fc_invoke_resp(ep, sp, fp);
1597+ if (!fc_invoke_resp(ep, sp, fp))
1598+ fc_frame_free(fp);
16001599
16011600 fc_exch_release(ep);
16021601 return;
@@ -1695,7 +1694,8 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp) · 92 unmodified lines
16951694 fc_exch_hold(ep);
16961695 if (!rc)
16971696 fc_exch_delete(ep);
1698− fc_invoke_resp(ep, sp, fp);
1697+ if (!fc_invoke_resp(ep, sp, fp))
1698+ fc_frame_free(fp);
16991699 if (has_rec)
17001700 fc_exch_timer_set(ep, ep->r_a_tov);
17011701 fc_exch_release(ep);
drivers/scsi/libfc/fc_fcp.c+17−2
@@ -1039,11 +1039,26 @@ restart: · 1038 unmodified lines
10391039 fc_fcp_pkt_hold(fsp);
10401040 spin_unlock_irqrestore(&si->scsi_queue_lock, flags);
10411041
1042− if (!fc_fcp_lock_pkt(fsp)) {
1042+ spin_lock_bh(&fsp->scsi_pkt_lock);
1043+ if (!(fsp->state & FC_SRB_COMPL)) {
1044+ fsp->state |= FC_SRB_COMPL;
1045+ /*
1046+ * TODO: dropping scsi_pkt_lock and then reacquiring
1047+ * again around fc_fcp_cleanup_cmd() is required,
1048+ * since fc_fcp_cleanup_cmd() calls into
1049+ * fc_seq_set_resp() and that func preempts cpu using
1050+ * schedule. May be schedule and related code should be
1051+ * removed instead of unlocking here to avoid scheduling
1052+ * while atomic bug.
1053+ */
1054+ spin_unlock_bh(&fsp->scsi_pkt_lock);
1055+
10431056 fc_fcp_cleanup_cmd(fsp, error);
1057+
1058+ spin_lock_bh(&fsp->scsi_pkt_lock);
10441059 fc_io_compl(fsp);
1045− fc_fcp_unlock_pkt(fsp);
10461060 }
1061+ spin_unlock_bh(&fsp->scsi_pkt_lock);
10471062
10481063 fc_fcp_pkt_release(fsp);
10491064 spin_lock_irqsave(&si->scsi_queue_lock, flags);
drivers/scsi/libiscsi.c+2−23
@@ -2941,10 +2941,10 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) · 2940 unmodified lines
29412941 {
29422942 struct iscsi_conn *conn = cls_conn->dd_data;
29432943 struct iscsi_session *session = conn->session;
2944− unsigned long flags;
29452944
29462945 del_timer_sync(&conn->transport_timer);
29472946
2947+ mutex_lock(&session->eh_mutex);
29482948 spin_lock_bh(&session->frwd_lock);
29492949 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT;
29502950 if (session->leadconn == conn) {
@@ -2956,28 +2956,6 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) · 5 unmodified lines
29562956 }
29572957 spin_unlock_bh(&session->frwd_lock);
29582958
2959− /*
2960− * Block until all in-progress commands for this connection
2961− * time out or fail.
2962− */
2963− for (;;) {
2964− spin_lock_irqsave(session->host->host_lock, flags);
2965− if (!atomic_read(&session->host->host_busy)) { /* OK for ERL == 0 */
2966− spin_unlock_irqrestore(session->host->host_lock, flags);
2967− break;
2968− }
2969− spin_unlock_irqrestore(session->host->host_lock, flags);
2970− msleep_interruptible(500);
2971− iscsi_conn_printk(KERN_INFO, conn, "iscsi conn_destroy(): "
2972− "host_busy %d host_failed %d\n",
2973− atomic_read(&session->host->host_busy),
2974− session->host->host_failed);
2975− /*
2976− * force eh_abort() to unblock
2977− */
2978− wake_up(&conn->ehwait);
2979− }
2980−
29812959 /* flush queued up work because we free the connection below */
29822960 iscsi_suspend_tx(conn);
29832961
@@ -2994,6 +2972,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) · 10 unmodified lines
29942972 if (session->leadconn == conn)
29952973 session->leadconn = NULL;
29962974 spin_unlock_bh(&session->frwd_lock);
2975+ mutex_unlock(&session->eh_mutex);
29972976
29982977 iscsi_destroy_conn(cls_conn);
29992978 }
drivers/scsi/qla2xxx/qla_attr.c+1−1
@@ -738,7 +738,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, · 737 unmodified lines
738738 ql_log(ql_log_info, vha, 0x706f,
739739 "Issuing MPI reset.\n");
740740
741− if (IS_QLA83XX(ha)) {
741+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
742742 uint32_t idc_control;
743743
744744 qla83xx_idc_lock(vha, 0);
drivers/scsi/qla2xxx/qla_dbg.c+3−3
@@ -67,10 +67,10 @@ · 66 unmodified lines
6767 * | | | 0xd031-0xd0ff |
6868 * | | | 0xd101-0xd1fe |
6969 * | | | 0xd214-0xd2fe |
70− * | Target Mode | 0xe079 | |
71− * | Target Mode Management | 0xf072 | 0xf002 |
70+ * | Target Mode | 0xe080 | |
71+ * | Target Mode Management | 0xf096 | 0xf002 |
7272 * | | | 0xf046-0xf049 |
73− * | Target Mode Task Management | 0x1000b | |
73+ * | Target Mode Task Management | 0x1000d | |
7474 * ----------------------------------------------------------------------
7575 */
7676
drivers/scsi/qla2xxx/qla_def.h+16−4
@@ -274,6 +274,7 @@ · 273 unmodified lines
274274 #define RESPONSE_ENTRY_CNT_FX00 256 /* Number of response entries.*/
275275
276276 struct req_que;
277+struct qla_tgt_sess;
277278
278279 /*
279280 * (sd.h is not exported, hence local inclusion)
@@ -2026,6 +2027,7 @@ typedef struct fc_port { · 1746 unmodified lines
20262027 uint16_t port_id;
20272028
20282029 unsigned long retry_delay_timestamp;
2030+ struct qla_tgt_sess *tgt_session;
20292031 } fc_port_t;
20302032
20312033 #include "qla_mr.h"
@@ -3154,13 +3156,13 @@ struct qla_hw_data { · 1122 unmodified lines
31543156 /* Bit 21 of fw_attributes decides the MCTP capabilities */
31553157 #define IS_MCTP_CAPABLE(ha) (IS_QLA2031(ha) && \
31563158 ((ha)->fw_attributes_ext[0] & BIT_0))
3157−#define IS_PI_UNINIT_CAPABLE(ha) (IS_QLA83XX(ha))
3158−#define IS_PI_IPGUARD_CAPABLE(ha) (IS_QLA83XX(ha))
3159+#define IS_PI_UNINIT_CAPABLE(ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha))
3160+#define IS_PI_IPGUARD_CAPABLE(ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha))
31593161 #define IS_PI_DIFB_DIX0_CAPABLE(ha) (0)
3160−#define IS_PI_SPLIT_DET_CAPABLE_HBA(ha) (IS_QLA83XX(ha))
3162+#define IS_PI_SPLIT_DET_CAPABLE_HBA(ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha))
31613163 #define IS_PI_SPLIT_DET_CAPABLE(ha) (IS_PI_SPLIT_DET_CAPABLE_HBA(ha) && \
31623164 (((ha)->fw_attributes_h << 16 | (ha)->fw_attributes) & BIT_22))
3163−#define IS_ATIO_MSIX_CAPABLE(ha) (IS_QLA83XX(ha))
3165+#define IS_ATIO_MSIX_CAPABLE(ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha))
31643166 #define IS_TGT_MODE_CAPABLE(ha) (ha->tgt.atio_q_length)
31653167 #define IS_SHADOW_REG_CAPABLE(ha) (IS_QLA27XX(ha))
31663168 #define IS_DPORT_CAPABLE(ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha))
@@ -3579,6 +3581,16 @@ typedef struct scsi_qla_host { · 412 unmodified lines
35793581 uint16_t fcoe_fcf_idx;
35803582 uint8_t fcoe_vn_port_mac[6];
35813583
3584+ /* list of commands waiting on workqueue */
3585+ struct list_head qla_cmd_list;
3586+ struct list_head qla_sess_op_cmd_list;
3587+ spinlock_t cmd_list_lock;
3588+
3589+ /* Counter to detect races between ELS and RSCN events */
3590+ atomic_t generation_tick;
3591+ /* Time when global fcport update has been scheduled */
3592+ int total_fcport_update_gen;
3593+
35823594 uint32_t vp_abort_cnt;
35833595
35843596 struct fc_vport *fc_vport; /* holds fc_vport * for each vport */
drivers/scsi/qla2xxx/qla_init.c+150−40
@@ -115,6 +115,8 @@ qla2x00_async_iocb_timeout(void *data) · 114 unmodified lines
115115 QLA_LOGIO_LOGIN_RETRIED : 0;
116116 qla2x00_post_async_login_done_work(fcport->vha, fcport,
117117 lio->u.logio.data);
118+ } else if (sp->type == SRB_LOGOUT_CMD) {
119+ qlt_logo_completion_handler(fcport, QLA_FUNCTION_TIMEOUT);
118120 }
119121 }
120122
@@ -497,7 +499,10 @@ void · 376 unmodified lines
497499 qla2x00_async_logout_done(struct scsi_qla_host *vha, fc_port_t *fcport,
498500 uint16_t *data)
499501 {
500− qla2x00_mark_device_lost(vha, fcport, 1, 0);
502+ /* Don't re-login in target mode */
503+ if (!fcport->tgt_session)
504+ qla2x00_mark_device_lost(vha, fcport, 1, 0);
505+ qlt_logo_completion_handler(fcport, data[0]);
501506 return;
502507 }
503508
@@ -1538,7 +1543,7 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) · 1034 unmodified lines
15381543 mem_size = (ha->fw_memory_size - 0x11000 + 1) *
15391544 sizeof(uint16_t);
15401545 } else if (IS_FWI2_CAPABLE(ha)) {
1541− if (IS_QLA83XX(ha))
1546+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha))
15421547 fixed_size = offsetof(struct qla83xx_fw_dump, ext_mem);
15431548 else if (IS_QLA81XX(ha))
15441549 fixed_size = offsetof(struct qla81xx_fw_dump, ext_mem);
@@ -1550,7 +1555,7 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) · 5 unmodified lines
15501555 mem_size = (ha->fw_memory_size - 0x100000 + 1) *
15511556 sizeof(uint32_t);
15521557 if (ha->mqenable) {
1553− if (!IS_QLA83XX(ha))
1558+ if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
15541559 mq_size = sizeof(struct qla2xxx_mq_chain);
15551560 /*
15561561 * Allocate maximum buffer size for all queues.
@@ -2922,21 +2927,14 @@ qla2x00_rport_del(void *data) · 1365 unmodified lines
29222927 {
29232928 fc_port_t *fcport = data;
29242929 struct fc_rport *rport;
2925− scsi_qla_host_t *vha = fcport->vha;
29262930 unsigned long flags;
29272931
29282932 spin_lock_irqsave(fcport->vha->host->host_lock, flags);
29292933 rport = fcport->drport ? fcport->drport: fcport->rport;
29302934 fcport->drport = NULL;
29312935 spin_unlock_irqrestore(fcport->vha->host->host_lock, flags);
2932− if (rport) {
2936+ if (rport)
29332937 fc_remote_port_delete(rport);
2934− /*
2935− * Release the target mode FC NEXUS in qla_target.c code
2936− * if target mod is enabled.
2937− */
2938− qlt_fc_port_deleted(vha, fcport);
2939− }
29402938 }
29412939
29422940 /**
@@ -3303,6 +3301,7 @@ qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport) · 360 unmodified lines
33033301 * Create target mode FC NEXUS in qla_target.c if target mode is
33043302 * enabled..
33053303 */
3304+
33063305 qlt_fc_port_added(vha, fcport);
33073306
33083307 spin_lock_irqsave(fcport->vha->host->host_lock, flags);
@@ -3341,8 +3340,7 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport) · 32 unmodified lines
33413340
33423341 if (IS_QLAFX00(vha->hw)) {
33433342 qla2x00_set_fcport_state(fcport, FCS_ONLINE);
3344− qla2x00_reg_remote_port(vha, fcport);
3345− return;
3343+ goto reg_port;
33463344 }
33473345 fcport->login_retry = 0;
33483346 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
@@ -3350,7 +3348,16 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport) · 1 unmodified line
33503348 qla2x00_set_fcport_state(fcport, FCS_ONLINE);
33513349 qla2x00_iidma_fcport(vha, fcport);
33523350 qla24xx_update_fcport_fcp_prio(vha, fcport);
3353− qla2x00_reg_remote_port(vha, fcport);
3351+
3352+reg_port:
3353+ if (qla_ini_mode_enabled(vha))
3354+ qla2x00_reg_remote_port(vha, fcport);
3355+ else {
3356+ /*
3357+ * Create target mode FC NEXUS in qla_target.c
3358+ */
3359+ qlt_fc_port_added(vha, fcport);
3360+ }
33543361 }
33553362
33563363 /*
@@ -3375,6 +3382,7 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha) · 18 unmodified lines
33753382 LIST_HEAD(new_fcports);
33763383 struct qla_hw_data *ha = vha->hw;
33773384 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
3385+ int discovery_gen;
33783386
33793387 /* If FL port exists, then SNS is present */
33803388 if (IS_FWI2_CAPABLE(ha))
@@ -3445,6 +3453,14 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha) · 64 unmodified lines
34453453 fcport->scan_state = QLA_FCPORT_SCAN;
34463454 }
34473455
3456+ /* Mark the time right before querying FW for connected ports.
3457+ * This process is long, asynchronous and by the time it's done,
3458+ * collected information might not be accurate anymore. E.g.
3459+ * disconnected port might have re-connected and a brand new
3460+ * session has been created. In this case session's generation
3461+ * will be newer than discovery_gen. */
3462+ qlt_do_generation_tick(vha, &discovery_gen);
3463+
34483464 rval = qla2x00_find_all_fabric_devs(vha, &new_fcports);
34493465 if (rval != QLA_SUCCESS)
34503466 break;
@@ -3460,20 +3476,44 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha) · 9 unmodified lines
34603476 if ((fcport->flags & FCF_FABRIC_DEVICE) == 0)
34613477 continue;
34623478
3463− if (fcport->scan_state == QLA_FCPORT_SCAN &&
3464− atomic_read(&fcport->state) == FCS_ONLINE) {
3465− qla2x00_mark_device_lost(vha, fcport,
3466− ql2xplogiabsentdevice, 0);
3467− if (fcport->loop_id != FC_NO_LOOP_ID &&
3468− (fcport->flags & FCF_FCP2_DEVICE) == 0 &&
3469− fcport->port_type != FCT_INITIATOR &&
3470− fcport->port_type != FCT_BROADCAST) {
3471− ha->isp_ops->fabric_logout(vha,
3472− fcport->loop_id,
3473− fcport->d_id.b.domain,
3474− fcport->d_id.b.area,
3475− fcport->d_id.b.al_pa);
3476− qla2x00_clear_loop_id(fcport);
3479+ if (fcport->scan_state == QLA_FCPORT_SCAN) {
3480+ if (qla_ini_mode_enabled(base_vha) &&
3481+ atomic_read(&fcport->state) == FCS_ONLINE) {
3482+ qla2x00_mark_device_lost(vha, fcport,
3483+ ql2xplogiabsentdevice, 0);
3484+ if (fcport->loop_id != FC_NO_LOOP_ID &&
3485+ (fcport->flags & FCF_FCP2_DEVICE) == 0 &&
3486+ fcport->port_type != FCT_INITIATOR &&
3487+ fcport->port_type != FCT_BROADCAST) {
3488+ ha->isp_ops->fabric_logout(vha,
3489+ fcport->loop_id,
3490+ fcport->d_id.b.domain,
3491+ fcport->d_id.b.area,
3492+ fcport->d_id.b.al_pa);
3493+ qla2x00_clear_loop_id(fcport);
3494+ }
3495+ } else if (!qla_ini_mode_enabled(base_vha)) {
3496+ /*
3497+ * In target mode, explicitly kill
3498+ * sessions and log out of devices
3499+ * that are gone, so that we don't
3500+ * end up with an initiator using the
3501+ * wrong ACL (if the fabric recycles
3502+ * an FC address and we have a stale
3503+ * session around) and so that we don't
3504+ * report initiators that are no longer
3505+ * on the fabric.
3506+ */
3507+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf077,
3508+ "port gone, logging out/killing session: "
3509+ "%8phC state 0x%x flags 0x%x fc4_type 0x%x "
3510+ "scan_state %d\n",
3511+ fcport->port_name,
3512+ atomic_read(&fcport->state),
3513+ fcport->flags, fcport->fc4_type,
3514+ fcport->scan_state);
3515+ qlt_fc_port_deleted(vha, fcport,
3516+ discovery_gen);
34773517 }
34783518 }
34793519 }
@@ -3494,6 +3534,28 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha) · 14 unmodified lines
34943534 (fcport->flags & FCF_LOGIN_NEEDED) == 0)
34953535 continue;
34963536
3537+ /*
3538+ * If we're not an initiator, skip looking for devices
3539+ * and logging in. There's no reason for us to do it,
3540+ * and it seems to actively cause problems in target
3541+ * mode if we race with the initiator logging into us
3542+ * (we might get the "port ID used" status back from
3543+ * our login command and log out the initiator, which
3544+ * seems to cause havoc).
3545+ */
3546+ if (!qla_ini_mode_enabled(base_vha)) {
3547+ if (fcport->scan_state == QLA_FCPORT_FOUND) {
3548+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf078,
3549+ "port %8phC state 0x%x flags 0x%x fc4_type 0x%x "
3550+ "scan_state %d (initiator mode disabled; skipping "
3551+ "login)\n", fcport->port_name,
3552+ atomic_read(&fcport->state),
3553+ fcport->flags, fcport->fc4_type,
3554+ fcport->scan_state);
3555+ }
3556+ continue;
3557+ }
3558+
34973559 if (fcport->loop_id == FC_NO_LOOP_ID) {
34983560 fcport->loop_id = next_loopid;
34993561 rval = qla2x00_find_new_loop_id(
@@ -3520,16 +3582,38 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha) · 20 unmodified lines
35203582 test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
35213583 break;
35223584
3523− /* Find a new loop ID to use. */
3524− fcport->loop_id = next_loopid;
3525− rval = qla2x00_find_new_loop_id(base_vha, fcport);
3526− if (rval != QLA_SUCCESS) {
3527− /* Ran out of IDs to use */
3528− break;
3529− }
3585+ /*
3586+ * If we're not an initiator, skip looking for devices
3587+ * and logging in. There's no reason for us to do it,
3588+ * and it seems to actively cause problems in target
3589+ * mode if we race with the initiator logging into us
3590+ * (we might get the "port ID used" status back from
3591+ * our login command and log out the initiator, which
3592+ * seems to cause havoc).
3593+ */
3594+ if (qla_ini_mode_enabled(base_vha)) {
3595+ /* Find a new loop ID to use. */
3596+ fcport->loop_id = next_loopid;
3597+ rval = qla2x00_find_new_loop_id(base_vha,
3598+ fcport);
3599+ if (rval != QLA_SUCCESS) {
3600+ /* Ran out of IDs to use */
3601+ break;
3602+ }
35303603
3531− /* Login and update database */
3532− qla2x00_fabric_dev_login(vha, fcport, &next_loopid);
3604+ /* Login and update database */
3605+ qla2x00_fabric_dev_login(vha, fcport,
3606+ &next_loopid);
3607+ } else {
3608+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf079,
3609+ "new port %8phC state 0x%x flags 0x%x fc4_type "
3610+ "0x%x scan_state %d (initiator mode disabled; "
3611+ "skipping login)\n",
3612+ fcport->port_name,
3613+ atomic_read(&fcport->state),
3614+ fcport->flags, fcport->fc4_type,
3615+ fcport->scan_state);
3616+ }
35333617
35343618 list_move_tail(&fcport->list, &vha->vp_fcports);
35353619 }
@@ -3725,11 +3809,12 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha, · 189 unmodified lines
37253809 fcport->fp_speed = new_fcport->fp_speed;
37263810
37273811 /*
3728− * If address the same and state FCS_ONLINE, nothing
3729− * changed.
3812+ * If address the same and state FCS_ONLINE
3813+ * (or in target mode), nothing changed.
37303814 */
37313815 if (fcport->d_id.b24 == new_fcport->d_id.b24 &&
3732− atomic_read(&fcport->state) == FCS_ONLINE) {
3816+ (atomic_read(&fcport->state) == FCS_ONLINE ||
3817+ !qla_ini_mode_enabled(base_vha))) {
37333818 break;
37343819 }
37353820
@@ -3749,6 +3834,22 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha, · 13 unmodified lines
37493834 * Log it out if still logged in and mark it for
37503835 * relogin later.
37513836 */
3837+ if (!qla_ini_mode_enabled(base_vha)) {
3838+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf080,
3839+ "port changed FC ID, %8phC"
3840+ " old %x:%x:%x (loop_id 0x%04x)-> new %x:%x:%x\n",
3841+ fcport->port_name,
3842+ fcport->d_id.b.domain,
3843+ fcport->d_id.b.area,
3844+ fcport->d_id.b.al_pa,
3845+ fcport->loop_id,
3846+ new_fcport->d_id.b.domain,
3847+ new_fcport->d_id.b.area,
3848+ new_fcport->d_id.b.al_pa);
3849+ fcport->d_id.b24 = new_fcport->d_id.b24;
3850+ break;
3851+ }
3852+
37523853 fcport->d_id.b24 = new_fcport->d_id.b24;
37533854 fcport->flags |= FCF_LOGIN_NEEDED;
37543855 if (fcport->loop_id != FC_NO_LOOP_ID &&
@@ -3768,6 +3869,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha, · 13 unmodified lines
37683869 if (found)
37693870 continue;
37703871 /* If device was not in our fcports list, then add it. */
3872+ new_fcport->scan_state = QLA_FCPORT_FOUND;
37713873 list_add_tail(&new_fcport->list, new_fcports);
37723874
37733875 /* Allocate a new replacement fcport. */
@@ -4188,6 +4290,14 @@ qla2x00_update_fcports(scsi_qla_host_t *base_vha) · 414 unmodified lines
41884290 atomic_read(&fcport->state) != FCS_UNCONFIGURED) {
41894291 spin_unlock_irqrestore(&ha->vport_slock, flags);
41904292 qla2x00_rport_del(fcport);
4293+
4294+ /*
4295+ * Release the target mode FC NEXUS in
4296+ * qla_target.c, if target mod is enabled.
4297+ */
4298+ qlt_fc_port_deleted(vha, fcport,
4299+ base_vha->total_fcport_update_gen);
4300+
41914301 spin_lock_irqsave(&ha->vport_slock, flags);
41924302 }
41934303 }
drivers/scsi/qla2xxx/qla_iocb.c+3−0
@@ -1943,6 +1943,9 @@ qla24xx_logout_iocb(srb_t *sp, struct logio_entry_24xx *logio) · 1942 unmodified lines
19431943 logio->entry_type = LOGINOUT_PORT_IOCB_TYPE;
19441944 logio->control_flags =
19451945 cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO);
1946+ if (!sp->fcport->tgt_session ||
1947+ !sp->fcport->tgt_session->keep_nport_handle)
1948+ logio->control_flags |= cpu_to_le16(LCF_FREE_NPORT);
19461949 logio->nport_handle = cpu_to_le16(sp->fcport->loop_id);
19471950 logio->port_id[0] = sp->fcport->d_id.b.al_pa;
19481951 logio->port_id[1] = sp->fcport->d_id.b.area;
drivers/scsi/qla2xxx/qla_mbx.c+4−3
@@ -2415,7 +2415,8 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *vha, uint16_t *cur_xchg_cnt, · 2414 unmodified lines
24152415 *orig_iocb_cnt = mcp->mb[10];
24162416 if (vha->hw->flags.npiv_supported && max_npiv_vports)
24172417 *max_npiv_vports = mcp->mb[11];
2418− if ((IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw)) && max_fcfs)
2418+ if ((IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw) ||
2419+ IS_QLA27XX(vha->hw)) && max_fcfs)
24192420 *max_fcfs = mcp->mb[12];
24202421 }
24212422
@@ -3898,7 +3899,7 @@ qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp) · 1476 unmodified lines
38983899 spin_lock_irqsave(&ha->hardware_lock, flags);
38993900 if (!(rsp->options & BIT_0)) {
39003901 WRT_REG_DWORD(rsp->rsp_q_out, 0);
3901− if (!IS_QLA83XX(ha))
3902+ if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
39023903 WRT_REG_DWORD(rsp->rsp_q_in, 0);
39033904 }
39043905
@@ -5345,7 +5346,7 @@ qla83xx_restart_nic_firmware(scsi_qla_host_t *vha) · 1440 unmodified lines
53455346 mbx_cmd_t *mcp = &mc;
53465347 struct qla_hw_data *ha = vha->hw;
53475348
5348− if (!IS_QLA83XX(ha))
5349+ if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
53495350 return QLA_FUNCTION_FAILED;
53505351
53515352 ql_dbg(ql_dbg_mbx, vha, 0x1143, "Entered %s.\n", __func__);
drivers/scsi/qla2xxx/qla_os.c+10−2
@@ -2504,6 +2504,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) · 2503 unmodified lines
25042504 ha->mbx_count = MAILBOX_REGISTER_COUNT;
25052505 req_length = REQUEST_ENTRY_CNT_24XX;
25062506 rsp_length = RESPONSE_ENTRY_CNT_2300;
2507+ ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX;
25072508 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
25082509 ha->init_cb_size = sizeof(struct mid_init_cb_81xx);
25092510 ha->gid_list_info_size = 8;
@@ -3229,11 +3230,15 @@ qla2x00_schedule_rport_del(struct scsi_qla_host *vha, fc_port_t *fcport, · 719 unmodified lines
32293230 spin_lock_irqsave(vha->host->host_lock, flags);
32303231 fcport->drport = rport;
32313232 spin_unlock_irqrestore(vha->host->host_lock, flags);
3233+ qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen);
32323234 set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags);
32333235 qla2xxx_wake_dpc(base_vha);
32343236 } else {
3235− fc_remote_port_delete(rport);
3236− qlt_fc_port_deleted(vha, fcport);
3237+ int now;
3238+ if (rport)
3239+ fc_remote_port_delete(rport);
3240+ qlt_do_generation_tick(vha, &now);
3241+ qlt_fc_port_deleted(vha, fcport, now);
32373242 }
32383243 }
32393244
@@ -3763,8 +3768,11 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, · 523 unmodified lines
37633768 INIT_LIST_HEAD(&vha->vp_fcports);
37643769 INIT_LIST_HEAD(&vha->work_list);
37653770 INIT_LIST_HEAD(&vha->list);
3771+ INIT_LIST_HEAD(&vha->qla_cmd_list);
3772+ INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list);
37663773
37673774 spin_lock_init(&vha->work_lock);
3775+ spin_lock_init(&vha->cmd_list_lock);
37683776
37693777 sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no);
37703778 ql_dbg(ql_dbg_init, vha, 0x0041,
drivers/scsi/qla2xxx/qla_sup.c+1−1
@@ -1697,7 +1697,7 @@ qla83xx_select_led_port(struct qla_hw_data *ha) · 1696 unmodified lines
16971697 {
16981698 uint32_t led_select_value = 0;
16991699
1700− if (!IS_QLA83XX(ha))
1700+ if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
17011701 goto out;
17021702
17031703 if (ha->port_no == 0)
drivers/scsi/qla2xxx/qla_target.c+692−71
@@ -113,6 +113,11 @@ static void qlt_abort_cmd_on_host_reset(struct scsi_qla_host *vha, · 112 unmodified lines
113113 static void qlt_alloc_qfull_cmd(struct scsi_qla_host *vha,
114114 struct atio_from_isp *atio, uint16_t status, int qfull);
115115 static void qlt_disable_vha(struct scsi_qla_host *vha);
116+static void qlt_clear_tgt_db(struct qla_tgt *tgt);
117+static void qlt_send_notify_ack(struct scsi_qla_host *vha,
118+ struct imm_ntfy_from_isp *ntfy,
119+ uint32_t add_flags, uint16_t resp_code, int resp_code_valid,
120+ uint16_t srr_flags, uint16_t srr_reject_code, uint8_t srr_explan);
116121 /*
117122 * Global Variables
118123 */
@@ -122,6 +127,16 @@ static struct workqueue_struct *qla_tgt_wq; · 3 unmodified lines
122127 static DEFINE_MUTEX(qla_tgt_mutex);
123128 static LIST_HEAD(qla_tgt_glist);
124129
130+/* This API intentionally takes dest as a parameter, rather than returning
131+ * int value to avoid caller forgetting to issue wmb() after the store */
132+void qlt_do_generation_tick(struct scsi_qla_host *vha, int *dest)
133+{
134+ scsi_qla_host_t *base_vha = pci_get_drvdata(vha->hw->pdev);
135+ *dest = atomic_inc_return(&base_vha->generation_tick);
136+ /* memory barrier */
137+ wmb();
138+}
139+
125140 /* ha->hardware_lock supposed to be held on entry (to protect tgt->sess_list) */
126141 static struct qla_tgt_sess *qlt_find_sess_by_port_name(
127142 struct qla_tgt *tgt,
@@ -381,14 +396,73 @@ static void qlt_free_session_done(struct work_struct *work) · 253 unmodified lines
381396 struct qla_tgt *tgt = sess->tgt;
382397 struct scsi_qla_host *vha = sess->vha;
383398 struct qla_hw_data *ha = vha->hw;
399+ unsigned long flags;
400+ bool logout_started = false;
401+ fc_port_t fcport;
402+
403+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf084,
404+ "%s: se_sess %p / sess %p from port %8phC loop_id %#04x"
405+ " s_id %02x:%02x:%02x logout %d keep %d plogi %d\n",
406+ __func__, sess->se_sess, sess, sess->port_name, sess->loop_id,
407+ sess->s_id.b.domain, sess->s_id.b.area, sess->s_id.b.al_pa,
408+ sess->logout_on_delete, sess->keep_nport_handle,
409+ sess->plogi_ack_needed);
384410
385411 BUG_ON(!tgt);
412+
413+ if (sess->logout_on_delete) {
414+ int rc;
415+
416+ memset(&fcport, 0, sizeof(fcport));
417+ fcport.loop_id = sess->loop_id;
418+ fcport.d_id = sess->s_id;
419+ memcpy(fcport.port_name, sess->port_name, WWN_SIZE);
420+ fcport.vha = vha;
421+ fcport.tgt_session = sess;
422+
423+ rc = qla2x00_post_async_logout_work(vha, &fcport, NULL);
424+ if (rc != QLA_SUCCESS)
425+ ql_log(ql_log_warn, vha, 0xf085,
426+ "Schedule logo failed sess %p rc %d\n",
427+ sess, rc);
428+ else
429+ logout_started = true;
430+ }
431+
386432 /*
387433 * Release the target session for FC Nexus from fabric module code.
388434 */
389435 if (sess->se_sess != NULL)
390436 ha->tgt.tgt_ops->free_session(sess);
391437
438+ if (logout_started) {
439+ bool traced = false;
440+
441+ while (!ACCESS_ONCE(sess->logout_completed)) {
442+ if (!traced) {
443+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf086,
444+ "%s: waiting for sess %p logout\n",
445+ __func__, sess);
446+ traced = true;
447+ }
448+ msleep(100);
449+ }
450+
451+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf087,
452+ "%s: sess %p logout completed\n",
453+ __func__, sess);
454+ }
455+
456+ spin_lock_irqsave(&ha->hardware_lock, flags);
457+
458+ if (sess->plogi_ack_needed)
459+ qlt_send_notify_ack(vha, &sess->tm_iocb,
460+ 0, 0, 0, 0, 0, 0);
461+
462+ list_del(&sess->sess_list_entry);
463+
464+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
465+
392466 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf001,
393467 "Unregistration of sess %p finished\n", sess);
394468
@@ -409,9 +483,9 @@ void qlt_unreg_sess(struct qla_tgt_sess *sess) · 14 unmodified lines
409483
410484 vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
411485
412− list_del(&sess->sess_list_entry);
413− if (sess->deleted)
414− list_del(&sess->del_list_entry);
486+ if (!list_empty(&sess->del_list_entry))
487+ list_del_init(&sess->del_list_entry);
488+ sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
415489
416490 INIT_WORK(&sess->free_work, qlt_free_session_done);
417491 schedule_work(&sess->free_work);
@@ -431,10 +505,10 @@ static int qlt_reset(struct scsi_qla_host *vha, void *iocb, int mcmd) · 13 unmodified lines
431505
432506 loop_id = le16_to_cpu(n->u.isp24.nport_handle);
433507 if (loop_id == 0xFFFF) {
434−#if 0 /* FIXME: Re-enable Global event handling.. */
435508 /* Global event */
436− atomic_inc(&ha->tgt.qla_tgt->tgt_global_resets_count);
437− qlt_clear_tgt_db(ha->tgt.qla_tgt);
509+ atomic_inc(&vha->vha_tgt.qla_tgt->tgt_global_resets_count);
510+ qlt_clear_tgt_db(vha->vha_tgt.qla_tgt);
511+#if 0 /* FIXME: do we need to choose a session here? */
438512 if (!list_empty(&ha->tgt.qla_tgt->sess_list)) {
439513 sess = list_entry(ha->tgt.qla_tgt->sess_list.next,
440514 typeof(*sess), sess_list_entry);
@@ -489,27 +563,38 @@ static void qlt_schedule_sess_for_deletion(struct qla_tgt_sess *sess, · 48 unmodified lines
489563 struct qla_tgt *tgt = sess->tgt;
490564 uint32_t dev_loss_tmo = tgt->ha->port_down_retry_count + 5;
491565
492− if (sess->deleted)
493− return;
566+ if (sess->deleted) {
567+ /* Upgrade to unconditional deletion in case it was temporary */
568+ if (immediate && sess->deleted == QLA_SESS_DELETION_PENDING)
569+ list_del(&sess->del_list_entry);
570+ else
571+ return;
572+ }
494573
495574 ql_dbg(ql_dbg_tgt, sess->vha, 0xe001,
496575 "Scheduling sess %p for deletion\n", sess);
497− list_add_tail(&sess->del_list_entry, &tgt->del_sess_list);
498− sess->deleted = 1;
499576
500− if (immediate)
577+ if (immediate) {
501578 dev_loss_tmo = 0;
579+ sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
580+ list_add(&sess->del_list_entry, &tgt->del_sess_list);
581+ } else {
582+ sess->deleted = QLA_SESS_DELETION_PENDING;
583+ list_add_tail(&sess->del_list_entry, &tgt->del_sess_list);
584+ }
502585
503586 sess->expires = jiffies + dev_loss_tmo * HZ;
504587
505588 ql_dbg(ql_dbg_tgt, sess->vha, 0xe048,
506− "qla_target(%d): session for port %8phC (loop ID %d) scheduled for "
507− "deletion in %u secs (expires: %lu) immed: %d\n",
508− sess->vha->vp_idx, sess->port_name, sess->loop_id, dev_loss_tmo,
509− sess->expires, immediate);
589+ "qla_target(%d): session for port %8phC (loop ID %d s_id %02x:%02x:%02x)"
590+ " scheduled for deletion in %u secs (expires: %lu) immed: %d, logout: %d, gen: %#x\n",
591+ sess->vha->vp_idx, sess->port_name, sess->loop_id,
592+ sess->s_id.b.domain, sess->s_id.b.area, sess->s_id.b.al_pa,
593+ dev_loss_tmo, sess->expires, immediate, sess->logout_on_delete,
594+ sess->generation);
510595
511596 if (immediate)
512− schedule_delayed_work(&tgt->sess_del_work, 0);
597+ mod_delayed_work(system_wq, &tgt->sess_del_work, 0);
513598 else
514599 schedule_delayed_work(&tgt->sess_del_work,
515600 sess->expires - jiffies);
@@ -578,9 +663,9 @@ out_free_id_list: · 62 unmodified lines
578663 /* ha->hardware_lock supposed to be held on entry */
579664 static void qlt_undelete_sess(struct qla_tgt_sess *sess)
580665 {
581− BUG_ON(!sess->deleted);
666+ BUG_ON(sess->deleted != QLA_SESS_DELETION_PENDING);
582667
583− list_del(&sess->del_list_entry);
668+ list_del_init(&sess->del_list_entry);
584669 sess->deleted = 0;
585670 }
586671
@@ -599,7 +684,9 @@ static void qlt_del_sess_work_fn(struct delayed_work *work) · 12 unmodified lines
599684 del_list_entry);
600685 elapsed = jiffies;
601686 if (time_after_eq(elapsed, sess->expires)) {
602− qlt_undelete_sess(sess);
687+ /* No turning back */
688+ list_del_init(&sess->del_list_entry);
689+ sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
603690
604691 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf004,
605692 "Timeout: sess %p about to be deleted\n",
@@ -643,6 +730,13 @@ static struct qla_tgt_sess *qlt_create_sess( · 37 unmodified lines
643730 fcport->d_id.b.al_pa, fcport->d_id.b.area,
644731 fcport->loop_id);
645732
733+ /* Cannot undelete at this point */
734+ if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
735+ spin_unlock_irqrestore(&ha->hardware_lock,
736+ flags);
737+ return NULL;
738+ }
739+
646740 if (sess->deleted)
647741 qlt_undelete_sess(sess);
648742
@@ -652,6 +746,9 @@ static struct qla_tgt_sess *qlt_create_sess( · 3 unmodified lines
652746
653747 if (sess->local && !local)
654748 sess->local = 0;
749+
750+ qlt_do_generation_tick(vha, &sess->generation);
751+
655752 spin_unlock_irqrestore(&ha->hardware_lock, flags);
656753
657754 return sess;
@@ -673,6 +770,14 @@ static struct qla_tgt_sess *qlt_create_sess( · 15 unmodified lines
673770 sess->s_id = fcport->d_id;
674771 sess->loop_id = fcport->loop_id;
675772 sess->local = local;
773+ INIT_LIST_HEAD(&sess->del_list_entry);
774+
775+ /* Under normal circumstances we want to logout from firmware when
776+ * session eventually ends and release corresponding nport handle.
777+ * In the exception cases (e.g. when new PLOGI is waiting) corresponding
778+ * code will adjust these flags as necessary. */
779+ sess->logout_on_delete = 1;
780+ sess->keep_nport_handle = 0;
676781
677782 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf006,
678783 "Adding sess %p to tgt %p via ->check_initiator_node_acl()\n",
@@ -705,6 +810,7 @@ static struct qla_tgt_sess *qlt_create_sess( · 26 unmodified lines
705810 spin_lock_irqsave(&ha->hardware_lock, flags);
706811 list_add_tail(&sess->sess_list_entry, &vha->vha_tgt.qla_tgt->sess_list);
707812 vha->vha_tgt.qla_tgt->sess_count++;
813+ qlt_do_generation_tick(vha, &sess->generation);
708814 spin_unlock_irqrestore(&ha->hardware_lock, flags);
709815
710816 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf04b,
@@ -718,7 +824,7 @@ static struct qla_tgt_sess *qlt_create_sess( · 7 unmodified lines
718824 }
719825
720826 /*
721− * Called from drivers/scsi/qla2xxx/qla_init.c:qla2x00_reg_remote_port()
827+ * Called from qla2x00_reg_remote_port()
722828 */
723829 void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport)
724830 {
@@ -750,6 +856,10 @@ void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport) · 25 unmodified lines
750856 mutex_unlock(&vha->vha_tgt.tgt_mutex);
751857
752858 spin_lock_irqsave(&ha->hardware_lock, flags);
859+ } else if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
860+ /* Point of no return */
861+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
862+ return;
753863 } else {
754864 kref_get(&sess->se_sess->sess_kref);
755865
@@ -780,27 +890,36 @@ void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport) · 24 unmodified lines
780890 spin_unlock_irqrestore(&ha->hardware_lock, flags);
781891 }
782892
783−void qlt_fc_port_deleted(struct scsi_qla_host *vha, fc_port_t *fcport)
893+/*
894+ * max_gen - specifies maximum session generation
895+ * at which this deletion requestion is still valid
896+ */
897+void
898+qlt_fc_port_deleted(struct scsi_qla_host *vha, fc_port_t *fcport, int max_gen)
784899 {
785− struct qla_hw_data *ha = vha->hw;
786900 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
787901 struct qla_tgt_sess *sess;
788− unsigned long flags;
789902
790903 if (!vha->hw->tgt.tgt_ops)
791904 return;
792905
793− if (!tgt || (fcport->port_type != FCT_INITIATOR))
906+ if (!tgt)
794907 return;
795908
796− spin_lock_irqsave(&ha->hardware_lock, flags);
797909 if (tgt->tgt_stop) {
798− spin_unlock_irqrestore(&ha->hardware_lock, flags);
799910 return;
800911 }
801912 sess = qlt_find_sess_by_port_name(tgt, fcport->port_name);
802913 if (!sess) {
803− spin_unlock_irqrestore(&ha->hardware_lock, flags);
914+ return;
915+ }
916+
917+ if (max_gen - sess->generation < 0) {
918+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf092,
919+ "Ignoring stale deletion request for se_sess %p / sess %p"
920+ " for port %8phC, req_gen %d, sess_gen %d\n",
921+ sess->se_sess, sess, sess->port_name, max_gen,
922+ sess->generation);
804923 return;
805924 }
806925
@@ -808,7 +927,6 @@ void qlt_fc_port_deleted(struct scsi_qla_host *vha, fc_port_t *fcport) · 1 unmodified line
808927
809928 sess->local = 1;
810929 qlt_schedule_sess_for_deletion(sess, false);
811− spin_unlock_irqrestore(&ha->hardware_lock, flags);
812930 }
813931
814932 static inline int test_tgt_sess_count(struct qla_tgt *tgt)
@@ -1175,6 +1293,70 @@ static void qlt_24xx_retry_term_exchange(struct scsi_qla_host *vha, · 360 unmodified lines
11751293 FCP_TMF_CMPL, true);
11761294 }
11771295
1296+static int abort_cmd_for_tag(struct scsi_qla_host *vha, uint32_t tag)
1297+{
1298+ struct qla_tgt_sess_op *op;
1299+ struct qla_tgt_cmd *cmd;
1300+
1301+ spin_lock(&vha->cmd_list_lock);
1302+
1303+ list_for_each_entry(op, &vha->qla_sess_op_cmd_list, cmd_list) {
1304+ if (tag == op->atio.u.isp24.exchange_addr) {
1305+ op->aborted = true;
1306+ spin_unlock(&vha->cmd_list_lock);
1307+ return 1;
1308+ }
1309+ }
1310+
1311+ list_for_each_entry(cmd, &vha->qla_cmd_list, cmd_list) {
1312+ if (tag == cmd->atio.u.isp24.exchange_addr) {
1313+ cmd->state = QLA_TGT_STATE_ABORTED;
1314+ spin_unlock(&vha->cmd_list_lock);
1315+ return 1;
1316+ }
1317+ }
1318+
1319+ spin_unlock(&vha->cmd_list_lock);
1320+ return 0;
1321+}
1322+
1323+/* drop cmds for the given lun
1324+ * XXX only looks for cmds on the port through which lun reset was recieved
1325+ * XXX does not go through the list of other port (which may have cmds
1326+ * for the same lun)
1327+ */
1328+static void abort_cmds_for_lun(struct scsi_qla_host *vha,
1329+ uint32_t lun, uint8_t *s_id)
1330+{
1331+ struct qla_tgt_sess_op *op;
1332+ struct qla_tgt_cmd *cmd;
1333+ uint32_t key;
1334+
1335+ key = sid_to_key(s_id);
1336+ spin_lock(&vha->cmd_list_lock);
1337+ list_for_each_entry(op, &vha->qla_sess_op_cmd_list, cmd_list) {
1338+ uint32_t op_key;
1339+ uint32_t op_lun;
1340+
1341+ op_key = sid_to_key(op->atio.u.isp24.fcp_hdr.s_id);
1342+ op_lun = scsilun_to_int(
1343+ (struct scsi_lun *)&op->atio.u.isp24.fcp_cmnd.lun);
1344+ if (op_key == key && op_lun == lun)
1345+ op->aborted = true;
1346+ }
1347+ list_for_each_entry(cmd, &vha->qla_cmd_list, cmd_list) {
1348+ uint32_t cmd_key;
1349+ uint32_t cmd_lun;
1350+
1351+ cmd_key = sid_to_key(cmd->atio.u.isp24.fcp_hdr.s_id);
1352+ cmd_lun = scsilun_to_int(
1353+ (struct scsi_lun *)&cmd->atio.u.isp24.fcp_cmnd.lun);
1354+ if (cmd_key == key && cmd_lun == lun)
1355+ cmd->state = QLA_TGT_STATE_ABORTED;
1356+ }
1357+ spin_unlock(&vha->cmd_list_lock);
1358+}
1359+
11781360 /* ha->hardware_lock supposed to be held on entry */
11791361 static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha,
11801362 struct abts_recv_from_24xx *abts, struct qla_tgt_sess *sess)
@@ -1199,8 +1381,19 @@ static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha, · 18 unmodified lines
11991381 }
12001382 spin_unlock(&se_sess->sess_cmd_lock);
12011383
1202− if (!found_lun)
1203− return -ENOENT;
1384+ /* cmd not in LIO lists, look in qla list */
1385+ if (!found_lun) {
1386+ if (abort_cmd_for_tag(vha, abts->exchange_addr_to_abort)) {
1387+ /* send TASK_ABORT response immediately */
1388+ qlt_24xx_send_abts_resp(vha, abts, FCP_TMF_CMPL, false);
1389+ return 0;
1390+ } else {
1391+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf081,
1392+ "unable to find cmd in driver or LIO for tag 0x%x\n",
1393+ abts->exchange_addr_to_abort);
1394+ return -ENOENT;
1395+ }
1396+ }
12041397
12051398 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf00f,
12061399 "qla_target(%d): task abort (tag=%d)\n",
@@ -1284,6 +1477,11 @@ static void qlt_24xx_handle_abts(struct scsi_qla_host *vha, · 77 unmodified lines
12841477 return;
12851478 }
12861479
1480+ if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
1481+ qlt_24xx_send_abts_resp(vha, abts, FCP_TMF_REJECTED, false);
1482+ return;
1483+ }
1484+
12871485 rc = __qlt_24xx_handle_abts(vha, abts, sess);
12881486 if (rc != 0) {
12891487 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf054,
@@ -1726,20 +1924,6 @@ static int qlt_pre_xmit_response(struct qla_tgt_cmd *cmd, · 436 unmodified lines
17261924 struct qla_hw_data *ha = vha->hw;
17271925 struct se_cmd *se_cmd = &cmd->se_cmd;
17281926
1729− if (unlikely(cmd->aborted)) {
1730− ql_dbg(ql_dbg_tgt_mgt, vha, 0xf014,
1731− "qla_target(%d): terminating exchange for aborted cmd=%p (se_cmd=%p, tag=%lld)",
1732− vha->vp_idx, cmd, se_cmd, se_cmd->tag);
1733−
1734− cmd->state = QLA_TGT_STATE_ABORTED;
1735− cmd->cmd_flags |= BIT_6;
1736−
1737− qlt_send_term_exchange(vha, cmd, &cmd->atio, 0);
1738−
1739− /* !! At this point cmd could be already freed !! */
1740− return QLA_TGT_PRE_XMIT_RESP_CMD_ABORTED;
1741− }
1742−
17431927 prm->cmd = cmd;
17441928 prm->tgt = tgt;
17451929 prm->rq_result = scsi_status;
@@ -2301,6 +2485,19 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, · 555 unmodified lines
23012485 unsigned long flags = 0;
23022486 int res;
23032487
2488+ spin_lock_irqsave(&ha->hardware_lock, flags);
2489+ if (cmd->sess && cmd->sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
2490+ cmd->state = QLA_TGT_STATE_PROCESSED;
2491+ if (cmd->sess->logout_completed)
2492+ /* no need to terminate. FW already freed exchange. */
2493+ qlt_abort_cmd_on_host_reset(cmd->vha, cmd);
2494+ else
2495+ qlt_send_term_exchange(vha, cmd, &cmd->atio, 1);
2496+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
2497+ return 0;
2498+ }
2499+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
2500+
23042501 memset(&prm, 0, sizeof(prm));
23052502 qlt_check_srr_debug(cmd, &xmit_type);
23062503
@@ -2313,9 +2510,6 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, · 6 unmodified lines
23132510 res = qlt_pre_xmit_response(cmd, &prm, xmit_type, scsi_status,
23142511 &full_req_cnt);
23152512 if (unlikely(res != 0)) {
2316− if (res == QLA_TGT_PRE_XMIT_RESP_CMD_ABORTED)
2317− return 0;
2318−
23192513 return res;
23202514 }
23212515
@@ -2345,9 +2539,10 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, · 23 unmodified lines
23452539 res = qlt_build_ctio_crc2_pkt(&prm, vha);
23462540 else
23472541 res = qlt_24xx_build_ctio_pkt(&prm, vha);
2348− if (unlikely(res != 0))
2542+ if (unlikely(res != 0)) {
2543+ vha->req->cnt += full_req_cnt;
23492544 goto out_unmap_unlock;
2350−
2545+ }
23512546
23522547 pkt = (struct ctio7_to_24xx *)prm.pkt;
23532548
@@ -2461,7 +2656,8 @@ int qlt_rdy_to_xfer(struct qla_tgt_cmd *cmd) · 107 unmodified lines
24612656
24622657 spin_lock_irqsave(&ha->hardware_lock, flags);
24632658
2464− if (qla2x00_reset_active(vha) || cmd->reset_count != ha->chip_reset) {
2659+ if (qla2x00_reset_active(vha) || (cmd->reset_count != ha->chip_reset) ||
2660+ (cmd->sess && cmd->sess->deleted == QLA_SESS_DELETION_IN_PROGRESS)) {
24652661 /*
24662662 * Either a chip reset is active or this request was from
24672663 * previous life, just abort the processing.
@@ -2485,8 +2681,11 @@ int qlt_rdy_to_xfer(struct qla_tgt_cmd *cmd) · 17 unmodified lines
24852681 else
24862682 res = qlt_24xx_build_ctio_pkt(&prm, vha);
24872683
2488− if (unlikely(res != 0))
2684+ if (unlikely(res != 0)) {
2685+ vha->req->cnt += prm.req_cnt;
24892686 goto out_unlock_free_unmap;
2687+ }
2688+
24902689 pkt = (struct ctio7_to_24xx *)prm.pkt;
24912690 pkt->u.status0.flags |= __constant_cpu_to_le16(CTIO7_FLAGS_DATA_OUT |
24922691 CTIO7_FLAGS_STATUS_MODE_0);
@@ -2649,6 +2848,89 @@ out: · 156 unmodified lines
26492848 }
26502849
26512850
2851+/* If hardware_lock held on entry, might drop it, then reaquire */
2852+/* This function sends the appropriate CTIO to ISP 2xxx or 24xx */
2853+static int __qlt_send_term_imm_notif(struct scsi_qla_host *vha,
2854+ struct imm_ntfy_from_isp *ntfy)
2855+{
2856+ struct nack_to_isp *nack;
2857+ struct qla_hw_data *ha = vha->hw;
2858+ request_t *pkt;
2859+ int ret = 0;
2860+
2861+ ql_dbg(ql_dbg_tgt_tmr, vha, 0xe01c,
2862+ "Sending TERM ELS CTIO (ha=%p)\n", ha);
2863+
2864+ pkt = (request_t *)qla2x00_alloc_iocbs_ready(vha, NULL);
2865+ if (pkt == NULL) {
2866+ ql_dbg(ql_dbg_tgt, vha, 0xe080,
2867+ "qla_target(%d): %s failed: unable to allocate "
2868+ "request packet\n", vha->vp_idx, __func__);
2869+ return -ENOMEM;
2870+ }
2871+
2872+ pkt->entry_type = NOTIFY_ACK_TYPE;
2873+ pkt->entry_count = 1;
2874+ pkt->handle = QLA_TGT_SKIP_HANDLE | CTIO_COMPLETION_HANDLE_MARK;
2875+
2876+ nack = (struct nack_to_isp *)pkt;
2877+ nack->ox_id = ntfy->ox_id;
2878+
2879+ nack->u.isp24.nport_handle = ntfy->u.isp24.nport_handle;
2880+ if (le16_to_cpu(ntfy->u.isp24.status) == IMM_NTFY_ELS) {
2881+ nack->u.isp24.flags = ntfy->u.isp24.flags &
2882+ __constant_cpu_to_le32(NOTIFY24XX_FLAGS_PUREX_IOCB);
2883+ }
2884+
2885+ /* terminate */
2886+ nack->u.isp24.flags |=
2887+ __constant_cpu_to_le16(NOTIFY_ACK_FLAGS_TERMINATE);
2888+
2889+ nack->u.isp24.srr_rx_id = ntfy->u.isp24.srr_rx_id;
2890+ nack->u.isp24.status = ntfy->u.isp24.status;
2891+ nack->u.isp24.status_subcode = ntfy->u.isp24.status_subcode;
2892+ nack->u.isp24.fw_handle = ntfy->u.isp24.fw_handle;
2893+ nack->u.isp24.exchange_address = ntfy->u.isp24.exchange_address;
2894+ nack->u.isp24.srr_rel_offs = ntfy->u.isp24.srr_rel_offs;
2895+ nack->u.isp24.srr_ui = ntfy->u.isp24.srr_ui;
2896+ nack->u.isp24.vp_index = ntfy->u.isp24.vp_index;
2897+
2898+ qla2x00_start_iocbs(vha, vha->req);
2899+ return ret;
2900+}
2901+
2902+static void qlt_send_term_imm_notif(struct scsi_qla_host *vha,
2903+ struct imm_ntfy_from_isp *imm, int ha_locked)
2904+{
2905+ unsigned long flags = 0;
2906+ int rc;
2907+
2908+ if (qlt_issue_marker(vha, ha_locked) < 0)
2909+ return;
2910+
2911+ if (ha_locked) {
2912+ rc = __qlt_send_term_imm_notif(vha, imm);
2913+
2914+#if 0 /* Todo */
2915+ if (rc == -ENOMEM)
2916+ qlt_alloc_qfull_cmd(vha, imm, 0, 0);
2917+#endif
2918+ goto done;
2919+ }
2920+
2921+ spin_lock_irqsave(&vha->hw->hardware_lock, flags);
2922+ rc = __qlt_send_term_imm_notif(vha, imm);
2923+
2924+#if 0 /* Todo */
2925+ if (rc == -ENOMEM)
2926+ qlt_alloc_qfull_cmd(vha, imm, 0, 0);
2927+#endif
2928+
2929+done:
2930+ if (!ha_locked)
2931+ spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
2932+}
2933+
26522934 /* If hardware_lock held on entry, might drop it, then reaquire */
26532935 /* This function sends the appropriate CTIO to ISP 2xxx or 24xx */
26542936 static int __qlt_send_term_exchange(struct scsi_qla_host *vha,
@@ -2715,7 +2997,7 @@ static int __qlt_send_term_exchange(struct scsi_qla_host *vha, · 60 unmodified lines
27152997 static void qlt_send_term_exchange(struct scsi_qla_host *vha,
27162998 struct qla_tgt_cmd *cmd, struct atio_from_isp *atio, int ha_locked)
27172999 {
2718− unsigned long flags;
3000+ unsigned long flags = 0;
27193001 int rc;
27203002
27213003 if (qlt_issue_marker(vha, ha_locked) < 0)
@@ -2731,17 +3013,18 @@ static void qlt_send_term_exchange(struct scsi_qla_host *vha, · 9 unmodified lines
27313013 rc = __qlt_send_term_exchange(vha, cmd, atio);
27323014 if (rc == -ENOMEM)
27333015 qlt_alloc_qfull_cmd(vha, atio, 0, 0);
2734− spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
27353016
27363017 done:
27373018 if (cmd && ((cmd->state != QLA_TGT_STATE_ABORTED) ||
27383019 !cmd->cmd_sent_to_fw)) {
2739− if (!ha_locked && !in_interrupt())
2740− msleep(250); /* just in case */
2741−
2742− qlt_unmap_sg(vha, cmd);
3020+ if (cmd->sg_mapped)
3021+ qlt_unmap_sg(vha, cmd);
27433022 vha->hw->tgt.tgt_ops->free_cmd(cmd);
27443023 }
3024+
3025+ if (!ha_locked)
3026+ spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
3027+
27453028 return;
27463029 }
27473030
@@ -2792,6 +3075,24 @@ static void qlt_chk_exch_leak_thresh_hold(struct scsi_qla_host *vha) · 44 unmodified lines
27923075
27933076 }
27943077
3078+void qlt_abort_cmd(struct qla_tgt_cmd *cmd)
3079+{
3080+ struct qla_tgt *tgt = cmd->tgt;
3081+ struct scsi_qla_host *vha = tgt->vha;
3082+ struct se_cmd *se_cmd = &cmd->se_cmd;
3083+
3084+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf014,
3085+ "qla_target(%d): terminating exchange for aborted cmd=%p "
3086+ "(se_cmd=%p, tag=%llu)", vha->vp_idx, cmd, &cmd->se_cmd,
3087+ se_cmd->tag);
3088+
3089+ cmd->state = QLA_TGT_STATE_ABORTED;
3090+ cmd->cmd_flags |= BIT_6;
3091+
3092+ qlt_send_term_exchange(vha, cmd, &cmd->atio, 0);
3093+}
3094+EXPORT_SYMBOL(qlt_abort_cmd);
3095+
27953096 void qlt_free_cmd(struct qla_tgt_cmd *cmd)
27963097 {
27973098 struct qla_tgt_sess *sess = cmd->sess;
@@ -3015,7 +3316,7 @@ qlt_abort_cmd_on_host_reset(struct scsi_qla_host *vha, struct qla_tgt_cmd *cmd) · 217 unmodified lines
30153316 dump_stack();
30163317 }
30173318
3018− cmd->cmd_flags |= BIT_12;
3319+ cmd->cmd_flags |= BIT_17;
30193320 ha->tgt.tgt_ops->free_cmd(cmd);
30203321 }
30213322
@@ -3177,7 +3478,7 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha, uint32_t handle, · 155 unmodified lines
31773478 skip_term:
31783479
31793480 if (cmd->state == QLA_TGT_STATE_PROCESSED) {
3180− ;
3481+ cmd->cmd_flags |= BIT_12;
31813482 } else if (cmd->state == QLA_TGT_STATE_NEED_DATA) {
31823483 int rx_status = 0;
31833484
@@ -3191,9 +3492,11 @@ skip_term: · 7 unmodified lines
31913492 ha->tgt.tgt_ops->handle_data(cmd);
31923493 return;
31933494 } else if (cmd->state == QLA_TGT_STATE_ABORTED) {
3495+ cmd->cmd_flags |= BIT_18;
31943496 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf01e,
31953497 "Aborted command %p (tag %lld) finished\n", cmd, se_cmd->tag);
31963498 } else {
3499+ cmd->cmd_flags |= BIT_19;
31973500 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf05c,
31983501 "qla_target(%d): A command in state (%d) should "
31993502 "not return a CTIO complete\n", vha->vp_idx, cmd->state);
@@ -3205,7 +3508,6 @@ skip_term: · 5 unmodified lines
32053508 dump_stack();
32063509 }
32073510
3208−
32093511 ha->tgt.tgt_ops->free_cmd(cmd);
32103512 }
32113513
@@ -3263,6 +3565,13 @@ static void __qlt_do_work(struct qla_tgt_cmd *cmd) · 51 unmodified lines
32633565 if (tgt->tgt_stop)
32643566 goto out_term;
32653567
3568+ if (cmd->state == QLA_TGT_STATE_ABORTED) {
3569+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf082,
3570+ "cmd with tag %u is aborted\n",
3571+ cmd->atio.u.isp24.exchange_addr);
3572+ goto out_term;
3573+ }
3574+
32663575 cdb = &atio->u.isp24.fcp_cmnd.cdb[0];
32673576 cmd->se_cmd.tag = atio->u.isp24.exchange_addr;
32683577 cmd->unpacked_lun = scsilun_to_int(
@@ -3316,6 +3625,12 @@ out_term: · 47 unmodified lines
33163625 static void qlt_do_work(struct work_struct *work)
33173626 {
33183627 struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work);
3628+ scsi_qla_host_t *vha = cmd->vha;
3629+ unsigned long flags;
3630+
3631+ spin_lock_irqsave(&vha->cmd_list_lock, flags);
3632+ list_del(&cmd->cmd_list);
3633+ spin_unlock_irqrestore(&vha->cmd_list_lock, flags);
33193634
33203635 __qlt_do_work(cmd);
33213636 }
@@ -3345,6 +3660,11 @@ static struct qla_tgt_cmd *qlt_get_tag(scsi_qla_host_t *vha, · 23 unmodified lines
33453660 cmd->loop_id = sess->loop_id;
33463661 cmd->conf_compl_supported = sess->conf_compl_supported;
33473662
3663+ cmd->cmd_flags = 0;
3664+ cmd->jiffies_at_alloc = get_jiffies_64();
3665+
3666+ cmd->reset_count = vha->hw->chip_reset;
3667+
33483668 return cmd;
33493669 }
33503670
@@ -3362,14 +3682,25 @@ static void qlt_create_sess_from_atio(struct work_struct *work) · 11 unmodified lines
33623682 unsigned long flags;
33633683 uint8_t *s_id = op->atio.u.isp24.fcp_hdr.s_id;
33643684
3685+ spin_lock_irqsave(&vha->cmd_list_lock, flags);
3686+ list_del(&op->cmd_list);
3687+ spin_unlock_irqrestore(&vha->cmd_list_lock, flags);
3688+
3689+ if (op->aborted) {
3690+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf083,
3691+ "sess_op with tag %u is aborted\n",
3692+ op->atio.u.isp24.exchange_addr);
3693+ goto out_term;
3694+ }
3695+
33653696 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf022,
3366− "qla_target(%d): Unable to find wwn login"
3367− " (s_id %x:%x:%x), trying to create it manually\n",
3368− vha->vp_idx, s_id[0], s_id[1], s_id[2]);
3697+ "qla_target(%d): Unable to find wwn login"
3698+ " (s_id %x:%x:%x), trying to create it manually\n",
3699+ vha->vp_idx, s_id[0], s_id[1], s_id[2]);
33693700
33703701 if (op->atio.u.raw.entry_count > 1) {
33713702 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf023,
3372− "Dropping multy entry atio %p\n", &op->atio);
3703+ "Dropping multy entry atio %p\n", &op->atio);
33733704 goto out_term;
33743705 }
33753706
@@ -3434,10 +3765,25 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha, · 58 unmodified lines
34343765
34353766 memcpy(&op->atio, atio, sizeof(*atio));
34363767 op->vha = vha;
3768+
3769+ spin_lock(&vha->cmd_list_lock);
3770+ list_add_tail(&op->cmd_list, &vha->qla_sess_op_cmd_list);
3771+ spin_unlock(&vha->cmd_list_lock);
3772+
34373773 INIT_WORK(&op->work, qlt_create_sess_from_atio);
34383774 queue_work(qla_tgt_wq, &op->work);
34393775 return 0;
34403776 }
3777+
3778+ /* Another WWN used to have our s_id. Our PLOGI scheduled its
3779+ * session deletion, but it's still in sess_del_work wq */
3780+ if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
3781+ ql_dbg(ql_dbg_io, vha, 0x3061,
3782+ "New command while old session %p is being deleted\n",
3783+ sess);
3784+ return -EFAULT;
3785+ }
3786+
34413787 /*
34423788 * Do kref_get() before returning + dropping qla_hw_data->hardware_lock.
34433789 */
@@ -3451,13 +3797,13 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha, · 7 unmodified lines
34513797 return -ENOMEM;
34523798 }
34533799
3454− cmd->cmd_flags = 0;
3455− cmd->jiffies_at_alloc = get_jiffies_64();
3456−
3457− cmd->reset_count = vha->hw->chip_reset;
3458−
34593800 cmd->cmd_in_wq = 1;
34603801 cmd->cmd_flags |= BIT_0;
3802+
3803+ spin_lock(&vha->cmd_list_lock);
3804+ list_add_tail(&cmd->cmd_list, &vha->qla_cmd_list);
3805+ spin_unlock(&vha->cmd_list_lock);
3806+
34613807 INIT_WORK(&cmd->work, qlt_do_work);
34623808 queue_work(qla_tgt_wq, &cmd->work);
34633809 return 0;
@@ -3471,6 +3817,7 @@ static int qlt_issue_task_mgmt(struct qla_tgt_sess *sess, uint32_t lun, · 7 unmodified lines
34713817 struct scsi_qla_host *vha = sess->vha;
34723818 struct qla_hw_data *ha = vha->hw;
34733819 struct qla_tgt_mgmt_cmd *mcmd;
3820+ struct atio_from_isp *a = (struct atio_from_isp *)iocb;
34743821 int res;
34753822 uint8_t tmr_func;
34763823
@@ -3511,6 +3858,7 @@ static int qlt_issue_task_mgmt(struct qla_tgt_sess *sess, uint32_t lun, · 34 unmodified lines
35113858 ql_dbg(ql_dbg_tgt_tmr, vha, 0x10002,
35123859 "qla_target(%d): LUN_RESET received\n", sess->vha->vp_idx);
35133860 tmr_func = TMR_LUN_RESET;
3861+ abort_cmds_for_lun(vha, lun, a->u.isp24.fcp_hdr.s_id);
35143862 break;
35153863
35163864 case QLA_TGT_CLEAR_TS:
@@ -3599,6 +3947,9 @@ static int qlt_handle_task_mgmt(struct scsi_qla_host *vha, void *iocb) · 82 unmodified lines
35993947 sizeof(struct atio_from_isp));
36003948 }
36013949
3950+ if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS)
3951+ return -EFAULT;
3952+
36023953 return qlt_issue_task_mgmt(sess, unpacked_lun, fn, iocb, 0);
36033954 }
36043955
@@ -3664,22 +4015,280 @@ static int qlt_abort_task(struct scsi_qla_host *vha, · 59 unmodified lines
36644015 return __qlt_abort_task(vha, iocb, sess);
36654016 }
36664017
4018+void qlt_logo_completion_handler(fc_port_t *fcport, int rc)
4019+{
4020+ if (fcport->tgt_session) {
4021+ if (rc != MBS_COMMAND_COMPLETE) {
4022+ ql_dbg(ql_dbg_tgt_mgt, fcport->vha, 0xf093,
4023+ "%s: se_sess %p / sess %p from"
4024+ " port %8phC loop_id %#04x s_id %02x:%02x:%02x"
4025+ " LOGO failed: %#x\n",
4026+ __func__,
4027+ fcport->tgt_session->se_sess,
4028+ fcport->tgt_session,
4029+ fcport->port_name, fcport->loop_id,
4030+ fcport->d_id.b.domain, fcport->d_id.b.area,
4031+ fcport->d_id.b.al_pa, rc);
4032+ }
4033+
4034+ fcport->tgt_session->logout_completed = 1;
4035+ }
4036+}
4037+
4038+static void qlt_swap_imm_ntfy_iocb(struct imm_ntfy_from_isp *a,
4039+ struct imm_ntfy_from_isp *b)
4040+{
4041+ struct imm_ntfy_from_isp tmp;
4042+ memcpy(&tmp, a, sizeof(struct imm_ntfy_from_isp));
4043+ memcpy(a, b, sizeof(struct imm_ntfy_from_isp));
4044+ memcpy(b, &tmp, sizeof(struct imm_ntfy_from_isp));
4045+}
4046+
4047+/*
4048+* ha->hardware_lock supposed to be held on entry (to protect tgt->sess_list)
4049+*
4050+* Schedules sessions with matching port_id/loop_id but different wwn for
4051+* deletion. Returns existing session with matching wwn if present.
4052+* Null otherwise.
4053+*/
4054+static struct qla_tgt_sess *
4055+qlt_find_sess_invalidate_other(struct qla_tgt *tgt, uint64_t wwn,
4056+ port_id_t port_id, uint16_t loop_id)
4057+{
4058+ struct qla_tgt_sess *sess = NULL, *other_sess;
4059+ uint64_t other_wwn;
4060+
4061+ list_for_each_entry(other_sess, &tgt->sess_list, sess_list_entry) {
4062+
4063+ other_wwn = wwn_to_u64(other_sess->port_name);
4064+
4065+ if (wwn == other_wwn) {
4066+ WARN_ON(sess);
4067+ sess = other_sess;
4068+ continue;
4069+ }
4070+
4071+ /* find other sess with nport_id collision */
4072+ if (port_id.b24 == other_sess->s_id.b24) {
4073+ if (loop_id != other_sess->loop_id) {
4074+ ql_dbg(ql_dbg_tgt_tmr, tgt->vha, 0x1000c,
4075+ "Invalidating sess %p loop_id %d wwn %llx.\n",
4076+ other_sess, other_sess->loop_id, other_wwn);
4077+
4078+ /*
4079+ * logout_on_delete is set by default, but another
4080+ * session that has the same s_id/loop_id combo
4081+ * might have cleared it when requested this session
4082+ * deletion, so don't touch it
4083+ */
4084+ qlt_schedule_sess_for_deletion(other_sess, true);
4085+ } else {
4086+ /*
4087+ * Another wwn used to have our s_id/loop_id
4088+ * combo - kill the session, but don't log out
4089+ */
4090+ sess->logout_on_delete = 0;
4091+ qlt_schedule_sess_for_deletion(other_sess,
4092+ true);
4093+ }
4094+ continue;
4095+ }
4096+
4097+ /* find other sess with nport handle collision */
4098+ if (loop_id == other_sess->loop_id) {
4099+ ql_dbg(ql_dbg_tgt_tmr, tgt->vha, 0x1000d,
4100+ "Invalidating sess %p loop_id %d wwn %llx.\n",
4101+ other_sess, other_sess->loop_id, other_wwn);
4102+
4103+ /* Same loop_id but different s_id
4104+ * Ok to kill and logout */
4105+ qlt_schedule_sess_for_deletion(other_sess, true);
4106+ }
4107+ }
4108+
4109+ return sess;
4110+}
4111+
4112+/* Abort any commands for this s_id waiting on qla_tgt_wq workqueue */
4113+static int abort_cmds_for_s_id(struct scsi_qla_host *vha, port_id_t *s_id)
4114+{
4115+ struct qla_tgt_sess_op *op;
4116+ struct qla_tgt_cmd *cmd;
4117+ uint32_t key;
4118+ int count = 0;
4119+
4120+ key = (((u32)s_id->b.domain << 16) |
4121+ ((u32)s_id->b.area << 8) |
4122+ ((u32)s_id->b.al_pa));
4123+
4124+ spin_lock(&vha->cmd_list_lock);
4125+ list_for_each_entry(op, &vha->qla_sess_op_cmd_list, cmd_list) {
4126+ uint32_t op_key = sid_to_key(op->atio.u.isp24.fcp_hdr.s_id);
4127+ if (op_key == key) {
4128+ op->aborted = true;
4129+ count++;
4130+ }
4131+ }
4132+ list_for_each_entry(cmd, &vha->qla_cmd_list, cmd_list) {
4133+ uint32_t cmd_key = sid_to_key(cmd->atio.u.isp24.fcp_hdr.s_id);
4134+ if (cmd_key == key) {
4135+ cmd->state = QLA_TGT_STATE_ABORTED;
4136+ count++;
4137+ }
4138+ }
4139+ spin_unlock(&vha->cmd_list_lock);
4140+
4141+ return count;
4142+}
4143+
36674144 /*
36684145 * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
36694146 */
36704147 static int qlt_24xx_handle_els(struct scsi_qla_host *vha,
36714148 struct imm_ntfy_from_isp *iocb)
36724149 {
4150+ struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
4151+ struct qla_hw_data *ha = vha->hw;
4152+ struct qla_tgt_sess *sess = NULL;
4153+ uint64_t wwn;
4154+ port_id_t port_id;
4155+ uint16_t loop_id;
4156+ uint16_t wd3_lo;
36734157 int res = 0;
36744158
4159+ wwn = wwn_to_u64(iocb->u.isp24.port_name);
4160+
4161+ port_id.b.domain = iocb->u.isp24.port_id[2];
4162+ port_id.b.area = iocb->u.isp24.port_id[1];
4163+ port_id.b.al_pa = iocb->u.isp24.port_id[0];
4164+ port_id.b.rsvd_1 = 0;
4165+
4166+ loop_id = le16_to_cpu(iocb->u.isp24.nport_handle);
4167+
36754168 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf026,
36764169 "qla_target(%d): Port ID: 0x%3phC ELS opcode: 0x%02x\n",
36774170 vha->vp_idx, iocb->u.isp24.port_id, iocb->u.isp24.status_subcode);
36784171
4172+ /* res = 1 means ack at the end of thread
4173+ * res = 0 means ack async/later.
4174+ */
36794175 switch (iocb->u.isp24.status_subcode) {
36804176 case ELS_PLOGI:
3681− case ELS_FLOGI:
4177+
4178+ /* Mark all stale commands in qla_tgt_wq for deletion */
4179+ abort_cmds_for_s_id(vha, &port_id);
4180+
4181+ if (wwn)
4182+ sess = qlt_find_sess_invalidate_other(tgt, wwn,
4183+ port_id, loop_id);
4184+
4185+ if (!sess || IS_SW_RESV_ADDR(sess->s_id)) {
4186+ res = 1;
4187+ break;
4188+ }
4189+
4190+ if (sess->plogi_ack_needed) {
4191+ /*
4192+ * Initiator sent another PLOGI before last PLOGI could
4193+ * finish. Swap plogi iocbs and terminate old one
4194+ * without acking, new one will get acked when session
4195+ * deletion completes.
4196+ */
4197+ ql_log(ql_log_warn, sess->vha, 0xf094,
4198+ "sess %p received double plogi.\n", sess);
4199+
4200+ qlt_swap_imm_ntfy_iocb(iocb, &sess->tm_iocb);
4201+
4202+ qlt_send_term_imm_notif(vha, iocb, 1);
4203+
4204+ res = 0;
4205+ break;
4206+ }
4207+
4208+ res = 0;
4209+
4210+ /*
4211+ * Save immediate Notif IOCB for Ack when sess is done
4212+ * and being deleted.
4213+ */
4214+ memcpy(&sess->tm_iocb, iocb, sizeof(sess->tm_iocb));
4215+ sess->plogi_ack_needed = 1;
4216+
4217+ /*
4218+ * Under normal circumstances we want to release nport handle
4219+ * during LOGO process to avoid nport handle leaks inside FW.
4220+ * The exception is when LOGO is done while another PLOGI with
4221+ * the same nport handle is waiting as might be the case here.
4222+ * Note: there is always a possibily of a race where session
4223+ * deletion has already started for other reasons (e.g. ACL
4224+ * removal) and now PLOGI arrives:
4225+ * 1. if PLOGI arrived in FW after nport handle has been freed,
4226+ * FW must have assigned this PLOGI a new/same handle and we
4227+ * can proceed ACK'ing it as usual when session deletion
4228+ * completes.
4229+ * 2. if PLOGI arrived in FW before LOGO with LCF_FREE_NPORT
4230+ * bit reached it, the handle has now been released. We'll
4231+ * get an error when we ACK this PLOGI. Nothing will be sent
4232+ * back to initiator. Initiator should eventually retry
4233+ * PLOGI and situation will correct itself.
4234+ */
4235+ sess->keep_nport_handle = ((sess->loop_id == loop_id) &&
4236+ (sess->s_id.b24 == port_id.b24));
4237+ qlt_schedule_sess_for_deletion(sess, true);
4238+ break;
4239+
36824240 case ELS_PRLI:
4241+ wd3_lo = le16_to_cpu(iocb->u.isp24.u.prli.wd3_lo);
4242+
4243+ if (wwn)
4244+ sess = qlt_find_sess_invalidate_other(tgt, wwn, port_id,
4245+ loop_id);
4246+
4247+ if (sess != NULL) {
4248+ if (sess->deleted) {
4249+ /*
4250+ * Impatient initiator sent PRLI before last
4251+ * PLOGI could finish. Will force him to re-try,
4252+ * while last one finishes.
4253+ */
4254+ ql_log(ql_log_warn, sess->vha, 0xf095,
4255+ "sess %p PRLI received, before plogi ack.\n",
4256+ sess);
4257+ qlt_send_term_imm_notif(vha, iocb, 1);
4258+ res = 0;
4259+ break;
4260+ }
4261+
4262+ /*
4263+ * This shouldn't happen under normal circumstances,
4264+ * since we have deleted the old session during PLOGI
4265+ */
4266+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf096,
4267+ "PRLI (loop_id %#04x) for existing sess %p (loop_id %#04x)\n",
4268+ sess->loop_id, sess, iocb->u.isp24.nport_handle);
4269+
4270+ sess->local = 0;
4271+ sess->loop_id = loop_id;
4272+ sess->s_id = port_id;
4273+
4274+ if (wd3_lo & BIT_7)
4275+ sess->conf_compl_supported = 1;
4276+
4277+ }
4278+ res = 1; /* send notify ack */
4279+
4280+ /* Make session global (not used in fabric mode) */
4281+ if (ha->current_topology != ISP_CFG_F) {
4282+ set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
4283+ set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
4284+ qla2xxx_wake_dpc(vha);
4285+ } else {
4286+ /* todo: else - create sess here. */
4287+ res = 1; /* send notify ack */
4288+ }
4289+
4290+ break;
4291+
36834292 case ELS_LOGO:
36844293 case ELS_PRLO:
36854294 res = qlt_reset(vha, iocb, QLA_TGT_NEXUS_LOSS_SESS);
@@ -3697,6 +4306,7 @@ static int qlt_24xx_handle_els(struct scsi_qla_host *vha, · 11 unmodified lines
36974306 break;
36984307 }
36994308
4309+ case ELS_FLOGI: /* should never happen */
37004310 default:
37014311 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf061,
37024312 "qla_target(%d): Unsupported ELS command %x "
@@ -5012,6 +5622,11 @@ static void qlt_abort_work(struct qla_tgt *tgt, · 1309 unmodified lines
50125622 if (!sess)
50135623 goto out_term;
50145624 } else {
5625+ if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
5626+ sess = NULL;
5627+ goto out_term;
5628+ }
5629+
50155630 kref_get(&sess->se_sess->sess_kref);
50165631 }
50175632
@@ -5066,6 +5681,11 @@ static void qlt_tmr_work(struct qla_tgt *tgt, · 48 unmodified lines
50665681 if (!sess)
50675682 goto out_term;
50685683 } else {
5684+ if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
5685+ sess = NULL;
5686+ goto out_term;
5687+ }
5688+
50695689 kref_get(&sess->se_sess->sess_kref);
50705690 }
50715691
@@ -5552,6 +6172,7 @@ qlt_24xx_process_atio_queue(struct scsi_qla_host *vha) · 480 unmodified lines
55526172
55536173 /* Adjust ring index */
55546174 WRT_REG_DWORD(ISP_ATIO_Q_OUT(vha), ha->tgt.atio_ring_index);
6175+ RD_REG_DWORD_RELAXED(ISP_ATIO_Q_OUT(vha));
55556176 }
55566177
55576178 void
@@ -5793,7 +6414,7 @@ qlt_probe_one_stage1(struct scsi_qla_host *base_vha, struct qla_hw_data *ha) · 235 unmodified lines
57936414 if (!QLA_TGT_MODE_ENABLED())
57946415 return;
57956416
5796− if (ha->mqenable || IS_QLA83XX(ha)) {
6417+ if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
57976418 ISP_ATIO_Q_IN(base_vha) = &ha->mqiobase->isp25mq.atio_q_in;
57986419 ISP_ATIO_Q_OUT(base_vha) = &ha->mqiobase->isp25mq.atio_q_out;
57996420 } else {
drivers/scsi/qla2xxx/qla_target.h+61−11
@@ -167,7 +167,24 @@ struct imm_ntfy_from_isp { · 166 unmodified lines
167167 uint32_t srr_rel_offs;
168168 uint16_t srr_ui;
169169 uint16_t srr_ox_id;
170− uint8_t reserved_4[19];
170+ union {
171+ struct {
172+ uint8_t node_name[8];
173+ } plogi; /* PLOGI/ADISC/PDISC */
174+ struct {
175+ /* PRLI word 3 bit 0-15 */
176+ uint16_t wd3_lo;
177+ uint8_t resv0[6];
178+ } prli;
179+ struct {
180+ uint8_t port_id[3];
181+ uint8_t resv1;
182+ uint16_t nport_handle;
183+ uint16_t resv2;
184+ } req_els;
185+ } u;
186+ uint8_t port_name[8];
187+ uint8_t resv3[3];
171188 uint8_t vp_index;
172189 uint32_t reserved_5;
173190 uint8_t port_id[3];
@@ -234,6 +251,7 @@ struct nack_to_isp { · 60 unmodified lines
234251 uint8_t reserved[2];
235252 uint16_t ox_id;
236253 } __packed;
254+#define NOTIFY_ACK_FLAGS_TERMINATE BIT_3
237255 #define NOTIFY_ACK_SRR_FLAGS_ACCEPT 0
238256 #define NOTIFY_ACK_SRR_FLAGS_REJECT 1
239257
@@ -790,13 +808,6 @@ int qla2x00_wait_for_hba_online(struct scsi_qla_host *); · 550 unmodified lines
790808 #define FC_TM_REJECT 4
791809 #define FC_TM_FAILED 5
792810
793−/*
794− * Error code of qlt_pre_xmit_response() meaning that cmd's exchange was
795− * terminated, so no more actions is needed and success should be returned
796− * to target.
797− */
798−#define QLA_TGT_PRE_XMIT_RESP_CMD_ABORTED 0x1717
799−
800811 #if (BITS_PER_LONG > 32) || defined(CONFIG_HIGHMEM64G)
801812 #define pci_dma_lo32(a) (a & 0xffffffff)
802813 #define pci_dma_hi32(a) ((((a) >> 16)>>16) & 0xffffffff)
@@ -874,6 +885,15 @@ struct qla_tgt_sess_op { · 71 unmodified lines
874885 struct scsi_qla_host *vha;
875886 struct atio_from_isp atio;
876887 struct work_struct work;
888+ struct list_head cmd_list;
889+ bool aborted;
890+};
891+
892+enum qla_sess_deletion {
893+ QLA_SESS_DELETION_NONE = 0,
894+ QLA_SESS_DELETION_PENDING = 1, /* hopefully we can get rid of
895+ * this one */
896+ QLA_SESS_DELETION_IN_PROGRESS = 2,
877897 };
878898
879899 /*
@@ -884,8 +904,15 @@ struct qla_tgt_sess { · 4 unmodified lines
884904 port_id_t s_id;
885905
886906 unsigned int conf_compl_supported:1;
887− unsigned int deleted:1;
907+ unsigned int deleted:2;
888908 unsigned int local:1;
909+ unsigned int logout_on_delete:1;
910+ unsigned int plogi_ack_needed:1;
911+ unsigned int keep_nport_handle:1;
912+
913+ unsigned char logout_completed;
914+
915+ int generation;
889916
890917 struct se_session *se_sess;
891918 struct scsi_qla_host *vha;
@@ -897,6 +924,10 @@ struct qla_tgt_sess { · 5 unmodified lines
897924
898925 uint8_t port_name[WWN_SIZE];
899926 struct work_struct free_work;
927+
928+ union {
929+ struct imm_ntfy_from_isp tm_iocb;
930+ };
900931 };
901932
902933 struct qla_tgt_cmd {
@@ -912,7 +943,6 @@ struct qla_tgt_cmd { · 9 unmodified lines
912943 unsigned int conf_compl_supported:1;
913944 unsigned int sg_mapped:1;
914945 unsigned int free_sg:1;
915− unsigned int aborted:1; /* Needed in case of SRR */
916946 unsigned int write_data_transferred:1;
917947 unsigned int ctx_dsd_alloced:1;
918948 unsigned int q_full:1;
@@ -961,6 +991,9 @@ struct qla_tgt_cmd { · 42 unmodified lines
961991 * BIT_14 - Back end data received/sent.
962992 * BIT_15 - SRR prepare ctio
963993 * BIT_16 - complete free
994+ * BIT_17 - flush - qlt_abort_cmd_on_host_reset
995+ * BIT_18 - completion w/abort status
996+ * BIT_19 - completion w/unknown status
964997 */
965998 uint32_t cmd_flags;
966999 };
@@ -1026,6 +1059,10 @@ struct qla_tgt_srr_ctio { · 59 unmodified lines
10261059 struct qla_tgt_cmd *cmd;
10271060 };
10281061
1062+/* Check for Switch reserved address */
1063+#define IS_SW_RESV_ADDR(_s_id) \
1064+ ((_s_id.b.domain == 0xff) && (_s_id.b.area == 0xfc))
1065+
10291066 #define QLA_TGT_XMIT_DATA 1
10301067 #define QLA_TGT_XMIT_STATUS 2
10311068 #define QLA_TGT_XMIT_ALL (QLA_TGT_XMIT_STATUS|QLA_TGT_XMIT_DATA)
@@ -1043,7 +1080,7 @@ extern int qlt_lport_register(void *, u64, u64, u64, · 11 unmodified lines
10431080 extern void qlt_lport_deregister(struct scsi_qla_host *);
10441081 extern void qlt_unreg_sess(struct qla_tgt_sess *);
10451082 extern void qlt_fc_port_added(struct scsi_qla_host *, fc_port_t *);
1046−extern void qlt_fc_port_deleted(struct scsi_qla_host *, fc_port_t *);
1083+extern void qlt_fc_port_deleted(struct scsi_qla_host *, fc_port_t *, int);
10471084 extern int __init qlt_init(void);
10481085 extern void qlt_exit(void);
10491086 extern void qlt_update_vp_map(struct scsi_qla_host *, int);
@@ -1073,12 +1110,23 @@ static inline void qla_reverse_ini_mode(struct scsi_qla_host *ha) · 23 unmodified lines
10731110 ha->host->active_mode |= MODE_INITIATOR;
10741111 }
10751112
1113+static inline uint32_t sid_to_key(const uint8_t *s_id)
1114+{
1115+ uint32_t key;
1116+
1117+ key = (((unsigned long)s_id[0] << 16) |
1118+ ((unsigned long)s_id[1] << 8) |
1119+ (unsigned long)s_id[2]);
1120+ return key;
1121+}
1122+
10761123 /*
10771124 * Exported symbols from qla_target.c LLD logic used by qla2xxx code..
10781125 */
10791126 extern void qlt_response_pkt_all_vps(struct scsi_qla_host *, response_t *);
10801127 extern int qlt_rdy_to_xfer(struct qla_tgt_cmd *);
10811128 extern int qlt_xmit_response(struct qla_tgt_cmd *, int, uint8_t);
1129+extern void qlt_abort_cmd(struct qla_tgt_cmd *);
10821130 extern void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *);
10831131 extern void qlt_free_mcmd(struct qla_tgt_mgmt_cmd *);
10841132 extern void qlt_free_cmd(struct qla_tgt_cmd *cmd);
@@ -1109,5 +1157,7 @@ extern void qlt_stop_phase2(struct qla_tgt *); · 24 unmodified lines
11091157 extern irqreturn_t qla83xx_msix_atio_q(int, void *);
11101158 extern void qlt_83xx_iospace_config(struct qla_hw_data *);
11111159 extern int qlt_free_qfull_cmds(struct scsi_qla_host *);
1160+extern void qlt_logo_completion_handler(fc_port_t *, int);
1161+extern void qlt_do_generation_tick(struct scsi_qla_host *, int *);
11121162
11131163 #endif /* __QLA_TARGET_H */
drivers/scsi/qla2xxx/tcm_qla2xxx.c+9−19
@@ -374,7 +374,7 @@ static int tcm_qla2xxx_write_pending(struct se_cmd *se_cmd) · 373 unmodified lines
374374 {
375375 struct qla_tgt_cmd *cmd = container_of(se_cmd,
376376 struct qla_tgt_cmd, se_cmd);
377−
377+ cmd->cmd_flags |= BIT_3;
378378 cmd->bufflen = se_cmd->data_length;
379379 cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
380380
@@ -405,7 +405,7 @@ static int tcm_qla2xxx_write_pending_status(struct se_cmd *se_cmd) · 24 unmodified lines
405405 se_cmd->t_state == TRANSPORT_COMPLETE_QF_WP) {
406406 spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
407407 wait_for_completion_timeout(&se_cmd->t_transport_stop_comp,
408− 3000);
408+ 3 * HZ);
409409 return 0;
410410 }
411411 spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
@@ -541,12 +541,10 @@ static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd) · 129 unmodified lines
541541 cmd->cmd_flags |= BIT_4;
542542 cmd->bufflen = se_cmd->data_length;
543543 cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
544− cmd->aborted = (se_cmd->transport_state & CMD_T_ABORTED);
545544
546545 cmd->sg_cnt = se_cmd->t_data_nents;
547546 cmd->sg = se_cmd->t_data_sg;
548547 cmd->offset = 0;
549− cmd->cmd_flags |= BIT_3;
550548
551549 cmd->prot_sg_cnt = se_cmd->t_prot_nents;
552550 cmd->prot_sg = se_cmd->t_prot_sg;
@@ -571,7 +569,6 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd) · 18 unmodified lines
571569 cmd->sg_cnt = 0;
572570 cmd->offset = 0;
573571 cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
574− cmd->aborted = (se_cmd->transport_state & CMD_T_ABORTED);
575572 if (cmd->cmd_flags & BIT_5) {
576573 pr_crit("Bit_5 already set for cmd = %p.\n", cmd);
577574 dump_stack();
@@ -636,14 +633,7 @@ static void tcm_qla2xxx_aborted_task(struct se_cmd *se_cmd) · 58 unmodified lines
636633 {
637634 struct qla_tgt_cmd *cmd = container_of(se_cmd,
638635 struct qla_tgt_cmd, se_cmd);
639− struct scsi_qla_host *vha = cmd->vha;
640− struct qla_hw_data *ha = vha->hw;
641−
642− if (!cmd->sg_mapped)
643− return;
644−
645− pci_unmap_sg(ha->pdev, cmd->sg, cmd->sg_cnt, cmd->dma_data_direction);
646− cmd->sg_mapped = 0;
636+ qlt_abort_cmd(cmd);
647637 }
648638
649639 static void tcm_qla2xxx_clear_sess_lookup(struct tcm_qla2xxx_lport *,
@@ -1149,9 +1139,7 @@ static struct qla_tgt_sess *tcm_qla2xxx_find_sess_by_s_id( · 499 unmodified lines
11491139 return NULL;
11501140 }
11511141
1152− key = (((unsigned long)s_id[0] << 16) |
1153− ((unsigned long)s_id[1] << 8) |
1154− (unsigned long)s_id[2]);
1142+ key = sid_to_key(s_id);
11551143 pr_debug("find_sess_by_s_id: 0x%06x\n", key);
11561144
11571145 se_nacl = btree_lookup32(&lport->lport_fcport_map, key);
@@ -1186,9 +1174,7 @@ static void tcm_qla2xxx_set_sess_by_s_id( · 28 unmodified lines
11861174 void *slot;
11871175 int rc;
11881176
1189− key = (((unsigned long)s_id[0] << 16) |
1190− ((unsigned long)s_id[1] << 8) |
1191− (unsigned long)s_id[2]);
1177+ key = sid_to_key(s_id);
11921178 pr_debug("set_sess_by_s_id: %06x\n", key);
11931179
11941180 slot = btree_lookup32(&lport->lport_fcport_map, key);
@@ -1544,6 +1530,10 @@ static void tcm_qla2xxx_update_sess(struct qla_tgt_sess *sess, port_id_t s_id, · 349 unmodified lines
15441530 }
15451531
15461532 sess->conf_compl_supported = conf_compl_supported;
1533+
1534+ /* Reset logout parameters to default */
1535+ sess->logout_on_delete = 1;
1536+ sess->keep_nport_handle = 0;
15471537 }
15481538
15491539 /*
drivers/scsi/scsi_error.c+1−32
@@ -26,7 +26,6 @@ · 25 unmodified lines
2626 #include <linux/blkdev.h>
2727 #include <linux/delay.h>
2828 #include <linux/jiffies.h>
29−#include <asm/unaligned.h>
3029
3130 #include <scsi/scsi.h>
3231 #include <scsi/scsi_cmnd.h>
@@ -944,7 +943,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses, · 911 unmodified lines
944943 scmd->sdb.length);
945944 scmd->sdb.table.sgl = &ses->sense_sgl;
946945 scmd->sc_data_direction = DMA_FROM_DEVICE;
947− scmd->sdb.table.nents = 1;
946+ scmd->sdb.table.nents = scmd->sdb.table.orig_nents = 1;
948947 scmd->cmnd[0] = REQUEST_SENSE;
949948 scmd->cmnd[4] = scmd->sdb.length;
950949 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
@@ -2523,33 +2522,3 @@ void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq) · 1572 unmodified lines
25232522 }
25242523 }
25252524 EXPORT_SYMBOL(scsi_build_sense_buffer);
2526−
2527−/**
2528− * scsi_set_sense_information - set the information field in a
2529− * formatted sense data buffer
2530− * @buf: Where to build sense data
2531− * @info: 64-bit information value to be set
2532− *
2533− **/
2534−void scsi_set_sense_information(u8 *buf, u64 info)
2535−{
2536− if ((buf[0] & 0x7f) == 0x72) {
2537− u8 *ucp, len;
2538−
2539− len = buf[7];
2540− ucp = (char *)scsi_sense_desc_find(buf, len + 8, 0);
2541− if (!ucp) {
2542− buf[7] = len + 0xa;
2543− ucp = buf + 8 + len;
2544− }
2545− ucp[0] = 0;
2546− ucp[1] = 0xa;
2547− ucp[2] = 0x80; /* Valid bit */
2548− ucp[3] = 0;
2549− put_unaligned_be64(info, &ucp[4]);
2550− } else if ((buf[0] & 0x7f) == 0x70) {
2551− buf[0] |= 0x80;
2552− put_unaligned_be64(info, &buf[3]);
2553− }
2554−}
2555−EXPORT_SYMBOL(scsi_set_sense_information);
drivers/scsi/scsi_lib.c+3−3
@@ -583,7 +583,7 @@ static struct scatterlist *scsi_sg_alloc(unsigned int nents, gfp_t gfp_mask) · 582 unmodified lines
583583
584584 static void scsi_free_sgtable(struct scsi_data_buffer *sdb, bool mq)
585585 {
586− if (mq && sdb->table.nents <= SCSI_MAX_SG_SEGMENTS)
586+ if (mq && sdb->table.orig_nents <= SCSI_MAX_SG_SEGMENTS)
587587 return;
588588 __sg_free_table(&sdb->table, SCSI_MAX_SG_SEGMENTS, mq, scsi_sg_free);
589589 }
@@ -597,8 +597,8 @@ static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, bool mq) · 7 unmodified lines
597597
598598 if (mq) {
599599 if (nents <= SCSI_MAX_SG_SEGMENTS) {
600− sdb->table.nents = nents;
601− sg_init_table(sdb->table.sgl, sdb->table.nents);
600+ sdb->table.nents = sdb->table.orig_nents = nents;
601+ sg_init_table(sdb->table.sgl, nents);
602602 return 0;
603603 }
604604 first_chunk = sdb->table.sgl;
drivers/scsi/sd.c+3−3
@@ -2770,9 +2770,9 @@ static int sd_revalidate_disk(struct gendisk *disk) · 2769 unmodified lines
27702770 max_xfer = sdkp->max_xfer_blocks;
27712771 max_xfer <<= ilog2(sdp->sector_size) - 9;
27722772
2773− max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue),
2774− max_xfer);
2775− blk_queue_max_hw_sectors(sdkp->disk->queue, max_xfer);
2773+ sdkp->disk->queue->limits.max_sectors =
2774+ min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), max_xfer);
2775+
27762776 set_capacity(disk, sdkp->capacity);
27772777 sd_config_write_same(sdkp);
27782778 kfree(buffer);
drivers/staging/comedi/drivers/das1800.c+1−0
@@ -1266,6 +1266,7 @@ static const struct das1800_board *das1800_probe(struct comedi_device *dev) · 1265 unmodified lines
12661266 if (index == das1801hc || index == das1802hc)
12671267 return board;
12681268 index = das1801hc;
1269+ break;
12691270 default:
12701271 dev_err(dev->class_dev,
12711272 "Board model: probe returned 0x%x (unknown, please report)\n",
drivers/staging/lustre/lustre/obdclass/debug.c+1−1
@@ -40,7 +40,7 @@ · 39 unmodified lines
4040
4141 #define DEBUG_SUBSYSTEM D_OTHER
4242
43−#include <linux/unaligned/access_ok.h>
43+#include <asm/unaligned.h>
4444
4545 #include "../include/obd_support.h"
4646 #include "../include/lustre_debug.h"
drivers/staging/vt6655/device_main.c+3−2
@@ -1483,8 +1483,9 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw, · 1482 unmodified lines
14831483 }
14841484 }
14851485
1486− if (changed & BSS_CHANGED_ASSOC && priv->op_mode != NL80211_IFTYPE_AP) {
1487− if (conf->assoc) {
1486+ if (changed & (BSS_CHANGED_ASSOC | BSS_CHANGED_BEACON_INFO) &&
1487+ priv->op_mode != NL80211_IFTYPE_AP) {
1488+ if (conf->assoc && conf->beacon_rate) {
14881489 CARDbUpdateTSF(priv, conf->beacon_rate->hw_value,
14891490 conf->sync_tsf);
14901491
drivers/target/iscsi/iscsi_target.c+39−9
@@ -3998,7 +3998,13 @@ get_immediate: · 3997 unmodified lines
39983998 }
39993999
40004000 transport_err:
4001− iscsit_take_action_for_connection_exit(conn);
4001+ /*
4002+ * Avoid the normal connection failure code-path if this connection
4003+ * is still within LOGIN mode, and iscsi_np process context is
4004+ * responsible for cleaning up the early connection failure.
4005+ */
4006+ if (conn->conn_state != TARG_CONN_STATE_IN_LOGIN)
4007+ iscsit_take_action_for_connection_exit(conn);
40024008 out:
40034009 return 0;
40044010 }
@@ -4082,7 +4088,7 @@ reject: · 77 unmodified lines
40824088
40834089 int iscsi_target_rx_thread(void *arg)
40844090 {
4085− int ret;
4091+ int ret, rc;
40864092 u8 buffer[ISCSI_HDR_LEN], opcode;
40874093 u32 checksum = 0, digest = 0;
40884094 struct iscsi_conn *conn = arg;
@@ -4092,10 +4098,16 @@ int iscsi_target_rx_thread(void *arg) · 3 unmodified lines
40924098 * connection recovery / failure event can be triggered externally.
40934099 */
40944100 allow_signal(SIGINT);
4101+ /*
4102+ * Wait for iscsi_post_login_handler() to complete before allowing
4103+ * incoming iscsi/tcp socket I/O, and/or failing the connection.
4104+ */
4105+ rc = wait_for_completion_interruptible(&conn->rx_login_comp);
4106+ if (rc < 0)
4107+ return 0;
40954108
40964109 if (conn->conn_transport->transport_type == ISCSI_INFINIBAND) {
40974110 struct completion comp;
4098− int rc;
40994111
41004112 init_completion(&comp);
41014113 rc = wait_for_completion_interruptible(&comp);
@@ -4532,7 +4544,18 @@ static void iscsit_logout_post_handler_closesession( · 430 unmodified lines
45324544 struct iscsi_conn *conn)
45334545 {
45344546 struct iscsi_session *sess = conn->sess;
4535− int sleep = cmpxchg(&conn->tx_thread_active, true, false);
4547+ int sleep = 1;
4548+ /*
4549+ * Traditional iscsi/tcp will invoke this logic from TX thread
4550+ * context during session logout, so clear tx_thread_active and
4551+ * sleep if iscsit_close_connection() has not already occured.
4552+ *
4553+ * Since iser-target invokes this logic from it's own workqueue,
4554+ * always sleep waiting for RX/TX thread shutdown to complete
4555+ * within iscsit_close_connection().
4556+ */
4557+ if (conn->conn_transport->transport_type == ISCSI_TCP)
4558+ sleep = cmpxchg(&conn->tx_thread_active, true, false);
45364559
45374560 atomic_set(&conn->conn_logout_remove, 0);
45384561 complete(&conn->conn_logout_comp);
@@ -4546,7 +4569,10 @@ static void iscsit_logout_post_handler_closesession( · 7 unmodified lines
45464569 static void iscsit_logout_post_handler_samecid(
45474570 struct iscsi_conn *conn)
45484571 {
4549− int sleep = cmpxchg(&conn->tx_thread_active, true, false);
4572+ int sleep = 1;
4573+
4574+ if (conn->conn_transport->transport_type == ISCSI_TCP)
4575+ sleep = cmpxchg(&conn->tx_thread_active, true, false);
45504576
45514577 atomic_set(&conn->conn_logout_remove, 0);
45524578 complete(&conn->conn_logout_comp);
@@ -4765,6 +4791,7 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force) · 212 unmodified lines
47654791 struct iscsi_session *sess;
47664792 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
47674793 struct se_session *se_sess, *se_sess_tmp;
4794+ LIST_HEAD(free_list);
47684795 int session_count = 0;
47694796
47704797 spin_lock_bh(&se_tpg->session_lock);
@@ -4786,14 +4813,17 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force) · 15 unmodified lines
47864813 }
47874814 atomic_set(&sess->session_reinstatement, 1);
47884815 spin_unlock(&sess->conn_lock);
4789− spin_unlock_bh(&se_tpg->session_lock);
47904816
4791− iscsit_free_session(sess);
4792− spin_lock_bh(&se_tpg->session_lock);
4817+ list_move_tail(&se_sess->sess_list, &free_list);
4818+ }
4819+ spin_unlock_bh(&se_tpg->session_lock);
4820+
4821+ list_for_each_entry_safe(se_sess, se_sess_tmp, &free_list, sess_list) {
4822+ sess = (struct iscsi_session *)se_sess->fabric_sess_ptr;
47934823
4824+ iscsit_free_session(sess);
47944825 session_count++;
47954826 }
4796− spin_unlock_bh(&se_tpg->session_lock);
47974827
47984828 pr_debug("Released %d iSCSI Session(s) from Target Portal"
47994829 " Group: %hu\n", session_count, tpg->tpgt);
drivers/target/iscsi/iscsi_target_login.c+17−28
@@ -82,6 +82,7 @@ static struct iscsi_login *iscsi_login_init_conn(struct iscsi_conn *conn) · 81 unmodified lines
8282 init_completion(&conn->conn_logout_comp);
8383 init_completion(&conn->rx_half_close_comp);
8484 init_completion(&conn->tx_half_close_comp);
85+ init_completion(&conn->rx_login_comp);
8586 spin_lock_init(&conn->cmd_lock);
8687 spin_lock_init(&conn->conn_usage_lock);
8788 spin_lock_init(&conn->immed_queue_lock);
@@ -644,7 +645,7 @@ static void iscsi_post_login_start_timers(struct iscsi_conn *conn) · 556 unmodified lines
644645 iscsit_start_nopin_timer(conn);
645646 }
646647
647−static int iscsit_start_kthreads(struct iscsi_conn *conn)
648+int iscsit_start_kthreads(struct iscsi_conn *conn)
648649 {
649650 int ret = 0;
650651
@@ -679,6 +680,7 @@ static int iscsit_start_kthreads(struct iscsi_conn *conn) · 28 unmodified lines
679680
680681 return 0;
681682 out_tx:
683+ send_sig(SIGINT, conn->tx_thread, 1);
682684 kthread_stop(conn->tx_thread);
683685 conn->tx_thread_active = false;
684686 out_bitmap:
@@ -689,7 +691,7 @@ out_bitmap: · 4 unmodified lines
689691 return ret;
690692 }
691693
692−int iscsi_post_login_handler(
694+void iscsi_post_login_handler(
693695 struct iscsi_np *np,
694696 struct iscsi_conn *conn,
695697 u8 zero_tsih)
@@ -699,7 +701,6 @@ int iscsi_post_login_handler( · 3 unmodified lines
699701 struct se_session *se_sess = sess->se_sess;
700702 struct iscsi_portal_group *tpg = sess->tpg;
701703 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
702− int rc;
703704
704705 iscsit_inc_conn_usage_count(conn);
705706
@@ -739,10 +740,6 @@ int iscsi_post_login_handler( · 33 unmodified lines
739740 sess->sess_ops->InitiatorName);
740741 spin_unlock_bh(&sess->conn_lock);
741742
742− rc = iscsit_start_kthreads(conn);
743− if (rc)
744− return rc;
745−
746743 iscsi_post_login_start_timers(conn);
747744 /*
748745 * Determine CPU mask to ensure connection's RX and TX kthreads
@@ -751,15 +748,20 @@ int iscsi_post_login_handler( · 2 unmodified lines
751748 iscsit_thread_get_cpumask(conn);
752749 conn->conn_rx_reset_cpumask = 1;
753750 conn->conn_tx_reset_cpumask = 1;
754−
751+ /*
752+ * Wakeup the sleeping iscsi_target_rx_thread() now that
753+ * iscsi_conn is in TARG_CONN_STATE_LOGGED_IN state.
754+ */
755+ complete(&conn->rx_login_comp);
755756 iscsit_dec_conn_usage_count(conn);
757+
756758 if (stop_timer) {
757759 spin_lock_bh(&se_tpg->session_lock);
758760 iscsit_stop_time2retain_timer(sess);
759761 spin_unlock_bh(&se_tpg->session_lock);
760762 }
761763 iscsit_dec_session_usage_count(sess);
762− return 0;
764+ return;
763765 }
764766
765767 iscsi_set_session_parameters(sess->sess_ops, conn->param_list, 1);
@@ -800,10 +802,6 @@ int iscsi_post_login_handler( · 34 unmodified lines
800802 " iSCSI Target Portal Group: %hu\n", tpg->nsessions, tpg->tpgt);
801803 spin_unlock_bh(&se_tpg->session_lock);
802804
803− rc = iscsit_start_kthreads(conn);
804− if (rc)
805− return rc;
806−
807805 iscsi_post_login_start_timers(conn);
808806 /*
809807 * Determine CPU mask to ensure connection's RX and TX kthreads
@@ -812,10 +810,12 @@ int iscsi_post_login_handler( · 2 unmodified lines
812810 iscsit_thread_get_cpumask(conn);
813811 conn->conn_rx_reset_cpumask = 1;
814812 conn->conn_tx_reset_cpumask = 1;
815−
813+ /*
814+ * Wakeup the sleeping iscsi_target_rx_thread() now that
815+ * iscsi_conn is in TARG_CONN_STATE_LOGGED_IN state.
816+ */
817+ complete(&conn->rx_login_comp);
816818 iscsit_dec_conn_usage_count(conn);
817−
818− return 0;
819819 }
820820
821821 static void iscsi_handle_login_thread_timeout(unsigned long data)
@@ -1380,23 +1380,12 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) · 558 unmodified lines
13801380 if (ret < 0)
13811381 goto new_sess_out;
13821382
1383− if (!conn->sess) {
1384− pr_err("struct iscsi_conn session pointer is NULL!\n");
1385− goto new_sess_out;
1386− }
1387−
13881383 iscsi_stop_login_thread_timer(np);
13891384
1390− if (signal_pending(current))
1391− goto new_sess_out;
1392−
13931385 if (ret == 1) {
13941386 tpg_np = conn->tpg_np;
13951387
1396− ret = iscsi_post_login_handler(np, conn, zero_tsih);
1397− if (ret < 0)
1398− goto new_sess_out;
1399−
1388+ iscsi_post_login_handler(np, conn, zero_tsih);
14001389 iscsit_deaccess_np(np, tpg, tpg_np);
14011390 }
14021391
drivers/target/iscsi/iscsi_target_login.h+2−1
@@ -12,7 +12,8 @@ extern int iscsit_accept_np(struct iscsi_np *, struct iscsi_conn *); · 11 unmodified lines
1212 extern int iscsit_get_login_rx(struct iscsi_conn *, struct iscsi_login *);
1313 extern int iscsit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32);
1414 extern void iscsit_free_conn(struct iscsi_np *, struct iscsi_conn *);
15−extern int iscsi_post_login_handler(struct iscsi_np *, struct iscsi_conn *, u8);
15+extern int iscsit_start_kthreads(struct iscsi_conn *);
16+extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsi_conn *, u8);
1617 extern void iscsi_target_login_sess_out(struct iscsi_conn *, struct iscsi_np *,
1718 bool, bool);
1819 extern int iscsi_target_login_thread(void *);
drivers/target/iscsi/iscsi_target_nego.c+33−1
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717 ******************************************************************************/
1818
1919 #include <linux/ctype.h>
20+#include <linux/kthread.h>
2021 #include <scsi/iscsi_proto.h>
2122 #include <target/target_core_base.h>
2223 #include <target/target_core_fabric.h>
@@ -361,10 +362,24 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log · 338 unmodified lines
361362 ntohl(login_rsp->statsn), login->rsp_length);
362363
363364 padding = ((-login->rsp_length) & 3);
365+ /*
366+ * Before sending the last login response containing the transition
367+ * bit for full-feature-phase, go ahead and start up TX/RX threads
368+ * now to avoid potential resource allocation failures after the
369+ * final login response has been sent.
370+ */
371+ if (login->login_complete) {
372+ int rc = iscsit_start_kthreads(conn);
373+ if (rc) {
374+ iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
375+ ISCSI_LOGIN_STATUS_NO_RESOURCES);
376+ return -1;
377+ }
378+ }
364379
365380 if (conn->conn_transport->iscsit_put_login_tx(conn, login,
366381 login->rsp_length + padding) < 0)
367− return -1;
382+ goto err;
368383
369384 login->rsp_length = 0;
370385 mutex_lock(&sess->cmdsn_mutex);
@@ -373,6 +388,23 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log · 2 unmodified lines
373388 mutex_unlock(&sess->cmdsn_mutex);
374389
375390 return 0;
391+
392+err:
393+ if (login->login_complete) {
394+ if (conn->rx_thread && conn->rx_thread_active) {
395+ send_sig(SIGINT, conn->rx_thread, 1);
396+ kthread_stop(conn->rx_thread);
397+ }
398+ if (conn->tx_thread && conn->tx_thread_active) {
399+ send_sig(SIGINT, conn->tx_thread, 1);
400+ kthread_stop(conn->tx_thread);
401+ }
402+ spin_lock(&iscsit_global->ts_bitmap_lock);
403+ bitmap_release_region(iscsit_global->ts_bitmap, conn->bitmap_id,
404+ get_order(1));
405+ spin_unlock(&iscsit_global->ts_bitmap_lock);
406+ }
407+ return -1;
376408 }
377409
378410 static void iscsi_target_sk_data_ready(struct sock *sk)
drivers/target/target_core_configfs.c+28−12
@@ -747,7 +747,7 @@ static ssize_t store_pi_prot_type(struct se_dev_attrib *da, · 746 unmodified lines
747747 if (!dev->transport->init_prot || !dev->transport->free_prot) {
748748 /* 0 is only allowed value for non-supporting backends */
749749 if (flag == 0)
750− return 0;
750+ return count;
751751
752752 pr_err("DIF protection not supported by backend: %s\n",
753753 dev->transport->name);
@@ -1590,9 +1590,9 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata( · 836 unmodified lines
15901590 u8 type = 0;
15911591
15921592 if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
1593− return 0;
1593+ return count;
15941594 if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS)
1595− return 0;
1595+ return count;
15961596
15971597 if (dev->export_count) {
15981598 pr_debug("Unable to process APTPL metadata while"
@@ -1658,22 +1658,32 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata( · 59 unmodified lines
16581658 * PR APTPL Metadata for Reservation
16591659 */
16601660 case Opt_res_holder:
1661− match_int(args, &arg);
1661+ ret = match_int(args, &arg);
1662+ if (ret)
1663+ goto out;
16621664 res_holder = arg;
16631665 break;
16641666 case Opt_res_type:
1665− match_int(args, &arg);
1667+ ret = match_int(args, &arg);
1668+ if (ret)
1669+ goto out;
16661670 type = (u8)arg;
16671671 break;
16681672 case Opt_res_scope:
1669− match_int(args, &arg);
1673+ ret = match_int(args, &arg);
1674+ if (ret)
1675+ goto out;
16701676 break;
16711677 case Opt_res_all_tg_pt:
1672− match_int(args, &arg);
1678+ ret = match_int(args, &arg);
1679+ if (ret)
1680+ goto out;
16731681 all_tg_pt = (int)arg;
16741682 break;
16751683 case Opt_mapped_lun:
1676− match_int(args, &arg);
1684+ ret = match_int(args, &arg);
1685+ if (ret)
1686+ goto out;
16771687 mapped_lun = (u64)arg;
16781688 break;
16791689 /*
@@ -1701,14 +1711,20 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata( · 21 unmodified lines
17011711 }
17021712 break;
17031713 case Opt_tpgt:
1704− match_int(args, &arg);
1714+ ret = match_int(args, &arg);
1715+ if (ret)
1716+ goto out;
17051717 tpgt = (u16)arg;
17061718 break;
17071719 case Opt_port_rtpi:
1708− match_int(args, &arg);
1720+ ret = match_int(args, &arg);
1721+ if (ret)
1722+ goto out;
17091723 break;
17101724 case Opt_target_lun:
1711− match_int(args, &arg);
1725+ ret = match_int(args, &arg);
1726+ if (ret)
1727+ goto out;
17121728 target_lun = (u64)arg;
17131729 break;
17141730 default:
@@ -1985,7 +2001,7 @@ static ssize_t target_core_store_alua_lu_gp( · 270 unmodified lines
19852001
19862002 lu_gp_mem = dev->dev_alua_lu_gp_mem;
19872003 if (!lu_gp_mem)
1988− return 0;
2004+ return count;
19892005
19902006 if (count > LU_GROUP_NAME_BUF) {
19912007 pr_err("ALUA LU Group Alias too large!\n");
drivers/target/target_core_pr.c+1−1
@@ -1474,7 +1474,7 @@ core_scsi3_decode_spec_i_port( · 1473 unmodified lines
14741474 LIST_HEAD(tid_dest_list);
14751475 struct pr_transport_id_holder *tidh_new, *tidh, *tidh_tmp;
14761476 unsigned char *buf, *ptr, proto_ident;
1477− const unsigned char *i_str;
1477+ const unsigned char *i_str = NULL;
14781478 char *iport_ptr = NULL, i_buf[PR_REG_ISID_ID_LEN];
14791479 sense_reason_t ret;
14801480 u32 tpdl, tid_len = 0;
drivers/target/target_core_rd.c+1−0
@@ -333,6 +333,7 @@ static int rd_configure_device(struct se_device *dev) · 332 unmodified lines
333333 dev->dev_attrib.hw_block_size = RD_BLOCKSIZE;
334334 dev->dev_attrib.hw_max_sectors = UINT_MAX;
335335 dev->dev_attrib.hw_queue_depth = RD_MAX_DEVICE_QUEUE_DEPTH;
336+ dev->dev_attrib.is_nonrot = 1;
336337
337338 rd_dev->rd_dev_id = rd_host->rd_host_dev_id_count++;
338339
drivers/target/target_core_spc.c+8−1
@@ -454,10 +454,17 @@ spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) · 453 unmodified lines
454454 cmd->se_sess->sess_prot_type == TARGET_DIF_TYPE1_PROT)
455455 buf[4] = 0x5;
456456 else if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE3_PROT ||
457− cmd->se_sess->sess_prot_type == TARGET_DIF_TYPE3_PROT)
457+ cmd->se_sess->sess_prot_type == TARGET_DIF_TYPE3_PROT)
458458 buf[4] = 0x4;
459459 }
460460
461+ /* logical unit supports type 1 and type 3 protection */
462+ if ((dev->transport->get_device_type(dev) == TYPE_DISK) &&
463+ (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) &&
464+ (dev->dev_attrib.pi_prot_type || cmd->se_sess->sess_prot_type)) {
465+ buf[4] |= (0x3 << 3);
466+ }
467+
461468 /* Set HEADSUP, ORDSUP, SIMPSUP */
462469 buf[5] = 0x07;
463470
drivers/thermal/hisi_thermal.c+0−1
@@ -405,7 +405,6 @@ static SIMPLE_DEV_PM_OPS(hisi_thermal_pm_ops, · 404 unmodified lines
405405 static struct platform_driver hisi_thermal_driver = {
406406 .driver = {
407407 .name = "hisi_thermal",
408− .owner = THIS_MODULE,
409408 .pm = &hisi_thermal_pm_ops,
410409 .of_match_table = of_hisi_thermal_match,
411410 },
drivers/thermal/power_allocator.c+16−10
@@ -229,7 +229,8 @@ static int allocate_power(struct thermal_zone_device *tz, · 228 unmodified lines
229229 struct thermal_instance *instance;
230230 struct power_allocator_params *params = tz->governor_data;
231231 u32 *req_power, *max_power, *granted_power, *extra_actor_power;
232− u32 total_req_power, max_allocatable_power;
232+ u32 *weighted_req_power;
233+ u32 total_req_power, max_allocatable_power, total_weighted_req_power;
233234 u32 total_granted_power, power_range;
234235 int i, num_actors, total_weight, ret = 0;
235236 int trip_max_desired_temperature = params->trip_max_desired_temperature;
@@ -247,16 +248,17 @@ static int allocate_power(struct thermal_zone_device *tz, · 11 unmodified lines
247248 }
248249
249250 /*
250− * We need to allocate three arrays of the same size:
251− * req_power, max_power and granted_power. They are going to
252− * be needed until this function returns. Allocate them all
253− * in one go to simplify the allocation and deallocation
254− * logic.
251+ * We need to allocate five arrays of the same size:
252+ * req_power, max_power, granted_power, extra_actor_power and
253+ * weighted_req_power. They are going to be needed until this
254+ * function returns. Allocate them all in one go to simplify
255+ * the allocation and deallocation logic.
255256 */
256257 BUILD_BUG_ON(sizeof(*req_power) != sizeof(*max_power));
257258 BUILD_BUG_ON(sizeof(*req_power) != sizeof(*granted_power));
258259 BUILD_BUG_ON(sizeof(*req_power) != sizeof(*extra_actor_power));
259− req_power = devm_kcalloc(&tz->device, num_actors * 4,
260+ BUILD_BUG_ON(sizeof(*req_power) != sizeof(*weighted_req_power));
261+ req_power = devm_kcalloc(&tz->device, num_actors * 5,
260262 sizeof(*req_power), GFP_KERNEL);
261263 if (!req_power) {
262264 ret = -ENOMEM;
@@ -266,8 +268,10 @@ static int allocate_power(struct thermal_zone_device *tz, · 3 unmodified lines
266268 max_power = &req_power[num_actors];
267269 granted_power = &req_power[2 * num_actors];
268270 extra_actor_power = &req_power[3 * num_actors];
271+ weighted_req_power = &req_power[4 * num_actors];
269272
270273 i = 0;
274+ total_weighted_req_power = 0;
271275 total_req_power = 0;
272276 max_allocatable_power = 0;
273277
@@ -289,13 +293,14 @@ static int allocate_power(struct thermal_zone_device *tz, · 15 unmodified lines
289293 else
290294 weight = instance->weight;
291295
292− req_power[i] = frac_to_int(weight * req_power[i]);
296+ weighted_req_power[i] = frac_to_int(weight * req_power[i]);
293297
294298 if (power_actor_get_max_power(cdev, tz, &max_power[i]))
295299 continue;
296300
297301 total_req_power += req_power[i];
298302 max_allocatable_power += max_power[i];
303+ total_weighted_req_power += weighted_req_power[i];
299304
300305 i++;
301306 }
@@ -303,8 +308,9 @@ static int allocate_power(struct thermal_zone_device *tz, · 1 unmodified line
303308 power_range = pid_controller(tz, current_temp, control_temp,
304309 max_allocatable_power);
305310
306− divvy_up_power(req_power, max_power, num_actors, total_req_power,
307− power_range, granted_power, extra_actor_power);
311+ divvy_up_power(weighted_req_power, max_power, num_actors,
312+ total_weighted_req_power, power_range, granted_power,
313+ extra_actor_power);
308314
309315 total_granted_power = 0;
310316 i = 0;
drivers/thermal/samsung/Kconfig+1−1
@@ -1,6 +1,6 @@
11 config EXYNOS_THERMAL
22 tristate "Exynos thermal management unit driver"
3− depends on OF
3+ depends on THERMAL_OF
44 help
55 If you say yes here you get support for the TMU (Thermal Management
66 Unit) driver for SAMSUNG EXYNOS series of SoCs. This driver initialises
drivers/thermal/samsung/exynos_tmu.c+2−3
@@ -1296,7 +1296,6 @@ static struct thermal_zone_of_device_ops exynos_sensor_ops = { · 1295 unmodified lines
12961296
12971297 static int exynos_tmu_probe(struct platform_device *pdev)
12981298 {
1299− struct exynos_tmu_platform_data *pdata;
13001299 struct exynos_tmu_data *data;
13011300 int ret;
13021301
@@ -1318,8 +1317,6 @@ static int exynos_tmu_probe(struct platform_device *pdev) · 15 unmodified lines
13181317 if (ret)
13191318 goto err_sensor;
13201319
1321− pdata = data->pdata;
1322−
13231320 INIT_WORK(&data->irq_work, exynos_tmu_work);
13241321
13251322 data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
@@ -1392,6 +1389,8 @@ err_clk_sec: · 66 unmodified lines
13921389 if (!IS_ERR(data->clk_sec))
13931390 clk_unprepare(data->clk_sec);
13941391 err_sensor:
1392+ if (!IS_ERR_OR_NULL(data->regulator))
1393+ regulator_disable(data->regulator);
13951394 thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
13961395
13971396 return ret;
drivers/thermal/thermal_core.c+1−0
@@ -1333,6 +1333,7 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, · 1332 unmodified lines
13331333 return -ENODEV;
13341334
13351335 unbind:
1336+ device_remove_file(&tz->device, &pos->weight_attr);
13361337 device_remove_file(&tz->device, &pos->attr);
13371338 sysfs_remove_link(&tz->device.kobj, pos->name);
13381339 release_idr(&tz->idr, &tz->lock, pos->id);
drivers/usb/chipidea/core.c+12−1
@@ -1024,7 +1024,18 @@ static struct platform_driver ci_hdrc_driver = { · 1023 unmodified lines
10241024 },
10251025 };
10261026
1027−module_platform_driver(ci_hdrc_driver);
1027+static int __init ci_hdrc_platform_register(void)
1028+{
1029+ ci_hdrc_host_driver_init();
1030+ return platform_driver_register(&ci_hdrc_driver);
1031+}
1032+module_init(ci_hdrc_platform_register);
1033+
1034+static void __exit ci_hdrc_platform_unregister(void)
1035+{
1036+ platform_driver_unregister(&ci_hdrc_driver);
1037+}
1038+module_exit(ci_hdrc_platform_unregister);
10281039
10291040 MODULE_ALIAS("platform:ci_hdrc");
10301041 MODULE_LICENSE("GPL v2");
drivers/usb/chipidea/host.c+5−2
@@ -249,9 +249,12 @@ int ci_hdrc_host_init(struct ci_hdrc *ci) · 248 unmodified lines
249249 rdrv->name = "host";
250250 ci->roles[CI_ROLE_HOST] = rdrv;
251251
252+ return 0;
253+}
254+
255+void ci_hdrc_host_driver_init(void)
256+{
252257 ehci_init_driver(&ci_ehci_hc_driver, &ehci_ci_overrides);
253258 orig_bus_suspend = ci_ehci_hc_driver.bus_suspend;
254259 ci_ehci_hc_driver.bus_suspend = ci_ehci_bus_suspend;
255−
256− return 0;
257260 }
drivers/usb/chipidea/host.h+6−0
@@ -5,6 +5,7 @@ · 4 unmodified lines
55
66 int ci_hdrc_host_init(struct ci_hdrc *ci);
77 void ci_hdrc_host_destroy(struct ci_hdrc *ci);
8+void ci_hdrc_host_driver_init(void);
89
910 #else
1011
@@ -18,6 +19,11 @@ static inline void ci_hdrc_host_destroy(struct ci_hdrc *ci) · 7 unmodified lines
1819
1920 }
2021
22+static void ci_hdrc_host_driver_init(void)
23+{
24+
25+}
26+
2127 #endif
2228
2329 #endif /* __DRIVERS_USB_CHIPIDEA_HOST_H */
drivers/usb/gadget/function/f_hid.c+4−0
@@ -699,6 +699,10 @@ static inline int hidg_get_minor(void) · 698 unmodified lines
699699 int ret;
700700
701701 ret = ida_simple_get(&hidg_ida, 0, 0, GFP_KERNEL);
702+ if (ret >= HIDG_MINORS) {
703+ ida_simple_remove(&hidg_ida, ret);
704+ ret = -ENODEV;
705+ }
702706
703707 return ret;
704708 }
drivers/usb/gadget/function/f_printer.c+9−1
@@ -1248,7 +1248,15 @@ static struct config_item_type printer_func_type = { · 1247 unmodified lines
12481248
12491249 static inline int gprinter_get_minor(void)
12501250 {
1251− return ida_simple_get(&printer_ida, 0, 0, GFP_KERNEL);
1251+ int ret;
1252+
1253+ ret = ida_simple_get(&printer_ida, 0, 0, GFP_KERNEL);
1254+ if (ret >= PRINTER_MINORS) {
1255+ ida_simple_remove(&printer_ida, ret);
1256+ ret = -ENODEV;
1257+ }
1258+
1259+ return ret;
12521260 }
12531261
12541262 static inline void gprinter_put_minor(int minor)
drivers/usb/gadget/function/f_uac2.c+2−2
@@ -1162,14 +1162,14 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt) · 1161 unmodified lines
11621162 factor = 1000;
11631163 } else {
11641164 ep_desc = &hs_epin_desc;
1165− factor = 125;
1165+ factor = 8000;
11661166 }
11671167
11681168 /* pre-compute some values for iso_complete() */
11691169 uac2->p_framesize = opts->p_ssize *
11701170 num_channels(opts->p_chmask);
11711171 rate = opts->p_srate * uac2->p_framesize;
1172− uac2->p_interval = (1 << (ep_desc->bInterval - 1)) * factor;
1172+ uac2->p_interval = factor / (1 << (ep_desc->bInterval - 1));
11731173 uac2->p_pktsize = min_t(unsigned int, rate / uac2->p_interval,
11741174 prm->max_psize);
11751175
drivers/usb/gadget/udc/bdc/bdc_ep.c+1−1
@@ -779,7 +779,7 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req *req) · 778 unmodified lines
779779 /* The current hw dequeue pointer */
780780 tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(0));
781781 deq_ptr_64 = tmp_32;
782− tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(1));
782+ tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS1(0));
783783 deq_ptr_64 |= ((u64)tmp_32 << 32);
784784
785785 /* we have the dma addr of next bd that will be fetched by hardware */
drivers/usb/gadget/udc/udc-core.c+1−0
@@ -323,6 +323,7 @@ err4: · 322 unmodified lines
323323
324324 err3:
325325 put_device(&udc->dev);
326+ device_del(&gadget->dev);
326327
327328 err2:
328329 put_device(&gadget->dev);
drivers/usb/host/xhci-mem.c+2−1
@@ -1792,7 +1792,8 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) · 1791 unmodified lines
17921792 int size;
17931793 int i, j, num_ports;
17941794
1795− del_timer_sync(&xhci->cmd_timer);
1795+ if (timer_pending(&xhci->cmd_timer))
1796+ del_timer_sync(&xhci->cmd_timer);
17961797
17971798 /* Free the Event Ring Segment Table and the actual Event Ring */
17981799 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
drivers/usb/host/xhci-ring.c+1−1
@@ -82,7 +82,7 @@ dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg, · 81 unmodified lines
8282 return 0;
8383 /* offset in TRBs */
8484 segment_offset = trb - seg->trbs;
85− if (segment_offset > TRBS_PER_SEGMENT)
85+ if (segment_offset >= TRBS_PER_SEGMENT)
8686 return 0;
8787 return seg->dma + (segment_offset * sizeof(*trb));
8888 }
drivers/usb/serial/option.c+2−0
@@ -1099,6 +1099,8 @@ static const struct usb_device_id option_ids[] = { · 1098 unmodified lines
10991099 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
11001100 { USB_DEVICE_INTERFACE_CLASS(SIERRA_VENDOR_ID, 0x68c0, 0xff),
11011101 .driver_info = (kernel_ulong_t)&sierra_mc73xx_blacklist }, /* MC73xx */
1102+ { USB_DEVICE_INTERFACE_CLASS(SIERRA_VENDOR_ID, 0x9041, 0xff),
1103+ .driver_info = (kernel_ulong_t)&sierra_mc73xx_blacklist }, /* MC7305/MC7355 */
11021104 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
11031105 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
11041106 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
drivers/usb/serial/qcserial.c+1−1
@@ -145,7 +145,6 @@ static const struct usb_device_id id_table[] = { · 144 unmodified lines
145145 {DEVICE_SWI(0x1199, 0x901c)}, /* Sierra Wireless EM7700 */
146146 {DEVICE_SWI(0x1199, 0x901f)}, /* Sierra Wireless EM7355 */
147147 {DEVICE_SWI(0x1199, 0x9040)}, /* Sierra Wireless Modem */
148− {DEVICE_SWI(0x1199, 0x9041)}, /* Sierra Wireless MC7305/MC7355 */
149148 {DEVICE_SWI(0x1199, 0x9051)}, /* Netgear AirCard 340U */
150149 {DEVICE_SWI(0x1199, 0x9053)}, /* Sierra Wireless Modem */
151150 {DEVICE_SWI(0x1199, 0x9054)}, /* Sierra Wireless Modem */
@@ -158,6 +157,7 @@ static const struct usb_device_id id_table[] = { · 6 unmodified lines
158157 {DEVICE_SWI(0x413c, 0x81a4)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */
159158 {DEVICE_SWI(0x413c, 0x81a8)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */
160159 {DEVICE_SWI(0x413c, 0x81a9)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
160+ {DEVICE_SWI(0x413c, 0x81b1)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */
161161
162162 /* Huawei devices */
163163 {DEVICE_HWI(0x03f0, 0x581d)}, /* HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e) */
drivers/usb/serial/sierra.c+1−0
@@ -289,6 +289,7 @@ static const struct usb_device_id id_table[] = { · 288 unmodified lines
289289 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68AA, 0xFF, 0xFF, 0xFF),
290290 .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
291291 },
292+ { USB_DEVICE(0x1199, 0x68AB) }, /* Sierra Wireless AR8550 */
292293 /* AT&T Direct IP LTE modems */
293294 { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68AA, 0xFF, 0xFF, 0xFF),
294295 .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
drivers/vfio/vfio.c+54−37
@@ -689,6 +689,23 @@ struct vfio_device *vfio_device_get_from_dev(struct device *dev) · 688 unmodified lines
689689 }
690690 EXPORT_SYMBOL_GPL(vfio_device_get_from_dev);
691691
692+static struct vfio_device *vfio_device_get_from_name(struct vfio_group *group,
693+ char *buf)
694+{
695+ struct vfio_device *device;
696+
697+ mutex_lock(&group->device_lock);
698+ list_for_each_entry(device, &group->device_list, group_next) {
699+ if (!strcmp(dev_name(device->dev), buf)) {
700+ vfio_device_get(device);
701+ break;
702+ }
703+ }
704+ mutex_unlock(&group->device_lock);
705+
706+ return device;
707+}
708+
692709 /*
693710 * Caller must hold a reference to the vfio_device
694711 */
@@ -1198,53 +1215,53 @@ static int vfio_group_get_device_fd(struct vfio_group *group, char *buf) · 503 unmodified lines
11981215 {
11991216 struct vfio_device *device;
12001217 struct file *filep;
1201− int ret = -ENODEV;
1218+ int ret;
12021219
12031220 if (0 == atomic_read(&group->container_users) ||
12041221 !group->container->iommu_driver || !vfio_group_viable(group))
12051222 return -EINVAL;
12061223
1207− mutex_lock(&group->device_lock);
1208− list_for_each_entry(device, &group->device_list, group_next) {
1209− if (strcmp(dev_name(device->dev), buf))
1210− continue;
1224+ device = vfio_device_get_from_name(group, buf);
1225+ if (!device)
1226+ return -ENODEV;
12111227
1212− ret = device->ops->open(device->device_data);
1213− if (ret)
1214− break;
1215− /*
1216− * We can't use anon_inode_getfd() because we need to modify
1217− * the f_mode flags directly to allow more than just ioctls
1218− */
1219− ret = get_unused_fd_flags(O_CLOEXEC);
1220− if (ret < 0) {
1221− device->ops->release(device->device_data);
1222− break;
1223− }
1228+ ret = device->ops->open(device->device_data);
1229+ if (ret) {
1230+ vfio_device_put(device);
1231+ return ret;
1232+ }
12241233
1225− filep = anon_inode_getfile("[vfio-device]", &vfio_device_fops,
1226− device, O_RDWR);
1227− if (IS_ERR(filep)) {
1228− put_unused_fd(ret);
1229− ret = PTR_ERR(filep);
1230− device->ops->release(device->device_data);
1231− break;
1232− }
1234+ /*
1235+ * We can't use anon_inode_getfd() because we need to modify
1236+ * the f_mode flags directly to allow more than just ioctls
1237+ */
1238+ ret = get_unused_fd_flags(O_CLOEXEC);
1239+ if (ret < 0) {
1240+ device->ops->release(device->device_data);
1241+ vfio_device_put(device);
1242+ return ret;
1243+ }
12331244
1234− /*
1235− * TODO: add an anon_inode interface to do this.
1236− * Appears to be missing by lack of need rather than
1237− * explicitly prevented. Now there's need.
1238− */
1239− filep->f_mode |= (FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE);
1245+ filep = anon_inode_getfile("[vfio-device]", &vfio_device_fops,
1246+ device, O_RDWR);
1247+ if (IS_ERR(filep)) {
1248+ put_unused_fd(ret);
1249+ ret = PTR_ERR(filep);
1250+ device->ops->release(device->device_data);
1251+ vfio_device_put(device);
1252+ return ret;
1253+ }
1254+
1255+ /*
1256+ * TODO: add an anon_inode interface to do this.
1257+ * Appears to be missing by lack of need rather than
1258+ * explicitly prevented. Now there's need.
1259+ */
1260+ filep->f_mode |= (FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE);
12401261
1241− vfio_device_get(device);
1242− atomic_inc(&group->container_users);
1262+ atomic_inc(&group->container_users);
12431263
1244− fd_install(ret, filep);
1245− break;
1246− }
1247− mutex_unlock(&group->device_lock);
1264+ fd_install(ret, filep);
12481265
12491266 return ret;
12501267 }
drivers/vhost/vhost.c+2−4
@@ -683,11 +683,8 @@ static void *vhost_kvzalloc(unsigned long size) · 682 unmodified lines
683683 {
684684 void *n = kzalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
685685
686− if (!n) {
686+ if (!n)
687687 n = vzalloc(size);
688− if (!n)
689− return ERR_PTR(-ENOMEM);
690− }
691688 return n;
692689 }
693690
@@ -995,6 +992,7 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp) · 301 unmodified lines
995992 }
996993 if (eventfp != d->log_file) {
997994 filep = d->log_file;
995+ d->log_file = eventfp;
998996 ctx = d->log_ctx;
999997 d->log_ctx = eventfp ?
1000998 eventfd_ctx_fileget(eventfp) : NULL;
drivers/video/console/fbcon.c+2−1
@@ -1306,10 +1306,11 @@ static void fbcon_cursor(struct vc_data *vc, int mode) · 1305 unmodified lines
13061306 int y;
13071307 int c = scr_readw((u16 *) vc->vc_pos);
13081308
1309+ ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms);
1310+
13091311 if (fbcon_is_inactive(vc, info) || vc->vc_deccm != 1)
13101312 return;
13111313
1312− ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms);
13131314 if (vc->vc_cursor_type & 0x10)
13141315 fbcon_del_cursor_timer(info);
13151316 else
drivers/video/fbdev/Kconfig+1−1
@@ -298,7 +298,7 @@ config FB_ARMCLCD · 297 unmodified lines
298298
299299 # Helper logic selected only by the ARM Versatile platform family.
300300 config PLAT_VERSATILE_CLCD
301− def_bool ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS
301+ def_bool ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS || ARCH_INTEGRATOR
302302 depends on ARM
303303 depends on FB_ARMCLCD && FB=y
304304
drivers/video/fbdev/omap2/dss/dss-of.c+3−1
@@ -60,6 +60,8 @@ omapdss_of_get_next_port(const struct device_node *parent, · 59 unmodified lines
6060 }
6161 prev = port;
6262 } while (of_node_cmp(port->name, "port") != 0);
63+
64+ of_node_put(ports);
6365 }
6466
6567 return port;
@@ -94,7 +96,7 @@ struct device_node *dss_of_port_get_parent_device(struct device_node *port) · 28 unmodified lines
9496 if (!port)
9597 return NULL;
9698
97− np = of_get_next_parent(port);
99+ np = of_get_parent(port);
98100
99101 for (i = 0; i < 2 && np; ++i) {
100102 struct property *prop;
drivers/video/fbdev/pxa3xx-gcu.c+2−2
@@ -653,7 +653,7 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev) · 652 unmodified lines
653653 goto err_free_dma;
654654 }
655655
656− ret = clk_enable(priv->clk);
656+ ret = clk_prepare_enable(priv->clk);
657657 if (ret < 0) {
658658 dev_err(dev, "failed to enable clock\n");
659659 goto err_misc_deregister;
@@ -685,7 +685,7 @@ err_misc_deregister: · 25 unmodified lines
685685 misc_deregister(&priv->misc_dev);
686686
687687 err_disable_clk:
688− clk_disable(priv->clk);
688+ clk_disable_unprepare(priv->clk);
689689
690690 return ret;
691691 }
drivers/video/of_videomode.c+1−3
@@ -44,11 +44,9 @@ int of_get_videomode(struct device_node *np, struct videomode *vm, · 43 unmodified lines
4444 index = disp->native_mode;
4545
4646 ret = videomode_from_timings(disp, vm, index);
47− if (ret)
48− return ret;
4947
5048 display_timings_release(disp);
5149
52− return 0;
50+ return ret;
5351 }
5452 EXPORT_SYMBOL_GPL(of_get_videomode);
drivers/virtio/virtio_input.c+4−0
@@ -313,6 +313,7 @@ err_init_vq: · 312 unmodified lines
313313 static void virtinput_remove(struct virtio_device *vdev)
314314 {
315315 struct virtio_input *vi = vdev->priv;
316+ void *buf;
316317 unsigned long flags;
317318
318319 spin_lock_irqsave(&vi->lock, flags);
@@ -320,6 +321,9 @@ static void virtinput_remove(struct virtio_device *vdev) · 1 unmodified line
320321 spin_unlock_irqrestore(&vi->lock, flags);
321322
322323 input_unregister_device(vi->idev);
324+ vdev->config->reset(vdev);
325+ while ((buf = virtqueue_detach_unused_buf(vi->sts)) != NULL)
326+ kfree(buf);
323327 vdev->config->del_vqs(vdev);
324328 kfree(vi);
325329 }
drivers/xen/balloon.c+7−8
@@ -472,7 +472,7 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) · 471 unmodified lines
472472 }
473473
474474 /*
475− * We avoid multiple worker processes conflicting via the balloon mutex.
475+ * As this is a work item it is guaranteed to run as a single instance only.
476476 * We may of course race updates of the target counts (which are protected
477477 * by the balloon lock), or with changes to the Xen hard limit, but we will
478478 * recover from these in time.
@@ -482,9 +482,10 @@ static void balloon_process(struct work_struct *work) · 3 unmodified lines
482482 enum bp_state state = BP_DONE;
483483 long credit;
484484
485− mutex_lock(&balloon_mutex);
486485
487486 do {
487+ mutex_lock(&balloon_mutex);
488+
488489 credit = current_credit();
489490
490491 if (credit > 0) {
@@ -499,17 +500,15 @@ static void balloon_process(struct work_struct *work) · 8 unmodified lines
499500
500501 state = update_schedule(state);
501502
502−#ifndef CONFIG_PREEMPT
503− if (need_resched())
504− schedule();
505−#endif
503+ mutex_unlock(&balloon_mutex);
504+
505+ cond_resched();
506+
506507 } while (credit && state == BP_DONE);
507508
508509 /* Schedule more work if there is some still to be done. */
509510 if (state == BP_EAGAIN)
510511 schedule_delayed_work(&balloon_worker, balloon_stats.schedule_delay * HZ);
511−
512− mutex_unlock(&balloon_mutex);
513512 }
514513
515514 /* Resets the Xen limit, sets new target, and kicks off processing. */
drivers/xen/gntdev.c+2−0
@@ -568,12 +568,14 @@ static int gntdev_release(struct inode *inode, struct file *flip) · 567 unmodified lines
568568
569569 pr_debug("priv %p\n", priv);
570570
571+ mutex_lock(&priv->lock);
571572 while (!list_empty(&priv->maps)) {
572573 map = list_entry(priv->maps.next, struct grant_map, next);
573574 list_del(&map->next);
574575 gntdev_put_map(NULL /* already removed */, map);
575576 }
576577 WARN_ON(!list_empty(&priv->freeable_maps));
578+ mutex_unlock(&priv->lock);
577579
578580 if (use_ptemod)
579581 mmu_notifier_unregister(&priv->mn, priv->mm);
drivers/xen/xenbus/xenbus_client.c+3−1
@@ -814,8 +814,10 @@ static int xenbus_unmap_ring_vfree_hvm(struct xenbus_device *dev, void *vaddr) · 813 unmodified lines
814814
815815 rv = xenbus_unmap_ring(dev, node->handles, node->nr_handles,
816816 addrs);
817− if (!rv)
817+ if (!rv) {
818818 vunmap(vaddr);
819+ free_xenballooned_pages(node->nr_handles, node->hvm.pages);
820+ }
819821 else
820822 WARN(1, "Leaking %p, size %u page(s)\n", vaddr,
821823 node->nr_handles);
fs/btrfs/dev-replace.c+1−1
@@ -378,7 +378,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root, · 377 unmodified lines
378378
379379 ret = btrfs_kobj_add_device(tgt_device->fs_devices, tgt_device);
380380 if (ret)
381− btrfs_error(root->fs_info, ret, "kobj add dev failed");
381+ btrfs_err(root->fs_info, "kobj add dev failed %d\n", ret);
382382
383383 printk_in_rcu(KERN_INFO
384384 "BTRFS: dev_replace from %s (devid %llu) to %s started\n",
fs/btrfs/disk-io.c+2−1
@@ -2842,6 +2842,7 @@ int open_ctree(struct super_block *sb, · 2841 unmodified lines
28422842 !extent_buffer_uptodate(chunk_root->node)) {
28432843 printk(KERN_ERR "BTRFS: failed to read chunk root on %s\n",
28442844 sb->s_id);
2845+ chunk_root->node = NULL;
28452846 goto fail_tree_roots;
28462847 }
28472848 btrfs_set_root_node(&chunk_root->root_item, chunk_root->node);
@@ -2879,7 +2880,7 @@ retry_root_backup: · 31 unmodified lines
28792880 !extent_buffer_uptodate(tree_root->node)) {
28802881 printk(KERN_WARNING "BTRFS: failed to read tree root on %s\n",
28812882 sb->s_id);
2882−
2883+ tree_root->node = NULL;
28832884 goto recovery_tree_root;
28842885 }
28852886
fs/btrfs/extent-tree.c+18−0
@@ -4227,6 +4227,24 @@ out: · 4226 unmodified lines
42274227 space_info->chunk_alloc = 0;
42284228 spin_unlock(&space_info->lock);
42294229 mutex_unlock(&fs_info->chunk_mutex);
4230+ /*
4231+ * When we allocate a new chunk we reserve space in the chunk block
4232+ * reserve to make sure we can COW nodes/leafs in the chunk tree or
4233+ * add new nodes/leafs to it if we end up needing to do it when
4234+ * inserting the chunk item and updating device items as part of the
4235+ * second phase of chunk allocation, performed by
4236+ * btrfs_finish_chunk_alloc(). So make sure we don't accumulate a
4237+ * large number of new block groups to create in our transaction
4238+ * handle's new_bgs list to avoid exhausting the chunk block reserve
4239+ * in extreme cases - like having a single transaction create many new
4240+ * block groups when starting to write out the free space caches of all
4241+ * the block groups that were made dirty during the lifetime of the
4242+ * transaction.
4243+ */
4244+ if (trans->chunk_bytes_reserved >= (2 * 1024 * 1024ull)) {
4245+ btrfs_create_pending_block_groups(trans, trans->root);
4246+ btrfs_trans_release_chunk_metadata(trans);
4247+ }
42304248 return ret;
42314249 }
42324250
fs/btrfs/qgroup.c+5−0
@@ -1651,6 +1651,11 @@ static int qgroup_update_counters(struct btrfs_fs_info *fs_info, · 1650 unmodified lines
16511651 /* Exclusive -> exclusive, nothing changed */
16521652 }
16531653 }
1654+
1655+ /* For exclusive extent, free its reserved bytes too */
1656+ if (nr_old_roots == 0 && nr_new_roots == 1 &&
1657+ cur_new_count == nr_new_roots)
1658+ qg->reserved -= num_bytes;
16541659 if (dirty)
16551660 qgroup_dirty(fs_info, qg);
16561661 }
fs/btrfs/transaction.c+2−1
@@ -2152,7 +2152,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, · 2151 unmodified lines
21522152
21532153 kmem_cache_free(btrfs_trans_handle_cachep, trans);
21542154
2155− if (current != root->fs_info->transaction_kthread)
2155+ if (current != root->fs_info->transaction_kthread &&
2156+ current != root->fs_info->cleaner_kthread)
21562157 btrfs_run_delayed_iputs(root);
21572158
21582159 return ret;
fs/ceph/caps.c+5−17
@@ -1506,7 +1506,6 @@ static int __mark_caps_flushing(struct inode *inode, · 1505 unmodified lines
15061506
15071507 swap(cf, ci->i_prealloc_cap_flush);
15081508 cf->caps = flushing;
1509− cf->kick = false;
15101509
15111510 spin_lock(&mdsc->cap_dirty_lock);
15121511 list_del_init(&ci->i_dirty_item);
@@ -2123,8 +2122,7 @@ static void kick_flushing_capsnaps(struct ceph_mds_client *mdsc, · 610 unmodified lines
21232122
21242123 static int __kick_flushing_caps(struct ceph_mds_client *mdsc,
21252124 struct ceph_mds_session *session,
2126− struct ceph_inode_info *ci,
2127− bool kick_all)
2125+ struct ceph_inode_info *ci)
21282126 {
21292127 struct inode *inode = &ci->vfs_inode;
21302128 struct ceph_cap *cap;
@@ -2150,9 +2148,7 @@ static int __kick_flushing_caps(struct ceph_mds_client *mdsc, · 19 unmodified lines
21502148
21512149 for (n = rb_first(&ci->i_cap_flush_tree); n; n = rb_next(n)) {
21522150 cf = rb_entry(n, struct ceph_cap_flush, i_node);
2153− if (cf->tid < first_tid)
2154− continue;
2155− if (kick_all || cf->kick)
2151+ if (cf->tid >= first_tid)
21562152 break;
21572153 }
21582154 if (!n) {
@@ -2161,7 +2157,6 @@ static int __kick_flushing_caps(struct ceph_mds_client *mdsc, · 2 unmodified lines
21612157 }
21622158
21632159 cf = rb_entry(n, struct ceph_cap_flush, i_node);
2164− cf->kick = false;
21652160
21662161 first_tid = cf->tid + 1;
21672162
@@ -2181,8 +2176,6 @@ void ceph_early_kick_flushing_caps(struct ceph_mds_client *mdsc, · 13 unmodified lines
21812176 {
21822177 struct ceph_inode_info *ci;
21832178 struct ceph_cap *cap;
2184− struct ceph_cap_flush *cf;
2185− struct rb_node *n;
21862179
21872180 dout("early_kick_flushing_caps mds%d\n", session->s_mds);
21882181 list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) {
@@ -2205,16 +2198,11 @@ void ceph_early_kick_flushing_caps(struct ceph_mds_client *mdsc, · 16 unmodified lines
22052198 if ((cap->issued & ci->i_flushing_caps) !=
22062199 ci->i_flushing_caps) {
22072200 spin_unlock(&ci->i_ceph_lock);
2208− if (!__kick_flushing_caps(mdsc, session, ci, true))
2201+ if (!__kick_flushing_caps(mdsc, session, ci))
22092202 continue;
22102203 spin_lock(&ci->i_ceph_lock);
22112204 }
22122205
2213− for (n = rb_first(&ci->i_cap_flush_tree); n; n = rb_next(n)) {
2214− cf = rb_entry(n, struct ceph_cap_flush, i_node);
2215− cf->kick = true;
2216− }
2217−
22182206 spin_unlock(&ci->i_ceph_lock);
22192207 }
22202208 }
@@ -2228,7 +2216,7 @@ void ceph_kick_flushing_caps(struct ceph_mds_client *mdsc, · 7 unmodified lines
22282216
22292217 dout("kick_flushing_caps mds%d\n", session->s_mds);
22302218 list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) {
2231− int delayed = __kick_flushing_caps(mdsc, session, ci, false);
2219+ int delayed = __kick_flushing_caps(mdsc, session, ci);
22322220 if (delayed) {
22332221 spin_lock(&ci->i_ceph_lock);
22342222 __cap_delay_requeue(mdsc, ci);
@@ -2261,7 +2249,7 @@ static void kick_flushing_inode_caps(struct ceph_mds_client *mdsc, · 26 unmodified lines
22612249
22622250 spin_unlock(&ci->i_ceph_lock);
22632251
2264− delayed = __kick_flushing_caps(mdsc, session, ci, true);
2252+ delayed = __kick_flushing_caps(mdsc, session, ci);
22652253 if (delayed) {
22662254 spin_lock(&ci->i_ceph_lock);
22672255 __cap_delay_requeue(mdsc, ci);
fs/ceph/locks.c+1−1
@@ -287,7 +287,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode, · 286 unmodified lines
287287 return 0;
288288
289289 spin_lock(&ctx->flc_lock);
290− list_for_each_entry(lock, &ctx->flc_flock, fl_list) {
290+ list_for_each_entry(lock, &ctx->flc_posix, fl_list) {
291291 ++seen_fcntl;
292292 if (seen_fcntl > num_fcntl_locks) {
293293 err = -ENOSPC;
fs/ceph/super.h+0−1
@@ -189,7 +189,6 @@ static inline void ceph_put_cap_snap(struct ceph_cap_snap *capsnap) · 188 unmodified lines
189189 struct ceph_cap_flush {
190190 u64 tid;
191191 int caps;
192− bool kick;
193192 struct rb_node g_node; // global
194193 union {
195194 struct rb_node i_node; // inode
fs/dax.c+12−2
@@ -319,6 +319,12 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, · 318 unmodified lines
319319 * @vma: The virtual memory area where the fault occurred
320320 * @vmf: The description of the fault
321321 * @get_block: The filesystem method used to translate file offsets to blocks
322+ * @complete_unwritten: The filesystem method used to convert unwritten blocks
323+ * to written so the data written to them is exposed. This is required for
324+ * required by write faults for filesystems that will return unwritten
325+ * extent mappings from @get_block, but it is optional for reads as
326+ * dax_insert_mapping() will always zero unwritten blocks. If the fs does
327+ * not support unwritten extents, the it should pass NULL.
322328 *
323329 * When a page fault occurs, filesystems may call this helper in their
324330 * fault handler for DAX files. __dax_fault() assumes the caller has done all
@@ -437,8 +443,12 @@ int __dax_fault(struct vm_area_struct *vma, struct vm_fault *vmf, · 112 unmodified lines
437443 * as for normal BH based IO completions.
438444 */
439445 error = dax_insert_mapping(inode, &bh, vma, vmf);
440− if (buffer_unwritten(&bh))
441− complete_unwritten(&bh, !error);
446+ if (buffer_unwritten(&bh)) {
447+ if (complete_unwritten)
448+ complete_unwritten(&bh, !error);
449+ else
450+ WARN_ON_ONCE(!(vmf->flags & FAULT_FLAG_WRITE));
451+ }
442452
443453 out:
444454 if (error == -ENOMEM)
fs/dcache.c+3−10
@@ -3442,22 +3442,15 @@ void __init vfs_caches_init_early(void) · 3441 unmodified lines
34423442 inode_init_early();
34433443 }
34443444
3445−void __init vfs_caches_init(unsigned long mempages)
3445+void __init vfs_caches_init(void)
34463446 {
3447− unsigned long reserve;
3448−
3449− /* Base hash sizes on available memory, with a reserve equal to
3450− 150% of current kernel size */
3451−
3452− reserve = min((mempages - nr_free_pages()) * 3/2, mempages - 1);
3453− mempages -= reserve;
3454−
34553447 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
34563448 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
34573449
34583450 dcache_init();
34593451 inode_init();
3460− files_init(mempages);
3452+ files_init();
3453+ files_maxfiles_init();
34613454 mnt_init();
34623455 bdev_cache_init();
34633456 chrdev_init();
fs/f2fs/data.c+0−2
@@ -2072,8 +2072,6 @@ static int f2fs_set_data_page_dirty(struct page *page) · 2071 unmodified lines
20722072 return 1;
20732073 }
20742074
2075− mark_inode_dirty(inode);
2076−
20772075 if (!PageDirty(page)) {
20782076 __set_page_dirty_nobuffers(page);
20792077 update_dirty_page(inode, page);
fs/f2fs/file.c+4−3
@@ -1331,12 +1331,13 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp) · 1330 unmodified lines
13311331 if (ret)
13321332 return ret;
13331333
1334− if (f2fs_is_atomic_file(inode))
1334+ if (f2fs_is_atomic_file(inode)) {
1335+ clear_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE);
13351336 commit_inmem_pages(inode, false);
1337+ }
13361338
13371339 ret = f2fs_sync_file(filp, 0, LONG_MAX, 0);
13381340 mnt_drop_write_file(filp);
1339− clear_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE);
13401341 return ret;
13411342 }
13421343
@@ -1387,8 +1388,8 @@ static int f2fs_ioc_abort_volatile_write(struct file *filp) · 44 unmodified lines
13871388 f2fs_balance_fs(F2FS_I_SB(inode));
13881389
13891390 if (f2fs_is_atomic_file(inode)) {
1390− commit_inmem_pages(inode, false);
13911391 clear_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE);
1392+ commit_inmem_pages(inode, false);
13921393 }
13931394
13941395 if (f2fs_is_volatile_file(inode))
fs/f2fs/gc.c+21−9
@@ -556,27 +556,39 @@ static void move_encrypted_block(struct inode *inode, block_t bidx) · 555 unmodified lines
556556 if (!fio.encrypted_page)
557557 goto put_out;
558558
559− f2fs_submit_page_bio(&fio);
559+ err = f2fs_submit_page_bio(&fio);
560+ if (err)
561+ goto put_page_out;
562+
563+ /* write page */
564+ lock_page(fio.encrypted_page);
565+
566+ if (unlikely(!PageUptodate(fio.encrypted_page)))
567+ goto put_page_out;
568+ if (unlikely(fio.encrypted_page->mapping != META_MAPPING(fio.sbi)))
569+ goto put_page_out;
570+
571+ set_page_dirty(fio.encrypted_page);
572+ f2fs_wait_on_page_writeback(fio.encrypted_page, META);
573+ if (clear_page_dirty_for_io(fio.encrypted_page))
574+ dec_page_count(fio.sbi, F2FS_DIRTY_META);
575+
576+ set_page_writeback(fio.encrypted_page);
560577
561578 /* allocate block address */
562579 f2fs_wait_on_page_writeback(dn.node_page, NODE);
563−
564580 allocate_data_block(fio.sbi, NULL, fio.blk_addr,
565581 &fio.blk_addr, &sum, CURSEG_COLD_DATA);
566− dn.data_blkaddr = fio.blk_addr;
567−
568− /* write page */
569− lock_page(fio.encrypted_page);
570− set_page_writeback(fio.encrypted_page);
571582 fio.rw = WRITE_SYNC;
572583 f2fs_submit_page_mbio(&fio);
573584
585+ dn.data_blkaddr = fio.blk_addr;
574586 set_data_blkaddr(&dn);
575587 f2fs_update_extent_cache(&dn);
576588 set_inode_flag(F2FS_I(inode), FI_APPEND_WRITE);
577589 if (page->index == 0)
578590 set_inode_flag(F2FS_I(inode), FI_FIRST_BLOCK_WRITTEN);
579−
591+put_page_out:
580592 f2fs_put_page(fio.encrypted_page, 1);
581593 put_out:
582594 f2fs_put_dnode(&dn);
@@ -605,8 +617,8 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type) · 22 unmodified lines
605617 .page = page,
606618 .encrypted_page = NULL,
607619 };
620+ set_page_dirty(page);
608621 f2fs_wait_on_page_writeback(page, DATA);
609−
610622 if (clear_page_dirty_for_io(page))
611623 inode_dec_dirty_pages(inode);
612624 set_cold_data(page);
fs/f2fs/inline.c+2−0
@@ -141,6 +141,8 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page) · 140 unmodified lines
141141 kunmap_atomic(dst_addr);
142142 SetPageUptodate(page);
143143 no_update:
144+ set_page_dirty(page);
145+
144146 /* clear dirty state */
145147 dirty = clear_page_dirty_for_io(page);
146148
fs/f2fs/segment.c+1−0
@@ -257,6 +257,7 @@ void commit_inmem_pages(struct inode *inode, bool abort) · 256 unmodified lines
257257 if (!abort) {
258258 lock_page(cur->page);
259259 if (cur->page->mapping == inode->i_mapping) {
260+ set_page_dirty(cur->page);
260261 f2fs_wait_on_page_writeback(cur->page, DATA);
261262 if (clear_page_dirty_for_io(cur->page))
262263 inode_dec_dirty_pages(inode);
fs/file_table.c+15−9
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include <linux/hardirq.h>
2626 #include <linux/task_work.h>
2727 #include <linux/ima.h>
28+#include <linux/swap.h>
2829
2930 #include <linux/atomic.h>
3031
@@ -308,19 +309,24 @@ void put_filp(struct file *file) · 277 unmodified lines
308309 }
309310 }
310311
311−void __init files_init(unsigned long mempages)
312+void __init files_init(void)
312313 {
313− unsigned long n;
314−
315314 filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
316315 SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
316+ percpu_counter_init(&nr_files, 0, GFP_KERNEL);
317+}
317318
318− /*
319− * One file with associated inode and dcache is very roughly 1K.
320− * Per default don't use more than 10% of our memory for files.
321− */
319+/*
320+ * One file with associated inode and dcache is very roughly 1K. Per default
321+ * do not use more than 10% of our memory for files.
322+ */
323+void __init files_maxfiles_init(void)
324+{
325+ unsigned long n;
326+ unsigned long memreserve = (totalram_pages - nr_free_pages()) * 3/2;
327+
328+ memreserve = min(memreserve, totalram_pages - 1);
329+ n = ((totalram_pages - memreserve) * (PAGE_SIZE / 1024)) / 10;
322330
323− n = (mempages * (PAGE_SIZE / 1024)) / 10;
324331 files_stat.max_files = max_t(unsigned long, n, NR_FILE);
325− percpu_counter_init(&nr_files, 0, GFP_KERNEL);
326332 }
fs/fuse/dev.c+9−1
@@ -2246,7 +2246,15 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd, · 2245 unmodified lines
22462246
22472247 err = -EINVAL;
22482248 if (old) {
2249− struct fuse_dev *fud = fuse_get_dev(old);
2249+ struct fuse_dev *fud = NULL;
2250+
2251+ /*
2252+ * Check against file->f_op because CUSE
2253+ * uses the same ioctl handler.
2254+ */
2255+ if (old->f_op == file->f_op &&
2256+ old->f_cred->user_ns == file->f_cred->user_ns)
2257+ fud = fuse_get_dev(old);
22502258
22512259 if (fud) {
22522260 mutex_lock(&fuse_mutex);
fs/hugetlbfs/inode.c+2−0
@@ -1010,6 +1010,8 @@ struct file *hugetlb_file_setup(const char *name, size_t size, · 1009 unmodified lines
10101010 inode = hugetlbfs_get_inode(sb, NULL, S_IFREG | S_IRWXUGO, 0);
10111011 if (!inode)
10121012 goto out_dentry;
1013+ if (creat_flags == HUGETLB_SHMFS_INODE)
1014+ inode->i_flags |= S_PRIVATE;
10131015
10141016 file = ERR_PTR(-ENOMEM);
10151017 if (hugetlb_reserve_pages(inode, 0,
fs/namei.c+7−2
@@ -879,7 +879,7 @@ static inline int may_follow_link(struct nameidata *nd) · 878 unmodified lines
879879 return 0;
880880
881881 /* Allowed if parent directory not sticky and world-writable. */
882− parent = nd->path.dentry->d_inode;
882+ parent = nd->inode;
883883 if ((parent->i_mode & (S_ISVTX|S_IWOTH)) != (S_ISVTX|S_IWOTH))
884884 return 0;
885885
@@ -1954,8 +1954,13 @@ OK: · 1068 unmodified lines
19541954 continue;
19551955 }
19561956 }
1957− if (unlikely(!d_can_lookup(nd->path.dentry)))
1957+ if (unlikely(!d_can_lookup(nd->path.dentry))) {
1958+ if (nd->flags & LOOKUP_RCU) {
1959+ if (unlazy_walk(nd, NULL, 0))
1960+ return -ECHILD;
1961+ }
19581962 return -ENOTDIR;
1963+ }
19591964 }
19601965 }
19611966
fs/nfs/client.c+1−1
@@ -775,7 +775,7 @@ static int nfs_init_server(struct nfs_server *server, · 774 unmodified lines
775775 server->options = data->options;
776776 server->caps |= NFS_CAP_HARDLINKS|NFS_CAP_SYMLINKS|NFS_CAP_FILEID|
777777 NFS_CAP_MODE|NFS_CAP_NLINK|NFS_CAP_OWNER|NFS_CAP_OWNER_GROUP|
778− NFS_CAP_ATIME|NFS_CAP_CTIME|NFS_CAP_MTIME|NFS_CAP_CHANGE_ATTR;
778+ NFS_CAP_ATIME|NFS_CAP_CTIME|NFS_CAP_MTIME;
779779
780780 if (data->rsize)
781781 server->rsize = nfs_block_size(data->rsize, NULL);
fs/nfs/flexfilelayout/flexfilelayout.c+1−1
@@ -1852,7 +1852,7 @@ ff_layout_mirror_prepare_stats(struct nfs42_layoutstat_args *args, · 1851 unmodified lines
18521852 struct nfs42_layoutstat_devinfo *devinfo;
18531853 int i;
18541854
1855− for (i = 0; i <= FF_LAYOUT_MIRROR_COUNT(pls); i++) {
1855+ for (i = 0; i < FF_LAYOUT_MIRROR_COUNT(pls); i++) {
18561856 if (*dev_count >= dev_limit)
18571857 break;
18581858 mirror = FF_LAYOUT_COMP(pls, i);
fs/nfs/inode.c+8−7
@@ -442,8 +442,9 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st · 441 unmodified lines
442442 nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATTR);
443443 if (fattr->valid & NFS_ATTR_FATTR_CHANGE)
444444 inode->i_version = fattr->change_attr;
445− else if (nfs_server_capable(inode, NFS_CAP_CHANGE_ATTR))
446− nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATTR);
445+ else
446+ nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATTR
447+ | NFS_INO_REVAL_PAGECACHE);
447448 if (fattr->valid & NFS_ATTR_FATTR_SIZE)
448449 inode->i_size = nfs_size_to_loff_t(fattr->size);
449450 else
@@ -1244,9 +1245,11 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat · 794 unmodified lines
12441245 if (fattr->valid & NFS_ATTR_FATTR_SIZE) {
12451246 cur_size = i_size_read(inode);
12461247 new_isize = nfs_size_to_loff_t(fattr->size);
1247− if (cur_size != new_isize && nfsi->nrequests == 0)
1248+ if (cur_size != new_isize)
12481249 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
12491250 }
1251+ if (nfsi->nrequests != 0)
1252+ invalid &= ~NFS_INO_REVAL_PAGECACHE;
12501253
12511254 /* Have any file permissions changed? */
12521255 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
@@ -1684,13 +1687,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) · 431 unmodified lines
16841687 invalid |= NFS_INO_INVALID_ATTR
16851688 | NFS_INO_INVALID_DATA
16861689 | NFS_INO_INVALID_ACCESS
1687− | NFS_INO_INVALID_ACL
1688− | NFS_INO_REVAL_PAGECACHE;
1690+ | NFS_INO_INVALID_ACL;
16891691 if (S_ISDIR(inode->i_mode))
16901692 nfs_force_lookup_revalidate(inode);
16911693 inode->i_version = fattr->change_attr;
16921694 }
1693− } else if (server->caps & NFS_CAP_CHANGE_ATTR)
1695+ } else
16941696 nfsi->cache_validity |= save_cache_validity;
16951697
16961698 if (fattr->valid & NFS_ATTR_FATTR_MTIME) {
@@ -1717,7 +1719,6 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) · 20 unmodified lines
17171719 if ((nfsi->nrequests == 0) || new_isize > cur_isize) {
17181720 i_size_write(inode, new_isize);
17191721 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA;
1720− invalid &= ~NFS_INO_REVAL_PAGECACHE;
17211722 }
17221723 dprintk("NFS: isize change on server for file %s/%ld "
17231724 "(%Ld to %Ld)\n",
fs/nfs/internal.h+21−0
@@ -296,6 +296,22 @@ extern struct rpc_procinfo nfs4_procedures[]; · 295 unmodified lines
296296
297297 #ifdef CONFIG_NFS_V4_SECURITY_LABEL
298298 extern struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags);
299+static inline struct nfs4_label *
300+nfs4_label_copy(struct nfs4_label *dst, struct nfs4_label *src)
301+{
302+ if (!dst || !src)
303+ return NULL;
304+
305+ if (src->len > NFS4_MAXLABELLEN)
306+ return NULL;
307+
308+ dst->lfs = src->lfs;
309+ dst->pi = src->pi;
310+ dst->len = src->len;
311+ memcpy(dst->label, src->label, src->len);
312+
313+ return dst;
314+}
299315 static inline void nfs4_label_free(struct nfs4_label *label)
300316 {
301317 if (label) {
@@ -316,6 +332,11 @@ static inline void nfs4_label_free(void *label) {} · 14 unmodified lines
316332 static inline void nfs_zap_label_cache_locked(struct nfs_inode *nfsi)
317333 {
318334 }
335+static inline struct nfs4_label *
336+nfs4_label_copy(struct nfs4_label *dst, struct nfs4_label *src)
337+{
338+ return NULL;
339+}
319340 #endif /* CONFIG_NFS_V4_SECURITY_LABEL */
320341
321342 /* proc.c */
fs/nfs/nfs42proc.c+18−1
@@ -135,7 +135,7 @@ int nfs42_proc_deallocate(struct file *filep, loff_t offset, loff_t len) · 134 unmodified lines
135135 return err;
136136 }
137137
138−loff_t nfs42_proc_llseek(struct file *filep, loff_t offset, int whence)
138+static loff_t _nfs42_proc_llseek(struct file *filep, loff_t offset, int whence)
139139 {
140140 struct inode *inode = file_inode(filep);
141141 struct nfs42_seek_args args = {
@@ -171,6 +171,23 @@ loff_t nfs42_proc_llseek(struct file *filep, loff_t offset, int whence) · 29 unmodified lines
171171 return vfs_setpos(filep, res.sr_offset, inode->i_sb->s_maxbytes);
172172 }
173173
174+loff_t nfs42_proc_llseek(struct file *filep, loff_t offset, int whence)
175+{
176+ struct nfs_server *server = NFS_SERVER(file_inode(filep));
177+ struct nfs4_exception exception = { };
178+ int err;
179+
180+ do {
181+ err = _nfs42_proc_llseek(filep, offset, whence);
182+ if (err == -ENOTSUPP)
183+ return -EOPNOTSUPP;
184+ err = nfs4_handle_exception(server, err, &exception);
185+ } while (exception.retry);
186+
187+ return err;
188+}
189+
190+
174191 static void
175192 nfs42_layoutstat_prepare(struct rpc_task *task, void *calldata)
176193 {
fs/nfs/nfs4proc.c+21−15
@@ -467,7 +467,10 @@ static void do_renew_lease(struct nfs_client *clp, unsigned long timestamp) · 466 unmodified lines
467467
468468 static void renew_lease(const struct nfs_server *server, unsigned long timestamp)
469469 {
470− do_renew_lease(server->nfs_client, timestamp);
470+ struct nfs_client *clp = server->nfs_client;
471+
472+ if (!nfs4_has_session(clp))
473+ do_renew_lease(clp, timestamp);
471474 }
472475
473476 struct nfs4_call_sync_data {
@@ -616,8 +619,7 @@ int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res) · 142 unmodified lines
616619 clp = session->clp;
617620 do_renew_lease(clp, res->sr_timestamp);
618621 /* Check sequence flags */
619− if (res->sr_status_flags != 0)
620− nfs4_schedule_lease_recovery(clp);
622+ nfs41_handle_sequence_flag_errors(clp, res->sr_status_flags);
621623 nfs41_update_target_slotid(slot->table, slot, res);
622624 break;
623625 case 1:
@@ -910,6 +912,7 @@ struct nfs4_opendata { · 286 unmodified lines
910912 struct nfs_open_confirmres c_res;
911913 struct nfs4_string owner_name;
912914 struct nfs4_string group_name;
915+ struct nfs4_label *a_label;
913916 struct nfs_fattr f_attr;
914917 struct nfs4_label *f_label;
915918 struct dentry *dir;
@@ -1013,6 +1016,10 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry, · 97 unmodified lines
10131016 if (IS_ERR(p->f_label))
10141017 goto err_free_p;
10151018
1019+ p->a_label = nfs4_label_alloc(server, gfp_mask);
1020+ if (IS_ERR(p->a_label))
1021+ goto err_free_f;
1022+
10161023 alloc_seqid = server->nfs_client->cl_mvops->alloc_seqid;
10171024 p->o_arg.seqid = alloc_seqid(&sp->so_seqid, gfp_mask);
10181025 if (IS_ERR(p->o_arg.seqid))
@@ -1041,7 +1048,7 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry, · 22 unmodified lines
10411048 p->o_arg.server = server;
10421049 p->o_arg.bitmask = nfs4_bitmask(server, label);
10431050 p->o_arg.open_bitmap = &nfs4_fattr_bitmap[0];
1044− p->o_arg.label = label;
1051+ p->o_arg.label = nfs4_label_copy(p->a_label, label);
10451052 p->o_arg.claim = nfs4_map_atomic_open_claim(server, claim);
10461053 switch (p->o_arg.claim) {
10471054 case NFS4_OPEN_CLAIM_NULL:
@@ -1074,6 +1081,8 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry, · 26 unmodified lines
10741081 return p;
10751082
10761083 err_free_label:
1084+ nfs4_label_free(p->a_label);
1085+err_free_f:
10771086 nfs4_label_free(p->f_label);
10781087 err_free_p:
10791088 kfree(p);
@@ -1093,6 +1102,7 @@ static void nfs4_opendata_free(struct kref *kref) · 13 unmodified lines
10931102 nfs4_put_open_state(p->state);
10941103 nfs4_put_state_owner(p->owner);
10951104
1105+ nfs4_label_free(p->a_label);
10961106 nfs4_label_free(p->f_label);
10971107
10981108 dput(p->dir);
@@ -1198,12 +1208,15 @@ static bool nfs_need_update_open_stateid(struct nfs4_state *state, · 99 unmodified lines
11981208
11991209 static void nfs_resync_open_stateid_locked(struct nfs4_state *state)
12001210 {
1211+ if (!(state->n_wronly || state->n_rdonly || state->n_rdwr))
1212+ return;
12011213 if (state->n_wronly)
12021214 set_bit(NFS_O_WRONLY_STATE, &state->flags);
12031215 if (state->n_rdonly)
12041216 set_bit(NFS_O_RDONLY_STATE, &state->flags);
12051217 if (state->n_rdwr)
12061218 set_bit(NFS_O_RDWR_STATE, &state->flags);
1219+ set_bit(NFS_OPEN_STATE, &state->flags);
12071220 }
12081221
12091222 static void nfs_clear_open_stateid_locked(struct nfs4_state *state,
@@ -7571,13 +7584,8 @@ static int nfs4_proc_sequence(struct nfs_client *clp, struct rpc_cred *cred) · 6361 unmodified lines
75717584 goto out;
75727585 }
75737586 ret = rpc_wait_for_completion_task(task);
7574− if (!ret) {
7575− struct nfs4_sequence_res *res = task->tk_msg.rpc_resp;
7576−
7577− if (task->tk_status == 0)
7578− nfs41_handle_sequence_flag_errors(clp, res->sr_status_flags);
7587+ if (!ret)
75797588 ret = task->tk_status;
7580− }
75817589 rpc_put_task(task);
75827590 out:
75837591 dprintk("<-- %s status=%d\n", __func__, ret);
@@ -7965,16 +7973,17 @@ static void nfs4_layoutreturn_release(void *calldata) · 381 unmodified lines
79657973 {
79667974 struct nfs4_layoutreturn *lrp = calldata;
79677975 struct pnfs_layout_hdr *lo = lrp->args.layout;
7976+ LIST_HEAD(freeme);
79687977
79697978 dprintk("--> %s\n", __func__);
79707979 spin_lock(&lo->plh_inode->i_lock);
79717980 if (lrp->res.lrs_present)
79727981 pnfs_set_layout_stateid(lo, &lrp->res.stateid, true);
7982+ pnfs_mark_matching_lsegs_invalid(lo, &freeme, &lrp->args.range);
79737983 pnfs_clear_layoutreturn_waitbit(lo);
7974− clear_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE, &lo->plh_flags);
7975− rpc_wake_up(&NFS_SERVER(lo->plh_inode)->roc_rpcwaitq);
79767984 lo->plh_block_lgets--;
79777985 spin_unlock(&lo->plh_inode->i_lock);
7986+ pnfs_free_lseg_list(&freeme);
79787987 pnfs_put_layout_hdr(lrp->args.layout);
79797988 nfs_iput_and_deactive(lrp->inode);
79807989 kfree(calldata);
@@ -8588,7 +8597,6 @@ static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = { · 607 unmodified lines
85888597 .minor_version = 0,
85898598 .init_caps = NFS_CAP_READDIRPLUS
85908599 | NFS_CAP_ATOMIC_OPEN
8591− | NFS_CAP_CHANGE_ATTR
85928600 | NFS_CAP_POSIX_LOCK,
85938601 .init_client = nfs40_init_client,
85948602 .shutdown_client = nfs40_shutdown_client,
@@ -8614,7 +8622,6 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = { · 19 unmodified lines
86148622 .minor_version = 1,
86158623 .init_caps = NFS_CAP_READDIRPLUS
86168624 | NFS_CAP_ATOMIC_OPEN
8617− | NFS_CAP_CHANGE_ATTR
86188625 | NFS_CAP_POSIX_LOCK
86198626 | NFS_CAP_STATEID_NFSV41
86208627 | NFS_CAP_ATOMIC_OPEN_V1,
@@ -8637,7 +8644,6 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = { · 16 unmodified lines
86378644 .minor_version = 2,
86388645 .init_caps = NFS_CAP_READDIRPLUS
86398646 | NFS_CAP_ATOMIC_OPEN
8640− | NFS_CAP_CHANGE_ATTR
86418647 | NFS_CAP_POSIX_LOCK
86428648 | NFS_CAP_STATEID_NFSV41
86438649 | NFS_CAP_ATOMIC_OPEN_V1
fs/nfs/nfs4state.c+20−9
@@ -2191,25 +2191,35 @@ static void nfs41_handle_server_reboot(struct nfs_client *clp) · 2190 unmodified lines
21912191 }
21922192 }
21932193
2194−static void nfs41_handle_state_revoked(struct nfs_client *clp)
2194+static void nfs41_handle_all_state_revoked(struct nfs_client *clp)
21952195 {
21962196 nfs4_reset_all_state(clp);
21972197 dprintk("%s: state revoked on server %s\n", __func__, clp->cl_hostname);
21982198 }
21992199
2200+static void nfs41_handle_some_state_revoked(struct nfs_client *clp)
2201+{
2202+ nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce);
2203+ nfs4_schedule_state_manager(clp);
2204+
2205+ dprintk("%s: state revoked on server %s\n", __func__, clp->cl_hostname);
2206+}
2207+
22002208 static void nfs41_handle_recallable_state_revoked(struct nfs_client *clp)
22012209 {
2202− /* This will need to handle layouts too */
2203− nfs_expire_all_delegations(clp);
2210+ /* FIXME: For now, we destroy all layouts. */
2211+ pnfs_destroy_all_layouts(clp);
2212+ /* FIXME: For now, we test all delegations+open state+locks. */
2213+ nfs41_handle_some_state_revoked(clp);
22042214 dprintk("%s: Recallable state revoked on server %s!\n", __func__,
22052215 clp->cl_hostname);
22062216 }
22072217
22082218 static void nfs41_handle_backchannel_fault(struct nfs_client *clp)
22092219 {
2210− nfs_expire_all_delegations(clp);
2211− if (test_and_set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state) == 0)
2212− nfs4_schedule_state_manager(clp);
2220+ set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state);
2221+ nfs4_schedule_state_manager(clp);
2222+
22132223 dprintk("%s: server %s declared a backchannel fault\n", __func__,
22142224 clp->cl_hostname);
22152225 }
@@ -2231,10 +2241,11 @@ void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags) · 15 unmodified lines
22312241
22322242 if (flags & SEQ4_STATUS_RESTART_RECLAIM_NEEDED)
22332243 nfs41_handle_server_reboot(clp);
2234− if (flags & (SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED |
2235− SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED |
2244+ if (flags & (SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED))
2245+ nfs41_handle_all_state_revoked(clp);
2246+ if (flags & (SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED |
22362247 SEQ4_STATUS_ADMIN_STATE_REVOKED))
2237− nfs41_handle_state_revoked(clp);
2248+ nfs41_handle_some_state_revoked(clp);
22382249 if (flags & SEQ4_STATUS_LEASE_MOVED)
22392250 nfs4_schedule_lease_moved_recovery(clp);
22402251 if (flags & SEQ4_STATUS_RECALLABLE_STATE_REVOKED)
fs/nfs/pagelist.c+4−3
@@ -1100,8 +1100,6 @@ static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc) · 1099 unmodified lines
11001100 mirror->pg_base = 0;
11011101 mirror->pg_recoalesce = 0;
11021102
1103− desc->pg_moreio = 0;
1104−
11051103 while (!list_empty(&head)) {
11061104 struct nfs_page *req;
11071105
@@ -1109,8 +1107,11 @@ static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc) · 1 unmodified line
11091107 nfs_list_remove_request(req);
11101108 if (__nfs_pageio_add_request(desc, req))
11111109 continue;
1112− if (desc->pg_error < 0)
1110+ if (desc->pg_error < 0) {
1111+ list_splice_tail(&head, &mirror->pg_list);
1112+ mirror->pg_recoalesce = 1;
11131113 return 0;
1114+ }
11141115 break;
11151116 }
11161117 } while (mirror->pg_recoalesce);
fs/nfs/pnfs.c+57−44
@@ -352,7 +352,7 @@ pnfs_layout_need_return(struct pnfs_layout_hdr *lo, · 351 unmodified lines
352352 {
353353 struct pnfs_layout_segment *s;
354354
355− if (!test_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags))
355+ if (!test_and_clear_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags))
356356 return false;
357357
358358 list_for_each_entry(s, &lo->plh_segs, pls_list)
@@ -362,6 +362,18 @@ pnfs_layout_need_return(struct pnfs_layout_hdr *lo, · 3 unmodified lines
362362 return true;
363363 }
364364
365+static bool
366+pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo)
367+{
368+ if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags))
369+ return false;
370+ lo->plh_return_iomode = 0;
371+ lo->plh_block_lgets++;
372+ pnfs_get_layout_hdr(lo);
373+ clear_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE, &lo->plh_flags);
374+ return true;
375+}
376+
365377 static void pnfs_layoutreturn_before_put_lseg(struct pnfs_layout_segment *lseg,
366378 struct pnfs_layout_hdr *lo, struct inode *inode)
367379 {
@@ -372,17 +384,16 @@ static void pnfs_layoutreturn_before_put_lseg(struct pnfs_layout_segment *lseg, · 4 unmodified lines
372384 if (pnfs_layout_need_return(lo, lseg)) {
373385 nfs4_stateid stateid;
374386 enum pnfs_iomode iomode;
387+ bool send;
375388
376389 stateid = lo->plh_stateid;
377390 iomode = lo->plh_return_iomode;
378− /* decreased in pnfs_send_layoutreturn() */
379− lo->plh_block_lgets++;
380− lo->plh_return_iomode = 0;
391+ send = pnfs_prepare_layoutreturn(lo);
381392 spin_unlock(&inode->i_lock);
382− pnfs_get_layout_hdr(lo);
383−
384− /* Send an async layoutreturn so we dont deadlock */
385− pnfs_send_layoutreturn(lo, stateid, iomode, false);
393+ if (send) {
394+ /* Send an async layoutreturn so we dont deadlock */
395+ pnfs_send_layoutreturn(lo, stateid, iomode, false);
396+ }
386397 } else
387398 spin_unlock(&inode->i_lock);
388399 }
@@ -411,6 +422,10 @@ pnfs_put_lseg(struct pnfs_layout_segment *lseg) · 22 unmodified lines
411422 pnfs_layoutreturn_before_put_lseg(lseg, lo, inode);
412423
413424 if (atomic_dec_and_lock(&lseg->pls_refcount, &inode->i_lock)) {
425+ if (test_bit(NFS_LSEG_VALID, &lseg->pls_flags)) {
426+ spin_unlock(&inode->i_lock);
427+ return;
428+ }
414429 pnfs_get_layout_hdr(lo);
415430 pnfs_layout_remove_lseg(lo, lseg);
416431 spin_unlock(&inode->i_lock);
@@ -451,6 +466,8 @@ pnfs_put_lseg_locked(struct pnfs_layout_segment *lseg) · 34 unmodified lines
451466 test_bit(NFS_LSEG_VALID, &lseg->pls_flags));
452467 if (atomic_dec_and_test(&lseg->pls_refcount)) {
453468 struct pnfs_layout_hdr *lo = lseg->pls_layout;
469+ if (test_bit(NFS_LSEG_VALID, &lseg->pls_flags))
470+ return;
454471 pnfs_get_layout_hdr(lo);
455472 pnfs_layout_remove_lseg(lo, lseg);
456473 pnfs_free_lseg_async(lseg);
@@ -924,6 +941,7 @@ void pnfs_clear_layoutreturn_waitbit(struct pnfs_layout_hdr *lo) · 467 unmodified lines
924941 clear_bit_unlock(NFS_LAYOUT_RETURN, &lo->plh_flags);
925942 smp_mb__after_atomic();
926943 wake_up_bit(&lo->plh_flags, NFS_LAYOUT_RETURN);
944+ rpc_wake_up(&NFS_SERVER(lo->plh_inode)->roc_rpcwaitq);
927945 }
928946
929947 static int
@@ -978,6 +996,7 @@ _pnfs_return_layout(struct inode *ino) · 48 unmodified lines
978996 LIST_HEAD(tmp_list);
979997 nfs4_stateid stateid;
980998 int status = 0, empty;
999+ bool send;
9811000
9821001 dprintk("NFS: %s for inode %lu\n", __func__, ino->i_ino);
9831002
@@ -1007,17 +1026,18 @@ _pnfs_return_layout(struct inode *ino) · 23 unmodified lines
10071026 /* Don't send a LAYOUTRETURN if list was initially empty */
10081027 if (empty) {
10091028 spin_unlock(&ino->i_lock);
1010− pnfs_put_layout_hdr(lo);
10111029 dprintk("NFS: %s no layout segments to return\n", __func__);
1012− goto out;
1030+ goto out_put_layout_hdr;
10131031 }
10141032
10151033 set_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags);
1016− lo->plh_block_lgets++;
1034+ send = pnfs_prepare_layoutreturn(lo);
10171035 spin_unlock(&ino->i_lock);
10181036 pnfs_free_lseg_list(&tmp_list);
1019−
1020− status = pnfs_send_layoutreturn(lo, stateid, IOMODE_ANY, true);
1037+ if (send)
1038+ status = pnfs_send_layoutreturn(lo, stateid, IOMODE_ANY, true);
1039+out_put_layout_hdr:
1040+ pnfs_put_layout_hdr(lo);
10211041 out:
10221042 dprintk("<-- %s status: %d\n", __func__, status);
10231043 return status;
@@ -1097,13 +1117,9 @@ bool pnfs_roc(struct inode *ino) · 73 unmodified lines
10971117 out_noroc:
10981118 if (lo) {
10991119 stateid = lo->plh_stateid;
1100− layoutreturn =
1101− test_and_clear_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE,
1102− &lo->plh_flags);
1103− if (layoutreturn) {
1104− lo->plh_block_lgets++;
1105− pnfs_get_layout_hdr(lo);
1106− }
1120+ if (test_and_clear_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE,
1121+ &lo->plh_flags))
1122+ layoutreturn = pnfs_prepare_layoutreturn(lo);
11071123 }
11081124 spin_unlock(&ino->i_lock);
11091125 if (layoutreturn) {
@@ -1146,15 +1162,18 @@ bool pnfs_roc_drain(struct inode *ino, u32 *barrier, struct rpc_task *task) · 36 unmodified lines
11461162 struct pnfs_layout_segment *lseg;
11471163 nfs4_stateid stateid;
11481164 u32 current_seqid;
1149− bool found = false, layoutreturn = false;
1165+ bool layoutreturn = false;
11501166
11511167 spin_lock(&ino->i_lock);
1152− list_for_each_entry(lseg, &nfsi->layout->plh_segs, pls_list)
1153− if (test_bit(NFS_LSEG_ROC, &lseg->pls_flags)) {
1154− rpc_sleep_on(&NFS_SERVER(ino)->roc_rpcwaitq, task, NULL);
1155− found = true;
1156− goto out;
1157− }
1168+ list_for_each_entry(lseg, &nfsi->layout->plh_segs, pls_list) {
1169+ if (!test_bit(NFS_LSEG_ROC, &lseg->pls_flags))
1170+ continue;
1171+ if (test_bit(NFS_LSEG_VALID, &lseg->pls_flags))
1172+ continue;
1173+ rpc_sleep_on(&NFS_SERVER(ino)->roc_rpcwaitq, task, NULL);
1174+ spin_unlock(&ino->i_lock);
1175+ return true;
1176+ }
11581177 lo = nfsi->layout;
11591178 current_seqid = be32_to_cpu(lo->plh_stateid.seqid);
11601179
@@ -1162,23 +1181,19 @@ bool pnfs_roc_drain(struct inode *ino, u32 *barrier, struct rpc_task *task) · 1 unmodified line
11621181 * a barrier, we choose the worst-case barrier.
11631182 */
11641183 *barrier = current_seqid + atomic_read(&lo->plh_outstanding);
1165−out:
1166− if (!found) {
1167− stateid = lo->plh_stateid;
1168− layoutreturn =
1169− test_and_clear_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE,
1170− &lo->plh_flags);
1171− if (layoutreturn) {
1172− lo->plh_block_lgets++;
1173− pnfs_get_layout_hdr(lo);
1174− }
1175− }
1184+ stateid = lo->plh_stateid;
1185+ if (test_and_clear_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE,
1186+ &lo->plh_flags))
1187+ layoutreturn = pnfs_prepare_layoutreturn(lo);
1188+ if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags))
1189+ rpc_sleep_on(&NFS_SERVER(ino)->roc_rpcwaitq, task, NULL);
1190+
11761191 spin_unlock(&ino->i_lock);
11771192 if (layoutreturn) {
1178− rpc_sleep_on(&NFS_SERVER(ino)->roc_rpcwaitq, task, NULL);
11791193 pnfs_send_layoutreturn(lo, stateid, IOMODE_ANY, false);
1194+ return true;
11801195 }
1181− return found;
1196+ return false;
11821197 }
11831198
11841199 /*
@@ -1695,7 +1710,6 @@ void pnfs_error_mark_layout_for_return(struct inode *inode, · 510 unmodified lines
16951710 spin_lock(&inode->i_lock);
16961711 /* set failure bit so that pnfs path will be retried later */
16971712 pnfs_layout_set_fail_bit(lo, iomode);
1698− set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags);
16991713 if (lo->plh_return_iomode == 0)
17001714 lo->plh_return_iomode = range.iomode;
17011715 else if (lo->plh_return_iomode != range.iomode)
@@ -2207,13 +2221,12 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync) · 505 unmodified lines
22072221 if (ld->prepare_layoutcommit) {
22082222 status = ld->prepare_layoutcommit(&data->args);
22092223 if (status) {
2224+ put_rpccred(data->cred);
22102225 spin_lock(&inode->i_lock);
22112226 set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags);
22122227 if (end_pos > nfsi->layout->plh_lwb)
22132228 nfsi->layout->plh_lwb = end_pos;
2214− spin_unlock(&inode->i_lock);
2215− put_rpccred(data->cred);
2216− goto clear_layoutcommitting;
2229+ goto out_unlock;
22172230 }
22182231 }
22192232
fs/nfs/write.c+9−6
@@ -1379,24 +1379,27 @@ static void nfs_writeback_check_extend(struct nfs_pgio_header *hdr, · 1378 unmodified lines
13791379 {
13801380 struct nfs_pgio_args *argp = &hdr->args;
13811381 struct nfs_pgio_res *resp = &hdr->res;
1382+ u64 size = argp->offset + resp->count;
13821383
13831384 if (!(fattr->valid & NFS_ATTR_FATTR_SIZE))
1385+ fattr->size = size;
1386+ if (nfs_size_to_loff_t(fattr->size) < i_size_read(hdr->inode)) {
1387+ fattr->valid &= ~NFS_ATTR_FATTR_SIZE;
13841388 return;
1385− if (argp->offset + resp->count != fattr->size)
1386− return;
1387− if (nfs_size_to_loff_t(fattr->size) < i_size_read(hdr->inode))
1389+ }
1390+ if (size != fattr->size)
13881391 return;
13891392 /* Set attribute barrier */
13901393 nfs_fattr_set_barrier(fattr);
1394+ /* ...and update size */
1395+ fattr->valid |= NFS_ATTR_FATTR_SIZE;
13911396 }
13921397
13931398 void nfs_writeback_update_inode(struct nfs_pgio_header *hdr)
13941399 {
1395− struct nfs_fattr *fattr = hdr->res.fattr;
1400+ struct nfs_fattr *fattr = &hdr->fattr;
13961401 struct inode *inode = hdr->inode;
13971402
1398− if (fattr == NULL)
1399− return;
14001403 spin_lock(&inode->i_lock);
14011404 nfs_writeback_check_extend(hdr, fattr);
14021405 nfs_post_op_update_inode_force_wcc_locked(inode, fattr);
fs/nfsd/nfs4layouts.c+1−0
@@ -212,6 +212,7 @@ nfsd4_alloc_layout_stateid(struct nfsd4_compound_state *cstate, · 211 unmodified lines
212212 BUG_ON(!ls->ls_file);
213213
214214 if (nfsd4_layout_setlease(ls)) {
215+ fput(ls->ls_file);
215216 put_nfs4_file(fp);
216217 kmem_cache_free(nfs4_layout_stateid_cache, ls);
217218 return NULL;
fs/nfsd/nfs4state.c+6−6
@@ -4396,9 +4396,9 @@ laundromat_main(struct work_struct *laundry) · 4395 unmodified lines
43964396 queue_delayed_work(laundry_wq, &nn->laundromat_work, t*HZ);
43974397 }
43984398
4399−static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_ol_stateid *stp)
4399+static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp)
44004400 {
4401− if (!fh_match(&fhp->fh_handle, &stp->st_stid.sc_file->fi_fhandle))
4401+ if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle))
44024402 return nfserr_bad_stateid;
44034403 return nfs_ok;
44044404 }
@@ -4601,9 +4601,6 @@ nfs4_check_olstateid(struct svc_fh *fhp, struct nfs4_ol_stateid *ols, int flags) · 196 unmodified lines
46014601 {
46024602 __be32 status;
46034603
4604− status = nfs4_check_fh(fhp, ols);
4605− if (status)
4606− return status;
46074604 status = nfsd4_check_openowner_confirmed(ols);
46084605 if (status)
46094606 return status;
@@ -4690,6 +4687,9 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, · 80 unmodified lines
46904687 status = nfserr_bad_stateid;
46914688 break;
46924689 }
4690+ if (status)
4691+ goto out;
4692+ status = nfs4_check_fh(fhp, s);
46934693
46944694 done:
46954695 if (!status && filpp)
@@ -4798,7 +4798,7 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_ · 102 unmodified lines
47984798 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate));
47994799 if (status)
48004800 return status;
4801− return nfs4_check_fh(current_fh, stp);
4801+ return nfs4_check_fh(current_fh, &stp->st_stid);
48024802 }
48034803
48044804 /*
fs/nfsd/nfs4xdr.c+6−5
@@ -2143,6 +2143,7 @@ nfsd4_encode_aclname(struct xdr_stream *xdr, struct svc_rqst *rqstp, · 2142 unmodified lines
21432143 #define WORD0_ABSENT_FS_ATTRS (FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_FSID | \
21442144 FATTR4_WORD0_RDATTR_ERROR)
21452145 #define WORD1_ABSENT_FS_ATTRS FATTR4_WORD1_MOUNTED_ON_FILEID
2146+#define WORD2_ABSENT_FS_ATTRS 0
21462147
21472148 #ifdef CONFIG_NFSD_V4_SECURITY_LABEL
21482149 static inline __be32
@@ -2171,7 +2172,7 @@ nfsd4_encode_security_label(struct xdr_stream *xdr, struct svc_rqst *rqstp, · 22 unmodified lines
21712172 { return 0; }
21722173 #endif
21732174
2174−static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *rdattr_err)
2175+static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *bmval2, u32 *rdattr_err)
21752176 {
21762177 /* As per referral draft: */
21772178 if (*bmval0 & ~WORD0_ABSENT_FS_ATTRS ||
@@ -2184,6 +2185,7 @@ static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *rdattr_err) · 6 unmodified lines
21842185 }
21852186 *bmval0 &= WORD0_ABSENT_FS_ATTRS;
21862187 *bmval1 &= WORD1_ABSENT_FS_ATTRS;
2188+ *bmval2 &= WORD2_ABSENT_FS_ATTRS;
21872189 return 0;
21882190 }
21892191
@@ -2246,8 +2248,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, · 56 unmodified lines
22462248 BUG_ON(bmval2 & ~nfsd_suppattrs2(minorversion));
22472249
22482250 if (exp->ex_fslocs.migrated) {
2249− BUG_ON(bmval[2]);
2250− status = fattr_handle_absent_fs(&bmval0, &bmval1, &rdattr_err);
2251+ status = fattr_handle_absent_fs(&bmval0, &bmval1, &bmval2, &rdattr_err);
22512252 if (status)
22522253 goto out;
22532254 }
@@ -2286,8 +2287,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, · 32 unmodified lines
22862287 }
22872288
22882289 #ifdef CONFIG_NFSD_V4_SECURITY_LABEL
2289− if ((bmval[2] & FATTR4_WORD2_SECURITY_LABEL) ||
2290− bmval[0] & FATTR4_WORD0_SUPPORTED_ATTRS) {
2290+ if ((bmval2 & FATTR4_WORD2_SECURITY_LABEL) ||
2291+ bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) {
22912292 err = security_inode_getsecctx(d_inode(dentry),
22922293 &context, &contextlen);
22932294 contextsupport = (err == 0);
fs/notify/mark.c+25−5
@@ -412,16 +412,36 @@ void fsnotify_clear_marks_by_group_flags(struct fsnotify_group *group, · 411 unmodified lines
412412 unsigned int flags)
413413 {
414414 struct fsnotify_mark *lmark, *mark;
415+ LIST_HEAD(to_free);
415416
417+ /*
418+ * We have to be really careful here. Anytime we drop mark_mutex, e.g.
419+ * fsnotify_clear_marks_by_inode() can come and free marks. Even in our
420+ * to_free list so we have to use mark_mutex even when accessing that
421+ * list. And freeing mark requires us to drop mark_mutex. So we can
422+ * reliably free only the first mark in the list. That's why we first
423+ * move marks to free to to_free list in one go and then free marks in
424+ * to_free list one by one.
425+ */
416426 mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING);
417427 list_for_each_entry_safe(mark, lmark, &group->marks_list, g_list) {
418− if (mark->flags & flags) {
419− fsnotify_get_mark(mark);
420− fsnotify_destroy_mark_locked(mark, group);
421− fsnotify_put_mark(mark);
422− }
428+ if (mark->flags & flags)
429+ list_move(&mark->g_list, &to_free);
423430 }
424431 mutex_unlock(&group->mark_mutex);
432+
433+ while (1) {
434+ mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING);
435+ if (list_empty(&to_free)) {
436+ mutex_unlock(&group->mark_mutex);
437+ break;
438+ }
439+ mark = list_first_entry(&to_free, struct fsnotify_mark, g_list);
440+ fsnotify_get_mark(mark);
441+ fsnotify_destroy_mark_locked(mark, group);
442+ mutex_unlock(&group->mark_mutex);
443+ fsnotify_put_mark(mark);
444+ }
425445 }
426446
427447 /*
fs/ocfs2/aops.c+2−2
@@ -685,7 +685,7 @@ static int ocfs2_direct_IO_zero_extend(struct ocfs2_super *osb, · 684 unmodified lines
685685
686686 if (p_cpos && !(ext_flags & OCFS2_EXT_UNWRITTEN)) {
687687 u64 s = i_size_read(inode);
688− sector_t sector = (p_cpos << (osb->s_clustersize_bits - 9)) +
688+ sector_t sector = ((u64)p_cpos << (osb->s_clustersize_bits - 9)) +
689689 (do_div(s, osb->s_clustersize) >> 9);
690690
691691 ret = blkdev_issue_zeroout(osb->sb->s_bdev, sector,
@@ -910,7 +910,7 @@ static ssize_t ocfs2_direct_IO_write(struct kiocb *iocb, · 218 unmodified lines
910910 BUG_ON(!p_cpos || (ext_flags & OCFS2_EXT_UNWRITTEN));
911911
912912 ret = blkdev_issue_zeroout(osb->sb->s_bdev,
913− p_cpos << (osb->s_clustersize_bits - 9),
913+ (u64)p_cpos << (osb->s_clustersize_bits - 9),
914914 zero_len_head >> 9, GFP_NOFS, false);
915915 if (ret < 0)
916916 mlog_errno(ret);
fs/ocfs2/dlmglue.c+7−3
@@ -4025,9 +4025,13 @@ static void ocfs2_downconvert_thread_do_work(struct ocfs2_super *osb) · 4024 unmodified lines
40254025 osb->dc_work_sequence = osb->dc_wake_sequence;
40264026
40274027 processed = osb->blocked_lock_count;
4028− while (processed) {
4029− BUG_ON(list_empty(&osb->blocked_lock_list));
4030−
4028+ /*
4029+ * blocked lock processing in this loop might call iput which can
4030+ * remove items off osb->blocked_lock_list. Downconvert up to
4031+ * 'processed' number of locks, but stop short if we had some
4032+ * removed in ocfs2_mark_lockres_freeing when downconverting.
4033+ */
4034+ while (processed && !list_empty(&osb->blocked_lock_list)) {
40314035 lockres = list_entry(osb->blocked_lock_list.next,
40324036 struct ocfs2_lock_res, l_blocked_list);
40334037 list_del_init(&lockres->l_blocked_list);
fs/signalfd.c+3−2
@@ -121,8 +121,9 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo, · 120 unmodified lines
121121 * Other callers might not initialize the si_lsb field,
122122 * so check explicitly for the right codes here.
123123 */
124− if (kinfo->si_code == BUS_MCEERR_AR ||
125− kinfo->si_code == BUS_MCEERR_AO)
124+ if (kinfo->si_signo == SIGBUS &&
125+ (kinfo->si_code == BUS_MCEERR_AR ||
126+ kinfo->si_code == BUS_MCEERR_AO))
126127 err |= __put_user((short) kinfo->si_addr_lsb,
127128 &uinfo->ssi_addr_lsb);
128129 #endif
fs/xfs/libxfs/xfs_attr_remote.c+34−10
@@ -159,11 +159,10 @@ xfs_attr3_rmt_write_verify( · 158 unmodified lines
159159 struct xfs_buf *bp)
160160 {
161161 struct xfs_mount *mp = bp->b_target->bt_mount;
162− struct xfs_buf_log_item *bip = bp->b_fspriv;
162+ int blksize = mp->m_attr_geo->blksize;
163163 char *ptr;
164164 int len;
165165 xfs_daddr_t bno;
166− int blksize = mp->m_attr_geo->blksize;
167166
168167 /* no verification of non-crc buffers */
169168 if (!xfs_sb_version_hascrc(&mp->m_sb))
@@ -175,16 +174,22 @@ xfs_attr3_rmt_write_verify( · 5 unmodified lines
175174 ASSERT(len >= blksize);
176175
177176 while (len > 0) {
177+ struct xfs_attr3_rmt_hdr *rmt = (struct xfs_attr3_rmt_hdr *)ptr;
178+
178179 if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
179180 xfs_buf_ioerror(bp, -EFSCORRUPTED);
180181 xfs_verifier_error(bp);
181182 return;
182183 }
183− if (bip) {
184− struct xfs_attr3_rmt_hdr *rmt;
185184
186− rmt = (struct xfs_attr3_rmt_hdr *)ptr;
187− rmt->rm_lsn = cpu_to_be64(bip->bli_item.li_lsn);
185+ /*
186+ * Ensure we aren't writing bogus LSNs to disk. See
187+ * xfs_attr3_rmt_hdr_set() for the explanation.
188+ */
189+ if (rmt->rm_lsn != cpu_to_be64(NULLCOMMITLSN)) {
190+ xfs_buf_ioerror(bp, -EFSCORRUPTED);
191+ xfs_verifier_error(bp);
192+ return;
188193 }
189194 xfs_update_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF);
190195
@@ -221,6 +226,18 @@ xfs_attr3_rmt_hdr_set( · 30 unmodified lines
221226 rmt->rm_owner = cpu_to_be64(ino);
222227 rmt->rm_blkno = cpu_to_be64(bno);
223228
229+ /*
230+ * Remote attribute blocks are written synchronously, so we don't
231+ * have an LSN that we can stamp in them that makes any sense to log
232+ * recovery. To ensure that log recovery handles overwrites of these
233+ * blocks sanely (i.e. once they've been freed and reallocated as some
234+ * other type of metadata) we need to ensure that the LSN has a value
235+ * that tells log recovery to ignore the LSN and overwrite the buffer
236+ * with whatever is in it's log. To do this, we use the magic
237+ * NULLCOMMITLSN to indicate that the LSN is invalid.
238+ */
239+ rmt->rm_lsn = cpu_to_be64(NULLCOMMITLSN);
240+
224241 return sizeof(struct xfs_attr3_rmt_hdr);
225242 }
226243
@@ -434,14 +451,21 @@ xfs_attr_rmtval_set( · 207 unmodified lines
434451
435452 /*
436453 * Allocate a single extent, up to the size of the value.
454+ *
455+ * Note that we have to consider this a data allocation as we
456+ * write the remote attribute without logging the contents.
457+ * Hence we must ensure that we aren't using blocks that are on
458+ * the busy list so that we don't overwrite blocks which have
459+ * recently been freed but their transactions are not yet
460+ * committed to disk. If we overwrite the contents of a busy
461+ * extent and then crash then the block may not contain the
462+ * correct metadata after log recovery occurs.
437463 */
438464 xfs_bmap_init(args->flist, args->firstblock);
439465 nmap = 1;
440466 error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno,
441− blkcnt,
442− XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA,
443− args->firstblock, args->total, &map, &nmap,
444− args->flist);
467+ blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock,
468+ args->total, &map, &nmap, args->flist);
445469 if (!error) {
446470 error = xfs_bmap_finish(&args->trans, args->flist,
447471 &committed);
fs/xfs/xfs_file.c+15−6
@@ -1514,18 +1514,27 @@ xfs_filemap_fault( · 1513 unmodified lines
15141514 struct vm_area_struct *vma,
15151515 struct vm_fault *vmf)
15161516 {
1517− struct xfs_inode *ip = XFS_I(file_inode(vma->vm_file));
1517+ struct inode *inode = file_inode(vma->vm_file);
15181518 int ret;
15191519
1520− trace_xfs_filemap_fault(ip);
1520+ trace_xfs_filemap_fault(XFS_I(inode));
15211521
15221522 /* DAX can shortcut the normal fault path on write faults! */
1523− if ((vmf->flags & FAULT_FLAG_WRITE) && IS_DAX(VFS_I(ip)))
1523+ if ((vmf->flags & FAULT_FLAG_WRITE) && IS_DAX(inode))
15241524 return xfs_filemap_page_mkwrite(vma, vmf);
15251525
1526− xfs_ilock(ip, XFS_MMAPLOCK_SHARED);
1527− ret = filemap_fault(vma, vmf);
1528− xfs_iunlock(ip, XFS_MMAPLOCK_SHARED);
1526+ xfs_ilock(XFS_I(inode), XFS_MMAPLOCK_SHARED);
1527+ if (IS_DAX(inode)) {
1528+ /*
1529+ * we do not want to trigger unwritten extent conversion on read
1530+ * faults - that is unnecessary overhead and would also require
1531+ * changes to xfs_get_blocks_direct() to map unwritten extent
1532+ * ioend for conversion on read-only mappings.
1533+ */
1534+ ret = __dax_fault(vma, vmf, xfs_get_blocks_direct, NULL);
1535+ } else
1536+ ret = filemap_fault(vma, vmf);
1537+ xfs_iunlock(XFS_I(inode), XFS_MMAPLOCK_SHARED);
15291538
15301539 return ret;
15311540 }
fs/xfs/xfs_log_recover.c+8−3
@@ -1886,9 +1886,14 @@ xlog_recover_get_buf_lsn( · 1885 unmodified lines
18861886 uuid = &((struct xfs_dir3_blk_hdr *)blk)->uuid;
18871887 break;
18881888 case XFS_ATTR3_RMT_MAGIC:
1889− lsn = be64_to_cpu(((struct xfs_attr3_rmt_hdr *)blk)->rm_lsn);
1890− uuid = &((struct xfs_attr3_rmt_hdr *)blk)->rm_uuid;
1891− break;
1889+ /*
1890+ * Remote attr blocks are written synchronously, rather than
1891+ * being logged. That means they do not contain a valid LSN
1892+ * (i.e. transactionally ordered) in them, and hence any time we
1893+ * see a buffer to replay over the top of a remote attribute
1894+ * block we should simply do so.
1895+ */
1896+ goto recover_immediately;
18921897 case XFS_SB_MAGIC:
18931898 lsn = be64_to_cpu(((struct xfs_dsb *)blk)->sb_lsn);
18941899 uuid = &((struct xfs_dsb *)blk)->sb_uuid;
include/drm/drmP.h+1−1
@@ -691,7 +691,7 @@ struct drm_vblank_crtc { · 690 unmodified lines
691691 struct timer_list disable_timer; /* delayed disable timer */
692692
693693 /* vblank counter, protected by dev->vblank_time_lock for writes */
694− unsigned long count;
694+ u32 count;
695695 /* vblank timestamps, protected by dev->vblank_time_lock for writes */
696696 struct timeval time[DRM_VBLANKTIME_RBSIZE];
697697
include/drm/drm_crtc.h+0−2
@@ -743,8 +743,6 @@ struct drm_connector { · 742 unmodified lines
743743 uint8_t num_h_tile, num_v_tile;
744744 uint8_t tile_h_loc, tile_v_loc;
745745 uint16_t tile_h_size, tile_v_size;
746−
747− struct list_head destroy_list;
748746 };
749747
750748 /**
include/drm/drm_crtc_helper.h+3−0
@@ -168,6 +168,7 @@ struct drm_encoder_helper_funcs { · 167 unmodified lines
168168 * @get_modes: get mode list for this connector
169169 * @mode_valid: is this mode valid on the given connector? (optional)
170170 * @best_encoder: return the preferred encoder for this connector
171+ * @atomic_best_encoder: atomic version of @best_encoder
171172 *
172173 * The helper operations are called by the mid-layer CRTC helper.
173174 */
@@ -176,6 +177,8 @@ struct drm_connector_helper_funcs { · 2 unmodified lines
176177 enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
177178 struct drm_display_mode *mode);
178179 struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
180+ struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,
181+ struct drm_connector_state *connector_state);
179182 };
180183
181184 extern void drm_helper_disable_unused_functions(struct drm_device *dev);
include/drm/drm_pciids.h+1−0
@@ -172,6 +172,7 @@ · 171 unmodified lines
172172 {0x1002, 0x6610, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
173173 {0x1002, 0x6611, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
174174 {0x1002, 0x6613, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
175+ {0x1002, 0x6617, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
175176 {0x1002, 0x6620, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
176177 {0x1002, 0x6621, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
177178 {0x1002, 0x6623, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
include/linux/ata.h+0−18
@@ -385,8 +385,6 @@ enum { · 384 unmodified lines
385385 SATA_SSP = 0x06, /* Software Settings Preservation */
386386 SATA_DEVSLP = 0x09, /* Device Sleep */
387387
388− SETFEATURE_SENSE_DATA = 0xC3, /* Sense Data Reporting feature */
389−
390388 /* feature values for SET_MAX */
391389 ATA_SET_MAX_ADDR = 0x00,
392390 ATA_SET_MAX_PASSWD = 0x01,
@@ -530,8 +528,6 @@ struct ata_bmdma_prd { · 137 unmodified lines
530528 #define ata_id_cdb_intr(id) (((id)[ATA_ID_CONFIG] & 0x60) == 0x20)
531529 #define ata_id_has_da(id) ((id)[ATA_ID_SATA_CAPABILITY_2] & (1 << 4))
532530 #define ata_id_has_devslp(id) ((id)[ATA_ID_FEATURE_SUPP] & (1 << 8))
533−#define ata_id_has_ncq_autosense(id) \
534− ((id)[ATA_ID_FEATURE_SUPP] & (1 << 7))
535531
536532 static inline bool ata_id_has_hipm(const u16 *id)
537533 {
@@ -720,20 +716,6 @@ static inline bool ata_id_has_read_log_dma_ext(const u16 *id) · 182 unmodified lines
720716 return false;
721717 }
722718
723−static inline bool ata_id_has_sense_reporting(const u16 *id)
724−{
725− if (!(id[ATA_ID_CFS_ENABLE_2] & (1 << 15)))
726− return false;
727− return id[ATA_ID_COMMAND_SET_3] & (1 << 6);
728−}
729−
730−static inline bool ata_id_sense_reporting_enabled(const u16 *id)
731−{
732− if (!(id[ATA_ID_CFS_ENABLE_2] & (1 << 15)))
733− return false;
734− return id[ATA_ID_COMMAND_SET_4] & (1 << 6);
735−}
736−
737719 /**
738720 * ata_id_major_version - get ATA level of drive
739721 * @id: Identify data
include/linux/cpufreq.h+1−0
@@ -62,6 +62,7 @@ struct cpufreq_policy { · 61 unmodified lines
6262 /* CPUs sharing clock, require sw coordination */
6363 cpumask_var_t cpus; /* Online CPUs only */
6464 cpumask_var_t related_cpus; /* Online + Offline CPUs */
65+ cpumask_var_t real_cpus; /* Related and present */
6566
6667 unsigned int shared_type; /* ACPI: ANY or ALL affected CPUs
6768 should set cpufreq */
include/linux/fs.h+3−2
@@ -55,7 +55,8 @@ struct vm_fault; · 54 unmodified lines
5555
5656 extern void __init inode_init(void);
5757 extern void __init inode_init_early(void);
58−extern void __init files_init(unsigned long);
58+extern void __init files_init(void);
59+extern void __init files_maxfiles_init(void);
5960
6061 extern struct files_stat_struct files_stat;
6162 extern unsigned long get_max_files(void);
@@ -2245,7 +2246,7 @@ extern int ioctl_preallocate(struct file *filp, void __user *argp); · 2183 unmodified lines
22452246
22462247 /* fs/dcache.c */
22472248 extern void __init vfs_caches_init_early(void);
2248−extern void __init vfs_caches_init(unsigned long);
2249+extern void __init vfs_caches_init(void);
22492250
22502251 extern struct kmem_cache *names_cachep;
22512252
include/linux/nfs_fs.h+5−2
@@ -292,9 +292,12 @@ static inline void nfs_mark_for_revalidate(struct inode *inode) · 291 unmodified lines
292292 struct nfs_inode *nfsi = NFS_I(inode);
293293
294294 spin_lock(&inode->i_lock);
295− nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS;
295+ nfsi->cache_validity |= NFS_INO_INVALID_ATTR |
296+ NFS_INO_REVAL_PAGECACHE |
297+ NFS_INO_INVALID_ACCESS |
298+ NFS_INO_INVALID_ACL;
296299 if (S_ISDIR(inode->i_mode))
297− nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA;
300+ nfsi->cache_validity |= NFS_INO_INVALID_DATA;
298301 spin_unlock(&inode->i_lock);
299302 }
300303
include/linux/nfs_fs_sb.h+1−1
@@ -220,7 +220,7 @@ struct nfs_server { · 219 unmodified lines
220220 #define NFS_CAP_SYMLINKS (1U << 2)
221221 #define NFS_CAP_ACLS (1U << 3)
222222 #define NFS_CAP_ATOMIC_OPEN (1U << 4)
223−#define NFS_CAP_CHANGE_ATTR (1U << 5)
223+/* #define NFS_CAP_CHANGE_ATTR (1U << 5) */
224224 #define NFS_CAP_FILEID (1U << 6)
225225 #define NFS_CAP_MODE (1U << 7)
226226 #define NFS_CAP_NLINK (1U << 8)
include/linux/of_device.h+1−1
@@ -59,7 +59,7 @@ void of_dma_configure(struct device *dev, struct device_node *np); · 58 unmodified lines
5959 #else /* CONFIG_OF */
6060
6161 static inline int of_driver_match_device(struct device *dev,
62− struct device_driver *drv)
62+ const struct device_driver *drv)
6363 {
6464 return 0;
6565 }
include/linux/page-flags.h+7−3
@@ -631,15 +631,19 @@ static inline void ClearPageSlabPfmemalloc(struct page *page) · 630 unmodified lines
631631 1 << PG_private | 1 << PG_private_2 | \
632632 1 << PG_writeback | 1 << PG_reserved | \
633633 1 << PG_slab | 1 << PG_swapcache | 1 << PG_active | \
634− 1 << PG_unevictable | __PG_MLOCKED | __PG_HWPOISON | \
634+ 1 << PG_unevictable | __PG_MLOCKED | \
635635 __PG_COMPOUND_LOCK)
636636
637637 /*
638638 * Flags checked when a page is prepped for return by the page allocator.
639− * Pages being prepped should not have any flags set. It they are set,
639+ * Pages being prepped should not have these flags set. It they are set,
640640 * there has been a kernel bug or struct page corruption.
641+ *
642+ * __PG_HWPOISON is exceptional because it needs to be kept beyond page's
643+ * alloc-free cycle to prevent from reusing the page.
641644 */
642−#define PAGE_FLAGS_CHECK_AT_PREP ((1 << NR_PAGEFLAGS) - 1)
645+#define PAGE_FLAGS_CHECK_AT_PREP \
646+ (((1 << NR_PAGEFLAGS) - 1) & ~__PG_HWPOISON)
643647
644648 #define PAGE_FLAGS_PRIVATE \
645649 (1 << PG_private | 1 << PG_private_2)
include/linux/platform_data/macb.h+11−3
@@ -8,11 +8,19 @@ · 7 unmodified lines
88 #ifndef __MACB_PDATA_H__
99 #define __MACB_PDATA_H__
1010
11+/**
12+ * struct macb_platform_data - platform data for MACB Ethernet
13+ * @phy_mask: phy mask passed when register the MDIO bus
14+ * within the driver
15+ * @phy_irq_pin: PHY IRQ
16+ * @is_rmii: using RMII interface?
17+ * @rev_eth_addr: reverse Ethernet address byte order
18+ */
1119 struct macb_platform_data {
1220 u32 phy_mask;
13− int phy_irq_pin; /* PHY IRQ */
14− u8 is_rmii; /* using RMII interface? */
15− u8 rev_eth_addr; /* reverse Ethernet address byte order */
21+ int phy_irq_pin;
22+ u8 is_rmii;
23+ u8 rev_eth_addr;
1624 };
1725
1826 #endif /* __MACB_PDATA_H__ */
include/linux/skbuff.h+3−3
@@ -2884,11 +2884,11 @@ static inline bool skb_defer_rx_timestamp(struct sk_buff *skb) · 2883 unmodified lines
28842884 *
28852885 * PHY drivers may accept clones of transmitted packets for
28862886 * timestamping via their phy_driver.txtstamp method. These drivers
2887− * must call this function to return the skb back to the stack, with
2888− * or without a timestamp.
2887+ * must call this function to return the skb back to the stack with a
2888+ * timestamp.
28892889 *
28902890 * @skb: clone of the the original outgoing packet

5 more lines aren’t shown here.

include/net/act_api.h+7−1

This diff is large: its 22 lines aren’t shown here.

include/net/inet_frag.h+11−6

This diff is large: its 61 lines aren’t shown here.

include/net/ip_fib.h+1−2

This diff is large: its 17 lines aren’t shown here.

include/net/netfilter/nf_conntrack.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/net/netns/conntrack.h+0−1

This diff is large: its 8 lines aren’t shown here.

include/net/sock.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/scsi/scsi_eh.h+0−1

This diff is large: its 8 lines aren’t shown here.

include/target/iscsi/iscsi_target_core.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/uapi/drm/amdgpu_drm.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/uapi/drm/radeon_drm.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/uapi/linux/pci_regs.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/uapi/sound/asoc.h+26−13

This diff is large: its 118 lines aren’t shown here.

init/main.c+1−1

This diff is large: its 9 lines aren’t shown here.

ipc/mqueue.c+0−5

This diff is large: its 40 lines aren’t shown here.

ipc/sem.c+35−12

This diff is large: its 91 lines aren’t shown here.

ipc/shm.c+1−1

This diff is large: its 9 lines aren’t shown here.

kernel/cpuset.c+1−1

This diff is large: its 9 lines aren’t shown here.

kernel/kthread.c+4−0

This diff is large: its 32 lines aren’t shown here.

kernel/locking/qspinlock_paravirt.h+10−1

This diff is large: its 33 lines aren’t shown here.

kernel/module.c+6−2

This diff is large: its 27 lines aren’t shown here.

kernel/signal.c+8−5

This diff is large: its 37 lines aren’t shown here.

lib/iommu-common.c+1−1

This diff is large: its 9 lines aren’t shown here.

mm/cma.h+1−1

This diff is large: its 9 lines aren’t shown here.

mm/huge_memory.c+1−6

This diff is large: its 14 lines aren’t shown here.

mm/kasan/kasan.c+1−1

This diff is large: its 9 lines aren’t shown here.

mm/kasan/report.c+1−1

This diff is large: its 9 lines aren’t shown here.

mm/memory-failure.c+31−23

This diff is large: its 104 lines aren’t shown here.

mm/memory_hotplug.c+12−1

This diff is large: its 41 lines aren’t shown here.

mm/migrate.c+6−2

This diff is large: its 22 lines aren’t shown here.

mm/page-writeback.c+2−2

This diff is large: its 13 lines aren’t shown here.

mm/page_alloc.c+38−15

This diff is large: its 128 lines aren’t shown here.

mm/shmem.c+2−2

This diff is large: its 11 lines aren’t shown here.

mm/slab_common.c+1−2

This diff is large: its 10 lines aren’t shown here.

mm/vmscan.c+6−10

This diff is large: its 37 lines aren’t shown here.

net/batman-adv/distributed-arp-table.c+13−5

This diff is large: its 41 lines aren’t shown here.

net/batman-adv/gateway_client.c+2−0

This diff is large: its 9 lines aren’t shown here.

net/batman-adv/soft-interface.c+3−0

This diff is large: its 10 lines aren’t shown here.

net/batman-adv/translation-table.c+24−5

This diff is large: its 68 lines aren’t shown here.

net/bluetooth/mgmt.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/bluetooth/smp.c+4−0

This diff is large: its 11 lines aren’t shown here.

net/bridge/br_forward.c+22−7

This diff is large: its 38 lines aren’t shown here.

net/bridge/br_mdb.c+1−0

This diff is large: its 8 lines aren’t shown here.

net/bridge/br_multicast.c+26−24

This diff is large: its 71 lines aren’t shown here.

net/bridge/br_netlink.c+13−1

This diff is large: its 37 lines aren’t shown here.

net/bridge/br_stp.c+3−2

This diff is large: its 12 lines aren’t shown here.

net/bridge/br_stp_if.c+12−1

This diff is large: its 47 lines aren’t shown here.

net/bridge/br_stp_timer.c+3−1

This diff is large: its 11 lines aren’t shown here.

net/core/datagram.c+7−6

This diff is large: its 45 lines aren’t shown here.

net/core/netclassid_cgroup.c+2−1

This diff is large: its 10 lines aren’t shown here.

net/core/pktgen.c+0−3

This diff is large: its 17 lines aren’t shown here.

net/core/request_sock.c+7−1

This diff is large: its 18 lines aren’t shown here.

net/core/sock.c+5−3

This diff is large: its 34 lines aren’t shown here.

net/dccp/proto.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/dsa/slave.c+2−1

This diff is large: its 10 lines aren’t shown here.

net/ieee802154/6lowpan/reassembly.c+3−3

This diff is large: its 27 lines aren’t shown here.

net/ipv4/arp.c+9−7

This diff is large: its 24 lines aren’t shown here.

net/ipv4/devinet.c+0−1

This diff is large: its 8 lines aren’t shown here.

net/ipv4/fib_lookup.h+1−0

This diff is large: its 8 lines aren’t shown here.

net/ipv4/fib_semantics.c+30−11

This diff is large: its 86 lines aren’t shown here.

net/ipv4/fib_trie.c+2−5

This diff is large: its 42 lines aren’t shown here.

net/ipv4/inet_connection_sock.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/ipv4/inet_fragment.c+15−25

This diff is large: its 106 lines aren’t shown here.

net/ipv4/ip_fragment.c+6−6

This diff is large: its 54 lines aren’t shown here.

net/ipv4/netfilter/ipt_SYNPROXY.c+2−1

This diff is large: its 10 lines aren’t shown here.

net/ipv4/route.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/ipv4/tcp.c+7−4

This diff is large: its 40 lines aren’t shown here.

net/ipv4/tcp_ipv4.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/ipv4/udp.c+10−3

This diff is large: its 23 lines aren’t shown here.

net/ipv6/ndisc.c+6−0

This diff is large: its 20 lines aren’t shown here.

net/ipv6/netfilter/ip6t_SYNPROXY.c+11−8

This diff is large: its 72 lines aren’t shown here.

net/ipv6/netfilter/nf_conntrack_reasm.c+3−3

This diff is large: its 27 lines aren’t shown here.

net/ipv6/reassembly.c+4−4

This diff is large: its 36 lines aren’t shown here.

net/ipv6/route.c+4−2

This diff is large: its 23 lines aren’t shown here.

net/ipv6/tcp_ipv6.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/llc/af_llc.c+2−2

This diff is large: its 18 lines aren’t shown here.

net/netfilter/ipvs/ip_vs_core.c+14−2

This diff is large: its 30 lines aren’t shown here.

net/netfilter/ipvs/ip_vs_ctl.c+49−29

This diff is large: its 185 lines aren’t shown here.

net/netfilter/ipvs/ip_vs_sched.c+6−6

This diff is large: its 36 lines aren’t shown here.

net/netfilter/ipvs/ip_vs_sync.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/netfilter/ipvs/ip_vs_xmit.c+40−1

This diff is large: its 94 lines aren’t shown here.

net/netfilter/nf_conntrack_core.c+45−26

This diff is large: its 107 lines aren’t shown here.

net/netfilter/nf_conntrack_expect.c+2−1

This diff is large: its 10 lines aren’t shown here.

net/netfilter/nf_conntrack_netlink.c+0−5

This diff is large: its 12 lines aren’t shown here.

net/netfilter/nf_synproxy_core.c+4−7

This diff is large: its 28 lines aren’t shown here.

net/netfilter/xt_CT.c+6−7

This diff is large: its 35 lines aren’t shown here.

net/netfilter/xt_IDLETIMER.c+1−0

This diff is large: its 8 lines aren’t shown here.

net/netlink/af_netlink.c+5−0

This diff is large: its 12 lines aren’t shown here.

net/openvswitch/actions.c+12−4

This diff is large: its 41 lines aren’t shown here.

net/packet/af_packet.c+5−6

This diff is large: its 37 lines aren’t shown here.

net/rds/info.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/sched/act_api.c+6−5

This diff is large: its 48 lines aren’t shown here.

net/sched/act_bpf.c+35−18

This diff is large: its 111 lines aren’t shown here.

net/sched/act_mirred.c+2−0

This diff is large: its 9 lines aren’t shown here.

net/sched/act_pedit.c+2−3

This diff is large: its 16 lines aren’t shown here.

net/sched/sch_choke.c+13−0

This diff is large: its 20 lines aren’t shown here.

net/sched/sch_fq_codel.c+19−3

This diff is large: its 30 lines aren’t shown here.

net/sched/sch_plug.c+1−0

This diff is large: its 8 lines aren’t shown here.

net/sctp/socket.c+0−6

This diff is large: its 13 lines aren’t shown here.

net/sunrpc/backchannel_rqst.c+3−3

This diff is large: its 20 lines aren’t shown here.

net/sunrpc/clnt.c+3−2

This diff is large: its 31 lines aren’t shown here.

net/sunrpc/xprtsock.c+17−8

This diff is large: its 74 lines aren’t shown here.

scripts/kconfig/streamline_config.pl+1−1

This diff is large: its 9 lines aren’t shown here.

security/keys/keyring.c+5−3

This diff is large: its 15 lines aren’t shown here.

security/yama/yama_lsm.c+1−0

This diff is large: its 8 lines aren’t shown here.

sound/firewire/amdtp.c+3−2

This diff is large: its 12 lines aren’t shown here.

sound/firewire/amdtp.h+2−0

This diff is large: its 9 lines aren’t shown here.

sound/firewire/fireworks/fireworks.c+8−0

This diff is large: its 17 lines aren’t shown here.

sound/firewire/fireworks/fireworks.h+1−0

This diff is large: its 8 lines aren’t shown here.

sound/firewire/fireworks/fireworks_stream.c+9−0

This diff is large: its 16 lines aren’t shown here.

sound/hda/ext/hdac_ext_controller.c+0−6

This diff is large: its 17 lines aren’t shown here.

sound/hda/ext/hdac_ext_stream.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/pci/hda/hda_intel.c+3−3

This diff is large: its 27 lines aren’t shown here.

sound/pci/hda/patch_cirrus.c+1−3

This diff is large: its 11 lines aren’t shown here.

sound/pci/hda/patch_realtek.c+36−5

This diff is large: its 81 lines aren’t shown here.

sound/pci/hda/patch_sigmatel.c+2−1

This diff is large: its 10 lines aren’t shown here.

sound/pci/oxygen/oxygen_mixer.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/codecs/cs4265.c+5−5

This diff is large: its 28 lines aren’t shown here.

sound/soc/codecs/pcm1681.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/codecs/rt5645.c+5−0

This diff is large: its 19 lines aren’t shown here.

sound/soc/codecs/rt5645.h+4−0

This diff is large: its 11 lines aren’t shown here.

sound/soc/codecs/sgtl5000.h+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/codecs/ssm4567.c+7−1

This diff is large: its 15 lines aren’t shown here.

sound/soc/fsl/fsl_ssi.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/intel/Makefile+1−1

This diff is large: its 6 lines aren’t shown here.

sound/soc/intel/atom/sst/sst_drv_interface.c+7−7

This diff is large: its 37 lines aren’t shown here.

sound/soc/intel/baytrail/sst-baytrail-ipc.c+2−0

This diff is large: its 9 lines aren’t shown here.

sound/soc/intel/boards/cht_bsw_max98090_ti.c+2−2

This diff is large: its 15 lines aren’t shown here.

sound/soc/intel/haswell/sst-haswell-ipc.c+2−0

This diff is large: its 9 lines aren’t shown here.

sound/soc/mediatek/mt8173-max98090.c+13−4

This diff is large: its 47 lines aren’t shown here.

sound/soc/mediatek/mt8173-rt5650-rt5676.c+15−4

This diff is large: its 47 lines aren’t shown here.

sound/soc/mediatek/mtk-afe-pcm.c+2−0

This diff is large: its 9 lines aren’t shown here.

sound/soc/soc-core.c+1−0

This diff is large: its 8 lines aren’t shown here.

sound/soc/soc-dapm.c+18−17

This diff is large: its 116 lines aren’t shown here.

sound/soc/soc-topology.c+43−19

This diff is large: its 111 lines aren’t shown here.

sound/soc/zte/zx296702-i2s.c+2−2

This diff is large: its 12 lines aren’t shown here.

sound/soc/zte/zx296702-spdif.c+2−2

This diff is large: its 12 lines aren’t shown here.

sound/usb/mixer_maps.c+24−0

This diff is large: its 38 lines aren’t shown here.

tools/perf/builtin-record.c+11−0

This diff is large: its 28 lines aren’t shown here.

tools/perf/builtin-top.c+2−2

This diff is large: its 11 lines aren’t shown here.

tools/perf/util/machine.c+18−2

This diff is large: its 34 lines aren’t shown here.

tools/perf/util/thread.c+6−0

This diff is large: its 13 lines aren’t shown here.

tools/testing/selftests/futex/functional/futex_requeue_pi_signal_restart.c+1−1

This diff is large: its 9 lines aren’t shown here.