History

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

Cross-merge networking fixes after downstream PR. No conflicts.

Jakub Kicinski committed 2 years ago

Commit 975f2d72 parents f9893fd 6172a51257 files · +2737 −3711Browse files

Unified · Split

257 files
  1. Documentation/ABI/testing/sysfs-class-led +0 −9
  2. Documentation/devicetree/bindings/pinctrl/nxp,s32g2-siul2-pinctrl.yaml +1 −1
  3. Documentation/devicetree/bindings/usb/microchip,usb5744.yaml +6 −1
  4. Documentation/devicetree/bindings/usb/qcom,dwc3.yaml +2 −2
  5. Documentation/devicetree/bindings/usb/usb-hcd.yaml +1 −1
  6. MAINTAINERS +1 −0
  7. Makefile +1 −1
  8. arch/arm/xen/enlighten.c +2 −1
  9. arch/arm64/Makefile +1 −1
  10. arch/arm64/include/asm/setup.h +15 −2
  11. arch/arm64/mm/pageattr.c +3 −4
  12. arch/parisc/Kconfig +5 −2
  13. arch/parisc/include/asm/alternative.h +6 −3
  14. arch/parisc/include/asm/assembly.h +1 −0
  15. arch/parisc/include/asm/bug.h +22 −16
  16. arch/parisc/include/asm/jump_label.h +6 −2
  17. arch/parisc/include/asm/ldcw.h +1 −1
  18. arch/parisc/include/asm/uaccess.h +1 −0
  19. arch/parisc/include/uapi/asm/errno.h +0 −2
  20. arch/parisc/kernel/vmlinux.lds.S +1 −0
  21. arch/s390/include/asm/processor.h +0 −1
  22. arch/s390/kernel/ipl.c +1 −0
  23. arch/s390/kernel/perf_pai_crypto.c +5 −6
  24. arch/s390/kernel/perf_pai_ext.c +0 −1
  25. arch/x86/events/intel/core.c +1 −1
  26. arch/x86/kernel/cpu/microcode/amd.c +11 −28
  27. arch/x86/kernel/cpu/microcode/core.c +9 −6
  28. arch/x86/kernel/cpu/microcode/intel.c +7 −10
  29. arch/x86/kernel/cpu/microcode/internal.h +10 −4
  30. block/bdev.c +2 −0
  31. block/blk-cgroup.c +13 −0
  32. block/blk-cgroup.h +0 −2
  33. block/blk-pm.c +5 −28
  34. block/blk-throttle.c +2 −0
  35. drivers/accel/ivpu/ivpu_hw_37xx.c +22 −24
  36. drivers/acpi/acpi_video.c +1 −1
  37. drivers/acpi/device_pm.c +13 −0
  38. drivers/acpi/processor_idle.c +1 −1
  39. drivers/acpi/resource.c +7 −0
  40. drivers/ata/pata_isapnp.c +3 −0
  41. drivers/block/nbd.c +75 −42
  42. drivers/block/null_blk/main.c +13 −12
  43. drivers/firmware/efi/unaccepted_memory.c +1 −1
  44. drivers/gpu/drm/ast/ast_drv.h +12 −1
  45. drivers/gpu/drm/ast/ast_mode.c +55 −7
  46. drivers/gpu/drm/i915/display/intel_dp_mst.c +8 −8
  47. drivers/gpu/drm/i915/gt/intel_gt.c +0 −11
  48. drivers/gpu/drm/i915/i915_driver.c +1 −3
  49. drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_8_0_sc8280xp.h +1 −0
  50. drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +1 −2
  51. drivers/gpu/drm/msm/dp/dp_display.c +10 −5
  52. drivers/gpu/drm/msm/dp/dp_drm.c +3 −0
  53. drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +1 −1
  54. drivers/gpu/drm/msm/msm_drv.c +0 −2
  55. drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +1 −1
  56. drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c +5 −4
  57. drivers/gpu/drm/panel/panel-simple.c +7 −6
  58. drivers/gpu/drm/rockchip/rockchip_drm_vop.c +11 −3
  59. drivers/hid/hid-apple.c +2 −0
  60. drivers/hid/hid-asus.c +23 −4
  61. drivers/hid/hid-core.c +10 −2
  62. drivers/hid/hid-debug.c +3 −0
  63. drivers/hid/hid-glorious.c +14 −2
  64. drivers/hid/hid-ids.h +7 −5
  65. drivers/hid/hid-logitech-dj.c +3 −8
  66. drivers/hid/hid-mcp2221.c +3 −1
  67. drivers/hid/hid-multitouch.c +5 −0
  68. drivers/hid/hid-quirks.c +1 −0
  69. drivers/leds/led-class.c +0 −14
  70. drivers/md/bcache/bcache.h +1 −0
  71. drivers/md/bcache/btree.c +10 −1
  72. drivers/md/bcache/super.c +3 −1
  73. drivers/md/bcache/sysfs.c +1 −1
  74. drivers/md/bcache/writeback.c +18 −6
  75. drivers/md/md.c +2 −1
  76. drivers/media/pci/mgb4/Kconfig +1 −0
  77. drivers/media/pci/mgb4/mgb4_core.c +15 −5
  78. drivers/media/platform/renesas/vsp1/vsp1_pipe.c +1 −1
  79. drivers/media/platform/renesas/vsp1/vsp1_rpf.c +1 −9
  80. drivers/media/platform/renesas/vsp1/vsp1_rwpf.c +6 −2
  81. drivers/media/platform/renesas/vsp1/vsp1_rwpf.h +3 −1
  82. drivers/media/platform/renesas/vsp1/vsp1_wpf.c +3 −26
  83. drivers/mmc/core/block.c +2 −0
  84. drivers/mmc/core/core.c +7 −2
  85. drivers/mmc/host/cqhci-core.c +22 −22
  86. drivers/mmc/host/sdhci-pci-gli.c +29 −25
  87. drivers/mmc/host/sdhci-sprd.c +25 −0
  88. drivers/net/dsa/mv88e6xxx/chip.c +20 −6
  89. drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +10 −6
  90. drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +1 −1
  91. drivers/net/ethernet/intel/ice/ice_lag.c +72 −50
  92. drivers/net/ethernet/intel/ice/ice_lag.h +1 −0
  93. drivers/net/ethernet/intel/ice/ice_vf_lib.c +20 −0
  94. drivers/net/ethernet/intel/ice/ice_virtchnl.c +25 −0
  95. drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +2 −2
  96. drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c +3 −0
  97. drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +2 −0
  98. drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +7 −2
  99. drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +95 −25
  100. drivers/net/ethernet/realtek/r8169_main.c +7 −2
  101. drivers/net/ethernet/renesas/ravb_main.c +45 −24
  102. drivers/net/ethernet/renesas/rswitch.c +13 −9
  103. drivers/net/ethernet/stmicro/stmmac/mmc_core.c +4 −0
  104. drivers/net/ethernet/wangxun/libwx/wx_lib.c +1 −1
  105. drivers/net/netdevsim/bpf.c +2 −2
  106. drivers/net/netkit.c +6 −0
  107. drivers/net/wireless/ath/ath9k/Kconfig +1 −3
  108. drivers/net/wireless/intel/iwlwifi/mvm/mld-sta.c +3 −1
  109. drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +1 −0
  110. drivers/net/wireless/mediatek/mt76/mt7925/main.c +2 −2
  111. drivers/nvme/host/auth.c +3 −2
  112. drivers/nvme/host/core.c +14 −7
  113. drivers/nvme/host/fabrics.c +2 −0
  114. drivers/nvme/host/fc.c +8 −11
  115. drivers/nvme/host/rdma.c +1 −0
  116. drivers/nvme/host/tcp.c +15 −17
  117. drivers/nvme/target/Kconfig +2 −2
  118. drivers/nvme/target/configfs.c +1 −1
  119. drivers/nvme/target/fabrics-cmd.c +4 −0
  120. drivers/nvme/target/tcp.c +3 −1
  121. drivers/phy/Kconfig +0 −1
  122. drivers/phy/Makefile +0 −1
  123. drivers/phy/realtek/Kconfig +0 −32
  124. drivers/phy/realtek/Makefile +0 −3
  125. drivers/phy/realtek/phy-rtk-usb2.c +0 −1325
  126. drivers/phy/realtek/phy-rtk-usb3.c +0 −761
  127. drivers/pinctrl/cirrus/Kconfig +2 −1
  128. drivers/pinctrl/core.c +3 −3
  129. drivers/pinctrl/nxp/pinctrl-s32cc.c +2 −2
  130. drivers/pinctrl/pinctrl-cy8c95x0.c +1 −0
  131. drivers/pinctrl/realtek/pinctrl-rtd.c +2 −2
  132. drivers/pinctrl/stm32/pinctrl-stm32.c +10 −3
  133. drivers/pmdomain/arm/scmi_perf_domain.c +1 −1
  134. drivers/s390/block/dasd.c +13 −11
  135. drivers/s390/block/dasd_int.h +1 −1
  136. drivers/thunderbolt/switch.c +3 −3
  137. drivers/thunderbolt/tb.c +11 −1
  138. drivers/usb/cdns3/cdnsp-ring.c +3 −0
  139. drivers/usb/core/config.c +2 −1
  140. drivers/usb/core/hub.c +0 −23
  141. drivers/usb/dwc2/hcd_intr.c +7 −8
  142. drivers/usb/dwc3/core.c +2 −0
  143. drivers/usb/dwc3/drd.c +1 −1
  144. drivers/usb/dwc3/dwc3-qcom.c +47 −22
  145. drivers/usb/dwc3/dwc3-rtk.c +7 −1
  146. drivers/usb/host/xhci-mtk-sch.c +10 −3
  147. drivers/usb/host/xhci-mtk.h +2 −0
  148. drivers/usb/host/xhci-plat.c +30 −20
  149. drivers/usb/misc/onboard_usb_hub.c +2 −0
  150. drivers/usb/misc/onboard_usb_hub.h +7 −0
  151. drivers/usb/misc/usb-ljca.c +4 −13
  152. drivers/usb/serial/option.c +8 −3
  153. drivers/usb/typec/tcpm/tcpm.c +11 −1
  154. drivers/usb/typec/tipd/core.c +9 −5
  155. drivers/xen/privcmd.c +1 −1
  156. drivers/xen/swiotlb-xen.c +1 −0
  157. fs/afs/dynroot.c +2 −2
  158. fs/afs/internal.h +1 −0
  159. fs/afs/server_list.c +1 −1
  160. fs/afs/super.c +4 −0
  161. fs/afs/vl_rotate.c +10 −0
  162. fs/autofs/inode.c +21 −35
  163. fs/btrfs/disk-io.c +1 −0
  164. fs/btrfs/extent_io.c +8 −3
  165. fs/btrfs/ioctl.c +1 −0
  166. fs/btrfs/ref-verify.c +2 −0
  167. fs/btrfs/send.c +1 −1
  168. fs/btrfs/super.c +4 −1
  169. fs/btrfs/transaction.c +1 −1
  170. fs/btrfs/tree-checker.c +39 −0
  171. fs/btrfs/volumes.c +5 −4
  172. fs/debugfs/file.c +100 −0
  173. fs/debugfs/inode.c +63 −8
  174. fs/debugfs/internal.h +19 −2
  175. fs/ecryptfs/inode.c +10 −2
  176. fs/inode.c +2 −0
  177. fs/libfs.c +11 −3
  178. fs/overlayfs/inode.c +5 −5
  179. fs/overlayfs/overlayfs.h +8 −0
  180. fs/smb/client/cifsglob.h +11 −3
  181. fs/smb/client/cifspdu.h +2 −2
  182. fs/smb/client/cifsproto.h +13 −1
  183. fs/smb/client/cifssmb.c +77 −116
  184. fs/smb/client/inode.c +60 −14
  185. fs/smb/client/readdir.c +5 −1
  186. fs/smb/client/sess.c +1 −1
  187. fs/smb/client/smb1ops.c +32 −121
  188. fs/smb/client/smb2inode.c +1 −1
  189. fs/smb/client/smb2ops.c +112 −115
  190. fs/smb/server/ksmbd_work.c +8 −2
  191. fs/smb/server/oplock.c +2 −1
  192. fs/smb/server/smb2pdu.c +82 −80
  193. fs/smb/server/smbacl.c +4 −3
  194. fs/smb/server/smbacl.h +1 −1
  195. fs/smb/server/vfs.c +42 −28
  196. fs/smb/server/vfs.h +7 −3
  197. fs/smb/server/vfs_cache.c +13 −20
  198. fs/smb/server/vfs_cache.h +3 −3
  199. fs/stat.c +5 −1
  200. fs/tracefs/event_inode.c +26 −39
  201. fs/tracefs/inode.c +4 −9
  202. fs/xfs/xfs_dquot.c +3 −2
  203. fs/xfs/xfs_dquot_item_recover.c +18 −3
  204. fs/xfs/xfs_inode.h +8 −0
  205. fs/xfs/xfs_ioctl.c +20 −10
  206. fs/xfs/xfs_iops.c +7 −0
  207. include/acpi/acpi_bus.h +1 −0
  208. include/linux/blk-pm.h +0 −1
  209. include/linux/debugfs.h +19 −0
  210. include/linux/hid.h +3 −0
  211. include/linux/ieee80211.h +3 −1
  212. include/linux/pagemap.h +17 −0
  213. include/linux/skmsg.h +1 −0
  214. include/linux/usb/phy.h +0 −13
  215. include/net/af_unix.h +1 −0
  216. include/net/cfg80211.h +46 −0
  217. include/net/neighbour.h +1 −1
  218. include/uapi/linux/fcntl.h +3 −0
  219. include/uapi/linux/v4l2-subdev.h +1 −1
  220. io_uring/fs.c +1 −1
  221. io_uring/rsrc.c +1 −1
  222. kernel/bpf/memalloc.c +2 −0
  223. kernel/locking/lockdep.c +2 −1
  224. lib/errname.c +0 −6
  225. lib/iov_iter.c +1 −1
  226. mm/page-writeback.c +1 −1
  227. net/core/skmsg.c +2 −0
  228. net/ethtool/netlink.c +1 −0
  229. net/ipv4/igmp.c +4 −2
  230. net/mac80211/Kconfig +1 −1
  231. net/mac80211/debugfs_netdev.c +105 −45
  232. net/mac80211/debugfs_sta.c +42 −32
  233. net/mac80211/driver-ops.h +7 −2
  234. net/mac80211/ht.c +1 −0
  235. net/mptcp/options.c +1 −0
  236. net/unix/af_unix.c +0 −2
  237. net/unix/unix_bpf.c +5 −0
  238. net/wireless/core.c +4 −2
  239. net/wireless/core.h +1 −0
  240. net/wireless/debugfs.c +160 −0
  241. net/wireless/nl80211.c +36 −19
  242. scripts/checkstack.pl +1 −2
  243. tools/arch/parisc/include/uapi/asm/errno.h +0 −2
  244. tools/net/ynl/generated/devlink-user.c +58 −29
  245. tools/net/ynl/generated/ethtool-user.c +34 −17
  246. tools/net/ynl/generated/fou-user.c +4 −2
  247. tools/net/ynl/generated/handshake-user.c +2 −1
  248. tools/net/ynl/ynl-gen-c.py +4 −6
  249. tools/power/pm-graph/sleepgraph.py +1 −1
  250. tools/testing/selftests/arm64/fp/za-fork.c +1 −1
  251. tools/testing/selftests/bpf/prog_tests/sockmap_listen.c +40 −11
  252. tools/testing/selftests/bpf/progs/test_sockmap_listen.c +7 −0
  253. tools/testing/selftests/net/af_unix/diag_uid.c +0 −1
  254. tools/testing/selftests/net/cmsg_sender.c +1 −1
  255. tools/testing/selftests/net/ipsec.c +2 −2
  256. tools/testing/selftests/net/mptcp/mptcp_connect.c +4 −7
  257. tools/testing/selftests/net/mptcp/mptcp_inq.c +4 −7
Documentation/ABI/testing/sysfs-class-led+0−9
@@ -59,15 +59,6 @@ Description: · 58 unmodified lines
5959 brightness. Reading this file when no hw brightness change
6060 event has happened will return an ENODATA error.
6161
62−What: /sys/class/leds/<led>/color
63−Date: June 2023
64−KernelVersion: 6.5
65−Description:
66− Color of the LED.
67−
68− This is a read-only file. Reading this file returns the color
69− of the LED as a string (e.g: "red", "green", "multicolor").
70−
7162 What: /sys/class/leds/<led>/trigger
7263 Date: March 2006
7364 KernelVersion: 2.6.17
Documentation/devicetree/bindings/pinctrl/nxp,s32g2-siul2-pinctrl.yaml+1−1
@@ -9,7 +9,7 @@ title: NXP S32G2 pin controller · 8 unmodified lines
99
1010 maintainers:
1111 - Ghennadi Procopciuc <Ghennadi.Procopciuc@oss.nxp.com>
12− - Chester Lin <clin@suse.com>
12+ - Chester Lin <chester62515@gmail.com>
1313
1414 description: |
1515 S32G2 pinmux is implemented in SIUL2 (System Integration Unit Lite2),
Documentation/devicetree/bindings/usb/microchip,usb5744.yaml+6−1
@@ -36,7 +36,11 @@ properties: · 35 unmodified lines
3636
3737 vdd-supply:
3838 description:
39− VDD power supply to the hub
39+ 3V3 power supply to the hub
40+
41+ vdd2-supply:
42+ description:
43+ 1V2 power supply to the hub
4044
4145 peer-hub:
4246 $ref: /schemas/types.yaml#/definitions/phandle
@@ -62,6 +66,7 @@ allOf: · 19 unmodified lines
6266 properties:
6367 reset-gpios: false
6468 vdd-supply: false
69+ vdd2-supply: false
6570 peer-hub: false
6671 i2c-bus: false
6772 else:
Documentation/devicetree/bindings/usb/qcom,dwc3.yaml+2−2
@@ -521,8 +521,8 @@ examples: · 520 unmodified lines
521521
522522 interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>,
523523 <GIC_SPI 486 IRQ_TYPE_LEVEL_HIGH>,
524− <GIC_SPI 488 IRQ_TYPE_LEVEL_HIGH>,
525− <GIC_SPI 489 IRQ_TYPE_LEVEL_HIGH>;
524+ <GIC_SPI 488 IRQ_TYPE_EDGE_BOTH>,
525+ <GIC_SPI 489 IRQ_TYPE_EDGE_BOTH>;
526526 interrupt-names = "hs_phy_irq", "ss_phy_irq",
527527 "dm_hs_phy_irq", "dp_hs_phy_irq";
528528
Documentation/devicetree/bindings/usb/usb-hcd.yaml+1−1
@@ -41,7 +41,7 @@ examples: · 40 unmodified lines
4141 - |
4242 usb {
4343 phys = <&usb2_phy1>, <&usb3_phy1>;
44− phy-names = "usb";
44+ phy-names = "usb2", "usb3";
4545 #address-cells = <1>;
4646 #size-cells = <0>;
4747
MAINTAINERS+1−0
@@ -22056,6 +22056,7 @@ F: drivers/watchdog/tqmx86_wdt.c · 22055 unmodified lines
2205622056 TRACING
2205722057 M: Steven Rostedt <rostedt@goodmis.org>
2205822058 M: Masami Hiramatsu <mhiramat@kernel.org>
22059+R: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2205922060 L: linux-kernel@vger.kernel.org
2206022061 L: linux-trace-kernel@vger.kernel.org
2206122062 S: Maintained
Makefile+1−1
@@ -2,7 +2,7 @@ · 1 unmodified line
22 VERSION = 6
33 PATCHLEVEL = 7
44 SUBLEVEL = 0
5−EXTRAVERSION = -rc2
5+EXTRAVERSION = -rc3
66 NAME = Hurr durr I'ma ninja sloth
77
88 # *DOCUMENTATION*
arch/arm/xen/enlighten.c+2−1
@@ -484,7 +484,8 @@ static int __init xen_guest_init(void) · 483 unmodified lines
484484 * for secondary CPUs as they are brought up.
485485 * For uniformity we use VCPUOP_register_vcpu_info even on cpu0.
486486 */
487− xen_vcpu_info = alloc_percpu(struct vcpu_info);
487+ xen_vcpu_info = __alloc_percpu(sizeof(struct vcpu_info),
488+ 1 << fls(sizeof(struct vcpu_info) - 1));
488489 if (xen_vcpu_info == NULL)
489490 return -ENOMEM;
490491
arch/arm64/Makefile+1−1
@@ -158,7 +158,7 @@ endif · 157 unmodified lines
158158
159159 all: $(notdir $(KBUILD_IMAGE))
160160
161−
161+vmlinuz.efi: Image
162162 Image vmlinuz.efi: vmlinux
163163 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
164164
arch/arm64/include/asm/setup.h+15−2
@@ -21,9 +21,22 @@ static inline bool arch_parse_debug_rodata(char *arg) · 20 unmodified lines
2121 extern bool rodata_enabled;
2222 extern bool rodata_full;
2323
24− if (arg && !strcmp(arg, "full")) {
24+ if (!arg)
25+ return false;
26+
27+ if (!strcmp(arg, "full")) {
28+ rodata_enabled = rodata_full = true;
29+ return true;
30+ }
31+
32+ if (!strcmp(arg, "off")) {
33+ rodata_enabled = rodata_full = false;
34+ return true;
35+ }
36+
37+ if (!strcmp(arg, "on")) {
2538 rodata_enabled = true;
26− rodata_full = true;
39+ rodata_full = false;
2740 return true;
2841 }
2942
arch/arm64/mm/pageattr.c+3−4
@@ -29,8 +29,8 @@ bool can_set_direct_map(void) · 28 unmodified lines
2929 *
3030 * KFENCE pool requires page-granular mapping if initialized late.
3131 */
32− return (rodata_enabled && rodata_full) || debug_pagealloc_enabled() ||
33− arm64_kfence_can_set_direct_map();
32+ return rodata_full || debug_pagealloc_enabled() ||
33+ arm64_kfence_can_set_direct_map();
3434 }
3535
3636 static int change_page_range(pte_t *ptep, unsigned long addr, void *data)
@@ -105,8 +105,7 @@ static int change_memory_common(unsigned long addr, int numpages, · 68 unmodified lines
105105 * If we are manipulating read-only permissions, apply the same
106106 * change to the linear mapping of the pages that back this VM area.
107107 */
108− if (rodata_enabled &&
109− rodata_full && (pgprot_val(set_mask) == PTE_RDONLY ||
108+ if (rodata_full && (pgprot_val(set_mask) == PTE_RDONLY ||
110109 pgprot_val(clear_mask) == PTE_RDONLY)) {
111110 for (i = 0; i < area->nr_pages; i++) {
112111 __change_memory_common((u64)page_address(area->pages[i]),
arch/parisc/Kconfig+5−2
@@ -115,9 +115,12 @@ config ARCH_HAS_ILOG2_U64 · 114 unmodified lines
115115 default n
116116
117117 config GENERIC_BUG
118− bool
119− default y
118+ def_bool y
120119 depends on BUG
120+ select GENERIC_BUG_RELATIVE_POINTERS if 64BIT
121+
122+config GENERIC_BUG_RELATIVE_POINTERS
123+ bool
121124
122125 config GENERIC_HWEIGHT
123126 bool
arch/parisc/include/asm/alternative.h+6−3
@@ -34,7 +34,8 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end, · 33 unmodified lines
3434
3535 /* Alternative SMP implementation. */
3636 #define ALTERNATIVE(cond, replacement) "!0:" \
37− ".section .altinstructions, \"aw\" !" \
37+ ".section .altinstructions, \"a\" !" \
38+ ".align 4 !" \
3839 ".word (0b-4-.) !" \
3940 ".hword 1, " __stringify(cond) " !" \
4041 ".word " __stringify(replacement) " !" \
@@ -44,7 +45,8 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end, · 3 unmodified lines
4445
4546 /* to replace one single instructions by a new instruction */
4647 #define ALTERNATIVE(from, to, cond, replacement)\
47− .section .altinstructions, "aw" ! \
48+ .section .altinstructions, "a" ! \
49+ .align 4 ! \
4850 .word (from - .) ! \
4951 .hword (to - from)/4, cond ! \
5052 .word replacement ! \
@@ -52,7 +54,8 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end, · 1 unmodified line
5254
5355 /* to replace multiple instructions by new code */
5456 #define ALTERNATIVE_CODE(from, num_instructions, cond, new_instr_ptr)\
55− .section .altinstructions, "aw" ! \
57+ .section .altinstructions, "a" ! \
58+ .align 4 ! \
5659 .word (from - .) ! \
5760 .hword -num_instructions, cond ! \
5861 .word (new_instr_ptr - .) ! \
arch/parisc/include/asm/assembly.h+1−0
@@ -574,6 +574,7 @@ · 573 unmodified lines
574574 */
575575 #define ASM_EXCEPTIONTABLE_ENTRY(fault_addr, except_addr) \
576576 .section __ex_table,"aw" ! \
577+ .align 4 ! \
577578 .word (fault_addr - .), (except_addr - .) ! \
578579 .previous
579580
arch/parisc/include/asm/bug.h+22−16
@@ -17,24 +17,27 @@ · 16 unmodified lines
1717 #define PARISC_BUG_BREAK_ASM "break 0x1f, 0x1fff"
1818 #define PARISC_BUG_BREAK_INSN 0x03ffe01f /* PARISC_BUG_BREAK_ASM */
1919
20−#if defined(CONFIG_64BIT)
21−#define ASM_WORD_INSN ".dword\t"
20+#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
21+# define __BUG_REL(val) ".word " __stringify(val) " - ."
2222 #else
23−#define ASM_WORD_INSN ".word\t"
23+# define __BUG_REL(val) ".word " __stringify(val)
2424 #endif
2525
26+
2627 #ifdef CONFIG_DEBUG_BUGVERBOSE
2728 #define BUG() \
2829 do { \
2930 asm volatile("\n" \
3031 "1:\t" PARISC_BUG_BREAK_ASM "\n" \
31− "\t.pushsection __bug_table,\"aw\"\n" \
32− "2:\t" ASM_WORD_INSN "1b, %c0\n" \
33− "\t.short %c1, %c2\n" \
34− "\t.org 2b+%c3\n" \
32+ "\t.pushsection __bug_table,\"a\"\n" \
33+ "\t.align 4\n" \
34+ "2:\t" __BUG_REL(1b) "\n" \
35+ "\t" __BUG_REL(%c0) "\n" \
36+ "\t.short %1, %2\n" \
37+ "\t.blockz %3-2*4-2*2\n" \
3538 "\t.popsection" \
3639 : : "i" (__FILE__), "i" (__LINE__), \
37− "i" (0), "i" (sizeof(struct bug_entry)) ); \
40+ "i" (0), "i" (sizeof(struct bug_entry)) ); \
3841 unreachable(); \
3942 } while(0)
4043
@@ -51,10 +54,12 @@ · 10 unmodified lines
5154 do { \
5255 asm volatile("\n" \
5356 "1:\t" PARISC_BUG_BREAK_ASM "\n" \
54− "\t.pushsection __bug_table,\"aw\"\n" \
55− "2:\t" ASM_WORD_INSN "1b, %c0\n" \
56− "\t.short %c1, %c2\n" \
57− "\t.org 2b+%c3\n" \
57+ "\t.pushsection __bug_table,\"a\"\n" \
58+ "\t.align 4\n" \
59+ "2:\t" __BUG_REL(1b) "\n" \
60+ "\t" __BUG_REL(%c0) "\n" \
61+ "\t.short %1, %2\n" \
62+ "\t.blockz %3-2*4-2*2\n" \
5863 "\t.popsection" \
5964 : : "i" (__FILE__), "i" (__LINE__), \
6065 "i" (BUGFLAG_WARNING|(flags)), \
@@ -65,10 +70,11 @@ · 4 unmodified lines
6570 do { \
6671 asm volatile("\n" \
6772 "1:\t" PARISC_BUG_BREAK_ASM "\n" \
68− "\t.pushsection __bug_table,\"aw\"\n" \
69− "2:\t" ASM_WORD_INSN "1b\n" \
70− "\t.short %c0\n" \
71− "\t.org 2b+%c1\n" \
73+ "\t.pushsection __bug_table,\"a\"\n" \
74+ "\t.align %2\n" \
75+ "2:\t" __BUG_REL(1b) "\n" \
76+ "\t.short %0\n" \
77+ "\t.blockz %1-4-2\n" \
7278 "\t.popsection" \
7379 : : "i" (BUGFLAG_WARNING|(flags)), \
7480 "i" (sizeof(struct bug_entry)) ); \
arch/parisc/include/asm/jump_label.h+6−2
@@ -15,10 +15,12 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran · 14 unmodified lines
1515 asm_volatile_goto("1:\n\t"
1616 "nop\n\t"
1717 ".pushsection __jump_table, \"aw\"\n\t"
18+ ".align %1\n\t"
1819 ".word 1b - ., %l[l_yes] - .\n\t"
1920 __stringify(ASM_ULONG_INSN) " %c0 - .\n\t"
2021 ".popsection\n\t"
21− : : "i" (&((char *)key)[branch]) : : l_yes);
22+ : : "i" (&((char *)key)[branch]), "i" (sizeof(long))
23+ : : l_yes);
2224
2325 return false;
2426 l_yes:
@@ -30,10 +32,12 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool · 5 unmodified lines
3032 asm_volatile_goto("1:\n\t"
3133 "b,n %l[l_yes]\n\t"
3234 ".pushsection __jump_table, \"aw\"\n\t"
35+ ".align %1\n\t"
3336 ".word 1b - ., %l[l_yes] - .\n\t"
3437 __stringify(ASM_ULONG_INSN) " %c0 - .\n\t"
3538 ".popsection\n\t"
36− : : "i" (&((char *)key)[branch]) : : l_yes);
39+ : : "i" (&((char *)key)[branch]), "i" (sizeof(long))
40+ : : l_yes);
3741
3842 return false;
3943 l_yes:
arch/parisc/include/asm/ldcw.h+1−1
@@ -55,7 +55,7 @@ · 54 unmodified lines
5555 })
5656
5757 #ifdef CONFIG_SMP
58−# define __lock_aligned __section(".data..lock_aligned")
58+# define __lock_aligned __section(".data..lock_aligned") __aligned(16)
5959 #endif
6060
6161 #endif /* __PARISC_LDCW_H */
arch/parisc/include/asm/uaccess.h+1−0
@@ -41,6 +41,7 @@ struct exception_table_entry { · 40 unmodified lines
4141
4242 #define ASM_EXCEPTIONTABLE_ENTRY( fault_addr, except_addr )\
4343 ".section __ex_table,\"aw\"\n" \
44+ ".align 4\n" \
4445 ".word (" #fault_addr " - .), (" #except_addr " - .)\n\t" \
4546 ".previous\n"
4647
arch/parisc/include/uapi/asm/errno.h+0−2
@@ -75,7 +75,6 @@ · 74 unmodified lines
7575
7676 /* We now return you to your regularly scheduled HPUX. */
7777
78−#define ENOSYM 215 /* symbol does not exist in executable */
7978 #define ENOTSOCK 216 /* Socket operation on non-socket */
8079 #define EDESTADDRREQ 217 /* Destination address required */
8180 #define EMSGSIZE 218 /* Message too long */
@@ -101,7 +100,6 @@ · 19 unmodified lines
101100 #define ETIMEDOUT 238 /* Connection timed out */
102101 #define ECONNREFUSED 239 /* Connection refused */
103102 #define EREFUSED ECONNREFUSED /* for HP's NFS apparently */
104−#define EREMOTERELEASE 240 /* Remote peer released connection */
105103 #define EHOSTDOWN 241 /* Host is down */
106104 #define EHOSTUNREACH 242 /* No route to host */
107105
arch/parisc/kernel/vmlinux.lds.S+1−0
@@ -130,6 +130,7 @@ SECTIONS · 129 unmodified lines
130130 RO_DATA(8)
131131
132132 /* unwind info */
133+ . = ALIGN(4);
133134 .PARISC.unwind : {
134135 __start___unwind = .;
135136 *(.PARISC.unwind)
arch/s390/include/asm/processor.h+0−1
@@ -228,7 +228,6 @@ typedef struct thread_struct thread_struct; · 227 unmodified lines
228228 execve_tail(); \
229229 } while (0)
230230
231−/* Forward declaration, a strange C thing */
232231 struct task_struct;
233232 struct mm_struct;
234233 struct seq_file;
arch/s390/kernel/ipl.c+1−0
@@ -666,6 +666,7 @@ static int __init ipl_init(void) · 665 unmodified lines
666666 &ipl_ccw_attr_group_lpar);
667667 break;
668668 case IPL_TYPE_ECKD:
669+ case IPL_TYPE_ECKD_DUMP:
669670 rc = sysfs_create_group(&ipl_kset->kobj, &ipl_eckd_attr_group);
670671 break;
671672 case IPL_TYPE_FCP:
arch/s390/kernel/perf_pai_crypto.c+5−6
@@ -279,12 +279,6 @@ static int paicrypt_event_init(struct perf_event *event) · 278 unmodified lines
279279 if (IS_ERR(cpump))
280280 return PTR_ERR(cpump);
281281
282− /* Event initialization sets last_tag to 0. When later on the events
283− * are deleted and re-added, do not reset the event count value to zero.
284− * Events are added, deleted and re-added when 2 or more events
285− * are active at the same time.
286− */
287− event->hw.last_tag = 0;
288282 event->destroy = paicrypt_event_destroy;
289283
290284 if (a->sample_period) {
@@ -318,6 +312,11 @@ static void paicrypt_start(struct perf_event *event, int flags) · 27 unmodified lines
318312 {
319313 u64 sum;
320314
315+ /* Event initialization sets last_tag to 0. When later on the events
316+ * are deleted and re-added, do not reset the event count value to zero.
317+ * Events are added, deleted and re-added when 2 or more events
318+ * are active at the same time.
319+ */
321320 if (!event->hw.last_tag) {
322321 event->hw.last_tag = 1;
323322 sum = paicrypt_getall(event); /* Get current value */
arch/s390/kernel/perf_pai_ext.c+0−1
@@ -260,7 +260,6 @@ static int paiext_event_init(struct perf_event *event) · 259 unmodified lines
260260 rc = paiext_alloc(a, event);
261261 if (rc)
262262 return rc;
263− event->hw.last_tag = 0;
264263 event->destroy = paiext_event_destroy;
265264
266265 if (a->sample_period) {
arch/x86/events/intel/core.c+1−1
@@ -4660,7 +4660,7 @@ static void intel_pmu_check_hybrid_pmus(struct x86_hybrid_pmu *pmu) · 4659 unmodified lines
46604660 if (pmu->intel_cap.pebs_output_pt_available)
46614661 pmu->pmu.capabilities |= PERF_PMU_CAP_AUX_OUTPUT;
46624662 else
4663− pmu->pmu.capabilities |= ~PERF_PMU_CAP_AUX_OUTPUT;
4663+ pmu->pmu.capabilities &= ~PERF_PMU_CAP_AUX_OUTPUT;
46644664
46654665 intel_pmu_check_event_constraints(pmu->event_constraints,
46664666 pmu->num_counters,
arch/x86/kernel/cpu/microcode/amd.c+11−28
@@ -104,8 +104,6 @@ struct cont_desc { · 103 unmodified lines
104104 size_t size;
105105 };
106106
107−static u32 ucode_new_rev;
108−
109107 /*
110108 * Microcode patch container file is prepended to the initrd in cpio
111109 * format. See Documentation/arch/x86/microcode.rst
@@ -442,12 +440,11 @@ static int __apply_microcode_amd(struct microcode_amd *mc) · 330 unmodified lines
442440 *
443441 * Returns true if container found (sets @desc), false otherwise.
444442 */
445−static bool early_apply_microcode(u32 cpuid_1_eax, void *ucode, size_t size)
443+static bool early_apply_microcode(u32 cpuid_1_eax, u32 old_rev, void *ucode, size_t size)
446444 {
447445 struct cont_desc desc = { 0 };
448446 struct microcode_amd *mc;
449447 bool ret = false;
450− u32 rev, dummy;
451448
452449 desc.cpuid_1_eax = cpuid_1_eax;
453450
@@ -457,22 +454,15 @@ static bool early_apply_microcode(u32 cpuid_1_eax, void *ucode, size_t size) · 3 unmodified lines
457454 if (!mc)
458455 return ret;
459456
460− native_rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy);
461−
462457 /*
463458 * Allow application of the same revision to pick up SMT-specific
464459 * changes even if the revision of the other SMT thread is already
465460 * up-to-date.
466461 */
467− if (rev > mc->hdr.patch_id)
462+ if (old_rev > mc->hdr.patch_id)
468463 return ret;
469464
470− if (!__apply_microcode_amd(mc)) {
471− ucode_new_rev = mc->hdr.patch_id;
472− ret = true;
473− }
474−
475− return ret;
465+ return !__apply_microcode_amd(mc);
476466 }
477467
478468 static bool get_builtin_microcode(struct cpio_data *cp, unsigned int family)
@@ -506,9 +496,12 @@ static void __init find_blobs_in_containers(unsigned int cpuid_1_eax, struct cpi · 27 unmodified lines
506496 *ret = cp;
507497 }
508498
509−void __init load_ucode_amd_bsp(unsigned int cpuid_1_eax)
499+void __init load_ucode_amd_bsp(struct early_load_data *ed, unsigned int cpuid_1_eax)
510500 {
511501 struct cpio_data cp = { };
502+ u32 dummy;
503+
504+ native_rdmsr(MSR_AMD64_PATCH_LEVEL, ed->old_rev, dummy);
512505
513506 /* Needed in load_microcode_amd() */
514507 ucode_cpu_info[0].cpu_sig.sig = cpuid_1_eax;
@@ -517,7 +510,8 @@ void __init load_ucode_amd_bsp(unsigned int cpuid_1_eax) · 2 unmodified lines
517510 if (!(cp.data && cp.size))
518511 return;
519512
520− early_apply_microcode(cpuid_1_eax, cp.data, cp.size);
513+ if (early_apply_microcode(cpuid_1_eax, ed->old_rev, cp.data, cp.size))
514+ native_rdmsr(MSR_AMD64_PATCH_LEVEL, ed->new_rev, dummy);
521515 }
522516
523517 static enum ucode_state load_microcode_amd(u8 family, const u8 *data, size_t size);
@@ -625,10 +619,8 @@ void reload_ucode_amd(unsigned int cpu) · 101 unmodified lines
625619 rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy);
626620
627621 if (rev < mc->hdr.patch_id) {
628− if (!__apply_microcode_amd(mc)) {
629− ucode_new_rev = mc->hdr.patch_id;
630− pr_info("reload patch_level=0x%08x\n", ucode_new_rev);
631− }
622+ if (!__apply_microcode_amd(mc))
623+ pr_info_once("reload revision: 0x%08x\n", mc->hdr.patch_id);
632624 }
633625 }
634626
@@ -649,8 +641,6 @@ static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig) · 14 unmodified lines
649641 if (p && (p->patch_id == csig->rev))
650642 uci->mc = p->data;
651643
652− pr_info("CPU%d: patch_level=0x%08x\n", cpu, csig->rev);
653−
654644 return 0;
655645 }
656646
@@ -691,8 +681,6 @@ static enum ucode_state apply_microcode_amd(int cpu) · 34 unmodified lines
691681 rev = mc_amd->hdr.patch_id;
692682 ret = UCODE_UPDATED;
693683
694− pr_info("CPU%d: new patch_level=0x%08x\n", cpu, rev);
695−
696684 out:
697685 uci->cpu_sig.rev = rev;
698686 c->microcode = rev;
@@ -935,11 +923,6 @@ struct microcode_ops * __init init_amd_microcode(void) · 236 unmodified lines
935923 pr_warn("AMD CPU family 0x%x not supported\n", c->x86);
936924 return NULL;
937925 }
938−
939− if (ucode_new_rev)
940− pr_info_once("microcode updated early to new patch_level=0x%08x\n",
941− ucode_new_rev);
942−
943926 return &microcode_amd_ops;
944927 }
945928
arch/x86/kernel/cpu/microcode/core.c+9−6
@@ -41,8 +41,6 @@ · 40 unmodified lines
4141
4242 #include "internal.h"
4343
44−#define DRIVER_VERSION "2.2"
45−
4644 static struct microcode_ops *microcode_ops;
4745 bool dis_ucode_ldr = true;
4846
@@ -77,6 +75,8 @@ static u32 final_levels[] = { · 28 unmodified lines
7775 0, /* T-101 terminator */
7876 };
7977
78+struct early_load_data early_data;
79+
8080 /*
8181 * Check the current patch level on this CPU.
8282 *
@@ -155,9 +155,9 @@ void __init load_ucode_bsp(void) · 72 unmodified lines
155155 return;
156156
157157 if (intel)
158− load_ucode_intel_bsp();
158+ load_ucode_intel_bsp(&early_data);
159159 else
160− load_ucode_amd_bsp(cpuid_1_eax);
160+ load_ucode_amd_bsp(&early_data, cpuid_1_eax);
161161 }
162162
163163 void load_ucode_ap(void)
@@ -828,6 +828,11 @@ static int __init microcode_init(void) · 664 unmodified lines
828828 if (!microcode_ops)
829829 return -ENODEV;
830830
831+ pr_info_once("Current revision: 0x%08x\n", (early_data.new_rev ?: early_data.old_rev));
832+
833+ if (early_data.new_rev)
834+ pr_info_once("Updated early from: 0x%08x\n", early_data.old_rev);
835+
831836 microcode_pdev = platform_device_register_simple("microcode", -1, NULL, 0);
832837 if (IS_ERR(microcode_pdev))
833838 return PTR_ERR(microcode_pdev);
@@ -846,8 +851,6 @@ static int __init microcode_init(void) · 12 unmodified lines
846851 cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/microcode:online",
847852 mc_cpu_online, mc_cpu_down_prep);
848853
849− pr_info("Microcode Update Driver: v%s.", DRIVER_VERSION);
850−
851854 return 0;
852855
853856 out_pdev:
arch/x86/kernel/cpu/microcode/intel.c+7−10
@@ -339,16 +339,9 @@ static enum ucode_state __apply_microcode(struct ucode_cpu_info *uci, · 338 unmodified lines
339339 static enum ucode_state apply_microcode_early(struct ucode_cpu_info *uci)
340340 {
341341 struct microcode_intel *mc = uci->mc;
342− enum ucode_state ret;
343− u32 cur_rev, date;
342+ u32 cur_rev;
344343
345− ret = __apply_microcode(uci, mc, &cur_rev);
346− if (ret == UCODE_UPDATED) {
347− date = mc->hdr.date;
348− pr_info_once("updated early: 0x%x -> 0x%x, date = %04x-%02x-%02x\n",
349− cur_rev, mc->hdr.rev, date & 0xffff, date >> 24, (date >> 16) & 0xff);
350− }
351− return ret;
344+ return __apply_microcode(uci, mc, &cur_rev);
352345 }
353346
354347 static __init bool load_builtin_intel_microcode(struct cpio_data *cp)
@@ -413,13 +406,17 @@ static int __init save_builtin_microcode(void) · 58 unmodified lines
413406 early_initcall(save_builtin_microcode);
414407
415408 /* Load microcode on BSP from initrd or builtin blobs */
416−void __init load_ucode_intel_bsp(void)
409+void __init load_ucode_intel_bsp(struct early_load_data *ed)
417410 {
418411 struct ucode_cpu_info uci;
419412
413+ ed->old_rev = intel_get_microcode_revision();
414+
420415 uci.mc = get_microcode_blob(&uci, false);
421416 if (uci.mc && apply_microcode_early(&uci) == UCODE_UPDATED)
422417 ucode_patch_va = UCODE_BSP_LOADED;
418+
419+ ed->new_rev = uci.cpu_sig.rev;
423420 }
424421
425422 void load_ucode_intel_ap(void)
arch/x86/kernel/cpu/microcode/internal.h+10−4
@@ -37,6 +37,12 @@ struct microcode_ops { · 36 unmodified lines
3737 use_nmi : 1;
3838 };
3939
40+struct early_load_data {
41+ u32 old_rev;
42+ u32 new_rev;
43+};
44+
45+extern struct early_load_data early_data;
4046 extern struct ucode_cpu_info ucode_cpu_info[];
4147 struct cpio_data find_microcode_in_initrd(const char *path);
4248
@@ -92,14 +98,14 @@ extern bool dis_ucode_ldr; · 49 unmodified lines
9298 extern bool force_minrev;
9399
94100 #ifdef CONFIG_CPU_SUP_AMD
95−void load_ucode_amd_bsp(unsigned int family);
101+void load_ucode_amd_bsp(struct early_load_data *ed, unsigned int family);
96102 void load_ucode_amd_ap(unsigned int family);
97103 int save_microcode_in_initrd_amd(unsigned int family);
98104 void reload_ucode_amd(unsigned int cpu);
99105 struct microcode_ops *init_amd_microcode(void);
100106 void exit_amd_microcode(void);
101107 #else /* CONFIG_CPU_SUP_AMD */
102−static inline void load_ucode_amd_bsp(unsigned int family) { }
108+static inline void load_ucode_amd_bsp(struct early_load_data *ed, unsigned int family) { }
103109 static inline void load_ucode_amd_ap(unsigned int family) { }
104110 static inline int save_microcode_in_initrd_amd(unsigned int family) { return -EINVAL; }
105111 static inline void reload_ucode_amd(unsigned int cpu) { }
@@ -108,12 +114,12 @@ static inline void exit_amd_microcode(void) { } · 2 unmodified lines
108114 #endif /* !CONFIG_CPU_SUP_AMD */
109115
110116 #ifdef CONFIG_CPU_SUP_INTEL
111−void load_ucode_intel_bsp(void);
117+void load_ucode_intel_bsp(struct early_load_data *ed);
112118 void load_ucode_intel_ap(void);
113119 void reload_ucode_intel(void);
114120 struct microcode_ops *init_intel_microcode(void);
115121 #else /* CONFIG_CPU_SUP_INTEL */
116−static inline void load_ucode_intel_bsp(void) { }
122+static inline void load_ucode_intel_bsp(struct early_load_data *ed) { }
117123 static inline void load_ucode_intel_ap(void) { }
118124 static inline void reload_ucode_intel(void) { }
119125 static inline struct microcode_ops *init_intel_microcode(void) { return NULL; }
block/bdev.c+2−0
@@ -425,6 +425,8 @@ void bdev_set_nr_sectors(struct block_device *bdev, sector_t sectors) · 424 unmodified lines
425425
426426 void bdev_add(struct block_device *bdev, dev_t dev)
427427 {
428+ if (bdev_stable_writes(bdev))
429+ mapping_set_stable_writes(bdev->bd_inode->i_mapping);
428430 bdev->bd_dev = dev;
429431 bdev->bd_inode->i_rdev = dev;
430432 bdev->bd_inode->i_ino = dev;
block/blk-cgroup.c+13−0
@@ -577,6 +577,7 @@ static void blkg_destroy_all(struct gendisk *disk) · 576 unmodified lines
577577 struct request_queue *q = disk->queue;
578578 struct blkcg_gq *blkg, *n;
579579 int count = BLKG_DESTROY_BATCH_SIZE;
580+ int i;
580581
581582 restart:
582583 spin_lock_irq(&q->queue_lock);
@@ -602,6 +603,18 @@ restart: · 19 unmodified lines
602603 }
603604 }
604605
606+ /*
607+ * Mark policy deactivated since policy offline has been done, and
608+ * the free is scheduled, so future blkcg_deactivate_policy() can
609+ * be bypassed
610+ */
611+ for (i = 0; i < BLKCG_MAX_POLS; i++) {
612+ struct blkcg_policy *pol = blkcg_policy[i];
613+
614+ if (pol)
615+ __clear_bit(pol->plid, q->blkcg_pols);
616+ }
617+
605618 q->root_blkg = NULL;
606619 spin_unlock_irq(&q->queue_lock);
607620 }
block/blk-cgroup.h+0−2
@@ -249,8 +249,6 @@ static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, · 248 unmodified lines
249249 {
250250 struct blkcg_gq *blkg;
251251
252− WARN_ON_ONCE(!rcu_read_lock_held());
253−
254252 if (blkcg == &blkcg_root)
255253 return q->root_blkg;
256254
block/blk-pm.c+5−28
@@ -163,38 +163,15 @@ EXPORT_SYMBOL(blk_pre_runtime_resume); · 162 unmodified lines
163163 * @q: the queue of the device
164164 *
165165 * Description:
166− * For historical reasons, this routine merely calls blk_set_runtime_active()
167− * to do the real work of restarting the queue. It does this regardless of
168− * whether the device's runtime-resume succeeded; even if it failed the
166+ * Restart the queue of a runtime suspended device. It does this regardless
167+ * of whether the device's runtime-resume succeeded; even if it failed the
169168 * driver or error handler will need to communicate with the device.
170169 *
171170 * This function should be called near the end of the device's
172− * runtime_resume callback.
171+ * runtime_resume callback to correct queue runtime PM status and re-enable
172+ * peeking requests from the queue.
173173 */
174174 void blk_post_runtime_resume(struct request_queue *q)
175−{
176− blk_set_runtime_active(q);
177−}
178−EXPORT_SYMBOL(blk_post_runtime_resume);
179−
180−/**
181− * blk_set_runtime_active - Force runtime status of the queue to be active
182− * @q: the queue of the device
183− *
184− * If the device is left runtime suspended during system suspend the resume
185− * hook typically resumes the device and corrects runtime status
186− * accordingly. However, that does not affect the queue runtime PM status
187− * which is still "suspended". This prevents processing requests from the
188− * queue.
189− *
190− * This function can be used in driver's resume hook to correct queue
191− * runtime PM status and re-enable peeking requests from the queue. It
192− * should be called before first request is added to the queue.
193− *
194− * This function is also called by blk_post_runtime_resume() for
195− * runtime resumes. It does everything necessary to restart the queue.
196− */
197−void blk_set_runtime_active(struct request_queue *q)
198175 {
199176 int old_status;
200177
@@ -211,4 +188,4 @@ void blk_set_runtime_active(struct request_queue *q) · 10 unmodified lines
211188 if (old_status != RPM_ACTIVE)
212189 blk_clear_pm_only(q);
213190 }
214−EXPORT_SYMBOL(blk_set_runtime_active);
191+EXPORT_SYMBOL(blk_post_runtime_resume);
block/blk-throttle.c+2−0
@@ -1320,6 +1320,7 @@ static void tg_conf_updated(struct throtl_grp *tg, bool global) · 1319 unmodified lines
13201320 tg_bps_limit(tg, READ), tg_bps_limit(tg, WRITE),
13211321 tg_iops_limit(tg, READ), tg_iops_limit(tg, WRITE));
13221322
1323+ rcu_read_lock();
13231324 /*
13241325 * Update has_rules[] flags for the updated tg's subtree. A tg is
13251326 * considered to have rules if either the tg itself or any of its
@@ -1347,6 +1348,7 @@ static void tg_conf_updated(struct throtl_grp *tg, bool global) · 21 unmodified lines
13471348 this_tg->latency_target = max(this_tg->latency_target,
13481349 parent_tg->latency_target);
13491350 }
1351+ rcu_read_unlock();
13501352
13511353 /*
13521354 * We're already holding queue_lock and know @tg is valid. Let's
drivers/accel/ivpu/ivpu_hw_37xx.c+22−24
@@ -502,6 +502,16 @@ static int ivpu_boot_pwr_domain_enable(struct ivpu_device *vdev) · 501 unmodified lines
502502 return ret;
503503 }
504504
505+static int ivpu_boot_pwr_domain_disable(struct ivpu_device *vdev)
506+{
507+ ivpu_boot_dpu_active_drive(vdev, false);
508+ ivpu_boot_pwr_island_isolation_drive(vdev, true);
509+ ivpu_boot_pwr_island_trickle_drive(vdev, false);
510+ ivpu_boot_pwr_island_drive(vdev, false);
511+
512+ return ivpu_boot_wait_for_pwr_island_status(vdev, 0x0);
513+}
514+
505515 static void ivpu_boot_no_snoop_enable(struct ivpu_device *vdev)
506516 {
507517 u32 val = REGV_RD32(VPU_37XX_HOST_IF_TCU_PTW_OVERRIDES);
@@ -600,25 +610,17 @@ static int ivpu_hw_37xx_info_init(struct ivpu_device *vdev) · 92 unmodified lines
600610
601611 static int ivpu_hw_37xx_reset(struct ivpu_device *vdev)
602612 {
603− int ret;
604− u32 val;
605−
606− if (IVPU_WA(punit_disabled))
607− return 0;
613+ int ret = 0;
608614
609− ret = REGB_POLL_FLD(VPU_37XX_BUTTRESS_VPU_IP_RESET, TRIGGER, 0, TIMEOUT_US);
610− if (ret) {
611− ivpu_err(vdev, "Timed out waiting for TRIGGER bit\n");
612− return ret;
615+ if (ivpu_boot_pwr_domain_disable(vdev)) {
616+ ivpu_err(vdev, "Failed to disable power domain\n");
617+ ret = -EIO;
613618 }
614619
615− val = REGB_RD32(VPU_37XX_BUTTRESS_VPU_IP_RESET);
616− val = REG_SET_FLD(VPU_37XX_BUTTRESS_VPU_IP_RESET, TRIGGER, val);
617− REGB_WR32(VPU_37XX_BUTTRESS_VPU_IP_RESET, val);
618−
619− ret = REGB_POLL_FLD(VPU_37XX_BUTTRESS_VPU_IP_RESET, TRIGGER, 0, TIMEOUT_US);
620− if (ret)
621− ivpu_err(vdev, "Timed out waiting for RESET completion\n");
620+ if (ivpu_pll_disable(vdev)) {
621+ ivpu_err(vdev, "Failed to disable PLL\n");
622+ ret = -EIO;
623+ }
622624
623625 return ret;
624626 }
@@ -651,10 +653,6 @@ static int ivpu_hw_37xx_power_up(struct ivpu_device *vdev) · 26 unmodified lines
651653 {
652654 int ret;
653655
654− ret = ivpu_hw_37xx_reset(vdev);
655− if (ret)
656− ivpu_warn(vdev, "Failed to reset HW: %d\n", ret);
657−
658656 ret = ivpu_hw_37xx_d0i3_disable(vdev);
659657 if (ret)
660658 ivpu_warn(vdev, "Failed to disable D0I3: %d\n", ret);
@@ -722,11 +720,11 @@ static int ivpu_hw_37xx_power_down(struct ivpu_device *vdev) · 61 unmodified lines
722720 {
723721 int ret = 0;
724722
725− if (!ivpu_hw_37xx_is_idle(vdev) && ivpu_hw_37xx_reset(vdev))
726− ivpu_err(vdev, "Failed to reset the VPU\n");
723+ if (!ivpu_hw_37xx_is_idle(vdev))
724+ ivpu_warn(vdev, "VPU not idle during power down\n");
727725
728− if (ivpu_pll_disable(vdev)) {
729− ivpu_err(vdev, "Failed to disable PLL\n");
726+ if (ivpu_hw_37xx_reset(vdev)) {
727+ ivpu_err(vdev, "Failed to reset VPU\n");
730728 ret = -EIO;
731729 }
732730
drivers/acpi/acpi_video.c+1−1
@@ -2031,7 +2031,7 @@ static int acpi_video_bus_add(struct acpi_device *device) · 2030 unmodified lines
20312031 * HP ZBook Fury 16 G10 requires ACPI video's child devices have _PS0
20322032 * evaluated to have functional panel brightness control.
20332033 */
2034− acpi_device_fix_up_power_extended(device);
2034+ acpi_device_fix_up_power_children(device);
20352035
20362036 pr_info("%s [%s] (multi-head: %s rom: %s post: %s)\n",
20372037 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
drivers/acpi/device_pm.c+13−0
@@ -397,6 +397,19 @@ void acpi_device_fix_up_power_extended(struct acpi_device *adev) · 396 unmodified lines
397397 }
398398 EXPORT_SYMBOL_GPL(acpi_device_fix_up_power_extended);
399399
400+/**
401+ * acpi_device_fix_up_power_children - Force a device's children into D0.
402+ * @adev: Parent device object whose children's power state is to be fixed up.
403+ *
404+ * Call acpi_device_fix_up_power() for @adev's children so long as they
405+ * are reported as present and enabled.
406+ */
407+void acpi_device_fix_up_power_children(struct acpi_device *adev)
408+{
409+ acpi_dev_for_each_child(adev, fix_up_power_if_applicable, NULL);
410+}
411+EXPORT_SYMBOL_GPL(acpi_device_fix_up_power_children);
412+
400413 int acpi_device_update_power(struct acpi_device *device, int *state_p)
401414 {
402415 int state;
drivers/acpi/processor_idle.c+1−1
@@ -592,7 +592,7 @@ static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) · 591 unmodified lines
592592 while (1) {
593593
594594 if (cx->entry_method == ACPI_CSTATE_HALT)
595− safe_halt();
595+ raw_safe_halt();
596596 else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) {
597597 io_idle(cx->address);
598598 } else
drivers/acpi/resource.c+7−0
@@ -447,6 +447,13 @@ static const struct dmi_system_id irq1_level_low_skip_override[] = { · 446 unmodified lines
447447 DMI_MATCH(DMI_BOARD_NAME, "B1402CBA"),
448448 },
449449 },
450+ {
451+ /* Asus ExpertBook B1402CVA */
452+ .matches = {
453+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
454+ DMI_MATCH(DMI_BOARD_NAME, "B1402CVA"),
455+ },
456+ },
450457 {
451458 /* Asus ExpertBook B1502CBA */
452459 .matches = {
drivers/ata/pata_isapnp.c+3−0
@@ -82,6 +82,9 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev · 81 unmodified lines
8282 if (pnp_port_valid(idev, 1)) {
8383 ctl_addr = devm_ioport_map(&idev->dev,
8484 pnp_port_start(idev, 1), 1);
85+ if (!ctl_addr)
86+ return -ENOMEM;
87+
8588 ap->ioaddr.altstatus_addr = ctl_addr;
8689 ap->ioaddr.ctl_addr = ctl_addr;
8790 ap->ops = &isapnp_port_ops;
drivers/block/nbd.c+75−42
@@ -67,6 +67,7 @@ struct nbd_sock { · 66 unmodified lines
6767 struct recv_thread_args {
6868 struct work_struct work;
6969 struct nbd_device *nbd;
70+ struct nbd_sock *nsock;
7071 int index;
7172 };
7273
@@ -395,6 +396,22 @@ static u32 req_to_nbd_cmd_type(struct request *req) · 322 unmodified lines
395396 }
396397 }
397398
399+static struct nbd_config *nbd_get_config_unlocked(struct nbd_device *nbd)
400+{
401+ if (refcount_inc_not_zero(&nbd->config_refs)) {
402+ /*
403+ * Add smp_mb__after_atomic to ensure that reading nbd->config_refs
404+ * and reading nbd->config is ordered. The pair is the barrier in
405+ * nbd_alloc_and_init_config(), avoid nbd->config_refs is set
406+ * before nbd->config.
407+ */
408+ smp_mb__after_atomic();
409+ return nbd->config;
410+ }
411+
412+ return NULL;
413+}
414+
398415 static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req)
399416 {
400417 struct nbd_cmd *cmd = blk_mq_rq_to_pdu(req);
@@ -409,13 +426,13 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req) · 8 unmodified lines
409426 return BLK_EH_DONE;
410427 }
411428
412− if (!refcount_inc_not_zero(&nbd->config_refs)) {
429+ config = nbd_get_config_unlocked(nbd);
430+ if (!config) {
413431 cmd->status = BLK_STS_TIMEOUT;
414432 __clear_bit(NBD_CMD_INFLIGHT, &cmd->flags);
415433 mutex_unlock(&cmd->lock);
416434 goto done;
417435 }
418− config = nbd->config;
419436
420437 if (config->num_connections > 1 ||
421438 (config->num_connections == 1 && nbd->tag_set.timeout)) {
@@ -489,15 +506,9 @@ done: · 67 unmodified lines
489506 return BLK_EH_DONE;
490507 }
491508
492−/*
493− * Send or receive packet. Return a positive value on success and
494− * negtive value on failue, and never return 0.
495− */
496−static int sock_xmit(struct nbd_device *nbd, int index, int send,
497− struct iov_iter *iter, int msg_flags, int *sent)
509+static int __sock_xmit(struct nbd_device *nbd, struct socket *sock, int send,
510+ struct iov_iter *iter, int msg_flags, int *sent)
498511 {
499− struct nbd_config *config = nbd->config;
500− struct socket *sock = config->socks[index]->sock;
501512 int result;
502513 struct msghdr msg;
503514 unsigned int noreclaim_flag;
@@ -540,6 +551,19 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send, · 36 unmodified lines
540551 return result;
541552 }
542553
554+/*
555+ * Send or receive packet. Return a positive value on success and
556+ * negtive value on failure, and never return 0.
557+ */
558+static int sock_xmit(struct nbd_device *nbd, int index, int send,
559+ struct iov_iter *iter, int msg_flags, int *sent)
560+{
561+ struct nbd_config *config = nbd->config;
562+ struct socket *sock = config->socks[index]->sock;
563+
564+ return __sock_xmit(nbd, sock, send, iter, msg_flags, sent);
565+}
566+
543567 /*
544568 * Different settings for sk->sk_sndtimeo can result in different return values
545569 * if there is a signal pending when we enter sendmsg, because reasons?
@@ -696,7 +720,7 @@ out: · 150 unmodified lines
696720 return 0;
697721 }
698722
699−static int nbd_read_reply(struct nbd_device *nbd, int index,
723+static int nbd_read_reply(struct nbd_device *nbd, struct socket *sock,
700724 struct nbd_reply *reply)
701725 {
702726 struct kvec iov = {.iov_base = reply, .iov_len = sizeof(*reply)};
@@ -705,7 +729,7 @@ static int nbd_read_reply(struct nbd_device *nbd, int index, · 2 unmodified lines
705729
706730 reply->magic = 0;
707731 iov_iter_kvec(&to, ITER_DEST, &iov, 1, sizeof(*reply));
708− result = sock_xmit(nbd, index, 0, &to, MSG_WAITALL, NULL);
732+ result = __sock_xmit(nbd, sock, 0, &to, MSG_WAITALL, NULL);
709733 if (result < 0) {
710734 if (!nbd_disconnected(nbd->config))
711735 dev_err(disk_to_dev(nbd->disk),
@@ -829,14 +853,14 @@ static void recv_work(struct work_struct *work) · 117 unmodified lines
829853 struct nbd_device *nbd = args->nbd;
830854 struct nbd_config *config = nbd->config;
831855 struct request_queue *q = nbd->disk->queue;
832− struct nbd_sock *nsock;
856+ struct nbd_sock *nsock = args->nsock;
833857 struct nbd_cmd *cmd;
834858 struct request *rq;
835859
836860 while (1) {
837861 struct nbd_reply reply;
838862
839− if (nbd_read_reply(nbd, args->index, &reply))
863+ if (nbd_read_reply(nbd, nsock->sock, &reply))
840864 break;
841865
842866 /*
@@ -871,7 +895,6 @@ static void recv_work(struct work_struct *work) · 28 unmodified lines
871895 percpu_ref_put(&q->q_usage_counter);
872896 }
873897
874− nsock = config->socks[args->index];
875898 mutex_lock(&nsock->tx_lock);
876899 nbd_mark_nsock_dead(nbd, nsock, 1);
877900 mutex_unlock(&nsock->tx_lock);
@@ -977,12 +1000,12 @@ static int nbd_handle_cmd(struct nbd_cmd *cmd, int index) · 99 unmodified lines
9771000 struct nbd_sock *nsock;
9781001 int ret;
9791002
980− if (!refcount_inc_not_zero(&nbd->config_refs)) {
1003+ config = nbd_get_config_unlocked(nbd);
1004+ if (!config) {
9811005 dev_err_ratelimited(disk_to_dev(nbd->disk),
9821006 "Socks array is empty\n");
9831007 return -EINVAL;
9841008 }
985− config = nbd->config;
9861009
9871010 if (index >= config->num_connections) {
9881011 dev_err_ratelimited(disk_to_dev(nbd->disk),
@@ -1215,6 +1238,7 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg) · 226 unmodified lines
12151238 INIT_WORK(&args->work, recv_work);
12161239 args->index = i;
12171240 args->nbd = nbd;
1241+ args->nsock = nsock;
12181242 nsock->cookie++;
12191243 mutex_unlock(&nsock->tx_lock);
12201244 sockfd_put(old);
@@ -1397,6 +1421,7 @@ static int nbd_start_device(struct nbd_device *nbd) · 176 unmodified lines
13971421 refcount_inc(&nbd->config_refs);
13981422 INIT_WORK(&args->work, recv_work);
13991423 args->nbd = nbd;
1424+ args->nsock = config->socks[i];
14001425 args->index = i;
14011426 queue_work(nbd->recv_workq, &args->work);
14021427 }
@@ -1530,17 +1555,20 @@ static int nbd_ioctl(struct block_device *bdev, blk_mode_t mode, · 127 unmodified lines
15301555 return error;
15311556 }
15321557
1533−static struct nbd_config *nbd_alloc_config(void)
1558+static int nbd_alloc_and_init_config(struct nbd_device *nbd)
15341559 {
15351560 struct nbd_config *config;
15361561
1562+ if (WARN_ON(nbd->config))
1563+ return -EINVAL;
1564+
15371565 if (!try_module_get(THIS_MODULE))
1538− return ERR_PTR(-ENODEV);
1566+ return -ENODEV;
15391567
15401568 config = kzalloc(sizeof(struct nbd_config), GFP_NOFS);
15411569 if (!config) {
15421570 module_put(THIS_MODULE);
1543− return ERR_PTR(-ENOMEM);
1571+ return -ENOMEM;
15441572 }
15451573
15461574 atomic_set(&config->recv_threads, 0);
@@ -1548,12 +1576,24 @@ static struct nbd_config *nbd_alloc_config(void) · 1 unmodified line
15481576 init_waitqueue_head(&config->conn_wait);
15491577 config->blksize_bits = NBD_DEF_BLKSIZE_BITS;
15501578 atomic_set(&config->live_connections, 0);
1551− return config;
1579+
1580+ nbd->config = config;
1581+ /*
1582+ * Order refcount_set(&nbd->config_refs, 1) and nbd->config assignment,
1583+ * its pair is the barrier in nbd_get_config_unlocked().
1584+ * So nbd_get_config_unlocked() won't see nbd->config as null after
1585+ * refcount_inc_not_zero() succeed.
1586+ */
1587+ smp_mb__before_atomic();
1588+ refcount_set(&nbd->config_refs, 1);
1589+
1590+ return 0;
15521591 }
15531592
15541593 static int nbd_open(struct gendisk *disk, blk_mode_t mode)
15551594 {
15561595 struct nbd_device *nbd;
1596+ struct nbd_config *config;
15571597 int ret = 0;
15581598
15591599 mutex_lock(&nbd_index_mutex);
@@ -1566,27 +1606,25 @@ static int nbd_open(struct gendisk *disk, blk_mode_t mode) · 6 unmodified lines
15661606 ret = -ENXIO;
15671607 goto out;
15681608 }
1569− if (!refcount_inc_not_zero(&nbd->config_refs)) {
1570− struct nbd_config *config;
15711609
1610+ config = nbd_get_config_unlocked(nbd);
1611+ if (!config) {
15721612 mutex_lock(&nbd->config_lock);
15731613 if (refcount_inc_not_zero(&nbd->config_refs)) {
15741614 mutex_unlock(&nbd->config_lock);
15751615 goto out;
15761616 }
1577− config = nbd_alloc_config();
1578− if (IS_ERR(config)) {
1579− ret = PTR_ERR(config);
1617+ ret = nbd_alloc_and_init_config(nbd);
1618+ if (ret) {
15801619 mutex_unlock(&nbd->config_lock);
15811620 goto out;
15821621 }
1583− nbd->config = config;
1584− refcount_set(&nbd->config_refs, 1);
1622+
15851623 refcount_inc(&nbd->refs);
15861624 mutex_unlock(&nbd->config_lock);
15871625 if (max_part)
15881626 set_bit(GD_NEED_PART_SCAN, &disk->state);
1589− } else if (nbd_disconnected(nbd->config)) {
1627+ } else if (nbd_disconnected(config)) {
15901628 if (max_part)
15911629 set_bit(GD_NEED_PART_SCAN, &disk->state);
15921630 }
@@ -1990,22 +2028,17 @@ again: · 397 unmodified lines
19902028 pr_err("nbd%d already in use\n", index);
19912029 return -EBUSY;
19922030 }
1993− if (WARN_ON(nbd->config)) {
1994− mutex_unlock(&nbd->config_lock);
1995− nbd_put(nbd);
1996− return -EINVAL;
1997− }
1998− config = nbd_alloc_config();
1999− if (IS_ERR(config)) {
2031+
2032+ ret = nbd_alloc_and_init_config(nbd);
2033+ if (ret) {
20002034 mutex_unlock(&nbd->config_lock);
20012035 nbd_put(nbd);
20022036 pr_err("couldn't allocate config\n");
2003− return PTR_ERR(config);
2037+ return ret;
20042038 }
2005− nbd->config = config;
2006− refcount_set(&nbd->config_refs, 1);
2007− set_bit(NBD_RT_BOUND, &config->runtime_flags);
20082039
2040+ config = nbd->config;
2041+ set_bit(NBD_RT_BOUND, &config->runtime_flags);
20092042 ret = nbd_genl_size_set(info, nbd);
20102043 if (ret)
20112044 goto out;
@@ -2208,7 +2241,8 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) · 196 unmodified lines
22082241 }
22092242 mutex_unlock(&nbd_index_mutex);
22102243
2211− if (!refcount_inc_not_zero(&nbd->config_refs)) {
2244+ config = nbd_get_config_unlocked(nbd);
2245+ if (!config) {
22122246 dev_err(nbd_to_dev(nbd),
22132247 "not configured, cannot reconfigure\n");
22142248 nbd_put(nbd);
@@ -2216,7 +2250,6 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) · 1 unmodified line
22162250 }
22172251
22182252 mutex_lock(&nbd->config_lock);
2219− config = nbd->config;
22202253 if (!test_bit(NBD_RT_BOUND, &config->runtime_flags) ||
22212254 !nbd->pid) {
22222255 dev_err(nbd_to_dev(nbd),
drivers/block/null_blk/main.c+13−12
@@ -1464,19 +1464,13 @@ blk_status_t null_process_cmd(struct nullb_cmd *cmd, enum req_op op, · 1463 unmodified lines
14641464 return BLK_STS_OK;
14651465 }
14661466
1467−static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector,
1468− sector_t nr_sectors, enum req_op op)
1467+static void null_handle_cmd(struct nullb_cmd *cmd, sector_t sector,
1468+ sector_t nr_sectors, enum req_op op)
14691469 {
14701470 struct nullb_device *dev = cmd->nq->dev;
14711471 struct nullb *nullb = dev->nullb;
14721472 blk_status_t sts;
14731473
1474− if (test_bit(NULLB_DEV_FL_THROTTLED, &dev->flags)) {
1475− sts = null_handle_throttled(cmd);
1476− if (sts != BLK_STS_OK)
1477− return sts;
1478− }
1479−
14801474 if (op == REQ_OP_FLUSH) {
14811475 cmd->error = errno_to_blk_status(null_handle_flush(nullb));
14821476 goto out;
@@ -1493,7 +1487,6 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector, · 10 unmodified lines
14931487
14941488 out:
14951489 nullb_complete_cmd(cmd);
1496− return BLK_STS_OK;
14971490 }
14981491
14991492 static enum hrtimer_restart nullb_bwtimer_fn(struct hrtimer *timer)
@@ -1724,8 +1717,6 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx, · 224 unmodified lines
17241717 cmd->fake_timeout = should_timeout_request(rq) ||
17251718 blk_should_fake_timeout(rq->q);
17261719
1727− blk_mq_start_request(rq);
1728−
17291720 if (should_requeue_request(rq)) {
17301721 /*
17311722 * Alternate between hitting the core BUSY path, and the
@@ -1738,6 +1729,15 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx, · 6 unmodified lines
17381729 return BLK_STS_OK;
17391730 }
17401731
1732+ if (test_bit(NULLB_DEV_FL_THROTTLED, &nq->dev->flags)) {
1733+ blk_status_t sts = null_handle_throttled(cmd);
1734+
1735+ if (sts != BLK_STS_OK)
1736+ return sts;
1737+ }
1738+
1739+ blk_mq_start_request(rq);
1740+
17411741 if (is_poll) {
17421742 spin_lock(&nq->poll_lock);
17431743 list_add_tail(&rq->queuelist, &nq->poll_list);
@@ -1747,7 +1747,8 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx, · 3 unmodified lines
17471747 if (cmd->fake_timeout)
17481748 return BLK_STS_OK;
17491749
1750− return null_handle_cmd(cmd, sector, nr_sectors, req_op(rq));
1750+ null_handle_cmd(cmd, sector, nr_sectors, req_op(rq));
1751+ return BLK_STS_OK;
17511752 }
17521753
17531754 static void null_queue_rqs(struct request **rqlist)
drivers/firmware/efi/unaccepted_memory.c+1−1
@@ -101,7 +101,7 @@ retry: · 100 unmodified lines
101101 * overlap on physical address level.
102102 */
103103 list_for_each_entry(entry, &accepting_list, list) {
104− if (entry->end < range.start)
104+ if (entry->end <= range.start)
105105 continue;
106106 if (entry->start >= range.end)
107107 continue;
drivers/gpu/drm/ast/ast_drv.h+12−1
@@ -174,6 +174,17 @@ to_ast_sil164_connector(struct drm_connector *connector) · 173 unmodified lines
174174 return container_of(connector, struct ast_sil164_connector, base);
175175 }
176176
177+struct ast_bmc_connector {
178+ struct drm_connector base;
179+ struct drm_connector *physical_connector;
180+};
181+
182+static inline struct ast_bmc_connector *
183+to_ast_bmc_connector(struct drm_connector *connector)
184+{
185+ return container_of(connector, struct ast_bmc_connector, base);
186+}
187+
177188 /*
178189 * Device
179190 */
@@ -218,7 +229,7 @@ struct ast_device { · 38 unmodified lines
218229 } astdp;
219230 struct {
220231 struct drm_encoder encoder;
221− struct drm_connector connector;
232+ struct ast_bmc_connector bmc_connector;
222233 } bmc;
223234 } output;
224235
drivers/gpu/drm/ast/ast_mode.c+55−7
@@ -1767,6 +1767,30 @@ static const struct drm_encoder_funcs ast_bmc_encoder_funcs = { · 1766 unmodified lines
17671767 .destroy = drm_encoder_cleanup,
17681768 };
17691769
1770+static int ast_bmc_connector_helper_detect_ctx(struct drm_connector *connector,
1771+ struct drm_modeset_acquire_ctx *ctx,
1772+ bool force)
1773+{
1774+ struct ast_bmc_connector *bmc_connector = to_ast_bmc_connector(connector);
1775+ struct drm_connector *physical_connector = bmc_connector->physical_connector;
1776+
1777+ /*
1778+ * Most user-space compositors cannot handle more than one connected
1779+ * connector per CRTC. Hence, we only mark the BMC as connected if the
1780+ * physical connector is disconnected. If the physical connector's status
1781+ * is connected or unknown, the BMC remains disconnected. This has no
1782+ * effect on the output of the BMC.
1783+ *
1784+ * FIXME: Remove this logic once user-space compositors can handle more
1785+ * than one connector per CRTC. The BMC should always be connected.
1786+ */
1787+
1788+ if (physical_connector && physical_connector->status == connector_status_disconnected)
1789+ return connector_status_connected;
1790+
1791+ return connector_status_disconnected;
1792+}
1793+
17701794 static int ast_bmc_connector_helper_get_modes(struct drm_connector *connector)
17711795 {
17721796 return drm_add_modes_noedid(connector, 4096, 4096);
@@ -1774,6 +1798,7 @@ static int ast_bmc_connector_helper_get_modes(struct drm_connector *connector) · 1 unmodified line
17741798
17751799 static const struct drm_connector_helper_funcs ast_bmc_connector_helper_funcs = {
17761800 .get_modes = ast_bmc_connector_helper_get_modes,
1801+ .detect_ctx = ast_bmc_connector_helper_detect_ctx,
17771802 };
17781803
17791804 static const struct drm_connector_funcs ast_bmc_connector_funcs = {
@@ -1784,12 +1809,33 @@ static const struct drm_connector_funcs ast_bmc_connector_funcs = { · 4 unmodified lines
17841809 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
17851810 };
17861811
1787−static int ast_bmc_output_init(struct ast_device *ast)
1812+static int ast_bmc_connector_init(struct drm_device *dev,
1813+ struct ast_bmc_connector *bmc_connector,
1814+ struct drm_connector *physical_connector)
1815+{
1816+ struct drm_connector *connector = &bmc_connector->base;
1817+ int ret;
1818+
1819+ ret = drm_connector_init(dev, connector, &ast_bmc_connector_funcs,
1820+ DRM_MODE_CONNECTOR_VIRTUAL);
1821+ if (ret)
1822+ return ret;
1823+
1824+ drm_connector_helper_add(connector, &ast_bmc_connector_helper_funcs);
1825+
1826+ bmc_connector->physical_connector = physical_connector;
1827+
1828+ return 0;
1829+}
1830+
1831+static int ast_bmc_output_init(struct ast_device *ast,
1832+ struct drm_connector *physical_connector)
17881833 {
17891834 struct drm_device *dev = &ast->base;
17901835 struct drm_crtc *crtc = &ast->crtc;
17911836 struct drm_encoder *encoder = &ast->output.bmc.encoder;
1792− struct drm_connector *connector = &ast->output.bmc.connector;
1837+ struct ast_bmc_connector *bmc_connector = &ast->output.bmc.bmc_connector;
1838+ struct drm_connector *connector = &bmc_connector->base;
17931839 int ret;
17941840
17951841 ret = drm_encoder_init(dev, encoder,
@@ -1799,13 +1845,10 @@ static int ast_bmc_output_init(struct ast_device *ast) · 3 unmodified lines
17991845 return ret;
18001846 encoder->possible_crtcs = drm_crtc_mask(crtc);
18011847
1802− ret = drm_connector_init(dev, connector, &ast_bmc_connector_funcs,
1803− DRM_MODE_CONNECTOR_VIRTUAL);
1848+ ret = ast_bmc_connector_init(dev, bmc_connector, physical_connector);
18041849 if (ret)
18051850 return ret;
18061851
1807− drm_connector_helper_add(connector, &ast_bmc_connector_helper_funcs);
1808−
18091852 ret = drm_connector_attach_encoder(connector, encoder);
18101853 if (ret)
18111854 return ret;
@@ -1864,6 +1907,7 @@ static const struct drm_mode_config_funcs ast_mode_config_funcs = { · 52 unmodified lines
18641907 int ast_mode_config_init(struct ast_device *ast)
18651908 {
18661909 struct drm_device *dev = &ast->base;
1910+ struct drm_connector *physical_connector = NULL;
18671911 int ret;
18681912
18691913 ret = drmm_mode_config_init(dev);
@@ -1904,23 +1948,27 @@ int ast_mode_config_init(struct ast_device *ast) · 34 unmodified lines
19041948 ret = ast_vga_output_init(ast);
19051949 if (ret)
19061950 return ret;
1951+ physical_connector = &ast->output.vga.vga_connector.base;
19071952 }
19081953 if (ast->tx_chip_types & AST_TX_SIL164_BIT) {
19091954 ret = ast_sil164_output_init(ast);
19101955 if (ret)
19111956 return ret;
1957+ physical_connector = &ast->output.sil164.sil164_connector.base;
19121958 }
19131959 if (ast->tx_chip_types & AST_TX_DP501_BIT) {
19141960 ret = ast_dp501_output_init(ast);
19151961 if (ret)
19161962 return ret;
1963+ physical_connector = &ast->output.dp501.connector;
19171964 }
19181965 if (ast->tx_chip_types & AST_TX_ASTDP_BIT) {
19191966 ret = ast_astdp_output_init(ast);
19201967 if (ret)
19211968 return ret;
1969+ physical_connector = &ast->output.astdp.connector;
19221970 }
1923− ret = ast_bmc_output_init(ast);
1971+ ret = ast_bmc_output_init(ast, physical_connector);
19241972 if (ret)
19251973 return ret;
19261974
drivers/gpu/drm/i915/display/intel_dp_mst.c+8−8
@@ -1161,6 +1161,14 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo · 1160 unmodified lines
11611161 intel_connector->port = port;
11621162 drm_dp_mst_get_port_malloc(port);
11631163
1164+ /*
1165+ * TODO: set the AUX for the actual MST port decompressing the stream.
1166+ * At the moment the driver only supports enabling this globally in the
1167+ * first downstream MST branch, via intel_dp's (root port) AUX.
1168+ */
1169+ intel_connector->dp.dsc_decompression_aux = &intel_dp->aux;
1170+ intel_dp_mst_read_decompression_port_dsc_caps(intel_dp, intel_connector);
1171+
11641172 connector = &intel_connector->base;
11651173 ret = drm_connector_init(dev, connector, &intel_dp_mst_connector_funcs,
11661174 DRM_MODE_CONNECTOR_DisplayPort);
@@ -1172,14 +1180,6 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo · 5 unmodified lines
11721180
11731181 drm_connector_helper_add(connector, &intel_dp_mst_connector_helper_funcs);
11741182
1175− /*
1176− * TODO: set the AUX for the actual MST port decompressing the stream.
1177− * At the moment the driver only supports enabling this globally in the
1178− * first downstream MST branch, via intel_dp's (root port) AUX.
1179− */
1180− intel_connector->dp.dsc_decompression_aux = &intel_dp->aux;
1181− intel_dp_mst_read_decompression_port_dsc_caps(intel_dp, intel_connector);
1182−
11831183 for_each_pipe(dev_priv, pipe) {
11841184 struct drm_encoder *enc =
11851185 &intel_dp->mst_encoders[pipe]->base.base;
drivers/gpu/drm/i915/gt/intel_gt.c+0−11
@@ -982,8 +982,6 @@ int intel_gt_probe_all(struct drm_i915_private *i915) · 981 unmodified lines
982982
983983 err:
984984 i915_probe_error(i915, "Failed to initialize %s! (%d)\n", gtdef->name, ret);
985− intel_gt_release_all(i915);
986−
987985 return ret;
988986 }
989987
@@ -1002,15 +1000,6 @@ int intel_gt_tiles_init(struct drm_i915_private *i915) · 12 unmodified lines
10021000 return 0;
10031001 }
10041002
1005−void intel_gt_release_all(struct drm_i915_private *i915)
1006−{
1007− struct intel_gt *gt;
1008− unsigned int id;
1009−
1010− for_each_gt(gt, i915, id)
1011− i915->gt[id] = NULL;
1012−}
1013−
10141003 void intel_gt_info_print(const struct intel_gt_info *info,
10151004 struct drm_printer *p)
10161005 {
drivers/gpu/drm/i915/i915_driver.c+1−3
@@ -782,7 +782,7 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 781 unmodified lines
782782
783783 ret = i915_driver_mmio_probe(i915);
784784 if (ret < 0)
785− goto out_tiles_cleanup;
785+ goto out_runtime_pm_put;
786786
787787 ret = i915_driver_hw_probe(i915);
788788 if (ret < 0)
@@ -842,8 +842,6 @@ out_cleanup_hw: · 53 unmodified lines
842842 i915_ggtt_driver_late_release(i915);
843843 out_cleanup_mmio:
844844 i915_driver_mmio_release(i915);
845−out_tiles_cleanup:
846− intel_gt_release_all(i915);
847845 out_runtime_pm_put:
848846 enable_rpm_wakeref_asserts(&i915->runtime_pm);
849847 i915_driver_late_release(i915);
drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_8_0_sc8280xp.h+1−0
@@ -406,6 +406,7 @@ static const struct dpu_perf_cfg sc8280xp_perf_data = { · 405 unmodified lines
406406 .min_llcc_ib = 0,
407407 .min_dram_ib = 800000,
408408 .danger_lut_tbl = {0xf, 0xffff, 0x0},
409+ .safe_lut_tbl = {0xfe00, 0xfe00, 0xffff},
409410 .qos_lut_tbl = {
410411 {.nentry = ARRAY_SIZE(sc8180x_qos_linear),
411412 .entries = sc8180x_qos_linear
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c+1−2
@@ -844,8 +844,7 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev) · 843 unmodified lines
844844
845845 return 0;
846846 fail:
847− if (mdp5_kms)
848− mdp5_destroy(mdp5_kms);
847+ mdp5_destroy(mdp5_kms);
849848 return ret;
850849 }
851850
drivers/gpu/drm/msm/dp/dp_display.c+10−5
@@ -365,9 +365,11 @@ static int dp_display_send_hpd_notification(struct dp_display_private *dp, · 364 unmodified lines
365365 /* reset video pattern flag on disconnect */
366366 if (!hpd) {
367367 dp->panel->video_test = false;
368− drm_dp_set_subconnector_property(dp->dp_display.connector,
369− connector_status_disconnected,
370− dp->panel->dpcd, dp->panel->downstream_ports);
368+ if (!dp->dp_display.is_edp)
369+ drm_dp_set_subconnector_property(dp->dp_display.connector,
370+ connector_status_disconnected,
371+ dp->panel->dpcd,
372+ dp->panel->downstream_ports);
371373 }
372374
373375 dp->dp_display.is_connected = hpd;
@@ -396,8 +398,11 @@ static int dp_display_process_hpd_high(struct dp_display_private *dp) · 22 unmodified lines
396398
397399 dp_link_process_request(dp->link);
398400
399− drm_dp_set_subconnector_property(dp->dp_display.connector, connector_status_connected,
400− dp->panel->dpcd, dp->panel->downstream_ports);
401+ if (!dp->dp_display.is_edp)
402+ drm_dp_set_subconnector_property(dp->dp_display.connector,
403+ connector_status_connected,
404+ dp->panel->dpcd,
405+ dp->panel->downstream_ports);
401406
402407 edid = dp->panel->edid;
403408
drivers/gpu/drm/msm/dp/dp_drm.c+3−0
@@ -345,6 +345,9 @@ struct drm_connector *dp_drm_connector_init(struct msm_dp *dp_display, struct dr · 344 unmodified lines
345345 if (IS_ERR(connector))
346346 return connector;
347347
348+ if (!dp_display->is_edp)
349+ drm_connector_attach_dp_subconnector_property(connector);
350+
348351 drm_connector_attach_encoder(connector, encoder);
349352
350353 return connector;
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c+1−1
@@ -918,7 +918,7 @@ static int dsi_7nm_phy_enable(struct msm_dsi_phy *phy, · 917 unmodified lines
918918 if ((phy->cfg->quirks & DSI_PHY_7NM_QUIRK_V5_2)) {
919919 if (phy->cphy_mode) {
920920 vreg_ctrl_0 = 0x45;
921− vreg_ctrl_1 = 0x45;
921+ vreg_ctrl_1 = 0x41;
922922 glbl_rescode_top_ctrl = 0x00;
923923 glbl_rescode_bot_ctrl = 0x00;
924924 } else {
drivers/gpu/drm/msm/msm_drv.c+0−2
@@ -288,8 +288,6 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) · 287 unmodified lines
288288 if (ret)
289289 goto err_msm_uninit;
290290
291− drm_kms_helper_poll_init(ddev);
292−
293291 if (priv->kms_init) {
294292 drm_kms_helper_poll_init(ddev);
295293 msm_fbdev_setup(ddev);
drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c+1−1
@@ -539,7 +539,7 @@ r535_fifo_runl_ctor(struct nvkm_fifo *fifo) · 538 unmodified lines
539539 struct nvkm_runl *runl;
540540 struct nvkm_engn *engn;
541541 u32 cgids = 2048;
542− u32 chids = 2048 / CHID_PER_USERD;
542+ u32 chids = 2048;
543543 int ret;
544544 NV2080_CTRL_FIFO_GET_DEVICE_INFO_TABLE_PARAMS *ctrl;
545545
drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c+5−4
@@ -1709,6 +1709,7 @@ static const struct panel_desc auo_b101uan08_3_desc = { · 1708 unmodified lines
17091709 .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
17101710 MIPI_DSI_MODE_LPM,
17111711 .init_cmds = auo_b101uan08_3_init_cmd,
1712+ .lp11_before_reset = true,
17121713 };
17131714
17141715 static const struct drm_display_mode boe_tv105wum_nw0_default_mode = {
@@ -1766,11 +1767,11 @@ static const struct panel_desc starry_qfh032011_53g_desc = { · 51 unmodified lines
17661767 };
17671768
17681769 static const struct drm_display_mode starry_himax83102_j02_default_mode = {
1769− .clock = 161600,
1770+ .clock = 162850,
17701771 .hdisplay = 1200,
1771− .hsync_start = 1200 + 40,
1772− .hsync_end = 1200 + 40 + 20,
1773− .htotal = 1200 + 40 + 20 + 40,
1772+ .hsync_start = 1200 + 50,
1773+ .hsync_end = 1200 + 50 + 20,
1774+ .htotal = 1200 + 50 + 20 + 50,
17741775 .vdisplay = 1920,
17751776 .vsync_start = 1920 + 116,
17761777 .vsync_end = 1920 + 116 + 8,
drivers/gpu/drm/panel/panel-simple.c+7−6
@@ -2379,13 +2379,13 @@ static const struct panel_desc innolux_g070y2_t02 = { · 2378 unmodified lines
23792379 static const struct display_timing innolux_g101ice_l01_timing = {
23802380 .pixelclock = { 60400000, 71100000, 74700000 },
23812381 .hactive = { 1280, 1280, 1280 },
2382− .hfront_porch = { 41, 80, 100 },
2383− .hback_porch = { 40, 79, 99 },
2384− .hsync_len = { 1, 1, 1 },
2382+ .hfront_porch = { 30, 60, 70 },
2383+ .hback_porch = { 30, 60, 70 },
2384+ .hsync_len = { 22, 40, 60 },
23852385 .vactive = { 800, 800, 800 },
2386− .vfront_porch = { 5, 11, 14 },
2387− .vback_porch = { 4, 11, 14 },
2388− .vsync_len = { 1, 1, 1 },
2386+ .vfront_porch = { 3, 8, 14 },
2387+ .vback_porch = { 3, 8, 14 },
2388+ .vsync_len = { 4, 7, 12 },
23892389 .flags = DISPLAY_FLAGS_DE_HIGH,
23902390 };
23912391
@@ -2402,6 +2402,7 @@ static const struct panel_desc innolux_g101ice_l01 = { · 10 unmodified lines
24022402 .disable = 200,
24032403 },
24042404 .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
2405+ .bus_flags = DRM_BUS_FLAG_DE_HIGH,
24052406 .connector_type = DRM_MODE_CONNECTOR_LVDS,
24062407 };
24072408
drivers/gpu/drm/rockchip/rockchip_drm_vop.c+11−3
@@ -247,14 +247,22 @@ static inline void vop_cfg_done(struct vop *vop) · 246 unmodified lines
247247 VOP_REG_SET(vop, common, cfg_done, 1);
248248 }
249249
250−static bool has_rb_swapped(uint32_t format)
250+static bool has_rb_swapped(uint32_t version, uint32_t format)
251251 {
252252 switch (format) {
253253 case DRM_FORMAT_XBGR8888:
254254 case DRM_FORMAT_ABGR8888:
255− case DRM_FORMAT_BGR888:
256255 case DRM_FORMAT_BGR565:
257256 return true;
257+ /*
258+ * full framework (IP version 3.x) only need rb swapped for RGB888 and
259+ * little framework (IP version 2.x) only need rb swapped for BGR888,
260+ * check for 3.x to also only rb swap BGR888 for unknown vop version
261+ */
262+ case DRM_FORMAT_RGB888:
263+ return VOP_MAJOR(version) == 3;
264+ case DRM_FORMAT_BGR888:
265+ return VOP_MAJOR(version) != 3;
258266 default:
259267 return false;
260268 }
@@ -1030,7 +1038,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane, · 769 unmodified lines
10301038 VOP_WIN_SET(vop, win, dsp_info, dsp_info);
10311039 VOP_WIN_SET(vop, win, dsp_st, dsp_st);
10321040
1033− rb_swap = has_rb_swapped(fb->format->format);
1041+ rb_swap = has_rb_swapped(vop->data->version, fb->format->format);
10341042 VOP_WIN_SET(vop, win, rb_swap, rb_swap);
10351043
10361044 /*
drivers/hid/hid-apple.c+2−0
@@ -345,6 +345,8 @@ static const struct apple_non_apple_keyboard non_apple_keyboards[] = { · 344 unmodified lines
345345 { "AONE" },
346346 { "GANSS" },
347347 { "Hailuck" },
348+ { "Jamesdonkey" },
349+ { "A3R" },
348350 };
349351
350352 static bool apple_is_non_apple_keyboard(struct hid_device *hdev)
drivers/hid/hid-asus.c+23−4
@@ -381,7 +381,7 @@ static int asus_raw_event(struct hid_device *hdev, · 380 unmodified lines
381381 return 0;
382382 }
383383
384−static int asus_kbd_set_report(struct hid_device *hdev, u8 *buf, size_t buf_size)
384+static int asus_kbd_set_report(struct hid_device *hdev, const u8 *buf, size_t buf_size)
385385 {
386386 unsigned char *dmabuf;
387387 int ret;
@@ -404,7 +404,7 @@ static int asus_kbd_set_report(struct hid_device *hdev, u8 *buf, size_t buf_size · 16 unmodified lines
404404
405405 static int asus_kbd_init(struct hid_device *hdev)
406406 {
407− u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x41, 0x53, 0x55, 0x53, 0x20, 0x54,
407+ const u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x41, 0x53, 0x55, 0x53, 0x20, 0x54,
408408 0x65, 0x63, 0x68, 0x2e, 0x49, 0x6e, 0x63, 0x2e, 0x00 };
409409 int ret;
410410
@@ -418,7 +418,7 @@ static int asus_kbd_init(struct hid_device *hdev) · 7 unmodified lines
418418 static int asus_kbd_get_functions(struct hid_device *hdev,
419419 unsigned char *kbd_func)
420420 {
421− u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x05, 0x20, 0x31, 0x00, 0x08 };
421+ const u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x05, 0x20, 0x31, 0x00, 0x08 };
422422 u8 *readbuf;
423423 int ret;
424424
@@ -449,7 +449,7 @@ static int asus_kbd_get_functions(struct hid_device *hdev, · 24 unmodified lines
449449
450450 static int rog_nkey_led_init(struct hid_device *hdev)
451451 {
452− u8 buf_init_start[] = { FEATURE_KBD_LED_REPORT_ID1, 0xB9 };
452+ const u8 buf_init_start[] = { FEATURE_KBD_LED_REPORT_ID1, 0xB9 };
453453 u8 buf_init2[] = { FEATURE_KBD_LED_REPORT_ID1, 0x41, 0x53, 0x55, 0x53, 0x20,
454454 0x54, 0x65, 0x63, 0x68, 0x2e, 0x49, 0x6e, 0x63, 0x2e, 0x00 };
455455 u8 buf_init3[] = { FEATURE_KBD_LED_REPORT_ID1,
@@ -1000,6 +1000,24 @@ static int asus_start_multitouch(struct hid_device *hdev) · 544 unmodified lines
10001000 return 0;
10011001 }
10021002
1003+static int __maybe_unused asus_resume(struct hid_device *hdev) {
1004+ struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
1005+ int ret = 0;
1006+
1007+ if (drvdata->kbd_backlight) {
1008+ const u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4,
1009+ drvdata->kbd_backlight->cdev.brightness };
1010+ ret = asus_kbd_set_report(hdev, buf, sizeof(buf));
1011+ if (ret < 0) {
1012+ hid_err(hdev, "Asus failed to set keyboard backlight: %d\n", ret);
1013+ goto asus_resume_err;
1014+ }
1015+ }
1016+
1017+asus_resume_err:
1018+ return ret;
1019+}
1020+
10031021 static int __maybe_unused asus_reset_resume(struct hid_device *hdev)
10041022 {
10051023 struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
@@ -1294,6 +1312,7 @@ static struct hid_driver asus_driver = { · 288 unmodified lines
12941312 .input_configured = asus_input_configured,
12951313 #ifdef CONFIG_PM
12961314 .reset_resume = asus_reset_resume,
1315+ .resume = asus_resume,
12971316 #endif
12981317 .event = asus_event,
12991318 .raw_event = asus_raw_event
drivers/hid/hid-core.c+10−2
@@ -702,15 +702,22 @@ static void hid_close_report(struct hid_device *device) · 701 unmodified lines
702702 * Free a device structure, all reports, and all fields.
703703 */
704704
705−static void hid_device_release(struct device *dev)
705+void hiddev_free(struct kref *ref)
706706 {
707− struct hid_device *hid = to_hid_device(dev);
707+ struct hid_device *hid = container_of(ref, struct hid_device, ref);
708708
709709 hid_close_report(hid);
710710 kfree(hid->dev_rdesc);
711711 kfree(hid);
712712 }
713713
714+static void hid_device_release(struct device *dev)
715+{
716+ struct hid_device *hid = to_hid_device(dev);
717+
718+ kref_put(&hid->ref, hiddev_free);
719+}
720+
714721 /*
715722 * Fetch a report description item from the data stream. We support long
716723 * items, though they are not used yet.
@@ -2846,6 +2853,7 @@ struct hid_device *hid_allocate_device(void) · 2129 unmodified lines
28462853 spin_lock_init(&hdev->debug_list_lock);
28472854 sema_init(&hdev->driver_input_lock, 1);
28482855 mutex_init(&hdev->ll_open_lock);
2856+ kref_init(&hdev->ref);
28492857
28502858 hid_bpf_device_init(hdev);
28512859
drivers/hid/hid-debug.c+3−0
@@ -1135,6 +1135,7 @@ static int hid_debug_events_open(struct inode *inode, struct file *file) · 1134 unmodified lines
11351135 goto out;
11361136 }
11371137 list->hdev = (struct hid_device *) inode->i_private;
1138+ kref_get(&list->hdev->ref);
11381139 file->private_data = list;
11391140 mutex_init(&list->read_mutex);
11401141
@@ -1227,6 +1228,8 @@ static int hid_debug_events_release(struct inode *inode, struct file *file) · 86 unmodified lines
12271228 list_del(&list->node);
12281229 spin_unlock_irqrestore(&list->hdev->debug_list_lock, flags);
12291230 kfifo_free(&list->hid_debug_fifo);
1231+
1232+ kref_put(&list->hdev->ref, hiddev_free);
12301233 kfree(list);
12311234
12321235 return 0;
drivers/hid/hid-glorious.c+14−2
@@ -21,6 +21,10 @@ MODULE_DESCRIPTION("HID driver for Glorious PC Gaming Race mice"); · 20 unmodified lines
2121 * Glorious Model O and O- specify the const flag in the consumer input
2222 * report descriptor, which leads to inputs being ignored. Fix this
2323 * by patching the descriptor.
24+ *
25+ * Glorious Model I incorrectly specifes the Usage Minimum for its
26+ * keyboard HID report, causing keycodes to be misinterpreted.
27+ * Fix this by setting Usage Minimum to 0 in that report.
2428 */
2529 static __u8 *glorious_report_fixup(struct hid_device *hdev, __u8 *rdesc,
2630 unsigned int *rsize)
@@ -32,6 +36,10 @@ static __u8 *glorious_report_fixup(struct hid_device *hdev, __u8 *rdesc, · 5 unmodified lines
3236 rdesc[85] = rdesc[113] = rdesc[141] = \
3337 HID_MAIN_ITEM_VARIABLE | HID_MAIN_ITEM_RELATIVE;
3438 }
39+ if (*rsize == 156 && rdesc[41] == 1) {
40+ hid_info(hdev, "patching Glorious Model I keyboard report descriptor\n");
41+ rdesc[41] = 0;
42+ }
3543 return rdesc;
3644 }
3745
@@ -44,6 +52,8 @@ static void glorious_update_name(struct hid_device *hdev) · 6 unmodified lines
4452 model = "Model O"; break;
4553 case USB_DEVICE_ID_GLORIOUS_MODEL_D:
4654 model = "Model D"; break;
55+ case USB_DEVICE_ID_GLORIOUS_MODEL_I:
56+ model = "Model I"; break;
4757 }
4858
4959 snprintf(hdev->name, sizeof(hdev->name), "%s %s", "Glorious", model);
@@ -66,10 +76,12 @@ static int glorious_probe(struct hid_device *hdev, · 16 unmodified lines
6676 }
6777
6878 static const struct hid_device_id glorious_devices[] = {
69− { HID_USB_DEVICE(USB_VENDOR_ID_GLORIOUS,
79+ { HID_USB_DEVICE(USB_VENDOR_ID_SINOWEALTH,
7080 USB_DEVICE_ID_GLORIOUS_MODEL_O) },
71− { HID_USB_DEVICE(USB_VENDOR_ID_GLORIOUS,
81+ { HID_USB_DEVICE(USB_VENDOR_ID_SINOWEALTH,
7282 USB_DEVICE_ID_GLORIOUS_MODEL_D) },
83+ { HID_USB_DEVICE(USB_VENDOR_ID_LAVIEW,
84+ USB_DEVICE_ID_GLORIOUS_MODEL_I) },
7385 { }
7486 };
7587 MODULE_DEVICE_TABLE(hid, glorious_devices);
drivers/hid/hid-ids.h+7−5
@@ -511,10 +511,6 @@ · 510 unmodified lines
511511 #define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A 0x010a
512512 #define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100 0xe100
513513
514−#define USB_VENDOR_ID_GLORIOUS 0x258a
515−#define USB_DEVICE_ID_GLORIOUS_MODEL_D 0x0033
516−#define USB_DEVICE_ID_GLORIOUS_MODEL_O 0x0036
517−
518514 #define I2C_VENDOR_ID_GOODIX 0x27c6
519515 #define I2C_DEVICE_ID_GOODIX_01F0 0x01f0
520516
@@ -745,6 +741,9 @@ · 224 unmodified lines
745741 #define USB_VENDOR_ID_LABTEC 0x1020
746742 #define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006
747743
744+#define USB_VENDOR_ID_LAVIEW 0x22D4
745+#define USB_DEVICE_ID_GLORIOUS_MODEL_I 0x1503
746+
748747 #define USB_VENDOR_ID_LCPOWER 0x1241
749748 #define USB_DEVICE_ID_LCPOWER_LC1000 0xf767
750749
@@ -869,7 +868,6 @@ · 118 unmodified lines
869868 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_2 0xc534
870869 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1 0xc539
871870 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_1 0xc53f
872−#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_2 0xc547
873871 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_POWERPLAY 0xc53a
874872 #define USB_DEVICE_ID_SPACETRAVELLER 0xc623
875873 #define USB_DEVICE_ID_SPACENAVIGATOR 0xc626
@@ -1160,6 +1158,10 @@ · 284 unmodified lines
11601158 #define USB_VENDOR_ID_SIGMATEL 0x066F
11611159 #define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780
11621160
1161+#define USB_VENDOR_ID_SINOWEALTH 0x258a
1162+#define USB_DEVICE_ID_GLORIOUS_MODEL_D 0x0033
1163+#define USB_DEVICE_ID_GLORIOUS_MODEL_O 0x0036
1164+
11631165 #define USB_VENDOR_ID_SIS_TOUCH 0x0457
11641166 #define USB_DEVICE_ID_SIS9200_TOUCH 0x9200
11651167 #define USB_DEVICE_ID_SIS817_TOUCH 0x0817
drivers/hid/hid-logitech-dj.c+3−8
@@ -1695,12 +1695,11 @@ static int logi_dj_raw_event(struct hid_device *hdev, · 1694 unmodified lines
16951695 }
16961696 /*
16971697 * Mouse-only receivers send unnumbered mouse data. The 27 MHz
1698− * receiver uses 6 byte packets, the nano receiver 8 bytes,
1699− * the lightspeed receiver (Pro X Superlight) 13 bytes.
1698+ * receiver uses 6 byte packets, the nano receiver 8 bytes.
17001699 */
17011700 if (djrcv_dev->unnumbered_application == HID_GD_MOUSE &&
1702− size <= 13){
1703− u8 mouse_report[14];
1701+ size <= 8) {
1702+ u8 mouse_report[9];
17041703
17051704 /* Prepend report id */
17061705 mouse_report[0] = REPORT_TYPE_MOUSE;
@@ -1984,10 +1983,6 @@ static const struct hid_device_id logi_dj_receivers[] = { · 277 unmodified lines
19841983 HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
19851984 USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_1),
19861985 .driver_data = recvr_type_gaming_hidpp},
1987− { /* Logitech lightspeed receiver (0xc547) */
1988− HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1989− USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_2),
1990− .driver_data = recvr_type_gaming_hidpp},
19911986
19921987 { /* Logitech 27 MHz HID++ 1.0 receiver (0xc513) */
19931988 HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER),
drivers/hid/hid-mcp2221.c+3−1
@@ -1142,6 +1142,8 @@ static int mcp2221_probe(struct hid_device *hdev, · 1141 unmodified lines
11421142 if (ret)
11431143 return ret;
11441144
1145+ hid_device_io_start(hdev);
1146+
11451147 /* Set I2C bus clock diviser */
11461148 if (i2c_clk_freq > 400)
11471149 i2c_clk_freq = 400;
@@ -1157,12 +1159,12 @@ static int mcp2221_probe(struct hid_device *hdev, · 9 unmodified lines
11571159 snprintf(mcp->adapter.name, sizeof(mcp->adapter.name),
11581160 "MCP2221 usb-i2c bridge");
11591161
1162+ i2c_set_adapdata(&mcp->adapter, mcp);
11601163 ret = devm_i2c_add_adapter(&hdev->dev, &mcp->adapter);
11611164 if (ret) {
11621165 hid_err(hdev, "can't add usb-i2c adapter: %d\n", ret);
11631166 return ret;
11641167 }
1165− i2c_set_adapdata(&mcp->adapter, mcp);
11661168
11671169 #if IS_REACHABLE(CONFIG_GPIOLIB)
11681170 /* Setup GPIO chip */
drivers/hid/hid-multitouch.c+5−0
@@ -2046,6 +2046,11 @@ static const struct hid_device_id mt_devices[] = { · 2045 unmodified lines
20462046 MT_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT,
20472047 USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) },
20482048
2049+ /* HONOR GLO-GXXX panel */
2050+ { .driver_data = MT_CLS_VTL,
2051+ HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
2052+ 0x347d, 0x7853) },
2053+
20492054 /* Ilitek dual touch panel */
20502055 { .driver_data = MT_CLS_NSMU,
20512056 MT_USB_DEVICE(USB_VENDOR_ID_ILITEK,
drivers/hid/hid-quirks.c+1−0
@@ -33,6 +33,7 @@ static const struct hid_device_id hid_quirks[] = { · 32 unmodified lines
3333 { HID_USB_DEVICE(USB_VENDOR_ID_AKAI, USB_DEVICE_ID_AKAI_MPKMINI2), HID_QUIRK_NO_INIT_REPORTS },
3434 { HID_USB_DEVICE(USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD), HID_QUIRK_BADPAD },
3535 { HID_USB_DEVICE(USB_VENDOR_ID_AMI, USB_DEVICE_ID_AMI_VIRT_KEYBOARD_AND_MOUSE), HID_QUIRK_ALWAYS_POLL },
36+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI), HID_QUIRK_ALWAYS_POLL },
3637 { HID_USB_DEVICE(USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM), HID_QUIRK_NOGET },
3738 { HID_USB_DEVICE(USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC), HID_QUIRK_NOGET },
3839 { HID_USB_DEVICE(USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM), HID_QUIRK_NOGET },
drivers/leds/led-class.c+0−14
@@ -75,19 +75,6 @@ static ssize_t max_brightness_show(struct device *dev, · 74 unmodified lines
7575 }
7676 static DEVICE_ATTR_RO(max_brightness);
7777
78−static ssize_t color_show(struct device *dev,
79− struct device_attribute *attr, char *buf)
80−{
81− const char *color_text = "invalid";
82− struct led_classdev *led_cdev = dev_get_drvdata(dev);
83−
84− if (led_cdev->color < LED_COLOR_ID_MAX)
85− color_text = led_colors[led_cdev->color];
86−
87− return sysfs_emit(buf, "%s\n", color_text);
88−}
89−static DEVICE_ATTR_RO(color);
90−
9178 #ifdef CONFIG_LEDS_TRIGGERS
9279 static BIN_ATTR(trigger, 0644, led_trigger_read, led_trigger_write, 0);
9380 static struct bin_attribute *led_trigger_bin_attrs[] = {
@@ -102,7 +89,6 @@ static const struct attribute_group led_trigger_group = { · 8 unmodified lines
10289 static struct attribute *led_class_attrs[] = {
10390 &dev_attr_brightness.attr,
10491 &dev_attr_max_brightness.attr,
105− &dev_attr_color.attr,
10692 NULL,
10793 };
10894
drivers/md/bcache/bcache.h+1−0
@@ -265,6 +265,7 @@ struct bcache_device { · 264 unmodified lines
265265 #define BCACHE_DEV_WB_RUNNING 3
266266 #define BCACHE_DEV_RATE_DW_RUNNING 4
267267 int nr_stripes;
268+#define BCH_MIN_STRIPE_SZ ((4 << 20) >> SECTOR_SHIFT)
268269 unsigned int stripe_size;
269270 atomic_t *stripe_sectors_dirty;
270271 unsigned long *full_dirty_stripes;
drivers/md/bcache/btree.c+10−1
@@ -1000,6 +1000,9 @@ err: · 999 unmodified lines
10001000 *
10011001 * The btree node will have either a read or a write lock held, depending on
10021002 * level and op->lock.
1003+ *
1004+ * Note: Only error code or btree pointer will be returned, it is unncessary
1005+ * for callers to check NULL pointer.
10031006 */
10041007 struct btree *bch_btree_node_get(struct cache_set *c, struct btree_op *op,
10051008 struct bkey *k, int level, bool write,
@@ -1111,6 +1114,10 @@ retry: · 105 unmodified lines
11111114 mutex_unlock(&b->c->bucket_lock);
11121115 }
11131116
1117+/*
1118+ * Only error code or btree pointer will be returned, it is unncessary for
1119+ * callers to check NULL pointer.
1120+ */
11141121 struct btree *__bch_btree_node_alloc(struct cache_set *c, struct btree_op *op,
11151122 int level, bool wait,
11161123 struct btree *parent)
@@ -1368,7 +1375,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, · 251 unmodified lines
13681375 memset(new_nodes, 0, sizeof(new_nodes));
13691376 closure_init_stack(&cl);
13701377
1371− while (nodes < GC_MERGE_NODES && !IS_ERR(r[nodes].b))
1378+ while (nodes < GC_MERGE_NODES && !IS_ERR_OR_NULL(r[nodes].b))
13721379 keys += r[nodes++].keys;
13731380
13741381 blocks = btree_default_blocks(b->c) * 2 / 3;
@@ -1532,6 +1539,8 @@ static int btree_gc_rewrite_node(struct btree *b, struct btree_op *op, · 157 unmodified lines
15321539 return 0;
15331540
15341541 n = btree_node_alloc_replacement(replace, NULL);
1542+ if (IS_ERR(n))
1543+ return 0;
15351544
15361545 /* recheck reserve after allocating replacement node */
15371546 if (btree_check_reserve(b, NULL)) {
drivers/md/bcache/super.c+3−1
@@ -905,6 +905,8 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size, · 904 unmodified lines
905905
906906 if (!d->stripe_size)
907907 d->stripe_size = 1 << 31;
908+ else if (d->stripe_size < BCH_MIN_STRIPE_SZ)
909+ d->stripe_size = roundup(BCH_MIN_STRIPE_SZ, d->stripe_size);
908910
909911 n = DIV_ROUND_UP_ULL(sectors, d->stripe_size);
910912 if (!n || n > max_stripes) {
@@ -2016,7 +2018,7 @@ static int run_cache_set(struct cache_set *c) · 1105 unmodified lines
20162018 c->root = bch_btree_node_get(c, NULL, k,
20172019 j->btree_level,
20182020 true, NULL);
2019− if (IS_ERR_OR_NULL(c->root))
2021+ if (IS_ERR(c->root))
20202022 goto err;
20212023
20222024 list_del_init(&c->root->list);
drivers/md/bcache/sysfs.c+1−1
@@ -1104,7 +1104,7 @@ SHOW(__bch_cache) · 1103 unmodified lines
11041104 sum += INITIAL_PRIO - cached[i];
11051105
11061106 if (n)
1107− do_div(sum, n);
1107+ sum = div64_u64(sum, n);
11081108
11091109 for (i = 0; i < ARRAY_SIZE(q); i++)
11101110 q[i] = INITIAL_PRIO - cached[n * (i + 1) /
drivers/md/bcache/writeback.c+18−6
@@ -913,7 +913,7 @@ static int bch_dirty_init_thread(void *arg) · 912 unmodified lines
913913 int cur_idx, prev_idx, skip_nr;
914914
915915 k = p = NULL;
916− cur_idx = prev_idx = 0;
916+ prev_idx = 0;
917917
918918 bch_btree_iter_init(&c->root->keys, &iter, NULL);
919919 k = bch_btree_iter_next_filter(&iter, &c->root->keys, bch_ptr_bad);
@@ -977,24 +977,35 @@ static int bch_btre_dirty_init_thread_nr(void) · 57 unmodified lines
977977 void bch_sectors_dirty_init(struct bcache_device *d)
978978 {
979979 int i;
980+ struct btree *b = NULL;
980981 struct bkey *k = NULL;
981982 struct btree_iter iter;
982983 struct sectors_dirty_init op;
983984 struct cache_set *c = d->c;
984985 struct bch_dirty_init_state state;
985986
987+retry_lock:
988+ b = c->root;
989+ rw_lock(0, b, b->level);
990+ if (b != c->root) {
991+ rw_unlock(0, b);
992+ goto retry_lock;
993+ }
994+
986995 /* Just count root keys if no leaf node */
987− rw_lock(0, c->root, c->root->level);
988996 if (c->root->level == 0) {
989997 bch_btree_op_init(&op.op, -1);
990998 op.inode = d->id;
991999 op.count = 0;
9921000
9931001 for_each_key_filter(&c->root->keys,
994− k, &iter, bch_ptr_invalid)
1002+ k, &iter, bch_ptr_invalid) {
1003+ if (KEY_INODE(k) != op.inode)
1004+ continue;
9951005 sectors_dirty_init_fn(&op.op, c->root, k);
1006+ }
9961007
997− rw_unlock(0, c->root);
1008+ rw_unlock(0, b);
9981009 return;
9991010 }
10001011
@@ -1014,23 +1025,24 @@ void bch_sectors_dirty_init(struct bcache_device *d) · 13 unmodified lines
10141025 if (atomic_read(&state.enough))
10151026 break;
10161027
1028+ atomic_inc(&state.started);
10171029 state.infos[i].state = &state;
10181030 state.infos[i].thread =
10191031 kthread_run(bch_dirty_init_thread, &state.infos[i],
10201032 "bch_dirtcnt[%d]", i);
10211033 if (IS_ERR(state.infos[i].thread)) {
10221034 pr_err("fails to run thread bch_dirty_init[%d]\n", i);
1035+ atomic_dec(&state.started);
10231036 for (--i; i >= 0; i--)
10241037 kthread_stop(state.infos[i].thread);
10251038 goto out;
10261039 }
1027− atomic_inc(&state.started);
10281040 }
10291041
10301042 out:
10311043 /* Must wait for all threads to stop. */
10321044 wait_event(state.wait, atomic_read(&state.started) == 0);
1033− rw_unlock(0, c->root);
1045+ rw_unlock(0, b);
10341046 }
10351047
10361048 void bch_cached_dev_writeback_init(struct cached_dev *dc)
drivers/md/md.c+2−1
@@ -8666,7 +8666,8 @@ static void md_end_clone_io(struct bio *bio) · 8665 unmodified lines
86668666 struct bio *orig_bio = md_io_clone->orig_bio;
86678667 struct mddev *mddev = md_io_clone->mddev;
86688668
8669− orig_bio->bi_status = bio->bi_status;
8669+ if (bio->bi_status && !orig_bio->bi_status)
8670+ orig_bio->bi_status = bio->bi_status;
86708671
86718672 if (md_io_clone->start_time)
86728673 bio_end_io_acct(orig_bio, md_io_clone->start_time);
drivers/media/pci/mgb4/Kconfig+1−0
@@ -2,6 +2,7 @@ · 1 unmodified line
22 config VIDEO_MGB4
33 tristate "Digiteq Automotive MGB4 support"
44 depends on VIDEO_DEV && PCI && I2C && DMADEVICES && SPI && MTD && IIO
5+ depends on COMMON_CLK
56 select VIDEOBUF2_DMA_SG
67 select IIO_BUFFER
78 select IIO_TRIGGERED_BUFFER
drivers/media/pci/mgb4/mgb4_core.c+15−5
@@ -42,6 +42,10 @@ · 41 unmodified lines
4242
4343 #define MGB4_USER_IRQS 16
4444
45+#define DIGITEQ_VID 0x1ed8
46+#define T100_DID 0x0101
47+#define T200_DID 0x0201
48+
4549 ATTRIBUTE_GROUPS(mgb4_pci);
4650
4751 static int flashid;
@@ -151,7 +155,7 @@ static struct spi_master *get_spi_adap(struct platform_device *pdev) · 103 unmodified lines
151155 return dev ? container_of(dev, struct spi_master, dev) : NULL;
152156 }
153157
154−static int init_spi(struct mgb4_dev *mgbdev)
158+static int init_spi(struct mgb4_dev *mgbdev, u32 devid)
155159 {
156160 struct resource spi_resources[] = {
157161 {
@@ -213,8 +217,13 @@ static int init_spi(struct mgb4_dev *mgbdev) · 55 unmodified lines
213217 snprintf(mgbdev->fw_part_name, sizeof(mgbdev->fw_part_name),
214218 "mgb4-fw.%d", flashid);
215219 mgbdev->partitions[0].name = mgbdev->fw_part_name;
216− mgbdev->partitions[0].size = 0x400000;
217− mgbdev->partitions[0].offset = 0x400000;
220+ if (devid == T200_DID) {
221+ mgbdev->partitions[0].size = 0x950000;
222+ mgbdev->partitions[0].offset = 0x1000000;
223+ } else {
224+ mgbdev->partitions[0].size = 0x400000;
225+ mgbdev->partitions[0].offset = 0x400000;
226+ }
218227 mgbdev->partitions[0].mask_flags = 0;
219228
220229 snprintf(mgbdev->data_part_name, sizeof(mgbdev->data_part_name),
@@ -551,7 +560,7 @@ static int mgb4_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 330 unmodified lines
551560 goto err_video_regs;
552561
553562 /* SPI FLASH */
554− rv = init_spi(mgbdev);
563+ rv = init_spi(mgbdev, id->device);
555564 if (rv < 0)
556565 goto err_cmt_regs;
557566
@@ -666,7 +675,8 @@ static void mgb4_remove(struct pci_dev *pdev) · 108 unmodified lines
666675 }
667676
668677 static const struct pci_device_id mgb4_pci_ids[] = {
669− { PCI_DEVICE(0x1ed8, 0x0101), },
678+ { PCI_DEVICE(DIGITEQ_VID, T100_DID), },
679+ { PCI_DEVICE(DIGITEQ_VID, T200_DID), },
670680 { 0, }
671681 };
672682 MODULE_DEVICE_TABLE(pci, mgb4_pci_ids);
drivers/media/platform/renesas/vsp1/vsp1_pipe.c+1−1
@@ -373,7 +373,7 @@ int vsp1_pipeline_stop(struct vsp1_pipeline *pipe) · 372 unmodified lines
373373 (7 << VI6_DPR_SMPPT_TGW_SHIFT) |
374374 (VI6_DPR_NODE_UNUSED << VI6_DPR_SMPPT_PT_SHIFT));
375375
376− v4l2_subdev_call(&pipe->output->entity.subdev, video, s_stream, 0);
376+ vsp1_wpf_stop(pipe->output);
377377
378378 return ret;
379379 }
drivers/media/platform/renesas/vsp1/vsp1_rpf.c+1−9
@@ -43,14 +43,6 @@ static inline void vsp1_rpf_write(struct vsp1_rwpf *rpf, · 42 unmodified lines
4343 data);
4444 }
4545
46−/* -----------------------------------------------------------------------------
47− * V4L2 Subdevice Operations
48− */
49−
50−static const struct v4l2_subdev_ops rpf_ops = {
51− .pad = &vsp1_rwpf_pad_ops,
52−};
53−
5446 /* -----------------------------------------------------------------------------
5547 * VSP1 Entity Operations
5648 */
@@ -411,7 +403,7 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index) · 354 unmodified lines
411403 rpf->entity.index = index;
412404
413405 sprintf(name, "rpf.%u", index);
414− ret = vsp1_entity_init(vsp1, &rpf->entity, name, 2, &rpf_ops,
406+ ret = vsp1_entity_init(vsp1, &rpf->entity, name, 2, &vsp1_rwpf_subdev_ops,
415407 MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER);
416408 if (ret < 0)
417409 return ERR_PTR(ret);
drivers/media/platform/renesas/vsp1/vsp1_rwpf.c+6−2
@@ -24,7 +24,7 @@ struct v4l2_rect *vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf, · 23 unmodified lines
2424 }
2525
2626 /* -----------------------------------------------------------------------------
27− * V4L2 Subdevice Pad Operations
27+ * V4L2 Subdevice Operations
2828 */
2929
3030 static int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev,
@@ -243,7 +243,7 @@ done: · 212 unmodified lines
243243 return ret;
244244 }
245245
246−const struct v4l2_subdev_pad_ops vsp1_rwpf_pad_ops = {
246+static const struct v4l2_subdev_pad_ops vsp1_rwpf_pad_ops = {
247247 .init_cfg = vsp1_entity_init_cfg,
248248 .enum_mbus_code = vsp1_rwpf_enum_mbus_code,
249249 .enum_frame_size = vsp1_rwpf_enum_frame_size,
@@ -253,6 +253,10 @@ const struct v4l2_subdev_pad_ops vsp1_rwpf_pad_ops = { · 3 unmodified lines
253253 .set_selection = vsp1_rwpf_set_selection,
254254 };
255255
256+const struct v4l2_subdev_ops vsp1_rwpf_subdev_ops = {
257+ .pad = &vsp1_rwpf_pad_ops,
258+};
259+
256260 /* -----------------------------------------------------------------------------
257261 * Controls
258262 */
drivers/media/platform/renesas/vsp1/vsp1_rwpf.h+3−1
@@ -79,9 +79,11 @@ static inline struct vsp1_rwpf *entity_to_rwpf(struct vsp1_entity *entity) · 78 unmodified lines
7979 struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index);
8080 struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index);
8181
82+void vsp1_wpf_stop(struct vsp1_rwpf *wpf);
83+
8284 int vsp1_rwpf_init_ctrls(struct vsp1_rwpf *rwpf, unsigned int ncontrols);
8385
84−extern const struct v4l2_subdev_pad_ops vsp1_rwpf_pad_ops;
86+extern const struct v4l2_subdev_ops vsp1_rwpf_subdev_ops;
8587
8688 struct v4l2_rect *vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf,
8789 struct v4l2_subdev_state *sd_state);
drivers/media/platform/renesas/vsp1/vsp1_wpf.c+3−26
@@ -186,17 +186,13 @@ static int wpf_init_controls(struct vsp1_rwpf *wpf) · 185 unmodified lines
186186 }
187187
188188 /* -----------------------------------------------------------------------------
189− * V4L2 Subdevice Core Operations
189+ * VSP1 Entity Operations
190190 */
191191
192−static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
192+void vsp1_wpf_stop(struct vsp1_rwpf *wpf)
193193 {
194− struct vsp1_rwpf *wpf = to_rwpf(subdev);
195194 struct vsp1_device *vsp1 = wpf->entity.vsp1;
196195
197− if (enable)
198− return 0;
199−
200196 /*
201197 * Write to registers directly when stopping the stream as there will be
202198 * no pipeline run to apply the display list.
@@ -204,27 +200,8 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable) · 1 unmodified line
204200 vsp1_write(vsp1, VI6_WPF_IRQ_ENB(wpf->entity.index), 0);
205201 vsp1_write(vsp1, wpf->entity.index * VI6_WPF_OFFSET +
206202 VI6_WPF_SRCRPF, 0);
207−
208− return 0;
209203 }
210204
211−/* -----------------------------------------------------------------------------
212− * V4L2 Subdevice Operations
213− */
214−
215−static const struct v4l2_subdev_video_ops wpf_video_ops = {
216− .s_stream = wpf_s_stream,
217−};
218−
219−static const struct v4l2_subdev_ops wpf_ops = {
220− .video = &wpf_video_ops,
221− .pad = &vsp1_rwpf_pad_ops,
222−};
223−
224−/* -----------------------------------------------------------------------------
225− * VSP1 Entity Operations
226− */
227−
228205 static void vsp1_wpf_destroy(struct vsp1_entity *entity)
229206 {
230207 struct vsp1_rwpf *wpf = entity_to_rwpf(entity);
@@ -583,7 +560,7 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index) · 352 unmodified lines
583560 wpf->entity.index = index;
584561
585562 sprintf(name, "wpf.%u", index);
586− ret = vsp1_entity_init(vsp1, &wpf->entity, name, 2, &wpf_ops,
563+ ret = vsp1_entity_init(vsp1, &wpf->entity, name, 2, &vsp1_rwpf_subdev_ops,
587564 MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER);
588565 if (ret < 0)
589566 return ERR_PTR(ret);
drivers/mmc/core/block.c+2−0
@@ -1482,6 +1482,8 @@ static void mmc_blk_cqe_complete_rq(struct mmc_queue *mq, struct request *req) · 1481 unmodified lines
14821482 blk_mq_requeue_request(req, true);
14831483 else
14841484 __blk_mq_end_request(req, BLK_STS_OK);
1485+ } else if (mq->in_recovery) {
1486+ blk_mq_requeue_request(req, true);
14851487 } else {
14861488 blk_mq_end_request(req, BLK_STS_OK);
14871489 }
drivers/mmc/core/core.c+7−2
@@ -551,7 +551,9 @@ int mmc_cqe_recovery(struct mmc_host *host) · 550 unmodified lines
551551 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
552552 cmd.flags &= ~MMC_RSP_CRC; /* Ignore CRC */
553553 cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT;
554− mmc_wait_for_cmd(host, &cmd, 0);
554+ mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
555+
556+ mmc_poll_for_busy(host->card, MMC_CQE_RECOVERY_TIMEOUT, true, MMC_BUSY_IO);
555557
556558 memset(&cmd, 0, sizeof(cmd));
557559 cmd.opcode = MMC_CMDQ_TASK_MGMT;
@@ -559,10 +561,13 @@ int mmc_cqe_recovery(struct mmc_host *host) · 1 unmodified line
559561 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
560562 cmd.flags &= ~MMC_RSP_CRC; /* Ignore CRC */
561563 cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT;
562− err = mmc_wait_for_cmd(host, &cmd, 0);
564+ err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
563565
564566 host->cqe_ops->cqe_recovery_finish(host);
565567
568+ if (err)
569+ err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
570+
566571 mmc_retune_release(host);
567572
568573 return err;
drivers/mmc/host/cqhci-core.c+22−22
@@ -942,8 +942,8 @@ static bool cqhci_clear_all_tasks(struct mmc_host *mmc, unsigned int timeout) · 941 unmodified lines
942942 ret = cqhci_tasks_cleared(cq_host);
943943
944944 if (!ret)
945− pr_debug("%s: cqhci: Failed to clear tasks\n",
946− mmc_hostname(mmc));
945+ pr_warn("%s: cqhci: Failed to clear tasks\n",
946+ mmc_hostname(mmc));
947947
948948 return ret;
949949 }
@@ -976,7 +976,7 @@ static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout) · 26 unmodified lines
976976 ret = cqhci_halted(cq_host);
977977
978978 if (!ret)
979− pr_debug("%s: cqhci: Failed to halt\n", mmc_hostname(mmc));
979+ pr_warn("%s: cqhci: Failed to halt\n", mmc_hostname(mmc));
980980
981981 return ret;
982982 }
@@ -984,10 +984,10 @@ static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout) · 1 unmodified line
984984 /*
985985 * After halting we expect to be able to use the command line. We interpret the
986986 * failure to halt to mean the data lines might still be in use (and the upper
987− * layers will need to send a STOP command), so we set the timeout based on a
988− * generous command timeout.
987+ * layers will need to send a STOP command), however failing to halt complicates
988+ * the recovery, so set a timeout that would reasonably allow I/O to complete.
989989 */
990−#define CQHCI_START_HALT_TIMEOUT 5
990+#define CQHCI_START_HALT_TIMEOUT 500
991991
992992 static void cqhci_recovery_start(struct mmc_host *mmc)
993993 {
@@ -1075,28 +1075,28 @@ static void cqhci_recovery_finish(struct mmc_host *mmc) · 81 unmodified lines
10751075
10761076 ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT);
10771077
1078− if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT))
1079− ok = false;
1080−
10811078 /*
10821079 * The specification contradicts itself, by saying that tasks cannot be
10831080 * cleared if CQHCI does not halt, but if CQHCI does not halt, it should
10841081 * be disabled/re-enabled, but not to disable before clearing tasks.
10851082 * Have a go anyway.
10861083 */
1087− if (!ok) {
1088− pr_debug("%s: cqhci: disable / re-enable\n", mmc_hostname(mmc));
1089− cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
1090− cqcfg &= ~CQHCI_ENABLE;
1091− cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
1092− cqcfg |= CQHCI_ENABLE;
1093− cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
1094− /* Be sure that there are no tasks */
1095− ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT);
1096− if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT))
1097− ok = false;
1098− WARN_ON(!ok);
1099− }
1084+ if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT))
1085+ ok = false;
1086+
1087+ /* Disable to make sure tasks really are cleared */
1088+ cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
1089+ cqcfg &= ~CQHCI_ENABLE;
1090+ cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
1091+
1092+ cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
1093+ cqcfg |= CQHCI_ENABLE;
1094+ cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
1095+
1096+ cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT);
1097+
1098+ if (!ok)
1099+ cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT);
11001100
11011101 cqhci_recover_mrqs(cq_host);
11021102
drivers/mmc/host/sdhci-pci-gli.c+29−25
@@ -1189,6 +1189,32 @@ static void gl9763e_hs400_enhanced_strobe(struct mmc_host *mmc, · 1188 unmodified lines
11891189 sdhci_writel(host, val, SDHCI_GLI_9763E_HS400_ES_REG);
11901190 }
11911191
1192+static void gl9763e_set_low_power_negotiation(struct sdhci_pci_slot *slot,
1193+ bool enable)
1194+{
1195+ struct pci_dev *pdev = slot->chip->pdev;
1196+ u32 value;
1197+
1198+ pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value);
1199+ value &= ~GLI_9763E_VHS_REV;
1200+ value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_W);
1201+ pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value);
1202+
1203+ pci_read_config_dword(pdev, PCIE_GLI_9763E_CFG, &value);
1204+
1205+ if (enable)
1206+ value &= ~GLI_9763E_CFG_LPSN_DIS;
1207+ else
1208+ value |= GLI_9763E_CFG_LPSN_DIS;
1209+
1210+ pci_write_config_dword(pdev, PCIE_GLI_9763E_CFG, value);
1211+
1212+ pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value);
1213+ value &= ~GLI_9763E_VHS_REV;
1214+ value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_R);
1215+ pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value);
1216+}
1217+
11921218 static void sdhci_set_gl9763e_signaling(struct sdhci_host *host,
11931219 unsigned int timing)
11941220 {
@@ -1297,6 +1323,9 @@ static int gl9763e_add_host(struct sdhci_pci_slot *slot) · 102 unmodified lines
12971323 if (ret)
12981324 goto cleanup;
12991325
1326+ /* Disable LPM negotiation to avoid entering L1 state. */
1327+ gl9763e_set_low_power_negotiation(slot, false);
1328+
13001329 return 0;
13011330
13021331 cleanup:
@@ -1340,31 +1369,6 @@ static void gli_set_gl9763e(struct sdhci_pci_slot *slot) · 37 unmodified lines
13401369 }
13411370
13421371 #ifdef CONFIG_PM
1343−static void gl9763e_set_low_power_negotiation(struct sdhci_pci_slot *slot, bool enable)
1344−{
1345− struct pci_dev *pdev = slot->chip->pdev;
1346− u32 value;
1347−
1348− pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value);
1349− value &= ~GLI_9763E_VHS_REV;
1350− value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_W);
1351− pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value);
1352−
1353− pci_read_config_dword(pdev, PCIE_GLI_9763E_CFG, &value);
1354−
1355− if (enable)
1356− value &= ~GLI_9763E_CFG_LPSN_DIS;
1357− else
1358− value |= GLI_9763E_CFG_LPSN_DIS;
1359−
1360− pci_write_config_dword(pdev, PCIE_GLI_9763E_CFG, value);
1361−
1362− pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value);
1363− value &= ~GLI_9763E_VHS_REV;
1364− value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_R);
1365− pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value);
1366−}
1367−
13681372 static int gl9763e_runtime_suspend(struct sdhci_pci_chip *chip)
13691373 {
13701374 struct sdhci_pci_slot *slot = chip->slots[0];
drivers/mmc/host/sdhci-sprd.c+25−0
@@ -416,12 +416,33 @@ static void sdhci_sprd_request_done(struct sdhci_host *host, · 415 unmodified lines
416416 mmc_request_done(host->mmc, mrq);
417417 }
418418
419+static void sdhci_sprd_set_power(struct sdhci_host *host, unsigned char mode,
420+ unsigned short vdd)
421+{
422+ struct mmc_host *mmc = host->mmc;
423+
424+ switch (mode) {
425+ case MMC_POWER_OFF:
426+ mmc_regulator_set_ocr(host->mmc, mmc->supply.vmmc, 0);
427+
428+ mmc_regulator_disable_vqmmc(mmc);
429+ break;
430+ case MMC_POWER_ON:
431+ mmc_regulator_enable_vqmmc(mmc);
432+ break;
433+ case MMC_POWER_UP:
434+ mmc_regulator_set_ocr(host->mmc, mmc->supply.vmmc, vdd);
435+ break;
436+ }
437+}
438+
419439 static struct sdhci_ops sdhci_sprd_ops = {
420440 .read_l = sdhci_sprd_readl,
421441 .write_l = sdhci_sprd_writel,
422442 .write_w = sdhci_sprd_writew,
423443 .write_b = sdhci_sprd_writeb,
424444 .set_clock = sdhci_sprd_set_clock,
445+ .set_power = sdhci_sprd_set_power,
425446 .get_max_clock = sdhci_sprd_get_max_clock,
426447 .get_min_clock = sdhci_sprd_get_min_clock,
427448 .set_bus_width = sdhci_set_bus_width,
@@ -823,6 +844,10 @@ static int sdhci_sprd_probe(struct platform_device *pdev) · 395 unmodified lines
823844 host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |
824845 SDHCI_SUPPORT_DDR50);
825846
847+ ret = mmc_regulator_get_supply(host->mmc);
848+ if (ret)
849+ goto pm_runtime_disable;
850+
826851 ret = sdhci_setup_host(host);
827852 if (ret)
828853 goto pm_runtime_disable;
drivers/net/dsa/mv88e6xxx/chip.c+20−6
@@ -577,6 +577,18 @@ static void mv88e6250_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, · 576 unmodified lines
577577 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100;
578578 }
579579
580+static void mv88e6351_phylink_get_caps(struct mv88e6xxx_chip *chip, int port,
581+ struct phylink_config *config)
582+{
583+ unsigned long *supported = config->supported_interfaces;
584+
585+ /* Translate the default cmode */
586+ mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported);
587+
588+ config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 |
589+ MAC_1000FD;
590+}
591+
580592 static int mv88e6352_get_port4_serdes_cmode(struct mv88e6xxx_chip *chip)
581593 {
582594 u16 reg, val;
@@ -3880,7 +3892,8 @@ static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port) · 3297 unmodified lines
38803892 struct mv88e6xxx_chip *chip = ds->priv;
38813893 int err;
38823894
3883− if (chip->info->ops->pcs_ops->pcs_init) {
3895+ if (chip->info->ops->pcs_ops &&
3896+ chip->info->ops->pcs_ops->pcs_init) {
38843897 err = chip->info->ops->pcs_ops->pcs_init(chip, port);
38853898 if (err)
38863899 return err;
@@ -3895,7 +3908,8 @@ static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port) · 8 unmodified lines
38953908
38963909 mv88e6xxx_teardown_devlink_regions_port(ds, port);
38973910
3898− if (chip->info->ops->pcs_ops->pcs_teardown)
3911+ if (chip->info->ops->pcs_ops &&
3912+ chip->info->ops->pcs_ops->pcs_teardown)
38993913 chip->info->ops->pcs_ops->pcs_teardown(chip, port);
39003914 }
39013915
@@ -4340,7 +4354,7 @@ static const struct mv88e6xxx_ops mv88e6171_ops = { · 438 unmodified lines
43404354 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
43414355 .stu_getnext = mv88e6352_g1_stu_getnext,
43424356 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
4343− .phylink_get_caps = mv88e6185_phylink_get_caps,
4357+ .phylink_get_caps = mv88e6351_phylink_get_caps,
43444358 };
43454359
43464360 static const struct mv88e6xxx_ops mv88e6172_ops = {
@@ -4440,7 +4454,7 @@ static const struct mv88e6xxx_ops mv88e6175_ops = { · 93 unmodified lines
44404454 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
44414455 .stu_getnext = mv88e6352_g1_stu_getnext,
44424456 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
4443− .phylink_get_caps = mv88e6185_phylink_get_caps,
4457+ .phylink_get_caps = mv88e6351_phylink_get_caps,
44444458 };
44454459
44464460 static const struct mv88e6xxx_ops mv88e6176_ops = {
@@ -5069,7 +5083,7 @@ static const struct mv88e6xxx_ops mv88e6350_ops = { · 622 unmodified lines
50695083 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
50705084 .stu_getnext = mv88e6352_g1_stu_getnext,
50715085 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
5072− .phylink_get_caps = mv88e6185_phylink_get_caps,
5086+ .phylink_get_caps = mv88e6351_phylink_get_caps,
50735087 };
50745088
50755089 static const struct mv88e6xxx_ops mv88e6351_ops = {
@@ -5117,7 +5131,7 @@ static const struct mv88e6xxx_ops mv88e6351_ops = { · 41 unmodified lines
51175131 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
51185132 .avb_ops = &mv88e6352_avb_ops,
51195133 .ptp_ops = &mv88e6352_ptp_ops,
5120− .phylink_get_caps = mv88e6185_phylink_get_caps,
5134+ .phylink_get_caps = mv88e6351_phylink_get_caps,
51215135 };
51225136
51235137 static const struct mv88e6xxx_ops mv88e6352_ops = {
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c+10−6
@@ -516,8 +516,6 @@ struct sk_buff *dpaa2_eth_alloc_skb(struct dpaa2_eth_priv *priv, · 515 unmodified lines
516516
517517 memcpy(skb->data, fd_vaddr + fd_offset, fd_length);
518518
519− dpaa2_eth_recycle_buf(priv, ch, dpaa2_fd_get_addr(fd));
520−
521519 return skb;
522520 }
523521
@@ -589,6 +587,7 @@ void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, · 65 unmodified lines
589587 struct rtnl_link_stats64 *percpu_stats;
590588 struct dpaa2_eth_drv_stats *percpu_extras;
591589 struct device *dev = priv->net_dev->dev.parent;
590+ bool recycle_rx_buf = false;
592591 void *buf_data;
593592 u32 xdp_act;
594593
@@ -618,6 +617,8 @@ void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, · 23 unmodified lines
618617 dma_unmap_page(dev, addr, priv->rx_buf_size,
619618 DMA_BIDIRECTIONAL);
620619 skb = dpaa2_eth_build_linear_skb(ch, fd, vaddr);
620+ } else {
621+ recycle_rx_buf = true;
621622 }
622623 } else if (fd_format == dpaa2_fd_sg) {
623624 WARN_ON(priv->xdp_prog);
@@ -637,6 +638,9 @@ void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, · 13 unmodified lines
637638 goto err_build_skb;
638639
639640 dpaa2_eth_receive_skb(priv, ch, fd, vaddr, fq, percpu_stats, skb);
641+
642+ if (recycle_rx_buf)
643+ dpaa2_eth_recycle_buf(priv, ch, dpaa2_fd_get_addr(fd));
640644 return;
641645
642646 err_build_skb:
@@ -1073,14 +1077,12 @@ static int dpaa2_eth_build_single_fd(struct dpaa2_eth_priv *priv, · 430 unmodified lines
10731077 dma_addr_t addr;
10741078
10751079 buffer_start = skb->data - dpaa2_eth_needed_headroom(skb);
1076−
1077− /* If there's enough room to align the FD address, do it.
1078− * It will help hardware optimize accesses.
1079− */
10801080 aligned_start = PTR_ALIGN(buffer_start - DPAA2_ETH_TX_BUF_ALIGN,
10811081 DPAA2_ETH_TX_BUF_ALIGN);
10821082 if (aligned_start >= skb->head)
10831083 buffer_start = aligned_start;
1084+ else
1085+ return -ENOMEM;
10841086
10851087 /* Store a backpointer to the skb at the beginning of the buffer
10861088 * (in the private data area) such that we can release it
@@ -4967,6 +4969,8 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev) · 3880 unmodified lines
49674969 if (err)
49684970 goto err_dl_port_add;
49694971
4972+ net_dev->needed_headroom = DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN;
4973+
49704974 err = register_netdev(net_dev);
49714975 if (err < 0) {
49724976 dev_err(dev, "register_netdev() failed\n");
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h+1−1
@@ -740,7 +740,7 @@ static inline bool dpaa2_eth_rx_pause_enabled(u64 link_options) · 739 unmodified lines
740740
741741 static inline unsigned int dpaa2_eth_needed_headroom(struct sk_buff *skb)
742742 {
743− unsigned int headroom = DPAA2_ETH_SWA_SIZE;
743+ unsigned int headroom = DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN;
744744
745745 /* If we don't have an skb (e.g. XDP buffer), we only need space for
746746 * the software annotation area
drivers/net/ethernet/intel/ice/ice_lag.c+72−50
@@ -569,6 +569,50 @@ resume_traffic: · 568 unmodified lines
569569 dev_dbg(dev, "Problem restarting traffic for LAG node move\n");
570570 }
571571
572+/**
573+ * ice_lag_build_netdev_list - populate the lag struct's netdev list
574+ * @lag: local lag struct
575+ * @ndlist: pointer to netdev list to populate
576+ */
577+static void ice_lag_build_netdev_list(struct ice_lag *lag,
578+ struct ice_lag_netdev_list *ndlist)
579+{
580+ struct ice_lag_netdev_list *nl;
581+ struct net_device *tmp_nd;
582+
583+ INIT_LIST_HEAD(&ndlist->node);
584+ rcu_read_lock();
585+ for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) {
586+ nl = kzalloc(sizeof(*nl), GFP_ATOMIC);
587+ if (!nl)
588+ break;
589+
590+ nl->netdev = tmp_nd;
591+ list_add(&nl->node, &ndlist->node);
592+ }
593+ rcu_read_unlock();
594+ lag->netdev_head = &ndlist->node;
595+}
596+
597+/**
598+ * ice_lag_destroy_netdev_list - free lag struct's netdev list
599+ * @lag: pointer to local lag struct
600+ * @ndlist: pointer to lag struct netdev list
601+ */
602+static void ice_lag_destroy_netdev_list(struct ice_lag *lag,
603+ struct ice_lag_netdev_list *ndlist)
604+{
605+ struct ice_lag_netdev_list *entry, *n;
606+
607+ rcu_read_lock();
608+ list_for_each_entry_safe(entry, n, &ndlist->node, node) {
609+ list_del(&entry->node);
610+ kfree(entry);
611+ }
612+ rcu_read_unlock();
613+ lag->netdev_head = NULL;
614+}
615+
572616 /**
573617 * ice_lag_move_single_vf_nodes - Move Tx scheduling nodes for single VF
574618 * @lag: primary interface LAG struct
@@ -597,7 +641,6 @@ ice_lag_move_single_vf_nodes(struct ice_lag *lag, u8 oldport, u8 newport, · 22 unmodified lines
597641 void ice_lag_move_new_vf_nodes(struct ice_vf *vf)
598642 {
599643 struct ice_lag_netdev_list ndlist;
600− struct list_head *tmp, *n;
601644 u8 pri_port, act_port;
602645 struct ice_lag *lag;
603646 struct ice_vsi *vsi;
@@ -621,38 +664,15 @@ void ice_lag_move_new_vf_nodes(struct ice_vf *vf) · 17 unmodified lines
621664 pri_port = pf->hw.port_info->lport;
622665 act_port = lag->active_port;
623666
624− if (lag->upper_netdev) {
625− struct ice_lag_netdev_list *nl;
626− struct net_device *tmp_nd;
627−
628− INIT_LIST_HEAD(&ndlist.node);
629− rcu_read_lock();
630− for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) {
631− nl = kzalloc(sizeof(*nl), GFP_ATOMIC);
632− if (!nl)
633− break;
634−
635− nl->netdev = tmp_nd;
636− list_add(&nl->node, &ndlist.node);
637− }
638− rcu_read_unlock();
639− }
640−
641− lag->netdev_head = &ndlist.node;
667+ if (lag->upper_netdev)
668+ ice_lag_build_netdev_list(lag, &ndlist);
642669
643670 if (ice_is_feature_supported(pf, ICE_F_SRIOV_LAG) &&
644671 lag->bonded && lag->primary && pri_port != act_port &&
645672 !list_empty(lag->netdev_head))
646673 ice_lag_move_single_vf_nodes(lag, pri_port, act_port, vsi->idx);
647674
648− list_for_each_safe(tmp, n, &ndlist.node) {
649− struct ice_lag_netdev_list *entry;
650−
651− entry = list_entry(tmp, struct ice_lag_netdev_list, node);
652− list_del(&entry->node);
653− kfree(entry);
654− }
655− lag->netdev_head = NULL;
675+ ice_lag_destroy_netdev_list(lag, &ndlist);
656676
657677 new_vf_unlock:
658678 mutex_unlock(&pf->lag_mutex);
@@ -679,6 +699,29 @@ static void ice_lag_move_vf_nodes(struct ice_lag *lag, u8 oldport, u8 newport) · 20 unmodified lines
679699 ice_lag_move_single_vf_nodes(lag, oldport, newport, i);
680700 }
681701
702+/**
703+ * ice_lag_move_vf_nodes_cfg - move vf nodes outside LAG netdev event context
704+ * @lag: local lag struct
705+ * @src_prt: lport value for source port
706+ * @dst_prt: lport value for destination port
707+ *
708+ * This function is used to move nodes during an out-of-netdev-event situation,
709+ * primarily when the driver needs to reconfigure or recreate resources.
710+ *
711+ * Must be called while holding the lag_mutex to avoid lag events from
712+ * processing while out-of-sync moves are happening. Also, paired moves,
713+ * such as used in a reset flow, should both be called under the same mutex
714+ * lock to avoid changes between start of reset and end of reset.
715+ */
716+void ice_lag_move_vf_nodes_cfg(struct ice_lag *lag, u8 src_prt, u8 dst_prt)
717+{
718+ struct ice_lag_netdev_list ndlist;
719+
720+ ice_lag_build_netdev_list(lag, &ndlist);
721+ ice_lag_move_vf_nodes(lag, src_prt, dst_prt);
722+ ice_lag_destroy_netdev_list(lag, &ndlist);
723+}
724+
682725 #define ICE_LAG_SRIOV_CP_RECIPE 10
683726 #define ICE_LAG_SRIOV_TRAIN_PKT_LEN 16
684727
@@ -2051,7 +2094,6 @@ void ice_lag_rebuild(struct ice_pf *pf) · 1366 unmodified lines
20512094 {
20522095 struct ice_lag_netdev_list ndlist;
20532096 struct ice_lag *lag, *prim_lag;
2054− struct list_head *tmp, *n;
20552097 u8 act_port, loc_port;
20562098
20572099 if (!pf->lag || !pf->lag->bonded)
@@ -2063,21 +2105,7 @@ void ice_lag_rebuild(struct ice_pf *pf) · 5 unmodified lines
20632105 if (lag->primary) {
20642106 prim_lag = lag;
20652107 } else {
2066− struct ice_lag_netdev_list *nl;
2067− struct net_device *tmp_nd;
2068−
2069− INIT_LIST_HEAD(&ndlist.node);
2070− rcu_read_lock();
2071− for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) {
2072− nl = kzalloc(sizeof(*nl), GFP_ATOMIC);
2073− if (!nl)
2074− break;
2075−
2076− nl->netdev = tmp_nd;
2077− list_add(&nl->node, &ndlist.node);
2078− }
2079− rcu_read_unlock();
2080− lag->netdev_head = &ndlist.node;
2108+ ice_lag_build_netdev_list(lag, &ndlist);
20812109 prim_lag = ice_lag_find_primary(lag);
20822110 }
20832111
@@ -2107,13 +2135,7 @@ void ice_lag_rebuild(struct ice_pf *pf) · 23 unmodified lines
21072135
21082136 ice_clear_rdma_cap(pf);
21092137 lag_rebuild_out:
2110− list_for_each_safe(tmp, n, &ndlist.node) {
2111− struct ice_lag_netdev_list *entry;
2112−
2113− entry = list_entry(tmp, struct ice_lag_netdev_list, node);
2114− list_del(&entry->node);
2115− kfree(entry);
2116− }
2138+ ice_lag_destroy_netdev_list(lag, &ndlist);
21172139 mutex_unlock(&pf->lag_mutex);
21182140 }
21192141
drivers/net/ethernet/intel/ice/ice_lag.h+1−0
@@ -65,4 +65,5 @@ int ice_init_lag(struct ice_pf *pf); · 64 unmodified lines
6565 void ice_deinit_lag(struct ice_pf *pf);
6666 void ice_lag_rebuild(struct ice_pf *pf);
6767 bool ice_lag_is_switchdev_running(struct ice_pf *pf);
68+void ice_lag_move_vf_nodes_cfg(struct ice_lag *lag, u8 src_prt, u8 dst_prt);
6869 #endif /* _ICE_LAG_H_ */
drivers/net/ethernet/intel/ice/ice_vf_lib.c+20−0
@@ -828,12 +828,16 @@ static void ice_notify_vf_reset(struct ice_vf *vf) · 827 unmodified lines
828828 int ice_reset_vf(struct ice_vf *vf, u32 flags)
829829 {
830830 struct ice_pf *pf = vf->pf;
831+ struct ice_lag *lag;
831832 struct ice_vsi *vsi;
833+ u8 act_prt, pri_prt;
832834 struct device *dev;
833835 int err = 0;
834836 bool rsd;
835837
836838 dev = ice_pf_to_dev(pf);
839+ act_prt = ICE_LAG_INVALID_PORT;
840+ pri_prt = pf->hw.port_info->lport;
837841
838842 if (flags & ICE_VF_RESET_NOTIFY)
839843 ice_notify_vf_reset(vf);
@@ -844,6 +848,17 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags) · 4 unmodified lines
844848 return 0;
845849 }
846850
851+ lag = pf->lag;
852+ mutex_lock(&pf->lag_mutex);
853+ if (lag && lag->bonded && lag->primary) {
854+ act_prt = lag->active_port;
855+ if (act_prt != pri_prt && act_prt != ICE_LAG_INVALID_PORT &&
856+ lag->upper_netdev)
857+ ice_lag_move_vf_nodes_cfg(lag, act_prt, pri_prt);
858+ else
859+ act_prt = ICE_LAG_INVALID_PORT;
860+ }
861+
847862 if (flags & ICE_VF_RESET_LOCK)
848863 mutex_lock(&vf->cfg_lock);
849864 else
@@ -936,6 +951,11 @@ out_unlock: · 86 unmodified lines
936951 if (flags & ICE_VF_RESET_LOCK)
937952 mutex_unlock(&vf->cfg_lock);
938953
954+ if (lag && lag->bonded && lag->primary &&
955+ act_prt != ICE_LAG_INVALID_PORT)
956+ ice_lag_move_vf_nodes_cfg(lag, pri_prt, act_prt);
957+ mutex_unlock(&pf->lag_mutex);
958+
939959 return err;
940960 }
941961
drivers/net/ethernet/intel/ice/ice_virtchnl.c+25−0
@@ -1603,9 +1603,24 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · 1602 unmodified lines
16031603 (struct virtchnl_vsi_queue_config_info *)msg;
16041604 struct virtchnl_queue_pair_info *qpi;
16051605 struct ice_pf *pf = vf->pf;
1606+ struct ice_lag *lag;
16061607 struct ice_vsi *vsi;
1608+ u8 act_prt, pri_prt;
16071609 int i = -1, q_idx;
16081610
1611+ lag = pf->lag;
1612+ mutex_lock(&pf->lag_mutex);
1613+ act_prt = ICE_LAG_INVALID_PORT;
1614+ pri_prt = pf->hw.port_info->lport;
1615+ if (lag && lag->bonded && lag->primary) {
1616+ act_prt = lag->active_port;
1617+ if (act_prt != pri_prt && act_prt != ICE_LAG_INVALID_PORT &&
1618+ lag->upper_netdev)
1619+ ice_lag_move_vf_nodes_cfg(lag, act_prt, pri_prt);
1620+ else
1621+ act_prt = ICE_LAG_INVALID_PORT;
1622+ }
1623+
16091624 if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
16101625 goto error_param;
16111626
@@ -1729,6 +1744,11 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · 117 unmodified lines
17291744 }
17301745 }
17311746
1747+ if (lag && lag->bonded && lag->primary &&
1748+ act_prt != ICE_LAG_INVALID_PORT)
1749+ ice_lag_move_vf_nodes_cfg(lag, pri_prt, act_prt);
1750+ mutex_unlock(&pf->lag_mutex);
1751+
17321752 /* send the response to the VF */
17331753 return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
17341754 VIRTCHNL_STATUS_SUCCESS, NULL, 0);
@@ -1743,6 +1763,11 @@ error_param: · 8 unmodified lines
17431763 vf->vf_id, i);
17441764 }
17451765
1766+ if (lag && lag->bonded && lag->primary &&
1767+ act_prt != ICE_LAG_INVALID_PORT)
1768+ ice_lag_move_vf_nodes_cfg(lag, pri_prt, act_prt);
1769+ mutex_unlock(&pf->lag_mutex);
1770+
17461771 ice_lag_move_new_vf_nodes(vf);
17471772
17481773 /* send the response to the VF */
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c+2−2
@@ -5505,6 +5505,8 @@ int rvu_mbox_handler_nix_bandprof_free(struct rvu *rvu, · 5504 unmodified lines
55055505
55065506 ipolicer = &nix_hw->ipolicer[layer];
55075507 for (idx = 0; idx < req->prof_count[layer]; idx++) {
5508+ if (idx == MAX_BANDPROF_PER_PFFUNC)
5509+ break;
55085510 prof_idx = req->prof_idx[layer][idx];
55095511 if (prof_idx >= ipolicer->band_prof.max ||
55105512 ipolicer->pfvf_map[prof_idx] != pcifunc)
@@ -5518,8 +5520,6 @@ int rvu_mbox_handler_nix_bandprof_free(struct rvu *rvu, · 7 unmodified lines
55185520 ipolicer->pfvf_map[prof_idx] = 0x00;
55195521 ipolicer->match_id[prof_idx] = 0;
55205522 rvu_free_rsrc(&ipolicer->band_prof, prof_idx);
5521− if (idx == MAX_BANDPROF_PER_PFFUNC)
5522− break;
55235523 }
55245524 }
55255525 mutex_unlock(&rvu->rsrc_lock);
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c+3−0
@@ -450,6 +450,9 @@ int cn10k_set_ipolicer_rate(struct otx2_nic *pfvf, u16 profile, · 449 unmodified lines
450450 aq->prof.pebs_mantissa = 0;
451451 aq->prof_mask.pebs_mantissa = 0xFF;
452452
453+ aq->prof.hl_en = 0;
454+ aq->prof_mask.hl_en = 1;
455+
453456 /* Fill AQ info */
454457 aq->qidx = profile;
455458 aq->ctype = NIX_AQ_CTYPE_BANDPROF;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h+2−0
@@ -1070,6 +1070,8 @@ int otx2_init_tc(struct otx2_nic *nic); · 1069 unmodified lines
10701070 void otx2_shutdown_tc(struct otx2_nic *nic);
10711071 int otx2_setup_tc(struct net_device *netdev, enum tc_setup_type type,
10721072 void *type_data);
1073+void otx2_tc_apply_ingress_police_rules(struct otx2_nic *nic);
1074+
10731075 /* CGX/RPM DMAC filters support */
10741076 int otx2_dmacflt_get_max_cnt(struct otx2_nic *pf);
10751077 int otx2_dmacflt_add(struct otx2_nic *pf, const u8 *mac, u32 bit_pos);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c+7−2
@@ -566,7 +566,9 @@ static irqreturn_t otx2_pfvf_mbox_intr_handler(int irq, void *pf_irq) · 565 unmodified lines
566566 otx2_write64(pf, RVU_PF_VFPF_MBOX_INTX(1), intr);
567567 otx2_queue_work(mbox, pf->mbox_pfvf_wq, 64, vfs, intr,
568568 TYPE_PFVF);
569− vfs -= 64;
569+ if (intr)
570+ trace_otx2_msg_interrupt(mbox->mbox.pdev, "VF(s) to PF", intr);
571+ vfs = 64;
570572 }
571573
572574 intr = otx2_read64(pf, RVU_PF_VFPF_MBOX_INTX(0));
@@ -574,7 +576,8 @@ static irqreturn_t otx2_pfvf_mbox_intr_handler(int irq, void *pf_irq) · 1 unmodified line
574576
575577 otx2_queue_work(mbox, pf->mbox_pfvf_wq, 0, vfs, intr, TYPE_PFVF);
576578
577− trace_otx2_msg_interrupt(mbox->mbox.pdev, "VF(s) to PF", intr);
579+ if (intr)
580+ trace_otx2_msg_interrupt(mbox->mbox.pdev, "VF(s) to PF", intr);
578581
579582 return IRQ_HANDLED;
580583 }
@@ -1870,6 +1873,8 @@ int otx2_open(struct net_device *netdev) · 1289 unmodified lines
18701873 if (pf->flags & OTX2_FLAG_DMACFLTR_SUPPORT)
18711874 otx2_dmacflt_reinstall_flows(pf);
18721875
1876+ otx2_tc_apply_ingress_police_rules(pf);
1877+
18731878 err = otx2_rxtx_enable(pf, true);
18741879 /* If a mbox communication error happens at this point then interface
18751880 * will end up in a state such that it is in down state but hardware
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c+95−25
@@ -47,6 +47,9 @@ struct otx2_tc_flow { · 46 unmodified lines
4747 bool is_act_police;
4848 u32 prio;
4949 struct npc_install_flow_req req;
50+ u64 rate;
51+ u32 burst;
52+ bool is_pps;
5053 };
5154
5255 static void otx2_get_egress_burst_cfg(struct otx2_nic *nic, u32 burst,
@@ -284,21 +287,10 @@ static int otx2_tc_egress_matchall_delete(struct otx2_nic *nic, · 231 unmodified lines
284287 return err;
285288 }
286289
287−static int otx2_tc_act_set_police(struct otx2_nic *nic,
288− struct otx2_tc_flow *node,
289− struct flow_cls_offload *f,
290− u64 rate, u32 burst, u32 mark,
291− struct npc_install_flow_req *req, bool pps)
290+static int otx2_tc_act_set_hw_police(struct otx2_nic *nic,
291+ struct otx2_tc_flow *node)
292292 {
293− struct netlink_ext_ack *extack = f->common.extack;
294− struct otx2_hw *hw = &nic->hw;
295− int rq_idx, rc;
296−
297− rq_idx = find_first_zero_bit(&nic->rq_bmap, hw->rx_queues);
298− if (rq_idx >= hw->rx_queues) {
299− NL_SET_ERR_MSG_MOD(extack, "Police action rules exceeded");
300− return -EINVAL;
301− }
293+ int rc;
302294
303295 mutex_lock(&nic->mbox.lock);
304296
@@ -308,23 +300,17 @@ static int otx2_tc_act_set_police(struct otx2_nic *nic, · 3 unmodified lines
308300 return rc;
309301 }
310302
311− rc = cn10k_set_ipolicer_rate(nic, node->leaf_profile, burst, rate, pps);
303+ rc = cn10k_set_ipolicer_rate(nic, node->leaf_profile,
304+ node->burst, node->rate, node->is_pps);
312305 if (rc)
313306 goto free_leaf;
314307
315− rc = cn10k_map_unmap_rq_policer(nic, rq_idx, node->leaf_profile, true);
308+ rc = cn10k_map_unmap_rq_policer(nic, node->rq, node->leaf_profile, true);
316309 if (rc)
317310 goto free_leaf;
318311
319312 mutex_unlock(&nic->mbox.lock);
320313
321− req->match_id = mark & 0xFFFFULL;
322− req->index = rq_idx;
323− req->op = NIX_RX_ACTIONOP_UCAST;
324− set_bit(rq_idx, &nic->rq_bmap);
325− node->is_act_police = true;
326− node->rq = rq_idx;
327−
328314 return 0;
329315
330316 free_leaf:
@@ -336,6 +322,39 @@ free_leaf: · 5 unmodified lines
336322 return rc;
337323 }
338324
325+static int otx2_tc_act_set_police(struct otx2_nic *nic,
326+ struct otx2_tc_flow *node,
327+ struct flow_cls_offload *f,
328+ u64 rate, u32 burst, u32 mark,
329+ struct npc_install_flow_req *req, bool pps)
330+{
331+ struct netlink_ext_ack *extack = f->common.extack;
332+ struct otx2_hw *hw = &nic->hw;
333+ int rq_idx, rc;
334+
335+ rq_idx = find_first_zero_bit(&nic->rq_bmap, hw->rx_queues);
336+ if (rq_idx >= hw->rx_queues) {
337+ NL_SET_ERR_MSG_MOD(extack, "Police action rules exceeded");
338+ return -EINVAL;
339+ }
340+
341+ req->match_id = mark & 0xFFFFULL;
342+ req->index = rq_idx;
343+ req->op = NIX_RX_ACTIONOP_UCAST;
344+
345+ node->is_act_police = true;
346+ node->rq = rq_idx;
347+ node->burst = burst;
348+ node->rate = rate;
349+ node->is_pps = pps;
350+
351+ rc = otx2_tc_act_set_hw_police(nic, node);
352+ if (!rc)
353+ set_bit(rq_idx, &nic->rq_bmap);
354+
355+ return rc;
356+}
357+
339358 static int otx2_tc_parse_actions(struct otx2_nic *nic,
340359 struct flow_action *flow_action,
341360 struct npc_install_flow_req *req,
@@ -1058,6 +1077,11 @@ static int otx2_tc_del_flow(struct otx2_nic *nic, · 716 unmodified lines
10581077 }
10591078
10601079 if (flow_node->is_act_police) {
1080+ __clear_bit(flow_node->rq, &nic->rq_bmap);
1081+
1082+ if (nic->flags & OTX2_FLAG_INTF_DOWN)
1083+ goto free_mcam_flow;
1084+
10611085 mutex_lock(&nic->mbox.lock);
10621086
10631087 err = cn10k_map_unmap_rq_policer(nic, flow_node->rq,
@@ -1073,11 +1097,10 @@ static int otx2_tc_del_flow(struct otx2_nic *nic, · 9 unmodified lines
10731097 "Unable to free leaf bandwidth profile(%d)\n",
10741098 flow_node->leaf_profile);
10751099
1076− __clear_bit(flow_node->rq, &nic->rq_bmap);
1077−
10781100 mutex_unlock(&nic->mbox.lock);
10791101 }
10801102
1103+free_mcam_flow:
10811104 otx2_del_mcam_flow_entry(nic, flow_node->entry, NULL);
10821105 otx2_tc_update_mcam_table(nic, flow_cfg, flow_node, false);
10831106 kfree_rcu(flow_node, rcu);
@@ -1097,6 +1120,11 @@ static int otx2_tc_add_flow(struct otx2_nic *nic, · 13 unmodified lines
10971120 if (!(nic->flags & OTX2_FLAG_TC_FLOWER_SUPPORT))
10981121 return -ENOMEM;
10991122
1123+ if (nic->flags & OTX2_FLAG_INTF_DOWN) {
1124+ NL_SET_ERR_MSG_MOD(extack, "Interface not initialized");
1125+ return -EINVAL;
1126+ }
1127+
11001128 if (flow_cfg->nr_flows == flow_cfg->max_flows) {
11011129 NL_SET_ERR_MSG_MOD(extack,
11021130 "Free MCAM entry not available to add the flow");
@@ -1456,3 +1484,45 @@ void otx2_shutdown_tc(struct otx2_nic *nic) · 353 unmodified lines
14561484 otx2_destroy_tc_flow_list(nic);
14571485 }
14581486 EXPORT_SYMBOL(otx2_shutdown_tc);
1487+
1488+static void otx2_tc_config_ingress_rule(struct otx2_nic *nic,
1489+ struct otx2_tc_flow *node)
1490+{
1491+ struct npc_install_flow_req *req;
1492+
1493+ if (otx2_tc_act_set_hw_police(nic, node))
1494+ return;
1495+
1496+ mutex_lock(&nic->mbox.lock);
1497+
1498+ req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox);
1499+ if (!req)
1500+ goto err;
1501+
1502+ memcpy(req, &node->req, sizeof(struct npc_install_flow_req));
1503+
1504+ if (otx2_sync_mbox_msg(&nic->mbox))
1505+ netdev_err(nic->netdev,
1506+ "Failed to install MCAM flow entry for ingress rule");
1507+err:
1508+ mutex_unlock(&nic->mbox.lock);
1509+}
1510+
1511+void otx2_tc_apply_ingress_police_rules(struct otx2_nic *nic)
1512+{
1513+ struct otx2_flow_config *flow_cfg = nic->flow_cfg;
1514+ struct otx2_tc_flow *node;
1515+
1516+ /* If any ingress policer rules exist for the interface then
1517+ * apply those rules. Ingress policer rules depend on bandwidth
1518+ * profiles linked to the receive queues. Since no receive queues
1519+ * exist when interface is down, ingress policer rules are stored
1520+ * and configured in hardware after all receive queues are allocated
1521+ * in otx2_open.
1522+ */
1523+ list_for_each_entry(node, &flow_cfg->flow_list_tc, list) {
1524+ if (node->is_act_police)
1525+ otx2_tc_config_ingress_rule(nic, node);
1526+ }
1527+}
1528+EXPORT_SYMBOL(otx2_tc_apply_ingress_police_rules);
drivers/net/ethernet/realtek/r8169_main.c+7−2
@@ -575,6 +575,7 @@ struct rtl8169_tc_offsets { · 574 unmodified lines
575575 enum rtl_flag {
576576 RTL_FLAG_TASK_ENABLED = 0,
577577 RTL_FLAG_TASK_RESET_PENDING,
578+ RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE,
578579 RTL_FLAG_TASK_TX_TIMEOUT,
579580 RTL_FLAG_MAX
580581 };
@@ -4496,6 +4497,8 @@ static void rtl_task(struct work_struct *work) · 3915 unmodified lines
44964497 reset:
44974498 rtl_reset_work(tp);
44984499 netif_wake_queue(tp->dev);
4500+ } else if (test_and_clear_bit(RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE, tp->wk.flags)) {
4501+ rtl_reset_work(tp);
44994502 }
45004503 out_unlock:
45014504 rtnl_unlock();
@@ -4529,7 +4532,7 @@ static void r8169_phylink_handler(struct net_device *ndev) · 27 unmodified lines
45294532 } else {
45304533 /* In few cases rx is broken after link-down otherwise */
45314534 if (rtl_is_8125(tp))
4532− rtl_reset_work(tp);
4535+ rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE);
45334536 pm_runtime_idle(d);
45344537 }
45354538
@@ -4605,7 +4608,7 @@ static int rtl8169_close(struct net_device *dev) · 69 unmodified lines
46054608 rtl8169_down(tp);
46064609 rtl8169_rx_clear(tp);
46074610
4608− cancel_work_sync(&tp->wk.work);
4611+ cancel_work(&tp->wk.work);
46094612
46104613 free_irq(tp->irq, tp);
46114614
@@ -4839,6 +4842,8 @@ static void rtl_remove_one(struct pci_dev *pdev) · 227 unmodified lines
48394842 if (pci_dev_run_wake(pdev))
48404843 pm_runtime_get_noresume(&pdev->dev);
48414844
4845+ cancel_work_sync(&tp->wk.work);
4846+
48424847 unregister_netdev(tp->dev);
48434848
48444849 if (tp->dash_type != RTL_DASH_NONE)
drivers/net/ethernet/renesas/ravb_main.c+45−24
@@ -515,6 +515,15 @@ static void ravb_emac_init_gbeth(struct net_device *ndev) · 514 unmodified lines
515515 {
516516 struct ravb_private *priv = netdev_priv(ndev);
517517
518+ if (priv->phy_interface == PHY_INTERFACE_MODE_MII) {
519+ ravb_write(ndev, (1000 << 16) | CXR35_SEL_XMII_MII, CXR35);
520+ ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1, 0);
521+ } else {
522+ ravb_write(ndev, (1000 << 16) | CXR35_SEL_XMII_RGMII, CXR35);
523+ ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1,
524+ CXR31_SEL_LINK0);
525+ }
526+
518527 /* Receive frame limit set register */
519528 ravb_write(ndev, GBETH_RX_BUFF_MAX + ETH_FCS_LEN, RFLR);
520529
@@ -537,14 +546,6 @@ static void ravb_emac_init_gbeth(struct net_device *ndev) · 16 unmodified lines
537546
538547 /* E-MAC interrupt enable register */
539548 ravb_write(ndev, ECSIPR_ICDIP, ECSIPR);
540−
541− if (priv->phy_interface == PHY_INTERFACE_MODE_MII) {
542− ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1, 0);
543− ravb_write(ndev, (1000 << 16) | CXR35_SEL_XMII_MII, CXR35);
544− } else {
545− ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1,
546− CXR31_SEL_LINK0);
547− }
548549 }
549550
550551 static void ravb_emac_init_rcar(struct net_device *ndev)
@@ -1811,19 +1812,20 @@ static int ravb_open(struct net_device *ndev) · 1260 unmodified lines
18111812 if (info->gptp)
18121813 ravb_ptp_init(ndev, priv->pdev);
18131814
1814− netif_tx_start_all_queues(ndev);
1815−
18161815 /* PHY control start */
18171816 error = ravb_phy_start(ndev);
18181817 if (error)
18191818 goto out_ptp_stop;
18201819
1820+ netif_tx_start_all_queues(ndev);
1821+
18211822 return 0;
18221823
18231824 out_ptp_stop:
18241825 /* Stop PTP Clock driver */
18251826 if (info->gptp)
18261827 ravb_ptp_stop(ndev);
1828+ ravb_stop_dma(ndev);
18271829 out_free_irq_mgmta:
18281830 if (!info->multi_irqs)
18291831 goto out_free_irq;
@@ -1874,6 +1876,12 @@ static void ravb_tx_timeout_work(struct work_struct *work) · 44 unmodified lines
18741876 struct net_device *ndev = priv->ndev;
18751877 int error;
18761878
1879+ if (!rtnl_trylock()) {
1880+ usleep_range(1000, 2000);
1881+ schedule_work(&priv->work);
1882+ return;
1883+ }
1884+
18771885 netif_tx_stop_all_queues(ndev);
18781886
18791887 /* Stop PTP Clock driver */
@@ -1907,7 +1915,7 @@ static void ravb_tx_timeout_work(struct work_struct *work) · 27 unmodified lines
19071915 */
19081916 netdev_err(ndev, "%s: ravb_dmac_init() failed, error %d\n",
19091917 __func__, error);
1910− return;
1918+ goto out_unlock;
19111919 }
19121920 ravb_emac_init(ndev);
19131921
@@ -1917,6 +1925,9 @@ out: · 3 unmodified lines
19171925 ravb_ptp_init(ndev, priv->pdev);
19181926
19191927 netif_tx_start_all_queues(ndev);
1928+
1929+out_unlock:
1930+ rtnl_unlock();
19201931 }
19211932
19221933 /* Packet transmit function for Ethernet AVB */
@@ -2645,9 +2656,14 @@ static int ravb_probe(struct platform_device *pdev) · 722 unmodified lines
26452656 ndev->features = info->net_features;
26462657 ndev->hw_features = info->net_hw_features;
26472658
2648− reset_control_deassert(rstc);
2659+ error = reset_control_deassert(rstc);
2660+ if (error)
2661+ goto out_free_netdev;
2662+
26492663 pm_runtime_enable(&pdev->dev);
2650− pm_runtime_get_sync(&pdev->dev);
2664+ error = pm_runtime_resume_and_get(&pdev->dev);
2665+ if (error < 0)
2666+ goto out_rpm_disable;
26512667
26522668 if (info->multi_irqs) {
26532669 if (info->err_mgmt_irqs)
@@ -2872,11 +2888,12 @@ out_disable_gptp_clk: · 218 unmodified lines
28722888 out_disable_refclk:
28732889 clk_disable_unprepare(priv->refclk);
28742890 out_release:
2875− free_netdev(ndev);
2876−
28772891 pm_runtime_put(&pdev->dev);
2892+out_rpm_disable:
28782893 pm_runtime_disable(&pdev->dev);
28792894 reset_control_assert(rstc);
2895+out_free_netdev:
2896+ free_netdev(ndev);
28802897 return error;
28812898 }
28822899
@@ -2886,22 +2903,26 @@ static void ravb_remove(struct platform_device *pdev) · 3 unmodified lines
28862903 struct ravb_private *priv = netdev_priv(ndev);
28872904 const struct ravb_hw_info *info = priv->info;
28882905
2889− /* Stop PTP Clock driver */
2890− if (info->ccc_gac)
2891− ravb_ptp_stop(ndev);
2892−
2893− clk_disable_unprepare(priv->gptp_clk);
2894− clk_disable_unprepare(priv->refclk);
2895−
2896− /* Set reset mode */
2897− ravb_write(ndev, CCC_OPC_RESET, CCC);
28982906 unregister_netdev(ndev);
28992907 if (info->nc_queues)
29002908 netif_napi_del(&priv->napi[RAVB_NC]);
29012909 netif_napi_del(&priv->napi[RAVB_BE]);
2910+
29022911 ravb_mdio_release(priv);
2912+
2913+ /* Stop PTP Clock driver */
2914+ if (info->ccc_gac)
2915+ ravb_ptp_stop(ndev);
2916+
29032917 dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
29042918 priv->desc_bat_dma);
2919+
2920+ /* Set reset mode */
2921+ ravb_write(ndev, CCC_OPC_RESET, CCC);
2922+
2923+ clk_disable_unprepare(priv->gptp_clk);
2924+ clk_disable_unprepare(priv->refclk);
2925+
29052926 pm_runtime_put_sync(&pdev->dev);
29062927 pm_runtime_disable(&pdev->dev);
29072928 reset_control_assert(priv->rstc);
drivers/net/ethernet/renesas/rswitch.c+13−9
@@ -1504,8 +1504,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd · 1503 unmodified lines
15041504 {
15051505 struct rswitch_device *rdev = netdev_priv(ndev);
15061506 struct rswitch_gwca_queue *gq = rdev->tx_queue;
1507+ netdev_tx_t ret = NETDEV_TX_OK;
15071508 struct rswitch_ext_desc *desc;
1508− int ret = NETDEV_TX_OK;
15091509 dma_addr_t dma_addr;
15101510
15111511 if (rswitch_get_num_cur_queues(gq) >= gq->ring_size - 1) {
@@ -1517,10 +1517,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd · 5 unmodified lines
15171517 return ret;
15181518
15191519 dma_addr = dma_map_single(ndev->dev.parent, skb->data, skb->len, DMA_TO_DEVICE);
1520− if (dma_mapping_error(ndev->dev.parent, dma_addr)) {
1521− dev_kfree_skb_any(skb);
1522− return ret;
1523− }
1520+ if (dma_mapping_error(ndev->dev.parent, dma_addr))
1521+ goto err_kfree;
15241522
15251523 gq->skbs[gq->cur] = skb;
15261524 desc = &gq->tx_ring[gq->cur];
@@ -1533,10 +1531,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd · 6 unmodified lines
15331531 struct rswitch_gwca_ts_info *ts_info;
15341532
15351533 ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC);
1536− if (!ts_info) {
1537− dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);
1538− return -ENOMEM;
1539− }
1534+ if (!ts_info)
1535+ goto err_unmap;
15401536
15411537 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
15421538 rdev->ts_tag++;
@@ -1558,6 +1554,14 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd · 15 unmodified lines
15581554 gq->cur = rswitch_next_queue_index(gq, true, 1);
15591555 rswitch_modify(rdev->addr, GWTRC(gq->index), 0, BIT(gq->index % 32));
15601556
1557+ return ret;
1558+
1559+err_unmap:
1560+ dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);
1561+
1562+err_kfree:
1563+ dev_kfree_skb_any(skb);
1564+
15611565 return ret;
15621566 }
15631567
drivers/net/ethernet/stmicro/stmmac/mmc_core.c+4−0
@@ -177,8 +177,10 @@ · 176 unmodified lines
177177 #define MMC_XGMAC_RX_DISCARD_OCT_GB 0x1b4
178178 #define MMC_XGMAC_RX_ALIGN_ERR_PKT 0x1bc
179179
180+#define MMC_XGMAC_TX_FPE_INTR_MASK 0x204
180181 #define MMC_XGMAC_TX_FPE_FRAG 0x208
181182 #define MMC_XGMAC_TX_HOLD_REQ 0x20c
183+#define MMC_XGMAC_RX_FPE_INTR_MASK 0x224
182184 #define MMC_XGMAC_RX_PKT_ASSEMBLY_ERR 0x228
183185 #define MMC_XGMAC_RX_PKT_SMD_ERR 0x22c
184186 #define MMC_XGMAC_RX_PKT_ASSEMBLY_OK 0x230
@@ -352,6 +354,8 @@ static void dwxgmac_mmc_intr_all_mask(void __iomem *mmcaddr) · 167 unmodified lines
352354 {
353355 writel(0x0, mmcaddr + MMC_RX_INTR_MASK);
354356 writel(0x0, mmcaddr + MMC_TX_INTR_MASK);
357+ writel(MMC_DEFAULT_MASK, mmcaddr + MMC_XGMAC_TX_FPE_INTR_MASK);
358+ writel(MMC_DEFAULT_MASK, mmcaddr + MMC_XGMAC_RX_FPE_INTR_MASK);
355359 writel(MMC_DEFAULT_MASK, mmcaddr + MMC_XGMAC_RX_IPC_INTR_MASK);
356360 }
357361
drivers/net/ethernet/wangxun/libwx/wx_lib.c+1−1
@@ -1972,11 +1972,11 @@ void wx_reset_interrupt_capability(struct wx *wx) · 1971 unmodified lines
19721972 if (!pdev->msi_enabled && !pdev->msix_enabled)
19731973 return;
19741974
1975− pci_free_irq_vectors(wx->pdev);
19761975 if (pdev->msix_enabled) {
19771976 kfree(wx->msix_entries);
19781977 wx->msix_entries = NULL;
19791978 }
1979+ pci_free_irq_vectors(wx->pdev);
19801980 }
19811981 EXPORT_SYMBOL(wx_reset_interrupt_capability);
19821982
drivers/net/netdevsim/bpf.c+2−2
@@ -93,7 +93,7 @@ static void nsim_prog_set_loaded(struct bpf_prog *prog, bool loaded) · 92 unmodified lines
9393 {
9494 struct nsim_bpf_bound_prog *state;
9595
96− if (!prog || !prog->aux->offload)
96+ if (!prog || !bpf_prog_is_offloaded(prog->aux))
9797 return;
9898
9999 state = prog->aux->offload->dev_priv;
@@ -311,7 +311,7 @@ nsim_setup_prog_hw_checks(struct netdevsim *ns, struct netdev_bpf *bpf) · 211 unmodified lines
311311 if (!bpf->prog)
312312 return 0;
313313
314− if (!bpf->prog->aux->offload) {
314+ if (!bpf_prog_is_offloaded(bpf->prog->aux)) {
315315 NSIM_EA(bpf->extack, "xdpoffload of non-bound program");
316316 return -EINVAL;
317317 }
drivers/net/netkit.c+6−0
@@ -851,6 +851,12 @@ static int netkit_change_link(struct net_device *dev, struct nlattr *tb[], · 850 unmodified lines
851851 return -EACCES;
852852 }
853853
854+ if (data[IFLA_NETKIT_PEER_INFO]) {
855+ NL_SET_ERR_MSG_ATTR(extack, data[IFLA_NETKIT_PEER_INFO],
856+ "netkit peer info cannot be changed after device creation");
857+ return -EINVAL;
858+ }
859+
854860 if (data[IFLA_NETKIT_POLICY]) {
855861 attr = data[IFLA_NETKIT_POLICY];
856862 policy = nla_get_u32(attr);
drivers/net/wireless/ath/ath9k/Kconfig+1−3
@@ -57,8 +57,7 @@ config ATH9K_AHB · 56 unmodified lines
5757
5858 config ATH9K_DEBUGFS
5959 bool "Atheros ath9k debugging"
60− depends on ATH9K && DEBUG_FS
61− select MAC80211_DEBUGFS
60+ depends on ATH9K && DEBUG_FS && MAC80211_DEBUGFS
6261 select ATH9K_COMMON_DEBUG
6362 help
6463 Say Y, if you need access to ath9k's statistics for
@@ -70,7 +69,6 @@ config ATH9K_DEBUGFS · 5 unmodified lines
7069 config ATH9K_STATION_STATISTICS
7170 bool "Detailed station statistics"
7271 depends on ATH9K && ATH9K_DEBUGFS && DEBUG_FS
73− select MAC80211_DEBUGFS
7472 default n
7573 help
7674 This option enables detailed statistics for association stations.
drivers/net/wireless/intel/iwlwifi/mvm/mld-sta.c+3−1
@@ -707,8 +707,10 @@ int iwl_mvm_mld_add_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif, · 706 unmodified lines
707707 rcu_dereference_protected(mvm_sta->link[link_id],
708708 lockdep_is_held(&mvm->mutex));
709709
710− if (WARN_ON(!link_conf || !mvm_link_sta))
710+ if (WARN_ON(!link_conf || !mvm_link_sta)) {
711+ ret = -EINVAL;
711712 goto err;
713+ }
712714
713715 ret = iwl_mvm_mld_cfg_sta(mvm, sta, vif, link_sta, link_conf,
714716 mvm_link_sta);
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c+1−0
@@ -375,6 +375,7 @@ static int mt7921_load_clc(struct mt792x_dev *dev, const char *fw_name) · 374 unmodified lines
375375 int ret, i, len, offset = 0;
376376 u8 *clc_base = NULL, hw_encap = 0;
377377
378+ dev->phy.clc_chan_conf = 0xff;
378379 if (mt7921_disable_clc ||
379380 mt76_is_usb(&dev->mt76))
380381 return 0;
drivers/net/wireless/mediatek/mt76/mt7925/main.c+2−2
@@ -14,7 +14,7 @@ · 13 unmodified lines
1414 static void
1515 mt7925_init_he_caps(struct mt792x_phy *phy, enum nl80211_band band,
1616 struct ieee80211_sband_iftype_data *data,
17− enum nl80211_iftype iftype)
17+ enum nl80211_iftype iftype)
1818 {
1919 struct ieee80211_sta_he_cap *he_cap = &data->he_cap;
2020 struct ieee80211_he_cap_elem *he_cap_elem = &he_cap->he_cap_elem;
@@ -53,7 +53,7 @@ mt7925_init_he_caps(struct mt792x_phy *phy, enum nl80211_band band, · 32 unmodified lines
5353 IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO |
5454 IEEE80211_HE_PHY_CAP2_UL_MU_PARTIAL_MU_MIMO;
5555
56− switch (i) {
56+ switch (iftype) {
5757 case NL80211_IFTYPE_AP:
5858 he_cap_elem->mac_cap_info[2] |=
5959 IEEE80211_HE_MAC_CAP2_BSR;
drivers/nvme/host/auth.c+3−2
@@ -757,12 +757,11 @@ static void nvme_queue_auth_work(struct work_struct *work) · 756 unmodified lines
757757 __func__, chap->qid);
758758 mutex_lock(&ctrl->dhchap_auth_mutex);
759759 ret = nvme_auth_dhchap_setup_host_response(ctrl, chap);
760+ mutex_unlock(&ctrl->dhchap_auth_mutex);
760761 if (ret) {
761− mutex_unlock(&ctrl->dhchap_auth_mutex);
762762 chap->error = ret;
763763 goto fail2;
764764 }
765− mutex_unlock(&ctrl->dhchap_auth_mutex);
766765
767766 /* DH-HMAC-CHAP Step 3: send reply */
768767 dev_dbg(ctrl->device, "%s: qid %d send reply\n",
@@ -839,6 +838,8 @@ static void nvme_queue_auth_work(struct work_struct *work) · 70 unmodified lines
839838 }
840839
841840 fail2:
841+ if (chap->status == 0)
842+ chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED;
842843 dev_dbg(ctrl->device, "%s: qid %d send failure2, status %x\n",
843844 __func__, chap->qid, chap->status);
844845 tl = nvme_auth_set_dhchap_failure2_data(ctrl, chap);
drivers/nvme/host/core.c+14−7
@@ -482,7 +482,6 @@ EXPORT_SYMBOL_GPL(nvme_cancel_tagset); · 481 unmodified lines
482482
483483 void nvme_cancel_admin_tagset(struct nvme_ctrl *ctrl)
484484 {
485− nvme_stop_keep_alive(ctrl);
486485 if (ctrl->admin_tagset) {
487486 blk_mq_tagset_busy_iter(ctrl->admin_tagset,
488487 nvme_cancel_request, ctrl);
@@ -1814,16 +1813,18 @@ set_pi: · 1325 unmodified lines
18141813 return ret;
18151814 }
18161815
1817−static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
1816+static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
18181817 {
18191818 struct nvme_ctrl *ctrl = ns->ctrl;
1819+ int ret;
18201820
1821− if (nvme_init_ms(ns, id))
1822− return;
1821+ ret = nvme_init_ms(ns, id);
1822+ if (ret)
1823+ return ret;
18231824
18241825 ns->features &= ~(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS);
18251826 if (!ns->ms || !(ctrl->ops->flags & NVME_F_METADATA_SUPPORTED))
1826− return;
1827+ return 0;
18271828
18281829 if (ctrl->ops->flags & NVME_F_FABRICS) {
18291830 /*
@@ -1832,7 +1833,7 @@ static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id) · 2 unmodified lines
18321833 * remap the separate metadata buffer from the block layer.
18331834 */
18341835 if (WARN_ON_ONCE(!(id->flbas & NVME_NS_FLBAS_META_EXT)))
1835− return;
1836+ return 0;
18361837
18371838 ns->features |= NVME_NS_EXT_LBAS;
18381839
@@ -1859,6 +1860,7 @@ static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id) · 20 unmodified lines
18591860 else
18601861 ns->features |= NVME_NS_METADATA_SUPPORTED;
18611862 }
1863+ return 0;
18621864 }
18631865
18641866 static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
@@ -2032,7 +2034,11 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, · 167 unmodified lines
20322034 ns->lba_shift = id->lbaf[lbaf].ds;
20332035 nvme_set_queue_limits(ns->ctrl, ns->queue);
20342036
2035− nvme_configure_metadata(ns, id);
2037+ ret = nvme_configure_metadata(ns, id);
2038+ if (ret < 0) {
2039+ blk_mq_unfreeze_queue(ns->disk->queue);
2040+ goto out;
2041+ }
20362042 nvme_set_chunk_sectors(ns, id);
20372043 nvme_update_disk_info(ns->disk, ns, id);
20382044
@@ -4348,6 +4354,7 @@ void nvme_stop_ctrl(struct nvme_ctrl *ctrl) · 2309 unmodified lines
43484354 {
43494355 nvme_mpath_stop(ctrl);
43504356 nvme_auth_stop(ctrl);
4357+ nvme_stop_keep_alive(ctrl);
43514358 nvme_stop_failfast_work(ctrl);
43524359 flush_work(&ctrl->async_event_work);
43534360 cancel_work_sync(&ctrl->fw_act_work);
drivers/nvme/host/fabrics.c+2−0
@@ -667,8 +667,10 @@ static const match_table_t opt_tokens = { · 666 unmodified lines
667667 #endif
668668 { NVMF_OPT_FAIL_FAST_TMO, "fast_io_fail_tmo=%d" },
669669 { NVMF_OPT_DISCOVERY, "discovery" },
670+#ifdef CONFIG_NVME_HOST_AUTH
670671 { NVMF_OPT_DHCHAP_SECRET, "dhchap_secret=%s" },
671672 { NVMF_OPT_DHCHAP_CTRL_SECRET, "dhchap_ctrl_secret=%s" },
673+#endif
672674 #ifdef CONFIG_NVME_TCP_TLS
673675 { NVMF_OPT_TLS, "tls" },
674676 #endif
drivers/nvme/host/fc.c+8−11
@@ -2530,12 +2530,6 @@ __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues) · 2529 unmodified lines
25302530 * clean up the admin queue. Same thing as above.
25312531 */
25322532 nvme_quiesce_admin_queue(&ctrl->ctrl);
2533−
2534− /*
2535− * Open-coding nvme_cancel_admin_tagset() as fc
2536− * is not using nvme_cancel_request().
2537− */
2538− nvme_stop_keep_alive(&ctrl->ctrl);
25392533 blk_sync_queue(ctrl->ctrl.admin_q);
25402534 blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
25412535 nvme_fc_terminate_exchange, &ctrl->ctrl);
@@ -3138,11 +3132,12 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl) · 596 unmodified lines
31383132 nvme_unquiesce_admin_queue(&ctrl->ctrl);
31393133
31403134 ret = nvme_init_ctrl_finish(&ctrl->ctrl, false);
3141− if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags))
3142− ret = -EIO;
31433135 if (ret)
31443136 goto out_disconnect_admin_queue;
3145−
3137+ if (test_bit(ASSOC_FAILED, &ctrl->flags)) {
3138+ ret = -EIO;
3139+ goto out_stop_keep_alive;
3140+ }
31463141 /* sanity checks */
31473142
31483143 /* FC-NVME does not have other data in the capsule */
@@ -3150,7 +3145,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl) · 1 unmodified line
31503145 dev_err(ctrl->ctrl.device, "icdoff %d is not supported!\n",
31513146 ctrl->ctrl.icdoff);
31523147 ret = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
3153− goto out_disconnect_admin_queue;
3148+ goto out_stop_keep_alive;
31543149 }
31553150
31563151 /* FC-NVME supports normal SGL Data Block Descriptors */
@@ -3158,7 +3153,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl) · 1 unmodified line
31583153 dev_err(ctrl->ctrl.device,
31593154 "Mandatory sgls are not supported!\n");
31603155 ret = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
3161− goto out_disconnect_admin_queue;
3156+ goto out_stop_keep_alive;
31623157 }
31633158
31643159 if (opts->queue_size > ctrl->ctrl.maxcmd) {
@@ -3205,6 +3200,8 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl) · 40 unmodified lines
32053200
32063201 out_term_aen_ops:
32073202 nvme_fc_term_aen_ops(ctrl);
3203+out_stop_keep_alive:
3204+ nvme_stop_keep_alive(&ctrl->ctrl);
32083205 out_disconnect_admin_queue:
32093206 dev_warn(ctrl->ctrl.device,
32103207 "NVME-FC{%d}: create_assoc failed, assoc_id %llx ret %d\n",
drivers/nvme/host/rdma.c+1−0
@@ -1080,6 +1080,7 @@ destroy_io: · 1079 unmodified lines
10801080 nvme_rdma_free_io_queues(ctrl);
10811081 }
10821082 destroy_admin:
1083+ nvme_stop_keep_alive(&ctrl->ctrl);
10831084 nvme_quiesce_admin_queue(&ctrl->ctrl);
10841085 blk_sync_queue(ctrl->ctrl.admin_q);
10851086 nvme_rdma_stop_queue(&ctrl->queues[0]);
drivers/nvme/host/tcp.c+15−17
@@ -36,11 +36,11 @@ static int so_priority; · 35 unmodified lines
3636 module_param(so_priority, int, 0644);
3737 MODULE_PARM_DESC(so_priority, "nvme tcp socket optimize priority");
3838
39−#ifdef CONFIG_NVME_TCP_TLS
4039 /*
4140 * TLS handshake timeout
4241 */
4342 static int tls_handshake_timeout = 10;
43+#ifdef CONFIG_NVME_TCP_TLS
4444 module_param(tls_handshake_timeout, int, 0644);
4545 MODULE_PARM_DESC(tls_handshake_timeout,
4646 "nvme TLS handshake timeout in seconds (default 10)");
@@ -161,10 +161,8 @@ struct nvme_tcp_queue { · 114 unmodified lines
161161 struct ahash_request *snd_hash;
162162 __le32 exp_ddgst;
163163 __le32 recv_ddgst;
164−#ifdef CONFIG_NVME_TCP_TLS
165164 struct completion tls_complete;
166165 int tls_err;
167−#endif
168166 struct page_frag_cache pf_cache;
169167
170168 void (*state_change)(struct sock *);
@@ -207,6 +205,14 @@ static inline int nvme_tcp_queue_id(struct nvme_tcp_queue *queue) · 36 unmodified lines
207205 return queue - queue->ctrl->queues;
208206 }
209207
208+static inline bool nvme_tcp_tls(struct nvme_ctrl *ctrl)
209+{
210+ if (!IS_ENABLED(CONFIG_NVME_TCP_TLS))
211+ return 0;
212+
213+ return ctrl->opts->tls;
214+}
215+
210216 static inline struct blk_mq_tags *nvme_tcp_tagset(struct nvme_tcp_queue *queue)
211217 {
212218 u32 queue_idx = nvme_tcp_queue_id(queue);
@@ -1412,7 +1418,7 @@ static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue) · 1199 unmodified lines
14121418 memset(&msg, 0, sizeof(msg));
14131419 iov.iov_base = icresp;
14141420 iov.iov_len = sizeof(*icresp);
1415− if (queue->ctrl->ctrl.opts->tls) {
1421+ if (nvme_tcp_tls(&queue->ctrl->ctrl)) {
14161422 msg.msg_control = cbuf;
14171423 msg.msg_controllen = sizeof(cbuf);
14181424 }
@@ -1424,7 +1430,7 @@ static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue) · 5 unmodified lines
14241430 goto free_icresp;
14251431 }
14261432 ret = -ENOTCONN;
1427− if (queue->ctrl->ctrl.opts->tls) {
1433+ if (nvme_tcp_tls(&queue->ctrl->ctrl)) {
14281434 ctype = tls_get_record_type(queue->sock->sk,
14291435 (struct cmsghdr *)cbuf);
14301436 if (ctype != TLS_RECORD_TYPE_DATA) {
@@ -1548,7 +1554,6 @@ static void nvme_tcp_set_queue_io_cpu(struct nvme_tcp_queue *queue) · 117 unmodified lines
15481554 queue->io_cpu = cpumask_next_wrap(n - 1, cpu_online_mask, -1, false);
15491555 }
15501556
1551−#ifdef CONFIG_NVME_TCP_TLS
15521557 static void nvme_tcp_tls_done(void *data, int status, key_serial_t pskid)
15531558 {
15541559 struct nvme_tcp_queue *queue = data;
@@ -1625,14 +1630,6 @@ static int nvme_tcp_start_tls(struct nvme_ctrl *nctrl, · 70 unmodified lines
16251630 }
16261631 return ret;
16271632 }
1628−#else
1629−static int nvme_tcp_start_tls(struct nvme_ctrl *nctrl,
1630− struct nvme_tcp_queue *queue,
1631− key_serial_t pskid)
1632−{
1633− return -EPROTONOSUPPORT;
1634−}
1635−#endif
16361633
16371634 static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid,
16381635 key_serial_t pskid)
@@ -1759,7 +1756,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid, · 120 unmodified lines
17591756 }
17601757
17611758 /* If PSKs are configured try to start TLS */
1762− if (pskid) {
1759+ if (IS_ENABLED(CONFIG_NVME_TCP_TLS) && pskid) {
17631760 ret = nvme_tcp_start_tls(nctrl, queue, pskid);
17641761 if (ret)
17651762 goto err_init_connect;
@@ -1916,7 +1913,7 @@ static int nvme_tcp_alloc_admin_queue(struct nvme_ctrl *ctrl) · 150 unmodified lines
19161913 int ret;
19171914 key_serial_t pskid = 0;
19181915
1919− if (ctrl->opts->tls) {
1916+ if (nvme_tcp_tls(ctrl)) {
19201917 if (ctrl->opts->tls_key)
19211918 pskid = key_serial(ctrl->opts->tls_key);
19221919 else
@@ -1949,7 +1946,7 @@ static int __nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl) · 26 unmodified lines
19491946 {
19501947 int i, ret;
19511948
1952− if (ctrl->opts->tls && !ctrl->tls_key) {
1949+ if (nvme_tcp_tls(ctrl) && !ctrl->tls_key) {
19531950 dev_err(ctrl->device, "no PSK negotiated\n");
19541951 return -ENOKEY;
19551952 }
@@ -2237,6 +2234,7 @@ destroy_io: · 281 unmodified lines
22372234 nvme_tcp_destroy_io_queues(ctrl, new);
22382235 }
22392236 destroy_admin:
2237+ nvme_stop_keep_alive(ctrl);
22402238 nvme_tcp_teardown_admin_queue(ctrl, false);
22412239 return ret;
22422240 }
drivers/nvme/target/Kconfig+2−2
@@ -4,6 +4,8 @@ config NVME_TARGET · 3 unmodified lines
44 tristate "NVMe Target support"
55 depends on BLOCK
66 depends on CONFIGFS_FS
7+ select NVME_KEYRING if NVME_TARGET_TCP_TLS
8+ select KEYS if NVME_TARGET_TCP_TLS
79 select BLK_DEV_INTEGRITY_T10 if BLK_DEV_INTEGRITY
810 select SGL_ALLOC
911 help
@@ -87,9 +89,7 @@ config NVME_TARGET_TCP · 77 unmodified lines
8789 config NVME_TARGET_TCP_TLS
8890 bool "NVMe over Fabrics TCP target TLS encryption support"
8991 depends on NVME_TARGET_TCP
90− select NVME_KEYRING
9192 select NET_HANDSHAKE
92− select KEYS
9393 help
9494 Enables TLS encryption for the NVMe TCP target using the netlink handshake API.
9595
drivers/nvme/target/configfs.c+1−1
@@ -1893,7 +1893,7 @@ static struct config_group *nvmet_ports_make(struct config_group *group, · 1892 unmodified lines
18931893 return ERR_PTR(-ENOMEM);
18941894 }
18951895
1896− if (nvme_keyring_id()) {
1896+ if (IS_ENABLED(CONFIG_NVME_TARGET_TCP_TLS) && nvme_keyring_id()) {
18971897 port->keyring = key_lookup(nvme_keyring_id());
18981898 if (IS_ERR(port->keyring)) {
18991899 pr_warn("NVMe keyring not available, disabling TLS\n");
drivers/nvme/target/fabrics-cmd.c+4−0
@@ -244,6 +244,8 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req) · 243 unmodified lines
244244 goto out;
245245 }
246246
247+ d->subsysnqn[NVMF_NQN_FIELD_LEN - 1] = '\0';
248+ d->hostnqn[NVMF_NQN_FIELD_LEN - 1] = '\0';
247249 status = nvmet_alloc_ctrl(d->subsysnqn, d->hostnqn, req,
248250 le32_to_cpu(c->kato), &ctrl);
249251 if (status)
@@ -313,6 +315,8 @@ static void nvmet_execute_io_connect(struct nvmet_req *req) · 63 unmodified lines
313315 goto out;
314316 }
315317
318+ d->subsysnqn[NVMF_NQN_FIELD_LEN - 1] = '\0';
319+ d->hostnqn[NVMF_NQN_FIELD_LEN - 1] = '\0';
316320 ctrl = nvmet_ctrl_find_get(d->subsysnqn, d->hostnqn,
317321 le16_to_cpu(d->cntlid), req);
318322 if (!ctrl) {
drivers/nvme/target/tcp.c+3−1
@@ -1854,6 +1854,8 @@ static int nvmet_tcp_tls_handshake(struct nvmet_tcp_queue *queue) · 1853 unmodified lines
18541854 }
18551855 return ret;
18561856 }
1857+#else
1858+static void nvmet_tcp_tls_handshake_timeout(struct work_struct *w) {}
18571859 #endif
18581860
18591861 static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port,
@@ -1911,9 +1913,9 @@ static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port, · 51 unmodified lines
19111913 list_add_tail(&queue->queue_list, &nvmet_tcp_queue_list);
19121914 mutex_unlock(&nvmet_tcp_queue_mutex);
19131915
1914−#ifdef CONFIG_NVME_TARGET_TCP_TLS
19151916 INIT_DELAYED_WORK(&queue->tls_handshake_tmo_work,
19161917 nvmet_tcp_tls_handshake_timeout);
1918+#ifdef CONFIG_NVME_TARGET_TCP_TLS
19171919 if (queue->state == NVMET_TCP_Q_TLS_HANDSHAKE) {
19181920 struct sock *sk = queue->sock->sk;
19191921
drivers/phy/Kconfig+0−1
@@ -87,7 +87,6 @@ source "drivers/phy/motorola/Kconfig" · 86 unmodified lines
8787 source "drivers/phy/mscc/Kconfig"
8888 source "drivers/phy/qualcomm/Kconfig"
8989 source "drivers/phy/ralink/Kconfig"
90−source "drivers/phy/realtek/Kconfig"
9190 source "drivers/phy/renesas/Kconfig"
9291 source "drivers/phy/rockchip/Kconfig"
9392 source "drivers/phy/samsung/Kconfig"
drivers/phy/Makefile+0−1
@@ -26,7 +26,6 @@ obj-y += allwinner/ \ · 25 unmodified lines
2626 mscc/ \
2727 qualcomm/ \
2828 ralink/ \
29− realtek/ \
3029 renesas/ \
3130 rockchip/ \
3231 samsung/ \
drivers/phy/realtek/Kconfig+0−32
@@ -1,32 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0
2−#
3−# Phy drivers for Realtek platforms
4−#
5−
6−if ARCH_REALTEK || COMPILE_TEST
7−
8−config PHY_RTK_RTD_USB2PHY
9− tristate "Realtek RTD USB2 PHY Transceiver Driver"
10− depends on USB_SUPPORT
11− select GENERIC_PHY
12− select USB_PHY
13− select USB_COMMON
14− help
15− Enable this to support Realtek SoC USB2 phy transceiver.
16− The DHC (digital home center) RTD series SoCs used the Synopsys
17− DWC3 USB IP. This driver will do the PHY initialization
18− of the parameters.
19−
20−config PHY_RTK_RTD_USB3PHY
21− tristate "Realtek RTD USB3 PHY Transceiver Driver"
22− depends on USB_SUPPORT
23− select GENERIC_PHY
24− select USB_PHY
25− select USB_COMMON
26− help
27− Enable this to support Realtek SoC USB3 phy transceiver.
28− The DHC (digital home center) RTD series SoCs used the Synopsys
29− DWC3 USB IP. This driver will do the PHY initialization
30− of the parameters.
31−
32−endif # ARCH_REALTEK || COMPILE_TEST
drivers/phy/realtek/Makefile+0−3
@@ -1,3 +0,0 @@
1−# SPDX-License-Identifier: GPL-2.0
2−obj-$(CONFIG_PHY_RTK_RTD_USB2PHY) += phy-rtk-usb2.o
3−obj-$(CONFIG_PHY_RTK_RTD_USB3PHY) += phy-rtk-usb3.o
drivers/phy/realtek/phy-rtk-usb2.c+0−1325
@@ -1,1325 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0
2−/*
3− * phy-rtk-usb2.c RTK usb2.0 PHY driver
4− *
5− * Copyright (C) 2023 Realtek Semiconductor Corporation
6− *
7− */
8−
9−#include <linux/module.h>
10−#include <linux/of.h>
11−#include <linux/of_address.h>
12−#include <linux/platform_device.h>
13−#include <linux/uaccess.h>
14−#include <linux/debugfs.h>
15−#include <linux/nvmem-consumer.h>
16−#include <linux/regmap.h>
17−#include <linux/sys_soc.h>
18−#include <linux/mfd/syscon.h>
19−#include <linux/phy/phy.h>
20−#include <linux/usb.h>
21−#include <linux/usb/phy.h>
22−#include <linux/usb/hcd.h>
23−
24−/* GUSB2PHYACCn register */
25−#define PHY_NEW_REG_REQ BIT(25)
26−#define PHY_VSTS_BUSY BIT(23)
27−#define PHY_VCTRL_SHIFT 8
28−#define PHY_REG_DATA_MASK 0xff
29−
30−#define GET_LOW_NIBBLE(addr) ((addr) & 0x0f)
31−#define GET_HIGH_NIBBLE(addr) (((addr) & 0xf0) >> 4)
32−
33−#define EFUS_USB_DC_CAL_RATE 2
34−#define EFUS_USB_DC_CAL_MAX 7
35−
36−#define EFUS_USB_DC_DIS_RATE 1
37−#define EFUS_USB_DC_DIS_MAX 7
38−
39−#define MAX_PHY_DATA_SIZE 20
40−#define OFFEST_PHY_READ 0x20
41−
42−#define MAX_USB_PHY_NUM 4
43−#define MAX_USB_PHY_PAGE0_DATA_SIZE 16
44−#define MAX_USB_PHY_PAGE1_DATA_SIZE 16
45−#define MAX_USB_PHY_PAGE2_DATA_SIZE 8
46−
47−#define SET_PAGE_OFFSET 0xf4
48−#define SET_PAGE_0 0x9b
49−#define SET_PAGE_1 0xbb
50−#define SET_PAGE_2 0xdb
51−
52−#define PAGE_START 0xe0
53−#define PAGE0_0XE4 0xe4
54−#define PAGE0_0XE6 0xe6
55−#define PAGE0_0XE7 0xe7
56−#define PAGE1_0XE0 0xe0
57−#define PAGE1_0XE2 0xe2
58−
59−#define SENSITIVITY_CTRL (BIT(4) | BIT(5) | BIT(6))
60−#define ENABLE_AUTO_SENSITIVITY_CALIBRATION BIT(2)
61−#define DEFAULT_DC_DRIVING_VALUE (0x8)
62−#define DEFAULT_DC_DISCONNECTION_VALUE (0x6)
63−#define HS_CLK_SELECT BIT(6)
64−
65−struct phy_reg {
66− void __iomem *reg_wrap_vstatus;
67− void __iomem *reg_gusb2phyacc0;
68− int vstatus_index;
69−};
70−
71−struct phy_data {
72− u8 addr;
73− u8 data;
74−};
75−
76−struct phy_cfg {
77− int page0_size;
78− struct phy_data page0[MAX_USB_PHY_PAGE0_DATA_SIZE];
79− int page1_size;
80− struct phy_data page1[MAX_USB_PHY_PAGE1_DATA_SIZE];
81− int page2_size;
82− struct phy_data page2[MAX_USB_PHY_PAGE2_DATA_SIZE];
83−
84− int num_phy;
85−
86− bool check_efuse;
87− int check_efuse_version;
88−#define CHECK_EFUSE_V1 1
89−#define CHECK_EFUSE_V2 2
90− int efuse_dc_driving_rate;
91− int efuse_dc_disconnect_rate;
92− int dc_driving_mask;
93− int dc_disconnect_mask;
94− bool usb_dc_disconnect_at_page0;
95− int driving_updated_for_dev_dis;
96−
97− bool do_toggle;
98− bool do_toggle_driving;
99− bool use_default_parameter;
100− bool is_double_sensitivity_mode;
101−};
102−
103−struct phy_parameter {
104− struct phy_reg phy_reg;
105−
106− /* Get from efuse */
107− s8 efuse_usb_dc_cal;
108− s8 efuse_usb_dc_dis;
109−
110− /* Get from dts */
111− bool inverse_hstx_sync_clock;
112− u32 driving_level;
113− s32 driving_level_compensate;
114− s32 disconnection_compensate;
115−};
116−
117−struct rtk_phy {
118− struct usb_phy phy;
119− struct device *dev;
120−
121− struct phy_cfg *phy_cfg;
122− int num_phy;
123− struct phy_parameter *phy_parameter;
124−
125− struct dentry *debug_dir;
126−};
127−
128−/* mapping 0xE0 to 0 ... 0xE7 to 7, 0xF0 to 8 ,,, 0xF7 to 15 */
129−static inline int page_addr_to_array_index(u8 addr)
130−{
131− return (int)((((addr) - PAGE_START) & 0x7) +
132− ((((addr) - PAGE_START) & 0x10) >> 1));
133−}
134−
135−static inline u8 array_index_to_page_addr(int index)
136−{
137− return ((((index) + PAGE_START) & 0x7) +
138− ((((index) & 0x8) << 1) + PAGE_START));
139−}
140−
141−#define PHY_IO_TIMEOUT_USEC (50000)
142−#define PHY_IO_DELAY_US (100)
143−
144−static inline int utmi_wait_register(void __iomem *reg, u32 mask, u32 result)
145−{
146− int ret;
147− unsigned int val;
148−
149− ret = read_poll_timeout(readl, val, ((val & mask) == result),
150− PHY_IO_DELAY_US, PHY_IO_TIMEOUT_USEC, false, reg);
151− if (ret) {
152− pr_err("%s can't program USB phy\n", __func__);
153− return -ETIMEDOUT;
154− }
155−
156− return 0;
157−}
158−
159−static char rtk_phy_read(struct phy_reg *phy_reg, char addr)
160−{
161− void __iomem *reg_gusb2phyacc0 = phy_reg->reg_gusb2phyacc0;
162− unsigned int val;
163− int ret = 0;
164−
165− addr -= OFFEST_PHY_READ;
166−
167− /* polling until VBusy == 0 */
168− ret = utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0);
169− if (ret)
170− return (char)ret;
171−
172− /* VCtrl = low nibble of addr, and set PHY_NEW_REG_REQ */
173− val = PHY_NEW_REG_REQ | (GET_LOW_NIBBLE(addr) << PHY_VCTRL_SHIFT);
174− writel(val, reg_gusb2phyacc0);
175− ret = utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0);
176− if (ret)
177− return (char)ret;
178−
179− /* VCtrl = high nibble of addr, and set PHY_NEW_REG_REQ */
180− val = PHY_NEW_REG_REQ | (GET_HIGH_NIBBLE(addr) << PHY_VCTRL_SHIFT);
181− writel(val, reg_gusb2phyacc0);
182− ret = utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0);
183− if (ret)
184− return (char)ret;
185−
186− val = readl(reg_gusb2phyacc0);
187−
188− return (char)(val & PHY_REG_DATA_MASK);
189−}
190−
191−static int rtk_phy_write(struct phy_reg *phy_reg, char addr, char data)
192−{
193− unsigned int val;
194− void __iomem *reg_wrap_vstatus = phy_reg->reg_wrap_vstatus;
195− void __iomem *reg_gusb2phyacc0 = phy_reg->reg_gusb2phyacc0;
196− int shift_bits = phy_reg->vstatus_index * 8;
197− int ret = 0;
198−
199− /* write data to VStatusOut2 (data output to phy) */
200− writel((u32)data << shift_bits, reg_wrap_vstatus);
201−
202− ret = utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0);
203− if (ret)
204− return ret;
205−
206− /* VCtrl = low nibble of addr, set PHY_NEW_REG_REQ */
207− val = PHY_NEW_REG_REQ | (GET_LOW_NIBBLE(addr) << PHY_VCTRL_SHIFT);
208−
209− writel(val, reg_gusb2phyacc0);
210− ret = utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0);
211− if (ret)
212− return ret;
213−
214− /* VCtrl = high nibble of addr, set PHY_NEW_REG_REQ */
215− val = PHY_NEW_REG_REQ | (GET_HIGH_NIBBLE(addr) << PHY_VCTRL_SHIFT);
216−
217− writel(val, reg_gusb2phyacc0);
218− ret = utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0);
219− if (ret)
220− return ret;
221−
222− return 0;
223−}
224−
225−static int rtk_phy_set_page(struct phy_reg *phy_reg, int page)
226−{
227− switch (page) {
228− case 0:
229− return rtk_phy_write(phy_reg, SET_PAGE_OFFSET, SET_PAGE_0);
230− case 1:
231− return rtk_phy_write(phy_reg, SET_PAGE_OFFSET, SET_PAGE_1);
232− case 2:
233− return rtk_phy_write(phy_reg, SET_PAGE_OFFSET, SET_PAGE_2);
234− default:
235− pr_err("%s error page=%d\n", __func__, page);
236− }
237−
238− return -EINVAL;
239−}
240−
241−static u8 __updated_dc_disconnect_level_page0_0xe4(struct phy_cfg *phy_cfg,
242− struct phy_parameter *phy_parameter, u8 data)
243−{
244− u8 ret;
245− s32 val;
246− s32 dc_disconnect_mask = phy_cfg->dc_disconnect_mask;
247− int offset = 4;
248−
249− val = (s32)((data >> offset) & dc_disconnect_mask)
250− + phy_parameter->efuse_usb_dc_dis
251− + phy_parameter->disconnection_compensate;
252−
253− if (val > dc_disconnect_mask)
254− val = dc_disconnect_mask;
255− else if (val < 0)
256− val = 0;
257−
258− ret = (data & (~(dc_disconnect_mask << offset))) |
259− (val & dc_disconnect_mask) << offset;
260−
261− return ret;
262−}
263−
264−/* updated disconnect level at page0 */
265−static void update_dc_disconnect_level_at_page0(struct rtk_phy *rtk_phy,
266− struct phy_parameter *phy_parameter, bool update)
267−{
268− struct phy_cfg *phy_cfg;
269− struct phy_reg *phy_reg;
270− struct phy_data *phy_data_page;
271− struct phy_data *phy_data;
272− u8 addr, data;
273− int offset = 4;
274− s32 dc_disconnect_mask;
275− int i;
276−
277− phy_cfg = rtk_phy->phy_cfg;
278− phy_reg = &phy_parameter->phy_reg;
279−
280− /* Set page 0 */
281− phy_data_page = phy_cfg->page0;
282− rtk_phy_set_page(phy_reg, 0);
283−
284− i = page_addr_to_array_index(PAGE0_0XE4);
285− phy_data = phy_data_page + i;
286− if (!phy_data->addr) {
287− phy_data->addr = PAGE0_0XE4;
288− phy_data->data = rtk_phy_read(phy_reg, PAGE0_0XE4);
289− }
290−
291− addr = phy_data->addr;
292− data = phy_data->data;
293− dc_disconnect_mask = phy_cfg->dc_disconnect_mask;
294−
295− if (update)
296− data = __updated_dc_disconnect_level_page0_0xe4(phy_cfg, phy_parameter, data);
297− else
298− data = (data & ~(dc_disconnect_mask << offset)) |
299− (DEFAULT_DC_DISCONNECTION_VALUE << offset);
300−
301− if (rtk_phy_write(phy_reg, addr, data))
302− dev_err(rtk_phy->dev,
303− "%s: Error to set page1 parameter addr=0x%x value=0x%x\n",
304− __func__, addr, data);
305−}
306−
307−static u8 __updated_dc_disconnect_level_page1_0xe2(struct phy_cfg *phy_cfg,
308− struct phy_parameter *phy_parameter, u8 data)
309−{
310− u8 ret;
311− s32 val;
312− s32 dc_disconnect_mask = phy_cfg->dc_disconnect_mask;
313−
314− if (phy_cfg->check_efuse_version == CHECK_EFUSE_V1) {
315− val = (s32)(data & dc_disconnect_mask)
316− + phy_parameter->efuse_usb_dc_dis
317− + phy_parameter->disconnection_compensate;
318− } else { /* for CHECK_EFUSE_V2 or no efuse */
319− if (phy_parameter->efuse_usb_dc_dis)
320− val = (s32)(phy_parameter->efuse_usb_dc_dis +
321− phy_parameter->disconnection_compensate);
322− else
323− val = (s32)((data & dc_disconnect_mask) +
324− phy_parameter->disconnection_compensate);
325− }
326−
327− if (val > dc_disconnect_mask)
328− val = dc_disconnect_mask;
329− else if (val < 0)
330− val = 0;
331−
332− ret = (data & (~dc_disconnect_mask)) | (val & dc_disconnect_mask);
333−
334− return ret;
335−}
336−
337−/* updated disconnect level at page1 */
338−static void update_dc_disconnect_level_at_page1(struct rtk_phy *rtk_phy,
339− struct phy_parameter *phy_parameter, bool update)
340−{
341− struct phy_cfg *phy_cfg;
342− struct phy_data *phy_data_page;
343− struct phy_data *phy_data;
344− struct phy_reg *phy_reg;
345− u8 addr, data;
346− s32 dc_disconnect_mask;
347− int i;
348−
349− phy_cfg = rtk_phy->phy_cfg;
350− phy_reg = &phy_parameter->phy_reg;
351−
352− /* Set page 1 */
353− phy_data_page = phy_cfg->page1;
354− rtk_phy_set_page(phy_reg, 1);
355−
356− i = page_addr_to_array_index(PAGE1_0XE2);
357− phy_data = phy_data_page + i;
358− if (!phy_data->addr) {
359− phy_data->addr = PAGE1_0XE2;
360− phy_data->data = rtk_phy_read(phy_reg, PAGE1_0XE2);
361− }
362−
363− addr = phy_data->addr;
364− data = phy_data->data;
365− dc_disconnect_mask = phy_cfg->dc_disconnect_mask;
366−
367− if (update)
368− data = __updated_dc_disconnect_level_page1_0xe2(phy_cfg, phy_parameter, data);
369− else
370− data = (data & ~dc_disconnect_mask) | DEFAULT_DC_DISCONNECTION_VALUE;
371−
372− if (rtk_phy_write(phy_reg, addr, data))
373− dev_err(rtk_phy->dev,
374− "%s: Error to set page1 parameter addr=0x%x value=0x%x\n",
375− __func__, addr, data);
376−}
377−
378−static void update_dc_disconnect_level(struct rtk_phy *rtk_phy,
379− struct phy_parameter *phy_parameter, bool update)
380−{
381− struct phy_cfg *phy_cfg = rtk_phy->phy_cfg;
382−
383− if (phy_cfg->usb_dc_disconnect_at_page0)
384− update_dc_disconnect_level_at_page0(rtk_phy, phy_parameter, update);
385− else
386− update_dc_disconnect_level_at_page1(rtk_phy, phy_parameter, update);
387−}
388−
389−static u8 __update_dc_driving_page0_0xe4(struct phy_cfg *phy_cfg,
390− struct phy_parameter *phy_parameter, u8 data)
391−{
392− s32 driving_level_compensate = phy_parameter->driving_level_compensate;
393− s32 dc_driving_mask = phy_cfg->dc_driving_mask;
394− s32 val;
395− u8 ret;
396−
397− if (phy_cfg->check_efuse_version == CHECK_EFUSE_V1) {
398− val = (s32)(data & dc_driving_mask) + driving_level_compensate
399− + phy_parameter->efuse_usb_dc_cal;
400− } else { /* for CHECK_EFUSE_V2 or no efuse */
401− if (phy_parameter->efuse_usb_dc_cal)
402− val = (s32)((phy_parameter->efuse_usb_dc_cal & dc_driving_mask)
403− + driving_level_compensate);
404− else
405− val = (s32)(data & dc_driving_mask);
406− }
407−
408− if (val > dc_driving_mask)
409− val = dc_driving_mask;
410− else if (val < 0)
411− val = 0;
412−
413− ret = (data & (~dc_driving_mask)) | (val & dc_driving_mask);
414−
415− return ret;
416−}
417−
418−static void update_dc_driving_level(struct rtk_phy *rtk_phy,
419− struct phy_parameter *phy_parameter)
420−{
421− struct phy_cfg *phy_cfg;
422− struct phy_reg *phy_reg;
423−
424− phy_reg = &phy_parameter->phy_reg;
425− phy_cfg = rtk_phy->phy_cfg;
426− if (!phy_cfg->page0[4].addr) {
427− rtk_phy_set_page(phy_reg, 0);
428− phy_cfg->page0[4].addr = PAGE0_0XE4;
429− phy_cfg->page0[4].data = rtk_phy_read(phy_reg, PAGE0_0XE4);
430− }
431−
432− if (phy_parameter->driving_level != DEFAULT_DC_DRIVING_VALUE) {
433− u32 dc_driving_mask;
434− u8 driving_level;
435− u8 data;
436−
437− data = phy_cfg->page0[4].data;
438− dc_driving_mask = phy_cfg->dc_driving_mask;
439− driving_level = data & dc_driving_mask;
440−
441− dev_dbg(rtk_phy->dev, "%s driving_level=%d => dts driving_level=%d\n",
442− __func__, driving_level, phy_parameter->driving_level);
443−
444− phy_cfg->page0[4].data = (data & (~dc_driving_mask)) |
445− (phy_parameter->driving_level & dc_driving_mask);
446− }
447−
448− phy_cfg->page0[4].data = __update_dc_driving_page0_0xe4(phy_cfg,
449− phy_parameter,
450− phy_cfg->page0[4].data);
451−}
452−
453−static void update_hs_clk_select(struct rtk_phy *rtk_phy,
454− struct phy_parameter *phy_parameter)
455−{
456− struct phy_cfg *phy_cfg;
457− struct phy_reg *phy_reg;
458−
459− phy_cfg = rtk_phy->phy_cfg;
460− phy_reg = &phy_parameter->phy_reg;
461−
462− if (phy_parameter->inverse_hstx_sync_clock) {
463− if (!phy_cfg->page0[6].addr) {
464− rtk_phy_set_page(phy_reg, 0);
465− phy_cfg->page0[6].addr = PAGE0_0XE6;
466− phy_cfg->page0[6].data = rtk_phy_read(phy_reg, PAGE0_0XE6);
467− }
468−
469− phy_cfg->page0[6].data = phy_cfg->page0[6].data | HS_CLK_SELECT;
470− }
471−}
472−
473−static void do_rtk_phy_toggle(struct rtk_phy *rtk_phy,
474− int index, bool connect)
475−{
476− struct phy_parameter *phy_parameter;
477− struct phy_cfg *phy_cfg;
478− struct phy_reg *phy_reg;
479− struct phy_data *phy_data_page;
480− u8 addr, data;
481− int i;
482−
483− phy_cfg = rtk_phy->phy_cfg;
484− phy_parameter = &((struct phy_parameter *)rtk_phy->phy_parameter)[index];
485− phy_reg = &phy_parameter->phy_reg;
486−
487− if (!phy_cfg->do_toggle)
488− goto out;
489−
490− if (phy_cfg->is_double_sensitivity_mode)
491− goto do_toggle_driving;
492−
493− /* Set page 0 */
494− rtk_phy_set_page(phy_reg, 0);
495−
496− addr = PAGE0_0XE7;
497− data = rtk_phy_read(phy_reg, addr);
498−
499− if (connect)
500− rtk_phy_write(phy_reg, addr, data & (~SENSITIVITY_CTRL));
501− else
502− rtk_phy_write(phy_reg, addr, data | (SENSITIVITY_CTRL));
503−
504−do_toggle_driving:
505−
506− if (!phy_cfg->do_toggle_driving)
507− goto do_toggle;
508−
509− /* Page 0 addr 0xE4 driving capability */
510−
511− /* Set page 0 */
512− phy_data_page = phy_cfg->page0;
513− rtk_phy_set_page(phy_reg, 0);
514−
515− i = page_addr_to_array_index(PAGE0_0XE4);
516− addr = phy_data_page[i].addr;
517− data = phy_data_page[i].data;
518−
519− if (connect) {
520− rtk_phy_write(phy_reg, addr, data);
521− } else {
522− u8 value;
523− s32 tmp;
524− s32 driving_updated =
525− phy_cfg->driving_updated_for_dev_dis;
526− s32 dc_driving_mask = phy_cfg->dc_driving_mask;
527−
528− tmp = (s32)(data & dc_driving_mask) + driving_updated;
529−
530− if (tmp > dc_driving_mask)
531− tmp = dc_driving_mask;
532− else if (tmp < 0)
533− tmp = 0;
534−
535− value = (data & (~dc_driving_mask)) | (tmp & dc_driving_mask);
536−
537− rtk_phy_write(phy_reg, addr, value);
538− }
539−
540−do_toggle:
541− /* restore dc disconnect level before toggle */
542− update_dc_disconnect_level(rtk_phy, phy_parameter, false);
543−
544− /* Set page 1 */
545− rtk_phy_set_page(phy_reg, 1);
546−
547− addr = PAGE1_0XE0;
548− data = rtk_phy_read(phy_reg, addr);
549−
550− rtk_phy_write(phy_reg, addr, data &
551− (~ENABLE_AUTO_SENSITIVITY_CALIBRATION));
552− mdelay(1);
553− rtk_phy_write(phy_reg, addr, data |
554− (ENABLE_AUTO_SENSITIVITY_CALIBRATION));
555−
556− /* update dc disconnect level after toggle */
557− update_dc_disconnect_level(rtk_phy, phy_parameter, true);
558−
559−out:
560− return;
561−}
562−
563−static int do_rtk_phy_init(struct rtk_phy *rtk_phy, int index)
564−{
565− struct phy_parameter *phy_parameter;
566− struct phy_cfg *phy_cfg;
567− struct phy_data *phy_data_page;
568− struct phy_reg *phy_reg;
569− int i;
570−
571− phy_cfg = rtk_phy->phy_cfg;
572− phy_parameter = &((struct phy_parameter *)rtk_phy->phy_parameter)[index];
573− phy_reg = &phy_parameter->phy_reg;
574−
575− if (phy_cfg->use_default_parameter) {
576− dev_dbg(rtk_phy->dev, "%s phy#%d use default parameter\n",
577− __func__, index);
578− goto do_toggle;
579− }
580−
581− /* Set page 0 */
582− phy_data_page = phy_cfg->page0;
583− rtk_phy_set_page(phy_reg, 0);
584−
585− for (i = 0; i < phy_cfg->page0_size; i++) {
586− struct phy_data *phy_data = phy_data_page + i;
587− u8 addr = phy_data->addr;
588− u8 data = phy_data->data;
589−
590− if (!addr)
591− continue;
592−
593− if (rtk_phy_write(phy_reg, addr, data)) {
594− dev_err(rtk_phy->dev,
595− "%s: Error to set page0 parameter addr=0x%x value=0x%x\n",
596− __func__, addr, data);
597− return -EINVAL;
598− }
599− }
600−
601− /* Set page 1 */
602− phy_data_page = phy_cfg->page1;
603− rtk_phy_set_page(phy_reg, 1);
604−
605− for (i = 0; i < phy_cfg->page1_size; i++) {
606− struct phy_data *phy_data = phy_data_page + i;
607− u8 addr = phy_data->addr;
608− u8 data = phy_data->data;
609−
610− if (!addr)
611− continue;
612−
613− if (rtk_phy_write(phy_reg, addr, data)) {
614− dev_err(rtk_phy->dev,
615− "%s: Error to set page1 parameter addr=0x%x value=0x%x\n",
616− __func__, addr, data);
617− return -EINVAL;
618− }
619− }
620−
621− if (phy_cfg->page2_size == 0)
622− goto do_toggle;
623−
624− /* Set page 2 */
625− phy_data_page = phy_cfg->page2;
626− rtk_phy_set_page(phy_reg, 2);
627−
628− for (i = 0; i < phy_cfg->page2_size; i++) {
629− struct phy_data *phy_data = phy_data_page + i;
630− u8 addr = phy_data->addr;
631− u8 data = phy_data->data;
632−
633− if (!addr)
634− continue;
635−
636− if (rtk_phy_write(phy_reg, addr, data)) {
637− dev_err(rtk_phy->dev,
638− "%s: Error to set page2 parameter addr=0x%x value=0x%x\n",
639− __func__, addr, data);
640− return -EINVAL;
641− }
642− }
643−
644−do_toggle:
645− do_rtk_phy_toggle(rtk_phy, index, false);
646−
647− return 0;
648−}
649−
650−static int rtk_phy_init(struct phy *phy)
651−{
652− struct rtk_phy *rtk_phy = phy_get_drvdata(phy);
653− unsigned long phy_init_time = jiffies;
654− int i, ret = 0;
655−
656− if (!rtk_phy)
657− return -EINVAL;
658−
659− for (i = 0; i < rtk_phy->num_phy; i++)
660− ret = do_rtk_phy_init(rtk_phy, i);
661−
662− dev_dbg(rtk_phy->dev, "Initialized RTK USB 2.0 PHY (take %dms)\n",
663− jiffies_to_msecs(jiffies - phy_init_time));
664− return ret;
665−}
666−
667−static int rtk_phy_exit(struct phy *phy)
668−{
669− return 0;
670−}
671−
672−static const struct phy_ops ops = {
673− .init = rtk_phy_init,
674− .exit = rtk_phy_exit,
675− .owner = THIS_MODULE,
676−};
677−
678−static void rtk_phy_toggle(struct usb_phy *usb2_phy, bool connect, int port)
679−{
680− int index = port;
681− struct rtk_phy *rtk_phy = NULL;
682−
683− rtk_phy = dev_get_drvdata(usb2_phy->dev);
684−
685− if (index > rtk_phy->num_phy) {
686− dev_err(rtk_phy->dev, "%s: The port=%d is not in usb phy (num_phy=%d)\n",
687− __func__, index, rtk_phy->num_phy);
688− return;
689− }
690−
691− do_rtk_phy_toggle(rtk_phy, index, connect);
692−}
693−
694−static int rtk_phy_notify_port_status(struct usb_phy *x, int port,
695− u16 portstatus, u16 portchange)
696−{
697− bool connect = false;
698−
699− pr_debug("%s port=%d portstatus=0x%x portchange=0x%x\n",
700− __func__, port, (int)portstatus, (int)portchange);
701− if (portstatus & USB_PORT_STAT_CONNECTION)
702− connect = true;
703−
704− if (portchange & USB_PORT_STAT_C_CONNECTION)
705− rtk_phy_toggle(x, connect, port);
706−
707− return 0;
708−}
709−
710−#ifdef CONFIG_DEBUG_FS
711−static struct dentry *create_phy_debug_root(void)
712−{
713− struct dentry *phy_debug_root;
714−
715− phy_debug_root = debugfs_lookup("phy", usb_debug_root);
716− if (!phy_debug_root)
717− phy_debug_root = debugfs_create_dir("phy", usb_debug_root);
718−
719− return phy_debug_root;
720−}
721−
722−static int rtk_usb2_parameter_show(struct seq_file *s, void *unused)
723−{
724− struct rtk_phy *rtk_phy = s->private;
725− struct phy_cfg *phy_cfg;
726− int i, index;
727−
728− phy_cfg = rtk_phy->phy_cfg;
729−
730− seq_puts(s, "Property:\n");
731− seq_printf(s, " check_efuse: %s\n",
732− phy_cfg->check_efuse ? "Enable" : "Disable");
733− seq_printf(s, " check_efuse_version: %d\n",
734− phy_cfg->check_efuse_version);
735− seq_printf(s, " efuse_dc_driving_rate: %d\n",
736− phy_cfg->efuse_dc_driving_rate);
737− seq_printf(s, " dc_driving_mask: 0x%x\n",
738− phy_cfg->dc_driving_mask);
739− seq_printf(s, " efuse_dc_disconnect_rate: %d\n",
740− phy_cfg->efuse_dc_disconnect_rate);
741− seq_printf(s, " dc_disconnect_mask: 0x%x\n",
742− phy_cfg->dc_disconnect_mask);
743− seq_printf(s, " usb_dc_disconnect_at_page0: %s\n",
744− phy_cfg->usb_dc_disconnect_at_page0 ? "true" : "false");
745− seq_printf(s, " do_toggle: %s\n",
746− phy_cfg->do_toggle ? "Enable" : "Disable");
747− seq_printf(s, " do_toggle_driving: %s\n",
748− phy_cfg->do_toggle_driving ? "Enable" : "Disable");
749− seq_printf(s, " driving_updated_for_dev_dis: 0x%x\n",
750− phy_cfg->driving_updated_for_dev_dis);
751− seq_printf(s, " use_default_parameter: %s\n",
752− phy_cfg->use_default_parameter ? "Enable" : "Disable");
753− seq_printf(s, " is_double_sensitivity_mode: %s\n",
754− phy_cfg->is_double_sensitivity_mode ? "Enable" : "Disable");
755−
756− for (index = 0; index < rtk_phy->num_phy; index++) {
757− struct phy_parameter *phy_parameter;
758− struct phy_reg *phy_reg;
759− struct phy_data *phy_data_page;
760−
761− phy_parameter = &((struct phy_parameter *)rtk_phy->phy_parameter)[index];
762− phy_reg = &phy_parameter->phy_reg;
763−
764− seq_printf(s, "PHY %d:\n", index);
765−
766− seq_puts(s, "Page 0:\n");
767− /* Set page 0 */
768− phy_data_page = phy_cfg->page0;
769− rtk_phy_set_page(phy_reg, 0);
770−
771− for (i = 0; i < phy_cfg->page0_size; i++) {
772− struct phy_data *phy_data = phy_data_page + i;
773− u8 addr = array_index_to_page_addr(i);
774− u8 data = phy_data->data;
775− u8 value = rtk_phy_read(phy_reg, addr);
776−
777− if (phy_data->addr)
778− seq_printf(s, " Page 0: addr=0x%x data=0x%02x ==> read value=0x%02x\n",
779− addr, data, value);
780− else
781− seq_printf(s, " Page 0: addr=0x%x data=none ==> read value=0x%02x\n",
782− addr, value);
783− }
784−
785− seq_puts(s, "Page 1:\n");
786− /* Set page 1 */
787− phy_data_page = phy_cfg->page1;
788− rtk_phy_set_page(phy_reg, 1);
789−
790− for (i = 0; i < phy_cfg->page1_size; i++) {
791− struct phy_data *phy_data = phy_data_page + i;
792− u8 addr = array_index_to_page_addr(i);
793− u8 data = phy_data->data;
794− u8 value = rtk_phy_read(phy_reg, addr);
795−
796− if (phy_data->addr)
797− seq_printf(s, " Page 1: addr=0x%x data=0x%02x ==> read value=0x%02x\n",
798− addr, data, value);
799− else
800− seq_printf(s, " Page 1: addr=0x%x data=none ==> read value=0x%02x\n",
801− addr, value);
802− }
803−
804− if (phy_cfg->page2_size == 0)
805− goto out;
806−
807− seq_puts(s, "Page 2:\n");
808− /* Set page 2 */
809− phy_data_page = phy_cfg->page2;
810− rtk_phy_set_page(phy_reg, 2);
811−
812− for (i = 0; i < phy_cfg->page2_size; i++) {
813− struct phy_data *phy_data = phy_data_page + i;
814− u8 addr = array_index_to_page_addr(i);
815− u8 data = phy_data->data;
816− u8 value = rtk_phy_read(phy_reg, addr);
817−
818− if (phy_data->addr)
819− seq_printf(s, " Page 2: addr=0x%x data=0x%02x ==> read value=0x%02x\n",
820− addr, data, value);
821− else
822− seq_printf(s, " Page 2: addr=0x%x data=none ==> read value=0x%02x\n",
823− addr, value);
824− }
825−
826−out:
827− seq_puts(s, "PHY Property:\n");
828− seq_printf(s, " efuse_usb_dc_cal: %d\n",
829− (int)phy_parameter->efuse_usb_dc_cal);
830− seq_printf(s, " efuse_usb_dc_dis: %d\n",
831− (int)phy_parameter->efuse_usb_dc_dis);
832− seq_printf(s, " inverse_hstx_sync_clock: %s\n",
833− phy_parameter->inverse_hstx_sync_clock ? "Enable" : "Disable");
834− seq_printf(s, " driving_level: %d\n",
835− phy_parameter->driving_level);
836− seq_printf(s, " driving_level_compensate: %d\n",
837− phy_parameter->driving_level_compensate);
838− seq_printf(s, " disconnection_compensate: %d\n",
839− phy_parameter->disconnection_compensate);
840− }
841−
842− return 0;
843−}
844−DEFINE_SHOW_ATTRIBUTE(rtk_usb2_parameter);
845−
846−static inline void create_debug_files(struct rtk_phy *rtk_phy)
847−{
848− struct dentry *phy_debug_root = NULL;
849−
850− phy_debug_root = create_phy_debug_root();
851− if (!phy_debug_root)
852− return;
853−
854− rtk_phy->debug_dir = debugfs_create_dir(dev_name(rtk_phy->dev),
855− phy_debug_root);
856−
857− debugfs_create_file("parameter", 0444, rtk_phy->debug_dir, rtk_phy,
858− &rtk_usb2_parameter_fops);
859−
860− return;
861−}
862−
863−static inline void remove_debug_files(struct rtk_phy *rtk_phy)
864−{
865− debugfs_remove_recursive(rtk_phy->debug_dir);
866−}
867−#else
868−static inline void create_debug_files(struct rtk_phy *rtk_phy) { }
869−static inline void remove_debug_files(struct rtk_phy *rtk_phy) { }
870−#endif /* CONFIG_DEBUG_FS */
871−
872−static int get_phy_data_by_efuse(struct rtk_phy *rtk_phy,
873− struct phy_parameter *phy_parameter, int index)
874−{
875− struct phy_cfg *phy_cfg = rtk_phy->phy_cfg;
876− u8 value = 0;
877− struct nvmem_cell *cell;
878− struct soc_device_attribute rtk_soc_groot[] = {
879− { .family = "Realtek Groot",},
880− { /* empty */ } };
881−
882− if (!phy_cfg->check_efuse)
883− goto out;
884−
885− /* Read efuse for usb dc cal */
886− cell = nvmem_cell_get(rtk_phy->dev, "usb-dc-cal");
887− if (IS_ERR(cell)) {
888− dev_dbg(rtk_phy->dev, "%s no usb-dc-cal: %ld\n",
889− __func__, PTR_ERR(cell));
890− } else {
891− unsigned char *buf;
892− size_t buf_size;
893−
894− buf = nvmem_cell_read(cell, &buf_size);
895− if (!IS_ERR(buf)) {
896− value = buf[0] & phy_cfg->dc_driving_mask;
897− kfree(buf);
898− }
899− nvmem_cell_put(cell);
900− }
901−
902− if (phy_cfg->check_efuse_version == CHECK_EFUSE_V1) {
903− int rate = phy_cfg->efuse_dc_driving_rate;
904−
905− if (value <= EFUS_USB_DC_CAL_MAX)
906− phy_parameter->efuse_usb_dc_cal = (int8_t)(value * rate);
907− else
908− phy_parameter->efuse_usb_dc_cal = -(int8_t)
909− ((EFUS_USB_DC_CAL_MAX & value) * rate);
910−
911− if (soc_device_match(rtk_soc_groot)) {
912− dev_dbg(rtk_phy->dev, "For groot IC we need a workaround to adjust efuse_usb_dc_cal\n");
913−
914− /* We don't multiple dc_cal_rate=2 for positive dc cal compensate */
915− if (value <= EFUS_USB_DC_CAL_MAX)
916− phy_parameter->efuse_usb_dc_cal = (int8_t)(value);
917−
918− /* We set max dc cal compensate is 0x8 if otp is 0x7 */
919− if (value == 0x7)
920− phy_parameter->efuse_usb_dc_cal = (int8_t)(value + 1);
921− }
922− } else { /* for CHECK_EFUSE_V2 */
923− phy_parameter->efuse_usb_dc_cal = value & phy_cfg->dc_driving_mask;
924− }
925−
926− /* Read efuse for usb dc disconnect level */
927− value = 0;
928− cell = nvmem_cell_get(rtk_phy->dev, "usb-dc-dis");
929− if (IS_ERR(cell)) {
930− dev_dbg(rtk_phy->dev, "%s no usb-dc-dis: %ld\n",
931− __func__, PTR_ERR(cell));
932− } else {
933− unsigned char *buf;
934− size_t buf_size;
935−
936− buf = nvmem_cell_read(cell, &buf_size);
937− if (!IS_ERR(buf)) {
938− value = buf[0] & phy_cfg->dc_disconnect_mask;
939− kfree(buf);
940− }
941− nvmem_cell_put(cell);
942− }
943−
944− if (phy_cfg->check_efuse_version == CHECK_EFUSE_V1) {
945− int rate = phy_cfg->efuse_dc_disconnect_rate;
946−
947− if (value <= EFUS_USB_DC_DIS_MAX)
948− phy_parameter->efuse_usb_dc_dis = (int8_t)(value * rate);
949− else
950− phy_parameter->efuse_usb_dc_dis = -(int8_t)
951− ((EFUS_USB_DC_DIS_MAX & value) * rate);
952− } else { /* for CHECK_EFUSE_V2 */
953− phy_parameter->efuse_usb_dc_dis = value & phy_cfg->dc_disconnect_mask;
954− }
955−
956−out:
957− return 0;
958−}
959−
960−static int parse_phy_data(struct rtk_phy *rtk_phy)
961−{
962− struct device *dev = rtk_phy->dev;
963− struct device_node *np = dev->of_node;
964− struct phy_parameter *phy_parameter;
965− int ret = 0;
966− int index;
967−
968− rtk_phy->phy_parameter = devm_kzalloc(dev, sizeof(struct phy_parameter) *
969− rtk_phy->num_phy, GFP_KERNEL);
970− if (!rtk_phy->phy_parameter)
971− return -ENOMEM;
972−
973− for (index = 0; index < rtk_phy->num_phy; index++) {
974− phy_parameter = &((struct phy_parameter *)rtk_phy->phy_parameter)[index];
975−
976− phy_parameter->phy_reg.reg_wrap_vstatus = of_iomap(np, 0);
977− phy_parameter->phy_reg.reg_gusb2phyacc0 = of_iomap(np, 1) + index;
978− phy_parameter->phy_reg.vstatus_index = index;
979−
980− if (of_property_read_bool(np, "realtek,inverse-hstx-sync-clock"))
981− phy_parameter->inverse_hstx_sync_clock = true;
982− else
983− phy_parameter->inverse_hstx_sync_clock = false;
984−
985− if (of_property_read_u32_index(np, "realtek,driving-level",
986− index, &phy_parameter->driving_level))
987− phy_parameter->driving_level = DEFAULT_DC_DRIVING_VALUE;
988−
989− if (of_property_read_u32_index(np, "realtek,driving-level-compensate",
990− index, &phy_parameter->driving_level_compensate))
991− phy_parameter->driving_level_compensate = 0;
992−
993− if (of_property_read_u32_index(np, "realtek,disconnection-compensate",
994− index, &phy_parameter->disconnection_compensate))
995− phy_parameter->disconnection_compensate = 0;
996−
997− get_phy_data_by_efuse(rtk_phy, phy_parameter, index);
998−
999− update_dc_driving_level(rtk_phy, phy_parameter);
1000−
1001− update_hs_clk_select(rtk_phy, phy_parameter);
1002− }
1003−
1004− return ret;
1005−}
1006−
1007−static int rtk_usb2phy_probe(struct platform_device *pdev)
1008−{
1009− struct rtk_phy *rtk_phy;
1010− struct device *dev = &pdev->dev;
1011− struct phy *generic_phy;
1012− struct phy_provider *phy_provider;
1013− const struct phy_cfg *phy_cfg;
1014− int ret = 0;
1015−
1016− phy_cfg = of_device_get_match_data(dev);
1017− if (!phy_cfg) {
1018− dev_err(dev, "phy config are not assigned!\n");
1019− return -EINVAL;
1020− }
1021−
1022− rtk_phy = devm_kzalloc(dev, sizeof(*rtk_phy), GFP_KERNEL);
1023− if (!rtk_phy)
1024− return -ENOMEM;
1025−
1026− rtk_phy->dev = &pdev->dev;
1027− rtk_phy->phy.dev = rtk_phy->dev;
1028− rtk_phy->phy.label = "rtk-usb2phy";
1029− rtk_phy->phy.notify_port_status = rtk_phy_notify_port_status;
1030−
1031− rtk_phy->phy_cfg = devm_kzalloc(dev, sizeof(*phy_cfg), GFP_KERNEL);
1032−
1033− memcpy(rtk_phy->phy_cfg, phy_cfg, sizeof(*phy_cfg));
1034−
1035− rtk_phy->num_phy = phy_cfg->num_phy;
1036−
1037− ret = parse_phy_data(rtk_phy);
1038− if (ret)
1039− goto err;
1040−
1041− platform_set_drvdata(pdev, rtk_phy);
1042−
1043− generic_phy = devm_phy_create(rtk_phy->dev, NULL, &ops);
1044− if (IS_ERR(generic_phy))
1045− return PTR_ERR(generic_phy);
1046−
1047− phy_set_drvdata(generic_phy, rtk_phy);
1048−
1049− phy_provider = devm_of_phy_provider_register(rtk_phy->dev,
1050− of_phy_simple_xlate);
1051− if (IS_ERR(phy_provider))
1052− return PTR_ERR(phy_provider);
1053−
1054− ret = usb_add_phy_dev(&rtk_phy->phy);
1055− if (ret)
1056− goto err;
1057−
1058− create_debug_files(rtk_phy);
1059−
1060−err:
1061− return ret;
1062−}
1063−
1064−static void rtk_usb2phy_remove(struct platform_device *pdev)
1065−{
1066− struct rtk_phy *rtk_phy = platform_get_drvdata(pdev);
1067−
1068− remove_debug_files(rtk_phy);
1069−
1070− usb_remove_phy(&rtk_phy->phy);
1071−}
1072−
1073−static const struct phy_cfg rtd1295_phy_cfg = {
1074− .page0_size = MAX_USB_PHY_PAGE0_DATA_SIZE,
1075− .page0 = { [0] = {0xe0, 0x90},
1076− [3] = {0xe3, 0x3a},
1077− [4] = {0xe4, 0x68},
1078− [6] = {0xe6, 0x91},
1079− [13] = {0xf5, 0x81},
1080− [15] = {0xf7, 0x02}, },
1081− .page1_size = 8,
1082− .page1 = { /* default parameter */ },
1083− .page2_size = 0,
1084− .page2 = { /* no parameter */ },
1085− .num_phy = 1,
1086− .check_efuse = false,
1087− .check_efuse_version = CHECK_EFUSE_V1,
1088− .efuse_dc_driving_rate = 1,
1089− .dc_driving_mask = 0xf,
1090− .efuse_dc_disconnect_rate = EFUS_USB_DC_DIS_RATE,
1091− .dc_disconnect_mask = 0xf,
1092− .usb_dc_disconnect_at_page0 = true,
1093− .do_toggle = true,
1094− .do_toggle_driving = false,
1095− .driving_updated_for_dev_dis = 0xf,
1096− .use_default_parameter = false,
1097− .is_double_sensitivity_mode = false,
1098−};
1099−
1100−static const struct phy_cfg rtd1395_phy_cfg = {
1101− .page0_size = MAX_USB_PHY_PAGE0_DATA_SIZE,
1102− .page0 = { [4] = {0xe4, 0xac},
1103− [13] = {0xf5, 0x00},
1104− [15] = {0xf7, 0x02}, },
1105− .page1_size = 8,
1106− .page1 = { /* default parameter */ },
1107− .page2_size = 0,
1108− .page2 = { /* no parameter */ },
1109− .num_phy = 1,
1110− .check_efuse = false,
1111− .check_efuse_version = CHECK_EFUSE_V1,
1112− .efuse_dc_driving_rate = 1,
1113− .dc_driving_mask = 0xf,
1114− .efuse_dc_disconnect_rate = EFUS_USB_DC_DIS_RATE,
1115− .dc_disconnect_mask = 0xf,
1116− .usb_dc_disconnect_at_page0 = true,
1117− .do_toggle = true,
1118− .do_toggle_driving = false,
1119− .driving_updated_for_dev_dis = 0xf,
1120− .use_default_parameter = false,
1121− .is_double_sensitivity_mode = false,
1122−};
1123−
1124−static const struct phy_cfg rtd1395_phy_cfg_2port = {
1125− .page0_size = MAX_USB_PHY_PAGE0_DATA_SIZE,
1126− .page0 = { [4] = {0xe4, 0xac},
1127− [13] = {0xf5, 0x00},
1128− [15] = {0xf7, 0x02}, },
1129− .page1_size = 8,
1130− .page1 = { /* default parameter */ },
1131− .page2_size = 0,
1132− .page2 = { /* no parameter */ },
1133− .num_phy = 2,
1134− .check_efuse = false,
1135− .check_efuse_version = CHECK_EFUSE_V1,
1136− .efuse_dc_driving_rate = 1,
1137− .dc_driving_mask = 0xf,
1138− .efuse_dc_disconnect_rate = EFUS_USB_DC_DIS_RATE,
1139− .dc_disconnect_mask = 0xf,
1140− .usb_dc_disconnect_at_page0 = true,
1141− .do_toggle = true,
1142− .do_toggle_driving = false,
1143− .driving_updated_for_dev_dis = 0xf,
1144− .use_default_parameter = false,
1145− .is_double_sensitivity_mode = false,
1146−};
1147−
1148−static const struct phy_cfg rtd1619_phy_cfg = {
1149− .page0_size = MAX_USB_PHY_PAGE0_DATA_SIZE,
1150− .page0 = { [4] = {0xe4, 0x68}, },
1151− .page1_size = 8,
1152− .page1 = { /* default parameter */ },
1153− .page2_size = 0,
1154− .page2 = { /* no parameter */ },
1155− .num_phy = 1,
1156− .check_efuse = true,
1157− .check_efuse_version = CHECK_EFUSE_V1,
1158− .efuse_dc_driving_rate = 1,
1159− .dc_driving_mask = 0xf,
1160− .efuse_dc_disconnect_rate = EFUS_USB_DC_DIS_RATE,
1161− .dc_disconnect_mask = 0xf,
1162− .usb_dc_disconnect_at_page0 = true,
1163− .do_toggle = true,
1164− .do_toggle_driving = false,
1165− .driving_updated_for_dev_dis = 0xf,
1166− .use_default_parameter = false,
1167− .is_double_sensitivity_mode = false,
1168−};
1169−
1170−static const struct phy_cfg rtd1319_phy_cfg = {
1171− .page0_size = MAX_USB_PHY_PAGE0_DATA_SIZE,
1172− .page0 = { [0] = {0xe0, 0x18},
1173− [4] = {0xe4, 0x6a},
1174− [7] = {0xe7, 0x71},
1175− [13] = {0xf5, 0x15},
1176− [15] = {0xf7, 0x32}, },
1177− .page1_size = 8,
1178− .page1 = { [3] = {0xe3, 0x44}, },
1179− .page2_size = MAX_USB_PHY_PAGE2_DATA_SIZE,
1180− .page2 = { [0] = {0xe0, 0x01}, },
1181− .num_phy = 1,
1182− .check_efuse = true,
1183− .check_efuse_version = CHECK_EFUSE_V1,
1184− .efuse_dc_driving_rate = 1,
1185− .dc_driving_mask = 0xf,
1186− .efuse_dc_disconnect_rate = EFUS_USB_DC_DIS_RATE,
1187− .dc_disconnect_mask = 0xf,
1188− .usb_dc_disconnect_at_page0 = true,
1189− .do_toggle = true,
1190− .do_toggle_driving = true,
1191− .driving_updated_for_dev_dis = 0xf,
1192− .use_default_parameter = false,
1193− .is_double_sensitivity_mode = true,
1194−};
1195−
1196−static const struct phy_cfg rtd1312c_phy_cfg = {
1197− .page0_size = MAX_USB_PHY_PAGE0_DATA_SIZE,
1198− .page0 = { [0] = {0xe0, 0x14},
1199− [4] = {0xe4, 0x67},
1200− [5] = {0xe5, 0x55}, },
1201− .page1_size = 8,
1202− .page1 = { [3] = {0xe3, 0x23},
1203− [6] = {0xe6, 0x58}, },
1204− .page2_size = MAX_USB_PHY_PAGE2_DATA_SIZE,
1205− .page2 = { /* default parameter */ },
1206− .num_phy = 1,
1207− .check_efuse = true,
1208− .check_efuse_version = CHECK_EFUSE_V1,
1209− .efuse_dc_driving_rate = 1,
1210− .dc_driving_mask = 0xf,
1211− .efuse_dc_disconnect_rate = EFUS_USB_DC_DIS_RATE,
1212− .dc_disconnect_mask = 0xf,
1213− .usb_dc_disconnect_at_page0 = true,
1214− .do_toggle = true,
1215− .do_toggle_driving = true,
1216− .driving_updated_for_dev_dis = 0xf,
1217− .use_default_parameter = false,
1218− .is_double_sensitivity_mode = true,
1219−};
1220−
1221−static const struct phy_cfg rtd1619b_phy_cfg = {
1222− .page0_size = MAX_USB_PHY_PAGE0_DATA_SIZE,
1223− .page0 = { [0] = {0xe0, 0xa3},
1224− [4] = {0xe4, 0x88},
1225− [5] = {0xe5, 0x4f},
1226− [6] = {0xe6, 0x02}, },
1227− .page1_size = 8,
1228− .page1 = { [3] = {0xe3, 0x64}, },
1229− .page2_size = MAX_USB_PHY_PAGE2_DATA_SIZE,
1230− .page2 = { [7] = {0xe7, 0x45}, },
1231− .num_phy = 1,
1232− .check_efuse = true,
1233− .check_efuse_version = CHECK_EFUSE_V1,
1234− .efuse_dc_driving_rate = EFUS_USB_DC_CAL_RATE,
1235− .dc_driving_mask = 0x1f,
1236− .efuse_dc_disconnect_rate = EFUS_USB_DC_DIS_RATE,
1237− .dc_disconnect_mask = 0xf,
1238− .usb_dc_disconnect_at_page0 = false,
1239− .do_toggle = true,
1240− .do_toggle_driving = true,
1241− .driving_updated_for_dev_dis = 0x8,
1242− .use_default_parameter = false,
1243− .is_double_sensitivity_mode = true,
1244−};
1245−
1246−static const struct phy_cfg rtd1319d_phy_cfg = {
1247− .page0_size = MAX_USB_PHY_PAGE0_DATA_SIZE,
1248− .page0 = { [0] = {0xe0, 0xa3},
1249− [4] = {0xe4, 0x8e},
1250− [5] = {0xe5, 0x4f},
1251− [6] = {0xe6, 0x02}, },
1252− .page1_size = MAX_USB_PHY_PAGE1_DATA_SIZE,
1253− .page1 = { [14] = {0xf5, 0x1}, },
1254− .page2_size = MAX_USB_PHY_PAGE2_DATA_SIZE,
1255− .page2 = { [7] = {0xe7, 0x44}, },
1256− .check_efuse = true,
1257− .num_phy = 1,
1258− .check_efuse_version = CHECK_EFUSE_V1,
1259− .efuse_dc_driving_rate = EFUS_USB_DC_CAL_RATE,
1260− .dc_driving_mask = 0x1f,
1261− .efuse_dc_disconnect_rate = EFUS_USB_DC_DIS_RATE,
1262− .dc_disconnect_mask = 0xf,
1263− .usb_dc_disconnect_at_page0 = false,
1264− .do_toggle = true,
1265− .do_toggle_driving = false,
1266− .driving_updated_for_dev_dis = 0x8,
1267− .use_default_parameter = false,
1268− .is_double_sensitivity_mode = true,
1269−};
1270−
1271−static const struct phy_cfg rtd1315e_phy_cfg = {
1272− .page0_size = MAX_USB_PHY_PAGE0_DATA_SIZE,
1273− .page0 = { [0] = {0xe0, 0xa3},
1274− [4] = {0xe4, 0x8c},
1275− [5] = {0xe5, 0x4f},
1276− [6] = {0xe6, 0x02}, },
1277− .page1_size = MAX_USB_PHY_PAGE1_DATA_SIZE,
1278− .page1 = { [3] = {0xe3, 0x7f},
1279− [14] = {0xf5, 0x01}, },
1280− .page2_size = MAX_USB_PHY_PAGE2_DATA_SIZE,
1281− .page2 = { [7] = {0xe7, 0x44}, },
1282− .num_phy = 1,
1283− .check_efuse = true,
1284− .check_efuse_version = CHECK_EFUSE_V2,
1285− .efuse_dc_driving_rate = EFUS_USB_DC_CAL_RATE,
1286− .dc_driving_mask = 0x1f,
1287− .efuse_dc_disconnect_rate = EFUS_USB_DC_DIS_RATE,
1288− .dc_disconnect_mask = 0xf,
1289− .usb_dc_disconnect_at_page0 = false,
1290− .do_toggle = true,
1291− .do_toggle_driving = false,
1292− .driving_updated_for_dev_dis = 0x8,
1293− .use_default_parameter = false,
1294− .is_double_sensitivity_mode = true,
1295−};
1296−
1297−static const struct of_device_id usbphy_rtk_dt_match[] = {
1298− { .compatible = "realtek,rtd1295-usb2phy", .data = &rtd1295_phy_cfg },
1299− { .compatible = "realtek,rtd1312c-usb2phy", .data = &rtd1312c_phy_cfg },
1300− { .compatible = "realtek,rtd1315e-usb2phy", .data = &rtd1315e_phy_cfg },
1301− { .compatible = "realtek,rtd1319-usb2phy", .data = &rtd1319_phy_cfg },
1302− { .compatible = "realtek,rtd1319d-usb2phy", .data = &rtd1319d_phy_cfg },
1303− { .compatible = "realtek,rtd1395-usb2phy", .data = &rtd1395_phy_cfg },
1304− { .compatible = "realtek,rtd1395-usb2phy-2port", .data = &rtd1395_phy_cfg_2port },
1305− { .compatible = "realtek,rtd1619-usb2phy", .data = &rtd1619_phy_cfg },
1306− { .compatible = "realtek,rtd1619b-usb2phy", .data = &rtd1619b_phy_cfg },
1307− {},
1308−};
1309−MODULE_DEVICE_TABLE(of, usbphy_rtk_dt_match);
1310−
1311−static struct platform_driver rtk_usb2phy_driver = {
1312− .probe = rtk_usb2phy_probe,
1313− .remove_new = rtk_usb2phy_remove,
1314− .driver = {
1315− .name = "rtk-usb2phy",
1316− .of_match_table = usbphy_rtk_dt_match,
1317− },
1318−};
1319−
1320−module_platform_driver(rtk_usb2phy_driver);
1321−
1322−MODULE_LICENSE("GPL");
1323−MODULE_ALIAS("platform: rtk-usb2phy");
1324−MODULE_AUTHOR("Stanley Chang <stanley_chang@realtek.com>");
1325−MODULE_DESCRIPTION("Realtek usb 2.0 phy driver");
drivers/phy/realtek/phy-rtk-usb3.c+0−761
@@ -1,761 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0
2−/*
3− * phy-rtk-usb3.c RTK usb3.0 phy driver
4− *
5− * copyright (c) 2023 realtek semiconductor corporation
6− *
7− */
8−
9−#include <linux/module.h>
10−#include <linux/of.h>
11−#include <linux/of_address.h>
12−#include <linux/platform_device.h>
13−#include <linux/uaccess.h>
14−#include <linux/debugfs.h>
15−#include <linux/nvmem-consumer.h>
16−#include <linux/regmap.h>
17−#include <linux/sys_soc.h>
18−#include <linux/mfd/syscon.h>
19−#include <linux/phy/phy.h>
20−#include <linux/usb.h>
21−#include <linux/usb/hcd.h>
22−#include <linux/usb/phy.h>
23−
24−#define USB_MDIO_CTRL_PHY_BUSY BIT(7)
25−#define USB_MDIO_CTRL_PHY_WRITE BIT(0)
26−#define USB_MDIO_CTRL_PHY_ADDR_SHIFT 8
27−#define USB_MDIO_CTRL_PHY_DATA_SHIFT 16
28−
29−#define MAX_USB_PHY_DATA_SIZE 0x30
30−#define PHY_ADDR_0X09 0x09
31−#define PHY_ADDR_0X0B 0x0b
32−#define PHY_ADDR_0X0D 0x0d
33−#define PHY_ADDR_0X10 0x10
34−#define PHY_ADDR_0X1F 0x1f
35−#define PHY_ADDR_0X20 0x20
36−#define PHY_ADDR_0X21 0x21
37−#define PHY_ADDR_0X30 0x30
38−
39−#define REG_0X09_FORCE_CALIBRATION BIT(9)
40−#define REG_0X0B_RX_OFFSET_RANGE_MASK 0xc
41−#define REG_0X0D_RX_DEBUG_TEST_EN BIT(6)
42−#define REG_0X10_DEBUG_MODE_SETTING 0x3c0
43−#define REG_0X10_DEBUG_MODE_SETTING_MASK 0x3f8
44−#define REG_0X1F_RX_OFFSET_CODE_MASK 0x1e
45−
46−#define USB_U3_TX_LFPS_SWING_TRIM_SHIFT 4
47−#define USB_U3_TX_LFPS_SWING_TRIM_MASK 0xf
48−#define AMPLITUDE_CONTROL_COARSE_MASK 0xff
49−#define AMPLITUDE_CONTROL_FINE_MASK 0xffff
50−#define AMPLITUDE_CONTROL_COARSE_DEFAULT 0xff
51−#define AMPLITUDE_CONTROL_FINE_DEFAULT 0xffff
52−
53−#define PHY_ADDR_MAP_ARRAY_INDEX(addr) (addr)
54−#define ARRAY_INDEX_MAP_PHY_ADDR(index) (index)
55−
56−struct phy_reg {
57− void __iomem *reg_mdio_ctl;
58−};
59−
60−struct phy_data {
61− u8 addr;
62− u16 data;
63−};
64−
65−struct phy_cfg {
66− int param_size;
67− struct phy_data param[MAX_USB_PHY_DATA_SIZE];
68−
69− bool check_efuse;
70− bool do_toggle;
71− bool do_toggle_once;
72− bool use_default_parameter;
73− bool check_rx_front_end_offset;
74−};
75−
76−struct phy_parameter {
77− struct phy_reg phy_reg;
78−
79− /* Get from efuse */
80− u8 efuse_usb_u3_tx_lfps_swing_trim;
81−
82− /* Get from dts */
83− u32 amplitude_control_coarse;
84− u32 amplitude_control_fine;
85−};
86−
87−struct rtk_phy {
88− struct usb_phy phy;
89− struct device *dev;
90−
91− struct phy_cfg *phy_cfg;
92− int num_phy;
93− struct phy_parameter *phy_parameter;
94−
95− struct dentry *debug_dir;
96−};
97−
98−#define PHY_IO_TIMEOUT_USEC (50000)
99−#define PHY_IO_DELAY_US (100)
100−
101−static inline int utmi_wait_register(void __iomem *reg, u32 mask, u32 result)
102−{
103− int ret;
104− unsigned int val;
105−
106− ret = read_poll_timeout(readl, val, ((val & mask) == result),
107− PHY_IO_DELAY_US, PHY_IO_TIMEOUT_USEC, false, reg);
108− if (ret) {
109− pr_err("%s can't program USB phy\n", __func__);
110− return -ETIMEDOUT;
111− }
112−
113− return 0;
114−}
115−
116−static int rtk_phy3_wait_vbusy(struct phy_reg *phy_reg)
117−{
118− return utmi_wait_register(phy_reg->reg_mdio_ctl, USB_MDIO_CTRL_PHY_BUSY, 0);
119−}
120−
121−static u16 rtk_phy_read(struct phy_reg *phy_reg, char addr)
122−{
123− unsigned int tmp;
124− u32 value;
125−
126− tmp = (addr << USB_MDIO_CTRL_PHY_ADDR_SHIFT);
127−
128− writel(tmp, phy_reg->reg_mdio_ctl);
129−
130− rtk_phy3_wait_vbusy(phy_reg);
131−
132− value = readl(phy_reg->reg_mdio_ctl);
133− value = value >> USB_MDIO_CTRL_PHY_DATA_SHIFT;
134−
135− return (u16)value;
136−}
137−
138−static int rtk_phy_write(struct phy_reg *phy_reg, char addr, u16 data)
139−{
140− unsigned int val;
141−
142− val = USB_MDIO_CTRL_PHY_WRITE |
143− (addr << USB_MDIO_CTRL_PHY_ADDR_SHIFT) |
144− (data << USB_MDIO_CTRL_PHY_DATA_SHIFT);
145−
146− writel(val, phy_reg->reg_mdio_ctl);
147−
148− rtk_phy3_wait_vbusy(phy_reg);
149−
150− return 0;
151−}
152−
153−static void do_rtk_usb3_phy_toggle(struct rtk_phy *rtk_phy, int index, bool connect)
154−{
155− struct phy_cfg *phy_cfg = rtk_phy->phy_cfg;
156− struct phy_reg *phy_reg;
157− struct phy_parameter *phy_parameter;
158− struct phy_data *phy_data;
159− u8 addr;
160− u16 data;
161− int i;
162−
163− phy_parameter = &((struct phy_parameter *)rtk_phy->phy_parameter)[index];
164− phy_reg = &phy_parameter->phy_reg;
165−
166− if (!phy_cfg->do_toggle)
167− return;
168−
169− i = PHY_ADDR_MAP_ARRAY_INDEX(PHY_ADDR_0X09);
170− phy_data = phy_cfg->param + i;
171− addr = phy_data->addr;
172− data = phy_data->data;
173−
174− if (!addr && !data) {
175− addr = PHY_ADDR_0X09;
176− data = rtk_phy_read(phy_reg, addr);
177− phy_data->addr = addr;
178− phy_data->data = data;
179− }
180−
181− rtk_phy_write(phy_reg, addr, data & (~REG_0X09_FORCE_CALIBRATION));
182− mdelay(1);
183− rtk_phy_write(phy_reg, addr, data | REG_0X09_FORCE_CALIBRATION);
184−}
185−
186−static int do_rtk_phy_init(struct rtk_phy *rtk_phy, int index)
187−{
188− struct phy_cfg *phy_cfg;
189− struct phy_reg *phy_reg;
190− struct phy_parameter *phy_parameter;
191− int i = 0;
192−
193− phy_cfg = rtk_phy->phy_cfg;
194− phy_parameter = &((struct phy_parameter *)rtk_phy->phy_parameter)[index];
195− phy_reg = &phy_parameter->phy_reg;
196−
197− if (phy_cfg->use_default_parameter)
198− goto do_toggle;
199−
200− for (i = 0; i < phy_cfg->param_size; i++) {
201− struct phy_data *phy_data = phy_cfg->param + i;
202− u8 addr = phy_data->addr;
203− u16 data = phy_data->data;
204−
205− if (!addr && !data)
206− continue;
207−
208− rtk_phy_write(phy_reg, addr, data);
209− }
210−
211−do_toggle:
212− if (phy_cfg->do_toggle_once)
213− phy_cfg->do_toggle = true;
214−
215− do_rtk_usb3_phy_toggle(rtk_phy, index, false);
216−
217− if (phy_cfg->do_toggle_once) {
218− u16 check_value = 0;
219− int count = 10;
220− u16 value_0x0d, value_0x10;
221−
222− /* Enable Debug mode by set 0x0D and 0x10 */
223− value_0x0d = rtk_phy_read(phy_reg, PHY_ADDR_0X0D);
224− value_0x10 = rtk_phy_read(phy_reg, PHY_ADDR_0X10);
225−
226− rtk_phy_write(phy_reg, PHY_ADDR_0X0D,
227− value_0x0d | REG_0X0D_RX_DEBUG_TEST_EN);
228− rtk_phy_write(phy_reg, PHY_ADDR_0X10,
229− (value_0x10 & ~REG_0X10_DEBUG_MODE_SETTING_MASK) |
230− REG_0X10_DEBUG_MODE_SETTING);
231−
232− check_value = rtk_phy_read(phy_reg, PHY_ADDR_0X30);
233−
234− while (!(check_value & BIT(15))) {
235− check_value = rtk_phy_read(phy_reg, PHY_ADDR_0X30);
236− mdelay(1);
237− if (count-- < 0)
238− break;
239− }
240−
241− if (!(check_value & BIT(15)))
242− dev_info(rtk_phy->dev, "toggle fail addr=0x%02x, data=0x%04x\n",
243− PHY_ADDR_0X30, check_value);
244−
245− /* Disable Debug mode by set 0x0D and 0x10 to default*/
246− rtk_phy_write(phy_reg, PHY_ADDR_0X0D, value_0x0d);
247− rtk_phy_write(phy_reg, PHY_ADDR_0X10, value_0x10);
248−
249− phy_cfg->do_toggle = false;
250− }
251−
252− if (phy_cfg->check_rx_front_end_offset) {
253− u16 rx_offset_code, rx_offset_range;
254− u16 code_mask = REG_0X1F_RX_OFFSET_CODE_MASK;
255− u16 range_mask = REG_0X0B_RX_OFFSET_RANGE_MASK;
256− bool do_update = false;
257−
258− rx_offset_code = rtk_phy_read(phy_reg, PHY_ADDR_0X1F);
259− if (((rx_offset_code & code_mask) == 0x0) ||
260− ((rx_offset_code & code_mask) == code_mask))
261− do_update = true;
262−
263− rx_offset_range = rtk_phy_read(phy_reg, PHY_ADDR_0X0B);
264− if (((rx_offset_range & range_mask) == range_mask) && do_update) {
265− dev_warn(rtk_phy->dev, "Don't update rx_offset_range (rx_offset_code=0x%x, rx_offset_range=0x%x)\n",
266− rx_offset_code, rx_offset_range);
267− do_update = false;
268− }
269−
270− if (do_update) {
271− u16 tmp1, tmp2;
272−
273− tmp1 = rx_offset_range & (~range_mask);
274− tmp2 = rx_offset_range & range_mask;
275− tmp2 += (1 << 2);
276− rx_offset_range = tmp1 | (tmp2 & range_mask);
277− rtk_phy_write(phy_reg, PHY_ADDR_0X0B, rx_offset_range);
278− goto do_toggle;
279− }
280− }
281−
282− return 0;
283−}
284−
285−static int rtk_phy_init(struct phy *phy)
286−{
287− struct rtk_phy *rtk_phy = phy_get_drvdata(phy);
288− int ret = 0;
289− int i;
290− unsigned long phy_init_time = jiffies;
291−
292− for (i = 0; i < rtk_phy->num_phy; i++)
293− ret = do_rtk_phy_init(rtk_phy, i);
294−
295− dev_dbg(rtk_phy->dev, "Initialized RTK USB 3.0 PHY (take %dms)\n",
296− jiffies_to_msecs(jiffies - phy_init_time));
297−
298− return ret;
299−}
300−
301−static int rtk_phy_exit(struct phy *phy)
302−{
303− return 0;
304−}
305−
306−static const struct phy_ops ops = {
307− .init = rtk_phy_init,
308− .exit = rtk_phy_exit,
309− .owner = THIS_MODULE,
310−};
311−
312−static void rtk_phy_toggle(struct usb_phy *usb3_phy, bool connect, int port)
313−{
314− int index = port;
315− struct rtk_phy *rtk_phy = NULL;
316−
317− rtk_phy = dev_get_drvdata(usb3_phy->dev);
318−
319− if (index > rtk_phy->num_phy) {
320− dev_err(rtk_phy->dev, "%s: The port=%d is not in usb phy (num_phy=%d)\n",
321− __func__, index, rtk_phy->num_phy);
322− return;
323− }
324−
325− do_rtk_usb3_phy_toggle(rtk_phy, index, connect);
326−}
327−
328−static int rtk_phy_notify_port_status(struct usb_phy *x, int port,
329− u16 portstatus, u16 portchange)
330−{
331− bool connect = false;
332−
333− pr_debug("%s port=%d portstatus=0x%x portchange=0x%x\n",
334− __func__, port, (int)portstatus, (int)portchange);
335− if (portstatus & USB_PORT_STAT_CONNECTION)
336− connect = true;
337−
338− if (portchange & USB_PORT_STAT_C_CONNECTION)
339− rtk_phy_toggle(x, connect, port);
340−
341− return 0;
342−}
343−
344−#ifdef CONFIG_DEBUG_FS
345−static struct dentry *create_phy_debug_root(void)
346−{
347− struct dentry *phy_debug_root;
348−
349− phy_debug_root = debugfs_lookup("phy", usb_debug_root);
350− if (!phy_debug_root)
351− phy_debug_root = debugfs_create_dir("phy", usb_debug_root);
352−
353− return phy_debug_root;
354−}
355−
356−static int rtk_usb3_parameter_show(struct seq_file *s, void *unused)
357−{
358− struct rtk_phy *rtk_phy = s->private;
359− struct phy_cfg *phy_cfg;
360− int i, index;
361−
362− phy_cfg = rtk_phy->phy_cfg;
363−
364− seq_puts(s, "Property:\n");
365− seq_printf(s, " check_efuse: %s\n",
366− phy_cfg->check_efuse ? "Enable" : "Disable");
367− seq_printf(s, " do_toggle: %s\n",
368− phy_cfg->do_toggle ? "Enable" : "Disable");
369− seq_printf(s, " do_toggle_once: %s\n",
370− phy_cfg->do_toggle_once ? "Enable" : "Disable");
371− seq_printf(s, " use_default_parameter: %s\n",
372− phy_cfg->use_default_parameter ? "Enable" : "Disable");
373−
374− for (index = 0; index < rtk_phy->num_phy; index++) {
375− struct phy_reg *phy_reg;
376− struct phy_parameter *phy_parameter;
377−
378− phy_parameter = &((struct phy_parameter *)rtk_phy->phy_parameter)[index];
379− phy_reg = &phy_parameter->phy_reg;
380−
381− seq_printf(s, "PHY %d:\n", index);
382−
383− for (i = 0; i < phy_cfg->param_size; i++) {
384− struct phy_data *phy_data = phy_cfg->param + i;
385− u8 addr = ARRAY_INDEX_MAP_PHY_ADDR(i);
386− u16 data = phy_data->data;
387−
388− if (!phy_data->addr && !data)
389− seq_printf(s, " addr = 0x%02x, data = none ==> read value = 0x%04x\n",
390− addr, rtk_phy_read(phy_reg, addr));
391− else
392− seq_printf(s, " addr = 0x%02x, data = 0x%04x ==> read value = 0x%04x\n",
393− addr, data, rtk_phy_read(phy_reg, addr));
394− }
395−
396− seq_puts(s, "PHY Property:\n");
397− seq_printf(s, " efuse_usb_u3_tx_lfps_swing_trim: 0x%x\n",
398− (int)phy_parameter->efuse_usb_u3_tx_lfps_swing_trim);
399− seq_printf(s, " amplitude_control_coarse: 0x%x\n",
400− (int)phy_parameter->amplitude_control_coarse);
401− seq_printf(s, " amplitude_control_fine: 0x%x\n",
402− (int)phy_parameter->amplitude_control_fine);
403− }
404−
405− return 0;
406−}
407−DEFINE_SHOW_ATTRIBUTE(rtk_usb3_parameter);
408−
409−static inline void create_debug_files(struct rtk_phy *rtk_phy)
410−{
411− struct dentry *phy_debug_root = NULL;
412−
413− phy_debug_root = create_phy_debug_root();
414−
415− if (!phy_debug_root)
416− return;
417−
418− rtk_phy->debug_dir = debugfs_create_dir(dev_name(rtk_phy->dev), phy_debug_root);
419−
420− debugfs_create_file("parameter", 0444, rtk_phy->debug_dir, rtk_phy,
421− &rtk_usb3_parameter_fops);
422−
423− return;
424−}
425−
426−static inline void remove_debug_files(struct rtk_phy *rtk_phy)
427−{
428− debugfs_remove_recursive(rtk_phy->debug_dir);
429−}
430−#else
431−static inline void create_debug_files(struct rtk_phy *rtk_phy) { }
432−static inline void remove_debug_files(struct rtk_phy *rtk_phy) { }
433−#endif /* CONFIG_DEBUG_FS */
434−
435−static int get_phy_data_by_efuse(struct rtk_phy *rtk_phy,
436− struct phy_parameter *phy_parameter, int index)
437−{
438− struct phy_cfg *phy_cfg = rtk_phy->phy_cfg;
439− u8 value = 0;
440− struct nvmem_cell *cell;
441−
442− if (!phy_cfg->check_efuse)
443− goto out;
444−
445− cell = nvmem_cell_get(rtk_phy->dev, "usb_u3_tx_lfps_swing_trim");
446− if (IS_ERR(cell)) {
447− dev_dbg(rtk_phy->dev, "%s no usb_u3_tx_lfps_swing_trim: %ld\n",
448− __func__, PTR_ERR(cell));
449− } else {
450− unsigned char *buf;
451− size_t buf_size;
452−
453− buf = nvmem_cell_read(cell, &buf_size);
454− if (!IS_ERR(buf)) {
455− value = buf[0] & USB_U3_TX_LFPS_SWING_TRIM_MASK;
456− kfree(buf);
457− }
458− nvmem_cell_put(cell);
459− }
460−
461− if (value > 0 && value < 0x8)
462− phy_parameter->efuse_usb_u3_tx_lfps_swing_trim = 0x8;
463− else
464− phy_parameter->efuse_usb_u3_tx_lfps_swing_trim = (u8)value;
465−
466−out:
467− return 0;
468−}
469−
470−static void update_amplitude_control_value(struct rtk_phy *rtk_phy,
471− struct phy_parameter *phy_parameter)
472−{
473− struct phy_cfg *phy_cfg;
474− struct phy_reg *phy_reg;
475−
476− phy_reg = &phy_parameter->phy_reg;
477− phy_cfg = rtk_phy->phy_cfg;
478−
479− if (phy_parameter->amplitude_control_coarse != AMPLITUDE_CONTROL_COARSE_DEFAULT) {
480− u16 val_mask = AMPLITUDE_CONTROL_COARSE_MASK;
481− u16 data;
482−
483− if (!phy_cfg->param[PHY_ADDR_0X20].addr && !phy_cfg->param[PHY_ADDR_0X20].data) {
484− phy_cfg->param[PHY_ADDR_0X20].addr = PHY_ADDR_0X20;
485− data = rtk_phy_read(phy_reg, PHY_ADDR_0X20);
486− } else {
487− data = phy_cfg->param[PHY_ADDR_0X20].data;
488− }
489−
490− data &= (~val_mask);
491− data |= (phy_parameter->amplitude_control_coarse & val_mask);
492−
493− phy_cfg->param[PHY_ADDR_0X20].data = data;
494− }
495−
496− if (phy_parameter->efuse_usb_u3_tx_lfps_swing_trim) {
497− u8 efuse_val = phy_parameter->efuse_usb_u3_tx_lfps_swing_trim;
498− u16 val_mask = USB_U3_TX_LFPS_SWING_TRIM_MASK;
499− int val_shift = USB_U3_TX_LFPS_SWING_TRIM_SHIFT;
500− u16 data;
501−
502− if (!phy_cfg->param[PHY_ADDR_0X20].addr && !phy_cfg->param[PHY_ADDR_0X20].data) {
503− phy_cfg->param[PHY_ADDR_0X20].addr = PHY_ADDR_0X20;
504− data = rtk_phy_read(phy_reg, PHY_ADDR_0X20);
505− } else {
506− data = phy_cfg->param[PHY_ADDR_0X20].data;
507− }
508−
509− data &= ~(val_mask << val_shift);
510− data |= ((efuse_val & val_mask) << val_shift);
511−
512− phy_cfg->param[PHY_ADDR_0X20].data = data;
513− }
514−
515− if (phy_parameter->amplitude_control_fine != AMPLITUDE_CONTROL_FINE_DEFAULT) {
516− u16 val_mask = AMPLITUDE_CONTROL_FINE_MASK;
517−
518− if (!phy_cfg->param[PHY_ADDR_0X21].addr && !phy_cfg->param[PHY_ADDR_0X21].data)
519− phy_cfg->param[PHY_ADDR_0X21].addr = PHY_ADDR_0X21;
520−
521− phy_cfg->param[PHY_ADDR_0X21].data =
522− phy_parameter->amplitude_control_fine & val_mask;
523− }
524−}
525−
526−static int parse_phy_data(struct rtk_phy *rtk_phy)
527−{
528− struct device *dev = rtk_phy->dev;
529− struct phy_parameter *phy_parameter;
530− int ret = 0;
531− int index;
532−
533− rtk_phy->phy_parameter = devm_kzalloc(dev, sizeof(struct phy_parameter) *
534− rtk_phy->num_phy, GFP_KERNEL);
535− if (!rtk_phy->phy_parameter)
536− return -ENOMEM;
537−
538− for (index = 0; index < rtk_phy->num_phy; index++) {
539− phy_parameter = &((struct phy_parameter *)rtk_phy->phy_parameter)[index];
540−
541− phy_parameter->phy_reg.reg_mdio_ctl = of_iomap(dev->of_node, 0) + index;
542−
543− /* Amplitude control address 0x20 bit 0 to bit 7 */
544− if (of_property_read_u32(dev->of_node, "realtek,amplitude-control-coarse-tuning",
545− &phy_parameter->amplitude_control_coarse))
546− phy_parameter->amplitude_control_coarse = AMPLITUDE_CONTROL_COARSE_DEFAULT;
547−
548− /* Amplitude control address 0x21 bit 0 to bit 16 */
549− if (of_property_read_u32(dev->of_node, "realtek,amplitude-control-fine-tuning",
550− &phy_parameter->amplitude_control_fine))
551− phy_parameter->amplitude_control_fine = AMPLITUDE_CONTROL_FINE_DEFAULT;
552−
553− get_phy_data_by_efuse(rtk_phy, phy_parameter, index);
554−
555− update_amplitude_control_value(rtk_phy, phy_parameter);
556− }
557−
558− return ret;
559−}
560−
561−static int rtk_usb3phy_probe(struct platform_device *pdev)
562−{
563− struct rtk_phy *rtk_phy;
564− struct device *dev = &pdev->dev;
565− struct phy *generic_phy;
566− struct phy_provider *phy_provider;
567− const struct phy_cfg *phy_cfg;
568− int ret;
569−
570− phy_cfg = of_device_get_match_data(dev);
571− if (!phy_cfg) {
572− dev_err(dev, "phy config are not assigned!\n");
573− return -EINVAL;
574− }
575−
576− rtk_phy = devm_kzalloc(dev, sizeof(*rtk_phy), GFP_KERNEL);
577− if (!rtk_phy)
578− return -ENOMEM;
579−
580− rtk_phy->dev = &pdev->dev;
581− rtk_phy->phy.dev = rtk_phy->dev;
582− rtk_phy->phy.label = "rtk-usb3phy";
583− rtk_phy->phy.notify_port_status = rtk_phy_notify_port_status;
584−
585− rtk_phy->phy_cfg = devm_kzalloc(dev, sizeof(*phy_cfg), GFP_KERNEL);
586−
587− memcpy(rtk_phy->phy_cfg, phy_cfg, sizeof(*phy_cfg));
588−
589− rtk_phy->num_phy = 1;
590−
591− ret = parse_phy_data(rtk_phy);
592− if (ret)
593− goto err;
594−
595− platform_set_drvdata(pdev, rtk_phy);
596−
597− generic_phy = devm_phy_create(rtk_phy->dev, NULL, &ops);
598− if (IS_ERR(generic_phy))
599− return PTR_ERR(generic_phy);
600−
601− phy_set_drvdata(generic_phy, rtk_phy);
602−
603− phy_provider = devm_of_phy_provider_register(rtk_phy->dev, of_phy_simple_xlate);
604− if (IS_ERR(phy_provider))
605− return PTR_ERR(phy_provider);
606−
607− ret = usb_add_phy_dev(&rtk_phy->phy);
608− if (ret)
609− goto err;
610−
611− create_debug_files(rtk_phy);
612−
613−err:
614− return ret;
615−}
616−
617−static void rtk_usb3phy_remove(struct platform_device *pdev)
618−{
619− struct rtk_phy *rtk_phy = platform_get_drvdata(pdev);
620−
621− remove_debug_files(rtk_phy);
622−
623− usb_remove_phy(&rtk_phy->phy);
624−}
625−
626−static const struct phy_cfg rtd1295_phy_cfg = {
627− .param_size = MAX_USB_PHY_DATA_SIZE,
628− .param = { [0] = {0x01, 0x4008}, [1] = {0x01, 0xe046},
629− [2] = {0x02, 0x6046}, [3] = {0x03, 0x2779},
630− [4] = {0x04, 0x72f5}, [5] = {0x05, 0x2ad3},
631− [6] = {0x06, 0x000e}, [7] = {0x07, 0x2e00},
632− [8] = {0x08, 0x3591}, [9] = {0x09, 0x525c},
633− [10] = {0x0a, 0xa600}, [11] = {0x0b, 0xa904},
634− [12] = {0x0c, 0xc000}, [13] = {0x0d, 0xef1c},
635− [14] = {0x0e, 0x2000}, [15] = {0x0f, 0x0000},
636− [16] = {0x10, 0x000c}, [17] = {0x11, 0x4c00},
637− [18] = {0x12, 0xfc00}, [19] = {0x13, 0x0c81},
638− [20] = {0x14, 0xde01}, [21] = {0x15, 0x0000},
639− [22] = {0x16, 0x0000}, [23] = {0x17, 0x0000},
640− [24] = {0x18, 0x0000}, [25] = {0x19, 0x4004},
641− [26] = {0x1a, 0x1260}, [27] = {0x1b, 0xff00},
642− [28] = {0x1c, 0xcb00}, [29] = {0x1d, 0xa03f},
643− [30] = {0x1e, 0xc2e0}, [31] = {0x1f, 0x2807},
644− [32] = {0x20, 0x947a}, [33] = {0x21, 0x88aa},
645− [34] = {0x22, 0x0057}, [35] = {0x23, 0xab66},
646− [36] = {0x24, 0x0800}, [37] = {0x25, 0x0000},
647− [38] = {0x26, 0x040a}, [39] = {0x27, 0x01d6},
648− [40] = {0x28, 0xf8c2}, [41] = {0x29, 0x3080},
649− [42] = {0x2a, 0x3082}, [43] = {0x2b, 0x2078},
650− [44] = {0x2c, 0xffff}, [45] = {0x2d, 0xffff},
651− [46] = {0x2e, 0x0000}, [47] = {0x2f, 0x0040}, },
652− .check_efuse = false,
653− .do_toggle = true,
654− .do_toggle_once = false,
655− .use_default_parameter = false,
656− .check_rx_front_end_offset = false,
657−};
658−
659−static const struct phy_cfg rtd1619_phy_cfg = {
660− .param_size = MAX_USB_PHY_DATA_SIZE,
661− .param = { [8] = {0x08, 0x3591},
662− [38] = {0x26, 0x840b},
663− [40] = {0x28, 0xf842}, },
664− .check_efuse = false,
665− .do_toggle = true,
666− .do_toggle_once = false,
667− .use_default_parameter = false,
668− .check_rx_front_end_offset = false,
669−};
670−
671−static const struct phy_cfg rtd1319_phy_cfg = {
672− .param_size = MAX_USB_PHY_DATA_SIZE,
673− .param = { [1] = {0x01, 0xac86},
674− [6] = {0x06, 0x0003},
675− [9] = {0x09, 0x924c},
676− [10] = {0x0a, 0xa608},
677− [11] = {0x0b, 0xb905},
678− [14] = {0x0e, 0x2010},
679− [32] = {0x20, 0x705a},
680− [33] = {0x21, 0xf645},
681− [34] = {0x22, 0x0013},
682− [35] = {0x23, 0xcb66},
683− [41] = {0x29, 0xff00}, },
684− .check_efuse = true,
685− .do_toggle = true,
686− .do_toggle_once = false,
687− .use_default_parameter = false,
688− .check_rx_front_end_offset = false,
689−};
690−
691−static const struct phy_cfg rtd1619b_phy_cfg = {
692− .param_size = MAX_USB_PHY_DATA_SIZE,
693− .param = { [1] = {0x01, 0xac8c},
694− [6] = {0x06, 0x0017},
695− [9] = {0x09, 0x724c},
696− [10] = {0x0a, 0xb610},
697− [11] = {0x0b, 0xb90d},
698− [13] = {0x0d, 0xef2a},
699− [15] = {0x0f, 0x9050},
700− [16] = {0x10, 0x000c},
701− [32] = {0x20, 0x70ff},
702− [34] = {0x22, 0x0013},
703− [35] = {0x23, 0xdb66},
704− [38] = {0x26, 0x8609},
705− [41] = {0x29, 0xff13},
706− [42] = {0x2a, 0x3070}, },
707− .check_efuse = true,
708− .do_toggle = false,
709− .do_toggle_once = true,
710− .use_default_parameter = false,
711− .check_rx_front_end_offset = false,
712−};
713−
714−static const struct phy_cfg rtd1319d_phy_cfg = {
715− .param_size = MAX_USB_PHY_DATA_SIZE,
716− .param = { [1] = {0x01, 0xac89},
717− [4] = {0x04, 0xf2f5},
718− [6] = {0x06, 0x0017},
719− [9] = {0x09, 0x424c},
720− [10] = {0x0a, 0x9610},
721− [11] = {0x0b, 0x9901},
722− [12] = {0x0c, 0xf000},
723− [13] = {0x0d, 0xef2a},
724− [14] = {0x0e, 0x1000},
725− [15] = {0x0f, 0x9050},
726− [32] = {0x20, 0x7077},
727− [35] = {0x23, 0x0b62},
728− [37] = {0x25, 0x10ec},
729− [42] = {0x2a, 0x3070}, },
730− .check_efuse = true,
731− .do_toggle = false,
732− .do_toggle_once = true,
733− .use_default_parameter = false,
734− .check_rx_front_end_offset = true,
735−};
736−
737−static const struct of_device_id usbphy_rtk_dt_match[] = {
738− { .compatible = "realtek,rtd1295-usb3phy", .data = &rtd1295_phy_cfg },
739− { .compatible = "realtek,rtd1319-usb3phy", .data = &rtd1319_phy_cfg },
740− { .compatible = "realtek,rtd1319d-usb3phy", .data = &rtd1319d_phy_cfg },
741− { .compatible = "realtek,rtd1619-usb3phy", .data = &rtd1619_phy_cfg },
742− { .compatible = "realtek,rtd1619b-usb3phy", .data = &rtd1619b_phy_cfg },
743− {},
744−};
745−MODULE_DEVICE_TABLE(of, usbphy_rtk_dt_match);
746−
747−static struct platform_driver rtk_usb3phy_driver = {
748− .probe = rtk_usb3phy_probe,
749− .remove_new = rtk_usb3phy_remove,
750− .driver = {
751− .name = "rtk-usb3phy",
752− .of_match_table = usbphy_rtk_dt_match,
753− },
754−};
755−
756−module_platform_driver(rtk_usb3phy_driver);
757−
758−MODULE_LICENSE("GPL");
759−MODULE_ALIAS("platform: rtk-usb3phy");
760−MODULE_AUTHOR("Stanley Chang <stanley_chang@realtek.com>");
761−MODULE_DESCRIPTION("Realtek usb 3.0 phy driver");
drivers/pinctrl/cirrus/Kconfig+2−1
@@ -12,7 +12,8 @@ config PINCTRL_CS42L43 · 11 unmodified lines
1212
1313 config PINCTRL_LOCHNAGAR
1414 tristate "Cirrus Logic Lochnagar pinctrl driver"
15− depends on MFD_LOCHNAGAR
15+ # Avoid clash caused by MIPS defining RST, which is used in the driver
16+ depends on MFD_LOCHNAGAR && !MIPS
1617 select GPIOLIB
1718 select PINMUX
1819 select PINCONF
drivers/pinctrl/core.c+3−3
@@ -1262,17 +1262,17 @@ static void pinctrl_link_add(struct pinctrl_dev *pctldev, · 1261 unmodified lines
12621262 static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
12631263 {
12641264 struct pinctrl_setting *setting, *setting2;
1265− struct pinctrl_state *old_state = p->state;
1265+ struct pinctrl_state *old_state = READ_ONCE(p->state);
12661266 int ret;
12671267
1268− if (p->state) {
1268+ if (old_state) {
12691269 /*
12701270 * For each pinmux setting in the old state, forget SW's record
12711271 * of mux owner for that pingroup. Any pingroups which are
12721272 * still owned by the new state will be re-acquired by the call
12731273 * to pinmux_enable_setting() in the loop below.
12741274 */
1275− list_for_each_entry(setting, &p->state->settings, node) {
1275+ list_for_each_entry(setting, &old_state->settings, node) {
12761276 if (setting->type != PIN_MAP_TYPE_MUX_GROUP)
12771277 continue;
12781278 pinmux_disable_setting(setting);
drivers/pinctrl/nxp/pinctrl-s32cc.c+2−2
@@ -843,8 +843,8 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev, · 842 unmodified lines
843843 if (!np)
844844 return -ENODEV;
845845
846− if (mem_regions == 0) {
847− dev_err(&pdev->dev, "mem_regions is 0\n");
846+ if (mem_regions == 0 || mem_regions >= 10000) {
847+ dev_err(&pdev->dev, "mem_regions is invalid: %u\n", mem_regions);
848848 return -EINVAL;
849849 }
850850
drivers/pinctrl/pinctrl-cy8c95x0.c+1−0
@@ -143,6 +143,7 @@ static const struct dmi_system_id cy8c95x0_dmi_acpi_irq_info[] = { · 142 unmodified lines
143143 * @pinctrl_desc: pin controller description
144144 * @name: Chip controller name
145145 * @tpin: Total number of pins
146+ * @gpio_reset: GPIO line handler that can reset the IC
146147 */
147148 struct cy8c95x0_pinctrl {
148149 struct regmap *regmap;
drivers/pinctrl/realtek/pinctrl-rtd.c+2−2
@@ -146,7 +146,7 @@ static int rtd_pinctrl_get_function_groups(struct pinctrl_dev *pcdev, · 145 unmodified lines
146146
147147 static const struct rtd_pin_desc *rtd_pinctrl_find_mux(struct rtd_pinctrl *data, unsigned int pin)
148148 {
149− if (!data->info->muxes[pin].name)
149+ if (data->info->muxes[pin].name)
150150 return &data->info->muxes[pin];
151151
152152 return NULL;
@@ -249,7 +249,7 @@ static const struct pinctrl_pin_desc · 96 unmodified lines
249249 static const struct rtd_pin_config_desc
250250 *rtd_pinctrl_find_config(struct rtd_pinctrl *data, unsigned int pin)
251251 {
252− if (!data->info->configs[pin].name)
252+ if (data->info->configs[pin].name)
253253 return &data->info->configs[pin];
254254
255255 return NULL;
drivers/pinctrl/stm32/pinctrl-stm32.c+10−3
@@ -1273,9 +1273,11 @@ static struct stm32_desc_pin *stm32_pctrl_get_desc_pin_from_gpio(struct stm32_pi · 1272 unmodified lines
12731273 int i;
12741274
12751275 /* With few exceptions (e.g. bank 'Z'), pin number matches with pin index in array */
1276− pin_desc = pctl->pins + stm32_pin_nb;
1277− if (pin_desc->pin.number == stm32_pin_nb)
1278− return pin_desc;
1276+ if (stm32_pin_nb < pctl->npins) {
1277+ pin_desc = pctl->pins + stm32_pin_nb;
1278+ if (pin_desc->pin.number == stm32_pin_nb)
1279+ return pin_desc;
1280+ }
12791281
12801282 /* Otherwise, loop all array to find the pin with the right number */
12811283 for (i = 0; i < pctl->npins; i++) {
@@ -1368,6 +1370,11 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode · 86 unmodified lines
13681370 }
13691371
13701372 names = devm_kcalloc(dev, npins, sizeof(char *), GFP_KERNEL);
1373+ if (!names) {
1374+ err = -ENOMEM;
1375+ goto err_clk;
1376+ }
1377+
13711378 for (i = 0; i < npins; i++) {
13721379 stm32_pin = stm32_pctrl_get_desc_pin_from_gpio(pctl, bank, i);
13731380 if (stm32_pin && stm32_pin->pin.name)
drivers/pmdomain/arm/scmi_perf_domain.c+1−1
@@ -35,7 +35,7 @@ scmi_pd_set_perf_state(struct generic_pm_domain *genpd, unsigned int state) · 34 unmodified lines
3535 if (!state)
3636 return -EINVAL;
3737
38− ret = pd->perf_ops->level_set(pd->ph, pd->domain_id, state, true);
38+ ret = pd->perf_ops->level_set(pd->ph, pd->domain_id, state, false);
3939 if (ret)
4040 dev_warn(&genpd->dev, "Failed with %d when trying to set %d perf level",
4141 ret, state);
drivers/s390/block/dasd.c+13−11
@@ -676,18 +676,20 @@ static void dasd_profile_start(struct dasd_block *block, · 675 unmodified lines
676676 * we count each request only once.
677677 */
678678 device = cqr->startdev;
679− if (device->profile.data) {
680− counter = 1; /* request is not yet queued on the start device */
681− list_for_each(l, &device->ccw_queue)
682− if (++counter >= 31)
683− break;
684− }
679+ if (!device->profile.data)
680+ return;
681+
682+ spin_lock(get_ccwdev_lock(device->cdev));
683+ counter = 1; /* request is not yet queued on the start device */
684+ list_for_each(l, &device->ccw_queue)
685+ if (++counter >= 31)
686+ break;
687+ spin_unlock(get_ccwdev_lock(device->cdev));
688+
685689 spin_lock(&device->profile.lock);
686− if (device->profile.data) {
687− device->profile.data->dasd_io_nr_req[counter]++;
688− if (rq_data_dir(req) == READ)
689− device->profile.data->dasd_read_nr_req[counter]++;
690− }
690+ device->profile.data->dasd_io_nr_req[counter]++;
691+ if (rq_data_dir(req) == READ)
692+ device->profile.data->dasd_read_nr_req[counter]++;
691693 spin_unlock(&device->profile.lock);
692694 }
693695
drivers/s390/block/dasd_int.h+1−1
@@ -283,7 +283,7 @@ struct dasd_pprc_dev_info { · 282 unmodified lines
283283 __u8 secondary; /* 7 Secondary device address */
284284 __u16 pprc_id; /* 8-9 Peer-to-Peer Remote Copy ID */
285285 __u8 reserved2[12]; /* 10-21 reserved */
286− __u16 prim_cu_ssid; /* 22-23 Pimary Control Unit SSID */
286+ __u16 prim_cu_ssid; /* 22-23 Primary Control Unit SSID */
287287 __u8 reserved3[12]; /* 24-35 reserved */
288288 __u16 sec_cu_ssid; /* 36-37 Secondary Control Unit SSID */
289289 __u8 reserved4[90]; /* 38-127 reserved */
drivers/thunderbolt/switch.c+3−3
@@ -1143,7 +1143,7 @@ int tb_port_lane_bonding_enable(struct tb_port *port) · 1142 unmodified lines
11431143 * Only set bonding if the link was not already bonded. This
11441144 * avoids the lane adapter to re-enter bonding state.
11451145 */
1146− if (width == TB_LINK_WIDTH_SINGLE) {
1146+ if (width == TB_LINK_WIDTH_SINGLE && !tb_is_upstream_port(port)) {
11471147 ret = tb_port_set_lane_bonding(port, true);
11481148 if (ret)
11491149 goto err_lane1;
@@ -2880,6 +2880,7 @@ static int tb_switch_lane_bonding_disable(struct tb_switch *sw) · 1730 unmodified lines
28802880 return tb_port_wait_for_link_width(down, TB_LINK_WIDTH_SINGLE, 100);
28812881 }
28822882
2883+/* Note updating sw->link_width done in tb_switch_update_link_attributes() */
28832884 static int tb_switch_asym_enable(struct tb_switch *sw, enum tb_link_width width)
28842885 {
28852886 struct tb_port *up, *down, *port;
@@ -2919,10 +2920,10 @@ static int tb_switch_asym_enable(struct tb_switch *sw, enum tb_link_width width) · 33 unmodified lines
29192920 return ret;
29202921 }
29212922
2922− sw->link_width = width;
29232923 return 0;
29242924 }
29252925
2926+/* Note updating sw->link_width done in tb_switch_update_link_attributes() */
29262927 static int tb_switch_asym_disable(struct tb_switch *sw)
29272928 {
29282929 struct tb_port *up, *down;
@@ -2957,7 +2958,6 @@ static int tb_switch_asym_disable(struct tb_switch *sw) · 28 unmodified lines
29572958 return ret;
29582959 }
29592960
2960− sw->link_width = TB_LINK_WIDTH_DUAL;
29612961 return 0;
29622962 }
29632963
drivers/thunderbolt/tb.c+11−1
@@ -213,7 +213,17 @@ static void tb_add_dp_resources(struct tb_switch *sw) · 212 unmodified lines
213213 if (!tb_switch_query_dp_resource(sw, port))
214214 continue;
215215
216− list_add(&port->list, &tcm->dp_resources);
216+ /*
217+ * If DP IN on device router exist, position it at the
218+ * beginning of the DP resources list, so that it is used
219+ * before DP IN of the host router. This way external GPU(s)
220+ * will be prioritized when pairing DP IN to a DP OUT.
221+ */
222+ if (tb_route(sw))
223+ list_add(&port->list, &tcm->dp_resources);
224+ else
225+ list_add_tail(&port->list, &tcm->dp_resources);
226+
217227 tb_port_dbg(port, "DP IN resource available\n");
218228 }
219229 }
drivers/usb/cdns3/cdnsp-ring.c+3−0
@@ -1529,6 +1529,7 @@ irqreturn_t cdnsp_thread_irq_handler(int irq, void *data) · 1528 unmodified lines
15291529 unsigned long flags;
15301530 int counter = 0;
15311531
1532+ local_bh_disable();
15321533 spin_lock_irqsave(&pdev->lock, flags);
15331534
15341535 if (pdev->cdnsp_state & (CDNSP_STATE_HALTED | CDNSP_STATE_DYING)) {
@@ -1541,6 +1542,7 @@ irqreturn_t cdnsp_thread_irq_handler(int irq, void *data) · 6 unmodified lines
15411542 cdnsp_died(pdev);
15421543
15431544 spin_unlock_irqrestore(&pdev->lock, flags);
1545+ local_bh_enable();
15441546 return IRQ_HANDLED;
15451547 }
15461548
@@ -1557,6 +1559,7 @@ irqreturn_t cdnsp_thread_irq_handler(int irq, void *data) · 10 unmodified lines
15571559 cdnsp_update_erst_dequeue(pdev, event_ring_deq, 1);
15581560
15591561 spin_unlock_irqrestore(&pdev->lock, flags);
1562+ local_bh_enable();
15601563
15611564 return IRQ_HANDLED;
15621565 }
drivers/usb/core/config.c+2−1
@@ -1047,7 +1047,7 @@ int usb_get_bos_descriptor(struct usb_device *dev) · 1046 unmodified lines
10471047
10481048 if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {
10491049 dev_notice(ddev, "descriptor type invalid, skip\n");
1050− continue;
1050+ goto skip_to_next_descriptor;
10511051 }
10521052
10531053 switch (cap_type) {
@@ -1078,6 +1078,7 @@ int usb_get_bos_descriptor(struct usb_device *dev) · 24 unmodified lines
10781078 break;
10791079 }
10801080
1081+skip_to_next_descriptor:
10811082 total_len -= length;
10821083 buffer += length;
10831084 }
drivers/usb/core/hub.c+0−23
@@ -622,29 +622,6 @@ static int hub_ext_port_status(struct usb_hub *hub, int port1, int type, · 621 unmodified lines
622622 ret = 0;
623623 }
624624 mutex_unlock(&hub->status_mutex);
625−
626− /*
627− * There is no need to lock status_mutex here, because status_mutex
628− * protects hub->status, and the phy driver only checks the port
629− * status without changing the status.
630− */
631− if (!ret) {
632− struct usb_device *hdev = hub->hdev;
633−
634− /*
635− * Only roothub will be notified of port state changes,
636− * since the USB PHY only cares about changes at the next
637− * level.
638− */
639− if (is_root_hub(hdev)) {
640− struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
641−
642− if (hcd->usb_phy)
643− usb_phy_notify_port_status(hcd->usb_phy,
644− port1 - 1, *status, *change);
645− }
646− }
647−
648625 return ret;
649626 }
650627
drivers/usb/dwc2/hcd_intr.c+7−8
@@ -2015,15 +2015,17 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int chnum) · 2014 unmodified lines
20152015 {
20162016 struct dwc2_qtd *qtd;
20172017 struct dwc2_host_chan *chan;
2018− u32 hcint, hcintmsk;
2018+ u32 hcint, hcintraw, hcintmsk;
20192019
20202020 chan = hsotg->hc_ptr_array[chnum];
20212021
2022− hcint = dwc2_readl(hsotg, HCINT(chnum));
2022+ hcintraw = dwc2_readl(hsotg, HCINT(chnum));
20232023 hcintmsk = dwc2_readl(hsotg, HCINTMSK(chnum));
2024+ hcint = hcintraw & hcintmsk;
2025+ dwc2_writel(hsotg, hcint, HCINT(chnum));
2026+
20242027 if (!chan) {
20252028 dev_err(hsotg->dev, "## hc_ptr_array for channel is NULL ##\n");
2026− dwc2_writel(hsotg, hcint, HCINT(chnum));
20272029 return;
20282030 }
20292031
@@ -2032,11 +2034,9 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int chnum) · 2 unmodified lines
20322034 chnum);
20332035 dev_vdbg(hsotg->dev,
20342036 " hcint 0x%08x, hcintmsk 0x%08x, hcint&hcintmsk 0x%08x\n",
2035− hcint, hcintmsk, hcint & hcintmsk);
2037+ hcintraw, hcintmsk, hcint);
20362038 }
20372039
2038− dwc2_writel(hsotg, hcint, HCINT(chnum));
2039−
20402040 /*
20412041 * If we got an interrupt after someone called
20422042 * dwc2_hcd_endpoint_disable() we don't want to crash below
@@ -2046,8 +2046,7 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int chnum) · 3 unmodified lines
20462046 return;
20472047 }
20482048
2049− chan->hcint = hcint;
2050− hcint &= hcintmsk;
2049+ chan->hcint = hcintraw;
20512050
20522051 /*
20532052 * If the channel was halted due to a dequeue, the qtd list might
drivers/usb/dwc3/core.c+2−0
@@ -2034,6 +2034,8 @@ static int dwc3_probe(struct platform_device *pdev) · 2033 unmodified lines
20342034
20352035 pm_runtime_put(dev);
20362036
2037+ dma_set_max_seg_size(dev, UINT_MAX);
2038+
20372039 return 0;
20382040
20392041 err_exit_debugfs:
drivers/usb/dwc3/drd.c+1−1
@@ -505,6 +505,7 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc) · 504 unmodified lines
505505 dwc->role_switch_default_mode = USB_DR_MODE_PERIPHERAL;
506506 mode = DWC3_GCTL_PRTCAP_DEVICE;
507507 }
508+ dwc3_set_mode(dwc, mode);
508509
509510 dwc3_role_switch.fwnode = dev_fwnode(dwc->dev);
510511 dwc3_role_switch.set = dwc3_usb_role_switch_set;
@@ -526,7 +527,6 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc) · 15 unmodified lines
526527 }
527528 }
528529
529− dwc3_set_mode(dwc, mode);
530530 return 0;
531531 }
532532 #else
drivers/usb/dwc3/dwc3-qcom.c+47−22
@@ -546,10 +546,9 @@ static int dwc3_qcom_setup_irq(struct platform_device *pdev) · 545 unmodified lines
546546 pdata ? pdata->hs_phy_irq_index : -1);
547547 if (irq > 0) {
548548 /* Keep wakeup interrupts disabled until suspend */
549− irq_set_status_flags(irq, IRQ_NOAUTOEN);
550549 ret = devm_request_threaded_irq(qcom->dev, irq, NULL,
551550 qcom_dwc3_resume_irq,
552− IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
551+ IRQF_ONESHOT | IRQF_NO_AUTOEN,
553552 "qcom_dwc3 HS", qcom);
554553 if (ret) {
555554 dev_err(qcom->dev, "hs_phy_irq failed: %d\n", ret);
@@ -561,10 +560,9 @@ static int dwc3_qcom_setup_irq(struct platform_device *pdev) · 5 unmodified lines
561560 irq = dwc3_qcom_get_irq(pdev, "dp_hs_phy_irq",
562561 pdata ? pdata->dp_hs_phy_irq_index : -1);
563562 if (irq > 0) {
564− irq_set_status_flags(irq, IRQ_NOAUTOEN);
565563 ret = devm_request_threaded_irq(qcom->dev, irq, NULL,
566564 qcom_dwc3_resume_irq,
567− IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
565+ IRQF_ONESHOT | IRQF_NO_AUTOEN,
568566 "qcom_dwc3 DP_HS", qcom);
569567 if (ret) {
570568 dev_err(qcom->dev, "dp_hs_phy_irq failed: %d\n", ret);
@@ -576,10 +574,9 @@ static int dwc3_qcom_setup_irq(struct platform_device *pdev) · 5 unmodified lines
576574 irq = dwc3_qcom_get_irq(pdev, "dm_hs_phy_irq",
577575 pdata ? pdata->dm_hs_phy_irq_index : -1);
578576 if (irq > 0) {
579− irq_set_status_flags(irq, IRQ_NOAUTOEN);
580577 ret = devm_request_threaded_irq(qcom->dev, irq, NULL,
581578 qcom_dwc3_resume_irq,
582− IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
579+ IRQF_ONESHOT | IRQF_NO_AUTOEN,
583580 "qcom_dwc3 DM_HS", qcom);
584581 if (ret) {
585582 dev_err(qcom->dev, "dm_hs_phy_irq failed: %d\n", ret);
@@ -591,10 +588,9 @@ static int dwc3_qcom_setup_irq(struct platform_device *pdev) · 5 unmodified lines
591588 irq = dwc3_qcom_get_irq(pdev, "ss_phy_irq",
592589 pdata ? pdata->ss_phy_irq_index : -1);
593590 if (irq > 0) {
594− irq_set_status_flags(irq, IRQ_NOAUTOEN);
595591 ret = devm_request_threaded_irq(qcom->dev, irq, NULL,
596592 qcom_dwc3_resume_irq,
597− IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
593+ IRQF_ONESHOT | IRQF_NO_AUTOEN,
598594 "qcom_dwc3 SS", qcom);
599595 if (ret) {
600596 dev_err(qcom->dev, "ss_phy_irq failed: %d\n", ret);
@@ -758,6 +754,7 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev) · 157 unmodified lines
758754 if (!qcom->dwc3) {
759755 ret = -ENODEV;
760756 dev_err(dev, "failed to get dwc3 platform device\n");
757+ of_platform_depopulate(dev);
761758 }
762759
763760 node_put:
@@ -766,9 +763,9 @@ node_put: · 2 unmodified lines
766763 return ret;
767764 }
768765
769−static struct platform_device *
770−dwc3_qcom_create_urs_usb_platdev(struct device *dev)
766+static struct platform_device *dwc3_qcom_create_urs_usb_platdev(struct device *dev)
771767 {
768+ struct platform_device *urs_usb = NULL;
772769 struct fwnode_handle *fwh;
773770 struct acpi_device *adev;
774771 char name[8];
@@ -788,9 +785,26 @@ dwc3_qcom_create_urs_usb_platdev(struct device *dev) · 13 unmodified lines
788785
789786 adev = to_acpi_device_node(fwh);
790787 if (!adev)
791− return NULL;
788+ goto err_put_handle;
789+
790+ urs_usb = acpi_create_platform_device(adev, NULL);
791+ if (IS_ERR_OR_NULL(urs_usb))
792+ goto err_put_handle;
793+
794+ return urs_usb;
795+
796+err_put_handle:
797+ fwnode_handle_put(fwh);
798+
799+ return urs_usb;
800+}
792801
793− return acpi_create_platform_device(adev, NULL);
802+static void dwc3_qcom_destroy_urs_usb_platdev(struct platform_device *urs_usb)
803+{
804+ struct fwnode_handle *fwh = urs_usb->dev.fwnode;
805+
806+ platform_device_unregister(urs_usb);
807+ fwnode_handle_put(fwh);
794808 }
795809
796810 static int dwc3_qcom_probe(struct platform_device *pdev)
@@ -874,13 +888,13 @@ static int dwc3_qcom_probe(struct platform_device *pdev) · 77 unmodified lines
874888 qcom->qscratch_base = devm_ioremap_resource(dev, parent_res);
875889 if (IS_ERR(qcom->qscratch_base)) {
876890 ret = PTR_ERR(qcom->qscratch_base);
877− goto clk_disable;
891+ goto free_urs;
878892 }
879893
880894 ret = dwc3_qcom_setup_irq(pdev);
881895 if (ret) {
882896 dev_err(dev, "failed to setup IRQs, err=%d\n", ret);
883− goto clk_disable;
897+ goto free_urs;
884898 }
885899
886900 /*
@@ -899,7 +913,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev) · 12 unmodified lines
899913
900914 if (ret) {
901915 dev_err(dev, "failed to register DWC3 Core, err=%d\n", ret);
902− goto depopulate;
916+ goto free_urs;
903917 }
904918
905919 ret = dwc3_qcom_interconnect_init(qcom);
@@ -931,10 +945,16 @@ static int dwc3_qcom_probe(struct platform_device *pdev) · 25 unmodified lines
931945 interconnect_exit:
932946 dwc3_qcom_interconnect_exit(qcom);
933947 depopulate:
934− if (np)
948+ if (np) {
935949 of_platform_depopulate(&pdev->dev);
936− else
937− platform_device_put(pdev);
950+ } else {
951+ device_remove_software_node(&qcom->dwc3->dev);
952+ platform_device_del(qcom->dwc3);
953+ }
954+ platform_device_put(qcom->dwc3);
955+free_urs:
956+ if (qcom->urs_usb)
957+ dwc3_qcom_destroy_urs_usb_platdev(qcom->urs_usb);
938958 clk_disable:
939959 for (i = qcom->num_clocks - 1; i >= 0; i--) {
940960 clk_disable_unprepare(qcom->clks[i]);
@@ -953,11 +973,16 @@ static void dwc3_qcom_remove(struct platform_device *pdev) · 12 unmodified lines
953973 struct device *dev = &pdev->dev;
954974 int i;
955975
956− device_remove_software_node(&qcom->dwc3->dev);
957− if (np)
976+ if (np) {
958977 of_platform_depopulate(&pdev->dev);
959− else
960− platform_device_put(pdev);
978+ } else {
979+ device_remove_software_node(&qcom->dwc3->dev);
980+ platform_device_del(qcom->dwc3);
981+ }
982+ platform_device_put(qcom->dwc3);
983+
984+ if (qcom->urs_usb)
985+ dwc3_qcom_destroy_urs_usb_platdev(qcom->urs_usb);
961986
962987 for (i = qcom->num_clocks - 1; i >= 0; i--) {
963988 clk_disable_unprepare(qcom->clks[i]);
drivers/usb/dwc3/dwc3-rtk.c+7−1
@@ -183,10 +183,13 @@ static enum usb_device_speed __get_dwc3_maximum_speed(struct device_node *np) · 182 unmodified lines
183183
184184 ret = of_property_read_string(dwc3_np, "maximum-speed", &maximum_speed);
185185 if (ret < 0)
186− return USB_SPEED_UNKNOWN;
186+ goto out;
187187
188188 ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed);
189189
190+out:
191+ of_node_put(dwc3_np);
192+
190193 return (ret < 0) ? USB_SPEED_UNKNOWN : ret;
191194 }
192195
@@ -339,6 +342,9 @@ static int dwc3_rtk_probe_dwc3_core(struct dwc3_rtk *rtk) · 146 unmodified lines
339342
340343 switch_usb2_role(rtk, rtk->cur_role);
341344
345+ platform_device_put(dwc3_pdev);
346+ of_node_put(dwc3_node);
347+
342348 return 0;
343349
344350 err_pdev_put:
drivers/usb/host/xhci-mtk-sch.c+10−3
@@ -650,9 +650,8 @@ static int check_isoc_ss_overlap(struct mu3h_sch_ep_info *sch_ep, u32 offset) · 649 unmodified lines
650650
651651 if (sch_ep->ep_type == ISOC_OUT_EP) {
652652 for (j = 0; j < sch_ep->num_budget_microframes; j++) {
653− k = XHCI_MTK_BW_INDEX(base + j + CS_OFFSET);
654− /* use cs to indicate existence of in-ss @(base+j) */
655− if (tt->fs_bus_bw_in[k])
653+ k = XHCI_MTK_BW_INDEX(base + j);
654+ if (tt->in_ss_cnt[k])
656655 return -ESCH_SS_OVERLAP;
657656 }
658657 } else if (sch_ep->ep_type == ISOC_IN_EP || sch_ep->ep_type == INT_IN_EP) {
@@ -769,6 +768,14 @@ static void update_sch_tt(struct mu3h_sch_ep_info *sch_ep, bool used) · 110 unmodified lines
769768 tt->fs_frame_bw[f] -= (u16)sch_ep->bw_budget_table[j];
770769 }
771770 }
771+
772+ if (sch_ep->ep_type == ISOC_IN_EP || sch_ep->ep_type == INT_IN_EP) {
773+ k = XHCI_MTK_BW_INDEX(base);
774+ if (used)
775+ tt->in_ss_cnt[k]++;
776+ else
777+ tt->in_ss_cnt[k]--;
778+ }
772779 }
773780
774781 if (used)
drivers/usb/host/xhci-mtk.h+2−0
@@ -38,6 +38,7 @@ · 37 unmodified lines
3838 * @fs_bus_bw_in: save bandwidth used by FS/LS IN eps in each uframes
3939 * @ls_bus_bw: save bandwidth used by LS eps in each uframes
4040 * @fs_frame_bw: save bandwidth used by FS/LS eps in each FS frames
41+ * @in_ss_cnt: the count of Start-Split for IN eps
4142 * @ep_list: Endpoints using this TT
4243 */
4344 struct mu3h_sch_tt {
@@ -45,6 +46,7 @@ struct mu3h_sch_tt { · 1 unmodified line
4546 u16 fs_bus_bw_in[XHCI_MTK_MAX_ESIT];
4647 u8 ls_bus_bw[XHCI_MTK_MAX_ESIT];
4748 u16 fs_frame_bw[XHCI_MTK_FRAMES_CNT];
49+ u8 in_ss_cnt[XHCI_MTK_MAX_ESIT];
4850 struct list_head ep_list;
4951 };
5052
drivers/usb/host/xhci-plat.c+30−20
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313 #include <linux/module.h>
1414 #include <linux/pci.h>
1515 #include <linux/of.h>
16+#include <linux/of_device.h>
1617 #include <linux/platform_device.h>
1718 #include <linux/usb/phy.h>
1819 #include <linux/slab.h>
@@ -148,7 +149,7 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s · 129 unmodified lines
148149 int ret;
149150 int irq;
150151 struct xhci_plat_priv *priv = NULL;
151−
152+ bool of_match;
152153
153154 if (usb_disabled())
154155 return -ENODEV;
@@ -253,16 +254,23 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s · 98 unmodified lines
253254 &xhci->imod_interval);
254255 }
255256
256− hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0);
257− if (IS_ERR(hcd->usb_phy)) {
258− ret = PTR_ERR(hcd->usb_phy);
259− if (ret == -EPROBE_DEFER)
260− goto disable_clk;
261− hcd->usb_phy = NULL;
262− } else {
263− ret = usb_phy_init(hcd->usb_phy);
264− if (ret)
265− goto disable_clk;
257+ /*
258+ * Drivers such as dwc3 manages PHYs themself (and rely on driver name
259+ * matching for the xhci platform device).
260+ */
261+ of_match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev);
262+ if (of_match) {
263+ hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0);
264+ if (IS_ERR(hcd->usb_phy)) {
265+ ret = PTR_ERR(hcd->usb_phy);
266+ if (ret == -EPROBE_DEFER)
267+ goto disable_clk;
268+ hcd->usb_phy = NULL;
269+ } else {
270+ ret = usb_phy_init(hcd->usb_phy);
271+ if (ret)
272+ goto disable_clk;
273+ }
266274 }
267275
268276 hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node);
@@ -285,15 +293,17 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s · 16 unmodified lines
285293 goto dealloc_usb2_hcd;
286294 }
287295
288− xhci->shared_hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev,
289− "usb-phy", 1);
290− if (IS_ERR(xhci->shared_hcd->usb_phy)) {
291− xhci->shared_hcd->usb_phy = NULL;
292− } else {
293− ret = usb_phy_init(xhci->shared_hcd->usb_phy);
294− if (ret)
295− dev_err(sysdev, "%s init usb3phy fail (ret=%d)\n",
296− __func__, ret);
296+ if (of_match) {
297+ xhci->shared_hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev,
298+ "usb-phy", 1);
299+ if (IS_ERR(xhci->shared_hcd->usb_phy)) {
300+ xhci->shared_hcd->usb_phy = NULL;
301+ } else {
302+ ret = usb_phy_init(xhci->shared_hcd->usb_phy);
303+ if (ret)
304+ dev_err(sysdev, "%s init usb3phy fail (ret=%d)\n",
305+ __func__, ret);
306+ }
297307 }
298308
299309 xhci->shared_hcd->tpl_support = hcd->tpl_support;
drivers/usb/misc/onboard_usb_hub.c+2−0
@@ -432,6 +432,8 @@ static const struct usb_device_id onboard_hub_id_table[] = { · 431 unmodified lines
432432 { USB_DEVICE(VENDOR_ID_MICROCHIP, 0x2412) }, /* USB2412 USB 2.0 */
433433 { USB_DEVICE(VENDOR_ID_MICROCHIP, 0x2514) }, /* USB2514B USB 2.0 */
434434 { USB_DEVICE(VENDOR_ID_MICROCHIP, 0x2517) }, /* USB2517 USB 2.0 */
435+ { USB_DEVICE(VENDOR_ID_MICROCHIP, 0x2744) }, /* USB5744 USB 2.0 */
436+ { USB_DEVICE(VENDOR_ID_MICROCHIP, 0x5744) }, /* USB5744 USB 3.0 */
435437 { USB_DEVICE(VENDOR_ID_REALTEK, 0x0411) }, /* RTS5411 USB 3.1 */
436438 { USB_DEVICE(VENDOR_ID_REALTEK, 0x5411) }, /* RTS5411 USB 2.1 */
437439 { USB_DEVICE(VENDOR_ID_REALTEK, 0x0414) }, /* RTS5414 USB 3.2 */
drivers/usb/misc/onboard_usb_hub.h+7−0
@@ -16,6 +16,11 @@ static const struct onboard_hub_pdata microchip_usb424_data = { · 15 unmodified lines
1616 .num_supplies = 1,
1717 };
1818
19+static const struct onboard_hub_pdata microchip_usb5744_data = {
20+ .reset_us = 0,
21+ .num_supplies = 2,
22+};
23+
1924 static const struct onboard_hub_pdata realtek_rts5411_data = {
2025 .reset_us = 0,
2126 .num_supplies = 1,
@@ -50,6 +55,8 @@ static const struct of_device_id onboard_hub_match[] = { · 28 unmodified lines
5055 { .compatible = "usb424,2412", .data = &microchip_usb424_data, },
5156 { .compatible = "usb424,2514", .data = &microchip_usb424_data, },
5257 { .compatible = "usb424,2517", .data = &microchip_usb424_data, },
58+ { .compatible = "usb424,2744", .data = &microchip_usb5744_data, },
59+ { .compatible = "usb424,5744", .data = &microchip_usb5744_data, },
5360 { .compatible = "usb451,8140", .data = &ti_tusb8041_data, },
5461 { .compatible = "usb451,8142", .data = &ti_tusb8041_data, },
5562 { .compatible = "usb4b4,6504", .data = &cypress_hx3_data, },
drivers/usb/misc/usb-ljca.c+4−13
@@ -457,8 +457,8 @@ static void ljca_auxdev_acpi_bind(struct ljca_adapter *adap, · 456 unmodified lines
457457 u64 adr, u8 id)
458458 {
459459 struct ljca_match_ids_walk_data wd = { 0 };
460− struct acpi_device *parent, *adev;
461460 struct device *dev = adap->dev;
461+ struct acpi_device *parent;
462462 char uid[4];
463463
464464 parent = ACPI_COMPANION(dev);
@@ -466,17 +466,7 @@ static void ljca_auxdev_acpi_bind(struct ljca_adapter *adap, · 1 unmodified line
466466 return;
467467
468468 /*
469− * get auxdev ACPI handle from the ACPI device directly
470− * under the parent that matches _ADR.
471− */
472− adev = acpi_find_child_device(parent, adr, false);
473− if (adev) {
474− ACPI_COMPANION_SET(&auxdev->dev, adev);
475− return;
476− }
477−
478− /*
479− * _ADR is a grey area in the ACPI specification, some
469+ * Currently LJCA hw doesn't use _ADR instead the shipped
480470 * platforms use _HID to distinguish children devices.
481471 */
482472 switch (adr) {
@@ -656,10 +646,11 @@ static int ljca_enumerate_spi(struct ljca_adapter *adap) · 173 unmodified lines
656646 unsigned int i;
657647 int ret;
658648
649+ /* Not all LJCA chips implement SPI, a timeout reading the descriptors is normal */
659650 ret = ljca_send(adap, LJCA_CLIENT_MNG, LJCA_MNG_ENUM_SPI, NULL, 0, buf,
660651 sizeof(buf), true, LJCA_ENUM_CLIENT_TIMEOUT_MS);
661652 if (ret < 0)
662− return ret;
653+ return (ret == -ETIMEDOUT) ? 0 : ret;
663654
664655 /* check firmware response */
665656 desc = (struct ljca_spi_descriptor *)buf;
drivers/usb/serial/option.c+8−3
@@ -203,8 +203,8 @@ static void option_instat_callback(struct urb *urb); · 202 unmodified lines
203203 #define DELL_PRODUCT_5829E_ESIM 0x81e4
204204 #define DELL_PRODUCT_5829E 0x81e6
205205
206−#define DELL_PRODUCT_FM101R 0x8213
207−#define DELL_PRODUCT_FM101R_ESIM 0x8215
206+#define DELL_PRODUCT_FM101R_ESIM 0x8213
207+#define DELL_PRODUCT_FM101R 0x8215
208208
209209 #define KYOCERA_VENDOR_ID 0x0c88
210210 #define KYOCERA_PRODUCT_KPC650 0x17da
@@ -609,6 +609,8 @@ static void option_instat_callback(struct urb *urb); · 398 unmodified lines
609609 #define UNISOC_VENDOR_ID 0x1782
610610 /* TOZED LT70-C based on UNISOC SL8563 uses UNISOC's vendor ID */
611611 #define TOZED_PRODUCT_LT70C 0x4055
612+/* Luat Air72*U series based on UNISOC UIS8910 uses UNISOC's vendor ID */
613+#define LUAT_PRODUCT_AIR720U 0x4e00
612614
613615 /* Device flags */
614616
@@ -1546,7 +1548,8 @@ static const struct usb_device_id option_ids[] = { · 931 unmodified lines
15461548 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) },
15471549 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff),
15481550 .driver_info = RSVD(4) },
1549− { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0189, 0xff, 0xff, 0xff) },
1551+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0189, 0xff, 0xff, 0xff),
1552+ .driver_info = RSVD(4) },
15501553 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */
15511554 .driver_info = RSVD(4) },
15521555 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0196, 0xff, 0xff, 0xff) },
@@ -2249,6 +2252,7 @@ static const struct usb_device_id option_ids[] = { · 696 unmodified lines
22492252 .driver_info = RSVD(4) | RSVD(5) | RSVD(6) },
22502253 { USB_DEVICE(0x1782, 0x4d10) }, /* Fibocom L610 (AT mode) */
22512254 { USB_DEVICE_INTERFACE_CLASS(0x1782, 0x4d11, 0xff) }, /* Fibocom L610 (ECM/RNDIS mode) */
2255+ { USB_DEVICE_AND_INTERFACE_INFO(0x2cb7, 0x0001, 0xff, 0xff, 0xff) }, /* Fibocom L716-EU (ECM/RNDIS mode) */
22522256 { USB_DEVICE(0x2cb7, 0x0104), /* Fibocom NL678 series */
22532257 .driver_info = RSVD(4) | RSVD(5) },
22542258 { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0105, 0xff), /* Fibocom NL678 series */
@@ -2271,6 +2275,7 @@ static const struct usb_device_id option_ids[] = { · 16 unmodified lines
22712275 { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0xff, 0x40) },
22722276 { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0, 0) },
22732277 { USB_DEVICE_AND_INTERFACE_INFO(UNISOC_VENDOR_ID, TOZED_PRODUCT_LT70C, 0xff, 0, 0) },
2278+ { USB_DEVICE_AND_INTERFACE_INFO(UNISOC_VENDOR_ID, LUAT_PRODUCT_AIR720U, 0xff, 0, 0) },
22742279 { } /* Terminating entry */
22752280 };
22762281 MODULE_DEVICE_TABLE(usb, option_ids);
drivers/usb/typec/tcpm/tcpm.c+11−1
@@ -4273,7 +4273,8 @@ static void run_state_machine(struct tcpm_port *port) · 4272 unmodified lines
42734273 current_lim = PD_P_SNK_STDBY_MW / 5;
42744274 tcpm_set_current_limit(port, current_lim, 5000);
42754275 /* Not sink vbus if operational current is 0mA */
4276− tcpm_set_charge(port, !!pdo_max_current(port->snk_pdo[0]));
4276+ tcpm_set_charge(port, !port->pd_supported ||
4277+ pdo_max_current(port->snk_pdo[0]));
42774278
42784279 if (!port->pd_supported)
42794280 tcpm_set_state(port, SNK_READY, 0);
@@ -5391,6 +5392,15 @@ static void _tcpm_pd_hard_reset(struct tcpm_port *port) · 1111 unmodified lines
53915392 if (port->bist_request == BDO_MODE_TESTDATA && port->tcpc->set_bist_data)
53925393 port->tcpc->set_bist_data(port->tcpc, false);
53935394
5395+ switch (port->state) {
5396+ case ERROR_RECOVERY:
5397+ case PORT_RESET:
5398+ case PORT_RESET_WAIT_OFF:
5399+ return;
5400+ default:
5401+ break;
5402+ }
5403+
53945404 if (port->ams != NONE_AMS)
53955405 port->ams = NONE_AMS;
53965406 if (port->hard_reset_count < PD_N_HARD_RESET_COUNT)
drivers/usb/typec/tipd/core.c+9−5
@@ -968,16 +968,17 @@ static int tps25750_start_patch_burst_mode(struct tps6598x *tps) · 967 unmodified lines
968968 ret = of_property_match_string(np, "reg-names", "patch-address");
969969 if (ret < 0) {
970970 dev_err(tps->dev, "failed to get patch-address %d\n", ret);
971− return ret;
971+ goto release_fw;
972972 }
973973
974974 ret = of_property_read_u32_index(np, "reg", ret, &addr);
975975 if (ret)
976− return ret;
976+ goto release_fw;
977977
978978 if (addr == 0 || (addr >= 0x20 && addr <= 0x23)) {
979979 dev_err(tps->dev, "wrong patch address %u\n", addr);
980− return -EINVAL;
980+ ret = -EINVAL;
981+ goto release_fw;
981982 }
982983
983984 bpms_data.addr = (u8)addr;
@@ -1226,7 +1227,10 @@ static int tps6598x_probe(struct i2c_client *client) · 242 unmodified lines
12261227 TPS_REG_INT_PLUG_EVENT;
12271228 }
12281229
1229− tps->data = device_get_match_data(tps->dev);
1230+ if (dev_fwnode(tps->dev))
1231+ tps->data = device_get_match_data(tps->dev);
1232+ else
1233+ tps->data = i2c_get_match_data(client);
12301234 if (!tps->data)
12311235 return -EINVAL;
12321236
@@ -1425,7 +1429,7 @@ static const struct of_device_id tps6598x_of_match[] = { · 192 unmodified lines
14251429 MODULE_DEVICE_TABLE(of, tps6598x_of_match);
14261430
14271431 static const struct i2c_device_id tps6598x_id[] = {
1428− { "tps6598x" },
1432+ { "tps6598x", (kernel_ulong_t)&tps6598x_data },
14291433 { }
14301434 };
14311435 MODULE_DEVICE_TABLE(i2c, tps6598x_id);
drivers/xen/privcmd.c+1−1
@@ -1115,7 +1115,7 @@ struct privcmd_kernel_ioreq { · 1114 unmodified lines
11151115 spinlock_t lock; /* Protects ioeventfds list */
11161116 struct list_head ioeventfds;
11171117 struct list_head list;
1118− struct ioreq_port ports[0];
1118+ struct ioreq_port ports[] __counted_by(vcpus);
11191119 };
11201120
11211121 static irqreturn_t ioeventfd_interrupt(int irq, void *dev_id)
drivers/xen/swiotlb-xen.c+1−0
@@ -405,4 +405,5 @@ const struct dma_map_ops xen_swiotlb_dma_ops = { · 404 unmodified lines
405405 .get_sgtable = dma_common_get_sgtable,
406406 .alloc_pages = dma_common_alloc_pages,
407407 .free_pages = dma_common_free_pages,
408+ .max_mapping_size = swiotlb_max_mapping_size,
408409 };
fs/afs/dynroot.c+2−2
@@ -132,8 +132,8 @@ static int afs_probe_cell_name(struct dentry *dentry) · 131 unmodified lines
132132
133133 ret = dns_query(net->net, "afsdb", name, len, "srv=1",
134134 NULL, NULL, false);
135− if (ret == -ENODATA)
136− ret = -EDESTADDRREQ;
135+ if (ret == -ENODATA || ret == -ENOKEY)
136+ ret = -ENOENT;
137137 return ret;
138138 }
139139
fs/afs/internal.h+1−0
@@ -553,6 +553,7 @@ struct afs_server_entry { · 552 unmodified lines
553553 };
554554
555555 struct afs_server_list {
556+ struct rcu_head rcu;
556557 afs_volid_t vids[AFS_MAXTYPES]; /* Volume IDs */
557558 refcount_t usage;
558559 unsigned char nr_servers;
fs/afs/server_list.c+1−1
@@ -17,7 +17,7 @@ void afs_put_serverlist(struct afs_net *net, struct afs_server_list *slist) · 16 unmodified lines
1717 for (i = 0; i < slist->nr_servers; i++)
1818 afs_unuse_server(net, slist->servers[i].server,
1919 afs_server_trace_put_slist);
20− kfree(slist);
20+ kfree_rcu(slist, rcu);
2121 }
2222 }
2323
fs/afs/super.c+4−0
@@ -407,6 +407,10 @@ static int afs_validate_fc(struct fs_context *fc) · 406 unmodified lines
407407 return PTR_ERR(volume);
408408
409409 ctx->volume = volume;
410+ if (volume->type != AFSVL_RWVOL) {
411+ ctx->flock_mode = afs_flock_mode_local;
412+ fc->sb_flags |= SB_RDONLY;
413+ }
410414 }
411415
412416 return 0;
fs/afs/vl_rotate.c+10−0
@@ -58,6 +58,12 @@ static bool afs_start_vl_iteration(struct afs_vl_cursor *vc) · 57 unmodified lines
5858 }
5959
6060 /* Status load is ordered after lookup counter load */
61+ if (cell->dns_status == DNS_LOOKUP_GOT_NOT_FOUND) {
62+ pr_warn("No record of cell %s\n", cell->name);
63+ vc->error = -ENOENT;
64+ return false;
65+ }
66+
6167 if (cell->dns_source == DNS_RECORD_UNAVAILABLE) {
6268 vc->error = -EDESTADDRREQ;
6369 return false;
@@ -285,6 +291,7 @@ failed: · 221 unmodified lines
285291 */
286292 static void afs_vl_dump_edestaddrreq(const struct afs_vl_cursor *vc)
287293 {
294+ struct afs_cell *cell = vc->cell;
288295 static int count;
289296 int i;
290297
@@ -294,6 +301,9 @@ static void afs_vl_dump_edestaddrreq(const struct afs_vl_cursor *vc) · 3 unmodified lines
294301
295302 rcu_read_lock();
296303 pr_notice("EDESTADDR occurred\n");
304+ pr_notice("CELL: %s err=%d\n", cell->name, cell->error);
305+ pr_notice("DNS: src=%u st=%u lc=%x\n",
306+ cell->dns_source, cell->dns_status, cell->dns_lookup_count);
297307 pr_notice("VC: ut=%lx ix=%u ni=%hu fl=%hx err=%hd\n",
298308 vc->untried, vc->index, vc->nr_iterations, vc->flags, vc->error);
299309
fs/autofs/inode.c+21−35
@@ -309,9 +309,7 @@ static int autofs_fill_super(struct super_block *s, struct fs_context *fc) · 308 unmodified lines
309309 struct autofs_fs_context *ctx = fc->fs_private;
310310 struct autofs_sb_info *sbi = s->s_fs_info;
311311 struct inode *root_inode;
312− struct dentry *root;
313312 struct autofs_info *ino;
314− int ret = -ENOMEM;
315313
316314 pr_debug("starting up, sbi = %p\n", sbi);
317315
@@ -328,56 +326,44 @@ static int autofs_fill_super(struct super_block *s, struct fs_context *fc) · 10 unmodified lines
328326 */
329327 ino = autofs_new_ino(sbi);
330328 if (!ino)
331− goto fail;
329+ return -ENOMEM;
332330
333331 root_inode = autofs_get_inode(s, S_IFDIR | 0755);
332+ if (!root_inode)
333+ return -ENOMEM;
334+
334335 root_inode->i_uid = ctx->uid;
335336 root_inode->i_gid = ctx->gid;
337+ root_inode->i_fop = &autofs_root_operations;
338+ root_inode->i_op = &autofs_dir_inode_operations;
336339
337− root = d_make_root(root_inode);
338− if (!root)
339− goto fail_ino;
340−
341− root->d_fsdata = ino;
340+ s->s_root = d_make_root(root_inode);
341+ if (unlikely(!s->s_root)) {
342+ autofs_free_ino(ino);
343+ return -ENOMEM;
344+ }
345+ s->s_root->d_fsdata = ino;
342346
343347 if (ctx->pgrp_set) {
344348 sbi->oz_pgrp = find_get_pid(ctx->pgrp);
345− if (!sbi->oz_pgrp) {
346− ret = invalf(fc, "Could not find process group %d",
347− ctx->pgrp);
348− goto fail_dput;
349− }
350− } else {
349+ if (!sbi->oz_pgrp)
350+ return invalf(fc, "Could not find process group %d",
351+ ctx->pgrp);
352+ } else
351353 sbi->oz_pgrp = get_task_pid(current, PIDTYPE_PGID);
352− }
353354
354355 if (autofs_type_trigger(sbi->type))
355− __managed_dentry_set_managed(root);
356−
357− root_inode->i_fop = &autofs_root_operations;
358− root_inode->i_op = &autofs_dir_inode_operations;
356+ /* s->s_root won't be contended so there's little to
357+ * be gained by not taking the d_lock when setting
358+ * d_flags, even when a lot mounts are being done.
359+ */
360+ managed_dentry_set_managed(s->s_root);
359361
360362 pr_debug("pipe fd = %d, pgrp = %u\n",
361363 sbi->pipefd, pid_nr(sbi->oz_pgrp));
362364
363365 sbi->flags &= ~AUTOFS_SBI_CATATONIC;
364−
365− /*
366− * Success! Install the root dentry now to indicate completion.
367− */
368− s->s_root = root;
369366 return 0;
370−
371− /*
372− * Failure ... clean up.
373− */
374−fail_dput:
375− dput(root);
376− goto fail;
377−fail_ino:
378− autofs_free_ino(ino);
379−fail:
380− return ret;
381367 }
382368
383369 /*
fs/btrfs/disk-io.c+1−0
@@ -3213,6 +3213,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device · 3212 unmodified lines
32133213 goto fail_alloc;
32143214 }
32153215
3216+ btrfs_info(fs_info, "first mount of filesystem %pU", disk_super->fsid);
32163217 /*
32173218 * Verify the type first, if that or the checksum value are
32183219 * corrupted, we'll find out
fs/btrfs/extent_io.c+8−3
@@ -674,8 +674,8 @@ static void end_bio_extent_readpage(struct btrfs_bio *bbio) · 673 unmodified lines
674674 * the array will be skipped
675675 *
676676 * Return: 0 if all pages were able to be allocated;
677− * -ENOMEM otherwise, and the caller is responsible for freeing all
678− * non-null page pointers in the array.
677+ * -ENOMEM otherwise, the partially allocated pages would be freed and
678+ * the array slots zeroed
679679 */
680680 int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array)
681681 {
@@ -694,8 +694,13 @@ int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array) · 12 unmodified lines
694694 * though alloc_pages_bulk_array() falls back to alloc_page()
695695 * if it could not bulk-allocate. So we must be out of memory.
696696 */
697− if (allocated == last)
697+ if (allocated == last) {
698+ for (int i = 0; i < allocated; i++) {
699+ __free_page(page_array[i]);
700+ page_array[i] = NULL;
701+ }
698702 return -ENOMEM;
703+ }
699704
700705 memalloc_retry_wait(GFP_NOFS);
701706 }
fs/btrfs/ioctl.c+1−0
@@ -4356,6 +4356,7 @@ static int _btrfs_ioctl_send(struct inode *inode, void __user *argp, bool compat · 4355 unmodified lines
43564356 arg->clone_sources = compat_ptr(args32.clone_sources);
43574357 arg->parent_root = args32.parent_root;
43584358 arg->flags = args32.flags;
4359+ arg->version = args32.version;
43594360 memcpy(arg->reserved, args32.reserved,
43604361 sizeof(args32.reserved));
43614362 #else
fs/btrfs/ref-verify.c+2−0
@@ -794,6 +794,7 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info, · 793 unmodified lines
794794 dump_ref_action(fs_info, ra);
795795 kfree(ref);
796796 kfree(ra);
797+ kfree(re);
797798 goto out_unlock;
798799 } else if (be->num_refs == 0) {
799800 btrfs_err(fs_info,
@@ -803,6 +804,7 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info, · 3 unmodified lines
803804 dump_ref_action(fs_info, ra);
804805 kfree(ref);
805806 kfree(ra);
807+ kfree(re);
806808 goto out_unlock;
807809 }
808810
fs/btrfs/send.c+1−1
@@ -8158,7 +8158,7 @@ long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg) · 8157 unmodified lines
81588158 }
81598159
81608160 sctx->send_filp = fget(arg->send_fd);
8161− if (!sctx->send_filp) {
8161+ if (!sctx->send_filp || !(sctx->send_filp->f_mode & FMODE_WRITE)) {
81628162 ret = -EBADF;
81638163 goto out;
81648164 }
fs/btrfs/super.c+4−1
@@ -80,7 +80,10 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data); · 79 unmodified lines
8080
8181 static void btrfs_put_super(struct super_block *sb)
8282 {
83− close_ctree(btrfs_sb(sb));
83+ struct btrfs_fs_info *fs_info = btrfs_sb(sb);
84+
85+ btrfs_info(fs_info, "last unmount of filesystem %pU", fs_info->fs_devices->fsid);
86+ close_ctree(fs_info);
8487 }
8588
8689 enum {
fs/btrfs/transaction.c+1−1
@@ -1774,7 +1774,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, · 1773 unmodified lines
17741774 btrfs_release_path(path);
17751775
17761776 ret = btrfs_create_qgroup(trans, objectid);
1777− if (ret) {
1777+ if (ret && ret != -EEXIST) {
17781778 btrfs_abort_transaction(trans, ret);
17791779 goto fail;
17801780 }
fs/btrfs/tree-checker.c+39−0
@@ -31,6 +31,7 @@ · 30 unmodified lines
3131 #include "inode-item.h"
3232 #include "dir-item.h"
3333 #include "raid-stripe-tree.h"
34+#include "extent-tree.h"
3435
3536 /*
3637 * Error message should follow the following format:
@@ -1276,6 +1277,8 @@ static int check_extent_item(struct extent_buffer *leaf, · 1239 unmodified lines
12761277 unsigned long ptr; /* Current pointer inside inline refs */
12771278 unsigned long end; /* Extent item end */
12781279 const u32 item_size = btrfs_item_size(leaf, slot);
1280+ u8 last_type = 0;
1281+ u64 last_seq = U64_MAX;
12791282 u64 flags;
12801283 u64 generation;
12811284 u64 total_refs; /* Total refs in btrfs_extent_item */
@@ -1322,6 +1325,18 @@ static int check_extent_item(struct extent_buffer *leaf, · 40 unmodified lines
13221325 * 2.2) Ref type specific data
13231326 * Either using btrfs_extent_inline_ref::offset, or specific
13241327 * data structure.
1328+ *
1329+ * All above inline items should follow the order:
1330+ *
1331+ * - All btrfs_extent_inline_ref::type should be in an ascending
1332+ * order
1333+ *
1334+ * - Within the same type, the items should follow a descending
1335+ * order by their sequence number. The sequence number is
1336+ * determined by:
1337+ * * btrfs_extent_inline_ref::offset for all types other than
1338+ * EXTENT_DATA_REF
1339+ * * hash_extent_data_ref() for EXTENT_DATA_REF
13251340 */
13261341 if (unlikely(item_size < sizeof(*ei))) {
13271342 extent_err(leaf, slot,
@@ -1403,6 +1418,7 @@ static int check_extent_item(struct extent_buffer *leaf, · 75 unmodified lines
14031418 struct btrfs_extent_inline_ref *iref;
14041419 struct btrfs_extent_data_ref *dref;
14051420 struct btrfs_shared_data_ref *sref;
1421+ u64 seq;
14061422 u64 dref_offset;
14071423 u64 inline_offset;
14081424 u8 inline_type;
@@ -1416,6 +1432,7 @@ static int check_extent_item(struct extent_buffer *leaf, · 7 unmodified lines
14161432 iref = (struct btrfs_extent_inline_ref *)ptr;
14171433 inline_type = btrfs_extent_inline_ref_type(leaf, iref);
14181434 inline_offset = btrfs_extent_inline_ref_offset(leaf, iref);
1435+ seq = inline_offset;
14191436 if (unlikely(ptr + btrfs_extent_inline_ref_size(inline_type) > end)) {
14201437 extent_err(leaf, slot,
14211438 "inline ref item overflows extent item, ptr %lu iref size %u end %lu",
@@ -1446,6 +1463,10 @@ static int check_extent_item(struct extent_buffer *leaf, · 24 unmodified lines
14461463 case BTRFS_EXTENT_DATA_REF_KEY:
14471464 dref = (struct btrfs_extent_data_ref *)(&iref->offset);
14481465 dref_offset = btrfs_extent_data_ref_offset(leaf, dref);
1466+ seq = hash_extent_data_ref(
1467+ btrfs_extent_data_ref_root(leaf, dref),
1468+ btrfs_extent_data_ref_objectid(leaf, dref),
1469+ btrfs_extent_data_ref_offset(leaf, dref));
14491470 if (unlikely(!IS_ALIGNED(dref_offset,
14501471 fs_info->sectorsize))) {
14511472 extent_err(leaf, slot,
@@ -1475,6 +1496,24 @@ static int check_extent_item(struct extent_buffer *leaf, · 23 unmodified lines
14751496 inline_type);
14761497 return -EUCLEAN;
14771498 }
1499+ if (inline_type < last_type) {
1500+ extent_err(leaf, slot,
1501+ "inline ref out-of-order: has type %u, prev type %u",
1502+ inline_type, last_type);
1503+ return -EUCLEAN;
1504+ }
1505+ /* Type changed, allow the sequence starts from U64_MAX again. */
1506+ if (inline_type > last_type)
1507+ last_seq = U64_MAX;
1508+ if (seq > last_seq) {
1509+ extent_err(leaf, slot,
1510+"inline ref out-of-order: has type %u offset %llu seq 0x%llx, prev type %u seq 0x%llx",
1511+ inline_type, inline_offset, seq,
1512+ last_type, last_seq);
1513+ return -EUCLEAN;
1514+ }
1515+ last_type = inline_type;
1516+ last_seq = seq;
14781517 ptr += btrfs_extent_inline_ref_size(inline_type);
14791518 }
14801519 /* No padding is allowed */
fs/btrfs/volumes.c+5−4
@@ -3006,15 +3006,16 @@ struct extent_map *btrfs_get_chunk_map(struct btrfs_fs_info *fs_info, · 3005 unmodified lines
30063006 read_unlock(&em_tree->lock);
30073007
30083008 if (!em) {
3009− btrfs_crit(fs_info, "unable to find logical %llu length %llu",
3009+ btrfs_crit(fs_info,
3010+ "unable to find chunk map for logical %llu length %llu",
30103011 logical, length);
30113012 return ERR_PTR(-EINVAL);
30123013 }
30133014
3014− if (em->start > logical || em->start + em->len < logical) {
3015+ if (em->start > logical || em->start + em->len <= logical) {
30153016 btrfs_crit(fs_info,
3016− "found a bad mapping, wanted %llu-%llu, found %llu-%llu",
3017− logical, length, em->start, em->start + em->len);
3017+ "found a bad chunk map, wanted %llu-%llu, found %llu-%llu",
3018+ logical, logical + length, em->start, em->start + em->len);
30183019 free_extent_map(em);
30193020 return ERR_PTR(-EINVAL);
30203021 }
fs/debugfs/file.c+100−0
@@ -84,6 +84,14 @@ int debugfs_file_get(struct dentry *dentry) · 83 unmodified lines
8484 struct debugfs_fsdata *fsd;
8585 void *d_fsd;
8686
87+ /*
88+ * This could only happen if some debugfs user erroneously calls
89+ * debugfs_file_get() on a dentry that isn't even a file, let
90+ * them know about it.
91+ */
92+ if (WARN_ON(!d_is_reg(dentry)))
93+ return -EINVAL;
94+
8795 d_fsd = READ_ONCE(dentry->d_fsdata);
8896 if (!((unsigned long)d_fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)) {
8997 fsd = d_fsd;
@@ -100,6 +108,14 @@ int debugfs_file_get(struct dentry *dentry) · 10 unmodified lines
100108 kfree(fsd);
101109 fsd = READ_ONCE(dentry->d_fsdata);
102110 }
111+#ifdef CONFIG_LOCKDEP
112+ fsd->lock_name = kasprintf(GFP_KERNEL, "debugfs:%pd", dentry);
113+ lockdep_register_key(&fsd->key);
114+ lockdep_init_map(&fsd->lockdep_map, fsd->lock_name ?: "debugfs",
115+ &fsd->key, 0);
116+#endif
117+ INIT_LIST_HEAD(&fsd->cancellations);
118+ mutex_init(&fsd->cancellations_mtx);
103119 }
104120
105121 /*
@@ -116,6 +132,8 @@ int debugfs_file_get(struct dentry *dentry) · 10 unmodified lines
116132 if (!refcount_inc_not_zero(&fsd->active_users))
117133 return -EIO;
118134
135+ lock_map_acquire_read(&fsd->lockdep_map);
136+
119137 return 0;
120138 }
121139 EXPORT_SYMBOL_GPL(debugfs_file_get);
@@ -133,11 +151,93 @@ void debugfs_file_put(struct dentry *dentry) · 11 unmodified lines
133151 {
134152 struct debugfs_fsdata *fsd = READ_ONCE(dentry->d_fsdata);
135153
154+ lock_map_release(&fsd->lockdep_map);
155+
136156 if (refcount_dec_and_test(&fsd->active_users))
137157 complete(&fsd->active_users_drained);
138158 }
139159 EXPORT_SYMBOL_GPL(debugfs_file_put);
140160
161+/**
162+ * debugfs_enter_cancellation - enter a debugfs cancellation
163+ * @file: the file being accessed
164+ * @cancellation: the cancellation object, the cancel callback
165+ * inside of it must be initialized
166+ *
167+ * When a debugfs file is removed it needs to wait for all active
168+ * operations to complete. However, the operation itself may need
169+ * to wait for hardware or completion of some asynchronous process
170+ * or similar. As such, it may need to be cancelled to avoid long
171+ * waits or even deadlocks.
172+ *
173+ * This function can be used inside a debugfs handler that may
174+ * need to be cancelled. As soon as this function is called, the
175+ * cancellation's 'cancel' callback may be called, at which point
176+ * the caller should proceed to call debugfs_leave_cancellation()
177+ * and leave the debugfs handler function as soon as possible.
178+ * Note that the 'cancel' callback is only ever called in the
179+ * context of some kind of debugfs_remove().
180+ *
181+ * This function must be paired with debugfs_leave_cancellation().
182+ */
183+void debugfs_enter_cancellation(struct file *file,
184+ struct debugfs_cancellation *cancellation)
185+{
186+ struct debugfs_fsdata *fsd;
187+ struct dentry *dentry = F_DENTRY(file);
188+
189+ INIT_LIST_HEAD(&cancellation->list);
190+
191+ if (WARN_ON(!d_is_reg(dentry)))
192+ return;
193+
194+ if (WARN_ON(!cancellation->cancel))
195+ return;
196+
197+ fsd = READ_ONCE(dentry->d_fsdata);
198+ if (WARN_ON(!fsd ||
199+ ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)))
200+ return;
201+
202+ mutex_lock(&fsd->cancellations_mtx);
203+ list_add(&cancellation->list, &fsd->cancellations);
204+ mutex_unlock(&fsd->cancellations_mtx);
205+
206+ /* if we're already removing wake it up to cancel */
207+ if (d_unlinked(dentry))
208+ complete(&fsd->active_users_drained);
209+}
210+EXPORT_SYMBOL_GPL(debugfs_enter_cancellation);
211+
212+/**
213+ * debugfs_leave_cancellation - leave cancellation section
214+ * @file: the file being accessed
215+ * @cancellation: the cancellation previously registered with
216+ * debugfs_enter_cancellation()
217+ *
218+ * See the documentation of debugfs_enter_cancellation().
219+ */
220+void debugfs_leave_cancellation(struct file *file,
221+ struct debugfs_cancellation *cancellation)
222+{
223+ struct debugfs_fsdata *fsd;
224+ struct dentry *dentry = F_DENTRY(file);
225+
226+ if (WARN_ON(!d_is_reg(dentry)))
227+ return;
228+
229+ fsd = READ_ONCE(dentry->d_fsdata);
230+ if (WARN_ON(!fsd ||
231+ ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)))
232+ return;
233+
234+ mutex_lock(&fsd->cancellations_mtx);
235+ if (!list_empty(&cancellation->list))
236+ list_del(&cancellation->list);
237+ mutex_unlock(&fsd->cancellations_mtx);
238+}
239+EXPORT_SYMBOL_GPL(debugfs_leave_cancellation);
240+
141241 /*
142242 * Only permit access to world-readable files when the kernel is locked down.
143243 * We also need to exclude any file that has ways to write or alter it as root
fs/debugfs/inode.c+63−8
@@ -236,17 +236,29 @@ static const struct super_operations debugfs_super_operations = { · 235 unmodified lines
236236
237237 static void debugfs_release_dentry(struct dentry *dentry)
238238 {
239− void *fsd = dentry->d_fsdata;
239+ struct debugfs_fsdata *fsd = dentry->d_fsdata;
240240
241− if (!((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT))
242− kfree(dentry->d_fsdata);
241+ if ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)
242+ return;
243+
244+ /* check it wasn't a dir (no fsdata) or automount (no real_fops) */
245+ if (fsd && fsd->real_fops) {
246+#ifdef CONFIG_LOCKDEP
247+ lockdep_unregister_key(&fsd->key);
248+ kfree(fsd->lock_name);
249+#endif
250+ WARN_ON(!list_empty(&fsd->cancellations));
251+ mutex_destroy(&fsd->cancellations_mtx);
252+ }
253+
254+ kfree(fsd);
243255 }
244256
245257 static struct vfsmount *debugfs_automount(struct path *path)
246258 {
247− debugfs_automount_t f;
248− f = (debugfs_automount_t)path->dentry->d_fsdata;
249− return f(path->dentry, d_inode(path->dentry)->i_private);
259+ struct debugfs_fsdata *fsd = path->dentry->d_fsdata;
260+
261+ return fsd->automount(path->dentry, d_inode(path->dentry)->i_private);
250262 }
251263
252264 static const struct dentry_operations debugfs_dops = {
@@ -634,13 +646,23 @@ struct dentry *debugfs_create_automount(const char *name, · 381 unmodified lines
634646 void *data)
635647 {
636648 struct dentry *dentry = start_creating(name, parent);
649+ struct debugfs_fsdata *fsd;
637650 struct inode *inode;
638651
639652 if (IS_ERR(dentry))
640653 return dentry;
641654
655+ fsd = kzalloc(sizeof(*fsd), GFP_KERNEL);
656+ if (!fsd) {
657+ failed_creating(dentry);
658+ return ERR_PTR(-ENOMEM);
659+ }
660+
661+ fsd->automount = f;
662+
642663 if (!(debugfs_allow & DEBUGFS_ALLOW_API)) {
643664 failed_creating(dentry);
665+ kfree(fsd);
644666 return ERR_PTR(-EPERM);
645667 }
646668
@@ -648,13 +670,14 @@ struct dentry *debugfs_create_automount(const char *name, · 1 unmodified line
648670 if (unlikely(!inode)) {
649671 pr_err("out of free dentries, can not create automount '%s'\n",
650672 name);
673+ kfree(fsd);
651674 return failed_creating(dentry);
652675 }
653676
654677 make_empty_dir_inode(inode);
655678 inode->i_flags |= S_AUTOMOUNT;
656679 inode->i_private = data;
657− dentry->d_fsdata = (void *)f;
680+ dentry->d_fsdata = fsd;
658681 /* directory inodes start off with i_nlink == 2 (for "." entry) */
659682 inc_nlink(inode);
660683 d_instantiate(dentry, inode);
@@ -731,8 +754,40 @@ static void __debugfs_file_removed(struct dentry *dentry) · 70 unmodified lines
731754 fsd = READ_ONCE(dentry->d_fsdata);
732755 if ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)
733756 return;
734− if (!refcount_dec_and_test(&fsd->active_users))
757+
758+ lock_map_acquire(&fsd->lockdep_map);
759+ lock_map_release(&fsd->lockdep_map);
760+
761+ /* if we hit zero, just wait for all to finish */
762+ if (!refcount_dec_and_test(&fsd->active_users)) {
763+ wait_for_completion(&fsd->active_users_drained);
764+ return;
765+ }
766+
767+ /* if we didn't hit zero, try to cancel any we can */
768+ while (refcount_read(&fsd->active_users)) {
769+ struct debugfs_cancellation *c;
770+
771+ /*
772+ * Lock the cancellations. Note that the cancellations
773+ * structs are meant to be on the stack, so we need to
774+ * ensure we either use them here or don't touch them,
775+ * and debugfs_leave_cancellation() will wait for this
776+ * to be finished processing before exiting one. It may
777+ * of course win and remove the cancellation, but then
778+ * chances are we never even got into this bit, we only
779+ * do if the refcount isn't zero already.
780+ */
781+ mutex_lock(&fsd->cancellations_mtx);
782+ while ((c = list_first_entry_or_null(&fsd->cancellations,
783+ typeof(*c), list))) {
784+ list_del_init(&c->list);
785+ c->cancel(dentry, c->cancel_data);
786+ }
787+ mutex_unlock(&fsd->cancellations_mtx);
788+
735789 wait_for_completion(&fsd->active_users_drained);
790+ }
736791 }
737792
738793 static void remove_one(struct dentry *victim)
fs/debugfs/internal.h+19−2
@@ -7,6 +7,8 @@ · 6 unmodified lines
77
88 #ifndef _DEBUGFS_INTERNAL_H_
99 #define _DEBUGFS_INTERNAL_H_
10+#include <linux/lockdep.h>
11+#include <linux/list.h>
1012
1113 struct file_operations;
1214
@@ -17,8 +19,23 @@ extern const struct file_operations debugfs_full_proxy_file_operations; · 4 unmodified lines
1719
1820 struct debugfs_fsdata {
1921 const struct file_operations *real_fops;
20− refcount_t active_users;
21− struct completion active_users_drained;
22+ union {
23+ /* automount_fn is used when real_fops is NULL */
24+ debugfs_automount_t automount;
25+ struct {
26+ refcount_t active_users;
27+ struct completion active_users_drained;
28+#ifdef CONFIG_LOCKDEP
29+ struct lockdep_map lockdep_map;
30+ struct lock_class_key key;
31+ char *lock_name;
32+#endif
33+
34+ /* protect cancellations */
35+ struct mutex cancellations_mtx;
36+ struct list_head cancellations;
37+ };
38+ };
2239 };
2340
2441 /*
fs/ecryptfs/inode.c+10−2
@@ -998,6 +998,14 @@ static int ecryptfs_getattr_link(struct mnt_idmap *idmap, · 997 unmodified lines
998998 return rc;
999999 }
10001000
1001+static int ecryptfs_do_getattr(const struct path *path, struct kstat *stat,
1002+ u32 request_mask, unsigned int flags)
1003+{
1004+ if (flags & AT_GETATTR_NOSEC)
1005+ return vfs_getattr_nosec(path, stat, request_mask, flags);
1006+ return vfs_getattr(path, stat, request_mask, flags);
1007+}
1008+
10011009 static int ecryptfs_getattr(struct mnt_idmap *idmap,
10021010 const struct path *path, struct kstat *stat,
10031011 u32 request_mask, unsigned int flags)
@@ -1006,8 +1014,8 @@ static int ecryptfs_getattr(struct mnt_idmap *idmap, · 2 unmodified lines
10061014 struct kstat lower_stat;
10071015 int rc;
10081016
1009− rc = vfs_getattr(ecryptfs_dentry_to_lower_path(dentry), &lower_stat,
1010− request_mask, flags);
1017+ rc = ecryptfs_do_getattr(ecryptfs_dentry_to_lower_path(dentry),
1018+ &lower_stat, request_mask, flags);
10111019 if (!rc) {
10121020 fsstack_copy_attr_all(d_inode(dentry),
10131021 ecryptfs_inode_to_lower(d_inode(dentry)));
fs/inode.c+2−0
@@ -215,6 +215,8 @@ int inode_init_always(struct super_block *sb, struct inode *inode) · 214 unmodified lines
215215 lockdep_set_class_and_name(&mapping->invalidate_lock,
216216 &sb->s_type->invalidate_lock_key,
217217 "mapping.invalidate_lock");
218+ if (sb->s_iflags & SB_I_STABLE_WRITES)
219+ mapping_set_stable_writes(mapping);
218220 inode->i_private = NULL;
219221 inode->i_mapping = mapping;
220222 INIT_HLIST_HEAD(&inode->i_dentry); /* buggered by rcu freeing */
fs/libfs.c+11−3
@@ -399,6 +399,8 @@ static loff_t offset_dir_llseek(struct file *file, loff_t offset, int whence) · 398 unmodified lines
399399 return -EINVAL;
400400 }
401401
402+ /* In this case, ->private_data is protected by f_pos_lock */
403+ file->private_data = NULL;
402404 return vfs_setpos(file, offset, U32_MAX);
403405 }
404406
@@ -428,7 +430,7 @@ static bool offset_dir_emit(struct dir_context *ctx, struct dentry *dentry) · 23 unmodified lines
428430 inode->i_ino, fs_umode_to_dtype(inode->i_mode));
429431 }
430432
431−static void offset_iterate_dir(struct inode *inode, struct dir_context *ctx)
433+static void *offset_iterate_dir(struct inode *inode, struct dir_context *ctx)
432434 {
433435 struct offset_ctx *so_ctx = inode->i_op->get_offset_ctx(inode);
434436 XA_STATE(xas, &so_ctx->xa, ctx->pos);
@@ -437,7 +439,7 @@ static void offset_iterate_dir(struct inode *inode, struct dir_context *ctx) · 2 unmodified lines
437439 while (true) {
438440 dentry = offset_find_next(&xas);
439441 if (!dentry)
440− break;
442+ return ERR_PTR(-ENOENT);
441443
442444 if (!offset_dir_emit(ctx, dentry)) {
443445 dput(dentry);
@@ -447,6 +449,7 @@ static void offset_iterate_dir(struct inode *inode, struct dir_context *ctx) · 3 unmodified lines
447449 dput(dentry);
448450 ctx->pos = xas.xa_index + 1;
449451 }
452+ return NULL;
450453 }
451454
452455 /**
@@ -479,7 +482,12 @@ static int offset_readdir(struct file *file, struct dir_context *ctx) · 26 unmodified lines
479482 if (!dir_emit_dots(file, ctx))
480483 return 0;
481484
482− offset_iterate_dir(d_inode(dir), ctx);
485+ /* In this case, ->private_data is protected by f_pos_lock */
486+ if (ctx->pos == 2)
487+ file->private_data = NULL;
488+ else if (file->private_data == ERR_PTR(-ENOENT))
489+ return 0;
490+ file->private_data = offset_iterate_dir(d_inode(dir), ctx);
483491 return 0;
484492 }
485493
fs/overlayfs/inode.c+5−5
@@ -171,7 +171,7 @@ int ovl_getattr(struct mnt_idmap *idmap, const struct path *path, · 170 unmodified lines
171171
172172 type = ovl_path_real(dentry, &realpath);
173173 old_cred = ovl_override_creds(dentry->d_sb);
174− err = vfs_getattr(&realpath, stat, request_mask, flags);
174+ err = ovl_do_getattr(&realpath, stat, request_mask, flags);
175175 if (err)
176176 goto out;
177177
@@ -196,8 +196,8 @@ int ovl_getattr(struct mnt_idmap *idmap, const struct path *path, · 18 unmodified lines
196196 (!is_dir ? STATX_NLINK : 0);
197197
198198 ovl_path_lower(dentry, &realpath);
199− err = vfs_getattr(&realpath, &lowerstat,
200− lowermask, flags);
199+ err = ovl_do_getattr(&realpath, &lowerstat, lowermask,
200+ flags);
201201 if (err)
202202 goto out;
203203
@@ -249,8 +249,8 @@ int ovl_getattr(struct mnt_idmap *idmap, const struct path *path, · 45 unmodified lines
249249
250250 ovl_path_lowerdata(dentry, &realpath);
251251 if (realpath.dentry) {
252− err = vfs_getattr(&realpath, &lowerdatastat,
253− lowermask, flags);
252+ err = ovl_do_getattr(&realpath, &lowerdatastat,
253+ lowermask, flags);
254254 if (err)
255255 goto out;
256256 } else {
fs/overlayfs/overlayfs.h+8−0
@@ -408,6 +408,14 @@ static inline bool ovl_open_flags_need_copy_up(int flags) · 407 unmodified lines
408408 return ((OPEN_FMODE(flags) & FMODE_WRITE) || (flags & O_TRUNC));
409409 }
410410
411+static inline int ovl_do_getattr(const struct path *path, struct kstat *stat,
412+ u32 request_mask, unsigned int flags)
413+{
414+ if (flags & AT_GETATTR_NOSEC)
415+ return vfs_getattr_nosec(path, stat, request_mask, flags);
416+ return vfs_getattr(path, stat, request_mask, flags);
417+}
418+
411419 /* util.c */
412420 int ovl_get_write_access(struct dentry *dentry);
413421 void ovl_put_write_access(struct dentry *dentry);
fs/smb/client/cifsglob.h+11−3
@@ -191,7 +191,13 @@ struct cifs_open_info_data { · 190 unmodified lines
191191 bool reparse_point;
192192 bool symlink;
193193 };
194− __u32 reparse_tag;
194+ struct {
195+ __u32 tag;
196+ union {
197+ struct reparse_data_buffer *buf;
198+ struct reparse_posix_data *posix;
199+ };
200+ } reparse;
195201 char *symlink_target;
196202 union {
197203 struct smb2_file_all_info fi;
@@ -395,8 +401,7 @@ struct smb_version_operations { · 197 unmodified lines
395401 struct cifs_tcon *tcon,
396402 struct cifs_sb_info *cifs_sb,
397403 const char *full_path,
398− char **target_path,
399− struct kvec *rsp_iov);
404+ char **target_path);
400405 /* open a file for non-posix mounts */
401406 int (*open)(const unsigned int xid, struct cifs_open_parms *oparms, __u32 *oplock,
402407 void *buf);
@@ -551,6 +556,9 @@ struct smb_version_operations { · 148 unmodified lines
551556 bool (*is_status_io_timeout)(char *buf);
552557 /* Check for STATUS_NETWORK_NAME_DELETED */
553558 bool (*is_network_name_deleted)(char *buf, struct TCP_Server_Info *srv);
559+ int (*parse_reparse_point)(struct cifs_sb_info *cifs_sb,
560+ struct kvec *rsp_iov,
561+ struct cifs_open_info_data *data);
554562 };
555563
556564 struct smb_version_values {
fs/smb/client/cifspdu.h+2−2
@@ -1356,7 +1356,7 @@ typedef struct smb_com_transaction_ioctl_rsp { · 1355 unmodified lines
13561356 __le32 DataDisplacement;
13571357 __u8 SetupCount; /* 1 */
13581358 __le16 ReturnedDataLen;
1359− __u16 ByteCount;
1359+ __le16 ByteCount;
13601360 } __attribute__((packed)) TRANSACT_IOCTL_RSP;
13611361
13621362 #define CIFS_ACL_OWNER 1
@@ -1509,7 +1509,7 @@ struct reparse_posix_data { · 146 unmodified lines
15091509 __le16 ReparseDataLength;
15101510 __u16 Reserved;
15111511 __le64 InodeType; /* LNK, FIFO, CHR etc. */
1512− char PathBuffer[];
1512+ __u8 DataBuffer[];
15131513 } __attribute__((packed));
15141514
15151515 struct cifs_quota_data {
fs/smb/client/cifsproto.h+13−1
@@ -210,7 +210,7 @@ int cifs_get_inode_info(struct inode **inode, const char *full_path, · 209 unmodified lines
210210 const struct cifs_fid *fid);
211211 bool cifs_reparse_point_to_fattr(struct cifs_sb_info *cifs_sb,
212212 struct cifs_fattr *fattr,
213− u32 tag);
213+ struct cifs_open_info_data *data);
214214 extern int smb311_posix_get_inode_info(struct inode **pinode, const char *search_path,
215215 struct super_block *sb, unsigned int xid);
216216 extern int cifs_get_inode_info_unix(struct inode **pinode,
@@ -458,6 +458,12 @@ extern int CIFSSMBUnixQuerySymLink(const unsigned int xid, · 241 unmodified lines
458458 struct cifs_tcon *tcon,
459459 const unsigned char *searchName, char **syminfo,
460460 const struct nls_table *nls_codepage, int remap);
461+extern int cifs_query_reparse_point(const unsigned int xid,
462+ struct cifs_tcon *tcon,
463+ struct cifs_sb_info *cifs_sb,
464+ const char *full_path,
465+ u32 *tag, struct kvec *rsp,
466+ int *rsp_buftype);
461467 extern int CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon,
462468 __u16 fid, char **symlinkinfo,
463469 const struct nls_table *nls_codepage);
@@ -659,6 +665,12 @@ void cifs_put_tcp_super(struct super_block *sb); · 195 unmodified lines
659665 int cifs_update_super_prepath(struct cifs_sb_info *cifs_sb, char *prefix);
660666 char *extract_hostname(const char *unc);
661667 char *extract_sharename(const char *unc);
668+int parse_reparse_point(struct reparse_data_buffer *buf,
669+ u32 plen, struct cifs_sb_info *cifs_sb,
670+ bool unicode, struct cifs_open_info_data *data);
671+int cifs_sfu_make_node(unsigned int xid, struct inode *inode,
672+ struct dentry *dentry, struct cifs_tcon *tcon,
673+ const char *full_path, umode_t mode, dev_t dev);
662674
663675 #ifdef CONFIG_CIFS_DFS_UPCALL
664676 static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses,
fs/smb/client/cifssmb.c+77−116
@@ -2690,136 +2690,97 @@ querySymLinkRetry: · 2689 unmodified lines
26902690 return rc;
26912691 }
26922692
2693−/*
2694− * Recent Windows versions now create symlinks more frequently
2695− * and they use the "reparse point" mechanism below. We can of course
2696− * do symlinks nicely to Samba and other servers which support the
2697− * CIFS Unix Extensions and we can also do SFU symlinks and "client only"
2698− * "MF" symlinks optionally, but for recent Windows we really need to
2699− * reenable the code below and fix the cifs_symlink callers to handle this.
2700− * In the interim this code has been moved to its own config option so
2701− * it is not compiled in by default until callers fixed up and more tested.
2702− */
2703−int
2704−CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon,
2705− __u16 fid, char **symlinkinfo,
2706− const struct nls_table *nls_codepage)
2693+int cifs_query_reparse_point(const unsigned int xid,
2694+ struct cifs_tcon *tcon,
2695+ struct cifs_sb_info *cifs_sb,
2696+ const char *full_path,
2697+ u32 *tag, struct kvec *rsp,
2698+ int *rsp_buftype)
27072699 {
2708− int rc = 0;
2709− int bytes_returned;
2710− struct smb_com_transaction_ioctl_req *pSMB;
2711− struct smb_com_transaction_ioctl_rsp *pSMBr;
2712− bool is_unicode;
2713− unsigned int sub_len;
2714− char *sub_start;
2715− struct reparse_symlink_data *reparse_buf;
2716− struct reparse_posix_data *posix_buf;
2700+ struct cifs_open_parms oparms;
2701+ TRANSACT_IOCTL_REQ *io_req = NULL;
2702+ TRANSACT_IOCTL_RSP *io_rsp = NULL;
2703+ struct cifs_fid fid;
27172704 __u32 data_offset, data_count;
2718− char *end_of_smb;
2705+ __u8 *start, *end;
2706+ int io_rsp_len;
2707+ int oplock = 0;
2708+ int rc;
27192709
2720− cifs_dbg(FYI, "In Windows reparse style QueryLink for fid %u\n", fid);
2721− rc = smb_init(SMB_COM_NT_TRANSACT, 23, tcon, (void **) &pSMB,
2722− (void **) &pSMBr);
2710+ cifs_tcon_dbg(FYI, "%s: path=%s\n", __func__, full_path);
2711+
2712+ if (cap_unix(tcon->ses))
2713+ return -EOPNOTSUPP;
2714+
2715+ oparms = (struct cifs_open_parms) {
2716+ .tcon = tcon,
2717+ .cifs_sb = cifs_sb,
2718+ .desired_access = FILE_READ_ATTRIBUTES,
2719+ .create_options = cifs_create_options(cifs_sb,
2720+ OPEN_REPARSE_POINT),
2721+ .disposition = FILE_OPEN,
2722+ .path = full_path,
2723+ .fid = &fid,
2724+ };
2725+
2726+ rc = CIFS_open(xid, &oparms, &oplock, NULL);
27232727 if (rc)
27242728 return rc;
27252729
2726− pSMB->TotalParameterCount = 0 ;
2727− pSMB->TotalDataCount = 0;
2728− pSMB->MaxParameterCount = cpu_to_le32(2);
2729− /* BB find exact data count max from sess structure BB */
2730− pSMB->MaxDataCount = cpu_to_le32(CIFSMaxBufSize & 0xFFFFFF00);
2731− pSMB->MaxSetupCount = 4;
2732− pSMB->Reserved = 0;
2733− pSMB->ParameterOffset = 0;
2734− pSMB->DataCount = 0;
2735− pSMB->DataOffset = 0;
2736− pSMB->SetupCount = 4;
2737− pSMB->SubCommand = cpu_to_le16(NT_TRANSACT_IOCTL);
2738− pSMB->ParameterCount = pSMB->TotalParameterCount;
2739− pSMB->FunctionCode = cpu_to_le32(FSCTL_GET_REPARSE_POINT);
2740− pSMB->IsFsctl = 1; /* FSCTL */
2741− pSMB->IsRootFlag = 0;
2742− pSMB->Fid = fid; /* file handle always le */
2743− pSMB->ByteCount = 0;
2730+ rc = smb_init(SMB_COM_NT_TRANSACT, 23, tcon,
2731+ (void **)&io_req, (void **)&io_rsp);
2732+ if (rc)
2733+ goto error;
27442734
2745− rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2746− (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2747− if (rc) {
2748− cifs_dbg(FYI, "Send error in QueryReparseLinkInfo = %d\n", rc);
2749− goto qreparse_out;
2750− }
2735+ io_req->TotalParameterCount = 0;
2736+ io_req->TotalDataCount = 0;
2737+ io_req->MaxParameterCount = cpu_to_le32(2);
2738+ /* BB find exact data count max from sess structure BB */
2739+ io_req->MaxDataCount = cpu_to_le32(CIFSMaxBufSize & 0xFFFFFF00);
2740+ io_req->MaxSetupCount = 4;
2741+ io_req->Reserved = 0;
2742+ io_req->ParameterOffset = 0;
2743+ io_req->DataCount = 0;
2744+ io_req->DataOffset = 0;
2745+ io_req->SetupCount = 4;
2746+ io_req->SubCommand = cpu_to_le16(NT_TRANSACT_IOCTL);
2747+ io_req->ParameterCount = io_req->TotalParameterCount;
2748+ io_req->FunctionCode = cpu_to_le32(FSCTL_GET_REPARSE_POINT);
2749+ io_req->IsFsctl = 1;
2750+ io_req->IsRootFlag = 0;
2751+ io_req->Fid = fid.netfid;
2752+ io_req->ByteCount = 0;
2753+
2754+ rc = SendReceive(xid, tcon->ses, (struct smb_hdr *)io_req,
2755+ (struct smb_hdr *)io_rsp, &io_rsp_len, 0);
2756+ if (rc)
2757+ goto error;
27512758
2752− data_offset = le32_to_cpu(pSMBr->DataOffset);
2753− data_count = le32_to_cpu(pSMBr->DataCount);
2754− if (get_bcc(&pSMBr->hdr) < 2 || data_offset > 512) {
2755− /* BB also check enough total bytes returned */
2756− rc = -EIO; /* bad smb */
2757− goto qreparse_out;
2758− }
2759− if (!data_count || (data_count > 2048)) {
2759+ data_offset = le32_to_cpu(io_rsp->DataOffset);
2760+ data_count = le32_to_cpu(io_rsp->DataCount);
2761+ if (get_bcc(&io_rsp->hdr) < 2 || data_offset > 512 ||
2762+ !data_count || data_count > 2048) {
27602763 rc = -EIO;
2761− cifs_dbg(FYI, "Invalid return data count on get reparse info ioctl\n");
2762− goto qreparse_out;
2763− }
2764− end_of_smb = 2 + get_bcc(&pSMBr->hdr) + (char *)&pSMBr->ByteCount;
2765− reparse_buf = (struct reparse_symlink_data *)
2766− ((char *)&pSMBr->hdr.Protocol + data_offset);
2767− if ((char *)reparse_buf >= end_of_smb) {
2768− rc = -EIO;
2769− goto qreparse_out;
2770− }
2771− if (reparse_buf->ReparseTag == cpu_to_le32(IO_REPARSE_TAG_NFS)) {
2772− cifs_dbg(FYI, "NFS style reparse tag\n");
2773− posix_buf = (struct reparse_posix_data *)reparse_buf;
2774−
2775− if (posix_buf->InodeType != cpu_to_le64(NFS_SPECFILE_LNK)) {
2776− cifs_dbg(FYI, "unsupported file type 0x%llx\n",
2777− le64_to_cpu(posix_buf->InodeType));
2778− rc = -EOPNOTSUPP;
2779− goto qreparse_out;
2780− }
2781− is_unicode = true;
2782− sub_len = le16_to_cpu(reparse_buf->ReparseDataLength);
2783− if (posix_buf->PathBuffer + sub_len > end_of_smb) {
2784− cifs_dbg(FYI, "reparse buf beyond SMB\n");
2785− rc = -EIO;
2786− goto qreparse_out;
2787− }
2788− *symlinkinfo = cifs_strndup_from_utf16(posix_buf->PathBuffer,
2789− sub_len, is_unicode, nls_codepage);
2790− goto qreparse_out;
2791− } else if (reparse_buf->ReparseTag !=
2792− cpu_to_le32(IO_REPARSE_TAG_SYMLINK)) {
2793− rc = -EOPNOTSUPP;
2794− goto qreparse_out;
2764+ goto error;
27952765 }
27962766
2797− /* Reparse tag is NTFS symlink */
2798− sub_start = le16_to_cpu(reparse_buf->SubstituteNameOffset) +
2799− reparse_buf->PathBuffer;
2800− sub_len = le16_to_cpu(reparse_buf->SubstituteNameLength);
2801− if (sub_start + sub_len > end_of_smb) {
2802− cifs_dbg(FYI, "reparse buf beyond SMB\n");
2767+ end = 2 + get_bcc(&io_rsp->hdr) + (__u8 *)&io_rsp->ByteCount;
2768+ start = (__u8 *)&io_rsp->hdr.Protocol + data_offset;
2769+ if (start >= end) {
28032770 rc = -EIO;
2804− goto qreparse_out;
2771+ goto error;
28052772 }
2806− if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
2807− is_unicode = true;
2808− else
2809− is_unicode = false;
2810−
2811− /* BB FIXME investigate remapping reserved chars here */
2812− *symlinkinfo = cifs_strndup_from_utf16(sub_start, sub_len, is_unicode,
2813− nls_codepage);
2814− if (!*symlinkinfo)
2815− rc = -ENOMEM;
2816−qreparse_out:
2817− cifs_buf_release(pSMB);
28182773
2819− /*
2820− * Note: On -EAGAIN error only caller can retry on handle based calls
2821− * since file handle passed in no longer valid.
2822− */
2774+ *tag = le32_to_cpu(((struct reparse_data_buffer *)start)->ReparseTag);
2775+ rsp->iov_base = io_rsp;
2776+ rsp->iov_len = io_rsp_len;
2777+ *rsp_buftype = CIFS_LARGE_BUFFER;
2778+ CIFSSMBClose(xid, tcon, fid.netfid);
2779+ return 0;
2780+
2781+error:
2782+ cifs_buf_release(io_req);
2783+ CIFSSMBClose(xid, tcon, fid.netfid);
28232784 return rc;
28242785 }
28252786
fs/smb/client/inode.c+60−14
@@ -459,8 +459,7 @@ static int cifs_get_unix_fattr(const unsigned char *full_path, · 458 unmodified lines
459459 return -EOPNOTSUPP;
460460 rc = server->ops->query_symlink(xid, tcon,
461461 cifs_sb, full_path,
462− &fattr->cf_symlink_target,
463− NULL);
462+ &fattr->cf_symlink_target);
464463 cifs_dbg(FYI, "%s: query_symlink: %d\n", __func__, rc);
465464 }
466465 return rc;
@@ -722,10 +721,51 @@ static void smb311_posix_info_to_fattr(struct cifs_fattr *fattr, · 255 unmodified lines
722721 fattr->cf_mode, fattr->cf_uniqueid, fattr->cf_nlink);
723722 }
724723
724+static inline dev_t nfs_mkdev(struct reparse_posix_data *buf)
725+{
726+ u64 v = le64_to_cpu(*(__le64 *)buf->DataBuffer);
727+
728+ return MKDEV(v >> 32, v & 0xffffffff);
729+}
730+
725731 bool cifs_reparse_point_to_fattr(struct cifs_sb_info *cifs_sb,
726732 struct cifs_fattr *fattr,
727− u32 tag)
733+ struct cifs_open_info_data *data)
728734 {
735+ struct reparse_posix_data *buf = data->reparse.posix;
736+ u32 tag = data->reparse.tag;
737+
738+ if (tag == IO_REPARSE_TAG_NFS && buf) {
739+ switch (le64_to_cpu(buf->InodeType)) {
740+ case NFS_SPECFILE_CHR:
741+ fattr->cf_mode |= S_IFCHR | cifs_sb->ctx->file_mode;
742+ fattr->cf_dtype = DT_CHR;
743+ fattr->cf_rdev = nfs_mkdev(buf);
744+ break;
745+ case NFS_SPECFILE_BLK:
746+ fattr->cf_mode |= S_IFBLK | cifs_sb->ctx->file_mode;
747+ fattr->cf_dtype = DT_BLK;
748+ fattr->cf_rdev = nfs_mkdev(buf);
749+ break;
750+ case NFS_SPECFILE_FIFO:
751+ fattr->cf_mode |= S_IFIFO | cifs_sb->ctx->file_mode;
752+ fattr->cf_dtype = DT_FIFO;
753+ break;
754+ case NFS_SPECFILE_SOCK:
755+ fattr->cf_mode |= S_IFSOCK | cifs_sb->ctx->file_mode;
756+ fattr->cf_dtype = DT_SOCK;
757+ break;
758+ case NFS_SPECFILE_LNK:
759+ fattr->cf_mode = S_IFLNK | cifs_sb->ctx->file_mode;
760+ fattr->cf_dtype = DT_LNK;
761+ break;
762+ default:
763+ WARN_ON_ONCE(1);
764+ return false;
765+ }
766+ return true;
767+ }
768+
729769 switch (tag) {
730770 case IO_REPARSE_TAG_LX_SYMLINK:
731771 fattr->cf_mode |= S_IFLNK | cifs_sb->ctx->file_mode;
@@ -791,7 +831,7 @@ static void cifs_open_info_to_fattr(struct cifs_fattr *fattr, · 59 unmodified lines
791831 fattr->cf_nlink = le32_to_cpu(info->NumberOfLinks);
792832
793833 if (cifs_open_data_reparse(data) &&
794− cifs_reparse_point_to_fattr(cifs_sb, fattr, data->reparse_tag))
834+ cifs_reparse_point_to_fattr(cifs_sb, fattr, data))
795835 goto out_reparse;
796836
797837 if (fattr->cf_cifsattrs & ATTR_DIRECTORY) {
@@ -856,7 +896,7 @@ cifs_get_file_info(struct file *filp) · 58 unmodified lines
856896 data.adjust_tz = false;
857897 if (data.symlink_target) {
858898 data.symlink = true;
859− data.reparse_tag = IO_REPARSE_TAG_SYMLINK;
899+ data.reparse.tag = IO_REPARSE_TAG_SYMLINK;
860900 }
861901 cifs_open_info_to_fattr(&fattr, &data, inode->i_sb);
862902 break;
@@ -1025,7 +1065,7 @@ static int reparse_info_to_fattr(struct cifs_open_info_data *data, · 162 unmodified lines
10251065 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
10261066 struct kvec rsp_iov, *iov = NULL;
10271067 int rsp_buftype = CIFS_NO_BUFFER;
1028− u32 tag = data->reparse_tag;
1068+ u32 tag = data->reparse.tag;
10291069 int rc = 0;
10301070
10311071 if (!tag && server->ops->query_reparse_point) {
@@ -1035,22 +1075,28 @@ static int reparse_info_to_fattr(struct cifs_open_info_data *data, · 3 unmodified lines
10351075 if (!rc)
10361076 iov = &rsp_iov;
10371077 }
1038− switch ((data->reparse_tag = tag)) {
1078+
1079+ rc = -EOPNOTSUPP;
1080+ switch ((data->reparse.tag = tag)) {
10391081 case 0: /* SMB1 symlink */
1040− iov = NULL;
1041− fallthrough;
1042− case IO_REPARSE_TAG_NFS:
1043− case IO_REPARSE_TAG_SYMLINK:
1044− if (!data->symlink_target && server->ops->query_symlink) {
1082+ if (server->ops->query_symlink) {
10451083 rc = server->ops->query_symlink(xid, tcon,
10461084 cifs_sb, full_path,
1047− &data->symlink_target,
1048− iov);
1085+ &data->symlink_target);
10491086 }
10501087 break;
10511088 case IO_REPARSE_TAG_MOUNT_POINT:
10521089 cifs_create_junction_fattr(fattr, sb);
1090+ rc = 0;
10531091 goto out;
1092+ default:
1093+ if (data->symlink_target) {
1094+ rc = 0;
1095+ } else if (server->ops->parse_reparse_point) {
1096+ rc = server->ops->parse_reparse_point(cifs_sb,
1097+ iov, data);
1098+ }
1099+ break;
10541100 }
10551101
10561102 cifs_open_info_to_fattr(fattr, data, sb);
fs/smb/client/readdir.c+5−1
@@ -153,6 +153,10 @@ static bool reparse_file_needs_reval(const struct cifs_fattr *fattr) · 152 unmodified lines
153153 static void
154154 cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)
155155 {
156+ struct cifs_open_info_data data = {
157+ .reparse = { .tag = fattr->cf_cifstag, },
158+ };
159+
156160 fattr->cf_uid = cifs_sb->ctx->linux_uid;
157161 fattr->cf_gid = cifs_sb->ctx->linux_gid;
158162
@@ -165,7 +169,7 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb) · 6 unmodified lines
165169 * reasonably map some of them to directories vs. files vs. symlinks
166170 */
167171 if ((fattr->cf_cifsattrs & ATTR_REPARSE) &&
168− cifs_reparse_point_to_fattr(cifs_sb, fattr, fattr->cf_cifstag))
172+ cifs_reparse_point_to_fattr(cifs_sb, fattr, &data))
169173 goto out_reparse;
170174
171175 if (fattr->cf_cifsattrs & ATTR_DIRECTORY) {
fs/smb/client/sess.c+1−1
@@ -332,10 +332,10 @@ cifs_disable_secondary_channels(struct cifs_ses *ses) · 331 unmodified lines
332332
333333 if (iface) {
334334 spin_lock(&ses->iface_lock);
335− kref_put(&iface->refcount, release_iface);
336335 iface->num_channels--;
337336 if (iface->weight_fulfilled)
338337 iface->weight_fulfilled--;
338+ kref_put(&iface->refcount, release_iface);
339339 spin_unlock(&ses->iface_lock);
340340 }
341341
fs/smb/client/smb1ops.c+32−121
@@ -976,64 +976,37 @@ static int cifs_query_symlink(const unsigned int xid, · 975 unmodified lines
976976 struct cifs_tcon *tcon,
977977 struct cifs_sb_info *cifs_sb,
978978 const char *full_path,
979− char **target_path,
980− struct kvec *rsp_iov)
979+ char **target_path)
981980 {
982981 int rc;
983− int oplock = 0;
984− bool is_reparse_point = !!rsp_iov;
985− struct cifs_fid fid;
986− struct cifs_open_parms oparms;
987982
988− cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);
983+ cifs_tcon_dbg(FYI, "%s: path=%s\n", __func__, full_path);
989984
990− if (is_reparse_point) {
991− cifs_dbg(VFS, "reparse points not handled for SMB1 symlinks\n");
985+ if (!cap_unix(tcon->ses))
992986 return -EOPNOTSUPP;
993− }
994−
995− /* Check for unix extensions */
996− if (cap_unix(tcon->ses)) {
997− rc = CIFSSMBUnixQuerySymLink(xid, tcon, full_path, target_path,
998− cifs_sb->local_nls,
999− cifs_remap(cifs_sb));
1000− if (rc == -EREMOTE)
1001− rc = cifs_unix_dfs_readlink(xid, tcon, full_path,
1002− target_path,
1003− cifs_sb->local_nls);
1004−
1005− goto out;
1006− }
1007−
1008− oparms = (struct cifs_open_parms) {
1009− .tcon = tcon,
1010− .cifs_sb = cifs_sb,
1011− .desired_access = FILE_READ_ATTRIBUTES,
1012− .create_options = cifs_create_options(cifs_sb,
1013− OPEN_REPARSE_POINT),
1014− .disposition = FILE_OPEN,
1015− .path = full_path,
1016− .fid = &fid,
1017− };
1018−
1019− rc = CIFS_open(xid, &oparms, &oplock, NULL);
1020− if (rc)
1021− goto out;
1022−
1023− rc = CIFSSMBQuerySymLink(xid, tcon, fid.netfid, target_path,
1024− cifs_sb->local_nls);
1025− if (rc)
1026− goto out_close;
1027987
1028− convert_delimiter(*target_path, '/');
1029−out_close:
1030− CIFSSMBClose(xid, tcon, fid.netfid);
1031−out:
1032− if (!rc)
1033− cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);
988+ rc = CIFSSMBUnixQuerySymLink(xid, tcon, full_path, target_path,
989+ cifs_sb->local_nls, cifs_remap(cifs_sb));
990+ if (rc == -EREMOTE)
991+ rc = cifs_unix_dfs_readlink(xid, tcon, full_path,
992+ target_path, cifs_sb->local_nls);
1034993 return rc;
1035994 }
1036995
996+static int cifs_parse_reparse_point(struct cifs_sb_info *cifs_sb,
997+ struct kvec *rsp_iov,
998+ struct cifs_open_info_data *data)
999+{
1000+ struct reparse_data_buffer *buf;
1001+ TRANSACT_IOCTL_RSP *io = rsp_iov->iov_base;
1002+ bool unicode = !!(io->hdr.Flags2 & SMBFLG2_UNICODE);
1003+ u32 plen = le16_to_cpu(io->ByteCount);
1004+
1005+ buf = (struct reparse_data_buffer *)((__u8 *)&io->hdr.Protocol +
1006+ le32_to_cpu(io->DataOffset));
1007+ return parse_reparse_point(buf, plen, cifs_sb, unicode, data);
1008+}
1009+
10371010 static bool
10381011 cifs_is_read_op(__u32 oplock)
10391012 {
@@ -1068,15 +1041,7 @@ cifs_make_node(unsigned int xid, struct inode *inode, · 28 unmodified lines
10681041 {
10691042 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
10701043 struct inode *newinode = NULL;
1071− int rc = -EPERM;
1072− struct cifs_open_info_data buf = {};
1073− struct cifs_io_parms io_parms;
1074− __u32 oplock = 0;
1075− struct cifs_fid fid;
1076− struct cifs_open_parms oparms;
1077− unsigned int bytes_written;
1078− struct win_dev *pdev;
1079− struct kvec iov[2];
1044+ int rc;
10801045
10811046 if (tcon->unix_ext) {
10821047 /*
@@ -1110,74 +1075,18 @@ cifs_make_node(unsigned int xid, struct inode *inode, · 27 unmodified lines
11101075 d_instantiate(dentry, newinode);
11111076 return rc;
11121077 }
1113−
11141078 /*
1115− * SMB1 SFU emulation: should work with all servers, but only
1116− * support block and char device (no socket & fifo)
1079+ * Check if mounted with mount parm 'sfu' mount parm.
1080+ * SFU emulation should work with all servers, but only
1081+ * supports block and char device (no socket & fifo),
1082+ * and was used by default in earlier versions of Windows
11171083 */
11181084 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))
1119− return rc;
1120−
1121− if (!S_ISCHR(mode) && !S_ISBLK(mode))
1122− return rc;
1123−
1124− cifs_dbg(FYI, "sfu compat create special file\n");
1125−
1126− oparms = (struct cifs_open_parms) {
1127− .tcon = tcon,
1128− .cifs_sb = cifs_sb,
1129− .desired_access = GENERIC_WRITE,
1130− .create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR |
1131− CREATE_OPTION_SPECIAL),
1132− .disposition = FILE_CREATE,
1133− .path = full_path,
1134− .fid = &fid,
1135− };
1136−
1137− if (tcon->ses->server->oplocks)
1138− oplock = REQ_OPLOCK;
1139− else
1140− oplock = 0;
1141− rc = tcon->ses->server->ops->open(xid, &oparms, &oplock, &buf);
1142− if (rc)
1143− return rc;
1144−
1145− /*
1146− * BB Do not bother to decode buf since no local inode yet to put
1147− * timestamps in, but we can reuse it safely.
1148− */
1149−
1150− pdev = (struct win_dev *)&buf.fi;
1151− io_parms.pid = current->tgid;
1152− io_parms.tcon = tcon;
1153− io_parms.offset = 0;
1154− io_parms.length = sizeof(struct win_dev);
1155− iov[1].iov_base = &buf.fi;
1156− iov[1].iov_len = sizeof(struct win_dev);
1157− if (S_ISCHR(mode)) {
1158− memcpy(pdev->type, "IntxCHR", 8);
1159− pdev->major = cpu_to_le64(MAJOR(dev));
1160− pdev->minor = cpu_to_le64(MINOR(dev));
1161− rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
1162− &bytes_written, iov, 1);
1163− } else if (S_ISBLK(mode)) {
1164− memcpy(pdev->type, "IntxBLK", 8);
1165− pdev->major = cpu_to_le64(MAJOR(dev));
1166− pdev->minor = cpu_to_le64(MINOR(dev));
1167− rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
1168− &bytes_written, iov, 1);
1169− }
1170− tcon->ses->server->ops->close(xid, tcon, &fid);
1171− d_drop(dentry);
1172−
1173− /* FIXME: add code here to set EAs */
1174−
1175− cifs_free_open_info(&buf);
1176− return rc;
1085+ return -EPERM;
1086+ return cifs_sfu_make_node(xid, inode, dentry, tcon,
1087+ full_path, mode, dev);
11771088 }
11781089
1179−
1180−
11811090 struct smb_version_operations smb1_operations = {
11821091 .send_cancel = send_nt_cancel,
11831092 .compare_fids = cifs_compare_fids,
@@ -1214,6 +1123,7 @@ struct smb_version_operations smb1_operations = { · 30 unmodified lines
12141123 .is_path_accessible = cifs_is_path_accessible,
12151124 .can_echo = cifs_can_echo,
12161125 .query_path_info = cifs_query_path_info,
1126+ .query_reparse_point = cifs_query_reparse_point,
12171127 .query_file_info = cifs_query_file_info,
12181128 .get_srv_inum = cifs_get_srv_inum,
12191129 .set_path_size = CIFSSMBSetEOF,
@@ -1229,6 +1139,7 @@ struct smb_version_operations smb1_operations = { · 9 unmodified lines
12291139 .rename = CIFSSMBRename,
12301140 .create_hardlink = CIFSCreateHardLink,
12311141 .query_symlink = cifs_query_symlink,
1142+ .parse_reparse_point = cifs_parse_reparse_point,
12321143 .open = cifs_open_file,
12331144 .set_fid = cifs_set_fid,
12341145 .close = cifs_close_file,
fs/smb/client/smb2inode.c+1−1
@@ -555,7 +555,7 @@ static int parse_create_response(struct cifs_open_info_data *data, · 554 unmodified lines
555555 break;
556556 }
557557 data->reparse_point = reparse_point;
558− data->reparse_tag = tag;
558+ data->reparse.tag = tag;
559559 return rc;
560560 }
561561
fs/smb/client/smb2ops.c+112−115
@@ -2866,115 +2866,119 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses, · 2865 unmodified lines
28662866 return rc;
28672867 }
28682868
2869−static int
2870−parse_reparse_posix(struct reparse_posix_data *symlink_buf,
2871− u32 plen, char **target_path,
2872− struct cifs_sb_info *cifs_sb)
2869+/* See MS-FSCC 2.1.2.6 for the 'NFS' style reparse tags */
2870+static int parse_reparse_posix(struct reparse_posix_data *buf,
2871+ struct cifs_sb_info *cifs_sb,
2872+ struct cifs_open_info_data *data)
28732873 {
28742874 unsigned int len;
2875−
2876− /* See MS-FSCC 2.1.2.6 for the 'NFS' style reparse tags */
2877− len = le16_to_cpu(symlink_buf->ReparseDataLength);
2878−
2879− if (le64_to_cpu(symlink_buf->InodeType) != NFS_SPECFILE_LNK) {
2880− cifs_dbg(VFS, "%lld not a supported symlink type\n",
2881− le64_to_cpu(symlink_buf->InodeType));
2875+ u64 type;
2876+
2877+ switch ((type = le64_to_cpu(buf->InodeType))) {
2878+ case NFS_SPECFILE_LNK:
2879+ len = le16_to_cpu(buf->ReparseDataLength);
2880+ data->symlink_target = cifs_strndup_from_utf16(buf->DataBuffer,
2881+ len, true,
2882+ cifs_sb->local_nls);
2883+ if (!data->symlink_target)
2884+ return -ENOMEM;
2885+ convert_delimiter(data->symlink_target, '/');
2886+ cifs_dbg(FYI, "%s: target path: %s\n",
2887+ __func__, data->symlink_target);
2888+ break;
2889+ case NFS_SPECFILE_CHR:
2890+ case NFS_SPECFILE_BLK:
2891+ case NFS_SPECFILE_FIFO:
2892+ case NFS_SPECFILE_SOCK:
2893+ break;
2894+ default:
2895+ cifs_dbg(VFS, "%s: unhandled inode type: 0x%llx\n",
2896+ __func__, type);
28822897 return -EOPNOTSUPP;
28832898 }
2884−
2885− *target_path = cifs_strndup_from_utf16(
2886− symlink_buf->PathBuffer,
2887− len, true, cifs_sb->local_nls);
2888− if (!(*target_path))
2889− return -ENOMEM;
2890−
2891− convert_delimiter(*target_path, '/');
2892− cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);
2893−
28942899 return 0;
28952900 }
28962901
2897−static int
2898−parse_reparse_symlink(struct reparse_symlink_data_buffer *symlink_buf,
2899− u32 plen, char **target_path,
2900− struct cifs_sb_info *cifs_sb)
2902+static int parse_reparse_symlink(struct reparse_symlink_data_buffer *sym,
2903+ u32 plen, bool unicode,
2904+ struct cifs_sb_info *cifs_sb,
2905+ struct cifs_open_info_data *data)
29012906 {
2902− unsigned int sub_len;
2903− unsigned int sub_offset;
2907+ unsigned int len;
2908+ unsigned int offs;
29042909
29052910 /* We handle Symbolic Link reparse tag here. See: MS-FSCC 2.1.2.4 */
29062911
2907− sub_offset = le16_to_cpu(symlink_buf->SubstituteNameOffset);
2908− sub_len = le16_to_cpu(symlink_buf->SubstituteNameLength);
2909− if (sub_offset + 20 > plen ||
2910− sub_offset + sub_len + 20 > plen) {
2912+ offs = le16_to_cpu(sym->SubstituteNameOffset);
2913+ len = le16_to_cpu(sym->SubstituteNameLength);
2914+ if (offs + 20 > plen || offs + len + 20 > plen) {
29112915 cifs_dbg(VFS, "srv returned malformed symlink buffer\n");
29122916 return -EIO;
29132917 }
29142918
2915− *target_path = cifs_strndup_from_utf16(
2916− symlink_buf->PathBuffer + sub_offset,
2917− sub_len, true, cifs_sb->local_nls);
2918− if (!(*target_path))
2919+ data->symlink_target = cifs_strndup_from_utf16(sym->PathBuffer + offs,
2920+ len, unicode,
2921+ cifs_sb->local_nls);
2922+ if (!data->symlink_target)
29192923 return -ENOMEM;
29202924
2921− convert_delimiter(*target_path, '/');
2922− cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);
2925+ convert_delimiter(data->symlink_target, '/');
2926+ cifs_dbg(FYI, "%s: target path: %s\n", __func__, data->symlink_target);
29232927
29242928 return 0;
29252929 }
29262930
2927−static int
2928−parse_reparse_point(struct reparse_data_buffer *buf,
2929− u32 plen, char **target_path,
2930− struct cifs_sb_info *cifs_sb)
2931+int parse_reparse_point(struct reparse_data_buffer *buf,
2932+ u32 plen, struct cifs_sb_info *cifs_sb,
2933+ bool unicode, struct cifs_open_info_data *data)
29312934 {
2932− if (plen < sizeof(struct reparse_data_buffer)) {
2933− cifs_dbg(VFS, "reparse buffer is too small. Must be at least 8 bytes but was %d\n",
2934− plen);
2935+ if (plen < sizeof(*buf)) {
2936+ cifs_dbg(VFS, "%s: reparse buffer is too small. Must be at least 8 bytes but was %d\n",
2937+ __func__, plen);
29352938 return -EIO;
29362939 }
29372940
2938− if (plen < le16_to_cpu(buf->ReparseDataLength) +
2939− sizeof(struct reparse_data_buffer)) {
2940− cifs_dbg(VFS, "srv returned invalid reparse buf length: %d\n",
2941− plen);
2941+ if (plen < le16_to_cpu(buf->ReparseDataLength) + sizeof(*buf)) {
2942+ cifs_dbg(VFS, "%s: invalid reparse buf length: %d\n",
2943+ __func__, plen);
29422944 return -EIO;
29432945 }
29442946
2947+ data->reparse.buf = buf;
2948+
29452949 /* See MS-FSCC 2.1.2 */
29462950 switch (le32_to_cpu(buf->ReparseTag)) {
29472951 case IO_REPARSE_TAG_NFS:
2948− return parse_reparse_posix(
2949− (struct reparse_posix_data *)buf,
2950− plen, target_path, cifs_sb);
2952+ return parse_reparse_posix((struct reparse_posix_data *)buf,
2953+ cifs_sb, data);
29512954 case IO_REPARSE_TAG_SYMLINK:
29522955 return parse_reparse_symlink(
29532956 (struct reparse_symlink_data_buffer *)buf,
2954− plen, target_path, cifs_sb);
2957+ plen, unicode, cifs_sb, data);
2958+ case IO_REPARSE_TAG_LX_SYMLINK:
2959+ case IO_REPARSE_TAG_AF_UNIX:
2960+ case IO_REPARSE_TAG_LX_FIFO:
2961+ case IO_REPARSE_TAG_LX_CHR:
2962+ case IO_REPARSE_TAG_LX_BLK:
2963+ return 0;
29552964 default:
2956− cifs_dbg(VFS, "srv returned unknown symlink buffer tag:0x%08x\n",
2957− le32_to_cpu(buf->ReparseTag));
2965+ cifs_dbg(VFS, "%s: unhandled reparse tag: 0x%08x\n",
2966+ __func__, le32_to_cpu(buf->ReparseTag));
29582967 return -EOPNOTSUPP;
29592968 }
29602969 }
29612970
2962−static int smb2_query_symlink(const unsigned int xid,
2963− struct cifs_tcon *tcon,
2964− struct cifs_sb_info *cifs_sb,
2965− const char *full_path,
2966− char **target_path,
2967− struct kvec *rsp_iov)
2971+static int smb2_parse_reparse_point(struct cifs_sb_info *cifs_sb,
2972+ struct kvec *rsp_iov,
2973+ struct cifs_open_info_data *data)
29682974 {
29692975 struct reparse_data_buffer *buf;
29702976 struct smb2_ioctl_rsp *io = rsp_iov->iov_base;
29712977 u32 plen = le32_to_cpu(io->OutputCount);
29722978
2973− cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);
2974−
29752979 buf = (struct reparse_data_buffer *)((u8 *)io +
29762980 le32_to_cpu(io->OutputOffset));
2977− return parse_reparse_point(buf, plen, target_path, cifs_sb);
2981+ return parse_reparse_point(buf, plen, cifs_sb, true, data);
29782982 }
29792983
29802984 static int smb2_query_reparse_point(const unsigned int xid,
@@ -5064,41 +5068,24 @@ smb2_next_header(char *buf) · 2083 unmodified lines
50645068 return le32_to_cpu(hdr->NextCommand);
50655069 }
50665070
5067−static int
5068−smb2_make_node(unsigned int xid, struct inode *inode,
5069− struct dentry *dentry, struct cifs_tcon *tcon,
5070− const char *full_path, umode_t mode, dev_t dev)
5071+int cifs_sfu_make_node(unsigned int xid, struct inode *inode,
5072+ struct dentry *dentry, struct cifs_tcon *tcon,
5073+ const char *full_path, umode_t mode, dev_t dev)
50715074 {
5072− struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
5073− int rc = -EPERM;
50745075 struct cifs_open_info_data buf = {};
5075− struct cifs_io_parms io_parms = {0};
5076− __u32 oplock = 0;
5077− struct cifs_fid fid;
5076+ struct TCP_Server_Info *server = tcon->ses->server;
50785077 struct cifs_open_parms oparms;
5078+ struct cifs_io_parms io_parms = {};
5079+ struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
5080+ struct cifs_fid fid;
50795081 unsigned int bytes_written;
50805082 struct win_dev *pdev;
50815083 struct kvec iov[2];
5082−
5083− /*
5084− * Check if mounted with mount parm 'sfu' mount parm.
5085− * SFU emulation should work with all servers, but only
5086− * supports block and char device (no socket & fifo),
5087− * and was used by default in earlier versions of Windows
5088− */
5089− if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))
5090− return rc;
5091−
5092− /*
5093− * TODO: Add ability to create instead via reparse point. Windows (e.g.
5094− * their current NFS server) uses this approach to expose special files
5095− * over SMB2/SMB3 and Samba will do this with SMB3.1.1 POSIX Extensions
5096− */
5084+ __u32 oplock = server->oplocks ? REQ_OPLOCK : 0;
5085+ int rc;
50975086
50985087 if (!S_ISCHR(mode) && !S_ISBLK(mode) && !S_ISFIFO(mode))
5099− return rc;
5100−
5101− cifs_dbg(FYI, "sfu compat create special file\n");
5088+ return -EPERM;
51025089
51035090 oparms = (struct cifs_open_parms) {
51045091 .tcon = tcon,
@@ -5111,11 +5098,7 @@ smb2_make_node(unsigned int xid, struct inode *inode, · 6 unmodified lines
51115098 .fid = &fid,
51125099 };
51135100
5114− if (tcon->ses->server->oplocks)
5115− oplock = REQ_OPLOCK;
5116− else
5117− oplock = 0;
5118− rc = tcon->ses->server->ops->open(xid, &oparms, &oplock, &buf);
5101+ rc = server->ops->open(xid, &oparms, &oplock, &buf);
51195102 if (rc)
51205103 return rc;
51215104
@@ -5123,42 +5106,56 @@ smb2_make_node(unsigned int xid, struct inode *inode, · 1 unmodified line
51235106 * BB Do not bother to decode buf since no local inode yet to put
51245107 * timestamps in, but we can reuse it safely.
51255108 */
5126−
51275109 pdev = (struct win_dev *)&buf.fi;
51285110 io_parms.pid = current->tgid;
51295111 io_parms.tcon = tcon;
5130− io_parms.offset = 0;
5131− io_parms.length = sizeof(struct win_dev);
5132− iov[1].iov_base = &buf.fi;
5133− iov[1].iov_len = sizeof(struct win_dev);
5112+ io_parms.length = sizeof(*pdev);
5113+ iov[1].iov_base = pdev;
5114+ iov[1].iov_len = sizeof(*pdev);
51345115 if (S_ISCHR(mode)) {
51355116 memcpy(pdev->type, "IntxCHR", 8);
51365117 pdev->major = cpu_to_le64(MAJOR(dev));
51375118 pdev->minor = cpu_to_le64(MINOR(dev));
5138− rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
5139− &bytes_written, iov, 1);
51405119 } else if (S_ISBLK(mode)) {
51415120 memcpy(pdev->type, "IntxBLK", 8);
51425121 pdev->major = cpu_to_le64(MAJOR(dev));
51435122 pdev->minor = cpu_to_le64(MINOR(dev));
5144− rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
5145− &bytes_written, iov, 1);
51465123 } else if (S_ISFIFO(mode)) {
51475124 memcpy(pdev->type, "LnxFIFO", 8);
5148− pdev->major = 0;
5149− pdev->minor = 0;
5150− rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
5151− &bytes_written, iov, 1);
51525125 }
5153− tcon->ses->server->ops->close(xid, tcon, &fid);
5154− d_drop(dentry);
51555126
5127+ rc = server->ops->sync_write(xid, &fid, &io_parms,
5128+ &bytes_written, iov, 1);
5129+ server->ops->close(xid, tcon, &fid);
5130+ d_drop(dentry);
51565131 /* FIXME: add code here to set EAs */
5157−
51585132 cifs_free_open_info(&buf);
51595133 return rc;
51605134 }
51615135
5136+static int smb2_make_node(unsigned int xid, struct inode *inode,
5137+ struct dentry *dentry, struct cifs_tcon *tcon,
5138+ const char *full_path, umode_t mode, dev_t dev)
5139+{
5140+ struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
5141+
5142+ /*
5143+ * Check if mounted with mount parm 'sfu' mount parm.
5144+ * SFU emulation should work with all servers, but only
5145+ * supports block and char device (no socket & fifo),
5146+ * and was used by default in earlier versions of Windows
5147+ */
5148+ if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))
5149+ return -EPERM;
5150+ /*
5151+ * TODO: Add ability to create instead via reparse point. Windows (e.g.
5152+ * their current NFS server) uses this approach to expose special files
5153+ * over SMB2/SMB3 and Samba will do this with SMB3.1.1 POSIX Extensions
5154+ */
5155+ return cifs_sfu_make_node(xid, inode, dentry, tcon,
5156+ full_path, mode, dev);
5157+}
5158+
51625159 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
51635160 struct smb_version_operations smb20_operations = {
51645161 .compare_fids = smb2_compare_fids,
@@ -5209,7 +5206,7 @@ struct smb_version_operations smb20_operations = { · 44 unmodified lines
52095206 .unlink = smb2_unlink,
52105207 .rename = smb2_rename_path,
52115208 .create_hardlink = smb2_create_hardlink,
5212− .query_symlink = smb2_query_symlink,
5209+ .parse_reparse_point = smb2_parse_reparse_point,
52135210 .query_mf_symlink = smb3_query_mf_symlink,
52145211 .create_mf_symlink = smb3_create_mf_symlink,
52155212 .open = smb2_open_file,
@@ -5311,7 +5308,7 @@ struct smb_version_operations smb21_operations = { · 95 unmodified lines
53115308 .unlink = smb2_unlink,
53125309 .rename = smb2_rename_path,
53135310 .create_hardlink = smb2_create_hardlink,
5314− .query_symlink = smb2_query_symlink,
5311+ .parse_reparse_point = smb2_parse_reparse_point,
53155312 .query_mf_symlink = smb3_query_mf_symlink,
53165313 .create_mf_symlink = smb3_create_mf_symlink,
53175314 .open = smb2_open_file,
@@ -5416,7 +5413,7 @@ struct smb_version_operations smb30_operations = { · 98 unmodified lines
54165413 .unlink = smb2_unlink,
54175414 .rename = smb2_rename_path,
54185415 .create_hardlink = smb2_create_hardlink,
5419− .query_symlink = smb2_query_symlink,
5416+ .parse_reparse_point = smb2_parse_reparse_point,
54205417 .query_mf_symlink = smb3_query_mf_symlink,
54215418 .create_mf_symlink = smb3_create_mf_symlink,
54225419 .open = smb2_open_file,
@@ -5530,7 +5527,7 @@ struct smb_version_operations smb311_operations = { · 107 unmodified lines
55305527 .unlink = smb2_unlink,
55315528 .rename = smb2_rename_path,
55325529 .create_hardlink = smb2_create_hardlink,
5533− .query_symlink = smb2_query_symlink,
5530+ .parse_reparse_point = smb2_parse_reparse_point,
55345531 .query_mf_symlink = smb3_query_mf_symlink,
55355532 .create_mf_symlink = smb3_create_mf_symlink,
55365533 .open = smb2_open_file,
fs/smb/server/ksmbd_work.c+8−2
@@ -56,6 +56,9 @@ void ksmbd_free_work_struct(struct ksmbd_work *work) · 55 unmodified lines
5656 kfree(work->tr_buf);
5757 kvfree(work->request_buf);
5858 kfree(work->iov);
59+ if (!list_empty(&work->interim_entry))
60+ list_del(&work->interim_entry);
61+
5962 if (work->async_id)
6063 ksmbd_release_id(&work->conn->async_ida, work->async_id);
6164 kmem_cache_free(work_cache, work);
@@ -106,7 +109,7 @@ static inline void __ksmbd_iov_pin(struct ksmbd_work *work, void *ib, · 44 unmodified lines
106109 static int __ksmbd_iov_pin_rsp(struct ksmbd_work *work, void *ib, int len,
107110 void *aux_buf, unsigned int aux_size)
108111 {
109− struct aux_read *ar;
112+ struct aux_read *ar = NULL;
110113 int need_iov_cnt = 1;
111114
112115 if (aux_size) {
@@ -123,8 +126,11 @@ static int __ksmbd_iov_pin_rsp(struct ksmbd_work *work, void *ib, int len, · 10 unmodified lines
123126 new = krealloc(work->iov,
124127 sizeof(struct kvec) * work->iov_alloc_cnt,
125128 GFP_KERNEL | __GFP_ZERO);
126− if (!new)
129+ if (!new) {
130+ kfree(ar);
131+ work->iov_alloc_cnt -= 4;
127132 return -ENOMEM;
133+ }
128134 work->iov = new;
129135 }
130136
fs/smb/server/oplock.c+2−1
@@ -833,7 +833,8 @@ static int smb2_lease_break_noti(struct oplock_info *opinfo) · 832 unmodified lines
833833 interim_entry);
834834 setup_async_work(in_work, NULL, NULL);
835835 smb2_send_interim_resp(in_work, STATUS_PENDING);
836− list_del(&in_work->interim_entry);
836+ list_del_init(&in_work->interim_entry);
837+ release_async_work(in_work);
837838 }
838839 INIT_WORK(&work->work, __smb2_lease_break_noti);
839840 ksmbd_queue_work(work);
fs/smb/server/smb2pdu.c+82−80
@@ -657,13 +657,9 @@ smb2_get_name(const char *src, const int maxlen, struct nls_table *local_nls) · 656 unmodified lines
657657
658658 int setup_async_work(struct ksmbd_work *work, void (*fn)(void **), void **arg)
659659 {
660− struct smb2_hdr *rsp_hdr;
661660 struct ksmbd_conn *conn = work->conn;
662661 int id;
663662
664− rsp_hdr = ksmbd_resp_buf_next(work);
665− rsp_hdr->Flags |= SMB2_FLAGS_ASYNC_COMMAND;
666−
667663 id = ksmbd_acquire_async_msg_id(&conn->async_ida);
668664 if (id < 0) {
669665 pr_err("Failed to alloc async message id\n");
@@ -671,7 +667,6 @@ int setup_async_work(struct ksmbd_work *work, void (*fn)(void **), void **arg) · 1 unmodified line
671667 }
672668 work->asynchronous = true;
673669 work->async_id = id;
674− rsp_hdr->Id.AsyncId = cpu_to_le64(id);
675670
676671 ksmbd_debug(SMB,
677672 "Send interim Response to inform async request id : %d\n",
@@ -723,6 +718,8 @@ void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status) · 45 unmodified lines
723718 __SMB2_HEADER_STRUCTURE_SIZE);
724719
725720 rsp_hdr = smb2_get_msg(in_work->response_buf);
721+ rsp_hdr->Flags |= SMB2_FLAGS_ASYNC_COMMAND;
722+ rsp_hdr->Id.AsyncId = cpu_to_le64(work->async_id);
726723 smb2_set_err_rsp(in_work);
727724 rsp_hdr->Status = status;
728725
@@ -2380,7 +2377,8 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len, · 1651 unmodified lines
23802377 rc = 0;
23812378 } else {
23822379 rc = ksmbd_vfs_setxattr(idmap, path, attr_name, value,
2383− le16_to_cpu(eabuf->EaValueLength), 0);
2380+ le16_to_cpu(eabuf->EaValueLength),
2381+ 0, true);
23842382 if (rc < 0) {
23852383 ksmbd_debug(SMB,
23862384 "ksmbd_vfs_setxattr is failed(%d)\n",
@@ -2443,7 +2441,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path, · 56 unmodified lines
24432441 return -EBADF;
24442442 }
24452443
2446− rc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name, NULL, 0, 0);
2444+ rc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name, NULL, 0, 0, false);
24472445 if (rc < 0)
24482446 pr_err("Failed to store XATTR stream name :%d\n", rc);
24492447 return 0;
@@ -2518,7 +2516,7 @@ static void smb2_new_xattrs(struct ksmbd_tree_connect *tcon, const struct path * · 68 unmodified lines
25182516 da.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |
25192517 XATTR_DOSINFO_ITIME;
25202518
2521− rc = ksmbd_vfs_set_dos_attrib_xattr(mnt_idmap(path->mnt), path, &da);
2519+ rc = ksmbd_vfs_set_dos_attrib_xattr(mnt_idmap(path->mnt), path, &da, false);
25222520 if (rc)
25232521 ksmbd_debug(SMB, "failed to store file attribute into xattr\n");
25242522 }
@@ -2608,7 +2606,7 @@ static int smb2_create_sd_buffer(struct ksmbd_work *work, · 83 unmodified lines
26082606 sizeof(struct create_sd_buf_req))
26092607 return -EINVAL;
26102608 return set_info_sec(work->conn, work->tcon, path, &sd_buf->ntsd,
2611− le32_to_cpu(sd_buf->ccontext.DataLength), true);
2609+ le32_to_cpu(sd_buf->ccontext.DataLength), true, false);
26122610 }
26132611
26142612 static void ksmbd_acls_fattr(struct smb_fattr *fattr,
@@ -2690,7 +2688,7 @@ int smb2_open(struct ksmbd_work *work) · 75 unmodified lines
26902688 *(char *)req->Buffer == '\\') {
26912689 pr_err("not allow directory name included leading slash\n");
26922690 rc = -EINVAL;
2693− goto err_out1;
2691+ goto err_out2;
26942692 }
26952693
26962694 name = smb2_get_name(req->Buffer,
@@ -2701,7 +2699,7 @@ int smb2_open(struct ksmbd_work *work) · 4 unmodified lines
27012699 if (rc != -ENOMEM)
27022700 rc = -ENOENT;
27032701 name = NULL;
2704− goto err_out1;
2702+ goto err_out2;
27052703 }
27062704
27072705 ksmbd_debug(SMB, "converted name = %s\n", name);
@@ -2709,28 +2707,28 @@ int smb2_open(struct ksmbd_work *work) · 1 unmodified line
27092707 if (!test_share_config_flag(work->tcon->share_conf,
27102708 KSMBD_SHARE_FLAG_STREAMS)) {
27112709 rc = -EBADF;
2712− goto err_out1;
2710+ goto err_out2;
27132711 }
27142712 rc = parse_stream_name(name, &stream_name, &s_type);
27152713 if (rc < 0)
2716− goto err_out1;
2714+ goto err_out2;
27172715 }
27182716
27192717 rc = ksmbd_validate_filename(name);
27202718 if (rc < 0)
2721− goto err_out1;
2719+ goto err_out2;
27222720
27232721 if (ksmbd_share_veto_filename(share, name)) {
27242722 rc = -ENOENT;
27252723 ksmbd_debug(SMB, "Reject open(), vetoed file: %s\n",
27262724 name);
2727− goto err_out1;
2725+ goto err_out2;
27282726 }
27292727 } else {
27302728 name = kstrdup("", GFP_KERNEL);
27312729 if (!name) {
27322730 rc = -ENOMEM;
2733− goto err_out1;
2731+ goto err_out2;
27342732 }
27352733 }
27362734
@@ -2743,14 +2741,14 @@ int smb2_open(struct ksmbd_work *work) · 6 unmodified lines
27432741 le32_to_cpu(req->ImpersonationLevel));
27442742 rc = -EIO;
27452743 rsp->hdr.Status = STATUS_BAD_IMPERSONATION_LEVEL;
2746− goto err_out1;
2744+ goto err_out2;
27472745 }
27482746
27492747 if (req->CreateOptions && !(req->CreateOptions & CREATE_OPTIONS_MASK_LE)) {
27502748 pr_err("Invalid create options : 0x%x\n",
27512749 le32_to_cpu(req->CreateOptions));
27522750 rc = -EINVAL;
2753− goto err_out1;
2751+ goto err_out2;
27542752 } else {
27552753 if (req->CreateOptions & FILE_SEQUENTIAL_ONLY_LE &&
27562754 req->CreateOptions & FILE_RANDOM_ACCESS_LE)
@@ -2760,13 +2758,13 @@ int smb2_open(struct ksmbd_work *work) · 3 unmodified lines
27602758 (FILE_OPEN_BY_FILE_ID_LE | CREATE_TREE_CONNECTION |
27612759 FILE_RESERVE_OPFILTER_LE)) {
27622760 rc = -EOPNOTSUPP;
2763− goto err_out1;
2761+ goto err_out2;
27642762 }
27652763
27662764 if (req->CreateOptions & FILE_DIRECTORY_FILE_LE) {
27672765 if (req->CreateOptions & FILE_NON_DIRECTORY_FILE_LE) {
27682766 rc = -EINVAL;
2769− goto err_out1;
2767+ goto err_out2;
27702768 } else if (req->CreateOptions & FILE_NO_COMPRESSION_LE) {
27712769 req->CreateOptions = ~(FILE_NO_COMPRESSION_LE);
27722770 }
@@ -2778,21 +2776,21 @@ int smb2_open(struct ksmbd_work *work) · 5 unmodified lines
27782776 pr_err("Invalid create disposition : 0x%x\n",
27792777 le32_to_cpu(req->CreateDisposition));
27802778 rc = -EINVAL;
2781− goto err_out1;
2779+ goto err_out2;
27822780 }
27832781
27842782 if (!(req->DesiredAccess & DESIRED_ACCESS_MASK)) {
27852783 pr_err("Invalid desired access : 0x%x\n",
27862784 le32_to_cpu(req->DesiredAccess));
27872785 rc = -EACCES;
2788− goto err_out1;
2786+ goto err_out2;
27892787 }
27902788
27912789 if (req->FileAttributes && !(req->FileAttributes & FILE_ATTRIBUTE_MASK_LE)) {
27922790 pr_err("Invalid file attribute : 0x%x\n",
27932791 le32_to_cpu(req->FileAttributes));
27942792 rc = -EINVAL;
2795− goto err_out1;
2793+ goto err_out2;
27962794 }
27972795
27982796 if (req->CreateContextsOffset) {
@@ -2800,19 +2798,19 @@ int smb2_open(struct ksmbd_work *work) · 1 unmodified line
28002798 context = smb2_find_context_vals(req, SMB2_CREATE_EA_BUFFER, 4);
28012799 if (IS_ERR(context)) {
28022800 rc = PTR_ERR(context);
2803− goto err_out1;
2801+ goto err_out2;
28042802 } else if (context) {
28052803 ea_buf = (struct create_ea_buf_req *)context;
28062804 if (le16_to_cpu(context->DataOffset) +
28072805 le32_to_cpu(context->DataLength) <
28082806 sizeof(struct create_ea_buf_req)) {
28092807 rc = -EINVAL;
2810− goto err_out1;
2808+ goto err_out2;
28112809 }
28122810 if (req->CreateOptions & FILE_NO_EA_KNOWLEDGE_LE) {
28132811 rsp->hdr.Status = STATUS_ACCESS_DENIED;
28142812 rc = -EACCES;
2815− goto err_out1;
2813+ goto err_out2;
28162814 }
28172815 }
28182816
@@ -2820,7 +2818,7 @@ int smb2_open(struct ksmbd_work *work) · 1 unmodified line
28202818 SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST, 4);
28212819 if (IS_ERR(context)) {
28222820 rc = PTR_ERR(context);
2823− goto err_out1;
2821+ goto err_out2;
28242822 } else if (context) {
28252823 ksmbd_debug(SMB,
28262824 "get query maximal access context\n");
@@ -2831,11 +2829,11 @@ int smb2_open(struct ksmbd_work *work) · 4 unmodified lines
28312829 SMB2_CREATE_TIMEWARP_REQUEST, 4);
28322830 if (IS_ERR(context)) {
28332831 rc = PTR_ERR(context);
2834− goto err_out1;
2832+ goto err_out2;
28352833 } else if (context) {
28362834 ksmbd_debug(SMB, "get timewarp context\n");
28372835 rc = -EBADF;
2838− goto err_out1;
2836+ goto err_out2;
28392837 }
28402838
28412839 if (tcon->posix_extensions) {
@@ -2843,7 +2841,7 @@ int smb2_open(struct ksmbd_work *work) · 1 unmodified line
28432841 SMB2_CREATE_TAG_POSIX, 16);
28442842 if (IS_ERR(context)) {
28452843 rc = PTR_ERR(context);
2846− goto err_out1;
2844+ goto err_out2;
28472845 } else if (context) {
28482846 struct create_posix *posix =
28492847 (struct create_posix *)context;
@@ -2851,7 +2849,7 @@ int smb2_open(struct ksmbd_work *work) · 1 unmodified line
28512849 le32_to_cpu(context->DataLength) <
28522850 sizeof(struct create_posix) - 4) {
28532851 rc = -EINVAL;
2854− goto err_out1;
2852+ goto err_out2;
28552853 }
28562854 ksmbd_debug(SMB, "get posix context\n");
28572855
@@ -2863,7 +2861,7 @@ int smb2_open(struct ksmbd_work *work) · 5 unmodified lines
28632861
28642862 if (ksmbd_override_fsids(work)) {
28652863 rc = -ENOMEM;
2866− goto err_out1;
2864+ goto err_out2;
28672865 }
28682866
28692867 rc = ksmbd_vfs_kern_path_locked(work, name, LOOKUP_NO_SYMLINKS,
@@ -3038,7 +3036,7 @@ int smb2_open(struct ksmbd_work *work) · 168 unmodified lines
30383036 }
30393037 }
30403038
3041− rc = ksmbd_query_inode_status(d_inode(path.dentry->d_parent));
3039+ rc = ksmbd_query_inode_status(path.dentry->d_parent);
30423040 if (rc == KSMBD_INODE_STATUS_PENDING_DELETE) {
30433041 rc = -EBUSY;
30443042 goto err_out;
@@ -3152,7 +3150,8 @@ int smb2_open(struct ksmbd_work *work) · 107 unmodified lines
31523150 idmap,
31533151 &path,
31543152 pntsd,
3155− pntsd_size);
3153+ pntsd_size,
3154+ false);
31563155 kfree(pntsd);
31573156 if (rc)
31583157 pr_err("failed to store ntacl in xattr : %d\n",
@@ -3175,11 +3174,6 @@ int smb2_open(struct ksmbd_work *work) · 16 unmodified lines
31753174
31763175 fp->attrib_only = !(req->DesiredAccess & ~(FILE_READ_ATTRIBUTES_LE |
31773176 FILE_WRITE_ATTRIBUTES_LE | FILE_SYNCHRONIZE_LE));
3178− if (!S_ISDIR(file_inode(filp)->i_mode) && open_flags & O_TRUNC &&
3179− !fp->attrib_only && !stream_name) {
3180− smb_break_all_oplock(work, fp);
3181− need_truncate = 1;
3182− }
31833177
31843178 /* fp should be searchable through ksmbd_inode.m_fp_list
31853179 * after daccess, saccess, attrib_only, and stream are
@@ -3195,13 +3189,39 @@ int smb2_open(struct ksmbd_work *work) · 9 unmodified lines
31953189 goto err_out;
31963190 }
31973191
3192+ rc = ksmbd_vfs_getattr(&path, &stat);
3193+ if (rc)
3194+ goto err_out;
3195+
3196+ if (stat.result_mask & STATX_BTIME)
3197+ fp->create_time = ksmbd_UnixTimeToNT(stat.btime);
3198+ else
3199+ fp->create_time = ksmbd_UnixTimeToNT(stat.ctime);
3200+ if (req->FileAttributes || fp->f_ci->m_fattr == 0)
3201+ fp->f_ci->m_fattr =
3202+ cpu_to_le32(smb2_get_dos_mode(&stat, le32_to_cpu(req->FileAttributes)));
3203+
3204+ if (!created)
3205+ smb2_update_xattrs(tcon, &path, fp);
3206+ else
3207+ smb2_new_xattrs(tcon, &path, fp);
3208+
3209+ if (file_present || created)
3210+ ksmbd_vfs_kern_path_unlock(&parent_path, &path);
3211+
3212+ if (!S_ISDIR(file_inode(filp)->i_mode) && open_flags & O_TRUNC &&
3213+ !fp->attrib_only && !stream_name) {
3214+ smb_break_all_oplock(work, fp);
3215+ need_truncate = 1;
3216+ }
3217+
31983218 share_ret = ksmbd_smb_check_shared_mode(fp->filp, fp);
31993219 if (!test_share_config_flag(work->tcon->share_conf, KSMBD_SHARE_FLAG_OPLOCKS) ||
32003220 (req_op_level == SMB2_OPLOCK_LEVEL_LEASE &&
32013221 !(conn->vals->capabilities & SMB2_GLOBAL_CAP_LEASING))) {
32023222 if (share_ret < 0 && !S_ISDIR(file_inode(fp->filp)->i_mode)) {
32033223 rc = share_ret;
3204− goto err_out;
3224+ goto err_out1;
32053225 }
32063226 } else {
32073227 if (req_op_level == SMB2_OPLOCK_LEVEL_LEASE) {
@@ -3211,7 +3231,7 @@ int smb2_open(struct ksmbd_work *work) · 3 unmodified lines
32113231 name, req_op_level, lc->req_state);
32123232 rc = find_same_lease_key(sess, fp->f_ci, lc);
32133233 if (rc)
3214− goto err_out;
3234+ goto err_out1;
32153235 } else if (open_flags == O_RDONLY &&
32163236 (req_op_level == SMB2_OPLOCK_LEVEL_BATCH ||
32173237 req_op_level == SMB2_OPLOCK_LEVEL_EXCLUSIVE))
@@ -3222,16 +3242,16 @@ int smb2_open(struct ksmbd_work *work) · 4 unmodified lines
32223242 le32_to_cpu(req->hdr.Id.SyncId.TreeId),
32233243 lc, share_ret);
32243244 if (rc < 0)
3225− goto err_out;
3245+ goto err_out1;
32263246 }
32273247
32283248 if (req->CreateOptions & FILE_DELETE_ON_CLOSE_LE)
32293249 ksmbd_fd_set_delete_on_close(fp, file_info);
32303250
32313251 if (need_truncate) {
3232− rc = smb2_create_truncate(&path);
3252+ rc = smb2_create_truncate(&fp->filp->f_path);
32333253 if (rc)
3234− goto err_out;
3254+ goto err_out1;
32353255 }
32363256
32373257 if (req->CreateContextsOffset) {
@@ -3241,7 +3261,7 @@ int smb2_open(struct ksmbd_work *work) · 3 unmodified lines
32413261 SMB2_CREATE_ALLOCATION_SIZE, 4);
32423262 if (IS_ERR(az_req)) {
32433263 rc = PTR_ERR(az_req);
3244− goto err_out;
3264+ goto err_out1;
32453265 } else if (az_req) {
32463266 loff_t alloc_size;
32473267 int err;
@@ -3250,7 +3270,7 @@ int smb2_open(struct ksmbd_work *work) · 2 unmodified lines
32503270 le32_to_cpu(az_req->ccontext.DataLength) <
32513271 sizeof(struct create_alloc_size_req)) {
32523272 rc = -EINVAL;
3253− goto err_out;
3273+ goto err_out1;
32543274 }
32553275 alloc_size = le64_to_cpu(az_req->AllocationSize);
32563276 ksmbd_debug(SMB,
@@ -3268,30 +3288,13 @@ int smb2_open(struct ksmbd_work *work) · 11 unmodified lines
32683288 context = smb2_find_context_vals(req, SMB2_CREATE_QUERY_ON_DISK_ID, 4);
32693289 if (IS_ERR(context)) {
32703290 rc = PTR_ERR(context);
3271− goto err_out;
3291+ goto err_out1;
32723292 } else if (context) {
32733293 ksmbd_debug(SMB, "get query on disk id context\n");
32743294 query_disk_id = 1;
32753295 }
32763296 }
32773297
3278− rc = ksmbd_vfs_getattr(&path, &stat);
3279− if (rc)
3280− goto err_out;
3281−
3282− if (stat.result_mask & STATX_BTIME)
3283− fp->create_time = ksmbd_UnixTimeToNT(stat.btime);
3284− else
3285− fp->create_time = ksmbd_UnixTimeToNT(stat.ctime);
3286− if (req->FileAttributes || fp->f_ci->m_fattr == 0)
3287− fp->f_ci->m_fattr =
3288− cpu_to_le32(smb2_get_dos_mode(&stat, le32_to_cpu(req->FileAttributes)));
3289−
3290− if (!created)
3291− smb2_update_xattrs(tcon, &path, fp);
3292− else
3293− smb2_new_xattrs(tcon, &path, fp);
3294−
32953298 memcpy(fp->client_guid, conn->ClientGUID, SMB2_CLIENT_GUID_SIZE);
32963299
32973300 rsp->StructureSize = cpu_to_le16(89);
@@ -3398,13 +3401,13 @@ int smb2_open(struct ksmbd_work *work) · 100 unmodified lines
33983401 }
33993402
34003403 err_out:
3401− if (file_present || created) {
3402− inode_unlock(d_inode(parent_path.dentry));
3403− path_put(&path);
3404− path_put(&parent_path);
3405− }
3406− ksmbd_revert_fsids(work);
3404+ if (rc && (file_present || created))
3405+ ksmbd_vfs_kern_path_unlock(&parent_path, &path);
3406+
34073407 err_out1:
3408+ ksmbd_revert_fsids(work);
3409+
3410+err_out2:
34083411 if (!rc) {
34093412 ksmbd_update_fstate(&work->sess->file_table, fp, FP_INITED);
34103413 rc = ksmbd_iov_pin_rsp(work, (void *)rsp, iov_len);
@@ -5537,7 +5540,7 @@ static int smb2_rename(struct ksmbd_work *work, · 2126 unmodified lines
55375540 rc = ksmbd_vfs_setxattr(file_mnt_idmap(fp->filp),
55385541 &fp->filp->f_path,
55395542 xattr_stream_name,
5540− NULL, 0, 0);
5543+ NULL, 0, 0, true);
55415544 if (rc < 0) {
55425545 pr_err("failed to store stream name in xattr: %d\n",
55435546 rc);
@@ -5630,11 +5633,9 @@ static int smb2_create_link(struct ksmbd_work *work, · 86 unmodified lines
56305633 if (rc)
56315634 rc = -EINVAL;
56325635 out:
5633− if (file_present) {
5634− inode_unlock(d_inode(parent_path.dentry));
5635− path_put(&path);
5636− path_put(&parent_path);
5637− }
5636+ if (file_present)
5637+ ksmbd_vfs_kern_path_unlock(&parent_path, &path);
5638+
56385639 if (!IS_ERR(link_name))
56395640 kfree(link_name);
56405641 kfree(pathname);
@@ -5701,7 +5702,8 @@ static int set_file_basic_info(struct ksmbd_file *fp, · 60 unmodified lines
57015702 da.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |
57025703 XATTR_DOSINFO_ITIME;
57035704
5704− rc = ksmbd_vfs_set_dos_attrib_xattr(idmap, &filp->f_path, &da);
5705+ rc = ksmbd_vfs_set_dos_attrib_xattr(idmap, &filp->f_path, &da,
5706+ true);
57055707 if (rc)
57065708 ksmbd_debug(SMB,
57075709 "failed to restore file attribute in EA\n");
@@ -6013,7 +6015,7 @@ static int smb2_set_info_sec(struct ksmbd_file *fp, int addition_info, · 305 unmodified lines
60136015 fp->saccess |= FILE_SHARE_DELETE_LE;
60146016
60156017 return set_info_sec(fp->conn, fp->tcon, &fp->filp->f_path, pntsd,
6016− buf_len, false);
6018+ buf_len, false, true);
60176019 }
60186020
60196021 /**
@@ -7582,7 +7584,8 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id, · 1562 unmodified lines
75827584
75837585 da.attr = le32_to_cpu(fp->f_ci->m_fattr);
75847586 ret = ksmbd_vfs_set_dos_attrib_xattr(idmap,
7585− &fp->filp->f_path, &da);
7587+ &fp->filp->f_path,
7588+ &da, true);
75867589 if (ret)
75877590 fp->f_ci->m_fattr = old_fattr;
75887591 }
@@ -8231,7 +8234,6 @@ static void smb21_lease_break_ack(struct ksmbd_work *work) · 642 unmodified lines
82318234 return;
82328235
82338236 err_out:
8234− opinfo->op_state = OPLOCK_STATE_NONE;
82358237 wake_up_interruptible_all(&opinfo->oplock_q);
82368238 atomic_dec(&opinfo->breaking_cnt);
82378239 wake_up_interruptible_all(&opinfo->oplock_brk);
fs/smb/server/smbacl.c+4−3
@@ -1185,7 +1185,7 @@ pass: · 1184 unmodified lines
11851185 pntsd_size += sizeof(struct smb_acl) + nt_size;
11861186 }
11871187
1188− ksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, pntsd_size);
1188+ ksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, pntsd_size, false);
11891189 kfree(pntsd);
11901190 }
11911191
@@ -1377,7 +1377,7 @@ err_out: · 185 unmodified lines
13771377
13781378 int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
13791379 const struct path *path, struct smb_ntsd *pntsd, int ntsd_len,
1380− bool type_check)
1380+ bool type_check, bool get_write)
13811381 {
13821382 int rc;
13831383 struct smb_fattr fattr = {{0}};
@@ -1437,7 +1437,8 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon, · 53 unmodified lines
14371437 if (test_share_config_flag(tcon->share_conf, KSMBD_SHARE_FLAG_ACL_XATTR)) {
14381438 /* Update WinACL in xattr */
14391439 ksmbd_vfs_remove_sd_xattrs(idmap, path);
1440− ksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, ntsd_len);
1440+ ksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, ntsd_len,
1441+ get_write);
14411442 }
14421443
14431444 out:
fs/smb/server/smbacl.h+1−1
@@ -207,7 +207,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path, · 206 unmodified lines
207207 __le32 *pdaccess, int uid);
208208 int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
209209 const struct path *path, struct smb_ntsd *pntsd, int ntsd_len,
210− bool type_check);
210+ bool type_check, bool get_write);
211211 void id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid);
212212 void ksmbd_init_domain(u32 *sub_auth);
213213
fs/smb/server/vfs.c+42−28
@@ -97,6 +97,13 @@ static int ksmbd_vfs_path_lookup_locked(struct ksmbd_share_config *share_conf, · 96 unmodified lines
9797 return -ENOENT;
9898 }
9999
100+ err = mnt_want_write(parent_path->mnt);
101+ if (err) {
102+ path_put(parent_path);
103+ putname(filename);
104+ return -ENOENT;
105+ }
106+
100107 inode_lock_nested(parent_path->dentry->d_inode, I_MUTEX_PARENT);
101108 d = lookup_one_qstr_excl(&last, parent_path->dentry, 0);
102109 if (IS_ERR(d))
@@ -123,6 +130,7 @@ static int ksmbd_vfs_path_lookup_locked(struct ksmbd_share_config *share_conf, · 20 unmodified lines
123130
124131 err_out:
125132 inode_unlock(d_inode(parent_path->dentry));
133+ mnt_drop_write(parent_path->mnt);
126134 path_put(parent_path);
127135 putname(filename);
128136 return -ENOENT;
@@ -451,7 +459,8 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos, · 322 unmodified lines
451459 fp->stream.name,
452460 (void *)stream_buf,
453461 size,
454− 0);
462+ 0,
463+ true);
455464 if (err < 0)
456465 goto out;
457466
@@ -593,10 +602,6 @@ int ksmbd_vfs_remove_file(struct ksmbd_work *work, const struct path *path) · 135 unmodified lines
593602 goto out_err;
594603 }
595604
596− err = mnt_want_write(path->mnt);
597− if (err)
598− goto out_err;
599−
600605 idmap = mnt_idmap(path->mnt);
601606 if (S_ISDIR(d_inode(path->dentry)->i_mode)) {
602607 err = vfs_rmdir(idmap, d_inode(parent), path->dentry);
@@ -607,7 +612,6 @@ int ksmbd_vfs_remove_file(struct ksmbd_work *work, const struct path *path) · 4 unmodified lines
607612 if (err)
608613 ksmbd_debug(VFS, "unlink failed, err %d\n", err);
609614 }
610− mnt_drop_write(path->mnt);
611615
612616 out_err:
613617 ksmbd_revert_fsids(work);
@@ -715,7 +719,7 @@ retry: · 101 unmodified lines
715719 goto out3;
716720 }
717721
718− parent_fp = ksmbd_lookup_fd_inode(d_inode(old_child->d_parent));
722+ parent_fp = ksmbd_lookup_fd_inode(old_child->d_parent);
719723 if (parent_fp) {
720724 if (parent_fp->daccess & FILE_DELETE_LE) {
721725 pr_err("parent dir is opened with delete access\n");
@@ -907,18 +911,22 @@ ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap, · 185 unmodified lines
907911 * @attr_value: xattr value to set
908912 * @attr_size: size of xattr value
909913 * @flags: destination buffer length
914+ * @get_write: get write access to a mount
910915 *
911916 * Return: 0 on success, otherwise error
912917 */
913918 int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
914919 const struct path *path, const char *attr_name,
915− void *attr_value, size_t attr_size, int flags)
920+ void *attr_value, size_t attr_size, int flags,
921+ bool get_write)
916922 {
917923 int err;
918924
919− err = mnt_want_write(path->mnt);
920− if (err)
921− return err;
925+ if (get_write == true) {
926+ err = mnt_want_write(path->mnt);
927+ if (err)
928+ return err;
929+ }
922930
923931 err = vfs_setxattr(idmap,
924932 path->dentry,
@@ -928,7 +936,8 @@ int ksmbd_vfs_setxattr(struct mnt_idmap *idmap, · 3 unmodified lines
928936 flags);
929937 if (err)
930938 ksmbd_debug(VFS, "setxattr failed, err %d\n", err);
931− mnt_drop_write(path->mnt);
939+ if (get_write == true)
940+ mnt_drop_write(path->mnt);
932941 return err;
933942 }
934943
@@ -1252,6 +1261,13 @@ out1: · 317 unmodified lines
12521261 }
12531262
12541263 if (!err) {
1264+ err = mnt_want_write(parent_path->mnt);
1265+ if (err) {
1266+ path_put(path);
1267+ path_put(parent_path);
1268+ return err;
1269+ }
1270+
12551271 err = ksmbd_vfs_lock_parent(parent_path->dentry, path->dentry);
12561272 if (err) {
12571273 path_put(path);
@@ -1261,6 +1277,14 @@ out1: · 3 unmodified lines
12611277 return err;
12621278 }
12631279
1280+void ksmbd_vfs_kern_path_unlock(struct path *parent_path, struct path *path)
1281+{
1282+ inode_unlock(d_inode(parent_path->dentry));
1283+ mnt_drop_write(parent_path->mnt);
1284+ path_put(path);
1285+ path_put(parent_path);
1286+}
1287+
12641288 struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
12651289 const char *name,
12661290 unsigned int flags,
@@ -1415,7 +1439,8 @@ out: · 148 unmodified lines
14151439 int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
14161440 struct mnt_idmap *idmap,
14171441 const struct path *path,
1418− struct smb_ntsd *pntsd, int len)
1442+ struct smb_ntsd *pntsd, int len,
1443+ bool get_write)
14191444 {
14201445 int rc;
14211446 struct ndr sd_ndr = {0}, acl_ndr = {0};
@@ -1475,7 +1500,7 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn, · 53 unmodified lines
14751500
14761501 rc = ksmbd_vfs_setxattr(idmap, path,
14771502 XATTR_NAME_SD, sd_ndr.data,
1478− sd_ndr.offset, 0);
1503+ sd_ndr.offset, 0, get_write);
14791504 if (rc < 0)
14801505 pr_err("Failed to store XATTR ntacl :%d\n", rc);
14811506
@@ -1564,7 +1589,8 @@ free_n_data: · 82 unmodified lines
15641589
15651590 int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
15661591 const struct path *path,
1567− struct xattr_dos_attrib *da)
1592+ struct xattr_dos_attrib *da,
1593+ bool get_write)
15681594 {
15691595 struct ndr n;
15701596 int err;
@@ -1574,7 +1600,7 @@ int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap, · 3 unmodified lines
15741600 return err;
15751601
15761602 err = ksmbd_vfs_setxattr(idmap, path, XATTR_NAME_DOS_ATTRIBUTE,
1577− (void *)n.data, n.offset, 0);
1603+ (void *)n.data, n.offset, 0, get_write);
15781604 if (err)
15791605 ksmbd_debug(SMB, "failed to store dos attribute in xattr\n");
15801606 kfree(n.data);
@@ -1846,10 +1872,6 @@ int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap, · 265 unmodified lines
18461872 }
18471873 posix_state_to_acl(&acl_state, acls->a_entries);
18481874
1849− rc = mnt_want_write(path->mnt);
1850− if (rc)
1851− goto out_err;
1852−
18531875 rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls);
18541876 if (rc < 0)
18551877 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_ACCESS) failed, rc : %d\n",
@@ -1861,9 +1883,7 @@ int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap, · 5 unmodified lines
18611883 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n",
18621884 rc);
18631885 }
1864− mnt_drop_write(path->mnt);
18651886
1866−out_err:
18671887 free_acl_state(&acl_state);
18681888 posix_acl_release(acls);
18691889 return rc;
@@ -1893,10 +1913,6 @@ int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap, · 23 unmodified lines
18931913 }
18941914 }
18951915
1896− rc = mnt_want_write(path->mnt);
1897− if (rc)
1898− goto out_err;
1899−
19001916 rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls);
19011917 if (rc < 0)
19021918 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_ACCESS) failed, rc : %d\n",
@@ -1908,9 +1924,7 @@ int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap, · 5 unmodified lines
19081924 ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n",
19091925 rc);
19101926 }
1911− mnt_drop_write(path->mnt);
19121927
1913−out_err:
19141928 posix_acl_release(acls);
19151929 return rc;
19161930 }
fs/smb/server/vfs.h+7−3
@@ -109,7 +109,8 @@ ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap, · 108 unmodified lines
109109 int attr_name_len);
110110 int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
111111 const struct path *path, const char *attr_name,
112− void *attr_value, size_t attr_size, int flags);
112+ void *attr_value, size_t attr_size, int flags,
113+ bool get_write);
113114 int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
114115 size_t *xattr_stream_name_size, int s_type);
115116 int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
@@ -117,6 +118,7 @@ int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap, · 1 unmodified line
117118 int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
118119 unsigned int flags, struct path *parent_path,
119120 struct path *path, bool caseless);
121+void ksmbd_vfs_kern_path_unlock(struct path *parent_path, struct path *path);
120122 struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
121123 const char *name,
122124 unsigned int flags,
@@ -144,14 +146,16 @@ int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path) · 21 unmodified lines
144146 int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
145147 struct mnt_idmap *idmap,
146148 const struct path *path,
147− struct smb_ntsd *pntsd, int len);
149+ struct smb_ntsd *pntsd, int len,
150+ bool get_write);
148151 int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
149152 struct mnt_idmap *idmap,
150153 struct dentry *dentry,
151154 struct smb_ntsd **pntsd);
152155 int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
153156 const struct path *path,
154− struct xattr_dos_attrib *da);
157+ struct xattr_dos_attrib *da,
158+ bool get_write);
155159 int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
156160 struct dentry *dentry,
157161 struct xattr_dos_attrib *da);
fs/smb/server/vfs_cache.c+13−20
@@ -66,14 +66,14 @@ static unsigned long inode_hash(struct super_block *sb, unsigned long hashval) · 65 unmodified lines
6666 return tmp & inode_hash_mask;
6767 }
6868
69−static struct ksmbd_inode *__ksmbd_inode_lookup(struct inode *inode)
69+static struct ksmbd_inode *__ksmbd_inode_lookup(struct dentry *de)
7070 {
7171 struct hlist_head *head = inode_hashtable +
72− inode_hash(inode->i_sb, inode->i_ino);
72+ inode_hash(d_inode(de)->i_sb, (unsigned long)de);
7373 struct ksmbd_inode *ci = NULL, *ret_ci = NULL;
7474
7575 hlist_for_each_entry(ci, head, m_hash) {
76− if (ci->m_inode == inode) {
76+ if (ci->m_de == de) {
7777 if (atomic_inc_not_zero(&ci->m_count))
7878 ret_ci = ci;
7979 break;
@@ -84,26 +84,16 @@ static struct ksmbd_inode *__ksmbd_inode_lookup(struct inode *inode) · 4 unmodified lines
8484
8585 static struct ksmbd_inode *ksmbd_inode_lookup(struct ksmbd_file *fp)
8686 {
87− return __ksmbd_inode_lookup(file_inode(fp->filp));
87+ return __ksmbd_inode_lookup(fp->filp->f_path.dentry);
8888 }
8989
90−static struct ksmbd_inode *ksmbd_inode_lookup_by_vfsinode(struct inode *inode)
91−{
92− struct ksmbd_inode *ci;
93−
94− read_lock(&inode_hash_lock);
95− ci = __ksmbd_inode_lookup(inode);
96− read_unlock(&inode_hash_lock);
97− return ci;
98−}
99−
100−int ksmbd_query_inode_status(struct inode *inode)
90+int ksmbd_query_inode_status(struct dentry *dentry)
10191 {
10292 struct ksmbd_inode *ci;
10393 int ret = KSMBD_INODE_STATUS_UNKNOWN;
10494
10595 read_lock(&inode_hash_lock);
106− ci = __ksmbd_inode_lookup(inode);
96+ ci = __ksmbd_inode_lookup(dentry);
10797 if (ci) {
10898 ret = KSMBD_INODE_STATUS_OK;
10999 if (ci->m_flags & (S_DEL_PENDING | S_DEL_ON_CLS))
@@ -143,7 +133,7 @@ void ksmbd_fd_set_delete_on_close(struct ksmbd_file *fp, · 33 unmodified lines
143133 static void ksmbd_inode_hash(struct ksmbd_inode *ci)
144134 {
145135 struct hlist_head *b = inode_hashtable +
146− inode_hash(ci->m_inode->i_sb, ci->m_inode->i_ino);
136+ inode_hash(d_inode(ci->m_de)->i_sb, (unsigned long)ci->m_de);
147137
148138 hlist_add_head(&ci->m_hash, b);
149139 }
@@ -157,7 +147,6 @@ static void ksmbd_inode_unhash(struct ksmbd_inode *ci) · 7 unmodified lines
157147
158148 static int ksmbd_inode_init(struct ksmbd_inode *ci, struct ksmbd_file *fp)
159149 {
160− ci->m_inode = file_inode(fp->filp);
161150 atomic_set(&ci->m_count, 1);
162151 atomic_set(&ci->op_count, 0);
163152 atomic_set(&ci->sop_count, 0);
@@ -166,6 +155,7 @@ static int ksmbd_inode_init(struct ksmbd_inode *ci, struct ksmbd_file *fp) · 2 unmodified lines
166155 INIT_LIST_HEAD(&ci->m_fp_list);
167156 INIT_LIST_HEAD(&ci->m_op_list);
168157 rwlock_init(&ci->m_lock);
158+ ci->m_de = fp->filp->f_path.dentry;
169159 return 0;
170160 }
171161
@@ -488,12 +478,15 @@ struct ksmbd_file *ksmbd_lookup_fd_cguid(char *cguid) · 316 unmodified lines
488478 return fp;
489479 }
490480
491−struct ksmbd_file *ksmbd_lookup_fd_inode(struct inode *inode)
481+struct ksmbd_file *ksmbd_lookup_fd_inode(struct dentry *dentry)
492482 {
493483 struct ksmbd_file *lfp;
494484 struct ksmbd_inode *ci;
485+ struct inode *inode = d_inode(dentry);
495486
496− ci = ksmbd_inode_lookup_by_vfsinode(inode);
487+ read_lock(&inode_hash_lock);
488+ ci = __ksmbd_inode_lookup(dentry);
489+ read_unlock(&inode_hash_lock);
497490 if (!ci)
498491 return NULL;
499492
fs/smb/server/vfs_cache.h+3−3
@@ -51,7 +51,7 @@ struct ksmbd_inode { · 50 unmodified lines
5151 atomic_t op_count;
5252 /* opinfo count for streams */
5353 atomic_t sop_count;
54− struct inode *m_inode;
54+ struct dentry *m_de;
5555 unsigned int m_flags;
5656 struct hlist_node m_hash;
5757 struct list_head m_fp_list;
@@ -140,7 +140,7 @@ struct ksmbd_file *ksmbd_lookup_fd_slow(struct ksmbd_work *work, u64 id, · 82 unmodified lines
140140 void ksmbd_fd_put(struct ksmbd_work *work, struct ksmbd_file *fp);
141141 struct ksmbd_file *ksmbd_lookup_durable_fd(unsigned long long id);
142142 struct ksmbd_file *ksmbd_lookup_fd_cguid(char *cguid);
143−struct ksmbd_file *ksmbd_lookup_fd_inode(struct inode *inode);
143+struct ksmbd_file *ksmbd_lookup_fd_inode(struct dentry *dentry);
144144 unsigned int ksmbd_open_durable_fd(struct ksmbd_file *fp);
145145 struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp);
146146 void ksmbd_close_tree_conn_fds(struct ksmbd_work *work);
@@ -164,7 +164,7 @@ enum KSMBD_INODE_STATUS { · 17 unmodified lines
164164 KSMBD_INODE_STATUS_PENDING_DELETE,
165165 };
166166
167−int ksmbd_query_inode_status(struct inode *inode);
167+int ksmbd_query_inode_status(struct dentry *dentry);
168168 bool ksmbd_inode_pending_delete(struct ksmbd_file *fp);
169169 void ksmbd_set_inode_pending_delete(struct ksmbd_file *fp);
170170 void ksmbd_clear_inode_pending_delete(struct ksmbd_file *fp);
fs/stat.c+5−1
@@ -133,7 +133,8 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, · 132 unmodified lines
133133 idmap = mnt_idmap(path->mnt);
134134 if (inode->i_op->getattr)
135135 return inode->i_op->getattr(idmap, path, stat,
136− request_mask, query_flags);
136+ request_mask,
137+ query_flags | AT_GETATTR_NOSEC);
137138
138139 generic_fillattr(idmap, request_mask, inode, stat);
139140 return 0;
@@ -166,6 +167,9 @@ int vfs_getattr(const struct path *path, struct kstat *stat, · 26 unmodified lines
166167 {
167168 int retval;
168169
170+ if (WARN_ON_ONCE(query_flags & AT_GETATTR_NOSEC))
171+ return -EPERM;
172+
169173 retval = security_inode_getattr(path);
170174 if (retval)
171175 return retval;
fs/tracefs/event_inode.c+26−39
@@ -27,16 +27,16 @@ · 26 unmodified lines
2727 /*
2828 * eventfs_mutex protects the eventfs_inode (ei) dentry. Any access
2929 * to the ei->dentry must be done under this mutex and after checking
30− * if ei->is_freed is not set. The ei->dentry is released under the
31− * mutex at the same time ei->is_freed is set. If ei->is_freed is set
32− * then the ei->dentry is invalid.
30+ * if ei->is_freed is not set. When ei->is_freed is set, the dentry
31+ * is on its way to being freed after the last dput() is made on it.
3332 */
3433 static DEFINE_MUTEX(eventfs_mutex);
3534
3635 /*
3736 * The eventfs_inode (ei) itself is protected by SRCU. It is released from
3837 * its parent's list and will have is_freed set (under eventfs_mutex).
39− * After the SRCU grace period is over, the ei may be freed.
38+ * After the SRCU grace period is over and the last dput() is called
39+ * the ei is freed.
4040 */
4141 DEFINE_STATIC_SRCU(eventfs_srcu);
4242
@@ -95,7 +95,7 @@ static int eventfs_set_attr(struct mnt_idmap *idmap, struct dentry *dentry, · 52 unmodified lines
9595 if (!(dentry->d_inode->i_mode & S_IFDIR)) {
9696 if (!ei->entry_attrs) {
9797 ei->entry_attrs = kzalloc(sizeof(*ei->entry_attrs) * ei->nr_entries,
98− GFP_KERNEL);
98+ GFP_NOFS);
9999 if (!ei->entry_attrs) {
100100 ret = -ENOMEM;
101101 goto out;
@@ -326,7 +326,8 @@ create_file_dentry(struct eventfs_inode *ei, int idx, · 224 unmodified lines
326326 struct eventfs_attr *attr = NULL;
327327 struct dentry **e_dentry = &ei->d_children[idx];
328328 struct dentry *dentry;
329− bool invalidate = false;
329+
330+ WARN_ON_ONCE(!inode_is_locked(parent->d_inode));
330331
331332 mutex_lock(&eventfs_mutex);
332333 if (ei->is_freed) {
@@ -348,15 +349,8 @@ create_file_dentry(struct eventfs_inode *ei, int idx, · 15 unmodified lines
348349
349350 mutex_unlock(&eventfs_mutex);
350351
351− /* The lookup already has the parent->d_inode locked */
352− if (!lookup)
353− inode_lock(parent->d_inode);
354−
355352 dentry = create_file(name, mode, attr, parent, data, fops);
356353
357− if (!lookup)
358− inode_unlock(parent->d_inode);
359−
360354 mutex_lock(&eventfs_mutex);
361355
362356 if (IS_ERR_OR_NULL(dentry)) {
@@ -365,12 +359,14 @@ create_file_dentry(struct eventfs_inode *ei, int idx, · 2 unmodified lines
365359 * created the dentry for this e_dentry. In which case
366360 * use that one.
367361 *
368− * Note, with the mutex held, the e_dentry cannot have content
369− * and the ei->is_freed be true at the same time.
362+ * If ei->is_freed is set, the e_dentry is currently on its
363+ * way to being freed, don't return it. If e_dentry is NULL
364+ * it means it was already freed.
370365 */
371− dentry = *e_dentry;
372− if (WARN_ON_ONCE(dentry && ei->is_freed))
366+ if (ei->is_freed)
373367 dentry = NULL;
368+ else
369+ dentry = *e_dentry;
374370 /* The lookup does not need to up the dentry refcount */
375371 if (dentry && !lookup)
376372 dget(dentry);
@@ -387,17 +383,14 @@ create_file_dentry(struct eventfs_inode *ei, int idx, · 10 unmodified lines
387383 * Otherwise it means two dentries exist with the same name.
388384 */
389385 WARN_ON_ONCE(!ei->is_freed);
390− invalidate = true;
386+ dentry = NULL;
391387 }
392388 mutex_unlock(&eventfs_mutex);
393389
394− if (invalidate)
395− d_invalidate(dentry);
396−
397− if (lookup || invalidate)
390+ if (lookup)
398391 dput(dentry);
399392
400− return invalidate ? NULL : dentry;
393+ return dentry;
401394 }
402395
403396 /**
@@ -437,9 +430,10 @@ static struct dentry * · 33 unmodified lines
437430 create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei,
438431 struct dentry *parent, bool lookup)
439432 {
440− bool invalidate = false;
441433 struct dentry *dentry = NULL;
442434
435+ WARN_ON_ONCE(!inode_is_locked(parent->d_inode));
436+
443437 mutex_lock(&eventfs_mutex);
444438 if (pei->is_freed || ei->is_freed) {
445439 mutex_unlock(&eventfs_mutex);
@@ -456,15 +450,8 @@ create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei, · 10 unmodified lines
456450 }
457451 mutex_unlock(&eventfs_mutex);
458452
459− /* The lookup already has the parent->d_inode locked */
460− if (!lookup)
461− inode_lock(parent->d_inode);
462−
463453 dentry = create_dir(ei, parent);
464454
465− if (!lookup)
466− inode_unlock(parent->d_inode);
467−
468455 mutex_lock(&eventfs_mutex);
469456
470457 if (IS_ERR_OR_NULL(dentry) && !ei->is_freed) {
@@ -473,8 +460,8 @@ create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei, · 2 unmodified lines
473460 * created the dentry for this e_dentry. In which case
474461 * use that one.
475462 *
476− * Note, with the mutex held, the e_dentry cannot have content
477− * and the ei->is_freed be true at the same time.
463+ * If ei->is_freed is set, the e_dentry is currently on its
464+ * way to being freed.
478465 */
479466 dentry = ei->dentry;
480467 if (dentry && !lookup)
@@ -493,16 +480,14 @@ create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei, · 12 unmodified lines
493480 * Otherwise it means two dentries exist with the same name.
494481 */
495482 WARN_ON_ONCE(!ei->is_freed);
496− invalidate = true;
483+ dentry = NULL;
497484 }
498485 mutex_unlock(&eventfs_mutex);
499− if (invalidate)
500− d_invalidate(dentry);
501486
502− if (lookup || invalidate)
487+ if (lookup)
503488 dput(dentry);
504489
505− return invalidate ? NULL : dentry;
490+ return dentry;
506491 }
507492
508493 /**
@@ -632,7 +617,7 @@ static int add_dentries(struct dentry ***dentries, struct dentry *d, int cnt) · 123 unmodified lines
632617 {
633618 struct dentry **tmp;
634619
635− tmp = krealloc(*dentries, sizeof(d) * (cnt + 2), GFP_KERNEL);
620+ tmp = krealloc(*dentries, sizeof(d) * (cnt + 2), GFP_NOFS);
636621 if (!tmp)
637622 return -1;
638623 tmp[cnt] = d;
@@ -698,6 +683,7 @@ static int dcache_dir_open_wrapper(struct inode *inode, struct file *file) · 59 unmodified lines
698683 return -ENOMEM;
699684 }
700685
686+ inode_lock(parent->d_inode);
701687 list_for_each_entry_srcu(ei_child, &ei->children, list,
702688 srcu_read_lock_held(&eventfs_srcu)) {
703689 d = create_dir_dentry(ei, ei_child, parent, false);
@@ -730,6 +716,7 @@ static int dcache_dir_open_wrapper(struct inode *inode, struct file *file) · 26 unmodified lines
730716 cnt++;
731717 }
732718 }
719+ inode_unlock(parent->d_inode);
733720 srcu_read_unlock(&eventfs_srcu, idx);
734721 ret = dcache_dir_open(inode, file);
735722
fs/tracefs/inode.c+4−9
@@ -509,20 +509,15 @@ struct dentry *eventfs_start_creating(const char *name, struct dentry *parent) · 508 unmodified lines
509509 struct dentry *dentry;
510510 int error;
511511
512+ /* Must always have a parent. */
513+ if (WARN_ON_ONCE(!parent))
514+ return ERR_PTR(-EINVAL);
515+
512516 error = simple_pin_fs(&trace_fs_type, &tracefs_mount,
513517 &tracefs_mount_count);
514518 if (error)
515519 return ERR_PTR(error);
516520
517− /*
518− * If the parent is not specified, we create it in the root.
519− * We need the root dentry to do this, which is in the super
520− * block. A pointer to that is in the struct vfsmount that we
521− * have around.
522− */
523− if (!parent)
524− parent = tracefs_mount->mnt_root;
525−
526521 if (unlikely(IS_DEADDIR(parent->d_inode)))
527522 dentry = ERR_PTR(-ENOENT);
528523 else
fs/xfs/xfs_dquot.c+3−2
@@ -562,7 +562,8 @@ xfs_dquot_from_disk( · 561 unmodified lines
562562 struct xfs_dquot *dqp,
563563 struct xfs_buf *bp)
564564 {
565− struct xfs_disk_dquot *ddqp = bp->b_addr + dqp->q_bufoffset;
565+ struct xfs_dqblk *dqb = xfs_buf_offset(bp, dqp->q_bufoffset);
566+ struct xfs_disk_dquot *ddqp = &dqb->dd_diskdq;
566567
567568 /*
568569 * Ensure that we got the type and ID we were looking for.
@@ -1250,7 +1251,7 @@ xfs_qm_dqflush( · 681 unmodified lines
12501251 }
12511252
12521253 /* Flush the incore dquot to the ondisk buffer. */
1253− dqblk = bp->b_addr + dqp->q_bufoffset;
1254+ dqblk = xfs_buf_offset(bp, dqp->q_bufoffset);
12541255 xfs_dquot_to_disk(&dqblk->dd_diskdq, dqp);
12551256
12561257 /*
fs/xfs/xfs_dquot_item_recover.c+18−3
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #include "xfs_log.h"
2020 #include "xfs_log_priv.h"
2121 #include "xfs_log_recover.h"
22+#include "xfs_error.h"
2223
2324 STATIC void
2425 xlog_recover_dquot_ra_pass2(
@@ -65,6 +66,7 @@ xlog_recover_dquot_commit_pass2( · 40 unmodified lines
6566 {
6667 struct xfs_mount *mp = log->l_mp;
6768 struct xfs_buf *bp;
69+ struct xfs_dqblk *dqb;
6870 struct xfs_disk_dquot *ddq, *recddq;
6971 struct xfs_dq_logformat *dq_f;
7072 xfs_failaddr_t fa;
@@ -130,14 +132,14 @@ xlog_recover_dquot_commit_pass2( · 59 unmodified lines
130132 return error;
131133
132134 ASSERT(bp);
133− ddq = xfs_buf_offset(bp, dq_f->qlf_boffset);
135+ dqb = xfs_buf_offset(bp, dq_f->qlf_boffset);
136+ ddq = &dqb->dd_diskdq;
134137
135138 /*
136139 * If the dquot has an LSN in it, recover the dquot only if it's less
137140 * than the lsn of the transaction we are replaying.
138141 */
139142 if (xfs_has_crc(mp)) {
140− struct xfs_dqblk *dqb = (struct xfs_dqblk *)ddq;
141143 xfs_lsn_t lsn = be64_to_cpu(dqb->dd_lsn);
142144
143145 if (lsn && lsn != -1 && XFS_LSN_CMP(lsn, current_lsn) >= 0) {
@@ -147,10 +149,23 @@ xlog_recover_dquot_commit_pass2( · 3 unmodified lines
147149
148150 memcpy(ddq, recddq, item->ri_buf[1].i_len);
149151 if (xfs_has_crc(mp)) {
150− xfs_update_cksum((char *)ddq, sizeof(struct xfs_dqblk),
152+ xfs_update_cksum((char *)dqb, sizeof(struct xfs_dqblk),
151153 XFS_DQUOT_CRC_OFF);
152154 }
153155
156+ /* Validate the recovered dquot. */
157+ fa = xfs_dqblk_verify(log->l_mp, dqb, dq_f->qlf_id);
158+ if (fa) {
159+ XFS_CORRUPTION_ERROR("Bad dquot after recovery",
160+ XFS_ERRLEVEL_LOW, mp, dqb,
161+ sizeof(struct xfs_dqblk));
162+ xfs_alert(mp,
163+ "Metadata corruption detected at %pS, dquot 0x%x",
164+ fa, dq_f->qlf_id);
165+ error = -EFSCORRUPTED;
166+ goto out_release;
167+ }
168+
154169 ASSERT(dq_f->qlf_size == 2);
155170 ASSERT(bp->b_mount == mp);
156171 bp->b_flags |= _XBF_LOGRECOVERY;
fs/xfs/xfs_inode.h+8−0
@@ -569,6 +569,14 @@ extern void xfs_setup_inode(struct xfs_inode *ip); · 568 unmodified lines
569569 extern void xfs_setup_iops(struct xfs_inode *ip);
570570 extern void xfs_diflags_to_iflags(struct xfs_inode *ip, bool init);
571571
572+static inline void xfs_update_stable_writes(struct xfs_inode *ip)
573+{
574+ if (bdev_stable_writes(xfs_inode_buftarg(ip)->bt_bdev))
575+ mapping_set_stable_writes(VFS_I(ip)->i_mapping);
576+ else
577+ mapping_clear_stable_writes(VFS_I(ip)->i_mapping);
578+}
579+
572580 /*
573581 * When setting up a newly allocated inode, we need to call
574582 * xfs_finish_inode_setup() once the inode is fully instantiated at
fs/xfs/xfs_ioctl.c+20−10
@@ -1121,23 +1121,25 @@ xfs_ioctl_setattr_xflags( · 1120 unmodified lines
11211121 struct fileattr *fa)
11221122 {
11231123 struct xfs_mount *mp = ip->i_mount;
1124+ bool rtflag = (fa->fsx_xflags & FS_XFLAG_REALTIME);
11241125 uint64_t i_flags2;
11251126
1126− /* Can't change realtime flag if any extents are allocated. */
1127− if ((ip->i_df.if_nextents || ip->i_delayed_blks) &&
1128− XFS_IS_REALTIME_INODE(ip) != (fa->fsx_xflags & FS_XFLAG_REALTIME))
1129− return -EINVAL;
1127+ if (rtflag != XFS_IS_REALTIME_INODE(ip)) {
1128+ /* Can't change realtime flag if any extents are allocated. */
1129+ if (ip->i_df.if_nextents || ip->i_delayed_blks)
1130+ return -EINVAL;
1131+ }
11301132
1131− /* If realtime flag is set then must have realtime device */
1132− if (fa->fsx_xflags & FS_XFLAG_REALTIME) {
1133+ if (rtflag) {
1134+ /* If realtime flag is set then must have realtime device */
11331135 if (mp->m_sb.sb_rblocks == 0 || mp->m_sb.sb_rextsize == 0 ||
11341136 xfs_extlen_to_rtxmod(mp, ip->i_extsize))
11351137 return -EINVAL;
1136− }
11371138
1138− /* Clear reflink if we are actually able to set the rt flag. */
1139− if ((fa->fsx_xflags & FS_XFLAG_REALTIME) && xfs_is_reflink_inode(ip))
1140− ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
1139+ /* Clear reflink if we are actually able to set the rt flag. */
1140+ if (xfs_is_reflink_inode(ip))
1141+ ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
1142+ }
11411143
11421144 /* diflags2 only valid for v3 inodes. */
11431145 i_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags);
@@ -1148,6 +1150,14 @@ xfs_ioctl_setattr_xflags( · 4 unmodified lines
11481150 ip->i_diflags2 = i_flags2;
11491151
11501152 xfs_diflags_to_iflags(ip, false);
1153+
1154+ /*
1155+ * Make the stable writes flag match that of the device the inode
1156+ * resides on when flipping the RT flag.
1157+ */
1158+ if (rtflag != XFS_IS_REALTIME_INODE(ip) && S_ISREG(VFS_I(ip)->i_mode))
1159+ xfs_update_stable_writes(ip);
1160+
11511161 xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
11521162 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
11531163 XFS_STATS_INC(mp, xs_ig_attrchg);
fs/xfs/xfs_iops.c+7−0
@@ -1298,6 +1298,13 @@ xfs_setup_inode( · 1297 unmodified lines
12981298 gfp_mask = mapping_gfp_mask(inode->i_mapping);
12991299 mapping_set_gfp_mask(inode->i_mapping, (gfp_mask & ~(__GFP_FS)));
13001300
1301+ /*
1302+ * For real-time inodes update the stable write flags to that of the RT
1303+ * device instead of the data device.
1304+ */
1305+ if (S_ISREG(inode->i_mode) && XFS_IS_REALTIME_INODE(ip))
1306+ xfs_update_stable_writes(ip);
1307+
13011308 /*
13021309 * If there is no attribute fork no ACL can exist on this inode,
13031310 * and it can't have any file capabilities attached to it either.
include/acpi/acpi_bus.h+1−0
@@ -542,6 +542,7 @@ int acpi_device_set_power(struct acpi_device *device, int state); · 541 unmodified lines
542542 int acpi_bus_init_power(struct acpi_device *device);
543543 int acpi_device_fix_up_power(struct acpi_device *device);
544544 void acpi_device_fix_up_power_extended(struct acpi_device *adev);
545+void acpi_device_fix_up_power_children(struct acpi_device *adev);
545546 int acpi_bus_update_power(acpi_handle handle, int *state_p);
546547 int acpi_device_update_power(struct acpi_device *device, int *state_p);
547548 bool acpi_bus_power_manageable(acpi_handle handle);
include/linux/blk-pm.h+0−1
@@ -15,7 +15,6 @@ extern int blk_pre_runtime_suspend(struct request_queue *q); · 14 unmodified lines
1515 extern void blk_post_runtime_suspend(struct request_queue *q, int err);
1616 extern void blk_pre_runtime_resume(struct request_queue *q);
1717 extern void blk_post_runtime_resume(struct request_queue *q);
18−extern void blk_set_runtime_active(struct request_queue *q);
1918 #else
2019 static inline void blk_pm_runtime_init(struct request_queue *q,
2120 struct device *dev) {}
include/linux/debugfs.h+19−0
@@ -171,6 +171,25 @@ ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf, · 170 unmodified lines
171171 ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf,
172172 size_t count, loff_t *ppos);
173173
174+/**
175+ * struct debugfs_cancellation - cancellation data
176+ * @list: internal, for keeping track
177+ * @cancel: callback to call
178+ * @cancel_data: extra data for the callback to call
179+ */
180+struct debugfs_cancellation {
181+ struct list_head list;
182+ void (*cancel)(struct dentry *, void *);
183+ void *cancel_data;
184+};
185+
186+void __acquires(cancellation)
187+debugfs_enter_cancellation(struct file *file,
188+ struct debugfs_cancellation *cancellation);
189+void __releases(cancellation)
190+debugfs_leave_cancellation(struct file *file,
191+ struct debugfs_cancellation *cancellation);
192+
174193 #else
175194
176195 #include <linux/err.h>
include/linux/hid.h+3−0
@@ -679,6 +679,7 @@ struct hid_device { /* device report descriptor */ · 678 unmodified lines
679679 struct list_head debug_list;
680680 spinlock_t debug_list_lock;
681681 wait_queue_head_t debug_wait;
682+ struct kref ref;
682683
683684 unsigned int id; /* system unique id */
684685
@@ -687,6 +688,8 @@ struct hid_device { /* device report descriptor */ · 2 unmodified lines
687688 #endif /* CONFIG_BPF */
688689 };
689690
691+void hiddev_free(struct kref *ref);
692+
690693 #define to_hid_device(pdev) \
691694 container_of(pdev, struct hid_device, dev)
692695
include/linux/ieee80211.h+3−1
@@ -2830,12 +2830,14 @@ ieee80211_he_oper_size(const u8 *he_oper_ie) · 2829 unmodified lines
28302830 static inline const struct ieee80211_he_6ghz_oper *
28312831 ieee80211_he_6ghz_oper(const struct ieee80211_he_operation *he_oper)
28322832 {
2833− const u8 *ret = (const void *)&he_oper->optional;
2833+ const u8 *ret;
28342834 u32 he_oper_params;
28352835
28362836 if (!he_oper)
28372837 return NULL;
28382838
2839+ ret = (const void *)&he_oper->optional;
2840+
28392841 he_oper_params = le32_to_cpu(he_oper->he_oper_params);
28402842
28412843 if (!(he_oper_params & IEEE80211_HE_OPERATION_6GHZ_OP_INFO))
include/linux/pagemap.h+17−0
@@ -204,6 +204,8 @@ enum mapping_flags { · 203 unmodified lines
204204 AS_NO_WRITEBACK_TAGS = 5,
205205 AS_LARGE_FOLIO_SUPPORT = 6,
206206 AS_RELEASE_ALWAYS, /* Call ->release_folio(), even if no private data */
207+ AS_STABLE_WRITES, /* must wait for writeback before modifying
208+ folio contents */
207209 };
208210
209211 /**
@@ -289,6 +291,21 @@ static inline void mapping_clear_release_always(struct address_space *mapping) · 79 unmodified lines
289291 clear_bit(AS_RELEASE_ALWAYS, &mapping->flags);
290292 }
291293
294+static inline bool mapping_stable_writes(const struct address_space *mapping)
295+{
296+ return test_bit(AS_STABLE_WRITES, &mapping->flags);
297+}
298+
299+static inline void mapping_set_stable_writes(struct address_space *mapping)
300+{
301+ set_bit(AS_STABLE_WRITES, &mapping->flags);
302+}
303+
304+static inline void mapping_clear_stable_writes(struct address_space *mapping)
305+{
306+ clear_bit(AS_STABLE_WRITES, &mapping->flags);
307+}
308+
292309 static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
293310 {
294311 return mapping->gfp_mask;
include/linux/skmsg.h+1−0
@@ -106,6 +106,7 @@ struct sk_psock { · 105 unmodified lines
106106 struct mutex work_mutex;
107107 struct sk_psock_work_state work_state;
108108 struct delayed_work work;
109+ struct sock *sk_pair;
109110 struct rcu_work rwork;
110111 };
111112
include/linux/usb/phy.h+0−13
@@ -144,10 +144,6 @@ struct usb_phy { · 143 unmodified lines
144144 */
145145 int (*set_wakeup)(struct usb_phy *x, bool enabled);
146146
147− /* notify phy port status change */
148− int (*notify_port_status)(struct usb_phy *x, int port,
149− u16 portstatus, u16 portchange);
150−
151147 /* notify phy connect status change */
152148 int (*notify_connect)(struct usb_phy *x,
153149 enum usb_device_speed speed);
@@ -320,15 +316,6 @@ usb_phy_set_wakeup(struct usb_phy *x, bool enabled) · 166 unmodified lines
320316 return 0;
321317 }
322318
323−static inline int
324−usb_phy_notify_port_status(struct usb_phy *x, int port, u16 portstatus, u16 portchange)
325−{
326− if (x && x->notify_port_status)
327− return x->notify_port_status(x, port, portstatus, portchange);
328− else
329− return 0;
330−}
331−
332319 static inline int
333320 usb_phy_notify_connect(struct usb_phy *x, enum usb_device_speed speed)
334321 {
include/net/af_unix.h+1−0
@@ -75,6 +75,7 @@ struct unix_sock { · 74 unmodified lines
7575 };
7676
7777 #define unix_sk(ptr) container_of_const(ptr, struct unix_sock, sk)
78+#define unix_peer(sk) (unix_sk(sk)->peer)
7879
7980 #define peer_wait peer_wq.wait
8081
include/net/cfg80211.h+46−0
@@ -9302,4 +9302,50 @@ bool cfg80211_valid_disable_subchannel_bitmap(u16 *bitmap, · 9301 unmodified lines
93029302 */
93039303 void cfg80211_links_removed(struct net_device *dev, u16 link_mask);
93049304
9305+#ifdef CONFIG_CFG80211_DEBUGFS
9306+/**
9307+ * wiphy_locked_debugfs_read - do a locked read in debugfs
9308+ * @wiphy: the wiphy to use
9309+ * @file: the file being read
9310+ * @buf: the buffer to fill and then read from
9311+ * @bufsize: size of the buffer
9312+ * @userbuf: the user buffer to copy to
9313+ * @count: read count
9314+ * @ppos: read position
9315+ * @handler: the read handler to call (under wiphy lock)
9316+ * @data: additional data to pass to the read handler
9317+ */
9318+ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file,
9319+ char *buf, size_t bufsize,
9320+ char __user *userbuf, size_t count,
9321+ loff_t *ppos,
9322+ ssize_t (*handler)(struct wiphy *wiphy,
9323+ struct file *file,
9324+ char *buf,
9325+ size_t bufsize,
9326+ void *data),
9327+ void *data);
9328+
9329+/**
9330+ * wiphy_locked_debugfs_write - do a locked write in debugfs
9331+ * @wiphy: the wiphy to use
9332+ * @file: the file being written to
9333+ * @buf: the buffer to copy the user data to
9334+ * @bufsize: size of the buffer
9335+ * @userbuf: the user buffer to copy from
9336+ * @count: read count
9337+ * @handler: the write handler to call (under wiphy lock)
9338+ * @data: additional data to pass to the write handler
9339+ */
9340+ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy, struct file *file,
9341+ char *buf, size_t bufsize,
9342+ const char __user *userbuf, size_t count,
9343+ ssize_t (*handler)(struct wiphy *wiphy,
9344+ struct file *file,
9345+ char *buf,
9346+ size_t count,
9347+ void *data),
9348+ void *data);
9349+#endif
9350+
93059351 #endif /* __NET_CFG80211_H */
include/net/neighbour.h+1−1
@@ -162,7 +162,7 @@ struct neighbour { · 161 unmodified lines
162162 struct rcu_head rcu;
163163 struct net_device *dev;
164164 netdevice_tracker dev_tracker;
165− u8 primary_key[0];
165+ u8 primary_key[];
166166 } __randomize_layout;
167167
168168 struct neigh_ops {
include/uapi/linux/fcntl.h+3−0
@@ -116,5 +116,8 @@ · 115 unmodified lines
116116 #define AT_HANDLE_FID AT_REMOVEDIR /* file handle is needed to
117117 compare object identity and may not
118118 be usable to open_by_handle_at(2) */
119+#if defined(__KERNEL__)
120+#define AT_GETATTR_NOSEC 0x80000000
121+#endif
119122
120123 #endif /* _UAPI_LINUX_FCNTL_H */
include/uapi/linux/v4l2-subdev.h+1−1
@@ -239,7 +239,7 @@ struct v4l2_subdev_routing { · 238 unmodified lines
239239 * set (which is the default), the 'stream' fields will be forced to 0 by the
240240 * kernel.
241241 */
242− #define V4L2_SUBDEV_CLIENT_CAP_STREAMS (1U << 0)
242+ #define V4L2_SUBDEV_CLIENT_CAP_STREAMS (1ULL << 0)
243243
244244 /**
245245 * struct v4l2_subdev_client_capability - Capabilities of the client accessing
io_uring/fs.c+1−1
@@ -254,7 +254,7 @@ int io_linkat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) · 253 unmodified lines
254254 newf = u64_to_user_ptr(READ_ONCE(sqe->addr2));
255255 lnk->flags = READ_ONCE(sqe->hardlink_flags);
256256
257− lnk->oldpath = getname(oldf);
257+ lnk->oldpath = getname_uflags(oldf, lnk->flags);
258258 if (IS_ERR(lnk->oldpath))
259259 return PTR_ERR(lnk->oldpath);
260260
io_uring/rsrc.c+1−1
@@ -1258,7 +1258,7 @@ int io_import_fixed(int ddir, struct iov_iter *iter, · 1257 unmodified lines
12581258 */
12591259 const struct bio_vec *bvec = imu->bvec;
12601260
1261− if (offset <= bvec->bv_len) {
1261+ if (offset < bvec->bv_len) {
12621262 /*
12631263 * Note, huge pages buffers consists of one large
12641264 * bvec entry and should always go this way. The other
kernel/bpf/memalloc.c+2−0
@@ -978,6 +978,8 @@ void notrace *bpf_mem_cache_alloc_flags(struct bpf_mem_alloc *ma, gfp_t flags) · 977 unmodified lines
978978 memcg = get_memcg(c);
979979 old_memcg = set_active_memcg(memcg);
980980 ret = __alloc(c, NUMA_NO_NODE, GFP_KERNEL | __GFP_NOWARN | __GFP_ACCOUNT);
981+ if (ret)
982+ *(struct bpf_mem_cache **)ret = c;
981983 set_active_memcg(old_memcg);
982984 mem_cgroup_put(memcg);
983985 }
kernel/locking/lockdep.c+2−1
@@ -3497,7 +3497,8 @@ static int alloc_chain_hlocks(int req) · 3496 unmodified lines
34973497 size = chain_block_size(curr);
34983498 if (likely(size >= req)) {
34993499 del_chain_block(0, size, chain_block_next(curr));
3500− add_chain_block(curr + req, size - req);
3500+ if (size > req)
3501+ add_chain_block(curr + req, size - req);
35013502 return curr;
35023503 }
35033504 }
lib/errname.c+0−6
@@ -111,9 +111,6 @@ static const char *names_0[] = { · 110 unmodified lines
111111 E(ENOSPC),
112112 E(ENOSR),
113113 E(ENOSTR),
114−#ifdef ENOSYM
115− E(ENOSYM),
116−#endif
117114 E(ENOSYS),
118115 E(ENOTBLK),
119116 E(ENOTCONN),
@@ -144,9 +141,6 @@ static const char *names_0[] = { · 24 unmodified lines
144141 #endif
145142 E(EREMOTE),
146143 E(EREMOTEIO),
147−#ifdef EREMOTERELEASE
148− E(EREMOTERELEASE),
149−#endif
150144 E(ERESTART),
151145 E(ERFKILL),
152146 E(EROFS),
lib/iov_iter.c+1−1
@@ -409,7 +409,7 @@ size_t copy_page_to_iter_nofault(struct page *page, unsigned offset, size_t byte · 408 unmodified lines
409409 void *kaddr = kmap_local_page(page);
410410 size_t n = min(bytes, (size_t)PAGE_SIZE - offset);
411411
412− n = iterate_and_advance(i, bytes, kaddr,
412+ n = iterate_and_advance(i, n, kaddr + offset,
413413 copy_to_user_iter_nofault,
414414 memcpy_to_iter);
415415 kunmap_local(kaddr);
mm/page-writeback.c+1−1
@@ -3107,7 +3107,7 @@ EXPORT_SYMBOL_GPL(folio_wait_writeback_killable); · 3106 unmodified lines
31073107 */
31083108 void folio_wait_stable(struct folio *folio)
31093109 {
3110− if (folio_inode(folio)->i_sb->s_iflags & SB_I_STABLE_WRITES)
3110+ if (mapping_stable_writes(folio_mapping(folio)))
31113111 folio_wait_writeback(folio);
31123112 }
31133113 EXPORT_SYMBOL_GPL(folio_wait_stable);
net/core/skmsg.c+2−0
@@ -826,6 +826,8 @@ static void sk_psock_destroy(struct work_struct *work) · 825 unmodified lines
826826
827827 if (psock->sk_redir)
828828 sock_put(psock->sk_redir);
829+ if (psock->sk_pair)
830+ sock_put(psock->sk_pair);
829831 sock_put(psock->sk);
830832 kfree(psock);
831833 }
net/ethtool/netlink.c+1−0
@@ -505,6 +505,7 @@ static int ethnl_default_dumpit(struct sk_buff *skb, · 504 unmodified lines
505505 ret = skb->len;
506506 break;
507507 }
508+ ret = 0;
508509 }
509510 rtnl_unlock();
510511
net/ipv4/igmp.c+4−2
@@ -216,8 +216,10 @@ static void igmp_start_timer(struct ip_mc_list *im, int max_delay) · 215 unmodified lines
216216 int tv = get_random_u32_below(max_delay);
217217
218218 im->tm_running = 1;
219− if (!mod_timer(&im->timer, jiffies+tv+2))
220− refcount_inc(&im->refcnt);
219+ if (refcount_inc_not_zero(&im->refcnt)) {
220+ if (mod_timer(&im->timer, jiffies + tv + 2))
221+ ip_ma_put(im);
222+ }
221223 }
222224
223225 static void igmp_gq_start_timer(struct in_device *in_dev)
net/mac80211/Kconfig+1−1
@@ -88,7 +88,7 @@ config MAC80211_LEDS · 87 unmodified lines
8888
8989 config MAC80211_DEBUGFS
9090 bool "Export mac80211 internals in DebugFS"
91− depends on MAC80211 && DEBUG_FS
91+ depends on MAC80211 && CFG80211_DEBUGFS
9292 help
9393 Select this to see extensive information about
9494 the internal state of mac80211 in debugfs.
net/mac80211/debugfs_netdev.c+105−45
@@ -22,88 +22,148 @@ · 21 unmodified lines
2222 #include "debugfs_netdev.h"
2323 #include "driver-ops.h"
2424
25+struct ieee80211_if_read_sdata_data {
26+ ssize_t (*format)(const struct ieee80211_sub_if_data *, char *, int);
27+ struct ieee80211_sub_if_data *sdata;
28+};
29+
30+static ssize_t ieee80211_if_read_sdata_handler(struct wiphy *wiphy,
31+ struct file *file,
32+ char *buf,
33+ size_t bufsize,
34+ void *data)
35+{
36+ struct ieee80211_if_read_sdata_data *d = data;
37+
38+ return d->format(d->sdata, buf, bufsize);
39+}
40+
2541 static ssize_t ieee80211_if_read_sdata(
26− struct ieee80211_sub_if_data *sdata,
42+ struct file *file,
2743 char __user *userbuf,
2844 size_t count, loff_t *ppos,
2945 ssize_t (*format)(const struct ieee80211_sub_if_data *sdata, char *, int))
3046 {
47+ struct ieee80211_sub_if_data *sdata = file->private_data;
48+ struct ieee80211_if_read_sdata_data data = {
49+ .format = format,
50+ .sdata = sdata,
51+ };
3152 char buf[200];
32− ssize_t ret = -EINVAL;
3353
34− wiphy_lock(sdata->local->hw.wiphy);
35− ret = (*format)(sdata, buf, sizeof(buf));
36− wiphy_unlock(sdata->local->hw.wiphy);
54+ return wiphy_locked_debugfs_read(sdata->local->hw.wiphy,
55+ file, buf, sizeof(buf),
56+ userbuf, count, ppos,
57+ ieee80211_if_read_sdata_handler,
58+ &data);
59+}
3760
38− if (ret >= 0)
39− ret = simple_read_from_buffer(userbuf, count, ppos, buf, ret);
61+struct ieee80211_if_write_sdata_data {
62+ ssize_t (*write)(struct ieee80211_sub_if_data *, const char *, int);
63+ struct ieee80211_sub_if_data *sdata;
64+};
65+
66+static ssize_t ieee80211_if_write_sdata_handler(struct wiphy *wiphy,
67+ struct file *file,
68+ char *buf,
69+ size_t count,
70+ void *data)
71+{
72+ struct ieee80211_if_write_sdata_data *d = data;
4073
41− return ret;
74+ return d->write(d->sdata, buf, count);
4275 }
4376
4477 static ssize_t ieee80211_if_write_sdata(
45− struct ieee80211_sub_if_data *sdata,
78+ struct file *file,
4679 const char __user *userbuf,
4780 size_t count, loff_t *ppos,
4881 ssize_t (*write)(struct ieee80211_sub_if_data *sdata, const char *, int))
4982 {
83+ struct ieee80211_sub_if_data *sdata = file->private_data;
84+ struct ieee80211_if_write_sdata_data data = {
85+ .write = write,
86+ .sdata = sdata,
87+ };
5088 char buf[64];
51− ssize_t ret;
5289
53− if (count >= sizeof(buf))
54− return -E2BIG;
90+ return wiphy_locked_debugfs_write(sdata->local->hw.wiphy,
91+ file, buf, sizeof(buf),
92+ userbuf, count,
93+ ieee80211_if_write_sdata_handler,
94+ &data);
95+}
5596
56− if (copy_from_user(buf, userbuf, count))
57− return -EFAULT;
58− buf[count] = '\0';
97+struct ieee80211_if_read_link_data {
98+ ssize_t (*format)(const struct ieee80211_link_data *, char *, int);
99+ struct ieee80211_link_data *link;
100+};
59101
60− wiphy_lock(sdata->local->hw.wiphy);
61− ret = (*write)(sdata, buf, count);
62− wiphy_unlock(sdata->local->hw.wiphy);
102+static ssize_t ieee80211_if_read_link_handler(struct wiphy *wiphy,
103+ struct file *file,
104+ char *buf,
105+ size_t bufsize,
106+ void *data)
107+{
108+ struct ieee80211_if_read_link_data *d = data;
63109
64− return ret;
110+ return d->format(d->link, buf, bufsize);
65111 }
66112
67113 static ssize_t ieee80211_if_read_link(
68− struct ieee80211_link_data *link,
114+ struct file *file,
69115 char __user *userbuf,
70116 size_t count, loff_t *ppos,
71117 ssize_t (*format)(const struct ieee80211_link_data *link, char *, int))
72118 {
119+ struct ieee80211_link_data *link = file->private_data;
120+ struct ieee80211_if_read_link_data data = {
121+ .format = format,
122+ .link = link,
123+ };
73124 char buf[200];
74− ssize_t ret = -EINVAL;
75125
76− wiphy_lock(link->sdata->local->hw.wiphy);
77− ret = (*format)(link, buf, sizeof(buf));
78− wiphy_unlock(link->sdata->local->hw.wiphy);
126+ return wiphy_locked_debugfs_read(link->sdata->local->hw.wiphy,
127+ file, buf, sizeof(buf),
128+ userbuf, count, ppos,
129+ ieee80211_if_read_link_handler,
130+ &data);
131+}
132+
133+struct ieee80211_if_write_link_data {
134+ ssize_t (*write)(struct ieee80211_link_data *, const char *, int);
135+ struct ieee80211_link_data *link;
136+};
79137
80− if (ret >= 0)
81− ret = simple_read_from_buffer(userbuf, count, ppos, buf, ret);
138+static ssize_t ieee80211_if_write_link_handler(struct wiphy *wiphy,
139+ struct file *file,
140+ char *buf,
141+ size_t count,
142+ void *data)
143+{
144+ struct ieee80211_if_write_sdata_data *d = data;
82145
83− return ret;
146+ return d->write(d->sdata, buf, count);
84147 }
85148
86149 static ssize_t ieee80211_if_write_link(
87− struct ieee80211_link_data *link,
150+ struct file *file,
88151 const char __user *userbuf,
89152 size_t count, loff_t *ppos,
90153 ssize_t (*write)(struct ieee80211_link_data *link, const char *, int))
91154 {
155+ struct ieee80211_link_data *link = file->private_data;
156+ struct ieee80211_if_write_link_data data = {
157+ .write = write,
158+ .link = link,
159+ };
92160 char buf[64];
93− ssize_t ret;
94−
95− if (count >= sizeof(buf))
96− return -E2BIG;
97−
98− if (copy_from_user(buf, userbuf, count))
99− return -EFAULT;
100− buf[count] = '\0';
101−
102− wiphy_lock(link->sdata->local->hw.wiphy);
103− ret = (*write)(link, buf, count);
104− wiphy_unlock(link->sdata->local->hw.wiphy);
105161
106− return ret;
162+ return wiphy_locked_debugfs_write(link->sdata->local->hw.wiphy,
163+ file, buf, sizeof(buf),
164+ userbuf, count,
165+ ieee80211_if_write_link_handler,
166+ &data);
107167 }
108168
109169 #define IEEE80211_IF_FMT(name, type, field, format_string) \
@@ -173,7 +233,7 @@ static ssize_t ieee80211_if_read_##name(struct file *file, \ · 63 unmodified lines
173233 char __user *userbuf, \
174234 size_t count, loff_t *ppos) \
175235 { \
176− return ieee80211_if_read_sdata(file->private_data, \
236+ return ieee80211_if_read_sdata(file, \
177237 userbuf, count, ppos, \
178238 ieee80211_if_fmt_##name); \
179239 }
@@ -183,7 +243,7 @@ static ssize_t ieee80211_if_write_##name(struct file *file, \ · 3 unmodified lines
183243 const char __user *userbuf, \
184244 size_t count, loff_t *ppos) \
185245 { \
186− return ieee80211_if_write_sdata(file->private_data, userbuf, \
246+ return ieee80211_if_write_sdata(file, userbuf, \
187247 count, ppos, \
188248 ieee80211_if_parse_##name); \
189249 }
@@ -211,7 +271,7 @@ static ssize_t ieee80211_if_read_##name(struct file *file, \ · 21 unmodified lines
211271 char __user *userbuf, \
212272 size_t count, loff_t *ppos) \
213273 { \
214− return ieee80211_if_read_link(file->private_data, \
274+ return ieee80211_if_read_link(file, \
215275 userbuf, count, ppos, \
216276 ieee80211_if_fmt_##name); \
217277 }
@@ -221,7 +281,7 @@ static ssize_t ieee80211_if_write_##name(struct file *file, \ · 3 unmodified lines
221281 const char __user *userbuf, \
222282 size_t count, loff_t *ppos) \
223283 { \
224− return ieee80211_if_write_link(file->private_data, userbuf, \
284+ return ieee80211_if_write_link(file, userbuf, \
225285 count, ppos, \
226286 ieee80211_if_parse_##name); \
227287 }
net/mac80211/debugfs_sta.c+42−32
@@ -312,23 +312,14 @@ static ssize_t sta_aql_write(struct file *file, const char __user *userbuf, · 311 unmodified lines
312312 STA_OPS_RW(aql);
313313
314314
315−static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
316− size_t count, loff_t *ppos)
315+static ssize_t sta_agg_status_do_read(struct wiphy *wiphy, struct file *file,
316+ char *buf, size_t bufsz, void *data)
317317 {
318− char *buf, *p;
319− ssize_t bufsz = 71 + IEEE80211_NUM_TIDS * 40;
318+ struct sta_info *sta = data;
319+ char *p = buf;
320320 int i;
321− struct sta_info *sta = file->private_data;
322321 struct tid_ampdu_rx *tid_rx;
323322 struct tid_ampdu_tx *tid_tx;
324− ssize_t ret;
325−
326− buf = kzalloc(bufsz, GFP_KERNEL);
327− if (!buf)
328− return -ENOMEM;
329− p = buf;
330−
331− rcu_read_lock();
332323
333324 p += scnprintf(p, bufsz + buf - p, "next dialog_token: %#02x\n",
334325 sta->ampdu_mlme.dialog_token_allocator + 1);
@@ -338,8 +329,8 @@ static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf, · 3 unmodified lines
338329 for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
339330 bool tid_rx_valid;
340331
341− tid_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[i]);
342− tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[i]);
332+ tid_rx = wiphy_dereference(wiphy, sta->ampdu_mlme.tid_rx[i]);
333+ tid_tx = wiphy_dereference(wiphy, sta->ampdu_mlme.tid_tx[i]);
343334 tid_rx_valid = test_bit(i, sta->ampdu_mlme.agg_session_valid);
344335
345336 p += scnprintf(p, bufsz + buf - p, "%02d", i);
@@ -358,31 +349,39 @@ static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf, · 12 unmodified lines
358349 tid_tx ? skb_queue_len(&tid_tx->pending) : 0);
359350 p += scnprintf(p, bufsz + buf - p, "\n");
360351 }
361− rcu_read_unlock();
362352
363− ret = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
353+ return p - buf;
354+}
355+
356+static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
357+ size_t count, loff_t *ppos)
358+{
359+ struct sta_info *sta = file->private_data;
360+ struct wiphy *wiphy = sta->local->hw.wiphy;
361+ size_t bufsz = 71 + IEEE80211_NUM_TIDS * 40;
362+ char *buf = kmalloc(bufsz, GFP_KERNEL);
363+ ssize_t ret;
364+
365+ if (!buf)
366+ return -ENOMEM;
367+
368+ ret = wiphy_locked_debugfs_read(wiphy, file, buf, bufsz,
369+ userbuf, count, ppos,
370+ sta_agg_status_do_read, sta);
364371 kfree(buf);
372+
365373 return ret;
366374 }
367375
368−static ssize_t sta_agg_status_write(struct file *file, const char __user *userbuf,
369− size_t count, loff_t *ppos)
376+static ssize_t sta_agg_status_do_write(struct wiphy *wiphy, struct file *file,
377+ char *buf, size_t count, void *data)
370378 {
371− char _buf[25] = {}, *buf = _buf;
372− struct sta_info *sta = file->private_data;
379+ struct sta_info *sta = data;
373380 bool start, tx;
374381 unsigned long tid;
375− char *pos;
382+ char *pos = buf;
376383 int ret, timeout = 5000;
377384
378− if (count > sizeof(_buf))
379− return -EINVAL;
380−
381− if (copy_from_user(buf, userbuf, count))
382− return -EFAULT;
383−
384− buf[sizeof(_buf) - 1] = '\0';
385− pos = buf;
386385 buf = strsep(&pos, " ");
387386 if (!buf)
388387 return -EINVAL;
@@ -420,7 +419,6 @@ static ssize_t sta_agg_status_write(struct file *file, const char __user *userbu · 31 unmodified lines
420419 if (ret || tid >= IEEE80211_NUM_TIDS)
421420 return -EINVAL;
422421
423− wiphy_lock(sta->local->hw.wiphy);
424422 if (tx) {
425423 if (start)
426424 ret = ieee80211_start_tx_ba_session(&sta->sta, tid,
@@ -432,10 +430,22 @@ static ssize_t sta_agg_status_write(struct file *file, const char __user *userbu · 5 unmodified lines
432430 3, true);
433431 ret = 0;
434432 }
435− wiphy_unlock(sta->local->hw.wiphy);
436433
437434 return ret ?: count;
438435 }
436+
437+static ssize_t sta_agg_status_write(struct file *file,
438+ const char __user *userbuf,
439+ size_t count, loff_t *ppos)
440+{
441+ struct sta_info *sta = file->private_data;
442+ struct wiphy *wiphy = sta->local->hw.wiphy;
443+ char _buf[26];
444+
445+ return wiphy_locked_debugfs_write(wiphy, file, _buf, sizeof(_buf),
446+ userbuf, count,
447+ sta_agg_status_do_write, sta);
448+}
439449 STA_OPS_RW(agg_status);
440450
441451 /* link sta attributes */
net/mac80211/driver-ops.h+7−2
@@ -23,7 +23,7 @@ · 22 unmodified lines
2323 static inline struct ieee80211_sub_if_data *
2424 get_bss_sdata(struct ieee80211_sub_if_data *sdata)
2525 {
26− if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
26+ if (sdata && sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
2727 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
2828 u.ap);
2929
@@ -695,11 +695,14 @@ static inline void drv_flush(struct ieee80211_local *local, · 665 unmodified lines
695695 struct ieee80211_sub_if_data *sdata,
696696 u32 queues, bool drop)
697697 {
698− struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
698+ struct ieee80211_vif *vif;
699699
700700 might_sleep();
701701 lockdep_assert_wiphy(local->hw.wiphy);
702702
703+ sdata = get_bss_sdata(sdata);
704+ vif = sdata ? &sdata->vif : NULL;
705+
703706 if (sdata && !check_sdata_in_driver(sdata))
704707 return;
705708
@@ -716,6 +719,8 @@ static inline void drv_flush_sta(struct ieee80211_local *local, · 10 unmodified lines
716719 might_sleep();
717720 lockdep_assert_wiphy(local->hw.wiphy);
718721
722+ sdata = get_bss_sdata(sdata);
723+
719724 if (sdata && !check_sdata_in_driver(sdata))
720725 return;
721726
net/mac80211/ht.c+1−0
@@ -271,6 +271,7 @@ bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata, · 270 unmodified lines
271271 case NL80211_CHAN_WIDTH_80:
272272 case NL80211_CHAN_WIDTH_80P80:
273273 case NL80211_CHAN_WIDTH_160:
274+ case NL80211_CHAN_WIDTH_320:
274275 bw = ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 ?
275276 IEEE80211_STA_RX_BW_40 : IEEE80211_STA_RX_BW_20;
276277 break;
net/mptcp/options.c+1−0
@@ -108,6 +108,7 @@ static void mptcp_parse_option(const struct sk_buff *skb, · 107 unmodified lines
108108 mp_opt->suboptions |= OPTION_MPTCP_DSS;
109109 mp_opt->use_map = 1;
110110 mp_opt->mpc_map = 1;
111+ mp_opt->use_ack = 0;
111112 mp_opt->data_len = get_unaligned_be16(ptr);
112113 ptr += 2;
113114 }
net/unix/af_unix.c+0−2
@@ -213,8 +213,6 @@ static inline bool unix_secdata_eq(struct scm_cookie *scm, struct sk_buff *skb) · 212 unmodified lines
213213 }
214214 #endif /* CONFIG_SECURITY_NETWORK */
215215
216−#define unix_peer(sk) (unix_sk(sk)->peer)
217−
218216 static inline int unix_our_peer(struct sock *sk, struct sock *osk)
219217 {
220218 return unix_peer(osk) == sk;
net/unix/unix_bpf.c+5−0
@@ -159,12 +159,17 @@ int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool re · 158 unmodified lines
159159
160160 int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore)
161161 {
162+ struct sock *sk_pair;
163+
162164 if (restore) {
163165 sk->sk_write_space = psock->saved_write_space;
164166 sock_replace_proto(sk, psock->sk_proto);
165167 return 0;
166168 }
167169
170+ sk_pair = unix_peer(sk);
171+ sock_hold(sk_pair);
172+ psock->sk_pair = sk_pair;
168173 unix_stream_bpf_check_needs_rebuild(psock->sk_proto);
169174 sock_replace_proto(sk, &unix_stream_bpf_prot);
170175 return 0;
net/wireless/core.c+4−2
@@ -191,13 +191,13 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev, · 190 unmodified lines
191191 return err;
192192 }
193193
194+ wiphy_lock(&rdev->wiphy);
194195 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
195196 if (!wdev->netdev)
196197 continue;
197198 nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE);
198199 }
199200
200− wiphy_lock(&rdev->wiphy);
201201 nl80211_notify_wiphy(rdev, NL80211_CMD_DEL_WIPHY);
202202
203203 wiphy_net_set(&rdev->wiphy, net);
@@ -206,13 +206,13 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev, · 2 unmodified lines
206206 WARN_ON(err);
207207
208208 nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
209− wiphy_unlock(&rdev->wiphy);
210209
211210 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
212211 if (!wdev->netdev)
213212 continue;
214213 nl80211_notify_iface(rdev, wdev, NL80211_CMD_NEW_INTERFACE);
215214 }
215+ wiphy_unlock(&rdev->wiphy);
216216
217217 return 0;
218218 }
@@ -221,7 +221,9 @@ static void cfg80211_rfkill_poll(struct rfkill *rfkill, void *data) · 2 unmodified lines
221221 {
222222 struct cfg80211_registered_device *rdev = data;
223223
224+ wiphy_lock(&rdev->wiphy);
224225 rdev_rfkill_poll(rdev);
226+ wiphy_unlock(&rdev->wiphy);
225227 }
226228
227229 void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
net/wireless/core.h+1−0
@@ -293,6 +293,7 @@ struct cfg80211_cqm_config { · 292 unmodified lines
293293 u32 rssi_hyst;
294294 s32 last_rssi_event_value;
295295 enum nl80211_cqm_rssi_threshold_event last_rssi_event_type;
296+ bool use_range_api;
296297 int n_rssi_thresholds;
297298 s32 rssi_thresholds[] __counted_by(n_rssi_thresholds);
298299 };
net/wireless/debugfs.c+160−0
@@ -4,6 +4,7 @@ · 3 unmodified lines
44 *
55 * Copyright 2009 Luis R. Rodriguez <lrodriguez@atheros.com>
66 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
7+ * Copyright (C) 2023 Intel Corporation
78 */
89
910 #include <linux/slab.h>
@@ -109,3 +110,162 @@ void cfg80211_debugfs_rdev_add(struct cfg80211_registered_device *rdev) · 99 unmodified lines
109110 DEBUGFS_ADD(long_retry_limit);
110111 DEBUGFS_ADD(ht40allow_map);
111112 }
113+
114+struct debugfs_read_work {
115+ struct wiphy_work work;
116+ ssize_t (*handler)(struct wiphy *wiphy,
117+ struct file *file,
118+ char *buf,
119+ size_t count,
120+ void *data);
121+ struct wiphy *wiphy;
122+ struct file *file;
123+ char *buf;
124+ size_t bufsize;
125+ void *data;
126+ ssize_t ret;
127+ struct completion completion;
128+};
129+
130+static void wiphy_locked_debugfs_read_work(struct wiphy *wiphy,
131+ struct wiphy_work *work)
132+{
133+ struct debugfs_read_work *w = container_of(work, typeof(*w), work);
134+
135+ w->ret = w->handler(w->wiphy, w->file, w->buf, w->bufsize, w->data);
136+ complete(&w->completion);
137+}
138+
139+static void wiphy_locked_debugfs_read_cancel(struct dentry *dentry,
140+ void *data)
141+{
142+ struct debugfs_read_work *w = data;
143+
144+ wiphy_work_cancel(w->wiphy, &w->work);
145+ complete(&w->completion);
146+}
147+
148+ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file,
149+ char *buf, size_t bufsize,
150+ char __user *userbuf, size_t count,
151+ loff_t *ppos,
152+ ssize_t (*handler)(struct wiphy *wiphy,
153+ struct file *file,
154+ char *buf,
155+ size_t bufsize,
156+ void *data),
157+ void *data)
158+{
159+ struct debugfs_read_work work = {
160+ .handler = handler,
161+ .wiphy = wiphy,
162+ .file = file,
163+ .buf = buf,
164+ .bufsize = bufsize,
165+ .data = data,
166+ .ret = -ENODEV,
167+ .completion = COMPLETION_INITIALIZER_ONSTACK(work.completion),
168+ };
169+ struct debugfs_cancellation cancellation = {
170+ .cancel = wiphy_locked_debugfs_read_cancel,
171+ .cancel_data = &work,
172+ };
173+
174+ /* don't leak stack data or whatever */
175+ memset(buf, 0, bufsize);
176+
177+ wiphy_work_init(&work.work, wiphy_locked_debugfs_read_work);
178+ wiphy_work_queue(wiphy, &work.work);
179+
180+ debugfs_enter_cancellation(file, &cancellation);
181+ wait_for_completion(&work.completion);
182+ debugfs_leave_cancellation(file, &cancellation);
183+
184+ if (work.ret < 0)
185+ return work.ret;
186+
187+ if (WARN_ON(work.ret > bufsize))
188+ return -EINVAL;
189+
190+ return simple_read_from_buffer(userbuf, count, ppos, buf, work.ret);
191+}
192+EXPORT_SYMBOL_GPL(wiphy_locked_debugfs_read);
193+
194+struct debugfs_write_work {
195+ struct wiphy_work work;
196+ ssize_t (*handler)(struct wiphy *wiphy,
197+ struct file *file,
198+ char *buf,
199+ size_t count,
200+ void *data);
201+ struct wiphy *wiphy;
202+ struct file *file;
203+ char *buf;
204+ size_t count;
205+ void *data;
206+ ssize_t ret;
207+ struct completion completion;
208+};
209+
210+static void wiphy_locked_debugfs_write_work(struct wiphy *wiphy,
211+ struct wiphy_work *work)
212+{
213+ struct debugfs_write_work *w = container_of(work, typeof(*w), work);
214+
215+ w->ret = w->handler(w->wiphy, w->file, w->buf, w->count, w->data);
216+ complete(&w->completion);
217+}
218+
219+static void wiphy_locked_debugfs_write_cancel(struct dentry *dentry,
220+ void *data)
221+{
222+ struct debugfs_write_work *w = data;
223+
224+ wiphy_work_cancel(w->wiphy, &w->work);
225+ complete(&w->completion);
226+}
227+
228+ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy,
229+ struct file *file, char *buf, size_t bufsize,
230+ const char __user *userbuf, size_t count,
231+ ssize_t (*handler)(struct wiphy *wiphy,
232+ struct file *file,
233+ char *buf,
234+ size_t count,
235+ void *data),
236+ void *data)
237+{
238+ struct debugfs_write_work work = {
239+ .handler = handler,
240+ .wiphy = wiphy,
241+ .file = file,
242+ .buf = buf,
243+ .count = count,
244+ .data = data,
245+ .ret = -ENODEV,
246+ .completion = COMPLETION_INITIALIZER_ONSTACK(work.completion),
247+ };
248+ struct debugfs_cancellation cancellation = {
249+ .cancel = wiphy_locked_debugfs_write_cancel,
250+ .cancel_data = &work,
251+ };
252+
253+ /* mostly used for strings so enforce NUL-termination for safety */
254+ if (count >= bufsize)
255+ return -EINVAL;
256+
257+ memset(buf, 0, bufsize);
258+
259+ if (copy_from_user(buf, userbuf, count))
260+ return -EFAULT;
261+
262+ wiphy_work_init(&work.work, wiphy_locked_debugfs_write_work);
263+ wiphy_work_queue(wiphy, &work.work);
264+
265+ debugfs_enter_cancellation(file, &cancellation);
266+ wait_for_completion(&work.completion);
267+ debugfs_leave_cancellation(file, &cancellation);
268+
269+ return work.ret;
270+}
271+EXPORT_SYMBOL_GPL(wiphy_locked_debugfs_write);
net/wireless/nl80211.c+36−19
@@ -3822,6 +3822,8 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag · 3821 unmodified lines
38223822 struct net_device *dev = wdev->netdev;
38233823 void *hdr;
38243824
3825+ lockdep_assert_wiphy(&rdev->wiphy);
3826+
38253827 WARN_ON(cmd != NL80211_CMD_NEW_INTERFACE &&
38263828 cmd != NL80211_CMD_DEL_INTERFACE &&
38273829 cmd != NL80211_CMD_SET_INTERFACE);
@@ -3989,6 +3991,7 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback * · 161 unmodified lines
39893991
39903992 if_idx = 0;
39913993
3994+ wiphy_lock(&rdev->wiphy);
39923995 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
39933996 if (if_idx < if_start) {
39943997 if_idx++;
@@ -3998,10 +4001,12 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback * · 3 unmodified lines
39984001 cb->nlh->nlmsg_seq, NLM_F_MULTI,
39994002 rdev, wdev,
40004003 NL80211_CMD_NEW_INTERFACE) < 0) {
4004+ wiphy_unlock(&rdev->wiphy);
40014005 goto out;
40024006 }
40034007 if_idx++;
40044008 }
4009+ wiphy_unlock(&rdev->wiphy);
40054010
40064011 wp_idx++;
40074012 }
@@ -12788,10 +12793,6 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev, · 8780 unmodified lines
1278812793 int i, n, low_index;
1278912794 int err;
1279012795
12791− /* RSSI reporting disabled? */
12792− if (!cqm_config)
12793− return rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);
12794−
1279512796 /*
1279612797 * Obtain current RSSI value if possible, if not and no RSSI threshold
1279712798 * event has been received yet, we should receive an event after a
@@ -12866,23 +12867,25 @@ static int nl80211_set_cqm_rssi(struct genl_info *info, · 68 unmodified lines
1286612867 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
1286712868 return -EOPNOTSUPP;
1286812869
12869− if (n_thresholds <= 1 && rdev->ops->set_cqm_rssi_config) {
12870− if (n_thresholds == 0 || thresholds[0] == 0) /* Disabling */
12871− return rdev_set_cqm_rssi_config(rdev, dev, 0, 0);
12872−
12873− return rdev_set_cqm_rssi_config(rdev, dev,
12874− thresholds[0], hysteresis);
12875− }
12876−
12877− if (!wiphy_ext_feature_isset(&rdev->wiphy,
12878− NL80211_EXT_FEATURE_CQM_RSSI_LIST))
12879− return -EOPNOTSUPP;
12880−
1288112870 if (n_thresholds == 1 && thresholds[0] == 0) /* Disabling */
1288212871 n_thresholds = 0;
1288312872
1288412873 old = wiphy_dereference(wdev->wiphy, wdev->cqm_config);
1288512874
12875+ /* if already disabled just succeed */
12876+ if (!n_thresholds && !old)
12877+ return 0;
12878+
12879+ if (n_thresholds > 1) {
12880+ if (!wiphy_ext_feature_isset(&rdev->wiphy,
12881+ NL80211_EXT_FEATURE_CQM_RSSI_LIST) ||
12882+ !rdev->ops->set_cqm_rssi_range_config)
12883+ return -EOPNOTSUPP;
12884+ } else {
12885+ if (!rdev->ops->set_cqm_rssi_config)
12886+ return -EOPNOTSUPP;
12887+ }
12888+
1288612889 if (n_thresholds) {
1288712890 cqm_config = kzalloc(struct_size(cqm_config, rssi_thresholds,
1288812891 n_thresholds),
@@ -12895,13 +12898,26 @@ static int nl80211_set_cqm_rssi(struct genl_info *info, · 6 unmodified lines
1289512898 memcpy(cqm_config->rssi_thresholds, thresholds,
1289612899 flex_array_size(cqm_config, rssi_thresholds,
1289712900 n_thresholds));
12901+ cqm_config->use_range_api = n_thresholds > 1 ||
12902+ !rdev->ops->set_cqm_rssi_config;
1289812903
1289912904 rcu_assign_pointer(wdev->cqm_config, cqm_config);
12905+
12906+ if (cqm_config->use_range_api)
12907+ err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config);
12908+ else
12909+ err = rdev_set_cqm_rssi_config(rdev, dev,
12910+ thresholds[0],
12911+ hysteresis);
1290012912 } else {
1290112913 RCU_INIT_POINTER(wdev->cqm_config, NULL);
12914+ /* if enabled as range also disable via range */
12915+ if (old->use_range_api)
12916+ err = rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);
12917+ else
12918+ err = rdev_set_cqm_rssi_config(rdev, dev, 0, 0);
1290212919 }
1290312920
12904− err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config);
1290512921 if (err) {
1290612922 rcu_assign_pointer(wdev->cqm_config, old);
1290712923 kfree_rcu(cqm_config, rcu_head);
@@ -19010,10 +19026,11 @@ void cfg80211_cqm_rssi_notify_work(struct wiphy *wiphy, struct wiphy_work *work) · 6102 unmodified lines
1901019026 s32 rssi_level;
1901119027
1901219028 cqm_config = wiphy_dereference(wdev->wiphy, wdev->cqm_config);
19013− if (!wdev->cqm_config)
19029+ if (!cqm_config)
1901419030 return;
1901519031
19016− cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config);
19032+ if (cqm_config->use_range_api)
19033+ cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config);
1901719034
1901819035 rssi_level = cqm_config->last_rssi_event_value;
1901919036 rssi_event = cqm_config->last_rssi_event_type;
scripts/checkstack.pl+1−2
@@ -97,8 +97,7 @@ my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack); · 96 unmodified lines
9797 # 11160: a7 fb ff 60 aghi %r15,-160
9898 # or
9999 # 100092: e3 f0 ff c8 ff 71 lay %r15,-56(%r15)
100− $re = qr/.*(?:lay|ag?hi).*\%r15,-(([0-9]{2}|[3-9])[0-9]{2})
101− (?:\(\%r15\))?$/ox;
100+ $re = qr/.*(?:lay|ag?hi).*\%r15,-([0-9]+)(?:\(\%r15\))?$/o;
102101 } elsif ($arch eq 'sparc' || $arch eq 'sparc64') {
103102 # f0019d10: 9d e3 bf 90 save %sp, -112, %sp
104103 $re = qr/.*save.*%sp, -(([0-9]{2}|[3-9])[0-9]{2}), %sp/o;
tools/arch/parisc/include/uapi/asm/errno.h+0−2
@@ -75,7 +75,6 @@ · 74 unmodified lines
7575
7676 /* We now return you to your regularly scheduled HPUX. */
7777
78−#define ENOSYM 215 /* symbol does not exist in executable */
7978 #define ENOTSOCK 216 /* Socket operation on non-socket */
8079 #define EDESTADDRREQ 217 /* Destination address required */
8180 #define EMSGSIZE 218 /* Message too long */
@@ -101,7 +100,6 @@ · 19 unmodified lines
101100 #define ETIMEDOUT 238 /* Connection timed out */
102101 #define ECONNREFUSED 239 /* Connection refused */
103102 #define EREFUSED ECONNREFUSED /* for HP's NFS apparently */
104−#define EREMOTERELEASE 240 /* Remote peer released connection */
105103 #define EHOSTDOWN 241 /* Host is down */
106104 #define EHOSTUNREACH 242 /* No route to host */
107105
tools/net/ynl/generated/devlink-user.c+58−29
@@ -2399,6 +2399,7 @@ void devlink_port_set_req_free(struct devlink_port_set_req *req) · 2398 unmodified lines
23992399
24002400 int devlink_port_set(struct ynl_sock *ys, struct devlink_port_set_req *req)
24012401 {
2402+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
24022403 struct nlmsghdr *nlh;
24032404 int err;
24042405
@@ -2416,7 +2417,7 @@ int devlink_port_set(struct ynl_sock *ys, struct devlink_port_set_req *req) · 11 unmodified lines
24162417 if (req->_present.port_function)
24172418 devlink_dl_port_function_put(nlh, DEVLINK_ATTR_PORT_FUNCTION, &req->port_function);
24182419
2419− err = ynl_exec(ys, nlh, NULL);
2420+ err = ynl_exec(ys, nlh, &yrs);
24202421 if (err < 0)
24212422 return -1;
24222423
@@ -2537,6 +2538,7 @@ void devlink_port_del_req_free(struct devlink_port_del_req *req) · 114 unmodified lines
25372538
25382539 int devlink_port_del(struct ynl_sock *ys, struct devlink_port_del_req *req)
25392540 {
2541+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
25402542 struct nlmsghdr *nlh;
25412543 int err;
25422544
@@ -2550,7 +2552,7 @@ int devlink_port_del(struct ynl_sock *ys, struct devlink_port_del_req *req) · 7 unmodified lines
25502552 if (req->_present.port_index)
25512553 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
25522554
2553− err = ynl_exec(ys, nlh, NULL);
2555+ err = ynl_exec(ys, nlh, &yrs);
25542556 if (err < 0)
25552557 return -1;
25562558
@@ -2568,6 +2570,7 @@ void devlink_port_split_req_free(struct devlink_port_split_req *req) · 11 unmodified lines
25682570
25692571 int devlink_port_split(struct ynl_sock *ys, struct devlink_port_split_req *req)
25702572 {
2573+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
25712574 struct nlmsghdr *nlh;
25722575 int err;
25732576
@@ -2583,7 +2586,7 @@ int devlink_port_split(struct ynl_sock *ys, struct devlink_port_split_req *req) · 9 unmodified lines
25832586 if (req->_present.port_split_count)
25842587 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_SPLIT_COUNT, req->port_split_count);
25852588
2586− err = ynl_exec(ys, nlh, NULL);
2589+ err = ynl_exec(ys, nlh, &yrs);
25872590 if (err < 0)
25882591 return -1;
25892592
@@ -2602,6 +2605,7 @@ void devlink_port_unsplit_req_free(struct devlink_port_unsplit_req *req) · 12 unmodified lines
26022605 int devlink_port_unsplit(struct ynl_sock *ys,
26032606 struct devlink_port_unsplit_req *req)
26042607 {
2608+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
26052609 struct nlmsghdr *nlh;
26062610 int err;
26072611
@@ -2615,7 +2619,7 @@ int devlink_port_unsplit(struct ynl_sock *ys, · 7 unmodified lines
26152619 if (req->_present.port_index)
26162620 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
26172621
2618− err = ynl_exec(ys, nlh, NULL);
2622+ err = ynl_exec(ys, nlh, &yrs);
26192623 if (err < 0)
26202624 return -1;
26212625
@@ -2926,6 +2930,7 @@ void devlink_sb_pool_set_req_free(struct devlink_sb_pool_set_req *req) · 304 unmodified lines
29262930 int devlink_sb_pool_set(struct ynl_sock *ys,
29272931 struct devlink_sb_pool_set_req *req)
29282932 {
2933+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
29292934 struct nlmsghdr *nlh;
29302935 int err;
29312936
@@ -2945,7 +2950,7 @@ int devlink_sb_pool_set(struct ynl_sock *ys, · 13 unmodified lines
29452950 if (req->_present.sb_pool_size)
29462951 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_POOL_SIZE, req->sb_pool_size);
29472952
2948− err = ynl_exec(ys, nlh, NULL);
2953+ err = ynl_exec(ys, nlh, &yrs);
29492954 if (err < 0)
29502955 return -1;
29512956
@@ -3126,6 +3131,7 @@ devlink_sb_port_pool_set_req_free(struct devlink_sb_port_pool_set_req *req) · 174 unmodified lines
31263131 int devlink_sb_port_pool_set(struct ynl_sock *ys,
31273132 struct devlink_sb_port_pool_set_req *req)
31283133 {
3134+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
31293135 struct nlmsghdr *nlh;
31303136 int err;
31313137
@@ -3145,7 +3151,7 @@ int devlink_sb_port_pool_set(struct ynl_sock *ys, · 13 unmodified lines
31453151 if (req->_present.sb_threshold)
31463152 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_THRESHOLD, req->sb_threshold);
31473153
3148− err = ynl_exec(ys, nlh, NULL);
3154+ err = ynl_exec(ys, nlh, &yrs);
31493155 if (err < 0)
31503156 return -1;
31513157
@@ -3334,6 +3340,7 @@ devlink_sb_tc_pool_bind_set_req_free(struct devlink_sb_tc_pool_bind_set_req *req · 182 unmodified lines
33343340 int devlink_sb_tc_pool_bind_set(struct ynl_sock *ys,
33353341 struct devlink_sb_tc_pool_bind_set_req *req)
33363342 {
3343+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
33373344 struct nlmsghdr *nlh;
33383345 int err;
33393346
@@ -3357,7 +3364,7 @@ int devlink_sb_tc_pool_bind_set(struct ynl_sock *ys, · 17 unmodified lines
33573364 if (req->_present.sb_threshold)
33583365 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_THRESHOLD, req->sb_threshold);
33593366
3360− err = ynl_exec(ys, nlh, NULL);
3367+ err = ynl_exec(ys, nlh, &yrs);
33613368 if (err < 0)
33623369 return -1;
33633370
@@ -3376,6 +3383,7 @@ void devlink_sb_occ_snapshot_req_free(struct devlink_sb_occ_snapshot_req *req) · 12 unmodified lines
33763383 int devlink_sb_occ_snapshot(struct ynl_sock *ys,
33773384 struct devlink_sb_occ_snapshot_req *req)
33783385 {
3386+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
33793387 struct nlmsghdr *nlh;
33803388 int err;
33813389
@@ -3389,7 +3397,7 @@ int devlink_sb_occ_snapshot(struct ynl_sock *ys, · 7 unmodified lines
33893397 if (req->_present.sb_index)
33903398 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
33913399
3392− err = ynl_exec(ys, nlh, NULL);
3400+ err = ynl_exec(ys, nlh, &yrs);
33933401 if (err < 0)
33943402 return -1;
33953403
@@ -3409,6 +3417,7 @@ devlink_sb_occ_max_clear_req_free(struct devlink_sb_occ_max_clear_req *req) · 13 unmodified lines
34093417 int devlink_sb_occ_max_clear(struct ynl_sock *ys,
34103418 struct devlink_sb_occ_max_clear_req *req)
34113419 {
3420+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
34123421 struct nlmsghdr *nlh;
34133422 int err;
34143423
@@ -3422,7 +3431,7 @@ int devlink_sb_occ_max_clear(struct ynl_sock *ys, · 7 unmodified lines
34223431 if (req->_present.sb_index)
34233432 mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
34243433
3425− err = ynl_exec(ys, nlh, NULL);
3434+ err = ynl_exec(ys, nlh, &yrs);
34263435 if (err < 0)
34273436 return -1;
34283437
@@ -3544,6 +3553,7 @@ void devlink_eswitch_set_req_free(struct devlink_eswitch_set_req *req) · 115 unmodified lines
35443553 int devlink_eswitch_set(struct ynl_sock *ys,
35453554 struct devlink_eswitch_set_req *req)
35463555 {
3556+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
35473557 struct nlmsghdr *nlh;
35483558 int err;
35493559
@@ -3561,7 +3571,7 @@ int devlink_eswitch_set(struct ynl_sock *ys, · 11 unmodified lines
35613571 if (req->_present.eswitch_encap_mode)
35623572 mnl_attr_put_u8(nlh, DEVLINK_ATTR_ESWITCH_ENCAP_MODE, req->eswitch_encap_mode);
35633573
3564− err = ynl_exec(ys, nlh, NULL);
3574+ err = ynl_exec(ys, nlh, &yrs);
35653575 if (err < 0)
35663576 return -1;
35673577
@@ -3895,6 +3905,7 @@ devlink_dpipe_table_counters_set_req_free(struct devlink_dpipe_table_counters_se · 327 unmodified lines
38953905 int devlink_dpipe_table_counters_set(struct ynl_sock *ys,
38963906 struct devlink_dpipe_table_counters_set_req *req)
38973907 {
3908+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
38983909 struct nlmsghdr *nlh;
38993910 int err;
39003911
@@ -3910,7 +3921,7 @@ int devlink_dpipe_table_counters_set(struct ynl_sock *ys, · 9 unmodified lines
39103921 if (req->_present.dpipe_table_counters_enabled)
39113922 mnl_attr_put_u8(nlh, DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED, req->dpipe_table_counters_enabled);
39123923
3913− err = ynl_exec(ys, nlh, NULL);
3924+ err = ynl_exec(ys, nlh, &yrs);
39143925 if (err < 0)
39153926 return -1;
39163927
@@ -3929,6 +3940,7 @@ void devlink_resource_set_req_free(struct devlink_resource_set_req *req) · 12 unmodified lines
39293940 int devlink_resource_set(struct ynl_sock *ys,
39303941 struct devlink_resource_set_req *req)
39313942 {
3943+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
39323944 struct nlmsghdr *nlh;
39333945 int err;
39343946
@@ -3944,7 +3956,7 @@ int devlink_resource_set(struct ynl_sock *ys, · 9 unmodified lines
39443956 if (req->_present.resource_size)
39453957 mnl_attr_put_u64(nlh, DEVLINK_ATTR_RESOURCE_SIZE, req->resource_size);
39463958
3947− err = ynl_exec(ys, nlh, NULL);
3959+ err = ynl_exec(ys, nlh, &yrs);
39483960 if (err < 0)
39493961 return -1;
39503962
@@ -4319,6 +4331,7 @@ void devlink_param_set_req_free(struct devlink_param_set_req *req) · 368 unmodified lines
43194331
43204332 int devlink_param_set(struct ynl_sock *ys, struct devlink_param_set_req *req)
43214333 {
4334+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
43224335 struct nlmsghdr *nlh;
43234336 int err;
43244337
@@ -4336,7 +4349,7 @@ int devlink_param_set(struct ynl_sock *ys, struct devlink_param_set_req *req) · 11 unmodified lines
43364349 if (req->_present.param_value_cmode)
43374350 mnl_attr_put_u8(nlh, DEVLINK_ATTR_PARAM_VALUE_CMODE, req->param_value_cmode);
43384351
4339− err = ynl_exec(ys, nlh, NULL);
4352+ err = ynl_exec(ys, nlh, &yrs);
43404353 if (err < 0)
43414354 return -1;
43424355
@@ -4631,6 +4644,7 @@ void devlink_region_del_req_free(struct devlink_region_del_req *req) · 288 unmodified lines
46314644
46324645 int devlink_region_del(struct ynl_sock *ys, struct devlink_region_del_req *req)
46334646 {
4647+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
46344648 struct nlmsghdr *nlh;
46354649 int err;
46364650
@@ -4648,7 +4662,7 @@ int devlink_region_del(struct ynl_sock *ys, struct devlink_region_del_req *req) · 11 unmodified lines
46484662 if (req->_present.region_snapshot_id)
46494663 mnl_attr_put_u32(nlh, DEVLINK_ATTR_REGION_SNAPSHOT_ID, req->region_snapshot_id);
46504664
4651− err = ynl_exec(ys, nlh, NULL);
4665+ err = ynl_exec(ys, nlh, &yrs);
46524666 if (err < 0)
46534667 return -1;
46544668
@@ -4922,6 +4936,7 @@ void devlink_port_param_set_req_free(struct devlink_port_param_set_req *req) · 267 unmodified lines
49224936 int devlink_port_param_set(struct ynl_sock *ys,
49234937 struct devlink_port_param_set_req *req)
49244938 {
4939+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
49254940 struct nlmsghdr *nlh;
49264941 int err;
49274942
@@ -4935,7 +4950,7 @@ int devlink_port_param_set(struct ynl_sock *ys, · 7 unmodified lines
49354950 if (req->_present.port_index)
49364951 mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
49374952
4938− err = ynl_exec(ys, nlh, NULL);
4953+ err = ynl_exec(ys, nlh, &yrs);
49394954 if (err < 0)
49404955 return -1;
49414956
@@ -5360,6 +5375,7 @@ devlink_health_reporter_set_req_free(struct devlink_health_reporter_set_req *req · 418 unmodified lines
53605375 int devlink_health_reporter_set(struct ynl_sock *ys,
53615376 struct devlink_health_reporter_set_req *req)
53625377 {
5378+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
53635379 struct nlmsghdr *nlh;
53645380 int err;
53655381
@@ -5381,7 +5397,7 @@ int devlink_health_reporter_set(struct ynl_sock *ys, · 15 unmodified lines
53815397 if (req->_present.health_reporter_auto_dump)
53825398 mnl_attr_put_u8(nlh, DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP, req->health_reporter_auto_dump);
53835399
5384− err = ynl_exec(ys, nlh, NULL);
5400+ err = ynl_exec(ys, nlh, &yrs);
53855401 if (err < 0)
53865402 return -1;
53875403
@@ -5402,6 +5418,7 @@ devlink_health_reporter_recover_req_free(struct devlink_health_reporter_recover_ · 14 unmodified lines
54025418 int devlink_health_reporter_recover(struct ynl_sock *ys,
54035419 struct devlink_health_reporter_recover_req *req)
54045420 {
5421+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
54055422 struct nlmsghdr *nlh;
54065423 int err;
54075424
@@ -5417,7 +5434,7 @@ int devlink_health_reporter_recover(struct ynl_sock *ys, · 9 unmodified lines
54175434 if (req->_present.health_reporter_name_len)
54185435 mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME, req->health_reporter_name);
54195436
5420− err = ynl_exec(ys, nlh, NULL);
5437+ err = ynl_exec(ys, nlh, &yrs);
54215438 if (err < 0)
54225439 return -1;
54235440
@@ -5438,6 +5455,7 @@ devlink_health_reporter_diagnose_req_free(struct devlink_health_reporter_diagnos · 14 unmodified lines
54385455 int devlink_health_reporter_diagnose(struct ynl_sock *ys,
54395456 struct devlink_health_reporter_diagnose_req *req)
54405457 {
5458+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
54415459 struct nlmsghdr *nlh;
54425460 int err;
54435461
@@ -5453,7 +5471,7 @@ int devlink_health_reporter_diagnose(struct ynl_sock *ys, · 9 unmodified lines
54535471 if (req->_present.health_reporter_name_len)
54545472 mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME, req->health_reporter_name);
54555473
5456− err = ynl_exec(ys, nlh, NULL);
5474+ err = ynl_exec(ys, nlh, &yrs);
54575475 if (err < 0)
54585476 return -1;
54595477
@@ -5556,6 +5574,7 @@ devlink_health_reporter_dump_clear_req_free(struct devlink_health_reporter_dump_ · 96 unmodified lines
55565574 int devlink_health_reporter_dump_clear(struct ynl_sock *ys,
55575575 struct devlink_health_reporter_dump_clear_req *req)
55585576 {
5577+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
55595578 struct nlmsghdr *nlh;
55605579 int err;
55615580
@@ -5571,7 +5590,7 @@ int devlink_health_reporter_dump_clear(struct ynl_sock *ys, · 9 unmodified lines
55715590 if (req->_present.health_reporter_name_len)
55725591 mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME, req->health_reporter_name);
55735592
5574− err = ynl_exec(ys, nlh, NULL);
5593+ err = ynl_exec(ys, nlh, &yrs);
55755594 if (err < 0)
55765595 return -1;
55775596
@@ -5592,6 +5611,7 @@ void devlink_flash_update_req_free(struct devlink_flash_update_req *req) · 14 unmodified lines
55925611 int devlink_flash_update(struct ynl_sock *ys,
55935612 struct devlink_flash_update_req *req)
55945613 {
5614+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
55955615 struct nlmsghdr *nlh;
55965616 int err;
55975617
@@ -5609,7 +5629,7 @@ int devlink_flash_update(struct ynl_sock *ys, · 11 unmodified lines
56095629 if (req->_present.flash_update_overwrite_mask)
56105630 mnl_attr_put(nlh, DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK, sizeof(struct nla_bitfield32), &req->flash_update_overwrite_mask);
56115631
5612− err = ynl_exec(ys, nlh, NULL);
5632+ err = ynl_exec(ys, nlh, &yrs);
56135633 if (err < 0)
56145634 return -1;
56155635
@@ -5780,6 +5800,7 @@ void devlink_trap_set_req_free(struct devlink_trap_set_req *req) · 164 unmodified lines
57805800
57815801 int devlink_trap_set(struct ynl_sock *ys, struct devlink_trap_set_req *req)
57825802 {
5803+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
57835804 struct nlmsghdr *nlh;
57845805 int err;
57855806
@@ -5795,7 +5816,7 @@ int devlink_trap_set(struct ynl_sock *ys, struct devlink_trap_set_req *req) · 9 unmodified lines
57955816 if (req->_present.trap_action)
57965817 mnl_attr_put_u8(nlh, DEVLINK_ATTR_TRAP_ACTION, req->trap_action);
57975818
5798− err = ynl_exec(ys, nlh, NULL);
5819+ err = ynl_exec(ys, nlh, &yrs);
57995820 if (err < 0)
58005821 return -1;
58015822
@@ -5968,6 +5989,7 @@ void devlink_trap_group_set_req_free(struct devlink_trap_group_set_req *req) · 166 unmodified lines
59685989 int devlink_trap_group_set(struct ynl_sock *ys,
59695990 struct devlink_trap_group_set_req *req)
59705991 {
5992+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
59715993 struct nlmsghdr *nlh;
59725994 int err;
59735995
@@ -5985,7 +6007,7 @@ int devlink_trap_group_set(struct ynl_sock *ys, · 11 unmodified lines
59856007 if (req->_present.trap_policer_id)
59866008 mnl_attr_put_u32(nlh, DEVLINK_ATTR_TRAP_POLICER_ID, req->trap_policer_id);
59876009
5988− err = ynl_exec(ys, nlh, NULL);
6010+ err = ynl_exec(ys, nlh, &yrs);
59896011 if (err < 0)
59906012 return -1;
59916013
@@ -6152,6 +6174,7 @@ devlink_trap_policer_set_req_free(struct devlink_trap_policer_set_req *req) · 160 unmodified lines
61526174 int devlink_trap_policer_set(struct ynl_sock *ys,
61536175 struct devlink_trap_policer_set_req *req)
61546176 {
6177+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
61556178 struct nlmsghdr *nlh;
61566179 int err;
61576180
@@ -6169,7 +6192,7 @@ int devlink_trap_policer_set(struct ynl_sock *ys, · 11 unmodified lines
61696192 if (req->_present.trap_policer_burst)
61706193 mnl_attr_put_u64(nlh, DEVLINK_ATTR_TRAP_POLICER_BURST, req->trap_policer_burst);
61716194
6172− err = ynl_exec(ys, nlh, NULL);
6195+ err = ynl_exec(ys, nlh, &yrs);
61736196 if (err < 0)
61746197 return -1;
61756198
@@ -6190,6 +6213,7 @@ devlink_health_reporter_test_req_free(struct devlink_health_reporter_test_req *r · 14 unmodified lines
61906213 int devlink_health_reporter_test(struct ynl_sock *ys,
61916214 struct devlink_health_reporter_test_req *req)
61926215 {
6216+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
61936217 struct nlmsghdr *nlh;
61946218 int err;
61956219
@@ -6205,7 +6229,7 @@ int devlink_health_reporter_test(struct ynl_sock *ys, · 9 unmodified lines
62056229 if (req->_present.health_reporter_name_len)
62066230 mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME, req->health_reporter_name);
62076231
6208− err = ynl_exec(ys, nlh, NULL);
6232+ err = ynl_exec(ys, nlh, &yrs);
62096233 if (err < 0)
62106234 return -1;
62116235
@@ -6384,6 +6408,7 @@ void devlink_rate_set_req_free(struct devlink_rate_set_req *req) · 172 unmodified lines
63846408
63856409 int devlink_rate_set(struct ynl_sock *ys, struct devlink_rate_set_req *req)
63866410 {
6411+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
63876412 struct nlmsghdr *nlh;
63886413 int err;
63896414
@@ -6407,7 +6432,7 @@ int devlink_rate_set(struct ynl_sock *ys, struct devlink_rate_set_req *req) · 17 unmodified lines
64076432 if (req->_present.rate_parent_node_name_len)
64086433 mnl_attr_put_strz(nlh, DEVLINK_ATTR_RATE_PARENT_NODE_NAME, req->rate_parent_node_name);
64096434
6410− err = ynl_exec(ys, nlh, NULL);
6435+ err = ynl_exec(ys, nlh, &yrs);
64116436 if (err < 0)
64126437 return -1;
64136438
@@ -6427,6 +6452,7 @@ void devlink_rate_new_req_free(struct devlink_rate_new_req *req) · 13 unmodified lines
64276452
64286453 int devlink_rate_new(struct ynl_sock *ys, struct devlink_rate_new_req *req)
64296454 {
6455+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
64306456 struct nlmsghdr *nlh;
64316457 int err;
64326458
@@ -6450,7 +6476,7 @@ int devlink_rate_new(struct ynl_sock *ys, struct devlink_rate_new_req *req) · 17 unmodified lines
64506476 if (req->_present.rate_parent_node_name_len)
64516477 mnl_attr_put_strz(nlh, DEVLINK_ATTR_RATE_PARENT_NODE_NAME, req->rate_parent_node_name);
64526478
6453− err = ynl_exec(ys, nlh, NULL);
6479+ err = ynl_exec(ys, nlh, &yrs);
64546480 if (err < 0)
64556481 return -1;
64566482
@@ -6469,6 +6495,7 @@ void devlink_rate_del_req_free(struct devlink_rate_del_req *req) · 12 unmodified lines
64696495
64706496 int devlink_rate_del(struct ynl_sock *ys, struct devlink_rate_del_req *req)
64716497 {
6498+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
64726499 struct nlmsghdr *nlh;
64736500 int err;
64746501
@@ -6482,7 +6509,7 @@ int devlink_rate_del(struct ynl_sock *ys, struct devlink_rate_del_req *req) · 7 unmodified lines
64826509 if (req->_present.rate_node_name_len)
64836510 mnl_attr_put_strz(nlh, DEVLINK_ATTR_RATE_NODE_NAME, req->rate_node_name);
64846511
6485− err = ynl_exec(ys, nlh, NULL);
6512+ err = ynl_exec(ys, nlh, &yrs);
64866513 if (err < 0)
64876514 return -1;
64886515
@@ -6645,6 +6672,7 @@ void devlink_linecard_set_req_free(struct devlink_linecard_set_req *req) · 156 unmodified lines
66456672 int devlink_linecard_set(struct ynl_sock *ys,
66466673 struct devlink_linecard_set_req *req)
66476674 {
6675+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
66486676 struct nlmsghdr *nlh;
66496677 int err;
66506678
@@ -6660,7 +6688,7 @@ int devlink_linecard_set(struct ynl_sock *ys, · 9 unmodified lines
66606688 if (req->_present.linecard_type_len)
66616689 mnl_attr_put_strz(nlh, DEVLINK_ATTR_LINECARD_TYPE, req->linecard_type);
66626690
6663− err = ynl_exec(ys, nlh, NULL);
6691+ err = ynl_exec(ys, nlh, &yrs);
66646692 if (err < 0)
66656693 return -1;
66666694
@@ -6810,6 +6838,7 @@ void devlink_selftests_run_req_free(struct devlink_selftests_run_req *req) · 143 unmodified lines
68106838 int devlink_selftests_run(struct ynl_sock *ys,
68116839 struct devlink_selftests_run_req *req)
68126840 {
6841+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
68136842 struct nlmsghdr *nlh;
68146843 int err;
68156844
@@ -6823,7 +6852,7 @@ int devlink_selftests_run(struct ynl_sock *ys, · 7 unmodified lines
68236852 if (req->_present.selftests)
68246853 devlink_dl_selftest_id_put(nlh, DEVLINK_ATTR_SELFTESTS, &req->selftests);
68256854
6826− err = ynl_exec(ys, nlh, NULL);
6855+ err = ynl_exec(ys, nlh, &yrs);
68276856 if (err < 0)
68286857 return -1;
68296858
tools/net/ynl/generated/ethtool-user.c+34−17
@@ -1843,6 +1843,7 @@ void ethtool_linkinfo_set_req_free(struct ethtool_linkinfo_set_req *req) · 1842 unmodified lines
18431843 int ethtool_linkinfo_set(struct ynl_sock *ys,
18441844 struct ethtool_linkinfo_set_req *req)
18451845 {
1846+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
18461847 struct nlmsghdr *nlh;
18471848 int err;
18481849
@@ -1862,7 +1863,7 @@ int ethtool_linkinfo_set(struct ynl_sock *ys, · 13 unmodified lines
18621863 if (req->_present.transceiver)
18631864 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKINFO_TRANSCEIVER, req->transceiver);
18641865
1865− err = ynl_exec(ys, nlh, NULL);
1866+ err = ynl_exec(ys, nlh, &yrs);
18661867 if (err < 0)
18671868 return -1;
18681869
@@ -2067,6 +2068,7 @@ void ethtool_linkmodes_set_req_free(struct ethtool_linkmodes_set_req *req) · 198 unmodified lines
20672068 int ethtool_linkmodes_set(struct ynl_sock *ys,
20682069 struct ethtool_linkmodes_set_req *req)
20692070 {
2071+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
20702072 struct nlmsghdr *nlh;
20712073 int err;
20722074
@@ -2094,7 +2096,7 @@ int ethtool_linkmodes_set(struct ynl_sock *ys, · 21 unmodified lines
20942096 if (req->_present.rate_matching)
20952097 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKMODES_RATE_MATCHING, req->rate_matching);
20962098
2097− err = ynl_exec(ys, nlh, NULL);
2099+ err = ynl_exec(ys, nlh, &yrs);
20982100 if (err < 0)
20992101 return -1;
21002102
@@ -2398,6 +2400,7 @@ void ethtool_debug_set_req_free(struct ethtool_debug_set_req *req) · 297 unmodified lines
23982400
23992401 int ethtool_debug_set(struct ynl_sock *ys, struct ethtool_debug_set_req *req)
24002402 {
2403+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
24012404 struct nlmsghdr *nlh;
24022405 int err;
24032406
@@ -2409,7 +2412,7 @@ int ethtool_debug_set(struct ynl_sock *ys, struct ethtool_debug_set_req *req) · 5 unmodified lines
24092412 if (req->_present.msgmask)
24102413 ethtool_bitset_put(nlh, ETHTOOL_A_DEBUG_MSGMASK, &req->msgmask);
24112414
2412− err = ynl_exec(ys, nlh, NULL);
2415+ err = ynl_exec(ys, nlh, &yrs);
24132416 if (err < 0)
24142417 return -1;
24152418
@@ -2577,6 +2580,7 @@ void ethtool_wol_set_req_free(struct ethtool_wol_set_req *req) · 161 unmodified lines
25772580
25782581 int ethtool_wol_set(struct ynl_sock *ys, struct ethtool_wol_set_req *req)
25792582 {
2583+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
25802584 struct nlmsghdr *nlh;
25812585 int err;
25822586
@@ -2590,7 +2594,7 @@ int ethtool_wol_set(struct ynl_sock *ys, struct ethtool_wol_set_req *req) · 7 unmodified lines
25902594 if (req->_present.sopass_len)
25912595 mnl_attr_put(nlh, ETHTOOL_A_WOL_SOPASS, req->_present.sopass_len, req->sopass);
25922596
2593− err = ynl_exec(ys, nlh, NULL);
2597+ err = ynl_exec(ys, nlh, &yrs);
25942598 if (err < 0)
25952599 return -1;
25962600
@@ -3045,6 +3049,7 @@ void ethtool_privflags_set_req_free(struct ethtool_privflags_set_req *req) · 448 unmodified lines
30453049 int ethtool_privflags_set(struct ynl_sock *ys,
30463050 struct ethtool_privflags_set_req *req)
30473051 {
3052+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
30483053 struct nlmsghdr *nlh;
30493054 int err;
30503055
@@ -3056,7 +3061,7 @@ int ethtool_privflags_set(struct ynl_sock *ys, · 5 unmodified lines
30563061 if (req->_present.flags)
30573062 ethtool_bitset_put(nlh, ETHTOOL_A_PRIVFLAGS_FLAGS, &req->flags);
30583063
3059− err = ynl_exec(ys, nlh, NULL);
3064+ err = ynl_exec(ys, nlh, &yrs);
30603065 if (err < 0)
30613066 return -1;
30623067
@@ -3273,6 +3278,7 @@ void ethtool_rings_set_req_free(struct ethtool_rings_set_req *req) · 210 unmodified lines
32733278
32743279 int ethtool_rings_set(struct ynl_sock *ys, struct ethtool_rings_set_req *req)
32753280 {
3281+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
32763282 struct nlmsghdr *nlh;
32773283 int err;
32783284
@@ -3312,7 +3318,7 @@ int ethtool_rings_set(struct ynl_sock *ys, struct ethtool_rings_set_req *req) · 33 unmodified lines
33123318 if (req->_present.tx_push_buf_len_max)
33133319 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX, req->tx_push_buf_len_max);
33143320
3315− err = ynl_exec(ys, nlh, NULL);
3321+ err = ynl_exec(ys, nlh, &yrs);
33163322 if (err < 0)
33173323 return -1;
33183324
@@ -3495,6 +3501,7 @@ void ethtool_channels_set_req_free(struct ethtool_channels_set_req *req) · 176 unmodified lines
34953501 int ethtool_channels_set(struct ynl_sock *ys,
34963502 struct ethtool_channels_set_req *req)
34973503 {
3504+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
34983505 struct nlmsghdr *nlh;
34993506 int err;
35003507
@@ -3520,7 +3527,7 @@ int ethtool_channels_set(struct ynl_sock *ys, · 19 unmodified lines
35203527 if (req->_present.combined_count)
35213528 mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_COMBINED_COUNT, req->combined_count);
35223529
3523− err = ynl_exec(ys, nlh, NULL);
3530+ err = ynl_exec(ys, nlh, &yrs);
35243531 if (err < 0)
35253532 return -1;
35263533
@@ -3798,6 +3805,7 @@ void ethtool_coalesce_set_req_free(struct ethtool_coalesce_set_req *req) · 271 unmodified lines
37983805 int ethtool_coalesce_set(struct ynl_sock *ys,
37993806 struct ethtool_coalesce_set_req *req)
38003807 {
3808+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
38013809 struct nlmsghdr *nlh;
38023810 int err;
38033811
@@ -3861,7 +3869,7 @@ int ethtool_coalesce_set(struct ynl_sock *ys, · 57 unmodified lines
38613869 if (req->_present.tx_aggr_time_usecs)
38623870 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS, req->tx_aggr_time_usecs);
38633871
3864− err = ynl_exec(ys, nlh, NULL);
3872+ err = ynl_exec(ys, nlh, &yrs);
38653873 if (err < 0)
38663874 return -1;
38673875
@@ -4036,6 +4044,7 @@ void ethtool_pause_set_req_free(struct ethtool_pause_set_req *req) · 168 unmodified lines
40364044
40374045 int ethtool_pause_set(struct ynl_sock *ys, struct ethtool_pause_set_req *req)
40384046 {
4047+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
40394048 struct nlmsghdr *nlh;
40404049 int err;
40414050
@@ -4055,7 +4064,7 @@ int ethtool_pause_set(struct ynl_sock *ys, struct ethtool_pause_set_req *req) · 13 unmodified lines
40554064 if (req->_present.stats_src)
40564065 mnl_attr_put_u32(nlh, ETHTOOL_A_PAUSE_STATS_SRC, req->stats_src);
40574066
4058− err = ynl_exec(ys, nlh, NULL);
4067+ err = ynl_exec(ys, nlh, &yrs);
40594068 if (err < 0)
40604069 return -1;
40614070
@@ -4242,6 +4251,7 @@ void ethtool_eee_set_req_free(struct ethtool_eee_set_req *req) · 180 unmodified lines
42424251
42434252 int ethtool_eee_set(struct ynl_sock *ys, struct ethtool_eee_set_req *req)
42444253 {
4254+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
42454255 struct nlmsghdr *nlh;
42464256 int err;
42474257
@@ -4263,7 +4273,7 @@ int ethtool_eee_set(struct ynl_sock *ys, struct ethtool_eee_set_req *req) · 15 unmodified lines
42634273 if (req->_present.tx_lpi_timer)
42644274 mnl_attr_put_u32(nlh, ETHTOOL_A_EEE_TX_LPI_TIMER, req->tx_lpi_timer);
42654275
4266− err = ynl_exec(ys, nlh, NULL);
4276+ err = ynl_exec(ys, nlh, &yrs);
42674277 if (err < 0)
42684278 return -1;
42694279
@@ -4437,6 +4447,7 @@ void ethtool_cable_test_act_req_free(struct ethtool_cable_test_act_req *req) · 167 unmodified lines
44374447 int ethtool_cable_test_act(struct ynl_sock *ys,
44384448 struct ethtool_cable_test_act_req *req)
44394449 {
4450+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
44404451 struct nlmsghdr *nlh;
44414452 int err;
44424453
@@ -4446,7 +4457,7 @@ int ethtool_cable_test_act(struct ynl_sock *ys, · 3 unmodified lines
44464457 if (req->_present.header)
44474458 ethtool_header_put(nlh, ETHTOOL_A_CABLE_TEST_HEADER, &req->header);
44484459
4449− err = ynl_exec(ys, nlh, NULL);
4460+ err = ynl_exec(ys, nlh, &yrs);
44504461 if (err < 0)
44514462 return -1;
44524463
@@ -4465,6 +4476,7 @@ ethtool_cable_test_tdr_act_req_free(struct ethtool_cable_test_tdr_act_req *req) · 12 unmodified lines
44654476 int ethtool_cable_test_tdr_act(struct ynl_sock *ys,
44664477 struct ethtool_cable_test_tdr_act_req *req)
44674478 {
4479+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
44684480 struct nlmsghdr *nlh;
44694481 int err;
44704482
@@ -4474,7 +4486,7 @@ int ethtool_cable_test_tdr_act(struct ynl_sock *ys, · 3 unmodified lines
44744486 if (req->_present.header)
44754487 ethtool_header_put(nlh, ETHTOOL_A_CABLE_TEST_TDR_HEADER, &req->header);
44764488
4477− err = ynl_exec(ys, nlh, NULL);
4489+ err = ynl_exec(ys, nlh, &yrs);
44784490 if (err < 0)
44794491 return -1;
44804492
@@ -4782,6 +4794,7 @@ void ethtool_fec_set_req_free(struct ethtool_fec_set_req *req) · 301 unmodified lines
47824794
47834795 int ethtool_fec_set(struct ynl_sock *ys, struct ethtool_fec_set_req *req)
47844796 {
4797+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
47854798 struct nlmsghdr *nlh;
47864799 int err;
47874800
@@ -4799,7 +4812,7 @@ int ethtool_fec_set(struct ynl_sock *ys, struct ethtool_fec_set_req *req) · 11 unmodified lines
47994812 if (req->_present.stats)
48004813 ethtool_fec_stat_put(nlh, ETHTOOL_A_FEC_STATS, &req->stats);
48014814
4802− err = ynl_exec(ys, nlh, NULL);
4815+ err = ynl_exec(ys, nlh, &yrs);
48034816 if (err < 0)
48044817 return -1;
48054818
@@ -5235,6 +5248,7 @@ void ethtool_module_set_req_free(struct ethtool_module_set_req *req) · 429 unmodified lines
52355248
52365249 int ethtool_module_set(struct ynl_sock *ys, struct ethtool_module_set_req *req)
52375250 {
5251+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
52385252 struct nlmsghdr *nlh;
52395253 int err;
52405254
@@ -5248,7 +5262,7 @@ int ethtool_module_set(struct ynl_sock *ys, struct ethtool_module_set_req *req) · 7 unmodified lines
52485262 if (req->_present.power_mode)
52495263 mnl_attr_put_u8(nlh, ETHTOOL_A_MODULE_POWER_MODE, req->power_mode);
52505264
5251− err = ynl_exec(ys, nlh, NULL);
5265+ err = ynl_exec(ys, nlh, &yrs);
52525266 if (err < 0)
52535267 return -1;
52545268
@@ -5397,6 +5411,7 @@ void ethtool_pse_set_req_free(struct ethtool_pse_set_req *req) · 142 unmodified lines
53975411
53985412 int ethtool_pse_set(struct ynl_sock *ys, struct ethtool_pse_set_req *req)
53995413 {
5414+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
54005415 struct nlmsghdr *nlh;
54015416 int err;
54025417
@@ -5412,7 +5427,7 @@ int ethtool_pse_set(struct ynl_sock *ys, struct ethtool_pse_set_req *req) · 9 unmodified lines
54125427 if (req->_present.pw_d_status)
54135428 mnl_attr_put_u32(nlh, ETHTOOL_A_PODL_PSE_PW_D_STATUS, req->pw_d_status);
54145429
5415− err = ynl_exec(ys, nlh, NULL);
5430+ err = ynl_exec(ys, nlh, &yrs);
54165431 if (err < 0)
54175432 return -1;
54185433
@@ -5746,6 +5761,7 @@ void ethtool_plca_set_cfg_req_free(struct ethtool_plca_set_cfg_req *req) · 327 unmodified lines
57465761 int ethtool_plca_set_cfg(struct ynl_sock *ys,
57475762 struct ethtool_plca_set_cfg_req *req)
57485763 {
5764+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
57495765 struct nlmsghdr *nlh;
57505766 int err;
57515767
@@ -5771,7 +5787,7 @@ int ethtool_plca_set_cfg(struct ynl_sock *ys, · 19 unmodified lines
57715787 if (req->_present.burst_tmr)
57725788 mnl_attr_put_u32(nlh, ETHTOOL_A_PLCA_BURST_TMR, req->burst_tmr);
57735789
5774− err = ynl_exec(ys, nlh, NULL);
5790+ err = ynl_exec(ys, nlh, &yrs);
57755791 if (err < 0)
57765792 return -1;
57775793
@@ -6124,6 +6140,7 @@ void ethtool_mm_set_req_free(struct ethtool_mm_set_req *req) · 346 unmodified lines
61246140
61256141 int ethtool_mm_set(struct ynl_sock *ys, struct ethtool_mm_set_req *req)
61266142 {
6143+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
61276144 struct nlmsghdr *nlh;
61286145 int err;
61296146
@@ -6143,7 +6160,7 @@ int ethtool_mm_set(struct ynl_sock *ys, struct ethtool_mm_set_req *req) · 13 unmodified lines
61436160 if (req->_present.tx_min_frag_size)
61446161 mnl_attr_put_u32(nlh, ETHTOOL_A_MM_TX_MIN_FRAG_SIZE, req->tx_min_frag_size);
61456162
6146− err = ynl_exec(ys, nlh, NULL);
6163+ err = ynl_exec(ys, nlh, &yrs);
61476164 if (err < 0)
61486165 return -1;
61496166
tools/net/ynl/generated/fou-user.c+4−2
@@ -72,6 +72,7 @@ void fou_add_req_free(struct fou_add_req *req) · 71 unmodified lines
7272
7373 int fou_add(struct ynl_sock *ys, struct fou_add_req *req)
7474 {
75+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
7576 struct nlmsghdr *nlh;
7677 int err;
7778
@@ -99,7 +100,7 @@ int fou_add(struct ynl_sock *ys, struct fou_add_req *req) · 21 unmodified lines
99100 if (req->_present.ifindex)
100101 mnl_attr_put_u32(nlh, FOU_ATTR_IFINDEX, req->ifindex);
101102
102− err = ynl_exec(ys, nlh, NULL);
103+ err = ynl_exec(ys, nlh, &yrs);
103104 if (err < 0)
104105 return -1;
105106
@@ -117,6 +118,7 @@ void fou_del_req_free(struct fou_del_req *req) · 11 unmodified lines
117118
118119 int fou_del(struct ynl_sock *ys, struct fou_del_req *req)
119120 {
121+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
120122 struct nlmsghdr *nlh;
121123 int err;
122124
@@ -140,7 +142,7 @@ int fou_del(struct ynl_sock *ys, struct fou_del_req *req) · 17 unmodified lines
140142 if (req->_present.peer_v6_len)
141143 mnl_attr_put(nlh, FOU_ATTR_PEER_V6, req->_present.peer_v6_len, req->peer_v6);
142144
143− err = ynl_exec(ys, nlh, NULL);
145+ err = ynl_exec(ys, nlh, &yrs);
144146 if (err < 0)
145147 return -1;
146148
tools/net/ynl/generated/handshake-user.c+2−1
@@ -295,6 +295,7 @@ void handshake_done_req_free(struct handshake_done_req *req) · 294 unmodified lines
295295
296296 int handshake_done(struct ynl_sock *ys, struct handshake_done_req *req)
297297 {
298+ struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
298299 struct nlmsghdr *nlh;
299300 int err;
300301
@@ -308,7 +309,7 @@ int handshake_done(struct ynl_sock *ys, struct handshake_done_req *req) · 7 unmodified lines
308309 for (unsigned int i = 0; i < req->n_remote_auth; i++)
309310 mnl_attr_put_u32(nlh, HANDSHAKE_A_DONE_REMOTE_AUTH, req->remote_auth[i]);
310311
311− err = ynl_exec(ys, nlh, NULL);
312+ err = ynl_exec(ys, nlh, &yrs);
312313 if (err < 0)
313314 return -1;
314315
tools/net/ynl/ynl-gen-c.py+4−6
@@ -1715,14 +1715,14 @@ def print_req(ri): · 1714 unmodified lines
17151715 ret_ok = '0'
17161716 ret_err = '-1'
17171717 direction = "request"
1718− local_vars = ['struct nlmsghdr *nlh;',
1718+ local_vars = ['struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };',
1719+ 'struct nlmsghdr *nlh;',
17191720 'int err;']
17201721
17211722 if 'reply' in ri.op[ri.op_mode]:
17221723 ret_ok = 'rsp'
17231724 ret_err = 'NULL'
1724− local_vars += [f'{type_name(ri, rdir(direction))} *rsp;',
1725− 'struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };']
1725+ local_vars += [f'{type_name(ri, rdir(direction))} *rsp;']
17261726
17271727 print_prototype(ri, direction, terminate=False)
17281728 ri.cw.block_start()
@@ -1738,7 +1738,6 @@ def print_req(ri): · 9 unmodified lines
17381738 attr.attr_put(ri, "req")
17391739 ri.cw.nl()
17401740
1741− parse_arg = "NULL"
17421741 if 'reply' in ri.op[ri.op_mode]:
17431742 ri.cw.p('rsp = calloc(1, sizeof(*rsp));')
17441743 ri.cw.p('yrs.yarg.data = rsp;')
@@ -1748,8 +1747,7 @@ def print_req(ri): · 3 unmodified lines
17481747 else:
17491748 ri.cw.p(f'yrs.rsp_cmd = {ri.op.rsp_value};')
17501749 ri.cw.nl()
1751− parse_arg = '&yrs'
1752− ri.cw.p(f"err = ynl_exec(ys, nlh, {parse_arg});")
1750+ ri.cw.p("err = ynl_exec(ys, nlh, &yrs);")
17531751 ri.cw.p('if (err < 0)')
17541752 if 'reply' in ri.op[ri.op_mode]:
17551753 ri.cw.p('goto err_free;')
tools/power/pm-graph/sleepgraph.py+1−1
@@ -4151,7 +4151,7 @@ def parseKernelLog(data): · 4150 unmodified lines
41514151 elif(re.match('Enabling non-boot CPUs .*', msg)):
41524152 # start of first cpu resume
41534153 cpu_start = ktime
4154− elif(re.match('smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg)) \
4154+ elif(re.match('smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg) \
41554155 or re.match('psci: CPU(?P<cpu>[0-9]*) killed.*', msg)):
41564156 # end of a cpu suspend, start of the next
41574157 m = re.match('smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg)
tools/testing/selftests/arm64/fp/za-fork.c+1−1
@@ -85,7 +85,7 @@ int main(int argc, char **argv) · 84 unmodified lines
8585 */
8686 ret = open("/proc/sys/abi/sme_default_vector_length", O_RDONLY, 0);
8787 if (ret >= 0) {
88− ksft_test_result(fork_test(), "fork_test");
88+ ksft_test_result(fork_test(), "fork_test\n");
8989
9090 } else {
9191 ksft_print_msg("SME not supported\n");
tools/testing/selftests/bpf/prog_tests/sockmap_listen.c+40−11
@@ -1337,7 +1337,8 @@ static void test_redir(struct test_sockmap_listen *skel, struct bpf_map *map, · 1336 unmodified lines
13371337 }
13381338
13391339 static void pairs_redir_to_connected(int cli0, int peer0, int cli1, int peer1,
1340− int sock_mapfd, int verd_mapfd, enum redir_mode mode)
1340+ int sock_mapfd, int nop_mapfd,
1341+ int verd_mapfd, enum redir_mode mode)
13411342 {
13421343 const char *log_prefix = redir_mode_str(mode);
13431344 unsigned int pass;
@@ -1351,6 +1352,12 @@ static void pairs_redir_to_connected(int cli0, int peer0, int cli1, int peer1, · 7 unmodified lines
13511352 if (err)
13521353 return;
13531354
1355+ if (nop_mapfd >= 0) {
1356+ err = add_to_sockmap(nop_mapfd, cli0, cli1);
1357+ if (err)
1358+ return;
1359+ }
1360+
13541361 n = write(cli1, "a", 1);
13551362 if (n < 0)
13561363 FAIL_ERRNO("%s: write", log_prefix);
@@ -1387,7 +1394,7 @@ static void unix_redir_to_connected(int sotype, int sock_mapfd, · 30 unmodified lines
13871394 goto close0;
13881395 c1 = sfd[0], p1 = sfd[1];
13891396
1390− pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, verd_mapfd, mode);
1397+ pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, -1, verd_mapfd, mode);
13911398
13921399 xclose(c1);
13931400 xclose(p1);
@@ -1677,7 +1684,7 @@ static void udp_redir_to_connected(int family, int sock_mapfd, int verd_mapfd, · 283 unmodified lines
16771684 if (err)
16781685 goto close_cli0;
16791686
1680− pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, verd_mapfd, mode);
1687+ pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, -1, verd_mapfd, mode);
16811688
16821689 xclose(c1);
16831690 xclose(p1);
@@ -1735,7 +1742,7 @@ static void inet_unix_redir_to_connected(int family, int type, int sock_mapfd, · 51 unmodified lines
17351742 if (err)
17361743 goto close;
17371744
1738− pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, verd_mapfd, mode);
1745+ pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, -1, verd_mapfd, mode);
17391746
17401747 xclose(c1);
17411748 xclose(p1);
@@ -1770,8 +1777,10 @@ static void inet_unix_skb_redir_to_connected(struct test_sockmap_listen *skel, · 28 unmodified lines
17701777 xbpf_prog_detach2(verdict, sock_map, BPF_SK_SKB_VERDICT);
17711778 }
17721779
1773−static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd,
1774− int verd_mapfd, enum redir_mode mode)
1780+static void unix_inet_redir_to_connected(int family, int type,
1781+ int sock_mapfd, int nop_mapfd,
1782+ int verd_mapfd,
1783+ enum redir_mode mode)
17751784 {
17761785 int c0, c1, p0, p1;
17771786 int sfd[2];
@@ -1785,7 +1794,8 @@ static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd, · 7 unmodified lines
17851794 goto close_cli0;
17861795 c1 = sfd[0], p1 = sfd[1];
17871796
1788− pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, verd_mapfd, mode);
1797+ pairs_redir_to_connected(c0, p0, c1, p1,
1798+ sock_mapfd, nop_mapfd, verd_mapfd, mode);
17891799
17901800 xclose(c1);
17911801 xclose(p1);
@@ -1799,6 +1809,7 @@ static void unix_inet_skb_redir_to_connected(struct test_sockmap_listen *skel, · 7 unmodified lines
17991809 struct bpf_map *inner_map, int family)
18001810 {
18011811 int verdict = bpf_program__fd(skel->progs.prog_skb_verdict);
1812+ int nop_map = bpf_map__fd(skel->maps.nop_map);
18021813 int verdict_map = bpf_map__fd(skel->maps.verdict_map);
18031814 int sock_map = bpf_map__fd(inner_map);
18041815 int err;
@@ -1808,14 +1819,32 @@ static void unix_inet_skb_redir_to_connected(struct test_sockmap_listen *skel, · 3 unmodified lines
18081819 return;
18091820
18101821 skel->bss->test_ingress = false;
1811− unix_inet_redir_to_connected(family, SOCK_DGRAM, sock_map, verdict_map,
1822+ unix_inet_redir_to_connected(family, SOCK_DGRAM,
1823+ sock_map, -1, verdict_map,
18121824 REDIR_EGRESS);
1813− unix_inet_redir_to_connected(family, SOCK_STREAM, sock_map, verdict_map,
1825+ unix_inet_redir_to_connected(family, SOCK_DGRAM,
1826+ sock_map, -1, verdict_map,
1827+ REDIR_EGRESS);
1828+
1829+ unix_inet_redir_to_connected(family, SOCK_DGRAM,
1830+ sock_map, nop_map, verdict_map,
1831+ REDIR_EGRESS);
1832+ unix_inet_redir_to_connected(family, SOCK_STREAM,
1833+ sock_map, nop_map, verdict_map,
18141834 REDIR_EGRESS);
18151835 skel->bss->test_ingress = true;
1816− unix_inet_redir_to_connected(family, SOCK_DGRAM, sock_map, verdict_map,
1836+ unix_inet_redir_to_connected(family, SOCK_DGRAM,
1837+ sock_map, -1, verdict_map,
1838+ REDIR_INGRESS);
1839+ unix_inet_redir_to_connected(family, SOCK_STREAM,
1840+ sock_map, -1, verdict_map,
1841+ REDIR_INGRESS);
1842+
1843+ unix_inet_redir_to_connected(family, SOCK_DGRAM,
1844+ sock_map, nop_map, verdict_map,
18171845 REDIR_INGRESS);
1818− unix_inet_redir_to_connected(family, SOCK_STREAM, sock_map, verdict_map,
1846+ unix_inet_redir_to_connected(family, SOCK_STREAM,
1847+ sock_map, nop_map, verdict_map,
18191848 REDIR_INGRESS);
18201849
18211850 xbpf_prog_detach2(verdict, sock_map, BPF_SK_SKB_VERDICT);
tools/testing/selftests/bpf/progs/test_sockmap_listen.c+7−0
@@ -14,6 +14,13 @@ struct { · 13 unmodified lines
1414 __type(value, __u64);
1515 } sock_map SEC(".maps");
1616
17+struct {
18+ __uint(type, BPF_MAP_TYPE_SOCKMAP);
19+ __uint(max_entries, 2);
20+ __type(key, __u32);
21+ __type(value, __u64);
22+} nop_map SEC(".maps");
23+
1724 struct {
1825 __uint(type, BPF_MAP_TYPE_SOCKHASH);
1926 __uint(max_entries, 2);
tools/testing/selftests/net/af_unix/diag_uid.c+0−1
@@ -148,7 +148,6 @@ void receive_response(struct __test_metadata *_metadata, · 147 unmodified lines
148148 .msg_iov = &iov,
149149 .msg_iovlen = 1
150150 };
151− struct unix_diag_req *udr;
152151 struct nlmsghdr *nlh;
153152 int ret;
154153
tools/testing/selftests/net/cmsg_sender.c+1−1
@@ -428,9 +428,9 @@ int main(int argc, char *argv[]) · 427 unmodified lines
428428 {
429429 struct addrinfo hints, *ai;
430430 struct iovec iov[1];
431+ unsigned char *buf;
431432 struct msghdr msg;
432433 char cbuf[1024];
433− char *buf;
434434 int err;
435435 int fd;
436436 int i;
tools/testing/selftests/net/ipsec.c+2−2
@@ -2263,7 +2263,7 @@ static int check_results(void) · 2262 unmodified lines
22632263
22642264 int main(int argc, char **argv)
22652265 {
2266− unsigned int nr_process = 1;
2266+ long nr_process = 1;
22672267 int route_sock = -1, ret = KSFT_SKIP;
22682268 int test_desc_fd[2];
22692269 uint32_t route_seq;
@@ -2284,7 +2284,7 @@ int main(int argc, char **argv) · 14 unmodified lines
22842284 exit_usage(argv);
22852285 }
22862286
2287− if (nr_process > MAX_PROCESSES || !nr_process) {
2287+ if (nr_process > MAX_PROCESSES || nr_process < 1) {
22882288 printk("nr_process should be between [1; %u]",
22892289 MAX_PROCESSES);
22902290 exit_usage(argv);
tools/testing/selftests/net/mptcp/mptcp_connect.c+4−7
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818
1919 #include <sys/ioctl.h>
2020 #include <sys/poll.h>
21+#include <sys/random.h>
2122 #include <sys/sendfile.h>
2223 #include <sys/stat.h>
2324 #include <sys/socket.h>
@@ -1125,15 +1126,11 @@ again: · 1101 unmodified lines
11251126
11261127 static void init_rng(void)
11271128 {
1128− int fd = open("/dev/urandom", O_RDONLY);
11291129 unsigned int foo;
11301130
1131− if (fd > 0) {
1132− int ret = read(fd, &foo, sizeof(foo));
1133−
1134− if (ret < 0)
1135− srand(fd + foo);
1136− close(fd);
1131+ if (getrandom(&foo, sizeof(foo), 0) == -1) {
1132+ perror("getrandom");
1133+ exit(1);
11371134 }
11381135
11391136 srand(foo);
tools/testing/selftests/net/mptcp/mptcp_inq.c+4−7
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818 #include <time.h>
1919
2020 #include <sys/ioctl.h>
21+#include <sys/random.h>
2122 #include <sys/socket.h>
2223 #include <sys/types.h>
2324 #include <sys/wait.h>
@@ -519,15 +520,11 @@ static int client(int unixfd) · 495 unmodified lines
519520
520521 static void init_rng(void)
521522 {
522− int fd = open("/dev/urandom", O_RDONLY);
523523 unsigned int foo;
524524
525− if (fd > 0) {
526− int ret = read(fd, &foo, sizeof(foo));
527−
528− if (ret < 0)
529− srand(fd + foo);
530− close(fd);
525+ if (getrandom(&foo, sizeof(foo), 0) == -1) {
526+ perror("getrandom");
527+ exit(1);
531528 }
532529
533530 srand(foo);

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