Unified · Split
| @@ -108,6 +108,10 @@ Jason Gunthorpe <jgg@ziepe.ca> <jgg@mellanox.com> · 107 unmodified lines | ||
| 108 | 108 | Jason Gunthorpe <jgg@ziepe.ca> <jgunthorpe@obsidianresearch.com> |
| 109 | 109 | Javi Merino <javi.merino@kernel.org> <javi.merino@arm.com> |
| 110 | 110 | <javier@osg.samsung.com> <javier.martinez@collabora.co.uk> |
| 111 | +Jayachandran C <c.jayachandran@gmail.com> <jayachandranc@netlogicmicro.com> | |
| 112 | +Jayachandran C <c.jayachandran@gmail.com> <jchandra@broadcom.com> | |
| 113 | +Jayachandran C <c.jayachandran@gmail.com> <jchandra@digeo.com> | |
| 114 | +Jayachandran C <c.jayachandran@gmail.com> <jnair@caviumnetworks.com> | |
| 111 | 115 | Jean Tourrilhes <jt@hpl.hp.com> |
| 112 | 116 | <jean-philippe@linaro.org> <jean-philippe.brucker@arm.com> |
| 113 | 117 | Jeff Garzik <jgarzik@pretzel.yyz.us> |
| @@ -91,6 +91,11 @@ stable kernels. · 90 unmodified lines | ||
| 91 | 91 | | ARM | MMU-500 | #841119,826419 | N/A | |
| 92 | 92 | +----------------+-----------------+-----------------+-----------------------------+ |
| 93 | 93 | +----------------+-----------------+-----------------+-----------------------------+ |
| 94 | +| Broadcom | Brahma-B53 | N/A | ARM64_ERRATUM_845719 | | |
| 95 | ++----------------+-----------------+-----------------+-----------------------------+ | |
| 96 | +| Broadcom | Brahma-B53 | N/A | ARM64_ERRATUM_843419 | | |
| 97 | ++----------------+-----------------+-----------------+-----------------------------+ | |
| 98 | ++----------------+-----------------+-----------------+-----------------------------+ | |
| 94 | 99 | | Cavium | ThunderX ITS | #22375,24313 | CAVIUM_ERRATUM_22375 | |
| 95 | 100 | +----------------+-----------------+-----------------+-----------------------------+ |
| 96 | 101 | | Cavium | ThunderX ITS | #23144 | CAVIUM_ERRATUM_23144 | |
| @@ -126,7 +131,7 @@ stable kernels. · 29 unmodified lines | ||
| 126 | 131 | +----------------+-----------------+-----------------+-----------------------------+ |
| 127 | 132 | | Qualcomm Tech. | Kryo/Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 | |
| 128 | 133 | +----------------+-----------------+-----------------+-----------------------------+ |
| 129 | −| Qualcomm Tech. | Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 | | |
| 134 | +| Qualcomm Tech. | Kryo/Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 | | |
| 130 | 135 | +----------------+-----------------+-----------------+-----------------------------+ |
| 131 | 136 | | Qualcomm Tech. | QDF2400 ITS | E0065 | QCOM_QDF2400_ERRATUM_0065 | |
| 132 | 137 | +----------------+-----------------+-----------------+-----------------------------+ |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | |
| 3 | −============================================================== | |
| 4 | −Linux* Base Driver for the Intel(R) PRO/100 Family of Adapters | |
| 5 | −============================================================== | |
| 3 | +============================================================= | |
| 4 | +Linux Base Driver for the Intel(R) PRO/100 Family of Adapters | |
| 5 | +============================================================= | |
| 6 | 6 | |
| 7 | 7 | June 1, 2018 |
| 8 | 8 | |
| @@ -21,7 +21,7 @@ Contents · 12 unmodified lines | ||
| 21 | 21 | In This Release |
| 22 | 22 | =============== |
| 23 | 23 | |
| 24 | −This file describes the Linux* Base Driver for the Intel(R) PRO/100 Family of | |
| 24 | +This file describes the Linux Base Driver for the Intel(R) PRO/100 Family of | |
| 25 | 25 | Adapters. This driver includes support for Itanium(R)2-based systems. |
| 26 | 26 | |
| 27 | 27 | For questions related to hardware requirements, refer to the documentation |
| @@ -138,9 +138,9 @@ version 1.6 or later is required for this functionality. · 110 unmodified lines | ||
| 138 | 138 | The latest release of ethtool can be found from |
| 139 | 139 | https://www.kernel.org/pub/software/network/ethtool/ |
| 140 | 140 | |
| 141 | −Enabling Wake on LAN* (WoL) | |
| 142 | −--------------------------- | |
| 143 | −WoL is provided through the ethtool* utility. For instructions on | |
| 141 | +Enabling Wake on LAN (WoL) | |
| 142 | +-------------------------- | |
| 143 | +WoL is provided through the ethtool utility. For instructions on | |
| 144 | 144 | enabling WoL with ethtool, refer to the ethtool man page. WoL will be |
| 145 | 145 | enabled on the system during the next shut down or reboot. For this |
| 146 | 146 | driver version, in order to enable WoL, the e100 driver must be loaded |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | |
| 3 | −=========================================================== | |
| 4 | −Linux* Base Driver for Intel(R) Ethernet Network Connection | |
| 5 | −=========================================================== | |
| 3 | +========================================================== | |
| 4 | +Linux Base Driver for Intel(R) Ethernet Network Connection | |
| 5 | +========================================================== | |
| 6 | 6 | |
| 7 | 7 | Intel Gigabit Linux driver. |
| 8 | 8 | Copyright(c) 1999 - 2013 Intel Corporation. |
| @@ -438,10 +438,10 @@ ethtool · 429 unmodified lines | ||
| 438 | 438 | The latest release of ethtool can be found from |
| 439 | 439 | https://www.kernel.org/pub/software/network/ethtool/ |
| 440 | 440 | |
| 441 | −Enabling Wake on LAN* (WoL) | |
| 442 | −--------------------------- | |
| 441 | +Enabling Wake on LAN (WoL) | |
| 442 | +-------------------------- | |
| 443 | 443 | |
| 444 | − WoL is configured through the ethtool* utility. | |
| 444 | + WoL is configured through the ethtool utility. | |
| 445 | 445 | |
| 446 | 446 | WoL will be enabled on the system during the next shut down or reboot. |
| 447 | 447 | For this driver version, in order to enable WoL, the e1000 driver must be |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | |
| 3 | −====================================================== | |
| 4 | −Linux* Driver for Intel(R) Ethernet Network Connection | |
| 5 | −====================================================== | |
| 3 | +===================================================== | |
| 4 | +Linux Driver for Intel(R) Ethernet Network Connection | |
| 5 | +===================================================== | |
| 6 | 6 | |
| 7 | 7 | Intel Gigabit Linux driver. |
| 8 | 8 | Copyright(c) 2008-2018 Intel Corporation. |
| @@ -338,7 +338,7 @@ and higher cannot be forced. Use the autonegotiation advertising setting to · 329 unmodified lines | ||
| 338 | 338 | manually set devices for 1 Gbps and higher. |
| 339 | 339 | |
| 340 | 340 | Speed, duplex, and autonegotiation advertising are configured through the |
| 341 | −ethtool* utility. | |
| 341 | +ethtool utility. | |
| 342 | 342 | |
| 343 | 343 | Caution: Only experienced network administrators should force speed and duplex |
| 344 | 344 | or change autonegotiation advertising manually. The settings at the switch must |
| @@ -351,9 +351,9 @@ will not attempt to auto-negotiate with its link partner since those adapters · 6 unmodified lines | ||
| 351 | 351 | operate only in full duplex and only at their native speed. |
| 352 | 352 | |
| 353 | 353 | |
| 354 | −Enabling Wake on LAN* (WoL) | |
| 355 | −--------------------------- | |
| 356 | −WoL is configured through the ethtool* utility. | |
| 354 | +Enabling Wake on LAN (WoL) | |
| 355 | +-------------------------- | |
| 356 | +WoL is configured through the ethtool utility. | |
| 357 | 357 | |
| 358 | 358 | WoL will be enabled on the system during the next shut down or reboot. For |
| 359 | 359 | this driver version, in order to enable WoL, the e1000e driver must be loaded |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | |
| 3 | −============================================================== | |
| 4 | −Linux* Base Driver for Intel(R) Ethernet Multi-host Controller | |
| 5 | −============================================================== | |
| 3 | +============================================================= | |
| 4 | +Linux Base Driver for Intel(R) Ethernet Multi-host Controller | |
| 5 | +============================================================= | |
| 6 | 6 | |
| 7 | 7 | August 20, 2018 |
| 8 | 8 | Copyright(c) 2015-2018 Intel Corporation. |
| @@ -120,8 +120,8 @@ rx-flow-hash tcp4|udp4|ah4|esp4|sctp4|tcp6|udp6|ah6|esp6|sctp6 m|v|t|s|d|f|n|r · 111 unmodified lines | ||
| 120 | 120 | Known Issues/Troubleshooting |
| 121 | 121 | ============================ |
| 122 | 122 | |
| 123 | −Enabling SR-IOV in a 64-bit Microsoft* Windows Server* 2012/R2 guest OS under Linux KVM | |
| 124 | −--------------------------------------------------------------------------------------- | |
| 123 | +Enabling SR-IOV in a 64-bit Microsoft Windows Server 2012/R2 guest OS under Linux KVM | |
| 124 | +------------------------------------------------------------------------------------- | |
| 125 | 125 | KVM Hypervisor/VMM supports direct assignment of a PCIe device to a VM. This |
| 126 | 126 | includes traditional PCIe devices, as well as SR-IOV-capable devices based on |
| 127 | 127 | the Intel Ethernet Controller XL710. |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | |
| 3 | −================================================================== | |
| 4 | −Linux* Base Driver for the Intel(R) Ethernet Controller 700 Series | |
| 5 | −================================================================== | |
| 3 | +================================================================= | |
| 4 | +Linux Base Driver for the Intel(R) Ethernet Controller 700 Series | |
| 5 | +================================================================= | |
| 6 | 6 | |
| 7 | 7 | Intel 40 Gigabit Linux driver. |
| 8 | 8 | Copyright(c) 1999-2018 Intel Corporation. |
| @@ -384,7 +384,7 @@ NOTE: You cannot set the speed for devices based on the Intel(R) Ethernet · 375 unmodified lines | ||
| 384 | 384 | Network Adapter XXV710 based devices. |
| 385 | 385 | |
| 386 | 386 | Speed, duplex, and autonegotiation advertising are configured through the |
| 387 | −ethtool* utility. | |
| 387 | +ethtool utility. | |
| 388 | 388 | |
| 389 | 389 | Caution: Only experienced network administrators should force speed and duplex |
| 390 | 390 | or change autonegotiation advertising manually. The settings at the switch must |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | |
| 3 | −================================================================== | |
| 4 | −Linux* Base Driver for Intel(R) Ethernet Adaptive Virtual Function | |
| 5 | −================================================================== | |
| 3 | +================================================================= | |
| 4 | +Linux Base Driver for Intel(R) Ethernet Adaptive Virtual Function | |
| 5 | +================================================================= | |
| 6 | 6 | |
| 7 | 7 | Intel Ethernet Adaptive Virtual Function Linux driver. |
| 8 | 8 | Copyright(c) 2013-2018 Intel Corporation. |
| @@ -19,7 +19,7 @@ Contents · 10 unmodified lines | ||
| 19 | 19 | Overview |
| 20 | 20 | ======== |
| 21 | 21 | |
| 22 | −This file describes the iavf Linux* Base Driver. This driver was formerly | |
| 22 | +This file describes the iavf Linux Base Driver. This driver was formerly | |
| 23 | 23 | called i40evf. |
| 24 | 24 | |
| 25 | 25 | The iavf driver supports the below mentioned virtual function devices and |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | |
| 3 | −=================================================================== | |
| 4 | −Linux* Base Driver for the Intel(R) Ethernet Connection E800 Series | |
| 5 | −=================================================================== | |
| 3 | +================================================================== | |
| 4 | +Linux Base Driver for the Intel(R) Ethernet Connection E800 Series | |
| 5 | +================================================================== | |
| 6 | 6 | |
| 7 | 7 | Intel ice Linux driver. |
| 8 | 8 | Copyright(c) 2018 Intel Corporation. |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | |
| 3 | −=========================================================== | |
| 4 | −Linux* Base Driver for Intel(R) Ethernet Network Connection | |
| 5 | −=========================================================== | |
| 3 | +========================================================== | |
| 4 | +Linux Base Driver for Intel(R) Ethernet Network Connection | |
| 5 | +========================================================== | |
| 6 | 6 | |
| 7 | 7 | Intel Gigabit Linux driver. |
| 8 | 8 | Copyright(c) 1999-2018 Intel Corporation. |
| @@ -129,9 +129,9 @@ version is required for this functionality. Download it at: · 120 unmodified lines | ||
| 129 | 129 | https://www.kernel.org/pub/software/network/ethtool/ |
| 130 | 130 | |
| 131 | 131 | |
| 132 | −Enabling Wake on LAN* (WoL) | |
| 133 | −--------------------------- | |
| 134 | −WoL is configured through the ethtool* utility. | |
| 132 | +Enabling Wake on LAN (WoL) | |
| 133 | +-------------------------- | |
| 134 | +WoL is configured through the ethtool utility. | |
| 135 | 135 | |
| 136 | 136 | WoL will be enabled on the system during the next shut down or reboot. For |
| 137 | 137 | this driver version, in order to enable WoL, the igb driver must be loaded |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | |
| 3 | −============================================================ | |
| 4 | −Linux* Base Virtual Function Driver for Intel(R) 1G Ethernet | |
| 5 | −============================================================ | |
| 3 | +=========================================================== | |
| 4 | +Linux Base Virtual Function Driver for Intel(R) 1G Ethernet | |
| 5 | +=========================================================== | |
| 6 | 6 | |
| 7 | 7 | Intel Gigabit Virtual Function Linux driver. |
| 8 | 8 | Copyright(c) 1999-2018 Intel Corporation. |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | |
| 3 | −============================================================================= | |
| 4 | −Linux* Base Driver for the Intel(R) Ethernet 10 Gigabit PCI Express Adapters | |
| 5 | −============================================================================= | |
| 3 | +=========================================================================== | |
| 4 | +Linux Base Driver for the Intel(R) Ethernet 10 Gigabit PCI Express Adapters | |
| 5 | +=========================================================================== | |
| 6 | 6 | |
| 7 | 7 | Intel 10 Gigabit Linux driver. |
| 8 | 8 | Copyright(c) 1999-2018 Intel Corporation. |
| @@ -519,8 +519,8 @@ The offload is also supported for ixgbe's VFs, but the VF must be set as · 510 unmodified lines | ||
| 519 | 519 | Known Issues/Troubleshooting |
| 520 | 520 | ============================ |
| 521 | 521 | |
| 522 | −Enabling SR-IOV in a 64-bit Microsoft* Windows Server* 2012/R2 guest OS | |
| 523 | −----------------------------------------------------------------------- | |
| 522 | +Enabling SR-IOV in a 64-bit Microsoft Windows Server 2012/R2 guest OS | |
| 523 | +--------------------------------------------------------------------- | |
| 524 | 524 | Linux KVM Hypervisor/VMM supports direct assignment of a PCIe device to a VM. |
| 525 | 525 | This includes traditional PCIe devices, as well as SR-IOV-capable devices based |
| 526 | 526 | on the Intel Ethernet Controller XL710. |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | |
| 3 | −============================================================= | |
| 4 | −Linux* Base Virtual Function Driver for Intel(R) 10G Ethernet | |
| 5 | −============================================================= | |
| 3 | +============================================================ | |
| 4 | +Linux Base Virtual Function Driver for Intel(R) 10G Ethernet | |
| 5 | +============================================================ | |
| 6 | 6 | |
| 7 | 7 | Intel 10 Gigabit Virtual Function Linux driver. |
| 8 | 8 | Copyright(c) 1999-2018 Intel Corporation. |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | |
| 3 | −========================================================== | |
| 4 | −Linux* Driver for the Pensando(R) Ethernet adapter family | |
| 5 | −========================================================== | |
| 3 | +======================================================== | |
| 4 | +Linux Driver for the Pensando(R) Ethernet adapter family | |
| 5 | +======================================================== | |
| 6 | 6 | |
| 7 | 7 | Pensando Linux Ethernet driver. |
| 8 | 8 | Copyright(c) 2019 Pensando Systems, Inc |
| @@ -207,8 +207,8 @@ TCP variables: · 206 unmodified lines | ||
| 207 | 207 | |
| 208 | 208 | somaxconn - INTEGER |
| 209 | 209 | Limit of socket listen() backlog, known in userspace as SOMAXCONN. |
| 210 | − Defaults to 128. See also tcp_max_syn_backlog for additional tuning | |
| 211 | − for TCP sockets. | |
| 210 | + Defaults to 4096. (Was 128 before linux-5.4) | |
| 211 | + See also tcp_max_syn_backlog for additional tuning for TCP sockets. | |
| 212 | 212 | |
| 213 | 213 | tcp_abort_on_overflow - BOOLEAN |
| 214 | 214 | If listening service is too slow to accept new connections, |
| @@ -408,11 +408,14 @@ tcp_max_orphans - INTEGER · 193 unmodified lines | ||
| 408 | 408 | up to ~64K of unswappable memory. |
| 409 | 409 | |
| 410 | 410 | tcp_max_syn_backlog - INTEGER |
| 411 | − Maximal number of remembered connection requests, which have not | |
| 412 | − received an acknowledgment from connecting client. | |
| 411 | + Maximal number of remembered connection requests (SYN_RECV), | |
| 412 | + which have not received an acknowledgment from connecting client. | |
| 413 | + This is a per-listener limit. | |
| 413 | 414 | The minimal value is 128 for low memory machines, and it will |
| 414 | 415 | increase in proportion to the memory of machine. |
| 415 | 416 | If server suffers from overload, try increasing this number. |
| 417 | + Remember to also check /proc/sys/net/core/somaxconn | |
| 418 | + A SYN_RECV request socket consumes about 304 bytes of memory. | |
| 416 | 419 | |
| 417 | 420 | tcp_max_tw_buckets - INTEGER |
| 418 | 421 | Maximal number of timewait sockets held by system simultaneously. |
| @@ -436,6 +436,10 @@ by the driver: · 435 unmodified lines | ||
| 436 | 436 | encryption. |
| 437 | 437 | * ``tx_tls_ooo`` - number of TX packets which were part of a TLS stream |
| 438 | 438 | but did not arrive in the expected order. |
| 439 | + * ``tx_tls_skip_no_sync_data`` - number of TX packets which were part of | |
| 440 | + a TLS stream and arrived out-of-order, but skipped the HW offload routine | |
| 441 | + and went to the regular transmit flow as they were retransmissions of the | |
| 442 | + connection handshake. | |
| 439 | 443 | * ``tx_tls_drop_no_sync_data`` - number of TX packets which were part of |
| 440 | 444 | a TLS stream dropped, because they arrived out of order and associated |
| 441 | 445 | record could not be found. |
| @@ -3053,6 +3053,7 @@ M: Daniel Borkmann <daniel@iogearbox.net> · 3052 unmodified lines | ||
| 3053 | 3053 | R: Martin KaFai Lau <kafai@fb.com> |
| 3054 | 3054 | R: Song Liu <songliubraving@fb.com> |
| 3055 | 3055 | R: Yonghong Song <yhs@fb.com> |
| 3056 | +R: Andrii Nakryiko <andriin@fb.com> | |
| 3056 | 3057 | L: netdev@vger.kernel.org |
| 3057 | 3058 | L: bpf@vger.kernel.org |
| 3058 | 3059 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git |
| @@ -3737,7 +3738,6 @@ F: drivers/crypto/cavium/cpt/ · 678 unmodified lines | ||
| 3737 | 3738 | |
| 3738 | 3739 | CAVIUM THUNDERX2 ARM64 SOC |
| 3739 | 3740 | M: Robert Richter <rrichter@cavium.com> |
| 3740 | −M: Jayachandran C <jnair@caviumnetworks.com> | |
| 3741 | 3741 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) |
| 3742 | 3742 | S: Maintained |
| 3743 | 3743 | F: arch/arm64/boot/dts/cavium/thunder2-99xx* |
| @@ -10519,8 +10519,12 @@ F: mm/memblock.c · 6775 unmodified lines | ||
| 10519 | 10519 | F: Documentation/core-api/boot-time-mm.rst |
| 10520 | 10520 | |
| 10521 | 10521 | MEMORY MANAGEMENT |
| 10522 | +M: Andrew Morton <akpm@linux-foundation.org> | |
| 10522 | 10523 | L: linux-mm@kvack.org |
| 10523 | 10524 | W: http://www.linux-mm.org |
| 10525 | +T: quilt https://ozlabs.org/~akpm/mmotm/ | |
| 10526 | +T: quilt https://ozlabs.org/~akpm/mmots/ | |
| 10527 | +T: git git://github.com/hnaz/linux-mm.git | |
| 10524 | 10528 | S: Maintained |
| 10525 | 10529 | F: include/linux/mm.h |
| 10526 | 10530 | F: include/linux/gfp.h |
| @@ -11408,7 +11412,6 @@ F: include/trace/events/tcp.h · 881 unmodified lines | ||
| 11408 | 11412 | NETWORKING [TLS] |
| 11409 | 11413 | M: Boris Pismenny <borisp@mellanox.com> |
| 11410 | 11414 | M: Aviad Yehezkel <aviadye@mellanox.com> |
| 11411 | −M: Dave Watson <davejwatson@fb.com> | |
| 11412 | 11415 | M: John Fastabend <john.fastabend@gmail.com> |
| 11413 | 11416 | M: Daniel Borkmann <daniel@iogearbox.net> |
| 11414 | 11417 | M: Jakub Kicinski <jakub.kicinski@netronome.com> |
| @@ -13913,7 +13916,7 @@ F: drivers/mtd/nand/raw/r852.h · 2498 unmodified lines | ||
| 13913 | 13916 | |
| 13914 | 13917 | RISC-V ARCHITECTURE |
| 13915 | 13918 | M: Paul Walmsley <paul.walmsley@sifive.com> |
| 13916 | −M: Palmer Dabbelt <palmer@sifive.com> | |
| 13919 | +M: Palmer Dabbelt <palmer@dabbelt.com> | |
| 13917 | 13920 | M: Albert Ou <aou@eecs.berkeley.edu> |
| 13918 | 13921 | L: linux-riscv@lists.infradead.org |
| 13919 | 13922 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git |
| @@ -14790,7 +14793,7 @@ F: drivers/media/usb/siano/ · 870 unmodified lines | ||
| 14790 | 14793 | F: drivers/media/mmc/siano/ |
| 14791 | 14794 | |
| 14792 | 14795 | SIFIVE DRIVERS |
| 14793 | −M: Palmer Dabbelt <palmer@sifive.com> | |
| 14796 | +M: Palmer Dabbelt <palmer@dabbelt.com> | |
| 14794 | 14797 | M: Paul Walmsley <paul.walmsley@sifive.com> |
| 14795 | 14798 | L: linux-riscv@lists.infradead.org |
| 14796 | 14799 | T: git git://github.com/sifive/riscv-linux.git |
| @@ -14800,7 +14803,7 @@ N: sifive · 3 unmodified lines | ||
| 14800 | 14803 | |
| 14801 | 14804 | SIFIVE FU540 SYSTEM-ON-CHIP |
| 14802 | 14805 | M: Paul Walmsley <paul.walmsley@sifive.com> |
| 14803 | −M: Palmer Dabbelt <palmer@sifive.com> | |
| 14806 | +M: Palmer Dabbelt <palmer@dabbelt.com> | |
| 14804 | 14807 | L: linux-riscv@lists.infradead.org |
| 14805 | 14808 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/pjw/sifive.git |
| 14806 | 14809 | S: Supported |
| @@ -17342,6 +17345,12 @@ F: include/linux/vbox_utils.h · 2535 unmodified lines | ||
| 17342 | 17345 | F: include/uapi/linux/vbox*.h |
| 17343 | 17346 | F: drivers/virt/vboxguest/ |
| 17344 | 17347 | |
| 17348 | +VIRTUAL BOX SHARED FOLDER VFS DRIVER: | |
| 17349 | +M: Hans de Goede <hdegoede@redhat.com> | |
| 17350 | +L: linux-fsdevel@vger.kernel.org | |
| 17351 | +S: Maintained | |
| 17352 | +F: drivers/staging/vboxsf/* | |
| 17353 | + | |
| 17345 | 17354 | VIRTUAL SERIO DEVICE DRIVER |
| 17346 | 17355 | M: Stephen Chandler Paul <thatslyude@gmail.com> |
| 17347 | 17356 | S: Maintained |
| @@ -18042,6 +18051,7 @@ F: Documentation/vm/zsmalloc.rst · 694 unmodified lines | ||
| 18042 | 18051 | ZSWAP COMPRESSED SWAP CACHING |
| 18043 | 18052 | M: Seth Jennings <sjenning@redhat.com> |
| 18044 | 18053 | M: Dan Streetman <ddstreet@ieee.org> |
| 18054 | +M: Vitaly Wool <vitaly.wool@konsulko.com> | |
| 18045 | 18055 | L: linux-mm@kvack.org |
| 18046 | 18056 | S: Maintained |
| 18047 | 18057 | F: mm/zswap.c |
| @@ -2,7 +2,7 @@ · 1 unmodified line | ||
| 2 | 2 | VERSION = 5 |
| 3 | 3 | PATCHLEVEL = 4 |
| 4 | 4 | SUBLEVEL = 0 |
| 5 | −EXTRAVERSION = -rc5 | |
| 5 | +EXTRAVERSION = -rc7 | |
| 6 | 6 | NAME = Kleptomaniac Octopus |
| 7 | 7 | |
| 8 | 8 | # *DOCUMENTATION* |
| @@ -65,6 +65,14 @@ · 64 unmodified lines | ||
| 65 | 65 | clock-frequency = <33333333>; |
| 66 | 66 | }; |
| 67 | 67 | |
| 68 | + reg_5v0: regulator-5v0 { | |
| 69 | + compatible = "regulator-fixed"; | |
| 70 | + | |
| 71 | + regulator-name = "5v0-supply"; | |
| 72 | + regulator-min-microvolt = <5000000>; | |
| 73 | + regulator-max-microvolt = <5000000>; | |
| 74 | + }; | |
| 75 | + | |
| 68 | 76 | cpu_intc: cpu-interrupt-controller { |
| 69 | 77 | compatible = "snps,archs-intc"; |
| 70 | 78 | interrupt-controller; |
| @@ -264,6 +272,21 @@ · 193 unmodified lines | ||
| 264 | 272 | clocks = <&input_clk>; |
| 265 | 273 | cs-gpios = <&creg_gpio 0 GPIO_ACTIVE_LOW>, |
| 266 | 274 | <&creg_gpio 1 GPIO_ACTIVE_LOW>; |
| 275 | + | |
| 276 | + spi-flash@0 { | |
| 277 | + compatible = "sst26wf016b", "jedec,spi-nor"; | |
| 278 | + reg = <0>; | |
| 279 | + #address-cells = <1>; | |
| 280 | + #size-cells = <1>; | |
| 281 | + spi-max-frequency = <4000000>; | |
| 282 | + }; | |
| 283 | + | |
| 284 | + adc@1 { | |
| 285 | + compatible = "ti,adc108s102"; | |
| 286 | + reg = <1>; | |
| 287 | + vref-supply = <®_5v0>; | |
| 288 | + spi-max-frequency = <1000000>; | |
| 289 | + }; | |
| 267 | 290 | }; |
| 268 | 291 | |
| 269 | 292 | creg_gpio: gpio@14b0 { |
| @@ -32,6 +32,8 @@ CONFIG_INET=y · 31 unmodified lines | ||
| 32 | 32 | CONFIG_DEVTMPFS=y |
| 33 | 33 | # CONFIG_STANDALONE is not set |
| 34 | 34 | # CONFIG_PREVENT_FIRMWARE_BUILD is not set |
| 35 | +CONFIG_MTD=y | |
| 36 | +CONFIG_MTD_SPI_NOR=y | |
| 35 | 37 | CONFIG_SCSI=y |
| 36 | 38 | CONFIG_BLK_DEV_SD=y |
| 37 | 39 | CONFIG_NETDEVICES=y |
| @@ -55,6 +57,8 @@ CONFIG_GPIO_SYSFS=y · 17 unmodified lines | ||
| 55 | 57 | CONFIG_GPIO_DWAPB=y |
| 56 | 58 | CONFIG_GPIO_SNPS_CREG=y |
| 57 | 59 | # CONFIG_HWMON is not set |
| 60 | +CONFIG_REGULATOR=y | |
| 61 | +CONFIG_REGULATOR_FIXED_VOLTAGE=y | |
| 58 | 62 | CONFIG_DRM=y |
| 59 | 63 | # CONFIG_DRM_FBDEV_EMULATION is not set |
| 60 | 64 | CONFIG_DRM_UDL=y |
| @@ -72,6 +76,8 @@ CONFIG_MMC_SDHCI_PLTFM=y · 11 unmodified lines | ||
| 72 | 76 | CONFIG_MMC_DW=y |
| 73 | 77 | CONFIG_DMADEVICES=y |
| 74 | 78 | CONFIG_DW_AXI_DMAC=y |
| 79 | +CONFIG_IIO=y | |
| 80 | +CONFIG_TI_ADC108S102=y | |
| 75 | 81 | CONFIG_EXT3_FS=y |
| 76 | 82 | CONFIG_VFAT_FS=y |
| 77 | 83 | CONFIG_TMPFS=y |
| @@ -614,8 +614,8 @@ static int arc_pmu_device_probe(struct platform_device *pdev) · 613 unmodified lines | ||
| 614 | 614 | /* loop thru all available h/w condition indexes */ |
| 615 | 615 | for (i = 0; i < cc_bcr.c; i++) { |
| 616 | 616 | write_aux_reg(ARC_REG_CC_INDEX, i); |
| 617 | − cc_name.indiv.word0 = read_aux_reg(ARC_REG_CC_NAME0); | |
| 618 | − cc_name.indiv.word1 = read_aux_reg(ARC_REG_CC_NAME1); | |
| 617 | + cc_name.indiv.word0 = le32_to_cpu(read_aux_reg(ARC_REG_CC_NAME0)); | |
| 618 | + cc_name.indiv.word1 = le32_to_cpu(read_aux_reg(ARC_REG_CC_NAME1)); | |
| 619 | 619 | |
| 620 | 620 | arc_pmu_map_hw_event(i, cc_name.str); |
| 621 | 621 | arc_pmu_add_raw_event_attr(i, cc_name.str); |
| @@ -328,6 +328,10 @@ · 327 unmodified lines | ||
| 328 | 328 | pinctrl-0 = <&pinctrl_pwm3>; |
| 329 | 329 | }; |
| 330 | 330 | |
| 331 | +&snvs_pwrkey { | |
| 332 | + status = "okay"; | |
| 333 | +}; | |
| 334 | + | |
| 331 | 335 | &ssi2 { |
| 332 | 336 | status = "okay"; |
| 333 | 337 | }; |
| @@ -230,6 +230,8 @@ · 229 unmodified lines | ||
| 230 | 230 | accelerometer@1c { |
| 231 | 231 | compatible = "fsl,mma8451"; |
| 232 | 232 | reg = <0x1c>; |
| 233 | + pinctrl-names = "default"; | |
| 234 | + pinctrl-0 = <&pinctrl_mma8451_int>; | |
| 233 | 235 | interrupt-parent = <&gpio6>; |
| 234 | 236 | interrupts = <31 IRQ_TYPE_LEVEL_LOW>; |
| 235 | 237 | }; |
| @@ -628,6 +630,12 @@ · 392 unmodified lines | ||
| 628 | 630 | >; |
| 629 | 631 | }; |
| 630 | 632 | |
| 633 | + pinctrl_mma8451_int: mma8451intgrp { | |
| 634 | + fsl,pins = < | |
| 635 | + MX6QDL_PAD_EIM_BCLK__GPIO6_IO31 0xb0b1 | |
| 636 | + >; | |
| 637 | + }; | |
| 638 | + | |
| 631 | 639 | pinctrl_pwm3: pwm1grp { |
| 632 | 640 | fsl,pins = < |
| 633 | 641 | MX6QDL_PAD_SD4_DAT1__PWM3_OUT 0x1b0b1 |
| @@ -183,14 +183,12 @@ · 182 unmodified lines | ||
| 183 | 183 | |
| 184 | 184 | ov5640: camera@3c { |
| 185 | 185 | compatible = "ovti,ov5640"; |
| 186 | − pinctrl-names = "default"; | |
| 187 | − pinctrl-0 = <&ov5640_pins>; | |
| 188 | 186 | reg = <0x3c>; |
| 189 | 187 | clocks = <&clk_ext_camera>; |
| 190 | 188 | clock-names = "xclk"; |
| 191 | 189 | DOVDD-supply = <&v2v8>; |
| 192 | − powerdown-gpios = <&stmfx_pinctrl 18 GPIO_ACTIVE_HIGH>; | |
| 193 | − reset-gpios = <&stmfx_pinctrl 19 GPIO_ACTIVE_LOW>; | |
| 190 | + powerdown-gpios = <&stmfx_pinctrl 18 (GPIO_ACTIVE_HIGH | GPIO_PUSH_PULL)>; | |
| 191 | + reset-gpios = <&stmfx_pinctrl 19 (GPIO_ACTIVE_LOW | GPIO_PUSH_PULL)>; | |
| 194 | 192 | rotation = <180>; |
| 195 | 193 | status = "okay"; |
| 196 | 194 | |
| @@ -223,15 +221,8 @@ · 26 unmodified lines | ||
| 223 | 221 | |
| 224 | 222 | joystick_pins: joystick { |
| 225 | 223 | pins = "gpio0", "gpio1", "gpio2", "gpio3", "gpio4"; |
| 226 | − drive-push-pull; | |
| 227 | 224 | bias-pull-down; |
| 228 | 225 | }; |
| 229 | − | |
| 230 | − ov5640_pins: camera { | |
| 231 | − pins = "agpio2", "agpio3"; /* stmfx pins 18 & 19 */ | |
| 232 | − drive-push-pull; | |
| 233 | − output-low; | |
| 234 | − }; | |
| 235 | 226 | }; |
| 236 | 227 | }; |
| 237 | 228 | }; |
| @@ -932,7 +932,7 @@ · 931 unmodified lines | ||
| 932 | 932 | interrupt-names = "int0", "int1"; |
| 933 | 933 | clocks = <&rcc CK_HSE>, <&rcc FDCAN_K>; |
| 934 | 934 | clock-names = "hclk", "cclk"; |
| 935 | − bosch,mram-cfg = <0x1400 0 0 32 0 0 2 2>; | |
| 935 | + bosch,mram-cfg = <0x0 0 0 32 0 0 2 2>; | |
| 936 | 936 | status = "disabled"; |
| 937 | 937 | }; |
| 938 | 938 | |
| @@ -945,7 +945,7 @@ · 6 unmodified lines | ||
| 945 | 945 | interrupt-names = "int0", "int1"; |
| 946 | 946 | clocks = <&rcc CK_HSE>, <&rcc FDCAN_K>; |
| 947 | 947 | clock-names = "hclk", "cclk"; |
| 948 | − bosch,mram-cfg = <0x0 0 0 32 0 0 2 2>; | |
| 948 | + bosch,mram-cfg = <0x1400 0 0 32 0 0 2 2>; | |
| 949 | 949 | status = "disabled"; |
| 950 | 950 | }; |
| 951 | 951 | |
| @@ -192,6 +192,7 @@ · 191 unmodified lines | ||
| 192 | 192 | vqmmc-supply = <®_dldo1>; |
| 193 | 193 | non-removable; |
| 194 | 194 | wakeup-source; |
| 195 | + keep-power-in-suspend; | |
| 195 | 196 | status = "okay"; |
| 196 | 197 | |
| 197 | 198 | brcmf: wifi@1 { |
| @@ -481,14 +481,18 @@ static void sunxi_mc_smp_cpu_die(unsigned int l_cpu) · 480 unmodified lines | ||
| 481 | 481 | static int sunxi_cpu_powerdown(unsigned int cpu, unsigned int cluster) |
| 482 | 482 | { |
| 483 | 483 | u32 reg; |
| 484 | + int gating_bit = cpu; | |
| 484 | 485 | |
| 485 | 486 | pr_debug("%s: cluster %u cpu %u\n", __func__, cluster, cpu); |
| 486 | 487 | if (cpu >= SUNXI_CPUS_PER_CLUSTER || cluster >= SUNXI_NR_CLUSTERS) |
| 487 | 488 | return -EINVAL; |
| 488 | 489 | |
| 490 | + if (is_a83t && cpu == 0) | |
| 491 | + gating_bit = 4; | |
| 492 | + | |
| 489 | 493 | /* gate processor power */ |
| 490 | 494 | reg = readl(prcm_base + PRCM_PWROFF_GATING_REG(cluster)); |
| 491 | − reg |= PRCM_PWROFF_GATING_REG_CORE(cpu); | |
| 495 | + reg |= PRCM_PWROFF_GATING_REG_CORE(gating_bit); | |
| 492 | 496 | writel(reg, prcm_base + PRCM_PWROFF_GATING_REG(cluster)); |
| 493 | 497 | udelay(20); |
| 494 | 498 | |
| @@ -127,7 +127,7 @@ · 126 unmodified lines | ||
| 127 | 127 | status = "okay"; |
| 128 | 128 | |
| 129 | 129 | i2c-mux@77 { |
| 130 | − compatible = "nxp,pca9847"; | |
| 130 | + compatible = "nxp,pca9547"; | |
| 131 | 131 | reg = <0x77>; |
| 132 | 132 | #address-cells = <1>; |
| 133 | 133 | #size-cells = <0>; |
| @@ -394,7 +394,7 @@ · 393 unmodified lines | ||
| 394 | 394 | }; |
| 395 | 395 | |
| 396 | 396 | sdma2: dma-controller@302c0000 { |
| 397 | − compatible = "fsl,imx8mm-sdma", "fsl,imx7d-sdma"; | |
| 397 | + compatible = "fsl,imx8mm-sdma", "fsl,imx8mq-sdma"; | |
| 398 | 398 | reg = <0x302c0000 0x10000>; |
| 399 | 399 | interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; |
| 400 | 400 | clocks = <&clk IMX8MM_CLK_SDMA2_ROOT>, |
| @@ -405,7 +405,7 @@ · 4 unmodified lines | ||
| 405 | 405 | }; |
| 406 | 406 | |
| 407 | 407 | sdma3: dma-controller@302b0000 { |
| 408 | − compatible = "fsl,imx8mm-sdma", "fsl,imx7d-sdma"; | |
| 408 | + compatible = "fsl,imx8mm-sdma", "fsl,imx8mq-sdma"; | |
| 409 | 409 | reg = <0x302b0000 0x10000>; |
| 410 | 410 | interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>; |
| 411 | 411 | clocks = <&clk IMX8MM_CLK_SDMA3_ROOT>, |
| @@ -737,7 +737,7 @@ · 325 unmodified lines | ||
| 737 | 737 | }; |
| 738 | 738 | |
| 739 | 739 | sdma1: dma-controller@30bd0000 { |
| 740 | − compatible = "fsl,imx8mm-sdma", "fsl,imx7d-sdma"; | |
| 740 | + compatible = "fsl,imx8mm-sdma", "fsl,imx8mq-sdma"; | |
| 741 | 741 | reg = <0x30bd0000 0x10000>; |
| 742 | 742 | interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>; |
| 743 | 743 | clocks = <&clk IMX8MM_CLK_SDMA1_ROOT>, |
| @@ -288,7 +288,7 @@ · 287 unmodified lines | ||
| 288 | 288 | }; |
| 289 | 289 | |
| 290 | 290 | sdma3: dma-controller@302b0000 { |
| 291 | − compatible = "fsl,imx8mn-sdma", "fsl,imx7d-sdma"; | |
| 291 | + compatible = "fsl,imx8mn-sdma", "fsl,imx8mq-sdma"; | |
| 292 | 292 | reg = <0x302b0000 0x10000>; |
| 293 | 293 | interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>; |
| 294 | 294 | clocks = <&clk IMX8MN_CLK_SDMA3_ROOT>, |
| @@ -299,7 +299,7 @@ · 4 unmodified lines | ||
| 299 | 299 | }; |
| 300 | 300 | |
| 301 | 301 | sdma2: dma-controller@302c0000 { |
| 302 | − compatible = "fsl,imx8mn-sdma", "fsl,imx7d-sdma"; | |
| 302 | + compatible = "fsl,imx8mn-sdma", "fsl,imx8mq-sdma"; | |
| 303 | 303 | reg = <0x302c0000 0x10000>; |
| 304 | 304 | interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; |
| 305 | 305 | clocks = <&clk IMX8MN_CLK_SDMA2_ROOT>, |
| @@ -612,7 +612,7 @@ · 306 unmodified lines | ||
| 612 | 612 | }; |
| 613 | 613 | |
| 614 | 614 | sdma1: dma-controller@30bd0000 { |
| 615 | − compatible = "fsl,imx8mn-sdma", "fsl,imx7d-sdma"; | |
| 615 | + compatible = "fsl,imx8mn-sdma", "fsl,imx8mq-sdma"; | |
| 616 | 616 | reg = <0x30bd0000 0x10000>; |
| 617 | 617 | interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>; |
| 618 | 618 | clocks = <&clk IMX8MN_CLK_SDMA1_ROOT>, |
| @@ -88,7 +88,7 @@ · 87 unmodified lines | ||
| 88 | 88 | regulator-name = "0V9_ARM"; |
| 89 | 89 | regulator-min-microvolt = <900000>; |
| 90 | 90 | regulator-max-microvolt = <1000000>; |
| 91 | − gpios = <&gpio3 19 GPIO_ACTIVE_HIGH>; | |
| 91 | + gpios = <&gpio3 16 GPIO_ACTIVE_HIGH>; | |
| 92 | 92 | states = <1000000 0x1 |
| 93 | 93 | 900000 0x0>; |
| 94 | 94 | regulator-always-on; |
| @@ -79,6 +79,7 @@ · 78 unmodified lines | ||
| 79 | 79 | #define CAVIUM_CPU_PART_THUNDERX_83XX 0x0A3 |
| 80 | 80 | #define CAVIUM_CPU_PART_THUNDERX2 0x0AF |
| 81 | 81 | |
| 82 | +#define BRCM_CPU_PART_BRAHMA_B53 0x100 | |
| 82 | 83 | #define BRCM_CPU_PART_VULCAN 0x516 |
| 83 | 84 | |
| 84 | 85 | #define QCOM_CPU_PART_FALKOR_V1 0x800 |
| @@ -105,6 +106,7 @@ · 20 unmodified lines | ||
| 105 | 106 | #define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX) |
| 106 | 107 | #define MIDR_THUNDERX_83XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_83XX) |
| 107 | 108 | #define MIDR_CAVIUM_THUNDERX2 MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX2) |
| 109 | +#define MIDR_BRAHMA_B53 MIDR_CPU_MODEL(ARM_CPU_IMP_BRCM, BRCM_CPU_PART_BRAHMA_B53) | |
| 108 | 110 | #define MIDR_BRCM_VULCAN MIDR_CPU_MODEL(ARM_CPU_IMP_BRCM, BRCM_CPU_PART_VULCAN) |
| 109 | 111 | #define MIDR_QCOM_FALKOR_V1 MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_FALKOR_V1) |
| 110 | 112 | #define MIDR_QCOM_FALKOR MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_FALKOR) |
| @@ -32,11 +32,11 @@ · 31 unmodified lines | ||
| 32 | 32 | #define PROT_DEFAULT (_PROT_DEFAULT | PTE_MAYBE_NG) |
| 33 | 33 | #define PROT_SECT_DEFAULT (_PROT_SECT_DEFAULT | PMD_MAYBE_NG) |
| 34 | 34 | |
| 35 | −#define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRnE)) | |
| 36 | −#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRE)) | |
| 37 | −#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_NC)) | |
| 38 | −#define PROT_NORMAL_WT (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_WT)) | |
| 39 | −#define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL)) | |
| 35 | +#define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRnE)) | |
| 36 | +#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRE)) | |
| 37 | +#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_NC)) | |
| 38 | +#define PROT_NORMAL_WT (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_WT)) | |
| 39 | +#define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL)) | |
| 40 | 40 | |
| 41 | 41 | #define PROT_SECT_DEVICE_nGnRE (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_DEVICE_nGnRE)) |
| 42 | 42 | #define PROT_SECT_NORMAL (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_NORMAL)) |
| @@ -80,8 +80,9 @@ · 37 unmodified lines | ||
| 80 | 80 | #define PAGE_S2_DEVICE __pgprot(_PROT_DEFAULT | PAGE_S2_MEMATTR(DEVICE_nGnRE) | PTE_S2_RDONLY | PTE_S2_XN) |
| 81 | 81 | |
| 82 | 82 | #define PAGE_NONE __pgprot(((_PAGE_DEFAULT) & ~PTE_VALID) | PTE_PROT_NONE | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN) |
| 83 | −#define PAGE_SHARED __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_UXN | PTE_WRITE) | |
| 84 | −#define PAGE_SHARED_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_WRITE) | |
| 83 | +/* shared+writable pages are clean by default, hence PTE_RDONLY|PTE_WRITE */ | |
| 84 | +#define PAGE_SHARED __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN | PTE_WRITE) | |
| 85 | +#define PAGE_SHARED_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_WRITE) | |
| 85 | 86 | #define PAGE_READONLY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN) |
| 86 | 87 | #define PAGE_READONLY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN) |
| 87 | 88 | #define PAGE_EXECONLY __pgprot(_PAGE_DEFAULT | PTE_RDONLY | PTE_NG | PTE_PXN) |
| @@ -283,23 +283,6 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, · 282 unmodified lines | ||
| 283 | 283 | set_pte(ptep, pte); |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | −#define __HAVE_ARCH_PTE_SAME | |
| 287 | −static inline int pte_same(pte_t pte_a, pte_t pte_b) | |
| 288 | −{ | |
| 289 | − pteval_t lhs, rhs; | |
| 290 | − | |
| 291 | − lhs = pte_val(pte_a); | |
| 292 | − rhs = pte_val(pte_b); | |
| 293 | − | |
| 294 | − if (pte_present(pte_a)) | |
| 295 | − lhs &= ~PTE_RDONLY; | |
| 296 | − | |
| 297 | − if (pte_present(pte_b)) | |
| 298 | − rhs &= ~PTE_RDONLY; | |
| 299 | − | |
| 300 | − return (lhs == rhs); | |
| 301 | −} | |
| 302 | − | |
| 303 | 286 | /* |
| 304 | 287 | * Huge pte definitions. |
| 305 | 288 | */ |
| @@ -30,13 +30,6 @@ int __arm64_get_clock_mode(struct timekeeper *tk) · 29 unmodified lines | ||
| 30 | 30 | } |
| 31 | 31 | #define __arch_get_clock_mode __arm64_get_clock_mode |
| 32 | 32 | |
| 33 | −static __always_inline | |
| 34 | −int __arm64_use_vsyscall(struct vdso_data *vdata) | |
| 35 | −{ | |
| 36 | − return !vdata[CS_HRES_COARSE].clock_mode; | |
| 37 | −} | |
| 38 | −#define __arch_use_vsyscall __arm64_use_vsyscall | |
| 39 | − | |
| 40 | 33 | static __always_inline |
| 41 | 34 | void __arm64_update_vsyscall(struct vdso_data *vdata, struct timekeeper *tk) |
| 42 | 35 | { |
| @@ -489,6 +489,7 @@ static const struct midr_range arm64_ssb_cpus[] = { · 488 unmodified lines | ||
| 489 | 489 | MIDR_ALL_VERSIONS(MIDR_CORTEX_A35), |
| 490 | 490 | MIDR_ALL_VERSIONS(MIDR_CORTEX_A53), |
| 491 | 491 | MIDR_ALL_VERSIONS(MIDR_CORTEX_A55), |
| 492 | + MIDR_ALL_VERSIONS(MIDR_BRAHMA_B53), | |
| 492 | 493 | {}, |
| 493 | 494 | }; |
| 494 | 495 | |
| @@ -573,6 +574,7 @@ static const struct midr_range spectre_v2_safe_list[] = { · 78 unmodified lines | ||
| 573 | 574 | MIDR_ALL_VERSIONS(MIDR_CORTEX_A35), |
| 574 | 575 | MIDR_ALL_VERSIONS(MIDR_CORTEX_A53), |
| 575 | 576 | MIDR_ALL_VERSIONS(MIDR_CORTEX_A55), |
| 577 | + MIDR_ALL_VERSIONS(MIDR_BRAHMA_B53), | |
| 576 | 578 | { /* sentinel */ } |
| 577 | 579 | }; |
| 578 | 580 | |
| @@ -659,17 +661,23 @@ static const struct midr_range arm64_harden_el2_vectors[] = { · 80 unmodified lines | ||
| 659 | 661 | #endif |
| 660 | 662 | |
| 661 | 663 | #ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI |
| 662 | − | |
| 663 | −static const struct midr_range arm64_repeat_tlbi_cpus[] = { | |
| 664 | +static const struct arm64_cpu_capabilities arm64_repeat_tlbi_list[] = { | |
| 664 | 665 | #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1009 |
| 665 | − MIDR_RANGE(MIDR_QCOM_FALKOR_V1, 0, 0, 0, 0), | |
| 666 | + { | |
| 667 | + ERRATA_MIDR_REV(MIDR_QCOM_FALKOR_V1, 0, 0) | |
| 668 | + }, | |
| 669 | + { | |
| 670 | + .midr_range.model = MIDR_QCOM_KRYO, | |
| 671 | + .matches = is_kryo_midr, | |
| 672 | + }, | |
| 666 | 673 | #endif |
| 667 | 674 | #ifdef CONFIG_ARM64_ERRATUM_1286807 |
| 668 | − MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 3, 0), | |
| 675 | + { | |
| 676 | + ERRATA_MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 3, 0), | |
| 677 | + }, | |
| 669 | 678 | #endif |
| 670 | 679 | {}, |
| 671 | 680 | }; |
| 672 | − | |
| 673 | 681 | #endif |
| 674 | 682 | |
| 675 | 683 | #ifdef CONFIG_CAVIUM_ERRATUM_27456 |
| @@ -737,6 +745,33 @@ static const struct midr_range erratum_1418040_list[] = { · 61 unmodified lines | ||
| 737 | 745 | }; |
| 738 | 746 | #endif |
| 739 | 747 | |
| 748 | +#ifdef CONFIG_ARM64_ERRATUM_845719 | |
| 749 | +static const struct midr_range erratum_845719_list[] = { | |
| 750 | + /* Cortex-A53 r0p[01234] */ | |
| 751 | + MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4), | |
| 752 | + /* Brahma-B53 r0p[0] */ | |
| 753 | + MIDR_REV(MIDR_BRAHMA_B53, 0, 0), | |
| 754 | + {}, | |
| 755 | +}; | |
| 756 | +#endif | |
| 757 | + | |
| 758 | +#ifdef CONFIG_ARM64_ERRATUM_843419 | |
| 759 | +static const struct arm64_cpu_capabilities erratum_843419_list[] = { | |
| 760 | + { | |
| 761 | + /* Cortex-A53 r0p[01234] */ | |
| 762 | + .matches = is_affected_midr_range, | |
| 763 | + ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4), | |
| 764 | + MIDR_FIXED(0x4, BIT(8)), | |
| 765 | + }, | |
| 766 | + { | |
| 767 | + /* Brahma-B53 r0p[0] */ | |
| 768 | + .matches = is_affected_midr_range, | |
| 769 | + ERRATA_MIDR_REV(MIDR_BRAHMA_B53, 0, 0), | |
| 770 | + }, | |
| 771 | + {}, | |
| 772 | +}; | |
| 773 | +#endif | |
| 774 | + | |
| 740 | 775 | const struct arm64_cpu_capabilities arm64_errata[] = { |
| 741 | 776 | #ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE |
| 742 | 777 | { |
| @@ -768,19 +803,18 @@ const struct arm64_cpu_capabilities arm64_errata[] = { · 25 unmodified lines | ||
| 768 | 803 | #endif |
| 769 | 804 | #ifdef CONFIG_ARM64_ERRATUM_843419 |
| 770 | 805 | { |
| 771 | − /* Cortex-A53 r0p[01234] */ | |
| 772 | 806 | .desc = "ARM erratum 843419", |
| 773 | 807 | .capability = ARM64_WORKAROUND_843419, |
| 774 | − ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4), | |
| 775 | − MIDR_FIXED(0x4, BIT(8)), | |
| 808 | + .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, | |
| 809 | + .matches = cpucap_multi_entry_cap_matches, | |
| 810 | + .match_list = erratum_843419_list, | |
| 776 | 811 | }, |
| 777 | 812 | #endif |
| 778 | 813 | #ifdef CONFIG_ARM64_ERRATUM_845719 |
| 779 | 814 | { |
| 780 | − /* Cortex-A53 r0p[01234] */ | |
| 781 | 815 | .desc = "ARM erratum 845719", |
| 782 | 816 | .capability = ARM64_WORKAROUND_845719, |
| 783 | − ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4), | |
| 817 | + ERRATA_MIDR_RANGE_LIST(erratum_845719_list), | |
| 784 | 818 | }, |
| 785 | 819 | #endif |
| 786 | 820 | #ifdef CONFIG_CAVIUM_ERRATUM_23154 |
| @@ -816,6 +850,7 @@ const struct arm64_cpu_capabilities arm64_errata[] = { · 29 unmodified lines | ||
| 816 | 850 | { |
| 817 | 851 | .desc = "Qualcomm Technologies Falkor/Kryo erratum 1003", |
| 818 | 852 | .capability = ARM64_WORKAROUND_QCOM_FALKOR_E1003, |
| 853 | + .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, | |
| 819 | 854 | .matches = cpucap_multi_entry_cap_matches, |
| 820 | 855 | .match_list = qcom_erratum_1003_list, |
| 821 | 856 | }, |
| @@ -824,7 +859,9 @@ const struct arm64_cpu_capabilities arm64_errata[] = { · 2 unmodified lines | ||
| 824 | 859 | { |
| 825 | 860 | .desc = "Qualcomm erratum 1009, ARM erratum 1286807", |
| 826 | 861 | .capability = ARM64_WORKAROUND_REPEAT_TLBI, |
| 827 | − ERRATA_MIDR_RANGE_LIST(arm64_repeat_tlbi_cpus), | |
| 862 | + .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, | |
| 863 | + .matches = cpucap_multi_entry_cap_matches, | |
| 864 | + .match_list = arm64_repeat_tlbi_list, | |
| 828 | 865 | }, |
| 829 | 866 | #endif |
| 830 | 867 | #ifdef CONFIG_ARM64_ERRATUM_858921 |
| @@ -28,13 +28,6 @@ int __mips_get_clock_mode(struct timekeeper *tk) · 27 unmodified lines | ||
| 28 | 28 | } |
| 29 | 29 | #define __arch_get_clock_mode __mips_get_clock_mode |
| 30 | 30 | |
| 31 | −static __always_inline | |
| 32 | −int __mips_use_vsyscall(struct vdso_data *vdata) | |
| 33 | −{ | |
| 34 | − return (vdata[CS_HRES_COARSE].clock_mode != VDSO_CLOCK_NONE); | |
| 35 | −} | |
| 36 | −#define __arch_use_vsyscall __mips_use_vsyscall | |
| 37 | − | |
| 38 | 31 | /* The asm-generic header needs to be included after the definitions above */ |
| 39 | 32 | #include <asm-generic/vdso/vsyscall.h> |
| 40 | 33 | |
| @@ -2125,7 +2125,7 @@ ftrace_regs_caller: · 2124 unmodified lines | ||
| 2125 | 2125 | copy %rp, %r26 |
| 2126 | 2126 | LDREG -FTRACE_FRAME_SIZE-PT_SZ_ALGN(%sp), %r25 |
| 2127 | 2127 | ldo -8(%r25), %r25 |
| 2128 | − copy %r3, %arg2 | |
| 2128 | + ldo -FTRACE_FRAME_SIZE(%r1), %arg2 | |
| 2129 | 2129 | b,l ftrace_function_trampoline, %rp |
| 2130 | 2130 | copy %r1, %arg3 /* struct pt_regs */ |
| 2131 | 2131 | |
| @@ -91,6 +91,7 @@ · 90 unmodified lines | ||
| 91 | 91 | |
| 92 | 92 | static inline void kuap_update_sr(u32 sr, u32 addr, u32 end) |
| 93 | 93 | { |
| 94 | + addr &= 0xf0000000; /* align addr to start of segment */ | |
| 94 | 95 | barrier(); /* make sure thread.kuap is updated before playing with SRs */ |
| 95 | 96 | while (addr < end) { |
| 96 | 97 | mtsrin(sr, addr); |
| @@ -175,4 +175,7 @@ do { \ · 174 unmodified lines | ||
| 175 | 175 | ARCH_DLINFO_CACHE_GEOMETRY; \ |
| 176 | 176 | } while (0) |
| 177 | 177 | |
| 178 | +/* Relocate the kernel image to @final_address */ | |
| 179 | +void relocate(unsigned long final_address); | |
| 180 | + | |
| 178 | 181 | #endif /* _ASM_POWERPC_ELF_H */ |
| @@ -3249,7 +3249,20 @@ static void setup_secure_guest(unsigned long kbase, unsigned long fdt) · 3248 unmodified lines | ||
| 3249 | 3249 | /* Switch to secure mode. */ |
| 3250 | 3250 | prom_printf("Switching to secure mode.\n"); |
| 3251 | 3251 | |
| 3252 | + /* | |
| 3253 | + * The ultravisor will do an integrity check of the kernel image but we | |
| 3254 | + * relocated it so the check will fail. Restore the original image by | |
| 3255 | + * relocating it back to the kernel virtual base address. | |
| 3256 | + */ | |
| 3257 | + if (IS_ENABLED(CONFIG_RELOCATABLE)) | |
| 3258 | + relocate(KERNELBASE); | |
| 3259 | + | |
| 3252 | 3260 | ret = enter_secure_mode(kbase, fdt); |
| 3261 | + | |
| 3262 | + /* Relocate the kernel again. */ | |
| 3263 | + if (IS_ENABLED(CONFIG_RELOCATABLE)) | |
| 3264 | + relocate(kbase); | |
| 3265 | + | |
| 3253 | 3266 | if (ret != U_SUCCESS) { |
| 3254 | 3267 | prom_printf("Returned %d from switching to secure mode.\n", ret); |
| 3255 | 3268 | prom_rtas_os_term("Switch to secure mode failed.\n"); |
| @@ -26,7 +26,8 @@ _end enter_prom $MEM_FUNCS reloc_offset __secondary_hold · 25 unmodified lines | ||
| 26 | 26 | __secondary_hold_acknowledge __secondary_hold_spinloop __start |
| 27 | 27 | logo_linux_clut224 btext_prepare_BAT |
| 28 | 28 | reloc_got2 kernstart_addr memstart_addr linux_banner _stext |
| 29 | −__prom_init_toc_start __prom_init_toc_end btext_setup_display TOC." | |
| 29 | +__prom_init_toc_start __prom_init_toc_end btext_setup_display TOC. | |
| 30 | +relocate" | |
| 30 | 31 | |
| 31 | 32 | NM="$1" |
| 32 | 33 | OBJ="$2" |
| @@ -1141,6 +1141,19 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp) · 1140 unmodified lines | ||
| 1141 | 1141 | goto out_addrs; |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | + /* | |
| 1145 | + * If we have seen a tail call, we need a second pass. | |
| 1146 | + * This is because bpf_jit_emit_common_epilogue() is called | |
| 1147 | + * from bpf_jit_emit_tail_call() with a not yet stable ctx->seen. | |
| 1148 | + */ | |
| 1149 | + if (cgctx.seen & SEEN_TAILCALL) { | |
| 1150 | + cgctx.idx = 0; | |
| 1151 | + if (bpf_jit_build_body(fp, 0, &cgctx, addrs, false)) { | |
| 1152 | + fp = org_fp; | |
| 1153 | + goto out_addrs; | |
| 1154 | + } | |
| 1155 | + } | |
| 1156 | + | |
| 1144 | 1157 | /* |
| 1145 | 1158 | * Pretend to build prologue, given the features we've seen. This will |
| 1146 | 1159 | * update ctgtx.idx as it pretends to output instructions, then we can |
| @@ -42,7 +42,7 @@ void pnv_pcibios_bus_add_device(struct pci_dev *pdev) · 41 unmodified lines | ||
| 42 | 42 | { |
| 43 | 43 | struct pci_dn *pdn = pci_get_pdn(pdev); |
| 44 | 44 | |
| 45 | − if (eeh_has_flag(EEH_FORCE_DISABLED)) | |
| 45 | + if (!pdn || eeh_has_flag(EEH_FORCE_DISABLED)) | |
| 46 | 46 | return; |
| 47 | 47 | |
| 48 | 48 | dev_dbg(&pdev->dev, "EEH: Setting up device\n"); |
| @@ -146,20 +146,25 @@ static int pnv_smp_cpu_disable(void) · 145 unmodified lines | ||
| 146 | 146 | return 0; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | +static void pnv_flush_interrupts(void) | |
| 150 | +{ | |
| 151 | + if (cpu_has_feature(CPU_FTR_ARCH_300)) { | |
| 152 | + if (xive_enabled()) | |
| 153 | + xive_flush_interrupt(); | |
| 154 | + else | |
| 155 | + icp_opal_flush_interrupt(); | |
| 156 | + } else { | |
| 157 | + icp_native_flush_interrupt(); | |
| 158 | + } | |
| 159 | +} | |
| 160 | + | |
| 149 | 161 | static void pnv_smp_cpu_kill_self(void) |
| 150 | 162 | { |
| 163 | + unsigned long srr1, unexpected_mask, wmask; | |
| 151 | 164 | unsigned int cpu; |
| 152 | − unsigned long srr1, wmask; | |
| 153 | 165 | u64 lpcr_val; |
| 154 | 166 | |
| 155 | 167 | /* Standard hot unplug procedure */ |
| 156 | − /* | |
| 157 | − * This hard disables local interurpts, ensuring we have no lazy | |
| 158 | − * irqs pending. | |
| 159 | − */ | |
| 160 | − WARN_ON(irqs_disabled()); | |
| 161 | − hard_irq_disable(); | |
| 162 | − WARN_ON(lazy_irq_pending()); | |
| 163 | 168 | |
| 164 | 169 | idle_task_exit(); |
| 165 | 170 | current->active_mm = NULL; /* for sanity */ |
| @@ -172,6 +177,27 @@ static void pnv_smp_cpu_kill_self(void) · 6 unmodified lines | ||
| 172 | 177 | if (cpu_has_feature(CPU_FTR_ARCH_207S)) |
| 173 | 178 | wmask = SRR1_WAKEMASK_P8; |
| 174 | 179 | |
| 180 | + /* | |
| 181 | + * This turns the irq soft-disabled state we're called with, into a | |
| 182 | + * hard-disabled state with pending irq_happened interrupts cleared. | |
| 183 | + * | |
| 184 | + * PACA_IRQ_DEC - Decrementer should be ignored. | |
| 185 | + * PACA_IRQ_HMI - Can be ignored, processing is done in real mode. | |
| 186 | + * PACA_IRQ_DBELL, EE, PMI - Unexpected. | |
| 187 | + */ | |
| 188 | + hard_irq_disable(); | |
| 189 | + if (generic_check_cpu_restart(cpu)) | |
| 190 | + goto out; | |
| 191 | + | |
| 192 | + unexpected_mask = ~(PACA_IRQ_DEC | PACA_IRQ_HMI | PACA_IRQ_HARD_DIS); | |
| 193 | + if (local_paca->irq_happened & unexpected_mask) { | |
| 194 | + if (local_paca->irq_happened & PACA_IRQ_EE) | |
| 195 | + pnv_flush_interrupts(); | |
| 196 | + DBG("CPU%d Unexpected exit while offline irq_happened=%lx!\n", | |
| 197 | + cpu, local_paca->irq_happened); | |
| 198 | + } | |
| 199 | + local_paca->irq_happened = PACA_IRQ_HARD_DIS; | |
| 200 | + | |
| 175 | 201 | /* |
| 176 | 202 | * We don't want to take decrementer interrupts while we are |
| 177 | 203 | * offline, so clear LPCR:PECE1. We keep PECE2 (and |
| @@ -197,6 +223,7 @@ static void pnv_smp_cpu_kill_self(void) · 19 unmodified lines | ||
| 197 | 223 | |
| 198 | 224 | srr1 = pnv_cpu_offline(cpu); |
| 199 | 225 | |
| 226 | + WARN_ON_ONCE(!irqs_disabled()); | |
| 200 | 227 | WARN_ON(lazy_irq_pending()); |
| 201 | 228 | |
| 202 | 229 | /* |
| @@ -212,13 +239,7 @@ static void pnv_smp_cpu_kill_self(void) · 9 unmodified lines | ||
| 212 | 239 | */ |
| 213 | 240 | if (((srr1 & wmask) == SRR1_WAKEEE) || |
| 214 | 241 | ((srr1 & wmask) == SRR1_WAKEHVI)) { |
| 215 | − if (cpu_has_feature(CPU_FTR_ARCH_300)) { | |
| 216 | − if (xive_enabled()) | |
| 217 | − xive_flush_interrupt(); | |
| 218 | − else | |
| 219 | − icp_opal_flush_interrupt(); | |
| 220 | − } else | |
| 221 | − icp_native_flush_interrupt(); | |
| 242 | + pnv_flush_interrupts(); | |
| 222 | 243 | } else if ((srr1 & wmask) == SRR1_WAKEHDBELL) { |
| 223 | 244 | unsigned long msg = PPC_DBELL_TYPE(PPC_DBELL_SERVER); |
| 224 | 245 | asm volatile(PPC_MSGCLR(%0) : : "r" (msg)); |
| @@ -266,7 +287,7 @@ static void pnv_smp_cpu_kill_self(void) · 41 unmodified lines | ||
| 266 | 287 | */ |
| 267 | 288 | lpcr_val = mfspr(SPRN_LPCR) | (u64)LPCR_PECE1; |
| 268 | 289 | pnv_program_cpu_hotplug_lpcr(cpu, lpcr_val); |
| 269 | − | |
| 290 | +out: | |
| 270 | 291 | DBG("CPU%d coming online...\n", cpu); |
| 271 | 292 | } |
| 272 | 293 | |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | #include <linux/types.h> |
| 15 | 15 | #include <asm/mmiowb.h> |
| 16 | +#include <asm/pgtable.h> | |
| 16 | 17 | |
| 17 | 18 | extern void __iomem *ioremap(phys_addr_t offset, unsigned long size); |
| 18 | 19 | |
| @@ -161,6 +162,12 @@ static inline u64 __raw_readq(const volatile void __iomem *addr) · 142 unmodified lines | ||
| 161 | 162 | #define writeq(v,c) ({ __io_bw(); writeq_cpu((v),(c)); __io_aw(); }) |
| 162 | 163 | #endif |
| 163 | 164 | |
| 165 | +/* | |
| 166 | + * I/O port access constants. | |
| 167 | + */ | |
| 168 | +#define IO_SPACE_LIMIT (PCI_IO_SIZE - 1) | |
| 169 | +#define PCI_IOBASE ((void __iomem *)PCI_IO_START) | |
| 170 | + | |
| 164 | 171 | /* |
| 165 | 172 | * Emulation routines for the port-mapped IO space used by some PCI drivers. |
| 166 | 173 | * These are defined as being "fully synchronous", but also "not guaranteed to |
| @@ -7,6 +7,9 @@ · 6 unmodified lines | ||
| 7 | 7 | #ifndef _ASM_RISCV_IRQ_H |
| 8 | 8 | #define _ASM_RISCV_IRQ_H |
| 9 | 9 | |
| 10 | +#include <linux/interrupt.h> | |
| 11 | +#include <linux/linkage.h> | |
| 12 | + | |
| 10 | 13 | #define NR_IRQS 0 |
| 11 | 14 | |
| 12 | 15 | void riscv_timer_interrupt(void); |
| @@ -7,6 +7,7 @@ · 6 unmodified lines | ||
| 7 | 7 | #define _ASM_RISCV_PGTABLE_H |
| 8 | 8 | |
| 9 | 9 | #include <linux/mmzone.h> |
| 10 | +#include <linux/sizes.h> | |
| 10 | 11 | |
| 11 | 12 | #include <asm/pgtable-bits.h> |
| 12 | 13 | |
| @@ -86,6 +87,7 @@ extern pgd_t swapper_pg_dir[]; · 73 unmodified lines | ||
| 86 | 87 | #define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) |
| 87 | 88 | #define VMALLOC_END (PAGE_OFFSET - 1) |
| 88 | 89 | #define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE) |
| 90 | +#define PCI_IO_SIZE SZ_16M | |
| 89 | 91 | |
| 90 | 92 | /* |
| 91 | 93 | * Roughly size the vmemmap space to be large enough to fit enough |
| @@ -100,7 +102,10 @@ extern pgd_t swapper_pg_dir[]; · 8 unmodified lines | ||
| 100 | 102 | |
| 101 | 103 | #define vmemmap ((struct page *)VMEMMAP_START) |
| 102 | 104 | |
| 103 | −#define FIXADDR_TOP (VMEMMAP_START) | |
| 105 | +#define PCI_IO_END VMEMMAP_START | |
| 106 | +#define PCI_IO_START (PCI_IO_END - PCI_IO_SIZE) | |
| 107 | +#define FIXADDR_TOP PCI_IO_START | |
| 108 | + | |
| 104 | 109 | #ifdef CONFIG_64BIT |
| 105 | 110 | #define FIXADDR_SIZE PMD_SIZE |
| 106 | 111 | #else |
| @@ -6,6 +6,7 @@ · 5 unmodified lines | ||
| 6 | 6 | #ifndef _ASM_RISCV_SWITCH_TO_H |
| 7 | 7 | #define _ASM_RISCV_SWITCH_TO_H |
| 8 | 8 | |
| 9 | +#include <linux/sched/task_stack.h> | |
| 9 | 10 | #include <asm/processor.h> |
| 10 | 11 | #include <asm/ptrace.h> |
| 11 | 12 | #include <asm/csr.h> |
| @@ -10,6 +10,7 @@ · 9 unmodified lines | ||
| 10 | 10 | #include <asm/processor.h> |
| 11 | 11 | #include <asm/hwcap.h> |
| 12 | 12 | #include <asm/smp.h> |
| 13 | +#include <asm/switch_to.h> | |
| 13 | 14 | |
| 14 | 15 | unsigned long elf_hwcap __read_mostly; |
| 15 | 16 | #ifdef CONFIG_FPU |
| @@ -0,0 +1,21 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ | |
| 2 | +/* | |
| 3 | + * Copyright (C) 2019 SiFive, Inc. | |
| 4 | + */ | |
| 5 | +#ifndef __ASM_HEAD_H | |
| 6 | +#define __ASM_HEAD_H | |
| 7 | + | |
| 8 | +#include <linux/linkage.h> | |
| 9 | +#include <linux/init.h> | |
| 10 | + | |
| 11 | +extern atomic_t hart_lottery; | |
| 12 | + | |
| 13 | +asmlinkage void do_page_fault(struct pt_regs *regs); | |
| 14 | +asmlinkage void __init setup_vm(uintptr_t dtb_pa); | |
| 15 | + | |
| 16 | +extern void *__cpu_up_stack_pointer[]; | |
| 17 | +extern void *__cpu_up_task_pointer[]; | |
| 18 | + | |
| 19 | +void __init parse_dtb(void); | |
| 20 | + | |
| 21 | +#endif /* __ASM_HEAD_H */ | |
| @@ -24,7 +24,7 @@ int arch_show_interrupts(struct seq_file *p, int prec) · 23 unmodified lines | ||
| 24 | 24 | return 0; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | −asmlinkage void __irq_entry do_IRQ(struct pt_regs *regs) | |
| 27 | +asmlinkage __visible void __irq_entry do_IRQ(struct pt_regs *regs) | |
| 28 | 28 | { |
| 29 | 29 | struct pt_regs *old_regs = set_irq_regs(regs); |
| 30 | 30 | |
| @@ -8,6 +8,7 @@ · 7 unmodified lines | ||
| 8 | 8 | #include <linux/elf.h> |
| 9 | 9 | #include <linux/kernel.h> |
| 10 | 10 | #include <linux/module.h> |
| 11 | +#include <linux/moduleloader.h> | |
| 11 | 12 | |
| 12 | 13 | unsigned long module_emit_got_entry(struct module *mod, unsigned long val) |
| 13 | 14 | { |
| @@ -7,6 +7,7 @@ · 6 unmodified lines | ||
| 7 | 7 | * Copyright (C) 2017 SiFive |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | +#include <linux/cpu.h> | |
| 10 | 11 | #include <linux/kernel.h> |
| 11 | 12 | #include <linux/sched.h> |
| 12 | 13 | #include <linux/sched/task_stack.h> |
| @@ -19,6 +20,7 @@ · 6 unmodified lines | ||
| 19 | 20 | #include <asm/csr.h> |
| 20 | 21 | #include <asm/string.h> |
| 21 | 22 | #include <asm/switch_to.h> |
| 23 | +#include <asm/thread_info.h> | |
| 22 | 24 | |
| 23 | 25 | extern asmlinkage void ret_from_fork(void); |
| 24 | 26 | extern asmlinkage void ret_from_kernel_thread(void); |
| @@ -148,7 +148,7 @@ long arch_ptrace(struct task_struct *child, long request, · 147 unmodified lines | ||
| 148 | 148 | * Allows PTRACE_SYSCALL to work. These are called from entry.S in |
| 149 | 149 | * {handle,ret_from}_syscall. |
| 150 | 150 | */ |
| 151 | −void do_syscall_trace_enter(struct pt_regs *regs) | |
| 151 | +__visible void do_syscall_trace_enter(struct pt_regs *regs) | |
| 152 | 152 | { |
| 153 | 153 | if (test_thread_flag(TIF_SYSCALL_TRACE)) |
| 154 | 154 | if (tracehook_report_syscall_entry(regs)) |
| @@ -162,7 +162,7 @@ void do_syscall_trace_enter(struct pt_regs *regs) · 7 unmodified lines | ||
| 162 | 162 | audit_syscall_entry(regs->a7, regs->a0, regs->a1, regs->a2, regs->a3); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | −void do_syscall_trace_exit(struct pt_regs *regs) | |
| 165 | +__visible void do_syscall_trace_exit(struct pt_regs *regs) | |
| 166 | 166 | { |
| 167 | 167 | audit_syscall_exit(regs); |
| 168 | 168 | |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | #include <linux/reboot.h> |
| 7 | +#include <linux/pm.h> | |
| 7 | 8 | #include <asm/sbi.h> |
| 8 | 9 | |
| 9 | 10 | static void default_power_off(void) |
| @@ -24,6 +24,8 @@ · 23 unmodified lines | ||
| 24 | 24 | #include <asm/tlbflush.h> |
| 25 | 25 | #include <asm/thread_info.h> |
| 26 | 26 | |
| 27 | +#include "head.h" | |
| 28 | + | |
| 27 | 29 | #ifdef CONFIG_DUMMY_CONSOLE |
| 28 | 30 | struct screen_info screen_info = { |
| 29 | 31 | .orig_video_lines = 30, |
| @@ -26,7 +26,7 @@ struct rt_sigframe { · 25 unmodified lines | ||
| 26 | 26 | |
| 27 | 27 | #ifdef CONFIG_FPU |
| 28 | 28 | static long restore_fp_state(struct pt_regs *regs, |
| 29 | − union __riscv_fp_state *sc_fpregs) | |
| 29 | + union __riscv_fp_state __user *sc_fpregs) | |
| 30 | 30 | { |
| 31 | 31 | long err; |
| 32 | 32 | struct __riscv_d_ext_state __user *state = &sc_fpregs->d; |
| @@ -53,7 +53,7 @@ static long restore_fp_state(struct pt_regs *regs, · 20 unmodified lines | ||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | static long save_fp_state(struct pt_regs *regs, |
| 56 | − union __riscv_fp_state *sc_fpregs) | |
| 56 | + union __riscv_fp_state __user *sc_fpregs) | |
| 57 | 57 | { |
| 58 | 58 | long err; |
| 59 | 59 | struct __riscv_d_ext_state __user *state = &sc_fpregs->d; |
| @@ -292,8 +292,8 @@ static void do_signal(struct pt_regs *regs) · 232 unmodified lines | ||
| 292 | 292 | * notification of userspace execution resumption |
| 293 | 293 | * - triggered by the _TIF_WORK_MASK flags |
| 294 | 294 | */ |
| 295 | −asmlinkage void do_notify_resume(struct pt_regs *regs, | |
| 296 | − unsigned long thread_info_flags) | |
| 295 | +asmlinkage __visible void do_notify_resume(struct pt_regs *regs, | |
| 296 | + unsigned long thread_info_flags) | |
| 297 | 297 | { |
| 298 | 298 | /* Handle pending signal delivery */ |
| 299 | 299 | if (thread_info_flags & _TIF_SIGPENDING) |
| @@ -8,7 +8,9 @@ · 7 unmodified lines | ||
| 8 | 8 | * Copyright (C) 2017 SiFive |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | +#include <linux/cpu.h> | |
| 11 | 12 | #include <linux/interrupt.h> |
| 13 | +#include <linux/profile.h> | |
| 12 | 14 | #include <linux/smp.h> |
| 13 | 15 | #include <linux/sched.h> |
| 14 | 16 | #include <linux/seq_file.h> |
| @@ -29,6 +29,9 @@ · 28 unmodified lines | ||
| 29 | 29 | #include <asm/tlbflush.h> |
| 30 | 30 | #include <asm/sections.h> |
| 31 | 31 | #include <asm/sbi.h> |
| 32 | +#include <asm/smp.h> | |
| 33 | + | |
| 34 | +#include "head.h" | |
| 32 | 35 | |
| 33 | 36 | void *__cpu_up_stack_pointer[NR_CPUS]; |
| 34 | 37 | void *__cpu_up_task_pointer[NR_CPUS]; |
| @@ -130,7 +133,7 @@ void __init smp_cpus_done(unsigned int max_cpus) · 95 unmodified lines | ||
| 130 | 133 | /* |
| 131 | 134 | * C entry point for a secondary processor. |
| 132 | 135 | */ |
| 133 | −asmlinkage void __init smp_callin(void) | |
| 136 | +asmlinkage __visible void __init smp_callin(void) | |
| 134 | 137 | { |
| 135 | 138 | struct mm_struct *mm = &init_mm; |
| 136 | 139 | |
| @@ -8,6 +8,7 @@ · 7 unmodified lines | ||
| 8 | 8 | #include <linux/syscalls.h> |
| 9 | 9 | #include <asm-generic/syscalls.h> |
| 10 | 10 | #include <asm/vdso.h> |
| 11 | +#include <asm/syscall.h> | |
| 11 | 12 | |
| 12 | 13 | #undef __SYSCALL |
| 13 | 14 | #define __SYSCALL(nr, call) [nr] = (call), |
| @@ -7,6 +7,7 @@ · 6 unmodified lines | ||
| 7 | 7 | #include <linux/clocksource.h> |
| 8 | 8 | #include <linux/delay.h> |
| 9 | 9 | #include <asm/sbi.h> |
| 10 | +#include <asm/processor.h> | |
| 10 | 11 | |
| 11 | 12 | unsigned long riscv_timebase; |
| 12 | 13 | EXPORT_SYMBOL_GPL(riscv_timebase); |
| @@ -3,6 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | * Copyright (C) 2012 Regents of the University of California |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | +#include <linux/cpu.h> | |
| 6 | 7 | #include <linux/kernel.h> |
| 7 | 8 | #include <linux/init.h> |
| 8 | 9 | #include <linux/sched.h> |
| @@ -83,7 +84,7 @@ static void do_trap_error(struct pt_regs *regs, int signo, int code, · 74 unmodified lines | ||
| 83 | 84 | } |
| 84 | 85 | |
| 85 | 86 | #define DO_ERROR_INFO(name, signo, code, str) \ |
| 86 | −asmlinkage void name(struct pt_regs *regs) \ | |
| 87 | +asmlinkage __visible void name(struct pt_regs *regs) \ | |
| 87 | 88 | { \ |
| 88 | 89 | do_trap_error(regs, signo, code, regs->sepc, "Oops - " str); \ |
| 89 | 90 | } |
| @@ -120,7 +121,7 @@ static inline unsigned long get_break_insn_length(unsigned long pc) · 30 unmodified lines | ||
| 120 | 121 | return (((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? 4UL : 2UL); |
| 121 | 122 | } |
| 122 | 123 | |
| 123 | −asmlinkage void do_trap_break(struct pt_regs *regs) | |
| 124 | +asmlinkage __visible void do_trap_break(struct pt_regs *regs) | |
| 124 | 125 | { |
| 125 | 126 | if (user_mode(regs)) |
| 126 | 127 | force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->sepc); |
| @@ -6,6 +6,7 @@ · 5 unmodified lines | ||
| 6 | 6 | * Copyright (C) 2015 Regents of the University of California |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | +#include <linux/elf.h> | |
| 9 | 10 | #include <linux/mm.h> |
| 10 | 11 | #include <linux/slab.h> |
| 11 | 12 | #include <linux/binfmts.h> |
| @@ -25,7 +26,7 @@ static union { · 13 unmodified lines | ||
| 25 | 26 | struct vdso_data data; |
| 26 | 27 | u8 page[PAGE_SIZE]; |
| 27 | 28 | } vdso_data_store __page_aligned_data; |
| 28 | −struct vdso_data *vdso_data = &vdso_data_store.data; | |
| 29 | +static struct vdso_data *vdso_data = &vdso_data_store.data; | |
| 29 | 30 | |
| 30 | 31 | static int __init vdso_init(void) |
| 31 | 32 | { |
| @@ -7,6 +7,7 @@ · 6 unmodified lines | ||
| 7 | 7 | #include <linux/mm.h> |
| 8 | 8 | #include <asm/tlbflush.h> |
| 9 | 9 | #include <asm/cacheflush.h> |
| 10 | +#include <asm/mmu_context.h> | |
| 10 | 11 | |
| 11 | 12 | /* |
| 12 | 13 | * When necessary, performs a deferred icache flush for the given MM context, |
| @@ -18,6 +18,8 @@ · 17 unmodified lines | ||
| 18 | 18 | #include <asm/ptrace.h> |
| 19 | 19 | #include <asm/tlbflush.h> |
| 20 | 20 | |
| 21 | +#include "../kernel/head.h" | |
| 22 | + | |
| 21 | 23 | /* |
| 22 | 24 | * This routine handles page faults. It determines the address and the |
| 23 | 25 | * problem, and then passes it off to one of the appropriate routines. |
| @@ -19,6 +19,8 @@ · 18 unmodified lines | ||
| 19 | 19 | #include <asm/pgtable.h> |
| 20 | 20 | #include <asm/io.h> |
| 21 | 21 | |
| 22 | +#include "../kernel/head.h" | |
| 23 | + | |
| 22 | 24 | unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] |
| 23 | 25 | __page_aligned_bss; |
| 24 | 26 | EXPORT_SYMBOL(empty_zero_page); |
| @@ -337,8 +339,7 @@ static uintptr_t __init best_map_size(phys_addr_t base, phys_addr_t size) · 312 unmodified lines | ||
| 337 | 339 | */ |
| 338 | 340 | |
| 339 | 341 | #ifndef __riscv_cmodel_medany |
| 340 | −#error "setup_vm() is called from head.S before relocate so it should " | |
| 341 | − "not use absolute addressing." | |
| 342 | +#error "setup_vm() is called from head.S before relocate so it should not use absolute addressing." | |
| 342 | 343 | #endif |
| 343 | 344 | |
| 344 | 345 | asmlinkage void __init setup_vm(uintptr_t dtb_pa) |
| @@ -142,7 +142,7 @@ static irqreturn_t l2_int_handler(int irq, void *device) · 141 unmodified lines | ||
| 142 | 142 | return IRQ_HANDLED; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | −int __init sifive_l2_init(void) | |
| 145 | +static int __init sifive_l2_init(void) | |
| 146 | 146 | { |
| 147 | 147 | struct device_node *np; |
| 148 | 148 | struct resource res; |
| @@ -35,6 +35,7 @@ struct unwind_state { · 34 unmodified lines | ||
| 35 | 35 | struct task_struct *task; |
| 36 | 36 | struct pt_regs *regs; |
| 37 | 37 | unsigned long sp, ip; |
| 38 | + bool reuse_sp; | |
| 38 | 39 | int graph_idx; |
| 39 | 40 | bool reliable; |
| 40 | 41 | bool error; |
| @@ -69,18 +69,26 @@ DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL); · 68 unmodified lines | ||
| 69 | 69 | static ssize_t show_idle_time(struct device *dev, |
| 70 | 70 | struct device_attribute *attr, char *buf) |
| 71 | 71 | { |
| 72 | + unsigned long long now, idle_time, idle_enter, idle_exit, in_idle; | |
| 72 | 73 | struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id); |
| 73 | − unsigned long long now, idle_time, idle_enter, idle_exit; | |
| 74 | 74 | unsigned int seq; |
| 75 | 75 | |
| 76 | 76 | do { |
| 77 | − now = get_tod_clock(); | |
| 78 | 77 | seq = read_seqcount_begin(&idle->seqcount); |
| 79 | 78 | idle_time = READ_ONCE(idle->idle_time); |
| 80 | 79 | idle_enter = READ_ONCE(idle->clock_idle_enter); |
| 81 | 80 | idle_exit = READ_ONCE(idle->clock_idle_exit); |
| 82 | 81 | } while (read_seqcount_retry(&idle->seqcount, seq)); |
| 83 | − idle_time += idle_enter ? ((idle_exit ? : now) - idle_enter) : 0; | |
| 82 | + in_idle = 0; | |
| 83 | + now = get_tod_clock(); | |
| 84 | + if (idle_enter) { | |
| 85 | + if (idle_exit) { | |
| 86 | + in_idle = idle_exit - idle_enter; | |
| 87 | + } else if (now > idle_enter) { | |
| 88 | + in_idle = now - idle_enter; | |
| 89 | + } | |
| 90 | + } | |
| 91 | + idle_time += in_idle; | |
| 84 | 92 | return sprintf(buf, "%llu\n", idle_time >> 12); |
| 85 | 93 | } |
| 86 | 94 | DEVICE_ATTR(idle_time_us, 0444, show_idle_time, NULL); |
| @@ -88,17 +96,24 @@ DEVICE_ATTR(idle_time_us, 0444, show_idle_time, NULL); · 1 unmodified line | ||
| 88 | 96 | u64 arch_cpu_idle_time(int cpu) |
| 89 | 97 | { |
| 90 | 98 | struct s390_idle_data *idle = &per_cpu(s390_idle, cpu); |
| 91 | − unsigned long long now, idle_enter, idle_exit; | |
| 99 | + unsigned long long now, idle_enter, idle_exit, in_idle; | |
| 92 | 100 | unsigned int seq; |
| 93 | 101 | |
| 94 | 102 | do { |
| 95 | − now = get_tod_clock(); | |
| 96 | 103 | seq = read_seqcount_begin(&idle->seqcount); |
| 97 | 104 | idle_enter = READ_ONCE(idle->clock_idle_enter); |
| 98 | 105 | idle_exit = READ_ONCE(idle->clock_idle_exit); |
| 99 | 106 | } while (read_seqcount_retry(&idle->seqcount, seq)); |
| 100 | − | |
| 101 | − return cputime_to_nsecs(idle_enter ? ((idle_exit ?: now) - idle_enter) : 0); | |
| 107 | + in_idle = 0; | |
| 108 | + now = get_tod_clock(); | |
| 109 | + if (idle_enter) { | |
| 110 | + if (idle_exit) { | |
| 111 | + in_idle = idle_exit - idle_enter; | |
| 112 | + } else if (now > idle_enter) { | |
| 113 | + in_idle = now - idle_enter; | |
| 114 | + } | |
| 115 | + } | |
| 116 | + return cputime_to_nsecs(in_idle); | |
| 102 | 117 | } |
| 103 | 118 | |
| 104 | 119 | void arch_cpu_idle_enter(void) |
| @@ -46,10 +46,15 @@ bool unwind_next_frame(struct unwind_state *state) · 45 unmodified lines | ||
| 46 | 46 | |
| 47 | 47 | regs = state->regs; |
| 48 | 48 | if (unlikely(regs)) { |
| 49 | − sp = READ_ONCE_NOCHECK(regs->gprs[15]); | |
| 50 | − if (unlikely(outside_of_stack(state, sp))) { | |
| 51 | − if (!update_stack_info(state, sp)) | |
| 52 | − goto out_err; | |
| 49 | + if (state->reuse_sp) { | |
| 50 | + sp = state->sp; | |
| 51 | + state->reuse_sp = false; | |
| 52 | + } else { | |
| 53 | + sp = READ_ONCE_NOCHECK(regs->gprs[15]); | |
| 54 | + if (unlikely(outside_of_stack(state, sp))) { | |
| 55 | + if (!update_stack_info(state, sp)) | |
| 56 | + goto out_err; | |
| 57 | + } | |
| 53 | 58 | } |
| 54 | 59 | sf = (struct stack_frame *) sp; |
| 55 | 60 | ip = READ_ONCE_NOCHECK(sf->gprs[8]); |
| @@ -107,9 +112,9 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task, · 51 unmodified lines | ||
| 107 | 112 | { |
| 108 | 113 | struct stack_info *info = &state->stack_info; |
| 109 | 114 | unsigned long *mask = &state->stack_mask; |
| 115 | + bool reliable, reuse_sp; | |
| 110 | 116 | struct stack_frame *sf; |
| 111 | 117 | unsigned long ip; |
| 112 | − bool reliable; | |
| 113 | 118 | |
| 114 | 119 | memset(state, 0, sizeof(*state)); |
| 115 | 120 | state->task = task; |
| @@ -134,10 +139,12 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task, · 18 unmodified lines | ||
| 134 | 139 | if (regs) { |
| 135 | 140 | ip = READ_ONCE_NOCHECK(regs->psw.addr); |
| 136 | 141 | reliable = true; |
| 142 | + reuse_sp = true; | |
| 137 | 143 | } else { |
| 138 | 144 | sf = (struct stack_frame *) sp; |
| 139 | 145 | ip = READ_ONCE_NOCHECK(sf->gprs[8]); |
| 140 | 146 | reliable = false; |
| 147 | + reuse_sp = false; | |
| 141 | 148 | } |
| 142 | 149 | |
| 143 | 150 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
| @@ -151,5 +158,6 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task, · 7 unmodified lines | ||
| 151 | 158 | state->sp = sp; |
| 152 | 159 | state->ip = ip; |
| 153 | 160 | state->reliable = reliable; |
| 161 | + state->reuse_sp = reuse_sp; | |
| 154 | 162 | } |
| 155 | 163 | EXPORT_SYMBOL_GPL(__unwind_start); |
| @@ -298,16 +298,16 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write, · 297 unmodified lines | ||
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | if (write) { |
| 301 | − len = *lenp; | |
| 302 | − if (copy_from_user(buf, buffer, | |
| 303 | − len > sizeof(buf) ? sizeof(buf) : len)) | |
| 301 | + len = min(*lenp, sizeof(buf)); | |
| 302 | + if (copy_from_user(buf, buffer, len)) | |
| 304 | 303 | return -EFAULT; |
| 305 | − buf[sizeof(buf) - 1] = '\0'; | |
| 304 | + buf[len - 1] = '\0'; | |
| 306 | 305 | cmm_skip_blanks(buf, &p); |
| 307 | 306 | nr = simple_strtoul(p, &p, 0); |
| 308 | 307 | cmm_skip_blanks(p, &p); |
| 309 | 308 | seconds = simple_strtoul(p, &p, 0); |
| 310 | 309 | cmm_set_timeout(nr, seconds); |
| 310 | + *ppos += *lenp; | |
| 311 | 311 | } else { |
| 312 | 312 | len = sprintf(buf, "%ld %ld\n", |
| 313 | 313 | cmm_timeout_pages, cmm_timeout_seconds); |
| @@ -315,9 +315,9 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write, · 1 unmodified line | ||
| 315 | 315 | len = *lenp; |
| 316 | 316 | if (copy_to_user(buffer, buf, len)) |
| 317 | 317 | return -EFAULT; |
| 318 | + *lenp = len; | |
| 319 | + *ppos += len; | |
| 318 | 320 | } |
| 319 | − *lenp = len; | |
| 320 | − *ppos += len; | |
| 321 | 321 | return 0; |
| 322 | 322 | } |
| 323 | 323 | |
| @@ -1403,8 +1403,12 @@ static blk_status_t ubd_queue_rq(struct blk_mq_hw_ctx *hctx, · 1402 unmodified lines | ||
| 1403 | 1403 | |
| 1404 | 1404 | spin_unlock_irq(&ubd_dev->lock); |
| 1405 | 1405 | |
| 1406 | − if (ret < 0) | |
| 1407 | − blk_mq_requeue_request(req, true); | |
| 1406 | + if (ret < 0) { | |
| 1407 | + if (ret == -ENOMEM) | |
| 1408 | + res = BLK_STS_RESOURCE; | |
| 1409 | + else | |
| 1410 | + res = BLK_STS_DEV_RESOURCE; | |
| 1411 | + } | |
| 1408 | 1412 | |
| 1409 | 1413 | return res; |
| 1410 | 1414 | } |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | ||
| 13 | 13 | #include <asm/e820/types.h> |
| 14 | 14 | #include <asm/setup.h> |
| 15 | 15 | #include <asm/desc.h> |
| 16 | +#include <asm/boot.h> | |
| 16 | 17 | |
| 17 | 18 | #include "../string.h" |
| 18 | 19 | #include "eboot.h" |
| @@ -813,7 +814,8 @@ efi_main(struct efi_config *c, struct boot_params *boot_params) · 794 unmodified lines | ||
| 813 | 814 | status = efi_relocate_kernel(sys_table, &bzimage_addr, |
| 814 | 815 | hdr->init_size, hdr->init_size, |
| 815 | 816 | hdr->pref_address, |
| 816 | − hdr->kernel_alignment); | |
| 817 | + hdr->kernel_alignment, | |
| 818 | + LOAD_PHYSICAL_ADDR); | |
| 817 | 819 | if (status != EFI_SUCCESS) { |
| 818 | 820 | efi_printk(sys_table, "efi_relocate_kernel() failed!\n"); |
| 819 | 821 | goto fail; |
| @@ -1586,9 +1586,6 @@ static void setup_local_APIC(void) · 1585 unmodified lines | ||
| 1586 | 1586 | { |
| 1587 | 1587 | int cpu = smp_processor_id(); |
| 1588 | 1588 | unsigned int value; |
| 1589 | −#ifdef CONFIG_X86_32 | |
| 1590 | − int logical_apicid, ldr_apicid; | |
| 1591 | −#endif | |
| 1592 | 1589 | |
| 1593 | 1590 | if (disable_apic) { |
| 1594 | 1591 | disable_ioapic_support(); |
| @@ -1626,16 +1623,21 @@ static void setup_local_APIC(void) · 31 unmodified lines | ||
| 1626 | 1623 | apic->init_apic_ldr(); |
| 1627 | 1624 | |
| 1628 | 1625 | #ifdef CONFIG_X86_32 |
| 1629 | − /* | |
| 1630 | − * APIC LDR is initialized. If logical_apicid mapping was | |
| 1631 | − * initialized during get_smp_config(), make sure it matches the | |
| 1632 | − * actual value. | |
| 1633 | − */ | |
| 1634 | − logical_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu); | |
| 1635 | − ldr_apicid = GET_APIC_LOGICAL_ID(apic_read(APIC_LDR)); | |
| 1636 | − WARN_ON(logical_apicid != BAD_APICID && logical_apicid != ldr_apicid); | |
| 1637 | − /* always use the value from LDR */ | |
| 1638 | − early_per_cpu(x86_cpu_to_logical_apicid, cpu) = ldr_apicid; | |
| 1626 | + if (apic->dest_logical) { | |
| 1627 | + int logical_apicid, ldr_apicid; | |
| 1628 | + | |
| 1629 | + /* | |
| 1630 | + * APIC LDR is initialized. If logical_apicid mapping was | |
| 1631 | + * initialized during get_smp_config(), make sure it matches | |
| 1632 | + * the actual value. | |
| 1633 | + */ | |
| 1634 | + logical_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu); | |
| 1635 | + ldr_apicid = GET_APIC_LOGICAL_ID(apic_read(APIC_LDR)); | |
| 1636 | + if (logical_apicid != BAD_APICID) | |
| 1637 | + WARN_ON(logical_apicid != ldr_apicid); | |
| 1638 | + /* Always use the value from LDR. */ | |
| 1639 | + early_per_cpu(x86_cpu_to_logical_apicid, cpu) = ldr_apicid; | |
| 1640 | + } | |
| 1639 | 1641 | #endif |
| 1640 | 1642 | |
| 1641 | 1643 | /* |
| @@ -522,6 +522,10 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) · 521 unmodified lines | ||
| 522 | 522 | int ret = 0; |
| 523 | 523 | |
| 524 | 524 | rdtgrp = rdtgroup_kn_lock_live(of->kn); |
| 525 | + if (!rdtgrp) { | |
| 526 | + ret = -ENOENT; | |
| 527 | + goto out; | |
| 528 | + } | |
| 525 | 529 | |
| 526 | 530 | md.priv = of->kn->priv; |
| 527 | 531 | resid = md.u.rid; |
| @@ -94,6 +94,13 @@ static bool in_exception_stack(unsigned long *stack, struct stack_info *info) · 93 unmodified lines | ||
| 94 | 94 | BUILD_BUG_ON(N_EXCEPTION_STACKS != 6); |
| 95 | 95 | |
| 96 | 96 | begin = (unsigned long)__this_cpu_read(cea_exception_stacks); |
| 97 | + /* | |
| 98 | + * Handle the case where stack trace is collected _before_ | |
| 99 | + * cea_exception_stacks had been initialized. | |
| 100 | + */ | |
| 101 | + if (!begin) | |
| 102 | + return false; | |
| 103 | + | |
| 97 | 104 | end = begin + sizeof(struct cea_exception_stacks); |
| 98 | 105 | /* Bail if @stack is outside the exception stack area. */ |
| 99 | 106 | if (stk < begin || stk >= end) |
| @@ -1505,6 +1505,9 @@ void __init tsc_init(void) · 1504 unmodified lines | ||
| 1505 | 1505 | return; |
| 1506 | 1506 | } |
| 1507 | 1507 | |
| 1508 | + if (tsc_clocksource_reliable || no_tsc_watchdog) | |
| 1509 | + clocksource_tsc_early.flags &= ~CLOCK_SOURCE_MUST_VERIFY; | |
| 1510 | + | |
| 1508 | 1511 | clocksource_register_khz(&clocksource_tsc_early, tsc_khz); |
| 1509 | 1512 | detect_art(); |
| 1510 | 1513 | } |
| @@ -734,8 +734,14 @@ static int get_npt_level(struct kvm_vcpu *vcpu) · 733 unmodified lines | ||
| 734 | 734 | static void svm_set_efer(struct kvm_vcpu *vcpu, u64 efer) |
| 735 | 735 | { |
| 736 | 736 | vcpu->arch.efer = efer; |
| 737 | − if (!npt_enabled && !(efer & EFER_LMA)) | |
| 738 | − efer &= ~EFER_LME; | |
| 737 | + | |
| 738 | + if (!npt_enabled) { | |
| 739 | + /* Shadow paging assumes NX to be available. */ | |
| 740 | + efer |= EFER_NX; | |
| 741 | + | |
| 742 | + if (!(efer & EFER_LMA)) | |
| 743 | + efer &= ~EFER_LME; | |
| 744 | + } | |
| 739 | 745 | |
| 740 | 746 | to_svm(vcpu)->vmcb->save.efer = efer | EFER_SVME; |
| 741 | 747 | mark_dirty(to_svm(vcpu)->vmcb, VMCB_CR); |
| @@ -969,17 +969,9 @@ static bool update_transition_efer(struct vcpu_vmx *vmx, int efer_offset) · 968 unmodified lines | ||
| 969 | 969 | u64 guest_efer = vmx->vcpu.arch.efer; |
| 970 | 970 | u64 ignore_bits = 0; |
| 971 | 971 | |
| 972 | − if (!enable_ept) { | |
| 973 | − /* | |
| 974 | − * NX is needed to handle CR0.WP=1, CR4.SMEP=1. Testing | |
| 975 | − * host CPUID is more efficient than testing guest CPUID | |
| 976 | − * or CR4. Host SMEP is anyway a requirement for guest SMEP. | |
| 977 | − */ | |
| 978 | − if (boot_cpu_has(X86_FEATURE_SMEP)) | |
| 979 | − guest_efer |= EFER_NX; | |
| 980 | − else if (!(guest_efer & EFER_NX)) | |
| 981 | − ignore_bits |= EFER_NX; | |
| 982 | − } | |
| 972 | + /* Shadow paging assumes NX to be available. */ | |
| 973 | + if (!enable_ept) | |
| 974 | + guest_efer |= EFER_NX; | |
| 983 | 975 | |
| 984 | 976 | /* |
| 985 | 977 | * LMA and LME handled by hardware; SCE meaningless outside long mode. |
| @@ -934,9 +934,14 @@ static int blkcg_print_stat(struct seq_file *sf, void *v) · 933 unmodified lines | ||
| 934 | 934 | int i; |
| 935 | 935 | bool has_stats = false; |
| 936 | 936 | |
| 937 | + spin_lock_irq(&blkg->q->queue_lock); | |
| 938 | + | |
| 939 | + if (!blkg->online) | |
| 940 | + goto skip; | |
| 941 | + | |
| 937 | 942 | dname = blkg_dev_name(blkg); |
| 938 | 943 | if (!dname) |
| 939 | − continue; | |
| 944 | + goto skip; | |
| 940 | 945 | |
| 941 | 946 | /* |
| 942 | 947 | * Hooray string manipulation, count is the size written NOT |
| @@ -946,8 +951,6 @@ static int blkcg_print_stat(struct seq_file *sf, void *v) · 3 unmodified lines | ||
| 946 | 951 | */ |
| 947 | 952 | off += scnprintf(buf+off, size-off, "%s ", dname); |
| 948 | 953 | |
| 949 | − spin_lock_irq(&blkg->q->queue_lock); | |
| 950 | − | |
| 951 | 954 | blkg_rwstat_recursive_sum(blkg, NULL, |
| 952 | 955 | offsetof(struct blkcg_gq, stat_bytes), &rwstat); |
| 953 | 956 | rbytes = rwstat.cnt[BLKG_RWSTAT_READ]; |
| @@ -960,8 +963,6 @@ static int blkcg_print_stat(struct seq_file *sf, void *v) · 6 unmodified lines | ||
| 960 | 963 | wios = rwstat.cnt[BLKG_RWSTAT_WRITE]; |
| 961 | 964 | dios = rwstat.cnt[BLKG_RWSTAT_DISCARD]; |
| 962 | 965 | |
| 963 | − spin_unlock_irq(&blkg->q->queue_lock); | |
| 964 | − | |
| 965 | 966 | if (rbytes || wbytes || rios || wios) { |
| 966 | 967 | has_stats = true; |
| 967 | 968 | off += scnprintf(buf+off, size-off, |
| @@ -999,6 +1000,8 @@ static int blkcg_print_stat(struct seq_file *sf, void *v) · 31 unmodified lines | ||
| 999 | 1000 | seq_commit(sf, -1); |
| 1000 | 1001 | } |
| 1001 | 1002 | } |
| 1003 | + skip: | |
| 1004 | + spin_unlock_irq(&blkg->q->queue_lock); | |
| 1002 | 1005 | } |
| 1003 | 1006 | |
| 1004 | 1007 | rcu_read_unlock(); |
| @@ -2110,10 +2110,10 @@ static ssize_t ioc_weight_write(struct kernfs_open_file *of, char *buf, · 2109 unmodified lines | ||
| 2110 | 2110 | goto einval; |
| 2111 | 2111 | } |
| 2112 | 2112 | |
| 2113 | − spin_lock_irq(&iocg->ioc->lock); | |
| 2113 | + spin_lock(&iocg->ioc->lock); | |
| 2114 | 2114 | iocg->cfg_weight = v; |
| 2115 | 2115 | weight_updated(iocg); |
| 2116 | − spin_unlock_irq(&iocg->ioc->lock); | |
| 2116 | + spin_unlock(&iocg->ioc->lock); | |
| 2117 | 2117 | |
| 2118 | 2118 | blkg_conf_finish(&ctx); |
| 2119 | 2119 | return nbytes; |
| @@ -159,26 +159,34 @@ void acpi_processor_ignore_ppc_init(void) · 158 unmodified lines | ||
| 159 | 159 | |
| 160 | 160 | void acpi_processor_ppc_init(struct cpufreq_policy *policy) |
| 161 | 161 | { |
| 162 | − int cpu = policy->cpu; | |
| 163 | − struct acpi_processor *pr = per_cpu(processors, cpu); | |
| 164 | − int ret; | |
| 162 | + unsigned int cpu; | |
| 165 | 163 | |
| 166 | − if (!pr) | |
| 167 | − return; | |
| 164 | + for_each_cpu(cpu, policy->related_cpus) { | |
| 165 | + struct acpi_processor *pr = per_cpu(processors, cpu); | |
| 166 | + int ret; | |
| 167 | + | |
| 168 | + if (!pr) | |
| 169 | + continue; | |
| 168 | 170 | |
| 169 | − ret = freq_qos_add_request(&policy->constraints, &pr->perflib_req, | |
| 170 | − FREQ_QOS_MAX, INT_MAX); | |
| 171 | − if (ret < 0) | |
| 172 | − pr_err("Failed to add freq constraint for CPU%d (%d)\n", cpu, | |
| 173 | − ret); | |
| 171 | + ret = freq_qos_add_request(&policy->constraints, | |
| 172 | + &pr->perflib_req, | |
| 173 | + FREQ_QOS_MAX, INT_MAX); | |
| 174 | + if (ret < 0) | |
| 175 | + pr_err("Failed to add freq constraint for CPU%d (%d)\n", | |
| 176 | + cpu, ret); | |
| 177 | + } | |
| 174 | 178 | } |
| 175 | 179 | |
| 176 | 180 | void acpi_processor_ppc_exit(struct cpufreq_policy *policy) |
| 177 | 181 | { |
| 178 | − struct acpi_processor *pr = per_cpu(processors, policy->cpu); | |
| 182 | + unsigned int cpu; | |
| 179 | 183 | |
| 180 | − if (pr) | |
| 181 | − freq_qos_remove_request(&pr->perflib_req); | |
| 184 | + for_each_cpu(cpu, policy->related_cpus) { | |
| 185 | + struct acpi_processor *pr = per_cpu(processors, cpu); | |
| 186 | + | |
| 187 | + if (pr) | |
| 188 | + freq_qos_remove_request(&pr->perflib_req); | |
| 189 | + } | |
| 182 | 190 | } |
| 183 | 191 | |
| 184 | 192 | static int acpi_processor_get_performance_control(struct acpi_processor *pr) |
| @@ -127,26 +127,34 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state) · 126 unmodified lines | ||
| 127 | 127 | |
| 128 | 128 | void acpi_thermal_cpufreq_init(struct cpufreq_policy *policy) |
| 129 | 129 | { |
| 130 | − int cpu = policy->cpu; | |
| 131 | − struct acpi_processor *pr = per_cpu(processors, cpu); | |
| 132 | − int ret; | |
| 130 | + unsigned int cpu; | |
| 133 | 131 | |
| 134 | − if (!pr) | |
| 135 | − return; | |
| 132 | + for_each_cpu(cpu, policy->related_cpus) { | |
| 133 | + struct acpi_processor *pr = per_cpu(processors, cpu); | |
| 134 | + int ret; | |
| 135 | + | |
| 136 | + if (!pr) | |
| 137 | + continue; | |
| 136 | 138 | |
| 137 | − ret = freq_qos_add_request(&policy->constraints, &pr->thermal_req, | |
| 138 | − FREQ_QOS_MAX, INT_MAX); | |
| 139 | − if (ret < 0) | |
| 140 | − pr_err("Failed to add freq constraint for CPU%d (%d)\n", cpu, | |
| 141 | − ret); | |
| 139 | + ret = freq_qos_add_request(&policy->constraints, | |
| 140 | + &pr->thermal_req, | |
| 141 | + FREQ_QOS_MAX, INT_MAX); | |
| 142 | + if (ret < 0) | |
| 143 | + pr_err("Failed to add freq constraint for CPU%d (%d)\n", | |
| 144 | + cpu, ret); | |
| 145 | + } | |
| 142 | 146 | } |
| 143 | 147 | |
| 144 | 148 | void acpi_thermal_cpufreq_exit(struct cpufreq_policy *policy) |
| 145 | 149 | { |
| 146 | − struct acpi_processor *pr = per_cpu(processors, policy->cpu); | |
| 150 | + unsigned int cpu; | |
| 151 | + | |
| 152 | + for_each_cpu(cpu, policy->related_cpus) { | |
| 153 | + struct acpi_processor *pr = per_cpu(processors, policy->cpu); | |
| 147 | 154 | |
| 148 | − if (pr) | |
| 149 | − freq_qos_remove_request(&pr->thermal_req); | |
| 155 | + if (pr) | |
| 156 | + freq_qos_remove_request(&pr->thermal_req); | |
| 157 | + } | |
| 150 | 158 | } |
| 151 | 159 | #else /* ! CONFIG_CPU_FREQ */ |
| 152 | 160 | static int cpufreq_get_max_state(unsigned int cpu) |
| @@ -786,7 +786,6 @@ int __drbd_send_protocol(struct drbd_connection *connection, enum drbd_packet cm · 785 unmodified lines | ||
| 786 | 786 | |
| 787 | 787 | if (nc->tentative && connection->agreed_pro_version < 92) { |
| 788 | 788 | rcu_read_unlock(); |
| 789 | − mutex_unlock(&sock->mutex); | |
| 790 | 789 | drbd_err(connection, "--dry-run is not supported by peer"); |
| 791 | 790 | return -EOPNOTSUPP; |
| 792 | 791 | } |
| @@ -297,7 +297,10 @@ static int clk_main_probe_frequency(struct regmap *regmap) · 296 unmodified lines | ||
| 297 | 297 | regmap_read(regmap, AT91_CKGR_MCFR, &mcfr); |
| 298 | 298 | if (mcfr & AT91_PMC_MAINRDY) |
| 299 | 299 | return 0; |
| 300 | − usleep_range(MAINF_LOOP_MIN_WAIT, MAINF_LOOP_MAX_WAIT); | |
| 300 | + if (system_state < SYSTEM_RUNNING) | |
| 301 | + udelay(MAINF_LOOP_MIN_WAIT); | |
| 302 | + else | |
| 303 | + usleep_range(MAINF_LOOP_MIN_WAIT, MAINF_LOOP_MAX_WAIT); | |
| 301 | 304 | } while (time_before(prep_time, timeout)); |
| 302 | 305 | |
| 303 | 306 | return -ETIMEDOUT; |
| @@ -43,6 +43,7 @@ static const struct clk_pll_characteristics upll_characteristics = { · 42 unmodified lines | ||
| 43 | 43 | }; |
| 44 | 44 | |
| 45 | 45 | static const struct clk_programmable_layout sam9x60_programmable_layout = { |
| 46 | + .pres_mask = 0xff, | |
| 46 | 47 | .pres_shift = 8, |
| 47 | 48 | .css_mask = 0x1f, |
| 48 | 49 | .have_slck_mck = 0, |
| @@ -76,7 +76,10 @@ static int clk_slow_osc_prepare(struct clk_hw *hw) · 75 unmodified lines | ||
| 76 | 76 | |
| 77 | 77 | writel(tmp | osc->bits->cr_osc32en, sckcr); |
| 78 | 78 | |
| 79 | − usleep_range(osc->startup_usec, osc->startup_usec + 1); | |
| 79 | + if (system_state < SYSTEM_RUNNING) | |
| 80 | + udelay(osc->startup_usec); | |
| 81 | + else | |
| 82 | + usleep_range(osc->startup_usec, osc->startup_usec + 1); | |
| 80 | 83 | |
| 81 | 84 | return 0; |
| 82 | 85 | } |
| @@ -187,7 +190,10 @@ static int clk_slow_rc_osc_prepare(struct clk_hw *hw) · 104 unmodified lines | ||
| 187 | 190 | |
| 188 | 191 | writel(readl(sckcr) | osc->bits->cr_rcen, sckcr); |
| 189 | 192 | |
| 190 | − usleep_range(osc->startup_usec, osc->startup_usec + 1); | |
| 193 | + if (system_state < SYSTEM_RUNNING) | |
| 194 | + udelay(osc->startup_usec); | |
| 195 | + else | |
| 196 | + usleep_range(osc->startup_usec, osc->startup_usec + 1); | |
| 191 | 197 | |
| 192 | 198 | return 0; |
| 193 | 199 | } |
| @@ -288,7 +294,10 @@ static int clk_sam9x5_slow_set_parent(struct clk_hw *hw, u8 index) · 94 unmodified lines | ||
| 288 | 294 | |
| 289 | 295 | writel(tmp, sckcr); |
| 290 | 296 | |
| 291 | − usleep_range(SLOWCK_SW_TIME_USEC, SLOWCK_SW_TIME_USEC + 1); | |
| 297 | + if (system_state < SYSTEM_RUNNING) | |
| 298 | + udelay(SLOWCK_SW_TIME_USEC); | |
| 299 | + else | |
| 300 | + usleep_range(SLOWCK_SW_TIME_USEC, SLOWCK_SW_TIME_USEC + 1); | |
| 292 | 301 | |
| 293 | 302 | return 0; |
| 294 | 303 | } |
| @@ -533,7 +542,10 @@ static int clk_sama5d4_slow_osc_prepare(struct clk_hw *hw) · 238 unmodified lines | ||
| 533 | 542 | return 0; |
| 534 | 543 | } |
| 535 | 544 | |
| 536 | − usleep_range(osc->startup_usec, osc->startup_usec + 1); | |
| 545 | + if (system_state < SYSTEM_RUNNING) | |
| 546 | + udelay(osc->startup_usec); | |
| 547 | + else | |
| 548 | + usleep_range(osc->startup_usec, osc->startup_usec + 1); | |
| 537 | 549 | osc->prepared = true; |
| 538 | 550 | |
| 539 | 551 | return 0; |
| @@ -266,10 +266,11 @@ static int aspeed_g6_clk_enable(struct clk_hw *hw) · 265 unmodified lines | ||
| 266 | 266 | |
| 267 | 267 | /* Enable clock */ |
| 268 | 268 | if (gate->flags & CLK_GATE_SET_TO_DISABLE) { |
| 269 | − regmap_write(gate->map, get_clock_reg(gate), clk); | |
| 270 | − } else { | |
| 271 | − /* Use set to clear register */ | |
| 269 | + /* Clock is clear to enable, so use set to clear register */ | |
| 272 | 270 | regmap_write(gate->map, get_clock_reg(gate) + 0x04, clk); |
| 271 | + } else { | |
| 272 | + /* Clock is set to enable, so use write to set register */ | |
| 273 | + regmap_write(gate->map, get_clock_reg(gate), clk); | |
| 273 | 274 | } |
| 274 | 275 | |
| 275 | 276 | if (gate->reset_idx >= 0) { |
| @@ -638,7 +638,7 @@ static int imx8mm_clocks_probe(struct platform_device *pdev) · 637 unmodified lines | ||
| 638 | 638 | clks[IMX8MM_CLK_A53_DIV], |
| 639 | 639 | clks[IMX8MM_CLK_A53_SRC], |
| 640 | 640 | clks[IMX8MM_ARM_PLL_OUT], |
| 641 | − clks[IMX8MM_CLK_24M]); | |
| 641 | + clks[IMX8MM_SYS_PLL1_800M]); | |
| 642 | 642 | |
| 643 | 643 | imx_check_clocks(clks, ARRAY_SIZE(clks)); |
| 644 | 644 | |
| @@ -610,7 +610,7 @@ static int imx8mn_clocks_probe(struct platform_device *pdev) · 609 unmodified lines | ||
| 610 | 610 | clks[IMX8MN_CLK_A53_DIV], |
| 611 | 611 | clks[IMX8MN_CLK_A53_SRC], |
| 612 | 612 | clks[IMX8MN_ARM_PLL_OUT], |
| 613 | − clks[IMX8MN_CLK_24M]); | |
| 613 | + clks[IMX8MN_SYS_PLL1_800M]); | |
| 614 | 614 | |
| 615 | 615 | imx_check_clocks(clks, ARRAY_SIZE(clks)); |
| 616 | 616 | |
| @@ -343,6 +343,7 @@ static struct clk_regmap g12a_cpu_clk_premux0 = { · 342 unmodified lines | ||
| 343 | 343 | .offset = HHI_SYS_CPU_CLK_CNTL0, |
| 344 | 344 | .mask = 0x3, |
| 345 | 345 | .shift = 0, |
| 346 | + .flags = CLK_MUX_ROUND_CLOSEST, | |
| 346 | 347 | }, |
| 347 | 348 | .hw.init = &(struct clk_init_data){ |
| 348 | 349 | .name = "cpu_clk_dyn0_sel", |
| @@ -353,8 +354,7 @@ static struct clk_regmap g12a_cpu_clk_premux0 = { · 4 unmodified lines | ||
| 353 | 354 | { .hw = &g12a_fclk_div3.hw }, |
| 354 | 355 | }, |
| 355 | 356 | .num_parents = 3, |
| 356 | − /* This sub-tree is used a parking clock */ | |
| 357 | − .flags = CLK_SET_RATE_NO_REPARENT, | |
| 357 | + .flags = CLK_SET_RATE_PARENT, | |
| 358 | 358 | }, |
| 359 | 359 | }; |
| 360 | 360 | |
| @@ -410,6 +410,7 @@ static struct clk_regmap g12a_cpu_clk_postmux0 = { · 49 unmodified lines | ||
| 410 | 410 | .offset = HHI_SYS_CPU_CLK_CNTL0, |
| 411 | 411 | .mask = 0x1, |
| 412 | 412 | .shift = 2, |
| 413 | + .flags = CLK_MUX_ROUND_CLOSEST, | |
| 413 | 414 | }, |
| 414 | 415 | .hw.init = &(struct clk_init_data){ |
| 415 | 416 | .name = "cpu_clk_dyn0", |
| @@ -466,6 +467,7 @@ static struct clk_regmap g12a_cpu_clk_dyn = { · 50 unmodified lines | ||
| 466 | 467 | .offset = HHI_SYS_CPU_CLK_CNTL0, |
| 467 | 468 | .mask = 0x1, |
| 468 | 469 | .shift = 10, |
| 470 | + .flags = CLK_MUX_ROUND_CLOSEST, | |
| 469 | 471 | }, |
| 470 | 472 | .hw.init = &(struct clk_init_data){ |
| 471 | 473 | .name = "cpu_clk_dyn", |
| @@ -485,6 +487,7 @@ static struct clk_regmap g12a_cpu_clk = { · 13 unmodified lines | ||
| 485 | 487 | .offset = HHI_SYS_CPU_CLK_CNTL0, |
| 486 | 488 | .mask = 0x1, |
| 487 | 489 | .shift = 11, |
| 490 | + .flags = CLK_MUX_ROUND_CLOSEST, | |
| 488 | 491 | }, |
| 489 | 492 | .hw.init = &(struct clk_init_data){ |
| 490 | 493 | .name = "cpu_clk", |
| @@ -504,6 +507,7 @@ static struct clk_regmap g12b_cpu_clk = { · 13 unmodified lines | ||
| 504 | 507 | .offset = HHI_SYS_CPU_CLK_CNTL0, |
| 505 | 508 | .mask = 0x1, |
| 506 | 509 | .shift = 11, |
| 510 | + .flags = CLK_MUX_ROUND_CLOSEST, | |
| 507 | 511 | }, |
| 508 | 512 | .hw.init = &(struct clk_init_data){ |
| 509 | 513 | .name = "cpu_clk", |
| @@ -523,6 +527,7 @@ static struct clk_regmap g12b_cpub_clk_premux0 = { · 13 unmodified lines | ||
| 523 | 527 | .offset = HHI_SYS_CPUB_CLK_CNTL, |
| 524 | 528 | .mask = 0x3, |
| 525 | 529 | .shift = 0, |
| 530 | + .flags = CLK_MUX_ROUND_CLOSEST, | |
| 526 | 531 | }, |
| 527 | 532 | .hw.init = &(struct clk_init_data){ |
| 528 | 533 | .name = "cpub_clk_dyn0_sel", |
| @@ -533,6 +538,7 @@ static struct clk_regmap g12b_cpub_clk_premux0 = { · 4 unmodified lines | ||
| 533 | 538 | { .hw = &g12a_fclk_div3.hw }, |
| 534 | 539 | }, |
| 535 | 540 | .num_parents = 3, |
| 541 | + .flags = CLK_SET_RATE_PARENT, | |
| 536 | 542 | }, |
| 537 | 543 | }; |
| 538 | 544 | |
| @@ -567,6 +573,7 @@ static struct clk_regmap g12b_cpub_clk_postmux0 = { · 28 unmodified lines | ||
| 567 | 573 | .offset = HHI_SYS_CPUB_CLK_CNTL, |
| 568 | 574 | .mask = 0x1, |
| 569 | 575 | .shift = 2, |
| 576 | + .flags = CLK_MUX_ROUND_CLOSEST, | |
| 570 | 577 | }, |
| 571 | 578 | .hw.init = &(struct clk_init_data){ |
| 572 | 579 | .name = "cpub_clk_dyn0", |
| @@ -644,6 +651,7 @@ static struct clk_regmap g12b_cpub_clk_dyn = { · 71 unmodified lines | ||
| 644 | 651 | .offset = HHI_SYS_CPUB_CLK_CNTL, |
| 645 | 652 | .mask = 0x1, |
| 646 | 653 | .shift = 10, |
| 654 | + .flags = CLK_MUX_ROUND_CLOSEST, | |
| 647 | 655 | }, |
| 648 | 656 | .hw.init = &(struct clk_init_data){ |
| 649 | 657 | .name = "cpub_clk_dyn", |
| @@ -663,6 +671,7 @@ static struct clk_regmap g12b_cpub_clk = { · 13 unmodified lines | ||
| 663 | 671 | .offset = HHI_SYS_CPUB_CLK_CNTL, |
| 664 | 672 | .mask = 0x1, |
| 665 | 673 | .shift = 11, |
| 674 | + .flags = CLK_MUX_ROUND_CLOSEST, | |
| 666 | 675 | }, |
| 667 | 676 | .hw.init = &(struct clk_init_data){ |
| 668 | 677 | .name = "cpub_clk", |
| @@ -935,6 +935,7 @@ static struct clk_regmap gxbb_sar_adc_clk_div = { · 934 unmodified lines | ||
| 935 | 935 | &gxbb_sar_adc_clk_sel.hw |
| 936 | 936 | }, |
| 937 | 937 | .num_parents = 1, |
| 938 | + .flags = CLK_SET_RATE_PARENT, | |
| 938 | 939 | }, |
| 939 | 940 | }; |
| 940 | 941 | |
| @@ -165,12 +165,18 @@ static const unsigned long exynos5x_clk_regs[] __initconst = { · 164 unmodified lines | ||
| 165 | 165 | GATE_BUS_CPU, |
| 166 | 166 | GATE_SCLK_CPU, |
| 167 | 167 | CLKOUT_CMU_CPU, |
| 168 | + CPLL_CON0, | |
| 169 | + DPLL_CON0, | |
| 168 | 170 | EPLL_CON0, |
| 169 | 171 | EPLL_CON1, |
| 170 | 172 | EPLL_CON2, |
| 171 | 173 | RPLL_CON0, |
| 172 | 174 | RPLL_CON1, |
| 173 | 175 | RPLL_CON2, |
| 176 | + IPLL_CON0, | |
| 177 | + SPLL_CON0, | |
| 178 | + VPLL_CON0, | |
| 179 | + MPLL_CON0, | |
| 174 | 180 | SRC_TOP0, |
| 175 | 181 | SRC_TOP1, |
| 176 | 182 | SRC_TOP2, |
| @@ -1172,8 +1178,6 @@ static const struct samsung_gate_clock exynos5x_gate_clks[] __initconst = { · 995 unmodified lines | ||
| 1172 | 1178 | GATE(CLK_SCLK_ISP_SENSOR2, "sclk_isp_sensor2", "dout_isp_sensor2", |
| 1173 | 1179 | GATE_TOP_SCLK_ISP, 12, CLK_SET_RATE_PARENT, 0), |
| 1174 | 1180 | |
| 1175 | − GATE(CLK_G3D, "g3d", "mout_user_aclk_g3d", GATE_IP_G3D, 9, 0, 0), | |
| 1176 | − | |
| 1177 | 1181 | /* CDREX */ |
| 1178 | 1182 | GATE(CLK_CLKM_PHY0, "clkm_phy0", "dout_sclk_cdrex", |
| 1179 | 1183 | GATE_BUS_CDREX0, 0, 0, 0), |
| @@ -1248,6 +1252,15 @@ static struct exynos5_subcmu_reg_dump exynos5x_gsc_suspend_regs[] = { · 68 unmodified lines | ||
| 1248 | 1252 | { DIV2_RATIO0, 0, 0x30 }, /* DIV dout_gscl_blk_300 */ |
| 1249 | 1253 | }; |
| 1250 | 1254 | |
| 1255 | +static const struct samsung_gate_clock exynos5x_g3d_gate_clks[] __initconst = { | |
| 1256 | + GATE(CLK_G3D, "g3d", "mout_user_aclk_g3d", GATE_IP_G3D, 9, 0, 0), | |
| 1257 | +}; | |
| 1258 | + | |
| 1259 | +static struct exynos5_subcmu_reg_dump exynos5x_g3d_suspend_regs[] = { | |
| 1260 | + { GATE_IP_G3D, 0x3ff, 0x3ff }, /* G3D gates */ | |
| 1261 | + { SRC_TOP5, 0, BIT(16) }, /* MUX mout_user_aclk_g3d */ | |
| 1262 | +}; | |
| 1263 | + | |
| 1251 | 1264 | static const struct samsung_div_clock exynos5x_mfc_div_clks[] __initconst = { |
| 1252 | 1265 | DIV(0, "dout_mfc_blk", "mout_user_aclk333", DIV4_RATIO, 0, 2), |
| 1253 | 1266 | }; |
| @@ -1320,6 +1333,14 @@ static const struct exynos5_subcmu_info exynos5x_gsc_subcmu = { · 66 unmodified lines | ||
| 1320 | 1333 | .pd_name = "GSC", |
| 1321 | 1334 | }; |
| 1322 | 1335 | |
| 1336 | +static const struct exynos5_subcmu_info exynos5x_g3d_subcmu = { | |
| 1337 | + .gate_clks = exynos5x_g3d_gate_clks, | |
| 1338 | + .nr_gate_clks = ARRAY_SIZE(exynos5x_g3d_gate_clks), | |
| 1339 | + .suspend_regs = exynos5x_g3d_suspend_regs, | |
| 1340 | + .nr_suspend_regs = ARRAY_SIZE(exynos5x_g3d_suspend_regs), | |
| 1341 | + .pd_name = "G3D", | |
| 1342 | +}; | |
| 1343 | + | |
| 1323 | 1344 | static const struct exynos5_subcmu_info exynos5x_mfc_subcmu = { |
| 1324 | 1345 | .div_clks = exynos5x_mfc_div_clks, |
| 1325 | 1346 | .nr_div_clks = ARRAY_SIZE(exynos5x_mfc_div_clks), |
| @@ -1351,6 +1372,7 @@ static const struct exynos5_subcmu_info exynos5800_mau_subcmu = { · 25 unmodified lines | ||
| 1351 | 1372 | static const struct exynos5_subcmu_info *exynos5x_subcmus[] = { |
| 1352 | 1373 | &exynos5x_disp_subcmu, |
| 1353 | 1374 | &exynos5x_gsc_subcmu, |
| 1375 | + &exynos5x_g3d_subcmu, | |
| 1354 | 1376 | &exynos5x_mfc_subcmu, |
| 1355 | 1377 | &exynos5x_mscl_subcmu, |
| 1356 | 1378 | }; |
| @@ -1358,6 +1380,7 @@ static const struct exynos5_subcmu_info *exynos5x_subcmus[] = { · 1 unmodified line | ||
| 1358 | 1380 | static const struct exynos5_subcmu_info *exynos5800_subcmus[] = { |
| 1359 | 1381 | &exynos5x_disp_subcmu, |
| 1360 | 1382 | &exynos5x_gsc_subcmu, |
| 1383 | + &exynos5x_g3d_subcmu, | |
| 1361 | 1384 | &exynos5x_mfc_subcmu, |
| 1362 | 1385 | &exynos5x_mscl_subcmu, |
| 1363 | 1386 | &exynos5800_mau_subcmu, |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | ||
| 13 | 13 | #include <linux/of_device.h> |
| 14 | 14 | #include <linux/platform_device.h> |
| 15 | 15 | #include <linux/pm_runtime.h> |
| 16 | +#include <linux/slab.h> | |
| 16 | 17 | |
| 17 | 18 | #include <dt-bindings/clock/exynos5433.h> |
| 18 | 19 | |
| @@ -5584,6 +5585,8 @@ static int __init exynos5433_cmu_probe(struct platform_device *pdev) · 5565 unmodified lines | ||
| 5584 | 5585 | |
| 5585 | 5586 | data->clk_save = samsung_clk_alloc_reg_dump(info->clk_regs, |
| 5586 | 5587 | info->nr_clk_regs); |
| 5588 | + if (!data->clk_save) | |
| 5589 | + return -ENOMEM; | |
| 5587 | 5590 | data->nr_clk_save = info->nr_clk_regs; |
| 5588 | 5591 | data->clk_suspend = info->suspend_regs; |
| 5589 | 5592 | data->nr_clk_suspend = info->nr_suspend_regs; |
| @@ -5592,12 +5595,19 @@ static int __init exynos5433_cmu_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 5592 | 5595 | if (data->nr_pclks > 0) { |
| 5593 | 5596 | data->pclks = devm_kcalloc(dev, sizeof(struct clk *), |
| 5594 | 5597 | data->nr_pclks, GFP_KERNEL); |
| 5595 | − | |
| 5598 | + if (!data->pclks) { | |
| 5599 | + kfree(data->clk_save); | |
| 5600 | + return -ENOMEM; | |
| 5601 | + } | |
| 5596 | 5602 | for (i = 0; i < data->nr_pclks; i++) { |
| 5597 | 5603 | struct clk *clk = of_clk_get(dev->of_node, i); |
| 5598 | 5604 | |
| 5599 | − if (IS_ERR(clk)) | |
| 5605 | + if (IS_ERR(clk)) { | |
| 5606 | + kfree(data->clk_save); | |
| 5607 | + while (--i >= 0) | |
| 5608 | + clk_put(data->pclks[i]); | |
| 5600 | 5609 | return PTR_ERR(clk); |
| 5610 | + } | |
| 5601 | 5611 | data->pclks[i] = clk; |
| 5602 | 5612 | } |
| 5603 | 5613 | } |
| @@ -1224,7 +1224,7 @@ static int sun9i_a80_ccu_probe(struct platform_device *pdev) · 1223 unmodified lines | ||
| 1224 | 1224 | |
| 1225 | 1225 | /* Enforce d1 = 0, d2 = 0 for Audio PLL */ |
| 1226 | 1226 | val = readl(reg + SUN9I_A80_PLL_AUDIO_REG); |
| 1227 | − val &= (BIT(16) & BIT(18)); | |
| 1227 | + val &= ~(BIT(16) | BIT(18)); | |
| 1228 | 1228 | writel(val, reg + SUN9I_A80_PLL_AUDIO_REG); |
| 1229 | 1229 | |
| 1230 | 1230 | /* Enforce P = 1 for both CPU cluster PLLs */ |
| @@ -1080,8 +1080,8 @@ static struct clk ** __init sunxi_divs_clk_setup(struct device_node *node, · 1079 unmodified lines | ||
| 1080 | 1080 | rate_hw, rate_ops, |
| 1081 | 1081 | gate_hw, &clk_gate_ops, |
| 1082 | 1082 | clkflags | |
| 1083 | − data->div[i].critical ? | |
| 1084 | − CLK_IS_CRITICAL : 0); | |
| 1083 | + (data->div[i].critical ? | |
| 1084 | + CLK_IS_CRITICAL : 0)); | |
| 1085 | 1085 | |
| 1086 | 1086 | WARN_ON(IS_ERR(clk_data->clks[i])); |
| 1087 | 1087 | } |
| @@ -174,7 +174,6 @@ static void __init of_dra7_atl_clock_setup(struct device_node *node) · 173 unmodified lines | ||
| 174 | 174 | struct clk_init_data init = { NULL }; |
| 175 | 175 | const char **parent_names = NULL; |
| 176 | 176 | struct clk *clk; |
| 177 | − int ret; | |
| 178 | 177 | |
| 179 | 178 | clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL); |
| 180 | 179 | if (!clk_hw) { |
| @@ -207,11 +206,6 @@ static void __init of_dra7_atl_clock_setup(struct device_node *node) · 26 unmodified lines | ||
| 207 | 206 | clk = ti_clk_register(NULL, &clk_hw->hw, node->name); |
| 208 | 207 | |
| 209 | 208 | if (!IS_ERR(clk)) { |
| 210 | − ret = ti_clk_add_alias(NULL, clk, node->name); | |
| 211 | − if (ret) { | |
| 212 | − clk_unregister(clk); | |
| 213 | − goto cleanup; | |
| 214 | − } | |
| 215 | 209 | of_clk_add_provider(node, of_clk_src_simple_get, clk); |
| 216 | 210 | kfree(parent_names); |
| 217 | 211 | return; |
| @@ -100,11 +100,12 @@ static bool _omap4_is_timeout(union omap4_timeout *time, u32 timeout) · 99 unmodified lines | ||
| 100 | 100 | * can be from a timer that requires pm_runtime access, which |
| 101 | 101 | * will eventually bring us here with timekeeping_suspended, |
| 102 | 102 | * during both suspend entry and resume paths. This happens |
| 103 | − * at least on am43xx platform. | |
| 103 | + * at least on am43xx platform. Account for flakeyness | |
| 104 | + * with udelay() by multiplying the timeout value by 2. | |
| 104 | 105 | */ |
| 105 | 106 | if (unlikely(_early_timeout || timekeeping_suspended)) { |
| 106 | 107 | if (time->cycles++ < timeout) { |
| 107 | − udelay(1); | |
| 108 | + udelay(1 * 2); | |
| 108 | 109 | return false; |
| 109 | 110 | } |
| 110 | 111 | } else { |
| @@ -328,12 +328,13 @@ static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name) · 327 unmodified lines | ||
| 328 | 328 | return 0; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | +static const unsigned int sh_mtu2_channel_offsets[] = { | |
| 332 | + 0x300, 0x380, 0x000, | |
| 333 | +}; | |
| 334 | + | |
| 331 | 335 | static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index, |
| 332 | 336 | struct sh_mtu2_device *mtu) |
| 333 | 337 | { |
| 334 | − static const unsigned int channel_offsets[] = { | |
| 335 | − 0x300, 0x380, 0x000, | |
| 336 | − }; | |
| 337 | 338 | char name[6]; |
| 338 | 339 | int irq; |
| 339 | 340 | int ret; |
| @@ -356,7 +357,7 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index, · 16 unmodified lines | ||
| 356 | 357 | return ret; |
| 357 | 358 | } |
| 358 | 359 | |
| 359 | − ch->base = mtu->mapbase + channel_offsets[index]; | |
| 360 | + ch->base = mtu->mapbase + sh_mtu2_channel_offsets[index]; | |
| 360 | 361 | ch->index = index; |
| 361 | 362 | |
| 362 | 363 | return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev)); |
| @@ -408,7 +409,12 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, · 45 unmodified lines | ||
| 408 | 409 | } |
| 409 | 410 | |
| 410 | 411 | /* Allocate and setup the channels. */ |
| 411 | − mtu->num_channels = 3; | |
| 412 | + ret = platform_irq_count(pdev); | |
| 413 | + if (ret < 0) | |
| 414 | + goto err_unmap; | |
| 415 | + | |
| 416 | + mtu->num_channels = min_t(unsigned int, ret, | |
| 417 | + ARRAY_SIZE(sh_mtu2_channel_offsets)); | |
| 412 | 418 | |
| 413 | 419 | mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels), |
| 414 | 420 | GFP_KERNEL); |
| @@ -268,15 +268,12 @@ static int __init mtk_syst_init(struct device_node *node) · 267 unmodified lines | ||
| 268 | 268 | |
| 269 | 269 | ret = timer_of_init(node, &to); |
| 270 | 270 | if (ret) |
| 271 | − goto err; | |
| 271 | + return ret; | |
| 272 | 272 | |
| 273 | 273 | clockevents_config_and_register(&to.clkevt, timer_of_rate(&to), |
| 274 | 274 | TIMER_SYNC_TICKS, 0xffffffff); |
| 275 | 275 | |
| 276 | 276 | return 0; |
| 277 | −err: | |
| 278 | − timer_of_cleanup(&to); | |
| 279 | − return ret; | |
| 280 | 277 | } |
| 281 | 278 | |
| 282 | 279 | static int __init mtk_gpt_init(struct device_node *node) |
| @@ -293,7 +290,7 @@ static int __init mtk_gpt_init(struct device_node *node) · 10 unmodified lines | ||
| 293 | 290 | |
| 294 | 291 | ret = timer_of_init(node, &to); |
| 295 | 292 | if (ret) |
| 296 | − goto err; | |
| 293 | + return ret; | |
| 297 | 294 | |
| 298 | 295 | /* Configure clock source */ |
| 299 | 296 | mtk_gpt_setup(&to, TIMER_CLK_SRC, GPT_CTRL_OP_FREERUN); |
| @@ -311,9 +308,6 @@ static int __init mtk_gpt_init(struct device_node *node) · 11 unmodified lines | ||
| 311 | 308 | mtk_gpt_enable_irq(&to, TIMER_CLK_EVT); |
| 312 | 309 | |
| 313 | 310 | return 0; |
| 314 | −err: | |
| 315 | − timer_of_cleanup(&to); | |
| 316 | − return ret; | |
| 317 | 311 | } |
| 318 | 312 | TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init); |
| 319 | 313 | TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init); |
| @@ -847,11 +847,9 @@ static void intel_pstate_hwp_force_min_perf(int cpu) · 846 unmodified lines | ||
| 847 | 847 | value |= HWP_MAX_PERF(min_perf); |
| 848 | 848 | value |= HWP_MIN_PERF(min_perf); |
| 849 | 849 | |
| 850 | − /* Set EPP/EPB to min */ | |
| 850 | + /* Set EPP to min */ | |
| 851 | 851 | if (boot_cpu_has(X86_FEATURE_HWP_EPP)) |
| 852 | 852 | value |= HWP_ENERGY_PERF_PREFERENCE(HWP_EPP_POWERSAVE); |
| 853 | − else | |
| 854 | − intel_pstate_set_epb(cpu, HWP_EPP_BALANCE_POWERSAVE); | |
| 855 | 853 | |
| 856 | 854 | wrmsrl_on_cpu(cpu, MSR_HWP_REQUEST, value); |
| 857 | 855 | } |
| @@ -1297,7 +1297,7 @@ static void make_established(struct sock *sk, u32 snd_isn, unsigned int opt) · 1296 unmodified lines | ||
| 1297 | 1297 | tp->write_seq = snd_isn; |
| 1298 | 1298 | tp->snd_nxt = snd_isn; |
| 1299 | 1299 | tp->snd_una = snd_isn; |
| 1300 | − inet_sk(sk)->inet_id = tp->write_seq ^ jiffies; | |
| 1300 | + inet_sk(sk)->inet_id = prandom_u32(); | |
| 1301 | 1301 | assign_rxopt(sk, opt); |
| 1302 | 1302 | |
| 1303 | 1303 | if (tp->rcv_wnd > (RCV_BUFSIZ_M << 10)) |
| @@ -1702,7 +1702,7 @@ int chtls_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, · 1701 unmodified lines | ||
| 1702 | 1702 | return peekmsg(sk, msg, len, nonblock, flags); |
| 1703 | 1703 | |
| 1704 | 1704 | if (sk_can_busy_loop(sk) && |
| 1705 | − skb_queue_empty(&sk->sk_receive_queue) && | |
| 1705 | + skb_queue_empty_lockless(&sk->sk_receive_queue) && | |
| 1706 | 1706 | sk->sk_state == TCP_ESTABLISHED) |
| 1707 | 1707 | sk_busy_loop(sk, nonblock); |
| 1708 | 1708 | |
| @@ -1707,6 +1707,14 @@ static void sdma_add_scripts(struct sdma_engine *sdma, · 1706 unmodified lines | ||
| 1707 | 1707 | if (!sdma->script_number) |
| 1708 | 1708 | sdma->script_number = SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1; |
| 1709 | 1709 | |
| 1710 | + if (sdma->script_number > sizeof(struct sdma_script_start_addrs) | |
| 1711 | + / sizeof(s32)) { | |
| 1712 | + dev_err(sdma->dev, | |
| 1713 | + "SDMA script number %d not match with firmware.\n", | |
| 1714 | + sdma->script_number); | |
| 1715 | + return; | |
| 1716 | + } | |
| 1717 | + | |
| 1710 | 1718 | for (i = 0; i < sdma->script_number; i++) |
| 1711 | 1719 | if (addr_arr[i] > 0) |
| 1712 | 1720 | saddr_arr[i] = addr_arr[i]; |
| @@ -694,6 +694,25 @@ static int bam_dma_terminate_all(struct dma_chan *chan) · 693 unmodified lines | ||
| 694 | 694 | |
| 695 | 695 | /* remove all transactions, including active transaction */ |
| 696 | 696 | spin_lock_irqsave(&bchan->vc.lock, flag); |
| 697 | + /* | |
| 698 | + * If we have transactions queued, then some might be committed to the | |
| 699 | + * hardware in the desc fifo. The only way to reset the desc fifo is | |
| 700 | + * to do a hardware reset (either by pipe or the entire block). | |
| 701 | + * bam_chan_init_hw() will trigger a pipe reset, and also reinit the | |
| 702 | + * pipe. If the pipe is left disabled (default state after pipe reset) | |
| 703 | + * and is accessed by a connected hardware engine, a fatal error in | |
| 704 | + * the BAM will occur. There is a small window where this could happen | |
| 705 | + * with bam_chan_init_hw(), but it is assumed that the caller has | |
| 706 | + * stopped activity on any attached hardware engine. Make sure to do | |
| 707 | + * this first so that the BAM hardware doesn't cause memory corruption | |
| 708 | + * by accessing freed resources. | |
| 709 | + */ | |
| 710 | + if (!list_empty(&bchan->desc_list)) { | |
| 711 | + async_desc = list_first_entry(&bchan->desc_list, | |
| 712 | + struct bam_async_desc, desc_node); | |
| 713 | + bam_chan_init_hw(bchan, async_desc->dir); | |
| 714 | + } | |
| 715 | + | |
| 697 | 716 | list_for_each_entry_safe(async_desc, tmp, |
| 698 | 717 | &bchan->desc_list, desc_node) { |
| 699 | 718 | list_add(&async_desc->vd.node, &bchan->vc.desc_issued); |
| @@ -134,6 +134,10 @@ · 133 unmodified lines | ||
| 134 | 134 | #define SPRD_DMA_SRC_TRSF_STEP_OFFSET 0 |
| 135 | 135 | #define SPRD_DMA_TRSF_STEP_MASK GENMASK(15, 0) |
| 136 | 136 | |
| 137 | +/* SPRD DMA_SRC_BLK_STEP register definition */ | |
| 138 | +#define SPRD_DMA_LLIST_HIGH_MASK GENMASK(31, 28) | |
| 139 | +#define SPRD_DMA_LLIST_HIGH_SHIFT 28 | |
| 140 | + | |
| 137 | 141 | /* define DMA channel mode & trigger mode mask */ |
| 138 | 142 | #define SPRD_DMA_CHN_MODE_MASK GENMASK(7, 0) |
| 139 | 143 | #define SPRD_DMA_TRG_MODE_MASK GENMASK(7, 0) |
| @@ -208,6 +212,7 @@ struct sprd_dma_dev { · 68 unmodified lines | ||
| 208 | 212 | struct sprd_dma_chn channels[0]; |
| 209 | 213 | }; |
| 210 | 214 | |
| 215 | +static void sprd_dma_free_desc(struct virt_dma_desc *vd); | |
| 211 | 216 | static bool sprd_dma_filter_fn(struct dma_chan *chan, void *param); |
| 212 | 217 | static struct of_dma_filter_info sprd_dma_info = { |
| 213 | 218 | .filter_fn = sprd_dma_filter_fn, |
| @@ -609,12 +614,19 @@ static int sprd_dma_alloc_chan_resources(struct dma_chan *chan) · 395 unmodified lines | ||
| 609 | 614 | static void sprd_dma_free_chan_resources(struct dma_chan *chan) |
| 610 | 615 | { |
| 611 | 616 | struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); |
| 617 | + struct virt_dma_desc *cur_vd = NULL; | |
| 612 | 618 | unsigned long flags; |
| 613 | 619 | |
| 614 | 620 | spin_lock_irqsave(&schan->vc.lock, flags); |
| 621 | + if (schan->cur_desc) | |
| 622 | + cur_vd = &schan->cur_desc->vd; | |
| 623 | + | |
| 615 | 624 | sprd_dma_stop(schan); |
| 616 | 625 | spin_unlock_irqrestore(&schan->vc.lock, flags); |
| 617 | 626 | |
| 627 | + if (cur_vd) | |
| 628 | + sprd_dma_free_desc(cur_vd); | |
| 629 | + | |
| 618 | 630 | vchan_free_chan_resources(&schan->vc); |
| 619 | 631 | pm_runtime_put(chan->device->dev); |
| 620 | 632 | } |
| @@ -717,6 +729,7 @@ static int sprd_dma_fill_desc(struct dma_chan *chan, · 96 unmodified lines | ||
| 717 | 729 | u32 int_mode = flags & SPRD_DMA_INT_MASK; |
| 718 | 730 | int src_datawidth, dst_datawidth, src_step, dst_step; |
| 719 | 731 | u32 temp, fix_mode = 0, fix_en = 0; |
| 732 | + phys_addr_t llist_ptr; | |
| 720 | 733 | |
| 721 | 734 | if (dir == DMA_MEM_TO_DEV) { |
| 722 | 735 | src_step = sprd_dma_get_step(slave_cfg->src_addr_width); |
| @@ -814,13 +827,16 @@ static int sprd_dma_fill_desc(struct dma_chan *chan, · 91 unmodified lines | ||
| 814 | 827 | * Set the link-list pointer point to next link-list |
| 815 | 828 | * configuration's physical address. |
| 816 | 829 | */ |
| 817 | − hw->llist_ptr = schan->linklist.phy_addr + temp; | |
| 830 | + llist_ptr = schan->linklist.phy_addr + temp; | |
| 831 | + hw->llist_ptr = lower_32_bits(llist_ptr); | |
| 832 | + hw->src_blk_step = (upper_32_bits(llist_ptr) << SPRD_DMA_LLIST_HIGH_SHIFT) & | |
| 833 | + SPRD_DMA_LLIST_HIGH_MASK; | |
| 818 | 834 | } else { |
| 819 | 835 | hw->llist_ptr = 0; |
| 836 | + hw->src_blk_step = 0; | |
| 820 | 837 | } |
| 821 | 838 | |
| 822 | 839 | hw->frg_step = 0; |
| 823 | − hw->src_blk_step = 0; | |
| 824 | 840 | hw->des_blk_step = 0; |
| 825 | 841 | return 0; |
| 826 | 842 | } |
| @@ -1023,15 +1039,22 @@ static int sprd_dma_resume(struct dma_chan *chan) · 196 unmodified lines | ||
| 1023 | 1039 | static int sprd_dma_terminate_all(struct dma_chan *chan) |
| 1024 | 1040 | { |
| 1025 | 1041 | struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); |
| 1042 | + struct virt_dma_desc *cur_vd = NULL; | |
| 1026 | 1043 | unsigned long flags; |
| 1027 | 1044 | LIST_HEAD(head); |
| 1028 | 1045 | |
| 1029 | 1046 | spin_lock_irqsave(&schan->vc.lock, flags); |
| 1047 | + if (schan->cur_desc) | |
| 1048 | + cur_vd = &schan->cur_desc->vd; | |
| 1049 | + | |
| 1030 | 1050 | sprd_dma_stop(schan); |
| 1031 | 1051 | |
| 1032 | 1052 | vchan_get_all_descriptors(&schan->vc, &head); |
| 1033 | 1053 | spin_unlock_irqrestore(&schan->vc.lock, flags); |
| 1034 | 1054 | |
| 1055 | + if (cur_vd) | |
| 1056 | + sprd_dma_free_desc(cur_vd); | |
| 1057 | + | |
| 1035 | 1058 | vchan_dma_desc_free_list(&schan->vc, &head); |
| 1036 | 1059 | return 0; |
| 1037 | 1060 | } |
| @@ -40,6 +40,7 @@ · 39 unmodified lines | ||
| 40 | 40 | #define ADMA_CH_CONFIG_MAX_BURST_SIZE 16 |
| 41 | 41 | #define ADMA_CH_CONFIG_WEIGHT_FOR_WRR(val) ((val) & 0xf) |
| 42 | 42 | #define ADMA_CH_CONFIG_MAX_BUFS 8 |
| 43 | +#define TEGRA186_ADMA_CH_CONFIG_OUTSTANDING_REQS(reqs) (reqs << 4) | |
| 43 | 44 | |
| 44 | 45 | #define ADMA_CH_FIFO_CTRL 0x2c |
| 45 | 46 | #define TEGRA210_ADMA_CH_FIFO_CTRL_TXSIZE(val) (((val) & 0xf) << 8) |
| @@ -77,6 +78,7 @@ struct tegra_adma; · 31 unmodified lines | ||
| 77 | 78 | * @ch_req_tx_shift: Register offset for AHUB transmit channel select. |
| 78 | 79 | * @ch_req_rx_shift: Register offset for AHUB receive channel select. |
| 79 | 80 | * @ch_base_offset: Register offset of DMA channel registers. |
| 81 | + * @has_outstanding_reqs: If DMA channel can have outstanding requests. | |
| 80 | 82 | * @ch_fifo_ctrl: Default value for channel FIFO CTRL register. |
| 81 | 83 | * @ch_req_mask: Mask for Tx or Rx channel select. |
| 82 | 84 | * @ch_req_max: Maximum number of Tx or Rx channels available. |
| @@ -95,6 +97,7 @@ struct tegra_adma_chip_data { · 12 unmodified lines | ||
| 95 | 97 | unsigned int ch_req_max; |
| 96 | 98 | unsigned int ch_reg_size; |
| 97 | 99 | unsigned int nr_channels; |
| 100 | + bool has_outstanding_reqs; | |
| 98 | 101 | }; |
| 99 | 102 | |
| 100 | 103 | /* |
| @@ -594,6 +597,8 @@ static int tegra_adma_set_xfer_params(struct tegra_adma_chan *tdc, · 493 unmodified lines | ||
| 594 | 597 | ADMA_CH_CTRL_FLOWCTRL_EN; |
| 595 | 598 | ch_regs->config |= cdata->adma_get_burst_config(burst_size); |
| 596 | 599 | ch_regs->config |= ADMA_CH_CONFIG_WEIGHT_FOR_WRR(1); |
| 600 | + if (cdata->has_outstanding_reqs) | |
| 601 | + ch_regs->config |= TEGRA186_ADMA_CH_CONFIG_OUTSTANDING_REQS(8); | |
| 597 | 602 | ch_regs->fifo_ctrl = cdata->ch_fifo_ctrl; |
| 598 | 603 | ch_regs->tc = desc->period_len & ADMA_CH_TC_COUNT_MASK; |
| 599 | 604 | |
| @@ -778,6 +783,7 @@ static const struct tegra_adma_chip_data tegra210_chip_data = { · 178 unmodified lines | ||
| 778 | 783 | .ch_req_tx_shift = 28, |
| 779 | 784 | .ch_req_rx_shift = 24, |
| 780 | 785 | .ch_base_offset = 0, |
| 786 | + .has_outstanding_reqs = false, | |
| 781 | 787 | .ch_fifo_ctrl = TEGRA210_FIFO_CTRL_DEFAULT, |
| 782 | 788 | .ch_req_mask = 0xf, |
| 783 | 789 | .ch_req_max = 10, |
| @@ -792,6 +798,7 @@ static const struct tegra_adma_chip_data tegra186_chip_data = { · 8 unmodified lines | ||
| 792 | 798 | .ch_req_tx_shift = 27, |
| 793 | 799 | .ch_req_rx_shift = 22, |
| 794 | 800 | .ch_base_offset = 0x10000, |
| 801 | + .has_outstanding_reqs = true, | |
| 795 | 802 | .ch_fifo_ctrl = TEGRA186_FIFO_CTRL_DEFAULT, |
| 796 | 803 | .ch_req_mask = 0x1f, |
| 797 | 804 | .ch_req_max = 20, |
| @@ -586,9 +586,22 @@ static struct dma_async_tx_descriptor *cppi41_dma_prep_slave_sg( · 585 unmodified lines | ||
| 586 | 586 | enum dma_transfer_direction dir, unsigned long tx_flags, void *context) |
| 587 | 587 | { |
| 588 | 588 | struct cppi41_channel *c = to_cpp41_chan(chan); |
| 589 | + struct dma_async_tx_descriptor *txd = NULL; | |
| 590 | + struct cppi41_dd *cdd = c->cdd; | |
| 589 | 591 | struct cppi41_desc *d; |
| 590 | 592 | struct scatterlist *sg; |
| 591 | 593 | unsigned int i; |
| 594 | + int error; | |
| 595 | + | |
| 596 | + error = pm_runtime_get(cdd->ddev.dev); | |
| 597 | + if (error < 0) { | |
| 598 | + pm_runtime_put_noidle(cdd->ddev.dev); | |
| 599 | + | |
| 600 | + return NULL; | |
| 601 | + } | |
| 602 | + | |
| 603 | + if (cdd->is_suspended) | |
| 604 | + goto err_out_not_ready; | |
| 592 | 605 | |
| 593 | 606 | d = c->desc; |
| 594 | 607 | for_each_sg(sgl, sg, sg_len, i) { |
| @@ -611,7 +624,13 @@ static struct dma_async_tx_descriptor *cppi41_dma_prep_slave_sg( · 16 unmodified lines | ||
| 611 | 624 | d++; |
| 612 | 625 | } |
| 613 | 626 | |
| 614 | − return &c->txd; | |
| 627 | + txd = &c->txd; | |
| 628 | + | |
| 629 | +err_out_not_ready: | |
| 630 | + pm_runtime_mark_last_busy(cdd->ddev.dev); | |
| 631 | + pm_runtime_put_autosuspend(cdd->ddev.dev); | |
| 632 | + | |
| 633 | + return txd; | |
| 615 | 634 | } |
| 616 | 635 | |
| 617 | 636 | static void cppi41_compute_td_desc(struct cppi41_desc *d) |
| @@ -68,6 +68,9 @@ · 67 unmodified lines | ||
| 68 | 68 | #define XILINX_DMA_DMACR_CIRC_EN BIT(1) |
| 69 | 69 | #define XILINX_DMA_DMACR_RUNSTOP BIT(0) |
| 70 | 70 | #define XILINX_DMA_DMACR_FSYNCSRC_MASK GENMASK(6, 5) |
| 71 | +#define XILINX_DMA_DMACR_DELAY_MASK GENMASK(31, 24) | |
| 72 | +#define XILINX_DMA_DMACR_FRAME_COUNT_MASK GENMASK(23, 16) | |
| 73 | +#define XILINX_DMA_DMACR_MASTER_MASK GENMASK(11, 8) | |
| 71 | 74 | |
| 72 | 75 | #define XILINX_DMA_REG_DMASR 0x0004 |
| 73 | 76 | #define XILINX_DMA_DMASR_EOL_LATE_ERR BIT(15) |
| @@ -1354,7 +1357,8 @@ static void xilinx_dma_start_transfer(struct xilinx_dma_chan *chan) · 1280 unmodified lines | ||
| 1354 | 1357 | node); |
| 1355 | 1358 | hw = &segment->hw; |
| 1356 | 1359 | |
| 1357 | − xilinx_write(chan, XILINX_DMA_REG_SRCDSTADDR, hw->buf_addr); | |
| 1360 | + xilinx_write(chan, XILINX_DMA_REG_SRCDSTADDR, | |
| 1361 | + xilinx_prep_dma_addr_t(hw->buf_addr)); | |
| 1358 | 1362 | |
| 1359 | 1363 | /* Start the transfer */ |
| 1360 | 1364 | dma_ctrl_write(chan, XILINX_DMA_REG_BTT, |
| @@ -2117,8 +2121,10 @@ int xilinx_vdma_channel_set_config(struct dma_chan *dchan, · 756 unmodified lines | ||
| 2117 | 2121 | chan->config.gen_lock = cfg->gen_lock; |
| 2118 | 2122 | chan->config.master = cfg->master; |
| 2119 | 2123 | |
| 2124 | + dmacr &= ~XILINX_DMA_DMACR_GENLOCK_EN; | |
| 2120 | 2125 | if (cfg->gen_lock && chan->genlock) { |
| 2121 | 2126 | dmacr |= XILINX_DMA_DMACR_GENLOCK_EN; |
| 2127 | + dmacr &= ~XILINX_DMA_DMACR_MASTER_MASK; | |
| 2122 | 2128 | dmacr |= cfg->master << XILINX_DMA_DMACR_MASTER_SHIFT; |
| 2123 | 2129 | } |
| 2124 | 2130 | |
| @@ -2134,11 +2140,13 @@ int xilinx_vdma_channel_set_config(struct dma_chan *dchan, · 9 unmodified lines | ||
| 2134 | 2140 | chan->config.delay = cfg->delay; |
| 2135 | 2141 | |
| 2136 | 2142 | if (cfg->coalesc <= XILINX_DMA_DMACR_FRAME_COUNT_MAX) { |
| 2143 | + dmacr &= ~XILINX_DMA_DMACR_FRAME_COUNT_MASK; | |
| 2137 | 2144 | dmacr |= cfg->coalesc << XILINX_DMA_DMACR_FRAME_COUNT_SHIFT; |
| 2138 | 2145 | chan->config.coalesc = cfg->coalesc; |
| 2139 | 2146 | } |
| 2140 | 2147 | |
| 2141 | 2148 | if (cfg->delay <= XILINX_DMA_DMACR_DELAY_MAX) { |
| 2149 | + dmacr &= ~XILINX_DMA_DMACR_DELAY_MASK; | |
| 2142 | 2150 | dmacr |= cfg->delay << XILINX_DMA_DMACR_DELAY_SHIFT; |
| 2143 | 2151 | chan->config.delay = cfg->delay; |
| 2144 | 2152 | } |
| @@ -182,6 +182,7 @@ config RESET_ATTACK_MITIGATION · 181 unmodified lines | ||
| 182 | 182 | |
| 183 | 183 | config EFI_RCI2_TABLE |
| 184 | 184 | bool "EFI Runtime Configuration Interface Table Version 2 Support" |
| 185 | + depends on X86 || COMPILE_TEST | |
| 185 | 186 | help |
| 186 | 187 | Displays the content of the Runtime Configuration Interface |
| 187 | 188 | Table version 2 on Dell EMC PowerEdge systems as a binary |
| @@ -554,7 +554,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, · 553 unmodified lines | ||
| 554 | 554 | sizeof(*seed) + size); |
| 555 | 555 | if (seed != NULL) { |
| 556 | 556 | pr_notice("seeding entropy pool\n"); |
| 557 | − add_device_randomness(seed->bits, seed->size); | |
| 557 | + add_bootloader_randomness(seed->bits, seed->size); | |
| 558 | 558 | early_memunmap(seed, sizeof(*seed) + size); |
| 559 | 559 | } else { |
| 560 | 560 | pr_err("Could not map UEFI random seed!\n"); |
| @@ -52,6 +52,7 @@ lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o string.o random.o \ · 51 unmodified lines | ||
| 52 | 52 | |
| 53 | 53 | lib-$(CONFIG_ARM) += arm32-stub.o |
| 54 | 54 | lib-$(CONFIG_ARM64) += arm64-stub.o |
| 55 | +CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) | |
| 55 | 56 | CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) |
| 56 | 57 | |
| 57 | 58 | # |
| @@ -195,6 +195,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table, · 194 unmodified lines | ||
| 195 | 195 | unsigned long dram_base, |
| 196 | 196 | efi_loaded_image_t *image) |
| 197 | 197 | { |
| 198 | + unsigned long kernel_base; | |
| 198 | 199 | efi_status_t status; |
| 199 | 200 | |
| 200 | 201 | /* |
| @@ -204,9 +205,18 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table, · 3 unmodified lines | ||
| 204 | 205 | * loaded. These assumptions are made by the decompressor, |
| 205 | 206 | * before any memory map is available. |
| 206 | 207 | */ |
| 207 | − dram_base = round_up(dram_base, SZ_128M); | |
| 208 | + kernel_base = round_up(dram_base, SZ_128M); | |
| 208 | 209 | |
| 209 | − status = reserve_kernel_base(sys_table, dram_base, reserve_addr, | |
| 210 | + /* | |
| 211 | + * Note that some platforms (notably, the Raspberry Pi 2) put | |
| 212 | + * spin-tables and other pieces of firmware at the base of RAM, | |
| 213 | + * abusing the fact that the window of TEXT_OFFSET bytes at the | |
| 214 | + * base of the kernel image is only partially used at the moment. | |
| 215 | + * (Up to 5 pages are used for the swapper page tables) | |
| 216 | + */ | |
| 217 | + kernel_base += TEXT_OFFSET - 5 * PAGE_SIZE; | |
| 218 | + | |
| 219 | + status = reserve_kernel_base(sys_table, kernel_base, reserve_addr, | |
| 210 | 220 | reserve_size); |
| 211 | 221 | if (status != EFI_SUCCESS) { |
| 212 | 222 | pr_efi_err(sys_table, "Unable to allocate memory for uncompressed kernel.\n"); |
| @@ -220,7 +230,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table, · 7 unmodified lines | ||
| 220 | 230 | *image_size = image->image_size; |
| 221 | 231 | status = efi_relocate_kernel(sys_table, image_addr, *image_size, |
| 222 | 232 | *image_size, |
| 223 | − dram_base + MAX_UNCOMP_KERNEL_SIZE, 0); | |
| 233 | + kernel_base + MAX_UNCOMP_KERNEL_SIZE, 0, 0); | |
| 224 | 234 | if (status != EFI_SUCCESS) { |
| 225 | 235 | pr_efi_err(sys_table, "Failed to relocate kernel.\n"); |
| 226 | 236 | efi_free(sys_table, *reserve_size, *reserve_addr); |
| @@ -260,11 +260,11 @@ fail: · 259 unmodified lines | ||
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /* |
| 263 | − * Allocate at the lowest possible address. | |
| 263 | + * Allocate at the lowest possible address that is not below 'min'. | |
| 264 | 264 | */ |
| 265 | −efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, | |
| 266 | − unsigned long size, unsigned long align, | |
| 267 | − unsigned long *addr) | |
| 265 | +efi_status_t efi_low_alloc_above(efi_system_table_t *sys_table_arg, | |
| 266 | + unsigned long size, unsigned long align, | |
| 267 | + unsigned long *addr, unsigned long min) | |
| 268 | 268 | { |
| 269 | 269 | unsigned long map_size, desc_size, buff_size; |
| 270 | 270 | efi_memory_desc_t *map; |
| @@ -311,13 +311,8 @@ efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, · 40 unmodified lines | ||
| 311 | 311 | start = desc->phys_addr; |
| 312 | 312 | end = start + desc->num_pages * EFI_PAGE_SIZE; |
| 313 | 313 | |
| 314 | − /* | |
| 315 | − * Don't allocate at 0x0. It will confuse code that | |
| 316 | − * checks pointers against NULL. Skip the first 8 | |
| 317 | − * bytes so we start at a nice even number. | |
| 318 | − */ | |
| 319 | − if (start == 0x0) | |
| 320 | − start += 8; | |
| 314 | + if (start < min) | |
| 315 | + start = min; | |
| 321 | 316 | |
| 322 | 317 | start = round_up(start, align); |
| 323 | 318 | if ((start + size) > end) |
| @@ -698,7 +693,8 @@ efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg, · 374 unmodified lines | ||
| 698 | 693 | unsigned long image_size, |
| 699 | 694 | unsigned long alloc_size, |
| 700 | 695 | unsigned long preferred_addr, |
| 701 | − unsigned long alignment) | |
| 696 | + unsigned long alignment, | |
| 697 | + unsigned long min_addr) | |
| 702 | 698 | { |
| 703 | 699 | unsigned long cur_image_addr; |
| 704 | 700 | unsigned long new_addr = 0; |
| @@ -731,8 +727,8 @@ efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg, · 26 unmodified lines | ||
| 731 | 727 | * possible. |
| 732 | 728 | */ |
| 733 | 729 | if (status != EFI_SUCCESS) { |
| 734 | − status = efi_low_alloc(sys_table_arg, alloc_size, alignment, | |
| 735 | − &new_addr); | |
| 730 | + status = efi_low_alloc_above(sys_table_arg, alloc_size, | |
| 731 | + alignment, &new_addr, min_addr); | |
| 736 | 732 | } |
| 737 | 733 | if (status != EFI_SUCCESS) { |
| 738 | 734 | pr_efi_err(sys_table_arg, "Failed to allocate usable memory for kernel.\n"); |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | ||
| 14 | 14 | #include <linux/init.h> |
| 15 | 15 | #include <linux/proc_fs.h> |
| 16 | 16 | #include <linux/efi.h> |
| 17 | +#include <linux/security.h> | |
| 17 | 18 | #include <linux/slab.h> |
| 18 | 19 | #include <linux/uaccess.h> |
| 19 | 20 | |
| @@ -717,6 +718,13 @@ static long efi_test_ioctl(struct file *file, unsigned int cmd, · 697 unmodified lines | ||
| 717 | 718 | |
| 718 | 719 | static int efi_test_open(struct inode *inode, struct file *file) |
| 719 | 720 | { |
| 721 | + int ret = security_locked_down(LOCKDOWN_EFI_TEST); | |
| 722 | + | |
| 723 | + if (ret) | |
| 724 | + return ret; | |
| 725 | + | |
| 726 | + if (!capable(CAP_SYS_ADMIN)) | |
| 727 | + return -EACCES; | |
| 720 | 728 | /* |
| 721 | 729 | * nothing special to do here |
| 722 | 730 | * We do accept multiple open files at the same time as we |
| @@ -88,6 +88,7 @@ int __init efi_tpm_eventlog_init(void) · 87 unmodified lines | ||
| 88 | 88 | |
| 89 | 89 | if (tbl_size < 0) { |
| 90 | 90 | pr_err(FW_BUG "Failed to parse event in TPM Final Events Log\n"); |
| 91 | + ret = -EINVAL; | |
| 91 | 92 | goto out_calc; |
| 92 | 93 | } |
| 93 | 94 | |
| @@ -362,9 +362,8 @@ static void mrfld_irq_handler(struct irq_desc *desc) · 361 unmodified lines | ||
| 362 | 362 | chained_irq_exit(irqchip, desc); |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | −static int mrfld_irq_init_hw(struct gpio_chip *chip) | |
| 365 | +static void mrfld_irq_init_hw(struct mrfld_gpio *priv) | |
| 366 | 366 | { |
| 367 | − struct mrfld_gpio *priv = gpiochip_get_data(chip); | |
| 368 | 367 | void __iomem *reg; |
| 369 | 368 | unsigned int base; |
| 370 | 369 | |
| @@ -376,8 +375,6 @@ static int mrfld_irq_init_hw(struct gpio_chip *chip) · 5 unmodified lines | ||
| 376 | 375 | reg = gpio_reg(&priv->chip, base, GFER); |
| 377 | 376 | writel(0, reg); |
| 378 | 377 | } |
| 379 | − | |
| 380 | − return 0; | |
| 381 | 378 | } |
| 382 | 379 | |
| 383 | 380 | static const char *mrfld_gpio_get_pinctrl_dev_name(struct mrfld_gpio *priv) |
| @@ -400,7 +397,6 @@ static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id · 16 unmodified lines | ||
| 400 | 397 | { |
| 401 | 398 | const struct mrfld_gpio_pinrange *range; |
| 402 | 399 | const char *pinctrl_dev_name; |
| 403 | − struct gpio_irq_chip *girq; | |
| 404 | 400 | struct mrfld_gpio *priv; |
| 405 | 401 | u32 gpio_base, irq_base; |
| 406 | 402 | void __iomem *base; |
| @@ -448,21 +444,6 @@ static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id · 41 unmodified lines | ||
| 448 | 444 | |
| 449 | 445 | raw_spin_lock_init(&priv->lock); |
| 450 | 446 | |
| 451 | − girq = &priv->chip.irq; | |
| 452 | − girq->chip = &mrfld_irqchip; | |
| 453 | − girq->init_hw = mrfld_irq_init_hw; | |
| 454 | − girq->parent_handler = mrfld_irq_handler; | |
| 455 | − girq->num_parents = 1; | |
| 456 | − girq->parents = devm_kcalloc(&pdev->dev, girq->num_parents, | |
| 457 | − sizeof(*girq->parents), | |
| 458 | − GFP_KERNEL); | |
| 459 | − if (!girq->parents) | |
| 460 | − return -ENOMEM; | |
| 461 | − girq->parents[0] = pdev->irq; | |
| 462 | − girq->first = irq_base; | |
| 463 | − girq->default_type = IRQ_TYPE_NONE; | |
| 464 | − girq->handler = handle_bad_irq; | |
| 465 | − | |
| 466 | 447 | pci_set_drvdata(pdev, priv); |
| 467 | 448 | retval = devm_gpiochip_add_data(&pdev->dev, &priv->chip, priv); |
| 468 | 449 | if (retval) { |
| @@ -484,6 +465,18 @@ static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id · 15 unmodified lines | ||
| 484 | 465 | } |
| 485 | 466 | } |
| 486 | 467 | |
| 468 | + retval = gpiochip_irqchip_add(&priv->chip, &mrfld_irqchip, irq_base, | |
| 469 | + handle_bad_irq, IRQ_TYPE_NONE); | |
| 470 | + if (retval) { | |
| 471 | + dev_err(&pdev->dev, "could not connect irqchip to gpiochip\n"); | |
| 472 | + return retval; | |
| 473 | + } | |
| 474 | + | |
| 475 | + mrfld_irq_init_hw(priv); | |
| 476 | + | |
| 477 | + gpiochip_set_chained_irqchip(&priv->chip, &mrfld_irqchip, pdev->irq, | |
| 478 | + mrfld_irq_handler); | |
| 479 | + | |
| 487 | 480 | return 0; |
| 488 | 481 | } |
| 489 | 482 | |
| @@ -604,8 +604,11 @@ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr) · 603 unmodified lines | ||
| 604 | 604 | continue; |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | − for (i = 0; i < num_entities; i++) | |
| 607 | + for (i = 0; i < num_entities; i++) { | |
| 608 | + mutex_lock(&ctx->adev->lock_reset); | |
| 608 | 609 | drm_sched_entity_fini(&ctx->entities[0][i].entity); |
| 610 | + mutex_unlock(&ctx->adev->lock_reset); | |
| 611 | + } | |
| 609 | 612 | } |
| 610 | 613 | } |
| 611 | 614 | |
| @@ -2885,6 +2885,13 @@ fence_driver_init: · 2884 unmodified lines | ||
| 2885 | 2885 | DRM_INFO("amdgpu: acceleration disabled, skipping benchmarks\n"); |
| 2886 | 2886 | } |
| 2887 | 2887 | |
| 2888 | + /* | |
| 2889 | + * Register gpu instance before amdgpu_device_enable_mgpu_fan_boost. | |
| 2890 | + * Otherwise the mgpu fan boost feature will be skipped due to the | |
| 2891 | + * gpu instance is counted less. | |
| 2892 | + */ | |
| 2893 | + amdgpu_register_gpu_instance(adev); | |
| 2894 | + | |
| 2888 | 2895 | /* enable clockgating, etc. after ib tests, etc. since some blocks require |
| 2889 | 2896 | * explicit gating rather than handling it automatically. |
| 2890 | 2897 | */ |
| @@ -1016,6 +1016,7 @@ static const struct pci_device_id pciidlist[] = { · 1015 unmodified lines | ||
| 1016 | 1016 | {0x1002, 0x7340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14|AMD_EXP_HW_SUPPORT}, |
| 1017 | 1017 | {0x1002, 0x7341, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14|AMD_EXP_HW_SUPPORT}, |
| 1018 | 1018 | {0x1002, 0x7347, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14|AMD_EXP_HW_SUPPORT}, |
| 1019 | + {0x1002, 0x734F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14|AMD_EXP_HW_SUPPORT}, | |
| 1019 | 1020 | |
| 1020 | 1021 | /* Renoir */ |
| 1021 | 1022 | {0x1002, 0x1636, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RENOIR|AMD_IS_APU|AMD_EXP_HW_SUPPORT}, |
| @@ -289,6 +289,7 @@ struct amdgpu_gfx { · 288 unmodified lines | ||
| 289 | 289 | uint32_t mec2_feature_version; |
| 290 | 290 | bool mec_fw_write_wait; |
| 291 | 291 | bool me_fw_write_wait; |
| 292 | + bool cp_fw_write_wait; | |
| 292 | 293 | struct amdgpu_ring gfx_ring[AMDGPU_MAX_GFX_RINGS]; |
| 293 | 294 | unsigned num_gfx_rings; |
| 294 | 295 | struct amdgpu_ring compute_ring[AMDGPU_MAX_COMPUTE_RINGS]; |
| @@ -218,7 +218,7 @@ static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job) · 217 unmodified lines | ||
| 218 | 218 | struct amdgpu_ring *ring = to_amdgpu_ring(sched_job->sched); |
| 219 | 219 | struct dma_fence *fence = NULL, *finished; |
| 220 | 220 | struct amdgpu_job *job; |
| 221 | − int r; | |
| 221 | + int r = 0; | |
| 222 | 222 | |
| 223 | 223 | job = to_amdgpu_job(sched_job); |
| 224 | 224 | finished = &job->base.s_fence->finished; |
| @@ -243,6 +243,8 @@ static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job) · 18 unmodified lines | ||
| 243 | 243 | job->fence = dma_fence_get(fence); |
| 244 | 244 | |
| 245 | 245 | amdgpu_job_free_resources(job); |
| 246 | + | |
| 247 | + fence = r ? ERR_PTR(r) : fence; | |
| 246 | 248 | return fence; |
| 247 | 249 | } |
| 248 | 250 | |
| @@ -190,7 +190,6 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · 189 unmodified lines | ||
| 190 | 190 | pm_runtime_put_autosuspend(dev->dev); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | − amdgpu_register_gpu_instance(adev); | |
| 194 | 193 | out: |
| 195 | 194 | if (r) { |
| 196 | 195 | /* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */ |
| @@ -93,7 +93,7 @@ static const struct soc15_reg_golden golden_settings_gc_10_1[] = · 92 unmodified lines | ||
| 93 | 93 | { |
| 94 | 94 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_4, 0xffffffff, 0x00400014), |
| 95 | 95 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_CPF_CLK_CTRL, 0xfcff8fff, 0xf8000100), |
| 96 | − SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xc0000000, 0xc0000100), | |
| 96 | + SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xcd000000, 0x0d000100), | |
| 97 | 97 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQ_CLK_CTRL, 0x60000ff0, 0x60000100), |
| 98 | 98 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQG_CLK_CTRL, 0x40000000, 0x40000100), |
| 99 | 99 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_VGT_CLK_CTRL, 0xffff8fff, 0xffff8100), |
| @@ -140,7 +140,7 @@ static const struct soc15_reg_golden golden_settings_gc_10_1_1[] = · 40 unmodified lines | ||
| 140 | 140 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_4, 0xffffffff, 0x003c0014), |
| 141 | 141 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_GS_NGG_CLK_CTRL, 0xffff8fff, 0xffff8100), |
| 142 | 142 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_IA_CLK_CTRL, 0xffff0fff, 0xffff0100), |
| 143 | − SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xc0000000, 0xc0000100), | |
| 143 | + SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xcd000000, 0x0d000100), | |
| 144 | 144 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQ_CLK_CTRL, 0xf8ff0fff, 0x60000100), |
| 145 | 145 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQG_CLK_CTRL, 0x40000ff0, 0x40000100), |
| 146 | 146 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_VGT_CLK_CTRL, 0xffff8fff, 0xffff8100), |
| @@ -179,7 +179,7 @@ static const struct soc15_reg_golden golden_settings_gc_10_1_2[] = · 32 unmodified lines | ||
| 179 | 179 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_4, 0x003e001f, 0x003c0014), |
| 180 | 180 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_GS_NGG_CLK_CTRL, 0xffff8fff, 0xffff8100), |
| 181 | 181 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_IA_CLK_CTRL, 0xffff0fff, 0xffff0100), |
| 182 | − SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xff7f0fff, 0xc0000100), | |
| 182 | + SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CLK_CTRL, 0xff7f0fff, 0x0d000100), | |
| 183 | 183 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQ_CLK_CTRL, 0xffffcfff, 0x60000100), |
| 184 | 184 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SQG_CLK_CTRL, 0xffff0fff, 0x40000100), |
| 185 | 185 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_VGT_CLK_CTRL, 0xffff8fff, 0xffff8100), |
| @@ -564,6 +564,32 @@ static void gfx_v10_0_free_microcode(struct amdgpu_device *adev) · 378 unmodified lines | ||
| 564 | 564 | kfree(adev->gfx.rlc.register_list_format); |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | +static void gfx_v10_0_check_fw_write_wait(struct amdgpu_device *adev) | |
| 568 | +{ | |
| 569 | + adev->gfx.cp_fw_write_wait = false; | |
| 570 | + | |
| 571 | + switch (adev->asic_type) { | |
| 572 | + case CHIP_NAVI10: | |
| 573 | + case CHIP_NAVI12: | |
| 574 | + case CHIP_NAVI14: | |
| 575 | + if ((adev->gfx.me_fw_version >= 0x00000046) && | |
| 576 | + (adev->gfx.me_feature_version >= 27) && | |
| 577 | + (adev->gfx.pfp_fw_version >= 0x00000068) && | |
| 578 | + (adev->gfx.pfp_feature_version >= 27) && | |
| 579 | + (adev->gfx.mec_fw_version >= 0x0000005b) && | |
| 580 | + (adev->gfx.mec_feature_version >= 27)) | |
| 581 | + adev->gfx.cp_fw_write_wait = true; | |
| 582 | + break; | |
| 583 | + default: | |
| 584 | + break; | |
| 585 | + } | |
| 586 | + | |
| 587 | + if (adev->gfx.cp_fw_write_wait == false) | |
| 588 | + DRM_WARN_ONCE("Warning: check cp_fw_version and update it to realize \ | |
| 589 | + GRBM requires 1-cycle delay in cp firmware\n"); | |
| 590 | +} | |
| 591 | + | |
| 592 | + | |
| 567 | 593 | static void gfx_v10_0_init_rlc_ext_microcode(struct amdgpu_device *adev) |
| 568 | 594 | { |
| 569 | 595 | const struct rlc_firmware_header_v2_1 *rlc_hdr; |
| @@ -832,6 +858,7 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev) · 262 unmodified lines | ||
| 832 | 858 | } |
| 833 | 859 | } |
| 834 | 860 | |
| 861 | + gfx_v10_0_check_fw_write_wait(adev); | |
| 835 | 862 | out: |
| 836 | 863 | if (err) { |
| 837 | 864 | dev_err(adev->dev, |
| @@ -4765,6 +4792,24 @@ static void gfx_v10_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, · 3927 unmodified lines | ||
| 4765 | 4792 | gfx_v10_0_wait_reg_mem(ring, 0, 0, 0, reg, 0, val, mask, 0x20); |
| 4766 | 4793 | } |
| 4767 | 4794 | |
| 4795 | +static void gfx_v10_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring, | |
| 4796 | + uint32_t reg0, uint32_t reg1, | |
| 4797 | + uint32_t ref, uint32_t mask) | |
| 4798 | +{ | |
| 4799 | + int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX); | |
| 4800 | + struct amdgpu_device *adev = ring->adev; | |
| 4801 | + bool fw_version_ok = false; | |
| 4802 | + | |
| 4803 | + fw_version_ok = adev->gfx.cp_fw_write_wait; | |
| 4804 | + | |
| 4805 | + if (fw_version_ok) | |
| 4806 | + gfx_v10_0_wait_reg_mem(ring, usepfp, 0, 1, reg0, reg1, | |
| 4807 | + ref, mask, 0x20); | |
| 4808 | + else | |
| 4809 | + amdgpu_ring_emit_reg_write_reg_wait_helper(ring, reg0, reg1, | |
| 4810 | + ref, mask); | |
| 4811 | +} | |
| 4812 | + | |
| 4768 | 4813 | static void |
| 4769 | 4814 | gfx_v10_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, |
| 4770 | 4815 | uint32_t me, uint32_t pipe, |
| @@ -5155,6 +5200,7 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_gfx = { · 384 unmodified lines | ||
| 5155 | 5200 | .emit_tmz = gfx_v10_0_ring_emit_tmz, |
| 5156 | 5201 | .emit_wreg = gfx_v10_0_ring_emit_wreg, |
| 5157 | 5202 | .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait, |
| 5203 | + .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, | |
| 5158 | 5204 | }; |
| 5159 | 5205 | |
| 5160 | 5206 | static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_compute = { |
| @@ -5188,6 +5234,7 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_compute = { · 27 unmodified lines | ||
| 5188 | 5234 | .pad_ib = amdgpu_ring_generic_pad_ib, |
| 5189 | 5235 | .emit_wreg = gfx_v10_0_ring_emit_wreg, |
| 5190 | 5236 | .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait, |
| 5237 | + .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, | |
| 5191 | 5238 | }; |
| 5192 | 5239 | |
| 5193 | 5240 | static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_kiq = { |
| @@ -5218,6 +5265,7 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_kiq = { · 24 unmodified lines | ||
| 5218 | 5265 | .emit_rreg = gfx_v10_0_ring_emit_rreg, |
| 5219 | 5266 | .emit_wreg = gfx_v10_0_ring_emit_wreg, |
| 5220 | 5267 | .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait, |
| 5268 | + .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, | |
| 5221 | 5269 | }; |
| 5222 | 5270 | |
| 5223 | 5271 | static void gfx_v10_0_set_ring_funcs(struct amdgpu_device *adev) |
| @@ -973,6 +973,13 @@ static void gfx_v9_0_check_fw_write_wait(struct amdgpu_device *adev) · 972 unmodified lines | ||
| 973 | 973 | adev->gfx.me_fw_write_wait = false; |
| 974 | 974 | adev->gfx.mec_fw_write_wait = false; |
| 975 | 975 | |
| 976 | + if ((adev->gfx.mec_fw_version < 0x000001a5) || | |
| 977 | + (adev->gfx.mec_feature_version < 46) || | |
| 978 | + (adev->gfx.pfp_fw_version < 0x000000b7) || | |
| 979 | + (adev->gfx.pfp_feature_version < 46)) | |
| 980 | + DRM_WARN_ONCE("Warning: check cp_fw_version and update it to realize \ | |
| 981 | + GRBM requires 1-cycle delay in cp firmware\n"); | |
| 982 | + | |
| 976 | 983 | switch (adev->asic_type) { |
| 977 | 984 | case CHIP_VEGA10: |
| 978 | 985 | if ((adev->gfx.me_fw_version >= 0x0000009c) && |
| @@ -1039,6 +1046,12 @@ static void gfx_v9_0_check_if_need_gfxoff(struct amdgpu_device *adev) · 60 unmodified lines | ||
| 1039 | 1046 | !adev->gfx.rlc.is_rlc_v2_1)) |
| 1040 | 1047 | adev->pm.pp_feature &= ~PP_GFXOFF_MASK; |
| 1041 | 1048 | |
| 1049 | + if (adev->pm.pp_feature & PP_GFXOFF_MASK) | |
| 1050 | + adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG | | |
| 1051 | + AMD_PG_SUPPORT_CP | | |
| 1052 | + AMD_PG_SUPPORT_RLC_SMU_HS; | |
| 1053 | + break; | |
| 1054 | + case CHIP_RENOIR: | |
| 1042 | 1055 | if (adev->pm.pp_feature & PP_GFXOFF_MASK) |
| 1043 | 1056 | adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG | |
| 1044 | 1057 | AMD_PG_SUPPORT_CP | |
| @@ -151,6 +151,15 @@ static void gfxhub_v2_0_init_cache_regs(struct amdgpu_device *adev) · 150 unmodified lines | ||
| 151 | 151 | WREG32_SOC15(GC, 0, mmGCVM_L2_CNTL2, tmp); |
| 152 | 152 | |
| 153 | 153 | tmp = mmGCVM_L2_CNTL3_DEFAULT; |
| 154 | + if (adev->gmc.translate_further) { | |
| 155 | + tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL3, BANK_SELECT, 12); | |
| 156 | + tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL3, | |
| 157 | + L2_CACHE_BIGK_FRAGMENT_SIZE, 9); | |
| 158 | + } else { | |
| 159 | + tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL3, BANK_SELECT, 9); | |
| 160 | + tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL3, | |
| 161 | + L2_CACHE_BIGK_FRAGMENT_SIZE, 6); | |
| 162 | + } | |
| 154 | 163 | WREG32_SOC15(GC, 0, mmGCVM_L2_CNTL3, tmp); |
| 155 | 164 | |
| 156 | 165 | tmp = mmGCVM_L2_CNTL4_DEFAULT; |
| @@ -309,6 +309,7 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, · 308 unmodified lines | ||
| 309 | 309 | |
| 310 | 310 | job->vm_pd_addr = amdgpu_gmc_pd_addr(adev->gart.bo); |
| 311 | 311 | job->vm_needs_flush = true; |
| 312 | + job->ibs->ptr[job->ibs->length_dw++] = ring->funcs->nop; | |
| 312 | 313 | amdgpu_ring_pad_ib(ring, &job->ibs[0]); |
| 313 | 314 | r = amdgpu_job_submit(job, &adev->mman.entity, |
| 314 | 315 | AMDGPU_FENCE_OWNER_UNDEFINED, &fence); |
| @@ -343,11 +344,9 @@ static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring, · 28 unmodified lines | ||
| 343 | 344 | amdgpu_ring_emit_wreg(ring, hub->ctx0_ptb_addr_hi32 + (2 * vmid), |
| 344 | 345 | upper_32_bits(pd_addr)); |
| 345 | 346 | |
| 346 | − amdgpu_ring_emit_wreg(ring, hub->vm_inv_eng0_req + eng, req); | |
| 347 | − | |
| 348 | − /* wait for the invalidate to complete */ | |
| 349 | − amdgpu_ring_emit_reg_wait(ring, hub->vm_inv_eng0_ack + eng, | |
| 350 | − 1 << vmid, 1 << vmid); | |
| 347 | + amdgpu_ring_emit_reg_write_reg_wait(ring, hub->vm_inv_eng0_req + eng, | |
| 348 | + hub->vm_inv_eng0_ack + eng, | |
| 349 | + req, 1 << vmid); | |
| 351 | 350 | |
| 352 | 351 | return pd_addr; |
| 353 | 352 | } |
| @@ -137,6 +137,15 @@ static void mmhub_v2_0_init_cache_regs(struct amdgpu_device *adev) · 136 unmodified lines | ||
| 137 | 137 | WREG32_SOC15(MMHUB, 0, mmMMVM_L2_CNTL2, tmp); |
| 138 | 138 | |
| 139 | 139 | tmp = mmMMVM_L2_CNTL3_DEFAULT; |
| 140 | + if (adev->gmc.translate_further) { | |
| 141 | + tmp = REG_SET_FIELD(tmp, MMVM_L2_CNTL3, BANK_SELECT, 12); | |
| 142 | + tmp = REG_SET_FIELD(tmp, MMVM_L2_CNTL3, | |
| 143 | + L2_CACHE_BIGK_FRAGMENT_SIZE, 9); | |
| 144 | + } else { | |
| 145 | + tmp = REG_SET_FIELD(tmp, MMVM_L2_CNTL3, BANK_SELECT, 9); | |
| 146 | + tmp = REG_SET_FIELD(tmp, MMVM_L2_CNTL3, | |
| 147 | + L2_CACHE_BIGK_FRAGMENT_SIZE, 6); | |
| 148 | + } | |
| 140 | 149 | WREG32_SOC15(MMHUB, 0, mmMMVM_L2_CNTL3, tmp); |
| 141 | 150 | |
| 142 | 151 | tmp = mmMMVM_L2_CNTL4_DEFAULT; |
| @@ -219,6 +219,15 @@ static void mmhub_v9_4_init_cache_regs(struct amdgpu_device *adev, int hubid) · 218 unmodified lines | ||
| 219 | 219 | hubid * MMHUB_INSTANCE_REGISTER_OFFSET, tmp); |
| 220 | 220 | |
| 221 | 221 | tmp = mmVML2PF0_VM_L2_CNTL3_DEFAULT; |
| 222 | + if (adev->gmc.translate_further) { | |
| 223 | + tmp = REG_SET_FIELD(tmp, VML2PF0_VM_L2_CNTL3, BANK_SELECT, 12); | |
| 224 | + tmp = REG_SET_FIELD(tmp, VML2PF0_VM_L2_CNTL3, | |
| 225 | + L2_CACHE_BIGK_FRAGMENT_SIZE, 9); | |
| 226 | + } else { | |
| 227 | + tmp = REG_SET_FIELD(tmp, VML2PF0_VM_L2_CNTL3, BANK_SELECT, 9); | |
| 228 | + tmp = REG_SET_FIELD(tmp, VML2PF0_VM_L2_CNTL3, | |
| 229 | + L2_CACHE_BIGK_FRAGMENT_SIZE, 6); | |
| 230 | + } | |
| 222 | 231 | WREG32_SOC15_OFFSET(MMHUB, 0, mmVML2PF0_VM_L2_CNTL3, |
| 223 | 232 | hubid * MMHUB_INSTANCE_REGISTER_OFFSET, tmp); |
| 224 | 233 | |
| @@ -254,6 +254,7 @@ static const struct soc15_reg_golden golden_settings_sdma_4_3[] = { · 253 unmodified lines | ||
| 254 | 254 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC0_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), |
| 255 | 255 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), |
| 256 | 256 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0), |
| 257 | + SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_WATERMK, 0xfc000000, 0x00000000) | |
| 257 | 258 | }; |
| 258 | 259 | |
| 259 | 260 | static u32 sdma_v4_0_get_reg_offset(struct amdgpu_device *adev, |
| @@ -1173,6 +1173,16 @@ static void sdma_v5_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, · 1172 unmodified lines | ||
| 1173 | 1173 | SDMA_PKT_POLL_REGMEM_DW5_INTERVAL(10)); |
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | +static void sdma_v5_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring, | |
| 1177 | + uint32_t reg0, uint32_t reg1, | |
| 1178 | + uint32_t ref, uint32_t mask) | |
| 1179 | +{ | |
| 1180 | + amdgpu_ring_emit_wreg(ring, reg0, ref); | |
| 1181 | + /* wait for a cycle to reset vm_inv_eng*_ack */ | |
| 1182 | + amdgpu_ring_emit_reg_wait(ring, reg0, 0, 0); | |
| 1183 | + amdgpu_ring_emit_reg_wait(ring, reg1, mask, mask); | |
| 1184 | +} | |
| 1185 | + | |
| 1176 | 1186 | static int sdma_v5_0_early_init(void *handle) |
| 1177 | 1187 | { |
| 1178 | 1188 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| @@ -1588,7 +1598,7 @@ static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = { · 409 unmodified lines | ||
| 1588 | 1598 | 6 + /* sdma_v5_0_ring_emit_pipeline_sync */ |
| 1589 | 1599 | /* sdma_v5_0_ring_emit_vm_flush */ |
| 1590 | 1600 | SOC15_FLUSH_GPU_TLB_NUM_WREG * 3 + |
| 1591 | − SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 6 + | |
| 1601 | + SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 6 * 2 + | |
| 1592 | 1602 | 10 + 10 + 10, /* sdma_v5_0_ring_emit_fence x3 for user fence, vm fence */ |
| 1593 | 1603 | .emit_ib_size = 7 + 6, /* sdma_v5_0_ring_emit_ib */ |
| 1594 | 1604 | .emit_ib = sdma_v5_0_ring_emit_ib, |
| @@ -1602,6 +1612,7 @@ static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = { · 7 unmodified lines | ||
| 1602 | 1612 | .pad_ib = sdma_v5_0_ring_pad_ib, |
| 1603 | 1613 | .emit_wreg = sdma_v5_0_ring_emit_wreg, |
| 1604 | 1614 | .emit_reg_wait = sdma_v5_0_ring_emit_reg_wait, |
| 1615 | + .emit_reg_write_reg_wait = sdma_v5_0_ring_emit_reg_write_reg_wait, | |
| 1605 | 1616 | .init_cond_exec = sdma_v5_0_ring_init_cond_exec, |
| 1606 | 1617 | .patch_cond_exec = sdma_v5_0_ring_patch_cond_exec, |
| 1607 | 1618 | .preempt_ib = sdma_v5_0_ring_preempt_ib, |
| @@ -1186,11 +1186,6 @@ static int soc15_common_early_init(void *handle) · 1185 unmodified lines | ||
| 1186 | 1186 | AMD_PG_SUPPORT_VCN | |
| 1187 | 1187 | AMD_PG_SUPPORT_VCN_DPG; |
| 1188 | 1188 | adev->external_rev_id = adev->rev_id + 0x91; |
| 1189 | − | |
| 1190 | − if (adev->pm.pp_feature & PP_GFXOFF_MASK) | |
| 1191 | − adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG | | |
| 1192 | − AMD_PG_SUPPORT_CP | | |
| 1193 | − AMD_PG_SUPPORT_RLC_SMU_HS; | |
| 1194 | 1189 | break; |
| 1195 | 1190 | default: |
| 1196 | 1191 | /* FIXME: not supported yet */ |
| @@ -24,15 +24,20 @@ · 23 unmodified lines | ||
| 24 | 24 | # It calculates Bandwidth and Watermarks values for HW programming |
| 25 | 25 | # |
| 26 | 26 | |
| 27 | −ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) | |
| 28 | − cc_stack_align := -mpreferred-stack-boundary=4 | |
| 29 | −else ifneq ($(call cc-option, -mstack-alignment=16),) | |
| 30 | − cc_stack_align := -mstack-alignment=16 | |
| 31 | −endif | |
| 27 | +calcs_ccflags := -mhard-float -msse | |
| 32 | 28 | |
| 33 | −calcs_ccflags := -mhard-float -msse $(cc_stack_align) | |
| 29 | +ifdef CONFIG_CC_IS_GCC | |
| 30 | +ifeq ($(call cc-ifversion, -lt, 0701, y), y) | |
| 31 | +IS_OLD_GCC = 1 | |
| 32 | +endif | |
| 33 | +endif | |
| 34 | 34 | |
| 35 | −ifdef CONFIG_CC_IS_CLANG | |
| 35 | +ifdef IS_OLD_GCC | |
| 36 | +# Stack alignment mismatch, proceed with caution. | |
| 37 | +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 | |
| 38 | +# (8B stack alignment). | |
| 39 | +calcs_ccflags += -mpreferred-stack-boundary=4 | |
| 40 | +else | |
| 36 | 41 | calcs_ccflags += -msse2 |
| 37 | 42 | endif |
| 38 | 43 | |
| @@ -580,6 +580,10 @@ static bool construct(struct dc *dc, · 579 unmodified lines | ||
| 580 | 580 | #ifdef CONFIG_DRM_AMD_DC_DCN2_0 |
| 581 | 581 | // Allocate memory for the vm_helper |
| 582 | 582 | dc->vm_helper = kzalloc(sizeof(struct vm_helper), GFP_KERNEL); |
| 583 | + if (!dc->vm_helper) { | |
| 584 | + dm_error("%s: failed to create dc->vm_helper\n", __func__); | |
| 585 | + goto fail; | |
| 586 | + } | |
| 583 | 587 | |
| 584 | 588 | #endif |
| 585 | 589 | memcpy(&dc->bb_overrides, &init_params->bb_overrides, sizeof(dc->bb_overrides)); |
| @@ -374,6 +374,7 @@ void dal_ddc_service_i2c_query_dp_dual_mode_adaptor( · 373 unmodified lines | ||
| 374 | 374 | enum display_dongle_type *dongle = &sink_cap->dongle_type; |
| 375 | 375 | uint8_t type2_dongle_buf[DP_ADAPTOR_TYPE2_SIZE]; |
| 376 | 376 | bool is_type2_dongle = false; |
| 377 | + int retry_count = 2; | |
| 377 | 378 | struct dp_hdmi_dongle_signature_data *dongle_signature; |
| 378 | 379 | |
| 379 | 380 | /* Assume we have no valid DP passive dongle connected */ |
| @@ -386,13 +387,24 @@ void dal_ddc_service_i2c_query_dp_dual_mode_adaptor( · 6 unmodified lines | ||
| 386 | 387 | DP_HDMI_DONGLE_ADDRESS, |
| 387 | 388 | type2_dongle_buf, |
| 388 | 389 | sizeof(type2_dongle_buf))) { |
| 389 | − *dongle = DISPLAY_DONGLE_DP_DVI_DONGLE; | |
| 390 | − sink_cap->max_hdmi_pixel_clock = DP_ADAPTOR_DVI_MAX_TMDS_CLK; | |
| 390 | + /* Passive HDMI dongles can sometimes fail here without retrying*/ | |
| 391 | + while (retry_count > 0) { | |
| 392 | + if (i2c_read(ddc, | |
| 393 | + DP_HDMI_DONGLE_ADDRESS, | |
| 394 | + type2_dongle_buf, | |
| 395 | + sizeof(type2_dongle_buf))) | |
| 396 | + break; | |
| 397 | + retry_count--; | |
| 398 | + } | |
| 399 | + if (retry_count == 0) { | |
| 400 | + *dongle = DISPLAY_DONGLE_DP_DVI_DONGLE; | |
| 401 | + sink_cap->max_hdmi_pixel_clock = DP_ADAPTOR_DVI_MAX_TMDS_CLK; | |
| 391 | 402 | |
| 392 | − CONN_DATA_DETECT(ddc->link, type2_dongle_buf, sizeof(type2_dongle_buf), | |
| 393 | − "DP-DVI passive dongle %dMhz: ", | |
| 394 | − DP_ADAPTOR_DVI_MAX_TMDS_CLK / 1000); | |
| 395 | − return; | |
| 403 | + CONN_DATA_DETECT(ddc->link, type2_dongle_buf, sizeof(type2_dongle_buf), | |
| 404 | + "DP-DVI passive dongle %dMhz: ", | |
| 405 | + DP_ADAPTOR_DVI_MAX_TMDS_CLK / 1000); | |
| 406 | + return; | |
| 407 | + } | |
| 396 | 408 | } |
| 397 | 409 | |
| 398 | 410 | /* Check if Type 2 dongle.*/ |
| @@ -404,6 +404,9 @@ bool resource_are_streams_timing_synchronizable( · 403 unmodified lines | ||
| 404 | 404 | if (stream1->view_format != stream2->view_format) |
| 405 | 405 | return false; |
| 406 | 406 | |
| 407 | + if (stream1->ignore_msa_timing_param || stream2->ignore_msa_timing_param) | |
| 408 | + return false; | |
| 409 | + | |
| 407 | 410 | return true; |
| 408 | 411 | } |
| 409 | 412 | static bool is_dp_and_hdmi_sharable( |
| @@ -1540,6 +1543,9 @@ bool dc_is_stream_unchanged( · 1130 unmodified lines | ||
| 1540 | 1543 | if (!are_stream_backends_same(old_stream, stream)) |
| 1541 | 1544 | return false; |
| 1542 | 1545 | |
| 1546 | + if (old_stream->ignore_msa_timing_param != stream->ignore_msa_timing_param) | |
| 1547 | + return false; | |
| 1548 | + | |
| 1543 | 1549 | return true; |
| 1544 | 1550 | } |
| 1545 | 1551 | |
| @@ -393,6 +393,10 @@ bool cm_helper_translate_curve_to_hw_format( · 392 unmodified lines | ||
| 393 | 393 | rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; |
| 394 | 394 | rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; |
| 395 | 395 | |
| 396 | + rgb_resulted[hw_points].red = rgb_resulted[hw_points - 1].red; | |
| 397 | + rgb_resulted[hw_points].green = rgb_resulted[hw_points - 1].green; | |
| 398 | + rgb_resulted[hw_points].blue = rgb_resulted[hw_points - 1].blue; | |
| 399 | + | |
| 396 | 400 | // All 3 color channels have same x |
| 397 | 401 | corner_points[0].red.x = dc_fixpt_pow(dc_fixpt_from_int(2), |
| 398 | 402 | dc_fixpt_from_int(region_start)); |
| @@ -464,13 +468,6 @@ bool cm_helper_translate_curve_to_hw_format( · 65 unmodified lines | ||
| 464 | 468 | |
| 465 | 469 | i = 1; |
| 466 | 470 | while (i != hw_points + 1) { |
| 467 | − if (dc_fixpt_lt(rgb_plus_1->red, rgb->red)) | |
| 468 | − rgb_plus_1->red = rgb->red; | |
| 469 | − if (dc_fixpt_lt(rgb_plus_1->green, rgb->green)) | |
| 470 | − rgb_plus_1->green = rgb->green; | |
| 471 | − if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue)) | |
| 472 | − rgb_plus_1->blue = rgb->blue; | |
| 473 | − | |
| 474 | 471 | rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red); |
| 475 | 472 | rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green); |
| 476 | 473 | rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue); |
| @@ -562,6 +559,10 @@ bool cm_helper_translate_curve_to_degamma_hw_format( · 85 unmodified lines | ||
| 562 | 559 | rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; |
| 563 | 560 | rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; |
| 564 | 561 | |
| 562 | + rgb_resulted[hw_points].red = rgb_resulted[hw_points - 1].red; | |
| 563 | + rgb_resulted[hw_points].green = rgb_resulted[hw_points - 1].green; | |
| 564 | + rgb_resulted[hw_points].blue = rgb_resulted[hw_points - 1].blue; | |
| 565 | + | |
| 565 | 566 | corner_points[0].red.x = dc_fixpt_pow(dc_fixpt_from_int(2), |
| 566 | 567 | dc_fixpt_from_int(region_start)); |
| 567 | 568 | corner_points[0].green.x = corner_points[0].red.x; |
| @@ -624,13 +625,6 @@ bool cm_helper_translate_curve_to_degamma_hw_format( · 56 unmodified lines | ||
| 624 | 625 | |
| 625 | 626 | i = 1; |
| 626 | 627 | while (i != hw_points + 1) { |
| 627 | − if (dc_fixpt_lt(rgb_plus_1->red, rgb->red)) | |
| 628 | − rgb_plus_1->red = rgb->red; | |
| 629 | − if (dc_fixpt_lt(rgb_plus_1->green, rgb->green)) | |
| 630 | − rgb_plus_1->green = rgb->green; | |
| 631 | − if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue)) | |
| 632 | − rgb_plus_1->blue = rgb->blue; | |
| 633 | − | |
| 634 | 628 | rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red); |
| 635 | 629 | rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green); |
| 636 | 630 | rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue); |
| @@ -10,15 +10,20 @@ ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT · 9 unmodified lines | ||
| 10 | 10 | DCN20 += dcn20_dsc.o |
| 11 | 11 | endif |
| 12 | 12 | |
| 13 | −ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) | |
| 14 | − cc_stack_align := -mpreferred-stack-boundary=4 | |
| 15 | −else ifneq ($(call cc-option, -mstack-alignment=16),) | |
| 16 | − cc_stack_align := -mstack-alignment=16 | |
| 17 | −endif | |
| 13 | +CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := -mhard-float -msse | |
| 18 | 14 | |
| 19 | −CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := -mhard-float -msse $(cc_stack_align) | |
| 15 | +ifdef CONFIG_CC_IS_GCC | |
| 16 | +ifeq ($(call cc-ifversion, -lt, 0701, y), y) | |
| 17 | +IS_OLD_GCC = 1 | |
| 18 | +endif | |
| 19 | +endif | |
| 20 | 20 | |
| 21 | −ifdef CONFIG_CC_IS_CLANG | |
| 21 | +ifdef IS_OLD_GCC | |
| 22 | +# Stack alignment mismatch, proceed with caution. | |
| 23 | +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 | |
| 24 | +# (8B stack alignment). | |
| 25 | +CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o += -mpreferred-stack-boundary=4 | |
| 26 | +else | |
| 22 | 27 | CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o += -msse2 |
| 23 | 28 | endif |
| 24 | 29 | |
| @@ -814,7 +814,7 @@ static const struct resource_caps res_cap_nv14 = { · 813 unmodified lines | ||
| 814 | 814 | .num_audio = 6, |
| 815 | 815 | .num_stream_encoder = 5, |
| 816 | 816 | .num_pll = 5, |
| 817 | − .num_dwb = 0, | |
| 817 | + .num_dwb = 1, | |
| 818 | 818 | .num_ddc = 5, |
| 819 | 819 | }; |
| 820 | 820 | |
| @@ -1107,6 +1107,11 @@ struct stream_encoder *dcn20_stream_encoder_create( · 286 unmodified lines | ||
| 1107 | 1107 | if (!enc1) |
| 1108 | 1108 | return NULL; |
| 1109 | 1109 | |
| 1110 | + if (ASICREV_IS_NAVI14_M(ctx->asic_id.hw_internal_rev)) { | |
| 1111 | + if (eng_id >= ENGINE_ID_DIGD) | |
| 1112 | + eng_id++; | |
| 1113 | + } | |
| 1114 | + | |
| 1110 | 1115 | dcn20_stream_encoder_construct(enc1, ctx, ctx->dc_bios, eng_id, |
| 1111 | 1116 | &stream_enc_regs[eng_id], |
| 1112 | 1117 | &se_shift, &se_mask); |
| @@ -3,15 +3,20 @@ · 2 unmodified lines | ||
| 3 | 3 | |
| 4 | 4 | DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o |
| 5 | 5 | |
| 6 | −ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) | |
| 7 | − cc_stack_align := -mpreferred-stack-boundary=4 | |
| 8 | −else ifneq ($(call cc-option, -mstack-alignment=16),) | |
| 9 | − cc_stack_align := -mstack-alignment=16 | |
| 10 | −endif | |
| 6 | +CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o := -mhard-float -msse | |
| 11 | 7 | |
| 12 | −CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o := -mhard-float -msse $(cc_stack_align) | |
| 8 | +ifdef CONFIG_CC_IS_GCC | |
| 9 | +ifeq ($(call cc-ifversion, -lt, 0701, y), y) | |
| 10 | +IS_OLD_GCC = 1 | |
| 11 | +endif | |
| 12 | +endif | |
| 13 | 13 | |
| 14 | −ifdef CONFIG_CC_IS_CLANG | |
| 14 | +ifdef IS_OLD_GCC | |
| 15 | +# Stack alignment mismatch, proceed with caution. | |
| 16 | +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 | |
| 17 | +# (8B stack alignment). | |
| 18 | +CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o += -mpreferred-stack-boundary=4 | |
| 19 | +else | |
| 15 | 20 | CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o += -msse2 |
| 16 | 21 | endif |
| 17 | 22 | |
| @@ -24,15 +24,20 @@ · 23 unmodified lines | ||
| 24 | 24 | # It provides the general basic services required by other DAL |
| 25 | 25 | # subcomponents. |
| 26 | 26 | |
| 27 | −ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) | |
| 28 | − cc_stack_align := -mpreferred-stack-boundary=4 | |
| 29 | −else ifneq ($(call cc-option, -mstack-alignment=16),) | |
| 30 | − cc_stack_align := -mstack-alignment=16 | |
| 31 | −endif | |
| 27 | +dml_ccflags := -mhard-float -msse | |
| 32 | 28 | |
| 33 | −dml_ccflags := -mhard-float -msse $(cc_stack_align) | |
| 29 | +ifdef CONFIG_CC_IS_GCC | |
| 30 | +ifeq ($(call cc-ifversion, -lt, 0701, y), y) | |
| 31 | +IS_OLD_GCC = 1 | |
| 32 | +endif | |
| 33 | +endif | |
| 34 | 34 | |
| 35 | −ifdef CONFIG_CC_IS_CLANG | |
| 35 | +ifdef IS_OLD_GCC | |
| 36 | +# Stack alignment mismatch, proceed with caution. | |
| 37 | +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 | |
| 38 | +# (8B stack alignment). | |
| 39 | +dml_ccflags += -mpreferred-stack-boundary=4 | |
| 40 | +else | |
| 36 | 41 | dml_ccflags += -msse2 |
| 37 | 42 | endif |
| 38 | 43 | |
| @@ -2577,7 +2577,8 @@ static void dml20_DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPer · 2576 unmodified lines | ||
| 2577 | 2577 | mode_lib->vba.MinActiveDRAMClockChangeMargin |
| 2578 | 2578 | + mode_lib->vba.DRAMClockChangeLatency; |
| 2579 | 2579 | |
| 2580 | − if (mode_lib->vba.MinActiveDRAMClockChangeMargin > 0) { | |
| 2580 | + if (mode_lib->vba.MinActiveDRAMClockChangeMargin > 50) { | |
| 2581 | + mode_lib->vba.DRAMClockChangeWatermark += 25; | |
| 2581 | 2582 | mode_lib->vba.DRAMClockChangeSupport[0][0] = dm_dram_clock_change_vactive; |
| 2582 | 2583 | } else { |
| 2583 | 2584 | if (mode_lib->vba.SynchronizedVBlank || mode_lib->vba.NumberOfActivePlanes == 1) { |
| @@ -1,15 +1,20 @@ | ||
| 1 | 1 | # |
| 2 | 2 | # Makefile for the 'dsc' sub-component of DAL. |
| 3 | 3 | |
| 4 | −ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) | |
| 5 | − cc_stack_align := -mpreferred-stack-boundary=4 | |
| 6 | −else ifneq ($(call cc-option, -mstack-alignment=16),) | |
| 7 | − cc_stack_align := -mstack-alignment=16 | |
| 8 | −endif | |
| 4 | +dsc_ccflags := -mhard-float -msse | |
| 9 | 5 | |
| 10 | −dsc_ccflags := -mhard-float -msse $(cc_stack_align) | |
| 6 | +ifdef CONFIG_CC_IS_GCC | |
| 7 | +ifeq ($(call cc-ifversion, -lt, 0701, y), y) | |
| 8 | +IS_OLD_GCC = 1 | |
| 9 | +endif | |
| 10 | +endif | |
| 11 | 11 | |
| 12 | −ifdef CONFIG_CC_IS_CLANG | |
| 12 | +ifdef IS_OLD_GCC | |
| 13 | +# Stack alignment mismatch, proceed with caution. | |
| 14 | +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 | |
| 15 | +# (8B stack alignment). | |
| 16 | +dsc_ccflags += -mpreferred-stack-boundary=4 | |
| 17 | +else | |
| 13 | 18 | dsc_ccflags += -msse2 |
| 14 | 19 | endif |
| 15 | 20 | |
| @@ -5098,9 +5098,7 @@ static void vega10_odn_update_soc_table(struct pp_hwmgr *hwmgr, · 5097 unmodified lines | ||
| 5098 | 5098 | |
| 5099 | 5099 | if (type == PP_OD_EDIT_SCLK_VDDC_TABLE) { |
| 5100 | 5100 | podn_vdd_dep = &data->odn_dpm_table.vdd_dep_on_sclk; |
| 5101 | − for (i = 0; i < podn_vdd_dep->count - 1; i++) | |
| 5102 | − od_vddc_lookup_table->entries[i].us_vdd = podn_vdd_dep->entries[i].vddc; | |
| 5103 | − if (od_vddc_lookup_table->entries[i].us_vdd < podn_vdd_dep->entries[i].vddc) | |
| 5101 | + for (i = 0; i < podn_vdd_dep->count; i++) | |
| 5104 | 5102 | od_vddc_lookup_table->entries[i].us_vdd = podn_vdd_dep->entries[i].vddc; |
| 5105 | 5103 | } else if (type == PP_OD_EDIT_MCLK_VDDC_TABLE) { |
| 5106 | 5104 | podn_vdd_dep = &data->odn_dpm_table.vdd_dep_on_mclk; |
| @@ -205,7 +205,7 @@ static struct smu_11_0_cmn2aisc_mapping navi10_workload_map[PP_SMC_POWER_PROFILE · 204 unmodified lines | ||
| 205 | 205 | WORKLOAD_MAP(PP_SMC_POWER_PROFILE_POWERSAVING, WORKLOAD_PPLIB_POWER_SAVING_BIT), |
| 206 | 206 | WORKLOAD_MAP(PP_SMC_POWER_PROFILE_VIDEO, WORKLOAD_PPLIB_VIDEO_BIT), |
| 207 | 207 | WORKLOAD_MAP(PP_SMC_POWER_PROFILE_VR, WORKLOAD_PPLIB_VR_BIT), |
| 208 | − WORKLOAD_MAP(PP_SMC_POWER_PROFILE_COMPUTE, WORKLOAD_PPLIB_CUSTOM_BIT), | |
| 208 | + WORKLOAD_MAP(PP_SMC_POWER_PROFILE_COMPUTE, WORKLOAD_PPLIB_COMPUTE_BIT), | |
| 209 | 209 | WORKLOAD_MAP(PP_SMC_POWER_PROFILE_CUSTOM, WORKLOAD_PPLIB_CUSTOM_BIT), |
| 210 | 210 | }; |
| 211 | 211 | |
| @@ -219,7 +219,7 @@ static struct smu_11_0_cmn2aisc_mapping vega20_workload_map[PP_SMC_POWER_PROFILE · 218 unmodified lines | ||
| 219 | 219 | WORKLOAD_MAP(PP_SMC_POWER_PROFILE_POWERSAVING, WORKLOAD_PPLIB_POWER_SAVING_BIT), |
| 220 | 220 | WORKLOAD_MAP(PP_SMC_POWER_PROFILE_VIDEO, WORKLOAD_PPLIB_VIDEO_BIT), |
| 221 | 221 | WORKLOAD_MAP(PP_SMC_POWER_PROFILE_VR, WORKLOAD_PPLIB_VR_BIT), |
| 222 | − WORKLOAD_MAP(PP_SMC_POWER_PROFILE_COMPUTE, WORKLOAD_PPLIB_CUSTOM_BIT), | |
| 222 | + WORKLOAD_MAP(PP_SMC_POWER_PROFILE_COMPUTE, WORKLOAD_PPLIB_COMPUTE_BIT), | |
| 223 | 223 | WORKLOAD_MAP(PP_SMC_POWER_PROFILE_CUSTOM, WORKLOAD_PPLIB_CUSTOM_BIT), |
| 224 | 224 | }; |
| 225 | 225 | |
| @@ -1581,8 +1581,11 @@ static void commit_tail(struct drm_atomic_state *old_state) · 1580 unmodified lines | ||
| 1581 | 1581 | { |
| 1582 | 1582 | struct drm_device *dev = old_state->dev; |
| 1583 | 1583 | const struct drm_mode_config_helper_funcs *funcs; |
| 1584 | + struct drm_crtc_state *new_crtc_state; | |
| 1585 | + struct drm_crtc *crtc; | |
| 1584 | 1586 | ktime_t start; |
| 1585 | 1587 | s64 commit_time_ms; |
| 1588 | + unsigned int i, new_self_refresh_mask = 0; | |
| 1586 | 1589 | |
| 1587 | 1590 | funcs = dev->mode_config.helper_private; |
| 1588 | 1591 | |
| @@ -1602,6 +1605,15 @@ static void commit_tail(struct drm_atomic_state *old_state) · 13 unmodified lines | ||
| 1602 | 1605 | |
| 1603 | 1606 | drm_atomic_helper_wait_for_dependencies(old_state); |
| 1604 | 1607 | |
| 1608 | + /* | |
| 1609 | + * We cannot safely access new_crtc_state after | |
| 1610 | + * drm_atomic_helper_commit_hw_done() so figure out which crtc's have | |
| 1611 | + * self-refresh active beforehand: | |
| 1612 | + */ | |
| 1613 | + for_each_new_crtc_in_state(old_state, crtc, new_crtc_state, i) | |
| 1614 | + if (new_crtc_state->self_refresh_active) | |
| 1615 | + new_self_refresh_mask |= BIT(i); | |
| 1616 | + | |
| 1605 | 1617 | if (funcs && funcs->atomic_commit_tail) |
| 1606 | 1618 | funcs->atomic_commit_tail(old_state); |
| 1607 | 1619 | else |
| @@ -1610,7 +1622,8 @@ static void commit_tail(struct drm_atomic_state *old_state) · 2 unmodified lines | ||
| 1610 | 1622 | commit_time_ms = ktime_ms_delta(ktime_get(), start); |
| 1611 | 1623 | if (commit_time_ms > 0) |
| 1612 | 1624 | drm_self_refresh_helper_update_avg_times(old_state, |
| 1613 | − (unsigned long)commit_time_ms); | |
| 1625 | + (unsigned long)commit_time_ms, | |
| 1626 | + new_self_refresh_mask); | |
| 1614 | 1627 | |
| 1615 | 1628 | drm_atomic_helper_commit_cleanup_done(old_state); |
| 1616 | 1629 | |
| @@ -133,29 +133,33 @@ out_drop_locks: · 132 unmodified lines | ||
| 133 | 133 | * drm_self_refresh_helper_update_avg_times - Updates a crtc's SR time averages |
| 134 | 134 | * @state: the state which has just been applied to hardware |
| 135 | 135 | * @commit_time_ms: the amount of time in ms that this commit took to complete |
| 136 | + * @new_self_refresh_mask: bitmask of crtc's that have self_refresh_active in | |
| 137 | + * new state | |
| 136 | 138 | * |
| 137 | 139 | * Called after &drm_mode_config_funcs.atomic_commit_tail, this function will |
| 138 | 140 | * update the average entry/exit self refresh times on self refresh transitions. |
| 139 | 141 | * These averages will be used when calculating how long to delay before |
| 140 | 142 | * entering self refresh mode after activity. |
| 141 | 143 | */ |
| 142 | −void drm_self_refresh_helper_update_avg_times(struct drm_atomic_state *state, | |
| 143 | − unsigned int commit_time_ms) | |
| 144 | +void | |
| 145 | +drm_self_refresh_helper_update_avg_times(struct drm_atomic_state *state, | |
| 146 | + unsigned int commit_time_ms, | |
| 147 | + unsigned int new_self_refresh_mask) | |
| 144 | 148 | { |
| 145 | 149 | struct drm_crtc *crtc; |
| 146 | − struct drm_crtc_state *old_crtc_state, *new_crtc_state; | |
| 150 | + struct drm_crtc_state *old_crtc_state; | |
| 147 | 151 | int i; |
| 148 | 152 | |
| 149 | − for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, | |
| 150 | − new_crtc_state, i) { | |
| 153 | + for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) { | |
| 154 | + bool new_self_refresh_active = new_self_refresh_mask & BIT(i); | |
| 151 | 155 | struct drm_self_refresh_data *sr_data = crtc->self_refresh_data; |
| 152 | 156 | struct ewma_psr_time *time; |
| 153 | 157 | |
| 154 | 158 | if (old_crtc_state->self_refresh_active == |
| 155 | − new_crtc_state->self_refresh_active) | |
| 159 | + new_self_refresh_active) | |
| 156 | 160 | continue; |
| 157 | 161 | |
| 158 | − if (new_crtc_state->self_refresh_active) | |
| 162 | + if (new_self_refresh_active) | |
| 159 | 163 | time = &sr_data->entry_avg_ms; |
| 160 | 164 | else |
| 161 | 165 | time = &sr_data->exit_avg_ms; |
| @@ -180,6 +180,8 @@ void etnaviv_core_dump(struct etnaviv_gem_submit *submit) · 179 unmodified lines | ||
| 180 | 180 | etnaviv_cmdbuf_get_va(&submit->cmdbuf, |
| 181 | 181 | &gpu->mmu_context->cmdbuf_mapping)); |
| 182 | 182 | |
| 183 | + mutex_unlock(&gpu->mmu_context->lock); | |
| 184 | + | |
| 183 | 185 | /* Reserve space for the bomap */ |
| 184 | 186 | if (n_bomap_pages) { |
| 185 | 187 | bomap_start = bomap = iter.data; |
| @@ -221,8 +223,6 @@ void etnaviv_core_dump(struct etnaviv_gem_submit *submit) · 35 unmodified lines | ||
| 221 | 223 | obj->base.size); |
| 222 | 224 | } |
| 223 | 225 | |
| 224 | − mutex_unlock(&gpu->mmu_context->lock); | |
| 225 | − | |
| 226 | 226 | etnaviv_core_dump_header(&iter, ETDUMP_BUF_END, iter.data); |
| 227 | 227 | |
| 228 | 228 | dev_coredumpv(gpu->dev, iter.start, iter.data - iter.start, GFP_KERNEL); |
| @@ -155,9 +155,11 @@ static void etnaviv_iommuv2_dump(struct etnaviv_iommu_context *context, void *bu · 154 unmodified lines | ||
| 155 | 155 | |
| 156 | 156 | memcpy(buf, v2_context->mtlb_cpu, SZ_4K); |
| 157 | 157 | buf += SZ_4K; |
| 158 | − for (i = 0; i < MMUv2_MAX_STLB_ENTRIES; i++, buf += SZ_4K) | |
| 159 | − if (v2_context->mtlb_cpu[i] & MMUv2_PTE_PRESENT) | |
| 158 | + for (i = 0; i < MMUv2_MAX_STLB_ENTRIES; i++) | |
| 159 | + if (v2_context->mtlb_cpu[i] & MMUv2_PTE_PRESENT) { | |
| 160 | 160 | memcpy(buf, v2_context->stlb_cpu[i], SZ_4K); |
| 161 | + buf += SZ_4K; | |
| 162 | + } | |
| 161 | 163 | } |
| 162 | 164 | |
| 163 | 165 | static void etnaviv_iommuv2_restore_nonsec(struct etnaviv_gpu *gpu, |
| @@ -328,12 +328,23 @@ etnaviv_iommu_context_init(struct etnaviv_iommu_global *global, · 327 unmodified lines | ||
| 328 | 328 | |
| 329 | 329 | ret = etnaviv_cmdbuf_suballoc_map(suballoc, ctx, &ctx->cmdbuf_mapping, |
| 330 | 330 | global->memory_base); |
| 331 | − if (ret) { | |
| 332 | − global->ops->free(ctx); | |
| 333 | − return NULL; | |
| 331 | + if (ret) | |
| 332 | + goto out_free; | |
| 333 | + | |
| 334 | + if (global->version == ETNAVIV_IOMMU_V1 && | |
| 335 | + ctx->cmdbuf_mapping.iova > 0x80000000) { | |
| 336 | + dev_err(global->dev, | |
| 337 | + "command buffer outside valid memory window\n"); | |
| 338 | + goto out_unmap; | |
| 334 | 339 | } |
| 335 | 340 | |
| 336 | 341 | return ctx; |
| 342 | + | |
| 343 | +out_unmap: | |
| 344 | + etnaviv_cmdbuf_suballoc_unmap(ctx, &ctx->cmdbuf_mapping); | |
| 345 | +out_free: | |
| 346 | + global->ops->free(ctx); | |
| 347 | + return NULL; | |
| 337 | 348 | } |
| 338 | 349 | |
| 339 | 350 | void etnaviv_iommu_restore(struct etnaviv_gpu *gpu, |
| @@ -864,6 +864,13 @@ load_detect: · 863 unmodified lines | ||
| 864 | 864 | |
| 865 | 865 | out: |
| 866 | 866 | intel_display_power_put(dev_priv, intel_encoder->power_domain, wakeref); |
| 867 | + | |
| 868 | + /* | |
| 869 | + * Make sure the refs for power wells enabled during detect are | |
| 870 | + * dropped to avoid a new detect cycle triggered by HPD polling. | |
| 871 | + */ | |
| 872 | + intel_display_power_flush_work(dev_priv); | |
| 873 | + | |
| 867 | 874 | return status; |
| 868 | 875 | } |
| 869 | 876 | |
| @@ -9315,7 +9315,6 @@ static bool wrpll_uses_pch_ssc(struct drm_i915_private *dev_priv, · 9314 unmodified lines | ||
| 9315 | 9315 | static void lpt_init_pch_refclk(struct drm_i915_private *dev_priv) |
| 9316 | 9316 | { |
| 9317 | 9317 | struct intel_encoder *encoder; |
| 9318 | − bool pch_ssc_in_use = false; | |
| 9319 | 9318 | bool has_fdi = false; |
| 9320 | 9319 | |
| 9321 | 9320 | for_each_intel_encoder(&dev_priv->drm, encoder) { |
| @@ -9343,22 +9342,24 @@ static void lpt_init_pch_refclk(struct drm_i915_private *dev_priv) · 21 unmodified lines | ||
| 9343 | 9342 | * clock hierarchy. That would also allow us to do |
| 9344 | 9343 | * clock bending finally. |
| 9345 | 9344 | */ |
| 9345 | + dev_priv->pch_ssc_use = 0; | |
| 9346 | + | |
| 9346 | 9347 | if (spll_uses_pch_ssc(dev_priv)) { |
| 9347 | 9348 | DRM_DEBUG_KMS("SPLL using PCH SSC\n"); |
| 9348 | − pch_ssc_in_use = true; | |
| 9349 | + dev_priv->pch_ssc_use |= BIT(DPLL_ID_SPLL); | |
| 9349 | 9350 | } |
| 9350 | 9351 | |
| 9351 | 9352 | if (wrpll_uses_pch_ssc(dev_priv, DPLL_ID_WRPLL1)) { |
| 9352 | 9353 | DRM_DEBUG_KMS("WRPLL1 using PCH SSC\n"); |
| 9353 | − pch_ssc_in_use = true; | |
| 9354 | + dev_priv->pch_ssc_use |= BIT(DPLL_ID_WRPLL1); | |
| 9354 | 9355 | } |
| 9355 | 9356 | |
| 9356 | 9357 | if (wrpll_uses_pch_ssc(dev_priv, DPLL_ID_WRPLL2)) { |
| 9357 | 9358 | DRM_DEBUG_KMS("WRPLL2 using PCH SSC\n"); |
| 9358 | − pch_ssc_in_use = true; | |
| 9359 | + dev_priv->pch_ssc_use |= BIT(DPLL_ID_WRPLL2); | |
| 9359 | 9360 | } |
| 9360 | 9361 | |
| 9361 | − if (pch_ssc_in_use) | |
| 9362 | + if (dev_priv->pch_ssc_use) | |
| 9362 | 9363 | return; |
| 9363 | 9364 | |
| 9364 | 9365 | if (has_fdi) { |
| @@ -1256,6 +1256,9 @@ static u32 skl_get_aux_send_ctl(struct intel_dp *intel_dp, · 1255 unmodified lines | ||
| 1256 | 1256 | u32 unused) |
| 1257 | 1257 | { |
| 1258 | 1258 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 1259 | + struct drm_i915_private *i915 = | |
| 1260 | + to_i915(intel_dig_port->base.base.dev); | |
| 1261 | + enum phy phy = intel_port_to_phy(i915, intel_dig_port->base.port); | |
| 1259 | 1262 | u32 ret; |
| 1260 | 1263 | |
| 1261 | 1264 | ret = DP_AUX_CH_CTL_SEND_BUSY | |
| @@ -1268,7 +1271,8 @@ static u32 skl_get_aux_send_ctl(struct intel_dp *intel_dp, · 6 unmodified lines | ||
| 1268 | 1271 | DP_AUX_CH_CTL_FW_SYNC_PULSE_SKL(32) | |
| 1269 | 1272 | DP_AUX_CH_CTL_SYNC_PULSE_SKL(32); |
| 1270 | 1273 | |
| 1271 | − if (intel_dig_port->tc_mode == TC_PORT_TBT_ALT) | |
| 1274 | + if (intel_phy_is_tc(i915, phy) && | |
| 1275 | + intel_dig_port->tc_mode == TC_PORT_TBT_ALT) | |
| 1272 | 1276 | ret |= DP_AUX_CH_CTL_TBT_IO; |
| 1273 | 1277 | |
| 1274 | 1278 | return ret; |
| @@ -5436,6 +5440,12 @@ out: · 4161 unmodified lines | ||
| 5436 | 5440 | if (status != connector_status_connected && !intel_dp->is_mst) |
| 5437 | 5441 | intel_dp_unset_edid(intel_dp); |
| 5438 | 5442 | |
| 5443 | + /* | |
| 5444 | + * Make sure the refs for power wells enabled during detect are | |
| 5445 | + * dropped to avoid a new detect cycle triggered by HPD polling. | |
| 5446 | + */ | |
| 5447 | + intel_display_power_flush_work(dev_priv); | |
| 5448 | + | |
| 5439 | 5449 | return status; |
| 5440 | 5450 | } |
| 5441 | 5451 | |
| @@ -525,16 +525,31 @@ static void hsw_ddi_wrpll_disable(struct drm_i915_private *dev_priv, · 524 unmodified lines | ||
| 525 | 525 | val = I915_READ(WRPLL_CTL(id)); |
| 526 | 526 | I915_WRITE(WRPLL_CTL(id), val & ~WRPLL_PLL_ENABLE); |
| 527 | 527 | POSTING_READ(WRPLL_CTL(id)); |
| 528 | + | |
| 529 | + /* | |
| 530 | + * Try to set up the PCH reference clock once all DPLLs | |
| 531 | + * that depend on it have been shut down. | |
| 532 | + */ | |
| 533 | + if (dev_priv->pch_ssc_use & BIT(id)) | |
| 534 | + intel_init_pch_refclk(dev_priv); | |
| 528 | 535 | } |
| 529 | 536 | |
| 530 | 537 | static void hsw_ddi_spll_disable(struct drm_i915_private *dev_priv, |
| 531 | 538 | struct intel_shared_dpll *pll) |
| 532 | 539 | { |
| 540 | + enum intel_dpll_id id = pll->info->id; | |
| 533 | 541 | u32 val; |
| 534 | 542 | |
| 535 | 543 | val = I915_READ(SPLL_CTL); |
| 536 | 544 | I915_WRITE(SPLL_CTL, val & ~SPLL_PLL_ENABLE); |
| 537 | 545 | POSTING_READ(SPLL_CTL); |
| 546 | + | |
| 547 | + /* | |
| 548 | + * Try to set up the PCH reference clock once all DPLLs | |
| 549 | + * that depend on it have been shut down. | |
| 550 | + */ | |
| 551 | + if (dev_priv->pch_ssc_use & BIT(id)) | |
| 552 | + intel_init_pch_refclk(dev_priv); | |
| 538 | 553 | } |
| 539 | 554 | |
| 540 | 555 | static bool hsw_ddi_wrpll_get_hw_state(struct drm_i915_private *dev_priv, |
| @@ -147,11 +147,11 @@ enum intel_dpll_id { · 146 unmodified lines | ||
| 147 | 147 | */ |
| 148 | 148 | DPLL_ID_ICL_MGPLL4 = 6, |
| 149 | 149 | /** |
| 150 | − * @DPLL_ID_TGL_TCPLL5: TGL TC PLL port 5 (TC5) | |
| 150 | + * @DPLL_ID_TGL_MGPLL5: TGL TC PLL port 5 (TC5) | |
| 151 | 151 | */ |
| 152 | 152 | DPLL_ID_TGL_MGPLL5 = 7, |
| 153 | 153 | /** |
| 154 | − * @DPLL_ID_TGL_TCPLL6: TGL TC PLL port 6 (TC6) | |
| 154 | + * @DPLL_ID_TGL_MGPLL6: TGL TC PLL port 6 (TC6) | |
| 155 | 155 | */ |
| 156 | 156 | DPLL_ID_TGL_MGPLL6 = 8, |
| 157 | 157 | }; |
| @@ -2565,6 +2565,12 @@ out: · 2564 unmodified lines | ||
| 2565 | 2565 | if (status != connector_status_connected) |
| 2566 | 2566 | cec_notifier_phys_addr_invalidate(intel_hdmi->cec_notifier); |
| 2567 | 2567 | |
| 2568 | + /* | |
| 2569 | + * Make sure the refs for power wells enabled during detect are | |
| 2570 | + * dropped to avoid a new detect cycle triggered by HPD polling. | |
| 2571 | + */ | |
| 2572 | + intel_display_power_flush_work(dev_priv); | |
| 2573 | + | |
| 2568 | 2574 | return status; |
| 2569 | 2575 | } |
| 2570 | 2576 | |
| @@ -1723,6 +1723,8 @@ struct drm_i915_private { · 1722 unmodified lines | ||
| 1723 | 1723 | struct work_struct idle_work; |
| 1724 | 1724 | } gem; |
| 1725 | 1725 | |
| 1726 | + u8 pch_ssc_use; | |
| 1727 | + | |
| 1726 | 1728 | /* For i945gm vblank irq vs. C3 workaround */ |
| 1727 | 1729 | struct { |
| 1728 | 1730 | struct work_struct work; |
| @@ -556,11 +556,11 @@ static int panfrost_probe(struct platform_device *pdev) · 555 unmodified lines | ||
| 556 | 556 | return 0; |
| 557 | 557 | |
| 558 | 558 | err_out2: |
| 559 | + pm_runtime_disable(pfdev->dev); | |
| 559 | 560 | panfrost_devfreq_fini(pfdev); |
| 560 | 561 | err_out1: |
| 561 | 562 | panfrost_device_fini(pfdev); |
| 562 | 563 | err_out0: |
| 563 | − pm_runtime_disable(pfdev->dev); | |
| 564 | 564 | drm_dev_put(ddev); |
| 565 | 565 | return err; |
| 566 | 566 | } |
| @@ -224,9 +224,9 @@ static size_t get_pgsize(u64 addr, size_t size) · 223 unmodified lines | ||
| 224 | 224 | return SZ_2M; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | −void panfrost_mmu_flush_range(struct panfrost_device *pfdev, | |
| 228 | − struct panfrost_mmu *mmu, | |
| 229 | − u64 iova, size_t size) | |
| 227 | +static void panfrost_mmu_flush_range(struct panfrost_device *pfdev, | |
| 228 | + struct panfrost_mmu *mmu, | |
| 229 | + u64 iova, size_t size) | |
| 230 | 230 | { |
| 231 | 231 | if (mmu->as < 0) |
| 232 | 232 | return; |
| @@ -406,11 +406,11 @@ addr_to_drm_mm_node(struct panfrost_device *pfdev, int as, u64 addr) · 173 unmodified lines | ||
| 406 | 406 | spin_lock(&pfdev->as_lock); |
| 407 | 407 | list_for_each_entry(mmu, &pfdev->as_lru_list, list) { |
| 408 | 408 | if (as == mmu->as) |
| 409 | − break; | |
| 409 | + goto found_mmu; | |
| 410 | 410 | } |
| 411 | − if (as != mmu->as) | |
| 412 | − goto out; | |
| 411 | + goto out; | |
| 413 | 412 | |
| 413 | +found_mmu: | |
| 414 | 414 | priv = container_of(mmu, struct panfrost_file_priv, mmu); |
| 415 | 415 | |
| 416 | 416 | spin_lock(&priv->mm_lock); |
| @@ -432,7 +432,8 @@ out: · 15 unmodified lines | ||
| 432 | 432 | |
| 433 | 433 | #define NUM_FAULT_PAGES (SZ_2M / PAGE_SIZE) |
| 434 | 434 | |
| 435 | −int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as, u64 addr) | |
| 435 | +static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as, | |
| 436 | + u64 addr) | |
| 436 | 437 | { |
| 437 | 438 | int ret, i; |
| 438 | 439 | struct panfrost_gem_object *bo; |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 16 | 16 | #include "panfrost_issues.h" |
| 17 | 17 | #include "panfrost_job.h" |
| 18 | 18 | #include "panfrost_mmu.h" |
| 19 | +#include "panfrost_perfcnt.h" | |
| 19 | 20 | #include "panfrost_regs.h" |
| 20 | 21 | |
| 21 | 22 | #define COUNTERS_PER_BLOCK 64 |
| @@ -379,11 +379,25 @@ radeon_pci_remove(struct pci_dev *pdev) · 378 unmodified lines | ||
| 379 | 379 | static void |
| 380 | 380 | radeon_pci_shutdown(struct pci_dev *pdev) |
| 381 | 381 | { |
| 382 | +#ifdef CONFIG_PPC64 | |
| 383 | + struct drm_device *ddev = pci_get_drvdata(pdev); | |
| 384 | +#endif | |
| 385 | + | |
| 382 | 386 | /* if we are running in a VM, make sure the device |
| 383 | 387 | * torn down properly on reboot/shutdown |
| 384 | 388 | */ |
| 385 | 389 | if (radeon_device_is_virtual()) |
| 386 | 390 | radeon_pci_remove(pdev); |
| 391 | + | |
| 392 | +#ifdef CONFIG_PPC64 | |
| 393 | + /* Some adapters need to be suspended before a | |
| 394 | + * shutdown occurs in order to prevent an error | |
| 395 | + * during kexec. | |
| 396 | + * Make this power specific becauase it breaks | |
| 397 | + * some non-power boards. | |
| 398 | + */ | |
| 399 | + radeon_suspend_kms(ddev, true, true, false); | |
| 400 | +#endif | |
| 387 | 401 | } |
| 388 | 402 | |
| 389 | 403 | static int radeon_pmops_suspend(struct device *dev) |
| @@ -1958,6 +1958,7 @@ static void si_initialize_powertune_defaults(struct radeon_device *rdev) · 1957 unmodified lines | ||
| 1958 | 1958 | case 0x682C: |
| 1959 | 1959 | si_pi->cac_weights = cac_weights_cape_verde_pro; |
| 1960 | 1960 | si_pi->dte_data = dte_data_sun_xt; |
| 1961 | + update_dte_from_pl2 = true; | |
| 1961 | 1962 | break; |
| 1962 | 1963 | case 0x6825: |
| 1963 | 1964 | case 0x6827: |
| @@ -479,6 +479,7 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched) · 478 unmodified lines | ||
| 479 | 479 | struct drm_sched_job *s_job, *tmp; |
| 480 | 480 | uint64_t guilty_context; |
| 481 | 481 | bool found_guilty = false; |
| 482 | + struct dma_fence *fence; | |
| 482 | 483 | |
| 483 | 484 | list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) { |
| 484 | 485 | struct drm_sched_fence *s_fence = s_job->s_fence; |
| @@ -492,7 +493,16 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched) · 7 unmodified lines | ||
| 492 | 493 | dma_fence_set_error(&s_fence->finished, -ECANCELED); |
| 493 | 494 | |
| 494 | 495 | dma_fence_put(s_job->s_fence->parent); |
| 495 | − s_job->s_fence->parent = sched->ops->run_job(s_job); | |
| 496 | + fence = sched->ops->run_job(s_job); | |
| 497 | + | |
| 498 | + if (IS_ERR_OR_NULL(fence)) { | |
| 499 | + s_job->s_fence->parent = NULL; | |
| 500 | + dma_fence_set_error(&s_fence->finished, PTR_ERR(fence)); | |
| 501 | + } else { | |
| 502 | + s_job->s_fence->parent = fence; | |
| 503 | + } | |
| 504 | + | |
| 505 | + | |
| 496 | 506 | } |
| 497 | 507 | } |
| 498 | 508 | EXPORT_SYMBOL(drm_sched_resubmit_jobs); |
| @@ -720,7 +730,7 @@ static int drm_sched_main(void *param) · 221 unmodified lines | ||
| 720 | 730 | fence = sched->ops->run_job(sched_job); |
| 721 | 731 | drm_sched_fence_scheduled(s_fence); |
| 722 | 732 | |
| 723 | − if (fence) { | |
| 733 | + if (!IS_ERR_OR_NULL(fence)) { | |
| 724 | 734 | s_fence->parent = dma_fence_get(fence); |
| 725 | 735 | r = dma_fence_add_callback(fence, &sched_job->cb, |
| 726 | 736 | drm_sched_process_job); |
| @@ -730,8 +740,11 @@ static int drm_sched_main(void *param) · 3 unmodified lines | ||
| 730 | 740 | DRM_ERROR("fence add callback failed (%d)\n", |
| 731 | 741 | r); |
| 732 | 742 | dma_fence_put(fence); |
| 733 | − } else | |
| 743 | + } else { | |
| 744 | + | |
| 745 | + dma_fence_set_error(&s_fence->finished, PTR_ERR(fence)); | |
| 734 | 746 | drm_sched_process_job(NULL, &sched_job->cb); |
| 747 | + } | |
| 735 | 748 | |
| 736 | 749 | wake_up(&sched->job_scheduled); |
| 737 | 750 | } |
| @@ -557,13 +557,16 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, · 556 unmodified lines | ||
| 557 | 557 | |
| 558 | 558 | if (args->bcl_start != args->bcl_end) { |
| 559 | 559 | bin = kcalloc(1, sizeof(*bin), GFP_KERNEL); |
| 560 | − if (!bin) | |
| 560 | + if (!bin) { | |
| 561 | + v3d_job_put(&render->base); | |
| 561 | 562 | return -ENOMEM; |
| 563 | + } | |
| 562 | 564 | |
| 563 | 565 | ret = v3d_job_init(v3d, file_priv, &bin->base, |
| 564 | 566 | v3d_job_free, args->in_sync_bcl); |
| 565 | 567 | if (ret) { |
| 566 | 568 | v3d_job_put(&render->base); |
| 569 | + kfree(bin); | |
| 567 | 570 | return ret; |
| 568 | 571 | } |
| 569 | 572 | |
| @@ -63,13 +63,20 @@ static int axff_init(struct hid_device *hid) · 62 unmodified lines | ||
| 63 | 63 | { |
| 64 | 64 | struct axff_device *axff; |
| 65 | 65 | struct hid_report *report; |
| 66 | − struct hid_input *hidinput = list_first_entry(&hid->inputs, struct hid_input, list); | |
| 66 | + struct hid_input *hidinput; | |
| 67 | 67 | struct list_head *report_list =&hid->report_enum[HID_OUTPUT_REPORT].report_list; |
| 68 | − struct input_dev *dev = hidinput->input; | |
| 68 | + struct input_dev *dev; | |
| 69 | 69 | int field_count = 0; |
| 70 | 70 | int i, j; |
| 71 | 71 | int error; |
| 72 | 72 | |
| 73 | + if (list_empty(&hid->inputs)) { | |
| 74 | + hid_err(hid, "no inputs found\n"); | |
| 75 | + return -ENODEV; | |
| 76 | + } | |
| 77 | + hidinput = list_first_entry(&hid->inputs, struct hid_input, list); | |
| 78 | + dev = hidinput->input; | |
| 79 | + | |
| 73 | 80 | if (list_empty(report_list)) { |
| 74 | 81 | hid_err(hid, "no output reports found\n"); |
| 75 | 82 | return -ENODEV; |
| @@ -1139,6 +1139,7 @@ int hid_open_report(struct hid_device *device) · 1138 unmodified lines | ||
| 1139 | 1139 | __u8 *start; |
| 1140 | 1140 | __u8 *buf; |
| 1141 | 1141 | __u8 *end; |
| 1142 | + __u8 *next; | |
| 1142 | 1143 | int ret; |
| 1143 | 1144 | static int (*dispatch_type[])(struct hid_parser *parser, |
| 1144 | 1145 | struct hid_item *item) = { |
| @@ -1192,7 +1193,8 @@ int hid_open_report(struct hid_device *device) · 47 unmodified lines | ||
| 1192 | 1193 | device->collection_size = HID_DEFAULT_NUM_COLLECTIONS; |
| 1193 | 1194 | |
| 1194 | 1195 | ret = -EINVAL; |
| 1195 | − while ((start = fetch_item(start, end, &item)) != NULL) { | |
| 1196 | + while ((next = fetch_item(start, end, &item)) != NULL) { | |
| 1197 | + start = next; | |
| 1196 | 1198 | |
| 1197 | 1199 | if (item.format != HID_ITEM_FORMAT_SHORT) { |
| 1198 | 1200 | hid_err(device, "unexpected long global item\n"); |
| @@ -1230,7 +1232,8 @@ int hid_open_report(struct hid_device *device) · 31 unmodified lines | ||
| 1230 | 1232 | } |
| 1231 | 1233 | } |
| 1232 | 1234 | |
| 1233 | − hid_err(device, "item fetching failed at offset %d\n", (int)(end - start)); | |
| 1235 | + hid_err(device, "item fetching failed at offset %u/%u\n", | |
| 1236 | + size - (unsigned int)(end - start), size); | |
| 1234 | 1237 | err: |
| 1235 | 1238 | kfree(parser->collection_stack); |
| 1236 | 1239 | alloc_err: |
| @@ -75,13 +75,19 @@ static int drff_init(struct hid_device *hid) · 74 unmodified lines | ||
| 75 | 75 | { |
| 76 | 76 | struct drff_device *drff; |
| 77 | 77 | struct hid_report *report; |
| 78 | − struct hid_input *hidinput = list_first_entry(&hid->inputs, | |
| 79 | − struct hid_input, list); | |
| 78 | + struct hid_input *hidinput; | |
| 80 | 79 | struct list_head *report_list = |
| 81 | 80 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
| 82 | − struct input_dev *dev = hidinput->input; | |
| 81 | + struct input_dev *dev; | |
| 83 | 82 | int error; |
| 84 | 83 | |
| 84 | + if (list_empty(&hid->inputs)) { | |
| 85 | + hid_err(hid, "no inputs found\n"); | |
| 86 | + return -ENODEV; | |
| 87 | + } | |
| 88 | + hidinput = list_first_entry(&hid->inputs, struct hid_input, list); | |
| 89 | + dev = hidinput->input; | |
| 90 | + | |
| 85 | 91 | if (list_empty(report_list)) { |
| 86 | 92 | hid_err(hid, "no output reports found\n"); |
| 87 | 93 | return -ENODEV; |
| @@ -47,13 +47,19 @@ static int emsff_init(struct hid_device *hid) · 46 unmodified lines | ||
| 47 | 47 | { |
| 48 | 48 | struct emsff_device *emsff; |
| 49 | 49 | struct hid_report *report; |
| 50 | − struct hid_input *hidinput = list_first_entry(&hid->inputs, | |
| 51 | − struct hid_input, list); | |
| 50 | + struct hid_input *hidinput; | |
| 52 | 51 | struct list_head *report_list = |
| 53 | 52 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
| 54 | − struct input_dev *dev = hidinput->input; | |
| 53 | + struct input_dev *dev; | |
| 55 | 54 | int error; |
| 56 | 55 | |
| 56 | + if (list_empty(&hid->inputs)) { | |
| 57 | + hid_err(hid, "no inputs found\n"); | |
| 58 | + return -ENODEV; | |
| 59 | + } | |
| 60 | + hidinput = list_first_entry(&hid->inputs, struct hid_input, list); | |
| 61 | + dev = hidinput->input; | |
| 62 | + | |
| 57 | 63 | if (list_empty(report_list)) { |
| 58 | 64 | hid_err(hid, "no output reports found\n"); |
| 59 | 65 | return -ENODEV; |
| @@ -64,14 +64,20 @@ static int gaff_init(struct hid_device *hid) · 63 unmodified lines | ||
| 64 | 64 | { |
| 65 | 65 | struct gaff_device *gaff; |
| 66 | 66 | struct hid_report *report; |
| 67 | − struct hid_input *hidinput = list_entry(hid->inputs.next, | |
| 68 | − struct hid_input, list); | |
| 67 | + struct hid_input *hidinput; | |
| 69 | 68 | struct list_head *report_list = |
| 70 | 69 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
| 71 | 70 | struct list_head *report_ptr = report_list; |
| 72 | − struct input_dev *dev = hidinput->input; | |
| 71 | + struct input_dev *dev; | |
| 73 | 72 | int error; |
| 74 | 73 | |
| 74 | + if (list_empty(&hid->inputs)) { | |
| 75 | + hid_err(hid, "no inputs found\n"); | |
| 76 | + return -ENODEV; | |
| 77 | + } | |
| 78 | + hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 79 | + dev = hidinput->input; | |
| 80 | + | |
| 75 | 81 | if (list_empty(report_list)) { |
| 76 | 82 | hid_err(hid, "no output reports found\n"); |
| 77 | 83 | return -ENODEV; |
| @@ -469,6 +469,10 @@ static int hammer_probe(struct hid_device *hdev, · 468 unmodified lines | ||
| 469 | 469 | static const struct hid_device_id hammer_devices[] = { |
| 470 | 470 | { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, |
| 471 | 471 | USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_HAMMER) }, |
| 472 | + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, | |
| 473 | + USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MAGNEMITE) }, | |
| 474 | + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, | |
| 475 | + USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MASTERBALL) }, | |
| 472 | 476 | { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, |
| 473 | 477 | USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_STAFF) }, |
| 474 | 478 | { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, |
| @@ -124,13 +124,19 @@ static int holtekff_init(struct hid_device *hid) · 123 unmodified lines | ||
| 124 | 124 | { |
| 125 | 125 | struct holtekff_device *holtekff; |
| 126 | 126 | struct hid_report *report; |
| 127 | − struct hid_input *hidinput = list_entry(hid->inputs.next, | |
| 128 | − struct hid_input, list); | |
| 127 | + struct hid_input *hidinput; | |
| 129 | 128 | struct list_head *report_list = |
| 130 | 129 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
| 131 | − struct input_dev *dev = hidinput->input; | |
| 130 | + struct input_dev *dev; | |
| 132 | 131 | int error; |
| 133 | 132 | |
| 133 | + if (list_empty(&hid->inputs)) { | |
| 134 | + hid_err(hid, "no inputs found\n"); | |
| 135 | + return -ENODEV; | |
| 136 | + } | |
| 137 | + hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 138 | + dev = hidinput->input; | |
| 139 | + | |
| 134 | 140 | if (list_empty(report_list)) { |
| 135 | 141 | hid_err(hid, "no output report found\n"); |
| 136 | 142 | return -ENODEV; |
| @@ -476,6 +476,8 @@ · 475 unmodified lines | ||
| 476 | 476 | #define USB_DEVICE_ID_GOOGLE_STAFF 0x502b |
| 477 | 477 | #define USB_DEVICE_ID_GOOGLE_WAND 0x502d |
| 478 | 478 | #define USB_DEVICE_ID_GOOGLE_WHISKERS 0x5030 |
| 479 | +#define USB_DEVICE_ID_GOOGLE_MASTERBALL 0x503c | |
| 480 | +#define USB_DEVICE_ID_GOOGLE_MAGNEMITE 0x503d | |
| 479 | 481 | |
| 480 | 482 | #define USB_VENDOR_ID_GOTOP 0x08f2 |
| 481 | 483 | #define USB_DEVICE_ID_SUPER_Q2 0x007f |
| @@ -50,11 +50,17 @@ int lg2ff_init(struct hid_device *hid) · 49 unmodified lines | ||
| 50 | 50 | { |
| 51 | 51 | struct lg2ff_device *lg2ff; |
| 52 | 52 | struct hid_report *report; |
| 53 | − struct hid_input *hidinput = list_entry(hid->inputs.next, | |
| 54 | − struct hid_input, list); | |
| 55 | − struct input_dev *dev = hidinput->input; | |
| 53 | + struct hid_input *hidinput; | |
| 54 | + struct input_dev *dev; | |
| 56 | 55 | int error; |
| 57 | 56 | |
| 57 | + if (list_empty(&hid->inputs)) { | |
| 58 | + hid_err(hid, "no inputs found\n"); | |
| 59 | + return -ENODEV; | |
| 60 | + } | |
| 61 | + hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 62 | + dev = hidinput->input; | |
| 63 | + | |
| 58 | 64 | /* Check that the report looks ok */ |
| 59 | 65 | report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7); |
| 60 | 66 | if (!report) |
| @@ -117,12 +117,19 @@ static const signed short ff3_joystick_ac[] = { · 116 unmodified lines | ||
| 117 | 117 | |
| 118 | 118 | int lg3ff_init(struct hid_device *hid) |
| 119 | 119 | { |
| 120 | − struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 121 | − struct input_dev *dev = hidinput->input; | |
| 120 | + struct hid_input *hidinput; | |
| 121 | + struct input_dev *dev; | |
| 122 | 122 | const signed short *ff_bits = ff3_joystick_ac; |
| 123 | 123 | int error; |
| 124 | 124 | int i; |
| 125 | 125 | |
| 126 | + if (list_empty(&hid->inputs)) { | |
| 127 | + hid_err(hid, "no inputs found\n"); | |
| 128 | + return -ENODEV; | |
| 129 | + } | |
| 130 | + hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 131 | + dev = hidinput->input; | |
| 132 | + | |
| 126 | 133 | /* Check that the report looks ok */ |
| 127 | 134 | if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 35)) |
| 128 | 135 | return -ENODEV; |
| @@ -1253,8 +1253,8 @@ static int lg4ff_handle_multimode_wheel(struct hid_device *hid, u16 *real_produc · 1252 unmodified lines | ||
| 1253 | 1253 | |
| 1254 | 1254 | int lg4ff_init(struct hid_device *hid) |
| 1255 | 1255 | { |
| 1256 | − struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 1257 | − struct input_dev *dev = hidinput->input; | |
| 1256 | + struct hid_input *hidinput; | |
| 1257 | + struct input_dev *dev; | |
| 1258 | 1258 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
| 1259 | 1259 | struct hid_report *report = list_entry(report_list->next, struct hid_report, list); |
| 1260 | 1260 | const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor); |
| @@ -1266,6 +1266,13 @@ int lg4ff_init(struct hid_device *hid) · 5 unmodified lines | ||
| 1266 | 1266 | int mmode_ret, mmode_idx = -1; |
| 1267 | 1267 | u16 real_product_id; |
| 1268 | 1268 | |
| 1269 | + if (list_empty(&hid->inputs)) { | |
| 1270 | + hid_err(hid, "no inputs found\n"); | |
| 1271 | + return -ENODEV; | |
| 1272 | + } | |
| 1273 | + hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 1274 | + dev = hidinput->input; | |
| 1275 | + | |
| 1269 | 1276 | /* Check that the report looks ok */ |
| 1270 | 1277 | if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7)) |
| 1271 | 1278 | return -1; |
| @@ -115,12 +115,19 @@ static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude) · 114 unmodified lines | ||
| 115 | 115 | |
| 116 | 116 | int lgff_init(struct hid_device* hid) |
| 117 | 117 | { |
| 118 | − struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 119 | − struct input_dev *dev = hidinput->input; | |
| 118 | + struct hid_input *hidinput; | |
| 119 | + struct input_dev *dev; | |
| 120 | 120 | const signed short *ff_bits = ff_joystick; |
| 121 | 121 | int error; |
| 122 | 122 | int i; |
| 123 | 123 | |
| 124 | + if (list_empty(&hid->inputs)) { | |
| 125 | + hid_err(hid, "no inputs found\n"); | |
| 126 | + return -ENODEV; | |
| 127 | + } | |
| 128 | + hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 129 | + dev = hidinput->input; | |
| 130 | + | |
| 124 | 131 | /* Check that the report looks ok */ |
| 125 | 132 | if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7)) |
| 126 | 133 | return -ENODEV; |
| @@ -1669,6 +1669,7 @@ static void hidpp_touchpad_raw_xy_event(struct hidpp_device *hidpp_dev, · 1668 unmodified lines | ||
| 1669 | 1669 | |
| 1670 | 1670 | #define HIDPP_FF_EFFECTID_NONE -1 |
| 1671 | 1671 | #define HIDPP_FF_EFFECTID_AUTOCENTER -2 |
| 1672 | +#define HIDPP_AUTOCENTER_PARAMS_LENGTH 18 | |
| 1672 | 1673 | |
| 1673 | 1674 | #define HIDPP_FF_MAX_PARAMS 20 |
| 1674 | 1675 | #define HIDPP_FF_RESERVED_SLOTS 1 |
| @@ -2009,7 +2010,7 @@ static int hidpp_ff_erase_effect(struct input_dev *dev, int effect_id) · 334 unmodified lines | ||
| 2009 | 2010 | static void hidpp_ff_set_autocenter(struct input_dev *dev, u16 magnitude) |
| 2010 | 2011 | { |
| 2011 | 2012 | struct hidpp_ff_private_data *data = dev->ff->private; |
| 2012 | − u8 params[18]; | |
| 2013 | + u8 params[HIDPP_AUTOCENTER_PARAMS_LENGTH]; | |
| 2013 | 2014 | |
| 2014 | 2015 | dbg_hid("Setting autocenter to %d.\n", magnitude); |
| 2015 | 2016 | |
| @@ -2077,23 +2078,34 @@ static DEVICE_ATTR(range, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, hidpp · 61 unmodified lines | ||
| 2077 | 2078 | static void hidpp_ff_destroy(struct ff_device *ff) |
| 2078 | 2079 | { |
| 2079 | 2080 | struct hidpp_ff_private_data *data = ff->private; |
| 2081 | + struct hid_device *hid = data->hidpp->hid_dev; | |
| 2080 | 2082 | |
| 2083 | + hid_info(hid, "Unloading HID++ force feedback.\n"); | |
| 2084 | + | |
| 2085 | + device_remove_file(&hid->dev, &dev_attr_range); | |
| 2086 | + destroy_workqueue(data->wq); | |
| 2081 | 2087 | kfree(data->effect_ids); |
| 2082 | 2088 | } |
| 2083 | 2089 | |
| 2084 | −static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index) | |
| 2090 | +static int hidpp_ff_init(struct hidpp_device *hidpp, | |
| 2091 | + struct hidpp_ff_private_data *data) | |
| 2085 | 2092 | { |
| 2086 | 2093 | struct hid_device *hid = hidpp->hid_dev; |
| 2087 | − struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 2088 | − struct input_dev *dev = hidinput->input; | |
| 2094 | + struct hid_input *hidinput; | |
| 2095 | + struct input_dev *dev; | |
| 2089 | 2096 | const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor); |
| 2090 | 2097 | const u16 bcdDevice = le16_to_cpu(udesc->bcdDevice); |
| 2091 | 2098 | struct ff_device *ff; |
| 2092 | − struct hidpp_report response; | |
| 2093 | − struct hidpp_ff_private_data *data; | |
| 2094 | − int error, j, num_slots; | |
| 2099 | + int error, j, num_slots = data->num_effects; | |
| 2095 | 2100 | u8 version; |
| 2096 | 2101 | |
| 2102 | + if (list_empty(&hid->inputs)) { | |
| 2103 | + hid_err(hid, "no inputs found\n"); | |
| 2104 | + return -ENODEV; | |
| 2105 | + } | |
| 2106 | + hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 2107 | + dev = hidinput->input; | |
| 2108 | + | |
| 2097 | 2109 | if (!dev) { |
| 2098 | 2110 | hid_err(hid, "Struct input_dev not set!\n"); |
| 2099 | 2111 | return -EINVAL; |
| @@ -2109,27 +2121,17 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index) · 9 unmodified lines | ||
| 2109 | 2121 | for (j = 0; hidpp_ff_effects_v2[j] >= 0; j++) |
| 2110 | 2122 | set_bit(hidpp_ff_effects_v2[j], dev->ffbit); |
| 2111 | 2123 | |
| 2112 | − /* Read number of slots available in device */ | |
| 2113 | − error = hidpp_send_fap_command_sync(hidpp, feature_index, | |
| 2114 | − HIDPP_FF_GET_INFO, NULL, 0, &response); | |
| 2115 | − if (error) { | |
| 2116 | − if (error < 0) | |
| 2117 | − return error; | |
| 2118 | − hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", | |
| 2119 | − __func__, error); | |
| 2120 | − return -EPROTO; | |
| 2121 | − } | |
| 2122 | − | |
| 2123 | − num_slots = response.fap.params[0] - HIDPP_FF_RESERVED_SLOTS; | |
| 2124 | − | |
| 2125 | 2124 | error = input_ff_create(dev, num_slots); |
| 2126 | 2125 | |
| 2127 | 2126 | if (error) { |
| 2128 | 2127 | hid_err(dev, "Failed to create FF device!\n"); |
| 2129 | 2128 | return error; |
| 2130 | 2129 | } |
| 2131 | − | |
| 2132 | − data = kzalloc(sizeof(*data), GFP_KERNEL); | |
| 2130 | + /* | |
| 2131 | + * Create a copy of passed data, so we can transfer memory | |
| 2132 | + * ownership to FF core | |
| 2133 | + */ | |
| 2134 | + data = kmemdup(data, sizeof(*data), GFP_KERNEL); | |
| 2133 | 2135 | if (!data) |
| 2134 | 2136 | return -ENOMEM; |
| 2135 | 2137 | data->effect_ids = kcalloc(num_slots, sizeof(int), GFP_KERNEL); |
| @@ -2145,10 +2147,7 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index) · 9 unmodified lines | ||
| 2145 | 2147 | } |
| 2146 | 2148 | |
| 2147 | 2149 | data->hidpp = hidpp; |
| 2148 | − data->feature_index = feature_index; | |
| 2149 | 2150 | data->version = version; |
| 2150 | − data->slot_autocenter = 0; | |
| 2151 | − data->num_effects = num_slots; | |
| 2152 | 2151 | for (j = 0; j < num_slots; j++) |
| 2153 | 2152 | data->effect_ids[j] = -1; |
| 2154 | 2153 | |
| @@ -2162,68 +2161,20 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index) · 7 unmodified lines | ||
| 2162 | 2161 | ff->set_autocenter = hidpp_ff_set_autocenter; |
| 2163 | 2162 | ff->destroy = hidpp_ff_destroy; |
| 2164 | 2163 | |
| 2165 | − | |
| 2166 | − /* reset all forces */ | |
| 2167 | − error = hidpp_send_fap_command_sync(hidpp, feature_index, | |
| 2168 | − HIDPP_FF_RESET_ALL, NULL, 0, &response); | |
| 2169 | − | |
| 2170 | − /* Read current Range */ | |
| 2171 | − error = hidpp_send_fap_command_sync(hidpp, feature_index, | |
| 2172 | − HIDPP_FF_GET_APERTURE, NULL, 0, &response); | |
| 2173 | − if (error) | |
| 2174 | − hid_warn(hidpp->hid_dev, "Failed to read range from device!\n"); | |
| 2175 | − data->range = error ? 900 : get_unaligned_be16(&response.fap.params[0]); | |
| 2176 | − | |
| 2177 | 2164 | /* Create sysfs interface */ |
| 2178 | 2165 | error = device_create_file(&(hidpp->hid_dev->dev), &dev_attr_range); |
| 2179 | 2166 | if (error) |
| 2180 | 2167 | hid_warn(hidpp->hid_dev, "Unable to create sysfs interface for \"range\", errno %d!\n", error); |
| 2181 | 2168 | |
| 2182 | − /* Read the current gain values */ | |
| 2183 | − error = hidpp_send_fap_command_sync(hidpp, feature_index, | |
| 2184 | − HIDPP_FF_GET_GLOBAL_GAINS, NULL, 0, &response); | |
| 2185 | − if (error) | |
| 2186 | − hid_warn(hidpp->hid_dev, "Failed to read gain values from device!\n"); | |
| 2187 | − data->gain = error ? 0xffff : get_unaligned_be16(&response.fap.params[0]); | |
| 2188 | − /* ignore boost value at response.fap.params[2] */ | |
| 2189 | − | |
| 2190 | 2169 | /* init the hardware command queue */ |
| 2191 | 2170 | atomic_set(&data->workqueue_size, 0); |
| 2192 | 2171 | |
| 2193 | − /* initialize with zero autocenter to get wheel in usable state */ | |
| 2194 | − hidpp_ff_set_autocenter(dev, 0); | |
| 2195 | − | |
| 2196 | 2172 | hid_info(hid, "Force feedback support loaded (firmware release %d).\n", |
| 2197 | 2173 | version); |
| 2198 | 2174 | |
| 2199 | 2175 | return 0; |
| 2200 | 2176 | } |
| 2201 | 2177 | |
| 2202 | −static int hidpp_ff_deinit(struct hid_device *hid) | |
| 2203 | −{ | |
| 2204 | − struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 2205 | − struct input_dev *dev = hidinput->input; | |
| 2206 | − struct hidpp_ff_private_data *data; | |
| 2207 | − | |
| 2208 | − if (!dev) { | |
| 2209 | − hid_err(hid, "Struct input_dev not found!\n"); | |
| 2210 | − return -EINVAL; | |
| 2211 | − } | |
| 2212 | − | |
| 2213 | − hid_info(hid, "Unloading HID++ force feedback.\n"); | |
| 2214 | − data = dev->ff->private; | |
| 2215 | − if (!data) { | |
| 2216 | − hid_err(hid, "Private data not found!\n"); | |
| 2217 | − return -EINVAL; | |
| 2218 | − } | |
| 2219 | − | |
| 2220 | − destroy_workqueue(data->wq); | |
| 2221 | − device_remove_file(&hid->dev, &dev_attr_range); | |
| 2222 | − | |
| 2223 | − return 0; | |
| 2224 | −} | |
| 2225 | − | |
| 2226 | − | |
| 2227 | 2178 | /* ************************************************************************** */ |
| 2228 | 2179 | /* */ |
| 2229 | 2180 | /* Device Support */ |
| @@ -2725,24 +2676,93 @@ static int k400_connect(struct hid_device *hdev, bool connected) · 495 unmodified lines | ||
| 2725 | 2676 | |
| 2726 | 2677 | #define HIDPP_PAGE_G920_FORCE_FEEDBACK 0x8123 |
| 2727 | 2678 | |
| 2728 | −static int g920_get_config(struct hidpp_device *hidpp) | |
| 2679 | +static int g920_ff_set_autocenter(struct hidpp_device *hidpp, | |
| 2680 | + struct hidpp_ff_private_data *data) | |
| 2729 | 2681 | { |
| 2682 | + struct hidpp_report response; | |
| 2683 | + u8 params[HIDPP_AUTOCENTER_PARAMS_LENGTH] = { | |
| 2684 | + [1] = HIDPP_FF_EFFECT_SPRING | HIDPP_FF_EFFECT_AUTOSTART, | |
| 2685 | + }; | |
| 2686 | + int ret; | |
| 2687 | + | |
| 2688 | + /* initialize with zero autocenter to get wheel in usable state */ | |
| 2689 | + | |
| 2690 | + dbg_hid("Setting autocenter to 0.\n"); | |
| 2691 | + ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, | |
| 2692 | + HIDPP_FF_DOWNLOAD_EFFECT, | |
| 2693 | + params, ARRAY_SIZE(params), | |
| 2694 | + &response); | |
| 2695 | + if (ret) | |
| 2696 | + hid_warn(hidpp->hid_dev, "Failed to autocenter device!\n"); | |
| 2697 | + else | |
| 2698 | + data->slot_autocenter = response.fap.params[0]; | |
| 2699 | + | |
| 2700 | + return ret; | |
| 2701 | +} | |
| 2702 | + | |
| 2703 | +static int g920_get_config(struct hidpp_device *hidpp, | |
| 2704 | + struct hidpp_ff_private_data *data) | |
| 2705 | +{ | |
| 2706 | + struct hidpp_report response; | |
| 2730 | 2707 | u8 feature_type; |
| 2731 | − u8 feature_index; | |
| 2732 | 2708 | int ret; |
| 2733 | 2709 | |
| 2710 | + memset(data, 0, sizeof(*data)); | |
| 2711 | + | |
| 2734 | 2712 | /* Find feature and store for later use */ |
| 2735 | 2713 | ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_G920_FORCE_FEEDBACK, |
| 2736 | − &feature_index, &feature_type); | |
| 2714 | + &data->feature_index, &feature_type); | |
| 2737 | 2715 | if (ret) |
| 2738 | 2716 | return ret; |
| 2739 | 2717 | |
| 2740 | − ret = hidpp_ff_init(hidpp, feature_index); | |
| 2718 | + /* Read number of slots available in device */ | |
| 2719 | + ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, | |
| 2720 | + HIDPP_FF_GET_INFO, | |
| 2721 | + NULL, 0, | |
| 2722 | + &response); | |
| 2723 | + if (ret) { | |
| 2724 | + if (ret < 0) | |
| 2725 | + return ret; | |
| 2726 | + hid_err(hidpp->hid_dev, | |
| 2727 | + "%s: received protocol error 0x%02x\n", __func__, ret); | |
| 2728 | + return -EPROTO; | |
| 2729 | + } | |
| 2730 | + | |
| 2731 | + data->num_effects = response.fap.params[0] - HIDPP_FF_RESERVED_SLOTS; | |
| 2732 | + | |
| 2733 | + /* reset all forces */ | |
| 2734 | + ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, | |
| 2735 | + HIDPP_FF_RESET_ALL, | |
| 2736 | + NULL, 0, | |
| 2737 | + &response); | |
| 2741 | 2738 | if (ret) |
| 2742 | − hid_warn(hidpp->hid_dev, "Unable to initialize force feedback support, errno %d\n", | |
| 2743 | − ret); | |
| 2739 | + hid_warn(hidpp->hid_dev, "Failed to reset all forces!\n"); | |
| 2744 | 2740 | |
| 2745 | − return 0; | |
| 2741 | + ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, | |
| 2742 | + HIDPP_FF_GET_APERTURE, | |
| 2743 | + NULL, 0, | |
| 2744 | + &response); | |
| 2745 | + if (ret) { | |
| 2746 | + hid_warn(hidpp->hid_dev, | |
| 2747 | + "Failed to read range from device!\n"); | |
| 2748 | + } | |
| 2749 | + data->range = ret ? | |
| 2750 | + 900 : get_unaligned_be16(&response.fap.params[0]); | |
| 2751 | + | |
| 2752 | + /* Read the current gain values */ | |
| 2753 | + ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, | |
| 2754 | + HIDPP_FF_GET_GLOBAL_GAINS, | |
| 2755 | + NULL, 0, | |
| 2756 | + &response); | |
| 2757 | + if (ret) | |
| 2758 | + hid_warn(hidpp->hid_dev, | |
| 2759 | + "Failed to read gain values from device!\n"); | |
| 2760 | + data->gain = ret ? | |
| 2761 | + 0xffff : get_unaligned_be16(&response.fap.params[0]); | |
| 2762 | + | |
| 2763 | + /* ignore boost value at response.fap.params[2] */ | |
| 2764 | + | |
| 2765 | + return g920_ff_set_autocenter(hidpp, data); | |
| 2746 | 2766 | } |
| 2747 | 2767 | |
| 2748 | 2768 | /* -------------------------------------------------------------------------- */ |
| @@ -3458,34 +3478,45 @@ static int hidpp_get_report_length(struct hid_device *hdev, int id) · 709 unmodified lines | ||
| 3458 | 3478 | return report->field[0]->report_count + 1; |
| 3459 | 3479 | } |
| 3460 | 3480 | |
| 3461 | −static bool hidpp_validate_report(struct hid_device *hdev, int id, | |
| 3462 | − int expected_length, bool optional) | |
| 3481 | +static bool hidpp_validate_device(struct hid_device *hdev) | |
| 3463 | 3482 | { |
| 3464 | − int report_length; | |
| 3483 | + struct hidpp_device *hidpp = hid_get_drvdata(hdev); | |
| 3484 | + int id, report_length, supported_reports = 0; | |
| 3465 | 3485 | |
| 3466 | − if (id >= HID_MAX_IDS || id < 0) { | |
| 3467 | − hid_err(hdev, "invalid HID report id %u\n", id); | |
| 3468 | − return false; | |
| 3486 | + id = REPORT_ID_HIDPP_SHORT; | |
| 3487 | + report_length = hidpp_get_report_length(hdev, id); | |
| 3488 | + if (report_length) { | |
| 3489 | + if (report_length < HIDPP_REPORT_SHORT_LENGTH) | |
| 3490 | + goto bad_device; | |
| 3491 | + | |
| 3492 | + supported_reports++; | |
| 3469 | 3493 | } |
| 3470 | 3494 | |
| 3495 | + id = REPORT_ID_HIDPP_LONG; | |
| 3471 | 3496 | report_length = hidpp_get_report_length(hdev, id); |
| 3472 | − if (!report_length) | |
| 3473 | − return optional; | |
| 3497 | + if (report_length) { | |
| 3498 | + if (report_length < HIDPP_REPORT_LONG_LENGTH) | |
| 3499 | + goto bad_device; | |
| 3474 | 3500 | |
| 3475 | − if (report_length < expected_length) { | |
| 3476 | − hid_warn(hdev, "not enough values in hidpp report %d\n", id); | |
| 3477 | − return false; | |
| 3501 | + supported_reports++; | |
| 3478 | 3502 | } |
| 3479 | 3503 | |
| 3480 | − return true; | |
| 3481 | −} | |
| 3504 | + id = REPORT_ID_HIDPP_VERY_LONG; | |
| 3505 | + report_length = hidpp_get_report_length(hdev, id); | |
| 3506 | + if (report_length) { | |
| 3507 | + if (report_length < HIDPP_REPORT_LONG_LENGTH || | |
| 3508 | + report_length > HIDPP_REPORT_VERY_LONG_MAX_LENGTH) | |
| 3509 | + goto bad_device; | |
| 3482 | 3510 | |
| 3483 | −static bool hidpp_validate_device(struct hid_device *hdev) | |
| 3484 | −{ | |
| 3485 | − return hidpp_validate_report(hdev, REPORT_ID_HIDPP_SHORT, | |
| 3486 | − HIDPP_REPORT_SHORT_LENGTH, false) && | |
| 3487 | − hidpp_validate_report(hdev, REPORT_ID_HIDPP_LONG, | |
| 3488 | − HIDPP_REPORT_LONG_LENGTH, true); | |
| 3511 | + supported_reports++; | |
| 3512 | + hidpp->very_long_report_length = report_length; | |
| 3513 | + } | |
| 3514 | + | |
| 3515 | + return supported_reports; | |
| 3516 | + | |
| 3517 | +bad_device: | |
| 3518 | + hid_warn(hdev, "not enough values in hidpp report %d\n", id); | |
| 3519 | + return false; | |
| 3489 | 3520 | } |
| 3490 | 3521 | |
| 3491 | 3522 | static bool hidpp_application_equals(struct hid_device *hdev, |
| @@ -3505,6 +3536,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) · 13 unmodified lines | ||
| 3505 | 3536 | int ret; |
| 3506 | 3537 | bool connected; |
| 3507 | 3538 | unsigned int connect_mask = HID_CONNECT_DEFAULT; |
| 3539 | + struct hidpp_ff_private_data data; | |
| 3508 | 3540 | |
| 3509 | 3541 | /* report_fixup needs drvdata to be set before we call hid_parse */ |
| 3510 | 3542 | hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL); |
| @@ -3531,11 +3563,6 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) · 20 unmodified lines | ||
| 3531 | 3563 | return hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
| 3532 | 3564 | } |
| 3533 | 3565 | |
| 3534 | − hidpp->very_long_report_length = | |
| 3535 | − hidpp_get_report_length(hdev, REPORT_ID_HIDPP_VERY_LONG); | |
| 3536 | − if (hidpp->very_long_report_length > HIDPP_REPORT_VERY_LONG_MAX_LENGTH) | |
| 3537 | − hidpp->very_long_report_length = HIDPP_REPORT_VERY_LONG_MAX_LENGTH; | |
| 3538 | − | |
| 3539 | 3566 | if (id->group == HID_GROUP_LOGITECH_DJ_DEVICE) |
| 3540 | 3567 | hidpp->quirks |= HIDPP_QUIRK_UNIFYING; |
| 3541 | 3568 | |
| @@ -3614,7 +3641,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) · 72 unmodified lines | ||
| 3614 | 3641 | if (ret) |
| 3615 | 3642 | goto hid_hw_init_fail; |
| 3616 | 3643 | } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { |
| 3617 | − ret = g920_get_config(hidpp); | |
| 3644 | + ret = g920_get_config(hidpp, &data); | |
| 3618 | 3645 | if (ret) |
| 3619 | 3646 | goto hid_hw_init_fail; |
| 3620 | 3647 | } |
| @@ -3636,6 +3663,14 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) · 15 unmodified lines | ||
| 3636 | 3663 | goto hid_hw_start_fail; |
| 3637 | 3664 | } |
| 3638 | 3665 | |
| 3666 | + if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { | |
| 3667 | + ret = hidpp_ff_init(hidpp, &data); | |
| 3668 | + if (ret) | |
| 3669 | + hid_warn(hidpp->hid_dev, | |
| 3670 | + "Unable to initialize force feedback support, errno %d\n", | |
| 3671 | + ret); | |
| 3672 | + } | |
| 3673 | + | |
| 3639 | 3674 | return ret; |
| 3640 | 3675 | |
| 3641 | 3676 | hid_hw_init_fail: |
| @@ -3658,9 +3693,6 @@ static void hidpp_remove(struct hid_device *hdev) · 16 unmodified lines | ||
| 3658 | 3693 | |
| 3659 | 3694 | sysfs_remove_group(&hdev->dev.kobj, &ps_attribute_group); |
| 3660 | 3695 | |
| 3661 | − if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) | |
| 3662 | − hidpp_ff_deinit(hdev); | |
| 3663 | − | |
| 3664 | 3696 | hid_hw_stop(hdev); |
| 3665 | 3697 | cancel_work_sync(&hidpp->work); |
| 3666 | 3698 | mutex_destroy(&hidpp->send_mutex); |
| @@ -328,11 +328,17 @@ static int ms_play_effect(struct input_dev *dev, void *data, · 327 unmodified lines | ||
| 328 | 328 | |
| 329 | 329 | static int ms_init_ff(struct hid_device *hdev) |
| 330 | 330 | { |
| 331 | − struct hid_input *hidinput = list_entry(hdev->inputs.next, | |
| 332 | − struct hid_input, list); | |
| 333 | − struct input_dev *input_dev = hidinput->input; | |
| 331 | + struct hid_input *hidinput; | |
| 332 | + struct input_dev *input_dev; | |
| 334 | 333 | struct ms_data *ms = hid_get_drvdata(hdev); |
| 335 | 334 | |
| 335 | + if (list_empty(&hdev->inputs)) { | |
| 336 | + hid_err(hdev, "no inputs found\n"); | |
| 337 | + return -ENODEV; | |
| 338 | + } | |
| 339 | + hidinput = list_entry(hdev->inputs.next, struct hid_input, list); | |
| 340 | + input_dev = hidinput->input; | |
| 341 | + | |
| 336 | 342 | if (!(ms->quirks & MS_QUIRK_FF)) |
| 337 | 343 | return 0; |
| 338 | 344 | |
| @@ -516,7 +516,7 @@ static void pcmidi_setup_extra_keys( · 515 unmodified lines | ||
| 516 | 516 | MY PICTURES => KEY_WORDPROCESSOR |
| 517 | 517 | MY MUSIC=> KEY_SPREADSHEET |
| 518 | 518 | */ |
| 519 | − unsigned int keys[] = { | |
| 519 | + static const unsigned int keys[] = { | |
| 520 | 520 | KEY_FN, |
| 521 | 521 | KEY_MESSENGER, KEY_CALENDAR, |
| 522 | 522 | KEY_ADDRESSBOOK, KEY_DOCUMENTS, |
| @@ -532,7 +532,7 @@ static void pcmidi_setup_extra_keys( · 9 unmodified lines | ||
| 532 | 532 | 0 |
| 533 | 533 | }; |
| 534 | 534 | |
| 535 | − unsigned int *pkeys = &keys[0]; | |
| 535 | + const unsigned int *pkeys = &keys[0]; | |
| 536 | 536 | unsigned short i; |
| 537 | 537 | |
| 538 | 538 | if (pm->ifnum != 1) /* only set up ONCE for interace 1 */ |
| @@ -2254,9 +2254,15 @@ static int sony_play_effect(struct input_dev *dev, void *data, · 2253 unmodified lines | ||
| 2254 | 2254 | |
| 2255 | 2255 | static int sony_init_ff(struct sony_sc *sc) |
| 2256 | 2256 | { |
| 2257 | − struct hid_input *hidinput = list_entry(sc->hdev->inputs.next, | |
| 2258 | − struct hid_input, list); | |
| 2259 | − struct input_dev *input_dev = hidinput->input; | |
| 2257 | + struct hid_input *hidinput; | |
| 2258 | + struct input_dev *input_dev; | |
| 2259 | + | |
| 2260 | + if (list_empty(&sc->hdev->inputs)) { | |
| 2261 | + hid_err(sc->hdev, "no inputs found\n"); | |
| 2262 | + return -ENODEV; | |
| 2263 | + } | |
| 2264 | + hidinput = list_entry(sc->hdev->inputs.next, struct hid_input, list); | |
| 2265 | + input_dev = hidinput->input; | |
| 2260 | 2266 | |
| 2261 | 2267 | input_set_capability(input_dev, EV_FF, FF_RUMBLE); |
| 2262 | 2268 | return input_ff_create_memless(input_dev, NULL, sony_play_effect); |
| @@ -124,12 +124,18 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits) · 123 unmodified lines | ||
| 124 | 124 | struct tmff_device *tmff; |
| 125 | 125 | struct hid_report *report; |
| 126 | 126 | struct list_head *report_list; |
| 127 | − struct hid_input *hidinput = list_entry(hid->inputs.next, | |
| 128 | − struct hid_input, list); | |
| 129 | − struct input_dev *input_dev = hidinput->input; | |
| 127 | + struct hid_input *hidinput; | |
| 128 | + struct input_dev *input_dev; | |
| 130 | 129 | int error; |
| 131 | 130 | int i; |
| 132 | 131 | |
| 132 | + if (list_empty(&hid->inputs)) { | |
| 133 | + hid_err(hid, "no inputs found\n"); | |
| 134 | + return -ENODEV; | |
| 135 | + } | |
| 136 | + hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 137 | + input_dev = hidinput->input; | |
| 138 | + | |
| 133 | 139 | tmff = kzalloc(sizeof(struct tmff_device), GFP_KERNEL); |
| 134 | 140 | if (!tmff) |
| 135 | 141 | return -ENOMEM; |
| @@ -54,11 +54,17 @@ static int zpff_init(struct hid_device *hid) · 53 unmodified lines | ||
| 54 | 54 | { |
| 55 | 55 | struct zpff_device *zpff; |
| 56 | 56 | struct hid_report *report; |
| 57 | − struct hid_input *hidinput = list_entry(hid->inputs.next, | |
| 58 | − struct hid_input, list); | |
| 59 | − struct input_dev *dev = hidinput->input; | |
| 57 | + struct hid_input *hidinput; | |
| 58 | + struct input_dev *dev; | |
| 60 | 59 | int i, error; |
| 61 | 60 | |
| 61 | + if (list_empty(&hid->inputs)) { | |
| 62 | + hid_err(hid, "no inputs found\n"); | |
| 63 | + return -ENODEV; | |
| 64 | + } | |
| 65 | + hidinput = list_entry(hid->inputs.next, struct hid_input, list); | |
| 66 | + dev = hidinput->input; | |
| 67 | + | |
| 62 | 68 | for (i = 0; i < 4; i++) { |
| 63 | 69 | report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, i, 1); |
| 64 | 70 | if (!report) |
| @@ -26,7 +26,6 @@ · 25 unmodified lines | ||
| 26 | 26 | #include <linux/delay.h> |
| 27 | 27 | #include <linux/slab.h> |
| 28 | 28 | #include <linux/pm.h> |
| 29 | −#include <linux/pm_runtime.h> | |
| 30 | 29 | #include <linux/device.h> |
| 31 | 30 | #include <linux/wait.h> |
| 32 | 31 | #include <linux/err.h> |
| @@ -48,8 +47,6 @@ · 15 unmodified lines | ||
| 48 | 47 | /* quirks to control the device */ |
| 49 | 48 | #define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV BIT(0) |
| 50 | 49 | #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1) |
| 51 | −#define I2C_HID_QUIRK_NO_RUNTIME_PM BIT(2) | |
| 52 | −#define I2C_HID_QUIRK_DELAY_AFTER_SLEEP BIT(3) | |
| 53 | 50 | #define I2C_HID_QUIRK_BOGUS_IRQ BIT(4) |
| 54 | 51 | |
| 55 | 52 | /* flags */ |
| @@ -172,14 +169,7 @@ static const struct i2c_hid_quirks { · 116 unmodified lines | ||
| 172 | 169 | { USB_VENDOR_ID_WEIDA, HID_ANY_ID, |
| 173 | 170 | I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, |
| 174 | 171 | { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, |
| 175 | − I2C_HID_QUIRK_NO_IRQ_AFTER_RESET | | |
| 176 | − I2C_HID_QUIRK_NO_RUNTIME_PM }, | |
| 177 | − { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_4B33, | |
| 178 | − I2C_HID_QUIRK_DELAY_AFTER_SLEEP }, | |
| 179 | − { USB_VENDOR_ID_LG, I2C_DEVICE_ID_LG_8001, | |
| 180 | − I2C_HID_QUIRK_NO_RUNTIME_PM }, | |
| 181 | − { I2C_VENDOR_ID_GOODIX, I2C_DEVICE_ID_GOODIX_01F0, | |
| 182 | − I2C_HID_QUIRK_NO_RUNTIME_PM }, | |
| 172 | + I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, | |
| 183 | 173 | { USB_VENDOR_ID_ELAN, HID_ANY_ID, |
| 184 | 174 | I2C_HID_QUIRK_BOGUS_IRQ }, |
| 185 | 175 | { 0, 0 } |
| @@ -397,7 +387,6 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state) · 211 unmodified lines | ||
| 397 | 387 | { |
| 398 | 388 | struct i2c_hid *ihid = i2c_get_clientdata(client); |
| 399 | 389 | int ret; |
| 400 | − unsigned long now, delay; | |
| 401 | 390 | |
| 402 | 391 | i2c_hid_dbg(ihid, "%s\n", __func__); |
| 403 | 392 | |
| @@ -415,22 +404,9 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state) · 11 unmodified lines | ||
| 415 | 404 | goto set_pwr_exit; |
| 416 | 405 | } |
| 417 | 406 | |
| 418 | − if (ihid->quirks & I2C_HID_QUIRK_DELAY_AFTER_SLEEP && | |
| 419 | − power_state == I2C_HID_PWR_ON) { | |
| 420 | − now = jiffies; | |
| 421 | − if (time_after(ihid->sleep_delay, now)) { | |
| 422 | − delay = jiffies_to_usecs(ihid->sleep_delay - now); | |
| 423 | − usleep_range(delay, delay + 1); | |
| 424 | − } | |
| 425 | − } | |
| 426 | − | |
| 427 | 407 | ret = __i2c_hid_command(client, &hid_set_power_cmd, power_state, |
| 428 | 408 | 0, NULL, 0, NULL, 0); |
| 429 | 409 | |
| 430 | − if (ihid->quirks & I2C_HID_QUIRK_DELAY_AFTER_SLEEP && | |
| 431 | − power_state == I2C_HID_PWR_SLEEP) | |
| 432 | − ihid->sleep_delay = jiffies + msecs_to_jiffies(20); | |
| 433 | − | |
| 434 | 410 | if (ret) |
| 435 | 411 | dev_err(&client->dev, "failed to change power setting.\n"); |
| 436 | 412 | |
| @@ -471,8 +447,12 @@ static int i2c_hid_hwreset(struct i2c_client *client) · 34 unmodified lines | ||
| 471 | 447 | if (ret) { |
| 472 | 448 | dev_err(&client->dev, "failed to reset device.\n"); |
| 473 | 449 | i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); |
| 450 | + goto out_unlock; | |
| 474 | 451 | } |
| 475 | 452 | |
| 453 | + /* At least some SIS devices need this after reset */ | |
| 454 | + ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); | |
| 455 | + | |
| 476 | 456 | out_unlock: |
| 477 | 457 | mutex_unlock(&ihid->reset_lock); |
| 478 | 458 | return ret; |
| @@ -791,11 +771,6 @@ static int i2c_hid_open(struct hid_device *hid) · 312 unmodified lines | ||
| 791 | 771 | { |
| 792 | 772 | struct i2c_client *client = hid->driver_data; |
| 793 | 773 | struct i2c_hid *ihid = i2c_get_clientdata(client); |
| 794 | − int ret = 0; | |
| 795 | − | |
| 796 | − ret = pm_runtime_get_sync(&client->dev); | |
| 797 | − if (ret < 0) | |
| 798 | − return ret; | |
| 799 | 774 | |
| 800 | 775 | set_bit(I2C_HID_STARTED, &ihid->flags); |
| 801 | 776 | return 0; |
| @@ -807,27 +782,6 @@ static void i2c_hid_close(struct hid_device *hid) · 5 unmodified lines | ||
| 807 | 782 | struct i2c_hid *ihid = i2c_get_clientdata(client); |
| 808 | 783 | |
| 809 | 784 | clear_bit(I2C_HID_STARTED, &ihid->flags); |
| 810 | − | |
| 811 | − /* Save some power */ | |
| 812 | − pm_runtime_put(&client->dev); | |
| 813 | −} | |
| 814 | − | |
| 815 | −static int i2c_hid_power(struct hid_device *hid, int lvl) | |
| 816 | −{ | |
| 817 | − struct i2c_client *client = hid->driver_data; | |
| 818 | − struct i2c_hid *ihid = i2c_get_clientdata(client); | |
| 819 | − | |
| 820 | − i2c_hid_dbg(ihid, "%s lvl:%d\n", __func__, lvl); | |
| 821 | − | |
| 822 | − switch (lvl) { | |
| 823 | − case PM_HINT_FULLON: | |
| 824 | − pm_runtime_get_sync(&client->dev); | |
| 825 | − break; | |
| 826 | − case PM_HINT_NORMAL: | |
| 827 | − pm_runtime_put(&client->dev); | |
| 828 | − break; | |
| 829 | − } | |
| 830 | − return 0; | |
| 831 | 785 | } |
| 832 | 786 | |
| 833 | 787 | struct hid_ll_driver i2c_hid_ll_driver = { |
| @@ -836,7 +790,6 @@ struct hid_ll_driver i2c_hid_ll_driver = { · 2 unmodified lines | ||
| 836 | 790 | .stop = i2c_hid_stop, |
| 837 | 791 | .open = i2c_hid_open, |
| 838 | 792 | .close = i2c_hid_close, |
| 839 | − .power = i2c_hid_power, | |
| 840 | 793 | .output_report = i2c_hid_output_report, |
| 841 | 794 | .raw_request = i2c_hid_raw_request, |
| 842 | 795 | }; |
| @@ -1104,9 +1057,6 @@ static int i2c_hid_probe(struct i2c_client *client, · 261 unmodified lines | ||
| 1104 | 1057 | |
| 1105 | 1058 | i2c_hid_acpi_fix_up_power(&client->dev); |
| 1106 | 1059 | |
| 1107 | − pm_runtime_get_noresume(&client->dev); | |
| 1108 | − pm_runtime_set_active(&client->dev); | |
| 1109 | − pm_runtime_enable(&client->dev); | |
| 1110 | 1060 | device_enable_async_suspend(&client->dev); |
| 1111 | 1061 | |
| 1112 | 1062 | /* Make sure there is something at this address */ |
| @@ -1114,16 +1064,16 @@ static int i2c_hid_probe(struct i2c_client *client, · 1 unmodified line | ||
| 1114 | 1064 | if (ret < 0) { |
| 1115 | 1065 | dev_dbg(&client->dev, "nothing at this address: %d\n", ret); |
| 1116 | 1066 | ret = -ENXIO; |
| 1117 | − goto err_pm; | |
| 1067 | + goto err_regulator; | |
| 1118 | 1068 | } |
| 1119 | 1069 | |
| 1120 | 1070 | ret = i2c_hid_fetch_hid_descriptor(ihid); |
| 1121 | 1071 | if (ret < 0) |
| 1122 | − goto err_pm; | |
| 1072 | + goto err_regulator; | |
| 1123 | 1073 | |
| 1124 | 1074 | ret = i2c_hid_init_irq(client); |
| 1125 | 1075 | if (ret < 0) |
| 1126 | − goto err_pm; | |
| 1076 | + goto err_regulator; | |
| 1127 | 1077 | |
| 1128 | 1078 | hid = hid_allocate_device(); |
| 1129 | 1079 | if (IS_ERR(hid)) { |
| @@ -1154,9 +1104,6 @@ static int i2c_hid_probe(struct i2c_client *client, · 24 unmodified lines | ||
| 1154 | 1104 | goto err_mem_free; |
| 1155 | 1105 | } |
| 1156 | 1106 | |
| 1157 | − if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM)) | |
| 1158 | − pm_runtime_put(&client->dev); | |
| 1159 | − | |
| 1160 | 1107 | return 0; |
| 1161 | 1108 | |
| 1162 | 1109 | err_mem_free: |
| @@ -1165,10 +1112,6 @@ err_mem_free: · 2 unmodified lines | ||
| 1165 | 1112 | err_irq: |
| 1166 | 1113 | free_irq(client->irq, ihid); |
| 1167 | 1114 | |
| 1168 | −err_pm: | |
| 1169 | − pm_runtime_put_noidle(&client->dev); | |
| 1170 | − pm_runtime_disable(&client->dev); | |
| 1171 | − | |
| 1172 | 1115 | err_regulator: |
| 1173 | 1116 | regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies), |
| 1174 | 1117 | ihid->pdata.supplies); |
| @@ -1181,12 +1124,6 @@ static int i2c_hid_remove(struct i2c_client *client) · 6 unmodified lines | ||
| 1181 | 1124 | struct i2c_hid *ihid = i2c_get_clientdata(client); |
| 1182 | 1125 | struct hid_device *hid; |
| 1183 | 1126 | |
| 1184 | − if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM)) | |
| 1185 | − pm_runtime_get_sync(&client->dev); | |
| 1186 | − pm_runtime_disable(&client->dev); | |
| 1187 | − pm_runtime_set_suspended(&client->dev); | |
| 1188 | − pm_runtime_put_noidle(&client->dev); | |
| 1189 | − | |
| 1190 | 1127 | hid = ihid->hid; |
| 1191 | 1128 | hid_destroy_device(hid); |
| 1192 | 1129 | |
| @@ -1219,25 +1156,15 @@ static int i2c_hid_suspend(struct device *dev) · 26 unmodified lines | ||
| 1219 | 1156 | int wake_status; |
| 1220 | 1157 | |
| 1221 | 1158 | if (hid->driver && hid->driver->suspend) { |
| 1222 | − /* | |
| 1223 | − * Wake up the device so that IO issues in | |
| 1224 | − * HID driver's suspend code can succeed. | |
| 1225 | − */ | |
| 1226 | − ret = pm_runtime_resume(dev); | |
| 1227 | − if (ret < 0) | |
| 1228 | − return ret; | |
| 1229 | − | |
| 1230 | 1159 | ret = hid->driver->suspend(hid, PMSG_SUSPEND); |
| 1231 | 1160 | if (ret < 0) |
| 1232 | 1161 | return ret; |
| 1233 | 1162 | } |
| 1234 | 1163 | |
| 1235 | − if (!pm_runtime_suspended(dev)) { | |
| 1236 | − /* Save some power */ | |
| 1237 | − i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); | |
| 1164 | + /* Save some power */ | |
| 1165 | + i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); | |
| 1238 | 1166 | |
| 1239 | − disable_irq(client->irq); | |
| 1240 | − } | |
| 1167 | + disable_irq(client->irq); | |
| 1241 | 1168 | |
| 1242 | 1169 | if (device_may_wakeup(&client->dev)) { |
| 1243 | 1170 | wake_status = enable_irq_wake(client->irq); |
| @@ -1279,11 +1206,6 @@ static int i2c_hid_resume(struct device *dev) · 35 unmodified lines | ||
| 1279 | 1206 | wake_status); |
| 1280 | 1207 | } |
| 1281 | 1208 | |
| 1282 | − /* We'll resume to full power */ | |
| 1283 | − pm_runtime_disable(dev); | |
| 1284 | − pm_runtime_set_active(dev); | |
| 1285 | − pm_runtime_enable(dev); | |
| 1286 | − | |
| 1287 | 1209 | enable_irq(client->irq); |
| 1288 | 1210 | |
| 1289 | 1211 | /* Instead of resetting device, simply powers the device on. This |
| @@ -1304,30 +1226,8 @@ static int i2c_hid_resume(struct device *dev) · 14 unmodified lines | ||
| 1304 | 1226 | } |
| 1305 | 1227 | #endif |
| 1306 | 1228 | |
| 1307 | −#ifdef CONFIG_PM | |
| 1308 | −static int i2c_hid_runtime_suspend(struct device *dev) | |
| 1309 | −{ | |
| 1310 | − struct i2c_client *client = to_i2c_client(dev); | |
| 1311 | − | |
| 1312 | − i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); | |
| 1313 | − disable_irq(client->irq); | |
| 1314 | − return 0; | |
| 1315 | −} | |
| 1316 | − | |
| 1317 | −static int i2c_hid_runtime_resume(struct device *dev) | |
| 1318 | −{ | |
| 1319 | − struct i2c_client *client = to_i2c_client(dev); | |
| 1320 | − | |
| 1321 | − enable_irq(client->irq); | |
| 1322 | − i2c_hid_set_power(client, I2C_HID_PWR_ON); | |
| 1323 | − return 0; | |
| 1324 | −} | |
| 1325 | −#endif | |
| 1326 | − | |
| 1327 | 1229 | static const struct dev_pm_ops i2c_hid_pm = { |
| 1328 | 1230 | SET_SYSTEM_SLEEP_PM_OPS(i2c_hid_suspend, i2c_hid_resume) |
| 1329 | − SET_RUNTIME_PM_OPS(i2c_hid_runtime_suspend, i2c_hid_runtime_resume, | |
| 1330 | − NULL) | |
| 1331 | 1231 | }; |
| 1332 | 1232 | |
| 1333 | 1233 | static const struct i2c_device_id i2c_hid_id_table[] = { |
| @@ -322,6 +322,25 @@ static const struct dmi_system_id i2c_hid_dmi_desc_override_table[] = { · 321 unmodified lines | ||
| 322 | 322 | }, |
| 323 | 323 | .driver_data = (void *)&sipodev_desc |
| 324 | 324 | }, |
| 325 | + { | |
| 326 | + /* | |
| 327 | + * There are at least 2 Primebook C11B versions, the older | |
| 328 | + * version has a product-name of "Primebook C11B", and a | |
| 329 | + * bios version / release / firmware revision of: | |
| 330 | + * V2.1.2 / 05/03/2018 / 18.2 | |
| 331 | + * The new version has "PRIMEBOOK C11B" as product-name and a | |
| 332 | + * bios version / release / firmware revision of: | |
| 333 | + * CFALKSW05_BIOS_V1.1.2 / 11/19/2018 / 19.2 | |
| 334 | + * Only the older version needs this quirk, note the newer | |
| 335 | + * version will not match as it has a different product-name. | |
| 336 | + */ | |
| 337 | + .ident = "Trekstor Primebook C11B", | |
| 338 | + .matches = { | |
| 339 | + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TREKSTOR"), | |
| 340 | + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Primebook C11B"), | |
| 341 | + }, | |
| 342 | + .driver_data = (void *)&sipodev_desc | |
| 343 | + }, | |
| 325 | 344 | { |
| 326 | 345 | .ident = "Direkt-Tek DTLAPY116-2", |
| 327 | 346 | .matches = { |
| @@ -84,7 +84,7 @@ int ishtp_cl_alloc_tx_ring(struct ishtp_cl *cl) · 83 unmodified lines | ||
| 84 | 84 | return 0; |
| 85 | 85 | out: |
| 86 | 86 | dev_err(&cl->device->dev, "error in allocating Tx pool\n"); |
| 87 | − ishtp_cl_free_rx_ring(cl); | |
| 87 | + ishtp_cl_free_tx_ring(cl); | |
| 88 | 88 | return -ENOMEM; |
| 89 | 89 | } |
| 90 | 90 | |
| @@ -202,6 +202,21 @@ static inline void wacom_schedule_work(struct wacom_wac *wacom_wac, · 201 unmodified lines | ||
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | +/* | |
| 206 | + * Convert a signed 32-bit integer to an unsigned n-bit integer. Undoes | |
| 207 | + * the normally-helpful work of 'hid_snto32' for fields that use signed | |
| 208 | + * ranges for questionable reasons. | |
| 209 | + */ | |
| 210 | +static inline __u32 wacom_s32tou(s32 value, __u8 n) | |
| 211 | +{ | |
| 212 | + switch (n) { | |
| 213 | + case 8: return ((__u8)value); | |
| 214 | + case 16: return ((__u16)value); | |
| 215 | + case 32: return ((__u32)value); | |
| 216 | + } | |
| 217 | + return value & (1 << (n - 1)) ? value & (~(~0U << n)) : value; | |
| 218 | +} | |
| 219 | + | |
| 205 | 220 | extern const struct hid_device_id wacom_ids[]; |
| 206 | 221 | |
| 207 | 222 | void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len); |
| @@ -2303,7 +2303,7 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field · 2302 unmodified lines | ||
| 2303 | 2303 | case HID_DG_TOOLSERIALNUMBER: |
| 2304 | 2304 | if (value) { |
| 2305 | 2305 | wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); |
| 2306 | − wacom_wac->serial[0] |= (__u32)value; | |
| 2306 | + wacom_wac->serial[0] |= wacom_s32tou(value, field->report_size); | |
| 2307 | 2307 | } |
| 2308 | 2308 | return; |
| 2309 | 2309 | case HID_DG_TWIST: |
| @@ -2319,15 +2319,17 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field · 9 unmodified lines | ||
| 2319 | 2319 | return; |
| 2320 | 2320 | case WACOM_HID_WD_SERIALHI: |
| 2321 | 2321 | if (value) { |
| 2322 | + __u32 raw_value = wacom_s32tou(value, field->report_size); | |
| 2323 | + | |
| 2322 | 2324 | wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF); |
| 2323 | − wacom_wac->serial[0] |= ((__u64)value) << 32; | |
| 2325 | + wacom_wac->serial[0] |= ((__u64)raw_value) << 32; | |
| 2324 | 2326 | /* |
| 2325 | 2327 | * Non-USI EMR devices may contain additional tool type |
| 2326 | 2328 | * information here. See WACOM_HID_WD_TOOLTYPE case for |
| 2327 | 2329 | * more details. |
| 2328 | 2330 | */ |
| 2329 | 2331 | if (value >> 20 == 1) { |
| 2330 | − wacom_wac->id[0] |= value & 0xFFFFF; | |
| 2332 | + wacom_wac->id[0] |= raw_value & 0xFFFFF; | |
| 2331 | 2333 | } |
| 2332 | 2334 | } |
| 2333 | 2335 | return; |
| @@ -2339,7 +2341,7 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field · 5 unmodified lines | ||
| 2339 | 2341 | * bitwise OR so the complete value can be built |
| 2340 | 2342 | * up over time :( |
| 2341 | 2343 | */ |
| 2342 | − wacom_wac->id[0] |= value; | |
| 2344 | + wacom_wac->id[0] |= wacom_s32tou(value, field->report_size); | |
| 2343 | 2345 | return; |
| 2344 | 2346 | case WACOM_HID_WD_OFFSETLEFT: |
| 2345 | 2347 | if (features->offset_left && value != features->offset_left) |
| @@ -170,7 +170,7 @@ static inline int ina3221_wait_for_data(struct ina3221_data *ina) · 169 unmodified lines | ||
| 170 | 170 | |
| 171 | 171 | /* Polling the CVRF bit to make sure read data is ready */ |
| 172 | 172 | return regmap_field_read_poll_timeout(ina->fields[F_CVRF], |
| 173 | − cvrf, cvrf, wait, 100000); | |
| 173 | + cvrf, cvrf, wait, wait * 2); | |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | static int ina3221_read_value(struct ina3221_data *ina, unsigned int reg, |
| @@ -82,6 +82,10 @@ · 81 unmodified lines | ||
| 82 | 82 | #define FANCTL1_FMR_REG 0x00 /* Bank 3; 1 reg per channel */ |
| 83 | 83 | #define FANCTL1_OUT_REG 0x10 /* Bank 3; 1 reg per channel */ |
| 84 | 84 | |
| 85 | +#define VOLT_MONITOR_MODE 0x0 | |
| 86 | +#define THERMAL_DIODE_MODE 0x1 | |
| 87 | +#define THERMISTOR_MODE 0x3 | |
| 88 | + | |
| 85 | 89 | #define ENABLE_TSI BIT(1) |
| 86 | 90 | |
| 87 | 91 | static const unsigned short normal_i2c[] = { |
| @@ -935,11 +939,16 @@ static int nct7904_probe(struct i2c_client *client, · 847 unmodified lines | ||
| 935 | 939 | for (i = 0; i < 4; i++) { |
| 936 | 940 | val = (ret >> (i * 2)) & 0x03; |
| 937 | 941 | bit = (1 << i); |
| 938 | − if (val == 0) { | |
| 942 | + if (val == VOLT_MONITOR_MODE) { | |
| 939 | 943 | data->tcpu_mask &= ~bit; |
| 944 | + } else if (val == THERMAL_DIODE_MODE && i < 2) { | |
| 945 | + data->temp_mode |= bit; | |
| 946 | + data->vsen_mask &= ~(0x06 << (i * 2)); | |
| 947 | + } else if (val == THERMISTOR_MODE) { | |
| 948 | + data->vsen_mask &= ~(0x02 << (i * 2)); | |
| 940 | 949 | } else { |
| 941 | − if (val == 0x1 || val == 0x2) | |
| 942 | − data->temp_mode |= bit; | |
| 950 | + /* Reserved */ | |
| 951 | + data->tcpu_mask &= ~bit; | |
| 943 | 952 | data->vsen_mask &= ~(0x06 << (i * 2)); |
| 944 | 953 | } |
| 945 | 954 | } |
| @@ -626,6 +626,9 @@ static void intel_th_gth_switch(struct intel_th_device *thdev, · 625 unmodified lines | ||
| 626 | 626 | if (!count) |
| 627 | 627 | dev_dbg(&thdev->dev, "timeout waiting for CTS Trigger\n"); |
| 628 | 628 | |
| 629 | + /* De-assert the trigger */ | |
| 630 | + iowrite32(0, gth->base + REG_CTS_CTL); | |
| 631 | + | |
| 629 | 632 | intel_th_gth_stop(gth, output, false); |
| 630 | 633 | intel_th_gth_start(gth, output); |
| 631 | 634 | } |
| @@ -164,7 +164,7 @@ struct msc { · 163 unmodified lines | ||
| 164 | 164 | }; |
| 165 | 165 | |
| 166 | 166 | static LIST_HEAD(msu_buffer_list); |
| 167 | −static struct mutex msu_buffer_mutex; | |
| 167 | +static DEFINE_MUTEX(msu_buffer_mutex); | |
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | 170 | * struct msu_buffer_entry - internal MSU buffer bookkeeping |
| @@ -327,7 +327,7 @@ static size_t msc_win_total_sz(struct msc_window *win) · 156 unmodified lines | ||
| 327 | 327 | struct msc_block_desc *bdesc = sg_virt(sg); |
| 328 | 328 | |
| 329 | 329 | if (msc_block_wrapped(bdesc)) |
| 330 | − return win->nr_blocks << PAGE_SHIFT; | |
| 330 | + return (size_t)win->nr_blocks << PAGE_SHIFT; | |
| 331 | 331 | |
| 332 | 332 | size += msc_total_sz(bdesc); |
| 333 | 333 | if (msc_block_last_written(bdesc)) |
| @@ -1848,9 +1848,14 @@ mode_store(struct device *dev, struct device_attribute *attr, const char *buf, · 1514 unmodified lines | ||
| 1848 | 1848 | len = cp - buf; |
| 1849 | 1849 | |
| 1850 | 1850 | mode = kstrndup(buf, len, GFP_KERNEL); |
| 1851 | + if (!mode) | |
| 1852 | + return -ENOMEM; | |
| 1853 | + | |
| 1851 | 1854 | i = match_string(msc_mode, ARRAY_SIZE(msc_mode), mode); |
| 1852 | − if (i >= 0) | |
| 1855 | + if (i >= 0) { | |
| 1856 | + kfree(mode); | |
| 1853 | 1857 | goto found; |
| 1858 | + } | |
| 1854 | 1859 | |
| 1855 | 1860 | /* Buffer sinks only work with a usable IRQ */ |
| 1856 | 1861 | if (!msc->do_irq) { |
| @@ -199,6 +199,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = { · 198 unmodified lines | ||
| 199 | 199 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x02a6), |
| 200 | 200 | .driver_data = (kernel_ulong_t)&intel_th_2x, |
| 201 | 201 | }, |
| 202 | + { | |
| 203 | + /* Comet Lake PCH */ | |
| 204 | + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x06a6), | |
| 205 | + .driver_data = (kernel_ulong_t)&intel_th_2x, | |
| 206 | + }, | |
| 202 | 207 | { |
| 203 | 208 | /* Ice Lake NNPI */ |
| 204 | 209 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x45c5), |
| @@ -209,6 +214,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = { · 4 unmodified lines | ||
| 209 | 214 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa0a6), |
| 210 | 215 | .driver_data = (kernel_ulong_t)&intel_th_2x, |
| 211 | 216 | }, |
| 217 | + { | |
| 218 | + /* Jasper Lake PCH */ | |
| 219 | + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4da6), | |
| 220 | + .driver_data = (kernel_ulong_t)&intel_th_2x, | |
| 221 | + }, | |
| 212 | 222 | { 0 }, |
| 213 | 223 | }; |
| 214 | 224 | |
| @@ -1399,7 +1399,7 @@ static int stm32_adc_dma_start(struct iio_dev *indio_dev) · 1398 unmodified lines | ||
| 1399 | 1399 | cookie = dmaengine_submit(desc); |
| 1400 | 1400 | ret = dma_submit_error(cookie); |
| 1401 | 1401 | if (ret) { |
| 1402 | − dmaengine_terminate_all(adc->dma_chan); | |
| 1402 | + dmaengine_terminate_sync(adc->dma_chan); | |
| 1403 | 1403 | return ret; |
| 1404 | 1404 | } |
| 1405 | 1405 | |
| @@ -1477,7 +1477,7 @@ static void __stm32_adc_buffer_predisable(struct iio_dev *indio_dev) · 71 unmodified lines | ||
| 1477 | 1477 | stm32_adc_conv_irq_disable(adc); |
| 1478 | 1478 | |
| 1479 | 1479 | if (adc->dma_chan) |
| 1480 | − dmaengine_terminate_all(adc->dma_chan); | |
| 1480 | + dmaengine_terminate_sync(adc->dma_chan); | |
| 1481 | 1481 | |
| 1482 | 1482 | if (stm32_adc_set_trig(indio_dev, NULL)) |
| 1483 | 1483 | dev_err(&indio_dev->dev, "Can't clear trigger\n"); |
| @@ -317,8 +317,11 @@ static int adis16480_set_freq(struct iio_dev *indio_dev, int val, int val2) · 316 unmodified lines | ||
| 317 | 317 | struct adis16480 *st = iio_priv(indio_dev); |
| 318 | 318 | unsigned int t, reg; |
| 319 | 319 | |
| 320 | + if (val < 0 || val2 < 0) | |
| 321 | + return -EINVAL; | |
| 322 | + | |
| 320 | 323 | t = val * 1000 + val2 / 1000; |
| 321 | − if (t <= 0) | |
| 324 | + if (t == 0) | |
| 322 | 325 | return -EINVAL; |
| 323 | 326 | |
| 324 | 327 | /* |
| @@ -114,54 +114,63 @@ static const struct inv_mpu6050_hw hw_info[] = { · 113 unmodified lines | ||
| 114 | 114 | .name = "MPU6050", |
| 115 | 115 | .reg = ®_set_6050, |
| 116 | 116 | .config = &chip_config_6050, |
| 117 | + .fifo_size = 1024, | |
| 117 | 118 | }, |
| 118 | 119 | { |
| 119 | 120 | .whoami = INV_MPU6500_WHOAMI_VALUE, |
| 120 | 121 | .name = "MPU6500", |
| 121 | 122 | .reg = ®_set_6500, |
| 122 | 123 | .config = &chip_config_6050, |
| 124 | + .fifo_size = 512, | |
| 123 | 125 | }, |
| 124 | 126 | { |
| 125 | 127 | .whoami = INV_MPU6515_WHOAMI_VALUE, |
| 126 | 128 | .name = "MPU6515", |
| 127 | 129 | .reg = ®_set_6500, |
| 128 | 130 | .config = &chip_config_6050, |
| 131 | + .fifo_size = 512, | |
| 129 | 132 | }, |
| 130 | 133 | { |
| 131 | 134 | .whoami = INV_MPU6000_WHOAMI_VALUE, |
| 132 | 135 | .name = "MPU6000", |
| 133 | 136 | .reg = ®_set_6050, |
| 134 | 137 | .config = &chip_config_6050, |
| 138 | + .fifo_size = 1024, | |
| 135 | 139 | }, |
| 136 | 140 | { |
| 137 | 141 | .whoami = INV_MPU9150_WHOAMI_VALUE, |
| 138 | 142 | .name = "MPU9150", |
| 139 | 143 | .reg = ®_set_6050, |
| 140 | 144 | .config = &chip_config_6050, |
| 145 | + .fifo_size = 1024, | |
| 141 | 146 | }, |
| 142 | 147 | { |
| 143 | 148 | .whoami = INV_MPU9250_WHOAMI_VALUE, |
| 144 | 149 | .name = "MPU9250", |
| 145 | 150 | .reg = ®_set_6500, |
| 146 | 151 | .config = &chip_config_6050, |
| 152 | + .fifo_size = 512, | |
| 147 | 153 | }, |
| 148 | 154 | { |
| 149 | 155 | .whoami = INV_MPU9255_WHOAMI_VALUE, |
| 150 | 156 | .name = "MPU9255", |
| 151 | 157 | .reg = ®_set_6500, |
| 152 | 158 | .config = &chip_config_6050, |
| 159 | + .fifo_size = 512, | |
| 153 | 160 | }, |
| 154 | 161 | { |
| 155 | 162 | .whoami = INV_ICM20608_WHOAMI_VALUE, |
| 156 | 163 | .name = "ICM20608", |
| 157 | 164 | .reg = ®_set_6500, |
| 158 | 165 | .config = &chip_config_6050, |
| 166 | + .fifo_size = 512, | |
| 159 | 167 | }, |
| 160 | 168 | { |
| 161 | 169 | .whoami = INV_ICM20602_WHOAMI_VALUE, |
| 162 | 170 | .name = "ICM20602", |
| 163 | 171 | .reg = ®_set_icm20602, |
| 164 | 172 | .config = &chip_config_6050, |
| 173 | + .fifo_size = 1008, | |
| 165 | 174 | }, |
| 166 | 175 | }; |
| 167 | 176 | |
| @@ -100,12 +100,14 @@ struct inv_mpu6050_chip_config { · 99 unmodified lines | ||
| 100 | 100 | * @name: name of the chip. |
| 101 | 101 | * @reg: register map of the chip. |
| 102 | 102 | * @config: configuration of the chip. |
| 103 | + * @fifo_size: size of the FIFO in bytes. | |
| 103 | 104 | */ |
| 104 | 105 | struct inv_mpu6050_hw { |
| 105 | 106 | u8 whoami; |
| 106 | 107 | u8 *name; |
| 107 | 108 | const struct inv_mpu6050_reg_map *reg; |
| 108 | 109 | const struct inv_mpu6050_chip_config *config; |
| 110 | + size_t fifo_size; | |
| 109 | 111 | }; |
| 110 | 112 | |
| 111 | 113 | /* |
| @@ -180,9 +180,6 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) · 179 unmodified lines | ||
| 180 | 180 | "failed to ack interrupt\n"); |
| 181 | 181 | goto flush_fifo; |
| 182 | 182 | } |
| 183 | − /* handle fifo overflow by reseting fifo */ | |
| 184 | − if (int_status & INV_MPU6050_BIT_FIFO_OVERFLOW_INT) | |
| 185 | − goto flush_fifo; | |
| 186 | 183 | if (!(int_status & INV_MPU6050_BIT_RAW_DATA_RDY_INT)) { |
| 187 | 184 | dev_warn(regmap_get_device(st->map), |
| 188 | 185 | "spurious interrupt with status 0x%x\n", int_status); |
| @@ -211,6 +208,18 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) · 22 unmodified lines | ||
| 211 | 208 | if (result) |
| 212 | 209 | goto end_session; |
| 213 | 210 | fifo_count = get_unaligned_be16(&data[0]); |
| 211 | + | |
| 212 | + /* | |
| 213 | + * Handle fifo overflow by resetting fifo. | |
| 214 | + * Reset if there is only 3 data set free remaining to mitigate | |
| 215 | + * possible delay between reading fifo count and fifo data. | |
| 216 | + */ | |
| 217 | + nb = 3 * bytes_per_datum; | |
| 218 | + if (fifo_count >= st->hw->fifo_size - nb) { | |
| 219 | + dev_warn(regmap_get_device(st->map), "fifo overflow reset\n"); | |
| 220 | + goto flush_fifo; | |
| 221 | + } | |
| 222 | + | |
| 214 | 223 | /* compute and process all complete datum */ |
| 215 | 224 | nb = fifo_count / bytes_per_datum; |
| 216 | 225 | inv_mpu6050_update_period(st, pf->timestamp, nb); |
| @@ -110,7 +110,7 @@ static int srf04_read(struct srf04_data *data) · 109 unmodified lines | ||
| 110 | 110 | udelay(data->cfg->trigger_pulse_us); |
| 111 | 111 | gpiod_set_value(data->gpiod_trig, 0); |
| 112 | 112 | |
| 113 | − /* it cannot take more than 20 ms */ | |
| 113 | + /* it should not take more than 20 ms until echo is rising */ | |
| 114 | 114 | ret = wait_for_completion_killable_timeout(&data->rising, HZ/50); |
| 115 | 115 | if (ret < 0) { |
| 116 | 116 | mutex_unlock(&data->lock); |
| @@ -120,7 +120,8 @@ static int srf04_read(struct srf04_data *data) · 3 unmodified lines | ||
| 120 | 120 | return -ETIMEDOUT; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | − ret = wait_for_completion_killable_timeout(&data->falling, HZ/50); | |
| 123 | + /* it cannot take more than 50 ms until echo is falling */ | |
| 124 | + ret = wait_for_completion_killable_timeout(&data->falling, HZ/20); | |
| 124 | 125 | if (ret < 0) { |
| 125 | 126 | mutex_unlock(&data->lock); |
| 126 | 127 | return ret; |
| @@ -135,19 +136,19 @@ static int srf04_read(struct srf04_data *data) · 8 unmodified lines | ||
| 135 | 136 | |
| 136 | 137 | dt_ns = ktime_to_ns(ktime_dt); |
| 137 | 138 | /* |
| 138 | − * measuring more than 3 meters is beyond the capabilities of | |
| 139 | − * the sensor | |
| 139 | + * measuring more than 6,45 meters is beyond the capabilities of | |
| 140 | + * the supported sensors | |
| 140 | 141 | * ==> filter out invalid results for not measuring echos of |
| 141 | 142 | * another us sensor |
| 142 | 143 | * |
| 143 | 144 | * formula: |
| 144 | − * distance 3 m | |
| 145 | − * time = ---------- = --------- = 9404389 ns | |
| 146 | − * speed 319 m/s | |
| 145 | + * distance 6,45 * 2 m | |
| 146 | + * time = ---------- = ------------ = 40438871 ns | |
| 147 | + * speed 319 m/s | |
| 147 | 148 | * |
| 148 | 149 | * using a minimum speed at -20 °C of 319 m/s |
| 149 | 150 | */ |
| 150 | − if (dt_ns > 9404389) | |
| 151 | + if (dt_ns > 40438871) | |
| 151 | 152 | return -EIO; |
| 152 | 153 | |
| 153 | 154 | time_ns = dt_ns; |
| @@ -159,20 +160,20 @@ static int srf04_read(struct srf04_data *data) · 5 unmodified lines | ||
| 159 | 160 | * with Temp in °C |
| 160 | 161 | * and speed in m/s |
| 161 | 162 | * |
| 162 | − * use 343 m/s as ultrasonic speed at 20 °C here in absence of the | |
| 163 | + * use 343,5 m/s as ultrasonic speed at 20 °C here in absence of the | |
| 163 | 164 | * temperature |
| 164 | 165 | * |
| 165 | 166 | * therefore: |
| 166 | − * time 343 | |
| 167 | − * distance = ------ * ----- | |
| 168 | − * 10^6 2 | |
| 167 | + * time 343,5 time * 106 | |
| 168 | + * distance = ------ * ------- = ------------ | |
| 169 | + * 10^6 2 617176 | |
| 169 | 170 | * with time in ns |
| 170 | 171 | * and distance in mm (one way) |
| 171 | 172 | * |
| 172 | − * because we limit to 3 meters the multiplication with 343 just | |
| 173 | + * because we limit to 6,45 meters the multiplication with 106 just | |
| 173 | 174 | * fits into 32 bit |
| 174 | 175 | */ |
| 175 | − distance_mm = time_ns * 343 / 2000000; | |
| 176 | + distance_mm = time_ns * 106 / 617176; | |
| 176 | 177 | |
| 177 | 178 | return distance_mm; |
| 178 | 179 | } |
| @@ -199,6 +199,7 @@ void ib_mad_cleanup(void); · 198 unmodified lines | ||
| 199 | 199 | int ib_sa_init(void); |
| 200 | 200 | void ib_sa_cleanup(void); |
| 201 | 201 | |
| 202 | +void rdma_nl_init(void); | |
| 202 | 203 | void rdma_nl_exit(void); |
| 203 | 204 | |
| 204 | 205 | int ib_nl_handle_resolve_resp(struct sk_buff *skb, |
| @@ -2716,6 +2716,8 @@ static int __init ib_core_init(void) · 2715 unmodified lines | ||
| 2716 | 2716 | goto err_comp_unbound; |
| 2717 | 2717 | } |
| 2718 | 2718 | |
| 2719 | + rdma_nl_init(); | |
| 2720 | + | |
| 2719 | 2721 | ret = addr_init(); |
| 2720 | 2722 | if (ret) { |
| 2721 | 2723 | pr_warn("Could't init IB address resolution\n"); |
| @@ -372,6 +372,7 @@ EXPORT_SYMBOL(iw_cm_disconnect); · 371 unmodified lines | ||
| 372 | 372 | static void destroy_cm_id(struct iw_cm_id *cm_id) |
| 373 | 373 | { |
| 374 | 374 | struct iwcm_id_private *cm_id_priv; |
| 375 | + struct ib_qp *qp; | |
| 375 | 376 | unsigned long flags; |
| 376 | 377 | |
| 377 | 378 | cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); |
| @@ -389,6 +390,9 @@ static void destroy_cm_id(struct iw_cm_id *cm_id) · 11 unmodified lines | ||
| 389 | 390 | set_bit(IWCM_F_DROP_EVENTS, &cm_id_priv->flags); |
| 390 | 391 | |
| 391 | 392 | spin_lock_irqsave(&cm_id_priv->lock, flags); |
| 393 | + qp = cm_id_priv->qp; | |
| 394 | + cm_id_priv->qp = NULL; | |
| 395 | + | |
| 392 | 396 | switch (cm_id_priv->state) { |
| 393 | 397 | case IW_CM_STATE_LISTEN: |
| 394 | 398 | cm_id_priv->state = IW_CM_STATE_DESTROYING; |
| @@ -401,7 +405,7 @@ static void destroy_cm_id(struct iw_cm_id *cm_id) · 6 unmodified lines | ||
| 401 | 405 | cm_id_priv->state = IW_CM_STATE_DESTROYING; |
| 402 | 406 | spin_unlock_irqrestore(&cm_id_priv->lock, flags); |
| 403 | 407 | /* Abrupt close of the connection */ |
| 404 | − (void)iwcm_modify_qp_err(cm_id_priv->qp); | |
| 408 | + (void)iwcm_modify_qp_err(qp); | |
| 405 | 409 | spin_lock_irqsave(&cm_id_priv->lock, flags); |
| 406 | 410 | break; |
| 407 | 411 | case IW_CM_STATE_IDLE: |
| @@ -426,11 +430,9 @@ static void destroy_cm_id(struct iw_cm_id *cm_id) · 18 unmodified lines | ||
| 426 | 430 | BUG(); |
| 427 | 431 | break; |
| 428 | 432 | } |
| 429 | − if (cm_id_priv->qp) { | |
| 430 | − cm_id_priv->id.device->ops.iw_rem_ref(cm_id_priv->qp); | |
| 431 | − cm_id_priv->qp = NULL; | |
| 432 | − } | |
| 433 | 433 | spin_unlock_irqrestore(&cm_id_priv->lock, flags); |
| 434 | + if (qp) | |
| 435 | + cm_id_priv->id.device->ops.iw_rem_ref(qp); | |
| 434 | 436 | |
| 435 | 437 | if (cm_id->mapped) { |
| 436 | 438 | iwpm_remove_mapinfo(&cm_id->local_addr, &cm_id->m_local_addr); |
| @@ -671,11 +673,11 @@ int iw_cm_accept(struct iw_cm_id *cm_id, · 234 unmodified lines | ||
| 671 | 673 | BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_RECV); |
| 672 | 674 | cm_id_priv->state = IW_CM_STATE_IDLE; |
| 673 | 675 | spin_lock_irqsave(&cm_id_priv->lock, flags); |
| 674 | − if (cm_id_priv->qp) { | |
| 675 | − cm_id->device->ops.iw_rem_ref(qp); | |
| 676 | − cm_id_priv->qp = NULL; | |
| 677 | − } | |
| 676 | + qp = cm_id_priv->qp; | |
| 677 | + cm_id_priv->qp = NULL; | |
| 678 | 678 | spin_unlock_irqrestore(&cm_id_priv->lock, flags); |
| 679 | + if (qp) | |
| 680 | + cm_id->device->ops.iw_rem_ref(qp); | |
| 679 | 681 | clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); |
| 680 | 682 | wake_up_all(&cm_id_priv->connect_wait); |
| 681 | 683 | } |
| @@ -696,7 +698,7 @@ int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param) · 14 unmodified lines | ||
| 696 | 698 | struct iwcm_id_private *cm_id_priv; |
| 697 | 699 | int ret; |
| 698 | 700 | unsigned long flags; |
| 699 | − struct ib_qp *qp; | |
| 701 | + struct ib_qp *qp = NULL; | |
| 700 | 702 | |
| 701 | 703 | cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); |
| 702 | 704 | |
| @@ -730,13 +732,13 @@ int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param) · 27 unmodified lines | ||
| 730 | 732 | return 0; /* success */ |
| 731 | 733 | |
| 732 | 734 | spin_lock_irqsave(&cm_id_priv->lock, flags); |
| 733 | − if (cm_id_priv->qp) { | |
| 734 | − cm_id->device->ops.iw_rem_ref(qp); | |
| 735 | − cm_id_priv->qp = NULL; | |
| 736 | − } | |
| 735 | + qp = cm_id_priv->qp; | |
| 736 | + cm_id_priv->qp = NULL; | |
| 737 | 737 | cm_id_priv->state = IW_CM_STATE_IDLE; |
| 738 | 738 | err: |
| 739 | 739 | spin_unlock_irqrestore(&cm_id_priv->lock, flags); |
| 740 | + if (qp) | |
| 741 | + cm_id->device->ops.iw_rem_ref(qp); | |
| 740 | 742 | clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); |
| 741 | 743 | wake_up_all(&cm_id_priv->connect_wait); |
| 742 | 744 | return ret; |
| @@ -878,6 +880,7 @@ static int cm_conn_est_handler(struct iwcm_id_private *cm_id_priv, · 135 unmodified lines | ||
| 878 | 880 | static int cm_conn_rep_handler(struct iwcm_id_private *cm_id_priv, |
| 879 | 881 | struct iw_cm_event *iw_event) |
| 880 | 882 | { |
| 883 | + struct ib_qp *qp = NULL; | |
| 881 | 884 | unsigned long flags; |
| 882 | 885 | int ret; |
| 883 | 886 | |
| @@ -896,11 +899,13 @@ static int cm_conn_rep_handler(struct iwcm_id_private *cm_id_priv, · 12 unmodified lines | ||
| 896 | 899 | cm_id_priv->state = IW_CM_STATE_ESTABLISHED; |
| 897 | 900 | } else { |
| 898 | 901 | /* REJECTED or RESET */ |
| 899 | − cm_id_priv->id.device->ops.iw_rem_ref(cm_id_priv->qp); | |
| 902 | + qp = cm_id_priv->qp; | |
| 900 | 903 | cm_id_priv->qp = NULL; |
| 901 | 904 | cm_id_priv->state = IW_CM_STATE_IDLE; |
| 902 | 905 | } |
| 903 | 906 | spin_unlock_irqrestore(&cm_id_priv->lock, flags); |
| 907 | + if (qp) | |
| 908 | + cm_id_priv->id.device->ops.iw_rem_ref(qp); | |
| 904 | 909 | ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event); |
| 905 | 910 | |
| 906 | 911 | if (iw_event->private_data_len) |
| @@ -942,21 +947,18 @@ static void cm_disconnect_handler(struct iwcm_id_private *cm_id_priv, · 35 unmodified lines | ||
| 942 | 947 | static int cm_close_handler(struct iwcm_id_private *cm_id_priv, |
| 943 | 948 | struct iw_cm_event *iw_event) |
| 944 | 949 | { |
| 950 | + struct ib_qp *qp; | |
| 945 | 951 | unsigned long flags; |
| 946 | − int ret = 0; | |
| 952 | + int ret = 0, notify_event = 0; | |
| 947 | 953 | spin_lock_irqsave(&cm_id_priv->lock, flags); |
| 954 | + qp = cm_id_priv->qp; | |
| 955 | + cm_id_priv->qp = NULL; | |
| 948 | 956 | |
| 949 | − if (cm_id_priv->qp) { | |
| 950 | − cm_id_priv->id.device->ops.iw_rem_ref(cm_id_priv->qp); | |
| 951 | − cm_id_priv->qp = NULL; | |
| 952 | − } | |
| 953 | 957 | switch (cm_id_priv->state) { |
| 954 | 958 | case IW_CM_STATE_ESTABLISHED: |
| 955 | 959 | case IW_CM_STATE_CLOSING: |
| 956 | 960 | cm_id_priv->state = IW_CM_STATE_IDLE; |
| 957 | − spin_unlock_irqrestore(&cm_id_priv->lock, flags); | |
| 958 | − ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event); | |
| 959 | − spin_lock_irqsave(&cm_id_priv->lock, flags); | |
| 961 | + notify_event = 1; | |
| 960 | 962 | break; |
| 961 | 963 | case IW_CM_STATE_DESTROYING: |
| 962 | 964 | break; |
| @@ -965,6 +967,10 @@ static int cm_close_handler(struct iwcm_id_private *cm_id_priv, · 2 unmodified lines | ||
| 965 | 967 | } |
| 966 | 968 | spin_unlock_irqrestore(&cm_id_priv->lock, flags); |
| 967 | 969 | |
| 970 | + if (qp) | |
| 971 | + cm_id_priv->id.device->ops.iw_rem_ref(qp); | |
| 972 | + if (notify_event) | |
| 973 | + ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event); | |
| 968 | 974 | return ret; |
| 969 | 975 | } |
| 970 | 976 | |
| @@ -42,9 +42,12 @@ · 41 unmodified lines | ||
| 42 | 42 | #include <linux/module.h> |
| 43 | 43 | #include "core_priv.h" |
| 44 | 44 | |
| 45 | −static DEFINE_MUTEX(rdma_nl_mutex); | |
| 46 | 45 | static struct { |
| 47 | − const struct rdma_nl_cbs *cb_table; | |
| 46 | + const struct rdma_nl_cbs *cb_table; | |
| 47 | + /* Synchronizes between ongoing netlink commands and netlink client | |
| 48 | + * unregistration. | |
| 49 | + */ | |
| 50 | + struct rw_semaphore sem; | |
| 48 | 51 | } rdma_nl_types[RDMA_NL_NUM_CLIENTS]; |
| 49 | 52 | |
| 50 | 53 | bool rdma_nl_chk_listeners(unsigned int group) |
| @@ -75,70 +78,53 @@ static bool is_nl_msg_valid(unsigned int type, unsigned int op) · 24 unmodified lines | ||
| 75 | 78 | return (op < max_num_ops[type]) ? true : false; |
| 76 | 79 | } |
| 77 | 80 | |
| 78 | −static bool | |
| 79 | −is_nl_valid(const struct sk_buff *skb, unsigned int type, unsigned int op) | |
| 81 | +static const struct rdma_nl_cbs * | |
| 82 | +get_cb_table(const struct sk_buff *skb, unsigned int type, unsigned int op) | |
| 80 | 83 | { |
| 81 | 84 | const struct rdma_nl_cbs *cb_table; |
| 82 | 85 | |
| 83 | − if (!is_nl_msg_valid(type, op)) | |
| 84 | − return false; | |
| 85 | − | |
| 86 | 86 | /* |
| 87 | 87 | * Currently only NLDEV client is supporting netlink commands in |
| 88 | 88 | * non init_net net namespace. |
| 89 | 89 | */ |
| 90 | 90 | if (sock_net(skb->sk) != &init_net && type != RDMA_NL_NLDEV) |
| 91 | − return false; | |
| 91 | + return NULL; | |
| 92 | 92 | |
| 93 | − if (!rdma_nl_types[type].cb_table) { | |
| 94 | − mutex_unlock(&rdma_nl_mutex); | |
| 95 | − request_module("rdma-netlink-subsys-%d", type); | |
| 96 | − mutex_lock(&rdma_nl_mutex); | |
| 97 | − } | |
| 93 | + cb_table = READ_ONCE(rdma_nl_types[type].cb_table); | |
| 94 | + if (!cb_table) { | |
| 95 | + /* | |
| 96 | + * Didn't get valid reference of the table, attempt module | |
| 97 | + * load once. | |
| 98 | + */ | |
| 99 | + up_read(&rdma_nl_types[type].sem); | |
| 98 | 100 | |
| 99 | − cb_table = rdma_nl_types[type].cb_table; | |
| 101 | + request_module("rdma-netlink-subsys-%d", type); | |
| 100 | 102 | |
| 103 | + down_read(&rdma_nl_types[type].sem); | |
| 104 | + cb_table = READ_ONCE(rdma_nl_types[type].cb_table); | |
| 105 | + } | |
| 101 | 106 | if (!cb_table || (!cb_table[op].dump && !cb_table[op].doit)) |
| 102 | − return false; | |
| 103 | − return true; | |
| 107 | + return NULL; | |
| 108 | + return cb_table; | |
| 104 | 109 | } |
| 105 | 110 | |
| 106 | 111 | void rdma_nl_register(unsigned int index, |
| 107 | 112 | const struct rdma_nl_cbs cb_table[]) |
| 108 | 113 | { |
| 109 | − mutex_lock(&rdma_nl_mutex); | |
| 110 | − if (!is_nl_msg_valid(index, 0)) { | |
| 111 | − /* | |
| 112 | − * All clients are not interesting in success/failure of | |
| 113 | − * this call. They want to see the print to error log and | |
| 114 | − * continue their initialization. Print warning for them, | |
| 115 | − * because it is programmer's error to be here. | |
| 116 | − */ | |
| 117 | − mutex_unlock(&rdma_nl_mutex); | |
| 118 | − WARN(true, | |
| 119 | − "The not-valid %u index was supplied to RDMA netlink\n", | |
| 120 | − index); | |
| 114 | + if (WARN_ON(!is_nl_msg_valid(index, 0)) || | |
| 115 | + WARN_ON(READ_ONCE(rdma_nl_types[index].cb_table))) | |
| 121 | 116 | return; |
| 122 | − } | |
| 123 | − | |
| 124 | − if (rdma_nl_types[index].cb_table) { | |
| 125 | − mutex_unlock(&rdma_nl_mutex); | |
| 126 | − WARN(true, | |
| 127 | − "The %u index is already registered in RDMA netlink\n", | |
| 128 | − index); | |
| 129 | − return; | |
| 130 | − } | |
| 131 | 117 | |
| 132 | − rdma_nl_types[index].cb_table = cb_table; | |
| 133 | − mutex_unlock(&rdma_nl_mutex); | |
| 118 | + /* Pairs with the READ_ONCE in is_nl_valid() */ | |
| 119 | + smp_store_release(&rdma_nl_types[index].cb_table, cb_table); | |
| 134 | 120 | } |
| 135 | 121 | EXPORT_SYMBOL(rdma_nl_register); |
| 136 | 122 | |
| 137 | 123 | void rdma_nl_unregister(unsigned int index) |
| 138 | 124 | { |
| 139 | − mutex_lock(&rdma_nl_mutex); | |
| 125 | + down_write(&rdma_nl_types[index].sem); | |
| 140 | 126 | rdma_nl_types[index].cb_table = NULL; |
| 141 | − mutex_unlock(&rdma_nl_mutex); | |
| 127 | + up_write(&rdma_nl_types[index].sem); | |
| 142 | 128 | } |
| 143 | 129 | EXPORT_SYMBOL(rdma_nl_unregister); |
| 144 | 130 | |
| @@ -170,15 +156,21 @@ static int rdma_nl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, · 25 unmodified lines | ||
| 170 | 156 | unsigned int index = RDMA_NL_GET_CLIENT(type); |
| 171 | 157 | unsigned int op = RDMA_NL_GET_OP(type); |
| 172 | 158 | const struct rdma_nl_cbs *cb_table; |
| 159 | + int err = -EINVAL; | |
| 173 | 160 | |
| 174 | − if (!is_nl_valid(skb, index, op)) | |
| 161 | + if (!is_nl_msg_valid(index, op)) | |
| 175 | 162 | return -EINVAL; |
| 176 | 163 | |
| 177 | − cb_table = rdma_nl_types[index].cb_table; | |
| 164 | + down_read(&rdma_nl_types[index].sem); | |
| 165 | + cb_table = get_cb_table(skb, index, op); | |
| 166 | + if (!cb_table) | |
| 167 | + goto done; | |
| 178 | 168 | |
| 179 | 169 | if ((cb_table[op].flags & RDMA_NL_ADMIN_PERM) && |
| 180 | − !netlink_capable(skb, CAP_NET_ADMIN)) | |
| 181 | − return -EPERM; | |
| 170 | + !netlink_capable(skb, CAP_NET_ADMIN)) { | |
| 171 | + err = -EPERM; | |
| 172 | + goto done; | |
| 173 | + } | |
| 182 | 174 | |
| 183 | 175 | /* |
| 184 | 176 | * LS responses overload the 0x100 (NLM_F_ROOT) flag. Don't |
| @@ -186,8 +178,8 @@ static int rdma_nl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, · 1 unmodified line | ||
| 186 | 178 | */ |
| 187 | 179 | if (index == RDMA_NL_LS) { |
| 188 | 180 | if (cb_table[op].doit) |
| 189 | − return cb_table[op].doit(skb, nlh, extack); | |
| 190 | − return -EINVAL; | |
| 181 | + err = cb_table[op].doit(skb, nlh, extack); | |
| 182 | + goto done; | |
| 191 | 183 | } |
| 192 | 184 | /* FIXME: Convert IWCM to properly handle doit callbacks */ |
| 193 | 185 | if ((nlh->nlmsg_flags & NLM_F_DUMP) || index == RDMA_NL_IWCM) { |
| @@ -195,14 +187,15 @@ static int rdma_nl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, · 1 unmodified line | ||
| 195 | 187 | .dump = cb_table[op].dump, |
| 196 | 188 | }; |
| 197 | 189 | if (c.dump) |
| 198 | − return netlink_dump_start(skb->sk, skb, nlh, &c); | |
| 199 | − return -EINVAL; | |
| 190 | + err = netlink_dump_start(skb->sk, skb, nlh, &c); | |
| 191 | + goto done; | |
| 200 | 192 | } |
| 201 | 193 | |
| 202 | 194 | if (cb_table[op].doit) |
| 203 | − return cb_table[op].doit(skb, nlh, extack); | |
| 204 | − | |
| 205 | − return 0; | |
| 195 | + err = cb_table[op].doit(skb, nlh, extack); | |
| 196 | +done: | |
| 197 | + up_read(&rdma_nl_types[index].sem); | |
| 198 | + return err; | |
| 206 | 199 | } |
| 207 | 200 | |
| 208 | 201 | /* |
| @@ -263,9 +256,7 @@ skip: · 54 unmodified lines | ||
| 263 | 256 | |
| 264 | 257 | static void rdma_nl_rcv(struct sk_buff *skb) |
| 265 | 258 | { |
| 266 | − mutex_lock(&rdma_nl_mutex); | |
| 267 | 259 | rdma_nl_rcv_skb(skb, &rdma_nl_rcv_msg); |
| 268 | − mutex_unlock(&rdma_nl_mutex); | |
| 269 | 260 | } |
| 270 | 261 | |
| 271 | 262 | int rdma_nl_unicast(struct net *net, struct sk_buff *skb, u32 pid) |
| @@ -297,6 +288,14 @@ int rdma_nl_multicast(struct net *net, struct sk_buff *skb, · 25 unmodified lines | ||
| 297 | 288 | } |
| 298 | 289 | EXPORT_SYMBOL(rdma_nl_multicast); |
| 299 | 290 | |
| 291 | +void rdma_nl_init(void) | |
| 292 | +{ | |
| 293 | + int idx; | |
| 294 | + | |
| 295 | + for (idx = 0; idx < RDMA_NL_NUM_CLIENTS; idx++) | |
| 296 | + init_rwsem(&rdma_nl_types[idx].sem); | |
| 297 | +} | |
| 298 | + | |
| 300 | 299 | void rdma_nl_exit(void) |
| 301 | 300 | { |
| 302 | 301 | int idx; |
| @@ -778,7 +778,7 @@ static int fill_res_counter_entry(struct sk_buff *msg, bool has_cap_net_admin, · 777 unmodified lines | ||
| 778 | 778 | container_of(res, struct rdma_counter, res); |
| 779 | 779 | |
| 780 | 780 | if (port && port != counter->port) |
| 781 | − return 0; | |
| 781 | + return -EAGAIN; | |
| 782 | 782 | |
| 783 | 783 | /* Dump it even query failed */ |
| 784 | 784 | rdma_counter_query_stats(counter); |
| @@ -98,7 +98,7 @@ ib_uverbs_init_udata_buf_or_null(struct ib_udata *udata, · 97 unmodified lines | ||
| 98 | 98 | |
| 99 | 99 | struct ib_uverbs_device { |
| 100 | 100 | atomic_t refcount; |
| 101 | − int num_comp_vectors; | |
| 101 | + u32 num_comp_vectors; | |
| 102 | 102 | struct completion comp; |
| 103 | 103 | struct device dev; |
| 104 | 104 | /* First group for device attributes, NULL terminated array */ |
| @@ -662,16 +662,17 @@ static bool find_gid_index(const union ib_gid *gid, · 661 unmodified lines | ||
| 662 | 662 | void *context) |
| 663 | 663 | { |
| 664 | 664 | struct find_gid_index_context *ctx = context; |
| 665 | + u16 vlan_id = 0xffff; | |
| 666 | + int ret; | |
| 665 | 667 | |
| 666 | 668 | if (ctx->gid_type != gid_attr->gid_type) |
| 667 | 669 | return false; |
| 668 | 670 | |
| 669 | − if ((!!(ctx->vlan_id != 0xffff) == !is_vlan_dev(gid_attr->ndev)) || | |
| 670 | − (is_vlan_dev(gid_attr->ndev) && | |
| 671 | − vlan_dev_vlan_id(gid_attr->ndev) != ctx->vlan_id)) | |
| 671 | + ret = rdma_read_gid_l2_fields(gid_attr, &vlan_id, NULL); | |
| 672 | + if (ret) | |
| 672 | 673 | return false; |
| 673 | 674 | |
| 674 | − return true; | |
| 675 | + return ctx->vlan_id == vlan_id; | |
| 675 | 676 | } |
| 676 | 677 | |
| 677 | 678 | static const struct ib_gid_attr * |
| @@ -495,7 +495,6 @@ static int _put_ep_safe(struct c4iw_dev *dev, struct sk_buff *skb) · 494 unmodified lines | ||
| 495 | 495 | |
| 496 | 496 | ep = *((struct c4iw_ep **)(skb->cb + 2 * sizeof(void *))); |
| 497 | 497 | release_ep_resources(ep); |
| 498 | − kfree_skb(skb); | |
| 499 | 498 | return 0; |
| 500 | 499 | } |
| 501 | 500 | |
| @@ -506,7 +505,6 @@ static int _put_pass_ep_safe(struct c4iw_dev *dev, struct sk_buff *skb) · 4 unmodified lines | ||
| 506 | 505 | ep = *((struct c4iw_ep **)(skb->cb + 2 * sizeof(void *))); |
| 507 | 506 | c4iw_put_ep(&ep->parent_ep->com); |
| 508 | 507 | release_ep_resources(ep); |
| 509 | − kfree_skb(skb); | |
| 510 | 508 | return 0; |
| 511 | 509 | } |
| 512 | 510 | |
| @@ -2424,20 +2422,6 @@ static int accept_cr(struct c4iw_ep *ep, struct sk_buff *skb, · 1911 unmodified lines | ||
| 2424 | 2422 | enum chip_type adapter_type = ep->com.dev->rdev.lldi.adapter_type; |
| 2425 | 2423 | |
| 2426 | 2424 | pr_debug("ep %p tid %u\n", ep, ep->hwtid); |
| 2427 | − | |
| 2428 | − skb_get(skb); | |
| 2429 | − rpl = cplhdr(skb); | |
| 2430 | − if (!is_t4(adapter_type)) { | |
| 2431 | − skb_trim(skb, roundup(sizeof(*rpl5), 16)); | |
| 2432 | − rpl5 = (void *)rpl; | |
| 2433 | − INIT_TP_WR(rpl5, ep->hwtid); | |
| 2434 | − } else { | |
| 2435 | − skb_trim(skb, sizeof(*rpl)); | |
| 2436 | − INIT_TP_WR(rpl, ep->hwtid); | |
| 2437 | − } | |
| 2438 | − OPCODE_TID(rpl) = cpu_to_be32(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL, | |
| 2439 | − ep->hwtid)); | |
| 2440 | − | |
| 2441 | 2425 | cxgb_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx, |
| 2442 | 2426 | enable_tcp_timestamps && req->tcpopt.tstamp, |
| 2443 | 2427 | (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1); |
| @@ -2483,6 +2467,20 @@ static int accept_cr(struct c4iw_ep *ep, struct sk_buff *skb, · 39 unmodified lines | ||
| 2483 | 2467 | if (tcph->ece && tcph->cwr) |
| 2484 | 2468 | opt2 |= CCTRL_ECN_V(1); |
| 2485 | 2469 | } |
| 2470 | + | |
| 2471 | + skb_get(skb); | |
| 2472 | + rpl = cplhdr(skb); | |
| 2473 | + if (!is_t4(adapter_type)) { | |
| 2474 | + skb_trim(skb, roundup(sizeof(*rpl5), 16)); | |
| 2475 | + rpl5 = (void *)rpl; | |
| 2476 | + INIT_TP_WR(rpl5, ep->hwtid); | |
| 2477 | + } else { | |
| 2478 | + skb_trim(skb, sizeof(*rpl)); | |
| 2479 | + INIT_TP_WR(rpl, ep->hwtid); | |
| 2480 | + } | |
| 2481 | + OPCODE_TID(rpl) = cpu_to_be32(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL, | |
| 2482 | + ep->hwtid)); | |
| 2483 | + | |
| 2486 | 2484 | if (CHELSIO_CHIP_VERSION(adapter_type) > CHELSIO_T4) { |
| 2487 | 2485 | u32 isn = (prandom_u32() & ~7UL) - 1; |
| 2488 | 2486 | opt2 |= T5_OPT_2_VALID_F; |
| @@ -65,6 +65,7 @@ · 64 unmodified lines | ||
| 65 | 65 | #define SDMA_DESCQ_CNT 2048 |
| 66 | 66 | #define SDMA_DESC_INTR 64 |
| 67 | 67 | #define INVALID_TAIL 0xffff |
| 68 | +#define SDMA_PAD max_t(size_t, MAX_16B_PADDING, sizeof(u32)) | |
| 68 | 69 | |
| 69 | 70 | static uint sdma_descq_cnt = SDMA_DESCQ_CNT; |
| 70 | 71 | module_param(sdma_descq_cnt, uint, S_IRUGO); |
| @@ -1296,7 +1297,7 @@ void sdma_clean(struct hfi1_devdata *dd, size_t num_engines) · 1225 unmodified lines | ||
| 1296 | 1297 | struct sdma_engine *sde; |
| 1297 | 1298 | |
| 1298 | 1299 | if (dd->sdma_pad_dma) { |
| 1299 | − dma_free_coherent(&dd->pcidev->dev, 4, | |
| 1300 | + dma_free_coherent(&dd->pcidev->dev, SDMA_PAD, | |
| 1300 | 1301 | (void *)dd->sdma_pad_dma, |
| 1301 | 1302 | dd->sdma_pad_phys); |
| 1302 | 1303 | dd->sdma_pad_dma = NULL; |
| @@ -1491,7 +1492,7 @@ int sdma_init(struct hfi1_devdata *dd, u8 port) · 188 unmodified lines | ||
| 1491 | 1492 | } |
| 1492 | 1493 | |
| 1493 | 1494 | /* Allocate memory for pad */ |
| 1494 | − dd->sdma_pad_dma = dma_alloc_coherent(&dd->pcidev->dev, sizeof(u32), | |
| 1495 | + dd->sdma_pad_dma = dma_alloc_coherent(&dd->pcidev->dev, SDMA_PAD, | |
| 1495 | 1496 | &dd->sdma_pad_phys, GFP_KERNEL); |
| 1496 | 1497 | if (!dd->sdma_pad_dma) { |
| 1497 | 1498 | dd_dev_err(dd, "failed to allocate SendDMA pad memory\n"); |
| @@ -2736,11 +2736,6 @@ static bool handle_read_kdeth_eflags(struct hfi1_ctxtdata *rcd, · 2735 unmodified lines | ||
| 2736 | 2736 | diff = cmp_psn(psn, |
| 2737 | 2737 | flow->flow_state.r_next_psn); |
| 2738 | 2738 | if (diff > 0) { |
| 2739 | − if (!(qp->r_flags & RVT_R_RDMAR_SEQ)) | |
| 2740 | − restart_tid_rdma_read_req(rcd, | |
| 2741 | − qp, | |
| 2742 | − wqe); | |
| 2743 | − | |
| 2744 | 2739 | /* Drop the packet.*/ |
| 2745 | 2740 | goto s_unlock; |
| 2746 | 2741 | } else if (diff < 0) { |
| @@ -147,9 +147,6 @@ static int pio_wait(struct rvt_qp *qp, · 146 unmodified lines | ||
| 147 | 147 | /* Length of buffer to create verbs txreq cache name */ |
| 148 | 148 | #define TXREQ_NAME_LEN 24 |
| 149 | 149 | |
| 150 | −/* 16B trailing buffer */ | |
| 151 | −static const u8 trail_buf[MAX_16B_PADDING]; | |
| 152 | − | |
| 153 | 150 | static uint wss_threshold = 80; |
| 154 | 151 | module_param(wss_threshold, uint, S_IRUGO); |
| 155 | 152 | MODULE_PARM_DESC(wss_threshold, "Percentage (1-100) of LLC to use as a threshold for a cacheless copy"); |
| @@ -820,8 +817,8 @@ static int build_verbs_tx_desc( · 664 unmodified lines | ||
| 820 | 817 | |
| 821 | 818 | /* add icrc, lt byte, and padding to flit */ |
| 822 | 819 | if (extra_bytes) |
| 823 | − ret = sdma_txadd_kvaddr(sde->dd, &tx->txreq, | |
| 824 | − (void *)trail_buf, extra_bytes); | |
| 820 | + ret = sdma_txadd_daddr(sde->dd, &tx->txreq, | |
| 821 | + sde->dd->sdma_pad_phys, extra_bytes); | |
| 825 | 822 | |
| 826 | 823 | bail_txadd: |
| 827 | 824 | return ret; |
| @@ -1089,7 +1086,8 @@ int hfi1_verbs_send_pio(struct rvt_qp *qp, struct hfi1_pkt_state *ps, · 261 unmodified lines | ||
| 1089 | 1086 | } |
| 1090 | 1087 | /* add icrc, lt byte, and padding to flit */ |
| 1091 | 1088 | if (extra_bytes) |
| 1092 | − seg_pio_copy_mid(pbuf, trail_buf, extra_bytes); | |
| 1089 | + seg_pio_copy_mid(pbuf, ppd->dd->sdma_pad_dma, | |
| 1090 | + extra_bytes); | |
| 1093 | 1091 | |
| 1094 | 1092 | seg_pio_copy_end(pbuf); |
| 1095 | 1093 | } |
| @@ -5389,9 +5389,9 @@ static void hns_roce_v2_free_eq(struct hns_roce_dev *hr_dev, · 5388 unmodified lines | ||
| 5389 | 5389 | return; |
| 5390 | 5390 | } |
| 5391 | 5391 | |
| 5392 | − if (eq->buf_list) | |
| 5393 | − dma_free_coherent(hr_dev->dev, buf_chk_sz, | |
| 5394 | − eq->buf_list->buf, eq->buf_list->map); | |
| 5392 | + dma_free_coherent(hr_dev->dev, buf_chk_sz, eq->buf_list->buf, | |
| 5393 | + eq->buf_list->map); | |
| 5394 | + kfree(eq->buf_list); | |
| 5395 | 5395 | } |
| 5396 | 5396 | |
| 5397 | 5397 | static void hns_roce_config_eqc(struct hns_roce_dev *hr_dev, |
| @@ -1967,8 +1967,8 @@ int mlx5_ib_dealloc_mw(struct ib_mw *mw) · 1966 unmodified lines | ||
| 1967 | 1967 | int err; |
| 1968 | 1968 | |
| 1969 | 1969 | if (IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING)) { |
| 1970 | − xa_erase(&dev->mdev->priv.mkey_table, | |
| 1971 | − mlx5_base_mkey(mmw->mmkey.key)); | |
| 1970 | + xa_erase_irq(&dev->mdev->priv.mkey_table, | |
| 1971 | + mlx5_base_mkey(mmw->mmkey.key)); | |
| 1972 | 1972 | /* |
| 1973 | 1973 | * pagefault_single_data_segment() may be accessing mmw under |
| 1974 | 1974 | * SRCU if the user bound an ODP MR to this MW. |
| @@ -3249,10 +3249,12 @@ static int modify_raw_packet_qp_sq( · 3248 unmodified lines | ||
| 3249 | 3249 | } |
| 3250 | 3250 | |
| 3251 | 3251 | /* Only remove the old rate after new rate was set */ |
| 3252 | − if ((old_rl.rate && | |
| 3253 | − !mlx5_rl_are_equal(&old_rl, &new_rl)) || | |
| 3254 | − (new_state != MLX5_SQC_STATE_RDY)) | |
| 3252 | + if ((old_rl.rate && !mlx5_rl_are_equal(&old_rl, &new_rl)) || | |
| 3253 | + (new_state != MLX5_SQC_STATE_RDY)) { | |
| 3255 | 3254 | mlx5_rl_remove_rate(dev, &old_rl); |
| 3255 | + if (new_state != MLX5_SQC_STATE_RDY) | |
| 3256 | + memset(&new_rl, 0, sizeof(new_rl)); | |
| 3257 | + } | |
| 3256 | 3258 | |
| 3257 | 3259 | ibqp->rl = new_rl; |
| 3258 | 3260 | sq->state = new_state; |
| @@ -76,7 +76,7 @@ static void qedr_get_dev_fw_str(struct ib_device *ibdev, char *str) · 75 unmodified lines | ||
| 76 | 76 | struct qedr_dev *qedr = get_qedr_dev(ibdev); |
| 77 | 77 | u32 fw_ver = (u32)qedr->attr.fw_ver; |
| 78 | 78 | |
| 79 | − snprintf(str, IB_FW_VERSION_NAME_MAX, "%d. %d. %d. %d", | |
| 79 | + snprintf(str, IB_FW_VERSION_NAME_MAX, "%d.%d.%d.%d", | |
| 80 | 80 | (fw_ver >> 24) & 0xFF, (fw_ver >> 16) & 0xFF, |
| 81 | 81 | (fw_ver >> 8) & 0xFF, fw_ver & 0xFF); |
| 82 | 82 | } |
| @@ -1312,6 +1312,7 @@ int siw_qp_add(struct siw_device *sdev, struct siw_qp *qp) · 1311 unmodified lines | ||
| 1312 | 1312 | void siw_free_qp(struct kref *ref) |
| 1313 | 1313 | { |
| 1314 | 1314 | struct siw_qp *found, *qp = container_of(ref, struct siw_qp, ref); |
| 1315 | + struct siw_base_qp *siw_base_qp = to_siw_base_qp(qp->ib_qp); | |
| 1315 | 1316 | struct siw_device *sdev = qp->sdev; |
| 1316 | 1317 | unsigned long flags; |
| 1317 | 1318 | |
| @@ -1334,4 +1335,5 @@ void siw_free_qp(struct kref *ref) · 16 unmodified lines | ||
| 1334 | 1335 | atomic_dec(&sdev->num_qp); |
| 1335 | 1336 | siw_dbg_qp(qp, "free QP\n"); |
| 1336 | 1337 | kfree_rcu(qp, rcu); |
| 1338 | + kfree(siw_base_qp); | |
| 1337 | 1339 | } |
| @@ -604,7 +604,6 @@ out: · 603 unmodified lines | ||
| 604 | 604 | int siw_destroy_qp(struct ib_qp *base_qp, struct ib_udata *udata) |
| 605 | 605 | { |
| 606 | 606 | struct siw_qp *qp = to_siw_qp(base_qp); |
| 607 | − struct siw_base_qp *siw_base_qp = to_siw_base_qp(base_qp); | |
| 608 | 607 | struct siw_ucontext *uctx = |
| 609 | 608 | rdma_udata_to_drv_context(udata, struct siw_ucontext, |
| 610 | 609 | base_ucontext); |
| @@ -641,7 +640,6 @@ int siw_destroy_qp(struct ib_qp *base_qp, struct ib_udata *udata) · 30 unmodified lines | ||
| 641 | 640 | qp->scq = qp->rcq = NULL; |
| 642 | 641 | |
| 643 | 642 | siw_qp_put(qp); |
| 644 | − kfree(siw_base_qp); | |
| 645 | 643 | |
| 646 | 644 | return 0; |
| 647 | 645 | } |
| @@ -405,8 +405,12 @@ void icc_set_tag(struct icc_path *path, u32 tag) · 404 unmodified lines | ||
| 405 | 405 | if (!path) |
| 406 | 406 | return; |
| 407 | 407 | |
| 408 | + mutex_lock(&icc_lock); | |
| 409 | + | |
| 408 | 410 | for (i = 0; i < path->num_nodes; i++) |
| 409 | 411 | path->reqs[i].tag = tag; |
| 412 | + | |
| 413 | + mutex_unlock(&icc_lock); | |
| 410 | 414 | } |
| 411 | 415 | EXPORT_SYMBOL_GPL(icc_set_tag); |
| 412 | 416 | |
| @@ -433,7 +433,8 @@ static int qnoc_probe(struct platform_device *pdev) · 432 unmodified lines | ||
| 433 | 433 | if (!qp) |
| 434 | 434 | return -ENOMEM; |
| 435 | 435 | |
| 436 | − data = devm_kcalloc(dev, num_nodes, sizeof(*node), GFP_KERNEL); | |
| 436 | + data = devm_kzalloc(dev, struct_size(data, nodes, num_nodes), | |
| 437 | + GFP_KERNEL); | |
| 437 | 438 | if (!data) |
| 438 | 439 | return -ENOMEM; |
| 439 | 440 | |
| @@ -790,7 +790,8 @@ static int qnoc_probe(struct platform_device *pdev) · 789 unmodified lines | ||
| 790 | 790 | if (!qp) |
| 791 | 791 | return -ENOMEM; |
| 792 | 792 | |
| 793 | − data = devm_kcalloc(&pdev->dev, num_nodes, sizeof(*node), GFP_KERNEL); | |
| 793 | + data = devm_kzalloc(&pdev->dev, struct_size(data, nodes, num_nodes), | |
| 794 | + GFP_KERNEL); | |
| 794 | 795 | if (!data) |
| 795 | 796 | return -ENOMEM; |
| 796 | 797 | |
| @@ -73,6 +73,19 @@ static const struct dmi_system_id ivrs_quirks[] __initconst = { · 72 unmodified lines | ||
| 73 | 73 | }, |
| 74 | 74 | .driver_data = (void *)&ivrs_ioapic_quirks[DELL_LATITUDE_5495], |
| 75 | 75 | }, |
| 76 | + { | |
| 77 | + /* | |
| 78 | + * Acer Aspire A315-41 requires the very same workaround as | |
| 79 | + * Dell Latitude 5495 | |
| 80 | + */ | |
| 81 | + .callback = ivrs_ioapic_quirk_cb, | |
| 82 | + .ident = "Acer Aspire A315-41", | |
| 83 | + .matches = { | |
| 84 | + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | |
| 85 | + DMI_MATCH(DMI_PRODUCT_NAME, "Aspire A315-41"), | |
| 86 | + }, | |
| 87 | + .driver_data = (void *)&ivrs_ioapic_quirks[DELL_LATITUDE_5495], | |
| 88 | + }, | |
| 76 | 89 | { |
| 77 | 90 | .callback = ivrs_ioapic_quirk_cb, |
| 78 | 91 | .ident = "Lenovo ideapad 330S-15ARR", |
| @@ -2794,7 +2794,7 @@ static int identity_mapping(struct device *dev) · 2793 unmodified lines | ||
| 2794 | 2794 | struct device_domain_info *info; |
| 2795 | 2795 | |
| 2796 | 2796 | info = dev->archdata.iommu; |
| 2797 | − if (info && info != DUMMY_DEVICE_DOMAIN_INFO) | |
| 2797 | + if (info && info != DUMMY_DEVICE_DOMAIN_INFO && info != DEFER_DEVICE_DOMAIN_INFO) | |
| 2798 | 2798 | return (info->domain == si_domain); |
| 2799 | 2799 | |
| 2800 | 2800 | return 0; |
| @@ -1105,10 +1105,8 @@ static int ipmmu_probe(struct platform_device *pdev) · 1104 unmodified lines | ||
| 1105 | 1105 | /* Root devices have mandatory IRQs */ |
| 1106 | 1106 | if (ipmmu_is_root(mmu)) { |
| 1107 | 1107 | irq = platform_get_irq(pdev, 0); |
| 1108 | − if (irq < 0) { | |
| 1109 | − dev_err(&pdev->dev, "no IRQ found\n"); | |
| 1108 | + if (irq < 0) | |
| 1110 | 1109 | return irq; |
| 1111 | − } | |
| 1112 | 1110 | |
| 1113 | 1111 | ret = devm_request_irq(&pdev->dev, irq, ipmmu_irq, 0, |
| 1114 | 1112 | dev_name(&pdev->dev), mmu); |
| @@ -744,7 +744,7 @@ capi_poll(struct file *file, poll_table *wait) · 743 unmodified lines | ||
| 744 | 744 | |
| 745 | 745 | poll_wait(file, &(cdev->recvwait), wait); |
| 746 | 746 | mask = EPOLLOUT | EPOLLWRNORM; |
| 747 | − if (!skb_queue_empty(&cdev->recvqueue)) | |
| 747 | + if (!skb_queue_empty_lockless(&cdev->recvqueue)) | |
| 748 | 748 | mask |= EPOLLIN | EPOLLRDNORM; |
| 749 | 749 | return mask; |
| 750 | 750 | } |
| @@ -952,7 +952,7 @@ static int alb_upper_dev_walk(struct net_device *upper, void *_data) · 951 unmodified lines | ||
| 952 | 952 | struct bond_vlan_tag *tags; |
| 953 | 953 | |
| 954 | 954 | if (is_vlan_dev(upper) && |
| 955 | − bond->nest_level == vlan_get_encap_level(upper) - 1) { | |
| 955 | + bond->dev->lower_level == upper->lower_level - 1) { | |
| 956 | 956 | if (upper->addr_assign_type == NET_ADDR_STOLEN) { |
| 957 | 957 | alb_send_lp_vid(slave, mac_addr, |
| 958 | 958 | vlan_dev_vlan_proto(upper), |
| @@ -1733,8 +1733,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, · 1732 unmodified lines | ||
| 1733 | 1733 | goto err_upper_unlink; |
| 1734 | 1734 | } |
| 1735 | 1735 | |
| 1736 | − bond->nest_level = dev_get_nest_level(bond_dev) + 1; | |
| 1737 | − | |
| 1738 | 1736 | /* If the mode uses primary, then the following is handled by |
| 1739 | 1737 | * bond_change_active_slave(). |
| 1740 | 1738 | */ |
| @@ -1816,7 +1814,8 @@ err_detach: · 75 unmodified lines | ||
| 1816 | 1814 | slave_disable_netpoll(new_slave); |
| 1817 | 1815 | |
| 1818 | 1816 | err_close: |
| 1819 | − slave_dev->priv_flags &= ~IFF_BONDING; | |
| 1817 | + if (!netif_is_bond_master(slave_dev)) | |
| 1818 | + slave_dev->priv_flags &= ~IFF_BONDING; | |
| 1820 | 1819 | dev_close(slave_dev); |
| 1821 | 1820 | |
| 1822 | 1821 | err_restore_mac: |
| @@ -1956,9 +1955,6 @@ static int __bond_release_one(struct net_device *bond_dev, · 133 unmodified lines | ||
| 1956 | 1955 | if (!bond_has_slaves(bond)) { |
| 1957 | 1956 | bond_set_carrier(bond); |
| 1958 | 1957 | eth_hw_addr_random(bond_dev); |
| 1959 | − bond->nest_level = SINGLE_DEPTH_NESTING; | |
| 1960 | − } else { | |
| 1961 | − bond->nest_level = dev_get_nest_level(bond_dev) + 1; | |
| 1962 | 1958 | } |
| 1963 | 1959 | |
| 1964 | 1960 | unblock_netpoll_tx(); |
| @@ -2017,7 +2013,8 @@ static int __bond_release_one(struct net_device *bond_dev, · 52 unmodified lines | ||
| 2017 | 2013 | else |
| 2018 | 2014 | dev_set_mtu(slave_dev, slave->original_mtu); |
| 2019 | 2015 | |
| 2020 | − slave_dev->priv_flags &= ~IFF_BONDING; | |
| 2016 | + if (!netif_is_bond_master(slave_dev)) | |
| 2017 | + slave_dev->priv_flags &= ~IFF_BONDING; | |
| 2021 | 2018 | |
| 2022 | 2019 | bond_free_slave(slave); |
| 2023 | 2020 | |
| @@ -2086,8 +2083,7 @@ static int bond_miimon_inspect(struct bonding *bond) · 62 unmodified lines | ||
| 2086 | 2083 | ignore_updelay = !rcu_dereference(bond->curr_active_slave); |
| 2087 | 2084 | |
| 2088 | 2085 | bond_for_each_slave_rcu(bond, slave, iter) { |
| 2089 | − slave->new_link = BOND_LINK_NOCHANGE; | |
| 2090 | − slave->link_new_state = slave->link; | |
| 2086 | + bond_propose_link_state(slave, BOND_LINK_NOCHANGE); | |
| 2091 | 2087 | |
| 2092 | 2088 | link_state = bond_check_dev_link(bond, slave->dev, 0); |
| 2093 | 2089 | |
| @@ -2121,7 +2117,7 @@ static int bond_miimon_inspect(struct bonding *bond) · 27 unmodified lines | ||
| 2121 | 2117 | } |
| 2122 | 2118 | |
| 2123 | 2119 | if (slave->delay <= 0) { |
| 2124 | − slave->new_link = BOND_LINK_DOWN; | |
| 2120 | + bond_propose_link_state(slave, BOND_LINK_DOWN); | |
| 2125 | 2121 | commit++; |
| 2126 | 2122 | continue; |
| 2127 | 2123 | } |
| @@ -2158,7 +2154,7 @@ static int bond_miimon_inspect(struct bonding *bond) · 30 unmodified lines | ||
| 2158 | 2154 | slave->delay = 0; |
| 2159 | 2155 | |
| 2160 | 2156 | if (slave->delay <= 0) { |
| 2161 | − slave->new_link = BOND_LINK_UP; | |
| 2157 | + bond_propose_link_state(slave, BOND_LINK_UP); | |
| 2162 | 2158 | commit++; |
| 2163 | 2159 | ignore_updelay = false; |
| 2164 | 2160 | continue; |
| @@ -2196,7 +2192,7 @@ static void bond_miimon_commit(struct bonding *bond) · 31 unmodified lines | ||
| 2196 | 2192 | struct slave *slave, *primary; |
| 2197 | 2193 | |
| 2198 | 2194 | bond_for_each_slave(bond, slave, iter) { |
| 2199 | − switch (slave->new_link) { | |
| 2195 | + switch (slave->link_new_state) { | |
| 2200 | 2196 | case BOND_LINK_NOCHANGE: |
| 2201 | 2197 | /* For 802.3ad mode, check current slave speed and |
| 2202 | 2198 | * duplex again in case its port was disabled after |
| @@ -2268,8 +2264,8 @@ static void bond_miimon_commit(struct bonding *bond) · 65 unmodified lines | ||
| 2268 | 2264 | |
| 2269 | 2265 | default: |
| 2270 | 2266 | slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n", |
| 2271 | − slave->new_link); | |
| 2272 | − slave->new_link = BOND_LINK_NOCHANGE; | |
| 2267 | + slave->link_new_state); | |
| 2268 | + bond_propose_link_state(slave, BOND_LINK_NOCHANGE); | |
| 2273 | 2269 | |
| 2274 | 2270 | continue; |
| 2275 | 2271 | } |
| @@ -2677,13 +2673,13 @@ static void bond_loadbalance_arp_mon(struct bonding *bond) · 401 unmodified lines | ||
| 2677 | 2673 | bond_for_each_slave_rcu(bond, slave, iter) { |
| 2678 | 2674 | unsigned long trans_start = dev_trans_start(slave->dev); |
| 2679 | 2675 | |
| 2680 | − slave->new_link = BOND_LINK_NOCHANGE; | |
| 2676 | + bond_propose_link_state(slave, BOND_LINK_NOCHANGE); | |
| 2681 | 2677 | |
| 2682 | 2678 | if (slave->link != BOND_LINK_UP) { |
| 2683 | 2679 | if (bond_time_in_interval(bond, trans_start, 1) && |
| 2684 | 2680 | bond_time_in_interval(bond, slave->last_rx, 1)) { |
| 2685 | 2681 | |
| 2686 | − slave->new_link = BOND_LINK_UP; | |
| 2682 | + bond_propose_link_state(slave, BOND_LINK_UP); | |
| 2687 | 2683 | slave_state_changed = 1; |
| 2688 | 2684 | |
| 2689 | 2685 | /* primary_slave has no meaning in round-robin |
| @@ -2708,7 +2704,7 @@ static void bond_loadbalance_arp_mon(struct bonding *bond) · 18 unmodified lines | ||
| 2708 | 2704 | if (!bond_time_in_interval(bond, trans_start, 2) || |
| 2709 | 2705 | !bond_time_in_interval(bond, slave->last_rx, 2)) { |
| 2710 | 2706 | |
| 2711 | − slave->new_link = BOND_LINK_DOWN; | |
| 2707 | + bond_propose_link_state(slave, BOND_LINK_DOWN); | |
| 2712 | 2708 | slave_state_changed = 1; |
| 2713 | 2709 | |
| 2714 | 2710 | if (slave->link_failure_count < UINT_MAX) |
| @@ -2739,8 +2735,8 @@ static void bond_loadbalance_arp_mon(struct bonding *bond) · 24 unmodified lines | ||
| 2739 | 2735 | goto re_arm; |
| 2740 | 2736 | |
| 2741 | 2737 | bond_for_each_slave(bond, slave, iter) { |
| 2742 | − if (slave->new_link != BOND_LINK_NOCHANGE) | |
| 2743 | − slave->link = slave->new_link; | |
| 2738 | + if (slave->link_new_state != BOND_LINK_NOCHANGE) | |
| 2739 | + slave->link = slave->link_new_state; | |
| 2744 | 2740 | } |
| 2745 | 2741 | |
| 2746 | 2742 | if (slave_state_changed) { |
| @@ -2763,9 +2759,9 @@ re_arm: · 16 unmodified lines | ||
| 2763 | 2759 | } |
| 2764 | 2760 | |
| 2765 | 2761 | /* Called to inspect slaves for active-backup mode ARP monitor link state |
| 2766 | − * changes. Sets new_link in slaves to specify what action should take | |
| 2767 | − * place for the slave. Returns 0 if no changes are found, >0 if changes | |
| 2768 | − * to link states must be committed. | |
| 2762 | + * changes. Sets proposed link state in slaves to specify what action | |
| 2763 | + * should take place for the slave. Returns 0 if no changes are found, >0 | |
| 2764 | + * if changes to link states must be committed. | |
| 2769 | 2765 | * |
| 2770 | 2766 | * Called with rcu_read_lock held. |
| 2771 | 2767 | */ |
| @@ -2777,12 +2773,12 @@ static int bond_ab_arp_inspect(struct bonding *bond) · 5 unmodified lines | ||
| 2777 | 2773 | int commit = 0; |
| 2778 | 2774 | |
| 2779 | 2775 | bond_for_each_slave_rcu(bond, slave, iter) { |
| 2780 | − slave->new_link = BOND_LINK_NOCHANGE; | |
| 2776 | + bond_propose_link_state(slave, BOND_LINK_NOCHANGE); | |
| 2781 | 2777 | last_rx = slave_last_rx(bond, slave); |
| 2782 | 2778 | |
| 2783 | 2779 | if (slave->link != BOND_LINK_UP) { |
| 2784 | 2780 | if (bond_time_in_interval(bond, last_rx, 1)) { |
| 2785 | − slave->new_link = BOND_LINK_UP; | |
| 2781 | + bond_propose_link_state(slave, BOND_LINK_UP); | |
| 2786 | 2782 | commit++; |
| 2787 | 2783 | } |
| 2788 | 2784 | continue; |
| @@ -2810,7 +2806,7 @@ static int bond_ab_arp_inspect(struct bonding *bond) · 21 unmodified lines | ||
| 2810 | 2806 | if (!bond_is_active_slave(slave) && |
| 2811 | 2807 | !rcu_access_pointer(bond->current_arp_slave) && |
| 2812 | 2808 | !bond_time_in_interval(bond, last_rx, 3)) { |
| 2813 | − slave->new_link = BOND_LINK_DOWN; | |
| 2809 | + bond_propose_link_state(slave, BOND_LINK_DOWN); | |
| 2814 | 2810 | commit++; |
| 2815 | 2811 | } |
| 2816 | 2812 | |
| @@ -2823,7 +2819,7 @@ static int bond_ab_arp_inspect(struct bonding *bond) · 6 unmodified lines | ||
| 2823 | 2819 | if (bond_is_active_slave(slave) && |
| 2824 | 2820 | (!bond_time_in_interval(bond, trans_start, 2) || |
| 2825 | 2821 | !bond_time_in_interval(bond, last_rx, 2))) { |
| 2826 | − slave->new_link = BOND_LINK_DOWN; | |
| 2822 | + bond_propose_link_state(slave, BOND_LINK_DOWN); | |
| 2827 | 2823 | commit++; |
| 2828 | 2824 | } |
| 2829 | 2825 | } |
| @@ -2843,7 +2839,7 @@ static void bond_ab_arp_commit(struct bonding *bond) · 13 unmodified lines | ||
| 2843 | 2839 | struct slave *slave; |
| 2844 | 2840 | |
| 2845 | 2841 | bond_for_each_slave(bond, slave, iter) { |
| 2846 | − switch (slave->new_link) { | |
| 2842 | + switch (slave->link_new_state) { | |
| 2847 | 2843 | case BOND_LINK_NOCHANGE: |
| 2848 | 2844 | continue; |
| 2849 | 2845 | |
| @@ -2893,8 +2889,9 @@ static void bond_ab_arp_commit(struct bonding *bond) · 43 unmodified lines | ||
| 2893 | 2889 | continue; |
| 2894 | 2890 | |
| 2895 | 2891 | default: |
| 2896 | − slave_err(bond->dev, slave->dev, "impossible: new_link %d on slave\n", | |
| 2897 | − slave->new_link); | |
| 2892 | + slave_err(bond->dev, slave->dev, | |
| 2893 | + "impossible: link_new_state %d on slave\n", | |
| 2894 | + slave->link_new_state); | |
| 2898 | 2895 | continue; |
| 2899 | 2896 | } |
| 2900 | 2897 | |
| @@ -3442,13 +3439,6 @@ static void bond_fold_stats(struct rtnl_link_stats64 *_res, · 541 unmodified lines | ||
| 3442 | 3439 | } |
| 3443 | 3440 | } |
| 3444 | 3441 | |
| 3445 | −static int bond_get_nest_level(struct net_device *bond_dev) | |
| 3446 | −{ | |
| 3447 | − struct bonding *bond = netdev_priv(bond_dev); | |
| 3448 | − | |
| 3449 | − return bond->nest_level; | |
| 3450 | −} | |
| 3451 | − | |
| 3452 | 3442 | static void bond_get_stats(struct net_device *bond_dev, |
| 3453 | 3443 | struct rtnl_link_stats64 *stats) |
| 3454 | 3444 | { |
| @@ -3457,7 +3447,7 @@ static void bond_get_stats(struct net_device *bond_dev, · 2 unmodified lines | ||
| 3457 | 3447 | struct list_head *iter; |
| 3458 | 3448 | struct slave *slave; |
| 3459 | 3449 | |
| 3460 | − spin_lock_nested(&bond->stats_lock, bond_get_nest_level(bond_dev)); | |
| 3450 | + spin_lock(&bond->stats_lock); | |
| 3461 | 3451 | memcpy(stats, &bond->bond_stats, sizeof(*stats)); |
| 3462 | 3452 | |
| 3463 | 3453 | rcu_read_lock(); |
| @@ -4268,7 +4258,6 @@ static const struct net_device_ops bond_netdev_ops = { · 804 unmodified lines | ||
| 4268 | 4258 | .ndo_neigh_setup = bond_neigh_setup, |
| 4269 | 4259 | .ndo_vlan_rx_add_vid = bond_vlan_rx_add_vid, |
| 4270 | 4260 | .ndo_vlan_rx_kill_vid = bond_vlan_rx_kill_vid, |
| 4271 | − .ndo_get_lock_subclass = bond_get_nest_level, | |
| 4272 | 4261 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 4273 | 4262 | .ndo_netpoll_setup = bond_netpoll_setup, |
| 4274 | 4263 | .ndo_netpoll_cleanup = bond_netpoll_cleanup, |
| @@ -4296,7 +4285,6 @@ void bond_setup(struct net_device *bond_dev) · 21 unmodified lines | ||
| 4296 | 4285 | struct bonding *bond = netdev_priv(bond_dev); |
| 4297 | 4286 | |
| 4298 | 4287 | spin_lock_init(&bond->mode_lock); |
| 4299 | − spin_lock_init(&bond->stats_lock); | |
| 4300 | 4288 | bond->params = bonding_defaults; |
| 4301 | 4289 | |
| 4302 | 4290 | /* Initialize pointers */ |
| @@ -4365,6 +4353,7 @@ static void bond_uninit(struct net_device *bond_dev) · 62 unmodified lines | ||
| 4365 | 4353 | |
| 4366 | 4354 | list_del(&bond->bond_list); |
| 4367 | 4355 | |
| 4356 | + lockdep_unregister_key(&bond->stats_lock_key); | |
| 4368 | 4357 | bond_debug_unregister(bond); |
| 4369 | 4358 | } |
| 4370 | 4359 | |
| @@ -4768,8 +4757,9 @@ static int bond_init(struct net_device *bond_dev) · 397 unmodified lines | ||
| 4768 | 4757 | if (!bond->wq) |
| 4769 | 4758 | return -ENOMEM; |
| 4770 | 4759 | |
| 4771 | − bond->nest_level = SINGLE_DEPTH_NESTING; | |
| 4772 | − netdev_lockdep_set_classes(bond_dev); | |
| 4760 | + spin_lock_init(&bond->stats_lock); | |
| 4761 | + lockdep_register_key(&bond->stats_lock_key); | |
| 4762 | + lockdep_set_class(&bond->stats_lock, &bond->stats_lock_key); | |
| 4773 | 4763 | |
| 4774 | 4764 | list_add_tail(&bond->bond_list, &bn->dev_list); |
| 4775 | 4765 | |
| @@ -52,6 +52,7 @@ · 51 unmodified lines | ||
| 52 | 52 | #define CONTROL_EX_PDR BIT(8) |
| 53 | 53 | |
| 54 | 54 | /* control register */ |
| 55 | +#define CONTROL_SWR BIT(15) | |
| 55 | 56 | #define CONTROL_TEST BIT(7) |
| 56 | 57 | #define CONTROL_CCE BIT(6) |
| 57 | 58 | #define CONTROL_DISABLE_AR BIT(5) |
| @@ -97,6 +98,9 @@ · 39 unmodified lines | ||
| 97 | 98 | #define BTR_TSEG2_SHIFT 12 |
| 98 | 99 | #define BTR_TSEG2_MASK (0x7 << BTR_TSEG2_SHIFT) |
| 99 | 100 | |
| 101 | +/* interrupt register */ | |
| 102 | +#define INT_STS_PENDING 0x8000 | |
| 103 | + | |
| 100 | 104 | /* brp extension register */ |
| 101 | 105 | #define BRP_EXT_BRPE_MASK 0x0f |
| 102 | 106 | #define BRP_EXT_BRPE_SHIFT 0 |
| @@ -569,6 +573,26 @@ static void c_can_configure_msg_objects(struct net_device *dev) · 466 unmodified lines | ||
| 569 | 573 | IF_MCONT_RCV_EOB); |
| 570 | 574 | } |
| 571 | 575 | |
| 576 | +static int c_can_software_reset(struct net_device *dev) | |
| 577 | +{ | |
| 578 | + struct c_can_priv *priv = netdev_priv(dev); | |
| 579 | + int retry = 0; | |
| 580 | + | |
| 581 | + if (priv->type != BOSCH_D_CAN) | |
| 582 | + return 0; | |
| 583 | + | |
| 584 | + priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_SWR | CONTROL_INIT); | |
| 585 | + while (priv->read_reg(priv, C_CAN_CTRL_REG) & CONTROL_SWR) { | |
| 586 | + msleep(20); | |
| 587 | + if (retry++ > 100) { | |
| 588 | + netdev_err(dev, "CCTRL: software reset failed\n"); | |
| 589 | + return -EIO; | |
| 590 | + } | |
| 591 | + } | |
| 592 | + | |
| 593 | + return 0; | |
| 594 | +} | |
| 595 | + | |
| 572 | 596 | /* |
| 573 | 597 | * Configure C_CAN chip: |
| 574 | 598 | * - enable/disable auto-retransmission |
| @@ -578,6 +602,11 @@ static void c_can_configure_msg_objects(struct net_device *dev) · 3 unmodified lines | ||
| 578 | 602 | static int c_can_chip_config(struct net_device *dev) |
| 579 | 603 | { |
| 580 | 604 | struct c_can_priv *priv = netdev_priv(dev); |
| 605 | + int err; | |
| 606 | + | |
| 607 | + err = c_can_software_reset(dev); | |
| 608 | + if (err) | |
| 609 | + return err; | |
| 581 | 610 | |
| 582 | 611 | /* enable automatic retransmission */ |
| 583 | 612 | priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_ENABLE_AR); |
| @@ -886,6 +915,9 @@ static int c_can_handle_state_change(struct net_device *dev, · 302 unmodified lines | ||
| 886 | 915 | struct can_berr_counter bec; |
| 887 | 916 | |
| 888 | 917 | switch (error_type) { |
| 918 | + case C_CAN_NO_ERROR: | |
| 919 | + priv->can.state = CAN_STATE_ERROR_ACTIVE; | |
| 920 | + break; | |
| 889 | 921 | case C_CAN_ERROR_WARNING: |
| 890 | 922 | /* error warning state */ |
| 891 | 923 | priv->can.can_stats.error_warning++; |
| @@ -916,6 +948,13 @@ static int c_can_handle_state_change(struct net_device *dev, · 24 unmodified lines | ||
| 916 | 948 | ERR_CNT_RP_SHIFT; |
| 917 | 949 | |
| 918 | 950 | switch (error_type) { |
| 951 | + case C_CAN_NO_ERROR: | |
| 952 | + /* error warning state */ | |
| 953 | + cf->can_id |= CAN_ERR_CRTL; | |
| 954 | + cf->data[1] = CAN_ERR_CRTL_ACTIVE; | |
| 955 | + cf->data[6] = bec.txerr; | |
| 956 | + cf->data[7] = bec.rxerr; | |
| 957 | + break; | |
| 919 | 958 | case C_CAN_ERROR_WARNING: |
| 920 | 959 | /* error warning state */ |
| 921 | 960 | cf->can_id |= CAN_ERR_CRTL; |
| @@ -1029,10 +1068,16 @@ static int c_can_poll(struct napi_struct *napi, int quota) · 107 unmodified lines | ||
| 1029 | 1068 | u16 curr, last = priv->last_status; |
| 1030 | 1069 | int work_done = 0; |
| 1031 | 1070 | |
| 1032 | − priv->last_status = curr = priv->read_reg(priv, C_CAN_STS_REG); | |
| 1033 | − /* Ack status on C_CAN. D_CAN is self clearing */ | |
| 1034 | − if (priv->type != BOSCH_D_CAN) | |
| 1035 | − priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED); | |
| 1071 | + /* Only read the status register if a status interrupt was pending */ | |
| 1072 | + if (atomic_xchg(&priv->sie_pending, 0)) { | |
| 1073 | + priv->last_status = curr = priv->read_reg(priv, C_CAN_STS_REG); | |
| 1074 | + /* Ack status on C_CAN. D_CAN is self clearing */ | |
| 1075 | + if (priv->type != BOSCH_D_CAN) | |
| 1076 | + priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED); | |
| 1077 | + } else { | |
| 1078 | + /* no change detected ... */ | |
| 1079 | + curr = last; | |
| 1080 | + } | |
| 1036 | 1081 | |
| 1037 | 1082 | /* handle state changes */ |
| 1038 | 1083 | if ((curr & STATUS_EWARN) && (!(last & STATUS_EWARN))) { |
| @@ -1054,11 +1099,17 @@ static int c_can_poll(struct napi_struct *napi, int quota) · 15 unmodified lines | ||
| 1054 | 1099 | /* handle bus recovery events */ |
| 1055 | 1100 | if ((!(curr & STATUS_BOFF)) && (last & STATUS_BOFF)) { |
| 1056 | 1101 | netdev_dbg(dev, "left bus off state\n"); |
| 1057 | − priv->can.state = CAN_STATE_ERROR_ACTIVE; | |
| 1102 | + work_done += c_can_handle_state_change(dev, C_CAN_ERROR_PASSIVE); | |
| 1058 | 1103 | } |
| 1104 | + | |
| 1059 | 1105 | if ((!(curr & STATUS_EPASS)) && (last & STATUS_EPASS)) { |
| 1060 | 1106 | netdev_dbg(dev, "left error passive state\n"); |
| 1061 | − priv->can.state = CAN_STATE_ERROR_ACTIVE; | |
| 1107 | + work_done += c_can_handle_state_change(dev, C_CAN_ERROR_WARNING); | |
| 1108 | + } | |
| 1109 | + | |
| 1110 | + if ((!(curr & STATUS_EWARN)) && (last & STATUS_EWARN)) { | |
| 1111 | + netdev_dbg(dev, "left error warning state\n"); | |
| 1112 | + work_done += c_can_handle_state_change(dev, C_CAN_NO_ERROR); | |
| 1062 | 1113 | } |
| 1063 | 1114 | |
| 1064 | 1115 | /* handle lec errors on the bus */ |
| @@ -1083,10 +1134,16 @@ static irqreturn_t c_can_isr(int irq, void *dev_id) · 18 unmodified lines | ||
| 1083 | 1134 | { |
| 1084 | 1135 | struct net_device *dev = (struct net_device *)dev_id; |
| 1085 | 1136 | struct c_can_priv *priv = netdev_priv(dev); |
| 1137 | + int reg_int; | |
| 1086 | 1138 | |
| 1087 | − if (!priv->read_reg(priv, C_CAN_INT_REG)) | |
| 1139 | + reg_int = priv->read_reg(priv, C_CAN_INT_REG); | |
| 1140 | + if (!reg_int) | |
| 1088 | 1141 | return IRQ_NONE; |
| 1089 | 1142 | |
| 1143 | + /* save for later use */ | |
| 1144 | + if (reg_int & INT_STS_PENDING) | |
| 1145 | + atomic_set(&priv->sie_pending, 1); | |
| 1146 | + | |
| 1090 | 1147 | /* disable all interrupts and schedule the NAPI */ |
| 1091 | 1148 | c_can_irq_control(priv, false); |
| 1092 | 1149 | napi_schedule(&priv->napi); |
| @@ -198,6 +198,7 @@ struct c_can_priv { · 197 unmodified lines | ||
| 198 | 198 | struct net_device *dev; |
| 199 | 199 | struct device *device; |
| 200 | 200 | atomic_t tx_active; |
| 201 | + atomic_t sie_pending; | |
| 201 | 202 | unsigned long tx_dir; |
| 202 | 203 | int last_status; |
| 203 | 204 | u16 (*read_reg) (const struct c_can_priv *priv, enum reg index); |
| @@ -848,6 +848,7 @@ void of_can_transceiver(struct net_device *dev) · 847 unmodified lines | ||
| 848 | 848 | return; |
| 849 | 849 | |
| 850 | 850 | ret = of_property_read_u32(dn, "max-bitrate", &priv->bitrate_max); |
| 851 | + of_node_put(dn); | |
| 851 | 852 | if ((ret && ret != -EINVAL) || (!ret && !priv->bitrate_max)) |
| 852 | 853 | netdev_warn(dev, "Invalid value for transceiver max bitrate. Ignoring bitrate limit.\n"); |
| 853 | 854 | } |
| @@ -677,6 +677,7 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr) · 676 unmodified lines | ||
| 677 | 677 | struct can_frame *cf; |
| 678 | 678 | bool rx_errors = false, tx_errors = false; |
| 679 | 679 | u32 timestamp; |
| 680 | + int err; | |
| 680 | 681 | |
| 681 | 682 | timestamp = priv->read(®s->timer) << 16; |
| 682 | 683 | |
| @@ -725,7 +726,9 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr) · 42 unmodified lines | ||
| 725 | 726 | if (tx_errors) |
| 726 | 727 | dev->stats.tx_errors++; |
| 727 | 728 | |
| 728 | − can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); | |
| 729 | + err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); | |
| 730 | + if (err) | |
| 731 | + dev->stats.rx_fifo_errors++; | |
| 729 | 732 | } |
| 730 | 733 | |
| 731 | 734 | static void flexcan_irq_state(struct net_device *dev, u32 reg_esr) |
| @@ -738,6 +741,7 @@ static void flexcan_irq_state(struct net_device *dev, u32 reg_esr) · 6 unmodified lines | ||
| 738 | 741 | int flt; |
| 739 | 742 | struct can_berr_counter bec; |
| 740 | 743 | u32 timestamp; |
| 744 | + int err; | |
| 741 | 745 | |
| 742 | 746 | timestamp = priv->read(®s->timer) << 16; |
| 743 | 747 | |
| @@ -769,7 +773,9 @@ static void flexcan_irq_state(struct net_device *dev, u32 reg_esr) · 25 unmodified lines | ||
| 769 | 773 | if (unlikely(new_state == CAN_STATE_BUS_OFF)) |
| 770 | 774 | can_bus_off(dev); |
| 771 | 775 | |
| 772 | − can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); | |
| 776 | + err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); | |
| 777 | + if (err) | |
| 778 | + dev->stats.rx_fifo_errors++; | |
| 773 | 779 | } |
| 774 | 780 | |
| 775 | 781 | static inline struct flexcan_priv *rx_offload_to_priv(struct can_rx_offload *offload) |
| @@ -1188,6 +1194,7 @@ static int flexcan_chip_start(struct net_device *dev) · 412 unmodified lines | ||
| 1188 | 1194 | reg_mecr = priv->read(®s->mecr); |
| 1189 | 1195 | reg_mecr &= ~FLEXCAN_MECR_ECRWRDIS; |
| 1190 | 1196 | priv->write(reg_mecr, ®s->mecr); |
| 1197 | + reg_mecr |= FLEXCAN_MECR_ECCDIS; | |
| 1191 | 1198 | reg_mecr &= ~(FLEXCAN_MECR_NCEFAFRZ | FLEXCAN_MECR_HANCEI_MSK | |
| 1192 | 1199 | FLEXCAN_MECR_FANCEI_MSK); |
| 1193 | 1200 | priv->write(reg_mecr, ®s->mecr); |
| @@ -107,37 +107,95 @@ static int can_rx_offload_compare(struct sk_buff *a, struct sk_buff *b) · 106 unmodified lines | ||
| 107 | 107 | return cb_b->timestamp - cb_a->timestamp; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | −static struct sk_buff *can_rx_offload_offload_one(struct can_rx_offload *offload, unsigned int n) | |
| 110 | +/** | |
| 111 | + * can_rx_offload_offload_one() - Read one CAN frame from HW | |
| 112 | + * @offload: pointer to rx_offload context | |
| 113 | + * @n: number of mailbox to read | |
| 114 | + * | |
| 115 | + * The task of this function is to read a CAN frame from mailbox @n | |
| 116 | + * from the device and return the mailbox's content as a struct | |
| 117 | + * sk_buff. | |
| 118 | + * | |
| 119 | + * If the struct can_rx_offload::skb_queue exceeds the maximal queue | |
| 120 | + * length (struct can_rx_offload::skb_queue_len_max) or no skb can be | |
| 121 | + * allocated, the mailbox contents is discarded by reading it into an | |
| 122 | + * overflow buffer. This way the mailbox is marked as free by the | |
| 123 | + * driver. | |
| 124 | + * | |
| 125 | + * Return: A pointer to skb containing the CAN frame on success. | |
| 126 | + * | |
| 127 | + * NULL if the mailbox @n is empty. | |
| 128 | + * | |
| 129 | + * ERR_PTR() in case of an error | |
| 130 | + */ | |
| 131 | +static struct sk_buff * | |
| 132 | +can_rx_offload_offload_one(struct can_rx_offload *offload, unsigned int n) | |
| 111 | 133 | { |
| 112 | − struct sk_buff *skb = NULL; | |
| 134 | + struct sk_buff *skb = NULL, *skb_error = NULL; | |
| 113 | 135 | struct can_rx_offload_cb *cb; |
| 114 | 136 | struct can_frame *cf; |
| 115 | 137 | int ret; |
| 116 | 138 | |
| 117 | − /* If queue is full or skb not available, read to discard mailbox */ | |
| 118 | − if (likely(skb_queue_len(&offload->skb_queue) <= | |
| 119 | − offload->skb_queue_len_max)) | |
| 139 | + if (likely(skb_queue_len(&offload->skb_queue) < | |
| 140 | + offload->skb_queue_len_max)) { | |
| 120 | 141 | skb = alloc_can_skb(offload->dev, &cf); |
| 142 | + if (unlikely(!skb)) | |
| 143 | + skb_error = ERR_PTR(-ENOMEM); /* skb alloc failed */ | |
| 144 | + } else { | |
| 145 | + skb_error = ERR_PTR(-ENOBUFS); /* skb_queue is full */ | |
| 146 | + } | |
| 121 | 147 | |
| 122 | − if (!skb) { | |
| 148 | + /* If queue is full or skb not available, drop by reading into | |
| 149 | + * overflow buffer. | |
| 150 | + */ | |
| 151 | + if (unlikely(skb_error)) { | |
| 123 | 152 | struct can_frame cf_overflow; |
| 124 | 153 | u32 timestamp; |
| 125 | 154 | |
| 126 | 155 | ret = offload->mailbox_read(offload, &cf_overflow, |
| 127 | 156 | ×tamp, n); |
| 128 | − if (ret) | |
| 129 | − offload->dev->stats.rx_dropped++; | |
| 130 | 157 | |
| 131 | − return NULL; | |
| 158 | + /* Mailbox was empty. */ | |
| 159 | + if (unlikely(!ret)) | |
| 160 | + return NULL; | |
| 161 | + | |
| 162 | + /* Mailbox has been read and we're dropping it or | |
| 163 | + * there was a problem reading the mailbox. | |
| 164 | + * | |
| 165 | + * Increment error counters in any case. | |
| 166 | + */ | |
| 167 | + offload->dev->stats.rx_dropped++; | |
| 168 | + offload->dev->stats.rx_fifo_errors++; | |
| 169 | + | |
| 170 | + /* There was a problem reading the mailbox, propagate | |
| 171 | + * error value. | |
| 172 | + */ | |
| 173 | + if (unlikely(ret < 0)) | |
| 174 | + return ERR_PTR(ret); | |
| 175 | + | |
| 176 | + return skb_error; | |
| 132 | 177 | } |
| 133 | 178 | |
| 134 | 179 | cb = can_rx_offload_get_cb(skb); |
| 135 | 180 | ret = offload->mailbox_read(offload, cf, &cb->timestamp, n); |
| 136 | − if (!ret) { | |
| 181 | + | |
| 182 | + /* Mailbox was empty. */ | |
| 183 | + if (unlikely(!ret)) { | |
| 137 | 184 | kfree_skb(skb); |
| 138 | 185 | return NULL; |
| 139 | 186 | } |
| 140 | 187 | |
| 188 | + /* There was a problem reading the mailbox, propagate error value. */ | |
| 189 | + if (unlikely(ret < 0)) { | |
| 190 | + kfree_skb(skb); | |
| 191 | + | |
| 192 | + offload->dev->stats.rx_dropped++; | |
| 193 | + offload->dev->stats.rx_fifo_errors++; | |
| 194 | + | |
| 195 | + return ERR_PTR(ret); | |
| 196 | + } | |
| 197 | + | |
| 198 | + /* Mailbox was read. */ | |
| 141 | 199 | return skb; |
| 142 | 200 | } |
| 143 | 201 | |
| @@ -157,8 +215,8 @@ int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, u64 pen · 13 unmodified lines | ||
| 157 | 215 | continue; |
| 158 | 216 | |
| 159 | 217 | skb = can_rx_offload_offload_one(offload, i); |
| 160 | − if (!skb) | |
| 161 | − break; | |
| 218 | + if (IS_ERR_OR_NULL(skb)) | |
| 219 | + continue; | |
| 162 | 220 | |
| 163 | 221 | __skb_queue_add_sort(&skb_queue, skb, can_rx_offload_compare); |
| 164 | 222 | } |
| @@ -188,7 +246,13 @@ int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload) · 23 unmodified lines | ||
| 188 | 246 | struct sk_buff *skb; |
| 189 | 247 | int received = 0; |
| 190 | 248 | |
| 191 | − while ((skb = can_rx_offload_offload_one(offload, 0))) { | |
| 249 | + while (1) { | |
| 250 | + skb = can_rx_offload_offload_one(offload, 0); | |
| 251 | + if (IS_ERR(skb)) | |
| 252 | + continue; | |
| 253 | + if (!skb) | |
| 254 | + break; | |
| 255 | + | |
| 192 | 256 | skb_queue_tail(&offload->skb_queue, skb); |
| 193 | 257 | received++; |
| 194 | 258 | } |
| @@ -207,8 +271,10 @@ int can_rx_offload_queue_sorted(struct can_rx_offload *offload, · 12 unmodified lines | ||
| 207 | 271 | unsigned long flags; |
| 208 | 272 | |
| 209 | 273 | if (skb_queue_len(&offload->skb_queue) > |
| 210 | − offload->skb_queue_len_max) | |
| 211 | − return -ENOMEM; | |
| 274 | + offload->skb_queue_len_max) { | |
| 275 | + kfree_skb(skb); | |
| 276 | + return -ENOBUFS; | |
| 277 | + } | |
| 212 | 278 | |
| 213 | 279 | cb = can_rx_offload_get_cb(skb); |
| 214 | 280 | cb->timestamp = timestamp; |
| @@ -250,8 +316,10 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload, · 35 unmodified lines | ||
| 250 | 316 | struct sk_buff *skb) |
| 251 | 317 | { |
| 252 | 318 | if (skb_queue_len(&offload->skb_queue) > |
| 253 | − offload->skb_queue_len_max) | |
| 254 | − return -ENOMEM; | |
| 319 | + offload->skb_queue_len_max) { | |
| 320 | + kfree_skb(skb); | |
| 321 | + return -ENOBUFS; | |
| 322 | + } | |
| 255 | 323 | |
| 256 | 324 | skb_queue_tail(&offload->skb_queue, skb); |
| 257 | 325 | can_rx_offload_schedule(offload); |
| @@ -717,6 +717,7 @@ static void mcp251x_restart_work_handler(struct work_struct *ws) · 716 unmodified lines | ||
| 717 | 717 | if (priv->after_suspend) { |
| 718 | 718 | mcp251x_hw_reset(spi); |
| 719 | 719 | mcp251x_setup(net, spi); |
| 720 | + priv->force_quit = 0; | |
| 720 | 721 | if (priv->after_suspend & AFTER_SUSPEND_RESTART) { |
| 721 | 722 | mcp251x_set_normal_mode(spi); |
| 722 | 723 | } else if (priv->after_suspend & AFTER_SUSPEND_UP) { |
| @@ -728,7 +729,6 @@ static void mcp251x_restart_work_handler(struct work_struct *ws) · 5 unmodified lines | ||
| 728 | 729 | mcp251x_hw_sleep(spi); |
| 729 | 730 | } |
| 730 | 731 | priv->after_suspend = 0; |
| 731 | − priv->force_quit = 0; | |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | if (priv->restart_tx) { |
| @@ -73,6 +73,7 @@ MODULE_VERSION(HECC_MODULE_VERSION); · 72 unmodified lines | ||
| 73 | 73 | */ |
| 74 | 74 | #define HECC_MAX_RX_MBOX (HECC_MAX_MAILBOXES - HECC_MAX_TX_MBOX) |
| 75 | 75 | #define HECC_RX_FIRST_MBOX (HECC_MAX_MAILBOXES - 1) |
| 76 | +#define HECC_RX_LAST_MBOX (HECC_MAX_TX_MBOX) | |
| 76 | 77 | |
| 77 | 78 | /* TI HECC module registers */ |
| 78 | 79 | #define HECC_CANME 0x0 /* Mailbox enable */ |
| @@ -82,7 +83,7 @@ MODULE_VERSION(HECC_MODULE_VERSION); · 3 unmodified lines | ||
| 82 | 83 | #define HECC_CANTA 0x10 /* Transmission acknowledge */ |
| 83 | 84 | #define HECC_CANAA 0x14 /* Abort acknowledge */ |
| 84 | 85 | #define HECC_CANRMP 0x18 /* Receive message pending */ |
| 85 | −#define HECC_CANRML 0x1C /* Remote message lost */ | |
| 86 | +#define HECC_CANRML 0x1C /* Receive message lost */ | |
| 86 | 87 | #define HECC_CANRFP 0x20 /* Remote frame pending */ |
| 87 | 88 | #define HECC_CANGAM 0x24 /* SECC only:Global acceptance mask */ |
| 88 | 89 | #define HECC_CANMC 0x28 /* Master control */ |
| @@ -149,6 +150,8 @@ MODULE_VERSION(HECC_MODULE_VERSION); · 60 unmodified lines | ||
| 149 | 150 | #define HECC_BUS_ERROR (HECC_CANES_FE | HECC_CANES_BE |\ |
| 150 | 151 | HECC_CANES_CRCE | HECC_CANES_SE |\ |
| 151 | 152 | HECC_CANES_ACKE) |
| 153 | +#define HECC_CANES_FLAGS (HECC_BUS_ERROR | HECC_CANES_BO |\ | |
| 154 | + HECC_CANES_EP | HECC_CANES_EW) | |
| 152 | 155 | |
| 153 | 156 | #define HECC_CANMCF_RTR BIT(4) /* Remote transmit request */ |
| 154 | 157 | |
| @@ -382,8 +385,18 @@ static void ti_hecc_start(struct net_device *ndev) · 227 unmodified lines | ||
| 382 | 385 | hecc_set_bit(priv, HECC_CANMIM, mbx_mask); |
| 383 | 386 | } |
| 384 | 387 | |
| 385 | − /* Prevent message over-write & Enable interrupts */ | |
| 386 | − hecc_write(priv, HECC_CANOPC, HECC_SET_REG); | |
| 388 | + /* Enable tx interrupts */ | |
| 389 | + hecc_set_bit(priv, HECC_CANMIM, BIT(HECC_MAX_TX_MBOX) - 1); | |
| 390 | + | |
| 391 | + /* Prevent message over-write to create a rx fifo, but not for | |
| 392 | + * the lowest priority mailbox, since that allows detecting | |
| 393 | + * overflows instead of the hardware silently dropping the | |
| 394 | + * messages. | |
| 395 | + */ | |
| 396 | + mbx_mask = ~BIT(HECC_RX_LAST_MBOX); | |
| 397 | + hecc_write(priv, HECC_CANOPC, mbx_mask); | |
| 398 | + | |
| 399 | + /* Enable interrupts */ | |
| 387 | 400 | if (priv->use_hecc1int) { |
| 388 | 401 | hecc_write(priv, HECC_CANMIL, HECC_SET_REG); |
| 389 | 402 | hecc_write(priv, HECC_CANGIM, HECC_CANGIM_DEF_MASK | |
| @@ -400,6 +413,9 @@ static void ti_hecc_stop(struct net_device *ndev) · 10 unmodified lines | ||
| 400 | 413 | { |
| 401 | 414 | struct ti_hecc_priv *priv = netdev_priv(ndev); |
| 402 | 415 | |
| 416 | + /* Disable the CPK; stop sending, erroring and acking */ | |
| 417 | + hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_CCR); | |
| 418 | + | |
| 403 | 419 | /* Disable interrupts and disable mailboxes */ |
| 404 | 420 | hecc_write(priv, HECC_CANGIM, 0); |
| 405 | 421 | hecc_write(priv, HECC_CANMIM, 0); |
| @@ -508,8 +524,6 @@ static netdev_tx_t ti_hecc_xmit(struct sk_buff *skb, struct net_device *ndev) · 102 unmodified lines | ||
| 508 | 524 | hecc_set_bit(priv, HECC_CANME, mbx_mask); |
| 509 | 525 | spin_unlock_irqrestore(&priv->mbx_lock, flags); |
| 510 | 526 | |
| 511 | − hecc_clear_bit(priv, HECC_CANMD, mbx_mask); | |
| 512 | − hecc_set_bit(priv, HECC_CANMIM, mbx_mask); | |
| 513 | 527 | hecc_write(priv, HECC_CANTRS, mbx_mask); |
| 514 | 528 | |
| 515 | 529 | return NETDEV_TX_OK; |
| @@ -526,8 +540,10 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload, · 10 unmodified lines | ||
| 526 | 540 | u32 *timestamp, unsigned int mbxno) |
| 527 | 541 | { |
| 528 | 542 | struct ti_hecc_priv *priv = rx_offload_to_priv(offload); |
| 529 | − u32 data; | |
| 543 | + u32 data, mbx_mask; | |
| 544 | + int ret = 1; | |
| 530 | 545 | |
| 546 | + mbx_mask = BIT(mbxno); | |
| 531 | 547 | data = hecc_read_mbx(priv, mbxno, HECC_CANMID); |
| 532 | 548 | if (data & HECC_CANMID_IDE) |
| 533 | 549 | cf->can_id = (data & CAN_EFF_MASK) | CAN_EFF_FLAG; |
| @@ -548,7 +564,25 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload, · 14 unmodified lines | ||
| 548 | 564 | |
| 549 | 565 | *timestamp = hecc_read_stamp(priv, mbxno); |
| 550 | 566 | |
| 551 | − return 1; | |
| 567 | + /* Check for FIFO overrun. | |
| 568 | + * | |
| 569 | + * All but the last RX mailbox have activated overwrite | |
| 570 | + * protection. So skip check for overrun, if we're not | |
| 571 | + * handling the last RX mailbox. | |
| 572 | + * | |
| 573 | + * As the overwrite protection for the last RX mailbox is | |
| 574 | + * disabled, the CAN core might update while we're reading | |
| 575 | + * it. This means the skb might be inconsistent. | |
| 576 | + * | |
| 577 | + * Return an error to let rx-offload discard this CAN frame. | |
| 578 | + */ | |
| 579 | + if (unlikely(mbxno == HECC_RX_LAST_MBOX && | |
| 580 | + hecc_read(priv, HECC_CANRML) & mbx_mask)) | |
| 581 | + ret = -ENOBUFS; | |
| 582 | + | |
| 583 | + hecc_write(priv, HECC_CANRMP, mbx_mask); | |
| 584 | + | |
| 585 | + return ret; | |
| 552 | 586 | } |
| 553 | 587 | |
| 554 | 588 | static int ti_hecc_error(struct net_device *ndev, int int_status, |
| @@ -558,92 +592,73 @@ static int ti_hecc_error(struct net_device *ndev, int int_status, · 3 unmodified lines | ||
| 558 | 592 | struct can_frame *cf; |
| 559 | 593 | struct sk_buff *skb; |
| 560 | 594 | u32 timestamp; |
| 595 | + int err; | |
| 561 | 596 | |
| 562 | − /* propagate the error condition to the can stack */ | |
| 563 | − skb = alloc_can_err_skb(ndev, &cf); | |
| 564 | − if (!skb) { | |
| 565 | − if (printk_ratelimit()) | |
| 566 | − netdev_err(priv->ndev, | |
| 567 | − "%s: alloc_can_err_skb() failed\n", | |
| 568 | − __func__); | |
| 569 | − return -ENOMEM; | |
| 570 | − } | |
| 571 | − | |
| 572 | − if (int_status & HECC_CANGIF_WLIF) { /* warning level int */ | |
| 573 | − if ((int_status & HECC_CANGIF_BOIF) == 0) { | |
| 574 | − priv->can.state = CAN_STATE_ERROR_WARNING; | |
| 575 | − ++priv->can.can_stats.error_warning; | |
| 576 | − cf->can_id |= CAN_ERR_CRTL; | |
| 577 | − if (hecc_read(priv, HECC_CANTEC) > 96) | |
| 578 | − cf->data[1] |= CAN_ERR_CRTL_TX_WARNING; | |
| 579 | − if (hecc_read(priv, HECC_CANREC) > 96) | |
| 580 | − cf->data[1] |= CAN_ERR_CRTL_RX_WARNING; | |
| 581 | − } | |
| 582 | − hecc_set_bit(priv, HECC_CANES, HECC_CANES_EW); | |
| 583 | − netdev_dbg(priv->ndev, "Error Warning interrupt\n"); | |
| 584 | − hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR); | |
| 585 | − } | |
| 586 | − | |
| 587 | − if (int_status & HECC_CANGIF_EPIF) { /* error passive int */ | |
| 588 | − if ((int_status & HECC_CANGIF_BOIF) == 0) { | |
| 589 | − priv->can.state = CAN_STATE_ERROR_PASSIVE; | |
| 590 | − ++priv->can.can_stats.error_passive; | |
| 591 | − cf->can_id |= CAN_ERR_CRTL; | |
| 592 | − if (hecc_read(priv, HECC_CANTEC) > 127) | |
| 593 | − cf->data[1] |= CAN_ERR_CRTL_TX_PASSIVE; | |
| 594 | − if (hecc_read(priv, HECC_CANREC) > 127) | |
| 595 | − cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE; | |
| 597 | + if (err_status & HECC_BUS_ERROR) { | |
| 598 | + /* propagate the error condition to the can stack */ | |
| 599 | + skb = alloc_can_err_skb(ndev, &cf); | |
| 600 | + if (!skb) { | |
| 601 | + if (net_ratelimit()) | |
| 602 | + netdev_err(priv->ndev, | |
| 603 | + "%s: alloc_can_err_skb() failed\n", | |
| 604 | + __func__); | |
| 605 | + return -ENOMEM; | |
| 596 | 606 | } |
| 597 | − hecc_set_bit(priv, HECC_CANES, HECC_CANES_EP); | |
| 598 | − netdev_dbg(priv->ndev, "Error passive interrupt\n"); | |
| 599 | − hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR); | |
| 600 | − } | |
| 601 | − | |
| 602 | − /* Need to check busoff condition in error status register too to | |
| 603 | − * ensure warning interrupts don't hog the system | |
| 604 | − */ | |
| 605 | − if ((int_status & HECC_CANGIF_BOIF) || (err_status & HECC_CANES_BO)) { | |
| 606 | − priv->can.state = CAN_STATE_BUS_OFF; | |
| 607 | − cf->can_id |= CAN_ERR_BUSOFF; | |
| 608 | − hecc_set_bit(priv, HECC_CANES, HECC_CANES_BO); | |
| 609 | − hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR); | |
| 610 | − /* Disable all interrupts in bus-off to avoid int hog */ | |
| 611 | − hecc_write(priv, HECC_CANGIM, 0); | |
| 612 | − ++priv->can.can_stats.bus_off; | |
| 613 | − can_bus_off(ndev); | |
| 614 | − } | |
| 615 | 607 | |
| 616 | − if (err_status & HECC_BUS_ERROR) { | |
| 617 | 608 | ++priv->can.can_stats.bus_error; |
| 618 | 609 | cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT; |
| 619 | − if (err_status & HECC_CANES_FE) { | |
| 620 | − hecc_set_bit(priv, HECC_CANES, HECC_CANES_FE); | |
| 610 | + if (err_status & HECC_CANES_FE) | |
| 621 | 611 | cf->data[2] |= CAN_ERR_PROT_FORM; |
| 622 | − } | |
| 623 | − if (err_status & HECC_CANES_BE) { | |
| 624 | − hecc_set_bit(priv, HECC_CANES, HECC_CANES_BE); | |
| 612 | + if (err_status & HECC_CANES_BE) | |
| 625 | 613 | cf->data[2] |= CAN_ERR_PROT_BIT; |
| 626 | − } | |
| 627 | − if (err_status & HECC_CANES_SE) { | |
| 628 | − hecc_set_bit(priv, HECC_CANES, HECC_CANES_SE); | |
| 614 | + if (err_status & HECC_CANES_SE) | |
| 629 | 615 | cf->data[2] |= CAN_ERR_PROT_STUFF; |
| 630 | − } | |
| 631 | − if (err_status & HECC_CANES_CRCE) { | |
| 632 | − hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE); | |
| 616 | + if (err_status & HECC_CANES_CRCE) | |
| 633 | 617 | cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; |
| 634 | − } | |
| 635 | − if (err_status & HECC_CANES_ACKE) { | |
| 636 | − hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE); | |
| 618 | + if (err_status & HECC_CANES_ACKE) | |
| 637 | 619 | cf->data[3] = CAN_ERR_PROT_LOC_ACK; |
| 638 | − } | |
| 620 | + | |
| 621 | + timestamp = hecc_read(priv, HECC_CANLNT); | |
| 622 | + err = can_rx_offload_queue_sorted(&priv->offload, skb, | |
| 623 | + timestamp); | |
| 624 | + if (err) | |
| 625 | + ndev->stats.rx_fifo_errors++; | |
| 639 | 626 | } |
| 640 | 627 | |
| 641 | − timestamp = hecc_read(priv, HECC_CANLNT); | |
| 642 | − can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); | |
| 628 | + hecc_write(priv, HECC_CANES, HECC_CANES_FLAGS); | |
| 643 | 629 | |
| 644 | 630 | return 0; |
| 645 | 631 | } |
| 646 | 632 | |
| 633 | +static void ti_hecc_change_state(struct net_device *ndev, | |
| 634 | + enum can_state rx_state, | |
| 635 | + enum can_state tx_state) | |
| 636 | +{ | |
| 637 | + struct ti_hecc_priv *priv = netdev_priv(ndev); | |
| 638 | + struct can_frame *cf; | |
| 639 | + struct sk_buff *skb; | |
| 640 | + u32 timestamp; | |
| 641 | + int err; | |
| 642 | + | |
| 643 | + skb = alloc_can_err_skb(priv->ndev, &cf); | |
| 644 | + if (unlikely(!skb)) { | |
| 645 | + priv->can.state = max(tx_state, rx_state); | |
| 646 | + return; | |
| 647 | + } | |
| 648 | + | |
| 649 | + can_change_state(priv->ndev, cf, tx_state, rx_state); | |
| 650 | + | |
| 651 | + if (max(tx_state, rx_state) != CAN_STATE_BUS_OFF) { | |
| 652 | + cf->data[6] = hecc_read(priv, HECC_CANTEC); | |
| 653 | + cf->data[7] = hecc_read(priv, HECC_CANREC); | |
| 654 | + } | |
| 655 | + | |
| 656 | + timestamp = hecc_read(priv, HECC_CANLNT); | |
| 657 | + err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); | |
| 658 | + if (err) | |
| 659 | + ndev->stats.rx_fifo_errors++; | |
| 660 | +} | |
| 661 | + | |
| 647 | 662 | static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id) |
| 648 | 663 | { |
| 649 | 664 | struct net_device *ndev = (struct net_device *)dev_id; |
| @@ -651,6 +666,7 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id) · 1 unmodified line | ||
| 651 | 666 | struct net_device_stats *stats = &ndev->stats; |
| 652 | 667 | u32 mbxno, mbx_mask, int_status, err_status, stamp; |
| 653 | 668 | unsigned long flags, rx_pending; |
| 669 | + u32 handled = 0; | |
| 654 | 670 | |
| 655 | 671 | int_status = hecc_read(priv, |
| 656 | 672 | priv->use_hecc1int ? |
| @@ -660,17 +676,66 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id) · 3 unmodified lines | ||
| 660 | 676 | return IRQ_NONE; |
| 661 | 677 | |
| 662 | 678 | err_status = hecc_read(priv, HECC_CANES); |
| 663 | − if (err_status & (HECC_BUS_ERROR | HECC_CANES_BO | | |
| 664 | − HECC_CANES_EP | HECC_CANES_EW)) | |
| 679 | + if (unlikely(err_status & HECC_CANES_FLAGS)) | |
| 665 | 680 | ti_hecc_error(ndev, int_status, err_status); |
| 666 | 681 | |
| 682 | + if (unlikely(int_status & HECC_CANGIM_DEF_MASK)) { | |
| 683 | + enum can_state rx_state, tx_state; | |
| 684 | + u32 rec = hecc_read(priv, HECC_CANREC); | |
| 685 | + u32 tec = hecc_read(priv, HECC_CANTEC); | |
| 686 | + | |
| 687 | + if (int_status & HECC_CANGIF_WLIF) { | |
| 688 | + handled |= HECC_CANGIF_WLIF; | |
| 689 | + rx_state = rec >= tec ? CAN_STATE_ERROR_WARNING : 0; | |
| 690 | + tx_state = rec <= tec ? CAN_STATE_ERROR_WARNING : 0; | |
| 691 | + netdev_dbg(priv->ndev, "Error Warning interrupt\n"); | |
| 692 | + ti_hecc_change_state(ndev, rx_state, tx_state); | |
| 693 | + } | |
| 694 | + | |
| 695 | + if (int_status & HECC_CANGIF_EPIF) { | |
| 696 | + handled |= HECC_CANGIF_EPIF; | |
| 697 | + rx_state = rec >= tec ? CAN_STATE_ERROR_PASSIVE : 0; | |
| 698 | + tx_state = rec <= tec ? CAN_STATE_ERROR_PASSIVE : 0; | |
| 699 | + netdev_dbg(priv->ndev, "Error passive interrupt\n"); | |
| 700 | + ti_hecc_change_state(ndev, rx_state, tx_state); | |
| 701 | + } | |
| 702 | + | |
| 703 | + if (int_status & HECC_CANGIF_BOIF) { | |
| 704 | + handled |= HECC_CANGIF_BOIF; | |
| 705 | + rx_state = CAN_STATE_BUS_OFF; | |
| 706 | + tx_state = CAN_STATE_BUS_OFF; | |
| 707 | + netdev_dbg(priv->ndev, "Bus off interrupt\n"); | |
| 708 | + | |
| 709 | + /* Disable all interrupts */ | |
| 710 | + hecc_write(priv, HECC_CANGIM, 0); | |
| 711 | + can_bus_off(ndev); | |
| 712 | + ti_hecc_change_state(ndev, rx_state, tx_state); | |
| 713 | + } | |
| 714 | + } else if (unlikely(priv->can.state != CAN_STATE_ERROR_ACTIVE)) { | |
| 715 | + enum can_state new_state, tx_state, rx_state; | |
| 716 | + u32 rec = hecc_read(priv, HECC_CANREC); | |
| 717 | + u32 tec = hecc_read(priv, HECC_CANTEC); | |
| 718 | + | |
| 719 | + if (rec >= 128 || tec >= 128) | |
| 720 | + new_state = CAN_STATE_ERROR_PASSIVE; | |
| 721 | + else if (rec >= 96 || tec >= 96) | |
| 722 | + new_state = CAN_STATE_ERROR_WARNING; | |
| 723 | + else | |
| 724 | + new_state = CAN_STATE_ERROR_ACTIVE; | |
| 725 | + | |
| 726 | + if (new_state < priv->can.state) { | |
| 727 | + rx_state = rec >= tec ? new_state : 0; | |
| 728 | + tx_state = rec <= tec ? new_state : 0; | |
| 729 | + ti_hecc_change_state(ndev, rx_state, tx_state); | |
| 730 | + } | |
| 731 | + } | |
| 732 | + | |
| 667 | 733 | if (int_status & HECC_CANGIF_GMIF) { |
| 668 | 734 | while (priv->tx_tail - priv->tx_head > 0) { |
| 669 | 735 | mbxno = get_tx_tail_mb(priv); |
| 670 | 736 | mbx_mask = BIT(mbxno); |
| 671 | 737 | if (!(mbx_mask & hecc_read(priv, HECC_CANTA))) |
| 672 | 738 | break; |
| 673 | − hecc_clear_bit(priv, HECC_CANMIM, mbx_mask); | |
| 674 | 739 | hecc_write(priv, HECC_CANTA, mbx_mask); |
| 675 | 740 | spin_lock_irqsave(&priv->mbx_lock, flags); |
| 676 | 741 | hecc_clear_bit(priv, HECC_CANME, mbx_mask); |
| @@ -695,16 +760,15 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id) · 18 unmodified lines | ||
| 695 | 760 | while ((rx_pending = hecc_read(priv, HECC_CANRMP))) { |
| 696 | 761 | can_rx_offload_irq_offload_timestamp(&priv->offload, |
| 697 | 762 | rx_pending); |
| 698 | − hecc_write(priv, HECC_CANRMP, rx_pending); | |
| 699 | 763 | } |
| 700 | 764 | } |
| 701 | 765 | |
| 702 | 766 | /* clear all interrupt conditions - read back to avoid spurious ints */ |
| 703 | 767 | if (priv->use_hecc1int) { |
| 704 | − hecc_write(priv, HECC_CANGIF1, HECC_SET_REG); | |
| 768 | + hecc_write(priv, HECC_CANGIF1, handled); | |
| 705 | 769 | int_status = hecc_read(priv, HECC_CANGIF1); |
| 706 | 770 | } else { |
| 707 | − hecc_write(priv, HECC_CANGIF0, HECC_SET_REG); | |
| 771 | + hecc_write(priv, HECC_CANGIF0, handled); | |
| 708 | 772 | int_status = hecc_read(priv, HECC_CANGIF0); |
| 709 | 773 | } |
| 710 | 774 | |
| @@ -877,7 +941,7 @@ static int ti_hecc_probe(struct platform_device *pdev) · 166 unmodified lines | ||
| 877 | 941 | |
| 878 | 942 | priv->offload.mailbox_read = ti_hecc_mailbox_read; |
| 879 | 943 | priv->offload.mb_first = HECC_RX_FIRST_MBOX; |
| 880 | − priv->offload.mb_last = HECC_MAX_TX_MBOX; | |
| 944 | + priv->offload.mb_last = HECC_RX_LAST_MBOX; | |
| 881 | 945 | err = can_rx_offload_add_timestamp(ndev, &priv->offload); |
| 882 | 946 | if (err) { |
| 883 | 947 | dev_err(&pdev->dev, "can_rx_offload_add_timestamp() failed\n"); |
| @@ -623,6 +623,7 @@ static int gs_can_open(struct net_device *netdev) · 622 unmodified lines | ||
| 623 | 623 | rc); |
| 624 | 624 | |
| 625 | 625 | usb_unanchor_urb(urb); |
| 626 | + usb_free_urb(urb); | |
| 626 | 627 | break; |
| 627 | 628 | } |
| 628 | 629 | |
| @@ -876,9 +876,8 @@ static void mcba_usb_disconnect(struct usb_interface *intf) · 875 unmodified lines | ||
| 876 | 876 | netdev_info(priv->netdev, "device disconnected\n"); |
| 877 | 877 | |
| 878 | 878 | unregister_candev(priv->netdev); |
| 879 | − free_candev(priv->netdev); | |
| 880 | − | |
| 881 | 879 | mcba_urb_unlink(priv); |
| 880 | + free_candev(priv->netdev); | |
| 882 | 881 | } |
| 883 | 882 | |
| 884 | 883 | static struct usb_driver mcba_usb_driver = { |
| @@ -100,7 +100,7 @@ struct pcan_usb_msg_context { · 99 unmodified lines | ||
| 100 | 100 | u8 *end; |
| 101 | 101 | u8 rec_cnt; |
| 102 | 102 | u8 rec_idx; |
| 103 | − u8 rec_data_idx; | |
| 103 | + u8 rec_ts_idx; | |
| 104 | 104 | struct net_device *netdev; |
| 105 | 105 | struct pcan_usb *pdev; |
| 106 | 106 | }; |
| @@ -436,8 +436,8 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n, · 329 unmodified lines | ||
| 436 | 436 | } |
| 437 | 437 | if ((n & PCAN_USB_ERROR_BUS_LIGHT) == 0) { |
| 438 | 438 | /* no error (back to active state) */ |
| 439 | − mc->pdev->dev.can.state = CAN_STATE_ERROR_ACTIVE; | |
| 440 | − return 0; | |
| 439 | + new_state = CAN_STATE_ERROR_ACTIVE; | |
| 440 | + break; | |
| 441 | 441 | } |
| 442 | 442 | break; |
| 443 | 443 | |
| @@ -460,9 +460,9 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n, · 16 unmodified lines | ||
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | if ((n & PCAN_USB_ERROR_BUS_HEAVY) == 0) { |
| 463 | − /* no error (back to active state) */ | |
| 464 | − mc->pdev->dev.can.state = CAN_STATE_ERROR_ACTIVE; | |
| 465 | − return 0; | |
| 463 | + /* no error (back to warning state) */ | |
| 464 | + new_state = CAN_STATE_ERROR_WARNING; | |
| 465 | + break; | |
| 466 | 466 | } |
| 467 | 467 | break; |
| 468 | 468 | |
| @@ -501,6 +501,11 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n, · 32 unmodified lines | ||
| 501 | 501 | mc->pdev->dev.can.can_stats.error_warning++; |
| 502 | 502 | break; |
| 503 | 503 | |
| 504 | + case CAN_STATE_ERROR_ACTIVE: | |
| 505 | + cf->can_id |= CAN_ERR_CRTL; | |
| 506 | + cf->data[1] = CAN_ERR_CRTL_ACTIVE; | |
| 507 | + break; | |
| 508 | + | |
| 504 | 509 | default: |
| 505 | 510 | /* CAN_STATE_MAX (trick to handle other errors) */ |
| 506 | 511 | cf->can_id |= CAN_ERR_CRTL; |
| @@ -547,10 +552,15 @@ static int pcan_usb_decode_status(struct pcan_usb_msg_context *mc, · 40 unmodified lines | ||
| 547 | 552 | mc->ptr += PCAN_USB_CMD_ARGS; |
| 548 | 553 | |
| 549 | 554 | if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) { |
| 550 | − int err = pcan_usb_decode_ts(mc, !mc->rec_idx); | |
| 555 | + int err = pcan_usb_decode_ts(mc, !mc->rec_ts_idx); | |
| 551 | 556 | |
| 552 | 557 | if (err) |
| 553 | 558 | return err; |
| 559 | + | |
| 560 | + /* Next packet in the buffer will have a timestamp on a single | |
| 561 | + * byte | |
| 562 | + */ | |
| 563 | + mc->rec_ts_idx++; | |
| 554 | 564 | } |
| 555 | 565 | |
| 556 | 566 | switch (f) { |
| @@ -632,10 +642,13 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len) · 75 unmodified lines | ||
| 632 | 642 | |
| 633 | 643 | cf->can_dlc = get_can_dlc(rec_len); |
| 634 | 644 | |
| 635 | − /* first data packet timestamp is a word */ | |
| 636 | − if (pcan_usb_decode_ts(mc, !mc->rec_data_idx)) | |
| 645 | + /* Only first packet timestamp is a word */ | |
| 646 | + if (pcan_usb_decode_ts(mc, !mc->rec_ts_idx)) | |
| 637 | 647 | goto decode_failed; |
| 638 | 648 | |
| 649 | + /* Next packet in the buffer will have a timestamp on a single byte */ | |
| 650 | + mc->rec_ts_idx++; | |
| 651 | + | |
| 639 | 652 | /* read data */ |
| 640 | 653 | memset(cf->data, 0x0, sizeof(cf->data)); |
| 641 | 654 | if (status_len & PCAN_USB_STATUSLEN_RTR) { |
| @@ -688,7 +701,6 @@ static int pcan_usb_decode_msg(struct peak_usb_device *dev, u8 *ibuf, u32 lbuf) · 46 unmodified lines | ||
| 688 | 701 | /* handle normal can frames here */ |
| 689 | 702 | } else { |
| 690 | 703 | err = pcan_usb_decode_data(&mc, sl); |
| 691 | − mc.rec_data_idx++; | |
| 692 | 704 | } |
| 693 | 705 | } |
| 694 | 706 | |
| @@ -750,7 +750,7 @@ static int peak_usb_create_dev(const struct peak_usb_adapter *peak_usb_adapter, · 749 unmodified lines | ||
| 750 | 750 | dev = netdev_priv(netdev); |
| 751 | 751 | |
| 752 | 752 | /* allocate a buffer large enough to send commands */ |
| 753 | − dev->cmd_buf = kmalloc(PCAN_USB_MAX_CMD_LEN, GFP_KERNEL); | |
| 753 | + dev->cmd_buf = kzalloc(PCAN_USB_MAX_CMD_LEN, GFP_KERNEL); | |
| 754 | 754 | if (!dev->cmd_buf) { |
| 755 | 755 | err = -ENOMEM; |
| 756 | 756 | goto lbl_free_candev; |
| @@ -996,9 +996,8 @@ static void usb_8dev_disconnect(struct usb_interface *intf) · 995 unmodified lines | ||
| 996 | 996 | netdev_info(priv->netdev, "device disconnected\n"); |
| 997 | 997 | |
| 998 | 998 | unregister_netdev(priv->netdev); |
| 999 | − free_candev(priv->netdev); | |
| 1000 | − | |
| 1001 | 999 | unlink_all_urbs(priv); |
| 1000 | + free_candev(priv->netdev); | |
| 1002 | 1001 | } |
| 1003 | 1002 | |
| 1004 | 1003 | } |
| @@ -1599,7 +1599,6 @@ static const struct xcan_devtype_data xcan_zynq_data = { · 1598 unmodified lines | ||
| 1599 | 1599 | |
| 1600 | 1600 | static const struct xcan_devtype_data xcan_axi_data = { |
| 1601 | 1601 | .cantype = XAXI_CAN, |
| 1602 | − .flags = XCAN_FLAG_TXFEMP, | |
| 1603 | 1602 | .bittiming_const = &xcan_bittiming_const, |
| 1604 | 1603 | .btr_ts2_shift = XCAN_BTR_TS2_SHIFT, |
| 1605 | 1604 | .btr_sjw_shift = XCAN_BTR_SJW_SHIFT, |
| @@ -37,22 +37,11 @@ static void bcm_sf2_imp_setup(struct dsa_switch *ds, int port) · 36 unmodified lines | ||
| 37 | 37 | unsigned int i; |
| 38 | 38 | u32 reg, offset; |
| 39 | 39 | |
| 40 | − if (priv->type == BCM7445_DEVICE_ID) | |
| 41 | − offset = CORE_STS_OVERRIDE_IMP; | |
| 42 | − else | |
| 43 | − offset = CORE_STS_OVERRIDE_IMP2; | |
| 44 | − | |
| 45 | 40 | /* Enable the port memories */ |
| 46 | 41 | reg = core_readl(priv, CORE_MEM_PSM_VDD_CTRL); |
| 47 | 42 | reg &= ~P_TXQ_PSM_VDD(port); |
| 48 | 43 | core_writel(priv, reg, CORE_MEM_PSM_VDD_CTRL); |
| 49 | 44 | |
| 50 | − /* Enable Broadcast, Multicast, Unicast forwarding to IMP port */ | |
| 51 | − reg = core_readl(priv, CORE_IMP_CTL); | |
| 52 | − reg |= (RX_BCST_EN | RX_MCST_EN | RX_UCST_EN); | |
| 53 | − reg &= ~(RX_DIS | TX_DIS); | |
| 54 | − core_writel(priv, reg, CORE_IMP_CTL); | |
| 55 | − | |
| 56 | 45 | /* Enable forwarding */ |
| 57 | 46 | core_writel(priv, SW_FWDG_EN, CORE_SWMODE); |
| 58 | 47 | |
| @@ -71,10 +60,27 @@ static void bcm_sf2_imp_setup(struct dsa_switch *ds, int port) · 12 unmodified lines | ||
| 71 | 60 | |
| 72 | 61 | b53_brcm_hdr_setup(ds, port); |
| 73 | 62 | |
| 74 | − /* Force link status for IMP port */ | |
| 75 | − reg = core_readl(priv, offset); | |
| 76 | − reg |= (MII_SW_OR | LINK_STS); | |
| 77 | − core_writel(priv, reg, offset); | |
| 63 | + if (port == 8) { | |
| 64 | + if (priv->type == BCM7445_DEVICE_ID) | |
| 65 | + offset = CORE_STS_OVERRIDE_IMP; | |
| 66 | + else | |
| 67 | + offset = CORE_STS_OVERRIDE_IMP2; | |
| 68 | + | |
| 69 | + /* Force link status for IMP port */ | |
| 70 | + reg = core_readl(priv, offset); | |
| 71 | + reg |= (MII_SW_OR | LINK_STS); | |
| 72 | + core_writel(priv, reg, offset); | |
| 73 | + | |
| 74 | + /* Enable Broadcast, Multicast, Unicast forwarding to IMP port */ | |
| 75 | + reg = core_readl(priv, CORE_IMP_CTL); | |
| 76 | + reg |= (RX_BCST_EN | RX_MCST_EN | RX_UCST_EN); | |
| 77 | + reg &= ~(RX_DIS | TX_DIS); | |
| 78 | + core_writel(priv, reg, CORE_IMP_CTL); | |
| 79 | + } else { | |
| 80 | + reg = core_readl(priv, CORE_G_PCTL_PORT(port)); | |
| 81 | + reg &= ~(RX_DIS | TX_DIS); | |
| 82 | + core_writel(priv, reg, CORE_G_PCTL_PORT(port)); | |
| 83 | + } | |
| 78 | 84 | } |
| 79 | 85 | |
| 80 | 86 | static void bcm_sf2_gphy_enable_set(struct dsa_switch *ds, bool enable) |
| @@ -1209,10 +1215,10 @@ static int bcm_sf2_sw_remove(struct platform_device *pdev) · 1128 unmodified lines | ||
| 1209 | 1215 | struct bcm_sf2_priv *priv = platform_get_drvdata(pdev); |
| 1210 | 1216 | |
| 1211 | 1217 | priv->wol_ports_mask = 0; |
| 1218 | + /* Disable interrupts */ | |
| 1219 | + bcm_sf2_intr_disable(priv); | |
| 1212 | 1220 | dsa_unregister_switch(priv->dev->ds); |
| 1213 | 1221 | bcm_sf2_cfp_exit(priv->dev->ds); |
| 1214 | − /* Disable all ports and interrupts */ | |
| 1215 | − bcm_sf2_sw_suspend(priv->dev->ds); | |
| 1216 | 1222 | bcm_sf2_mdio_unregister(priv); |
| 1217 | 1223 | |
| 1218 | 1224 | return 0; |
| @@ -26,8 +26,8 @@ config NET_DSA_SJA1105_PTP · 25 unmodified lines | ||
| 26 | 26 | |
| 27 | 27 | config NET_DSA_SJA1105_TAS |
| 28 | 28 | bool "Support for the Time-Aware Scheduler on NXP SJA1105" |
| 29 | − depends on NET_DSA_SJA1105 | |
| 30 | − depends on NET_SCH_TAPRIO | |
| 29 | + depends on NET_DSA_SJA1105 && NET_SCH_TAPRIO | |
| 30 | + depends on NET_SCH_TAPRIO=y || NET_DSA_SJA1105=m | |
| 31 | 31 | help |
| 32 | 32 | This enables support for the TTEthernet-based egress scheduling |
| 33 | 33 | engine in the SJA1105 DSA driver, which is controlled using a |
| @@ -256,6 +256,9 @@ static int emac_rockchip_remove(struct platform_device *pdev) · 255 unmodified lines | ||
| 256 | 256 | if (priv->regulator) |
| 257 | 257 | regulator_disable(priv->regulator); |
| 258 | 258 | |
| 259 | + if (priv->soc_data->need_div_macclk) | |
| 260 | + clk_disable_unprepare(priv->macclk); | |
| 261 | + | |
| 259 | 262 | free_netdev(ndev); |
| 260 | 263 | return err; |
| 261 | 264 | } |
| @@ -10382,7 +10382,8 @@ static void bnxt_cleanup_pci(struct bnxt *bp) · 10381 unmodified lines | ||
| 10382 | 10382 | { |
| 10383 | 10383 | bnxt_unmap_bars(bp, bp->pdev); |
| 10384 | 10384 | pci_release_regions(bp->pdev); |
| 10385 | − pci_disable_device(bp->pdev); | |
| 10385 | + if (pci_is_enabled(bp->pdev)) | |
| 10386 | + pci_disable_device(bp->pdev); | |
| 10386 | 10387 | } |
| 10387 | 10388 | |
| 10388 | 10389 | static void bnxt_init_dflt_coal(struct bnxt *bp) |
| @@ -10669,14 +10670,11 @@ static void bnxt_fw_reset_task(struct work_struct *work) · 280 unmodified lines | ||
| 10669 | 10670 | bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; |
| 10670 | 10671 | } |
| 10671 | 10672 | /* fall through */ |
| 10672 | − case BNXT_FW_RESET_STATE_RESET_FW: { | |
| 10673 | − u32 wait_dsecs = bp->fw_health->post_reset_wait_dsecs; | |
| 10674 | − | |
| 10673 | + case BNXT_FW_RESET_STATE_RESET_FW: | |
| 10675 | 10674 | bnxt_reset_all(bp); |
| 10676 | 10675 | bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; |
| 10677 | − bnxt_queue_fw_reset_work(bp, wait_dsecs * HZ / 10); | |
| 10676 | + bnxt_queue_fw_reset_work(bp, bp->fw_reset_min_dsecs * HZ / 10); | |
| 10678 | 10677 | return; |
| 10679 | − } | |
| 10680 | 10678 | case BNXT_FW_RESET_STATE_ENABLE_DEV: |
| 10681 | 10679 | if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) && |
| 10682 | 10680 | bp->fw_health) { |
| @@ -29,25 +29,20 @@ static int bnxt_fw_reporter_diagnose(struct devlink_health_reporter *reporter, · 28 unmodified lines | ||
| 29 | 29 | val = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG); |
| 30 | 30 | health_status = val & 0xffff; |
| 31 | 31 | |
| 32 | − if (health_status == BNXT_FW_STATUS_HEALTHY) { | |
| 33 | − rc = devlink_fmsg_string_pair_put(fmsg, "FW status", | |
| 34 | − "Healthy;"); | |
| 35 | − if (rc) | |
| 36 | − return rc; | |
| 37 | − } else if (health_status < BNXT_FW_STATUS_HEALTHY) { | |
| 38 | − rc = devlink_fmsg_string_pair_put(fmsg, "FW status", | |
| 39 | − "Not yet completed initialization;"); | |
| 32 | + if (health_status < BNXT_FW_STATUS_HEALTHY) { | |
| 33 | + rc = devlink_fmsg_string_pair_put(fmsg, "Description", | |
| 34 | + "Not yet completed initialization"); | |
| 40 | 35 | if (rc) |
| 41 | 36 | return rc; |
| 42 | 37 | } else if (health_status > BNXT_FW_STATUS_HEALTHY) { |
| 43 | − rc = devlink_fmsg_string_pair_put(fmsg, "FW status", | |
| 44 | − "Encountered fatal error and cannot recover;"); | |
| 38 | + rc = devlink_fmsg_string_pair_put(fmsg, "Description", | |
| 39 | + "Encountered fatal error and cannot recover"); | |
| 45 | 40 | if (rc) |
| 46 | 41 | return rc; |
| 47 | 42 | } |
| 48 | 43 | |
| 49 | 44 | if (val >> 16) { |
| 50 | − rc = devlink_fmsg_u32_pair_put(fmsg, "Error", val >> 16); | |
| 45 | + rc = devlink_fmsg_u32_pair_put(fmsg, "Error code", val >> 16); | |
| 51 | 46 | if (rc) |
| 52 | 47 | return rc; |
| 53 | 48 | } |
| @@ -215,25 +210,68 @@ enum bnxt_dl_param_id { · 161 unmodified lines | ||
| 215 | 210 | |
| 216 | 211 | static const struct bnxt_dl_nvm_param nvm_params[] = { |
| 217 | 212 | {DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, NVM_OFF_ENABLE_SRIOV, |
| 218 | − BNXT_NVM_SHARED_CFG, 1}, | |
| 213 | + BNXT_NVM_SHARED_CFG, 1, 1}, | |
| 219 | 214 | {DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, NVM_OFF_IGNORE_ARI, |
| 220 | − BNXT_NVM_SHARED_CFG, 1}, | |
| 215 | + BNXT_NVM_SHARED_CFG, 1, 1}, | |
| 221 | 216 | {DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, |
| 222 | − NVM_OFF_MSIX_VEC_PER_PF_MAX, BNXT_NVM_SHARED_CFG, 10}, | |
| 217 | + NVM_OFF_MSIX_VEC_PER_PF_MAX, BNXT_NVM_SHARED_CFG, 10, 4}, | |
| 223 | 218 | {DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, |
| 224 | − NVM_OFF_MSIX_VEC_PER_PF_MIN, BNXT_NVM_SHARED_CFG, 7}, | |
| 219 | + NVM_OFF_MSIX_VEC_PER_PF_MIN, BNXT_NVM_SHARED_CFG, 7, 4}, | |
| 225 | 220 | {BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK, NVM_OFF_DIS_GRE_VER_CHECK, |
| 226 | − BNXT_NVM_SHARED_CFG, 1}, | |
| 221 | + BNXT_NVM_SHARED_CFG, 1, 1}, | |
| 227 | 222 | }; |
| 228 | 223 | |
| 224 | +union bnxt_nvm_data { | |
| 225 | + u8 val8; | |
| 226 | + __le32 val32; | |
| 227 | +}; | |
| 228 | + | |
| 229 | +static void bnxt_copy_to_nvm_data(union bnxt_nvm_data *dst, | |
| 230 | + union devlink_param_value *src, | |
| 231 | + int nvm_num_bits, int dl_num_bytes) | |
| 232 | +{ | |
| 233 | + u32 val32 = 0; | |
| 234 | + | |
| 235 | + if (nvm_num_bits == 1) { | |
| 236 | + dst->val8 = src->vbool; | |
| 237 | + return; | |
| 238 | + } | |
| 239 | + if (dl_num_bytes == 4) | |
| 240 | + val32 = src->vu32; | |
| 241 | + else if (dl_num_bytes == 2) | |
| 242 | + val32 = (u32)src->vu16; | |
| 243 | + else if (dl_num_bytes == 1) | |
| 244 | + val32 = (u32)src->vu8; | |
| 245 | + dst->val32 = cpu_to_le32(val32); | |
| 246 | +} | |
| 247 | + | |
| 248 | +static void bnxt_copy_from_nvm_data(union devlink_param_value *dst, | |
| 249 | + union bnxt_nvm_data *src, | |
| 250 | + int nvm_num_bits, int dl_num_bytes) | |
| 251 | +{ | |
| 252 | + u32 val32; | |
| 253 | + | |
| 254 | + if (nvm_num_bits == 1) { | |
| 255 | + dst->vbool = src->val8; | |
| 256 | + return; | |
| 257 | + } | |
| 258 | + val32 = le32_to_cpu(src->val32); | |
| 259 | + if (dl_num_bytes == 4) | |
| 260 | + dst->vu32 = val32; | |
| 261 | + else if (dl_num_bytes == 2) | |
| 262 | + dst->vu16 = (u16)val32; | |
| 263 | + else if (dl_num_bytes == 1) | |
| 264 | + dst->vu8 = (u8)val32; | |
| 265 | +} | |
| 266 | + | |
| 229 | 267 | static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg, |
| 230 | 268 | int msg_len, union devlink_param_value *val) |
| 231 | 269 | { |
| 232 | 270 | struct hwrm_nvm_get_variable_input *req = msg; |
| 233 | − void *data_addr = NULL, *buf = NULL; | |
| 234 | 271 | struct bnxt_dl_nvm_param nvm_param; |
| 235 | − int bytesize, idx = 0, rc, i; | |
| 272 | + union bnxt_nvm_data *data; | |
| 236 | 273 | dma_addr_t data_dma_addr; |
| 274 | + int idx = 0, rc, i; | |
| 237 | 275 | |
| 238 | 276 | /* Get/Set NVM CFG parameter is supported only on PFs */ |
| 239 | 277 | if (BNXT_VF(bp)) |
| @@ -254,47 +292,31 @@ static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg, · 14 unmodified lines | ||
| 254 | 292 | else if (nvm_param.dir_type == BNXT_NVM_FUNC_CFG) |
| 255 | 293 | idx = bp->pf.fw_fid - BNXT_FIRST_PF_FID; |
| 256 | 294 | |
| 257 | − bytesize = roundup(nvm_param.num_bits, BITS_PER_BYTE) / BITS_PER_BYTE; | |
| 258 | − switch (bytesize) { | |
| 259 | − case 1: | |
| 260 | − if (nvm_param.num_bits == 1) | |
| 261 | − buf = &val->vbool; | |
| 262 | − else | |
| 263 | − buf = &val->vu8; | |
| 264 | − break; | |
| 265 | − case 2: | |
| 266 | − buf = &val->vu16; | |
| 267 | − break; | |
| 268 | − case 4: | |
| 269 | − buf = &val->vu32; | |
| 270 | − break; | |
| 271 | − default: | |
| 272 | − return -EFAULT; | |
| 273 | − } | |
| 274 | − | |
| 275 | − data_addr = dma_alloc_coherent(&bp->pdev->dev, bytesize, | |
| 276 | − &data_dma_addr, GFP_KERNEL); | |
| 277 | − if (!data_addr) | |
| 295 | + data = dma_alloc_coherent(&bp->pdev->dev, sizeof(*data), | |
| 296 | + &data_dma_addr, GFP_KERNEL); | |
| 297 | + if (!data) | |
| 278 | 298 | return -ENOMEM; |
| 279 | 299 | |
| 280 | 300 | req->dest_data_addr = cpu_to_le64(data_dma_addr); |
| 281 | − req->data_len = cpu_to_le16(nvm_param.num_bits); | |
| 301 | + req->data_len = cpu_to_le16(nvm_param.nvm_num_bits); | |
| 282 | 302 | req->option_num = cpu_to_le16(nvm_param.offset); |
| 283 | 303 | req->index_0 = cpu_to_le16(idx); |
| 284 | 304 | if (idx) |
| 285 | 305 | req->dimensions = cpu_to_le16(1); |
| 286 | 306 | |
| 287 | 307 | if (req->req_type == cpu_to_le16(HWRM_NVM_SET_VARIABLE)) { |
| 288 | − memcpy(data_addr, buf, bytesize); | |
| 308 | + bnxt_copy_to_nvm_data(data, val, nvm_param.nvm_num_bits, | |
| 309 | + nvm_param.dl_num_bytes); | |
| 289 | 310 | rc = hwrm_send_message(bp, msg, msg_len, HWRM_CMD_TIMEOUT); |
| 290 | 311 | } else { |
| 291 | 312 | rc = hwrm_send_message_silent(bp, msg, msg_len, |
| 292 | 313 | HWRM_CMD_TIMEOUT); |
| 314 | + if (!rc) | |
| 315 | + bnxt_copy_from_nvm_data(val, data, | |
| 316 | + nvm_param.nvm_num_bits, | |
| 317 | + nvm_param.dl_num_bytes); | |
| 293 | 318 | } |
| 294 | − if (!rc && req->req_type == cpu_to_le16(HWRM_NVM_GET_VARIABLE)) | |
| 295 | − memcpy(buf, data_addr, bytesize); | |
| 296 | − | |
| 297 | − dma_free_coherent(&bp->pdev->dev, bytesize, data_addr, data_dma_addr); | |
| 319 | + dma_free_coherent(&bp->pdev->dev, sizeof(*data), data, data_dma_addr); | |
| 298 | 320 | if (rc == -EACCES) |
| 299 | 321 | netdev_err(bp->dev, "PF does not have admin privileges to modify NVM config\n"); |
| 300 | 322 | return rc; |
| @@ -52,7 +52,8 @@ struct bnxt_dl_nvm_param { · 51 unmodified lines | ||
| 52 | 52 | u16 id; |
| 53 | 53 | u16 offset; |
| 54 | 54 | u16 dir_type; |
| 55 | − u16 num_bits; | |
| 55 | + u16 nvm_num_bits; | |
| 56 | + u8 dl_num_bytes; | |
| 56 | 57 | }; |
| 57 | 58 | |
| 58 | 59 | void bnxt_devlink_health_report(struct bnxt *bp, unsigned long event); |
| @@ -1996,8 +1996,6 @@ static void reset_umac(struct bcmgenet_priv *priv) · 1995 unmodified lines | ||
| 1996 | 1996 | |
| 1997 | 1997 | /* issue soft reset with (rg)mii loopback to ensure a stable rxclk */ |
| 1998 | 1998 | bcmgenet_umac_writel(priv, CMD_SW_RESET | CMD_LCL_LOOP_EN, UMAC_CMD); |
| 1999 | − udelay(2); | |
| 2000 | − bcmgenet_umac_writel(priv, 0, UMAC_CMD); | |
| 2001 | 1999 | } |
| 2002 | 2000 | |
| 2003 | 2001 | static void bcmgenet_intr_disable(struct bcmgenet_priv *priv) |
| @@ -2614,8 +2612,10 @@ static void bcmgenet_irq_task(struct work_struct *work) · 610 unmodified lines | ||
| 2614 | 2612 | spin_unlock_irq(&priv->lock); |
| 2615 | 2613 | |
| 2616 | 2614 | if (status & UMAC_IRQ_PHY_DET_R && |
| 2617 | − priv->dev->phydev->autoneg != AUTONEG_ENABLE) | |
| 2615 | + priv->dev->phydev->autoneg != AUTONEG_ENABLE) { | |
| 2618 | 2616 | phy_init_hw(priv->dev->phydev); |
| 2617 | + genphy_config_aneg(priv->dev->phydev); | |
| 2618 | + } | |
| 2619 | 2619 | |
| 2620 | 2620 | /* Link UP/DOWN event */ |
| 2621 | 2621 | if (status & UMAC_IRQ_LINK_EVENT) |
| @@ -2879,12 +2879,6 @@ static int bcmgenet_open(struct net_device *dev) · 257 unmodified lines | ||
| 2879 | 2879 | if (priv->internal_phy) |
| 2880 | 2880 | bcmgenet_power_up(priv, GENET_POWER_PASSIVE); |
| 2881 | 2881 | |
| 2882 | − ret = bcmgenet_mii_connect(dev); | |
| 2883 | − if (ret) { | |
| 2884 | − netdev_err(dev, "failed to connect to PHY\n"); | |
| 2885 | − goto err_clk_disable; | |
| 2886 | − } | |
| 2887 | − | |
| 2888 | 2882 | /* take MAC out of reset */ |
| 2889 | 2883 | bcmgenet_umac_reset(priv); |
| 2890 | 2884 | |
| @@ -2894,12 +2888,6 @@ static int bcmgenet_open(struct net_device *dev) · 3 unmodified lines | ||
| 2894 | 2888 | reg = bcmgenet_umac_readl(priv, UMAC_CMD); |
| 2895 | 2889 | priv->crc_fwd_en = !!(reg & CMD_CRC_FWD); |
| 2896 | 2890 | |
| 2897 | − ret = bcmgenet_mii_config(dev, true); | |
| 2898 | − if (ret) { | |
| 2899 | − netdev_err(dev, "unsupported PHY\n"); | |
| 2900 | − goto err_disconnect_phy; | |
| 2901 | − } | |
| 2902 | − | |
| 2903 | 2891 | bcmgenet_set_hw_addr(priv, dev->dev_addr); |
| 2904 | 2892 | |
| 2905 | 2893 | if (priv->internal_phy) { |
| @@ -2915,7 +2903,7 @@ static int bcmgenet_open(struct net_device *dev) · 9 unmodified lines | ||
| 2915 | 2903 | ret = bcmgenet_init_dma(priv); |
| 2916 | 2904 | if (ret) { |
| 2917 | 2905 | netdev_err(dev, "failed to initialize DMA\n"); |
| 2918 | − goto err_disconnect_phy; | |
| 2906 | + goto err_clk_disable; | |
| 2919 | 2907 | } |
| 2920 | 2908 | |
| 2921 | 2909 | /* Always enable ring 16 - descriptor ring */ |
| @@ -2938,19 +2926,25 @@ static int bcmgenet_open(struct net_device *dev) · 16 unmodified lines | ||
| 2938 | 2926 | goto err_irq0; |
| 2939 | 2927 | } |
| 2940 | 2928 | |
| 2929 | + ret = bcmgenet_mii_probe(dev); | |
| 2930 | + if (ret) { | |
| 2931 | + netdev_err(dev, "failed to connect to PHY\n"); | |
| 2932 | + goto err_irq1; | |
| 2933 | + } | |
| 2934 | + | |
| 2941 | 2935 | bcmgenet_netif_start(dev); |
| 2942 | 2936 | |
| 2943 | 2937 | netif_tx_start_all_queues(dev); |
| 2944 | 2938 | |
| 2945 | 2939 | return 0; |
| 2946 | 2940 | |
| 2941 | +err_irq1: | |
| 2942 | + free_irq(priv->irq1, priv); | |
| 2947 | 2943 | err_irq0: |
| 2948 | 2944 | free_irq(priv->irq0, priv); |
| 2949 | 2945 | err_fini_dma: |
| 2950 | 2946 | bcmgenet_dma_teardown(priv); |
| 2951 | 2947 | bcmgenet_fini_dma(priv); |
| 2952 | −err_disconnect_phy: | |
| 2953 | − phy_disconnect(dev->phydev); | |
| 2954 | 2948 | err_clk_disable: |
| 2955 | 2949 | if (priv->internal_phy) |
| 2956 | 2950 | bcmgenet_power_down(priv, GENET_POWER_PASSIVE); |
| @@ -3631,8 +3625,6 @@ static int bcmgenet_resume(struct device *d) · 674 unmodified lines | ||
| 3631 | 3625 | if (priv->internal_phy) |
| 3632 | 3626 | bcmgenet_power_up(priv, GENET_POWER_PASSIVE); |
| 3633 | 3627 | |
| 3634 | − phy_init_hw(dev->phydev); | |
| 3635 | − | |
| 3636 | 3628 | bcmgenet_umac_reset(priv); |
| 3637 | 3629 | |
| 3638 | 3630 | init_umac(priv); |
| @@ -3641,7 +3633,10 @@ static int bcmgenet_resume(struct device *d) · 2 unmodified lines | ||
| 3641 | 3633 | if (priv->wolopts) |
| 3642 | 3634 | clk_disable_unprepare(priv->clk_wol); |
| 3643 | 3635 | |
| 3636 | + phy_init_hw(dev->phydev); | |
| 3637 | + | |
| 3644 | 3638 | /* Speed settings must be restored */ |
| 3639 | + genphy_config_aneg(dev->phydev); | |
| 3645 | 3640 | bcmgenet_mii_config(priv->dev, false); |
| 3646 | 3641 | |
| 3647 | 3642 | bcmgenet_set_hw_addr(priv, dev->dev_addr); |
| @@ -720,8 +720,8 @@ GENET_IO_MACRO(rbuf, GENET_RBUF_OFF); · 719 unmodified lines | ||
| 720 | 720 | |
| 721 | 721 | /* MDIO routines */ |
| 722 | 722 | int bcmgenet_mii_init(struct net_device *dev); |
| 723 | −int bcmgenet_mii_connect(struct net_device *dev); | |
| 724 | 723 | int bcmgenet_mii_config(struct net_device *dev, bool init); |
| 724 | +int bcmgenet_mii_probe(struct net_device *dev); | |
| 725 | 725 | void bcmgenet_mii_exit(struct net_device *dev); |
| 726 | 726 | void bcmgenet_phy_power_set(struct net_device *dev, bool enable); |
| 727 | 727 | void bcmgenet_mii_setup(struct net_device *dev); |
| @@ -173,46 +173,6 @@ static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv) · 172 unmodified lines | ||
| 173 | 173 | bcmgenet_fixed_phy_link_update); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | −int bcmgenet_mii_connect(struct net_device *dev) | |
| 177 | −{ | |
| 178 | − struct bcmgenet_priv *priv = netdev_priv(dev); | |
| 179 | − struct device_node *dn = priv->pdev->dev.of_node; | |
| 180 | − struct phy_device *phydev; | |
| 181 | − u32 phy_flags = 0; | |
| 182 | − int ret; | |
| 183 | − | |
| 184 | − /* Communicate the integrated PHY revision */ | |
| 185 | − if (priv->internal_phy) | |
| 186 | − phy_flags = priv->gphy_rev; | |
| 187 | − | |
| 188 | − /* Initialize link state variables that bcmgenet_mii_setup() uses */ | |
| 189 | − priv->old_link = -1; | |
| 190 | − priv->old_speed = -1; | |
| 191 | − priv->old_duplex = -1; | |
| 192 | − priv->old_pause = -1; | |
| 193 | − | |
| 194 | − if (dn) { | |
| 195 | − phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup, | |
| 196 | − phy_flags, priv->phy_interface); | |
| 197 | − if (!phydev) { | |
| 198 | − pr_err("could not attach to PHY\n"); | |
| 199 | − return -ENODEV; | |
| 200 | − } | |
| 201 | − } else { | |
| 202 | − phydev = dev->phydev; | |
| 203 | − phydev->dev_flags = phy_flags; | |
| 204 | − | |
| 205 | − ret = phy_connect_direct(dev, phydev, bcmgenet_mii_setup, | |
| 206 | − priv->phy_interface); | |
| 207 | − if (ret) { | |
| 208 | − pr_err("could not attach to PHY\n"); | |
| 209 | − return -ENODEV; | |
| 210 | − } | |
| 211 | − } | |
| 212 | − | |
| 213 | − return 0; | |
| 214 | −} | |
| 215 | − | |
| 216 | 176 | int bcmgenet_mii_config(struct net_device *dev, bool init) |
| 217 | 177 | { |
| 218 | 178 | struct bcmgenet_priv *priv = netdev_priv(dev); |
| @@ -221,8 +181,38 @@ int bcmgenet_mii_config(struct net_device *dev, bool init) · 2 unmodified lines | ||
| 221 | 181 | const char *phy_name = NULL; |
| 222 | 182 | u32 id_mode_dis = 0; |
| 223 | 183 | u32 port_ctrl; |
| 184 | + int bmcr = -1; | |
| 185 | + int ret; | |
| 224 | 186 | u32 reg; |
| 225 | 187 | |
| 188 | + /* MAC clocking workaround during reset of umac state machines */ | |
| 189 | + reg = bcmgenet_umac_readl(priv, UMAC_CMD); | |
| 190 | + if (reg & CMD_SW_RESET) { | |
| 191 | + /* An MII PHY must be isolated to prevent TXC contention */ | |
| 192 | + if (priv->phy_interface == PHY_INTERFACE_MODE_MII) { | |
| 193 | + ret = phy_read(phydev, MII_BMCR); | |
| 194 | + if (ret >= 0) { | |
| 195 | + bmcr = ret; | |
| 196 | + ret = phy_write(phydev, MII_BMCR, | |
| 197 | + bmcr | BMCR_ISOLATE); | |
| 198 | + } | |
| 199 | + if (ret) { | |
| 200 | + netdev_err(dev, "failed to isolate PHY\n"); | |
| 201 | + return ret; | |
| 202 | + } | |
| 203 | + } | |
| 204 | + /* Switch MAC clocking to RGMII generated clock */ | |
| 205 | + bcmgenet_sys_writel(priv, PORT_MODE_EXT_GPHY, SYS_PORT_CTRL); | |
| 206 | + /* Ensure 5 clks with Rx disabled | |
| 207 | + * followed by 5 clks with Reset asserted | |
| 208 | + */ | |
| 209 | + udelay(4); | |
| 210 | + reg &= ~(CMD_SW_RESET | CMD_LCL_LOOP_EN); | |
| 211 | + bcmgenet_umac_writel(priv, reg, UMAC_CMD); | |
| 212 | + /* Ensure 5 more clocks before Rx is enabled */ | |
| 213 | + udelay(2); | |
| 214 | + } | |
| 215 | + | |
| 226 | 216 | priv->ext_phy = !priv->internal_phy && |
| 227 | 217 | (priv->phy_interface != PHY_INTERFACE_MODE_MOCA); |
| 228 | 218 | |
| @@ -254,6 +244,9 @@ int bcmgenet_mii_config(struct net_device *dev, bool init) · 25 unmodified lines | ||
| 254 | 244 | phy_set_max_speed(phydev, SPEED_100); |
| 255 | 245 | bcmgenet_sys_writel(priv, |
| 256 | 246 | PORT_MODE_EXT_EPHY, SYS_PORT_CTRL); |
| 247 | + /* Restore the MII PHY after isolation */ | |
| 248 | + if (bmcr >= 0) | |
| 249 | + phy_write(phydev, MII_BMCR, bmcr); | |
| 257 | 250 | break; |
| 258 | 251 | |
| 259 | 252 | case PHY_INTERFACE_MODE_REVMII: |
| @@ -306,21 +299,71 @@ int bcmgenet_mii_config(struct net_device *dev, bool init) · 46 unmodified lines | ||
| 306 | 299 | bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL); |
| 307 | 300 | } |
| 308 | 301 | |
| 309 | − if (init) { | |
| 310 | − linkmode_copy(phydev->advertising, phydev->supported); | |
| 302 | + if (init) | |
| 303 | + dev_info(kdev, "configuring instance for %s\n", phy_name); | |
| 311 | 304 | |
| 312 | − /* The internal PHY has its link interrupts routed to the | |
| 313 | − * Ethernet MAC ISRs. On GENETv5 there is a hardware issue | |
| 314 | − * that prevents the signaling of link UP interrupts when | |
| 315 | − * the link operates at 10Mbps, so fallback to polling for | |
| 316 | − * those versions of GENET. | |
| 317 | − */ | |
| 318 | − if (priv->internal_phy && !GENET_IS_V5(priv)) | |
| 319 | − phydev->irq = PHY_IGNORE_INTERRUPT; | |
| 305 | + return 0; | |
| 306 | +} | |
| 320 | 307 | |
| 321 | − dev_info(kdev, "configuring instance for %s\n", phy_name); | |
| 308 | +int bcmgenet_mii_probe(struct net_device *dev) | |
| 309 | +{ | |
| 310 | + struct bcmgenet_priv *priv = netdev_priv(dev); | |
| 311 | + struct device_node *dn = priv->pdev->dev.of_node; | |
| 312 | + struct phy_device *phydev; | |
| 313 | + u32 phy_flags = 0; | |
| 314 | + int ret; | |
| 315 | + | |
| 316 | + /* Communicate the integrated PHY revision */ | |
| 317 | + if (priv->internal_phy) | |
| 318 | + phy_flags = priv->gphy_rev; | |
| 319 | + | |
| 320 | + /* Initialize link state variables that bcmgenet_mii_setup() uses */ | |
| 321 | + priv->old_link = -1; | |
| 322 | + priv->old_speed = -1; | |
| 323 | + priv->old_duplex = -1; | |
| 324 | + priv->old_pause = -1; | |
| 325 | + | |
| 326 | + if (dn) { | |
| 327 | + phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup, | |
| 328 | + phy_flags, priv->phy_interface); | |
| 329 | + if (!phydev) { | |
| 330 | + pr_err("could not attach to PHY\n"); | |
| 331 | + return -ENODEV; | |
| 332 | + } | |
| 333 | + } else { | |
| 334 | + phydev = dev->phydev; | |
| 335 | + phydev->dev_flags = phy_flags; | |
| 336 | + | |
| 337 | + ret = phy_connect_direct(dev, phydev, bcmgenet_mii_setup, | |
| 338 | + priv->phy_interface); | |
| 339 | + if (ret) { | |
| 340 | + pr_err("could not attach to PHY\n"); | |
| 341 | + return -ENODEV; | |
| 342 | + } | |
| 322 | 343 | } |
| 323 | 344 | |
| 345 | + /* Configure port multiplexer based on what the probed PHY device since | |
| 346 | + * reading the 'max-speed' property determines the maximum supported | |
| 347 | + * PHY speed which is needed for bcmgenet_mii_config() to configure | |
| 348 | + * things appropriately. | |
| 349 | + */ | |
| 350 | + ret = bcmgenet_mii_config(dev, true); | |
| 351 | + if (ret) { | |
| 352 | + phy_disconnect(dev->phydev); | |
| 353 | + return ret; | |
| 354 | + } | |
| 355 | + | |
| 356 | + linkmode_copy(phydev->advertising, phydev->supported); | |
| 357 | + | |
| 358 | + /* The internal PHY has its link interrupts routed to the | |
| 359 | + * Ethernet MAC ISRs. On GENETv5 there is a hardware issue | |
| 360 | + * that prevents the signaling of link UP interrupts when | |
| 361 | + * the link operates at 10Mbps, so fallback to polling for | |
| 362 | + * those versions of GENET. | |
| 363 | + */ | |
| 364 | + if (priv->internal_phy && !GENET_IS_V5(priv)) | |
| 365 | + dev->phydev->irq = PHY_IGNORE_INTERRUPT; | |
| 366 | + | |
| 324 | 367 | return 0; |
| 325 | 368 | } |
| 326 | 369 | |
| @@ -1499,7 +1499,7 @@ static int octeon_mgmt_probe(struct platform_device *pdev) · 1498 unmodified lines | ||
| 1499 | 1499 | netdev->ethtool_ops = &octeon_mgmt_ethtool_ops; |
| 1500 | 1500 | |
| 1501 | 1501 | netdev->min_mtu = 64 - OCTEON_MGMT_RX_HEADROOM; |
| 1502 | − netdev->max_mtu = 16383 - OCTEON_MGMT_RX_HEADROOM; | |
| 1502 | + netdev->max_mtu = 16383 - OCTEON_MGMT_RX_HEADROOM - VLAN_HLEN; | |
| 1503 | 1503 | |
| 1504 | 1504 | mac = of_get_mac_address(pdev->dev.of_node); |
| 1505 | 1505 | |
| @@ -695,10 +695,10 @@ static void uld_init(struct adapter *adap, struct cxgb4_lld_info *lld) · 694 unmodified lines | ||
| 695 | 695 | lld->write_cmpl_support = adap->params.write_cmpl_support; |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | −static void uld_attach(struct adapter *adap, unsigned int uld) | |
| 698 | +static int uld_attach(struct adapter *adap, unsigned int uld) | |
| 699 | 699 | { |
| 700 | − void *handle; | |
| 701 | 700 | struct cxgb4_lld_info lli; |
| 701 | + void *handle; | |
| 702 | 702 | |
| 703 | 703 | uld_init(adap, &lli); |
| 704 | 704 | uld_queue_init(adap, uld, &lli); |
| @@ -708,7 +708,7 @@ static void uld_attach(struct adapter *adap, unsigned int uld) · 3 unmodified lines | ||
| 708 | 708 | dev_warn(adap->pdev_dev, |
| 709 | 709 | "could not attach to the %s driver, error %ld\n", |
| 710 | 710 | adap->uld[uld].name, PTR_ERR(handle)); |
| 711 | − return; | |
| 711 | + return PTR_ERR(handle); | |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | adap->uld[uld].handle = handle; |
| @@ -716,22 +716,22 @@ static void uld_attach(struct adapter *adap, unsigned int uld) · 1 unmodified line | ||
| 716 | 716 | |
| 717 | 717 | if (adap->flags & CXGB4_FULL_INIT_DONE) |
| 718 | 718 | adap->uld[uld].state_change(handle, CXGB4_STATE_UP); |
| 719 | + | |
| 720 | + return 0; | |
| 719 | 721 | } |
| 720 | 722 | |
| 721 | −/** | |
| 722 | − * cxgb4_register_uld - register an upper-layer driver | |
| 723 | − * @type: the ULD type | |
| 724 | − * @p: the ULD methods | |
| 723 | +/* cxgb4_register_uld - register an upper-layer driver | |
| 724 | + * @type: the ULD type | |
| 725 | + * @p: the ULD methods | |
| 725 | 726 | * |
| 726 | − * Registers an upper-layer driver with this driver and notifies the ULD | |
| 727 | − * about any presently available devices that support its type. Returns | |
| 728 | − * %-EBUSY if a ULD of the same type is already registered. | |
| 727 | + * Registers an upper-layer driver with this driver and notifies the ULD | |
| 728 | + * about any presently available devices that support its type. | |
| 729 | 729 | */ |
| 730 | 730 | void cxgb4_register_uld(enum cxgb4_uld type, |
| 731 | 731 | const struct cxgb4_uld_info *p) |
| 732 | 732 | { |
| 733 | − int ret = 0; | |
| 734 | 733 | struct adapter *adap; |
| 734 | + int ret = 0; | |
| 735 | 735 | |
| 736 | 736 | if (type >= CXGB4_ULD_MAX) |
| 737 | 737 | return; |
| @@ -763,8 +763,12 @@ void cxgb4_register_uld(enum cxgb4_uld type, · 25 unmodified lines | ||
| 763 | 763 | if (ret) |
| 764 | 764 | goto free_irq; |
| 765 | 765 | adap->uld[type] = *p; |
| 766 | − uld_attach(adap, type); | |
| 766 | + ret = uld_attach(adap, type); | |
| 767 | + if (ret) | |
| 768 | + goto free_txq; | |
| 767 | 769 | continue; |
| 770 | +free_txq: | |
| 771 | + release_sge_txq_uld(adap, type); | |
| 768 | 772 | free_irq: |
| 769 | 773 | if (adap->flags & CXGB4_FULL_INIT_DONE) |
| 770 | 774 | quiesce_rx_uld(adap, type); |
| @@ -3791,15 +3791,11 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq, · 3790 unmodified lines | ||
| 3791 | 3791 | * write the CIDX Updates into the Status Page at the end of the |
| 3792 | 3792 | * TX Queue. |
| 3793 | 3793 | */ |
| 3794 | − c.autoequiqe_to_viid = htonl((dbqt | |
| 3795 | − ? FW_EQ_ETH_CMD_AUTOEQUIQE_F | |
| 3796 | − : FW_EQ_ETH_CMD_AUTOEQUEQE_F) | | |
| 3794 | + c.autoequiqe_to_viid = htonl(FW_EQ_ETH_CMD_AUTOEQUEQE_F | | |
| 3797 | 3795 | FW_EQ_ETH_CMD_VIID_V(pi->viid)); |
| 3798 | 3796 | |
| 3799 | 3797 | c.fetchszm_to_iqid = |
| 3800 | − htonl(FW_EQ_ETH_CMD_HOSTFCMODE_V(dbqt | |
| 3801 | − ? HOSTFCMODE_INGRESS_QUEUE_X | |
| 3802 | − : HOSTFCMODE_STATUS_PAGE_X) | | |
| 3798 | + htonl(FW_EQ_ETH_CMD_HOSTFCMODE_V(HOSTFCMODE_STATUS_PAGE_X) | | |
| 3803 | 3799 | FW_EQ_ETH_CMD_PCIECHN_V(pi->tx_chan) | |
| 3804 | 3800 | FW_EQ_ETH_CMD_FETCHRO_F | FW_EQ_ETH_CMD_IQID_V(iqid)); |
| 3805 | 3801 | |
| @@ -1,4 +1,4 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0 | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ | |
| 2 | 2 | /* Register definitions for Gemini GMAC Ethernet device driver |
| 3 | 3 | * |
| 4 | 4 | * Copyright (C) 2006 Storlink, Corp. |
| @@ -727,6 +727,18 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb, · 726 unmodified lines | ||
| 727 | 727 | */ |
| 728 | 728 | nfrags = skb_shinfo(skb)->nr_frags; |
| 729 | 729 | |
| 730 | + /* Setup HW checksumming */ | |
| 731 | + csum_vlan = 0; | |
| 732 | + if (skb->ip_summed == CHECKSUM_PARTIAL && | |
| 733 | + !ftgmac100_prep_tx_csum(skb, &csum_vlan)) | |
| 734 | + goto drop; | |
| 735 | + | |
| 736 | + /* Add VLAN tag */ | |
| 737 | + if (skb_vlan_tag_present(skb)) { | |
| 738 | + csum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG; | |
| 739 | + csum_vlan |= skb_vlan_tag_get(skb) & 0xffff; | |
| 740 | + } | |
| 741 | + | |
| 730 | 742 | /* Get header len */ |
| 731 | 743 | len = skb_headlen(skb); |
| 732 | 744 | |
| @@ -753,19 +765,6 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb, · 20 unmodified lines | ||
| 753 | 765 | if (nfrags == 0) |
| 754 | 766 | f_ctl_stat |= FTGMAC100_TXDES0_LTS; |
| 755 | 767 | txdes->txdes3 = cpu_to_le32(map); |
| 756 | − | |
| 757 | − /* Setup HW checksumming */ | |
| 758 | − csum_vlan = 0; | |
| 759 | − if (skb->ip_summed == CHECKSUM_PARTIAL && | |
| 760 | − !ftgmac100_prep_tx_csum(skb, &csum_vlan)) | |
| 761 | − goto drop; | |
| 762 | − | |
| 763 | − /* Add VLAN tag */ | |
| 764 | − if (skb_vlan_tag_present(skb)) { | |
| 765 | − csum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG; | |
| 766 | − csum_vlan |= skb_vlan_tag_get(skb) & 0xffff; | |
| 767 | − } | |
| 768 | − | |
| 769 | 768 | txdes->txdes1 = cpu_to_le32(csum_vlan); |
| 770 | 769 | |
| 771 | 770 | /* Next descriptor */ |
| @@ -1,4 +1,4 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0 | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ | |
| 2 | 2 | /* |
| 3 | 3 | * Copyright 2018 NXP |
| 4 | 4 | */ |
| @@ -1,4 +1,4 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0 | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ | |
| 2 | 2 | /* |
| 3 | 3 | * Copyright 2013-2016 Freescale Semiconductor Inc. |
| 4 | 4 | * Copyright 2016-2018 NXP |
| @@ -1,4 +1,4 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0 | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ | |
| 2 | 2 | /* |
| 3 | 3 | * Copyright 2013-2016 Freescale Semiconductor Inc. |
| 4 | 4 | * Copyright 2016-2018 NXP |
| @@ -3558,7 +3558,7 @@ fec_probe(struct platform_device *pdev) · 3557 unmodified lines | ||
| 3558 | 3558 | |
| 3559 | 3559 | for (i = 0; i < irq_cnt; i++) { |
| 3560 | 3560 | snprintf(irq_name, sizeof(irq_name), "int%d", i); |
| 3561 | − irq = platform_get_irq_byname(pdev, irq_name); | |
| 3561 | + irq = platform_get_irq_byname_optional(pdev, irq_name); | |
| 3562 | 3562 | if (irq < 0) |
| 3563 | 3563 | irq = platform_get_irq(pdev, i); |
| 3564 | 3564 | if (irq < 0) { |
| @@ -3645,6 +3645,8 @@ fec_drv_remove(struct platform_device *pdev) · 80 unmodified lines | ||
| 3645 | 3645 | regulator_disable(fep->reg_phy); |
| 3646 | 3646 | pm_runtime_put(&pdev->dev); |
| 3647 | 3647 | pm_runtime_disable(&pdev->dev); |
| 3648 | + clk_disable_unprepare(fep->clk_ahb); | |
| 3649 | + clk_disable_unprepare(fep->clk_ipg); | |
| 3648 | 3650 | if (of_phy_is_fixed_link(np)) |
| 3649 | 3651 | of_phy_deregister_fixed_link(np); |
| 3650 | 3652 | of_node_put(fep->phy_node); |
| @@ -600,9 +600,9 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx) · 599 unmodified lines | ||
| 600 | 600 | |
| 601 | 601 | INIT_DELAYED_WORK(&fep->time_keep, fec_time_keep); |
| 602 | 602 | |
| 603 | − irq = platform_get_irq_byname(pdev, "pps"); | |
| 603 | + irq = platform_get_irq_byname_optional(pdev, "pps"); | |
| 604 | 604 | if (irq < 0) |
| 605 | − irq = platform_get_irq(pdev, irq_idx); | |
| 605 | + irq = platform_get_irq_optional(pdev, irq_idx); | |
| 606 | 606 | /* Failure to get an irq is not fatal, |
| 607 | 607 | * only the PTP_CLOCK_PPS clock events should stop |
| 608 | 608 | */ |
| @@ -289,6 +289,8 @@ static bool gve_rx(struct gve_rx_ring *rx, struct gve_rx_desc *rx_desc, · 288 unmodified lines | ||
| 289 | 289 | |
| 290 | 290 | len = be16_to_cpu(rx_desc->len) - GVE_RX_PAD; |
| 291 | 291 | page_info = &rx->data.page_info[idx]; |
| 292 | + dma_sync_single_for_cpu(&priv->pdev->dev, rx->data.qpl->page_buses[idx], | |
| 293 | + PAGE_SIZE, DMA_FROM_DEVICE); | |
| 292 | 294 | |
| 293 | 295 | /* gvnic can only receive into registered segments. If the buffer |
| 294 | 296 | * can't be recycled, our only choice is to copy the data out of |
| @@ -390,7 +390,21 @@ static void gve_tx_fill_seg_desc(union gve_tx_desc *seg_desc, · 389 unmodified lines | ||
| 390 | 390 | seg_desc->seg.seg_addr = cpu_to_be64(addr); |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | −static int gve_tx_add_skb(struct gve_tx_ring *tx, struct sk_buff *skb) | |
| 393 | +static void gve_dma_sync_for_device(struct device *dev, dma_addr_t *page_buses, | |
| 394 | + u64 iov_offset, u64 iov_len) | |
| 395 | +{ | |
| 396 | + dma_addr_t dma; | |
| 397 | + u64 addr; | |
| 398 | + | |
| 399 | + for (addr = iov_offset; addr < iov_offset + iov_len; | |
| 400 | + addr += PAGE_SIZE) { | |
| 401 | + dma = page_buses[addr / PAGE_SIZE]; | |
| 402 | + dma_sync_single_for_device(dev, dma, PAGE_SIZE, DMA_TO_DEVICE); | |
| 403 | + } | |
| 404 | +} | |
| 405 | + | |
| 406 | +static int gve_tx_add_skb(struct gve_tx_ring *tx, struct sk_buff *skb, | |
| 407 | + struct device *dev) | |
| 394 | 408 | { |
| 395 | 409 | int pad_bytes, hlen, hdr_nfrags, payload_nfrags, l4_hdr_offset; |
| 396 | 410 | union gve_tx_desc *pkt_desc, *seg_desc; |
| @@ -432,6 +446,9 @@ static int gve_tx_add_skb(struct gve_tx_ring *tx, struct sk_buff *skb) · 35 unmodified lines | ||
| 432 | 446 | skb_copy_bits(skb, 0, |
| 433 | 447 | tx->tx_fifo.base + info->iov[hdr_nfrags - 1].iov_offset, |
| 434 | 448 | hlen); |
| 449 | + gve_dma_sync_for_device(dev, tx->tx_fifo.qpl->page_buses, | |
| 450 | + info->iov[hdr_nfrags - 1].iov_offset, | |
| 451 | + info->iov[hdr_nfrags - 1].iov_len); | |
| 435 | 452 | copy_offset = hlen; |
| 436 | 453 | |
| 437 | 454 | for (i = payload_iov; i < payload_nfrags + payload_iov; i++) { |
| @@ -445,6 +462,9 @@ static int gve_tx_add_skb(struct gve_tx_ring *tx, struct sk_buff *skb) · 7 unmodified lines | ||
| 445 | 462 | skb_copy_bits(skb, copy_offset, |
| 446 | 463 | tx->tx_fifo.base + info->iov[i].iov_offset, |
| 447 | 464 | info->iov[i].iov_len); |
| 465 | + gve_dma_sync_for_device(dev, tx->tx_fifo.qpl->page_buses, | |
| 466 | + info->iov[i].iov_offset, | |
| 467 | + info->iov[i].iov_len); | |
| 448 | 468 | copy_offset += info->iov[i].iov_len; |
| 449 | 469 | } |
| 450 | 470 | |
| @@ -473,7 +493,7 @@ netdev_tx_t gve_tx(struct sk_buff *skb, struct net_device *dev) · 22 unmodified lines | ||
| 473 | 493 | gve_tx_put_doorbell(priv, tx->q_resources, tx->req); |
| 474 | 494 | return NETDEV_TX_BUSY; |
| 475 | 495 | } |
| 476 | − nsegs = gve_tx_add_skb(tx, skb); | |
| 496 | + nsegs = gve_tx_add_skb(tx, skb, &priv->pdev->dev); | |
| 477 | 497 | |
| 478 | 498 | netdev_tx_sent_queue(tx->netdev_txq, skb->len); |
| 479 | 499 | skb_tx_timestamp(skb); |
| @@ -237,6 +237,7 @@ struct hip04_priv { · 236 unmodified lines | ||
| 237 | 237 | dma_addr_t rx_phys[RX_DESC_NUM]; |
| 238 | 238 | unsigned int rx_head; |
| 239 | 239 | unsigned int rx_buf_size; |
| 240 | + unsigned int rx_cnt_remaining; | |
| 240 | 241 | |
| 241 | 242 | struct device_node *phy_node; |
| 242 | 243 | struct phy_device *phy; |
| @@ -575,7 +576,6 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget) · 332 unmodified lines | ||
| 575 | 576 | struct hip04_priv *priv = container_of(napi, struct hip04_priv, napi); |
| 576 | 577 | struct net_device *ndev = priv->ndev; |
| 577 | 578 | struct net_device_stats *stats = &ndev->stats; |
| 578 | − unsigned int cnt = hip04_recv_cnt(priv); | |
| 579 | 579 | struct rx_desc *desc; |
| 580 | 580 | struct sk_buff *skb; |
| 581 | 581 | unsigned char *buf; |
| @@ -588,8 +588,8 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget) · 6 unmodified lines | ||
| 588 | 588 | |
| 589 | 589 | /* clean up tx descriptors */ |
| 590 | 590 | tx_remaining = hip04_tx_reclaim(ndev, false); |
| 591 | − | |
| 592 | − while (cnt && !last) { | |
| 591 | + priv->rx_cnt_remaining += hip04_recv_cnt(priv); | |
| 592 | + while (priv->rx_cnt_remaining && !last) { | |
| 593 | 593 | buf = priv->rx_buf[priv->rx_head]; |
| 594 | 594 | skb = build_skb(buf, priv->rx_buf_size); |
| 595 | 595 | if (unlikely(!skb)) { |
| @@ -635,11 +635,13 @@ refill: · 39 unmodified lines | ||
| 635 | 635 | hip04_set_recv_desc(priv, phys); |
| 636 | 636 | |
| 637 | 637 | priv->rx_head = RX_NEXT(priv->rx_head); |
| 638 | − if (rx >= budget) | |
| 638 | + if (rx >= budget) { | |
| 639 | + --priv->rx_cnt_remaining; | |
| 639 | 640 | goto done; |
| 641 | + } | |
| 640 | 642 | |
| 641 | − if (--cnt == 0) | |
| 642 | − cnt = hip04_recv_cnt(priv); | |
| 643 | + if (--priv->rx_cnt_remaining == 0) | |
| 644 | + priv->rx_cnt_remaining += hip04_recv_cnt(priv); | |
| 643 | 645 | } |
| 644 | 646 | |
| 645 | 647 | if (!(priv->reg_inten & RCV_INT)) { |
| @@ -724,6 +726,7 @@ static int hip04_mac_open(struct net_device *ndev) · 78 unmodified lines | ||
| 724 | 726 | int i; |
| 725 | 727 | |
| 726 | 728 | priv->rx_head = 0; |
| 729 | + priv->rx_cnt_remaining = 0; | |
| 727 | 730 | priv->tx_head = 0; |
| 728 | 731 | priv->tx_tail = 0; |
| 729 | 732 | hip04_reset_ppe(priv); |
| @@ -1038,7 +1041,6 @@ static int hip04_remove(struct platform_device *pdev) · 308 unmodified lines | ||
| 1038 | 1041 | |
| 1039 | 1042 | hip04_free_ring(ndev, d); |
| 1040 | 1043 | unregister_netdev(ndev); |
| 1041 | − free_irq(ndev->irq, ndev); | |
| 1042 | 1044 | of_node_put(priv->phy_node); |
| 1043 | 1045 | cancel_work_sync(&priv->tx_timeout_task); |
| 1044 | 1046 | free_netdev(ndev); |
| @@ -199,7 +199,6 @@ hnae_init_ring(struct hnae_queue *q, struct hnae_ring *ring, int flags) · 198 unmodified lines | ||
| 199 | 199 | |
| 200 | 200 | ring->q = q; |
| 201 | 201 | ring->flags = flags; |
| 202 | − spin_lock_init(&ring->lock); | |
| 203 | 202 | ring->coal_param = q->handle->coal_param; |
| 204 | 203 | assert(!ring->desc && !ring->desc_cb && !ring->desc_dma_addr); |
| 205 | 204 | |
| @@ -274,9 +274,6 @@ struct hnae_ring { · 273 unmodified lines | ||
| 274 | 274 | /* statistic */ |
| 275 | 275 | struct ring_stats stats; |
| 276 | 276 | |
| 277 | − /* ring lock for poll one */ | |
| 278 | − spinlock_t lock; | |
| 279 | − | |
| 280 | 277 | dma_addr_t desc_dma_addr; |
| 281 | 278 | u32 buf_size; /* size for hnae_desc->addr, preset by AE */ |
| 282 | 279 | u16 desc_num; /* total number of desc */ |
| @@ -943,15 +943,6 @@ static int is_valid_clean_head(struct hnae_ring *ring, int h) · 942 unmodified lines | ||
| 943 | 943 | return u > c ? (h > c && h <= u) : (h > c || h <= u); |
| 944 | 944 | } |
| 945 | 945 | |
| 946 | −/* netif_tx_lock will turn down the performance, set only when necessary */ | |
| 947 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 948 | −#define NETIF_TX_LOCK(ring) spin_lock(&(ring)->lock) | |
| 949 | −#define NETIF_TX_UNLOCK(ring) spin_unlock(&(ring)->lock) | |
| 950 | −#else | |
| 951 | −#define NETIF_TX_LOCK(ring) | |
| 952 | −#define NETIF_TX_UNLOCK(ring) | |
| 953 | −#endif | |
| 954 | − | |
| 955 | 946 | /* reclaim all desc in one budget |
| 956 | 947 | * return error or number of desc left |
| 957 | 948 | */ |
| @@ -965,21 +956,16 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data, · 7 unmodified lines | ||
| 965 | 956 | int head; |
| 966 | 957 | int bytes, pkts; |
| 967 | 958 | |
| 968 | − NETIF_TX_LOCK(ring); | |
| 969 | − | |
| 970 | 959 | head = readl_relaxed(ring->io_base + RCB_REG_HEAD); |
| 971 | 960 | rmb(); /* make sure head is ready before touch any data */ |
| 972 | 961 | |
| 973 | − if (is_ring_empty(ring) || head == ring->next_to_clean) { | |
| 974 | − NETIF_TX_UNLOCK(ring); | |
| 962 | + if (is_ring_empty(ring) || head == ring->next_to_clean) | |
| 975 | 963 | return 0; /* no data to poll */ |
| 976 | − } | |
| 977 | 964 | |
| 978 | 965 | if (!is_valid_clean_head(ring, head)) { |
| 979 | 966 | netdev_err(ndev, "wrong head (%d, %d-%d)\n", head, |
| 980 | 967 | ring->next_to_use, ring->next_to_clean); |
| 981 | 968 | ring->stats.io_err_cnt++; |
| 982 | − NETIF_TX_UNLOCK(ring); | |
| 983 | 969 | return -EIO; |
| 984 | 970 | } |
| 985 | 971 | |
| @@ -994,8 +980,6 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data, · 8 unmodified lines | ||
| 994 | 980 | ring->stats.tx_pkts += pkts; |
| 995 | 981 | ring->stats.tx_bytes += bytes; |
| 996 | 982 | |
| 997 | − NETIF_TX_UNLOCK(ring); | |
| 998 | − | |
| 999 | 983 | dev_queue = netdev_get_tx_queue(ndev, ring_data->queue_index); |
| 1000 | 984 | netdev_tx_completed_queue(dev_queue, pkts, bytes); |
| 1001 | 985 | |
| @@ -1055,16 +1039,12 @@ static void hns_nic_tx_clr_all_bufs(struct hns_nic_ring_data *ring_data) · 53 unmodified lines | ||
| 1055 | 1039 | int head; |
| 1056 | 1040 | int bytes, pkts; |
| 1057 | 1041 | |
| 1058 | − NETIF_TX_LOCK(ring); | |
| 1059 | − | |
| 1060 | 1042 | head = ring->next_to_use; /* ntu :soft setted ring position*/ |
| 1061 | 1043 | bytes = 0; |
| 1062 | 1044 | pkts = 0; |
| 1063 | 1045 | while (head != ring->next_to_clean) |
| 1064 | 1046 | hns_nic_reclaim_one_desc(ring, &bytes, &pkts); |
| 1065 | 1047 | |
| 1066 | − NETIF_TX_UNLOCK(ring); | |
| 1067 | − | |
| 1068 | 1048 | dev_queue = netdev_get_tx_queue(ndev, ring_data->queue_index); |
| 1069 | 1049 | netdev_tx_reset_queue(dev_queue); |
| 1070 | 1050 | } |
| @@ -1,4 +1,4 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0+ | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 2 | 2 | // Copyright (c) 2016-2017 Hisilicon Limited. |
| 3 | 3 | |
| 4 | 4 | #ifndef __HNAE3_H |
| @@ -1,4 +1,4 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0+ | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 2 | 2 | // Copyright (c) 2016-2017 Hisilicon Limited. |
| 3 | 3 | |
| 4 | 4 | #ifndef __HNS3_ENET_H |
| @@ -1,4 +1,4 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0+ | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 2 | 2 | // Copyright (c) 2016-2017 Hisilicon Limited. |
| 3 | 3 | |
| 4 | 4 | #ifndef __HCLGE_CMD_H |
| @@ -1,4 +1,4 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0+ | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 2 | 2 | // Copyright (c) 2016-2017 Hisilicon Limited. |
| 3 | 3 | |
| 4 | 4 | #ifndef __HCLGE_DCB_H__ |
| @@ -3587,12 +3587,28 @@ static int hclge_set_rst_done(struct hclge_dev *hdev) · 3586 unmodified lines | ||
| 3587 | 3587 | { |
| 3588 | 3588 | struct hclge_pf_rst_done_cmd *req; |
| 3589 | 3589 | struct hclge_desc desc; |
| 3590 | + int ret; | |
| 3590 | 3591 | |
| 3591 | 3592 | req = (struct hclge_pf_rst_done_cmd *)desc.data; |
| 3592 | 3593 | hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_PF_RST_DONE, false); |
| 3593 | 3594 | req->pf_rst_done |= HCLGE_PF_RESET_DONE_BIT; |
| 3594 | 3595 | |
| 3595 | − return hclge_cmd_send(&hdev->hw, &desc, 1); | |
| 3596 | + ret = hclge_cmd_send(&hdev->hw, &desc, 1); | |
| 3597 | + /* To be compatible with the old firmware, which does not support | |
| 3598 | + * command HCLGE_OPC_PF_RST_DONE, just print a warning and | |
| 3599 | + * return success | |
| 3600 | + */ | |
| 3601 | + if (ret == -EOPNOTSUPP) { | |
| 3602 | + dev_warn(&hdev->pdev->dev, | |
| 3603 | + "current firmware does not support command(0x%x)!\n", | |
| 3604 | + HCLGE_OPC_PF_RST_DONE); | |
| 3605 | + return 0; | |
| 3606 | + } else if (ret) { | |
| 3607 | + dev_err(&hdev->pdev->dev, "assert PF reset done fail %d!\n", | |
| 3608 | + ret); | |
| 3609 | + } | |
| 3610 | + | |
| 3611 | + return ret; | |
| 3596 | 3612 | } |
| 3597 | 3613 | |
| 3598 | 3614 | static int hclge_reset_prepare_up(struct hclge_dev *hdev) |
| @@ -1,4 +1,4 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0+ | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 2 | 2 | // Copyright (c) 2016-2017 Hisilicon Limited. |
| 3 | 3 | |
| 4 | 4 | #ifndef __HCLGE_MAIN_H |
| @@ -1,4 +1,4 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0+ | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 2 | 2 | // Copyright (c) 2016-2017 Hisilicon Limited. |
| 3 | 3 | |
| 4 | 4 | #ifndef __HCLGE_MDIO_H |
| @@ -1,4 +1,4 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0+ | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 2 | 2 | // Copyright (c) 2016-2017 Hisilicon Limited. |
| 3 | 3 | |
| 4 | 4 | #ifndef __HCLGE_TM_H |
| @@ -607,6 +607,7 @@ static int e1000_set_ringparam(struct net_device *netdev, · 606 unmodified lines | ||
| 607 | 607 | for (i = 0; i < adapter->num_rx_queues; i++) |
| 608 | 608 | rxdr[i].count = rxdr->count; |
| 609 | 609 | |
| 610 | + err = 0; | |
| 610 | 611 | if (netif_running(adapter->netdev)) { |
| 611 | 612 | /* Try to get new resources before deleting old */ |
| 612 | 613 | err = e1000_setup_all_rx_resources(adapter); |
| @@ -627,14 +628,13 @@ static int e1000_set_ringparam(struct net_device *netdev, · 14 unmodified lines | ||
| 627 | 628 | adapter->rx_ring = rxdr; |
| 628 | 629 | adapter->tx_ring = txdr; |
| 629 | 630 | err = e1000_up(adapter); |
| 630 | − if (err) | |
| 631 | − goto err_setup; | |
| 632 | 631 | } |
| 633 | 632 | kfree(tx_old); |
| 634 | 633 | kfree(rx_old); |
| 635 | 634 | |
| 636 | 635 | clear_bit(__E1000_RESETTING, &adapter->flags); |
| 637 | − return 0; | |
| 636 | + return err; | |
| 637 | + | |
| 638 | 638 | err_setup_tx: |
| 639 | 639 | e1000_free_all_rx_resources(adapter); |
| 640 | 640 | err_setup_rx: |
| @@ -646,7 +646,6 @@ err_alloc_rx: · 5 unmodified lines | ||
| 646 | 646 | err_alloc_tx: |
| 647 | 647 | if (netif_running(adapter->netdev)) |
| 648 | 648 | e1000_up(adapter); |
| 649 | −err_setup: | |
| 650 | 649 | clear_bit(__E1000_RESETTING, &adapter->flags); |
| 651 | 650 | return err; |
| 652 | 651 | } |
| @@ -20,6 +20,8 @@ · 19 unmodified lines | ||
| 20 | 20 | |
| 21 | 21 | /* API version 1.7 implements additional link and PHY-specific APIs */ |
| 22 | 22 | #define I40E_MINOR_VER_GET_LINK_INFO_XL710 0x0007 |
| 23 | +/* API version 1.9 for X722 implements additional link and PHY-specific APIs */ | |
| 24 | +#define I40E_MINOR_VER_GET_LINK_INFO_X722 0x0009 | |
| 23 | 25 | /* API version 1.6 for X722 devices adds ability to stop FW LLDP agent */ |
| 24 | 26 | #define I40E_MINOR_VER_FW_LLDP_STOPPABLE_X722 0x0006 |
| 25 | 27 | |
| @@ -1876,7 +1876,8 @@ i40e_status i40e_aq_get_link_info(struct i40e_hw *hw, · 1875 unmodified lines | ||
| 1876 | 1876 | hw->aq.fw_min_ver < 40)) && hw_link_info->phy_type == 0xE) |
| 1877 | 1877 | hw_link_info->phy_type = I40E_PHY_TYPE_10GBASE_SFPP_CU; |
| 1878 | 1878 | |
| 1879 | − if (hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE) { | |
| 1879 | + if (hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE && | |
| 1880 | + hw->mac.type != I40E_MAC_X722) { | |
| 1880 | 1881 | __le32 tmp; |
| 1881 | 1882 | |
| 1882 | 1883 | memcpy(&tmp, resp->link_type, sizeof(tmp)); |
| @@ -157,11 +157,6 @@ static int i40e_xsk_umem_disable(struct i40e_vsi *vsi, u16 qid) · 156 unmodified lines | ||
| 157 | 157 | err = i40e_queue_pair_enable(vsi, qid); |
| 158 | 158 | if (err) |
| 159 | 159 | return err; |
| 160 | − | |
| 161 | − /* Kick start the NAPI context so that receiving will start */ | |
| 162 | − err = i40e_xsk_wakeup(vsi->netdev, qid, XDP_WAKEUP_RX); | |
| 163 | − if (err) | |
| 164 | − return err; | |
| 165 | 160 | } |
| 166 | 161 | |
| 167 | 162 | return 0; |
| @@ -694,8 +689,6 @@ static bool i40e_xmit_zc(struct i40e_ring *xdp_ring, unsigned int budget) · 526 unmodified lines | ||
| 694 | 689 | i40e_xdp_ring_update_tail(xdp_ring); |
| 695 | 690 | |
| 696 | 691 | xsk_umem_consume_tx_done(xdp_ring->xsk_umem); |
| 697 | − if (xsk_umem_uses_need_wakeup(xdp_ring->xsk_umem)) | |
| 698 | − xsk_clear_tx_need_wakeup(xdp_ring->xsk_umem); | |
| 699 | 692 | } |
| 700 | 693 | |
| 701 | 694 | return !!budget && work_done; |
| @@ -774,12 +767,8 @@ bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi, · 72 unmodified lines | ||
| 774 | 767 | i40e_update_tx_stats(tx_ring, completed_frames, total_bytes); |
| 775 | 768 | |
| 776 | 769 | out_xmit: |
| 777 | − if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem)) { | |
| 778 | − if (tx_ring->next_to_clean == tx_ring->next_to_use) | |
| 779 | − xsk_set_tx_need_wakeup(tx_ring->xsk_umem); | |
| 780 | − else | |
| 781 | − xsk_clear_tx_need_wakeup(tx_ring->xsk_umem); | |
| 782 | − } | |
| 770 | + if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem)) | |
| 771 | + xsk_set_tx_need_wakeup(tx_ring->xsk_umem); | |
| 783 | 772 | |
| 784 | 773 | xmit_done = i40e_xmit_zc(tx_ring, budget); |
| 785 | 774 | |
| @@ -314,7 +314,7 @@ iavf_map_vector_to_rxq(struct iavf_adapter *adapter, int v_idx, int r_idx) · 313 unmodified lines | ||
| 314 | 314 | q_vector->rx.target_itr = ITR_TO_REG(rx_ring->itr_setting); |
| 315 | 315 | q_vector->ring_mask |= BIT(r_idx); |
| 316 | 316 | wr32(hw, IAVF_VFINT_ITRN1(IAVF_RX_ITR, q_vector->reg_idx), |
| 317 | − q_vector->rx.current_itr); | |
| 317 | + q_vector->rx.current_itr >> 1); | |
| 318 | 318 | q_vector->rx.current_itr = q_vector->rx.target_itr; |
| 319 | 319 | } |
| 320 | 320 | |
| @@ -340,7 +340,7 @@ iavf_map_vector_to_txq(struct iavf_adapter *adapter, int v_idx, int t_idx) · 19 unmodified lines | ||
| 340 | 340 | q_vector->tx.target_itr = ITR_TO_REG(tx_ring->itr_setting); |
| 341 | 341 | q_vector->num_ringpairs++; |
| 342 | 342 | wr32(hw, IAVF_VFINT_ITRN1(IAVF_TX_ITR, q_vector->reg_idx), |
| 343 | − q_vector->tx.target_itr); | |
| 343 | + q_vector->tx.target_itr >> 1); | |
| 344 | 344 | q_vector->tx.current_itr = q_vector->tx.target_itr; |
| 345 | 345 | } |
| 346 | 346 | |
| @@ -1036,7 +1036,7 @@ enum ice_status ice_sched_query_res_alloc(struct ice_hw *hw) · 1035 unmodified lines | ||
| 1036 | 1036 | struct ice_aqc_query_txsched_res_resp *buf; |
| 1037 | 1037 | enum ice_status status = 0; |
| 1038 | 1038 | __le16 max_sibl; |
| 1039 | − u8 i; | |
| 1039 | + u16 i; | |
| 1040 | 1040 | |
| 1041 | 1041 | if (hw->layer_info) |
| 1042 | 1042 | return status; |
| @@ -466,7 +466,7 @@ static s32 igb_init_mac_params_82575(struct e1000_hw *hw) · 465 unmodified lines | ||
| 466 | 466 | ? igb_setup_copper_link_82575 |
| 467 | 467 | : igb_setup_serdes_link_82575; |
| 468 | 468 | |
| 469 | − if (mac->type == e1000_82580) { | |
| 469 | + if (mac->type == e1000_82580 || mac->type == e1000_i350) { | |
| 470 | 470 | switch (hw->device_id) { |
| 471 | 471 | /* feature not supported on these id's */ |
| 472 | 472 | case E1000_DEV_ID_DH89XXCC_SGMII: |
| @@ -753,7 +753,8 @@ u32 igb_rd32(struct e1000_hw *hw, u32 reg) · 752 unmodified lines | ||
| 753 | 753 | struct net_device *netdev = igb->netdev; |
| 754 | 754 | hw->hw_addr = NULL; |
| 755 | 755 | netdev_err(netdev, "PCIe link lost\n"); |
| 756 | − WARN(1, "igb: Failed to read reg 0x%x!\n", reg); | |
| 756 | + WARN(pci_device_is_present(igb->pdev), | |
| 757 | + "igb: Failed to read reg 0x%x!\n", reg); | |
| 757 | 758 | } |
| 758 | 759 | |
| 759 | 760 | return value; |
| @@ -2064,7 +2065,8 @@ static void igb_check_swap_media(struct igb_adapter *adapter) · 1304 unmodified lines | ||
| 2064 | 2065 | if ((hw->phy.media_type == e1000_media_type_copper) && |
| 2065 | 2066 | (!(connsw & E1000_CONNSW_AUTOSENSE_EN))) { |
| 2066 | 2067 | swap_now = true; |
| 2067 | − } else if (!(connsw & E1000_CONNSW_SERDESD)) { | |
| 2068 | + } else if ((hw->phy.media_type != e1000_media_type_copper) && | |
| 2069 | + !(connsw & E1000_CONNSW_SERDESD)) { | |
| 2068 | 2070 | /* copper signal takes time to appear */ |
| 2069 | 2071 | if (adapter->copper_tries < 4) { |
| 2070 | 2072 | adapter->copper_tries++; |
| @@ -2370,7 +2372,7 @@ void igb_reset(struct igb_adapter *adapter) · 299 unmodified lines | ||
| 2370 | 2372 | adapter->ei.get_invariants(hw); |
| 2371 | 2373 | adapter->flags &= ~IGB_FLAG_MEDIA_RESET; |
| 2372 | 2374 | } |
| 2373 | − if ((mac->type == e1000_82575) && | |
| 2375 | + if ((mac->type == e1000_82575 || mac->type == e1000_i350) && | |
| 2374 | 2376 | (adapter->flags & IGB_FLAG_MAS_ENABLE)) { |
| 2375 | 2377 | igb_enable_mas(adapter); |
| 2376 | 2378 | } |
| @@ -5673,8 +5675,8 @@ static void igb_tx_ctxtdesc(struct igb_ring *tx_ring, · 3296 unmodified lines | ||
| 5673 | 5675 | * should have been handled by the upper layers. |
| 5674 | 5676 | */ |
| 5675 | 5677 | if (tx_ring->launchtime_enable) { |
| 5676 | − ts = ns_to_timespec64(first->skb->tstamp); | |
| 5677 | − first->skb->tstamp = 0; | |
| 5678 | + ts = ktime_to_timespec64(first->skb->tstamp); | |
| 5679 | + first->skb->tstamp = ktime_set(0, 0); | |
| 5678 | 5680 | context_desc->seqnum_seed = cpu_to_le32(ts.tv_nsec / 32); |
| 5679 | 5681 | } else { |
| 5680 | 5682 | context_desc->seqnum_seed = 0; |
| @@ -824,8 +824,8 @@ static void igc_tx_ctxtdesc(struct igc_ring *tx_ring, · 823 unmodified lines | ||
| 824 | 824 | * should have been handled by the upper layers. |
| 825 | 825 | */ |
| 826 | 826 | if (tx_ring->launchtime_enable) { |
| 827 | − ts = ns_to_timespec64(first->skb->tstamp); | |
| 828 | − first->skb->tstamp = 0; | |
| 827 | + ts = ktime_to_timespec64(first->skb->tstamp); | |
| 828 | + first->skb->tstamp = ktime_set(0, 0); | |
| 829 | 829 | context_desc->launch_time = cpu_to_le32(ts.tv_nsec / 32); |
| 830 | 830 | } else { |
| 831 | 831 | context_desc->launch_time = 0; |
| @@ -4047,7 +4047,8 @@ u32 igc_rd32(struct igc_hw *hw, u32 reg) · 3215 unmodified lines | ||
| 4047 | 4047 | hw->hw_addr = NULL; |
| 4048 | 4048 | netif_device_detach(netdev); |
| 4049 | 4049 | netdev_err(netdev, "PCIe link lost, device now detached\n"); |
| 4050 | − WARN(1, "igc: Failed to read reg 0x%x!\n", reg); | |
| 4050 | + WARN(pci_device_is_present(igc->pdev), | |
| 4051 | + "igc: Failed to read reg 0x%x!\n", reg); | |
| 4051 | 4052 | } |
| 4052 | 4053 | |
| 4053 | 4054 | return value; |
| @@ -4310,7 +4310,6 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) · 4309 unmodified lines | ||
| 4310 | 4310 | if (test_bit(__IXGBE_RX_FCOE, &rx_ring->state)) |
| 4311 | 4311 | set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); |
| 4312 | 4312 | |
| 4313 | − clear_bit(__IXGBE_RX_BUILD_SKB_ENABLED, &rx_ring->state); | |
| 4314 | 4313 | if (adapter->flags2 & IXGBE_FLAG2_RX_LEGACY) |
| 4315 | 4314 | continue; |
| 4316 | 4315 | |
| @@ -622,8 +622,6 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) · 621 unmodified lines | ||
| 622 | 622 | if (tx_desc) { |
| 623 | 623 | ixgbe_xdp_ring_update_tail(xdp_ring); |
| 624 | 624 | xsk_umem_consume_tx_done(xdp_ring->xsk_umem); |
| 625 | − if (xsk_umem_uses_need_wakeup(xdp_ring->xsk_umem)) | |
| 626 | − xsk_clear_tx_need_wakeup(xdp_ring->xsk_umem); | |
| 627 | 625 | } |
| 628 | 626 | |
| 629 | 627 | return !!budget && work_done; |
| @@ -691,12 +689,8 @@ bool ixgbe_clean_xdp_tx_irq(struct ixgbe_q_vector *q_vector, · 61 unmodified lines | ||
| 691 | 689 | if (xsk_frames) |
| 692 | 690 | xsk_umem_complete_tx(umem, xsk_frames); |
| 693 | 691 | |
| 694 | − if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem)) { | |
| 695 | − if (tx_ring->next_to_clean == tx_ring->next_to_use) | |
| 696 | − xsk_set_tx_need_wakeup(tx_ring->xsk_umem); | |
| 697 | − else | |
| 698 | − xsk_clear_tx_need_wakeup(tx_ring->xsk_umem); | |
| 699 | − } | |
| 692 | + if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem)) | |
| 693 | + xsk_set_tx_need_wakeup(tx_ring->xsk_umem); | |
| 700 | 694 | |
| 701 | 695 | return ixgbe_xmit_zc(tx_ring, q_vector->tx.work_limit); |
| 702 | 696 | } |
| @@ -160,16 +160,23 @@ static inline u32 mvneta_bm_pool_get_bp(struct mvneta_bm *priv, · 159 unmodified lines | ||
| 160 | 160 | (bm_pool->id << MVNETA_BM_POOL_ACCESS_OFFS)); |
| 161 | 161 | } |
| 162 | 162 | #else |
| 163 | −void mvneta_bm_pool_destroy(struct mvneta_bm *priv, | |
| 164 | − struct mvneta_bm_pool *bm_pool, u8 port_map) {} | |
| 165 | −void mvneta_bm_bufs_free(struct mvneta_bm *priv, struct mvneta_bm_pool *bm_pool, | |
| 166 | − u8 port_map) {} | |
| 167 | −int mvneta_bm_construct(struct hwbm_pool *hwbm_pool, void *buf) { return 0; } | |
| 168 | −int mvneta_bm_pool_refill(struct mvneta_bm *priv, | |
| 169 | − struct mvneta_bm_pool *bm_pool) {return 0; } | |
| 170 | −struct mvneta_bm_pool *mvneta_bm_pool_use(struct mvneta_bm *priv, u8 pool_id, | |
| 171 | − enum mvneta_bm_type type, u8 port_id, | |
| 172 | − int pkt_size) { return NULL; } | |
| 163 | +static inline void mvneta_bm_pool_destroy(struct mvneta_bm *priv, | |
| 164 | + struct mvneta_bm_pool *bm_pool, | |
| 165 | + u8 port_map) {} | |
| 166 | +static inline void mvneta_bm_bufs_free(struct mvneta_bm *priv, | |
| 167 | + struct mvneta_bm_pool *bm_pool, | |
| 168 | + u8 port_map) {} | |
| 169 | +static inline int mvneta_bm_construct(struct hwbm_pool *hwbm_pool, void *buf) | |
| 170 | +{ return 0; } | |
| 171 | +static inline int mvneta_bm_pool_refill(struct mvneta_bm *priv, | |
| 172 | + struct mvneta_bm_pool *bm_pool) | |
| 173 | +{ return 0; } | |
| 174 | +static inline struct mvneta_bm_pool *mvneta_bm_pool_use(struct mvneta_bm *priv, | |
| 175 | + u8 pool_id, | |
| 176 | + enum mvneta_bm_type type, | |
| 177 | + u8 port_id, | |
| 178 | + int pkt_size) | |
| 179 | +{ return NULL; } | |
| 173 | 180 | |
| 174 | 181 | static inline void mvneta_bm_pool_put_bp(struct mvneta_bm *priv, |
| 175 | 182 | struct mvneta_bm_pool *bm_pool, |
| @@ -178,7 +185,8 @@ static inline void mvneta_bm_pool_put_bp(struct mvneta_bm *priv, · 2 unmodified lines | ||
| 178 | 185 | static inline u32 mvneta_bm_pool_get_bp(struct mvneta_bm *priv, |
| 179 | 186 | struct mvneta_bm_pool *bm_pool) |
| 180 | 187 | { return 0; } |
| 181 | −struct mvneta_bm *mvneta_bm_get(struct device_node *node) { return NULL; } | |
| 182 | −void mvneta_bm_put(struct mvneta_bm *priv) {} | |
| 188 | +static inline struct mvneta_bm *mvneta_bm_get(struct device_node *node) | |
| 189 | +{ return NULL; } | |
| 190 | +static inline void mvneta_bm_put(struct mvneta_bm *priv) {} | |
| 183 | 191 | #endif /* CONFIG_MVNETA_BM */ |
| 184 | 192 | #endif |
| @@ -514,8 +514,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) · 513 unmodified lines | ||
| 514 | 514 | dev->caps.max_rq_desc_sz = dev_cap->max_rq_desc_sz; |
| 515 | 515 | /* |
| 516 | 516 | * Subtract 1 from the limit because we need to allocate a |
| 517 | − * spare CQE so the HCA HW can tell the difference between an | |
| 518 | − * empty CQ and a full CQ. | |
| 517 | + * spare CQE to enable resizing the CQ. | |
| 519 | 518 | */ |
| 520 | 519 | dev->caps.max_cqes = dev_cap->max_cq_sz - 1; |
| 521 | 520 | dev->caps.reserved_cqs = dev_cap->reserved_cqs; |
| @@ -471,12 +471,31 @@ void mlx4_init_quotas(struct mlx4_dev *dev) · 470 unmodified lines | ||
| 471 | 471 | priv->mfunc.master.res_tracker.res_alloc[RES_MPT].quota[pf]; |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | −static int get_max_gauranteed_vfs_counter(struct mlx4_dev *dev) | |
| 474 | +static int | |
| 475 | +mlx4_calc_res_counter_guaranteed(struct mlx4_dev *dev, | |
| 476 | + struct resource_allocator *res_alloc, | |
| 477 | + int vf) | |
| 475 | 478 | { |
| 476 | − /* reduce the sink counter */ | |
| 477 | − return (dev->caps.max_counters - 1 - | |
| 478 | − (MLX4_PF_COUNTERS_PER_PORT * MLX4_MAX_PORTS)) | |
| 479 | − / MLX4_MAX_PORTS; | |
| 479 | + struct mlx4_active_ports actv_ports; | |
| 480 | + int ports, counters_guaranteed; | |
| 481 | + | |
| 482 | + /* For master, only allocate according to the number of phys ports */ | |
| 483 | + if (vf == mlx4_master_func_num(dev)) | |
| 484 | + return MLX4_PF_COUNTERS_PER_PORT * dev->caps.num_ports; | |
| 485 | + | |
| 486 | + /* calculate real number of ports for the VF */ | |
| 487 | + actv_ports = mlx4_get_active_ports(dev, vf); | |
| 488 | + ports = bitmap_weight(actv_ports.ports, dev->caps.num_ports); | |
| 489 | + counters_guaranteed = ports * MLX4_VF_COUNTERS_PER_PORT; | |
| 490 | + | |
| 491 | + /* If we do not have enough counters for this VF, do not | |
| 492 | + * allocate any for it. '-1' to reduce the sink counter. | |
| 493 | + */ | |
| 494 | + if ((res_alloc->res_reserved + counters_guaranteed) > | |
| 495 | + (dev->caps.max_counters - 1)) | |
| 496 | + return 0; | |
| 497 | + | |
| 498 | + return counters_guaranteed; | |
| 480 | 499 | } |
| 481 | 500 | |
| 482 | 501 | int mlx4_init_resource_tracker(struct mlx4_dev *dev) |
| @@ -484,7 +503,6 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev) · 1 unmodified line | ||
| 484 | 503 | struct mlx4_priv *priv = mlx4_priv(dev); |
| 485 | 504 | int i, j; |
| 486 | 505 | int t; |
| 487 | − int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev); | |
| 488 | 506 | |
| 489 | 507 | priv->mfunc.master.res_tracker.slave_list = |
| 490 | 508 | kcalloc(dev->num_slaves, sizeof(struct slave_list), |
| @@ -603,16 +621,8 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev) · 112 unmodified lines | ||
| 603 | 621 | break; |
| 604 | 622 | case RES_COUNTER: |
| 605 | 623 | res_alloc->quota[t] = dev->caps.max_counters; |
| 606 | − if (t == mlx4_master_func_num(dev)) | |
| 607 | − res_alloc->guaranteed[t] = | |
| 608 | − MLX4_PF_COUNTERS_PER_PORT * | |
| 609 | − MLX4_MAX_PORTS; | |
| 610 | − else if (t <= max_vfs_guarantee_counter) | |
| 611 | − res_alloc->guaranteed[t] = | |
| 612 | − MLX4_VF_COUNTERS_PER_PORT * | |
| 613 | − MLX4_MAX_PORTS; | |
| 614 | − else | |
| 615 | − res_alloc->guaranteed[t] = 0; | |
| 624 | + res_alloc->guaranteed[t] = | |
| 625 | + mlx4_calc_res_counter_guaranteed(dev, res_alloc, t); | |
| 616 | 626 | break; |
| 617 | 627 | default: |
| 618 | 628 | break; |
| @@ -345,7 +345,7 @@ struct mlx5e_tx_wqe_info { · 344 unmodified lines | ||
| 345 | 345 | u8 num_wqebbs; |
| 346 | 346 | u8 num_dma; |
| 347 | 347 | #ifdef CONFIG_MLX5_EN_TLS |
| 348 | − skb_frag_t *resync_dump_frag; | |
| 348 | + struct page *resync_dump_frag_page; | |
| 349 | 349 | #endif |
| 350 | 350 | }; |
| 351 | 351 | |
| @@ -410,6 +410,7 @@ struct mlx5e_txqsq { · 58 unmodified lines | ||
| 410 | 410 | struct device *pdev; |
| 411 | 411 | __be32 mkey_be; |
| 412 | 412 | unsigned long state; |
| 413 | + unsigned int hw_mtu; | |
| 413 | 414 | struct hwtstamp_config *tstamp; |
| 414 | 415 | struct mlx5_clock *clock; |
| 415 | 416 | |
| @@ -141,7 +141,7 @@ int mlx5e_hv_vhca_stats_create(struct mlx5e_priv *priv) · 140 unmodified lines | ||
| 141 | 141 | "Failed to create hv vhca stats agent, err = %ld\n", |
| 142 | 142 | PTR_ERR(agent)); |
| 143 | 143 | |
| 144 | − kfree(priv->stats_agent.buf); | |
| 144 | + kvfree(priv->stats_agent.buf); | |
| 145 | 145 | return IS_ERR_OR_NULL(agent); |
| 146 | 146 | } |
| 147 | 147 | |
| @@ -157,5 +157,5 @@ void mlx5e_hv_vhca_stats_destroy(struct mlx5e_priv *priv) · 9 unmodified lines | ||
| 157 | 157 | return; |
| 158 | 158 | |
| 159 | 159 | mlx5_hv_vhca_agent_destroy(priv->stats_agent.agent); |
| 160 | − kfree(priv->stats_agent.buf); | |
| 160 | + kvfree(priv->stats_agent.buf); | |
| 161 | 161 | } |
| @@ -97,15 +97,19 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv, · 96 unmodified lines | ||
| 97 | 97 | if (ret) |
| 98 | 98 | return ret; |
| 99 | 99 | |
| 100 | − if (mlx5_lag_is_multipath(mdev) && rt->rt_gw_family != AF_INET) | |
| 100 | + if (mlx5_lag_is_multipath(mdev) && rt->rt_gw_family != AF_INET) { | |
| 101 | + ip_rt_put(rt); | |
| 101 | 102 | return -ENETUNREACH; |
| 103 | + } | |
| 102 | 104 | #else |
| 103 | 105 | return -EOPNOTSUPP; |
| 104 | 106 | #endif |
| 105 | 107 | |
| 106 | 108 | ret = get_route_and_out_devs(priv, rt->dst.dev, route_dev, out_dev); |
| 107 | − if (ret < 0) | |
| 109 | + if (ret < 0) { | |
| 110 | + ip_rt_put(rt); | |
| 108 | 111 | return ret; |
| 112 | + } | |
| 109 | 113 | |
| 110 | 114 | if (!(*out_ttl)) |
| 111 | 115 | *out_ttl = ip4_dst_hoplimit(&rt->dst); |
| @@ -149,8 +153,10 @@ static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv, · 37 unmodified lines | ||
| 149 | 153 | *out_ttl = ip6_dst_hoplimit(dst); |
| 150 | 154 | |
| 151 | 155 | ret = get_route_and_out_devs(priv, dst->dev, route_dev, out_dev); |
| 152 | − if (ret < 0) | |
| 156 | + if (ret < 0) { | |
| 157 | + dst_release(dst); | |
| 153 | 158 | return ret; |
| 159 | + } | |
| 154 | 160 | #else |
| 155 | 161 | return -EOPNOTSUPP; |
| 156 | 162 | #endif |
| @@ -15,15 +15,14 @@ · 14 unmodified lines | ||
| 15 | 15 | #else |
| 16 | 16 | /* TLS offload requires additional stop_room for: |
| 17 | 17 | * - a resync SKB. |
| 18 | − * kTLS offload requires additional stop_room for: | |
| 19 | − * - static params WQE, | |
| 20 | − * - progress params WQE, and | |
| 21 | − * - resync DUMP per frag. | |
| 18 | + * kTLS offload requires fixed additional stop_room for: | |
| 19 | + * - a static params WQE, and a progress params WQE. | |
| 20 | + * The additional MTU-depending room for the resync DUMP WQEs | |
| 21 | + * will be calculated and added in runtime. | |
| 22 | 22 | */ |
| 23 | 23 | #define MLX5E_SQ_TLS_ROOM \ |
| 24 | 24 | (MLX5_SEND_WQE_MAX_WQEBBS + \ |
| 25 | − MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS + \ | |
| 26 | − MAX_SKB_FRAGS * MLX5E_KTLS_MAX_DUMP_WQEBBS) | |
| 25 | + MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS) | |
| 27 | 26 | #endif |
| 28 | 27 | |
| 29 | 28 | #define INL_HDR_START_SZ (sizeof(((struct mlx5_wqe_eth_seg *)NULL)->inline_hdr.start)) |
| @@ -92,7 +91,7 @@ mlx5e_fill_sq_frag_edge(struct mlx5e_txqsq *sq, struct mlx5_wq_cyc *wq, · 62 unmodified lines | ||
| 92 | 91 | |
| 93 | 92 | /* fill sq frag edge with nops to avoid wqe wrapping two pages */ |
| 94 | 93 | for (; wi < edge_wi; wi++) { |
| 95 | − wi->skb = NULL; | |
| 94 | + memset(wi, 0, sizeof(*wi)); | |
| 96 | 95 | wi->num_wqebbs = 1; |
| 97 | 96 | mlx5e_post_nop(wq, sq->sqn, &sq->pc); |
| 98 | 97 | } |
| @@ -38,7 +38,7 @@ static int mlx5e_ktls_add(struct net_device *netdev, struct sock *sk, · 37 unmodified lines | ||
| 38 | 38 | return -ENOMEM; |
| 39 | 39 | |
| 40 | 40 | tx_priv->expected_seq = start_offload_tcp_sn; |
| 41 | − tx_priv->crypto_info = crypto_info; | |
| 41 | + tx_priv->crypto_info = *(struct tls12_crypto_info_aes_gcm_128 *)crypto_info; | |
| 42 | 42 | mlx5e_set_ktls_tx_priv_ctx(tls_ctx, tx_priv); |
| 43 | 43 | |
| 44 | 44 | /* tc and underlay_qpn values are not in use for tls tis */ |
| @@ -21,7 +21,14 @@ · 20 unmodified lines | ||
| 21 | 21 | MLX5_ST_SZ_BYTES(tls_progress_params)) |
| 22 | 22 | #define MLX5E_KTLS_PROGRESS_WQEBBS \ |
| 23 | 23 | (DIV_ROUND_UP(MLX5E_KTLS_PROGRESS_WQE_SZ, MLX5_SEND_WQE_BB)) |
| 24 | −#define MLX5E_KTLS_MAX_DUMP_WQEBBS 2 | |
| 24 | + | |
| 25 | +struct mlx5e_dump_wqe { | |
| 26 | + struct mlx5_wqe_ctrl_seg ctrl; | |
| 27 | + struct mlx5_wqe_data_seg data; | |
| 28 | +}; | |
| 29 | + | |
| 30 | +#define MLX5E_KTLS_DUMP_WQEBBS \ | |
| 31 | + (DIV_ROUND_UP(sizeof(struct mlx5e_dump_wqe), MLX5_SEND_WQE_BB)) | |
| 25 | 32 | |
| 26 | 33 | enum { |
| 27 | 34 | MLX5E_TLS_PROGRESS_PARAMS_AUTH_STATE_NO_OFFLOAD = 0, |
| @@ -37,7 +44,7 @@ enum { · 9 unmodified lines | ||
| 37 | 44 | |
| 38 | 45 | struct mlx5e_ktls_offload_context_tx { |
| 39 | 46 | struct tls_offload_context_tx *tx_ctx; |
| 40 | − struct tls_crypto_info *crypto_info; | |
| 47 | + struct tls12_crypto_info_aes_gcm_128 crypto_info; | |
| 41 | 48 | u32 expected_seq; |
| 42 | 49 | u32 tisn; |
| 43 | 50 | u32 key_id; |
| @@ -86,14 +93,28 @@ struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev, · 42 unmodified lines | ||
| 86 | 93 | struct mlx5e_tx_wqe **wqe, u16 *pi); |
| 87 | 94 | void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq, |
| 88 | 95 | struct mlx5e_tx_wqe_info *wi, |
| 89 | − struct mlx5e_sq_dma *dma); | |
| 90 | − | |
| 96 | + u32 *dma_fifo_cc); | |
| 97 | +static inline u8 | |
| 98 | +mlx5e_ktls_dumps_num_wqebbs(struct mlx5e_txqsq *sq, unsigned int nfrags, | |
| 99 | + unsigned int sync_len) | |
| 100 | +{ | |
| 101 | + /* Given the MTU and sync_len, calculates an upper bound for the | |
| 102 | + * number of WQEBBs needed for the TX resync DUMP WQEs of a record. | |
| 103 | + */ | |
| 104 | + return MLX5E_KTLS_DUMP_WQEBBS * | |
| 105 | + (nfrags + DIV_ROUND_UP(sync_len, sq->hw_mtu)); | |
| 106 | +} | |
| 91 | 107 | #else |
| 92 | 108 | |
| 93 | 109 | static inline void mlx5e_ktls_build_netdev(struct mlx5e_priv *priv) |
| 94 | 110 | { |
| 95 | 111 | } |
| 96 | 112 | |
| 113 | +static inline void | |
| 114 | +mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq, | |
| 115 | + struct mlx5e_tx_wqe_info *wi, | |
| 116 | + u32 *dma_fifo_cc) {} | |
| 117 | + | |
| 97 | 118 | #endif |
| 98 | 119 | |
| 99 | 120 | #endif /* __MLX5E_TLS_H__ */ |
| @@ -24,17 +24,12 @@ enum { · 23 unmodified lines | ||
| 24 | 24 | static void |
| 25 | 25 | fill_static_params_ctx(void *ctx, struct mlx5e_ktls_offload_context_tx *priv_tx) |
| 26 | 26 | { |
| 27 | − struct tls_crypto_info *crypto_info = priv_tx->crypto_info; | |
| 28 | − struct tls12_crypto_info_aes_gcm_128 *info; | |
| 27 | + struct tls12_crypto_info_aes_gcm_128 *info = &priv_tx->crypto_info; | |
| 29 | 28 | char *initial_rn, *gcm_iv; |
| 30 | 29 | u16 salt_sz, rec_seq_sz; |
| 31 | 30 | char *salt, *rec_seq; |
| 32 | 31 | u8 tls_version; |
| 33 | 32 | |
| 34 | − if (WARN_ON(crypto_info->cipher_type != TLS_CIPHER_AES_GCM_128)) | |
| 35 | − return; | |
| 36 | − | |
| 37 | − info = (struct tls12_crypto_info_aes_gcm_128 *)crypto_info; | |
| 38 | 33 | EXTRACT_INFO_FIELDS; |
| 39 | 34 | |
| 40 | 35 | gcm_iv = MLX5_ADDR_OF(tls_static_params, ctx, gcm_iv); |
| @@ -108,16 +103,15 @@ build_progress_params(struct mlx5e_tx_wqe *wqe, u16 pc, u32 sqn, · 67 unmodified lines | ||
| 108 | 103 | } |
| 109 | 104 | |
| 110 | 105 | static void tx_fill_wi(struct mlx5e_txqsq *sq, |
| 111 | − u16 pi, u8 num_wqebbs, | |
| 112 | − skb_frag_t *resync_dump_frag, | |
| 113 | − u32 num_bytes) | |
| 106 | + u16 pi, u8 num_wqebbs, u32 num_bytes, | |
| 107 | + struct page *page) | |
| 114 | 108 | { |
| 115 | 109 | struct mlx5e_tx_wqe_info *wi = &sq->db.wqe_info[pi]; |
| 116 | 110 | |
| 117 | − wi->skb = NULL; | |
| 118 | − wi->num_wqebbs = num_wqebbs; | |
| 119 | − wi->resync_dump_frag = resync_dump_frag; | |
| 120 | − wi->num_bytes = num_bytes; | |
| 111 | + memset(wi, 0, sizeof(*wi)); | |
| 112 | + wi->num_wqebbs = num_wqebbs; | |
| 113 | + wi->num_bytes = num_bytes; | |
| 114 | + wi->resync_dump_frag_page = page; | |
| 121 | 115 | } |
| 122 | 116 | |
| 123 | 117 | void mlx5e_ktls_tx_offload_set_pending(struct mlx5e_ktls_offload_context_tx *priv_tx) |
| @@ -145,7 +139,7 @@ post_static_params(struct mlx5e_txqsq *sq, · 21 unmodified lines | ||
| 145 | 139 | |
| 146 | 140 | umr_wqe = mlx5e_sq_fetch_wqe(sq, MLX5E_KTLS_STATIC_UMR_WQE_SZ, &pi); |
| 147 | 141 | build_static_params(umr_wqe, sq->pc, sq->sqn, priv_tx, fence); |
| 148 | − tx_fill_wi(sq, pi, MLX5E_KTLS_STATIC_WQEBBS, NULL, 0); | |
| 142 | + tx_fill_wi(sq, pi, MLX5E_KTLS_STATIC_WQEBBS, 0, NULL); | |
| 149 | 143 | sq->pc += MLX5E_KTLS_STATIC_WQEBBS; |
| 150 | 144 | } |
| 151 | 145 | |
| @@ -159,7 +153,7 @@ post_progress_params(struct mlx5e_txqsq *sq, · 7 unmodified lines | ||
| 159 | 153 | |
| 160 | 154 | wqe = mlx5e_sq_fetch_wqe(sq, MLX5E_KTLS_PROGRESS_WQE_SZ, &pi); |
| 161 | 155 | build_progress_params(wqe, sq->pc, sq->sqn, priv_tx, fence); |
| 162 | − tx_fill_wi(sq, pi, MLX5E_KTLS_PROGRESS_WQEBBS, NULL, 0); | |
| 156 | + tx_fill_wi(sq, pi, MLX5E_KTLS_PROGRESS_WQEBBS, 0, NULL); | |
| 163 | 157 | sq->pc += MLX5E_KTLS_PROGRESS_WQEBBS; |
| 164 | 158 | } |
| 165 | 159 | |
| @@ -169,6 +163,14 @@ mlx5e_ktls_tx_post_param_wqes(struct mlx5e_txqsq *sq, · 3 unmodified lines | ||
| 169 | 163 | bool skip_static_post, bool fence_first_post) |
| 170 | 164 | { |
| 171 | 165 | bool progress_fence = skip_static_post || !fence_first_post; |
| 166 | + struct mlx5_wq_cyc *wq = &sq->wq; | |
| 167 | + u16 contig_wqebbs_room, pi; | |
| 168 | + | |
| 169 | + pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); | |
| 170 | + contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi); | |
| 171 | + if (unlikely(contig_wqebbs_room < | |
| 172 | + MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS)) | |
| 173 | + mlx5e_fill_sq_frag_edge(sq, wq, pi, contig_wqebbs_room); | |
| 172 | 174 | |
| 173 | 175 | if (!skip_static_post) |
| 174 | 176 | post_static_params(sq, priv_tx, fence_first_post); |
| @@ -180,29 +182,36 @@ struct tx_sync_info { · 5 unmodified lines | ||
| 180 | 182 | u64 rcd_sn; |
| 181 | 183 | s32 sync_len; |
| 182 | 184 | int nr_frags; |
| 183 | − skb_frag_t *frags[MAX_SKB_FRAGS]; | |
| 185 | + skb_frag_t frags[MAX_SKB_FRAGS]; | |
| 186 | +}; | |
| 187 | + | |
| 188 | +enum mlx5e_ktls_sync_retval { | |
| 189 | + MLX5E_KTLS_SYNC_DONE, | |
| 190 | + MLX5E_KTLS_SYNC_FAIL, | |
| 191 | + MLX5E_KTLS_SYNC_SKIP_NO_DATA, | |
| 184 | 192 | }; |
| 185 | 193 | |
| 186 | −static bool tx_sync_info_get(struct mlx5e_ktls_offload_context_tx *priv_tx, | |
| 187 | − u32 tcp_seq, struct tx_sync_info *info) | |
| 194 | +static enum mlx5e_ktls_sync_retval | |
| 195 | +tx_sync_info_get(struct mlx5e_ktls_offload_context_tx *priv_tx, | |
| 196 | + u32 tcp_seq, struct tx_sync_info *info) | |
| 188 | 197 | { |
| 189 | 198 | struct tls_offload_context_tx *tx_ctx = priv_tx->tx_ctx; |
| 199 | + enum mlx5e_ktls_sync_retval ret = MLX5E_KTLS_SYNC_DONE; | |
| 190 | 200 | struct tls_record_info *record; |
| 191 | 201 | int remaining, i = 0; |
| 192 | 202 | unsigned long flags; |
| 193 | − bool ret = true; | |
| 194 | 203 | |
| 195 | 204 | spin_lock_irqsave(&tx_ctx->lock, flags); |
| 196 | 205 | record = tls_get_record(tx_ctx, tcp_seq, &info->rcd_sn); |
| 197 | 206 | |
| 198 | 207 | if (unlikely(!record)) { |
| 199 | − ret = false; | |
| 208 | + ret = MLX5E_KTLS_SYNC_FAIL; | |
| 200 | 209 | goto out; |
| 201 | 210 | } |
| 202 | 211 | |
| 203 | 212 | if (unlikely(tcp_seq < tls_record_start_seq(record))) { |
| 204 | − if (!tls_record_is_start_marker(record)) | |
| 205 | − ret = false; | |
| 213 | + ret = tls_record_is_start_marker(record) ? | |
| 214 | + MLX5E_KTLS_SYNC_SKIP_NO_DATA : MLX5E_KTLS_SYNC_FAIL; | |
| 206 | 215 | goto out; |
| 207 | 216 | } |
| 208 | 217 | |
| @@ -211,13 +220,13 @@ static bool tx_sync_info_get(struct mlx5e_ktls_offload_context_tx *priv_tx, · 2 unmodified lines | ||
| 211 | 220 | while (remaining > 0) { |
| 212 | 221 | skb_frag_t *frag = &record->frags[i]; |
| 213 | 222 | |
| 214 | − __skb_frag_ref(frag); | |
| 223 | + get_page(skb_frag_page(frag)); | |
| 215 | 224 | remaining -= skb_frag_size(frag); |
| 216 | − info->frags[i++] = frag; | |
| 225 | + info->frags[i++] = *frag; | |
| 217 | 226 | } |
| 218 | 227 | /* reduce the part which will be sent with the original SKB */ |
| 219 | 228 | if (remaining < 0) |
| 220 | − skb_frag_size_add(info->frags[i - 1], remaining); | |
| 229 | + skb_frag_size_add(&info->frags[i - 1], remaining); | |
| 221 | 230 | info->nr_frags = i; |
| 222 | 231 | out: |
| 223 | 232 | spin_unlock_irqrestore(&tx_ctx->lock, flags); |
| @@ -229,17 +238,12 @@ tx_post_resync_params(struct mlx5e_txqsq *sq, · 5 unmodified lines | ||
| 229 | 238 | struct mlx5e_ktls_offload_context_tx *priv_tx, |
| 230 | 239 | u64 rcd_sn) |
| 231 | 240 | { |
| 232 | − struct tls_crypto_info *crypto_info = priv_tx->crypto_info; | |
| 233 | − struct tls12_crypto_info_aes_gcm_128 *info; | |
| 241 | + struct tls12_crypto_info_aes_gcm_128 *info = &priv_tx->crypto_info; | |
| 234 | 242 | __be64 rn_be = cpu_to_be64(rcd_sn); |
| 235 | 243 | bool skip_static_post; |
| 236 | 244 | u16 rec_seq_sz; |
| 237 | 245 | char *rec_seq; |
| 238 | 246 | |
| 239 | − if (WARN_ON(crypto_info->cipher_type != TLS_CIPHER_AES_GCM_128)) | |
| 240 | − return; | |
| 241 | − | |
| 242 | − info = (struct tls12_crypto_info_aes_gcm_128 *)crypto_info; | |
| 243 | 247 | rec_seq = info->rec_seq; |
| 244 | 248 | rec_seq_sz = sizeof(info->rec_seq); |
| 245 | 249 | |
| @@ -250,11 +254,6 @@ tx_post_resync_params(struct mlx5e_txqsq *sq, · 4 unmodified lines | ||
| 250 | 254 | mlx5e_ktls_tx_post_param_wqes(sq, priv_tx, skip_static_post, true); |
| 251 | 255 | } |
| 252 | 256 | |
| 253 | −struct mlx5e_dump_wqe { | |
| 254 | − struct mlx5_wqe_ctrl_seg ctrl; | |
| 255 | − struct mlx5_wqe_data_seg data; | |
| 256 | −}; | |
| 257 | − | |
| 258 | 257 | static int |
| 259 | 258 | tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool first) |
| 260 | 259 | { |
| @@ -262,7 +261,6 @@ tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool fir · 1 unmodified line | ||
| 262 | 261 | struct mlx5_wqe_data_seg *dseg; |
| 263 | 262 | struct mlx5e_dump_wqe *wqe; |
| 264 | 263 | dma_addr_t dma_addr = 0; |
| 265 | − u8 num_wqebbs; | |
| 266 | 264 | u16 ds_cnt; |
| 267 | 265 | int fsz; |
| 268 | 266 | u16 pi; |
| @@ -270,7 +268,6 @@ tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool fir · 1 unmodified line | ||
| 270 | 268 | wqe = mlx5e_sq_fetch_wqe(sq, sizeof(*wqe), &pi); |
| 271 | 269 | |
| 272 | 270 | ds_cnt = sizeof(*wqe) / MLX5_SEND_WQE_DS; |
| 273 | − num_wqebbs = DIV_ROUND_UP(ds_cnt, MLX5_SEND_WQEBB_NUM_DS); | |
| 274 | 271 | |
| 275 | 272 | cseg = &wqe->ctrl; |
| 276 | 273 | dseg = &wqe->data; |
| @@ -291,24 +288,27 @@ tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool fir · 14 unmodified lines | ||
| 291 | 288 | dseg->byte_count = cpu_to_be32(fsz); |
| 292 | 289 | mlx5e_dma_push(sq, dma_addr, fsz, MLX5E_DMA_MAP_PAGE); |
| 293 | 290 | |
| 294 | − tx_fill_wi(sq, pi, num_wqebbs, frag, fsz); | |
| 295 | − sq->pc += num_wqebbs; | |
| 296 | − | |
| 297 | − WARN(num_wqebbs > MLX5E_KTLS_MAX_DUMP_WQEBBS, | |
| 298 | − "unexpected DUMP num_wqebbs, %d > %d", | |
| 299 | − num_wqebbs, MLX5E_KTLS_MAX_DUMP_WQEBBS); | |
| 291 | + tx_fill_wi(sq, pi, MLX5E_KTLS_DUMP_WQEBBS, fsz, skb_frag_page(frag)); | |
| 292 | + sq->pc += MLX5E_KTLS_DUMP_WQEBBS; | |
| 300 | 293 | |
| 301 | 294 | return 0; |
| 302 | 295 | } |
| 303 | 296 | |
| 304 | 297 | void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq, |
| 305 | 298 | struct mlx5e_tx_wqe_info *wi, |
| 306 | − struct mlx5e_sq_dma *dma) | |
| 299 | + u32 *dma_fifo_cc) | |
| 307 | 300 | { |
| 308 | − struct mlx5e_sq_stats *stats = sq->stats; | |
| 301 | + struct mlx5e_sq_stats *stats; | |
| 302 | + struct mlx5e_sq_dma *dma; | |
| 303 | + | |
| 304 | + if (!wi->resync_dump_frag_page) | |
| 305 | + return; | |
| 306 | + | |
| 307 | + dma = mlx5e_dma_get(sq, (*dma_fifo_cc)++); | |
| 308 | + stats = sq->stats; | |
| 309 | 309 | |
| 310 | 310 | mlx5e_tx_dma_unmap(sq->pdev, dma); |
| 311 | − __skb_frag_unref(wi->resync_dump_frag); | |
| 311 | + put_page(wi->resync_dump_frag_page); | |
| 312 | 312 | stats->tls_dump_packets++; |
| 313 | 313 | stats->tls_dump_bytes += wi->num_bytes; |
| 314 | 314 | } |
| @@ -318,25 +318,31 @@ static void tx_post_fence_nop(struct mlx5e_txqsq *sq) · 3 unmodified lines | ||
| 318 | 318 | struct mlx5_wq_cyc *wq = &sq->wq; |
| 319 | 319 | u16 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); |
| 320 | 320 | |
| 321 | − tx_fill_wi(sq, pi, 1, NULL, 0); | |
| 321 | + tx_fill_wi(sq, pi, 1, 0, NULL); | |
| 322 | 322 | |
| 323 | 323 | mlx5e_post_nop_fence(wq, sq->sqn, &sq->pc); |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | −static struct sk_buff * | |
| 326 | +static enum mlx5e_ktls_sync_retval | |
| 327 | 327 | mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx, |
| 328 | 328 | struct mlx5e_txqsq *sq, |
| 329 | − struct sk_buff *skb, | |
| 329 | + int datalen, | |
| 330 | 330 | u32 seq) |
| 331 | 331 | { |
| 332 | 332 | struct mlx5e_sq_stats *stats = sq->stats; |
| 333 | 333 | struct mlx5_wq_cyc *wq = &sq->wq; |
| 334 | + enum mlx5e_ktls_sync_retval ret; | |
| 334 | 335 | struct tx_sync_info info = {}; |
| 335 | 336 | u16 contig_wqebbs_room, pi; |
| 336 | 337 | u8 num_wqebbs; |
| 337 | − int i; | |
| 338 | − | |
| 339 | − if (!tx_sync_info_get(priv_tx, seq, &info)) { | |
| 338 | + int i = 0; | |
| 339 | + | |
| 340 | + ret = tx_sync_info_get(priv_tx, seq, &info); | |
| 341 | + if (unlikely(ret != MLX5E_KTLS_SYNC_DONE)) { | |
| 342 | + if (ret == MLX5E_KTLS_SYNC_SKIP_NO_DATA) { | |
| 343 | + stats->tls_skip_no_sync_data++; | |
| 344 | + return MLX5E_KTLS_SYNC_SKIP_NO_DATA; | |
| 345 | + } | |
| 340 | 346 | /* We might get here if a retransmission reaches the driver |
| 341 | 347 | * after the relevant record is acked. |
| 342 | 348 | * It should be safe to drop the packet in this case |
| @@ -346,13 +352,8 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx, · 3 unmodified lines | ||
| 346 | 352 | } |
| 347 | 353 | |
| 348 | 354 | if (unlikely(info.sync_len < 0)) { |
| 349 | − u32 payload; | |
| 350 | − int headln; | |
| 351 | − | |
| 352 | − headln = skb_transport_offset(skb) + tcp_hdrlen(skb); | |
| 353 | − payload = skb->len - headln; | |
| 354 | − if (likely(payload <= -info.sync_len)) | |
| 355 | − return skb; | |
| 355 | + if (likely(datalen <= -info.sync_len)) | |
| 356 | + return MLX5E_KTLS_SYNC_DONE; | |
| 356 | 357 | |
| 357 | 358 | stats->tls_drop_bypass_req++; |
| 358 | 359 | goto err_out; |
| @@ -360,30 +361,62 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx, · 1 unmodified line | ||
| 360 | 361 | |
| 361 | 362 | stats->tls_ooo++; |
| 362 | 363 | |
| 363 | − num_wqebbs = MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS + | |
| 364 | − (info.nr_frags ? info.nr_frags * MLX5E_KTLS_MAX_DUMP_WQEBBS : 1); | |
| 364 | + tx_post_resync_params(sq, priv_tx, info.rcd_sn); | |
| 365 | + | |
| 366 | + /* If no dump WQE was sent, we need to have a fence NOP WQE before the | |
| 367 | + * actual data xmit. | |
| 368 | + */ | |
| 369 | + if (!info.nr_frags) { | |
| 370 | + tx_post_fence_nop(sq); | |
| 371 | + return MLX5E_KTLS_SYNC_DONE; | |
| 372 | + } | |
| 373 | + | |
| 374 | + num_wqebbs = mlx5e_ktls_dumps_num_wqebbs(sq, info.nr_frags, info.sync_len); | |
| 365 | 375 | pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); |
| 366 | 376 | contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi); |
| 377 | + | |
| 367 | 378 | if (unlikely(contig_wqebbs_room < num_wqebbs)) |
| 368 | 379 | mlx5e_fill_sq_frag_edge(sq, wq, pi, contig_wqebbs_room); |
| 369 | 380 | |
| 370 | 381 | tx_post_resync_params(sq, priv_tx, info.rcd_sn); |
| 371 | 382 | |
| 372 | − for (i = 0; i < info.nr_frags; i++) | |
| 373 | − if (tx_post_resync_dump(sq, info.frags[i], priv_tx->tisn, !i)) | |
| 374 | − goto err_out; | |
| 383 | + for (; i < info.nr_frags; i++) { | |
| 384 | + unsigned int orig_fsz, frag_offset = 0, n = 0; | |
| 385 | + skb_frag_t *f = &info.frags[i]; | |
| 375 | 386 | |
| 376 | − /* If no dump WQE was sent, we need to have a fence NOP WQE before the | |
| 377 | − * actual data xmit. | |
| 378 | − */ | |
| 379 | − if (!info.nr_frags) | |
| 380 | − tx_post_fence_nop(sq); | |
| 387 | + orig_fsz = skb_frag_size(f); | |
| 381 | 388 | |
| 382 | − return skb; | |
| 389 | + do { | |
| 390 | + bool fence = !(i || frag_offset); | |
| 391 | + unsigned int fsz; | |
| 392 | + | |
| 393 | + n++; | |
| 394 | + fsz = min_t(unsigned int, sq->hw_mtu, orig_fsz - frag_offset); | |
| 395 | + skb_frag_size_set(f, fsz); | |
| 396 | + if (tx_post_resync_dump(sq, f, priv_tx->tisn, fence)) { | |
| 397 | + page_ref_add(skb_frag_page(f), n - 1); | |
| 398 | + goto err_out; | |
| 399 | + } | |
| 400 | + | |
| 401 | + skb_frag_off_add(f, fsz); | |
| 402 | + frag_offset += fsz; | |
| 403 | + } while (frag_offset < orig_fsz); | |
| 404 | + | |
| 405 | + page_ref_add(skb_frag_page(f), n - 1); | |
| 406 | + } | |
| 407 | + | |
| 408 | + return MLX5E_KTLS_SYNC_DONE; | |
| 383 | 409 | |
| 384 | 410 | err_out: |
| 385 | − dev_kfree_skb_any(skb); | |
| 386 | − return NULL; | |
| 411 | + for (; i < info.nr_frags; i++) | |
| 412 | + /* The put_page() here undoes the page ref obtained in tx_sync_info_get(). | |
| 413 | + * Page refs obtained for the DUMP WQEs above (by page_ref_add) will be | |
| 414 | + * released only upon their completions (or in mlx5e_free_txqsq_descs, | |
| 415 | + * if channel closes). | |
| 416 | + */ | |
| 417 | + put_page(skb_frag_page(&info.frags[i])); | |
| 418 | + | |
| 419 | + return MLX5E_KTLS_SYNC_FAIL; | |
| 387 | 420 | } |
| 388 | 421 | |
| 389 | 422 | struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev, |
| @@ -419,10 +452,15 @@ struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev, · 29 unmodified lines | ||
| 419 | 452 | |
| 420 | 453 | seq = ntohl(tcp_hdr(skb)->seq); |
| 421 | 454 | if (unlikely(priv_tx->expected_seq != seq)) { |
| 422 | − skb = mlx5e_ktls_tx_handle_ooo(priv_tx, sq, skb, seq); | |
| 423 | − if (unlikely(!skb)) | |
| 455 | + enum mlx5e_ktls_sync_retval ret = | |
| 456 | + mlx5e_ktls_tx_handle_ooo(priv_tx, sq, datalen, seq); | |
| 457 | + | |
| 458 | + if (likely(ret == MLX5E_KTLS_SYNC_DONE)) | |
| 459 | + *wqe = mlx5e_sq_fetch_wqe(sq, sizeof(**wqe), pi); | |
| 460 | + else if (ret == MLX5E_KTLS_SYNC_FAIL) | |
| 461 | + goto err_out; | |
| 462 | + else /* ret == MLX5E_KTLS_SYNC_SKIP_NO_DATA */ | |
| 424 | 463 | goto out; |
| 425 | − *wqe = mlx5e_sq_fetch_wqe(sq, sizeof(**wqe), pi); | |
| 426 | 464 | } |
| 427 | 465 | |
| 428 | 466 | priv_tx->expected_seq = seq + datalen; |
| @@ -1021,7 +1021,7 @@ static bool ext_link_mode_requested(const unsigned long *adver) · 1020 unmodified lines | ||
| 1021 | 1021 | { |
| 1022 | 1022 | #define MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT ETHTOOL_LINK_MODE_50000baseKR_Full_BIT |
| 1023 | 1023 | int size = __ETHTOOL_LINK_MODE_MASK_NBITS - MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT; |
| 1024 | − __ETHTOOL_DECLARE_LINK_MODE_MASK(modes); | |
| 1024 | + __ETHTOOL_DECLARE_LINK_MODE_MASK(modes) = {0,}; | |
| 1025 | 1025 | |
| 1026 | 1026 | bitmap_set(modes, MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT, size); |
| 1027 | 1027 | return bitmap_intersects(modes, adver, __ETHTOOL_LINK_MODE_MASK_NBITS); |
| @@ -1128,6 +1128,7 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c, · 1127 unmodified lines | ||
| 1128 | 1128 | sq->txq_ix = txq_ix; |
| 1129 | 1129 | sq->uar_map = mdev->mlx5e_res.bfreg.map; |
| 1130 | 1130 | sq->min_inline_mode = params->tx_min_inline_mode; |
| 1131 | + sq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu); | |
| 1131 | 1132 | sq->stats = &c->priv->channel_stats[c->ix].sq[tc]; |
| 1132 | 1133 | sq->stop_room = MLX5E_SQ_STOP_ROOM; |
| 1133 | 1134 | INIT_WORK(&sq->recover_work, mlx5e_tx_err_cqe_work); |
| @@ -1135,10 +1136,14 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c, · 1 unmodified line | ||
| 1135 | 1136 | set_bit(MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE, &sq->state); |
| 1136 | 1137 | if (MLX5_IPSEC_DEV(c->priv->mdev)) |
| 1137 | 1138 | set_bit(MLX5E_SQ_STATE_IPSEC, &sq->state); |
| 1139 | +#ifdef CONFIG_MLX5_EN_TLS | |
| 1138 | 1140 | if (mlx5_accel_is_tls_device(c->priv->mdev)) { |
| 1139 | 1141 | set_bit(MLX5E_SQ_STATE_TLS, &sq->state); |
| 1140 | − sq->stop_room += MLX5E_SQ_TLS_ROOM; | |
| 1142 | + sq->stop_room += MLX5E_SQ_TLS_ROOM + | |
| 1143 | + mlx5e_ktls_dumps_num_wqebbs(sq, MAX_SKB_FRAGS, | |
| 1144 | + TLS_MAX_PAYLOAD_SIZE); | |
| 1141 | 1145 | } |
| 1146 | +#endif | |
| 1142 | 1147 | |
| 1143 | 1148 | param->wq.db_numa_node = cpu_to_node(c->cpu); |
| 1144 | 1149 | err = mlx5_wq_cyc_create(mdev, ¶m->wq, sqc_wq, wq, &sq->wq_ctrl); |
| @@ -1349,9 +1354,13 @@ static void mlx5e_deactivate_txqsq(struct mlx5e_txqsq *sq) · 204 unmodified lines | ||
| 1349 | 1354 | /* last doorbell out, godspeed .. */ |
| 1350 | 1355 | if (mlx5e_wqc_has_room_for(wq, sq->cc, sq->pc, 1)) { |
| 1351 | 1356 | u16 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc); |
| 1357 | + struct mlx5e_tx_wqe_info *wi; | |
| 1352 | 1358 | struct mlx5e_tx_wqe *nop; |
| 1353 | 1359 | |
| 1354 | − sq->db.wqe_info[pi].skb = NULL; | |
| 1360 | + wi = &sq->db.wqe_info[pi]; | |
| 1361 | + | |
| 1362 | + memset(wi, 0, sizeof(*wi)); | |
| 1363 | + wi->num_wqebbs = 1; | |
| 1355 | 1364 | nop = mlx5e_post_nop(wq, sq->sqn, &sq->pc); |
| 1356 | 1365 | mlx5e_notify_hw(wq, sq->pc, sq->uar_map, &nop->ctrl); |
| 1357 | 1366 | } |
| @@ -611,8 +611,8 @@ static void mlx5e_rep_update_flows(struct mlx5e_priv *priv, · 610 unmodified lines | ||
| 611 | 611 | |
| 612 | 612 | mutex_lock(&esw->offloads.encap_tbl_lock); |
| 613 | 613 | encap_connected = !!(e->flags & MLX5_ENCAP_ENTRY_VALID); |
| 614 | − if (e->compl_result || (encap_connected == neigh_connected && | |
| 615 | − ether_addr_equal(e->h_dest, ha))) | |
| 614 | + if (e->compl_result < 0 || (encap_connected == neigh_connected && | |
| 615 | + ether_addr_equal(e->h_dest, ha))) | |
| 616 | 616 | goto unlock; |
| 617 | 617 | |
| 618 | 618 | mlx5e_take_all_encap_flows(e, &flow_list); |
| @@ -1386,8 +1386,11 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget) · 1385 unmodified lines | ||
| 1386 | 1386 | if (unlikely(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state))) |
| 1387 | 1387 | return 0; |
| 1388 | 1388 | |
| 1389 | − if (rq->cqd.left) | |
| 1389 | + if (rq->cqd.left) { | |
| 1390 | 1390 | work_done += mlx5e_decompress_cqes_cont(rq, cqwq, 0, budget); |
| 1391 | + if (rq->cqd.left || work_done >= budget) | |
| 1392 | + goto out; | |
| 1393 | + } | |
| 1391 | 1394 | |
| 1392 | 1395 | cqe = mlx5_cqwq_get_cqe(cqwq); |
| 1393 | 1396 | if (!cqe) { |
| @@ -35,6 +35,7 @@ · 34 unmodified lines | ||
| 35 | 35 | #include <linux/udp.h> |
| 36 | 36 | #include <net/udp.h> |
| 37 | 37 | #include "en.h" |
| 38 | +#include "en/port.h" | |
| 38 | 39 | |
| 39 | 40 | enum { |
| 40 | 41 | MLX5E_ST_LINK_STATE, |
| @@ -80,22 +81,12 @@ static int mlx5e_test_link_state(struct mlx5e_priv *priv) · 39 unmodified lines | ||
| 80 | 81 | |
| 81 | 82 | static int mlx5e_test_link_speed(struct mlx5e_priv *priv) |
| 82 | 83 | { |
| 83 | − u32 out[MLX5_ST_SZ_DW(ptys_reg)]; | |
| 84 | − u32 eth_proto_oper; | |
| 85 | − int i; | |
| 84 | + u32 speed; | |
| 86 | 85 | |
| 87 | 86 | if (!netif_carrier_ok(priv->netdev)) |
| 88 | 87 | return 1; |
| 89 | 88 | |
| 90 | − if (mlx5_query_port_ptys(priv->mdev, out, sizeof(out), MLX5_PTYS_EN, 1)) | |
| 91 | − return 1; | |
| 92 | − | |
| 93 | − eth_proto_oper = MLX5_GET(ptys_reg, out, eth_proto_oper); | |
| 94 | − for (i = 0; i < MLX5E_LINK_MODES_NUMBER; i++) { | |
| 95 | − if (eth_proto_oper & MLX5E_PROT_MASK(i)) | |
| 96 | − return 0; | |
| 97 | − } | |
| 98 | − return 1; | |
| 89 | + return mlx5e_port_linkspeed(priv->mdev, &speed); | |
| 99 | 90 | } |
| 100 | 91 | |
| 101 | 92 | struct mlx5ehdr { |
| @@ -52,11 +52,12 @@ static const struct counter_desc sw_stats_desc[] = { · 51 unmodified lines | ||
| 52 | 52 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_encrypted_bytes) }, |
| 53 | 53 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_ctx) }, |
| 54 | 54 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_ooo) }, |
| 55 | + { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_dump_packets) }, | |
| 56 | + { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_dump_bytes) }, | |
| 55 | 57 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_resync_bytes) }, |
| 58 | + { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_skip_no_sync_data) }, | |
| 56 | 59 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_drop_no_sync_data) }, |
| 57 | 60 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_drop_bypass_req) }, |
| 58 | − { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_dump_packets) }, | |
| 59 | − { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_dump_bytes) }, | |
| 60 | 61 | #endif |
| 61 | 62 | |
| 62 | 63 | { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_lro_packets) }, |
| @@ -288,11 +289,12 @@ static void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv) · 225 unmodified lines | ||
| 288 | 289 | s->tx_tls_encrypted_bytes += sq_stats->tls_encrypted_bytes; |
| 289 | 290 | s->tx_tls_ctx += sq_stats->tls_ctx; |
| 290 | 291 | s->tx_tls_ooo += sq_stats->tls_ooo; |
| 292 | + s->tx_tls_dump_bytes += sq_stats->tls_dump_bytes; | |
| 293 | + s->tx_tls_dump_packets += sq_stats->tls_dump_packets; | |
| 291 | 294 | s->tx_tls_resync_bytes += sq_stats->tls_resync_bytes; |
| 295 | + s->tx_tls_skip_no_sync_data += sq_stats->tls_skip_no_sync_data; | |
| 292 | 296 | s->tx_tls_drop_no_sync_data += sq_stats->tls_drop_no_sync_data; |
| 293 | 297 | s->tx_tls_drop_bypass_req += sq_stats->tls_drop_bypass_req; |
| 294 | − s->tx_tls_dump_bytes += sq_stats->tls_dump_bytes; | |
| 295 | − s->tx_tls_dump_packets += sq_stats->tls_dump_packets; | |
| 296 | 298 | #endif |
| 297 | 299 | s->tx_cqes += sq_stats->cqes; |
| 298 | 300 | } |
| @@ -1472,10 +1474,12 @@ static const struct counter_desc sq_stats_desc[] = { · 1173 unmodified lines | ||
| 1472 | 1474 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_encrypted_bytes) }, |
| 1473 | 1475 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_ctx) }, |
| 1474 | 1476 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_ooo) }, |
| 1475 | − { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_drop_no_sync_data) }, | |
| 1476 | − { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_drop_bypass_req) }, | |
| 1477 | 1477 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_dump_packets) }, |
| 1478 | 1478 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_dump_bytes) }, |
| 1479 | + { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_resync_bytes) }, | |
| 1480 | + { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_skip_no_sync_data) }, | |
| 1481 | + { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_drop_no_sync_data) }, | |
| 1482 | + { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_drop_bypass_req) }, | |
| 1479 | 1483 | #endif |
| 1480 | 1484 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_none) }, |
| 1481 | 1485 | { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, stopped) }, |
| @@ -129,11 +129,12 @@ struct mlx5e_sw_stats { · 128 unmodified lines | ||
| 129 | 129 | u64 tx_tls_encrypted_bytes; |
| 130 | 130 | u64 tx_tls_ctx; |
| 131 | 131 | u64 tx_tls_ooo; |
| 132 | + u64 tx_tls_dump_packets; | |
| 133 | + u64 tx_tls_dump_bytes; | |
| 132 | 134 | u64 tx_tls_resync_bytes; |
| 135 | + u64 tx_tls_skip_no_sync_data; | |
| 133 | 136 | u64 tx_tls_drop_no_sync_data; |
| 134 | 137 | u64 tx_tls_drop_bypass_req; |
| 135 | − u64 tx_tls_dump_packets; | |
| 136 | − u64 tx_tls_dump_bytes; | |
| 137 | 138 | #endif |
| 138 | 139 | |
| 139 | 140 | u64 rx_xsk_packets; |
| @@ -273,11 +274,12 @@ struct mlx5e_sq_stats { · 133 unmodified lines | ||
| 273 | 274 | u64 tls_encrypted_bytes; |
| 274 | 275 | u64 tls_ctx; |
| 275 | 276 | u64 tls_ooo; |
| 277 | + u64 tls_dump_packets; | |
| 278 | + u64 tls_dump_bytes; | |
| 276 | 279 | u64 tls_resync_bytes; |
| 280 | + u64 tls_skip_no_sync_data; | |
| 277 | 281 | u64 tls_drop_no_sync_data; |
| 278 | 282 | u64 tls_drop_bypass_req; |
| 279 | − u64 tls_dump_packets; | |
| 280 | − u64 tls_dump_bytes; | |
| 281 | 283 | #endif |
| 282 | 284 | /* less likely accessed in data path */ |
| 283 | 285 | u64 csum_none; |
| @@ -1278,8 +1278,10 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, · 1277 unmodified lines | ||
| 1278 | 1278 | mlx5_eswitch_del_vlan_action(esw, attr); |
| 1279 | 1279 | |
| 1280 | 1280 | for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) |
| 1281 | − if (attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP) | |
| 1281 | + if (attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP) { | |
| 1282 | 1282 | mlx5e_detach_encap(priv, flow, out_index); |
| 1283 | + kfree(attr->parse_attr->tun_info[out_index]); | |
| 1284 | + } | |
| 1283 | 1285 | kvfree(attr->parse_attr); |
| 1284 | 1286 | |
| 1285 | 1287 | if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) |
| @@ -1559,6 +1561,7 @@ static void mlx5e_encap_dealloc(struct mlx5e_priv *priv, struct mlx5e_encap_entr · 273 unmodified lines | ||
| 1559 | 1561 | mlx5_packet_reformat_dealloc(priv->mdev, e->pkt_reformat); |
| 1560 | 1562 | } |
| 1561 | 1563 | |
| 1564 | + kfree(e->tun_info); | |
| 1562 | 1565 | kfree(e->encap_header); |
| 1563 | 1566 | kfree_rcu(e, rcu); |
| 1564 | 1567 | } |
| @@ -2972,6 +2975,13 @@ mlx5e_encap_get(struct mlx5e_priv *priv, struct encap_key *key, · 1407 unmodified lines | ||
| 2972 | 2975 | return NULL; |
| 2973 | 2976 | } |
| 2974 | 2977 | |
| 2978 | +static struct ip_tunnel_info *dup_tun_info(const struct ip_tunnel_info *tun_info) | |
| 2979 | +{ | |
| 2980 | + size_t tun_size = sizeof(*tun_info) + tun_info->options_len; | |
| 2981 | + | |
| 2982 | + return kmemdup(tun_info, tun_size, GFP_KERNEL); | |
| 2983 | +} | |
| 2984 | + | |
| 2975 | 2985 | static int mlx5e_attach_encap(struct mlx5e_priv *priv, |
| 2976 | 2986 | struct mlx5e_tc_flow *flow, |
| 2977 | 2987 | struct net_device *mirred_dev, |
| @@ -3028,13 +3038,15 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv, · 50 unmodified lines | ||
| 3028 | 3038 | refcount_set(&e->refcnt, 1); |
| 3029 | 3039 | init_completion(&e->res_ready); |
| 3030 | 3040 | |
| 3041 | + tun_info = dup_tun_info(tun_info); | |
| 3042 | + if (!tun_info) { | |
| 3043 | + err = -ENOMEM; | |
| 3044 | + goto out_err_init; | |
| 3045 | + } | |
| 3031 | 3046 | e->tun_info = tun_info; |
| 3032 | 3047 | err = mlx5e_tc_tun_init_encap_attr(mirred_dev, priv, e, extack); |
| 3033 | − if (err) { | |
| 3034 | − kfree(e); | |
| 3035 | − e = NULL; | |
| 3036 | − goto out_err; | |
| 3037 | − } | |
| 3048 | + if (err) | |
| 3049 | + goto out_err_init; | |
| 3038 | 3050 | |
| 3039 | 3051 | INIT_LIST_HEAD(&e->flows); |
| 3040 | 3052 | hash_add_rcu(esw->offloads.encap_tbl, &e->encap_hlist, hash_key); |
| @@ -3075,6 +3087,12 @@ out_err: · 34 unmodified lines | ||
| 3075 | 3087 | if (e) |
| 3076 | 3088 | mlx5e_encap_put(priv, e); |
| 3077 | 3089 | return err; |
| 3090 | + | |
| 3091 | +out_err_init: | |
| 3092 | + mutex_unlock(&esw->offloads.encap_tbl_lock); | |
| 3093 | + kfree(tun_info); | |
| 3094 | + kfree(e); | |
| 3095 | + return err; | |
| 3078 | 3096 | } |
| 3079 | 3097 | |
| 3080 | 3098 | static int parse_tc_vlan_action(struct mlx5e_priv *priv, |
| @@ -3160,7 +3178,7 @@ static int add_vlan_pop_action(struct mlx5e_priv *priv, · 79 unmodified lines | ||
| 3160 | 3178 | struct mlx5_esw_flow_attr *attr, |
| 3161 | 3179 | u32 *action) |
| 3162 | 3180 | { |
| 3163 | − int nest_level = vlan_get_encap_level(attr->parse_attr->filter_dev); | |
| 3181 | + int nest_level = attr->parse_attr->filter_dev->lower_level; | |
| 3164 | 3182 | struct flow_action_entry vlan_act = { |
| 3165 | 3183 | .id = FLOW_ACTION_VLAN_POP, |
| 3166 | 3184 | }; |
| @@ -3295,7 +3313,9 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, · 128 unmodified lines | ||
| 3295 | 3313 | } else if (encap) { |
| 3296 | 3314 | parse_attr->mirred_ifindex[attr->out_count] = |
| 3297 | 3315 | out_dev->ifindex; |
| 3298 | − parse_attr->tun_info[attr->out_count] = info; | |
| 3316 | + parse_attr->tun_info[attr->out_count] = dup_tun_info(info); | |
| 3317 | + if (!parse_attr->tun_info[attr->out_count]) | |
| 3318 | + return -ENOMEM; | |
| 3299 | 3319 | encap = false; |
| 3300 | 3320 | attr->dests[attr->out_count].flags |= |
| 3301 | 3321 | MLX5_ESW_DEST_ENCAP; |
| @@ -403,7 +403,10 @@ netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev) · 402 unmodified lines | ||
| 403 | 403 | static void mlx5e_dump_error_cqe(struct mlx5e_txqsq *sq, |
| 404 | 404 | struct mlx5_err_cqe *err_cqe) |
| 405 | 405 | { |
| 406 | − u32 ci = mlx5_cqwq_get_ci(&sq->cq.wq); | |
| 406 | + struct mlx5_cqwq *wq = &sq->cq.wq; | |
| 407 | + u32 ci; | |
| 408 | + | |
| 409 | + ci = mlx5_cqwq_ctr2ix(wq, wq->cc - 1); | |
| 407 | 410 | |
| 408 | 411 | netdev_err(sq->channel->netdev, |
| 409 | 412 | "Error cqe on cqn 0x%x, ci 0x%x, sqn 0x%x, opcode 0x%x, syndrome 0x%x, vendor syndrome 0x%x\n", |
| @@ -479,14 +482,7 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget) · 69 unmodified lines | ||
| 479 | 482 | skb = wi->skb; |
| 480 | 483 | |
| 481 | 484 | if (unlikely(!skb)) { |
| 482 | −#ifdef CONFIG_MLX5_EN_TLS | |
| 483 | − if (wi->resync_dump_frag) { | |
| 484 | − struct mlx5e_sq_dma *dma = | |
| 485 | − mlx5e_dma_get(sq, dma_fifo_cc++); | |
| 486 | − | |
| 487 | − mlx5e_ktls_tx_handle_resync_dump_comp(sq, wi, dma); | |
| 488 | − } | |
| 489 | −#endif | |
| 485 | + mlx5e_ktls_tx_handle_resync_dump_comp(sq, wi, &dma_fifo_cc); | |
| 490 | 486 | sqcc += wi->num_wqebbs; |
| 491 | 487 | continue; |
| 492 | 488 | } |
| @@ -542,29 +538,38 @@ void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq) · 49 unmodified lines | ||
| 542 | 538 | { |
| 543 | 539 | struct mlx5e_tx_wqe_info *wi; |
| 544 | 540 | struct sk_buff *skb; |
| 541 | + u32 dma_fifo_cc; | |
| 542 | + u16 sqcc; | |
| 545 | 543 | u16 ci; |
| 546 | 544 | int i; |
| 547 | 545 | |
| 548 | − while (sq->cc != sq->pc) { | |
| 549 | − ci = mlx5_wq_cyc_ctr2ix(&sq->wq, sq->cc); | |
| 546 | + sqcc = sq->cc; | |
| 547 | + dma_fifo_cc = sq->dma_fifo_cc; | |
| 548 | + | |
| 549 | + while (sqcc != sq->pc) { | |
| 550 | + ci = mlx5_wq_cyc_ctr2ix(&sq->wq, sqcc); | |
| 550 | 551 | wi = &sq->db.wqe_info[ci]; |
| 551 | 552 | skb = wi->skb; |
| 552 | 553 | |
| 553 | − if (!skb) { /* nop */ | |
| 554 | − sq->cc++; | |
| 554 | + if (!skb) { | |
| 555 | + mlx5e_ktls_tx_handle_resync_dump_comp(sq, wi, &dma_fifo_cc); | |
| 556 | + sqcc += wi->num_wqebbs; | |
| 555 | 557 | continue; |
| 556 | 558 | } |
| 557 | 559 | |
| 558 | 560 | for (i = 0; i < wi->num_dma; i++) { |
| 559 | 561 | struct mlx5e_sq_dma *dma = |
| 560 | − mlx5e_dma_get(sq, sq->dma_fifo_cc++); | |
| 562 | + mlx5e_dma_get(sq, dma_fifo_cc++); | |
| 561 | 563 | |
| 562 | 564 | mlx5e_tx_dma_unmap(sq->pdev, dma); |
| 563 | 565 | } |
| 564 | 566 | |
| 565 | 567 | dev_kfree_skb_any(skb); |
| 566 | − sq->cc += wi->num_wqebbs; | |
| 568 | + sqcc += wi->num_wqebbs; | |
| 567 | 569 | } |
| 570 | + | |
| 571 | + sq->dma_fifo_cc = dma_fifo_cc; | |
| 572 | + sq->cc = sqcc; | |
| 568 | 573 | } |
| 569 | 574 | |
| 570 | 575 | #ifdef CONFIG_MLX5_CORE_IPOIB |
| @@ -285,7 +285,6 @@ mlx5_eswitch_add_fwd_rule(struct mlx5_eswitch *esw, · 284 unmodified lines | ||
| 285 | 285 | |
| 286 | 286 | mlx5_eswitch_set_rule_source_port(esw, spec, attr); |
| 287 | 287 | |
| 288 | − spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS; | |
| 289 | 288 | if (attr->outer_match_level != MLX5_MATCH_NONE) |
| 290 | 289 | spec->match_criteria_enable |= MLX5_MATCH_OUTER_HEADERS; |
| 291 | 290 | |
| @@ -1080,7 +1079,7 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw, int nvports) · 788 unmodified lines | ||
| 1080 | 1079 | MLX5_CAP_GEN(dev, max_flow_counter_15_0); |
| 1081 | 1080 | fdb_max = 1 << MLX5_CAP_ESW_FLOWTABLE_FDB(dev, log_max_ft_size); |
| 1082 | 1081 | |
| 1083 | − esw_debug(dev, "Create offloads FDB table, min (max esw size(2^%d), max counters(%d), groups(%d), max flow table size(2^%d))\n", | |
| 1082 | + esw_debug(dev, "Create offloads FDB table, min (max esw size(2^%d), max counters(%d), groups(%d), max flow table size(%d))\n", | |
| 1084 | 1083 | MLX5_CAP_ESW_FLOWTABLE_FDB(dev, log_max_ft_size), |
| 1085 | 1084 | max_flow_counter, ESW_OFFLOADS_NUM_GROUPS, |
| 1086 | 1085 | fdb_max); |
| @@ -177,22 +177,33 @@ mlx5_eswitch_termtbl_actions_move(struct mlx5_flow_act *src, · 176 unmodified lines | ||
| 177 | 177 | memset(&src->vlan[1], 0, sizeof(src->vlan[1])); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | +static bool mlx5_eswitch_offload_is_uplink_port(const struct mlx5_eswitch *esw, | |
| 181 | + const struct mlx5_flow_spec *spec) | |
| 182 | +{ | |
| 183 | + u32 port_mask, port_value; | |
| 184 | + | |
| 185 | + if (MLX5_CAP_ESW_FLOWTABLE(esw->dev, flow_source)) | |
| 186 | + return spec->flow_context.flow_source == | |
| 187 | + MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK; | |
| 188 | + | |
| 189 | + port_mask = MLX5_GET(fte_match_param, spec->match_criteria, | |
| 190 | + misc_parameters.source_port); | |
| 191 | + port_value = MLX5_GET(fte_match_param, spec->match_value, | |
| 192 | + misc_parameters.source_port); | |
| 193 | + return (port_mask & port_value & 0xffff) == MLX5_VPORT_UPLINK; | |
| 194 | +} | |
| 195 | + | |
| 180 | 196 | bool |
| 181 | 197 | mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw, |
| 182 | 198 | struct mlx5_flow_act *flow_act, |
| 183 | 199 | struct mlx5_flow_spec *spec) |
| 184 | 200 | { |
| 185 | − u32 port_mask = MLX5_GET(fte_match_param, spec->match_criteria, | |
| 186 | − misc_parameters.source_port); | |
| 187 | − u32 port_value = MLX5_GET(fte_match_param, spec->match_value, | |
| 188 | − misc_parameters.source_port); | |
| 189 | − | |
| 190 | 201 | if (!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, termination_table)) |
| 191 | 202 | return false; |
| 192 | 203 | |
| 193 | 204 | /* push vlan on RX */ |
| 194 | 205 | return (flow_act->action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH) && |
| 195 | − ((port_mask & port_value) == MLX5_VPORT_UPLINK); | |
| 206 | + mlx5_eswitch_offload_is_uplink_port(esw, spec); | |
| 196 | 207 | } |
| 197 | 208 | |
| 198 | 209 | struct mlx5_flow_handle * |
| @@ -464,8 +464,10 @@ static int mlx5_fpga_conn_create_cq(struct mlx5_fpga_conn *conn, int cq_size) · 463 unmodified lines | ||
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | err = mlx5_vector2eqn(mdev, smp_processor_id(), &eqn, &irqn); |
| 467 | − if (err) | |
| 467 | + if (err) { | |
| 468 | + kvfree(in); | |
| 468 | 469 | goto err_cqwq; |
| 470 | + } | |
| 469 | 471 | |
| 470 | 472 | cqc = MLX5_ADDR_OF(create_cq_in, in, cq_context); |
| 471 | 473 | MLX5_SET(cqc, cqc, log_cq_size, ilog2(cq_size)); |
| @@ -507,7 +507,8 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, · 506 unmodified lines | ||
| 507 | 507 | MLX5_SET(dest_format_struct, in_dests, |
| 508 | 508 | destination_eswitch_owner_vhca_id, |
| 509 | 509 | dst->dest_attr.vport.vhca_id); |
| 510 | − if (extended_dest) { | |
| 510 | + if (extended_dest && | |
| 511 | + dst->dest_attr.vport.pkt_reformat) { | |
| 511 | 512 | MLX5_SET(dest_format_struct, in_dests, |
| 512 | 513 | packet_reformat, |
| 513 | 514 | !!(dst->dest_attr.vport.flags & |
| @@ -572,7 +572,7 @@ mlx5_fw_fatal_reporter_dump(struct devlink_health_reporter *reporter, · 571 unmodified lines | ||
| 572 | 572 | return -ENOMEM; |
| 573 | 573 | err = mlx5_crdump_collect(dev, cr_data); |
| 574 | 574 | if (err) |
| 575 | − return err; | |
| 575 | + goto free_data; | |
| 576 | 576 | |
| 577 | 577 | if (priv_ctx) { |
| 578 | 578 | struct mlx5_fw_reporter_ctx *fw_reporter_ctx = priv_ctx; |
| @@ -1577,6 +1577,7 @@ int mlx5dr_action_destroy(struct mlx5dr_action *action) · 1576 unmodified lines | ||
| 1577 | 1577 | break; |
| 1578 | 1578 | case DR_ACTION_TYP_MODIFY_HDR: |
| 1579 | 1579 | mlx5dr_icm_free_chunk(action->rewrite.chunk); |
| 1580 | + kfree(action->rewrite.data); | |
| 1580 | 1581 | refcount_dec(&action->rewrite.dmn->refcount); |
| 1581 | 1582 | break; |
| 1582 | 1583 | default: |
| @@ -1096,6 +1096,8 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule, · 1095 unmodified lines | ||
| 1096 | 1096 | if (htbl) |
| 1097 | 1097 | mlx5dr_htbl_put(htbl); |
| 1098 | 1098 | |
| 1099 | + kfree(hw_ste_arr); | |
| 1100 | + | |
| 1099 | 1101 | return 0; |
| 1100 | 1102 | |
| 1101 | 1103 | free_ste: |
| @@ -1186,7 +1186,7 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, · 1185 unmodified lines | ||
| 1186 | 1186 | if (err) |
| 1187 | 1187 | goto err_thermal_init; |
| 1188 | 1188 | |
| 1189 | − if (mlxsw_driver->params_register && !reload) | |
| 1189 | + if (mlxsw_driver->params_register) | |
| 1190 | 1190 | devlink_params_publish(devlink); |
| 1191 | 1191 | |
| 1192 | 1192 | return 0; |
| @@ -1259,7 +1259,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, · 66 unmodified lines | ||
| 1259 | 1259 | return; |
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | − if (mlxsw_core->driver->params_unregister && !reload) | |
| 1262 | + if (mlxsw_core->driver->params_unregister) | |
| 1263 | 1263 | devlink_params_unpublish(devlink); |
| 1264 | 1264 | mlxsw_thermal_fini(mlxsw_core->thermal); |
| 1265 | 1265 | mlxsw_hwmon_fini(mlxsw_core->hwmon); |
| @@ -261,8 +261,15 @@ static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid, · 260 unmodified lines | ||
| 261 | 261 | port->pvid = vid; |
| 262 | 262 | |
| 263 | 263 | /* Untagged egress vlan clasification */ |
| 264 | − if (untagged) | |
| 264 | + if (untagged && port->vid != vid) { | |
| 265 | + if (port->vid) { | |
| 266 | + dev_err(ocelot->dev, | |
| 267 | + "Port already has a native VLAN: %d\n", | |
| 268 | + port->vid); | |
| 269 | + return -EBUSY; | |
| 270 | + } | |
| 265 | 271 | port->vid = vid; |
| 272 | + } | |
| 266 | 273 | |
| 267 | 274 | ocelot_vlan_port_apply(ocelot, port); |
| 268 | 275 | |
| @@ -934,7 +941,7 @@ end: · 665 unmodified lines | ||
| 934 | 941 | static int ocelot_vlan_rx_add_vid(struct net_device *dev, __be16 proto, |
| 935 | 942 | u16 vid) |
| 936 | 943 | { |
| 937 | − return ocelot_vlan_vid_add(dev, vid, false, true); | |
| 944 | + return ocelot_vlan_vid_add(dev, vid, false, false); | |
| 938 | 945 | } |
| 939 | 946 | |
| 940 | 947 | static int ocelot_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, |
| @@ -1673,9 +1680,6 @@ static int ocelot_netdevice_port_event(struct net_device *dev, · 732 unmodified lines | ||
| 1673 | 1680 | struct ocelot_port *ocelot_port = netdev_priv(dev); |
| 1674 | 1681 | int err = 0; |
| 1675 | 1682 | |
| 1676 | − if (!ocelot_netdevice_dev_check(dev)) | |
| 1677 | − return 0; | |
| 1678 | − | |
| 1679 | 1683 | switch (event) { |
| 1680 | 1684 | case NETDEV_CHANGEUPPER: |
| 1681 | 1685 | if (netif_is_bridge_master(info->upper_dev)) { |
| @@ -1712,12 +1716,16 @@ static int ocelot_netdevice_event(struct notifier_block *unused, · 30 unmodified lines | ||
| 1712 | 1716 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); |
| 1713 | 1717 | int ret = 0; |
| 1714 | 1718 | |
| 1719 | + if (!ocelot_netdevice_dev_check(dev)) | |
| 1720 | + return 0; | |
| 1721 | + | |
| 1715 | 1722 | if (event == NETDEV_PRECHANGEUPPER && |
| 1716 | 1723 | netif_is_lag_master(info->upper_dev)) { |
| 1717 | 1724 | struct netdev_lag_upper_info *lag_upper_info = info->upper_info; |
| 1718 | 1725 | struct netlink_ext_ack *extack; |
| 1719 | 1726 | |
| 1720 | − if (lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) { | |
| 1727 | + if (lag_upper_info && | |
| 1728 | + lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) { | |
| 1721 | 1729 | extack = netdev_notifier_info_to_extack(&info->info); |
| 1722 | 1730 | NL_SET_ERR_MSG_MOD(extack, "LAG device using unsupported Tx type"); |
| 1723 | 1731 | |
| @@ -523,7 +523,7 @@ void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset); · 522 unmodified lines | ||
| 523 | 523 | #define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri)) |
| 524 | 524 | #define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0) |
| 525 | 525 | |
| 526 | −void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 mask, | |
| 526 | +void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg, | |
| 527 | 527 | u32 offset); |
| 528 | 528 | #define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) |
| 529 | 529 | #define ocelot_rmw_gix(ocelot, val, m, reg, gi) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi)) |
| @@ -299,22 +299,6 @@ static void nfp_repr_clean(struct nfp_repr *repr) · 298 unmodified lines | ||
| 299 | 299 | nfp_port_free(repr->port); |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | −static struct lock_class_key nfp_repr_netdev_xmit_lock_key; | |
| 303 | −static struct lock_class_key nfp_repr_netdev_addr_lock_key; | |
| 304 | − | |
| 305 | −static void nfp_repr_set_lockdep_class_one(struct net_device *dev, | |
| 306 | − struct netdev_queue *txq, | |
| 307 | − void *_unused) | |
| 308 | −{ | |
| 309 | − lockdep_set_class(&txq->_xmit_lock, &nfp_repr_netdev_xmit_lock_key); | |
| 310 | −} | |
| 311 | − | |
| 312 | −static void nfp_repr_set_lockdep_class(struct net_device *dev) | |
| 313 | −{ | |
| 314 | − lockdep_set_class(&dev->addr_list_lock, &nfp_repr_netdev_addr_lock_key); | |
| 315 | − netdev_for_each_tx_queue(dev, nfp_repr_set_lockdep_class_one, NULL); | |
| 316 | −} | |
| 317 | − | |
| 318 | 302 | int nfp_repr_init(struct nfp_app *app, struct net_device *netdev, |
| 319 | 303 | u32 cmsg_port_id, struct nfp_port *port, |
| 320 | 304 | struct net_device *pf_netdev) |
| @@ -324,8 +308,6 @@ int nfp_repr_init(struct nfp_app *app, struct net_device *netdev, · 3 unmodified lines | ||
| 324 | 308 | u32 repr_cap = nn->tlv_caps.repr_cap; |
| 325 | 309 | int err; |
| 326 | 310 | |
| 327 | − nfp_repr_set_lockdep_class(netdev); | |
| 328 | − | |
| 329 | 311 | repr->port = port; |
| 330 | 312 | repr->dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX, GFP_KERNEL); |
| 331 | 313 | if (!repr->dst) |
| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* Copyright(c) 2017 - 2019 Pensando Systems, Inc */ |
| 3 | 3 | |
| 4 | +#include <linux/printk.h> | |
| 5 | +#include <linux/dynamic_debug.h> | |
| 4 | 6 | #include <linux/netdevice.h> |
| 5 | 7 | #include <linux/etherdevice.h> |
| 6 | 8 | #include <linux/rtnetlink.h> |
| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* Copyright(c) 2017 - 2019 Pensando Systems, Inc */ |
| 3 | 3 | |
| 4 | +#include <linux/printk.h> | |
| 5 | +#include <linux/dynamic_debug.h> | |
| 4 | 6 | #include <linux/module.h> |
| 5 | 7 | #include <linux/netdevice.h> |
| 6 | 8 | #include <linux/utsname.h> |
| @@ -67,10 +67,9 @@ · 66 unmodified lines | ||
| 67 | 67 | #define QED_ROCE_QPS (8192) |
| 68 | 68 | #define QED_ROCE_DPIS (8) |
| 69 | 69 | #define QED_RDMA_SRQS QED_ROCE_QPS |
| 70 | −#define QED_NVM_CFG_SET_FLAGS 0xE | |
| 71 | −#define QED_NVM_CFG_SET_PF_FLAGS 0x1E | |
| 72 | 70 | #define QED_NVM_CFG_GET_FLAGS 0xA |
| 73 | 71 | #define QED_NVM_CFG_GET_PF_FLAGS 0x1A |
| 72 | +#define QED_NVM_CFG_MAX_ATTRS 50 | |
| 74 | 73 | |
| 75 | 74 | static char version[] = |
| 76 | 75 | "QLogic FastLinQ 4xxxx Core Module qed " DRV_MODULE_VERSION "\n"; |
| @@ -2255,6 +2254,7 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data) · 2178 unmodified lines | ||
| 2255 | 2254 | { |
| 2256 | 2255 | struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); |
| 2257 | 2256 | u8 entity_id, len, buf[32]; |
| 2257 | + bool need_nvm_init = true; | |
| 2258 | 2258 | struct qed_ptt *ptt; |
| 2259 | 2259 | u16 cfg_id, count; |
| 2260 | 2260 | int rc = 0, i; |
| @@ -2271,8 +2271,10 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data) · 10 unmodified lines | ||
| 2271 | 2271 | |
| 2272 | 2272 | DP_VERBOSE(cdev, NETIF_MSG_DRV, |
| 2273 | 2273 | "Read config ids: num_attrs = %0d\n", count); |
| 2274 | − /* NVM CFG ID attributes */ | |
| 2275 | − for (i = 0; i < count; i++) { | |
| 2274 | + /* NVM CFG ID attributes. Start loop index from 1 to avoid additional | |
| 2275 | + * arithmetic operations in the implementation. | |
| 2276 | + */ | |
| 2277 | + for (i = 1; i <= count; i++) { | |
| 2276 | 2278 | cfg_id = *((u16 *)*data); |
| 2277 | 2279 | *data += 2; |
| 2278 | 2280 | entity_id = **data; |
| @@ -2282,8 +2284,21 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data) · 3 unmodified lines | ||
| 2282 | 2284 | memcpy(buf, *data, len); |
| 2283 | 2285 | *data += len; |
| 2284 | 2286 | |
| 2285 | − flags = entity_id ? QED_NVM_CFG_SET_PF_FLAGS : | |
| 2286 | − QED_NVM_CFG_SET_FLAGS; | |
| 2287 | + flags = 0; | |
| 2288 | + if (need_nvm_init) { | |
| 2289 | + flags |= QED_NVM_CFG_OPTION_INIT; | |
| 2290 | + need_nvm_init = false; | |
| 2291 | + } | |
| 2292 | + | |
| 2293 | + /* Commit to flash and free the resources */ | |
| 2294 | + if (!(i % QED_NVM_CFG_MAX_ATTRS) || i == count) { | |
| 2295 | + flags |= QED_NVM_CFG_OPTION_COMMIT | | |
| 2296 | + QED_NVM_CFG_OPTION_FREE; | |
| 2297 | + need_nvm_init = true; | |
| 2298 | + } | |
| 2299 | + | |
| 2300 | + if (entity_id) | |
| 2301 | + flags |= QED_NVM_CFG_OPTION_ENTITY_SEL; | |
| 2287 | 2302 | |
| 2288 | 2303 | DP_VERBOSE(cdev, NETIF_MSG_DRV, |
| 2289 | 2304 | "cfg_id = %d entity = %d len = %d\n", cfg_id, |
| @@ -2005,7 +2005,7 @@ static void qed_iov_vf_mbx_stop_vport(struct qed_hwfn *p_hwfn, · 2004 unmodified lines | ||
| 2005 | 2005 | (qed_iov_validate_active_txq(p_hwfn, vf))) { |
| 2006 | 2006 | vf->b_malicious = true; |
| 2007 | 2007 | DP_NOTICE(p_hwfn, |
| 2008 | − "VF [%02x] - considered malicious; Unable to stop RX/TX queuess\n", | |
| 2008 | + "VF [%02x] - considered malicious; Unable to stop RX/TX queues\n", | |
| 2009 | 2009 | vf->abs_vf_id); |
| 2010 | 2010 | status = PFVF_STATUS_MALICIOUS; |
| 2011 | 2011 | goto out; |
| @@ -1208,8 +1208,16 @@ enum qede_remove_mode { · 1207 unmodified lines | ||
| 1208 | 1208 | static void __qede_remove(struct pci_dev *pdev, enum qede_remove_mode mode) |
| 1209 | 1209 | { |
| 1210 | 1210 | struct net_device *ndev = pci_get_drvdata(pdev); |
| 1211 | − struct qede_dev *edev = netdev_priv(ndev); | |
| 1212 | − struct qed_dev *cdev = edev->cdev; | |
| 1211 | + struct qede_dev *edev; | |
| 1212 | + struct qed_dev *cdev; | |
| 1213 | + | |
| 1214 | + if (!ndev) { | |
| 1215 | + dev_info(&pdev->dev, "Device has already been removed\n"); | |
| 1216 | + return; | |
| 1217 | + } | |
| 1218 | + | |
| 1219 | + edev = netdev_priv(ndev); | |
| 1220 | + cdev = edev->cdev; | |
| 1213 | 1221 | |
| 1214 | 1222 | DP_INFO(edev, "Starting qede_remove\n"); |
| 1215 | 1223 | |
| @@ -57,10 +57,10 @@ static int rmnet_unregister_real_device(struct net_device *real_dev, · 56 unmodified lines | ||
| 57 | 57 | if (port->nr_rmnet_devs) |
| 58 | 58 | return -EINVAL; |
| 59 | 59 | |
| 60 | − kfree(port); | |
| 61 | − | |
| 62 | 60 | netdev_rx_handler_unregister(real_dev); |
| 63 | 61 | |
| 62 | + kfree(port); | |
| 63 | + | |
| 64 | 64 | /* release reference on real_dev */ |
| 65 | 65 | dev_put(real_dev); |
| 66 | 66 | |
| @@ -916,6 +916,9 @@ static void r8168g_mdio_write(struct rtl8169_private *tp, int reg, int value) · 915 unmodified lines | ||
| 916 | 916 | |
| 917 | 917 | static int r8168g_mdio_read(struct rtl8169_private *tp, int reg) |
| 918 | 918 | { |
| 919 | + if (reg == 0x1f) | |
| 920 | + return tp->ocp_base == OCP_STD_PHY_BASE ? 0 : tp->ocp_base >> 4; | |
| 921 | + | |
| 919 | 922 | if (tp->ocp_base != OCP_STD_PHY_BASE) |
| 920 | 923 | reg -= 0x10; |
| 921 | 924 | |
| @@ -1029,6 +1032,10 @@ static int r8168dp_2_mdio_read(struct rtl8169_private *tp, int reg) · 107 unmodified lines | ||
| 1029 | 1032 | { |
| 1030 | 1033 | int value; |
| 1031 | 1034 | |
| 1035 | + /* Work around issue with chip reporting wrong PHY ID */ | |
| 1036 | + if (reg == MII_PHYSID2) | |
| 1037 | + return 0xc912; | |
| 1038 | + | |
| 1032 | 1039 | r8168dp_2_mdio_start(tp); |
| 1033 | 1040 | |
| 1034 | 1041 | value = r8169_mdio_read(tp, reg); |
| @@ -432,7 +432,7 @@ static void dwmac4_set_filter(struct mac_device_info *hw, · 431 unmodified lines | ||
| 432 | 432 | * bits used depends on the hardware configuration |
| 433 | 433 | * selected at core configuration time. |
| 434 | 434 | */ |
| 435 | − int bit_nr = bitrev32(~crc32_le(~0, ha->addr, | |
| 435 | + u32 bit_nr = bitrev32(~crc32_le(~0, ha->addr, | |
| 436 | 436 | ETH_ALEN)) >> (32 - mcbitslog2); |
| 437 | 437 | /* The most significant bit determines the register to |
| 438 | 438 | * use (H/L) while the other 5 bits determine the bit |
| @@ -224,6 +224,7 @@ static void dwxgmac2_config_cbs(struct mac_device_info *hw, · 223 unmodified lines | ||
| 224 | 224 | writel(low_credit, ioaddr + XGMAC_MTL_TCx_LOCREDIT(queue)); |
| 225 | 225 | |
| 226 | 226 | value = readl(ioaddr + XGMAC_MTL_TCx_ETS_CONTROL(queue)); |
| 227 | + value &= ~XGMAC_TSA; | |
| 227 | 228 | value |= XGMAC_CC | XGMAC_CBS; |
| 228 | 229 | writel(value, ioaddr + XGMAC_MTL_TCx_ETS_CONTROL(queue)); |
| 229 | 230 | } |
| @@ -463,7 +464,7 @@ static void dwxgmac2_set_filter(struct mac_device_info *hw, · 233 unmodified lines | ||
| 463 | 464 | value |= XGMAC_FILTER_HMC; |
| 464 | 465 | |
| 465 | 466 | netdev_for_each_mc_addr(ha, dev) { |
| 466 | − int nr = (bitrev32(~crc32_le(~0, ha->addr, 6)) >> | |
| 467 | + u32 nr = (bitrev32(~crc32_le(~0, ha->addr, 6)) >> | |
| 467 | 468 | (32 - mcbitslog2)); |
| 468 | 469 | mc_filter[nr >> 5] |= (1 << (nr & 0x1F)); |
| 469 | 470 | } |
| @@ -288,7 +288,8 @@ static int dwxgmac2_get_rx_hash(struct dma_desc *p, u32 *hash, · 287 unmodified lines | ||
| 288 | 288 | |
| 289 | 289 | static int dwxgmac2_get_rx_header_len(struct dma_desc *p, unsigned int *len) |
| 290 | 290 | { |
| 291 | − *len = le32_to_cpu(p->des2) & XGMAC_RDES2_HL; | |
| 291 | + if (le32_to_cpu(p->des3) & XGMAC_RDES3_L34T) | |
| 292 | + *len = le32_to_cpu(p->des2) & XGMAC_RDES2_HL; | |
| 292 | 293 | return 0; |
| 293 | 294 | } |
| 294 | 295 | |
| @@ -369,7 +369,7 @@ static void dwxgmac2_get_hw_feature(void __iomem *ioaddr, · 368 unmodified lines | ||
| 369 | 369 | dma_cap->eee = (hw_cap & XGMAC_HWFEAT_EEESEL) >> 13; |
| 370 | 370 | dma_cap->atime_stamp = (hw_cap & XGMAC_HWFEAT_TSSEL) >> 12; |
| 371 | 371 | dma_cap->av = (hw_cap & XGMAC_HWFEAT_AVSEL) >> 11; |
| 372 | − dma_cap->av &= !(hw_cap & XGMAC_HWFEAT_RAVSEL) >> 10; | |
| 372 | + dma_cap->av &= !((hw_cap & XGMAC_HWFEAT_RAVSEL) >> 10); | |
| 373 | 373 | dma_cap->arpoffsel = (hw_cap & XGMAC_HWFEAT_ARPOFFSEL) >> 9; |
| 374 | 374 | dma_cap->rmon = (hw_cap & XGMAC_HWFEAT_MMCSEL) >> 8; |
| 375 | 375 | dma_cap->pmt_magic_frame = (hw_cap & XGMAC_HWFEAT_MGKSEL) >> 7; |
| @@ -470,6 +470,7 @@ static void dwxgmac2_enable_tso(void __iomem *ioaddr, bool en, u32 chan) · 94 unmodified lines | ||
| 470 | 470 | static void dwxgmac2_qmode(void __iomem *ioaddr, u32 channel, u8 qmode) |
| 471 | 471 | { |
| 472 | 472 | u32 value = readl(ioaddr + XGMAC_MTL_TXQ_OPMODE(channel)); |
| 473 | + u32 flow = readl(ioaddr + XGMAC_RX_FLOW_CTRL); | |
| 473 | 474 | |
| 474 | 475 | value &= ~XGMAC_TXQEN; |
| 475 | 476 | if (qmode != MTL_QUEUE_AVB) { |
| @@ -477,6 +478,7 @@ static void dwxgmac2_qmode(void __iomem *ioaddr, u32 channel, u8 qmode) · 1 unmodified line | ||
| 477 | 478 | writel(0, ioaddr + XGMAC_MTL_TCx_ETS_CONTROL(channel)); |
| 478 | 479 | } else { |
| 479 | 480 | value |= 0x1 << XGMAC_TXQEN_SHIFT; |
| 481 | + writel(flow & (~XGMAC_RFE), ioaddr + XGMAC_RX_FLOW_CTRL); | |
| 480 | 482 | } |
| 481 | 483 | |
| 482 | 484 | writel(value, ioaddr + XGMAC_MTL_TXQ_OPMODE(channel)); |
| @@ -176,6 +176,7 @@ · 175 unmodified lines | ||
| 176 | 176 | #define MMC_XGMAC_RX_PKT_SMD_ERR 0x22c |
| 177 | 177 | #define MMC_XGMAC_RX_PKT_ASSEMBLY_OK 0x230 |
| 178 | 178 | #define MMC_XGMAC_RX_FPE_FRAG 0x234 |
| 179 | +#define MMC_XGMAC_RX_IPC_INTR_MASK 0x25c | |
| 179 | 180 | |
| 180 | 181 | static void dwmac_mmc_ctrl(void __iomem *mmcaddr, unsigned int mode) |
| 181 | 182 | { |
| @@ -333,8 +334,9 @@ static void dwxgmac_mmc_ctrl(void __iomem *mmcaddr, unsigned int mode) · 151 unmodified lines | ||
| 333 | 334 | |
| 334 | 335 | static void dwxgmac_mmc_intr_all_mask(void __iomem *mmcaddr) |
| 335 | 336 | { |
| 336 | − writel(MMC_DEFAULT_MASK, mmcaddr + MMC_RX_INTR_MASK); | |
| 337 | − writel(MMC_DEFAULT_MASK, mmcaddr + MMC_TX_INTR_MASK); | |
| 337 | + writel(0x0, mmcaddr + MMC_RX_INTR_MASK); | |
| 338 | + writel(0x0, mmcaddr + MMC_TX_INTR_MASK); | |
| 339 | + writel(MMC_DEFAULT_MASK, mmcaddr + MMC_XGMAC_RX_IPC_INTR_MASK); | |
| 338 | 340 | } |
| 339 | 341 | |
| 340 | 342 | static void dwxgmac_read_mmc_reg(void __iomem *addr, u32 reg, u32 *dest) |
| @@ -2995,6 +2995,8 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) · 2994 unmodified lines | ||
| 2995 | 2995 | } else { |
| 2996 | 2996 | stmmac_set_desc_addr(priv, first, des); |
| 2997 | 2997 | tmp_pay_len = pay_len; |
| 2998 | + des += proto_hdr_len; | |
| 2999 | + pay_len = 0; | |
| 2998 | 3000 | } |
| 2999 | 3001 | |
| 3000 | 3002 | stmmac_tso_allocator(priv, des, tmp_pay_len, (nfrags == 0), queue); |
| @@ -3022,6 +3024,19 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) · 21 unmodified lines | ||
| 3022 | 3024 | /* Only the last descriptor gets to point to the skb. */ |
| 3023 | 3025 | tx_q->tx_skbuff[tx_q->cur_tx] = skb; |
| 3024 | 3026 | |
| 3027 | + /* Manage tx mitigation */ | |
| 3028 | + tx_q->tx_count_frames += nfrags + 1; | |
| 3029 | + if (likely(priv->tx_coal_frames > tx_q->tx_count_frames) && | |
| 3030 | + !((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && | |
| 3031 | + priv->hwts_tx_en)) { | |
| 3032 | + stmmac_tx_timer_arm(priv, queue); | |
| 3033 | + } else { | |
| 3034 | + desc = &tx_q->dma_tx[tx_q->cur_tx]; | |
| 3035 | + tx_q->tx_count_frames = 0; | |
| 3036 | + stmmac_set_tx_ic(priv, desc); | |
| 3037 | + priv->xstats.tx_set_ic_bit++; | |
| 3038 | + } | |
| 3039 | + | |
| 3025 | 3040 | /* We've used all descriptors we need for this skb, however, |
| 3026 | 3041 | * advance cur_tx so that it references a fresh descriptor. |
| 3027 | 3042 | * ndo_start_xmit will fill this descriptor the next time it's |
| @@ -3039,19 +3054,6 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) · 11 unmodified lines | ||
| 3039 | 3054 | priv->xstats.tx_tso_frames++; |
| 3040 | 3055 | priv->xstats.tx_tso_nfrags += nfrags; |
| 3041 | 3056 | |
| 3042 | − /* Manage tx mitigation */ | |
| 3043 | − tx_q->tx_count_frames += nfrags + 1; | |
| 3044 | − if (likely(priv->tx_coal_frames > tx_q->tx_count_frames) && | |
| 3045 | − !(priv->synopsys_id >= DWMAC_CORE_4_00 && | |
| 3046 | − (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && | |
| 3047 | − priv->hwts_tx_en)) { | |
| 3048 | − stmmac_tx_timer_arm(priv, queue); | |
| 3049 | − } else { | |
| 3050 | − tx_q->tx_count_frames = 0; | |
| 3051 | − stmmac_set_tx_ic(priv, desc); | |
| 3052 | − priv->xstats.tx_set_ic_bit++; | |
| 3053 | − } | |
| 3054 | − | |
| 3055 | 3057 | if (priv->sarc_type) |
| 3056 | 3058 | stmmac_set_desc_sarc(priv, first, priv->sarc_type); |
| 3057 | 3059 | |
| @@ -3223,6 +3225,27 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) · 165 unmodified lines | ||
| 3223 | 3225 | /* Only the last descriptor gets to point to the skb. */ |
| 3224 | 3226 | tx_q->tx_skbuff[entry] = skb; |
| 3225 | 3227 | |
| 3228 | + /* According to the coalesce parameter the IC bit for the latest | |
| 3229 | + * segment is reset and the timer re-started to clean the tx status. | |
| 3230 | + * This approach takes care about the fragments: desc is the first | |
| 3231 | + * element in case of no SG. | |
| 3232 | + */ | |
| 3233 | + tx_q->tx_count_frames += nfrags + 1; | |
| 3234 | + if (likely(priv->tx_coal_frames > tx_q->tx_count_frames) && | |
| 3235 | + !((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && | |
| 3236 | + priv->hwts_tx_en)) { | |
| 3237 | + stmmac_tx_timer_arm(priv, queue); | |
| 3238 | + } else { | |
| 3239 | + if (likely(priv->extend_desc)) | |
| 3240 | + desc = &tx_q->dma_etx[entry].basic; | |
| 3241 | + else | |
| 3242 | + desc = &tx_q->dma_tx[entry]; | |
| 3243 | + | |
| 3244 | + tx_q->tx_count_frames = 0; | |
| 3245 | + stmmac_set_tx_ic(priv, desc); | |
| 3246 | + priv->xstats.tx_set_ic_bit++; | |
| 3247 | + } | |
| 3248 | + | |
| 3226 | 3249 | /* We've used all descriptors we need for this skb, however, |
| 3227 | 3250 | * advance cur_tx so that it references a fresh descriptor. |
| 3228 | 3251 | * ndo_start_xmit will fill this descriptor the next time it's |
| @@ -3258,23 +3281,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) · 29 unmodified lines | ||
| 3258 | 3281 | |
| 3259 | 3282 | dev->stats.tx_bytes += skb->len; |
| 3260 | 3283 | |
| 3261 | − /* According to the coalesce parameter the IC bit for the latest | |
| 3262 | − * segment is reset and the timer re-started to clean the tx status. | |
| 3263 | − * This approach takes care about the fragments: desc is the first | |
| 3264 | − * element in case of no SG. | |
| 3265 | − */ | |
| 3266 | − tx_q->tx_count_frames += nfrags + 1; | |
| 3267 | − if (likely(priv->tx_coal_frames > tx_q->tx_count_frames) && | |
| 3268 | − !(priv->synopsys_id >= DWMAC_CORE_4_00 && | |
| 3269 | − (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && | |
| 3270 | − priv->hwts_tx_en)) { | |
| 3271 | − stmmac_tx_timer_arm(priv, queue); | |
| 3272 | − } else { | |
| 3273 | − tx_q->tx_count_frames = 0; | |
| 3274 | − stmmac_set_tx_ic(priv, desc); | |
| 3275 | − priv->xstats.tx_set_ic_bit++; | |
| 3276 | − } | |
| 3277 | − | |
| 3278 | 3284 | if (priv->sarc_type) |
| 3279 | 3285 | stmmac_set_desc_sarc(priv, first, priv->sarc_type); |
| 3280 | 3286 | |
| @@ -3505,8 +3511,6 @@ read_again: · 224 unmodified lines | ||
| 3505 | 3511 | if (unlikely(status & dma_own)) |
| 3506 | 3512 | break; |
| 3507 | 3513 | |
| 3508 | − count++; | |
| 3509 | − | |
| 3510 | 3514 | rx_q->cur_rx = STMMAC_GET_ENTRY(rx_q->cur_rx, DMA_RX_SIZE); |
| 3511 | 3515 | next_entry = rx_q->cur_rx; |
| 3512 | 3516 | |
| @@ -3533,6 +3537,7 @@ read_again: · 20 unmodified lines | ||
| 3533 | 3537 | goto read_again; |
| 3534 | 3538 | if (unlikely(error)) { |
| 3535 | 3539 | dev_kfree_skb(skb); |
| 3540 | + count++; | |
| 3536 | 3541 | continue; |
| 3537 | 3542 | } |
| 3538 | 3543 | |
| @@ -3572,6 +3577,7 @@ read_again: · 33 unmodified lines | ||
| 3572 | 3577 | skb = napi_alloc_skb(&ch->rx_napi, len); |
| 3573 | 3578 | if (!skb) { |
| 3574 | 3579 | priv->dev->stats.rx_dropped++; |
| 3580 | + count++; | |
| 3575 | 3581 | continue; |
| 3576 | 3582 | } |
| 3577 | 3583 | |
| @@ -3637,6 +3643,7 @@ read_again: · 59 unmodified lines | ||
| 3637 | 3643 | |
| 3638 | 3644 | priv->dev->stats.rx_packets++; |
| 3639 | 3645 | priv->dev->stats.rx_bytes += len; |
| 3646 | + count++; | |
| 3640 | 3647 | } |
| 3641 | 3648 | |
| 3642 | 3649 | if (status & rx_not_ls) { |
| @@ -6,7 +6,9 @@ · 5 unmodified lines | ||
| 6 | 6 | * Author: Jose Abreu <joabreu@synopsys.com> |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | +#include <linux/bitrev.h> | |
| 9 | 10 | #include <linux/completion.h> |
| 11 | +#include <linux/crc32.h> | |
| 10 | 12 | #include <linux/ethtool.h> |
| 11 | 13 | #include <linux/ip.h> |
| 12 | 14 | #include <linux/phy.h> |
| @@ -485,12 +487,48 @@ static int stmmac_filter_check(struct stmmac_priv *priv) · 472 unmodified lines | ||
| 485 | 487 | return -EOPNOTSUPP; |
| 486 | 488 | } |
| 487 | 489 | |
| 490 | +static bool stmmac_hash_check(struct stmmac_priv *priv, unsigned char *addr) | |
| 491 | +{ | |
| 492 | + int mc_offset = 32 - priv->hw->mcast_bits_log2; | |
| 493 | + struct netdev_hw_addr *ha; | |
| 494 | + u32 hash, hash_nr; | |
| 495 | + | |
| 496 | + /* First compute the hash for desired addr */ | |
| 497 | + hash = bitrev32(~crc32_le(~0, addr, 6)) >> mc_offset; | |
| 498 | + hash_nr = hash >> 5; | |
| 499 | + hash = 1 << (hash & 0x1f); | |
| 500 | + | |
| 501 | + /* Now, check if it collides with any existing one */ | |
| 502 | + netdev_for_each_mc_addr(ha, priv->dev) { | |
| 503 | + u32 nr = bitrev32(~crc32_le(~0, ha->addr, ETH_ALEN)) >> mc_offset; | |
| 504 | + if (((nr >> 5) == hash_nr) && ((1 << (nr & 0x1f)) == hash)) | |
| 505 | + return false; | |
| 506 | + } | |
| 507 | + | |
| 508 | + /* No collisions, address is good to go */ | |
| 509 | + return true; | |
| 510 | +} | |
| 511 | + | |
| 512 | +static bool stmmac_perfect_check(struct stmmac_priv *priv, unsigned char *addr) | |
| 513 | +{ | |
| 514 | + struct netdev_hw_addr *ha; | |
| 515 | + | |
| 516 | + /* Check if it collides with any existing one */ | |
| 517 | + netdev_for_each_uc_addr(ha, priv->dev) { | |
| 518 | + if (!memcmp(ha->addr, addr, ETH_ALEN)) | |
| 519 | + return false; | |
| 520 | + } | |
| 521 | + | |
| 522 | + /* No collisions, address is good to go */ | |
| 523 | + return true; | |
| 524 | +} | |
| 525 | + | |
| 488 | 526 | static int stmmac_test_hfilt(struct stmmac_priv *priv) |
| 489 | 527 | { |
| 490 | − unsigned char gd_addr[ETH_ALEN] = {0x01, 0xee, 0xdd, 0xcc, 0xbb, 0xaa}; | |
| 491 | − unsigned char bd_addr[ETH_ALEN] = {0x01, 0x01, 0x02, 0x03, 0x04, 0x05}; | |
| 528 | + unsigned char gd_addr[ETH_ALEN] = {0xf1, 0xee, 0xdd, 0xcc, 0xbb, 0xaa}; | |
| 529 | + unsigned char bd_addr[ETH_ALEN] = {0xf1, 0xff, 0xff, 0xff, 0xff, 0xff}; | |
| 492 | 530 | struct stmmac_packet_attrs attr = { }; |
| 493 | − int ret; | |
| 531 | + int ret, tries = 256; | |
| 494 | 532 | |
| 495 | 533 | ret = stmmac_filter_check(priv); |
| 496 | 534 | if (ret) |
| @@ -499,6 +537,16 @@ static int stmmac_test_hfilt(struct stmmac_priv *priv) · 2 unmodified lines | ||
| 499 | 537 | if (netdev_mc_count(priv->dev) >= priv->hw->multicast_filter_bins) |
| 500 | 538 | return -EOPNOTSUPP; |
| 501 | 539 | |
| 540 | + while (--tries) { | |
| 541 | + /* We only need to check the bd_addr for collisions */ | |
| 542 | + bd_addr[ETH_ALEN - 1] = tries; | |
| 543 | + if (stmmac_hash_check(priv, bd_addr)) | |
| 544 | + break; | |
| 545 | + } | |
| 546 | + | |
| 547 | + if (!tries) | |
| 548 | + return -EOPNOTSUPP; | |
| 549 | + | |
| 502 | 550 | ret = dev_mc_add(priv->dev, gd_addr); |
| 503 | 551 | if (ret) |
| 504 | 552 | return ret; |
| @@ -523,13 +571,25 @@ cleanup: · 18 unmodified lines | ||
| 523 | 571 | |
| 524 | 572 | static int stmmac_test_pfilt(struct stmmac_priv *priv) |
| 525 | 573 | { |
| 526 | − unsigned char gd_addr[ETH_ALEN] = {0x00, 0x01, 0x44, 0x55, 0x66, 0x77}; | |
| 527 | − unsigned char bd_addr[ETH_ALEN] = {0x08, 0x00, 0x22, 0x33, 0x44, 0x55}; | |
| 574 | + unsigned char gd_addr[ETH_ALEN] = {0xf0, 0x01, 0x44, 0x55, 0x66, 0x77}; | |
| 575 | + unsigned char bd_addr[ETH_ALEN] = {0xf0, 0xff, 0xff, 0xff, 0xff, 0xff}; | |
| 528 | 576 | struct stmmac_packet_attrs attr = { }; |
| 529 | − int ret; | |
| 577 | + int ret, tries = 256; | |
| 530 | 578 | |
| 531 | 579 | if (stmmac_filter_check(priv)) |
| 532 | 580 | return -EOPNOTSUPP; |
| 581 | + if (netdev_uc_count(priv->dev) >= priv->hw->unicast_filter_entries) | |
| 582 | + return -EOPNOTSUPP; | |
| 583 | + | |
| 584 | + while (--tries) { | |
| 585 | + /* We only need to check the bd_addr for collisions */ | |
| 586 | + bd_addr[ETH_ALEN - 1] = tries; | |
| 587 | + if (stmmac_perfect_check(priv, bd_addr)) | |
| 588 | + break; | |
| 589 | + } | |
| 590 | + | |
| 591 | + if (!tries) | |
| 592 | + return -EOPNOTSUPP; | |
| 533 | 593 | |
| 534 | 594 | ret = dev_uc_add(priv->dev, gd_addr); |
| 535 | 595 | if (ret) |
| @@ -553,39 +613,31 @@ cleanup: · 17 unmodified lines | ||
| 553 | 613 | return ret; |
| 554 | 614 | } |
| 555 | 615 | |
| 556 | −static int stmmac_dummy_sync(struct net_device *netdev, const u8 *addr) | |
| 557 | −{ | |
| 558 | − return 0; | |
| 559 | −} | |
| 560 | − | |
| 561 | −static void stmmac_test_set_rx_mode(struct net_device *netdev) | |
| 562 | −{ | |
| 563 | − /* As we are in test mode of ethtool we already own the rtnl lock | |
| 564 | − * so no address will change from user. We can just call the | |
| 565 | − * ndo_set_rx_mode() callback directly */ | |
| 566 | − if (netdev->netdev_ops->ndo_set_rx_mode) | |
| 567 | − netdev->netdev_ops->ndo_set_rx_mode(netdev); | |
| 568 | −} | |
| 569 | − | |
| 570 | 616 | static int stmmac_test_mcfilt(struct stmmac_priv *priv) |
| 571 | 617 | { |
| 572 | − unsigned char uc_addr[ETH_ALEN] = {0x00, 0x01, 0x44, 0x55, 0x66, 0x77}; | |
| 573 | − unsigned char mc_addr[ETH_ALEN] = {0x01, 0x01, 0x44, 0x55, 0x66, 0x77}; | |
| 618 | + unsigned char uc_addr[ETH_ALEN] = {0xf0, 0xff, 0xff, 0xff, 0xff, 0xff}; | |
| 619 | + unsigned char mc_addr[ETH_ALEN] = {0xf1, 0xff, 0xff, 0xff, 0xff, 0xff}; | |
| 574 | 620 | struct stmmac_packet_attrs attr = { }; |
| 575 | − int ret; | |
| 621 | + int ret, tries = 256; | |
| 576 | 622 | |
| 577 | 623 | if (stmmac_filter_check(priv)) |
| 578 | 624 | return -EOPNOTSUPP; |
| 579 | − if (!priv->hw->multicast_filter_bins) | |
| 625 | + if (netdev_uc_count(priv->dev) >= priv->hw->unicast_filter_entries) | |
| 580 | 626 | return -EOPNOTSUPP; |
| 581 | 627 | |
| 582 | − /* Remove all MC addresses */ | |
| 583 | − __dev_mc_unsync(priv->dev, NULL); | |
| 584 | − stmmac_test_set_rx_mode(priv->dev); | |
| 628 | + while (--tries) { | |
| 629 | + /* We only need to check the mc_addr for collisions */ | |
| 630 | + mc_addr[ETH_ALEN - 1] = tries; | |
| 631 | + if (stmmac_hash_check(priv, mc_addr)) | |
| 632 | + break; | |
| 633 | + } | |
| 634 | + | |
| 635 | + if (!tries) | |
| 636 | + return -EOPNOTSUPP; | |
| 585 | 637 | |
| 586 | 638 | ret = dev_uc_add(priv->dev, uc_addr); |
| 587 | 639 | if (ret) |
| 588 | − goto cleanup; | |
| 640 | + return ret; | |
| 589 | 641 | |
| 590 | 642 | attr.dst = uc_addr; |
| 591 | 643 | |
| @@ -602,30 +654,34 @@ static int stmmac_test_mcfilt(struct stmmac_priv *priv) · 10 unmodified lines | ||
| 602 | 654 | |
| 603 | 655 | cleanup: |
| 604 | 656 | dev_uc_del(priv->dev, uc_addr); |
| 605 | − __dev_mc_sync(priv->dev, stmmac_dummy_sync, NULL); | |
| 606 | − stmmac_test_set_rx_mode(priv->dev); | |
| 607 | 657 | return ret; |
| 608 | 658 | } |
| 609 | 659 | |
| 610 | 660 | static int stmmac_test_ucfilt(struct stmmac_priv *priv) |
| 611 | 661 | { |
| 612 | − unsigned char uc_addr[ETH_ALEN] = {0x00, 0x01, 0x44, 0x55, 0x66, 0x77}; | |
| 613 | − unsigned char mc_addr[ETH_ALEN] = {0x01, 0x01, 0x44, 0x55, 0x66, 0x77}; | |
| 662 | + unsigned char uc_addr[ETH_ALEN] = {0xf0, 0xff, 0xff, 0xff, 0xff, 0xff}; | |
| 663 | + unsigned char mc_addr[ETH_ALEN] = {0xf1, 0xff, 0xff, 0xff, 0xff, 0xff}; | |
| 614 | 664 | struct stmmac_packet_attrs attr = { }; |
| 615 | − int ret; | |
| 665 | + int ret, tries = 256; | |
| 616 | 666 | |
| 617 | 667 | if (stmmac_filter_check(priv)) |
| 618 | 668 | return -EOPNOTSUPP; |
| 619 | − if (!priv->hw->multicast_filter_bins) | |
| 669 | + if (netdev_mc_count(priv->dev) >= priv->hw->multicast_filter_bins) | |
| 620 | 670 | return -EOPNOTSUPP; |
| 621 | 671 | |
| 622 | − /* Remove all UC addresses */ | |
| 623 | − __dev_uc_unsync(priv->dev, NULL); | |
| 624 | − stmmac_test_set_rx_mode(priv->dev); | |
| 672 | + while (--tries) { | |
| 673 | + /* We only need to check the uc_addr for collisions */ | |
| 674 | + uc_addr[ETH_ALEN - 1] = tries; | |
| 675 | + if (stmmac_perfect_check(priv, uc_addr)) | |
| 676 | + break; | |
| 677 | + } | |
| 678 | + | |
| 679 | + if (!tries) | |
| 680 | + return -EOPNOTSUPP; | |
| 625 | 681 | |
| 626 | 682 | ret = dev_mc_add(priv->dev, mc_addr); |
| 627 | 683 | if (ret) |
| 628 | − goto cleanup; | |
| 684 | + return ret; | |
| 629 | 685 | |
| 630 | 686 | attr.dst = mc_addr; |
| 631 | 687 | |
| @@ -642,8 +698,6 @@ static int stmmac_test_ucfilt(struct stmmac_priv *priv) · 10 unmodified lines | ||
| 642 | 698 | |
| 643 | 699 | cleanup: |
| 644 | 700 | dev_mc_del(priv->dev, mc_addr); |
| 645 | − __dev_uc_sync(priv->dev, stmmac_dummy_sync, NULL); | |
| 646 | − stmmac_test_set_rx_mode(priv->dev); | |
| 647 | 701 | return ret; |
| 648 | 702 | } |
| 649 | 703 | |
| @@ -1237,8 +1237,17 @@ static int fjes_probe(struct platform_device *plat_dev) · 1236 unmodified lines | ||
| 1237 | 1237 | adapter->open_guard = false; |
| 1238 | 1238 | |
| 1239 | 1239 | adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0); |
| 1240 | + if (unlikely(!adapter->txrx_wq)) { | |
| 1241 | + err = -ENOMEM; | |
| 1242 | + goto err_free_netdev; | |
| 1243 | + } | |
| 1244 | + | |
| 1240 | 1245 | adapter->control_wq = alloc_workqueue(DRV_NAME "/control", |
| 1241 | 1246 | WQ_MEM_RECLAIM, 0); |
| 1247 | + if (unlikely(!adapter->control_wq)) { | |
| 1248 | + err = -ENOMEM; | |
| 1249 | + goto err_free_txrx_wq; | |
| 1250 | + } | |
| 1242 | 1251 | |
| 1243 | 1252 | INIT_WORK(&adapter->tx_stall_task, fjes_tx_stall_task); |
| 1244 | 1253 | INIT_WORK(&adapter->raise_intr_rxdata_task, |
| @@ -1255,7 +1264,7 @@ static int fjes_probe(struct platform_device *plat_dev) · 10 unmodified lines | ||
| 1255 | 1264 | hw->hw_res.irq = platform_get_irq(plat_dev, 0); |
| 1256 | 1265 | err = fjes_hw_init(&adapter->hw); |
| 1257 | 1266 | if (err) |
| 1258 | − goto err_free_netdev; | |
| 1267 | + goto err_free_control_wq; | |
| 1259 | 1268 | |
| 1260 | 1269 | /* setup MAC address (02:00:00:00:00:[epid])*/ |
| 1261 | 1270 | netdev->dev_addr[0] = 2; |
| @@ -1277,6 +1286,10 @@ static int fjes_probe(struct platform_device *plat_dev) · 15 unmodified lines | ||
| 1277 | 1286 | |
| 1278 | 1287 | err_hw_exit: |
| 1279 | 1288 | fjes_hw_exit(&adapter->hw); |
| 1289 | +err_free_control_wq: | |
| 1290 | + destroy_workqueue(adapter->control_wq); | |
| 1291 | +err_free_txrx_wq: | |
| 1292 | + destroy_workqueue(adapter->txrx_wq); | |
| 1280 | 1293 | err_free_netdev: |
| 1281 | 1294 | free_netdev(netdev); |
| 1282 | 1295 | err_out: |
| @@ -107,27 +107,6 @@ struct bpqdev { · 106 unmodified lines | ||
| 107 | 107 | |
| 108 | 108 | static LIST_HEAD(bpq_devices); |
| 109 | 109 | |
| 110 | −/* | |
| 111 | − * bpqether network devices are paired with ethernet devices below them, so | |
| 112 | − * form a special "super class" of normal ethernet devices; split their locks | |
| 113 | − * off into a separate class since they always nest. | |
| 114 | − */ | |
| 115 | −static struct lock_class_key bpq_netdev_xmit_lock_key; | |
| 116 | −static struct lock_class_key bpq_netdev_addr_lock_key; | |
| 117 | − | |
| 118 | −static void bpq_set_lockdep_class_one(struct net_device *dev, | |
| 119 | − struct netdev_queue *txq, | |
| 120 | − void *_unused) | |
| 121 | −{ | |
| 122 | − lockdep_set_class(&txq->_xmit_lock, &bpq_netdev_xmit_lock_key); | |
| 123 | −} | |
| 124 | − | |
| 125 | −static void bpq_set_lockdep_class(struct net_device *dev) | |
| 126 | −{ | |
| 127 | − lockdep_set_class(&dev->addr_list_lock, &bpq_netdev_addr_lock_key); | |
| 128 | − netdev_for_each_tx_queue(dev, bpq_set_lockdep_class_one, NULL); | |
| 129 | −} | |
| 130 | − | |
| 131 | 110 | /* ------------------------------------------------------------------------ */ |
| 132 | 111 | |
| 133 | 112 | |
| @@ -498,7 +477,6 @@ static int bpq_new_device(struct net_device *edev) · 364 unmodified lines | ||
| 498 | 477 | err = register_netdevice(ndev); |
| 499 | 478 | if (err) |
| 500 | 479 | goto error; |
| 501 | − bpq_set_lockdep_class(ndev); | |
| 502 | 480 | |
| 503 | 481 | /* List protected by RTNL */ |
| 504 | 482 | list_add_rcu(&bpq->bpq_list, &bpq_devices); |
| @@ -982,7 +982,7 @@ static int netvsc_attach(struct net_device *ndev, · 981 unmodified lines | ||
| 982 | 982 | if (netif_running(ndev)) { |
| 983 | 983 | ret = rndis_filter_open(nvdev); |
| 984 | 984 | if (ret) |
| 985 | − return ret; | |
| 985 | + goto err; | |
| 986 | 986 | |
| 987 | 987 | rdev = nvdev->extension; |
| 988 | 988 | if (!rdev->link_state) |
| @@ -990,6 +990,13 @@ static int netvsc_attach(struct net_device *ndev, · 1 unmodified line | ||
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | return 0; |
| 993 | + | |
| 994 | +err: | |
| 995 | + netif_device_detach(ndev); | |
| 996 | + | |
| 997 | + rndis_filter_device_remove(hdev, nvdev); | |
| 998 | + | |
| 999 | + return ret; | |
| 993 | 1000 | } |
| 994 | 1001 | |
| 995 | 1002 | static int netvsc_set_channels(struct net_device *net, |
| @@ -1807,8 +1814,10 @@ static int netvsc_set_features(struct net_device *ndev, · 811 unmodified lines | ||
| 1807 | 1814 | |
| 1808 | 1815 | ret = rndis_filter_set_offload_params(ndev, nvdev, &offloads); |
| 1809 | 1816 | |
| 1810 | − if (ret) | |
| 1817 | + if (ret) { | |
| 1811 | 1818 | features ^= NETIF_F_LRO; |
| 1819 | + ndev->features = features; | |
| 1820 | + } | |
| 1812 | 1821 | |
| 1813 | 1822 | syncvf: |
| 1814 | 1823 | if (!vf_netdev) |
| @@ -2335,8 +2344,6 @@ static int netvsc_probe(struct hv_device *dev, · 520 unmodified lines | ||
| 2335 | 2344 | NETIF_F_HW_VLAN_CTAG_RX; |
| 2336 | 2345 | net->vlan_features = net->features; |
| 2337 | 2346 | |
| 2338 | − netdev_lockdep_set_classes(net); | |
| 2339 | − | |
| 2340 | 2347 | /* MTU range: 68 - 1500 or 65521 */ |
| 2341 | 2348 | net->min_mtu = NETVSC_MTU_MIN; |
| 2342 | 2349 | if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2) |
| @@ -131,8 +131,6 @@ static int ipvlan_init(struct net_device *dev) · 130 unmodified lines | ||
| 131 | 131 | dev->gso_max_segs = phy_dev->gso_max_segs; |
| 132 | 132 | dev->hard_header_len = phy_dev->hard_header_len; |
| 133 | 133 | |
| 134 | − netdev_lockdep_set_classes(dev); | |
| 135 | − | |
| 136 | 134 | ipvlan->pcpu_stats = netdev_alloc_pcpu_stats(struct ipvl_pcpu_stats); |
| 137 | 135 | if (!ipvlan->pcpu_stats) |
| 138 | 136 | return -ENOMEM; |
| @@ -267,7 +267,6 @@ struct macsec_dev { · 266 unmodified lines | ||
| 267 | 267 | struct pcpu_secy_stats __percpu *stats; |
| 268 | 268 | struct list_head secys; |
| 269 | 269 | struct gro_cells gro_cells; |
| 270 | − unsigned int nest_level; | |
| 271 | 270 | }; |
| 272 | 271 | |
| 273 | 272 | /** |
| @@ -2750,7 +2749,6 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb, · 2476 unmodified lines | ||
| 2750 | 2749 | |
| 2751 | 2750 | #define MACSEC_FEATURES \ |
| 2752 | 2751 | (NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST) |
| 2753 | −static struct lock_class_key macsec_netdev_addr_lock_key; | |
| 2754 | 2752 | |
| 2755 | 2753 | static int macsec_dev_init(struct net_device *dev) |
| 2756 | 2754 | { |
| @@ -2958,11 +2956,6 @@ static int macsec_get_iflink(const struct net_device *dev) · 201 unmodified lines | ||
| 2958 | 2956 | return macsec_priv(dev)->real_dev->ifindex; |
| 2959 | 2957 | } |
| 2960 | 2958 | |
| 2961 | −static int macsec_get_nest_level(struct net_device *dev) | |
| 2962 | −{ | |
| 2963 | − return macsec_priv(dev)->nest_level; | |
| 2964 | −} | |
| 2965 | − | |
| 2966 | 2959 | static const struct net_device_ops macsec_netdev_ops = { |
| 2967 | 2960 | .ndo_init = macsec_dev_init, |
| 2968 | 2961 | .ndo_uninit = macsec_dev_uninit, |
| @@ -2976,7 +2969,6 @@ static const struct net_device_ops macsec_netdev_ops = { · 7 unmodified lines | ||
| 2976 | 2969 | .ndo_start_xmit = macsec_start_xmit, |
| 2977 | 2970 | .ndo_get_stats64 = macsec_get_stats64, |
| 2978 | 2971 | .ndo_get_iflink = macsec_get_iflink, |
| 2979 | − .ndo_get_lock_subclass = macsec_get_nest_level, | |
| 2980 | 2972 | }; |
| 2981 | 2973 | |
| 2982 | 2974 | static const struct device_type macsec_type = { |
| @@ -3001,12 +2993,10 @@ static const struct nla_policy macsec_rtnl_policy[IFLA_MACSEC_MAX + 1] = { · 18 unmodified lines | ||
| 3001 | 2993 | static void macsec_free_netdev(struct net_device *dev) |
| 3002 | 2994 | { |
| 3003 | 2995 | struct macsec_dev *macsec = macsec_priv(dev); |
| 3004 | − struct net_device *real_dev = macsec->real_dev; | |
| 3005 | 2996 | |
| 3006 | 2997 | free_percpu(macsec->stats); |
| 3007 | 2998 | free_percpu(macsec->secy.tx_sc.stats); |
| 3008 | 2999 | |
| 3009 | − dev_put(real_dev); | |
| 3010 | 3000 | } |
| 3011 | 3001 | |
| 3012 | 3002 | static void macsec_setup(struct net_device *dev) |
| @@ -3261,14 +3251,6 @@ static int macsec_newlink(struct net *net, struct net_device *dev, · 248 unmodified lines | ||
| 3261 | 3251 | if (err < 0) |
| 3262 | 3252 | return err; |
| 3263 | 3253 | |
| 3264 | − dev_hold(real_dev); | |
| 3265 | − | |
| 3266 | − macsec->nest_level = dev_get_nest_level(real_dev) + 1; | |
| 3267 | − netdev_lockdep_set_classes(dev); | |
| 3268 | − lockdep_set_class_and_subclass(&dev->addr_list_lock, | |
| 3269 | − &macsec_netdev_addr_lock_key, | |
| 3270 | − macsec_get_nest_level(dev)); | |
| 3271 | − | |
| 3272 | 3254 | err = netdev_upper_dev_link(real_dev, dev, extack); |
| 3273 | 3255 | if (err < 0) |
| 3274 | 3256 | goto unregister; |
| @@ -852,8 +852,6 @@ static int macvlan_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) · 851 unmodified lines | ||
| 852 | 852 | * "super class" of normal network devices; split their locks off into a |
| 853 | 853 | * separate class since they always nest. |
| 854 | 854 | */ |
| 855 | −static struct lock_class_key macvlan_netdev_addr_lock_key; | |
| 856 | − | |
| 857 | 855 | #define ALWAYS_ON_OFFLOADS \ |
| 858 | 856 | (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE | \ |
| 859 | 857 | NETIF_F_GSO_ROBUST | NETIF_F_GSO_ENCAP_ALL) |
| @@ -869,19 +867,6 @@ static struct lock_class_key macvlan_netdev_addr_lock_key; · 9 unmodified lines | ||
| 869 | 867 | #define MACVLAN_STATE_MASK \ |
| 870 | 868 | ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT)) |
| 871 | 869 | |
| 872 | −static int macvlan_get_nest_level(struct net_device *dev) | |
| 873 | −{ | |
| 874 | − return ((struct macvlan_dev *)netdev_priv(dev))->nest_level; | |
| 875 | −} | |
| 876 | − | |
| 877 | −static void macvlan_set_lockdep_class(struct net_device *dev) | |
| 878 | −{ | |
| 879 | − netdev_lockdep_set_classes(dev); | |
| 880 | − lockdep_set_class_and_subclass(&dev->addr_list_lock, | |
| 881 | − &macvlan_netdev_addr_lock_key, | |
| 882 | − macvlan_get_nest_level(dev)); | |
| 883 | −} | |
| 884 | − | |
| 885 | 870 | static int macvlan_init(struct net_device *dev) |
| 886 | 871 | { |
| 887 | 872 | struct macvlan_dev *vlan = netdev_priv(dev); |
| @@ -900,8 +885,6 @@ static int macvlan_init(struct net_device *dev) · 12 unmodified lines | ||
| 900 | 885 | dev->gso_max_segs = lowerdev->gso_max_segs; |
| 901 | 886 | dev->hard_header_len = lowerdev->hard_header_len; |
| 902 | 887 | |
| 903 | − macvlan_set_lockdep_class(dev); | |
| 904 | − | |
| 905 | 888 | vlan->pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats); |
| 906 | 889 | if (!vlan->pcpu_stats) |
| 907 | 890 | return -ENOMEM; |
| @@ -1161,7 +1144,6 @@ static const struct net_device_ops macvlan_netdev_ops = { · 253 unmodified lines | ||
| 1161 | 1144 | .ndo_fdb_add = macvlan_fdb_add, |
| 1162 | 1145 | .ndo_fdb_del = macvlan_fdb_del, |
| 1163 | 1146 | .ndo_fdb_dump = ndo_dflt_fdb_dump, |
| 1164 | − .ndo_get_lock_subclass = macvlan_get_nest_level, | |
| 1165 | 1147 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 1166 | 1148 | .ndo_poll_controller = macvlan_dev_poll_controller, |
| 1167 | 1149 | .ndo_netpoll_setup = macvlan_dev_netpoll_setup, |
| @@ -1445,7 +1427,6 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, · 277 unmodified lines | ||
| 1445 | 1427 | vlan->dev = dev; |
| 1446 | 1428 | vlan->port = port; |
| 1447 | 1429 | vlan->set_features = MACVLAN_FEATURES; |
| 1448 | − vlan->nest_level = dev_get_nest_level(lowerdev) + 1; | |
| 1449 | 1430 | |
| 1450 | 1431 | vlan->mode = MACVLAN_MODE_VEPA; |
| 1451 | 1432 | if (data && data[IFLA_MACVLAN_MODE]) |
| @@ -806,9 +806,11 @@ static void nsim_dev_port_del_all(struct nsim_dev *nsim_dev) · 805 unmodified lines | ||
| 806 | 806 | { |
| 807 | 807 | struct nsim_dev_port *nsim_dev_port, *tmp; |
| 808 | 808 | |
| 809 | + mutex_lock(&nsim_dev->port_list_lock); | |
| 809 | 810 | list_for_each_entry_safe(nsim_dev_port, tmp, |
| 810 | 811 | &nsim_dev->port_list, list) |
| 811 | 812 | __nsim_dev_port_del(nsim_dev_port); |
| 813 | + mutex_unlock(&nsim_dev->port_list_lock); | |
| 812 | 814 | } |
| 813 | 815 | |
| 814 | 816 | int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev) |
| @@ -822,14 +824,17 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev) · 7 unmodified lines | ||
| 822 | 824 | return PTR_ERR(nsim_dev); |
| 823 | 825 | dev_set_drvdata(&nsim_bus_dev->dev, nsim_dev); |
| 824 | 826 | |
| 827 | + mutex_lock(&nsim_dev->port_list_lock); | |
| 825 | 828 | for (i = 0; i < nsim_bus_dev->port_count; i++) { |
| 826 | 829 | err = __nsim_dev_port_add(nsim_dev, i); |
| 827 | 830 | if (err) |
| 828 | 831 | goto err_port_del_all; |
| 829 | 832 | } |
| 833 | + mutex_unlock(&nsim_dev->port_list_lock); | |
| 830 | 834 | return 0; |
| 831 | 835 | |
| 832 | 836 | err_port_del_all: |
| 837 | + mutex_unlock(&nsim_dev->port_list_lock); | |
| 833 | 838 | nsim_dev_port_del_all(nsim_dev); |
| 834 | 839 | nsim_dev_destroy(nsim_dev); |
| 835 | 840 | return err; |
| @@ -87,8 +87,24 @@ struct phylink { · 86 unmodified lines | ||
| 87 | 87 | phylink_printk(KERN_WARNING, pl, fmt, ##__VA_ARGS__) |
| 88 | 88 | #define phylink_info(pl, fmt, ...) \ |
| 89 | 89 | phylink_printk(KERN_INFO, pl, fmt, ##__VA_ARGS__) |
| 90 | +#if defined(CONFIG_DYNAMIC_DEBUG) | |
| 90 | 91 | #define phylink_dbg(pl, fmt, ...) \ |
| 92 | +do { \ | |
| 93 | + if ((pl)->config->type == PHYLINK_NETDEV) \ | |
| 94 | + netdev_dbg((pl)->netdev, fmt, ##__VA_ARGS__); \ | |
| 95 | + else if ((pl)->config->type == PHYLINK_DEV) \ | |
| 96 | + dev_dbg((pl)->dev, fmt, ##__VA_ARGS__); \ | |
| 97 | +} while (0) | |
| 98 | +#elif defined(DEBUG) | |
| 99 | +#define phylink_dbg(pl, fmt, ...) \ | |
| 91 | 100 | phylink_printk(KERN_DEBUG, pl, fmt, ##__VA_ARGS__) |
| 101 | +#else | |
| 102 | +#define phylink_dbg(pl, fmt, ...) \ | |
| 103 | +({ \ | |
| 104 | + if (0) \ | |
| 105 | + phylink_printk(KERN_DEBUG, pl, fmt, ##__VA_ARGS__); \ | |
| 106 | +}) | |
| 107 | +#endif | |
| 92 | 108 | |
| 93 | 109 | /** |
| 94 | 110 | * phylink_set_port_modes() - set the port type modes in the ethtool mask |
| @@ -327,6 +327,7 @@ static struct phy_driver smsc_phy_driver[] = { · 326 unmodified lines | ||
| 327 | 327 | .name = "SMSC LAN8740", |
| 328 | 328 | |
| 329 | 329 | /* PHY_BASIC_FEATURES */ |
| 330 | + .flags = PHY_RST_AFTER_CLK_EN, | |
| 330 | 331 | |
| 331 | 332 | .probe = smsc_phy_probe, |
| 332 | 333 | |
| @@ -1324,8 +1324,6 @@ static int ppp_dev_init(struct net_device *dev) · 1323 unmodified lines | ||
| 1324 | 1324 | { |
| 1325 | 1325 | struct ppp *ppp; |
| 1326 | 1326 | |
| 1327 | − netdev_lockdep_set_classes(dev); | |
| 1328 | − | |
| 1329 | 1327 | ppp = netdev_priv(dev); |
| 1330 | 1328 | /* Let the netdevice take a reference on the ppp file. This ensures |
| 1331 | 1329 | * that ppp_destroy_interface() won't run before the device gets |
| @@ -1615,7 +1615,6 @@ static int team_init(struct net_device *dev) · 1614 unmodified lines | ||
| 1615 | 1615 | int err; |
| 1616 | 1616 | |
| 1617 | 1617 | team->dev = dev; |
| 1618 | − mutex_init(&team->lock); | |
| 1619 | 1618 | team_set_no_mode(team); |
| 1620 | 1619 | |
| 1621 | 1620 | team->pcpu_stats = netdev_alloc_pcpu_stats(struct team_pcpu_stats); |
| @@ -1642,7 +1641,8 @@ static int team_init(struct net_device *dev) · 20 unmodified lines | ||
| 1642 | 1641 | goto err_options_register; |
| 1643 | 1642 | netif_carrier_off(dev); |
| 1644 | 1643 | |
| 1645 | − netdev_lockdep_set_classes(dev); | |
| 1644 | + lockdep_register_key(&team->team_lock_key); | |
| 1645 | + __mutex_init(&team->lock, "team->team_lock_key", &team->team_lock_key); | |
| 1646 | 1646 | |
| 1647 | 1647 | return 0; |
| 1648 | 1648 | |
| @@ -1673,6 +1673,7 @@ static void team_uninit(struct net_device *dev) · 24 unmodified lines | ||
| 1673 | 1673 | team_queue_override_fini(team); |
| 1674 | 1674 | mutex_unlock(&team->lock); |
| 1675 | 1675 | netdev_change_features(dev); |
| 1676 | + lockdep_unregister_key(&team->team_lock_key); | |
| 1676 | 1677 | } |
| 1677 | 1678 | |
| 1678 | 1679 | static void team_destructor(struct net_device *dev) |
| @@ -1976,8 +1977,15 @@ static int team_del_slave(struct net_device *dev, struct net_device *port_dev) · 297 unmodified lines | ||
| 1976 | 1977 | err = team_port_del(team, port_dev); |
| 1977 | 1978 | mutex_unlock(&team->lock); |
| 1978 | 1979 | |
| 1979 | − if (!err) | |
| 1980 | − netdev_change_features(dev); | |
| 1980 | + if (err) | |
| 1981 | + return err; | |
| 1982 | + | |
| 1983 | + if (netif_is_team_master(port_dev)) { | |
| 1984 | + lockdep_unregister_key(&team->team_lock_key); | |
| 1985 | + lockdep_register_key(&team->team_lock_key); | |
| 1986 | + lockdep_set_class(&team->lock, &team->team_lock_key); | |
| 1987 | + } | |
| 1988 | + netdev_change_features(dev); | |
| 1981 | 1989 | |
| 1982 | 1990 | return err; |
| 1983 | 1991 | } |
| @@ -787,6 +787,13 @@ static const struct usb_device_id products[] = { · 786 unmodified lines | ||
| 787 | 787 | .driver_info = 0, |
| 788 | 788 | }, |
| 789 | 789 | |
| 790 | +/* ThinkPad USB-C Dock Gen 2 (based on Realtek RTL8153) */ | |
| 791 | +{ | |
| 792 | + USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0xa387, USB_CLASS_COMM, | |
| 793 | + USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | |
| 794 | + .driver_info = 0, | |
| 795 | +}, | |
| 796 | + | |
| 790 | 797 | /* NVIDIA Tegra USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */ |
| 791 | 798 | { |
| 792 | 799 | USB_DEVICE_AND_INTERFACE_INFO(NVIDIA_VENDOR_ID, 0x09ff, USB_CLASS_COMM, |
| @@ -578,8 +578,8 @@ static void cdc_ncm_set_dgram_size(struct usbnet *dev, int new_size) · 577 unmodified lines | ||
| 578 | 578 | /* read current mtu value from device */ |
| 579 | 579 | err = usbnet_read_cmd(dev, USB_CDC_GET_MAX_DATAGRAM_SIZE, |
| 580 | 580 | USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE, |
| 581 | − 0, iface_no, &max_datagram_size, 2); | |
| 582 | − if (err < 0) { | |
| 581 | + 0, iface_no, &max_datagram_size, sizeof(max_datagram_size)); | |
| 582 | + if (err < sizeof(max_datagram_size)) { | |
| 583 | 583 | dev_dbg(&dev->intf->dev, "GET_MAX_DATAGRAM_SIZE failed\n"); |
| 584 | 584 | goto out; |
| 585 | 585 | } |
| @@ -590,7 +590,7 @@ static void cdc_ncm_set_dgram_size(struct usbnet *dev, int new_size) · 4 unmodified lines | ||
| 590 | 590 | max_datagram_size = cpu_to_le16(ctx->max_datagram_size); |
| 591 | 591 | err = usbnet_write_cmd(dev, USB_CDC_SET_MAX_DATAGRAM_SIZE, |
| 592 | 592 | USB_TYPE_CLASS | USB_DIR_OUT | USB_RECIP_INTERFACE, |
| 593 | − 0, iface_no, &max_datagram_size, 2); | |
| 593 | + 0, iface_no, &max_datagram_size, sizeof(max_datagram_size)); | |
| 594 | 594 | if (err < 0) |
| 595 | 595 | dev_dbg(&dev->intf->dev, "SET_MAX_DATAGRAM_SIZE failed\n"); |
| 596 | 596 | |
| @@ -1264,8 +1264,11 @@ static void lan78xx_status(struct lan78xx_net *dev, struct urb *urb) · 1263 unmodified lines | ||
| 1264 | 1264 | netif_dbg(dev, link, dev->net, "PHY INTR: 0x%08x\n", intdata); |
| 1265 | 1265 | lan78xx_defer_kevent(dev, EVENT_LINK_RESET); |
| 1266 | 1266 | |
| 1267 | − if (dev->domain_data.phyirq > 0) | |
| 1267 | + if (dev->domain_data.phyirq > 0) { | |
| 1268 | + local_irq_disable(); | |
| 1268 | 1269 | generic_handle_irq(dev->domain_data.phyirq); |
| 1270 | + local_irq_enable(); | |
| 1271 | + } | |
| 1269 | 1272 | } else |
| 1270 | 1273 | netdev_warn(dev->net, |
| 1271 | 1274 | "unexpected interrupt: 0x%08x\n", intdata); |
| @@ -1362,6 +1362,7 @@ static const struct usb_device_id products[] = { · 1361 unmodified lines | ||
| 1362 | 1362 | {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */ |
| 1363 | 1363 | {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */ |
| 1364 | 1364 | {QMI_FIXED_INTF(0x413c, 0x81d7, 0)}, /* Dell Wireless 5821e */ |
| 1365 | + {QMI_FIXED_INTF(0x413c, 0x81e0, 0)}, /* Dell Wireless 5821e with eSIM support*/ | |
| 1365 | 1366 | {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */ |
| 1366 | 1367 | {QMI_FIXED_INTF(0x03f0, 0x9d1d, 1)}, /* HP lt4120 Snapdragon X5 LTE */ |
| 1367 | 1368 | {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */ |
| @@ -5755,6 +5755,7 @@ static const struct usb_device_id rtl8152_table[] = { · 5754 unmodified lines | ||
| 5755 | 5755 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)}, |
| 5756 | 5756 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x720c)}, |
| 5757 | 5757 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7214)}, |
| 5758 | + {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0xa387)}, | |
| 5758 | 5759 | {REALTEK_USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041)}, |
| 5759 | 5760 | {REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff)}, |
| 5760 | 5761 | {REALTEK_USB_DEVICE(VENDOR_ID_TPLINK, 0x0601)}, |
| @@ -865,7 +865,6 @@ static int vrf_dev_init(struct net_device *dev) · 864 unmodified lines | ||
| 865 | 865 | |
| 866 | 866 | /* similarly, oper state is irrelevant; set to up to avoid confusion */ |
| 867 | 867 | dev->operstate = IF_OPER_UP; |
| 868 | − netdev_lockdep_set_classes(dev); | |
| 869 | 868 | return 0; |
| 870 | 869 | |
| 871 | 870 | out_rth: |
| @@ -2487,9 +2487,11 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, · 2486 unmodified lines | ||
| 2487 | 2487 | vni = tunnel_id_to_key32(info->key.tun_id); |
| 2488 | 2488 | ifindex = 0; |
| 2489 | 2489 | dst_cache = &info->dst_cache; |
| 2490 | − if (info->options_len && | |
| 2491 | − info->key.tun_flags & TUNNEL_VXLAN_OPT) | |
| 2490 | + if (info->key.tun_flags & TUNNEL_VXLAN_OPT) { | |
| 2491 | + if (info->options_len < sizeof(*md)) | |
| 2492 | + goto drop; | |
| 2492 | 2493 | md = ip_tunnel_info_opts(info); |
| 2494 | + } | |
| 2493 | 2495 | ttl = info->key.ttl; |
| 2494 | 2496 | tos = info->key.tos; |
| 2495 | 2497 | label = info->key.label; |
| @@ -3566,10 +3568,13 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev, · 1070 unmodified lines | ||
| 3566 | 3568 | { |
| 3567 | 3569 | struct vxlan_net *vn = net_generic(net, vxlan_net_id); |
| 3568 | 3570 | struct vxlan_dev *vxlan = netdev_priv(dev); |
| 3571 | + struct net_device *remote_dev = NULL; | |
| 3569 | 3572 | struct vxlan_fdb *f = NULL; |
| 3570 | 3573 | bool unregister = false; |
| 3574 | + struct vxlan_rdst *dst; | |
| 3571 | 3575 | int err; |
| 3572 | 3576 | |
| 3577 | + dst = &vxlan->default_dst; | |
| 3573 | 3578 | err = vxlan_dev_configure(net, dev, conf, false, extack); |
| 3574 | 3579 | if (err) |
| 3575 | 3580 | return err; |
| @@ -3577,14 +3582,14 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev, · 1 unmodified line | ||
| 3577 | 3582 | dev->ethtool_ops = &vxlan_ethtool_ops; |
| 3578 | 3583 | |
| 3579 | 3584 | /* create an fdb entry for a valid default destination */ |
| 3580 | − if (!vxlan_addr_any(&vxlan->default_dst.remote_ip)) { | |
| 3585 | + if (!vxlan_addr_any(&dst->remote_ip)) { | |
| 3581 | 3586 | err = vxlan_fdb_create(vxlan, all_zeros_mac, |
| 3582 | − &vxlan->default_dst.remote_ip, | |
| 3587 | + &dst->remote_ip, | |
| 3583 | 3588 | NUD_REACHABLE | NUD_PERMANENT, |
| 3584 | 3589 | vxlan->cfg.dst_port, |
| 3585 | − vxlan->default_dst.remote_vni, | |
| 3586 | − vxlan->default_dst.remote_vni, | |
| 3587 | − vxlan->default_dst.remote_ifindex, | |
| 3590 | + dst->remote_vni, | |
| 3591 | + dst->remote_vni, | |
| 3592 | + dst->remote_ifindex, | |
| 3588 | 3593 | NTF_SELF, &f); |
| 3589 | 3594 | if (err) |
| 3590 | 3595 | return err; |
| @@ -3595,26 +3600,41 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev, · 4 unmodified lines | ||
| 3595 | 3600 | goto errout; |
| 3596 | 3601 | unregister = true; |
| 3597 | 3602 | |
| 3603 | + if (dst->remote_ifindex) { | |
| 3604 | + remote_dev = __dev_get_by_index(net, dst->remote_ifindex); | |
| 3605 | + if (!remote_dev) | |
| 3606 | + goto errout; | |
| 3607 | + | |
| 3608 | + err = netdev_upper_dev_link(remote_dev, dev, extack); | |
| 3609 | + if (err) | |
| 3610 | + goto errout; | |
| 3611 | + } | |
| 3612 | + | |
| 3598 | 3613 | err = rtnl_configure_link(dev, NULL); |
| 3599 | 3614 | if (err) |
| 3600 | − goto errout; | |
| 3615 | + goto unlink; | |
| 3601 | 3616 | |
| 3602 | 3617 | if (f) { |
| 3603 | − vxlan_fdb_insert(vxlan, all_zeros_mac, | |
| 3604 | − vxlan->default_dst.remote_vni, f); | |
| 3618 | + vxlan_fdb_insert(vxlan, all_zeros_mac, dst->remote_vni, f); | |
| 3605 | 3619 | |
| 3606 | 3620 | /* notify default fdb entry */ |
| 3607 | 3621 | err = vxlan_fdb_notify(vxlan, f, first_remote_rtnl(f), |
| 3608 | 3622 | RTM_NEWNEIGH, true, extack); |
| 3609 | 3623 | if (err) { |
| 3610 | 3624 | vxlan_fdb_destroy(vxlan, f, false, false); |
| 3625 | + if (remote_dev) | |
| 3626 | + netdev_upper_dev_unlink(remote_dev, dev); | |
| 3611 | 3627 | goto unregister; |
| 3612 | 3628 | } |
| 3613 | 3629 | } |
| 3614 | 3630 | |
| 3615 | 3631 | list_add(&vxlan->next, &vn->vxlan_list); |
| 3632 | + if (remote_dev) | |
| 3633 | + dst->remote_dev = remote_dev; | |
| 3616 | 3634 | return 0; |
| 3617 | − | |
| 3635 | +unlink: | |
| 3636 | + if (remote_dev) | |
| 3637 | + netdev_upper_dev_unlink(remote_dev, dev); | |
| 3618 | 3638 | errout: |
| 3619 | 3639 | /* unregister_netdevice() destroys the default FDB entry with deletion |
| 3620 | 3640 | * notification. But the addition notification was not sent yet, so |
| @@ -3932,11 +3952,12 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], · 311 unmodified lines | ||
| 3932 | 3952 | struct netlink_ext_ack *extack) |
| 3933 | 3953 | { |
| 3934 | 3954 | struct vxlan_dev *vxlan = netdev_priv(dev); |
| 3935 | − struct vxlan_rdst *dst = &vxlan->default_dst; | |
| 3936 | 3955 | struct net_device *lowerdev; |
| 3937 | 3956 | struct vxlan_config conf; |
| 3957 | + struct vxlan_rdst *dst; | |
| 3938 | 3958 | int err; |
| 3939 | 3959 | |
| 3960 | + dst = &vxlan->default_dst; | |
| 3940 | 3961 | err = vxlan_nl2conf(tb, data, dev, &conf, true, extack); |
| 3941 | 3962 | if (err) |
| 3942 | 3963 | return err; |
| @@ -3946,6 +3967,14 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], · 3 unmodified lines | ||
| 3946 | 3967 | if (err) |
| 3947 | 3968 | return err; |
| 3948 | 3969 | |
| 3970 | + if (dst->remote_dev == lowerdev) | |
| 3971 | + lowerdev = NULL; | |
| 3972 | + | |
| 3973 | + err = netdev_adjacent_change_prepare(dst->remote_dev, lowerdev, dev, | |
| 3974 | + extack); | |
| 3975 | + if (err) | |
| 3976 | + return err; | |
| 3977 | + | |
| 3949 | 3978 | /* handle default dst entry */ |
| 3950 | 3979 | if (!vxlan_addr_equal(&conf.remote_ip, &dst->remote_ip)) { |
| 3951 | 3980 | u32 hash_index = fdb_head_index(vxlan, all_zeros_mac, conf.vni); |
| @@ -3962,6 +3991,8 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], · 10 unmodified lines | ||
| 3962 | 3991 | NTF_SELF, true, extack); |
| 3963 | 3992 | if (err) { |
| 3964 | 3993 | spin_unlock_bh(&vxlan->hash_lock[hash_index]); |
| 3994 | + netdev_adjacent_change_abort(dst->remote_dev, | |
| 3995 | + lowerdev, dev); | |
| 3965 | 3996 | return err; |
| 3966 | 3997 | } |
| 3967 | 3998 | } |
| @@ -3979,6 +4010,11 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], · 11 unmodified lines | ||
| 3979 | 4010 | if (conf.age_interval != vxlan->cfg.age_interval) |
| 3980 | 4011 | mod_timer(&vxlan->age_timer, jiffies); |
| 3981 | 4012 | |
| 4013 | + netdev_adjacent_change_commit(dst->remote_dev, lowerdev, dev); | |
| 4014 | + if (lowerdev && lowerdev != dst->remote_dev) { | |
| 4015 | + dst->remote_dev = lowerdev; | |
| 4016 | + netdev_update_lockdep_key(lowerdev); | |
| 4017 | + } | |
| 3982 | 4018 | vxlan_config_apply(dev, &conf, lowerdev, vxlan->net, true); |
| 3983 | 4019 | return 0; |
| 3984 | 4020 | } |
| @@ -3991,6 +4027,8 @@ static void vxlan_dellink(struct net_device *dev, struct list_head *head) · 6 unmodified lines | ||
| 3991 | 4027 | |
| 3992 | 4028 | list_del(&vxlan->next); |
| 3993 | 4029 | unregister_netdevice_queue(dev, head); |
| 4030 | + if (vxlan->default_dst.remote_dev) | |
| 4031 | + netdev_upper_dev_unlink(vxlan->default_dst.remote_dev, dev); | |
| 3994 | 4032 | } |
| 3995 | 4033 | |
| 3996 | 4034 | static size_t vxlan_get_size(const struct net_device *dev) |
| @@ -127,12 +127,12 @@ int i2400m_op_rfkill_sw_toggle(struct wimax_dev *wimax_dev, · 126 unmodified lines | ||
| 127 | 127 | "%d\n", result); |
| 128 | 128 | result = 0; |
| 129 | 129 | error_cmd: |
| 130 | − kfree(cmd); | |
| 131 | 130 | kfree_skb(ack_skb); |
| 132 | 131 | error_msg_to_dev: |
| 133 | 132 | error_alloc: |
| 134 | 133 | d_fnend(4, dev, "(wimax_dev %p state %d) = %d\n", |
| 135 | 134 | wimax_dev, state, result); |
| 135 | + kfree(cmd); | |
| 136 | 136 | return result; |
| 137 | 137 | } |
| 138 | 138 | |
| @@ -520,7 +520,7 @@ struct iwl_scan_dwell { · 519 unmodified lines | ||
| 520 | 520 | } __packed; |
| 521 | 521 | |
| 522 | 522 | /** |
| 523 | − * struct iwl_scan_config | |
| 523 | + * struct iwl_scan_config_v1 | |
| 524 | 524 | * @flags: enum scan_config_flags |
| 525 | 525 | * @tx_chains: valid_tx antenna - ANT_* definitions |
| 526 | 526 | * @rx_chains: valid_rx antenna - ANT_* definitions |
| @@ -552,7 +552,7 @@ struct iwl_scan_config_v1 { · 25 unmodified lines | ||
| 552 | 552 | #define SCAN_LB_LMAC_IDX 0 |
| 553 | 553 | #define SCAN_HB_LMAC_IDX 1 |
| 554 | 554 | |
| 555 | −struct iwl_scan_config { | |
| 555 | +struct iwl_scan_config_v2 { | |
| 556 | 556 | __le32 flags; |
| 557 | 557 | __le32 tx_chains; |
| 558 | 558 | __le32 rx_chains; |
| @@ -564,6 +564,24 @@ struct iwl_scan_config { · 5 unmodified lines | ||
| 564 | 564 | u8 bcast_sta_id; |
| 565 | 565 | u8 channel_flags; |
| 566 | 566 | u8 channel_array[]; |
| 567 | +} __packed; /* SCAN_CONFIG_DB_CMD_API_S_2 */ | |
| 568 | + | |
| 569 | +/** | |
| 570 | + * struct iwl_scan_config | |
| 571 | + * @enable_cam_mode: whether to enable CAM mode. | |
| 572 | + * @enable_promiscouos_mode: whether to enable promiscouos mode | |
| 573 | + * @bcast_sta_id: the index of the station in the fw | |
| 574 | + * @reserved: reserved | |
| 575 | + * @tx_chains: valid_tx antenna - ANT_* definitions | |
| 576 | + * @rx_chains: valid_rx antenna - ANT_* definitions | |
| 577 | + */ | |
| 578 | +struct iwl_scan_config { | |
| 579 | + u8 enable_cam_mode; | |
| 580 | + u8 enable_promiscouos_mode; | |
| 581 | + u8 bcast_sta_id; | |
| 582 | + u8 reserved; | |
| 583 | + __le32 tx_chains; | |
| 584 | + __le32 rx_chains; | |
| 567 | 585 | } __packed; /* SCAN_CONFIG_DB_CMD_API_S_3 */ |
| 568 | 586 | |
| 569 | 587 | /** |
| @@ -288,6 +288,8 @@ typedef unsigned int __bitwise iwl_ucode_tlv_api_t; · 287 unmodified lines | ||
| 288 | 288 | * STA_CONTEXT_DOT11AX_API_S |
| 289 | 289 | * @IWL_UCODE_TLV_CAPA_SAR_TABLE_VER: This ucode supports different sar |
| 290 | 290 | * version tables. |
| 291 | + * @IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG: This ucode supports v3 of | |
| 292 | + * SCAN_CONFIG_DB_CMD_API_S. | |
| 291 | 293 | * |
| 292 | 294 | * @NUM_IWL_UCODE_TLV_API: number of bits used |
| 293 | 295 | */ |
| @@ -321,6 +323,7 @@ enum iwl_ucode_tlv_api { · 27 unmodified lines | ||
| 321 | 323 | IWL_UCODE_TLV_API_WOWLAN_TCP_SYN_WAKE = (__force iwl_ucode_tlv_api_t)53, |
| 322 | 324 | IWL_UCODE_TLV_API_FTM_RTT_ACCURACY = (__force iwl_ucode_tlv_api_t)54, |
| 323 | 325 | IWL_UCODE_TLV_API_SAR_TABLE_VER = (__force iwl_ucode_tlv_api_t)55, |
| 326 | + IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG = (__force iwl_ucode_tlv_api_t)56, | |
| 324 | 327 | IWL_UCODE_TLV_API_ADWELL_HB_DEF_N_AP = (__force iwl_ucode_tlv_api_t)57, |
| 325 | 328 | IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER = (__force iwl_ucode_tlv_api_t)58, |
| 326 | 329 | |
| @@ -279,6 +279,7 @@ · 278 unmodified lines | ||
| 279 | 279 | * Indicates MAC is entering a power-saving sleep power-down. |
| 280 | 280 | * Not a good time to access device-internal resources. |
| 281 | 281 | */ |
| 282 | +#define CSR_GP_CNTRL_REG_FLAG_INIT_DONE (0x00000004) | |
| 282 | 283 | #define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010) |
| 283 | 284 | #define CSR_GP_CNTRL_REG_FLAG_XTAL_ON (0x00000400) |
| 284 | 285 | |
| @@ -449,6 +449,11 @@ enum { · 448 unmodified lines | ||
| 449 | 449 | #define PERSISTENCE_BIT BIT(12) |
| 450 | 450 | #define PREG_WFPM_ACCESS BIT(12) |
| 451 | 451 | |
| 452 | +#define HPM_HIPM_GEN_CFG 0xA03458 | |
| 453 | +#define HPM_HIPM_GEN_CFG_CR_PG_EN BIT(0) | |
| 454 | +#define HPM_HIPM_GEN_CFG_CR_SLP_EN BIT(1) | |
| 455 | +#define HPM_HIPM_GEN_CFG_CR_FORCE_ACTIVE BIT(10) | |
| 456 | + | |
| 452 | 457 | #define UREG_DOORBELL_TO_ISR6 0xA05C04 |
| 453 | 458 | #define UREG_DOORBELL_TO_ISR6_NMI_BIT BIT(0) |
| 454 | 459 | #define UREG_DOORBELL_TO_ISR6_SUSPEND BIT(18) |
| @@ -1405,6 +1405,12 @@ static inline bool iwl_mvm_is_scan_ext_chan_supported(struct iwl_mvm *mvm) · 1404 unmodified lines | ||
| 1405 | 1405 | IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER); |
| 1406 | 1406 | } |
| 1407 | 1407 | |
| 1408 | +static inline bool iwl_mvm_is_reduced_config_scan_supported(struct iwl_mvm *mvm) | |
| 1409 | +{ | |
| 1410 | + return fw_has_api(&mvm->fw->ucode_capa, | |
| 1411 | + IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG); | |
| 1412 | +} | |
| 1413 | + | |
| 1408 | 1414 | static inline bool iwl_mvm_has_new_rx_stats_api(struct iwl_mvm *mvm) |
| 1409 | 1415 | { |
| 1410 | 1416 | return fw_has_api(&mvm->fw->ucode_capa, |
| @@ -1137,11 +1137,11 @@ static void iwl_mvm_fill_scan_config_v1(struct iwl_mvm *mvm, void *config, · 1136 unmodified lines | ||
| 1137 | 1137 | iwl_mvm_fill_channels(mvm, cfg->channel_array, max_channels); |
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | −static void iwl_mvm_fill_scan_config(struct iwl_mvm *mvm, void *config, | |
| 1141 | − u32 flags, u8 channel_flags, | |
| 1142 | − u32 max_channels) | |
| 1140 | +static void iwl_mvm_fill_scan_config_v2(struct iwl_mvm *mvm, void *config, | |
| 1141 | + u32 flags, u8 channel_flags, | |
| 1142 | + u32 max_channels) | |
| 1143 | 1143 | { |
| 1144 | − struct iwl_scan_config *cfg = config; | |
| 1144 | + struct iwl_scan_config_v2 *cfg = config; | |
| 1145 | 1145 | |
| 1146 | 1146 | cfg->flags = cpu_to_le32(flags); |
| 1147 | 1147 | cfg->tx_chains = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm)); |
| @@ -1185,7 +1185,7 @@ static void iwl_mvm_fill_scan_config(struct iwl_mvm *mvm, void *config, · 37 unmodified lines | ||
| 1185 | 1185 | iwl_mvm_fill_channels(mvm, cfg->channel_array, max_channels); |
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | −int iwl_mvm_config_scan(struct iwl_mvm *mvm) | |
| 1188 | +static int iwl_mvm_legacy_config_scan(struct iwl_mvm *mvm) | |
| 1189 | 1189 | { |
| 1190 | 1190 | void *cfg; |
| 1191 | 1191 | int ret, cmd_size; |
| @@ -1217,7 +1217,7 @@ int iwl_mvm_config_scan(struct iwl_mvm *mvm) · 25 unmodified lines | ||
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | 1219 | if (iwl_mvm_cdb_scan_api(mvm)) |
| 1220 | − cmd_size = sizeof(struct iwl_scan_config); | |
| 1220 | + cmd_size = sizeof(struct iwl_scan_config_v2); | |
| 1221 | 1221 | else |
| 1222 | 1222 | cmd_size = sizeof(struct iwl_scan_config_v1); |
| 1223 | 1223 | cmd_size += num_channels; |
| @@ -1254,8 +1254,8 @@ int iwl_mvm_config_scan(struct iwl_mvm *mvm) · 30 unmodified lines | ||
| 1254 | 1254 | flags |= (iwl_mvm_is_scan_fragmented(hb_type)) ? |
| 1255 | 1255 | SCAN_CONFIG_FLAG_SET_LMAC2_FRAGMENTED : |
| 1256 | 1256 | SCAN_CONFIG_FLAG_CLEAR_LMAC2_FRAGMENTED; |
| 1257 | − iwl_mvm_fill_scan_config(mvm, cfg, flags, channel_flags, | |
| 1258 | − num_channels); | |
| 1257 | + iwl_mvm_fill_scan_config_v2(mvm, cfg, flags, channel_flags, | |
| 1258 | + num_channels); | |
| 1259 | 1259 | } else { |
| 1260 | 1260 | iwl_mvm_fill_scan_config_v1(mvm, cfg, flags, channel_flags, |
| 1261 | 1261 | num_channels); |
| @@ -1277,6 +1277,30 @@ int iwl_mvm_config_scan(struct iwl_mvm *mvm) · 15 unmodified lines | ||
| 1277 | 1277 | return ret; |
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | +int iwl_mvm_config_scan(struct iwl_mvm *mvm) | |
| 1281 | +{ | |
| 1282 | + struct iwl_scan_config cfg; | |
| 1283 | + struct iwl_host_cmd cmd = { | |
| 1284 | + .id = iwl_cmd_id(SCAN_CFG_CMD, IWL_ALWAYS_LONG_GROUP, 0), | |
| 1285 | + .len[0] = sizeof(cfg), | |
| 1286 | + .data[0] = &cfg, | |
| 1287 | + .dataflags[0] = IWL_HCMD_DFL_NOCOPY, | |
| 1288 | + }; | |
| 1289 | + | |
| 1290 | + if (!iwl_mvm_is_reduced_config_scan_supported(mvm)) | |
| 1291 | + return iwl_mvm_legacy_config_scan(mvm); | |
| 1292 | + | |
| 1293 | + memset(&cfg, 0, sizeof(cfg)); | |
| 1294 | + | |
| 1295 | + cfg.bcast_sta_id = mvm->aux_sta.sta_id; | |
| 1296 | + cfg.tx_chains = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm)); | |
| 1297 | + cfg.rx_chains = cpu_to_le32(iwl_mvm_scan_rx_ant(mvm)); | |
| 1298 | + | |
| 1299 | + IWL_DEBUG_SCAN(mvm, "Sending UMAC scan config\n"); | |
| 1300 | + | |
| 1301 | + return iwl_mvm_send_cmd(mvm, &cmd); | |
| 1302 | +} | |
| 1303 | + | |
| 1280 | 1304 | static int iwl_mvm_scan_uid_by_status(struct iwl_mvm *mvm, int status) |
| 1281 | 1305 | { |
| 1282 | 1306 | int i; |
| @@ -1482,6 +1482,13 @@ static void iwl_mvm_realloc_queues_after_restart(struct iwl_mvm *mvm, · 1481 unmodified lines | ||
| 1482 | 1482 | mvm_sta->sta_id, i); |
| 1483 | 1483 | txq_id = iwl_mvm_tvqm_enable_txq(mvm, mvm_sta->sta_id, |
| 1484 | 1484 | i, wdg); |
| 1485 | + /* | |
| 1486 | + * on failures, just set it to IWL_MVM_INVALID_QUEUE | |
| 1487 | + * to try again later, we have no other good way of | |
| 1488 | + * failing here | |
| 1489 | + */ | |
| 1490 | + if (txq_id < 0) | |
| 1491 | + txq_id = IWL_MVM_INVALID_QUEUE; | |
| 1485 | 1492 | tid_data->txq_id = txq_id; |
| 1486 | 1493 | |
| 1487 | 1494 | /* |
| @@ -1950,30 +1957,73 @@ void iwl_mvm_dealloc_int_sta(struct iwl_mvm *mvm, struct iwl_mvm_int_sta *sta) · 462 unmodified lines | ||
| 1950 | 1957 | sta->sta_id = IWL_MVM_INVALID_STA; |
| 1951 | 1958 | } |
| 1952 | 1959 | |
| 1953 | −static void iwl_mvm_enable_aux_snif_queue(struct iwl_mvm *mvm, u16 *queue, | |
| 1960 | +static void iwl_mvm_enable_aux_snif_queue(struct iwl_mvm *mvm, u16 queue, | |
| 1954 | 1961 | u8 sta_id, u8 fifo) |
| 1955 | 1962 | { |
| 1956 | 1963 | unsigned int wdg_timeout = iwlmvm_mod_params.tfd_q_hang_detect ? |
| 1957 | 1964 | mvm->trans->trans_cfg->base_params->wd_timeout : |
| 1958 | 1965 | IWL_WATCHDOG_DISABLED; |
| 1966 | + struct iwl_trans_txq_scd_cfg cfg = { | |
| 1967 | + .fifo = fifo, | |
| 1968 | + .sta_id = sta_id, | |
| 1969 | + .tid = IWL_MAX_TID_COUNT, | |
| 1970 | + .aggregate = false, | |
| 1971 | + .frame_limit = IWL_FRAME_LIMIT, | |
| 1972 | + }; | |
| 1973 | + | |
| 1974 | + WARN_ON(iwl_mvm_has_new_tx_api(mvm)); | |
| 1975 | + | |
| 1976 | + iwl_mvm_enable_txq(mvm, NULL, queue, 0, &cfg, wdg_timeout); | |
| 1977 | +} | |
| 1978 | + | |
| 1979 | +static int iwl_mvm_enable_aux_snif_queue_tvqm(struct iwl_mvm *mvm, u8 sta_id) | |
| 1980 | +{ | |
| 1981 | + unsigned int wdg_timeout = iwlmvm_mod_params.tfd_q_hang_detect ? | |
| 1982 | + mvm->trans->trans_cfg->base_params->wd_timeout : | |
| 1983 | + IWL_WATCHDOG_DISABLED; | |
| 1984 | + | |
| 1985 | + WARN_ON(!iwl_mvm_has_new_tx_api(mvm)); | |
| 1986 | + | |
| 1987 | + return iwl_mvm_tvqm_enable_txq(mvm, sta_id, IWL_MAX_TID_COUNT, | |
| 1988 | + wdg_timeout); | |
| 1989 | +} | |
| 1959 | 1990 | |
| 1991 | +static int iwl_mvm_add_int_sta_with_queue(struct iwl_mvm *mvm, int macidx, | |
| 1992 | + int maccolor, | |
| 1993 | + struct iwl_mvm_int_sta *sta, | |
| 1994 | + u16 *queue, int fifo) | |
| 1995 | +{ | |
| 1996 | + int ret; | |
| 1997 | + | |
| 1998 | + /* Map queue to fifo - needs to happen before adding station */ | |
| 1999 | + if (!iwl_mvm_has_new_tx_api(mvm)) | |
| 2000 | + iwl_mvm_enable_aux_snif_queue(mvm, *queue, sta->sta_id, fifo); | |
| 2001 | + | |
| 2002 | + ret = iwl_mvm_add_int_sta_common(mvm, sta, NULL, macidx, maccolor); | |
| 2003 | + if (ret) { | |
| 2004 | + if (!iwl_mvm_has_new_tx_api(mvm)) | |
| 2005 | + iwl_mvm_disable_txq(mvm, NULL, *queue, | |
| 2006 | + IWL_MAX_TID_COUNT, 0); | |
| 2007 | + return ret; | |
| 2008 | + } | |
| 2009 | + | |
| 2010 | + /* | |
| 2011 | + * For 22000 firmware and on we cannot add queue to a station unknown | |
| 2012 | + * to firmware so enable queue here - after the station was added | |
| 2013 | + */ | |
| 1960 | 2014 | if (iwl_mvm_has_new_tx_api(mvm)) { |
| 1961 | − int tvqm_queue = | |
| 1962 | − iwl_mvm_tvqm_enable_txq(mvm, sta_id, | |
| 1963 | − IWL_MAX_TID_COUNT, | |
| 1964 | − wdg_timeout); | |
| 1965 | − *queue = tvqm_queue; | |
| 1966 | − } else { | |
| 1967 | − struct iwl_trans_txq_scd_cfg cfg = { | |
| 1968 | − .fifo = fifo, | |
| 1969 | − .sta_id = sta_id, | |
| 1970 | − .tid = IWL_MAX_TID_COUNT, | |
| 1971 | − .aggregate = false, | |
| 1972 | − .frame_limit = IWL_FRAME_LIMIT, | |
| 1973 | − }; | |
| 2015 | + int txq; | |
| 1974 | 2016 | |
| 1975 | − iwl_mvm_enable_txq(mvm, NULL, *queue, 0, &cfg, wdg_timeout); | |
| 2017 | + txq = iwl_mvm_enable_aux_snif_queue_tvqm(mvm, sta->sta_id); | |
| 2018 | + if (txq < 0) { | |
| 2019 | + iwl_mvm_rm_sta_common(mvm, sta->sta_id); | |
| 2020 | + return txq; | |
| 2021 | + } | |
| 2022 | + | |
| 2023 | + *queue = txq; | |
| 1976 | 2024 | } |
| 2025 | + | |
| 2026 | + return 0; | |
| 1977 | 2027 | } |
| 1978 | 2028 | |
| 1979 | 2029 | int iwl_mvm_add_aux_sta(struct iwl_mvm *mvm) |
| @@ -1989,59 +2039,26 @@ int iwl_mvm_add_aux_sta(struct iwl_mvm *mvm) · 9 unmodified lines | ||
| 1989 | 2039 | if (ret) |
| 1990 | 2040 | return ret; |
| 1991 | 2041 | |
| 1992 | − /* Map Aux queue to fifo - needs to happen before adding Aux station */ | |
| 1993 | − if (!iwl_mvm_has_new_tx_api(mvm)) | |
| 1994 | − iwl_mvm_enable_aux_snif_queue(mvm, &mvm->aux_queue, | |
| 1995 | − mvm->aux_sta.sta_id, | |
| 1996 | − IWL_MVM_TX_FIFO_MCAST); | |
| 1997 | − | |
| 1998 | − ret = iwl_mvm_add_int_sta_common(mvm, &mvm->aux_sta, NULL, | |
| 1999 | − MAC_INDEX_AUX, 0); | |
| 2042 | + ret = iwl_mvm_add_int_sta_with_queue(mvm, MAC_INDEX_AUX, 0, | |
| 2043 | + &mvm->aux_sta, &mvm->aux_queue, | |
| 2044 | + IWL_MVM_TX_FIFO_MCAST); | |
| 2000 | 2045 | if (ret) { |
| 2001 | 2046 | iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta); |
| 2002 | 2047 | return ret; |
| 2003 | 2048 | } |
| 2004 | 2049 | |
| 2005 | − /* | |
| 2006 | − * For 22000 firmware and on we cannot add queue to a station unknown | |
| 2007 | − * to firmware so enable queue here - after the station was added | |
| 2008 | − */ | |
| 2009 | − if (iwl_mvm_has_new_tx_api(mvm)) | |
| 2010 | − iwl_mvm_enable_aux_snif_queue(mvm, &mvm->aux_queue, | |
| 2011 | − mvm->aux_sta.sta_id, | |
| 2012 | − IWL_MVM_TX_FIFO_MCAST); | |
| 2013 | − | |
| 2014 | 2050 | return 0; |
| 2015 | 2051 | } |
| 2016 | 2052 | |
| 2017 | 2053 | int iwl_mvm_add_snif_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) |
| 2018 | 2054 | { |
| 2019 | 2055 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 2020 | − int ret; | |
| 2021 | 2056 | |
| 2022 | 2057 | lockdep_assert_held(&mvm->mutex); |
| 2023 | 2058 | |
| 2024 | − /* Map snif queue to fifo - must happen before adding snif station */ | |
| 2025 | − if (!iwl_mvm_has_new_tx_api(mvm)) | |
| 2026 | − iwl_mvm_enable_aux_snif_queue(mvm, &mvm->snif_queue, | |
| 2027 | − mvm->snif_sta.sta_id, | |
| 2059 | + return iwl_mvm_add_int_sta_with_queue(mvm, mvmvif->id, mvmvif->color, | |
| 2060 | + &mvm->snif_sta, &mvm->snif_queue, | |
| 2028 | 2061 | IWL_MVM_TX_FIFO_BE); |
| 2029 | − | |
| 2030 | − ret = iwl_mvm_add_int_sta_common(mvm, &mvm->snif_sta, vif->addr, | |
| 2031 | − mvmvif->id, 0); | |
| 2032 | − if (ret) | |
| 2033 | − return ret; | |
| 2034 | − | |
| 2035 | − /* | |
| 2036 | − * For 22000 firmware and on we cannot add queue to a station unknown | |
| 2037 | − * to firmware so enable queue here - after the station was added | |
| 2038 | − */ | |
| 2039 | − if (iwl_mvm_has_new_tx_api(mvm)) | |
| 2040 | − iwl_mvm_enable_aux_snif_queue(mvm, &mvm->snif_queue, | |
| 2041 | − mvm->snif_sta.sta_id, | |
| 2042 | − IWL_MVM_TX_FIFO_BE); | |
| 2043 | − | |
| 2044 | − return 0; | |
| 2045 | 2062 | } |
| 2046 | 2063 | |
| 2047 | 2064 | int iwl_mvm_rm_snif_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) |
| @@ -2133,6 +2150,10 @@ int iwl_mvm_send_add_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) · 85 unmodified lines | ||
| 2133 | 2150 | queue = iwl_mvm_tvqm_enable_txq(mvm, bsta->sta_id, |
| 2134 | 2151 | IWL_MAX_TID_COUNT, |
| 2135 | 2152 | wdg_timeout); |
| 2153 | + if (queue < 0) { | |
| 2154 | + iwl_mvm_rm_sta_common(mvm, bsta->sta_id); | |
| 2155 | + return queue; | |
| 2156 | + } | |
| 2136 | 2157 | |
| 2137 | 2158 | if (vif->type == NL80211_IFTYPE_AP || |
| 2138 | 2159 | vif->type == NL80211_IFTYPE_ADHOC) |
| @@ -2307,10 +2328,8 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) · 168 unmodified lines | ||
| 2307 | 2328 | } |
| 2308 | 2329 | ret = iwl_mvm_add_int_sta_common(mvm, msta, maddr, |
| 2309 | 2330 | mvmvif->id, mvmvif->color); |
| 2310 | − if (ret) { | |
| 2311 | − iwl_mvm_dealloc_int_sta(mvm, msta); | |
| 2312 | − return ret; | |
| 2313 | − } | |
| 2331 | + if (ret) | |
| 2332 | + goto err; | |
| 2314 | 2333 | |
| 2315 | 2334 | /* |
| 2316 | 2335 | * Enable cab queue after the ADD_STA command is sent. |
| @@ -2323,6 +2342,10 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) · 6 unmodified lines | ||
| 2323 | 2342 | int queue = iwl_mvm_tvqm_enable_txq(mvm, msta->sta_id, |
| 2324 | 2343 | 0, |
| 2325 | 2344 | timeout); |
| 2345 | + if (queue < 0) { | |
| 2346 | + ret = queue; | |
| 2347 | + goto err; | |
| 2348 | + } | |
| 2326 | 2349 | mvmvif->cab_queue = queue; |
| 2327 | 2350 | } else if (!fw_has_api(&mvm->fw->ucode_capa, |
| 2328 | 2351 | IWL_UCODE_TLV_API_STA_TYPE)) |
| @@ -2330,6 +2353,9 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) · 1 unmodified line | ||
| 2330 | 2353 | timeout); |
| 2331 | 2354 | |
| 2332 | 2355 | return 0; |
| 2356 | +err: | |
| 2357 | + iwl_mvm_dealloc_int_sta(mvm, msta); | |
| 2358 | + return ret; | |
| 2333 | 2359 | } |
| 2334 | 2360 | |
| 2335 | 2361 | static int __iwl_mvm_remove_sta_key(struct iwl_mvm *mvm, u8 sta_id, |
| @@ -573,20 +573,20 @@ static const struct pci_device_id iwl_hw_card_ids[] = { · 572 unmodified lines | ||
| 573 | 573 | {IWL_PCI_DEVICE(0x2526, 0x0034, iwl9560_2ac_cfg)}, |
| 574 | 574 | {IWL_PCI_DEVICE(0x2526, 0x0038, iwl9560_2ac_160_cfg)}, |
| 575 | 575 | {IWL_PCI_DEVICE(0x2526, 0x003C, iwl9560_2ac_160_cfg)}, |
| 576 | − {IWL_PCI_DEVICE(0x2526, 0x0060, iwl9460_2ac_cfg)}, | |
| 577 | − {IWL_PCI_DEVICE(0x2526, 0x0064, iwl9460_2ac_cfg)}, | |
| 578 | − {IWL_PCI_DEVICE(0x2526, 0x00A0, iwl9460_2ac_cfg)}, | |
| 579 | − {IWL_PCI_DEVICE(0x2526, 0x00A4, iwl9460_2ac_cfg)}, | |
| 576 | + {IWL_PCI_DEVICE(0x2526, 0x0060, iwl9461_2ac_cfg_soc)}, | |
| 577 | + {IWL_PCI_DEVICE(0x2526, 0x0064, iwl9461_2ac_cfg_soc)}, | |
| 578 | + {IWL_PCI_DEVICE(0x2526, 0x00A0, iwl9462_2ac_cfg_soc)}, | |
| 579 | + {IWL_PCI_DEVICE(0x2526, 0x00A4, iwl9462_2ac_cfg_soc)}, | |
| 580 | 580 | {IWL_PCI_DEVICE(0x2526, 0x0210, iwl9260_2ac_cfg)}, |
| 581 | 581 | {IWL_PCI_DEVICE(0x2526, 0x0214, iwl9260_2ac_cfg)}, |
| 582 | 582 | {IWL_PCI_DEVICE(0x2526, 0x0230, iwl9560_2ac_cfg)}, |
| 583 | 583 | {IWL_PCI_DEVICE(0x2526, 0x0234, iwl9560_2ac_cfg)}, |
| 584 | 584 | {IWL_PCI_DEVICE(0x2526, 0x0238, iwl9560_2ac_cfg)}, |
| 585 | 585 | {IWL_PCI_DEVICE(0x2526, 0x023C, iwl9560_2ac_cfg)}, |
| 586 | − {IWL_PCI_DEVICE(0x2526, 0x0260, iwl9460_2ac_cfg)}, | |
| 586 | + {IWL_PCI_DEVICE(0x2526, 0x0260, iwl9461_2ac_cfg_soc)}, | |
| 587 | 587 | {IWL_PCI_DEVICE(0x2526, 0x0264, iwl9461_2ac_cfg_soc)}, |
| 588 | − {IWL_PCI_DEVICE(0x2526, 0x02A0, iwl9460_2ac_cfg)}, | |
| 589 | − {IWL_PCI_DEVICE(0x2526, 0x02A4, iwl9460_2ac_cfg)}, | |
| 588 | + {IWL_PCI_DEVICE(0x2526, 0x02A0, iwl9462_2ac_cfg_soc)}, | |
| 589 | + {IWL_PCI_DEVICE(0x2526, 0x02A4, iwl9462_2ac_cfg_soc)}, | |
| 590 | 590 | {IWL_PCI_DEVICE(0x2526, 0x1010, iwl9260_2ac_cfg)}, |
| 591 | 591 | {IWL_PCI_DEVICE(0x2526, 0x1030, iwl9560_2ac_cfg)}, |
| 592 | 592 | {IWL_PCI_DEVICE(0x2526, 0x1210, iwl9260_2ac_cfg)}, |
| @@ -603,7 +603,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = { · 10 unmodified lines | ||
| 603 | 603 | {IWL_PCI_DEVICE(0x2526, 0x401C, iwl9260_2ac_160_cfg)}, |
| 604 | 604 | {IWL_PCI_DEVICE(0x2526, 0x4030, iwl9560_2ac_160_cfg)}, |
| 605 | 605 | {IWL_PCI_DEVICE(0x2526, 0x4034, iwl9560_2ac_160_cfg_soc)}, |
| 606 | − {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9460_2ac_cfg)}, | |
| 606 | + {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9462_2ac_cfg_soc)}, | |
| 607 | 607 | {IWL_PCI_DEVICE(0x2526, 0x4234, iwl9560_2ac_cfg_soc)}, |
| 608 | 608 | {IWL_PCI_DEVICE(0x2526, 0x42A4, iwl9462_2ac_cfg_soc)}, |
| 609 | 609 | {IWL_PCI_DEVICE(0x2526, 0x6010, iwl9260_2ac_160_cfg)}, |
| @@ -618,60 +618,61 @@ static const struct pci_device_id iwl_hw_card_ids[] = { · 8 unmodified lines | ||
| 618 | 618 | {IWL_PCI_DEVICE(0x271B, 0x0210, iwl9160_2ac_cfg)}, |
| 619 | 619 | {IWL_PCI_DEVICE(0x271B, 0x0214, iwl9260_2ac_cfg)}, |
| 620 | 620 | {IWL_PCI_DEVICE(0x271C, 0x0214, iwl9260_2ac_cfg)}, |
| 621 | − {IWL_PCI_DEVICE(0x2720, 0x0034, iwl9560_2ac_160_cfg)}, | |
| 622 | − {IWL_PCI_DEVICE(0x2720, 0x0038, iwl9560_2ac_160_cfg)}, | |
| 623 | − {IWL_PCI_DEVICE(0x2720, 0x003C, iwl9560_2ac_160_cfg)}, | |
| 624 | − {IWL_PCI_DEVICE(0x2720, 0x0060, iwl9461_2ac_cfg_soc)}, | |
| 625 | − {IWL_PCI_DEVICE(0x2720, 0x0064, iwl9461_2ac_cfg_soc)}, | |
| 626 | − {IWL_PCI_DEVICE(0x2720, 0x00A0, iwl9462_2ac_cfg_soc)}, | |
| 627 | − {IWL_PCI_DEVICE(0x2720, 0x00A4, iwl9462_2ac_cfg_soc)}, | |
| 628 | − {IWL_PCI_DEVICE(0x2720, 0x0230, iwl9560_2ac_cfg)}, | |
| 629 | − {IWL_PCI_DEVICE(0x2720, 0x0234, iwl9560_2ac_cfg)}, | |
| 630 | − {IWL_PCI_DEVICE(0x2720, 0x0238, iwl9560_2ac_cfg)}, | |
| 631 | − {IWL_PCI_DEVICE(0x2720, 0x023C, iwl9560_2ac_cfg)}, | |
| 632 | − {IWL_PCI_DEVICE(0x2720, 0x0260, iwl9461_2ac_cfg_soc)}, | |
| 633 | − {IWL_PCI_DEVICE(0x2720, 0x0264, iwl9461_2ac_cfg_soc)}, | |
| 634 | − {IWL_PCI_DEVICE(0x2720, 0x02A0, iwl9462_2ac_cfg_soc)}, | |
| 635 | − {IWL_PCI_DEVICE(0x2720, 0x02A4, iwl9462_2ac_cfg_soc)}, | |
| 636 | − {IWL_PCI_DEVICE(0x2720, 0x1010, iwl9260_2ac_cfg)}, | |
| 637 | − {IWL_PCI_DEVICE(0x2720, 0x1030, iwl9560_2ac_cfg_soc)}, | |
| 638 | − {IWL_PCI_DEVICE(0x2720, 0x1210, iwl9260_2ac_cfg)}, | |
| 639 | − {IWL_PCI_DEVICE(0x2720, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, | |
| 640 | − {IWL_PCI_DEVICE(0x2720, 0x1552, iwl9560_killer_2ac_cfg_soc)}, | |
| 641 | − {IWL_PCI_DEVICE(0x2720, 0x2030, iwl9560_2ac_160_cfg_soc)}, | |
| 642 | − {IWL_PCI_DEVICE(0x2720, 0x2034, iwl9560_2ac_160_cfg_soc)}, | |
| 643 | − {IWL_PCI_DEVICE(0x2720, 0x4030, iwl9560_2ac_160_cfg)}, | |
| 644 | − {IWL_PCI_DEVICE(0x2720, 0x4034, iwl9560_2ac_160_cfg_soc)}, | |
| 645 | − {IWL_PCI_DEVICE(0x2720, 0x40A4, iwl9462_2ac_cfg_soc)}, | |
| 646 | − {IWL_PCI_DEVICE(0x2720, 0x4234, iwl9560_2ac_cfg_soc)}, | |
| 647 | − {IWL_PCI_DEVICE(0x2720, 0x42A4, iwl9462_2ac_cfg_soc)}, | |
| 648 | − | |
| 649 | − {IWL_PCI_DEVICE(0x30DC, 0x0030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 650 | − {IWL_PCI_DEVICE(0x30DC, 0x0034, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 651 | − {IWL_PCI_DEVICE(0x30DC, 0x0038, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 652 | − {IWL_PCI_DEVICE(0x30DC, 0x003C, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 653 | − {IWL_PCI_DEVICE(0x30DC, 0x0060, iwl9461_2ac_cfg_qu_b0_jf_b0)}, | |
| 654 | − {IWL_PCI_DEVICE(0x30DC, 0x0064, iwl9461_2ac_cfg_qu_b0_jf_b0)}, | |
| 655 | − {IWL_PCI_DEVICE(0x30DC, 0x00A0, iwl9462_2ac_cfg_qu_b0_jf_b0)}, | |
| 656 | − {IWL_PCI_DEVICE(0x30DC, 0x00A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, | |
| 657 | − {IWL_PCI_DEVICE(0x30DC, 0x0230, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 658 | − {IWL_PCI_DEVICE(0x30DC, 0x0234, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 659 | − {IWL_PCI_DEVICE(0x30DC, 0x0238, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 660 | − {IWL_PCI_DEVICE(0x30DC, 0x023C, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 661 | − {IWL_PCI_DEVICE(0x30DC, 0x0260, iwl9461_2ac_cfg_qu_b0_jf_b0)}, | |
| 662 | − {IWL_PCI_DEVICE(0x30DC, 0x0264, iwl9461_2ac_cfg_qu_b0_jf_b0)}, | |
| 663 | − {IWL_PCI_DEVICE(0x30DC, 0x02A0, iwl9462_2ac_cfg_qu_b0_jf_b0)}, | |
| 664 | − {IWL_PCI_DEVICE(0x30DC, 0x02A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, | |
| 665 | − {IWL_PCI_DEVICE(0x30DC, 0x1030, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 666 | − {IWL_PCI_DEVICE(0x30DC, 0x1551, killer1550s_2ac_cfg_qu_b0_jf_b0)}, | |
| 667 | − {IWL_PCI_DEVICE(0x30DC, 0x1552, killer1550i_2ac_cfg_qu_b0_jf_b0)}, | |
| 668 | − {IWL_PCI_DEVICE(0x30DC, 0x2030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 669 | − {IWL_PCI_DEVICE(0x30DC, 0x2034, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 670 | − {IWL_PCI_DEVICE(0x30DC, 0x4030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 671 | − {IWL_PCI_DEVICE(0x30DC, 0x4034, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 672 | − {IWL_PCI_DEVICE(0x30DC, 0x40A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, | |
| 673 | − {IWL_PCI_DEVICE(0x30DC, 0x4234, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 674 | − {IWL_PCI_DEVICE(0x30DC, 0x42A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, | |
| 621 | + | |
| 622 | + {IWL_PCI_DEVICE(0x2720, 0x0034, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 623 | + {IWL_PCI_DEVICE(0x2720, 0x0038, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 624 | + {IWL_PCI_DEVICE(0x2720, 0x003C, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 625 | + {IWL_PCI_DEVICE(0x2720, 0x0060, iwl9461_2ac_cfg_qu_b0_jf_b0)}, | |
| 626 | + {IWL_PCI_DEVICE(0x2720, 0x0064, iwl9461_2ac_cfg_qu_b0_jf_b0)}, | |
| 627 | + {IWL_PCI_DEVICE(0x2720, 0x00A0, iwl9462_2ac_cfg_qu_b0_jf_b0)}, | |
| 628 | + {IWL_PCI_DEVICE(0x2720, 0x00A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, | |
| 629 | + {IWL_PCI_DEVICE(0x2720, 0x0230, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 630 | + {IWL_PCI_DEVICE(0x2720, 0x0234, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 631 | + {IWL_PCI_DEVICE(0x2720, 0x0238, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 632 | + {IWL_PCI_DEVICE(0x2720, 0x023C, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 633 | + {IWL_PCI_DEVICE(0x2720, 0x0260, iwl9461_2ac_cfg_qu_b0_jf_b0)}, | |
| 634 | + {IWL_PCI_DEVICE(0x2720, 0x0264, iwl9461_2ac_cfg_qu_b0_jf_b0)}, | |
| 635 | + {IWL_PCI_DEVICE(0x2720, 0x02A0, iwl9462_2ac_cfg_qu_b0_jf_b0)}, | |
| 636 | + {IWL_PCI_DEVICE(0x2720, 0x02A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, | |
| 637 | + {IWL_PCI_DEVICE(0x2720, 0x1030, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 638 | + {IWL_PCI_DEVICE(0x2720, 0x1551, killer1550s_2ac_cfg_qu_b0_jf_b0)}, | |
| 639 | + {IWL_PCI_DEVICE(0x2720, 0x1552, killer1550i_2ac_cfg_qu_b0_jf_b0)}, | |
| 640 | + {IWL_PCI_DEVICE(0x2720, 0x2030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 641 | + {IWL_PCI_DEVICE(0x2720, 0x2034, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 642 | + {IWL_PCI_DEVICE(0x2720, 0x4030, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 643 | + {IWL_PCI_DEVICE(0x2720, 0x4034, iwl9560_2ac_160_cfg_qu_b0_jf_b0)}, | |
| 644 | + {IWL_PCI_DEVICE(0x2720, 0x40A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, | |
| 645 | + {IWL_PCI_DEVICE(0x2720, 0x4234, iwl9560_2ac_cfg_qu_b0_jf_b0)}, | |
| 646 | + {IWL_PCI_DEVICE(0x2720, 0x42A4, iwl9462_2ac_cfg_qu_b0_jf_b0)}, | |
| 647 | + | |
| 648 | + {IWL_PCI_DEVICE(0x30DC, 0x0030, iwl9560_2ac_160_cfg_soc)}, | |
| 649 | + {IWL_PCI_DEVICE(0x30DC, 0x0034, iwl9560_2ac_cfg_soc)}, | |
| 650 | + {IWL_PCI_DEVICE(0x30DC, 0x0038, iwl9560_2ac_160_cfg_soc)}, | |
| 651 | + {IWL_PCI_DEVICE(0x30DC, 0x003C, iwl9560_2ac_160_cfg_soc)}, | |
| 652 | + {IWL_PCI_DEVICE(0x30DC, 0x0060, iwl9460_2ac_cfg_soc)}, | |
| 653 | + {IWL_PCI_DEVICE(0x30DC, 0x0064, iwl9461_2ac_cfg_soc)}, | |
| 654 | + {IWL_PCI_DEVICE(0x30DC, 0x00A0, iwl9462_2ac_cfg_soc)}, | |
| 655 | + {IWL_PCI_DEVICE(0x30DC, 0x00A4, iwl9462_2ac_cfg_soc)}, | |
| 656 | + {IWL_PCI_DEVICE(0x30DC, 0x0230, iwl9560_2ac_cfg_soc)}, | |
| 657 | + {IWL_PCI_DEVICE(0x30DC, 0x0234, iwl9560_2ac_cfg_soc)}, | |
| 658 | + {IWL_PCI_DEVICE(0x30DC, 0x0238, iwl9560_2ac_cfg_soc)}, | |
| 659 | + {IWL_PCI_DEVICE(0x30DC, 0x023C, iwl9560_2ac_cfg_soc)}, | |
| 660 | + {IWL_PCI_DEVICE(0x30DC, 0x0260, iwl9461_2ac_cfg_soc)}, | |
| 661 | + {IWL_PCI_DEVICE(0x30DC, 0x0264, iwl9461_2ac_cfg_soc)}, | |
| 662 | + {IWL_PCI_DEVICE(0x30DC, 0x02A0, iwl9462_2ac_cfg_soc)}, | |
| 663 | + {IWL_PCI_DEVICE(0x30DC, 0x02A4, iwl9462_2ac_cfg_soc)}, | |
| 664 | + {IWL_PCI_DEVICE(0x30DC, 0x1010, iwl9260_2ac_cfg)}, | |
| 665 | + {IWL_PCI_DEVICE(0x30DC, 0x1030, iwl9560_2ac_cfg_soc)}, | |
| 666 | + {IWL_PCI_DEVICE(0x30DC, 0x1210, iwl9260_2ac_cfg)}, | |
| 667 | + {IWL_PCI_DEVICE(0x30DC, 0x1551, iwl9560_killer_s_2ac_cfg_soc)}, | |
| 668 | + {IWL_PCI_DEVICE(0x30DC, 0x1552, iwl9560_killer_2ac_cfg_soc)}, | |
| 669 | + {IWL_PCI_DEVICE(0x30DC, 0x2030, iwl9560_2ac_160_cfg_soc)}, | |
| 670 | + {IWL_PCI_DEVICE(0x30DC, 0x2034, iwl9560_2ac_160_cfg_soc)}, | |
| 671 | + {IWL_PCI_DEVICE(0x30DC, 0x4030, iwl9560_2ac_160_cfg_soc)}, | |
| 672 | + {IWL_PCI_DEVICE(0x30DC, 0x4034, iwl9560_2ac_160_cfg_soc)}, | |
| 673 | + {IWL_PCI_DEVICE(0x30DC, 0x40A4, iwl9462_2ac_cfg_soc)}, | |
| 674 | + {IWL_PCI_DEVICE(0x30DC, 0x4234, iwl9560_2ac_cfg_soc)}, | |
| 675 | + {IWL_PCI_DEVICE(0x30DC, 0x42A4, iwl9462_2ac_cfg_soc)}, | |
| 675 | 676 | |
| 676 | 677 | {IWL_PCI_DEVICE(0x31DC, 0x0030, iwl9560_2ac_160_cfg_shared_clk)}, |
| 677 | 678 | {IWL_PCI_DEVICE(0x31DC, 0x0034, iwl9560_2ac_cfg_shared_clk)}, |
| @@ -1067,11 +1068,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 389 unmodified lines | ||
| 1067 | 1068 | } |
| 1068 | 1069 | } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(iwl_trans->hw_rf_id) == |
| 1069 | 1070 | CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR) && |
| 1070 | − ((cfg != &iwl_ax200_cfg_cc && | |
| 1071 | − cfg != &killer1650x_2ax_cfg && | |
| 1072 | − cfg != &killer1650w_2ax_cfg && | |
| 1073 | − cfg != &iwl_ax201_cfg_quz_hr) || | |
| 1074 | − iwl_trans->hw_rev == CSR_HW_REV_TYPE_QNJ_B0)) { | |
| 1071 | + iwl_trans->hw_rev == CSR_HW_REV_TYPE_QNJ_B0) { | |
| 1075 | 1072 | u32 hw_status; |
| 1076 | 1073 | |
| 1077 | 1074 | hw_status = iwl_read_prph(iwl_trans, UMAG_GEN_HW_STATUS); |
| @@ -57,6 +57,24 @@ · 56 unmodified lines | ||
| 57 | 57 | #include "internal.h" |
| 58 | 58 | #include "fw/dbg.h" |
| 59 | 59 | |
| 60 | +static int iwl_pcie_gen2_force_power_gating(struct iwl_trans *trans) | |
| 61 | +{ | |
| 62 | + iwl_set_bits_prph(trans, HPM_HIPM_GEN_CFG, | |
| 63 | + HPM_HIPM_GEN_CFG_CR_FORCE_ACTIVE); | |
| 64 | + udelay(20); | |
| 65 | + iwl_set_bits_prph(trans, HPM_HIPM_GEN_CFG, | |
| 66 | + HPM_HIPM_GEN_CFG_CR_PG_EN | | |
| 67 | + HPM_HIPM_GEN_CFG_CR_SLP_EN); | |
| 68 | + udelay(20); | |
| 69 | + iwl_clear_bits_prph(trans, HPM_HIPM_GEN_CFG, | |
| 70 | + HPM_HIPM_GEN_CFG_CR_FORCE_ACTIVE); | |
| 71 | + | |
| 72 | + iwl_trans_sw_reset(trans); | |
| 73 | + iwl_clear_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | |
| 74 | + | |
| 75 | + return 0; | |
| 76 | +} | |
| 77 | + | |
| 60 | 78 | /* |
| 61 | 79 | * Start up NIC's basic functionality after it has been reset |
| 62 | 80 | * (e.g. after platform boot, or shutdown via iwl_pcie_apm_stop()) |
| @@ -92,6 +110,13 @@ int iwl_pcie_gen2_apm_init(struct iwl_trans *trans) · 29 unmodified lines | ||
| 92 | 110 | |
| 93 | 111 | iwl_pcie_apm_config(trans); |
| 94 | 112 | |
| 113 | + if (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_22000 && | |
| 114 | + trans->cfg->integrated) { | |
| 115 | + ret = iwl_pcie_gen2_force_power_gating(trans); | |
| 116 | + if (ret) | |
| 117 | + return ret; | |
| 118 | + } | |
| 119 | + | |
| 95 | 120 | ret = iwl_finish_nic_init(trans, trans->trans_cfg); |
| 96 | 121 | if (ret) |
| 97 | 122 | return ret; |
| @@ -3041,30 +3041,6 @@ static void prism2_clear_set_tim_queue(local_info_t *local) · 3040 unmodified lines | ||
| 3041 | 3041 | } |
| 3042 | 3042 | } |
| 3043 | 3043 | |
| 3044 | − | |
| 3045 | −/* | |
| 3046 | − * HostAP uses two layers of net devices, where the inner | |
| 3047 | − * layer gets called all the time from the outer layer. | |
| 3048 | − * This is a natural nesting, which needs a split lock type. | |
| 3049 | − */ | |
| 3050 | −static struct lock_class_key hostap_netdev_xmit_lock_key; | |
| 3051 | −static struct lock_class_key hostap_netdev_addr_lock_key; | |
| 3052 | − | |
| 3053 | −static void prism2_set_lockdep_class_one(struct net_device *dev, | |
| 3054 | − struct netdev_queue *txq, | |
| 3055 | − void *_unused) | |
| 3056 | −{ | |
| 3057 | − lockdep_set_class(&txq->_xmit_lock, | |
| 3058 | − &hostap_netdev_xmit_lock_key); | |
| 3059 | −} | |
| 3060 | − | |
| 3061 | −static void prism2_set_lockdep_class(struct net_device *dev) | |
| 3062 | −{ | |
| 3063 | − lockdep_set_class(&dev->addr_list_lock, | |
| 3064 | − &hostap_netdev_addr_lock_key); | |
| 3065 | − netdev_for_each_tx_queue(dev, prism2_set_lockdep_class_one, NULL); | |
| 3066 | −} | |
| 3067 | − | |
| 3068 | 3044 | static struct net_device * |
| 3069 | 3045 | prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx, |
| 3070 | 3046 | struct device *sdev) |
| @@ -3223,7 +3199,6 @@ while (0) · 152 unmodified lines | ||
| 3223 | 3199 | if (ret >= 0) |
| 3224 | 3200 | ret = register_netdevice(dev); |
| 3225 | 3201 | |
| 3226 | − prism2_set_lockdep_class(dev); | |
| 3227 | 3202 | rtnl_unlock(); |
| 3228 | 3203 | if (ret < 0) { |
| 3229 | 3204 | printk(KERN_WARNING "%s: register netdevice failed!\n", |
| @@ -8,6 +8,8 @@ mt76-y := \ · 7 unmodified lines | ||
| 8 | 8 | mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o \ |
| 9 | 9 | tx.o agg-rx.o mcu.o |
| 10 | 10 | |
| 11 | +mt76-$(CONFIG_PCI) += pci.o | |
| 12 | + | |
| 11 | 13 | mt76-usb-y := usb.o usb_trace.o |
| 12 | 14 | |
| 13 | 15 | CFLAGS_trace.o := -I$(src) |
| @@ -53,8 +53,10 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, · 52 unmodified lines | ||
| 53 | 53 | u32 ctrl; |
| 54 | 54 | int i, idx = -1; |
| 55 | 55 | |
| 56 | − if (txwi) | |
| 56 | + if (txwi) { | |
| 57 | 57 | q->entry[q->head].txwi = DMA_DUMMY_DATA; |
| 58 | + q->entry[q->head].skip_buf0 = true; | |
| 59 | + } | |
| 58 | 60 | |
| 59 | 61 | for (i = 0; i < nbufs; i += 2, buf += 2) { |
| 60 | 62 | u32 buf0 = buf[0].addr, buf1 = 0; |
| @@ -97,7 +99,7 @@ mt76_dma_tx_cleanup_idx(struct mt76_dev *dev, struct mt76_queue *q, int idx, · 36 unmodified lines | ||
| 97 | 99 | __le32 __ctrl = READ_ONCE(q->desc[idx].ctrl); |
| 98 | 100 | u32 ctrl = le32_to_cpu(__ctrl); |
| 99 | 101 | |
| 100 | − if (!e->txwi || !e->skb) { | |
| 102 | + if (!e->skip_buf0) { | |
| 101 | 103 | __le32 addr = READ_ONCE(q->desc[idx].buf0); |
| 102 | 104 | u32 len = FIELD_GET(MT_DMA_CTL_SD_LEN0, ctrl); |
| 103 | 105 | |
| @@ -93,8 +93,9 @@ struct mt76_queue_entry { · 92 unmodified lines | ||
| 93 | 93 | struct urb *urb; |
| 94 | 94 | }; |
| 95 | 95 | enum mt76_txq_id qid; |
| 96 | − bool schedule; | |
| 97 | − bool done; | |
| 96 | + bool skip_buf0:1; | |
| 97 | + bool schedule:1; | |
| 98 | + bool done:1; | |
| 98 | 99 | }; |
| 99 | 100 | |
| 100 | 101 | struct mt76_queue_regs { |
| @@ -578,6 +579,7 @@ bool __mt76_poll_msec(struct mt76_dev *dev, u32 offset, u32 mask, u32 val, · 477 unmodified lines | ||
| 578 | 579 | #define mt76_poll_msec(dev, ...) __mt76_poll_msec(&((dev)->mt76), __VA_ARGS__) |
| 579 | 580 | |
| 580 | 581 | void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs); |
| 582 | +void mt76_pci_disable_aspm(struct pci_dev *pdev); | |
| 581 | 583 | |
| 582 | 584 | static inline u16 mt76_chip(struct mt76_dev *dev) |
| 583 | 585 | { |
| @@ -81,6 +81,8 @@ mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 80 unmodified lines | ||
| 81 | 81 | /* RG_SSUSB_CDR_BR_PE1D = 0x3 */ |
| 82 | 82 | mt76_rmw_field(dev, 0x15c58, 0x3 << 6, 0x3); |
| 83 | 83 | |
| 84 | + mt76_pci_disable_aspm(pdev); | |
| 85 | + | |
| 84 | 86 | return 0; |
| 85 | 87 | |
| 86 | 88 | error: |
| @@ -0,0 +1,46 @@ | ||
| 1 | +// SPDX-License-Identifier: ISC | |
| 2 | +/* | |
| 3 | + * Copyright (C) 2019 Lorenzo Bianconi <lorenzo@kernel.org> | |
| 4 | + */ | |
| 5 | + | |
| 6 | +#include <linux/pci.h> | |
| 7 | + | |
| 8 | +void mt76_pci_disable_aspm(struct pci_dev *pdev) | |
| 9 | +{ | |
| 10 | + struct pci_dev *parent = pdev->bus->self; | |
| 11 | + u16 aspm_conf, parent_aspm_conf = 0; | |
| 12 | + | |
| 13 | + pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &aspm_conf); | |
| 14 | + aspm_conf &= PCI_EXP_LNKCTL_ASPMC; | |
| 15 | + if (parent) { | |
| 16 | + pcie_capability_read_word(parent, PCI_EXP_LNKCTL, | |
| 17 | + &parent_aspm_conf); | |
| 18 | + parent_aspm_conf &= PCI_EXP_LNKCTL_ASPMC; | |
| 19 | + } | |
| 20 | + | |
| 21 | + if (!aspm_conf && (!parent || !parent_aspm_conf)) { | |
| 22 | + /* aspm already disabled */ | |
| 23 | + return; | |
| 24 | + } | |
| 25 | + | |
| 26 | + dev_info(&pdev->dev, "disabling ASPM %s %s\n", | |
| 27 | + (aspm_conf & PCI_EXP_LNKCTL_ASPM_L0S) ? "L0s" : "", | |
| 28 | + (aspm_conf & PCI_EXP_LNKCTL_ASPM_L1) ? "L1" : ""); | |
| 29 | + | |
| 30 | + if (IS_ENABLED(CONFIG_PCIEASPM)) { | |
| 31 | + int err; | |
| 32 | + | |
| 33 | + err = pci_disable_link_state(pdev, aspm_conf); | |
| 34 | + if (!err) | |
| 35 | + return; | |
| 36 | + } | |
| 37 | + | |
| 38 | + /* both device and parent should have the same ASPM setting. | |
| 39 | + * disable ASPM in downstream component first and then upstream. | |
| 40 | + */ | |
| 41 | + pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, aspm_conf); | |
| 42 | + if (parent) | |
| 43 | + pcie_capability_clear_word(parent, PCI_EXP_LNKCTL, | |
| 44 | + aspm_conf); | |
| 45 | +} | |
| 46 | +EXPORT_SYMBOL_GPL(mt76_pci_disable_aspm); | |
| @@ -822,7 +822,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) · 821 unmodified lines | ||
| 822 | 822 | hdr = rtl_get_hdr(skb); |
| 823 | 823 | fc = rtl_get_fc(skb); |
| 824 | 824 | |
| 825 | − if (!stats.crc && !stats.hwerror) { | |
| 825 | + if (!stats.crc && !stats.hwerror && (skb->len > FCS_LEN)) { | |
| 826 | 826 | memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, |
| 827 | 827 | sizeof(rx_status)); |
| 828 | 828 | |
| @@ -859,6 +859,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) · 30 unmodified lines | ||
| 859 | 859 | _rtl_pci_rx_to_mac80211(hw, skb, rx_status); |
| 860 | 860 | } |
| 861 | 861 | } else { |
| 862 | + /* drop packets with errors or those too short */ | |
| 862 | 863 | dev_kfree_skb_any(skb); |
| 863 | 864 | } |
| 864 | 865 | new_trx_end: |
| @@ -754,6 +754,9 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data, · 753 unmodified lines | ||
| 754 | 754 | return; |
| 755 | 755 | } else { |
| 756 | 756 | noa_num = (noa_len - 2) / 13; |
| 757 | + if (noa_num > P2P_MAX_NOA_NUM) | |
| 758 | + noa_num = P2P_MAX_NOA_NUM; | |
| 759 | + | |
| 757 | 760 | } |
| 758 | 761 | noa_index = ie[3]; |
| 759 | 762 | if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode == |
| @@ -848,6 +851,9 @@ static void rtl_p2p_action_ie(struct ieee80211_hw *hw, void *data, · 88 unmodified lines | ||
| 848 | 851 | return; |
| 849 | 852 | } else { |
| 850 | 853 | noa_num = (noa_len - 2) / 13; |
| 854 | + if (noa_num > P2P_MAX_NOA_NUM) | |
| 855 | + noa_num = P2P_MAX_NOA_NUM; | |
| 856 | + | |
| 851 | 857 | } |
| 852 | 858 | noa_index = ie[3]; |
| 853 | 859 | if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode == |
| @@ -548,6 +548,7 @@ static int virt_wifi_newlink(struct net *src_net, struct net_device *dev, · 547 unmodified lines | ||
| 548 | 548 | priv->is_connected = false; |
| 549 | 549 | priv->is_up = false; |
| 550 | 550 | INIT_DELAYED_WORK(&priv->connect, virt_wifi_connect_complete); |
| 551 | + __module_get(THIS_MODULE); | |
| 551 | 552 | |
| 552 | 553 | return 0; |
| 553 | 554 | unregister_netdev: |
| @@ -578,6 +579,7 @@ static void virt_wifi_dellink(struct net_device *dev, · 24 unmodified lines | ||
| 578 | 579 | netdev_upper_dev_unlink(priv->lowerdev, dev); |
| 579 | 580 | |
| 580 | 581 | unregister_netdevice_queue(dev, head); |
| 582 | + module_put(THIS_MODULE); | |
| 581 | 583 | |
| 582 | 584 | /* Deleting the wiphy is handled in the module destructor. */ |
| 583 | 585 | } |
| @@ -590,6 +592,42 @@ static struct rtnl_link_ops virt_wifi_link_ops = { · 6 unmodified lines | ||
| 590 | 592 | .priv_size = sizeof(struct virt_wifi_netdev_priv), |
| 591 | 593 | }; |
| 592 | 594 | |
| 595 | +static bool netif_is_virt_wifi_dev(const struct net_device *dev) | |
| 596 | +{ | |
| 597 | + return rcu_access_pointer(dev->rx_handler) == virt_wifi_rx_handler; | |
| 598 | +} | |
| 599 | + | |
| 600 | +static int virt_wifi_event(struct notifier_block *this, unsigned long event, | |
| 601 | + void *ptr) | |
| 602 | +{ | |
| 603 | + struct net_device *lower_dev = netdev_notifier_info_to_dev(ptr); | |
| 604 | + struct virt_wifi_netdev_priv *priv; | |
| 605 | + struct net_device *upper_dev; | |
| 606 | + LIST_HEAD(list_kill); | |
| 607 | + | |
| 608 | + if (!netif_is_virt_wifi_dev(lower_dev)) | |
| 609 | + return NOTIFY_DONE; | |
| 610 | + | |
| 611 | + switch (event) { | |
| 612 | + case NETDEV_UNREGISTER: | |
| 613 | + priv = rtnl_dereference(lower_dev->rx_handler_data); | |
| 614 | + if (!priv) | |
| 615 | + return NOTIFY_DONE; | |
| 616 | + | |
| 617 | + upper_dev = priv->upperdev; | |
| 618 | + | |
| 619 | + upper_dev->rtnl_link_ops->dellink(upper_dev, &list_kill); | |
| 620 | + unregister_netdevice_many(&list_kill); | |
| 621 | + break; | |
| 622 | + } | |
| 623 | + | |
| 624 | + return NOTIFY_DONE; | |
| 625 | +} | |
| 626 | + | |
| 627 | +static struct notifier_block virt_wifi_notifier = { | |
| 628 | + .notifier_call = virt_wifi_event, | |
| 629 | +}; | |
| 630 | + | |
| 593 | 631 | /* Acquires and releases the rtnl lock. */ |
| 594 | 632 | static int __init virt_wifi_init_module(void) |
| 595 | 633 | { |
| @@ -598,14 +636,25 @@ static int __init virt_wifi_init_module(void) · 2 unmodified lines | ||
| 598 | 636 | /* Guaranteed to be locallly-administered and not multicast. */ |
| 599 | 637 | eth_random_addr(fake_router_bssid); |
| 600 | 638 | |
| 639 | + err = register_netdevice_notifier(&virt_wifi_notifier); | |
| 640 | + if (err) | |
| 641 | + return err; | |
| 642 | + | |
| 643 | + err = -ENOMEM; | |
| 601 | 644 | common_wiphy = virt_wifi_make_wiphy(); |
| 602 | 645 | if (!common_wiphy) |
| 603 | − return -ENOMEM; | |
| 646 | + goto notifier; | |
| 604 | 647 | |
| 605 | 648 | err = rtnl_link_register(&virt_wifi_link_ops); |
| 606 | 649 | if (err) |
| 607 | − virt_wifi_destroy_wiphy(common_wiphy); | |
| 650 | + goto destroy_wiphy; | |
| 608 | 651 | |
| 652 | + return 0; | |
| 653 | + | |
| 654 | +destroy_wiphy: | |
| 655 | + virt_wifi_destroy_wiphy(common_wiphy); | |
| 656 | +notifier: | |
| 657 | + unregister_netdevice_notifier(&virt_wifi_notifier); | |
| 609 | 658 | return err; |
| 610 | 659 | } |
| 611 | 660 | |
| @@ -615,6 +664,7 @@ static void __exit virt_wifi_cleanup_module(void) · 3 unmodified lines | ||
| 615 | 664 | /* Will delete any devices that depend on the wiphy. */ |
| 616 | 665 | rtnl_link_unregister(&virt_wifi_link_ops); |
| 617 | 666 | virt_wifi_destroy_wiphy(common_wiphy); |
| 667 | + unregister_netdevice_notifier(&virt_wifi_notifier); | |
| 618 | 668 | } |
| 619 | 669 | |
| 620 | 670 | module_init(virt_wifi_init_module); |
| @@ -259,7 +259,7 @@ static void fdp_nci_i2c_read_device_properties(struct device *dev, · 258 unmodified lines | ||
| 259 | 259 | *fw_vsc_cfg, len); |
| 260 | 260 | |
| 261 | 261 | if (r) { |
| 262 | − devm_kfree(dev, fw_vsc_cfg); | |
| 262 | + devm_kfree(dev, *fw_vsc_cfg); | |
| 263 | 263 | goto vsc_read_err; |
| 264 | 264 | } |
| 265 | 265 | } else { |
| @@ -708,6 +708,7 @@ static int st21nfca_hci_complete_target_discovered(struct nfc_hci_dev *hdev, · 707 unmodified lines | ||
| 708 | 708 | NFC_PROTO_FELICA_MASK; |
| 709 | 709 | } else { |
| 710 | 710 | kfree_skb(nfcid_skb); |
| 711 | + nfcid_skb = NULL; | |
| 711 | 712 | /* P2P in type A */ |
| 712 | 713 | r = nfc_hci_get_param(hdev, ST21NFCA_RF_READER_F_GATE, |
| 713 | 714 | ST21NFCA_RF_READER_F_NFCID1, |
| @@ -158,9 +158,11 @@ void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl) · 157 unmodified lines | ||
| 158 | 158 | struct nvme_ns *ns; |
| 159 | 159 | |
| 160 | 160 | mutex_lock(&ctrl->scan_lock); |
| 161 | + down_read(&ctrl->namespaces_rwsem); | |
| 161 | 162 | list_for_each_entry(ns, &ctrl->namespaces, list) |
| 162 | 163 | if (nvme_mpath_clear_current_path(ns)) |
| 163 | 164 | kblockd_schedule_work(&ns->head->requeue_work); |
| 165 | + up_read(&ctrl->namespaces_rwsem); | |
| 164 | 166 | mutex_unlock(&ctrl->scan_lock); |
| 165 | 167 | } |
| 166 | 168 | |
| @@ -522,14 +524,13 @@ static int nvme_update_ana_state(struct nvme_ctrl *ctrl, · 355 unmodified lines | ||
| 522 | 524 | return 0; |
| 523 | 525 | } |
| 524 | 526 | |
| 525 | −static int nvme_read_ana_log(struct nvme_ctrl *ctrl, bool groups_only) | |
| 527 | +static int nvme_read_ana_log(struct nvme_ctrl *ctrl) | |
| 526 | 528 | { |
| 527 | 529 | u32 nr_change_groups = 0; |
| 528 | 530 | int error; |
| 529 | 531 | |
| 530 | 532 | mutex_lock(&ctrl->ana_lock); |
| 531 | − error = nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_ANA, | |
| 532 | − groups_only ? NVME_ANA_LOG_RGO : 0, | |
| 533 | + error = nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_ANA, 0, | |
| 533 | 534 | ctrl->ana_log_buf, ctrl->ana_log_size, 0); |
| 534 | 535 | if (error) { |
| 535 | 536 | dev_warn(ctrl->device, "Failed to get ANA log: %d\n", error); |
| @@ -565,7 +566,7 @@ static void nvme_ana_work(struct work_struct *work) · 29 unmodified lines | ||
| 565 | 566 | { |
| 566 | 567 | struct nvme_ctrl *ctrl = container_of(work, struct nvme_ctrl, ana_work); |
| 567 | 568 | |
| 568 | − nvme_read_ana_log(ctrl, false); | |
| 569 | + nvme_read_ana_log(ctrl); | |
| 569 | 570 | } |
| 570 | 571 | |
| 571 | 572 | static void nvme_anatt_timeout(struct timer_list *t) |
| @@ -715,7 +716,7 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) · 143 unmodified lines | ||
| 715 | 716 | goto out; |
| 716 | 717 | } |
| 717 | 718 | |
| 718 | − error = nvme_read_ana_log(ctrl, true); | |
| 719 | + error = nvme_read_ana_log(ctrl); | |
| 719 | 720 | if (error) |
| 720 | 721 | goto out_free_ana_log_buf; |
| 721 | 722 | return 0; |
| @@ -2133,8 +2133,16 @@ err_unreg_client: · 2132 unmodified lines | ||
| 2133 | 2133 | |
| 2134 | 2134 | static void __exit nvme_rdma_cleanup_module(void) |
| 2135 | 2135 | { |
| 2136 | + struct nvme_rdma_ctrl *ctrl; | |
| 2137 | + | |
| 2136 | 2138 | nvmf_unregister_transport(&nvme_rdma_transport); |
| 2137 | 2139 | ib_unregister_client(&nvme_rdma_ib_client); |
| 2140 | + | |
| 2141 | + mutex_lock(&nvme_rdma_ctrl_mutex); | |
| 2142 | + list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) | |
| 2143 | + nvme_delete_ctrl(&ctrl->ctrl); | |
| 2144 | + mutex_unlock(&nvme_rdma_ctrl_mutex); | |
| 2145 | + flush_workqueue(nvme_delete_wq); | |
| 2138 | 2146 | } |
| 2139 | 2147 | |
| 2140 | 2148 | module_init(nvme_rdma_init_module); |
| @@ -2219,7 +2219,7 @@ static int nvme_tcp_poll(struct blk_mq_hw_ctx *hctx) · 2218 unmodified lines | ||
| 2219 | 2219 | struct nvme_tcp_queue *queue = hctx->driver_data; |
| 2220 | 2220 | struct sock *sk = queue->sock->sk; |
| 2221 | 2221 | |
| 2222 | − if (sk_can_busy_loop(sk) && skb_queue_empty(&sk->sk_receive_queue)) | |
| 2222 | + if (sk_can_busy_loop(sk) && skb_queue_empty_lockless(&sk->sk_receive_queue)) | |
| 2223 | 2223 | sk_busy_loop(sk, true); |
| 2224 | 2224 | nvme_tcp_try_recv(queue); |
| 2225 | 2225 | return queue->nr_cqe; |
| @@ -147,6 +147,7 @@ struct chv_pin_context { · 146 unmodified lines | ||
| 147 | 147 | * @pctldesc: Pin controller description |
| 148 | 148 | * @pctldev: Pointer to the pin controller device |
| 149 | 149 | * @chip: GPIO chip in this pin controller |
| 150 | + * @irqchip: IRQ chip in this pin controller | |
| 150 | 151 | * @regs: MMIO registers |
| 151 | 152 | * @intr_lines: Stores mapping between 16 HW interrupt wires and GPIO |
| 152 | 153 | * offset (in GPIO number space) |
| @@ -162,6 +163,7 @@ struct chv_pinctrl { · 9 unmodified lines | ||
| 162 | 163 | struct pinctrl_desc pctldesc; |
| 163 | 164 | struct pinctrl_dev *pctldev; |
| 164 | 165 | struct gpio_chip chip; |
| 166 | + struct irq_chip irqchip; | |
| 165 | 167 | void __iomem *regs; |
| 166 | 168 | unsigned intr_lines[16]; |
| 167 | 169 | const struct chv_community *community; |
| @@ -1466,16 +1468,6 @@ static int chv_gpio_irq_type(struct irq_data *d, unsigned int type) · 1298 unmodified lines | ||
| 1466 | 1468 | return 0; |
| 1467 | 1469 | } |
| 1468 | 1470 | |
| 1469 | −static struct irq_chip chv_gpio_irqchip = { | |
| 1470 | − .name = "chv-gpio", | |
| 1471 | − .irq_startup = chv_gpio_irq_startup, | |
| 1472 | − .irq_ack = chv_gpio_irq_ack, | |
| 1473 | − .irq_mask = chv_gpio_irq_mask, | |
| 1474 | − .irq_unmask = chv_gpio_irq_unmask, | |
| 1475 | − .irq_set_type = chv_gpio_irq_type, | |
| 1476 | − .flags = IRQCHIP_SKIP_SET_WAKE, | |
| 1477 | −}; | |
| 1478 | − | |
| 1479 | 1471 | static void chv_gpio_irq_handler(struct irq_desc *desc) |
| 1480 | 1472 | { |
| 1481 | 1473 | struct gpio_chip *gc = irq_desc_get_handler_data(desc); |
| @@ -1559,7 +1551,7 @@ static void chv_init_irq_valid_mask(struct gpio_chip *chip, · 77 unmodified lines | ||
| 1559 | 1551 | intsel >>= CHV_PADCTRL0_INTSEL_SHIFT; |
| 1560 | 1552 | |
| 1561 | 1553 | if (intsel >= community->nirqs) |
| 1562 | − clear_bit(i, valid_mask); | |
| 1554 | + clear_bit(desc->number, valid_mask); | |
| 1563 | 1555 | } |
| 1564 | 1556 | } |
| 1565 | 1557 | |
| @@ -1625,7 +1617,15 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq) · 59 unmodified lines | ||
| 1625 | 1617 | } |
| 1626 | 1618 | } |
| 1627 | 1619 | |
| 1628 | − ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0, | |
| 1620 | + pctrl->irqchip.name = "chv-gpio"; | |
| 1621 | + pctrl->irqchip.irq_startup = chv_gpio_irq_startup; | |
| 1622 | + pctrl->irqchip.irq_ack = chv_gpio_irq_ack; | |
| 1623 | + pctrl->irqchip.irq_mask = chv_gpio_irq_mask; | |
| 1624 | + pctrl->irqchip.irq_unmask = chv_gpio_irq_unmask; | |
| 1625 | + pctrl->irqchip.irq_set_type = chv_gpio_irq_type; | |
| 1626 | + pctrl->irqchip.flags = IRQCHIP_SKIP_SET_WAKE; | |
| 1627 | + | |
| 1628 | + ret = gpiochip_irqchip_add(chip, &pctrl->irqchip, 0, | |
| 1629 | 1629 | handle_bad_irq, IRQ_TYPE_NONE); |
| 1630 | 1630 | if (ret) { |
| 1631 | 1631 | dev_err(pctrl->dev, "failed to add IRQ chip\n"); |
| @@ -1642,7 +1642,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq) · 10 unmodified lines | ||
| 1642 | 1642 | } |
| 1643 | 1643 | } |
| 1644 | 1644 | |
| 1645 | − gpiochip_set_chained_irqchip(chip, &chv_gpio_irqchip, irq, | |
| 1645 | + gpiochip_set_chained_irqchip(chip, &pctrl->irqchip, irq, | |
| 1646 | 1646 | chv_gpio_irq_handler); |
| 1647 | 1647 | return 0; |
| 1648 | 1648 | } |
| @@ -52,6 +52,7 @@ · 51 unmodified lines | ||
| 52 | 52 | #define PADCFG0_GPIROUTNMI BIT(17) |
| 53 | 53 | #define PADCFG0_PMODE_SHIFT 10 |
| 54 | 54 | #define PADCFG0_PMODE_MASK GENMASK(13, 10) |
| 55 | +#define PADCFG0_PMODE_GPIO 0 | |
| 55 | 56 | #define PADCFG0_GPIORXDIS BIT(9) |
| 56 | 57 | #define PADCFG0_GPIOTXDIS BIT(8) |
| 57 | 58 | #define PADCFG0_GPIORXSTATE BIT(1) |
| @@ -332,7 +333,7 @@ static void intel_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, · 274 unmodified lines | ||
| 332 | 333 | cfg1 = readl(intel_get_padcfg(pctrl, pin, PADCFG1)); |
| 333 | 334 | |
| 334 | 335 | mode = (cfg0 & PADCFG0_PMODE_MASK) >> PADCFG0_PMODE_SHIFT; |
| 335 | − if (!mode) | |
| 336 | + if (mode == PADCFG0_PMODE_GPIO) | |
| 336 | 337 | seq_puts(s, "GPIO "); |
| 337 | 338 | else |
| 338 | 339 | seq_printf(s, "mode %d ", mode); |
| @@ -458,6 +459,11 @@ static void __intel_gpio_set_direction(void __iomem *padcfg0, bool input) · 119 unmodified lines | ||
| 458 | 459 | writel(value, padcfg0); |
| 459 | 460 | } |
| 460 | 461 | |
| 462 | +static int intel_gpio_get_gpio_mode(void __iomem *padcfg0) | |
| 463 | +{ | |
| 464 | + return (readl(padcfg0) & PADCFG0_PMODE_MASK) >> PADCFG0_PMODE_SHIFT; | |
| 465 | +} | |
| 466 | + | |
| 461 | 467 | static void intel_gpio_set_gpio_mode(void __iomem *padcfg0) |
| 462 | 468 | { |
| 463 | 469 | u32 value; |
| @@ -491,7 +497,20 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev, · 27 unmodified lines | ||
| 491 | 497 | } |
| 492 | 498 | |
| 493 | 499 | padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); |
| 500 | + | |
| 501 | + /* | |
| 502 | + * If pin is already configured in GPIO mode, we assume that | |
| 503 | + * firmware provides correct settings. In such case we avoid | |
| 504 | + * potential glitches on the pin. Otherwise, for the pin in | |
| 505 | + * alternative mode, consumer has to supply respective flags. | |
| 506 | + */ | |
| 507 | + if (intel_gpio_get_gpio_mode(padcfg0) == PADCFG0_PMODE_GPIO) { | |
| 508 | + raw_spin_unlock_irqrestore(&pctrl->lock, flags); | |
| 509 | + return 0; | |
| 510 | + } | |
| 511 | + | |
| 494 | 512 | intel_gpio_set_gpio_mode(padcfg0); |
| 513 | + | |
| 495 | 514 | /* Disable TX buffer and enable RX (this will be input) */ |
| 496 | 515 | __intel_gpio_set_direction(padcfg0, true); |
| 497 | 516 | |
| @@ -585,19 +585,6 @@ static int stmfx_pinctrl_gpio_function_enable(struct stmfx_pinctrl *pctl) · 584 unmodified lines | ||
| 585 | 585 | return stmfx_function_enable(pctl->stmfx, func); |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | −static int stmfx_pinctrl_gpio_init_valid_mask(struct gpio_chip *gc, | |
| 589 | − unsigned long *valid_mask, | |
| 590 | − unsigned int ngpios) | |
| 591 | −{ | |
| 592 | − struct stmfx_pinctrl *pctl = gpiochip_get_data(gc); | |
| 593 | − u32 n; | |
| 594 | − | |
| 595 | − for_each_clear_bit(n, &pctl->gpio_valid_mask, ngpios) | |
| 596 | − clear_bit(n, valid_mask); | |
| 597 | − | |
| 598 | − return 0; | |
| 599 | −} | |
| 600 | − | |
| 601 | 588 | static int stmfx_pinctrl_probe(struct platform_device *pdev) |
| 602 | 589 | { |
| 603 | 590 | struct stmfx *stmfx = dev_get_drvdata(pdev->dev.parent); |
| @@ -660,7 +647,6 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev) · 56 unmodified lines | ||
| 660 | 647 | pctl->gpio_chip.ngpio = pctl->pctl_desc.npins; |
| 661 | 648 | pctl->gpio_chip.can_sleep = true; |
| 662 | 649 | pctl->gpio_chip.of_node = np; |
| 663 | − pctl->gpio_chip.init_valid_mask = stmfx_pinctrl_gpio_init_valid_mask; | |
| 664 | 650 | |
| 665 | 651 | ret = devm_gpiochip_add_data(pctl->dev, &pctl->gpio_chip, pctl); |
| 666 | 652 | if (ret) { |
| @@ -472,14 +472,7 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state) · 471 unmodified lines | ||
| 472 | 472 | if (err) |
| 473 | 473 | return err; |
| 474 | 474 | |
| 475 | − /* | |
| 476 | − * .apply might have to round some values in *state, if possible | |
| 477 | − * read the actually implemented value back. | |
| 478 | − */ | |
| 479 | − if (chip->ops->get_state) | |
| 480 | − chip->ops->get_state(chip, pwm, &pwm->state); | |
| 481 | − else | |
| 482 | − pwm->state = *state; | |
| 475 | + pwm->state = *state; | |
| 483 | 476 | } else { |
| 484 | 477 | /* |
| 485 | 478 | * FIXME: restore the initial state in case of error. |
| @@ -187,6 +187,7 @@ static int iproc_pwmc_apply(struct pwm_chip *chip, struct pwm_device *pwm, · 186 unmodified lines | ||
| 187 | 187 | static const struct pwm_ops iproc_pwm_ops = { |
| 188 | 188 | .apply = iproc_pwmc_apply, |
| 189 | 189 | .get_state = iproc_pwmc_get_state, |
| 190 | + .owner = THIS_MODULE, | |
| 190 | 191 | }; |
| 191 | 192 | |
| 192 | 193 | static int iproc_pwmc_probe(struct platform_device *pdev) |
| @@ -76,7 +76,6 @@ static const char *rcdev_name(struct reset_controller_dev *rcdev) · 75 unmodified lines | ||
| 76 | 76 | * of_reset_simple_xlate - translate reset_spec to the reset line number |
| 77 | 77 | * @rcdev: a pointer to the reset controller device |
| 78 | 78 | * @reset_spec: reset line specifier as found in the device tree |
| 79 | − * @flags: a flags pointer to fill in (optional) | |
| 80 | 79 | * |
| 81 | 80 | * This simple translation function should be used for reset controllers |
| 82 | 81 | * with 1:1 mapping, where reset lines can be indexed by number without gaps. |
| @@ -748,6 +747,7 @@ static void reset_control_array_put(struct reset_control_array *resets) · 665 unmodified lines | ||
| 748 | 747 | for (i = 0; i < resets->num_rstcs; i++) |
| 749 | 748 | __reset_control_put_internal(resets->rstc[i]); |
| 750 | 749 | mutex_unlock(&reset_list_mutex); |
| 750 | + kfree(resets); | |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | /** |
| @@ -825,9 +825,10 @@ int __device_reset(struct device *dev, bool optional) · 71 unmodified lines | ||
| 825 | 825 | } |
| 826 | 826 | EXPORT_SYMBOL_GPL(__device_reset); |
| 827 | 827 | |
| 828 | −/** | |
| 828 | +/* | |
| 829 | 829 | * APIs to manage an array of reset controls. |
| 830 | 830 | */ |
| 831 | + | |
| 831 | 832 | /** |
| 832 | 833 | * of_reset_control_get_count - Count number of resets available with a device |
| 833 | 834 | * |
| @@ -851,9 +851,9 @@ lpfc_disc_set_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 850 unmodified lines | ||
| 851 | 851 | |
| 852 | 852 | if (!(vport->fc_flag & FC_PT2PT)) { |
| 853 | 853 | /* Check config parameter use-adisc or FCP-2 */ |
| 854 | − if ((vport->cfg_use_adisc && (vport->fc_flag & FC_RSCN_MODE)) || | |
| 854 | + if (vport->cfg_use_adisc && ((vport->fc_flag & FC_RSCN_MODE) || | |
| 855 | 855 | ((ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) && |
| 856 | − (ndlp->nlp_type & NLP_FCP_TARGET))) { | |
| 856 | + (ndlp->nlp_type & NLP_FCP_TARGET)))) { | |
| 857 | 857 | spin_lock_irq(shost->host_lock); |
| 858 | 858 | ndlp->nlp_flag |= NLP_NPR_ADISC; |
| 859 | 859 | spin_unlock_irq(shost->host_lock); |
| @@ -7866,7 +7866,7 @@ lpfc_sli4_process_missed_mbox_completions(struct lpfc_hba *phba) · 7865 unmodified lines | ||
| 7866 | 7866 | if (sli4_hba->hdwq) { |
| 7867 | 7867 | for (eqidx = 0; eqidx < phba->cfg_irq_chann; eqidx++) { |
| 7868 | 7868 | eq = phba->sli4_hba.hba_eq_hdl[eqidx].eq; |
| 7869 | − if (eq->queue_id == sli4_hba->mbx_cq->assoc_qid) { | |
| 7869 | + if (eq && eq->queue_id == sli4_hba->mbx_cq->assoc_qid) { | |
| 7870 | 7870 | fpeq = eq; |
| 7871 | 7871 | break; |
| 7872 | 7872 | } |
| @@ -440,9 +440,6 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, · 439 unmodified lines | ||
| 440 | 440 | valid = 0; |
| 441 | 441 | if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0) |
| 442 | 442 | valid = 1; |
| 443 | − else if (start == (ha->flt_region_boot * 4) || | |
| 444 | − start == (ha->flt_region_fw * 4)) | |
| 445 | − valid = 1; | |
| 446 | 443 | else if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha)) |
| 447 | 444 | valid = 1; |
| 448 | 445 | if (!valid) { |
| @@ -489,8 +486,10 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, · 40 unmodified lines | ||
| 489 | 486 | "Writing flash region -- 0x%x/0x%x.\n", |
| 490 | 487 | ha->optrom_region_start, ha->optrom_region_size); |
| 491 | 488 | |
| 492 | − ha->isp_ops->write_optrom(vha, ha->optrom_buffer, | |
| 489 | + rval = ha->isp_ops->write_optrom(vha, ha->optrom_buffer, | |
| 493 | 490 | ha->optrom_region_start, ha->optrom_region_size); |
| 491 | + if (rval) | |
| 492 | + rval = -EIO; | |
| 494 | 493 | break; |
| 495 | 494 | default: |
| 496 | 495 | rval = -EINVAL; |
| @@ -253,7 +253,7 @@ qla2x00_process_els(struct bsg_job *bsg_job) · 252 unmodified lines | ||
| 253 | 253 | srb_t *sp; |
| 254 | 254 | const char *type; |
| 255 | 255 | int req_sg_cnt, rsp_sg_cnt; |
| 256 | − int rval = (DRIVER_ERROR << 16); | |
| 256 | + int rval = (DID_ERROR << 16); | |
| 257 | 257 | uint16_t nextlid = 0; |
| 258 | 258 | |
| 259 | 259 | if (bsg_request->msgcode == FC_BSG_RPT_ELS) { |
| @@ -432,7 +432,7 @@ qla2x00_process_ct(struct bsg_job *bsg_job) · 172 unmodified lines | ||
| 432 | 432 | struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); |
| 433 | 433 | scsi_qla_host_t *vha = shost_priv(host); |
| 434 | 434 | struct qla_hw_data *ha = vha->hw; |
| 435 | − int rval = (DRIVER_ERROR << 16); | |
| 435 | + int rval = (DID_ERROR << 16); | |
| 436 | 436 | int req_sg_cnt, rsp_sg_cnt; |
| 437 | 437 | uint16_t loop_id; |
| 438 | 438 | struct fc_port *fcport; |
| @@ -1950,7 +1950,7 @@ qlafx00_mgmt_cmd(struct bsg_job *bsg_job) · 1511 unmodified lines | ||
| 1950 | 1950 | struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); |
| 1951 | 1951 | scsi_qla_host_t *vha = shost_priv(host); |
| 1952 | 1952 | struct qla_hw_data *ha = vha->hw; |
| 1953 | − int rval = (DRIVER_ERROR << 16); | |
| 1953 | + int rval = (DID_ERROR << 16); | |
| 1954 | 1954 | struct qla_mt_iocb_rqst_fx00 *piocb_rqst; |
| 1955 | 1955 | srb_t *sp; |
| 1956 | 1956 | int req_sg_cnt = 0, rsp_sg_cnt = 0; |
| @@ -702,6 +702,7 @@ qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr) · 701 unmodified lines | ||
| 702 | 702 | mcp->mb[2] = LSW(risc_addr); |
| 703 | 703 | mcp->mb[3] = 0; |
| 704 | 704 | mcp->mb[4] = 0; |
| 705 | + mcp->mb[11] = 0; | |
| 705 | 706 | ha->flags.using_lr_setting = 0; |
| 706 | 707 | if (IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) || |
| 707 | 708 | IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
| @@ -746,7 +747,7 @@ qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr) · 38 unmodified lines | ||
| 746 | 747 | if (ha->flags.exchoffld_enabled) |
| 747 | 748 | mcp->mb[4] |= ENABLE_EXCHANGE_OFFLD; |
| 748 | 749 | |
| 749 | − mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1; | |
| 750 | + mcp->out_mb |= MBX_4 | MBX_3 | MBX_2 | MBX_1 | MBX_11; | |
| 750 | 751 | mcp->in_mb |= MBX_3 | MBX_2 | MBX_1; |
| 751 | 752 | } else { |
| 752 | 753 | mcp->mb[1] = LSW(risc_addr); |
| @@ -3535,6 +3535,10 @@ qla2x00_shutdown(struct pci_dev *pdev) · 3534 unmodified lines | ||
| 3535 | 3535 | qla2x00_try_to_stop_firmware(vha); |
| 3536 | 3536 | } |
| 3537 | 3537 | |
| 3538 | + /* Disable timer */ | |
| 3539 | + if (vha->timer_active) | |
| 3540 | + qla2x00_stop_timer(vha); | |
| 3541 | + | |
| 3538 | 3542 | /* Turn adapter off line */ |
| 3539 | 3543 | vha->flags.online = 0; |
| 3540 | 3544 | |
| @@ -1166,11 +1166,12 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) · 1165 unmodified lines | ||
| 1166 | 1166 | sector_t lba = sectors_to_logical(sdp, blk_rq_pos(rq)); |
| 1167 | 1167 | sector_t threshold; |
| 1168 | 1168 | unsigned int nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq)); |
| 1169 | − bool dif, dix; | |
| 1170 | 1169 | unsigned int mask = logical_to_sectors(sdp, 1) - 1; |
| 1171 | 1170 | bool write = rq_data_dir(rq) == WRITE; |
| 1172 | 1171 | unsigned char protect, fua; |
| 1173 | 1172 | blk_status_t ret; |
| 1173 | + unsigned int dif; | |
| 1174 | + bool dix; | |
| 1174 | 1175 | |
| 1175 | 1176 | ret = scsi_init_io(cmd); |
| 1176 | 1177 | if (ret != BLK_STS_OK) |
| @@ -98,6 +98,8 @@ static int ufs_bsg_request(struct bsg_job *job) · 97 unmodified lines | ||
| 98 | 98 | |
| 99 | 99 | bsg_reply->reply_payload_rcv_len = 0; |
| 100 | 100 | |
| 101 | + pm_runtime_get_sync(hba->dev); | |
| 102 | + | |
| 101 | 103 | msgcode = bsg_request->msgcode; |
| 102 | 104 | switch (msgcode) { |
| 103 | 105 | case UPIU_TRANSACTION_QUERY_REQ: |
| @@ -135,6 +137,8 @@ static int ufs_bsg_request(struct bsg_job *job) · 31 unmodified lines | ||
| 135 | 137 | break; |
| 136 | 138 | } |
| 137 | 139 | |
| 140 | + pm_runtime_put_sync(hba->dev); | |
| 141 | + | |
| 138 | 142 | if (!desc_buff) |
| 139 | 143 | goto out; |
| 140 | 144 | |
| @@ -249,13 +249,13 @@ static struct genpd_power_state imx6_pm_domain_pu_state = { · 248 unmodified lines | ||
| 249 | 249 | }; |
| 250 | 250 | |
| 251 | 251 | static struct imx_pm_domain imx_gpc_domains[] = { |
| 252 | − [GPC_PGC_DOMAIN_ARM] { | |
| 252 | + [GPC_PGC_DOMAIN_ARM] = { | |
| 253 | 253 | .base = { |
| 254 | 254 | .name = "ARM", |
| 255 | 255 | .flags = GENPD_FLAG_ALWAYS_ON, |
| 256 | 256 | }, |
| 257 | 257 | }, |
| 258 | − [GPC_PGC_DOMAIN_PU] { | |
| 258 | + [GPC_PGC_DOMAIN_PU] = { | |
| 259 | 259 | .base = { |
| 260 | 260 | .name = "PU", |
| 261 | 261 | .power_off = imx6_pm_domain_power_off, |
| @@ -266,7 +266,7 @@ static struct imx_pm_domain imx_gpc_domains[] = { · 4 unmodified lines | ||
| 266 | 266 | .reg_offs = 0x260, |
| 267 | 267 | .cntr_pdn_bit = 0, |
| 268 | 268 | }, |
| 269 | − [GPC_PGC_DOMAIN_DISPLAY] { | |
| 269 | + [GPC_PGC_DOMAIN_DISPLAY] = { | |
| 270 | 270 | .base = { |
| 271 | 271 | .name = "DISPLAY", |
| 272 | 272 | .power_off = imx6_pm_domain_power_off, |
| @@ -275,7 +275,7 @@ static struct imx_pm_domain imx_gpc_domains[] = { · 2 unmodified lines | ||
| 275 | 275 | .reg_offs = 0x240, |
| 276 | 276 | .cntr_pdn_bit = 4, |
| 277 | 277 | }, |
| 278 | − [GPC_PGC_DOMAIN_PCI] { | |
| 278 | + [GPC_PGC_DOMAIN_PCI] = { | |
| 279 | 279 | .base = { |
| 280 | 280 | .name = "PCI", |
| 281 | 281 | .power_off = imx6_pm_domain_power_off, |
| @@ -5,6 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | |
| 6 | 6 | menuconfig SOUNDWIRE |
| 7 | 7 | tristate "SoundWire support" |
| 8 | + depends on ACPI || OF | |
| 8 | 9 | help |
| 9 | 10 | SoundWire is a 2-Pin interface with data and clock line ratified |
| 10 | 11 | by the MIPI Alliance. SoundWire is used for transporting data |
| @@ -900,7 +900,7 @@ static int intel_register_dai(struct sdw_intel *sdw) · 899 unmodified lines | ||
| 900 | 900 | /* Create PCM DAIs */ |
| 901 | 901 | stream = &cdns->pcm; |
| 902 | 902 | |
| 903 | − ret = intel_create_dai(cdns, dais, INTEL_PDI_IN, stream->num_in, | |
| 903 | + ret = intel_create_dai(cdns, dais, INTEL_PDI_IN, cdns->pcm.num_in, | |
| 904 | 904 | off, stream->num_ch_in, true); |
| 905 | 905 | if (ret) |
| 906 | 906 | return ret; |
| @@ -931,7 +931,7 @@ static int intel_register_dai(struct sdw_intel *sdw) · 24 unmodified lines | ||
| 931 | 931 | if (ret) |
| 932 | 932 | return ret; |
| 933 | 933 | |
| 934 | − off += cdns->pdm.num_bd; | |
| 934 | + off += cdns->pdm.num_out; | |
| 935 | 935 | ret = intel_create_dai(cdns, dais, INTEL_PDI_BD, cdns->pdm.num_bd, |
| 936 | 936 | off, stream->num_ch_bd, false); |
| 937 | 937 | if (ret) |
| @@ -128,7 +128,8 @@ int sdw_of_find_slaves(struct sdw_bus *bus) · 127 unmodified lines | ||
| 128 | 128 | struct device_node *node; |
| 129 | 129 | |
| 130 | 130 | for_each_child_of_node(bus->dev->of_node, node) { |
| 131 | − int link_id, sdw_version, ret, len; | |
| 131 | + int link_id, ret, len; | |
| 132 | + unsigned int sdw_version; | |
| 132 | 133 | const char *compat = NULL; |
| 133 | 134 | struct sdw_slave_id id; |
| 134 | 135 | const __be32 *addr; |
| @@ -125,4 +125,6 @@ source "drivers/staging/exfat/Kconfig" · 124 unmodified lines | ||
| 125 | 125 | |
| 126 | 126 | source "drivers/staging/qlge/Kconfig" |
| 127 | 127 | |
| 128 | +source "drivers/staging/vboxsf/Kconfig" | |
| 129 | + | |
| 128 | 130 | endif # STAGING |
| @@ -53,3 +53,4 @@ obj-$(CONFIG_UWB) += uwb/ · 52 unmodified lines | ||
| 53 | 53 | obj-$(CONFIG_USB_WUSB) += wusbcore/ |
| 54 | 54 | obj-$(CONFIG_EXFAT_FS) += exfat/ |
| 55 | 55 | obj-$(CONFIG_QLGE) += qlge/ |
| 56 | +obj-$(CONFIG_VBOXSF_FS) += vboxsf/ | |
| @@ -0,0 +1,10 @@ | ||
| 1 | +config VBOXSF_FS | |
| 2 | + tristate "VirtualBox guest shared folder (vboxsf) support" | |
| 3 | + depends on X86 && VBOXGUEST | |
| 4 | + select NLS | |
| 5 | + help | |
| 6 | + VirtualBox hosts can share folders with guests, this driver | |
| 7 | + implements the Linux-guest side of this allowing folders exported | |
| 8 | + by the host to be mounted under Linux. | |
| 9 | + | |
| 10 | + If you want to use shared folders in VirtualBox guests, answer Y or M. | |
| @@ -0,0 +1,5 @@ | ||
| 1 | +# SPDX-License-Identifier: MIT | |
| 2 | + | |
| 3 | +obj-$(CONFIG_VBOXSF_FS) += vboxsf.o | |
| 4 | + | |
| 5 | +vboxsf-y := dir.o file.o utils.o vboxsf_wrappers.o super.o | |
| @@ -0,0 +1,7 @@ | ||
| 1 | +TODO: | |
| 2 | +- Find a file-system developer to review this and give their Reviewed-By | |
| 3 | +- Address any items coming up during review | |
| 4 | +- Move to fs/vboxfs | |
| 5 | + | |
| 6 | +Please send any patches to Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
| 7 | +and Hans de Goede <hdegoede@redhat.com> | |
| @@ -0,0 +1,418 @@ | ||
| 1 | +// SPDX-License-Identifier: MIT | |
| 2 | +/* | |
| 3 | + * VirtualBox Guest Shared Folders support: Directory inode and file operations | |
| 4 | + * | |
| 5 | + * Copyright (C) 2006-2018 Oracle Corporation | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#include <linux/namei.h> | |
| 9 | +#include <linux/vbox_utils.h> | |
| 10 | +#include "vfsmod.h" | |
| 11 | + | |
| 12 | +static int vboxsf_dir_open(struct inode *inode, struct file *file) | |
| 13 | +{ | |
| 14 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(inode->i_sb); | |
| 15 | + struct shfl_createparms params = {}; | |
| 16 | + struct vboxsf_dir_info *sf_d; | |
| 17 | + int err; | |
| 18 | + | |
| 19 | + sf_d = vboxsf_dir_info_alloc(); | |
| 20 | + if (!sf_d) | |
| 21 | + return -ENOMEM; | |
| 22 | + | |
| 23 | + params.handle = SHFL_HANDLE_NIL; | |
| 24 | + params.create_flags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_OPEN_IF_EXISTS | | |
| 25 | + SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READ; | |
| 26 | + | |
| 27 | + err = vboxsf_create_at_dentry(file_dentry(file), ¶ms); | |
| 28 | + if (err) | |
| 29 | + goto err_free_dir_info; | |
| 30 | + | |
| 31 | + if (params.result != SHFL_FILE_EXISTS) { | |
| 32 | + err = -ENOENT; | |
| 33 | + goto err_close; | |
| 34 | + } | |
| 35 | + | |
| 36 | + err = vboxsf_dir_read_all(sbi, sf_d, params.handle); | |
| 37 | + if (err) | |
| 38 | + goto err_close; | |
| 39 | + | |
| 40 | + vboxsf_close(sbi->root, params.handle); | |
| 41 | + file->private_data = sf_d; | |
| 42 | + return 0; | |
| 43 | + | |
| 44 | +err_close: | |
| 45 | + vboxsf_close(sbi->root, params.handle); | |
| 46 | +err_free_dir_info: | |
| 47 | + vboxsf_dir_info_free(sf_d); | |
| 48 | + return err; | |
| 49 | +} | |
| 50 | + | |
| 51 | +static int vboxsf_dir_release(struct inode *inode, struct file *file) | |
| 52 | +{ | |
| 53 | + if (file->private_data) | |
| 54 | + vboxsf_dir_info_free(file->private_data); | |
| 55 | + | |
| 56 | + return 0; | |
| 57 | +} | |
| 58 | + | |
| 59 | +static unsigned int vboxsf_get_d_type(u32 mode) | |
| 60 | +{ | |
| 61 | + unsigned int d_type; | |
| 62 | + | |
| 63 | + switch (mode & SHFL_TYPE_MASK) { | |
| 64 | + case SHFL_TYPE_FIFO: | |
| 65 | + d_type = DT_FIFO; | |
| 66 | + break; | |
| 67 | + case SHFL_TYPE_DEV_CHAR: | |
| 68 | + d_type = DT_CHR; | |
| 69 | + break; | |
| 70 | + case SHFL_TYPE_DIRECTORY: | |
| 71 | + d_type = DT_DIR; | |
| 72 | + break; | |
| 73 | + case SHFL_TYPE_DEV_BLOCK: | |
| 74 | + d_type = DT_BLK; | |
| 75 | + break; | |
| 76 | + case SHFL_TYPE_FILE: | |
| 77 | + d_type = DT_REG; | |
| 78 | + break; | |
| 79 | + case SHFL_TYPE_SYMLINK: | |
| 80 | + d_type = DT_LNK; | |
| 81 | + break; | |
| 82 | + case SHFL_TYPE_SOCKET: | |
| 83 | + d_type = DT_SOCK; | |
| 84 | + break; | |
| 85 | + case SHFL_TYPE_WHITEOUT: | |
| 86 | + d_type = DT_WHT; | |
| 87 | + break; | |
| 88 | + default: | |
| 89 | + d_type = DT_UNKNOWN; | |
| 90 | + break; | |
| 91 | + } | |
| 92 | + return d_type; | |
| 93 | +} | |
| 94 | + | |
| 95 | +static bool vboxsf_dir_emit(struct file *dir, struct dir_context *ctx) | |
| 96 | +{ | |
| 97 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(file_inode(dir)->i_sb); | |
| 98 | + struct vboxsf_dir_info *sf_d = dir->private_data; | |
| 99 | + struct shfl_dirinfo *info; | |
| 100 | + struct vboxsf_dir_buf *b; | |
| 101 | + unsigned int d_type; | |
| 102 | + loff_t i, cur = 0; | |
| 103 | + ino_t fake_ino; | |
| 104 | + size_t size; | |
| 105 | + int err; | |
| 106 | + | |
| 107 | + list_for_each_entry(b, &sf_d->info_list, head) { | |
| 108 | +try_next_entry: | |
| 109 | + if (ctx->pos >= cur + b->entries) { | |
| 110 | + cur += b->entries; | |
| 111 | + continue; | |
| 112 | + } | |
| 113 | + | |
| 114 | + /* | |
| 115 | + * Note the vboxsf_dir_info objects we are iterating over here | |
| 116 | + * are variable sized, so the info pointer may end up being | |
| 117 | + * unaligned. This is how we get the data from the host. | |
| 118 | + * Since vboxsf is only supported on x86 machines this is not | |
| 119 | + * a problem. | |
| 120 | + */ | |
| 121 | + for (i = 0, info = b->buf; i < ctx->pos - cur; i++) { | |
| 122 | + size = offsetof(struct shfl_dirinfo, name.string) + | |
| 123 | + info->name.size; | |
| 124 | + info = (struct shfl_dirinfo *)((uintptr_t)info + size); | |
| 125 | + } | |
| 126 | + | |
| 127 | + /* Info now points to the right entry, emit it. */ | |
| 128 | + d_type = vboxsf_get_d_type(info->info.attr.mode); | |
| 129 | + | |
| 130 | + /* | |
| 131 | + * On 32 bit systems pos is 64 signed, while ino is 32 bit | |
| 132 | + * unsigned so fake_ino may overflow, check for this. | |
| 133 | + */ | |
| 134 | + if ((ino_t)(ctx->pos + 1) != (u64)(ctx->pos + 1)) { | |
| 135 | + vbg_err("vboxsf: fake ino overflow, truncating dir\n"); | |
| 136 | + return false; | |
| 137 | + } | |
| 138 | + fake_ino = ctx->pos + 1; | |
| 139 | + | |
| 140 | + if (sbi->nls) { | |
| 141 | + char d_name[NAME_MAX]; | |
| 142 | + | |
| 143 | + err = vboxsf_nlscpy(sbi, d_name, NAME_MAX, | |
| 144 | + info->name.string.utf8, | |
| 145 | + info->name.length); | |
| 146 | + if (err) { | |
| 147 | + /* skip erroneous entry and proceed */ | |
| 148 | + ctx->pos += 1; | |
| 149 | + goto try_next_entry; | |
| 150 | + } | |
| 151 | + | |
| 152 | + return dir_emit(ctx, d_name, strlen(d_name), | |
| 153 | + fake_ino, d_type); | |
| 154 | + } | |
| 155 | + | |
| 156 | + return dir_emit(ctx, info->name.string.utf8, info->name.length, | |
| 157 | + fake_ino, d_type); | |
| 158 | + } | |
| 159 | + | |
| 160 | + return false; | |
| 161 | +} | |
| 162 | + | |
| 163 | +static int vboxsf_dir_iterate(struct file *dir, struct dir_context *ctx) | |
| 164 | +{ | |
| 165 | + bool keep_iterating; | |
| 166 | + | |
| 167 | + for (keep_iterating = true; keep_iterating; ctx->pos += 1) | |
| 168 | + keep_iterating = vboxsf_dir_emit(dir, ctx); | |
| 169 | + | |
| 170 | + return 0; | |
| 171 | +} | |
| 172 | + | |
| 173 | +const struct file_operations vboxsf_dir_fops = { | |
| 174 | + .open = vboxsf_dir_open, | |
| 175 | + .iterate = vboxsf_dir_iterate, | |
| 176 | + .release = vboxsf_dir_release, | |
| 177 | + .read = generic_read_dir, | |
| 178 | + .llseek = generic_file_llseek, | |
| 179 | +}; | |
| 180 | + | |
| 181 | +/* | |
| 182 | + * This is called during name resolution/lookup to check if the @dentry in | |
| 183 | + * the cache is still valid. the job is handled by vboxsf_inode_revalidate. | |
| 184 | + */ | |
| 185 | +static int vboxsf_dentry_revalidate(struct dentry *dentry, unsigned int flags) | |
| 186 | +{ | |
| 187 | + if (flags & LOOKUP_RCU) | |
| 188 | + return -ECHILD; | |
| 189 | + | |
| 190 | + if (d_really_is_positive(dentry)) | |
| 191 | + return vboxsf_inode_revalidate(dentry) == 0; | |
| 192 | + else | |
| 193 | + return vboxsf_stat_dentry(dentry, NULL) == -ENOENT; | |
| 194 | +} | |
| 195 | + | |
| 196 | +const struct dentry_operations vboxsf_dentry_ops = { | |
| 197 | + .d_revalidate = vboxsf_dentry_revalidate | |
| 198 | +}; | |
| 199 | + | |
| 200 | +/* iops */ | |
| 201 | + | |
| 202 | +static struct dentry *vboxsf_dir_lookup(struct inode *parent, | |
| 203 | + struct dentry *dentry, | |
| 204 | + unsigned int flags) | |
| 205 | +{ | |
| 206 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(parent->i_sb); | |
| 207 | + struct shfl_fsobjinfo fsinfo; | |
| 208 | + struct inode *inode; | |
| 209 | + int err; | |
| 210 | + | |
| 211 | + dentry->d_time = jiffies; | |
| 212 | + | |
| 213 | + err = vboxsf_stat_dentry(dentry, &fsinfo); | |
| 214 | + if (err) { | |
| 215 | + inode = (err == -ENOENT) ? NULL : ERR_PTR(err); | |
| 216 | + } else { | |
| 217 | + inode = vboxsf_new_inode(parent->i_sb); | |
| 218 | + if (!IS_ERR(inode)) | |
| 219 | + vboxsf_init_inode(sbi, inode, &fsinfo); | |
| 220 | + } | |
| 221 | + | |
| 222 | + return d_splice_alias(inode, dentry); | |
| 223 | +} | |
| 224 | + | |
| 225 | +static int vboxsf_dir_instantiate(struct inode *parent, struct dentry *dentry, | |
| 226 | + struct shfl_fsobjinfo *info) | |
| 227 | +{ | |
| 228 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(parent->i_sb); | |
| 229 | + struct vboxsf_inode *sf_i; | |
| 230 | + struct inode *inode; | |
| 231 | + | |
| 232 | + inode = vboxsf_new_inode(parent->i_sb); | |
| 233 | + if (IS_ERR(inode)) | |
| 234 | + return PTR_ERR(inode); | |
| 235 | + | |
| 236 | + sf_i = VBOXSF_I(inode); | |
| 237 | + /* The host may have given us different attr then requested */ | |
| 238 | + sf_i->force_restat = 1; | |
| 239 | + vboxsf_init_inode(sbi, inode, info); | |
| 240 | + | |
| 241 | + d_instantiate(dentry, inode); | |
| 242 | + | |
| 243 | + return 0; | |
| 244 | +} | |
| 245 | + | |
| 246 | +static int vboxsf_dir_create(struct inode *parent, struct dentry *dentry, | |
| 247 | + umode_t mode, int is_dir) | |
| 248 | +{ | |
| 249 | + struct vboxsf_inode *sf_parent_i = VBOXSF_I(parent); | |
| 250 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(parent->i_sb); | |
| 251 | + struct shfl_createparms params = {}; | |
| 252 | + int err; | |
| 253 | + | |
| 254 | + params.handle = SHFL_HANDLE_NIL; | |
| 255 | + params.create_flags = SHFL_CF_ACT_CREATE_IF_NEW | | |
| 256 | + SHFL_CF_ACT_FAIL_IF_EXISTS | | |
| 257 | + SHFL_CF_ACCESS_READWRITE | | |
| 258 | + (is_dir ? SHFL_CF_DIRECTORY : 0); | |
| 259 | + params.info.attr.mode = (mode & 0777) | | |
| 260 | + (is_dir ? SHFL_TYPE_DIRECTORY : SHFL_TYPE_FILE); | |
| 261 | + params.info.attr.additional = SHFLFSOBJATTRADD_NOTHING; | |
| 262 | + | |
| 263 | + err = vboxsf_create_at_dentry(dentry, ¶ms); | |
| 264 | + if (err) | |
| 265 | + return err; | |
| 266 | + | |
| 267 | + if (params.result != SHFL_FILE_CREATED) | |
| 268 | + return -EPERM; | |
| 269 | + | |
| 270 | + vboxsf_close(sbi->root, params.handle); | |
| 271 | + | |
| 272 | + err = vboxsf_dir_instantiate(parent, dentry, ¶ms.info); | |
| 273 | + if (err) | |
| 274 | + return err; | |
| 275 | + | |
| 276 | + /* parent directory access/change time changed */ | |
| 277 | + sf_parent_i->force_restat = 1; | |
| 278 | + | |
| 279 | + return 0; | |
| 280 | +} | |
| 281 | + | |
| 282 | +static int vboxsf_dir_mkfile(struct inode *parent, struct dentry *dentry, | |
| 283 | + umode_t mode, bool excl) | |
| 284 | +{ | |
| 285 | + return vboxsf_dir_create(parent, dentry, mode, 0); | |
| 286 | +} | |
| 287 | + | |
| 288 | +static int vboxsf_dir_mkdir(struct inode *parent, struct dentry *dentry, | |
| 289 | + umode_t mode) | |
| 290 | +{ | |
| 291 | + return vboxsf_dir_create(parent, dentry, mode, 1); | |
| 292 | +} | |
| 293 | + | |
| 294 | +static int vboxsf_dir_unlink(struct inode *parent, struct dentry *dentry) | |
| 295 | +{ | |
| 296 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(parent->i_sb); | |
| 297 | + struct vboxsf_inode *sf_parent_i = VBOXSF_I(parent); | |
| 298 | + struct inode *inode = d_inode(dentry); | |
| 299 | + struct shfl_string *path; | |
| 300 | + u32 flags; | |
| 301 | + int err; | |
| 302 | + | |
| 303 | + if (S_ISDIR(inode->i_mode)) | |
| 304 | + flags = SHFL_REMOVE_DIR; | |
| 305 | + else | |
| 306 | + flags = SHFL_REMOVE_FILE; | |
| 307 | + | |
| 308 | + if (S_ISLNK(inode->i_mode)) | |
| 309 | + flags |= SHFL_REMOVE_SYMLINK; | |
| 310 | + | |
| 311 | + path = vboxsf_path_from_dentry(sbi, dentry); | |
| 312 | + if (IS_ERR(path)) | |
| 313 | + return PTR_ERR(path); | |
| 314 | + | |
| 315 | + err = vboxsf_remove(sbi->root, path, flags); | |
| 316 | + __putname(path); | |
| 317 | + if (err) | |
| 318 | + return err; | |
| 319 | + | |
| 320 | + /* parent directory access/change time changed */ | |
| 321 | + sf_parent_i->force_restat = 1; | |
| 322 | + | |
| 323 | + return 0; | |
| 324 | +} | |
| 325 | + | |
| 326 | +static int vboxsf_dir_rename(struct inode *old_parent, | |
| 327 | + struct dentry *old_dentry, | |
| 328 | + struct inode *new_parent, | |
| 329 | + struct dentry *new_dentry, | |
| 330 | + unsigned int flags) | |
| 331 | +{ | |
| 332 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(old_parent->i_sb); | |
| 333 | + struct vboxsf_inode *sf_old_parent_i = VBOXSF_I(old_parent); | |
| 334 | + struct vboxsf_inode *sf_new_parent_i = VBOXSF_I(new_parent); | |
| 335 | + u32 shfl_flags = SHFL_RENAME_FILE | SHFL_RENAME_REPLACE_IF_EXISTS; | |
| 336 | + struct shfl_string *old_path, *new_path; | |
| 337 | + int err; | |
| 338 | + | |
| 339 | + if (flags) | |
| 340 | + return -EINVAL; | |
| 341 | + | |
| 342 | + old_path = vboxsf_path_from_dentry(sbi, old_dentry); | |
| 343 | + if (IS_ERR(old_path)) | |
| 344 | + return PTR_ERR(old_path); | |
| 345 | + | |
| 346 | + new_path = vboxsf_path_from_dentry(sbi, new_dentry); | |
| 347 | + if (IS_ERR(new_path)) { | |
| 348 | + err = PTR_ERR(new_path); | |
| 349 | + goto err_put_old_path; | |
| 350 | + } | |
| 351 | + | |
| 352 | + if (d_inode(old_dentry)->i_mode & S_IFDIR) | |
| 353 | + shfl_flags = 0; | |
| 354 | + | |
| 355 | + err = vboxsf_rename(sbi->root, old_path, new_path, shfl_flags); | |
| 356 | + if (err == 0) { | |
| 357 | + /* parent directories access/change time changed */ | |
| 358 | + sf_new_parent_i->force_restat = 1; | |
| 359 | + sf_old_parent_i->force_restat = 1; | |
| 360 | + } | |
| 361 | + | |
| 362 | + __putname(new_path); | |
| 363 | +err_put_old_path: | |
| 364 | + __putname(old_path); | |
| 365 | + return err; | |
| 366 | +} | |
| 367 | + | |
| 368 | +static int vboxsf_dir_symlink(struct inode *parent, struct dentry *dentry, | |
| 369 | + const char *symname) | |
| 370 | +{ | |
| 371 | + struct vboxsf_inode *sf_parent_i = VBOXSF_I(parent); | |
| 372 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(parent->i_sb); | |
| 373 | + int symname_size = strlen(symname) + 1; | |
| 374 | + struct shfl_string *path, *ssymname; | |
| 375 | + struct shfl_fsobjinfo info; | |
| 376 | + int err; | |
| 377 | + | |
| 378 | + path = vboxsf_path_from_dentry(sbi, dentry); | |
| 379 | + if (IS_ERR(path)) | |
| 380 | + return PTR_ERR(path); | |
| 381 | + | |
| 382 | + ssymname = kmalloc(SHFLSTRING_HEADER_SIZE + symname_size, GFP_KERNEL); | |
| 383 | + if (!ssymname) { | |
| 384 | + __putname(path); | |
| 385 | + return -ENOMEM; | |
| 386 | + } | |
| 387 | + ssymname->length = symname_size - 1; | |
| 388 | + ssymname->size = symname_size; | |
| 389 | + memcpy(ssymname->string.utf8, symname, symname_size); | |
| 390 | + | |
| 391 | + err = vboxsf_symlink(sbi->root, path, ssymname, &info); | |
| 392 | + kfree(ssymname); | |
| 393 | + __putname(path); | |
| 394 | + if (err) { | |
| 395 | + /* -EROFS means symlinks are note support -> -EPERM */ | |
| 396 | + return (err == -EROFS) ? -EPERM : err; | |
| 397 | + } | |
| 398 | + | |
| 399 | + err = vboxsf_dir_instantiate(parent, dentry, &info); | |
| 400 | + if (err) | |
| 401 | + return err; | |
| 402 | + | |
| 403 | + /* parent directory access/change time changed */ | |
| 404 | + sf_parent_i->force_restat = 1; | |
| 405 | + return 0; | |
| 406 | +} | |
| 407 | + | |
| 408 | +const struct inode_operations vboxsf_dir_iops = { | |
| 409 | + .lookup = vboxsf_dir_lookup, | |
| 410 | + .create = vboxsf_dir_mkfile, | |
| 411 | + .mkdir = vboxsf_dir_mkdir, | |
| 412 | + .rmdir = vboxsf_dir_unlink, | |
| 413 | + .unlink = vboxsf_dir_unlink, | |
| 414 | + .rename = vboxsf_dir_rename, | |
| 415 | + .symlink = vboxsf_dir_symlink, | |
| 416 | + .getattr = vboxsf_getattr, | |
| 417 | + .setattr = vboxsf_setattr, | |
| 418 | +}; | |
| @@ -0,0 +1,370 @@ | ||
| 1 | +// SPDX-License-Identifier: MIT | |
| 2 | +/* | |
| 3 | + * VirtualBox Guest Shared Folders support: Regular file inode and file ops. | |
| 4 | + * | |
| 5 | + * Copyright (C) 2006-2018 Oracle Corporation | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#include <linux/mm.h> | |
| 9 | +#include <linux/page-flags.h> | |
| 10 | +#include <linux/pagemap.h> | |
| 11 | +#include <linux/highmem.h> | |
| 12 | +#include <linux/sizes.h> | |
| 13 | +#include "vfsmod.h" | |
| 14 | + | |
| 15 | +struct vboxsf_handle { | |
| 16 | + u64 handle; | |
| 17 | + u32 root; | |
| 18 | + u32 access_flags; | |
| 19 | + struct kref refcount; | |
| 20 | + struct list_head head; | |
| 21 | +}; | |
| 22 | + | |
| 23 | +static int vboxsf_file_open(struct inode *inode, struct file *file) | |
| 24 | +{ | |
| 25 | + struct vboxsf_inode *sf_i = VBOXSF_I(inode); | |
| 26 | + struct shfl_createparms params = {}; | |
| 27 | + struct vboxsf_handle *sf_handle; | |
| 28 | + u32 access_flags = 0; | |
| 29 | + int err; | |
| 30 | + | |
| 31 | + sf_handle = kmalloc(sizeof(*sf_handle), GFP_KERNEL); | |
| 32 | + if (!sf_handle) | |
| 33 | + return -ENOMEM; | |
| 34 | + | |
| 35 | + /* | |
| 36 | + * We check the value of params.handle afterwards to find out if | |
| 37 | + * the call succeeded or failed, as the API does not seem to cleanly | |
| 38 | + * distinguish error and informational messages. | |
| 39 | + * | |
| 40 | + * Furthermore, we must set params.handle to SHFL_HANDLE_NIL to | |
| 41 | + * make the shared folders host service use our mode parameter. | |
| 42 | + */ | |
| 43 | + params.handle = SHFL_HANDLE_NIL; | |
| 44 | + if (file->f_flags & O_CREAT) { | |
| 45 | + params.create_flags |= SHFL_CF_ACT_CREATE_IF_NEW; | |
| 46 | + /* | |
| 47 | + * We ignore O_EXCL, as the Linux kernel seems to call create | |
| 48 | + * beforehand itself, so O_EXCL should always fail. | |
| 49 | + */ | |
| 50 | + if (file->f_flags & O_TRUNC) | |
| 51 | + params.create_flags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS; | |
| 52 | + else | |
| 53 | + params.create_flags |= SHFL_CF_ACT_OPEN_IF_EXISTS; | |
| 54 | + } else { | |
| 55 | + params.create_flags |= SHFL_CF_ACT_FAIL_IF_NEW; | |
| 56 | + if (file->f_flags & O_TRUNC) | |
| 57 | + params.create_flags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS; | |
| 58 | + } | |
| 59 | + | |
| 60 | + switch (file->f_flags & O_ACCMODE) { | |
| 61 | + case O_RDONLY: | |
| 62 | + access_flags |= SHFL_CF_ACCESS_READ; | |
| 63 | + break; | |
| 64 | + | |
| 65 | + case O_WRONLY: | |
| 66 | + access_flags |= SHFL_CF_ACCESS_WRITE; | |
| 67 | + break; | |
| 68 | + | |
| 69 | + case O_RDWR: | |
| 70 | + access_flags |= SHFL_CF_ACCESS_READWRITE; | |
| 71 | + break; | |
| 72 | + | |
| 73 | + default: | |
| 74 | + WARN_ON(1); | |
| 75 | + } | |
| 76 | + | |
| 77 | + if (file->f_flags & O_APPEND) | |
| 78 | + access_flags |= SHFL_CF_ACCESS_APPEND; | |
| 79 | + | |
| 80 | + params.create_flags |= access_flags; | |
| 81 | + params.info.attr.mode = inode->i_mode; | |
| 82 | + | |
| 83 | + err = vboxsf_create_at_dentry(file_dentry(file), ¶ms); | |
| 84 | + if (err == 0 && params.handle == SHFL_HANDLE_NIL) | |
| 85 | + err = (params.result == SHFL_FILE_EXISTS) ? -EEXIST : -ENOENT; | |
| 86 | + if (err) { | |
| 87 | + kfree(sf_handle); | |
| 88 | + return err; | |
| 89 | + } | |
| 90 | + | |
| 91 | + /* the host may have given us different attr then requested */ | |
| 92 | + sf_i->force_restat = 1; | |
| 93 | + | |
| 94 | + /* init our handle struct and add it to the inode's handles list */ | |
| 95 | + sf_handle->handle = params.handle; | |
| 96 | + sf_handle->root = VBOXSF_SBI(inode->i_sb)->root; | |
| 97 | + sf_handle->access_flags = access_flags; | |
| 98 | + kref_init(&sf_handle->refcount); | |
| 99 | + | |
| 100 | + mutex_lock(&sf_i->handle_list_mutex); | |
| 101 | + list_add(&sf_handle->head, &sf_i->handle_list); | |
| 102 | + mutex_unlock(&sf_i->handle_list_mutex); | |
| 103 | + | |
| 104 | + file->private_data = sf_handle; | |
| 105 | + return 0; | |
| 106 | +} | |
| 107 | + | |
| 108 | +static void vboxsf_handle_release(struct kref *refcount) | |
| 109 | +{ | |
| 110 | + struct vboxsf_handle *sf_handle = | |
| 111 | + container_of(refcount, struct vboxsf_handle, refcount); | |
| 112 | + | |
| 113 | + vboxsf_close(sf_handle->root, sf_handle->handle); | |
| 114 | + kfree(sf_handle); | |
| 115 | +} | |
| 116 | + | |
| 117 | +static int vboxsf_file_release(struct inode *inode, struct file *file) | |
| 118 | +{ | |
| 119 | + struct vboxsf_inode *sf_i = VBOXSF_I(inode); | |
| 120 | + struct vboxsf_handle *sf_handle = file->private_data; | |
| 121 | + | |
| 122 | + /* | |
| 123 | + * When a file is closed on our (the guest) side, we want any subsequent | |
| 124 | + * accesses done on the host side to see all changes done from our side. | |
| 125 | + */ | |
| 126 | + filemap_write_and_wait(inode->i_mapping); | |
| 127 | + | |
| 128 | + mutex_lock(&sf_i->handle_list_mutex); | |
| 129 | + list_del(&sf_handle->head); | |
| 130 | + mutex_unlock(&sf_i->handle_list_mutex); | |
| 131 | + | |
| 132 | + kref_put(&sf_handle->refcount, vboxsf_handle_release); | |
| 133 | + return 0; | |
| 134 | +} | |
| 135 | + | |
| 136 | +/* | |
| 137 | + * Write back dirty pages now, because there may not be any suitable | |
| 138 | + * open files later | |
| 139 | + */ | |
| 140 | +static void vboxsf_vma_close(struct vm_area_struct *vma) | |
| 141 | +{ | |
| 142 | + filemap_write_and_wait(vma->vm_file->f_mapping); | |
| 143 | +} | |
| 144 | + | |
| 145 | +static const struct vm_operations_struct vboxsf_file_vm_ops = { | |
| 146 | + .close = vboxsf_vma_close, | |
| 147 | + .fault = filemap_fault, | |
| 148 | + .map_pages = filemap_map_pages, | |
| 149 | +}; | |
| 150 | + | |
| 151 | +static int vboxsf_file_mmap(struct file *file, struct vm_area_struct *vma) | |
| 152 | +{ | |
| 153 | + int err; | |
| 154 | + | |
| 155 | + err = generic_file_mmap(file, vma); | |
| 156 | + if (!err) | |
| 157 | + vma->vm_ops = &vboxsf_file_vm_ops; | |
| 158 | + | |
| 159 | + return err; | |
| 160 | +} | |
| 161 | + | |
| 162 | +/* | |
| 163 | + * Note that since we are accessing files on the host's filesystem, files | |
| 164 | + * may always be changed underneath us by the host! | |
| 165 | + * | |
| 166 | + * The vboxsf API between the guest and the host does not offer any functions | |
| 167 | + * to deal with this. There is no inode-generation to check for changes, no | |
| 168 | + * events / callback on changes and no way to lock files. | |
| 169 | + * | |
| 170 | + * To avoid returning stale data when a file gets *opened* on our (the guest) | |
| 171 | + * side, we do a "stat" on the host side, then compare the mtime with the | |
| 172 | + * last known mtime and invalidate the page-cache if they differ. | |
| 173 | + * This is done from vboxsf_inode_revalidate(). | |
| 174 | + * | |
| 175 | + * When reads are done through the read_iter fop, it is possible to do | |
| 176 | + * further cache revalidation then, there are 3 options to deal with this: | |
| 177 | + * | |
| 178 | + * 1) Rely solely on the revalidation done at open time | |
| 179 | + * 2) Do another "stat" and compare mtime again. Unfortunately the vboxsf | |
| 180 | + * host API does not allow stat on handles, so we would need to use | |
| 181 | + * file->f_path.dentry and the stat will then fail if the file was unlinked | |
| 182 | + * or renamed (and there is no thing like NFS' silly-rename). So we get: | |
| 183 | + * 2a) "stat" and compare mtime, on stat failure invalidate the cache | |
| 184 | + * 2b) "stat" and compare mtime, on stat failure do nothing | |
| 185 | + * 3) Simply always call invalidate_inode_pages2_range on the range of the read | |
| 186 | + * | |
| 187 | + * Currently we are keeping things KISS and using option 1. this allows | |
| 188 | + * directly using generic_file_read_iter without wrapping it. | |
| 189 | + * | |
| 190 | + * This means that only data written on the host side before open() on | |
| 191 | + * the guest side is guaranteed to be seen by the guest. If necessary | |
| 192 | + * we may provide other read-cache strategies in the future and make this | |
| 193 | + * configurable through a mount option. | |
| 194 | + */ | |
| 195 | +const struct file_operations vboxsf_reg_fops = { | |
| 196 | + .llseek = generic_file_llseek, | |
| 197 | + .read_iter = generic_file_read_iter, | |
| 198 | + .write_iter = generic_file_write_iter, | |
| 199 | + .mmap = vboxsf_file_mmap, | |
| 200 | + .open = vboxsf_file_open, | |
| 201 | + .release = vboxsf_file_release, | |
| 202 | + .fsync = noop_fsync, | |
| 203 | + .splice_read = generic_file_splice_read, | |
| 204 | +}; | |
| 205 | + | |
| 206 | +const struct inode_operations vboxsf_reg_iops = { | |
| 207 | + .getattr = vboxsf_getattr, | |
| 208 | + .setattr = vboxsf_setattr | |
| 209 | +}; | |
| 210 | + | |
| 211 | +static int vboxsf_readpage(struct file *file, struct page *page) | |
| 212 | +{ | |
| 213 | + struct vboxsf_handle *sf_handle = file->private_data; | |
| 214 | + loff_t off = page_offset(page); | |
| 215 | + u32 nread = PAGE_SIZE; | |
| 216 | + u8 *buf; | |
| 217 | + int err; | |
| 218 | + | |
| 219 | + buf = kmap(page); | |
| 220 | + | |
| 221 | + err = vboxsf_read(sf_handle->root, sf_handle->handle, off, &nread, buf); | |
| 222 | + if (err == 0) { | |
| 223 | + memset(&buf[nread], 0, PAGE_SIZE - nread); | |
| 224 | + flush_dcache_page(page); | |
| 225 | + SetPageUptodate(page); | |
| 226 | + } else { | |
| 227 | + SetPageError(page); | |
| 228 | + } | |
| 229 | + | |
| 230 | + kunmap(page); | |
| 231 | + unlock_page(page); | |
| 232 | + return err; | |
| 233 | +} | |
| 234 | + | |
| 235 | +static struct vboxsf_handle *vboxsf_get_write_handle(struct vboxsf_inode *sf_i) | |
| 236 | +{ | |
| 237 | + struct vboxsf_handle *h, *sf_handle = NULL; | |
| 238 | + | |
| 239 | + mutex_lock(&sf_i->handle_list_mutex); | |
| 240 | + list_for_each_entry(h, &sf_i->handle_list, head) { | |
| 241 | + if (h->access_flags == SHFL_CF_ACCESS_WRITE || | |
| 242 | + h->access_flags == SHFL_CF_ACCESS_READWRITE) { | |
| 243 | + kref_get(&h->refcount); | |
| 244 | + sf_handle = h; | |
| 245 | + break; | |
| 246 | + } | |
| 247 | + } | |
| 248 | + mutex_unlock(&sf_i->handle_list_mutex); | |
| 249 | + | |
| 250 | + return sf_handle; | |
| 251 | +} | |
| 252 | + | |
| 253 | +static int vboxsf_writepage(struct page *page, struct writeback_control *wbc) | |
| 254 | +{ | |
| 255 | + struct inode *inode = page->mapping->host; | |
| 256 | + struct vboxsf_inode *sf_i = VBOXSF_I(inode); | |
| 257 | + struct vboxsf_handle *sf_handle; | |
| 258 | + loff_t off = page_offset(page); | |
| 259 | + loff_t size = i_size_read(inode); | |
| 260 | + u32 nwrite = PAGE_SIZE; | |
| 261 | + u8 *buf; | |
| 262 | + int err; | |
| 263 | + | |
| 264 | + if (off + PAGE_SIZE > size) | |
| 265 | + nwrite = size & ~PAGE_MASK; | |
| 266 | + | |
| 267 | + sf_handle = vboxsf_get_write_handle(sf_i); | |
| 268 | + if (!sf_handle) | |
| 269 | + return -EBADF; | |
| 270 | + | |
| 271 | + buf = kmap(page); | |
| 272 | + err = vboxsf_write(sf_handle->root, sf_handle->handle, | |
| 273 | + off, &nwrite, buf); | |
| 274 | + kunmap(page); | |
| 275 | + | |
| 276 | + kref_put(&sf_handle->refcount, vboxsf_handle_release); | |
| 277 | + | |
| 278 | + if (err == 0) { | |
| 279 | + ClearPageError(page); | |
| 280 | + /* mtime changed */ | |
| 281 | + sf_i->force_restat = 1; | |
| 282 | + } else { | |
| 283 | + ClearPageUptodate(page); | |
| 284 | + } | |
| 285 | + | |
| 286 | + unlock_page(page); | |
| 287 | + return err; | |
| 288 | +} | |
| 289 | + | |
| 290 | +static int vboxsf_write_end(struct file *file, struct address_space *mapping, | |
| 291 | + loff_t pos, unsigned int len, unsigned int copied, | |
| 292 | + struct page *page, void *fsdata) | |
| 293 | +{ | |
| 294 | + struct inode *inode = mapping->host; | |
| 295 | + struct vboxsf_handle *sf_handle = file->private_data; | |
| 296 | + unsigned int from = pos & ~PAGE_MASK; | |
| 297 | + u32 nwritten = len; | |
| 298 | + u8 *buf; | |
| 299 | + int err; | |
| 300 | + | |
| 301 | + buf = kmap(page); | |
| 302 | + err = vboxsf_write(sf_handle->root, sf_handle->handle, | |
| 303 | + pos, &nwritten, buf + from); | |
| 304 | + kunmap(page); | |
| 305 | + | |
| 306 | + if (err) { | |
| 307 | + nwritten = 0; | |
| 308 | + goto out; | |
| 309 | + } | |
| 310 | + | |
| 311 | + /* mtime changed */ | |
| 312 | + VBOXSF_I(inode)->force_restat = 1; | |
| 313 | + | |
| 314 | + if (!PageUptodate(page) && nwritten == PAGE_SIZE) | |
| 315 | + SetPageUptodate(page); | |
| 316 | + | |
| 317 | + pos += nwritten; | |
| 318 | + if (pos > inode->i_size) | |
| 319 | + i_size_write(inode, pos); | |
| 320 | + | |
| 321 | +out: | |
| 322 | + unlock_page(page); | |
| 323 | + put_page(page); | |
| 324 | + | |
| 325 | + return nwritten; | |
| 326 | +} | |
| 327 | + | |
| 328 | +const struct address_space_operations vboxsf_reg_aops = { | |
| 329 | + .readpage = vboxsf_readpage, | |
| 330 | + .writepage = vboxsf_writepage, | |
| 331 | + .set_page_dirty = __set_page_dirty_nobuffers, | |
| 332 | + .write_begin = simple_write_begin, | |
| 333 | + .write_end = vboxsf_write_end, | |
| 334 | +}; | |
| 335 | + | |
| 336 | +static const char *vboxsf_get_link(struct dentry *dentry, struct inode *inode, | |
| 337 | + struct delayed_call *done) | |
| 338 | +{ | |
| 339 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(inode->i_sb); | |
| 340 | + struct shfl_string *path; | |
| 341 | + char *link; | |
| 342 | + int err; | |
| 343 | + | |
| 344 | + if (!dentry) | |
| 345 | + return ERR_PTR(-ECHILD); | |
| 346 | + | |
| 347 | + path = vboxsf_path_from_dentry(sbi, dentry); | |
| 348 | + if (IS_ERR(path)) | |
| 349 | + return (char *)path; | |
| 350 | + | |
| 351 | + link = kzalloc(PATH_MAX, GFP_KERNEL); | |
| 352 | + if (!link) { | |
| 353 | + __putname(path); | |
| 354 | + return ERR_PTR(-ENOMEM); | |
| 355 | + } | |
| 356 | + | |
| 357 | + err = vboxsf_readlink(sbi->root, path, PATH_MAX, link); | |
| 358 | + __putname(path); | |
| 359 | + if (err) { | |
| 360 | + kfree(link); | |
| 361 | + return ERR_PTR(err); | |
| 362 | + } | |
| 363 | + | |
| 364 | + set_delayed_call(done, kfree_link, link); | |
| 365 | + return link; | |
| 366 | +} | |
| 367 | + | |
| 368 | +const struct inode_operations vboxsf_lnk_iops = { | |
| 369 | + .get_link = vboxsf_get_link | |
| 370 | +}; | |
| @@ -0,0 +1,901 @@ | ||
| 1 | +/* SPDX-License-Identifier: MIT */ | |
| 2 | +/* | |
| 3 | + * VirtualBox Shared Folders: host interface definition. | |
| 4 | + * | |
| 5 | + * Copyright (C) 2006-2018 Oracle Corporation | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#ifndef SHFL_HOSTINTF_H | |
| 9 | +#define SHFL_HOSTINTF_H | |
| 10 | + | |
| 11 | +#include <linux/vbox_vmmdev_types.h> | |
| 12 | + | |
| 13 | +/* The max in/out buffer size for a FN_READ or FN_WRITE call */ | |
| 14 | +#define SHFL_MAX_RW_COUNT (16 * SZ_1M) | |
| 15 | + | |
| 16 | +/* | |
| 17 | + * Structures shared between guest and the service | |
| 18 | + * can be relocated and use offsets to point to variable | |
| 19 | + * length parts. | |
| 20 | + * | |
| 21 | + * Shared folders protocol works with handles. | |
| 22 | + * Before doing any action on a file system object, | |
| 23 | + * one have to obtain the object handle via a SHFL_FN_CREATE | |
| 24 | + * request. A handle must be closed with SHFL_FN_CLOSE. | |
| 25 | + */ | |
| 26 | + | |
| 27 | +enum { | |
| 28 | + SHFL_FN_QUERY_MAPPINGS = 1, /* Query mappings changes. */ | |
| 29 | + SHFL_FN_QUERY_MAP_NAME = 2, /* Query map name. */ | |
| 30 | + SHFL_FN_CREATE = 3, /* Open/create object. */ | |
| 31 | + SHFL_FN_CLOSE = 4, /* Close object handle. */ | |
| 32 | + SHFL_FN_READ = 5, /* Read object content. */ | |
| 33 | + SHFL_FN_WRITE = 6, /* Write new object content. */ | |
| 34 | + SHFL_FN_LOCK = 7, /* Lock/unlock a range in the object. */ | |
| 35 | + SHFL_FN_LIST = 8, /* List object content. */ | |
| 36 | + SHFL_FN_INFORMATION = 9, /* Query/set object information. */ | |
| 37 | + /* Note function number 10 is not used! */ | |
| 38 | + SHFL_FN_REMOVE = 11, /* Remove object */ | |
| 39 | + SHFL_FN_MAP_FOLDER_OLD = 12, /* Map folder (legacy) */ | |
| 40 | + SHFL_FN_UNMAP_FOLDER = 13, /* Unmap folder */ | |
| 41 | + SHFL_FN_RENAME = 14, /* Rename object */ | |
| 42 | + SHFL_FN_FLUSH = 15, /* Flush file */ | |
| 43 | + SHFL_FN_SET_UTF8 = 16, /* Select UTF8 filename encoding */ | |
| 44 | + SHFL_FN_MAP_FOLDER = 17, /* Map folder */ | |
| 45 | + SHFL_FN_READLINK = 18, /* Read symlink dest (as of VBox 4.0) */ | |
| 46 | + SHFL_FN_SYMLINK = 19, /* Create symlink (as of VBox 4.0) */ | |
| 47 | + SHFL_FN_SET_SYMLINKS = 20, /* Ask host to show symlinks (4.0+) */ | |
| 48 | +}; | |
| 49 | + | |
| 50 | +/* Root handles for a mapping are of type u32, Root handles are unique. */ | |
| 51 | +#define SHFL_ROOT_NIL UINT_MAX | |
| 52 | + | |
| 53 | +/* Shared folders handle for an opened object are of type u64. */ | |
| 54 | +#define SHFL_HANDLE_NIL ULLONG_MAX | |
| 55 | + | |
| 56 | +/* Hardcoded maximum length (in chars) of a shared folder name. */ | |
| 57 | +#define SHFL_MAX_LEN (256) | |
| 58 | +/* Hardcoded maximum number of shared folder mapping available to the guest. */ | |
| 59 | +#define SHFL_MAX_MAPPINGS (64) | |
| 60 | + | |
| 61 | +/** Shared folder string buffer structure. */ | |
| 62 | +struct shfl_string { | |
| 63 | + /** Allocated size of the string member in bytes. */ | |
| 64 | + u16 size; | |
| 65 | + | |
| 66 | + /** Length of string without trailing nul in bytes. */ | |
| 67 | + u16 length; | |
| 68 | + | |
| 69 | + /** UTF-8 or UTF-16 string. Nul terminated. */ | |
| 70 | + union { | |
| 71 | + u8 utf8[2]; | |
| 72 | + u16 utf16[1]; | |
| 73 | + u16 ucs2[1]; /* misnomer, use utf16. */ | |
| 74 | + } string; | |
| 75 | +}; | |
| 76 | +VMMDEV_ASSERT_SIZE(shfl_string, 6); | |
| 77 | + | |
| 78 | +/* The size of shfl_string w/o the string part. */ | |
| 79 | +#define SHFLSTRING_HEADER_SIZE 4 | |
| 80 | + | |
| 81 | +/* Calculate size of the string. */ | |
| 82 | +static inline u32 shfl_string_buf_size(const struct shfl_string *string) | |
| 83 | +{ | |
| 84 | + return string ? SHFLSTRING_HEADER_SIZE + string->size : 0; | |
| 85 | +} | |
| 86 | + | |
| 87 | +/* Set user id on execution (S_ISUID). */ | |
| 88 | +#define SHFL_UNIX_ISUID 0004000U | |
| 89 | +/* Set group id on execution (S_ISGID). */ | |
| 90 | +#define SHFL_UNIX_ISGID 0002000U | |
| 91 | +/* Sticky bit (S_ISVTX / S_ISTXT). */ | |
| 92 | +#define SHFL_UNIX_ISTXT 0001000U | |
| 93 | + | |
| 94 | +/* Owner readable (S_IRUSR). */ | |
| 95 | +#define SHFL_UNIX_IRUSR 0000400U | |
| 96 | +/* Owner writable (S_IWUSR). */ | |
| 97 | +#define SHFL_UNIX_IWUSR 0000200U | |
| 98 | +/* Owner executable (S_IXUSR). */ | |
| 99 | +#define SHFL_UNIX_IXUSR 0000100U | |
| 100 | + | |
| 101 | +/* Group readable (S_IRGRP). */ | |
| 102 | +#define SHFL_UNIX_IRGRP 0000040U | |
| 103 | +/* Group writable (S_IWGRP). */ | |
| 104 | +#define SHFL_UNIX_IWGRP 0000020U | |
| 105 | +/* Group executable (S_IXGRP). */ | |
| 106 | +#define SHFL_UNIX_IXGRP 0000010U | |
| 107 | + | |
| 108 | +/* Other readable (S_IROTH). */ | |
| 109 | +#define SHFL_UNIX_IROTH 0000004U | |
| 110 | +/* Other writable (S_IWOTH). */ | |
| 111 | +#define SHFL_UNIX_IWOTH 0000002U | |
| 112 | +/* Other executable (S_IXOTH). */ | |
| 113 | +#define SHFL_UNIX_IXOTH 0000001U | |
| 114 | + | |
| 115 | +/* Named pipe (fifo) (S_IFIFO). */ | |
| 116 | +#define SHFL_TYPE_FIFO 0010000U | |
| 117 | +/* Character device (S_IFCHR). */ | |
| 118 | +#define SHFL_TYPE_DEV_CHAR 0020000U | |
| 119 | +/* Directory (S_IFDIR). */ | |
| 120 | +#define SHFL_TYPE_DIRECTORY 0040000U | |
| 121 | +/* Block device (S_IFBLK). */ | |
| 122 | +#define SHFL_TYPE_DEV_BLOCK 0060000U | |
| 123 | +/* Regular file (S_IFREG). */ | |
| 124 | +#define SHFL_TYPE_FILE 0100000U | |
| 125 | +/* Symbolic link (S_IFLNK). */ | |
| 126 | +#define SHFL_TYPE_SYMLINK 0120000U | |
| 127 | +/* Socket (S_IFSOCK). */ | |
| 128 | +#define SHFL_TYPE_SOCKET 0140000U | |
| 129 | +/* Whiteout (S_IFWHT). */ | |
| 130 | +#define SHFL_TYPE_WHITEOUT 0160000U | |
| 131 | +/* Type mask (S_IFMT). */ | |
| 132 | +#define SHFL_TYPE_MASK 0170000U | |
| 133 | + | |
| 134 | +/* Checks the mode flags indicate a directory (S_ISDIR). */ | |
| 135 | +#define SHFL_IS_DIRECTORY(m) (((m) & SHFL_TYPE_MASK) == SHFL_TYPE_DIRECTORY) | |
| 136 | +/* Checks the mode flags indicate a symbolic link (S_ISLNK). */ | |
| 137 | +#define SHFL_IS_SYMLINK(m) (((m) & SHFL_TYPE_MASK) == SHFL_TYPE_SYMLINK) | |
| 138 | + | |
| 139 | +/** The available additional information in a shfl_fsobjattr object. */ | |
| 140 | +enum shfl_fsobjattr_add { | |
| 141 | + /** No additional information is available / requested. */ | |
| 142 | + SHFLFSOBJATTRADD_NOTHING = 1, | |
| 143 | + /** | |
| 144 | + * The additional unix attributes (shfl_fsobjattr::u::unix_attr) are | |
| 145 | + * available / requested. | |
| 146 | + */ | |
| 147 | + SHFLFSOBJATTRADD_UNIX, | |
| 148 | + /** | |
| 149 | + * The additional extended attribute size (shfl_fsobjattr::u::size) is | |
| 150 | + * available / requested. | |
| 151 | + */ | |
| 152 | + SHFLFSOBJATTRADD_EASIZE, | |
| 153 | + /** | |
| 154 | + * The last valid item (inclusive). | |
| 155 | + * The valid range is SHFLFSOBJATTRADD_NOTHING thru | |
| 156 | + * SHFLFSOBJATTRADD_LAST. | |
| 157 | + */ | |
| 158 | + SHFLFSOBJATTRADD_LAST = SHFLFSOBJATTRADD_EASIZE, | |
| 159 | + | |
| 160 | + /** The usual 32-bit hack. */ | |
| 161 | + SHFLFSOBJATTRADD_32BIT_SIZE_HACK = 0x7fffffff | |
| 162 | +}; | |
| 163 | + | |
| 164 | +/** | |
| 165 | + * Additional unix Attributes, these are available when | |
| 166 | + * shfl_fsobjattr.additional == SHFLFSOBJATTRADD_UNIX. | |
| 167 | + */ | |
| 168 | +struct shfl_fsobjattr_unix { | |
| 169 | + /** | |
| 170 | + * The user owning the filesystem object (st_uid). | |
| 171 | + * This field is ~0U if not supported. | |
| 172 | + */ | |
| 173 | + u32 uid; | |
| 174 | + | |
| 175 | + /** | |
| 176 | + * The group the filesystem object is assigned (st_gid). | |
| 177 | + * This field is ~0U if not supported. | |
| 178 | + */ | |
| 179 | + u32 gid; | |
| 180 | + | |
| 181 | + /** | |
| 182 | + * Number of hard links to this filesystem object (st_nlink). | |
| 183 | + * This field is 1 if the filesystem doesn't support hardlinking or | |
| 184 | + * the information isn't available. | |
| 185 | + */ | |
| 186 | + u32 hardlinks; | |
| 187 | + | |
| 188 | + /** | |
| 189 | + * The device number of the device which this filesystem object resides | |
| 190 | + * on (st_dev). This field is 0 if this information is not available. | |
| 191 | + */ | |
| 192 | + u32 inode_id_device; | |
| 193 | + | |
| 194 | + /** | |
| 195 | + * The unique identifier (within the filesystem) of this filesystem | |
| 196 | + * object (st_ino). Together with inode_id_device, this field can be | |
| 197 | + * used as a OS wide unique id, when both their values are not 0. | |
| 198 | + * This field is 0 if the information is not available. | |
| 199 | + */ | |
| 200 | + u64 inode_id; | |
| 201 | + | |
| 202 | + /** | |
| 203 | + * User flags (st_flags). | |
| 204 | + * This field is 0 if this information is not available. | |
| 205 | + */ | |
| 206 | + u32 flags; | |
| 207 | + | |
| 208 | + /** | |
| 209 | + * The current generation number (st_gen). | |
| 210 | + * This field is 0 if this information is not available. | |
| 211 | + */ | |
| 212 | + u32 generation_id; | |
| 213 | + | |
| 214 | + /** | |
| 215 | + * The device number of a char. or block device type object (st_rdev). | |
| 216 | + * This field is 0 if the file isn't a char. or block device or when | |
| 217 | + * the OS doesn't use the major+minor device idenfication scheme. | |
| 218 | + */ | |
| 219 | + u32 device; | |
| 220 | +} __packed; | |
| 221 | + | |
| 222 | +/** Extended attribute size. */ | |
| 223 | +struct shfl_fsobjattr_easize { | |
| 224 | + /** Size of EAs. */ | |
| 225 | + s64 cb; | |
| 226 | +} __packed; | |
| 227 | + | |
| 228 | +/** Shared folder filesystem object attributes. */ | |
| 229 | +struct shfl_fsobjattr { | |
| 230 | + /** Mode flags (st_mode). SHFL_UNIX_*, SHFL_TYPE_*, and SHFL_DOS_*. */ | |
| 231 | + u32 mode; | |
| 232 | + | |
| 233 | + /** The additional attributes available. */ | |
| 234 | + enum shfl_fsobjattr_add additional; | |
| 235 | + | |
| 236 | + /** | |
| 237 | + * Additional attributes. | |
| 238 | + * | |
| 239 | + * Unless explicitly specified to an API, the API can provide additional | |
| 240 | + * data as it is provided by the underlying OS. | |
| 241 | + */ | |
| 242 | + union { | |
| 243 | + struct shfl_fsobjattr_unix unix_attr; | |
| 244 | + struct shfl_fsobjattr_easize size; | |
| 245 | + } __packed u; | |
| 246 | +} __packed; | |
| 247 | +VMMDEV_ASSERT_SIZE(shfl_fsobjattr, 44); | |
| 248 | + | |
| 249 | +struct shfl_timespec { | |
| 250 | + s64 ns_relative_to_unix_epoch; | |
| 251 | +}; | |
| 252 | + | |
| 253 | +/** Filesystem object information structure. */ | |
| 254 | +struct shfl_fsobjinfo { | |
| 255 | + /** | |
| 256 | + * Logical size (st_size). | |
| 257 | + * For normal files this is the size of the file. | |
| 258 | + * For symbolic links, this is the length of the path name contained | |
| 259 | + * in the symbolic link. | |
| 260 | + * For other objects this fields needs to be specified. | |
| 261 | + */ | |
| 262 | + s64 size; | |
| 263 | + | |
| 264 | + /** Disk allocation size (st_blocks * DEV_BSIZE). */ | |
| 265 | + s64 allocated; | |
| 266 | + | |
| 267 | + /** Time of last access (st_atime). */ | |
| 268 | + struct shfl_timespec access_time; | |
| 269 | + | |
| 270 | + /** Time of last data modification (st_mtime). */ | |
| 271 | + struct shfl_timespec modification_time; | |
| 272 | + | |
| 273 | + /** | |
| 274 | + * Time of last status change (st_ctime). | |
| 275 | + * If not available this is set to modification_time. | |
| 276 | + */ | |
| 277 | + struct shfl_timespec change_time; | |
| 278 | + | |
| 279 | + /** | |
| 280 | + * Time of file birth (st_birthtime). | |
| 281 | + * If not available this is set to change_time. | |
| 282 | + */ | |
| 283 | + struct shfl_timespec birth_time; | |
| 284 | + | |
| 285 | + /** Attributes. */ | |
| 286 | + struct shfl_fsobjattr attr; | |
| 287 | + | |
| 288 | +} __packed; | |
| 289 | +VMMDEV_ASSERT_SIZE(shfl_fsobjinfo, 92); | |
| 290 | + | |
| 291 | +/** | |
| 292 | + * result of an open/create request. | |
| 293 | + * Along with handle value the result code | |
| 294 | + * identifies what has happened while | |
| 295 | + * trying to open the object. | |
| 296 | + */ | |
| 297 | +enum shfl_create_result { | |
| 298 | + SHFL_NO_RESULT, | |
| 299 | + /** Specified path does not exist. */ | |
| 300 | + SHFL_PATH_NOT_FOUND, | |
| 301 | + /** Path to file exists, but the last component does not. */ | |
| 302 | + SHFL_FILE_NOT_FOUND, | |
| 303 | + /** File already exists and either has been opened or not. */ | |
| 304 | + SHFL_FILE_EXISTS, | |
| 305 | + /** New file was created. */ | |
| 306 | + SHFL_FILE_CREATED, | |
| 307 | + /** Existing file was replaced or overwritten. */ | |
| 308 | + SHFL_FILE_REPLACED | |
| 309 | +}; | |
| 310 | + | |
| 311 | +/* No flags. Initialization value. */ | |
| 312 | +#define SHFL_CF_NONE (0x00000000) | |
| 313 | + | |
| 314 | +/* | |
| 315 | + * Only lookup the object, do not return a handle. When this is set all other | |
| 316 | + * flags are ignored. | |
| 317 | + */ | |
| 318 | +#define SHFL_CF_LOOKUP (0x00000001) | |
| 319 | + | |
| 320 | +/* | |
| 321 | + * Open parent directory of specified object. | |
| 322 | + * Useful for the corresponding Windows FSD flag | |
| 323 | + * and for opening paths like \\dir\\*.* to search the 'dir'. | |
| 324 | + */ | |
| 325 | +#define SHFL_CF_OPEN_TARGET_DIRECTORY (0x00000002) | |
| 326 | + | |
| 327 | +/* Create/open a directory. */ | |
| 328 | +#define SHFL_CF_DIRECTORY (0x00000004) | |
| 329 | + | |
| 330 | +/* | |
| 331 | + * Open/create action to do if object exists | |
| 332 | + * and if the object does not exists. | |
| 333 | + * REPLACE file means atomically DELETE and CREATE. | |
| 334 | + * OVERWRITE file means truncating the file to 0 and | |
| 335 | + * setting new size. | |
| 336 | + * When opening an existing directory REPLACE and OVERWRITE | |
| 337 | + * actions are considered invalid, and cause returning | |
| 338 | + * FILE_EXISTS with NIL handle. | |
| 339 | + */ | |
| 340 | +#define SHFL_CF_ACT_MASK_IF_EXISTS (0x000000f0) | |
| 341 | +#define SHFL_CF_ACT_MASK_IF_NEW (0x00000f00) | |
| 342 | + | |
| 343 | +/* What to do if object exists. */ | |
| 344 | +#define SHFL_CF_ACT_OPEN_IF_EXISTS (0x00000000) | |
| 345 | +#define SHFL_CF_ACT_FAIL_IF_EXISTS (0x00000010) | |
| 346 | +#define SHFL_CF_ACT_REPLACE_IF_EXISTS (0x00000020) | |
| 347 | +#define SHFL_CF_ACT_OVERWRITE_IF_EXISTS (0x00000030) | |
| 348 | + | |
| 349 | +/* What to do if object does not exist. */ | |
| 350 | +#define SHFL_CF_ACT_CREATE_IF_NEW (0x00000000) | |
| 351 | +#define SHFL_CF_ACT_FAIL_IF_NEW (0x00000100) | |
| 352 | + | |
| 353 | +/* Read/write requested access for the object. */ | |
| 354 | +#define SHFL_CF_ACCESS_MASK_RW (0x00003000) | |
| 355 | + | |
| 356 | +/* No access requested. */ | |
| 357 | +#define SHFL_CF_ACCESS_NONE (0x00000000) | |
| 358 | +/* Read access requested. */ | |
| 359 | +#define SHFL_CF_ACCESS_READ (0x00001000) | |
| 360 | +/* Write access requested. */ | |
| 361 | +#define SHFL_CF_ACCESS_WRITE (0x00002000) | |
| 362 | +/* Read/Write access requested. */ | |
| 363 | +#define SHFL_CF_ACCESS_READWRITE (0x00003000) | |
| 364 | + | |
| 365 | +/* Requested share access for the object. */ | |
| 366 | +#define SHFL_CF_ACCESS_MASK_DENY (0x0000c000) | |
| 367 | + | |
| 368 | +/* Allow any access. */ | |
| 369 | +#define SHFL_CF_ACCESS_DENYNONE (0x00000000) | |
| 370 | +/* Do not allow read. */ | |
| 371 | +#define SHFL_CF_ACCESS_DENYREAD (0x00004000) | |
| 372 | +/* Do not allow write. */ | |
| 373 | +#define SHFL_CF_ACCESS_DENYWRITE (0x00008000) | |
| 374 | +/* Do not allow access. */ | |
| 375 | +#define SHFL_CF_ACCESS_DENYALL (0x0000c000) | |
| 376 | + | |
| 377 | +/* Requested access to attributes of the object. */ | |
| 378 | +#define SHFL_CF_ACCESS_MASK_ATTR (0x00030000) | |
| 379 | + | |
| 380 | +/* No access requested. */ | |
| 381 | +#define SHFL_CF_ACCESS_ATTR_NONE (0x00000000) | |
| 382 | +/* Read access requested. */ | |
| 383 | +#define SHFL_CF_ACCESS_ATTR_READ (0x00010000) | |
| 384 | +/* Write access requested. */ | |
| 385 | +#define SHFL_CF_ACCESS_ATTR_WRITE (0x00020000) | |
| 386 | +/* Read/Write access requested. */ | |
| 387 | +#define SHFL_CF_ACCESS_ATTR_READWRITE (0x00030000) | |
| 388 | + | |
| 389 | +/* | |
| 390 | + * The file is opened in append mode. | |
| 391 | + * Ignored if SHFL_CF_ACCESS_WRITE is not set. | |
| 392 | + */ | |
| 393 | +#define SHFL_CF_ACCESS_APPEND (0x00040000) | |
| 394 | + | |
| 395 | +/** Create parameters buffer struct for SHFL_FN_CREATE call */ | |
| 396 | +struct shfl_createparms { | |
| 397 | + /** Returned handle of opened object. */ | |
| 398 | + u64 handle; | |
| 399 | + | |
| 400 | + /** Returned result of the operation */ | |
| 401 | + enum shfl_create_result result; | |
| 402 | + | |
| 403 | + /** SHFL_CF_* */ | |
| 404 | + u32 create_flags; | |
| 405 | + | |
| 406 | + /** | |
| 407 | + * Attributes of object to create and | |
| 408 | + * returned actual attributes of opened/created object. | |
| 409 | + */ | |
| 410 | + struct shfl_fsobjinfo info; | |
| 411 | +} __packed; | |
| 412 | + | |
| 413 | +/** Shared Folder directory information */ | |
| 414 | +struct shfl_dirinfo { | |
| 415 | + /** Full information about the object. */ | |
| 416 | + struct shfl_fsobjinfo info; | |
| 417 | + /** | |
| 418 | + * The length of the short field (number of UTF16 chars). | |
| 419 | + * It is 16-bit for reasons of alignment. | |
| 420 | + */ | |
| 421 | + u16 short_name_len; | |
| 422 | + /** | |
| 423 | + * The short name for 8.3 compatibility. | |
| 424 | + * Empty string if not available. | |
| 425 | + */ | |
| 426 | + u16 short_name[14]; | |
| 427 | + struct shfl_string name; | |
| 428 | +}; | |
| 429 | + | |
| 430 | +/** Shared folder filesystem properties. */ | |
| 431 | +struct shfl_fsproperties { | |
| 432 | + /** | |
| 433 | + * The maximum size of a filesystem object name. | |
| 434 | + * This does not include the '\\0'. | |
| 435 | + */ | |
| 436 | + u32 max_component_len; | |
| 437 | + | |
| 438 | + /** | |
| 439 | + * True if the filesystem is remote. | |
| 440 | + * False if the filesystem is local. | |
| 441 | + */ | |
| 442 | + bool remote; | |
| 443 | + | |
| 444 | + /** | |
| 445 | + * True if the filesystem is case sensitive. | |
| 446 | + * False if the filesystem is case insensitive. | |
| 447 | + */ | |
| 448 | + bool case_sensitive; | |
| 449 | + | |
| 450 | + /** | |
| 451 | + * True if the filesystem is mounted read only. | |
| 452 | + * False if the filesystem is mounted read write. | |
| 453 | + */ | |
| 454 | + bool read_only; | |
| 455 | + | |
| 456 | + /** | |
| 457 | + * True if the filesystem can encode unicode object names. | |
| 458 | + * False if it can't. | |
| 459 | + */ | |
| 460 | + bool supports_unicode; | |
| 461 | + | |
| 462 | + /** | |
| 463 | + * True if the filesystem is compresses. | |
| 464 | + * False if it isn't or we don't know. | |
| 465 | + */ | |
| 466 | + bool compressed; | |
| 467 | + | |
| 468 | + /** | |
| 469 | + * True if the filesystem compresses of individual files. | |
| 470 | + * False if it doesn't or we don't know. | |
| 471 | + */ | |
| 472 | + bool file_compression; | |
| 473 | +}; | |
| 474 | +VMMDEV_ASSERT_SIZE(shfl_fsproperties, 12); | |
| 475 | + | |
| 476 | +struct shfl_volinfo { | |
| 477 | + s64 total_allocation_bytes; | |
| 478 | + s64 available_allocation_bytes; | |
| 479 | + u32 bytes_per_allocation_unit; | |
| 480 | + u32 bytes_per_sector; | |
| 481 | + u32 serial; | |
| 482 | + struct shfl_fsproperties properties; | |
| 483 | +}; | |
| 484 | + | |
| 485 | + | |
| 486 | +/** SHFL_FN_MAP_FOLDER Parameters structure. */ | |
| 487 | +struct shfl_map_folder { | |
| 488 | + /** | |
| 489 | + * pointer, in: | |
| 490 | + * Points to struct shfl_string buffer. | |
| 491 | + */ | |
| 492 | + struct vmmdev_hgcm_function_parameter path; | |
| 493 | + | |
| 494 | + /** | |
| 495 | + * pointer, out: SHFLROOT (u32) | |
| 496 | + * Root handle of the mapping which name is queried. | |
| 497 | + */ | |
| 498 | + struct vmmdev_hgcm_function_parameter root; | |
| 499 | + | |
| 500 | + /** | |
| 501 | + * pointer, in: UTF16 | |
| 502 | + * Path delimiter | |
| 503 | + */ | |
| 504 | + struct vmmdev_hgcm_function_parameter delimiter; | |
| 505 | + | |
| 506 | + /** | |
| 507 | + * pointer, in: SHFLROOT (u32) | |
| 508 | + * Case senstive flag | |
| 509 | + */ | |
| 510 | + struct vmmdev_hgcm_function_parameter case_sensitive; | |
| 511 | + | |
| 512 | +}; | |
| 513 | + | |
| 514 | +/* Number of parameters */ | |
| 515 | +#define SHFL_CPARMS_MAP_FOLDER (4) | |
| 516 | + | |
| 517 | + | |
| 518 | +/** SHFL_FN_UNMAP_FOLDER Parameters structure. */ | |
| 519 | +struct shfl_unmap_folder { | |
| 520 | + /** | |
| 521 | + * pointer, in: SHFLROOT (u32) | |
| 522 | + * Root handle of the mapping which name is queried. | |
| 523 | + */ | |
| 524 | + struct vmmdev_hgcm_function_parameter root; | |
| 525 | + | |
| 526 | +}; | |
| 527 | + | |
| 528 | +/* Number of parameters */ | |
| 529 | +#define SHFL_CPARMS_UNMAP_FOLDER (1) | |
| 530 | + | |
| 531 | + | |
| 532 | +/** SHFL_FN_CREATE Parameters structure. */ | |
| 533 | +struct shfl_create { | |
| 534 | + /** | |
| 535 | + * pointer, in: SHFLROOT (u32) | |
| 536 | + * Root handle of the mapping which name is queried. | |
| 537 | + */ | |
| 538 | + struct vmmdev_hgcm_function_parameter root; | |
| 539 | + | |
| 540 | + /** | |
| 541 | + * pointer, in: | |
| 542 | + * Points to struct shfl_string buffer. | |
| 543 | + */ | |
| 544 | + struct vmmdev_hgcm_function_parameter path; | |
| 545 | + | |
| 546 | + /** | |
| 547 | + * pointer, in/out: | |
| 548 | + * Points to struct shfl_createparms buffer. | |
| 549 | + */ | |
| 550 | + struct vmmdev_hgcm_function_parameter parms; | |
| 551 | + | |
| 552 | +}; | |
| 553 | + | |
| 554 | +/* Number of parameters */ | |
| 555 | +#define SHFL_CPARMS_CREATE (3) | |
| 556 | + | |
| 557 | + | |
| 558 | +/** SHFL_FN_CLOSE Parameters structure. */ | |
| 559 | +struct shfl_close { | |
| 560 | + /** | |
| 561 | + * pointer, in: SHFLROOT (u32) | |
| 562 | + * Root handle of the mapping which name is queried. | |
| 563 | + */ | |
| 564 | + struct vmmdev_hgcm_function_parameter root; | |
| 565 | + | |
| 566 | + /** | |
| 567 | + * value64, in: | |
| 568 | + * SHFLHANDLE (u64) of object to close. | |
| 569 | + */ | |
| 570 | + struct vmmdev_hgcm_function_parameter handle; | |
| 571 | + | |
| 572 | +}; | |
| 573 | + | |
| 574 | +/* Number of parameters */ | |
| 575 | +#define SHFL_CPARMS_CLOSE (2) | |
| 576 | + | |
| 577 | + | |
| 578 | +/** SHFL_FN_READ Parameters structure. */ | |
| 579 | +struct shfl_read { | |
| 580 | + /** | |
| 581 | + * pointer, in: SHFLROOT (u32) | |
| 582 | + * Root handle of the mapping which name is queried. | |
| 583 | + */ | |
| 584 | + struct vmmdev_hgcm_function_parameter root; | |
| 585 | + | |
| 586 | + /** | |
| 587 | + * value64, in: | |
| 588 | + * SHFLHANDLE (u64) of object to read from. | |
| 589 | + */ | |
| 590 | + struct vmmdev_hgcm_function_parameter handle; | |
| 591 | + | |
| 592 | + /** | |
| 593 | + * value64, in: | |
| 594 | + * Offset to read from. | |
| 595 | + */ | |
| 596 | + struct vmmdev_hgcm_function_parameter offset; | |
| 597 | + | |
| 598 | + /** | |
| 599 | + * value64, in/out: | |
| 600 | + * Bytes to read/How many were read. | |
| 601 | + */ | |
| 602 | + struct vmmdev_hgcm_function_parameter cb; | |
| 603 | + | |
| 604 | + /** | |
| 605 | + * pointer, out: | |
| 606 | + * Buffer to place data to. | |
| 607 | + */ | |
| 608 | + struct vmmdev_hgcm_function_parameter buffer; | |
| 609 | + | |
| 610 | +}; | |
| 611 | + | |
| 612 | +/* Number of parameters */ | |
| 613 | +#define SHFL_CPARMS_READ (5) | |
| 614 | + | |
| 615 | + | |
| 616 | +/** SHFL_FN_WRITE Parameters structure. */ | |
| 617 | +struct shfl_write { | |
| 618 | + /** | |
| 619 | + * pointer, in: SHFLROOT (u32) | |
| 620 | + * Root handle of the mapping which name is queried. | |
| 621 | + */ | |
| 622 | + struct vmmdev_hgcm_function_parameter root; | |
| 623 | + | |
| 624 | + /** | |
| 625 | + * value64, in: | |
| 626 | + * SHFLHANDLE (u64) of object to write to. | |
| 627 | + */ | |
| 628 | + struct vmmdev_hgcm_function_parameter handle; | |
| 629 | + | |
| 630 | + /** | |
| 631 | + * value64, in: | |
| 632 | + * Offset to write to. | |
| 633 | + */ | |
| 634 | + struct vmmdev_hgcm_function_parameter offset; | |
| 635 | + | |
| 636 | + /** | |
| 637 | + * value64, in/out: | |
| 638 | + * Bytes to write/How many were written. | |
| 639 | + */ | |
| 640 | + struct vmmdev_hgcm_function_parameter cb; | |
| 641 | + | |
| 642 | + /** | |
| 643 | + * pointer, in: | |
| 644 | + * Data to write. | |
| 645 | + */ | |
| 646 | + struct vmmdev_hgcm_function_parameter buffer; | |
| 647 | + | |
| 648 | +}; | |
| 649 | + | |
| 650 | +/* Number of parameters */ | |
| 651 | +#define SHFL_CPARMS_WRITE (5) | |
| 652 | + | |
| 653 | + | |
| 654 | +/* | |
| 655 | + * SHFL_FN_LIST | |
| 656 | + * Listing information includes variable length RTDIRENTRY[EX] structures. | |
| 657 | + */ | |
| 658 | + | |
| 659 | +#define SHFL_LIST_NONE 0 | |
| 660 | +#define SHFL_LIST_RETURN_ONE 1 | |
| 661 | + | |
| 662 | +/** SHFL_FN_LIST Parameters structure. */ | |
| 663 | +struct shfl_list { | |
| 664 | + /** | |
| 665 | + * pointer, in: SHFLROOT (u32) | |
| 666 | + * Root handle of the mapping which name is queried. | |
| 667 | + */ | |
| 668 | + struct vmmdev_hgcm_function_parameter root; | |
| 669 | + | |
| 670 | + /** | |
| 671 | + * value64, in: | |
| 672 | + * SHFLHANDLE (u64) of object to be listed. | |
| 673 | + */ | |
| 674 | + struct vmmdev_hgcm_function_parameter handle; | |
| 675 | + | |
| 676 | + /** | |
| 677 | + * value32, in: | |
| 678 | + * List flags SHFL_LIST_*. | |
| 679 | + */ | |
| 680 | + struct vmmdev_hgcm_function_parameter flags; | |
| 681 | + | |
| 682 | + /** | |
| 683 | + * value32, in/out: | |
| 684 | + * Bytes to be used for listing information/How many bytes were used. | |
| 685 | + */ | |
| 686 | + struct vmmdev_hgcm_function_parameter cb; | |
| 687 | + | |
| 688 | + /** | |
| 689 | + * pointer, in/optional | |
| 690 | + * Points to struct shfl_string buffer that specifies a search path. | |
| 691 | + */ | |
| 692 | + struct vmmdev_hgcm_function_parameter path; | |
| 693 | + | |
| 694 | + /** | |
| 695 | + * pointer, out: | |
| 696 | + * Buffer to place listing information to. (struct shfl_dirinfo) | |
| 697 | + */ | |
| 698 | + struct vmmdev_hgcm_function_parameter buffer; | |
| 699 | + | |
| 700 | + /** | |
| 701 | + * value32, in/out: | |
| 702 | + * Indicates a key where the listing must be resumed. | |
| 703 | + * in: 0 means start from begin of object. | |
| 704 | + * out: 0 means listing completed. | |
| 705 | + */ | |
| 706 | + struct vmmdev_hgcm_function_parameter resume_point; | |
| 707 | + | |
| 708 | + /** | |
| 709 | + * pointer, out: | |
| 710 | + * Number of files returned | |
| 711 | + */ | |
| 712 | + struct vmmdev_hgcm_function_parameter file_count; | |
| 713 | +}; | |
| 714 | + | |
| 715 | +/* Number of parameters */ | |
| 716 | +#define SHFL_CPARMS_LIST (8) | |
| 717 | + | |
| 718 | + | |
| 719 | +/** SHFL_FN_READLINK Parameters structure. */ | |
| 720 | +struct shfl_readLink { | |
| 721 | + /** | |
| 722 | + * pointer, in: SHFLROOT (u32) | |
| 723 | + * Root handle of the mapping which name is queried. | |
| 724 | + */ | |
| 725 | + struct vmmdev_hgcm_function_parameter root; | |
| 726 | + | |
| 727 | + /** | |
| 728 | + * pointer, in: | |
| 729 | + * Points to struct shfl_string buffer. | |
| 730 | + */ | |
| 731 | + struct vmmdev_hgcm_function_parameter path; | |
| 732 | + | |
| 733 | + /** | |
| 734 | + * pointer, out: | |
| 735 | + * Buffer to place data to. | |
| 736 | + */ | |
| 737 | + struct vmmdev_hgcm_function_parameter buffer; | |
| 738 | + | |
| 739 | +}; | |
| 740 | + | |
| 741 | +/* Number of parameters */ | |
| 742 | +#define SHFL_CPARMS_READLINK (3) | |
| 743 | + | |
| 744 | + | |
| 745 | +/* SHFL_FN_INFORMATION */ | |
| 746 | + | |
| 747 | +/* Mask of Set/Get bit. */ | |
| 748 | +#define SHFL_INFO_MODE_MASK (0x1) | |
| 749 | +/* Get information */ | |
| 750 | +#define SHFL_INFO_GET (0x0) | |
| 751 | +/* Set information */ | |
| 752 | +#define SHFL_INFO_SET (0x1) | |
| 753 | + | |
| 754 | +/* Get name of the object. */ | |
| 755 | +#define SHFL_INFO_NAME (0x2) | |
| 756 | +/* Set size of object (extend/trucate); only applies to file objects */ | |
| 757 | +#define SHFL_INFO_SIZE (0x4) | |
| 758 | +/* Get/Set file object info. */ | |
| 759 | +#define SHFL_INFO_FILE (0x8) | |
| 760 | +/* Get volume information. */ | |
| 761 | +#define SHFL_INFO_VOLUME (0x10) | |
| 762 | + | |
| 763 | +/** SHFL_FN_INFORMATION Parameters structure. */ | |
| 764 | +struct shfl_information { | |
| 765 | + /** | |
| 766 | + * pointer, in: SHFLROOT (u32) | |
| 767 | + * Root handle of the mapping which name is queried. | |
| 768 | + */ | |
| 769 | + struct vmmdev_hgcm_function_parameter root; | |
| 770 | + | |
| 771 | + /** | |
| 772 | + * value64, in: | |
| 773 | + * SHFLHANDLE (u64) of object to be listed. | |
| 774 | + */ | |
| 775 | + struct vmmdev_hgcm_function_parameter handle; | |
| 776 | + | |
| 777 | + /** | |
| 778 | + * value32, in: | |
| 779 | + * SHFL_INFO_* | |
| 780 | + */ | |
| 781 | + struct vmmdev_hgcm_function_parameter flags; | |
| 782 | + | |
| 783 | + /** | |
| 784 | + * value32, in/out: | |
| 785 | + * Bytes to be used for information/How many bytes were used. | |
| 786 | + */ | |
| 787 | + struct vmmdev_hgcm_function_parameter cb; | |
| 788 | + | |
| 789 | + /** | |
| 790 | + * pointer, in/out: | |
| 791 | + * Information to be set/get (shfl_fsobjinfo or shfl_string). Do not | |
| 792 | + * forget to set the shfl_fsobjinfo::attr::additional for a get | |
| 793 | + * operation as well. | |
| 794 | + */ | |
| 795 | + struct vmmdev_hgcm_function_parameter info; | |
| 796 | + | |
| 797 | +}; | |
| 798 | + | |
| 799 | +/* Number of parameters */ | |
| 800 | +#define SHFL_CPARMS_INFORMATION (5) | |
| 801 | + | |
| 802 | + | |
| 803 | +/* SHFL_FN_REMOVE */ | |
| 804 | + | |
| 805 | +#define SHFL_REMOVE_FILE (0x1) | |
| 806 | +#define SHFL_REMOVE_DIR (0x2) | |
| 807 | +#define SHFL_REMOVE_SYMLINK (0x4) | |
| 808 | + | |
| 809 | +/** SHFL_FN_REMOVE Parameters structure. */ | |
| 810 | +struct shfl_remove { | |
| 811 | + /** | |
| 812 | + * pointer, in: SHFLROOT (u32) | |
| 813 | + * Root handle of the mapping which name is queried. | |
| 814 | + */ | |
| 815 | + struct vmmdev_hgcm_function_parameter root; | |
| 816 | + | |
| 817 | + /** | |
| 818 | + * pointer, in: | |
| 819 | + * Points to struct shfl_string buffer. | |
| 820 | + */ | |
| 821 | + struct vmmdev_hgcm_function_parameter path; | |
| 822 | + | |
| 823 | + /** | |
| 824 | + * value32, in: | |
| 825 | + * remove flags (file/directory) | |
| 826 | + */ | |
| 827 | + struct vmmdev_hgcm_function_parameter flags; | |
| 828 | + | |
| 829 | +}; | |
| 830 | + | |
| 831 | +#define SHFL_CPARMS_REMOVE (3) | |
| 832 | + | |
| 833 | + | |
| 834 | +/* SHFL_FN_RENAME */ | |
| 835 | + | |
| 836 | +#define SHFL_RENAME_FILE (0x1) | |
| 837 | +#define SHFL_RENAME_DIR (0x2) | |
| 838 | +#define SHFL_RENAME_REPLACE_IF_EXISTS (0x4) | |
| 839 | + | |
| 840 | +/** SHFL_FN_RENAME Parameters structure. */ | |
| 841 | +struct shfl_rename { | |
| 842 | + /** | |
| 843 | + * pointer, in: SHFLROOT (u32) | |
| 844 | + * Root handle of the mapping which name is queried. | |
| 845 | + */ | |
| 846 | + struct vmmdev_hgcm_function_parameter root; | |
| 847 | + | |
| 848 | + /** | |
| 849 | + * pointer, in: | |
| 850 | + * Points to struct shfl_string src. | |
| 851 | + */ | |
| 852 | + struct vmmdev_hgcm_function_parameter src; | |
| 853 | + | |
| 854 | + /** | |
| 855 | + * pointer, in: | |
| 856 | + * Points to struct shfl_string dest. | |
| 857 | + */ | |
| 858 | + struct vmmdev_hgcm_function_parameter dest; | |
| 859 | + | |
| 860 | + /** | |
| 861 | + * value32, in: | |
| 862 | + * rename flags (file/directory) | |
| 863 | + */ | |
| 864 | + struct vmmdev_hgcm_function_parameter flags; | |
| 865 | + | |
| 866 | +}; | |
| 867 | + | |
| 868 | +#define SHFL_CPARMS_RENAME (4) | |
| 869 | + | |
| 870 | + | |
| 871 | +/** SHFL_FN_SYMLINK Parameters structure. */ | |
| 872 | +struct shfl_symlink { | |
| 873 | + /** | |
| 874 | + * pointer, in: SHFLROOT (u32) | |
| 875 | + * Root handle of the mapping which name is queried. | |
| 876 | + */ | |
| 877 | + struct vmmdev_hgcm_function_parameter root; | |
| 878 | + | |
| 879 | + /** | |
| 880 | + * pointer, in: | |
| 881 | + * Points to struct shfl_string of path for the new symlink. | |
| 882 | + */ | |
| 883 | + struct vmmdev_hgcm_function_parameter new_path; | |
| 884 | + | |
| 885 | + /** | |
| 886 | + * pointer, in: | |
| 887 | + * Points to struct shfl_string of destination for symlink. | |
| 888 | + */ | |
| 889 | + struct vmmdev_hgcm_function_parameter old_path; | |
| 890 | + | |
| 891 | + /** | |
| 892 | + * pointer, out: | |
| 893 | + * Information about created symlink. | |
| 894 | + */ | |
| 895 | + struct vmmdev_hgcm_function_parameter info; | |
| 896 | + | |
| 897 | +}; | |
| 898 | + | |
| 899 | +#define SHFL_CPARMS_SYMLINK (4) | |
| 900 | + | |
| 901 | +#endif | |
| @@ -0,0 +1,501 @@ | ||
| 1 | +// SPDX-License-Identifier: MIT | |
| 2 | +/* | |
| 3 | + * VirtualBox Guest Shared Folders support: Virtual File System. | |
| 4 | + * | |
| 5 | + * Module initialization/finalization | |
| 6 | + * File system registration/deregistration | |
| 7 | + * Superblock reading | |
| 8 | + * Few utility functions | |
| 9 | + * | |
| 10 | + * Copyright (C) 2006-2018 Oracle Corporation | |
| 11 | + */ | |
| 12 | + | |
| 13 | +#include <linux/idr.h> | |
| 14 | +#include <linux/fs_parser.h> | |
| 15 | +#include <linux/magic.h> | |
| 16 | +#include <linux/module.h> | |
| 17 | +#include <linux/nls.h> | |
| 18 | +#include <linux/statfs.h> | |
| 19 | +#include <linux/vbox_utils.h> | |
| 20 | +#include "vfsmod.h" | |
| 21 | + | |
| 22 | +#define VBOXSF_SUPER_MAGIC 0x786f4256 /* 'VBox' little endian */ | |
| 23 | + | |
| 24 | +#define VBSF_MOUNT_SIGNATURE_BYTE_0 ('\000') | |
| 25 | +#define VBSF_MOUNT_SIGNATURE_BYTE_1 ('\377') | |
| 26 | +#define VBSF_MOUNT_SIGNATURE_BYTE_2 ('\376') | |
| 27 | +#define VBSF_MOUNT_SIGNATURE_BYTE_3 ('\375') | |
| 28 | + | |
| 29 | +static int follow_symlinks; | |
| 30 | +module_param(follow_symlinks, int, 0444); | |
| 31 | +MODULE_PARM_DESC(follow_symlinks, | |
| 32 | + "Let host resolve symlinks rather than showing them"); | |
| 33 | + | |
| 34 | +static DEFINE_IDA(vboxsf_bdi_ida); | |
| 35 | +static DEFINE_MUTEX(vboxsf_setup_mutex); | |
| 36 | +static bool vboxsf_setup_done; | |
| 37 | +static struct super_operations vboxsf_super_ops; /* forward declaration */ | |
| 38 | +static struct kmem_cache *vboxsf_inode_cachep; | |
| 39 | + | |
| 40 | +static char * const vboxsf_default_nls = CONFIG_NLS_DEFAULT; | |
| 41 | + | |
| 42 | +enum { opt_nls, opt_uid, opt_gid, opt_ttl, opt_dmode, opt_fmode, | |
| 43 | + opt_dmask, opt_fmask }; | |
| 44 | + | |
| 45 | +static const struct fs_parameter_spec vboxsf_param_specs[] = { | |
| 46 | + fsparam_string ("nls", opt_nls), | |
| 47 | + fsparam_u32 ("uid", opt_uid), | |
| 48 | + fsparam_u32 ("gid", opt_gid), | |
| 49 | + fsparam_u32 ("ttl", opt_ttl), | |
| 50 | + fsparam_u32oct ("dmode", opt_dmode), | |
| 51 | + fsparam_u32oct ("fmode", opt_fmode), | |
| 52 | + fsparam_u32oct ("dmask", opt_dmask), | |
| 53 | + fsparam_u32oct ("fmask", opt_fmask), | |
| 54 | + {} | |
| 55 | +}; | |
| 56 | + | |
| 57 | +static const struct fs_parameter_description vboxsf_fs_parameters = { | |
| 58 | + .name = "vboxsf", | |
| 59 | + .specs = vboxsf_param_specs, | |
| 60 | +}; | |
| 61 | + | |
| 62 | +static int vboxsf_parse_param(struct fs_context *fc, struct fs_parameter *param) | |
| 63 | +{ | |
| 64 | + struct vboxsf_fs_context *ctx = fc->fs_private; | |
| 65 | + struct fs_parse_result result; | |
| 66 | + kuid_t uid; | |
| 67 | + kgid_t gid; | |
| 68 | + int opt; | |
| 69 | + | |
| 70 | + opt = fs_parse(fc, &vboxsf_fs_parameters, param, &result); | |
| 71 | + if (opt < 0) | |
| 72 | + return opt; | |
| 73 | + | |
| 74 | + switch (opt) { | |
| 75 | + case opt_nls: | |
| 76 | + if (fc->purpose != FS_CONTEXT_FOR_MOUNT) { | |
| 77 | + vbg_err("vboxsf: Cannot reconfigure nls option\n"); | |
| 78 | + return -EINVAL; | |
| 79 | + } | |
| 80 | + ctx->nls_name = param->string; | |
| 81 | + param->string = NULL; | |
| 82 | + break; | |
| 83 | + case opt_uid: | |
| 84 | + uid = make_kuid(current_user_ns(), result.uint_32); | |
| 85 | + if (!uid_valid(uid)) | |
| 86 | + return -EINVAL; | |
| 87 | + ctx->o.uid = uid; | |
| 88 | + break; | |
| 89 | + case opt_gid: | |
| 90 | + gid = make_kgid(current_user_ns(), result.uint_32); | |
| 91 | + if (!gid_valid(gid)) | |
| 92 | + return -EINVAL; | |
| 93 | + ctx->o.gid = gid; | |
| 94 | + break; | |
| 95 | + case opt_ttl: | |
| 96 | + ctx->o.ttl = msecs_to_jiffies(result.uint_32); | |
| 97 | + break; | |
| 98 | + case opt_dmode: | |
| 99 | + if (result.uint_32 & ~0777) | |
| 100 | + return -EINVAL; | |
| 101 | + ctx->o.dmode = result.uint_32; | |
| 102 | + ctx->o.dmode_set = true; | |
| 103 | + break; | |
| 104 | + case opt_fmode: | |
| 105 | + if (result.uint_32 & ~0777) | |
| 106 | + return -EINVAL; | |
| 107 | + ctx->o.fmode = result.uint_32; | |
| 108 | + ctx->o.fmode_set = true; | |
| 109 | + break; | |
| 110 | + case opt_dmask: | |
| 111 | + if (result.uint_32 & ~07777) | |
| 112 | + return -EINVAL; | |
| 113 | + ctx->o.dmask = result.uint_32; | |
| 114 | + break; | |
| 115 | + case opt_fmask: | |
| 116 | + if (result.uint_32 & ~07777) | |
| 117 | + return -EINVAL; | |
| 118 | + ctx->o.fmask = result.uint_32; | |
| 119 | + break; | |
| 120 | + default: | |
| 121 | + return -EINVAL; | |
| 122 | + } | |
| 123 | + | |
| 124 | + return 0; | |
| 125 | +} | |
| 126 | + | |
| 127 | +static int vboxsf_fill_super(struct super_block *sb, struct fs_context *fc) | |
| 128 | +{ | |
| 129 | + struct vboxsf_fs_context *ctx = fc->fs_private; | |
| 130 | + struct shfl_string *folder_name, root_path; | |
| 131 | + struct vboxsf_sbi *sbi; | |
| 132 | + struct dentry *droot; | |
| 133 | + struct inode *iroot; | |
| 134 | + char *nls_name; | |
| 135 | + size_t size; | |
| 136 | + int err; | |
| 137 | + | |
| 138 | + if (!fc->source) | |
| 139 | + return -EINVAL; | |
| 140 | + | |
| 141 | + sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | |
| 142 | + if (!sbi) | |
| 143 | + return -ENOMEM; | |
| 144 | + | |
| 145 | + sbi->o = ctx->o; | |
| 146 | + idr_init(&sbi->ino_idr); | |
| 147 | + spin_lock_init(&sbi->ino_idr_lock); | |
| 148 | + sbi->next_generation = 1; | |
| 149 | + sbi->bdi_id = -1; | |
| 150 | + | |
| 151 | + /* Load nls if not utf8 */ | |
| 152 | + nls_name = ctx->nls_name ? ctx->nls_name : vboxsf_default_nls; | |
| 153 | + if (strcmp(nls_name, "utf8") != 0) { | |
| 154 | + if (nls_name == vboxsf_default_nls) | |
| 155 | + sbi->nls = load_nls_default(); | |
| 156 | + else | |
| 157 | + sbi->nls = load_nls(nls_name); | |
| 158 | + | |
| 159 | + if (!sbi->nls) { | |
| 160 | + vbg_err("vboxsf: Count not load '%s' nls\n", nls_name); | |
| 161 | + err = -EINVAL; | |
| 162 | + goto fail_free; | |
| 163 | + } | |
| 164 | + } | |
| 165 | + | |
| 166 | + sbi->bdi_id = ida_simple_get(&vboxsf_bdi_ida, 0, 0, GFP_KERNEL); | |
| 167 | + if (sbi->bdi_id < 0) { | |
| 168 | + err = sbi->bdi_id; | |
| 169 | + goto fail_free; | |
| 170 | + } | |
| 171 | + | |
| 172 | + err = super_setup_bdi_name(sb, "vboxsf-%s.%d", fc->source, sbi->bdi_id); | |
| 173 | + if (err) | |
| 174 | + goto fail_free; | |
| 175 | + | |
| 176 | + /* Turn source into a shfl_string and map the folder */ | |
| 177 | + size = strlen(fc->source) + 1; | |
| 178 | + folder_name = kmalloc(SHFLSTRING_HEADER_SIZE + size, GFP_KERNEL); | |
| 179 | + if (!folder_name) { | |
| 180 | + err = -ENOMEM; | |
| 181 | + goto fail_free; | |
| 182 | + } | |
| 183 | + folder_name->size = size; | |
| 184 | + folder_name->length = size - 1; | |
| 185 | + strlcpy(folder_name->string.utf8, fc->source, size); | |
| 186 | + err = vboxsf_map_folder(folder_name, &sbi->root); | |
| 187 | + kfree(folder_name); | |
| 188 | + if (err) { | |
| 189 | + vbg_err("vboxsf: Host rejected mount of '%s' with error %d\n", | |
| 190 | + fc->source, err); | |
| 191 | + goto fail_free; | |
| 192 | + } | |
| 193 | + | |
| 194 | + root_path.length = 1; | |
| 195 | + root_path.size = 2; | |
| 196 | + root_path.string.utf8[0] = '/'; | |
| 197 | + root_path.string.utf8[1] = 0; | |
| 198 | + err = vboxsf_stat(sbi, &root_path, &sbi->root_info); | |
| 199 | + if (err) | |
| 200 | + goto fail_unmap; | |
| 201 | + | |
| 202 | + sb->s_magic = VBOXSF_SUPER_MAGIC; | |
| 203 | + sb->s_blocksize = 1024; | |
| 204 | + sb->s_maxbytes = MAX_LFS_FILESIZE; | |
| 205 | + sb->s_op = &vboxsf_super_ops; | |
| 206 | + sb->s_d_op = &vboxsf_dentry_ops; | |
| 207 | + | |
| 208 | + iroot = iget_locked(sb, 0); | |
| 209 | + if (!iroot) { | |
| 210 | + err = -ENOMEM; | |
| 211 | + goto fail_unmap; | |
| 212 | + } | |
| 213 | + vboxsf_init_inode(sbi, iroot, &sbi->root_info); | |
| 214 | + unlock_new_inode(iroot); | |
| 215 | + | |
| 216 | + droot = d_make_root(iroot); | |
| 217 | + if (!droot) { | |
| 218 | + err = -ENOMEM; | |
| 219 | + goto fail_unmap; | |
| 220 | + } | |
| 221 | + | |
| 222 | + sb->s_root = droot; | |
| 223 | + sb->s_fs_info = sbi; | |
| 224 | + return 0; | |
| 225 | + | |
| 226 | +fail_unmap: | |
| 227 | + vboxsf_unmap_folder(sbi->root); | |
| 228 | +fail_free: | |
| 229 | + if (sbi->bdi_id >= 0) | |
| 230 | + ida_simple_remove(&vboxsf_bdi_ida, sbi->bdi_id); | |
| 231 | + if (sbi->nls) | |
| 232 | + unload_nls(sbi->nls); | |
| 233 | + idr_destroy(&sbi->ino_idr); | |
| 234 | + kfree(sbi); | |
| 235 | + return err; | |
| 236 | +} | |
| 237 | + | |
| 238 | +static void vboxsf_inode_init_once(void *data) | |
| 239 | +{ | |
| 240 | + struct vboxsf_inode *sf_i = data; | |
| 241 | + | |
| 242 | + mutex_init(&sf_i->handle_list_mutex); | |
| 243 | + inode_init_once(&sf_i->vfs_inode); | |
| 244 | +} | |
| 245 | + | |
| 246 | +static struct inode *vboxsf_alloc_inode(struct super_block *sb) | |
| 247 | +{ | |
| 248 | + struct vboxsf_inode *sf_i; | |
| 249 | + | |
| 250 | + sf_i = kmem_cache_alloc(vboxsf_inode_cachep, GFP_NOFS); | |
| 251 | + if (!sf_i) | |
| 252 | + return NULL; | |
| 253 | + | |
| 254 | + sf_i->force_restat = 0; | |
| 255 | + INIT_LIST_HEAD(&sf_i->handle_list); | |
| 256 | + | |
| 257 | + return &sf_i->vfs_inode; | |
| 258 | +} | |
| 259 | + | |
| 260 | +static void vboxsf_free_inode(struct inode *inode) | |
| 261 | +{ | |
| 262 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(inode->i_sb); | |
| 263 | + unsigned long flags; | |
| 264 | + | |
| 265 | + spin_lock_irqsave(&sbi->ino_idr_lock, flags); | |
| 266 | + idr_remove(&sbi->ino_idr, inode->i_ino); | |
| 267 | + spin_unlock_irqrestore(&sbi->ino_idr_lock, flags); | |
| 268 | + kmem_cache_free(vboxsf_inode_cachep, VBOXSF_I(inode)); | |
| 269 | +} | |
| 270 | + | |
| 271 | +static void vboxsf_put_super(struct super_block *sb) | |
| 272 | +{ | |
| 273 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(sb); | |
| 274 | + | |
| 275 | + vboxsf_unmap_folder(sbi->root); | |
| 276 | + if (sbi->bdi_id >= 0) | |
| 277 | + ida_simple_remove(&vboxsf_bdi_ida, sbi->bdi_id); | |
| 278 | + if (sbi->nls) | |
| 279 | + unload_nls(sbi->nls); | |
| 280 | + | |
| 281 | + /* | |
| 282 | + * vboxsf_free_inode uses the idr, make sure all delayed rcu free | |
| 283 | + * inodes are flushed. | |
| 284 | + */ | |
| 285 | + rcu_barrier(); | |
| 286 | + idr_destroy(&sbi->ino_idr); | |
| 287 | + kfree(sbi); | |
| 288 | +} | |
| 289 | + | |
| 290 | +static int vboxsf_statfs(struct dentry *dentry, struct kstatfs *stat) | |
| 291 | +{ | |
| 292 | + struct super_block *sb = dentry->d_sb; | |
| 293 | + struct shfl_volinfo shfl_volinfo; | |
| 294 | + struct vboxsf_sbi *sbi; | |
| 295 | + u32 buf_len; | |
| 296 | + int err; | |
| 297 | + | |
| 298 | + sbi = VBOXSF_SBI(sb); | |
| 299 | + buf_len = sizeof(shfl_volinfo); | |
| 300 | + err = vboxsf_fsinfo(sbi->root, 0, SHFL_INFO_GET | SHFL_INFO_VOLUME, | |
| 301 | + &buf_len, &shfl_volinfo); | |
| 302 | + if (err) | |
| 303 | + return err; | |
| 304 | + | |
| 305 | + stat->f_type = VBOXSF_SUPER_MAGIC; | |
| 306 | + stat->f_bsize = shfl_volinfo.bytes_per_allocation_unit; | |
| 307 | + | |
| 308 | + do_div(shfl_volinfo.total_allocation_bytes, | |
| 309 | + shfl_volinfo.bytes_per_allocation_unit); | |
| 310 | + stat->f_blocks = shfl_volinfo.total_allocation_bytes; | |
| 311 | + | |
| 312 | + do_div(shfl_volinfo.available_allocation_bytes, | |
| 313 | + shfl_volinfo.bytes_per_allocation_unit); | |
| 314 | + stat->f_bfree = shfl_volinfo.available_allocation_bytes; | |
| 315 | + stat->f_bavail = shfl_volinfo.available_allocation_bytes; | |
| 316 | + | |
| 317 | + stat->f_files = 1000; | |
| 318 | + /* | |
| 319 | + * Don't return 0 here since the guest may then think that it is not | |
| 320 | + * possible to create any more files. | |
| 321 | + */ | |
| 322 | + stat->f_ffree = 1000000; | |
| 323 | + stat->f_fsid.val[0] = 0; | |
| 324 | + stat->f_fsid.val[1] = 0; | |
| 325 | + stat->f_namelen = 255; | |
| 326 | + return 0; | |
| 327 | +} | |
| 328 | + | |
| 329 | +static struct super_operations vboxsf_super_ops = { | |
| 330 | + .alloc_inode = vboxsf_alloc_inode, | |
| 331 | + .free_inode = vboxsf_free_inode, | |
| 332 | + .put_super = vboxsf_put_super, | |
| 333 | + .statfs = vboxsf_statfs, | |
| 334 | +}; | |
| 335 | + | |
| 336 | +static int vboxsf_setup(void) | |
| 337 | +{ | |
| 338 | + int err; | |
| 339 | + | |
| 340 | + mutex_lock(&vboxsf_setup_mutex); | |
| 341 | + | |
| 342 | + if (vboxsf_setup_done) | |
| 343 | + goto success; | |
| 344 | + | |
| 345 | + vboxsf_inode_cachep = | |
| 346 | + kmem_cache_create("vboxsf_inode_cache", | |
| 347 | + sizeof(struct vboxsf_inode), 0, | |
| 348 | + (SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD | | |
| 349 | + SLAB_ACCOUNT), | |
| 350 | + vboxsf_inode_init_once); | |
| 351 | + if (!vboxsf_inode_cachep) { | |
| 352 | + err = -ENOMEM; | |
| 353 | + goto fail_nomem; | |
| 354 | + } | |
| 355 | + | |
| 356 | + err = vboxsf_connect(); | |
| 357 | + if (err) { | |
| 358 | + vbg_err("vboxsf: err %d connecting to guest PCI-device\n", err); | |
| 359 | + vbg_err("vboxsf: make sure you are inside a VirtualBox VM\n"); | |
| 360 | + vbg_err("vboxsf: and check dmesg for vboxguest errors\n"); | |
| 361 | + goto fail_free_cache; | |
| 362 | + } | |
| 363 | + | |
| 364 | + err = vboxsf_set_utf8(); | |
| 365 | + if (err) { | |
| 366 | + vbg_err("vboxsf_setutf8 error %d\n", err); | |
| 367 | + goto fail_disconnect; | |
| 368 | + } | |
| 369 | + | |
| 370 | + if (!follow_symlinks) { | |
| 371 | + err = vboxsf_set_symlinks(); | |
| 372 | + if (err) | |
| 373 | + vbg_warn("vboxsf: Unable to show symlinks: %d\n", err); | |
| 374 | + } | |
| 375 | + | |
| 376 | + vboxsf_setup_done = true; | |
| 377 | +success: | |
| 378 | + mutex_unlock(&vboxsf_setup_mutex); | |
| 379 | + return 0; | |
| 380 | + | |
| 381 | +fail_disconnect: | |
| 382 | + vboxsf_disconnect(); | |
| 383 | +fail_free_cache: | |
| 384 | + kmem_cache_destroy(vboxsf_inode_cachep); | |
| 385 | +fail_nomem: | |
| 386 | + mutex_unlock(&vboxsf_setup_mutex); | |
| 387 | + return err; | |
| 388 | +} | |
| 389 | + | |
| 390 | +static int vboxsf_parse_monolithic(struct fs_context *fc, void *data) | |
| 391 | +{ | |
| 392 | + char *options = data; | |
| 393 | + | |
| 394 | + if (options && options[0] == VBSF_MOUNT_SIGNATURE_BYTE_0 && | |
| 395 | + options[1] == VBSF_MOUNT_SIGNATURE_BYTE_1 && | |
| 396 | + options[2] == VBSF_MOUNT_SIGNATURE_BYTE_2 && | |
| 397 | + options[3] == VBSF_MOUNT_SIGNATURE_BYTE_3) { | |
| 398 | + vbg_err("vboxsf: Old binary mount data not supported, remove obsolete mount.vboxsf and/or update your VBoxService.\n"); | |
| 399 | + return -EINVAL; | |
| 400 | + } | |
| 401 | + | |
| 402 | + return generic_parse_monolithic(fc, data); | |
| 403 | +} | |
| 404 | + | |
| 405 | +static int vboxsf_get_tree(struct fs_context *fc) | |
| 406 | +{ | |
| 407 | + int err; | |
| 408 | + | |
| 409 | + err = vboxsf_setup(); | |
| 410 | + if (err) | |
| 411 | + return err; | |
| 412 | + | |
| 413 | + return vfs_get_super(fc, vfs_get_independent_super, vboxsf_fill_super); | |
| 414 | +} | |
| 415 | + | |
| 416 | +static int vboxsf_reconfigure(struct fs_context *fc) | |
| 417 | +{ | |
| 418 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(fc->root->d_sb); | |
| 419 | + struct vboxsf_fs_context *ctx = fc->fs_private; | |
| 420 | + struct inode *iroot; | |
| 421 | + | |
| 422 | + iroot = ilookup(fc->root->d_sb, 0); | |
| 423 | + if (!iroot) | |
| 424 | + return -ENOENT; | |
| 425 | + | |
| 426 | + /* Apply changed options to the root inode */ | |
| 427 | + sbi->o = ctx->o; | |
| 428 | + vboxsf_init_inode(sbi, iroot, &sbi->root_info); | |
| 429 | + | |
| 430 | + return 0; | |
| 431 | +} | |
| 432 | + | |
| 433 | +static void vboxsf_free_fc(struct fs_context *fc) | |
| 434 | +{ | |
| 435 | + struct vboxsf_fs_context *ctx = fc->fs_private; | |
| 436 | + | |
| 437 | + kfree(ctx->nls_name); | |
| 438 | + kfree(ctx); | |
| 439 | +} | |
| 440 | + | |
| 441 | +static const struct fs_context_operations vboxsf_context_ops = { | |
| 442 | + .free = vboxsf_free_fc, | |
| 443 | + .parse_param = vboxsf_parse_param, | |
| 444 | + .parse_monolithic = vboxsf_parse_monolithic, | |
| 445 | + .get_tree = vboxsf_get_tree, | |
| 446 | + .reconfigure = vboxsf_reconfigure, | |
| 447 | +}; | |
| 448 | + | |
| 449 | +static int vboxsf_init_fs_context(struct fs_context *fc) | |
| 450 | +{ | |
| 451 | + struct vboxsf_fs_context *ctx; | |
| 452 | + | |
| 453 | + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); | |
| 454 | + if (!ctx) | |
| 455 | + return -ENOMEM; | |
| 456 | + | |
| 457 | + current_uid_gid(&ctx->o.uid, &ctx->o.gid); | |
| 458 | + | |
| 459 | + fc->fs_private = ctx; | |
| 460 | + fc->ops = &vboxsf_context_ops; | |
| 461 | + return 0; | |
| 462 | +} | |
| 463 | + | |
| 464 | +static struct file_system_type vboxsf_fs_type = { | |
| 465 | + .owner = THIS_MODULE, | |
| 466 | + .name = "vboxsf", | |
| 467 | + .init_fs_context = vboxsf_init_fs_context, | |
| 468 | + .parameters = &vboxsf_fs_parameters, | |
| 469 | + .kill_sb = kill_anon_super | |
| 470 | +}; | |
| 471 | + | |
| 472 | +/* Module initialization/finalization handlers */ | |
| 473 | +static int __init vboxsf_init(void) | |
| 474 | +{ | |
| 475 | + return register_filesystem(&vboxsf_fs_type); | |
| 476 | +} | |
| 477 | + | |
| 478 | +static void __exit vboxsf_fini(void) | |
| 479 | +{ | |
| 480 | + unregister_filesystem(&vboxsf_fs_type); | |
| 481 | + | |
| 482 | + mutex_lock(&vboxsf_setup_mutex); | |
| 483 | + if (vboxsf_setup_done) { | |
| 484 | + vboxsf_disconnect(); | |
| 485 | + /* | |
| 486 | + * Make sure all delayed rcu free inodes are flushed | |
| 487 | + * before we destroy the cache. | |
| 488 | + */ | |
| 489 | + rcu_barrier(); | |
| 490 | + kmem_cache_destroy(vboxsf_inode_cachep); | |
| 491 | + } | |
| 492 | + mutex_unlock(&vboxsf_setup_mutex); | |
| 493 | +} | |
| 494 | + | |
| 495 | +module_init(vboxsf_init); | |
| 496 | +module_exit(vboxsf_fini); | |
| 497 | + | |
| 498 | +MODULE_DESCRIPTION("Oracle VM VirtualBox Module for Host File System Access"); | |
| 499 | +MODULE_AUTHOR("Oracle Corporation"); | |
| 500 | +MODULE_LICENSE("GPL v2"); | |
| 501 | +MODULE_ALIAS_FS("vboxsf"); | |
| @@ -0,0 +1,551 @@ | ||
| 1 | +// SPDX-License-Identifier: MIT | |
| 2 | +/* | |
| 3 | + * VirtualBox Guest Shared Folders support: Utility functions. | |
| 4 | + * Mainly conversion from/to VirtualBox/Linux data structures. | |
| 5 | + * | |
| 6 | + * Copyright (C) 2006-2018 Oracle Corporation | |
| 7 | + */ | |
| 8 | + | |
| 9 | +#include <linux/namei.h> | |
| 10 | +#include <linux/nls.h> | |
| 11 | +#include <linux/sizes.h> | |
| 12 | +#include <linux/vfs.h> | |
| 13 | +#include "vfsmod.h" | |
| 14 | + | |
| 15 | +struct inode *vboxsf_new_inode(struct super_block *sb) | |
| 16 | +{ | |
| 17 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(sb); | |
| 18 | + struct inode *inode; | |
| 19 | + unsigned long flags; | |
| 20 | + int cursor, ret; | |
| 21 | + u32 gen; | |
| 22 | + | |
| 23 | + inode = new_inode(sb); | |
| 24 | + if (!inode) | |
| 25 | + return ERR_PTR(-ENOMEM); | |
| 26 | + | |
| 27 | + idr_preload(GFP_KERNEL); | |
| 28 | + spin_lock_irqsave(&sbi->ino_idr_lock, flags); | |
| 29 | + cursor = idr_get_cursor(&sbi->ino_idr); | |
| 30 | + ret = idr_alloc_cyclic(&sbi->ino_idr, inode, 1, 0, GFP_ATOMIC); | |
| 31 | + if (ret >= 0 && ret < cursor) | |
| 32 | + sbi->next_generation++; | |
| 33 | + gen = sbi->next_generation; | |
| 34 | + spin_unlock_irqrestore(&sbi->ino_idr_lock, flags); | |
| 35 | + idr_preload_end(); | |
| 36 | + | |
| 37 | + if (ret < 0) { | |
| 38 | + iput(inode); | |
| 39 | + return ERR_PTR(ret); | |
| 40 | + } | |
| 41 | + | |
| 42 | + inode->i_ino = ret; | |
| 43 | + inode->i_generation = gen; | |
| 44 | + return inode; | |
| 45 | +} | |
| 46 | + | |
| 47 | +/* set [inode] attributes based on [info], uid/gid based on [sbi] */ | |
| 48 | +void vboxsf_init_inode(struct vboxsf_sbi *sbi, struct inode *inode, | |
| 49 | + const struct shfl_fsobjinfo *info) | |
| 50 | +{ | |
| 51 | + const struct shfl_fsobjattr *attr; | |
| 52 | + s64 allocated; | |
| 53 | + int mode; | |
| 54 | + | |
| 55 | + attr = &info->attr; | |
| 56 | + | |
| 57 | +#define mode_set(r) ((attr->mode & (SHFL_UNIX_##r)) ? (S_##r) : 0) | |
| 58 | + | |
| 59 | + mode = mode_set(IRUSR); | |
| 60 | + mode |= mode_set(IWUSR); | |
| 61 | + mode |= mode_set(IXUSR); | |
| 62 | + | |
| 63 | + mode |= mode_set(IRGRP); | |
| 64 | + mode |= mode_set(IWGRP); | |
| 65 | + mode |= mode_set(IXGRP); | |
| 66 | + | |
| 67 | + mode |= mode_set(IROTH); | |
| 68 | + mode |= mode_set(IWOTH); | |
| 69 | + mode |= mode_set(IXOTH); | |
| 70 | + | |
| 71 | +#undef mode_set | |
| 72 | + | |
| 73 | + /* We use the host-side values for these */ | |
| 74 | + inode->i_flags |= S_NOATIME | S_NOCMTIME; | |
| 75 | + inode->i_mapping->a_ops = &vboxsf_reg_aops; | |
| 76 | + | |
| 77 | + if (SHFL_IS_DIRECTORY(attr->mode)) { | |
| 78 | + inode->i_mode = sbi->o.dmode_set ? sbi->o.dmode : mode; | |
| 79 | + inode->i_mode &= ~sbi->o.dmask; | |
| 80 | + inode->i_mode |= S_IFDIR; | |
| 81 | + inode->i_op = &vboxsf_dir_iops; | |
| 82 | + inode->i_fop = &vboxsf_dir_fops; | |
| 83 | + /* | |
| 84 | + * XXX: this probably should be set to the number of entries | |
| 85 | + * in the directory plus two (. ..) | |
| 86 | + */ | |
| 87 | + set_nlink(inode, 1); | |
| 88 | + } else if (SHFL_IS_SYMLINK(attr->mode)) { | |
| 89 | + inode->i_mode = sbi->o.fmode_set ? sbi->o.fmode : mode; | |
| 90 | + inode->i_mode &= ~sbi->o.fmask; | |
| 91 | + inode->i_mode |= S_IFLNK; | |
| 92 | + inode->i_op = &vboxsf_lnk_iops; | |
| 93 | + set_nlink(inode, 1); | |
| 94 | + } else { | |
| 95 | + inode->i_mode = sbi->o.fmode_set ? sbi->o.fmode : mode; | |
| 96 | + inode->i_mode &= ~sbi->o.fmask; | |
| 97 | + inode->i_mode |= S_IFREG; | |
| 98 | + inode->i_op = &vboxsf_reg_iops; | |
| 99 | + inode->i_fop = &vboxsf_reg_fops; | |
| 100 | + set_nlink(inode, 1); | |
| 101 | + } | |
| 102 | + | |
| 103 | + inode->i_uid = sbi->o.uid; | |
| 104 | + inode->i_gid = sbi->o.gid; | |
| 105 | + | |
| 106 | + inode->i_size = info->size; | |
| 107 | + inode->i_blkbits = 12; | |
| 108 | + /* i_blocks always in units of 512 bytes! */ | |
| 109 | + allocated = info->allocated + 511; | |
| 110 | + do_div(allocated, 512); | |
| 111 | + inode->i_blocks = allocated; | |
| 112 | + | |
| 113 | + inode->i_atime = ns_to_timespec64( | |
| 114 | + info->access_time.ns_relative_to_unix_epoch); | |
| 115 | + inode->i_ctime = ns_to_timespec64( | |
| 116 | + info->change_time.ns_relative_to_unix_epoch); | |
| 117 | + inode->i_mtime = ns_to_timespec64( | |
| 118 | + info->modification_time.ns_relative_to_unix_epoch); | |
| 119 | +} | |
| 120 | + | |
| 121 | +int vboxsf_create_at_dentry(struct dentry *dentry, | |
| 122 | + struct shfl_createparms *params) | |
| 123 | +{ | |
| 124 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(dentry->d_sb); | |
| 125 | + struct shfl_string *path; | |
| 126 | + int err; | |
| 127 | + | |
| 128 | + path = vboxsf_path_from_dentry(sbi, dentry); | |
| 129 | + if (IS_ERR(path)) | |
| 130 | + return PTR_ERR(path); | |
| 131 | + | |
| 132 | + err = vboxsf_create(sbi->root, path, params); | |
| 133 | + __putname(path); | |
| 134 | + | |
| 135 | + return err; | |
| 136 | +} | |
| 137 | + | |
| 138 | +int vboxsf_stat(struct vboxsf_sbi *sbi, struct shfl_string *path, | |
| 139 | + struct shfl_fsobjinfo *info) | |
| 140 | +{ | |
| 141 | + struct shfl_createparms params = {}; | |
| 142 | + int err; | |
| 143 | + | |
| 144 | + params.handle = SHFL_HANDLE_NIL; | |
| 145 | + params.create_flags = SHFL_CF_LOOKUP | SHFL_CF_ACT_FAIL_IF_NEW; | |
| 146 | + | |
| 147 | + err = vboxsf_create(sbi->root, path, ¶ms); | |
| 148 | + if (err) | |
| 149 | + return err; | |
| 150 | + | |
| 151 | + if (params.result != SHFL_FILE_EXISTS) | |
| 152 | + return -ENOENT; | |
| 153 | + | |
| 154 | + if (info) | |
| 155 | + *info = params.info; | |
| 156 | + | |
| 157 | + return 0; | |
| 158 | +} | |
| 159 | + | |
| 160 | +int vboxsf_stat_dentry(struct dentry *dentry, struct shfl_fsobjinfo *info) | |
| 161 | +{ | |
| 162 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(dentry->d_sb); | |
| 163 | + struct shfl_string *path; | |
| 164 | + int err; | |
| 165 | + | |
| 166 | + path = vboxsf_path_from_dentry(sbi, dentry); | |
| 167 | + if (IS_ERR(path)) | |
| 168 | + return PTR_ERR(path); | |
| 169 | + | |
| 170 | + err = vboxsf_stat(sbi, path, info); | |
| 171 | + __putname(path); | |
| 172 | + return err; | |
| 173 | +} | |
| 174 | + | |
| 175 | +int vboxsf_inode_revalidate(struct dentry *dentry) | |
| 176 | +{ | |
| 177 | + struct vboxsf_sbi *sbi; | |
| 178 | + struct vboxsf_inode *sf_i; | |
| 179 | + struct shfl_fsobjinfo info; | |
| 180 | + struct timespec64 prev_mtime; | |
| 181 | + struct inode *inode; | |
| 182 | + int err; | |
| 183 | + | |
| 184 | + if (!dentry || !d_really_is_positive(dentry)) | |
| 185 | + return -EINVAL; | |
| 186 | + | |
| 187 | + inode = d_inode(dentry); | |
| 188 | + prev_mtime = inode->i_mtime; | |
| 189 | + sf_i = VBOXSF_I(inode); | |
| 190 | + sbi = VBOXSF_SBI(dentry->d_sb); | |
| 191 | + if (!sf_i->force_restat) { | |
| 192 | + if (time_before(jiffies, dentry->d_time + sbi->o.ttl)) | |
| 193 | + return 0; | |
| 194 | + } | |
| 195 | + | |
| 196 | + err = vboxsf_stat_dentry(dentry, &info); | |
| 197 | + if (err) | |
| 198 | + return err; | |
| 199 | + | |
| 200 | + dentry->d_time = jiffies; | |
| 201 | + sf_i->force_restat = 0; | |
| 202 | + vboxsf_init_inode(sbi, inode, &info); | |
| 203 | + | |
| 204 | + /* | |
| 205 | + * If the file was changed on the host side we need to invalidate the | |
| 206 | + * page-cache for it. Note this also gets triggered by our own writes, | |
| 207 | + * this is unavoidable. | |
| 208 | + */ | |
| 209 | + if (timespec64_compare(&inode->i_mtime, &prev_mtime) > 0) | |
| 210 | + invalidate_inode_pages2(inode->i_mapping); | |
| 211 | + | |
| 212 | + return 0; | |
| 213 | +} | |
| 214 | + | |
| 215 | +int vboxsf_getattr(const struct path *path, struct kstat *kstat, | |
| 216 | + u32 request_mask, unsigned int flags) | |
| 217 | +{ | |
| 218 | + int err; | |
| 219 | + struct dentry *dentry = path->dentry; | |
| 220 | + struct inode *inode = d_inode(dentry); | |
| 221 | + struct vboxsf_inode *sf_i = VBOXSF_I(inode); | |
| 222 | + | |
| 223 | + switch (flags & AT_STATX_SYNC_TYPE) { | |
| 224 | + case AT_STATX_DONT_SYNC: | |
| 225 | + err = 0; | |
| 226 | + break; | |
| 227 | + case AT_STATX_FORCE_SYNC: | |
| 228 | + sf_i->force_restat = 1; | |
| 229 | + /* fall-through */ | |
| 230 | + default: | |
| 231 | + err = vboxsf_inode_revalidate(dentry); | |
| 232 | + } | |
| 233 | + if (err) | |
| 234 | + return err; | |
| 235 | + | |
| 236 | + generic_fillattr(d_inode(dentry), kstat); | |
| 237 | + return 0; | |
| 238 | +} | |
| 239 | + | |
| 240 | +int vboxsf_setattr(struct dentry *dentry, struct iattr *iattr) | |
| 241 | +{ | |
| 242 | + struct vboxsf_inode *sf_i = VBOXSF_I(d_inode(dentry)); | |
| 243 | + struct vboxsf_sbi *sbi = VBOXSF_SBI(dentry->d_sb); | |
| 244 | + struct shfl_createparms params = {}; | |
| 245 | + struct shfl_fsobjinfo info = {}; | |
| 246 | + u32 buf_len; | |
| 247 | + int err; | |
| 248 | + | |
| 249 | + params.handle = SHFL_HANDLE_NIL; | |
| 250 | + params.create_flags = SHFL_CF_ACT_OPEN_IF_EXISTS | | |
| 251 | + SHFL_CF_ACT_FAIL_IF_NEW | | |
| 252 | + SHFL_CF_ACCESS_ATTR_WRITE; | |
| 253 | + | |
| 254 | + /* this is at least required for Posix hosts */ | |
| 255 | + if (iattr->ia_valid & ATTR_SIZE) | |
| 256 | + params.create_flags |= SHFL_CF_ACCESS_WRITE; | |
| 257 | + | |
| 258 | + err = vboxsf_create_at_dentry(dentry, ¶ms); | |
| 259 | + if (err || params.result != SHFL_FILE_EXISTS) | |
| 260 | + return err ? err : -ENOENT; | |
| 261 | + | |
| 262 | +#define mode_set(r) ((iattr->ia_mode & (S_##r)) ? SHFL_UNIX_##r : 0) | |
| 263 | + | |
| 264 | + /* | |
| 265 | + * Setting the file size and setting the other attributes has to | |
| 266 | + * be handled separately. | |
| 267 | + */ | |
| 268 | + if (iattr->ia_valid & (ATTR_MODE | ATTR_ATIME | ATTR_MTIME)) { | |
| 269 | + if (iattr->ia_valid & ATTR_MODE) { | |
| 270 | + info.attr.mode = mode_set(IRUSR); | |
| 271 | + info.attr.mode |= mode_set(IWUSR); | |
| 272 | + info.attr.mode |= mode_set(IXUSR); | |
| 273 | + info.attr.mode |= mode_set(IRGRP); | |
| 274 | + info.attr.mode |= mode_set(IWGRP); | |
| 275 | + info.attr.mode |= mode_set(IXGRP); | |
| 276 | + info.attr.mode |= mode_set(IROTH); | |
| 277 | + info.attr.mode |= mode_set(IWOTH); | |
| 278 | + info.attr.mode |= mode_set(IXOTH); | |
| 279 | + | |
| 280 | + if (iattr->ia_mode & S_IFDIR) | |
| 281 | + info.attr.mode |= SHFL_TYPE_DIRECTORY; | |
| 282 | + else | |
| 283 | + info.attr.mode |= SHFL_TYPE_FILE; | |
| 284 | + } | |
| 285 | + | |
| 286 | + if (iattr->ia_valid & ATTR_ATIME) | |
| 287 | + info.access_time.ns_relative_to_unix_epoch = | |
| 288 | + timespec64_to_ns(&iattr->ia_atime); | |
| 289 | + | |
| 290 | + if (iattr->ia_valid & ATTR_MTIME) | |
| 291 | + info.modification_time.ns_relative_to_unix_epoch = | |
| 292 | + timespec64_to_ns(&iattr->ia_mtime); | |
| 293 | + | |
| 294 | + /* | |
| 295 | + * Ignore ctime (inode change time) as it can't be set | |
| 296 | + * from userland anyway. | |
| 297 | + */ | |
| 298 | + | |
| 299 | + buf_len = sizeof(info); | |
| 300 | + err = vboxsf_fsinfo(sbi->root, params.handle, | |
| 301 | + SHFL_INFO_SET | SHFL_INFO_FILE, &buf_len, | |
| 302 | + &info); | |
| 303 | + if (err) { | |
| 304 | + vboxsf_close(sbi->root, params.handle); | |
| 305 | + return err; | |
| 306 | + } | |
| 307 | + | |
| 308 | + /* the host may have given us different attr then requested */ | |
| 309 | + sf_i->force_restat = 1; | |
| 310 | + } | |
| 311 | + | |
| 312 | +#undef mode_set | |
| 313 | + | |
| 314 | + if (iattr->ia_valid & ATTR_SIZE) { | |
| 315 | + memset(&info, 0, sizeof(info)); | |
| 316 | + info.size = iattr->ia_size; | |
| 317 | + buf_len = sizeof(info); | |
| 318 | + err = vboxsf_fsinfo(sbi->root, params.handle, | |
| 319 | + SHFL_INFO_SET | SHFL_INFO_SIZE, &buf_len, | |
| 320 | + &info); | |
| 321 | + if (err) { | |
| 322 | + vboxsf_close(sbi->root, params.handle); | |
| 323 | + return err; | |
| 324 | + } | |
| 325 | + | |
| 326 | + /* the host may have given us different attr then requested */ | |
| 327 | + sf_i->force_restat = 1; | |
| 328 | + } | |
| 329 | + | |
| 330 | + vboxsf_close(sbi->root, params.handle); | |
| 331 | + | |
| 332 | + /* Update the inode with what the host has actually given us. */ | |
| 333 | + if (sf_i->force_restat) | |
| 334 | + vboxsf_inode_revalidate(dentry); | |
| 335 | + | |
| 336 | + return 0; | |
| 337 | +} | |
| 338 | + | |
| 339 | +/* | |
| 340 | + * [dentry] contains string encoded in coding system that corresponds | |
| 341 | + * to [sbi]->nls, we must convert it to UTF8 here. | |
| 342 | + * Returns a shfl_string allocated through __getname (must be freed using | |
| 343 | + * __putname), or an ERR_PTR on error. | |
| 344 | + */ | |
| 345 | +struct shfl_string *vboxsf_path_from_dentry(struct vboxsf_sbi *sbi, | |
| 346 | + struct dentry *dentry) | |
| 347 | +{ | |
| 348 | + struct shfl_string *shfl_path; | |
| 349 | + int path_len, out_len, nb; | |
| 350 | + char *buf, *path; | |
| 351 | + wchar_t uni; | |
| 352 | + u8 *out; | |
| 353 | + | |
| 354 | + buf = __getname(); | |
| 355 | + if (!buf) | |
| 356 | + return ERR_PTR(-ENOMEM); | |
| 357 | + | |
| 358 | + path = dentry_path_raw(dentry, buf, PATH_MAX); | |
| 359 | + if (IS_ERR(path)) { | |
| 360 | + __putname(buf); | |
| 361 | + return (struct shfl_string *)path; | |
| 362 | + } | |
| 363 | + path_len = strlen(path); | |
| 364 | + | |
| 365 | + if (sbi->nls) { | |
| 366 | + shfl_path = __getname(); | |
| 367 | + if (!shfl_path) { | |
| 368 | + __putname(buf); | |
| 369 | + return ERR_PTR(-ENOMEM); | |
| 370 | + } | |
| 371 | + | |
| 372 | + out = shfl_path->string.utf8; | |
| 373 | + out_len = PATH_MAX - SHFLSTRING_HEADER_SIZE - 1; | |
| 374 | + | |
| 375 | + while (path_len) { | |
| 376 | + nb = sbi->nls->char2uni(path, path_len, &uni); | |
| 377 | + if (nb < 0) { | |
| 378 | + __putname(shfl_path); | |
| 379 | + __putname(buf); | |
| 380 | + return ERR_PTR(-EINVAL); | |
| 381 | + } | |
| 382 | + path += nb; | |
| 383 | + path_len -= nb; | |
| 384 | + | |
| 385 | + nb = utf32_to_utf8(uni, out, out_len); | |
| 386 | + if (nb < 0) { | |
| 387 | + __putname(shfl_path); | |
| 388 | + __putname(buf); | |
| 389 | + return ERR_PTR(-ENAMETOOLONG); | |
| 390 | + } | |
| 391 | + out += nb; | |
| 392 | + out_len -= nb; | |
| 393 | + } | |
| 394 | + *out = 0; | |
| 395 | + shfl_path->length = out - shfl_path->string.utf8; | |
| 396 | + shfl_path->size = shfl_path->length + 1; | |
| 397 | + __putname(buf); | |
| 398 | + } else { | |
| 399 | + if ((SHFLSTRING_HEADER_SIZE + path_len + 1) > PATH_MAX) { | |
| 400 | + __putname(buf); | |
| 401 | + return ERR_PTR(-ENAMETOOLONG); | |
| 402 | + } | |
| 403 | + /* | |
| 404 | + * dentry_path stores the name at the end of buf, but the | |
| 405 | + * shfl_string string we return must be properly aligned. | |
| 406 | + */ | |
| 407 | + shfl_path = (struct shfl_string *)buf; | |
| 408 | + memmove(shfl_path->string.utf8, path, path_len); | |
| 409 | + shfl_path->string.utf8[path_len] = 0; | |
| 410 | + shfl_path->length = path_len; | |
| 411 | + shfl_path->size = path_len + 1; | |
| 412 | + } | |
| 413 | + | |
| 414 | + return shfl_path; | |
| 415 | +} | |
| 416 | + | |
| 417 | +int vboxsf_nlscpy(struct vboxsf_sbi *sbi, char *name, size_t name_bound_len, | |
| 418 | + const unsigned char *utf8_name, size_t utf8_len) | |
| 419 | +{ | |
| 420 | + const char *in; | |
| 421 | + char *out; | |
| 422 | + size_t out_len; | |
| 423 | + size_t out_bound_len; | |
| 424 | + size_t in_bound_len; | |
| 425 | + | |
| 426 | + in = utf8_name; | |
| 427 | + in_bound_len = utf8_len; | |
| 428 | + | |
| 429 | + out = name; | |
| 430 | + out_len = 0; | |
| 431 | + /* Reserve space for terminating 0 */ | |
| 432 | + out_bound_len = name_bound_len - 1; | |
| 433 | + | |
| 434 | + while (in_bound_len) { | |
| 435 | + int nb; | |
| 436 | + unicode_t uni; | |
| 437 | + | |
| 438 | + nb = utf8_to_utf32(in, in_bound_len, &uni); | |
| 439 | + if (nb < 0) | |
| 440 | + return -EINVAL; | |
| 441 | + | |
| 442 | + in += nb; | |
| 443 | + in_bound_len -= nb; | |
| 444 | + | |
| 445 | + nb = sbi->nls->uni2char(uni, out, out_bound_len); | |
| 446 | + if (nb < 0) | |
| 447 | + return nb; | |
| 448 | + | |
| 449 | + out += nb; | |
| 450 | + out_bound_len -= nb; | |
| 451 | + out_len += nb; | |
| 452 | + } | |
| 453 | + | |
| 454 | + *out = 0; | |
| 455 | + | |
| 456 | + return 0; | |
| 457 | +} | |
| 458 | + | |
| 459 | +static struct vboxsf_dir_buf *vboxsf_dir_buf_alloc(struct list_head *list) | |
| 460 | +{ | |
| 461 | + struct vboxsf_dir_buf *b; | |
| 462 | + | |
| 463 | + b = kmalloc(sizeof(*b), GFP_KERNEL); | |
| 464 | + if (!b) | |
| 465 | + return NULL; | |
| 466 | + | |
| 467 | + b->buf = kmalloc(DIR_BUFFER_SIZE, GFP_KERNEL); | |
| 468 | + if (!b->buf) { | |
| 469 | + kfree(b); | |
| 470 | + return NULL; | |
| 471 | + } | |
| 472 | + | |
| 473 | + b->entries = 0; | |
| 474 | + b->used = 0; | |
| 475 | + b->free = DIR_BUFFER_SIZE; | |
| 476 | + list_add(&b->head, list); | |
| 477 | + | |
| 478 | + return b; | |
| 479 | +} | |
| 480 | + | |
| 481 | +static void vboxsf_dir_buf_free(struct vboxsf_dir_buf *b) | |
| 482 | +{ | |
| 483 | + list_del(&b->head); | |
| 484 | + kfree(b->buf); | |
| 485 | + kfree(b); | |
| 486 | +} | |
| 487 | + | |
| 488 | +struct vboxsf_dir_info *vboxsf_dir_info_alloc(void) | |
| 489 | +{ | |
| 490 | + struct vboxsf_dir_info *p; | |
| 491 | + | |
| 492 | + p = kmalloc(sizeof(*p), GFP_KERNEL); | |
| 493 | + if (!p) | |
| 494 | + return NULL; | |
| 495 | + | |
| 496 | + INIT_LIST_HEAD(&p->info_list); | |
| 497 | + return p; | |
| 498 | +} | |
| 499 | + | |
| 500 | +void vboxsf_dir_info_free(struct vboxsf_dir_info *p) | |
| 501 | +{ | |
| 502 | + struct list_head *list, *pos, *tmp; | |
| 503 | + | |
| 504 | + list = &p->info_list; | |
| 505 | + list_for_each_safe(pos, tmp, list) { | |
| 506 | + struct vboxsf_dir_buf *b; | |
| 507 | + | |
| 508 | + b = list_entry(pos, struct vboxsf_dir_buf, head); | |
| 509 | + vboxsf_dir_buf_free(b); | |
| 510 | + } | |
| 511 | + kfree(p); | |
| 512 | +} | |
| 513 | + | |
| 514 | +int vboxsf_dir_read_all(struct vboxsf_sbi *sbi, struct vboxsf_dir_info *sf_d, | |
| 515 | + u64 handle) | |
| 516 | +{ | |
| 517 | + struct vboxsf_dir_buf *b; | |
| 518 | + u32 entries, size; | |
| 519 | + int err = 0; | |
| 520 | + void *buf; | |
| 521 | + | |
| 522 | + /* vboxsf_dirinfo returns 1 on end of dir */ | |
| 523 | + while (err == 0) { | |
| 524 | + b = vboxsf_dir_buf_alloc(&sf_d->info_list); | |
| 525 | + if (!b) { | |
| 526 | + err = -ENOMEM; | |
| 527 | + break; | |
| 528 | + } | |
| 529 | + | |
| 530 | + buf = b->buf; | |
| 531 | + size = b->free; | |
| 532 | + | |
| 533 | + err = vboxsf_dirinfo(sbi->root, handle, NULL, 0, 0, | |
| 534 | + &size, buf, &entries); | |
| 535 | + if (err < 0) | |
| 536 | + break; | |
| 537 | + | |
| 538 | + b->entries += entries; | |
| 539 | + b->free -= size; | |
| 540 | + b->used += size; | |
| 541 | + } | |
| 542 | + | |
| 543 | + if (b && b->used == 0) | |
| 544 | + vboxsf_dir_buf_free(b); | |
| 545 | + | |
| 546 | + /* -EILSEQ means the host could not translate a filename, ignore */ | |
| 547 | + if (err > 0 || err == -EILSEQ) | |
| 548 | + err = 0; | |
| 549 | + | |
| 550 | + return err; | |
| 551 | +} | |
| @@ -0,0 +1,371 @@ | ||
| 1 | +// SPDX-License-Identifier: MIT | |
| 2 | +/* | |
| 3 | + * Wrapper functions for the shfl host calls. | |
| 4 | + * | |
| 5 | + * Copyright (C) 2006-2018 Oracle Corporation | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#include <linux/mm.h> | |
| 9 | +#include <linux/slab.h> | |
| 10 | +#include <linux/vbox_err.h> | |
| 11 | +#include <linux/vbox_utils.h> | |
| 12 | +#include "vfsmod.h" | |
| 13 | + | |
| 14 | +#define SHFL_REQUEST \ | |
| 15 | + (VMMDEV_REQUESTOR_KERNEL | VMMDEV_REQUESTOR_USR_DRV_OTHER | \ | |
| 16 | + VMMDEV_REQUESTOR_CON_DONT_KNOW | VMMDEV_REQUESTOR_TRUST_NOT_GIVEN) | |
| 17 | + | |
| 18 | +static u32 vboxsf_client_id; | |
| 19 | + | |
| 20 | +int vboxsf_connect(void) | |
| 21 | +{ | |
| 22 | + struct vbg_dev *gdev; | |
| 23 | + struct vmmdev_hgcm_service_location loc; | |
| 24 | + int err, vbox_status; | |
| 25 | + | |
| 26 | + loc.type = VMMDEV_HGCM_LOC_LOCALHOST_EXISTING; | |
| 27 | + strcpy(loc.u.localhost.service_name, "VBoxSharedFolders"); | |
| 28 | + | |
| 29 | + gdev = vbg_get_gdev(); | |
| 30 | + if (IS_ERR(gdev)) | |
| 31 | + return -ENODEV; /* No guest-device */ | |
| 32 | + | |
| 33 | + err = vbg_hgcm_connect(gdev, SHFL_REQUEST, &loc, | |
| 34 | + &vboxsf_client_id, &vbox_status); | |
| 35 | + vbg_put_gdev(gdev); | |
| 36 | + | |
| 37 | + return err ? err : vbg_status_code_to_errno(vbox_status); | |
| 38 | +} | |
| 39 | + | |
| 40 | +void vboxsf_disconnect(void) | |
| 41 | +{ | |
| 42 | + struct vbg_dev *gdev; | |
| 43 | + int vbox_status; | |
| 44 | + | |
| 45 | + gdev = vbg_get_gdev(); | |
| 46 | + if (IS_ERR(gdev)) | |
| 47 | + return; /* guest-device is gone, already disconnected */ | |
| 48 | + | |
| 49 | + vbg_hgcm_disconnect(gdev, SHFL_REQUEST, vboxsf_client_id, &vbox_status); | |
| 50 | + vbg_put_gdev(gdev); | |
| 51 | +} | |
| 52 | + | |
| 53 | +static int vboxsf_call(u32 function, void *parms, u32 parm_count, int *status) | |
| 54 | +{ | |
| 55 | + struct vbg_dev *gdev; | |
| 56 | + int err, vbox_status; | |
| 57 | + | |
| 58 | + gdev = vbg_get_gdev(); | |
| 59 | + if (IS_ERR(gdev)) | |
| 60 | + return -ESHUTDOWN; /* guest-dev removed underneath us */ | |
| 61 | + | |
| 62 | + err = vbg_hgcm_call(gdev, SHFL_REQUEST, vboxsf_client_id, function, | |
| 63 | + U32_MAX, parms, parm_count, &vbox_status); | |
| 64 | + vbg_put_gdev(gdev); | |
| 65 | + | |
| 66 | + if (err < 0) | |
| 67 | + return err; | |
| 68 | + | |
| 69 | + if (status) | |
| 70 | + *status = vbox_status; | |
| 71 | + | |
| 72 | + return vbg_status_code_to_errno(vbox_status); | |
| 73 | +} | |
| 74 | + | |
| 75 | +int vboxsf_map_folder(struct shfl_string *folder_name, u32 *root) | |
| 76 | +{ | |
| 77 | + struct shfl_map_folder parms; | |
| 78 | + int err, status; | |
| 79 | + | |
| 80 | + parms.path.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL; | |
| 81 | + parms.path.u.pointer.size = shfl_string_buf_size(folder_name); | |
| 82 | + parms.path.u.pointer.u.linear_addr = (uintptr_t)folder_name; | |
| 83 | + | |
| 84 | + parms.root.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 85 | + parms.root.u.value32 = 0; | |
| 86 | + | |
| 87 | + parms.delimiter.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 88 | + parms.delimiter.u.value32 = '/'; | |
| 89 | + | |
| 90 | + parms.case_sensitive.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 91 | + parms.case_sensitive.u.value32 = 1; | |
| 92 | + | |
| 93 | + err = vboxsf_call(SHFL_FN_MAP_FOLDER, &parms, SHFL_CPARMS_MAP_FOLDER, | |
| 94 | + &status); | |
| 95 | + if (err == -ENOSYS && status == VERR_NOT_IMPLEMENTED) | |
| 96 | + vbg_err("%s: Error host is too old\n", __func__); | |
| 97 | + | |
| 98 | + *root = parms.root.u.value32; | |
| 99 | + return err; | |
| 100 | +} | |
| 101 | + | |
| 102 | +int vboxsf_unmap_folder(u32 root) | |
| 103 | +{ | |
| 104 | + struct shfl_unmap_folder parms; | |
| 105 | + | |
| 106 | + parms.root.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 107 | + parms.root.u.value32 = root; | |
| 108 | + | |
| 109 | + return vboxsf_call(SHFL_FN_UNMAP_FOLDER, &parms, | |
| 110 | + SHFL_CPARMS_UNMAP_FOLDER, NULL); | |
| 111 | +} | |
| 112 | + | |
| 113 | +/** | |
| 114 | + * vboxsf_create - Create a new file or folder | |
| 115 | + * @root: Root of the shared folder in which to create the file | |
| 116 | + * @parsed_path: The path of the file or folder relative to the shared folder | |
| 117 | + * @param: create_parms Parameters for file/folder creation. | |
| 118 | + * | |
| 119 | + * Create a new file or folder or open an existing one in a shared folder. | |
| 120 | + * Note this function always returns 0 / success unless an exceptional condition | |
| 121 | + * occurs - out of memory, invalid arguments, etc. If the file or folder could | |
| 122 | + * not be opened or created, create_parms->handle will be set to | |
| 123 | + * SHFL_HANDLE_NIL on return. In this case the value in create_parms->result | |
| 124 | + * provides information as to why (e.g. SHFL_FILE_EXISTS), create_parms->result | |
| 125 | + * is also set on success as additional information. | |
| 126 | + * | |
| 127 | + * Returns: | |
| 128 | + * 0 or negative errno value. | |
| 129 | + */ | |
| 130 | +int vboxsf_create(u32 root, struct shfl_string *parsed_path, | |
| 131 | + struct shfl_createparms *create_parms) | |
| 132 | +{ | |
| 133 | + struct shfl_create parms; | |
| 134 | + | |
| 135 | + parms.root.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 136 | + parms.root.u.value32 = root; | |
| 137 | + | |
| 138 | + parms.path.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL; | |
| 139 | + parms.path.u.pointer.size = shfl_string_buf_size(parsed_path); | |
| 140 | + parms.path.u.pointer.u.linear_addr = (uintptr_t)parsed_path; | |
| 141 | + | |
| 142 | + parms.parms.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL; | |
| 143 | + parms.parms.u.pointer.size = sizeof(struct shfl_createparms); | |
| 144 | + parms.parms.u.pointer.u.linear_addr = (uintptr_t)create_parms; | |
| 145 | + | |
| 146 | + return vboxsf_call(SHFL_FN_CREATE, &parms, SHFL_CPARMS_CREATE, NULL); | |
| 147 | +} | |
| 148 | + | |
| 149 | +int vboxsf_close(u32 root, u64 handle) | |
| 150 | +{ | |
| 151 | + struct shfl_close parms; | |
| 152 | + | |
| 153 | + parms.root.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 154 | + parms.root.u.value32 = root; | |
| 155 | + | |
| 156 | + parms.handle.type = VMMDEV_HGCM_PARM_TYPE_64BIT; | |
| 157 | + parms.handle.u.value64 = handle; | |
| 158 | + | |
| 159 | + return vboxsf_call(SHFL_FN_CLOSE, &parms, SHFL_CPARMS_CLOSE, NULL); | |
| 160 | +} | |
| 161 | + | |
| 162 | +int vboxsf_remove(u32 root, struct shfl_string *parsed_path, u32 flags) | |
| 163 | +{ | |
| 164 | + struct shfl_remove parms; | |
| 165 | + | |
| 166 | + parms.root.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 167 | + parms.root.u.value32 = root; | |
| 168 | + | |
| 169 | + parms.path.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN; | |
| 170 | + parms.path.u.pointer.size = shfl_string_buf_size(parsed_path); | |
| 171 | + parms.path.u.pointer.u.linear_addr = (uintptr_t)parsed_path; | |
| 172 | + | |
| 173 | + parms.flags.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 174 | + parms.flags.u.value32 = flags; | |
| 175 | + | |
| 176 | + return vboxsf_call(SHFL_FN_REMOVE, &parms, SHFL_CPARMS_REMOVE, NULL); | |
| 177 | +} | |
| 178 | + | |
| 179 | +int vboxsf_rename(u32 root, struct shfl_string *src_path, | |
| 180 | + struct shfl_string *dest_path, u32 flags) | |
| 181 | +{ | |
| 182 | + struct shfl_rename parms; | |
| 183 | + | |
| 184 | + parms.root.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 185 | + parms.root.u.value32 = root; | |
| 186 | + | |
| 187 | + parms.src.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN; | |
| 188 | + parms.src.u.pointer.size = shfl_string_buf_size(src_path); | |
| 189 | + parms.src.u.pointer.u.linear_addr = (uintptr_t)src_path; | |
| 190 | + | |
| 191 | + parms.dest.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN; | |
| 192 | + parms.dest.u.pointer.size = shfl_string_buf_size(dest_path); | |
| 193 | + parms.dest.u.pointer.u.linear_addr = (uintptr_t)dest_path; | |
| 194 | + | |
| 195 | + parms.flags.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 196 | + parms.flags.u.value32 = flags; | |
| 197 | + | |
| 198 | + return vboxsf_call(SHFL_FN_RENAME, &parms, SHFL_CPARMS_RENAME, NULL); | |
| 199 | +} | |
| 200 | + | |
| 201 | +int vboxsf_read(u32 root, u64 handle, u64 offset, u32 *buf_len, u8 *buf) | |
| 202 | +{ | |
| 203 | + struct shfl_read parms; | |
| 204 | + int err; | |
| 205 | + | |
| 206 | + parms.root.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 207 | + parms.root.u.value32 = root; | |
| 208 | + | |
| 209 | + parms.handle.type = VMMDEV_HGCM_PARM_TYPE_64BIT; | |
| 210 | + parms.handle.u.value64 = handle; | |
| 211 | + parms.offset.type = VMMDEV_HGCM_PARM_TYPE_64BIT; | |
| 212 | + parms.offset.u.value64 = offset; | |
| 213 | + parms.cb.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 214 | + parms.cb.u.value32 = *buf_len; | |
| 215 | + parms.buffer.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_OUT; | |
| 216 | + parms.buffer.u.pointer.size = *buf_len; | |
| 217 | + parms.buffer.u.pointer.u.linear_addr = (uintptr_t)buf; | |
| 218 | + | |
| 219 | + err = vboxsf_call(SHFL_FN_READ, &parms, SHFL_CPARMS_READ, NULL); | |
| 220 | + | |
| 221 | + *buf_len = parms.cb.u.value32; | |
| 222 | + return err; | |
| 223 | +} | |
| 224 | + | |
| 225 | +int vboxsf_write(u32 root, u64 handle, u64 offset, u32 *buf_len, u8 *buf) | |
| 226 | +{ | |
| 227 | + struct shfl_write parms; | |
| 228 | + int err; | |
| 229 | + | |
| 230 | + parms.root.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 231 | + parms.root.u.value32 = root; | |
| 232 | + | |
| 233 | + parms.handle.type = VMMDEV_HGCM_PARM_TYPE_64BIT; | |
| 234 | + parms.handle.u.value64 = handle; | |
| 235 | + parms.offset.type = VMMDEV_HGCM_PARM_TYPE_64BIT; | |
| 236 | + parms.offset.u.value64 = offset; | |
| 237 | + parms.cb.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 238 | + parms.cb.u.value32 = *buf_len; | |
| 239 | + parms.buffer.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN; | |
| 240 | + parms.buffer.u.pointer.size = *buf_len; | |
| 241 | + parms.buffer.u.pointer.u.linear_addr = (uintptr_t)buf; | |
| 242 | + | |
| 243 | + err = vboxsf_call(SHFL_FN_WRITE, &parms, SHFL_CPARMS_WRITE, NULL); | |
| 244 | + | |
| 245 | + *buf_len = parms.cb.u.value32; | |
| 246 | + return err; | |
| 247 | +} | |
| 248 | + | |
| 249 | +/* Returns 0 on success, 1 on end-of-dir, negative errno otherwise */ | |
| 250 | +int vboxsf_dirinfo(u32 root, u64 handle, | |
| 251 | + struct shfl_string *parsed_path, u32 flags, u32 index, | |
| 252 | + u32 *buf_len, struct shfl_dirinfo *buf, u32 *file_count) | |
| 253 | +{ | |
| 254 | + struct shfl_list parms; | |
| 255 | + int err, status; | |
| 256 | + | |
| 257 | + parms.root.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 258 | + parms.root.u.value32 = root; | |
| 259 | + | |
| 260 | + parms.handle.type = VMMDEV_HGCM_PARM_TYPE_64BIT; | |
| 261 | + parms.handle.u.value64 = handle; | |
| 262 | + parms.flags.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 263 | + parms.flags.u.value32 = flags; | |
| 264 | + parms.cb.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 265 | + parms.cb.u.value32 = *buf_len; | |
| 266 | + if (parsed_path) { | |
| 267 | + parms.path.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN; | |
| 268 | + parms.path.u.pointer.size = shfl_string_buf_size(parsed_path); | |
| 269 | + parms.path.u.pointer.u.linear_addr = (uintptr_t)parsed_path; | |
| 270 | + } else { | |
| 271 | + parms.path.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_IN; | |
| 272 | + parms.path.u.pointer.size = 0; | |
| 273 | + parms.path.u.pointer.u.linear_addr = 0; | |
| 274 | + } | |
| 275 | + | |
| 276 | + parms.buffer.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_OUT; | |
| 277 | + parms.buffer.u.pointer.size = *buf_len; | |
| 278 | + parms.buffer.u.pointer.u.linear_addr = (uintptr_t)buf; | |
| 279 | + | |
| 280 | + parms.resume_point.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 281 | + parms.resume_point.u.value32 = index; | |
| 282 | + parms.file_count.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 283 | + parms.file_count.u.value32 = 0; /* out parameter only */ | |
| 284 | + | |
| 285 | + err = vboxsf_call(SHFL_FN_LIST, &parms, SHFL_CPARMS_LIST, &status); | |
| 286 | + if (err == -ENODATA && status == VERR_NO_MORE_FILES) | |
| 287 | + err = 1; | |
| 288 | + | |
| 289 | + *buf_len = parms.cb.u.value32; | |
| 290 | + *file_count = parms.file_count.u.value32; | |
| 291 | + return err; | |
| 292 | +} | |
| 293 | + | |
| 294 | +int vboxsf_fsinfo(u32 root, u64 handle, u32 flags, | |
| 295 | + u32 *buf_len, void *buf) | |
| 296 | +{ | |
| 297 | + struct shfl_information parms; | |
| 298 | + int err; | |
| 299 | + | |
| 300 | + parms.root.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 301 | + parms.root.u.value32 = root; | |
| 302 | + | |
| 303 | + parms.handle.type = VMMDEV_HGCM_PARM_TYPE_64BIT; | |
| 304 | + parms.handle.u.value64 = handle; | |
| 305 | + parms.flags.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 306 | + parms.flags.u.value32 = flags; | |
| 307 | + parms.cb.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 308 | + parms.cb.u.value32 = *buf_len; | |
| 309 | + parms.info.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL; | |
| 310 | + parms.info.u.pointer.size = *buf_len; | |
| 311 | + parms.info.u.pointer.u.linear_addr = (uintptr_t)buf; | |
| 312 | + | |
| 313 | + err = vboxsf_call(SHFL_FN_INFORMATION, &parms, SHFL_CPARMS_INFORMATION, | |
| 314 | + NULL); | |
| 315 | + | |
| 316 | + *buf_len = parms.cb.u.value32; | |
| 317 | + return err; | |
| 318 | +} | |
| 319 | + | |
| 320 | +int vboxsf_readlink(u32 root, struct shfl_string *parsed_path, | |
| 321 | + u32 buf_len, u8 *buf) | |
| 322 | +{ | |
| 323 | + struct shfl_readLink parms; | |
| 324 | + | |
| 325 | + parms.root.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 326 | + parms.root.u.value32 = root; | |
| 327 | + | |
| 328 | + parms.path.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN; | |
| 329 | + parms.path.u.pointer.size = shfl_string_buf_size(parsed_path); | |
| 330 | + parms.path.u.pointer.u.linear_addr = (uintptr_t)parsed_path; | |
| 331 | + | |
| 332 | + parms.buffer.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_OUT; | |
| 333 | + parms.buffer.u.pointer.size = buf_len; | |
| 334 | + parms.buffer.u.pointer.u.linear_addr = (uintptr_t)buf; | |
| 335 | + | |
| 336 | + return vboxsf_call(SHFL_FN_READLINK, &parms, SHFL_CPARMS_READLINK, | |
| 337 | + NULL); | |
| 338 | +} | |
| 339 | + | |
| 340 | +int vboxsf_symlink(u32 root, struct shfl_string *new_path, | |
| 341 | + struct shfl_string *old_path, struct shfl_fsobjinfo *buf) | |
| 342 | +{ | |
| 343 | + struct shfl_symlink parms; | |
| 344 | + | |
| 345 | + parms.root.type = VMMDEV_HGCM_PARM_TYPE_32BIT; | |
| 346 | + parms.root.u.value32 = root; | |
| 347 | + | |
| 348 | + parms.new_path.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN; | |
| 349 | + parms.new_path.u.pointer.size = shfl_string_buf_size(new_path); | |
| 350 | + parms.new_path.u.pointer.u.linear_addr = (uintptr_t)new_path; | |
| 351 | + | |
| 352 | + parms.old_path.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN; | |
| 353 | + parms.old_path.u.pointer.size = shfl_string_buf_size(old_path); | |
| 354 | + parms.old_path.u.pointer.u.linear_addr = (uintptr_t)old_path; | |
| 355 | + | |
| 356 | + parms.info.type = VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_OUT; | |
| 357 | + parms.info.u.pointer.size = sizeof(struct shfl_fsobjinfo); | |
| 358 | + parms.info.u.pointer.u.linear_addr = (uintptr_t)buf; | |
| 359 | + | |
| 360 | + return vboxsf_call(SHFL_FN_SYMLINK, &parms, SHFL_CPARMS_SYMLINK, NULL); | |
| 361 | +} | |
| 362 | + | |
| 363 | +int vboxsf_set_utf8(void) | |
| 364 | +{ | |
| 365 | + return vboxsf_call(SHFL_FN_SET_UTF8, NULL, 0, NULL); | |
| 366 | +} | |
| 367 | + | |
| 368 | +int vboxsf_set_symlinks(void) | |
| 369 | +{ | |
| 370 | + return vboxsf_call(SHFL_FN_SET_SYMLINKS, NULL, 0, NULL); | |
| 371 | +} | |
| @@ -0,0 +1,137 @@ | ||
| 1 | +/* SPDX-License-Identifier: MIT */ | |
| 2 | +/* | |
| 3 | + * VirtualBox Guest Shared Folders support: module header. | |
| 4 | + * | |
| 5 | + * Copyright (C) 2006-2018 Oracle Corporation | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#ifndef VFSMOD_H | |
| 9 | +#define VFSMOD_H | |
| 10 | + | |
| 11 | +#include <linux/backing-dev.h> | |
| 12 | +#include <linux/idr.h> | |
| 13 | +#include "shfl_hostintf.h" | |
| 14 | + | |
| 15 | +#define DIR_BUFFER_SIZE SZ_16K | |
| 16 | + | |
| 17 | +/* The cast is to prevent assignment of void * to pointers of arbitrary type */ | |
| 18 | +#define VBOXSF_SBI(sb) ((struct vboxsf_sbi *)(sb)->s_fs_info) | |
| 19 | +#define VBOXSF_I(i) container_of(i, struct vboxsf_inode, vfs_inode) | |
| 20 | + | |
| 21 | +struct vboxsf_options { | |
| 22 | + unsigned long ttl; | |
| 23 | + kuid_t uid; | |
| 24 | + kgid_t gid; | |
| 25 | + bool dmode_set; | |
| 26 | + bool fmode_set; | |
| 27 | + umode_t dmode; | |
| 28 | + umode_t fmode; | |
| 29 | + umode_t dmask; | |
| 30 | + umode_t fmask; | |
| 31 | +}; | |
| 32 | + | |
| 33 | +struct vboxsf_fs_context { | |
| 34 | + struct vboxsf_options o; | |
| 35 | + char *nls_name; | |
| 36 | +}; | |
| 37 | + | |
| 38 | +/* per-shared folder information */ | |
| 39 | +struct vboxsf_sbi { | |
| 40 | + struct vboxsf_options o; | |
| 41 | + struct shfl_fsobjinfo root_info; | |
| 42 | + struct idr ino_idr; | |
| 43 | + spinlock_t ino_idr_lock; /* This protects ino_idr */ | |
| 44 | + struct nls_table *nls; | |
| 45 | + u32 next_generation; | |
| 46 | + u32 root; | |
| 47 | + int bdi_id; | |
| 48 | +}; | |
| 49 | + | |
| 50 | +/* per-inode information */ | |
| 51 | +struct vboxsf_inode { | |
| 52 | + /* some information was changed, update data on next revalidate */ | |
| 53 | + int force_restat; | |
| 54 | + /* list of open handles for this inode + lock protecting it */ | |
| 55 | + struct list_head handle_list; | |
| 56 | + /* This mutex protects handle_list accesses */ | |
| 57 | + struct mutex handle_list_mutex; | |
| 58 | + /* The VFS inode struct */ | |
| 59 | + struct inode vfs_inode; | |
| 60 | +}; | |
| 61 | + | |
| 62 | +struct vboxsf_dir_info { | |
| 63 | + struct list_head info_list; | |
| 64 | +}; | |
| 65 | + | |
| 66 | +struct vboxsf_dir_buf { | |
| 67 | + size_t entries; | |
| 68 | + size_t free; | |
| 69 | + size_t used; | |
| 70 | + void *buf; | |
| 71 | + struct list_head head; | |
| 72 | +}; | |
| 73 | + | |
| 74 | +/* globals */ | |
| 75 | +extern const struct inode_operations vboxsf_dir_iops; | |
| 76 | +extern const struct inode_operations vboxsf_lnk_iops; | |
| 77 | +extern const struct inode_operations vboxsf_reg_iops; | |
| 78 | +extern const struct file_operations vboxsf_dir_fops; | |
| 79 | +extern const struct file_operations vboxsf_reg_fops; | |
| 80 | +extern const struct address_space_operations vboxsf_reg_aops; | |
| 81 | +extern const struct dentry_operations vboxsf_dentry_ops; | |
| 82 | + | |
| 83 | +/* from utils.c */ | |
| 84 | +struct inode *vboxsf_new_inode(struct super_block *sb); | |
| 85 | +void vboxsf_init_inode(struct vboxsf_sbi *sbi, struct inode *inode, | |
| 86 | + const struct shfl_fsobjinfo *info); | |
| 87 | +int vboxsf_create_at_dentry(struct dentry *dentry, | |
| 88 | + struct shfl_createparms *params); | |
| 89 | +int vboxsf_stat(struct vboxsf_sbi *sbi, struct shfl_string *path, | |
| 90 | + struct shfl_fsobjinfo *info); | |
| 91 | +int vboxsf_stat_dentry(struct dentry *dentry, struct shfl_fsobjinfo *info); | |
| 92 | +int vboxsf_inode_revalidate(struct dentry *dentry); | |
| 93 | +int vboxsf_getattr(const struct path *path, struct kstat *kstat, | |
| 94 | + u32 request_mask, unsigned int query_flags); | |
| 95 | +int vboxsf_setattr(struct dentry *dentry, struct iattr *iattr); | |
| 96 | +struct shfl_string *vboxsf_path_from_dentry(struct vboxsf_sbi *sbi, | |
| 97 | + struct dentry *dentry); | |
| 98 | +int vboxsf_nlscpy(struct vboxsf_sbi *sbi, char *name, size_t name_bound_len, | |
| 99 | + const unsigned char *utf8_name, size_t utf8_len); | |
| 100 | +struct vboxsf_dir_info *vboxsf_dir_info_alloc(void); | |
| 101 | +void vboxsf_dir_info_free(struct vboxsf_dir_info *p); | |
| 102 | +int vboxsf_dir_read_all(struct vboxsf_sbi *sbi, struct vboxsf_dir_info *sf_d, | |
| 103 | + u64 handle); | |
| 104 | + | |
| 105 | +/* from vboxsf_wrappers.c */ | |
| 106 | +int vboxsf_connect(void); | |
| 107 | +void vboxsf_disconnect(void); | |
| 108 | + | |
| 109 | +int vboxsf_create(u32 root, struct shfl_string *parsed_path, | |
| 110 | + struct shfl_createparms *create_parms); | |
| 111 | + | |
| 112 | +int vboxsf_close(u32 root, u64 handle); | |
| 113 | +int vboxsf_remove(u32 root, struct shfl_string *parsed_path, u32 flags); | |
| 114 | +int vboxsf_rename(u32 root, struct shfl_string *src_path, | |
| 115 | + struct shfl_string *dest_path, u32 flags); | |
| 116 | + | |
| 117 | +int vboxsf_read(u32 root, u64 handle, u64 offset, u32 *buf_len, u8 *buf); | |
| 118 | +int vboxsf_write(u32 root, u64 handle, u64 offset, u32 *buf_len, u8 *buf); | |
| 119 | + | |
| 120 | +int vboxsf_dirinfo(u32 root, u64 handle, | |
| 121 | + struct shfl_string *parsed_path, u32 flags, u32 index, | |
| 122 | + u32 *buf_len, struct shfl_dirinfo *buf, u32 *file_count); | |
| 123 | +int vboxsf_fsinfo(u32 root, u64 handle, u32 flags, | |
| 124 | + u32 *buf_len, void *buf); | |
| 125 | + | |
| 126 | +int vboxsf_map_folder(struct shfl_string *folder_name, u32 *root); | |
| 127 | +int vboxsf_unmap_folder(u32 root); | |
| 128 | + | |
| 129 | +int vboxsf_readlink(u32 root, struct shfl_string *parsed_path, | |
| 130 | + u32 buf_len, u8 *buf); | |
| 131 | +int vboxsf_symlink(u32 root, struct shfl_string *new_path, | |
| 132 | + struct shfl_string *old_path, struct shfl_fsobjinfo *buf); | |
| 133 | + | |
| 134 | +int vboxsf_set_utf8(void); | |
| 135 | +int vboxsf_set_symlinks(void); | |
| 136 | + | |
| 137 | +#endif | |
| @@ -1831,7 +1831,7 @@ static void cxgbit_fw4_ack(struct cxgbit_sock *csk, struct sk_buff *skb) · 1830 unmodified lines | ||
| 1831 | 1831 | |
| 1832 | 1832 | while (credits) { |
| 1833 | 1833 | struct sk_buff *p = cxgbit_sock_peek_wr(csk); |
| 1834 | − const u32 csum = (__force u32)p->csum; | |
| 1834 | + u32 csum; | |
| 1835 | 1835 | |
| 1836 | 1836 | if (unlikely(!p)) { |
| 1837 | 1837 | pr_err("csk 0x%p,%u, cr %u,%u+%u, empty.\n", |
| @@ -1840,6 +1840,7 @@ static void cxgbit_fw4_ack(struct cxgbit_sock *csk, struct sk_buff *skb) · 2 unmodified lines | ||
| 1840 | 1840 | break; |
| 1841 | 1841 | } |
| 1842 | 1842 | |
| 1843 | + csum = (__force u32)p->csum; | |
| 1843 | 1844 | if (unlikely(credits < csum)) { |
| 1844 | 1845 | pr_warn("csk 0x%p,%u, cr %u,%u+%u, < %u.\n", |
| 1845 | 1846 | csk, csk->tid, |
| @@ -80,7 +80,6 @@ static void icl_nhi_lc_mailbox_cmd(struct tb_nhi *nhi, enum icl_lc_mailbox_cmd c · 79 unmodified lines | ||
| 80 | 80 | { |
| 81 | 81 | u32 data; |
| 82 | 82 | |
| 83 | − pci_read_config_dword(nhi->pdev, VS_CAP_19, &data); | |
| 84 | 83 | data = (cmd << VS_CAP_19_CMD_SHIFT) & VS_CAP_19_CMD_MASK; |
| 85 | 84 | pci_write_config_dword(nhi->pdev, VS_CAP_19, data | VS_CAP_19_VALID); |
| 86 | 85 | } |
| @@ -896,12 +896,13 @@ int tb_dp_port_set_hops(struct tb_port *port, unsigned int video, · 895 unmodified lines | ||
| 896 | 896 | */ |
| 897 | 897 | bool tb_dp_port_is_enabled(struct tb_port *port) |
| 898 | 898 | { |
| 899 | − u32 data; | |
| 899 | + u32 data[2]; | |
| 900 | 900 | |
| 901 | − if (tb_port_read(port, &data, TB_CFG_PORT, port->cap_adap, 1)) | |
| 901 | + if (tb_port_read(port, data, TB_CFG_PORT, port->cap_adap, | |
| 902 | + ARRAY_SIZE(data))) | |
| 902 | 903 | return false; |
| 903 | 904 | |
| 904 | − return !!(data & (TB_DP_VIDEO_EN | TB_DP_AUX_EN)); | |
| 905 | + return !!(data[0] & (TB_DP_VIDEO_EN | TB_DP_AUX_EN)); | |
| 905 | 906 | } |
| 906 | 907 | |
| 907 | 908 | /** |
| @@ -914,19 +915,21 @@ bool tb_dp_port_is_enabled(struct tb_port *port) · 6 unmodified lines | ||
| 914 | 915 | */ |
| 915 | 916 | int tb_dp_port_enable(struct tb_port *port, bool enable) |
| 916 | 917 | { |
| 917 | − u32 data; | |
| 918 | + u32 data[2]; | |
| 918 | 919 | int ret; |
| 919 | 920 | |
| 920 | − ret = tb_port_read(port, &data, TB_CFG_PORT, port->cap_adap, 1); | |
| 921 | + ret = tb_port_read(port, data, TB_CFG_PORT, port->cap_adap, | |
| 922 | + ARRAY_SIZE(data)); | |
| 921 | 923 | if (ret) |
| 922 | 924 | return ret; |
| 923 | 925 | |
| 924 | 926 | if (enable) |
| 925 | − data |= TB_DP_VIDEO_EN | TB_DP_AUX_EN; | |
| 927 | + data[0] |= TB_DP_VIDEO_EN | TB_DP_AUX_EN; | |
| 926 | 928 | else |
| 927 | − data &= ~(TB_DP_VIDEO_EN | TB_DP_AUX_EN); | |
| 929 | + data[0] &= ~(TB_DP_VIDEO_EN | TB_DP_AUX_EN); | |
| 928 | 930 | |
| 929 | − return tb_port_write(port, &data, TB_CFG_PORT, port->cap_adap, 1); | |
| 931 | + return tb_port_write(port, data, TB_CFG_PORT, port->cap_adap, | |
| 932 | + ARRAY_SIZE(data)); | |
| 930 | 933 | } |
| 931 | 934 | |
| 932 | 935 | /* switch utility functions */ |
| @@ -1031,13 +1034,6 @@ static int tb_switch_set_authorized(struct tb_switch *sw, unsigned int val) · 98 unmodified lines | ||
| 1031 | 1034 | if (sw->authorized) |
| 1032 | 1035 | goto unlock; |
| 1033 | 1036 | |
| 1034 | − /* | |
| 1035 | − * Make sure there is no PCIe rescan ongoing when a new PCIe | |
| 1036 | − * tunnel is created. Otherwise the PCIe rescan code might find | |
| 1037 | − * the new tunnel too early. | |
| 1038 | − */ | |
| 1039 | − pci_lock_rescan_remove(); | |
| 1040 | − | |
| 1041 | 1037 | switch (val) { |
| 1042 | 1038 | /* Approve switch */ |
| 1043 | 1039 | case 1: |
| @@ -1057,8 +1053,6 @@ static int tb_switch_set_authorized(struct tb_switch *sw, unsigned int val) · 13 unmodified lines | ||
| 1057 | 1053 | break; |
| 1058 | 1054 | } |
| 1059 | 1055 | |
| 1060 | − pci_unlock_rescan_remove(); | |
| 1061 | − | |
| 1062 | 1056 | if (!ret) { |
| 1063 | 1057 | sw->authorized = val; |
| 1064 | 1058 | /* Notify status change to the userspace */ |
| @@ -2329,8 +2329,6 @@ static void cdns3_gadget_config(struct cdns3_device *priv_dev) · 2328 unmodified lines | ||
| 2329 | 2329 | writel(USB_CONF_CLK2OFFDS | USB_CONF_L1DS, ®s->usb_conf); |
| 2330 | 2330 | |
| 2331 | 2331 | cdns3_configure_dmult(priv_dev, NULL); |
| 2332 | − | |
| 2333 | − cdns3_gadget_pullup(&priv_dev->gadget, 1); | |
| 2334 | 2332 | } |
| 2335 | 2333 | |
| 2336 | 2334 | /** |
| @@ -2345,9 +2343,35 @@ static int cdns3_gadget_udc_start(struct usb_gadget *gadget, · 8 unmodified lines | ||
| 2345 | 2343 | { |
| 2346 | 2344 | struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget); |
| 2347 | 2345 | unsigned long flags; |
| 2346 | + enum usb_device_speed max_speed = driver->max_speed; | |
| 2348 | 2347 | |
| 2349 | 2348 | spin_lock_irqsave(&priv_dev->lock, flags); |
| 2350 | 2349 | priv_dev->gadget_driver = driver; |
| 2350 | + | |
| 2351 | + /* limit speed if necessary */ | |
| 2352 | + max_speed = min(driver->max_speed, gadget->max_speed); | |
| 2353 | + | |
| 2354 | + switch (max_speed) { | |
| 2355 | + case USB_SPEED_FULL: | |
| 2356 | + writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf); | |
| 2357 | + writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); | |
| 2358 | + break; | |
| 2359 | + case USB_SPEED_HIGH: | |
| 2360 | + writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); | |
| 2361 | + break; | |
| 2362 | + case USB_SPEED_SUPER: | |
| 2363 | + break; | |
| 2364 | + default: | |
| 2365 | + dev_err(priv_dev->dev, | |
| 2366 | + "invalid maximum_speed parameter %d\n", | |
| 2367 | + max_speed); | |
| 2368 | + /* fall through */ | |
| 2369 | + case USB_SPEED_UNKNOWN: | |
| 2370 | + /* default to superspeed */ | |
| 2371 | + max_speed = USB_SPEED_SUPER; | |
| 2372 | + break; | |
| 2373 | + } | |
| 2374 | + | |
| 2351 | 2375 | cdns3_gadget_config(priv_dev); |
| 2352 | 2376 | spin_unlock_irqrestore(&priv_dev->lock, flags); |
| 2353 | 2377 | return 0; |
| @@ -2381,6 +2405,8 @@ static int cdns3_gadget_udc_stop(struct usb_gadget *gadget) · 27 unmodified lines | ||
| 2381 | 2405 | writel(EP_CMD_EPRST, &priv_dev->regs->ep_cmd); |
| 2382 | 2406 | readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val, |
| 2383 | 2407 | !(val & EP_CMD_EPRST), 1, 100); |
| 2408 | + | |
| 2409 | + priv_ep->flags &= ~EP_CLAIMED; | |
| 2384 | 2410 | } |
| 2385 | 2411 | |
| 2386 | 2412 | /* disable interrupt for device */ |
| @@ -2575,12 +2601,7 @@ static int cdns3_gadget_start(struct cdns3 *cdns) · 188 unmodified lines | ||
| 2575 | 2601 | /* Check the maximum_speed parameter */ |
| 2576 | 2602 | switch (max_speed) { |
| 2577 | 2603 | case USB_SPEED_FULL: |
| 2578 | − writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf); | |
| 2579 | − writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); | |
| 2580 | − break; | |
| 2581 | 2604 | case USB_SPEED_HIGH: |
| 2582 | − writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); | |
| 2583 | − break; | |
| 2584 | 2605 | case USB_SPEED_SUPER: |
| 2585 | 2606 | break; |
| 2586 | 2607 | default: |
| @@ -2713,8 +2734,6 @@ static int cdns3_gadget_suspend(struct cdns3 *cdns, bool do_wakeup) · 126 unmodified lines | ||
| 2713 | 2734 | /* disable interrupt for device */ |
| 2714 | 2735 | writel(0, &priv_dev->regs->usb_ien); |
| 2715 | 2736 | |
| 2716 | − cdns3_gadget_pullup(&priv_dev->gadget, 0); | |
| 2717 | − | |
| 2718 | 2737 | return 0; |
| 2719 | 2738 | } |
| 2720 | 2739 | |
| @@ -12,7 +12,6 @@ · 11 unmodified lines | ||
| 12 | 12 | #ifdef CONFIG_USB_CDNS3_HOST |
| 13 | 13 | |
| 14 | 14 | int cdns3_host_init(struct cdns3 *cdns); |
| 15 | −void cdns3_host_exit(struct cdns3 *cdns); | |
| 16 | 15 | |
| 17 | 16 | #else |
| 18 | 17 | |
| @@ -12,6 +12,7 @@ · 11 unmodified lines | ||
| 12 | 12 | #include <linux/platform_device.h> |
| 13 | 13 | #include "core.h" |
| 14 | 14 | #include "drd.h" |
| 15 | +#include "host-export.h" | |
| 15 | 16 | |
| 16 | 17 | static int __cdns3_host_init(struct cdns3 *cdns) |
| 17 | 18 | { |
| @@ -348,6 +348,11 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, · 347 unmodified lines | ||
| 348 | 348 | |
| 349 | 349 | /* Validate the wMaxPacketSize field */ |
| 350 | 350 | maxp = usb_endpoint_maxp(&endpoint->desc); |
| 351 | + if (maxp == 0) { | |
| 352 | + dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has wMaxPacketSize 0, skipping\n", | |
| 353 | + cfgno, inum, asnum, d->bEndpointAddress); | |
| 354 | + goto skip_to_next_endpoint_or_interface_descriptor; | |
| 355 | + } | |
| 351 | 356 | |
| 352 | 357 | /* Find the highest legal maxpacket size for this endpoint */ |
| 353 | 358 | i = 0; /* additional transactions per microframe */ |
| @@ -102,6 +102,7 @@ config USB_DWC3_MESON_G12A · 101 unmodified lines | ||
| 102 | 102 | depends on ARCH_MESON || COMPILE_TEST |
| 103 | 103 | default USB_DWC3 |
| 104 | 104 | select USB_ROLE_SWITCH |
| 105 | + select REGMAP_MMIO | |
| 105 | 106 | help |
| 106 | 107 | Support USB2/3 functionality in Amlogic G12A platforms. |
| 107 | 108 | Say 'Y' or 'M' if you have one such device. |
| @@ -312,8 +312,7 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc) · 311 unmodified lines | ||
| 312 | 312 | |
| 313 | 313 | reg = dwc3_readl(dwc->regs, DWC3_GFLADJ); |
| 314 | 314 | dft = reg & DWC3_GFLADJ_30MHZ_MASK; |
| 315 | − if (!dev_WARN_ONCE(dwc->dev, dft == dwc->fladj, | |
| 316 | − "request value same as default, ignoring\n")) { | |
| 315 | + if (dft != dwc->fladj) { | |
| 317 | 316 | reg &= ~DWC3_GFLADJ_30MHZ_MASK; |
| 318 | 317 | reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | dwc->fladj; |
| 319 | 318 | dwc3_writel(dwc->regs, DWC3_GFLADJ, reg); |
| @@ -258,7 +258,7 @@ static int dwc3_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) · 257 unmodified lines | ||
| 258 | 258 | |
| 259 | 259 | ret = platform_device_add_properties(dwc->dwc3, p); |
| 260 | 260 | if (ret < 0) |
| 261 | − return ret; | |
| 261 | + goto err; | |
| 262 | 262 | |
| 263 | 263 | ret = dwc3_pci_quirks(dwc); |
| 264 | 264 | if (ret) |
| @@ -707,6 +707,12 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep) · 706 unmodified lines | ||
| 707 | 707 | |
| 708 | 708 | dwc3_gadget_giveback(dep, req, -ESHUTDOWN); |
| 709 | 709 | } |
| 710 | + | |
| 711 | + while (!list_empty(&dep->cancelled_list)) { | |
| 712 | + req = next_request(&dep->cancelled_list); | |
| 713 | + | |
| 714 | + dwc3_gadget_giveback(dep, req, -ESHUTDOWN); | |
| 715 | + } | |
| 710 | 716 | } |
| 711 | 717 | |
| 712 | 718 | /** |
| @@ -2170,14 +2170,18 @@ void composite_dev_cleanup(struct usb_composite_dev *cdev) · 2169 unmodified lines | ||
| 2170 | 2170 | usb_ep_dequeue(cdev->gadget->ep0, cdev->os_desc_req); |
| 2171 | 2171 | |
| 2172 | 2172 | kfree(cdev->os_desc_req->buf); |
| 2173 | + cdev->os_desc_req->buf = NULL; | |
| 2173 | 2174 | usb_ep_free_request(cdev->gadget->ep0, cdev->os_desc_req); |
| 2175 | + cdev->os_desc_req = NULL; | |
| 2174 | 2176 | } |
| 2175 | 2177 | if (cdev->req) { |
| 2176 | 2178 | if (cdev->setup_pending) |
| 2177 | 2179 | usb_ep_dequeue(cdev->gadget->ep0, cdev->req); |
| 2178 | 2180 | |
| 2179 | 2181 | kfree(cdev->req->buf); |
| 2182 | + cdev->req->buf = NULL; | |
| 2180 | 2183 | usb_ep_free_request(cdev->gadget->ep0, cdev->req); |
| 2184 | + cdev->req = NULL; | |
| 2181 | 2185 | } |
| 2182 | 2186 | cdev->next_string_id = 0; |
| 2183 | 2187 | device_remove_file(&cdev->gadget->dev, &dev_attr_suspended); |
| @@ -61,6 +61,8 @@ struct gadget_info { · 60 unmodified lines | ||
| 61 | 61 | bool use_os_desc; |
| 62 | 62 | char b_vendor_code; |
| 63 | 63 | char qw_sign[OS_STRING_QW_SIGN_LEN]; |
| 64 | + spinlock_t spinlock; | |
| 65 | + bool unbind; | |
| 64 | 66 | }; |
| 65 | 67 | |
| 66 | 68 | static inline struct gadget_info *to_gadget_info(struct config_item *item) |
| @@ -1244,6 +1246,7 @@ static int configfs_composite_bind(struct usb_gadget *gadget, · 1177 unmodified lines | ||
| 1244 | 1246 | int ret; |
| 1245 | 1247 | |
| 1246 | 1248 | /* the gi->lock is hold by the caller */ |
| 1249 | + gi->unbind = 0; | |
| 1247 | 1250 | cdev->gadget = gadget; |
| 1248 | 1251 | set_gadget_data(gadget, cdev); |
| 1249 | 1252 | ret = composite_dev_prepare(composite, cdev); |
| @@ -1376,31 +1379,128 @@ static void configfs_composite_unbind(struct usb_gadget *gadget) · 126 unmodified lines | ||
| 1376 | 1379 | { |
| 1377 | 1380 | struct usb_composite_dev *cdev; |
| 1378 | 1381 | struct gadget_info *gi; |
| 1382 | + unsigned long flags; | |
| 1379 | 1383 | |
| 1380 | 1384 | /* the gi->lock is hold by the caller */ |
| 1381 | 1385 | |
| 1382 | 1386 | cdev = get_gadget_data(gadget); |
| 1383 | 1387 | gi = container_of(cdev, struct gadget_info, cdev); |
| 1388 | + spin_lock_irqsave(&gi->spinlock, flags); | |
| 1389 | + gi->unbind = 1; | |
| 1390 | + spin_unlock_irqrestore(&gi->spinlock, flags); | |
| 1384 | 1391 | |
| 1385 | 1392 | kfree(otg_desc[0]); |
| 1386 | 1393 | otg_desc[0] = NULL; |
| 1387 | 1394 | purge_configs_funcs(gi); |
| 1388 | 1395 | composite_dev_cleanup(cdev); |
| 1389 | 1396 | usb_ep_autoconfig_reset(cdev->gadget); |
| 1397 | + spin_lock_irqsave(&gi->spinlock, flags); | |
| 1390 | 1398 | cdev->gadget = NULL; |
| 1391 | 1399 | set_gadget_data(gadget, NULL); |
| 1400 | + spin_unlock_irqrestore(&gi->spinlock, flags); | |
| 1401 | +} | |
| 1402 | + | |
| 1403 | +static int configfs_composite_setup(struct usb_gadget *gadget, | |
| 1404 | + const struct usb_ctrlrequest *ctrl) | |
| 1405 | +{ | |
| 1406 | + struct usb_composite_dev *cdev; | |
| 1407 | + struct gadget_info *gi; | |
| 1408 | + unsigned long flags; | |
| 1409 | + int ret; | |
| 1410 | + | |
| 1411 | + cdev = get_gadget_data(gadget); | |
| 1412 | + if (!cdev) | |
| 1413 | + return 0; | |
| 1414 | + | |
| 1415 | + gi = container_of(cdev, struct gadget_info, cdev); | |
| 1416 | + spin_lock_irqsave(&gi->spinlock, flags); | |
| 1417 | + cdev = get_gadget_data(gadget); | |
| 1418 | + if (!cdev || gi->unbind) { | |
| 1419 | + spin_unlock_irqrestore(&gi->spinlock, flags); | |
| 1420 | + return 0; | |
| 1421 | + } | |
| 1422 | + | |
| 1423 | + ret = composite_setup(gadget, ctrl); | |
| 1424 | + spin_unlock_irqrestore(&gi->spinlock, flags); | |
| 1425 | + return ret; | |
| 1426 | +} | |
| 1427 | + | |
| 1428 | +static void configfs_composite_disconnect(struct usb_gadget *gadget) | |
| 1429 | +{ | |
| 1430 | + struct usb_composite_dev *cdev; | |
| 1431 | + struct gadget_info *gi; | |
| 1432 | + unsigned long flags; | |
| 1433 | + | |
| 1434 | + cdev = get_gadget_data(gadget); | |
| 1435 | + if (!cdev) | |
| 1436 | + return; | |
| 1437 | + | |
| 1438 | + gi = container_of(cdev, struct gadget_info, cdev); | |
| 1439 | + spin_lock_irqsave(&gi->spinlock, flags); | |
| 1440 | + cdev = get_gadget_data(gadget); | |
| 1441 | + if (!cdev || gi->unbind) { | |
| 1442 | + spin_unlock_irqrestore(&gi->spinlock, flags); | |
| 1443 | + return; | |
| 1444 | + } | |
| 1445 | + | |
| 1446 | + composite_disconnect(gadget); | |
| 1447 | + spin_unlock_irqrestore(&gi->spinlock, flags); | |
| 1448 | +} | |
| 1449 | + | |
| 1450 | +static void configfs_composite_suspend(struct usb_gadget *gadget) | |
| 1451 | +{ | |
| 1452 | + struct usb_composite_dev *cdev; | |
| 1453 | + struct gadget_info *gi; | |
| 1454 | + unsigned long flags; | |
| 1455 | + | |
| 1456 | + cdev = get_gadget_data(gadget); | |
| 1457 | + if (!cdev) | |
| 1458 | + return; | |
| 1459 | + | |
| 1460 | + gi = container_of(cdev, struct gadget_info, cdev); | |
| 1461 | + spin_lock_irqsave(&gi->spinlock, flags); | |
| 1462 | + cdev = get_gadget_data(gadget); | |
| 1463 | + if (!cdev || gi->unbind) { | |
| 1464 | + spin_unlock_irqrestore(&gi->spinlock, flags); | |
| 1465 | + return; | |
| 1466 | + } | |
| 1467 | + | |
| 1468 | + composite_suspend(gadget); | |
| 1469 | + spin_unlock_irqrestore(&gi->spinlock, flags); | |
| 1470 | +} | |
| 1471 | + | |
| 1472 | +static void configfs_composite_resume(struct usb_gadget *gadget) | |
| 1473 | +{ | |
| 1474 | + struct usb_composite_dev *cdev; | |
| 1475 | + struct gadget_info *gi; | |
| 1476 | + unsigned long flags; | |
| 1477 | + | |
| 1478 | + cdev = get_gadget_data(gadget); | |
| 1479 | + if (!cdev) | |
| 1480 | + return; | |
| 1481 | + | |
| 1482 | + gi = container_of(cdev, struct gadget_info, cdev); | |
| 1483 | + spin_lock_irqsave(&gi->spinlock, flags); | |
| 1484 | + cdev = get_gadget_data(gadget); | |
| 1485 | + if (!cdev || gi->unbind) { | |
| 1486 | + spin_unlock_irqrestore(&gi->spinlock, flags); | |
| 1487 | + return; | |
| 1488 | + } | |
| 1489 | + | |
| 1490 | + composite_resume(gadget); | |
| 1491 | + spin_unlock_irqrestore(&gi->spinlock, flags); | |
| 1392 | 1492 | } |
| 1393 | 1493 | |
| 1394 | 1494 | static const struct usb_gadget_driver configfs_driver_template = { |
| 1395 | 1495 | .bind = configfs_composite_bind, |
| 1396 | 1496 | .unbind = configfs_composite_unbind, |
| 1397 | 1497 | |
| 1398 | − .setup = composite_setup, | |
| 1399 | − .reset = composite_disconnect, | |
| 1400 | − .disconnect = composite_disconnect, | |
| 1498 | + .setup = configfs_composite_setup, | |
| 1499 | + .reset = configfs_composite_disconnect, | |
| 1500 | + .disconnect = configfs_composite_disconnect, | |
| 1401 | 1501 | |
| 1402 | − .suspend = composite_suspend, | |
| 1403 | − .resume = composite_resume, | |
| 1502 | + .suspend = configfs_composite_suspend, | |
| 1503 | + .resume = configfs_composite_resume, | |
| 1404 | 1504 | |
| 1405 | 1505 | .max_speed = USB_SPEED_SUPER, |
| 1406 | 1506 | .driver = { |
| @@ -449,9 +449,11 @@ static void submit_request(struct usba_ep *ep, struct usba_request *req) · 448 unmodified lines | ||
| 449 | 449 | next_fifo_transaction(ep, req); |
| 450 | 450 | if (req->last_transaction) { |
| 451 | 451 | usba_ep_writel(ep, CTL_DIS, USBA_TX_PK_RDY); |
| 452 | − usba_ep_writel(ep, CTL_ENB, USBA_TX_COMPLETE); | |
| 452 | + if (ep_is_control(ep)) | |
| 453 | + usba_ep_writel(ep, CTL_ENB, USBA_TX_COMPLETE); | |
| 453 | 454 | } else { |
| 454 | − usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); | |
| 455 | + if (ep_is_control(ep)) | |
| 456 | + usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); | |
| 455 | 457 | usba_ep_writel(ep, CTL_ENB, USBA_TX_PK_RDY); |
| 456 | 458 | } |
| 457 | 459 | } |
| @@ -98,6 +98,17 @@ int usb_ep_enable(struct usb_ep *ep) · 97 unmodified lines | ||
| 98 | 98 | if (ep->enabled) |
| 99 | 99 | goto out; |
| 100 | 100 | |
| 101 | + /* UDC drivers can't handle endpoints with maxpacket size 0 */ | |
| 102 | + if (usb_endpoint_maxp(ep->desc) == 0) { | |
| 103 | + /* | |
| 104 | + * We should log an error message here, but we can't call | |
| 105 | + * dev_err() because there's no way to find the gadget | |
| 106 | + * given only ep. | |
| 107 | + */ | |
| 108 | + ret = -EINVAL; | |
| 109 | + goto out; | |
| 110 | + } | |
| 111 | + | |
| 101 | 112 | ret = ep->ops->enable(ep, ep->desc); |
| 102 | 113 | if (ret) |
| 103 | 114 | goto out; |
| @@ -2576,7 +2576,7 @@ static int fsl_udc_remove(struct platform_device *pdev) · 2575 unmodified lines | ||
| 2576 | 2576 | dma_pool_destroy(udc_controller->td_pool); |
| 2577 | 2577 | free_irq(udc_controller->irq, udc_controller); |
| 2578 | 2578 | iounmap(dr_regs); |
| 2579 | − if (pdata->operating_mode == FSL_USB2_DR_DEVICE) | |
| 2579 | + if (res && (pdata->operating_mode == FSL_USB2_DR_DEVICE)) | |
| 2580 | 2580 | release_mem_region(res->start, resource_size(res)); |
| 2581 | 2581 | |
| 2582 | 2582 | /* free udc --wait for the release() finished */ |
| @@ -1544,10 +1544,10 @@ static void usb3_set_device_address(struct renesas_usb3 *usb3, u16 addr) · 1543 unmodified lines | ||
| 1544 | 1544 | static bool usb3_std_req_set_address(struct renesas_usb3 *usb3, |
| 1545 | 1545 | struct usb_ctrlrequest *ctrl) |
| 1546 | 1546 | { |
| 1547 | − if (ctrl->wValue >= 128) | |
| 1547 | + if (le16_to_cpu(ctrl->wValue) >= 128) | |
| 1548 | 1548 | return true; /* stall */ |
| 1549 | 1549 | |
| 1550 | − usb3_set_device_address(usb3, ctrl->wValue); | |
| 1550 | + usb3_set_device_address(usb3, le16_to_cpu(ctrl->wValue)); | |
| 1551 | 1551 | usb3_set_p0_con_for_no_data(usb3); |
| 1552 | 1552 | |
| 1553 | 1553 | return false; |
| @@ -1582,6 +1582,7 @@ static bool usb3_std_req_get_status(struct renesas_usb3 *usb3, · 28 unmodified lines | ||
| 1582 | 1582 | struct renesas_usb3_ep *usb3_ep; |
| 1583 | 1583 | int num; |
| 1584 | 1584 | u16 status = 0; |
| 1585 | + __le16 tx_data; | |
| 1585 | 1586 | |
| 1586 | 1587 | switch (ctrl->bRequestType & USB_RECIP_MASK) { |
| 1587 | 1588 | case USB_RECIP_DEVICE: |
| @@ -1604,10 +1605,10 @@ static bool usb3_std_req_get_status(struct renesas_usb3 *usb3, · 16 unmodified lines | ||
| 1604 | 1605 | } |
| 1605 | 1606 | |
| 1606 | 1607 | if (!stall) { |
| 1607 | − status = cpu_to_le16(status); | |
| 1608 | + tx_data = cpu_to_le16(status); | |
| 1608 | 1609 | dev_dbg(usb3_to_dev(usb3), "get_status: req = %p\n", |
| 1609 | 1610 | usb_req_to_usb3_req(usb3->ep0_req)); |
| 1610 | − usb3_pipe0_internal_xfer(usb3, &status, sizeof(status), | |
| 1611 | + usb3_pipe0_internal_xfer(usb3, &tx_data, sizeof(tx_data), | |
| 1611 | 1612 | usb3_pipe0_get_status_completion); |
| 1612 | 1613 | } |
| 1613 | 1614 | |
| @@ -1772,7 +1773,7 @@ static bool usb3_std_req_set_sel(struct renesas_usb3 *usb3, · 158 unmodified lines | ||
| 1772 | 1773 | static bool usb3_std_req_set_configuration(struct renesas_usb3 *usb3, |
| 1773 | 1774 | struct usb_ctrlrequest *ctrl) |
| 1774 | 1775 | { |
| 1775 | − if (ctrl->wValue > 0) | |
| 1776 | + if (le16_to_cpu(ctrl->wValue) > 0) | |
| 1776 | 1777 | usb3_set_bit(usb3, USB_COM_CON_CONF, USB3_USB_COM_CON); |
| 1777 | 1778 | else |
| 1778 | 1779 | usb3_clear_bit(usb3, USB_COM_CON_CONF, USB3_USB_COM_CON); |
| @@ -202,10 +202,10 @@ static void xhci_ring_dump_segment(struct seq_file *s, · 201 unmodified lines | ||
| 202 | 202 | trb = &seg->trbs[i]; |
| 203 | 203 | dma = seg->dma + i * sizeof(*trb); |
| 204 | 204 | seq_printf(s, "%pad: %s\n", &dma, |
| 205 | − xhci_decode_trb(trb->generic.field[0], | |
| 206 | − trb->generic.field[1], | |
| 207 | − trb->generic.field[2], | |
| 208 | − trb->generic.field[3])); | |
| 205 | + xhci_decode_trb(le32_to_cpu(trb->generic.field[0]), | |
| 206 | + le32_to_cpu(trb->generic.field[1]), | |
| 207 | + le32_to_cpu(trb->generic.field[2]), | |
| 208 | + le32_to_cpu(trb->generic.field[3]))); | |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
| @@ -263,10 +263,10 @@ static int xhci_slot_context_show(struct seq_file *s, void *unused) · 51 unmodified lines | ||
| 263 | 263 | xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus)); |
| 264 | 264 | slot_ctx = xhci_get_slot_ctx(xhci, dev->out_ctx); |
| 265 | 265 | seq_printf(s, "%pad: %s\n", &dev->out_ctx->dma, |
| 266 | − xhci_decode_slot_context(slot_ctx->dev_info, | |
| 267 | − slot_ctx->dev_info2, | |
| 268 | − slot_ctx->tt_info, | |
| 269 | − slot_ctx->dev_state)); | |
| 266 | + xhci_decode_slot_context(le32_to_cpu(slot_ctx->dev_info), | |
| 267 | + le32_to_cpu(slot_ctx->dev_info2), | |
| 268 | + le32_to_cpu(slot_ctx->tt_info), | |
| 269 | + le32_to_cpu(slot_ctx->dev_state))); | |
| 270 | 270 | |
| 271 | 271 | return 0; |
| 272 | 272 | } |
| @@ -286,10 +286,10 @@ static int xhci_endpoint_context_show(struct seq_file *s, void *unused) · 13 unmodified lines | ||
| 286 | 286 | ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, dci); |
| 287 | 287 | dma = dev->out_ctx->dma + dci * CTX_SIZE(xhci->hcc_params); |
| 288 | 288 | seq_printf(s, "%pad: %s\n", &dma, |
| 289 | − xhci_decode_ep_context(ep_ctx->ep_info, | |
| 290 | − ep_ctx->ep_info2, | |
| 291 | − ep_ctx->deq, | |
| 292 | − ep_ctx->tx_info)); | |
| 289 | + xhci_decode_ep_context(le32_to_cpu(ep_ctx->ep_info), | |
| 290 | + le32_to_cpu(ep_ctx->ep_info2), | |
| 291 | + le64_to_cpu(ep_ctx->deq), | |
| 292 | + le32_to_cpu(ep_ctx->tx_info))); | |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | return 0; |
| @@ -3330,6 +3330,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, · 3329 unmodified lines | ||
| 3330 | 3330 | if (xhci_urb_suitable_for_idt(urb)) { |
| 3331 | 3331 | memcpy(&send_addr, urb->transfer_buffer, |
| 3332 | 3332 | trb_buff_len); |
| 3333 | + le64_to_cpus(&send_addr); | |
| 3333 | 3334 | field |= TRB_IDT; |
| 3334 | 3335 | } |
| 3335 | 3336 | } |
| @@ -3475,6 +3476,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, · 139 unmodified lines | ||
| 3475 | 3476 | if (xhci_urb_suitable_for_idt(urb)) { |
| 3476 | 3477 | memcpy(&addr, urb->transfer_buffer, |
| 3477 | 3478 | urb->transfer_buffer_length); |
| 3479 | + le64_to_cpus(&addr); | |
| 3478 | 3480 | field |= TRB_IDT; |
| 3479 | 3481 | } else { |
| 3480 | 3482 | addr = (u64) urb->transfer_dma; |
| @@ -3071,6 +3071,48 @@ void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, unsigned int ep_index, · 3070 unmodified lines | ||
| 3071 | 3071 | } |
| 3072 | 3072 | } |
| 3073 | 3073 | |
| 3074 | +static void xhci_endpoint_disable(struct usb_hcd *hcd, | |
| 3075 | + struct usb_host_endpoint *host_ep) | |
| 3076 | +{ | |
| 3077 | + struct xhci_hcd *xhci; | |
| 3078 | + struct xhci_virt_device *vdev; | |
| 3079 | + struct xhci_virt_ep *ep; | |
| 3080 | + struct usb_device *udev; | |
| 3081 | + unsigned long flags; | |
| 3082 | + unsigned int ep_index; | |
| 3083 | + | |
| 3084 | + xhci = hcd_to_xhci(hcd); | |
| 3085 | +rescan: | |
| 3086 | + spin_lock_irqsave(&xhci->lock, flags); | |
| 3087 | + | |
| 3088 | + udev = (struct usb_device *)host_ep->hcpriv; | |
| 3089 | + if (!udev || !udev->slot_id) | |
| 3090 | + goto done; | |
| 3091 | + | |
| 3092 | + vdev = xhci->devs[udev->slot_id]; | |
| 3093 | + if (!vdev) | |
| 3094 | + goto done; | |
| 3095 | + | |
| 3096 | + ep_index = xhci_get_endpoint_index(&host_ep->desc); | |
| 3097 | + ep = &vdev->eps[ep_index]; | |
| 3098 | + if (!ep) | |
| 3099 | + goto done; | |
| 3100 | + | |
| 3101 | + /* wait for hub_tt_work to finish clearing hub TT */ | |
| 3102 | + if (ep->ep_state & EP_CLEARING_TT) { | |
| 3103 | + spin_unlock_irqrestore(&xhci->lock, flags); | |
| 3104 | + schedule_timeout_uninterruptible(1); | |
| 3105 | + goto rescan; | |
| 3106 | + } | |
| 3107 | + | |
| 3108 | + if (ep->ep_state) | |
| 3109 | + xhci_dbg(xhci, "endpoint disable with ep_state 0x%x\n", | |
| 3110 | + ep->ep_state); | |
| 3111 | +done: | |
| 3112 | + host_ep->hcpriv = NULL; | |
| 3113 | + spin_unlock_irqrestore(&xhci->lock, flags); | |
| 3114 | +} | |
| 3115 | + | |
| 3074 | 3116 | /* |
| 3075 | 3117 | * Called after usb core issues a clear halt control message. |
| 3076 | 3118 | * The host side of the halt should already be cleared by a reset endpoint |
| @@ -5238,20 +5280,13 @@ static void xhci_clear_tt_buffer_complete(struct usb_hcd *hcd, · 2161 unmodified lines | ||
| 5238 | 5280 | unsigned int ep_index; |
| 5239 | 5281 | unsigned long flags; |
| 5240 | 5282 | |
| 5241 | − /* | |
| 5242 | − * udev might be NULL if tt buffer is cleared during a failed device | |
| 5243 | − * enumeration due to a halted control endpoint. Usb core might | |
| 5244 | − * have allocated a new udev for the next enumeration attempt. | |
| 5245 | − */ | |
| 5246 | − | |
| 5247 | 5283 | xhci = hcd_to_xhci(hcd); |
| 5284 | + | |
| 5285 | + spin_lock_irqsave(&xhci->lock, flags); | |
| 5248 | 5286 | udev = (struct usb_device *)ep->hcpriv; |
| 5249 | − if (!udev) | |
| 5250 | − return; | |
| 5251 | 5287 | slot_id = udev->slot_id; |
| 5252 | 5288 | ep_index = xhci_get_endpoint_index(&ep->desc); |
| 5253 | 5289 | |
| 5254 | − spin_lock_irqsave(&xhci->lock, flags); | |
| 5255 | 5290 | xhci->devs[slot_id]->eps[ep_index].ep_state &= ~EP_CLEARING_TT; |
| 5256 | 5291 | xhci_ring_doorbell_for_active_rings(xhci, slot_id, ep_index); |
| 5257 | 5292 | spin_unlock_irqrestore(&xhci->lock, flags); |
| @@ -5288,6 +5323,7 @@ static const struct hc_driver xhci_hc_driver = { · 30 unmodified lines | ||
| 5288 | 5323 | .free_streams = xhci_free_streams, |
| 5289 | 5324 | .add_endpoint = xhci_add_endpoint, |
| 5290 | 5325 | .drop_endpoint = xhci_drop_endpoint, |
| 5326 | + .endpoint_disable = xhci_endpoint_disable, | |
| 5291 | 5327 | .endpoint_reset = xhci_endpoint_reset, |
| 5292 | 5328 | .check_bandwidth = xhci_check_bandwidth, |
| 5293 | 5329 | .reset_bandwidth = xhci_reset_bandwidth, |
| @@ -487,7 +487,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count, · 486 unmodified lines | ||
| 487 | 487 | } |
| 488 | 488 | bytes_to_read = min(count, *actual_buffer); |
| 489 | 489 | if (bytes_to_read < *actual_buffer) |
| 490 | − dev_warn(&dev->intf->dev, "Read buffer overflow, %zd bytes dropped\n", | |
| 490 | + dev_warn(&dev->intf->dev, "Read buffer overflow, %zu bytes dropped\n", | |
| 491 | 491 | *actual_buffer-bytes_to_read); |
| 492 | 492 | |
| 493 | 493 | /* copy one interrupt_in_buffer from ring_buffer into userspace */ |
| @@ -495,11 +495,11 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count, · 1 unmodified line | ||
| 495 | 495 | retval = -EFAULT; |
| 496 | 496 | goto unlock_exit; |
| 497 | 497 | } |
| 498 | − dev->ring_tail = (dev->ring_tail+1) % ring_buffer_size; | |
| 499 | − | |
| 500 | 498 | retval = bytes_to_read; |
| 501 | 499 | |
| 502 | 500 | spin_lock_irq(&dev->rbsl); |
| 501 | + dev->ring_tail = (dev->ring_tail + 1) % ring_buffer_size; | |
| 502 | + | |
| 503 | 503 | if (dev->buffer_overflow) { |
| 504 | 504 | dev->buffer_overflow = 0; |
| 505 | 505 | spin_unlock_irq(&dev->rbsl); |
| @@ -562,8 +562,9 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, · 56 unmodified lines | ||
| 562 | 562 | /* write the data into interrupt_out_buffer from userspace */ |
| 563 | 563 | bytes_to_write = min(count, write_buffer_size*dev->interrupt_out_endpoint_size); |
| 564 | 564 | if (bytes_to_write < count) |
| 565 | − dev_warn(&dev->intf->dev, "Write buffer overflow, %zd bytes dropped\n", count-bytes_to_write); | |
| 566 | − dev_dbg(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n", | |
| 565 | + dev_warn(&dev->intf->dev, "Write buffer overflow, %zu bytes dropped\n", | |
| 566 | + count - bytes_to_write); | |
| 567 | + dev_dbg(&dev->intf->dev, "%s: count = %zu, bytes_to_write = %zu\n", | |
| 567 | 568 | __func__, count, bytes_to_write); |
| 568 | 569 | |
| 569 | 570 | if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) { |
| @@ -580,7 +581,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, · 10 unmodified lines | ||
| 580 | 581 | 1 << 8, 0, |
| 581 | 582 | dev->interrupt_out_buffer, |
| 582 | 583 | bytes_to_write, |
| 583 | − USB_CTRL_SET_TIMEOUT * HZ); | |
| 584 | + USB_CTRL_SET_TIMEOUT); | |
| 584 | 585 | if (retval < 0) |
| 585 | 586 | dev_err(&dev->intf->dev, |
| 586 | 587 | "Couldn't submit HID_REQ_SET_REPORT %d\n", |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 16 | 16 | #include <linux/platform_device.h> |
| 17 | 17 | |
| 18 | 18 | #include "mtu3.h" |
| 19 | +#include "mtu3_dr.h" | |
| 19 | 20 | #include "mtu3_debug.h" |
| 20 | 21 | #include "mtu3_trace.h" |
| 21 | 22 | |
| @@ -162,17 +162,17 @@ void usbhs_usbreq_get_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req) · 161 unmodified lines | ||
| 162 | 162 | req->bRequest = (val >> 8) & 0xFF; |
| 163 | 163 | req->bRequestType = (val >> 0) & 0xFF; |
| 164 | 164 | |
| 165 | − req->wValue = usbhs_read(priv, USBVAL); | |
| 166 | − req->wIndex = usbhs_read(priv, USBINDX); | |
| 167 | − req->wLength = usbhs_read(priv, USBLENG); | |
| 165 | + req->wValue = cpu_to_le16(usbhs_read(priv, USBVAL)); | |
| 166 | + req->wIndex = cpu_to_le16(usbhs_read(priv, USBINDX)); | |
| 167 | + req->wLength = cpu_to_le16(usbhs_read(priv, USBLENG)); | |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | void usbhs_usbreq_set_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req) |
| 171 | 171 | { |
| 172 | 172 | usbhs_write(priv, USBREQ, (req->bRequest << 8) | req->bRequestType); |
| 173 | − usbhs_write(priv, USBVAL, req->wValue); | |
| 174 | − usbhs_write(priv, USBINDX, req->wIndex); | |
| 175 | − usbhs_write(priv, USBLENG, req->wLength); | |
| 173 | + usbhs_write(priv, USBVAL, le16_to_cpu(req->wValue)); | |
| 174 | + usbhs_write(priv, USBINDX, le16_to_cpu(req->wIndex)); | |
| 175 | + usbhs_write(priv, USBLENG, le16_to_cpu(req->wLength)); | |
| 176 | 176 | |
| 177 | 177 | usbhs_bset(priv, DCPCTR, SUREQ, SUREQ); |
| 178 | 178 | } |
| @@ -265,7 +265,7 @@ static int usbhsg_recip_handler_std_set_device(struct usbhs_priv *priv, · 264 unmodified lines | ||
| 265 | 265 | case USB_DEVICE_TEST_MODE: |
| 266 | 266 | usbhsg_recip_handler_std_control_done(priv, uep, ctrl); |
| 267 | 267 | udelay(100); |
| 268 | − usbhs_sys_set_test_mode(priv, le16_to_cpu(ctrl->wIndex >> 8)); | |
| 268 | + usbhs_sys_set_test_mode(priv, le16_to_cpu(ctrl->wIndex) >> 8); | |
| 269 | 269 | break; |
| 270 | 270 | default: |
| 271 | 271 | usbhsg_recip_handler_std_control_done(priv, uep, ctrl); |
| @@ -315,7 +315,7 @@ static void __usbhsg_recip_send_status(struct usbhsg_gpriv *gpriv, · 43 unmodified lines | ||
| 315 | 315 | struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(dcp); |
| 316 | 316 | struct device *dev = usbhsg_gpriv_to_dev(gpriv); |
| 317 | 317 | struct usb_request *req; |
| 318 | − unsigned short *buf; | |
| 318 | + __le16 *buf; | |
| 319 | 319 | |
| 320 | 320 | /* alloc new usb_request for recip */ |
| 321 | 321 | req = usb_ep_alloc_request(&dcp->ep, GFP_ATOMIC); |
| @@ -559,6 +559,10 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, · 558 unmodified lines | ||
| 559 | 559 | |
| 560 | 560 | command_port = port->serial->port[COMMAND_PORT]; |
| 561 | 561 | command_info = usb_get_serial_port_data(command_port); |
| 562 | + | |
| 563 | + if (command_port->bulk_out_size < datasize + 1) | |
| 564 | + return -EIO; | |
| 565 | + | |
| 562 | 566 | mutex_lock(&command_info->mutex); |
| 563 | 567 | command_info->command_finished = false; |
| 564 | 568 | |
| @@ -632,6 +636,7 @@ static void firm_setup_port(struct tty_struct *tty) · 67 unmodified lines | ||
| 632 | 636 | struct device *dev = &port->dev; |
| 633 | 637 | struct whiteheat_port_settings port_settings; |
| 634 | 638 | unsigned int cflag = tty->termios.c_cflag; |
| 639 | + speed_t baud; | |
| 635 | 640 | |
| 636 | 641 | port_settings.port = port->port_number + 1; |
| 637 | 642 | |
| @@ -692,11 +697,13 @@ static void firm_setup_port(struct tty_struct *tty) · 54 unmodified lines | ||
| 692 | 697 | dev_dbg(dev, "%s - XON = %2x, XOFF = %2x\n", __func__, port_settings.xon, port_settings.xoff); |
| 693 | 698 | |
| 694 | 699 | /* get the baud rate wanted */ |
| 695 | − port_settings.baud = tty_get_baud_rate(tty); | |
| 696 | − dev_dbg(dev, "%s - baud rate = %d\n", __func__, port_settings.baud); | |
| 700 | + baud = tty_get_baud_rate(tty); | |
| 701 | + port_settings.baud = cpu_to_le32(baud); | |
| 702 | + dev_dbg(dev, "%s - baud rate = %u\n", __func__, baud); | |
| 697 | 703 | |
| 698 | 704 | /* fixme: should set validated settings */ |
| 699 | − tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud); | |
| 705 | + tty_encode_baud_rate(tty, baud, baud); | |
| 706 | + | |
| 700 | 707 | /* handle any settings that aren't specified in the tty structure */ |
| 701 | 708 | port_settings.lloop = 0; |
| 702 | 709 | |
| @@ -87,7 +87,7 @@ struct whiteheat_simple { · 86 unmodified lines | ||
| 87 | 87 | |
| 88 | 88 | struct whiteheat_port_settings { |
| 89 | 89 | __u8 port; /* port number (1 to N) */ |
| 90 | − __u32 baud; /* any value 7 - 460800, firmware calculates | |
| 90 | + __le32 baud; /* any value 7 - 460800, firmware calculates | |
| 91 | 91 | best fit; arrives little endian */ |
| 92 | 92 | __u8 bits; /* 5, 6, 7, or 8 */ |
| 93 | 93 | __u8 stop; /* 1 or 2, default 1 (2 = 1.5 if bits = 5) */ |
| @@ -68,7 +68,6 @@ static const char* host_info(struct Scsi_Host *host) · 67 unmodified lines | ||
| 68 | 68 | static int slave_alloc (struct scsi_device *sdev) |
| 69 | 69 | { |
| 70 | 70 | struct us_data *us = host_to_us(sdev->host); |
| 71 | − int maxp; | |
| 72 | 71 | |
| 73 | 72 | /* |
| 74 | 73 | * Set the INQUIRY transfer length to 36. We don't use any of |
| @@ -77,15 +76,6 @@ static int slave_alloc (struct scsi_device *sdev) · 2 unmodified lines | ||
| 77 | 76 | */ |
| 78 | 77 | sdev->inquiry_len = 36; |
| 79 | 78 | |
| 80 | − /* | |
| 81 | − * USB has unusual scatter-gather requirements: the length of each | |
| 82 | − * scatterlist element except the last must be divisible by the | |
| 83 | − * Bulk maxpacket value. Fortunately this value is always a | |
| 84 | − * power of 2. Inform the block layer about this requirement. | |
| 85 | − */ | |
| 86 | − maxp = usb_maxpacket(us->pusb_dev, us->recv_bulk_pipe, 0); | |
| 87 | − blk_queue_virt_boundary(sdev->request_queue, maxp - 1); | |
| 88 | − | |
| 89 | 79 | /* |
| 90 | 80 | * Some host controllers may have alignment requirements. |
| 91 | 81 | * We'll play it safe by requiring 512-byte alignment always. |
| @@ -789,29 +789,9 @@ static int uas_slave_alloc(struct scsi_device *sdev) · 788 unmodified lines | ||
| 789 | 789 | { |
| 790 | 790 | struct uas_dev_info *devinfo = |
| 791 | 791 | (struct uas_dev_info *)sdev->host->hostdata; |
| 792 | − int maxp; | |
| 793 | 792 | |
| 794 | 793 | sdev->hostdata = devinfo; |
| 795 | 794 | |
| 796 | − /* | |
| 797 | − * We have two requirements here. We must satisfy the requirements | |
| 798 | − * of the physical HC and the demands of the protocol, as we | |
| 799 | − * definitely want no additional memory allocation in this path | |
| 800 | − * ruling out using bounce buffers. | |
| 801 | − * | |
| 802 | − * For a transmission on USB to continue we must never send | |
| 803 | − * a package that is smaller than maxpacket. Hence the length of each | |
| 804 | − * scatterlist element except the last must be divisible by the | |
| 805 | − * Bulk maxpacket value. | |
| 806 | − * If the HC does not ensure that through SG, | |
| 807 | − * the upper layer must do that. We must assume nothing | |
| 808 | − * about the capabilities off the HC, so we use the most | |
| 809 | − * pessimistic requirement. | |
| 810 | − */ | |
| 811 | − | |
| 812 | − maxp = usb_maxpacket(devinfo->udev, devinfo->data_in_pipe, 0); | |
| 813 | − blk_queue_virt_boundary(sdev->request_queue, maxp - 1); | |
| 814 | − | |
| 815 | 795 | /* |
| 816 | 796 | * The protocol has no requirements on alignment in the strict sense. |
| 817 | 797 | * Controllers may or may not have alignment restrictions. |
| @@ -147,7 +147,10 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev) · 146 unmodified lines | ||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | kfree(iov); |
| 150 | + /* This is only for isochronous case */ | |
| 150 | 151 | kfree(iso_buffer); |
| 152 | + iso_buffer = NULL; | |
| 153 | + | |
| 151 | 154 | usbip_dbg_vhci_tx("send txdata\n"); |
| 152 | 155 | |
| 153 | 156 | total_size += txsize; |
| @@ -852,6 +852,12 @@ static inline int xfer_kern(void *src, void *dst, size_t len) · 851 unmodified lines | ||
| 852 | 852 | return 0; |
| 853 | 853 | } |
| 854 | 854 | |
| 855 | +static inline int kern_xfer(void *dst, void *src, size_t len) | |
| 856 | +{ | |
| 857 | + memcpy(dst, src, len); | |
| 858 | + return 0; | |
| 859 | +} | |
| 860 | + | |
| 855 | 861 | /** |
| 856 | 862 | * vringh_init_kern - initialize a vringh for a kernelspace vring. |
| 857 | 863 | * @vrh: the vringh to initialize. |
| @@ -958,7 +964,7 @@ EXPORT_SYMBOL(vringh_iov_pull_kern); · 100 unmodified lines | ||
| 958 | 964 | ssize_t vringh_iov_push_kern(struct vringh_kiov *wiov, |
| 959 | 965 | const void *src, size_t len) |
| 960 | 966 | { |
| 961 | − return vringh_iov_xfer(wiov, (void *)src, len, xfer_kern); | |
| 967 | + return vringh_iov_xfer(wiov, (void *)src, len, kern_xfer); | |
| 962 | 968 | } |
| 963 | 969 | EXPORT_SYMBOL(vringh_iov_push_kern); |
| 964 | 970 | |
| @@ -29,7 +29,7 @@ static inline void _transp(u32 d[], unsigned int i1, unsigned int i2, · 28 unmodified lines | ||
| 29 | 29 | |
| 30 | 30 | extern void c2p_unsupported(void); |
| 31 | 31 | |
| 32 | −static inline u32 get_mask(unsigned int n) | |
| 32 | +static __always_inline u32 get_mask(unsigned int n) | |
| 33 | 33 | { |
| 34 | 34 | switch (n) { |
| 35 | 35 | case 1: |
| @@ -57,7 +57,7 @@ static inline u32 get_mask(unsigned int n) · 21 unmodified lines | ||
| 57 | 57 | * Transpose operations on 8 32-bit words |
| 58 | 58 | */ |
| 59 | 59 | |
| 60 | −static inline void transp8(u32 d[], unsigned int n, unsigned int m) | |
| 60 | +static __always_inline void transp8(u32 d[], unsigned int n, unsigned int m) | |
| 61 | 61 | { |
| 62 | 62 | u32 mask = get_mask(n); |
| 63 | 63 | |
| @@ -99,7 +99,7 @@ static inline void transp8(u32 d[], unsigned int n, unsigned int m) · 35 unmodified lines | ||
| 99 | 99 | * Transpose operations on 4 32-bit words |
| 100 | 100 | */ |
| 101 | 101 | |
| 102 | −static inline void transp4(u32 d[], unsigned int n, unsigned int m) | |
| 102 | +static __always_inline void transp4(u32 d[], unsigned int n, unsigned int m) | |
| 103 | 103 | { |
| 104 | 104 | u32 mask = get_mask(n); |
| 105 | 105 | |
| @@ -126,7 +126,7 @@ static inline void transp4(u32 d[], unsigned int n, unsigned int m) · 20 unmodified lines | ||
| 126 | 126 | * Transpose operations on 4 32-bit words (reverse order) |
| 127 | 127 | */ |
| 128 | 128 | |
| 129 | −static inline void transp4x(u32 d[], unsigned int n, unsigned int m) | |
| 129 | +static __always_inline void transp4x(u32 d[], unsigned int n, unsigned int m) | |
| 130 | 130 | { |
| 131 | 131 | u32 mask = get_mask(n); |
| 132 | 132 | |
| @@ -1499,9 +1499,6 @@ static bool virtqueue_enable_cb_delayed_packed(struct virtqueue *_vq) · 1498 unmodified lines | ||
| 1499 | 1499 | * counter first before updating event flags. |
| 1500 | 1500 | */ |
| 1501 | 1501 | virtio_wmb(vq->weak_barriers); |
| 1502 | − } else { | |
| 1503 | − used_idx = vq->last_used_idx; | |
| 1504 | − wrap_counter = vq->packed.used_wrap_counter; | |
| 1505 | 1502 | } |
| 1506 | 1503 | |
| 1507 | 1504 | if (vq->packed.event_flags_shadow == VRING_PACKED_EVENT_FLAG_DISABLE) { |
| @@ -1518,7 +1515,9 @@ static bool virtqueue_enable_cb_delayed_packed(struct virtqueue *_vq) · 10 unmodified lines | ||
| 1518 | 1515 | */ |
| 1519 | 1516 | virtio_mb(vq->weak_barriers); |
| 1520 | 1517 | |
| 1521 | − if (is_used_desc_packed(vq, used_idx, wrap_counter)) { | |
| 1518 | + if (is_used_desc_packed(vq, | |
| 1519 | + vq->last_used_idx, | |
| 1520 | + vq->packed.used_wrap_counter)) { | |
| 1522 | 1521 | END_USE(vq); |
| 1523 | 1522 | return false; |
| 1524 | 1523 | } |
| @@ -288,3 +288,4 @@ module_platform_driver(bd70528_wdt); · 287 unmodified lines | ||
| 288 | 288 | MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>"); |
| 289 | 289 | MODULE_DESCRIPTION("BD70528 watchdog driver"); |
| 290 | 290 | MODULE_LICENSE("GPL"); |
| 291 | +MODULE_ALIAS("platform:bd70528-wdt"); | |
| @@ -26,6 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | #include <linux/interrupt.h> |
| 27 | 27 | #include <linux/ioport.h> |
| 28 | 28 | #include <linux/timer.h> |
| 29 | +#include <linux/compat.h> | |
| 29 | 30 | #include <linux/slab.h> |
| 30 | 31 | #include <linux/mutex.h> |
| 31 | 32 | #include <linux/io.h> |
| @@ -473,6 +474,11 @@ static long cpwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 441 unmodified lines | ||
| 473 | 474 | return 0; |
| 474 | 475 | } |
| 475 | 476 | |
| 477 | +static long cpwd_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |
| 478 | +{ | |
| 479 | + return cpwd_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); | |
| 480 | +} | |
| 481 | + | |
| 476 | 482 | static ssize_t cpwd_write(struct file *file, const char __user *buf, |
| 477 | 483 | size_t count, loff_t *ppos) |
| 478 | 484 | { |
| @@ -497,7 +503,7 @@ static ssize_t cpwd_read(struct file *file, char __user *buffer, · 18 unmodified lines | ||
| 497 | 503 | static const struct file_operations cpwd_fops = { |
| 498 | 504 | .owner = THIS_MODULE, |
| 499 | 505 | .unlocked_ioctl = cpwd_ioctl, |
| 500 | − .compat_ioctl = compat_ptr_ioctl, | |
| 506 | + .compat_ioctl = cpwd_compat_ioctl, | |
| 501 | 507 | .open = cpwd_open, |
| 502 | 508 | .write = cpwd_write, |
| 503 | 509 | .read = cpwd_read, |
| @@ -99,8 +99,14 @@ static int imx_sc_wdt_set_pretimeout(struct watchdog_device *wdog, · 98 unmodified lines | ||
| 99 | 99 | { |
| 100 | 100 | struct arm_smccc_res res; |
| 101 | 101 | |
| 102 | + /* | |
| 103 | + * SCU firmware calculates pretimeout based on current time | |
| 104 | + * stamp instead of watchdog timeout stamp, need to convert | |
| 105 | + * the pretimeout to SCU firmware's timeout value. | |
| 106 | + */ | |
| 102 | 107 | arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_SET_PRETIME_WDOG, |
| 103 | − pretimeout * 1000, 0, 0, 0, 0, 0, &res); | |
| 108 | + (wdog->timeout - pretimeout) * 1000, 0, 0, 0, | |
| 109 | + 0, 0, &res); | |
| 104 | 110 | if (res.a0) |
| 105 | 111 | return -EACCES; |
| 106 | 112 | |
| @@ -89,8 +89,8 @@ static unsigned int meson_gxbb_wdt_get_timeleft(struct watchdog_device *wdt_dev) · 88 unmodified lines | ||
| 89 | 89 | |
| 90 | 90 | reg = readl(data->reg_base + GXBB_WDT_TCNT_REG); |
| 91 | 91 | |
| 92 | − return ((reg >> GXBB_WDT_TCNT_CNT_SHIFT) - | |
| 93 | − (reg & GXBB_WDT_TCNT_SETUP_MASK)) / 1000; | |
| 92 | + return ((reg & GXBB_WDT_TCNT_SETUP_MASK) - | |
| 93 | + (reg >> GXBB_WDT_TCNT_CNT_SHIFT)) / 1000; | |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | static const struct watchdog_ops meson_gxbb_wdt_ops = { |
| @@ -163,9 +163,17 @@ static int pm8916_wdt_probe(struct platform_device *pdev) · 162 unmodified lines | ||
| 163 | 163 | |
| 164 | 164 | irq = platform_get_irq(pdev, 0); |
| 165 | 165 | if (irq > 0) { |
| 166 | − if (devm_request_irq(dev, irq, pm8916_wdt_isr, 0, "pm8916_wdt", | |
| 167 | − wdt)) | |
| 168 | − irq = 0; | |
| 166 | + err = devm_request_irq(dev, irq, pm8916_wdt_isr, 0, | |
| 167 | + "pm8916_wdt", wdt); | |
| 168 | + if (err) | |
| 169 | + return err; | |
| 170 | + | |
| 171 | + wdt->wdev.info = &pm8916_wdt_pt_ident; | |
| 172 | + } else { | |
| 173 | + if (irq == -EPROBE_DEFER) | |
| 174 | + return -EPROBE_DEFER; | |
| 175 | + | |
| 176 | + wdt->wdev.info = &pm8916_wdt_ident; | |
| 169 | 177 | } |
| 170 | 178 | |
| 171 | 179 | /* Configure watchdog to hard-reset mode */ |
| @@ -177,7 +185,6 @@ static int pm8916_wdt_probe(struct platform_device *pdev) · 5 unmodified lines | ||
| 177 | 185 | return err; |
| 178 | 186 | } |
| 179 | 187 | |
| 180 | − wdt->wdev.info = (irq > 0) ? &pm8916_wdt_pt_ident : &pm8916_wdt_ident, | |
| 181 | 188 | wdt->wdev.ops = &pm8916_wdt_ops, |
| 182 | 189 | wdt->wdev.parent = dev; |
| 183 | 190 | wdt->wdev.min_timeout = PM8916_WDT_MIN_TIMEOUT; |
| @@ -474,6 +474,7 @@ static noinline int compress_file_range(struct async_chunk *async_chunk) · 473 unmodified lines | ||
| 474 | 474 | u64 start = async_chunk->start; |
| 475 | 475 | u64 end = async_chunk->end; |
| 476 | 476 | u64 actual_end; |
| 477 | + u64 i_size; | |
| 477 | 478 | int ret = 0; |
| 478 | 479 | struct page **pages = NULL; |
| 479 | 480 | unsigned long nr_pages; |
| @@ -488,7 +489,19 @@ static noinline int compress_file_range(struct async_chunk *async_chunk) · 8 unmodified lines | ||
| 488 | 489 | inode_should_defrag(BTRFS_I(inode), start, end, end - start + 1, |
| 489 | 490 | SZ_16K); |
| 490 | 491 | |
| 491 | − actual_end = min_t(u64, i_size_read(inode), end + 1); | |
| 492 | + /* | |
| 493 | + * We need to save i_size before now because it could change in between | |
| 494 | + * us evaluating the size and assigning it. This is because we lock and | |
| 495 | + * unlock the page in truncate and fallocate, and then modify the i_size | |
| 496 | + * later on. | |
| 497 | + * | |
| 498 | + * The barriers are to emulate READ_ONCE, remove that once i_size_read | |
| 499 | + * does that for us. | |
| 500 | + */ | |
| 501 | + barrier(); | |
| 502 | + i_size = i_size_read(inode); | |
| 503 | + barrier(); | |
| 504 | + actual_end = min_t(u64, i_size, end + 1); | |
| 492 | 505 | again: |
| 493 | 506 | will_compress = 0; |
| 494 | 507 | nr_pages = (end >> PAGE_SHIFT) - (start >> PAGE_SHIFT) + 1; |
| @@ -4195,9 +4195,6 @@ static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root, · 4194 unmodified lines | ||
| 4195 | 4195 | u64 transid; |
| 4196 | 4196 | int ret; |
| 4197 | 4197 | |
| 4198 | − btrfs_warn(root->fs_info, | |
| 4199 | − "START_SYNC ioctl is deprecated and will be removed in kernel 5.7"); | |
| 4200 | − | |
| 4201 | 4198 | trans = btrfs_attach_transaction_barrier(root); |
| 4202 | 4199 | if (IS_ERR(trans)) { |
| 4203 | 4200 | if (PTR_ERR(trans) != -ENOENT) |
| @@ -4225,9 +4222,6 @@ static noinline long btrfs_ioctl_wait_sync(struct btrfs_fs_info *fs_info, · 21 unmodified lines | ||
| 4225 | 4222 | { |
| 4226 | 4223 | u64 transid; |
| 4227 | 4224 | |
| 4228 | − btrfs_warn(fs_info, | |
| 4229 | − "WAIT_SYNC ioctl is deprecated and will be removed in kernel 5.7"); | |
| 4230 | − | |
| 4231 | 4225 | if (argp) { |
| 4232 | 4226 | if (copy_from_user(&transid, argp, sizeof(transid))) |
| 4233 | 4227 | return -EFAULT; |
| @@ -893,6 +893,15 @@ static void wait_reserve_ticket(struct btrfs_fs_info *fs_info, · 892 unmodified lines | ||
| 893 | 893 | while (ticket->bytes > 0 && ticket->error == 0) { |
| 894 | 894 | ret = prepare_to_wait_event(&ticket->wait, &wait, TASK_KILLABLE); |
| 895 | 895 | if (ret) { |
| 896 | + /* | |
| 897 | + * Delete us from the list. After we unlock the space | |
| 898 | + * info, we don't want the async reclaim job to reserve | |
| 899 | + * space for this ticket. If that would happen, then the | |
| 900 | + * ticket's task would not known that space was reserved | |
| 901 | + * despite getting an error, resulting in a space leak | |
| 902 | + * (bytes_may_use counter of our space_info). | |
| 903 | + */ | |
| 904 | + list_del_init(&ticket->list); | |
| 896 | 905 | ticket->error = -EINTR; |
| 897 | 906 | break; |
| 898 | 907 | } |
| @@ -945,12 +954,24 @@ static int handle_reserve_ticket(struct btrfs_fs_info *fs_info, · 46 unmodified lines | ||
| 945 | 954 | spin_lock(&space_info->lock); |
| 946 | 955 | ret = ticket->error; |
| 947 | 956 | if (ticket->bytes || ticket->error) { |
| 957 | + /* | |
| 958 | + * Need to delete here for priority tickets. For regular tickets | |
| 959 | + * either the async reclaim job deletes the ticket from the list | |
| 960 | + * or we delete it ourselves at wait_reserve_ticket(). | |
| 961 | + */ | |
| 948 | 962 | list_del_init(&ticket->list); |
| 949 | 963 | if (!ret) |
| 950 | 964 | ret = -ENOSPC; |
| 951 | 965 | } |
| 952 | 966 | spin_unlock(&space_info->lock); |
| 953 | 967 | ASSERT(list_empty(&ticket->list)); |
| 968 | + /* | |
| 969 | + * Check that we can't have an error set if the reservation succeeded, | |
| 970 | + * as that would confuse tasks and lead them to error out without | |
| 971 | + * releasing reserved space (if an error happens the expectation is that | |
| 972 | + * space wasn't reserved at all). | |
| 973 | + */ | |
| 974 | + ASSERT(!(ticket->bytes == 0 && ticket->error)); | |
| 954 | 975 | return ret; |
| 955 | 976 | } |
| 956 | 977 | |
| @@ -686,9 +686,7 @@ static void dev_item_err(const struct extent_buffer *eb, int slot, · 685 unmodified lines | ||
| 686 | 686 | static int check_dev_item(struct extent_buffer *leaf, |
| 687 | 687 | struct btrfs_key *key, int slot) |
| 688 | 688 | { |
| 689 | − struct btrfs_fs_info *fs_info = leaf->fs_info; | |
| 690 | 689 | struct btrfs_dev_item *ditem; |
| 691 | − u64 max_devid = max(BTRFS_MAX_DEVS(fs_info), BTRFS_MAX_DEVS_SYS_CHUNK); | |
| 692 | 690 | |
| 693 | 691 | if (key->objectid != BTRFS_DEV_ITEMS_OBJECTID) { |
| 694 | 692 | dev_item_err(leaf, slot, |
| @@ -696,12 +694,6 @@ static int check_dev_item(struct extent_buffer *leaf, · 1 unmodified line | ||
| 696 | 694 | key->objectid, BTRFS_DEV_ITEMS_OBJECTID); |
| 697 | 695 | return -EUCLEAN; |
| 698 | 696 | } |
| 699 | − if (key->offset > max_devid) { | |
| 700 | − dev_item_err(leaf, slot, | |
| 701 | − "invalid devid: has=%llu expect=[0, %llu]", | |
| 702 | − key->offset, max_devid); | |
| 703 | − return -EUCLEAN; | |
| 704 | − } | |
| 705 | 697 | ditem = btrfs_item_ptr(leaf, slot, struct btrfs_dev_item); |
| 706 | 698 | if (btrfs_device_id(leaf, ditem) != key->offset) { |
| 707 | 699 | dev_item_err(leaf, slot, |
| @@ -4967,6 +4967,7 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, · 4966 unmodified lines | ||
| 4967 | 4967 | } else if (type & BTRFS_BLOCK_GROUP_SYSTEM) { |
| 4968 | 4968 | max_stripe_size = SZ_32M; |
| 4969 | 4969 | max_chunk_size = 2 * max_stripe_size; |
| 4970 | + devs_max = min_t(int, devs_max, BTRFS_MAX_DEVS_SYS_CHUNK); | |
| 4970 | 4971 | } else { |
| 4971 | 4972 | btrfs_err(info, "invalid chunk type 0x%llx requested", |
| 4972 | 4973 | type); |
| @@ -1058,6 +1058,11 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release) · 1057 unmodified lines | ||
| 1058 | 1058 | |
| 1059 | 1059 | dout("__ceph_remove_cap %p from %p\n", cap, &ci->vfs_inode); |
| 1060 | 1060 | |
| 1061 | + /* remove from inode's cap rbtree, and clear auth cap */ | |
| 1062 | + rb_erase(&cap->ci_node, &ci->i_caps); | |
| 1063 | + if (ci->i_auth_cap == cap) | |
| 1064 | + ci->i_auth_cap = NULL; | |
| 1065 | + | |
| 1061 | 1066 | /* remove from session list */ |
| 1062 | 1067 | spin_lock(&session->s_cap_lock); |
| 1063 | 1068 | if (session->s_cap_iterator == cap) { |
| @@ -1091,11 +1096,6 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release) · 27 unmodified lines | ||
| 1091 | 1096 | |
| 1092 | 1097 | spin_unlock(&session->s_cap_lock); |
| 1093 | 1098 | |
| 1094 | − /* remove from inode list */ | |
| 1095 | − rb_erase(&cap->ci_node, &ci->i_caps); | |
| 1096 | − if (ci->i_auth_cap == cap) | |
| 1097 | − ci->i_auth_cap = NULL; | |
| 1098 | − | |
| 1099 | 1099 | if (removed) |
| 1100 | 1100 | ceph_put_cap(mdsc, cap); |
| 1101 | 1101 | |
| @@ -1553,36 +1553,37 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) · 1552 unmodified lines | ||
| 1553 | 1553 | { |
| 1554 | 1554 | int valid = 0; |
| 1555 | 1555 | struct dentry *parent; |
| 1556 | − struct inode *dir; | |
| 1556 | + struct inode *dir, *inode; | |
| 1557 | 1557 | |
| 1558 | 1558 | if (flags & LOOKUP_RCU) { |
| 1559 | 1559 | parent = READ_ONCE(dentry->d_parent); |
| 1560 | 1560 | dir = d_inode_rcu(parent); |
| 1561 | 1561 | if (!dir) |
| 1562 | 1562 | return -ECHILD; |
| 1563 | + inode = d_inode_rcu(dentry); | |
| 1563 | 1564 | } else { |
| 1564 | 1565 | parent = dget_parent(dentry); |
| 1565 | 1566 | dir = d_inode(parent); |
| 1567 | + inode = d_inode(dentry); | |
| 1566 | 1568 | } |
| 1567 | 1569 | |
| 1568 | 1570 | dout("d_revalidate %p '%pd' inode %p offset %lld\n", dentry, |
| 1569 | − dentry, d_inode(dentry), ceph_dentry(dentry)->offset); | |
| 1571 | + dentry, inode, ceph_dentry(dentry)->offset); | |
| 1570 | 1572 | |
| 1571 | 1573 | /* always trust cached snapped dentries, snapdir dentry */ |
| 1572 | 1574 | if (ceph_snap(dir) != CEPH_NOSNAP) { |
| 1573 | 1575 | dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry, |
| 1574 | − dentry, d_inode(dentry)); | |
| 1576 | + dentry, inode); | |
| 1575 | 1577 | valid = 1; |
| 1576 | − } else if (d_really_is_positive(dentry) && | |
| 1577 | − ceph_snap(d_inode(dentry)) == CEPH_SNAPDIR) { | |
| 1578 | + } else if (inode && ceph_snap(inode) == CEPH_SNAPDIR) { | |
| 1578 | 1579 | valid = 1; |
| 1579 | 1580 | } else { |
| 1580 | 1581 | valid = dentry_lease_is_valid(dentry, flags); |
| 1581 | 1582 | if (valid == -ECHILD) |
| 1582 | 1583 | return valid; |
| 1583 | 1584 | if (valid || dir_lease_is_valid(dir, dentry)) { |
| 1584 | − if (d_really_is_positive(dentry)) | |
| 1585 | − valid = ceph_is_any_caps(d_inode(dentry)); | |
| 1585 | + if (inode) | |
| 1586 | + valid = ceph_is_any_caps(inode); | |
| 1586 | 1587 | else |
| 1587 | 1588 | valid = 1; |
| 1588 | 1589 | } |
| @@ -462,6 +462,9 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, · 461 unmodified lines | ||
| 462 | 462 | err = ceph_security_init_secctx(dentry, mode, &as_ctx); |
| 463 | 463 | if (err < 0) |
| 464 | 464 | goto out_ctx; |
| 465 | + } else if (!d_in_lookup(dentry)) { | |
| 466 | + /* If it's not being looked up, it's negative */ | |
| 467 | + return -ENOENT; | |
| 465 | 468 | } |
| 466 | 469 | |
| 467 | 470 | /* do the open */ |
| @@ -1956,10 +1959,18 @@ static ssize_t __ceph_copy_file_range(struct file *src_file, loff_t src_off, · 1488 unmodified lines | ||
| 1956 | 1959 | if (ceph_test_mount_opt(src_fsc, NOCOPYFROM)) |
| 1957 | 1960 | return -EOPNOTSUPP; |
| 1958 | 1961 | |
| 1962 | + /* | |
| 1963 | + * Striped file layouts require that we copy partial objects, but the | |
| 1964 | + * OSD copy-from operation only supports full-object copies. Limit | |
| 1965 | + * this to non-striped file layouts for now. | |
| 1966 | + */ | |
| 1959 | 1967 | if ((src_ci->i_layout.stripe_unit != dst_ci->i_layout.stripe_unit) || |
| 1960 | − (src_ci->i_layout.stripe_count != dst_ci->i_layout.stripe_count) || | |
| 1961 | − (src_ci->i_layout.object_size != dst_ci->i_layout.object_size)) | |
| 1968 | + (src_ci->i_layout.stripe_count != 1) || | |
| 1969 | + (dst_ci->i_layout.stripe_count != 1) || | |
| 1970 | + (src_ci->i_layout.object_size != dst_ci->i_layout.object_size)) { | |
| 1971 | + dout("Invalid src/dst files layout\n"); | |
| 1962 | 1972 | return -EOPNOTSUPP; |
| 1973 | + } | |
| 1963 | 1974 | |
| 1964 | 1975 | if (len < src_ci->i_layout.object_size) |
| 1965 | 1976 | return -EOPNOTSUPP; /* no remote copy will be done */ |
| @@ -1434,6 +1434,7 @@ retry_lookup: · 1433 unmodified lines | ||
| 1434 | 1434 | dout(" final dn %p\n", dn); |
| 1435 | 1435 | } else if ((req->r_op == CEPH_MDS_OP_LOOKUPSNAP || |
| 1436 | 1436 | req->r_op == CEPH_MDS_OP_MKSNAP) && |
| 1437 | + test_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags) && | |
| 1437 | 1438 | !test_bit(CEPH_MDS_R_ABORTED, &req->r_req_flags)) { |
| 1438 | 1439 | struct inode *dir = req->r_parent; |
| 1439 | 1440 | |
| @@ -268,6 +268,7 @@ static int parse_fsopt_token(char *c, void *private) · 267 unmodified lines | ||
| 268 | 268 | } |
| 269 | 269 | break; |
| 270 | 270 | case Opt_fscache_uniq: |
| 271 | +#ifdef CONFIG_CEPH_FSCACHE | |
| 271 | 272 | kfree(fsopt->fscache_uniq); |
| 272 | 273 | fsopt->fscache_uniq = kstrndup(argstr[0].from, |
| 273 | 274 | argstr[0].to-argstr[0].from, |
| @@ -276,7 +277,10 @@ static int parse_fsopt_token(char *c, void *private) · 2 unmodified lines | ||
| 276 | 277 | return -ENOMEM; |
| 277 | 278 | fsopt->flags |= CEPH_MOUNT_OPT_FSCACHE; |
| 278 | 279 | break; |
| 279 | − /* misc */ | |
| 280 | +#else | |
| 281 | + pr_err("fscache support is disabled\n"); | |
| 282 | + return -EINVAL; | |
| 283 | +#endif | |
| 280 | 284 | case Opt_wsize: |
| 281 | 285 | if (intval < (int)PAGE_SIZE || intval > CEPH_MAX_WRITE_SIZE) |
| 282 | 286 | return -EINVAL; |
| @@ -353,10 +357,15 @@ static int parse_fsopt_token(char *c, void *private) · 70 unmodified lines | ||
| 353 | 357 | fsopt->flags &= ~CEPH_MOUNT_OPT_INO32; |
| 354 | 358 | break; |
| 355 | 359 | case Opt_fscache: |
| 360 | +#ifdef CONFIG_CEPH_FSCACHE | |
| 356 | 361 | fsopt->flags |= CEPH_MOUNT_OPT_FSCACHE; |
| 357 | 362 | kfree(fsopt->fscache_uniq); |
| 358 | 363 | fsopt->fscache_uniq = NULL; |
| 359 | 364 | break; |
| 365 | +#else | |
| 366 | + pr_err("fscache support is disabled\n"); | |
| 367 | + return -EINVAL; | |
| 368 | +#endif | |
| 360 | 369 | case Opt_nofscache: |
| 361 | 370 | fsopt->flags &= ~CEPH_MOUNT_OPT_FSCACHE; |
| 362 | 371 | kfree(fsopt->fscache_uniq); |
| @@ -4084,6 +4084,7 @@ free_pages: · 4083 unmodified lines | ||
| 4084 | 4084 | |
| 4085 | 4085 | kfree(dw->ppages); |
| 4086 | 4086 | cifs_small_buf_release(dw->buf); |
| 4087 | + kfree(dw); | |
| 4087 | 4088 | } |
| 4088 | 4089 | |
| 4089 | 4090 | |
| @@ -4157,7 +4158,7 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid, · 67 unmodified lines | ||
| 4157 | 4158 | dw->server = server; |
| 4158 | 4159 | dw->ppages = pages; |
| 4159 | 4160 | dw->len = len; |
| 4160 | − queue_work(cifsiod_wq, &dw->decrypt); | |
| 4161 | + queue_work(decrypt_wq, &dw->decrypt); | |
| 4161 | 4162 | *num_mids = 0; /* worker thread takes care of finding mid */ |
| 4162 | 4163 | return -1; |
| 4163 | 4164 | } |
| @@ -838,6 +838,7 @@ struct create_durable_handle_reconnect_v2 { · 837 unmodified lines | ||
| 838 | 838 | struct create_context ccontext; |
| 839 | 839 | __u8 Name[8]; |
| 840 | 840 | struct durable_reconnect_context_v2 dcontext; |
| 841 | + __u8 Pad[4]; | |
| 841 | 842 | } __packed; |
| 842 | 843 | |
| 843 | 844 | /* See MS-SMB2 2.2.13.2.5 */ |
| @@ -101,7 +101,7 @@ static int create_link(struct config_item *parent_item, · 100 unmodified lines | ||
| 101 | 101 | } |
| 102 | 102 | target_sd->s_links++; |
| 103 | 103 | spin_unlock(&configfs_dirent_lock); |
| 104 | − ret = configfs_get_target_path(item, item, body); | |
| 104 | + ret = configfs_get_target_path(parent_item, item, body); | |
| 105 | 105 | if (!ret) |
| 106 | 106 | ret = configfs_create_link(target_sd, parent_item->ci_dentry, |
| 107 | 107 | dentry, body); |
| @@ -576,10 +576,13 @@ void wbc_attach_and_unlock_inode(struct writeback_control *wbc, · 575 unmodified lines | ||
| 576 | 576 | spin_unlock(&inode->i_lock); |
| 577 | 577 | |
| 578 | 578 | /* |
| 579 | − * A dying wb indicates that the memcg-blkcg mapping has changed | |
| 580 | − * and a new wb is already serving the memcg. Switch immediately. | |
| 579 | + * A dying wb indicates that either the blkcg associated with the | |
| 580 | + * memcg changed or the associated memcg is dying. In the first | |
| 581 | + * case, a replacement wb should already be available and we should | |
| 582 | + * refresh the wb immediately. In the second case, trying to | |
| 583 | + * refresh will keep failing. | |
| 581 | 584 | */ |
| 582 | − if (unlikely(wb_dying(wbc->wb))) | |
| 585 | + if (unlikely(wb_dying(wbc->wb) && !css_is_dying(wbc->wb->memcg_css))) | |
| 583 | 586 | inode_switch_wbs(inode, wbc->wb_id); |
| 584 | 587 | } |
| 585 | 588 | EXPORT_SYMBOL_GPL(wbc_attach_and_unlock_inode); |
| @@ -5,6 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | |
| 6 | 6 | obj-$(CONFIG_FUSE_FS) += fuse.o |
| 7 | 7 | obj-$(CONFIG_CUSE) += cuse.o |
| 8 | −obj-$(CONFIG_VIRTIO_FS) += virtio_fs.o | |
| 8 | +obj-$(CONFIG_VIRTIO_FS) += virtiofs.o | |
| 9 | 9 | |
| 10 | 10 | fuse-objs := dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o |
| 11 | +virtiofs-y += virtio_fs.o | |
| @@ -276,10 +276,12 @@ static void flush_bg_queue(struct fuse_conn *fc) · 275 unmodified lines | ||
| 276 | 276 | void fuse_request_end(struct fuse_conn *fc, struct fuse_req *req) |
| 277 | 277 | { |
| 278 | 278 | struct fuse_iqueue *fiq = &fc->iq; |
| 279 | − bool async = req->args->end; | |
| 279 | + bool async; | |
| 280 | 280 | |
| 281 | 281 | if (test_and_set_bit(FR_FINISHED, &req->flags)) |
| 282 | 282 | goto put_request; |
| 283 | + | |
| 284 | + async = req->args->end; | |
| 283 | 285 | /* |
| 284 | 286 | * test_and_set_bit() implies smp_mb() between bit |
| 285 | 287 | * changing and below intr_entry check. Pairs with |
| @@ -405,7 +405,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, · 404 unmodified lines | ||
| 405 | 405 | else |
| 406 | 406 | fuse_invalidate_entry_cache(entry); |
| 407 | 407 | |
| 408 | − fuse_advise_use_readdirplus(dir); | |
| 408 | + if (inode) | |
| 409 | + fuse_advise_use_readdirplus(dir); | |
| 409 | 410 | return newent; |
| 410 | 411 | |
| 411 | 412 | out_iput: |
| @@ -1521,6 +1522,19 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr, · 1109 unmodified lines | ||
| 1521 | 1522 | is_truncate = true; |
| 1522 | 1523 | } |
| 1523 | 1524 | |
| 1525 | + /* Flush dirty data/metadata before non-truncate SETATTR */ | |
| 1526 | + if (is_wb && S_ISREG(inode->i_mode) && | |
| 1527 | + attr->ia_valid & | |
| 1528 | + (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_MTIME_SET | | |
| 1529 | + ATTR_TIMES_SET)) { | |
| 1530 | + err = write_inode_now(inode, true); | |
| 1531 | + if (err) | |
| 1532 | + return err; | |
| 1533 | + | |
| 1534 | + fuse_set_nowrite(inode); | |
| 1535 | + fuse_release_nowrite(inode); | |
| 1536 | + } | |
| 1537 | + | |
| 1524 | 1538 | if (is_truncate) { |
| 1525 | 1539 | fuse_set_nowrite(inode); |
| 1526 | 1540 | set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state); |
| @@ -217,7 +217,7 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir) · 216 unmodified lines | ||
| 217 | 217 | { |
| 218 | 218 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 219 | 219 | int err; |
| 220 | − bool lock_inode = (file->f_flags & O_TRUNC) && | |
| 220 | + bool is_wb_truncate = (file->f_flags & O_TRUNC) && | |
| 221 | 221 | fc->atomic_o_trunc && |
| 222 | 222 | fc->writeback_cache; |
| 223 | 223 | |
| @@ -225,16 +225,20 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir) · 1 unmodified line | ||
| 225 | 225 | if (err) |
| 226 | 226 | return err; |
| 227 | 227 | |
| 228 | − if (lock_inode) | |
| 228 | + if (is_wb_truncate) { | |
| 229 | 229 | inode_lock(inode); |
| 230 | + fuse_set_nowrite(inode); | |
| 231 | + } | |
| 230 | 232 | |
| 231 | 233 | err = fuse_do_open(fc, get_node_id(inode), file, isdir); |
| 232 | 234 | |
| 233 | 235 | if (!err) |
| 234 | 236 | fuse_finish_open(inode, file); |
| 235 | 237 | |
| 236 | − if (lock_inode) | |
| 238 | + if (is_wb_truncate) { | |
| 239 | + fuse_release_nowrite(inode); | |
| 237 | 240 | inode_unlock(inode); |
| 241 | + } | |
| 238 | 242 | |
| 239 | 243 | return err; |
| 240 | 244 | } |
| @@ -1997,7 +2001,7 @@ static int fuse_writepages_fill(struct page *page, · 1756 unmodified lines | ||
| 1997 | 2001 | |
| 1998 | 2002 | if (!data->ff) { |
| 1999 | 2003 | err = -EIO; |
| 2000 | − data->ff = fuse_write_file_get(fc, get_fuse_inode(inode)); | |
| 2004 | + data->ff = fuse_write_file_get(fc, fi); | |
| 2001 | 2005 | if (!data->ff) |
| 2002 | 2006 | goto out_unlock; |
| 2003 | 2007 | } |
| @@ -2042,8 +2046,6 @@ static int fuse_writepages_fill(struct page *page, · 38 unmodified lines | ||
| 2042 | 2046 | * under writeback, so we can release the page lock. |
| 2043 | 2047 | */ |
| 2044 | 2048 | if (data->wpa == NULL) { |
| 2045 | − struct fuse_inode *fi = get_fuse_inode(inode); | |
| 2046 | − | |
| 2047 | 2049 | err = -ENOMEM; |
| 2048 | 2050 | wpa = fuse_writepage_args_alloc(); |
| 2049 | 2051 | if (!wpa) { |
| @@ -479,6 +479,7 @@ struct fuse_fs_context { · 478 unmodified lines | ||
| 479 | 479 | bool destroy:1; |
| 480 | 480 | bool no_control:1; |
| 481 | 481 | bool no_force_umount:1; |
| 482 | + bool no_mount_options:1; | |
| 482 | 483 | unsigned int max_read; |
| 483 | 484 | unsigned int blksize; |
| 484 | 485 | const char *subtype; |
| @@ -713,6 +714,9 @@ struct fuse_conn { · 228 unmodified lines | ||
| 713 | 714 | /** Do not allow MNT_FORCE umount */ |
| 714 | 715 | unsigned int no_force_umount:1; |
| 715 | 716 | |
| 717 | + /* Do not show mount options */ | |
| 718 | + unsigned int no_mount_options:1; | |
| 719 | + | |
| 716 | 720 | /** The number of requests waiting for completion */ |
| 717 | 721 | atomic_t num_waiting; |
| 718 | 722 | |
| @@ -558,6 +558,9 @@ static int fuse_show_options(struct seq_file *m, struct dentry *root) · 557 unmodified lines | ||
| 558 | 558 | struct super_block *sb = root->d_sb; |
| 559 | 559 | struct fuse_conn *fc = get_fuse_conn_super(sb); |
| 560 | 560 | |
| 561 | + if (fc->no_mount_options) | |
| 562 | + return 0; | |
| 563 | + | |
| 561 | 564 | seq_printf(m, ",user_id=%u", from_kuid_munged(fc->user_ns, fc->user_id)); |
| 562 | 565 | seq_printf(m, ",group_id=%u", from_kgid_munged(fc->user_ns, fc->group_id)); |
| 563 | 566 | if (fc->default_permissions) |
| @@ -1180,6 +1183,7 @@ int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx) · 616 unmodified lines | ||
| 1180 | 1183 | fc->destroy = ctx->destroy; |
| 1181 | 1184 | fc->no_control = ctx->no_control; |
| 1182 | 1185 | fc->no_force_umount = ctx->no_force_umount; |
| 1186 | + fc->no_mount_options = ctx->no_mount_options; | |
| 1183 | 1187 | |
| 1184 | 1188 | err = -ENOMEM; |
| 1185 | 1189 | root = fuse_get_root_inode(sb, ctx->rootmode); |
| @@ -30,6 +30,7 @@ struct virtio_fs_vq { · 29 unmodified lines | ||
| 30 | 30 | struct virtqueue *vq; /* protected by ->lock */ |
| 31 | 31 | struct work_struct done_work; |
| 32 | 32 | struct list_head queued_reqs; |
| 33 | + struct list_head end_reqs; /* End these requests */ | |
| 33 | 34 | struct delayed_work dispatch_work; |
| 34 | 35 | struct fuse_dev *fud; |
| 35 | 36 | bool connected; |
| @@ -54,6 +55,9 @@ struct virtio_fs_forget { · 18 unmodified lines | ||
| 54 | 55 | struct list_head list; |
| 55 | 56 | }; |
| 56 | 57 | |
| 58 | +static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq, | |
| 59 | + struct fuse_req *req, bool in_flight); | |
| 60 | + | |
| 57 | 61 | static inline struct virtio_fs_vq *vq_to_fsvq(struct virtqueue *vq) |
| 58 | 62 | { |
| 59 | 63 | struct virtio_fs *fs = vq->vdev->priv; |
| @@ -66,6 +70,19 @@ static inline struct fuse_pqueue *vq_to_fpq(struct virtqueue *vq) · 6 unmodified lines | ||
| 66 | 70 | return &vq_to_fsvq(vq)->fud->pq; |
| 67 | 71 | } |
| 68 | 72 | |
| 73 | +/* Should be called with fsvq->lock held. */ | |
| 74 | +static inline void inc_in_flight_req(struct virtio_fs_vq *fsvq) | |
| 75 | +{ | |
| 76 | + fsvq->in_flight++; | |
| 77 | +} | |
| 78 | + | |
| 79 | +/* Should be called with fsvq->lock held. */ | |
| 80 | +static inline void dec_in_flight_req(struct virtio_fs_vq *fsvq) | |
| 81 | +{ | |
| 82 | + WARN_ON(fsvq->in_flight <= 0); | |
| 83 | + fsvq->in_flight--; | |
| 84 | +} | |
| 85 | + | |
| 69 | 86 | static void release_virtio_fs_obj(struct kref *ref) |
| 70 | 87 | { |
| 71 | 88 | struct virtio_fs *vfs = container_of(ref, struct virtio_fs, refcount); |
| @@ -109,22 +126,6 @@ static void virtio_fs_drain_queue(struct virtio_fs_vq *fsvq) · 37 unmodified lines | ||
| 109 | 126 | flush_delayed_work(&fsvq->dispatch_work); |
| 110 | 127 | } |
| 111 | 128 | |
| 112 | −static inline void drain_hiprio_queued_reqs(struct virtio_fs_vq *fsvq) | |
| 113 | −{ | |
| 114 | − struct virtio_fs_forget *forget; | |
| 115 | − | |
| 116 | − spin_lock(&fsvq->lock); | |
| 117 | − while (1) { | |
| 118 | − forget = list_first_entry_or_null(&fsvq->queued_reqs, | |
| 119 | − struct virtio_fs_forget, list); | |
| 120 | − if (!forget) | |
| 121 | − break; | |
| 122 | − list_del(&forget->list); | |
| 123 | − kfree(forget); | |
| 124 | − } | |
| 125 | − spin_unlock(&fsvq->lock); | |
| 126 | −} | |
| 127 | − | |
| 128 | 129 | static void virtio_fs_drain_all_queues(struct virtio_fs *fs) |
| 129 | 130 | { |
| 130 | 131 | struct virtio_fs_vq *fsvq; |
| @@ -132,9 +133,6 @@ static void virtio_fs_drain_all_queues(struct virtio_fs *fs) · 1 unmodified line | ||
| 132 | 133 | |
| 133 | 134 | for (i = 0; i < fs->nvqs; i++) { |
| 134 | 135 | fsvq = &fs->vqs[i]; |
| 135 | − if (i == VQ_HIPRIO) | |
| 136 | − drain_hiprio_queued_reqs(fsvq); | |
| 137 | − | |
| 138 | 136 | virtio_fs_drain_queue(fsvq); |
| 139 | 137 | } |
| 140 | 138 | } |
| @@ -253,14 +251,66 @@ static void virtio_fs_hiprio_done_work(struct work_struct *work) · 112 unmodified lines | ||
| 253 | 251 | |
| 254 | 252 | while ((req = virtqueue_get_buf(vq, &len)) != NULL) { |
| 255 | 253 | kfree(req); |
| 256 | − fsvq->in_flight--; | |
| 254 | + dec_in_flight_req(fsvq); | |
| 257 | 255 | } |
| 258 | 256 | } while (!virtqueue_enable_cb(vq) && likely(!virtqueue_is_broken(vq))); |
| 259 | 257 | spin_unlock(&fsvq->lock); |
| 260 | 258 | } |
| 261 | 259 | |
| 262 | −static void virtio_fs_dummy_dispatch_work(struct work_struct *work) | |
| 260 | +static void virtio_fs_request_dispatch_work(struct work_struct *work) | |
| 263 | 261 | { |
| 262 | + struct fuse_req *req; | |
| 263 | + struct virtio_fs_vq *fsvq = container_of(work, struct virtio_fs_vq, | |
| 264 | + dispatch_work.work); | |
| 265 | + struct fuse_conn *fc = fsvq->fud->fc; | |
| 266 | + int ret; | |
| 267 | + | |
| 268 | + pr_debug("virtio-fs: worker %s called.\n", __func__); | |
| 269 | + while (1) { | |
| 270 | + spin_lock(&fsvq->lock); | |
| 271 | + req = list_first_entry_or_null(&fsvq->end_reqs, struct fuse_req, | |
| 272 | + list); | |
| 273 | + if (!req) { | |
| 274 | + spin_unlock(&fsvq->lock); | |
| 275 | + break; | |
| 276 | + } | |
| 277 | + | |
| 278 | + list_del_init(&req->list); | |
| 279 | + spin_unlock(&fsvq->lock); | |
| 280 | + fuse_request_end(fc, req); | |
| 281 | + } | |
| 282 | + | |
| 283 | + /* Dispatch pending requests */ | |
| 284 | + while (1) { | |
| 285 | + spin_lock(&fsvq->lock); | |
| 286 | + req = list_first_entry_or_null(&fsvq->queued_reqs, | |
| 287 | + struct fuse_req, list); | |
| 288 | + if (!req) { | |
| 289 | + spin_unlock(&fsvq->lock); | |
| 290 | + return; | |
| 291 | + } | |
| 292 | + list_del_init(&req->list); | |
| 293 | + spin_unlock(&fsvq->lock); | |
| 294 | + | |
| 295 | + ret = virtio_fs_enqueue_req(fsvq, req, true); | |
| 296 | + if (ret < 0) { | |
| 297 | + if (ret == -ENOMEM || ret == -ENOSPC) { | |
| 298 | + spin_lock(&fsvq->lock); | |
| 299 | + list_add_tail(&req->list, &fsvq->queued_reqs); | |
| 300 | + schedule_delayed_work(&fsvq->dispatch_work, | |
| 301 | + msecs_to_jiffies(1)); | |
| 302 | + spin_unlock(&fsvq->lock); | |
| 303 | + return; | |
| 304 | + } | |
| 305 | + req->out.h.error = ret; | |
| 306 | + spin_lock(&fsvq->lock); | |
| 307 | + dec_in_flight_req(fsvq); | |
| 308 | + spin_unlock(&fsvq->lock); | |
| 309 | + pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n", | |
| 310 | + ret); | |
| 311 | + fuse_request_end(fc, req); | |
| 312 | + } | |
| 313 | + } | |
| 264 | 314 | } |
| 265 | 315 | |
| 266 | 316 | static void virtio_fs_hiprio_dispatch_work(struct work_struct *work) |
| @@ -286,6 +336,7 @@ static void virtio_fs_hiprio_dispatch_work(struct work_struct *work) · 19 unmodified lines | ||
| 286 | 336 | |
| 287 | 337 | list_del(&forget->list); |
| 288 | 338 | if (!fsvq->connected) { |
| 339 | + dec_in_flight_req(fsvq); | |
| 289 | 340 | spin_unlock(&fsvq->lock); |
| 290 | 341 | kfree(forget); |
| 291 | 342 | continue; |
| @@ -307,13 +358,13 @@ static void virtio_fs_hiprio_dispatch_work(struct work_struct *work) · 15 unmodified lines | ||
| 307 | 358 | } else { |
| 308 | 359 | pr_debug("virtio-fs: Could not queue FORGET: err=%d. Dropping it.\n", |
| 309 | 360 | ret); |
| 361 | + dec_in_flight_req(fsvq); | |
| 310 | 362 | kfree(forget); |
| 311 | 363 | } |
| 312 | 364 | spin_unlock(&fsvq->lock); |
| 313 | 365 | return; |
| 314 | 366 | } |
| 315 | 367 | |
| 316 | − fsvq->in_flight++; | |
| 317 | 368 | notify = virtqueue_kick_prepare(vq); |
| 318 | 369 | spin_unlock(&fsvq->lock); |
| 319 | 370 | |
| @@ -452,7 +503,7 @@ static void virtio_fs_requests_done_work(struct work_struct *work) · 132 unmodified lines | ||
| 452 | 503 | |
| 453 | 504 | fuse_request_end(fc, req); |
| 454 | 505 | spin_lock(&fsvq->lock); |
| 455 | − fsvq->in_flight--; | |
| 506 | + dec_in_flight_req(fsvq); | |
| 456 | 507 | spin_unlock(&fsvq->lock); |
| 457 | 508 | } |
| 458 | 509 | } |
| @@ -502,6 +553,7 @@ static int virtio_fs_setup_vqs(struct virtio_device *vdev, · 43 unmodified lines | ||
| 502 | 553 | names[VQ_HIPRIO] = fs->vqs[VQ_HIPRIO].name; |
| 503 | 554 | INIT_WORK(&fs->vqs[VQ_HIPRIO].done_work, virtio_fs_hiprio_done_work); |
| 504 | 555 | INIT_LIST_HEAD(&fs->vqs[VQ_HIPRIO].queued_reqs); |
| 556 | + INIT_LIST_HEAD(&fs->vqs[VQ_HIPRIO].end_reqs); | |
| 505 | 557 | INIT_DELAYED_WORK(&fs->vqs[VQ_HIPRIO].dispatch_work, |
| 506 | 558 | virtio_fs_hiprio_dispatch_work); |
| 507 | 559 | spin_lock_init(&fs->vqs[VQ_HIPRIO].lock); |
| @@ -511,8 +563,9 @@ static int virtio_fs_setup_vqs(struct virtio_device *vdev, · 3 unmodified lines | ||
| 511 | 563 | spin_lock_init(&fs->vqs[i].lock); |
| 512 | 564 | INIT_WORK(&fs->vqs[i].done_work, virtio_fs_requests_done_work); |
| 513 | 565 | INIT_DELAYED_WORK(&fs->vqs[i].dispatch_work, |
| 514 | − virtio_fs_dummy_dispatch_work); | |
| 566 | + virtio_fs_request_dispatch_work); | |
| 515 | 567 | INIT_LIST_HEAD(&fs->vqs[i].queued_reqs); |
| 568 | + INIT_LIST_HEAD(&fs->vqs[i].end_reqs); | |
| 516 | 569 | snprintf(fs->vqs[i].name, sizeof(fs->vqs[i].name), |
| 517 | 570 | "requests.%u", i - VQ_REQUEST); |
| 518 | 571 | callbacks[i] = virtio_fs_vq_done; |
| @@ -708,6 +761,7 @@ __releases(fiq->lock) · 189 unmodified lines | ||
| 708 | 761 | list_add_tail(&forget->list, &fsvq->queued_reqs); |
| 709 | 762 | schedule_delayed_work(&fsvq->dispatch_work, |
| 710 | 763 | msecs_to_jiffies(1)); |
| 764 | + inc_in_flight_req(fsvq); | |
| 711 | 765 | } else { |
| 712 | 766 | pr_debug("virtio-fs: Could not queue FORGET: err=%d. Dropping it.\n", |
| 713 | 767 | ret); |
| @@ -717,7 +771,7 @@ __releases(fiq->lock) · 3 unmodified lines | ||
| 717 | 771 | goto out; |
| 718 | 772 | } |
| 719 | 773 | |
| 720 | − fsvq->in_flight++; | |
| 774 | + inc_in_flight_req(fsvq); | |
| 721 | 775 | notify = virtqueue_kick_prepare(vq); |
| 722 | 776 | |
| 723 | 777 | spin_unlock(&fsvq->lock); |
| @@ -819,7 +873,7 @@ static unsigned int sg_init_fuse_args(struct scatterlist *sg, · 95 unmodified lines | ||
| 819 | 873 | |
| 820 | 874 | /* Add a request to a virtqueue and kick the device */ |
| 821 | 875 | static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq, |
| 822 | − struct fuse_req *req) | |
| 876 | + struct fuse_req *req, bool in_flight) | |
| 823 | 877 | { |
| 824 | 878 | /* requests need at least 4 elements */ |
| 825 | 879 | struct scatterlist *stack_sgs[6]; |
| @@ -835,6 +889,7 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq, · 9 unmodified lines | ||
| 835 | 889 | unsigned int i; |
| 836 | 890 | int ret; |
| 837 | 891 | bool notify; |
| 892 | + struct fuse_pqueue *fpq; | |
| 838 | 893 | |
| 839 | 894 | /* Does the sglist fit on the stack? */ |
| 840 | 895 | total_sgs = sg_count_fuse_req(req); |
| @@ -889,7 +944,17 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq, · 48 unmodified lines | ||
| 889 | 944 | goto out; |
| 890 | 945 | } |
| 891 | 946 | |
| 892 | − fsvq->in_flight++; | |
| 947 | + /* Request successfully sent. */ | |
| 948 | + fpq = &fsvq->fud->pq; | |
| 949 | + spin_lock(&fpq->lock); | |
| 950 | + list_add_tail(&req->list, fpq->processing); | |
| 951 | + spin_unlock(&fpq->lock); | |
| 952 | + set_bit(FR_SENT, &req->flags); | |
| 953 | + /* matches barrier in request_wait_answer() */ | |
| 954 | + smp_mb__after_atomic(); | |
| 955 | + | |
| 956 | + if (!in_flight) | |
| 957 | + inc_in_flight_req(fsvq); | |
| 893 | 958 | notify = virtqueue_kick_prepare(vq); |
| 894 | 959 | |
| 895 | 960 | spin_unlock(&fsvq->lock); |
| @@ -915,9 +980,8 @@ __releases(fiq->lock) · 19 unmodified lines | ||
| 915 | 980 | { |
| 916 | 981 | unsigned int queue_id = VQ_REQUEST; /* TODO multiqueue */ |
| 917 | 982 | struct virtio_fs *fs; |
| 918 | − struct fuse_conn *fc; | |
| 919 | 983 | struct fuse_req *req; |
| 920 | − struct fuse_pqueue *fpq; | |
| 984 | + struct virtio_fs_vq *fsvq; | |
| 921 | 985 | int ret; |
| 922 | 986 | |
| 923 | 987 | WARN_ON(list_empty(&fiq->pending)); |
| @@ -928,44 +992,36 @@ __releases(fiq->lock) · 4 unmodified lines | ||
| 928 | 992 | spin_unlock(&fiq->lock); |
| 929 | 993 | |
| 930 | 994 | fs = fiq->priv; |
| 931 | − fc = fs->vqs[queue_id].fud->fc; | |
| 932 | 995 | |
| 933 | 996 | pr_debug("%s: opcode %u unique %#llx nodeid %#llx in.len %u out.len %u\n", |
| 934 | 997 | __func__, req->in.h.opcode, req->in.h.unique, |
| 935 | 998 | req->in.h.nodeid, req->in.h.len, |
| 936 | 999 | fuse_len_args(req->args->out_numargs, req->args->out_args)); |
| 937 | 1000 | |
| 938 | − fpq = &fs->vqs[queue_id].fud->pq; | |
| 939 | − spin_lock(&fpq->lock); | |
| 940 | − if (!fpq->connected) { | |
| 941 | − spin_unlock(&fpq->lock); | |
| 942 | − req->out.h.error = -ENODEV; | |
| 943 | − pr_err("virtio-fs: %s disconnected\n", __func__); | |
| 944 | − fuse_request_end(fc, req); | |
| 945 | − return; | |
| 946 | − } | |
| 947 | − list_add_tail(&req->list, fpq->processing); | |
| 948 | − spin_unlock(&fpq->lock); | |
| 949 | − set_bit(FR_SENT, &req->flags); | |
| 950 | − /* matches barrier in request_wait_answer() */ | |
| 951 | − smp_mb__after_atomic(); | |
| 952 | − | |
| 953 | −retry: | |
| 954 | − ret = virtio_fs_enqueue_req(&fs->vqs[queue_id], req); | |
| 1001 | + fsvq = &fs->vqs[queue_id]; | |
| 1002 | + ret = virtio_fs_enqueue_req(fsvq, req, false); | |
| 955 | 1003 | if (ret < 0) { |
| 956 | 1004 | if (ret == -ENOMEM || ret == -ENOSPC) { |
| 957 | − /* Virtqueue full. Retry submission */ | |
| 958 | − /* TODO use completion instead of timeout */ | |
| 959 | − usleep_range(20, 30); | |
| 960 | − goto retry; | |
| 1005 | + /* | |
| 1006 | + * Virtqueue full. Retry submission from worker | |
| 1007 | + * context as we might be holding fc->bg_lock. | |
| 1008 | + */ | |
| 1009 | + spin_lock(&fsvq->lock); | |
| 1010 | + list_add_tail(&req->list, &fsvq->queued_reqs); | |
| 1011 | + inc_in_flight_req(fsvq); | |
| 1012 | + schedule_delayed_work(&fsvq->dispatch_work, | |
| 1013 | + msecs_to_jiffies(1)); | |
| 1014 | + spin_unlock(&fsvq->lock); | |
| 1015 | + return; | |
| 961 | 1016 | } |
| 962 | 1017 | req->out.h.error = ret; |
| 963 | 1018 | pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n", ret); |
| 964 | − spin_lock(&fpq->lock); | |
| 965 | − clear_bit(FR_SENT, &req->flags); | |
| 966 | − list_del_init(&req->list); | |
| 967 | − spin_unlock(&fpq->lock); | |
| 968 | − fuse_request_end(fc, req); | |
| 1019 | + | |
| 1020 | + /* Can't end request in submission context. Use a worker */ | |
| 1021 | + spin_lock(&fsvq->lock); | |
| 1022 | + list_add_tail(&req->list, &fsvq->end_reqs); | |
| 1023 | + schedule_delayed_work(&fsvq->dispatch_work, 0); | |
| 1024 | + spin_unlock(&fsvq->lock); | |
| 969 | 1025 | return; |
| 970 | 1026 | } |
| 971 | 1027 | } |
| @@ -992,6 +1048,7 @@ static int virtio_fs_fill_super(struct super_block *sb) · 20 unmodified lines | ||
| 992 | 1048 | .destroy = true, |
| 993 | 1049 | .no_control = true, |
| 994 | 1050 | .no_force_umount = true, |
| 1051 | + .no_mount_options = true, | |
| 995 | 1052 | }; |
| 996 | 1053 | |
| 997 | 1054 | mutex_lock(&virtio_fs_mutex); |
| @@ -1540,17 +1540,23 @@ static int gfs2_init_fs_context(struct fs_context *fc) · 1539 unmodified lines | ||
| 1540 | 1540 | { |
| 1541 | 1541 | struct gfs2_args *args; |
| 1542 | 1542 | |
| 1543 | − args = kzalloc(sizeof(*args), GFP_KERNEL); | |
| 1543 | + args = kmalloc(sizeof(*args), GFP_KERNEL); | |
| 1544 | 1544 | if (args == NULL) |
| 1545 | 1545 | return -ENOMEM; |
| 1546 | 1546 | |
| 1547 | − args->ar_quota = GFS2_QUOTA_DEFAULT; | |
| 1548 | − args->ar_data = GFS2_DATA_DEFAULT; | |
| 1549 | − args->ar_commit = 30; | |
| 1550 | − args->ar_statfs_quantum = 30; | |
| 1551 | − args->ar_quota_quantum = 60; | |
| 1552 | − args->ar_errors = GFS2_ERRORS_DEFAULT; | |
| 1547 | + if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) { | |
| 1548 | + struct gfs2_sbd *sdp = fc->root->d_sb->s_fs_info; | |
| 1553 | 1549 | |
| 1550 | + *args = sdp->sd_args; | |
| 1551 | + } else { | |
| 1552 | + memset(args, 0, sizeof(*args)); | |
| 1553 | + args->ar_quota = GFS2_QUOTA_DEFAULT; | |
| 1554 | + args->ar_data = GFS2_DATA_DEFAULT; | |
| 1555 | + args->ar_commit = 30; | |
| 1556 | + args->ar_statfs_quantum = 30; | |
| 1557 | + args->ar_quota_quantum = 60; | |
| 1558 | + args->ar_errors = GFS2_ERRORS_DEFAULT; | |
| 1559 | + } | |
| 1554 | 1560 | fc->fs_private = args; |
| 1555 | 1561 | fc->ops = &gfs2_context_ops; |
| 1556 | 1562 | return 0; |
| @@ -1124,6 +1124,7 @@ static int io_prep_rw(struct io_kiocb *req, const struct sqe_submit *s, · 1123 unmodified lines | ||
| 1124 | 1124 | |
| 1125 | 1125 | kiocb->ki_flags |= IOCB_HIPRI; |
| 1126 | 1126 | kiocb->ki_complete = io_complete_rw_iopoll; |
| 1127 | + req->result = 0; | |
| 1127 | 1128 | } else { |
| 1128 | 1129 | if (kiocb->ki_flags & IOCB_HIPRI) |
| 1129 | 1130 | return -EINVAL; |
| @@ -2413,6 +2414,7 @@ static int io_queue_link_head(struct io_ring_ctx *ctx, struct io_kiocb *req, · 1283 unmodified lines | ||
| 2413 | 2414 | if (ret) { |
| 2414 | 2415 | if (ret != -EIOCBQUEUED) { |
| 2415 | 2416 | io_free_req(req); |
| 2417 | + __io_free_req(shadow); | |
| 2416 | 2418 | io_cqring_add_event(ctx, s->sqe->user_data, ret); |
| 2417 | 2419 | return 0; |
| 2418 | 2420 | } |
| @@ -3828,10 +3830,6 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p) · 1409 unmodified lines | ||
| 3828 | 3830 | if (ret) |
| 3829 | 3831 | goto err; |
| 3830 | 3832 | |
| 3831 | − ret = io_uring_get_fd(ctx); | |
| 3832 | − if (ret < 0) | |
| 3833 | − goto err; | |
| 3834 | − | |
| 3835 | 3833 | memset(&p->sq_off, 0, sizeof(p->sq_off)); |
| 3836 | 3834 | p->sq_off.head = offsetof(struct io_rings, sq.head); |
| 3837 | 3835 | p->sq_off.tail = offsetof(struct io_rings, sq.tail); |
| @@ -3849,6 +3847,14 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p) · 11 unmodified lines | ||
| 3849 | 3847 | p->cq_off.overflow = offsetof(struct io_rings, cq_overflow); |
| 3850 | 3848 | p->cq_off.cqes = offsetof(struct io_rings, cqes); |
| 3851 | 3849 | |
| 3850 | + /* | |
| 3851 | + * Install ring fd as the very last thing, so we don't risk someone | |
| 3852 | + * having closed it before we finish setup | |
| 3853 | + */ | |
| 3854 | + ret = io_uring_get_fd(ctx); | |
| 3855 | + if (ret < 0) | |
| 3856 | + goto err; | |
| 3857 | + | |
| 3852 | 3858 | p->features = IORING_FEAT_SINGLE_MMAP; |
| 3853 | 3859 | return ret; |
| 3854 | 3860 | err: |
| @@ -53,6 +53,16 @@ nfs4_is_valid_delegation(const struct nfs_delegation *delegation, · 52 unmodified lines | ||
| 53 | 53 | return false; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | +struct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode) | |
| 57 | +{ | |
| 58 | + struct nfs_delegation *delegation; | |
| 59 | + | |
| 60 | + delegation = rcu_dereference(NFS_I(inode)->delegation); | |
| 61 | + if (nfs4_is_valid_delegation(delegation, 0)) | |
| 62 | + return delegation; | |
| 63 | + return NULL; | |
| 64 | +} | |
| 65 | + | |
| 56 | 66 | static int |
| 57 | 67 | nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark) |
| 58 | 68 | { |
| @@ -1181,7 +1191,7 @@ bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode) · 1122 unmodified lines | ||
| 1181 | 1191 | if (delegation != NULL && |
| 1182 | 1192 | nfs4_stateid_match_other(dst, &delegation->stateid)) { |
| 1183 | 1193 | dst->seqid = delegation->stateid.seqid; |
| 1184 | − return ret; | |
| 1194 | + ret = true; | |
| 1185 | 1195 | } |
| 1186 | 1196 | rcu_read_unlock(); |
| 1187 | 1197 | out: |
| @@ -68,6 +68,7 @@ int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, · 67 unmodified lines | ||
| 68 | 68 | bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, nfs4_stateid *dst, const struct cred **cred); |
| 69 | 69 | bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode); |
| 70 | 70 | |
| 71 | +struct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode); | |
| 71 | 72 | void nfs_mark_delegation_referenced(struct nfs_delegation *delegation); |
| 72 | 73 | int nfs4_have_delegation(struct inode *inode, fmode_t flags); |
| 73 | 74 | int nfs4_check_delegation(struct inode *inode, fmode_t flags); |
| @@ -1440,8 +1440,6 @@ static int can_open_delegated(struct nfs_delegation *delegation, fmode_t fmode, · 1439 unmodified lines | ||
| 1440 | 1440 | return 0; |
| 1441 | 1441 | if ((delegation->type & fmode) != fmode) |
| 1442 | 1442 | return 0; |
| 1443 | − if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) | |
| 1444 | − return 0; | |
| 1445 | 1443 | switch (claim) { |
| 1446 | 1444 | case NFS4_OPEN_CLAIM_NULL: |
| 1447 | 1445 | case NFS4_OPEN_CLAIM_FH: |
| @@ -1810,7 +1808,6 @@ static void nfs4_return_incompatible_delegation(struct inode *inode, fmode_t fmo · 362 unmodified lines | ||
| 1810 | 1808 | static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) |
| 1811 | 1809 | { |
| 1812 | 1810 | struct nfs4_state *state = opendata->state; |
| 1813 | − struct nfs_inode *nfsi = NFS_I(state->inode); | |
| 1814 | 1811 | struct nfs_delegation *delegation; |
| 1815 | 1812 | int open_mode = opendata->o_arg.open_flags; |
| 1816 | 1813 | fmode_t fmode = opendata->o_arg.fmode; |
| @@ -1827,7 +1824,7 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) · 10 unmodified lines | ||
| 1827 | 1824 | } |
| 1828 | 1825 | spin_unlock(&state->owner->so_lock); |
| 1829 | 1826 | rcu_read_lock(); |
| 1830 | − delegation = rcu_dereference(nfsi->delegation); | |
| 1827 | + delegation = nfs4_get_valid_delegation(state->inode); | |
| 1831 | 1828 | if (!can_open_delegated(delegation, fmode, claim)) { |
| 1832 | 1829 | rcu_read_unlock(); |
| 1833 | 1830 | break; |
| @@ -2371,7 +2368,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata) · 537 unmodified lines | ||
| 2371 | 2368 | data->o_arg.open_flags, claim)) |
| 2372 | 2369 | goto out_no_action; |
| 2373 | 2370 | rcu_read_lock(); |
| 2374 | − delegation = rcu_dereference(NFS_I(data->state->inode)->delegation); | |
| 2371 | + delegation = nfs4_get_valid_delegation(data->state->inode); | |
| 2375 | 2372 | if (can_open_delegated(delegation, data->o_arg.fmode, claim)) |
| 2376 | 2373 | goto unlock_no_action; |
| 2377 | 2374 | rcu_read_unlock(); |
| @@ -2098,53 +2098,89 @@ static int ocfs2_is_io_unaligned(struct inode *inode, size_t count, loff_t pos) · 2097 unmodified lines | ||
| 2098 | 2098 | return 0; |
| 2099 | 2099 | } |
| 2100 | 2100 | |
| 2101 | −static int ocfs2_prepare_inode_for_refcount(struct inode *inode, | |
| 2102 | − struct file *file, | |
| 2103 | − loff_t pos, size_t count, | |
| 2104 | − int *meta_level) | |
| 2101 | +static int ocfs2_inode_lock_for_extent_tree(struct inode *inode, | |
| 2102 | + struct buffer_head **di_bh, | |
| 2103 | + int meta_level, | |
| 2104 | + int overwrite_io, | |
| 2105 | + int write_sem, | |
| 2106 | + int wait) | |
| 2105 | 2107 | { |
| 2106 | − int ret; | |
| 2107 | − struct buffer_head *di_bh = NULL; | |
| 2108 | − u32 cpos = pos >> OCFS2_SB(inode->i_sb)->s_clustersize_bits; | |
| 2109 | − u32 clusters = | |
| 2110 | − ocfs2_clusters_for_bytes(inode->i_sb, pos + count) - cpos; | |
| 2108 | + int ret = 0; | |
| 2111 | 2109 | |
| 2112 | − ret = ocfs2_inode_lock(inode, &di_bh, 1); | |
| 2113 | − if (ret) { | |
| 2114 | − mlog_errno(ret); | |
| 2110 | + if (wait) | |
| 2111 | + ret = ocfs2_inode_lock(inode, NULL, meta_level); | |
| 2112 | + else | |
| 2113 | + ret = ocfs2_try_inode_lock(inode, | |
| 2114 | + overwrite_io ? NULL : di_bh, meta_level); | |
| 2115 | + if (ret < 0) | |
| 2115 | 2116 | goto out; |
| 2117 | + | |
| 2118 | + if (wait) { | |
| 2119 | + if (write_sem) | |
| 2120 | + down_write(&OCFS2_I(inode)->ip_alloc_sem); | |
| 2121 | + else | |
| 2122 | + down_read(&OCFS2_I(inode)->ip_alloc_sem); | |
| 2123 | + } else { | |
| 2124 | + if (write_sem) | |
| 2125 | + ret = down_write_trylock(&OCFS2_I(inode)->ip_alloc_sem); | |
| 2126 | + else | |
| 2127 | + ret = down_read_trylock(&OCFS2_I(inode)->ip_alloc_sem); | |
| 2128 | + | |
| 2129 | + if (!ret) { | |
| 2130 | + ret = -EAGAIN; | |
| 2131 | + goto out_unlock; | |
| 2132 | + } | |
| 2116 | 2133 | } |
| 2117 | 2134 | |
| 2118 | − *meta_level = 1; | |
| 2135 | + return ret; | |
| 2119 | 2136 | |
| 2120 | − ret = ocfs2_refcount_cow(inode, di_bh, cpos, clusters, UINT_MAX); | |
| 2121 | − if (ret) | |
| 2122 | − mlog_errno(ret); | |
| 2137 | +out_unlock: | |
| 2138 | + brelse(*di_bh); | |
| 2139 | + ocfs2_inode_unlock(inode, meta_level); | |
| 2123 | 2140 | out: |
| 2124 | − brelse(di_bh); | |
| 2125 | 2141 | return ret; |
| 2126 | 2142 | } |
| 2127 | 2143 | |
| 2144 | +static void ocfs2_inode_unlock_for_extent_tree(struct inode *inode, | |
| 2145 | + struct buffer_head **di_bh, | |
| 2146 | + int meta_level, | |
| 2147 | + int write_sem) | |
| 2148 | +{ | |
| 2149 | + if (write_sem) | |
| 2150 | + up_write(&OCFS2_I(inode)->ip_alloc_sem); | |
| 2151 | + else | |
| 2152 | + up_read(&OCFS2_I(inode)->ip_alloc_sem); | |
| 2153 | + | |
| 2154 | + brelse(*di_bh); | |
| 2155 | + *di_bh = NULL; | |
| 2156 | + | |
| 2157 | + if (meta_level >= 0) | |
| 2158 | + ocfs2_inode_unlock(inode, meta_level); | |
| 2159 | +} | |
| 2160 | + | |
| 2128 | 2161 | static int ocfs2_prepare_inode_for_write(struct file *file, |
| 2129 | 2162 | loff_t pos, size_t count, int wait) |
| 2130 | 2163 | { |
| 2131 | 2164 | int ret = 0, meta_level = 0, overwrite_io = 0; |
| 2165 | + int write_sem = 0; | |
| 2132 | 2166 | struct dentry *dentry = file->f_path.dentry; |
| 2133 | 2167 | struct inode *inode = d_inode(dentry); |
| 2134 | 2168 | struct buffer_head *di_bh = NULL; |
| 2169 | + u32 cpos; | |
| 2170 | + u32 clusters; | |
| 2135 | 2171 | |
| 2136 | 2172 | /* |
| 2137 | 2173 | * We start with a read level meta lock and only jump to an ex |
| 2138 | 2174 | * if we need to make modifications here. |
| 2139 | 2175 | */ |
| 2140 | 2176 | for(;;) { |
| 2141 | − if (wait) | |
| 2142 | − ret = ocfs2_inode_lock(inode, NULL, meta_level); | |
| 2143 | − else | |
| 2144 | − ret = ocfs2_try_inode_lock(inode, | |
| 2145 | − overwrite_io ? NULL : &di_bh, meta_level); | |
| 2177 | + ret = ocfs2_inode_lock_for_extent_tree(inode, | |
| 2178 | + &di_bh, | |
| 2179 | + meta_level, | |
| 2180 | + overwrite_io, | |
| 2181 | + write_sem, | |
| 2182 | + wait); | |
| 2146 | 2183 | if (ret < 0) { |
| 2147 | − meta_level = -1; | |
| 2148 | 2184 | if (ret != -EAGAIN) |
| 2149 | 2185 | mlog_errno(ret); |
| 2150 | 2186 | goto out; |
| @@ -2156,15 +2192,8 @@ static int ocfs2_prepare_inode_for_write(struct file *file, · 5 unmodified lines | ||
| 2156 | 2192 | */ |
| 2157 | 2193 | if (!wait && !overwrite_io) { |
| 2158 | 2194 | overwrite_io = 1; |
| 2159 | − if (!down_read_trylock(&OCFS2_I(inode)->ip_alloc_sem)) { | |
| 2160 | − ret = -EAGAIN; | |
| 2161 | − goto out_unlock; | |
| 2162 | − } | |
| 2163 | 2195 | |
| 2164 | 2196 | ret = ocfs2_overwrite_io(inode, di_bh, pos, count); |
| 2165 | − brelse(di_bh); | |
| 2166 | − di_bh = NULL; | |
| 2167 | − up_read(&OCFS2_I(inode)->ip_alloc_sem); | |
| 2168 | 2197 | if (ret < 0) { |
| 2169 | 2198 | if (ret != -EAGAIN) |
| 2170 | 2199 | mlog_errno(ret); |
| @@ -2183,7 +2212,10 @@ static int ocfs2_prepare_inode_for_write(struct file *file, · 12 unmodified lines | ||
| 2183 | 2212 | * set inode->i_size at the end of a write. */ |
| 2184 | 2213 | if (should_remove_suid(dentry)) { |
| 2185 | 2214 | if (meta_level == 0) { |
| 2186 | − ocfs2_inode_unlock(inode, meta_level); | |
| 2215 | + ocfs2_inode_unlock_for_extent_tree(inode, | |
| 2216 | + &di_bh, | |
| 2217 | + meta_level, | |
| 2218 | + write_sem); | |
| 2187 | 2219 | meta_level = 1; |
| 2188 | 2220 | continue; |
| 2189 | 2221 | } |
| @@ -2197,18 +2229,32 @@ static int ocfs2_prepare_inode_for_write(struct file *file, · 7 unmodified lines | ||
| 2197 | 2229 | |
| 2198 | 2230 | ret = ocfs2_check_range_for_refcount(inode, pos, count); |
| 2199 | 2231 | if (ret == 1) { |
| 2200 | − ocfs2_inode_unlock(inode, meta_level); | |
| 2201 | − meta_level = -1; | |
| 2202 | − | |
| 2203 | − ret = ocfs2_prepare_inode_for_refcount(inode, | |
| 2204 | − file, | |
| 2205 | − pos, | |
| 2206 | − count, | |
| 2207 | − &meta_level); | |
| 2232 | + ocfs2_inode_unlock_for_extent_tree(inode, | |
| 2233 | + &di_bh, | |
| 2234 | + meta_level, | |
| 2235 | + write_sem); | |
| 2236 | + ret = ocfs2_inode_lock_for_extent_tree(inode, | |
| 2237 | + &di_bh, | |
| 2238 | + meta_level, | |
| 2239 | + overwrite_io, | |
| 2240 | + 1, | |
| 2241 | + wait); | |
| 2242 | + write_sem = 1; | |
| 2243 | + if (ret < 0) { | |
| 2244 | + if (ret != -EAGAIN) | |
| 2245 | + mlog_errno(ret); | |
| 2246 | + goto out; | |
| 2247 | + } | |
| 2248 | + | |
| 2249 | + cpos = pos >> OCFS2_SB(inode->i_sb)->s_clustersize_bits; | |
| 2250 | + clusters = | |
| 2251 | + ocfs2_clusters_for_bytes(inode->i_sb, pos + count) - cpos; | |
| 2252 | + ret = ocfs2_refcount_cow(inode, di_bh, cpos, clusters, UINT_MAX); | |
| 2208 | 2253 | } |
| 2209 | 2254 | |
| 2210 | 2255 | if (ret < 0) { |
| 2211 | − mlog_errno(ret); | |
| 2256 | + if (ret != -EAGAIN) | |
| 2257 | + mlog_errno(ret); | |
| 2212 | 2258 | goto out_unlock; |
| 2213 | 2259 | } |
| 2214 | 2260 | |
| @@ -2219,10 +2265,10 @@ out_unlock: · 4 unmodified lines | ||
| 2219 | 2265 | trace_ocfs2_prepare_inode_for_write(OCFS2_I(inode)->ip_blkno, |
| 2220 | 2266 | pos, count, wait); |
| 2221 | 2267 | |
| 2222 | − brelse(di_bh); | |
| 2223 | − | |
| 2224 | − if (meta_level >= 0) | |
| 2225 | − ocfs2_inode_unlock(inode, meta_level); | |
| 2268 | + ocfs2_inode_unlock_for_extent_tree(inode, | |
| 2269 | + &di_bh, | |
| 2270 | + meta_level, | |
| 2271 | + write_sem); | |
| 2226 | 2272 | |
| 2227 | 2273 | out: |
| 2228 | 2274 | return ret; |
| @@ -25,13 +25,6 @@ static __always_inline int __arch_get_clock_mode(struct timekeeper *tk) · 24 unmodified lines | ||
| 25 | 25 | } |
| 26 | 26 | #endif /* __arch_get_clock_mode */ |
| 27 | 27 | |
| 28 | −#ifndef __arch_use_vsyscall | |
| 29 | −static __always_inline int __arch_use_vsyscall(struct vdso_data *vdata) | |
| 30 | −{ | |
| 31 | − return 1; | |
| 32 | −} | |
| 33 | −#endif /* __arch_use_vsyscall */ | |
| 34 | − | |
| 35 | 28 | #ifndef __arch_update_vsyscall |
| 36 | 29 | static __always_inline void __arch_update_vsyscall(struct vdso_data *vdata, |
| 37 | 30 | struct timekeeper *tk) |
| @@ -44,7 +44,20 @@ struct drm_gem_shmem_object { · 43 unmodified lines | ||
| 44 | 44 | */ |
| 45 | 45 | unsigned int pages_use_count; |
| 46 | 46 | |
| 47 | + /** | |
| 48 | + * @madv: State for madvise | |
| 49 | + * | |
| 50 | + * 0 is active/inuse. | |
| 51 | + * A negative value is the object is purged. | |
| 52 | + * Positive values are driver specific and not used by the helpers. | |
| 53 | + */ | |
| 47 | 54 | int madv; |
| 55 | + | |
| 56 | + /** | |
| 57 | + * @madv_list: List entry for madvise tracking | |
| 58 | + * | |
| 59 | + * Typically used by drivers to track purgeable objects | |
| 60 | + */ | |
| 48 | 61 | struct list_head madv_list; |
| 49 | 62 | |
| 50 | 63 | /** |
| @@ -13,7 +13,8 @@ struct drm_crtc; · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | void drm_self_refresh_helper_alter_state(struct drm_atomic_state *state); |
| 15 | 15 | void drm_self_refresh_helper_update_avg_times(struct drm_atomic_state *state, |
| 16 | − unsigned int commit_time_ms); | |
| 16 | + unsigned int commit_time_ms, | |
| 17 | + unsigned int new_self_refresh_mask); | |
| 17 | 18 | |
| 18 | 19 | int drm_self_refresh_helper_init(struct drm_crtc *crtc); |
| 19 | 20 | void drm_self_refresh_helper_cleanup(struct drm_crtc *crtc); |
| @@ -656,11 +656,11 @@ void bpf_map_put_with_uref(struct bpf_map *map); · 655 unmodified lines | ||
| 656 | 656 | void bpf_map_put(struct bpf_map *map); |
| 657 | 657 | int bpf_map_charge_memlock(struct bpf_map *map, u32 pages); |
| 658 | 658 | void bpf_map_uncharge_memlock(struct bpf_map *map, u32 pages); |
| 659 | −int bpf_map_charge_init(struct bpf_map_memory *mem, size_t size); | |
| 659 | +int bpf_map_charge_init(struct bpf_map_memory *mem, u64 size); | |
| 660 | 660 | void bpf_map_charge_finish(struct bpf_map_memory *mem); |
| 661 | 661 | void bpf_map_charge_move(struct bpf_map_memory *dst, |
| 662 | 662 | struct bpf_map_memory *src); |
| 663 | −void *bpf_map_area_alloc(size_t size, int numa_node); | |
| 663 | +void *bpf_map_area_alloc(u64 size, int numa_node); | |
| 664 | 664 | void bpf_map_area_free(void *base); |
| 665 | 665 | void bpf_map_init_from_attr(struct bpf_map *map, union bpf_attr *attr); |
| 666 | 666 | |
| @@ -204,6 +204,12 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, · 203 unmodified lines | ||
| 204 | 204 | do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0) |
| 205 | 205 | #define dynamic_dev_dbg(dev, fmt, ...) \ |
| 206 | 206 | do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0) |
| 207 | +#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ | |
| 208 | + groupsize, buf, len, ascii) \ | |
| 209 | + do { if (0) \ | |
| 210 | + print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, \ | |
| 211 | + rowsize, groupsize, buf, len, ascii); \ | |
| 212 | + } while (0) | |
| 207 | 213 | #endif |
| 208 | 214 | |
| 209 | 215 | #endif |
| @@ -1579,9 +1579,22 @@ char *efi_convert_cmdline(efi_system_table_t *sys_table_arg, · 1578 unmodified lines | ||
| 1579 | 1579 | efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, |
| 1580 | 1580 | struct efi_boot_memmap *map); |
| 1581 | 1581 | |
| 1582 | +efi_status_t efi_low_alloc_above(efi_system_table_t *sys_table_arg, | |
| 1583 | + unsigned long size, unsigned long align, | |
| 1584 | + unsigned long *addr, unsigned long min); | |
| 1585 | + | |
| 1586 | +static inline | |
| 1582 | 1587 | efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, |
| 1583 | 1588 | unsigned long size, unsigned long align, |
| 1584 | − unsigned long *addr); | |
| 1589 | + unsigned long *addr) | |
| 1590 | +{ | |
| 1591 | + /* | |
| 1592 | + * Don't allocate at 0x0. It will confuse code that | |
| 1593 | + * checks pointers against NULL. Skip the first 8 | |
| 1594 | + * bytes so we start at a nice even number. | |
| 1595 | + */ | |
| 1596 | + return efi_low_alloc_above(sys_table_arg, size, align, addr, 0x8); | |
| 1597 | +} | |
| 1585 | 1598 | |
| 1586 | 1599 | efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg, |
| 1587 | 1600 | unsigned long size, unsigned long align, |
| @@ -1592,7 +1605,8 @@ efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg, · 4 unmodified lines | ||
| 1592 | 1605 | unsigned long image_size, |
| 1593 | 1606 | unsigned long alloc_size, |
| 1594 | 1607 | unsigned long preferred_addr, |
| 1595 | − unsigned long alignment); | |
| 1608 | + unsigned long alignment, | |
| 1609 | + unsigned long min_addr); | |
| 1596 | 1610 | |
| 1597 | 1611 | efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, |
| 1598 | 1612 | efi_loaded_image_t *image, |
| @@ -1099,7 +1099,6 @@ static inline void bpf_get_prog_name(const struct bpf_prog *prog, char *sym) · 1098 unmodified lines | ||
| 1099 | 1099 | |
| 1100 | 1100 | #endif /* CONFIG_BPF_JIT */ |
| 1101 | 1101 | |
| 1102 | −void bpf_prog_kallsyms_del_subprogs(struct bpf_prog *fp); | |
| 1103 | 1102 | void bpf_prog_kallsyms_del_all(struct bpf_prog *fp); |
| 1104 | 1103 | |
| 1105 | 1104 | #define BPF_ANC BIT(15) |
| @@ -325,6 +325,29 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) · 324 unmodified lines | ||
| 325 | 325 | return !!(gfp_flags & __GFP_DIRECT_RECLAIM); |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | +/** | |
| 329 | + * gfpflags_normal_context - is gfp_flags a normal sleepable context? | |
| 330 | + * @gfp_flags: gfp_flags to test | |
| 331 | + * | |
| 332 | + * Test whether @gfp_flags indicates that the allocation is from the | |
| 333 | + * %current context and allowed to sleep. | |
| 334 | + * | |
| 335 | + * An allocation being allowed to block doesn't mean it owns the %current | |
| 336 | + * context. When direct reclaim path tries to allocate memory, the | |
| 337 | + * allocation context is nested inside whatever %current was doing at the | |
| 338 | + * time of the original allocation. The nested allocation may be allowed | |
| 339 | + * to block but modifying anything %current owns can corrupt the outer | |
| 340 | + * context's expectations. | |
| 341 | + * | |
| 342 | + * %true result from this function indicates that the allocation context | |
| 343 | + * can sleep and use anything that's associated with %current. | |
| 344 | + */ | |
| 345 | +static inline bool gfpflags_normal_context(const gfp_t gfp_flags) | |
| 346 | +{ | |
| 347 | + return (gfp_flags & (__GFP_DIRECT_RECLAIM | __GFP_MEMALLOC)) == | |
| 348 | + __GFP_DIRECT_RECLAIM; | |
| 349 | +} | |
| 350 | + | |
| 328 | 351 | #ifdef CONFIG_HIGHMEM |
| 329 | 352 | #define OPT_ZONE_HIGHMEM ZONE_HIGHMEM |
| 330 | 353 | #else |
| @@ -185,7 +185,7 @@ static inline void idr_preload_end(void) · 184 unmodified lines | ||
| 185 | 185 | * is convenient for a "not found" value. |
| 186 | 186 | */ |
| 187 | 187 | #define idr_for_each_entry(idr, entry, id) \ |
| 188 | − for (id = 0; ((entry) = idr_get_next(idr, &(id))) != NULL; ++id) | |
| 188 | + for (id = 0; ((entry) = idr_get_next(idr, &(id))) != NULL; id += 1U) | |
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | 191 | * idr_for_each_entry_ul() - Iterate over an IDR's elements of a given type. |
| @@ -29,7 +29,6 @@ struct macvlan_dev { · 28 unmodified lines | ||
| 29 | 29 | netdev_features_t set_features; |
| 30 | 30 | enum macvlan_mode mode; |
| 31 | 31 | u16 flags; |
| 32 | − int nest_level; | |
| 33 | 32 | unsigned int macaddr_count; |
| 34 | 33 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 35 | 34 | struct netpoll *netpoll; |
| @@ -223,6 +223,7 @@ struct team { · 222 unmodified lines | ||
| 223 | 223 | atomic_t count_pending; |
| 224 | 224 | struct delayed_work dw; |
| 225 | 225 | } mcast_rejoin; |
| 226 | + struct lock_class_key team_lock_key; | |
| 226 | 227 | long mode_priv[TEAM_MODE_PRIV_LONGS]; |
| 227 | 228 | }; |
| 228 | 229 | |
| @@ -182,7 +182,6 @@ struct vlan_dev_priv { · 181 unmodified lines | ||
| 182 | 182 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 183 | 183 | struct netpoll *netpoll; |
| 184 | 184 | #endif |
| 185 | − unsigned int nest_level; | |
| 186 | 185 | }; |
| 187 | 186 | |
| 188 | 187 | static inline struct vlan_dev_priv *vlan_dev_priv(const struct net_device *dev) |
| @@ -221,11 +220,6 @@ extern void vlan_vids_del_by_dev(struct net_device *dev, · 32 unmodified lines | ||
| 221 | 220 | |
| 222 | 221 | extern bool vlan_uses_dev(const struct net_device *dev); |
| 223 | 222 | |
| 224 | −static inline int vlan_get_encap_level(struct net_device *dev) | |
| 225 | −{ | |
| 226 | − BUG_ON(!is_vlan_dev(dev)); | |
| 227 | − return vlan_dev_priv(dev)->nest_level; | |
| 228 | −} | |
| 229 | 223 | #else |
| 230 | 224 | static inline struct net_device * |
| 231 | 225 | __vlan_find_dev_deep_rcu(struct net_device *real_dev, |
| @@ -295,11 +289,6 @@ static inline bool vlan_uses_dev(const struct net_device *dev) · 63 unmodified lines | ||
| 295 | 289 | { |
| 296 | 290 | return false; |
| 297 | 291 | } |
| 298 | −static inline int vlan_get_encap_level(struct net_device *dev) | |
| 299 | −{ | |
| 300 | − BUG(); | |
| 301 | − return 0; | |
| 302 | −} | |
| 303 | 292 | #endif |
| 304 | 293 | |
| 305 | 294 | /** |
| @@ -1545,9 +1545,8 @@ struct mlx5_ifc_extended_dest_format_bits { · 1544 unmodified lines | ||
| 1545 | 1545 | }; |
| 1546 | 1546 | |
| 1547 | 1547 | union mlx5_ifc_dest_format_struct_flow_counter_list_auto_bits { |
| 1548 | − struct mlx5_ifc_dest_format_struct_bits dest_format_struct; | |
| 1548 | + struct mlx5_ifc_extended_dest_format_bits extended_dest_format; | |
| 1549 | 1549 | struct mlx5_ifc_flow_counter_list_bits flow_counter_list; |
| 1550 | − u8 reserved_at_0[0x40]; | |
| 1551 | 1550 | }; |
| 1552 | 1551 | |
| 1553 | 1552 | struct mlx5_ifc_fte_match_param_bits { |
| @@ -695,11 +695,6 @@ static inline void *kvcalloc(size_t n, size_t size, gfp_t flags) · 694 unmodified lines | ||
| 695 | 695 | |
| 696 | 696 | extern void kvfree(const void *addr); |
| 697 | 697 | |
| 698 | −static inline atomic_t *compound_mapcount_ptr(struct page *page) | |
| 699 | −{ | |
| 700 | − return &page[1].compound_mapcount; | |
| 701 | −} | |
| 702 | − | |
| 703 | 698 | static inline int compound_mapcount(struct page *page) |
| 704 | 699 | { |
| 705 | 700 | VM_BUG_ON_PAGE(!PageCompound(page), page); |
| @@ -221,6 +221,11 @@ struct page { · 220 unmodified lines | ||
| 221 | 221 | #endif |
| 222 | 222 | } _struct_page_alignment; |
| 223 | 223 | |
| 224 | +static inline atomic_t *compound_mapcount_ptr(struct page *page) | |
| 225 | +{ | |
| 226 | + return &page[1].compound_mapcount; | |
| 227 | +} | |
| 228 | + | |
| 224 | 229 | /* |
| 225 | 230 | * Used for sizing the vmemmap region on some architectures |
| 226 | 231 | */ |
| @@ -925,6 +925,7 @@ struct dev_ifalias { · 924 unmodified lines | ||
| 925 | 925 | struct devlink; |
| 926 | 926 | struct tlsdev_ops; |
| 927 | 927 | |
| 928 | + | |
| 928 | 929 | /* |
| 929 | 930 | * This structure defines the management hooks for network devices. |
| 930 | 931 | * The following hooks can be defined; unless noted otherwise, they are |
| @@ -1421,7 +1422,6 @@ struct net_device_ops { · 490 unmodified lines | ||
| 1421 | 1422 | void (*ndo_dfwd_del_station)(struct net_device *pdev, |
| 1422 | 1423 | void *priv); |
| 1423 | 1424 | |
| 1424 | − int (*ndo_get_lock_subclass)(struct net_device *dev); | |
| 1425 | 1425 | int (*ndo_set_tx_maxrate)(struct net_device *dev, |
| 1426 | 1426 | int queue_index, |
| 1427 | 1427 | u32 maxrate); |
| @@ -1649,6 +1649,8 @@ enum netdev_priv_flags { · 221 unmodified lines | ||
| 1649 | 1649 | * @perm_addr: Permanent hw address |
| 1650 | 1650 | * @addr_assign_type: Hw address assignment type |
| 1651 | 1651 | * @addr_len: Hardware address length |
| 1652 | + * @upper_level: Maximum depth level of upper devices. | |
| 1653 | + * @lower_level: Maximum depth level of lower devices. | |
| 1652 | 1654 | * @neigh_priv_len: Used in neigh_alloc() |
| 1653 | 1655 | * @dev_id: Used to differentiate devices that share |
| 1654 | 1656 | * the same link layer address |
| @@ -1758,9 +1760,13 @@ enum netdev_priv_flags { · 103 unmodified lines | ||
| 1758 | 1760 | * @phydev: Physical device may attach itself |
| 1759 | 1761 | * for hardware timestamping |
| 1760 | 1762 | * @sfp_bus: attached &struct sfp_bus structure. |
| 1761 | − * | |
| 1762 | − * @qdisc_tx_busylock: lockdep class annotating Qdisc->busylock spinlock | |
| 1763 | − * @qdisc_running_key: lockdep class annotating Qdisc->running seqcount | |
| 1763 | + * @qdisc_tx_busylock_key: lockdep class annotating Qdisc->busylock | |
| 1764 | + spinlock | |
| 1765 | + * @qdisc_running_key: lockdep class annotating Qdisc->running seqcount | |
| 1766 | + * @qdisc_xmit_lock_key: lockdep class annotating | |
| 1767 | + * netdev_queue->_xmit_lock spinlock | |
| 1768 | + * @addr_list_lock_key: lockdep class annotating | |
| 1769 | + * net_device->addr_list_lock spinlock | |
| 1764 | 1770 | * |
| 1765 | 1771 | * @proto_down: protocol port state information can be sent to the |
| 1766 | 1772 | * switch driver and used to set the phys state of the |
| @@ -1875,6 +1881,8 @@ struct net_device { · 108 unmodified lines | ||
| 1875 | 1881 | unsigned char perm_addr[MAX_ADDR_LEN]; |
| 1876 | 1882 | unsigned char addr_assign_type; |
| 1877 | 1883 | unsigned char addr_len; |
| 1884 | + unsigned char upper_level; | |
| 1885 | + unsigned char lower_level; | |
| 1878 | 1886 | unsigned short neigh_priv_len; |
| 1879 | 1887 | unsigned short dev_id; |
| 1880 | 1888 | unsigned short dev_port; |
| @@ -2045,8 +2053,10 @@ struct net_device { · 164 unmodified lines | ||
| 2045 | 2053 | #endif |
| 2046 | 2054 | struct phy_device *phydev; |
| 2047 | 2055 | struct sfp_bus *sfp_bus; |
| 2048 | − struct lock_class_key *qdisc_tx_busylock; | |
| 2049 | − struct lock_class_key *qdisc_running_key; | |
| 2056 | + struct lock_class_key qdisc_tx_busylock_key; | |
| 2057 | + struct lock_class_key qdisc_running_key; | |
| 2058 | + struct lock_class_key qdisc_xmit_lock_key; | |
| 2059 | + struct lock_class_key addr_list_lock_key; | |
| 2050 | 2060 | bool proto_down; |
| 2051 | 2061 | unsigned wol_enabled:1; |
| 2052 | 2062 | }; |
| @@ -2124,23 +2134,6 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev, · 71 unmodified lines | ||
| 2124 | 2134 | f(dev, &dev->_tx[i], arg); |
| 2125 | 2135 | } |
| 2126 | 2136 | |
| 2127 | −#define netdev_lockdep_set_classes(dev) \ | |
| 2128 | −{ \ | |
| 2129 | − static struct lock_class_key qdisc_tx_busylock_key; \ | |
| 2130 | − static struct lock_class_key qdisc_running_key; \ | |
| 2131 | − static struct lock_class_key qdisc_xmit_lock_key; \ | |
| 2132 | − static struct lock_class_key dev_addr_list_lock_key; \ | |
| 2133 | − unsigned int i; \ | |
| 2134 | − \ | |
| 2135 | − (dev)->qdisc_tx_busylock = &qdisc_tx_busylock_key; \ | |
| 2136 | − (dev)->qdisc_running_key = &qdisc_running_key; \ | |
| 2137 | − lockdep_set_class(&(dev)->addr_list_lock, \ | |
| 2138 | − &dev_addr_list_lock_key); \ | |
| 2139 | − for (i = 0; i < (dev)->num_tx_queues; i++) \ | |
| 2140 | − lockdep_set_class(&(dev)->_tx[i]._xmit_lock, \ | |
| 2141 | − &qdisc_xmit_lock_key); \ | |
| 2142 | −} | |
| 2143 | − | |
| 2144 | 2137 | u16 netdev_pick_tx(struct net_device *dev, struct sk_buff *skb, |
| 2145 | 2138 | struct net_device *sb_dev); |
| 2146 | 2139 | struct netdev_queue *netdev_core_pick_tx(struct net_device *dev, |
| @@ -3139,6 +3132,7 @@ static inline void netif_stop_queue(struct net_device *dev) · 992 unmodified lines | ||
| 3139 | 3132 | } |
| 3140 | 3133 | |
| 3141 | 3134 | void netif_tx_stop_all_queues(struct net_device *dev); |
| 3135 | +void netdev_update_lockdep_key(struct net_device *dev); | |
| 3142 | 3136 | |
| 3143 | 3137 | static inline bool netif_tx_queue_stopped(const struct netdev_queue *dev_queue) |
| 3144 | 3138 | { |
| @@ -4056,16 +4050,6 @@ static inline void netif_addr_lock(struct net_device *dev) · 911 unmodified lines | ||
| 4056 | 4050 | spin_lock(&dev->addr_list_lock); |
| 4057 | 4051 | } |
| 4058 | 4052 | |
| 4059 | −static inline void netif_addr_lock_nested(struct net_device *dev) | |
| 4060 | −{ | |
| 4061 | − int subclass = SINGLE_DEPTH_NESTING; | |
| 4062 | − | |
| 4063 | − if (dev->netdev_ops->ndo_get_lock_subclass) | |
| 4064 | − subclass = dev->netdev_ops->ndo_get_lock_subclass(dev); | |
| 4065 | − | |
| 4066 | − spin_lock_nested(&dev->addr_list_lock, subclass); | |
| 4067 | −} | |
| 4068 | − | |
| 4069 | 4053 | static inline void netif_addr_lock_bh(struct net_device *dev) |
| 4070 | 4054 | { |
| 4071 | 4055 | spin_lock_bh(&dev->addr_list_lock); |
| @@ -4329,6 +4313,16 @@ int netdev_master_upper_dev_link(struct net_device *dev, · 257 unmodified lines | ||
| 4329 | 4313 | struct netlink_ext_ack *extack); |
| 4330 | 4314 | void netdev_upper_dev_unlink(struct net_device *dev, |
| 4331 | 4315 | struct net_device *upper_dev); |
| 4316 | +int netdev_adjacent_change_prepare(struct net_device *old_dev, | |
| 4317 | + struct net_device *new_dev, | |
| 4318 | + struct net_device *dev, | |
| 4319 | + struct netlink_ext_ack *extack); | |
| 4320 | +void netdev_adjacent_change_commit(struct net_device *old_dev, | |
| 4321 | + struct net_device *new_dev, | |
| 4322 | + struct net_device *dev); | |
| 4323 | +void netdev_adjacent_change_abort(struct net_device *old_dev, | |
| 4324 | + struct net_device *new_dev, | |
| 4325 | + struct net_device *dev); | |
| 4332 | 4326 | void netdev_adjacent_rename_links(struct net_device *dev, char *oldname); |
| 4333 | 4327 | void *netdev_lower_dev_get_private(struct net_device *dev, |
| 4334 | 4328 | struct net_device *lower_dev); |
| @@ -4340,7 +4334,6 @@ void netdev_lower_state_changed(struct net_device *lower_dev, · 5 unmodified lines | ||
| 4340 | 4334 | extern u8 netdev_rss_key[NETDEV_RSS_KEY_LEN] __read_mostly; |
| 4341 | 4335 | void netdev_rss_key_fill(void *buffer, size_t len); |
| 4342 | 4336 | |
| 4343 | −int dev_get_nest_level(struct net_device *dev); | |
| 4344 | 4337 | int skb_checksum_help(struct sk_buff *skb); |
| 4345 | 4338 | int skb_crc32c_csum_help(struct sk_buff *skb); |
| 4346 | 4339 | int skb_csum_hwoffload_help(struct sk_buff *skb, |
| @@ -622,12 +622,28 @@ static inline int PageTransCompound(struct page *page) · 621 unmodified lines | ||
| 622 | 622 | * |
| 623 | 623 | * Unlike PageTransCompound, this is safe to be called only while |
| 624 | 624 | * split_huge_pmd() cannot run from under us, like if protected by the |
| 625 | − * MMU notifier, otherwise it may result in page->_mapcount < 0 false | |
| 625 | + * MMU notifier, otherwise it may result in page->_mapcount check false | |
| 626 | 626 | * positives. |
| 627 | + * | |
| 628 | + * We have to treat page cache THP differently since every subpage of it | |
| 629 | + * would get _mapcount inc'ed once it is PMD mapped. But, it may be PTE | |
| 630 | + * mapped in the current process so comparing subpage's _mapcount to | |
| 631 | + * compound_mapcount to filter out PTE mapped case. | |
| 627 | 632 | */ |
| 628 | 633 | static inline int PageTransCompoundMap(struct page *page) |
| 629 | 634 | { |
| 630 | − return PageTransCompound(page) && atomic_read(&page->_mapcount) < 0; | |
| 635 | + struct page *head; | |
| 636 | + | |
| 637 | + if (!PageTransCompound(page)) | |
| 638 | + return 0; | |
| 639 | + | |
| 640 | + if (PageAnon(page)) | |
| 641 | + return atomic_read(&page->_mapcount) < 0; | |
| 642 | + | |
| 643 | + head = compound_head(page); | |
| 644 | + /* File THP is PMD mapped and not PTE mapped */ | |
| 645 | + return atomic_read(&page->_mapcount) == | |
| 646 | + atomic_read(compound_mapcount_ptr(head)); | |
| 631 | 647 | } |
| 632 | 648 | |
| 633 | 649 | /* |
| @@ -51,7 +51,10 @@ struct sdma_script_start_addrs { · 50 unmodified lines | ||
| 51 | 51 | /* End of v2 array */ |
| 52 | 52 | s32 zcanfd_2_mcu_addr; |
| 53 | 53 | s32 zqspi_2_mcu_addr; |
| 54 | + s32 mcu_2_ecspi_addr; | |
| 54 | 55 | /* End of v3 array */ |
| 56 | + s32 mcu_2_zqspi_addr; | |
| 57 | + /* End of v4 array */ | |
| 55 | 58 | }; |
| 56 | 59 | |
| 57 | 60 | /** |
| @@ -315,24 +315,6 @@ radix_tree_iter_lookup(const struct radix_tree_root *root, · 314 unmodified lines | ||
| 315 | 315 | return radix_tree_next_chunk(root, iter, RADIX_TREE_ITER_CONTIG); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | −/** | |
| 319 | − * radix_tree_iter_find - find a present entry | |
| 320 | − * @root: radix tree root | |
| 321 | − * @iter: iterator state | |
| 322 | − * @index: start location | |
| 323 | − * | |
| 324 | − * This function returns the slot containing the entry with the lowest index | |
| 325 | − * which is at least @index. If @index is larger than any present entry, this | |
| 326 | − * function returns NULL. The @iter is updated to describe the entry found. | |
| 327 | − */ | |
| 328 | −static inline void __rcu ** | |
| 329 | −radix_tree_iter_find(const struct radix_tree_root *root, | |
| 330 | − struct radix_tree_iter *iter, unsigned long index) | |
| 331 | −{ | |
| 332 | − radix_tree_iter_init(iter, index); | |
| 333 | − return radix_tree_next_chunk(root, iter, 0); | |
| 334 | −} | |
| 335 | − | |
| 336 | 318 | /** |
| 337 | 319 | * radix_tree_iter_retry - retry this chunk of the iteration |
| 338 | 320 | * @iter: iterator state |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | ||
| 7 | 7 | struct reset_controller_dev; |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | − * struct reset_control_ops | |
| 10 | + * struct reset_control_ops - reset controller driver callbacks | |
| 11 | 11 | * |
| 12 | 12 | * @reset: for self-deasserting resets, does all necessary |
| 13 | 13 | * things to reset the device |
| @@ -33,7 +33,7 @@ struct of_phandle_args; · 19 unmodified lines | ||
| 33 | 33 | * @provider: name of the reset controller device controlling this reset line |
| 34 | 34 | * @index: ID of the reset controller in the reset controller device |
| 35 | 35 | * @dev_id: name of the device associated with this reset line |
| 36 | − * @con_id name of the reset line (can be NULL) | |
| 36 | + * @con_id: name of the reset line (can be NULL) | |
| 37 | 37 | */ |
| 38 | 38 | struct reset_control_lookup { |
| 39 | 39 | struct list_head list; |
| @@ -143,7 +143,7 @@ static inline int device_reset_optional(struct device *dev) · 142 unmodified lines | ||
| 143 | 143 | * If this function is called more than once for the same reset_control it will |
| 144 | 144 | * return -EBUSY. |
| 145 | 145 | * |
| 146 | − * See reset_control_get_shared for details on shared references to | |
| 146 | + * See reset_control_get_shared() for details on shared references to | |
| 147 | 147 | * reset-controls. |
| 148 | 148 | * |
| 149 | 149 | * Use of id names is optional. |
| @@ -105,6 +105,7 @@ enum lockdown_reason { · 104 unmodified lines | ||
| 105 | 105 | LOCKDOWN_NONE, |
| 106 | 106 | LOCKDOWN_MODULE_SIGNATURE, |
| 107 | 107 | LOCKDOWN_DEV_MEM, |
| 108 | + LOCKDOWN_EFI_TEST, | |
| 108 | 109 | LOCKDOWN_KEXEC, |
| 109 | 110 | LOCKDOWN_HIBERNATION, |
| 110 | 111 | LOCKDOWN_PCI_ACCESS, |
| @@ -1354,7 +1354,8 @@ static inline __u32 skb_get_hash_flowi6(struct sk_buff *skb, const struct flowi6 · 1353 unmodified lines | ||
| 1354 | 1354 | return skb->hash; |
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | −__u32 skb_get_hash_perturb(const struct sk_buff *skb, u32 perturb); | |
| 1357 | +__u32 skb_get_hash_perturb(const struct sk_buff *skb, | |
| 1358 | + const siphash_key_t *perturb); | |
| 1358 | 1359 | |
| 1359 | 1360 | static inline __u32 skb_get_hash_raw(const struct sk_buff *skb) |
| 1360 | 1361 | { |
| @@ -1494,6 +1495,19 @@ static inline int skb_queue_empty(const struct sk_buff_head *list) · 133 unmodified lines | ||
| 1494 | 1495 | return list->next == (const struct sk_buff *) list; |
| 1495 | 1496 | } |
| 1496 | 1497 | |
| 1498 | +/** | |
| 1499 | + * skb_queue_empty_lockless - check if a queue is empty | |
| 1500 | + * @list: queue head | |
| 1501 | + * | |
| 1502 | + * Returns true if the queue is empty, false otherwise. | |
| 1503 | + * This variant can be used in lockless contexts. | |
| 1504 | + */ | |
| 1505 | +static inline bool skb_queue_empty_lockless(const struct sk_buff_head *list) | |
| 1506 | +{ | |
| 1507 | + return READ_ONCE(list->next) == (const struct sk_buff *) list; | |
| 1508 | +} | |
| 1509 | + | |
| 1510 | + | |
| 1497 | 1511 | /** |
| 1498 | 1512 | * skb_queue_is_last - check if skb is the last entry in the queue |
| 1499 | 1513 | * @list: queue head |
| @@ -1847,9 +1861,11 @@ static inline void __skb_insert(struct sk_buff *newsk, · 347 unmodified lines | ||
| 1847 | 1861 | struct sk_buff *prev, struct sk_buff *next, |
| 1848 | 1862 | struct sk_buff_head *list) |
| 1849 | 1863 | { |
| 1850 | − newsk->next = next; | |
| 1851 | − newsk->prev = prev; | |
| 1852 | − next->prev = prev->next = newsk; | |
| 1864 | + /* see skb_queue_empty_lockless() for the opposite READ_ONCE() */ | |
| 1865 | + WRITE_ONCE(newsk->next, next); | |
| 1866 | + WRITE_ONCE(newsk->prev, prev); | |
| 1867 | + WRITE_ONCE(next->prev, newsk); | |
| 1868 | + WRITE_ONCE(prev->next, newsk); | |
| 1853 | 1869 | list->qlen++; |
| 1854 | 1870 | } |
| 1855 | 1871 | |
| @@ -1860,11 +1876,11 @@ static inline void __skb_queue_splice(const struct sk_buff_head *list, · 4 unmodified lines | ||
| 1860 | 1876 | struct sk_buff *first = list->next; |
| 1861 | 1877 | struct sk_buff *last = list->prev; |
| 1862 | 1878 | |
| 1863 | − first->prev = prev; | |
| 1864 | − prev->next = first; | |
| 1879 | + WRITE_ONCE(first->prev, prev); | |
| 1880 | + WRITE_ONCE(prev->next, first); | |
| 1865 | 1881 | |
| 1866 | − last->next = next; | |
| 1867 | − next->prev = last; | |
| 1882 | + WRITE_ONCE(last->next, next); | |
| 1883 | + WRITE_ONCE(next->prev, last); | |
| 1868 | 1884 | } |
| 1869 | 1885 | |
| 1870 | 1886 | /** |
| @@ -2005,8 +2021,8 @@ static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list) · 134 unmodified lines | ||
| 2005 | 2021 | next = skb->next; |
| 2006 | 2022 | prev = skb->prev; |
| 2007 | 2023 | skb->next = skb->prev = NULL; |
| 2008 | − next->prev = prev; | |
| 2009 | − prev->next = next; | |
| 2024 | + WRITE_ONCE(next->prev, prev); | |
| 2025 | + WRITE_ONCE(prev->next, next); | |
| 2010 | 2026 | } |
| 2011 | 2027 | |
| 2012 | 2028 | /** |
| @@ -139,6 +139,11 @@ static inline void sk_msg_apply_bytes(struct sk_psock *psock, u32 bytes) · 138 unmodified lines | ||
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | +static inline u32 sk_msg_iter_dist(u32 start, u32 end) | |
| 143 | +{ | |
| 144 | + return end >= start ? end - start : end + (MAX_MSG_FRAGS - start); | |
| 145 | +} | |
| 146 | + | |
| 142 | 147 | #define sk_msg_iter_var_prev(var) \ |
| 143 | 148 | do { \ |
| 144 | 149 | if (var == 0) \ |
| @@ -198,9 +203,7 @@ static inline u32 sk_msg_elem_used(const struct sk_msg *msg) · 53 unmodified lines | ||
| 198 | 203 | if (sk_msg_full(msg)) |
| 199 | 204 | return MAX_MSG_FRAGS; |
| 200 | 205 | |
| 201 | − return msg->sg.end >= msg->sg.start ? | |
| 202 | − msg->sg.end - msg->sg.start : | |
| 203 | − msg->sg.end + (MAX_MSG_FRAGS - msg->sg.start); | |
| 206 | + return sk_msg_iter_dist(msg->sg.start, msg->sg.end); | |
| 204 | 207 | } |
| 205 | 208 | |
| 206 | 209 | static inline struct scatterlist *sk_msg_elem(struct sk_msg *msg, int which) |
| @@ -263,7 +263,7 @@ struct ucred { · 262 unmodified lines | ||
| 263 | 263 | #define PF_MAX AF_MAX |
| 264 | 264 | |
| 265 | 265 | /* Maximum queue length specifiable by listen. */ |
| 266 | −#define SOMAXCONN 128 | |
| 266 | +#define SOMAXCONN 4096 | |
| 267 | 267 | |
| 268 | 268 | /* Flags we can use with send/ and recv. |
| 269 | 269 | Added those for 1003.1g not all are supported yet |
| @@ -64,6 +64,11 @@ static inline int xprt_setup_backchannel(struct rpc_xprt *xprt, · 63 unmodified lines | ||
| 64 | 64 | return 0; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | +static inline void xprt_destroy_backchannel(struct rpc_xprt *xprt, | |
| 68 | + unsigned int max_reqs) | |
| 69 | +{ | |
| 70 | +} | |
| 71 | + | |
| 67 | 72 | static inline bool svc_is_backchannel(const struct svc_rqst *rqstp) |
| 68 | 73 | { |
| 69 | 74 | return false; |
| @@ -48,7 +48,6 @@ struct virtio_vsock_sock { · 47 unmodified lines | ||
| 48 | 48 | |
| 49 | 49 | struct virtio_vsock_pkt { |
| 50 | 50 | struct virtio_vsock_hdr hdr; |
| 51 | − struct work_struct work; | |
| 52 | 51 | struct list_head list; |
| 53 | 52 | /* socket refcnt not held, only use for cancellation */ |
| 54 | 53 | struct vsock_sock *vsk; |
| @@ -159,7 +159,6 @@ struct slave { · 158 unmodified lines | ||
| 159 | 159 | unsigned long target_last_arp_rx[BOND_MAX_ARP_TARGETS]; |
| 160 | 160 | s8 link; /* one of BOND_LINK_XXXX */ |
| 161 | 161 | s8 link_new_state; /* one of BOND_LINK_XXXX */ |
| 162 | − s8 new_link; | |
| 163 | 162 | u8 backup:1, /* indicates backup slave. Value corresponds with |
| 164 | 163 | BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ |
| 165 | 164 | inactive:1, /* indicates inactive slave */ |
| @@ -203,7 +202,6 @@ struct bonding { · 37 unmodified lines | ||
| 203 | 202 | struct slave __rcu *primary_slave; |
| 204 | 203 | struct bond_up_slave __rcu *slave_arr; /* Array of usable slaves */ |
| 205 | 204 | bool force_primary; |
| 206 | − u32 nest_level; | |
| 207 | 205 | s32 slave_cnt; /* never change this value outside the attach/detach wrappers */ |
| 208 | 206 | int (*recv_probe)(const struct sk_buff *, struct bonding *, |
| 209 | 207 | struct slave *); |
| @@ -239,6 +237,7 @@ struct bonding { · 29 unmodified lines | ||
| 239 | 237 | struct dentry *debug_dir; |
| 240 | 238 | #endif /* CONFIG_DEBUG_FS */ |
| 241 | 239 | struct rtnl_link_stats64 bond_stats; |
| 240 | + struct lock_class_key stats_lock_key; | |
| 242 | 241 | }; |
| 243 | 242 | |
| 244 | 243 | #define bond_slave_get_rcu(dev) \ |
| @@ -549,7 +548,7 @@ static inline void bond_propose_link_state(struct slave *slave, int state) · 304 unmodified lines | ||
| 549 | 548 | |
| 550 | 549 | static inline void bond_commit_link_state(struct slave *slave, bool notify) |
| 551 | 550 | { |
| 552 | − if (slave->link == slave->link_new_state) | |
| 551 | + if (slave->link_new_state == BOND_LINK_NOCHANGE) | |
| 553 | 552 | return; |
| 554 | 553 | |
| 555 | 554 | slave->link = slave->link_new_state; |
| @@ -122,7 +122,7 @@ static inline void skb_mark_napi_id(struct sk_buff *skb, · 121 unmodified lines | ||
| 122 | 122 | static inline void sk_mark_napi_id(struct sock *sk, const struct sk_buff *skb) |
| 123 | 123 | { |
| 124 | 124 | #ifdef CONFIG_NET_RX_BUSY_POLL |
| 125 | − sk->sk_napi_id = skb->napi_id; | |
| 125 | + WRITE_ONCE(sk->sk_napi_id, skb->napi_id); | |
| 126 | 126 | #endif |
| 127 | 127 | sk_rx_queue_set(sk, skb); |
| 128 | 128 | } |
| @@ -132,8 +132,8 @@ static inline void sk_mark_napi_id_once(struct sock *sk, · 3 unmodified lines | ||
| 132 | 132 | const struct sk_buff *skb) |
| 133 | 133 | { |
| 134 | 134 | #ifdef CONFIG_NET_RX_BUSY_POLL |
| 135 | − if (!sk->sk_napi_id) | |
| 136 | − sk->sk_napi_id = skb->napi_id; | |
| 135 | + if (!READ_ONCE(sk->sk_napi_id)) | |
| 136 | + WRITE_ONCE(sk->sk_napi_id, skb->napi_id); | |
| 137 | 137 | #endif |
| 138 | 138 | } |
| 139 | 139 | |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | #include <linux/types.h> |
| 6 | 6 | #include <linux/in6.h> |
| 7 | +#include <linux/siphash.h> | |
| 7 | 8 | #include <uapi/linux/if_ether.h> |
| 8 | 9 | |
| 9 | 10 | /** |
| @@ -276,7 +277,7 @@ struct flow_keys_basic { · 266 unmodified lines | ||
| 276 | 277 | struct flow_keys { |
| 277 | 278 | struct flow_dissector_key_control control; |
| 278 | 279 | #define FLOW_KEYS_HASH_START_FIELD basic |
| 279 | − struct flow_dissector_key_basic basic; | |
| 280 | + struct flow_dissector_key_basic basic __aligned(SIPHASH_ALIGNMENT); | |
| 280 | 281 | struct flow_dissector_key_tags tags; |
| 281 | 282 | struct flow_dissector_key_vlan vlan; |
| 282 | 283 | struct flow_dissector_key_vlan cvlan; |
| @@ -69,7 +69,7 @@ struct fq { · 68 unmodified lines | ||
| 69 | 69 | struct list_head backlogs; |
| 70 | 70 | spinlock_t lock; |
| 71 | 71 | u32 flows_cnt; |
| 72 | − u32 perturbation; | |
| 72 | + siphash_key_t perturbation; | |
| 73 | 73 | u32 limit; |
| 74 | 74 | u32 memory_limit; |
| 75 | 75 | u32 memory_usage; |
| @@ -108,7 +108,7 @@ begin: · 107 unmodified lines | ||
| 108 | 108 | |
| 109 | 109 | static u32 fq_flow_idx(struct fq *fq, struct sk_buff *skb) |
| 110 | 110 | { |
| 111 | − u32 hash = skb_get_hash_perturb(skb, fq->perturbation); | |
| 111 | + u32 hash = skb_get_hash_perturb(skb, &fq->perturbation); | |
| 112 | 112 | |
| 113 | 113 | return reciprocal_scale(hash, fq->flows_cnt); |
| 114 | 114 | } |
| @@ -308,12 +308,12 @@ static int fq_init(struct fq *fq, int flows_cnt) · 193 unmodified lines | ||
| 308 | 308 | INIT_LIST_HEAD(&fq->backlogs); |
| 309 | 309 | spin_lock_init(&fq->lock); |
| 310 | 310 | fq->flows_cnt = max_t(u32, flows_cnt, 1); |
| 311 | − fq->perturbation = prandom_u32(); | |
| 311 | + get_random_bytes(&fq->perturbation, sizeof(fq->perturbation)); | |
| 312 | 312 | fq->quantum = 300; |
| 313 | 313 | fq->limit = 8192; |
| 314 | 314 | fq->memory_limit = 16 << 20; /* 16 MBytes */ |
| 315 | 315 | |
| 316 | − fq->flows = kcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL); | |
| 316 | + fq->flows = kvcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL); | |
| 317 | 317 | if (!fq->flows) |
| 318 | 318 | return -ENOMEM; |
| 319 | 319 | |
| @@ -331,7 +331,7 @@ static void fq_reset(struct fq *fq, · 11 unmodified lines | ||
| 331 | 331 | for (i = 0; i < fq->flows_cnt; i++) |
| 332 | 332 | fq_flow_reset(fq, &fq->flows[i], free_func); |
| 333 | 333 | |
| 334 | − kfree(fq->flows); | |
| 334 | + kvfree(fq->flows); | |
| 335 | 335 | fq->flows = NULL; |
| 336 | 336 | } |
| 337 | 337 | |
| @@ -21,9 +21,13 @@ void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf); · 20 unmodified lines | ||
| 21 | 21 | int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp); |
| 22 | 22 | int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num); |
| 23 | 23 | #else |
| 24 | −void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {} | |
| 25 | −int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp) { return 0; } | |
| 26 | −int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num) | |
| 24 | +static inline void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {} | |
| 25 | + | |
| 26 | +static inline int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp) | |
| 27 | +{ return 0; } | |
| 28 | + | |
| 29 | +static inline int hwbm_pool_add(struct hwbm_pool *bm_pool, | |
| 30 | + unsigned int buf_num) | |
| 27 | 31 | { return 0; } |
| 28 | 32 | #endif /* CONFIG_HWBM */ |
| 29 | 33 | #endif /* _HWBM_H */ |
| @@ -185,7 +185,7 @@ static inline struct sk_buff *ip_fraglist_next(struct ip_fraglist_iter *iter) · 184 unmodified lines | ||
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | struct ip_frag_state { |
| 188 | − struct iphdr *iph; | |
| 188 | + bool DF; | |
| 189 | 189 | unsigned int hlen; |
| 190 | 190 | unsigned int ll_rs; |
| 191 | 191 | unsigned int mtu; |
| @@ -196,7 +196,7 @@ struct ip_frag_state { · 4 unmodified lines | ||
| 196 | 196 | }; |
| 197 | 197 | |
| 198 | 198 | void ip_frag_init(struct sk_buff *skb, unsigned int hlen, unsigned int ll_rs, |
| 199 | − unsigned int mtu, struct ip_frag_state *state); | |
| 199 | + unsigned int mtu, bool DF, struct ip_frag_state *state); | |
| 200 | 200 | struct sk_buff *ip_frag_next(struct sk_buff *skb, |
| 201 | 201 | struct ip_frag_state *state); |
| 202 | 202 | |
| @@ -889,6 +889,7 @@ struct netns_ipvs { · 888 unmodified lines | ||
| 889 | 889 | struct delayed_work defense_work; /* Work handler */ |
| 890 | 890 | int drop_rate; |
| 891 | 891 | int drop_counter; |
| 892 | + int old_secure_tcp; | |
| 892 | 893 | atomic_t dropentry; |
| 893 | 894 | /* locks in ctl.c */ |
| 894 | 895 | spinlock_t dropentry_lock; /* drop entry handling */ |
| @@ -439,8 +439,8 @@ static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) · 438 unmodified lines | ||
| 439 | 439 | { |
| 440 | 440 | unsigned long now = jiffies; |
| 441 | 441 | |
| 442 | − if (neigh->used != now) | |
| 443 | − neigh->used = now; | |
| 442 | + if (READ_ONCE(neigh->used) != now) | |
| 443 | + WRITE_ONCE(neigh->used, now); | |
| 444 | 444 | if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE))) |
| 445 | 445 | return __neigh_event_send(neigh, skb); |
| 446 | 446 | return 0; |
| @@ -342,7 +342,7 @@ static inline struct net *read_pnet(const possible_net_t *pnet) · 341 unmodified lines | ||
| 342 | 342 | #define __net_initconst __initconst |
| 343 | 343 | #endif |
| 344 | 344 | |
| 345 | −int peernet2id_alloc(struct net *net, struct net *peer); | |
| 345 | +int peernet2id_alloc(struct net *net, struct net *peer, gfp_t gfp); | |
| 346 | 346 | int peernet2id(struct net *net, struct net *peer); |
| 347 | 347 | bool peernet_has_id(struct net *net, struct net *peer); |
| 348 | 348 | struct net *get_net_ns_by_id(struct net *net, int id); |
| @@ -820,7 +820,8 @@ struct nft_expr_ops { · 819 unmodified lines | ||
| 820 | 820 | */ |
| 821 | 821 | struct nft_expr { |
| 822 | 822 | const struct nft_expr_ops *ops; |
| 823 | − unsigned char data[]; | |
| 823 | + unsigned char data[] | |
| 824 | + __attribute__((aligned(__alignof__(u64)))); | |
| 824 | 825 | }; |
| 825 | 826 | |
| 826 | 827 | static inline void *nft_expr_priv(const struct nft_expr *expr) |
| @@ -15,6 +15,7 @@ · 14 unmodified lines | ||
| 15 | 15 | #include <linux/mutex.h> |
| 16 | 16 | #include <linux/rwsem.h> |
| 17 | 17 | #include <linux/atomic.h> |
| 18 | +#include <linux/hashtable.h> | |
| 18 | 19 | #include <net/gen_stats.h> |
| 19 | 20 | #include <net/rtnetlink.h> |
| 20 | 21 | #include <net/flow_offload.h> |
| @@ -362,6 +363,7 @@ struct tcf_proto { · 341 unmodified lines | ||
| 362 | 363 | bool deleting; |
| 363 | 364 | refcount_t refcnt; |
| 364 | 365 | struct rcu_head rcu; |
| 366 | + struct hlist_node destroy_ht_node; | |
| 365 | 367 | }; |
| 366 | 368 | |
| 367 | 369 | struct qdisc_skb_cb { |
| @@ -414,6 +416,8 @@ struct tcf_block { · 46 unmodified lines | ||
| 414 | 416 | struct list_head filter_chain_list; |
| 415 | 417 | } chain0; |
| 416 | 418 | struct rcu_head rcu; |
| 419 | + DECLARE_HASHTABLE(proto_destroy_ht, 7); | |
| 420 | + struct mutex proto_destroy_lock; /* Lock for proto_destroy hashtable. */ | |
| 417 | 421 | }; |
| 418 | 422 | |
| 419 | 423 | #ifdef CONFIG_PROVE_LOCKING |
| @@ -954,8 +954,8 @@ static inline void sk_incoming_cpu_update(struct sock *sk) · 953 unmodified lines | ||
| 954 | 954 | { |
| 955 | 955 | int cpu = raw_smp_processor_id(); |
| 956 | 956 | |
| 957 | − if (unlikely(sk->sk_incoming_cpu != cpu)) | |
| 958 | − sk->sk_incoming_cpu = cpu; | |
| 957 | + if (unlikely(READ_ONCE(sk->sk_incoming_cpu) != cpu)) | |
| 958 | + WRITE_ONCE(sk->sk_incoming_cpu, cpu); | |
| 959 | 959 | } |
| 960 | 960 | |
| 961 | 961 | static inline void sock_rps_record_flow_hash(__u32 hash) |
| @@ -2242,12 +2242,17 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp, · 1280 unmodified lines | ||
| 2242 | 2242 | * sk_page_frag - return an appropriate page_frag |
| 2243 | 2243 | * @sk: socket |
| 2244 | 2244 | * |
| 2245 | − * If socket allocation mode allows current thread to sleep, it means its | |
| 2246 | − * safe to use the per task page_frag instead of the per socket one. | |
| 2245 | + * Use the per task page_frag instead of the per socket one for | |
| 2246 | + * optimization when we know that we're in the normal context and owns | |
| 2247 | + * everything that's associated with %current. | |
| 2248 | + * | |
| 2249 | + * gfpflags_allow_blocking() isn't enough here as direct reclaim may nest | |
| 2250 | + * inside other socket operations and end up recursing into sk_page_frag() | |
| 2251 | + * while it's already in use. | |
| 2247 | 2252 | */ |
| 2248 | 2253 | static inline struct page_frag *sk_page_frag(struct sock *sk) |
| 2249 | 2254 | { |
| 2250 | − if (gfpflags_allow_blocking(sk->sk_allocation)) | |
| 2255 | + if (gfpflags_normal_context(sk->sk_allocation)) | |
| 2251 | 2256 | return ¤t->task_frag; |
| 2252 | 2257 | |
| 2253 | 2258 | return &sk->sk_frag; |
| @@ -2337,7 +2342,7 @@ static inline ktime_t sock_read_timestamp(struct sock *sk) · 83 unmodified lines | ||
| 2337 | 2342 | |
| 2338 | 2343 | return kt; |
| 2339 | 2344 | #else |
| 2340 | − return sk->sk_stamp; | |
| 2345 | + return READ_ONCE(sk->sk_stamp); | |
| 2341 | 2346 | #endif |
| 2342 | 2347 | } |
| 2343 | 2348 | |
| @@ -2348,7 +2353,7 @@ static inline void sock_write_timestamp(struct sock *sk, ktime_t kt) · 4 unmodified lines | ||
| 2348 | 2353 | sk->sk_stamp = kt; |
| 2349 | 2354 | write_sequnlock(&sk->sk_stamp_seq); |
| 2350 | 2355 | #else |
| 2351 | − sk->sk_stamp = kt; | |
| 2356 | + WRITE_ONCE(sk->sk_stamp, kt); | |
| 2352 | 2357 | #endif |
| 2353 | 2358 | } |
| 2354 | 2359 | |
| @@ -40,6 +40,7 @@ · 39 unmodified lines | ||
| 40 | 40 | #include <linux/socket.h> |
| 41 | 41 | #include <linux/tcp.h> |
| 42 | 42 | #include <linux/skmsg.h> |
| 43 | +#include <linux/mutex.h> | |
| 43 | 44 | #include <linux/netdevice.h> |
| 44 | 45 | #include <linux/rcupdate.h> |
| 45 | 46 | |
| @@ -269,6 +270,10 @@ struct tls_context { · 223 unmodified lines | ||
| 269 | 270 | |
| 270 | 271 | bool in_tcp_sendpages; |
| 271 | 272 | bool pending_open_record_frags; |
| 273 | + | |
| 274 | + struct mutex tx_lock; /* protects partially_sent_* fields and | |
| 275 | + * per-type TX fields | |
| 276 | + */ | |
| 272 | 277 | unsigned long flags; |
| 273 | 278 | |
| 274 | 279 | /* cache cold stuff */ |
| @@ -197,6 +197,7 @@ struct vxlan_rdst { · 196 unmodified lines | ||
| 197 | 197 | u8 offloaded:1; |
| 198 | 198 | __be32 remote_vni; |
| 199 | 199 | u32 remote_ifindex; |
| 200 | + struct net_device *remote_dev; | |
| 200 | 201 | struct list_head list; |
| 201 | 202 | struct rcu_head rcu; |
| 202 | 203 | struct dst_cache dst_cache; |
| @@ -366,7 +366,7 @@ struct ib_tm_caps { · 365 unmodified lines | ||
| 366 | 366 | |
| 367 | 367 | struct ib_cq_init_attr { |
| 368 | 368 | unsigned int cqe; |
| 369 | − int comp_vector; | |
| 369 | + u32 comp_vector; | |
| 370 | 370 | u32 flags; |
| 371 | 371 | }; |
| 372 | 372 | |
| @@ -1,4 +1,4 @@ | ||
| 1 | −/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ | |
| 1 | +/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */ | |
| 2 | 2 | /* |
| 3 | 3 | * linux/can.h |
| 4 | 4 | * |
| @@ -1,4 +1,4 @@ | ||
| 1 | −/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ | |
| 1 | +/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */ | |
| 2 | 2 | /* |
| 3 | 3 | * linux/can/bcm.h |
| 4 | 4 | * |
| @@ -1,4 +1,4 @@ | ||
| 1 | −/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ | |
| 1 | +/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */ | |
| 2 | 2 | /* |
| 3 | 3 | * linux/can/error.h |
| 4 | 4 | * |
| @@ -1,4 +1,4 @@ | ||
| 1 | −/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ | |
| 1 | +/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */ | |
| 2 | 2 | /* |
| 3 | 3 | * linux/can/gw.h |
| 4 | 4 | * |
| @@ -1,4 +1,4 @@ | ||
| 1 | −/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ | |
| 2 | 2 | /* |
| 3 | 3 | * j1939.h |
| 4 | 4 | * |
| @@ -1,4 +1,4 @@ | ||
| 1 | −/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ | |
| 2 | 2 | /* |
| 3 | 3 | * linux/can/netlink.h |
| 4 | 4 | * |
| @@ -1,4 +1,4 @@ | ||
| 1 | −/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ | |
| 1 | +/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */ | |
| 2 | 2 | /* |
| 3 | 3 | * linux/can/raw.h |
| 4 | 4 | * |
| @@ -1,4 +1,4 @@ | ||
| 1 | −/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ | |
| 2 | 2 | #ifndef _UAPI_CAN_VXCAN_H |
| 3 | 3 | #define _UAPI_CAN_VXCAN_H |
| 4 | 4 | |
| @@ -38,6 +38,43 @@ · 37 unmodified lines | ||
| 38 | 38 | * |
| 39 | 39 | * Protocol changelog: |
| 40 | 40 | * |
| 41 | + * 7.1: | |
| 42 | + * - add the following messages: | |
| 43 | + * FUSE_SETATTR, FUSE_SYMLINK, FUSE_MKNOD, FUSE_MKDIR, FUSE_UNLINK, | |
| 44 | + * FUSE_RMDIR, FUSE_RENAME, FUSE_LINK, FUSE_OPEN, FUSE_READ, FUSE_WRITE, | |
| 45 | + * FUSE_RELEASE, FUSE_FSYNC, FUSE_FLUSH, FUSE_SETXATTR, FUSE_GETXATTR, | |
| 46 | + * FUSE_LISTXATTR, FUSE_REMOVEXATTR, FUSE_OPENDIR, FUSE_READDIR, | |
| 47 | + * FUSE_RELEASEDIR | |
| 48 | + * - add padding to messages to accommodate 32-bit servers on 64-bit kernels | |
| 49 | + * | |
| 50 | + * 7.2: | |
| 51 | + * - add FOPEN_DIRECT_IO and FOPEN_KEEP_CACHE flags | |
| 52 | + * - add FUSE_FSYNCDIR message | |
| 53 | + * | |
| 54 | + * 7.3: | |
| 55 | + * - add FUSE_ACCESS message | |
| 56 | + * - add FUSE_CREATE message | |
| 57 | + * - add filehandle to fuse_setattr_in | |
| 58 | + * | |
| 59 | + * 7.4: | |
| 60 | + * - add frsize to fuse_kstatfs | |
| 61 | + * - clean up request size limit checking | |
| 62 | + * | |
| 63 | + * 7.5: | |
| 64 | + * - add flags and max_write to fuse_init_out | |
| 65 | + * | |
| 66 | + * 7.6: | |
| 67 | + * - add max_readahead to fuse_init_in and fuse_init_out | |
| 68 | + * | |
| 69 | + * 7.7: | |
| 70 | + * - add FUSE_INTERRUPT message | |
| 71 | + * - add POSIX file lock support | |
| 72 | + * | |
| 73 | + * 7.8: | |
| 74 | + * - add lock_owner and flags fields to fuse_release_in | |
| 75 | + * - add FUSE_BMAP message | |
| 76 | + * - add FUSE_DESTROY message | |
| 77 | + * | |
| 41 | 78 | * 7.9: |
| 42 | 79 | * - new fuse_getattr_in input argument of GETATTR |
| 43 | 80 | * - add lk_flags in fuse_lk_in |
| @@ -63,6 +63,7 @@ struct nvme_passthru_cmd64 { · 62 unmodified lines | ||
| 63 | 63 | __u32 cdw14; |
| 64 | 64 | __u32 cdw15; |
| 65 | 65 | __u32 timeout_ms; |
| 66 | + __u32 rsvd2; | |
| 66 | 67 | __u64 result; |
| 67 | 68 | }; |
| 68 | 69 | |
| @@ -51,6 +51,10 @@ · 50 unmodified lines | ||
| 51 | 51 | * sent when the child exits. |
| 52 | 52 | * @stack: Specify the location of the stack for the |
| 53 | 53 | * child process. |
| 54 | + * Note, @stack is expected to point to the | |
| 55 | + * lowest address. The stack direction will be | |
| 56 | + * determined by the kernel and set up | |
| 57 | + * appropriately based on @stack_size. | |
| 54 | 58 | * @stack_size: The size of the stack for the child process. |
| 55 | 59 | * @tls: If CLONE_SETTLS is set, the tls descriptor |
| 56 | 60 | * is set to tls. |
| @@ -1311,12 +1311,12 @@ static bool sysctl_is_valid_access(int off, int size, enum bpf_access_type type, · 1310 unmodified lines | ||
| 1311 | 1311 | return false; |
| 1312 | 1312 | |
| 1313 | 1313 | switch (off) { |
| 1314 | − case offsetof(struct bpf_sysctl, write): | |
| 1314 | + case bpf_ctx_range(struct bpf_sysctl, write): | |
| 1315 | 1315 | if (type != BPF_READ) |
| 1316 | 1316 | return false; |
| 1317 | 1317 | bpf_ctx_record_field_size(info, size_default); |
| 1318 | 1318 | return bpf_ctx_narrow_access_ok(off, size, size_default); |
| 1319 | − case offsetof(struct bpf_sysctl, file_pos): | |
| 1319 | + case bpf_ctx_range(struct bpf_sysctl, file_pos): | |
| 1320 | 1320 | if (type == BPF_READ) { |
| 1321 | 1321 | bpf_ctx_record_field_size(info, size_default); |
| 1322 | 1322 | return bpf_ctx_narrow_access_ok(off, size, size_default); |
| @@ -502,7 +502,7 @@ int bpf_remove_insns(struct bpf_prog *prog, u32 off, u32 cnt) · 501 unmodified lines | ||
| 502 | 502 | return WARN_ON_ONCE(bpf_adj_branches(prog, off, off + cnt, off, false)); |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | −void bpf_prog_kallsyms_del_subprogs(struct bpf_prog *fp) | |
| 505 | +static void bpf_prog_kallsyms_del_subprogs(struct bpf_prog *fp) | |
| 506 | 506 | { |
| 507 | 507 | int i; |
| 508 | 508 | |
| @@ -128,7 +128,7 @@ static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr) · 127 unmodified lines | ||
| 128 | 128 | |
| 129 | 129 | if (!dtab->n_buckets) /* Overflow check */ |
| 130 | 130 | return -EINVAL; |
| 131 | − cost += sizeof(struct hlist_head) * dtab->n_buckets; | |
| 131 | + cost += (u64) sizeof(struct hlist_head) * dtab->n_buckets; | |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /* if map size is larger than memlock limit, reject it */ |
| @@ -719,6 +719,32 @@ const struct bpf_map_ops dev_map_hash_ops = { · 584 unmodified lines | ||
| 719 | 719 | .map_check_btf = map_check_no_btf, |
| 720 | 720 | }; |
| 721 | 721 | |
| 722 | +static void dev_map_hash_remove_netdev(struct bpf_dtab *dtab, | |
| 723 | + struct net_device *netdev) | |
| 724 | +{ | |
| 725 | + unsigned long flags; | |
| 726 | + u32 i; | |
| 727 | + | |
| 728 | + spin_lock_irqsave(&dtab->index_lock, flags); | |
| 729 | + for (i = 0; i < dtab->n_buckets; i++) { | |
| 730 | + struct bpf_dtab_netdev *dev; | |
| 731 | + struct hlist_head *head; | |
| 732 | + struct hlist_node *next; | |
| 733 | + | |
| 734 | + head = dev_map_index_hash(dtab, i); | |
| 735 | + | |
| 736 | + hlist_for_each_entry_safe(dev, next, head, index_hlist) { | |
| 737 | + if (netdev != dev->dev) | |
| 738 | + continue; | |
| 739 | + | |
| 740 | + dtab->items--; | |
| 741 | + hlist_del_rcu(&dev->index_hlist); | |
| 742 | + call_rcu(&dev->rcu, __dev_map_entry_free); | |
| 743 | + } | |
| 744 | + } | |
| 745 | + spin_unlock_irqrestore(&dtab->index_lock, flags); | |
| 746 | +} | |
| 747 | + | |
| 722 | 748 | static int dev_map_notification(struct notifier_block *notifier, |
| 723 | 749 | ulong event, void *ptr) |
| 724 | 750 | { |
| @@ -735,6 +761,11 @@ static int dev_map_notification(struct notifier_block *notifier, · 10 unmodified lines | ||
| 735 | 761 | */ |
| 736 | 762 | rcu_read_lock(); |
| 737 | 763 | list_for_each_entry_rcu(dtab, &dev_map_list, list) { |
| 764 | + if (dtab->map.map_type == BPF_MAP_TYPE_DEVMAP_HASH) { | |
| 765 | + dev_map_hash_remove_netdev(dtab, netdev); | |
| 766 | + continue; | |
| 767 | + } | |
| 768 | + | |
| 738 | 769 | for (i = 0; i < dtab->map.max_entries; i++) { |
| 739 | 770 | struct bpf_dtab_netdev *dev, *odev; |
| 740 | 771 | |
| @@ -126,7 +126,7 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr) · 125 unmodified lines | ||
| 126 | 126 | return map; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | −void *bpf_map_area_alloc(size_t size, int numa_node) | |
| 129 | +void *bpf_map_area_alloc(u64 size, int numa_node) | |
| 130 | 130 | { |
| 131 | 131 | /* We really just want to fail instead of triggering OOM killer |
| 132 | 132 | * under memory pressure, therefore we set __GFP_NORETRY to kmalloc, |
| @@ -141,6 +141,9 @@ void *bpf_map_area_alloc(size_t size, int numa_node) · 8 unmodified lines | ||
| 141 | 141 | const gfp_t flags = __GFP_NOWARN | __GFP_ZERO; |
| 142 | 142 | void *area; |
| 143 | 143 | |
| 144 | + if (size >= SIZE_MAX) | |
| 145 | + return NULL; | |
| 146 | + | |
| 144 | 147 | if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { |
| 145 | 148 | area = kmalloc_node(size, GFP_USER | __GFP_NORETRY | flags, |
| 146 | 149 | numa_node); |
| @@ -197,7 +200,7 @@ static void bpf_uncharge_memlock(struct user_struct *user, u32 pages) · 50 unmodified lines | ||
| 197 | 200 | atomic_long_sub(pages, &user->locked_vm); |
| 198 | 201 | } |
| 199 | 202 | |
| 200 | −int bpf_map_charge_init(struct bpf_map_memory *mem, size_t size) | |
| 203 | +int bpf_map_charge_init(struct bpf_map_memory *mem, u64 size) | |
| 201 | 204 | { |
| 202 | 205 | u32 pages = round_up(size, PAGE_SIZE) >> PAGE_SHIFT; |
| 203 | 206 | struct user_struct *user; |
| @@ -1326,24 +1329,32 @@ static void __bpf_prog_put_rcu(struct rcu_head *rcu) · 1122 unmodified lines | ||
| 1326 | 1329 | { |
| 1327 | 1330 | struct bpf_prog_aux *aux = container_of(rcu, struct bpf_prog_aux, rcu); |
| 1328 | 1331 | |
| 1332 | + kvfree(aux->func_info); | |
| 1329 | 1333 | free_used_maps(aux); |
| 1330 | 1334 | bpf_prog_uncharge_memlock(aux->prog); |
| 1331 | 1335 | security_bpf_prog_free(aux); |
| 1332 | 1336 | bpf_prog_free(aux->prog); |
| 1333 | 1337 | } |
| 1334 | 1338 | |
| 1339 | +static void __bpf_prog_put_noref(struct bpf_prog *prog, bool deferred) | |
| 1340 | +{ | |
| 1341 | + bpf_prog_kallsyms_del_all(prog); | |
| 1342 | + btf_put(prog->aux->btf); | |
| 1343 | + bpf_prog_free_linfo(prog); | |
| 1344 | + | |
| 1345 | + if (deferred) | |
| 1346 | + call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu); | |
| 1347 | + else | |
| 1348 | + __bpf_prog_put_rcu(&prog->aux->rcu); | |
| 1349 | +} | |
| 1350 | + | |
| 1335 | 1351 | static void __bpf_prog_put(struct bpf_prog *prog, bool do_idr_lock) |
| 1336 | 1352 | { |
| 1337 | 1353 | if (atomic_dec_and_test(&prog->aux->refcnt)) { |
| 1338 | 1354 | perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_UNLOAD, 0); |
| 1339 | 1355 | /* bpf_prog_free_id() must be called first */ |
| 1340 | 1356 | bpf_prog_free_id(prog, do_idr_lock); |
| 1341 | − bpf_prog_kallsyms_del_all(prog); | |
| 1342 | − btf_put(prog->aux->btf); | |
| 1343 | − kvfree(prog->aux->func_info); | |
| 1344 | − bpf_prog_free_linfo(prog); | |
| 1345 | − | |
| 1346 | − call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu); | |
| 1357 | + __bpf_prog_put_noref(prog, true); | |
| 1347 | 1358 | } |
| 1348 | 1359 | } |
| 1349 | 1360 | |
| @@ -1741,11 +1752,12 @@ static int bpf_prog_load(union bpf_attr *attr, union bpf_attr __user *uattr) · 391 unmodified lines | ||
| 1741 | 1752 | return err; |
| 1742 | 1753 | |
| 1743 | 1754 | free_used_maps: |
| 1744 | − bpf_prog_free_linfo(prog); | |
| 1745 | − kvfree(prog->aux->func_info); | |
| 1746 | − btf_put(prog->aux->btf); | |
| 1747 | − bpf_prog_kallsyms_del_subprogs(prog); | |
| 1748 | − free_used_maps(prog->aux); | |
| 1755 | + /* In case we have subprogs, we need to wait for a grace | |
| 1756 | + * period before we can tear down JIT memory since symbols | |
| 1757 | + * are already exposed under kallsyms. | |
| 1758 | + */ | |
| 1759 | + __bpf_prog_put_noref(prog, prog->aux->func_cnt); | |
| 1760 | + return err; | |
| 1749 | 1761 | free_prog: |
| 1750 | 1762 | bpf_prog_uncharge_memlock(prog); |
| 1751 | 1763 | free_prog_sec: |
| @@ -798,7 +798,8 @@ static int generate_sched_domains(cpumask_var_t **domains, · 797 unmodified lines | ||
| 798 | 798 | cpumask_subset(cp->cpus_allowed, top_cpuset.effective_cpus)) |
| 799 | 799 | continue; |
| 800 | 800 | |
| 801 | − if (is_sched_load_balance(cp)) | |
| 801 | + if (is_sched_load_balance(cp) && | |
| 802 | + !cpumask_empty(cp->effective_cpus)) | |
| 802 | 803 | csa[csn++] = cp; |
| 803 | 804 | |
| 804 | 805 | /* skip @cp's subtree if not a partition root */ |
| @@ -2561,7 +2561,35 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs, · 2560 unmodified lines | ||
| 2561 | 2561 | return 0; |
| 2562 | 2562 | } |
| 2563 | 2563 | |
| 2564 | −static bool clone3_args_valid(const struct kernel_clone_args *kargs) | |
| 2564 | +/** | |
| 2565 | + * clone3_stack_valid - check and prepare stack | |
| 2566 | + * @kargs: kernel clone args | |
| 2567 | + * | |
| 2568 | + * Verify that the stack arguments userspace gave us are sane. | |
| 2569 | + * In addition, set the stack direction for userspace since it's easy for us to | |
| 2570 | + * determine. | |
| 2571 | + */ | |
| 2572 | +static inline bool clone3_stack_valid(struct kernel_clone_args *kargs) | |
| 2573 | +{ | |
| 2574 | + if (kargs->stack == 0) { | |
| 2575 | + if (kargs->stack_size > 0) | |
| 2576 | + return false; | |
| 2577 | + } else { | |
| 2578 | + if (kargs->stack_size == 0) | |
| 2579 | + return false; | |
| 2580 | + | |
| 2581 | + if (!access_ok((void __user *)kargs->stack, kargs->stack_size)) | |
| 2582 | + return false; | |
| 2583 | + | |
| 2584 | +#if !defined(CONFIG_STACK_GROWSUP) && !defined(CONFIG_IA64) | |
| 2585 | + kargs->stack += kargs->stack_size; | |
| 2586 | +#endif | |
| 2587 | + } | |
| 2588 | + | |
| 2589 | + return true; | |
| 2590 | +} | |
| 2591 | + | |
| 2592 | +static bool clone3_args_valid(struct kernel_clone_args *kargs) | |
| 2565 | 2593 | { |
| 2566 | 2594 | /* |
| 2567 | 2595 | * All lower bits of the flag word are taken. |
| @@ -2581,6 +2609,9 @@ static bool clone3_args_valid(const struct kernel_clone_args *kargs) · 13 unmodified lines | ||
| 2581 | 2609 | kargs->exit_signal) |
| 2582 | 2610 | return false; |
| 2583 | 2611 | |
| 2612 | + if (!clone3_stack_valid(kargs)) | |
| 2613 | + return false; | |
| 2614 | + | |
| 2584 | 2615 | return true; |
| 2585 | 2616 | } |
| 2586 | 2617 | |
| @@ -51,7 +51,7 @@ EXPORT_SYMBOL_GPL(irqchip_fwnode_ops); · 50 unmodified lines | ||
| 51 | 51 | * @type: Type of irqchip_fwnode. See linux/irqdomain.h |
| 52 | 52 | * @name: Optional user provided domain name |
| 53 | 53 | * @id: Optional user provided id if name != NULL |
| 54 | − * @data: Optional user-provided data | |
| 54 | + * @pa: Optional user-provided physical address | |
| 55 | 55 | * |
| 56 | 56 | * Allocate a struct irqchip_fwid, and return a poiner to the embedded |
| 57 | 57 | * fwnode_handle (or NULL on failure). |
| @@ -1073,6 +1073,7 @@ uclamp_update_active(struct task_struct *p, enum uclamp_id clamp_id) · 1072 unmodified lines | ||
| 1073 | 1073 | task_rq_unlock(rq, p, &rf); |
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | +#ifdef CONFIG_UCLAMP_TASK_GROUP | |
| 1076 | 1077 | static inline void |
| 1077 | 1078 | uclamp_update_active_tasks(struct cgroup_subsys_state *css, |
| 1078 | 1079 | unsigned int clamps) |
| @@ -1091,7 +1092,6 @@ uclamp_update_active_tasks(struct cgroup_subsys_state *css, · 12 unmodified lines | ||
| 1091 | 1092 | css_task_iter_end(&it); |
| 1092 | 1093 | } |
| 1093 | 1094 | |
| 1094 | −#ifdef CONFIG_UCLAMP_TASK_GROUP | |
| 1095 | 1095 | static void cpu_util_update_eff(struct cgroup_subsys_state *css); |
| 1096 | 1096 | static void uclamp_update_root_tg(void) |
| 1097 | 1097 | { |
| @@ -3929,13 +3929,22 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) · 2831 unmodified lines | ||
| 3929 | 3929 | } |
| 3930 | 3930 | |
| 3931 | 3931 | restart: |
| 3932 | +#ifdef CONFIG_SMP | |
| 3932 | 3933 | /* |
| 3933 | − * Ensure that we put DL/RT tasks before the pick loop, such that they | |
| 3934 | − * can PULL higher prio tasks when we lower the RQ 'priority'. | |
| 3934 | + * We must do the balancing pass before put_next_task(), such | |
| 3935 | + * that when we release the rq->lock the task is in the same | |
| 3936 | + * state as before we took rq->lock. | |
| 3937 | + * | |
| 3938 | + * We can terminate the balance pass as soon as we know there is | |
| 3939 | + * a runnable task of @class priority or higher. | |
| 3935 | 3940 | */ |
| 3936 | − prev->sched_class->put_prev_task(rq, prev, rf); | |
| 3937 | − if (!rq->nr_running) | |
| 3938 | − newidle_balance(rq, rf); | |
| 3941 | + for_class_range(class, prev->sched_class, &idle_sched_class) { | |
| 3942 | + if (class->balance(rq, prev, rf)) | |
| 3943 | + break; | |
| 3944 | + } | |
| 3945 | +#endif | |
| 3946 | + | |
| 3947 | + put_prev_task(rq, prev); | |
| 3939 | 3948 | |
| 3940 | 3949 | for_each_class(class) { |
| 3941 | 3950 | p = class->pick_next_task(rq, NULL, NULL); |
| @@ -6201,7 +6210,7 @@ static struct task_struct *__pick_migrate_task(struct rq *rq) · 2259 unmodified lines | ||
| 6201 | 6210 | for_each_class(class) { |
| 6202 | 6211 | next = class->pick_next_task(rq, NULL, NULL); |
| 6203 | 6212 | if (next) { |
| 6204 | − next->sched_class->put_prev_task(rq, next, NULL); | |
| 6213 | + next->sched_class->put_prev_task(rq, next); | |
| 6205 | 6214 | return next; |
| 6206 | 6215 | } |
| 6207 | 6216 | } |
| @@ -1691,6 +1691,22 @@ static void check_preempt_equal_dl(struct rq *rq, struct task_struct *p) · 1690 unmodified lines | ||
| 1691 | 1691 | resched_curr(rq); |
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | +static int balance_dl(struct rq *rq, struct task_struct *p, struct rq_flags *rf) | |
| 1695 | +{ | |
| 1696 | + if (!on_dl_rq(&p->dl) && need_pull_dl_task(rq, p)) { | |
| 1697 | + /* | |
| 1698 | + * This is OK, because current is on_cpu, which avoids it being | |
| 1699 | + * picked for load-balance and preemption/IRQs are still | |
| 1700 | + * disabled avoiding further scheduler activity on it and we've | |
| 1701 | + * not yet started the picking loop. | |
| 1702 | + */ | |
| 1703 | + rq_unpin_lock(rq, rf); | |
| 1704 | + pull_dl_task(rq); | |
| 1705 | + rq_repin_lock(rq, rf); | |
| 1706 | + } | |
| 1707 | + | |
| 1708 | + return sched_stop_runnable(rq) || sched_dl_runnable(rq); | |
| 1709 | +} | |
| 1694 | 1710 | #endif /* CONFIG_SMP */ |
| 1695 | 1711 | |
| 1696 | 1712 | /* |
| @@ -1758,45 +1774,28 @@ static struct task_struct * · 61 unmodified lines | ||
| 1758 | 1774 | pick_next_task_dl(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) |
| 1759 | 1775 | { |
| 1760 | 1776 | struct sched_dl_entity *dl_se; |
| 1777 | + struct dl_rq *dl_rq = &rq->dl; | |
| 1761 | 1778 | struct task_struct *p; |
| 1762 | − struct dl_rq *dl_rq; | |
| 1763 | 1779 | |
| 1764 | 1780 | WARN_ON_ONCE(prev || rf); |
| 1765 | 1781 | |
| 1766 | − dl_rq = &rq->dl; | |
| 1767 | − | |
| 1768 | − if (unlikely(!dl_rq->dl_nr_running)) | |
| 1782 | + if (!sched_dl_runnable(rq)) | |
| 1769 | 1783 | return NULL; |
| 1770 | 1784 | |
| 1771 | 1785 | dl_se = pick_next_dl_entity(rq, dl_rq); |
| 1772 | 1786 | BUG_ON(!dl_se); |
| 1773 | − | |
| 1774 | 1787 | p = dl_task_of(dl_se); |
| 1775 | − | |
| 1776 | 1788 | set_next_task_dl(rq, p); |
| 1777 | − | |
| 1778 | 1789 | return p; |
| 1779 | 1790 | } |
| 1780 | 1791 | |
| 1781 | −static void put_prev_task_dl(struct rq *rq, struct task_struct *p, struct rq_flags *rf) | |
| 1792 | +static void put_prev_task_dl(struct rq *rq, struct task_struct *p) | |
| 1782 | 1793 | { |
| 1783 | 1794 | update_curr_dl(rq); |
| 1784 | 1795 | |
| 1785 | 1796 | update_dl_rq_load_avg(rq_clock_pelt(rq), rq, 1); |
| 1786 | 1797 | if (on_dl_rq(&p->dl) && p->nr_cpus_allowed > 1) |
| 1787 | 1798 | enqueue_pushable_dl_task(rq, p); |
| 1788 | − | |
| 1789 | − if (rf && !on_dl_rq(&p->dl) && need_pull_dl_task(rq, p)) { | |
| 1790 | − /* | |
| 1791 | − * This is OK, because current is on_cpu, which avoids it being | |
| 1792 | − * picked for load-balance and preemption/IRQs are still | |
| 1793 | − * disabled avoiding further scheduler activity on it and we've | |
| 1794 | − * not yet started the picking loop. | |
| 1795 | − */ | |
| 1796 | − rq_unpin_lock(rq, rf); | |
| 1797 | − pull_dl_task(rq); | |
| 1798 | − rq_repin_lock(rq, rf); | |
| 1799 | − } | |
| 1800 | 1799 | } |
| 1801 | 1800 | |
| 1802 | 1801 | /* |
| @@ -2442,6 +2441,7 @@ const struct sched_class dl_sched_class = { · 639 unmodified lines | ||
| 2442 | 2441 | .set_next_task = set_next_task_dl, |
| 2443 | 2442 | |
| 2444 | 2443 | #ifdef CONFIG_SMP |
| 2444 | + .balance = balance_dl, | |
| 2445 | 2445 | .select_task_rq = select_task_rq_dl, |
| 2446 | 2446 | .migrate_task_rq = migrate_task_rq_dl, |
| 2447 | 2447 | .set_cpus_allowed = set_cpus_allowed_dl, |
| @@ -6570,6 +6570,15 @@ static void task_dead_fair(struct task_struct *p) · 6569 unmodified lines | ||
| 6570 | 6570 | { |
| 6571 | 6571 | remove_entity_load_avg(&p->se); |
| 6572 | 6572 | } |
| 6573 | + | |
| 6574 | +static int | |
| 6575 | +balance_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) | |
| 6576 | +{ | |
| 6577 | + if (rq->nr_running) | |
| 6578 | + return 1; | |
| 6579 | + | |
| 6580 | + return newidle_balance(rq, rf) != 0; | |
| 6581 | +} | |
| 6573 | 6582 | #endif /* CONFIG_SMP */ |
| 6574 | 6583 | |
| 6575 | 6584 | static unsigned long wakeup_gran(struct sched_entity *se) |
| @@ -6746,7 +6755,7 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf · 170 unmodified lines | ||
| 6746 | 6755 | int new_tasks; |
| 6747 | 6756 | |
| 6748 | 6757 | again: |
| 6749 | − if (!cfs_rq->nr_running) | |
| 6758 | + if (!sched_fair_runnable(rq)) | |
| 6750 | 6759 | goto idle; |
| 6751 | 6760 | |
| 6752 | 6761 | #ifdef CONFIG_FAIR_GROUP_SCHED |
| @@ -6884,7 +6893,7 @@ idle: · 131 unmodified lines | ||
| 6884 | 6893 | /* |
| 6885 | 6894 | * Account for a descheduled task: |
| 6886 | 6895 | */ |
| 6887 | −static void put_prev_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) | |
| 6896 | +static void put_prev_task_fair(struct rq *rq, struct task_struct *prev) | |
| 6888 | 6897 | { |
| 6889 | 6898 | struct sched_entity *se = &prev->se; |
| 6890 | 6899 | struct cfs_rq *cfs_rq; |
| @@ -10414,11 +10423,11 @@ const struct sched_class fair_sched_class = { · 3523 unmodified lines | ||
| 10414 | 10423 | .check_preempt_curr = check_preempt_wakeup, |
| 10415 | 10424 | |
| 10416 | 10425 | .pick_next_task = pick_next_task_fair, |
| 10417 | − | |
| 10418 | 10426 | .put_prev_task = put_prev_task_fair, |
| 10419 | 10427 | .set_next_task = set_next_task_fair, |
| 10420 | 10428 | |
| 10421 | 10429 | #ifdef CONFIG_SMP |
| 10430 | + .balance = balance_fair, | |
| 10422 | 10431 | .select_task_rq = select_task_rq_fair, |
| 10423 | 10432 | .migrate_task_rq = migrate_task_rq_fair, |
| 10424 | 10433 | |
| @@ -365,6 +365,12 @@ select_task_rq_idle(struct task_struct *p, int cpu, int sd_flag, int flags) · 364 unmodified lines | ||
| 365 | 365 | { |
| 366 | 366 | return task_cpu(p); /* IDLE tasks as never migrated */ |
| 367 | 367 | } |
| 368 | + | |
| 369 | +static int | |
| 370 | +balance_idle(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) | |
| 371 | +{ | |
| 372 | + return WARN_ON_ONCE(1); | |
| 373 | +} | |
| 368 | 374 | #endif |
| 369 | 375 | |
| 370 | 376 | /* |
| @@ -375,7 +381,7 @@ static void check_preempt_curr_idle(struct rq *rq, struct task_struct *p, int fl · 4 unmodified lines | ||
| 375 | 381 | resched_curr(rq); |
| 376 | 382 | } |
| 377 | 383 | |
| 378 | −static void put_prev_task_idle(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) | |
| 384 | +static void put_prev_task_idle(struct rq *rq, struct task_struct *prev) | |
| 379 | 385 | { |
| 380 | 386 | } |
| 381 | 387 | |
| @@ -460,6 +466,7 @@ const struct sched_class idle_sched_class = { · 78 unmodified lines | ||
| 460 | 466 | .set_next_task = set_next_task_idle, |
| 461 | 467 | |
| 462 | 468 | #ifdef CONFIG_SMP |
| 469 | + .balance = balance_idle, | |
| 463 | 470 | .select_task_rq = select_task_rq_idle, |
| 464 | 471 | .set_cpus_allowed = set_cpus_allowed_common, |
| 465 | 472 | #endif |
| @@ -1469,6 +1469,22 @@ static void check_preempt_equal_prio(struct rq *rq, struct task_struct *p) · 1468 unmodified lines | ||
| 1469 | 1469 | resched_curr(rq); |
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | +static int balance_rt(struct rq *rq, struct task_struct *p, struct rq_flags *rf) | |
| 1473 | +{ | |
| 1474 | + if (!on_rt_rq(&p->rt) && need_pull_rt_task(rq, p)) { | |
| 1475 | + /* | |
| 1476 | + * This is OK, because current is on_cpu, which avoids it being | |
| 1477 | + * picked for load-balance and preemption/IRQs are still | |
| 1478 | + * disabled avoiding further scheduler activity on it and we've | |
| 1479 | + * not yet started the picking loop. | |
| 1480 | + */ | |
| 1481 | + rq_unpin_lock(rq, rf); | |
| 1482 | + pull_rt_task(rq); | |
| 1483 | + rq_repin_lock(rq, rf); | |
| 1484 | + } | |
| 1485 | + | |
| 1486 | + return sched_stop_runnable(rq) || sched_dl_runnable(rq) || sched_rt_runnable(rq); | |
| 1487 | +} | |
| 1472 | 1488 | #endif /* CONFIG_SMP */ |
| 1473 | 1489 | |
| 1474 | 1490 | /* |
| @@ -1552,21 +1568,18 @@ static struct task_struct * · 77 unmodified lines | ||
| 1552 | 1568 | pick_next_task_rt(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) |
| 1553 | 1569 | { |
| 1554 | 1570 | struct task_struct *p; |
| 1555 | − struct rt_rq *rt_rq = &rq->rt; | |
| 1556 | 1571 | |
| 1557 | 1572 | WARN_ON_ONCE(prev || rf); |
| 1558 | 1573 | |
| 1559 | − if (!rt_rq->rt_queued) | |
| 1574 | + if (!sched_rt_runnable(rq)) | |
| 1560 | 1575 | return NULL; |
| 1561 | 1576 | |
| 1562 | 1577 | p = _pick_next_task_rt(rq); |
| 1563 | − | |
| 1564 | 1578 | set_next_task_rt(rq, p); |
| 1565 | − | |
| 1566 | 1579 | return p; |
| 1567 | 1580 | } |
| 1568 | 1581 | |
| 1569 | −static void put_prev_task_rt(struct rq *rq, struct task_struct *p, struct rq_flags *rf) | |
| 1582 | +static void put_prev_task_rt(struct rq *rq, struct task_struct *p) | |
| 1570 | 1583 | { |
| 1571 | 1584 | update_curr_rt(rq); |
| 1572 | 1585 | |
| @@ -1578,18 +1591,6 @@ static void put_prev_task_rt(struct rq *rq, struct task_struct *p, struct rq_fla · 5 unmodified lines | ||
| 1578 | 1591 | */ |
| 1579 | 1592 | if (on_rt_rq(&p->rt) && p->nr_cpus_allowed > 1) |
| 1580 | 1593 | enqueue_pushable_task(rq, p); |
| 1581 | − | |
| 1582 | − if (rf && !on_rt_rq(&p->rt) && need_pull_rt_task(rq, p)) { | |
| 1583 | − /* | |
| 1584 | − * This is OK, because current is on_cpu, which avoids it being | |
| 1585 | − * picked for load-balance and preemption/IRQs are still | |
| 1586 | − * disabled avoiding further scheduler activity on it and we've | |
| 1587 | − * not yet started the picking loop. | |
| 1588 | − */ | |
| 1589 | − rq_unpin_lock(rq, rf); | |
| 1590 | − pull_rt_task(rq); | |
| 1591 | − rq_repin_lock(rq, rf); | |
| 1592 | − } | |
| 1593 | 1594 | } |
| 1594 | 1595 | |
| 1595 | 1596 | #ifdef CONFIG_SMP |
| @@ -2366,8 +2367,8 @@ const struct sched_class rt_sched_class = { · 770 unmodified lines | ||
| 2366 | 2367 | .set_next_task = set_next_task_rt, |
| 2367 | 2368 | |
| 2368 | 2369 | #ifdef CONFIG_SMP |
| 2370 | + .balance = balance_rt, | |
| 2369 | 2371 | .select_task_rq = select_task_rq_rt, |
| 2370 | − | |
| 2371 | 2372 | .set_cpus_allowed = set_cpus_allowed_common, |
| 2372 | 2373 | .rq_online = rq_online_rt, |
| 2373 | 2374 | .rq_offline = rq_offline_rt, |
| @@ -1727,10 +1727,11 @@ struct sched_class { · 1726 unmodified lines | ||
| 1727 | 1727 | struct task_struct * (*pick_next_task)(struct rq *rq, |
| 1728 | 1728 | struct task_struct *prev, |
| 1729 | 1729 | struct rq_flags *rf); |
| 1730 | − void (*put_prev_task)(struct rq *rq, struct task_struct *p, struct rq_flags *rf); | |
| 1730 | + void (*put_prev_task)(struct rq *rq, struct task_struct *p); | |
| 1731 | 1731 | void (*set_next_task)(struct rq *rq, struct task_struct *p); |
| 1732 | 1732 | |
| 1733 | 1733 | #ifdef CONFIG_SMP |
| 1734 | + int (*balance)(struct rq *rq, struct task_struct *prev, struct rq_flags *rf); | |
| 1734 | 1735 | int (*select_task_rq)(struct task_struct *p, int task_cpu, int sd_flag, int flags); |
| 1735 | 1736 | void (*migrate_task_rq)(struct task_struct *p, int new_cpu); |
| 1736 | 1737 | |
| @@ -1773,7 +1774,7 @@ struct sched_class { · 36 unmodified lines | ||
| 1773 | 1774 | static inline void put_prev_task(struct rq *rq, struct task_struct *prev) |
| 1774 | 1775 | { |
| 1775 | 1776 | WARN_ON_ONCE(rq->curr != prev); |
| 1776 | − prev->sched_class->put_prev_task(rq, prev, NULL); | |
| 1777 | + prev->sched_class->put_prev_task(rq, prev); | |
| 1777 | 1778 | } |
| 1778 | 1779 | |
| 1779 | 1780 | static inline void set_next_task(struct rq *rq, struct task_struct *next) |
| @@ -1787,8 +1788,12 @@ static inline void set_next_task(struct rq *rq, struct task_struct *next) · 7 unmodified lines | ||
| 1787 | 1788 | #else |
| 1788 | 1789 | #define sched_class_highest (&dl_sched_class) |
| 1789 | 1790 | #endif |
| 1791 | + | |
| 1792 | +#define for_class_range(class, _from, _to) \ | |
| 1793 | + for (class = (_from); class != (_to); class = class->next) | |
| 1794 | + | |
| 1790 | 1795 | #define for_each_class(class) \ |
| 1791 | − for (class = sched_class_highest; class; class = class->next) | |
| 1796 | + for_class_range(class, sched_class_highest, NULL) | |
| 1792 | 1797 | |
| 1793 | 1798 | extern const struct sched_class stop_sched_class; |
| 1794 | 1799 | extern const struct sched_class dl_sched_class; |
| @@ -1796,6 +1801,25 @@ extern const struct sched_class rt_sched_class; · 1 unmodified line | ||
| 1796 | 1801 | extern const struct sched_class fair_sched_class; |
| 1797 | 1802 | extern const struct sched_class idle_sched_class; |
| 1798 | 1803 | |
| 1804 | +static inline bool sched_stop_runnable(struct rq *rq) | |
| 1805 | +{ | |
| 1806 | + return rq->stop && task_on_rq_queued(rq->stop); | |
| 1807 | +} | |
| 1808 | + | |
| 1809 | +static inline bool sched_dl_runnable(struct rq *rq) | |
| 1810 | +{ | |
| 1811 | + return rq->dl.dl_nr_running > 0; | |
| 1812 | +} | |
| 1813 | + | |
| 1814 | +static inline bool sched_rt_runnable(struct rq *rq) | |
| 1815 | +{ | |
| 1816 | + return rq->rt.rt_queued > 0; | |
| 1817 | +} | |
| 1818 | + | |
| 1819 | +static inline bool sched_fair_runnable(struct rq *rq) | |
| 1820 | +{ | |
| 1821 | + return rq->cfs.nr_running > 0; | |
| 1822 | +} | |
| 1799 | 1823 | |
| 1800 | 1824 | #ifdef CONFIG_SMP |
| 1801 | 1825 | |
| @@ -15,6 +15,12 @@ select_task_rq_stop(struct task_struct *p, int cpu, int sd_flag, int flags) · 14 unmodified lines | ||
| 15 | 15 | { |
| 16 | 16 | return task_cpu(p); /* stop tasks as never migrate */ |
| 17 | 17 | } |
| 18 | + | |
| 19 | +static int | |
| 20 | +balance_stop(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) | |
| 21 | +{ | |
| 22 | + return sched_stop_runnable(rq); | |
| 23 | +} | |
| 18 | 24 | #endif /* CONFIG_SMP */ |
| 19 | 25 | |
| 20 | 26 | static void |
| @@ -31,16 +37,13 @@ static void set_next_task_stop(struct rq *rq, struct task_struct *stop) · 10 unmodified lines | ||
| 31 | 37 | static struct task_struct * |
| 32 | 38 | pick_next_task_stop(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) |
| 33 | 39 | { |
| 34 | − struct task_struct *stop = rq->stop; | |
| 35 | − | |
| 36 | 40 | WARN_ON_ONCE(prev || rf); |
| 37 | 41 | |
| 38 | − if (!stop || !task_on_rq_queued(stop)) | |
| 42 | + if (!sched_stop_runnable(rq)) | |
| 39 | 43 | return NULL; |
| 40 | 44 | |
| 41 | − set_next_task_stop(rq, stop); | |
| 42 | − | |
| 43 | − return stop; | |
| 45 | + set_next_task_stop(rq, rq->stop); | |
| 46 | + return rq->stop; | |
| 44 | 47 | } |
| 45 | 48 | |
| 46 | 49 | static void |
| @@ -60,7 +63,7 @@ static void yield_task_stop(struct rq *rq) · 13 unmodified lines | ||
| 60 | 63 | BUG(); /* the stop task should never yield, its pointless. */ |
| 61 | 64 | } |
| 62 | 65 | |
| 63 | −static void put_prev_task_stop(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) | |
| 66 | +static void put_prev_task_stop(struct rq *rq, struct task_struct *prev) | |
| 64 | 67 | { |
| 65 | 68 | struct task_struct *curr = rq->curr; |
| 66 | 69 | u64 delta_exec; |
| @@ -129,6 +132,7 @@ const struct sched_class stop_sched_class = { · 62 unmodified lines | ||
| 129 | 132 | .set_next_task = set_next_task_stop, |
| 130 | 133 | |
| 131 | 134 | #ifdef CONFIG_SMP |
| 135 | + .balance = balance_stop, | |
| 132 | 136 | .select_task_rq = select_task_rq_stop, |
| 133 | 137 | .set_cpus_allowed = set_cpus_allowed_common, |
| 134 | 138 | #endif |
| @@ -1948,7 +1948,7 @@ next_level: · 1947 unmodified lines | ||
| 1948 | 1948 | static int |
| 1949 | 1949 | build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *attr) |
| 1950 | 1950 | { |
| 1951 | − enum s_alloc alloc_state; | |
| 1951 | + enum s_alloc alloc_state = sa_none; | |
| 1952 | 1952 | struct sched_domain *sd; |
| 1953 | 1953 | struct s_data d; |
| 1954 | 1954 | struct rq *rq = NULL; |
| @@ -1956,6 +1956,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att · 1 unmodified line | ||
| 1956 | 1956 | struct sched_domain_topology_level *tl_asym; |
| 1957 | 1957 | bool has_asym = false; |
| 1958 | 1958 | |
| 1959 | + if (WARN_ON(cpumask_empty(cpu_map))) | |
| 1960 | + goto error; | |
| 1961 | + | |
| 1959 | 1962 | alloc_state = __visit_domain_allocation_hell(&d, cpu_map); |
| 1960 | 1963 | if (alloc_state != sa_rootdomain) |
| 1961 | 1964 | goto error; |
| @@ -2026,7 +2029,7 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att · 64 unmodified lines | ||
| 2026 | 2029 | rcu_read_unlock(); |
| 2027 | 2030 | |
| 2028 | 2031 | if (has_asym) |
| 2029 | − static_branch_enable_cpuslocked(&sched_asym_cpucapacity); | |
| 2032 | + static_branch_inc_cpuslocked(&sched_asym_cpucapacity); | |
| 2030 | 2033 | |
| 2031 | 2034 | if (rq && sched_debug_enabled) { |
| 2032 | 2035 | pr_info("root domain span: %*pbl (max cpu_capacity = %lu)\n", |
| @@ -2121,8 +2124,12 @@ int sched_init_domains(const struct cpumask *cpu_map) · 88 unmodified lines | ||
| 2121 | 2124 | */ |
| 2122 | 2125 | static void detach_destroy_domains(const struct cpumask *cpu_map) |
| 2123 | 2126 | { |
| 2127 | + unsigned int cpu = cpumask_any(cpu_map); | |
| 2124 | 2128 | int i; |
| 2125 | 2129 | |
| 2130 | + if (rcu_access_pointer(per_cpu(sd_asym_cpucapacity, cpu))) | |
| 2131 | + static_branch_dec_cpuslocked(&sched_asym_cpucapacity); | |
| 2132 | + | |
| 2126 | 2133 | rcu_read_lock(); |
| 2127 | 2134 | for_each_cpu(i, cpu_map) |
| 2128 | 2135 | cpu_attach_domain(NULL, &def_root_domain, i); |
| @@ -141,7 +141,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *tsk, unsigned long *store, · 140 unmodified lines | ||
| 141 | 141 | struct stacktrace_cookie c = { |
| 142 | 142 | .store = store, |
| 143 | 143 | .size = size, |
| 144 | − .skip = skipnr + 1, | |
| 144 | + /* skip this function if they are tracing us */ | |
| 145 | + .skip = skipnr + !!(current == tsk), | |
| 145 | 146 | }; |
| 146 | 147 | |
| 147 | 148 | if (!try_get_task_stack(tsk)) |
| @@ -298,7 +299,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *task, · 150 unmodified lines | ||
| 298 | 299 | struct stack_trace trace = { |
| 299 | 300 | .entries = store, |
| 300 | 301 | .max_entries = size, |
| 301 | − .skip = skipnr + 1, | |
| 302 | + /* skip this function if they are tracing us */ | |
| 303 | + .skip = skipnr + !!(current == task), | |
| 302 | 304 | }; |
| 303 | 305 | |
| 304 | 306 | save_stack_trace_tsk(task, &trace); |
| @@ -110,8 +110,7 @@ void update_vsyscall(struct timekeeper *tk) · 109 unmodified lines | ||
| 110 | 110 | nsec = nsec + tk->wall_to_monotonic.tv_nsec; |
| 111 | 111 | vdso_ts->sec += __iter_div_u64_rem(nsec, NSEC_PER_SEC, &vdso_ts->nsec); |
| 112 | 112 | |
| 113 | − if (__arch_use_vsyscall(vdata)) | |
| 114 | − update_vdso_data(vdata, tk); | |
| 113 | + update_vdso_data(vdata, tk); | |
| 115 | 114 | |
| 116 | 115 | __arch_update_vsyscall(vdata, tk); |
| 117 | 116 | |
| @@ -124,10 +123,8 @@ void update_vsyscall_tz(void) · 6 unmodified lines | ||
| 124 | 123 | { |
| 125 | 124 | struct vdso_data *vdata = __arch_get_k_vdso_data(); |
| 126 | 125 | |
| 127 | − if (__arch_use_vsyscall(vdata)) { | |
| 128 | − vdata[CS_HRES_COARSE].tz_minuteswest = sys_tz.tz_minuteswest; | |
| 129 | − vdata[CS_HRES_COARSE].tz_dsttime = sys_tz.tz_dsttime; | |
| 130 | − } | |
| 126 | + vdata[CS_HRES_COARSE].tz_minuteswest = sys_tz.tz_minuteswest; | |
| 127 | + vdata[CS_HRES_COARSE].tz_dsttime = sys_tz.tz_dsttime; | |
| 131 | 128 | |
| 132 | 129 | __arch_sync_vdso_data(vdata); |
| 133 | 130 | } |
| @@ -447,7 +447,6 @@ config ASSOCIATIVE_ARRAY · 446 unmodified lines | ||
| 447 | 447 | config HAS_IOMEM |
| 448 | 448 | bool |
| 449 | 449 | depends on !NO_IOMEM |
| 450 | − select GENERIC_IO | |
| 451 | 450 | default y |
| 452 | 451 | |
| 453 | 452 | config HAS_IOPORT_MAP |
| @@ -106,7 +106,12 @@ retry: · 105 unmodified lines | ||
| 106 | 106 | was_locked = 1; |
| 107 | 107 | } else { |
| 108 | 108 | local_irq_restore(flags); |
| 109 | − cpu_relax(); | |
| 109 | + /* | |
| 110 | + * Wait for the lock to release before jumping to | |
| 111 | + * atomic_cmpxchg() in order to mitigate the thundering herd | |
| 112 | + * problem. | |
| 113 | + */ | |
| 114 | + do { cpu_relax(); } while (atomic_read(&dump_lock) != -1); | |
| 110 | 115 | goto retry; |
| 111 | 116 | } |
| 112 | 117 | |
| @@ -215,7 +215,7 @@ int idr_for_each(const struct idr *idr, · 214 unmodified lines | ||
| 215 | 215 | EXPORT_SYMBOL(idr_for_each); |
| 216 | 216 | |
| 217 | 217 | /** |
| 218 | − * idr_get_next() - Find next populated entry. | |
| 218 | + * idr_get_next_ul() - Find next populated entry. | |
| 219 | 219 | * @idr: IDR handle. |
| 220 | 220 | * @nextid: Pointer to an ID. |
| 221 | 221 | * |
| @@ -224,7 +224,7 @@ EXPORT_SYMBOL(idr_for_each); · 2 unmodified lines | ||
| 224 | 224 | * to the ID of the found value. To use in a loop, the value pointed to by |
| 225 | 225 | * nextid must be incremented by the user. |
| 226 | 226 | */ |
| 227 | −void *idr_get_next(struct idr *idr, int *nextid) | |
| 227 | +void *idr_get_next_ul(struct idr *idr, unsigned long *nextid) | |
| 228 | 228 | { |
| 229 | 229 | struct radix_tree_iter iter; |
| 230 | 230 | void __rcu **slot; |
| @@ -245,18 +245,14 @@ void *idr_get_next(struct idr *idr, int *nextid) · 14 unmodified lines | ||
| 245 | 245 | } |
| 246 | 246 | if (!slot) |
| 247 | 247 | return NULL; |
| 248 | − id = iter.index + base; | |
| 249 | − | |
| 250 | − if (WARN_ON_ONCE(id > INT_MAX)) | |
| 251 | − return NULL; | |
| 252 | 248 | |
| 253 | − *nextid = id; | |
| 249 | + *nextid = iter.index + base; | |
| 254 | 250 | return entry; |
| 255 | 251 | } |
| 256 | −EXPORT_SYMBOL(idr_get_next); | |
| 252 | +EXPORT_SYMBOL(idr_get_next_ul); | |
| 257 | 253 | |
| 258 | 254 | /** |
| 259 | − * idr_get_next_ul() - Find next populated entry. | |
| 255 | + * idr_get_next() - Find next populated entry. | |
| 260 | 256 | * @idr: IDR handle. |
| 261 | 257 | * @nextid: Pointer to an ID. |
| 262 | 258 | * |
| @@ -265,22 +261,17 @@ EXPORT_SYMBOL(idr_get_next); · 2 unmodified lines | ||
| 265 | 261 | * to the ID of the found value. To use in a loop, the value pointed to by |
| 266 | 262 | * nextid must be incremented by the user. |
| 267 | 263 | */ |
| 268 | −void *idr_get_next_ul(struct idr *idr, unsigned long *nextid) | |
| 264 | +void *idr_get_next(struct idr *idr, int *nextid) | |
| 269 | 265 | { |
| 270 | − struct radix_tree_iter iter; | |
| 271 | − void __rcu **slot; | |
| 272 | − unsigned long base = idr->idr_base; | |
| 273 | 266 | unsigned long id = *nextid; |
| 267 | + void *entry = idr_get_next_ul(idr, &id); | |
| 274 | 268 | |
| 275 | − id = (id < base) ? 0 : id - base; | |
| 276 | − slot = radix_tree_iter_find(&idr->idr_rt, &iter, id); | |
| 277 | − if (!slot) | |
| 269 | + if (WARN_ON_ONCE(id > INT_MAX)) | |
| 278 | 270 | return NULL; |
| 279 | − | |
| 280 | − *nextid = iter.index + base; | |
| 281 | − return rcu_dereference_raw(*slot); | |
| 271 | + *nextid = id; | |
| 272 | + return entry; | |
| 282 | 273 | } |
| 283 | −EXPORT_SYMBOL(idr_get_next_ul); | |
| 274 | +EXPORT_SYMBOL(idr_get_next); | |
| 284 | 275 | |
| 285 | 276 | /** |
| 286 | 277 | * idr_replace() - replace pointer for given ID. |
| @@ -1529,7 +1529,7 @@ void __rcu **idr_get_free(struct radix_tree_root *root, · 1528 unmodified lines | ||
| 1529 | 1529 | offset = radix_tree_find_next_bit(node, IDR_FREE, |
| 1530 | 1530 | offset + 1); |
| 1531 | 1531 | start = next_index(start, node, offset); |
| 1532 | − if (start > max) | |
| 1532 | + if (start > max || start == 0) | |
| 1533 | 1533 | return ERR_PTR(-ENOSPC); |
| 1534 | 1534 | while (offset == RADIX_TREE_MAP_SIZE) { |
| 1535 | 1535 | offset = node->offset + 1; |
| @@ -1110,6 +1110,28 @@ static noinline void check_find_entry(struct xarray *xa) · 1109 unmodified lines | ||
| 1110 | 1110 | XA_BUG_ON(xa, !xa_empty(xa)); |
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | +static noinline void check_move_tiny(struct xarray *xa) | |
| 1114 | +{ | |
| 1115 | + XA_STATE(xas, xa, 0); | |
| 1116 | + | |
| 1117 | + XA_BUG_ON(xa, !xa_empty(xa)); | |
| 1118 | + rcu_read_lock(); | |
| 1119 | + XA_BUG_ON(xa, xas_next(&xas) != NULL); | |
| 1120 | + XA_BUG_ON(xa, xas_next(&xas) != NULL); | |
| 1121 | + rcu_read_unlock(); | |
| 1122 | + xa_store_index(xa, 0, GFP_KERNEL); | |
| 1123 | + rcu_read_lock(); | |
| 1124 | + xas_set(&xas, 0); | |
| 1125 | + XA_BUG_ON(xa, xas_next(&xas) != xa_mk_index(0)); | |
| 1126 | + XA_BUG_ON(xa, xas_next(&xas) != NULL); | |
| 1127 | + xas_set(&xas, 0); | |
| 1128 | + XA_BUG_ON(xa, xas_prev(&xas) != xa_mk_index(0)); | |
| 1129 | + XA_BUG_ON(xa, xas_prev(&xas) != NULL); | |
| 1130 | + rcu_read_unlock(); | |
| 1131 | + xa_erase_index(xa, 0); | |
| 1132 | + XA_BUG_ON(xa, !xa_empty(xa)); | |
| 1133 | +} | |
| 1134 | + | |
| 1113 | 1135 | static noinline void check_move_small(struct xarray *xa, unsigned long idx) |
| 1114 | 1136 | { |
| 1115 | 1137 | XA_STATE(xas, xa, 0); |
| @@ -1217,6 +1239,8 @@ static noinline void check_move(struct xarray *xa) · 101 unmodified lines | ||
| 1217 | 1239 | |
| 1218 | 1240 | xa_destroy(xa); |
| 1219 | 1241 | |
| 1242 | + check_move_tiny(xa); | |
| 1243 | + | |
| 1220 | 1244 | for (i = 0; i < 16; i++) |
| 1221 | 1245 | check_move_small(xa, 1UL << i); |
| 1222 | 1246 | |
| @@ -994,6 +994,8 @@ void *__xas_prev(struct xa_state *xas) · 993 unmodified lines | ||
| 994 | 994 | |
| 995 | 995 | if (!xas_frozen(xas->xa_node)) |
| 996 | 996 | xas->xa_index--; |
| 997 | + if (!xas->xa_node) | |
| 998 | + return set_bounds(xas); | |
| 997 | 999 | if (xas_not_node(xas->xa_node)) |
| 998 | 1000 | return xas_load(xas); |
| 999 | 1001 | |
| @@ -1031,6 +1033,8 @@ void *__xas_next(struct xa_state *xas) · 31 unmodified lines | ||
| 1031 | 1033 | |
| 1032 | 1034 | if (!xas_frozen(xas->xa_node)) |
| 1033 | 1035 | xas->xa_index++; |
| 1036 | + if (!xas->xa_node) | |
| 1037 | + return set_bounds(xas); | |
| 1034 | 1038 | if (xas_not_node(xas->xa_node)) |
| 1035 | 1039 | return xas_load(xas); |
| 1036 | 1040 | |
| @@ -1028,12 +1028,13 @@ static void collapse_huge_page(struct mm_struct *mm, · 1027 unmodified lines | ||
| 1028 | 1028 | |
| 1029 | 1029 | anon_vma_lock_write(vma->anon_vma); |
| 1030 | 1030 | |
| 1031 | − pte = pte_offset_map(pmd, address); | |
| 1032 | − pte_ptl = pte_lockptr(mm, pmd); | |
| 1033 | − | |
| 1034 | 1031 | mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, NULL, mm, |
| 1035 | 1032 | address, address + HPAGE_PMD_SIZE); |
| 1036 | 1033 | mmu_notifier_invalidate_range_start(&range); |
| 1034 | + | |
| 1035 | + pte = pte_offset_map(pmd, address); | |
| 1036 | + pte_ptl = pte_lockptr(mm, pmd); | |
| 1037 | + | |
| 1037 | 1038 | pmd_ptl = pmd_lock(mm, pmd); /* probably unnecessary */ |
| 1038 | 1039 | /* |
| 1039 | 1040 | * After this gup_fast can't run anymore. This also removes |
| @@ -484,7 +484,7 @@ ino_t page_cgroup_ino(struct page *page) · 483 unmodified lines | ||
| 484 | 484 | unsigned long ino = 0; |
| 485 | 485 | |
| 486 | 486 | rcu_read_lock(); |
| 487 | − if (PageHead(page) && PageSlab(page)) | |
| 487 | + if (PageSlab(page) && !PageTail(page)) | |
| 488 | 488 | memcg = memcg_from_slab_page(page); |
| 489 | 489 | else |
| 490 | 490 | memcg = READ_ONCE(page->mem_cgroup); |
| @@ -2534,6 +2534,15 @@ retry: · 2043 unmodified lines | ||
| 2534 | 2534 | goto retry; |
| 2535 | 2535 | } |
| 2536 | 2536 | |
| 2537 | + /* | |
| 2538 | + * Memcg doesn't have a dedicated reserve for atomic | |
| 2539 | + * allocations. But like the global atomic pool, we need to | |
| 2540 | + * put the burden of reclaim on regular allocation requests | |
| 2541 | + * and let these go through as privileged allocations. | |
| 2542 | + */ | |
| 2543 | + if (gfp_mask & __GFP_ATOMIC) | |
| 2544 | + goto force; | |
| 2545 | + | |
| 2537 | 2546 | /* |
| 2538 | 2547 | * Unlike in global OOM situations, memcg is not in a physical |
| 2539 | 2548 | * memory shortage. Allow dying and OOM-killed tasks to |
| @@ -5014,12 +5023,6 @@ static void __mem_cgroup_free(struct mem_cgroup *memcg) · 2474 unmodified lines | ||
| 5014 | 5023 | { |
| 5015 | 5024 | int node; |
| 5016 | 5025 | |
| 5017 | − /* | |
| 5018 | − * Flush percpu vmstats and vmevents to guarantee the value correctness | |
| 5019 | − * on parent's and all ancestor levels. | |
| 5020 | − */ | |
| 5021 | − memcg_flush_percpu_vmstats(memcg, false); | |
| 5022 | − memcg_flush_percpu_vmevents(memcg); | |
| 5023 | 5026 | for_each_node(node) |
| 5024 | 5027 | free_mem_cgroup_per_node_info(memcg, node); |
| 5025 | 5028 | free_percpu(memcg->vmstats_percpu); |
| @@ -5030,6 +5033,12 @@ static void __mem_cgroup_free(struct mem_cgroup *memcg) · 4 unmodified lines | ||
| 5030 | 5033 | static void mem_cgroup_free(struct mem_cgroup *memcg) |
| 5031 | 5034 | { |
| 5032 | 5035 | memcg_wb_domain_exit(memcg); |
| 5036 | + /* | |
| 5037 | + * Flush percpu vmstats and vmevents to guarantee the value correctness | |
| 5038 | + * on parent's and all ancestor levels. | |
| 5039 | + */ | |
| 5040 | + memcg_flush_percpu_vmstats(memcg, false); | |
| 5041 | + memcg_flush_percpu_vmevents(memcg); | |
| 5033 | 5042 | __mem_cgroup_free(memcg); |
| 5034 | 5043 | } |
| 5035 | 5044 | |
| @@ -447,6 +447,14 @@ static void update_pgdat_span(struct pglist_data *pgdat) · 446 unmodified lines | ||
| 447 | 447 | zone->spanned_pages; |
| 448 | 448 | |
| 449 | 449 | /* No need to lock the zones, they can't change. */ |
| 450 | + if (!zone->spanned_pages) | |
| 451 | + continue; | |
| 452 | + if (!node_end_pfn) { | |
| 453 | + node_start_pfn = zone->zone_start_pfn; | |
| 454 | + node_end_pfn = zone_end_pfn; | |
| 455 | + continue; | |
| 456 | + } | |
| 457 | + | |
| 450 | 458 | if (zone_end_pfn > node_end_pfn) |
| 451 | 459 | node_end_pfn = zone_end_pfn; |
| 452 | 460 | if (zone->zone_start_pfn < node_start_pfn) |
| @@ -180,7 +180,7 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) · 179 unmodified lines | ||
| 180 | 180 | mn->ops->invalidate_range_start, _ret, |
| 181 | 181 | !mmu_notifier_range_blockable(range) ? "non-" : ""); |
| 182 | 182 | WARN_ON(mmu_notifier_range_blockable(range) || |
| 183 | − ret != -EAGAIN); | |
| 183 | + _ret != -EAGAIN); | |
| 184 | 184 | ret = _ret; |
| 185 | 185 | } |
| 186 | 186 | } |
| @@ -1947,6 +1947,14 @@ void __init page_alloc_init_late(void) · 1946 unmodified lines | ||
| 1947 | 1947 | /* Block until all are initialised */ |
| 1948 | 1948 | wait_for_completion(&pgdat_init_all_done_comp); |
| 1949 | 1949 | |
| 1950 | + /* | |
| 1951 | + * The number of managed pages has changed due to the initialisation | |
| 1952 | + * so the pcpu batch and high limits needs to be updated or the limits | |
| 1953 | + * will be artificially small. | |
| 1954 | + */ | |
| 1955 | + for_each_populated_zone(zone) | |
| 1956 | + zone_pcp_update(zone); | |
| 1957 | + | |
| 1950 | 1958 | /* |
| 1951 | 1959 | * We initialized the rest of the deferred pages. Permanently disable |
| 1952 | 1960 | * on-demand struct page initialization. |
| @@ -3720,10 +3728,6 @@ try_this_zone: · 1767 unmodified lines | ||
| 3720 | 3728 | static void warn_alloc_show_mem(gfp_t gfp_mask, nodemask_t *nodemask) |
| 3721 | 3729 | { |
| 3722 | 3730 | unsigned int filter = SHOW_MEM_FILTER_NODES; |
| 3723 | − static DEFINE_RATELIMIT_STATE(show_mem_rs, HZ, 1); | |
| 3724 | − | |
| 3725 | − if (!__ratelimit(&show_mem_rs)) | |
| 3726 | − return; | |
| 3727 | 3731 | |
| 3728 | 3732 | /* |
| 3729 | 3733 | * This documents exceptions given to allocations in certain |
| @@ -3744,8 +3748,7 @@ void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...) · 14 unmodified lines | ||
| 3744 | 3748 | { |
| 3745 | 3749 | struct va_format vaf; |
| 3746 | 3750 | va_list args; |
| 3747 | − static DEFINE_RATELIMIT_STATE(nopage_rs, DEFAULT_RATELIMIT_INTERVAL, | |
| 3748 | − DEFAULT_RATELIMIT_BURST); | |
| 3751 | + static DEFINE_RATELIMIT_STATE(nopage_rs, 10*HZ, 1); | |
| 3749 | 3752 | |
| 3750 | 3753 | if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs)) |
| 3751 | 3754 | return; |
| @@ -8514,7 +8517,6 @@ void free_contig_range(unsigned long pfn, unsigned int nr_pages) · 4762 unmodified lines | ||
| 8514 | 8517 | WARN(count != 0, "%d pages are still in use!\n", count); |
| 8515 | 8518 | } |
| 8516 | 8519 | |
| 8517 | −#ifdef CONFIG_MEMORY_HOTPLUG | |
| 8518 | 8520 | /* |
| 8519 | 8521 | * The zone indicated has a new number of managed_pages; batch sizes and percpu |
| 8520 | 8522 | * page high values need to be recalulated. |
| @@ -8528,7 +8530,6 @@ void __meminit zone_pcp_update(struct zone *zone) · 7 unmodified lines | ||
| 8528 | 8530 | per_cpu_ptr(zone->pageset, cpu)); |
| 8529 | 8531 | mutex_unlock(&pcp_batch_high_lock); |
| 8530 | 8532 | } |
| 8531 | −#endif | |
| 8532 | 8533 | |
| 8533 | 8534 | void zone_pcp_reset(struct zone *zone) |
| 8534 | 8535 | { |
| @@ -323,8 +323,8 @@ static inline struct kmem_cache *memcg_root_cache(struct kmem_cache *s) · 322 unmodified lines | ||
| 323 | 323 | * Expects a pointer to a slab page. Please note, that PageSlab() check |
| 324 | 324 | * isn't sufficient, as it returns true also for tail compound slab pages, |
| 325 | 325 | * which do not have slab_cache pointer set. |
| 326 | − * So this function assumes that the page can pass PageHead() and PageSlab() | |
| 327 | − * checks. | |
| 326 | + * So this function assumes that the page can pass PageSlab() && !PageTail() | |
| 327 | + * check. | |
| 328 | 328 | * |
| 329 | 329 | * The kmem_cache can be reparented asynchronously. The caller must ensure |
| 330 | 330 | * the memcg lifetime, e.g. by taking rcu_read_lock() or cgroup_mutex. |
| @@ -1383,12 +1383,29 @@ static void pagetypeinfo_showfree_print(struct seq_file *m, · 1382 unmodified lines | ||
| 1383 | 1383 | unsigned long freecount = 0; |
| 1384 | 1384 | struct free_area *area; |
| 1385 | 1385 | struct list_head *curr; |
| 1386 | + bool overflow = false; | |
| 1386 | 1387 | |
| 1387 | 1388 | area = &(zone->free_area[order]); |
| 1388 | 1389 | |
| 1389 | − list_for_each(curr, &area->free_list[mtype]) | |
| 1390 | − freecount++; | |
| 1391 | − seq_printf(m, "%6lu ", freecount); | |
| 1390 | + list_for_each(curr, &area->free_list[mtype]) { | |
| 1391 | + /* | |
| 1392 | + * Cap the free_list iteration because it might | |
| 1393 | + * be really large and we are under a spinlock | |
| 1394 | + * so a long time spent here could trigger a | |
| 1395 | + * hard lockup detector. Anyway this is a | |
| 1396 | + * debugging tool so knowing there is a handful | |
| 1397 | + * of pages of this order should be more than | |
| 1398 | + * sufficient. | |
| 1399 | + */ | |
| 1400 | + if (++freecount >= 100000) { | |
| 1401 | + overflow = true; | |
| 1402 | + break; | |
| 1403 | + } | |
| 1404 | + } | |
| 1405 | + seq_printf(m, "%s%6lu ", overflow ? ">" : "", freecount); | |
| 1406 | + spin_unlock_irq(&zone->lock); | |
| 1407 | + cond_resched(); | |
| 1408 | + spin_lock_irq(&zone->lock); | |
| 1392 | 1409 | } |
| 1393 | 1410 | seq_putc(m, '\n'); |
| 1394 | 1411 | } |
| @@ -1972,7 +1989,7 @@ void __init init_mm_internals(void) · 577 unmodified lines | ||
| 1972 | 1989 | #endif |
| 1973 | 1990 | #ifdef CONFIG_PROC_FS |
| 1974 | 1991 | proc_create_seq("buddyinfo", 0444, NULL, &fragmentation_op); |
| 1975 | − proc_create_seq("pagetypeinfo", 0444, NULL, &pagetypeinfo_op); | |
| 1992 | + proc_create_seq("pagetypeinfo", 0400, NULL, &pagetypeinfo_op); | |
| 1976 | 1993 | proc_create_seq("vmstat", 0444, NULL, &vmstat_op); |
| 1977 | 1994 | proc_create_seq("zoneinfo", 0444, NULL, &zoneinfo_op); |
| 1978 | 1995 | #endif |
| @@ -172,7 +172,6 @@ int register_vlan_dev(struct net_device *dev, struct netlink_ext_ack *extack) · 171 unmodified lines | ||
| 172 | 172 | if (err < 0) |
| 173 | 173 | goto out_uninit_mvrp; |
| 174 | 174 | |
| 175 | − vlan->nest_level = dev_get_nest_level(real_dev) + 1; | |
| 176 | 175 | err = register_netdevice(dev); |
| 177 | 176 | if (err < 0) |
| 178 | 177 | goto out_uninit_mvrp; |
| @@ -489,36 +489,6 @@ static void vlan_dev_set_rx_mode(struct net_device *vlan_dev) · 488 unmodified lines | ||
| 489 | 489 | dev_uc_sync(vlan_dev_priv(vlan_dev)->real_dev, vlan_dev); |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | −/* | |
| 493 | − * vlan network devices have devices nesting below it, and are a special | |
| 494 | − * "super class" of normal network devices; split their locks off into a | |
| 495 | − * separate class since they always nest. | |
| 496 | − */ | |
| 497 | −static struct lock_class_key vlan_netdev_xmit_lock_key; | |
| 498 | −static struct lock_class_key vlan_netdev_addr_lock_key; | |
| 499 | − | |
| 500 | −static void vlan_dev_set_lockdep_one(struct net_device *dev, | |
| 501 | − struct netdev_queue *txq, | |
| 502 | − void *_subclass) | |
| 503 | −{ | |
| 504 | − lockdep_set_class_and_subclass(&txq->_xmit_lock, | |
| 505 | − &vlan_netdev_xmit_lock_key, | |
| 506 | − *(int *)_subclass); | |
| 507 | −} | |
| 508 | − | |
| 509 | −static void vlan_dev_set_lockdep_class(struct net_device *dev, int subclass) | |
| 510 | −{ | |
| 511 | − lockdep_set_class_and_subclass(&dev->addr_list_lock, | |
| 512 | − &vlan_netdev_addr_lock_key, | |
| 513 | − subclass); | |
| 514 | − netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, &subclass); | |
| 515 | −} | |
| 516 | − | |
| 517 | −static int vlan_dev_get_lock_subclass(struct net_device *dev) | |
| 518 | −{ | |
| 519 | − return vlan_dev_priv(dev)->nest_level; | |
| 520 | −} | |
| 521 | − | |
| 522 | 492 | static const struct header_ops vlan_header_ops = { |
| 523 | 493 | .create = vlan_dev_hard_header, |
| 524 | 494 | .parse = eth_header_parse, |
| @@ -609,8 +579,6 @@ static int vlan_dev_init(struct net_device *dev) · 84 unmodified lines | ||
| 609 | 579 | |
| 610 | 580 | SET_NETDEV_DEVTYPE(dev, &vlan_type); |
| 611 | 581 | |
| 612 | − vlan_dev_set_lockdep_class(dev, vlan_dev_get_lock_subclass(dev)); | |
| 613 | − | |
| 614 | 582 | vlan->vlan_pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats); |
| 615 | 583 | if (!vlan->vlan_pcpu_stats) |
| 616 | 584 | return -ENOMEM; |
| @@ -812,7 +780,6 @@ static const struct net_device_ops vlan_netdev_ops = { · 195 unmodified lines | ||
| 812 | 780 | .ndo_netpoll_cleanup = vlan_dev_netpoll_cleanup, |
| 813 | 781 | #endif |
| 814 | 782 | .ndo_fix_features = vlan_dev_fix_features, |
| 815 | − .ndo_get_lock_subclass = vlan_dev_get_lock_subclass, | |
| 816 | 783 | .ndo_get_iflink = vlan_dev_get_iflink, |
| 817 | 784 | }; |
| 818 | 785 | |
| @@ -668,7 +668,7 @@ __poll_t vcc_poll(struct file *file, struct socket *sock, poll_table *wait) · 667 unmodified lines | ||
| 668 | 668 | mask |= EPOLLHUP; |
| 669 | 669 | |
| 670 | 670 | /* readable? */ |
| 671 | − if (!skb_queue_empty(&sk->sk_receive_queue)) | |
| 671 | + if (!skb_queue_empty_lockless(&sk->sk_receive_queue)) | |
| 672 | 672 | mask |= EPOLLIN | EPOLLRDNORM; |
| 673 | 673 | |
| 674 | 674 | /* writable? */ |
| @@ -22,6 +22,8 @@ · 21 unmodified lines | ||
| 22 | 22 | #include <linux/kernel.h> |
| 23 | 23 | #include <linux/kref.h> |
| 24 | 24 | #include <linux/list.h> |
| 25 | +#include <linux/lockdep.h> | |
| 26 | +#include <linux/mutex.h> | |
| 25 | 27 | #include <linux/netdevice.h> |
| 26 | 28 | #include <linux/netlink.h> |
| 27 | 29 | #include <linux/pkt_sched.h> |
| @@ -193,14 +195,18 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface) · 165 unmodified lines | ||
| 193 | 195 | unsigned char *ogm_buff; |
| 194 | 196 | u32 random_seqno; |
| 195 | 197 | |
| 198 | + mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 199 | + | |
| 196 | 200 | /* randomize initial seqno to avoid collision */ |
| 197 | 201 | get_random_bytes(&random_seqno, sizeof(random_seqno)); |
| 198 | 202 | atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno); |
| 199 | 203 | |
| 200 | 204 | hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN; |
| 201 | 205 | ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC); |
| 202 | − if (!ogm_buff) | |
| 206 | + if (!ogm_buff) { | |
| 207 | + mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 203 | 208 | return -ENOMEM; |
| 209 | + } | |
| 204 | 210 | |
| 205 | 211 | hard_iface->bat_iv.ogm_buff = ogm_buff; |
| 206 | 212 | |
| @@ -212,35 +218,59 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface) · 5 unmodified lines | ||
| 212 | 218 | batadv_ogm_packet->reserved = 0; |
| 213 | 219 | batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE; |
| 214 | 220 | |
| 221 | + mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 222 | + | |
| 215 | 223 | return 0; |
| 216 | 224 | } |
| 217 | 225 | |
| 218 | 226 | static void batadv_iv_ogm_iface_disable(struct batadv_hard_iface *hard_iface) |
| 219 | 227 | { |
| 228 | + mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 229 | + | |
| 220 | 230 | kfree(hard_iface->bat_iv.ogm_buff); |
| 221 | 231 | hard_iface->bat_iv.ogm_buff = NULL; |
| 232 | + | |
| 233 | + mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 222 | 234 | } |
| 223 | 235 | |
| 224 | 236 | static void batadv_iv_ogm_iface_update_mac(struct batadv_hard_iface *hard_iface) |
| 225 | 237 | { |
| 226 | 238 | struct batadv_ogm_packet *batadv_ogm_packet; |
| 227 | − unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff; | |
| 239 | + void *ogm_buff; | |
| 228 | 240 | |
| 229 | − batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff; | |
| 241 | + mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 242 | + | |
| 243 | + ogm_buff = hard_iface->bat_iv.ogm_buff; | |
| 244 | + if (!ogm_buff) | |
| 245 | + goto unlock; | |
| 246 | + | |
| 247 | + batadv_ogm_packet = ogm_buff; | |
| 230 | 248 | ether_addr_copy(batadv_ogm_packet->orig, |
| 231 | 249 | hard_iface->net_dev->dev_addr); |
| 232 | 250 | ether_addr_copy(batadv_ogm_packet->prev_sender, |
| 233 | 251 | hard_iface->net_dev->dev_addr); |
| 252 | + | |
| 253 | +unlock: | |
| 254 | + mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 234 | 255 | } |
| 235 | 256 | |
| 236 | 257 | static void |
| 237 | 258 | batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface) |
| 238 | 259 | { |
| 239 | 260 | struct batadv_ogm_packet *batadv_ogm_packet; |
| 240 | − unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff; | |
| 261 | + void *ogm_buff; | |
| 241 | 262 | |
| 242 | − batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff; | |
| 263 | + mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 264 | + | |
| 265 | + ogm_buff = hard_iface->bat_iv.ogm_buff; | |
| 266 | + if (!ogm_buff) | |
| 267 | + goto unlock; | |
| 268 | + | |
| 269 | + batadv_ogm_packet = ogm_buff; | |
| 243 | 270 | batadv_ogm_packet->ttl = BATADV_TTL; |
| 271 | + | |
| 272 | +unlock: | |
| 273 | + mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 244 | 274 | } |
| 245 | 275 | |
| 246 | 276 | /* when do we schedule our own ogm to be sent */ |
| @@ -742,7 +772,11 @@ batadv_iv_ogm_slide_own_bcast_window(struct batadv_hard_iface *hard_iface) · 495 unmodified lines | ||
| 742 | 772 | } |
| 743 | 773 | } |
| 744 | 774 | |
| 745 | −static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) | |
| 775 | +/** | |
| 776 | + * batadv_iv_ogm_schedule_buff() - schedule submission of hardif ogm buffer | |
| 777 | + * @hard_iface: interface whose ogm buffer should be transmitted | |
| 778 | + */ | |
| 779 | +static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface) | |
| 746 | 780 | { |
| 747 | 781 | struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); |
| 748 | 782 | unsigned char **ogm_buff = &hard_iface->bat_iv.ogm_buff; |
| @@ -753,9 +787,7 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) · 4 unmodified lines | ||
| 753 | 787 | u16 tvlv_len = 0; |
| 754 | 788 | unsigned long send_time; |
| 755 | 789 | |
| 756 | − if (hard_iface->if_status == BATADV_IF_NOT_IN_USE || | |
| 757 | − hard_iface->if_status == BATADV_IF_TO_BE_REMOVED) | |
| 758 | − return; | |
| 790 | + lockdep_assert_held(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 759 | 791 | |
| 760 | 792 | /* the interface gets activated here to avoid race conditions between |
| 761 | 793 | * the moment of activating the interface in |
| @@ -823,6 +855,17 @@ out: · 61 unmodified lines | ||
| 823 | 855 | batadv_hardif_put(primary_if); |
| 824 | 856 | } |
| 825 | 857 | |
| 858 | +static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) | |
| 859 | +{ | |
| 860 | + if (hard_iface->if_status == BATADV_IF_NOT_IN_USE || | |
| 861 | + hard_iface->if_status == BATADV_IF_TO_BE_REMOVED) | |
| 862 | + return; | |
| 863 | + | |
| 864 | + mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 865 | + batadv_iv_ogm_schedule_buff(hard_iface); | |
| 866 | + mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 867 | +} | |
| 868 | + | |
| 826 | 869 | /** |
| 827 | 870 | * batadv_iv_orig_ifinfo_sum() - Get bcast_own sum for originator over iterface |
| 828 | 871 | * @orig_node: originator which reproadcasted the OGMs directly |
| @@ -18,6 +18,7 @@ · 17 unmodified lines | ||
| 18 | 18 | #include <linux/kref.h> |
| 19 | 19 | #include <linux/list.h> |
| 20 | 20 | #include <linux/lockdep.h> |
| 21 | +#include <linux/mutex.h> | |
| 21 | 22 | #include <linux/netdevice.h> |
| 22 | 23 | #include <linux/random.h> |
| 23 | 24 | #include <linux/rculist.h> |
| @@ -256,14 +257,12 @@ static void batadv_v_ogm_queue_on_if(struct sk_buff *skb, · 232 unmodified lines | ||
| 256 | 257 | } |
| 257 | 258 | |
| 258 | 259 | /** |
| 259 | − * batadv_v_ogm_send() - periodic worker broadcasting the own OGM | |
| 260 | − * @work: work queue item | |
| 260 | + * batadv_v_ogm_send_softif() - periodic worker broadcasting the own OGM | |
| 261 | + * @bat_priv: the bat priv with all the soft interface information | |
| 261 | 262 | */ |
| 262 | −static void batadv_v_ogm_send(struct work_struct *work) | |
| 263 | +static void batadv_v_ogm_send_softif(struct batadv_priv *bat_priv) | |
| 263 | 264 | { |
| 264 | 265 | struct batadv_hard_iface *hard_iface; |
| 265 | − struct batadv_priv_bat_v *bat_v; | |
| 266 | − struct batadv_priv *bat_priv; | |
| 267 | 266 | struct batadv_ogm2_packet *ogm_packet; |
| 268 | 267 | struct sk_buff *skb, *skb_tmp; |
| 269 | 268 | unsigned char *ogm_buff; |
| @@ -271,8 +270,7 @@ static void batadv_v_ogm_send(struct work_struct *work) · 1 unmodified line | ||
| 271 | 270 | u16 tvlv_len = 0; |
| 272 | 271 | int ret; |
| 273 | 272 | |
| 274 | − bat_v = container_of(work, struct batadv_priv_bat_v, ogm_wq.work); | |
| 275 | − bat_priv = container_of(bat_v, struct batadv_priv, bat_v); | |
| 273 | + lockdep_assert_held(&bat_priv->bat_v.ogm_buff_mutex); | |
| 276 | 274 | |
| 277 | 275 | if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) |
| 278 | 276 | goto out; |
| @@ -363,6 +361,23 @@ out: · 84 unmodified lines | ||
| 363 | 361 | return; |
| 364 | 362 | } |
| 365 | 363 | |
| 364 | +/** | |
| 365 | + * batadv_v_ogm_send() - periodic worker broadcasting the own OGM | |
| 366 | + * @work: work queue item | |
| 367 | + */ | |
| 368 | +static void batadv_v_ogm_send(struct work_struct *work) | |
| 369 | +{ | |
| 370 | + struct batadv_priv_bat_v *bat_v; | |
| 371 | + struct batadv_priv *bat_priv; | |
| 372 | + | |
| 373 | + bat_v = container_of(work, struct batadv_priv_bat_v, ogm_wq.work); | |
| 374 | + bat_priv = container_of(bat_v, struct batadv_priv, bat_v); | |
| 375 | + | |
| 376 | + mutex_lock(&bat_priv->bat_v.ogm_buff_mutex); | |
| 377 | + batadv_v_ogm_send_softif(bat_priv); | |
| 378 | + mutex_unlock(&bat_priv->bat_v.ogm_buff_mutex); | |
| 379 | +} | |
| 380 | + | |
| 366 | 381 | /** |
| 367 | 382 | * batadv_v_ogm_aggr_work() - OGM queue periodic task per interface |
| 368 | 383 | * @work: work queue item |
| @@ -424,11 +439,15 @@ void batadv_v_ogm_primary_iface_set(struct batadv_hard_iface *primary_iface) · 55 unmodified lines | ||
| 424 | 439 | struct batadv_priv *bat_priv = netdev_priv(primary_iface->soft_iface); |
| 425 | 440 | struct batadv_ogm2_packet *ogm_packet; |
| 426 | 441 | |
| 442 | + mutex_lock(&bat_priv->bat_v.ogm_buff_mutex); | |
| 427 | 443 | if (!bat_priv->bat_v.ogm_buff) |
| 428 | − return; | |
| 444 | + goto unlock; | |
| 429 | 445 | |
| 430 | 446 | ogm_packet = (struct batadv_ogm2_packet *)bat_priv->bat_v.ogm_buff; |
| 431 | 447 | ether_addr_copy(ogm_packet->orig, primary_iface->net_dev->dev_addr); |
| 448 | + | |
| 449 | +unlock: | |
| 450 | + mutex_unlock(&bat_priv->bat_v.ogm_buff_mutex); | |
| 432 | 451 | } |
| 433 | 452 | |
| 434 | 453 | /** |
| @@ -1050,6 +1069,8 @@ int batadv_v_ogm_init(struct batadv_priv *bat_priv) · 615 unmodified lines | ||
| 1050 | 1069 | atomic_set(&bat_priv->bat_v.ogm_seqno, random_seqno); |
| 1051 | 1070 | INIT_DELAYED_WORK(&bat_priv->bat_v.ogm_wq, batadv_v_ogm_send); |
| 1052 | 1071 | |
| 1072 | + mutex_init(&bat_priv->bat_v.ogm_buff_mutex); | |
| 1073 | + | |
| 1053 | 1074 | return 0; |
| 1054 | 1075 | } |
| 1055 | 1076 | |
| @@ -1061,7 +1082,11 @@ void batadv_v_ogm_free(struct batadv_priv *bat_priv) · 5 unmodified lines | ||
| 1061 | 1082 | { |
| 1062 | 1083 | cancel_delayed_work_sync(&bat_priv->bat_v.ogm_wq); |
| 1063 | 1084 | |
| 1085 | + mutex_lock(&bat_priv->bat_v.ogm_buff_mutex); | |
| 1086 | + | |
| 1064 | 1087 | kfree(bat_priv->bat_v.ogm_buff); |
| 1065 | 1088 | bat_priv->bat_v.ogm_buff = NULL; |
| 1066 | 1089 | bat_priv->bat_v.ogm_buff_len = 0; |
| 1090 | + | |
| 1091 | + mutex_unlock(&bat_priv->bat_v.ogm_buff_mutex); | |
| 1067 | 1092 | } |
| @@ -18,6 +18,7 @@ · 17 unmodified lines | ||
| 18 | 18 | #include <linux/kref.h> |
| 19 | 19 | #include <linux/limits.h> |
| 20 | 20 | #include <linux/list.h> |
| 21 | +#include <linux/mutex.h> | |
| 21 | 22 | #include <linux/netdevice.h> |
| 22 | 23 | #include <linux/printk.h> |
| 23 | 24 | #include <linux/rculist.h> |
| @@ -929,6 +930,7 @@ batadv_hardif_add_interface(struct net_device *net_dev) · 905 unmodified lines | ||
| 929 | 930 | INIT_LIST_HEAD(&hard_iface->list); |
| 930 | 931 | INIT_HLIST_HEAD(&hard_iface->neigh_list); |
| 931 | 932 | |
| 933 | + mutex_init(&hard_iface->bat_iv.ogm_buff_mutex); | |
| 932 | 934 | spin_lock_init(&hard_iface->neigh_list_lock); |
| 933 | 935 | kref_init(&hard_iface->refcount); |
| 934 | 936 | |
| @@ -740,36 +740,6 @@ static int batadv_interface_kill_vid(struct net_device *dev, __be16 proto, · 739 unmodified lines | ||
| 740 | 740 | return 0; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | −/* batman-adv network devices have devices nesting below it and are a special | |
| 744 | − * "super class" of normal network devices; split their locks off into a | |
| 745 | − * separate class since they always nest. | |
| 746 | − */ | |
| 747 | −static struct lock_class_key batadv_netdev_xmit_lock_key; | |
| 748 | −static struct lock_class_key batadv_netdev_addr_lock_key; | |
| 749 | − | |
| 750 | −/** | |
| 751 | − * batadv_set_lockdep_class_one() - Set lockdep class for a single tx queue | |
| 752 | − * @dev: device which owns the tx queue | |
| 753 | − * @txq: tx queue to modify | |
| 754 | − * @_unused: always NULL | |
| 755 | − */ | |
| 756 | −static void batadv_set_lockdep_class_one(struct net_device *dev, | |
| 757 | − struct netdev_queue *txq, | |
| 758 | − void *_unused) | |
| 759 | −{ | |
| 760 | − lockdep_set_class(&txq->_xmit_lock, &batadv_netdev_xmit_lock_key); | |
| 761 | −} | |
| 762 | − | |
| 763 | −/** | |
| 764 | − * batadv_set_lockdep_class() - Set txq and addr_list lockdep class | |
| 765 | − * @dev: network device to modify | |
| 766 | − */ | |
| 767 | −static void batadv_set_lockdep_class(struct net_device *dev) | |
| 768 | −{ | |
| 769 | − lockdep_set_class(&dev->addr_list_lock, &batadv_netdev_addr_lock_key); | |
| 770 | − netdev_for_each_tx_queue(dev, batadv_set_lockdep_class_one, NULL); | |
| 771 | −} | |
| 772 | − | |
| 773 | 743 | /** |
| 774 | 744 | * batadv_softif_init_late() - late stage initialization of soft interface |
| 775 | 745 | * @dev: registered network device to modify |
| @@ -783,8 +753,6 @@ static int batadv_softif_init_late(struct net_device *dev) · 7 unmodified lines | ||
| 783 | 753 | int ret; |
| 784 | 754 | size_t cnt_len = sizeof(u64) * BATADV_CNT_NUM; |
| 785 | 755 | |
| 786 | − batadv_set_lockdep_class(dev); | |
| 787 | − | |
| 788 | 756 | bat_priv = netdev_priv(dev); |
| 789 | 757 | bat_priv->soft_iface = dev; |
| 790 | 758 | |
| @@ -17,6 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | #include <linux/if.h> |
| 18 | 18 | #include <linux/if_ether.h> |
25 more lines aren’t shown here.
This diff is large: its 16 lines aren’t shown here.
This diff is large: its 18 lines aren’t shown here.
This diff is large: its 29 lines aren’t shown here.
This diff is large: its 34 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 32 lines aren’t shown here.
This diff is large: its 37 lines aren’t shown here.
This diff is large: its 36 lines aren’t shown here.
This diff is large: its 827 lines aren’t shown here.
This diff is large: its 54 lines aren’t shown here.
This diff is large: its 15 lines aren’t shown here.
This diff is large: its 105 lines aren’t shown here.
This diff is large: its 18 lines aren’t shown here.
This diff is large: its 77 lines aren’t shown here.
This diff is large: its 80 lines aren’t shown here.
This diff is large: its 34 lines aren’t shown here.
This diff is large: its 27 lines aren’t shown here.
This diff is large: its 18 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 19 lines aren’t shown here.
This diff is large: its 26 lines aren’t shown here.
This diff is large: its 22 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 43 lines aren’t shown here.
This diff is large: its 18 lines aren’t shown here.
This diff is large: its 27 lines aren’t shown here.
This diff is large: its 78 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 45 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 133 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 32 lines aren’t shown here.
This diff is large: its 98 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 39 lines aren’t shown here.
This diff is large: its 17 lines aren’t shown here.
This diff is large: its 28 lines aren’t shown here.
This diff is large: its 19 lines aren’t shown here.
This diff is large: its 16 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 104 lines aren’t shown here.
This diff is large: its 37 lines aren’t shown here.
This diff is large: its 14 lines aren’t shown here.
This diff is large: its 16 lines aren’t shown here.
This diff is large: its 79 lines aren’t shown here.
This diff is large: its 40 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 37 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 90 lines aren’t shown here.
This diff is large: its 164 lines aren’t shown here.
This diff is large: its 23 lines aren’t shown here.
This diff is large: its 50 lines aren’t shown here.
This diff is large: its 40 lines aren’t shown here.
This diff is large: its 49 lines aren’t shown here.
This diff is large: its 58 lines aren’t shown here.
This diff is large: its 28 lines aren’t shown here.
This diff is large: its 36 lines aren’t shown here.
This diff is large: its 49 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 18 lines aren’t shown here.
This diff is large: its 36 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 16 lines aren’t shown here.
This diff is large: its 18 lines aren’t shown here.
This diff is large: its 55 lines aren’t shown here.
This diff is large: its 16 lines aren’t shown here.
This diff is large: its 86 lines aren’t shown here.
This diff is large: its 27 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 15 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 20 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 16 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 107 lines aren’t shown here.
This diff is large: its 17 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 11 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 79 lines aren’t shown here.
This diff is large: its 53 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
This diff is large: its 47 lines aren’t shown here.
This diff is large: its 14 lines aren’t shown here.
This diff is large: its 18 lines aren’t shown here.
This diff is large: its 39 lines aren’t shown here.
This diff is large: its 16 lines aren’t shown here.
This diff is large: its 13 lines aren’t shown here.
This diff is large: its 13 lines aren’t shown here.
This diff is large: its 18 lines aren’t shown here.
This diff is large: its 12 lines aren’t shown here.
This diff is large: its 22 lines aren’t shown here.
This diff is large: its 26 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 13 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 20 lines aren’t shown here.
This diff is large: its 24 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 28 lines aren’t shown here.
File mode changed from 100644 to 100755.
This diff is large: its 17 lines aren’t shown here.
This diff is large: its 115 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 21 lines aren’t shown here.
This diff is large: its 88 lines aren’t shown here.