Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge 6.2-rc3 into usb-next

We need the USB fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+7418 -2105
+1
.gitignore
··· 39 39 *.o.* 40 40 *.patch 41 41 *.rmeta 42 + *.rpm 42 43 *.rsi 43 44 *.s 44 45 *.so
+18
Documentation/ABI/testing/debugfs-pktcdvd
··· 1 + What: /sys/kernel/debug/pktcdvd/pktcdvd[0-7] 2 + Date: Oct. 2006 3 + KernelVersion: 2.6.20 4 + Contact: Thomas Maier <balagi@justmail.de> 5 + Description: 6 + 7 + The pktcdvd module (packet writing driver) creates 8 + these files in debugfs: 9 + 10 + /sys/kernel/debug/pktcdvd/pktcdvd[0-7]/ 11 + 12 + ==== ====== ==================================== 13 + info 0444 Lots of driver statistics and infos. 14 + ==== ====== ==================================== 15 + 16 + Example:: 17 + 18 + cat /sys/kernel/debug/pktcdvd/pktcdvd0/info
+97
Documentation/ABI/testing/sysfs-class-pktcdvd
··· 1 + sysfs interface 2 + --------------- 3 + The pktcdvd module (packet writing driver) creates the following files in the 4 + sysfs: (<devid> is in the format major:minor) 5 + 6 + What: /sys/class/pktcdvd/add 7 + What: /sys/class/pktcdvd/remove 8 + What: /sys/class/pktcdvd/device_map 9 + Date: Oct. 2006 10 + KernelVersion: 2.6.20 11 + Contact: Thomas Maier <balagi@justmail.de> 12 + Description: 13 + 14 + ========== ============================================== 15 + add (WO) Write a block device id (major:minor) to 16 + create a new pktcdvd device and map it to the 17 + block device. 18 + 19 + remove (WO) Write the pktcdvd device id (major:minor) 20 + to remove the pktcdvd device. 21 + 22 + device_map (RO) Shows the device mapping in format: 23 + pktcdvd[0-7] <pktdevid> <blkdevid> 24 + ========== ============================================== 25 + 26 + 27 + What: /sys/class/pktcdvd/pktcdvd[0-7]/dev 28 + What: /sys/class/pktcdvd/pktcdvd[0-7]/uevent 29 + Date: Oct. 2006 30 + KernelVersion: 2.6.20 31 + Contact: Thomas Maier <balagi@justmail.de> 32 + Description: 33 + dev: (RO) Device id 34 + 35 + uevent: (WO) To send a uevent 36 + 37 + 38 + What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/packets_started 39 + What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/packets_finished 40 + What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/kb_written 41 + What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/kb_read 42 + What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/kb_read_gather 43 + What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/reset 44 + Date: Oct. 2006 45 + KernelVersion: 2.6.20 46 + Contact: Thomas Maier <balagi@justmail.de> 47 + Description: 48 + packets_started: (RO) Number of started packets. 49 + 50 + packets_finished: (RO) Number of finished packets. 51 + 52 + kb_written: (RO) kBytes written. 53 + 54 + kb_read: (RO) kBytes read. 55 + 56 + kb_read_gather: (RO) kBytes read to fill write packets. 57 + 58 + reset: (WO) Write any value to it to reset 59 + pktcdvd device statistic values, like 60 + bytes read/written. 61 + 62 + 63 + What: /sys/class/pktcdvd/pktcdvd[0-7]/write_queue/size 64 + What: /sys/class/pktcdvd/pktcdvd[0-7]/write_queue/congestion_off 65 + What: /sys/class/pktcdvd/pktcdvd[0-7]/write_queue/congestion_on 66 + Date: Oct. 2006 67 + KernelVersion: 2.6.20 68 + Contact: Thomas Maier <balagi@justmail.de> 69 + Description: 70 + ============== ================================================ 71 + size (RO) Contains the size of the bio write queue. 72 + 73 + congestion_off (RW) If bio write queue size is below this mark, 74 + accept new bio requests from the block layer. 75 + 76 + congestion_on (RW) If bio write queue size is higher as this 77 + mark, do no longer accept bio write requests 78 + from the block layer and wait till the pktcdvd 79 + device has processed enough bio's so that bio 80 + write queue size is below congestion off mark. 81 + A value of <= 0 disables congestion control. 82 + ============== ================================================ 83 + 84 + 85 + Example: 86 + -------- 87 + To use the pktcdvd sysfs interface directly, you can do:: 88 + 89 + # create a new pktcdvd device mapped to /dev/hdc 90 + echo "22:0" >/sys/class/pktcdvd/add 91 + cat /sys/class/pktcdvd/device_map 92 + # assuming device pktcdvd0 was created, look at stat's 93 + cat /sys/class/pktcdvd/pktcdvd0/stat/kb_written 94 + # print the device id of the mapped block device 95 + fgrep pktcdvd0 /sys/class/pktcdvd/device_map 96 + # remove device, using pktcdvd0 device id 253:0 97 + echo "253:0" >/sys/class/pktcdvd/remove
+3
Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml
··· 40 40 clock-names: 41 41 const: stmmaceth 42 42 43 + phy-supply: 44 + description: PHY regulator 45 + 43 46 syscon: 44 47 $ref: /schemas/types.yaml#/definitions/phandle 45 48 description:
+26 -4
Documentation/devicetree/bindings/net/marvell,orion-mdio.yaml
··· 16 16 8k has a second unit which provides an interface with the xMDIO bus. This 17 17 driver handles these interfaces. 18 18 19 - allOf: 20 - - $ref: "mdio.yaml#" 21 - 22 19 properties: 23 20 compatible: 24 21 enum: ··· 36 39 - compatible 37 40 - reg 38 41 42 + allOf: 43 + - $ref: mdio.yaml# 44 + 45 + - if: 46 + required: 47 + - interrupts 48 + 49 + then: 50 + properties: 51 + reg: 52 + items: 53 + - items: 54 + - $ref: /schemas/types.yaml#/definitions/cell 55 + - const: 0x84 56 + 57 + else: 58 + properties: 59 + reg: 60 + items: 61 + - items: 62 + - $ref: /schemas/types.yaml#/definitions/cell 63 + - enum: 64 + - 0x4 65 + - 0x10 66 + 39 67 unevaluatedProperties: false 40 68 41 69 examples: 42 70 - | 43 71 mdio@d0072004 { 44 72 compatible = "marvell,orion-mdio"; 45 - reg = <0xd0072004 0x4>; 73 + reg = <0xd0072004 0x84>; 46 74 #address-cells = <1>; 47 75 #size-cells = <0>; 48 76 interrupts = <30>;
+5 -5
Documentation/devicetree/bindings/soundwire/qcom,soundwire.yaml
··· 80 80 or applicable for the respective data port. 81 81 More info in MIPI Alliance SoundWire 1.0 Specifications. 82 82 minItems: 3 83 - maxItems: 5 83 + maxItems: 8 84 84 85 85 qcom,ports-sinterval-low: 86 86 $ref: /schemas/types.yaml#/definitions/uint8-array ··· 124 124 or applicable for the respective data port. 125 125 More info in MIPI Alliance SoundWire 1.0 Specifications. 126 126 minItems: 3 127 - maxItems: 5 127 + maxItems: 8 128 128 129 129 qcom,ports-block-pack-mode: 130 130 $ref: /schemas/types.yaml#/definitions/uint8-array ··· 154 154 or applicable for the respective data port. 155 155 More info in MIPI Alliance SoundWire 1.0 Specifications. 156 156 minItems: 3 157 - maxItems: 5 157 + maxItems: 8 158 158 items: 159 159 oneOf: 160 160 - minimum: 0 ··· 171 171 or applicable for the respective data port. 172 172 More info in MIPI Alliance SoundWire 1.0 Specifications. 173 173 minItems: 3 174 - maxItems: 5 174 + maxItems: 8 175 175 items: 176 176 oneOf: 177 177 - minimum: 0 ··· 187 187 or applicable for the respective data port. 188 188 More info in MIPI Alliance SoundWire 1.0 Specifications. 189 189 minItems: 3 190 - maxItems: 5 190 + maxItems: 8 191 191 items: 192 192 oneOf: 193 193 - minimum: 0
+1
Documentation/maintainer/maintainer-entry-profile.rst
··· 104 104 ../riscv/patch-acceptance 105 105 ../driver-api/media/maintainer-entry-profile 106 106 ../driver-api/vfio-pci-device-specific-driver-acceptance 107 + ../nvme/feature-and-quirk-policy
+77
Documentation/nvme/feature-and-quirk-policy.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + ======================================= 4 + Linux NVMe feature and and quirk policy 5 + ======================================= 6 + 7 + This file explains the policy used to decide what is supported by the 8 + Linux NVMe driver and what is not. 9 + 10 + 11 + Introduction 12 + ============ 13 + 14 + NVM Express is an open collection of standards and information. 15 + 16 + The Linux NVMe host driver in drivers/nvme/host/ supports devices 17 + implementing the NVM Express (NVMe) family of specifications, which 18 + currently consists of a number of documents: 19 + 20 + - the NVMe Base specification 21 + - various Command Set specifications (e.g. NVM Command Set) 22 + - various Transport specifications (e.g. PCIe, Fibre Channel, RDMA, TCP) 23 + - the NVMe Management Interface specification 24 + 25 + See https://nvmexpress.org/developers/ for the NVMe specifications. 26 + 27 + 28 + Supported features 29 + ================== 30 + 31 + NVMe is a large suite of specifications, and contains features that are only 32 + useful or suitable for specific use-cases. It is important to note that Linux 33 + does not aim to implement every feature in the specification. Every additional 34 + feature implemented introduces more code, more maintenance and potentially more 35 + bugs. Hence there is an inherent tradeoff between functionality and 36 + maintainability of the NVMe host driver. 37 + 38 + Any feature implemented in the Linux NVMe host driver must support the 39 + following requirements: 40 + 41 + 1. The feature is specified in a release version of an official NVMe 42 + specification, or in a ratified Technical Proposal (TP) that is 43 + available on NVMe website. Or if it is not directly related to the 44 + on-wire protocol, does not contradict any of the NVMe specifications. 45 + 2. Does not conflict with the Linux architecture, nor the design of the 46 + NVMe host driver. 47 + 3. Has a clear, indisputable value-proposition and a wide consensus across 48 + the community. 49 + 50 + Vendor specific extensions are generally not supported in the NVMe host 51 + driver. 52 + 53 + It is strongly recommended to work with the Linux NVMe and block layer 54 + maintainers and get feedback on specification changes that are intended 55 + to be used by the Linux NVMe host driver in order to avoid conflict at a 56 + later stage. 57 + 58 + 59 + Quirks 60 + ====== 61 + 62 + Sometimes implementations of open standards fail to correctly implement parts 63 + of the standards. Linux uses identifier-based quirks to work around such 64 + implementation bugs. The intent of quirks is to deal with widely available 65 + hardware, usually consumer, which Linux users can't use without these quirks. 66 + Typically these implementations are not or only superficially tested with Linux 67 + by the hardware manufacturer. 68 + 69 + The Linux NVMe maintainers decide ad hoc whether to quirk implementations 70 + based on the impact of the problem to Linux users and how it impacts 71 + maintainability of the driver. In general quirks are a last resort, if no 72 + firmware updates or other workarounds are available from the vendor. 73 + 74 + Quirks will not be added to the Linux kernel for hardware that isn't available 75 + on the mass market. Hardware that fails qualification for enterprise Linux 76 + distributions, ChromeOS, Android or other consumers of the Linux kernel 77 + should be fixed before it is shipped instead of relying on Linux quirks.
+205 -176
Documentation/process/maintainer-netdev.rst
··· 2 2 3 3 .. _netdev-FAQ: 4 4 5 - ========== 6 - netdev FAQ 7 - ========== 5 + ============================= 6 + Networking subsystem (netdev) 7 + ============================= 8 8 9 9 tl;dr 10 10 ----- ··· 15 15 - don't repost your patches within one 24h period 16 16 - reverse xmas tree 17 17 18 - What is netdev? 19 - --------------- 20 - It is a mailing list for all network-related Linux stuff. This 18 + netdev 19 + ------ 20 + 21 + netdev is a mailing list for all network-related Linux stuff. This 21 22 includes anything found under net/ (i.e. core code like IPv6) and 22 23 drivers/net (i.e. hardware specific drivers) in the Linux source tree. 23 24 24 25 Note that some subsystems (e.g. wireless drivers) which have a high 25 - volume of traffic have their own specific mailing lists. 26 + volume of traffic have their own specific mailing lists and trees. 26 27 27 28 The netdev list is managed (like many other Linux mailing lists) through 28 29 VGER (http://vger.kernel.org/) with archives available at ··· 33 32 Linux development (i.e. RFC, review, comments, etc.) takes place on 34 33 netdev. 35 34 36 - How do the changes posted to netdev make their way into Linux? 37 - -------------------------------------------------------------- 38 - There are always two trees (git repositories) in play. Both are 39 - driven by David Miller, the main network maintainer. There is the 40 - ``net`` tree, and the ``net-next`` tree. As you can probably guess from 41 - the names, the ``net`` tree is for fixes to existing code already in the 42 - mainline tree from Linus, and ``net-next`` is where the new code goes 43 - for the future release. You can find the trees here: 35 + Development cycle 36 + ----------------- 44 37 45 - - https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git 46 - - https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git 47 - 48 - How do I indicate which tree (net vs. net-next) my patch should be in? 49 - ---------------------------------------------------------------------- 50 - To help maintainers and CI bots you should explicitly mark which tree 51 - your patch is targeting. Assuming that you use git, use the prefix 52 - flag:: 53 - 54 - git format-patch --subject-prefix='PATCH net-next' start..finish 55 - 56 - Use ``net`` instead of ``net-next`` (always lower case) in the above for 57 - bug-fix ``net`` content. 58 - 59 - How often do changes from these trees make it to the mainline Linus tree? 60 - ------------------------------------------------------------------------- 61 - To understand this, you need to know a bit of background information on 38 + Here is a bit of background information on 62 39 the cadence of Linux development. Each new release starts off with a 63 40 two week "merge window" where the main maintainers feed their new stuff 64 41 to Linus for merging into the mainline tree. After the two weeks, the ··· 48 69 state of churn), and a week after the last vX.Y-rcN was done, the 49 70 official vX.Y is released. 50 71 51 - Relating that to netdev: At the beginning of the 2-week merge window, 52 - the ``net-next`` tree will be closed - no new changes/features. The 53 - accumulated new content of the past ~10 weeks will be passed onto 72 + To find out where we are now in the cycle - load the mainline (Linus) 73 + page here: 74 + 75 + https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 76 + 77 + and note the top of the "tags" section. If it is rc1, it is early in 78 + the dev cycle. If it was tagged rc7 a week ago, then a release is 79 + probably imminent. If the most recent tag is a final release tag 80 + (without an ``-rcN`` suffix) - we are most likely in a merge window 81 + and ``net-next`` is closed. 82 + 83 + git trees and patch flow 84 + ------------------------ 85 + 86 + There are two networking trees (git repositories) in play. Both are 87 + driven by David Miller, the main network maintainer. There is the 88 + ``net`` tree, and the ``net-next`` tree. As you can probably guess from 89 + the names, the ``net`` tree is for fixes to existing code already in the 90 + mainline tree from Linus, and ``net-next`` is where the new code goes 91 + for the future release. You can find the trees here: 92 + 93 + - https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git 94 + - https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git 95 + 96 + Relating that to kernel development: At the beginning of the 2-week 97 + merge window, the ``net-next`` tree will be closed - no new changes/features. 98 + The accumulated new content of the past ~10 weeks will be passed onto 54 99 mainline/Linus via a pull request for vX.Y -- at the same time, the 55 100 ``net`` tree will start accumulating fixes for this pulled content 56 101 relating to vX.Y ··· 106 103 107 104 Finally, the vX.Y gets released, and the whole cycle starts over. 108 105 109 - So where are we now in this cycle? 110 - ---------------------------------- 106 + netdev patch review 107 + ------------------- 111 108 112 - Load the mainline (Linus) page here: 109 + Patch status 110 + ~~~~~~~~~~~~ 113 111 114 - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 115 - 116 - and note the top of the "tags" section. If it is rc1, it is early in 117 - the dev cycle. If it was tagged rc7 a week ago, then a release is 118 - probably imminent. If the most recent tag is a final release tag 119 - (without an ``-rcN`` suffix) - we are most likely in a merge window 120 - and ``net-next`` is closed. 121 - 122 - How can I tell the status of a patch I've sent? 123 - ----------------------------------------------- 124 - Start by looking at the main patchworks queue for netdev: 112 + Status of a patch can be checked by looking at the main patchwork 113 + queue for netdev: 125 114 126 115 https://patchwork.kernel.org/project/netdevbpf/list/ 127 116 ··· 122 127 which carried them so if you have trouble finding your patch append 123 128 the value of ``Message-ID`` to the URL above. 124 129 125 - How long before my patch is accepted? 126 - ------------------------------------- 130 + Updating patch status 131 + ~~~~~~~~~~~~~~~~~~~~~ 132 + 133 + It may be tempting to help the maintainers and update the state of your 134 + own patches when you post a new version or spot a bug. Please **do not** 135 + do that. 136 + Interfering with the patch status on patchwork will only cause confusion. Leave 137 + it to the maintainer to figure out what is the most recent and current 138 + version that should be applied. If there is any doubt, the maintainer 139 + will reply and ask what should be done. 140 + 141 + Review timelines 142 + ~~~~~~~~~~~~~~~~ 143 + 127 144 Generally speaking, the patches get triaged quickly (in less than 128 145 48h). But be patient, if your patch is active in patchwork (i.e. it's 129 146 listed on the project's patch list) the chances it was missed are close to zero. ··· 143 136 patch is a good way to ensure your patch is ignored or pushed to the 144 137 bottom of the priority list. 145 138 146 - Should I directly update patchwork state of my own patches? 147 - ----------------------------------------------------------- 148 - It may be tempting to help the maintainers and update the state of your 149 - own patches when you post a new version or spot a bug. Please do not do that. 150 - Interfering with the patch status on patchwork will only cause confusion. Leave 151 - it to the maintainer to figure out what is the most recent and current 152 - version that should be applied. If there is any doubt, the maintainer 153 - will reply and ask what should be done. 139 + Partial resends 140 + ~~~~~~~~~~~~~~~ 154 141 155 - How do I divide my work into patches? 156 - ------------------------------------- 157 - 158 - Put yourself in the shoes of the reviewer. Each patch is read separately 159 - and therefore should constitute a comprehensible step towards your stated 160 - goal. 161 - 162 - Avoid sending series longer than 15 patches. Larger series takes longer 163 - to review as reviewers will defer looking at it until they find a large 164 - chunk of time. A small series can be reviewed in a short time, so Maintainers 165 - just do it. As a result, a sequence of smaller series gets merged quicker and 166 - with better review coverage. Re-posting large series also increases the mailing 167 - list traffic. 168 - 169 - I made changes to only a few patches in a patch series should I resend only those changed? 170 - ------------------------------------------------------------------------------------------ 171 - No, please resend the entire patch series and make sure you do number your 142 + Please always resend the entire patch series and make sure you do number your 172 143 patches such that it is clear this is the latest and greatest set of patches 173 - that can be applied. 144 + that can be applied. Do not try to resend just the patches which changed. 174 145 175 - I have received review feedback, when should I post a revised version of the patches? 176 - ------------------------------------------------------------------------------------- 177 - Allow at least 24 hours to pass between postings. This will ensure reviewers 178 - from all geographical locations have a chance to chime in. Do not wait 179 - too long (weeks) between postings either as it will make it harder for reviewers 180 - to recall all the context. 146 + Handling misapplied patches 147 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 181 148 182 - Make sure you address all the feedback in your new posting. Do not post a new 183 - version of the code if the discussion about the previous version is still 184 - ongoing, unless directly instructed by a reviewer. 185 - 186 - I submitted multiple versions of a patch series and it looks like a version other than the last one has been accepted, what should I do? 187 - ---------------------------------------------------------------------------------------------------------------------------------------- 149 + Occasionally a patch series gets applied before receiving critical feedback, 150 + or the wrong version of a series gets applied. 188 151 There is no revert possible, once it is pushed out, it stays like that. 189 152 Please send incremental versions on top of what has been merged in order to fix 190 153 the patches the way they would look like if your latest patch series was to be 191 154 merged. 192 155 193 - Are there special rules regarding stable submissions on netdev? 194 - --------------------------------------------------------------- 156 + Stable tree 157 + ~~~~~~~~~~~ 158 + 195 159 While it used to be the case that netdev submissions were not supposed 196 160 to carry explicit ``CC: stable@vger.kernel.org`` tags that is no longer 197 161 the case today. Please follow the standard stable rules in 198 162 :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>`, 199 163 and make sure you include appropriate Fixes tags! 200 164 201 - Is the comment style convention different for the networking content? 202 - --------------------------------------------------------------------- 203 - Yes, in a largely trivial way. Instead of this:: 165 + Security fixes 166 + ~~~~~~~~~~~~~~ 204 167 205 - /* 206 - * foobar blah blah blah 207 - * another line of text 208 - */ 209 - 210 - it is requested that you make it look like this:: 211 - 212 - /* foobar blah blah blah 213 - * another line of text 214 - */ 215 - 216 - What is "reverse xmas tree"? 217 - ---------------------------- 218 - 219 - Netdev has a convention for ordering local variables in functions. 220 - Order the variable declaration lines longest to shortest, e.g.:: 221 - 222 - struct scatterlist *sg; 223 - struct sk_buff *skb; 224 - int err, i; 225 - 226 - If there are dependencies between the variables preventing the ordering 227 - move the initialization out of line. 228 - 229 - I am working in existing code which uses non-standard formatting. Which formatting should I use? 230 - ------------------------------------------------------------------------------------------------ 231 - Make your code follow the most recent guidelines, so that eventually all code 232 - in the domain of netdev is in the preferred format. 233 - 234 - I found a bug that might have possible security implications or similar. Should I mail the main netdev maintainer off-list? 235 - --------------------------------------------------------------------------------------------------------------------------- 236 - No. The current netdev maintainer has consistently requested that 168 + Do not email netdev maintainers directly if you think you discovered 169 + a bug that might have possible security implications. 170 + The current netdev maintainer has consistently requested that 237 171 people use the mailing lists and not reach out directly. If you aren't 238 172 OK with that, then perhaps consider mailing security@kernel.org or 239 173 reading about http://oss-security.openwall.org/wiki/mailing-lists/distros 240 174 as possible alternative mechanisms. 241 175 242 - What level of testing is expected before I submit my change? 243 - ------------------------------------------------------------ 244 - At the very minimum your changes must survive an ``allyesconfig`` and an 245 - ``allmodconfig`` build with ``W=1`` set without new warnings or failures. 246 176 247 - Ideally you will have done run-time testing specific to your change, 248 - and the patch series contains a set of kernel selftest for 249 - ``tools/testing/selftests/net`` or using the KUnit framework. 177 + Co-posting changes to user space components 178 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 250 179 251 - You are expected to test your changes on top of the relevant networking 252 - tree (``net`` or ``net-next``) and not e.g. a stable tree or ``linux-next``. 253 - 254 - How do I post corresponding changes to user space components? 255 - ------------------------------------------------------------- 256 180 User space code exercising kernel features should be posted 257 181 alongside kernel patches. This gives reviewers a chance to see 258 182 how any new interface is used and how well it works. ··· 208 270 Posting as one thread is discouraged because it confuses patchwork 209 271 (as of patchwork 2.2.2). 210 272 211 - Can I reproduce the checks from patchwork on my local machine? 212 - -------------------------------------------------------------- 273 + Preparing changes 274 + ----------------- 213 275 214 - Checks in patchwork are mostly simple wrappers around existing kernel 215 - scripts, the sources are available at: 216 - 217 - https://github.com/kuba-moo/nipa/tree/master/tests 218 - 219 - Running all the builds and checks locally is a pain, can I post my patches and have the patchwork bot validate them? 220 - -------------------------------------------------------------------------------------------------------------------- 221 - 222 - No, you must ensure that your patches are ready by testing them locally 223 - before posting to the mailing list. The patchwork build bot instance 224 - gets overloaded very easily and netdev@vger really doesn't need more 225 - traffic if we can help it. 226 - 227 - netdevsim is great, can I extend it for my out-of-tree tests? 228 - ------------------------------------------------------------- 229 - 230 - No, ``netdevsim`` is a test vehicle solely for upstream tests. 231 - (Please add your tests under ``tools/testing/selftests/``.) 232 - 233 - We also give no guarantees that ``netdevsim`` won't change in the future 234 - in a way which would break what would normally be considered uAPI. 235 - 236 - Is netdevsim considered a "user" of an API? 237 - ------------------------------------------- 238 - 239 - Linux kernel has a long standing rule that no API should be added unless 240 - it has a real, in-tree user. Mock-ups and tests based on ``netdevsim`` are 241 - strongly encouraged when adding new APIs, but ``netdevsim`` in itself 242 - is **not** considered a use case/user. 243 - 244 - Any other tips to help ensure my net/net-next patch gets OK'd? 245 - -------------------------------------------------------------- 246 - Attention to detail. Re-read your own work as if you were the 276 + Attention to detail is important. Re-read your own work as if you were the 247 277 reviewer. You can start with using ``checkpatch.pl``, perhaps even with 248 278 the ``--strict`` flag. But do not be mindlessly robotic in doing so. 249 279 If your change is a bug fix, make sure your commit log indicates the ··· 226 320 :ref:`Documentation/process/submitting-patches.rst <submittingpatches>` 227 321 to be sure you are not repeating some common mistake documented there. 228 322 229 - My company uses peer feedback in employee performance reviews. Can I ask netdev maintainers for feedback? 230 - --------------------------------------------------------------------------------------------------------- 323 + Indicating target tree 324 + ~~~~~~~~~~~~~~~~~~~~~~ 231 325 232 - Yes, especially if you spend significant amount of time reviewing code 326 + To help maintainers and CI bots you should explicitly mark which tree 327 + your patch is targeting. Assuming that you use git, use the prefix 328 + flag:: 329 + 330 + git format-patch --subject-prefix='PATCH net-next' start..finish 331 + 332 + Use ``net`` instead of ``net-next`` (always lower case) in the above for 333 + bug-fix ``net`` content. 334 + 335 + Dividing work into patches 336 + ~~~~~~~~~~~~~~~~~~~~~~~~~~ 337 + 338 + Put yourself in the shoes of the reviewer. Each patch is read separately 339 + and therefore should constitute a comprehensible step towards your stated 340 + goal. 341 + 342 + Avoid sending series longer than 15 patches. Larger series takes longer 343 + to review as reviewers will defer looking at it until they find a large 344 + chunk of time. A small series can be reviewed in a short time, so Maintainers 345 + just do it. As a result, a sequence of smaller series gets merged quicker and 346 + with better review coverage. Re-posting large series also increases the mailing 347 + list traffic. 348 + 349 + Multi-line comments 350 + ~~~~~~~~~~~~~~~~~~~ 351 + 352 + Comment style convention is slightly different for networking and most of 353 + the tree. Instead of this:: 354 + 355 + /* 356 + * foobar blah blah blah 357 + * another line of text 358 + */ 359 + 360 + it is requested that you make it look like this:: 361 + 362 + /* foobar blah blah blah 363 + * another line of text 364 + */ 365 + 366 + Local variable ordering ("reverse xmas tree", "RCS") 367 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 368 + 369 + Netdev has a convention for ordering local variables in functions. 370 + Order the variable declaration lines longest to shortest, e.g.:: 371 + 372 + struct scatterlist *sg; 373 + struct sk_buff *skb; 374 + int err, i; 375 + 376 + If there are dependencies between the variables preventing the ordering 377 + move the initialization out of line. 378 + 379 + Format precedence 380 + ~~~~~~~~~~~~~~~~~ 381 + 382 + When working in existing code which uses nonstandard formatting make 383 + your code follow the most recent guidelines, so that eventually all code 384 + in the domain of netdev is in the preferred format. 385 + 386 + Resending after review 387 + ~~~~~~~~~~~~~~~~~~~~~~ 388 + 389 + Allow at least 24 hours to pass between postings. This will ensure reviewers 390 + from all geographical locations have a chance to chime in. Do not wait 391 + too long (weeks) between postings either as it will make it harder for reviewers 392 + to recall all the context. 393 + 394 + Make sure you address all the feedback in your new posting. Do not post a new 395 + version of the code if the discussion about the previous version is still 396 + ongoing, unless directly instructed by a reviewer. 397 + 398 + Testing 399 + ------- 400 + 401 + Expected level of testing 402 + ~~~~~~~~~~~~~~~~~~~~~~~~~ 403 + 404 + At the very minimum your changes must survive an ``allyesconfig`` and an 405 + ``allmodconfig`` build with ``W=1`` set without new warnings or failures. 406 + 407 + Ideally you will have done run-time testing specific to your change, 408 + and the patch series contains a set of kernel selftest for 409 + ``tools/testing/selftests/net`` or using the KUnit framework. 410 + 411 + You are expected to test your changes on top of the relevant networking 412 + tree (``net`` or ``net-next``) and not e.g. a stable tree or ``linux-next``. 413 + 414 + patchwork checks 415 + ~~~~~~~~~~~~~~~~ 416 + 417 + Checks in patchwork are mostly simple wrappers around existing kernel 418 + scripts, the sources are available at: 419 + 420 + https://github.com/kuba-moo/nipa/tree/master/tests 421 + 422 + **Do not** post your patches just to run them through the checks. 423 + You must ensure that your patches are ready by testing them locally 424 + before posting to the mailing list. The patchwork build bot instance 425 + gets overloaded very easily and netdev@vger really doesn't need more 426 + traffic if we can help it. 427 + 428 + netdevsim 429 + ~~~~~~~~~ 430 + 431 + ``netdevsim`` is a test driver which can be used to exercise driver 432 + configuration APIs without requiring capable hardware. 433 + Mock-ups and tests based on ``netdevsim`` are strongly encouraged when 434 + adding new APIs, but ``netdevsim`` in itself is **not** considered 435 + a use case/user. You must also implement the new APIs in a real driver. 436 + 437 + We give no guarantees that ``netdevsim`` won't change in the future 438 + in a way which would break what would normally be considered uAPI. 439 + 440 + ``netdevsim`` is reserved for use by upstream tests only, so any 441 + new ``netdevsim`` features must be accompanied by selftests under 442 + ``tools/testing/selftests/``. 443 + 444 + Testimonials / feedback 445 + ----------------------- 446 + 447 + Some companies use peer feedback in employee performance reviews. 448 + Please feel free to request feedback from netdev maintainers, 449 + especially if you spend significant amount of time reviewing code 233 450 and go out of your way to improve shared infrastructure. 234 451 235 452 The feedback must be requested by you, the contributor, and will always
+26 -20
Documentation/virt/kvm/api.rst
··· 5343 5343 32 vCPUs in the shared_info page, KVM does not automatically do so 5344 5344 and instead requires that KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO be used 5345 5345 explicitly even when the vcpu_info for a given vCPU resides at the 5346 - "default" location in the shared_info page. This is because KVM is 5347 - not aware of the Xen CPU id which is used as the index into the 5348 - vcpu_info[] array, so cannot know the correct default location. 5346 + "default" location in the shared_info page. This is because KVM may 5347 + not be aware of the Xen CPU id which is used as the index into the 5348 + vcpu_info[] array, so may know the correct default location. 5349 5349 5350 5350 Note that the shared info page may be constantly written to by KVM; 5351 5351 it contains the event channel bitmap used to deliver interrupts to ··· 5356 5356 any vCPU has been running or any event channel interrupts can be 5357 5357 routed to the guest. 5358 5358 5359 + Setting the gfn to KVM_XEN_INVALID_GFN will disable the shared info 5360 + page. 5361 + 5359 5362 KVM_XEN_ATTR_TYPE_UPCALL_VECTOR 5360 5363 Sets the exception vector used to deliver Xen event channel upcalls. 5361 5364 This is the HVM-wide vector injected directly by the hypervisor 5362 5365 (not through the local APIC), typically configured by a guest via 5363 - HVM_PARAM_CALLBACK_IRQ. 5366 + HVM_PARAM_CALLBACK_IRQ. This can be disabled again (e.g. for guest 5367 + SHUTDOWN_soft_reset) by setting it to zero. 5364 5368 5365 5369 KVM_XEN_ATTR_TYPE_EVTCHN 5366 5370 This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates 5367 5371 support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It configures 5368 5372 an outbound port number for interception of EVTCHNOP_send requests 5369 - from the guest. A given sending port number may be directed back 5370 - to a specified vCPU (by APIC ID) / port / priority on the guest, 5371 - or to trigger events on an eventfd. The vCPU and priority can be 5372 - changed by setting KVM_XEN_EVTCHN_UPDATE in a subsequent call, 5373 - but other fields cannot change for a given sending port. A port 5374 - mapping is removed by using KVM_XEN_EVTCHN_DEASSIGN in the flags 5375 - field. 5373 + from the guest. A given sending port number may be directed back to 5374 + a specified vCPU (by APIC ID) / port / priority on the guest, or to 5375 + trigger events on an eventfd. The vCPU and priority can be changed 5376 + by setting KVM_XEN_EVTCHN_UPDATE in a subsequent call, but but other 5377 + fields cannot change for a given sending port. A port mapping is 5378 + removed by using KVM_XEN_EVTCHN_DEASSIGN in the flags field. Passing 5379 + KVM_XEN_EVTCHN_RESET in the flags field removes all interception of 5380 + outbound event channels. The values of the flags field are mutually 5381 + exclusive and cannot be combined as a bitmask. 5376 5382 5377 5383 KVM_XEN_ATTR_TYPE_XEN_VERSION 5378 5384 This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates ··· 5394 5388 support for KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG. It enables the 5395 5389 XEN_RUNSTATE_UPDATE flag which allows guest vCPUs to safely read 5396 5390 other vCPUs' vcpu_runstate_info. Xen guests enable this feature via 5397 - the VM_ASST_TYPE_runstate_update_flag of the HYPERVISOR_vm_assist 5391 + the VMASST_TYPE_runstate_update_flag of the HYPERVISOR_vm_assist 5398 5392 hypercall. 5399 5393 5400 5394 4.127 KVM_XEN_HVM_GET_ATTR ··· 5452 5446 As with the shared_info page for the VM, the corresponding page may be 5453 5447 dirtied at any time if event channel interrupt delivery is enabled, so 5454 5448 userspace should always assume that the page is dirty without relying 5455 - on dirty logging. 5449 + on dirty logging. Setting the gpa to KVM_XEN_INVALID_GPA will disable 5450 + the vcpu_info. 5456 5451 5457 5452 KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO 5458 5453 Sets the guest physical address of an additional pvclock structure 5459 5454 for a given vCPU. This is typically used for guest vsyscall support. 5455 + Setting the gpa to KVM_XEN_INVALID_GPA will disable the structure. 5460 5456 5461 5457 KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR 5462 5458 Sets the guest physical address of the vcpu_runstate_info for a given 5463 5459 vCPU. This is how a Xen guest tracks CPU state such as steal time. 5460 + Setting the gpa to KVM_XEN_INVALID_GPA will disable the runstate area. 5464 5461 5465 5462 KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT 5466 5463 Sets the runstate (RUNSTATE_running/_runnable/_blocked/_offline) of ··· 5496 5487 This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates 5497 5488 support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It sets the 5498 5489 event channel port/priority for the VIRQ_TIMER of the vCPU, as well 5499 - as allowing a pending timer to be saved/restored. 5490 + as allowing a pending timer to be saved/restored. Setting the timer 5491 + port to zero disables kernel handling of the singleshot timer. 5500 5492 5501 5493 KVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR 5502 5494 This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates ··· 5505 5495 per-vCPU local APIC upcall vector, configured by a Xen guest with 5506 5496 the HVMOP_set_evtchn_upcall_vector hypercall. This is typically 5507 5497 used by Windows guests, and is distinct from the HVM-wide upcall 5508 - vector configured with HVM_PARAM_CALLBACK_IRQ. 5498 + vector configured with HVM_PARAM_CALLBACK_IRQ. It is disabled by 5499 + setting the vector to zero. 5509 5500 5510 5501 5511 5502 4.129 KVM_XEN_VCPU_GET_ATTR ··· 6587 6576 Please note that the kernel is allowed to use the kvm_run structure as the 6588 6577 primary storage for certain register types. Therefore, the kernel may use the 6589 6578 values in kvm_run even if the corresponding bit in kvm_dirty_regs is not set. 6590 - 6591 - :: 6592 - 6593 - }; 6594 - 6595 6579 6596 6580 6597 6581 6. Capabilities that can be enabled on vCPUs
+14 -5
Documentation/virt/kvm/locking.rst
··· 16 16 - kvm->slots_lock is taken outside kvm->irq_lock, though acquiring 17 17 them together is quite rare. 18 18 19 - - Unlike kvm->slots_lock, kvm->slots_arch_lock is released before 20 - synchronize_srcu(&kvm->srcu). Therefore kvm->slots_arch_lock 21 - can be taken inside a kvm->srcu read-side critical section, 22 - while kvm->slots_lock cannot. 23 - 24 19 - kvm->mn_active_invalidate_count ensures that pairs of 25 20 invalidate_range_start() and invalidate_range_end() callbacks 26 21 use the same memslots array. kvm->slots_lock and kvm->slots_arch_lock 27 22 are taken on the waiting side in install_new_memslots, so MMU notifiers 28 23 must not take either kvm->slots_lock or kvm->slots_arch_lock. 24 + 25 + For SRCU: 26 + 27 + - ``synchronize_srcu(&kvm->srcu)`` is called _inside_ 28 + the kvm->slots_lock critical section, therefore kvm->slots_lock 29 + cannot be taken inside a kvm->srcu read-side critical section. 30 + Instead, kvm->slots_arch_lock is released before the call 31 + to ``synchronize_srcu()`` and _can_ be taken inside a 32 + kvm->srcu read-side critical section. 33 + 34 + - kvm->lock is taken inside kvm->srcu, therefore 35 + ``synchronize_srcu(&kvm->srcu)`` cannot be called inside 36 + a kvm->lock critical section. If you cannot delay the 37 + call until after kvm->lock is released, use ``call_srcu``. 29 38 30 39 On x86: 31 40
+12 -2
MAINTAINERS
··· 11468 11468 F: arch/x86/kvm/kvm_onhyperv.* 11469 11469 F: arch/x86/kvm/svm/hyperv.* 11470 11470 F: arch/x86/kvm/svm/svm_onhyperv.* 11471 - F: arch/x86/kvm/vmx/evmcs.* 11471 + F: arch/x86/kvm/vmx/hyperv.* 11472 11472 11473 11473 KVM X86 Xen (KVM/Xen) 11474 11474 M: David Woodhouse <dwmw2@infradead.org> ··· 14916 14916 S: Supported 14917 14917 W: http://git.infradead.org/nvme.git 14918 14918 T: git://git.infradead.org/nvme.git 14919 + F: Documentation/nvme/ 14919 14920 F: drivers/nvme/host/ 14920 14921 F: drivers/nvme/common/ 14921 14922 F: include/linux/nvme* ··· 16609 16608 S: Supported 16610 16609 F: Documentation/devicetree/bindings/input/pine64,pinephone-keyboard.yaml 16611 16610 F: drivers/input/keyboard/pinephone-keyboard.c 16611 + 16612 + PKTCDVD DRIVER 16613 + M: linux-block@vger.kernel.org 16614 + S: Orphan 16615 + F: drivers/block/pktcdvd.c 16616 + F: include/linux/pktcdvd.h 16617 + F: include/uapi/linux/pktcdvd.h 16612 16618 16613 16619 PLANTOWER PMS7003 AIR POLLUTION SENSOR DRIVER 16614 16620 M: Tomasz Duszynski <tduszyns@gmail.com> ··· 22253 22245 F: drivers/scsi/vmw_pvscsi.h 22254 22246 22255 22247 VMWARE VIRTUAL PTP CLOCK DRIVER 22256 - M: Vivek Thampi <vithampi@vmware.com> 22248 + M: Srivatsa S. Bhat (VMware) <srivatsa@csail.mit.edu> 22249 + M: Deep Shah <sdeep@vmware.com> 22250 + R: Alexey Makhalov <amakhalov@vmware.com> 22257 22251 R: VMware PV-Drivers Reviewers <pv-drivers@vmware.com> 22258 22252 L: netdev@vger.kernel.org 22259 22253 S: Supported
+3 -3
Makefile
··· 2 2 VERSION = 6 3 3 PATCHLEVEL = 2 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc1 5 + EXTRAVERSION = -rc3 6 6 NAME = Hurr durr I'ma ninja sloth 7 7 8 8 # *DOCUMENTATION* ··· 297 297 headers_install modules_install kernelrelease image_name 298 298 no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \ 299 299 image_name 300 - single-targets := %.a %.i %.rsi %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/ 300 + single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %.symtypes %/ 301 301 302 302 config-build := 303 303 mixed-build := ··· 1986 1986 # Remove MODORDER when done because it is not the real one. 1987 1987 PHONY += single_modules 1988 1988 single_modules: $(single-no-ko) modules_prepare 1989 - $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$m;) } > $(MODORDER) 1989 + $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$(m:%.ko=%.o);) } > $(MODORDER) 1990 1990 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1991 1991 ifneq ($(KBUILD_MODPOST_NOFINAL),1) 1992 1992 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
+7 -6
arch/arm/include/asm/thread_info.h
··· 128 128 #define TIF_NEED_RESCHED 1 /* rescheduling necessary */ 129 129 #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */ 130 130 #define TIF_UPROBE 3 /* breakpointed or singlestepping */ 131 - #define TIF_SYSCALL_TRACE 4 /* syscall trace active */ 132 - #define TIF_SYSCALL_AUDIT 5 /* syscall auditing active */ 133 - #define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */ 134 - #define TIF_SECCOMP 7 /* seccomp syscall filtering active */ 135 - #define TIF_NOTIFY_SIGNAL 8 /* signal notifications exist */ 131 + #define TIF_NOTIFY_SIGNAL 4 /* signal notifications exist */ 136 132 137 133 #define TIF_USING_IWMMXT 17 138 134 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ 139 - #define TIF_RESTORE_SIGMASK 20 135 + #define TIF_RESTORE_SIGMASK 19 136 + #define TIF_SYSCALL_TRACE 20 /* syscall trace active */ 137 + #define TIF_SYSCALL_AUDIT 21 /* syscall auditing active */ 138 + #define TIF_SYSCALL_TRACEPOINT 22 /* syscall tracepoint instrumentation */ 139 + #define TIF_SECCOMP 23 /* seccomp syscall filtering active */ 140 + 140 141 141 142 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 142 143 #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
+3 -2
arch/arm64/crypto/sm4-ce-ccm-core.S
··· 8 8 */ 9 9 10 10 #include <linux/linkage.h> 11 + #include <linux/cfi_types.h> 11 12 #include <asm/assembler.h> 12 13 #include "sm4-ce-asm.h" 13 14 ··· 105 104 SYM_FUNC_END(sm4_ce_ccm_final) 106 105 107 106 .align 3 108 - SYM_FUNC_START(sm4_ce_ccm_enc) 107 + SYM_TYPED_FUNC_START(sm4_ce_ccm_enc) 109 108 /* input: 110 109 * x0: round key array, CTX 111 110 * x1: dst ··· 217 216 SYM_FUNC_END(sm4_ce_ccm_enc) 218 217 219 218 .align 3 220 - SYM_FUNC_START(sm4_ce_ccm_dec) 219 + SYM_TYPED_FUNC_START(sm4_ce_ccm_dec) 221 220 /* input: 222 221 * x0: round key array, CTX 223 222 * x1: dst
+3 -2
arch/arm64/crypto/sm4-ce-gcm-core.S
··· 9 9 */ 10 10 11 11 #include <linux/linkage.h> 12 + #include <linux/cfi_types.h> 12 13 #include <asm/assembler.h> 13 14 #include "sm4-ce-asm.h" 14 15 ··· 371 370 SYM_FUNC_END(pmull_ghash_update) 372 371 373 372 .align 3 374 - SYM_FUNC_START(sm4_ce_pmull_gcm_enc) 373 + SYM_TYPED_FUNC_START(sm4_ce_pmull_gcm_enc) 375 374 /* input: 376 375 * x0: round key array, CTX 377 376 * x1: dst ··· 582 581 #define RH3 v20 583 582 584 583 .align 3 585 - SYM_FUNC_START(sm4_ce_pmull_gcm_dec) 584 + SYM_TYPED_FUNC_START(sm4_ce_pmull_gcm_dec) 586 585 /* input: 587 586 * x0: round key array, CTX 588 587 * x1: dst
+1 -1
arch/mips/ralink/of.c
··· 64 64 dtb = get_fdt(); 65 65 __dt_setup_arch(dtb); 66 66 67 - if (!early_init_dt_scan_memory()) 67 + if (early_init_dt_scan_memory()) 68 68 return; 69 69 70 70 if (soc_info.mem_detect)
+16
arch/powerpc/boot/dts/fsl/t2081si-post.dtsi
··· 659 659 interrupts = <16 2 1 9>; 660 660 }; 661 661 }; 662 + 663 + &fman0_rx_0x08 { 664 + /delete-property/ fsl,fman-10g-port; 665 + }; 666 + 667 + &fman0_tx_0x28 { 668 + /delete-property/ fsl,fman-10g-port; 669 + }; 670 + 671 + &fman0_rx_0x09 { 672 + /delete-property/ fsl,fman-10g-port; 673 + }; 674 + 675 + &fman0_tx_0x29 { 676 + /delete-property/ fsl,fman-10g-port; 677 + };
+5 -1
arch/powerpc/kernel/vmlinux.lds.S
··· 8 8 #define BSS_FIRST_SECTIONS *(.bss.prominit) 9 9 #define EMITS_PT_NOTE 10 10 #define RO_EXCEPTION_TABLE_ALIGN 0 11 + #define RUNTIME_DISCARD_EXIT 11 12 12 13 #define SOFT_MASK_TABLE(align) \ 13 14 . = ALIGN(align); \ ··· 411 410 DISCARDS 412 411 /DISCARD/ : { 413 412 *(*.EMB.apuinfo) 414 - *(.glink .iplt .plt .rela* .comment) 413 + *(.glink .iplt .plt) 415 414 *(.gnu.version*) 416 415 *(.gnu.attributes) 417 416 *(.eh_frame) 417 + #ifndef CONFIG_RELOCATABLE 418 + *(.rela*) 419 + #endif 418 420 } 419 421 }
+1 -1
arch/riscv/include/asm/uaccess.h
··· 165 165 might_fault(); \ 166 166 access_ok(__p, sizeof(*__p)) ? \ 167 167 __get_user((x), __p) : \ 168 - ((x) = 0, -EFAULT); \ 168 + ((x) = (__force __typeof__(x))0, -EFAULT); \ 169 169 }) 170 170 171 171 #define __put_user_asm(insn, x, ptr, err) \
+2 -2
arch/riscv/kernel/probes/simulate-insn.h
··· 31 31 } while (0) 32 32 33 33 __RISCV_INSN_FUNCS(c_j, 0xe003, 0xa001); 34 - __RISCV_INSN_FUNCS(c_jr, 0xf007, 0x8002); 34 + __RISCV_INSN_FUNCS(c_jr, 0xf07f, 0x8002); 35 35 __RISCV_INSN_FUNCS(c_jal, 0xe003, 0x2001); 36 - __RISCV_INSN_FUNCS(c_jalr, 0xf007, 0x9002); 36 + __RISCV_INSN_FUNCS(c_jalr, 0xf07f, 0x9002); 37 37 __RISCV_INSN_FUNCS(c_beqz, 0xe003, 0xc001); 38 38 __RISCV_INSN_FUNCS(c_bnez, 0xe003, 0xe001); 39 39 __RISCV_INSN_FUNCS(c_ebreak, 0xffff, 0x9002);
+13 -13
arch/x86/coco/tdx/tdx.c
··· 386 386 { 387 387 unsigned long *reg, val, vaddr; 388 388 char buffer[MAX_INSN_SIZE]; 389 + enum insn_mmio_type mmio; 389 390 struct insn insn = {}; 390 - enum mmio_type mmio; 391 391 int size, extend_size; 392 392 u8 extend_val = 0; 393 393 ··· 402 402 return -EINVAL; 403 403 404 404 mmio = insn_decode_mmio(&insn, &size); 405 - if (WARN_ON_ONCE(mmio == MMIO_DECODE_FAILED)) 405 + if (WARN_ON_ONCE(mmio == INSN_MMIO_DECODE_FAILED)) 406 406 return -EINVAL; 407 407 408 - if (mmio != MMIO_WRITE_IMM && mmio != MMIO_MOVS) { 408 + if (mmio != INSN_MMIO_WRITE_IMM && mmio != INSN_MMIO_MOVS) { 409 409 reg = insn_get_modrm_reg_ptr(&insn, regs); 410 410 if (!reg) 411 411 return -EINVAL; ··· 426 426 427 427 /* Handle writes first */ 428 428 switch (mmio) { 429 - case MMIO_WRITE: 429 + case INSN_MMIO_WRITE: 430 430 memcpy(&val, reg, size); 431 431 if (!mmio_write(size, ve->gpa, val)) 432 432 return -EIO; 433 433 return insn.length; 434 - case MMIO_WRITE_IMM: 434 + case INSN_MMIO_WRITE_IMM: 435 435 val = insn.immediate.value; 436 436 if (!mmio_write(size, ve->gpa, val)) 437 437 return -EIO; 438 438 return insn.length; 439 - case MMIO_READ: 440 - case MMIO_READ_ZERO_EXTEND: 441 - case MMIO_READ_SIGN_EXTEND: 439 + case INSN_MMIO_READ: 440 + case INSN_MMIO_READ_ZERO_EXTEND: 441 + case INSN_MMIO_READ_SIGN_EXTEND: 442 442 /* Reads are handled below */ 443 443 break; 444 - case MMIO_MOVS: 445 - case MMIO_DECODE_FAILED: 444 + case INSN_MMIO_MOVS: 445 + case INSN_MMIO_DECODE_FAILED: 446 446 /* 447 447 * MMIO was accessed with an instruction that could not be 448 448 * decoded or handled properly. It was likely not using io.h ··· 459 459 return -EIO; 460 460 461 461 switch (mmio) { 462 - case MMIO_READ: 462 + case INSN_MMIO_READ: 463 463 /* Zero-extend for 32-bit operation */ 464 464 extend_size = size == 4 ? sizeof(*reg) : 0; 465 465 break; 466 - case MMIO_READ_ZERO_EXTEND: 466 + case INSN_MMIO_READ_ZERO_EXTEND: 467 467 /* Zero extend based on operand size */ 468 468 extend_size = insn.opnd_bytes; 469 469 break; 470 - case MMIO_READ_SIGN_EXTEND: 470 + case INSN_MMIO_READ_SIGN_EXTEND: 471 471 /* Sign extend based on operand size */ 472 472 extend_size = insn.opnd_bytes; 473 473 if (size == 1 && val & BIT(7))
+1 -1
arch/x86/events/amd/core.c
··· 1387 1387 * numbered counter following it. 1388 1388 */ 1389 1389 for (i = 0; i < x86_pmu.num_counters - 1; i += 2) 1390 - even_ctr_mask |= 1 << i; 1390 + even_ctr_mask |= BIT_ULL(i); 1391 1391 1392 1392 pair_constraint = (struct event_constraint) 1393 1393 __EVENT_CONSTRAINT(0, even_ctr_mask, 0,
+5
arch/x86/events/rapl.c
··· 800 800 X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, &model_hsx), 801 801 X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE_L, &model_skl), 802 802 X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE, &model_skl), 803 + X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE_L, &model_skl), 804 + X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE, &model_skl), 803 805 X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE, &model_skl), 804 806 X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L, &model_skl), 805 807 X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_N, &model_skl), 806 808 X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, &model_spr), 809 + X86_MATCH_INTEL_FAM6_MODEL(EMERALDRAPIDS_X, &model_spr), 807 810 X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE, &model_skl), 808 811 X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE_P, &model_skl), 809 812 X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE_S, &model_skl), 813 + X86_MATCH_INTEL_FAM6_MODEL(METEORLAKE, &model_skl), 814 + X86_MATCH_INTEL_FAM6_MODEL(METEORLAKE_L, &model_skl), 810 815 {}, 811 816 }; 812 817 MODULE_DEVICE_TABLE(x86cpu, rapl_model_match);
+9 -9
arch/x86/include/asm/insn-eval.h
··· 32 32 bool insn_decode_from_regs(struct insn *insn, struct pt_regs *regs, 33 33 unsigned char buf[MAX_INSN_SIZE], int buf_size); 34 34 35 - enum mmio_type { 36 - MMIO_DECODE_FAILED, 37 - MMIO_WRITE, 38 - MMIO_WRITE_IMM, 39 - MMIO_READ, 40 - MMIO_READ_ZERO_EXTEND, 41 - MMIO_READ_SIGN_EXTEND, 42 - MMIO_MOVS, 35 + enum insn_mmio_type { 36 + INSN_MMIO_DECODE_FAILED, 37 + INSN_MMIO_WRITE, 38 + INSN_MMIO_WRITE_IMM, 39 + INSN_MMIO_READ, 40 + INSN_MMIO_READ_ZERO_EXTEND, 41 + INSN_MMIO_READ_SIGN_EXTEND, 42 + INSN_MMIO_MOVS, 43 43 }; 44 44 45 - enum mmio_type insn_decode_mmio(struct insn *insn, int *bytes); 45 + enum insn_mmio_type insn_decode_mmio(struct insn *insn, int *bytes); 46 46 47 47 #endif /* _ASM_X86_INSN_EVAL_H */
+2 -2
arch/x86/kernel/callthunks.c
··· 119 119 return within_module_coretext(addr); 120 120 } 121 121 122 - static __init_or_module bool skip_addr(void *dest) 122 + static bool skip_addr(void *dest) 123 123 { 124 124 if (dest == error_entry) 125 125 return true; ··· 181 181 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 182 182 }; 183 183 184 - static __init_or_module void *patch_dest(void *dest, bool direct) 184 + static void *patch_dest(void *dest, bool direct) 185 185 { 186 186 unsigned int tsize = SKL_TMPL_SIZE; 187 187 u8 *pad = dest - tsize;
+2
arch/x86/kernel/cpu/bugs.c
··· 1981 1981 if (ctrl == PR_SPEC_FORCE_DISABLE) 1982 1982 task_set_spec_ib_force_disable(task); 1983 1983 task_update_spec_tif(task); 1984 + if (task == current) 1985 + indirect_branch_prediction_barrier(); 1984 1986 break; 1985 1987 default: 1986 1988 return -ERANGE;
+1 -3
arch/x86/kernel/crash.c
··· 401 401 kbuf.buf_align = ELF_CORE_HEADER_ALIGN; 402 402 kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; 403 403 ret = kexec_add_buffer(&kbuf); 404 - if (ret) { 405 - vfree((void *)image->elf_headers); 404 + if (ret) 406 405 return ret; 407 - } 408 406 image->elf_load_addr = kbuf.mem; 409 407 pr_debug("Loaded ELF headers at 0x%lx bufsz=0x%lx memsz=0x%lx\n", 410 408 image->elf_load_addr, kbuf.bufsz, kbuf.memsz);
+7 -3
arch/x86/kernel/kprobes/core.c
··· 37 37 #include <linux/extable.h> 38 38 #include <linux/kdebug.h> 39 39 #include <linux/kallsyms.h> 40 + #include <linux/kgdb.h> 40 41 #include <linux/ftrace.h> 41 42 #include <linux/kasan.h> 42 43 #include <linux/moduleloader.h> ··· 282 281 if (ret < 0) 283 282 return 0; 284 283 284 + #ifdef CONFIG_KGDB 285 285 /* 286 - * Another debugging subsystem might insert this breakpoint. 287 - * In that case, we can't recover it. 286 + * If there is a dynamically installed kgdb sw breakpoint, 287 + * this function should not be probed. 288 288 */ 289 - if (insn.opcode.bytes[0] == INT3_INSN_OPCODE) 289 + if (insn.opcode.bytes[0] == INT3_INSN_OPCODE && 290 + kgdb_has_hit_break(addr)) 290 291 return 0; 292 + #endif 291 293 addr += insn.length; 292 294 } 293 295
+8 -20
arch/x86/kernel/kprobes/opt.c
··· 15 15 #include <linux/extable.h> 16 16 #include <linux/kdebug.h> 17 17 #include <linux/kallsyms.h> 18 + #include <linux/kgdb.h> 18 19 #include <linux/ftrace.h> 19 20 #include <linux/objtool.h> 20 21 #include <linux/pgtable.h> ··· 280 279 return ret; 281 280 } 282 281 283 - static bool is_padding_int3(unsigned long addr, unsigned long eaddr) 284 - { 285 - unsigned char ops; 286 - 287 - for (; addr < eaddr; addr++) { 288 - if (get_kernel_nofault(ops, (void *)addr) < 0 || 289 - ops != INT3_INSN_OPCODE) 290 - return false; 291 - } 292 - 293 - return true; 294 - } 295 - 296 282 /* Decode whole function to ensure any instructions don't jump into target */ 297 283 static int can_optimize(unsigned long paddr) 298 284 { ··· 322 334 ret = insn_decode_kernel(&insn, (void *)recovered_insn); 323 335 if (ret < 0) 324 336 return 0; 325 - 337 + #ifdef CONFIG_KGDB 326 338 /* 327 - * In the case of detecting unknown breakpoint, this could be 328 - * a padding INT3 between functions. Let's check that all the 329 - * rest of the bytes are also INT3. 339 + * If there is a dynamically installed kgdb sw breakpoint, 340 + * this function should not be probed. 330 341 */ 331 - if (insn.opcode.bytes[0] == INT3_INSN_OPCODE) 332 - return is_padding_int3(addr, paddr - offset + size) ? 1 : 0; 333 - 342 + if (insn.opcode.bytes[0] == INT3_INSN_OPCODE && 343 + kgdb_has_hit_break(addr)) 344 + return 0; 345 + #endif 334 346 /* Recover address */ 335 347 insn.kaddr = (void *)addr; 336 348 insn.next_byte = (void *)(addr + insn.length);
+9 -9
arch/x86/kernel/sev.c
··· 1536 1536 static enum es_result vc_handle_mmio(struct ghcb *ghcb, struct es_em_ctxt *ctxt) 1537 1537 { 1538 1538 struct insn *insn = &ctxt->insn; 1539 + enum insn_mmio_type mmio; 1539 1540 unsigned int bytes = 0; 1540 - enum mmio_type mmio; 1541 1541 enum es_result ret; 1542 1542 u8 sign_byte; 1543 1543 long *reg_data; 1544 1544 1545 1545 mmio = insn_decode_mmio(insn, &bytes); 1546 - if (mmio == MMIO_DECODE_FAILED) 1546 + if (mmio == INSN_MMIO_DECODE_FAILED) 1547 1547 return ES_DECODE_FAILED; 1548 1548 1549 - if (mmio != MMIO_WRITE_IMM && mmio != MMIO_MOVS) { 1549 + if (mmio != INSN_MMIO_WRITE_IMM && mmio != INSN_MMIO_MOVS) { 1550 1550 reg_data = insn_get_modrm_reg_ptr(insn, ctxt->regs); 1551 1551 if (!reg_data) 1552 1552 return ES_DECODE_FAILED; 1553 1553 } 1554 1554 1555 1555 switch (mmio) { 1556 - case MMIO_WRITE: 1556 + case INSN_MMIO_WRITE: 1557 1557 memcpy(ghcb->shared_buffer, reg_data, bytes); 1558 1558 ret = vc_do_mmio(ghcb, ctxt, bytes, false); 1559 1559 break; 1560 - case MMIO_WRITE_IMM: 1560 + case INSN_MMIO_WRITE_IMM: 1561 1561 memcpy(ghcb->shared_buffer, insn->immediate1.bytes, bytes); 1562 1562 ret = vc_do_mmio(ghcb, ctxt, bytes, false); 1563 1563 break; 1564 - case MMIO_READ: 1564 + case INSN_MMIO_READ: 1565 1565 ret = vc_do_mmio(ghcb, ctxt, bytes, true); 1566 1566 if (ret) 1567 1567 break; ··· 1572 1572 1573 1573 memcpy(reg_data, ghcb->shared_buffer, bytes); 1574 1574 break; 1575 - case MMIO_READ_ZERO_EXTEND: 1575 + case INSN_MMIO_READ_ZERO_EXTEND: 1576 1576 ret = vc_do_mmio(ghcb, ctxt, bytes, true); 1577 1577 if (ret) 1578 1578 break; ··· 1581 1581 memset(reg_data, 0, insn->opnd_bytes); 1582 1582 memcpy(reg_data, ghcb->shared_buffer, bytes); 1583 1583 break; 1584 - case MMIO_READ_SIGN_EXTEND: 1584 + case INSN_MMIO_READ_SIGN_EXTEND: 1585 1585 ret = vc_do_mmio(ghcb, ctxt, bytes, true); 1586 1586 if (ret) 1587 1587 break; ··· 1600 1600 memset(reg_data, sign_byte, insn->opnd_bytes); 1601 1601 memcpy(reg_data, ghcb->shared_buffer, bytes); 1602 1602 break; 1603 - case MMIO_MOVS: 1603 + case INSN_MMIO_MOVS: 1604 1604 ret = vc_handle_mmio_movs(ctxt, bytes); 1605 1605 break; 1606 1606 default:
+36 -27
arch/x86/kvm/hyperv.c
··· 1769 1769 } 1770 1770 1771 1771 struct kvm_hv_hcall { 1772 + /* Hypercall input data */ 1772 1773 u64 param; 1773 1774 u64 ingpa; 1774 1775 u64 outgpa; ··· 1780 1779 bool fast; 1781 1780 bool rep; 1782 1781 sse128_t xmm[HV_HYPERCALL_MAX_XMM_REGISTERS]; 1782 + 1783 + /* 1784 + * Current read offset when KVM reads hypercall input data gradually, 1785 + * either offset in bytes from 'ingpa' for regular hypercalls or the 1786 + * number of already consumed 'XMM halves' for 'fast' hypercalls. 1787 + */ 1788 + union { 1789 + gpa_t data_offset; 1790 + int consumed_xmm_halves; 1791 + }; 1783 1792 }; 1784 1793 1785 1794 1786 1795 static int kvm_hv_get_hc_data(struct kvm *kvm, struct kvm_hv_hcall *hc, 1787 - u16 orig_cnt, u16 cnt_cap, u64 *data, 1788 - int consumed_xmm_halves, gpa_t offset) 1796 + u16 orig_cnt, u16 cnt_cap, u64 *data) 1789 1797 { 1790 1798 /* 1791 1799 * Preserve the original count when ignoring entries via a "cap", KVM ··· 1809 1799 * Each XMM holds two sparse banks, but do not count halves that 1810 1800 * have already been consumed for hypercall parameters. 1811 1801 */ 1812 - if (orig_cnt > 2 * HV_HYPERCALL_MAX_XMM_REGISTERS - consumed_xmm_halves) 1802 + if (orig_cnt > 2 * HV_HYPERCALL_MAX_XMM_REGISTERS - hc->consumed_xmm_halves) 1813 1803 return HV_STATUS_INVALID_HYPERCALL_INPUT; 1814 1804 1815 1805 for (i = 0; i < cnt; i++) { 1816 - j = i + consumed_xmm_halves; 1806 + j = i + hc->consumed_xmm_halves; 1817 1807 if (j % 2) 1818 1808 data[i] = sse128_hi(hc->xmm[j / 2]); 1819 1809 else ··· 1822 1812 return 0; 1823 1813 } 1824 1814 1825 - return kvm_read_guest(kvm, hc->ingpa + offset, data, 1815 + return kvm_read_guest(kvm, hc->ingpa + hc->data_offset, data, 1826 1816 cnt * sizeof(*data)); 1827 1817 } 1828 1818 1829 1819 static u64 kvm_get_sparse_vp_set(struct kvm *kvm, struct kvm_hv_hcall *hc, 1830 - u64 *sparse_banks, int consumed_xmm_halves, 1831 - gpa_t offset) 1820 + u64 *sparse_banks) 1832 1821 { 1833 1822 if (hc->var_cnt > HV_MAX_SPARSE_VCPU_BANKS) 1834 1823 return -EINVAL; 1835 1824 1836 1825 /* Cap var_cnt to ignore banks that cannot contain a legal VP index. */ 1837 1826 return kvm_hv_get_hc_data(kvm, hc, hc->var_cnt, KVM_HV_MAX_SPARSE_VCPU_SET_BITS, 1838 - sparse_banks, consumed_xmm_halves, offset); 1827 + sparse_banks); 1839 1828 } 1840 1829 1841 - static int kvm_hv_get_tlb_flush_entries(struct kvm *kvm, struct kvm_hv_hcall *hc, u64 entries[], 1842 - int consumed_xmm_halves, gpa_t offset) 1830 + static int kvm_hv_get_tlb_flush_entries(struct kvm *kvm, struct kvm_hv_hcall *hc, u64 entries[]) 1843 1831 { 1844 - return kvm_hv_get_hc_data(kvm, hc, hc->rep_cnt, hc->rep_cnt, 1845 - entries, consumed_xmm_halves, offset); 1832 + return kvm_hv_get_hc_data(kvm, hc, hc->rep_cnt, hc->rep_cnt, entries); 1846 1833 } 1847 1834 1848 1835 static void hv_tlb_flush_enqueue(struct kvm_vcpu *vcpu, ··· 1933 1926 struct kvm_vcpu *v; 1934 1927 unsigned long i; 1935 1928 bool all_cpus; 1936 - int consumed_xmm_halves = 0; 1937 - gpa_t data_offset; 1938 1929 1939 1930 /* 1940 1931 * The Hyper-V TLFS doesn't allow more than HV_MAX_SPARSE_VCPU_BANKS ··· 1960 1955 flush.address_space = hc->ingpa; 1961 1956 flush.flags = hc->outgpa; 1962 1957 flush.processor_mask = sse128_lo(hc->xmm[0]); 1963 - consumed_xmm_halves = 1; 1958 + hc->consumed_xmm_halves = 1; 1964 1959 } else { 1965 1960 if (unlikely(kvm_read_guest(kvm, hc->ingpa, 1966 1961 &flush, sizeof(flush)))) 1967 1962 return HV_STATUS_INVALID_HYPERCALL_INPUT; 1968 - data_offset = sizeof(flush); 1963 + hc->data_offset = sizeof(flush); 1969 1964 } 1970 1965 1971 1966 trace_kvm_hv_flush_tlb(flush.processor_mask, ··· 1990 1985 flush_ex.flags = hc->outgpa; 1991 1986 memcpy(&flush_ex.hv_vp_set, 1992 1987 &hc->xmm[0], sizeof(hc->xmm[0])); 1993 - consumed_xmm_halves = 2; 1988 + hc->consumed_xmm_halves = 2; 1994 1989 } else { 1995 1990 if (unlikely(kvm_read_guest(kvm, hc->ingpa, &flush_ex, 1996 1991 sizeof(flush_ex)))) 1997 1992 return HV_STATUS_INVALID_HYPERCALL_INPUT; 1998 - data_offset = sizeof(flush_ex); 1993 + hc->data_offset = sizeof(flush_ex); 1999 1994 } 2000 1995 2001 1996 trace_kvm_hv_flush_tlb_ex(flush_ex.hv_vp_set.valid_bank_mask, ··· 2014 2009 if (!hc->var_cnt) 2015 2010 goto ret_success; 2016 2011 2017 - if (kvm_get_sparse_vp_set(kvm, hc, sparse_banks, 2018 - consumed_xmm_halves, data_offset)) 2012 + if (kvm_get_sparse_vp_set(kvm, hc, sparse_banks)) 2019 2013 return HV_STATUS_INVALID_HYPERCALL_INPUT; 2020 2014 } 2021 2015 ··· 2025 2021 * consumed_xmm_halves to make sure TLB flush entries are read 2026 2022 * from the correct offset. 2027 2023 */ 2028 - data_offset += hc->var_cnt * sizeof(sparse_banks[0]); 2029 - consumed_xmm_halves += hc->var_cnt; 2024 + if (hc->fast) 2025 + hc->consumed_xmm_halves += hc->var_cnt; 2026 + else 2027 + hc->data_offset += hc->var_cnt * sizeof(sparse_banks[0]); 2030 2028 } 2031 2029 2032 2030 if (hc->code == HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE || ··· 2036 2030 hc->rep_cnt > ARRAY_SIZE(__tlb_flush_entries)) { 2037 2031 tlb_flush_entries = NULL; 2038 2032 } else { 2039 - if (kvm_hv_get_tlb_flush_entries(kvm, hc, __tlb_flush_entries, 2040 - consumed_xmm_halves, data_offset)) 2033 + if (kvm_hv_get_tlb_flush_entries(kvm, hc, __tlb_flush_entries)) 2041 2034 return HV_STATUS_INVALID_HYPERCALL_INPUT; 2042 2035 tlb_flush_entries = __tlb_flush_entries; 2043 2036 } ··· 2185 2180 if (!hc->var_cnt) 2186 2181 goto ret_success; 2187 2182 2188 - if (kvm_get_sparse_vp_set(kvm, hc, sparse_banks, 1, 2189 - offsetof(struct hv_send_ipi_ex, 2190 - vp_set.bank_contents))) 2183 + if (!hc->fast) 2184 + hc->data_offset = offsetof(struct hv_send_ipi_ex, 2185 + vp_set.bank_contents); 2186 + else 2187 + hc->consumed_xmm_halves = 1; 2188 + 2189 + if (kvm_get_sparse_vp_set(kvm, hc, sparse_banks)) 2191 2190 return HV_STATUS_INVALID_HYPERCALL_INPUT; 2192 2191 } 2193 2192
+3 -2
arch/x86/kvm/irq_comm.c
··· 426 426 kvm_set_msi_irq(vcpu->kvm, entry, &irq); 427 427 428 428 if (irq.trig_mode && 429 - kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT, 430 - irq.dest_id, irq.dest_mode)) 429 + (kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT, 430 + irq.dest_id, irq.dest_mode) || 431 + kvm_apic_pending_eoi(vcpu, irq.vector))) 431 432 __set_bit(irq.vector, ioapic_handled_vectors); 432 433 } 433 434 }
+2 -2
arch/x86/kvm/lapic.h
··· 188 188 189 189 extern struct static_key_false_deferred apic_hw_disabled; 190 190 191 - static inline int kvm_apic_hw_enabled(struct kvm_lapic *apic) 191 + static inline bool kvm_apic_hw_enabled(struct kvm_lapic *apic) 192 192 { 193 193 if (static_branch_unlikely(&apic_hw_disabled.key)) 194 194 return apic->vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE; 195 - return MSR_IA32_APICBASE_ENABLE; 195 + return true; 196 196 } 197 197 198 198 extern struct static_key_false_deferred apic_sw_disabled;
+1 -1
arch/x86/kvm/mmu/spte.h
··· 363 363 * A shadow-present leaf SPTE may be non-writable for 4 possible reasons: 364 364 * 365 365 * 1. To intercept writes for dirty logging. KVM write-protects huge pages 366 - * so that they can be split be split down into the dirty logging 366 + * so that they can be split down into the dirty logging 367 367 * granularity (4KiB) whenever the guest writes to them. KVM also 368 368 * write-protects 4KiB pages so that writes can be recorded in the dirty log 369 369 * (e.g. if not using PML). SPTEs are write-protected for dirty logging
+18 -7
arch/x86/kvm/mmu/tdp_mmu.c
··· 1074 1074 int ret = RET_PF_FIXED; 1075 1075 bool wrprot = false; 1076 1076 1077 - WARN_ON(sp->role.level != fault->goal_level); 1077 + if (WARN_ON_ONCE(sp->role.level != fault->goal_level)) 1078 + return RET_PF_RETRY; 1079 + 1078 1080 if (unlikely(!fault->slot)) 1079 1081 new_spte = make_mmio_spte(vcpu, iter->gfn, ACC_ALL); 1080 1082 else ··· 1175 1173 if (fault->nx_huge_page_workaround_enabled) 1176 1174 disallowed_hugepage_adjust(fault, iter.old_spte, iter.level); 1177 1175 1178 - if (iter.level == fault->goal_level) 1179 - break; 1180 - 1181 1176 /* 1182 1177 * If SPTE has been frozen by another thread, just give up and 1183 1178 * retry, avoiding unnecessary page table allocation and free. 1184 1179 */ 1185 1180 if (is_removed_spte(iter.old_spte)) 1186 1181 goto retry; 1182 + 1183 + if (iter.level == fault->goal_level) 1184 + goto map_target_level; 1187 1185 1188 1186 /* Step down into the lower level page table if it exists. */ 1189 1187 if (is_shadow_present_pte(iter.old_spte) && ··· 1205 1203 r = tdp_mmu_link_sp(kvm, &iter, sp, true); 1206 1204 1207 1205 /* 1208 - * Also force the guest to retry the access if the upper level SPTEs 1209 - * aren't in place. 1206 + * Force the guest to retry if installing an upper level SPTE 1207 + * failed, e.g. because a different task modified the SPTE. 1210 1208 */ 1211 1209 if (r) { 1212 1210 tdp_mmu_free_sp(sp); ··· 1216 1214 if (fault->huge_page_disallowed && 1217 1215 fault->req_level >= iter.level) { 1218 1216 spin_lock(&kvm->arch.tdp_mmu_pages_lock); 1219 - track_possible_nx_huge_page(kvm, sp); 1217 + if (sp->nx_huge_page_disallowed) 1218 + track_possible_nx_huge_page(kvm, sp); 1220 1219 spin_unlock(&kvm->arch.tdp_mmu_pages_lock); 1221 1220 } 1222 1221 } 1223 1222 1223 + /* 1224 + * The walk aborted before reaching the target level, e.g. because the 1225 + * iterator detected an upper level SPTE was frozen during traversal. 1226 + */ 1227 + WARN_ON_ONCE(iter.level == fault->goal_level); 1228 + goto retry; 1229 + 1230 + map_target_level: 1224 1231 ret = tdp_mmu_map_handle_target_level(vcpu, fault, &iter); 1225 1232 1226 1233 retry:
+2 -1
arch/x86/kvm/pmu.c
··· 238 238 return false; 239 239 240 240 /* recalibrate sample period and check if it's accepted by perf core */ 241 - if (perf_event_period(pmc->perf_event, 241 + if (is_sampling_event(pmc->perf_event) && 242 + perf_event_period(pmc->perf_event, 242 243 get_sample_period(pmc, pmc->counter))) 243 244 return false; 244 245
+2 -1
arch/x86/kvm/pmu.h
··· 140 140 141 141 static inline void pmc_update_sample_period(struct kvm_pmc *pmc) 142 142 { 143 - if (!pmc->perf_event || pmc->is_paused) 143 + if (!pmc->perf_event || pmc->is_paused || 144 + !is_sampling_event(pmc->perf_event)) 144 145 return; 145 146 146 147 perf_event_period(pmc->perf_event,
+15 -5
arch/x86/kvm/vmx/nested.c
··· 5296 5296 if (vmptr == vmx->nested.current_vmptr) 5297 5297 nested_release_vmcs12(vcpu); 5298 5298 5299 - kvm_vcpu_write_guest(vcpu, 5300 - vmptr + offsetof(struct vmcs12, 5301 - launch_state), 5302 - &zero, sizeof(zero)); 5299 + /* 5300 + * Silently ignore memory errors on VMCLEAR, Intel's pseudocode 5301 + * for VMCLEAR includes a "ensure that data for VMCS referenced 5302 + * by the operand is in memory" clause that guards writes to 5303 + * memory, i.e. doing nothing for I/O is architecturally valid. 5304 + * 5305 + * FIXME: Suppress failures if and only if no memslot is found, 5306 + * i.e. exit to userspace if __copy_to_user() fails. 5307 + */ 5308 + (void)kvm_vcpu_write_guest(vcpu, 5309 + vmptr + offsetof(struct vmcs12, 5310 + launch_state), 5311 + &zero, sizeof(zero)); 5303 5312 } else if (vmx->nested.hv_evmcs && vmptr == vmx->nested.hv_evmcs_vmptr) { 5304 5313 nested_release_evmcs(vcpu); 5305 5314 } ··· 6882 6873 SECONDARY_EXEC_ENABLE_INVPCID | 6883 6874 SECONDARY_EXEC_RDSEED_EXITING | 6884 6875 SECONDARY_EXEC_XSAVES | 6885 - SECONDARY_EXEC_TSC_SCALING; 6876 + SECONDARY_EXEC_TSC_SCALING | 6877 + SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE; 6886 6878 6887 6879 /* 6888 6880 * We can emulate "VMCS shadowing," even if the hardware
+7
arch/x86/kvm/vmx/vmx.c
··· 4459 4459 * controls for features that are/aren't exposed to the guest. 4460 4460 */ 4461 4461 if (nested) { 4462 + /* 4463 + * All features that can be added or removed to VMX MSRs must 4464 + * be supported in the first place for nested virtualization. 4465 + */ 4466 + if (WARN_ON_ONCE(!(vmcs_config.nested.secondary_ctls_high & control))) 4467 + enabled = false; 4468 + 4462 4469 if (enabled) 4463 4470 vmx->nested.msrs.secondary_ctls_high |= control; 4464 4471 else
+3
arch/x86/kvm/x86.c
··· 13132 13132 struct x86_exception *e) 13133 13133 { 13134 13134 if (r == X86EMUL_PROPAGATE_FAULT) { 13135 + if (KVM_BUG_ON(!e, vcpu->kvm)) 13136 + return -EIO; 13137 + 13135 13138 kvm_inject_emulated_page_fault(vcpu, e); 13136 13139 return 1; 13137 13140 }
+75 -69
arch/x86/kvm/xen.c
··· 41 41 int ret = 0; 42 42 int idx = srcu_read_lock(&kvm->srcu); 43 43 44 - if (gfn == GPA_INVALID) { 44 + if (gfn == KVM_XEN_INVALID_GFN) { 45 45 kvm_gpc_deactivate(gpc); 46 46 goto out; 47 47 } ··· 659 659 if (kvm->arch.xen.shinfo_cache.active) 660 660 data->u.shared_info.gfn = gpa_to_gfn(kvm->arch.xen.shinfo_cache.gpa); 661 661 else 662 - data->u.shared_info.gfn = GPA_INVALID; 662 + data->u.shared_info.gfn = KVM_XEN_INVALID_GFN; 663 663 r = 0; 664 664 break; 665 665 ··· 705 705 BUILD_BUG_ON(offsetof(struct vcpu_info, time) != 706 706 offsetof(struct compat_vcpu_info, time)); 707 707 708 - if (data->u.gpa == GPA_INVALID) { 708 + if (data->u.gpa == KVM_XEN_INVALID_GPA) { 709 709 kvm_gpc_deactivate(&vcpu->arch.xen.vcpu_info_cache); 710 710 r = 0; 711 711 break; ··· 719 719 break; 720 720 721 721 case KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO: 722 - if (data->u.gpa == GPA_INVALID) { 722 + if (data->u.gpa == KVM_XEN_INVALID_GPA) { 723 723 kvm_gpc_deactivate(&vcpu->arch.xen.vcpu_time_info_cache); 724 724 r = 0; 725 725 break; ··· 739 739 r = -EOPNOTSUPP; 740 740 break; 741 741 } 742 - if (data->u.gpa == GPA_INVALID) { 742 + if (data->u.gpa == KVM_XEN_INVALID_GPA) { 743 743 r = 0; 744 744 deactivate_out: 745 745 kvm_gpc_deactivate(&vcpu->arch.xen.runstate_cache); ··· 937 937 if (vcpu->arch.xen.vcpu_info_cache.active) 938 938 data->u.gpa = vcpu->arch.xen.vcpu_info_cache.gpa; 939 939 else 940 - data->u.gpa = GPA_INVALID; 940 + data->u.gpa = KVM_XEN_INVALID_GPA; 941 941 r = 0; 942 942 break; 943 943 ··· 945 945 if (vcpu->arch.xen.vcpu_time_info_cache.active) 946 946 data->u.gpa = vcpu->arch.xen.vcpu_time_info_cache.gpa; 947 947 else 948 - data->u.gpa = GPA_INVALID; 948 + data->u.gpa = KVM_XEN_INVALID_GPA; 949 949 r = 0; 950 950 break; 951 951 ··· 1069 1069 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64 1070 1070 : kvm->arch.xen_hvm_config.blob_size_32; 1071 1071 u8 *page; 1072 + int ret; 1072 1073 1073 1074 if (page_num >= blob_size) 1074 1075 return 1; ··· 1080 1079 if (IS_ERR(page)) 1081 1080 return PTR_ERR(page); 1082 1081 1083 - if (kvm_vcpu_write_guest(vcpu, page_addr, page, PAGE_SIZE)) { 1084 - kfree(page); 1082 + ret = kvm_vcpu_write_guest(vcpu, page_addr, page, PAGE_SIZE); 1083 + kfree(page); 1084 + if (ret) 1085 1085 return 1; 1086 - } 1087 1086 } 1088 1087 return 0; 1089 1088 } ··· 1184 1183 static bool kvm_xen_schedop_poll(struct kvm_vcpu *vcpu, bool longmode, 1185 1184 u64 param, u64 *r) 1186 1185 { 1187 - int idx, i; 1188 1186 struct sched_poll sched_poll; 1189 1187 evtchn_port_t port, *ports; 1190 - gpa_t gpa; 1188 + struct x86_exception e; 1189 + int i; 1191 1190 1192 1191 if (!lapic_in_kernel(vcpu) || 1193 1192 !(vcpu->kvm->arch.xen_hvm_config.flags & KVM_XEN_HVM_CONFIG_EVTCHN_SEND)) 1194 1193 return false; 1195 - 1196 - idx = srcu_read_lock(&vcpu->kvm->srcu); 1197 - gpa = kvm_mmu_gva_to_gpa_system(vcpu, param, NULL); 1198 - srcu_read_unlock(&vcpu->kvm->srcu, idx); 1199 - if (!gpa) { 1200 - *r = -EFAULT; 1201 - return true; 1202 - } 1203 1194 1204 1195 if (IS_ENABLED(CONFIG_64BIT) && !longmode) { 1205 1196 struct compat_sched_poll sp32; ··· 1199 1206 /* Sanity check that the compat struct definition is correct */ 1200 1207 BUILD_BUG_ON(sizeof(sp32) != 16); 1201 1208 1202 - if (kvm_vcpu_read_guest(vcpu, gpa, &sp32, sizeof(sp32))) { 1209 + if (kvm_read_guest_virt(vcpu, param, &sp32, sizeof(sp32), &e)) { 1203 1210 *r = -EFAULT; 1204 1211 return true; 1205 1212 } ··· 1213 1220 sched_poll.nr_ports = sp32.nr_ports; 1214 1221 sched_poll.timeout = sp32.timeout; 1215 1222 } else { 1216 - if (kvm_vcpu_read_guest(vcpu, gpa, &sched_poll, 1217 - sizeof(sched_poll))) { 1223 + if (kvm_read_guest_virt(vcpu, param, &sched_poll, 1224 + sizeof(sched_poll), &e)) { 1218 1225 *r = -EFAULT; 1219 1226 return true; 1220 1227 } ··· 1236 1243 } else 1237 1244 ports = &port; 1238 1245 1239 - for (i = 0; i < sched_poll.nr_ports; i++) { 1240 - idx = srcu_read_lock(&vcpu->kvm->srcu); 1241 - gpa = kvm_mmu_gva_to_gpa_system(vcpu, 1242 - (gva_t)(sched_poll.ports + i), 1243 - NULL); 1244 - srcu_read_unlock(&vcpu->kvm->srcu, idx); 1246 + if (kvm_read_guest_virt(vcpu, (gva_t)sched_poll.ports, ports, 1247 + sched_poll.nr_ports * sizeof(*ports), &e)) { 1248 + *r = -EFAULT; 1249 + return true; 1250 + } 1245 1251 1246 - if (!gpa || kvm_vcpu_read_guest(vcpu, gpa, 1247 - &ports[i], sizeof(port))) { 1248 - *r = -EFAULT; 1249 - goto out; 1250 - } 1252 + for (i = 0; i < sched_poll.nr_ports; i++) { 1251 1253 if (ports[i] >= max_evtchn_port(vcpu->kvm)) { 1252 1254 *r = -EINVAL; 1253 1255 goto out; ··· 1318 1330 int vcpu_id, u64 param, u64 *r) 1319 1331 { 1320 1332 struct vcpu_set_singleshot_timer oneshot; 1333 + struct x86_exception e; 1321 1334 s64 delta; 1322 - gpa_t gpa; 1323 - int idx; 1324 1335 1325 1336 if (!kvm_xen_timer_enabled(vcpu)) 1326 1337 return false; ··· 1330 1343 *r = -EINVAL; 1331 1344 return true; 1332 1345 } 1333 - idx = srcu_read_lock(&vcpu->kvm->srcu); 1334 - gpa = kvm_mmu_gva_to_gpa_system(vcpu, param, NULL); 1335 - srcu_read_unlock(&vcpu->kvm->srcu, idx); 1336 1346 1337 1347 /* 1338 1348 * The only difference for 32-bit compat is the 4 bytes of ··· 1347 1363 BUILD_BUG_ON(sizeof_field(struct compat_vcpu_set_singleshot_timer, flags) != 1348 1364 sizeof_field(struct vcpu_set_singleshot_timer, flags)); 1349 1365 1350 - if (!gpa || 1351 - kvm_vcpu_read_guest(vcpu, gpa, &oneshot, longmode ? sizeof(oneshot) : 1352 - sizeof(struct compat_vcpu_set_singleshot_timer))) { 1366 + if (kvm_read_guest_virt(vcpu, param, &oneshot, longmode ? sizeof(oneshot) : 1367 + sizeof(struct compat_vcpu_set_singleshot_timer), &e)) { 1353 1368 *r = -EFAULT; 1354 1369 return true; 1355 1370 } ··· 1808 1825 { 1809 1826 u32 port = data->u.evtchn.send_port; 1810 1827 struct evtchnfd *evtchnfd; 1828 + int ret; 1811 1829 1812 - if (!port || port >= max_evtchn_port(kvm)) 1813 - return -EINVAL; 1814 - 1830 + /* Protect writes to evtchnfd as well as the idr lookup. */ 1815 1831 mutex_lock(&kvm->lock); 1816 1832 evtchnfd = idr_find(&kvm->arch.xen.evtchn_ports, port); 1817 - mutex_unlock(&kvm->lock); 1818 1833 1834 + ret = -ENOENT; 1819 1835 if (!evtchnfd) 1820 - return -ENOENT; 1836 + goto out_unlock; 1821 1837 1822 1838 /* For an UPDATE, nothing may change except the priority/vcpu */ 1839 + ret = -EINVAL; 1823 1840 if (evtchnfd->type != data->u.evtchn.type) 1824 - return -EINVAL; 1841 + goto out_unlock; 1825 1842 1826 1843 /* 1827 1844 * Port cannot change, and if it's zero that was an eventfd ··· 1829 1846 */ 1830 1847 if (!evtchnfd->deliver.port.port || 1831 1848 evtchnfd->deliver.port.port != data->u.evtchn.deliver.port.port) 1832 - return -EINVAL; 1849 + goto out_unlock; 1833 1850 1834 1851 /* We only support 2 level event channels for now */ 1835 1852 if (data->u.evtchn.deliver.port.priority != KVM_IRQ_ROUTING_XEN_EVTCHN_PRIO_2LEVEL) 1836 - return -EINVAL; 1853 + goto out_unlock; 1837 1854 1838 - mutex_lock(&kvm->lock); 1839 1855 evtchnfd->deliver.port.priority = data->u.evtchn.deliver.port.priority; 1840 1856 if (evtchnfd->deliver.port.vcpu_id != data->u.evtchn.deliver.port.vcpu) { 1841 1857 evtchnfd->deliver.port.vcpu_id = data->u.evtchn.deliver.port.vcpu; 1842 1858 evtchnfd->deliver.port.vcpu_idx = -1; 1843 1859 } 1860 + ret = 0; 1861 + out_unlock: 1844 1862 mutex_unlock(&kvm->lock); 1845 - return 0; 1863 + return ret; 1846 1864 } 1847 1865 1848 1866 /* ··· 1855 1871 { 1856 1872 u32 port = data->u.evtchn.send_port; 1857 1873 struct eventfd_ctx *eventfd = NULL; 1858 - struct evtchnfd *evtchnfd = NULL; 1874 + struct evtchnfd *evtchnfd; 1859 1875 int ret = -EINVAL; 1860 - 1861 - if (!port || port >= max_evtchn_port(kvm)) 1862 - return -EINVAL; 1863 1876 1864 1877 evtchnfd = kzalloc(sizeof(struct evtchnfd), GFP_KERNEL); 1865 1878 if (!evtchnfd) ··· 1933 1952 if (!evtchnfd) 1934 1953 return -ENOENT; 1935 1954 1936 - if (kvm) 1937 - synchronize_srcu(&kvm->srcu); 1955 + synchronize_srcu(&kvm->srcu); 1938 1956 if (!evtchnfd->deliver.port.port) 1939 1957 eventfd_ctx_put(evtchnfd->deliver.eventfd.ctx); 1940 1958 kfree(evtchnfd); ··· 1942 1962 1943 1963 static int kvm_xen_eventfd_reset(struct kvm *kvm) 1944 1964 { 1945 - struct evtchnfd *evtchnfd; 1965 + struct evtchnfd *evtchnfd, **all_evtchnfds; 1946 1966 int i; 1967 + int n = 0; 1947 1968 1948 1969 mutex_lock(&kvm->lock); 1970 + 1971 + /* 1972 + * Because synchronize_srcu() cannot be called inside the 1973 + * critical section, first collect all the evtchnfd objects 1974 + * in an array as they are removed from evtchn_ports. 1975 + */ 1976 + idr_for_each_entry(&kvm->arch.xen.evtchn_ports, evtchnfd, i) 1977 + n++; 1978 + 1979 + all_evtchnfds = kmalloc_array(n, sizeof(struct evtchnfd *), GFP_KERNEL); 1980 + if (!all_evtchnfds) { 1981 + mutex_unlock(&kvm->lock); 1982 + return -ENOMEM; 1983 + } 1984 + 1985 + n = 0; 1949 1986 idr_for_each_entry(&kvm->arch.xen.evtchn_ports, evtchnfd, i) { 1987 + all_evtchnfds[n++] = evtchnfd; 1950 1988 idr_remove(&kvm->arch.xen.evtchn_ports, evtchnfd->send_port); 1951 - synchronize_srcu(&kvm->srcu); 1989 + } 1990 + mutex_unlock(&kvm->lock); 1991 + 1992 + synchronize_srcu(&kvm->srcu); 1993 + 1994 + while (n--) { 1995 + evtchnfd = all_evtchnfds[n]; 1952 1996 if (!evtchnfd->deliver.port.port) 1953 1997 eventfd_ctx_put(evtchnfd->deliver.eventfd.ctx); 1954 1998 kfree(evtchnfd); 1955 1999 } 1956 - mutex_unlock(&kvm->lock); 2000 + kfree(all_evtchnfds); 1957 2001 1958 2002 return 0; 1959 2003 } ··· 2006 2002 { 2007 2003 struct evtchnfd *evtchnfd; 2008 2004 struct evtchn_send send; 2009 - gpa_t gpa; 2010 - int idx; 2005 + struct x86_exception e; 2011 2006 2012 - idx = srcu_read_lock(&vcpu->kvm->srcu); 2013 - gpa = kvm_mmu_gva_to_gpa_system(vcpu, param, NULL); 2014 - srcu_read_unlock(&vcpu->kvm->srcu, idx); 2015 - 2016 - if (!gpa || kvm_vcpu_read_guest(vcpu, gpa, &send, sizeof(send))) { 2007 + /* Sanity check: this structure is the same for 32-bit and 64-bit */ 2008 + BUILD_BUG_ON(sizeof(send) != 4); 2009 + if (kvm_read_guest_virt(vcpu, param, &send, sizeof(send), &e)) { 2017 2010 *r = -EFAULT; 2018 2011 return true; 2019 2012 } 2020 2013 2021 - /* The evtchn_ports idr is protected by vcpu->kvm->srcu */ 2014 + /* 2015 + * evtchnfd is protected by kvm->srcu; the idr lookup instead 2016 + * is protected by RCU. 2017 + */ 2018 + rcu_read_lock(); 2022 2019 evtchnfd = idr_find(&vcpu->kvm->arch.xen.evtchn_ports, send.port); 2020 + rcu_read_unlock(); 2023 2021 if (!evtchnfd) 2024 2022 return false; 2025 2023
+10 -10
arch/x86/lib/insn-eval.c
··· 1595 1595 * Returns: 1596 1596 * 1597 1597 * Type of the instruction. Size of the memory operand is stored in 1598 - * @bytes. If decode failed, MMIO_DECODE_FAILED returned. 1598 + * @bytes. If decode failed, INSN_MMIO_DECODE_FAILED returned. 1599 1599 */ 1600 - enum mmio_type insn_decode_mmio(struct insn *insn, int *bytes) 1600 + enum insn_mmio_type insn_decode_mmio(struct insn *insn, int *bytes) 1601 1601 { 1602 - enum mmio_type type = MMIO_DECODE_FAILED; 1602 + enum insn_mmio_type type = INSN_MMIO_DECODE_FAILED; 1603 1603 1604 1604 *bytes = 0; 1605 1605 1606 1606 if (insn_get_opcode(insn)) 1607 - return MMIO_DECODE_FAILED; 1607 + return INSN_MMIO_DECODE_FAILED; 1608 1608 1609 1609 switch (insn->opcode.bytes[0]) { 1610 1610 case 0x88: /* MOV m8,r8 */ ··· 1613 1613 case 0x89: /* MOV m16/m32/m64, r16/m32/m64 */ 1614 1614 if (!*bytes) 1615 1615 *bytes = insn->opnd_bytes; 1616 - type = MMIO_WRITE; 1616 + type = INSN_MMIO_WRITE; 1617 1617 break; 1618 1618 1619 1619 case 0xc6: /* MOV m8, imm8 */ ··· 1622 1622 case 0xc7: /* MOV m16/m32/m64, imm16/imm32/imm64 */ 1623 1623 if (!*bytes) 1624 1624 *bytes = insn->opnd_bytes; 1625 - type = MMIO_WRITE_IMM; 1625 + type = INSN_MMIO_WRITE_IMM; 1626 1626 break; 1627 1627 1628 1628 case 0x8a: /* MOV r8, m8 */ ··· 1631 1631 case 0x8b: /* MOV r16/r32/r64, m16/m32/m64 */ 1632 1632 if (!*bytes) 1633 1633 *bytes = insn->opnd_bytes; 1634 - type = MMIO_READ; 1634 + type = INSN_MMIO_READ; 1635 1635 break; 1636 1636 1637 1637 case 0xa4: /* MOVS m8, m8 */ ··· 1640 1640 case 0xa5: /* MOVS m16/m32/m64, m16/m32/m64 */ 1641 1641 if (!*bytes) 1642 1642 *bytes = insn->opnd_bytes; 1643 - type = MMIO_MOVS; 1643 + type = INSN_MMIO_MOVS; 1644 1644 break; 1645 1645 1646 1646 case 0x0f: /* Two-byte instruction */ ··· 1651 1651 case 0xb7: /* MOVZX r32/r64, m16 */ 1652 1652 if (!*bytes) 1653 1653 *bytes = 2; 1654 - type = MMIO_READ_ZERO_EXTEND; 1654 + type = INSN_MMIO_READ_ZERO_EXTEND; 1655 1655 break; 1656 1656 1657 1657 case 0xbe: /* MOVSX r16/r32/r64, m8 */ ··· 1660 1660 case 0xbf: /* MOVSX r32/r64, m16 */ 1661 1661 if (!*bytes) 1662 1662 *bytes = 2; 1663 - type = MMIO_READ_SIGN_EXTEND; 1663 + type = INSN_MMIO_READ_SIGN_EXTEND; 1664 1664 break; 1665 1665 } 1666 1666 break;
+1 -1
arch/x86/lib/iomap_copy_64.S
··· 10 10 */ 11 11 SYM_FUNC_START(__iowrite32_copy) 12 12 movl %edx,%ecx 13 - rep movsd 13 + rep movsl 14 14 RET 15 15 SYM_FUNC_END(__iowrite32_copy)
-1
block/Kconfig
··· 6 6 bool "Enable the block layer" if EXPERT 7 7 default y 8 8 select SBITMAP 9 - select SRCU 10 9 help 11 10 Provide block layer support for the kernel. 12 11
+1 -1
block/bfq-iosched.c
··· 5317 5317 unsigned long flags; 5318 5318 5319 5319 spin_lock_irqsave(&bfqd->lock, flags); 5320 - bfq_exit_bfqq(bfqd, bfqq); 5321 5320 bic_set_bfqq(bic, NULL, is_sync); 5321 + bfq_exit_bfqq(bfqd, bfqq); 5322 5322 spin_unlock_irqrestore(&bfqd->lock, flags); 5323 5323 } 5324 5324 }
+22 -15
block/bio.c
··· 1401 1401 } 1402 1402 EXPORT_SYMBOL(__bio_advance); 1403 1403 1404 + void bio_copy_data_iter(struct bio *dst, struct bvec_iter *dst_iter, 1405 + struct bio *src, struct bvec_iter *src_iter) 1406 + { 1407 + while (src_iter->bi_size && dst_iter->bi_size) { 1408 + struct bio_vec src_bv = bio_iter_iovec(src, *src_iter); 1409 + struct bio_vec dst_bv = bio_iter_iovec(dst, *dst_iter); 1410 + unsigned int bytes = min(src_bv.bv_len, dst_bv.bv_len); 1411 + void *src_buf = bvec_kmap_local(&src_bv); 1412 + void *dst_buf = bvec_kmap_local(&dst_bv); 1413 + 1414 + memcpy(dst_buf, src_buf, bytes); 1415 + 1416 + kunmap_local(dst_buf); 1417 + kunmap_local(src_buf); 1418 + 1419 + bio_advance_iter_single(src, src_iter, bytes); 1420 + bio_advance_iter_single(dst, dst_iter, bytes); 1421 + } 1422 + } 1423 + EXPORT_SYMBOL(bio_copy_data_iter); 1424 + 1404 1425 /** 1405 1426 * bio_copy_data - copy contents of data buffers from one bio to another 1406 1427 * @src: source bio ··· 1435 1414 struct bvec_iter src_iter = src->bi_iter; 1436 1415 struct bvec_iter dst_iter = dst->bi_iter; 1437 1416 1438 - while (src_iter.bi_size && dst_iter.bi_size) { 1439 - struct bio_vec src_bv = bio_iter_iovec(src, src_iter); 1440 - struct bio_vec dst_bv = bio_iter_iovec(dst, dst_iter); 1441 - unsigned int bytes = min(src_bv.bv_len, dst_bv.bv_len); 1442 - void *src_buf = bvec_kmap_local(&src_bv); 1443 - void *dst_buf = bvec_kmap_local(&dst_bv); 1444 - 1445 - memcpy(dst_buf, src_buf, bytes); 1446 - 1447 - kunmap_local(dst_buf); 1448 - kunmap_local(src_buf); 1449 - 1450 - bio_advance_iter_single(src, &src_iter, bytes); 1451 - bio_advance_iter_single(dst, &dst_iter, bytes); 1452 - } 1417 + bio_copy_data_iter(dst, &dst_iter, src, &src_iter); 1453 1418 } 1454 1419 EXPORT_SYMBOL(bio_copy_data); 1455 1420
+13 -1
block/blk-merge.c
··· 309 309 *segs = nsegs; 310 310 return NULL; 311 311 split: 312 + /* 313 + * We can't sanely support splitting for a REQ_NOWAIT bio. End it 314 + * with EAGAIN if splitting is required and return an error pointer. 315 + */ 316 + if (bio->bi_opf & REQ_NOWAIT) { 317 + bio->bi_status = BLK_STS_AGAIN; 318 + bio_endio(bio); 319 + return ERR_PTR(-EAGAIN); 320 + } 321 + 312 322 *segs = nsegs; 313 323 314 324 /* ··· 368 358 default: 369 359 split = bio_split_rw(bio, lim, nr_segs, bs, 370 360 get_max_io_size(bio, lim) << SECTOR_SHIFT); 361 + if (IS_ERR(split)) 362 + return NULL; 371 363 break; 372 364 } 373 365 374 366 if (split) { 375 - /* there isn't chance to merge the splitted bio */ 367 + /* there isn't chance to merge the split bio */ 376 368 split->bi_opf |= REQ_NOMERGE; 377 369 378 370 blkcg_bio_issue_init(split);
+4 -1
block/blk-mq.c
··· 2951 2951 blk_status_t ret; 2952 2952 2953 2953 bio = blk_queue_bounce(bio, q); 2954 - if (bio_may_exceed_limits(bio, &q->limits)) 2954 + if (bio_may_exceed_limits(bio, &q->limits)) { 2955 2955 bio = __bio_split_to_limits(bio, &q->limits, &nr_segs); 2956 + if (!bio) 2957 + return; 2958 + } 2956 2959 2957 2960 if (!bio_integrity_prep(bio)) 2958 2961 return;
+11
block/genhd.c
··· 1201 1201 .dev_uevent = block_uevent, 1202 1202 }; 1203 1203 1204 + static char *block_devnode(struct device *dev, umode_t *mode, 1205 + kuid_t *uid, kgid_t *gid) 1206 + { 1207 + struct gendisk *disk = dev_to_disk(dev); 1208 + 1209 + if (disk->fops->devnode) 1210 + return disk->fops->devnode(disk, mode); 1211 + return NULL; 1212 + } 1213 + 1204 1214 const struct device_type disk_type = { 1205 1215 .name = "disk", 1206 1216 .groups = disk_attr_groups, 1207 1217 .release = disk_release, 1218 + .devnode = block_devnode, 1208 1219 }; 1209 1220 1210 1221 #ifdef CONFIG_PROC_FS
+12 -5
drivers/acpi/acpi_video.c
··· 70 70 static int only_lcd = -1; 71 71 module_param(only_lcd, int, 0444); 72 72 73 - /* 74 - * Display probing is known to take up to 5 seconds, so delay the fallback 75 - * backlight registration by 5 seconds + 3 seconds for some extra margin. 76 - */ 77 - static int register_backlight_delay = 8; 73 + static int register_backlight_delay; 78 74 module_param(register_backlight_delay, int, 0444); 79 75 MODULE_PARM_DESC(register_backlight_delay, 80 76 "Delay in seconds before doing fallback (non GPU driver triggered) " ··· 2171 2175 2172 2176 return false; 2173 2177 } 2178 + 2179 + /* 2180 + * At least one graphics driver has reported that no LCD is connected 2181 + * via the native interface. cancel the registration for fallback acpi_video0. 2182 + * If another driver still deems this necessary, it can explicitly register it. 2183 + */ 2184 + void acpi_video_report_nolcd(void) 2185 + { 2186 + cancel_delayed_work(&video_bus_register_backlight_work); 2187 + } 2188 + EXPORT_SYMBOL(acpi_video_report_nolcd); 2174 2189 2175 2190 int acpi_video_register(void) 2176 2191 {
+29 -3
drivers/acpi/resource.c
··· 432 432 DMI_MATCH(DMI_BOARD_NAME, "S5602ZA"), 433 433 }, 434 434 }, 435 + { 436 + .ident = "Asus ExpertBook B2502", 437 + .matches = { 438 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 439 + DMI_MATCH(DMI_BOARD_NAME, "B2502CBA"), 440 + }, 441 + }, 435 442 { } 436 443 }; 437 444 438 - static const struct dmi_system_id lenovo_82ra[] = { 445 + static const struct dmi_system_id lenovo_laptop[] = { 446 + { 447 + .ident = "LENOVO IdeaPad Flex 5 14ALC7", 448 + .matches = { 449 + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 450 + DMI_MATCH(DMI_PRODUCT_NAME, "82R9"), 451 + }, 452 + }, 439 453 { 440 454 .ident = "LENOVO IdeaPad Flex 5 16ALC7", 441 455 .matches = { 442 456 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 443 457 DMI_MATCH(DMI_PRODUCT_NAME, "82RA"), 458 + }, 459 + }, 460 + { } 461 + }; 462 + 463 + static const struct dmi_system_id schenker_gm_rg[] = { 464 + { 465 + .ident = "XMG CORE 15 (M22)", 466 + .matches = { 467 + DMI_MATCH(DMI_SYS_VENDOR, "SchenkerTechnologiesGmbH"), 468 + DMI_MATCH(DMI_BOARD_NAME, "GMxRGxx"), 444 469 }, 445 470 }, 446 471 { } ··· 483 458 static const struct irq_override_cmp override_table[] = { 484 459 { medion_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false }, 485 460 { asus_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false }, 486 - { lenovo_82ra, 6, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, true }, 487 - { lenovo_82ra, 10, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, true }, 461 + { lenovo_laptop, 6, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, true }, 462 + { lenovo_laptop, 10, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, true }, 463 + { schenker_gm_rg, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, true }, 488 464 }; 489 465 490 466 static bool acpi_dev_irq_override(u32 gsi, u8 triggering, u8 polarity,
+22 -1
drivers/acpi/video_detect.c
··· 34 34 #include <linux/module.h> 35 35 #include <linux/pci.h> 36 36 #include <linux/platform_data/x86/nvidia-wmi-ec-backlight.h> 37 + #include <linux/pnp.h> 37 38 #include <linux/types.h> 38 39 #include <linux/workqueue.h> 39 40 #include <acpi/video.h> ··· 105 104 return false; 106 105 } 107 106 #endif 107 + 108 + static bool apple_gmux_backlight_present(void) 109 + { 110 + struct acpi_device *adev; 111 + struct device *dev; 112 + 113 + adev = acpi_dev_get_first_match_dev(GMUX_ACPI_HID, NULL, -1); 114 + if (!adev) 115 + return false; 116 + 117 + dev = acpi_get_first_physical_node(adev); 118 + if (!dev) 119 + return false; 120 + 121 + /* 122 + * drivers/platform/x86/apple-gmux.c only supports old style 123 + * Apple GMUX with an IO-resource. 124 + */ 125 + return pnp_get_resource(to_pnp_dev(dev), IORESOURCE_IO, 0) != NULL; 126 + } 108 127 109 128 /* Force to use vendor driver when the ACPI device is known to be 110 129 * buggy */ ··· 788 767 if (nvidia_wmi_ec_present) 789 768 return acpi_backlight_nvidia_wmi_ec; 790 769 791 - if (apple_gmux_present()) 770 + if (apple_gmux_backlight_present()) 792 771 return acpi_backlight_apple_gmux; 793 772 794 773 /* Use ACPI video if available, except when native should be preferred. */
+13 -74
drivers/acpi/x86/s2idle.c
··· 28 28 module_param(sleep_no_lps0, bool, 0644); 29 29 MODULE_PARM_DESC(sleep_no_lps0, "Do not use the special LPS0 device interface"); 30 30 31 - static bool prefer_microsoft_dsm_guid __read_mostly; 32 - module_param(prefer_microsoft_dsm_guid, bool, 0644); 33 - MODULE_PARM_DESC(prefer_microsoft_dsm_guid, "Prefer using Microsoft GUID in LPS0 device _DSM evaluation"); 34 - 35 31 static const struct acpi_device_id lps0_device_ids[] = { 36 32 {"PNP0D80", }, 37 33 {"", }, ··· 365 369 } 366 370 367 371 struct amd_lps0_hid_device_data { 368 - const unsigned int rev_id; 369 372 const bool check_off_by_one; 370 - const bool prefer_amd_guid; 371 373 }; 372 374 373 375 static const struct amd_lps0_hid_device_data amd_picasso = { 374 - .rev_id = 0, 375 376 .check_off_by_one = true, 376 - .prefer_amd_guid = false, 377 377 }; 378 378 379 379 static const struct amd_lps0_hid_device_data amd_cezanne = { 380 - .rev_id = 0, 381 380 .check_off_by_one = false, 382 - .prefer_amd_guid = false, 383 - }; 384 - 385 - static const struct amd_lps0_hid_device_data amd_rembrandt = { 386 - .rev_id = 2, 387 - .check_off_by_one = false, 388 - .prefer_amd_guid = true, 389 381 }; 390 382 391 383 static const struct acpi_device_id amd_hid_ids[] = { ··· 381 397 {"AMD0005", (kernel_ulong_t)&amd_picasso, }, 382 398 {"AMDI0005", (kernel_ulong_t)&amd_picasso, }, 383 399 {"AMDI0006", (kernel_ulong_t)&amd_cezanne, }, 384 - {"AMDI0007", (kernel_ulong_t)&amd_rembrandt, }, 385 400 {} 386 401 }; 387 402 388 - static int lps0_prefer_microsoft(const struct dmi_system_id *id) 403 + static int lps0_prefer_amd(const struct dmi_system_id *id) 389 404 { 390 - pr_debug("Preferring Microsoft GUID.\n"); 391 - prefer_microsoft_dsm_guid = true; 405 + pr_debug("Using AMD GUID w/ _REV 2.\n"); 406 + rev_id = 2; 392 407 return 0; 393 408 } 394 - 395 409 static const struct dmi_system_id s2idle_dmi_table[] __initconst = { 396 410 { 397 411 /* 398 - * ASUS TUF Gaming A17 FA707RE 399 - * https://bugzilla.kernel.org/show_bug.cgi?id=216101 412 + * AMD Rembrandt based HP EliteBook 835/845/865 G9 413 + * Contains specialized AML in AMD/_REV 2 path to avoid 414 + * triggering a bug in Qualcomm WLAN firmware. This may be 415 + * removed in the future if that firmware is fixed. 400 416 */ 401 - .callback = lps0_prefer_microsoft, 417 + .callback = lps0_prefer_amd, 402 418 .matches = { 403 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 404 - DMI_MATCH(DMI_PRODUCT_NAME, "ASUS TUF Gaming A17"), 405 - }, 406 - }, 407 - { 408 - /* ASUS ROG Zephyrus G14 (2022) */ 409 - .callback = lps0_prefer_microsoft, 410 - .matches = { 411 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 412 - DMI_MATCH(DMI_PRODUCT_NAME, "ROG Zephyrus G14 GA402"), 413 - }, 414 - }, 415 - { 416 - /* 417 - * Lenovo Yoga Slim 7 Pro X 14ARH7 418 - * https://bugzilla.kernel.org/show_bug.cgi?id=216473 : 82V2 419 - * https://bugzilla.kernel.org/show_bug.cgi?id=216438 : 82TL 420 - */ 421 - .callback = lps0_prefer_microsoft, 422 - .matches = { 423 - DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 424 - DMI_MATCH(DMI_PRODUCT_NAME, "82"), 425 - }, 426 - }, 427 - { 428 - /* 429 - * ASUSTeK COMPUTER INC. ROG Flow X13 GV301RE_GV301RE 430 - * https://gitlab.freedesktop.org/drm/amd/-/issues/2148 431 - */ 432 - .callback = lps0_prefer_microsoft, 433 - .matches = { 434 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 435 - DMI_MATCH(DMI_PRODUCT_NAME, "ROG Flow X13 GV301"), 436 - }, 437 - }, 438 - { 439 - /* 440 - * ASUSTeK COMPUTER INC. ROG Flow X16 GV601RW_GV601RW 441 - * https://gitlab.freedesktop.org/drm/amd/-/issues/2148 442 - */ 443 - .callback = lps0_prefer_microsoft, 444 - .matches = { 445 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 446 - DMI_MATCH(DMI_PRODUCT_NAME, "ROG Flow X16 GV601"), 419 + DMI_MATCH(DMI_BOARD_VENDOR, "HP"), 420 + DMI_MATCH(DMI_BOARD_NAME, "8990"), 447 421 }, 448 422 }, 449 423 {} ··· 426 484 if (dev_id->id[0]) 427 485 data = (const struct amd_lps0_hid_device_data *) dev_id->driver_data; 428 486 else 429 - data = &amd_rembrandt; 430 - rev_id = data->rev_id; 487 + data = &amd_cezanne; 431 488 lps0_dsm_func_mask = validate_dsm(adev->handle, 432 489 ACPI_LPS0_DSM_UUID_AMD, rev_id, &lps0_dsm_guid); 433 490 if (lps0_dsm_func_mask > 0x3 && data->check_off_by_one) { 434 491 lps0_dsm_func_mask = (lps0_dsm_func_mask << 1) | 0x1; 435 492 acpi_handle_debug(adev->handle, "_DSM UUID %s: Adjusted function mask: 0x%x\n", 436 493 ACPI_LPS0_DSM_UUID_AMD, lps0_dsm_func_mask); 437 - } else if (lps0_dsm_func_mask_microsoft > 0 && data->prefer_amd_guid && 438 - !prefer_microsoft_dsm_guid) { 494 + } else if (lps0_dsm_func_mask_microsoft > 0 && rev_id) { 439 495 lps0_dsm_func_mask_microsoft = -EINVAL; 440 496 acpi_handle_debug(adev->handle, "_DSM Using AMD method\n"); 441 497 } ··· 441 501 rev_id = 1; 442 502 lps0_dsm_func_mask = validate_dsm(adev->handle, 443 503 ACPI_LPS0_DSM_UUID, rev_id, &lps0_dsm_guid); 444 - if (!prefer_microsoft_dsm_guid) 445 - lps0_dsm_func_mask_microsoft = -EINVAL; 504 + lps0_dsm_func_mask_microsoft = -EINVAL; 446 505 } 447 506 448 507 if (lps0_dsm_func_mask < 0 && lps0_dsm_func_mask_microsoft < 0)
+23 -9
drivers/ata/ahci.c
··· 83 83 static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 84 84 static void ahci_remove_one(struct pci_dev *dev); 85 85 static void ahci_shutdown_one(struct pci_dev *dev); 86 + static void ahci_intel_pcs_quirk(struct pci_dev *pdev, struct ahci_host_priv *hpriv); 86 87 static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class, 87 88 unsigned long deadline); 88 89 static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class, ··· 677 676 ahci_save_initial_config(&pdev->dev, hpriv); 678 677 } 679 678 679 + static int ahci_pci_reset_controller(struct ata_host *host) 680 + { 681 + struct pci_dev *pdev = to_pci_dev(host->dev); 682 + struct ahci_host_priv *hpriv = host->private_data; 683 + int rc; 684 + 685 + rc = ahci_reset_controller(host); 686 + if (rc) 687 + return rc; 688 + 689 + /* 690 + * If platform firmware failed to enable ports, try to enable 691 + * them here. 692 + */ 693 + ahci_intel_pcs_quirk(pdev, hpriv); 694 + 695 + return 0; 696 + } 697 + 680 698 static void ahci_pci_init_controller(struct ata_host *host) 681 699 { 682 700 struct ahci_host_priv *hpriv = host->private_data; ··· 890 870 struct ata_host *host = pci_get_drvdata(pdev); 891 871 int rc; 892 872 893 - rc = ahci_reset_controller(host); 873 + rc = ahci_pci_reset_controller(host); 894 874 if (rc) 895 875 return rc; 896 876 ahci_pci_init_controller(host); ··· 926 906 ahci_mcp89_apple_enable(pdev); 927 907 928 908 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { 929 - rc = ahci_reset_controller(host); 909 + rc = ahci_pci_reset_controller(host); 930 910 if (rc) 931 911 return rc; 932 912 ··· 1804 1784 /* save initial config */ 1805 1785 ahci_pci_save_initial_config(pdev, hpriv); 1806 1786 1807 - /* 1808 - * If platform firmware failed to enable ports, try to enable 1809 - * them here. 1810 - */ 1811 - ahci_intel_pcs_quirk(pdev, hpriv); 1812 - 1813 1787 /* prepare host */ 1814 1788 if (hpriv->cap & HOST_CAP_NCQ) { 1815 1789 pi.flags |= ATA_FLAG_NCQ; ··· 1913 1899 if (rc) 1914 1900 return rc; 1915 1901 1916 - rc = ahci_reset_controller(host); 1902 + rc = ahci_pci_reset_controller(host); 1917 1903 if (rc) 1918 1904 return rc; 1919 1905
+43
drivers/block/Kconfig
··· 285 285 The default value is 4096 kilobytes. Only change this if you know 286 286 what you are doing. 287 287 288 + config CDROM_PKTCDVD 289 + tristate "Packet writing on CD/DVD media (DEPRECATED)" 290 + depends on !UML 291 + depends on SCSI 292 + select CDROM 293 + help 294 + Note: This driver is deprecated and will be removed from the 295 + kernel in the near future! 296 + 297 + If you have a CDROM/DVD drive that supports packet writing, say 298 + Y to include support. It should work with any MMC/Mt Fuji 299 + compliant ATAPI or SCSI drive, which is just about any newer 300 + DVD/CD writer. 301 + 302 + Currently only writing to CD-RW, DVD-RW, DVD+RW and DVDRAM discs 303 + is possible. 304 + DVD-RW disks must be in restricted overwrite mode. 305 + 306 + See the file <file:Documentation/cdrom/packet-writing.rst> 307 + for further information on the use of this driver. 308 + 309 + To compile this driver as a module, choose M here: the 310 + module will be called pktcdvd. 311 + 312 + config CDROM_PKTCDVD_BUFFERS 313 + int "Free buffers for data gathering" 314 + depends on CDROM_PKTCDVD 315 + default "8" 316 + help 317 + This controls the maximum number of active concurrent packets. More 318 + concurrent packets can increase write performance, but also require 319 + more memory. Each concurrent packet will require approximately 64Kb 320 + of non-swappable kernel memory, memory which will be allocated when 321 + a disc is opened for writing. 322 + 323 + config CDROM_PKTCDVD_WCACHE 324 + bool "Enable write caching" 325 + depends on CDROM_PKTCDVD 326 + help 327 + If enabled, write caching will be set for the CD-R/W device. For now 328 + this option is dangerous unless the CD-RW media is known good, as we 329 + don't do deferred write error handling yet. 330 + 288 331 config ATA_OVER_ETH 289 332 tristate "ATA over Ethernet support" 290 333 depends on NET
+1
drivers/block/Makefile
··· 20 20 obj-$(CONFIG_N64CART) += n64cart.o 21 21 obj-$(CONFIG_BLK_DEV_RAM) += brd.o 22 22 obj-$(CONFIG_BLK_DEV_LOOP) += loop.o 23 + obj-$(CONFIG_CDROM_PKTCDVD) += pktcdvd.o 23 24 obj-$(CONFIG_SUNVDC) += sunvdc.o 24 25 25 26 obj-$(CONFIG_BLK_DEV_NBD) += nbd.o
+2
drivers/block/drbd/drbd_req.c
··· 1607 1607 struct drbd_device *device = bio->bi_bdev->bd_disk->private_data; 1608 1608 1609 1609 bio = bio_split_to_limits(bio); 1610 + if (!bio) 1611 + return; 1610 1612 1611 1613 /* 1612 1614 * what we "blindly" assume:
+2944
drivers/block/pktcdvd.c
··· 1 + /* 2 + * Copyright (C) 2000 Jens Axboe <axboe@suse.de> 3 + * Copyright (C) 2001-2004 Peter Osterlund <petero2@telia.com> 4 + * Copyright (C) 2006 Thomas Maier <balagi@justmail.de> 5 + * 6 + * May be copied or modified under the terms of the GNU General Public 7 + * License. See linux/COPYING for more information. 8 + * 9 + * Packet writing layer for ATAPI and SCSI CD-RW, DVD+RW, DVD-RW and 10 + * DVD-RAM devices. 11 + * 12 + * Theory of operation: 13 + * 14 + * At the lowest level, there is the standard driver for the CD/DVD device, 15 + * such as drivers/scsi/sr.c. This driver can handle read and write requests, 16 + * but it doesn't know anything about the special restrictions that apply to 17 + * packet writing. One restriction is that write requests must be aligned to 18 + * packet boundaries on the physical media, and the size of a write request 19 + * must be equal to the packet size. Another restriction is that a 20 + * GPCMD_FLUSH_CACHE command has to be issued to the drive before a read 21 + * command, if the previous command was a write. 22 + * 23 + * The purpose of the packet writing driver is to hide these restrictions from 24 + * higher layers, such as file systems, and present a block device that can be 25 + * randomly read and written using 2kB-sized blocks. 26 + * 27 + * The lowest layer in the packet writing driver is the packet I/O scheduler. 28 + * Its data is defined by the struct packet_iosched and includes two bio 29 + * queues with pending read and write requests. These queues are processed 30 + * by the pkt_iosched_process_queue() function. The write requests in this 31 + * queue are already properly aligned and sized. This layer is responsible for 32 + * issuing the flush cache commands and scheduling the I/O in a good order. 33 + * 34 + * The next layer transforms unaligned write requests to aligned writes. This 35 + * transformation requires reading missing pieces of data from the underlying 36 + * block device, assembling the pieces to full packets and queuing them to the 37 + * packet I/O scheduler. 38 + * 39 + * At the top layer there is a custom ->submit_bio function that forwards 40 + * read requests directly to the iosched queue and puts write requests in the 41 + * unaligned write queue. A kernel thread performs the necessary read 42 + * gathering to convert the unaligned writes to aligned writes and then feeds 43 + * them to the packet I/O scheduler. 44 + * 45 + *************************************************************************/ 46 + 47 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 48 + 49 + #include <linux/pktcdvd.h> 50 + #include <linux/module.h> 51 + #include <linux/types.h> 52 + #include <linux/kernel.h> 53 + #include <linux/compat.h> 54 + #include <linux/kthread.h> 55 + #include <linux/errno.h> 56 + #include <linux/spinlock.h> 57 + #include <linux/file.h> 58 + #include <linux/proc_fs.h> 59 + #include <linux/seq_file.h> 60 + #include <linux/miscdevice.h> 61 + #include <linux/freezer.h> 62 + #include <linux/mutex.h> 63 + #include <linux/slab.h> 64 + #include <linux/backing-dev.h> 65 + #include <scsi/scsi_cmnd.h> 66 + #include <scsi/scsi_ioctl.h> 67 + #include <scsi/scsi.h> 68 + #include <linux/debugfs.h> 69 + #include <linux/device.h> 70 + #include <linux/nospec.h> 71 + #include <linux/uaccess.h> 72 + 73 + #define DRIVER_NAME "pktcdvd" 74 + 75 + #define pkt_err(pd, fmt, ...) \ 76 + pr_err("%s: " fmt, pd->name, ##__VA_ARGS__) 77 + #define pkt_notice(pd, fmt, ...) \ 78 + pr_notice("%s: " fmt, pd->name, ##__VA_ARGS__) 79 + #define pkt_info(pd, fmt, ...) \ 80 + pr_info("%s: " fmt, pd->name, ##__VA_ARGS__) 81 + 82 + #define pkt_dbg(level, pd, fmt, ...) \ 83 + do { \ 84 + if (level == 2 && PACKET_DEBUG >= 2) \ 85 + pr_notice("%s: %s():" fmt, \ 86 + pd->name, __func__, ##__VA_ARGS__); \ 87 + else if (level == 1 && PACKET_DEBUG >= 1) \ 88 + pr_notice("%s: " fmt, pd->name, ##__VA_ARGS__); \ 89 + } while (0) 90 + 91 + #define MAX_SPEED 0xffff 92 + 93 + static DEFINE_MUTEX(pktcdvd_mutex); 94 + static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; 95 + static struct proc_dir_entry *pkt_proc; 96 + static int pktdev_major; 97 + static int write_congestion_on = PKT_WRITE_CONGESTION_ON; 98 + static int write_congestion_off = PKT_WRITE_CONGESTION_OFF; 99 + static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */ 100 + static mempool_t psd_pool; 101 + static struct bio_set pkt_bio_set; 102 + 103 + static struct class *class_pktcdvd = NULL; /* /sys/class/pktcdvd */ 104 + static struct dentry *pkt_debugfs_root = NULL; /* /sys/kernel/debug/pktcdvd */ 105 + 106 + /* forward declaration */ 107 + static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev); 108 + static int pkt_remove_dev(dev_t pkt_dev); 109 + static int pkt_seq_show(struct seq_file *m, void *p); 110 + 111 + static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd) 112 + { 113 + return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1); 114 + } 115 + 116 + /********************************************************** 117 + * sysfs interface for pktcdvd 118 + * by (C) 2006 Thomas Maier <balagi@justmail.de> 119 + 120 + /sys/class/pktcdvd/pktcdvd[0-7]/ 121 + stat/reset 122 + stat/packets_started 123 + stat/packets_finished 124 + stat/kb_written 125 + stat/kb_read 126 + stat/kb_read_gather 127 + write_queue/size 128 + write_queue/congestion_off 129 + write_queue/congestion_on 130 + **********************************************************/ 131 + 132 + static ssize_t packets_started_show(struct device *dev, 133 + struct device_attribute *attr, char *buf) 134 + { 135 + struct pktcdvd_device *pd = dev_get_drvdata(dev); 136 + 137 + return sysfs_emit(buf, "%lu\n", pd->stats.pkt_started); 138 + } 139 + static DEVICE_ATTR_RO(packets_started); 140 + 141 + static ssize_t packets_finished_show(struct device *dev, 142 + struct device_attribute *attr, char *buf) 143 + { 144 + struct pktcdvd_device *pd = dev_get_drvdata(dev); 145 + 146 + return sysfs_emit(buf, "%lu\n", pd->stats.pkt_ended); 147 + } 148 + static DEVICE_ATTR_RO(packets_finished); 149 + 150 + static ssize_t kb_written_show(struct device *dev, 151 + struct device_attribute *attr, char *buf) 152 + { 153 + struct pktcdvd_device *pd = dev_get_drvdata(dev); 154 + 155 + return sysfs_emit(buf, "%lu\n", pd->stats.secs_w >> 1); 156 + } 157 + static DEVICE_ATTR_RO(kb_written); 158 + 159 + static ssize_t kb_read_show(struct device *dev, 160 + struct device_attribute *attr, char *buf) 161 + { 162 + struct pktcdvd_device *pd = dev_get_drvdata(dev); 163 + 164 + return sysfs_emit(buf, "%lu\n", pd->stats.secs_r >> 1); 165 + } 166 + static DEVICE_ATTR_RO(kb_read); 167 + 168 + static ssize_t kb_read_gather_show(struct device *dev, 169 + struct device_attribute *attr, char *buf) 170 + { 171 + struct pktcdvd_device *pd = dev_get_drvdata(dev); 172 + 173 + return sysfs_emit(buf, "%lu\n", pd->stats.secs_rg >> 1); 174 + } 175 + static DEVICE_ATTR_RO(kb_read_gather); 176 + 177 + static ssize_t reset_store(struct device *dev, struct device_attribute *attr, 178 + const char *buf, size_t len) 179 + { 180 + struct pktcdvd_device *pd = dev_get_drvdata(dev); 181 + 182 + if (len > 0) { 183 + pd->stats.pkt_started = 0; 184 + pd->stats.pkt_ended = 0; 185 + pd->stats.secs_w = 0; 186 + pd->stats.secs_rg = 0; 187 + pd->stats.secs_r = 0; 188 + } 189 + return len; 190 + } 191 + static DEVICE_ATTR_WO(reset); 192 + 193 + static struct attribute *pkt_stat_attrs[] = { 194 + &dev_attr_packets_finished.attr, 195 + &dev_attr_packets_started.attr, 196 + &dev_attr_kb_read.attr, 197 + &dev_attr_kb_written.attr, 198 + &dev_attr_kb_read_gather.attr, 199 + &dev_attr_reset.attr, 200 + NULL, 201 + }; 202 + 203 + static const struct attribute_group pkt_stat_group = { 204 + .name = "stat", 205 + .attrs = pkt_stat_attrs, 206 + }; 207 + 208 + static ssize_t size_show(struct device *dev, 209 + struct device_attribute *attr, char *buf) 210 + { 211 + struct pktcdvd_device *pd = dev_get_drvdata(dev); 212 + int n; 213 + 214 + spin_lock(&pd->lock); 215 + n = sysfs_emit(buf, "%d\n", pd->bio_queue_size); 216 + spin_unlock(&pd->lock); 217 + return n; 218 + } 219 + static DEVICE_ATTR_RO(size); 220 + 221 + static void init_write_congestion_marks(int* lo, int* hi) 222 + { 223 + if (*hi > 0) { 224 + *hi = max(*hi, 500); 225 + *hi = min(*hi, 1000000); 226 + if (*lo <= 0) 227 + *lo = *hi - 100; 228 + else { 229 + *lo = min(*lo, *hi - 100); 230 + *lo = max(*lo, 100); 231 + } 232 + } else { 233 + *hi = -1; 234 + *lo = -1; 235 + } 236 + } 237 + 238 + static ssize_t congestion_off_show(struct device *dev, 239 + struct device_attribute *attr, char *buf) 240 + { 241 + struct pktcdvd_device *pd = dev_get_drvdata(dev); 242 + int n; 243 + 244 + spin_lock(&pd->lock); 245 + n = sysfs_emit(buf, "%d\n", pd->write_congestion_off); 246 + spin_unlock(&pd->lock); 247 + return n; 248 + } 249 + 250 + static ssize_t congestion_off_store(struct device *dev, 251 + struct device_attribute *attr, 252 + const char *buf, size_t len) 253 + { 254 + struct pktcdvd_device *pd = dev_get_drvdata(dev); 255 + int val; 256 + 257 + if (sscanf(buf, "%d", &val) == 1) { 258 + spin_lock(&pd->lock); 259 + pd->write_congestion_off = val; 260 + init_write_congestion_marks(&pd->write_congestion_off, 261 + &pd->write_congestion_on); 262 + spin_unlock(&pd->lock); 263 + } 264 + return len; 265 + } 266 + static DEVICE_ATTR_RW(congestion_off); 267 + 268 + static ssize_t congestion_on_show(struct device *dev, 269 + struct device_attribute *attr, char *buf) 270 + { 271 + struct pktcdvd_device *pd = dev_get_drvdata(dev); 272 + int n; 273 + 274 + spin_lock(&pd->lock); 275 + n = sysfs_emit(buf, "%d\n", pd->write_congestion_on); 276 + spin_unlock(&pd->lock); 277 + return n; 278 + } 279 + 280 + static ssize_t congestion_on_store(struct device *dev, 281 + struct device_attribute *attr, 282 + const char *buf, size_t len) 283 + { 284 + struct pktcdvd_device *pd = dev_get_drvdata(dev); 285 + int val; 286 + 287 + if (sscanf(buf, "%d", &val) == 1) { 288 + spin_lock(&pd->lock); 289 + pd->write_congestion_on = val; 290 + init_write_congestion_marks(&pd->write_congestion_off, 291 + &pd->write_congestion_on); 292 + spin_unlock(&pd->lock); 293 + } 294 + return len; 295 + } 296 + static DEVICE_ATTR_RW(congestion_on); 297 + 298 + static struct attribute *pkt_wq_attrs[] = { 299 + &dev_attr_congestion_on.attr, 300 + &dev_attr_congestion_off.attr, 301 + &dev_attr_size.attr, 302 + NULL, 303 + }; 304 + 305 + static const struct attribute_group pkt_wq_group = { 306 + .name = "write_queue", 307 + .attrs = pkt_wq_attrs, 308 + }; 309 + 310 + static const struct attribute_group *pkt_groups[] = { 311 + &pkt_stat_group, 312 + &pkt_wq_group, 313 + NULL, 314 + }; 315 + 316 + static void pkt_sysfs_dev_new(struct pktcdvd_device *pd) 317 + { 318 + if (class_pktcdvd) { 319 + pd->dev = device_create_with_groups(class_pktcdvd, NULL, 320 + MKDEV(0, 0), pd, pkt_groups, 321 + "%s", pd->name); 322 + if (IS_ERR(pd->dev)) 323 + pd->dev = NULL; 324 + } 325 + } 326 + 327 + static void pkt_sysfs_dev_remove(struct pktcdvd_device *pd) 328 + { 329 + if (class_pktcdvd) 330 + device_unregister(pd->dev); 331 + } 332 + 333 + 334 + /******************************************************************** 335 + /sys/class/pktcdvd/ 336 + add map block device 337 + remove unmap packet dev 338 + device_map show mappings 339 + *******************************************************************/ 340 + 341 + static void class_pktcdvd_release(struct class *cls) 342 + { 343 + kfree(cls); 344 + } 345 + 346 + static ssize_t device_map_show(struct class *c, struct class_attribute *attr, 347 + char *data) 348 + { 349 + int n = 0; 350 + int idx; 351 + mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 352 + for (idx = 0; idx < MAX_WRITERS; idx++) { 353 + struct pktcdvd_device *pd = pkt_devs[idx]; 354 + if (!pd) 355 + continue; 356 + n += sprintf(data+n, "%s %u:%u %u:%u\n", 357 + pd->name, 358 + MAJOR(pd->pkt_dev), MINOR(pd->pkt_dev), 359 + MAJOR(pd->bdev->bd_dev), 360 + MINOR(pd->bdev->bd_dev)); 361 + } 362 + mutex_unlock(&ctl_mutex); 363 + return n; 364 + } 365 + static CLASS_ATTR_RO(device_map); 366 + 367 + static ssize_t add_store(struct class *c, struct class_attribute *attr, 368 + const char *buf, size_t count) 369 + { 370 + unsigned int major, minor; 371 + 372 + if (sscanf(buf, "%u:%u", &major, &minor) == 2) { 373 + /* pkt_setup_dev() expects caller to hold reference to self */ 374 + if (!try_module_get(THIS_MODULE)) 375 + return -ENODEV; 376 + 377 + pkt_setup_dev(MKDEV(major, minor), NULL); 378 + 379 + module_put(THIS_MODULE); 380 + 381 + return count; 382 + } 383 + 384 + return -EINVAL; 385 + } 386 + static CLASS_ATTR_WO(add); 387 + 388 + static ssize_t remove_store(struct class *c, struct class_attribute *attr, 389 + const char *buf, size_t count) 390 + { 391 + unsigned int major, minor; 392 + if (sscanf(buf, "%u:%u", &major, &minor) == 2) { 393 + pkt_remove_dev(MKDEV(major, minor)); 394 + return count; 395 + } 396 + return -EINVAL; 397 + } 398 + static CLASS_ATTR_WO(remove); 399 + 400 + static struct attribute *class_pktcdvd_attrs[] = { 401 + &class_attr_add.attr, 402 + &class_attr_remove.attr, 403 + &class_attr_device_map.attr, 404 + NULL, 405 + }; 406 + ATTRIBUTE_GROUPS(class_pktcdvd); 407 + 408 + static int pkt_sysfs_init(void) 409 + { 410 + int ret = 0; 411 + 412 + /* 413 + * create control files in sysfs 414 + * /sys/class/pktcdvd/... 415 + */ 416 + class_pktcdvd = kzalloc(sizeof(*class_pktcdvd), GFP_KERNEL); 417 + if (!class_pktcdvd) 418 + return -ENOMEM; 419 + class_pktcdvd->name = DRIVER_NAME; 420 + class_pktcdvd->owner = THIS_MODULE; 421 + class_pktcdvd->class_release = class_pktcdvd_release; 422 + class_pktcdvd->class_groups = class_pktcdvd_groups; 423 + ret = class_register(class_pktcdvd); 424 + if (ret) { 425 + kfree(class_pktcdvd); 426 + class_pktcdvd = NULL; 427 + pr_err("failed to create class pktcdvd\n"); 428 + return ret; 429 + } 430 + return 0; 431 + } 432 + 433 + static void pkt_sysfs_cleanup(void) 434 + { 435 + if (class_pktcdvd) 436 + class_destroy(class_pktcdvd); 437 + class_pktcdvd = NULL; 438 + } 439 + 440 + /******************************************************************** 441 + entries in debugfs 442 + 443 + /sys/kernel/debug/pktcdvd[0-7]/ 444 + info 445 + 446 + *******************************************************************/ 447 + 448 + static int pkt_debugfs_seq_show(struct seq_file *m, void *p) 449 + { 450 + return pkt_seq_show(m, p); 451 + } 452 + 453 + static int pkt_debugfs_fops_open(struct inode *inode, struct file *file) 454 + { 455 + return single_open(file, pkt_debugfs_seq_show, inode->i_private); 456 + } 457 + 458 + static const struct file_operations debug_fops = { 459 + .open = pkt_debugfs_fops_open, 460 + .read = seq_read, 461 + .llseek = seq_lseek, 462 + .release = single_release, 463 + .owner = THIS_MODULE, 464 + }; 465 + 466 + static void pkt_debugfs_dev_new(struct pktcdvd_device *pd) 467 + { 468 + if (!pkt_debugfs_root) 469 + return; 470 + pd->dfs_d_root = debugfs_create_dir(pd->name, pkt_debugfs_root); 471 + if (!pd->dfs_d_root) 472 + return; 473 + 474 + pd->dfs_f_info = debugfs_create_file("info", 0444, 475 + pd->dfs_d_root, pd, &debug_fops); 476 + } 477 + 478 + static void pkt_debugfs_dev_remove(struct pktcdvd_device *pd) 479 + { 480 + if (!pkt_debugfs_root) 481 + return; 482 + debugfs_remove(pd->dfs_f_info); 483 + debugfs_remove(pd->dfs_d_root); 484 + pd->dfs_f_info = NULL; 485 + pd->dfs_d_root = NULL; 486 + } 487 + 488 + static void pkt_debugfs_init(void) 489 + { 490 + pkt_debugfs_root = debugfs_create_dir(DRIVER_NAME, NULL); 491 + } 492 + 493 + static void pkt_debugfs_cleanup(void) 494 + { 495 + debugfs_remove(pkt_debugfs_root); 496 + pkt_debugfs_root = NULL; 497 + } 498 + 499 + /* ----------------------------------------------------------*/ 500 + 501 + 502 + static void pkt_bio_finished(struct pktcdvd_device *pd) 503 + { 504 + BUG_ON(atomic_read(&pd->cdrw.pending_bios) <= 0); 505 + if (atomic_dec_and_test(&pd->cdrw.pending_bios)) { 506 + pkt_dbg(2, pd, "queue empty\n"); 507 + atomic_set(&pd->iosched.attention, 1); 508 + wake_up(&pd->wqueue); 509 + } 510 + } 511 + 512 + /* 513 + * Allocate a packet_data struct 514 + */ 515 + static struct packet_data *pkt_alloc_packet_data(int frames) 516 + { 517 + int i; 518 + struct packet_data *pkt; 519 + 520 + pkt = kzalloc(sizeof(struct packet_data), GFP_KERNEL); 521 + if (!pkt) 522 + goto no_pkt; 523 + 524 + pkt->frames = frames; 525 + pkt->w_bio = bio_kmalloc(frames, GFP_KERNEL); 526 + if (!pkt->w_bio) 527 + goto no_bio; 528 + 529 + for (i = 0; i < frames / FRAMES_PER_PAGE; i++) { 530 + pkt->pages[i] = alloc_page(GFP_KERNEL|__GFP_ZERO); 531 + if (!pkt->pages[i]) 532 + goto no_page; 533 + } 534 + 535 + spin_lock_init(&pkt->lock); 536 + bio_list_init(&pkt->orig_bios); 537 + 538 + for (i = 0; i < frames; i++) { 539 + pkt->r_bios[i] = bio_kmalloc(1, GFP_KERNEL); 540 + if (!pkt->r_bios[i]) 541 + goto no_rd_bio; 542 + } 543 + 544 + return pkt; 545 + 546 + no_rd_bio: 547 + for (i = 0; i < frames; i++) 548 + kfree(pkt->r_bios[i]); 549 + no_page: 550 + for (i = 0; i < frames / FRAMES_PER_PAGE; i++) 551 + if (pkt->pages[i]) 552 + __free_page(pkt->pages[i]); 553 + kfree(pkt->w_bio); 554 + no_bio: 555 + kfree(pkt); 556 + no_pkt: 557 + return NULL; 558 + } 559 + 560 + /* 561 + * Free a packet_data struct 562 + */ 563 + static void pkt_free_packet_data(struct packet_data *pkt) 564 + { 565 + int i; 566 + 567 + for (i = 0; i < pkt->frames; i++) 568 + kfree(pkt->r_bios[i]); 569 + for (i = 0; i < pkt->frames / FRAMES_PER_PAGE; i++) 570 + __free_page(pkt->pages[i]); 571 + kfree(pkt->w_bio); 572 + kfree(pkt); 573 + } 574 + 575 + static void pkt_shrink_pktlist(struct pktcdvd_device *pd) 576 + { 577 + struct packet_data *pkt, *next; 578 + 579 + BUG_ON(!list_empty(&pd->cdrw.pkt_active_list)); 580 + 581 + list_for_each_entry_safe(pkt, next, &pd->cdrw.pkt_free_list, list) { 582 + pkt_free_packet_data(pkt); 583 + } 584 + INIT_LIST_HEAD(&pd->cdrw.pkt_free_list); 585 + } 586 + 587 + static int pkt_grow_pktlist(struct pktcdvd_device *pd, int nr_packets) 588 + { 589 + struct packet_data *pkt; 590 + 591 + BUG_ON(!list_empty(&pd->cdrw.pkt_free_list)); 592 + 593 + while (nr_packets > 0) { 594 + pkt = pkt_alloc_packet_data(pd->settings.size >> 2); 595 + if (!pkt) { 596 + pkt_shrink_pktlist(pd); 597 + return 0; 598 + } 599 + pkt->id = nr_packets; 600 + pkt->pd = pd; 601 + list_add(&pkt->list, &pd->cdrw.pkt_free_list); 602 + nr_packets--; 603 + } 604 + return 1; 605 + } 606 + 607 + static inline struct pkt_rb_node *pkt_rbtree_next(struct pkt_rb_node *node) 608 + { 609 + struct rb_node *n = rb_next(&node->rb_node); 610 + if (!n) 611 + return NULL; 612 + return rb_entry(n, struct pkt_rb_node, rb_node); 613 + } 614 + 615 + static void pkt_rbtree_erase(struct pktcdvd_device *pd, struct pkt_rb_node *node) 616 + { 617 + rb_erase(&node->rb_node, &pd->bio_queue); 618 + mempool_free(node, &pd->rb_pool); 619 + pd->bio_queue_size--; 620 + BUG_ON(pd->bio_queue_size < 0); 621 + } 622 + 623 + /* 624 + * Find the first node in the pd->bio_queue rb tree with a starting sector >= s. 625 + */ 626 + static struct pkt_rb_node *pkt_rbtree_find(struct pktcdvd_device *pd, sector_t s) 627 + { 628 + struct rb_node *n = pd->bio_queue.rb_node; 629 + struct rb_node *next; 630 + struct pkt_rb_node *tmp; 631 + 632 + if (!n) { 633 + BUG_ON(pd->bio_queue_size > 0); 634 + return NULL; 635 + } 636 + 637 + for (;;) { 638 + tmp = rb_entry(n, struct pkt_rb_node, rb_node); 639 + if (s <= tmp->bio->bi_iter.bi_sector) 640 + next = n->rb_left; 641 + else 642 + next = n->rb_right; 643 + if (!next) 644 + break; 645 + n = next; 646 + } 647 + 648 + if (s > tmp->bio->bi_iter.bi_sector) { 649 + tmp = pkt_rbtree_next(tmp); 650 + if (!tmp) 651 + return NULL; 652 + } 653 + BUG_ON(s > tmp->bio->bi_iter.bi_sector); 654 + return tmp; 655 + } 656 + 657 + /* 658 + * Insert a node into the pd->bio_queue rb tree. 659 + */ 660 + static void pkt_rbtree_insert(struct pktcdvd_device *pd, struct pkt_rb_node *node) 661 + { 662 + struct rb_node **p = &pd->bio_queue.rb_node; 663 + struct rb_node *parent = NULL; 664 + sector_t s = node->bio->bi_iter.bi_sector; 665 + struct pkt_rb_node *tmp; 666 + 667 + while (*p) { 668 + parent = *p; 669 + tmp = rb_entry(parent, struct pkt_rb_node, rb_node); 670 + if (s < tmp->bio->bi_iter.bi_sector) 671 + p = &(*p)->rb_left; 672 + else 673 + p = &(*p)->rb_right; 674 + } 675 + rb_link_node(&node->rb_node, parent, p); 676 + rb_insert_color(&node->rb_node, &pd->bio_queue); 677 + pd->bio_queue_size++; 678 + } 679 + 680 + /* 681 + * Send a packet_command to the underlying block device and 682 + * wait for completion. 683 + */ 684 + static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *cgc) 685 + { 686 + struct request_queue *q = bdev_get_queue(pd->bdev); 687 + struct scsi_cmnd *scmd; 688 + struct request *rq; 689 + int ret = 0; 690 + 691 + rq = scsi_alloc_request(q, (cgc->data_direction == CGC_DATA_WRITE) ? 692 + REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 693 + if (IS_ERR(rq)) 694 + return PTR_ERR(rq); 695 + scmd = blk_mq_rq_to_pdu(rq); 696 + 697 + if (cgc->buflen) { 698 + ret = blk_rq_map_kern(q, rq, cgc->buffer, cgc->buflen, 699 + GFP_NOIO); 700 + if (ret) 701 + goto out; 702 + } 703 + 704 + scmd->cmd_len = COMMAND_SIZE(cgc->cmd[0]); 705 + memcpy(scmd->cmnd, cgc->cmd, CDROM_PACKET_SIZE); 706 + 707 + rq->timeout = 60*HZ; 708 + if (cgc->quiet) 709 + rq->rq_flags |= RQF_QUIET; 710 + 711 + blk_execute_rq(rq, false); 712 + if (scmd->result) 713 + ret = -EIO; 714 + out: 715 + blk_mq_free_request(rq); 716 + return ret; 717 + } 718 + 719 + static const char *sense_key_string(__u8 index) 720 + { 721 + static const char * const info[] = { 722 + "No sense", "Recovered error", "Not ready", 723 + "Medium error", "Hardware error", "Illegal request", 724 + "Unit attention", "Data protect", "Blank check", 725 + }; 726 + 727 + return index < ARRAY_SIZE(info) ? info[index] : "INVALID"; 728 + } 729 + 730 + /* 731 + * A generic sense dump / resolve mechanism should be implemented across 732 + * all ATAPI + SCSI devices. 733 + */ 734 + static void pkt_dump_sense(struct pktcdvd_device *pd, 735 + struct packet_command *cgc) 736 + { 737 + struct scsi_sense_hdr *sshdr = cgc->sshdr; 738 + 739 + if (sshdr) 740 + pkt_err(pd, "%*ph - sense %02x.%02x.%02x (%s)\n", 741 + CDROM_PACKET_SIZE, cgc->cmd, 742 + sshdr->sense_key, sshdr->asc, sshdr->ascq, 743 + sense_key_string(sshdr->sense_key)); 744 + else 745 + pkt_err(pd, "%*ph - no sense\n", CDROM_PACKET_SIZE, cgc->cmd); 746 + } 747 + 748 + /* 749 + * flush the drive cache to media 750 + */ 751 + static int pkt_flush_cache(struct pktcdvd_device *pd) 752 + { 753 + struct packet_command cgc; 754 + 755 + init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE); 756 + cgc.cmd[0] = GPCMD_FLUSH_CACHE; 757 + cgc.quiet = 1; 758 + 759 + /* 760 + * the IMMED bit -- we default to not setting it, although that 761 + * would allow a much faster close, this is safer 762 + */ 763 + #if 0 764 + cgc.cmd[1] = 1 << 1; 765 + #endif 766 + return pkt_generic_packet(pd, &cgc); 767 + } 768 + 769 + /* 770 + * speed is given as the normal factor, e.g. 4 for 4x 771 + */ 772 + static noinline_for_stack int pkt_set_speed(struct pktcdvd_device *pd, 773 + unsigned write_speed, unsigned read_speed) 774 + { 775 + struct packet_command cgc; 776 + struct scsi_sense_hdr sshdr; 777 + int ret; 778 + 779 + init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE); 780 + cgc.sshdr = &sshdr; 781 + cgc.cmd[0] = GPCMD_SET_SPEED; 782 + cgc.cmd[2] = (read_speed >> 8) & 0xff; 783 + cgc.cmd[3] = read_speed & 0xff; 784 + cgc.cmd[4] = (write_speed >> 8) & 0xff; 785 + cgc.cmd[5] = write_speed & 0xff; 786 + 787 + ret = pkt_generic_packet(pd, &cgc); 788 + if (ret) 789 + pkt_dump_sense(pd, &cgc); 790 + 791 + return ret; 792 + } 793 + 794 + /* 795 + * Queue a bio for processing by the low-level CD device. Must be called 796 + * from process context. 797 + */ 798 + static void pkt_queue_bio(struct pktcdvd_device *pd, struct bio *bio) 799 + { 800 + spin_lock(&pd->iosched.lock); 801 + if (bio_data_dir(bio) == READ) 802 + bio_list_add(&pd->iosched.read_queue, bio); 803 + else 804 + bio_list_add(&pd->iosched.write_queue, bio); 805 + spin_unlock(&pd->iosched.lock); 806 + 807 + atomic_set(&pd->iosched.attention, 1); 808 + wake_up(&pd->wqueue); 809 + } 810 + 811 + /* 812 + * Process the queued read/write requests. This function handles special 813 + * requirements for CDRW drives: 814 + * - A cache flush command must be inserted before a read request if the 815 + * previous request was a write. 816 + * - Switching between reading and writing is slow, so don't do it more often 817 + * than necessary. 818 + * - Optimize for throughput at the expense of latency. This means that streaming 819 + * writes will never be interrupted by a read, but if the drive has to seek 820 + * before the next write, switch to reading instead if there are any pending 821 + * read requests. 822 + * - Set the read speed according to current usage pattern. When only reading 823 + * from the device, it's best to use the highest possible read speed, but 824 + * when switching often between reading and writing, it's better to have the 825 + * same read and write speeds. 826 + */ 827 + static void pkt_iosched_process_queue(struct pktcdvd_device *pd) 828 + { 829 + 830 + if (atomic_read(&pd->iosched.attention) == 0) 831 + return; 832 + atomic_set(&pd->iosched.attention, 0); 833 + 834 + for (;;) { 835 + struct bio *bio; 836 + int reads_queued, writes_queued; 837 + 838 + spin_lock(&pd->iosched.lock); 839 + reads_queued = !bio_list_empty(&pd->iosched.read_queue); 840 + writes_queued = !bio_list_empty(&pd->iosched.write_queue); 841 + spin_unlock(&pd->iosched.lock); 842 + 843 + if (!reads_queued && !writes_queued) 844 + break; 845 + 846 + if (pd->iosched.writing) { 847 + int need_write_seek = 1; 848 + spin_lock(&pd->iosched.lock); 849 + bio = bio_list_peek(&pd->iosched.write_queue); 850 + spin_unlock(&pd->iosched.lock); 851 + if (bio && (bio->bi_iter.bi_sector == 852 + pd->iosched.last_write)) 853 + need_write_seek = 0; 854 + if (need_write_seek && reads_queued) { 855 + if (atomic_read(&pd->cdrw.pending_bios) > 0) { 856 + pkt_dbg(2, pd, "write, waiting\n"); 857 + break; 858 + } 859 + pkt_flush_cache(pd); 860 + pd->iosched.writing = 0; 861 + } 862 + } else { 863 + if (!reads_queued && writes_queued) { 864 + if (atomic_read(&pd->cdrw.pending_bios) > 0) { 865 + pkt_dbg(2, pd, "read, waiting\n"); 866 + break; 867 + } 868 + pd->iosched.writing = 1; 869 + } 870 + } 871 + 872 + spin_lock(&pd->iosched.lock); 873 + if (pd->iosched.writing) 874 + bio = bio_list_pop(&pd->iosched.write_queue); 875 + else 876 + bio = bio_list_pop(&pd->iosched.read_queue); 877 + spin_unlock(&pd->iosched.lock); 878 + 879 + if (!bio) 880 + continue; 881 + 882 + if (bio_data_dir(bio) == READ) 883 + pd->iosched.successive_reads += 884 + bio->bi_iter.bi_size >> 10; 885 + else { 886 + pd->iosched.successive_reads = 0; 887 + pd->iosched.last_write = bio_end_sector(bio); 888 + } 889 + if (pd->iosched.successive_reads >= HI_SPEED_SWITCH) { 890 + if (pd->read_speed == pd->write_speed) { 891 + pd->read_speed = MAX_SPEED; 892 + pkt_set_speed(pd, pd->write_speed, pd->read_speed); 893 + } 894 + } else { 895 + if (pd->read_speed != pd->write_speed) { 896 + pd->read_speed = pd->write_speed; 897 + pkt_set_speed(pd, pd->write_speed, pd->read_speed); 898 + } 899 + } 900 + 901 + atomic_inc(&pd->cdrw.pending_bios); 902 + submit_bio_noacct(bio); 903 + } 904 + } 905 + 906 + /* 907 + * Special care is needed if the underlying block device has a small 908 + * max_phys_segments value. 909 + */ 910 + static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_queue *q) 911 + { 912 + if ((pd->settings.size << 9) / CD_FRAMESIZE 913 + <= queue_max_segments(q)) { 914 + /* 915 + * The cdrom device can handle one segment/frame 916 + */ 917 + clear_bit(PACKET_MERGE_SEGS, &pd->flags); 918 + return 0; 919 + } else if ((pd->settings.size << 9) / PAGE_SIZE 920 + <= queue_max_segments(q)) { 921 + /* 922 + * We can handle this case at the expense of some extra memory 923 + * copies during write operations 924 + */ 925 + set_bit(PACKET_MERGE_SEGS, &pd->flags); 926 + return 0; 927 + } else { 928 + pkt_err(pd, "cdrom max_phys_segments too small\n"); 929 + return -EIO; 930 + } 931 + } 932 + 933 + static void pkt_end_io_read(struct bio *bio) 934 + { 935 + struct packet_data *pkt = bio->bi_private; 936 + struct pktcdvd_device *pd = pkt->pd; 937 + BUG_ON(!pd); 938 + 939 + pkt_dbg(2, pd, "bio=%p sec0=%llx sec=%llx err=%d\n", 940 + bio, (unsigned long long)pkt->sector, 941 + (unsigned long long)bio->bi_iter.bi_sector, bio->bi_status); 942 + 943 + if (bio->bi_status) 944 + atomic_inc(&pkt->io_errors); 945 + bio_uninit(bio); 946 + if (atomic_dec_and_test(&pkt->io_wait)) { 947 + atomic_inc(&pkt->run_sm); 948 + wake_up(&pd->wqueue); 949 + } 950 + pkt_bio_finished(pd); 951 + } 952 + 953 + static void pkt_end_io_packet_write(struct bio *bio) 954 + { 955 + struct packet_data *pkt = bio->bi_private; 956 + struct pktcdvd_device *pd = pkt->pd; 957 + BUG_ON(!pd); 958 + 959 + pkt_dbg(2, pd, "id=%d, err=%d\n", pkt->id, bio->bi_status); 960 + 961 + pd->stats.pkt_ended++; 962 + 963 + bio_uninit(bio); 964 + pkt_bio_finished(pd); 965 + atomic_dec(&pkt->io_wait); 966 + atomic_inc(&pkt->run_sm); 967 + wake_up(&pd->wqueue); 968 + } 969 + 970 + /* 971 + * Schedule reads for the holes in a packet 972 + */ 973 + static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt) 974 + { 975 + int frames_read = 0; 976 + struct bio *bio; 977 + int f; 978 + char written[PACKET_MAX_SIZE]; 979 + 980 + BUG_ON(bio_list_empty(&pkt->orig_bios)); 981 + 982 + atomic_set(&pkt->io_wait, 0); 983 + atomic_set(&pkt->io_errors, 0); 984 + 985 + /* 986 + * Figure out which frames we need to read before we can write. 987 + */ 988 + memset(written, 0, sizeof(written)); 989 + spin_lock(&pkt->lock); 990 + bio_list_for_each(bio, &pkt->orig_bios) { 991 + int first_frame = (bio->bi_iter.bi_sector - pkt->sector) / 992 + (CD_FRAMESIZE >> 9); 993 + int num_frames = bio->bi_iter.bi_size / CD_FRAMESIZE; 994 + pd->stats.secs_w += num_frames * (CD_FRAMESIZE >> 9); 995 + BUG_ON(first_frame < 0); 996 + BUG_ON(first_frame + num_frames > pkt->frames); 997 + for (f = first_frame; f < first_frame + num_frames; f++) 998 + written[f] = 1; 999 + } 1000 + spin_unlock(&pkt->lock); 1001 + 1002 + if (pkt->cache_valid) { 1003 + pkt_dbg(2, pd, "zone %llx cached\n", 1004 + (unsigned long long)pkt->sector); 1005 + goto out_account; 1006 + } 1007 + 1008 + /* 1009 + * Schedule reads for missing parts of the packet. 1010 + */ 1011 + for (f = 0; f < pkt->frames; f++) { 1012 + int p, offset; 1013 + 1014 + if (written[f]) 1015 + continue; 1016 + 1017 + bio = pkt->r_bios[f]; 1018 + bio_init(bio, pd->bdev, bio->bi_inline_vecs, 1, REQ_OP_READ); 1019 + bio->bi_iter.bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9); 1020 + bio->bi_end_io = pkt_end_io_read; 1021 + bio->bi_private = pkt; 1022 + 1023 + p = (f * CD_FRAMESIZE) / PAGE_SIZE; 1024 + offset = (f * CD_FRAMESIZE) % PAGE_SIZE; 1025 + pkt_dbg(2, pd, "Adding frame %d, page:%p offs:%d\n", 1026 + f, pkt->pages[p], offset); 1027 + if (!bio_add_page(bio, pkt->pages[p], CD_FRAMESIZE, offset)) 1028 + BUG(); 1029 + 1030 + atomic_inc(&pkt->io_wait); 1031 + pkt_queue_bio(pd, bio); 1032 + frames_read++; 1033 + } 1034 + 1035 + out_account: 1036 + pkt_dbg(2, pd, "need %d frames for zone %llx\n", 1037 + frames_read, (unsigned long long)pkt->sector); 1038 + pd->stats.pkt_started++; 1039 + pd->stats.secs_rg += frames_read * (CD_FRAMESIZE >> 9); 1040 + } 1041 + 1042 + /* 1043 + * Find a packet matching zone, or the least recently used packet if 1044 + * there is no match. 1045 + */ 1046 + static struct packet_data *pkt_get_packet_data(struct pktcdvd_device *pd, int zone) 1047 + { 1048 + struct packet_data *pkt; 1049 + 1050 + list_for_each_entry(pkt, &pd->cdrw.pkt_free_list, list) { 1051 + if (pkt->sector == zone || pkt->list.next == &pd->cdrw.pkt_free_list) { 1052 + list_del_init(&pkt->list); 1053 + if (pkt->sector != zone) 1054 + pkt->cache_valid = 0; 1055 + return pkt; 1056 + } 1057 + } 1058 + BUG(); 1059 + return NULL; 1060 + } 1061 + 1062 + static void pkt_put_packet_data(struct pktcdvd_device *pd, struct packet_data *pkt) 1063 + { 1064 + if (pkt->cache_valid) { 1065 + list_add(&pkt->list, &pd->cdrw.pkt_free_list); 1066 + } else { 1067 + list_add_tail(&pkt->list, &pd->cdrw.pkt_free_list); 1068 + } 1069 + } 1070 + 1071 + static inline void pkt_set_state(struct packet_data *pkt, enum packet_data_state state) 1072 + { 1073 + #if PACKET_DEBUG > 1 1074 + static const char *state_name[] = { 1075 + "IDLE", "WAITING", "READ_WAIT", "WRITE_WAIT", "RECOVERY", "FINISHED" 1076 + }; 1077 + enum packet_data_state old_state = pkt->state; 1078 + pkt_dbg(2, pd, "pkt %2d : s=%6llx %s -> %s\n", 1079 + pkt->id, (unsigned long long)pkt->sector, 1080 + state_name[old_state], state_name[state]); 1081 + #endif 1082 + pkt->state = state; 1083 + } 1084 + 1085 + /* 1086 + * Scan the work queue to see if we can start a new packet. 1087 + * returns non-zero if any work was done. 1088 + */ 1089 + static int pkt_handle_queue(struct pktcdvd_device *pd) 1090 + { 1091 + struct packet_data *pkt, *p; 1092 + struct bio *bio = NULL; 1093 + sector_t zone = 0; /* Suppress gcc warning */ 1094 + struct pkt_rb_node *node, *first_node; 1095 + struct rb_node *n; 1096 + 1097 + atomic_set(&pd->scan_queue, 0); 1098 + 1099 + if (list_empty(&pd->cdrw.pkt_free_list)) { 1100 + pkt_dbg(2, pd, "no pkt\n"); 1101 + return 0; 1102 + } 1103 + 1104 + /* 1105 + * Try to find a zone we are not already working on. 1106 + */ 1107 + spin_lock(&pd->lock); 1108 + first_node = pkt_rbtree_find(pd, pd->current_sector); 1109 + if (!first_node) { 1110 + n = rb_first(&pd->bio_queue); 1111 + if (n) 1112 + first_node = rb_entry(n, struct pkt_rb_node, rb_node); 1113 + } 1114 + node = first_node; 1115 + while (node) { 1116 + bio = node->bio; 1117 + zone = get_zone(bio->bi_iter.bi_sector, pd); 1118 + list_for_each_entry(p, &pd->cdrw.pkt_active_list, list) { 1119 + if (p->sector == zone) { 1120 + bio = NULL; 1121 + goto try_next_bio; 1122 + } 1123 + } 1124 + break; 1125 + try_next_bio: 1126 + node = pkt_rbtree_next(node); 1127 + if (!node) { 1128 + n = rb_first(&pd->bio_queue); 1129 + if (n) 1130 + node = rb_entry(n, struct pkt_rb_node, rb_node); 1131 + } 1132 + if (node == first_node) 1133 + node = NULL; 1134 + } 1135 + spin_unlock(&pd->lock); 1136 + if (!bio) { 1137 + pkt_dbg(2, pd, "no bio\n"); 1138 + return 0; 1139 + } 1140 + 1141 + pkt = pkt_get_packet_data(pd, zone); 1142 + 1143 + pd->current_sector = zone + pd->settings.size; 1144 + pkt->sector = zone; 1145 + BUG_ON(pkt->frames != pd->settings.size >> 2); 1146 + pkt->write_size = 0; 1147 + 1148 + /* 1149 + * Scan work queue for bios in the same zone and link them 1150 + * to this packet. 1151 + */ 1152 + spin_lock(&pd->lock); 1153 + pkt_dbg(2, pd, "looking for zone %llx\n", (unsigned long long)zone); 1154 + while ((node = pkt_rbtree_find(pd, zone)) != NULL) { 1155 + bio = node->bio; 1156 + pkt_dbg(2, pd, "found zone=%llx\n", (unsigned long long) 1157 + get_zone(bio->bi_iter.bi_sector, pd)); 1158 + if (get_zone(bio->bi_iter.bi_sector, pd) != zone) 1159 + break; 1160 + pkt_rbtree_erase(pd, node); 1161 + spin_lock(&pkt->lock); 1162 + bio_list_add(&pkt->orig_bios, bio); 1163 + pkt->write_size += bio->bi_iter.bi_size / CD_FRAMESIZE; 1164 + spin_unlock(&pkt->lock); 1165 + } 1166 + /* check write congestion marks, and if bio_queue_size is 1167 + * below, wake up any waiters 1168 + */ 1169 + if (pd->congested && 1170 + pd->bio_queue_size <= pd->write_congestion_off) { 1171 + pd->congested = false; 1172 + wake_up_var(&pd->congested); 1173 + } 1174 + spin_unlock(&pd->lock); 1175 + 1176 + pkt->sleep_time = max(PACKET_WAIT_TIME, 1); 1177 + pkt_set_state(pkt, PACKET_WAITING_STATE); 1178 + atomic_set(&pkt->run_sm, 1); 1179 + 1180 + spin_lock(&pd->cdrw.active_list_lock); 1181 + list_add(&pkt->list, &pd->cdrw.pkt_active_list); 1182 + spin_unlock(&pd->cdrw.active_list_lock); 1183 + 1184 + return 1; 1185 + } 1186 + 1187 + /** 1188 + * bio_list_copy_data - copy contents of data buffers from one chain of bios to 1189 + * another 1190 + * @src: source bio list 1191 + * @dst: destination bio list 1192 + * 1193 + * Stops when it reaches the end of either the @src list or @dst list - that is, 1194 + * copies min(src->bi_size, dst->bi_size) bytes (or the equivalent for lists of 1195 + * bios). 1196 + */ 1197 + static void bio_list_copy_data(struct bio *dst, struct bio *src) 1198 + { 1199 + struct bvec_iter src_iter = src->bi_iter; 1200 + struct bvec_iter dst_iter = dst->bi_iter; 1201 + 1202 + while (1) { 1203 + if (!src_iter.bi_size) { 1204 + src = src->bi_next; 1205 + if (!src) 1206 + break; 1207 + 1208 + src_iter = src->bi_iter; 1209 + } 1210 + 1211 + if (!dst_iter.bi_size) { 1212 + dst = dst->bi_next; 1213 + if (!dst) 1214 + break; 1215 + 1216 + dst_iter = dst->bi_iter; 1217 + } 1218 + 1219 + bio_copy_data_iter(dst, &dst_iter, src, &src_iter); 1220 + } 1221 + } 1222 + 1223 + /* 1224 + * Assemble a bio to write one packet and queue the bio for processing 1225 + * by the underlying block device. 1226 + */ 1227 + static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt) 1228 + { 1229 + int f; 1230 + 1231 + bio_init(pkt->w_bio, pd->bdev, pkt->w_bio->bi_inline_vecs, pkt->frames, 1232 + REQ_OP_WRITE); 1233 + pkt->w_bio->bi_iter.bi_sector = pkt->sector; 1234 + pkt->w_bio->bi_end_io = pkt_end_io_packet_write; 1235 + pkt->w_bio->bi_private = pkt; 1236 + 1237 + /* XXX: locking? */ 1238 + for (f = 0; f < pkt->frames; f++) { 1239 + struct page *page = pkt->pages[(f * CD_FRAMESIZE) / PAGE_SIZE]; 1240 + unsigned offset = (f * CD_FRAMESIZE) % PAGE_SIZE; 1241 + 1242 + if (!bio_add_page(pkt->w_bio, page, CD_FRAMESIZE, offset)) 1243 + BUG(); 1244 + } 1245 + pkt_dbg(2, pd, "vcnt=%d\n", pkt->w_bio->bi_vcnt); 1246 + 1247 + /* 1248 + * Fill-in bvec with data from orig_bios. 1249 + */ 1250 + spin_lock(&pkt->lock); 1251 + bio_list_copy_data(pkt->w_bio, pkt->orig_bios.head); 1252 + 1253 + pkt_set_state(pkt, PACKET_WRITE_WAIT_STATE); 1254 + spin_unlock(&pkt->lock); 1255 + 1256 + pkt_dbg(2, pd, "Writing %d frames for zone %llx\n", 1257 + pkt->write_size, (unsigned long long)pkt->sector); 1258 + 1259 + if (test_bit(PACKET_MERGE_SEGS, &pd->flags) || (pkt->write_size < pkt->frames)) 1260 + pkt->cache_valid = 1; 1261 + else 1262 + pkt->cache_valid = 0; 1263 + 1264 + /* Start the write request */ 1265 + atomic_set(&pkt->io_wait, 1); 1266 + pkt_queue_bio(pd, pkt->w_bio); 1267 + } 1268 + 1269 + static void pkt_finish_packet(struct packet_data *pkt, blk_status_t status) 1270 + { 1271 + struct bio *bio; 1272 + 1273 + if (status) 1274 + pkt->cache_valid = 0; 1275 + 1276 + /* Finish all bios corresponding to this packet */ 1277 + while ((bio = bio_list_pop(&pkt->orig_bios))) { 1278 + bio->bi_status = status; 1279 + bio_endio(bio); 1280 + } 1281 + } 1282 + 1283 + static void pkt_run_state_machine(struct pktcdvd_device *pd, struct packet_data *pkt) 1284 + { 1285 + pkt_dbg(2, pd, "pkt %d\n", pkt->id); 1286 + 1287 + for (;;) { 1288 + switch (pkt->state) { 1289 + case PACKET_WAITING_STATE: 1290 + if ((pkt->write_size < pkt->frames) && (pkt->sleep_time > 0)) 1291 + return; 1292 + 1293 + pkt->sleep_time = 0; 1294 + pkt_gather_data(pd, pkt); 1295 + pkt_set_state(pkt, PACKET_READ_WAIT_STATE); 1296 + break; 1297 + 1298 + case PACKET_READ_WAIT_STATE: 1299 + if (atomic_read(&pkt->io_wait) > 0) 1300 + return; 1301 + 1302 + if (atomic_read(&pkt->io_errors) > 0) { 1303 + pkt_set_state(pkt, PACKET_RECOVERY_STATE); 1304 + } else { 1305 + pkt_start_write(pd, pkt); 1306 + } 1307 + break; 1308 + 1309 + case PACKET_WRITE_WAIT_STATE: 1310 + if (atomic_read(&pkt->io_wait) > 0) 1311 + return; 1312 + 1313 + if (!pkt->w_bio->bi_status) { 1314 + pkt_set_state(pkt, PACKET_FINISHED_STATE); 1315 + } else { 1316 + pkt_set_state(pkt, PACKET_RECOVERY_STATE); 1317 + } 1318 + break; 1319 + 1320 + case PACKET_RECOVERY_STATE: 1321 + pkt_dbg(2, pd, "No recovery possible\n"); 1322 + pkt_set_state(pkt, PACKET_FINISHED_STATE); 1323 + break; 1324 + 1325 + case PACKET_FINISHED_STATE: 1326 + pkt_finish_packet(pkt, pkt->w_bio->bi_status); 1327 + return; 1328 + 1329 + default: 1330 + BUG(); 1331 + break; 1332 + } 1333 + } 1334 + } 1335 + 1336 + static void pkt_handle_packets(struct pktcdvd_device *pd) 1337 + { 1338 + struct packet_data *pkt, *next; 1339 + 1340 + /* 1341 + * Run state machine for active packets 1342 + */ 1343 + list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) { 1344 + if (atomic_read(&pkt->run_sm) > 0) { 1345 + atomic_set(&pkt->run_sm, 0); 1346 + pkt_run_state_machine(pd, pkt); 1347 + } 1348 + } 1349 + 1350 + /* 1351 + * Move no longer active packets to the free list 1352 + */ 1353 + spin_lock(&pd->cdrw.active_list_lock); 1354 + list_for_each_entry_safe(pkt, next, &pd->cdrw.pkt_active_list, list) { 1355 + if (pkt->state == PACKET_FINISHED_STATE) { 1356 + list_del(&pkt->list); 1357 + pkt_put_packet_data(pd, pkt); 1358 + pkt_set_state(pkt, PACKET_IDLE_STATE); 1359 + atomic_set(&pd->scan_queue, 1); 1360 + } 1361 + } 1362 + spin_unlock(&pd->cdrw.active_list_lock); 1363 + } 1364 + 1365 + static void pkt_count_states(struct pktcdvd_device *pd, int *states) 1366 + { 1367 + struct packet_data *pkt; 1368 + int i; 1369 + 1370 + for (i = 0; i < PACKET_NUM_STATES; i++) 1371 + states[i] = 0; 1372 + 1373 + spin_lock(&pd->cdrw.active_list_lock); 1374 + list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) { 1375 + states[pkt->state]++; 1376 + } 1377 + spin_unlock(&pd->cdrw.active_list_lock); 1378 + } 1379 + 1380 + /* 1381 + * kcdrwd is woken up when writes have been queued for one of our 1382 + * registered devices 1383 + */ 1384 + static int kcdrwd(void *foobar) 1385 + { 1386 + struct pktcdvd_device *pd = foobar; 1387 + struct packet_data *pkt; 1388 + long min_sleep_time, residue; 1389 + 1390 + set_user_nice(current, MIN_NICE); 1391 + set_freezable(); 1392 + 1393 + for (;;) { 1394 + DECLARE_WAITQUEUE(wait, current); 1395 + 1396 + /* 1397 + * Wait until there is something to do 1398 + */ 1399 + add_wait_queue(&pd->wqueue, &wait); 1400 + for (;;) { 1401 + set_current_state(TASK_INTERRUPTIBLE); 1402 + 1403 + /* Check if we need to run pkt_handle_queue */ 1404 + if (atomic_read(&pd->scan_queue) > 0) 1405 + goto work_to_do; 1406 + 1407 + /* Check if we need to run the state machine for some packet */ 1408 + list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) { 1409 + if (atomic_read(&pkt->run_sm) > 0) 1410 + goto work_to_do; 1411 + } 1412 + 1413 + /* Check if we need to process the iosched queues */ 1414 + if (atomic_read(&pd->iosched.attention) != 0) 1415 + goto work_to_do; 1416 + 1417 + /* Otherwise, go to sleep */ 1418 + if (PACKET_DEBUG > 1) { 1419 + int states[PACKET_NUM_STATES]; 1420 + pkt_count_states(pd, states); 1421 + pkt_dbg(2, pd, "i:%d ow:%d rw:%d ww:%d rec:%d fin:%d\n", 1422 + states[0], states[1], states[2], 1423 + states[3], states[4], states[5]); 1424 + } 1425 + 1426 + min_sleep_time = MAX_SCHEDULE_TIMEOUT; 1427 + list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) { 1428 + if (pkt->sleep_time && pkt->sleep_time < min_sleep_time) 1429 + min_sleep_time = pkt->sleep_time; 1430 + } 1431 + 1432 + pkt_dbg(2, pd, "sleeping\n"); 1433 + residue = schedule_timeout(min_sleep_time); 1434 + pkt_dbg(2, pd, "wake up\n"); 1435 + 1436 + /* make swsusp happy with our thread */ 1437 + try_to_freeze(); 1438 + 1439 + list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) { 1440 + if (!pkt->sleep_time) 1441 + continue; 1442 + pkt->sleep_time -= min_sleep_time - residue; 1443 + if (pkt->sleep_time <= 0) { 1444 + pkt->sleep_time = 0; 1445 + atomic_inc(&pkt->run_sm); 1446 + } 1447 + } 1448 + 1449 + if (kthread_should_stop()) 1450 + break; 1451 + } 1452 + work_to_do: 1453 + set_current_state(TASK_RUNNING); 1454 + remove_wait_queue(&pd->wqueue, &wait); 1455 + 1456 + if (kthread_should_stop()) 1457 + break; 1458 + 1459 + /* 1460 + * if pkt_handle_queue returns true, we can queue 1461 + * another request. 1462 + */ 1463 + while (pkt_handle_queue(pd)) 1464 + ; 1465 + 1466 + /* 1467 + * Handle packet state machine 1468 + */ 1469 + pkt_handle_packets(pd); 1470 + 1471 + /* 1472 + * Handle iosched queues 1473 + */ 1474 + pkt_iosched_process_queue(pd); 1475 + } 1476 + 1477 + return 0; 1478 + } 1479 + 1480 + static void pkt_print_settings(struct pktcdvd_device *pd) 1481 + { 1482 + pkt_info(pd, "%s packets, %u blocks, Mode-%c disc\n", 1483 + pd->settings.fp ? "Fixed" : "Variable", 1484 + pd->settings.size >> 2, 1485 + pd->settings.block_mode == 8 ? '1' : '2'); 1486 + } 1487 + 1488 + static int pkt_mode_sense(struct pktcdvd_device *pd, struct packet_command *cgc, int page_code, int page_control) 1489 + { 1490 + memset(cgc->cmd, 0, sizeof(cgc->cmd)); 1491 + 1492 + cgc->cmd[0] = GPCMD_MODE_SENSE_10; 1493 + cgc->cmd[2] = page_code | (page_control << 6); 1494 + cgc->cmd[7] = cgc->buflen >> 8; 1495 + cgc->cmd[8] = cgc->buflen & 0xff; 1496 + cgc->data_direction = CGC_DATA_READ; 1497 + return pkt_generic_packet(pd, cgc); 1498 + } 1499 + 1500 + static int pkt_mode_select(struct pktcdvd_device *pd, struct packet_command *cgc) 1501 + { 1502 + memset(cgc->cmd, 0, sizeof(cgc->cmd)); 1503 + memset(cgc->buffer, 0, 2); 1504 + cgc->cmd[0] = GPCMD_MODE_SELECT_10; 1505 + cgc->cmd[1] = 0x10; /* PF */ 1506 + cgc->cmd[7] = cgc->buflen >> 8; 1507 + cgc->cmd[8] = cgc->buflen & 0xff; 1508 + cgc->data_direction = CGC_DATA_WRITE; 1509 + return pkt_generic_packet(pd, cgc); 1510 + } 1511 + 1512 + static int pkt_get_disc_info(struct pktcdvd_device *pd, disc_information *di) 1513 + { 1514 + struct packet_command cgc; 1515 + int ret; 1516 + 1517 + /* set up command and get the disc info */ 1518 + init_cdrom_command(&cgc, di, sizeof(*di), CGC_DATA_READ); 1519 + cgc.cmd[0] = GPCMD_READ_DISC_INFO; 1520 + cgc.cmd[8] = cgc.buflen = 2; 1521 + cgc.quiet = 1; 1522 + 1523 + ret = pkt_generic_packet(pd, &cgc); 1524 + if (ret) 1525 + return ret; 1526 + 1527 + /* not all drives have the same disc_info length, so requeue 1528 + * packet with the length the drive tells us it can supply 1529 + */ 1530 + cgc.buflen = be16_to_cpu(di->disc_information_length) + 1531 + sizeof(di->disc_information_length); 1532 + 1533 + if (cgc.buflen > sizeof(disc_information)) 1534 + cgc.buflen = sizeof(disc_information); 1535 + 1536 + cgc.cmd[8] = cgc.buflen; 1537 + return pkt_generic_packet(pd, &cgc); 1538 + } 1539 + 1540 + static int pkt_get_track_info(struct pktcdvd_device *pd, __u16 track, __u8 type, track_information *ti) 1541 + { 1542 + struct packet_command cgc; 1543 + int ret; 1544 + 1545 + init_cdrom_command(&cgc, ti, 8, CGC_DATA_READ); 1546 + cgc.cmd[0] = GPCMD_READ_TRACK_RZONE_INFO; 1547 + cgc.cmd[1] = type & 3; 1548 + cgc.cmd[4] = (track & 0xff00) >> 8; 1549 + cgc.cmd[5] = track & 0xff; 1550 + cgc.cmd[8] = 8; 1551 + cgc.quiet = 1; 1552 + 1553 + ret = pkt_generic_packet(pd, &cgc); 1554 + if (ret) 1555 + return ret; 1556 + 1557 + cgc.buflen = be16_to_cpu(ti->track_information_length) + 1558 + sizeof(ti->track_information_length); 1559 + 1560 + if (cgc.buflen > sizeof(track_information)) 1561 + cgc.buflen = sizeof(track_information); 1562 + 1563 + cgc.cmd[8] = cgc.buflen; 1564 + return pkt_generic_packet(pd, &cgc); 1565 + } 1566 + 1567 + static noinline_for_stack int pkt_get_last_written(struct pktcdvd_device *pd, 1568 + long *last_written) 1569 + { 1570 + disc_information di; 1571 + track_information ti; 1572 + __u32 last_track; 1573 + int ret; 1574 + 1575 + ret = pkt_get_disc_info(pd, &di); 1576 + if (ret) 1577 + return ret; 1578 + 1579 + last_track = (di.last_track_msb << 8) | di.last_track_lsb; 1580 + ret = pkt_get_track_info(pd, last_track, 1, &ti); 1581 + if (ret) 1582 + return ret; 1583 + 1584 + /* if this track is blank, try the previous. */ 1585 + if (ti.blank) { 1586 + last_track--; 1587 + ret = pkt_get_track_info(pd, last_track, 1, &ti); 1588 + if (ret) 1589 + return ret; 1590 + } 1591 + 1592 + /* if last recorded field is valid, return it. */ 1593 + if (ti.lra_v) { 1594 + *last_written = be32_to_cpu(ti.last_rec_address); 1595 + } else { 1596 + /* make it up instead */ 1597 + *last_written = be32_to_cpu(ti.track_start) + 1598 + be32_to_cpu(ti.track_size); 1599 + if (ti.free_blocks) 1600 + *last_written -= (be32_to_cpu(ti.free_blocks) + 7); 1601 + } 1602 + return 0; 1603 + } 1604 + 1605 + /* 1606 + * write mode select package based on pd->settings 1607 + */ 1608 + static noinline_for_stack int pkt_set_write_settings(struct pktcdvd_device *pd) 1609 + { 1610 + struct packet_command cgc; 1611 + struct scsi_sense_hdr sshdr; 1612 + write_param_page *wp; 1613 + char buffer[128]; 1614 + int ret, size; 1615 + 1616 + /* doesn't apply to DVD+RW or DVD-RAM */ 1617 + if ((pd->mmc3_profile == 0x1a) || (pd->mmc3_profile == 0x12)) 1618 + return 0; 1619 + 1620 + memset(buffer, 0, sizeof(buffer)); 1621 + init_cdrom_command(&cgc, buffer, sizeof(*wp), CGC_DATA_READ); 1622 + cgc.sshdr = &sshdr; 1623 + ret = pkt_mode_sense(pd, &cgc, GPMODE_WRITE_PARMS_PAGE, 0); 1624 + if (ret) { 1625 + pkt_dump_sense(pd, &cgc); 1626 + return ret; 1627 + } 1628 + 1629 + size = 2 + ((buffer[0] << 8) | (buffer[1] & 0xff)); 1630 + pd->mode_offset = (buffer[6] << 8) | (buffer[7] & 0xff); 1631 + if (size > sizeof(buffer)) 1632 + size = sizeof(buffer); 1633 + 1634 + /* 1635 + * now get it all 1636 + */ 1637 + init_cdrom_command(&cgc, buffer, size, CGC_DATA_READ); 1638 + cgc.sshdr = &sshdr; 1639 + ret = pkt_mode_sense(pd, &cgc, GPMODE_WRITE_PARMS_PAGE, 0); 1640 + if (ret) { 1641 + pkt_dump_sense(pd, &cgc); 1642 + return ret; 1643 + } 1644 + 1645 + /* 1646 + * write page is offset header + block descriptor length 1647 + */ 1648 + wp = (write_param_page *) &buffer[sizeof(struct mode_page_header) + pd->mode_offset]; 1649 + 1650 + wp->fp = pd->settings.fp; 1651 + wp->track_mode = pd->settings.track_mode; 1652 + wp->write_type = pd->settings.write_type; 1653 + wp->data_block_type = pd->settings.block_mode; 1654 + 1655 + wp->multi_session = 0; 1656 + 1657 + #ifdef PACKET_USE_LS 1658 + wp->link_size = 7; 1659 + wp->ls_v = 1; 1660 + #endif 1661 + 1662 + if (wp->data_block_type == PACKET_BLOCK_MODE1) { 1663 + wp->session_format = 0; 1664 + wp->subhdr2 = 0x20; 1665 + } else if (wp->data_block_type == PACKET_BLOCK_MODE2) { 1666 + wp->session_format = 0x20; 1667 + wp->subhdr2 = 8; 1668 + #if 0 1669 + wp->mcn[0] = 0x80; 1670 + memcpy(&wp->mcn[1], PACKET_MCN, sizeof(wp->mcn) - 1); 1671 + #endif 1672 + } else { 1673 + /* 1674 + * paranoia 1675 + */ 1676 + pkt_err(pd, "write mode wrong %d\n", wp->data_block_type); 1677 + return 1; 1678 + } 1679 + wp->packet_size = cpu_to_be32(pd->settings.size >> 2); 1680 + 1681 + cgc.buflen = cgc.cmd[8] = size; 1682 + ret = pkt_mode_select(pd, &cgc); 1683 + if (ret) { 1684 + pkt_dump_sense(pd, &cgc); 1685 + return ret; 1686 + } 1687 + 1688 + pkt_print_settings(pd); 1689 + return 0; 1690 + } 1691 + 1692 + /* 1693 + * 1 -- we can write to this track, 0 -- we can't 1694 + */ 1695 + static int pkt_writable_track(struct pktcdvd_device *pd, track_information *ti) 1696 + { 1697 + switch (pd->mmc3_profile) { 1698 + case 0x1a: /* DVD+RW */ 1699 + case 0x12: /* DVD-RAM */ 1700 + /* The track is always writable on DVD+RW/DVD-RAM */ 1701 + return 1; 1702 + default: 1703 + break; 1704 + } 1705 + 1706 + if (!ti->packet || !ti->fp) 1707 + return 0; 1708 + 1709 + /* 1710 + * "good" settings as per Mt Fuji. 1711 + */ 1712 + if (ti->rt == 0 && ti->blank == 0) 1713 + return 1; 1714 + 1715 + if (ti->rt == 0 && ti->blank == 1) 1716 + return 1; 1717 + 1718 + if (ti->rt == 1 && ti->blank == 0) 1719 + return 1; 1720 + 1721 + pkt_err(pd, "bad state %d-%d-%d\n", ti->rt, ti->blank, ti->packet); 1722 + return 0; 1723 + } 1724 + 1725 + /* 1726 + * 1 -- we can write to this disc, 0 -- we can't 1727 + */ 1728 + static int pkt_writable_disc(struct pktcdvd_device *pd, disc_information *di) 1729 + { 1730 + switch (pd->mmc3_profile) { 1731 + case 0x0a: /* CD-RW */ 1732 + case 0xffff: /* MMC3 not supported */ 1733 + break; 1734 + case 0x1a: /* DVD+RW */ 1735 + case 0x13: /* DVD-RW */ 1736 + case 0x12: /* DVD-RAM */ 1737 + return 1; 1738 + default: 1739 + pkt_dbg(2, pd, "Wrong disc profile (%x)\n", 1740 + pd->mmc3_profile); 1741 + return 0; 1742 + } 1743 + 1744 + /* 1745 + * for disc type 0xff we should probably reserve a new track. 1746 + * but i'm not sure, should we leave this to user apps? probably. 1747 + */ 1748 + if (di->disc_type == 0xff) { 1749 + pkt_notice(pd, "unknown disc - no track?\n"); 1750 + return 0; 1751 + } 1752 + 1753 + if (di->disc_type != 0x20 && di->disc_type != 0) { 1754 + pkt_err(pd, "wrong disc type (%x)\n", di->disc_type); 1755 + return 0; 1756 + } 1757 + 1758 + if (di->erasable == 0) { 1759 + pkt_notice(pd, "disc not erasable\n"); 1760 + return 0; 1761 + } 1762 + 1763 + if (di->border_status == PACKET_SESSION_RESERVED) { 1764 + pkt_err(pd, "can't write to last track (reserved)\n"); 1765 + return 0; 1766 + } 1767 + 1768 + return 1; 1769 + } 1770 + 1771 + static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd) 1772 + { 1773 + struct packet_command cgc; 1774 + unsigned char buf[12]; 1775 + disc_information di; 1776 + track_information ti; 1777 + int ret, track; 1778 + 1779 + init_cdrom_command(&cgc, buf, sizeof(buf), CGC_DATA_READ); 1780 + cgc.cmd[0] = GPCMD_GET_CONFIGURATION; 1781 + cgc.cmd[8] = 8; 1782 + ret = pkt_generic_packet(pd, &cgc); 1783 + pd->mmc3_profile = ret ? 0xffff : buf[6] << 8 | buf[7]; 1784 + 1785 + memset(&di, 0, sizeof(disc_information)); 1786 + memset(&ti, 0, sizeof(track_information)); 1787 + 1788 + ret = pkt_get_disc_info(pd, &di); 1789 + if (ret) { 1790 + pkt_err(pd, "failed get_disc\n"); 1791 + return ret; 1792 + } 1793 + 1794 + if (!pkt_writable_disc(pd, &di)) 1795 + return -EROFS; 1796 + 1797 + pd->type = di.erasable ? PACKET_CDRW : PACKET_CDR; 1798 + 1799 + track = 1; /* (di.last_track_msb << 8) | di.last_track_lsb; */ 1800 + ret = pkt_get_track_info(pd, track, 1, &ti); 1801 + if (ret) { 1802 + pkt_err(pd, "failed get_track\n"); 1803 + return ret; 1804 + } 1805 + 1806 + if (!pkt_writable_track(pd, &ti)) { 1807 + pkt_err(pd, "can't write to this track\n"); 1808 + return -EROFS; 1809 + } 1810 + 1811 + /* 1812 + * we keep packet size in 512 byte units, makes it easier to 1813 + * deal with request calculations. 1814 + */ 1815 + pd->settings.size = be32_to_cpu(ti.fixed_packet_size) << 2; 1816 + if (pd->settings.size == 0) { 1817 + pkt_notice(pd, "detected zero packet size!\n"); 1818 + return -ENXIO; 1819 + } 1820 + if (pd->settings.size > PACKET_MAX_SECTORS) { 1821 + pkt_err(pd, "packet size is too big\n"); 1822 + return -EROFS; 1823 + } 1824 + pd->settings.fp = ti.fp; 1825 + pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1); 1826 + 1827 + if (ti.nwa_v) { 1828 + pd->nwa = be32_to_cpu(ti.next_writable); 1829 + set_bit(PACKET_NWA_VALID, &pd->flags); 1830 + } 1831 + 1832 + /* 1833 + * in theory we could use lra on -RW media as well and just zero 1834 + * blocks that haven't been written yet, but in practice that 1835 + * is just a no-go. we'll use that for -R, naturally. 1836 + */ 1837 + if (ti.lra_v) { 1838 + pd->lra = be32_to_cpu(ti.last_rec_address); 1839 + set_bit(PACKET_LRA_VALID, &pd->flags); 1840 + } else { 1841 + pd->lra = 0xffffffff; 1842 + set_bit(PACKET_LRA_VALID, &pd->flags); 1843 + } 1844 + 1845 + /* 1846 + * fine for now 1847 + */ 1848 + pd->settings.link_loss = 7; 1849 + pd->settings.write_type = 0; /* packet */ 1850 + pd->settings.track_mode = ti.track_mode; 1851 + 1852 + /* 1853 + * mode1 or mode2 disc 1854 + */ 1855 + switch (ti.data_mode) { 1856 + case PACKET_MODE1: 1857 + pd->settings.block_mode = PACKET_BLOCK_MODE1; 1858 + break; 1859 + case PACKET_MODE2: 1860 + pd->settings.block_mode = PACKET_BLOCK_MODE2; 1861 + break; 1862 + default: 1863 + pkt_err(pd, "unknown data mode\n"); 1864 + return -EROFS; 1865 + } 1866 + return 0; 1867 + } 1868 + 1869 + /* 1870 + * enable/disable write caching on drive 1871 + */ 1872 + static noinline_for_stack int pkt_write_caching(struct pktcdvd_device *pd, 1873 + int set) 1874 + { 1875 + struct packet_command cgc; 1876 + struct scsi_sense_hdr sshdr; 1877 + unsigned char buf[64]; 1878 + int ret; 1879 + 1880 + init_cdrom_command(&cgc, buf, sizeof(buf), CGC_DATA_READ); 1881 + cgc.sshdr = &sshdr; 1882 + cgc.buflen = pd->mode_offset + 12; 1883 + 1884 + /* 1885 + * caching mode page might not be there, so quiet this command 1886 + */ 1887 + cgc.quiet = 1; 1888 + 1889 + ret = pkt_mode_sense(pd, &cgc, GPMODE_WCACHING_PAGE, 0); 1890 + if (ret) 1891 + return ret; 1892 + 1893 + buf[pd->mode_offset + 10] |= (!!set << 2); 1894 + 1895 + cgc.buflen = cgc.cmd[8] = 2 + ((buf[0] << 8) | (buf[1] & 0xff)); 1896 + ret = pkt_mode_select(pd, &cgc); 1897 + if (ret) { 1898 + pkt_err(pd, "write caching control failed\n"); 1899 + pkt_dump_sense(pd, &cgc); 1900 + } else if (!ret && set) 1901 + pkt_notice(pd, "enabled write caching\n"); 1902 + return ret; 1903 + } 1904 + 1905 + static int pkt_lock_door(struct pktcdvd_device *pd, int lockflag) 1906 + { 1907 + struct packet_command cgc; 1908 + 1909 + init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE); 1910 + cgc.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; 1911 + cgc.cmd[4] = lockflag ? 1 : 0; 1912 + return pkt_generic_packet(pd, &cgc); 1913 + } 1914 + 1915 + /* 1916 + * Returns drive maximum write speed 1917 + */ 1918 + static noinline_for_stack int pkt_get_max_speed(struct pktcdvd_device *pd, 1919 + unsigned *write_speed) 1920 + { 1921 + struct packet_command cgc; 1922 + struct scsi_sense_hdr sshdr; 1923 + unsigned char buf[256+18]; 1924 + unsigned char *cap_buf; 1925 + int ret, offset; 1926 + 1927 + cap_buf = &buf[sizeof(struct mode_page_header) + pd->mode_offset]; 1928 + init_cdrom_command(&cgc, buf, sizeof(buf), CGC_DATA_UNKNOWN); 1929 + cgc.sshdr = &sshdr; 1930 + 1931 + ret = pkt_mode_sense(pd, &cgc, GPMODE_CAPABILITIES_PAGE, 0); 1932 + if (ret) { 1933 + cgc.buflen = pd->mode_offset + cap_buf[1] + 2 + 1934 + sizeof(struct mode_page_header); 1935 + ret = pkt_mode_sense(pd, &cgc, GPMODE_CAPABILITIES_PAGE, 0); 1936 + if (ret) { 1937 + pkt_dump_sense(pd, &cgc); 1938 + return ret; 1939 + } 1940 + } 1941 + 1942 + offset = 20; /* Obsoleted field, used by older drives */ 1943 + if (cap_buf[1] >= 28) 1944 + offset = 28; /* Current write speed selected */ 1945 + if (cap_buf[1] >= 30) { 1946 + /* If the drive reports at least one "Logical Unit Write 1947 + * Speed Performance Descriptor Block", use the information 1948 + * in the first block. (contains the highest speed) 1949 + */ 1950 + int num_spdb = (cap_buf[30] << 8) + cap_buf[31]; 1951 + if (num_spdb > 0) 1952 + offset = 34; 1953 + } 1954 + 1955 + *write_speed = (cap_buf[offset] << 8) | cap_buf[offset + 1]; 1956 + return 0; 1957 + } 1958 + 1959 + /* These tables from cdrecord - I don't have orange book */ 1960 + /* standard speed CD-RW (1-4x) */ 1961 + static char clv_to_speed[16] = { 1962 + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ 1963 + 0, 2, 4, 6, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 1964 + }; 1965 + /* high speed CD-RW (-10x) */ 1966 + static char hs_clv_to_speed[16] = { 1967 + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ 1968 + 0, 2, 4, 6, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 1969 + }; 1970 + /* ultra high speed CD-RW */ 1971 + static char us_clv_to_speed[16] = { 1972 + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ 1973 + 0, 2, 4, 8, 0, 0,16, 0,24,32,40,48, 0, 0, 0, 0 1974 + }; 1975 + 1976 + /* 1977 + * reads the maximum media speed from ATIP 1978 + */ 1979 + static noinline_for_stack int pkt_media_speed(struct pktcdvd_device *pd, 1980 + unsigned *speed) 1981 + { 1982 + struct packet_command cgc; 1983 + struct scsi_sense_hdr sshdr; 1984 + unsigned char buf[64]; 1985 + unsigned int size, st, sp; 1986 + int ret; 1987 + 1988 + init_cdrom_command(&cgc, buf, 2, CGC_DATA_READ); 1989 + cgc.sshdr = &sshdr; 1990 + cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP; 1991 + cgc.cmd[1] = 2; 1992 + cgc.cmd[2] = 4; /* READ ATIP */ 1993 + cgc.cmd[8] = 2; 1994 + ret = pkt_generic_packet(pd, &cgc); 1995 + if (ret) { 1996 + pkt_dump_sense(pd, &cgc); 1997 + return ret; 1998 + } 1999 + size = ((unsigned int) buf[0]<<8) + buf[1] + 2; 2000 + if (size > sizeof(buf)) 2001 + size = sizeof(buf); 2002 + 2003 + init_cdrom_command(&cgc, buf, size, CGC_DATA_READ); 2004 + cgc.sshdr = &sshdr; 2005 + cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP; 2006 + cgc.cmd[1] = 2; 2007 + cgc.cmd[2] = 4; 2008 + cgc.cmd[8] = size; 2009 + ret = pkt_generic_packet(pd, &cgc); 2010 + if (ret) { 2011 + pkt_dump_sense(pd, &cgc); 2012 + return ret; 2013 + } 2014 + 2015 + if (!(buf[6] & 0x40)) { 2016 + pkt_notice(pd, "disc type is not CD-RW\n"); 2017 + return 1; 2018 + } 2019 + if (!(buf[6] & 0x4)) { 2020 + pkt_notice(pd, "A1 values on media are not valid, maybe not CDRW?\n"); 2021 + return 1; 2022 + } 2023 + 2024 + st = (buf[6] >> 3) & 0x7; /* disc sub-type */ 2025 + 2026 + sp = buf[16] & 0xf; /* max speed from ATIP A1 field */ 2027 + 2028 + /* Info from cdrecord */ 2029 + switch (st) { 2030 + case 0: /* standard speed */ 2031 + *speed = clv_to_speed[sp]; 2032 + break; 2033 + case 1: /* high speed */ 2034 + *speed = hs_clv_to_speed[sp]; 2035 + break; 2036 + case 2: /* ultra high speed */ 2037 + *speed = us_clv_to_speed[sp]; 2038 + break; 2039 + default: 2040 + pkt_notice(pd, "unknown disc sub-type %d\n", st); 2041 + return 1; 2042 + } 2043 + if (*speed) { 2044 + pkt_info(pd, "maximum media speed: %d\n", *speed); 2045 + return 0; 2046 + } else { 2047 + pkt_notice(pd, "unknown speed %d for sub-type %d\n", sp, st); 2048 + return 1; 2049 + } 2050 + } 2051 + 2052 + static noinline_for_stack int pkt_perform_opc(struct pktcdvd_device *pd) 2053 + { 2054 + struct packet_command cgc; 2055 + struct scsi_sense_hdr sshdr; 2056 + int ret; 2057 + 2058 + pkt_dbg(2, pd, "Performing OPC\n"); 2059 + 2060 + init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE); 2061 + cgc.sshdr = &sshdr; 2062 + cgc.timeout = 60*HZ; 2063 + cgc.cmd[0] = GPCMD_SEND_OPC; 2064 + cgc.cmd[1] = 1; 2065 + ret = pkt_generic_packet(pd, &cgc); 2066 + if (ret) 2067 + pkt_dump_sense(pd, &cgc); 2068 + return ret; 2069 + } 2070 + 2071 + static int pkt_open_write(struct pktcdvd_device *pd) 2072 + { 2073 + int ret; 2074 + unsigned int write_speed, media_write_speed, read_speed; 2075 + 2076 + ret = pkt_probe_settings(pd); 2077 + if (ret) { 2078 + pkt_dbg(2, pd, "failed probe\n"); 2079 + return ret; 2080 + } 2081 + 2082 + ret = pkt_set_write_settings(pd); 2083 + if (ret) { 2084 + pkt_dbg(1, pd, "failed saving write settings\n"); 2085 + return -EIO; 2086 + } 2087 + 2088 + pkt_write_caching(pd, USE_WCACHING); 2089 + 2090 + ret = pkt_get_max_speed(pd, &write_speed); 2091 + if (ret) 2092 + write_speed = 16 * 177; 2093 + switch (pd->mmc3_profile) { 2094 + case 0x13: /* DVD-RW */ 2095 + case 0x1a: /* DVD+RW */ 2096 + case 0x12: /* DVD-RAM */ 2097 + pkt_dbg(1, pd, "write speed %ukB/s\n", write_speed); 2098 + break; 2099 + default: 2100 + ret = pkt_media_speed(pd, &media_write_speed); 2101 + if (ret) 2102 + media_write_speed = 16; 2103 + write_speed = min(write_speed, media_write_speed * 177); 2104 + pkt_dbg(1, pd, "write speed %ux\n", write_speed / 176); 2105 + break; 2106 + } 2107 + read_speed = write_speed; 2108 + 2109 + ret = pkt_set_speed(pd, write_speed, read_speed); 2110 + if (ret) { 2111 + pkt_dbg(1, pd, "couldn't set write speed\n"); 2112 + return -EIO; 2113 + } 2114 + pd->write_speed = write_speed; 2115 + pd->read_speed = read_speed; 2116 + 2117 + ret = pkt_perform_opc(pd); 2118 + if (ret) { 2119 + pkt_dbg(1, pd, "Optimum Power Calibration failed\n"); 2120 + } 2121 + 2122 + return 0; 2123 + } 2124 + 2125 + /* 2126 + * called at open time. 2127 + */ 2128 + static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write) 2129 + { 2130 + int ret; 2131 + long lba; 2132 + struct request_queue *q; 2133 + struct block_device *bdev; 2134 + 2135 + /* 2136 + * We need to re-open the cdrom device without O_NONBLOCK to be able 2137 + * to read/write from/to it. It is already opened in O_NONBLOCK mode 2138 + * so open should not fail. 2139 + */ 2140 + bdev = blkdev_get_by_dev(pd->bdev->bd_dev, FMODE_READ | FMODE_EXCL, pd); 2141 + if (IS_ERR(bdev)) { 2142 + ret = PTR_ERR(bdev); 2143 + goto out; 2144 + } 2145 + 2146 + ret = pkt_get_last_written(pd, &lba); 2147 + if (ret) { 2148 + pkt_err(pd, "pkt_get_last_written failed\n"); 2149 + goto out_putdev; 2150 + } 2151 + 2152 + set_capacity(pd->disk, lba << 2); 2153 + set_capacity_and_notify(pd->bdev->bd_disk, lba << 2); 2154 + 2155 + q = bdev_get_queue(pd->bdev); 2156 + if (write) { 2157 + ret = pkt_open_write(pd); 2158 + if (ret) 2159 + goto out_putdev; 2160 + /* 2161 + * Some CDRW drives can not handle writes larger than one packet, 2162 + * even if the size is a multiple of the packet size. 2163 + */ 2164 + blk_queue_max_hw_sectors(q, pd->settings.size); 2165 + set_bit(PACKET_WRITABLE, &pd->flags); 2166 + } else { 2167 + pkt_set_speed(pd, MAX_SPEED, MAX_SPEED); 2168 + clear_bit(PACKET_WRITABLE, &pd->flags); 2169 + } 2170 + 2171 + ret = pkt_set_segment_merging(pd, q); 2172 + if (ret) 2173 + goto out_putdev; 2174 + 2175 + if (write) { 2176 + if (!pkt_grow_pktlist(pd, CONFIG_CDROM_PKTCDVD_BUFFERS)) { 2177 + pkt_err(pd, "not enough memory for buffers\n"); 2178 + ret = -ENOMEM; 2179 + goto out_putdev; 2180 + } 2181 + pkt_info(pd, "%lukB available on disc\n", lba << 1); 2182 + } 2183 + 2184 + return 0; 2185 + 2186 + out_putdev: 2187 + blkdev_put(bdev, FMODE_READ | FMODE_EXCL); 2188 + out: 2189 + return ret; 2190 + } 2191 + 2192 + /* 2193 + * called when the device is closed. makes sure that the device flushes 2194 + * the internal cache before we close. 2195 + */ 2196 + static void pkt_release_dev(struct pktcdvd_device *pd, int flush) 2197 + { 2198 + if (flush && pkt_flush_cache(pd)) 2199 + pkt_dbg(1, pd, "not flushing cache\n"); 2200 + 2201 + pkt_lock_door(pd, 0); 2202 + 2203 + pkt_set_speed(pd, MAX_SPEED, MAX_SPEED); 2204 + blkdev_put(pd->bdev, FMODE_READ | FMODE_EXCL); 2205 + 2206 + pkt_shrink_pktlist(pd); 2207 + } 2208 + 2209 + static struct pktcdvd_device *pkt_find_dev_from_minor(unsigned int dev_minor) 2210 + { 2211 + if (dev_minor >= MAX_WRITERS) 2212 + return NULL; 2213 + 2214 + dev_minor = array_index_nospec(dev_minor, MAX_WRITERS); 2215 + return pkt_devs[dev_minor]; 2216 + } 2217 + 2218 + static int pkt_open(struct block_device *bdev, fmode_t mode) 2219 + { 2220 + struct pktcdvd_device *pd = NULL; 2221 + int ret; 2222 + 2223 + mutex_lock(&pktcdvd_mutex); 2224 + mutex_lock(&ctl_mutex); 2225 + pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev)); 2226 + if (!pd) { 2227 + ret = -ENODEV; 2228 + goto out; 2229 + } 2230 + BUG_ON(pd->refcnt < 0); 2231 + 2232 + pd->refcnt++; 2233 + if (pd->refcnt > 1) { 2234 + if ((mode & FMODE_WRITE) && 2235 + !test_bit(PACKET_WRITABLE, &pd->flags)) { 2236 + ret = -EBUSY; 2237 + goto out_dec; 2238 + } 2239 + } else { 2240 + ret = pkt_open_dev(pd, mode & FMODE_WRITE); 2241 + if (ret) 2242 + goto out_dec; 2243 + /* 2244 + * needed here as well, since ext2 (among others) may change 2245 + * the blocksize at mount time 2246 + */ 2247 + set_blocksize(bdev, CD_FRAMESIZE); 2248 + } 2249 + 2250 + mutex_unlock(&ctl_mutex); 2251 + mutex_unlock(&pktcdvd_mutex); 2252 + return 0; 2253 + 2254 + out_dec: 2255 + pd->refcnt--; 2256 + out: 2257 + mutex_unlock(&ctl_mutex); 2258 + mutex_unlock(&pktcdvd_mutex); 2259 + return ret; 2260 + } 2261 + 2262 + static void pkt_close(struct gendisk *disk, fmode_t mode) 2263 + { 2264 + struct pktcdvd_device *pd = disk->private_data; 2265 + 2266 + mutex_lock(&pktcdvd_mutex); 2267 + mutex_lock(&ctl_mutex); 2268 + pd->refcnt--; 2269 + BUG_ON(pd->refcnt < 0); 2270 + if (pd->refcnt == 0) { 2271 + int flush = test_bit(PACKET_WRITABLE, &pd->flags); 2272 + pkt_release_dev(pd, flush); 2273 + } 2274 + mutex_unlock(&ctl_mutex); 2275 + mutex_unlock(&pktcdvd_mutex); 2276 + } 2277 + 2278 + 2279 + static void pkt_end_io_read_cloned(struct bio *bio) 2280 + { 2281 + struct packet_stacked_data *psd = bio->bi_private; 2282 + struct pktcdvd_device *pd = psd->pd; 2283 + 2284 + psd->bio->bi_status = bio->bi_status; 2285 + bio_put(bio); 2286 + bio_endio(psd->bio); 2287 + mempool_free(psd, &psd_pool); 2288 + pkt_bio_finished(pd); 2289 + } 2290 + 2291 + static void pkt_make_request_read(struct pktcdvd_device *pd, struct bio *bio) 2292 + { 2293 + struct bio *cloned_bio = 2294 + bio_alloc_clone(pd->bdev, bio, GFP_NOIO, &pkt_bio_set); 2295 + struct packet_stacked_data *psd = mempool_alloc(&psd_pool, GFP_NOIO); 2296 + 2297 + psd->pd = pd; 2298 + psd->bio = bio; 2299 + cloned_bio->bi_private = psd; 2300 + cloned_bio->bi_end_io = pkt_end_io_read_cloned; 2301 + pd->stats.secs_r += bio_sectors(bio); 2302 + pkt_queue_bio(pd, cloned_bio); 2303 + } 2304 + 2305 + static void pkt_make_request_write(struct request_queue *q, struct bio *bio) 2306 + { 2307 + struct pktcdvd_device *pd = q->queuedata; 2308 + sector_t zone; 2309 + struct packet_data *pkt; 2310 + int was_empty, blocked_bio; 2311 + struct pkt_rb_node *node; 2312 + 2313 + zone = get_zone(bio->bi_iter.bi_sector, pd); 2314 + 2315 + /* 2316 + * If we find a matching packet in state WAITING or READ_WAIT, we can 2317 + * just append this bio to that packet. 2318 + */ 2319 + spin_lock(&pd->cdrw.active_list_lock); 2320 + blocked_bio = 0; 2321 + list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) { 2322 + if (pkt->sector == zone) { 2323 + spin_lock(&pkt->lock); 2324 + if ((pkt->state == PACKET_WAITING_STATE) || 2325 + (pkt->state == PACKET_READ_WAIT_STATE)) { 2326 + bio_list_add(&pkt->orig_bios, bio); 2327 + pkt->write_size += 2328 + bio->bi_iter.bi_size / CD_FRAMESIZE; 2329 + if ((pkt->write_size >= pkt->frames) && 2330 + (pkt->state == PACKET_WAITING_STATE)) { 2331 + atomic_inc(&pkt->run_sm); 2332 + wake_up(&pd->wqueue); 2333 + } 2334 + spin_unlock(&pkt->lock); 2335 + spin_unlock(&pd->cdrw.active_list_lock); 2336 + return; 2337 + } else { 2338 + blocked_bio = 1; 2339 + } 2340 + spin_unlock(&pkt->lock); 2341 + } 2342 + } 2343 + spin_unlock(&pd->cdrw.active_list_lock); 2344 + 2345 + /* 2346 + * Test if there is enough room left in the bio work queue 2347 + * (queue size >= congestion on mark). 2348 + * If not, wait till the work queue size is below the congestion off mark. 2349 + */ 2350 + spin_lock(&pd->lock); 2351 + if (pd->write_congestion_on > 0 2352 + && pd->bio_queue_size >= pd->write_congestion_on) { 2353 + struct wait_bit_queue_entry wqe; 2354 + 2355 + init_wait_var_entry(&wqe, &pd->congested, 0); 2356 + for (;;) { 2357 + prepare_to_wait_event(__var_waitqueue(&pd->congested), 2358 + &wqe.wq_entry, 2359 + TASK_UNINTERRUPTIBLE); 2360 + if (pd->bio_queue_size <= pd->write_congestion_off) 2361 + break; 2362 + pd->congested = true; 2363 + spin_unlock(&pd->lock); 2364 + schedule(); 2365 + spin_lock(&pd->lock); 2366 + } 2367 + } 2368 + spin_unlock(&pd->lock); 2369 + 2370 + /* 2371 + * No matching packet found. Store the bio in the work queue. 2372 + */ 2373 + node = mempool_alloc(&pd->rb_pool, GFP_NOIO); 2374 + node->bio = bio; 2375 + spin_lock(&pd->lock); 2376 + BUG_ON(pd->bio_queue_size < 0); 2377 + was_empty = (pd->bio_queue_size == 0); 2378 + pkt_rbtree_insert(pd, node); 2379 + spin_unlock(&pd->lock); 2380 + 2381 + /* 2382 + * Wake up the worker thread. 2383 + */ 2384 + atomic_set(&pd->scan_queue, 1); 2385 + if (was_empty) { 2386 + /* This wake_up is required for correct operation */ 2387 + wake_up(&pd->wqueue); 2388 + } else if (!list_empty(&pd->cdrw.pkt_free_list) && !blocked_bio) { 2389 + /* 2390 + * This wake up is not required for correct operation, 2391 + * but improves performance in some cases. 2392 + */ 2393 + wake_up(&pd->wqueue); 2394 + } 2395 + } 2396 + 2397 + static void pkt_submit_bio(struct bio *bio) 2398 + { 2399 + struct pktcdvd_device *pd = bio->bi_bdev->bd_disk->queue->queuedata; 2400 + struct bio *split; 2401 + 2402 + bio = bio_split_to_limits(bio); 2403 + 2404 + pkt_dbg(2, pd, "start = %6llx stop = %6llx\n", 2405 + (unsigned long long)bio->bi_iter.bi_sector, 2406 + (unsigned long long)bio_end_sector(bio)); 2407 + 2408 + /* 2409 + * Clone READ bios so we can have our own bi_end_io callback. 2410 + */ 2411 + if (bio_data_dir(bio) == READ) { 2412 + pkt_make_request_read(pd, bio); 2413 + return; 2414 + } 2415 + 2416 + if (!test_bit(PACKET_WRITABLE, &pd->flags)) { 2417 + pkt_notice(pd, "WRITE for ro device (%llu)\n", 2418 + (unsigned long long)bio->bi_iter.bi_sector); 2419 + goto end_io; 2420 + } 2421 + 2422 + if (!bio->bi_iter.bi_size || (bio->bi_iter.bi_size % CD_FRAMESIZE)) { 2423 + pkt_err(pd, "wrong bio size\n"); 2424 + goto end_io; 2425 + } 2426 + 2427 + do { 2428 + sector_t zone = get_zone(bio->bi_iter.bi_sector, pd); 2429 + sector_t last_zone = get_zone(bio_end_sector(bio) - 1, pd); 2430 + 2431 + if (last_zone != zone) { 2432 + BUG_ON(last_zone != zone + pd->settings.size); 2433 + 2434 + split = bio_split(bio, last_zone - 2435 + bio->bi_iter.bi_sector, 2436 + GFP_NOIO, &pkt_bio_set); 2437 + bio_chain(split, bio); 2438 + } else { 2439 + split = bio; 2440 + } 2441 + 2442 + pkt_make_request_write(bio->bi_bdev->bd_disk->queue, split); 2443 + } while (split != bio); 2444 + 2445 + return; 2446 + end_io: 2447 + bio_io_error(bio); 2448 + } 2449 + 2450 + static void pkt_init_queue(struct pktcdvd_device *pd) 2451 + { 2452 + struct request_queue *q = pd->disk->queue; 2453 + 2454 + blk_queue_logical_block_size(q, CD_FRAMESIZE); 2455 + blk_queue_max_hw_sectors(q, PACKET_MAX_SECTORS); 2456 + q->queuedata = pd; 2457 + } 2458 + 2459 + static int pkt_seq_show(struct seq_file *m, void *p) 2460 + { 2461 + struct pktcdvd_device *pd = m->private; 2462 + char *msg; 2463 + int states[PACKET_NUM_STATES]; 2464 + 2465 + seq_printf(m, "Writer %s mapped to %pg:\n", pd->name, pd->bdev); 2466 + 2467 + seq_printf(m, "\nSettings:\n"); 2468 + seq_printf(m, "\tpacket size:\t\t%dkB\n", pd->settings.size / 2); 2469 + 2470 + if (pd->settings.write_type == 0) 2471 + msg = "Packet"; 2472 + else 2473 + msg = "Unknown"; 2474 + seq_printf(m, "\twrite type:\t\t%s\n", msg); 2475 + 2476 + seq_printf(m, "\tpacket type:\t\t%s\n", pd->settings.fp ? "Fixed" : "Variable"); 2477 + seq_printf(m, "\tlink loss:\t\t%d\n", pd->settings.link_loss); 2478 + 2479 + seq_printf(m, "\ttrack mode:\t\t%d\n", pd->settings.track_mode); 2480 + 2481 + if (pd->settings.block_mode == PACKET_BLOCK_MODE1) 2482 + msg = "Mode 1"; 2483 + else if (pd->settings.block_mode == PACKET_BLOCK_MODE2) 2484 + msg = "Mode 2"; 2485 + else 2486 + msg = "Unknown"; 2487 + seq_printf(m, "\tblock mode:\t\t%s\n", msg); 2488 + 2489 + seq_printf(m, "\nStatistics:\n"); 2490 + seq_printf(m, "\tpackets started:\t%lu\n", pd->stats.pkt_started); 2491 + seq_printf(m, "\tpackets ended:\t\t%lu\n", pd->stats.pkt_ended); 2492 + seq_printf(m, "\twritten:\t\t%lukB\n", pd->stats.secs_w >> 1); 2493 + seq_printf(m, "\tread gather:\t\t%lukB\n", pd->stats.secs_rg >> 1); 2494 + seq_printf(m, "\tread:\t\t\t%lukB\n", pd->stats.secs_r >> 1); 2495 + 2496 + seq_printf(m, "\nMisc:\n"); 2497 + seq_printf(m, "\treference count:\t%d\n", pd->refcnt); 2498 + seq_printf(m, "\tflags:\t\t\t0x%lx\n", pd->flags); 2499 + seq_printf(m, "\tread speed:\t\t%ukB/s\n", pd->read_speed); 2500 + seq_printf(m, "\twrite speed:\t\t%ukB/s\n", pd->write_speed); 2501 + seq_printf(m, "\tstart offset:\t\t%lu\n", pd->offset); 2502 + seq_printf(m, "\tmode page offset:\t%u\n", pd->mode_offset); 2503 + 2504 + seq_printf(m, "\nQueue state:\n"); 2505 + seq_printf(m, "\tbios queued:\t\t%d\n", pd->bio_queue_size); 2506 + seq_printf(m, "\tbios pending:\t\t%d\n", atomic_read(&pd->cdrw.pending_bios)); 2507 + seq_printf(m, "\tcurrent sector:\t\t0x%llx\n", (unsigned long long)pd->current_sector); 2508 + 2509 + pkt_count_states(pd, states); 2510 + seq_printf(m, "\tstate:\t\t\ti:%d ow:%d rw:%d ww:%d rec:%d fin:%d\n", 2511 + states[0], states[1], states[2], states[3], states[4], states[5]); 2512 + 2513 + seq_printf(m, "\twrite congestion marks:\toff=%d on=%d\n", 2514 + pd->write_congestion_off, 2515 + pd->write_congestion_on); 2516 + return 0; 2517 + } 2518 + 2519 + static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) 2520 + { 2521 + int i; 2522 + struct block_device *bdev; 2523 + struct scsi_device *sdev; 2524 + 2525 + if (pd->pkt_dev == dev) { 2526 + pkt_err(pd, "recursive setup not allowed\n"); 2527 + return -EBUSY; 2528 + } 2529 + for (i = 0; i < MAX_WRITERS; i++) { 2530 + struct pktcdvd_device *pd2 = pkt_devs[i]; 2531 + if (!pd2) 2532 + continue; 2533 + if (pd2->bdev->bd_dev == dev) { 2534 + pkt_err(pd, "%pg already setup\n", pd2->bdev); 2535 + return -EBUSY; 2536 + } 2537 + if (pd2->pkt_dev == dev) { 2538 + pkt_err(pd, "can't chain pktcdvd devices\n"); 2539 + return -EBUSY; 2540 + } 2541 + } 2542 + 2543 + bdev = blkdev_get_by_dev(dev, FMODE_READ | FMODE_NDELAY, NULL); 2544 + if (IS_ERR(bdev)) 2545 + return PTR_ERR(bdev); 2546 + sdev = scsi_device_from_queue(bdev->bd_disk->queue); 2547 + if (!sdev) { 2548 + blkdev_put(bdev, FMODE_READ | FMODE_NDELAY); 2549 + return -EINVAL; 2550 + } 2551 + put_device(&sdev->sdev_gendev); 2552 + 2553 + /* This is safe, since we have a reference from open(). */ 2554 + __module_get(THIS_MODULE); 2555 + 2556 + pd->bdev = bdev; 2557 + set_blocksize(bdev, CD_FRAMESIZE); 2558 + 2559 + pkt_init_queue(pd); 2560 + 2561 + atomic_set(&pd->cdrw.pending_bios, 0); 2562 + pd->cdrw.thread = kthread_run(kcdrwd, pd, "%s", pd->name); 2563 + if (IS_ERR(pd->cdrw.thread)) { 2564 + pkt_err(pd, "can't start kernel thread\n"); 2565 + goto out_mem; 2566 + } 2567 + 2568 + proc_create_single_data(pd->name, 0, pkt_proc, pkt_seq_show, pd); 2569 + pkt_dbg(1, pd, "writer mapped to %pg\n", bdev); 2570 + return 0; 2571 + 2572 + out_mem: 2573 + blkdev_put(bdev, FMODE_READ | FMODE_NDELAY); 2574 + /* This is safe: open() is still holding a reference. */ 2575 + module_put(THIS_MODULE); 2576 + return -ENOMEM; 2577 + } 2578 + 2579 + static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) 2580 + { 2581 + struct pktcdvd_device *pd = bdev->bd_disk->private_data; 2582 + int ret; 2583 + 2584 + pkt_dbg(2, pd, "cmd %x, dev %d:%d\n", 2585 + cmd, MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev)); 2586 + 2587 + mutex_lock(&pktcdvd_mutex); 2588 + switch (cmd) { 2589 + case CDROMEJECT: 2590 + /* 2591 + * The door gets locked when the device is opened, so we 2592 + * have to unlock it or else the eject command fails. 2593 + */ 2594 + if (pd->refcnt == 1) 2595 + pkt_lock_door(pd, 0); 2596 + fallthrough; 2597 + /* 2598 + * forward selected CDROM ioctls to CD-ROM, for UDF 2599 + */ 2600 + case CDROMMULTISESSION: 2601 + case CDROMREADTOCENTRY: 2602 + case CDROM_LAST_WRITTEN: 2603 + case CDROM_SEND_PACKET: 2604 + case SCSI_IOCTL_SEND_COMMAND: 2605 + if (!bdev->bd_disk->fops->ioctl) 2606 + ret = -ENOTTY; 2607 + else 2608 + ret = bdev->bd_disk->fops->ioctl(bdev, mode, cmd, arg); 2609 + break; 2610 + default: 2611 + pkt_dbg(2, pd, "Unknown ioctl (%x)\n", cmd); 2612 + ret = -ENOTTY; 2613 + } 2614 + mutex_unlock(&pktcdvd_mutex); 2615 + 2616 + return ret; 2617 + } 2618 + 2619 + static unsigned int pkt_check_events(struct gendisk *disk, 2620 + unsigned int clearing) 2621 + { 2622 + struct pktcdvd_device *pd = disk->private_data; 2623 + struct gendisk *attached_disk; 2624 + 2625 + if (!pd) 2626 + return 0; 2627 + if (!pd->bdev) 2628 + return 0; 2629 + attached_disk = pd->bdev->bd_disk; 2630 + if (!attached_disk || !attached_disk->fops->check_events) 2631 + return 0; 2632 + return attached_disk->fops->check_events(attached_disk, clearing); 2633 + } 2634 + 2635 + static char *pkt_devnode(struct gendisk *disk, umode_t *mode) 2636 + { 2637 + return kasprintf(GFP_KERNEL, "pktcdvd/%s", disk->disk_name); 2638 + } 2639 + 2640 + static const struct block_device_operations pktcdvd_ops = { 2641 + .owner = THIS_MODULE, 2642 + .submit_bio = pkt_submit_bio, 2643 + .open = pkt_open, 2644 + .release = pkt_close, 2645 + .ioctl = pkt_ioctl, 2646 + .compat_ioctl = blkdev_compat_ptr_ioctl, 2647 + .check_events = pkt_check_events, 2648 + .devnode = pkt_devnode, 2649 + }; 2650 + 2651 + /* 2652 + * Set up mapping from pktcdvd device to CD-ROM device. 2653 + */ 2654 + static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev) 2655 + { 2656 + int idx; 2657 + int ret = -ENOMEM; 2658 + struct pktcdvd_device *pd; 2659 + struct gendisk *disk; 2660 + 2661 + mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 2662 + 2663 + for (idx = 0; idx < MAX_WRITERS; idx++) 2664 + if (!pkt_devs[idx]) 2665 + break; 2666 + if (idx == MAX_WRITERS) { 2667 + pr_err("max %d writers supported\n", MAX_WRITERS); 2668 + ret = -EBUSY; 2669 + goto out_mutex; 2670 + } 2671 + 2672 + pd = kzalloc(sizeof(struct pktcdvd_device), GFP_KERNEL); 2673 + if (!pd) 2674 + goto out_mutex; 2675 + 2676 + ret = mempool_init_kmalloc_pool(&pd->rb_pool, PKT_RB_POOL_SIZE, 2677 + sizeof(struct pkt_rb_node)); 2678 + if (ret) 2679 + goto out_mem; 2680 + 2681 + INIT_LIST_HEAD(&pd->cdrw.pkt_free_list); 2682 + INIT_LIST_HEAD(&pd->cdrw.pkt_active_list); 2683 + spin_lock_init(&pd->cdrw.active_list_lock); 2684 + 2685 + spin_lock_init(&pd->lock); 2686 + spin_lock_init(&pd->iosched.lock); 2687 + bio_list_init(&pd->iosched.read_queue); 2688 + bio_list_init(&pd->iosched.write_queue); 2689 + sprintf(pd->name, DRIVER_NAME"%d", idx); 2690 + init_waitqueue_head(&pd->wqueue); 2691 + pd->bio_queue = RB_ROOT; 2692 + 2693 + pd->write_congestion_on = write_congestion_on; 2694 + pd->write_congestion_off = write_congestion_off; 2695 + 2696 + ret = -ENOMEM; 2697 + disk = blk_alloc_disk(NUMA_NO_NODE); 2698 + if (!disk) 2699 + goto out_mem; 2700 + pd->disk = disk; 2701 + disk->major = pktdev_major; 2702 + disk->first_minor = idx; 2703 + disk->minors = 1; 2704 + disk->fops = &pktcdvd_ops; 2705 + disk->flags = GENHD_FL_REMOVABLE | GENHD_FL_NO_PART; 2706 + strcpy(disk->disk_name, pd->name); 2707 + disk->private_data = pd; 2708 + 2709 + pd->pkt_dev = MKDEV(pktdev_major, idx); 2710 + ret = pkt_new_dev(pd, dev); 2711 + if (ret) 2712 + goto out_mem2; 2713 + 2714 + /* inherit events of the host device */ 2715 + disk->events = pd->bdev->bd_disk->events; 2716 + 2717 + ret = add_disk(disk); 2718 + if (ret) 2719 + goto out_mem2; 2720 + 2721 + pkt_sysfs_dev_new(pd); 2722 + pkt_debugfs_dev_new(pd); 2723 + 2724 + pkt_devs[idx] = pd; 2725 + if (pkt_dev) 2726 + *pkt_dev = pd->pkt_dev; 2727 + 2728 + mutex_unlock(&ctl_mutex); 2729 + return 0; 2730 + 2731 + out_mem2: 2732 + put_disk(disk); 2733 + out_mem: 2734 + mempool_exit(&pd->rb_pool); 2735 + kfree(pd); 2736 + out_mutex: 2737 + mutex_unlock(&ctl_mutex); 2738 + pr_err("setup of pktcdvd device failed\n"); 2739 + return ret; 2740 + } 2741 + 2742 + /* 2743 + * Tear down mapping from pktcdvd device to CD-ROM device. 2744 + */ 2745 + static int pkt_remove_dev(dev_t pkt_dev) 2746 + { 2747 + struct pktcdvd_device *pd; 2748 + int idx; 2749 + int ret = 0; 2750 + 2751 + mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 2752 + 2753 + for (idx = 0; idx < MAX_WRITERS; idx++) { 2754 + pd = pkt_devs[idx]; 2755 + if (pd && (pd->pkt_dev == pkt_dev)) 2756 + break; 2757 + } 2758 + if (idx == MAX_WRITERS) { 2759 + pr_debug("dev not setup\n"); 2760 + ret = -ENXIO; 2761 + goto out; 2762 + } 2763 + 2764 + if (pd->refcnt > 0) { 2765 + ret = -EBUSY; 2766 + goto out; 2767 + } 2768 + if (!IS_ERR(pd->cdrw.thread)) 2769 + kthread_stop(pd->cdrw.thread); 2770 + 2771 + pkt_devs[idx] = NULL; 2772 + 2773 + pkt_debugfs_dev_remove(pd); 2774 + pkt_sysfs_dev_remove(pd); 2775 + 2776 + blkdev_put(pd->bdev, FMODE_READ | FMODE_NDELAY); 2777 + 2778 + remove_proc_entry(pd->name, pkt_proc); 2779 + pkt_dbg(1, pd, "writer unmapped\n"); 2780 + 2781 + del_gendisk(pd->disk); 2782 + put_disk(pd->disk); 2783 + 2784 + mempool_exit(&pd->rb_pool); 2785 + kfree(pd); 2786 + 2787 + /* This is safe: open() is still holding a reference. */ 2788 + module_put(THIS_MODULE); 2789 + 2790 + out: 2791 + mutex_unlock(&ctl_mutex); 2792 + return ret; 2793 + } 2794 + 2795 + static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd) 2796 + { 2797 + struct pktcdvd_device *pd; 2798 + 2799 + mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 2800 + 2801 + pd = pkt_find_dev_from_minor(ctrl_cmd->dev_index); 2802 + if (pd) { 2803 + ctrl_cmd->dev = new_encode_dev(pd->bdev->bd_dev); 2804 + ctrl_cmd->pkt_dev = new_encode_dev(pd->pkt_dev); 2805 + } else { 2806 + ctrl_cmd->dev = 0; 2807 + ctrl_cmd->pkt_dev = 0; 2808 + } 2809 + ctrl_cmd->num_devices = MAX_WRITERS; 2810 + 2811 + mutex_unlock(&ctl_mutex); 2812 + } 2813 + 2814 + static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 2815 + { 2816 + void __user *argp = (void __user *)arg; 2817 + struct pkt_ctrl_command ctrl_cmd; 2818 + int ret = 0; 2819 + dev_t pkt_dev = 0; 2820 + 2821 + if (cmd != PACKET_CTRL_CMD) 2822 + return -ENOTTY; 2823 + 2824 + if (copy_from_user(&ctrl_cmd, argp, sizeof(struct pkt_ctrl_command))) 2825 + return -EFAULT; 2826 + 2827 + switch (ctrl_cmd.command) { 2828 + case PKT_CTRL_CMD_SETUP: 2829 + if (!capable(CAP_SYS_ADMIN)) 2830 + return -EPERM; 2831 + ret = pkt_setup_dev(new_decode_dev(ctrl_cmd.dev), &pkt_dev); 2832 + ctrl_cmd.pkt_dev = new_encode_dev(pkt_dev); 2833 + break; 2834 + case PKT_CTRL_CMD_TEARDOWN: 2835 + if (!capable(CAP_SYS_ADMIN)) 2836 + return -EPERM; 2837 + ret = pkt_remove_dev(new_decode_dev(ctrl_cmd.pkt_dev)); 2838 + break; 2839 + case PKT_CTRL_CMD_STATUS: 2840 + pkt_get_status(&ctrl_cmd); 2841 + break; 2842 + default: 2843 + return -ENOTTY; 2844 + } 2845 + 2846 + if (copy_to_user(argp, &ctrl_cmd, sizeof(struct pkt_ctrl_command))) 2847 + return -EFAULT; 2848 + return ret; 2849 + } 2850 + 2851 + #ifdef CONFIG_COMPAT 2852 + static long pkt_ctl_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 2853 + { 2854 + return pkt_ctl_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); 2855 + } 2856 + #endif 2857 + 2858 + static const struct file_operations pkt_ctl_fops = { 2859 + .open = nonseekable_open, 2860 + .unlocked_ioctl = pkt_ctl_ioctl, 2861 + #ifdef CONFIG_COMPAT 2862 + .compat_ioctl = pkt_ctl_compat_ioctl, 2863 + #endif 2864 + .owner = THIS_MODULE, 2865 + .llseek = no_llseek, 2866 + }; 2867 + 2868 + static struct miscdevice pkt_misc = { 2869 + .minor = MISC_DYNAMIC_MINOR, 2870 + .name = DRIVER_NAME, 2871 + .nodename = "pktcdvd/control", 2872 + .fops = &pkt_ctl_fops 2873 + }; 2874 + 2875 + static int __init pkt_init(void) 2876 + { 2877 + int ret; 2878 + 2879 + mutex_init(&ctl_mutex); 2880 + 2881 + ret = mempool_init_kmalloc_pool(&psd_pool, PSD_POOL_SIZE, 2882 + sizeof(struct packet_stacked_data)); 2883 + if (ret) 2884 + return ret; 2885 + ret = bioset_init(&pkt_bio_set, BIO_POOL_SIZE, 0, 0); 2886 + if (ret) { 2887 + mempool_exit(&psd_pool); 2888 + return ret; 2889 + } 2890 + 2891 + ret = register_blkdev(pktdev_major, DRIVER_NAME); 2892 + if (ret < 0) { 2893 + pr_err("unable to register block device\n"); 2894 + goto out2; 2895 + } 2896 + if (!pktdev_major) 2897 + pktdev_major = ret; 2898 + 2899 + ret = pkt_sysfs_init(); 2900 + if (ret) 2901 + goto out; 2902 + 2903 + pkt_debugfs_init(); 2904 + 2905 + ret = misc_register(&pkt_misc); 2906 + if (ret) { 2907 + pr_err("unable to register misc device\n"); 2908 + goto out_misc; 2909 + } 2910 + 2911 + pkt_proc = proc_mkdir("driver/"DRIVER_NAME, NULL); 2912 + 2913 + return 0; 2914 + 2915 + out_misc: 2916 + pkt_debugfs_cleanup(); 2917 + pkt_sysfs_cleanup(); 2918 + out: 2919 + unregister_blkdev(pktdev_major, DRIVER_NAME); 2920 + out2: 2921 + mempool_exit(&psd_pool); 2922 + bioset_exit(&pkt_bio_set); 2923 + return ret; 2924 + } 2925 + 2926 + static void __exit pkt_exit(void) 2927 + { 2928 + remove_proc_entry("driver/"DRIVER_NAME, NULL); 2929 + misc_deregister(&pkt_misc); 2930 + 2931 + pkt_debugfs_cleanup(); 2932 + pkt_sysfs_cleanup(); 2933 + 2934 + unregister_blkdev(pktdev_major, DRIVER_NAME); 2935 + mempool_exit(&psd_pool); 2936 + bioset_exit(&pkt_bio_set); 2937 + } 2938 + 2939 + MODULE_DESCRIPTION("Packet writing layer for CD/DVD drives"); 2940 + MODULE_AUTHOR("Jens Axboe <axboe@suse.de>"); 2941 + MODULE_LICENSE("GPL"); 2942 + 2943 + module_init(pkt_init); 2944 + module_exit(pkt_exit);
+2
drivers/block/ps3vram.c
··· 587 587 dev_dbg(&dev->core, "%s\n", __func__); 588 588 589 589 bio = bio_split_to_limits(bio); 590 + if (!bio) 591 + return; 590 592 591 593 spin_lock_irq(&priv->lock); 592 594 busy = !bio_list_empty(&priv->list);
+3
drivers/block/ublk_drv.c
··· 1992 1992 struct ublksrv_ctrl_cmd *header = (struct ublksrv_ctrl_cmd *)cmd->cmd; 1993 1993 int ret = -EINVAL; 1994 1994 1995 + if (issue_flags & IO_URING_F_NONBLOCK) 1996 + return -EAGAIN; 1997 + 1995 1998 ublk_ctrl_cmd_dump(cmd); 1996 1999 1997 2000 if (!(issue_flags & IO_URING_F_SQE128))
+20 -15
drivers/block/virtio_blk.c
··· 315 315 virtqueue_notify(vq->vq); 316 316 } 317 317 318 + static blk_status_t virtblk_fail_to_queue(struct request *req, int rc) 319 + { 320 + virtblk_cleanup_cmd(req); 321 + switch (rc) { 322 + case -ENOSPC: 323 + return BLK_STS_DEV_RESOURCE; 324 + case -ENOMEM: 325 + return BLK_STS_RESOURCE; 326 + default: 327 + return BLK_STS_IOERR; 328 + } 329 + } 330 + 318 331 static blk_status_t virtblk_prep_rq(struct blk_mq_hw_ctx *hctx, 319 332 struct virtio_blk *vblk, 320 333 struct request *req, 321 334 struct virtblk_req *vbr) 322 335 { 323 336 blk_status_t status; 337 + int num; 324 338 325 339 status = virtblk_setup_cmd(vblk->vdev, req, vbr); 326 340 if (unlikely(status)) 327 341 return status; 328 342 329 - vbr->sg_table.nents = virtblk_map_data(hctx, req, vbr); 330 - if (unlikely(vbr->sg_table.nents < 0)) { 331 - virtblk_cleanup_cmd(req); 332 - return BLK_STS_RESOURCE; 333 - } 343 + num = virtblk_map_data(hctx, req, vbr); 344 + if (unlikely(num < 0)) 345 + return virtblk_fail_to_queue(req, -ENOMEM); 346 + vbr->sg_table.nents = num; 334 347 335 348 blk_mq_start_request(req); 336 349 ··· 377 364 blk_mq_stop_hw_queue(hctx); 378 365 spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags); 379 366 virtblk_unmap_data(req, vbr); 380 - virtblk_cleanup_cmd(req); 381 - switch (err) { 382 - case -ENOSPC: 383 - return BLK_STS_DEV_RESOURCE; 384 - case -ENOMEM: 385 - return BLK_STS_RESOURCE; 386 - default: 387 - return BLK_STS_IOERR; 388 - } 367 + return virtblk_fail_to_queue(req, err); 389 368 } 390 369 391 370 if (bd->last && virtqueue_kick_prepare(vblk->vqs[qid].vq)) ··· 996 991 blk_queue_max_segments(q, sg_elems); 997 992 998 993 /* No real sector limit. */ 999 - blk_queue_max_hw_sectors(q, -1U); 994 + blk_queue_max_hw_sectors(q, UINT_MAX); 1000 995 1001 996 max_size = virtio_max_dma_size(vdev); 1002 997
+3 -1
drivers/char/tpm/tpm-interface.c
··· 412 412 } 413 413 414 414 suspended: 415 - return rc; 415 + if (rc) 416 + dev_err(dev, "Ignoring error %d while suspending\n", rc); 417 + return 0; 416 418 } 417 419 EXPORT_SYMBOL_GPL(tpm_pm_suspend); 418 420
+1 -1
drivers/crypto/caam/blob_gen.c
··· 104 104 } 105 105 106 106 ctrlpriv = dev_get_drvdata(jrdev->parent); 107 - moo = FIELD_GET(CSTA_MOO, ioread32(&ctrlpriv->ctrl->perfmon.status)); 107 + moo = FIELD_GET(CSTA_MOO, rd_reg32(&ctrlpriv->ctrl->perfmon.status)); 108 108 if (moo != CSTA_MOO_SECURE && moo != CSTA_MOO_TRUSTED) 109 109 dev_warn(jrdev, 110 110 "using insecure test key, enable HAB to use unique device key!\n");
+2 -1
drivers/crypto/virtio/virtio_crypto_skcipher_algs.c
··· 239 239 pr_err("virtio_crypto: Close session failed status: %u, session_id: 0x%llx\n", 240 240 ctrl_status->status, destroy_session->session_id); 241 241 242 - return -EINVAL; 242 + err = -EINVAL; 243 + goto out; 243 244 } 244 245 245 246 err = 0;
+2 -5
drivers/dma-buf/dma-buf-sysfs-stats.c
··· 168 168 kset_unregister(dma_buf_stats_kset); 169 169 } 170 170 171 - int dma_buf_stats_setup(struct dma_buf *dmabuf) 171 + int dma_buf_stats_setup(struct dma_buf *dmabuf, struct file *file) 172 172 { 173 173 struct dma_buf_sysfs_entry *sysfs_entry; 174 174 int ret; 175 - 176 - if (!dmabuf || !dmabuf->file) 177 - return -EINVAL; 178 175 179 176 if (!dmabuf->exp_name) { 180 177 pr_err("exporter name must not be empty if stats needed\n"); ··· 189 192 190 193 /* create the directory for buffer stats */ 191 194 ret = kobject_init_and_add(&sysfs_entry->kobj, &dma_buf_ktype, NULL, 192 - "%lu", file_inode(dmabuf->file)->i_ino); 195 + "%lu", file_inode(file)->i_ino); 193 196 if (ret) 194 197 goto err_sysfs_dmabuf; 195 198
+2 -2
drivers/dma-buf/dma-buf-sysfs-stats.h
··· 13 13 int dma_buf_init_sysfs_statistics(void); 14 14 void dma_buf_uninit_sysfs_statistics(void); 15 15 16 - int dma_buf_stats_setup(struct dma_buf *dmabuf); 16 + int dma_buf_stats_setup(struct dma_buf *dmabuf, struct file *file); 17 17 18 18 void dma_buf_stats_teardown(struct dma_buf *dmabuf); 19 19 #else ··· 25 25 26 26 static inline void dma_buf_uninit_sysfs_statistics(void) {} 27 27 28 - static inline int dma_buf_stats_setup(struct dma_buf *dmabuf) 28 + static inline int dma_buf_stats_setup(struct dma_buf *dmabuf, struct file *file) 29 29 { 30 30 return 0; 31 31 }
+38 -44
drivers/dma-buf/dma-buf.c
··· 95 95 return -EINVAL; 96 96 97 97 dmabuf = file->private_data; 98 - 99 - mutex_lock(&db_list.lock); 100 - list_del(&dmabuf->list_node); 101 - mutex_unlock(&db_list.lock); 98 + if (dmabuf) { 99 + mutex_lock(&db_list.lock); 100 + list_del(&dmabuf->list_node); 101 + mutex_unlock(&db_list.lock); 102 + } 102 103 103 104 return 0; 104 105 } ··· 529 528 return file->f_op == &dma_buf_fops; 530 529 } 531 530 532 - static struct file *dma_buf_getfile(struct dma_buf *dmabuf, int flags) 531 + static struct file *dma_buf_getfile(size_t size, int flags) 533 532 { 534 533 static atomic64_t dmabuf_inode = ATOMIC64_INIT(0); 535 - struct file *file; 536 534 struct inode *inode = alloc_anon_inode(dma_buf_mnt->mnt_sb); 535 + struct file *file; 537 536 538 537 if (IS_ERR(inode)) 539 538 return ERR_CAST(inode); 540 539 541 - inode->i_size = dmabuf->size; 542 - inode_set_bytes(inode, dmabuf->size); 540 + inode->i_size = size; 541 + inode_set_bytes(inode, size); 543 542 544 543 /* 545 544 * The ->i_ino acquired from get_next_ino() is not unique thus ··· 553 552 flags, &dma_buf_fops); 554 553 if (IS_ERR(file)) 555 554 goto err_alloc_file; 556 - file->private_data = dmabuf; 557 - file->f_path.dentry->d_fsdata = dmabuf; 558 555 559 556 return file; 560 557 ··· 618 619 size_t alloc_size = sizeof(struct dma_buf); 619 620 int ret; 620 621 621 - if (!exp_info->resv) 622 - alloc_size += sizeof(struct dma_resv); 623 - else 624 - /* prevent &dma_buf[1] == dma_buf->resv */ 625 - alloc_size += 1; 626 - 627 - if (WARN_ON(!exp_info->priv 628 - || !exp_info->ops 629 - || !exp_info->ops->map_dma_buf 630 - || !exp_info->ops->unmap_dma_buf 631 - || !exp_info->ops->release)) { 622 + if (WARN_ON(!exp_info->priv || !exp_info->ops 623 + || !exp_info->ops->map_dma_buf 624 + || !exp_info->ops->unmap_dma_buf 625 + || !exp_info->ops->release)) 632 626 return ERR_PTR(-EINVAL); 633 - } 634 627 635 628 if (WARN_ON(exp_info->ops->cache_sgt_mapping && 636 629 (exp_info->ops->pin || exp_info->ops->unpin))) ··· 634 643 if (!try_module_get(exp_info->owner)) 635 644 return ERR_PTR(-ENOENT); 636 645 646 + file = dma_buf_getfile(exp_info->size, exp_info->flags); 647 + if (IS_ERR(file)) { 648 + ret = PTR_ERR(file); 649 + goto err_module; 650 + } 651 + 652 + if (!exp_info->resv) 653 + alloc_size += sizeof(struct dma_resv); 654 + else 655 + /* prevent &dma_buf[1] == dma_buf->resv */ 656 + alloc_size += 1; 637 657 dmabuf = kzalloc(alloc_size, GFP_KERNEL); 638 658 if (!dmabuf) { 639 659 ret = -ENOMEM; 640 - goto err_module; 660 + goto err_file; 641 661 } 642 662 643 663 dmabuf->priv = exp_info->priv; ··· 660 658 init_waitqueue_head(&dmabuf->poll); 661 659 dmabuf->cb_in.poll = dmabuf->cb_out.poll = &dmabuf->poll; 662 660 dmabuf->cb_in.active = dmabuf->cb_out.active = 0; 661 + INIT_LIST_HEAD(&dmabuf->attachments); 663 662 664 663 if (!resv) { 665 - resv = (struct dma_resv *)&dmabuf[1]; 666 - dma_resv_init(resv); 664 + dmabuf->resv = (struct dma_resv *)&dmabuf[1]; 665 + dma_resv_init(dmabuf->resv); 666 + } else { 667 + dmabuf->resv = resv; 667 668 } 668 - dmabuf->resv = resv; 669 669 670 - file = dma_buf_getfile(dmabuf, exp_info->flags); 671 - if (IS_ERR(file)) { 672 - ret = PTR_ERR(file); 670 + ret = dma_buf_stats_setup(dmabuf, file); 671 + if (ret) 673 672 goto err_dmabuf; 674 - } 675 673 674 + file->private_data = dmabuf; 675 + file->f_path.dentry->d_fsdata = dmabuf; 676 676 dmabuf->file = file; 677 - 678 - INIT_LIST_HEAD(&dmabuf->attachments); 679 677 680 678 mutex_lock(&db_list.lock); 681 679 list_add(&dmabuf->list_node, &db_list.head); 682 680 mutex_unlock(&db_list.lock); 683 681 684 - ret = dma_buf_stats_setup(dmabuf); 685 - if (ret) 686 - goto err_sysfs; 687 - 688 682 return dmabuf; 689 683 690 - err_sysfs: 691 - /* 692 - * Set file->f_path.dentry->d_fsdata to NULL so that when 693 - * dma_buf_release() gets invoked by dentry_ops, it exits 694 - * early before calling the release() dma_buf op. 695 - */ 696 - file->f_path.dentry->d_fsdata = NULL; 697 - fput(file); 698 684 err_dmabuf: 685 + if (!resv) 686 + dma_resv_fini(dmabuf->resv); 699 687 kfree(dmabuf); 688 + err_file: 689 + fput(file); 700 690 err_module: 701 691 module_put(exp_info->owner); 702 692 return ERR_PTR(ret);
+14 -9
drivers/gpio/gpio-eic-sprd.c
··· 91 91 92 92 struct sprd_eic { 93 93 struct gpio_chip chip; 94 - struct irq_chip intc; 95 94 void __iomem *base[SPRD_EIC_MAX_BANK]; 96 95 enum sprd_eic_type type; 97 96 spinlock_t lock; ··· 254 255 default: 255 256 dev_err(chip->parent, "Unsupported EIC type.\n"); 256 257 } 258 + 259 + gpiochip_disable_irq(chip, offset); 257 260 } 258 261 259 262 static void sprd_eic_irq_unmask(struct irq_data *data) ··· 263 262 struct gpio_chip *chip = irq_data_get_irq_chip_data(data); 264 263 struct sprd_eic *sprd_eic = gpiochip_get_data(chip); 265 264 u32 offset = irqd_to_hwirq(data); 265 + 266 + gpiochip_enable_irq(chip, offset); 266 267 267 268 switch (sprd_eic->type) { 268 269 case SPRD_EIC_DEBOUNCE: ··· 567 564 chained_irq_exit(ic, desc); 568 565 } 569 566 567 + static const struct irq_chip sprd_eic_irq = { 568 + .name = "sprd-eic", 569 + .irq_ack = sprd_eic_irq_ack, 570 + .irq_mask = sprd_eic_irq_mask, 571 + .irq_unmask = sprd_eic_irq_unmask, 572 + .irq_set_type = sprd_eic_irq_set_type, 573 + .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE, 574 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 575 + }; 570 576 static int sprd_eic_probe(struct platform_device *pdev) 571 577 { 572 578 const struct sprd_eic_variant_data *pdata; ··· 638 626 break; 639 627 } 640 628 641 - sprd_eic->intc.name = dev_name(&pdev->dev); 642 - sprd_eic->intc.irq_ack = sprd_eic_irq_ack; 643 - sprd_eic->intc.irq_mask = sprd_eic_irq_mask; 644 - sprd_eic->intc.irq_unmask = sprd_eic_irq_unmask; 645 - sprd_eic->intc.irq_set_type = sprd_eic_irq_set_type; 646 - sprd_eic->intc.flags = IRQCHIP_SKIP_SET_WAKE; 647 - 648 629 irq = &sprd_eic->chip.irq; 649 - irq->chip = &sprd_eic->intc; 630 + gpio_irq_chip_set_chip(irq, &sprd_eic_irq); 650 631 irq->handler = handle_bad_irq; 651 632 irq->default_type = IRQ_TYPE_NONE; 652 633 irq->parent_handler = sprd_eic_irq_handler;
+3
drivers/gpio/gpio-pca953x.c
··· 474 474 case PCAL6524_DEBOUNCE: 475 475 pinctrl = ((reg & PCAL_PINCTRL_MASK) >> 1) + 0x1c; 476 476 break; 477 + default: 478 + pinctrl = 0; 479 + break; 477 480 } 478 481 479 482 return pinctrl + addr + (off / BANK_SZ);
+18 -11
drivers/gpio/gpio-pmic-eic-sprd.c
··· 47 47 /** 48 48 * struct sprd_pmic_eic - PMIC EIC controller 49 49 * @chip: the gpio_chip structure. 50 - * @intc: the irq_chip structure. 51 50 * @map: the regmap from the parent device. 52 51 * @offset: the EIC controller's offset address of the PMIC. 53 52 * @reg: the array to cache the EIC registers. ··· 55 56 */ 56 57 struct sprd_pmic_eic { 57 58 struct gpio_chip chip; 58 - struct irq_chip intc; 59 59 struct regmap *map; 60 60 u32 offset; 61 61 u8 reg[CACHE_NR_REGS]; ··· 149 151 { 150 152 struct gpio_chip *chip = irq_data_get_irq_chip_data(data); 151 153 struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip); 154 + u32 offset = irqd_to_hwirq(data); 152 155 153 156 pmic_eic->reg[REG_IE] = 0; 154 157 pmic_eic->reg[REG_TRIG] = 0; 158 + 159 + gpiochip_disable_irq(chip, offset); 155 160 } 156 161 157 162 static void sprd_pmic_eic_irq_unmask(struct irq_data *data) 158 163 { 159 164 struct gpio_chip *chip = irq_data_get_irq_chip_data(data); 160 165 struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip); 166 + u32 offset = irqd_to_hwirq(data); 167 + 168 + gpiochip_enable_irq(chip, offset); 161 169 162 170 pmic_eic->reg[REG_IE] = 1; 163 171 pmic_eic->reg[REG_TRIG] = 1; ··· 296 292 return IRQ_HANDLED; 297 293 } 298 294 295 + static const struct irq_chip pmic_eic_irq_chip = { 296 + .name = "sprd-pmic-eic", 297 + .irq_mask = sprd_pmic_eic_irq_mask, 298 + .irq_unmask = sprd_pmic_eic_irq_unmask, 299 + .irq_set_type = sprd_pmic_eic_irq_set_type, 300 + .irq_bus_lock = sprd_pmic_eic_bus_lock, 301 + .irq_bus_sync_unlock = sprd_pmic_eic_bus_sync_unlock, 302 + .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE, 303 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 304 + }; 305 + 299 306 static int sprd_pmic_eic_probe(struct platform_device *pdev) 300 307 { 301 308 struct gpio_irq_chip *irq; ··· 353 338 pmic_eic->chip.set = sprd_pmic_eic_set; 354 339 pmic_eic->chip.get = sprd_pmic_eic_get; 355 340 356 - pmic_eic->intc.name = dev_name(&pdev->dev); 357 - pmic_eic->intc.irq_mask = sprd_pmic_eic_irq_mask; 358 - pmic_eic->intc.irq_unmask = sprd_pmic_eic_irq_unmask; 359 - pmic_eic->intc.irq_set_type = sprd_pmic_eic_irq_set_type; 360 - pmic_eic->intc.irq_bus_lock = sprd_pmic_eic_bus_lock; 361 - pmic_eic->intc.irq_bus_sync_unlock = sprd_pmic_eic_bus_sync_unlock; 362 - pmic_eic->intc.flags = IRQCHIP_SKIP_SET_WAKE; 363 - 364 341 irq = &pmic_eic->chip.irq; 365 - irq->chip = &pmic_eic->intc; 342 + gpio_irq_chip_set_chip(irq, &pmic_eic_irq_chip); 366 343 irq->threaded = true; 367 344 368 345 ret = devm_gpiochip_add_data(&pdev->dev, &pmic_eic->chip, pmic_eic);
+1
drivers/gpio/gpio-sifive.c
··· 215 215 return -ENODEV; 216 216 } 217 217 parent = irq_find_host(irq_parent); 218 + of_node_put(irq_parent); 218 219 if (!parent) { 219 220 dev_err(dev, "no IRQ parent domain\n"); 220 221 return -ENODEV;
+6 -3
drivers/gpio/gpio-sprd.c
··· 120 120 u32 offset = irqd_to_hwirq(data); 121 121 122 122 sprd_gpio_update(chip, offset, SPRD_GPIO_IE, 0); 123 + gpiochip_disable_irq(chip, offset); 123 124 } 124 125 125 126 static void sprd_gpio_irq_ack(struct irq_data *data) ··· 137 136 u32 offset = irqd_to_hwirq(data); 138 137 139 138 sprd_gpio_update(chip, offset, SPRD_GPIO_IE, 1); 139 + gpiochip_enable_irq(chip, offset); 140 140 } 141 141 142 142 static int sprd_gpio_irq_set_type(struct irq_data *data, ··· 207 205 chained_irq_exit(ic, desc); 208 206 } 209 207 210 - static struct irq_chip sprd_gpio_irqchip = { 208 + static const struct irq_chip sprd_gpio_irqchip = { 211 209 .name = "sprd-gpio", 212 210 .irq_ack = sprd_gpio_irq_ack, 213 211 .irq_mask = sprd_gpio_irq_mask, 214 212 .irq_unmask = sprd_gpio_irq_unmask, 215 213 .irq_set_type = sprd_gpio_irq_set_type, 216 - .flags = IRQCHIP_SKIP_SET_WAKE, 214 + .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE, 215 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 217 216 }; 218 217 219 218 static int sprd_gpio_probe(struct platform_device *pdev) ··· 248 245 sprd_gpio->chip.direction_output = sprd_gpio_direction_output; 249 246 250 247 irq = &sprd_gpio->chip.irq; 251 - irq->chip = &sprd_gpio_irqchip; 248 + gpio_irq_chip_set_chip(irq, &sprd_gpio_irqchip); 252 249 irq->handler = handle_bad_irq; 253 250 irq->default_type = IRQ_TYPE_NONE; 254 251 irq->parent_handler = sprd_gpio_irq_handler;
+1 -1
drivers/gpio/gpiolib.c
··· 3905 3905 const char *label, 3906 3906 bool platform_lookup_allowed) 3907 3907 { 3908 + unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT; 3908 3909 struct gpio_desc *desc = ERR_PTR(-ENOENT); 3909 - unsigned long lookupflags; 3910 3910 int ret; 3911 3911 3912 3912 if (!IS_ERR_OR_NULL(fwnode))
+1
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 195 195 extern uint amdgpu_smu_memory_pool_size; 196 196 extern int amdgpu_smu_pptable_id; 197 197 extern uint amdgpu_dc_feature_mask; 198 + extern uint amdgpu_freesync_vid_mode; 198 199 extern uint amdgpu_dc_debug_mask; 199 200 extern uint amdgpu_dc_visual_confirm; 200 201 extern uint amdgpu_dm_abm_level;
+27
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
··· 181 181 int amdgpu_noretry = -1; 182 182 int amdgpu_force_asic_type = -1; 183 183 int amdgpu_tmz = -1; /* auto */ 184 + uint amdgpu_freesync_vid_mode; 184 185 int amdgpu_reset_method = -1; /* auto */ 185 186 int amdgpu_num_kcq = -1; 186 187 int amdgpu_smartshift_bias; ··· 879 878 */ 880 879 MODULE_PARM_DESC(tmz, "Enable TMZ feature (-1 = auto (default), 0 = off, 1 = on)"); 881 880 module_param_named(tmz, amdgpu_tmz, int, 0444); 881 + 882 + /** 883 + * DOC: freesync_video (uint) 884 + * Enable the optimization to adjust front porch timing to achieve seamless 885 + * mode change experience when setting a freesync supported mode for which full 886 + * modeset is not needed. 887 + * 888 + * The Display Core will add a set of modes derived from the base FreeSync 889 + * video mode into the corresponding connector's mode list based on commonly 890 + * used refresh rates and VRR range of the connected display, when users enable 891 + * this feature. From the userspace perspective, they can see a seamless mode 892 + * change experience when the change between different refresh rates under the 893 + * same resolution. Additionally, userspace applications such as Video playback 894 + * can read this modeset list and change the refresh rate based on the video 895 + * frame rate. Finally, the userspace can also derive an appropriate mode for a 896 + * particular refresh rate based on the FreeSync Mode and add it to the 897 + * connector's mode list. 898 + * 899 + * Note: This is an experimental feature. 900 + * 901 + * The default value: 0 (off). 902 + */ 903 + MODULE_PARM_DESC( 904 + freesync_video, 905 + "Enable freesync modesetting optimization feature (0 = off (default), 1 = on)"); 906 + module_param_named(freesync_video, amdgpu_freesync_vid_mode, uint, 0444); 882 907 883 908 /** 884 909 * DOC: reset_method (int)
+1 -1
drivers/gpu/drm/amd/amdkfd/kfd_topology.c
··· 801 801 802 802 p2plink->attr.name = "properties"; 803 803 p2plink->attr.mode = KFD_SYSFS_FILE_MODE; 804 - sysfs_attr_init(&iolink->attr); 804 + sysfs_attr_init(&p2plink->attr); 805 805 ret = sysfs_create_file(p2plink->kobj, &p2plink->attr); 806 806 if (ret < 0) 807 807 return ret;
+11 -5
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 4361 4361 amdgpu_set_panel_orientation(&aconnector->base); 4362 4362 } 4363 4363 4364 + /* If we didn't find a panel, notify the acpi video detection */ 4365 + if (dm->adev->flags & AMD_IS_APU && dm->num_of_edps == 0) 4366 + acpi_video_report_nolcd(); 4367 + 4364 4368 /* Software is initialized. Now we can register interrupt handlers. */ 4365 4369 switch (adev->asic_type) { 4366 4370 #if defined(CONFIG_DRM_AMD_DC_SI) ··· 5835 5831 */ 5836 5832 DRM_DEBUG_DRIVER("No preferred mode found\n"); 5837 5833 } else { 5838 - recalculate_timing = is_freesync_video_mode(&mode, aconnector); 5834 + recalculate_timing = amdgpu_freesync_vid_mode && 5835 + is_freesync_video_mode(&mode, aconnector); 5839 5836 if (recalculate_timing) { 5840 5837 freesync_mode = get_highest_refresh_rate_mode(aconnector, false); 5841 5838 drm_mode_copy(&saved_mode, &mode); ··· 6987 6982 struct amdgpu_dm_connector *amdgpu_dm_connector = 6988 6983 to_amdgpu_dm_connector(connector); 6989 6984 6990 - if (!edid) 6985 + if (!(amdgpu_freesync_vid_mode && edid)) 6991 6986 return; 6992 6987 6993 6988 if (amdgpu_dm_connector->max_vfreq - amdgpu_dm_connector->min_vfreq > 10) ··· 8851 8846 * TODO: Refactor this function to allow this check to work 8852 8847 * in all conditions. 8853 8848 */ 8854 - if (dm_new_crtc_state->stream && 8849 + if (amdgpu_freesync_vid_mode && 8850 + dm_new_crtc_state->stream && 8855 8851 is_timing_unchanged_for_freesync(new_crtc_state, old_crtc_state)) 8856 8852 goto skip_modeset; 8857 8853 ··· 8887 8881 if (!dm_old_crtc_state->stream) 8888 8882 goto skip_modeset; 8889 8883 8890 - if (dm_new_crtc_state->stream && 8884 + if (amdgpu_freesync_vid_mode && dm_new_crtc_state->stream && 8891 8885 is_timing_unchanged_for_freesync(new_crtc_state, 8892 8886 old_crtc_state)) { 8893 8887 new_crtc_state->mode_changed = false; ··· 8899 8893 set_freesync_fixed_config(dm_new_crtc_state); 8900 8894 8901 8895 goto skip_modeset; 8902 - } else if (aconnector && 8896 + } else if (amdgpu_freesync_vid_mode && aconnector && 8903 8897 is_freesync_video_mode(&new_crtc_state->mode, 8904 8898 aconnector)) { 8905 8899 struct drm_display_mode *high_mode;
+3 -3
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_util_32.c
··· 6257 6257 double SwathSizePerSurfaceC[DC__NUM_DPP__MAX]; 6258 6258 bool NotEnoughDETSwathFillLatencyHiding = false; 6259 6259 6260 - /* calculate sum of single swath size for all pipes in bytes*/ 6260 + /* calculate sum of single swath size for all pipes in bytes */ 6261 6261 for (k = 0; k < NumberOfActiveSurfaces; k++) { 6262 - SwathSizePerSurfaceY[k] += SwathHeightY[k] * SwathWidthY[k] * BytePerPixelInDETY[k] * NumOfDPP[k]; 6262 + SwathSizePerSurfaceY[k] = SwathHeightY[k] * SwathWidthY[k] * BytePerPixelInDETY[k] * NumOfDPP[k]; 6263 6263 6264 6264 if (SwathHeightC[k] != 0) 6265 - SwathSizePerSurfaceC[k] += SwathHeightC[k] * SwathWidthC[k] * BytePerPixelInDETC[k] * NumOfDPP[k]; 6265 + SwathSizePerSurfaceC[k] = SwathHeightC[k] * SwathWidthC[k] * BytePerPixelInDETC[k] * NumOfDPP[k]; 6266 6266 else 6267 6267 SwathSizePerSurfaceC[k] = 0; 6268 6268
+91 -3
drivers/gpu/drm/i915/display/intel_dsi_vbt.c
··· 41 41 42 42 #include "i915_drv.h" 43 43 #include "i915_reg.h" 44 + #include "intel_de.h" 44 45 #include "intel_display_types.h" 45 46 #include "intel_dsi.h" 46 47 #include "intel_dsi_vbt.h" 48 + #include "intel_gmbus_regs.h" 47 49 #include "vlv_dsi.h" 48 50 #include "vlv_dsi_regs.h" 49 51 #include "vlv_sideband.h" ··· 379 377 drm_dbg_kms(&dev_priv->drm, "Skipping ICL GPIO element execution\n"); 380 378 } 381 379 380 + enum { 381 + MIPI_RESET_1 = 0, 382 + MIPI_AVDD_EN_1, 383 + MIPI_BKLT_EN_1, 384 + MIPI_AVEE_EN_1, 385 + MIPI_VIO_EN_1, 386 + MIPI_RESET_2, 387 + MIPI_AVDD_EN_2, 388 + MIPI_BKLT_EN_2, 389 + MIPI_AVEE_EN_2, 390 + MIPI_VIO_EN_2, 391 + }; 392 + 393 + static void icl_native_gpio_set_value(struct drm_i915_private *dev_priv, 394 + int gpio, bool value) 395 + { 396 + int index; 397 + 398 + if (drm_WARN_ON(&dev_priv->drm, DISPLAY_VER(dev_priv) == 11 && gpio >= MIPI_RESET_2)) 399 + return; 400 + 401 + switch (gpio) { 402 + case MIPI_RESET_1: 403 + case MIPI_RESET_2: 404 + index = gpio == MIPI_RESET_1 ? HPD_PORT_A : HPD_PORT_B; 405 + 406 + /* 407 + * Disable HPD to set the pin to output, and set output 408 + * value. The HPD pin should not be enabled for DSI anyway, 409 + * assuming the board design and VBT are sane, and the pin isn't 410 + * used by a non-DSI encoder. 411 + * 412 + * The locking protects against concurrent SHOTPLUG_CTL_DDI 413 + * modifications in irq setup and handling. 414 + */ 415 + spin_lock_irq(&dev_priv->irq_lock); 416 + intel_de_rmw(dev_priv, SHOTPLUG_CTL_DDI, 417 + SHOTPLUG_CTL_DDI_HPD_ENABLE(index) | 418 + SHOTPLUG_CTL_DDI_HPD_OUTPUT_DATA(index), 419 + value ? SHOTPLUG_CTL_DDI_HPD_OUTPUT_DATA(index) : 0); 420 + spin_unlock_irq(&dev_priv->irq_lock); 421 + break; 422 + case MIPI_AVDD_EN_1: 423 + case MIPI_AVDD_EN_2: 424 + index = gpio == MIPI_AVDD_EN_1 ? 0 : 1; 425 + 426 + intel_de_rmw(dev_priv, PP_CONTROL(index), PANEL_POWER_ON, 427 + value ? PANEL_POWER_ON : 0); 428 + break; 429 + case MIPI_BKLT_EN_1: 430 + case MIPI_BKLT_EN_2: 431 + index = gpio == MIPI_BKLT_EN_1 ? 0 : 1; 432 + 433 + intel_de_rmw(dev_priv, PP_CONTROL(index), EDP_BLC_ENABLE, 434 + value ? EDP_BLC_ENABLE : 0); 435 + break; 436 + case MIPI_AVEE_EN_1: 437 + case MIPI_AVEE_EN_2: 438 + index = gpio == MIPI_AVEE_EN_1 ? 1 : 2; 439 + 440 + intel_de_rmw(dev_priv, GPIO(dev_priv, index), 441 + GPIO_CLOCK_VAL_OUT, 442 + GPIO_CLOCK_DIR_MASK | GPIO_CLOCK_DIR_OUT | 443 + GPIO_CLOCK_VAL_MASK | (value ? GPIO_CLOCK_VAL_OUT : 0)); 444 + break; 445 + case MIPI_VIO_EN_1: 446 + case MIPI_VIO_EN_2: 447 + index = gpio == MIPI_VIO_EN_1 ? 1 : 2; 448 + 449 + intel_de_rmw(dev_priv, GPIO(dev_priv, index), 450 + GPIO_DATA_VAL_OUT, 451 + GPIO_DATA_DIR_MASK | GPIO_DATA_DIR_OUT | 452 + GPIO_DATA_VAL_MASK | (value ? GPIO_DATA_VAL_OUT : 0)); 453 + break; 454 + default: 455 + MISSING_CASE(gpio); 456 + } 457 + } 458 + 382 459 static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) 383 460 { 384 461 struct drm_device *dev = intel_dsi->base.base.dev; ··· 465 384 struct intel_connector *connector = intel_dsi->attached_connector; 466 385 u8 gpio_source, gpio_index = 0, gpio_number; 467 386 bool value; 468 - 469 - drm_dbg_kms(&dev_priv->drm, "\n"); 387 + bool native = DISPLAY_VER(dev_priv) >= 11; 470 388 471 389 if (connector->panel.vbt.dsi.seq_version >= 3) 472 390 gpio_index = *data++; ··· 478 398 else 479 399 gpio_source = 0; 480 400 401 + if (connector->panel.vbt.dsi.seq_version >= 4 && *data & BIT(1)) 402 + native = false; 403 + 481 404 /* pull up/down */ 482 405 value = *data++ & 1; 483 406 484 - if (DISPLAY_VER(dev_priv) >= 11) 407 + drm_dbg_kms(&dev_priv->drm, "GPIO index %u, number %u, source %u, native %s, set to %s\n", 408 + gpio_index, gpio_number, gpio_source, str_yes_no(native), str_on_off(value)); 409 + 410 + if (native) 411 + icl_native_gpio_set_value(dev_priv, gpio_number, value); 412 + else if (DISPLAY_VER(dev_priv) >= 11) 485 413 icl_exec_gpio(connector, gpio_source, gpio_index, value); 486 414 else if (IS_VALLEYVIEW(dev_priv)) 487 415 vlv_exec_gpio(connector, gpio_source, gpio_number, value);
+48 -11
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
··· 730 730 bool unpinned; 731 731 732 732 /* 733 - * Attempt to pin all of the buffers into the GTT. 734 - * This is done in 2 phases: 733 + * We have one more buffers that we couldn't bind, which could be due to 734 + * various reasons. To resolve this we have 4 passes, with every next 735 + * level turning the screws tighter: 735 736 * 736 - * 1. Unbind all objects that do not match the GTT constraints for 737 - * the execbuffer (fenceable, mappable, alignment etc). 738 - * 2. Bind new objects. 737 + * 0. Unbind all objects that do not match the GTT constraints for the 738 + * execbuffer (fenceable, mappable, alignment etc). Bind all new 739 + * objects. This avoids unnecessary unbinding of later objects in order 740 + * to make room for the earlier objects *unless* we need to defragment. 739 741 * 740 - * This avoid unnecessary unbinding of later objects in order to make 741 - * room for the earlier objects *unless* we need to defragment. 742 + * 1. Reorder the buffers, where objects with the most restrictive 743 + * placement requirements go first (ignoring fixed location buffers for 744 + * now). For example, objects needing the mappable aperture (the first 745 + * 256M of GTT), should go first vs objects that can be placed just 746 + * about anywhere. Repeat the previous pass. 742 747 * 743 - * Defragmenting is skipped if all objects are pinned at a fixed location. 748 + * 2. Consider buffers that are pinned at a fixed location. Also try to 749 + * evict the entire VM this time, leaving only objects that we were 750 + * unable to lock. Try again to bind the buffers. (still using the new 751 + * buffer order). 752 + * 753 + * 3. We likely have object lock contention for one or more stubborn 754 + * objects in the VM, for which we need to evict to make forward 755 + * progress (perhaps we are fighting the shrinker?). When evicting the 756 + * VM this time around, anything that we can't lock we now track using 757 + * the busy_bo, using the full lock (after dropping the vm->mutex to 758 + * prevent deadlocks), instead of trylock. We then continue to evict the 759 + * VM, this time with the stubborn object locked, which we can now 760 + * hopefully unbind (if still bound in the VM). Repeat until the VM is 761 + * evicted. Finally we should be able bind everything. 744 762 */ 745 - for (pass = 0; pass <= 2; pass++) { 763 + for (pass = 0; pass <= 3; pass++) { 746 764 int pin_flags = PIN_USER | PIN_VALIDATE; 747 765 748 766 if (pass == 0) 749 767 pin_flags |= PIN_NONBLOCK; 750 768 751 769 if (pass >= 1) 752 - unpinned = eb_unbind(eb, pass == 2); 770 + unpinned = eb_unbind(eb, pass >= 2); 753 771 754 772 if (pass == 2) { 755 773 err = mutex_lock_interruptible(&eb->context->vm->mutex); 756 774 if (!err) { 757 - err = i915_gem_evict_vm(eb->context->vm, &eb->ww); 775 + err = i915_gem_evict_vm(eb->context->vm, &eb->ww, NULL); 758 776 mutex_unlock(&eb->context->vm->mutex); 777 + } 778 + if (err) 779 + return err; 780 + } 781 + 782 + if (pass == 3) { 783 + retry: 784 + err = mutex_lock_interruptible(&eb->context->vm->mutex); 785 + if (!err) { 786 + struct drm_i915_gem_object *busy_bo = NULL; 787 + 788 + err = i915_gem_evict_vm(eb->context->vm, &eb->ww, &busy_bo); 789 + mutex_unlock(&eb->context->vm->mutex); 790 + if (err && busy_bo) { 791 + err = i915_gem_object_lock(busy_bo, &eb->ww); 792 + i915_gem_object_put(busy_bo); 793 + if (!err) 794 + goto retry; 795 + } 759 796 } 760 797 if (err) 761 798 return err;
+1 -1
drivers/gpu/drm/i915/gem/i915_gem_mman.c
··· 369 369 if (vma == ERR_PTR(-ENOSPC)) { 370 370 ret = mutex_lock_interruptible(&ggtt->vm.mutex); 371 371 if (!ret) { 372 - ret = i915_gem_evict_vm(&ggtt->vm, &ww); 372 + ret = i915_gem_evict_vm(&ggtt->vm, &ww, NULL); 373 373 mutex_unlock(&ggtt->vm.mutex); 374 374 } 375 375 if (ret)
+7 -1
drivers/gpu/drm/i915/gt/intel_gt.c
··· 1109 1109 continue; 1110 1110 1111 1111 if (GRAPHICS_VER_FULL(i915) >= IP_VER(12, 50)) { 1112 + u32 val = BIT(engine->instance); 1113 + 1114 + if (engine->class == VIDEO_DECODE_CLASS || 1115 + engine->class == VIDEO_ENHANCEMENT_CLASS || 1116 + engine->class == COMPUTE_CLASS) 1117 + val = _MASKED_BIT_ENABLE(val); 1112 1118 intel_gt_mcr_multicast_write_fw(gt, 1113 1119 xehp_regs[engine->class], 1114 - BIT(engine->instance)); 1120 + val); 1115 1121 } else { 1116 1122 rb = get_reg_and_bit(engine, regs == gen8_regs, regs, num); 1117 1123 if (!i915_mmio_reg_offset(rb.reg))
+28 -14
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
··· 545 545 return 0; 546 546 } 547 547 548 + static int try_firmware_load(struct intel_uc_fw *uc_fw, const struct firmware **fw) 549 + { 550 + struct intel_gt *gt = __uc_fw_to_gt(uc_fw); 551 + struct device *dev = gt->i915->drm.dev; 552 + int err; 553 + 554 + err = firmware_request_nowarn(fw, uc_fw->file_selected.path, dev); 555 + 556 + if (err) 557 + return err; 558 + 559 + if ((*fw)->size > INTEL_UC_RSVD_GGTT_PER_FW) { 560 + drm_err(&gt->i915->drm, 561 + "%s firmware %s: size (%zuKB) exceeds max supported size (%uKB)\n", 562 + intel_uc_fw_type_repr(uc_fw->type), uc_fw->file_selected.path, 563 + (*fw)->size / SZ_1K, INTEL_UC_RSVD_GGTT_PER_FW / SZ_1K); 564 + 565 + /* try to find another blob to load */ 566 + release_firmware(*fw); 567 + *fw = NULL; 568 + return -ENOENT; 569 + } 570 + 571 + return 0; 572 + } 573 + 548 574 /** 549 575 * intel_uc_fw_fetch - fetch uC firmware 550 576 * @uc_fw: uC firmware ··· 584 558 struct intel_gt *gt = __uc_fw_to_gt(uc_fw); 585 559 struct drm_i915_private *i915 = gt->i915; 586 560 struct intel_uc_fw_file file_ideal; 587 - struct device *dev = i915->drm.dev; 588 561 struct drm_i915_gem_object *obj; 589 562 const struct firmware *fw = NULL; 590 563 bool old_ver = false; ··· 599 574 __force_fw_fetch_failures(uc_fw, -EINVAL); 600 575 __force_fw_fetch_failures(uc_fw, -ESTALE); 601 576 602 - err = firmware_request_nowarn(&fw, uc_fw->file_selected.path, dev); 577 + err = try_firmware_load(uc_fw, &fw); 603 578 memcpy(&file_ideal, &uc_fw->file_wanted, sizeof(file_ideal)); 604 - 605 - if (!err && fw->size > INTEL_UC_RSVD_GGTT_PER_FW) { 606 - drm_err(&i915->drm, 607 - "%s firmware %s: size (%zuKB) exceeds max supported size (%uKB)\n", 608 - intel_uc_fw_type_repr(uc_fw->type), uc_fw->file_selected.path, 609 - fw->size / SZ_1K, INTEL_UC_RSVD_GGTT_PER_FW / SZ_1K); 610 - 611 - /* try to find another blob to load */ 612 - release_firmware(fw); 613 - err = -ENOENT; 614 - } 615 579 616 580 /* Any error is terminal if overriding. Don't bother searching for older versions */ 617 581 if (err && intel_uc_fw_is_overridden(uc_fw)) ··· 622 608 break; 623 609 } 624 610 625 - err = firmware_request_nowarn(&fw, uc_fw->file_selected.path, dev); 611 + err = try_firmware_load(uc_fw, &fw); 626 612 } 627 613 628 614 if (err)
+31 -5
drivers/gpu/drm/i915/gvt/debugfs.c
··· 151 151 vgpu_scan_nonprivbb_get, vgpu_scan_nonprivbb_set, 152 152 "0x%llx\n"); 153 153 154 + static int vgpu_status_get(void *data, u64 *val) 155 + { 156 + struct intel_vgpu *vgpu = (struct intel_vgpu *)data; 157 + 158 + *val = 0; 159 + 160 + if (test_bit(INTEL_VGPU_STATUS_ATTACHED, vgpu->status)) 161 + *val |= (1 << INTEL_VGPU_STATUS_ATTACHED); 162 + if (test_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status)) 163 + *val |= (1 << INTEL_VGPU_STATUS_ACTIVE); 164 + 165 + return 0; 166 + } 167 + 168 + DEFINE_SIMPLE_ATTRIBUTE(vgpu_status_fops, vgpu_status_get, NULL, "0x%llx\n"); 169 + 154 170 /** 155 171 * intel_gvt_debugfs_add_vgpu - register debugfs entries for a vGPU 156 172 * @vgpu: a vGPU ··· 178 162 snprintf(name, 16, "vgpu%d", vgpu->id); 179 163 vgpu->debugfs = debugfs_create_dir(name, vgpu->gvt->debugfs_root); 180 164 181 - debugfs_create_bool("active", 0444, vgpu->debugfs, &vgpu->active); 182 165 debugfs_create_file("mmio_diff", 0444, vgpu->debugfs, vgpu, 183 166 &vgpu_mmio_diff_fops); 184 167 debugfs_create_file("scan_nonprivbb", 0644, vgpu->debugfs, vgpu, 185 168 &vgpu_scan_nonprivbb_fops); 169 + debugfs_create_file("status", 0644, vgpu->debugfs, vgpu, 170 + &vgpu_status_fops); 186 171 } 187 172 188 173 /** ··· 192 175 */ 193 176 void intel_gvt_debugfs_remove_vgpu(struct intel_vgpu *vgpu) 194 177 { 195 - debugfs_remove_recursive(vgpu->debugfs); 196 - vgpu->debugfs = NULL; 178 + struct intel_gvt *gvt = vgpu->gvt; 179 + struct drm_minor *minor = gvt->gt->i915->drm.primary; 180 + 181 + if (minor->debugfs_root && gvt->debugfs_root) { 182 + debugfs_remove_recursive(vgpu->debugfs); 183 + vgpu->debugfs = NULL; 184 + } 197 185 } 198 186 199 187 /** ··· 221 199 */ 222 200 void intel_gvt_debugfs_clean(struct intel_gvt *gvt) 223 201 { 224 - debugfs_remove_recursive(gvt->debugfs_root); 225 - gvt->debugfs_root = NULL; 202 + struct drm_minor *minor = gvt->gt->i915->drm.primary; 203 + 204 + if (minor->debugfs_root) { 205 + debugfs_remove_recursive(gvt->debugfs_root); 206 + gvt->debugfs_root = NULL; 207 + } 226 208 }
+2 -1
drivers/gpu/drm/i915/gvt/dmabuf.c
··· 134 134 struct list_head *pos; 135 135 struct intel_vgpu_dmabuf_obj *dmabuf_obj; 136 136 137 - if (vgpu && vgpu->active && !list_empty(&vgpu->dmabuf_obj_list_head)) { 137 + if (vgpu && test_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status) && 138 + !list_empty(&vgpu->dmabuf_obj_list_head)) { 138 139 list_for_each(pos, &vgpu->dmabuf_obj_list_head) { 139 140 dmabuf_obj = list_entry(pos, struct intel_vgpu_dmabuf_obj, list); 140 141 if (dmabuf_obj == obj) {
+15 -6
drivers/gpu/drm/i915/gvt/gtt.c
··· 55 55 int idx; 56 56 bool ret; 57 57 58 - if (!vgpu->attached) 58 + if (!test_bit(INTEL_VGPU_STATUS_ATTACHED, vgpu->status)) 59 59 return false; 60 60 61 61 idx = srcu_read_lock(&kvm->srcu); ··· 1178 1178 if (!HAS_PAGE_SIZES(vgpu->gvt->gt->i915, I915_GTT_PAGE_SIZE_2M)) 1179 1179 return 0; 1180 1180 1181 - if (!vgpu->attached) 1181 + if (!test_bit(INTEL_VGPU_STATUS_ATTACHED, vgpu->status)) 1182 1182 return -EINVAL; 1183 1183 pfn = gfn_to_pfn(vgpu->vfio_device.kvm, ops->get_pfn(entry)); 1184 1184 if (is_error_noslot_pfn(pfn)) ··· 1209 1209 for_each_shadow_entry(sub_spt, &sub_se, sub_index) { 1210 1210 ret = intel_gvt_dma_map_guest_page(vgpu, start_gfn + sub_index, 1211 1211 PAGE_SIZE, &dma_addr); 1212 - if (ret) { 1213 - ppgtt_invalidate_spt(spt); 1214 - return ret; 1215 - } 1212 + if (ret) 1213 + goto err; 1216 1214 sub_se.val64 = se->val64; 1217 1215 1218 1216 /* Copy the PAT field from PDE. */ ··· 1229 1231 ops->set_pfn(se, sub_spt->shadow_page.mfn); 1230 1232 ppgtt_set_shadow_entry(spt, se, index); 1231 1233 return 0; 1234 + err: 1235 + /* Cancel the existing addess mappings of DMA addr. */ 1236 + for_each_present_shadow_entry(sub_spt, &sub_se, sub_index) { 1237 + gvt_vdbg_mm("invalidate 4K entry\n"); 1238 + ppgtt_invalidate_pte(sub_spt, &sub_se); 1239 + } 1240 + /* Release the new allocated spt. */ 1241 + trace_spt_change(sub_spt->vgpu->id, "release", sub_spt, 1242 + sub_spt->guest_page.gfn, sub_spt->shadow_page.type); 1243 + ppgtt_free_spt(sub_spt); 1244 + return ret; 1232 1245 } 1233 1246 1234 1247 static int split_64KB_gtt_entry(struct intel_vgpu *vgpu,
+10 -5
drivers/gpu/drm/i915/gvt/gvt.h
··· 172 172 173 173 #define KVMGT_DEBUGFS_FILENAME "kvmgt_nr_cache_entries" 174 174 175 + enum { 176 + INTEL_VGPU_STATUS_ATTACHED = 0, 177 + INTEL_VGPU_STATUS_ACTIVE, 178 + INTEL_VGPU_STATUS_NR_BITS, 179 + }; 180 + 175 181 struct intel_vgpu { 176 182 struct vfio_device vfio_device; 177 183 struct intel_gvt *gvt; 178 184 struct mutex vgpu_lock; 179 185 int id; 180 - bool active; 181 - bool attached; 186 + DECLARE_BITMAP(status, INTEL_VGPU_STATUS_NR_BITS); 182 187 bool pv_notified; 183 188 bool failsafe; 184 189 unsigned int resetting_eng; ··· 472 467 473 468 #define for_each_active_vgpu(gvt, vgpu, id) \ 474 469 idr_for_each_entry((&(gvt)->vgpu_idr), (vgpu), (id)) \ 475 - for_each_if(vgpu->active) 470 + for_each_if(test_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status)) 476 471 477 472 static inline void intel_vgpu_write_pci_bar(struct intel_vgpu *vgpu, 478 473 u32 offset, u32 val, bool low) ··· 730 725 static inline int intel_gvt_read_gpa(struct intel_vgpu *vgpu, unsigned long gpa, 731 726 void *buf, unsigned long len) 732 727 { 733 - if (!vgpu->attached) 728 + if (!test_bit(INTEL_VGPU_STATUS_ATTACHED, vgpu->status)) 734 729 return -ESRCH; 735 730 return vfio_dma_rw(&vgpu->vfio_device, gpa, buf, len, false); 736 731 } ··· 748 743 static inline int intel_gvt_write_gpa(struct intel_vgpu *vgpu, 749 744 unsigned long gpa, void *buf, unsigned long len) 750 745 { 751 - if (!vgpu->attached) 746 + if (!test_bit(INTEL_VGPU_STATUS_ATTACHED, vgpu->status)) 752 747 return -ESRCH; 753 748 return vfio_dma_rw(&vgpu->vfio_device, gpa, buf, len, true); 754 749 }
+1 -1
drivers/gpu/drm/i915/gvt/interrupt.c
··· 433 433 * enabled by guest. so if msi_trigger is null, success is still 434 434 * returned and don't inject interrupt into guest. 435 435 */ 436 - if (!vgpu->attached) 436 + if (!test_bit(INTEL_VGPU_STATUS_ATTACHED, vgpu->status)) 437 437 return -ESRCH; 438 438 if (vgpu->msi_trigger && eventfd_signal(vgpu->msi_trigger, 1) != 1) 439 439 return -EFAULT;
+13 -22
drivers/gpu/drm/i915/gvt/kvmgt.c
··· 638 638 639 639 mutex_lock(&vgpu->gvt->lock); 640 640 for_each_active_vgpu(vgpu->gvt, itr, id) { 641 - if (!itr->attached) 641 + if (!test_bit(INTEL_VGPU_STATUS_ATTACHED, itr->status)) 642 642 continue; 643 643 644 644 if (vgpu->vfio_device.kvm == itr->vfio_device.kvm) { ··· 655 655 { 656 656 struct intel_vgpu *vgpu = vfio_dev_to_vgpu(vfio_dev); 657 657 658 - if (vgpu->attached) 659 - return -EEXIST; 660 - 661 658 if (!vgpu->vfio_device.kvm || 662 659 vgpu->vfio_device.kvm->mm != current->mm) { 663 660 gvt_vgpu_err("KVM is required to use Intel vGPU\n"); ··· 664 667 if (__kvmgt_vgpu_exist(vgpu)) 665 668 return -EEXIST; 666 669 667 - vgpu->attached = true; 668 - 669 670 vgpu->track_node.track_write = kvmgt_page_track_write; 670 671 vgpu->track_node.track_flush_slot = kvmgt_page_track_flush_slot; 671 672 kvm_get_kvm(vgpu->vfio_device.kvm); 672 673 kvm_page_track_register_notifier(vgpu->vfio_device.kvm, 673 674 &vgpu->track_node); 675 + 676 + set_bit(INTEL_VGPU_STATUS_ATTACHED, vgpu->status); 674 677 675 678 debugfs_create_ulong(KVMGT_DEBUGFS_FILENAME, 0444, vgpu->debugfs, 676 679 &vgpu->nr_cache_entries); ··· 695 698 { 696 699 struct intel_vgpu *vgpu = vfio_dev_to_vgpu(vfio_dev); 697 700 698 - if (!vgpu->attached) 699 - return; 700 - 701 701 intel_gvt_release_vgpu(vgpu); 702 + 703 + clear_bit(INTEL_VGPU_STATUS_ATTACHED, vgpu->status); 702 704 703 705 debugfs_remove(debugfs_lookup(KVMGT_DEBUGFS_FILENAME, vgpu->debugfs)); 704 706 ··· 714 718 vgpu->dma_addr_cache = RB_ROOT; 715 719 716 720 intel_vgpu_release_msi_eventfd_ctx(vgpu); 717 - 718 - vgpu->attached = false; 719 721 } 720 722 721 723 static u64 intel_vgpu_get_bar_addr(struct intel_vgpu *vgpu, int bar) ··· 1506 1512 { 1507 1513 struct intel_vgpu *vgpu = dev_get_drvdata(&mdev->dev); 1508 1514 1509 - if (WARN_ON_ONCE(vgpu->attached)) 1510 - return; 1511 - 1512 1515 vfio_unregister_group_dev(&vgpu->vfio_device); 1513 1516 vfio_put_device(&vgpu->vfio_device); 1514 1517 } ··· 1550 1559 struct kvm_memory_slot *slot; 1551 1560 int idx; 1552 1561 1553 - if (!info->attached) 1562 + if (!test_bit(INTEL_VGPU_STATUS_ATTACHED, info->status)) 1554 1563 return -ESRCH; 1555 1564 1556 1565 idx = srcu_read_lock(&kvm->srcu); ··· 1580 1589 struct kvm_memory_slot *slot; 1581 1590 int idx; 1582 1591 1583 - if (!info->attached) 1584 - return 0; 1592 + if (!test_bit(INTEL_VGPU_STATUS_ATTACHED, info->status)) 1593 + return -ESRCH; 1585 1594 1586 1595 idx = srcu_read_lock(&kvm->srcu); 1587 1596 slot = gfn_to_memslot(kvm, gfn); ··· 1659 1668 struct gvt_dma *entry; 1660 1669 int ret; 1661 1670 1662 - if (!vgpu->attached) 1671 + if (!test_bit(INTEL_VGPU_STATUS_ATTACHED, vgpu->status)) 1663 1672 return -EINVAL; 1664 1673 1665 1674 mutex_lock(&vgpu->cache_lock); ··· 1705 1714 struct gvt_dma *entry; 1706 1715 int ret = 0; 1707 1716 1708 - if (!vgpu->attached) 1709 - return -ENODEV; 1717 + if (!test_bit(INTEL_VGPU_STATUS_ATTACHED, vgpu->status)) 1718 + return -EINVAL; 1710 1719 1711 1720 mutex_lock(&vgpu->cache_lock); 1712 1721 entry = __gvt_cache_find_dma_addr(vgpu, dma_addr); ··· 1733 1742 { 1734 1743 struct gvt_dma *entry; 1735 1744 1736 - if (!vgpu->attached) 1745 + if (!test_bit(INTEL_VGPU_STATUS_ATTACHED, vgpu->status)) 1737 1746 return; 1738 1747 1739 1748 mutex_lock(&vgpu->cache_lock); ··· 1769 1778 idr_for_each_entry((&(gvt)->vgpu_idr), (vgpu), (id)) { 1770 1779 if (test_and_clear_bit(INTEL_GVT_REQUEST_EMULATE_VBLANK + id, 1771 1780 (void *)&gvt->service_request)) { 1772 - if (vgpu->active) 1781 + if (test_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status)) 1773 1782 intel_vgpu_emulate_vblank(vgpu); 1774 1783 } 1775 1784 }
+3 -1
drivers/gpu/drm/i915/gvt/scheduler.c
··· 695 695 696 696 if (workload->shadow_mm->type != INTEL_GVT_MM_PPGTT || 697 697 !workload->shadow_mm->ppgtt_mm.shadowed) { 698 + intel_vgpu_unpin_mm(workload->shadow_mm); 698 699 gvt_vgpu_err("workload shadow ppgtt isn't ready\n"); 699 700 return -EINVAL; 700 701 } ··· 866 865 goto out; 867 866 } 868 867 869 - if (!scheduler->current_vgpu->active || 868 + if (!test_bit(INTEL_VGPU_STATUS_ACTIVE, 869 + scheduler->current_vgpu->status) || 870 870 list_empty(workload_q_head(scheduler->current_vgpu, engine))) 871 871 goto out; 872 872
+5 -7
drivers/gpu/drm/i915/gvt/vgpu.c
··· 166 166 */ 167 167 void intel_gvt_activate_vgpu(struct intel_vgpu *vgpu) 168 168 { 169 - mutex_lock(&vgpu->vgpu_lock); 170 - vgpu->active = true; 171 - mutex_unlock(&vgpu->vgpu_lock); 169 + set_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status); 172 170 } 173 171 174 172 /** ··· 181 183 { 182 184 mutex_lock(&vgpu->vgpu_lock); 183 185 184 - vgpu->active = false; 186 + clear_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status); 185 187 186 188 if (atomic_read(&vgpu->submission.running_workload_num)) { 187 189 mutex_unlock(&vgpu->vgpu_lock); ··· 226 228 struct intel_gvt *gvt = vgpu->gvt; 227 229 struct drm_i915_private *i915 = gvt->gt->i915; 228 230 229 - drm_WARN(&i915->drm, vgpu->active, "vGPU is still active!\n"); 231 + drm_WARN(&i915->drm, test_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status), 232 + "vGPU is still active!\n"); 230 233 231 234 /* 232 235 * remove idr first so later clean can judge if need to stop ··· 284 285 if (ret) 285 286 goto out_free_vgpu; 286 287 287 - vgpu->active = false; 288 - 288 + clear_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status); 289 289 return vgpu; 290 290 291 291 out_free_vgpu:
+27 -10
drivers/gpu/drm/i915/i915_gem_evict.c
··· 416 416 * @vm: Address space to cleanse 417 417 * @ww: An optional struct i915_gem_ww_ctx. If not NULL, i915_gem_evict_vm 418 418 * will be able to evict vma's locked by the ww as well. 419 + * @busy_bo: Optional pointer to struct drm_i915_gem_object. If not NULL, then 420 + * in the event i915_gem_evict_vm() is unable to trylock an object for eviction, 421 + * then @busy_bo will point to it. -EBUSY is also returned. The caller must drop 422 + * the vm->mutex, before trying again to acquire the contended lock. The caller 423 + * also owns a reference to the object. 419 424 * 420 425 * This function evicts all vmas from a vm. 421 426 * ··· 430 425 * To clarify: This is for freeing up virtual address space, not for freeing 431 426 * memory in e.g. the shrinker. 432 427 */ 433 - int i915_gem_evict_vm(struct i915_address_space *vm, struct i915_gem_ww_ctx *ww) 428 + int i915_gem_evict_vm(struct i915_address_space *vm, struct i915_gem_ww_ctx *ww, 429 + struct drm_i915_gem_object **busy_bo) 434 430 { 435 431 int ret = 0; 436 432 ··· 463 457 * the resv is shared among multiple objects, we still 464 458 * need the object ref. 465 459 */ 466 - if (dying_vma(vma) || 460 + if (!i915_gem_object_get_rcu(vma->obj) || 467 461 (ww && (dma_resv_locking_ctx(vma->obj->base.resv) == &ww->ctx))) { 468 462 __i915_vma_pin(vma); 469 463 list_add(&vma->evict_link, &locked_eviction_list); 470 464 continue; 471 465 } 472 466 473 - if (!i915_gem_object_trylock(vma->obj, ww)) 467 + if (!i915_gem_object_trylock(vma->obj, ww)) { 468 + if (busy_bo) { 469 + *busy_bo = vma->obj; /* holds ref */ 470 + ret = -EBUSY; 471 + break; 472 + } 473 + i915_gem_object_put(vma->obj); 474 474 continue; 475 + } 475 476 476 477 __i915_vma_pin(vma); 477 478 list_add(&vma->evict_link, &eviction_list); ··· 486 473 if (list_empty(&eviction_list) && list_empty(&locked_eviction_list)) 487 474 break; 488 475 489 - ret = 0; 490 476 /* Unbind locked objects first, before unlocking the eviction_list */ 491 477 list_for_each_entry_safe(vma, vn, &locked_eviction_list, evict_link) { 492 478 __i915_vma_unpin(vma); 493 479 494 - if (ret == 0) 480 + if (ret == 0) { 495 481 ret = __i915_vma_unbind(vma); 496 - if (ret != -EINTR) /* "Get me out of here!" */ 497 - ret = 0; 482 + if (ret != -EINTR) /* "Get me out of here!" */ 483 + ret = 0; 484 + } 485 + if (!dying_vma(vma)) 486 + i915_gem_object_put(vma->obj); 498 487 } 499 488 500 489 list_for_each_entry_safe(vma, vn, &eviction_list, evict_link) { 501 490 __i915_vma_unpin(vma); 502 - if (ret == 0) 491 + if (ret == 0) { 503 492 ret = __i915_vma_unbind(vma); 504 - if (ret != -EINTR) /* "Get me out of here!" */ 505 - ret = 0; 493 + if (ret != -EINTR) /* "Get me out of here!" */ 494 + ret = 0; 495 + } 506 496 507 497 i915_gem_object_unlock(vma->obj); 498 + i915_gem_object_put(vma->obj); 508 499 } 509 500 } while (ret == 0); 510 501
+3 -1
drivers/gpu/drm/i915/i915_gem_evict.h
··· 11 11 struct drm_mm_node; 12 12 struct i915_address_space; 13 13 struct i915_gem_ww_ctx; 14 + struct drm_i915_gem_object; 14 15 15 16 int __must_check i915_gem_evict_something(struct i915_address_space *vm, 16 17 struct i915_gem_ww_ctx *ww, ··· 24 23 struct drm_mm_node *node, 25 24 unsigned int flags); 26 25 int i915_gem_evict_vm(struct i915_address_space *vm, 27 - struct i915_gem_ww_ctx *ww); 26 + struct i915_gem_ww_ctx *ww, 27 + struct drm_i915_gem_object **busy_bo); 28 28 29 29 #endif /* __I915_GEM_EVICT_H__ */
+3
drivers/gpu/drm/i915/i915_irq.c
··· 1974 1974 if (ddi_hotplug_trigger) { 1975 1975 u32 dig_hotplug_reg; 1976 1976 1977 + /* Locking due to DSI native GPIO sequences */ 1978 + spin_lock(&dev_priv->irq_lock); 1977 1979 dig_hotplug_reg = intel_uncore_rmw(&dev_priv->uncore, SHOTPLUG_CTL_DDI, 0, 0); 1980 + spin_unlock(&dev_priv->irq_lock); 1978 1981 1979 1982 intel_get_hpd_pins(dev_priv, &pin_mask, &long_mask, 1980 1983 ddi_hotplug_trigger, dig_hotplug_reg,
-1
drivers/gpu/drm/i915/i915_pci.c
··· 1129 1129 {} 1130 1130 }; 1131 1131 1132 - __maybe_unused 1133 1132 static const struct intel_device_info mtl_info = { 1134 1133 XE_HP_FEATURES, 1135 1134 XE_LPDP_FEATURES,
+1
drivers/gpu/drm/i915/i915_reg.h
··· 5988 5988 5989 5989 #define SHOTPLUG_CTL_DDI _MMIO(0xc4030) 5990 5990 #define SHOTPLUG_CTL_DDI_HPD_ENABLE(hpd_pin) (0x8 << (_HPD_PIN_DDI(hpd_pin) * 4)) 5991 + #define SHOTPLUG_CTL_DDI_HPD_OUTPUT_DATA(hpd_pin) (0x4 << (_HPD_PIN_DDI(hpd_pin) * 4)) 5991 5992 #define SHOTPLUG_CTL_DDI_HPD_STATUS_MASK(hpd_pin) (0x3 << (_HPD_PIN_DDI(hpd_pin) * 4)) 5992 5993 #define SHOTPLUG_CTL_DDI_HPD_NO_DETECT(hpd_pin) (0x0 << (_HPD_PIN_DDI(hpd_pin) * 4)) 5993 5994 #define SHOTPLUG_CTL_DDI_HPD_SHORT_DETECT(hpd_pin) (0x1 << (_HPD_PIN_DDI(hpd_pin) * 4))
+1 -1
drivers/gpu/drm/i915/i915_vma.c
··· 1566 1566 * locked objects when called from execbuf when pinning 1567 1567 * is removed. This would probably regress badly. 1568 1568 */ 1569 - i915_gem_evict_vm(vm, NULL); 1569 + i915_gem_evict_vm(vm, NULL, NULL); 1570 1570 mutex_unlock(&vm->mutex); 1571 1571 } 1572 1572 } while (1);
+2 -2
drivers/gpu/drm/i915/selftests/i915_gem_evict.c
··· 344 344 345 345 /* Everything is pinned, nothing should happen */ 346 346 mutex_lock(&ggtt->vm.mutex); 347 - err = i915_gem_evict_vm(&ggtt->vm, NULL); 347 + err = i915_gem_evict_vm(&ggtt->vm, NULL, NULL); 348 348 mutex_unlock(&ggtt->vm.mutex); 349 349 if (err) { 350 350 pr_err("i915_gem_evict_vm on a full GGTT returned err=%d]\n", ··· 356 356 357 357 for_i915_gem_ww(&ww, err, false) { 358 358 mutex_lock(&ggtt->vm.mutex); 359 - err = i915_gem_evict_vm(&ggtt->vm, &ww); 359 + err = i915_gem_evict_vm(&ggtt->vm, &ww, NULL); 360 360 mutex_unlock(&ggtt->vm.mutex); 361 361 } 362 362
+8 -6
drivers/gpu/drm/imx/ipuv3-plane.c
··· 614 614 break; 615 615 } 616 616 617 + if (ipu_plane->dp_flow == IPU_DP_FLOW_SYNC_BG) 618 + width = ipu_src_rect_width(new_state); 619 + else 620 + width = drm_rect_width(&new_state->src) >> 16; 621 + 617 622 eba = drm_plane_state_to_eba(new_state, 0); 618 623 619 624 /* ··· 627 622 */ 628 623 if (ipu_state->use_pre) { 629 624 axi_id = ipu_chan_assign_axi_id(ipu_plane->dma); 630 - ipu_prg_channel_configure(ipu_plane->ipu_ch, axi_id, 631 - ipu_src_rect_width(new_state), 625 + ipu_prg_channel_configure(ipu_plane->ipu_ch, axi_id, width, 632 626 drm_rect_height(&new_state->src) >> 16, 633 627 fb->pitches[0], fb->format->format, 634 628 fb->modifier, &eba); ··· 682 678 break; 683 679 } 684 680 685 - ipu_dmfc_config_wait4eot(ipu_plane->dmfc, ALIGN(drm_rect_width(dst), 8)); 681 + ipu_dmfc_config_wait4eot(ipu_plane->dmfc, width); 686 682 687 - width = ipu_src_rect_width(new_state); 688 683 height = drm_rect_height(&new_state->src) >> 16; 689 684 info = drm_format_info(fb->format->format); 690 685 ipu_calculate_bursts(width, info->cpp[0], fb->pitches[0], ··· 747 744 ipu_cpmem_set_burstsize(ipu_plane->ipu_ch, 16); 748 745 749 746 ipu_cpmem_zero(ipu_plane->alpha_ch); 750 - ipu_cpmem_set_resolution(ipu_plane->alpha_ch, 751 - ipu_src_rect_width(new_state), 747 + ipu_cpmem_set_resolution(ipu_plane->alpha_ch, width, 752 748 drm_rect_height(&new_state->src) >> 16); 753 749 ipu_cpmem_set_format_passthrough(ipu_plane->alpha_ch, 8); 754 750 ipu_cpmem_set_high_priority(ipu_plane->alpha_ch);
+2 -3
drivers/gpu/drm/meson/meson_viu.c
··· 436 436 437 437 /* Initialize OSD1 fifo control register */ 438 438 reg = VIU_OSD_DDR_PRIORITY_URGENT | 439 - VIU_OSD_HOLD_FIFO_LINES(31) | 440 439 VIU_OSD_FIFO_DEPTH_VAL(32) | /* fifo_depth_val: 32*8=256 */ 441 440 VIU_OSD_WORDS_PER_BURST(4) | /* 4 words in 1 burst */ 442 441 VIU_OSD_FIFO_LIMITS(2); /* fifo_lim: 2*16=32 */ 443 442 444 443 if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) 445 - reg |= VIU_OSD_BURST_LENGTH_32; 444 + reg |= (VIU_OSD_BURST_LENGTH_32 | VIU_OSD_HOLD_FIFO_LINES(31)); 446 445 else 447 - reg |= VIU_OSD_BURST_LENGTH_64; 446 + reg |= (VIU_OSD_BURST_LENGTH_64 | VIU_OSD_HOLD_FIFO_LINES(4)); 448 447 449 448 writel_relaxed(reg, priv->io_base + _REG(VIU_OSD1_FIFO_CTRL_STAT)); 450 449 writel_relaxed(reg, priv->io_base + _REG(VIU_OSD2_FIFO_CTRL_STAT));
+18 -9
drivers/gpu/drm/panfrost/panfrost_drv.c
··· 82 82 struct panfrost_gem_object *bo; 83 83 struct drm_panfrost_create_bo *args = data; 84 84 struct panfrost_gem_mapping *mapping; 85 + int ret; 85 86 86 87 if (!args->size || args->pad || 87 88 (args->flags & ~(PANFROST_BO_NOEXEC | PANFROST_BO_HEAP))) ··· 93 92 !(args->flags & PANFROST_BO_NOEXEC)) 94 93 return -EINVAL; 95 94 96 - bo = panfrost_gem_create_with_handle(file, dev, args->size, args->flags, 97 - &args->handle); 95 + bo = panfrost_gem_create(dev, args->size, args->flags); 98 96 if (IS_ERR(bo)) 99 97 return PTR_ERR(bo); 100 98 99 + ret = drm_gem_handle_create(file, &bo->base.base, &args->handle); 100 + if (ret) 101 + goto out; 102 + 101 103 mapping = panfrost_gem_mapping_get(bo, priv); 102 - if (!mapping) { 103 - drm_gem_object_put(&bo->base.base); 104 - return -EINVAL; 104 + if (mapping) { 105 + args->offset = mapping->mmnode.start << PAGE_SHIFT; 106 + panfrost_gem_mapping_put(mapping); 107 + } else { 108 + /* This can only happen if the handle from 109 + * drm_gem_handle_create() has already been guessed and freed 110 + * by user space 111 + */ 112 + ret = -EINVAL; 105 113 } 106 114 107 - args->offset = mapping->mmnode.start << PAGE_SHIFT; 108 - panfrost_gem_mapping_put(mapping); 109 - 110 - return 0; 115 + out: 116 + drm_gem_object_put(&bo->base.base); 117 + return ret; 111 118 } 112 119 113 120 /**
+1 -15
drivers/gpu/drm/panfrost/panfrost_gem.c
··· 235 235 } 236 236 237 237 struct panfrost_gem_object * 238 - panfrost_gem_create_with_handle(struct drm_file *file_priv, 239 - struct drm_device *dev, size_t size, 240 - u32 flags, 241 - uint32_t *handle) 238 + panfrost_gem_create(struct drm_device *dev, size_t size, u32 flags) 242 239 { 243 - int ret; 244 240 struct drm_gem_shmem_object *shmem; 245 241 struct panfrost_gem_object *bo; 246 242 ··· 251 255 bo = to_panfrost_bo(&shmem->base); 252 256 bo->noexec = !!(flags & PANFROST_BO_NOEXEC); 253 257 bo->is_heap = !!(flags & PANFROST_BO_HEAP); 254 - 255 - /* 256 - * Allocate an id of idr table where the obj is registered 257 - * and handle has the id what user can see. 258 - */ 259 - ret = drm_gem_handle_create(file_priv, &shmem->base, handle); 260 - /* drop reference from allocate - handle holds it now. */ 261 - drm_gem_object_put(&shmem->base); 262 - if (ret) 263 - return ERR_PTR(ret); 264 258 265 259 return bo; 266 260 }
+1 -4
drivers/gpu/drm/panfrost/panfrost_gem.h
··· 69 69 struct sg_table *sgt); 70 70 71 71 struct panfrost_gem_object * 72 - panfrost_gem_create_with_handle(struct drm_file *file_priv, 73 - struct drm_device *dev, size_t size, 74 - u32 flags, 75 - uint32_t *handle); 72 + panfrost_gem_create(struct drm_device *dev, size_t size, u32 flags); 76 73 77 74 int panfrost_gem_open(struct drm_gem_object *obj, struct drm_file *file_priv); 78 75 void panfrost_gem_close(struct drm_gem_object *obj,
+1 -1
drivers/gpu/drm/scheduler/sched_entity.c
··· 81 81 init_completion(&entity->entity_idle); 82 82 83 83 /* We start in an idle state. */ 84 - complete(&entity->entity_idle); 84 + complete_all(&entity->entity_idle); 85 85 86 86 spin_lock_init(&entity->rq_lock); 87 87 spsc_queue_init(&entity->job_queue);
+2 -2
drivers/gpu/drm/scheduler/sched_main.c
··· 987 987 sched_job = drm_sched_entity_pop_job(entity); 988 988 989 989 if (!sched_job) { 990 - complete(&entity->entity_idle); 990 + complete_all(&entity->entity_idle); 991 991 continue; 992 992 } 993 993 ··· 998 998 999 999 trace_drm_run_job(sched_job, entity); 1000 1000 fence = sched->ops->run_job(sched_job); 1001 - complete(&entity->entity_idle); 1001 + complete_all(&entity->entity_idle); 1002 1002 drm_sched_fence_scheduled(s_fence); 1003 1003 1004 1004 if (!IS_ERR_OR_NULL(fence)) {
+2
drivers/gpu/drm/tests/Makefile
··· 12 12 drm_mm_test.o \ 13 13 drm_plane_helper_test.o \ 14 14 drm_rect_test.o 15 + 16 + CFLAGS_drm_mm_test.o := $(DISABLE_STRUCTLEAK_PLUGIN)
+3 -3
drivers/gpu/drm/tests/drm_mm_test.c
··· 298 298 return false; 299 299 } 300 300 301 - static bool check_reserve_boundaries(struct kunit *test, struct drm_mm *mm, 302 - unsigned int count, 303 - u64 size) 301 + static bool noinline_for_stack check_reserve_boundaries(struct kunit *test, struct drm_mm *mm, 302 + unsigned int count, 303 + u64 size) 304 304 { 305 305 const struct boundary { 306 306 u64 start, size;
+4 -2
drivers/gpu/drm/virtio/virtgpu_object.c
··· 184 184 struct virtio_gpu_object_array *objs = NULL; 185 185 struct drm_gem_shmem_object *shmem_obj; 186 186 struct virtio_gpu_object *bo; 187 - struct virtio_gpu_mem_entry *ents; 187 + struct virtio_gpu_mem_entry *ents = NULL; 188 188 unsigned int nents; 189 189 int ret; 190 190 ··· 210 210 ret = -ENOMEM; 211 211 objs = virtio_gpu_array_alloc(1); 212 212 if (!objs) 213 - goto err_put_id; 213 + goto err_free_entry; 214 214 virtio_gpu_array_add_obj(objs, &bo->base.base); 215 215 216 216 ret = virtio_gpu_array_lock_resv(objs); ··· 239 239 240 240 err_put_objs: 241 241 virtio_gpu_array_put_free(objs); 242 + err_free_entry: 243 + kvfree(ents); 242 244 err_put_id: 243 245 virtio_gpu_resource_id_put(vgdev, bo->hw_res_handle); 244 246 err_free_gem:
+3 -3
drivers/infiniband/hw/mlx5/counters.c
··· 278 278 const struct mlx5_ib_counters *cnts = get_counters(dev, port_num - 1); 279 279 struct mlx5_core_dev *mdev; 280 280 int ret, num_counters; 281 - u32 mdev_port_num; 282 281 283 282 if (!stats) 284 283 return -EINVAL; ··· 298 299 } 299 300 300 301 if (MLX5_CAP_GEN(dev->mdev, cc_query_allowed)) { 301 - mdev = mlx5_ib_get_native_port_mdev(dev, port_num, 302 - &mdev_port_num); 302 + if (!port_num) 303 + port_num = 1; 304 + mdev = mlx5_ib_get_native_port_mdev(dev, port_num, NULL); 303 305 if (!mdev) { 304 306 /* If port is not affiliated yet, its in down state 305 307 * which doesn't have any counters yet, so it would be
+35 -14
drivers/infiniband/hw/mlx5/qp.c
··· 4502 4502 return false; 4503 4503 } 4504 4504 4505 + static int validate_rd_atomic(struct mlx5_ib_dev *dev, struct ib_qp_attr *attr, 4506 + int attr_mask, enum ib_qp_type qp_type) 4507 + { 4508 + int log_max_ra_res; 4509 + int log_max_ra_req; 4510 + 4511 + if (qp_type == MLX5_IB_QPT_DCI) { 4512 + log_max_ra_res = 1 << MLX5_CAP_GEN(dev->mdev, 4513 + log_max_ra_res_dc); 4514 + log_max_ra_req = 1 << MLX5_CAP_GEN(dev->mdev, 4515 + log_max_ra_req_dc); 4516 + } else { 4517 + log_max_ra_res = 1 << MLX5_CAP_GEN(dev->mdev, 4518 + log_max_ra_res_qp); 4519 + log_max_ra_req = 1 << MLX5_CAP_GEN(dev->mdev, 4520 + log_max_ra_req_qp); 4521 + } 4522 + 4523 + if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC && 4524 + attr->max_rd_atomic > log_max_ra_res) { 4525 + mlx5_ib_dbg(dev, "invalid max_rd_atomic value %d\n", 4526 + attr->max_rd_atomic); 4527 + return false; 4528 + } 4529 + 4530 + if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC && 4531 + attr->max_dest_rd_atomic > log_max_ra_req) { 4532 + mlx5_ib_dbg(dev, "invalid max_dest_rd_atomic value %d\n", 4533 + attr->max_dest_rd_atomic); 4534 + return false; 4535 + } 4536 + return true; 4537 + } 4538 + 4505 4539 int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 4506 4540 int attr_mask, struct ib_udata *udata) 4507 4541 { ··· 4623 4589 goto out; 4624 4590 } 4625 4591 4626 - if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC && 4627 - attr->max_rd_atomic > 4628 - (1 << MLX5_CAP_GEN(dev->mdev, log_max_ra_res_qp))) { 4629 - mlx5_ib_dbg(dev, "invalid max_rd_atomic value %d\n", 4630 - attr->max_rd_atomic); 4592 + if (!validate_rd_atomic(dev, attr, attr_mask, qp_type)) 4631 4593 goto out; 4632 - } 4633 - 4634 - if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC && 4635 - attr->max_dest_rd_atomic > 4636 - (1 << MLX5_CAP_GEN(dev->mdev, log_max_ra_req_qp))) { 4637 - mlx5_ib_dbg(dev, "invalid max_dest_rd_atomic value %d\n", 4638 - attr->max_dest_rd_atomic); 4639 - goto out; 4640 - } 4641 4594 4642 4595 if (cur_state == new_state && cur_state == IB_QPS_RESET) { 4643 4596 err = 0;
+5 -3
drivers/infiniband/ulp/srp/ib_srp.h
··· 62 62 SRP_DEFAULT_CMD_SQ_SIZE = SRP_DEFAULT_QUEUE_SIZE - SRP_RSP_SQ_SIZE - 63 63 SRP_TSK_MGMT_SQ_SIZE, 64 64 65 - SRP_TAG_NO_REQ = ~0U, 66 - SRP_TAG_TSK_MGMT = 1U << 31, 67 - 68 65 SRP_MAX_PAGES_PER_MR = 512, 69 66 70 67 SRP_MAX_ADD_CDB_LEN = 16, ··· 74 77 SRP_IMM_DATA_OFFSET = sizeof(struct srp_cmd) + 75 78 SRP_MAX_ADD_CDB_LEN + 76 79 sizeof(struct srp_imm_buf), 80 + }; 81 + 82 + enum { 83 + SRP_TAG_NO_REQ = ~0U, 84 + SRP_TAG_TSK_MGMT = BIT(31), 77 85 }; 78 86 79 87 enum srp_target_state {
+2
drivers/md/dm.c
··· 1742 1742 * otherwise associated queue_limits won't be imposed. 1743 1743 */ 1744 1744 bio = bio_split_to_limits(bio); 1745 + if (!bio) 1746 + return; 1745 1747 } 1746 1748 1747 1749 init_clone_info(&ci, md, map, bio, is_abnormal);
+2
drivers/md/md.c
··· 455 455 } 456 456 457 457 bio = bio_split_to_limits(bio); 458 + if (!bio) 459 + return; 458 460 459 461 if (mddev->ro == MD_RDONLY && unlikely(rw == WRITE)) { 460 462 if (bio_sectors(bio) != 0)
+1
drivers/net/bonding/bond_3ad.c
··· 1549 1549 slave_err(bond->dev, port->slave->dev, 1550 1550 "Port %d did not find a suitable aggregator\n", 1551 1551 port->actor_port_number); 1552 + return; 1552 1553 } 1553 1554 } 1554 1555 /* if all aggregator's ports are READY_N == TRUE, set ready=TRUE
+5 -3
drivers/net/bonding/bond_main.c
··· 2654 2654 2655 2655 static void bond_miimon_commit(struct bonding *bond) 2656 2656 { 2657 - struct slave *slave, *primary; 2657 + struct slave *slave, *primary, *active; 2658 2658 bool do_failover = false; 2659 2659 struct list_head *iter; 2660 + 2661 + ASSERT_RTNL(); 2660 2662 2661 2663 bond_for_each_slave(bond, slave, iter) { 2662 2664 switch (slave->link_new_state) { ··· 2702 2700 2703 2701 bond_miimon_link_change(bond, slave, BOND_LINK_UP); 2704 2702 2705 - if (!rcu_access_pointer(bond->curr_active_slave) || slave == primary || 2706 - slave->prio > rcu_dereference(bond->curr_active_slave)->prio) 2703 + active = rtnl_dereference(bond->curr_active_slave); 2704 + if (!active || slave == primary || slave->prio > active->prio) 2707 2705 do_failover = true; 2708 2706 2709 2707 continue;
+2 -2
drivers/net/dsa/mv88e6xxx/Kconfig
··· 2 2 config NET_DSA_MV88E6XXX 3 3 tristate "Marvell 88E6xxx Ethernet switch fabric support" 4 4 depends on NET_DSA 5 - depends on PTP_1588_CLOCK_OPTIONAL 6 5 select IRQ_DOMAIN 7 6 select NET_DSA_TAG_EDSA 8 7 select NET_DSA_TAG_DSA ··· 12 13 config NET_DSA_MV88E6XXX_PTP 13 14 bool "PTP support for Marvell 88E6xxx" 14 15 default n 15 - depends on NET_DSA_MV88E6XXX && PTP_1588_CLOCK 16 + depends on (NET_DSA_MV88E6XXX = y && PTP_1588_CLOCK = y) || \ 17 + (NET_DSA_MV88E6XXX = m && PTP_1588_CLOCK) 16 18 help 17 19 Say Y to enable PTP hardware timestamping on Marvell 88E6xxx switch 18 20 chips that support it.
+108 -58
drivers/net/dsa/qca/qca8k-8xxx.c
··· 37 37 } 38 38 39 39 static int 40 - qca8k_set_lo(struct qca8k_priv *priv, int phy_id, u32 regnum, u16 lo) 40 + qca8k_mii_write_lo(struct mii_bus *bus, int phy_id, u32 regnum, u32 val) 41 41 { 42 - u16 *cached_lo = &priv->mdio_cache.lo; 43 - struct mii_bus *bus = priv->bus; 44 42 int ret; 43 + u16 lo; 45 44 46 - if (lo == *cached_lo) 47 - return 0; 48 - 45 + lo = val & 0xffff; 49 46 ret = bus->write(bus, phy_id, regnum, lo); 50 47 if (ret < 0) 51 48 dev_err_ratelimited(&bus->dev, 52 49 "failed to write qca8k 32bit lo register\n"); 53 50 54 - *cached_lo = lo; 55 - return 0; 51 + return ret; 56 52 } 57 53 58 54 static int 59 - qca8k_set_hi(struct qca8k_priv *priv, int phy_id, u32 regnum, u16 hi) 55 + qca8k_mii_write_hi(struct mii_bus *bus, int phy_id, u32 regnum, u32 val) 60 56 { 61 - u16 *cached_hi = &priv->mdio_cache.hi; 62 - struct mii_bus *bus = priv->bus; 63 57 int ret; 58 + u16 hi; 64 59 65 - if (hi == *cached_hi) 66 - return 0; 67 - 60 + hi = (u16)(val >> 16); 68 61 ret = bus->write(bus, phy_id, regnum, hi); 69 62 if (ret < 0) 70 63 dev_err_ratelimited(&bus->dev, 71 64 "failed to write qca8k 32bit hi register\n"); 72 65 73 - *cached_hi = hi; 66 + return ret; 67 + } 68 + 69 + static int 70 + qca8k_mii_read_lo(struct mii_bus *bus, int phy_id, u32 regnum, u32 *val) 71 + { 72 + int ret; 73 + 74 + ret = bus->read(bus, phy_id, regnum); 75 + if (ret < 0) 76 + goto err; 77 + 78 + *val = ret & 0xffff; 74 79 return 0; 80 + 81 + err: 82 + dev_err_ratelimited(&bus->dev, 83 + "failed to read qca8k 32bit lo register\n"); 84 + *val = 0; 85 + 86 + return ret; 87 + } 88 + 89 + static int 90 + qca8k_mii_read_hi(struct mii_bus *bus, int phy_id, u32 regnum, u32 *val) 91 + { 92 + int ret; 93 + 94 + ret = bus->read(bus, phy_id, regnum); 95 + if (ret < 0) 96 + goto err; 97 + 98 + *val = ret << 16; 99 + return 0; 100 + 101 + err: 102 + dev_err_ratelimited(&bus->dev, 103 + "failed to read qca8k 32bit hi register\n"); 104 + *val = 0; 105 + 106 + return ret; 75 107 } 76 108 77 109 static int 78 110 qca8k_mii_read32(struct mii_bus *bus, int phy_id, u32 regnum, u32 *val) 79 111 { 112 + u32 hi, lo; 80 113 int ret; 81 114 82 - ret = bus->read(bus, phy_id, regnum); 83 - if (ret >= 0) { 84 - *val = ret; 85 - ret = bus->read(bus, phy_id, regnum + 1); 86 - *val |= ret << 16; 87 - } 115 + *val = 0; 88 116 89 - if (ret < 0) { 90 - dev_err_ratelimited(&bus->dev, 91 - "failed to read qca8k 32bit register\n"); 92 - *val = 0; 93 - return ret; 94 - } 117 + ret = qca8k_mii_read_lo(bus, phy_id, regnum, &lo); 118 + if (ret < 0) 119 + goto err; 95 120 96 - return 0; 121 + ret = qca8k_mii_read_hi(bus, phy_id, regnum + 1, &hi); 122 + if (ret < 0) 123 + goto err; 124 + 125 + *val = lo | hi; 126 + 127 + err: 128 + return ret; 97 129 } 98 130 99 131 static void 100 - qca8k_mii_write32(struct qca8k_priv *priv, int phy_id, u32 regnum, u32 val) 132 + qca8k_mii_write32(struct mii_bus *bus, int phy_id, u32 regnum, u32 val) 101 133 { 102 - u16 lo, hi; 103 - int ret; 134 + if (qca8k_mii_write_lo(bus, phy_id, regnum, val) < 0) 135 + return; 104 136 105 - lo = val & 0xffff; 106 - hi = (u16)(val >> 16); 107 - 108 - ret = qca8k_set_lo(priv, phy_id, regnum, lo); 109 - if (ret >= 0) 110 - ret = qca8k_set_hi(priv, phy_id, regnum + 1, hi); 137 + qca8k_mii_write_hi(bus, phy_id, regnum + 1, val); 111 138 } 112 139 113 140 static int ··· 173 146 174 147 command = get_unaligned_le32(&mgmt_ethhdr->command); 175 148 cmd = FIELD_GET(QCA_HDR_MGMT_CMD, command); 149 + 176 150 len = FIELD_GET(QCA_HDR_MGMT_LENGTH, command); 151 + /* Special case for len of 15 as this is the max value for len and needs to 152 + * be increased before converting it from word to dword. 153 + */ 154 + if (len == 15) 155 + len++; 156 + 157 + /* We can ignore odd value, we always round up them in the alloc function. */ 158 + len *= sizeof(u16); 177 159 178 160 /* Make sure the seq match the requested packet */ 179 161 if (get_unaligned_le32(&mgmt_ethhdr->seq) == mgmt_eth_data->seq) ··· 229 193 if (!skb) 230 194 return NULL; 231 195 232 - /* Max value for len reg is 15 (0xf) but the switch actually return 16 byte 233 - * Actually for some reason the steps are: 234 - * 0: nothing 235 - * 1-4: first 4 byte 236 - * 5-6: first 12 byte 237 - * 7-15: all 16 byte 196 + /* Hdr mgmt length value is in step of word size. 197 + * As an example to process 4 byte of data the correct length to set is 2. 198 + * To process 8 byte 4, 12 byte 6, 16 byte 8... 199 + * 200 + * Odd values will always return the next size on the ack packet. 201 + * (length of 3 (6 byte) will always return 8 bytes of data) 202 + * 203 + * This means that a value of 15 (0xf) actually means reading/writing 32 bytes 204 + * of data. 205 + * 206 + * To correctly calculate the length we devide the requested len by word and 207 + * round up. 208 + * On the ack function we can skip the odd check as we already handle the 209 + * case here. 238 210 */ 239 - if (len == 16) 240 - real_len = 15; 241 - else 242 - real_len = len; 211 + real_len = DIV_ROUND_UP(len, sizeof(u16)); 212 + 213 + /* We check if the result len is odd and we round up another time to 214 + * the next size. (length of 3 will be increased to 4 as switch will always 215 + * return 8 bytes) 216 + */ 217 + if (real_len % sizeof(u16) != 0) 218 + real_len++; 219 + 220 + /* Max reg value is 0xf(15) but switch will always return the next size (32 byte) */ 221 + if (real_len == 16) 222 + real_len--; 243 223 244 224 skb_reset_mac_header(skb); 245 225 skb_set_network_header(skb, skb->len); ··· 469 417 if (ret < 0) 470 418 goto exit; 471 419 472 - qca8k_mii_write32(priv, 0x10 | r2, r1, val); 420 + qca8k_mii_write32(bus, 0x10 | r2, r1, val); 473 421 474 422 exit: 475 423 mutex_unlock(&bus->mdio_lock); ··· 502 450 503 451 val &= ~mask; 504 452 val |= write_val; 505 - qca8k_mii_write32(priv, 0x10 | r2, r1, val); 453 + qca8k_mii_write32(bus, 0x10 | r2, r1, val); 506 454 507 455 exit: 508 456 mutex_unlock(&bus->mdio_lock); ··· 740 688 741 689 qca8k_split_addr(reg, &r1, &r2, &page); 742 690 743 - ret = read_poll_timeout(qca8k_mii_read32, ret1, !(val & mask), 0, 691 + ret = read_poll_timeout(qca8k_mii_read_hi, ret1, !(val & mask), 0, 744 692 QCA8K_BUSY_WAIT_TIMEOUT * USEC_PER_MSEC, false, 745 - bus, 0x10 | r2, r1, &val); 693 + bus, 0x10 | r2, r1 + 1, &val); 746 694 747 695 /* Check if qca8k_read has failed for a different reason 748 696 * before returnting -ETIMEDOUT ··· 777 725 if (ret) 778 726 goto exit; 779 727 780 - qca8k_mii_write32(priv, 0x10 | r2, r1, val); 728 + qca8k_mii_write32(bus, 0x10 | r2, r1, val); 781 729 782 730 ret = qca8k_mdio_busy_wait(bus, QCA8K_MDIO_MASTER_CTRL, 783 731 QCA8K_MDIO_MASTER_BUSY); 784 732 785 733 exit: 786 734 /* even if the busy_wait timeouts try to clear the MASTER_EN */ 787 - qca8k_mii_write32(priv, 0x10 | r2, r1, 0); 735 + qca8k_mii_write_hi(bus, 0x10 | r2, r1 + 1, 0); 788 736 789 737 mutex_unlock(&bus->mdio_lock); 790 738 ··· 814 762 if (ret) 815 763 goto exit; 816 764 817 - qca8k_mii_write32(priv, 0x10 | r2, r1, val); 765 + qca8k_mii_write_hi(bus, 0x10 | r2, r1 + 1, val); 818 766 819 767 ret = qca8k_mdio_busy_wait(bus, QCA8K_MDIO_MASTER_CTRL, 820 768 QCA8K_MDIO_MASTER_BUSY); 821 769 if (ret) 822 770 goto exit; 823 771 824 - ret = qca8k_mii_read32(bus, 0x10 | r2, r1, &val); 772 + ret = qca8k_mii_read_lo(bus, 0x10 | r2, r1, &val); 825 773 826 774 exit: 827 775 /* even if the busy_wait timeouts try to clear the MASTER_EN */ 828 - qca8k_mii_write32(priv, 0x10 | r2, r1, 0); 776 + qca8k_mii_write_hi(bus, 0x10 | r2, r1 + 1, 0); 829 777 830 778 mutex_unlock(&bus->mdio_lock); 831 779 ··· 1995 1943 } 1996 1944 1997 1945 priv->mdio_cache.page = 0xffff; 1998 - priv->mdio_cache.lo = 0xffff; 1999 - priv->mdio_cache.hi = 0xffff; 2000 1946 2001 1947 /* Check the detected switch id */ 2002 1948 ret = qca8k_read_switch_id(priv);
-5
drivers/net/dsa/qca/qca8k.h
··· 375 375 * mdio writes 376 376 */ 377 377 u16 page; 378 - /* lo and hi can also be cached and from Documentation we can skip one 379 - * extra mdio write if lo or hi is didn't change. 380 - */ 381 - u16 lo; 382 - u16 hi; 383 378 }; 384 379 385 380 struct qca8k_pcs {
+9 -20
drivers/net/ethernet/amazon/ena/ena_com.c
··· 2400 2400 return -EOPNOTSUPP; 2401 2401 } 2402 2402 2403 - switch (func) { 2404 - case ENA_ADMIN_TOEPLITZ: 2405 - if (key) { 2406 - if (key_len != sizeof(hash_key->key)) { 2407 - netdev_err(ena_dev->net_device, 2408 - "key len (%u) doesn't equal the supported size (%zu)\n", 2409 - key_len, sizeof(hash_key->key)); 2410 - return -EINVAL; 2411 - } 2412 - memcpy(hash_key->key, key, key_len); 2413 - rss->hash_init_val = init_val; 2414 - hash_key->key_parts = key_len / sizeof(hash_key->key[0]); 2403 + if ((func == ENA_ADMIN_TOEPLITZ) && key) { 2404 + if (key_len != sizeof(hash_key->key)) { 2405 + netdev_err(ena_dev->net_device, 2406 + "key len (%u) doesn't equal the supported size (%zu)\n", 2407 + key_len, sizeof(hash_key->key)); 2408 + return -EINVAL; 2415 2409 } 2416 - break; 2417 - case ENA_ADMIN_CRC32: 2418 - rss->hash_init_val = init_val; 2419 - break; 2420 - default: 2421 - netdev_err(ena_dev->net_device, "Invalid hash function (%d)\n", 2422 - func); 2423 - return -EINVAL; 2410 + memcpy(hash_key->key, key, key_len); 2411 + hash_key->key_parts = key_len / sizeof(hash_key->key[0]); 2424 2412 } 2425 2413 2414 + rss->hash_init_val = init_val; 2426 2415 old_func = rss->hash_func; 2427 2416 rss->hash_func = func; 2428 2417 rc = ena_com_set_hash_function(ena_dev);
+1 -5
drivers/net/ethernet/amazon/ena/ena_ethtool.c
··· 887 887 switch (tuna->id) { 888 888 case ETHTOOL_RX_COPYBREAK: 889 889 len = *(u32 *)data; 890 - if (len > adapter->netdev->mtu) { 891 - ret = -EINVAL; 892 - break; 893 - } 894 - adapter->rx_copybreak = len; 890 + ret = ena_set_rx_copybreak(adapter, len); 895 891 break; 896 892 default: 897 893 ret = -EINVAL;
+60 -23
drivers/net/ethernet/amazon/ena/ena_netdev.c
··· 374 374 375 375 static int ena_xdp_execute(struct ena_ring *rx_ring, struct xdp_buff *xdp) 376 376 { 377 + u32 verdict = ENA_XDP_PASS; 377 378 struct bpf_prog *xdp_prog; 378 379 struct ena_ring *xdp_ring; 379 - u32 verdict = XDP_PASS; 380 380 struct xdp_frame *xdpf; 381 381 u64 *xdp_stat; 382 382 ··· 393 393 if (unlikely(!xdpf)) { 394 394 trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict); 395 395 xdp_stat = &rx_ring->rx_stats.xdp_aborted; 396 - verdict = XDP_ABORTED; 396 + verdict = ENA_XDP_DROP; 397 397 break; 398 398 } 399 399 ··· 409 409 410 410 spin_unlock(&xdp_ring->xdp_tx_lock); 411 411 xdp_stat = &rx_ring->rx_stats.xdp_tx; 412 + verdict = ENA_XDP_TX; 412 413 break; 413 414 case XDP_REDIRECT: 414 415 if (likely(!xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog))) { 415 416 xdp_stat = &rx_ring->rx_stats.xdp_redirect; 417 + verdict = ENA_XDP_REDIRECT; 416 418 break; 417 419 } 418 420 trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict); 419 421 xdp_stat = &rx_ring->rx_stats.xdp_aborted; 420 - verdict = XDP_ABORTED; 422 + verdict = ENA_XDP_DROP; 421 423 break; 422 424 case XDP_ABORTED: 423 425 trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict); 424 426 xdp_stat = &rx_ring->rx_stats.xdp_aborted; 427 + verdict = ENA_XDP_DROP; 425 428 break; 426 429 case XDP_DROP: 427 430 xdp_stat = &rx_ring->rx_stats.xdp_drop; 431 + verdict = ENA_XDP_DROP; 428 432 break; 429 433 case XDP_PASS: 430 434 xdp_stat = &rx_ring->rx_stats.xdp_pass; 435 + verdict = ENA_XDP_PASS; 431 436 break; 432 437 default: 433 438 bpf_warn_invalid_xdp_action(rx_ring->netdev, xdp_prog, verdict); 434 439 xdp_stat = &rx_ring->rx_stats.xdp_invalid; 440 + verdict = ENA_XDP_DROP; 435 441 } 436 442 437 443 ena_increase_stat(xdp_stat, 1, &rx_ring->syncp); ··· 518 512 struct bpf_prog *prog, 519 513 int first, int count) 520 514 { 515 + struct bpf_prog *old_bpf_prog; 521 516 struct ena_ring *rx_ring; 522 517 int i = 0; 523 518 524 519 for (i = first; i < count; i++) { 525 520 rx_ring = &adapter->rx_ring[i]; 526 - xchg(&rx_ring->xdp_bpf_prog, prog); 527 - if (prog) { 521 + old_bpf_prog = xchg(&rx_ring->xdp_bpf_prog, prog); 522 + 523 + if (!old_bpf_prog && prog) { 528 524 ena_xdp_register_rxq_info(rx_ring); 529 525 rx_ring->rx_headroom = XDP_PACKET_HEADROOM; 530 - } else { 526 + } else if (old_bpf_prog && !prog) { 531 527 ena_xdp_unregister_rxq_info(rx_ring); 532 528 rx_ring->rx_headroom = NET_SKB_PAD; 533 529 } ··· 680 672 ring->ena_dev = adapter->ena_dev; 681 673 ring->per_napi_packets = 0; 682 674 ring->cpu = 0; 675 + ring->numa_node = 0; 683 676 ring->no_interrupt_event_cnt = 0; 684 677 u64_stats_init(&ring->syncp); 685 678 } ··· 784 775 tx_ring->next_to_use = 0; 785 776 tx_ring->next_to_clean = 0; 786 777 tx_ring->cpu = ena_irq->cpu; 778 + tx_ring->numa_node = node; 787 779 return 0; 788 780 789 781 err_push_buf_intermediate_buf: ··· 917 907 rx_ring->next_to_clean = 0; 918 908 rx_ring->next_to_use = 0; 919 909 rx_ring->cpu = ena_irq->cpu; 910 + rx_ring->numa_node = node; 920 911 921 912 return 0; 922 913 } ··· 1630 1619 * we expect, then we simply drop it 1631 1620 */ 1632 1621 if (unlikely(rx_ring->ena_bufs[0].len > ENA_XDP_MAX_MTU)) 1633 - return XDP_DROP; 1622 + return ENA_XDP_DROP; 1634 1623 1635 1624 ret = ena_xdp_execute(rx_ring, xdp); 1636 1625 1637 1626 /* The xdp program might expand the headers */ 1638 - if (ret == XDP_PASS) { 1627 + if (ret == ENA_XDP_PASS) { 1639 1628 rx_info->page_offset = xdp->data - xdp->data_hard_start; 1640 1629 rx_ring->ena_bufs[0].len = xdp->data_end - xdp->data; 1641 1630 } ··· 1674 1663 xdp_init_buff(&xdp, ENA_PAGE_SIZE, &rx_ring->xdp_rxq); 1675 1664 1676 1665 do { 1677 - xdp_verdict = XDP_PASS; 1666 + xdp_verdict = ENA_XDP_PASS; 1678 1667 skb = NULL; 1679 1668 ena_rx_ctx.ena_bufs = rx_ring->ena_bufs; 1680 1669 ena_rx_ctx.max_bufs = rx_ring->sgl_size; ··· 1702 1691 xdp_verdict = ena_xdp_handle_buff(rx_ring, &xdp); 1703 1692 1704 1693 /* allocate skb and fill it */ 1705 - if (xdp_verdict == XDP_PASS) 1694 + if (xdp_verdict == ENA_XDP_PASS) 1706 1695 skb = ena_rx_skb(rx_ring, 1707 1696 rx_ring->ena_bufs, 1708 1697 ena_rx_ctx.descs, ··· 1720 1709 /* Packets was passed for transmission, unmap it 1721 1710 * from RX side. 1722 1711 */ 1723 - if (xdp_verdict == XDP_TX || xdp_verdict == XDP_REDIRECT) { 1712 + if (xdp_verdict & ENA_XDP_FORWARDED) { 1724 1713 ena_unmap_rx_buff(rx_ring, 1725 1714 &rx_ring->rx_buffer_info[req_id]); 1726 1715 rx_ring->rx_buffer_info[req_id].page = NULL; 1727 1716 } 1728 1717 } 1729 - if (xdp_verdict != XDP_PASS) { 1718 + if (xdp_verdict != ENA_XDP_PASS) { 1730 1719 xdp_flags |= xdp_verdict; 1720 + total_len += ena_rx_ctx.ena_bufs[0].len; 1731 1721 res_budget--; 1732 1722 continue; 1733 1723 } ··· 1772 1760 ena_refill_rx_bufs(rx_ring, refill_required); 1773 1761 } 1774 1762 1775 - if (xdp_flags & XDP_REDIRECT) 1763 + if (xdp_flags & ENA_XDP_REDIRECT) 1776 1764 xdp_do_flush_map(); 1777 1765 1778 1766 return work_done; ··· 1826 1814 static void ena_unmask_interrupt(struct ena_ring *tx_ring, 1827 1815 struct ena_ring *rx_ring) 1828 1816 { 1817 + u32 rx_interval = tx_ring->smoothed_interval; 1829 1818 struct ena_eth_io_intr_reg intr_reg; 1830 - u32 rx_interval = 0; 1819 + 1831 1820 /* Rx ring can be NULL when for XDP tx queues which don't have an 1832 1821 * accompanying rx_ring pair. 1833 1822 */ ··· 1866 1853 if (likely(tx_ring->cpu == cpu)) 1867 1854 goto out; 1868 1855 1856 + tx_ring->cpu = cpu; 1857 + if (rx_ring) 1858 + rx_ring->cpu = cpu; 1859 + 1869 1860 numa_node = cpu_to_node(cpu); 1861 + 1862 + if (likely(tx_ring->numa_node == numa_node)) 1863 + goto out; 1864 + 1870 1865 put_cpu(); 1871 1866 1872 1867 if (numa_node != NUMA_NO_NODE) { 1873 1868 ena_com_update_numa_node(tx_ring->ena_com_io_cq, numa_node); 1874 - if (rx_ring) 1869 + tx_ring->numa_node = numa_node; 1870 + if (rx_ring) { 1871 + rx_ring->numa_node = numa_node; 1875 1872 ena_com_update_numa_node(rx_ring->ena_com_io_cq, 1876 1873 numa_node); 1874 + } 1877 1875 } 1878 - 1879 - tx_ring->cpu = cpu; 1880 - if (rx_ring) 1881 - rx_ring->cpu = cpu; 1882 1876 1883 1877 return; 1884 1878 out: ··· 2007 1987 if (ena_com_get_adaptive_moderation_enabled(rx_ring->ena_dev)) 2008 1988 ena_adjust_adaptive_rx_intr_moderation(ena_napi); 2009 1989 1990 + ena_update_ring_numa_node(tx_ring, rx_ring); 2010 1991 ena_unmask_interrupt(tx_ring, rx_ring); 2011 1992 } 2012 - 2013 - ena_update_ring_numa_node(tx_ring, rx_ring); 2014 1993 2015 1994 ret = rx_work_done; 2016 1995 } else { ··· 2395 2376 ctx.mem_queue_type = ena_dev->tx_mem_queue_type; 2396 2377 ctx.msix_vector = msix_vector; 2397 2378 ctx.queue_size = tx_ring->ring_size; 2398 - ctx.numa_node = cpu_to_node(tx_ring->cpu); 2379 + ctx.numa_node = tx_ring->numa_node; 2399 2380 2400 2381 rc = ena_com_create_io_queue(ena_dev, &ctx); 2401 2382 if (rc) { ··· 2463 2444 ctx.mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; 2464 2445 ctx.msix_vector = msix_vector; 2465 2446 ctx.queue_size = rx_ring->ring_size; 2466 - ctx.numa_node = cpu_to_node(rx_ring->cpu); 2447 + ctx.numa_node = rx_ring->numa_node; 2467 2448 2468 2449 rc = ena_com_create_io_queue(ena_dev, &ctx); 2469 2450 if (rc) { ··· 2822 2803 adapter->xdp_num_queues + 2823 2804 adapter->num_io_queues); 2824 2805 return dev_was_up ? ena_up(adapter) : 0; 2806 + } 2807 + 2808 + int ena_set_rx_copybreak(struct ena_adapter *adapter, u32 rx_copybreak) 2809 + { 2810 + struct ena_ring *rx_ring; 2811 + int i; 2812 + 2813 + if (rx_copybreak > min_t(u16, adapter->netdev->mtu, ENA_PAGE_SIZE)) 2814 + return -EINVAL; 2815 + 2816 + adapter->rx_copybreak = rx_copybreak; 2817 + 2818 + for (i = 0; i < adapter->num_io_queues; i++) { 2819 + rx_ring = &adapter->rx_ring[i]; 2820 + rx_ring->rx_copybreak = rx_copybreak; 2821 + } 2822 + 2823 + return 0; 2825 2824 } 2826 2825 2827 2826 int ena_update_queue_count(struct ena_adapter *adapter, u32 new_channel_count)
+15 -2
drivers/net/ethernet/amazon/ena/ena_netdev.h
··· 262 262 bool disable_meta_caching; 263 263 u16 no_interrupt_event_cnt; 264 264 265 - /* cpu for TPH */ 265 + /* cpu and NUMA for TPH */ 266 266 int cpu; 267 - /* number of tx/rx_buffer_info's entries */ 267 + int numa_node; 268 + 269 + /* number of tx/rx_buffer_info's entries */ 268 270 int ring_size; 269 271 270 272 enum ena_admin_placement_policy_type tx_mem_queue_type; ··· 394 392 395 393 int ena_update_queue_count(struct ena_adapter *adapter, u32 new_channel_count); 396 394 395 + int ena_set_rx_copybreak(struct ena_adapter *adapter, u32 rx_copybreak); 396 + 397 397 int ena_get_sset_count(struct net_device *netdev, int sset); 398 398 399 399 static inline void ena_reset_device(struct ena_adapter *adapter, ··· 412 408 ENA_XDP_CURRENT_MTU_TOO_LARGE, 413 409 ENA_XDP_NO_ENOUGH_QUEUES, 414 410 }; 411 + 412 + enum ENA_XDP_ACTIONS { 413 + ENA_XDP_PASS = 0, 414 + ENA_XDP_TX = BIT(0), 415 + ENA_XDP_REDIRECT = BIT(1), 416 + ENA_XDP_DROP = BIT(2) 417 + }; 418 + 419 + #define ENA_XDP_FORWARDED (ENA_XDP_TX | ENA_XDP_REDIRECT) 415 420 416 421 static inline bool ena_xdp_present(struct ena_adapter *adapter) 417 422 {
+3
drivers/net/ethernet/amd/xgbe/xgbe-drv.c
··· 1064 1064 1065 1065 devm_free_irq(pdata->dev, pdata->dev_irq, pdata); 1066 1066 1067 + tasklet_kill(&pdata->tasklet_dev); 1068 + tasklet_kill(&pdata->tasklet_ecc); 1069 + 1067 1070 if (pdata->vdata->ecc_support && (pdata->dev_irq != pdata->ecc_irq)) 1068 1071 devm_free_irq(pdata->dev, pdata->ecc_irq, pdata); 1069 1072
+3 -1
drivers/net/ethernet/amd/xgbe/xgbe-i2c.c
··· 447 447 xgbe_i2c_disable(pdata); 448 448 xgbe_i2c_clear_all_interrupts(pdata); 449 449 450 - if (pdata->dev_irq != pdata->i2c_irq) 450 + if (pdata->dev_irq != pdata->i2c_irq) { 451 451 devm_free_irq(pdata->dev, pdata->i2c_irq, pdata); 452 + tasklet_kill(&pdata->tasklet_i2c); 453 + } 452 454 } 453 455 454 456 static int xgbe_i2c_start(struct xgbe_prv_data *pdata)
+3 -1
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
··· 1390 1390 /* Disable auto-negotiation */ 1391 1391 xgbe_an_disable_all(pdata); 1392 1392 1393 - if (pdata->dev_irq != pdata->an_irq) 1393 + if (pdata->dev_irq != pdata->an_irq) { 1394 1394 devm_free_irq(pdata->dev, pdata->an_irq, pdata); 1395 + tasklet_kill(&pdata->tasklet_an); 1396 + } 1395 1397 1396 1398 pdata->phy_if.phy_impl.stop(pdata); 1397 1399
-6
drivers/net/ethernet/broadcom/bcm63xx_enet.c
··· 2784 2784 return 0; 2785 2785 } 2786 2786 2787 - static int bcm_enet_shared_remove(struct platform_device *pdev) 2788 - { 2789 - return 0; 2790 - } 2791 - 2792 2787 /* this "shared" driver is needed because both macs share a single 2793 2788 * address space 2794 2789 */ 2795 2790 struct platform_driver bcm63xx_enet_shared_driver = { 2796 2791 .probe = bcm_enet_shared_probe, 2797 - .remove = bcm_enet_shared_remove, 2798 2792 .driver = { 2799 2793 .name = "bcm63xx_enet_shared", 2800 2794 .owner = THIS_MODULE,
+16 -11
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 991 991 dma_addr -= bp->rx_dma_offset; 992 992 dma_unmap_page_attrs(&bp->pdev->dev, dma_addr, PAGE_SIZE, bp->rx_dir, 993 993 DMA_ATTR_WEAK_ORDERING); 994 - skb = build_skb(page_address(page), BNXT_PAGE_MODE_BUF_SIZE + 995 - bp->rx_dma_offset); 994 + skb = build_skb(page_address(page), PAGE_SIZE); 996 995 if (!skb) { 997 996 __free_page(page); 998 997 return NULL; ··· 1924 1925 dma_addr = rx_buf->mapping; 1925 1926 1926 1927 if (bnxt_xdp_attached(bp, rxr)) { 1927 - bnxt_xdp_buff_init(bp, rxr, cons, &data_ptr, &len, &xdp); 1928 + bnxt_xdp_buff_init(bp, rxr, cons, data_ptr, len, &xdp); 1928 1929 if (agg_bufs) { 1929 1930 u32 frag_len = bnxt_rx_agg_pages_xdp(bp, cpr, &xdp, 1930 1931 cp_cons, agg_bufs, ··· 1939 1940 } 1940 1941 1941 1942 if (xdp_active) { 1942 - if (bnxt_rx_xdp(bp, rxr, cons, xdp, data, &len, event)) { 1943 + if (bnxt_rx_xdp(bp, rxr, cons, xdp, data, &data_ptr, &len, event)) { 1943 1944 rc = 1; 1944 1945 goto next_rx; 1945 1946 } ··· 3968 3969 bp->rx_agg_ring_mask = (bp->rx_agg_nr_pages * RX_DESC_CNT) - 1; 3969 3970 3970 3971 if (BNXT_RX_PAGE_MODE(bp)) { 3971 - rx_space = BNXT_PAGE_MODE_BUF_SIZE; 3972 - rx_size = BNXT_MAX_PAGE_MODE_MTU; 3972 + rx_space = PAGE_SIZE; 3973 + rx_size = PAGE_SIZE - 3974 + ALIGN(max(NET_SKB_PAD, XDP_PACKET_HEADROOM), 8) - 3975 + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); 3973 3976 } else { 3974 3977 rx_size = SKB_DATA_ALIGN(BNXT_RX_COPY_THRESH + NET_IP_ALIGN); 3975 3978 rx_space = rx_size + NET_SKB_PAD + ··· 5399 5398 req->flags = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_JUMBO_PLACEMENT); 5400 5399 req->enables = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_JUMBO_THRESH_VALID); 5401 5400 5402 - if (BNXT_RX_PAGE_MODE(bp) && !BNXT_RX_JUMBO_MODE(bp)) { 5401 + if (BNXT_RX_PAGE_MODE(bp)) { 5402 + req->jumbo_thresh = cpu_to_le16(bp->rx_buf_use_size); 5403 + } else { 5403 5404 req->flags |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4 | 5404 5405 VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV6); 5405 5406 req->enables |= 5406 5407 cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_HDS_THRESHOLD_VALID); 5408 + req->jumbo_thresh = cpu_to_le16(bp->rx_copy_thresh); 5409 + req->hds_threshold = cpu_to_le16(bp->rx_copy_thresh); 5407 5410 } 5408 - /* thresholds not implemented in firmware yet */ 5409 - req->jumbo_thresh = cpu_to_le16(bp->rx_copy_thresh); 5410 - req->hds_threshold = cpu_to_le16(bp->rx_copy_thresh); 5411 5411 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); 5412 5412 return hwrm_req_send(bp, req); 5413 5413 } ··· 13593 13591 return -ENOMEM; 13594 13592 13595 13593 bp = netdev_priv(dev); 13596 - SET_NETDEV_DEVLINK_PORT(dev, &bp->dl_port); 13597 13594 bp->board_idx = ent->driver_data; 13598 13595 bp->msg_enable = BNXT_DEF_MSG_ENABLE; 13599 13596 bnxt_set_max_func_irqs(bp, max_irqs); 13600 13597 13601 13598 if (bnxt_vf_pciid(bp->board_idx)) 13602 13599 bp->flags |= BNXT_FLAG_VF; 13600 + 13601 + /* No devlink port registration in case of a VF */ 13602 + if (BNXT_PF(bp)) 13603 + SET_NETDEV_DEVLINK_PORT(dev, &bp->dl_port); 13603 13604 13604 13605 if (pdev->msix_cap) 13605 13606 bp->flags |= BNXT_FLAG_MSIX_CAP;
+11 -4
drivers/net/ethernet/broadcom/bnxt/bnxt.h
··· 591 591 #define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT) 592 592 593 593 #define BNXT_MAX_MTU 9500 594 - #define BNXT_PAGE_MODE_BUF_SIZE \ 594 + 595 + /* First RX buffer page in XDP multi-buf mode 596 + * 597 + * +-------------------------------------------------------------------------+ 598 + * | XDP_PACKET_HEADROOM | bp->rx_buf_use_size | skb_shared_info| 599 + * | (bp->rx_dma_offset) | | | 600 + * +-------------------------------------------------------------------------+ 601 + */ 602 + #define BNXT_MAX_PAGE_MODE_MTU_SBUF \ 595 603 ((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN - \ 596 604 XDP_PACKET_HEADROOM) 597 605 #define BNXT_MAX_PAGE_MODE_MTU \ 598 - BNXT_PAGE_MODE_BUF_SIZE - \ 599 - SKB_DATA_ALIGN((unsigned int)sizeof(struct skb_shared_info)) 606 + (BNXT_MAX_PAGE_MODE_MTU_SBUF - \ 607 + SKB_DATA_ALIGN((unsigned int)sizeof(struct skb_shared_info))) 600 608 601 609 #define BNXT_MIN_PKT_SIZE 52 602 610 ··· 2142 2134 #define BNXT_DUMP_CRASH 1 2143 2135 2144 2136 struct bpf_prog *xdp_prog; 2145 - u8 xdp_has_frags; 2146 2137 2147 2138 struct bnxt_ptp_cfg *ptp_cfg; 2148 2139 u8 ptp_all_rx_tstamp;
+9 -11
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
··· 177 177 } 178 178 179 179 void bnxt_xdp_buff_init(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, 180 - u16 cons, u8 **data_ptr, unsigned int *len, 180 + u16 cons, u8 *data_ptr, unsigned int len, 181 181 struct xdp_buff *xdp) 182 182 { 183 183 struct bnxt_sw_rx_bd *rx_buf; ··· 191 191 offset = bp->rx_offset; 192 192 193 193 mapping = rx_buf->mapping - bp->rx_dma_offset; 194 - dma_sync_single_for_cpu(&pdev->dev, mapping + offset, *len, bp->rx_dir); 195 - 196 - if (bp->xdp_has_frags) 197 - buflen = BNXT_PAGE_MODE_BUF_SIZE + offset; 194 + dma_sync_single_for_cpu(&pdev->dev, mapping + offset, len, bp->rx_dir); 198 195 199 196 xdp_init_buff(xdp, buflen, &rxr->xdp_rxq); 200 - xdp_prepare_buff(xdp, *data_ptr - offset, offset, *len, false); 197 + xdp_prepare_buff(xdp, data_ptr - offset, offset, len, false); 201 198 } 202 199 203 200 void bnxt_xdp_buff_frags_free(struct bnxt_rx_ring_info *rxr, ··· 219 222 * false - packet should be passed to the stack. 220 223 */ 221 224 bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons, 222 - struct xdp_buff xdp, struct page *page, unsigned int *len, u8 *event) 225 + struct xdp_buff xdp, struct page *page, u8 **data_ptr, 226 + unsigned int *len, u8 *event) 223 227 { 224 228 struct bpf_prog *xdp_prog = READ_ONCE(rxr->xdp_prog); 225 229 struct bnxt_tx_ring_info *txr; ··· 253 255 *event &= ~BNXT_RX_EVENT; 254 256 255 257 *len = xdp.data_end - xdp.data; 256 - if (orig_data != xdp.data) 258 + if (orig_data != xdp.data) { 257 259 offset = xdp.data - xdp.data_hard_start; 260 + *data_ptr = xdp.data_hard_start + offset; 261 + } 258 262 259 263 switch (act) { 260 264 case XDP_PASS: ··· 401 401 netdev_warn(dev, "ethtool rx/tx channels must be combined to support XDP.\n"); 402 402 return -EOPNOTSUPP; 403 403 } 404 - if (prog) { 404 + if (prog) 405 405 tx_xdp = bp->rx_nr_rings; 406 - bp->xdp_has_frags = prog->aux->xdp_has_frags; 407 - } 408 406 409 407 tc = netdev_get_num_tc(dev); 410 408 if (!tc)
+3 -3
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h
··· 18 18 struct xdp_buff *xdp); 19 19 void bnxt_tx_int_xdp(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts); 20 20 bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons, 21 - struct xdp_buff xdp, struct page *page, unsigned int *len, 22 - u8 *event); 21 + struct xdp_buff xdp, struct page *page, u8 **data_ptr, 22 + unsigned int *len, u8 *event); 23 23 int bnxt_xdp(struct net_device *dev, struct netdev_bpf *xdp); 24 24 int bnxt_xdp_xmit(struct net_device *dev, int num_frames, 25 25 struct xdp_frame **frames, u32 flags); ··· 27 27 bool bnxt_xdp_attached(struct bnxt *bp, struct bnxt_rx_ring_info *rxr); 28 28 29 29 void bnxt_xdp_buff_init(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, 30 - u16 cons, u8 **data_ptr, unsigned int *len, 30 + u16 cons, u8 *data_ptr, unsigned int len, 31 31 struct xdp_buff *xdp); 32 32 void bnxt_xdp_buff_frags_free(struct bnxt_rx_ring_info *rxr, 33 33 struct xdp_buff *xdp);
-6
drivers/net/ethernet/freescale/enetc/enetc_ierb.c
··· 127 127 return 0; 128 128 } 129 129 130 - static int enetc_ierb_remove(struct platform_device *pdev) 131 - { 132 - return 0; 133 - } 134 - 135 130 static const struct of_device_id enetc_ierb_match[] = { 136 131 { .compatible = "fsl,ls1028a-enetc-ierb", }, 137 132 {}, ··· 139 144 .of_match_table = enetc_ierb_match, 140 145 }, 141 146 .probe = enetc_ierb_probe, 142 - .remove = enetc_ierb_remove, 143 147 }; 144 148 145 149 module_platform_driver(enetc_ierb_driver);
+1 -1
drivers/net/ethernet/freescale/fman/fman_dtsec.c
··· 1430 1430 dtsec->dtsec_drv_param->tx_pad_crc = true; 1431 1431 1432 1432 phy_node = of_parse_phandle(mac_node, "tbi-handle", 0); 1433 - if (!phy_node || of_device_is_available(phy_node)) { 1433 + if (!phy_node || !of_device_is_available(phy_node)) { 1434 1434 of_node_put(phy_node); 1435 1435 err = -EINVAL; 1436 1436 dev_err_probe(mac_dev->dev, err,
+4 -6
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
··· 3855 3855 return 0; 3856 3856 } 3857 3857 3858 - static bool hns3_checksum_complete(struct hns3_enet_ring *ring, 3858 + static void hns3_checksum_complete(struct hns3_enet_ring *ring, 3859 3859 struct sk_buff *skb, u32 ptype, u16 csum) 3860 3860 { 3861 3861 if (ptype == HNS3_INVALID_PTYPE || 3862 3862 hns3_rx_ptype_tbl[ptype].ip_summed != CHECKSUM_COMPLETE) 3863 - return false; 3863 + return; 3864 3864 3865 3865 hns3_ring_stats_update(ring, csum_complete); 3866 3866 skb->ip_summed = CHECKSUM_COMPLETE; 3867 3867 skb->csum = csum_unfold((__force __sum16)csum); 3868 - 3869 - return true; 3870 3868 } 3871 3869 3872 3870 static void hns3_rx_handle_csum(struct sk_buff *skb, u32 l234info, ··· 3924 3926 ptype = hnae3_get_field(ol_info, HNS3_RXD_PTYPE_M, 3925 3927 HNS3_RXD_PTYPE_S); 3926 3928 3927 - if (hns3_checksum_complete(ring, skb, ptype, csum)) 3928 - return; 3929 + hns3_checksum_complete(ring, skb, ptype, csum); 3929 3930 3930 3931 /* check if hardware has done checksum */ 3931 3932 if (!(bd_base_info & BIT(HNS3_RXD_L3L4P_B))) ··· 3933 3936 if (unlikely(l234info & (BIT(HNS3_RXD_L3E_B) | BIT(HNS3_RXD_L4E_B) | 3934 3937 BIT(HNS3_RXD_OL3E_B) | 3935 3938 BIT(HNS3_RXD_OL4E_B)))) { 3939 + skb->ip_summed = CHECKSUM_NONE; 3936 3940 hns3_ring_stats_update(ring, l3l4_csum_err); 3937 3941 3938 3942 return;
+90 -50
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
··· 3910 3910 return ret; 3911 3911 } 3912 3912 3913 - if (!reset || !test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) 3913 + if (!reset || 3914 + !test_bit(HCLGE_VPORT_STATE_INITED, &vport->state)) 3914 3915 continue; 3916 + 3917 + if (!test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state) && 3918 + hdev->reset_type == HNAE3_FUNC_RESET) { 3919 + set_bit(HCLGE_VPORT_NEED_NOTIFY_RESET, 3920 + &vport->need_notify); 3921 + continue; 3922 + } 3915 3923 3916 3924 /* Inform VF to process the reset. 3917 3925 * hclge_inform_reset_assert_to_vf may fail if VF ··· 4617 4609 4618 4610 static void hclge_update_vport_alive(struct hclge_dev *hdev) 4619 4611 { 4612 + #define HCLGE_ALIVE_SECONDS_NORMAL 8 4613 + 4614 + unsigned long alive_time = HCLGE_ALIVE_SECONDS_NORMAL * HZ; 4620 4615 int i; 4621 4616 4622 4617 /* start from vport 1 for PF is always alive */ 4623 4618 for (i = 1; i < hdev->num_alloc_vport; i++) { 4624 4619 struct hclge_vport *vport = &hdev->vport[i]; 4625 4620 4626 - if (time_after(jiffies, vport->last_active_jiffies + 8 * HZ)) 4621 + if (!test_bit(HCLGE_VPORT_STATE_INITED, &vport->state) || 4622 + !test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) 4623 + continue; 4624 + if (time_after(jiffies, vport->last_active_jiffies + 4625 + alive_time)) { 4627 4626 clear_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state); 4628 - 4629 - /* If vf is not alive, set to default value */ 4630 - if (!test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) 4631 - vport->mps = HCLGE_MAC_DEFAULT_FRAME; 4627 + dev_warn(&hdev->pdev->dev, 4628 + "VF %u heartbeat timeout\n", 4629 + i - HCLGE_VF_VPORT_START_NUM); 4630 + } 4632 4631 } 4633 4632 } 4634 4633 ··· 8079 8064 { 8080 8065 struct hclge_dev *hdev = vport->back; 8081 8066 8067 + set_bit(HCLGE_VPORT_STATE_INITED, &vport->state); 8082 8068 set_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state); 8083 8069 set_bit(HCLGE_VPORT_STATE_PROMISC_CHANGE, &vport->state); 8084 8070 vport->last_active_jiffies = jiffies; 8071 + vport->need_notify = 0; 8085 8072 8086 8073 if (test_bit(vport->vport_id, hdev->vport_config_block)) { 8087 8074 if (vport->vport_id) { ··· 8101 8084 8102 8085 void hclge_vport_stop(struct hclge_vport *vport) 8103 8086 { 8087 + clear_bit(HCLGE_VPORT_STATE_INITED, &vport->state); 8104 8088 clear_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state); 8089 + vport->need_notify = 0; 8105 8090 } 8106 8091 8107 8092 static int hclge_client_start(struct hnae3_handle *handle) ··· 9227 9208 return 0; 9228 9209 } 9229 9210 9230 - dev_info(&hdev->pdev->dev, "MAC of VF %d has been set to %s\n", 9211 + dev_info(&hdev->pdev->dev, 9212 + "MAC of VF %d has been set to %s, will be active after VF reset\n", 9231 9213 vf, format_mac_addr); 9232 9214 return 0; 9233 9215 } ··· 10485 10465 * for DEVICE_VERSION_V3, vf doesn't need to know about the port based 10486 10466 * VLAN state. 10487 10467 */ 10488 - if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V3 && 10489 - test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) 10490 - (void)hclge_push_vf_port_base_vlan_info(&hdev->vport[0], 10491 - vport->vport_id, 10492 - state, &vlan_info); 10493 - 10468 + if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V3) { 10469 + if (test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) 10470 + (void)hclge_push_vf_port_base_vlan_info(&hdev->vport[0], 10471 + vport->vport_id, 10472 + state, 10473 + &vlan_info); 10474 + else 10475 + set_bit(HCLGE_VPORT_NEED_NOTIFY_VF_VLAN, 10476 + &vport->need_notify); 10477 + } 10494 10478 return 0; 10495 10479 } 10496 10480 ··· 11965 11941 int i; 11966 11942 11967 11943 for (i = 0; i < hdev->num_alloc_vport; i++) { 11968 - hclge_vport_stop(vport); 11944 + clear_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state); 11969 11945 vport++; 11970 11946 } 11971 11947 } ··· 12778 12754 return ret; 12779 12755 } 12780 12756 12781 - static void hclge_sync_promisc_mode(struct hclge_dev *hdev) 12757 + static int hclge_sync_vport_promisc_mode(struct hclge_vport *vport) 12782 12758 { 12783 - struct hclge_vport *vport = &hdev->vport[0]; 12784 12759 struct hnae3_handle *handle = &vport->nic; 12760 + struct hclge_dev *hdev = vport->back; 12761 + bool uc_en = false; 12762 + bool mc_en = false; 12785 12763 u8 tmp_flags; 12764 + bool bc_en; 12786 12765 int ret; 12787 - u16 i; 12788 12766 12789 12767 if (vport->last_promisc_flags != vport->overflow_promisc_flags) { 12790 12768 set_bit(HCLGE_VPORT_STATE_PROMISC_CHANGE, &vport->state); 12791 12769 vport->last_promisc_flags = vport->overflow_promisc_flags; 12792 12770 } 12793 12771 12794 - if (test_bit(HCLGE_VPORT_STATE_PROMISC_CHANGE, &vport->state)) { 12772 + if (!test_and_clear_bit(HCLGE_VPORT_STATE_PROMISC_CHANGE, 12773 + &vport->state)) 12774 + return 0; 12775 + 12776 + /* for PF */ 12777 + if (!vport->vport_id) { 12795 12778 tmp_flags = handle->netdev_flags | vport->last_promisc_flags; 12796 12779 ret = hclge_set_promisc_mode(handle, tmp_flags & HNAE3_UPE, 12797 12780 tmp_flags & HNAE3_MPE); 12798 - if (!ret) { 12799 - clear_bit(HCLGE_VPORT_STATE_PROMISC_CHANGE, 12800 - &vport->state); 12781 + if (!ret) 12801 12782 set_bit(HCLGE_VPORT_STATE_VLAN_FLTR_CHANGE, 12802 12783 &vport->state); 12803 - } 12804 - } 12805 - 12806 - for (i = 1; i < hdev->num_alloc_vport; i++) { 12807 - bool uc_en = false; 12808 - bool mc_en = false; 12809 - bool bc_en; 12810 - 12811 - vport = &hdev->vport[i]; 12812 - 12813 - if (!test_and_clear_bit(HCLGE_VPORT_STATE_PROMISC_CHANGE, 12814 - &vport->state)) 12815 - continue; 12816 - 12817 - if (vport->vf_info.trusted) { 12818 - uc_en = vport->vf_info.request_uc_en > 0 || 12819 - vport->overflow_promisc_flags & 12820 - HNAE3_OVERFLOW_UPE; 12821 - mc_en = vport->vf_info.request_mc_en > 0 || 12822 - vport->overflow_promisc_flags & 12823 - HNAE3_OVERFLOW_MPE; 12824 - } 12825 - bc_en = vport->vf_info.request_bc_en > 0; 12826 - 12827 - ret = hclge_cmd_set_promisc_mode(hdev, vport->vport_id, uc_en, 12828 - mc_en, bc_en); 12829 - if (ret) { 12784 + else 12830 12785 set_bit(HCLGE_VPORT_STATE_PROMISC_CHANGE, 12831 12786 &vport->state); 12787 + return ret; 12788 + } 12789 + 12790 + /* for VF */ 12791 + if (vport->vf_info.trusted) { 12792 + uc_en = vport->vf_info.request_uc_en > 0 || 12793 + vport->overflow_promisc_flags & HNAE3_OVERFLOW_UPE; 12794 + mc_en = vport->vf_info.request_mc_en > 0 || 12795 + vport->overflow_promisc_flags & HNAE3_OVERFLOW_MPE; 12796 + } 12797 + bc_en = vport->vf_info.request_bc_en > 0; 12798 + 12799 + ret = hclge_cmd_set_promisc_mode(hdev, vport->vport_id, uc_en, 12800 + mc_en, bc_en); 12801 + if (ret) { 12802 + set_bit(HCLGE_VPORT_STATE_PROMISC_CHANGE, &vport->state); 12803 + return ret; 12804 + } 12805 + hclge_set_vport_vlan_fltr_change(vport); 12806 + 12807 + return 0; 12808 + } 12809 + 12810 + static void hclge_sync_promisc_mode(struct hclge_dev *hdev) 12811 + { 12812 + struct hclge_vport *vport; 12813 + int ret; 12814 + u16 i; 12815 + 12816 + for (i = 0; i < hdev->num_alloc_vport; i++) { 12817 + vport = &hdev->vport[i]; 12818 + 12819 + ret = hclge_sync_vport_promisc_mode(vport); 12820 + if (ret) 12832 12821 return; 12833 - } 12834 - hclge_set_vport_vlan_fltr_change(vport); 12835 12822 } 12836 12823 } 12837 12824 ··· 12978 12943 struct hclge_dev *hdev = vport->back; 12979 12944 struct hclge_vlan_info vlan_info; 12980 12945 int ret; 12946 + 12947 + clear_bit(HCLGE_VPORT_STATE_INITED, &vport->state); 12948 + clear_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state); 12949 + vport->need_notify = 0; 12950 + vport->mps = 0; 12981 12951 12982 12952 /* after disable sriov, clean VF rate configured by PF */ 12983 12953 ret = hclge_tm_qs_shaper_cfg(vport, 0);
+7
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
··· 995 995 HCLGE_VPORT_STATE_MAC_TBL_CHANGE, 996 996 HCLGE_VPORT_STATE_PROMISC_CHANGE, 997 997 HCLGE_VPORT_STATE_VLAN_FLTR_CHANGE, 998 + HCLGE_VPORT_STATE_INITED, 998 999 HCLGE_VPORT_STATE_MAX 1000 + }; 1001 + 1002 + enum HCLGE_VPORT_NEED_NOTIFY { 1003 + HCLGE_VPORT_NEED_NOTIFY_RESET, 1004 + HCLGE_VPORT_NEED_NOTIFY_VF_VLAN, 999 1005 }; 1000 1006 1001 1007 struct hclge_vlan_info { ··· 1050 1044 struct hnae3_handle roce; 1051 1045 1052 1046 unsigned long state; 1047 + unsigned long need_notify; 1053 1048 unsigned long last_active_jiffies; 1054 1049 u32 mps; /* Max packet size */ 1055 1050 struct hclge_vf_info vf_info;
+62 -9
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
··· 124 124 return status; 125 125 } 126 126 127 + static int hclge_inform_vf_reset(struct hclge_vport *vport, u16 reset_type) 128 + { 129 + __le16 msg_data; 130 + u8 dest_vfid; 131 + 132 + dest_vfid = (u8)vport->vport_id; 133 + msg_data = cpu_to_le16(reset_type); 134 + 135 + /* send this requested info to VF */ 136 + return hclge_send_mbx_msg(vport, (u8 *)&msg_data, sizeof(msg_data), 137 + HCLGE_MBX_ASSERTING_RESET, dest_vfid); 138 + } 139 + 127 140 int hclge_inform_reset_assert_to_vf(struct hclge_vport *vport) 128 141 { 129 142 struct hclge_dev *hdev = vport->back; 130 - __le16 msg_data; 131 143 u16 reset_type; 132 - u8 dest_vfid; 133 144 134 145 BUILD_BUG_ON(HNAE3_MAX_RESET > U16_MAX); 135 - 136 - dest_vfid = (u8)vport->vport_id; 137 146 138 147 if (hdev->reset_type == HNAE3_FUNC_RESET) 139 148 reset_type = HNAE3_VF_PF_FUNC_RESET; ··· 151 142 else 152 143 reset_type = HNAE3_VF_FUNC_RESET; 153 144 154 - msg_data = cpu_to_le16(reset_type); 155 - 156 - /* send this requested info to VF */ 157 - return hclge_send_mbx_msg(vport, (u8 *)&msg_data, sizeof(msg_data), 158 - HCLGE_MBX_ASSERTING_RESET, dest_vfid); 145 + return hclge_inform_vf_reset(vport, reset_type); 159 146 } 160 147 161 148 static void hclge_free_vector_ring_chain(struct hnae3_ring_chain_node *head) ··· 657 652 return hclge_func_reset_cmd(hdev, vport->vport_id); 658 653 } 659 654 655 + static void hclge_notify_vf_config(struct hclge_vport *vport) 656 + { 657 + struct hclge_dev *hdev = vport->back; 658 + struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); 659 + struct hclge_port_base_vlan_config *vlan_cfg; 660 + int ret; 661 + 662 + hclge_push_vf_link_status(vport); 663 + if (test_bit(HCLGE_VPORT_NEED_NOTIFY_RESET, &vport->need_notify)) { 664 + ret = hclge_inform_vf_reset(vport, HNAE3_VF_PF_FUNC_RESET); 665 + if (ret) { 666 + dev_err(&hdev->pdev->dev, 667 + "failed to inform VF %u reset!", 668 + vport->vport_id - HCLGE_VF_VPORT_START_NUM); 669 + return; 670 + } 671 + vport->need_notify = 0; 672 + return; 673 + } 674 + 675 + if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V3 && 676 + test_bit(HCLGE_VPORT_NEED_NOTIFY_VF_VLAN, &vport->need_notify)) { 677 + vlan_cfg = &vport->port_base_vlan_cfg; 678 + ret = hclge_push_vf_port_base_vlan_info(&hdev->vport[0], 679 + vport->vport_id, 680 + vlan_cfg->state, 681 + &vlan_cfg->vlan_info); 682 + if (ret) { 683 + dev_err(&hdev->pdev->dev, 684 + "failed to inform VF %u port base vlan!", 685 + vport->vport_id - HCLGE_VF_VPORT_START_NUM); 686 + return; 687 + } 688 + clear_bit(HCLGE_VPORT_NEED_NOTIFY_VF_VLAN, &vport->need_notify); 689 + } 690 + } 691 + 660 692 static void hclge_vf_keep_alive(struct hclge_vport *vport) 661 693 { 694 + struct hclge_dev *hdev = vport->back; 695 + 662 696 vport->last_active_jiffies = jiffies; 697 + 698 + if (test_bit(HCLGE_VPORT_STATE_INITED, &vport->state) && 699 + !test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) { 700 + set_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state); 701 + dev_info(&hdev->pdev->dev, "VF %u is alive!", 702 + vport->vport_id - HCLGE_VF_VPORT_START_NUM); 703 + hclge_notify_vf_config(vport); 704 + } 663 705 } 664 706 665 707 static int hclge_set_vf_mtu(struct hclge_vport *vport, ··· 1006 954 hclge_rm_vport_all_mac_table(param->vport, true, 1007 955 HCLGE_MAC_ADDR_MC); 1008 956 hclge_rm_vport_all_vlan_table(param->vport, true); 957 + param->vport->mps = 0; 1009 958 return 0; 1010 959 } 1011 960
+2 -1
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
··· 2767 2767 struct pci_dev *pdev = hdev->pdev; 2768 2768 int ret = 0; 2769 2769 2770 - if (hdev->reset_type == HNAE3_VF_FULL_RESET && 2770 + if ((hdev->reset_type == HNAE3_VF_FULL_RESET || 2771 + hdev->reset_type == HNAE3_FLR_RESET) && 2771 2772 test_bit(HCLGEVF_STATE_IRQ_INITED, &hdev->state)) { 2772 2773 hclgevf_misc_irq_uninit(hdev); 2773 2774 hclgevf_uninit_msi(hdev);
+1 -1
drivers/net/ethernet/intel/ice/ice_xsk.c
··· 783 783 static void 784 784 ice_clean_xdp_tx_buf(struct ice_tx_ring *xdp_ring, struct ice_tx_buf *tx_buf) 785 785 { 786 - xdp_return_frame((struct xdp_frame *)tx_buf->raw_buf); 786 + page_frag_free(tx_buf->raw_buf); 787 787 xdp_ring->xdp_tx_active--; 788 788 dma_unmap_single(xdp_ring->dev, dma_unmap_addr(tx_buf, dma), 789 789 dma_unmap_len(tx_buf, len), DMA_TO_DEVICE);
+1 -1
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c
··· 589 589 u16 pcifunc = req->hdr.pcifunc; 590 590 struct mcs_rsrc_map *map; 591 591 struct mcs *mcs; 592 - int rc; 592 + int rc = 0; 593 593 594 594 if (req->mcs_id >= rvu->mcs_blk_cnt) 595 595 return MCS_AF_ERR_INVALID_MCSID;
+21 -9
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
··· 1012 1012 rbpool = cq->rbpool; 1013 1013 free_ptrs = cq->pool_ptrs; 1014 1014 1015 + get_cpu(); 1015 1016 while (cq->pool_ptrs) { 1016 1017 if (otx2_alloc_rbuf(pfvf, rbpool, &bufptr)) { 1017 1018 /* Schedule a WQ if we fails to free atleast half of the ··· 1032 1031 pfvf->hw_ops->aura_freeptr(pfvf, qidx, bufptr + OTX2_HEAD_ROOM); 1033 1032 cq->pool_ptrs--; 1034 1033 } 1034 + put_cpu(); 1035 1035 cq->refill_task_sched = false; 1036 1036 } 1037 1037 ··· 1370 1368 if (err) 1371 1369 goto fail; 1372 1370 1371 + get_cpu(); 1373 1372 /* Allocate pointers and free them to aura/pool */ 1374 1373 for (qidx = 0; qidx < hw->tot_tx_queues; qidx++) { 1375 1374 pool_id = otx2_get_pool_idx(pfvf, AURA_NIX_SQ, qidx); ··· 1379 1376 sq = &qset->sq[qidx]; 1380 1377 sq->sqb_count = 0; 1381 1378 sq->sqb_ptrs = kcalloc(num_sqbs, sizeof(*sq->sqb_ptrs), GFP_KERNEL); 1382 - if (!sq->sqb_ptrs) 1383 - return -ENOMEM; 1379 + if (!sq->sqb_ptrs) { 1380 + err = -ENOMEM; 1381 + goto err_mem; 1382 + } 1384 1383 1385 1384 for (ptr = 0; ptr < num_sqbs; ptr++) { 1386 - if (otx2_alloc_rbuf(pfvf, pool, &bufptr)) 1387 - return -ENOMEM; 1385 + err = otx2_alloc_rbuf(pfvf, pool, &bufptr); 1386 + if (err) 1387 + goto err_mem; 1388 1388 pfvf->hw_ops->aura_freeptr(pfvf, pool_id, bufptr); 1389 1389 sq->sqb_ptrs[sq->sqb_count++] = (u64)bufptr; 1390 1390 } 1391 1391 } 1392 1392 1393 - return 0; 1393 + err_mem: 1394 + put_cpu(); 1395 + return err ? -ENOMEM : 0; 1396 + 1394 1397 fail: 1395 1398 otx2_mbox_reset(&pfvf->mbox.mbox, 0); 1396 1399 otx2_aura_pool_free(pfvf); ··· 1435 1426 if (err) 1436 1427 goto fail; 1437 1428 1429 + get_cpu(); 1438 1430 /* Allocate pointers and free them to aura/pool */ 1439 1431 for (pool_id = 0; pool_id < hw->rqpool_cnt; pool_id++) { 1440 1432 pool = &pfvf->qset.pool[pool_id]; 1441 1433 for (ptr = 0; ptr < num_ptrs; ptr++) { 1442 - if (otx2_alloc_rbuf(pfvf, pool, &bufptr)) 1443 - return -ENOMEM; 1434 + err = otx2_alloc_rbuf(pfvf, pool, &bufptr); 1435 + if (err) 1436 + goto err_mem; 1444 1437 pfvf->hw_ops->aura_freeptr(pfvf, pool_id, 1445 1438 bufptr + OTX2_HEAD_ROOM); 1446 1439 } 1447 1440 } 1448 - 1449 - return 0; 1441 + err_mem: 1442 + put_cpu(); 1443 + return err ? -ENOMEM : 0; 1450 1444 fail: 1451 1445 otx2_mbox_reset(&pfvf->mbox.mbox, 0); 1452 1446 otx2_aura_pool_free(pfvf);
+2 -2
drivers/net/ethernet/mellanox/mlx5/core/devlink.c
··· 468 468 bool new_state = val.vbool; 469 469 470 470 if (new_state && !MLX5_CAP_GEN(dev, roce) && 471 - !MLX5_CAP_GEN(dev, roce_rw_supported)) { 471 + !(MLX5_CAP_GEN(dev, roce_rw_supported) && MLX5_CAP_GEN_MAX(dev, roce))) { 472 472 NL_SET_ERR_MSG_MOD(extack, "Device doesn't support RoCE"); 473 473 return -EOPNOTSUPP; 474 474 } ··· 563 563 union devlink_param_value val, 564 564 struct netlink_ext_ack *extack) 565 565 { 566 - return (val.vu16 >= 64 && val.vu16 <= 4096) ? 0 : -EINVAL; 566 + return (val.vu32 >= 64 && val.vu32 <= 4096) ? 0 : -EINVAL; 567 567 } 568 568 569 569 static const struct devlink_param mlx5_devlink_params[] = {
+5 -1
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c
··· 459 459 goto unlock; 460 460 461 461 for (i = 0; i < priv->channels.num; i++) { 462 - struct mlx5e_rq *rq = &priv->channels.c[i]->rq; 462 + struct mlx5e_channel *c = priv->channels.c[i]; 463 + struct mlx5e_rq *rq; 464 + 465 + rq = test_bit(MLX5E_CHANNEL_STATE_XSK, c->state) ? 466 + &c->xskrq : &c->rq; 463 467 464 468 err = mlx5e_rx_reporter_build_diagnose_output(rq, fmsg); 465 469 if (err)
+1 -6
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
··· 2103 2103 static void 2104 2104 mlx5_ct_tc_create_dbgfs(struct mlx5_tc_ct_priv *ct_priv) 2105 2105 { 2106 - bool is_fdb = ct_priv->ns_type == MLX5_FLOW_NAMESPACE_FDB; 2107 2106 struct mlx5_tc_ct_debugfs *ct_dbgfs = &ct_priv->debugfs; 2108 - char dirname[16] = {}; 2109 2107 2110 - if (sscanf(dirname, "ct_%s", is_fdb ? "fdb" : "nic") < 0) 2111 - return; 2112 - 2113 - ct_dbgfs->root = debugfs_create_dir(dirname, mlx5_debugfs_get_dev_root(ct_priv->dev)); 2108 + ct_dbgfs->root = debugfs_create_dir("ct", mlx5_debugfs_get_dev_root(ct_priv->dev)); 2114 2109 debugfs_create_atomic_t("offloaded", 0400, ct_dbgfs->root, 2115 2110 &ct_dbgfs->stats.offloaded); 2116 2111 debugfs_create_atomic_t("rx_dropped", 0400, ct_dbgfs->root,
+8 -1
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
··· 222 222 int err; 223 223 224 224 list_for_each_entry(flow, flow_list, tmp_list) { 225 - if (!mlx5e_is_offloaded_flow(flow) || flow_flag_test(flow, SLOW)) 225 + if (!mlx5e_is_offloaded_flow(flow)) 226 226 continue; 227 227 228 228 attr = mlx5e_tc_get_encap_attr(flow); ··· 230 230 /* mark the flow's encap dest as non-valid */ 231 231 esw_attr->dests[flow->tmp_entry_index].flags &= ~MLX5_ESW_DEST_ENCAP_VALID; 232 232 esw_attr->dests[flow->tmp_entry_index].pkt_reformat = NULL; 233 + 234 + /* Clear pkt_reformat before checking slow path flag. Because 235 + * in next iteration, the same flow is already set slow path 236 + * flag, but still need to clear the pkt_reformat. 237 + */ 238 + if (flow_flag_test(flow, SLOW)) 239 + continue; 233 240 234 241 /* update from encap rule to slow path rule */ 235 242 spec = &flow->attr->parse_attr->spec;
+5
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
··· 273 273 geneve_tlv_option_0_data, be32_to_cpu(opt_data_key)); 274 274 MLX5_SET(fte_match_set_misc3, misc_3_c, 275 275 geneve_tlv_option_0_data, be32_to_cpu(opt_data_mask)); 276 + if (MLX5_CAP_ESW_FLOWTABLE_FDB(priv->mdev, 277 + ft_field_support.geneve_tlv_option_0_exist)) { 278 + MLX5_SET_TO_ONES(fte_match_set_misc, misc_c, geneve_tlv_option_0_exist); 279 + MLX5_SET_TO_ONES(fte_match_set_misc, misc_v, geneve_tlv_option_0_exist); 280 + } 276 281 277 282 spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS_3; 278 283
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 1305 1305 sq->channel = c; 1306 1306 sq->uar_map = mdev->mlx5e_res.hw_objs.bfreg.map; 1307 1307 sq->min_inline_mode = params->tx_min_inline_mode; 1308 - sq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu); 1308 + sq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu) - ETH_FCS_LEN; 1309 1309 sq->xsk_pool = xsk_pool; 1310 1310 1311 1311 sq->stats = sq->xsk_pool ?
+6 -1
drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_lgcy.c
··· 67 67 int esw_acl_egress_lgcy_setup(struct mlx5_eswitch *esw, 68 68 struct mlx5_vport *vport) 69 69 { 70 + bool vst_mode_steering = esw_vst_mode_is_steering(esw); 70 71 struct mlx5_flow_destination drop_ctr_dst = {}; 71 72 struct mlx5_flow_destination *dst = NULL; 72 73 struct mlx5_fc *drop_counter = NULL; ··· 78 77 */ 79 78 int table_size = 2; 80 79 int dest_num = 0; 80 + int actions_flag; 81 81 int err = 0; 82 82 83 83 if (vport->egress.legacy.drop_counter) { ··· 121 119 vport->vport, vport->info.vlan, vport->info.qos); 122 120 123 121 /* Allowed vlan rule */ 122 + actions_flag = MLX5_FLOW_CONTEXT_ACTION_ALLOW; 123 + if (vst_mode_steering) 124 + actions_flag |= MLX5_FLOW_CONTEXT_ACTION_VLAN_POP; 124 125 err = esw_egress_acl_vlan_create(esw, vport, NULL, vport->info.vlan, 125 - MLX5_FLOW_CONTEXT_ACTION_ALLOW); 126 + actions_flag); 126 127 if (err) 127 128 goto out; 128 129
+28 -5
drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_lgcy.c
··· 139 139 int esw_acl_ingress_lgcy_setup(struct mlx5_eswitch *esw, 140 140 struct mlx5_vport *vport) 141 141 { 142 + bool vst_mode_steering = esw_vst_mode_is_steering(esw); 142 143 struct mlx5_flow_destination drop_ctr_dst = {}; 143 144 struct mlx5_flow_destination *dst = NULL; 144 145 struct mlx5_flow_act flow_act = {}; 145 146 struct mlx5_flow_spec *spec = NULL; 146 147 struct mlx5_fc *counter = NULL; 148 + bool vst_check_cvlan = false; 149 + bool vst_push_cvlan = false; 147 150 /* The ingress acl table contains 4 groups 148 151 * (2 active rules at the same time - 149 152 * 1 allow rule from one of the first 3 groups. ··· 206 203 goto out; 207 204 } 208 205 209 - if (vport->info.vlan || vport->info.qos) 206 + if ((vport->info.vlan || vport->info.qos)) { 207 + if (vst_mode_steering) 208 + vst_push_cvlan = true; 209 + else if (!MLX5_CAP_ESW(esw->dev, vport_cvlan_insert_always)) 210 + vst_check_cvlan = true; 211 + } 212 + 213 + if (vst_check_cvlan || vport->info.spoofchk) 214 + spec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS; 215 + 216 + /* Create ingress allow rule */ 217 + flow_act.action = MLX5_FLOW_CONTEXT_ACTION_ALLOW; 218 + if (vst_push_cvlan) { 219 + flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH; 220 + flow_act.vlan[0].prio = vport->info.qos; 221 + flow_act.vlan[0].vid = vport->info.vlan; 222 + flow_act.vlan[0].ethtype = ETH_P_8021Q; 223 + } 224 + 225 + if (vst_check_cvlan) 210 226 MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, 211 227 outer_headers.cvlan_tag); 212 228 ··· 240 218 ether_addr_copy(smac_v, vport->info.mac); 241 219 } 242 220 243 - /* Create ingress allow rule */ 244 - spec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS; 245 - flow_act.action = MLX5_FLOW_CONTEXT_ACTION_ALLOW; 246 221 vport->ingress.allow_rule = mlx5_add_flow_rules(vport->ingress.acl, spec, 247 222 &flow_act, NULL, 0); 248 223 if (IS_ERR(vport->ingress.allow_rule)) { ··· 250 231 vport->ingress.allow_rule = NULL; 251 232 goto out; 252 233 } 234 + 235 + if (!vst_check_cvlan && !vport->info.spoofchk) 236 + goto out; 253 237 254 238 memset(&flow_act, 0, sizeof(flow_act)); 255 239 flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP; ··· 279 257 return 0; 280 258 281 259 out: 282 - esw_acl_ingress_lgcy_cleanup(esw, vport); 260 + if (err) 261 + esw_acl_ingress_lgcy_cleanup(esw, vport); 283 262 kvfree(spec); 284 263 return err; 285 264 }
+21 -9
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
··· 161 161 esw_vport_context.vport_cvlan_strip, 1); 162 162 163 163 if (set_flags & SET_VLAN_INSERT) { 164 - /* insert only if no vlan in packet */ 165 - MLX5_SET(modify_esw_vport_context_in, in, 166 - esw_vport_context.vport_cvlan_insert, 1); 167 - 164 + if (MLX5_CAP_ESW(dev, vport_cvlan_insert_always)) { 165 + /* insert either if vlan exist in packet or not */ 166 + MLX5_SET(modify_esw_vport_context_in, in, 167 + esw_vport_context.vport_cvlan_insert, 168 + MLX5_VPORT_CVLAN_INSERT_ALWAYS); 169 + } else { 170 + /* insert only if no vlan in packet */ 171 + MLX5_SET(modify_esw_vport_context_in, in, 172 + esw_vport_context.vport_cvlan_insert, 173 + MLX5_VPORT_CVLAN_INSERT_WHEN_NO_CVLAN); 174 + } 168 175 MLX5_SET(modify_esw_vport_context_in, in, 169 176 esw_vport_context.cvlan_pcp, qos); 170 177 MLX5_SET(modify_esw_vport_context_in, in, ··· 816 809 817 810 static int esw_vport_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vport) 818 811 { 812 + bool vst_mode_steering = esw_vst_mode_is_steering(esw); 819 813 u16 vport_num = vport->vport; 820 814 int flags; 821 815 int err; ··· 847 839 848 840 flags = (vport->info.vlan || vport->info.qos) ? 849 841 SET_VLAN_STRIP | SET_VLAN_INSERT : 0; 850 - modify_esw_vport_cvlan(esw->dev, vport_num, vport->info.vlan, 851 - vport->info.qos, flags); 842 + if (esw->mode == MLX5_ESWITCH_OFFLOADS || !vst_mode_steering) 843 + modify_esw_vport_cvlan(esw->dev, vport_num, vport->info.vlan, 844 + vport->info.qos, flags); 852 845 853 846 return 0; 854 847 ··· 1857 1848 u16 vport, u16 vlan, u8 qos, u8 set_flags) 1858 1849 { 1859 1850 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 1851 + bool vst_mode_steering = esw_vst_mode_is_steering(esw); 1860 1852 int err = 0; 1861 1853 1862 1854 if (IS_ERR(evport)) ··· 1865 1855 if (vlan > 4095 || qos > 7) 1866 1856 return -EINVAL; 1867 1857 1868 - err = modify_esw_vport_cvlan(esw->dev, vport, vlan, qos, set_flags); 1869 - if (err) 1870 - return err; 1858 + if (esw->mode == MLX5_ESWITCH_OFFLOADS || !vst_mode_steering) { 1859 + err = modify_esw_vport_cvlan(esw->dev, vport, vlan, qos, set_flags); 1860 + if (err) 1861 + return err; 1862 + } 1871 1863 1872 1864 evport->info.vlan = vlan; 1873 1865 evport->info.qos = qos;
+6
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
··· 527 527 int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw, 528 528 u16 vport, u16 vlan, u8 qos, u8 set_flags); 529 529 530 + static inline bool esw_vst_mode_is_steering(struct mlx5_eswitch *esw) 531 + { 532 + return (MLX5_CAP_ESW_EGRESS_ACL(esw->dev, pop_vlan) && 533 + MLX5_CAP_ESW_INGRESS_ACL(esw->dev, push_vlan)); 534 + } 535 + 530 536 static inline bool mlx5_eswitch_vlan_actions_supported(struct mlx5_core_dev *dev, 531 537 u8 vlan_depth) 532 538 {
+6
drivers/net/ethernet/mellanox/mlx5/core/health.c
··· 674 674 dev = container_of(priv, struct mlx5_core_dev, priv); 675 675 devlink = priv_to_devlink(dev); 676 676 677 + mutex_lock(&dev->intf_state_mutex); 678 + if (test_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags)) { 679 + mlx5_core_err(dev, "health works are not permitted at this stage\n"); 680 + return; 681 + } 682 + mutex_unlock(&dev->intf_state_mutex); 677 683 enter_error_state(dev, false); 678 684 if (IS_ERR_OR_NULL(health->fw_fatal_reporter)) { 679 685 devl_lock(devlink);
+4
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
··· 71 71 params->packet_merge.type = MLX5E_PACKET_MERGE_NONE; 72 72 params->hard_mtu = MLX5_IB_GRH_BYTES + MLX5_IPOIB_HARD_LEN; 73 73 params->tunneled_offload_en = false; 74 + 75 + /* CQE compression is not supported for IPoIB */ 76 + params->rx_cqe_compress_def = false; 77 + MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS, params->rx_cqe_compress_def); 74 78 } 75 79 76 80 /* Called directly after IPoIB netdevice was created to initialize SW structs */
+1
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
··· 228 228 if (ldev->nb.notifier_call) 229 229 unregister_netdevice_notifier_net(&init_net, &ldev->nb); 230 230 mlx5_lag_mp_cleanup(ldev); 231 + cancel_delayed_work_sync(&ldev->bond_work); 231 232 destroy_workqueue(ldev->wq); 232 233 mlx5_lag_mpesw_cleanup(ldev); 233 234 mutex_destroy(&ldev->lock);
+3 -1
drivers/net/ethernet/mellanox/mlx5/core/main.c
··· 613 613 MLX5_SET(cmd_hca_cap, set_hca_cap, num_total_dynamic_vf_msix, 614 614 MLX5_CAP_GEN_MAX(dev, num_total_dynamic_vf_msix)); 615 615 616 - if (MLX5_CAP_GEN(dev, roce_rw_supported)) 616 + if (MLX5_CAP_GEN(dev, roce_rw_supported) && MLX5_CAP_GEN_MAX(dev, roce)) 617 617 MLX5_SET(cmd_hca_cap, set_hca_cap, roce, 618 618 mlx5_is_roce_on(dev)); 619 619 ··· 1050 1050 err_tables_cleanup: 1051 1051 mlx5_geneve_destroy(dev->geneve); 1052 1052 mlx5_vxlan_destroy(dev->vxlan); 1053 + mlx5_cleanup_clock(dev); 1054 + mlx5_cleanup_reserved_gids(dev); 1053 1055 mlx5_cq_debugfs_cleanup(dev); 1054 1056 mlx5_fw_reset_cleanup(dev); 1055 1057 err_events_cleanup:
+1 -1
drivers/net/ethernet/microchip/lan966x/lan966x_port.c
··· 381 381 } 382 382 383 383 /* Take PCS out of reset */ 384 - lan_rmw(DEV_CLOCK_CFG_LINK_SPEED_SET(2) | 384 + lan_rmw(DEV_CLOCK_CFG_LINK_SPEED_SET(LAN966X_SPEED_1000) | 385 385 DEV_CLOCK_CFG_PCS_RX_RST_SET(0) | 386 386 DEV_CLOCK_CFG_PCS_TX_RST_SET(0), 387 387 DEV_CLOCK_CFG_LINK_SPEED |
+1 -1
drivers/net/ethernet/microchip/sparx5/sparx5_main.c
··· 834 834 if (err) 835 835 goto cleanup_config; 836 836 837 - if (!of_get_mac_address(np, sparx5->base_mac)) { 837 + if (of_get_mac_address(np, sparx5->base_mac)) { 838 838 dev_info(sparx5->dev, "MAC addr was not set, use random MAC\n"); 839 839 eth_random_addr(sparx5->base_mac); 840 840 sparx5->base_mac[5] = 0;
+7
drivers/net/ethernet/netronome/nfp/nfp_net.h
··· 617 617 * @vnic_no_name: For non-port PF vNIC make ndo_get_phys_port_name return 618 618 * -EOPNOTSUPP to keep backwards compatibility (set by app) 619 619 * @port: Pointer to nfp_port structure if vNIC is a port 620 + * @mc_lock: Protect mc_addrs list 621 + * @mc_addrs: List of mc addrs to add/del to HW 622 + * @mc_work: Work to update mc addrs 620 623 * @app_priv: APP private data for this vNIC 621 624 */ 622 625 struct nfp_net { ··· 720 717 bool vnic_no_name; 721 718 722 719 struct nfp_port *port; 720 + 721 + spinlock_t mc_lock; 722 + struct list_head mc_addrs; 723 + struct work_struct mc_work; 723 724 724 725 void *app_priv; 725 726 };
+57 -4
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
··· 1334 1334 return err; 1335 1335 } 1336 1336 1337 - static int nfp_net_mc_cfg(struct net_device *netdev, const unsigned char *addr, const u32 cmd) 1337 + struct nfp_mc_addr_entry { 1338 + u8 addr[ETH_ALEN]; 1339 + u32 cmd; 1340 + struct list_head list; 1341 + }; 1342 + 1343 + static int nfp_net_mc_cfg(struct nfp_net *nn, const unsigned char *addr, const u32 cmd) 1338 1344 { 1339 - struct nfp_net *nn = netdev_priv(netdev); 1340 1345 int ret; 1341 1346 1342 1347 ret = nfp_net_mbox_lock(nn, NFP_NET_CFG_MULTICAST_SZ); ··· 1356 1351 return nfp_net_mbox_reconfig_and_unlock(nn, cmd); 1357 1352 } 1358 1353 1354 + static int nfp_net_mc_prep(struct nfp_net *nn, const unsigned char *addr, const u32 cmd) 1355 + { 1356 + struct nfp_mc_addr_entry *entry; 1357 + 1358 + entry = kmalloc(sizeof(*entry), GFP_ATOMIC); 1359 + if (!entry) 1360 + return -ENOMEM; 1361 + 1362 + ether_addr_copy(entry->addr, addr); 1363 + entry->cmd = cmd; 1364 + spin_lock_bh(&nn->mc_lock); 1365 + list_add_tail(&entry->list, &nn->mc_addrs); 1366 + spin_unlock_bh(&nn->mc_lock); 1367 + 1368 + schedule_work(&nn->mc_work); 1369 + 1370 + return 0; 1371 + } 1372 + 1359 1373 static int nfp_net_mc_sync(struct net_device *netdev, const unsigned char *addr) 1360 1374 { 1361 1375 struct nfp_net *nn = netdev_priv(netdev); ··· 1385 1361 return -EINVAL; 1386 1362 } 1387 1363 1388 - return nfp_net_mc_cfg(netdev, addr, NFP_NET_CFG_MBOX_CMD_MULTICAST_ADD); 1364 + return nfp_net_mc_prep(nn, addr, NFP_NET_CFG_MBOX_CMD_MULTICAST_ADD); 1389 1365 } 1390 1366 1391 1367 static int nfp_net_mc_unsync(struct net_device *netdev, const unsigned char *addr) 1392 1368 { 1393 - return nfp_net_mc_cfg(netdev, addr, NFP_NET_CFG_MBOX_CMD_MULTICAST_DEL); 1369 + struct nfp_net *nn = netdev_priv(netdev); 1370 + 1371 + return nfp_net_mc_prep(nn, addr, NFP_NET_CFG_MBOX_CMD_MULTICAST_DEL); 1372 + } 1373 + 1374 + static void nfp_net_mc_addr_config(struct work_struct *work) 1375 + { 1376 + struct nfp_net *nn = container_of(work, struct nfp_net, mc_work); 1377 + struct nfp_mc_addr_entry *entry, *tmp; 1378 + struct list_head tmp_list; 1379 + 1380 + INIT_LIST_HEAD(&tmp_list); 1381 + 1382 + spin_lock_bh(&nn->mc_lock); 1383 + list_splice_init(&nn->mc_addrs, &tmp_list); 1384 + spin_unlock_bh(&nn->mc_lock); 1385 + 1386 + list_for_each_entry_safe(entry, tmp, &tmp_list, list) { 1387 + if (nfp_net_mc_cfg(nn, entry->addr, entry->cmd)) 1388 + nn_err(nn, "Config mc address to HW failed.\n"); 1389 + 1390 + list_del(&entry->list); 1391 + kfree(entry); 1392 + } 1394 1393 } 1395 1394 1396 1395 static void nfp_net_set_rx_mode(struct net_device *netdev) ··· 2680 2633 2681 2634 if (!nn->dp.netdev) 2682 2635 return 0; 2636 + 2637 + spin_lock_init(&nn->mc_lock); 2638 + INIT_LIST_HEAD(&nn->mc_addrs); 2639 + INIT_WORK(&nn->mc_work, nfp_net_mc_addr_config); 2640 + 2683 2641 return register_netdev(nn->dp.netdev); 2684 2642 2685 2643 err_clean_mbox: ··· 2704 2652 unregister_netdev(nn->dp.netdev); 2705 2653 nfp_net_ipsec_clean(nn); 2706 2654 nfp_ccm_mbox_clean(nn); 2655 + flush_work(&nn->mc_work); 2707 2656 nfp_net_reconfig_wait_posted(nn); 2708 2657 }
+20 -8
drivers/net/ethernet/qlogic/qed/qed_debug.c
··· 1832 1832 struct qed_ptt *p_ptt, 1833 1833 u32 image_type, 1834 1834 u32 *nvram_offset_bytes, 1835 - u32 *nvram_size_bytes) 1835 + u32 *nvram_size_bytes, 1836 + bool b_can_sleep) 1836 1837 { 1837 1838 u32 ret_mcp_resp, ret_mcp_param, ret_txn_size; 1838 1839 struct mcp_file_att file_att; ··· 1847 1846 &ret_mcp_resp, 1848 1847 &ret_mcp_param, 1849 1848 &ret_txn_size, 1850 - (u32 *)&file_att, false); 1849 + (u32 *)&file_att, 1850 + b_can_sleep); 1851 1851 1852 1852 /* Check response */ 1853 1853 if (nvm_result || (ret_mcp_resp & FW_MSG_CODE_MASK) != ··· 1875 1873 static enum dbg_status qed_nvram_read(struct qed_hwfn *p_hwfn, 1876 1874 struct qed_ptt *p_ptt, 1877 1875 u32 nvram_offset_bytes, 1878 - u32 nvram_size_bytes, u32 *ret_buf) 1876 + u32 nvram_size_bytes, 1877 + u32 *ret_buf, 1878 + bool b_can_sleep) 1879 1879 { 1880 1880 u32 ret_mcp_resp, ret_mcp_param, ret_read_size, bytes_to_copy; 1881 1881 s32 bytes_left = nvram_size_bytes; ··· 1903 1899 &ret_mcp_resp, 1904 1900 &ret_mcp_param, &ret_read_size, 1905 1901 (u32 *)((u8 *)ret_buf + read_offset), 1906 - false)) 1902 + b_can_sleep)) 1907 1903 return DBG_STATUS_NVRAM_READ_FAILED; 1908 1904 1909 1905 /* Check response */ ··· 3384 3380 p_ptt, 3385 3381 NVM_TYPE_HW_DUMP_OUT, 3386 3382 &hw_dump_offset_bytes, 3387 - &hw_dump_size_bytes); 3383 + &hw_dump_size_bytes, 3384 + false); 3388 3385 if (status != DBG_STATUS_OK) 3389 3386 return 0; 3390 3387 ··· 3402 3397 status = qed_nvram_read(p_hwfn, 3403 3398 p_ptt, 3404 3399 hw_dump_offset_bytes, 3405 - hw_dump_size_bytes, dump_buf + offset); 3400 + hw_dump_size_bytes, 3401 + dump_buf + offset, 3402 + false); 3406 3403 if (status != DBG_STATUS_OK) { 3407 3404 DP_NOTICE(p_hwfn, 3408 3405 "Failed to read MCP HW Dump image from NVRAM\n"); ··· 4130 4123 return qed_find_nvram_image(p_hwfn, 4131 4124 p_ptt, 4132 4125 nvram_image_type, 4133 - trace_meta_offset, trace_meta_size); 4126 + trace_meta_offset, 4127 + trace_meta_size, 4128 + true); 4134 4129 } 4135 4130 4136 4131 /* Reads the MCP Trace meta data from NVRAM into the specified buffer */ ··· 4148 4139 /* Read meta data from NVRAM */ 4149 4140 status = qed_nvram_read(p_hwfn, 4150 4141 p_ptt, 4151 - nvram_offset_in_bytes, size_in_bytes, buf); 4142 + nvram_offset_in_bytes, 4143 + size_in_bytes, 4144 + buf, 4145 + true); 4152 4146 if (status != DBG_STATUS_OK) 4153 4147 return status; 4154 4148
+7 -1
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
··· 2505 2505 goto disable_mbx_intr; 2506 2506 2507 2507 qlcnic_83xx_clear_function_resources(adapter); 2508 - qlcnic_dcb_enable(adapter->dcb); 2508 + 2509 + err = qlcnic_dcb_enable(adapter->dcb); 2510 + if (err) { 2511 + qlcnic_dcb_free(adapter->dcb); 2512 + goto disable_mbx_intr; 2513 + } 2514 + 2509 2515 qlcnic_83xx_initialize_nic(adapter, 1); 2510 2516 qlcnic_dcb_get_info(adapter->dcb); 2511 2517
+2 -8
drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h
··· 41 41 unsigned long state; 42 42 }; 43 43 44 - static inline void qlcnic_clear_dcb_ops(struct qlcnic_dcb *dcb) 45 - { 46 - kfree(dcb); 47 - } 48 - 49 44 static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_dcb *dcb) 50 45 { 51 46 if (dcb && dcb->ops->get_hw_capability) ··· 107 112 dcb->ops->init_dcbnl_ops(dcb); 108 113 } 109 114 110 - static inline void qlcnic_dcb_enable(struct qlcnic_dcb *dcb) 115 + static inline int qlcnic_dcb_enable(struct qlcnic_dcb *dcb) 111 116 { 112 - if (dcb && qlcnic_dcb_attach(dcb)) 113 - qlcnic_clear_dcb_ops(dcb); 117 + return dcb ? qlcnic_dcb_attach(dcb) : 0; 114 118 } 115 119 #endif
+7 -1
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
··· 2599 2599 "Device does not support MSI interrupts\n"); 2600 2600 2601 2601 if (qlcnic_82xx_check(adapter)) { 2602 - qlcnic_dcb_enable(adapter->dcb); 2602 + err = qlcnic_dcb_enable(adapter->dcb); 2603 + if (err) { 2604 + qlcnic_dcb_free(adapter->dcb); 2605 + dev_err(&pdev->dev, "Failed to enable DCB\n"); 2606 + goto err_out_free_hw; 2607 + } 2608 + 2603 2609 qlcnic_dcb_get_info(adapter->dcb); 2604 2610 err = qlcnic_setup_intr(adapter); 2605 2611
+29 -29
drivers/net/ethernet/realtek/r8169_main.c
··· 2210 2210 return 0; 2211 2211 } 2212 2212 2213 - static void rtl_wol_enable_rx(struct rtl8169_private *tp) 2214 - { 2215 - if (tp->mac_version >= RTL_GIGA_MAC_VER_25) 2216 - RTL_W32(tp, RxConfig, RTL_R32(tp, RxConfig) | 2217 - AcceptBroadcast | AcceptMulticast | AcceptMyPhys); 2218 - } 2219 - 2220 - static void rtl_prepare_power_down(struct rtl8169_private *tp) 2221 - { 2222 - if (tp->dash_type != RTL_DASH_NONE) 2223 - return; 2224 - 2225 - if (tp->mac_version == RTL_GIGA_MAC_VER_32 || 2226 - tp->mac_version == RTL_GIGA_MAC_VER_33) 2227 - rtl_ephy_write(tp, 0x19, 0xff64); 2228 - 2229 - if (device_may_wakeup(tp_to_dev(tp))) { 2230 - phy_speed_down(tp->phydev, false); 2231 - rtl_wol_enable_rx(tp); 2232 - } 2233 - } 2234 - 2235 2213 static void rtl_init_rxcfg(struct rtl8169_private *tp) 2236 2214 { 2237 2215 switch (tp->mac_version) { ··· 2431 2453 RTL_W32(tp, MISC, RTL_R32(tp, MISC) | RXDV_GATED_EN); 2432 2454 fsleep(2000); 2433 2455 rtl_wait_txrx_fifo_empty(tp); 2456 + } 2457 + 2458 + static void rtl_wol_enable_rx(struct rtl8169_private *tp) 2459 + { 2460 + if (tp->mac_version >= RTL_GIGA_MAC_VER_25) 2461 + RTL_W32(tp, RxConfig, RTL_R32(tp, RxConfig) | 2462 + AcceptBroadcast | AcceptMulticast | AcceptMyPhys); 2463 + 2464 + if (tp->mac_version >= RTL_GIGA_MAC_VER_40) 2465 + rtl_disable_rxdvgate(tp); 2466 + } 2467 + 2468 + static void rtl_prepare_power_down(struct rtl8169_private *tp) 2469 + { 2470 + if (tp->dash_type != RTL_DASH_NONE) 2471 + return; 2472 + 2473 + if (tp->mac_version == RTL_GIGA_MAC_VER_32 || 2474 + tp->mac_version == RTL_GIGA_MAC_VER_33) 2475 + rtl_ephy_write(tp, 0x19, 0xff64); 2476 + 2477 + if (device_may_wakeup(tp_to_dev(tp))) { 2478 + phy_speed_down(tp->phydev, false); 2479 + rtl_wol_enable_rx(tp); 2480 + } 2434 2481 } 2435 2482 2436 2483 static void rtl_set_tx_config_registers(struct rtl8169_private *tp) ··· 3875 3872 netdev_reset_queue(tp->dev); 3876 3873 } 3877 3874 3878 - static void rtl8169_cleanup(struct rtl8169_private *tp, bool going_down) 3875 + static void rtl8169_cleanup(struct rtl8169_private *tp) 3879 3876 { 3880 3877 napi_disable(&tp->napi); 3881 3878 ··· 3886 3883 rtl8169_irq_mask_and_ack(tp); 3887 3884 3888 3885 rtl_rx_close(tp); 3889 - 3890 - if (going_down && tp->dev->wol_enabled) 3891 - goto no_reset; 3892 3886 3893 3887 switch (tp->mac_version) { 3894 3888 case RTL_GIGA_MAC_VER_28: ··· 3907 3907 } 3908 3908 3909 3909 rtl_hw_reset(tp); 3910 - no_reset: 3910 + 3911 3911 rtl8169_tx_clear(tp); 3912 3912 rtl8169_init_ring_indexes(tp); 3913 3913 } ··· 3918 3918 3919 3919 netif_stop_queue(tp->dev); 3920 3920 3921 - rtl8169_cleanup(tp, false); 3921 + rtl8169_cleanup(tp); 3922 3922 3923 3923 for (i = 0; i < NUM_RX_DESC; i++) 3924 3924 rtl8169_mark_to_asic(tp->RxDescArray + i); ··· 4605 4605 pci_clear_master(tp->pci_dev); 4606 4606 rtl_pci_commit(tp); 4607 4607 4608 - rtl8169_cleanup(tp, true); 4608 + rtl8169_cleanup(tp); 4609 4609 rtl_disable_exit_l1(tp); 4610 4610 rtl_prepare_power_down(tp); 4611 4611 }
+9 -1
drivers/net/ethernet/renesas/rswitch.c
··· 1578 1578 { 1579 1579 struct platform_device *pdev = priv->pdev; 1580 1580 struct rswitch_device *rdev; 1581 + struct device_node *port; 1581 1582 struct net_device *ndev; 1582 1583 int err; 1583 1584 ··· 1607 1606 1608 1607 netif_napi_add(ndev, &rdev->napi, rswitch_poll); 1609 1608 1610 - err = of_get_ethdev_address(pdev->dev.of_node, ndev); 1609 + port = rswitch_get_port_node(rdev); 1610 + err = of_get_ethdev_address(port, ndev); 1611 + of_node_put(port); 1611 1612 if (err) { 1612 1613 if (is_valid_ether_addr(rdev->etha->mac_addr)) 1613 1614 eth_hw_addr_set(ndev, rdev->etha->mac_addr); ··· 1789 1786 pm_runtime_get_sync(&pdev->dev); 1790 1787 1791 1788 ret = rswitch_init(priv); 1789 + if (ret < 0) { 1790 + pm_runtime_put(&pdev->dev); 1791 + pm_runtime_disable(&pdev->dev); 1792 + return ret; 1793 + } 1792 1794 1793 1795 device_set_wakeup_capable(&pdev->dev, 1); 1794 1796
+1 -2
drivers/net/ipa/ipa_interrupt.c
··· 132 132 u32 endpoint_id, bool enable) 133 133 { 134 134 struct ipa *ipa = interrupt->ipa; 135 + u32 mask = BIT(endpoint_id % 32); 135 136 u32 unit = endpoint_id / 32; 136 137 const struct ipa_reg *reg; 137 138 u32 offset; 138 - u32 mask; 139 139 u32 val; 140 140 141 141 WARN_ON(!test_bit(endpoint_id, ipa->available)); ··· 148 148 offset = ipa_reg_n_offset(reg, unit); 149 149 val = ioread32(ipa->reg_virt + offset); 150 150 151 - mask = BIT(endpoint_id); 152 151 if (enable) 153 152 val |= mask; 154 153 else
+1
drivers/net/phy/xilinx_gmii2rgmii.c
··· 105 105 106 106 if (!priv->phy_dev->drv) { 107 107 dev_info(dev, "Attached phy not ready\n"); 108 + put_device(&priv->phy_dev->mdio.dev); 108 109 return -EPROBE_DEFER; 109 110 } 110 111
+2 -1
drivers/net/usb/rndis_host.c
··· 255 255 256 256 off = le32_to_cpu(u.get_c->offset); 257 257 len = le32_to_cpu(u.get_c->len); 258 - if (unlikely((8 + off + len) > CONTROL_BUFFER_SIZE)) 258 + if (unlikely((off > CONTROL_BUFFER_SIZE - 8) || 259 + (len > CONTROL_BUFFER_SIZE - 8 - off))) 259 260 goto response_error; 260 261 261 262 if (*reply_len != -1 && len != *reply_len)
+3 -2
drivers/net/veth.c
··· 974 974 xdp_set_return_frame_no_direct(); 975 975 done = veth_xdp_rcv(rq, budget, &bq, &stats); 976 976 977 + if (stats.xdp_redirect > 0) 978 + xdp_do_flush(); 979 + 977 980 if (done < budget && napi_complete_done(napi, done)) { 978 981 /* Write rx_notify_masked before reading ptr_ring */ 979 982 smp_store_mb(rq->rx_notify_masked, false); ··· 990 987 991 988 if (stats.xdp_tx > 0) 992 989 veth_xdp_flush(rq, &bq); 993 - if (stats.xdp_redirect > 0) 994 - xdp_do_flush(); 995 990 xdp_clear_return_frame_no_direct(); 996 991 997 992 return done;
+8
drivers/net/vmxnet3/vmxnet3_drv.c
··· 1288 1288 (le32_to_cpu(gdesc->dword[3]) & 1289 1289 VMXNET3_RCD_CSUM_OK) == VMXNET3_RCD_CSUM_OK) { 1290 1290 skb->ip_summed = CHECKSUM_UNNECESSARY; 1291 + if ((le32_to_cpu(gdesc->dword[0]) & 1292 + (1UL << VMXNET3_RCD_HDR_INNER_SHIFT))) { 1293 + skb->csum_level = 1; 1294 + } 1291 1295 WARN_ON_ONCE(!(gdesc->rcd.tcp || gdesc->rcd.udp) && 1292 1296 !(le32_to_cpu(gdesc->dword[0]) & 1293 1297 (1UL << VMXNET3_RCD_HDR_INNER_SHIFT))); ··· 1301 1297 } else if (gdesc->rcd.v6 && (le32_to_cpu(gdesc->dword[3]) & 1302 1298 (1 << VMXNET3_RCD_TUC_SHIFT))) { 1303 1299 skb->ip_summed = CHECKSUM_UNNECESSARY; 1300 + if ((le32_to_cpu(gdesc->dword[0]) & 1301 + (1UL << VMXNET3_RCD_HDR_INNER_SHIFT))) { 1302 + skb->csum_level = 1; 1303 + } 1304 1304 WARN_ON_ONCE(!(gdesc->rcd.tcp || gdesc->rcd.udp) && 1305 1305 !(le32_to_cpu(gdesc->dword[0]) & 1306 1306 (1UL << VMXNET3_RCD_HDR_INNER_SHIFT)));
+3 -3
drivers/net/vrf.c
··· 1385 1385 1386 1386 /* loopback, multicast & non-ND link-local traffic; do not push through 1387 1387 * packet taps again. Reset pkt_type for upper layers to process skb. 1388 - * For strict packets with a source LLA, determine the dst using the 1389 - * original ifindex. 1388 + * For non-loopback strict packets, determine the dst using the original 1389 + * ifindex. 1390 1390 */ 1391 1391 if (skb->pkt_type == PACKET_LOOPBACK || (need_strict && !is_ndisc)) { 1392 1392 skb->dev = vrf_dev; ··· 1395 1395 1396 1396 if (skb->pkt_type == PACKET_LOOPBACK) 1397 1397 skb->pkt_type = PACKET_HOST; 1398 - else if (ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL) 1398 + else 1399 1399 vrf_ip6_input_dst(skb, vrf_dev, orig_iif); 1400 1400 1401 1401 goto out;
+14 -7
drivers/net/vxlan/vxlan_core.c
··· 2917 2917 vxlan_vnigroup_init(vxlan); 2918 2918 2919 2919 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); 2920 - if (!dev->tstats) 2921 - return -ENOMEM; 2922 - 2923 - err = gro_cells_init(&vxlan->gro_cells, dev); 2924 - if (err) { 2925 - free_percpu(dev->tstats); 2926 - return err; 2920 + if (!dev->tstats) { 2921 + err = -ENOMEM; 2922 + goto err_vnigroup_uninit; 2927 2923 } 2928 2924 2925 + err = gro_cells_init(&vxlan->gro_cells, dev); 2926 + if (err) 2927 + goto err_free_percpu; 2928 + 2929 2929 return 0; 2930 + 2931 + err_free_percpu: 2932 + free_percpu(dev->tstats); 2933 + err_vnigroup_uninit: 2934 + if (vxlan->cfg.flags & VXLAN_F_VNIFILTER) 2935 + vxlan_vnigroup_uninit(vxlan); 2936 + return err; 2930 2937 } 2931 2938 2932 2939 static void vxlan_fdb_delete_default(struct vxlan_dev *vxlan, __be32 vni)
+7 -7
drivers/net/wireless/ath/ath9k/htc.h
··· 327 327 } 328 328 329 329 #ifdef CONFIG_ATH9K_HTC_DEBUGFS 330 - #define __STAT_SAFE(hif_dev, expr) ((hif_dev)->htc_handle->drv_priv ? (expr) : 0) 331 - #define CAB_STAT_INC(priv) ((priv)->debug.tx_stats.cab_queued++) 332 - #define TX_QSTAT_INC(priv, q) ((priv)->debug.tx_stats.queue_stats[q]++) 330 + #define __STAT_SAFE(hif_dev, expr) do { ((hif_dev)->htc_handle->drv_priv ? (expr) : 0); } while (0) 331 + #define CAB_STAT_INC(priv) do { ((priv)->debug.tx_stats.cab_queued++); } while (0) 332 + #define TX_QSTAT_INC(priv, q) do { ((priv)->debug.tx_stats.queue_stats[q]++); } while (0) 333 333 334 334 #define TX_STAT_INC(hif_dev, c) \ 335 335 __STAT_SAFE((hif_dev), (hif_dev)->htc_handle->drv_priv->debug.tx_stats.c++) ··· 378 378 struct ethtool_stats *stats, u64 *data); 379 379 #else 380 380 381 - #define TX_STAT_INC(hif_dev, c) 382 - #define TX_STAT_ADD(hif_dev, c, a) 383 - #define RX_STAT_INC(hif_dev, c) 384 - #define RX_STAT_ADD(hif_dev, c, a) 381 + #define TX_STAT_INC(hif_dev, c) do { } while (0) 382 + #define TX_STAT_ADD(hif_dev, c, a) do { } while (0) 383 + #define RX_STAT_INC(hif_dev, c) do { } while (0) 384 + #define RX_STAT_ADD(hif_dev, c, a) do { } while (0) 385 385 386 386 #define CAB_STAT_INC(priv) 387 387 #define TX_QSTAT_INC(priv, c)
+5
drivers/net/wireless/intel/iwlwifi/fw/acpi.c
··· 1106 1106 int i, j, num_sub_bands; 1107 1107 s8 *gain; 1108 1108 1109 + /* many firmware images for JF lie about this */ 1110 + if (CSR_HW_RFID_TYPE(fwrt->trans->hw_rf_id) == 1111 + CSR_HW_RFID_TYPE(CSR_HW_RF_ID_TYPE_JF)) 1112 + return -EOPNOTSUPP; 1113 + 1109 1114 if (!fw_has_capa(&fwrt->fw->ucode_capa, IWL_UCODE_TLV_CAPA_SET_PPAG)) { 1110 1115 IWL_DEBUG_RADIO(fwrt, 1111 1116 "PPAG capability not supported by FW, command not sent.\n");
+1
drivers/net/wireless/mediatek/mt76/mt7996/Kconfig
··· 2 2 config MT7996E 3 3 tristate "MediaTek MT7996 (PCIe) support" 4 4 select MT76_CONNAC_LIB 5 + select RELAY 5 6 depends on MAC80211 6 7 depends on PCI 7 8 help
-3
drivers/net/wireless/ti/Makefile
··· 3 3 obj-$(CONFIG_WL12XX) += wl12xx/ 4 4 obj-$(CONFIG_WL1251) += wl1251/ 5 5 obj-$(CONFIG_WL18XX) += wl18xx/ 6 - 7 - # small builtin driver bit 8 - obj-$(CONFIG_WILINK_PLATFORM_DATA) += wilink_platform_data.o
+1 -1
drivers/nvme/host/auth.c
··· 953 953 goto err_free_dhchap_secret; 954 954 955 955 if (!ctrl->opts->dhchap_secret && !ctrl->opts->dhchap_ctrl_secret) 956 - return ret; 956 + return 0; 957 957 958 958 ctrl->dhchap_ctxs = kvcalloc(ctrl_max_dhchaps(ctrl), 959 959 sizeof(*chap), GFP_KERNEL);
+27 -7
drivers/nvme/host/core.c
··· 1074 1074 return 0; 1075 1075 } 1076 1076 1077 + static u32 nvme_known_nvm_effects(u8 opcode) 1078 + { 1079 + switch (opcode) { 1080 + case nvme_cmd_write: 1081 + case nvme_cmd_write_zeroes: 1082 + case nvme_cmd_write_uncor: 1083 + return NVME_CMD_EFFECTS_LBCC; 1084 + default: 1085 + return 0; 1086 + } 1087 + } 1088 + 1077 1089 u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u8 opcode) 1078 1090 { 1079 1091 u32 effects = 0; ··· 1093 1081 if (ns) { 1094 1082 if (ns->head->effects) 1095 1083 effects = le32_to_cpu(ns->head->effects->iocs[opcode]); 1084 + if (ns->head->ids.csi == NVME_CAP_CSS_NVM) 1085 + effects |= nvme_known_nvm_effects(opcode); 1096 1086 if (effects & ~(NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC)) 1097 1087 dev_warn_once(ctrl->device, 1098 - "IO command:%02x has unhandled effects:%08x\n", 1088 + "IO command:%02x has unusual effects:%08x\n", 1099 1089 opcode, effects); 1100 - return 0; 1101 - } 1102 1090 1103 - if (ctrl->effects) 1104 - effects = le32_to_cpu(ctrl->effects->acs[opcode]); 1105 - effects |= nvme_known_admin_effects(opcode); 1091 + /* 1092 + * NVME_CMD_EFFECTS_CSE_MASK causes a freeze all I/O queues, 1093 + * which would deadlock when done on an I/O command. Note that 1094 + * We already warn about an unusual effect above. 1095 + */ 1096 + effects &= ~NVME_CMD_EFFECTS_CSE_MASK; 1097 + } else { 1098 + if (ctrl->effects) 1099 + effects = le32_to_cpu(ctrl->effects->acs[opcode]); 1100 + effects |= nvme_known_admin_effects(opcode); 1101 + } 1106 1102 1107 1103 return effects; 1108 1104 } ··· 4946 4926 4947 4927 memset(set, 0, sizeof(*set)); 4948 4928 set->ops = ops; 4949 - set->queue_depth = ctrl->sqsize + 1; 4929 + set->queue_depth = min_t(unsigned, ctrl->sqsize, BLK_MQ_MAX_DEPTH - 1); 4950 4930 /* 4951 4931 * Some Apple controllers requires tags to be unique across admin and 4952 4932 * the (only) I/O queue, so reserve the first 32 tags of the I/O queue.
+24 -4
drivers/nvme/host/ioctl.c
··· 11 11 static bool nvme_cmd_allowed(struct nvme_ns *ns, struct nvme_command *c, 12 12 fmode_t mode) 13 13 { 14 + u32 effects; 15 + 14 16 if (capable(CAP_SYS_ADMIN)) 15 17 return true; 16 18 ··· 45 43 } 46 44 47 45 /* 48 - * Only allow I/O commands that transfer data to the controller if the 49 - * special file is open for writing, but always allow I/O commands that 50 - * transfer data from the controller. 46 + * Check if the controller provides a Commands Supported and Effects log 47 + * and marks this command as supported. If not reject unprivileged 48 + * passthrough. 51 49 */ 52 - if (nvme_is_write(c)) 50 + effects = nvme_command_effects(ns->ctrl, ns, c->common.opcode); 51 + if (!(effects & NVME_CMD_EFFECTS_CSUPP)) 52 + return false; 53 + 54 + /* 55 + * Don't allow passthrough for command that have intrusive (or unknown) 56 + * effects. 57 + */ 58 + if (effects & ~(NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC | 59 + NVME_CMD_EFFECTS_UUID_SEL | 60 + NVME_CMD_EFFECTS_SCOPE_MASK)) 61 + return false; 62 + 63 + /* 64 + * Only allow I/O commands that transfer data to the controller or that 65 + * change the logical block contents if the file descriptor is open for 66 + * writing. 67 + */ 68 + if (nvme_is_write(c) || (effects & NVME_CMD_EFFECTS_LBCC)) 53 69 return mode & FMODE_WRITE; 54 70 return true; 55 71 }
+2
drivers/nvme/host/multipath.c
··· 376 376 * pool from the original queue to allocate the bvecs from. 377 377 */ 378 378 bio = bio_split_to_limits(bio); 379 + if (!bio) 380 + return; 379 381 380 382 srcu_idx = srcu_read_lock(&head->srcu); 381 383 ns = nvme_find_path(head);
+1 -1
drivers/nvme/host/nvme.h
··· 893 893 { 894 894 struct nvme_ns *ns = req->q->queuedata; 895 895 896 - if (req->cmd_flags & REQ_NVME_MPATH) 896 + if ((req->cmd_flags & REQ_NVME_MPATH) && req->bio) 897 897 trace_block_bio_complete(ns->head->disk->queue, req->bio); 898 898 } 899 899
+24 -22
drivers/nvme/host/pci.c
··· 36 36 #define SQ_SIZE(q) ((q)->q_depth << (q)->sqes) 37 37 #define CQ_SIZE(q) ((q)->q_depth * sizeof(struct nvme_completion)) 38 38 39 - #define SGES_PER_PAGE (PAGE_SIZE / sizeof(struct nvme_sgl_desc)) 39 + #define SGES_PER_PAGE (NVME_CTRL_PAGE_SIZE / sizeof(struct nvme_sgl_desc)) 40 40 41 41 /* 42 42 * These can be higher, but we need to ensure that any command doesn't ··· 144 144 mempool_t *iod_mempool; 145 145 146 146 /* shadow doorbell buffer support: */ 147 - u32 *dbbuf_dbs; 147 + __le32 *dbbuf_dbs; 148 148 dma_addr_t dbbuf_dbs_dma_addr; 149 - u32 *dbbuf_eis; 149 + __le32 *dbbuf_eis; 150 150 dma_addr_t dbbuf_eis_dma_addr; 151 151 152 152 /* host memory buffer support: */ ··· 208 208 #define NVMEQ_SQ_CMB 1 209 209 #define NVMEQ_DELETE_ERROR 2 210 210 #define NVMEQ_POLLED 3 211 - u32 *dbbuf_sq_db; 212 - u32 *dbbuf_cq_db; 213 - u32 *dbbuf_sq_ei; 214 - u32 *dbbuf_cq_ei; 211 + __le32 *dbbuf_sq_db; 212 + __le32 *dbbuf_cq_db; 213 + __le32 *dbbuf_sq_ei; 214 + __le32 *dbbuf_cq_ei; 215 215 struct completion delete_done; 216 216 }; 217 217 ··· 343 343 } 344 344 345 345 /* Update dbbuf and return true if an MMIO is required */ 346 - static bool nvme_dbbuf_update_and_check_event(u16 value, u32 *dbbuf_db, 347 - volatile u32 *dbbuf_ei) 346 + static bool nvme_dbbuf_update_and_check_event(u16 value, __le32 *dbbuf_db, 347 + volatile __le32 *dbbuf_ei) 348 348 { 349 349 if (dbbuf_db) { 350 - u16 old_value; 350 + u16 old_value, event_idx; 351 351 352 352 /* 353 353 * Ensure that the queue is written before updating ··· 355 355 */ 356 356 wmb(); 357 357 358 - old_value = *dbbuf_db; 359 - *dbbuf_db = value; 358 + old_value = le32_to_cpu(*dbbuf_db); 359 + *dbbuf_db = cpu_to_le32(value); 360 360 361 361 /* 362 362 * Ensure that the doorbell is updated before reading the event ··· 366 366 */ 367 367 mb(); 368 368 369 - if (!nvme_dbbuf_need_event(*dbbuf_ei, value, old_value)) 369 + event_idx = le32_to_cpu(*dbbuf_ei); 370 + if (!nvme_dbbuf_need_event(event_idx, value, old_value)) 370 371 return false; 371 372 } 372 373 ··· 381 380 */ 382 381 static int nvme_pci_npages_prp(void) 383 382 { 384 - unsigned nprps = DIV_ROUND_UP(NVME_MAX_KB_SZ + NVME_CTRL_PAGE_SIZE, 385 - NVME_CTRL_PAGE_SIZE); 386 - return DIV_ROUND_UP(8 * nprps, PAGE_SIZE - 8); 383 + unsigned max_bytes = (NVME_MAX_KB_SZ * 1024) + NVME_CTRL_PAGE_SIZE; 384 + unsigned nprps = DIV_ROUND_UP(max_bytes, NVME_CTRL_PAGE_SIZE); 385 + return DIV_ROUND_UP(8 * nprps, NVME_CTRL_PAGE_SIZE - 8); 387 386 } 388 387 389 388 /* ··· 393 392 static int nvme_pci_npages_sgl(void) 394 393 { 395 394 return DIV_ROUND_UP(NVME_MAX_SEGS * sizeof(struct nvme_sgl_desc), 396 - PAGE_SIZE); 395 + NVME_CTRL_PAGE_SIZE); 397 396 } 398 397 399 398 static int nvme_admin_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, ··· 709 708 sge->length = cpu_to_le32(entries * sizeof(*sge)); 710 709 sge->type = NVME_SGL_FMT_LAST_SEG_DESC << 4; 711 710 } else { 712 - sge->length = cpu_to_le32(PAGE_SIZE); 711 + sge->length = cpu_to_le32(NVME_CTRL_PAGE_SIZE); 713 712 sge->type = NVME_SGL_FMT_SEG_DESC << 4; 714 713 } 715 714 } ··· 2333 2332 if (dev->cmb_use_sqes) { 2334 2333 result = nvme_cmb_qdepth(dev, nr_io_queues, 2335 2334 sizeof(struct nvme_command)); 2336 - if (result > 0) 2335 + if (result > 0) { 2337 2336 dev->q_depth = result; 2338 - else 2337 + dev->ctrl.sqsize = result - 1; 2338 + } else { 2339 2339 dev->cmb_use_sqes = false; 2340 + } 2340 2341 } 2341 2342 2342 2343 do { ··· 2539 2536 2540 2537 dev->q_depth = min_t(u32, NVME_CAP_MQES(dev->ctrl.cap) + 1, 2541 2538 io_queue_depth); 2542 - dev->ctrl.sqsize = dev->q_depth - 1; /* 0's based queue depth */ 2543 2539 dev->db_stride = 1 << NVME_CAP_STRIDE(dev->ctrl.cap); 2544 2540 dev->dbs = dev->bar + 4096; 2545 2541 ··· 2579 2577 dev_warn(dev->ctrl.device, "IO queue depth clamped to %d\n", 2580 2578 dev->q_depth); 2581 2579 } 2582 - 2580 + dev->ctrl.sqsize = dev->q_depth - 1; /* 0's based queue depth */ 2583 2581 2584 2582 nvme_map_cmb(dev); 2585 2583
+20 -15
drivers/nvme/target/admin-cmd.c
··· 164 164 165 165 static void nvmet_get_cmd_effects_nvm(struct nvme_effects_log *log) 166 166 { 167 - log->acs[nvme_admin_get_log_page] = cpu_to_le32(1 << 0); 168 - log->acs[nvme_admin_identify] = cpu_to_le32(1 << 0); 169 - log->acs[nvme_admin_abort_cmd] = cpu_to_le32(1 << 0); 170 - log->acs[nvme_admin_set_features] = cpu_to_le32(1 << 0); 171 - log->acs[nvme_admin_get_features] = cpu_to_le32(1 << 0); 172 - log->acs[nvme_admin_async_event] = cpu_to_le32(1 << 0); 173 - log->acs[nvme_admin_keep_alive] = cpu_to_le32(1 << 0); 167 + log->acs[nvme_admin_get_log_page] = 168 + log->acs[nvme_admin_identify] = 169 + log->acs[nvme_admin_abort_cmd] = 170 + log->acs[nvme_admin_set_features] = 171 + log->acs[nvme_admin_get_features] = 172 + log->acs[nvme_admin_async_event] = 173 + log->acs[nvme_admin_keep_alive] = 174 + cpu_to_le32(NVME_CMD_EFFECTS_CSUPP); 174 175 175 - log->iocs[nvme_cmd_read] = cpu_to_le32(1 << 0); 176 - log->iocs[nvme_cmd_write] = cpu_to_le32(1 << 0); 177 - log->iocs[nvme_cmd_flush] = cpu_to_le32(1 << 0); 178 - log->iocs[nvme_cmd_dsm] = cpu_to_le32(1 << 0); 179 - log->iocs[nvme_cmd_write_zeroes] = cpu_to_le32(1 << 0); 176 + log->iocs[nvme_cmd_read] = 177 + log->iocs[nvme_cmd_flush] = 178 + log->iocs[nvme_cmd_dsm] = 179 + cpu_to_le32(NVME_CMD_EFFECTS_CSUPP); 180 + log->iocs[nvme_cmd_write] = 181 + log->iocs[nvme_cmd_write_zeroes] = 182 + cpu_to_le32(NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC); 180 183 } 181 184 182 185 static void nvmet_get_cmd_effects_zns(struct nvme_effects_log *log) 183 186 { 184 - log->iocs[nvme_cmd_zone_append] = cpu_to_le32(1 << 0); 185 - log->iocs[nvme_cmd_zone_mgmt_send] = cpu_to_le32(1 << 0); 186 - log->iocs[nvme_cmd_zone_mgmt_recv] = cpu_to_le32(1 << 0); 187 + log->iocs[nvme_cmd_zone_append] = 188 + log->iocs[nvme_cmd_zone_mgmt_send] = 189 + cpu_to_le32(NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC); 190 + log->iocs[nvme_cmd_zone_mgmt_recv] = 191 + cpu_to_le32(NVME_CMD_EFFECTS_CSUPP); 187 192 } 188 193 189 194 static void nvmet_execute_get_log_cmd_effects_ns(struct nvmet_req *req)
+5 -6
drivers/nvme/target/passthru.c
··· 334 334 } 335 335 336 336 /* 337 - * If there are effects for the command we are about to execute, or 338 - * an end_req function we need to use nvme_execute_passthru_rq() 339 - * synchronously in a work item seeing the end_req function and 340 - * nvme_passthru_end() can't be called in the request done callback 341 - * which is typically in interrupt context. 337 + * If a command needs post-execution fixups, or there are any 338 + * non-trivial effects, make sure to execute the command synchronously 339 + * in a workqueue so that nvme_passthru_end gets called. 342 340 */ 343 341 effects = nvme_command_effects(ctrl, ns, req->cmd->common.opcode); 344 - if (req->p.use_workqueue || effects) { 342 + if (req->p.use_workqueue || 343 + (effects & ~(NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC))) { 345 344 INIT_WORK(&req->p.work, nvmet_passthru_execute_cmd_work); 346 345 req->p.rq = rq; 347 346 queue_work(nvmet_wq, &req->p.work);
+32 -28
drivers/of/fdt.c
··· 1099 1099 */ 1100 1100 int __init early_init_dt_scan_memory(void) 1101 1101 { 1102 - int node; 1102 + int node, found_memory = 0; 1103 1103 const void *fdt = initial_boot_params; 1104 1104 1105 1105 fdt_for_each_subnode(node, fdt, 0) { ··· 1139 1139 1140 1140 early_init_dt_add_memory_arch(base, size); 1141 1141 1142 + found_memory = 1; 1143 + 1142 1144 if (!hotpluggable) 1143 1145 continue; 1144 1146 ··· 1149 1147 base, base + size); 1150 1148 } 1151 1149 } 1152 - return 0; 1150 + return found_memory; 1153 1151 } 1154 1152 1155 1153 int __init early_init_dt_scan_chosen(char *cmdline) ··· 1163 1161 if (node < 0) 1164 1162 node = fdt_path_offset(fdt, "/chosen@0"); 1165 1163 if (node < 0) 1166 - return -ENOENT; 1164 + /* Handle the cmdline config options even if no /chosen node */ 1165 + goto handle_cmdline; 1167 1166 1168 1167 chosen_node_offset = node; 1169 1168 1170 1169 early_init_dt_check_for_initrd(node); 1171 1170 early_init_dt_check_for_elfcorehdr(node); 1172 - 1173 - /* Retrieve command line */ 1174 - p = of_get_flat_dt_prop(node, "bootargs", &l); 1175 - if (p != NULL && l > 0) 1176 - strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); 1177 1171 1178 1172 rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l); 1179 1173 if (rng_seed && l > 0) { ··· 1182 1184 of_fdt_crc32 = crc32_be(~0, initial_boot_params, 1183 1185 fdt_totalsize(initial_boot_params)); 1184 1186 } 1187 + 1188 + /* Retrieve command line */ 1189 + p = of_get_flat_dt_prop(node, "bootargs", &l); 1190 + if (p != NULL && l > 0) 1191 + strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); 1192 + 1193 + handle_cmdline: 1194 + /* 1195 + * CONFIG_CMDLINE is meant to be a default in case nothing else 1196 + * managed to set the command line, unless CONFIG_CMDLINE_FORCE 1197 + * is set in which case we override whatever was found earlier. 1198 + */ 1199 + #ifdef CONFIG_CMDLINE 1200 + #if defined(CONFIG_CMDLINE_EXTEND) 1201 + strlcat(cmdline, " ", COMMAND_LINE_SIZE); 1202 + strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 1203 + #elif defined(CONFIG_CMDLINE_FORCE) 1204 + strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 1205 + #else 1206 + /* No arguments from boot loader, use kernel's cmdl*/ 1207 + if (!((char *)cmdline)[0]) 1208 + strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 1209 + #endif 1210 + #endif /* CONFIG_CMDLINE */ 1211 + 1212 + pr_debug("Command line is: %s\n", (char *)cmdline); 1185 1213 1186 1214 return 0; 1187 1215 } ··· 1300 1276 rc = early_init_dt_scan_chosen(boot_command_line); 1301 1277 if (rc) 1302 1278 pr_warn("No chosen node found, continuing without\n"); 1303 - 1304 - /* 1305 - * CONFIG_CMDLINE is meant to be a default in case nothing else 1306 - * managed to set the command line, unless CONFIG_CMDLINE_FORCE 1307 - * is set in which case we override whatever was found earlier. 1308 - */ 1309 - #ifdef CONFIG_CMDLINE 1310 - #if defined(CONFIG_CMDLINE_EXTEND) 1311 - strlcat(boot_command_line, " ", COMMAND_LINE_SIZE); 1312 - strlcat(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 1313 - #elif defined(CONFIG_CMDLINE_FORCE) 1314 - strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 1315 - #else 1316 - /* No arguments from boot loader, use kernel's cmdl */ 1317 - if (!boot_command_line[0]) 1318 - strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 1319 - #endif 1320 - #endif /* CONFIG_CMDLINE */ 1321 - 1322 - pr_debug("Command line is: %s\n", boot_command_line); 1323 1279 1324 1280 /* Setup memory, calling early_init_dt_add_memory_arch */ 1325 1281 early_init_dt_scan_memory();
+2
drivers/s390/block/dcssblk.c
··· 865 865 unsigned long bytes_done; 866 866 867 867 bio = bio_split_to_limits(bio); 868 + if (!bio) 869 + return; 868 870 869 871 bytes_done = 0; 870 872 dev_info = bio->bi_bdev->bd_disk->private_data;
+6 -6
drivers/s390/net/qeth_core_sys.c
··· 410 410 411 411 switch (card->options.isolation) { 412 412 case ISOLATION_MODE_NONE: 413 - return snprintf(buf, 6, "%s\n", ATTR_QETH_ISOLATION_NONE); 413 + return sysfs_emit(buf, "%s\n", ATTR_QETH_ISOLATION_NONE); 414 414 case ISOLATION_MODE_FWD: 415 - return snprintf(buf, 9, "%s\n", ATTR_QETH_ISOLATION_FWD); 415 + return sysfs_emit(buf, "%s\n", ATTR_QETH_ISOLATION_FWD); 416 416 case ISOLATION_MODE_DROP: 417 - return snprintf(buf, 6, "%s\n", ATTR_QETH_ISOLATION_DROP); 417 + return sysfs_emit(buf, "%s\n", ATTR_QETH_ISOLATION_DROP); 418 418 default: 419 - return snprintf(buf, 5, "%s\n", "N/A"); 419 + return sysfs_emit(buf, "%s\n", "N/A"); 420 420 } 421 421 } 422 422 ··· 500 500 struct qeth_card *card = dev_get_drvdata(dev); 501 501 502 502 if (card->info.hwtrap) 503 - return snprintf(buf, 5, "arm\n"); 503 + return sysfs_emit(buf, "arm\n"); 504 504 else 505 - return snprintf(buf, 8, "disarm\n"); 505 + return sysfs_emit(buf, "disarm\n"); 506 506 } 507 507 508 508 static ssize_t qeth_hw_trap_store(struct device *dev,
+4
drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c
··· 172 172 RFIM_SHOW(rfi_restriction_run_busy, 1) 173 173 RFIM_SHOW(rfi_restriction_err_code, 1) 174 174 RFIM_SHOW(rfi_restriction_data_rate, 1) 175 + RFIM_SHOW(rfi_restriction_data_rate_base, 1) 175 176 RFIM_SHOW(ddr_data_rate_point_0, 1) 176 177 RFIM_SHOW(ddr_data_rate_point_1, 1) 177 178 RFIM_SHOW(ddr_data_rate_point_2, 1) ··· 182 181 RFIM_STORE(rfi_restriction_run_busy, 1) 183 182 RFIM_STORE(rfi_restriction_err_code, 1) 184 183 RFIM_STORE(rfi_restriction_data_rate, 1) 184 + RFIM_STORE(rfi_restriction_data_rate_base, 1) 185 185 RFIM_STORE(rfi_disable, 1) 186 186 187 187 static DEVICE_ATTR_RW(rfi_restriction_run_busy); 188 188 static DEVICE_ATTR_RW(rfi_restriction_err_code); 189 189 static DEVICE_ATTR_RW(rfi_restriction_data_rate); 190 + static DEVICE_ATTR_RW(rfi_restriction_data_rate_base); 190 191 static DEVICE_ATTR_RO(ddr_data_rate_point_0); 191 192 static DEVICE_ATTR_RO(ddr_data_rate_point_1); 192 193 static DEVICE_ATTR_RO(ddr_data_rate_point_2); ··· 251 248 &dev_attr_rfi_restriction_run_busy.attr, 252 249 &dev_attr_rfi_restriction_err_code.attr, 253 250 &dev_attr_rfi_restriction_data_rate.attr, 251 + &dev_attr_rfi_restriction_data_rate_base.attr, 254 252 &dev_attr_ddr_data_rate_point_0.attr, 255 253 &dev_attr_ddr_data_rate_point_1.attr, 256 254 &dev_attr_ddr_data_rate_point_2.attr,
+1 -1
drivers/usb/common/ulpi.c
··· 207 207 /* Test the interface */ 208 208 ret = ulpi_write(ulpi, ULPI_SCRATCH, 0xaa); 209 209 if (ret < 0) 210 - return ret; 210 + goto err; 211 211 212 212 ret = ulpi_read(ulpi, ULPI_SCRATCH); 213 213 if (ret < 0)
+1
drivers/usb/dwc3/dwc3-xilinx.c
··· 13 13 #include <linux/of.h> 14 14 #include <linux/platform_device.h> 15 15 #include <linux/dma-mapping.h> 16 + #include <linux/gpio/consumer.h> 16 17 #include <linux/of_gpio.h> 17 18 #include <linux/of_platform.h> 18 19 #include <linux/pm_runtime.h>
+4 -1
drivers/usb/dwc3/gadget.c
··· 1727 1727 else if (!ret) 1728 1728 dep->flags |= DWC3_EP_END_TRANSFER_PENDING; 1729 1729 1730 + dep->flags &= ~DWC3_EP_DELAY_STOP; 1730 1731 return ret; 1731 1732 } 1732 1733 ··· 3733 3732 if (dep->number <= 1 && dwc->ep0state != EP0_DATA_PHASE) 3734 3733 return; 3735 3734 3735 + if (interrupt && (dep->flags & DWC3_EP_DELAY_STOP)) 3736 + return; 3737 + 3736 3738 if (!(dep->flags & DWC3_EP_TRANSFER_STARTED) || 3737 - (dep->flags & DWC3_EP_DELAY_STOP) || 3738 3739 (dep->flags & DWC3_EP_END_TRANSFER_PENDING)) 3739 3740 return; 3740 3741
+1 -4
drivers/usb/fotg210/fotg210-core.c
··· 144 144 145 145 static int __init fotg210_init(void) 146 146 { 147 - if (usb_disabled()) 148 - return -ENODEV; 149 - 150 - if (IS_ENABLED(CONFIG_USB_FOTG210_HCD)) 147 + if (IS_ENABLED(CONFIG_USB_FOTG210_HCD) && !usb_disabled()) 151 148 fotg210_hcd_init(); 152 149 return platform_driver_register(&fotg210_driver); 153 150 }
+2
drivers/usb/fotg210/fotg210-udc.c
··· 1201 1201 dev_info(dev, "found and initialized PHY\n"); 1202 1202 } 1203 1203 1204 + ret = -ENOMEM; 1205 + 1204 1206 for (i = 0; i < FOTG210_MAX_NUM_EP; i++) { 1205 1207 fotg210->ep[i] = kzalloc(sizeof(struct fotg210_ep), GFP_KERNEL); 1206 1208 if (!fotg210->ep[i])
+3 -2
drivers/vdpa/mlx5/core/mlx5_vdpa.h
··· 116 116 int inlen); 117 117 int mlx5_vdpa_destroy_mkey(struct mlx5_vdpa_dev *mvdev, u32 mkey); 118 118 int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, 119 - bool *change_map); 120 - int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb); 119 + bool *change_map, unsigned int asid); 120 + int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, 121 + unsigned int asid); 121 122 void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev); 122 123 123 124 #define mlx5_vdpa_warn(__dev, format, ...) \
+26 -20
drivers/vdpa/mlx5/core/mr.c
··· 311 311 u64 st; 312 312 u64 sz; 313 313 int err; 314 - int i = 0; 315 314 316 315 st = start; 317 316 while (size) { ··· 335 336 mr->num_directs++; 336 337 mr->num_klms++; 337 338 st += sz; 338 - i++; 339 339 } 340 340 list_splice_tail(&tmp, &mr->head); 341 341 return 0; ··· 509 511 mutex_unlock(&mr->mkey_mtx); 510 512 } 511 513 512 - static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) 514 + static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, 515 + struct vhost_iotlb *iotlb, unsigned int asid) 513 516 { 514 517 struct mlx5_vdpa_mr *mr = &mvdev->mr; 515 518 int err; ··· 518 519 if (mr->initialized) 519 520 return 0; 520 521 521 - if (iotlb) 522 - err = create_user_mr(mvdev, iotlb); 523 - else 524 - err = create_dma_mr(mvdev, mr); 522 + if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid) { 523 + if (iotlb) 524 + err = create_user_mr(mvdev, iotlb); 525 + else 526 + err = create_dma_mr(mvdev, mr); 525 527 526 - if (err) 527 - return err; 528 + if (err) 529 + return err; 530 + } 528 531 529 - err = dup_iotlb(mvdev, iotlb); 530 - if (err) 531 - goto out_err; 532 + if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] == asid) { 533 + err = dup_iotlb(mvdev, iotlb); 534 + if (err) 535 + goto out_err; 536 + } 532 537 533 538 mr->initialized = true; 534 539 return 0; 535 540 536 541 out_err: 537 - if (iotlb) 538 - destroy_user_mr(mvdev, mr); 539 - else 540 - destroy_dma_mr(mvdev, mr); 542 + if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid) { 543 + if (iotlb) 544 + destroy_user_mr(mvdev, mr); 545 + else 546 + destroy_dma_mr(mvdev, mr); 547 + } 541 548 542 549 return err; 543 550 } 544 551 545 - int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) 552 + int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, 553 + unsigned int asid) 546 554 { 547 555 int err; 548 556 549 557 mutex_lock(&mvdev->mr.mkey_mtx); 550 - err = _mlx5_vdpa_create_mr(mvdev, iotlb); 558 + err = _mlx5_vdpa_create_mr(mvdev, iotlb, asid); 551 559 mutex_unlock(&mvdev->mr.mkey_mtx); 552 560 return err; 553 561 } 554 562 555 563 int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, 556 - bool *change_map) 564 + bool *change_map, unsigned int asid) 557 565 { 558 566 struct mlx5_vdpa_mr *mr = &mvdev->mr; 559 567 int err = 0; ··· 572 566 *change_map = true; 573 567 } 574 568 if (!*change_map) 575 - err = _mlx5_vdpa_create_mr(mvdev, iotlb); 569 + err = _mlx5_vdpa_create_mr(mvdev, iotlb, asid); 576 570 mutex_unlock(&mr->mkey_mtx); 577 571 578 572 return err;
+23 -55
drivers/vdpa/mlx5/net/mlx5_vnet.c
··· 1468 1468 dmac_v = MLX5_ADDR_OF(fte_match_param, headers_v, outer_headers.dmac_47_16); 1469 1469 eth_broadcast_addr(dmac_c); 1470 1470 ether_addr_copy(dmac_v, mac); 1471 - MLX5_SET(fte_match_set_lyr_2_4, headers_c, cvlan_tag, 1); 1471 + if (ndev->mvdev.actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VLAN)) { 1472 + MLX5_SET(fte_match_set_lyr_2_4, headers_c, cvlan_tag, 1); 1473 + MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, first_vid); 1474 + } 1472 1475 if (tagged) { 1473 1476 MLX5_SET(fte_match_set_lyr_2_4, headers_v, cvlan_tag, 1); 1474 - MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, first_vid); 1475 - MLX5_SET(fte_match_set_lyr_2_4, headers_c, first_vid, vid); 1477 + MLX5_SET(fte_match_set_lyr_2_4, headers_v, first_vid, vid); 1476 1478 } 1477 1479 flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; 1478 1480 dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR; ··· 1686 1684 1687 1685 /* Need recreate the flow table entry, so that the packet could forward back 1688 1686 */ 1689 - mac_vlan_del(ndev, ndev->config.mac, 0, false); 1687 + mac_vlan_del(ndev, mac_back, 0, false); 1690 1688 1691 1689 if (mac_vlan_add(ndev, ndev->config.mac, 0, false)) { 1692 1690 mlx5_vdpa_warn(mvdev, "failed to insert forward rules, try to restore\n"); ··· 1822 1820 __virtio16 vlan; 1823 1821 size_t read; 1824 1822 u16 id; 1823 + 1824 + if (!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VLAN))) 1825 + return status; 1825 1826 1826 1827 switch (cmd) { 1827 1828 case VIRTIO_NET_CTRL_VLAN_ADD: ··· 2394 2389 } 2395 2390 } 2396 2391 2397 - static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) 2392 + static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev, 2393 + struct vhost_iotlb *iotlb, unsigned int asid) 2398 2394 { 2399 2395 struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev); 2400 2396 int err; ··· 2407 2401 2408 2402 teardown_driver(ndev); 2409 2403 mlx5_vdpa_destroy_mr(mvdev); 2410 - err = mlx5_vdpa_create_mr(mvdev, iotlb); 2404 + err = mlx5_vdpa_create_mr(mvdev, iotlb, asid); 2411 2405 if (err) 2412 2406 goto err_mr; 2413 2407 ··· 2588 2582 ++mvdev->generation; 2589 2583 2590 2584 if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0)) { 2591 - if (mlx5_vdpa_create_mr(mvdev, NULL)) 2585 + if (mlx5_vdpa_create_mr(mvdev, NULL, 0)) 2592 2586 mlx5_vdpa_warn(mvdev, "create MR failed\n"); 2593 2587 } 2594 2588 up_write(&ndev->reslock); ··· 2624 2618 return mvdev->generation; 2625 2619 } 2626 2620 2627 - static int set_map_control(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) 2628 - { 2629 - u64 start = 0ULL, last = 0ULL - 1; 2630 - struct vhost_iotlb_map *map; 2631 - int err = 0; 2632 - 2633 - spin_lock(&mvdev->cvq.iommu_lock); 2634 - vhost_iotlb_reset(mvdev->cvq.iotlb); 2635 - 2636 - for (map = vhost_iotlb_itree_first(iotlb, start, last); map; 2637 - map = vhost_iotlb_itree_next(map, start, last)) { 2638 - err = vhost_iotlb_add_range(mvdev->cvq.iotlb, map->start, 2639 - map->last, map->addr, map->perm); 2640 - if (err) 2641 - goto out; 2642 - } 2643 - 2644 - out: 2645 - spin_unlock(&mvdev->cvq.iommu_lock); 2646 - return err; 2647 - } 2648 - 2649 - static int set_map_data(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) 2621 + static int set_map_data(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, 2622 + unsigned int asid) 2650 2623 { 2651 2624 bool change_map; 2652 2625 int err; 2653 2626 2654 - err = mlx5_vdpa_handle_set_map(mvdev, iotlb, &change_map); 2627 + err = mlx5_vdpa_handle_set_map(mvdev, iotlb, &change_map, asid); 2655 2628 if (err) { 2656 2629 mlx5_vdpa_warn(mvdev, "set map failed(%d)\n", err); 2657 2630 return err; 2658 2631 } 2659 2632 2660 2633 if (change_map) 2661 - err = mlx5_vdpa_change_map(mvdev, iotlb); 2634 + err = mlx5_vdpa_change_map(mvdev, iotlb, asid); 2662 2635 2663 2636 return err; 2664 2637 } ··· 2650 2665 int err = -EINVAL; 2651 2666 2652 2667 down_write(&ndev->reslock); 2653 - if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid) { 2654 - err = set_map_data(mvdev, iotlb); 2655 - if (err) 2656 - goto out; 2657 - } 2658 - 2659 - if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] == asid) 2660 - err = set_map_control(mvdev, iotlb); 2661 - 2662 - out: 2668 + err = set_map_data(mvdev, iotlb, asid); 2663 2669 up_write(&ndev->reslock); 2664 2670 return err; 2665 2671 } ··· 2816 2840 int i; 2817 2841 2818 2842 down_write(&ndev->reslock); 2819 - mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); 2820 2843 ndev->nb_registered = false; 2844 + mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); 2821 2845 flush_workqueue(ndev->mvdev.wq); 2822 2846 for (i = 0; i < ndev->cur_num_vqs; i++) { 2823 2847 mvq = &ndev->vqs[i]; ··· 2995 3019 else 2996 3020 ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, ~VIRTIO_NET_S_LINK_UP); 2997 3021 2998 - if (ndev->config_cb.callback) 3022 + if (ndev->nb_registered && ndev->config_cb.callback) 2999 3023 ndev->config_cb.callback(ndev->config_cb.private); 3000 3024 3001 3025 kfree(wqent); ··· 3012 3036 switch (eqe->sub_type) { 3013 3037 case MLX5_PORT_CHANGE_SUBTYPE_DOWN: 3014 3038 case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE: 3015 - down_read(&ndev->reslock); 3016 - if (!ndev->nb_registered) { 3017 - up_read(&ndev->reslock); 3018 - return NOTIFY_DONE; 3019 - } 3020 3039 wqent = kzalloc(sizeof(*wqent), GFP_ATOMIC); 3021 - if (!wqent) { 3022 - up_read(&ndev->reslock); 3040 + if (!wqent) 3023 3041 return NOTIFY_DONE; 3024 - } 3025 3042 3026 3043 wqent->mvdev = &ndev->mvdev; 3027 3044 INIT_WORK(&wqent->work, update_carrier); 3028 3045 queue_work(ndev->mvdev.wq, &wqent->work); 3029 - up_read(&ndev->reslock); 3030 3046 ret = NOTIFY_OK; 3031 3047 break; 3032 3048 default: ··· 3153 3185 goto err_mpfs; 3154 3186 3155 3187 if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0)) { 3156 - err = mlx5_vdpa_create_mr(mvdev, NULL); 3188 + err = mlx5_vdpa_create_mr(mvdev, NULL, 0); 3157 3189 if (err) 3158 3190 goto err_res; 3159 3191 } ··· 3205 3237 struct workqueue_struct *wq; 3206 3238 3207 3239 if (ndev->nb_registered) { 3208 - mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); 3209 3240 ndev->nb_registered = false; 3241 + mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); 3210 3242 } 3211 3243 wq = mvdev->wq; 3212 3244 mvdev->wq = NULL;
+5 -6
drivers/vdpa/vdpa.c
··· 855 855 856 856 features_device = vdev->config->get_device_features(vdev); 857 857 858 - if (nla_put_u64_64bit(msg, VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES, features_device, 858 + if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_FEATURES, features_device, 859 859 VDPA_ATTR_PAD)) 860 860 return -EMSGSIZE; 861 861 ··· 935 935 { 936 936 struct virtio_net_config config = {}; 937 937 u64 features; 938 - u16 max_vqp; 939 938 u8 status; 940 939 int err; 941 940 ··· 945 946 } 946 947 vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config)); 947 948 948 - max_vqp = __virtio16_to_cpu(true, config.max_virtqueue_pairs); 949 - if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, max_vqp)) 950 - return -EMSGSIZE; 951 - 952 949 features = vdev->config->get_driver_features(vdev); 953 950 if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_NEGOTIATED_FEATURES, 954 951 features, VDPA_ATTR_PAD)) 955 952 return -EMSGSIZE; 953 + 954 + err = vdpa_dev_net_mq_config_fill(msg, features, &config); 955 + if (err) 956 + return err; 956 957 957 958 if (nla_put_u32(msg, VDPA_ATTR_DEV_QUEUE_INDEX, index)) 958 959 return -EMSGSIZE;
+4 -3
drivers/vdpa/vdpa_sim/vdpa_sim.c
··· 67 67 { 68 68 struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx]; 69 69 70 - vringh_init_iotlb(&vq->vring, vdpasim->dev_attr.supported_features, 71 - VDPASIM_QUEUE_MAX, false, 70 + vringh_init_iotlb(&vq->vring, vdpasim->features, vq->num, false, 72 71 (struct vring_desc *)(uintptr_t)vq->desc_addr, 73 72 (struct vring_avail *) 74 73 (uintptr_t)vq->driver_addr, ··· 689 690 } 690 691 691 692 kvfree(vdpasim->buffer); 692 - vhost_iotlb_free(vdpasim->iommu); 693 + for (i = 0; i < vdpasim->dev_attr.nas; i++) 694 + vhost_iotlb_reset(&vdpasim->iommu[i]); 695 + kfree(vdpasim->iommu); 693 696 kfree(vdpasim->vqs); 694 697 kfree(vdpasim->config); 695 698 }
+3 -1
drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
··· 427 427 int ret; 428 428 429 429 ret = device_register(&vdpasim_blk_mgmtdev); 430 - if (ret) 430 + if (ret) { 431 + put_device(&vdpasim_blk_mgmtdev); 431 432 return ret; 433 + } 432 434 433 435 ret = vdpa_mgmtdev_register(&mgmt_dev); 434 436 if (ret)
+6 -1
drivers/vdpa/vdpa_sim/vdpa_sim_net.c
··· 62 62 if (len < ETH_ALEN + hdr_len) 63 63 return false; 64 64 65 + if (is_broadcast_ether_addr(vdpasim->buffer + hdr_len) || 66 + is_multicast_ether_addr(vdpasim->buffer + hdr_len)) 67 + return true; 65 68 if (!strncmp(vdpasim->buffer + hdr_len, vio_config->mac, ETH_ALEN)) 66 69 return true; 67 70 ··· 308 305 int ret; 309 306 310 307 ret = device_register(&vdpasim_net_mgmtdev); 311 - if (ret) 308 + if (ret) { 309 + put_device(&vdpasim_net_mgmtdev); 312 310 return ret; 311 + } 313 312 314 313 ret = vdpa_mgmtdev_register(&mgmt_dev); 315 314 if (ret)
+3
drivers/vdpa/vdpa_user/vduse_dev.c
··· 1440 1440 if (config->config_size > PAGE_SIZE) 1441 1441 return false; 1442 1442 1443 + if (config->vq_num > 0xffff) 1444 + return false; 1445 + 1443 1446 if (!device_is_allowed(config->device_id)) 1444 1447 return false; 1445 1448
+1 -1
drivers/vdpa/virtio_pci/vp_vdpa.c
··· 647 647 mdev = vp_vdpa_mgtdev->mdev; 648 648 vp_modern_remove(mdev); 649 649 vdpa_mgmtdev_unregister(&vp_vdpa_mgtdev->mgtdev); 650 - kfree(&vp_vdpa_mgtdev->mgtdev.id_table); 650 + kfree(vp_vdpa_mgtdev->mgtdev.id_table); 651 651 kfree(mdev); 652 652 kfree(vp_vdpa_mgtdev); 653 653 }
+31 -21
drivers/vhost/vdpa.c
··· 65 65 66 66 static dev_t vhost_vdpa_major; 67 67 68 + static void vhost_vdpa_iotlb_unmap(struct vhost_vdpa *v, 69 + struct vhost_iotlb *iotlb, u64 start, 70 + u64 last, u32 asid); 71 + 68 72 static inline u32 iotlb_to_asid(struct vhost_iotlb *iotlb) 69 73 { 70 74 struct vhost_vdpa_as *as = container_of(iotlb, struct ··· 139 135 return -EINVAL; 140 136 141 137 hlist_del(&as->hash_link); 142 - vhost_iotlb_reset(&as->iotlb); 138 + vhost_vdpa_iotlb_unmap(v, &as->iotlb, 0ULL, 0ULL - 1, asid); 143 139 kfree(as); 144 140 145 141 return 0; ··· 687 683 mutex_unlock(&d->mutex); 688 684 return r; 689 685 } 686 + static void vhost_vdpa_general_unmap(struct vhost_vdpa *v, 687 + struct vhost_iotlb_map *map, u32 asid) 688 + { 689 + struct vdpa_device *vdpa = v->vdpa; 690 + const struct vdpa_config_ops *ops = vdpa->config; 691 + if (ops->dma_map) { 692 + ops->dma_unmap(vdpa, asid, map->start, map->size); 693 + } else if (ops->set_map == NULL) { 694 + iommu_unmap(v->domain, map->start, map->size); 695 + } 696 + } 690 697 691 - static void vhost_vdpa_pa_unmap(struct vhost_vdpa *v, 692 - struct vhost_iotlb *iotlb, 693 - u64 start, u64 last) 698 + static void vhost_vdpa_pa_unmap(struct vhost_vdpa *v, struct vhost_iotlb *iotlb, 699 + u64 start, u64 last, u32 asid) 694 700 { 695 701 struct vhost_dev *dev = &v->vdev; 696 702 struct vhost_iotlb_map *map; ··· 717 703 unpin_user_page(page); 718 704 } 719 705 atomic64_sub(PFN_DOWN(map->size), &dev->mm->pinned_vm); 706 + vhost_vdpa_general_unmap(v, map, asid); 720 707 vhost_iotlb_map_free(iotlb, map); 721 708 } 722 709 } 723 710 724 - static void vhost_vdpa_va_unmap(struct vhost_vdpa *v, 725 - struct vhost_iotlb *iotlb, 726 - u64 start, u64 last) 711 + static void vhost_vdpa_va_unmap(struct vhost_vdpa *v, struct vhost_iotlb *iotlb, 712 + u64 start, u64 last, u32 asid) 727 713 { 728 714 struct vhost_iotlb_map *map; 729 715 struct vdpa_map_file *map_file; ··· 732 718 map_file = (struct vdpa_map_file *)map->opaque; 733 719 fput(map_file->file); 734 720 kfree(map_file); 721 + vhost_vdpa_general_unmap(v, map, asid); 735 722 vhost_iotlb_map_free(iotlb, map); 736 723 } 737 724 } 738 725 739 726 static void vhost_vdpa_iotlb_unmap(struct vhost_vdpa *v, 740 - struct vhost_iotlb *iotlb, 741 - u64 start, u64 last) 727 + struct vhost_iotlb *iotlb, u64 start, 728 + u64 last, u32 asid) 742 729 { 743 730 struct vdpa_device *vdpa = v->vdpa; 744 731 745 732 if (vdpa->use_va) 746 - return vhost_vdpa_va_unmap(v, iotlb, start, last); 733 + return vhost_vdpa_va_unmap(v, iotlb, start, last, asid); 747 734 748 - return vhost_vdpa_pa_unmap(v, iotlb, start, last); 735 + return vhost_vdpa_pa_unmap(v, iotlb, start, last, asid); 749 736 } 750 737 751 738 static int perm_to_iommu_flags(u32 perm) ··· 813 798 const struct vdpa_config_ops *ops = vdpa->config; 814 799 u32 asid = iotlb_to_asid(iotlb); 815 800 816 - vhost_vdpa_iotlb_unmap(v, iotlb, iova, iova + size - 1); 801 + vhost_vdpa_iotlb_unmap(v, iotlb, iova, iova + size - 1, asid); 817 802 818 - if (ops->dma_map) { 819 - ops->dma_unmap(vdpa, asid, iova, size); 820 - } else if (ops->set_map) { 803 + if (ops->set_map) { 821 804 if (!v->in_batch) 822 805 ops->set_map(vdpa, asid, iotlb); 823 - } else { 824 - iommu_unmap(v->domain, iova, size); 825 806 } 826 - 827 807 /* If we are in the middle of batch processing, delay the free 828 808 * of AS until BATCH_END. 829 809 */ ··· 1172 1162 struct vhost_vdpa_as *as; 1173 1163 u32 asid; 1174 1164 1175 - vhost_dev_cleanup(&v->vdev); 1176 - kfree(v->vdev.vqs); 1177 - 1178 1165 for (asid = 0; asid < v->vdpa->nas; asid++) { 1179 1166 as = asid_to_as(v, asid); 1180 1167 if (as) 1181 1168 vhost_vdpa_remove_as(v, asid); 1182 1169 } 1170 + 1171 + vhost_dev_cleanup(&v->vdev); 1172 + kfree(v->vdev.vqs); 1183 1173 } 1184 1174 1185 1175 static int vhost_vdpa_open(struct inode *inode, struct file *filep)
+2 -2
drivers/vhost/vhost.c
··· 2053 2053 struct vhost_dev *dev = vq->dev; 2054 2054 struct vhost_iotlb *umem = dev->iotlb ? dev->iotlb : dev->umem; 2055 2055 struct iovec *_iov; 2056 - u64 s = 0; 2056 + u64 s = 0, last = addr + len - 1; 2057 2057 int ret = 0; 2058 2058 2059 2059 while ((u64)len > s) { ··· 2063 2063 break; 2064 2064 } 2065 2065 2066 - map = vhost_iotlb_itree_first(umem, addr, addr + len - 1); 2066 + map = vhost_iotlb_itree_first(umem, addr, last); 2067 2067 if (map == NULL || map->start > addr) { 2068 2068 if (umem != dev->iotlb) { 2069 2069 ret = -EFAULT;
+2 -3
drivers/vhost/vringh.c
··· 1102 1102 struct vhost_iotlb_map *map; 1103 1103 struct vhost_iotlb *iotlb = vrh->iotlb; 1104 1104 int ret = 0; 1105 - u64 s = 0; 1105 + u64 s = 0, last = addr + len - 1; 1106 1106 1107 1107 spin_lock(vrh->iotlb_lock); 1108 1108 ··· 1114 1114 break; 1115 1115 } 1116 1116 1117 - map = vhost_iotlb_itree_first(iotlb, addr, 1118 - addr + len - 1); 1117 + map = vhost_iotlb_itree_first(iotlb, addr, last); 1119 1118 if (!map || map->start > addr) { 1120 1119 ret = -EINVAL; 1121 1120 break;
+8 -1
drivers/vhost/vsock.c
··· 959 959 VSOCK_TRANSPORT_F_H2G); 960 960 if (ret < 0) 961 961 return ret; 962 - return misc_register(&vhost_vsock_misc); 962 + 963 + ret = misc_register(&vhost_vsock_misc); 964 + if (ret) { 965 + vsock_core_unregister(&vhost_transport.transport); 966 + return ret; 967 + } 968 + 969 + return 0; 963 970 }; 964 971 965 972 static void __exit vhost_vsock_exit(void)
+2 -2
drivers/video/fbdev/Kconfig
··· 456 456 chipset found in Ataris. 457 457 458 458 config FB_OF 459 - bool "Open Firmware frame buffer device support" 460 - depends on (FB = y) && PPC && (!PPC_PSERIES || PCI) 459 + tristate "Open Firmware frame buffer device support" 460 + depends on FB && PPC && (!PPC_PSERIES || PCI) 461 461 depends on !DRM_OFDRM 462 462 select APERTURE_HELPERS 463 463 select FB_CFB_FILLRECT
+1 -2
drivers/video/fbdev/aty/atyfb_base.c
··· 3192 3192 * which we print to the screen. 3193 3193 */ 3194 3194 id = *(u8 *)par->lcd_table; 3195 - strncpy(model, (char *)par->lcd_table+1, 24); 3196 - model[23] = 0; 3195 + strscpy(model, (char *)par->lcd_table+1, sizeof(model)); 3197 3196 3198 3197 width = par->lcd_width = *(u16 *)(par->lcd_table+25); 3199 3198 height = par->lcd_height = *(u16 *)(par->lcd_table+27);
+2 -2
drivers/video/fbdev/matrox/matroxfb_base.c
··· 1378 1378 .lowlevel = &matrox_G100 1379 1379 }; 1380 1380 static struct video_board vbG200eW = { 1381 - .maxvram = 0x100000, 1382 - .maxdisplayable = 0x800000, 1381 + .maxvram = 0x1000000, 1382 + .maxdisplayable = 0x0800000, 1383 1383 .accelID = FB_ACCEL_MATROX_MGAG200, 1384 1384 .lowlevel = &matrox_G100 1385 1385 };
+2 -3
drivers/video/fbdev/omap/omapfb_main.c
··· 1447 1447 info->fbops = &omapfb_ops; 1448 1448 info->flags = FBINFO_FLAG_DEFAULT; 1449 1449 1450 - strncpy(fix->id, MODULE_NAME, sizeof(fix->id)); 1450 + strscpy(fix->id, MODULE_NAME, sizeof(fix->id)); 1451 1451 1452 1452 info->pseudo_palette = fbdev->pseudo_palette; 1453 1453 ··· 1573 1573 1574 1574 fbdev->ctrl = NULL; 1575 1575 1576 - strncpy(name, conf->lcd.ctrl_name, sizeof(name) - 1); 1577 - name[sizeof(name) - 1] = '\0'; 1576 + strscpy(name, conf->lcd.ctrl_name, sizeof(name)); 1578 1577 1579 1578 if (strcmp(name, "internal") == 0) { 1580 1579 fbdev->ctrl = fbdev->int_ctrl;
+18 -10
drivers/video/fbdev/omap2/omapfb/dss/dsi.c
··· 1536 1536 { 1537 1537 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); 1538 1538 unsigned long flags; 1539 - struct dsi_irq_stats stats; 1539 + struct dsi_irq_stats *stats; 1540 + 1541 + stats = kzalloc(sizeof(*stats), GFP_KERNEL); 1542 + if (!stats) { 1543 + seq_printf(s, "out of memory\n"); 1544 + return; 1545 + } 1540 1546 1541 1547 spin_lock_irqsave(&dsi->irq_stats_lock, flags); 1542 1548 1543 - stats = dsi->irq_stats; 1549 + *stats = dsi->irq_stats; 1544 1550 memset(&dsi->irq_stats, 0, sizeof(dsi->irq_stats)); 1545 1551 dsi->irq_stats.last_reset = jiffies; 1546 1552 1547 1553 spin_unlock_irqrestore(&dsi->irq_stats_lock, flags); 1548 1554 1549 1555 seq_printf(s, "period %u ms\n", 1550 - jiffies_to_msecs(jiffies - stats.last_reset)); 1556 + jiffies_to_msecs(jiffies - stats->last_reset)); 1551 1557 1552 - seq_printf(s, "irqs %d\n", stats.irq_count); 1558 + seq_printf(s, "irqs %d\n", stats->irq_count); 1553 1559 #define PIS(x) \ 1554 - seq_printf(s, "%-20s %10d\n", #x, stats.dsi_irqs[ffs(DSI_IRQ_##x)-1]) 1560 + seq_printf(s, "%-20s %10d\n", #x, stats->dsi_irqs[ffs(DSI_IRQ_##x)-1]) 1555 1561 1556 1562 seq_printf(s, "-- DSI%d interrupts --\n", dsi->module_id + 1); 1557 1563 PIS(VC0); ··· 1581 1575 1582 1576 #define PIS(x) \ 1583 1577 seq_printf(s, "%-20s %10d %10d %10d %10d\n", #x, \ 1584 - stats.vc_irqs[0][ffs(DSI_VC_IRQ_##x)-1], \ 1585 - stats.vc_irqs[1][ffs(DSI_VC_IRQ_##x)-1], \ 1586 - stats.vc_irqs[2][ffs(DSI_VC_IRQ_##x)-1], \ 1587 - stats.vc_irqs[3][ffs(DSI_VC_IRQ_##x)-1]); 1578 + stats->vc_irqs[0][ffs(DSI_VC_IRQ_##x)-1], \ 1579 + stats->vc_irqs[1][ffs(DSI_VC_IRQ_##x)-1], \ 1580 + stats->vc_irqs[2][ffs(DSI_VC_IRQ_##x)-1], \ 1581 + stats->vc_irqs[3][ffs(DSI_VC_IRQ_##x)-1]); 1588 1582 1589 1583 seq_printf(s, "-- VC interrupts --\n"); 1590 1584 PIS(CS); ··· 1600 1594 1601 1595 #define PIS(x) \ 1602 1596 seq_printf(s, "%-20s %10d\n", #x, \ 1603 - stats.cio_irqs[ffs(DSI_CIO_IRQ_##x)-1]); 1597 + stats->cio_irqs[ffs(DSI_CIO_IRQ_##x)-1]); 1604 1598 1605 1599 seq_printf(s, "-- CIO interrupts --\n"); 1606 1600 PIS(ERRSYNCESC1); ··· 1624 1618 PIS(ULPSACTIVENOT_ALL0); 1625 1619 PIS(ULPSACTIVENOT_ALL1); 1626 1620 #undef PIS 1621 + 1622 + kfree(stats); 1627 1623 } 1628 1624 1629 1625 static void dsi1_dump_irqs(struct seq_file *s)
+6 -6
drivers/virtio/virtio.c
··· 15 15 struct device_attribute *attr, char *buf) 16 16 { 17 17 struct virtio_device *dev = dev_to_virtio(_d); 18 - return sprintf(buf, "0x%04x\n", dev->id.device); 18 + return sysfs_emit(buf, "0x%04x\n", dev->id.device); 19 19 } 20 20 static DEVICE_ATTR_RO(device); 21 21 ··· 23 23 struct device_attribute *attr, char *buf) 24 24 { 25 25 struct virtio_device *dev = dev_to_virtio(_d); 26 - return sprintf(buf, "0x%04x\n", dev->id.vendor); 26 + return sysfs_emit(buf, "0x%04x\n", dev->id.vendor); 27 27 } 28 28 static DEVICE_ATTR_RO(vendor); 29 29 ··· 31 31 struct device_attribute *attr, char *buf) 32 32 { 33 33 struct virtio_device *dev = dev_to_virtio(_d); 34 - return sprintf(buf, "0x%08x\n", dev->config->get_status(dev)); 34 + return sysfs_emit(buf, "0x%08x\n", dev->config->get_status(dev)); 35 35 } 36 36 static DEVICE_ATTR_RO(status); 37 37 ··· 39 39 struct device_attribute *attr, char *buf) 40 40 { 41 41 struct virtio_device *dev = dev_to_virtio(_d); 42 - return sprintf(buf, "virtio:d%08Xv%08X\n", 42 + return sysfs_emit(buf, "virtio:d%08Xv%08X\n", 43 43 dev->id.device, dev->id.vendor); 44 44 } 45 45 static DEVICE_ATTR_RO(modalias); ··· 54 54 /* We actually represent this as a bitstring, as it could be 55 55 * arbitrary length in future. */ 56 56 for (i = 0; i < sizeof(dev->features)*8; i++) 57 - len += sprintf(buf+len, "%c", 57 + len += sysfs_emit_at(buf, len, "%c", 58 58 __virtio_test_bit(dev, i) ? '1' : '0'); 59 - len += sprintf(buf+len, "\n"); 59 + len += sysfs_emit_at(buf, len, "\n"); 60 60 return len; 61 61 } 62 62 static DEVICE_ATTR_RO(features);
+2 -2
drivers/virtio/virtio_pci_modern.c
··· 303 303 int err; 304 304 305 305 if (index >= vp_modern_get_num_queues(mdev)) 306 - return ERR_PTR(-ENOENT); 306 + return ERR_PTR(-EINVAL); 307 307 308 308 /* Check if queue is either not available or already active. */ 309 309 num = vp_modern_get_queue_size(mdev, index); 310 310 if (!num || vp_modern_get_queue_enable(mdev, index)) 311 311 return ERR_PTR(-ENOENT); 312 312 313 - if (num & (num - 1)) { 313 + if (!is_power_of_2(num)) { 314 314 dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", num); 315 315 return ERR_PTR(-EINVAL); 316 316 }
+1 -1
drivers/virtio/virtio_ring.c
··· 1052 1052 dma_addr_t dma_addr; 1053 1053 1054 1054 /* We assume num is a power of 2. */ 1055 - if (num & (num - 1)) { 1055 + if (!is_power_of_2(num)) { 1056 1056 dev_warn(&vdev->dev, "Bad virtqueue length %u\n", num); 1057 1057 return -EINVAL; 1058 1058 }
+4
fs/btrfs/backref.c
··· 484 484 u64 wanted_disk_byte = ref->wanted_disk_byte; 485 485 u64 count = 0; 486 486 u64 data_offset; 487 + u8 type; 487 488 488 489 if (level != 0) { 489 490 eb = path->nodes[level]; ··· 539 538 continue; 540 539 } 541 540 fi = btrfs_item_ptr(eb, slot, struct btrfs_file_extent_item); 541 + type = btrfs_file_extent_type(eb, fi); 542 + if (type == BTRFS_FILE_EXTENT_INLINE) 543 + goto next; 542 544 disk_byte = btrfs_file_extent_disk_bytenr(eb, fi); 543 545 data_offset = btrfs_file_extent_offset(eb, fi); 544 546
+10 -1
fs/btrfs/bio.c
··· 329 329 &map_length, &bioc, mirror_num); 330 330 if (ret) 331 331 goto out_counter_dec; 332 - BUG_ON(mirror_num != bioc->mirror_num); 332 + /* 333 + * This happens when dev-replace is also running, and the 334 + * mirror_num indicates the dev-replace target. 335 + * 336 + * In this case, we don't need to do anything, as the read 337 + * error just means the replace progress hasn't reached our 338 + * read range, and later replace routine would handle it well. 339 + */ 340 + if (mirror_num != bioc->mirror_num) 341 + goto out_counter_dec; 333 342 } 334 343 335 344 sector = bioc->stripes[bioc->mirror_num - 1].physical >> 9;
+4 -2
fs/btrfs/defrag.c
··· 358 358 goto out; 359 359 360 360 path = btrfs_alloc_path(); 361 - if (!path) 362 - return -ENOMEM; 361 + if (!path) { 362 + ret = -ENOMEM; 363 + goto out; 364 + } 363 365 364 366 level = btrfs_header_level(root->node); 365 367
+8 -3
fs/btrfs/disk-io.c
··· 530 530 } 531 531 532 532 if (found_level != check->level) { 533 + btrfs_err(fs_info, 534 + "level verify failed on logical %llu mirror %u wanted %u found %u", 535 + eb->start, eb->read_mirror, check->level, found_level); 533 536 ret = -EIO; 534 537 goto out; 535 538 } ··· 3384 3381 /* 3385 3382 * Do various sanity and dependency checks of different features. 3386 3383 * 3384 + * @is_rw_mount: If the mount is read-write. 3385 + * 3387 3386 * This is the place for less strict checks (like for subpage or artificial 3388 3387 * feature dependencies). 3389 3388 * ··· 3396 3391 * (space cache related) can modify on-disk format like free space tree and 3397 3392 * screw up certain feature dependencies. 3398 3393 */ 3399 - int btrfs_check_features(struct btrfs_fs_info *fs_info, struct super_block *sb) 3394 + int btrfs_check_features(struct btrfs_fs_info *fs_info, bool is_rw_mount) 3400 3395 { 3401 3396 struct btrfs_super_block *disk_super = fs_info->super_copy; 3402 3397 u64 incompat = btrfs_super_incompat_flags(disk_super); ··· 3435 3430 if (btrfs_super_nodesize(disk_super) > PAGE_SIZE) 3436 3431 incompat |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA; 3437 3432 3438 - if (compat_ro_unsupp && !sb_rdonly(sb)) { 3433 + if (compat_ro_unsupp && is_rw_mount) { 3439 3434 btrfs_err(fs_info, 3440 3435 "cannot mount read-write because of unknown compat_ro features (0x%llx)", 3441 3436 compat_ro); ··· 3638 3633 goto fail_alloc; 3639 3634 } 3640 3635 3641 - ret = btrfs_check_features(fs_info, sb); 3636 + ret = btrfs_check_features(fs_info, !sb_rdonly(sb)); 3642 3637 if (ret < 0) { 3643 3638 err = ret; 3644 3639 goto fail_alloc;
+1 -1
fs/btrfs/disk-io.h
··· 50 50 void __cold close_ctree(struct btrfs_fs_info *fs_info); 51 51 int btrfs_validate_super(struct btrfs_fs_info *fs_info, 52 52 struct btrfs_super_block *sb, int mirror_num); 53 - int btrfs_check_features(struct btrfs_fs_info *fs_info, struct super_block *sb); 53 + int btrfs_check_features(struct btrfs_fs_info *fs_info, bool is_rw_mount); 54 54 int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors); 55 55 struct btrfs_super_block *btrfs_read_dev_super(struct block_device *bdev); 56 56 struct btrfs_super_block *btrfs_read_dev_one_super(struct block_device *bdev,
+1 -1
fs/btrfs/extent-io-tree.c
··· 1551 1551 u64 last = 0; 1552 1552 int found = 0; 1553 1553 1554 - if (WARN_ON(search_end <= cur_start)) 1554 + if (WARN_ON(search_end < cur_start)) 1555 1555 return 0; 1556 1556 1557 1557 spin_lock(&tree->lock);
+5 -2
fs/btrfs/extent-tree.c
··· 1713 1713 BUG(); 1714 1714 if (ret && insert_reserved) 1715 1715 btrfs_pin_extent(trans, node->bytenr, node->num_bytes, 1); 1716 + if (ret < 0) 1717 + btrfs_err(trans->fs_info, 1718 + "failed to run delayed ref for logical %llu num_bytes %llu type %u action %u ref_mod %d: %d", 1719 + node->bytenr, node->num_bytes, node->type, 1720 + node->action, node->ref_mod, ret); 1716 1721 return ret; 1717 1722 } 1718 1723 ··· 1959 1954 if (ret) { 1960 1955 unselect_delayed_ref_head(delayed_refs, locked_ref); 1961 1956 btrfs_put_delayed_ref(ref); 1962 - btrfs_debug(fs_info, "run_one_delayed_ref returned %d", 1963 - ret); 1964 1957 return ret; 1965 1958 } 1966 1959
+25 -5
fs/btrfs/extent_io.c
··· 104 104 btrfs_bio_end_io_t end_io_func; 105 105 106 106 /* 107 + * This is for metadata read, to provide the extra needed verification 108 + * info. This has to be provided for submit_one_bio(), as 109 + * submit_one_bio() can submit a bio if it ends at stripe boundary. If 110 + * no such parent_check is provided, the metadata can hit false alert at 111 + * endio time. 112 + */ 113 + struct btrfs_tree_parent_check *parent_check; 114 + 115 + /* 107 116 * Tell writepage not to lock the state bits for this range, it still 108 117 * does the unlocking. 109 118 */ ··· 142 133 143 134 btrfs_bio(bio)->file_offset = page_offset(bv->bv_page) + bv->bv_offset; 144 135 145 - if (!is_data_inode(&inode->vfs_inode)) 136 + if (!is_data_inode(&inode->vfs_inode)) { 137 + if (btrfs_op(bio) != BTRFS_MAP_WRITE) { 138 + /* 139 + * For metadata read, we should have the parent_check, 140 + * and copy it to bbio for metadata verification. 141 + */ 142 + ASSERT(bio_ctrl->parent_check); 143 + memcpy(&btrfs_bio(bio)->parent_check, 144 + bio_ctrl->parent_check, 145 + sizeof(struct btrfs_tree_parent_check)); 146 + } 146 147 btrfs_submit_metadata_bio(inode, bio, mirror_num); 147 - else if (btrfs_op(bio) == BTRFS_MAP_WRITE) 148 + } else if (btrfs_op(bio) == BTRFS_MAP_WRITE) { 148 149 btrfs_submit_data_write_bio(inode, bio, mirror_num); 149 - else 150 + } else { 150 151 btrfs_submit_data_read_bio(inode, bio, mirror_num, 151 152 bio_ctrl->compress_type); 153 + } 152 154 153 155 /* The bio is owned by the end_io handler now */ 154 156 bio_ctrl->bio = NULL; ··· 4849 4829 struct extent_state *cached_state = NULL; 4850 4830 struct btrfs_bio_ctrl bio_ctrl = { 4851 4831 .mirror_num = mirror_num, 4832 + .parent_check = check, 4852 4833 }; 4853 4834 int ret = 0; 4854 4835 ··· 4899 4878 */ 4900 4879 atomic_dec(&eb->io_pages); 4901 4880 } 4902 - memcpy(&btrfs_bio(bio_ctrl.bio)->parent_check, check, sizeof(*check)); 4903 4881 submit_one_bio(&bio_ctrl); 4904 4882 if (ret || wait != WAIT_COMPLETE) { 4905 4883 free_extent_state(cached_state); ··· 4925 4905 unsigned long num_reads = 0; 4926 4906 struct btrfs_bio_ctrl bio_ctrl = { 4927 4907 .mirror_num = mirror_num, 4908 + .parent_check = check, 4928 4909 }; 4929 4910 4930 4911 if (test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags)) ··· 5017 4996 } 5018 4997 } 5019 4998 5020 - memcpy(&btrfs_bio(bio_ctrl.bio)->parent_check, check, sizeof(*check)); 5021 4999 submit_one_bio(&bio_ctrl); 5022 5000 5023 5001 if (ret || wait != WAIT_COMPLETE)
+1 -1
fs/btrfs/file.c
··· 3354 3354 bool search_io_tree = true; 3355 3355 bool ret = false; 3356 3356 3357 - while (cur_offset < end) { 3357 + while (cur_offset <= end) { 3358 3358 u64 delalloc_start; 3359 3359 u64 delalloc_end; 3360 3360 bool delalloc;
+5 -3
fs/btrfs/inode.c
··· 7092 7092 * Other members are not utilized for inline extents. 7093 7093 */ 7094 7094 ASSERT(em->block_start == EXTENT_MAP_INLINE); 7095 - ASSERT(em->len = fs_info->sectorsize); 7095 + ASSERT(em->len == fs_info->sectorsize); 7096 7096 7097 7097 ret = read_inline_extent(inode, path, page); 7098 7098 if (ret < 0) ··· 9377 9377 9378 9378 if (flags & RENAME_WHITEOUT) { 9379 9379 whiteout_args.inode = new_whiteout_inode(mnt_userns, old_dir); 9380 - if (!whiteout_args.inode) 9381 - return -ENOMEM; 9380 + if (!whiteout_args.inode) { 9381 + ret = -ENOMEM; 9382 + goto out_fscrypt_names; 9383 + } 9382 9384 ret = btrfs_new_inode_prepare(&whiteout_args, &trans_num_items); 9383 9385 if (ret) 9384 9386 goto out_whiteout_inode;
+1
fs/btrfs/qgroup.c
··· 2787 2787 * current root. It's safe inside commit_transaction(). 2788 2788 */ 2789 2789 ctx.trans = trans; 2790 + ctx.time_seq = BTRFS_SEQ_LAST; 2790 2791 ret = btrfs_find_all_roots(&ctx, false); 2791 2792 if (ret < 0) 2792 2793 goto cleanup;
+1 -1
fs/btrfs/raid56.c
··· 2646 2646 void **pointers = NULL; 2647 2647 void **unmap_array = NULL; 2648 2648 int sector_nr; 2649 - int ret; 2649 + int ret = 0; 2650 2650 2651 2651 /* 2652 2652 * @pointers array stores the pointer for each sector.
+2 -1
fs/btrfs/super.c
··· 1705 1705 if (ret) 1706 1706 goto restore; 1707 1707 1708 - ret = btrfs_check_features(fs_info, sb); 1708 + ret = btrfs_check_features(fs_info, !(*flags & SB_RDONLY)); 1709 1709 if (ret < 0) 1710 1710 goto restore; 1711 1711 ··· 2514 2514 static void __exit exit_btrfs_fs(void) 2515 2515 { 2516 2516 btrfs_exit_btrfs_fs(); 2517 + btrfs_cleanup_fs_uuids(); 2517 2518 } 2518 2519 2519 2520 static int __init init_btrfs_fs(void)
+4 -1
fs/btrfs/tree-log.c
··· 7459 7459 * not fail, but if it does, it's not serious, just bail out and 7460 7460 * mark the log for a full commit. 7461 7461 */ 7462 - if (WARN_ON_ONCE(ret < 0)) 7462 + if (WARN_ON_ONCE(ret < 0)) { 7463 + fscrypt_free_filename(&fname); 7463 7464 goto out; 7465 + } 7466 + 7464 7467 log_pinned = true; 7465 7468 7466 7469 path = btrfs_alloc_path();
+1 -1
fs/ceph/caps.c
··· 2913 2913 2914 2914 while (true) { 2915 2915 flags &= CEPH_FILE_MODE_MASK; 2916 - if (atomic_read(&fi->num_locks)) 2916 + if (vfs_inode_has_locks(inode)) 2917 2917 flags |= CHECK_FILELOCK; 2918 2918 _got = 0; 2919 2919 ret = try_get_cap_refs(inode, need, want, endoff,
+18 -6
fs/ceph/locks.c
··· 32 32 33 33 static void ceph_fl_copy_lock(struct file_lock *dst, struct file_lock *src) 34 34 { 35 - struct ceph_file_info *fi = dst->fl_file->private_data; 36 35 struct inode *inode = file_inode(dst->fl_file); 37 36 atomic_inc(&ceph_inode(inode)->i_filelock_ref); 38 - atomic_inc(&fi->num_locks); 37 + dst->fl_u.ceph.inode = igrab(inode); 39 38 } 40 39 40 + /* 41 + * Do not use the 'fl->fl_file' in release function, which 42 + * is possibly already released by another thread. 43 + */ 41 44 static void ceph_fl_release_lock(struct file_lock *fl) 42 45 { 43 - struct ceph_file_info *fi = fl->fl_file->private_data; 44 - struct inode *inode = file_inode(fl->fl_file); 45 - struct ceph_inode_info *ci = ceph_inode(inode); 46 - atomic_dec(&fi->num_locks); 46 + struct inode *inode = fl->fl_u.ceph.inode; 47 + struct ceph_inode_info *ci; 48 + 49 + /* 50 + * If inode is NULL it should be a request file_lock, 51 + * nothing we can do. 52 + */ 53 + if (!inode) 54 + return; 55 + 56 + ci = ceph_inode(inode); 47 57 if (atomic_dec_and_test(&ci->i_filelock_ref)) { 48 58 /* clear error when all locks are released */ 49 59 spin_lock(&ci->i_ceph_lock); 50 60 ci->i_ceph_flags &= ~CEPH_I_ERROR_FILELOCK; 51 61 spin_unlock(&ci->i_ceph_lock); 52 62 } 63 + fl->fl_u.ceph.inode = NULL; 64 + iput(inode); 53 65 } 54 66 55 67 static const struct file_lock_operations ceph_fl_lock_ops = {
-1
fs/ceph/super.h
··· 790 790 struct list_head rw_contexts; 791 791 792 792 u32 filp_gen; 793 - atomic_t num_locks; 794 793 }; 795 794 796 795 struct ceph_dir_file_info {
+12 -13
fs/cifs/dfs.c
··· 327 327 return rc; 328 328 } 329 329 330 - static int target_share_matches_server(struct TCP_Server_Info *server, const char *tcp_host, 331 - size_t tcp_host_len, char *share, bool *target_match) 330 + static int target_share_matches_server(struct TCP_Server_Info *server, char *share, 331 + bool *target_match) 332 332 { 333 333 int rc = 0; 334 334 const char *dfs_host; ··· 338 338 extract_unc_hostname(share, &dfs_host, &dfs_host_len); 339 339 340 340 /* Check if hostnames or addresses match */ 341 - if (dfs_host_len != tcp_host_len || strncasecmp(dfs_host, tcp_host, dfs_host_len) != 0) { 342 - cifs_dbg(FYI, "%s: %.*s doesn't match %.*s\n", __func__, (int)dfs_host_len, 343 - dfs_host, (int)tcp_host_len, tcp_host); 341 + cifs_server_lock(server); 342 + if (dfs_host_len != strlen(server->hostname) || 343 + strncasecmp(dfs_host, server->hostname, dfs_host_len)) { 344 + cifs_dbg(FYI, "%s: %.*s doesn't match %s\n", __func__, 345 + (int)dfs_host_len, dfs_host, server->hostname); 344 346 rc = match_target_ip(server, dfs_host, dfs_host_len, target_match); 345 347 if (rc) 346 348 cifs_dbg(VFS, "%s: failed to match target ip: %d\n", __func__, rc); 347 349 } 350 + cifs_server_unlock(server); 348 351 return rc; 349 352 } 350 353 ··· 361 358 struct cifs_ses *root_ses = CIFS_DFS_ROOT_SES(tcon->ses); 362 359 struct cifs_tcon *ipc = root_ses->tcon_ipc; 363 360 char *share = NULL, *prefix = NULL; 364 - const char *tcp_host; 365 - size_t tcp_host_len; 366 361 struct dfs_cache_tgt_iterator *tit; 367 362 bool target_match; 368 - 369 - extract_unc_hostname(server->hostname, &tcp_host, &tcp_host_len); 370 363 371 364 tit = dfs_cache_get_tgt_iterator(tl); 372 365 if (!tit) { ··· 386 387 break; 387 388 } 388 389 389 - rc = target_share_matches_server(server, tcp_host, tcp_host_len, share, 390 - &target_match); 390 + rc = target_share_matches_server(server, share, &target_match); 391 391 if (rc) 392 392 break; 393 393 if (!target_match) { ··· 399 401 if (ipc->need_reconnect) { 400 402 scnprintf(tree, MAX_TREE_SIZE, "\\\\%s\\IPC$", server->hostname); 401 403 rc = ops->tree_connect(xid, ipc->ses, tree, ipc, cifs_sb->local_nls); 402 - if (rc) 403 - break; 404 + cifs_dbg(FYI, "%s: reconnect ipc: %d\n", __func__, rc); 404 405 } 405 406 406 407 scnprintf(tree, MAX_TREE_SIZE, "\\%s", share); ··· 495 498 } 496 499 497 500 if (tcon->ipc) { 501 + cifs_server_lock(server); 498 502 scnprintf(tree, MAX_TREE_SIZE, "\\\\%s\\IPC$", server->hostname); 503 + cifs_server_unlock(server); 499 504 rc = ops->tree_connect(xid, tcon->ses, tree, tcon, nlsc); 500 505 goto out; 501 506 }
+2
fs/cifs/misc.c
··· 1277 1277 if (rc < 0) 1278 1278 return rc; 1279 1279 1280 + spin_lock(&server->srv_lock); 1280 1281 *result = cifs_match_ipaddr((struct sockaddr *)&server->dstaddr, (struct sockaddr *)&ss); 1282 + spin_unlock(&server->srv_lock); 1281 1283 cifs_dbg(FYI, "%s: ip addresses match: %u\n", __func__, *result); 1282 1284 return 0; 1283 1285 }
+2 -1
fs/cifs/sess.c
··· 292 292 continue; 293 293 } 294 294 kref_get(&iface->refcount); 295 + break; 295 296 } 296 297 297 - if (!list_entry_is_head(iface, &ses->iface_list, iface_head)) { 298 + if (list_entry_is_head(iface, &ses->iface_list, iface_head)) { 298 299 rc = 1; 299 300 iface = NULL; 300 301 cifs_dbg(FYI, "unable to find a suitable iface\n");
+4 -8
fs/cifs/smb2ops.c
··· 530 530 p = buf; 531 531 532 532 spin_lock(&ses->iface_lock); 533 - ses->iface_count = 0; 534 533 /* 535 534 * Go through iface_list and do kref_put to remove 536 535 * any unused ifaces. ifaces in use will be removed ··· 539 540 iface_head) { 540 541 iface->is_active = 0; 541 542 kref_put(&iface->refcount, release_iface); 543 + ses->iface_count--; 542 544 } 543 545 spin_unlock(&ses->iface_lock); 544 546 ··· 618 618 /* just get a ref so that it doesn't get picked/freed */ 619 619 iface->is_active = 1; 620 620 kref_get(&iface->refcount); 621 + ses->iface_count++; 621 622 spin_unlock(&ses->iface_lock); 622 623 goto next_iface; 623 624 } else if (ret < 0) { ··· 4489 4488 4490 4489 /* copy pages form the old */ 4491 4490 for (j = 0; j < npages; j++) { 4492 - char *dst, *src; 4493 4491 unsigned int offset, len; 4494 4492 4495 4493 rqst_page_get_length(new, j, &len, &offset); 4496 4494 4497 - dst = kmap_local_page(new->rq_pages[j]) + offset; 4498 - src = kmap_local_page(old->rq_pages[j]) + offset; 4499 - 4500 - memcpy(dst, src, len); 4501 - kunmap(new->rq_pages[j]); 4502 - kunmap(old->rq_pages[j]); 4495 + memcpy_page(new->rq_pages[j], offset, 4496 + old->rq_pages[j], offset, len); 4503 4497 } 4504 4498 } 4505 4499
+7 -4
fs/cifs/smb2pdu.c
··· 541 541 assemble_neg_contexts(struct smb2_negotiate_req *req, 542 542 struct TCP_Server_Info *server, unsigned int *total_len) 543 543 { 544 - char *pneg_ctxt; 545 - char *hostname = NULL; 546 544 unsigned int ctxt_len, neg_context_count; 545 + struct TCP_Server_Info *pserver; 546 + char *pneg_ctxt; 547 + char *hostname; 547 548 548 549 if (*total_len > 200) { 549 550 /* In case length corrupted don't want to overrun smb buffer */ ··· 575 574 * secondary channels don't have the hostname field populated 576 575 * use the hostname field in the primary channel instead 577 576 */ 578 - hostname = CIFS_SERVER_IS_CHAN(server) ? 579 - server->primary_server->hostname : server->hostname; 577 + pserver = CIFS_SERVER_IS_CHAN(server) ? server->primary_server : server; 578 + cifs_server_lock(pserver); 579 + hostname = pserver->hostname; 580 580 if (hostname && (hostname[0] != 0)) { 581 581 ctxt_len = build_netname_ctxt((struct smb2_netname_neg_context *)pneg_ctxt, 582 582 hostname); ··· 586 584 neg_context_count = 3; 587 585 } else 588 586 neg_context_count = 2; 587 + cifs_server_unlock(pserver); 589 588 590 589 build_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt); 591 590 *total_len += sizeof(struct smb2_posix_neg_context);
+1 -1
fs/f2fs/data.c
··· 2183 2183 sector_t last_block_in_file; 2184 2184 const unsigned blocksize = blks_to_bytes(inode, 1); 2185 2185 struct decompress_io_ctx *dic = NULL; 2186 - struct extent_info ei = {0, }; 2186 + struct extent_info ei = {}; 2187 2187 bool from_dnode = true; 2188 2188 int i; 2189 2189 int ret = 0;
+18 -16
fs/f2fs/extent_cache.c
··· 546 546 struct extent_node *en; 547 547 bool ret = false; 548 548 549 - f2fs_bug_on(sbi, !et); 549 + if (!et) 550 + return false; 550 551 551 552 trace_f2fs_lookup_extent_tree_start(inode, pgofs, type); 552 553 ··· 882 881 } 883 882 884 883 /* This returns a new age and allocated blocks in ei */ 885 - static int __get_new_block_age(struct inode *inode, struct extent_info *ei) 884 + static int __get_new_block_age(struct inode *inode, struct extent_info *ei, 885 + block_t blkaddr) 886 886 { 887 887 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 888 888 loff_t f_size = i_size_read(inode); 889 889 unsigned long long cur_blocks = 890 890 atomic64_read(&sbi->allocated_data_blocks); 891 + struct extent_info tei = *ei; /* only fofs and len are valid */ 891 892 892 893 /* 893 894 * When I/O is not aligned to a PAGE_SIZE, update will happen to the last ··· 897 894 * block here. 898 895 */ 899 896 if ((f_size >> PAGE_SHIFT) == ei->fofs && f_size & (PAGE_SIZE - 1) && 900 - ei->blk == NEW_ADDR) 897 + blkaddr == NEW_ADDR) 901 898 return -EINVAL; 902 899 903 - if (__lookup_extent_tree(inode, ei->fofs, ei, EX_BLOCK_AGE)) { 900 + if (__lookup_extent_tree(inode, ei->fofs, &tei, EX_BLOCK_AGE)) { 904 901 unsigned long long cur_age; 905 902 906 - if (cur_blocks >= ei->last_blocks) 907 - cur_age = cur_blocks - ei->last_blocks; 903 + if (cur_blocks >= tei.last_blocks) 904 + cur_age = cur_blocks - tei.last_blocks; 908 905 else 909 906 /* allocated_data_blocks overflow */ 910 - cur_age = ULLONG_MAX - ei->last_blocks + cur_blocks; 907 + cur_age = ULLONG_MAX - tei.last_blocks + cur_blocks; 911 908 912 - if (ei->age) 913 - ei->age = __calculate_block_age(cur_age, ei->age); 909 + if (tei.age) 910 + ei->age = __calculate_block_age(cur_age, tei.age); 914 911 else 915 912 ei->age = cur_age; 916 913 ei->last_blocks = cur_blocks; ··· 918 915 return 0; 919 916 } 920 917 921 - f2fs_bug_on(sbi, ei->blk == NULL_ADDR); 918 + f2fs_bug_on(sbi, blkaddr == NULL_ADDR); 922 919 923 920 /* the data block was allocated for the first time */ 924 - if (ei->blk == NEW_ADDR) 921 + if (blkaddr == NEW_ADDR) 925 922 goto out; 926 923 927 - if (__is_valid_data_blkaddr(ei->blk) && 928 - !f2fs_is_valid_blkaddr(sbi, ei->blk, DATA_GENERIC_ENHANCE)) { 924 + if (__is_valid_data_blkaddr(blkaddr) && 925 + !f2fs_is_valid_blkaddr(sbi, blkaddr, DATA_GENERIC_ENHANCE)) { 929 926 f2fs_bug_on(sbi, 1); 930 927 return -EINVAL; 931 928 } ··· 941 938 942 939 static void __update_extent_cache(struct dnode_of_data *dn, enum extent_type type) 943 940 { 944 - struct extent_info ei; 941 + struct extent_info ei = {}; 945 942 946 943 if (!__may_extent_tree(dn->inode, type)) 947 944 return; ··· 956 953 else 957 954 ei.blk = dn->data_blkaddr; 958 955 } else if (type == EX_BLOCK_AGE) { 959 - ei.blk = dn->data_blkaddr; 960 - if (__get_new_block_age(dn->inode, &ei)) 956 + if (__get_new_block_age(dn->inode, &ei, dn->data_blkaddr)) 961 957 return; 962 958 } 963 959 __update_extent_tree_range(dn->inode, &ei, type);
+1 -1
fs/f2fs/file.c
··· 2559 2559 struct f2fs_map_blocks map = { .m_next_extent = NULL, 2560 2560 .m_seg_type = NO_CHECK_TYPE, 2561 2561 .m_may_create = false }; 2562 - struct extent_info ei = {0, }; 2562 + struct extent_info ei = {}; 2563 2563 pgoff_t pg_start, pg_end, next_pgofs; 2564 2564 unsigned int blk_per_seg = sbi->blocks_per_seg; 2565 2565 unsigned int total = 0, sec_num;
+5 -8
fs/f2fs/segment.c
··· 663 663 if (IS_ERR(fcc->f2fs_issue_flush)) { 664 664 int err = PTR_ERR(fcc->f2fs_issue_flush); 665 665 666 - kfree(fcc); 667 - SM_I(sbi)->fcc_info = NULL; 666 + fcc->f2fs_issue_flush = NULL; 668 667 return err; 669 668 } 670 669 ··· 3160 3161 static int __get_age_segment_type(struct inode *inode, pgoff_t pgofs) 3161 3162 { 3162 3163 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 3163 - struct extent_info ei; 3164 + struct extent_info ei = {}; 3164 3165 3165 3166 if (f2fs_lookup_age_extent_cache(inode, pgofs, &ei)) { 3166 3167 if (!ei.age) ··· 5137 5138 5138 5139 init_f2fs_rwsem(&sm_info->curseg_lock); 5139 5140 5140 - if (!f2fs_readonly(sbi->sb)) { 5141 - err = f2fs_create_flush_cmd_control(sbi); 5142 - if (err) 5143 - return err; 5144 - } 5141 + err = f2fs_create_flush_cmd_control(sbi); 5142 + if (err) 5143 + return err; 5145 5144 5146 5145 err = create_discard_cmd_control(sbi); 5147 5146 if (err)
+10 -5
fs/hfs/inode.c
··· 458 458 /* panic? */ 459 459 return -EIO; 460 460 461 + res = -EIO; 461 462 if (HFS_I(main_inode)->cat_key.CName.len > HFS_NAMELEN) 462 - return -EIO; 463 + goto out; 463 464 fd.search_key->cat = HFS_I(main_inode)->cat_key; 464 465 if (hfs_brec_find(&fd)) 465 - /* panic? */ 466 466 goto out; 467 467 468 468 if (S_ISDIR(main_inode->i_mode)) { 469 - WARN_ON(fd.entrylength < sizeof(struct hfs_cat_dir)); 469 + if (fd.entrylength < sizeof(struct hfs_cat_dir)) 470 + goto out; 470 471 hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, 471 472 sizeof(struct hfs_cat_dir)); 472 473 if (rec.type != HFS_CDR_DIR || ··· 480 479 hfs_bnode_write(fd.bnode, &rec, fd.entryoffset, 481 480 sizeof(struct hfs_cat_dir)); 482 481 } else if (HFS_IS_RSRC(inode)) { 482 + if (fd.entrylength < sizeof(struct hfs_cat_file)) 483 + goto out; 483 484 hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, 484 485 sizeof(struct hfs_cat_file)); 485 486 hfs_inode_write_fork(inode, rec.file.RExtRec, ··· 489 486 hfs_bnode_write(fd.bnode, &rec, fd.entryoffset, 490 487 sizeof(struct hfs_cat_file)); 491 488 } else { 492 - WARN_ON(fd.entrylength < sizeof(struct hfs_cat_file)); 489 + if (fd.entrylength < sizeof(struct hfs_cat_file)) 490 + goto out; 493 491 hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, 494 492 sizeof(struct hfs_cat_file)); 495 493 if (rec.type != HFS_CDR_FIL || ··· 507 503 hfs_bnode_write(fd.bnode, &rec, fd.entryoffset, 508 504 sizeof(struct hfs_cat_file)); 509 505 } 506 + res = 0; 510 507 out: 511 508 hfs_find_exit(&fd); 512 - return 0; 509 + return res; 513 510 } 514 511 515 512 static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry,
+6 -1
fs/nfs/dir.c
··· 2957 2957 const struct cred *cred) 2958 2958 { 2959 2959 const struct task_struct *parent; 2960 + const struct cred *pcred; 2960 2961 u64 ret; 2961 2962 2962 2963 rcu_read_lock(); 2963 2964 for (;;) { 2964 2965 parent = rcu_dereference(task->real_parent); 2965 - if (parent == task || cred_fscmp(parent->cred, cred) != 0) 2966 + pcred = rcu_dereference(parent->cred); 2967 + if (parent == task || cred_fscmp(pcred, cred) != 0) 2966 2968 break; 2967 2969 task = parent; 2968 2970 } ··· 3025 3023 * but do it without locking. 3026 3024 */ 3027 3025 struct nfs_inode *nfsi = NFS_I(inode); 3026 + u64 login_time = nfs_access_login_time(current, cred); 3028 3027 struct nfs_access_entry *cache; 3029 3028 int err = -ECHILD; 3030 3029 struct list_head *lh; ··· 3039 3036 access_cmp(cred, cache) != 0) 3040 3037 cache = NULL; 3041 3038 if (cache == NULL) 3039 + goto out; 3040 + if ((s64)(login_time - cache->timestamp) > 0) 3042 3041 goto out; 3043 3042 if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS)) 3044 3043 goto out;
+8
fs/nfs/filelayout/filelayout.c
··· 783 783 return &fl->generic_hdr; 784 784 } 785 785 786 + static bool 787 + filelayout_lseg_is_striped(const struct nfs4_filelayout_segment *flseg) 788 + { 789 + return flseg->num_fh > 1; 790 + } 791 + 786 792 /* 787 793 * filelayout_pg_test(). Called by nfs_can_coalesce_requests() 788 794 * ··· 809 803 size = pnfs_generic_pg_test(pgio, prev, req); 810 804 if (!size) 811 805 return 0; 806 + else if (!filelayout_lseg_is_striped(FILELAYOUT_LSEG(pgio->pg_lseg))) 807 + return size; 812 808 813 809 /* see if req and prev are in the same stripe */ 814 810 if (prev) {
+11
fs/nfsd/nfs4xdr.c
··· 3629 3629 case nfserr_noent: 3630 3630 xdr_truncate_encode(xdr, start_offset); 3631 3631 goto skip_entry; 3632 + case nfserr_jukebox: 3633 + /* 3634 + * The pseudoroot should only display dentries that lead to 3635 + * exports. If we get EJUKEBOX here, then we can't tell whether 3636 + * this entry should be included. Just fail the whole READDIR 3637 + * with NFS4ERR_DELAY in that case, and hope that the situation 3638 + * will resolve itself by the client's next attempt. 3639 + */ 3640 + if (cd->rd_fhp->fh_export->ex_flags & NFSEXP_V4ROOT) 3641 + goto fail; 3642 + fallthrough; 3632 3643 default: 3633 3644 /* 3634 3645 * If the client requested the RDATTR_ERROR attribute,
+1 -1
fs/nfsd/nfssvc.c
··· 453 453 { 454 454 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 455 455 456 - nfsd_file_cache_shutdown_net(net); 457 456 nfs4_state_shutdown_net(net); 457 + nfsd_file_cache_shutdown_net(net); 458 458 if (nn->lockd_up) { 459 459 lockd_down(net); 460 460 nn->lockd_up = false;
+2 -2
fs/ntfs3/file.c
··· 390 390 391 391 new_valid = ntfs_up_block(sb, min_t(u64, ni->i_valid, new_size)); 392 392 393 - ni_lock(ni); 394 - 395 393 truncate_setsize(inode, new_size); 394 + 395 + ni_lock(ni); 396 396 397 397 down_write(&ni->file.run_lock); 398 398 err = attr_set_size(ni, ATTR_DATA, NULL, 0, &ni->file.run, new_size,
+2 -4
fs/udf/inode.c
··· 595 595 */ 596 596 if (new_elen <= (last_ext->extLength & UDF_EXTENT_LENGTH_MASK)) 597 597 return; 598 - added_bytes = (last_ext->extLength & UDF_EXTENT_LENGTH_MASK) - new_elen; 598 + added_bytes = new_elen - (last_ext->extLength & UDF_EXTENT_LENGTH_MASK); 599 599 last_ext->extLength += added_bytes; 600 600 UDF_I(inode)->i_lenExtents += added_bytes; 601 601 ··· 684 684 struct kernel_lb_addr eloc, tmpeloc; 685 685 int c = 1; 686 686 loff_t lbcount = 0, b_off = 0; 687 - udf_pblk_t newblocknum, newblock; 687 + udf_pblk_t newblocknum, newblock = 0; 688 688 sector_t offset = 0; 689 689 int8_t etype; 690 690 struct udf_inode_info *iinfo = UDF_I(inode); ··· 787 787 ret = udf_do_extend_file(inode, &prev_epos, laarr, hole_len); 788 788 if (ret < 0) { 789 789 *err = ret; 790 - newblock = 0; 791 790 goto out_free; 792 791 } 793 792 c = 0; ··· 851 852 goal, err); 852 853 if (!newblocknum) { 853 854 *err = -ENOSPC; 854 - newblock = 0; 855 855 goto out_free; 856 856 } 857 857 if (isBeyondEOF)
+2
include/acpi/video.h
··· 53 53 }; 54 54 55 55 #if IS_ENABLED(CONFIG_ACPI_VIDEO) 56 + extern void acpi_video_report_nolcd(void); 56 57 extern int acpi_video_register(void); 57 58 extern void acpi_video_unregister(void); 58 59 extern void acpi_video_register_backlight(void); ··· 70 69 struct acpi_video_device_brightness **dev_br, 71 70 int *pmax_level); 72 71 #else 72 + static inline void acpi_video_report_nolcd(void) { return; }; 73 73 static inline int acpi_video_register(void) { return -ENODEV; } 74 74 static inline void acpi_video_unregister(void) { return; } 75 75 static inline void acpi_video_register_backlight(void) { return; }
+5
include/asm-generic/vmlinux.lds.h
··· 891 891 #define PRINTK_INDEX 892 892 #endif 893 893 894 + /* 895 + * Discard .note.GNU-stack, which is emitted as PROGBITS by the compiler. 896 + * Otherwise, the type of .notes section would become PROGBITS instead of NOTES. 897 + */ 894 898 #define NOTES \ 899 + /DISCARD/ : { *(.note.GNU-stack) } \ 895 900 .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \ 896 901 BOUNDED_SECTION_BY(.note.*, _notes) \ 897 902 } NOTES_HEADERS \
+1
include/drm/drm_plane_helper.h
··· 26 26 27 27 #include <linux/types.h> 28 28 29 + struct drm_atomic_state; 29 30 struct drm_crtc; 30 31 struct drm_framebuffer; 31 32 struct drm_modeset_acquire_ctx;
+2
include/linux/bio.h
··· 475 475 extern void bio_set_pages_dirty(struct bio *bio); 476 476 extern void bio_check_pages_dirty(struct bio *bio); 477 477 478 + extern void bio_copy_data_iter(struct bio *dst, struct bvec_iter *dst_iter, 479 + struct bio *src, struct bvec_iter *src_iter); 478 480 extern void bio_copy_data(struct bio *dst, struct bio *src); 479 481 extern void bio_free_pages(struct bio *bio); 480 482 void guard_bio_eod(struct bio *bio);
+1
include/linux/blkdev.h
··· 1395 1395 void (*swap_slot_free_notify) (struct block_device *, unsigned long); 1396 1396 int (*report_zones)(struct gendisk *, sector_t sector, 1397 1397 unsigned int nr_zones, report_zones_cb cb, void *data); 1398 + char *(*devnode)(struct gendisk *disk, umode_t *mode); 1398 1399 /* returns the length of the identifier or a negative errno: */ 1399 1400 int (*get_unique_id)(struct gendisk *disk, u8 id[16], 1400 1401 enum blk_unique_id id_type);
+2 -2
include/linux/dsa/tag_qca.h
··· 45 45 QCA_HDR_MGMT_COMMAND_LEN + \ 46 46 QCA_HDR_MGMT_DATA1_LEN) 47 47 48 - #define QCA_HDR_MGMT_DATA2_LEN 12 /* Other 12 byte for the mdio data */ 49 - #define QCA_HDR_MGMT_PADDING_LEN 34 /* Padding to reach the min Ethernet packet */ 48 + #define QCA_HDR_MGMT_DATA2_LEN 28 /* Other 28 byte for the mdio data */ 49 + #define QCA_HDR_MGMT_PADDING_LEN 18 /* Padding to reach the min Ethernet packet */ 50 50 51 51 #define QCA_HDR_MGMT_PKT_LEN (QCA_HDR_MGMT_HEADER_LEN + \ 52 52 QCA_HDR_LEN + \
+3
include/linux/fs.h
··· 1119 1119 int state; /* state of grant or error if -ve */ 1120 1120 unsigned int debug_id; 1121 1121 } afs; 1122 + struct { 1123 + struct inode *inode; 1124 + } ceph; 1122 1125 } fl_u; 1123 1126 } __randomize_layout; 1124 1127
+2 -1
include/linux/io_uring_types.h
··· 292 292 struct { 293 293 spinlock_t completion_lock; 294 294 295 + bool poll_multi_queue; 296 + 295 297 /* 296 298 * ->iopoll_list is protected by the ctx->uring_lock for 297 299 * io_uring instances that don't use IORING_SETUP_SQPOLL. ··· 302 300 */ 303 301 struct io_wq_work_list iopoll_list; 304 302 struct io_hash_table cancel_table; 305 - bool poll_multi_queue; 306 303 307 304 struct llist_head work_llist; 308 305
+5
include/linux/mlx5/device.h
··· 1091 1091 }; 1092 1092 1093 1093 enum { 1094 + MLX5_VPORT_CVLAN_INSERT_WHEN_NO_CVLAN = 0x1, 1095 + MLX5_VPORT_CVLAN_INSERT_ALWAYS = 0x3, 1096 + }; 1097 + 1098 + enum { 1094 1099 MLX5_L3_PROT_TYPE_IPV4 = 0, 1095 1100 MLX5_L3_PROT_TYPE_IPV6 = 1, 1096 1101 };
+2 -1
include/linux/mlx5/mlx5_ifc.h
··· 913 913 u8 vport_svlan_insert[0x1]; 914 914 u8 vport_cvlan_insert_if_not_exist[0x1]; 915 915 u8 vport_cvlan_insert_overwrite[0x1]; 916 - u8 reserved_at_5[0x2]; 916 + u8 reserved_at_5[0x1]; 917 + u8 vport_cvlan_insert_always[0x1]; 917 918 u8 esw_shared_ingress_acl[0x1]; 918 919 u8 esw_uplink_ingress_acl[0x1]; 919 920 u8 root_ft_on_other_esw[0x1];
+1 -1
include/linux/netfilter/ipset/ip_set.h
··· 197 197 }; 198 198 199 199 /* Max range where every element is added/deleted in one step */ 200 - #define IPSET_MAX_RANGE (1<<20) 200 + #define IPSET_MAX_RANGE (1<<14) 201 201 202 202 /* The max revision number supported by any set type + 1 */ 203 203 #define IPSET_REVISION_MAX 9
+3 -1
include/linux/nvme.h
··· 7 7 #ifndef _LINUX_NVME_H 8 8 #define _LINUX_NVME_H 9 9 10 + #include <linux/bits.h> 10 11 #include <linux/types.h> 11 12 #include <linux/uuid.h> 12 13 ··· 640 639 NVME_CMD_EFFECTS_NCC = 1 << 2, 641 640 NVME_CMD_EFFECTS_NIC = 1 << 3, 642 641 NVME_CMD_EFFECTS_CCC = 1 << 4, 643 - NVME_CMD_EFFECTS_CSE_MASK = 3 << 16, 642 + NVME_CMD_EFFECTS_CSE_MASK = GENMASK(18, 16), 644 643 NVME_CMD_EFFECTS_UUID_SEL = 1 << 19, 644 + NVME_CMD_EFFECTS_SCOPE_MASK = GENMASK(31, 20), 645 645 }; 646 646 647 647 struct nvme_effects_log {
+1 -4
include/linux/phy.h
··· 826 826 * whether to advertise lower-speed modes for that interface. It is 827 827 * assumed that if a rate matching mode is supported on an interface, 828 828 * then that interface's rate can be adapted to all slower link speeds 829 - * supported by the phy. If iface is %PHY_INTERFACE_MODE_NA, and the phy 830 - * supports any kind of rate matching for any interface, then it must 831 - * return that rate matching mode (preferring %RATE_MATCH_PAUSE to 832 - * %RATE_MATCH_CRS). If the interface is not supported, this should 829 + * supported by the phy. If the interface is not supported, this should 833 830 * return %RATE_MATCH_NONE. 834 831 */ 835 832 int (*get_rate_matching)(struct phy_device *phydev,
+197
include/linux/pktcdvd.h
··· 1 + /* 2 + * Copyright (C) 2000 Jens Axboe <axboe@suse.de> 3 + * Copyright (C) 2001-2004 Peter Osterlund <petero2@telia.com> 4 + * 5 + * May be copied or modified under the terms of the GNU General Public 6 + * License. See linux/COPYING for more information. 7 + * 8 + * Packet writing layer for ATAPI and SCSI CD-R, CD-RW, DVD-R, and 9 + * DVD-RW devices. 10 + * 11 + */ 12 + #ifndef __PKTCDVD_H 13 + #define __PKTCDVD_H 14 + 15 + #include <linux/blkdev.h> 16 + #include <linux/completion.h> 17 + #include <linux/cdrom.h> 18 + #include <linux/kobject.h> 19 + #include <linux/sysfs.h> 20 + #include <linux/mempool.h> 21 + #include <uapi/linux/pktcdvd.h> 22 + 23 + /* default bio write queue congestion marks */ 24 + #define PKT_WRITE_CONGESTION_ON 10000 25 + #define PKT_WRITE_CONGESTION_OFF 9000 26 + 27 + 28 + struct packet_settings 29 + { 30 + __u32 size; /* packet size in (512 byte) sectors */ 31 + __u8 fp; /* fixed packets */ 32 + __u8 link_loss; /* the rest is specified 33 + * as per Mt Fuji */ 34 + __u8 write_type; 35 + __u8 track_mode; 36 + __u8 block_mode; 37 + }; 38 + 39 + /* 40 + * Very crude stats for now 41 + */ 42 + struct packet_stats 43 + { 44 + unsigned long pkt_started; 45 + unsigned long pkt_ended; 46 + unsigned long secs_w; 47 + unsigned long secs_rg; 48 + unsigned long secs_r; 49 + }; 50 + 51 + struct packet_cdrw 52 + { 53 + struct list_head pkt_free_list; 54 + struct list_head pkt_active_list; 55 + spinlock_t active_list_lock; /* Serialize access to pkt_active_list */ 56 + struct task_struct *thread; 57 + atomic_t pending_bios; 58 + }; 59 + 60 + /* 61 + * Switch to high speed reading after reading this many kilobytes 62 + * with no interspersed writes. 63 + */ 64 + #define HI_SPEED_SWITCH 512 65 + 66 + struct packet_iosched 67 + { 68 + atomic_t attention; /* Set to non-zero when queue processing is needed */ 69 + int writing; /* Non-zero when writing, zero when reading */ 70 + spinlock_t lock; /* Protecting read/write queue manipulations */ 71 + struct bio_list read_queue; 72 + struct bio_list write_queue; 73 + sector_t last_write; /* The sector where the last write ended */ 74 + int successive_reads; 75 + }; 76 + 77 + /* 78 + * 32 buffers of 2048 bytes 79 + */ 80 + #if (PAGE_SIZE % CD_FRAMESIZE) != 0 81 + #error "PAGE_SIZE must be a multiple of CD_FRAMESIZE" 82 + #endif 83 + #define PACKET_MAX_SIZE 128 84 + #define FRAMES_PER_PAGE (PAGE_SIZE / CD_FRAMESIZE) 85 + #define PACKET_MAX_SECTORS (PACKET_MAX_SIZE * CD_FRAMESIZE >> 9) 86 + 87 + enum packet_data_state { 88 + PACKET_IDLE_STATE, /* Not used at the moment */ 89 + PACKET_WAITING_STATE, /* Waiting for more bios to arrive, so */ 90 + /* we don't have to do as much */ 91 + /* data gathering */ 92 + PACKET_READ_WAIT_STATE, /* Waiting for reads to fill in holes */ 93 + PACKET_WRITE_WAIT_STATE, /* Waiting for the write to complete */ 94 + PACKET_RECOVERY_STATE, /* Recover after read/write errors */ 95 + PACKET_FINISHED_STATE, /* After write has finished */ 96 + 97 + PACKET_NUM_STATES /* Number of possible states */ 98 + }; 99 + 100 + /* 101 + * Information needed for writing a single packet 102 + */ 103 + struct pktcdvd_device; 104 + 105 + struct packet_data 106 + { 107 + struct list_head list; 108 + 109 + spinlock_t lock; /* Lock protecting state transitions and */ 110 + /* orig_bios list */ 111 + 112 + struct bio_list orig_bios; /* Original bios passed to pkt_make_request */ 113 + /* that will be handled by this packet */ 114 + int write_size; /* Total size of all bios in the orig_bios */ 115 + /* list, measured in number of frames */ 116 + 117 + struct bio *w_bio; /* The bio we will send to the real CD */ 118 + /* device once we have all data for the */ 119 + /* packet we are going to write */ 120 + sector_t sector; /* First sector in this packet */ 121 + int frames; /* Number of frames in this packet */ 122 + 123 + enum packet_data_state state; /* Current state */ 124 + atomic_t run_sm; /* Incremented whenever the state */ 125 + /* machine needs to be run */ 126 + long sleep_time; /* Set this to non-zero to make the state */ 127 + /* machine run after this many jiffies. */ 128 + 129 + atomic_t io_wait; /* Number of pending IO operations */ 130 + atomic_t io_errors; /* Number of read/write errors during IO */ 131 + 132 + struct bio *r_bios[PACKET_MAX_SIZE]; /* bios to use during data gathering */ 133 + struct page *pages[PACKET_MAX_SIZE / FRAMES_PER_PAGE]; 134 + 135 + int cache_valid; /* If non-zero, the data for the zone defined */ 136 + /* by the sector variable is completely cached */ 137 + /* in the pages[] vector. */ 138 + 139 + int id; /* ID number for debugging */ 140 + struct pktcdvd_device *pd; 141 + }; 142 + 143 + struct pkt_rb_node { 144 + struct rb_node rb_node; 145 + struct bio *bio; 146 + }; 147 + 148 + struct packet_stacked_data 149 + { 150 + struct bio *bio; /* Original read request bio */ 151 + struct pktcdvd_device *pd; 152 + }; 153 + #define PSD_POOL_SIZE 64 154 + 155 + struct pktcdvd_device 156 + { 157 + struct block_device *bdev; /* dev attached */ 158 + dev_t pkt_dev; /* our dev */ 159 + char name[20]; 160 + struct packet_settings settings; 161 + struct packet_stats stats; 162 + int refcnt; /* Open count */ 163 + int write_speed; /* current write speed, kB/s */ 164 + int read_speed; /* current read speed, kB/s */ 165 + unsigned long offset; /* start offset */ 166 + __u8 mode_offset; /* 0 / 8 */ 167 + __u8 type; 168 + unsigned long flags; 169 + __u16 mmc3_profile; 170 + __u32 nwa; /* next writable address */ 171 + __u32 lra; /* last recorded address */ 172 + struct packet_cdrw cdrw; 173 + wait_queue_head_t wqueue; 174 + 175 + spinlock_t lock; /* Serialize access to bio_queue */ 176 + struct rb_root bio_queue; /* Work queue of bios we need to handle */ 177 + int bio_queue_size; /* Number of nodes in bio_queue */ 178 + bool congested; /* Someone is waiting for bio_queue_size 179 + * to drop. */ 180 + sector_t current_sector; /* Keep track of where the elevator is */ 181 + atomic_t scan_queue; /* Set to non-zero when pkt_handle_queue */ 182 + /* needs to be run. */ 183 + mempool_t rb_pool; /* mempool for pkt_rb_node allocations */ 184 + 185 + struct packet_iosched iosched; 186 + struct gendisk *disk; 187 + 188 + int write_congestion_off; 189 + int write_congestion_on; 190 + 191 + struct device *dev; /* sysfs pktcdvd[0-7] dev */ 192 + 193 + struct dentry *dfs_d_root; /* debugfs: devname directory */ 194 + struct dentry *dfs_f_info; /* debugfs: info file */ 195 + }; 196 + 197 + #endif /* __PKTCDVD_H */
+5
include/linux/sunrpc/rpc_pipe_fs.h
··· 92 92 char __user *, size_t); 93 93 extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *); 94 94 95 + /* returns true if the msg is in-flight, i.e., already eaten by the peer */ 96 + static inline bool rpc_msg_is_inflight(const struct rpc_pipe_msg *msg) { 97 + return (msg->copied != 0 && list_empty(&msg->list)); 98 + } 99 + 95 100 struct rpc_clnt; 96 101 extern struct dentry *rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *); 97 102 extern int rpc_remove_client_dir(struct rpc_clnt *);
+4
include/net/inet_hashtables.h
··· 108 108 struct hlist_node node; 109 109 /* List of sockets hashed to this bucket */ 110 110 struct hlist_head owners; 111 + /* bhash has twsk in owners, but bhash2 has twsk in 112 + * deathrow not to add a member in struct sock_common. 113 + */ 114 + struct hlist_head deathrow; 111 115 }; 112 116 113 117 static inline struct net *ib_net(const struct inet_bind_bucket *ib)
+5
include/net/inet_timewait_sock.h
··· 73 73 u32 tw_priority; 74 74 struct timer_list tw_timer; 75 75 struct inet_bind_bucket *tw_tb; 76 + struct inet_bind2_bucket *tw_tb2; 77 + struct hlist_node tw_bind2_node; 76 78 }; 77 79 #define tw_tclass tw_tos 80 + 81 + #define twsk_for_each_bound_bhash2(__tw, list) \ 82 + hlist_for_each_entry(__tw, list, tw_bind2_node) 78 83 79 84 static inline struct inet_timewait_sock *inet_twsk(const struct sock *sk) 80 85 {
+24 -1
include/net/netfilter/nf_tables.h
··· 312 312 /** 313 313 * struct nft_set_desc - description of set elements 314 314 * 315 + * @ktype: key type 315 316 * @klen: key length 317 + * @dtype: data type 316 318 * @dlen: data length 319 + * @objtype: object type 320 + * @flags: flags 317 321 * @size: number of set elements 322 + * @policy: set policy 323 + * @gc_int: garbage collector interval 318 324 * @field_len: length of each field in concatenation, bytes 319 325 * @field_count: number of concatenated fields in element 320 326 * @expr: set must support for expressions 321 327 */ 322 328 struct nft_set_desc { 329 + u32 ktype; 323 330 unsigned int klen; 331 + u32 dtype; 324 332 unsigned int dlen; 333 + u32 objtype; 325 334 unsigned int size; 335 + u32 policy; 336 + u32 gc_int; 337 + u64 timeout; 326 338 u8 field_len[NFT_REG32_COUNT]; 327 339 u8 field_count; 328 340 bool expr; ··· 597 585 598 586 static inline unsigned long nft_set_gc_interval(const struct nft_set *set) 599 587 { 600 - return set->gc_int ? msecs_to_jiffies(set->gc_int) : HZ; 588 + u32 gc_int = READ_ONCE(set->gc_int); 589 + 590 + return gc_int ? msecs_to_jiffies(gc_int) : HZ; 601 591 } 602 592 603 593 /** ··· 1572 1558 struct nft_trans_set { 1573 1559 struct nft_set *set; 1574 1560 u32 set_id; 1561 + u32 gc_int; 1562 + u64 timeout; 1563 + bool update; 1575 1564 bool bound; 1576 1565 }; 1577 1566 ··· 1584 1567 (((struct nft_trans_set *)trans->data)->set_id) 1585 1568 #define nft_trans_set_bound(trans) \ 1586 1569 (((struct nft_trans_set *)trans->data)->bound) 1570 + #define nft_trans_set_update(trans) \ 1571 + (((struct nft_trans_set *)trans->data)->update) 1572 + #define nft_trans_set_timeout(trans) \ 1573 + (((struct nft_trans_set *)trans->data)->timeout) 1574 + #define nft_trans_set_gc_int(trans) \ 1575 + (((struct nft_trans_set *)trans->data)->gc_int) 1587 1576 1588 1577 struct nft_trans_chain { 1589 1578 bool update;
+2 -2
include/net/tc_wrapper.h
··· 216 216 return tp->classify(skb, tp, res); 217 217 } 218 218 219 + #endif /* CONFIG_NET_CLS */ 220 + 219 221 static inline void tc_wrapper_init(void) 220 222 { 221 223 #ifdef CONFIG_X86 ··· 225 223 static_branch_enable(&tc_skip_wrapper); 226 224 #endif 227 225 } 228 - 229 - #endif /* CONFIG_NET_CLS */ 230 226 231 227 #else 232 228
+1 -1
include/trace/events/btrfs.h
··· 98 98 EM( FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT") \ 99 99 EM( FLUSH_DELALLOC_FULL, "FLUSH_DELALLOC_FULL") \ 100 100 EM( FLUSH_DELAYED_REFS_NR, "FLUSH_DELAYED_REFS_NR") \ 101 - EM( FLUSH_DELAYED_REFS, "FLUSH_ELAYED_REFS") \ 101 + EM( FLUSH_DELAYED_REFS, "FLUSH_DELAYED_REFS") \ 102 102 EM( ALLOC_CHUNK, "ALLOC_CHUNK") \ 103 103 EM( ALLOC_CHUNK_FORCE, "ALLOC_CHUNK_FORCE") \ 104 104 EM( RUN_DELAYED_IPUTS, "RUN_DELAYED_IPUTS") \
+3 -3
include/trace/events/rxrpc.h
··· 1062 1062 ); 1063 1063 1064 1064 TRACE_EVENT(rxrpc_recvmsg, 1065 - TP_PROTO(struct rxrpc_call *call, enum rxrpc_recvmsg_trace why, 1065 + TP_PROTO(unsigned int call_debug_id, enum rxrpc_recvmsg_trace why, 1066 1066 int ret), 1067 1067 1068 - TP_ARGS(call, why, ret), 1068 + TP_ARGS(call_debug_id, why, ret), 1069 1069 1070 1070 TP_STRUCT__entry( 1071 1071 __field(unsigned int, call ) ··· 1074 1074 ), 1075 1075 1076 1076 TP_fast_assign( 1077 - __entry->call = call ? call->debug_id : 0; 1077 + __entry->call = call_debug_id; 1078 1078 __entry->why = why; 1079 1079 __entry->ret = ret; 1080 1080 ),
+1 -1
include/uapi/linux/atmbr2684.h
··· 38 38 */ 39 39 #define BR2684_ENCAPS_VC (0) /* VC-mux */ 40 40 #define BR2684_ENCAPS_LLC (1) 41 - #define BR2684_ENCAPS_AUTODETECT (2) /* Unsuported */ 41 + #define BR2684_ENCAPS_AUTODETECT (2) /* Unsupported */ 42 42 43 43 /* 44 44 * Is this VC bridged or routed?
+8
include/uapi/linux/io_uring.h
··· 10 10 11 11 #include <linux/fs.h> 12 12 #include <linux/types.h> 13 + /* 14 + * this file is shared with liburing and that has to autodetect 15 + * if linux/time_types.h is available or not, it can 16 + * define UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H 17 + * if linux/time_types.h is not available 18 + */ 19 + #ifndef UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H 13 20 #include <linux/time_types.h> 21 + #endif 14 22 15 23 #ifdef __cplusplus 16 24 extern "C" {
+3
include/uapi/linux/kvm.h
··· 1767 1767 __u8 runstate_update_flag; 1768 1768 struct { 1769 1769 __u64 gfn; 1770 + #define KVM_XEN_INVALID_GFN ((__u64)-1) 1770 1771 } shared_info; 1771 1772 struct { 1772 1773 __u32 send_port; ··· 1799 1798 } u; 1800 1799 }; 1801 1800 1801 + 1802 1802 /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */ 1803 1803 #define KVM_XEN_ATTR_TYPE_LONG_MODE 0x0 1804 1804 #define KVM_XEN_ATTR_TYPE_SHARED_INFO 0x1 ··· 1825 1823 __u16 pad[3]; 1826 1824 union { 1827 1825 __u64 gpa; 1826 + #define KVM_XEN_INVALID_GPA ((__u64)-1) 1828 1827 __u64 pad[8]; 1829 1828 struct { 1830 1829 __u64 state;
+112
include/uapi/linux/pktcdvd.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 + /* 3 + * Copyright (C) 2000 Jens Axboe <axboe@suse.de> 4 + * Copyright (C) 2001-2004 Peter Osterlund <petero2@telia.com> 5 + * 6 + * May be copied or modified under the terms of the GNU General Public 7 + * License. See linux/COPYING for more information. 8 + * 9 + * Packet writing layer for ATAPI and SCSI CD-R, CD-RW, DVD-R, and 10 + * DVD-RW devices. 11 + * 12 + */ 13 + #ifndef _UAPI__PKTCDVD_H 14 + #define _UAPI__PKTCDVD_H 15 + 16 + #include <linux/types.h> 17 + 18 + /* 19 + * 1 for normal debug messages, 2 is very verbose. 0 to turn it off. 20 + */ 21 + #define PACKET_DEBUG 1 22 + 23 + #define MAX_WRITERS 8 24 + 25 + #define PKT_RB_POOL_SIZE 512 26 + 27 + /* 28 + * How long we should hold a non-full packet before starting data gathering. 29 + */ 30 + #define PACKET_WAIT_TIME (HZ * 5 / 1000) 31 + 32 + /* 33 + * use drive write caching -- we need deferred error handling to be 34 + * able to successfully recover with this option (drive will return good 35 + * status as soon as the cdb is validated). 36 + */ 37 + #if defined(CONFIG_CDROM_PKTCDVD_WCACHE) 38 + #define USE_WCACHING 1 39 + #else 40 + #define USE_WCACHING 0 41 + #endif 42 + 43 + /* 44 + * No user-servicable parts beyond this point -> 45 + */ 46 + 47 + /* 48 + * device types 49 + */ 50 + #define PACKET_CDR 1 51 + #define PACKET_CDRW 2 52 + #define PACKET_DVDR 3 53 + #define PACKET_DVDRW 4 54 + 55 + /* 56 + * flags 57 + */ 58 + #define PACKET_WRITABLE 1 /* pd is writable */ 59 + #define PACKET_NWA_VALID 2 /* next writable address valid */ 60 + #define PACKET_LRA_VALID 3 /* last recorded address valid */ 61 + #define PACKET_MERGE_SEGS 4 /* perform segment merging to keep */ 62 + /* underlying cdrom device happy */ 63 + 64 + /* 65 + * Disc status -- from READ_DISC_INFO 66 + */ 67 + #define PACKET_DISC_EMPTY 0 68 + #define PACKET_DISC_INCOMPLETE 1 69 + #define PACKET_DISC_COMPLETE 2 70 + #define PACKET_DISC_OTHER 3 71 + 72 + /* 73 + * write type, and corresponding data block type 74 + */ 75 + #define PACKET_MODE1 1 76 + #define PACKET_MODE2 2 77 + #define PACKET_BLOCK_MODE1 8 78 + #define PACKET_BLOCK_MODE2 10 79 + 80 + /* 81 + * Last session/border status 82 + */ 83 + #define PACKET_SESSION_EMPTY 0 84 + #define PACKET_SESSION_INCOMPLETE 1 85 + #define PACKET_SESSION_RESERVED 2 86 + #define PACKET_SESSION_COMPLETE 3 87 + 88 + #define PACKET_MCN "4a656e734178626f65323030300000" 89 + 90 + #undef PACKET_USE_LS 91 + 92 + #define PKT_CTRL_CMD_SETUP 0 93 + #define PKT_CTRL_CMD_TEARDOWN 1 94 + #define PKT_CTRL_CMD_STATUS 2 95 + 96 + struct pkt_ctrl_command { 97 + __u32 command; /* in: Setup, teardown, status */ 98 + __u32 dev_index; /* in/out: Device index */ 99 + __u32 dev; /* in/out: Device nr for cdrw device */ 100 + __u32 pkt_dev; /* in/out: Device nr for packet device */ 101 + __u32 num_devices; /* out: Largest device index + 1 */ 102 + __u32 padding; /* Not used */ 103 + }; 104 + 105 + /* 106 + * packet ioctls 107 + */ 108 + #define PACKET_IOCTL_MAGIC ('X') 109 + #define PACKET_CTRL_CMD _IOWR(PACKET_IOCTL_MAGIC, 1, struct pkt_ctrl_command) 110 + 111 + 112 + #endif /* _UAPI__PKTCDVD_H */
+1 -3
include/uapi/linux/vdpa.h
··· 53 53 VDPA_ATTR_DEV_VENDOR_ATTR_NAME, /* string */ 54 54 VDPA_ATTR_DEV_VENDOR_ATTR_VALUE, /* u64 */ 55 55 56 + /* virtio features that are provisioned to the vDPA device */ 56 57 VDPA_ATTR_DEV_FEATURES, /* u64 */ 57 - 58 - /* virtio features that are supported by the vDPA device */ 59 - VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES, /* u64 */ 60 58 61 59 /* new attributes must be added above here */ 62 60 VDPA_ATTR_MAX,
+4 -5
io_uring/cancel.c
··· 288 288 289 289 ret = __io_sync_cancel(current->io_uring, &cd, sc.fd); 290 290 291 + mutex_unlock(&ctx->uring_lock); 291 292 if (ret != -EALREADY) 292 293 break; 293 294 294 - mutex_unlock(&ctx->uring_lock); 295 295 ret = io_run_task_work_sig(ctx); 296 - if (ret < 0) { 297 - mutex_lock(&ctx->uring_lock); 296 + if (ret < 0) 298 297 break; 299 - } 300 298 ret = schedule_hrtimeout(&timeout, HRTIMER_MODE_ABS); 301 - mutex_lock(&ctx->uring_lock); 302 299 if (!ret) { 303 300 ret = -ETIME; 304 301 break; 305 302 } 303 + mutex_lock(&ctx->uring_lock); 306 304 } while (1); 307 305 308 306 finish_wait(&ctx->cq_wait, &wait); 307 + mutex_lock(&ctx->uring_lock); 309 308 310 309 if (ret == -ENOENT || ret > 0) 311 310 ret = 0;
+1
io_uring/io-wq.c
··· 1230 1230 1231 1231 worker = container_of(cb, struct io_worker, create_work); 1232 1232 io_worker_cancel_cb(worker); 1233 + kfree(worker); 1233 1234 } 1234 1235 } 1235 1236
+31 -18
io_uring/io_uring.c
··· 677 677 io_cq_unlock_post(ctx); 678 678 } 679 679 680 + static void io_cqring_do_overflow_flush(struct io_ring_ctx *ctx) 681 + { 682 + /* iopoll syncs against uring_lock, not completion_lock */ 683 + if (ctx->flags & IORING_SETUP_IOPOLL) 684 + mutex_lock(&ctx->uring_lock); 685 + __io_cqring_overflow_flush(ctx); 686 + if (ctx->flags & IORING_SETUP_IOPOLL) 687 + mutex_unlock(&ctx->uring_lock); 688 + } 689 + 680 690 static void io_cqring_overflow_flush(struct io_ring_ctx *ctx) 681 691 { 682 - if (test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq)) { 683 - /* iopoll syncs against uring_lock, not completion_lock */ 684 - if (ctx->flags & IORING_SETUP_IOPOLL) 685 - mutex_lock(&ctx->uring_lock); 686 - __io_cqring_overflow_flush(ctx); 687 - if (ctx->flags & IORING_SETUP_IOPOLL) 688 - mutex_unlock(&ctx->uring_lock); 689 - } 692 + if (test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq)) 693 + io_cqring_do_overflow_flush(ctx); 690 694 } 691 695 692 696 void __io_put_task(struct task_struct *task, int nr) ··· 730 726 struct io_overflow_cqe *ocqe; 731 727 size_t ocq_size = sizeof(struct io_overflow_cqe); 732 728 bool is_cqe32 = (ctx->flags & IORING_SETUP_CQE32); 729 + 730 + lockdep_assert_held(&ctx->completion_lock); 733 731 734 732 if (is_cqe32) 735 733 ocq_size += sizeof(struct io_uring_cqe); ··· 821 815 u32 cflags) 822 816 { 823 817 struct io_uring_cqe *cqe; 824 - 825 - if (!ctx->task_complete) 826 - lockdep_assert_held(&ctx->completion_lock); 827 818 828 819 ctx->cq_extra++; 829 820 ··· 1235 1232 { 1236 1233 struct io_ring_ctx *ctx = req->ctx; 1237 1234 1238 - if (!llist_add(&req->io_task_work.node, &ctx->work_llist)) 1235 + percpu_ref_get(&ctx->refs); 1236 + 1237 + if (!llist_add(&req->io_task_work.node, &ctx->work_llist)) { 1238 + percpu_ref_put(&ctx->refs); 1239 1239 return; 1240 + } 1240 1241 /* need it for the following io_cqring_wake() */ 1241 1242 smp_mb__after_atomic(); 1242 1243 1243 1244 if (unlikely(atomic_read(&req->task->io_uring->in_idle))) { 1244 1245 io_move_task_work_from_local(ctx); 1246 + percpu_ref_put(&ctx->refs); 1245 1247 return; 1246 1248 } 1247 1249 ··· 1256 1248 if (ctx->has_evfd) 1257 1249 io_eventfd_signal(ctx); 1258 1250 __io_cqring_wake(ctx); 1251 + percpu_ref_put(&ctx->refs); 1259 1252 } 1260 1253 1261 1254 void __io_req_task_work_add(struct io_kiocb *req, bool allow_local) ··· 2470 2461 /* when returns >0, the caller should retry */ 2471 2462 static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, 2472 2463 struct io_wait_queue *iowq, 2473 - ktime_t timeout) 2464 + ktime_t *timeout) 2474 2465 { 2475 2466 int ret; 2476 2467 unsigned long check_cq; ··· 2488 2479 if (check_cq & BIT(IO_CHECK_CQ_DROPPED_BIT)) 2489 2480 return -EBADR; 2490 2481 } 2491 - if (!schedule_hrtimeout(&timeout, HRTIMER_MODE_ABS)) 2482 + if (!schedule_hrtimeout(timeout, HRTIMER_MODE_ABS)) 2492 2483 return -ETIME; 2493 2484 2494 2485 /* ··· 2558 2549 2559 2550 trace_io_uring_cqring_wait(ctx, min_events); 2560 2551 do { 2561 - io_cqring_overflow_flush(ctx); 2552 + if (test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq)) { 2553 + finish_wait(&ctx->cq_wait, &iowq.wq); 2554 + io_cqring_do_overflow_flush(ctx); 2555 + } 2562 2556 prepare_to_wait_exclusive(&ctx->cq_wait, &iowq.wq, 2563 2557 TASK_INTERRUPTIBLE); 2564 - ret = io_cqring_wait_schedule(ctx, &iowq, timeout); 2558 + ret = io_cqring_wait_schedule(ctx, &iowq, &timeout); 2565 2559 if (__io_cqring_events_user(ctx) >= min_events) 2566 2560 break; 2567 2561 cond_resched(); ··· 4025 4013 return -EEXIST; 4026 4014 4027 4015 if (ctx->restricted) { 4028 - if (opcode >= IORING_REGISTER_LAST) 4029 - return -EINVAL; 4030 4016 opcode = array_index_nospec(opcode, IORING_REGISTER_LAST); 4031 4017 if (!test_bit(opcode, ctx->restrictions.register_op)) 4032 4018 return -EACCES; ··· 4179 4169 struct io_ring_ctx *ctx; 4180 4170 long ret = -EBADF; 4181 4171 struct fd f; 4172 + 4173 + if (opcode >= IORING_REGISTER_LAST) 4174 + return -EINVAL; 4182 4175 4183 4176 f = fdget(fd); 4184 4177 if (!f.file)
+15
io_uring/io_uring.h
··· 79 79 bool io_match_task_safe(struct io_kiocb *head, struct task_struct *task, 80 80 bool cancel_all); 81 81 82 + #define io_lockdep_assert_cq_locked(ctx) \ 83 + do { \ 84 + if (ctx->flags & IORING_SETUP_IOPOLL) { \ 85 + lockdep_assert_held(&ctx->uring_lock); \ 86 + } else if (!ctx->task_complete) { \ 87 + lockdep_assert_held(&ctx->completion_lock); \ 88 + } else if (ctx->submitter_task->flags & PF_EXITING) { \ 89 + lockdep_assert(current_work()); \ 90 + } else { \ 91 + lockdep_assert(current == ctx->submitter_task); \ 92 + } \ 93 + } while (0) 94 + 82 95 static inline void io_req_task_work_add(struct io_kiocb *req) 83 96 { 84 97 __io_req_task_work_add(req, true); ··· 105 92 static inline struct io_uring_cqe *io_get_cqe_overflow(struct io_ring_ctx *ctx, 106 93 bool overflow) 107 94 { 95 + io_lockdep_assert_cq_locked(ctx); 96 + 108 97 if (likely(ctx->cqe_cached < ctx->cqe_sentinel)) { 109 98 struct io_uring_cqe *cqe = ctx->cqe_cached; 110 99
+2
kernel/bpf/bpf_lsm.c
··· 351 351 BTF_ID(func, bpf_lsm_bpf_prog_free_security) 352 352 BTF_ID(func, bpf_lsm_file_alloc_security) 353 353 BTF_ID(func, bpf_lsm_file_free_security) 354 + #ifdef CONFIG_SECURITY_NETWORK 354 355 BTF_ID(func, bpf_lsm_sk_alloc_security) 355 356 BTF_ID(func, bpf_lsm_sk_free_security) 357 + #endif /* CONFIG_SECURITY_NETWORK */ 356 358 BTF_ID(func, bpf_lsm_task_free) 357 359 BTF_SET_END(untrusted_lsm_hooks) 358 360
+27 -12
kernel/bpf/task_iter.c
··· 438 438 */ 439 439 struct bpf_iter_seq_task_common common; 440 440 struct task_struct *task; 441 + struct mm_struct *mm; 441 442 struct vm_area_struct *vma; 442 443 u32 tid; 443 444 unsigned long prev_vm_start; ··· 457 456 enum bpf_task_vma_iter_find_op op; 458 457 struct vm_area_struct *curr_vma; 459 458 struct task_struct *curr_task; 459 + struct mm_struct *curr_mm; 460 460 u32 saved_tid = info->tid; 461 461 462 462 /* If this function returns a non-NULL vma, it holds a reference to 463 - * the task_struct, and holds read lock on vma->mm->mmap_lock. 463 + * the task_struct, holds a refcount on mm->mm_users, and holds 464 + * read lock on vma->mm->mmap_lock. 464 465 * If this function returns NULL, it does not hold any reference or 465 466 * lock. 466 467 */ 467 468 if (info->task) { 468 469 curr_task = info->task; 469 470 curr_vma = info->vma; 471 + curr_mm = info->mm; 470 472 /* In case of lock contention, drop mmap_lock to unblock 471 473 * the writer. 472 474 * ··· 508 504 * 4.2) VMA2 and VMA2' covers different ranges, process 509 505 * VMA2'. 510 506 */ 511 - if (mmap_lock_is_contended(curr_task->mm)) { 507 + if (mmap_lock_is_contended(curr_mm)) { 512 508 info->prev_vm_start = curr_vma->vm_start; 513 509 info->prev_vm_end = curr_vma->vm_end; 514 510 op = task_vma_iter_find_vma; 515 - mmap_read_unlock(curr_task->mm); 516 - if (mmap_read_lock_killable(curr_task->mm)) 511 + mmap_read_unlock(curr_mm); 512 + if (mmap_read_lock_killable(curr_mm)) { 513 + mmput(curr_mm); 517 514 goto finish; 515 + } 518 516 } else { 519 517 op = task_vma_iter_next_vma; 520 518 } ··· 541 535 op = task_vma_iter_find_vma; 542 536 } 543 537 544 - if (!curr_task->mm) 538 + curr_mm = get_task_mm(curr_task); 539 + if (!curr_mm) 545 540 goto next_task; 546 541 547 - if (mmap_read_lock_killable(curr_task->mm)) 542 + if (mmap_read_lock_killable(curr_mm)) { 543 + mmput(curr_mm); 548 544 goto finish; 545 + } 549 546 } 550 547 551 548 switch (op) { 552 549 case task_vma_iter_first_vma: 553 - curr_vma = find_vma(curr_task->mm, 0); 550 + curr_vma = find_vma(curr_mm, 0); 554 551 break; 555 552 case task_vma_iter_next_vma: 556 - curr_vma = find_vma(curr_task->mm, curr_vma->vm_end); 553 + curr_vma = find_vma(curr_mm, curr_vma->vm_end); 557 554 break; 558 555 case task_vma_iter_find_vma: 559 556 /* We dropped mmap_lock so it is necessary to use find_vma 560 557 * to find the next vma. This is similar to the mechanism 561 558 * in show_smaps_rollup(). 562 559 */ 563 - curr_vma = find_vma(curr_task->mm, info->prev_vm_end - 1); 560 + curr_vma = find_vma(curr_mm, info->prev_vm_end - 1); 564 561 /* case 1) and 4.2) above just use curr_vma */ 565 562 566 563 /* check for case 2) or case 4.1) above */ 567 564 if (curr_vma && 568 565 curr_vma->vm_start == info->prev_vm_start && 569 566 curr_vma->vm_end == info->prev_vm_end) 570 - curr_vma = find_vma(curr_task->mm, curr_vma->vm_end); 567 + curr_vma = find_vma(curr_mm, curr_vma->vm_end); 571 568 break; 572 569 } 573 570 if (!curr_vma) { 574 571 /* case 3) above, or case 2) 4.1) with vma->next == NULL */ 575 - mmap_read_unlock(curr_task->mm); 572 + mmap_read_unlock(curr_mm); 573 + mmput(curr_mm); 576 574 goto next_task; 577 575 } 578 576 info->task = curr_task; 579 577 info->vma = curr_vma; 578 + info->mm = curr_mm; 580 579 return curr_vma; 581 580 582 581 next_task: ··· 590 579 591 580 put_task_struct(curr_task); 592 581 info->task = NULL; 582 + info->mm = NULL; 593 583 info->tid++; 594 584 goto again; 595 585 ··· 599 587 put_task_struct(curr_task); 600 588 info->task = NULL; 601 589 info->vma = NULL; 590 + info->mm = NULL; 602 591 return NULL; 603 592 } 604 593 ··· 671 658 */ 672 659 info->prev_vm_start = ~0UL; 673 660 info->prev_vm_end = info->vma->vm_end; 674 - mmap_read_unlock(info->task->mm); 661 + mmap_read_unlock(info->mm); 662 + mmput(info->mm); 663 + info->mm = NULL; 675 664 put_task_struct(info->task); 676 665 info->task = NULL; 677 666 }
+4
kernel/bpf/trampoline.c
··· 488 488 /* reset fops->func and fops->trampoline for re-register */ 489 489 tr->fops->func = NULL; 490 490 tr->fops->trampoline = 0; 491 + 492 + /* reset im->image memory attr for arch_prepare_bpf_trampoline */ 493 + set_memory_nx((long)im->image, 1); 494 + set_memory_rw((long)im->image, 1); 491 495 goto again; 492 496 } 493 497 #endif
+15 -6
kernel/bpf/verifier.c
··· 1054 1054 */ 1055 1055 static void *copy_array(void *dst, const void *src, size_t n, size_t size, gfp_t flags) 1056 1056 { 1057 + size_t alloc_bytes; 1058 + void *orig = dst; 1057 1059 size_t bytes; 1058 1060 1059 1061 if (ZERO_OR_NULL_PTR(src)) ··· 1064 1062 if (unlikely(check_mul_overflow(n, size, &bytes))) 1065 1063 return NULL; 1066 1064 1067 - if (ksize(dst) < ksize(src)) { 1068 - kfree(dst); 1069 - dst = kmalloc_track_caller(kmalloc_size_roundup(bytes), flags); 1070 - if (!dst) 1071 - return NULL; 1065 + alloc_bytes = max(ksize(orig), kmalloc_size_roundup(bytes)); 1066 + dst = krealloc(orig, alloc_bytes, flags); 1067 + if (!dst) { 1068 + kfree(orig); 1069 + return NULL; 1072 1070 } 1073 1071 1074 1072 memcpy(dst, src, bytes); ··· 11824 11822 * register B - not null 11825 11823 * for JNE A, B, ... - A is not null in the false branch; 11826 11824 * for JEQ A, B, ... - A is not null in the true branch. 11825 + * 11826 + * Since PTR_TO_BTF_ID points to a kernel struct that does 11827 + * not need to be null checked by the BPF program, i.e., 11828 + * could be null even without PTR_MAYBE_NULL marking, so 11829 + * only propagate nullness when neither reg is that type. 11827 11830 */ 11828 11831 if (!is_jmp32 && BPF_SRC(insn->code) == BPF_X && 11829 11832 __is_pointer_value(false, src_reg) && __is_pointer_value(false, dst_reg) && 11830 - type_may_be_null(src_reg->type) != type_may_be_null(dst_reg->type)) { 11833 + type_may_be_null(src_reg->type) != type_may_be_null(dst_reg->type) && 11834 + base_type(src_reg->type) != PTR_TO_BTF_ID && 11835 + base_type(dst_reg->type) != PTR_TO_BTF_ID) { 11831 11836 eq_branch_regs = NULL; 11832 11837 switch (opcode) { 11833 11838 case BPF_JEQ:
+17 -37
kernel/events/core.c
··· 380 380 381 381 /* 382 382 * perf_sched_events : >0 events exist 383 - * perf_cgroup_events: >0 per-cpu cgroup events exist on this cpu 384 383 */ 385 384 386 385 static void perf_sched_delayed(struct work_struct *work); ··· 388 389 static DEFINE_MUTEX(perf_sched_mutex); 389 390 static atomic_t perf_sched_count; 390 391 391 - static DEFINE_PER_CPU(atomic_t, perf_cgroup_events); 392 392 static DEFINE_PER_CPU(struct pmu_event_list, pmu_sb_events); 393 393 394 394 static atomic_t nr_mmap_events __read_mostly; ··· 842 844 struct perf_cpu_context *cpuctx = this_cpu_ptr(&perf_cpu_context); 843 845 struct perf_cgroup *cgrp; 844 846 845 - cgrp = perf_cgroup_from_task(task, NULL); 847 + /* 848 + * cpuctx->cgrp is set when the first cgroup event enabled, 849 + * and is cleared when the last cgroup event disabled. 850 + */ 851 + if (READ_ONCE(cpuctx->cgrp) == NULL) 852 + return; 846 853 847 854 WARN_ON_ONCE(cpuctx->ctx.nr_cgroups == 0); 855 + 856 + cgrp = perf_cgroup_from_task(task, NULL); 848 857 if (READ_ONCE(cpuctx->cgrp) == cgrp) 849 858 return; 850 859 ··· 3636 3631 * to check if we have to switch out PMU state. 3637 3632 * cgroup event are system-wide mode only 3638 3633 */ 3639 - if (atomic_read(this_cpu_ptr(&perf_cgroup_events))) 3640 - perf_cgroup_switch(next); 3634 + perf_cgroup_switch(next); 3641 3635 } 3642 3636 3643 3637 static bool perf_less_group_idx(const void *l, const void *r) ··· 4978 4974 detach_sb_event(event); 4979 4975 } 4980 4976 4981 - static void unaccount_event_cpu(struct perf_event *event, int cpu) 4982 - { 4983 - if (event->parent) 4984 - return; 4985 - 4986 - if (is_cgroup_event(event)) 4987 - atomic_dec(&per_cpu(perf_cgroup_events, cpu)); 4988 - } 4989 - 4990 4977 #ifdef CONFIG_NO_HZ_FULL 4991 4978 static DEFINE_SPINLOCK(nr_freq_lock); 4992 4979 #endif ··· 5042 5047 if (!atomic_add_unless(&perf_sched_count, -1, 1)) 5043 5048 schedule_delayed_work(&perf_sched_work, HZ); 5044 5049 } 5045 - 5046 - unaccount_event_cpu(event, event->cpu); 5047 5050 5048 5051 unaccount_pmu_sb_event(event); 5049 5052 } ··· 11672 11679 attach_sb_event(event); 11673 11680 } 11674 11681 11675 - static void account_event_cpu(struct perf_event *event, int cpu) 11676 - { 11677 - if (event->parent) 11678 - return; 11679 - 11680 - if (is_cgroup_event(event)) 11681 - atomic_inc(&per_cpu(perf_cgroup_events, cpu)); 11682 - } 11683 - 11684 11682 /* Freq events need the tick to stay alive (see perf_event_task_tick). */ 11685 11683 static void account_freq_event_nohz(void) 11686 11684 { ··· 11758 11774 mutex_unlock(&perf_sched_mutex); 11759 11775 } 11760 11776 enabled: 11761 - 11762 - account_event_cpu(event, event->cpu); 11763 11777 11764 11778 account_pmu_sb_event(event); 11765 11779 } ··· 12321 12339 if (flags & ~PERF_FLAG_ALL) 12322 12340 return -EINVAL; 12323 12341 12324 - /* Do we allow access to perf_event_open(2) ? */ 12325 - err = security_perf_event_open(&attr, PERF_SECURITY_OPEN); 12342 + err = perf_copy_attr(attr_uptr, &attr); 12326 12343 if (err) 12327 12344 return err; 12328 12345 12329 - err = perf_copy_attr(attr_uptr, &attr); 12346 + /* Do we allow access to perf_event_open(2) ? */ 12347 + err = security_perf_event_open(&attr, PERF_SECURITY_OPEN); 12330 12348 if (err) 12331 12349 return err; 12332 12350 ··· 12671 12689 return event_fd; 12672 12690 12673 12691 err_context: 12674 - /* event->pmu_ctx freed by free_event() */ 12692 + put_pmu_ctx(event->pmu_ctx); 12693 + event->pmu_ctx = NULL; /* _free_event() */ 12675 12694 err_locked: 12676 12695 mutex_unlock(&ctx->mutex); 12677 12696 perf_unpin_context(ctx); ··· 12785 12802 12786 12803 err_pmu_ctx: 12787 12804 put_pmu_ctx(pmu_ctx); 12805 + event->pmu_ctx = NULL; /* _free_event() */ 12788 12806 err_unlock: 12789 12807 mutex_unlock(&ctx->mutex); 12790 12808 perf_unpin_context(ctx); ··· 12806 12822 12807 12823 perf_event_groups_for_cpu_pmu(event, groups, cpu, pmu) { 12808 12824 perf_remove_from_context(event, 0); 12809 - unaccount_event_cpu(event, cpu); 12810 12825 put_pmu_ctx(event->pmu_ctx); 12811 12826 list_add(&event->migrate_entry, events); 12812 12827 12813 12828 for_each_sibling_event(sibling, event) { 12814 12829 perf_remove_from_context(sibling, 0); 12815 - unaccount_event_cpu(sibling, cpu); 12816 12830 put_pmu_ctx(sibling->pmu_ctx); 12817 12831 list_add(&sibling->migrate_entry, events); 12818 12832 } ··· 12829 12847 12830 12848 if (event->state >= PERF_EVENT_STATE_OFF) 12831 12849 event->state = PERF_EVENT_STATE_INACTIVE; 12832 - account_event_cpu(event, cpu); 12833 12850 perf_install_in_context(ctx, event, cpu); 12834 12851 } 12835 12852 ··· 13212 13231 pmu_ctx = find_get_pmu_context(child_event->pmu, child_ctx, child_event); 13213 13232 if (IS_ERR(pmu_ctx)) { 13214 13233 free_event(child_event); 13215 - return NULL; 13234 + return ERR_CAST(pmu_ctx); 13216 13235 } 13217 13236 child_event->pmu_ctx = pmu_ctx; 13218 13237 ··· 13723 13742 struct task_struct *task = info; 13724 13743 13725 13744 preempt_disable(); 13726 - if (atomic_read(this_cpu_ptr(&perf_cgroup_events))) 13727 - perf_cgroup_switch(task); 13745 + perf_cgroup_switch(task); 13728 13746 preempt_enable(); 13729 13747 13730 13748 return 0;
+7 -4
kernel/futex/syscalls.c
··· 286 286 } 287 287 288 288 futexv = kcalloc(nr_futexes, sizeof(*futexv), GFP_KERNEL); 289 - if (!futexv) 290 - return -ENOMEM; 289 + if (!futexv) { 290 + ret = -ENOMEM; 291 + goto destroy_timer; 292 + } 291 293 292 294 ret = futex_parse_waitv(futexv, waiters, nr_futexes); 293 295 if (!ret) 294 296 ret = futex_wait_multiple(futexv, nr_futexes, timeout ? &to : NULL); 295 297 298 + kfree(futexv); 299 + 300 + destroy_timer: 296 301 if (timeout) { 297 302 hrtimer_cancel(&to.timer); 298 303 destroy_hrtimer_on_stack(&to.timer); 299 304 } 300 - 301 - kfree(futexv); 302 305 return ret; 303 306 } 304 307
+46 -9
kernel/locking/rtmutex.c
··· 89 89 * set this bit before looking at the lock. 90 90 */ 91 91 92 - static __always_inline void 93 - rt_mutex_set_owner(struct rt_mutex_base *lock, struct task_struct *owner) 92 + static __always_inline struct task_struct * 93 + rt_mutex_owner_encode(struct rt_mutex_base *lock, struct task_struct *owner) 94 94 { 95 95 unsigned long val = (unsigned long)owner; 96 96 97 97 if (rt_mutex_has_waiters(lock)) 98 98 val |= RT_MUTEX_HAS_WAITERS; 99 99 100 - WRITE_ONCE(lock->owner, (struct task_struct *)val); 100 + return (struct task_struct *)val; 101 + } 102 + 103 + static __always_inline void 104 + rt_mutex_set_owner(struct rt_mutex_base *lock, struct task_struct *owner) 105 + { 106 + /* 107 + * lock->wait_lock is held but explicit acquire semantics are needed 108 + * for a new lock owner so WRITE_ONCE is insufficient. 109 + */ 110 + xchg_acquire(&lock->owner, rt_mutex_owner_encode(lock, owner)); 111 + } 112 + 113 + static __always_inline void rt_mutex_clear_owner(struct rt_mutex_base *lock) 114 + { 115 + /* lock->wait_lock is held so the unlock provides release semantics. */ 116 + WRITE_ONCE(lock->owner, rt_mutex_owner_encode(lock, NULL)); 101 117 } 102 118 103 119 static __always_inline void clear_rt_mutex_waiters(struct rt_mutex_base *lock) ··· 122 106 ((unsigned long)lock->owner & ~RT_MUTEX_HAS_WAITERS); 123 107 } 124 108 125 - static __always_inline void fixup_rt_mutex_waiters(struct rt_mutex_base *lock) 109 + static __always_inline void 110 + fixup_rt_mutex_waiters(struct rt_mutex_base *lock, bool acquire_lock) 126 111 { 127 112 unsigned long owner, *p = (unsigned long *) &lock->owner; 128 113 ··· 189 172 * still set. 190 173 */ 191 174 owner = READ_ONCE(*p); 192 - if (owner & RT_MUTEX_HAS_WAITERS) 193 - WRITE_ONCE(*p, owner & ~RT_MUTEX_HAS_WAITERS); 175 + if (owner & RT_MUTEX_HAS_WAITERS) { 176 + /* 177 + * See rt_mutex_set_owner() and rt_mutex_clear_owner() on 178 + * why xchg_acquire() is used for updating owner for 179 + * locking and WRITE_ONCE() for unlocking. 180 + * 181 + * WRITE_ONCE() would work for the acquire case too, but 182 + * in case that the lock acquisition failed it might 183 + * force other lockers into the slow path unnecessarily. 184 + */ 185 + if (acquire_lock) 186 + xchg_acquire(p, owner & ~RT_MUTEX_HAS_WAITERS); 187 + else 188 + WRITE_ONCE(*p, owner & ~RT_MUTEX_HAS_WAITERS); 189 + } 194 190 } 195 191 196 192 /* ··· 238 208 owner = *p; 239 209 } while (cmpxchg_relaxed(p, owner, 240 210 owner | RT_MUTEX_HAS_WAITERS) != owner); 211 + 212 + /* 213 + * The cmpxchg loop above is relaxed to avoid back-to-back ACQUIRE 214 + * operations in the event of contention. Ensure the successful 215 + * cmpxchg is visible. 216 + */ 217 + smp_mb__after_atomic(); 241 218 } 242 219 243 220 /* ··· 1280 1243 * try_to_take_rt_mutex() sets the lock waiters bit 1281 1244 * unconditionally. Clean this up. 1282 1245 */ 1283 - fixup_rt_mutex_waiters(lock); 1246 + fixup_rt_mutex_waiters(lock, true); 1284 1247 1285 1248 return ret; 1286 1249 } ··· 1641 1604 * try_to_take_rt_mutex() sets the waiter bit 1642 1605 * unconditionally. We might have to fix that up. 1643 1606 */ 1644 - fixup_rt_mutex_waiters(lock); 1607 + fixup_rt_mutex_waiters(lock, true); 1645 1608 1646 1609 trace_contention_end(lock, ret); 1647 1610 ··· 1756 1719 * try_to_take_rt_mutex() sets the waiter bit unconditionally. 1757 1720 * We might have to fix that up: 1758 1721 */ 1759 - fixup_rt_mutex_waiters(lock); 1722 + fixup_rt_mutex_waiters(lock, true); 1760 1723 debug_rt_mutex_free_waiter(&waiter); 1761 1724 1762 1725 trace_contention_end(lock, 0);
+3 -3
kernel/locking/rtmutex_api.c
··· 267 267 void __sched rt_mutex_proxy_unlock(struct rt_mutex_base *lock) 268 268 { 269 269 debug_rt_mutex_proxy_unlock(lock); 270 - rt_mutex_set_owner(lock, NULL); 270 + rt_mutex_clear_owner(lock); 271 271 } 272 272 273 273 /** ··· 382 382 * try_to_take_rt_mutex() sets the waiter bit unconditionally. We might 383 383 * have to fix that up. 384 384 */ 385 - fixup_rt_mutex_waiters(lock); 385 + fixup_rt_mutex_waiters(lock, true); 386 386 raw_spin_unlock_irq(&lock->wait_lock); 387 387 388 388 return ret; ··· 438 438 * try_to_take_rt_mutex() sets the waiter bit unconditionally. We might 439 439 * have to fix that up. 440 440 */ 441 - fixup_rt_mutex_waiters(lock); 441 + fixup_rt_mutex_waiters(lock, false); 442 442 443 443 raw_spin_unlock_irq(&lock->wait_lock); 444 444
+3 -1
lib/kunit/string-stream.c
··· 23 23 return ERR_PTR(-ENOMEM); 24 24 25 25 frag->fragment = kunit_kmalloc(test, len, gfp); 26 - if (!frag->fragment) 26 + if (!frag->fragment) { 27 + kunit_kfree(test, frag); 27 28 return ERR_PTR(-ENOMEM); 29 + } 28 30 29 31 return frag; 30 32 }
+1 -1
lib/scatterlist.c
··· 476 476 /* Merge contiguous pages into the last SG */ 477 477 prv_len = sgt_append->prv->length; 478 478 last_pg = sg_page(sgt_append->prv); 479 - while (n_pages && pages_are_mergeable(last_pg, pages[0])) { 479 + while (n_pages && pages_are_mergeable(pages[0], last_pg)) { 480 480 if (sgt_append->prv->length + PAGE_SIZE > max_segment) 481 481 break; 482 482 sgt_append->prv->length += PAGE_SIZE;
+1 -1
mm/memblock.c
··· 836 836 * @base: phys starting address of the boot memory block 837 837 * @size: size of the boot memory block in bytes 838 838 * 839 - * Free boot memory block previously allocated by memblock_alloc_xx() API. 839 + * Free boot memory block previously allocated by memblock_phys_alloc_xx() API. 840 840 * The freeing memory will not be released to the buddy allocator. 841 841 */ 842 842 int __init_memblock memblock_phys_free(phys_addr_t base, phys_addr_t size)
+5 -1
net/caif/cfctrl.c
··· 269 269 default: 270 270 pr_warn("Request setup of bad link type = %d\n", 271 271 param->linktype); 272 + cfpkt_destroy(pkt); 272 273 return -EINVAL; 273 274 } 274 275 req = kzalloc(sizeof(*req), GFP_KERNEL); 275 - if (!req) 276 + if (!req) { 277 + cfpkt_destroy(pkt); 276 278 return -ENOMEM; 279 + } 280 + 277 281 req->client_layer = user_layer; 278 282 req->cmd = CFCTRL_CMD_LINK_SETUP; 279 283 req->param = *param;
+5 -2
net/core/filter.c
··· 3180 3180 3181 3181 static int bpf_skb_generic_pop(struct sk_buff *skb, u32 off, u32 len) 3182 3182 { 3183 + void *old_data; 3184 + 3183 3185 /* skb_ensure_writable() is not needed here, as we're 3184 3186 * already working on an uncloned skb. 3185 3187 */ 3186 3188 if (unlikely(!pskb_may_pull(skb, off + len))) 3187 3189 return -ENOMEM; 3188 3190 3189 - skb_postpull_rcsum(skb, skb->data + off, len); 3190 - memmove(skb->data + len, skb->data, off); 3191 + old_data = skb->data; 3191 3192 __skb_pull(skb, len); 3193 + skb_postpull_rcsum(skb, old_data + off, len); 3194 + memmove(skb->data, old_data, off); 3192 3195 3193 3196 return 0; 3194 3197 }
+71 -38
net/ethtool/ioctl.c
··· 2078 2078 return ret; 2079 2079 } 2080 2080 2081 - static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr) 2081 + static int ethtool_vzalloc_stats_array(int n_stats, u64 **data) 2082 2082 { 2083 - const struct ethtool_phy_ops *phy_ops = ethtool_phy_ops; 2084 - const struct ethtool_ops *ops = dev->ethtool_ops; 2085 - struct phy_device *phydev = dev->phydev; 2086 - struct ethtool_stats stats; 2087 - u64 *data; 2088 - int ret, n_stats; 2089 - 2090 - if (!phydev && (!ops->get_ethtool_phy_stats || !ops->get_sset_count)) 2091 - return -EOPNOTSUPP; 2092 - 2093 - if (phydev && !ops->get_ethtool_phy_stats && 2094 - phy_ops && phy_ops->get_sset_count) 2095 - n_stats = phy_ops->get_sset_count(phydev); 2096 - else 2097 - n_stats = ops->get_sset_count(dev, ETH_SS_PHY_STATS); 2098 2083 if (n_stats < 0) 2099 2084 return n_stats; 2100 2085 if (n_stats > S32_MAX / sizeof(u64)) 2101 2086 return -ENOMEM; 2102 - WARN_ON_ONCE(!n_stats); 2087 + if (WARN_ON_ONCE(!n_stats)) 2088 + return -EOPNOTSUPP; 2089 + 2090 + *data = vzalloc(array_size(n_stats, sizeof(u64))); 2091 + if (!*data) 2092 + return -ENOMEM; 2093 + 2094 + return 0; 2095 + } 2096 + 2097 + static int ethtool_get_phy_stats_phydev(struct phy_device *phydev, 2098 + struct ethtool_stats *stats, 2099 + u64 **data) 2100 + { 2101 + const struct ethtool_phy_ops *phy_ops = ethtool_phy_ops; 2102 + int n_stats, ret; 2103 + 2104 + if (!phy_ops || !phy_ops->get_sset_count || !phy_ops->get_stats) 2105 + return -EOPNOTSUPP; 2106 + 2107 + n_stats = phy_ops->get_sset_count(phydev); 2108 + 2109 + ret = ethtool_vzalloc_stats_array(n_stats, data); 2110 + if (ret) 2111 + return ret; 2112 + 2113 + stats->n_stats = n_stats; 2114 + return phy_ops->get_stats(phydev, stats, *data); 2115 + } 2116 + 2117 + static int ethtool_get_phy_stats_ethtool(struct net_device *dev, 2118 + struct ethtool_stats *stats, 2119 + u64 **data) 2120 + { 2121 + const struct ethtool_ops *ops = dev->ethtool_ops; 2122 + int n_stats, ret; 2123 + 2124 + if (!ops || !ops->get_sset_count || ops->get_ethtool_phy_stats) 2125 + return -EOPNOTSUPP; 2126 + 2127 + n_stats = ops->get_sset_count(dev, ETH_SS_PHY_STATS); 2128 + 2129 + ret = ethtool_vzalloc_stats_array(n_stats, data); 2130 + if (ret) 2131 + return ret; 2132 + 2133 + stats->n_stats = n_stats; 2134 + ops->get_ethtool_phy_stats(dev, stats, *data); 2135 + 2136 + return 0; 2137 + } 2138 + 2139 + static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr) 2140 + { 2141 + struct phy_device *phydev = dev->phydev; 2142 + struct ethtool_stats stats; 2143 + u64 *data = NULL; 2144 + int ret = -EOPNOTSUPP; 2103 2145 2104 2146 if (copy_from_user(&stats, useraddr, sizeof(stats))) 2105 2147 return -EFAULT; 2106 2148 2107 - stats.n_stats = n_stats; 2149 + if (phydev) 2150 + ret = ethtool_get_phy_stats_phydev(phydev, &stats, &data); 2108 2151 2109 - if (n_stats) { 2110 - data = vzalloc(array_size(n_stats, sizeof(u64))); 2111 - if (!data) 2112 - return -ENOMEM; 2152 + if (ret == -EOPNOTSUPP) 2153 + ret = ethtool_get_phy_stats_ethtool(dev, &stats, &data); 2113 2154 2114 - if (phydev && !ops->get_ethtool_phy_stats && 2115 - phy_ops && phy_ops->get_stats) { 2116 - ret = phy_ops->get_stats(phydev, &stats, data); 2117 - if (ret < 0) 2118 - goto out; 2119 - } else { 2120 - ops->get_ethtool_phy_stats(dev, &stats, data); 2121 - } 2122 - } else { 2123 - data = NULL; 2155 + if (ret) 2156 + goto out; 2157 + 2158 + if (copy_to_user(useraddr, &stats, sizeof(stats))) { 2159 + ret = -EFAULT; 2160 + goto out; 2124 2161 } 2125 2162 2126 - ret = -EFAULT; 2127 - if (copy_to_user(useraddr, &stats, sizeof(stats))) 2128 - goto out; 2129 2163 useraddr += sizeof(stats); 2130 - if (n_stats && copy_to_user(useraddr, data, array_size(n_stats, sizeof(u64)))) 2131 - goto out; 2132 - ret = 0; 2164 + if (copy_to_user(useraddr, data, array_size(stats.n_stats, sizeof(u64)))) 2165 + ret = -EFAULT; 2133 2166 2134 2167 out: 2135 2168 vfree(data);
+1
net/ipv4/af_inet.c
··· 1665 1665 if (rc == 0) { 1666 1666 *sk = sock->sk; 1667 1667 (*sk)->sk_allocation = GFP_ATOMIC; 1668 + (*sk)->sk_use_task_frag = false; 1668 1669 /* 1669 1670 * Unhash it so that IP input processing does not even see it, 1670 1671 * we do not wish this socket to see incoming packets.
+37 -5
net/ipv4/inet_connection_sock.c
··· 173 173 return false; 174 174 } 175 175 176 + static bool __inet_bhash2_conflict(const struct sock *sk, struct sock *sk2, 177 + kuid_t sk_uid, bool relax, 178 + bool reuseport_cb_ok, bool reuseport_ok) 179 + { 180 + if (sk->sk_family == AF_INET && ipv6_only_sock(sk2)) 181 + return false; 182 + 183 + return inet_bind_conflict(sk, sk2, sk_uid, relax, 184 + reuseport_cb_ok, reuseport_ok); 185 + } 186 + 176 187 static bool inet_bhash2_conflict(const struct sock *sk, 177 188 const struct inet_bind2_bucket *tb2, 178 189 kuid_t sk_uid, 179 190 bool relax, bool reuseport_cb_ok, 180 191 bool reuseport_ok) 181 192 { 193 + struct inet_timewait_sock *tw2; 182 194 struct sock *sk2; 183 195 184 196 sk_for_each_bound_bhash2(sk2, &tb2->owners) { 185 - if (sk->sk_family == AF_INET && ipv6_only_sock(sk2)) 186 - continue; 187 - 188 - if (inet_bind_conflict(sk, sk2, sk_uid, relax, 189 - reuseport_cb_ok, reuseport_ok)) 197 + if (__inet_bhash2_conflict(sk, sk2, sk_uid, relax, 198 + reuseport_cb_ok, reuseport_ok)) 190 199 return true; 191 200 } 201 + 202 + twsk_for_each_bound_bhash2(tw2, &tb2->deathrow) { 203 + sk2 = (struct sock *)tw2; 204 + 205 + if (__inet_bhash2_conflict(sk, sk2, sk_uid, relax, 206 + reuseport_cb_ok, reuseport_ok)) 207 + return true; 208 + } 209 + 192 210 return false; 193 211 } 194 212 ··· 1200 1182 } 1201 1183 EXPORT_SYMBOL(inet_csk_prepare_forced_close); 1202 1184 1185 + static int inet_ulp_can_listen(const struct sock *sk) 1186 + { 1187 + const struct inet_connection_sock *icsk = inet_csk(sk); 1188 + 1189 + if (icsk->icsk_ulp_ops && !icsk->icsk_ulp_ops->clone) 1190 + return -EINVAL; 1191 + 1192 + return 0; 1193 + } 1194 + 1203 1195 int inet_csk_listen_start(struct sock *sk) 1204 1196 { 1205 1197 struct inet_connection_sock *icsk = inet_csk(sk); 1206 1198 struct inet_sock *inet = inet_sk(sk); 1207 1199 int err; 1200 + 1201 + err = inet_ulp_can_listen(sk); 1202 + if (unlikely(err)) 1203 + return err; 1208 1204 1209 1205 reqsk_queue_alloc(&icsk->icsk_accept_queue); 1210 1206
+5 -3
net/ipv4/inet_hashtables.c
··· 116 116 #endif 117 117 tb->rcv_saddr = sk->sk_rcv_saddr; 118 118 INIT_HLIST_HEAD(&tb->owners); 119 + INIT_HLIST_HEAD(&tb->deathrow); 119 120 hlist_add_head(&tb->node, &head->chain); 120 121 } 121 122 ··· 138 137 /* Caller must hold hashbucket lock for this tb with local BH disabled */ 139 138 void inet_bind2_bucket_destroy(struct kmem_cache *cachep, struct inet_bind2_bucket *tb) 140 139 { 141 - if (hlist_empty(&tb->owners)) { 140 + if (hlist_empty(&tb->owners) && hlist_empty(&tb->deathrow)) { 142 141 __hlist_del(&tb->node); 143 142 kmem_cache_free(cachep, tb); 144 143 } ··· 1104 1103 /* Head lock still held and bh's disabled */ 1105 1104 inet_bind_hash(sk, tb, tb2, port); 1106 1105 1107 - spin_unlock(&head2->lock); 1108 - 1109 1106 if (sk_unhashed(sk)) { 1110 1107 inet_sk(sk)->inet_sport = htons(port); 1111 1108 inet_ehash_nolisten(sk, (struct sock *)tw, NULL); 1112 1109 } 1113 1110 if (tw) 1114 1111 inet_twsk_bind_unhash(tw, hinfo); 1112 + 1113 + spin_unlock(&head2->lock); 1115 1114 spin_unlock(&head->lock); 1115 + 1116 1116 if (tw) 1117 1117 inet_twsk_deschedule_put(tw); 1118 1118 local_bh_enable();
+29 -2
net/ipv4/inet_timewait_sock.c
··· 29 29 void inet_twsk_bind_unhash(struct inet_timewait_sock *tw, 30 30 struct inet_hashinfo *hashinfo) 31 31 { 32 + struct inet_bind2_bucket *tb2 = tw->tw_tb2; 32 33 struct inet_bind_bucket *tb = tw->tw_tb; 33 34 34 35 if (!tb) ··· 38 37 __hlist_del(&tw->tw_bind_node); 39 38 tw->tw_tb = NULL; 40 39 inet_bind_bucket_destroy(hashinfo->bind_bucket_cachep, tb); 40 + 41 + __hlist_del(&tw->tw_bind2_node); 42 + tw->tw_tb2 = NULL; 43 + inet_bind2_bucket_destroy(hashinfo->bind2_bucket_cachep, tb2); 44 + 41 45 __sock_put((struct sock *)tw); 42 46 } 43 47 ··· 51 45 { 52 46 struct inet_hashinfo *hashinfo = tw->tw_dr->hashinfo; 53 47 spinlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash); 54 - struct inet_bind_hashbucket *bhead; 48 + struct inet_bind_hashbucket *bhead, *bhead2; 55 49 56 50 spin_lock(lock); 57 51 sk_nulls_del_node_init_rcu((struct sock *)tw); ··· 60 54 /* Disassociate with bind bucket. */ 61 55 bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), tw->tw_num, 62 56 hashinfo->bhash_size)]; 57 + bhead2 = inet_bhashfn_portaddr(hashinfo, (struct sock *)tw, 58 + twsk_net(tw), tw->tw_num); 63 59 64 60 spin_lock(&bhead->lock); 61 + spin_lock(&bhead2->lock); 65 62 inet_twsk_bind_unhash(tw, hashinfo); 63 + spin_unlock(&bhead2->lock); 66 64 spin_unlock(&bhead->lock); 67 65 68 66 refcount_dec(&tw->tw_dr->tw_refcount); ··· 103 93 hlist_add_head(&tw->tw_bind_node, list); 104 94 } 105 95 96 + static void inet_twsk_add_bind2_node(struct inet_timewait_sock *tw, 97 + struct hlist_head *list) 98 + { 99 + hlist_add_head(&tw->tw_bind2_node, list); 100 + } 101 + 106 102 /* 107 103 * Enter the time wait state. This is called with locally disabled BH. 108 104 * Essentially we whip up a timewait bucket, copy the relevant info into it ··· 121 105 const struct inet_connection_sock *icsk = inet_csk(sk); 122 106 struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, sk->sk_hash); 123 107 spinlock_t *lock = inet_ehash_lockp(hashinfo, sk->sk_hash); 124 - struct inet_bind_hashbucket *bhead; 108 + struct inet_bind_hashbucket *bhead, *bhead2; 109 + 125 110 /* Step 1: Put TW into bind hash. Original socket stays there too. 126 111 Note, that any socket with inet->num != 0 MUST be bound in 127 112 binding cache, even if it is closed. 128 113 */ 129 114 bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), inet->inet_num, 130 115 hashinfo->bhash_size)]; 116 + bhead2 = inet_bhashfn_portaddr(hashinfo, sk, twsk_net(tw), inet->inet_num); 117 + 131 118 spin_lock(&bhead->lock); 119 + spin_lock(&bhead2->lock); 120 + 132 121 tw->tw_tb = icsk->icsk_bind_hash; 133 122 WARN_ON(!icsk->icsk_bind_hash); 134 123 inet_twsk_add_bind_node(tw, &tw->tw_tb->owners); 124 + 125 + tw->tw_tb2 = icsk->icsk_bind2_hash; 126 + WARN_ON(!icsk->icsk_bind2_hash); 127 + inet_twsk_add_bind2_node(tw, &tw->tw_tb2->deathrow); 128 + 129 + spin_unlock(&bhead2->lock); 135 130 spin_unlock(&bhead->lock); 136 131 137 132 spin_lock(lock);
+4
net/ipv4/tcp_ulp.c
··· 139 139 if (sk->sk_socket) 140 140 clear_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags); 141 141 142 + err = -EINVAL; 143 + if (!ulp_ops->clone && sk->sk_state == TCP_LISTEN) 144 + goto out_err; 145 + 142 146 err = ulp_ops->init(sk); 143 147 if (err) 144 148 goto out_err;
+16 -4
net/mptcp/protocol.c
··· 1662 1662 set_bit(MPTCP_NOSPACE, &mptcp_sk(sk)->flags); 1663 1663 } 1664 1664 1665 + static int mptcp_disconnect(struct sock *sk, int flags); 1666 + 1665 1667 static int mptcp_sendmsg_fastopen(struct sock *sk, struct sock *ssk, struct msghdr *msg, 1666 1668 size_t len, int *copied_syn) 1667 1669 { ··· 1674 1672 lock_sock(ssk); 1675 1673 msg->msg_flags |= MSG_DONTWAIT; 1676 1674 msk->connect_flags = O_NONBLOCK; 1677 - msk->is_sendmsg = 1; 1675 + msk->fastopening = 1; 1678 1676 ret = tcp_sendmsg_fastopen(ssk, msg, copied_syn, len, NULL); 1679 - msk->is_sendmsg = 0; 1677 + msk->fastopening = 0; 1680 1678 msg->msg_flags = saved_flags; 1681 1679 release_sock(ssk); 1682 1680 ··· 1690 1688 */ 1691 1689 if (ret && ret != -EINPROGRESS && ret != -ERESTARTSYS && ret != -EINTR) 1692 1690 *copied_syn = 0; 1691 + } else if (ret && ret != -EINPROGRESS) { 1692 + mptcp_disconnect(sk, 0); 1693 1693 } 1694 1694 1695 1695 return ret; ··· 2357 2353 /* otherwise tcp will dispose of the ssk and subflow ctx */ 2358 2354 if (ssk->sk_state == TCP_LISTEN) { 2359 2355 tcp_set_state(ssk, TCP_CLOSE); 2360 - mptcp_subflow_queue_clean(ssk); 2356 + mptcp_subflow_queue_clean(sk, ssk); 2361 2357 inet_csk_listen_stop(ssk); 2362 2358 mptcp_event_pm_listener(ssk, MPTCP_EVENT_LISTENER_CLOSED); 2363 2359 } ··· 2993 2989 { 2994 2990 struct mptcp_sock *msk = mptcp_sk(sk); 2995 2991 2992 + /* We are on the fastopen error path. We can't call straight into the 2993 + * subflows cleanup code due to lock nesting (we are already under 2994 + * msk->firstsocket lock). Do nothing and leave the cleanup to the 2995 + * caller. 2996 + */ 2997 + if (msk->fastopening) 2998 + return 0; 2999 + 2996 3000 inet_sk_state_store(sk, TCP_CLOSE); 2997 3001 2998 3002 mptcp_stop_timer(sk); ··· 3544 3532 /* if reaching here via the fastopen/sendmsg path, the caller already 3545 3533 * acquired the subflow socket lock, too. 3546 3534 */ 3547 - if (msk->is_sendmsg) 3535 + if (msk->fastopening) 3548 3536 err = __inet_stream_connect(ssock, uaddr, addr_len, msk->connect_flags, 1); 3549 3537 else 3550 3538 err = inet_stream_connect(ssock, uaddr, addr_len, msk->connect_flags);
+2 -2
net/mptcp/protocol.h
··· 295 295 u8 recvmsg_inq:1, 296 296 cork:1, 297 297 nodelay:1, 298 - is_sendmsg:1; 298 + fastopening:1; 299 299 int connect_flags; 300 300 struct work_struct work; 301 301 struct sk_buff *ooo_last_skb; ··· 628 628 struct mptcp_subflow_context *subflow); 629 629 void __mptcp_subflow_send_ack(struct sock *ssk); 630 630 void mptcp_subflow_reset(struct sock *ssk); 631 - void mptcp_subflow_queue_clean(struct sock *ssk); 631 + void mptcp_subflow_queue_clean(struct sock *sk, struct sock *ssk); 632 632 void mptcp_sock_graft(struct sock *sk, struct socket *parent); 633 633 struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk); 634 634 bool __mptcp_close(struct sock *sk, long timeout);
+17 -2
net/mptcp/subflow.c
··· 1791 1791 } 1792 1792 } 1793 1793 1794 - void mptcp_subflow_queue_clean(struct sock *listener_ssk) 1794 + void mptcp_subflow_queue_clean(struct sock *listener_sk, struct sock *listener_ssk) 1795 1795 { 1796 1796 struct request_sock_queue *queue = &inet_csk(listener_ssk)->icsk_accept_queue; 1797 1797 struct mptcp_sock *msk, *next, *head = NULL; ··· 1840 1840 1841 1841 do_cancel_work = __mptcp_close(sk, 0); 1842 1842 release_sock(sk); 1843 - if (do_cancel_work) 1843 + if (do_cancel_work) { 1844 + /* lockdep will report a false positive ABBA deadlock 1845 + * between cancel_work_sync and the listener socket. 1846 + * The involved locks belong to different sockets WRT 1847 + * the existing AB chain. 1848 + * Using a per socket key is problematic as key 1849 + * deregistration requires process context and must be 1850 + * performed at socket disposal time, in atomic 1851 + * context. 1852 + * Just tell lockdep to consider the listener socket 1853 + * released here. 1854 + */ 1855 + mutex_release(&listener_sk->sk_lock.dep_map, _RET_IP_); 1844 1856 mptcp_cancel_work(sk); 1857 + mutex_acquire(&listener_sk->sk_lock.dep_map, 1858 + SINGLE_DEPTH_NESTING, 0, _RET_IP_); 1859 + } 1845 1860 sock_put(sk); 1846 1861 } 1847 1862
+4 -3
net/netfilter/ipset/ip_set_core.c
··· 1698 1698 ret = set->variant->uadt(set, tb, adt, &lineno, flags, retried); 1699 1699 ip_set_unlock(set); 1700 1700 retried = true; 1701 - } while (ret == -EAGAIN && 1702 - set->variant->resize && 1703 - (ret = set->variant->resize(set, retried)) == 0); 1701 + } while (ret == -ERANGE || 1702 + (ret == -EAGAIN && 1703 + set->variant->resize && 1704 + (ret = set->variant->resize(set, retried)) == 0)); 1704 1705 1705 1706 if (!ret || (ret == -IPSET_ERR_EXIST && eexist)) 1706 1707 return 0;
+7 -7
net/netfilter/ipset/ip_set_hash_ip.c
··· 100 100 hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[], 101 101 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 102 102 { 103 - const struct hash_ip4 *h = set->data; 103 + struct hash_ip4 *h = set->data; 104 104 ipset_adtfn adtfn = set->variant->adt[adt]; 105 105 struct hash_ip4_elem e = { 0 }; 106 106 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 107 - u32 ip = 0, ip_to = 0, hosts; 107 + u32 ip = 0, ip_to = 0, hosts, i = 0; 108 108 int ret = 0; 109 109 110 110 if (tb[IPSET_ATTR_LINENO]) ··· 149 149 150 150 hosts = h->netmask == 32 ? 1 : 2 << (32 - h->netmask - 1); 151 151 152 - /* 64bit division is not allowed on 32bit */ 153 - if (((u64)ip_to - ip + 1) >> (32 - h->netmask) > IPSET_MAX_RANGE) 154 - return -ERANGE; 155 - 156 152 if (retried) 157 153 ip = ntohl(h->next.ip); 158 - for (; ip <= ip_to;) { 154 + for (; ip <= ip_to; i++) { 159 155 e.ip = htonl(ip); 156 + if (i > IPSET_MAX_RANGE) { 157 + hash_ip4_data_next(&h->next, &e); 158 + return -ERANGE; 159 + } 160 160 ret = adtfn(set, &e, &ext, &ext, flags); 161 161 if (ret && !ip_set_eexist(ret, flags)) 162 162 return ret;
+7 -6
net/netfilter/ipset/ip_set_hash_ipmark.c
··· 97 97 hash_ipmark4_uadt(struct ip_set *set, struct nlattr *tb[], 98 98 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 99 99 { 100 - const struct hash_ipmark4 *h = set->data; 100 + struct hash_ipmark4 *h = set->data; 101 101 ipset_adtfn adtfn = set->variant->adt[adt]; 102 102 struct hash_ipmark4_elem e = { }; 103 103 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 104 - u32 ip, ip_to = 0; 104 + u32 ip, ip_to = 0, i = 0; 105 105 int ret; 106 106 107 107 if (tb[IPSET_ATTR_LINENO]) ··· 148 148 ip_set_mask_from_to(ip, ip_to, cidr); 149 149 } 150 150 151 - if (((u64)ip_to - ip + 1) > IPSET_MAX_RANGE) 152 - return -ERANGE; 153 - 154 151 if (retried) 155 152 ip = ntohl(h->next.ip); 156 - for (; ip <= ip_to; ip++) { 153 + for (; ip <= ip_to; ip++, i++) { 157 154 e.ip = htonl(ip); 155 + if (i > IPSET_MAX_RANGE) { 156 + hash_ipmark4_data_next(&h->next, &e); 157 + return -ERANGE; 158 + } 158 159 ret = adtfn(set, &e, &ext, &ext, flags); 159 160 160 161 if (ret && !ip_set_eexist(ret, flags))
+7 -6
net/netfilter/ipset/ip_set_hash_ipport.c
··· 112 112 hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[], 113 113 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 114 114 { 115 - const struct hash_ipport4 *h = set->data; 115 + struct hash_ipport4 *h = set->data; 116 116 ipset_adtfn adtfn = set->variant->adt[adt]; 117 117 struct hash_ipport4_elem e = { .ip = 0 }; 118 118 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 119 - u32 ip, ip_to = 0, p = 0, port, port_to; 119 + u32 ip, ip_to = 0, p = 0, port, port_to, i = 0; 120 120 bool with_ports = false; 121 121 int ret; 122 122 ··· 184 184 swap(port, port_to); 185 185 } 186 186 187 - if (((u64)ip_to - ip + 1)*(port_to - port + 1) > IPSET_MAX_RANGE) 188 - return -ERANGE; 189 - 190 187 if (retried) 191 188 ip = ntohl(h->next.ip); 192 189 for (; ip <= ip_to; ip++) { 193 190 p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port) 194 191 : port; 195 - for (; p <= port_to; p++) { 192 + for (; p <= port_to; p++, i++) { 196 193 e.ip = htonl(ip); 197 194 e.port = htons(p); 195 + if (i > IPSET_MAX_RANGE) { 196 + hash_ipport4_data_next(&h->next, &e); 197 + return -ERANGE; 198 + } 198 199 ret = adtfn(set, &e, &ext, &ext, flags); 199 200 200 201 if (ret && !ip_set_eexist(ret, flags))
+7 -6
net/netfilter/ipset/ip_set_hash_ipportip.c
··· 108 108 hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[], 109 109 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 110 110 { 111 - const struct hash_ipportip4 *h = set->data; 111 + struct hash_ipportip4 *h = set->data; 112 112 ipset_adtfn adtfn = set->variant->adt[adt]; 113 113 struct hash_ipportip4_elem e = { .ip = 0 }; 114 114 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 115 - u32 ip, ip_to = 0, p = 0, port, port_to; 115 + u32 ip, ip_to = 0, p = 0, port, port_to, i = 0; 116 116 bool with_ports = false; 117 117 int ret; 118 118 ··· 180 180 swap(port, port_to); 181 181 } 182 182 183 - if (((u64)ip_to - ip + 1)*(port_to - port + 1) > IPSET_MAX_RANGE) 184 - return -ERANGE; 185 - 186 183 if (retried) 187 184 ip = ntohl(h->next.ip); 188 185 for (; ip <= ip_to; ip++) { 189 186 p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port) 190 187 : port; 191 - for (; p <= port_to; p++) { 188 + for (; p <= port_to; p++, i++) { 192 189 e.ip = htonl(ip); 193 190 e.port = htons(p); 191 + if (i > IPSET_MAX_RANGE) { 192 + hash_ipportip4_data_next(&h->next, &e); 193 + return -ERANGE; 194 + } 194 195 ret = adtfn(set, &e, &ext, &ext, flags); 195 196 196 197 if (ret && !ip_set_eexist(ret, flags))
+8 -5
net/netfilter/ipset/ip_set_hash_ipportnet.c
··· 160 160 hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[], 161 161 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 162 162 { 163 - const struct hash_ipportnet4 *h = set->data; 163 + struct hash_ipportnet4 *h = set->data; 164 164 ipset_adtfn adtfn = set->variant->adt[adt]; 165 165 struct hash_ipportnet4_elem e = { .cidr = HOST_MASK - 1 }; 166 166 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 167 167 u32 ip = 0, ip_to = 0, p = 0, port, port_to; 168 - u32 ip2_from = 0, ip2_to = 0, ip2; 168 + u32 ip2_from = 0, ip2_to = 0, ip2, i = 0; 169 169 bool with_ports = false; 170 170 u8 cidr; 171 171 int ret; ··· 253 253 swap(port, port_to); 254 254 } 255 255 256 - if (((u64)ip_to - ip + 1)*(port_to - port + 1) > IPSET_MAX_RANGE) 257 - return -ERANGE; 258 - 259 256 ip2_to = ip2_from; 260 257 if (tb[IPSET_ATTR_IP2_TO]) { 261 258 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2_TO], &ip2_to); ··· 279 282 for (; p <= port_to; p++) { 280 283 e.port = htons(p); 281 284 do { 285 + i++; 282 286 e.ip2 = htonl(ip2); 283 287 ip2 = ip_set_range_to_cidr(ip2, ip2_to, &cidr); 284 288 e.cidr = cidr - 1; 289 + if (i > IPSET_MAX_RANGE) { 290 + hash_ipportnet4_data_next(&h->next, 291 + &e); 292 + return -ERANGE; 293 + } 285 294 ret = adtfn(set, &e, &ext, &ext, flags); 286 295 287 296 if (ret && !ip_set_eexist(ret, flags))
+7 -10
net/netfilter/ipset/ip_set_hash_net.c
··· 136 136 hash_net4_uadt(struct ip_set *set, struct nlattr *tb[], 137 137 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 138 138 { 139 - const struct hash_net4 *h = set->data; 139 + struct hash_net4 *h = set->data; 140 140 ipset_adtfn adtfn = set->variant->adt[adt]; 141 141 struct hash_net4_elem e = { .cidr = HOST_MASK }; 142 142 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 143 - u32 ip = 0, ip_to = 0, ipn, n = 0; 143 + u32 ip = 0, ip_to = 0, i = 0; 144 144 int ret; 145 145 146 146 if (tb[IPSET_ATTR_LINENO]) ··· 188 188 if (ip + UINT_MAX == ip_to) 189 189 return -IPSET_ERR_HASH_RANGE; 190 190 } 191 - ipn = ip; 192 - do { 193 - ipn = ip_set_range_to_cidr(ipn, ip_to, &e.cidr); 194 - n++; 195 - } while (ipn++ < ip_to); 196 - 197 - if (n > IPSET_MAX_RANGE) 198 - return -ERANGE; 199 191 200 192 if (retried) 201 193 ip = ntohl(h->next.ip); 202 194 do { 195 + i++; 203 196 e.ip = htonl(ip); 197 + if (i > IPSET_MAX_RANGE) { 198 + hash_net4_data_next(&h->next, &e); 199 + return -ERANGE; 200 + } 204 201 ip = ip_set_range_to_cidr(ip, ip_to, &e.cidr); 205 202 ret = adtfn(set, &e, &ext, &ext, flags); 206 203 if (ret && !ip_set_eexist(ret, flags))
+6 -9
net/netfilter/ipset/ip_set_hash_netiface.c
··· 202 202 ipset_adtfn adtfn = set->variant->adt[adt]; 203 203 struct hash_netiface4_elem e = { .cidr = HOST_MASK, .elem = 1 }; 204 204 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 205 - u32 ip = 0, ip_to = 0, ipn, n = 0; 205 + u32 ip = 0, ip_to = 0, i = 0; 206 206 int ret; 207 207 208 208 if (tb[IPSET_ATTR_LINENO]) ··· 256 256 } else { 257 257 ip_set_mask_from_to(ip, ip_to, e.cidr); 258 258 } 259 - ipn = ip; 260 - do { 261 - ipn = ip_set_range_to_cidr(ipn, ip_to, &e.cidr); 262 - n++; 263 - } while (ipn++ < ip_to); 264 - 265 - if (n > IPSET_MAX_RANGE) 266 - return -ERANGE; 267 259 268 260 if (retried) 269 261 ip = ntohl(h->next.ip); 270 262 do { 263 + i++; 271 264 e.ip = htonl(ip); 265 + if (i > IPSET_MAX_RANGE) { 266 + hash_netiface4_data_next(&h->next, &e); 267 + return -ERANGE; 268 + } 272 269 ip = ip_set_range_to_cidr(ip, ip_to, &e.cidr); 273 270 ret = adtfn(set, &e, &ext, &ext, flags); 274 271
+7 -16
net/netfilter/ipset/ip_set_hash_netnet.c
··· 166 166 hash_netnet4_uadt(struct ip_set *set, struct nlattr *tb[], 167 167 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 168 168 { 169 - const struct hash_netnet4 *h = set->data; 169 + struct hash_netnet4 *h = set->data; 170 170 ipset_adtfn adtfn = set->variant->adt[adt]; 171 171 struct hash_netnet4_elem e = { }; 172 172 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 173 173 u32 ip = 0, ip_to = 0; 174 - u32 ip2 = 0, ip2_from = 0, ip2_to = 0, ipn; 175 - u64 n = 0, m = 0; 174 + u32 ip2 = 0, ip2_from = 0, ip2_to = 0, i = 0; 176 175 int ret; 177 176 178 177 if (tb[IPSET_ATTR_LINENO]) ··· 247 248 } else { 248 249 ip_set_mask_from_to(ip2_from, ip2_to, e.cidr[1]); 249 250 } 250 - ipn = ip; 251 - do { 252 - ipn = ip_set_range_to_cidr(ipn, ip_to, &e.cidr[0]); 253 - n++; 254 - } while (ipn++ < ip_to); 255 - ipn = ip2_from; 256 - do { 257 - ipn = ip_set_range_to_cidr(ipn, ip2_to, &e.cidr[1]); 258 - m++; 259 - } while (ipn++ < ip2_to); 260 - 261 - if (n*m > IPSET_MAX_RANGE) 262 - return -ERANGE; 263 251 264 252 if (retried) { 265 253 ip = ntohl(h->next.ip[0]); ··· 259 273 e.ip[0] = htonl(ip); 260 274 ip = ip_set_range_to_cidr(ip, ip_to, &e.cidr[0]); 261 275 do { 276 + i++; 262 277 e.ip[1] = htonl(ip2); 278 + if (i > IPSET_MAX_RANGE) { 279 + hash_netnet4_data_next(&h->next, &e); 280 + return -ERANGE; 281 + } 263 282 ip2 = ip_set_range_to_cidr(ip2, ip2_to, &e.cidr[1]); 264 283 ret = adtfn(set, &e, &ext, &ext, flags); 265 284 if (ret && !ip_set_eexist(ret, flags))
+7 -12
net/netfilter/ipset/ip_set_hash_netport.c
··· 154 154 hash_netport4_uadt(struct ip_set *set, struct nlattr *tb[], 155 155 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 156 156 { 157 - const struct hash_netport4 *h = set->data; 157 + struct hash_netport4 *h = set->data; 158 158 ipset_adtfn adtfn = set->variant->adt[adt]; 159 159 struct hash_netport4_elem e = { .cidr = HOST_MASK - 1 }; 160 160 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 161 - u32 port, port_to, p = 0, ip = 0, ip_to = 0, ipn; 162 - u64 n = 0; 161 + u32 port, port_to, p = 0, ip = 0, ip_to = 0, i = 0; 163 162 bool with_ports = false; 164 163 u8 cidr; 165 164 int ret; ··· 235 236 } else { 236 237 ip_set_mask_from_to(ip, ip_to, e.cidr + 1); 237 238 } 238 - ipn = ip; 239 - do { 240 - ipn = ip_set_range_to_cidr(ipn, ip_to, &cidr); 241 - n++; 242 - } while (ipn++ < ip_to); 243 - 244 - if (n*(port_to - port + 1) > IPSET_MAX_RANGE) 245 - return -ERANGE; 246 239 247 240 if (retried) { 248 241 ip = ntohl(h->next.ip); ··· 246 255 e.ip = htonl(ip); 247 256 ip = ip_set_range_to_cidr(ip, ip_to, &cidr); 248 257 e.cidr = cidr - 1; 249 - for (; p <= port_to; p++) { 258 + for (; p <= port_to; p++, i++) { 250 259 e.port = htons(p); 260 + if (i > IPSET_MAX_RANGE) { 261 + hash_netport4_data_next(&h->next, &e); 262 + return -ERANGE; 263 + } 251 264 ret = adtfn(set, &e, &ext, &ext, flags); 252 265 if (ret && !ip_set_eexist(ret, flags)) 253 266 return ret;
+21 -19
net/netfilter/ipset/ip_set_hash_netportnet.c
··· 173 173 return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags); 174 174 } 175 175 176 + static u32 177 + hash_netportnet4_range_to_cidr(u32 from, u32 to, u8 *cidr) 178 + { 179 + if (from == 0 && to == UINT_MAX) { 180 + *cidr = 0; 181 + return to; 182 + } 183 + return ip_set_range_to_cidr(from, to, cidr); 184 + } 185 + 176 186 static int 177 187 hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[], 178 188 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 179 189 { 180 - const struct hash_netportnet4 *h = set->data; 190 + struct hash_netportnet4 *h = set->data; 181 191 ipset_adtfn adtfn = set->variant->adt[adt]; 182 192 struct hash_netportnet4_elem e = { }; 183 193 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 184 194 u32 ip = 0, ip_to = 0, p = 0, port, port_to; 185 - u32 ip2_from = 0, ip2_to = 0, ip2, ipn; 186 - u64 n = 0, m = 0; 195 + u32 ip2_from = 0, ip2_to = 0, ip2, i = 0; 187 196 bool with_ports = false; 188 197 int ret; 189 198 ··· 294 285 } else { 295 286 ip_set_mask_from_to(ip2_from, ip2_to, e.cidr[1]); 296 287 } 297 - ipn = ip; 298 - do { 299 - ipn = ip_set_range_to_cidr(ipn, ip_to, &e.cidr[0]); 300 - n++; 301 - } while (ipn++ < ip_to); 302 - ipn = ip2_from; 303 - do { 304 - ipn = ip_set_range_to_cidr(ipn, ip2_to, &e.cidr[1]); 305 - m++; 306 - } while (ipn++ < ip2_to); 307 - 308 - if (n*m*(port_to - port + 1) > IPSET_MAX_RANGE) 309 - return -ERANGE; 310 288 311 289 if (retried) { 312 290 ip = ntohl(h->next.ip[0]); ··· 306 310 307 311 do { 308 312 e.ip[0] = htonl(ip); 309 - ip = ip_set_range_to_cidr(ip, ip_to, &e.cidr[0]); 313 + ip = hash_netportnet4_range_to_cidr(ip, ip_to, &e.cidr[0]); 310 314 for (; p <= port_to; p++) { 311 315 e.port = htons(p); 312 316 do { 317 + i++; 313 318 e.ip[1] = htonl(ip2); 314 - ip2 = ip_set_range_to_cidr(ip2, ip2_to, 315 - &e.cidr[1]); 319 + if (i > IPSET_MAX_RANGE) { 320 + hash_netportnet4_data_next(&h->next, 321 + &e); 322 + return -ERANGE; 323 + } 324 + ip2 = hash_netportnet4_range_to_cidr(ip2, 325 + ip2_to, &e.cidr[1]); 316 326 ret = adtfn(set, &e, &ext, &ext, flags); 317 327 if (ret && !ip_set_eexist(ret, flags)) 318 328 return ret;
+5 -2
net/netfilter/nf_conntrack_proto.c
··· 141 141 struct nf_conn *ct; 142 142 bool seqadj_needed; 143 143 __be16 frag_off; 144 + int start; 144 145 u8 pnum; 145 146 146 147 ct = nf_ct_get(skb, &ctinfo); ··· 164 163 break; 165 164 case NFPROTO_IPV6: 166 165 pnum = ipv6_hdr(skb)->nexthdr; 167 - protoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &pnum, &frag_off); 168 - if (protoff < 0 || (frag_off & htons(~0x7)) != 0) 166 + start = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &pnum, &frag_off); 167 + if (start < 0 || (frag_off & htons(~0x7)) != 0) 169 168 return nf_conntrack_confirm(skb); 169 + 170 + protoff = start; 170 171 break; 171 172 default: 172 173 return nf_conntrack_confirm(skb);
+175 -86
net/netfilter/nf_tables_api.c
··· 465 465 return 0; 466 466 } 467 467 468 - static int nft_trans_set_add(const struct nft_ctx *ctx, int msg_type, 469 - struct nft_set *set) 468 + static int __nft_trans_set_add(const struct nft_ctx *ctx, int msg_type, 469 + struct nft_set *set, 470 + const struct nft_set_desc *desc) 470 471 { 471 472 struct nft_trans *trans; 472 473 ··· 475 474 if (trans == NULL) 476 475 return -ENOMEM; 477 476 478 - if (msg_type == NFT_MSG_NEWSET && ctx->nla[NFTA_SET_ID] != NULL) { 477 + if (msg_type == NFT_MSG_NEWSET && ctx->nla[NFTA_SET_ID] && !desc) { 479 478 nft_trans_set_id(trans) = 480 479 ntohl(nla_get_be32(ctx->nla[NFTA_SET_ID])); 481 480 nft_activate_next(ctx->net, set); 482 481 } 483 482 nft_trans_set(trans) = set; 483 + if (desc) { 484 + nft_trans_set_update(trans) = true; 485 + nft_trans_set_gc_int(trans) = desc->gc_int; 486 + nft_trans_set_timeout(trans) = desc->timeout; 487 + } 484 488 nft_trans_commit_list_add_tail(ctx->net, trans); 485 489 486 490 return 0; 491 + } 492 + 493 + static int nft_trans_set_add(const struct nft_ctx *ctx, int msg_type, 494 + struct nft_set *set) 495 + { 496 + return __nft_trans_set_add(ctx, msg_type, set, NULL); 487 497 } 488 498 489 499 static int nft_delset(const struct nft_ctx *ctx, struct nft_set *set) ··· 3792 3780 static const struct nft_set_ops * 3793 3781 nft_select_set_ops(const struct nft_ctx *ctx, 3794 3782 const struct nlattr * const nla[], 3795 - const struct nft_set_desc *desc, 3796 - enum nft_set_policies policy) 3783 + const struct nft_set_desc *desc) 3797 3784 { 3798 3785 struct nftables_pernet *nft_net = nft_pernet(ctx->net); 3799 3786 const struct nft_set_ops *ops, *bops; ··· 3821 3810 if (!ops->estimate(desc, flags, &est)) 3822 3811 continue; 3823 3812 3824 - switch (policy) { 3813 + switch (desc->policy) { 3825 3814 case NFT_SET_POL_PERFORMANCE: 3826 3815 if (est.lookup < best.lookup) 3827 3816 break; ··· 4056 4045 static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx, 4057 4046 const struct nft_set *set, u16 event, u16 flags) 4058 4047 { 4059 - struct nlmsghdr *nlh; 4048 + u64 timeout = READ_ONCE(set->timeout); 4049 + u32 gc_int = READ_ONCE(set->gc_int); 4060 4050 u32 portid = ctx->portid; 4051 + struct nlmsghdr *nlh; 4061 4052 struct nlattr *nest; 4062 4053 u32 seq = ctx->seq; 4063 4054 int i; ··· 4095 4082 nla_put_be32(skb, NFTA_SET_OBJ_TYPE, htonl(set->objtype))) 4096 4083 goto nla_put_failure; 4097 4084 4098 - if (set->timeout && 4085 + if (timeout && 4099 4086 nla_put_be64(skb, NFTA_SET_TIMEOUT, 4100 - nf_jiffies64_to_msecs(set->timeout), 4087 + nf_jiffies64_to_msecs(timeout), 4101 4088 NFTA_SET_PAD)) 4102 4089 goto nla_put_failure; 4103 - if (set->gc_int && 4104 - nla_put_be32(skb, NFTA_SET_GC_INTERVAL, htonl(set->gc_int))) 4090 + if (gc_int && 4091 + nla_put_be32(skb, NFTA_SET_GC_INTERVAL, htonl(gc_int))) 4105 4092 goto nla_put_failure; 4106 4093 4107 4094 if (set->policy != NFT_SET_POL_PERFORMANCE) { ··· 4402 4389 return err; 4403 4390 } 4404 4391 4392 + static int nft_set_expr_alloc(struct nft_ctx *ctx, struct nft_set *set, 4393 + const struct nlattr * const *nla, 4394 + struct nft_expr **exprs, int *num_exprs, 4395 + u32 flags) 4396 + { 4397 + struct nft_expr *expr; 4398 + int err, i; 4399 + 4400 + if (nla[NFTA_SET_EXPR]) { 4401 + expr = nft_set_elem_expr_alloc(ctx, set, nla[NFTA_SET_EXPR]); 4402 + if (IS_ERR(expr)) { 4403 + err = PTR_ERR(expr); 4404 + goto err_set_expr_alloc; 4405 + } 4406 + exprs[0] = expr; 4407 + (*num_exprs)++; 4408 + } else if (nla[NFTA_SET_EXPRESSIONS]) { 4409 + struct nlattr *tmp; 4410 + int left; 4411 + 4412 + if (!(flags & NFT_SET_EXPR)) { 4413 + err = -EINVAL; 4414 + goto err_set_expr_alloc; 4415 + } 4416 + i = 0; 4417 + nla_for_each_nested(tmp, nla[NFTA_SET_EXPRESSIONS], left) { 4418 + if (i == NFT_SET_EXPR_MAX) { 4419 + err = -E2BIG; 4420 + goto err_set_expr_alloc; 4421 + } 4422 + if (nla_type(tmp) != NFTA_LIST_ELEM) { 4423 + err = -EINVAL; 4424 + goto err_set_expr_alloc; 4425 + } 4426 + expr = nft_set_elem_expr_alloc(ctx, set, tmp); 4427 + if (IS_ERR(expr)) { 4428 + err = PTR_ERR(expr); 4429 + goto err_set_expr_alloc; 4430 + } 4431 + exprs[i++] = expr; 4432 + (*num_exprs)++; 4433 + } 4434 + } 4435 + 4436 + return 0; 4437 + 4438 + err_set_expr_alloc: 4439 + for (i = 0; i < *num_exprs; i++) 4440 + nft_expr_destroy(ctx, exprs[i]); 4441 + 4442 + return err; 4443 + } 4444 + 4445 + static bool nft_set_is_same(const struct nft_set *set, 4446 + const struct nft_set_desc *desc, 4447 + struct nft_expr *exprs[], u32 num_exprs, u32 flags) 4448 + { 4449 + int i; 4450 + 4451 + if (set->ktype != desc->ktype || 4452 + set->dtype != desc->dtype || 4453 + set->flags != flags || 4454 + set->klen != desc->klen || 4455 + set->dlen != desc->dlen || 4456 + set->field_count != desc->field_count || 4457 + set->num_exprs != num_exprs) 4458 + return false; 4459 + 4460 + for (i = 0; i < desc->field_count; i++) { 4461 + if (set->field_len[i] != desc->field_len[i]) 4462 + return false; 4463 + } 4464 + 4465 + for (i = 0; i < num_exprs; i++) { 4466 + if (set->exprs[i]->ops != exprs[i]->ops) 4467 + return false; 4468 + } 4469 + 4470 + return true; 4471 + } 4472 + 4405 4473 static int nf_tables_newset(struct sk_buff *skb, const struct nfnl_info *info, 4406 4474 const struct nlattr * const nla[]) 4407 4475 { 4408 - u32 ktype, dtype, flags, policy, gc_int, objtype; 4409 4476 struct netlink_ext_ack *extack = info->extack; 4410 4477 u8 genmask = nft_genmask_next(info->net); 4411 4478 u8 family = info->nfmsg->nfgen_family; 4412 4479 const struct nft_set_ops *ops; 4413 - struct nft_expr *expr = NULL; 4414 4480 struct net *net = info->net; 4415 4481 struct nft_set_desc desc; 4416 4482 struct nft_table *table; ··· 4497 4405 struct nft_set *set; 4498 4406 struct nft_ctx ctx; 4499 4407 size_t alloc_size; 4500 - u64 timeout; 4408 + int num_exprs = 0; 4501 4409 char *name; 4502 4410 int err, i; 4503 4411 u16 udlen; 4412 + u32 flags; 4504 4413 u64 size; 4505 4414 4506 4415 if (nla[NFTA_SET_TABLE] == NULL || ··· 4512 4419 4513 4420 memset(&desc, 0, sizeof(desc)); 4514 4421 4515 - ktype = NFT_DATA_VALUE; 4422 + desc.ktype = NFT_DATA_VALUE; 4516 4423 if (nla[NFTA_SET_KEY_TYPE] != NULL) { 4517 - ktype = ntohl(nla_get_be32(nla[NFTA_SET_KEY_TYPE])); 4518 - if ((ktype & NFT_DATA_RESERVED_MASK) == NFT_DATA_RESERVED_MASK) 4424 + desc.ktype = ntohl(nla_get_be32(nla[NFTA_SET_KEY_TYPE])); 4425 + if ((desc.ktype & NFT_DATA_RESERVED_MASK) == NFT_DATA_RESERVED_MASK) 4519 4426 return -EINVAL; 4520 4427 } 4521 4428 ··· 4540 4447 return -EOPNOTSUPP; 4541 4448 } 4542 4449 4543 - dtype = 0; 4450 + desc.dtype = 0; 4544 4451 if (nla[NFTA_SET_DATA_TYPE] != NULL) { 4545 4452 if (!(flags & NFT_SET_MAP)) 4546 4453 return -EINVAL; 4547 4454 4548 - dtype = ntohl(nla_get_be32(nla[NFTA_SET_DATA_TYPE])); 4549 - if ((dtype & NFT_DATA_RESERVED_MASK) == NFT_DATA_RESERVED_MASK && 4550 - dtype != NFT_DATA_VERDICT) 4455 + desc.dtype = ntohl(nla_get_be32(nla[NFTA_SET_DATA_TYPE])); 4456 + if ((desc.dtype & NFT_DATA_RESERVED_MASK) == NFT_DATA_RESERVED_MASK && 4457 + desc.dtype != NFT_DATA_VERDICT) 4551 4458 return -EINVAL; 4552 4459 4553 - if (dtype != NFT_DATA_VERDICT) { 4460 + if (desc.dtype != NFT_DATA_VERDICT) { 4554 4461 if (nla[NFTA_SET_DATA_LEN] == NULL) 4555 4462 return -EINVAL; 4556 4463 desc.dlen = ntohl(nla_get_be32(nla[NFTA_SET_DATA_LEN])); ··· 4565 4472 if (!(flags & NFT_SET_OBJECT)) 4566 4473 return -EINVAL; 4567 4474 4568 - objtype = ntohl(nla_get_be32(nla[NFTA_SET_OBJ_TYPE])); 4569 - if (objtype == NFT_OBJECT_UNSPEC || 4570 - objtype > NFT_OBJECT_MAX) 4475 + desc.objtype = ntohl(nla_get_be32(nla[NFTA_SET_OBJ_TYPE])); 4476 + if (desc.objtype == NFT_OBJECT_UNSPEC || 4477 + desc.objtype > NFT_OBJECT_MAX) 4571 4478 return -EOPNOTSUPP; 4572 4479 } else if (flags & NFT_SET_OBJECT) 4573 4480 return -EINVAL; 4574 4481 else 4575 - objtype = NFT_OBJECT_UNSPEC; 4482 + desc.objtype = NFT_OBJECT_UNSPEC; 4576 4483 4577 - timeout = 0; 4484 + desc.timeout = 0; 4578 4485 if (nla[NFTA_SET_TIMEOUT] != NULL) { 4579 4486 if (!(flags & NFT_SET_TIMEOUT)) 4580 4487 return -EINVAL; 4581 4488 4582 - err = nf_msecs_to_jiffies64(nla[NFTA_SET_TIMEOUT], &timeout); 4489 + err = nf_msecs_to_jiffies64(nla[NFTA_SET_TIMEOUT], &desc.timeout); 4583 4490 if (err) 4584 4491 return err; 4585 4492 } 4586 - gc_int = 0; 4493 + desc.gc_int = 0; 4587 4494 if (nla[NFTA_SET_GC_INTERVAL] != NULL) { 4588 4495 if (!(flags & NFT_SET_TIMEOUT)) 4589 4496 return -EINVAL; 4590 - gc_int = ntohl(nla_get_be32(nla[NFTA_SET_GC_INTERVAL])); 4497 + desc.gc_int = ntohl(nla_get_be32(nla[NFTA_SET_GC_INTERVAL])); 4591 4498 } 4592 4499 4593 - policy = NFT_SET_POL_PERFORMANCE; 4500 + desc.policy = NFT_SET_POL_PERFORMANCE; 4594 4501 if (nla[NFTA_SET_POLICY] != NULL) 4595 - policy = ntohl(nla_get_be32(nla[NFTA_SET_POLICY])); 4502 + desc.policy = ntohl(nla_get_be32(nla[NFTA_SET_POLICY])); 4596 4503 4597 4504 if (nla[NFTA_SET_DESC] != NULL) { 4598 4505 err = nf_tables_set_desc_parse(&desc, nla[NFTA_SET_DESC]); ··· 4624 4531 return PTR_ERR(set); 4625 4532 } 4626 4533 } else { 4534 + struct nft_expr *exprs[NFT_SET_EXPR_MAX] = {}; 4535 + 4627 4536 if (info->nlh->nlmsg_flags & NLM_F_EXCL) { 4628 4537 NL_SET_BAD_ATTR(extack, nla[NFTA_SET_NAME]); 4629 4538 return -EEXIST; ··· 4633 4538 if (info->nlh->nlmsg_flags & NLM_F_REPLACE) 4634 4539 return -EOPNOTSUPP; 4635 4540 4636 - return 0; 4541 + err = nft_set_expr_alloc(&ctx, set, nla, exprs, &num_exprs, flags); 4542 + if (err < 0) 4543 + return err; 4544 + 4545 + err = 0; 4546 + if (!nft_set_is_same(set, &desc, exprs, num_exprs, flags)) { 4547 + NL_SET_BAD_ATTR(extack, nla[NFTA_SET_NAME]); 4548 + err = -EEXIST; 4549 + } 4550 + 4551 + for (i = 0; i < num_exprs; i++) 4552 + nft_expr_destroy(&ctx, exprs[i]); 4553 + 4554 + if (err < 0) 4555 + return err; 4556 + 4557 + return __nft_trans_set_add(&ctx, NFT_MSG_NEWSET, set, &desc); 4637 4558 } 4638 4559 4639 4560 if (!(info->nlh->nlmsg_flags & NLM_F_CREATE)) 4640 4561 return -ENOENT; 4641 4562 4642 - ops = nft_select_set_ops(&ctx, nla, &desc, policy); 4563 + ops = nft_select_set_ops(&ctx, nla, &desc); 4643 4564 if (IS_ERR(ops)) 4644 4565 return PTR_ERR(ops); 4645 4566 ··· 4695 4584 set->table = table; 4696 4585 write_pnet(&set->net, net); 4697 4586 set->ops = ops; 4698 - set->ktype = ktype; 4587 + set->ktype = desc.ktype; 4699 4588 set->klen = desc.klen; 4700 - set->dtype = dtype; 4701 - set->objtype = objtype; 4589 + set->dtype = desc.dtype; 4590 + set->objtype = desc.objtype; 4702 4591 set->dlen = desc.dlen; 4703 4592 set->flags = flags; 4704 4593 set->size = desc.size; 4705 - set->policy = policy; 4594 + set->policy = desc.policy; 4706 4595 set->udlen = udlen; 4707 4596 set->udata = udata; 4708 - set->timeout = timeout; 4709 - set->gc_int = gc_int; 4597 + set->timeout = desc.timeout; 4598 + set->gc_int = desc.gc_int; 4710 4599 4711 4600 set->field_count = desc.field_count; 4712 4601 for (i = 0; i < desc.field_count; i++) ··· 4716 4605 if (err < 0) 4717 4606 goto err_set_init; 4718 4607 4719 - if (nla[NFTA_SET_EXPR]) { 4720 - expr = nft_set_elem_expr_alloc(&ctx, set, nla[NFTA_SET_EXPR]); 4721 - if (IS_ERR(expr)) { 4722 - err = PTR_ERR(expr); 4723 - goto err_set_expr_alloc; 4724 - } 4725 - set->exprs[0] = expr; 4726 - set->num_exprs++; 4727 - } else if (nla[NFTA_SET_EXPRESSIONS]) { 4728 - struct nft_expr *expr; 4729 - struct nlattr *tmp; 4730 - int left; 4608 + err = nft_set_expr_alloc(&ctx, set, nla, set->exprs, &num_exprs, flags); 4609 + if (err < 0) 4610 + goto err_set_destroy; 4731 4611 4732 - if (!(flags & NFT_SET_EXPR)) { 4733 - err = -EINVAL; 4734 - goto err_set_expr_alloc; 4735 - } 4736 - i = 0; 4737 - nla_for_each_nested(tmp, nla[NFTA_SET_EXPRESSIONS], left) { 4738 - if (i == NFT_SET_EXPR_MAX) { 4739 - err = -E2BIG; 4740 - goto err_set_expr_alloc; 4741 - } 4742 - if (nla_type(tmp) != NFTA_LIST_ELEM) { 4743 - err = -EINVAL; 4744 - goto err_set_expr_alloc; 4745 - } 4746 - expr = nft_set_elem_expr_alloc(&ctx, set, tmp); 4747 - if (IS_ERR(expr)) { 4748 - err = PTR_ERR(expr); 4749 - goto err_set_expr_alloc; 4750 - } 4751 - set->exprs[i++] = expr; 4752 - set->num_exprs++; 4753 - } 4754 - } 4755 - 4612 + set->num_exprs = num_exprs; 4756 4613 set->handle = nf_tables_alloc_handle(table); 4757 4614 4758 4615 err = nft_trans_set_add(&ctx, NFT_MSG_NEWSET, set); ··· 4734 4655 err_set_expr_alloc: 4735 4656 for (i = 0; i < set->num_exprs; i++) 4736 4657 nft_expr_destroy(&ctx, set->exprs[i]); 4737 - 4658 + err_set_destroy: 4738 4659 ops->destroy(set); 4739 4660 err_set_init: 4740 4661 kfree(set->name); ··· 6087 6008 return err; 6088 6009 } else if (set->flags & NFT_SET_TIMEOUT && 6089 6010 !(flags & NFT_SET_ELEM_INTERVAL_END)) { 6090 - timeout = set->timeout; 6011 + timeout = READ_ONCE(set->timeout); 6091 6012 } 6092 6013 6093 6014 expiration = 0; ··· 6188 6109 if (err < 0) 6189 6110 goto err_parse_key_end; 6190 6111 6191 - if (timeout != set->timeout) { 6112 + if (timeout != READ_ONCE(set->timeout)) { 6192 6113 err = nft_set_ext_add(&tmpl, NFT_SET_EXT_TIMEOUT); 6193 6114 if (err < 0) 6194 6115 goto err_parse_key_end; ··· 9110 9031 nft_flow_rule_destroy(nft_trans_flow_rule(trans)); 9111 9032 break; 9112 9033 case NFT_MSG_NEWSET: 9113 - nft_clear(net, nft_trans_set(trans)); 9114 - /* This avoids hitting -EBUSY when deleting the table 9115 - * from the transaction. 9116 - */ 9117 - if (nft_set_is_anonymous(nft_trans_set(trans)) && 9118 - !list_empty(&nft_trans_set(trans)->bindings)) 9119 - trans->ctx.table->use--; 9034 + if (nft_trans_set_update(trans)) { 9035 + struct nft_set *set = nft_trans_set(trans); 9120 9036 9037 + WRITE_ONCE(set->timeout, nft_trans_set_timeout(trans)); 9038 + WRITE_ONCE(set->gc_int, nft_trans_set_gc_int(trans)); 9039 + } else { 9040 + nft_clear(net, nft_trans_set(trans)); 9041 + /* This avoids hitting -EBUSY when deleting the table 9042 + * from the transaction. 9043 + */ 9044 + if (nft_set_is_anonymous(nft_trans_set(trans)) && 9045 + !list_empty(&nft_trans_set(trans)->bindings)) 9046 + trans->ctx.table->use--; 9047 + } 9121 9048 nf_tables_set_notify(&trans->ctx, nft_trans_set(trans), 9122 9049 NFT_MSG_NEWSET, GFP_KERNEL); 9123 9050 nft_trans_destroy(trans); ··· 9345 9260 nft_trans_destroy(trans); 9346 9261 break; 9347 9262 case NFT_MSG_NEWSET: 9263 + if (nft_trans_set_update(trans)) { 9264 + nft_trans_destroy(trans); 9265 + break; 9266 + } 9348 9267 trans->ctx.table->use--; 9349 9268 if (nft_trans_set_bound(trans)) { 9350 9269 nft_trans_destroy(trans);
+38 -14
net/nfc/netlink.c
··· 1497 1497 u32 dev_idx, se_idx; 1498 1498 u8 *apdu; 1499 1499 size_t apdu_len; 1500 + int rc; 1500 1501 1501 1502 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || 1502 1503 !info->attrs[NFC_ATTR_SE_INDEX] || ··· 1511 1510 if (!dev) 1512 1511 return -ENODEV; 1513 1512 1514 - if (!dev->ops || !dev->ops->se_io) 1515 - return -ENOTSUPP; 1513 + if (!dev->ops || !dev->ops->se_io) { 1514 + rc = -EOPNOTSUPP; 1515 + goto put_dev; 1516 + } 1516 1517 1517 1518 apdu_len = nla_len(info->attrs[NFC_ATTR_SE_APDU]); 1518 - if (apdu_len == 0) 1519 - return -EINVAL; 1519 + if (apdu_len == 0) { 1520 + rc = -EINVAL; 1521 + goto put_dev; 1522 + } 1520 1523 1521 1524 apdu = nla_data(info->attrs[NFC_ATTR_SE_APDU]); 1522 - if (!apdu) 1523 - return -EINVAL; 1525 + if (!apdu) { 1526 + rc = -EINVAL; 1527 + goto put_dev; 1528 + } 1524 1529 1525 1530 ctx = kzalloc(sizeof(struct se_io_ctx), GFP_KERNEL); 1526 - if (!ctx) 1527 - return -ENOMEM; 1531 + if (!ctx) { 1532 + rc = -ENOMEM; 1533 + goto put_dev; 1534 + } 1528 1535 1529 1536 ctx->dev_idx = dev_idx; 1530 1537 ctx->se_idx = se_idx; 1531 1538 1532 - return nfc_se_io(dev, se_idx, apdu, apdu_len, se_io_cb, ctx); 1539 + rc = nfc_se_io(dev, se_idx, apdu, apdu_len, se_io_cb, ctx); 1540 + 1541 + put_dev: 1542 + nfc_put_device(dev); 1543 + return rc; 1533 1544 } 1534 1545 1535 1546 static int nfc_genl_vendor_cmd(struct sk_buff *skb, ··· 1564 1551 subcmd = nla_get_u32(info->attrs[NFC_ATTR_VENDOR_SUBCMD]); 1565 1552 1566 1553 dev = nfc_get_device(dev_idx); 1567 - if (!dev || !dev->vendor_cmds || !dev->n_vendor_cmds) 1554 + if (!dev) 1568 1555 return -ENODEV; 1556 + 1557 + if (!dev->vendor_cmds || !dev->n_vendor_cmds) { 1558 + err = -ENODEV; 1559 + goto put_dev; 1560 + } 1569 1561 1570 1562 if (info->attrs[NFC_ATTR_VENDOR_DATA]) { 1571 1563 data = nla_data(info->attrs[NFC_ATTR_VENDOR_DATA]); 1572 1564 data_len = nla_len(info->attrs[NFC_ATTR_VENDOR_DATA]); 1573 - if (data_len == 0) 1574 - return -EINVAL; 1565 + if (data_len == 0) { 1566 + err = -EINVAL; 1567 + goto put_dev; 1568 + } 1575 1569 } else { 1576 1570 data = NULL; 1577 1571 data_len = 0; ··· 1593 1573 dev->cur_cmd_info = info; 1594 1574 err = cmd->doit(dev, data, data_len); 1595 1575 dev->cur_cmd_info = NULL; 1596 - return err; 1576 + goto put_dev; 1597 1577 } 1598 1578 1599 - return -EOPNOTSUPP; 1579 + err = -EOPNOTSUPP; 1580 + 1581 + put_dev: 1582 + nfc_put_device(dev); 1583 + return err; 1600 1584 } 1601 1585 1602 1586 /* message building helper */
+6 -2
net/openvswitch/datapath.c
··· 1861 1861 vport->upcall_stats = netdev_alloc_pcpu_stats(struct vport_upcall_stats_percpu); 1862 1862 if (!vport->upcall_stats) { 1863 1863 err = -ENOMEM; 1864 - goto err_destroy_portids; 1864 + goto err_destroy_vport; 1865 1865 } 1866 1866 1867 1867 err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid, ··· 1876 1876 ovs_notify(&dp_datapath_genl_family, reply, info); 1877 1877 return 0; 1878 1878 1879 + err_destroy_vport: 1880 + ovs_dp_detach_port(vport); 1879 1881 err_destroy_portids: 1880 1882 kfree(rcu_dereference_raw(dp->upcall_portids)); 1881 1883 err_unlock_and_destroy_meters: ··· 2325 2323 vport->upcall_stats = netdev_alloc_pcpu_stats(struct vport_upcall_stats_percpu); 2326 2324 if (!vport->upcall_stats) { 2327 2325 err = -ENOMEM; 2328 - goto exit_unlock_free; 2326 + goto exit_unlock_free_vport; 2329 2327 } 2330 2328 2331 2329 err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info), ··· 2345 2343 ovs_notify(&dp_vport_genl_family, reply, info); 2346 2344 return 0; 2347 2345 2346 + exit_unlock_free_vport: 2347 + ovs_dp_detach_port(vport); 2348 2348 exit_unlock_free: 2349 2349 ovs_unlock(); 2350 2350 kfree_skb(reply);
+8 -6
net/rxrpc/recvmsg.c
··· 388 388 struct rxrpc_call *call; 389 389 struct rxrpc_sock *rx = rxrpc_sk(sock->sk); 390 390 struct list_head *l; 391 + unsigned int call_debug_id = 0; 391 392 size_t copied = 0; 392 393 long timeo; 393 394 int ret; 394 395 395 396 DEFINE_WAIT(wait); 396 397 397 - trace_rxrpc_recvmsg(NULL, rxrpc_recvmsg_enter, 0); 398 + trace_rxrpc_recvmsg(0, rxrpc_recvmsg_enter, 0); 398 399 399 400 if (flags & (MSG_OOB | MSG_TRUNC)) 400 401 return -EOPNOTSUPP; ··· 432 431 if (list_empty(&rx->recvmsg_q)) { 433 432 if (signal_pending(current)) 434 433 goto wait_interrupted; 435 - trace_rxrpc_recvmsg(NULL, rxrpc_recvmsg_wait, 0); 434 + trace_rxrpc_recvmsg(0, rxrpc_recvmsg_wait, 0); 436 435 timeo = schedule_timeout(timeo); 437 436 } 438 437 finish_wait(sk_sleep(&rx->sk), &wait); ··· 451 450 rxrpc_get_call(call, rxrpc_call_get_recvmsg); 452 451 write_unlock(&rx->recvmsg_lock); 453 452 454 - trace_rxrpc_recvmsg(call, rxrpc_recvmsg_dequeue, 0); 453 + call_debug_id = call->debug_id; 454 + trace_rxrpc_recvmsg(call_debug_id, rxrpc_recvmsg_dequeue, 0); 455 455 456 456 /* We're going to drop the socket lock, so we need to lock the call 457 457 * against interference by sendmsg. ··· 533 531 error_unlock_call: 534 532 mutex_unlock(&call->user_mutex); 535 533 rxrpc_put_call(call, rxrpc_call_put_recvmsg); 536 - trace_rxrpc_recvmsg(call, rxrpc_recvmsg_return, ret); 534 + trace_rxrpc_recvmsg(call_debug_id, rxrpc_recvmsg_return, ret); 537 535 return ret; 538 536 539 537 error_requeue_call: ··· 541 539 write_lock(&rx->recvmsg_lock); 542 540 list_add(&call->recvmsg_link, &rx->recvmsg_q); 543 541 write_unlock(&rx->recvmsg_lock); 544 - trace_rxrpc_recvmsg(call, rxrpc_recvmsg_requeue, 0); 542 + trace_rxrpc_recvmsg(call_debug_id, rxrpc_recvmsg_requeue, 0); 545 543 } else { 546 544 rxrpc_put_call(call, rxrpc_call_put_recvmsg); 547 545 } 548 546 error_no_call: 549 547 release_sock(&rx->sk); 550 548 error_trace: 551 - trace_rxrpc_recvmsg(call, rxrpc_recvmsg_return, ret); 549 + trace_rxrpc_recvmsg(call_debug_id, rxrpc_recvmsg_return, ret); 552 550 return ret; 553 551 554 552 wait_interrupted:
+2 -10
net/sched/cls_tcindex.c
··· 333 333 struct tcindex_filter_result *r, struct nlattr **tb, 334 334 struct nlattr *est, u32 flags, struct netlink_ext_ack *extack) 335 335 { 336 - struct tcindex_filter_result new_filter_result, *old_r = r; 336 + struct tcindex_filter_result new_filter_result; 337 337 struct tcindex_data *cp = NULL, *oldp; 338 338 struct tcindex_filter *f = NULL; /* make gcc behave */ 339 339 struct tcf_result cr = {}; ··· 402 402 err = tcindex_filter_result_init(&new_filter_result, cp, net); 403 403 if (err < 0) 404 404 goto errout_alloc; 405 - if (old_r) 405 + if (r) 406 406 cr = r->res; 407 407 408 408 err = -EBUSY; ··· 477 477 if (tb[TCA_TCINDEX_CLASSID]) { 478 478 cr.classid = nla_get_u32(tb[TCA_TCINDEX_CLASSID]); 479 479 tcf_bind_filter(tp, &cr, base); 480 - } 481 - 482 - if (old_r && old_r != r) { 483 - err = tcindex_filter_result_init(old_r, cp, net); 484 - if (err < 0) { 485 - kfree(f); 486 - goto errout_alloc; 487 - } 488 480 } 489 481 490 482 oldp = p;
+4 -1
net/sched/sch_atm.c
··· 393 393 result = tcf_classify(skb, NULL, fl, &res, true); 394 394 if (result < 0) 395 395 continue; 396 + if (result == TC_ACT_SHOT) 397 + goto done; 398 + 396 399 flow = (struct atm_flow_data *)res.class; 397 400 if (!flow) 398 401 flow = lookup_flow(sch, res.classid); 399 - goto done; 402 + goto drop; 400 403 } 401 404 } 402 405 flow = NULL;
+2 -2
net/sched/sch_cbq.c
··· 230 230 result = tcf_classify(skb, NULL, fl, &res, true); 231 231 if (!fl || result < 0) 232 232 goto fallback; 233 + if (result == TC_ACT_SHOT) 234 + return NULL; 233 235 234 236 cl = (void *)res.class; 235 237 if (!cl) { ··· 252 250 case TC_ACT_TRAP: 253 251 *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; 254 252 fallthrough; 255 - case TC_ACT_SHOT: 256 - return NULL; 257 253 case TC_ACT_RECLASSIFY: 258 254 return cbq_reclassify(skb, cl); 259 255 }
+6 -2
net/sched/sch_htb.c
··· 199 199 { 200 200 return (unsigned long)htb_find(handle, sch); 201 201 } 202 + 203 + #define HTB_DIRECT ((struct htb_class *)-1L) 204 + 202 205 /** 203 206 * htb_classify - classify a packet into class 207 + * @skb: the socket buffer 208 + * @sch: the active queue discipline 209 + * @qerr: pointer for returned status code 204 210 * 205 211 * It returns NULL if the packet should be dropped or -1 if the packet 206 212 * should be passed directly thru. In all other cases leaf class is returned. ··· 217 211 * have no valid leaf we try to use MAJOR:default leaf. It still unsuccessful 218 212 * then finish and return direct queue. 219 213 */ 220 - #define HTB_DIRECT ((struct htb_class *)-1L) 221 - 222 214 static struct htb_class *htb_classify(struct sk_buff *skb, struct Qdisc *sch, 223 215 int *qerr) 224 216 {
+17 -2
net/sunrpc/auth_gss/auth_gss.c
··· 302 302 list_for_each_entry(pos, &pipe->in_downcall, list) { 303 303 if (!uid_eq(pos->uid, uid)) 304 304 continue; 305 - if (auth && pos->auth->service != auth->service) 305 + if (pos->auth->service != auth->service) 306 306 continue; 307 307 refcount_inc(&pos->count); 308 308 return pos; ··· 686 686 return err; 687 687 } 688 688 689 + static struct gss_upcall_msg * 690 + gss_find_downcall(struct rpc_pipe *pipe, kuid_t uid) 691 + { 692 + struct gss_upcall_msg *pos; 693 + list_for_each_entry(pos, &pipe->in_downcall, list) { 694 + if (!uid_eq(pos->uid, uid)) 695 + continue; 696 + if (!rpc_msg_is_inflight(&pos->msg)) 697 + continue; 698 + refcount_inc(&pos->count); 699 + return pos; 700 + } 701 + return NULL; 702 + } 703 + 689 704 #define MSG_BUF_MAXSIZE 1024 690 705 691 706 static ssize_t ··· 747 732 err = -ENOENT; 748 733 /* Find a matching upcall */ 749 734 spin_lock(&pipe->lock); 750 - gss_msg = __gss_find_upcall(pipe, uid, NULL); 735 + gss_msg = gss_find_downcall(pipe, uid); 751 736 if (gss_msg == NULL) { 752 737 spin_unlock(&pipe->lock); 753 738 goto err_put_ctx;
+9 -8
scripts/Makefile.modpost
··· 44 44 $(if $(CONFIG_MODVERSIONS),-m) \ 45 45 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ 46 46 $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ 47 + $(if $(KBUILD_MODPOST_WARN),-w) \ 47 48 $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \ 48 49 $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \ 49 50 -o $@ ··· 54 53 # 'make -i -k' ignores compile errors, and builds as many modules as possible. 55 54 ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),) 56 55 modpost-args += -n 56 + endif 57 + 58 + # Read out modules.order to pass in modpost. 59 + # Otherwise, allmodconfig would fail with "Argument list too long". 60 + ifdef KBUILD_MODULES 61 + modpost-args += -T $(MODORDER) 62 + modpost-deps += $(MODORDER) 57 63 endif 58 64 59 65 ifeq ($(KBUILD_EXTMOD),) ··· 121 113 122 114 endif # ($(KBUILD_EXTMOD),) 123 115 124 - ifneq ($(KBUILD_MODPOST_WARN)$(missing-input),) 116 + ifneq ($(missing-input),) 125 117 modpost-args += -w 126 118 endif 127 119 128 - ifdef KBUILD_MODULES 129 - modpost-args += -T $(MODORDER) 130 - modpost-deps += $(MODORDER) 131 - endif 132 - 133 - # Read out modules.order to pass in modpost. 134 - # Otherwise, allmodconfig would fail with "Argument list too long". 135 120 quiet_cmd_modpost = MODPOST $@ 136 121 cmd_modpost = \ 137 122 $(if $(missing-input), \
+1
scripts/Makefile.package
··· 158 158 PHONY += help 159 159 help: 160 160 @echo ' rpm-pkg - Build both source and binary RPM kernel packages' 161 + @echo ' srcrpm-pkg - Build only the source kernel RPM package' 161 162 @echo ' binrpm-pkg - Build only the binary kernel RPM package' 162 163 @echo ' deb-pkg - Build both source and binary deb kernel packages' 163 164 @echo ' bindeb-pkg - Build only the binary kernel deb package'
-1
scripts/basic/fixdep.c
··· 94 94 #include <unistd.h> 95 95 #include <fcntl.h> 96 96 #include <string.h> 97 - #include <stdarg.h> 98 97 #include <stdlib.h> 99 98 #include <stdio.h> 100 99 #include <ctype.h>
+6
scripts/kconfig/mconf.c
··· 161 161 "(especially with a larger number of unrolled categories) than the\n" 162 162 "default mode.\n" 163 163 "\n" 164 + 165 + "Search\n" 166 + "-------\n" 167 + "Pressing the forward-slash (/) anywhere brings up a search dialog box.\n" 168 + "\n" 169 + 164 170 "Different color themes available\n" 165 171 "--------------------------------\n" 166 172 "It is possible to select different color themes using the variable\n"
+2 -1
scripts/package/mkspec
··· 51 51 URL: https://www.kernel.org 52 52 $S Source: kernel-$__KERNELRELEASE.tar.gz 53 53 Provides: $PROVIDES 54 - $S BuildRequires: bc binutils bison dwarves elfutils-libelf-devel flex 54 + $S BuildRequires: bc binutils bison dwarves 55 + $S BuildRequires: (elfutils-libelf-devel or libelf-devel) flex 55 56 $S BuildRequires: gcc make openssl openssl-devel perl python3 rsync 56 57 57 58 # $UTS_MACHINE as a fallback of _arch in case
+19 -8
sound/pci/hda/patch_hdmi.c
··· 167 167 struct hdmi_ops ops; 168 168 169 169 bool dyn_pin_out; 170 + bool static_pcm_mapping; 170 171 /* hdmi interrupt trigger control flag for Nvidia codec */ 171 172 bool hdmi_intr_trig_ctrl; 172 173 bool nv_dp_workaround; /* workaround DP audio infoframe for Nvidia */ ··· 1526 1525 */ 1527 1526 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); 1528 1527 1529 - if (eld->eld_valid) { 1530 - hdmi_attach_hda_pcm(spec, per_pin); 1531 - hdmi_pcm_setup_pin(spec, per_pin); 1532 - } else { 1533 - hdmi_pcm_reset_pin(spec, per_pin); 1534 - hdmi_detach_hda_pcm(spec, per_pin); 1528 + if (!spec->static_pcm_mapping) { 1529 + if (eld->eld_valid) { 1530 + hdmi_attach_hda_pcm(spec, per_pin); 1531 + hdmi_pcm_setup_pin(spec, per_pin); 1532 + } else { 1533 + hdmi_pcm_reset_pin(spec, per_pin); 1534 + hdmi_detach_hda_pcm(spec, per_pin); 1535 + } 1535 1536 } 1537 + 1536 1538 /* if pcm_idx == -1, it means this is in monitor connection event 1537 1539 * we can get the correct pcm_idx now. 1538 1540 */ ··· 2285 2281 struct hdmi_spec *spec = codec->spec; 2286 2282 int idx, pcm_num; 2287 2283 2288 - /* limit the PCM devices to the codec converters */ 2289 - pcm_num = spec->num_cvts; 2284 + /* limit the PCM devices to the codec converters or available PINs */ 2285 + pcm_num = min(spec->num_cvts, spec->num_pins); 2290 2286 codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num); 2291 2287 2292 2288 for (idx = 0; idx < pcm_num; idx++) { ··· 2382 2378 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { 2383 2379 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); 2384 2380 struct hdmi_eld *pin_eld = &per_pin->sink_eld; 2381 + 2382 + if (spec->static_pcm_mapping) { 2383 + hdmi_attach_hda_pcm(spec, per_pin); 2384 + hdmi_pcm_setup_pin(spec, per_pin); 2385 + } 2385 2386 2386 2387 pin_eld->eld_valid = false; 2387 2388 hdmi_present_sense(per_pin, 0); ··· 4427 4418 codec->patch_ops.init = atihdmi_init; 4428 4419 4429 4420 spec = codec->spec; 4421 + 4422 + spec->static_pcm_mapping = true; 4430 4423 4431 4424 spec->ops.pin_get_eld = atihdmi_pin_get_eld; 4432 4425 spec->ops.pin_setup_infoframe = atihdmi_pin_setup_infoframe;
+13
sound/pci/hda/patch_realtek.c
··· 7175 7175 ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK, 7176 7176 ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN, 7177 7177 ALC295_FIXUP_DELL_INSPIRON_TOP_SPEAKERS, 7178 + ALC236_FIXUP_DELL_DUAL_CODECS, 7178 7179 }; 7179 7180 7180 7181 /* A special fixup for Lenovo C940 and Yoga Duet 7; ··· 9131 9130 .chained = true, 9132 9131 .chain_id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, 9133 9132 }, 9133 + [ALC236_FIXUP_DELL_DUAL_CODECS] = { 9134 + .type = HDA_FIXUP_PINS, 9135 + .v.func = alc1220_fixup_gb_dual_codecs, 9136 + .chained = true, 9137 + .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 9138 + }, 9134 9139 }; 9135 9140 9136 9141 static const struct snd_pci_quirk alc269_fixup_tbl[] = { ··· 9239 9232 SND_PCI_QUIRK(0x1028, 0x0b1a, "Dell Precision 5570", ALC289_FIXUP_DUAL_SPK), 9240 9233 SND_PCI_QUIRK(0x1028, 0x0b37, "Dell Inspiron 16 Plus 7620 2-in-1", ALC295_FIXUP_DELL_INSPIRON_TOP_SPEAKERS), 9241 9234 SND_PCI_QUIRK(0x1028, 0x0b71, "Dell Inspiron 16 Plus 7620", ALC295_FIXUP_DELL_INSPIRON_TOP_SPEAKERS), 9235 + SND_PCI_QUIRK(0x1028, 0x0c19, "Dell Precision 3340", ALC236_FIXUP_DELL_DUAL_CODECS), 9236 + SND_PCI_QUIRK(0x1028, 0x0c1a, "Dell Precision 3340", ALC236_FIXUP_DELL_DUAL_CODECS), 9237 + SND_PCI_QUIRK(0x1028, 0x0c1b, "Dell Precision 3440", ALC236_FIXUP_DELL_DUAL_CODECS), 9238 + SND_PCI_QUIRK(0x1028, 0x0c1c, "Dell Precision 3540", ALC236_FIXUP_DELL_DUAL_CODECS), 9239 + SND_PCI_QUIRK(0x1028, 0x0c1d, "Dell Precision 3440", ALC236_FIXUP_DELL_DUAL_CODECS), 9240 + SND_PCI_QUIRK(0x1028, 0x0c1e, "Dell Precision 3540", ALC236_FIXUP_DELL_DUAL_CODECS), 9242 9241 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 9243 9242 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 9244 9243 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
+2 -1
sound/usb/line6/driver.c
··· 304 304 for (;;) { 305 305 done = 306 306 line6_midibuf_read(mb, line6->buffer_message, 307 - LINE6_MIDI_MESSAGE_MAXLEN); 307 + LINE6_MIDI_MESSAGE_MAXLEN, 308 + LINE6_MIDIBUF_READ_RX); 308 309 309 310 if (done <= 0) 310 311 break;
+4 -2
sound/usb/line6/midi.c
··· 44 44 int req, done; 45 45 46 46 for (;;) { 47 - req = min(line6_midibuf_bytes_free(mb), line6->max_packet_size); 47 + req = min3(line6_midibuf_bytes_free(mb), line6->max_packet_size, 48 + LINE6_FALLBACK_MAXPACKETSIZE); 48 49 done = snd_rawmidi_transmit_peek(substream, chunk, req); 49 50 50 51 if (done == 0) ··· 57 56 58 57 for (;;) { 59 58 done = line6_midibuf_read(mb, chunk, 60 - LINE6_FALLBACK_MAXPACKETSIZE); 59 + LINE6_FALLBACK_MAXPACKETSIZE, 60 + LINE6_MIDIBUF_READ_TX); 61 61 62 62 if (done == 0) 63 63 break;
+17 -8
sound/usb/line6/midibuf.c
··· 9 9 10 10 #include "midibuf.h" 11 11 12 + 12 13 static int midibuf_message_length(unsigned char code) 13 14 { 14 15 int message_length; ··· 21 20 22 21 message_length = length[(code >> 4) - 8]; 23 22 } else { 24 - /* 25 - Note that according to the MIDI specification 0xf2 is 26 - the "Song Position Pointer", but this is used by Line 6 27 - to send sysex messages to the host. 28 - */ 29 - static const int length[] = { -1, 2, -1, 2, -1, -1, 1, 1, 1, 1, 23 + static const int length[] = { -1, 2, 2, 2, -1, -1, 1, 1, 1, -1, 30 24 1, 1, 1, -1, 1, 1 31 25 }; 32 26 message_length = length[code & 0x0f]; ··· 121 125 } 122 126 123 127 int line6_midibuf_read(struct midi_buffer *this, unsigned char *data, 124 - int length) 128 + int length, int read_type) 125 129 { 126 130 int bytes_used; 127 131 int length1, length2; ··· 144 148 145 149 length1 = this->size - this->pos_read; 146 150 147 - /* check MIDI command length */ 148 151 command = this->buf[this->pos_read]; 152 + /* 153 + PODxt always has status byte lower nibble set to 0010, 154 + when it means to send 0000, so we correct if here so 155 + that control/program changes come on channel 1 and 156 + sysex message status byte is correct 157 + */ 158 + if (read_type == LINE6_MIDIBUF_READ_RX) { 159 + if (command == 0xb2 || command == 0xc2 || command == 0xf2) { 160 + unsigned char fixed = command & 0xf0; 161 + this->buf[this->pos_read] = fixed; 162 + command = fixed; 163 + } 164 + } 149 165 166 + /* check MIDI command length */ 150 167 if (command & 0x80) { 151 168 midi_length = midibuf_message_length(command); 152 169 this->command_prev = command;
+4 -1
sound/usb/line6/midibuf.h
··· 8 8 #ifndef MIDIBUF_H 9 9 #define MIDIBUF_H 10 10 11 + #define LINE6_MIDIBUF_READ_TX 0 12 + #define LINE6_MIDIBUF_READ_RX 1 13 + 11 14 struct midi_buffer { 12 15 unsigned char *buf; 13 16 int size; ··· 26 23 extern int line6_midibuf_ignore(struct midi_buffer *mb, int length); 27 24 extern int line6_midibuf_init(struct midi_buffer *mb, int size, int split); 28 25 extern int line6_midibuf_read(struct midi_buffer *mb, unsigned char *data, 29 - int length); 26 + int length, int read_type); 30 27 extern void line6_midibuf_reset(struct midi_buffer *mb); 31 28 extern int line6_midibuf_write(struct midi_buffer *mb, unsigned char *data, 32 29 int length);
+2 -1
sound/usb/line6/pod.c
··· 159 159 .bytes_per_channel = 3 /* SNDRV_PCM_FMTBIT_S24_3LE */ 160 160 }; 161 161 162 + 162 163 static const char pod_version_header[] = { 163 - 0xf2, 0x7e, 0x7f, 0x06, 0x02 164 + 0xf0, 0x7e, 0x7f, 0x06, 0x02 164 165 }; 165 166 166 167 static char *pod_alloc_sysex_buffer(struct usb_line6_pod *pod, int code,
+4
tools/bpf/bpftool/Makefile
··· 145 145 LLVM_CONFIG_LIB_COMPONENTS := mcdisassembler all-targets 146 146 CFLAGS += $(shell $(LLVM_CONFIG) --cflags --libs $(LLVM_CONFIG_LIB_COMPONENTS)) 147 147 LIBS += $(shell $(LLVM_CONFIG) --libs $(LLVM_CONFIG_LIB_COMPONENTS)) 148 + ifeq ($(shell $(LLVM_CONFIG) --shared-mode),static) 149 + LIBS += $(shell $(LLVM_CONFIG) --system-libs $(LLVM_CONFIG_LIB_COMPONENTS)) 150 + LIBS += -lstdc++ 151 + endif 148 152 LDFLAGS += $(shell $(LLVM_CONFIG) --ldflags) 149 153 else 150 154 # Fall back on libbfd
+1 -1
tools/perf/Documentation/Makefile
··· 267 267 $(ASCIIDOC) -b docbook -d manpage \ 268 268 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) \ 269 269 -aperf_date=$(shell git log -1 --pretty="format:%cd" \ 270 - --date=short $<) \ 270 + --date=short --no-show-signature $<) \ 271 271 -o $@+ $< && \ 272 272 mv $@+ $@ 273 273
+5 -5
tools/perf/Makefile.perf
··· 819 819 820 820 $(LIBAPI): FORCE | $(LIBAPI_OUTPUT) 821 821 $(Q)$(MAKE) -C $(LIBAPI_DIR) O=$(LIBAPI_OUTPUT) \ 822 - DESTDIR=$(LIBAPI_DESTDIR) prefix= \ 822 + DESTDIR=$(LIBAPI_DESTDIR) prefix= subdir= \ 823 823 $@ install_headers 824 824 825 825 $(LIBAPI)-clean: ··· 828 828 829 829 $(LIBBPF): FORCE | $(LIBBPF_OUTPUT) 830 830 $(Q)$(MAKE) -C $(LIBBPF_DIR) FEATURES_DUMP=$(FEATURE_DUMP_EXPORT) \ 831 - O= OUTPUT=$(LIBBPF_OUTPUT)/ DESTDIR=$(LIBBPF_DESTDIR) prefix= \ 831 + O= OUTPUT=$(LIBBPF_OUTPUT)/ DESTDIR=$(LIBBPF_DESTDIR) prefix= subdir= \ 832 832 $@ install_headers 833 833 834 834 $(LIBBPF)-clean: ··· 837 837 838 838 $(LIBPERF): FORCE | $(LIBPERF_OUTPUT) 839 839 $(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(LIBPERF_OUTPUT) \ 840 - DESTDIR=$(LIBPERF_DESTDIR) prefix= \ 840 + DESTDIR=$(LIBPERF_DESTDIR) prefix= subdir= \ 841 841 $@ install_headers 842 842 843 843 $(LIBPERF)-clean: ··· 846 846 847 847 $(LIBSUBCMD): FORCE | $(LIBSUBCMD_OUTPUT) 848 848 $(Q)$(MAKE) -C $(LIBSUBCMD_DIR) O=$(LIBSUBCMD_OUTPUT) \ 849 - DESTDIR=$(LIBSUBCMD_DESTDIR) prefix= \ 849 + DESTDIR=$(LIBSUBCMD_DESTDIR) prefix= subdir= \ 850 850 $@ install_headers 851 851 852 852 $(LIBSUBCMD)-clean: ··· 855 855 856 856 $(LIBSYMBOL): FORCE | $(LIBSYMBOL_OUTPUT) 857 857 $(Q)$(MAKE) -C $(LIBSYMBOL_DIR) O=$(LIBSYMBOL_OUTPUT) \ 858 - DESTDIR=$(LIBSYMBOL_DESTDIR) prefix= \ 858 + DESTDIR=$(LIBSYMBOL_DESTDIR) prefix= subdir= \ 859 859 $@ install_headers 860 860 861 861 $(LIBSYMBOL)-clean:
+1 -1
tools/perf/arch/riscv/util/unwind-libdw.c
··· 4 4 #include <elfutils/libdwfl.h> 5 5 #include "../../util/unwind-libdw.h" 6 6 #include "../../util/perf_regs.h" 7 - #include "../../util/event.h" 7 + #include "../../util/sample.h" 8 8 9 9 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) 10 10 {
+2
tools/perf/builtin-lock.c
··· 1670 1670 1671 1671 /* for lock function check */ 1672 1672 symbol_conf.sort_by_name = true; 1673 + symbol_conf.allow_aliases = true; 1673 1674 symbol__init(&session->header.env); 1674 1675 1675 1676 if (!data.is_pipe) { ··· 1758 1757 1759 1758 /* for lock function check */ 1760 1759 symbol_conf.sort_by_name = true; 1760 + symbol_conf.allow_aliases = true; 1761 1761 symbol__init(&session->header.env); 1762 1762 1763 1763 if (use_bpf) {
+5 -5
tools/perf/command-list.txt
··· 16 16 perf-inject mainporcelain common 17 17 perf-iostat mainporcelain common 18 18 perf-kallsyms mainporcelain common 19 - perf-kmem mainporcelain common 19 + perf-kmem mainporcelain traceevent 20 20 perf-kvm mainporcelain common 21 - perf-kwork mainporcelain common 21 + perf-kwork mainporcelain traceevent 22 22 perf-list mainporcelain common 23 - perf-lock mainporcelain common 23 + perf-lock mainporcelain traceevent 24 24 perf-mem mainporcelain common 25 25 perf-probe mainporcelain full 26 26 perf-record mainporcelain common 27 27 perf-report mainporcelain common 28 - perf-sched mainporcelain common 28 + perf-sched mainporcelain traceevent 29 29 perf-script mainporcelain common 30 30 perf-stat mainporcelain common 31 31 perf-test mainporcelain common 32 - perf-timechart mainporcelain common 32 + perf-timechart mainporcelain traceevent 33 33 perf-top mainporcelain common 34 34 perf-trace mainporcelain audit 35 35 perf-version mainporcelain common
+2 -1
tools/perf/tests/shell/record+probe_libc_inet_pton.sh
··· 37 37 case "$(uname -m)" in 38 38 s390x) 39 39 eventattr='call-graph=dwarf,max-stack=4' 40 + echo "text_to_binary_address.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected 40 41 echo "gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected 41 42 echo "(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected 42 43 echo "main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected ··· 58 57 perf_data=`mktemp -u /tmp/perf.data.XXX` 59 58 perf_script=`mktemp -u /tmp/perf.script.XXX` 60 59 perf record -e $event_name/$eventattr/ -o $perf_data ping -6 -c 1 ::1 > /dev/null 2>&1 61 - perf script -i $perf_data > $perf_script 60 + perf script -i $perf_data | tac | grep -m1 ^ping -B9 | tac > $perf_script 62 61 63 62 exec 3<$perf_script 64 63 exec 4<$expected
+1 -1
tools/perf/util/PERF-VERSION-GEN
··· 19 19 if test -d ../../.git -o -f ../../.git 20 20 then 21 21 TAG=$(MAKEFLAGS= make -sC ../.. kernelversion) 22 - CID=$(git log -1 --abbrev=12 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID" 22 + CID=$(git log -1 --abbrev=12 --pretty=format:"%h" --no-show-signature 2>/dev/null) && CID="-g$CID" 23 23 elif test -f ../../PERF-VERSION-FILE 24 24 then 25 25 TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g')
+3 -11
tools/perf/util/bpf_counter_cgroup.c
··· 116 116 117 117 /* open single copy of the events w/o cgroup */ 118 118 err = evsel__open_per_cpu(evsel, evsel->core.cpus, -1); 119 - if (err) { 120 - pr_err("Failed to open first cgroup events\n"); 121 - goto out; 122 - } 119 + if (err == 0) 120 + evsel->supported = true; 123 121 124 122 map_fd = bpf_map__fd(skel->maps.events); 125 123 perf_cpu_map__for_each_cpu(cpu, j, evsel->core.cpus) { 126 124 int fd = FD(evsel, j); 127 125 __u32 idx = evsel->core.idx * total_cpus + cpu.cpu; 128 126 129 - err = bpf_map_update_elem(map_fd, &idx, &fd, 130 - BPF_ANY); 131 - if (err < 0) { 132 - pr_err("Failed to update perf_event fd\n"); 133 - goto out; 134 - } 127 + bpf_map_update_elem(map_fd, &idx, &fd, BPF_ANY); 135 128 } 136 129 137 130 evsel->cgrp = leader_cgrp; 138 131 } 139 - evsel->supported = true; 140 132 141 133 if (evsel->cgrp == cgrp) 142 134 continue;
+18 -5
tools/perf/util/cgroup.c
··· 224 224 return 0; 225 225 } 226 226 227 + static int check_and_add_cgroup_name(const char *fpath) 228 + { 229 + struct cgroup_name *cn; 230 + 231 + list_for_each_entry(cn, &cgroup_list, list) { 232 + if (!strcmp(cn->name, fpath)) 233 + return 0; 234 + } 235 + 236 + /* pretend if it's added by ftw() */ 237 + return add_cgroup_name(fpath, NULL, FTW_D, NULL); 238 + } 239 + 227 240 static void release_cgroup_list(void) 228 241 { 229 242 struct cgroup_name *cn; ··· 255 242 struct cgroup_name *cn; 256 243 char *s; 257 244 258 - /* use given name as is - for testing purpose */ 245 + /* use given name as is when no regex is given */ 259 246 for (;;) { 260 247 p = strchr(str, ','); 261 248 e = p ? p : eos; ··· 266 253 s = strndup(str, e - str); 267 254 if (!s) 268 255 return -1; 269 - /* pretend if it's added by ftw() */ 270 - ret = add_cgroup_name(s, NULL, FTW_D, NULL); 256 + 257 + ret = check_and_add_cgroup_name(s); 271 258 free(s); 272 - if (ret) 259 + if (ret < 0) 273 260 return -1; 274 261 } else { 275 - if (add_cgroup_name("", NULL, FTW_D, NULL) < 0) 262 + if (check_and_add_cgroup_name("/") < 0) 276 263 return -1; 277 264 } 278 265
+2
tools/perf/util/data.c
··· 132 132 file->size = st.st_size; 133 133 } 134 134 135 + closedir(dir); 135 136 if (!files) 136 137 return -EINVAL; 137 138 ··· 141 140 return 0; 142 141 143 142 out_err: 143 + closedir(dir); 144 144 close_dir(files, nr); 145 145 return ret; 146 146 }
+17 -2
tools/perf/util/generate-cmdlist.sh
··· 38 38 done 39 39 echo "#endif /* HAVE_LIBELF_SUPPORT */" 40 40 41 - echo "#if defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT)" 41 + echo "#if defined(HAVE_LIBTRACEEVENT) && (defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT))" 42 42 sed -n -e 's/^perf-\([^ ]*\)[ ].* audit*/\1/p' command-list.txt | 43 43 sort | 44 44 while read cmd ··· 51 51 p 52 52 }' "Documentation/perf-$cmd.txt" 53 53 done 54 - echo "#endif /* HAVE_LIBELF_SUPPORT */" 54 + echo "#endif /* HAVE_LIBTRACEEVENT && (HAVE_LIBAUDIT_SUPPORT || HAVE_SYSCALL_TABLE_SUPPORT) */" 55 + 56 + echo "#ifdef HAVE_LIBTRACEEVENT" 57 + sed -n -e 's/^perf-\([^ ]*\)[ ].* traceevent.*/\1/p' command-list.txt | 58 + sort | 59 + while read cmd 60 + do 61 + sed -n ' 62 + /^NAME/,/perf-'"$cmd"'/H 63 + ${ 64 + x 65 + s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/ 66 + p 67 + }' "Documentation/perf-$cmd.txt" 68 + done 69 + echo "#endif /* HAVE_LIBTRACEEVENT */" 55 70 echo "};"
+12
tools/perf/util/sort.c
··· 2971 2971 ret = add_all_matching_fields(evlist, field_name, raw_trace, level); 2972 2972 goto out; 2973 2973 } 2974 + #else 2975 + evlist__for_each_entry(evlist, evsel) { 2976 + if (evsel->core.attr.type == PERF_TYPE_TRACEPOINT) { 2977 + pr_err("%s %s", ret ? "," : "This perf binary isn't linked with libtraceevent, can't process", evsel__name(evsel)); 2978 + ret = -ENOTSUP; 2979 + } 2980 + } 2981 + 2982 + if (ret) { 2983 + pr_err("\n"); 2984 + goto out; 2985 + } 2974 2986 #endif 2975 2987 2976 2988 evsel = find_evsel(evlist, event_name);
+1
tools/perf/util/trace-event.h
··· 4 4 5 5 #include <stdbool.h> 6 6 #include <stdio.h> 7 + #include <sys/types.h> 7 8 #include <linux/types.h> 8 9 9 10 struct evlist;
+1
tools/testing/memblock/.gitignore
··· 1 1 main 2 2 memblock.c 3 3 linux/memblock.h 4 + asm/asm.h 4 5 asm/cmpxchg.h
+2 -1
tools/testing/memblock/Makefile
··· 29 29 30 30 @mkdir -p linux 31 31 test -L linux/memblock.h || ln -s ../../../../include/linux/memblock.h linux/memblock.h 32 + test -L asm/asm.h || ln -s ../../../arch/x86/include/asm/asm.h asm/asm.h 32 33 test -L asm/cmpxchg.h || ln -s ../../../arch/x86/include/asm/cmpxchg.h asm/cmpxchg.h 33 34 34 35 memblock.c: $(EXTR_SRC) 35 36 test -L memblock.c || ln -s $(EXTR_SRC) memblock.c 36 37 37 38 clean: 38 - $(RM) $(TARGETS) $(OFILES) linux/memblock.h memblock.c asm/cmpxchg.h 39 + $(RM) $(TARGETS) $(OFILES) linux/memblock.h memblock.c asm/asm.h asm/cmpxchg.h 39 40 40 41 help: 41 42 @echo 'Memblock simulator'
+1
tools/testing/selftests/bpf/.gitignore
··· 36 36 *.lskel.h 37 37 /no_alu32 38 38 /bpf_gcc 39 + /host-tools 39 40 /tools 40 41 /runqslower 41 42 /bench
+1
tools/testing/selftests/bpf/DENYLIST.s390x
··· 14 14 cgrp_local_storage # prog_attach unexpected error: -524 (trampoline) 15 15 core_read_macros # unknown func bpf_probe_read#4 (overlapping) 16 16 d_path # failed to auto-attach program 'prog_stat': -524 (trampoline) 17 + decap_sanity # JIT does not support calling kernel function (kfunc) 17 18 deny_namespace # failed to attach: ERROR: strerror_r(-524)=22 (trampoline) 18 19 dummy_st_ops # test_run unexpected error: -524 (errno 524) (trampoline) 19 20 fentry_fexit # fentry attach failed: -524 (trampoline)
+73
tools/testing/selftests/bpf/prog_tests/bpf_iter.c
··· 1465 1465 bpf_iter_task_vma__destroy(skel); 1466 1466 } 1467 1467 1468 + static void test_task_vma_dead_task(void) 1469 + { 1470 + struct bpf_iter_task_vma *skel; 1471 + int wstatus, child_pid = -1; 1472 + time_t start_tm, cur_tm; 1473 + int err, iter_fd = -1; 1474 + int wait_sec = 3; 1475 + 1476 + skel = bpf_iter_task_vma__open(); 1477 + if (!ASSERT_OK_PTR(skel, "bpf_iter_task_vma__open")) 1478 + return; 1479 + 1480 + skel->bss->pid = getpid(); 1481 + 1482 + err = bpf_iter_task_vma__load(skel); 1483 + if (!ASSERT_OK(err, "bpf_iter_task_vma__load")) 1484 + goto out; 1485 + 1486 + skel->links.proc_maps = bpf_program__attach_iter( 1487 + skel->progs.proc_maps, NULL); 1488 + 1489 + if (!ASSERT_OK_PTR(skel->links.proc_maps, "bpf_program__attach_iter")) { 1490 + skel->links.proc_maps = NULL; 1491 + goto out; 1492 + } 1493 + 1494 + start_tm = time(NULL); 1495 + cur_tm = start_tm; 1496 + 1497 + child_pid = fork(); 1498 + if (child_pid == 0) { 1499 + /* Fork short-lived processes in the background. */ 1500 + while (cur_tm < start_tm + wait_sec) { 1501 + system("echo > /dev/null"); 1502 + cur_tm = time(NULL); 1503 + } 1504 + exit(0); 1505 + } 1506 + 1507 + if (!ASSERT_GE(child_pid, 0, "fork_child")) 1508 + goto out; 1509 + 1510 + while (cur_tm < start_tm + wait_sec) { 1511 + iter_fd = bpf_iter_create(bpf_link__fd(skel->links.proc_maps)); 1512 + if (!ASSERT_GE(iter_fd, 0, "create_iter")) 1513 + goto out; 1514 + 1515 + /* Drain all data from iter_fd. */ 1516 + while (cur_tm < start_tm + wait_sec) { 1517 + err = read_fd_into_buffer(iter_fd, task_vma_output, CMP_BUFFER_SIZE); 1518 + if (!ASSERT_GE(err, 0, "read_iter_fd")) 1519 + goto out; 1520 + 1521 + cur_tm = time(NULL); 1522 + 1523 + if (err == 0) 1524 + break; 1525 + } 1526 + 1527 + close(iter_fd); 1528 + iter_fd = -1; 1529 + } 1530 + 1531 + check_bpf_link_info(skel->progs.proc_maps); 1532 + 1533 + out: 1534 + waitpid(child_pid, &wstatus, 0); 1535 + close(iter_fd); 1536 + bpf_iter_task_vma__destroy(skel); 1537 + } 1538 + 1468 1539 void test_bpf_sockmap_map_iter_fd(void) 1469 1540 { 1470 1541 struct bpf_iter_sockmap *skel; ··· 1657 1586 test_task_file(); 1658 1587 if (test__start_subtest("task_vma")) 1659 1588 test_task_vma(); 1589 + if (test__start_subtest("task_vma_dead_task")) 1590 + test_task_vma_dead_task(); 1660 1591 if (test__start_subtest("task_btf")) 1661 1592 test_task_btf(); 1662 1593 if (test__start_subtest("tcp4"))
+1 -1
tools/testing/selftests/bpf/prog_tests/btf_dump.c
··· 801 801 static void test_btf_dump_var_data(struct btf *btf, struct btf_dump *d, 802 802 char *str) 803 803 { 804 - #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) 804 + #if 0 805 805 TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_number", int, BTF_F_COMPACT, 806 806 "int cpu_number = (int)100", 100); 807 807 #endif
+85
tools/testing/selftests/bpf/prog_tests/decap_sanity.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */ 3 + 4 + #include <sys/types.h> 5 + #include <sys/socket.h> 6 + #include <net/if.h> 7 + #include <linux/in6.h> 8 + 9 + #include "test_progs.h" 10 + #include "network_helpers.h" 11 + #include "decap_sanity.skel.h" 12 + 13 + #define SYS(fmt, ...) \ 14 + ({ \ 15 + char cmd[1024]; \ 16 + snprintf(cmd, sizeof(cmd), fmt, ##__VA_ARGS__); \ 17 + if (!ASSERT_OK(system(cmd), cmd)) \ 18 + goto fail; \ 19 + }) 20 + 21 + #define NS_TEST "decap_sanity_ns" 22 + #define IPV6_IFACE_ADDR "face::1" 23 + #define UDP_TEST_PORT 7777 24 + 25 + void test_decap_sanity(void) 26 + { 27 + LIBBPF_OPTS(bpf_tc_hook, qdisc_hook, .attach_point = BPF_TC_EGRESS); 28 + LIBBPF_OPTS(bpf_tc_opts, tc_attach); 29 + struct nstoken *nstoken = NULL; 30 + struct decap_sanity *skel; 31 + struct sockaddr_in6 addr; 32 + socklen_t addrlen; 33 + char buf[128] = {}; 34 + int sockfd, err; 35 + 36 + skel = decap_sanity__open_and_load(); 37 + if (!ASSERT_OK_PTR(skel, "skel open_and_load")) 38 + return; 39 + 40 + SYS("ip netns add %s", NS_TEST); 41 + SYS("ip -net %s -6 addr add %s/128 dev lo nodad", NS_TEST, IPV6_IFACE_ADDR); 42 + SYS("ip -net %s link set dev lo up", NS_TEST); 43 + 44 + nstoken = open_netns(NS_TEST); 45 + if (!ASSERT_OK_PTR(nstoken, "open_netns")) 46 + goto fail; 47 + 48 + qdisc_hook.ifindex = if_nametoindex("lo"); 49 + if (!ASSERT_GT(qdisc_hook.ifindex, 0, "if_nametoindex lo")) 50 + goto fail; 51 + 52 + err = bpf_tc_hook_create(&qdisc_hook); 53 + if (!ASSERT_OK(err, "create qdisc hook")) 54 + goto fail; 55 + 56 + tc_attach.prog_fd = bpf_program__fd(skel->progs.decap_sanity); 57 + err = bpf_tc_attach(&qdisc_hook, &tc_attach); 58 + if (!ASSERT_OK(err, "attach filter")) 59 + goto fail; 60 + 61 + addrlen = sizeof(addr); 62 + err = make_sockaddr(AF_INET6, IPV6_IFACE_ADDR, UDP_TEST_PORT, 63 + (void *)&addr, &addrlen); 64 + if (!ASSERT_OK(err, "make_sockaddr")) 65 + goto fail; 66 + sockfd = socket(AF_INET6, SOCK_DGRAM, 0); 67 + if (!ASSERT_NEQ(sockfd, -1, "socket")) 68 + goto fail; 69 + err = sendto(sockfd, buf, sizeof(buf), 0, (void *)&addr, addrlen); 70 + close(sockfd); 71 + if (!ASSERT_EQ(err, sizeof(buf), "send")) 72 + goto fail; 73 + 74 + ASSERT_TRUE(skel->bss->init_csum_partial, "init_csum_partial"); 75 + ASSERT_TRUE(skel->bss->final_csum_none, "final_csum_none"); 76 + ASSERT_FALSE(skel->bss->broken_csum_start, "broken_csum_start"); 77 + 78 + fail: 79 + if (nstoken) { 80 + bpf_tc_hook_destroy(&qdisc_hook); 81 + close_netns(nstoken); 82 + } 83 + system("ip netns del " NS_TEST " >& /dev/null"); 84 + decap_sanity__destroy(skel); 85 + }
+9
tools/testing/selftests/bpf/prog_tests/jeq_infer_not_null.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <test_progs.h> 4 + #include "jeq_infer_not_null_fail.skel.h" 5 + 6 + void test_jeq_infer_not_null(void) 7 + { 8 + RUN_TESTS(jeq_infer_not_null_fail); 9 + }
+6
tools/testing/selftests/bpf/progs/bpf_tracing_net.h
··· 50 50 #define ICSK_TIME_LOSS_PROBE 5 51 51 #define ICSK_TIME_REO_TIMEOUT 6 52 52 53 + #define ETH_HLEN 14 54 + #define ETH_P_IPV6 0x86DD 55 + 56 + #define CHECKSUM_NONE 0 57 + #define CHECKSUM_PARTIAL 3 58 + 53 59 #define IFNAMSIZ 16 54 60 55 61 #define RTF_GATEWAY 0x0002
+68
tools/testing/selftests/bpf/progs/decap_sanity.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */ 3 + 4 + #include "vmlinux.h" 5 + #include "bpf_tracing_net.h" 6 + #include <bpf/bpf_helpers.h> 7 + #include <bpf/bpf_endian.h> 8 + 9 + #define UDP_TEST_PORT 7777 10 + 11 + void *bpf_cast_to_kern_ctx(void *) __ksym; 12 + bool init_csum_partial = false; 13 + bool final_csum_none = false; 14 + bool broken_csum_start = false; 15 + 16 + static unsigned int skb_headlen(const struct sk_buff *skb) 17 + { 18 + return skb->len - skb->data_len; 19 + } 20 + 21 + static unsigned int skb_headroom(const struct sk_buff *skb) 22 + { 23 + return skb->data - skb->head; 24 + } 25 + 26 + static int skb_checksum_start_offset(const struct sk_buff *skb) 27 + { 28 + return skb->csum_start - skb_headroom(skb); 29 + } 30 + 31 + SEC("tc") 32 + int decap_sanity(struct __sk_buff *skb) 33 + { 34 + struct sk_buff *kskb; 35 + struct ipv6hdr ip6h; 36 + struct udphdr udph; 37 + int err; 38 + 39 + if (skb->protocol != __bpf_constant_htons(ETH_P_IPV6)) 40 + return TC_ACT_SHOT; 41 + 42 + if (bpf_skb_load_bytes(skb, ETH_HLEN, &ip6h, sizeof(ip6h))) 43 + return TC_ACT_SHOT; 44 + 45 + if (ip6h.nexthdr != IPPROTO_UDP) 46 + return TC_ACT_SHOT; 47 + 48 + if (bpf_skb_load_bytes(skb, ETH_HLEN + sizeof(ip6h), &udph, sizeof(udph))) 49 + return TC_ACT_SHOT; 50 + 51 + if (udph.dest != __bpf_constant_htons(UDP_TEST_PORT)) 52 + return TC_ACT_SHOT; 53 + 54 + kskb = bpf_cast_to_kern_ctx(skb); 55 + init_csum_partial = (kskb->ip_summed == CHECKSUM_PARTIAL); 56 + err = bpf_skb_adjust_room(skb, -(s32)(ETH_HLEN + sizeof(ip6h) + sizeof(udph)), 57 + 1, BPF_F_ADJ_ROOM_FIXED_GSO); 58 + if (err) 59 + return TC_ACT_SHOT; 60 + final_csum_none = (kskb->ip_summed == CHECKSUM_NONE); 61 + if (kskb->ip_summed == CHECKSUM_PARTIAL && 62 + (unsigned int)skb_checksum_start_offset(kskb) >= skb_headlen(kskb)) 63 + broken_csum_start = true; 64 + 65 + return TC_ACT_SHOT; 66 + } 67 + 68 + char __license[] SEC("license") = "GPL";
+42
tools/testing/selftests/bpf/progs/jeq_infer_not_null_fail.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include "vmlinux.h" 4 + #include <bpf/bpf_helpers.h> 5 + #include "bpf_misc.h" 6 + 7 + char _license[] SEC("license") = "GPL"; 8 + 9 + struct { 10 + __uint(type, BPF_MAP_TYPE_HASH); 11 + __uint(max_entries, 1); 12 + __type(key, u64); 13 + __type(value, u64); 14 + } m_hash SEC(".maps"); 15 + 16 + SEC("?raw_tp") 17 + __failure __msg("R8 invalid mem access 'map_value_or_null") 18 + int jeq_infer_not_null_ptr_to_btfid(void *ctx) 19 + { 20 + struct bpf_map *map = (struct bpf_map *)&m_hash; 21 + struct bpf_map *inner_map = map->inner_map_meta; 22 + u64 key = 0, ret = 0, *val; 23 + 24 + val = bpf_map_lookup_elem(map, &key); 25 + /* Do not mark ptr as non-null if one of them is 26 + * PTR_TO_BTF_ID (R9), reject because of invalid 27 + * access to map value (R8). 28 + * 29 + * Here, we need to inline those insns to access 30 + * R8 directly, since compiler may use other reg 31 + * once it figures out val==inner_map. 32 + */ 33 + asm volatile("r8 = %[val];\n" 34 + "r9 = %[inner_map];\n" 35 + "if r8 != r9 goto +1;\n" 36 + "%[ret] = *(u64 *)(r8 +0);\n" 37 + : [ret] "+r"(ret) 38 + : [inner_map] "r"(inner_map), [val] "r"(val) 39 + : "r8", "r9"); 40 + 41 + return ret; 42 + }
+6 -85
tools/testing/selftests/kvm/.gitignore
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 - /aarch64/aarch32_id_regs 3 - /aarch64/arch_timer 4 - /aarch64/debug-exceptions 5 - /aarch64/get-reg-list 6 - /aarch64/hypercalls 7 - /aarch64/page_fault_test 8 - /aarch64/psci_test 9 - /aarch64/vcpu_width_config 10 - /aarch64/vgic_init 11 - /aarch64/vgic_irq 12 - /s390x/memop 13 - /s390x/resets 14 - /s390x/sync_regs_test 15 - /s390x/tprot 16 - /x86_64/amx_test 17 - /x86_64/cpuid_test 18 - /x86_64/cr4_cpuid_sync_test 19 - /x86_64/debug_regs 20 - /x86_64/exit_on_emulation_failure_test 21 - /x86_64/fix_hypercall_test 22 - /x86_64/get_msr_index_features 23 - /x86_64/kvm_clock_test 24 - /x86_64/kvm_pv_test 25 - /x86_64/hyperv_clock 26 - /x86_64/hyperv_cpuid 27 - /x86_64/hyperv_evmcs 28 - /x86_64/hyperv_features 29 - /x86_64/hyperv_ipi 30 - /x86_64/hyperv_svm_test 31 - /x86_64/hyperv_tlb_flush 32 - /x86_64/max_vcpuid_cap_test 33 - /x86_64/mmio_warning_test 34 - /x86_64/monitor_mwait_test 35 - /x86_64/nested_exceptions_test 36 - /x86_64/nx_huge_pages_test 37 - /x86_64/platform_info_test 38 - /x86_64/pmu_event_filter_test 39 - /x86_64/set_boot_cpu_id 40 - /x86_64/set_sregs_test 41 - /x86_64/sev_migrate_tests 42 - /x86_64/smaller_maxphyaddr_emulation_test 43 - /x86_64/smm_test 44 - /x86_64/state_test 45 - /x86_64/svm_vmcall_test 46 - /x86_64/svm_int_ctl_test 47 - /x86_64/svm_nested_soft_inject_test 48 - /x86_64/svm_nested_shutdown_test 49 - /x86_64/sync_regs_test 50 - /x86_64/tsc_msrs_test 51 - /x86_64/tsc_scaling_sync 52 - /x86_64/ucna_injection_test 53 - /x86_64/userspace_io_test 54 - /x86_64/userspace_msr_exit_test 55 - /x86_64/vmx_apic_access_test 56 - /x86_64/vmx_close_while_nested_test 57 - /x86_64/vmx_dirty_log_test 58 - /x86_64/vmx_exception_with_invalid_guest_state 59 - /x86_64/vmx_invalid_nested_guest_state 60 - /x86_64/vmx_msrs_test 61 - /x86_64/vmx_preemption_timer_test 62 - /x86_64/vmx_set_nested_state_test 63 - /x86_64/vmx_tsc_adjust_test 64 - /x86_64/vmx_nested_tsc_scaling_test 65 - /x86_64/xapic_ipi_test 66 - /x86_64/xapic_state_test 67 - /x86_64/xen_shinfo_test 68 - /x86_64/xen_vmcall_test 69 - /x86_64/xss_msr_test 70 - /x86_64/vmx_pmu_caps_test 71 - /x86_64/triple_fault_event_test 72 - /access_tracking_perf_test 73 - /demand_paging_test 74 - /dirty_log_test 75 - /dirty_log_perf_test 76 - /hardware_disable_test 77 - /kvm_create_max_vcpus 78 - /kvm_page_table_test 79 - /max_guest_memory_test 80 - /memslot_modification_stress_test 81 - /memslot_perf_test 82 - /rseq_test 83 - /set_memory_region_test 84 - /steal_time 85 - /kvm_binary_stats_test 86 - /system_counter_offset_test 2 + * 3 + !/**/ 4 + !*.c 5 + !*.h 6 + !*.S 7 + !*.sh
+23 -41
tools/testing/selftests/kvm/Makefile
··· 7 7 include $(top_srcdir)/scripts/subarch.include 8 8 ARCH ?= $(SUBARCH) 9 9 10 - # For cross-builds to work, UNAME_M has to map to ARCH and arch specific 11 - # directories and targets in this Makefile. "uname -m" doesn't map to 12 - # arch specific sub-directory names. 13 - # 14 - # UNAME_M variable to used to run the compiles pointing to the right arch 15 - # directories and build the right targets for these supported architectures. 16 - # 17 - # TEST_GEN_PROGS and LIBKVM are set using UNAME_M variable. 18 - # LINUX_TOOL_ARCH_INCLUDE is set using ARCH variable. 19 - # 20 - # x86_64 targets are named to include x86_64 as a suffix and directories 21 - # for includes are in x86_64 sub-directory. s390x and aarch64 follow the 22 - # same convention. "uname -m" doesn't result in the correct mapping for 23 - # s390x and aarch64. 24 - # 25 - # No change necessary for x86_64 26 - UNAME_M := $(shell uname -m) 27 - 28 - # Set UNAME_M for arm64 compile/install to work 29 - ifeq ($(ARCH),arm64) 30 - UNAME_M := aarch64 31 - endif 32 - # Set UNAME_M s390x compile/install to work 33 - ifeq ($(ARCH),s390) 34 - UNAME_M := s390x 35 - endif 36 - # Set UNAME_M riscv compile/install to work 37 - ifeq ($(ARCH),riscv) 38 - UNAME_M := riscv 10 + ifeq ($(ARCH),x86) 11 + ARCH_DIR := x86_64 12 + else ifeq ($(ARCH),arm64) 13 + ARCH_DIR := aarch64 14 + else ifeq ($(ARCH),s390) 15 + ARCH_DIR := s390x 16 + else 17 + ARCH_DIR := $(ARCH) 39 18 endif 40 19 41 20 LIBKVM += lib/assert.c ··· 175 196 TEST_GEN_PROGS_riscv += set_memory_region_test 176 197 TEST_GEN_PROGS_riscv += kvm_binary_stats_test 177 198 178 - TEST_PROGS += $(TEST_PROGS_$(UNAME_M)) 179 - TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M)) 180 - TEST_GEN_PROGS_EXTENDED += $(TEST_GEN_PROGS_EXTENDED_$(UNAME_M)) 181 - LIBKVM += $(LIBKVM_$(UNAME_M)) 199 + TEST_PROGS += $(TEST_PROGS_$(ARCH_DIR)) 200 + TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(ARCH_DIR)) 201 + TEST_GEN_PROGS_EXTENDED += $(TEST_GEN_PROGS_EXTENDED_$(ARCH_DIR)) 202 + LIBKVM += $(LIBKVM_$(ARCH_DIR)) 203 + 204 + # lib.mak defines $(OUTPUT), prepends $(OUTPUT)/ to $(TEST_GEN_PROGS), and most 205 + # importantly defines, i.e. overwrites, $(CC) (unless `make -e` or `make CC=`, 206 + # which causes the environment variable to override the makefile). 207 + include ../lib.mk 182 208 183 209 INSTALL_HDR_PATH = $(top_srcdir)/usr 184 210 LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/ ··· 194 210 LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include 195 211 endif 196 212 CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ 213 + -Wno-gnu-variable-sized-type-not-at-end \ 214 + -fno-builtin-memcmp -fno-builtin-memcpy -fno-builtin-memset \ 197 215 -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \ 198 216 -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \ 199 - -I$(<D) -Iinclude/$(UNAME_M) -I ../rseq -I.. $(EXTRA_CFLAGS) \ 217 + -I$(<D) -Iinclude/$(ARCH_DIR) -I ../rseq -I.. $(EXTRA_CFLAGS) \ 200 218 $(KHDR_INCLUDES) 201 219 202 - no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ 203 - $(CC) -Werror -no-pie -x c - -o "$$TMP", -no-pie) 220 + no-pie-option := $(call try-run, echo 'int main(void) { return 0; }' | \ 221 + $(CC) -Werror $(CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) 204 222 205 223 # On s390, build the testcases KVM-enabled 206 - pgste-option = $(call try-run, echo 'int main() { return 0; }' | \ 224 + pgste-option = $(call try-run, echo 'int main(void) { return 0; }' | \ 207 225 $(CC) -Werror -Wl$(comma)--s390-pgste -x c - -o "$$TMP",-Wl$(comma)--s390-pgste) 208 226 209 227 LDLIBS += -ldl 210 228 LDFLAGS += -pthread $(no-pie-option) $(pgste-option) 211 - 212 - # After inclusion, $(OUTPUT) is defined and 213 - # $(TEST_GEN_PROGS) starts with $(OUTPUT)/ 214 - include ../lib.mk 215 229 216 230 LIBKVM_C := $(filter %.c,$(LIBKVM)) 217 231 LIBKVM_S := $(filter %.S,$(LIBKVM))
+1 -1
tools/testing/selftests/kvm/aarch64/page_fault_test.c
··· 117 117 GUEST_ASSERT(guest_check_lse()); 118 118 asm volatile(".arch_extension lse\n" 119 119 "casal %0, %1, [%2]\n" 120 - :: "r" (0), "r" (TEST_DATA), "r" (guest_test_memory)); 120 + :: "r" (0ul), "r" (TEST_DATA), "r" (guest_test_memory)); 121 121 val = READ_ONCE(*guest_test_memory); 122 122 GUEST_ASSERT_EQ(val, TEST_DATA); 123 123 }
+4 -2
tools/testing/selftests/kvm/lib/aarch64/ucall.c
··· 14 14 15 15 void ucall_arch_init(struct kvm_vm *vm, vm_paddr_t mmio_gpa) 16 16 { 17 - virt_pg_map(vm, mmio_gpa, mmio_gpa); 17 + vm_vaddr_t mmio_gva = vm_vaddr_unused_gap(vm, vm->page_size, KVM_UTIL_MIN_VADDR); 18 + 19 + virt_map(vm, mmio_gva, mmio_gpa, 1); 18 20 19 21 vm->ucall_mmio_addr = mmio_gpa; 20 22 21 - write_guest_global(vm, ucall_exit_mmio_addr, (vm_vaddr_t *)mmio_gpa); 23 + write_guest_global(vm, ucall_exit_mmio_addr, (vm_vaddr_t *)mmio_gva); 22 24 } 23 25 24 26 void ucall_arch_do_ucall(vm_vaddr_t uc)
+11 -2
tools/testing/selftests/kvm/lib/kvm_util.c
··· 186 186 _Static_assert(sizeof(vm_guest_mode_params)/sizeof(struct vm_guest_mode_params) == NUM_VM_MODES, 187 187 "Missing new mode params?"); 188 188 189 + /* 190 + * Initializes vm->vpages_valid to match the canonical VA space of the 191 + * architecture. 192 + * 193 + * The default implementation is valid for architectures which split the 194 + * range addressed by a single page table into a low and high region 195 + * based on the MSB of the VA. On architectures with this behavior 196 + * the VA region spans [0, 2^(va_bits - 1)), [-(2^(va_bits - 1), -1]. 197 + */ 189 198 __weak void vm_vaddr_populate_bitmap(struct kvm_vm *vm) 190 199 { 191 200 sparsebit_set_num(vm->vpages_valid, ··· 1425 1416 1426 1417 while (npages--) { 1427 1418 virt_pg_map(vm, vaddr, paddr); 1419 + sparsebit_set(vm->vpages_mapped, vaddr >> vm->page_shift); 1420 + 1428 1421 vaddr += page_size; 1429 1422 paddr += page_size; 1430 - 1431 - sparsebit_set(vm->vpages_mapped, vaddr >> vm->page_shift); 1432 1423 } 1433 1424 } 1434 1425
+14 -2
tools/testing/selftests/kvm/lib/ucall_common.c
··· 4 4 #include "linux/bitmap.h" 5 5 #include "linux/atomic.h" 6 6 7 + #define GUEST_UCALL_FAILED -1 8 + 7 9 struct ucall_header { 8 10 DECLARE_BITMAP(in_use, KVM_MAX_VCPUS); 9 11 struct ucall ucalls[KVM_MAX_VCPUS]; ··· 43 41 struct ucall *uc; 44 42 int i; 45 43 46 - GUEST_ASSERT(ucall_pool); 44 + if (!ucall_pool) 45 + goto ucall_failed; 47 46 48 47 for (i = 0; i < KVM_MAX_VCPUS; ++i) { 49 48 if (!test_and_set_bit(i, ucall_pool->in_use)) { ··· 54 51 } 55 52 } 56 53 57 - GUEST_ASSERT(0); 54 + ucall_failed: 55 + /* 56 + * If the vCPU cannot grab a ucall structure, make a bare ucall with a 57 + * magic value to signal to get_ucall() that things went sideways. 58 + * GUEST_ASSERT() depends on ucall_alloc() and so cannot be used here. 59 + */ 60 + ucall_arch_do_ucall(GUEST_UCALL_FAILED); 58 61 return NULL; 59 62 } 60 63 ··· 102 93 103 94 addr = ucall_arch_get_ucall(vcpu); 104 95 if (addr) { 96 + TEST_ASSERT(addr != (void *)GUEST_UCALL_FAILED, 97 + "Guest failed to allocate ucall struct"); 98 + 105 99 memcpy(uc, addr, sizeof(*uc)); 106 100 vcpu_run_complete_io(vcpu); 107 101 } else {
+1 -1
tools/testing/selftests/kvm/lib/x86_64/processor.c
··· 1031 1031 void kvm_get_cpu_address_width(unsigned int *pa_bits, unsigned int *va_bits) 1032 1032 { 1033 1033 if (!kvm_cpu_has_p(X86_PROPERTY_MAX_PHY_ADDR)) { 1034 - *pa_bits == kvm_cpu_has(X86_FEATURE_PAE) ? 36 : 32; 1034 + *pa_bits = kvm_cpu_has(X86_FEATURE_PAE) ? 36 : 32; 1035 1035 *va_bits = 32; 1036 1036 } else { 1037 1037 *pa_bits = kvm_cpu_property(X86_PROPERTY_MAX_PHY_ADDR);
+3
tools/testing/selftests/kvm/memslot_perf_test.c
··· 265 265 slots = data->nslots; 266 266 while (--slots > 1) { 267 267 pages_per_slot = mempages / slots; 268 + if (!pages_per_slot) 269 + continue; 270 + 268 271 rempages = mempages % pages_per_slot; 269 272 if (check_slot_pages(host_page_size, guest_page_size, 270 273 pages_per_slot, rempages))
+2 -1
tools/testing/selftests/kvm/x86_64/hyperv_ipi.c
··· 193 193 GUEST_SYNC(stage++); 194 194 /* 195 195 * 'XMM Fast' HvCallSendSyntheticClusterIpiEx to HV_GENERIC_SET_ALL. 196 - * Nothing to write anything to XMM regs. 197 196 */ 197 + ipi_ex->vp_set.valid_bank_mask = 0; 198 + hyperv_write_xmm_input(&ipi_ex->vp_set.valid_bank_mask, 2); 198 199 hyperv_hypercall(HVCALL_SEND_IPI_EX | HV_HYPERCALL_FAST_BIT, 199 200 IPI_VECTOR, HV_GENERIC_SET_ALL); 200 201 nop_loop();
+11 -2
tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c
··· 41 41 static void l2_guest_code_int(void) 42 42 { 43 43 GUEST_ASSERT_1(int_fired == 1, int_fired); 44 - vmmcall(); 45 - ud2(); 44 + 45 + /* 46 + * Same as the vmmcall() function, but with a ud2 sneaked after the 47 + * vmmcall. The caller injects an exception with the return address 48 + * increased by 2, so the "pop rbp" must be after the ud2 and we cannot 49 + * use vmmcall() directly. 50 + */ 51 + __asm__ __volatile__("push %%rbp; vmmcall; ud2; pop %%rbp" 52 + : : "a"(0xdeadbeef), "c"(0xbeefdead) 53 + : "rbx", "rdx", "rsi", "rdi", "r8", "r9", 54 + "r10", "r11", "r12", "r13", "r14", "r15"); 46 55 47 56 GUEST_ASSERT_1(bp_fired == 1, bp_fired); 48 57 hlt();
-5
tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c
··· 49 49 NUM_VMX_PAGES, 50 50 }; 51 51 52 - struct kvm_single_msr { 53 - struct kvm_msrs header; 54 - struct kvm_msr_entry entry; 55 - } __attribute__((packed)); 56 - 57 52 /* The virtual machine object. */ 58 53 static struct kvm_vm *vm; 59 54
+6
tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
··· 962 962 } 963 963 964 964 done: 965 + struct kvm_xen_hvm_attr evt_reset = { 966 + .type = KVM_XEN_ATTR_TYPE_EVTCHN, 967 + .u.evtchn.flags = KVM_XEN_EVTCHN_RESET, 968 + }; 969 + vm_ioctl(vm, KVM_XEN_HVM_SET_ATTR, &evt_reset); 970 + 965 971 alarm(0); 966 972 clock_gettime(CLOCK_REALTIME, &max_ts); 967 973
+1
tools/testing/selftests/net/.gitignore
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 bind_bhash 3 + bind_timewait 3 4 csum 4 5 cmsg_sender 5 6 diag_uid
+11 -4
tools/testing/selftests/net/arp_ndisc_evict_nocarrier.sh
··· 18 18 readonly V6_ADDR0=2001:db8:91::1 19 19 readonly V6_ADDR1=2001:db8:91::2 20 20 nsid=100 21 + ret=0 21 22 22 23 cleanup_v6() 23 24 { 24 25 ip netns del me 25 26 ip netns del peer 26 27 27 - sysctl -w net.ipv4.conf.veth0.ndisc_evict_nocarrier=1 >/dev/null 2>&1 28 - sysctl -w net.ipv4.conf.all.ndisc_evict_nocarrier=1 >/dev/null 2>&1 28 + sysctl -w net.ipv6.conf.veth1.ndisc_evict_nocarrier=1 >/dev/null 2>&1 29 + sysctl -w net.ipv6.conf.all.ndisc_evict_nocarrier=1 >/dev/null 2>&1 29 30 } 30 31 31 32 create_ns() ··· 62 61 if [ $? -ne 0 ]; then 63 62 cleanup_v6 64 63 echo "failed" 65 - exit 64 + exit 1 66 65 fi 67 66 68 67 # Set veth2 down, which will put veth1 in NOCARRIER state ··· 89 88 if [ $? -ne 0 ]; then 90 89 cleanup_v4 91 90 echo "failed" 92 - exit 91 + exit 1 93 92 fi 94 93 95 94 # Set veth1 down, which will put veth0 in NOCARRIER state ··· 116 115 117 116 if [ $? -eq 0 ];then 118 117 echo "failed" 118 + ret=1 119 119 else 120 120 echo "ok" 121 121 fi ··· 136 134 echo "ok" 137 135 else 138 136 echo "failed" 137 + ret=1 139 138 fi 140 139 141 140 cleanup_v4 ··· 167 164 168 165 if [ $? -eq 0 ];then 169 166 echo "failed" 167 + ret=1 170 168 else 171 169 echo "ok" 172 170 fi ··· 186 182 echo "ok" 187 183 else 188 184 echo "failed" 185 + ret=1 189 186 fi 190 187 191 188 cleanup_v6 ··· 203 198 echo "ok" 204 199 else 205 200 echo "failed" 201 + ret=1 206 202 fi 207 203 208 204 cleanup_v6 ··· 224 218 fi 225 219 226 220 run_all_tests 221 + exit $ret
+92
tools/testing/selftests/net/bind_timewait.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Copyright Amazon.com Inc. or its affiliates. */ 3 + 4 + #include <sys/socket.h> 5 + #include <netinet/in.h> 6 + 7 + #include "../kselftest_harness.h" 8 + 9 + FIXTURE(bind_timewait) 10 + { 11 + struct sockaddr_in addr; 12 + socklen_t addrlen; 13 + }; 14 + 15 + FIXTURE_VARIANT(bind_timewait) 16 + { 17 + __u32 addr_const; 18 + }; 19 + 20 + FIXTURE_VARIANT_ADD(bind_timewait, localhost) 21 + { 22 + .addr_const = INADDR_LOOPBACK 23 + }; 24 + 25 + FIXTURE_VARIANT_ADD(bind_timewait, addrany) 26 + { 27 + .addr_const = INADDR_ANY 28 + }; 29 + 30 + FIXTURE_SETUP(bind_timewait) 31 + { 32 + self->addr.sin_family = AF_INET; 33 + self->addr.sin_port = 0; 34 + self->addr.sin_addr.s_addr = htonl(variant->addr_const); 35 + self->addrlen = sizeof(self->addr); 36 + } 37 + 38 + FIXTURE_TEARDOWN(bind_timewait) 39 + { 40 + } 41 + 42 + void create_timewait_socket(struct __test_metadata *_metadata, 43 + FIXTURE_DATA(bind_timewait) *self) 44 + { 45 + int server_fd, client_fd, child_fd, ret; 46 + struct sockaddr_in addr; 47 + socklen_t addrlen; 48 + 49 + server_fd = socket(AF_INET, SOCK_STREAM, 0); 50 + ASSERT_GT(server_fd, 0); 51 + 52 + ret = bind(server_fd, (struct sockaddr *)&self->addr, self->addrlen); 53 + ASSERT_EQ(ret, 0); 54 + 55 + ret = listen(server_fd, 1); 56 + ASSERT_EQ(ret, 0); 57 + 58 + ret = getsockname(server_fd, (struct sockaddr *)&self->addr, &self->addrlen); 59 + ASSERT_EQ(ret, 0); 60 + 61 + client_fd = socket(AF_INET, SOCK_STREAM, 0); 62 + ASSERT_GT(client_fd, 0); 63 + 64 + ret = connect(client_fd, (struct sockaddr *)&self->addr, self->addrlen); 65 + ASSERT_EQ(ret, 0); 66 + 67 + addrlen = sizeof(addr); 68 + child_fd = accept(server_fd, (struct sockaddr *)&addr, &addrlen); 69 + ASSERT_GT(child_fd, 0); 70 + 71 + close(child_fd); 72 + close(client_fd); 73 + close(server_fd); 74 + } 75 + 76 + TEST_F(bind_timewait, 1) 77 + { 78 + int fd, ret; 79 + 80 + create_timewait_socket(_metadata, self); 81 + 82 + fd = socket(AF_INET, SOCK_STREAM, 0); 83 + ASSERT_GT(fd, 0); 84 + 85 + ret = bind(fd, (struct sockaddr *)&self->addr, self->addrlen); 86 + ASSERT_EQ(ret, -1); 87 + ASSERT_EQ(errno, EADDRINUSE); 88 + 89 + close(fd); 90 + } 91 + 92 + TEST_HARNESS_MAIN
+1 -1
tools/testing/selftests/net/cmsg_sender.c
··· 110 110 111 111 static void cs_parse_args(int argc, char *argv[]) 112 112 { 113 - char o; 113 + int o; 114 114 115 115 while ((o = getopt(argc, argv, "46sS:p:m:M:d:tf:F:c:C:l:L:H:")) != -1) { 116 116 switch (o) {
+20 -17
tools/virtio/ringtest/main.h
··· 140 140 #define smp_wmb() smp_release() 141 141 #endif 142 142 143 - #ifdef __alpha__ 144 - #define smp_read_barrier_depends() smp_acquire() 145 - #else 146 - #define smp_read_barrier_depends() do {} while(0) 147 - #endif 148 - 149 143 static __always_inline 150 144 void __read_once_size(const volatile void *p, void *res, int size) 151 145 { 152 - switch (size) { \ 153 - case 1: *(unsigned char *)res = *(volatile unsigned char *)p; break; \ 154 - case 2: *(unsigned short *)res = *(volatile unsigned short *)p; break; \ 155 - case 4: *(unsigned int *)res = *(volatile unsigned int *)p; break; \ 156 - case 8: *(unsigned long long *)res = *(volatile unsigned long long *)p; break; \ 157 - default: \ 158 - barrier(); \ 159 - __builtin_memcpy((void *)res, (const void *)p, size); \ 160 - barrier(); \ 161 - } \ 146 + switch (size) { 147 + case 1: *(unsigned char *)res = *(volatile unsigned char *)p; break; 148 + case 2: *(unsigned short *)res = *(volatile unsigned short *)p; break; 149 + case 4: *(unsigned int *)res = *(volatile unsigned int *)p; break; 150 + case 8: *(unsigned long long *)res = *(volatile unsigned long long *)p; break; 151 + default: 152 + barrier(); 153 + __builtin_memcpy((void *)res, (const void *)p, size); 154 + barrier(); 155 + } 162 156 } 163 157 164 158 static __always_inline void __write_once_size(volatile void *p, void *res, int size) ··· 169 175 } 170 176 } 171 177 178 + #ifdef __alpha__ 172 179 #define READ_ONCE(x) \ 173 180 ({ \ 174 181 union { typeof(x) __val; char __c[1]; } __u; \ 175 182 __read_once_size(&(x), __u.__c, sizeof(x)); \ 176 - smp_read_barrier_depends(); /* Enforce dependency ordering from x */ \ 183 + smp_mb(); /* Enforce dependency ordering from x */ \ 177 184 __u.__val; \ 178 185 }) 186 + #else 187 + #define READ_ONCE(x) \ 188 + ({ \ 189 + union { typeof(x) __val; char __c[1]; } __u; \ 190 + __read_once_size(&(x), __u.__c, sizeof(x)); \ 191 + __u.__val; \ 192 + }) 193 + #endif 179 194 180 195 #define WRITE_ONCE(x, val) \ 181 196 ({ \
+1 -1
tools/virtio/virtio-trace/trace-agent-ctl.c
··· 75 75 76 76 if (ret) 77 77 break; 78 - }; 78 + } 79 79 80 80 return ret; 81 81
+1 -1
tools/virtio/virtio_test.c
··· 173 173 long started = 0, completed = 0, next_reset = reset_n; 174 174 long completed_before, started_before; 175 175 int r, test = 1; 176 - unsigned len; 176 + unsigned int len; 177 177 long long spurious = 0; 178 178 const bool random_batch = batch == RANDOM_BATCH; 179 179
+2
tools/virtio/vringh_test.c
··· 308 308 309 309 gvdev.vdev.features = features; 310 310 INIT_LIST_HEAD(&gvdev.vdev.vqs); 311 + spin_lock_init(&gvdev.vdev.vqs_list_lock); 311 312 gvdev.to_host_fd = to_host[1]; 312 313 gvdev.notifies = 0; 313 314 ··· 456 455 getrange = getrange_iov; 457 456 vdev.features = 0; 458 457 INIT_LIST_HEAD(&vdev.vqs); 458 + spin_lock_init(&vdev.vqs_list_lock); 459 459 460 460 while (argv[1]) { 461 461 if (strcmp(argv[1], "--indirect") == 0)
-4
virt/kvm/kvm_mm.h
··· 14 14 #define KVM_MMU_LOCK_INIT(kvm) rwlock_init(&(kvm)->mmu_lock) 15 15 #define KVM_MMU_LOCK(kvm) write_lock(&(kvm)->mmu_lock) 16 16 #define KVM_MMU_UNLOCK(kvm) write_unlock(&(kvm)->mmu_lock) 17 - #define KVM_MMU_READ_LOCK(kvm) read_lock(&(kvm)->mmu_lock) 18 - #define KVM_MMU_READ_UNLOCK(kvm) read_unlock(&(kvm)->mmu_lock) 19 17 #else 20 18 #define KVM_MMU_LOCK_INIT(kvm) spin_lock_init(&(kvm)->mmu_lock) 21 19 #define KVM_MMU_LOCK(kvm) spin_lock(&(kvm)->mmu_lock) 22 20 #define KVM_MMU_UNLOCK(kvm) spin_unlock(&(kvm)->mmu_lock) 23 - #define KVM_MMU_READ_LOCK(kvm) spin_lock(&(kvm)->mmu_lock) 24 - #define KVM_MMU_READ_UNLOCK(kvm) spin_unlock(&(kvm)->mmu_lock) 25 21 #endif /* KVM_HAVE_MMU_RWLOCK */ 26 22 27 23 kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool interruptible,