History

Merge remote-tracking branch 'djwong/ocfs2-vfs-reflink-6' into for-linus

Al Viro committed 9 years ago

Commit 3c55d6b2 parents 4da00fd 29ac8e8208 files · +2175 −903Browse files

Unified · Split

208 files
  1. CREDITS +4 −4
  2. Documentation/devicetree/bindings/net/ethernet.txt +20 −4
  3. Documentation/networking/nf_conntrack-sysctl.txt +5 −2
  4. MAINTAINERS +4 −9
  5. Makefile +9 −4
  6. arch/arc/include/asm/delay.h +5 −4
  7. arch/arc/include/asm/pgtable.h +1 −1
  8. arch/arc/mm/cache.c +1 −1
  9. arch/arm/boot/dts/Makefile +1 −1
  10. arch/arm/boot/dts/stih407-family.dtsi +16 −0
  11. arch/arm/boot/dts/sun5i-gr8-evb.dts +1 −1
  12. arch/arm/boot/dts/sun5i-gr8.dtsi +0 −0
  13. arch/arm64/boot/dts/arm/juno-base.dtsi +1 −1
  14. arch/arm64/boot/dts/arm/juno-r1.dts +1 −1
  15. arch/arm64/boot/dts/arm/juno-r2.dts +1 −1
  16. arch/arm64/boot/dts/arm/juno.dts +1 −1
  17. drivers/ata/ahci.c +0 −7
  18. drivers/ata/libata-scsi.c +1 −1
  19. drivers/block/zram/zram_drv.c +2 −1
  20. drivers/clk/bcm/Kconfig +1 −1
  21. drivers/clk/sunxi-ng/ccu-sun6i-a31.c +1 −1
  22. drivers/clk/sunxi-ng/ccu-sun8i-a33.c +1 −1
  23. drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c +9 −2
  24. drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c +4 −1
  25. drivers/gpu/drm/arm/hdlcd_drv.c +1 −1
  26. drivers/gpu/drm/drm_ioctl.c +6 −4
  27. drivers/gpu/drm/i915/i915_gem.c +3 −2
  28. drivers/gpu/drm/i915/intel_display.c +2 −1
  29. drivers/gpu/drm/radeon/radeon_atpx_handler.c +9 −2
  30. drivers/i2c/busses/i2c-octeon-core.c +1 −3
  31. drivers/i2c/busses/i2c-octeon-core.h +11 −16
  32. drivers/input/mouse/psmouse-base.c +0 −4
  33. drivers/net/can/usb/peak_usb/pcan_ucan.h +29 −8
  34. drivers/net/can/usb/peak_usb/pcan_usb_core.c +2 −0
  35. drivers/net/can/usb/peak_usb/pcan_usb_core.h +2 −0
  36. drivers/net/can/usb/peak_usb/pcan_usb_fd.c +88 −16
  37. drivers/net/ethernet/altera/altera_tse_main.c +8 −13
  38. drivers/net/ethernet/amd/xgbe/xgbe-main.c +2 −2
  39. drivers/net/ethernet/aurora/nb8800.c +7 −2
  40. drivers/net/ethernet/broadcom/bcmsysport.c +12 −5
  41. drivers/net/ethernet/broadcom/genet/bcmgenet.c +5 −3
  42. drivers/net/ethernet/broadcom/genet/bcmmii.c +9 −1
  43. drivers/net/ethernet/cadence/macb.c +3 −2
  44. drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h +1 −0
  45. drivers/net/ethernet/freescale/fec.h +2 −0
  46. drivers/net/ethernet/freescale/fec_main.c +24 −4
  47. drivers/net/ethernet/freescale/fman/fman_memac.c +3 −0
  48. drivers/net/ethernet/freescale/fman/mac.c +2 −0
  49. drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +6 −1
  50. drivers/net/ethernet/freescale/gianfar.c +8 −0
  51. drivers/net/ethernet/freescale/ucc_geth.c +16 −7
  52. drivers/net/ethernet/intel/igb/igb_main.c +6 −2
  53. drivers/net/ethernet/intel/igbvf/netdev.c +6 −2
  54. drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +6 −2
  55. drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +6 −2
  56. drivers/net/ethernet/marvell/mvneta.c +5 −0
  57. drivers/net/ethernet/mediatek/mtk_eth_soc.c +4 −0
  58. drivers/net/ethernet/mellanox/mlx4/en_netdev.c +2 −15
  59. drivers/net/ethernet/mellanox/mlx4/main.c +1 −4
  60. drivers/net/ethernet/mellanox/mlx4/mcg.c +6 −1
  61. drivers/net/ethernet/qualcomm/emac/emac-phy.c +1 −0
  62. drivers/net/ethernet/qualcomm/emac/emac.c +4 −0
  63. drivers/net/ethernet/renesas/ravb_main.c +14 −5
  64. drivers/net/ethernet/renesas/sh_eth.c +1 −1
  65. drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c +15 −2
  66. drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c +19 −6
  67. drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c +14 −3
  68. drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c +18 −5
  69. drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +24 −8
  70. drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +17 −4
  71. drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +26 −13
  72. drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +18 −5
  73. drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c +14 −5
  74. drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c +19 −7
  75. drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 −1
  76. drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +29 −4
  77. drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +2 −0
  78. drivers/net/ethernet/synopsys/dwc_eth_qos.c +13 −7
  79. drivers/net/ethernet/ti/cpsw.c +6 −14
  80. drivers/net/ethernet/ti/davinci_emac.c +9 −1
  81. drivers/net/geneve.c +4 −10
  82. drivers/net/ipvlan/ipvlan_main.c +12 −5
  83. drivers/net/irda/w83977af_ir.c +3 −1
  84. drivers/net/macvtap.c +12 −7
  85. drivers/net/phy/realtek.c +12 −8
  86. drivers/net/tun.c +4 −6
  87. drivers/net/usb/asix_devices.c +3 −3
  88. drivers/net/usb/cdc_ether.c +31 −7
  89. drivers/net/usb/qmi_wwan.c +1 −0
  90. drivers/net/vxlan.c +7 −3
  91. drivers/net/wireless/marvell/mwifiex/cfg80211.c +7 −6
  92. drivers/of/of_mdio.c +15 −0
  93. drivers/pci/host/pcie-designware-plat.c +1 −1
  94. drivers/pci/pcie/aer/aer_inject.c +0 −14
  95. drivers/pci/probe.c +27 −1
  96. drivers/pwm/pwm-meson.c +1 −0
  97. drivers/pwm/sysfs.c +2 −0
  98. drivers/scsi/be2iscsi/be_mgmt.c +1 −1
  99. drivers/scsi/hpsa.c +11 −5
  100. drivers/scsi/hpsa.h +2 −0
  101. drivers/scsi/libfc/fc_lport.c +1 −1
  102. drivers/scsi/mpt3sas/mpt3sas_scsih.c +8 −5
  103. drivers/scsi/mvsas/mv_sas.c +3 −1
  104. drivers/scsi/qlogicpti.h +2 −2
  105. fs/btrfs/ctree.h +0 −3
  106. fs/btrfs/file.c +0 −1
  107. fs/btrfs/ioctl.c +0 −12
  108. fs/cifs/cifsencrypt.c +8 −3
  109. fs/cifs/cifssmb.c +2 −2
  110. fs/cifs/connect.c +18 −7
  111. fs/isofs/rock.c +2 −2
  112. fs/ocfs2/alloc.c +3 −4
  113. fs/ocfs2/aops.c +20 −11
  114. fs/ocfs2/file.c +35 −7
  115. fs/ocfs2/file.h +3 −0
  116. fs/ocfs2/inode.h +6 −0
  117. fs/ocfs2/move_extents.c +2 −8
  118. fs/ocfs2/refcounttree.c +451 −13
  119. fs/ocfs2/refcounttree.h +7 −0
  120. fs/ocfs2/xattr.c +2 −2
  121. fs/overlayfs/super.c +3 −3
  122. fs/read_write.c +226 −5
  123. fs/xfs/xfs_file.c +0 −19
  124. fs/xfs/xfs_reflink.c +9 −204
  125. include/asm-generic/export.h +1 −0
  126. include/linux/compiler-gcc.h +3 −1
  127. include/linux/fs.h +6 −0
  128. include/linux/mlx4/device.h +0 −1
  129. include/linux/of_mdio.h +4 −0
  130. include/linux/pagemap.h +15 −6
  131. include/linux/pci.h +14 −0
  132. include/net/ipv6.h +2 −0
  133. include/net/netfilter/nf_conntrack.h +3 −3
  134. include/net/netfilter/nf_tables.h +1 −1
  135. include/uapi/linux/input-event-codes.h +1 −1
  136. include/uapi/linux/tc_act/Kbuild +1 −0
  137. init/Kconfig +0 −1
  138. kernel/bpf/verifier.c +8 −2
  139. kernel/module.c +3 −2
  140. lib/debugobjects.c +8 −0
  141. lib/test_kasan.c +29 −0
  142. mm/huge_memory.c +2 −2
  143. mm/kasan/kasan.c +19 −0
  144. mm/kasan/kasan.h +4 −0
  145. mm/kasan/report.c +3 −0
  146. mm/khugepaged.c +2 −0
  147. mm/mlock.c +5 −2
  148. mm/mremap.c +8 −4
  149. mm/truncate.c +4 −4
  150. mm/vmscan.c +2 −0
  151. mm/workingset.c +1 −1
  152. net/core/flow.c +2 −4
  153. net/core/rtnetlink.c +2 −2
  154. net/core/sock.c +2 −2
  155. net/dccp/ipv4.c +7 −5
  156. net/dsa/dsa.c +4 −9
  157. net/dsa/dsa2.c +3 −1
  158. net/dsa/slave.c +16 −3
  159. net/ipv4/Kconfig +1 −0
  160. net/ipv4/af_inet.c +1 −1
  161. net/ipv4/esp4.c +1 −1
  162. net/ipv4/ip_output.c +2 −0
  163. net/ipv4/netfilter.c +4 −1
  164. net/ipv4/netfilter/arp_tables.c +2 −2
  165. net/ipv6/datagram.c +3 −1
  166. net/ipv6/esp6.c +1 −1
  167. net/ipv6/icmp.c +4 −2
  168. net/ipv6/ip6_offload.c +1 −1
  169. net/ipv6/ip6_tunnel.c +0 −1
  170. net/ipv6/ip6_vti.c +31 −0
  171. net/ipv6/netfilter/nf_conntrack_reasm.c +2 −2
  172. net/ipv6/netfilter/nf_defrag_ipv6_hooks.c +1 −1
  173. net/ipv6/netfilter/nf_reject_ipv6.c +1 −0
  174. net/ipv6/output_core.c +2 −0
  175. net/l2tp/l2tp_ip.c +34 −29
  176. net/l2tp/l2tp_ip6.c +42 −37
  177. net/netfilter/nf_nat_core.c +30 −19
  178. net/netfilter/nf_tables_api.c +9 −5
  179. net/netfilter/nft_hash.c +5 −2
  180. net/netfilter/nft_range.c +6 −0
  181. net/netlink/af_netlink.c +23 −4
  182. net/netlink/af_netlink.h +2 −0
  183. net/openvswitch/conntrack.c +4 −1
  184. net/packet/af_packet.c +12 −6
  185. net/rds/tcp.c +2 −0
  186. net/sched/act_pedit.c +20 −4
  187. net/sched/cls_basic.c +0 −4
  188. net/sched/cls_bpf.c +0 −4
  189. net/sched/cls_cgroup.c +3 −4
  190. net/sched/cls_flow.c +0 −1
  191. net/sched/cls_flower.c +32 −9
  192. net/sched/cls_matchall.c +0 −1
  193. net/sched/cls_rsvp.h +2 −1
  194. net/sched/cls_tcindex.c +0 −1
  195. net/tipc/bearer.c +9 −2
  196. net/tipc/bearer.h +13 −0
  197. net/tipc/link.c +19 −16
  198. net/tipc/udp_media.c +5 −0
  199. net/xfrm/xfrm_policy.c +6 −4
  200. net/xfrm/xfrm_user.c +1 −1
  201. samples/bpf/bpf_helpers.h +1 −1
  202. samples/bpf/sampleip_kern.c +1 −1
  203. samples/bpf/trace_event_kern.c +1 −1
  204. scripts/kconfig/Makefile +2 −0
  205. sound/sparc/dbri.c +16 −10
  206. virt/kvm/arm/vgic/vgic-v2.c +4 −2
  207. virt/kvm/arm/vgic/vgic-v3.c +4 −2
  208. virt/kvm/kvm_main.c +1 −1
CREDITS+4−4
@@ -9,7 +9,7 @@ · 8 unmodified lines
99 Linus
1010 ----------
1111
12−M: Matt Mackal
12+N: Matt Mackal
1313 E: mpm@selenic.com
1414 D: SLOB slab allocator
1515
@@ -1910,7 +1910,7 @@ S: Ra'annana, Israel · 1894 unmodified lines
19101910
19111911 N: Andi Kleen
19121912 E: andi@firstfloor.org
1913−U: http://www.halobates.de
1913+W: http://www.halobates.de
19141914 D: network, x86, NUMA, various hacks
19151915 S: Schwalbenstr. 96
19161916 S: 85551 Ottobrunn
@@ -2089,8 +2089,8 @@ D: ST Microelectronics SPEAr13xx PCI host bridge driver · 172 unmodified lines
20892089 D: Synopsys Designware PCI host bridge driver
20902090
20912091 N: Gabor Kuti
2092−M: seasons@falcon.sch.bme.hu
2093−M: seasons@makosteszta.sote.hu
2092+E: seasons@falcon.sch.bme.hu
2093+E: seasons@makosteszta.sote.hu
20942094 D: Original author of software suspend
20952095
20962096 N: Jaroslav Kysela
Documentation/devicetree/bindings/net/ethernet.txt+20−4
@@ -9,10 +9,26 @@ The following properties are common to the Ethernet controllers: · 8 unmodified lines
99 - max-speed: number, specifies maximum speed in Mbit/s supported by the device;
1010 - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than
1111 the maximum frame size (there's contradiction in ePAPR).
12−- phy-mode: string, operation mode of the PHY interface; supported values are
13− "mii", "gmii", "sgmii", "qsgmii", "tbi", "rev-mii", "rmii", "rgmii", "rgmii-id",
14− "rgmii-rxid", "rgmii-txid", "rtbi", "smii", "xgmii", "trgmii"; this is now a
15− de-facto standard property;
12+- phy-mode: string, operation mode of the PHY interface. This is now a de-facto
13+ standard property; supported values are:
14+ * "mii"
15+ * "gmii"
16+ * "sgmii"
17+ * "qsgmii"
18+ * "tbi"
19+ * "rev-mii"
20+ * "rmii"
21+ * "rgmii" (RX and TX delays are added by the MAC when required)
22+ * "rgmii-id" (RGMII with internal RX and TX delays provided by the PHY, the
23+ MAC should not add the RX or TX delays in this case)
24+ * "rgmii-rxid" (RGMII with internal RX delay provided by the PHY, the MAC
25+ should not add an RX delay in this case)
26+ * "rgmii-txid" (RGMII with internal TX delay provided by the PHY, the MAC
27+ should not add an TX delay in this case)
28+ * "rtbi"
29+ * "smii"
30+ * "xgmii"
31+ * "trgmii"
1632 - phy-connection-type: the same as "phy-mode" property but described in ePAPR;
1733 - phy-handle: phandle, specifies a reference to a node representing a PHY
1834 device; this property is described in ePAPR and so preferred;
Documentation/networking/nf_conntrack-sysctl.txt+5−2
@@ -62,10 +62,13 @@ nf_conntrack_generic_timeout - INTEGER (seconds) · 61 unmodified lines
6262 protocols.
6363
6464 nf_conntrack_helper - BOOLEAN
65− 0 - disabled
66− not 0 - enabled (default)
65+ 0 - disabled (default)
66+ not 0 - enabled
6767
6868 Enable automatic conntrack helper assignment.
69+ If disabled it is required to set up iptables rules to assign
70+ helpers to connections. See the CT target description in the
71+ iptables-extensions(8) man page for further information.
6972
7073 nf_conntrack_icmp_timeout - INTEGER (seconds)
7174 default 30
MAINTAINERS+4−9
@@ -9257,11 +9257,12 @@ S: Maintained · 9256 unmodified lines
92579257 F: drivers/pci/host/*layerscape*
92589258
92599259 PCI DRIVER FOR IMX6
9260−M: Richard Zhu <Richard.Zhu@freescale.com>
9260+M: Richard Zhu <hongxing.zhu@nxp.com>
92619261 M: Lucas Stach <l.stach@pengutronix.de>
92629262 L: linux-pci@vger.kernel.org
92639263 L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
92649264 S: Maintained
9265+F: Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
92659266 F: drivers/pci/host/*imx6*
92669267
92679268 PCI DRIVER FOR TI KEYSTONE
@@ -9320,17 +9321,11 @@ F: drivers/pci/host/pci-exynos.c · 52 unmodified lines
93209321
93219322 PCI DRIVER FOR SYNOPSIS DESIGNWARE
93229323 M: Jingoo Han <jingoohan1@gmail.com>
9323−M: Pratyush Anand <pratyush.anand@gmail.com>
9324−L: linux-pci@vger.kernel.org
9325−S: Maintained
9326−F: drivers/pci/host/*designware*
9327−
9328−PCI DRIVER FOR SYNOPSYS PROTOTYPING DEVICE
9329−M: Jose Abreu <Jose.Abreu@synopsys.com>
9324+M: Joao Pinto <Joao.Pinto@synopsys.com>
93309325 L: linux-pci@vger.kernel.org
93319326 S: Maintained
93329327 F: Documentation/devicetree/bindings/pci/designware-pcie.txt
9333−F: drivers/pci/host/pcie-designware-plat.c
9328+F: drivers/pci/host/*designware*
93349329
93359330 PCI DRIVER FOR GENERIC OF HOSTS
93369331 M: Will Deacon <will.deacon@arm.com>
Makefile+9−4
@@ -1,7 +1,7 @@
11 VERSION = 4
22 PATCHLEVEL = 9
33 SUBLEVEL = 0
4−EXTRAVERSION = -rc7
4+EXTRAVERSION = -rc8
55 NAME = Psychotic Stoned Sheep
66
77 # *DOCUMENTATION*
@@ -607,6 +607,13 @@ else · 599 unmodified lines
607607 include/config/auto.conf: ;
608608 endif # $(dot-config)
609609
610+# For the kernel to actually contain only the needed exported symbols,
611+# we have to build modules as well to determine what those symbols are.
612+# (this can be evaluated only once include/config/auto.conf has been included)
613+ifdef CONFIG_TRIM_UNUSED_KSYMS
614+ KBUILD_MODULES := 1
615+endif
616+
610617 # The all: target is the default when no target is given on the
611618 # command line.
612619 # This allow a user to issue only 'make' to build a kernel including modules
@@ -944,7 +951,7 @@ ifdef CONFIG_GDB_SCRIPTS · 331 unmodified lines
944951 endif
945952 ifdef CONFIG_TRIM_UNUSED_KSYMS
946953 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
947− "$(MAKE) KBUILD_MODULES=1 -f $(srctree)/Makefile vmlinux_prereq"
954+ "$(MAKE) -f $(srctree)/Makefile vmlinux"
948955 endif
949956
950957 # standalone target for easier testing
@@ -1019,8 +1026,6 @@ prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic · 68 unmodified lines
10191026 prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
10201027 include/config/auto.conf
10211028 $(cmd_crmodverdir)
1022− $(Q)test -e include/generated/autoksyms.h || \
1023− touch include/generated/autoksyms.h
10241029
10251030 archprepare: archheaders archscripts prepare1 scripts_basic
10261031
arch/arc/include/asm/delay.h+5−4
@@ -22,10 +22,11 @@ · 21 unmodified lines
2222 static inline void __delay(unsigned long loops)
2323 {
2424 __asm__ __volatile__(
25− " lp 1f \n"
26− " nop \n"
27− "1: \n"
28− : "+l"(loops));
25+ " mov lp_count, %0 \n"
26+ " lp 1f \n"
27+ " nop \n"
28+ "1: \n"
29+ : : "r"(loops));
2930 }
3031
3132 extern void __bad_udelay(void);
arch/arc/include/asm/pgtable.h+1−1
@@ -280,7 +280,7 @@ static inline void pmd_set(pmd_t *pmdp, pte_t *ptep) · 279 unmodified lines
280280
281281 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
282282 #define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot)
283−#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
283+#define pfn_pte(pfn, prot) __pte(__pfn_to_phys(pfn) | pgprot_val(prot))
284284
285285 /* Don't use virt_to_pfn for macros below: could cause truncations for PAE40*/
286286 #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT)
arch/arc/mm/cache.c+1−1
@@ -23,7 +23,7 @@ · 22 unmodified lines
2323
2424 static int l2_line_sz;
2525 static int ioc_exists;
26−int slc_enable = 1, ioc_enable = 1;
26+int slc_enable = 1, ioc_enable = 0;
2727 unsigned long perip_base = ARC_UNCACHED_ADDR_SPACE; /* legacy value for boot */
2828 unsigned long perip_end = 0xFFFFFFFF; /* legacy value */
2929
arch/arm/boot/dts/Makefile+1−1
@@ -745,7 +745,6 @@ dtb-$(CONFIG_MACH_SUN4I) += \ · 744 unmodified lines
745745 sun4i-a10-pcduino2.dtb \
746746 sun4i-a10-pov-protab2-ips9.dtb
747747 dtb-$(CONFIG_MACH_SUN5I) += \
748− ntc-gr8-evb.dtb \
749748 sun5i-a10s-auxtek-t003.dtb \
750749 sun5i-a10s-auxtek-t004.dtb \
751750 sun5i-a10s-mk802.dtb \
@@ -761,6 +760,7 @@ dtb-$(CONFIG_MACH_SUN5I) += \ · 9 unmodified lines
761760 sun5i-a13-olinuxino-micro.dtb \
762761 sun5i-a13-q8-tablet.dtb \
763762 sun5i-a13-utoo-p66.dtb \
763+ sun5i-gr8-evb.dtb \
764764 sun5i-r8-chip.dtb
765765 dtb-$(CONFIG_MACH_SUN6I) += \
766766 sun6i-a31-app4-evb1.dtb \
arch/arm/boot/dts/stih407-family.dtsi+16−0
@@ -283,6 +283,8 @@ · 282 unmodified lines
283283 clock-frequency = <400000>;
284284 pinctrl-names = "default";
285285 pinctrl-0 = <&pinctrl_i2c0_default>;
286+ #address-cells = <1>;
287+ #size-cells = <0>;
286288
287289 status = "disabled";
288290 };
@@ -296,6 +298,8 @@ · 7 unmodified lines
296298 clock-frequency = <400000>;
297299 pinctrl-names = "default";
298300 pinctrl-0 = <&pinctrl_i2c1_default>;
301+ #address-cells = <1>;
302+ #size-cells = <0>;
299303
300304 status = "disabled";
301305 };
@@ -309,6 +313,8 @@ · 7 unmodified lines
309313 clock-frequency = <400000>;
310314 pinctrl-names = "default";
311315 pinctrl-0 = <&pinctrl_i2c2_default>;
316+ #address-cells = <1>;
317+ #size-cells = <0>;
312318
313319 status = "disabled";
314320 };
@@ -322,6 +328,8 @@ · 7 unmodified lines
322328 clock-frequency = <400000>;
323329 pinctrl-names = "default";
324330 pinctrl-0 = <&pinctrl_i2c3_default>;
331+ #address-cells = <1>;
332+ #size-cells = <0>;
325333
326334 status = "disabled";
327335 };
@@ -335,6 +343,8 @@ · 7 unmodified lines
335343 clock-frequency = <400000>;
336344 pinctrl-names = "default";
337345 pinctrl-0 = <&pinctrl_i2c4_default>;
346+ #address-cells = <1>;
347+ #size-cells = <0>;
338348
339349 status = "disabled";
340350 };
@@ -348,6 +358,8 @@ · 7 unmodified lines
348358 clock-frequency = <400000>;
349359 pinctrl-names = "default";
350360 pinctrl-0 = <&pinctrl_i2c5_default>;
361+ #address-cells = <1>;
362+ #size-cells = <0>;
351363
352364 status = "disabled";
353365 };
@@ -363,6 +375,8 @@ · 9 unmodified lines
363375 clock-frequency = <400000>;
364376 pinctrl-names = "default";
365377 pinctrl-0 = <&pinctrl_i2c10_default>;
378+ #address-cells = <1>;
379+ #size-cells = <0>;
366380
367381 status = "disabled";
368382 };
@@ -376,6 +390,8 @@ · 7 unmodified lines
376390 clock-frequency = <400000>;
377391 pinctrl-names = "default";
378392 pinctrl-0 = <&pinctrl_i2c11_default>;
393+ #address-cells = <1>;
394+ #size-cells = <0>;
379395
380396 status = "disabled";
381397 };
arch/arm/boot/dts/sun5i-gr8-evb.dtsrenamed from arch/arm/boot/dts/ntc-gr8-evb.dts+1−1
@@ -44,7 +44,7 @@ · 43 unmodified lines
4444 */
4545
4646 /dts-v1/;
47−#include "ntc-gr8.dtsi"
47+#include "sun5i-gr8.dtsi"
4848 #include "sunxi-common-regulators.dtsi"
4949
5050 #include <dt-bindings/gpio/gpio.h>
arch/arm/boot/dts/sun5i-gr8.dtsirenamed from arch/arm/boot/dts/ntc-gr8.dtsi+0−0

File renamed without changes.

arch/arm64/boot/dts/arm/juno-base.dtsi+1−1
@@ -393,7 +393,7 @@ · 392 unmodified lines
393393 #address-cells = <3>;
394394 #size-cells = <2>;
395395 dma-coherent;
396− ranges = <0x01000000 0x00 0x5f800000 0x00 0x5f800000 0x0 0x00800000>,
396+ ranges = <0x01000000 0x00 0x00000000 0x00 0x5f800000 0x0 0x00800000>,
397397 <0x02000000 0x00 0x50000000 0x00 0x50000000 0x0 0x08000000>,
398398 <0x42000000 0x40 0x00000000 0x40 0x00000000 0x1 0x00000000>;
399399 #interrupt-cells = <1>;
arch/arm64/boot/dts/arm/juno-r1.dts+1−1
@@ -76,7 +76,7 @@ · 75 unmodified lines
7676 compatible = "arm,idle-state";
7777 arm,psci-suspend-param = <0x1010000>;
7878 local-timer-stop;
79− entry-latency-us = <300>;
79+ entry-latency-us = <400>;
8080 exit-latency-us = <1200>;
8181 min-residency-us = <2500>;
8282 };
arch/arm64/boot/dts/arm/juno-r2.dts+1−1
@@ -76,7 +76,7 @@ · 75 unmodified lines
7676 compatible = "arm,idle-state";
7777 arm,psci-suspend-param = <0x1010000>;
7878 local-timer-stop;
79− entry-latency-us = <300>;
79+ entry-latency-us = <400>;
8080 exit-latency-us = <1200>;
8181 min-residency-us = <2500>;
8282 };
arch/arm64/boot/dts/arm/juno.dts+1−1
@@ -76,7 +76,7 @@ · 75 unmodified lines
7676 compatible = "arm,idle-state";
7777 arm,psci-suspend-param = <0x1010000>;
7878 local-timer-stop;
79− entry-latency-us = <300>;
79+ entry-latency-us = <400>;
8080 exit-latency-us = <1200>;
8181 min-residency-us = <2500>;
8282 };
drivers/ata/ahci.c+0−7
@@ -1436,13 +1436,6 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports, · 1435 unmodified lines
14361436 "ahci: MRSM is on, fallback to single MSI\n");
14371437 pci_free_irq_vectors(pdev);
14381438 }
1439−
1440− /*
1441− * -ENOSPC indicated we don't have enough vectors. Don't bother
1442− * trying a single vectors for any other error:
1443− */
1444− if (nvec < 0 && nvec != -ENOSPC)
1445− return nvec;
14461439 }
14471440
14481441 /*
drivers/ata/libata-scsi.c+1−1
@@ -1088,7 +1088,7 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) · 1087 unmodified lines
10881088 desc[1] = tf->command; /* status */
10891089 desc[2] = tf->device;
10901090 desc[3] = tf->nsect;
1091− desc[0] = 0;
1091+ desc[7] = 0;
10921092 if (tf->flags & ATA_TFLAG_LBA48) {
10931093 desc[8] |= 0x80;
10941094 if (tf->hob_nsect)
drivers/block/zram/zram_drv.c+2−1
@@ -1403,7 +1403,8 @@ static ssize_t hot_remove_store(struct class *class, · 1402 unmodified lines
14031403 zram = idr_find(&zram_index_idr, dev_id);
14041404 if (zram) {
14051405 ret = zram_remove(zram);
1406− idr_remove(&zram_index_idr, dev_id);
1406+ if (!ret)
1407+ idr_remove(&zram_index_idr, dev_id);
14071408 } else {
14081409 ret = -ENODEV;
14091410 }
drivers/clk/bcm/Kconfig+1−1
@@ -20,7 +20,7 @@ config CLK_BCM_KONA · 19 unmodified lines
2020
2121 config COMMON_CLK_IPROC
2222 bool "Broadcom iProc clock support"
23− depends on ARCH_BCM_IPROC || COMPILE_TEST
23+ depends on ARCH_BCM_IPROC || ARCH_BCM_63XX || COMPILE_TEST
2424 depends on COMMON_CLK
2525 default ARCH_BCM_IPROC
2626 help
drivers/clk/sunxi-ng/ccu-sun6i-a31.c+1−1
@@ -143,7 +143,7 @@ static SUNXI_CCU_NKM_WITH_MUX_GATE_LOCK(pll_mipi_clk, "pll-mipi", · 142 unmodified lines
143143 4, 2, /* K */
144144 0, 4, /* M */
145145 21, 0, /* mux */
146− BIT(31), /* gate */
146+ BIT(31) | BIT(23) | BIT(22), /* gate */
147147 BIT(28), /* lock */
148148 CLK_SET_RATE_UNGATE);
149149
drivers/clk/sunxi-ng/ccu-sun8i-a33.c+1−1
@@ -131,7 +131,7 @@ static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_mipi_clk, "pll-mipi", · 130 unmodified lines
131131 8, 4, /* N */
132132 4, 2, /* K */
133133 0, 4, /* M */
134− BIT(31), /* gate */
134+ BIT(31) | BIT(23) | BIT(22), /* gate */
135135 BIT(28), /* lock */
136136 CLK_SET_RATE_UNGATE);
137137
drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c+9−2
@@ -485,7 +485,6 @@ static int amdgpu_atpx_power_state(enum vga_switcheroo_client_id id, · 484 unmodified lines
485485 */
486486 static bool amdgpu_atpx_pci_probe_handle(struct pci_dev *pdev)
487487 {
488− struct pci_dev *parent_pdev = pci_upstream_bridge(pdev);
489488 acpi_handle dhandle, atpx_handle;
490489 acpi_status status;
491490
@@ -500,7 +499,6 @@ static bool amdgpu_atpx_pci_probe_handle(struct pci_dev *pdev) · 8 unmodified lines
500499 }
501500 amdgpu_atpx_priv.dhandle = dhandle;
502501 amdgpu_atpx_priv.atpx.handle = atpx_handle;
503− amdgpu_atpx_priv.bridge_pm_usable = parent_pdev && parent_pdev->bridge_d3;
504502 return true;
505503 }
506504
@@ -562,17 +560,25 @@ static bool amdgpu_atpx_detect(void) · 55 unmodified lines
562560 struct pci_dev *pdev = NULL;
563561 bool has_atpx = false;
564562 int vga_count = 0;
563+ bool d3_supported = false;
564+ struct pci_dev *parent_pdev;
565565
566566 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
567567 vga_count++;
568568
569569 has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true);
570+
571+ parent_pdev = pci_upstream_bridge(pdev);
572+ d3_supported |= parent_pdev && parent_pdev->bridge_d3;
570573 }
571574
572575 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
573576 vga_count++;
574577
575578 has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true);
579+
580+ parent_pdev = pci_upstream_bridge(pdev);
581+ d3_supported |= parent_pdev && parent_pdev->bridge_d3;
576582 }
577583
578584 if (has_atpx && vga_count == 2) {
@@ -580,6 +586,7 @@ static bool amdgpu_atpx_detect(void) · 1 unmodified line
580586 printk(KERN_INFO "vga_switcheroo: detected switching method %s handle\n",
581587 acpi_method_name);
582588 amdgpu_atpx_priv.atpx_detected = true;
589+ amdgpu_atpx_priv.bridge_pm_usable = d3_supported;
583590 amdgpu_atpx_init();
584591 return true;
585592 }
drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c+4−1
@@ -2214,6 +2214,7 @@ uint32_t polaris10_get_mac_definition(uint32_t value) · 2213 unmodified lines
22142214 int polaris10_process_firmware_header(struct pp_hwmgr *hwmgr)
22152215 {
22162216 struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)(hwmgr->smumgr->backend);
2217+ struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
22172218 uint32_t tmp;
22182219 int result;
22192220 bool error = false;
@@ -2233,8 +2234,10 @@ int polaris10_process_firmware_header(struct pp_hwmgr *hwmgr) · 13 unmodified lines
22332234 offsetof(SMU74_Firmware_Header, SoftRegisters),
22342235 &tmp, SMC_RAM_END);
22352236
2236− if (!result)
2237+ if (!result) {
2238+ data->soft_regs_start = tmp;
22372239 smu_data->smu7_data.soft_regs_start = tmp;
2240+ }
22382241
22392242 error |= (0 != result);
22402243
drivers/gpu/drm/arm/hdlcd_drv.c+1−1
@@ -375,7 +375,6 @@ static int hdlcd_drm_bind(struct device *dev) · 374 unmodified lines
375375
376376 err_fbdev:
377377 drm_kms_helper_poll_fini(drm);
378− drm_mode_config_cleanup(drm);
379378 drm_vblank_cleanup(drm);
380379 err_vblank:
381380 pm_runtime_disable(drm->dev);
@@ -387,6 +386,7 @@ err_unload: · 5 unmodified lines
387386 drm_irq_uninstall(drm);
388387 of_reserved_mem_device_release(drm->dev);
389388 err_free:
389+ drm_mode_config_cleanup(drm);
390390 dev_set_drvdata(dev, NULL);
391391 drm_dev_unref(drm);
392392
drivers/gpu/drm/drm_ioctl.c+6−4
@@ -254,10 +254,12 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_ · 253 unmodified lines
254254 req->value = dev->mode_config.async_page_flip;
255255 break;
256256 case DRM_CAP_PAGE_FLIP_TARGET:
257− req->value = 1;
258− drm_for_each_crtc(crtc, dev) {
259− if (!crtc->funcs->page_flip_target)
260− req->value = 0;
257+ if (drm_core_check_feature(dev, DRIVER_MODESET)) {
258+ req->value = 1;
259+ drm_for_each_crtc(crtc, dev) {
260+ if (!crtc->funcs->page_flip_target)
261+ req->value = 0;
262+ }
261263 }
262264 break;
263265 case DRM_CAP_CURSOR_WIDTH:
drivers/gpu/drm/i915/i915_gem.c+3−2
@@ -2268,7 +2268,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) · 2267 unmodified lines
22682268 page = shmem_read_mapping_page(mapping, i);
22692269 if (IS_ERR(page)) {
22702270 ret = PTR_ERR(page);
2271− goto err_pages;
2271+ goto err_sg;
22722272 }
22732273 }
22742274 #ifdef CONFIG_SWIOTLB
@@ -2311,8 +2311,9 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) · 36 unmodified lines
23112311
23122312 return 0;
23132313
2314−err_pages:
2314+err_sg:
23152315 sg_mark_end(sg);
2316+err_pages:
23162317 for_each_sgt_page(page, sgt_iter, st)
23172318 put_page(page);
23182319 sg_free_table(st);
drivers/gpu/drm/i915/intel_display.c+2−1
@@ -12260,7 +12260,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, · 12259 unmodified lines
1226012260 intel_crtc->reset_count = i915_reset_count(&dev_priv->gpu_error);
1226112261 if (i915_reset_in_progress_or_wedged(&dev_priv->gpu_error)) {
1226212262 ret = -EIO;
12263− goto cleanup;
12263+ goto unlock;
1226412264 }
1226512265
1226612266 atomic_inc(&intel_crtc->unpin_work_count);
@@ -12352,6 +12352,7 @@ cleanup_unpin: · 85 unmodified lines
1235212352 intel_unpin_fb_obj(fb, crtc->primary->state->rotation);
1235312353 cleanup_pending:
1235412354 atomic_dec(&intel_crtc->unpin_work_count);
12355+unlock:
1235512356 mutex_unlock(&dev->struct_mutex);
1235612357 cleanup:
1235712358 crtc->primary->fb = old_fb;
drivers/gpu/drm/radeon/radeon_atpx_handler.c+9−2
@@ -479,7 +479,6 @@ static int radeon_atpx_power_state(enum vga_switcheroo_client_id id, · 478 unmodified lines
479479 */
480480 static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev)
481481 {
482− struct pci_dev *parent_pdev = pci_upstream_bridge(pdev);
483482 acpi_handle dhandle, atpx_handle;
484483 acpi_status status;
485484
@@ -493,7 +492,6 @@ static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev) · 7 unmodified lines
493492
494493 radeon_atpx_priv.dhandle = dhandle;
495494 radeon_atpx_priv.atpx.handle = atpx_handle;
496− radeon_atpx_priv.bridge_pm_usable = parent_pdev && parent_pdev->bridge_d3;
497495 return true;
498496 }
499497
@@ -555,11 +553,16 @@ static bool radeon_atpx_detect(void) · 55 unmodified lines
555553 struct pci_dev *pdev = NULL;
556554 bool has_atpx = false;
557555 int vga_count = 0;
556+ bool d3_supported = false;
557+ struct pci_dev *parent_pdev;
558558
559559 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
560560 vga_count++;
561561
562562 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true);
563+
564+ parent_pdev = pci_upstream_bridge(pdev);
565+ d3_supported |= parent_pdev && parent_pdev->bridge_d3;
563566 }
564567
565568 /* some newer PX laptops mark the dGPU as a non-VGA display device */
@@ -567,6 +570,9 @@ static bool radeon_atpx_detect(void) · 1 unmodified line
567570 vga_count++;
568571
569572 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true);
573+
574+ parent_pdev = pci_upstream_bridge(pdev);
575+ d3_supported |= parent_pdev && parent_pdev->bridge_d3;
570576 }
571577
572578 if (has_atpx && vga_count == 2) {
@@ -574,6 +580,7 @@ static bool radeon_atpx_detect(void) · 1 unmodified line
574580 printk(KERN_INFO "vga_switcheroo: detected switching method %s handle\n",
575581 acpi_method_name);
576582 radeon_atpx_priv.atpx_detected = true;
583+ radeon_atpx_priv.bridge_pm_usable = d3_supported;
577584 radeon_atpx_init();
578585 return true;
579586 }
drivers/i2c/busses/i2c-octeon-core.c+1−3
@@ -381,9 +381,7 @@ static int octeon_i2c_read(struct octeon_i2c *i2c, int target, · 380 unmodified lines
381381 if (result)
382382 return result;
383383
384− data[i] = octeon_i2c_data_read(i2c, &result);
385− if (result)
386− return result;
384+ data[i] = octeon_i2c_data_read(i2c);
387385 if (recv_len && i == 0) {
388386 if (data[i] > I2C_SMBUS_BLOCK_MAX + 1)
389387 return -EPROTO;
drivers/i2c/busses/i2c-octeon-core.h+11−16
@@ -5,7 +5,6 @@ · 4 unmodified lines
55 #include <linux/i2c.h>
66 #include <linux/i2c-smbus.h>
77 #include <linux/io.h>
8−#include <linux/iopoll.h>
98 #include <linux/kernel.h>
109 #include <linux/pci.h>
1110
@@ -145,9 +144,9 @@ static inline void octeon_i2c_reg_write(struct octeon_i2c *i2c, u64 eop_reg, u8 · 133 unmodified lines
145144 u64 tmp;
146145
147146 __raw_writeq(SW_TWSI_V | eop_reg | data, i2c->twsi_base + SW_TWSI(i2c));
148−
149− readq_poll_timeout(i2c->twsi_base + SW_TWSI(i2c), tmp, tmp & SW_TWSI_V,
150− I2C_OCTEON_EVENT_WAIT, i2c->adap.timeout);
147+ do {
148+ tmp = __raw_readq(i2c->twsi_base + SW_TWSI(i2c));
149+ } while ((tmp & SW_TWSI_V) != 0);
151150 }
152151
153152 #define octeon_i2c_ctl_write(i2c, val) \
@@ -164,28 +163,24 @@ static inline void octeon_i2c_reg_write(struct octeon_i2c *i2c, u64 eop_reg, u8 · 10 unmodified lines
164163 *
165164 * The I2C core registers are accessed indirectly via the SW_TWSI CSR.
166165 */
167−static inline int octeon_i2c_reg_read(struct octeon_i2c *i2c, u64 eop_reg,
168− int *error)
166+static inline u8 octeon_i2c_reg_read(struct octeon_i2c *i2c, u64 eop_reg)
169167 {
170168 u64 tmp;
171− int ret;
172169
173170 __raw_writeq(SW_TWSI_V | eop_reg | SW_TWSI_R, i2c->twsi_base + SW_TWSI(i2c));
171+ do {
172+ tmp = __raw_readq(i2c->twsi_base + SW_TWSI(i2c));
173+ } while ((tmp & SW_TWSI_V) != 0);
174174
175− ret = readq_poll_timeout(i2c->twsi_base + SW_TWSI(i2c), tmp,
176− tmp & SW_TWSI_V, I2C_OCTEON_EVENT_WAIT,
177− i2c->adap.timeout);
178− if (error)
179− *error = ret;
180175 return tmp & 0xFF;
181176 }
182177
183178 #define octeon_i2c_ctl_read(i2c) \
184− octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_CTL, NULL)
185−#define octeon_i2c_data_read(i2c, error) \
186− octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_DATA, error)
179+ octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_CTL)
180+#define octeon_i2c_data_read(i2c) \
181+ octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_DATA)
187182 #define octeon_i2c_stat_read(i2c) \
188− octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_STAT, NULL)
183+ octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_STAT)
189184
190185 /**
191186 * octeon_i2c_read_int - read the TWSI_INT register
drivers/input/mouse/psmouse-base.c+0−4
@@ -1115,10 +1115,6 @@ static int psmouse_extensions(struct psmouse *psmouse, · 1114 unmodified lines
11151115 if (psmouse_try_protocol(psmouse, PSMOUSE_TOUCHKIT_PS2,
11161116 &max_proto, set_properties, true))
11171117 return PSMOUSE_TOUCHKIT_PS2;
1118−
1119− if (psmouse_try_protocol(psmouse, PSMOUSE_BYD,
1120− &max_proto, set_properties, true))
1121− return PSMOUSE_BYD;
11221118 }
11231119
11241120 /*
drivers/net/can/usb/peak_usb/pcan_ucan.h+29−8
@@ -43,11 +43,22 @@ struct __packed pucan_command { · 42 unmodified lines
4343 u16 args[3];
4444 };
4545
46+#define PUCAN_TSLOW_BRP_BITS 10
47+#define PUCAN_TSLOW_TSGEG1_BITS 8
48+#define PUCAN_TSLOW_TSGEG2_BITS 7
49+#define PUCAN_TSLOW_SJW_BITS 7
50+
51+#define PUCAN_TSLOW_BRP_MASK ((1 << PUCAN_TSLOW_BRP_BITS) - 1)
52+#define PUCAN_TSLOW_TSEG1_MASK ((1 << PUCAN_TSLOW_TSGEG1_BITS) - 1)
53+#define PUCAN_TSLOW_TSEG2_MASK ((1 << PUCAN_TSLOW_TSGEG2_BITS) - 1)
54+#define PUCAN_TSLOW_SJW_MASK ((1 << PUCAN_TSLOW_SJW_BITS) - 1)
55+
4656 /* uCAN TIMING_SLOW command fields */
47−#define PUCAN_TSLOW_SJW_T(s, t) (((s) & 0xf) | ((!!(t)) << 7))
48−#define PUCAN_TSLOW_TSEG2(t) ((t) & 0xf)
49−#define PUCAN_TSLOW_TSEG1(t) ((t) & 0x3f)
50−#define PUCAN_TSLOW_BRP(b) ((b) & 0x3ff)
57+#define PUCAN_TSLOW_SJW_T(s, t) (((s) & PUCAN_TSLOW_SJW_MASK) | \
58+ ((!!(t)) << 7))
59+#define PUCAN_TSLOW_TSEG2(t) ((t) & PUCAN_TSLOW_TSEG2_MASK)
60+#define PUCAN_TSLOW_TSEG1(t) ((t) & PUCAN_TSLOW_TSEG1_MASK)
61+#define PUCAN_TSLOW_BRP(b) ((b) & PUCAN_TSLOW_BRP_MASK)
5162
5263 struct __packed pucan_timing_slow {
5364 __le16 opcode_channel;
@@ -60,11 +71,21 @@ struct __packed pucan_timing_slow { · 6 unmodified lines
6071 __le16 brp; /* BaudRate Prescaler */
6172 };
6273
74+#define PUCAN_TFAST_BRP_BITS 10
75+#define PUCAN_TFAST_TSGEG1_BITS 5
76+#define PUCAN_TFAST_TSGEG2_BITS 4
77+#define PUCAN_TFAST_SJW_BITS 4
78+
79+#define PUCAN_TFAST_BRP_MASK ((1 << PUCAN_TFAST_BRP_BITS) - 1)
80+#define PUCAN_TFAST_TSEG1_MASK ((1 << PUCAN_TFAST_TSGEG1_BITS) - 1)
81+#define PUCAN_TFAST_TSEG2_MASK ((1 << PUCAN_TFAST_TSGEG2_BITS) - 1)
82+#define PUCAN_TFAST_SJW_MASK ((1 << PUCAN_TFAST_SJW_BITS) - 1)
83+
6384 /* uCAN TIMING_FAST command fields */
64−#define PUCAN_TFAST_SJW(s) ((s) & 0x3)
65−#define PUCAN_TFAST_TSEG2(t) ((t) & 0x7)
66−#define PUCAN_TFAST_TSEG1(t) ((t) & 0xf)
67−#define PUCAN_TFAST_BRP(b) ((b) & 0x3ff)
85+#define PUCAN_TFAST_SJW(s) ((s) & PUCAN_TFAST_SJW_MASK)
86+#define PUCAN_TFAST_TSEG2(t) ((t) & PUCAN_TFAST_TSEG2_MASK)
87+#define PUCAN_TFAST_TSEG1(t) ((t) & PUCAN_TFAST_TSEG1_MASK)
88+#define PUCAN_TFAST_BRP(b) ((b) & PUCAN_TFAST_BRP_MASK)
6889
6990 struct __packed pucan_timing_fast {
7091 __le16 opcode_channel;
drivers/net/can/usb/peak_usb/pcan_usb_core.c+2−0
@@ -39,6 +39,7 @@ static struct usb_device_id peak_usb_table[] = { · 38 unmodified lines
3939 {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)},
4040 {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)},
4141 {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)},
42+ {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBX6_PRODUCT_ID)},
4243 {} /* Terminating entry */
4344 };
4445
@@ -50,6 +51,7 @@ static const struct peak_usb_adapter *const peak_usb_adapters_list[] = { · 5 unmodified lines
5051 &pcan_usb_pro,
5152 &pcan_usb_fd,
5253 &pcan_usb_pro_fd,
54+ &pcan_usb_x6,
5355 };
5456
5557 /*
drivers/net/can/usb/peak_usb/pcan_usb_core.h+2−0
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #define PCAN_USBPRO_PRODUCT_ID 0x000d
2828 #define PCAN_USBPROFD_PRODUCT_ID 0x0011
2929 #define PCAN_USBFD_PRODUCT_ID 0x0012
30+#define PCAN_USBX6_PRODUCT_ID 0x0014
3031
3132 #define PCAN_USB_DRIVER_NAME "peak_usb"
3233
@@ -90,6 +91,7 @@ extern const struct peak_usb_adapter pcan_usb; · 57 unmodified lines
9091 extern const struct peak_usb_adapter pcan_usb_pro;
9192 extern const struct peak_usb_adapter pcan_usb_fd;
9293 extern const struct peak_usb_adapter pcan_usb_pro_fd;
94+extern const struct peak_usb_adapter pcan_usb_x6;
9395
9496 struct peak_time_ref {
9597 struct timeval tv_host_0, tv_host;
drivers/net/can/usb/peak_usb/pcan_usb_fd.c+88−16
@@ -993,24 +993,24 @@ static void pcan_usb_fd_free(struct peak_usb_device *dev) · 992 unmodified lines
993993 static const struct can_bittiming_const pcan_usb_fd_const = {
994994 .name = "pcan_usb_fd",
995995 .tseg1_min = 1,
996− .tseg1_max = 64,
996+ .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
997997 .tseg2_min = 1,
998− .tseg2_max = 16,
999− .sjw_max = 16,
998+ .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
999+ .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
10001000 .brp_min = 1,
1001− .brp_max = 1024,
1001+ .brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
10021002 .brp_inc = 1,
10031003 };
10041004
10051005 static const struct can_bittiming_const pcan_usb_fd_data_const = {
10061006 .name = "pcan_usb_fd",
10071007 .tseg1_min = 1,
1008− .tseg1_max = 16,
1008+ .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
10091009 .tseg2_min = 1,
1010− .tseg2_max = 8,
1011− .sjw_max = 4,
1010+ .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
1011+ .sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
10121012 .brp_min = 1,
1013− .brp_max = 1024,
1013+ .brp_max = (1 << PUCAN_TFAST_BRP_BITS),
10141014 .brp_inc = 1,
10151015 };
10161016
@@ -1065,24 +1065,24 @@ const struct peak_usb_adapter pcan_usb_fd = { · 48 unmodified lines
10651065 static const struct can_bittiming_const pcan_usb_pro_fd_const = {
10661066 .name = "pcan_usb_pro_fd",
10671067 .tseg1_min = 1,
1068− .tseg1_max = 64,
1068+ .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
10691069 .tseg2_min = 1,
1070− .tseg2_max = 16,
1071− .sjw_max = 16,
1070+ .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
1071+ .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
10721072 .brp_min = 1,
1073− .brp_max = 1024,
1073+ .brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
10741074 .brp_inc = 1,
10751075 };
10761076
10771077 static const struct can_bittiming_const pcan_usb_pro_fd_data_const = {
10781078 .name = "pcan_usb_pro_fd",
10791079 .tseg1_min = 1,
1080− .tseg1_max = 16,
1080+ .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
10811081 .tseg2_min = 1,
1082− .tseg2_max = 8,
1083− .sjw_max = 4,
1082+ .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
1083+ .sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
10841084 .brp_min = 1,
1085− .brp_max = 1024,
1085+ .brp_max = (1 << PUCAN_TFAST_BRP_BITS),
10861086 .brp_inc = 1,
10871087 };
10881088
@@ -1132,3 +1132,75 @@ const struct peak_usb_adapter pcan_usb_pro_fd = { · 43 unmodified lines
11321132
11331133 .do_get_berr_counter = pcan_usb_fd_get_berr_counter,
11341134 };
1135+
1136+/* describes the PCAN-USB X6 adapter */
1137+static const struct can_bittiming_const pcan_usb_x6_const = {
1138+ .name = "pcan_usb_x6",
1139+ .tseg1_min = 1,
1140+ .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
1141+ .tseg2_min = 1,
1142+ .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
1143+ .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
1144+ .brp_min = 1,
1145+ .brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
1146+ .brp_inc = 1,
1147+};
1148+
1149+static const struct can_bittiming_const pcan_usb_x6_data_const = {
1150+ .name = "pcan_usb_x6",
1151+ .tseg1_min = 1,
1152+ .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
1153+ .tseg2_min = 1,
1154+ .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
1155+ .sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
1156+ .brp_min = 1,
1157+ .brp_max = (1 << PUCAN_TFAST_BRP_BITS),
1158+ .brp_inc = 1,
1159+};
1160+
1161+const struct peak_usb_adapter pcan_usb_x6 = {
1162+ .name = "PCAN-USB X6",
1163+ .device_id = PCAN_USBX6_PRODUCT_ID,
1164+ .ctrl_count = PCAN_USBPROFD_CHANNEL_COUNT,
1165+ .ctrlmode_supported = CAN_CTRLMODE_FD |
1166+ CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY,
1167+ .clock = {
1168+ .freq = PCAN_UFD_CRYSTAL_HZ,
1169+ },
1170+ .bittiming_const = &pcan_usb_x6_const,
1171+ .data_bittiming_const = &pcan_usb_x6_data_const,
1172+
1173+ /* size of device private data */
1174+ .sizeof_dev_private = sizeof(struct pcan_usb_fd_device),
1175+
1176+ /* timestamps usage */
1177+ .ts_used_bits = 32,
1178+ .ts_period = 1000000, /* calibration period in ts. */
1179+ .us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
1180+ .us_per_ts_shift = 0,
1181+
1182+ /* give here messages in/out endpoints */
1183+ .ep_msg_in = PCAN_USBPRO_EP_MSGIN,
1184+ .ep_msg_out = {PCAN_USBPRO_EP_MSGOUT_0, PCAN_USBPRO_EP_MSGOUT_1},
1185+
1186+ /* size of rx/tx usb buffers */
1187+ .rx_buffer_size = PCAN_UFD_RX_BUFFER_SIZE,
1188+ .tx_buffer_size = PCAN_UFD_TX_BUFFER_SIZE,
1189+
1190+ /* device callbacks */
1191+ .intf_probe = pcan_usb_pro_probe, /* same as PCAN-USB Pro */
1192+ .dev_init = pcan_usb_fd_init,
1193+
1194+ .dev_exit = pcan_usb_fd_exit,
1195+ .dev_free = pcan_usb_fd_free,
1196+ .dev_set_bus = pcan_usb_fd_set_bus,
1197+ .dev_set_bittiming = pcan_usb_fd_set_bittiming_slow,
1198+ .dev_set_data_bittiming = pcan_usb_fd_set_bittiming_fast,
1199+ .dev_decode_buf = pcan_usb_fd_decode_buf,
1200+ .dev_start = pcan_usb_fd_start,
1201+ .dev_stop = pcan_usb_fd_stop,
1202+ .dev_restart_async = pcan_usb_fd_restart_async,
1203+ .dev_encode_msg = pcan_usb_fd_encode_msg,
1204+
1205+ .do_get_berr_counter = pcan_usb_fd_get_berr_counter,
1206+};
drivers/net/ethernet/altera/altera_tse_main.c+8−13
@@ -400,12 +400,6 @@ static int tse_rx(struct altera_tse_private *priv, int limit) · 399 unmodified lines
400400
401401 skb_put(skb, pktlength);
402402
403− /* make cache consistent with receive packet buffer */
404− dma_sync_single_for_cpu(priv->device,
405− priv->rx_ring[entry].dma_addr,
406− priv->rx_ring[entry].len,
407− DMA_FROM_DEVICE);
408−
409403 dma_unmap_single(priv->device, priv->rx_ring[entry].dma_addr,
410404 priv->rx_ring[entry].len, DMA_FROM_DEVICE);
411405
@@ -469,7 +463,6 @@ static int tse_tx_complete(struct altera_tse_private *priv) · 57 unmodified lines
469463
470464 if (unlikely(netif_queue_stopped(priv->dev) &&
471465 tse_tx_avail(priv) > TSE_TX_THRESH(priv))) {
472− netif_tx_lock(priv->dev);
473466 if (netif_queue_stopped(priv->dev) &&
474467 tse_tx_avail(priv) > TSE_TX_THRESH(priv)) {
475468 if (netif_msg_tx_done(priv))
@@ -477,7 +470,6 @@ static int tse_tx_complete(struct altera_tse_private *priv) · 1 unmodified line
477470 __func__);
478471 netif_wake_queue(priv->dev);
479472 }
480− netif_tx_unlock(priv->dev);
481473 }
482474
483475 spin_unlock(&priv->tx_lock);
@@ -592,10 +584,6 @@ static int tse_start_xmit(struct sk_buff *skb, struct net_device *dev) · 108 unmodified lines
592584 buffer->dma_addr = dma_addr;
593585 buffer->len = nopaged_len;
594586
595− /* Push data out of the cache hierarchy into main memory */
596− dma_sync_single_for_device(priv->device, buffer->dma_addr,
597− buffer->len, DMA_TO_DEVICE);
598−
599587 priv->dmaops->tx_buffer(priv, buffer);
600588
601589 skb_tx_timestamp(skb);
@@ -819,6 +807,8 @@ static int init_phy(struct net_device *dev) · 217 unmodified lines
819807
820808 if (!phydev) {
821809 netdev_err(dev, "Could not find the PHY\n");
810+ if (fixed_link)
811+ of_phy_deregister_fixed_link(priv->device->of_node);
822812 return -ENODEV;
823813 }
824814
@@ -1545,10 +1535,15 @@ err_free_netdev: · 720 unmodified lines
15451535 static int altera_tse_remove(struct platform_device *pdev)
15461536 {
15471537 struct net_device *ndev = platform_get_drvdata(pdev);
1538+ struct altera_tse_private *priv = netdev_priv(ndev);
15481539
1549− if (ndev->phydev)
1540+ if (ndev->phydev) {
15501541 phy_disconnect(ndev->phydev);
15511542
1543+ if (of_phy_is_fixed_link(priv->device->of_node))
1544+ of_phy_deregister_fixed_link(priv->device->of_node);
1545+ }
1546+
15521547 platform_set_drvdata(pdev, NULL);
15531548 altera_tse_mdio_destroy(ndev);
15541549 unregister_netdev(ndev);
drivers/net/ethernet/amd/xgbe/xgbe-main.c+2−2
@@ -829,7 +829,7 @@ static int xgbe_remove(struct platform_device *pdev) · 828 unmodified lines
829829 return 0;
830830 }
831831
832−#ifdef CONFIG_PM
832+#ifdef CONFIG_PM_SLEEP
833833 static int xgbe_suspend(struct device *dev)
834834 {
835835 struct net_device *netdev = dev_get_drvdata(dev);
@@ -874,7 +874,7 @@ static int xgbe_resume(struct device *dev) · 38 unmodified lines
874874
875875 return ret;
876876 }
877−#endif /* CONFIG_PM */
877+#endif /* CONFIG_PM_SLEEP */
878878
879879 #ifdef CONFIG_ACPI
880880 static const struct acpi_device_id xgbe_acpi_match[] = {
drivers/net/ethernet/aurora/nb8800.c+7−2
@@ -1466,12 +1466,12 @@ static int nb8800_probe(struct platform_device *pdev) · 1465 unmodified lines
14661466
14671467 ret = nb8800_hw_init(dev);
14681468 if (ret)
1469− goto err_free_bus;
1469+ goto err_deregister_fixed_link;
14701470
14711471 if (ops && ops->init) {
14721472 ret = ops->init(dev);
14731473 if (ret)
1474− goto err_free_bus;
1474+ goto err_deregister_fixed_link;
14751475 }
14761476
14771477 dev->netdev_ops = &nb8800_netdev_ops;
@@ -1504,6 +1504,9 @@ static int nb8800_probe(struct platform_device *pdev) · 26 unmodified lines
15041504
15051505 err_free_dma:
15061506 nb8800_dma_free(dev);
1507+err_deregister_fixed_link:
1508+ if (of_phy_is_fixed_link(pdev->dev.of_node))
1509+ of_phy_deregister_fixed_link(pdev->dev.of_node);
15071510 err_free_bus:
15081511 of_node_put(priv->phy_node);
15091512 mdiobus_unregister(bus);
@@ -1521,6 +1524,8 @@ static int nb8800_remove(struct platform_device *pdev) · 11 unmodified lines
15211524 struct nb8800_priv *priv = netdev_priv(ndev);
15221525
15231526 unregister_netdev(ndev);
1527+ if (of_phy_is_fixed_link(pdev->dev.of_node))
1528+ of_phy_deregister_fixed_link(pdev->dev.of_node);
15241529 of_node_put(priv->phy_node);
15251530
15261531 mdiobus_unregister(priv->mii_bus);
drivers/net/ethernet/broadcom/bcmsysport.c+12−5
@@ -1755,13 +1755,13 @@ static int bcm_sysport_probe(struct platform_device *pdev) · 1754 unmodified lines
17551755 if (priv->irq0 <= 0 || priv->irq1 <= 0) {
17561756 dev_err(&pdev->dev, "invalid interrupts\n");
17571757 ret = -EINVAL;
1758− goto err;
1758+ goto err_free_netdev;
17591759 }
17601760
17611761 priv->base = devm_ioremap_resource(&pdev->dev, r);
17621762 if (IS_ERR(priv->base)) {
17631763 ret = PTR_ERR(priv->base);
1764− goto err;
1764+ goto err_free_netdev;
17651765 }
17661766
17671767 priv->netdev = dev;
@@ -1779,7 +1779,7 @@ static int bcm_sysport_probe(struct platform_device *pdev) · 11 unmodified lines
17791779 ret = of_phy_register_fixed_link(dn);
17801780 if (ret) {
17811781 dev_err(&pdev->dev, "failed to register fixed PHY\n");
1782− goto err;
1782+ goto err_free_netdev;
17831783 }
17841784
17851785 priv->phy_dn = dn;
@@ -1821,7 +1821,7 @@ static int bcm_sysport_probe(struct platform_device *pdev) · 35 unmodified lines
18211821 ret = register_netdev(dev);
18221822 if (ret) {
18231823 dev_err(&pdev->dev, "failed to register net_device\n");
1824− goto err;
1824+ goto err_deregister_fixed_link;
18251825 }
18261826
18271827 priv->rev = topctrl_readl(priv, REV_CNTL) & REV_MASK;
@@ -1832,7 +1832,11 @@ static int bcm_sysport_probe(struct platform_device *pdev) · 4 unmodified lines
18321832 priv->base, priv->irq0, priv->irq1, txq, rxq);
18331833
18341834 return 0;
1835−err:
1835+
1836+err_deregister_fixed_link:
1837+ if (of_phy_is_fixed_link(dn))
1838+ of_phy_deregister_fixed_link(dn);
1839+err_free_netdev:
18361840 free_netdev(dev);
18371841 return ret;
18381842 }
@@ -1840,11 +1844,14 @@ err: · 1 unmodified line
18401844 static int bcm_sysport_remove(struct platform_device *pdev)
18411845 {
18421846 struct net_device *dev = dev_get_drvdata(&pdev->dev);
1847+ struct device_node *dn = pdev->dev.of_node;
18431848
18441849 /* Not much to do, ndo_close has been called
18451850 * and we use managed allocations
18461851 */
18471852 unregister_netdev(dev);
1853+ if (of_phy_is_fixed_link(dn))
1854+ of_phy_deregister_fixed_link(dn);
18481855 free_netdev(dev);
18491856 dev_set_drvdata(&pdev->dev, NULL);
18501857
drivers/net/ethernet/broadcom/genet/bcmgenet.c+5−3
@@ -1172,6 +1172,7 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev, · 1171 unmodified lines
11721172 struct bcmgenet_tx_ring *ring)
11731173 {
11741174 struct bcmgenet_priv *priv = netdev_priv(dev);
1175+ struct device *kdev = &priv->pdev->dev;
11751176 struct enet_cb *tx_cb_ptr;
11761177 struct netdev_queue *txq;
11771178 unsigned int pkts_compl = 0;
@@ -1199,13 +1200,13 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev, · 21 unmodified lines
11991200 if (tx_cb_ptr->skb) {
12001201 pkts_compl++;
12011202 bytes_compl += GENET_CB(tx_cb_ptr->skb)->bytes_sent;
1202− dma_unmap_single(&dev->dev,
1203+ dma_unmap_single(kdev,
12031204 dma_unmap_addr(tx_cb_ptr, dma_addr),
12041205 dma_unmap_len(tx_cb_ptr, dma_len),
12051206 DMA_TO_DEVICE);
12061207 bcmgenet_free_cb(tx_cb_ptr);
12071208 } else if (dma_unmap_addr(tx_cb_ptr, dma_addr)) {
1208− dma_unmap_page(&dev->dev,
1209+ dma_unmap_page(kdev,
12091210 dma_unmap_addr(tx_cb_ptr, dma_addr),
12101211 dma_unmap_len(tx_cb_ptr, dma_len),
12111212 DMA_TO_DEVICE);
@@ -1775,6 +1776,7 @@ static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv, · 563 unmodified lines
17751776
17761777 static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv)
17771778 {
1779+ struct device *kdev = &priv->pdev->dev;
17781780 struct enet_cb *cb;
17791781 int i;
17801782
@@ -1782,7 +1784,7 @@ static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv) · 1 unmodified line
17821784 cb = &priv->rx_cbs[i];
17831785
17841786 if (dma_unmap_addr(cb, dma_addr)) {
1785− dma_unmap_single(&priv->dev->dev,
1787+ dma_unmap_single(kdev,
17861788 dma_unmap_addr(cb, dma_addr),
17871789 priv->rx_buf_len, DMA_FROM_DEVICE);
17881790 dma_unmap_addr_set(cb, dma_addr, 0);
drivers/net/ethernet/broadcom/genet/bcmmii.c+9−1
@@ -542,8 +542,10 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv) · 541 unmodified lines
542542 /* Make sure we initialize MoCA PHYs with a link down */
543543 if (phy_mode == PHY_INTERFACE_MODE_MOCA) {
544544 phydev = of_phy_find_device(dn);
545− if (phydev)
545+ if (phydev) {
546546 phydev->link = 0;
547+ put_device(&phydev->mdio.dev);
548+ }
547549 }
548550
549551 return 0;
@@ -625,6 +627,7 @@ static int bcmgenet_mii_bus_init(struct bcmgenet_priv *priv) · 75 unmodified lines
625627 int bcmgenet_mii_init(struct net_device *dev)
626628 {
627629 struct bcmgenet_priv *priv = netdev_priv(dev);
630+ struct device_node *dn = priv->pdev->dev.of_node;
628631 int ret;
629632
630633 ret = bcmgenet_mii_alloc(priv);
@@ -638,6 +641,8 @@ int bcmgenet_mii_init(struct net_device *dev) · 7 unmodified lines
638641 return 0;
639642
640643 out:
644+ if (of_phy_is_fixed_link(dn))
645+ of_phy_deregister_fixed_link(dn);
641646 of_node_put(priv->phy_dn);
642647 mdiobus_unregister(priv->mii_bus);
643648 mdiobus_free(priv->mii_bus);
@@ -647,7 +652,10 @@ out: · 3 unmodified lines
647652 void bcmgenet_mii_exit(struct net_device *dev)
648653 {
649654 struct bcmgenet_priv *priv = netdev_priv(dev);
655+ struct device_node *dn = priv->pdev->dev.of_node;
650656
657+ if (of_phy_is_fixed_link(dn))
658+ of_phy_deregister_fixed_link(dn);
651659 of_node_put(priv->phy_dn);
652660 mdiobus_unregister(priv->mii_bus);
653661 mdiobus_free(priv->mii_bus);
drivers/net/ethernet/cadence/macb.c+3−2
@@ -975,6 +975,7 @@ static inline void macb_init_rx_ring(struct macb *bp) · 974 unmodified lines
975975 addr += bp->rx_buffer_size;
976976 }
977977 bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP);
978+ bp->rx_tail = 0;
978979 }
979980
980981 static int macb_rx(struct macb *bp, int budget)
@@ -1156,6 +1157,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) · 175 unmodified lines
11561157 if (status & MACB_BIT(RXUBR)) {
11571158 ctrl = macb_readl(bp, NCR);
11581159 macb_writel(bp, NCR, ctrl & ~MACB_BIT(RE));
1160+ wmb();
11591161 macb_writel(bp, NCR, ctrl | MACB_BIT(RE));
11601162
11611163 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
@@ -1616,8 +1618,6 @@ static void macb_init_rings(struct macb *bp) · 454 unmodified lines
16161618 bp->queues[0].tx_head = 0;
16171619 bp->queues[0].tx_tail = 0;
16181620 bp->queues[0].tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
1619−
1620− bp->rx_tail = 0;
16211621 }
16221622
16231623 static void macb_reset_hw(struct macb *bp)
@@ -2770,6 +2770,7 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id) · 1146 unmodified lines
27702770 if (intstatus & MACB_BIT(RXUBR)) {
27712771 ctl = macb_readl(lp, NCR);
27722772 macb_writel(lp, NCR, ctl & ~MACB_BIT(RE));
2773+ wmb();
27732774 macb_writel(lp, NCR, ctl | MACB_BIT(RE));
27742775 }
27752776
drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h+1−0
@@ -168,6 +168,7 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN · 167 unmodified lines
168168 CH_PCI_ID_TABLE_FENTRY(0x509a), /* Custom T520-CR */
169169 CH_PCI_ID_TABLE_FENTRY(0x509b), /* Custom T540-CR LOM */
170170 CH_PCI_ID_TABLE_FENTRY(0x509c), /* Custom T520-CR*/
171+ CH_PCI_ID_TABLE_FENTRY(0x509d), /* Custom T540-CR*/
171172
172173 /* T6 adapters:
173174 */
drivers/net/ethernet/freescale/fec.h+2−0
@@ -574,6 +574,8 @@ struct fec_enet_private { · 573 unmodified lines
574574 unsigned int reload_period;
575575 int pps_enable;
576576 unsigned int next_counter;
577+
578+ u64 ethtool_stats[0];
577579 };
578580
579581 void fec_ptp_init(struct platform_device *pdev);
drivers/net/ethernet/freescale/fec_main.c+24−4
@@ -2313,14 +2313,24 @@ static const struct fec_stat { · 2312 unmodified lines
23132313 { "IEEE_rx_octets_ok", IEEE_R_OCTETS_OK },
23142314 };
23152315
2316−static void fec_enet_get_ethtool_stats(struct net_device *dev,
2317− struct ethtool_stats *stats, u64 *data)
2316+static void fec_enet_update_ethtool_stats(struct net_device *dev)
23182317 {
23192318 struct fec_enet_private *fep = netdev_priv(dev);
23202319 int i;
23212320
23222321 for (i = 0; i < ARRAY_SIZE(fec_stats); i++)
2323− data[i] = readl(fep->hwp + fec_stats[i].offset);
2322+ fep->ethtool_stats[i] = readl(fep->hwp + fec_stats[i].offset);
2323+}
2324+
2325+static void fec_enet_get_ethtool_stats(struct net_device *dev,
2326+ struct ethtool_stats *stats, u64 *data)
2327+{
2328+ struct fec_enet_private *fep = netdev_priv(dev);
2329+
2330+ if (netif_running(dev))
2331+ fec_enet_update_ethtool_stats(dev);
2332+
2333+ memcpy(data, fep->ethtool_stats, ARRAY_SIZE(fec_stats) * sizeof(u64));
23242334 }
23252335
23262336 static void fec_enet_get_strings(struct net_device *netdev,
@@ -2874,6 +2884,8 @@ fec_enet_close(struct net_device *ndev) · 547 unmodified lines
28742884 if (fep->quirks & FEC_QUIRK_ERR006687)
28752885 imx6q_cpuidle_fec_irqs_unused();
28762886
2887+ fec_enet_update_ethtool_stats(ndev);
2888+
28772889 fec_enet_clk_enable(ndev, false);
28782890 pinctrl_pm_select_sleep_state(&fep->pdev->dev);
28792891 pm_runtime_mark_last_busy(&fep->pdev->dev);
@@ -3180,6 +3192,8 @@ static int fec_enet_init(struct net_device *ndev) · 300 unmodified lines
31803192
31813193 fec_restart(ndev);
31823194
3195+ fec_enet_update_ethtool_stats(ndev);
3196+
31833197 return 0;
31843198 }
31853199
@@ -3278,7 +3292,8 @@ fec_probe(struct platform_device *pdev) · 92 unmodified lines
32783292 fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs);
32793293
32803294 /* Init network device */
3281− ndev = alloc_etherdev_mqs(sizeof(struct fec_enet_private),
3295+ ndev = alloc_etherdev_mqs(sizeof(struct fec_enet_private) +
3296+ ARRAY_SIZE(fec_stats) * sizeof(u64),
32823297 num_tx_qs, num_rx_qs);
32833298 if (!ndev)
32843299 return -ENOMEM;
@@ -3475,6 +3490,8 @@ failed_regulator: · 190 unmodified lines
34753490 failed_clk_ipg:
34763491 fec_enet_clk_enable(ndev, false);
34773492 failed_clk:
3493+ if (of_phy_is_fixed_link(np))
3494+ of_phy_deregister_fixed_link(np);
34783495 failed_phy:
34793496 of_node_put(phy_node);
34803497 failed_ioremap:
@@ -3488,6 +3505,7 @@ fec_drv_remove(struct platform_device *pdev) · 7 unmodified lines
34883505 {
34893506 struct net_device *ndev = platform_get_drvdata(pdev);
34903507 struct fec_enet_private *fep = netdev_priv(ndev);
3508+ struct device_node *np = pdev->dev.of_node;
34913509
34923510 cancel_work_sync(&fep->tx_timeout_work);
34933511 fec_ptp_stop(pdev);
@@ -3495,6 +3513,8 @@ fec_drv_remove(struct platform_device *pdev) · 1 unmodified line
34953513 fec_enet_mii_remove(fep);
34963514 if (fep->reg_phy)
34973515 regulator_disable(fep->reg_phy);
3516+ if (of_phy_is_fixed_link(np))
3517+ of_phy_deregister_fixed_link(np);
34983518 of_node_put(fep->phy_node);
34993519 free_netdev(ndev);
35003520
drivers/net/ethernet/freescale/fman/fman_memac.c+3−0
@@ -1107,6 +1107,9 @@ int memac_free(struct fman_mac *memac) · 1106 unmodified lines
11071107 {
11081108 free_init_resources(memac);
11091109
1110+ if (memac->pcsphy)
1111+ put_device(&memac->pcsphy->mdio.dev);
1112+
11101113 kfree(memac->memac_drv_param);
11111114 kfree(memac);
11121115
drivers/net/ethernet/freescale/fman/mac.c+2−0
@@ -892,6 +892,8 @@ static int mac_probe(struct platform_device *_of_dev) · 891 unmodified lines
892892 priv->fixed_link->duplex = phy->duplex;
893893 priv->fixed_link->pause = phy->pause;
894894 priv->fixed_link->asym_pause = phy->asym_pause;
895+
896+ put_device(&phy->mdio.dev);
895897 }
896898
897899 err = mac_dev->init(mac_dev);
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c+6−1
@@ -980,7 +980,7 @@ static int fs_enet_probe(struct platform_device *ofdev) · 979 unmodified lines
980980 err = clk_prepare_enable(clk);
981981 if (err) {
982982 ret = err;
983− goto out_free_fpi;
983+ goto out_deregister_fixed_link;
984984 }
985985 fpi->clk_per = clk;
986986 }
@@ -1061,6 +1061,9 @@ out_put: · 74 unmodified lines
10611061 of_node_put(fpi->phy_node);
10621062 if (fpi->clk_per)
10631063 clk_disable_unprepare(fpi->clk_per);
1064+out_deregister_fixed_link:
1065+ if (of_phy_is_fixed_link(ofdev->dev.of_node))
1066+ of_phy_deregister_fixed_link(ofdev->dev.of_node);
10641067 out_free_fpi:
10651068 kfree(fpi);
10661069 return ret;
@@ -1079,6 +1082,8 @@ static int fs_enet_remove(struct platform_device *ofdev) · 12 unmodified lines
10791082 of_node_put(fep->fpi->phy_node);
10801083 if (fep->fpi->clk_per)
10811084 clk_disable_unprepare(fep->fpi->clk_per);
1085+ if (of_phy_is_fixed_link(ofdev->dev.of_node))
1086+ of_phy_deregister_fixed_link(ofdev->dev.of_node);
10821087 free_netdev(ndev);
10831088 return 0;
10841089 }
drivers/net/ethernet/freescale/gianfar.c+8−0
@@ -1312,6 +1312,7 @@ static void gfar_init_addr_hash_table(struct gfar_private *priv) · 1311 unmodified lines
13121312 */
13131313 static int gfar_probe(struct platform_device *ofdev)
13141314 {
1315+ struct device_node *np = ofdev->dev.of_node;
13151316 struct net_device *dev = NULL;
13161317 struct gfar_private *priv = NULL;
13171318 int err = 0, i;
@@ -1462,6 +1463,8 @@ static int gfar_probe(struct platform_device *ofdev) · 144 unmodified lines
14621463 return 0;
14631464
14641465 register_fail:
1466+ if (of_phy_is_fixed_link(np))
1467+ of_phy_deregister_fixed_link(np);
14651468 unmap_group_regs(priv);
14661469 gfar_free_rx_queues(priv);
14671470 gfar_free_tx_queues(priv);
@@ -1474,11 +1477,16 @@ register_fail: · 6 unmodified lines
14741477 static int gfar_remove(struct platform_device *ofdev)
14751478 {
14761479 struct gfar_private *priv = platform_get_drvdata(ofdev);
1480+ struct device_node *np = ofdev->dev.of_node;
14771481
14781482 of_node_put(priv->phy_node);
14791483 of_node_put(priv->tbi_node);
14801484
14811485 unregister_netdev(priv->ndev);
1486+
1487+ if (of_phy_is_fixed_link(np))
1488+ of_phy_deregister_fixed_link(np);
1489+
14821490 unmap_group_regs(priv);
14831491 gfar_free_rx_queues(priv);
14841492 gfar_free_tx_queues(priv);
drivers/net/ethernet/freescale/ucc_geth.c+16−7
@@ -3868,9 +3868,8 @@ static int ucc_geth_probe(struct platform_device* ofdev) · 3867 unmodified lines
38683868 dev = alloc_etherdev(sizeof(*ugeth));
38693869
38703870 if (dev == NULL) {
3871− of_node_put(ug_info->tbi_node);
3872− of_node_put(ug_info->phy_node);
3873− return -ENOMEM;
3871+ err = -ENOMEM;
3872+ goto err_deregister_fixed_link;
38743873 }
38753874
38763875 ugeth = netdev_priv(dev);
@@ -3907,10 +3906,7 @@ static int ucc_geth_probe(struct platform_device* ofdev) · 30 unmodified lines
39073906 if (netif_msg_probe(ugeth))
39083907 pr_err("%s: Cannot register net device, aborting\n",
39093908 dev->name);
3910− free_netdev(dev);
3911− of_node_put(ug_info->tbi_node);
3912− of_node_put(ug_info->phy_node);
3913− return err;
3909+ goto err_free_netdev;
39143910 }
39153911
39163912 mac_addr = of_get_mac_address(np);
@@ -3923,16 +3919,29 @@ static int ucc_geth_probe(struct platform_device* ofdev) · 6 unmodified lines
39233919 ugeth->node = np;
39243920
39253921 return 0;
3922+
3923+err_free_netdev:
3924+ free_netdev(dev);
3925+err_deregister_fixed_link:
3926+ if (of_phy_is_fixed_link(np))
3927+ of_phy_deregister_fixed_link(np);
3928+ of_node_put(ug_info->tbi_node);
3929+ of_node_put(ug_info->phy_node);
3930+
3931+ return err;
39263932 }
39273933
39283934 static int ucc_geth_remove(struct platform_device* ofdev)
39293935 {
39303936 struct net_device *dev = platform_get_drvdata(ofdev);
39313937 struct ucc_geth_private *ugeth = netdev_priv(dev);
3938+ struct device_node *np = ofdev->dev.of_node;
39323939
39333940 unregister_netdev(dev);
39343941 free_netdev(dev);
39353942 ucc_geth_memclean(ugeth);
3943+ if (of_phy_is_fixed_link(np))
3944+ of_phy_deregister_fixed_link(np);
39363945 of_node_put(ugeth->ug_info->tbi_node);
39373946 of_node_put(ugeth->ug_info->phy_node);
39383947
drivers/net/ethernet/intel/igb/igb_main.c+6−2
@@ -4931,11 +4931,15 @@ static int igb_tso(struct igb_ring *tx_ring, · 4930 unmodified lines
49314931
49324932 /* initialize outer IP header fields */
49334933 if (ip.v4->version == 4) {
4934+ unsigned char *csum_start = skb_checksum_start(skb);
4935+ unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4);
4936+
49344937 /* IP header will have to cancel out any data that
49354938 * is not a part of the outer IP header
49364939 */
4937− ip.v4->check = csum_fold(csum_add(lco_csum(skb),
4938− csum_unfold(l4.tcp->check)));
4940+ ip.v4->check = csum_fold(csum_partial(trans_start,
4941+ csum_start - trans_start,
4942+ 0));
49394943 type_tucmd |= E1000_ADVTXD_TUCMD_IPV4;
49404944
49414945 ip.v4->tot_len = 0;
drivers/net/ethernet/intel/igbvf/netdev.c+6−2
@@ -1965,11 +1965,15 @@ static int igbvf_tso(struct igbvf_ring *tx_ring, · 1964 unmodified lines
19651965
19661966 /* initialize outer IP header fields */
19671967 if (ip.v4->version == 4) {
1968+ unsigned char *csum_start = skb_checksum_start(skb);
1969+ unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4);
1970+
19681971 /* IP header will have to cancel out any data that
19691972 * is not a part of the outer IP header
19701973 */
1971− ip.v4->check = csum_fold(csum_add(lco_csum(skb),
1972− csum_unfold(l4.tcp->check)));
1974+ ip.v4->check = csum_fold(csum_partial(trans_start,
1975+ csum_start - trans_start,
1976+ 0));
19731977 type_tucmd |= E1000_ADVTXD_TUCMD_IPV4;
19741978
19751979 ip.v4->tot_len = 0;
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c+6−2
@@ -7277,11 +7277,15 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring, · 7276 unmodified lines
72777277
72787278 /* initialize outer IP header fields */
72797279 if (ip.v4->version == 4) {
7280+ unsigned char *csum_start = skb_checksum_start(skb);
7281+ unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4);
7282+
72807283 /* IP header will have to cancel out any data that
72817284 * is not a part of the outer IP header
72827285 */
7283− ip.v4->check = csum_fold(csum_add(lco_csum(skb),
7284− csum_unfold(l4.tcp->check)));
7286+ ip.v4->check = csum_fold(csum_partial(trans_start,
7287+ csum_start - trans_start,
7288+ 0));
72857289 type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4;
72867290
72877291 ip.v4->tot_len = 0;
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c+6−2
@@ -3329,11 +3329,15 @@ static int ixgbevf_tso(struct ixgbevf_ring *tx_ring, · 3328 unmodified lines
33293329
33303330 /* initialize outer IP header fields */
33313331 if (ip.v4->version == 4) {
3332+ unsigned char *csum_start = skb_checksum_start(skb);
3333+ unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4);
3334+
33323335 /* IP header will have to cancel out any data that
33333336 * is not a part of the outer IP header
33343337 */
3335− ip.v4->check = csum_fold(csum_add(lco_csum(skb),
3336− csum_unfold(l4.tcp->check)));
3338+ ip.v4->check = csum_fold(csum_partial(trans_start,
3339+ csum_start - trans_start,
3340+ 0));
33373341 type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4;
33383342
33393343 ip.v4->tot_len = 0;
drivers/net/ethernet/marvell/mvneta.c+5−0
@@ -4191,6 +4191,8 @@ err_clk: · 4190 unmodified lines
41914191 clk_disable_unprepare(pp->clk);
41924192 err_put_phy_node:
41934193 of_node_put(phy_node);
4194+ if (of_phy_is_fixed_link(dn))
4195+ of_phy_deregister_fixed_link(dn);
41944196 err_free_irq:
41954197 irq_dispose_mapping(dev->irq);
41964198 err_free_netdev:
@@ -4202,6 +4204,7 @@ err_free_netdev: · 5 unmodified lines
42024204 static int mvneta_remove(struct platform_device *pdev)
42034205 {
42044206 struct net_device *dev = platform_get_drvdata(pdev);
4207+ struct device_node *dn = pdev->dev.of_node;
42054208 struct mvneta_port *pp = netdev_priv(dev);
42064209
42074210 unregister_netdev(dev);
@@ -4209,6 +4212,8 @@ static int mvneta_remove(struct platform_device *pdev) · 1 unmodified line
42094212 clk_disable_unprepare(pp->clk);
42104213 free_percpu(pp->ports);
42114214 free_percpu(pp->stats);
4215+ if (of_phy_is_fixed_link(dn))
4216+ of_phy_deregister_fixed_link(dn);
42124217 irq_dispose_mapping(dev->irq);
42134218 of_node_put(pp->phy_node);
42144219 free_netdev(dev);
drivers/net/ethernet/mediatek/mtk_eth_soc.c+4−0
@@ -318,6 +318,8 @@ static int mtk_phy_connect(struct net_device *dev) · 317 unmodified lines
318318 return 0;
319319
320320 err_phy:
321+ if (of_phy_is_fixed_link(mac->of_node))
322+ of_phy_deregister_fixed_link(mac->of_node);
321323 of_node_put(np);
322324 dev_err(eth->dev, "%s: invalid phy\n", __func__);
323325 return -EINVAL;
@@ -1923,6 +1925,8 @@ static void mtk_uninit(struct net_device *dev) · 1599 unmodified lines
19231925 struct mtk_eth *eth = mac->hw;
19241926
19251927 phy_disconnect(dev->phydev);
1928+ if (of_phy_is_fixed_link(mac->of_node))
1929+ of_phy_deregister_fixed_link(mac->of_node);
19261930 mtk_irq_disable(eth, MTK_QDMA_INT_MASK, ~0);
19271931 mtk_irq_disable(eth, MTK_PDMA_INT_MASK, ~0);
19281932 }
drivers/net/ethernet/mellanox/mlx4/en_netdev.c+2−15
@@ -2079,13 +2079,6 @@ err: · 2078 unmodified lines
20792079 return -ENOMEM;
20802080 }
20812081
2082−static void mlx4_en_shutdown(struct net_device *dev)
2083−{
2084− rtnl_lock();
2085− netif_device_detach(dev);
2086− mlx4_en_close(dev);
2087− rtnl_unlock();
2088−}
20892082
20902083 static int mlx4_en_copy_priv(struct mlx4_en_priv *dst,
20912084 struct mlx4_en_priv *src,
@@ -2162,8 +2155,6 @@ void mlx4_en_destroy_netdev(struct net_device *dev) · 70 unmodified lines
21622155 {
21632156 struct mlx4_en_priv *priv = netdev_priv(dev);
21642157 struct mlx4_en_dev *mdev = priv->mdev;
2165− bool shutdown = mdev->dev->persist->interface_state &
2166− MLX4_INTERFACE_STATE_SHUTDOWN;
21672158
21682159 en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port);
21692160
@@ -2171,10 +2162,7 @@ void mlx4_en_destroy_netdev(struct net_device *dev) · 1 unmodified line
21712162 if (priv->registered) {
21722163 devlink_port_type_clear(mlx4_get_devlink_port(mdev->dev,
21732164 priv->port));
2174− if (shutdown)
2175− mlx4_en_shutdown(dev);
2176− else
2177− unregister_netdev(dev);
2165+ unregister_netdev(dev);
21782166 }
21792167
21802168 if (priv->allocated)
@@ -2203,8 +2191,7 @@ void mlx4_en_destroy_netdev(struct net_device *dev) · 22 unmodified lines
22032191 kfree(priv->tx_ring);
22042192 kfree(priv->tx_cq);
22052193
2206− if (!shutdown)
2207− free_netdev(dev);
2194+ free_netdev(dev);
22082195 }
22092196
22102197 static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu)
drivers/net/ethernet/mellanox/mlx4/main.c+1−4
@@ -4147,11 +4147,8 @@ static void mlx4_shutdown(struct pci_dev *pdev) · 4146 unmodified lines
41474147
41484148 mlx4_info(persist->dev, "mlx4_shutdown was called\n");
41494149 mutex_lock(&persist->interface_state_mutex);
4150− if (persist->interface_state & MLX4_INTERFACE_STATE_UP) {
4151− /* Notify mlx4 clients that the kernel is being shut down */
4152− persist->interface_state |= MLX4_INTERFACE_STATE_SHUTDOWN;
4150+ if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
41534151 mlx4_unload_one(pdev);
4154− }
41554152 mutex_unlock(&persist->interface_state_mutex);
41564153 }
41574154
drivers/net/ethernet/mellanox/mlx4/mcg.c+6−1
@@ -1457,7 +1457,12 @@ EXPORT_SYMBOL_GPL(mlx4_multicast_detach); · 1456 unmodified lines
14571457 int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port,
14581458 u32 qpn, enum mlx4_net_trans_promisc_mode mode)
14591459 {
1460− struct mlx4_net_trans_rule rule;
1460+ struct mlx4_net_trans_rule rule = {
1461+ .queue_mode = MLX4_NET_TRANS_Q_FIFO,
1462+ .exclusive = 0,
1463+ .allow_loopback = 1,
1464+ };
1465+
14611466 u64 *regid_p;
14621467
14631468 switch (mode) {
drivers/net/ethernet/qualcomm/emac/emac-phy.c+1−0
@@ -212,6 +212,7 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt) · 211 unmodified lines
212212
213213 phy_np = of_parse_phandle(np, "phy-handle", 0);
214214 adpt->phydev = of_phy_find_device(phy_np);
215+ of_node_put(phy_np);
215216 }
216217
217218 if (!adpt->phydev) {
drivers/net/ethernet/qualcomm/emac/emac.c+4−0
@@ -711,6 +711,8 @@ static int emac_probe(struct platform_device *pdev) · 710 unmodified lines
711711 err_undo_napi:
712712 netif_napi_del(&adpt->rx_q.napi);
713713 err_undo_mdiobus:
714+ if (!has_acpi_companion(&pdev->dev))
715+ put_device(&adpt->phydev->mdio.dev);
714716 mdiobus_unregister(adpt->mii_bus);
715717 err_undo_clocks:
716718 emac_clks_teardown(adpt);
@@ -730,6 +732,8 @@ static int emac_remove(struct platform_device *pdev) · 13 unmodified lines
730732
731733 emac_clks_teardown(adpt);
732734
735+ if (!has_acpi_companion(&pdev->dev))
736+ put_device(&adpt->phydev->mdio.dev);
733737 mdiobus_unregister(adpt->mii_bus);
734738 free_netdev(netdev);
735739
drivers/net/ethernet/renesas/ravb_main.c+14−5
@@ -1008,20 +1008,18 @@ static int ravb_phy_init(struct net_device *ndev) · 1007 unmodified lines
10081008 of_node_put(pn);
10091009 if (!phydev) {
10101010 netdev_err(ndev, "failed to connect PHY\n");
1011− return -ENOENT;
1011+ err = -ENOENT;
1012+ goto err_deregister_fixed_link;
10121013 }
10131014
10141015 /* This driver only support 10/100Mbit speeds on Gen3
10151016 * at this time.
10161017 */
10171018 if (priv->chip_id == RCAR_GEN3) {
1018− int err;
1019−
10201019 err = phy_set_max_speed(phydev, SPEED_100);
10211020 if (err) {
10221021 netdev_err(ndev, "failed to limit PHY to 100Mbit/s\n");
1023− phy_disconnect(phydev);
1024− return err;
1022+ goto err_phy_disconnect;
10251023 }
10261024
10271025 netdev_info(ndev, "limited PHY to 100Mbit/s\n");
@@ -1033,6 +1031,14 @@ static int ravb_phy_init(struct net_device *ndev) · 5 unmodified lines
10331031 phy_attached_info(phydev);
10341032
10351033 return 0;
1034+
1035+err_phy_disconnect:
1036+ phy_disconnect(phydev);
1037+err_deregister_fixed_link:
1038+ if (of_phy_is_fixed_link(np))
1039+ of_phy_deregister_fixed_link(np);
1040+
1041+ return err;
10361042 }
10371043
10381044 /* PHY control start function */
@@ -1634,6 +1640,7 @@ static void ravb_set_rx_mode(struct net_device *ndev) · 595 unmodified lines
16341640 /* Device close function for Ethernet AVB */
16351641 static int ravb_close(struct net_device *ndev)
16361642 {
1643+ struct device_node *np = ndev->dev.parent->of_node;
16371644 struct ravb_private *priv = netdev_priv(ndev);
16381645 struct ravb_tstamp_skb *ts_skb, *ts_skb2;
16391646
@@ -1663,6 +1670,8 @@ static int ravb_close(struct net_device *ndev) · 23 unmodified lines
16631670 if (ndev->phydev) {
16641671 phy_stop(ndev->phydev);
16651672 phy_disconnect(ndev->phydev);
1673+ if (of_phy_is_fixed_link(np))
1674+ of_phy_deregister_fixed_link(np);
16661675 }
16671676
16681677 if (priv->chip_id != RCAR_GEN2) {
drivers/net/ethernet/renesas/sh_eth.c+1−1
@@ -518,7 +518,7 @@ static struct sh_eth_cpu_data r7s72100_data = { · 517 unmodified lines
518518
519519 .ecsr_value = ECSR_ICD,
520520 .ecsipr_value = ECSIPR_ICDIP,
521− .eesipr_value = 0xff7f009f,
521+ .eesipr_value = 0xe77f009f,
522522
523523 .tx_check = EESR_TC1 | EESR_FTC,
524524 .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT |
drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c+15−2
@@ -50,10 +50,23 @@ static int dwmac_generic_probe(struct platform_device *pdev) · 49 unmodified lines
5050 if (plat_dat->init) {
5151 ret = plat_dat->init(pdev, plat_dat->bsp_priv);
5252 if (ret)
53− return ret;
53+ goto err_remove_config_dt;
5454 }
5555
56− return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
56+ ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
57+ if (ret)
58+ goto err_exit;
59+
60+ return 0;
61+
62+err_exit:
63+ if (plat_dat->exit)
64+ plat_dat->exit(pdev, plat_dat->bsp_priv);
65+err_remove_config_dt:
66+ if (pdev->dev.of_node)
67+ stmmac_remove_config_dt(pdev, plat_dat);
68+
69+ return ret;
5770 }
5871
5972 static const struct of_device_id dwmac_generic_match[] = {
drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c+19−6
@@ -271,15 +271,17 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) · 270 unmodified lines
271271 return PTR_ERR(plat_dat);
272272
273273 gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL);
274− if (!gmac)
275− return -ENOMEM;
274+ if (!gmac) {
275+ err = -ENOMEM;
276+ goto err_remove_config_dt;
277+ }
276278
277279 gmac->pdev = pdev;
278280
279281 err = ipq806x_gmac_of_parse(gmac);
280282 if (err) {
281283 dev_err(dev, "device tree parsing error\n");
282− return err;
284+ goto err_remove_config_dt;
283285 }
284286
285287 regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL,
@@ -300,7 +302,8 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) · 14 unmodified lines
300302 default:
301303 dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
302304 phy_modes(gmac->phy_mode));
303− return -EINVAL;
305+ err = -EINVAL;
306+ goto err_remove_config_dt;
304307 }
305308 regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val);
306309
@@ -319,7 +322,8 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) · 12 unmodified lines
319322 default:
320323 dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
321324 phy_modes(gmac->phy_mode));
322− return -EINVAL;
325+ err = -EINVAL;
326+ goto err_remove_config_dt;
323327 }
324328 regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val);
325329
@@ -346,7 +350,16 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) · 20 unmodified lines
346350 plat_dat->bsp_priv = gmac;
347351 plat_dat->fix_mac_speed = ipq806x_gmac_fix_mac_speed;
348352
349− return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
353+ err = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
354+ if (err)
355+ goto err_remove_config_dt;
356+
357+ return 0;
358+
359+err_remove_config_dt:
360+ stmmac_remove_config_dt(pdev, plat_dat);
361+
362+ return err;
350363 }
351364
352365 static const struct of_device_id ipq806x_gmac_dwmac_match[] = {
drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c+14−3
@@ -46,7 +46,8 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev) · 45 unmodified lines
4646 reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg");
4747 if (IS_ERR(reg)) {
4848 dev_err(&pdev->dev, "syscon lookup failed\n");
49− return PTR_ERR(reg);
49+ ret = PTR_ERR(reg);
50+ goto err_remove_config_dt;
5051 }
5152
5253 if (plat_dat->interface == PHY_INTERFACE_MODE_MII) {
@@ -55,13 +56,23 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev) · 2 unmodified lines
5556 ethmode = LPC18XX_CREG_CREG6_ETHMODE_RMII;
5657 } else {
5758 dev_err(&pdev->dev, "Only MII and RMII mode supported\n");
58− return -EINVAL;
59+ ret = -EINVAL;
60+ goto err_remove_config_dt;
5961 }
6062
6163 regmap_update_bits(reg, LPC18XX_CREG_CREG6,
6264 LPC18XX_CREG_CREG6_ETHMODE_MASK, ethmode);
6365
64− return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
66+ ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
67+ if (ret)
68+ goto err_remove_config_dt;
69+
70+ return 0;
71+
72+err_remove_config_dt:
73+ stmmac_remove_config_dt(pdev, plat_dat);
74+
75+ return ret;
6576 }
6677
6778 static const struct of_device_id lpc18xx_dwmac_match[] = {
drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c+18−5
@@ -64,18 +64,31 @@ static int meson6_dwmac_probe(struct platform_device *pdev) · 63 unmodified lines
6464 return PTR_ERR(plat_dat);
6565
6666 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
67− if (!dwmac)
68− return -ENOMEM;
67+ if (!dwmac) {
68+ ret = -ENOMEM;
69+ goto err_remove_config_dt;
70+ }
6971
7072 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
7173 dwmac->reg = devm_ioremap_resource(&pdev->dev, res);
72− if (IS_ERR(dwmac->reg))
73− return PTR_ERR(dwmac->reg);
74+ if (IS_ERR(dwmac->reg)) {
75+ ret = PTR_ERR(dwmac->reg);
76+ goto err_remove_config_dt;
77+ }
7478
7579 plat_dat->bsp_priv = dwmac;
7680 plat_dat->fix_mac_speed = meson6_dwmac_fix_mac_speed;
7781
78− return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
82+ ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
83+ if (ret)
84+ goto err_remove_config_dt;
85+
86+ return 0;
87+
88+err_remove_config_dt:
89+ stmmac_remove_config_dt(pdev, plat_dat);
90+
91+ return ret;
7992 }
8093
8194 static const struct of_device_id meson6_dwmac_match[] = {
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c+24−8
@@ -264,32 +264,48 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) · 263 unmodified lines
264264 return PTR_ERR(plat_dat);
265265
266266 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
267− if (!dwmac)
268− return -ENOMEM;
267+ if (!dwmac) {
268+ ret = -ENOMEM;
269+ goto err_remove_config_dt;
270+ }
269271
270272 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
271273 dwmac->regs = devm_ioremap_resource(&pdev->dev, res);
272− if (IS_ERR(dwmac->regs))
273− return PTR_ERR(dwmac->regs);
274+ if (IS_ERR(dwmac->regs)) {
275+ ret = PTR_ERR(dwmac->regs);
276+ goto err_remove_config_dt;
277+ }
274278
275279 dwmac->pdev = pdev;
276280 dwmac->phy_mode = of_get_phy_mode(pdev->dev.of_node);
277281 if (dwmac->phy_mode < 0) {
278282 dev_err(&pdev->dev, "missing phy-mode property\n");
279− return -EINVAL;
283+ ret = -EINVAL;
284+ goto err_remove_config_dt;
280285 }
281286
282287 ret = meson8b_init_clk(dwmac);
283288 if (ret)
284− return ret;
289+ goto err_remove_config_dt;
285290
286291 ret = meson8b_init_prg_eth(dwmac);
287292 if (ret)
288− return ret;
293+ goto err_remove_config_dt;
289294
290295 plat_dat->bsp_priv = dwmac;
291296
292− return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
297+ ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
298+ if (ret)
299+ goto err_clk_disable;
300+
301+ return 0;
302+
303+err_clk_disable:
304+ clk_disable_unprepare(dwmac->m25_div_clk);
305+err_remove_config_dt:
306+ stmmac_remove_config_dt(pdev, plat_dat);
307+
308+ return ret;
293309 }
294310
295311 static int meson8b_dwmac_remove(struct platform_device *pdev)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c+17−4
@@ -981,14 +981,27 @@ static int rk_gmac_probe(struct platform_device *pdev) · 980 unmodified lines
981981 plat_dat->resume = rk_gmac_resume;
982982
983983 plat_dat->bsp_priv = rk_gmac_setup(pdev, data);
984− if (IS_ERR(plat_dat->bsp_priv))
985− return PTR_ERR(plat_dat->bsp_priv);
984+ if (IS_ERR(plat_dat->bsp_priv)) {
985+ ret = PTR_ERR(plat_dat->bsp_priv);
986+ goto err_remove_config_dt;
987+ }
986988
987989 ret = rk_gmac_init(pdev, plat_dat->bsp_priv);
988990 if (ret)
989− return ret;
991+ goto err_remove_config_dt;
992+
993+ ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
994+ if (ret)
995+ goto err_gmac_exit;
996+
997+ return 0;
998+
999+err_gmac_exit:
1000+ rk_gmac_exit(pdev, plat_dat->bsp_priv);
1001+err_remove_config_dt:
1002+ stmmac_remove_config_dt(pdev, plat_dat);
9901003
991− return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
1004+ return ret;
9921005 }
9931006
9941007 static const struct of_device_id rk_gmac_dwmac_match[] = {
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c+26−13
@@ -304,6 +304,8 @@ static int socfpga_dwmac_probe(struct platform_device *pdev) · 303 unmodified lines
304304 struct device *dev = &pdev->dev;
305305 int ret;
306306 struct socfpga_dwmac *dwmac;
307+ struct net_device *ndev;
308+ struct stmmac_priv *stpriv;
307309
308310 ret = stmmac_get_platform_resources(pdev, &stmmac_res);
309311 if (ret)
@@ -314,32 +316,43 @@ static int socfpga_dwmac_probe(struct platform_device *pdev) · 4 unmodified lines
314316 return PTR_ERR(plat_dat);
315317
316318 dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL);
317− if (!dwmac)
318− return -ENOMEM;
319+ if (!dwmac) {
320+ ret = -ENOMEM;
321+ goto err_remove_config_dt;
322+ }
319323
320324 ret = socfpga_dwmac_parse_data(dwmac, dev);
321325 if (ret) {
322326 dev_err(dev, "Unable to parse OF data\n");
323− return ret;
327+ goto err_remove_config_dt;
324328 }
325329
326330 plat_dat->bsp_priv = dwmac;
327331 plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed;
328332
329333 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
334+ if (ret)
335+ goto err_remove_config_dt;
330336
331− if (!ret) {
332− struct net_device *ndev = platform_get_drvdata(pdev);
333− struct stmmac_priv *stpriv = netdev_priv(ndev);
337+ ndev = platform_get_drvdata(pdev);
338+ stpriv = netdev_priv(ndev);
334339
335− /* The socfpga driver needs to control the stmmac reset to
336− * set the phy mode. Create a copy of the core reset handel
337− * so it can be used by the driver later.
338− */
339− dwmac->stmmac_rst = stpriv->stmmac_rst;
340+ /* The socfpga driver needs to control the stmmac reset to set the phy
341+ * mode. Create a copy of the core reset handle so it can be used by
342+ * the driver later.
343+ */
344+ dwmac->stmmac_rst = stpriv->stmmac_rst;
340345
341− ret = socfpga_dwmac_set_phy_mode(dwmac);
342− }
346+ ret = socfpga_dwmac_set_phy_mode(dwmac);
347+ if (ret)
348+ goto err_dvr_remove;
349+
350+ return 0;
351+
352+err_dvr_remove:
353+ stmmac_dvr_remove(&pdev->dev);
354+err_remove_config_dt:
355+ stmmac_remove_config_dt(pdev, plat_dat);
343356
344357 return ret;
345358 }
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c+18−5
@@ -345,13 +345,15 @@ static int sti_dwmac_probe(struct platform_device *pdev) · 344 unmodified lines
345345 return PTR_ERR(plat_dat);
346346
347347 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
348− if (!dwmac)
349− return -ENOMEM;
348+ if (!dwmac) {
349+ ret = -ENOMEM;
350+ goto err_remove_config_dt;
351+ }
350352
351353 ret = sti_dwmac_parse_data(dwmac, pdev);
352354 if (ret) {
353355 dev_err(&pdev->dev, "Unable to parse OF data\n");
354− return ret;
356+ goto err_remove_config_dt;
355357 }
356358
357359 dwmac->fix_retime_src = data->fix_retime_src;
@@ -363,9 +365,20 @@ static int sti_dwmac_probe(struct platform_device *pdev) · 5 unmodified lines
363365
364366 ret = sti_dwmac_init(pdev, plat_dat->bsp_priv);
365367 if (ret)
366− return ret;
368+ goto err_remove_config_dt;
369+
370+ ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
371+ if (ret)
372+ goto err_dwmac_exit;
373+
374+ return 0;
375+
376+err_dwmac_exit:
377+ sti_dwmac_exit(pdev, plat_dat->bsp_priv);
378+err_remove_config_dt:
379+ stmmac_remove_config_dt(pdev, plat_dat);
367380
368− return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
381+ return ret;
369382 }
370383
371384 static const struct sti_dwmac_of_data stih4xx_dwmac_data = {
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c+14−5
@@ -107,24 +107,33 @@ static int stm32_dwmac_probe(struct platform_device *pdev) · 106 unmodified lines
107107 return PTR_ERR(plat_dat);
108108
109109 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
110− if (!dwmac)
111− return -ENOMEM;
110+ if (!dwmac) {
111+ ret = -ENOMEM;
112+ goto err_remove_config_dt;
113+ }
112114
113115 ret = stm32_dwmac_parse_data(dwmac, &pdev->dev);
114116 if (ret) {
115117 dev_err(&pdev->dev, "Unable to parse OF data\n");
116− return ret;
118+ goto err_remove_config_dt;
117119 }
118120
119121 plat_dat->bsp_priv = dwmac;
120122
121123 ret = stm32_dwmac_init(plat_dat);
122124 if (ret)
123− return ret;
125+ goto err_remove_config_dt;
124126
125127 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
126128 if (ret)
127− stm32_dwmac_clk_disable(dwmac);
129+ goto err_clk_disable;
130+
131+ return 0;
132+
133+err_clk_disable:
134+ stm32_dwmac_clk_disable(dwmac);
135+err_remove_config_dt:
136+ stmmac_remove_config_dt(pdev, plat_dat);
128137
129138 return ret;
130139 }
drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c+19−7
@@ -120,22 +120,27 @@ static int sun7i_gmac_probe(struct platform_device *pdev) · 119 unmodified lines
120120 return PTR_ERR(plat_dat);
121121
122122 gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL);
123− if (!gmac)
124− return -ENOMEM;
123+ if (!gmac) {
124+ ret = -ENOMEM;
125+ goto err_remove_config_dt;
126+ }
125127
126128 gmac->interface = of_get_phy_mode(dev->of_node);
127129
128130 gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx");
129131 if (IS_ERR(gmac->tx_clk)) {
130132 dev_err(dev, "could not get tx clock\n");
131− return PTR_ERR(gmac->tx_clk);
133+ ret = PTR_ERR(gmac->tx_clk);
134+ goto err_remove_config_dt;
132135 }
133136
134137 /* Optional regulator for PHY */
135138 gmac->regulator = devm_regulator_get_optional(dev, "phy");
136139 if (IS_ERR(gmac->regulator)) {
137− if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER)
138− return -EPROBE_DEFER;
140+ if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER) {
141+ ret = -EPROBE_DEFER;
142+ goto err_remove_config_dt;
143+ }
139144 dev_info(dev, "no regulator found\n");
140145 gmac->regulator = NULL;
141146 }
@@ -151,11 +156,18 @@ static int sun7i_gmac_probe(struct platform_device *pdev) · 9 unmodified lines
151156
152157 ret = sun7i_gmac_init(pdev, plat_dat->bsp_priv);
153158 if (ret)
154− return ret;
159+ goto err_remove_config_dt;
155160
156161 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
157162 if (ret)
158− sun7i_gmac_exit(pdev, plat_dat->bsp_priv);
163+ goto err_gmac_exit;
164+
165+ return 0;
166+
167+err_gmac_exit:
168+ sun7i_gmac_exit(pdev, plat_dat->bsp_priv);
169+err_remove_config_dt:
170+ stmmac_remove_config_dt(pdev, plat_dat);
159171
160172 return ret;
161173 }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c+0−1
@@ -3416,7 +3416,6 @@ int stmmac_dvr_remove(struct device *dev) · 3415 unmodified lines
34163416 stmmac_set_mac(priv->ioaddr, false);
34173417 netif_carrier_off(ndev);
34183418 unregister_netdev(ndev);
3419− of_node_put(priv->plat->phy_node);
34203419 if (priv->stmmac_rst)
34213420 reset_control_assert(priv->stmmac_rst);
34223421 clk_disable_unprepare(priv->pclk);
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c+29−4
@@ -200,7 +200,6 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat, · 199 unmodified lines
200200 /**
201201 * stmmac_probe_config_dt - parse device-tree driver parameters
202202 * @pdev: platform_device structure
203− * @plat: driver data platform structure
204203 * @mac: MAC address to use
205204 * Description:
206205 * this function is to read the driver parameters from device-tree and
@@ -306,7 +305,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) · 99 unmodified lines
306305 dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg),
307306 GFP_KERNEL);
308307 if (!dma_cfg) {
309− of_node_put(plat->phy_node);
308+ stmmac_remove_config_dt(pdev, plat);
310309 return ERR_PTR(-ENOMEM);
311310 }
312311 plat->dma_cfg = dma_cfg;
@@ -329,14 +328,37 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) · 16 unmodified lines
329328
330329 return plat;
331330 }
331+
332+/**
333+ * stmmac_remove_config_dt - undo the effects of stmmac_probe_config_dt()
334+ * @pdev: platform_device structure
335+ * @plat: driver data platform structure
336+ *
337+ * Release resources claimed by stmmac_probe_config_dt().
338+ */
339+void stmmac_remove_config_dt(struct platform_device *pdev,
340+ struct plat_stmmacenet_data *plat)
341+{
342+ struct device_node *np = pdev->dev.of_node;
343+
344+ if (of_phy_is_fixed_link(np))
345+ of_phy_deregister_fixed_link(np);
346+ of_node_put(plat->phy_node);
347+}
332348 #else
333349 struct plat_stmmacenet_data *
334350 stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
335351 {
336352 return ERR_PTR(-ENOSYS);
337353 }
354+
355+void stmmac_remove_config_dt(struct platform_device *pdev,
356+ struct plat_stmmacenet_data *plat)
357+{
358+}
338359 #endif /* CONFIG_OF */
339360 EXPORT_SYMBOL_GPL(stmmac_probe_config_dt);
361+EXPORT_SYMBOL_GPL(stmmac_remove_config_dt);
340362
341363 int stmmac_get_platform_resources(struct platform_device *pdev,
342364 struct stmmac_resources *stmmac_res)
@@ -392,10 +414,13 @@ int stmmac_pltfr_remove(struct platform_device *pdev) · 49 unmodified lines
392414 {
393415 struct net_device *ndev = platform_get_drvdata(pdev);
394416 struct stmmac_priv *priv = netdev_priv(ndev);
417+ struct plat_stmmacenet_data *plat = priv->plat;
395418 int ret = stmmac_dvr_remove(&pdev->dev);
396419
397− if (priv->plat->exit)
398− priv->plat->exit(pdev, priv->plat->bsp_priv);
420+ if (plat->exit)
421+ plat->exit(pdev, plat->bsp_priv);
422+
423+ stmmac_remove_config_dt(pdev, plat);
399424
400425 return ret;
401426 }
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h+2−0
@@ -23,6 +23,8 @@ · 22 unmodified lines
2323
2424 struct plat_stmmacenet_data *
2525 stmmac_probe_config_dt(struct platform_device *pdev, const char **mac);
26+void stmmac_remove_config_dt(struct platform_device *pdev,
27+ struct plat_stmmacenet_data *plat);
2628
2729 int stmmac_get_platform_resources(struct platform_device *pdev,
2830 struct stmmac_resources *stmmac_res);
drivers/net/ethernet/synopsys/dwc_eth_qos.c+13−7
@@ -2881,7 +2881,7 @@ static int dwceqos_probe(struct platform_device *pdev) · 2880 unmodified lines
28812881 ret = of_get_phy_mode(lp->pdev->dev.of_node);
28822882 if (ret < 0) {
28832883 dev_err(&lp->pdev->dev, "error in getting phy i/f\n");
2884− goto err_out_clk_dis_phy;
2884+ goto err_out_deregister_fixed_link;
28852885 }
28862886
28872887 lp->phy_interface = ret;
@@ -2889,14 +2889,14 @@ static int dwceqos_probe(struct platform_device *pdev) · 1 unmodified line
28892889 ret = dwceqos_mii_init(lp);
28902890 if (ret) {
28912891 dev_err(&lp->pdev->dev, "error in dwceqos_mii_init\n");
2892− goto err_out_clk_dis_phy;
2892+ goto err_out_deregister_fixed_link;
28932893 }
28942894
28952895 ret = dwceqos_mii_probe(ndev);
28962896 if (ret != 0) {
28972897 netdev_err(ndev, "mii_probe fail.\n");
28982898 ret = -ENXIO;
2899− goto err_out_clk_dis_phy;
2899+ goto err_out_deregister_fixed_link;
29002900 }
29012901
29022902 dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0);
@@ -2914,7 +2914,7 @@ static int dwceqos_probe(struct platform_device *pdev) · 11 unmodified lines
29142914 if (ret) {
29152915 dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n",
29162916 ret);
2917− goto err_out_clk_dis_phy;
2917+ goto err_out_deregister_fixed_link;
29182918 }
29192919 dev_info(&lp->pdev->dev, "pdev->id %d, baseaddr 0x%08lx, irq %d\n",
29202920 pdev->id, ndev->base_addr, ndev->irq);
@@ -2924,7 +2924,7 @@ static int dwceqos_probe(struct platform_device *pdev) · 3 unmodified lines
29242924 if (ret) {
29252925 dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n",
29262926 ndev->irq, ret);
2927− goto err_out_clk_dis_phy;
2927+ goto err_out_deregister_fixed_link;
29282928 }
29292929
29302930 if (netif_msg_probe(lp))
@@ -2935,11 +2935,14 @@ static int dwceqos_probe(struct platform_device *pdev) · 4 unmodified lines
29352935 ret = register_netdev(ndev);
29362936 if (ret) {
29372937 dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
2938− goto err_out_clk_dis_phy;
2938+ goto err_out_deregister_fixed_link;
29392939 }
29402940
29412941 return 0;
29422942
2943+err_out_deregister_fixed_link:
2944+ if (of_phy_is_fixed_link(pdev->dev.of_node))
2945+ of_phy_deregister_fixed_link(pdev->dev.of_node);
29432946 err_out_clk_dis_phy:
29442947 clk_disable_unprepare(lp->phy_ref_clk);
29452948 err_out_clk_dis_aper:
@@ -2959,8 +2962,11 @@ static int dwceqos_remove(struct platform_device *pdev) · 13 unmodified lines
29592962 if (ndev) {
29602963 lp = netdev_priv(ndev);
29612964
2962− if (ndev->phydev)
2965+ if (ndev->phydev) {
29632966 phy_disconnect(ndev->phydev);
2967+ if (of_phy_is_fixed_link(pdev->dev.of_node))
2968+ of_phy_deregister_fixed_link(pdev->dev.of_node);
2969+ }
29642970 mdiobus_unregister(lp->mii_bus);
29652971 mdiobus_free(lp->mii_bus);
29662972
drivers/net/ethernet/ti/cpsw.c+6−14
@@ -2459,20 +2459,8 @@ static void cpsw_remove_dt(struct platform_device *pdev) · 2458 unmodified lines
24592459 if (strcmp(slave_node->name, "slave"))
24602460 continue;
24612461
2462− if (of_phy_is_fixed_link(slave_node)) {
2463− struct phy_device *phydev;
2464−
2465− phydev = of_phy_find_device(slave_node);
2466− if (phydev) {
2467− fixed_phy_unregister(phydev);
2468− /* Put references taken by
2469− * of_phy_find_device() and
2470− * of_phy_register_fixed_link().
2471− */
2472− phy_device_free(phydev);
2473− phy_device_free(phydev);
2474− }
2475− }
2462+ if (of_phy_is_fixed_link(slave_node))
2463+ of_phy_deregister_fixed_link(slave_node);
24762464
24772465 of_node_put(slave_data->phy_node);
24782466
@@ -2942,6 +2930,8 @@ static int cpsw_resume(struct device *dev) · 463 unmodified lines
29422930 /* Select default pin state */
29432931 pinctrl_pm_select_default_state(dev);
29442932
2933+ /* shut up ASSERT_RTNL() warning in netif_set_real_num_tx/rx_queues */
2934+ rtnl_lock();
29452935 if (cpsw->data.dual_emac) {
29462936 int i;
29472937
@@ -2953,6 +2943,8 @@ static int cpsw_resume(struct device *dev) · 5 unmodified lines
29532943 if (netif_running(ndev))
29542944 cpsw_ndo_open(ndev);
29552945 }
2946+ rtnl_unlock();
2947+
29562948 return 0;
29572949 }
29582950 #endif
drivers/net/ethernet/ti/davinci_emac.c+9−1
@@ -1767,6 +1767,7 @@ static int davinci_emac_try_get_mac(struct platform_device *pdev, · 1766 unmodified lines
17671767 */
17681768 static int davinci_emac_probe(struct platform_device *pdev)
17691769 {
1770+ struct device_node *np = pdev->dev.of_node;
17701771 int rc = 0;
17711772 struct resource *res, *res_ctrl;
17721773 struct net_device *ndev;
@@ -1805,7 +1806,7 @@ static int davinci_emac_probe(struct platform_device *pdev) · 32 unmodified lines
18051806 if (!pdata) {
18061807 dev_err(&pdev->dev, "no platform data\n");
18071808 rc = -ENODEV;
1808− goto no_pdata;
1809+ goto err_free_netdev;
18091810 }
18101811
18111812 /* MAC addr and PHY mask , RMII enable info from platform_data */
@@ -1941,6 +1942,10 @@ no_cpdma_chan: · 129 unmodified lines
19411942 cpdma_chan_destroy(priv->rxchan);
19421943 cpdma_ctlr_destroy(priv->dma);
19431944 no_pdata:
1945+ if (of_phy_is_fixed_link(np))
1946+ of_phy_deregister_fixed_link(np);
1947+ of_node_put(priv->phy_node);
1948+err_free_netdev:
19441949 free_netdev(ndev);
19451950 return rc;
19461951 }
@@ -1956,6 +1961,7 @@ static int davinci_emac_remove(struct platform_device *pdev) · 9 unmodified lines
19561961 {
19571962 struct net_device *ndev = platform_get_drvdata(pdev);
19581963 struct emac_priv *priv = netdev_priv(ndev);
1964+ struct device_node *np = pdev->dev.of_node;
19591965
19601966 dev_notice(&ndev->dev, "DaVinci EMAC: davinci_emac_remove()\n");
19611967
@@ -1968,6 +1974,8 @@ static int davinci_emac_remove(struct platform_device *pdev) · 6 unmodified lines
19681974 unregister_netdev(ndev);
19691975 of_node_put(priv->phy_node);
19701976 pm_runtime_disable(&pdev->dev);
1977+ if (of_phy_is_fixed_link(np))
1978+ of_phy_deregister_fixed_link(np);
19711979 free_netdev(ndev);
19721980
19731981 return 0;
drivers/net/geneve.c+4−10
@@ -859,7 +859,6 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 858 unmodified lines
859859 struct geneve_dev *geneve = netdev_priv(dev);
860860 struct geneve_sock *gs4;
861861 struct rtable *rt = NULL;
862− const struct iphdr *iip; /* interior IP header */
863862 int err = -EINVAL;
864863 struct flowi4 fl4;
865864 __u8 tos, ttl;
@@ -890,8 +889,6 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 24 unmodified lines
890889 sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
891890 skb_reset_mac_header(skb);
892891
893− iip = ip_hdr(skb);
894−
895892 if (info) {
896893 const struct ip_tunnel_key *key = &info->key;
897894 u8 *opts = NULL;
@@ -911,7 +908,7 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 13 unmodified lines
911908 if (unlikely(err))
912909 goto tx_error;
913910
914− tos = ip_tunnel_ecn_encap(key->tos, iip, skb);
911+ tos = ip_tunnel_ecn_encap(key->tos, ip_hdr(skb), skb);
915912 ttl = key->ttl;
916913 df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
917914 } else {
@@ -920,7 +917,7 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 2 unmodified lines
920917 if (unlikely(err))
921918 goto tx_error;
922919
923− tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, iip, skb);
920+ tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, ip_hdr(skb), skb);
924921 ttl = geneve->ttl;
925922 if (!ttl && IN_MULTICAST(ntohl(fl4.daddr)))
926923 ttl = 1;
@@ -952,7 +949,6 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 25 unmodified lines
952949 {
953950 struct geneve_dev *geneve = netdev_priv(dev);
954951 struct dst_entry *dst = NULL;
955− const struct iphdr *iip; /* interior IP header */
956952 struct geneve_sock *gs6;
957953 int err = -EINVAL;
958954 struct flowi6 fl6;
@@ -982,8 +978,6 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 23 unmodified lines
982978 sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
983979 skb_reset_mac_header(skb);
984980
985− iip = ip_hdr(skb);
986−
987981 if (info) {
988982 const struct ip_tunnel_key *key = &info->key;
989983 u8 *opts = NULL;
@@ -1004,7 +998,7 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 14 unmodified lines
1004998 if (unlikely(err))
1005999 goto tx_error;
10061000
1007− prio = ip_tunnel_ecn_encap(key->tos, iip, skb);
1001+ prio = ip_tunnel_ecn_encap(key->tos, ip_hdr(skb), skb);
10081002 ttl = key->ttl;
10091003 label = info->key.label;
10101004 } else {
@@ -1014,7 +1008,7 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 3 unmodified lines
10141008 goto tx_error;
10151009
10161010 prio = ip_tunnel_ecn_encap(ip6_tclass(fl6.flowlabel),
1017− iip, skb);
1011+ ip_hdr(skb), skb);
10181012 ttl = geneve->ttl;
10191013 if (!ttl && ipv6_addr_is_multicast(&fl6.daddr))
10201014 ttl = 1;
drivers/net/ipvlan/ipvlan_main.c+12−5
@@ -497,6 +497,7 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev, · 496 unmodified lines
497497 struct net_device *phy_dev;
498498 int err;
499499 u16 mode = IPVLAN_MODE_L3;
500+ bool create = false;
500501
501502 if (!tb[IFLA_LINK])
502503 return -EINVAL;
@@ -513,6 +514,7 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev, · 10 unmodified lines
513514 err = ipvlan_port_create(phy_dev);
514515 if (err < 0)
515516 return err;
517+ create = true;
516518 }
517519
518520 if (data && data[IFLA_IPVLAN_MODE])
@@ -536,22 +538,27 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev, · 17 unmodified lines
536538
537539 err = register_netdevice(dev);
538540 if (err < 0)
539− return err;
541+ goto destroy_ipvlan_port;
540542
541543 err = netdev_upper_dev_link(phy_dev, dev);
542544 if (err) {
543− unregister_netdevice(dev);
544− return err;
545+ goto unregister_netdev;
545546 }
546547 err = ipvlan_set_port_mode(port, mode);
547548 if (err) {
548− unregister_netdevice(dev);
549− return err;
549+ goto unregister_netdev;
550550 }
551551
552552 list_add_tail_rcu(&ipvlan->pnode, &port->ipvlans);
553553 netif_stacked_transfer_operstate(phy_dev, dev);
554554 return 0;
555+
556+unregister_netdev:
557+ unregister_netdevice(dev);
558+destroy_ipvlan_port:
559+ if (create)
560+ ipvlan_port_destroy(phy_dev);
561+ return err;
555562 }
556563
557564 static void ipvlan_link_delete(struct net_device *dev, struct list_head *head)
drivers/net/irda/w83977af_ir.c+3−1
@@ -518,7 +518,9 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, · 517 unmodified lines
518518
519519 mtt = irda_get_mtt(skb);
520520 pr_debug("%s(%ld), mtt=%d\n", __func__ , jiffies, mtt);
521− if (mtt)
521+ if (mtt > 1000)
522+ mdelay(mtt/1000);
523+ else if (mtt)
522524 udelay(mtt);
523525
524526 /* Enable DMA interrupt */
drivers/net/macvtap.c+12−7
@@ -491,7 +491,13 @@ static int macvtap_newlink(struct net *src_net, · 490 unmodified lines
491491 /* Don't put anything that may fail after macvlan_common_newlink
492492 * because we can't undo what it does.
493493 */
494− return macvlan_common_newlink(src_net, dev, tb, data);
494+ err = macvlan_common_newlink(src_net, dev, tb, data);
495+ if (err) {
496+ netdev_rx_handler_unregister(dev);
497+ return err;
498+ }
499+
500+ return 0;
495501 }
496502
497503 static void macvtap_dellink(struct net_device *dev,
@@ -736,13 +742,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, · 238 unmodified lines
736742
737743 if (zerocopy)
738744 err = zerocopy_sg_from_iter(skb, from);
739− else {
745+ else
740746 err = skb_copy_datagram_from_iter(skb, 0, from, len);
741− if (!err && m && m->msg_control) {
742− struct ubuf_info *uarg = m->msg_control;
743− uarg->callback(uarg, false);
744− }
745− }
746747
747748 if (err)
748749 goto err_kfree;
@@ -773,7 +774,11 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, · 24 unmodified lines
773774 skb_shinfo(skb)->destructor_arg = m->msg_control;
774775 skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
775776 skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
777+ } else if (m && m->msg_control) {
778+ struct ubuf_info *uarg = m->msg_control;
779+ uarg->callback(uarg, false);
776780 }
781+
777782 if (vlan) {
778783 skb->dev = vlan->dev;
779784 dev_queue_xmit(skb);
drivers/net/phy/realtek.c+12−8
@@ -102,15 +102,19 @@ static int rtl8211f_config_init(struct phy_device *phydev) · 101 unmodified lines
102102 if (ret < 0)
103103 return ret;
104104
105− if (phydev->interface == PHY_INTERFACE_MODE_RGMII) {
106− /* enable TXDLY */
107− phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08);
108− reg = phy_read(phydev, 0x11);
105+ phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08);
106+ reg = phy_read(phydev, 0x11);
107+
108+ /* enable TX-delay for rgmii-id and rgmii-txid, otherwise disable it */
109+ if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
110+ phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
109111 reg |= RTL8211F_TX_DELAY;
110− phy_write(phydev, 0x11, reg);
111− /* restore to default page 0 */
112− phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0);
113− }
112+ else
113+ reg &= ~RTL8211F_TX_DELAY;
114+
115+ phy_write(phydev, 0x11, reg);
116+ /* restore to default page 0 */
117+ phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0);
114118
115119 return 0;
116120 }
drivers/net/tun.c+4−6
@@ -1246,13 +1246,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · 1245 unmodified lines
12461246
12471247 if (zerocopy)
12481248 err = zerocopy_sg_from_iter(skb, from);
1249− else {
1249+ else
12501250 err = skb_copy_datagram_from_iter(skb, 0, from, len);
1251− if (!err && msg_control) {
1252− struct ubuf_info *uarg = msg_control;
1253− uarg->callback(uarg, false);
1254− }
1255− }
12561251
12571252 if (err) {
12581253 this_cpu_inc(tun->pcpu_stats->rx_dropped);
@@ -1298,6 +1293,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · 39 unmodified lines
12981293 skb_shinfo(skb)->destructor_arg = msg_control;
12991294 skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
13001295 skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
1296+ } else if (msg_control) {
1297+ struct ubuf_info *uarg = msg_control;
1298+ uarg->callback(uarg, false);
13011299 }
13021300
13031301 skb_reset_network_header(skb);
drivers/net/usb/asix_devices.c+3−3
@@ -603,12 +603,12 @@ static void ax88772_suspend(struct usbnet *dev) · 602 unmodified lines
603603 u16 medium;
604604
605605 /* Stop MAC operation */
606− medium = asix_read_medium_status(dev, 0);
606+ medium = asix_read_medium_status(dev, 1);
607607 medium &= ~AX_MEDIUM_RE;
608− asix_write_medium_mode(dev, medium, 0);
608+ asix_write_medium_mode(dev, medium, 1);
609609
610610 netdev_dbg(dev->net, "ax88772_suspend: medium=0x%04x\n",
611− asix_read_medium_status(dev, 0));
611+ asix_read_medium_status(dev, 1));
612612
613613 /* Preserve BMCR for restoring */
614614 priv->presvd_phy_bmcr =
drivers/net/usb/cdc_ether.c+31−7
@@ -388,12 +388,6 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb) · 387 unmodified lines
388388 case USB_CDC_NOTIFY_NETWORK_CONNECTION:
389389 netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n",
390390 event->wValue ? "on" : "off");
391−
392− /* Work-around for devices with broken off-notifications */
393− if (event->wValue &&
394− !test_bit(__LINK_STATE_NOCARRIER, &dev->net->state))
395− usbnet_link_change(dev, 0, 0);
396−
397391 usbnet_link_change(dev, !!event->wValue, 0);
398392 break;
399393 case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */
@@ -466,6 +460,36 @@ static int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, struct sk_buff *skb) · 66 unmodified lines
466460 return 1;
467461 }
468462
463+/* Ensure correct link state
464+ *
465+ * Some devices (ZTE MF823/831/910) export two carrier on notifications when
466+ * connected. This causes the link state to be incorrect. Work around this by
467+ * always setting the state to off, then on.
468+ */
469+void usbnet_cdc_zte_status(struct usbnet *dev, struct urb *urb)
470+{
471+ struct usb_cdc_notification *event;
472+
473+ if (urb->actual_length < sizeof(*event))
474+ return;
475+
476+ event = urb->transfer_buffer;
477+
478+ if (event->bNotificationType != USB_CDC_NOTIFY_NETWORK_CONNECTION) {
479+ usbnet_cdc_status(dev, urb);
480+ return;
481+ }
482+
483+ netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n",
484+ event->wValue ? "on" : "off");
485+
486+ if (event->wValue &&
487+ netif_carrier_ok(dev->net))
488+ netif_carrier_off(dev->net);
489+
490+ usbnet_link_change(dev, !!event->wValue, 0);
491+}
492+
469493 static const struct driver_info cdc_info = {
470494 .description = "CDC Ethernet Device",
471495 .flags = FLAG_ETHER | FLAG_POINTTOPOINT,
@@ -481,7 +505,7 @@ static const struct driver_info zte_cdc_info = { · 9 unmodified lines
481505 .flags = FLAG_ETHER | FLAG_POINTTOPOINT,
482506 .bind = usbnet_cdc_zte_bind,
483507 .unbind = usbnet_cdc_unbind,
484− .status = usbnet_cdc_status,
508+ .status = usbnet_cdc_zte_status,
485509 .set_rx_mode = usbnet_cdc_update_filter,
486510 .manage_power = usbnet_manage_power,
487511 .rx_fixup = usbnet_cdc_zte_rx_fixup,
drivers/net/usb/qmi_wwan.c+1−0
@@ -894,6 +894,7 @@ static const struct usb_device_id products[] = { · 893 unmodified lines
894894 {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */
895895 {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */
896896 {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */
897+ {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */
897898 {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */
898899 {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */
899900 {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */
drivers/net/vxlan.c+7−3
@@ -611,6 +611,7 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan, · 610 unmodified lines
611611 struct vxlan_rdst *rd = NULL;
612612 struct vxlan_fdb *f;
613613 int notify = 0;
614+ int rc;
614615
615616 f = __vxlan_find_mac(vxlan, mac);
616617 if (f) {
@@ -641,8 +642,7 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan, · 24 unmodified lines
641642 if ((flags & NLM_F_APPEND) &&
642643 (is_multicast_ether_addr(f->eth_addr) ||
643644 is_zero_ether_addr(f->eth_addr))) {
644− int rc = vxlan_fdb_append(f, ip, port, vni, ifindex,
645− &rd);
645+ rc = vxlan_fdb_append(f, ip, port, vni, ifindex, &rd);
646646
647647 if (rc < 0)
648648 return rc;
@@ -673,7 +673,11 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan, · 24 unmodified lines
673673 INIT_LIST_HEAD(&f->remotes);
674674 memcpy(f->eth_addr, mac, ETH_ALEN);
675675
676− vxlan_fdb_append(f, ip, port, vni, ifindex, &rd);
676+ rc = vxlan_fdb_append(f, ip, port, vni, ifindex, &rd);
677+ if (rc < 0) {
678+ kfree(f);
679+ return rc;
680+ }
677681
678682 ++vxlan->addrcnt;
679683 hlist_add_head_rcu(&f->hlist,
drivers/net/wireless/marvell/mwifiex/cfg80211.c+7−6
@@ -2222,8 +2222,9 @@ done: · 2221 unmodified lines
22222222 is_scanning_required = 1;
22232223 } else {
22242224 mwifiex_dbg(priv->adapter, MSG,
2225− "info: trying to associate to '%s' bssid %pM\n",
2226− (char *)req_ssid.ssid, bss->bssid);
2225+ "info: trying to associate to '%.*s' bssid %pM\n",
2226+ req_ssid.ssid_len, (char *)req_ssid.ssid,
2227+ bss->bssid);
22272228 memcpy(&priv->cfg_bssid, bss->bssid, ETH_ALEN);
22282229 break;
22292230 }
@@ -2283,8 +2284,8 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, · 53 unmodified lines
22832284 }
22842285
22852286 mwifiex_dbg(adapter, INFO,
2286− "info: Trying to associate to %s and bssid %pM\n",
2287− (char *)sme->ssid, sme->bssid);
2287+ "info: Trying to associate to %.*s and bssid %pM\n",
2288+ (int)sme->ssid_len, (char *)sme->ssid, sme->bssid);
22882289
22892290 if (!mwifiex_stop_bg_scan(priv))
22902291 cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy);
@@ -2417,8 +2418,8 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, · 126 unmodified lines
24172418 }
24182419
24192420 mwifiex_dbg(priv->adapter, MSG,
2420− "info: trying to join to %s and bssid %pM\n",
2421− (char *)params->ssid, params->bssid);
2421+ "info: trying to join to %.*s and bssid %pM\n",
2422+ params->ssid_len, (char *)params->ssid, params->bssid);
24222423
24232424 mwifiex_set_ibss_params(priv, params);
24242425
drivers/of/of_mdio.c+15−0
@@ -490,3 +490,18 @@ int of_phy_register_fixed_link(struct device_node *np) · 489 unmodified lines
490490 return -ENODEV;
491491 }
492492 EXPORT_SYMBOL(of_phy_register_fixed_link);
493+
494+void of_phy_deregister_fixed_link(struct device_node *np)
495+{
496+ struct phy_device *phydev;
497+
498+ phydev = of_phy_find_device(np);
499+ if (!phydev)
500+ return;
501+
502+ fixed_phy_unregister(phydev);
503+
504+ put_device(&phydev->mdio.dev); /* of_phy_find_device() */
505+ phy_device_free(phydev); /* fixed_phy_register() */
506+}
507+EXPORT_SYMBOL(of_phy_deregister_fixed_link);
drivers/pci/host/pcie-designware-plat.c+1−1
@@ -3,7 +3,7 @@ · 2 unmodified lines
33 *
44 * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
55 *
6− * Authors: Joao Pinto <jpmpinto@gmail.com>
6+ * Authors: Joao Pinto <Joao.Pinto@synopsys.com>
77 *
88 * This program is free software; you can redistribute it and/or modify
99 * it under the terms of the GNU General Public License version 2 as
drivers/pci/pcie/aer/aer_inject.c+0−14
@@ -307,20 +307,6 @@ out: · 306 unmodified lines
307307 return 0;
308308 }
309309
310−static struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
311−{
312− while (1) {
313− if (!pci_is_pcie(dev))
314− break;
315− if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
316− return dev;
317− if (!dev->bus->self)
318− break;
319− dev = dev->bus->self;
320− }
321− return NULL;
322−}
323−
324310 static int find_aer_device_iter(struct device *device, void *data)
325311 {
326312 struct pcie_device **result = data;
drivers/pci/probe.c+27−1
@@ -1439,6 +1439,21 @@ static void program_hpp_type1(struct pci_dev *dev, struct hpp_type1 *hpp) · 1438 unmodified lines
14391439 dev_warn(&dev->dev, "PCI-X settings not supported\n");
14401440 }
14411441
1442+static bool pcie_root_rcb_set(struct pci_dev *dev)
1443+{
1444+ struct pci_dev *rp = pcie_find_root_port(dev);
1445+ u16 lnkctl;
1446+
1447+ if (!rp)
1448+ return false;
1449+
1450+ pcie_capability_read_word(rp, PCI_EXP_LNKCTL, &lnkctl);
1451+ if (lnkctl & PCI_EXP_LNKCTL_RCB)
1452+ return true;
1453+
1454+ return false;
1455+}
1456+
14421457 static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
14431458 {
14441459 int pos;
@@ -1468,9 +1483,20 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) · 23 unmodified lines
14681483 ~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or);
14691484
14701485 /* Initialize Link Control Register */
1471− if (pcie_cap_has_lnkctl(dev))
1486+ if (pcie_cap_has_lnkctl(dev)) {
1487+
1488+ /*
1489+ * If the Root Port supports Read Completion Boundary of
1490+ * 128, set RCB to 128. Otherwise, clear it.
1491+ */
1492+ hpp->pci_exp_lnkctl_and |= PCI_EXP_LNKCTL_RCB;
1493+ hpp->pci_exp_lnkctl_or &= ~PCI_EXP_LNKCTL_RCB;
1494+ if (pcie_root_rcb_set(dev))
1495+ hpp->pci_exp_lnkctl_or |= PCI_EXP_LNKCTL_RCB;
1496+
14721497 pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL,
14731498 ~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or);
1499+ }
14741500
14751501 /* Find Advanced Error Reporting Enhanced Capability */
14761502 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
drivers/pwm/pwm-meson.c+1−0
@@ -474,6 +474,7 @@ static int meson_pwm_probe(struct platform_device *pdev) · 473 unmodified lines
474474 if (IS_ERR(meson->base))
475475 return PTR_ERR(meson->base);
476476
477+ spin_lock_init(&meson->lock);
477478 meson->chip.dev = &pdev->dev;
478479 meson->chip.ops = &meson_pwm_ops;
479480 meson->chip.base = -1;
drivers/pwm/sysfs.c+2−0
@@ -425,6 +425,8 @@ void pwmchip_sysfs_unexport_children(struct pwm_chip *chip) · 424 unmodified lines
425425 if (test_bit(PWMF_EXPORTED, &pwm->flags))
426426 pwm_unexport_child(parent, pwm);
427427 }
428+
429+ put_device(parent);
428430 }
429431
430432 static int __init pwm_sysfs_init(void)
drivers/scsi/be2iscsi/be_mgmt.c+1−1
@@ -1083,7 +1083,7 @@ unsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba *phba) · 1082 unmodified lines
10831083 nonemb_cmd = &phba->boot_struct.nonemb_cmd;
10841084 nonemb_cmd->size = sizeof(*resp);
10851085 nonemb_cmd->va = pci_alloc_consistent(phba->ctrl.pdev,
1086− sizeof(nonemb_cmd->size),
1086+ nonemb_cmd->size,
10871087 &nonemb_cmd->dma);
10881088 if (!nonemb_cmd->va) {
10891089 mutex_unlock(&ctrl->mbox_lock);
drivers/scsi/hpsa.c+11−5
@@ -2009,7 +2009,7 @@ static struct hpsa_scsi_dev_t *lookup_hpsa_scsi_dev(struct ctlr_info *h, · 2008 unmodified lines
20092009
20102010 static int hpsa_slave_alloc(struct scsi_device *sdev)
20112011 {
2012− struct hpsa_scsi_dev_t *sd;
2012+ struct hpsa_scsi_dev_t *sd = NULL;
20132013 unsigned long flags;
20142014 struct ctlr_info *h;
20152015
@@ -2026,7 +2026,8 @@ static int hpsa_slave_alloc(struct scsi_device *sdev) · 10 unmodified lines
20262026 sd->target = sdev_id(sdev);
20272027 sd->lun = sdev->lun;
20282028 }
2029− } else
2029+ }
2030+ if (!sd)
20302031 sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev),
20312032 sdev_id(sdev), sdev->lun);
20322033
@@ -3840,6 +3841,7 @@ static int hpsa_update_device_info(struct ctlr_info *h, · 1807 unmodified lines
38403841 sizeof(this_device->vendor));
38413842 memcpy(this_device->model, &inq_buff[16],
38423843 sizeof(this_device->model));
3844+ this_device->rev = inq_buff[2];
38433845 memset(this_device->device_id, 0,
38443846 sizeof(this_device->device_id));
38453847 if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8,
@@ -3929,10 +3931,14 @@ static void figure_bus_target_lun(struct ctlr_info *h, · 83 unmodified lines
39293931
39303932 if (!is_logical_dev_addr_mode(lunaddrbytes)) {
39313933 /* physical device, target and lun filled in later */
3932− if (is_hba_lunid(lunaddrbytes))
3934+ if (is_hba_lunid(lunaddrbytes)) {
3935+ int bus = HPSA_HBA_BUS;
3936+
3937+ if (!device->rev)
3938+ bus = HPSA_LEGACY_HBA_BUS;
39333939 hpsa_set_bus_target_lun(device,
3934− HPSA_HBA_BUS, 0, lunid & 0x3fff);
3935− else
3940+ bus, 0, lunid & 0x3fff);
3941+ } else
39363942 /* defer target, lun assignment for physical devices */
39373943 hpsa_set_bus_target_lun(device,
39383944 HPSA_PHYSICAL_DEVICE_BUS, -1, -1);
drivers/scsi/hpsa.h+2−0
@@ -69,6 +69,7 @@ struct hpsa_scsi_dev_t { · 68 unmodified lines
6969 u64 sas_address;
7070 unsigned char vendor[8]; /* bytes 8-15 of inquiry data */
7171 unsigned char model[16]; /* bytes 16-31 of inquiry data */
72+ unsigned char rev; /* byte 2 of inquiry data */
7273 unsigned char raid_level; /* from inquiry page 0xC1 */
7374 unsigned char volume_offline; /* discovered via TUR or VPD */
7475 u16 queue_depth; /* max queue_depth for this device */
@@ -402,6 +403,7 @@ struct offline_device_entry { · 327 unmodified lines
402403 #define HPSA_RAID_VOLUME_BUS 1
403404 #define HPSA_EXTERNAL_RAID_VOLUME_BUS 2
404405 #define HPSA_HBA_BUS 0
406+#define HPSA_LEGACY_HBA_BUS 3
405407
406408 /*
407409 Send the command to the hardware
drivers/scsi/libfc/fc_lport.c+1−1
@@ -308,7 +308,7 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost) · 307 unmodified lines
308308 fc_stats = &lport->host_stats;
309309 memset(fc_stats, 0, sizeof(struct fc_host_statistics));
310310
311− fc_stats->seconds_since_last_reset = (lport->boot_time - jiffies) / HZ;
311+ fc_stats->seconds_since_last_reset = (jiffies - lport->boot_time) / HZ;
312312
313313 for_each_possible_cpu(cpu) {
314314 struct fc_stats *stats;
drivers/scsi/mpt3sas/mpt3sas_scsih.c+8−5
@@ -3885,6 +3885,11 @@ _scsih_temp_threshold_events(struct MPT3SAS_ADAPTER *ioc, · 3884 unmodified lines
38853885 }
38863886 }
38873887
3888+static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd)
3889+{
3890+ return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16);
3891+}
3892+
38883893 /**
38893894 * _scsih_flush_running_cmds - completing outstanding commands.
38903895 * @ioc: per adapter object
@@ -3906,6 +3911,9 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc) · 15 unmodified lines
39063911 if (!scmd)
39073912 continue;
39083913 count++;
3914+ if (ata_12_16_cmd(scmd))
3915+ scsi_internal_device_unblock(scmd->device,
3916+ SDEV_RUNNING);
39093917 mpt3sas_base_free_smid(ioc, smid);
39103918 scsi_dma_unmap(scmd);
39113919 if (ioc->pci_error_recovery)
@@ -4010,11 +4018,6 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status) · 98 unmodified lines
40104018 SAM_STAT_CHECK_CONDITION;
40114019 }
40124020
4013−static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd)
4014−{
4015− return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16);
4016−}
4017−
40184021 /**
40194022 * scsih_qcmd - main scsi request entry point
40204023 * @scmd: pointer to scsi command object
drivers/scsi/mvsas/mv_sas.c+3−1
@@ -791,8 +791,10 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf · 790 unmodified lines
791791 slot->slot_tag = tag;
792792
793793 slot->buf = pci_pool_alloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma);
794− if (!slot->buf)
794+ if (!slot->buf) {
795+ rc = -ENOMEM;
795796 goto err_out_tag;
797+ }
796798 memset(slot->buf, 0, MVS_SLOT_BUF_SZ);
797799
798800 tei.task = task;
drivers/scsi/qlogicpti.h+2−2
@@ -356,8 +356,8 @@ struct qlogicpti { · 355 unmodified lines
356356
357357 /* The rest of the elements are unimportant for performance. */
358358 struct qlogicpti *next;
359− __u32 res_dvma; /* Ptr to RESPONSE bufs (DVMA)*/
360− __u32 req_dvma; /* Ptr to REQUEST bufs (DVMA) */
359+ dma_addr_t res_dvma; /* Ptr to RESPONSE bufs (DVMA)*/
360+ dma_addr_t req_dvma; /* Ptr to REQUEST bufs (DVMA) */
361361 u_char fware_majrev, fware_minrev, fware_micrev;
362362 struct Scsi_Host *qhost;
363363 int qpti_id;
fs/btrfs/ctree.h+0−3
@@ -3232,9 +3232,6 @@ int btrfs_dirty_pages(struct btrfs_root *root, struct inode *inode, · 3231 unmodified lines
32323232 loff_t pos, size_t write_bytes,
32333233 struct extent_state **cached);
32343234 int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end);
3235−ssize_t btrfs_copy_file_range(struct file *file_in, loff_t pos_in,
3236− struct file *file_out, loff_t pos_out,
3237− size_t len, unsigned int flags);
32383235 int btrfs_clone_file_range(struct file *file_in, loff_t pos_in,
32393236 struct file *file_out, loff_t pos_out, u64 len);
32403237
fs/btrfs/file.c+0−1
@@ -2998,7 +2998,6 @@ const struct file_operations btrfs_file_operations = { · 2997 unmodified lines
29982998 #ifdef CONFIG_COMPAT
29992999 .compat_ioctl = btrfs_compat_ioctl,
30003000 #endif
3001− .copy_file_range = btrfs_copy_file_range,
30023001 .clone_file_range = btrfs_clone_file_range,
30033002 .dedupe_file_range = btrfs_dedupe_file_range,
30043003 };
fs/btrfs/ioctl.c+0−12
@@ -3980,18 +3980,6 @@ out_unlock: · 3979 unmodified lines
39803980 return ret;
39813981 }
39823982
3983−ssize_t btrfs_copy_file_range(struct file *file_in, loff_t pos_in,
3984− struct file *file_out, loff_t pos_out,
3985− size_t len, unsigned int flags)
3986−{
3987− ssize_t ret;
3988−
3989− ret = btrfs_clone_files(file_out, file_in, pos_in, len, pos_out);
3990− if (ret == 0)
3991− ret = len;
3992− return ret;
3993−}
3994−
39953983 int btrfs_clone_file_range(struct file *src_file, loff_t off,
39963984 struct file *dst_file, loff_t destoff, u64 len)
39973985 {
fs/cifs/cifsencrypt.c+8−3
@@ -808,7 +808,11 @@ calc_seckey(struct cifs_ses *ses) · 807 unmodified lines
808808 struct crypto_skcipher *tfm_arc4;
809809 struct scatterlist sgin, sgout;
810810 struct skcipher_request *req;
811− unsigned char sec_key[CIFS_SESS_KEY_SIZE]; /* a nonce */
811+ unsigned char *sec_key;
812+
813+ sec_key = kmalloc(CIFS_SESS_KEY_SIZE, GFP_KERNEL);
814+ if (sec_key == NULL)
815+ return -ENOMEM;
812816
813817 get_random_bytes(sec_key, CIFS_SESS_KEY_SIZE);
814818
@@ -816,7 +820,7 @@ calc_seckey(struct cifs_ses *ses) · 1 unmodified line
816820 if (IS_ERR(tfm_arc4)) {
817821 rc = PTR_ERR(tfm_arc4);
818822 cifs_dbg(VFS, "could not allocate crypto API arc4\n");
819− return rc;
823+ goto out;
820824 }
821825
822826 rc = crypto_skcipher_setkey(tfm_arc4, ses->auth_key.response,
@@ -854,7 +858,8 @@ calc_seckey(struct cifs_ses *ses) · 31 unmodified lines
854858
855859 out_free_cipher:
856860 crypto_free_skcipher(tfm_arc4);
857−
861+out:
862+ kfree(sec_key);
858863 return rc;
859864 }
860865
fs/cifs/cifssmb.c+2−2
@@ -3427,6 +3427,7 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL, · 3426 unmodified lines
34273427 __u16 rc = 0;
34283428 struct cifs_posix_acl *cifs_acl = (struct cifs_posix_acl *)parm_data;
34293429 struct posix_acl_xattr_header *local_acl = (void *)pACL;
3430+ struct posix_acl_xattr_entry *ace = (void *)(local_acl + 1);
34303431 int count;
34313432 int i;
34323433
@@ -3453,8 +3454,7 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL, · 20 unmodified lines
34533454 return 0;
34543455 }
34553456 for (i = 0; i < count; i++) {
3456− rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i],
3457− (struct posix_acl_xattr_entry *)(local_acl + 1));
3457+ rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i], &ace[i]);
34583458 if (rc != 0) {
34593459 /* ACE not converted */
34603460 break;
fs/cifs/connect.c+18−7
@@ -412,6 +412,9 @@ cifs_reconnect(struct TCP_Server_Info *server) · 411 unmodified lines
412412 }
413413 } while (server->tcpStatus == CifsNeedReconnect);
414414
415+ if (server->tcpStatus == CifsNeedNegotiate)
416+ mod_delayed_work(cifsiod_wq, &server->echo, 0);
417+
415418 return rc;
416419 }
417420
@@ -421,17 +424,25 @@ cifs_echo_request(struct work_struct *work) · 3 unmodified lines
421424 int rc;
422425 struct TCP_Server_Info *server = container_of(work,
423426 struct TCP_Server_Info, echo.work);
424− unsigned long echo_interval = server->echo_interval;
427+ unsigned long echo_interval;
428+
429+ /*
430+ * If we need to renegotiate, set echo interval to zero to
431+ * immediately call echo service where we can renegotiate.
432+ */
433+ if (server->tcpStatus == CifsNeedNegotiate)
434+ echo_interval = 0;
435+ else
436+ echo_interval = server->echo_interval;
425437
426438 /*
427− * We cannot send an echo if it is disabled or until the
428− * NEGOTIATE_PROTOCOL request is done, which is indicated by
429− * server->ops->need_neg() == true. Also, no need to ping if
430− * we got a response recently.
439+ * We cannot send an echo if it is disabled.
440+ * Also, no need to ping if we got a response recently.
431441 */
432442
433443 if (server->tcpStatus == CifsNeedReconnect ||
434− server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew ||
444+ server->tcpStatus == CifsExiting ||
445+ server->tcpStatus == CifsNew ||
435446 (server->ops->can_echo && !server->ops->can_echo(server)) ||
436447 time_before(jiffies, server->lstrp + echo_interval - HZ))
437448 goto requeue_echo;
@@ -442,7 +453,7 @@ cifs_echo_request(struct work_struct *work) · 4 unmodified lines
442453 server->hostname);
443454
444455 requeue_echo:
445− queue_delayed_work(cifsiod_wq, &server->echo, echo_interval);
456+ queue_delayed_work(cifsiod_wq, &server->echo, server->echo_interval);
446457 }
447458
448459 static bool
fs/isofs/rock.c+2−2
@@ -377,9 +377,9 @@ repeat: · 376 unmodified lines
377377 {
378378 int p;
379379 for (p = 0; p < rr->u.ER.len_id; p++)
380− printk("%c", rr->u.ER.data[p]);
380+ printk(KERN_CONT "%c", rr->u.ER.data[p]);
381381 }
382− printk("\n");
382+ printk(KERN_CONT "\n");
383383 break;
384384 case SIG('P', 'X'):
385385 inode->i_mode = isonum_733(rr->u.PX.mode);
fs/ocfs2/alloc.c+3−4
@@ -5194,7 +5194,7 @@ int ocfs2_change_extent_flag(handle_t *handle, · 5193 unmodified lines
51945194 rec = &el->l_recs[index];
51955195 if (new_flags && (rec->e_flags & new_flags)) {
51965196 mlog(ML_ERROR, "Owner %llu tried to set %d flags on an "
5197− "extent that already had them",
5197+ "extent that already had them\n",
51985198 (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci),
51995199 new_flags);
52005200 goto out;
@@ -5202,7 +5202,7 @@ int ocfs2_change_extent_flag(handle_t *handle, · 1 unmodified line
52025202
52035203 if (clear_flags && !(rec->e_flags & clear_flags)) {
52045204 mlog(ML_ERROR, "Owner %llu tried to clear %d flags on an "
5205− "extent that didn't have them",
5205+ "extent that didn't have them\n",
52065206 (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci),
52075207 clear_flags);
52085208 goto out;
@@ -5713,8 +5713,7 @@ int ocfs2_remove_btree_range(struct inode *inode, · 504 unmodified lines
57135713 struct ocfs2_refcount_tree *ref_tree = NULL;
57145714
57155715 if ((flags & OCFS2_EXT_REFCOUNTED) && len) {
5716− BUG_ON(!(OCFS2_I(inode)->ip_dyn_features &
5717− OCFS2_HAS_REFCOUNT_FL));
5716+ BUG_ON(!ocfs2_is_refcount_inode(inode));
57185717
57195718 if (!refcount_tree_locked) {
57205719 ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1,
fs/ocfs2/aops.c+20−11
@@ -464,6 +464,15 @@ static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) · 463 unmodified lines
464464 trace_ocfs2_bmap((unsigned long long)OCFS2_I(inode)->ip_blkno,
465465 (unsigned long long)block);
466466
467+ /*
468+ * The swap code (ab-)uses ->bmap to get a block mapping and then
469+ * bypasseѕ the file system for actual I/O. We really can't allow
470+ * that on refcounted inodes, so we have to skip out here. And yes,
471+ * 0 is the magic code for a bmap error..
472+ */
473+ if (ocfs2_is_refcount_inode(inode))
474+ return 0;
475+
467476 /* We don't need to lock journal system files, since they aren't
468477 * accessed concurrently from multiple nodes.
469478 */
@@ -2254,10 +2263,10 @@ out: · 1784 unmodified lines
22542263 return ret;
22552264 }
22562265
2257−static void ocfs2_dio_end_io_write(struct inode *inode,
2258− struct ocfs2_dio_write_ctxt *dwc,
2259− loff_t offset,
2260− ssize_t bytes)
2266+static int ocfs2_dio_end_io_write(struct inode *inode,
2267+ struct ocfs2_dio_write_ctxt *dwc,
2268+ loff_t offset,
2269+ ssize_t bytes)
22612270 {
22622271 struct ocfs2_cached_dealloc_ctxt dealloc;
22632272 struct ocfs2_extent_tree et;
@@ -2308,7 +2317,7 @@ static void ocfs2_dio_end_io_write(struct inode *inode, · 44 unmodified lines
23082317 mlog_errno(ret);
23092318 }
23102319
2311− di = (struct ocfs2_dinode *)di_bh;
2320+ di = (struct ocfs2_dinode *)di_bh->b_data;
23122321
23132322 ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh);
23142323
@@ -2365,6 +2374,8 @@ out: · 50 unmodified lines
23652374 if (locked)
23662375 inode_unlock(inode);
23672376 ocfs2_dio_free_write_ctx(inode, dwc);
2377+
2378+ return ret;
23682379 }
23692380
23702381 /*
@@ -2379,21 +2390,19 @@ static int ocfs2_dio_end_io(struct kiocb *iocb, · 8 unmodified lines
23792390 {
23802391 struct inode *inode = file_inode(iocb->ki_filp);
23812392 int level;
2382−
2383− if (bytes <= 0)
2384− return 0;
2393+ int ret = 0;
23852394
23862395 /* this io's submitter should not have unlocked this before we could */
23872396 BUG_ON(!ocfs2_iocb_is_rw_locked(iocb));
23882397
2389− if (private)
2390− ocfs2_dio_end_io_write(inode, private, offset, bytes);
2398+ if (bytes > 0 && private)
2399+ ret = ocfs2_dio_end_io_write(inode, private, offset, bytes);
23912400
23922401 ocfs2_iocb_clear_rw_locked(iocb);
23932402
23942403 level = ocfs2_iocb_rw_locked_level(iocb);
23952404 ocfs2_rw_unlock(inode, level);
2396− return 0;
2405+ return ret;
23972406 }
23982407
23992408 static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
fs/ocfs2/file.c+35−7
@@ -1030,7 +1030,7 @@ int ocfs2_extend_no_holes(struct inode *inode, struct buffer_head *di_bh, · 1029 unmodified lines
10301030 * Only quota files call this without a bh, and they can't be
10311031 * refcounted.
10321032 */
1033− BUG_ON(!di_bh && (oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL));
1033+ BUG_ON(!di_bh && ocfs2_is_refcount_inode(inode));
10341034 BUG_ON(!di_bh && !(oi->ip_flags & OCFS2_INODE_SYSTEM_FILE));
10351035
10361036 clusters_to_add = ocfs2_clusters_for_bytes(inode->i_sb, new_i_size);
@@ -1667,9 +1667,9 @@ static void ocfs2_calc_trunc_pos(struct inode *inode, · 630 unmodified lines
16671667 *done = ret;
16681668 }
16691669
1670−static int ocfs2_remove_inode_range(struct inode *inode,
1671− struct buffer_head *di_bh, u64 byte_start,
1672− u64 byte_len)
1670+int ocfs2_remove_inode_range(struct inode *inode,
1671+ struct buffer_head *di_bh, u64 byte_start,
1672+ u64 byte_len)
16731673 {
16741674 int ret = 0, flags = 0, done = 0, i;
16751675 u32 trunc_start, trunc_len, trunc_end, trunc_cpos, phys_cpos;
@@ -1719,8 +1719,7 @@ static int ocfs2_remove_inode_range(struct inode *inode, · 43 unmodified lines
17191719 * within one cluster(means is not exactly aligned to clustersize).
17201720 */
17211721
1722− if (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL) {
1723−
1722+ if (ocfs2_is_refcount_inode(inode)) {
17241723 ret = ocfs2_cow_file_pos(inode, di_bh, byte_start);
17251724 if (ret) {
17261725 mlog_errno(ret);
@@ -2036,7 +2035,7 @@ int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos, · 309 unmodified lines
20362035 struct super_block *sb = inode->i_sb;
20372036
20382037 if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb)) ||
2039− !(OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL) ||
2038+ !ocfs2_is_refcount_inode(inode) ||
20402039 OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
20412040 return 0;
20422041
@@ -2440,6 +2439,31 @@ out: · 397 unmodified lines
24402439 return offset;
24412440 }
24422441
2442+static int ocfs2_file_clone_range(struct file *file_in,
2443+ loff_t pos_in,
2444+ struct file *file_out,
2445+ loff_t pos_out,
2446+ u64 len)
2447+{
2448+ return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out,
2449+ len, false);
2450+}
2451+
2452+static ssize_t ocfs2_file_dedupe_range(struct file *src_file,
2453+ u64 loff,
2454+ u64 len,
2455+ struct file *dst_file,
2456+ u64 dst_loff)
2457+{
2458+ int error;
2459+
2460+ error = ocfs2_reflink_remap_range(src_file, loff, dst_file, dst_loff,
2461+ len, true);
2462+ if (error)
2463+ return error;
2464+ return len;
2465+}
2466+
24432467 const struct inode_operations ocfs2_file_iops = {
24442468 .setattr = ocfs2_setattr,
24452469 .getattr = ocfs2_getattr,
@@ -2479,6 +2503,8 @@ const struct file_operations ocfs2_fops = { · 33 unmodified lines
24792503 .splice_read = generic_file_splice_read,
24802504 .splice_write = iter_file_splice_write,
24812505 .fallocate = ocfs2_fallocate,
2506+ .clone_file_range = ocfs2_file_clone_range,
2507+ .dedupe_file_range = ocfs2_file_dedupe_range,
24822508 };
24832509
24842510 const struct file_operations ocfs2_dops = {
@@ -2524,6 +2550,8 @@ const struct file_operations ocfs2_fops_no_plocks = { · 39 unmodified lines
25242550 .splice_read = generic_file_splice_read,
25252551 .splice_write = iter_file_splice_write,
25262552 .fallocate = ocfs2_fallocate,
2553+ .clone_file_range = ocfs2_file_clone_range,
2554+ .dedupe_file_range = ocfs2_file_dedupe_range,
25272555 };
25282556
25292557 const struct file_operations ocfs2_dops_no_plocks = {
fs/ocfs2/file.h+3−0
@@ -82,4 +82,7 @@ int ocfs2_change_file_space(struct file *file, unsigned int cmd, · 81 unmodified lines
8282
8383 int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos,
8484 size_t count);
85+int ocfs2_remove_inode_range(struct inode *inode,
86+ struct buffer_head *di_bh, u64 byte_start,
87+ u64 byte_len);
8588 #endif /* OCFS2_FILE_H */
fs/ocfs2/inode.h+6−0
@@ -181,4 +181,10 @@ static inline struct ocfs2_inode_info *cache_info_to_inode(struct ocfs2_caching_ · 180 unmodified lines
181181 return container_of(ci, struct ocfs2_inode_info, ip_metadata_cache);
182182 }
183183
184+/* Does this inode have the reflink flag set? */
185+static inline bool ocfs2_is_refcount_inode(struct inode *inode)
186+{
187+ return (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL);
188+}
189+
184190 #endif /* OCFS2_INODE_H */
fs/ocfs2/move_extents.c+2−8
@@ -235,10 +235,7 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context, · 234 unmodified lines
235235 u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
236236
237237 if ((ext_flags & OCFS2_EXT_REFCOUNTED) && *len) {
238−
239− BUG_ON(!(OCFS2_I(inode)->ip_dyn_features &
240− OCFS2_HAS_REFCOUNT_FL));
241−
238+ BUG_ON(!ocfs2_is_refcount_inode(inode));
242239 BUG_ON(!context->refcount_loc);
243240
244241 ret = ocfs2_lock_refcount_tree(osb, context->refcount_loc, 1,
@@ -581,10 +578,7 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context, · 336 unmodified lines
581578 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
582579
583580 if ((ext_flags & OCFS2_EXT_REFCOUNTED) && len) {
584−
585− BUG_ON(!(OCFS2_I(inode)->ip_dyn_features &
586− OCFS2_HAS_REFCOUNT_FL));
587−
581+ BUG_ON(!ocfs2_is_refcount_inode(inode));
588582 BUG_ON(!context->refcount_loc);
589583
590584 ret = ocfs2_lock_refcount_tree(osb, context->refcount_loc, 1,
fs/ocfs2/refcounttree.c+451−13
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #include "xattr.h"
3535 #include "namei.h"
3636 #include "ocfs2_trace.h"
37+#include "file.h"
3738
3839 #include <linux/bio.h>
3940 #include <linux/blkdev.h>
@@ -410,7 +411,7 @@ static int ocfs2_get_refcount_block(struct inode *inode, u64 *ref_blkno) · 370 unmodified lines
410411 goto out;
411412 }
412413
413− BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL));
414+ BUG_ON(!ocfs2_is_refcount_inode(inode));
414415
415416 di = (struct ocfs2_dinode *)di_bh->b_data;
416417 *ref_blkno = le64_to_cpu(di->i_refcount_loc);
@@ -570,7 +571,7 @@ static int ocfs2_create_refcount_tree(struct inode *inode, · 153 unmodified lines
570571 u32 num_got;
571572 u64 suballoc_loc, first_blkno;
572573
573− BUG_ON(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL);
574+ BUG_ON(ocfs2_is_refcount_inode(inode));
574575
575576 trace_ocfs2_create_refcount_tree(
576577 (unsigned long long)OCFS2_I(inode)->ip_blkno);
@@ -708,7 +709,7 @@ static int ocfs2_set_refcount_tree(struct inode *inode, · 131 unmodified lines
708709 struct ocfs2_refcount_block *rb;
709710 struct ocfs2_refcount_tree *ref_tree;
710711
711− BUG_ON(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL);
712+ BUG_ON(ocfs2_is_refcount_inode(inode));
712713
713714 ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1,
714715 &ref_tree, &ref_root_bh);
@@ -775,7 +776,7 @@ int ocfs2_remove_refcount_tree(struct inode *inode, struct buffer_head *di_bh) · 60 unmodified lines
775776 u64 blk = 0, bg_blkno = 0, ref_blkno = le64_to_cpu(di->i_refcount_loc);
776777 u16 bit = 0;
777778
778− if (!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL))
779+ if (!ocfs2_is_refcount_inode(inode))
779780 return 0;
780781
781782 BUG_ON(!ref_blkno);
@@ -2299,11 +2300,10 @@ int ocfs2_decrease_refcount(struct inode *inode, · 1517 unmodified lines
22992300 {
23002301 int ret;
23012302 u64 ref_blkno;
2302− struct ocfs2_inode_info *oi = OCFS2_I(inode);
23032303 struct buffer_head *ref_root_bh = NULL;
23042304 struct ocfs2_refcount_tree *tree;
23052305
2306− BUG_ON(!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL));
2306+ BUG_ON(!ocfs2_is_refcount_inode(inode));
23072307
23082308 ret = ocfs2_get_refcount_block(inode, &ref_blkno);
23092309 if (ret) {
@@ -2533,7 +2533,6 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode, · 223 unmodified lines
25332533 int *ref_blocks)
25342534 {
25352535 int ret;
2536− struct ocfs2_inode_info *oi = OCFS2_I(inode);
25372536 struct buffer_head *ref_root_bh = NULL;
25382537 struct ocfs2_refcount_tree *tree;
25392538 u64 start_cpos = ocfs2_blocks_to_clusters(inode->i_sb, phys_blkno);
@@ -2544,7 +2543,7 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode, · 4 unmodified lines
25442543 goto out;
25452544 }
25462545
2547− BUG_ON(!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL));
2546+ BUG_ON(!ocfs2_is_refcount_inode(inode));
25482547
25492548 ret = ocfs2_get_refcount_tree(OCFS2_SB(inode->i_sb),
25502549 refcount_loc, &tree);
@@ -3412,14 +3411,13 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode, · 861 unmodified lines
34123411 {
34133412 int ret;
34143413 u32 cow_start = 0, cow_len = 0;
3415− struct ocfs2_inode_info *oi = OCFS2_I(inode);
34163414 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
34173415 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
34183416 struct buffer_head *ref_root_bh = NULL;
34193417 struct ocfs2_refcount_tree *ref_tree;
34203418 struct ocfs2_cow_context *context = NULL;
34213419
3422− BUG_ON(!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL));
3420+ BUG_ON(!ocfs2_is_refcount_inode(inode));
34233421
34243422 ret = ocfs2_refcount_cal_cow_clusters(inode, &di->id2.i_list,
34253423 cpos, write_len, max_cpos,
@@ -3629,11 +3627,10 @@ int ocfs2_refcount_cow_xattr(struct inode *inode, · 203 unmodified lines
36293627 {
36303628 int ret;
36313629 struct ocfs2_xattr_value_root *xv = vb->vb_xv;
3632− struct ocfs2_inode_info *oi = OCFS2_I(inode);
36333630 struct ocfs2_cow_context *context = NULL;
36343631 u32 cow_start, cow_len;
36353632
3636− BUG_ON(!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL));
3633+ BUG_ON(!ocfs2_is_refcount_inode(inode));
36373634
36383635 ret = ocfs2_refcount_cal_cow_clusters(inode, &xv->xr_list,
36393636 cpos, write_len, UINT_MAX,
@@ -3696,6 +3693,9 @@ int ocfs2_add_refcount_flag(struct inode *inode, · 56 unmodified lines
36963693 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
36973694 struct ocfs2_alloc_context *meta_ac = NULL;
36983695
3696+ /* We need to be able to handle at least an extent tree split. */
3697+ ref_blocks = ocfs2_extend_meta_needed(data_et->et_root_el);
3698+
36993699 ret = ocfs2_calc_refcount_meta_credits(inode->i_sb,
37003700 ref_ci, ref_root_bh,
37013701 p_cluster, num_clusters,
@@ -3807,7 +3807,7 @@ static int ocfs2_attach_refcount_tree(struct inode *inode, · 105 unmodified lines
38073807
38083808 ocfs2_init_dealloc_ctxt(&dealloc);
38093809
3810− if (!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)) {
3810+ if (!ocfs2_is_refcount_inode(inode)) {
38113811 ret = ocfs2_create_refcount_tree(inode, di_bh);
38123812 if (ret) {
38133813 mlog_errno(ret);
@@ -3934,6 +3934,13 @@ static int ocfs2_add_refcounted_extent(struct inode *inode, · 120 unmodified lines
39343934 ret = ocfs2_increase_refcount(handle, ref_ci, ref_root_bh,
39353935 p_cluster, num_clusters,
39363936 meta_ac, dealloc);
3937+ if (ret) {
3938+ mlog_errno(ret);
3939+ goto out_commit;
3940+ }
3941+
3942+ ret = dquot_alloc_space_nodirty(inode,
3943+ ocfs2_clusters_to_bytes(osb->sb, num_clusters));
39373944 if (ret)
39383945 mlog_errno(ret);
39393946
@@ -4442,3 +4449,434 @@ out: · 502 unmodified lines
44424449
44434450 return error;
44444451 }
4452+
4453+/* Update destination inode size, if necessary. */
4454+static int ocfs2_reflink_update_dest(struct inode *dest,
4455+ struct buffer_head *d_bh,
4456+ loff_t newlen)
4457+{
4458+ handle_t *handle;
4459+ int ret;
4460+
4461+ dest->i_blocks = ocfs2_inode_sector_count(dest);
4462+
4463+ if (newlen <= i_size_read(dest))
4464+ return 0;
4465+
4466+ handle = ocfs2_start_trans(OCFS2_SB(dest->i_sb),
4467+ OCFS2_INODE_UPDATE_CREDITS);
4468+ if (IS_ERR(handle)) {
4469+ ret = PTR_ERR(handle);
4470+ mlog_errno(ret);
4471+ return ret;
4472+ }
4473+
4474+ /* Extend i_size if needed. */
4475+ spin_lock(&OCFS2_I(dest)->ip_lock);
4476+ if (newlen > i_size_read(dest))
4477+ i_size_write(dest, newlen);
4478+ spin_unlock(&OCFS2_I(dest)->ip_lock);
4479+ dest->i_ctime = dest->i_mtime = current_time(dest);
4480+
4481+ ret = ocfs2_mark_inode_dirty(handle, dest, d_bh);
4482+ if (ret) {
4483+ mlog_errno(ret);
4484+ goto out_commit;
4485+ }
4486+
4487+out_commit:
4488+ ocfs2_commit_trans(OCFS2_SB(dest->i_sb), handle);
4489+ return ret;
4490+}
4491+
4492+/* Remap the range pos_in:len in s_inode to pos_out:len in t_inode. */
4493+static int ocfs2_reflink_remap_extent(struct inode *s_inode,
4494+ struct buffer_head *s_bh,
4495+ loff_t pos_in,
4496+ struct inode *t_inode,
4497+ struct buffer_head *t_bh,
4498+ loff_t pos_out,
4499+ loff_t len,
4500+ struct ocfs2_cached_dealloc_ctxt *dealloc)
4501+{
4502+ struct ocfs2_extent_tree s_et;
4503+ struct ocfs2_extent_tree t_et;
4504+ struct ocfs2_dinode *dis;
4505+ struct buffer_head *ref_root_bh = NULL;
4506+ struct ocfs2_refcount_tree *ref_tree;
4507+ struct ocfs2_super *osb;
4508+ loff_t pstart, plen;
4509+ u32 p_cluster, num_clusters, slast, spos, tpos;
4510+ unsigned int ext_flags;
4511+ int ret = 0;
4512+
4513+ osb = OCFS2_SB(s_inode->i_sb);
4514+ dis = (struct ocfs2_dinode *)s_bh->b_data;
4515+ ocfs2_init_dinode_extent_tree(&s_et, INODE_CACHE(s_inode), s_bh);
4516+ ocfs2_init_dinode_extent_tree(&t_et, INODE_CACHE(t_inode), t_bh);
4517+
4518+ spos = ocfs2_bytes_to_clusters(s_inode->i_sb, pos_in);
4519+ tpos = ocfs2_bytes_to_clusters(t_inode->i_sb, pos_out);
4520+ slast = ocfs2_clusters_for_bytes(s_inode->i_sb, pos_in + len);
4521+
4522+ while (spos < slast) {
4523+ if (fatal_signal_pending(current)) {
4524+ ret = -EINTR;
4525+ goto out;
4526+ }
4527+
4528+ /* Look up the extent. */
4529+ ret = ocfs2_get_clusters(s_inode, spos, &p_cluster,
4530+ &num_clusters, &ext_flags);
4531+ if (ret) {
4532+ mlog_errno(ret);
4533+ goto out;
4534+ }
4535+
4536+ num_clusters = min_t(u32, num_clusters, slast - spos);
4537+
4538+ /* Punch out the dest range. */
4539+ pstart = ocfs2_clusters_to_bytes(t_inode->i_sb, tpos);
4540+ plen = ocfs2_clusters_to_bytes(t_inode->i_sb, num_clusters);
4541+ ret = ocfs2_remove_inode_range(t_inode, t_bh, pstart, plen);
4542+ if (ret) {
4543+ mlog_errno(ret);
4544+ goto out;
4545+ }
4546+
4547+ if (p_cluster == 0)
4548+ goto next_loop;
4549+
4550+ /* Lock the refcount btree... */
4551+ ret = ocfs2_lock_refcount_tree(osb,
4552+ le64_to_cpu(dis->i_refcount_loc),
4553+ 1, &ref_tree, &ref_root_bh);
4554+ if (ret) {
4555+ mlog_errno(ret);
4556+ goto out;
4557+ }
4558+
4559+ /* Mark s_inode's extent as refcounted. */
4560+ if (!(ext_flags & OCFS2_EXT_REFCOUNTED)) {
4561+ ret = ocfs2_add_refcount_flag(s_inode, &s_et,
4562+ &ref_tree->rf_ci,
4563+ ref_root_bh, spos,
4564+ p_cluster, num_clusters,
4565+ dealloc, NULL);
4566+ if (ret) {
4567+ mlog_errno(ret);
4568+ goto out_unlock_refcount;
4569+ }
4570+ }
4571+
4572+ /* Map in the new extent. */
4573+ ext_flags |= OCFS2_EXT_REFCOUNTED;
4574+ ret = ocfs2_add_refcounted_extent(t_inode, &t_et,
4575+ &ref_tree->rf_ci,
4576+ ref_root_bh,
4577+ tpos, p_cluster,
4578+ num_clusters,
4579+ ext_flags,
4580+ dealloc);
4581+ if (ret) {
4582+ mlog_errno(ret);
4583+ goto out_unlock_refcount;
4584+ }
4585+
4586+ ocfs2_unlock_refcount_tree(osb, ref_tree, 1);
4587+ brelse(ref_root_bh);
4588+next_loop:
4589+ spos += num_clusters;
4590+ tpos += num_clusters;
4591+ }
4592+
4593+out:
4594+ return ret;
4595+out_unlock_refcount:
4596+ ocfs2_unlock_refcount_tree(osb, ref_tree, 1);
4597+ brelse(ref_root_bh);
4598+ return ret;
4599+}
4600+
4601+/* Set up refcount tree and remap s_inode to t_inode. */
4602+static int ocfs2_reflink_remap_blocks(struct inode *s_inode,
4603+ struct buffer_head *s_bh,
4604+ loff_t pos_in,
4605+ struct inode *t_inode,
4606+ struct buffer_head *t_bh,
4607+ loff_t pos_out,
4608+ loff_t len)
4609+{
4610+ struct ocfs2_cached_dealloc_ctxt dealloc;
4611+ struct ocfs2_super *osb;
4612+ struct ocfs2_dinode *dis;
4613+ struct ocfs2_dinode *dit;
4614+ int ret;
4615+
4616+ osb = OCFS2_SB(s_inode->i_sb);
4617+ dis = (struct ocfs2_dinode *)s_bh->b_data;
4618+ dit = (struct ocfs2_dinode *)t_bh->b_data;
4619+ ocfs2_init_dealloc_ctxt(&dealloc);
4620+
4621+ /*
4622+ * If we're reflinking the entire file and the source is inline
4623+ * data, just copy the contents.
4624+ */
4625+ if (pos_in == pos_out && pos_in == 0 && len == i_size_read(s_inode) &&
4626+ i_size_read(t_inode) <= len &&
4627+ (OCFS2_I(s_inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)) {
4628+ ret = ocfs2_duplicate_inline_data(s_inode, s_bh, t_inode, t_bh);
4629+ if (ret)
4630+ mlog_errno(ret);
4631+ goto out;
4632+ }
4633+
4634+ /*
4635+ * If both inodes belong to two different refcount groups then
4636+ * forget it because we don't know how (or want) to go merging
4637+ * refcount trees.
4638+ */
4639+ ret = -EOPNOTSUPP;
4640+ if (ocfs2_is_refcount_inode(s_inode) &&
4641+ ocfs2_is_refcount_inode(t_inode) &&
4642+ le64_to_cpu(dis->i_refcount_loc) !=
4643+ le64_to_cpu(dit->i_refcount_loc))
4644+ goto out;
4645+
4646+ /* Neither inode has a refcount tree. Add one to s_inode. */
4647+ if (!ocfs2_is_refcount_inode(s_inode) &&
4648+ !ocfs2_is_refcount_inode(t_inode)) {
4649+ ret = ocfs2_create_refcount_tree(s_inode, s_bh);
4650+ if (ret) {
4651+ mlog_errno(ret);
4652+ goto out;
4653+ }
4654+ }
4655+
4656+ /* Ensure that both inodes end up with the same refcount tree. */
4657+ if (!ocfs2_is_refcount_inode(s_inode)) {
4658+ ret = ocfs2_set_refcount_tree(s_inode, s_bh,
4659+ le64_to_cpu(dit->i_refcount_loc));
4660+ if (ret) {
4661+ mlog_errno(ret);
4662+ goto out;
4663+ }
4664+ }
4665+ if (!ocfs2_is_refcount_inode(t_inode)) {
4666+ ret = ocfs2_set_refcount_tree(t_inode, t_bh,
4667+ le64_to_cpu(dis->i_refcount_loc));
4668+ if (ret) {
4669+ mlog_errno(ret);
4670+ goto out;
4671+ }
4672+ }
4673+
4674+ /* Turn off inline data in the dest file. */
4675+ if (OCFS2_I(t_inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
4676+ ret = ocfs2_convert_inline_data_to_extents(t_inode, t_bh);
4677+ if (ret) {
4678+ mlog_errno(ret);
4679+ goto out;
4680+ }
4681+ }
4682+
4683+ /* Actually remap extents now. */
4684+ ret = ocfs2_reflink_remap_extent(s_inode, s_bh, pos_in, t_inode, t_bh,
4685+ pos_out, len, &dealloc);
4686+ if (ret) {
4687+ mlog_errno(ret);
4688+ goto out;
4689+ }
4690+
4691+out:
4692+ if (ocfs2_dealloc_has_cluster(&dealloc)) {
4693+ ocfs2_schedule_truncate_log_flush(osb, 1);
4694+ ocfs2_run_deallocs(osb, &dealloc);
4695+ }
4696+
4697+ return ret;
4698+}
4699+
4700+/* Lock an inode and grab a bh pointing to the inode. */
4701+static int ocfs2_reflink_inodes_lock(struct inode *s_inode,
4702+ struct buffer_head **bh1,
4703+ struct inode *t_inode,
4704+ struct buffer_head **bh2)
4705+{
4706+ struct inode *inode1;
4707+ struct inode *inode2;
4708+ struct ocfs2_inode_info *oi1;
4709+ struct ocfs2_inode_info *oi2;
4710+ bool same_inode = (s_inode == t_inode);
4711+ int status;
4712+
4713+ /* First grab the VFS and rw locks. */
4714+ lock_two_nondirectories(s_inode, t_inode);
4715+ inode1 = s_inode;
4716+ inode2 = t_inode;
4717+ if (inode1->i_ino > inode2->i_ino)
4718+ swap(inode1, inode2);
4719+
4720+ status = ocfs2_rw_lock(inode1, 1);
4721+ if (status) {
4722+ mlog_errno(status);
4723+ goto out_i1;
4724+ }
4725+ if (!same_inode) {
4726+ status = ocfs2_rw_lock(inode2, 1);
4727+ if (status) {
4728+ mlog_errno(status);
4729+ goto out_i2;
4730+ }
4731+ }
4732+
4733+ /* Now go for the cluster locks */
4734+ oi1 = OCFS2_I(inode1);
4735+ oi2 = OCFS2_I(inode2);
4736+
4737+ trace_ocfs2_double_lock((unsigned long long)oi1->ip_blkno,
4738+ (unsigned long long)oi2->ip_blkno);
4739+
4740+ if (*bh1)
4741+ *bh1 = NULL;
4742+ if (*bh2)
4743+ *bh2 = NULL;
4744+
4745+ /* We always want to lock the one with the lower lockid first. */
4746+ if (oi1->ip_blkno > oi2->ip_blkno)
4747+ mlog_errno(-ENOLCK);
4748+
4749+ /* lock id1 */
4750+ status = ocfs2_inode_lock_nested(inode1, bh1, 1, OI_LS_REFLINK_TARGET);
4751+ if (status < 0) {
4752+ if (status != -ENOENT)
4753+ mlog_errno(status);
4754+ goto out_rw2;
4755+ }
4756+
4757+ /* lock id2 */
4758+ if (!same_inode) {
4759+ status = ocfs2_inode_lock_nested(inode2, bh2, 1,
4760+ OI_LS_REFLINK_TARGET);
4761+ if (status < 0) {
4762+ if (status != -ENOENT)
4763+ mlog_errno(status);
4764+ goto out_cl1;
4765+ }
4766+ } else
4767+ *bh2 = *bh1;
4768+
4769+ trace_ocfs2_double_lock_end(
4770+ (unsigned long long)OCFS2_I(inode1)->ip_blkno,
4771+ (unsigned long long)OCFS2_I(inode2)->ip_blkno);
4772+
4773+ return 0;
4774+
4775+out_cl1:
4776+ ocfs2_inode_unlock(inode1, 1);
4777+ brelse(*bh1);
4778+ *bh1 = NULL;
4779+out_rw2:
4780+ ocfs2_rw_unlock(inode2, 1);
4781+out_i2:
4782+ ocfs2_rw_unlock(inode1, 1);
4783+out_i1:
4784+ unlock_two_nondirectories(s_inode, t_inode);
4785+ return status;
4786+}
4787+
4788+/* Unlock both inodes and release buffers. */
4789+static void ocfs2_reflink_inodes_unlock(struct inode *s_inode,
4790+ struct buffer_head *s_bh,
4791+ struct inode *t_inode,
4792+ struct buffer_head *t_bh)
4793+{
4794+ ocfs2_inode_unlock(s_inode, 1);
4795+ ocfs2_rw_unlock(s_inode, 1);
4796+ brelse(s_bh);
4797+ if (s_inode != t_inode) {
4798+ ocfs2_inode_unlock(t_inode, 1);
4799+ ocfs2_rw_unlock(t_inode, 1);
4800+ brelse(t_bh);
4801+ }
4802+ unlock_two_nondirectories(s_inode, t_inode);
4803+}
4804+
4805+/* Link a range of blocks from one file to another. */
4806+int ocfs2_reflink_remap_range(struct file *file_in,
4807+ loff_t pos_in,
4808+ struct file *file_out,
4809+ loff_t pos_out,
4810+ u64 len,
4811+ bool is_dedupe)
4812+{
4813+ struct inode *inode_in = file_inode(file_in);
4814+ struct inode *inode_out = file_inode(file_out);
4815+ struct ocfs2_super *osb = OCFS2_SB(inode_in->i_sb);
4816+ struct buffer_head *in_bh = NULL, *out_bh = NULL;
4817+ bool same_inode = (inode_in == inode_out);
4818+ ssize_t ret;
4819+
4820+ if (!ocfs2_refcount_tree(osb))
4821+ return -EOPNOTSUPP;
4822+ if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
4823+ return -EROFS;
4824+
4825+ /* Lock both files against IO */
4826+ ret = ocfs2_reflink_inodes_lock(inode_in, &in_bh, inode_out, &out_bh);
4827+ if (ret)
4828+ return ret;
4829+
4830+ /* Check file eligibility and prepare for block sharing. */
4831+ ret = -EINVAL;
4832+ if ((OCFS2_I(inode_in)->ip_flags & OCFS2_INODE_SYSTEM_FILE) ||
4833+ (OCFS2_I(inode_out)->ip_flags & OCFS2_INODE_SYSTEM_FILE))
4834+ goto out_unlock;
4835+
4836+ ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out,
4837+ &len, is_dedupe);
4838+ if (ret || len == 0)
4839+ goto out_unlock;
4840+
4841+ /* Lock out changes to the allocation maps and remap. */
4842+ down_write(&OCFS2_I(inode_in)->ip_alloc_sem);
4843+ if (!same_inode)
4844+ down_write_nested(&OCFS2_I(inode_out)->ip_alloc_sem,
4845+ SINGLE_DEPTH_NESTING);
4846+
4847+ ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out,
4848+ out_bh, pos_out, len);
4849+
4850+ /* Zap any page cache for the destination file's range. */
4851+ if (!ret)
4852+ truncate_inode_pages_range(&inode_out->i_data, pos_out,
4853+ PAGE_ALIGN(pos_out + len) - 1);
4854+
4855+ up_write(&OCFS2_I(inode_in)->ip_alloc_sem);
4856+ if (!same_inode)
4857+ up_write(&OCFS2_I(inode_out)->ip_alloc_sem);
4858+ if (ret) {
4859+ mlog_errno(ret);
4860+ goto out_unlock;
4861+ }
4862+
4863+ /*
4864+ * Empty the extent map so that we may get the right extent
4865+ * record from the disk.
4866+ */
4867+ ocfs2_extent_map_trunc(inode_in, 0);
4868+ ocfs2_extent_map_trunc(inode_out, 0);
4869+
4870+ ret = ocfs2_reflink_update_dest(inode_out, out_bh, pos_out + len);
4871+ if (ret) {
4872+ mlog_errno(ret);
4873+ goto out_unlock;
4874+ }
4875+
4876+ ocfs2_reflink_inodes_unlock(inode_in, in_bh, inode_out, out_bh);
4877+ return 0;
4878+
4879+out_unlock:
4880+ ocfs2_reflink_inodes_unlock(inode_in, in_bh, inode_out, out_bh);
4881+ return ret;
4882+}
fs/ocfs2/refcounttree.h+7−0
@@ -115,4 +115,11 @@ int ocfs2_reflink_ioctl(struct inode *inode, · 114 unmodified lines
115115 const char __user *oldname,
116116 const char __user *newname,
117117 bool preserve);
118+int ocfs2_reflink_remap_range(struct file *file_in,
119+ loff_t pos_in,
120+ struct file *file_out,
121+ loff_t pos_out,
122+ u64 len,
123+ bool is_dedupe);
124+
118125 #endif /* OCFS2_REFCOUNTTREE_H */
fs/ocfs2/xattr.c+2−2
@@ -2577,7 +2577,7 @@ int ocfs2_xattr_remove(struct inode *inode, struct buffer_head *di_bh) · 2576 unmodified lines
25772577 if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL))
25782578 return 0;
25792579
2580− if (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL) {
2580+ if (ocfs2_is_refcount_inode(inode)) {
25812581 ret = ocfs2_lock_refcount_tree(OCFS2_SB(inode->i_sb),
25822582 le64_to_cpu(di->i_refcount_loc),
25832583 1, &ref_tree, &ref_root_bh);
@@ -3608,7 +3608,7 @@ int ocfs2_xattr_set(struct inode *inode, · 1024 unmodified lines
36083608 }
36093609
36103610 /* Check whether the value is refcounted and do some preparation. */
3611− if (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL &&
3611+ if (ocfs2_is_refcount_inode(inode) &&
36123612 (!xis.not_found || !xbs.not_found)) {
36133613 ret = ocfs2_prepare_refcount_xattr(inode, di, &xi,
36143614 &xis, &xbs, &ref_tree,
fs/overlayfs/super.c+3−3
@@ -328,11 +328,11 @@ static struct dentry *ovl_d_real(struct dentry *dentry, · 327 unmodified lines
328328 if (!real)
329329 goto bug;
330330
331+ /* Handle recursion */
332+ real = d_real(real, inode, open_flags);
333+
331334 if (!inode || inode == d_inode(real))
332335 return real;
333−
334− /* Handle recursion */
335− return d_real(real, inode, open_flags);
336336 bug:
337337 WARN(1, "ovl_d_real(%pd4, %s:%lu): real dentry not found\n", dentry,
338338 inode ? inode->i_sb->s_id : "NULL", inode ? inode->i_ino : 0);
fs/read_write.c+226−5
@@ -1542,20 +1542,37 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, · 1541 unmodified lines
15421542 if (ret)
15431543 return ret;
15441544
1545− ret = -EOPNOTSUPP;
1546− if (file_out->f_op->copy_file_range)
1545+ /*
1546+ * Try cloning first, this is supported by more file systems, and
1547+ * more efficient if both clone and copy are supported (e.g. NFS).
1548+ */
1549+ if (file_in->f_op->clone_file_range) {
1550+ ret = file_in->f_op->clone_file_range(file_in, pos_in,
1551+ file_out, pos_out, len);
1552+ if (ret == 0) {
1553+ ret = len;
1554+ goto done;
1555+ }
1556+ }
1557+
1558+ if (file_out->f_op->copy_file_range) {
15471559 ret = file_out->f_op->copy_file_range(file_in, pos_in, file_out,
15481560 pos_out, len, flags);
1549− if (ret == -EOPNOTSUPP)
1550− ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out,
1551− len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0);
1561+ if (ret != -EOPNOTSUPP)
1562+ goto done;
1563+ }
1564+
1565+ ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out,
1566+ len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0);
15521567
1568+done:
15531569 if (ret > 0) {
15541570 fsnotify_access(file_in);
15551571 add_rchar(current, ret);
15561572 fsnotify_modify(file_out);
15571573 add_wchar(current, ret);
15581574 }
1575+
15591576 inc_syscr(current);
15601577 inc_syscw(current);
15611578
@@ -1650,6 +1667,114 @@ static int clone_verify_area(struct file *file, loff_t pos, u64 len, bool write) · 88 unmodified lines
16501667 return security_file_permission(file, write ? MAY_WRITE : MAY_READ);
16511668 }
16521669
1670+/*
1671+ * Check that the two inodes are eligible for cloning, the ranges make
1672+ * sense, and then flush all dirty data. Caller must ensure that the
1673+ * inodes have been locked against any other modifications.
1674+ */
1675+int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in,
1676+ struct inode *inode_out, loff_t pos_out,
1677+ u64 *len, bool is_dedupe)
1678+{
1679+ loff_t bs = inode_out->i_sb->s_blocksize;
1680+ loff_t blen;
1681+ loff_t isize;
1682+ bool same_inode = (inode_in == inode_out);
1683+ int ret;
1684+
1685+ /* Don't touch certain kinds of inodes */
1686+ if (IS_IMMUTABLE(inode_out))
1687+ return -EPERM;
1688+
1689+ if (IS_SWAPFILE(inode_in) || IS_SWAPFILE(inode_out))
1690+ return -ETXTBSY;
1691+
1692+ /* Don't reflink dirs, pipes, sockets... */
1693+ if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode))
1694+ return -EISDIR;
1695+ if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode))
1696+ return -EINVAL;
1697+
1698+ /* Are we going all the way to the end? */
1699+ isize = i_size_read(inode_in);
1700+ if (isize == 0) {
1701+ *len = 0;
1702+ return 0;
1703+ }
1704+
1705+ /* Zero length dedupe exits immediately; reflink goes to EOF. */
1706+ if (*len == 0) {
1707+ if (is_dedupe) {
1708+ *len = 0;
1709+ return 0;
1710+ }
1711+ *len = isize - pos_in;
1712+ }
1713+
1714+ /* Ensure offsets don't wrap and the input is inside i_size */
1715+ if (pos_in + *len < pos_in || pos_out + *len < pos_out ||
1716+ pos_in + *len > isize)
1717+ return -EINVAL;
1718+
1719+ /* Don't allow dedupe past EOF in the dest file */
1720+ if (is_dedupe) {
1721+ loff_t disize;
1722+
1723+ disize = i_size_read(inode_out);
1724+ if (pos_out >= disize || pos_out + *len > disize)
1725+ return -EINVAL;
1726+ }
1727+
1728+ /* If we're linking to EOF, continue to the block boundary. */
1729+ if (pos_in + *len == isize)
1730+ blen = ALIGN(isize, bs) - pos_in;
1731+ else
1732+ blen = *len;
1733+
1734+ /* Only reflink if we're aligned to block boundaries */
1735+ if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_in + blen, bs) ||
1736+ !IS_ALIGNED(pos_out, bs) || !IS_ALIGNED(pos_out + blen, bs))
1737+ return -EINVAL;
1738+
1739+ /* Don't allow overlapped reflink within the same file */
1740+ if (same_inode) {
1741+ if (pos_out + blen > pos_in && pos_out < pos_in + blen)
1742+ return -EINVAL;
1743+ }
1744+
1745+ /* Wait for the completion of any pending IOs on both files */
1746+ inode_dio_wait(inode_in);
1747+ if (!same_inode)
1748+ inode_dio_wait(inode_out);
1749+
1750+ ret = filemap_write_and_wait_range(inode_in->i_mapping,
1751+ pos_in, pos_in + *len - 1);
1752+ if (ret)
1753+ return ret;
1754+
1755+ ret = filemap_write_and_wait_range(inode_out->i_mapping,
1756+ pos_out, pos_out + *len - 1);
1757+ if (ret)
1758+ return ret;
1759+
1760+ /*
1761+ * Check that the extents are the same.
1762+ */
1763+ if (is_dedupe) {
1764+ bool is_same = false;
1765+
1766+ ret = vfs_dedupe_file_range_compare(inode_in, pos_in,
1767+ inode_out, pos_out, *len, &is_same);
1768+ if (ret)
1769+ return ret;
1770+ if (!is_same)
1771+ return -EBADE;
1772+ }
1773+
1774+ return 0;
1775+}
1776+EXPORT_SYMBOL(vfs_clone_file_prep_inodes);
1777+
16531778 int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
16541779 struct file *file_out, loff_t pos_out, u64 len)
16551780 {
@@ -1701,6 +1826,102 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in, · 45 unmodified lines
17011826 }
17021827 EXPORT_SYMBOL(vfs_clone_file_range);
17031828
1829+/*
1830+ * Read a page's worth of file data into the page cache. Return the page
1831+ * locked.
1832+ */
1833+static struct page *vfs_dedupe_get_page(struct inode *inode, loff_t offset)
1834+{
1835+ struct address_space *mapping;
1836+ struct page *page;
1837+ pgoff_t n;
1838+
1839+ n = offset >> PAGE_SHIFT;
1840+ mapping = inode->i_mapping;
1841+ page = read_mapping_page(mapping, n, NULL);
1842+ if (IS_ERR(page))
1843+ return page;
1844+ if (!PageUptodate(page)) {
1845+ put_page(page);
1846+ return ERR_PTR(-EIO);
1847+ }
1848+ lock_page(page);
1849+ return page;
1850+}
1851+
1852+/*
1853+ * Compare extents of two files to see if they are the same.
1854+ * Caller must have locked both inodes to prevent write races.
1855+ */
1856+int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff,
1857+ struct inode *dest, loff_t destoff,
1858+ loff_t len, bool *is_same)
1859+{
1860+ loff_t src_poff;
1861+ loff_t dest_poff;
1862+ void *src_addr;
1863+ void *dest_addr;
1864+ struct page *src_page;
1865+ struct page *dest_page;
1866+ loff_t cmp_len;
1867+ bool same;
1868+ int error;
1869+
1870+ error = -EINVAL;
1871+ same = true;
1872+ while (len) {
1873+ src_poff = srcoff & (PAGE_SIZE - 1);
1874+ dest_poff = destoff & (PAGE_SIZE - 1);
1875+ cmp_len = min(PAGE_SIZE - src_poff,
1876+ PAGE_SIZE - dest_poff);
1877+ cmp_len = min(cmp_len, len);
1878+ if (cmp_len <= 0)
1879+ goto out_error;
1880+
1881+ src_page = vfs_dedupe_get_page(src, srcoff);
1882+ if (IS_ERR(src_page)) {
1883+ error = PTR_ERR(src_page);
1884+ goto out_error;
1885+ }
1886+ dest_page = vfs_dedupe_get_page(dest, destoff);
1887+ if (IS_ERR(dest_page)) {
1888+ error = PTR_ERR(dest_page);
1889+ unlock_page(src_page);
1890+ put_page(src_page);
1891+ goto out_error;
1892+ }
1893+ src_addr = kmap_atomic(src_page);
1894+ dest_addr = kmap_atomic(dest_page);
1895+
1896+ flush_dcache_page(src_page);
1897+ flush_dcache_page(dest_page);
1898+
1899+ if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len))
1900+ same = false;
1901+
1902+ kunmap_atomic(dest_addr);
1903+ kunmap_atomic(src_addr);
1904+ unlock_page(dest_page);
1905+ unlock_page(src_page);
1906+ put_page(dest_page);
1907+ put_page(src_page);
1908+
1909+ if (!same)
1910+ break;
1911+
1912+ srcoff += cmp_len;
1913+ destoff += cmp_len;
1914+ len -= cmp_len;
1915+ }
1916+
1917+ *is_same = same;
1918+ return 0;
1919+
1920+out_error:
1921+ return error;
1922+}
1923+EXPORT_SYMBOL(vfs_dedupe_file_range_compare);
1924+
17041925 int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
17051926 {
17061927 struct file_dedupe_range_info *info;
fs/xfs/xfs_file.c+0−19
@@ -909,24 +909,6 @@ out_unlock: · 908 unmodified lines
909909 return error;
910910 }
911911
912−STATIC ssize_t
913−xfs_file_copy_range(
914− struct file *file_in,
915− loff_t pos_in,
916− struct file *file_out,
917− loff_t pos_out,
918− size_t len,
919− unsigned int flags)
920−{
921− int error;
922−
923− error = xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out,
924− len, false);
925− if (error)
926− return error;
927− return len;
928−}
929−
930912 STATIC int
931913 xfs_file_clone_range(
932914 struct file *file_in,
@@ -1625,7 +1607,6 @@ const struct file_operations xfs_file_operations = { · 692 unmodified lines
16251607 .fsync = xfs_file_fsync,
16261608 .get_unmapped_area = thp_get_unmapped_area,
16271609 .fallocate = xfs_file_fallocate,
1628− .copy_file_range = xfs_file_copy_range,
16291610 .clone_file_range = xfs_file_clone_range,
16301611 .dedupe_file_range = xfs_file_dedupe_range,
16311612 };
fs/xfs/xfs_reflink.c+9−204
@@ -1164,111 +1164,6 @@ err: · 1163 unmodified lines
11641164 return error;
11651165 }
11661166
1167−/*
1168− * Read a page's worth of file data into the page cache. Return the page
1169− * locked.
1170− */
1171−static struct page *
1172−xfs_get_page(
1173− struct inode *inode,
1174− xfs_off_t offset)
1175−{
1176− struct address_space *mapping;
1177− struct page *page;
1178− pgoff_t n;
1179−
1180− n = offset >> PAGE_SHIFT;
1181− mapping = inode->i_mapping;
1182− page = read_mapping_page(mapping, n, NULL);
1183− if (IS_ERR(page))
1184− return page;
1185− if (!PageUptodate(page)) {
1186− put_page(page);
1187− return ERR_PTR(-EIO);
1188− }
1189− lock_page(page);
1190− return page;
1191−}
1192−
1193−/*
1194− * Compare extents of two files to see if they are the same.
1195− */
1196−static int
1197−xfs_compare_extents(
1198− struct inode *src,
1199− xfs_off_t srcoff,
1200− struct inode *dest,
1201− xfs_off_t destoff,
1202− xfs_off_t len,
1203− bool *is_same)
1204−{
1205− xfs_off_t src_poff;
1206− xfs_off_t dest_poff;
1207− void *src_addr;
1208− void *dest_addr;
1209− struct page *src_page;
1210− struct page *dest_page;
1211− xfs_off_t cmp_len;
1212− bool same;
1213− int error;
1214−
1215− error = -EINVAL;
1216− same = true;
1217− while (len) {
1218− src_poff = srcoff & (PAGE_SIZE - 1);
1219− dest_poff = destoff & (PAGE_SIZE - 1);
1220− cmp_len = min(PAGE_SIZE - src_poff,
1221− PAGE_SIZE - dest_poff);
1222− cmp_len = min(cmp_len, len);
1223− ASSERT(cmp_len > 0);
1224−
1225− trace_xfs_reflink_compare_extents(XFS_I(src), srcoff, cmp_len,
1226− XFS_I(dest), destoff);
1227−
1228− src_page = xfs_get_page(src, srcoff);
1229− if (IS_ERR(src_page)) {
1230− error = PTR_ERR(src_page);
1231− goto out_error;
1232− }
1233− dest_page = xfs_get_page(dest, destoff);
1234− if (IS_ERR(dest_page)) {
1235− error = PTR_ERR(dest_page);
1236− unlock_page(src_page);
1237− put_page(src_page);
1238− goto out_error;
1239− }
1240− src_addr = kmap_atomic(src_page);
1241− dest_addr = kmap_atomic(dest_page);
1242−
1243− flush_dcache_page(src_page);
1244− flush_dcache_page(dest_page);
1245−
1246− if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len))
1247− same = false;
1248−
1249− kunmap_atomic(dest_addr);
1250− kunmap_atomic(src_addr);
1251− unlock_page(dest_page);
1252− unlock_page(src_page);
1253− put_page(dest_page);
1254− put_page(src_page);
1255−
1256− if (!same)
1257− break;
1258−
1259− srcoff += cmp_len;
1260− destoff += cmp_len;
1261− len -= cmp_len;
1262− }
1263−
1264− *is_same = same;
1265− return 0;
1266−
1267−out_error:
1268− trace_xfs_reflink_compare_extents_error(XFS_I(dest), error, _RET_IP_);
1269− return error;
1270−}
1271−
12721167 /*
12731168 * Link a range of blocks from one file to another.
12741169 */
@@ -1286,14 +1181,11 @@ xfs_reflink_remap_range( · 11 unmodified lines
12861181 struct inode *inode_out = file_inode(file_out);
12871182 struct xfs_inode *dest = XFS_I(inode_out);
12881183 struct xfs_mount *mp = src->i_mount;
1289− loff_t bs = inode_out->i_sb->s_blocksize;
12901184 bool same_inode = (inode_in == inode_out);
12911185 xfs_fileoff_t sfsbno, dfsbno;
12921186 xfs_filblks_t fsblen;
12931187 xfs_extlen_t cowextsize;
1294− loff_t isize;
12951188 ssize_t ret;
1296− loff_t blen;
12971189
12981190 if (!xfs_sb_version_hasreflink(&mp->m_sb))
12991191 return -EOPNOTSUPP;
@@ -1310,26 +1202,8 @@ xfs_reflink_remap_range( · 10 unmodified lines
13101202 xfs_lock_two_inodes(src, dest, XFS_MMAPLOCK_EXCL);
13111203 }
13121204
1313− /* Don't touch certain kinds of inodes */
1314− ret = -EPERM;
1315− if (IS_IMMUTABLE(inode_out))
1316− goto out_unlock;
1317−
1318− ret = -ETXTBSY;
1319− if (IS_SWAPFILE(inode_in) || IS_SWAPFILE(inode_out))
1320− goto out_unlock;
1321−
1322−
1323− /* Don't reflink dirs, pipes, sockets... */
1324− ret = -EISDIR;
1325− if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode))
1326− goto out_unlock;
1205+ /* Check file eligibility and prepare for block sharing. */
13271206 ret = -EINVAL;
1328− if (S_ISFIFO(inode_in->i_mode) || S_ISFIFO(inode_out->i_mode))
1329− goto out_unlock;
1330− if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode))
1331− goto out_unlock;
1332−
13331207 /* Don't reflink realtime inodes */
13341208 if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest))
13351209 goto out_unlock;
@@ -1338,91 +1212,18 @@ xfs_reflink_remap_range( · 2 unmodified lines
13381212 if (IS_DAX(inode_in) || IS_DAX(inode_out))
13391213 goto out_unlock;
13401214
1341− /* Are we going all the way to the end? */
1342− isize = i_size_read(inode_in);
1343− if (isize == 0) {
1344− ret = 0;
1345− goto out_unlock;
1346− }
1347−
1348− if (len == 0)
1349− len = isize - pos_in;
1350−
1351− /* Ensure offsets don't wrap and the input is inside i_size */
1352− if (pos_in + len < pos_in || pos_out + len < pos_out ||
1353− pos_in + len > isize)
1354− goto out_unlock;
1355−
1356− /* Don't allow dedupe past EOF in the dest file */
1357− if (is_dedupe) {
1358− loff_t disize;
1359−
1360− disize = i_size_read(inode_out);
1361− if (pos_out >= disize || pos_out + len > disize)
1362− goto out_unlock;
1363− }
1364−
1365− /* If we're linking to EOF, continue to the block boundary. */
1366− if (pos_in + len == isize)
1367− blen = ALIGN(isize, bs) - pos_in;
1368− else
1369− blen = len;
1370−
1371− /* Only reflink if we're aligned to block boundaries */
1372− if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_in + blen, bs) ||
1373− !IS_ALIGNED(pos_out, bs) || !IS_ALIGNED(pos_out + blen, bs))
1374− goto out_unlock;
1375−
1376− /* Don't allow overlapped reflink within the same file */
1377− if (same_inode) {
1378− if (pos_out + blen > pos_in && pos_out < pos_in + blen)
1379− goto out_unlock;
1380− }
1381−
1382− /* Wait for the completion of any pending IOs on both files */
1383− inode_dio_wait(inode_in);
1384− if (!same_inode)
1385− inode_dio_wait(inode_out);
1386−
1387− ret = filemap_write_and_wait_range(inode_in->i_mapping,
1388− pos_in, pos_in + len - 1);
1389− if (ret)
1390− goto out_unlock;
1391−
1392− ret = filemap_write_and_wait_range(inode_out->i_mapping,
1393− pos_out, pos_out + len - 1);
1394− if (ret)
1215+ ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out,
1216+ &len, is_dedupe);
1217+ if (ret || len == 0)
13951218 goto out_unlock;
13961219
13971220 trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out);
13981221
1399− /*
1400− * Check that the extents are the same.
1401− */
1402− if (is_dedupe) {
1403− bool is_same = false;
1404−
1405− ret = xfs_compare_extents(inode_in, pos_in, inode_out, pos_out,
1406− len, &is_same);
1407− if (ret)
1408− goto out_unlock;
1409− if (!is_same) {
1410− ret = -EBADE;
1411− goto out_unlock;
1412− }
1413− }
1414−
1222+ /* Set flags and remap blocks. */
14151223 ret = xfs_reflink_set_inode_flag(src, dest);
14161224 if (ret)
14171225 goto out_unlock;
14181226
1419− /*
1420− * Invalidate the page cache so that we can clear any CoW mappings
1421− * in the destination file.
1422− */
1423− truncate_inode_pages_range(&inode_out->i_data, pos_out,
1424− PAGE_ALIGN(pos_out + len) - 1);
1425−
14261227 dfsbno = XFS_B_TO_FSBT(mp, pos_out);
14271228 sfsbno = XFS_B_TO_FSBT(mp, pos_in);
14281229 fsblen = XFS_B_TO_FSB(mp, len);
@@ -1431,6 +1232,10 @@ xfs_reflink_remap_range( · 2 unmodified lines
14311232 if (ret)
14321233 goto out_unlock;
14331234
1235+ /* Zap any page cache for the destination file's range. */
1236+ truncate_inode_pages_range(&inode_out->i_data, pos_out,
1237+ PAGE_ALIGN(pos_out + len) - 1);
1238+
14341239 /*
14351240 * Carry the cowextsize hint from src to dest if we're sharing the
14361241 * entire source file to the entire destination file, the source file
include/asm-generic/export.h+1−0
@@ -54,6 +54,7 @@ KSYM(__kstrtab_\name): · 53 unmodified lines
5454 KSYM(__kcrctab_\name):
5555 __put KSYM(__crc_\name)
5656 .weak KSYM(__crc_\name)
57+ .set KSYM(__crc_\name), 0
5758 .previous
5859 #endif
5960 #endif
include/linux/compiler-gcc.h+3−1
@@ -263,7 +263,9 @@ · 262 unmodified lines
263263 #endif
264264 #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP && !__CHECKER__ */
265265
266−#if GCC_VERSION >= 50000
266+#if GCC_VERSION >= 70000
267+#define KASAN_ABI_VERSION 5
268+#elif GCC_VERSION >= 50000
267269 #define KASAN_ABI_VERSION 4
268270 #elif GCC_VERSION >= 40902
269271 #define KASAN_ABI_VERSION 3
include/linux/fs.h+6−0
@@ -1778,8 +1778,14 @@ extern ssize_t vfs_writev(struct file *, const struct iovec __user *, · 1777 unmodified lines
17781778 unsigned long, loff_t *, int);
17791779 extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *,
17801780 loff_t, size_t, unsigned int);
1781+extern int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in,
1782+ struct inode *inode_out, loff_t pos_out,
1783+ u64 *len, bool is_dedupe);
17811784 extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
17821785 struct file *file_out, loff_t pos_out, u64 len);
1786+extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff,
1787+ struct inode *dest, loff_t destoff,
1788+ loff_t len, bool *is_same);
17831789 extern int vfs_dedupe_file_range(struct file *file,
17841790 struct file_dedupe_range *same);
17851791
include/linux/mlx4/device.h+0−1
@@ -476,7 +476,6 @@ enum { · 475 unmodified lines
476476 enum {
477477 MLX4_INTERFACE_STATE_UP = 1 << 0,
478478 MLX4_INTERFACE_STATE_DELETION = 1 << 1,
479− MLX4_INTERFACE_STATE_SHUTDOWN = 1 << 2,
480479 };
481480
482481 #define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \
include/linux/of_mdio.h+4−0
@@ -29,6 +29,7 @@ struct phy_device *of_phy_attach(struct net_device *dev, · 28 unmodified lines
2929 extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
3030 extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np);
3131 extern int of_phy_register_fixed_link(struct device_node *np);
32+extern void of_phy_deregister_fixed_link(struct device_node *np);
3233 extern bool of_phy_is_fixed_link(struct device_node *np);
3334
3435 #else /* CONFIG_OF */
@@ -83,6 +84,9 @@ static inline int of_phy_register_fixed_link(struct device_node *np) · 48 unmodified lines
8384 {
8485 return -ENOSYS;
8586 }
87+static inline void of_phy_deregister_fixed_link(struct device_node *np)
88+{
89+}
8690 static inline bool of_phy_is_fixed_link(struct device_node *np)
8791 {
8892 return false;
include/linux/pagemap.h+15−6
@@ -374,16 +374,13 @@ static inline struct page *read_mapping_page(struct address_space *mapping, · 373 unmodified lines
374374 }
375375
376376 /*
377− * Get the offset in PAGE_SIZE.
378− * (TODO: hugepage should have ->index in PAGE_SIZE)
377+ * Get index of the page with in radix-tree
378+ * (TODO: remove once hugetlb pages will have ->index in PAGE_SIZE)
379379 */
380−static inline pgoff_t page_to_pgoff(struct page *page)
380+static inline pgoff_t page_to_index(struct page *page)
381381 {
382382 pgoff_t pgoff;
383383
384− if (unlikely(PageHeadHuge(page)))
385− return page->index << compound_order(page);
386−
387384 if (likely(!PageTransTail(page)))
388385 return page->index;
389386
@@ -396,6 +393,18 @@ static inline pgoff_t page_to_pgoff(struct page *page) · 6 unmodified lines
396393 return pgoff;
397394 }
398395
396+/*
397+ * Get the offset in PAGE_SIZE.
398+ * (TODO: hugepage should have ->index in PAGE_SIZE)
399+ */
400+static inline pgoff_t page_to_pgoff(struct page *page)
401+{
402+ if (unlikely(PageHeadHuge(page)))
403+ return page->index << compound_order(page);
404+
405+ return page_to_index(page);
406+}
407+
399408 /*
400409 * Return byte-offset into filesystem object for page.
401410 */
include/linux/pci.h+14−0
@@ -1928,6 +1928,20 @@ static inline int pci_pcie_type(const struct pci_dev *dev) · 1927 unmodified lines
19281928 return (pcie_caps_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4;
19291929 }
19301930
1931+static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
1932+{
1933+ while (1) {
1934+ if (!pci_is_pcie(dev))
1935+ break;
1936+ if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
1937+ return dev;
1938+ if (!dev->bus->self)
1939+ break;
1940+ dev = dev->bus->self;
1941+ }
1942+ return NULL;
1943+}
1944+
19311945 void pci_request_acs(void);
19321946 bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags);
19331947 bool pci_acs_path_enabled(struct pci_dev *start,
include/net/ipv6.h+2−0
@@ -970,6 +970,8 @@ int compat_ipv6_setsockopt(struct sock *sk, int level, int optname, · 969 unmodified lines
970970 int compat_ipv6_getsockopt(struct sock *sk, int level, int optname,
971971 char __user *optval, int __user *optlen);
972972
973+int __ip6_datagram_connect(struct sock *sk, struct sockaddr *addr,
974+ int addr_len);
973975 int ip6_datagram_connect(struct sock *sk, struct sockaddr *addr, int addr_len);
974976 int ip6_datagram_connect_v6_only(struct sock *sk, struct sockaddr *addr,
975977 int addr_len);
include/net/netfilter/nf_conntrack.h+3−3
@@ -100,6 +100,9 @@ struct nf_conn { · 99 unmodified lines
100100
101101 possible_net_t ct_net;
102102
103+#if IS_ENABLED(CONFIG_NF_NAT)
104+ struct rhlist_head nat_bysource;
105+#endif
103106 /* all members below initialized via memset */
104107 u8 __nfct_init_offset[0];
105108
@@ -117,9 +120,6 @@ struct nf_conn { · 11 unmodified lines
117120 /* Extensions */
118121 struct nf_ct_ext *ext;
119122
120−#if IS_ENABLED(CONFIG_NF_NAT)
121− struct rhash_head nat_bysource;
122−#endif
123123 /* Storage reserved for other modules, must be the last member */
124124 union nf_conntrack_proto proto;
125125 };
include/net/netfilter/nf_tables.h+1−1
@@ -313,7 +313,7 @@ void nft_unregister_set(struct nft_set_ops *ops); · 312 unmodified lines
313313 * @size: maximum set size
314314 * @nelems: number of elements
315315 * @ndeact: number of deactivated elements queued for removal
316− * @timeout: default timeout value in msecs
316+ * @timeout: default timeout value in jiffies
317317 * @gc_int: garbage collection interval in msecs
318318 * @policy: set parameterization (see enum nft_set_policies)
319319 * @udlen: user data length
include/uapi/linux/input-event-codes.h+1−1
@@ -640,7 +640,7 @@ · 639 unmodified lines
640640 * Control a data application associated with the currently viewed channel,
641641 * e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.)
642642 */
643−#define KEY_DATA 0x275
643+#define KEY_DATA 0x277
644644
645645 #define BTN_TRIGGER_HAPPY 0x2c0
646646 #define BTN_TRIGGER_HAPPY1 0x2c0
include/uapi/linux/tc_act/Kbuild+1−0
@@ -11,3 +11,4 @@ header-y += tc_vlan.h · 10 unmodified lines
1111 header-y += tc_bpf.h
1212 header-y += tc_connmark.h
1313 header-y += tc_ife.h
14+header-y += tc_tunnel_key.h
init/Kconfig+0−1
@@ -1945,7 +1945,6 @@ config MODULE_FORCE_UNLOAD · 1944 unmodified lines
19451945
19461946 config MODVERSIONS
19471947 bool "Module versioning support"
1948− depends on BROKEN
19491948 help
19501949 Usually, you have to use modules compiled with your kernel.
19511950 Saying Y here makes it sometimes possible to use modules
kernel/bpf/verifier.c+8−2
@@ -2454,6 +2454,7 @@ static bool states_equal(struct bpf_verifier_env *env, · 2453 unmodified lines
24542454 struct bpf_verifier_state *old,
24552455 struct bpf_verifier_state *cur)
24562456 {
2457+ bool varlen_map_access = env->varlen_map_value_access;
24572458 struct bpf_reg_state *rold, *rcur;
24582459 int i;
24592460
@@ -2467,12 +2468,17 @@ static bool states_equal(struct bpf_verifier_env *env, · 7 unmodified lines
24672468 /* If the ranges were not the same, but everything else was and
24682469 * we didn't do a variable access into a map then we are a-ok.
24692470 */
2470− if (!env->varlen_map_value_access &&
2471+ if (!varlen_map_access &&
24712472 rold->type == rcur->type && rold->imm == rcur->imm)
24722473 continue;
24732474
2475+ /* If we didn't map access then again we don't care about the
2476+ * mismatched range values and it's ok if our old type was
2477+ * UNKNOWN and we didn't go to a NOT_INIT'ed reg.
2478+ */
24742479 if (rold->type == NOT_INIT ||
2475− (rold->type == UNKNOWN_VALUE && rcur->type != NOT_INIT))
2480+ (!varlen_map_access && rold->type == UNKNOWN_VALUE &&
2481+ rcur->type != NOT_INIT))
24762482 continue;
24772483
24782484 if (rold->type == PTR_TO_PACKET && rcur->type == PTR_TO_PACKET &&
kernel/module.c+3−2
@@ -1301,8 +1301,9 @@ static int check_version(Elf_Shdr *sechdrs, · 1300 unmodified lines
13011301 goto bad_version;
13021302 }
13031303
1304− pr_warn("%s: no symbol version for %s\n", mod->name, symname);
1305− return 0;
1304+ /* Broken toolchain. Warn once, then let it go.. */
1305+ pr_warn_once("%s: no symbol version for %s\n", mod->name, symname);
1306+ return 1;
13061307
13071308 bad_version:
13081309 pr_warn("%s: disagrees about version of symbol %s\n",
lib/debugobjects.c+8−0
@@ -362,6 +362,7 @@ void debug_object_init(void *addr, struct debug_obj_descr *descr) · 361 unmodified lines
362362
363363 __debug_object_init(addr, descr, 0);
364364 }
365+EXPORT_SYMBOL_GPL(debug_object_init);
365366
366367 /**
367368 * debug_object_init_on_stack - debug checks when an object on stack is
@@ -376,6 +377,7 @@ void debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr) · 8 unmodified lines
376377
377378 __debug_object_init(addr, descr, 1);
378379 }
380+EXPORT_SYMBOL_GPL(debug_object_init_on_stack);
379381
380382 /**
381383 * debug_object_activate - debug checks when an object is activated
@@ -449,6 +451,7 @@ int debug_object_activate(void *addr, struct debug_obj_descr *descr) · 67 unmodified lines
449451 }
450452 return 0;
451453 }
454+EXPORT_SYMBOL_GPL(debug_object_activate);
452455
453456 /**
454457 * debug_object_deactivate - debug checks when an object is deactivated
@@ -496,6 +499,7 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr) · 41 unmodified lines
496499
497500 raw_spin_unlock_irqrestore(&db->lock, flags);
498501 }
502+EXPORT_SYMBOL_GPL(debug_object_deactivate);
499503
500504 /**
501505 * debug_object_destroy - debug checks when an object is destroyed
@@ -542,6 +546,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr) · 40 unmodified lines
542546 out_unlock:
543547 raw_spin_unlock_irqrestore(&db->lock, flags);
544548 }
549+EXPORT_SYMBOL_GPL(debug_object_destroy);
545550
546551 /**
547552 * debug_object_free - debug checks when an object is freed
@@ -582,6 +587,7 @@ void debug_object_free(void *addr, struct debug_obj_descr *descr) · 34 unmodified lines
582587 out_unlock:
583588 raw_spin_unlock_irqrestore(&db->lock, flags);
584589 }
590+EXPORT_SYMBOL_GPL(debug_object_free);
585591
586592 /**
587593 * debug_object_assert_init - debug checks when object should be init-ed
@@ -626,6 +632,7 @@ void debug_object_assert_init(void *addr, struct debug_obj_descr *descr) · 38 unmodified lines
626632
627633 raw_spin_unlock_irqrestore(&db->lock, flags);
628634 }
635+EXPORT_SYMBOL_GPL(debug_object_assert_init);
629636
630637 /**
631638 * debug_object_active_state - debug checks object usage state machine
@@ -673,6 +680,7 @@ debug_object_active_state(void *addr, struct debug_obj_descr *descr, · 41 unmodified lines
673680
674681 raw_spin_unlock_irqrestore(&db->lock, flags);
675682 }
683+EXPORT_SYMBOL_GPL(debug_object_active_state);
676684
677685 #ifdef CONFIG_DEBUG_OBJECTS_FREE
678686 static void __debug_check_no_obj_freed(const void *address, unsigned long size)
lib/test_kasan.c+29−0
@@ -20,6 +20,11 @@ · 19 unmodified lines
2020 #include <linux/uaccess.h>
2121 #include <linux/module.h>
2222
23+/*
24+ * Note: test functions are marked noinline so that their names appear in
25+ * reports.
26+ */
27+
2328 static noinline void __init kmalloc_oob_right(void)
2429 {
2530 char *ptr;
@@ -411,6 +416,29 @@ static noinline void __init copy_user_test(void) · 385 unmodified lines
411416 kfree(kmem);
412417 }
413418
419+static noinline void __init use_after_scope_test(void)
420+{
421+ volatile char *volatile p;
422+
423+ pr_info("use-after-scope on int\n");
424+ {
425+ int local = 0;
426+
427+ p = (char *)&local;
428+ }
429+ p[0] = 1;
430+ p[3] = 1;
431+
432+ pr_info("use-after-scope on array\n");
433+ {
434+ char local[1024] = {0};
435+
436+ p = local;
437+ }
438+ p[0] = 1;
439+ p[1023] = 1;
440+}
441+
414442 static int __init kmalloc_tests_init(void)
415443 {
416444 kmalloc_oob_right();
@@ -436,6 +464,7 @@ static int __init kmalloc_tests_init(void) · 19 unmodified lines
436464 kasan_global_oob();
437465 ksize_unpoisons_memory();
438466 copy_user_test();
467+ use_after_scope_test();
439468 return -EAGAIN;
440469 }
441470
mm/huge_memory.c+2−2
@@ -1456,9 +1456,9 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr, · 1455 unmodified lines
14561456 new_ptl = pmd_lockptr(mm, new_pmd);
14571457 if (new_ptl != old_ptl)
14581458 spin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING);
1459− if (pmd_present(*old_pmd) && pmd_dirty(*old_pmd))
1460− force_flush = true;
14611459 pmd = pmdp_huge_get_and_clear(mm, old_addr, old_pmd);
1460+ if (pmd_present(pmd) && pmd_dirty(pmd))
1461+ force_flush = true;
14621462 VM_BUG_ON(!pmd_none(*new_pmd));
14631463
14641464 if (pmd_move_must_withdraw(new_ptl, old_ptl) &&
mm/kasan/kasan.c+19−0
@@ -764,6 +764,25 @@ EXPORT_SYMBOL(__asan_storeN_noabort); · 763 unmodified lines
764764 void __asan_handle_no_return(void) {}
765765 EXPORT_SYMBOL(__asan_handle_no_return);
766766
767+/* Emitted by compiler to poison large objects when they go out of scope. */
768+void __asan_poison_stack_memory(const void *addr, size_t size)
769+{
770+ /*
771+ * Addr is KASAN_SHADOW_SCALE_SIZE-aligned and the object is surrounded
772+ * by redzones, so we simply round up size to simplify logic.
773+ */
774+ kasan_poison_shadow(addr, round_up(size, KASAN_SHADOW_SCALE_SIZE),
775+ KASAN_USE_AFTER_SCOPE);
776+}
777+EXPORT_SYMBOL(__asan_poison_stack_memory);
778+
779+/* Emitted by compiler to unpoison large objects when they go into scope. */
780+void __asan_unpoison_stack_memory(const void *addr, size_t size)
781+{
782+ kasan_unpoison_shadow(addr, size);
783+}
784+EXPORT_SYMBOL(__asan_unpoison_stack_memory);
785+
767786 #ifdef CONFIG_MEMORY_HOTPLUG
768787 static int kasan_mem_notifier(struct notifier_block *nb,
769788 unsigned long action, void *data)
mm/kasan/kasan.h+4−0
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #define KASAN_STACK_MID 0xF2
2222 #define KASAN_STACK_RIGHT 0xF3
2323 #define KASAN_STACK_PARTIAL 0xF4
24+#define KASAN_USE_AFTER_SCOPE 0xF8
2425
2526 /* Don't break randconfig/all*config builds */
2627 #ifndef KASAN_ABI_VERSION
@@ -53,6 +54,9 @@ struct kasan_global { · 26 unmodified lines
5354 #if KASAN_ABI_VERSION >= 4
5455 struct kasan_source_location *location;
5556 #endif
57+#if KASAN_ABI_VERSION >= 5
58+ char *odr_indicator;
59+#endif
5660 };
5761
5862 /**
mm/kasan/report.c+3−0
@@ -90,6 +90,9 @@ static void print_error_description(struct kasan_access_info *info) · 89 unmodified lines
9090 case KASAN_KMALLOC_FREE:
9191 bug_type = "use-after-free";
9292 break;
93+ case KASAN_USE_AFTER_SCOPE:
94+ bug_type = "use-after-scope";
95+ break;
9396 }
9497
9598 pr_err("BUG: KASAN: %s in %pS at addr %p\n",
mm/khugepaged.c+2−0
@@ -103,6 +103,7 @@ static struct khugepaged_scan khugepaged_scan = { · 102 unmodified lines
103103 .mm_head = LIST_HEAD_INIT(khugepaged_scan.mm_head),
104104 };
105105
106+#ifdef CONFIG_SYSFS
106107 static ssize_t scan_sleep_millisecs_show(struct kobject *kobj,
107108 struct kobj_attribute *attr,
108109 char *buf)
@@ -295,6 +296,7 @@ struct attribute_group khugepaged_attr_group = { · 186 unmodified lines
295296 .attrs = khugepaged_attr,
296297 .name = "khugepaged",
297298 };
299+#endif /* CONFIG_SYSFS */
298300
299301 #define VM_NO_KHUGEPAGED (VM_SPECIAL | VM_HUGETLB)
300302
mm/mlock.c+5−2
@@ -190,10 +190,13 @@ unsigned int munlock_vma_page(struct page *page) · 189 unmodified lines
190190 */
191191 spin_lock_irq(zone_lru_lock(zone));
192192
193− nr_pages = hpage_nr_pages(page);
194− if (!TestClearPageMlocked(page))
193+ if (!TestClearPageMlocked(page)) {
194+ /* Potentially, PTE-mapped THP: do not skip the rest PTEs */
195+ nr_pages = 1;
195196 goto unlock_out;
197+ }
196198
199+ nr_pages = hpage_nr_pages(page);
197200 __mod_zone_page_state(zone, NR_MLOCK, -nr_pages);
198201
199202 if (__munlock_isolate_lru_page(page, true)) {
mm/mremap.c+8−4
@@ -149,14 +149,18 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd, · 148 unmodified lines
149149 if (pte_none(*old_pte))
150150 continue;
151151
152+ pte = ptep_get_and_clear(mm, old_addr, old_pte);
152153 /*
153− * We are remapping a dirty PTE, make sure to
154− * flush TLB before we drop the PTL for the
154+ * If we are remapping a dirty PTE, make sure
155+ * to flush TLB before we drop the PTL for the
155156 * old PTE or we may race with page_mkclean().
157+ *
158+ * This check has to be done after we removed the
159+ * old PTE from page tables or another thread may
160+ * dirty it after the check and before the removal.
156161 */
157− if (pte_present(*old_pte) && pte_dirty(*old_pte))
162+ if (pte_present(pte) && pte_dirty(pte))
158163 force_flush = true;
159− pte = ptep_get_and_clear(mm, old_addr, old_pte);
160164 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
161165 pte = move_soft_dirty_pte(pte);
162166 set_pte_at(mm, new_addr, new_pte, pte);
mm/truncate.c+4−4
@@ -283,7 +283,7 @@ void truncate_inode_pages_range(struct address_space *mapping, · 282 unmodified lines
283283
284284 if (!trylock_page(page))
285285 continue;
286− WARN_ON(page_to_pgoff(page) != index);
286+ WARN_ON(page_to_index(page) != index);
287287 if (PageWriteback(page)) {
288288 unlock_page(page);
289289 continue;
@@ -371,7 +371,7 @@ void truncate_inode_pages_range(struct address_space *mapping, · 81 unmodified lines
371371 }
372372
373373 lock_page(page);
374− WARN_ON(page_to_pgoff(page) != index);
374+ WARN_ON(page_to_index(page) != index);
375375 wait_on_page_writeback(page);
376376 truncate_inode_page(mapping, page);
377377 unlock_page(page);
@@ -492,7 +492,7 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping, · 114 unmodified lines
492492 if (!trylock_page(page))
493493 continue;
494494
495− WARN_ON(page_to_pgoff(page) != index);
495+ WARN_ON(page_to_index(page) != index);
496496
497497 /* Middle of THP: skip */
498498 if (PageTransTail(page)) {
@@ -612,7 +612,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping, · 113 unmodified lines
612612 }
613613
614614 lock_page(page);
615− WARN_ON(page_to_pgoff(page) != index);
615+ WARN_ON(page_to_index(page) != index);
616616 if (page->mapping != mapping) {
617617 unlock_page(page);
618618 continue;
mm/vmscan.c+2−0
@@ -2354,6 +2354,8 @@ static void shrink_node_memcg(struct pglist_data *pgdat, struct mem_cgroup *memc · 2353 unmodified lines
23542354 }
23552355 }
23562356
2357+ cond_resched();
2358+
23572359 if (nr_reclaimed < nr_to_reclaim || scan_adjusted)
23582360 continue;
23592361
mm/workingset.c+1−1
@@ -348,7 +348,7 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, · 347 unmodified lines
348348 shadow_nodes = list_lru_shrink_count(&workingset_shadow_nodes, sc);
349349 local_irq_enable();
350350
351− if (memcg_kmem_enabled()) {
351+ if (sc->memcg) {
352352 pages = mem_cgroup_node_nr_lru_pages(sc->memcg, sc->nid,
353353 LRU_ALL_FILE);
354354 } else {
net/core/flow.c+2−4
@@ -95,7 +95,6 @@ static void flow_cache_gc_task(struct work_struct *work) · 94 unmodified lines
9595 list_for_each_entry_safe(fce, n, &gc_list, u.gc_list) {
9696 flow_entry_kill(fce, xfrm);
9797 atomic_dec(&xfrm->flow_cache_gc_count);
98− WARN_ON(atomic_read(&xfrm->flow_cache_gc_count) < 0);
9998 }
10099 }
101100
@@ -236,9 +235,8 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir, · 134 unmodified lines
236235 if (fcp->hash_count > fc->high_watermark)
237236 flow_cache_shrink(fc, fcp);
238237
239− if (fcp->hash_count > 2 * fc->high_watermark ||
240− atomic_read(&net->xfrm.flow_cache_gc_count) > fc->high_watermark) {
241− atomic_inc(&net->xfrm.flow_cache_genid);
238+ if (atomic_read(&net->xfrm.flow_cache_gc_count) >
239+ 2 * num_online_cpus() * fc->high_watermark) {
242240 flo = ERR_PTR(-ENOBUFS);
243241 goto ret_object;
244242 }
net/core/rtnetlink.c+2−2
@@ -931,8 +931,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, · 930 unmodified lines
931931 + nla_total_size(4) /* IFLA_PROMISCUITY */
932932 + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */
933933 + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */
934− + nla_total_size(4) /* IFLA_MAX_GSO_SEGS */
935− + nla_total_size(4) /* IFLA_MAX_GSO_SIZE */
934+ + nla_total_size(4) /* IFLA_GSO_MAX_SEGS */
935+ + nla_total_size(4) /* IFLA_GSO_MAX_SIZE */
936936 + nla_total_size(1) /* IFLA_OPERSTATE */
937937 + nla_total_size(1) /* IFLA_LINKMODE */
938938 + nla_total_size(4) /* IFLA_CARRIER_CHANGES */
net/core/sock.c+2−2
@@ -715,7 +715,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, · 714 unmodified lines
715715 val = min_t(u32, val, sysctl_wmem_max);
716716 set_sndbuf:
717717 sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
718− sk->sk_sndbuf = max_t(u32, val * 2, SOCK_MIN_SNDBUF);
718+ sk->sk_sndbuf = max_t(int, val * 2, SOCK_MIN_SNDBUF);
719719 /* Wake up sending tasks if we upped the value. */
720720 sk->sk_write_space(sk);
721721 break;
@@ -751,7 +751,7 @@ set_rcvbuf: · 29 unmodified lines
751751 * returning the value we actually used in getsockopt
752752 * is the most desirable behavior.
753753 */
754− sk->sk_rcvbuf = max_t(u32, val * 2, SOCK_MIN_RCVBUF);
754+ sk->sk_rcvbuf = max_t(int, val * 2, SOCK_MIN_RCVBUF);
755755 break;
756756
757757 case SO_RCVBUFFORCE:
net/dccp/ipv4.c+7−5
@@ -700,6 +700,7 @@ int dccp_invalid_packet(struct sk_buff *skb) · 699 unmodified lines
700700 {
701701 const struct dccp_hdr *dh;
702702 unsigned int cscov;
703+ u8 dccph_doff;
703704
704705 if (skb->pkt_type != PACKET_HOST)
705706 return 1;
@@ -721,18 +722,19 @@ int dccp_invalid_packet(struct sk_buff *skb) · 15 unmodified lines
721722 /*
722723 * If P.Data Offset is too small for packet type, drop packet and return
723724 */
724− if (dh->dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) {
725− DCCP_WARN("P.Data Offset(%u) too small\n", dh->dccph_doff);
725+ dccph_doff = dh->dccph_doff;
726+ if (dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) {
727+ DCCP_WARN("P.Data Offset(%u) too small\n", dccph_doff);
726728 return 1;
727729 }
728730 /*
729731 * If P.Data Offset is too too large for packet, drop packet and return
730732 */
731− if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) {
732− DCCP_WARN("P.Data Offset(%u) too large\n", dh->dccph_doff);
733+ if (!pskb_may_pull(skb, dccph_doff * sizeof(u32))) {
734+ DCCP_WARN("P.Data Offset(%u) too large\n", dccph_doff);
733735 return 1;
734736 }
735−
737+ dh = dccp_hdr(skb);
736738 /*
737739 * If P.type is not Data, Ack, or DataAck and P.X == 0 (the packet
738740 * has short sequence numbers), drop packet and return
net/dsa/dsa.c+4−9
@@ -233,6 +233,8 @@ int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev, · 232 unmodified lines
233233 genphy_read_status(phydev);
234234 if (ds->ops->adjust_link)
235235 ds->ops->adjust_link(ds, port, phydev);
236+
237+ put_device(&phydev->mdio.dev);
236238 }
237239
238240 return 0;
@@ -504,15 +506,8 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, · 265 unmodified lines
504506
505507 void dsa_cpu_dsa_destroy(struct device_node *port_dn)
506508 {
507− struct phy_device *phydev;
508−
509− if (of_phy_is_fixed_link(port_dn)) {
510− phydev = of_phy_find_device(port_dn);
511− if (phydev) {
512− phy_device_free(phydev);
513− fixed_phy_unregister(phydev);
514− }
515− }
509+ if (of_phy_is_fixed_link(port_dn))
510+ of_phy_deregister_fixed_link(port_dn);
516511 }
517512
518513 static void dsa_switch_destroy(struct dsa_switch *ds)
net/dsa/dsa2.c+3−1
@@ -28,8 +28,10 @@ static struct dsa_switch_tree *dsa_get_dst(u32 tree) · 27 unmodified lines
2828 struct dsa_switch_tree *dst;
2929
3030 list_for_each_entry(dst, &dsa_switch_trees, list)
31− if (dst->tree == tree)
31+ if (dst->tree == tree) {
32+ kref_get(&dst->refcount);
3233 return dst;
34+ }
3335 return NULL;
3436 }
3537
net/dsa/slave.c+16−3
@@ -1125,7 +1125,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, · 1124 unmodified lines
11251125 p->phy_interface = mode;
11261126
11271127 phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);
1128− if (of_phy_is_fixed_link(port_dn)) {
1128+ if (!phy_dn && of_phy_is_fixed_link(port_dn)) {
11291129 /* In the case of a fixed PHY, the DT node associated
11301130 * to the fixed PHY is the Port DT node
11311131 */
@@ -1135,7 +1135,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, · 3 unmodified lines
11351135 return ret;
11361136 }
11371137 phy_is_fixed = true;
1138− phy_dn = port_dn;
1138+ phy_dn = of_node_get(port_dn);
11391139 }
11401140
11411141 if (ds->ops->get_phy_flags)
@@ -1154,6 +1154,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, · 12 unmodified lines
11541154 ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
11551155 if (ret) {
11561156 netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret);
1157+ of_node_put(phy_dn);
11571158 return ret;
11581159 }
11591160 } else {
@@ -1162,6 +1163,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, · 2 unmodified lines
11621163 phy_flags,
11631164 p->phy_interface);
11641165 }
1166+
1167+ of_node_put(phy_dn);
11651168 }
11661169
11671170 if (p->phy && phy_is_fixed)
@@ -1174,6 +1177,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, · 6 unmodified lines
11741177 ret = dsa_slave_phy_connect(p, slave_dev, p->port);
11751178 if (ret) {
11761179 netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret);
1180+ if (phy_is_fixed)
1181+ of_phy_deregister_fixed_link(port_dn);
11771182 return ret;
11781183 }
11791184 }
@@ -1289,10 +1294,18 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent, · 109 unmodified lines
12891294 void dsa_slave_destroy(struct net_device *slave_dev)
12901295 {
12911296 struct dsa_slave_priv *p = netdev_priv(slave_dev);
1297+ struct dsa_switch *ds = p->parent;
1298+ struct device_node *port_dn;
1299+
1300+ port_dn = ds->ports[p->port].dn;
12921301
12931302 netif_carrier_off(slave_dev);
1294− if (p->phy)
1303+ if (p->phy) {
12951304 phy_disconnect(p->phy);
1305+
1306+ if (of_phy_is_fixed_link(port_dn))
1307+ of_phy_deregister_fixed_link(port_dn);
1308+ }
12961309 unregister_netdev(slave_dev);
12971310 free_netdev(slave_dev);
12981311 }
net/ipv4/Kconfig+1−0
@@ -715,6 +715,7 @@ config DEFAULT_TCP_CONG · 714 unmodified lines
715715 default "reno" if DEFAULT_RENO
716716 default "dctcp" if DEFAULT_DCTCP
717717 default "cdg" if DEFAULT_CDG
718+ default "bbr" if DEFAULT_BBR
718719 default "cubic"
719720
720721 config TCP_MD5SIG
net/ipv4/af_inet.c+1−1
@@ -1233,7 +1233,7 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb, · 1232 unmodified lines
12331233 fixedid = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID);
12341234
12351235 /* fixed ID is invalid if DF bit is not set */
1236− if (fixedid && !(iph->frag_off & htons(IP_DF)))
1236+ if (fixedid && !(ip_hdr(skb)->frag_off & htons(IP_DF)))
12371237 goto out;
12381238 }
12391239
net/ipv4/esp4.c+1−1
@@ -476,7 +476,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb) · 475 unmodified lines
476476 esph = (void *)skb_push(skb, 4);
477477 *seqhi = esph->spi;
478478 esph->spi = esph->seq_no;
479− esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.input.hi);
479+ esph->seq_no = XFRM_SKB_CB(skb)->seq.input.hi;
480480 aead_request_set_callback(req, 0, esp_input_done_esn, skb);
481481 }
482482
net/ipv4/ip_output.c+2−0
@@ -107,6 +107,8 @@ int __ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb) · 106 unmodified lines
107107 if (unlikely(!skb))
108108 return 0;
109109
110+ skb->protocol = htons(ETH_P_IP);
111+
110112 return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT,
111113 net, sk, skb, NULL, skb_dst(skb)->dev,
112114 dst_output);
net/ipv4/netfilter.c+4−1
@@ -24,10 +24,11 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t · 23 unmodified lines
2424 struct flowi4 fl4 = {};
2525 __be32 saddr = iph->saddr;
2626 __u8 flags = skb->sk ? inet_sk_flowi_flags(skb->sk) : 0;
27+ struct net_device *dev = skb_dst(skb)->dev;
2728 unsigned int hh_len;
2829
2930 if (addr_type == RTN_UNSPEC)
30− addr_type = inet_addr_type(net, saddr);
31+ addr_type = inet_addr_type_dev_table(net, dev, saddr);
3132 if (addr_type == RTN_LOCAL || addr_type == RTN_UNICAST)
3233 flags |= FLOWI_FLAG_ANYSRC;
3334 else
@@ -40,6 +41,8 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t · 6 unmodified lines
4041 fl4.saddr = saddr;
4142 fl4.flowi4_tos = RT_TOS(iph->tos);
4243 fl4.flowi4_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0;
44+ if (!fl4.flowi4_oif)
45+ fl4.flowi4_oif = l3mdev_master_ifindex(dev);
4346 fl4.flowi4_mark = skb->mark;
4447 fl4.flowi4_flags = flags;
4548 rt = ip_route_output_key(net, &fl4);
net/ipv4/netfilter/arp_tables.c+2−2
@@ -1201,8 +1201,8 @@ static int translate_compat_table(struct xt_table_info **pinfo, · 1200 unmodified lines
12011201
12021202 newinfo->number = compatr->num_entries;
12031203 for (i = 0; i < NF_ARP_NUMHOOKS; i++) {
1204− newinfo->hook_entry[i] = info->hook_entry[i];
1205− newinfo->underflow[i] = info->underflow[i];
1204+ newinfo->hook_entry[i] = compatr->hook_entry[i];
1205+ newinfo->underflow[i] = compatr->underflow[i];
12061206 }
12071207 entry1 = newinfo->entries;
12081208 pos = entry1;
net/ipv6/datagram.c+3−1
@@ -139,7 +139,8 @@ void ip6_datagram_release_cb(struct sock *sk) · 138 unmodified lines
139139 }
140140 EXPORT_SYMBOL_GPL(ip6_datagram_release_cb);
141141
142−static int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
142+int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr,
143+ int addr_len)
143144 {
144145 struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
145146 struct inet_sock *inet = inet_sk(sk);
@@ -252,6 +253,7 @@ ipv4_connected: · 106 unmodified lines
252253 out:
253254 return err;
254255 }
256+EXPORT_SYMBOL_GPL(__ip6_datagram_connect);
255257
256258 int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
257259 {
net/ipv6/esp6.c+1−1
@@ -418,7 +418,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb) · 417 unmodified lines
418418 esph = (void *)skb_push(skb, 4);
419419 *seqhi = esph->spi;
420420 esph->spi = esph->seq_no;
421− esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.input.hi);
421+ esph->seq_no = XFRM_SKB_CB(skb)->seq.input.hi;
422422 aead_request_set_callback(req, 0, esp_input_done_esn, skb);
423423 }
424424
net/ipv6/icmp.c+4−2
@@ -447,8 +447,10 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, · 446 unmodified lines
447447
448448 if (__ipv6_addr_needs_scope_id(addr_type))
449449 iif = skb->dev->ifindex;
450− else
451− iif = l3mdev_master_ifindex(skb_dst(skb)->dev);
450+ else {
451+ dst = skb_dst(skb);
452+ iif = l3mdev_master_ifindex(dst ? dst->dev : skb->dev);
453+ }
452454
453455 /*
454456 * Must not send error if the source does not uniquely
net/ipv6/ip6_offload.c+1−1
@@ -99,7 +99,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, · 98 unmodified lines
9999 segs = ops->callbacks.gso_segment(skb, features);
100100 }
101101
102− if (IS_ERR(segs))
102+ if (IS_ERR_OR_NULL(segs))
103103 goto out;
104104
105105 gso_partial = !!(skb_shinfo(segs)->gso_type & SKB_GSO_PARTIAL);
net/ipv6/ip6_tunnel.c+0−1
@@ -1181,7 +1181,6 @@ route_lookup: · 1180 unmodified lines
11811181 if (err)
11821182 return err;
11831183
1184− skb->protocol = htons(ETH_P_IPV6);
11851184 skb_push(skb, sizeof(struct ipv6hdr));
11861185 skb_reset_network_header(skb);
11871186 ipv6h = ipv6_hdr(skb);
net/ipv6/ip6_vti.c+31−0
@@ -1138,6 +1138,33 @@ static struct xfrm6_protocol vti_ipcomp6_protocol __read_mostly = { · 1137 unmodified lines
11381138 .priority = 100,
11391139 };
11401140
1141+static bool is_vti6_tunnel(const struct net_device *dev)
1142+{
1143+ return dev->netdev_ops == &vti6_netdev_ops;
1144+}
1145+
1146+static int vti6_device_event(struct notifier_block *unused,
1147+ unsigned long event, void *ptr)
1148+{
1149+ struct net_device *dev = netdev_notifier_info_to_dev(ptr);
1150+ struct ip6_tnl *t = netdev_priv(dev);
1151+
1152+ if (!is_vti6_tunnel(dev))
1153+ return NOTIFY_DONE;
1154+
1155+ switch (event) {
1156+ case NETDEV_DOWN:
1157+ if (!net_eq(t->net, dev_net(dev)))
1158+ xfrm_garbage_collect(t->net);
1159+ break;
1160+ }
1161+ return NOTIFY_DONE;
1162+}
1163+
1164+static struct notifier_block vti6_notifier_block __read_mostly = {
1165+ .notifier_call = vti6_device_event,
1166+};
1167+
11411168 /**
11421169 * vti6_tunnel_init - register protocol and reserve needed resources
11431170 *
@@ -1148,6 +1175,8 @@ static int __init vti6_tunnel_init(void) · 4 unmodified lines
11481175 const char *msg;
11491176 int err;
11501177
1178+ register_netdevice_notifier(&vti6_notifier_block);
1179+
11511180 msg = "tunnel device";
11521181 err = register_pernet_device(&vti6_net_ops);
11531182 if (err < 0)
@@ -1180,6 +1209,7 @@ xfrm_proto_ah_failed: · 26 unmodified lines
11801209 xfrm_proto_esp_failed:
11811210 unregister_pernet_device(&vti6_net_ops);
11821211 pernet_dev_failed:
1212+ unregister_netdevice_notifier(&vti6_notifier_block);
11831213 pr_err("vti6 init: failed to register %s\n", msg);
11841214 return err;
11851215 }
@@ -1194,6 +1224,7 @@ static void __exit vti6_tunnel_cleanup(void) · 8 unmodified lines
11941224 xfrm6_protocol_deregister(&vti_ah6_protocol, IPPROTO_AH);
11951225 xfrm6_protocol_deregister(&vti_esp6_protocol, IPPROTO_ESP);
11961226 unregister_pernet_device(&vti6_net_ops);
1227+ unregister_netdevice_notifier(&vti6_notifier_block);
11971228 }
11981229
11991230 module_init(vti6_tunnel_init);
net/ipv6/netfilter/nf_conntrack_reasm.c+2−2
@@ -576,11 +576,11 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user) · 575 unmodified lines
576576 /* Jumbo payload inhibits frag. header */
577577 if (ipv6_hdr(skb)->payload_len == 0) {
578578 pr_debug("payload len = 0\n");
579− return -EINVAL;
579+ return 0;
580580 }
581581
582582 if (find_prev_fhdr(skb, &prevhdr, &nhoff, &fhoff) < 0)
583− return -EINVAL;
583+ return 0;
584584
585585 if (!pskb_may_pull(skb, fhoff + sizeof(*fhdr)))
586586 return -ENOMEM;
net/ipv6/netfilter/nf_defrag_ipv6_hooks.c+1−1
@@ -69,7 +69,7 @@ static unsigned int ipv6_defrag(void *priv, · 68 unmodified lines
6969 if (err == -EINPROGRESS)
7070 return NF_STOLEN;
7171
72− return NF_ACCEPT;
72+ return err == 0 ? NF_ACCEPT : NF_DROP;
7373 }
7474
7575 static struct nf_hook_ops ipv6_defrag_ops[] = {
net/ipv6/netfilter/nf_reject_ipv6.c+1−0
@@ -156,6 +156,7 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook) · 155 unmodified lines
156156 fl6.daddr = oip6h->saddr;
157157 fl6.fl6_sport = otcph->dest;
158158 fl6.fl6_dport = otcph->source;
159+ fl6.flowi6_oif = l3mdev_master_ifindex(skb_dst(oldskb)->dev);
159160 security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6));
160161 dst = ip6_route_output(net, NULL, &fl6);
161162 if (dst->error) {
net/ipv6/output_core.c+2−0
@@ -155,6 +155,8 @@ int __ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb) · 154 unmodified lines
155155 if (unlikely(!skb))
156156 return 0;
157157
158+ skb->protocol = htons(ETH_P_IPV6);
159+
158160 return nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT,
159161 net, sk, skb, NULL, skb_dst(skb)->dev,
160162 dst_output);
net/l2tp/l2tp_ip.c+34−29
@@ -61,7 +61,8 @@ static struct sock *__l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif · 60 unmodified lines
6161 if ((l2tp->conn_id == tunnel_id) &&
6262 net_eq(sock_net(sk), net) &&
6363 !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
64− !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
64+ (!sk->sk_bound_dev_if || !dif ||
65+ sk->sk_bound_dev_if == dif))
6566 goto found;
6667 }
6768
@@ -182,15 +183,17 @@ pass_up: · 114 unmodified lines
182183 struct iphdr *iph = (struct iphdr *) skb_network_header(skb);
183184
184185 read_lock_bh(&l2tp_ip_lock);
185− sk = __l2tp_ip_bind_lookup(net, iph->daddr, 0, tunnel_id);
186+ sk = __l2tp_ip_bind_lookup(net, iph->daddr, inet_iif(skb),
187+ tunnel_id);
188+ if (!sk) {
189+ read_unlock_bh(&l2tp_ip_lock);
190+ goto discard;
191+ }
192+
193+ sock_hold(sk);
186194 read_unlock_bh(&l2tp_ip_lock);
187195 }
188196
189− if (sk == NULL)
190− goto discard;
191−
192− sock_hold(sk);
193−
194197 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
195198 goto discard_put;
196199
@@ -256,15 +259,9 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) · 59 unmodified lines
256259 if (addr->l2tp_family != AF_INET)
257260 return -EINVAL;
258261
259− ret = -EADDRINUSE;
260− read_lock_bh(&l2tp_ip_lock);
261− if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr,
262− sk->sk_bound_dev_if, addr->l2tp_conn_id))
263− goto out_in_use;
264−
265− read_unlock_bh(&l2tp_ip_lock);
266−
267262 lock_sock(sk);
263+
264+ ret = -EINVAL;
268265 if (!sock_flag(sk, SOCK_ZAPPED))
269266 goto out;
270267
@@ -281,25 +278,28 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) · 10 unmodified lines
281278 inet->inet_rcv_saddr = inet->inet_saddr = addr->l2tp_addr.s_addr;
282279 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
283280 inet->inet_saddr = 0; /* Use device */
284− sk_dst_reset(sk);
285281
282+ write_lock_bh(&l2tp_ip_lock);
283+ if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr,
284+ sk->sk_bound_dev_if, addr->l2tp_conn_id)) {
285+ write_unlock_bh(&l2tp_ip_lock);
286+ ret = -EADDRINUSE;
287+ goto out;
288+ }
289+
290+ sk_dst_reset(sk);
286291 l2tp_ip_sk(sk)->conn_id = addr->l2tp_conn_id;
287292
288− write_lock_bh(&l2tp_ip_lock);
289293 sk_add_bind_node(sk, &l2tp_ip_bind_table);
290294 sk_del_node_init(sk);
291295 write_unlock_bh(&l2tp_ip_lock);
296+
292297 ret = 0;
293298 sock_reset_flag(sk, SOCK_ZAPPED);
294299
295300 out:
296301 release_sock(sk);
297302
298− return ret;
299−
300−out_in_use:
301− read_unlock_bh(&l2tp_ip_lock);
302−
303303 return ret;
304304 }
305305
@@ -308,21 +308,24 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len · 2 unmodified lines
308308 struct sockaddr_l2tpip *lsa = (struct sockaddr_l2tpip *) uaddr;
309309 int rc;
310310
311− if (sock_flag(sk, SOCK_ZAPPED)) /* Must bind first - autobinding does not work */
312− return -EINVAL;
313−
314311 if (addr_len < sizeof(*lsa))
315312 return -EINVAL;
316313
317314 if (ipv4_is_multicast(lsa->l2tp_addr.s_addr))
318315 return -EINVAL;
319316
320− rc = ip4_datagram_connect(sk, uaddr, addr_len);
321− if (rc < 0)
322− return rc;
323−
324317 lock_sock(sk);
325318
319+ /* Must bind first - autobinding does not work */
320+ if (sock_flag(sk, SOCK_ZAPPED)) {
321+ rc = -EINVAL;
322+ goto out_sk;
323+ }
324+
325+ rc = __ip4_datagram_connect(sk, uaddr, addr_len);
326+ if (rc < 0)
327+ goto out_sk;
328+
326329 l2tp_ip_sk(sk)->peer_conn_id = lsa->l2tp_conn_id;
327330
328331 write_lock_bh(&l2tp_ip_lock);
@@ -330,7 +333,9 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len · 1 unmodified line
330333 sk_add_bind_node(sk, &l2tp_ip_bind_table);
331334 write_unlock_bh(&l2tp_ip_lock);
332335
336+out_sk:
333337 release_sock(sk);
338+
334339 return rc;
335340 }
336341
net/l2tp/l2tp_ip6.c+42−37
@@ -72,8 +72,9 @@ static struct sock *__l2tp_ip6_bind_lookup(struct net *net, · 71 unmodified lines
7272
7373 if ((l2tp->conn_id == tunnel_id) &&
7474 net_eq(sock_net(sk), net) &&
75− !(addr && ipv6_addr_equal(addr, laddr)) &&
76− !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
75+ (!addr || ipv6_addr_equal(addr, laddr)) &&
76+ (!sk->sk_bound_dev_if || !dif ||
77+ sk->sk_bound_dev_if == dif))
7778 goto found;
7879 }
7980
@@ -196,16 +197,17 @@ pass_up: · 116 unmodified lines
196197 struct ipv6hdr *iph = ipv6_hdr(skb);
197198
198199 read_lock_bh(&l2tp_ip6_lock);
199− sk = __l2tp_ip6_bind_lookup(net, &iph->daddr,
200− 0, tunnel_id);
200+ sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, inet6_iif(skb),
201+ tunnel_id);
202+ if (!sk) {
203+ read_unlock_bh(&l2tp_ip6_lock);
204+ goto discard;
205+ }
206+
207+ sock_hold(sk);
201208 read_unlock_bh(&l2tp_ip6_lock);
202209 }
203210
204− if (sk == NULL)
205− goto discard;
206−
207− sock_hold(sk);
208−
209211 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
210212 goto discard_put;
211213
@@ -266,6 +268,7 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) · 54 unmodified lines
266268 struct sockaddr_l2tpip6 *addr = (struct sockaddr_l2tpip6 *) uaddr;
267269 struct net *net = sock_net(sk);
268270 __be32 v4addr = 0;
271+ int bound_dev_if;
269272 int addr_type;
270273 int err;
271274
@@ -284,13 +287,6 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) · 12 unmodified lines
284287 if (addr_type & IPV6_ADDR_MULTICAST)
285288 return -EADDRNOTAVAIL;
286289
287− err = -EADDRINUSE;
288− read_lock_bh(&l2tp_ip6_lock);
289− if (__l2tp_ip6_bind_lookup(net, &addr->l2tp_addr,
290− sk->sk_bound_dev_if, addr->l2tp_conn_id))
291− goto out_in_use;
292− read_unlock_bh(&l2tp_ip6_lock);
293−
294290 lock_sock(sk);
295291
296292 err = -EINVAL;
@@ -300,28 +296,25 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) · 3 unmodified lines
300296 if (sk->sk_state != TCP_CLOSE)
301297 goto out_unlock;
302298
299+ bound_dev_if = sk->sk_bound_dev_if;
300+
303301 /* Check if the address belongs to the host. */
304302 rcu_read_lock();
305303 if (addr_type != IPV6_ADDR_ANY) {
306304 struct net_device *dev = NULL;
307305
308306 if (addr_type & IPV6_ADDR_LINKLOCAL) {
309− if (addr_len >= sizeof(struct sockaddr_in6) &&
310− addr->l2tp_scope_id) {
311− /* Override any existing binding, if another
312− * one is supplied by user.
313− */
314− sk->sk_bound_dev_if = addr->l2tp_scope_id;
315− }
307+ if (addr->l2tp_scope_id)
308+ bound_dev_if = addr->l2tp_scope_id;
316309
317310 /* Binding to link-local address requires an
318− interface */
319− if (!sk->sk_bound_dev_if)
311+ * interface.
312+ */
313+ if (!bound_dev_if)
320314 goto out_unlock_rcu;
321315
322316 err = -ENODEV;
323− dev = dev_get_by_index_rcu(sock_net(sk),
324− sk->sk_bound_dev_if);
317+ dev = dev_get_by_index_rcu(sock_net(sk), bound_dev_if);
325318 if (!dev)
326319 goto out_unlock_rcu;
327320 }
@@ -336,13 +329,22 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) · 8 unmodified lines
336329 }
337330 rcu_read_unlock();
338331
339− inet->inet_rcv_saddr = inet->inet_saddr = v4addr;
332+ write_lock_bh(&l2tp_ip6_lock);
333+ if (__l2tp_ip6_bind_lookup(net, &addr->l2tp_addr, bound_dev_if,
334+ addr->l2tp_conn_id)) {
335+ write_unlock_bh(&l2tp_ip6_lock);
336+ err = -EADDRINUSE;
337+ goto out_unlock;
338+ }
339+
340+ inet->inet_saddr = v4addr;
341+ inet->inet_rcv_saddr = v4addr;
342+ sk->sk_bound_dev_if = bound_dev_if;
340343 sk->sk_v6_rcv_saddr = addr->l2tp_addr;
341344 np->saddr = addr->l2tp_addr;
342345
343346 l2tp_ip6_sk(sk)->conn_id = addr->l2tp_conn_id;
344347
345− write_lock_bh(&l2tp_ip6_lock);
346348 sk_add_bind_node(sk, &l2tp_ip6_bind_table);
347349 sk_del_node_init(sk);
348350 write_unlock_bh(&l2tp_ip6_lock);
@@ -355,10 +357,7 @@ out_unlock_rcu: · 6 unmodified lines
355357 rcu_read_unlock();
356358 out_unlock:
357359 release_sock(sk);
358− return err;
359360
360−out_in_use:
361− read_unlock_bh(&l2tp_ip6_lock);
362361 return err;
363362 }
364363
@@ -371,9 +370,6 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr, · 6 unmodified lines
371370 int addr_type;
372371 int rc;
373372
374− if (sock_flag(sk, SOCK_ZAPPED)) /* Must bind first - autobinding does not work */
375− return -EINVAL;
376−
377373 if (addr_len < sizeof(*lsa))
378374 return -EINVAL;
379375
@@ -390,10 +386,18 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr, · 10 unmodified lines
390386 return -EINVAL;
391387 }
392388
393− rc = ip6_datagram_connect(sk, uaddr, addr_len);
394−
395389 lock_sock(sk);
396390
391+ /* Must bind first - autobinding does not work */
392+ if (sock_flag(sk, SOCK_ZAPPED)) {
393+ rc = -EINVAL;
394+ goto out_sk;
395+ }
396+
397+ rc = __ip6_datagram_connect(sk, uaddr, addr_len);
398+ if (rc < 0)
399+ goto out_sk;
400+
397401 l2tp_ip6_sk(sk)->peer_conn_id = lsa->l2tp_conn_id;
398402
399403 write_lock_bh(&l2tp_ip6_lock);
@@ -401,6 +405,7 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr, · 1 unmodified line
401405 sk_add_bind_node(sk, &l2tp_ip6_bind_table);
402406 write_unlock_bh(&l2tp_ip6_lock);
403407
408+out_sk:
404409 release_sock(sk);
405410
406411 return rc;
net/netfilter/nf_nat_core.c+30−19
@@ -42,7 +42,7 @@ struct nf_nat_conn_key { · 41 unmodified lines
4242 const struct nf_conntrack_zone *zone;
4343 };
4444
45−static struct rhashtable nf_nat_bysource_table;
45+static struct rhltable nf_nat_bysource_table;
4646
4747 inline const struct nf_nat_l3proto *
4848 __nf_nat_l3proto_find(u8 family)
@@ -193,9 +193,12 @@ static int nf_nat_bysource_cmp(struct rhashtable_compare_arg *arg, · 144 unmodified lines
193193 const struct nf_nat_conn_key *key = arg->key;
194194 const struct nf_conn *ct = obj;
195195
196− return same_src(ct, key->tuple) &&
197− net_eq(nf_ct_net(ct), key->net) &&
198− nf_ct_zone_equal(ct, key->zone, IP_CT_DIR_ORIGINAL);
196+ if (!same_src(ct, key->tuple) ||
197+ !net_eq(nf_ct_net(ct), key->net) ||
198+ !nf_ct_zone_equal(ct, key->zone, IP_CT_DIR_ORIGINAL))
199+ return 1;
200+
201+ return 0;
199202 }
200203
201204 static struct rhashtable_params nf_nat_bysource_params = {
@@ -204,7 +207,6 @@ static struct rhashtable_params nf_nat_bysource_params = { · 2 unmodified lines
204207 .obj_cmpfn = nf_nat_bysource_cmp,
205208 .nelem_hint = 256,
206209 .min_size = 1024,
207− .nulls_base = (1U << RHT_BASE_SHIFT),
208210 };
209211
210212 /* Only called for SRC manip */
@@ -223,12 +225,15 @@ find_appropriate_src(struct net *net, · 12 unmodified lines
223225 .tuple = tuple,
224226 .zone = zone
225227 };
228+ struct rhlist_head *hl;
226229
227− ct = rhashtable_lookup_fast(&nf_nat_bysource_table, &key,
228− nf_nat_bysource_params);
229− if (!ct)
230+ hl = rhltable_lookup(&nf_nat_bysource_table, &key,
231+ nf_nat_bysource_params);
232+ if (!hl)
230233 return 0;
231234
235+ ct = container_of(hl, typeof(*ct), nat_bysource);
236+
232237 nf_ct_invert_tuplepr(result,
233238 &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
234239 result->dst = tuple->dst;
@@ -446,11 +451,17 @@ nf_nat_setup_info(struct nf_conn *ct, · 211 unmodified lines
446451 }
447452
448453 if (maniptype == NF_NAT_MANIP_SRC) {
454+ struct nf_nat_conn_key key = {
455+ .net = nf_ct_net(ct),
456+ .tuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
457+ .zone = nf_ct_zone(ct),
458+ };
449459 int err;
450460
451− err = rhashtable_insert_fast(&nf_nat_bysource_table,
452− &ct->nat_bysource,
453− nf_nat_bysource_params);
461+ err = rhltable_insert_key(&nf_nat_bysource_table,
462+ &key,
463+ &ct->nat_bysource,
464+ nf_nat_bysource_params);
454465 if (err)
455466 return NF_DROP;
456467 }
@@ -567,8 +578,8 @@ static int nf_nat_proto_clean(struct nf_conn *ct, void *data) · 110 unmodified lines
567578 * will delete entry from already-freed table.
568579 */
569580 ct->status &= ~IPS_NAT_DONE_MASK;
570− rhashtable_remove_fast(&nf_nat_bysource_table, &ct->nat_bysource,
571− nf_nat_bysource_params);
581+ rhltable_remove(&nf_nat_bysource_table, &ct->nat_bysource,
582+ nf_nat_bysource_params);
572583
573584 /* don't delete conntrack. Although that would make things a lot
574585 * simpler, we'd end up flushing all conntracks on nat rmmod.
@@ -698,8 +709,8 @@ static void nf_nat_cleanup_conntrack(struct nf_conn *ct) · 123 unmodified lines
698709 if (!nat)
699710 return;
700711
701− rhashtable_remove_fast(&nf_nat_bysource_table, &ct->nat_bysource,
702− nf_nat_bysource_params);
712+ rhltable_remove(&nf_nat_bysource_table, &ct->nat_bysource,
713+ nf_nat_bysource_params);
703714 }
704715
705716 static struct nf_ct_ext_type nat_extend __read_mostly = {
@@ -834,13 +845,13 @@ static int __init nf_nat_init(void) · 128 unmodified lines
834845 {
835846 int ret;
836847
837− ret = rhashtable_init(&nf_nat_bysource_table, &nf_nat_bysource_params);
848+ ret = rhltable_init(&nf_nat_bysource_table, &nf_nat_bysource_params);
838849 if (ret)
839850 return ret;
840851
841852 ret = nf_ct_extend_register(&nat_extend);
842853 if (ret < 0) {
843− rhashtable_destroy(&nf_nat_bysource_table);
854+ rhltable_destroy(&nf_nat_bysource_table);
844855 printk(KERN_ERR "nf_nat_core: Unable to register extension\n");
845856 return ret;
846857 }
@@ -864,7 +875,7 @@ static int __init nf_nat_init(void) · 17 unmodified lines
864875 return 0;
865876
866877 cleanup_extend:
867− rhashtable_destroy(&nf_nat_bysource_table);
878+ rhltable_destroy(&nf_nat_bysource_table);
868879 nf_ct_extend_unregister(&nat_extend);
869880 return ret;
870881 }
@@ -883,7 +894,7 @@ static void __exit nf_nat_cleanup(void) · 12 unmodified lines
883894 for (i = 0; i < NFPROTO_NUMPROTO; i++)
884895 kfree(nf_nat_l4protos[i]);
885896
886− rhashtable_destroy(&nf_nat_bysource_table);
897+ rhltable_destroy(&nf_nat_bysource_table);
887898 }
888899
889900 MODULE_LICENSE("GPL");
net/netfilter/nf_tables_api.c+9−5
@@ -2570,7 +2570,8 @@ static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx, · 2569 unmodified lines
25702570 }
25712571
25722572 if (set->timeout &&
2573− nla_put_be64(skb, NFTA_SET_TIMEOUT, cpu_to_be64(set->timeout),
2573+ nla_put_be64(skb, NFTA_SET_TIMEOUT,
2574+ cpu_to_be64(jiffies_to_msecs(set->timeout)),
25742575 NFTA_SET_PAD))
25752576 goto nla_put_failure;
25762577 if (set->gc_int &&
@@ -2859,7 +2860,8 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk, · 282 unmodified lines
28592860 if (nla[NFTA_SET_TIMEOUT] != NULL) {
28602861 if (!(flags & NFT_SET_TIMEOUT))
28612862 return -EINVAL;
2862− timeout = be64_to_cpu(nla_get_be64(nla[NFTA_SET_TIMEOUT]));
2863+ timeout = msecs_to_jiffies(be64_to_cpu(nla_get_be64(
2864+ nla[NFTA_SET_TIMEOUT])));
28632865 }
28642866 gc_int = 0;
28652867 if (nla[NFTA_SET_GC_INTERVAL] != NULL) {
@@ -3178,7 +3180,8 @@ static int nf_tables_fill_setelem(struct sk_buff *skb, · 312 unmodified lines
31783180
31793181 if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT) &&
31803182 nla_put_be64(skb, NFTA_SET_ELEM_TIMEOUT,
3181− cpu_to_be64(*nft_set_ext_timeout(ext)),
3183+ cpu_to_be64(jiffies_to_msecs(
3184+ *nft_set_ext_timeout(ext))),
31823185 NFTA_SET_ELEM_PAD))
31833186 goto nla_put_failure;
31843187
@@ -3447,7 +3450,7 @@ void *nft_set_elem_init(const struct nft_set *set, · 262 unmodified lines
34473450 memcpy(nft_set_ext_data(ext), data, set->dlen);
34483451 if (nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION))
34493452 *nft_set_ext_expiration(ext) =
3450− jiffies + msecs_to_jiffies(timeout);
3453+ jiffies + timeout;
34513454 if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT))
34523455 *nft_set_ext_timeout(ext) = timeout;
34533456
@@ -3535,7 +3538,8 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, · 81 unmodified lines
35353538 if (nla[NFTA_SET_ELEM_TIMEOUT] != NULL) {
35363539 if (!(set->flags & NFT_SET_TIMEOUT))
35373540 return -EINVAL;
3538− timeout = be64_to_cpu(nla_get_be64(nla[NFTA_SET_ELEM_TIMEOUT]));
3541+ timeout = msecs_to_jiffies(be64_to_cpu(nla_get_be64(
3542+ nla[NFTA_SET_ELEM_TIMEOUT])));
35393543 } else if (set->flags & NFT_SET_TIMEOUT) {
35403544 timeout = set->timeout;
35413545 }
net/netfilter/nft_hash.c+5−2
@@ -53,6 +53,7 @@ static int nft_hash_init(const struct nft_ctx *ctx, · 52 unmodified lines
5353 {
5454 struct nft_hash *priv = nft_expr_priv(expr);
5555 u32 len;
56+ int err;
5657
5758 if (!tb[NFTA_HASH_SREG] ||
5859 !tb[NFTA_HASH_DREG] ||
@@ -67,8 +68,10 @@ static int nft_hash_init(const struct nft_ctx *ctx, · 8 unmodified lines
6768 priv->sreg = nft_parse_register(tb[NFTA_HASH_SREG]);
6869 priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]);
6970
70− len = ntohl(nla_get_be32(tb[NFTA_HASH_LEN]));
71− if (len == 0 || len > U8_MAX)
71+ err = nft_parse_u32_check(tb[NFTA_HASH_LEN], U8_MAX, &len);
72+ if (err < 0)
73+ return err;
74+ if (len == 0)
7275 return -ERANGE;
7376
7477 priv->len = len;
net/netfilter/nft_range.c+6−0
@@ -59,6 +59,12 @@ static int nft_range_init(const struct nft_ctx *ctx, const struct nft_expr *expr · 58 unmodified lines
5959 int err;
6060 u32 op;
6161
62+ if (!tb[NFTA_RANGE_SREG] ||
63+ !tb[NFTA_RANGE_OP] ||
64+ !tb[NFTA_RANGE_FROM_DATA] ||
65+ !tb[NFTA_RANGE_TO_DATA])
66+ return -EINVAL;
67+
6268 err = nft_data_init(NULL, &priv->data_from, sizeof(priv->data_from),
6369 &desc_from, tb[NFTA_RANGE_FROM_DATA]);
6470 if (err < 0)
net/netlink/af_netlink.c+23−4
@@ -322,14 +322,11 @@ static void netlink_skb_set_owner_r(struct sk_buff *skb, struct sock *sk) · 321 unmodified lines
322322 sk_mem_charge(sk, skb->truesize);
323323 }
324324
325−static void netlink_sock_destruct(struct sock *sk)
325+static void __netlink_sock_destruct(struct sock *sk)
326326 {
327327 struct netlink_sock *nlk = nlk_sk(sk);
328328
329329 if (nlk->cb_running) {
330− if (nlk->cb.done)
331− nlk->cb.done(&nlk->cb);
332−
333330 module_put(nlk->cb.module);
334331 kfree_skb(nlk->cb.skb);
335332 }
@@ -346,6 +343,28 @@ static void netlink_sock_destruct(struct sock *sk) · 10 unmodified lines
346343 WARN_ON(nlk_sk(sk)->groups);
347344 }
348345
346+static void netlink_sock_destruct_work(struct work_struct *work)
347+{
348+ struct netlink_sock *nlk = container_of(work, struct netlink_sock,
349+ work);
350+
351+ nlk->cb.done(&nlk->cb);
352+ __netlink_sock_destruct(&nlk->sk);
353+}
354+
355+static void netlink_sock_destruct(struct sock *sk)
356+{
357+ struct netlink_sock *nlk = nlk_sk(sk);
358+
359+ if (nlk->cb_running && nlk->cb.done) {
360+ INIT_WORK(&nlk->work, netlink_sock_destruct_work);
361+ schedule_work(&nlk->work);
362+ return;
363+ }
364+
365+ __netlink_sock_destruct(sk);
366+}
367+
349368 /* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on
350369 * SMP. Look, when several writers sleep and reader wakes them up, all but one
351370 * immediately hit write lock and grab all the cpus. Exclusive sleep solves
net/netlink/af_netlink.h+2−0
@@ -3,6 +3,7 @@ · 2 unmodified lines
33
44 #include <linux/rhashtable.h>
55 #include <linux/atomic.h>
6+#include <linux/workqueue.h>
67 #include <net/sock.h>
78
89 #define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8)
@@ -33,6 +34,7 @@ struct netlink_sock { · 24 unmodified lines
3334
3435 struct rhash_head node;
3536 struct rcu_head rcu;
37+ struct work_struct work;
3638 };
3739
3840 static inline struct netlink_sock *nlk_sk(struct sock *sk)
net/openvswitch/conntrack.c+4−1
@@ -370,8 +370,11 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key, · 369 unmodified lines
370370 skb_orphan(skb);
371371 memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
372372 err = nf_ct_frag6_gather(net, skb, user);
373− if (err)
373+ if (err) {
374+ if (err != -EINPROGRESS)
375+ kfree_skb(skb);
374376 return err;
377+ }
375378
376379 key->ip.proto = ipv6_hdr(skb)->nexthdr;
377380 ovs_cb.mru = IP6CB(skb)->frag_max_size;
net/packet/af_packet.c+12−6
@@ -3648,19 +3648,25 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv · 3647 unmodified lines
36483648
36493649 if (optlen != sizeof(val))
36503650 return -EINVAL;
3651− if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)
3652− return -EBUSY;
36533651 if (copy_from_user(&val, optval, sizeof(val)))
36543652 return -EFAULT;
36553653 switch (val) {
36563654 case TPACKET_V1:
36573655 case TPACKET_V2:
36583656 case TPACKET_V3:
3659− po->tp_version = val;
3660− return 0;
3657+ break;
36613658 default:
36623659 return -EINVAL;
36633660 }
3661+ lock_sock(sk);
3662+ if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) {
3663+ ret = -EBUSY;
3664+ } else {
3665+ po->tp_version = val;
3666+ ret = 0;
3667+ }
3668+ release_sock(sk);
3669+ return ret;
36643670 }
36653671 case PACKET_RESERVE:
36663672 {
@@ -4164,6 +4170,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, · 497 unmodified lines
41644170 /* Added to avoid minimal code churn */
41654171 struct tpacket_req *req = &req_u->req;
41664172
4173+ lock_sock(sk);
41674174 /* Opening a Tx-ring is NOT supported in TPACKET_V3 */
41684175 if (!closing && tx_ring && (po->tp_version > TPACKET_V2)) {
41694176 net_warn_ratelimited("Tx-ring is not supported.\n");
@@ -4245,7 +4252,6 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, · 75 unmodified lines
42454252 goto out;
42464253 }
42474254
4248− lock_sock(sk);
42494255
42504256 /* Detach socket from network */
42514257 spin_lock(&po->bind_lock);
@@ -4294,11 +4300,11 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, · 42 unmodified lines
42944300 if (!tx_ring)
42954301 prb_shutdown_retire_blk_timer(po, rb_queue);
42964302 }
4297− release_sock(sk);
42984303
42994304 if (pg_vec)
43004305 free_pg_vec(pg_vec, order, req->tp_block_nr);
43014306 out:
4307+ release_sock(sk);
43024308 return err;
43034309 }
43044310
net/rds/tcp.c+2−0
@@ -659,6 +659,8 @@ out_recv: · 658 unmodified lines
659659 out_pernet:
660660 unregister_pernet_subsys(&rds_tcp_net_ops);
661661 out_slab:
662+ if (unregister_netdevice_notifier(&rds_tcp_dev_notifier))
663+ pr_warn("could not unregister rds_tcp_dev_notifier\n");
662664 kmem_cache_destroy(rds_tcp_conn_slab);
663665 out:
664666 return ret;
net/sched/act_pedit.c+20−4
@@ -108,6 +108,17 @@ static void tcf_pedit_cleanup(struct tc_action *a, int bind) · 107 unmodified lines
108108 kfree(keys);
109109 }
110110
111+static bool offset_valid(struct sk_buff *skb, int offset)
112+{
113+ if (offset > 0 && offset > skb->len)
114+ return false;
115+
116+ if (offset < 0 && -offset > skb_headroom(skb))
117+ return false;
118+
119+ return true;
120+}
121+
111122 static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a,
112123 struct tcf_result *res)
113124 {
@@ -134,6 +145,11 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, · 20 unmodified lines
134145 if (tkey->offmask) {
135146 char *d, _d;
136147
148+ if (!offset_valid(skb, off + tkey->at)) {
149+ pr_info("tc filter pedit 'at' offset %d out of bounds\n",
150+ off + tkey->at);
151+ goto bad;
152+ }
137153 d = skb_header_pointer(skb, off + tkey->at, 1,
138154 &_d);
139155 if (!d)
@@ -146,10 +162,10 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, · 6 unmodified lines
146162 " offset must be on 32 bit boundaries\n");
147163 goto bad;
148164 }
149− if (offset > 0 && offset > skb->len) {
150− pr_info("tc filter pedit"
151− " offset %d can't exceed pkt length %d\n",
152− offset, skb->len);
165+
166+ if (!offset_valid(skb, off + offset)) {
167+ pr_info("tc filter pedit offset %d out of bounds\n",
168+ offset);
153169 goto bad;
154170 }
155171
net/sched/cls_basic.c+0−4
@@ -62,9 +62,6 @@ static unsigned long basic_get(struct tcf_proto *tp, u32 handle) · 61 unmodified lines
6262 struct basic_head *head = rtnl_dereference(tp->root);
6363 struct basic_filter *f;
6464
65− if (head == NULL)
66− return 0UL;
67−
6865 list_for_each_entry(f, &head->flist, link) {
6966 if (f->handle == handle) {
7067 l = (unsigned long) f;
@@ -109,7 +106,6 @@ static bool basic_destroy(struct tcf_proto *tp, bool force) · 38 unmodified lines
109106 tcf_unbind_filter(tp, &f->res);
110107 call_rcu(&f->rcu, basic_delete_filter);
111108 }
112− RCU_INIT_POINTER(tp->root, NULL);
113109 kfree_rcu(head, rcu);
114110 return true;
115111 }
net/sched/cls_bpf.c+0−4
@@ -292,7 +292,6 @@ static bool cls_bpf_destroy(struct tcf_proto *tp, bool force) · 291 unmodified lines
292292 call_rcu(&prog->rcu, __cls_bpf_delete_prog);
293293 }
294294
295− RCU_INIT_POINTER(tp->root, NULL);
296295 kfree_rcu(head, rcu);
297296 return true;
298297 }
@@ -303,9 +302,6 @@ static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle) · 4 unmodified lines
303302 struct cls_bpf_prog *prog;
304303 unsigned long ret = 0UL;
305304
306− if (head == NULL)
307− return 0UL;
308−
309305 list_for_each_entry(prog, &head->plist, link) {
310306 if (prog->handle == handle) {
311307 ret = (unsigned long) prog;
net/sched/cls_cgroup.c+3−4
@@ -137,11 +137,10 @@ static bool cls_cgroup_destroy(struct tcf_proto *tp, bool force) · 136 unmodified lines
137137
138138 if (!force)
139139 return false;
140−
141− if (head) {
142− RCU_INIT_POINTER(tp->root, NULL);
140+ /* Head can still be NULL due to cls_cgroup_init(). */
141+ if (head)
143142 call_rcu(&head->rcu, cls_cgroup_destroy_rcu);
144− }
143+
145144 return true;
146145 }
147146
net/sched/cls_flow.c+0−1
@@ -596,7 +596,6 @@ static bool flow_destroy(struct tcf_proto *tp, bool force) · 595 unmodified lines
596596 list_del_rcu(&f->list);
597597 call_rcu(&f->rcu, flow_destroy_filter);
598598 }
599− RCU_INIT_POINTER(tp->root, NULL);
600599 kfree_rcu(head, rcu);
601600 return true;
602601 }
net/sched/cls_flower.c+32−9
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313 #include <linux/init.h>
1414 #include <linux/module.h>
1515 #include <linux/rhashtable.h>
16+#include <linux/workqueue.h>
1617
1718 #include <linux/if_ether.h>
1819 #include <linux/in6.h>
@@ -64,7 +65,10 @@ struct cls_fl_head { · 45 unmodified lines
6465 bool mask_assigned;
6566 struct list_head filters;
6667 struct rhashtable_params ht_params;
67− struct rcu_head rcu;
68+ union {
69+ struct work_struct work;
70+ struct rcu_head rcu;
71+ };
6872 };
6973
7074 struct cls_fl_filter {
@@ -269,6 +273,24 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f) · 198 unmodified lines
269273 dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc);
270274 }
271275
276+static void fl_destroy_sleepable(struct work_struct *work)
277+{
278+ struct cls_fl_head *head = container_of(work, struct cls_fl_head,
279+ work);
280+ if (head->mask_assigned)
281+ rhashtable_destroy(&head->ht);
282+ kfree(head);
283+ module_put(THIS_MODULE);
284+}
285+
286+static void fl_destroy_rcu(struct rcu_head *rcu)
287+{
288+ struct cls_fl_head *head = container_of(rcu, struct cls_fl_head, rcu);
289+
290+ INIT_WORK(&head->work, fl_destroy_sleepable);
291+ schedule_work(&head->work);
292+}
293+
272294 static bool fl_destroy(struct tcf_proto *tp, bool force)
273295 {
274296 struct cls_fl_head *head = rtnl_dereference(tp->root);
@@ -282,10 +304,9 @@ static bool fl_destroy(struct tcf_proto *tp, bool force) · 7 unmodified lines
282304 list_del_rcu(&f->list);
283305 call_rcu(&f->rcu, fl_destroy_filter);
284306 }
285− RCU_INIT_POINTER(tp->root, NULL);
286− if (head->mask_assigned)
287− rhashtable_destroy(&head->ht);
288− kfree_rcu(head, rcu);
307+
308+ __module_get(THIS_MODULE);
309+ call_rcu(&head->rcu, fl_destroy_rcu);
289310 return true;
290311 }
291312
@@ -711,8 +732,9 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, · 419 unmodified lines
711732 goto errout;
712733
713734 if (fold) {
714− rhashtable_remove_fast(&head->ht, &fold->ht_node,
715− head->ht_params);
735+ if (!tc_skip_sw(fold->flags))
736+ rhashtable_remove_fast(&head->ht, &fold->ht_node,
737+ head->ht_params);
716738 fl_hw_destroy_filter(tp, (unsigned long)fold);
717739 }
718740
@@ -739,8 +761,9 @@ static int fl_delete(struct tcf_proto *tp, unsigned long arg) · 20 unmodified lines
739761 struct cls_fl_head *head = rtnl_dereference(tp->root);
740762 struct cls_fl_filter *f = (struct cls_fl_filter *) arg;
741763
742− rhashtable_remove_fast(&head->ht, &f->ht_node,
743− head->ht_params);
764+ if (!tc_skip_sw(f->flags))
765+ rhashtable_remove_fast(&head->ht, &f->ht_node,
766+ head->ht_params);
744767 list_del_rcu(&f->list);
745768 fl_hw_destroy_filter(tp, (unsigned long)f);
746769 tcf_unbind_filter(tp, &f->res);
net/sched/cls_matchall.c+0−1
@@ -114,7 +114,6 @@ static bool mall_destroy(struct tcf_proto *tp, bool force) · 113 unmodified lines
114114
115115 call_rcu(&f->rcu, mall_destroy_filter);
116116 }
117− RCU_INIT_POINTER(tp->root, NULL);
118117 kfree_rcu(head, rcu);
119118 return true;
120119 }
net/sched/cls_rsvp.h+2−1
@@ -152,7 +152,8 @@ static int rsvp_classify(struct sk_buff *skb, const struct tcf_proto *tp, · 151 unmodified lines
152152 return -1;
153153 nhptr = ip_hdr(skb);
154154 #endif
155−
155+ if (unlikely(!head))
156+ return -1;
156157 restart:
157158
158159 #if RSVP_DST_LEN == 4
net/sched/cls_tcindex.c+0−1
@@ -543,7 +543,6 @@ static bool tcindex_destroy(struct tcf_proto *tp, bool force) · 542 unmodified lines
543543 walker.fn = tcindex_destroy_element;
544544 tcindex_walk(tp, &walker);
545545
546− RCU_INIT_POINTER(tp->root, NULL);
547546 call_rcu(&p->rcu, __tcindex_destroy);
548547 return true;
549548 }
net/tipc/bearer.c+9−2
@@ -421,6 +421,10 @@ int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b, · 420 unmodified lines
421421 dev = dev_get_by_name(net, driver_name);
422422 if (!dev)
423423 return -ENODEV;
424+ if (tipc_mtu_bad(dev, 0)) {
425+ dev_put(dev);
426+ return -EINVAL;
427+ }
424428
425429 /* Associate TIPC bearer with L2 bearer */
426430 rcu_assign_pointer(b->media_ptr, dev);
@@ -610,8 +614,6 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, · 183 unmodified lines
610614 if (!b)
611615 return NOTIFY_DONE;
612616
613− b->mtu = dev->mtu;
614−
615617 switch (evt) {
616618 case NETDEV_CHANGE:
617619 if (netif_carrier_ok(dev))
@@ -624,6 +626,11 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, · 6 unmodified lines
624626 tipc_reset_bearer(net, b);
625627 break;
626628 case NETDEV_CHANGEMTU:
629+ if (tipc_mtu_bad(dev, 0)) {
630+ bearer_disable(net, b);
631+ break;
632+ }
633+ b->mtu = dev->mtu;
627634 tipc_reset_bearer(net, b);
628635 break;
629636 case NETDEV_CHANGEADDR:
net/tipc/bearer.h+13−0
@@ -39,6 +39,7 @@ · 38 unmodified lines
3939
4040 #include "netlink.h"
4141 #include "core.h"
42+#include "msg.h"
4243 #include <net/genetlink.h>
4344
4445 #define MAX_MEDIA 3
@@ -59,6 +60,9 @@ · 14 unmodified lines
5960 #define TIPC_MEDIA_TYPE_IB 2
6061 #define TIPC_MEDIA_TYPE_UDP 3
6162
63+/* minimum bearer MTU */
64+#define TIPC_MIN_BEARER_MTU (MAX_H_SIZE + INT_H_SIZE)
65+
6266 /**
6367 * struct tipc_media_addr - destination address used by TIPC bearers
6468 * @value: address info (format defined by media)
@@ -215,4 +219,13 @@ void tipc_bearer_xmit(struct net *net, u32 bearer_id, · 150 unmodified lines
215219 void tipc_bearer_bc_xmit(struct net *net, u32 bearer_id,
216220 struct sk_buff_head *xmitq);
217221
222+/* check if device MTU is too low for tipc headers */
223+static inline bool tipc_mtu_bad(struct net_device *dev, unsigned int reserve)
224+{
225+ if (dev->mtu >= TIPC_MIN_BEARER_MTU + reserve)
226+ return false;
227+ netdev_warn(dev, "MTU too low for tipc bearer\n");
228+ return true;
229+}
230+
218231 #endif /* _TIPC_BEARER_H */
net/tipc/link.c+19−16
@@ -47,8 +47,8 @@ · 46 unmodified lines
4747 #include <linux/pkt_sched.h>
4848
4949 struct tipc_stats {
50− u32 sent_info; /* used in counting # sent packets */
51− u32 recv_info; /* used in counting # recv'd packets */
50+ u32 sent_pkts;
51+ u32 recv_pkts;
5252 u32 sent_states;
5353 u32 recv_states;
5454 u32 sent_probes;
@@ -857,7 +857,6 @@ void tipc_link_reset(struct tipc_link *l) · 802 unmodified lines
857857 l->acked = 0;
858858 l->silent_intv_cnt = 0;
859859 l->rst_cnt = 0;
860− l->stats.recv_info = 0;
861860 l->stale_count = 0;
862861 l->bc_peer_is_up = false;
863862 memset(&l->mon_state, 0, sizeof(l->mon_state));
@@ -888,6 +887,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list, · 24 unmodified lines
888887 struct sk_buff_head *transmq = &l->transmq;
889888 struct sk_buff_head *backlogq = &l->backlogq;
890889 struct sk_buff *skb, *_skb, *bskb;
890+ int pkt_cnt = skb_queue_len(list);
891891
892892 /* Match msg importance against this and all higher backlog limits: */
893893 if (!skb_queue_empty(backlogq)) {
@@ -901,6 +901,11 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list, · 7 unmodified lines
901901 return -EMSGSIZE;
902902 }
903903
904+ if (pkt_cnt > 1) {
905+ l->stats.sent_fragmented++;
906+ l->stats.sent_fragments += pkt_cnt;
907+ }
908+
904909 /* Prepare each packet for sending, and add to relevant queue: */
905910 while (skb_queue_len(list)) {
906911 skb = skb_peek(list);
@@ -920,6 +925,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list, · 13 unmodified lines
920925 __skb_queue_tail(xmitq, _skb);
921926 TIPC_SKB_CB(skb)->ackers = l->ackers;
922927 l->rcv_unacked = 0;
928+ l->stats.sent_pkts++;
923929 seqno++;
924930 continue;
925931 }
@@ -968,6 +974,7 @@ void tipc_link_advance_backlog(struct tipc_link *l, struct sk_buff_head *xmitq) · 42 unmodified lines
968974 msg_set_ack(hdr, ack);
969975 msg_set_bcast_ack(hdr, bc_ack);
970976 l->rcv_unacked = 0;
977+ l->stats.sent_pkts++;
971978 seqno++;
972979 }
973980 l->snd_nxt = seqno;
@@ -1260,7 +1267,7 @@ int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb, · 286 unmodified lines
12601267
12611268 /* Deliver packet */
12621269 l->rcv_nxt++;
1263− l->stats.recv_info++;
1270+ l->stats.recv_pkts++;
12641271 if (!tipc_data_input(l, skb, l->inputq))
12651272 rc |= tipc_link_input(l, skb, l->inputq);
12661273 if (unlikely(++l->rcv_unacked >= TIPC_MIN_LINK_WIN))
@@ -1800,10 +1807,6 @@ void tipc_link_set_queue_limits(struct tipc_link *l, u32 win) · 533 unmodified lines
18001807 void tipc_link_reset_stats(struct tipc_link *l)
18011808 {
18021809 memset(&l->stats, 0, sizeof(l->stats));
1803− if (!link_is_bc_sndlink(l)) {
1804− l->stats.sent_info = l->snd_nxt;
1805− l->stats.recv_info = l->rcv_nxt;
1806− }
18071810 }
18081811
18091812 static void link_print(struct tipc_link *l, const char *str)
@@ -1867,12 +1870,12 @@ static int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s) · 57 unmodified lines
18671870 };
18681871
18691872 struct nla_map map[] = {
1870− {TIPC_NLA_STATS_RX_INFO, s->recv_info},
1873+ {TIPC_NLA_STATS_RX_INFO, 0},
18711874 {TIPC_NLA_STATS_RX_FRAGMENTS, s->recv_fragments},
18721875 {TIPC_NLA_STATS_RX_FRAGMENTED, s->recv_fragmented},
18731876 {TIPC_NLA_STATS_RX_BUNDLES, s->recv_bundles},
18741877 {TIPC_NLA_STATS_RX_BUNDLED, s->recv_bundled},
1875− {TIPC_NLA_STATS_TX_INFO, s->sent_info},
1878+ {TIPC_NLA_STATS_TX_INFO, 0},
18761879 {TIPC_NLA_STATS_TX_FRAGMENTS, s->sent_fragments},
18771880 {TIPC_NLA_STATS_TX_FRAGMENTED, s->sent_fragmented},
18781881 {TIPC_NLA_STATS_TX_BUNDLES, s->sent_bundles},
@@ -1947,9 +1950,9 @@ int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg, · 68 unmodified lines
19471950 goto attr_msg_full;
19481951 if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu))
19491952 goto attr_msg_full;
1950− if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->rcv_nxt))
1953+ if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->stats.recv_pkts))
19511954 goto attr_msg_full;
1952− if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, link->snd_nxt))
1955+ if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, link->stats.sent_pkts))
19531956 goto attr_msg_full;
19541957
19551958 if (tipc_link_is_up(link))
@@ -2004,12 +2007,12 @@ static int __tipc_nl_add_bc_link_stat(struct sk_buff *skb, · 48 unmodified lines
20042007 };
20052008
20062009 struct nla_map map[] = {
2007− {TIPC_NLA_STATS_RX_INFO, stats->recv_info},
2010+ {TIPC_NLA_STATS_RX_INFO, stats->recv_pkts},
20082011 {TIPC_NLA_STATS_RX_FRAGMENTS, stats->recv_fragments},
20092012 {TIPC_NLA_STATS_RX_FRAGMENTED, stats->recv_fragmented},
20102013 {TIPC_NLA_STATS_RX_BUNDLES, stats->recv_bundles},
20112014 {TIPC_NLA_STATS_RX_BUNDLED, stats->recv_bundled},
2012− {TIPC_NLA_STATS_TX_INFO, stats->sent_info},
2015+ {TIPC_NLA_STATS_TX_INFO, stats->sent_pkts},
20132016 {TIPC_NLA_STATS_TX_FRAGMENTS, stats->sent_fragments},
20142017 {TIPC_NLA_STATS_TX_FRAGMENTED, stats->sent_fragmented},
20152018 {TIPC_NLA_STATS_TX_BUNDLES, stats->sent_bundles},
@@ -2076,9 +2079,9 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg) · 60 unmodified lines
20762079 goto attr_msg_full;
20772080 if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name))
20782081 goto attr_msg_full;
2079− if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, bcl->rcv_nxt))
2082+ if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, 0))
20802083 goto attr_msg_full;
2081− if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, bcl->snd_nxt))
2084+ if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, 0))
20822085 goto attr_msg_full;
20832086
20842087 prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP);
net/tipc/udp_media.c+5−0
@@ -697,6 +697,11 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, · 696 unmodified lines
697697 udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
698698 udp_conf.use_udp_checksums = false;
699699 ub->ifindex = dev->ifindex;
700+ if (tipc_mtu_bad(dev, sizeof(struct iphdr) +
701+ sizeof(struct udphdr))) {
702+ err = -EINVAL;
703+ goto err;
704+ }
700705 b->mtu = dev->mtu - sizeof(struct iphdr)
701706 - sizeof(struct udphdr);
702707 #if IS_ENABLED(CONFIG_IPV6)
net/xfrm/xfrm_policy.c+6−4
@@ -1268,12 +1268,14 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir, · 1267 unmodified lines
12681268 err = security_xfrm_policy_lookup(pol->security,
12691269 fl->flowi_secid,
12701270 policy_to_flow_dir(dir));
1271− if (!err && !xfrm_pol_hold_rcu(pol))
1272− goto again;
1273− else if (err == -ESRCH)
1271+ if (!err) {
1272+ if (!xfrm_pol_hold_rcu(pol))
1273+ goto again;
1274+ } else if (err == -ESRCH) {
12741275 pol = NULL;
1275− else
1276+ } else {
12761277 pol = ERR_PTR(err);
1278+ }
12771279 } else
12781280 pol = NULL;
12791281 }
net/xfrm/xfrm_user.c+1−1
@@ -2450,7 +2450,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · 2449 unmodified lines
24502450
24512451 #ifdef CONFIG_COMPAT
24522452 if (in_compat_syscall())
2453− return -ENOTSUPP;
2453+ return -EOPNOTSUPP;
24542454 #endif
24552455
24562456 type = nlh->nlmsg_type;
samples/bpf/bpf_helpers.h+1−1
@@ -113,7 +113,7 @@ static int (*bpf_skb_under_cgroup)(void *ctx, void *map, int index) = · 112 unmodified lines
113113 #define PT_REGS_FP(x) ((x)->gprs[11]) /* Works only with CONFIG_FRAME_POINTER */
114114 #define PT_REGS_RC(x) ((x)->gprs[2])
115115 #define PT_REGS_SP(x) ((x)->gprs[15])
116−#define PT_REGS_IP(x) ((x)->ip)
116+#define PT_REGS_IP(x) ((x)->psw.addr)
117117
118118 #elif defined(__aarch64__)
119119
samples/bpf/sampleip_kern.c+1−1
@@ -25,7 +25,7 @@ int do_sample(struct bpf_perf_event_data *ctx) · 24 unmodified lines
2525 u64 ip;
2626 u32 *value, init_val = 1;
2727
28− ip = ctx->regs.ip;
28+ ip = PT_REGS_IP(&ctx->regs);
2929 value = bpf_map_lookup_elem(&ip_map, &ip);
3030 if (value)
3131 *value += 1;
samples/bpf/trace_event_kern.c+1−1
@@ -50,7 +50,7 @@ int bpf_prog1(struct bpf_perf_event_data *ctx) · 49 unmodified lines
5050 key.userstack = bpf_get_stackid(ctx, &stackmap, USER_STACKID_FLAGS);
5151 if ((int)key.kernstack < 0 && (int)key.userstack < 0) {
5252 bpf_trace_printk(fmt, sizeof(fmt), cpu, ctx->sample_period,
53− ctx->regs.ip);
53+ PT_REGS_IP(&ctx->regs));
5454 return 0;
5555 }
5656
scripts/kconfig/Makefile+2−0
@@ -35,6 +35,8 @@ nconfig: $(obj)/nconf · 34 unmodified lines
3535
3636 silentoldconfig: $(obj)/conf
3737 $(Q)mkdir -p include/config include/generated
38+ $(Q)test -e include/generated/autoksyms.h || \
39+ touch include/generated/autoksyms.h
3840 $< $(silent) --$@ $(Kconfig)
3941
4042 localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
sound/sparc/dbri.c+16−10
@@ -304,7 +304,7 @@ struct snd_dbri { · 303 unmodified lines
304304 spinlock_t lock;
305305
306306 struct dbri_dma *dma; /* Pointer to our DMA block */
307− u32 dma_dvma; /* DBRI visible DMA address */
307+ dma_addr_t dma_dvma; /* DBRI visible DMA address */
308308
309309 void __iomem *regs; /* dbri HW regs */
310310 int dbri_irqp; /* intr queue pointer */
@@ -657,12 +657,14 @@ static void dbri_cmdwait(struct snd_dbri *dbri) · 346 unmodified lines
657657 */
658658 static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len)
659659 {
660+ u32 dvma_addr = (u32)dbri->dma_dvma;
661+
660662 /* Space for 2 WAIT cmds (replaced later by 1 JUMP cmd) */
661663 len += 2;
662664 spin_lock(&dbri->cmdlock);
663665 if (dbri->cmdptr - dbri->dma->cmd + len < DBRI_NO_CMDS - 2)
664666 return dbri->cmdptr + 2;
665− else if (len < sbus_readl(dbri->regs + REG8) - dbri->dma_dvma)
667+ else if (len < sbus_readl(dbri->regs + REG8) - dvma_addr)
666668 return dbri->dma->cmd;
667669 else
668670 printk(KERN_ERR "DBRI: no space for commands.");
@@ -680,6 +682,7 @@ static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len) · 11 unmodified lines
680682 */
681683 static void dbri_cmdsend(struct snd_dbri *dbri, s32 *cmd, int len)
682684 {
685+ u32 dvma_addr = (u32)dbri->dma_dvma;
683686 s32 tmp, addr;
684687 static int wait_id = 0;
685688
@@ -689,7 +692,7 @@ static void dbri_cmdsend(struct snd_dbri *dbri, s32 *cmd, int len) · 3 unmodified lines
689692 *(cmd+1) = DBRI_CMD(D_WAIT, 1, wait_id);
690693
691694 /* Replace the last command with JUMP */
692− addr = dbri->dma_dvma + (cmd - len - dbri->dma->cmd) * sizeof(s32);
695+ addr = dvma_addr + (cmd - len - dbri->dma->cmd) * sizeof(s32);
693696 *(dbri->cmdptr+1) = addr;
694697 *(dbri->cmdptr) = DBRI_CMD(D_JUMP, 0, 0);
695698
@@ -747,6 +750,7 @@ static void dbri_reset(struct snd_dbri *dbri) · 51 unmodified lines
747750 /* Lock must not be held before calling this */
748751 static void dbri_initialize(struct snd_dbri *dbri)
749752 {
753+ u32 dvma_addr = (u32)dbri->dma_dvma;
750754 s32 *cmd;
751755 u32 dma_addr;
752756 unsigned long flags;
@@ -764,7 +768,7 @@ static void dbri_initialize(struct snd_dbri *dbri) · 11 unmodified lines
764768 /*
765769 * Initialize the interrupt ring buffer.
766770 */
767− dma_addr = dbri->dma_dvma + dbri_dma_off(intr, 0);
771+ dma_addr = dvma_addr + dbri_dma_off(intr, 0);
768772 dbri->dma->intr[0] = dma_addr;
769773 dbri->dbri_irqp = 1;
770774 /*
@@ -778,7 +782,7 @@ static void dbri_initialize(struct snd_dbri *dbri) · 7 unmodified lines
778782 dbri->cmdptr = cmd;
779783 *(cmd++) = DBRI_CMD(D_WAIT, 1, 0);
780784 *(cmd++) = DBRI_CMD(D_WAIT, 1, 0);
781− dma_addr = dbri->dma_dvma + dbri_dma_off(cmd, 0);
785+ dma_addr = dvma_addr + dbri_dma_off(cmd, 0);
782786 sbus_writel(dma_addr, dbri->regs + REG8);
783787 spin_unlock(&dbri->cmdlock);
784788
@@ -1077,6 +1081,7 @@ static void recv_fixed(struct snd_dbri *dbri, int pipe, volatile __u32 *ptr) · 292 unmodified lines
10771081 static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period)
10781082 {
10791083 struct dbri_streaminfo *info = &dbri->stream_info[streamno];
1084+ u32 dvma_addr = (u32)dbri->dma_dvma;
10801085 __u32 dvma_buffer;
10811086 int desc;
10821087 int len;
@@ -1177,7 +1182,7 @@ static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period) · 94 unmodified lines
11771182 else {
11781183 dbri->next_desc[last_desc] = desc;
11791184 dbri->dma->desc[last_desc].nda =
1180− dbri->dma_dvma + dbri_dma_off(desc, desc);
1185+ dvma_addr + dbri_dma_off(desc, desc);
11811186 }
11821187
11831188 last_desc = desc;
@@ -1192,7 +1197,7 @@ static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period) · 8 unmodified lines
11921197 }
11931198
11941199 dbri->dma->desc[last_desc].nda =
1195− dbri->dma_dvma + dbri_dma_off(desc, first_desc);
1200+ dvma_addr + dbri_dma_off(desc, first_desc);
11961201 dbri->next_desc[last_desc] = first_desc;
11971202 dbri->pipes[info->pipe].first_desc = first_desc;
11981203 dbri->pipes[info->pipe].desc = first_desc;
@@ -1697,6 +1702,7 @@ interrupts are disabled. · 498 unmodified lines
16971702 static void xmit_descs(struct snd_dbri *dbri)
16981703 {
16991704 struct dbri_streaminfo *info;
1705+ u32 dvma_addr = (u32)dbri->dma_dvma;
17001706 s32 *cmd;
17011707 unsigned long flags;
17021708 int first_td;
@@ -1718,7 +1724,7 @@ static void xmit_descs(struct snd_dbri *dbri) · 15 unmodified lines
17181724 *(cmd++) = DBRI_CMD(D_SDP, 0,
17191725 dbri->pipes[info->pipe].sdp
17201726 | D_SDP_P | D_SDP_EVERY | D_SDP_C);
1721− *(cmd++) = dbri->dma_dvma +
1727+ *(cmd++) = dvma_addr +
17221728 dbri_dma_off(desc, first_td);
17231729 dbri_cmdsend(dbri, cmd, 2);
17241730
@@ -1740,7 +1746,7 @@ static void xmit_descs(struct snd_dbri *dbri) · 15 unmodified lines
17401746 *(cmd++) = DBRI_CMD(D_SDP, 0,
17411747 dbri->pipes[info->pipe].sdp
17421748 | D_SDP_P | D_SDP_EVERY | D_SDP_C);
1743− *(cmd++) = dbri->dma_dvma +
1749+ *(cmd++) = dvma_addr +
17441750 dbri_dma_off(desc, first_td);
17451751 dbri_cmdsend(dbri, cmd, 2);
17461752
@@ -2539,7 +2545,7 @@ static int snd_dbri_create(struct snd_card *card, · 792 unmodified lines
25392545 if (!dbri->dma)
25402546 return -ENOMEM;
25412547
2542− dprintk(D_GEN, "DMA Cmd Block 0x%p (0x%08x)\n",
2548+ dprintk(D_GEN, "DMA Cmd Block 0x%p (%pad)\n",
25432549 dbri->dma, dbri->dma_dvma);
25442550
25452551 /* Map the registers into memory. */
virt/kvm/arm/vgic/vgic-v2.c+4−2
@@ -50,8 +50,10 @@ void vgic_v2_process_maintenance(struct kvm_vcpu *vcpu) · 49 unmodified lines
5050
5151 WARN_ON(cpuif->vgic_lr[lr] & GICH_LR_STATE);
5252
53− kvm_notify_acked_irq(vcpu->kvm, 0,
54− intid - VGIC_NR_PRIVATE_IRQS);
53+ /* Only SPIs require notification */
54+ if (vgic_valid_spi(vcpu->kvm, intid))
55+ kvm_notify_acked_irq(vcpu->kvm, 0,
56+ intid - VGIC_NR_PRIVATE_IRQS);
5557 }
5658 }
5759
virt/kvm/arm/vgic/vgic-v3.c+4−2
@@ -41,8 +41,10 @@ void vgic_v3_process_maintenance(struct kvm_vcpu *vcpu) · 40 unmodified lines
4141
4242 WARN_ON(cpuif->vgic_lr[lr] & ICH_LR_STATE);
4343
44− kvm_notify_acked_irq(vcpu->kvm, 0,
45− intid - VGIC_NR_PRIVATE_IRQS);
44+ /* Only SPIs require notification */
45+ if (vgic_valid_spi(vcpu->kvm, intid))
46+ kvm_notify_acked_irq(vcpu->kvm, 0,
47+ intid - VGIC_NR_PRIVATE_IRQS);
4648 }
4749
4850 /*
virt/kvm/kvm_main.c+1−1
@@ -2889,10 +2889,10 @@ static int kvm_ioctl_create_device(struct kvm *kvm, · 2888 unmodified lines
28892889
28902890 ret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC);
28912891 if (ret < 0) {
2892− ops->destroy(dev);
28932892 mutex_lock(&kvm->lock);
28942893 list_del(&dev->vm_node);
28952894 mutex_unlock(&kvm->lock);
2895+ ops->destroy(dev);
28962896 return ret;
28972897 }
28982898

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t