Pull 7.2 devel branch for put_device auto-clean fixes.
Unified · Split
| @@ -66,6 +66,11 @@ Alex Hung <alexhung@gmail.com> <alex.hung@canonical.com> · 65 unmodified lines | ||
| 66 | 66 | Alex Shi <alexs@kernel.org> <alex.shi@intel.com> |
| 67 | 67 | Alex Shi <alexs@kernel.org> <alex.shi@linaro.org> |
| 68 | 68 | Alex Shi <alexs@kernel.org> <alex.shi@linux.alibaba.com> |
| 69 | +Alice Mikityanska <alice.kernel@fastmail.im> <maxtram95@gmail.com> | |
| 70 | +Alice Mikityanska <alice.kernel@fastmail.im> <maximmi@mellanox.com> | |
| 71 | +Alice Mikityanska <alice.kernel@fastmail.im> <maximmi@nvidia.com> | |
| 72 | +Alice Mikityanska <alice.kernel@fastmail.im> <maxim@isovalent.com> | |
| 73 | +Alice Mikityanska <alice.kernel@fastmail.im> <alice@isovalent.com> | |
| 69 | 74 | Aloka Dixit <quic_alokad@quicinc.com> <alokad@codeaurora.org> |
| 70 | 75 | Al Viro <viro@ftp.linux.org.uk> |
| 71 | 76 | Al Viro <viro@zenIV.linux.org.uk> |
| @@ -540,6 +545,7 @@ Maciej W. Rozycki <macro@mips.com> <macro@imgtec.com> · 468 unmodified lines | ||
| 540 | 545 | Maciej W. Rozycki <macro@orcam.me.uk> <macro@linux-mips.org> |
| 541 | 546 | Maharaja Kennadyrajan <quic_mkenna@quicinc.com> <mkenna@codeaurora.org> |
| 542 | 547 | Maheshwar Ajja <quic_majja@quicinc.com> <majja@codeaurora.org> |
| 548 | +Maíra Canal <mairacanal@riseup.net> <maira.canal@usp.br> | |
| 543 | 549 | Malathi Gottam <quic_mgottam@quicinc.com> <mgottam@codeaurora.org> |
| 544 | 550 | Manikanta Pubbisetty <quic_mpubbise@quicinc.com> <mpubbise@codeaurora.org> |
| 545 | 551 | Manivannan Sadhasivam <mani@kernel.org> <manivannanece23@gmail.com> |
| @@ -585,8 +591,6 @@ Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@osg.samsung.com> · 39 unmodified lines | ||
| 585 | 591 | Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@redhat.com> |
| 586 | 592 | Mauro Carvalho Chehab <mchehab@kernel.org> <m.chehab@samsung.com> |
| 587 | 593 | Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@s-opensource.com> |
| 588 | −Maxim Mikityanskiy <maxtram95@gmail.com> <maximmi@mellanox.com> | |
| 589 | −Maxim Mikityanskiy <maxtram95@gmail.com> <maximmi@nvidia.com> | |
| 590 | 594 | Maxime Ripard <mripard@kernel.org> <maxime@cerno.tech> |
| 591 | 595 | Maxime Ripard <mripard@kernel.org> <maxime.ripard@bootlin.com> |
| 592 | 596 | Maxime Ripard <mripard@kernel.org> <maxime.ripard@free-electrons.com> |
| @@ -595,8 +599,8 @@ Mayuresh Janorkar <mayur@ti.com> · 2 unmodified lines | ||
| 595 | 599 | Md Sadre Alam <quic_mdalam@quicinc.com> <mdalam@codeaurora.org> |
| 596 | 600 | Miaoqing Pan <quic_miaoqing@quicinc.com> <miaoqing@codeaurora.org> |
| 597 | 601 | Michael Buesch <m@bues.ch> |
| 598 | −Michal Grzeschik <mgr@kernel.org> <m.grzeschik@pengutronix.de> | |
| 599 | −Michal Grzeschik <mgr@kernel.org> <mgr@pengutronix.de> | |
| 602 | +Michael Grzeschik <mgr@kernel.org> <m.grzeschik@pengutronix.de> | |
| 603 | +Michael Grzeschik <mgr@kernel.org> <mgr@pengutronix.de> | |
| 600 | 604 | Michael Riesch <michael.riesch@collabora.com> <michael.riesch@wolfvision.net> |
| 601 | 605 | Michal Simek <michal.simek@amd.com> <michal.simek@xilinx.com> |
| 602 | 606 | Michel Dänzer <michel@tungstengraphics.com> |
| @@ -817,6 +821,7 @@ Simon Wunderlich <sw@simonwunderlich.de> <simon.wunderlich@s2003.tu-chemnitz.de> · 214 unmodified lines | ||
| 817 | 821 | Simon Wunderlich <sw@simonwunderlich.de> <simon.wunderlich@saxnet.de> |
| 818 | 822 | Simon Wunderlich <sw@simonwunderlich.de> <simon@open-mesh.com> |
| 819 | 823 | Simon Wunderlich <sw@simonwunderlich.de> <siwu@hrz.tu-chemnitz.de> |
| 824 | +SJ Park <sj@kernel.org> | |
| 820 | 825 | Sricharan Ramabadhran <quic_srichara@quicinc.com> <sricharan@codeaurora.org> |
| 821 | 826 | Srinivas Kandagatla <srini@kernel.org> <srinivas.kandagatla@st.com> |
| 822 | 827 | Srinivas Kandagatla <srini@kernel.org> <srinivas.kandagatla@linaro.org> |
| @@ -1,26 +1,26 @@ | ||
| 1 | 1 | what: /sys/kernel/mm/damon/ |
| 2 | 2 | Date: Mar 2022 |
| 3 | −Contact: SeongJae Park <sj@kernel.org> | |
| 3 | +Contact: SJ Park <sj@kernel.org> | |
| 4 | 4 | Description: Interface for Data Access MONitoring (DAMON). Contains files |
| 5 | 5 | for controlling DAMON. For more details on DAMON itself, |
| 6 | 6 | please refer to Documentation/admin-guide/mm/damon/index.rst. |
| 7 | 7 | |
| 8 | 8 | What: /sys/kernel/mm/damon/admin/ |
| 9 | 9 | Date: Mar 2022 |
| 10 | −Contact: SeongJae Park <sj@kernel.org> | |
| 10 | +Contact: SJ Park <sj@kernel.org> | |
| 11 | 11 | Description: Interface for privileged users of DAMON. Contains files for |
| 12 | 12 | controlling DAMON that aimed to be used by privileged users. |
| 13 | 13 | |
| 14 | 14 | What: /sys/kernel/mm/damon/admin/kdamonds/nr_kdamonds |
| 15 | 15 | Date: Mar 2022 |
| 16 | −Contact: SeongJae Park <sj@kernel.org> | |
| 16 | +Contact: SJ Park <sj@kernel.org> | |
| 17 | 17 | Description: Writing a number 'N' to this file creates the number of |
| 18 | 18 | directories for controlling each DAMON worker thread (kdamond) |
| 19 | 19 | named '0' to 'N-1' under the kdamonds/ directory. |
| 20 | 20 | |
| 21 | 21 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/state |
| 22 | 22 | Date: Mar 2022 |
| 23 | −Contact: SeongJae Park <sj@kernel.org> | |
| 23 | +Contact: SJ Park <sj@kernel.org> | |
| 24 | 24 | Description: Writing 'on' or 'off' to this file makes the kdamond starts or |
| 25 | 25 | stops, respectively. Reading the file returns the keywords |
| 26 | 26 | based on the current status. Writing 'commit' to this file |
| @@ -40,33 +40,33 @@ Description: Writing 'on' or 'off' to this file makes the kdamond starts or · 13 unmodified lines | ||
| 40 | 40 | |
| 41 | 41 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/pid |
| 42 | 42 | Date: Mar 2022 |
| 43 | −Contact: SeongJae Park <sj@kernel.org> | |
| 43 | +Contact: SJ Park <sj@kernel.org> | |
| 44 | 44 | Description: Reading this file returns the pid of the kdamond if it is |
| 45 | 45 | running. |
| 46 | 46 | |
| 47 | 47 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/refresh_ms |
| 48 | 48 | Date: Jul 2025 |
| 49 | −Contact: SeongJae Park <sj@kernel.org> | |
| 49 | +Contact: SJ Park <sj@kernel.org> | |
| 50 | 50 | Description: Writing a value to this file sets the time interval for |
| 51 | 51 | automatic DAMON status file contents update. Writing '0' |
| 52 | 52 | disables the update. Reading this file returns the value. |
| 53 | 53 | |
| 54 | 54 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/nr_contexts |
| 55 | 55 | Date: Mar 2022 |
| 56 | −Contact: SeongJae Park <sj@kernel.org> | |
| 56 | +Contact: SJ Park <sj@kernel.org> | |
| 57 | 57 | Description: Writing a number 'N' to this file creates the number of |
| 58 | 58 | directories for controlling each DAMON context named '0' to |
| 59 | 59 | 'N-1' under the contexts/ directory. |
| 60 | 60 | |
| 61 | 61 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/avail_operations |
| 62 | 62 | Date: Apr 2022 |
| 63 | −Contact: SeongJae Park <sj@kernel.org> | |
| 63 | +Contact: SJ Park <sj@kernel.org> | |
| 64 | 64 | Description: Reading this file returns the available monitoring operations |
| 65 | 65 | sets on the currently running kernel. |
| 66 | 66 | |
| 67 | 67 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/operations |
| 68 | 68 | Date: Mar 2022 |
| 69 | −Contact: SeongJae Park <sj@kernel.org> | |
| 69 | +Contact: SJ Park <sj@kernel.org> | |
| 70 | 70 | Description: Writing a keyword for a monitoring operations set ('vaddr' for |
| 71 | 71 | virtual address spaces monitoring, 'fvaddr' for fixed virtual |
| 72 | 72 | address ranges monitoring, and 'paddr' for the physical address |
| @@ -79,42 +79,42 @@ Description: Writing a keyword for a monitoring operations set ('vaddr' for · 6 unmodified lines | ||
| 79 | 79 | |
| 80 | 80 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/addr_unit |
| 81 | 81 | Date: Aug 2025 |
| 82 | −Contact: SeongJae Park <sj@kernel.org> | |
| 82 | +Contact: SJ Park <sj@kernel.org> | |
| 83 | 83 | Description: Writing an integer to this file sets the 'address unit' |
| 84 | 84 | parameter of the given operations set of the context. Reading |
| 85 | 85 | the file returns the last-written 'address unit' value. |
| 86 | 86 | |
| 87 | 87 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/pause |
| 88 | 88 | Date: Mar 2026 |
| 89 | −Contact: SeongJae Park <sj@kernel.org> | |
| 89 | +Contact: SJ Park <sj@kernel.org> | |
| 90 | 90 | Description: Writing a boolean keyword to this file sets the 'pause' request |
| 91 | 91 | parameter for the context. Reading the file returns the |
| 92 | 92 | last-written 'pause' value. |
| 93 | 93 | |
| 94 | 94 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/sample_us |
| 95 | 95 | Date: Mar 2022 |
| 96 | −Contact: SeongJae Park <sj@kernel.org> | |
| 96 | +Contact: SJ Park <sj@kernel.org> | |
| 97 | 97 | Description: Writing a value to this file sets the sampling interval of the |
| 98 | 98 | DAMON context in microseconds as the value. Reading this file |
| 99 | 99 | returns the value. |
| 100 | 100 | |
| 101 | 101 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/aggr_us |
| 102 | 102 | Date: Mar 2022 |
| 103 | −Contact: SeongJae Park <sj@kernel.org> | |
| 103 | +Contact: SJ Park <sj@kernel.org> | |
| 104 | 104 | Description: Writing a value to this file sets the aggregation interval of |
| 105 | 105 | the DAMON context in microseconds as the value. Reading this |
| 106 | 106 | file returns the value. |
| 107 | 107 | |
| 108 | 108 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/update_us |
| 109 | 109 | Date: Mar 2022 |
| 110 | −Contact: SeongJae Park <sj@kernel.org> | |
| 110 | +Contact: SJ Park <sj@kernel.org> | |
| 111 | 111 | Description: Writing a value to this file sets the update interval of the |
| 112 | 112 | DAMON context in microseconds as the value. Reading this file |
| 113 | 113 | returns the value. |
| 114 | 114 | |
| 115 | 115 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/access_bp |
| 116 | 116 | Date: Feb 2025 |
| 117 | −Contact: SeongJae Park <sj@kernel.org> | |
| 117 | +Contact: SJ Park <sj@kernel.org> | |
| 118 | 118 | Description: Writing a value to this file sets the monitoring intervals |
| 119 | 119 | auto-tuning target DAMON-observed access events ratio within |
| 120 | 120 | the given time interval (aggrs in same directory), in bp |
| @@ -122,7 +122,7 @@ Description: Writing a value to this file sets the monitoring intervals · 1 unmodified line | ||
| 122 | 122 | |
| 123 | 123 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/aggrs |
| 124 | 124 | Date: Feb 2025 |
| 125 | −Contact: SeongJae Park <sj@kernel.org> | |
| 125 | +Contact: SJ Park <sj@kernel.org> | |
| 126 | 126 | Description: Writing a value to this file sets the time interval to achieve |
| 127 | 127 | the monitoring intervals auto-tuning target DAMON-observed |
| 128 | 128 | access events ratio (access_bp in same directory) within. |
| @@ -130,14 +130,14 @@ Description: Writing a value to this file sets the time interval to achieve · 1 unmodified line | ||
| 130 | 130 | |
| 131 | 131 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/min_sample_us |
| 132 | 132 | Date: Feb 2025 |
| 133 | −Contact: SeongJae Park <sj@kernel.org> | |
| 133 | +Contact: SJ Park <sj@kernel.org> | |
| 134 | 134 | Description: Writing a value to this file sets the minimum value of |
| 135 | 135 | auto-tuned sampling interval in microseconds. Reading this |
| 136 | 136 | file returns the value. |
| 137 | 137 | |
| 138 | 138 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/max_sample_us |
| 139 | 139 | Date: Feb 2025 |
| 140 | −Contact: SeongJae Park <sj@kernel.org> | |
| 140 | +Contact: SJ Park <sj@kernel.org> | |
| 141 | 141 | Description: Writing a value to this file sets the maximum value of |
| 142 | 142 | auto-tuned sampling interval in microseconds. Reading this |
| 143 | 143 | file returns the value. |
| @@ -145,42 +145,42 @@ Description: Writing a value to this file sets the maximum value of · 1 unmodified line | ||
| 145 | 145 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/nr_regions/min |
| 146 | 146 | |
| 147 | 147 | WDate: Mar 2022 |
| 148 | −Contact: SeongJae Park <sj@kernel.org> | |
| 148 | +Contact: SJ Park <sj@kernel.org> | |
| 149 | 149 | Description: Writing a value to this file sets the minimum number of |
| 150 | 150 | monitoring regions of the DAMON context as the value. Reading |
| 151 | 151 | this file returns the value. |
| 152 | 152 | |
| 153 | 153 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/nr_regions/max |
| 154 | 154 | Date: Mar 2022 |
| 155 | −Contact: SeongJae Park <sj@kernel.org> | |
| 155 | +Contact: SJ Park <sj@kernel.org> | |
| 156 | 156 | Description: Writing a value to this file sets the maximum number of |
| 157 | 157 | monitoring regions of the DAMON context as the value. Reading |
| 158 | 158 | this file returns the value. |
| 159 | 159 | |
| 160 | 160 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/targets/nr_targets |
| 161 | 161 | Date: Mar 2022 |
| 162 | −Contact: SeongJae Park <sj@kernel.org> | |
| 162 | +Contact: SJ Park <sj@kernel.org> | |
| 163 | 163 | Description: Writing a number 'N' to this file creates the number of |
| 164 | 164 | directories for controlling each DAMON target of the context |
| 165 | 165 | named '0' to 'N-1' under the contexts/ directory. |
| 166 | 166 | |
| 167 | 167 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/targets/<T>/pid_target |
| 168 | 168 | Date: Mar 2022 |
| 169 | −Contact: SeongJae Park <sj@kernel.org> | |
| 169 | +Contact: SJ Park <sj@kernel.org> | |
| 170 | 170 | Description: Writing to and reading from this file sets and gets the pid of |
| 171 | 171 | the target process if the context is for virtual address spaces |
| 172 | 172 | monitoring, respectively. |
| 173 | 173 | |
| 174 | 174 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/targets/<T>/obsolete_target |
| 175 | 175 | Date: Oct 2025 |
| 176 | −Contact: SeongJae Park <sj@kernel.org> | |
| 176 | +Contact: SJ Park <sj@kernel.org> | |
| 177 | 177 | Description: Writing to and reading from this file sets and gets the |
| 178 | 178 | obsoleteness of the matching parameters commit destination |
| 179 | 179 | target. |
| 180 | 180 | |
| 181 | 181 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/targets/<T>/regions/nr_regions |
| 182 | 182 | Date: Mar 2022 |
| 183 | −Contact: SeongJae Park <sj@kernel.org> | |
| 183 | +Contact: SJ Park <sj@kernel.org> | |
| 184 | 184 | Description: Writing a number 'N' to this file creates the number of |
| 185 | 185 | directories for setting each DAMON target memory region of the |
| 186 | 186 | context named '0' to 'N-1' under the regions/ directory. In |
| @@ -190,181 +190,181 @@ Description: Writing a number 'N' to this file creates the number of · 3 unmodified lines | ||
| 190 | 190 | |
| 191 | 191 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/targets/<T>/regions/<R>/start |
| 192 | 192 | Date: Mar 2022 |
| 193 | −Contact: SeongJae Park <sj@kernel.org> | |
| 193 | +Contact: SJ Park <sj@kernel.org> | |
| 194 | 194 | Description: Writing to and reading from this file sets and gets the start |
| 195 | 195 | address of the monitoring region. |
| 196 | 196 | |
| 197 | 197 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/targets/<T>/regions/<R>/end |
| 198 | 198 | Date: Mar 2022 |
| 199 | −Contact: SeongJae Park <sj@kernel.org> | |
| 199 | +Contact: SJ Park <sj@kernel.org> | |
| 200 | 200 | Description: Writing to and reading from this file sets and gets the end |
| 201 | 201 | address of the monitoring region. |
| 202 | 202 | |
| 203 | 203 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/nr_schemes |
| 204 | 204 | Date: Mar 2022 |
| 205 | −Contact: SeongJae Park <sj@kernel.org> | |
| 205 | +Contact: SJ Park <sj@kernel.org> | |
| 206 | 206 | Description: Writing a number 'N' to this file creates the number of |
| 207 | 207 | directories for controlling each DAMON-based operation scheme |
| 208 | 208 | of the context named '0' to 'N-1' under the schemes/ directory. |
| 209 | 209 | |
| 210 | 210 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/action |
| 211 | 211 | Date: Mar 2022 |
| 212 | −Contact: SeongJae Park <sj@kernel.org> | |
| 212 | +Contact: SJ Park <sj@kernel.org> | |
| 213 | 213 | Description: Writing to and reading from this file sets and gets the action |
| 214 | 214 | of the scheme. |
| 215 | 215 | |
| 216 | 216 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/target_nid |
| 217 | 217 | Date: Jun 2024 |
| 218 | −Contact: SeongJae Park <sj@kernel.org> | |
| 218 | +Contact: SJ Park <sj@kernel.org> | |
| 219 | 219 | Description: Action's target NUMA node id. Supported by only relevant |
| 220 | 220 | actions. |
| 221 | 221 | |
| 222 | 222 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/apply_interval_us |
| 223 | 223 | Date: Sep 2023 |
| 224 | −Contact: SeongJae Park <sj@kernel.org> | |
| 224 | +Contact: SJ Park <sj@kernel.org> | |
| 225 | 225 | Description: Writing a value to this file sets the action apply interval of |
| 226 | 226 | the scheme in microseconds. Reading this file returns the |
| 227 | 227 | value. |
| 228 | 228 | |
| 229 | 229 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/access_pattern/sz/min |
| 230 | 230 | Date: Mar 2022 |
| 231 | −Contact: SeongJae Park <sj@kernel.org> | |
| 231 | +Contact: SJ Park <sj@kernel.org> | |
| 232 | 232 | Description: Writing to and reading from this file sets and gets the minimum |
| 233 | 233 | size of the scheme's target regions in bytes. |
| 234 | 234 | |
| 235 | 235 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/access_pattern/sz/max |
| 236 | 236 | Date: Mar 2022 |
| 237 | −Contact: SeongJae Park <sj@kernel.org> | |
| 237 | +Contact: SJ Park <sj@kernel.org> | |
| 238 | 238 | Description: Writing to and reading from this file sets and gets the maximum |
| 239 | 239 | size of the scheme's target regions in bytes. |
| 240 | 240 | |
| 241 | 241 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/access_pattern/nr_accesses/min |
| 242 | 242 | Date: Mar 2022 |
| 243 | −Contact: SeongJae Park <sj@kernel.org> | |
| 243 | +Contact: SJ Park <sj@kernel.org> | |
| 244 | 244 | Description: Writing to and reading from this file sets and gets the manimum |
| 245 | 245 | 'nr_accesses' of the scheme's target regions. |
| 246 | 246 | |
| 247 | 247 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/access_pattern/nr_accesses/max |
| 248 | 248 | Date: Mar 2022 |
| 249 | −Contact: SeongJae Park <sj@kernel.org> | |
| 249 | +Contact: SJ Park <sj@kernel.org> | |
| 250 | 250 | Description: Writing to and reading from this file sets and gets the maximum |
| 251 | 251 | 'nr_accesses' of the scheme's target regions. |
| 252 | 252 | |
| 253 | 253 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/access_pattern/age/min |
| 254 | 254 | Date: Mar 2022 |
| 255 | −Contact: SeongJae Park <sj@kernel.org> | |
| 255 | +Contact: SJ Park <sj@kernel.org> | |
| 256 | 256 | Description: Writing to and reading from this file sets and gets the minimum |
| 257 | 257 | 'age' of the scheme's target regions. |
| 258 | 258 | |
| 259 | 259 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/access_pattern/age/max |
| 260 | 260 | Date: Mar 2022 |
| 261 | −Contact: SeongJae Park <sj@kernel.org> | |
| 261 | +Contact: SJ Park <sj@kernel.org> | |
| 262 | 262 | Description: Writing to and reading from this file sets and gets the maximum |
| 263 | 263 | 'age' of the scheme's target regions. |
| 264 | 264 | |
| 265 | 265 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/ms |
| 266 | 266 | Date: Mar 2022 |
| 267 | −Contact: SeongJae Park <sj@kernel.org> | |
| 267 | +Contact: SJ Park <sj@kernel.org> | |
| 268 | 268 | Description: Writing to and reading from this file sets and gets the time |
| 269 | 269 | quota of the scheme in milliseconds. |
| 270 | 270 | |
| 271 | 271 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/bytes |
| 272 | 272 | Date: Mar 2022 |
| 273 | −Contact: SeongJae Park <sj@kernel.org> | |
| 273 | +Contact: SJ Park <sj@kernel.org> | |
| 274 | 274 | Description: Writing to and reading from this file sets and gets the size |
| 275 | 275 | quota of the scheme in bytes. |
| 276 | 276 | |
| 277 | 277 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/effective_bytes |
| 278 | 278 | Date: Feb 2024 |
| 279 | −Contact: SeongJae Park <sj@kernel.org> | |
| 279 | +Contact: SJ Park <sj@kernel.org> | |
| 280 | 280 | Description: Reading from this file gets the effective size quota of the |
| 281 | 281 | scheme in bytes, which adjusted for the time quota and goals. |
| 282 | 282 | |
| 283 | 283 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/reset_interval_ms |
| 284 | 284 | Date: Mar 2022 |
| 285 | −Contact: SeongJae Park <sj@kernel.org> | |
| 285 | +Contact: SJ Park <sj@kernel.org> | |
| 286 | 286 | Description: Writing to and reading from this file sets and gets the quotas |
| 287 | 287 | charge reset interval of the scheme in milliseconds. |
| 288 | 288 | |
| 289 | 289 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/goals/nr_goals |
| 290 | 290 | Date: Nov 2023 |
| 291 | −Contact: SeongJae Park <sj@kernel.org> | |
| 291 | +Contact: SJ Park <sj@kernel.org> | |
| 292 | 292 | Description: Writing a number 'N' to this file creates the number of |
| 293 | 293 | directories for setting automatic tuning of the scheme's |
| 294 | 294 | aggressiveness named '0' to 'N-1' under the goals/ directory. |
| 295 | 295 | |
| 296 | 296 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/goals/<G>/target_metric |
| 297 | 297 | Date: Feb 2024 |
| 298 | −Contact: SeongJae Park <sj@kernel.org> | |
| 298 | +Contact: SJ Park <sj@kernel.org> | |
| 299 | 299 | Description: Writing to and reading from this file sets and gets the quota |
| 300 | 300 | auto-tuning goal metric. |
| 301 | 301 | |
| 302 | 302 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/goals/<G>/target_value |
| 303 | 303 | Date: Nov 2023 |
| 304 | −Contact: SeongJae Park <sj@kernel.org> | |
| 304 | +Contact: SJ Park <sj@kernel.org> | |
| 305 | 305 | Description: Writing to and reading from this file sets and gets the target |
| 306 | 306 | value of the goal metric. |
| 307 | 307 | |
| 308 | 308 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/goals/<G>/current_value |
| 309 | 309 | Date: Nov 2023 |
| 310 | −Contact: SeongJae Park <sj@kernel.org> | |
| 310 | +Contact: SJ Park <sj@kernel.org> | |
| 311 | 311 | Description: Writing to and reading from this file sets and gets the current |
| 312 | 312 | value of the goal metric. |
| 313 | 313 | |
| 314 | 314 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/goals/<G>/nid |
| 315 | 315 | Date: Apr 2025 |
| 316 | −Contact: SeongJae Park <sj@kernel.org> | |
| 316 | +Contact: SJ Park <sj@kernel.org> | |
| 317 | 317 | Description: Writing to and reading from this file sets and gets the nid |
| 318 | 318 | parameter of the goal. |
| 319 | 319 | |
| 320 | 320 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/goals/<G>/path |
| 321 | 321 | Date: Oct 2025 |
| 322 | −Contact: SeongJae Park <sj@kernel.org> | |
| 322 | +Contact: SJ Park <sj@kernel.org> | |
| 323 | 323 | Description: Writing to and reading from this file sets and gets the path |
| 324 | 324 | parameter of the goal. |
| 325 | 325 | |
| 326 | 326 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/goal_tuner |
| 327 | 327 | Date: Mar 2026 |
| 328 | −Contact: SeongJae Park <sj@kernel.org> | |
| 328 | +Contact: SJ Park <sj@kernel.org> | |
| 329 | 329 | Description: Writing to and reading from this file sets and gets the |
| 330 | 330 | goal-based effective quota auto-tuning algorithm to use. |
| 331 | 331 | |
| 332 | 332 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/fail_charge_num |
| 333 | 333 | Date: Mar 2026 |
| 334 | −Contact: SeongJae Park <sj@kernel.org> | |
| 334 | +Contact: SJ Park <sj@kernel.org> | |
| 335 | 335 | Description: Writing to and reading from this file sets and gets the |
| 336 | 336 | action-failed memory quota charging ratio numerator. |
| 337 | 337 | |
| 338 | 338 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/fail_charge_denom |
| 339 | 339 | Date: Mar 2026 |
| 340 | −Contact: SeongJae Park <sj@kernel.org> | |
| 340 | +Contact: SJ Park <sj@kernel.org> | |
| 341 | 341 | Description: Writing to and reading from this file sets and gets the |
| 342 | 342 | action-failed memory quota charging ratio denominator. |
| 343 | 343 | |
| 344 | 344 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/weights/sz_permil |
| 345 | 345 | Date: Mar 2022 |
| 346 | −Contact: SeongJae Park <sj@kernel.org> | |
| 346 | +Contact: SJ Park <sj@kernel.org> | |
| 347 | 347 | Description: Writing to and reading from this file sets and gets the |
| 348 | 348 | under-quota limit regions prioritization weight for 'size' in |
| 349 | 349 | permil. |
| 350 | 350 | |
| 351 | 351 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/weights/nr_accesses_permil |
| 352 | 352 | Date: Mar 2022 |
| 353 | −Contact: SeongJae Park <sj@kernel.org> | |
| 353 | +Contact: SJ Park <sj@kernel.org> | |
| 354 | 354 | Description: Writing to and reading from this file sets and gets the |
| 355 | 355 | under-quota limit regions prioritization weight for |
| 356 | 356 | 'nr_accesses' in permil. |
| 357 | 357 | |
| 358 | 358 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/weights/age_permil |
| 359 | 359 | Date: Mar 2022 |
| 360 | −Contact: SeongJae Park <sj@kernel.org> | |
| 360 | +Contact: SJ Park <sj@kernel.org> | |
| 361 | 361 | Description: Writing to and reading from this file sets and gets the |
| 362 | 362 | under-quota limit regions prioritization weight for 'age' in |
| 363 | 363 | permil. |
| 364 | 364 | |
| 365 | 365 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/watermarks/metric |
| 366 | 366 | Date: Mar 2022 |
| 367 | −Contact: SeongJae Park <sj@kernel.org> | |
| 367 | +Contact: SJ Park <sj@kernel.org> | |
| 368 | 368 | Description: Writing to and reading from this file sets and gets the metric |
| 369 | 369 | of the watermarks for the scheme. The writable/readable |
| 370 | 370 | keywords for this file are 'none' for disabling the watermarks |
| @@ -373,44 +373,44 @@ Description: Writing to and reading from this file sets and gets the metric · 2 unmodified lines | ||
| 373 | 373 | |
| 374 | 374 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/watermarks/interval_us |
| 375 | 375 | Date: Mar 2022 |
| 376 | −Contact: SeongJae Park <sj@kernel.org> | |
| 376 | +Contact: SJ Park <sj@kernel.org> | |
| 377 | 377 | Description: Writing to and reading from this file sets and gets the metric |
| 378 | 378 | check interval of the watermarks for the scheme in |
| 379 | 379 | microseconds. |
| 380 | 380 | |
| 381 | 381 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/watermarks/high |
| 382 | 382 | Date: Mar 2022 |
| 383 | −Contact: SeongJae Park <sj@kernel.org> | |
| 383 | +Contact: SJ Park <sj@kernel.org> | |
| 384 | 384 | Description: Writing to and reading from this file sets and gets the high |
| 385 | 385 | watermark of the scheme in permil. |
| 386 | 386 | |
| 387 | 387 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/watermarks/mid |
| 388 | 388 | Date: Mar 2022 |
| 389 | −Contact: SeongJae Park <sj@kernel.org> | |
| 389 | +Contact: SJ Park <sj@kernel.org> | |
| 390 | 390 | Description: Writing to and reading from this file sets and gets the mid |
| 391 | 391 | watermark of the scheme in permil. |
| 392 | 392 | |
| 393 | 393 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/watermarks/low |
| 394 | 394 | Date: Mar 2022 |
| 395 | −Contact: SeongJae Park <sj@kernel.org> | |
| 395 | +Contact: SJ Park <sj@kernel.org> | |
| 396 | 396 | Description: Writing to and reading from this file sets and gets the low |
| 397 | 397 | watermark of the scheme in permil. |
| 398 | 398 | |
| 399 | 399 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/core_filters |
| 400 | 400 | Date: Feb 2025 |
| 401 | −Contact: SeongJae Park <sj@kernel.org> | |
| 401 | +Contact: SJ Park <sj@kernel.org> | |
| 402 | 402 | Description: Directory for DAMON core layer-handled DAMOS filters. |
| 403 | 403 | |
| 404 | 404 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/core_filters/nr_filters |
| 405 | 405 | Date: Feb 2025 |
| 406 | −Contact: SeongJae Park <sj@kernel.org> | |
| 406 | +Contact: SJ Park <sj@kernel.org> | |
| 407 | 407 | Description: Writing a number 'N' to this file creates the number of |
| 408 | 408 | directories for setting filters of the scheme named '0' to |
| 409 | 409 | 'N-1' under the core_filters/ directory. |
| 410 | 410 | |
| 411 | 411 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/core_filters/<F>/type |
| 412 | 412 | Date: Feb 2025 |
| 413 | −Contact: SeongJae Park <sj@kernel.org> | |
| 413 | +Contact: SJ Park <sj@kernel.org> | |
| 414 | 414 | Description: Writing to and reading from this file sets and gets the type of |
| 415 | 415 | the memory of the interest. 'anon' for anonymous pages, |
| 416 | 416 | 'memcg' for specific memory cgroup, 'young' for young pages, |
| @@ -419,62 +419,62 @@ Description: Writing to and reading from this file sets and gets the type of · 2 unmodified lines | ||
| 419 | 419 | |
| 420 | 420 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/core_filters/<F>/memcg_path |
| 421 | 421 | Date: Feb 2025 |
| 422 | −Contact: SeongJae Park <sj@kernel.org> | |
| 422 | +Contact: SJ Park <sj@kernel.org> | |
| 423 | 423 | Description: If 'memcg' is written to the 'type' file, writing to and |
| 424 | 424 | reading from this file sets and gets the path to the memory |
| 425 | 425 | cgroup of the interest. |
| 426 | 426 | |
| 427 | 427 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/core_filters/<F>/addr_start |
| 428 | 428 | Date: Feb 2025 |
| 429 | −Contact: SeongJae Park <sj@kernel.org> | |
| 429 | +Contact: SJ Park <sj@kernel.org> | |
| 430 | 430 | Description: If 'addr' is written to the 'type' file, writing to or reading |
| 431 | 431 | from this file sets or gets the start address of the address |
| 432 | 432 | range for the filter. |
| 433 | 433 | |
| 434 | 434 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/core_filters/<F>/addr_end |
| 435 | 435 | Date: Feb 2025 |
| 436 | −Contact: SeongJae Park <sj@kernel.org> | |
| 436 | +Contact: SJ Park <sj@kernel.org> | |
| 437 | 437 | Description: If 'addr' is written to the 'type' file, writing to or reading |
| 438 | 438 | from this file sets or gets the end address of the address |
| 439 | 439 | range for the filter. |
| 440 | 440 | |
| 441 | 441 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/core_filters/<F>/min |
| 442 | 442 | Date: Feb 2025 |
| 443 | −Contact: SeongJae Park <sj@kernel.org> | |
| 443 | +Contact: SJ Park <sj@kernel.org> | |
| 444 | 444 | Description: If 'hugepage_size' is written to the 'type' file, writing to |
| 445 | 445 | or reading from this file sets or gets the minimum size of the |
| 446 | 446 | hugepage for the filter. |
| 447 | 447 | |
| 448 | 448 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/core_filters/<F>/max |
| 449 | 449 | Date: Feb 2025 |
| 450 | −Contact: SeongJae Park <sj@kernel.org> | |
| 450 | +Contact: SJ Park <sj@kernel.org> | |
| 451 | 451 | Description: If 'hugepage_size' is written to the 'type' file, writing to |
| 452 | 452 | or reading from this file sets or gets the maximum size of the |
| 453 | 453 | hugepage for the filter. |
| 454 | 454 | |
| 455 | 455 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/core_filters/<F>/damon_target_idx |
| 456 | 456 | Date: Feb 2025 |
| 457 | −Contact: SeongJae Park <sj@kernel.org> | |
| 457 | +Contact: SJ Park <sj@kernel.org> | |
| 458 | 458 | Description: If 'target' is written to the 'type' file, writing to or |
| 459 | 459 | reading from this file sets or gets the index of the DAMON |
| 460 | 460 | monitoring target of the interest. |
| 461 | 461 | |
| 462 | 462 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/core_filters/<F>/matching |
| 463 | 463 | Date: Feb 2025 |
| 464 | −Contact: SeongJae Park <sj@kernel.org> | |
| 464 | +Contact: SJ Park <sj@kernel.org> | |
| 465 | 465 | Description: Writing 'Y' or 'N' to this file sets whether the filter is for |
| 466 | 466 | the memory of the 'type', or all except the 'type'. |
| 467 | 467 | |
| 468 | 468 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/core_filters/<F>/allow |
| 469 | 469 | Date: Feb 2025 |
| 470 | −Contact: SeongJae Park <sj@kernel.org> | |
| 470 | +Contact: SJ Park <sj@kernel.org> | |
| 471 | 471 | Description: Writing 'Y' or 'N' to this file sets whether to allow or reject |
| 472 | 472 | applying the scheme's action to the memory that satisfies the |
| 473 | 473 | 'type' and the 'matching' of the directory. |
| 474 | 474 | |
| 475 | 475 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/ops_filters |
| 476 | 476 | Date: Feb 2025 |
| 477 | −Contact: SeongJae Park <sj@kernel.org> | |
| 477 | +Contact: SJ Park <sj@kernel.org> | |
| 478 | 478 | Description: Directory for DAMON operations set layer-handled DAMOS filters. |
| 479 | 479 | Files under this directory works same to those of |
| 480 | 480 | /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/core_filters |
| @@ -482,7 +482,7 @@ Description: Directory for DAMON operations set layer-handled DAMOS filters. · 1 unmodified line | ||
| 482 | 482 | |
| 483 | 483 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/filters |
| 484 | 484 | Date: Dec 2022 |
| 485 | −Contact: SeongJae Park <sj@kernel.org> | |
| 485 | +Contact: SJ Park <sj@kernel.org> | |
| 486 | 486 | Description: Directory for DAMOS filters. Files under this directory works |
| 487 | 487 | same to those of |
| 488 | 488 | /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/{core,ops}_filters |
| @@ -491,14 +491,14 @@ Description: Directory for DAMOS filters. Files under this directory works · 2 unmodified lines | ||
| 491 | 491 | |
| 492 | 492 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/dests/nr_dests |
| 493 | 493 | Date: Jul 2025 |
| 494 | −Contact: SeongJae Park <sj@kernel.org> | |
| 494 | +Contact: SJ Park <sj@kernel.org> | |
| 495 | 495 | Description: Writing a number 'N' to this file creates the number of |
| 496 | 496 | directories for setting action destinations of the scheme named |
| 497 | 497 | '0' to 'N-1' under the dests/ directory. |
| 498 | 498 | |
| 499 | 499 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/dests/<D>/id |
| 500 | 500 | Date: Jul 2025 |
| 501 | −Contact: SeongJae Park <sj@kernel.org> | |
| 501 | +Contact: SJ Park <sj@kernel.org> | |
| 502 | 502 | Description: Writing to and reading from this file sets and gets the id of |
| 503 | 503 | the DAMOS action destination. For DAMOS_MIGRATE_{HOT,COLD} |
| 504 | 504 | actions, the destination node's node id can be written and |
| @@ -506,98 +506,98 @@ Description: Writing to and reading from this file sets and gets the id of · 1 unmodified line | ||
| 506 | 506 | |
| 507 | 507 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/dests/<D>/weight |
| 508 | 508 | Date: Jul 2025 |
| 509 | −Contact: SeongJae Park <sj@kernel.org> | |
| 509 | +Contact: SJ Park <sj@kernel.org> | |
| 510 | 510 | Description: Writing to and reading from this file sets and gets the weight |
| 511 | 511 | of the DAMOS action destination to select as the destination of |
| 512 | 512 | each action among the destinations. |
| 513 | 513 | |
| 514 | 514 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/stats/nr_tried |
| 515 | 515 | Date: Mar 2022 |
| 516 | −Contact: SeongJae Park <sj@kernel.org> | |
| 516 | +Contact: SJ Park <sj@kernel.org> | |
| 517 | 517 | Description: Reading this file returns the number of regions that the action |
| 518 | 518 | of the scheme has tried to be applied. |
| 519 | 519 | |
| 520 | 520 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/stats/sz_tried |
| 521 | 521 | Date: Mar 2022 |
| 522 | −Contact: SeongJae Park <sj@kernel.org> | |
| 522 | +Contact: SJ Park <sj@kernel.org> | |
| 523 | 523 | Description: Reading this file returns the total size of regions that the |
| 524 | 524 | action of the scheme has tried to be applied in bytes. |
| 525 | 525 | |
| 526 | 526 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/stats/nr_applied |
| 527 | 527 | Date: Mar 2022 |
| 528 | −Contact: SeongJae Park <sj@kernel.org> | |
| 528 | +Contact: SJ Park <sj@kernel.org> | |
| 529 | 529 | Description: Reading this file returns the number of regions that the action |
| 530 | 530 | of the scheme has successfully applied. |
| 531 | 531 | |
| 532 | 532 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/stats/sz_applied |
| 533 | 533 | Date: Mar 2022 |
| 534 | −Contact: SeongJae Park <sj@kernel.org> | |
| 534 | +Contact: SJ Park <sj@kernel.org> | |
| 535 | 535 | Description: Reading this file returns the total size of regions that the |
| 536 | 536 | action of the scheme has successfully applied in bytes. |
| 537 | 537 | |
| 538 | 538 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/stats/sz_ops_filter_passed |
| 539 | 539 | Date: Dec 2024 |
| 540 | −Contact: SeongJae Park <sj@kernel.org> | |
| 540 | +Contact: SJ Park <sj@kernel.org> | |
| 541 | 541 | Description: Reading this file returns the total size of memory that passed |
| 542 | 542 | DAMON operations layer-handled filters of the scheme in bytes. |
| 543 | 543 | |
| 544 | 544 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/stats/qt_exceeds |
| 545 | 545 | Date: Mar 2022 |
| 546 | −Contact: SeongJae Park <sj@kernel.org> | |
| 546 | +Contact: SJ Park <sj@kernel.org> | |
| 547 | 547 | Description: Reading this file returns the number of the exceed events of |
| 548 | 548 | the scheme's quotas. |
| 549 | 549 | |
| 550 | 550 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/stats/nr_snapshots |
| 551 | 551 | Date: Dec 2025 |
| 552 | −Contact: SeongJae Park <sj@kernel.org> | |
| 552 | +Contact: SJ Park <sj@kernel.org> | |
| 553 | 553 | Description: Reading this file returns the total number of DAMON snapshots |
| 554 | 554 | that the scheme has tried to be applied. |
| 555 | 555 | |
| 556 | 556 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/stats/max_nr_snapshots |
| 557 | 557 | Date: Dec 2025 |
| 558 | −Contact: SeongJae Park <sj@kernel.org> | |
| 558 | +Contact: SJ Park <sj@kernel.org> | |
| 559 | 559 | Description: Writing a number to this file sets the upper limit of |
| 560 | 560 | nr_snapshots that deactivates the scheme when the limit is |
| 561 | 561 | reached or exceeded. |
| 562 | 562 | |
| 563 | 563 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/tried_regions/total_bytes |
| 564 | 564 | Date: Jul 2023 |
| 565 | −Contact: SeongJae Park <sj@kernel.org> | |
| 565 | +Contact: SJ Park <sj@kernel.org> | |
| 566 | 566 | Description: Reading this file returns the total amount of memory that |
| 567 | 567 | corresponding DAMON-based Operation Scheme's action has tried |
| 568 | 568 | to be applied. |
| 569 | 569 | |
| 570 | 570 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/tried_regions/<R>/start |
| 571 | 571 | Date: Oct 2022 |
| 572 | −Contact: SeongJae Park <sj@kernel.org> | |
| 572 | +Contact: SJ Park <sj@kernel.org> | |
| 573 | 573 | Description: Reading this file returns the start address of a memory region |
| 574 | 574 | that corresponding DAMON-based Operation Scheme's action has |
| 575 | 575 | tried to be applied. |
| 576 | 576 | |
| 577 | 577 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/tried_regions/<R>/end |
| 578 | 578 | Date: Oct 2022 |
| 579 | −Contact: SeongJae Park <sj@kernel.org> | |
| 579 | +Contact: SJ Park <sj@kernel.org> | |
| 580 | 580 | Description: Reading this file returns the end address of a memory region |
| 581 | 581 | that corresponding DAMON-based Operation Scheme's action has |
| 582 | 582 | tried to be applied. |
| 583 | 583 | |
| 584 | 584 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/tried_regions/<R>/nr_accesses |
| 585 | 585 | Date: Oct 2022 |
| 586 | −Contact: SeongJae Park <sj@kernel.org> | |
| 586 | +Contact: SJ Park <sj@kernel.org> | |
| 587 | 587 | Description: Reading this file returns the 'nr_accesses' of a memory region |
| 588 | 588 | that corresponding DAMON-based Operation Scheme's action has |
| 589 | 589 | tried to be applied. |
| 590 | 590 | |
| 591 | 591 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/tried_regions/<R>/age |
| 592 | 592 | Date: Oct 2022 |
| 593 | −Contact: SeongJae Park <sj@kernel.org> | |
| 593 | +Contact: SJ Park <sj@kernel.org> | |
| 594 | 594 | Description: Reading this file returns the 'age' of a memory region that |
| 595 | 595 | corresponding DAMON-based Operation Scheme's action has tried |
| 596 | 596 | to be applied. |
| 597 | 597 | |
| 598 | 598 | What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/tried_regions/<R>/sz_filter_passed |
| 599 | 599 | Date: Dec 2024 |
| 600 | −Contact: SeongJae Park <sj@kernel.org> | |
| 600 | +Contact: SJ Park <sj@kernel.org> | |
| 601 | 601 | Description: Reading this file returns the size of the memory in the region |
| 602 | 602 | that passed DAMON operations layer-handled filters of the |
| 603 | 603 | scheme in bytes. |
| @@ -135,7 +135,6 @@ properties: · 134 unmodified lines | ||
| 135 | 135 | required: |
| 136 | 136 | - compatible |
| 137 | 137 | - reg |
| 138 | − - interrupts | |
| 139 | 138 | |
| 140 | 139 | unevaluatedProperties: false |
| 141 | 140 | |
| @@ -24,7 +24,11 @@ allOf: · 23 unmodified lines | ||
| 24 | 24 | |
| 25 | 25 | properties: |
| 26 | 26 | compatible: |
| 27 | − const: spacemit,k1-spi | |
| 27 | + oneOf: | |
| 28 | + - const: spacemit,k1-spi | |
| 29 | + - items: | |
| 30 | + - const: spacemit,k3-spi | |
| 31 | + - const: spacemit,k1-spi | |
| 28 | 32 | |
| 29 | 33 | reg: |
| 30 | 34 | maxItems: 1 |
| @@ -1585,31 +1585,31 @@ attribute-sets: · 1584 unmodified lines | ||
| 1585 | 1585 | type: u32 |
| 1586 | 1586 | - |
| 1587 | 1587 | name: mode |
| 1588 | − type: flag | |
| 1588 | + type: u8 | |
| 1589 | 1589 | - |
| 1590 | 1590 | name: guard |
| 1591 | − type: flag | |
| 1591 | + type: u8 | |
| 1592 | 1592 | - |
| 1593 | 1593 | name: protect |
| 1594 | − type: flag | |
| 1594 | + type: u8 | |
| 1595 | 1595 | - |
| 1596 | 1596 | name: fast-leave |
| 1597 | − type: flag | |
| 1597 | + type: u8 | |
| 1598 | 1598 | - |
| 1599 | 1599 | name: learning |
| 1600 | − type: flag | |
| 1600 | + type: u8 | |
| 1601 | 1601 | - |
| 1602 | 1602 | name: unicast-flood |
| 1603 | − type: flag | |
| 1603 | + type: u8 | |
| 1604 | 1604 | - |
| 1605 | 1605 | name: proxyarp |
| 1606 | − type: flag | |
| 1606 | + type: u8 | |
| 1607 | 1607 | - |
| 1608 | 1608 | name: learning-sync |
| 1609 | − type: flag | |
| 1609 | + type: u8 | |
| 1610 | 1610 | - |
| 1611 | 1611 | name: proxyarp-wifi |
| 1612 | − type: flag | |
| 1612 | + type: u8 | |
| 1613 | 1613 | - |
| 1614 | 1614 | name: root-id |
| 1615 | 1615 | type: binary |
| @@ -1656,34 +1656,34 @@ attribute-sets: · 40 unmodified lines | ||
| 1656 | 1656 | type: pad |
| 1657 | 1657 | - |
| 1658 | 1658 | name: mcast-flood |
| 1659 | − type: flag | |
| 1659 | + type: u8 | |
| 1660 | 1660 | - |
| 1661 | 1661 | name: mcast-to-ucast |
| 1662 | − type: flag | |
| 1662 | + type: u8 | |
| 1663 | 1663 | - |
| 1664 | 1664 | name: vlan-tunnel |
| 1665 | − type: flag | |
| 1665 | + type: u8 | |
| 1666 | 1666 | - |
| 1667 | 1667 | name: bcast-flood |
| 1668 | − type: flag | |
| 1668 | + type: u8 | |
| 1669 | 1669 | - |
| 1670 | 1670 | name: group-fwd-mask |
| 1671 | 1671 | type: u16 |
| 1672 | 1672 | - |
| 1673 | 1673 | name: neigh-suppress |
| 1674 | − type: flag | |
| 1674 | + type: u8 | |
| 1675 | 1675 | - |
| 1676 | 1676 | name: isolated |
| 1677 | − type: flag | |
| 1677 | + type: u8 | |
| 1678 | 1678 | - |
| 1679 | 1679 | name: backup-port |
| 1680 | 1680 | type: u32 |
| 1681 | 1681 | - |
| 1682 | 1682 | name: mrp-ring-open |
| 1683 | − type: flag | |
| 1683 | + type: u8 | |
| 1684 | 1684 | - |
| 1685 | 1685 | name: mrp-in-open |
| 1686 | − type: flag | |
| 1686 | + type: u8 | |
| 1687 | 1687 | - |
| 1688 | 1688 | name: mcast-eht-hosts-limit |
| 1689 | 1689 | type: u32 |
| @@ -1692,10 +1692,10 @@ attribute-sets: · 2 unmodified lines | ||
| 1692 | 1692 | type: u32 |
| 1693 | 1693 | - |
| 1694 | 1694 | name: locked |
| 1695 | − type: flag | |
| 1695 | + type: u8 | |
| 1696 | 1696 | - |
| 1697 | 1697 | name: mab |
| 1698 | − type: flag | |
| 1698 | + type: u8 | |
| 1699 | 1699 | - |
| 1700 | 1700 | name: mcast-n-groups |
| 1701 | 1701 | type: u32 |
| @@ -1704,7 +1704,7 @@ attribute-sets: · 2 unmodified lines | ||
| 1704 | 1704 | type: u32 |
| 1705 | 1705 | - |
| 1706 | 1706 | name: neigh-vlan-suppress |
| 1707 | − type: flag | |
| 1707 | + type: u8 | |
| 1708 | 1708 | - |
| 1709 | 1709 | name: backup-nhid |
| 1710 | 1710 | type: u32 |
| @@ -59,7 +59,7 @@ advantechwdt: · 58 unmodified lines | ||
| 59 | 59 | |
| 60 | 60 | alim1535_wdt: |
| 61 | 61 | timeout: |
| 62 | − Watchdog timeout in seconds. (0 < timeout < 18000, default=60 | |
| 62 | + Watchdog timeout in seconds. (0 < timeout < 18000, default=60) | |
| 63 | 63 | nowayout: |
| 64 | 64 | Watchdog cannot be stopped once started |
| 65 | 65 | (default=kernel config parameter) |
| @@ -68,7 +68,7 @@ alim1535_wdt: · 2 unmodified lines | ||
| 68 | 68 | |
| 69 | 69 | alim7101_wdt: |
| 70 | 70 | timeout: |
| 71 | − Watchdog timeout in seconds. (1<=timeout<=3600, default=30 | |
| 71 | + Watchdog timeout in seconds. (1<=timeout<=3600, default=30) | |
| 72 | 72 | use_gpio: |
| 73 | 73 | Use the gpio watchdog (required by old cobalt boards). |
| 74 | 74 | default=0/off/no |
| @@ -6478,7 +6478,7 @@ L: linux-cifs@vger.kernel.org · 6477 unmodified lines | ||
| 6478 | 6478 | L: samba-technical@lists.samba.org (moderated for non-subscribers) |
| 6479 | 6479 | S: Supported |
| 6480 | 6480 | W: https://wiki.samba.org/index.php/LinuxCIFS |
| 6481 | −T: git https://git.samba.org/sfrench/cifs-2.6.git | |
| 6481 | +T: git https://git.samba.org/sfrench/cifs-2.6.git for-next | |
| 6482 | 6482 | F: Documentation/admin-guide/cifs/ |
| 6483 | 6483 | F: fs/smb/client/ |
| 6484 | 6484 | F: fs/smb/common/ |
| @@ -7125,7 +7125,7 @@ W: https://docs.dasharo.com/ · 640 unmodified lines | ||
| 7125 | 7125 | F: drivers/platform/x86/dasharo-acpi.c |
| 7126 | 7126 | |
| 7127 | 7127 | DAMON |
| 7128 | −M: SeongJae Park <sj@kernel.org> | |
| 7128 | +M: SJ Park <sj@kernel.org> | |
| 7129 | 7129 | L: damon@lists.linux.dev |
| 7130 | 7130 | L: linux-mm@kvack.org |
| 7131 | 7131 | S: Maintained |
| @@ -11108,6 +11108,7 @@ F: drivers/platform/x86/gpd-pocket-fan.c · 3976 unmodified lines | ||
| 11108 | 11108 | |
| 11109 | 11109 | GPIB DRIVERS |
| 11110 | 11110 | M: Dave Penkler <dpenkler@gmail.com> |
| 11111 | +M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
| 11111 | 11112 | S: Maintained |
| 11112 | 11113 | F: drivers/gpib/ |
| 11113 | 11114 | F: include/uapi/linux/gpib.h |
| @@ -14142,7 +14143,7 @@ R: Sergey Senozhatsky <senozhatsky@chromium.org> · 3028 unmodified lines | ||
| 14142 | 14143 | R: Tom Talpey <tom@talpey.com> |
| 14143 | 14144 | L: linux-cifs@vger.kernel.org |
| 14144 | 14145 | S: Maintained |
| 14145 | −T: git https://git.samba.org/ksmbd.git | |
| 14146 | +T: git https://git.samba.org/ksmbd.git ksmbd-for-next | |
| 14146 | 14147 | F: Documentation/filesystems/smb/ksmbd.rst |
| 14147 | 14148 | F: fs/smb/common/ |
| 14148 | 14149 | F: fs/smb/server/ |
| @@ -17257,6 +17258,7 @@ R: Ryan Roberts <ryan.roberts@arm.com> · 3108 unmodified lines | ||
| 17257 | 17258 | R: Dev Jain <dev.jain@arm.com> |
| 17258 | 17259 | R: Barry Song <baohua@kernel.org> |
| 17259 | 17260 | R: Lance Yang <lance.yang@linux.dev> |
| 17261 | +R: Usama Arif <usama.arif@linux.dev> | |
| 17260 | 17262 | L: linux-mm@kvack.org |
| 17261 | 17263 | S: Maintained |
| 17262 | 17264 | W: http://www.linux-mm.org |
| @@ -19108,6 +19110,7 @@ F: drivers/nfc/ · 1845 unmodified lines | ||
| 19108 | 19110 | F: include/net/nfc/ |
| 19109 | 19111 | F: include/uapi/linux/nfc.h |
| 19110 | 19112 | F: net/nfc/ |
| 19113 | +F: tools/testing/selftests/nci/ | |
| 19111 | 19114 | |
| 19112 | 19115 | NFC VIRTUAL NCI DEVICE DRIVER |
| 19113 | 19116 | M: Bongsu Jeon <bongsu.jeon@samsung.com> |
| @@ -19299,7 +19302,7 @@ F: fs/ntfs3/ · 185 unmodified lines | ||
| 19299 | 19302 | |
| 19300 | 19303 | NTSYNC SYNCHRONIZATION PRIMITIVE DRIVER |
| 19301 | 19304 | M: Elizabeth Figura <zfigura@codeweavers.com> |
| 19302 | −L: wine-devel@winehq.org | |
| 19305 | +L: wine-devel@list.winehq.org | |
| 19303 | 19306 | S: Supported |
| 19304 | 19307 | F: Documentation/userspace-api/ntsync.rst |
| 19305 | 19308 | F: drivers/misc/ntsync.c |
| @@ -25972,8 +25975,9 @@ F: Documentation/devicetree/bindings/phy/st,stm32mp25-combophy.yaml · 6666 unmodified lines | ||
| 25972 | 25975 | F: drivers/phy/st/phy-stm32-combophy.c |
| 25973 | 25976 | |
| 25974 | 25977 | STMMAC ETHERNET DRIVER |
| 25978 | +M: Maxime Chevallier <maxime.chevallier@bootlin.com> | |
| 25975 | 25979 | L: netdev@vger.kernel.org |
| 25976 | −S: Orphan | |
| 25980 | +S: Maintained | |
| 25977 | 25981 | F: Documentation/networking/device_drivers/ethernet/stmicro/ |
| 25978 | 25982 | F: drivers/net/ethernet/stmicro/stmmac/ |
| 25979 | 25983 | |
| @@ -27929,7 +27933,6 @@ F: drivers/usb/isp1760/* · 1949 unmodified lines | ||
| 27929 | 27933 | |
| 27930 | 27934 | USB LAN78XX ETHERNET DRIVER |
| 27931 | 27935 | M: Thangaraj Samynathan <Thangaraj.S@microchip.com> |
| 27932 | −M: Rengarajan Sundararajan <Rengarajan.S@microchip.com> | |
| 27933 | 27936 | M: UNGLinuxDriver@microchip.com |
| 27934 | 27937 | L: netdev@vger.kernel.org |
| 27935 | 27938 | S: Maintained |
| @@ -29398,7 +29401,7 @@ F: net/xdp/ · 1462 unmodified lines | ||
| 29398 | 29401 | F: tools/testing/selftests/bpf/*xsk* |
| 29399 | 29402 | |
| 29400 | 29403 | XEN BLOCK SUBSYSTEM |
| 29401 | −M: Roger Pau Monné <roger.pau@citrix.com> | |
| 29404 | +M: Roger Pau Monné <roger@xenproject.org> | |
| 29402 | 29405 | L: xen-devel@lists.xenproject.org (moderated for non-subscribers) |
| 29403 | 29406 | S: Supported |
| 29404 | 29407 | F: drivers/block/xen* |
| @@ -2,7 +2,7 @@ · 1 unmodified line | ||
| 2 | 2 | VERSION = 7 |
| 3 | 3 | PATCHLEVEL = 2 |
| 4 | 4 | SUBLEVEL = 0 |
| 5 | −EXTRAVERSION = -rc4 | |
| 5 | +EXTRAVERSION = -rc5 | |
| 6 | 6 | NAME = Baby Opossum Posse |
| 7 | 7 | |
| 8 | 8 | # *DOCUMENTATION* |
| @@ -475,6 +475,10 @@ KBUILD_USERLDFLAGS := $(USERLDFLAGS) · 466 unmodified lines | ||
| 475 | 475 | |
| 476 | 476 | # These flags apply to all Rust code in the tree, including the kernel and |
| 477 | 477 | # host programs. |
| 478 | +# | |
| 479 | +# `-Aclippy::unwrap_or_default`: the lint is buggy [1] and ignores our | |
| 480 | +# MSRV. It can trigger depending on the optimization level. | |
| 481 | +# [1] https://github.com/rust-lang/rust-clippy/issues/17379 | |
| 478 | 482 | export rust_common_flags := --edition=2021 \ |
| 479 | 483 | -Zbinary_dep_depinfo=y \ |
| 480 | 484 | -Astable_features \ |
| @@ -503,6 +507,7 @@ export rust_common_flags := --edition=2021 \ · 22 unmodified lines | ||
| 503 | 507 | -Aclippy::uninlined_format_args \ |
| 504 | 508 | -Wclippy::unnecessary_safety_comment \ |
| 505 | 509 | -Wclippy::unnecessary_safety_doc \ |
| 510 | + -Aclippy::unwrap_or_default \ | |
| 506 | 511 | -Wrustdoc::missing_crate_level_docs \ |
| 507 | 512 | -Wrustdoc::unescaped_backticks |
| 508 | 513 | |
| @@ -131,7 +131,7 @@ · 130 unmodified lines | ||
| 131 | 131 | * Annoyingly, the negative levels for Address size faults aren't laid out |
| 132 | 132 | * contiguously (or in the desired order) |
| 133 | 133 | */ |
| 134 | −#define ESR_ELx_FSC_ADDRSZ_nL(n) ((n) == -1 ? 0x25 : 0x2C) | |
| 134 | +#define ESR_ELx_FSC_ADDRSZ_nL(n) ((n) == -1 ? 0x29 : 0x2C) | |
| 135 | 135 | #define ESR_ELx_FSC_ADDRSZ_L(n) ((n) < 0 ? ESR_ELx_FSC_ADDRSZ_nL(n) : \ |
| 136 | 136 | (ESR_ELx_FSC_ADDRSZ + (n))) |
| 137 | 137 | |
| @@ -78,8 +78,12 @@ enum fixed_addresses { · 77 unmodified lines | ||
| 78 | 78 | /* |
| 79 | 79 | * Temporary boot-time mappings, used by early_ioremap(), |
| 80 | 80 | * before ioremap() is functional. |
| 81 | + * | |
| 82 | + * Reserve one extra page so a 256K mapping may start at any | |
| 83 | + * offset within a page. early_ioremap() maps the page-aligned | |
| 84 | + * physical range, so the initial offset can consume an extra page. | |
| 81 | 85 | */ |
| 82 | −#define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE) | |
| 86 | +#define NR_FIX_BTMAPS ((SZ_256K / PAGE_SIZE) + 1) | |
| 83 | 87 | #define FIX_BTMAPS_SLOTS 7 |
| 84 | 88 | #define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) |
| 85 | 89 | |
| @@ -26,6 +26,12 @@ · 25 unmodified lines | ||
| 26 | 26 | struct prev_kprobe { |
| 27 | 27 | struct kprobe *kp; |
| 28 | 28 | unsigned int status; |
| 29 | + | |
| 30 | + /* | |
| 31 | + * The original DAIF state of the outer kprobe, saved here before | |
| 32 | + * a nested kprobe overwrites kcb->saved_irqflag during reentry. | |
| 33 | + */ | |
| 34 | + unsigned long saved_irqflag; | |
| 29 | 35 | }; |
| 30 | 36 | |
| 31 | 37 | /* per-cpu kprobe control block */ |
| @@ -174,12 +174,27 @@ static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb) · 173 unmodified lines | ||
| 174 | 174 | { |
| 175 | 175 | kcb->prev_kprobe.kp = kprobe_running(); |
| 176 | 176 | kcb->prev_kprobe.status = kcb->kprobe_status; |
| 177 | + | |
| 178 | + /* | |
| 179 | + * Save the outer kprobe's original DAIF flags before the nested | |
| 180 | + * kprobe calls kprobes_save_local_irqflag() and overwrites | |
| 181 | + * kcb->saved_irqflag. Without this, the outer kprobe will restore | |
| 182 | + * the wrong DAIF state and leave interrupts permanently masked. | |
| 183 | + */ | |
| 184 | + kcb->prev_kprobe.saved_irqflag = kcb->saved_irqflag; | |
| 177 | 185 | } |
| 178 | 186 | |
| 179 | 187 | static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb) |
| 180 | 188 | { |
| 181 | 189 | __this_cpu_write(current_kprobe, kcb->prev_kprobe.kp); |
| 182 | 190 | kcb->kprobe_status = kcb->prev_kprobe.status; |
| 191 | + | |
| 192 | + /* | |
| 193 | + * Restore the outer kprobe's saved_irqflag so that when its | |
| 194 | + * single-step completes, kprobes_restore_local_irqflag() uses | |
| 195 | + * the correct original DAIF value. | |
| 196 | + */ | |
| 197 | + kcb->saved_irqflag = kcb->prev_kprobe.saved_irqflag; | |
| 183 | 198 | } |
| 184 | 199 | |
| 185 | 200 | static void __kprobes set_current_kprobe(struct kprobe *p) |
| @@ -240,10 +255,16 @@ static int __kprobes reenter_kprobe(struct kprobe *p, · 54 unmodified lines | ||
| 240 | 255 | switch (kcb->kprobe_status) { |
| 241 | 256 | case KPROBE_HIT_SSDONE: |
| 242 | 257 | case KPROBE_HIT_ACTIVE: |
| 258 | + case KPROBE_HIT_SS: | |
| 259 | + /* | |
| 260 | + * A probe can be hit while another kprobe is preparing or | |
| 261 | + * executing its XOL single-step instruction. This is still a | |
| 262 | + * recoverable one-level reentry, so handle it in the same way as | |
| 263 | + * reentry from KPROBE_HIT_ACTIVE or KPROBE_HIT_SSDONE. | |
| 264 | + */ | |
| 243 | 265 | kprobes_inc_nmissed_count(p); |
| 244 | 266 | setup_singlestep(p, regs, kcb, 1); |
| 245 | 267 | break; |
| 246 | − case KPROBE_HIT_SS: | |
| 247 | 268 | case KPROBE_REENTER: |
| 248 | 269 | pr_warn("Failed to recover from reentered kprobes.\n"); |
| 249 | 270 | dump_kprobe(p); |
| @@ -282,9 +303,31 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr) · 32 unmodified lines | ||
| 282 | 303 | struct kprobe *cur = kprobe_running(); |
| 283 | 304 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); |
| 284 | 305 | |
| 306 | + /* | |
| 307 | + * Simulated kprobes execute in the debug trap context and have no | |
| 308 | + * XOL slot. Any page fault taken while a simulated kprobe is in | |
| 309 | + * progress cannot have been caused by kprobe single-stepping and | |
| 310 | + * must be left alone for the normal page fault handler, including | |
| 311 | + * fixup_exception. | |
| 312 | + */ | |
| 313 | + if (cur && !cur->ainsn.xol_insn) | |
| 314 | + return 0; | |
| 315 | + | |
| 285 | 316 | switch (kcb->kprobe_status) { |
| 286 | 317 | case KPROBE_HIT_SS: |
| 287 | 318 | case KPROBE_REENTER: |
| 319 | + /* | |
| 320 | + * A page fault taken while in KPROBE_HIT_SS or | |
| 321 | + * KPROBE_REENTER state is only attributable to kprobe | |
| 322 | + * single-stepping if the faulting PC points to the | |
| 323 | + * current kprobe's XOL instruction. If the fault occurred | |
| 324 | + * elsewhere (e.g. in perf or tracing code invoked from the | |
| 325 | + * debug exception path), leave it for the normal page fault | |
| 326 | + * handler to process. | |
| 327 | + */ | |
| 328 | + if (instruction_pointer(regs) != (unsigned long)cur->ainsn.xol_insn) | |
| 329 | + break; | |
| 330 | + | |
| 288 | 331 | /* |
| 289 | 332 | * We are here because the instruction being single |
| 290 | 333 | * stepped caused a page fault. We reset the current |
| @@ -76,6 +76,8 @@ static void data_abort_decode(unsigned long esr) · 75 unmodified lines | ||
| 76 | 76 | pr_alert(" SF = %lu, AR = %lu\n", |
| 77 | 77 | (esr & ESR_ELx_SF) >> ESR_ELx_SF_SHIFT, |
| 78 | 78 | (esr & ESR_ELx_AR) >> ESR_ELx_AR_SHIFT); |
| 79 | + pr_alert(" Xs = %llu\n", | |
| 80 | + (iss2 & ESR_ELx_Xs_MASK) >> ESR_ELx_Xs_SHIFT); | |
| 79 | 81 | } else { |
| 80 | 82 | pr_alert(" ISV = 0, ISS = 0x%08lx, ISS2 = 0x%08lx\n", |
| 81 | 83 | esr & ESR_ELx_ISS_MASK, iss2); |
| @@ -87,11 +89,10 @@ static void data_abort_decode(unsigned long esr) · 5 unmodified lines | ||
| 87 | 89 | (iss2 & ESR_ELx_TnD) >> ESR_ELx_TnD_SHIFT, |
| 88 | 90 | (iss2 & ESR_ELx_TagAccess) >> ESR_ELx_TagAccess_SHIFT); |
| 89 | 91 | |
| 90 | − pr_alert(" GCS = %ld, Overlay = %lu, DirtyBit = %lu, Xs = %llu\n", | |
| 92 | + pr_alert(" GCS = %ld, Overlay = %lu, DirtyBit = %lu\n", | |
| 91 | 93 | (iss2 & ESR_ELx_GCS) >> ESR_ELx_GCS_SHIFT, |
| 92 | 94 | (iss2 & ESR_ELx_Overlay) >> ESR_ELx_Overlay_SHIFT, |
| 93 | − (iss2 & ESR_ELx_DirtyBit) >> ESR_ELx_DirtyBit_SHIFT, | |
| 94 | − (iss2 & ESR_ELx_Xs_MASK) >> ESR_ELx_Xs_SHIFT); | |
| 95 | + (iss2 & ESR_ELx_DirtyBit) >> ESR_ELx_DirtyBit_SHIFT); | |
| 95 | 96 | } |
| 96 | 97 | |
| 97 | 98 | static void mem_abort_decode(unsigned long esr) |
| @@ -87,7 +87,7 @@ static int find_num_contig(struct mm_struct *mm, unsigned long addr, · 86 unmodified lines | ||
| 87 | 87 | p4dp = p4d_offset(pgdp, addr); |
| 88 | 88 | pudp = pud_offset(p4dp, addr); |
| 89 | 89 | pmdp = pmd_offset(pudp, addr); |
| 90 | − if ((pte_t *)pmdp == ptep) { | |
| 90 | + if ((pte_t *)PTR_ALIGN_DOWN(pmdp, sizeof(*pmdp) * CONT_PMDS) == ptep) { | |
| 91 | 91 | *pgsize = PMD_SIZE; |
| 92 | 92 | return CONT_PMDS; |
| 93 | 93 | } |
| @@ -2194,7 +2194,7 @@ static int prevent_memory_remove_notifier(struct notifier_block *nb, · 2193 unmodified lines | ||
| 2194 | 2194 | } |
| 2195 | 2195 | } |
| 2196 | 2196 | |
| 2197 | − if (!can_unmap_without_split(pfn, arg->nr_pages)) | |
| 2197 | + if (!can_unmap_without_split(arg->start_pfn, arg->nr_pages)) | |
| 2198 | 2198 | return NOTIFY_BAD; |
| 2199 | 2199 | |
| 2200 | 2200 | return NOTIFY_OK; |
| @@ -14,7 +14,7 @@ · 13 unmodified lines | ||
| 14 | 14 | #ifdef CONFIG_64BIT |
| 15 | 15 | #define TASK_STRUCT_OFFSET 0 |
| 16 | 16 | #else |
| 17 | −#define TASK_STRUCT_OFFSET 2000 | |
| 17 | +#define TASK_STRUCT_OFFSET 2040 | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | .macro cpu_save_nonscratch thread |
| @@ -201,10 +201,12 @@ static void __init acpi_process_madt(void) · 200 unmodified lines | ||
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | int pptt_enabled; |
| 204 | +static int acpi_nr_packages; | |
| 205 | +static int acpi_package_ids[MAX_PACKAGES]; | |
| 204 | 206 | |
| 205 | 207 | int __init parse_acpi_topology(void) |
| 206 | 208 | { |
| 207 | − int cpu, topology_id; | |
| 209 | + int i, cpu, topology_id; | |
| 208 | 210 | |
| 209 | 211 | for_each_possible_cpu(cpu) { |
| 210 | 212 | topology_id = find_acpi_cpu_topology(cpu, 0); |
| @@ -222,6 +224,29 @@ int __init parse_acpi_topology(void) · 11 unmodified lines | ||
| 222 | 224 | |
| 223 | 225 | cpu_data[cpu].core = topology_id; |
| 224 | 226 | } |
| 227 | + | |
| 228 | + topology_id = find_acpi_cpu_topology_package(cpu); | |
| 229 | + if (topology_id < 0) { | |
| 230 | + pr_warn("Invalid BIOS PPTT\n"); | |
| 231 | + return -ENOENT; | |
| 232 | + } | |
| 233 | + | |
| 234 | + for (i = 0; i < acpi_nr_packages; i++) | |
| 235 | + if (acpi_package_ids[i] == topology_id) | |
| 236 | + break; | |
| 237 | + | |
| 238 | + if (i == acpi_nr_packages) | |
| 239 | + acpi_package_ids[acpi_nr_packages++] = topology_id; | |
| 240 | + | |
| 241 | + cpu_data[cpu].package = topology_id; | |
| 242 | + } | |
| 243 | + | |
| 244 | + for_each_possible_cpu(cpu) { | |
| 245 | + for (i = 0; i < acpi_nr_packages; i++) | |
| 246 | + if (cpu_data[cpu].package == acpi_package_ids[i]) { | |
| 247 | + cpu_data[cpu].package = i; /* Canonicalize */ | |
| 248 | + break; | |
| 249 | + } | |
| 225 | 250 | } |
| 226 | 251 | |
| 227 | 252 | pptt_enabled = 1; |
| @@ -252,7 +252,8 @@ static int kgdb_loongarch_notify(struct notifier_block *self, unsigned long cmd, · 251 unmodified lines | ||
| 252 | 252 | if (atomic_read(&kgdb_active) != -1) |
| 253 | 253 | kgdb_nmicallback(smp_processor_id(), regs); |
| 254 | 254 | |
| 255 | − if (kgdb_handle_exception(args->trapnr, args->signr, cmd, regs)) | |
| 255 | + if (kgdb_handle_exception(regs->csr_era == stepped_address ? 0 : args->trapnr, | |
| 256 | + args->signr, cmd, regs)) | |
| 256 | 257 | return NOTIFY_DONE; |
| 257 | 258 | |
| 258 | 259 | if (atomic_read(&kgdb_setting_breakpoint)) |
| @@ -42,6 +42,7 @@ static unsigned long first_ind_entry; · 41 unmodified lines | ||
| 42 | 42 | int machine_kexec_prepare(struct kimage *kimage) |
| 43 | 43 | { |
| 44 | 44 | int i; |
| 45 | + char head[8]; | |
| 45 | 46 | char *bootloader = "kexec"; |
| 46 | 47 | void *cmdline_ptr = (void *)KEXEC_CMDLINE_ADDR; |
| 47 | 48 | |
| @@ -59,7 +60,9 @@ int machine_kexec_prepare(struct kimage *kimage) · 11 unmodified lines | ||
| 59 | 60 | } else { |
| 60 | 61 | /* Find the command line */ |
| 61 | 62 | for (i = 0; i < kimage->nr_segments; i++) { |
| 62 | − if (!strncmp(bootloader, (char __user *)kimage->segment[i].buf, strlen(bootloader))) { | |
| 63 | + if (copy_from_user(head, kimage->segment[i].buf, strlen(bootloader))) | |
| 64 | + continue; | |
| 65 | + if (!strncmp(bootloader, head, strlen(bootloader))) { | |
| 63 | 66 | if (!copy_from_user(cmdline_ptr, kimage->segment[i].buf, COMMAND_LINE_SIZE)) |
| 64 | 67 | kimage->arch.cmdline_ptr = (unsigned long)cmdline_ptr; |
| 65 | 68 | break; |
| @@ -71,27 +71,27 @@ · 70 unmodified lines | ||
| 71 | 71 | cfi_ld s7, PT_R30 |
| 72 | 72 | cfi_ld s8, PT_R31 |
| 73 | 73 | LONG_L t0, sp, PT_CRMD |
| 74 | − li.d t1, 0x7 /* mask bit[1:0] PLV, bit[2] IE */ | |
| 74 | + LONG_LI t1, 0x7 /* mask bit[1:0] PLV, bit[2] IE */ | |
| 75 | 75 | csrxchg t0, t1, LOONGARCH_CSR_CRMD |
| 76 | 76 | .endm |
| 77 | 77 | |
| 78 | 78 | SYM_CODE_START(arch_rethook_trampoline) |
| 79 | 79 | UNWIND_HINT_UNDEFINED |
| 80 | − addi.d sp, sp, -PT_SIZE | |
| 80 | + PTR_ADDI sp, sp, -PT_SIZE | |
| 81 | 81 | save_all_base_regs |
| 82 | 82 | |
| 83 | − addi.d t0, sp, PT_SIZE | |
| 84 | − LONG_S t0, sp, PT_R3 | |
| 83 | + PTR_ADDI t0, sp, PT_SIZE | |
| 84 | + LONG_S t0, sp, PT_R3 | |
| 85 | 85 | |
| 86 | − move a0, sp /* pt_regs */ | |
| 86 | + move a0, sp /* pt_regs */ | |
| 87 | 87 | |
| 88 | − bl arch_rethook_trampoline_callback | |
| 88 | + bl arch_rethook_trampoline_callback | |
| 89 | 89 | |
| 90 | 90 | /* use the result as the return-address */ |
| 91 | − move ra, a0 | |
| 91 | + move ra, a0 | |
| 92 | 92 | |
| 93 | 93 | restore_all_base_regs |
| 94 | − addi.d sp, sp, PT_SIZE | |
| 94 | + PTR_ADDI sp, sp, PT_SIZE | |
| 95 | 95 | |
| 96 | − jr ra | |
| 96 | + jr ra | |
| 97 | 97 | SYM_CODE_END(arch_rethook_trampoline) |
| @@ -603,6 +603,7 @@ void __init setup_arch(char **cmdline_p) · 602 unmodified lines | ||
| 603 | 603 | memblock_init(); |
| 604 | 604 | pagetable_init(); |
| 605 | 605 | bootcmdline_init(cmdline_p); |
| 606 | + jump_label_init(); /* Initialise the static keys for early params */ | |
| 606 | 607 | parse_early_param(); |
| 607 | 608 | reserve_initrd_mem(); |
| 608 | 609 | |
| @@ -610,8 +611,6 @@ void __init setup_arch(char **cmdline_p) · 1 unmodified line | ||
| 610 | 611 | arch_mem_init(cmdline_p); |
| 611 | 612 | |
| 612 | 613 | resource_init(); |
| 613 | − jump_label_init(); /* Initialise the static keys for paravirtualization */ | |
| 614 | − | |
| 615 | 614 | #ifdef CONFIG_SMP |
| 616 | 615 | plat_smp_setup(); |
| 617 | 616 | prefill_possible_map(); |
| @@ -426,10 +426,10 @@ void loongson_init_secondary(void) · 425 unmodified lines | ||
| 426 | 426 | numa_add_cpu(cpu); |
| 427 | 427 | #endif |
| 428 | 428 | per_cpu(cpu_state, cpu) = CPU_ONLINE; |
| 429 | − cpu_data[cpu].package = | |
| 430 | − cpu_logical_map(cpu) / loongson_sysconf.cores_per_package; | |
| 431 | 429 | cpu_data[cpu].core = pptt_enabled ? cpu_data[cpu].core : |
| 432 | 430 | cpu_logical_map(cpu) % loongson_sysconf.cores_per_package; |
| 431 | + cpu_data[cpu].package = pptt_enabled ? cpu_data[cpu].package : | |
| 432 | + cpu_logical_map(cpu) / loongson_sysconf.cores_per_package; | |
| 433 | 433 | cpu_data[cpu].global_id = cpu_logical_map(cpu); |
| 434 | 434 | } |
| 435 | 435 | |
| @@ -835,7 +835,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext · 834 unmodified lines | ||
| 835 | 835 | move_reg(ctx, t1, src); |
| 836 | 836 | emit_sext_32(ctx, t1, is32); |
| 837 | 837 | emit_insn(ctx, divd, dst, dst, t1); |
| 838 | − emit_sext_32(ctx, dst, is32); | |
| 838 | + emit_zext_32(ctx, dst, is32); | |
| 839 | 839 | } |
| 840 | 840 | break; |
| 841 | 841 | |
| @@ -852,7 +852,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext · 10 unmodified lines | ||
| 852 | 852 | emit_sext_32(ctx, t1, is32); |
| 853 | 853 | emit_sext_32(ctx, dst, is32); |
| 854 | 854 | emit_insn(ctx, divd, dst, dst, t1); |
| 855 | − emit_sext_32(ctx, dst, is32); | |
| 855 | + emit_zext_32(ctx, dst, is32); | |
| 856 | 856 | } |
| 857 | 857 | break; |
| 858 | 858 | |
| @@ -870,7 +870,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext · 11 unmodified lines | ||
| 870 | 870 | move_reg(ctx, t1, src); |
| 871 | 871 | emit_sext_32(ctx, t1, is32); |
| 872 | 872 | emit_insn(ctx, modd, dst, dst, t1); |
| 873 | − emit_sext_32(ctx, dst, is32); | |
| 873 | + emit_zext_32(ctx, dst, is32); | |
| 874 | 874 | } |
| 875 | 875 | break; |
| 876 | 876 | |
| @@ -887,7 +887,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext · 10 unmodified lines | ||
| 887 | 887 | emit_sext_32(ctx, t1, is32); |
| 888 | 888 | emit_sext_32(ctx, dst, is32); |
| 889 | 889 | emit_insn(ctx, modd, dst, dst, t1); |
| 890 | − emit_sext_32(ctx, dst, is32); | |
| 890 | + emit_zext_32(ctx, dst, is32); | |
| 891 | 891 | } |
| 892 | 892 | break; |
| 893 | 893 | |
| @@ -2361,6 +2361,7 @@ void bpf_jit_free(struct bpf_prog *prog) · 1467 unmodified lines | ||
| 2361 | 2361 | */ |
| 2362 | 2362 | if (jit_data) { |
| 2363 | 2363 | bpf_jit_binary_pack_finalize(jit_data->ro_header, jit_data->header); |
| 2364 | + kvfree(jit_data->ctx.offset); | |
| 2364 | 2365 | kfree(jit_data); |
| 2365 | 2366 | } |
| 2366 | 2367 | hdr = bpf_jit_binary_pack_hdr(prog); |
| @@ -110,7 +110,7 @@ void wildfiremod_halt(void) · 109 unmodified lines | ||
| 110 | 110 | printk(KERN_INFO "WildFireMod hibernating...\n"); |
| 111 | 111 | |
| 112 | 112 | /* Set portE.5 to Digital IO */ |
| 113 | − mcf_write16(read16(MCFGPIO_PEPAR) & ~(1 << (5 * 2)), MCFGPIO_PEPAR); | |
| 113 | + mcf_write16(mcf_read16(MCFGPIO_PEPAR) & ~(1 << (5 * 2)), MCFGPIO_PEPAR); | |
| 114 | 114 | |
| 115 | 115 | /* Make portE.5 an output */ |
| 116 | 116 | mcf_write8(mcf_read8(MCFGPIO_PDDR_E) | (1 << 5), MCFGPIO_PDDR_E); |
| @@ -55,10 +55,12 @@ static inline void clear_page(void *page) · 54 unmodified lines | ||
| 55 | 55 | #define clear_user_page(addr, vaddr, page) \ |
| 56 | 56 | do { clear_page(addr); \ |
| 57 | 57 | flush_dcache_page(page); \ |
| 58 | + (void)(vaddr); \ | |
| 58 | 59 | } while (0) |
| 59 | 60 | #define copy_user_page(to, from, vaddr, page) \ |
| 60 | 61 | do { copy_page(to, from); \ |
| 61 | 62 | flush_dcache_page(page); \ |
| 63 | + (void)(vaddr); \ | |
| 62 | 64 | } while (0) |
| 63 | 65 | |
| 64 | 66 | extern unsigned long m68k_memoffset; |
| @@ -209,13 +209,13 @@ struct kvm_vcpu_arch { · 208 unmodified lines | ||
| 209 | 209 | /* |
| 210 | 210 | * VCPU interrupts |
| 211 | 211 | * |
| 212 | − * We have a lockless approach for tracking pending VCPU interrupts | |
| 213 | − * implemented using atomic bitops. The irqs_pending bitmap represent | |
| 214 | − * pending interrupts whereas irqs_pending_mask represent bits changed | |
| 215 | − * in irqs_pending. Our approach is modeled around multiple producer | |
| 216 | − * and single consumer problem where the consumer is the VCPU itself. | |
| 212 | + * The irqs_pending bitmap represents pending interrupts whereas | |
| 213 | + * irqs_pending_mask represents bits changed in irqs_pending. Updates | |
| 214 | + * to these bitmaps are serialized so vcpu interrupt sync/flush cannot | |
| 215 | + * drop a newly injected interrupt while syncing guest-visible HVIP. | |
| 217 | 216 | */ |
| 218 | 217 | #define KVM_RISCV_VCPU_NR_IRQS 64 |
| 218 | + raw_spinlock_t irqs_pending_lock; | |
| 219 | 219 | DECLARE_BITMAP(irqs_pending, KVM_RISCV_VCPU_NR_IRQS); |
| 220 | 220 | DECLARE_BITMAP(irqs_pending_mask, KVM_RISCV_VCPU_NR_IRQS); |
| 221 | 221 | |
| @@ -53,12 +53,15 @@ void kvm_riscv_vcpu_aia_flush_interrupts(struct kvm_vcpu *vcpu) · 52 unmodified lines | ||
| 53 | 53 | struct kvm_vcpu_aia_csr *csr = &vcpu->arch.aia_context.guest_csr; |
| 54 | 54 | unsigned long mask, val; |
| 55 | 55 | |
| 56 | + lockdep_assert_held(&vcpu->arch.irqs_pending_lock); | |
| 57 | + | |
| 56 | 58 | if (!kvm_riscv_aia_available()) |
| 57 | 59 | return; |
| 58 | 60 | |
| 59 | − if (READ_ONCE(vcpu->arch.irqs_pending_mask[1])) { | |
| 60 | − mask = xchg_acquire(&vcpu->arch.irqs_pending_mask[1], 0); | |
| 61 | − val = READ_ONCE(vcpu->arch.irqs_pending[1]) & mask; | |
| 61 | + mask = vcpu->arch.irqs_pending_mask[1]; | |
| 62 | + if (mask) { | |
| 63 | + vcpu->arch.irqs_pending_mask[1] = 0; | |
| 64 | + val = vcpu->arch.irqs_pending[1] & mask; | |
| 62 | 65 | |
| 63 | 66 | csr->hviph &= ~mask; |
| 64 | 67 | csr->hviph |= val; |
| @@ -69,6 +72,8 @@ void kvm_riscv_vcpu_aia_sync_interrupts(struct kvm_vcpu *vcpu) · 4 unmodified lines | ||
| 69 | 72 | { |
| 70 | 73 | struct kvm_vcpu_aia_csr *csr = &vcpu->arch.aia_context.guest_csr; |
| 71 | 74 | |
| 75 | + lockdep_assert_held(&vcpu->arch.irqs_pending_lock); | |
| 76 | + | |
| 72 | 77 | if (kvm_riscv_aia_available()) |
| 73 | 78 | csr->vsieh = ncsr_read(CSR_VSIEH); |
| 74 | 79 | } |
| @@ -77,13 +82,22 @@ void kvm_riscv_vcpu_aia_sync_interrupts(struct kvm_vcpu *vcpu) · 2 unmodified lines | ||
| 77 | 82 | bool kvm_riscv_vcpu_aia_has_interrupts(struct kvm_vcpu *vcpu, u64 mask) |
| 78 | 83 | { |
| 79 | 84 | unsigned long seip; |
| 85 | +#ifdef CONFIG_32BIT | |
| 86 | + unsigned long flags; | |
| 87 | + bool pending; | |
| 88 | +#endif | |
| 80 | 89 | |
| 81 | 90 | if (!kvm_riscv_aia_available()) |
| 82 | 91 | return false; |
| 83 | 92 | |
| 84 | 93 | #ifdef CONFIG_32BIT |
| 85 | − if (READ_ONCE(vcpu->arch.irqs_pending[1]) & | |
| 86 | − (vcpu->arch.aia_context.guest_csr.vsieh & upper_32_bits(mask))) | |
| 94 | + raw_spin_lock_irqsave(&vcpu->arch.irqs_pending_lock, flags); | |
| 95 | + pending = vcpu->arch.irqs_pending[1] & | |
| 96 | + (vcpu->arch.aia_context.guest_csr.vsieh & | |
| 97 | + upper_32_bits(mask)); | |
| 98 | + raw_spin_unlock_irqrestore(&vcpu->arch.irqs_pending_lock, flags); | |
| 99 | + | |
| 100 | + if (pending) | |
| 87 | 101 | return true; |
| 88 | 102 | #endif |
| 89 | 103 | |
| @@ -207,6 +221,9 @@ int kvm_riscv_vcpu_aia_set_csr(struct kvm_vcpu *vcpu, · 117 unmodified lines | ||
| 207 | 221 | { |
| 208 | 222 | struct kvm_vcpu_aia_csr *csr = &vcpu->arch.aia_context.guest_csr; |
| 209 | 223 | unsigned long regs_max = sizeof(struct kvm_riscv_aia_csr) / sizeof(unsigned long); |
| 224 | +#ifdef CONFIG_32BIT | |
| 225 | + unsigned long flags; | |
| 226 | +#endif | |
| 210 | 227 | |
| 211 | 228 | if (!riscv_isa_extension_available(vcpu->arch.isa, SSAIA)) |
| 212 | 229 | return -ENOENT; |
| @@ -219,8 +236,12 @@ int kvm_riscv_vcpu_aia_set_csr(struct kvm_vcpu *vcpu, · 6 unmodified lines | ||
| 219 | 236 | ((unsigned long *)csr)[reg_num] = val; |
| 220 | 237 | |
| 221 | 238 | #ifdef CONFIG_32BIT |
| 222 | − if (reg_num == KVM_REG_RISCV_CSR_AIA_REG(siph)) | |
| 223 | − WRITE_ONCE(vcpu->arch.irqs_pending_mask[1], 0); | |
| 239 | + if (reg_num == KVM_REG_RISCV_CSR_AIA_REG(siph)) { | |
| 240 | + raw_spin_lock_irqsave(&vcpu->arch.irqs_pending_lock, flags); | |
| 241 | + vcpu->arch.irqs_pending_mask[1] = 0; | |
| 242 | + raw_spin_unlock_irqrestore(&vcpu->arch.irqs_pending_lock, | |
| 243 | + flags); | |
| 244 | + } | |
| 224 | 245 | #endif |
| 225 | 246 | } |
| 226 | 247 | |
| @@ -5,11 +5,13 @@ · 4 unmodified lines | ||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | #include <linux/bitops.h> |
| 8 | +#include <linux/cpufeature.h> | |
| 8 | 9 | #include <linux/errno.h> |
| 9 | 10 | #include <linux/kvm_host.h> |
| 10 | 11 | #include <linux/module.h> |
| 11 | 12 | #include <linux/pgtable.h> |
| 12 | 13 | #include <asm/kvm_gstage.h> |
| 14 | +#include <asm/hwcap.h> | |
| 13 | 15 | |
| 14 | 16 | #ifdef CONFIG_64BIT |
| 15 | 17 | unsigned long kvm_riscv_gstage_max_pgd_levels __ro_after_init = 3; |
| @@ -171,8 +173,10 @@ int kvm_riscv_gstage_set_pte(struct kvm_gstage *gstage, · 155 unmodified lines | ||
| 171 | 173 | } |
| 172 | 174 | |
| 173 | 175 | if (pte_val(*ptep) != pte_val(map->pte)) { |
| 176 | + bool was_invalid = !pte_val(*ptep); | |
| 174 | 177 | set_pte(ptep, map->pte); |
| 175 | − if (gstage_pte_leaf(ptep)) | |
| 178 | + if (gstage_pte_leaf(ptep) && | |
| 179 | + !(was_invalid && riscv_has_extension_unlikely(RISCV_ISA_EXT_SVVPTC))) | |
| 176 | 180 | gstage_tlb_flush(gstage, current_level, map->addr); |
| 177 | 181 | } |
| 178 | 182 | |
| @@ -41,6 +41,7 @@ int kvm_riscv_mmu_ioremap(struct kvm *kvm, gpa_t gpa, phys_addr_t hpa, · 40 unmodified lines | ||
| 41 | 41 | pgprot_t prot; |
| 42 | 42 | unsigned long pfn; |
| 43 | 43 | phys_addr_t addr, end; |
| 44 | + unsigned long pgd_levels = kvm->arch.pgd_levels; | |
| 44 | 45 | struct kvm_mmu_memory_cache pcache = { |
| 45 | 46 | .gfp_custom = (in_atomic) ? GFP_ATOMIC | __GFP_ACCOUNT : 0, |
| 46 | 47 | .gfp_zero = __GFP_ZERO, |
| @@ -63,7 +64,7 @@ int kvm_riscv_mmu_ioremap(struct kvm *kvm, gpa_t gpa, phys_addr_t hpa, · 16 unmodified lines | ||
| 63 | 64 | if (!writable) |
| 64 | 65 | map.pte = pte_wrprotect(map.pte); |
| 65 | 66 | |
| 66 | − ret = kvm_mmu_topup_memory_cache(&pcache, kvm->arch.pgd_levels); | |
| 67 | + ret = __kvm_mmu_topup_memory_cache(&pcache, pgd_levels, pgd_levels); | |
| 67 | 68 | if (ret) |
| 68 | 69 | goto out; |
| 69 | 70 | |
| @@ -80,6 +80,7 @@ static void kvm_riscv_vcpu_context_reset(struct kvm_vcpu *vcpu, · 79 unmodified lines | ||
| 80 | 80 | |
| 81 | 81 | static void kvm_riscv_reset_vcpu(struct kvm_vcpu *vcpu, bool kvm_sbi_reset) |
| 82 | 82 | { |
| 83 | + unsigned long flags; | |
| 83 | 84 | bool loaded; |
| 84 | 85 | |
| 85 | 86 | /** |
| @@ -104,8 +105,10 @@ static void kvm_riscv_reset_vcpu(struct kvm_vcpu *vcpu, bool kvm_sbi_reset) · 18 unmodified lines | ||
| 104 | 105 | |
| 105 | 106 | kvm_riscv_vcpu_aia_reset(vcpu); |
| 106 | 107 | |
| 108 | + raw_spin_lock_irqsave(&vcpu->arch.irqs_pending_lock, flags); | |
| 107 | 109 | bitmap_zero(vcpu->arch.irqs_pending, KVM_RISCV_VCPU_NR_IRQS); |
| 108 | 110 | bitmap_zero(vcpu->arch.irqs_pending_mask, KVM_RISCV_VCPU_NR_IRQS); |
| 111 | + raw_spin_unlock_irqrestore(&vcpu->arch.irqs_pending_lock, flags); | |
| 109 | 112 | |
| 110 | 113 | kvm_riscv_vcpu_pmu_reset(vcpu); |
| 111 | 114 | |
| @@ -151,6 +154,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) · 39 unmodified lines | ||
| 151 | 154 | |
| 152 | 155 | /* Setup VCPU hfence queue */ |
| 153 | 156 | spin_lock_init(&vcpu->arch.hfence_lock); |
| 157 | + raw_spin_lock_init(&vcpu->arch.irqs_pending_lock); | |
| 154 | 158 | |
| 155 | 159 | spin_lock_init(&vcpu->arch.reset_state.lock); |
| 156 | 160 | |
| @@ -352,10 +356,14 @@ void kvm_riscv_vcpu_flush_interrupts(struct kvm_vcpu *vcpu) · 195 unmodified lines | ||
| 352 | 356 | { |
| 353 | 357 | struct kvm_vcpu_csr *csr = &vcpu->arch.guest_csr; |
| 354 | 358 | unsigned long mask, val; |
| 359 | + unsigned long flags; | |
| 355 | 360 | |
| 356 | − if (READ_ONCE(vcpu->arch.irqs_pending_mask[0])) { | |
| 357 | − mask = xchg_acquire(&vcpu->arch.irqs_pending_mask[0], 0); | |
| 358 | − val = READ_ONCE(vcpu->arch.irqs_pending[0]) & mask; | |
| 361 | + raw_spin_lock_irqsave(&vcpu->arch.irqs_pending_lock, flags); | |
| 362 | + | |
| 363 | + mask = vcpu->arch.irqs_pending_mask[0]; | |
| 364 | + if (mask) { | |
| 365 | + vcpu->arch.irqs_pending_mask[0] = 0; | |
| 366 | + val = vcpu->arch.irqs_pending[0] & mask; | |
| 359 | 367 | |
| 360 | 368 | csr->hvip &= ~mask; |
| 361 | 369 | csr->hvip |= val; |
| @@ -363,11 +371,14 @@ void kvm_riscv_vcpu_flush_interrupts(struct kvm_vcpu *vcpu) · 1 unmodified line | ||
| 363 | 371 | |
| 364 | 372 | /* Flush AIA high interrupts */ |
| 365 | 373 | kvm_riscv_vcpu_aia_flush_interrupts(vcpu); |
| 374 | + | |
| 375 | + raw_spin_unlock_irqrestore(&vcpu->arch.irqs_pending_lock, flags); | |
| 366 | 376 | } |
| 367 | 377 | |
| 368 | 378 | void kvm_riscv_vcpu_sync_interrupts(struct kvm_vcpu *vcpu) |
| 369 | 379 | { |
| 370 | 380 | unsigned long hvip; |
| 381 | + unsigned long flags; | |
| 371 | 382 | struct kvm_vcpu_arch *v = &vcpu->arch; |
| 372 | 383 | struct kvm_vcpu_csr *csr = &vcpu->arch.guest_csr; |
| 373 | 384 | |
| @@ -376,34 +387,41 @@ void kvm_riscv_vcpu_sync_interrupts(struct kvm_vcpu *vcpu) · 2 unmodified lines | ||
| 376 | 387 | |
| 377 | 388 | /* Sync-up HVIP.VSSIP bit changes does by Guest */ |
| 378 | 389 | hvip = ncsr_read(CSR_HVIP); |
| 390 | + | |
| 391 | + raw_spin_lock_irqsave(&v->irqs_pending_lock, flags); | |
| 392 | + | |
| 379 | 393 | if ((csr->hvip ^ hvip) & (1UL << IRQ_VS_SOFT)) { |
| 380 | 394 | if (hvip & (1UL << IRQ_VS_SOFT)) { |
| 381 | − if (!test_and_set_bit(IRQ_VS_SOFT, | |
| 382 | − v->irqs_pending_mask)) | |
| 383 | − set_bit(IRQ_VS_SOFT, v->irqs_pending); | |
| 395 | + if (!__test_and_set_bit(IRQ_VS_SOFT, | |
| 396 | + v->irqs_pending_mask)) | |
| 397 | + __set_bit(IRQ_VS_SOFT, v->irqs_pending); | |
| 384 | 398 | } else { |
| 385 | − if (!test_and_set_bit(IRQ_VS_SOFT, | |
| 386 | − v->irqs_pending_mask)) | |
| 387 | − clear_bit(IRQ_VS_SOFT, v->irqs_pending); | |
| 399 | + if (!__test_and_set_bit(IRQ_VS_SOFT, | |
| 400 | + v->irqs_pending_mask)) | |
| 401 | + __clear_bit(IRQ_VS_SOFT, v->irqs_pending); | |
| 388 | 402 | } |
| 389 | 403 | } |
| 390 | 404 | |
| 391 | 405 | /* Sync up the HVIP.LCOFIP bit changes (only clear) by the guest */ |
| 392 | 406 | if ((csr->hvip ^ hvip) & (1UL << IRQ_PMU_OVF)) { |
| 393 | 407 | if (!(hvip & (1UL << IRQ_PMU_OVF)) && |
| 394 | − !test_and_set_bit(IRQ_PMU_OVF, v->irqs_pending_mask)) | |
| 395 | − clear_bit(IRQ_PMU_OVF, v->irqs_pending); | |
| 408 | + !__test_and_set_bit(IRQ_PMU_OVF, v->irqs_pending_mask)) | |
| 409 | + __clear_bit(IRQ_PMU_OVF, v->irqs_pending); | |
| 396 | 410 | } |
| 397 | 411 | |
| 398 | 412 | /* Sync-up AIA high interrupts */ |
| 399 | 413 | kvm_riscv_vcpu_aia_sync_interrupts(vcpu); |
| 400 | 414 | |
| 415 | + raw_spin_unlock_irqrestore(&v->irqs_pending_lock, flags); | |
| 416 | + | |
| 401 | 417 | /* Sync-up timer CSRs */ |
| 402 | 418 | kvm_riscv_vcpu_timer_sync(vcpu); |
| 403 | 419 | } |
| 404 | 420 | |
| 405 | 421 | int kvm_riscv_vcpu_set_interrupt(struct kvm_vcpu *vcpu, unsigned int irq) |
| 406 | 422 | { |
| 423 | + unsigned long flags; | |
| 424 | + | |
| 407 | 425 | /* |
| 408 | 426 | * We only allow VS-mode software, timer, and external |
| 409 | 427 | * interrupts when irq is one of the local interrupts |
| @@ -416,9 +434,10 @@ int kvm_riscv_vcpu_set_interrupt(struct kvm_vcpu *vcpu, unsigned int irq) · 6 unmodified lines | ||
| 416 | 434 | irq != IRQ_PMU_OVF) |
| 417 | 435 | return -EINVAL; |
| 418 | 436 | |
| 419 | − set_bit(irq, vcpu->arch.irqs_pending); | |
| 420 | − smp_mb__before_atomic(); | |
| 421 | − set_bit(irq, vcpu->arch.irqs_pending_mask); | |
| 437 | + raw_spin_lock_irqsave(&vcpu->arch.irqs_pending_lock, flags); | |
| 438 | + __set_bit(irq, vcpu->arch.irqs_pending); | |
| 439 | + __set_bit(irq, vcpu->arch.irqs_pending_mask); | |
| 440 | + raw_spin_unlock_irqrestore(&vcpu->arch.irqs_pending_lock, flags); | |
| 422 | 441 | |
| 423 | 442 | kvm_vcpu_kick(vcpu); |
| 424 | 443 | |
| @@ -427,6 +446,8 @@ int kvm_riscv_vcpu_set_interrupt(struct kvm_vcpu *vcpu, unsigned int irq) · 2 unmodified lines | ||
| 427 | 446 | |
| 428 | 447 | int kvm_riscv_vcpu_unset_interrupt(struct kvm_vcpu *vcpu, unsigned int irq) |
| 429 | 448 | { |
| 449 | + unsigned long flags; | |
| 450 | + | |
| 430 | 451 | /* |
| 431 | 452 | * We only allow VS-mode software, timer, counter overflow and external |
| 432 | 453 | * interrupts when irq is one of the local interrupts |
| @@ -439,26 +460,33 @@ int kvm_riscv_vcpu_unset_interrupt(struct kvm_vcpu *vcpu, unsigned int irq) · 6 unmodified lines | ||
| 439 | 460 | irq != IRQ_PMU_OVF) |
| 440 | 461 | return -EINVAL; |
| 441 | 462 | |
| 442 | − clear_bit(irq, vcpu->arch.irqs_pending); | |
| 443 | − smp_mb__before_atomic(); | |
| 444 | − set_bit(irq, vcpu->arch.irqs_pending_mask); | |
| 463 | + raw_spin_lock_irqsave(&vcpu->arch.irqs_pending_lock, flags); | |
| 464 | + __clear_bit(irq, vcpu->arch.irqs_pending); | |
| 465 | + __set_bit(irq, vcpu->arch.irqs_pending_mask); | |
| 466 | + raw_spin_unlock_irqrestore(&vcpu->arch.irqs_pending_lock, flags); | |
| 445 | 467 | |
| 446 | 468 | return 0; |
| 447 | 469 | } |
| 448 | 470 | |
| 449 | 471 | bool kvm_riscv_vcpu_has_interrupts(struct kvm_vcpu *vcpu, u64 mask) |
| 450 | 472 | { |
| 473 | + unsigned long flags; | |
| 451 | 474 | unsigned long ie; |
| 475 | + bool ret; | |
| 452 | 476 | |
| 477 | + raw_spin_lock_irqsave(&vcpu->arch.irqs_pending_lock, flags); | |
| 453 | 478 | ie = ((vcpu->arch.guest_csr.vsie & VSIP_VALID_MASK) |
| 454 | 479 | << VSIP_TO_HVIP_SHIFT) & (unsigned long)mask; |
| 455 | 480 | ie |= vcpu->arch.guest_csr.vsie & ~IRQ_LOCAL_MASK & |
| 456 | 481 | (unsigned long)mask; |
| 457 | − if (READ_ONCE(vcpu->arch.irqs_pending[0]) & ie) | |
| 458 | − return true; | |
| 482 | + ret = vcpu->arch.irqs_pending[0] & ie; | |
| 483 | + raw_spin_unlock_irqrestore(&vcpu->arch.irqs_pending_lock, flags); | |
| 459 | 484 | |
| 460 | 485 | /* Check AIA high interrupts */ |
| 461 | − return kvm_riscv_vcpu_aia_has_interrupts(vcpu, mask); | |
| 486 | + if (!ret) | |
| 487 | + ret = kvm_riscv_vcpu_aia_has_interrupts(vcpu, mask); | |
| 488 | + | |
| 489 | + return ret; | |
| 462 | 490 | } |
| 463 | 491 | |
| 464 | 492 | void __kvm_riscv_vcpu_power_off(struct kvm_vcpu *vcpu) |
| @@ -38,6 +38,25 @@ static int gstage_page_fault(struct kvm_vcpu *vcpu, struct kvm_run *run, · 37 unmodified lines | ||
| 38 | 38 | return kvm_riscv_vcpu_mmio_store(vcpu, run, |
| 39 | 39 | fault_addr, |
| 40 | 40 | trap->htinst); |
| 41 | + case EXC_INST_GUEST_PAGE_FAULT: { | |
| 42 | + /* | |
| 43 | + * No memslot backs this GPA and an instruction fetch | |
| 44 | + * cannot be emulated as MMIO. On bare metal a fetch | |
| 45 | + * from an unbacked physical address raises an | |
| 46 | + * instruction access fault, so reflect that back to | |
| 47 | + * the guest. | |
| 48 | + */ | |
| 49 | + struct kvm_cpu_trap inst_trap = { | |
| 50 | + .sepc = trap->sepc, | |
| 51 | + .scause = EXC_INST_ACCESS, | |
| 52 | + .stval = trap->stval, | |
| 53 | + .htval = 0, | |
| 54 | + .htinst = 0, | |
| 55 | + }; | |
| 56 | + | |
| 57 | + kvm_riscv_vcpu_trap_redirect(vcpu, &inst_trap); | |
| 58 | + return 1; | |
| 59 | + } | |
| 41 | 60 | default: |
| 42 | 61 | return -EOPNOTSUPP; |
| 43 | 62 | }; |
| @@ -50,19 +50,13 @@ static int kvm_riscv_vcpu_get_reg_config(struct kvm_vcpu *vcpu, · 49 unmodified lines | ||
| 50 | 50 | reg_val = vcpu->arch.isa[0] & KVM_RISCV_BASE_ISA_MASK; |
| 51 | 51 | break; |
| 52 | 52 | case KVM_REG_RISCV_CONFIG_REG(zicbom_block_size): |
| 53 | − if (kvm_riscv_isa_check_host(ZICBOM)) | |
| 54 | − return -ENOENT; | |
| 55 | − reg_val = riscv_cbom_block_size; | |
| 53 | + reg_val = (kvm_riscv_isa_check_host(ZICBOM)) ? 0 : riscv_cbom_block_size; | |
| 56 | 54 | break; |
| 57 | 55 | case KVM_REG_RISCV_CONFIG_REG(zicboz_block_size): |
| 58 | − if (kvm_riscv_isa_check_host(ZICBOZ)) | |
| 59 | − return -ENOENT; | |
| 60 | − reg_val = riscv_cboz_block_size; | |
| 56 | + reg_val = (kvm_riscv_isa_check_host(ZICBOZ)) ? 0 : riscv_cboz_block_size; | |
| 61 | 57 | break; |
| 62 | 58 | case KVM_REG_RISCV_CONFIG_REG(zicbop_block_size): |
| 63 | − if (kvm_riscv_isa_check_host(ZICBOP)) | |
| 64 | − return -ENOENT; | |
| 65 | − reg_val = riscv_cbop_block_size; | |
| 59 | + reg_val = (kvm_riscv_isa_check_host(ZICBOP)) ? 0 : riscv_cbop_block_size; | |
| 66 | 60 | break; |
| 67 | 61 | case KVM_REG_RISCV_CONFIG_REG(mvendorid): |
| 68 | 62 | reg_val = vcpu->arch.mvendorid; |
| @@ -144,21 +138,15 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu, · 75 unmodified lines | ||
| 144 | 138 | } |
| 145 | 139 | break; |
| 146 | 140 | case KVM_REG_RISCV_CONFIG_REG(zicbom_block_size): |
| 147 | − if (kvm_riscv_isa_check_host(ZICBOM)) | |
| 148 | − return -ENOENT; | |
| 149 | − if (reg_val != riscv_cbom_block_size) | |
| 141 | + if (reg_val && reg_val != riscv_cbom_block_size) | |
| 150 | 142 | return -EINVAL; |
| 151 | 143 | break; |
| 152 | 144 | case KVM_REG_RISCV_CONFIG_REG(zicboz_block_size): |
| 153 | − if (kvm_riscv_isa_check_host(ZICBOZ)) | |
| 154 | − return -ENOENT; | |
| 155 | − if (reg_val != riscv_cboz_block_size) | |
| 145 | + if (reg_val && reg_val != riscv_cboz_block_size) | |
| 156 | 146 | return -EINVAL; |
| 157 | 147 | break; |
| 158 | 148 | case KVM_REG_RISCV_CONFIG_REG(zicbop_block_size): |
| 159 | − if (kvm_riscv_isa_check_host(ZICBOP)) | |
| 160 | − return -ENOENT; | |
| 161 | − if (reg_val != riscv_cbop_block_size) | |
| 149 | + if (reg_val && reg_val != riscv_cbop_block_size) | |
| 162 | 150 | return -EINVAL; |
| 163 | 151 | break; |
| 164 | 152 | case KVM_REG_RISCV_CONFIG_REG(mvendorid): |
| @@ -298,6 +286,7 @@ static int kvm_riscv_vcpu_general_set_csr(struct kvm_vcpu *vcpu, · 133 unmodified lines | ||
| 298 | 286 | { |
| 299 | 287 | struct kvm_vcpu_csr *csr = &vcpu->arch.guest_csr; |
| 300 | 288 | unsigned long regs_max = sizeof(struct kvm_riscv_csr) / sizeof(unsigned long); |
| 289 | + unsigned long flags; | |
| 301 | 290 | |
| 302 | 291 | if (reg_num >= regs_max) |
| 303 | 292 | return -ENOENT; |
| @@ -311,8 +300,11 @@ static int kvm_riscv_vcpu_general_set_csr(struct kvm_vcpu *vcpu, · 7 unmodified lines | ||
| 311 | 300 | |
| 312 | 301 | ((unsigned long *)csr)[reg_num] = reg_val; |
| 313 | 302 | |
| 314 | − if (reg_num == KVM_REG_RISCV_CSR_REG(sip)) | |
| 315 | − WRITE_ONCE(vcpu->arch.irqs_pending_mask[0], 0); | |
| 303 | + if (reg_num == KVM_REG_RISCV_CSR_REG(sip)) { | |
| 304 | + raw_spin_lock_irqsave(&vcpu->arch.irqs_pending_lock, flags); | |
| 305 | + vcpu->arch.irqs_pending_mask[0] = 0; | |
| 306 | + raw_spin_unlock_irqrestore(&vcpu->arch.irqs_pending_lock, flags); | |
| 307 | + } | |
| 316 | 308 | |
| 317 | 309 | return 0; |
| 318 | 310 | } |
| @@ -614,20 +606,6 @@ static int copy_config_reg_indices(const struct kvm_vcpu *vcpu, · 295 unmodified lines | ||
| 614 | 606 | u64 size; |
| 615 | 607 | u64 reg; |
| 616 | 608 | |
| 617 | − /* | |
| 618 | − * Avoid reporting config reg if the corresponding extension | |
| 619 | − * was not available. | |
| 620 | − */ | |
| 621 | − if (i == KVM_REG_RISCV_CONFIG_REG(zicbom_block_size) && | |
| 622 | − kvm_riscv_isa_check_host(ZICBOM)) | |
| 623 | − continue; | |
| 624 | − else if (i == KVM_REG_RISCV_CONFIG_REG(zicboz_block_size) && | |
| 625 | − kvm_riscv_isa_check_host(ZICBOZ)) | |
| 626 | − continue; | |
| 627 | − else if (i == KVM_REG_RISCV_CONFIG_REG(zicbop_block_size) && | |
| 628 | − kvm_riscv_isa_check_host(ZICBOP)) | |
| 629 | − continue; | |
| 630 | − | |
| 631 | 609 | size = IS_ENABLED(CONFIG_32BIT) ? KVM_REG_SIZE_U32 : KVM_REG_SIZE_U64; |
| 632 | 610 | reg = KVM_REG_RISCV | size | KVM_REG_RISCV_CONFIG | i; |
| 633 | 611 | |
| @@ -586,7 +586,7 @@ int kvm_riscv_vcpu_pmu_ctr_start(struct kvm_vcpu *vcpu, unsigned long ctr_base, · 585 unmodified lines | ||
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | 588 | /* Start the counters that have been configured and requested by the guest */ |
| 589 | − for_each_set_bit(i, &ctr_mask, RISCV_MAX_COUNTERS) { | |
| 589 | + for_each_set_bit(i, &ctr_mask, BITS_PER_LONG) { | |
| 590 | 590 | pmc_index = array_index_nospec(i + ctr_base, |
| 591 | 591 | RISCV_KVM_MAX_COUNTERS); |
| 592 | 592 | if (!test_bit(pmc_index, kvpmu->pmc_in_use)) |
| @@ -658,7 +658,7 @@ int kvm_riscv_vcpu_pmu_ctr_stop(struct kvm_vcpu *vcpu, unsigned long ctr_base, · 65 unmodified lines | ||
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | /* Stop the counters that have been configured and requested by the guest */ |
| 661 | − for_each_set_bit(i, &ctr_mask, RISCV_MAX_COUNTERS) { | |
| 661 | + for_each_set_bit(i, &ctr_mask, BITS_PER_LONG) { | |
| 662 | 662 | pmc_index = array_index_nospec(i + ctr_base, |
| 663 | 663 | RISCV_KVM_MAX_COUNTERS); |
| 664 | 664 | if (!test_bit(pmc_index, kvpmu->pmc_in_use)) |
| @@ -327,9 +327,11 @@ static int kvm_sbi_fwft_set(struct kvm_vcpu *vcpu, u32 feature, · 326 unmodified lines | ||
| 327 | 327 | if (conf->flags & SBI_FWFT_SET_FLAG_LOCK) |
| 328 | 328 | return SBI_ERR_DENIED_LOCKED; |
| 329 | 329 | |
| 330 | − conf->flags = flags; | |
| 330 | + ret = conf->feature->set(vcpu, conf, false, value); | |
| 331 | + if (ret == SBI_SUCCESS) | |
| 332 | + conf->flags = flags; | |
| 331 | 333 | |
| 332 | − return conf->feature->set(vcpu, conf, false, value); | |
| 334 | + return ret; | |
| 333 | 335 | } |
| 334 | 336 | |
| 335 | 337 | static int kvm_sbi_fwft_get(struct kvm_vcpu *vcpu, unsigned long feature, |
| @@ -10,6 +10,7 @@ · 9 unmodified lines | ||
| 10 | 10 | #include <linux/errno.h> |
| 11 | 11 | #include <linux/err.h> |
| 12 | 12 | #include <linux/kvm_host.h> |
| 13 | +#include <linux/nospec.h> | |
| 13 | 14 | #include <linux/uaccess.h> |
| 14 | 15 | #include <asm/cpufeature.h> |
| 15 | 16 | #include <asm/kvm_isa.h> |
| @@ -129,11 +130,20 @@ static int kvm_riscv_vcpu_vreg_addr(struct kvm_vcpu *vcpu, · 113 unmodified lines | ||
| 129 | 130 | return -ENOENT; |
| 130 | 131 | } |
| 131 | 132 | } else if (reg_num <= KVM_REG_RISCV_VECTOR_REG(31)) { |
| 133 | + unsigned long reg_offset; | |
| 134 | + | |
| 132 | 135 | if (reg_size != vlenb) |
| 133 | 136 | return -EINVAL; |
| 134 | 137 | WARN_ON(!cntx->vector.datap); |
| 135 | − *reg_addr = cntx->vector.datap + | |
| 136 | − (reg_num - KVM_REG_RISCV_VECTOR_REG(0)) * vlenb; | |
| 138 | + /* | |
| 139 | + * The reg_num is derived from the userspace-provided ONE_REG | |
| 140 | + * id. Sanitize it with array_index_nospec() to prevent | |
| 141 | + * speculative out-of-bounds access to the vector register | |
| 142 | + * buffer (32 vector registers: v0..v31). | |
| 143 | + */ | |
| 144 | + reg_offset = array_index_nospec( | |
| 145 | + reg_num - KVM_REG_RISCV_VECTOR_REG(0), 32); | |
| 146 | + *reg_addr = cntx->vector.datap + reg_offset * vlenb; | |
| 137 | 147 | } else { |
| 138 | 148 | return -ENOENT; |
| 139 | 149 | } |
| @@ -65,6 +65,7 @@ ATOMIC_NOTIFIER_HEAD(s390_epoch_delta_notifier); · 64 unmodified lines | ||
| 65 | 65 | EXPORT_SYMBOL(s390_epoch_delta_notifier); |
| 66 | 66 | |
| 67 | 67 | unsigned char ptff_function_mask[16]; |
| 68 | +EXPORT_SYMBOL(ptff_function_mask); | |
| 68 | 69 | |
| 69 | 70 | static unsigned long lpar_offset; |
| 70 | 71 | static unsigned long initial_leap_seconds; |
| @@ -27,6 +27,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ · 26 unmodified lines | ||
| 27 | 27 | KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS) |
| 28 | 28 | KBUILD_CFLAGS += $(CC_FLAGS_DIALECT) |
| 29 | 29 | KBUILD_CFLAGS += -fno-strict-aliasing -fPIE |
| 30 | +KBUILD_CFLAGS += -fno-jump-tables | |
| 30 | 31 | KBUILD_CFLAGS += -Wundef |
| 31 | 32 | KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING |
| 32 | 33 | cflags-$(CONFIG_X86_32) := -march=i386 |
| @@ -2052,7 +2052,7 @@ static void apic_timer_expired(struct kvm_lapic *apic, bool from_timer_fn) · 2051 unmodified lines | ||
| 2052 | 2052 | if (apic_lvtt_tscdeadline(apic) || ktimer->hv_timer_in_use) |
| 2053 | 2053 | ktimer->expired_tscdeadline = ktimer->tscdeadline; |
| 2054 | 2054 | |
| 2055 | − if (!from_timer_fn && apic->apicv_active) { | |
| 2055 | + if (!from_timer_fn && apic->apicv_active && vcpu->wants_to_run) { | |
| 2056 | 2056 | WARN_ON(kvm_get_running_vcpu() != vcpu); |
| 2057 | 2057 | kvm_apic_inject_pending_timer_irqs(apic); |
| 2058 | 2058 | return; |
| @@ -2642,6 +2642,7 @@ static int mmu_page_zap_pte(struct kvm *kvm, struct kvm_mmu_page *sp, · 2641 unmodified lines | ||
| 2642 | 2642 | */ |
| 2643 | 2643 | if (tdp_enabled && invalid_list && |
| 2644 | 2644 | child->role.guest_mode && |
| 2645 | + !child->root_count && | |
| 2645 | 2646 | !atomic_long_read(&child->parent_ptes.val)) |
| 2646 | 2647 | return kvm_mmu_prepare_zap_page(kvm, child, |
| 2647 | 2648 | invalid_list); |
| @@ -4852,16 +4853,17 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault · 2204 unmodified lines | ||
| 4852 | 4853 | if (r != RET_PF_CONTINUE) |
| 4853 | 4854 | return r; |
| 4854 | 4855 | |
| 4855 | − r = RET_PF_RETRY; | |
| 4856 | 4856 | write_lock(&vcpu->kvm->mmu_lock); |
| 4857 | 4857 | |
| 4858 | − if (is_page_fault_stale(vcpu, fault)) | |
| 4859 | − goto out_unlock; | |
| 4860 | − | |
| 4861 | 4858 | r = make_mmu_pages_available(vcpu); |
| 4862 | 4859 | if (r) |
| 4863 | 4860 | goto out_unlock; |
| 4864 | 4861 | |
| 4862 | + if (is_page_fault_stale(vcpu, fault)) { | |
| 4863 | + r = RET_PF_RETRY; | |
| 4864 | + goto out_unlock; | |
| 4865 | + } | |
| 4866 | + | |
| 4865 | 4867 | r = direct_map(vcpu, fault); |
| 4866 | 4868 | |
| 4867 | 4869 | out_unlock: |
| @@ -7574,7 +7576,9 @@ void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen) · 2706 unmodified lines | ||
| 7574 | 7576 | static void mmu_destroy_caches(void) |
| 7575 | 7577 | { |
| 7576 | 7578 | kmem_cache_destroy(pte_list_desc_cache); |
| 7579 | + pte_list_desc_cache = NULL; | |
| 7577 | 7580 | kmem_cache_destroy(mmu_page_header_cache); |
| 7581 | + mmu_page_header_cache = NULL; | |
| 7578 | 7582 | } |
| 7579 | 7583 | |
| 7580 | 7584 | static void kvm_wake_nx_recovery_thread(struct kvm *kvm) |
| @@ -864,15 +864,17 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault · 863 unmodified lines | ||
| 864 | 864 | } |
| 865 | 865 | #endif |
| 866 | 866 | |
| 867 | − r = RET_PF_RETRY; | |
| 868 | 867 | write_lock(&vcpu->kvm->mmu_lock); |
| 869 | 868 | |
| 870 | − if (is_page_fault_stale(vcpu, fault)) | |
| 871 | − goto out_unlock; | |
| 872 | − | |
| 873 | 869 | r = make_mmu_pages_available(vcpu); |
| 874 | 870 | if (r) |
| 875 | 871 | goto out_unlock; |
| 872 | + | |
| 873 | + if (is_page_fault_stale(vcpu, fault)) { | |
| 874 | + r = RET_PF_RETRY; | |
| 875 | + goto out_unlock; | |
| 876 | + } | |
| 877 | + | |
| 876 | 878 | r = FNAME(fetch)(vcpu, fault, &walker); |
| 877 | 879 | |
| 878 | 880 | out_unlock: |
| @@ -336,6 +336,7 @@ static void nested_put_vmcs12_pages(struct kvm_vcpu *vcpu) · 335 unmodified lines | ||
| 336 | 336 | static void free_nested(struct kvm_vcpu *vcpu) |
| 337 | 337 | { |
| 338 | 338 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
| 339 | + struct vmcs *shadow_vmcs; | |
| 339 | 340 | |
| 340 | 341 | if (WARN_ON_ONCE(vmx->loaded_vmcs != &vmx->vmcs01)) |
| 341 | 342 | vmx_switch_vmcs(vcpu, &vmx->vmcs01); |
| @@ -353,9 +354,15 @@ static void free_nested(struct kvm_vcpu *vcpu) · 11 unmodified lines | ||
| 353 | 354 | vmx->nested.current_vmptr = INVALID_GPA; |
| 354 | 355 | if (enable_shadow_vmcs) { |
| 355 | 356 | vmx_disable_shadow_vmcs(vmx); |
| 356 | − vmcs_clear(vmx->vmcs01.shadow_vmcs); | |
| 357 | − free_vmcs(vmx->vmcs01.shadow_vmcs); | |
| 357 | + | |
| 358 | + /* | |
| 359 | + * Keep the pointer visible until after VMCLEAR, so migration | |
| 360 | + * can clear an active shadow VMCS on the old CPU. | |
| 361 | + */ | |
| 362 | + shadow_vmcs = vmx->vmcs01.shadow_vmcs; | |
| 363 | + vmcs_clear(shadow_vmcs); | |
| 358 | 364 | vmx->vmcs01.shadow_vmcs = NULL; |
| 365 | + free_vmcs(shadow_vmcs); | |
| 359 | 366 | } |
| 360 | 367 | kfree(vmx->nested.cached_vmcs12); |
| 361 | 368 | vmx->nested.cached_vmcs12 = NULL; |
| @@ -43,20 +43,22 @@ struct aie2_ctx_health { · 42 unmodified lines | ||
| 43 | 43 | |
| 44 | 44 | static inline void aie2_tdr_signal(struct amdxdna_dev *xdna) |
| 45 | 45 | { |
| 46 | − WRITE_ONCE(xdna->dev_handle->tdr_status, AIE2_TDR_SIGNALED); | |
| 46 | + WRITE_ONCE(xdna->dev_handle->last_signal_ts, jiffies); | |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | static bool aie2_tdr_detect(struct amdxdna_dev *xdna) |
| 50 | 50 | { |
| 51 | 51 | struct amdxdna_dev_hdl *ndev = xdna->dev_handle; |
| 52 | + unsigned long last = READ_ONCE(ndev->last_signal_ts); | |
| 52 | 53 | |
| 53 | − if (READ_ONCE(ndev->tdr_status) == AIE2_TDR_WAIT) { | |
| 54 | − XDNA_ERR(xdna, "TDR timeout detected"); | |
| 55 | − return true; | |
| 56 | − } | |
| 54 | + if (!tdr_timeout_ms) | |
| 55 | + return false; | |
| 56 | + | |
| 57 | + if (!time_after(jiffies, last + msecs_to_jiffies(tdr_timeout_ms))) | |
| 58 | + return false; | |
| 57 | 59 | |
| 58 | − WRITE_ONCE(ndev->tdr_status, AIE2_TDR_WAIT); | |
| 59 | − return false; | |
| 60 | + XDNA_ERR(xdna, "TDR timeout detected"); | |
| 61 | + return true; | |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | 64 | static void aie2_cmd_release(struct kref *ref) |
| @@ -434,6 +436,12 @@ out: · 371 unmodified lines | ||
| 434 | 436 | mmput(job->mm); |
| 435 | 437 | fence = ERR_PTR(ret); |
| 436 | 438 | } else { |
| 439 | + /* | |
| 440 | + * Command is successfully posted to hardware, update the | |
| 441 | + * tdr timestamp. The total pending commands are limited. | |
| 442 | + * So there will not be a case that driver keeps posting | |
| 443 | + * commands without getting any hardware respond. | |
| 444 | + */ | |
| 437 | 445 | aie2_tdr_signal(hwctx->client->xdna); |
| 438 | 446 | } |
| 439 | 447 | trace_xdna_job(sched_job, hwctx->name, "sent to device", |
| @@ -658,7 +666,9 @@ int aie2_hwctx_init(struct amdxdna_hwctx *hwctx) · 218 unmodified lines | ||
| 658 | 666 | const struct drm_sched_init_args args = { |
| 659 | 667 | .ops = &sched_ops, |
| 660 | 668 | .credit_limit = HWCTX_MAX_CMDS, |
| 661 | − .timeout = msecs_to_jiffies(tdr_timeout_ms), | |
| 669 | + .timeout = tdr_timeout_ms ? | |
| 670 | + msecs_to_jiffies(tdr_timeout_ms) : | |
| 671 | + MAX_SCHEDULE_TIMEOUT, | |
| 662 | 672 | .name = "amdxdna_js", |
| 663 | 673 | .dev = xdna->ddev.dev, |
| 664 | 674 | }; |
| @@ -420,6 +420,7 @@ static int aie2_hw_start(struct amdxdna_dev *xdna) · 419 unmodified lines | ||
| 420 | 420 | goto stop_fw; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | + WRITE_ONCE(ndev->last_signal_ts, jiffies); | |
| 423 | 424 | ndev->dev_status = AIE2_DEV_START; |
| 424 | 425 | |
| 425 | 426 | return 0; |
| @@ -143,11 +143,6 @@ struct aie2_exec_msg_ops { · 142 unmodified lines | ||
| 143 | 143 | u32 (*get_chain_msg_op)(u32 cmd_op); |
| 144 | 144 | }; |
| 145 | 145 | |
| 146 | −enum aie2_tdr_status { | |
| 147 | − AIE2_TDR_WAIT, | |
| 148 | − AIE2_TDR_SIGNALED, | |
| 149 | −}; | |
| 150 | − | |
| 151 | 146 | struct amdxdna_dev_hdl { |
| 152 | 147 | struct aie_device aie; |
| 153 | 148 | const struct amdxdna_dev_priv *priv; |
| @@ -179,7 +174,7 @@ struct amdxdna_dev_hdl { · 25 unmodified lines | ||
| 179 | 174 | u32 hwctx_num; |
| 180 | 175 | |
| 181 | 176 | struct amdxdna_async_error last_async_err; |
| 182 | − enum aie2_tdr_status tdr_status; | |
| 177 | + unsigned long last_signal_ts; | |
| 183 | 178 | }; |
| 184 | 179 | |
| 185 | 180 | struct aie2_hw_ops { |
| @@ -192,9 +192,17 @@ static u64 dma_length(struct ethosu_validated_cmdstream_info *info, · 191 unmodified lines | ||
| 192 | 192 | return len; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | −static u64 feat_matrix_length(struct ethosu_validated_cmdstream_info *info, | |
| 195 | +static bool feat_matrix_chained(struct ethosu_device *edev, struct feat_matrix *fm) | |
| 196 | +{ | |
| 197 | + u32 storage = fm->precision >> 14; | |
| 198 | + | |
| 199 | + return !ethosu_is_u65(edev) && storage == 2; | |
| 200 | +} | |
| 201 | + | |
| 202 | +static u64 feat_matrix_length(struct ethosu_device *edev, | |
| 203 | + struct ethosu_validated_cmdstream_info *info, | |
| 196 | 204 | struct feat_matrix *fm, |
| 197 | − u32 x, u32 y, u32 c) | |
| 205 | + u32 x, u32 y, u32 c, bool ofm) | |
| 198 | 206 | { |
| 199 | 207 | u32 element_size, storage = fm->precision >> 14; |
| 200 | 208 | int tile = 0; |
| @@ -203,6 +211,9 @@ static u64 feat_matrix_length(struct ethosu_validated_cmdstream_info *info, · 2 unmodified lines | ||
| 203 | 211 | if (fm->region < 0) |
| 204 | 212 | return U64_MAX; |
| 205 | 213 | |
| 214 | + if (feat_matrix_chained(edev, fm)) | |
| 215 | + return 0; | |
| 216 | + | |
| 206 | 217 | switch (storage) { |
| 207 | 218 | case 0: |
| 208 | 219 | if (x >= fm->width0 + 1) { |
| @@ -223,6 +234,8 @@ static u64 feat_matrix_length(struct ethosu_validated_cmdstream_info *info, · 14 unmodified lines | ||
| 223 | 234 | tile = 1; |
| 224 | 235 | } |
| 225 | 236 | break; |
| 237 | + default: | |
| 238 | + return U64_MAX; | |
| 226 | 239 | } |
| 227 | 240 | if (fm->base[tile] == U64_MAX) |
| 228 | 241 | return U64_MAX; |
| @@ -231,10 +244,11 @@ static u64 feat_matrix_length(struct ethosu_validated_cmdstream_info *info, · 2 unmodified lines | ||
| 231 | 244 | |
| 232 | 245 | switch ((fm->precision >> 6) & 0x3) { // format |
| 233 | 246 | case 0: //nhwc: |
| 234 | − addr += x * fm->stride_x + c; | |
| 247 | + element_size = BIT((fm->precision >> (ofm ? 1 : 2)) & 0x3); | |
| 248 | + addr += x * fm->stride_x + c * element_size; | |
| 235 | 249 | break; |
| 236 | 250 | case 1: //nhcwb16: |
| 237 | − element_size = BIT((fm->precision >> 1) & 0x3); | |
| 251 | + element_size = BIT((fm->precision >> (ofm ? 1 : 2)) & 0x3); | |
| 238 | 252 | |
| 239 | 253 | addr += (c / 16) * fm->stride_c + (16 * x + (c & 0xf)) * element_size; |
| 240 | 254 | break; |
| @@ -250,6 +264,7 @@ static int calc_sizes(struct drm_device *ddev, · 9 unmodified lines | ||
| 250 | 264 | u16 op, struct cmd_state *st, |
| 251 | 265 | bool ifm, bool ifm2, bool weight, bool scale) |
| 252 | 266 | { |
| 267 | + struct ethosu_device *edev = to_ethosu_device(ddev); | |
| 253 | 268 | u64 len; |
| 254 | 269 | |
| 255 | 270 | if (ifm) { |
| @@ -267,8 +282,8 @@ static int calc_sizes(struct drm_device *ddev, · 11 unmodified lines | ||
| 267 | 282 | if (ifm_height < 0 || ifm_width < 0) |
| 268 | 283 | return -EINVAL; |
| 269 | 284 | |
| 270 | − len = feat_matrix_length(info, &st->ifm, ifm_width, | |
| 271 | − ifm_height, st->ifm.depth); | |
| 285 | + len = feat_matrix_length(edev, info, &st->ifm, ifm_width, | |
| 286 | + ifm_height, st->ifm.depth, false); | |
| 272 | 287 | dev_dbg(ddev->dev, "op %d: IFM:%d:0x%llx-0x%llx\n", |
| 273 | 288 | op, st->ifm.region, st->ifm.base[0], len); |
| 274 | 289 | if (len == U64_MAX) |
| @@ -276,8 +291,8 @@ static int calc_sizes(struct drm_device *ddev, · 1 unmodified line | ||
| 276 | 291 | } |
| 277 | 292 | |
| 278 | 293 | if (ifm2) { |
| 279 | − len = feat_matrix_length(info, &st->ifm2, st->ifm.depth, | |
| 280 | − 0, st->ofm.depth); | |
| 294 | + len = feat_matrix_length(edev, info, &st->ifm2, st->ifm.depth, | |
| 295 | + 0, st->ofm.depth, false); | |
| 281 | 296 | dev_dbg(ddev->dev, "op %d: IFM2:%d:0x%llx-0x%llx\n", |
| 282 | 297 | op, st->ifm2.region, st->ifm2.base[0], len); |
| 283 | 298 | if (len == U64_MAX) |
| @@ -308,13 +323,14 @@ static int calc_sizes(struct drm_device *ddev, · 24 unmodified lines | ||
| 308 | 323 | st->scale[0].base + st->scale[0].length); |
| 309 | 324 | } |
| 310 | 325 | |
| 311 | − len = feat_matrix_length(info, &st->ofm, st->ofm.width, | |
| 312 | − st->ofm.height[2], st->ofm.depth); | |
| 326 | + len = feat_matrix_length(edev, info, &st->ofm, st->ofm.width, | |
| 327 | + st->ofm.height[2], st->ofm.depth, true); | |
| 313 | 328 | dev_dbg(ddev->dev, "op %d: OFM:%d:0x%llx-0x%llx\n", |
| 314 | 329 | op, st->ofm.region, st->ofm.base[0], len); |
| 315 | 330 | if (len == U64_MAX) |
| 316 | 331 | return -EINVAL; |
| 317 | − info->output_region[st->ofm.region] = true; | |
| 332 | + if (!feat_matrix_chained(edev, &st->ofm)) | |
| 333 | + info->output_region[st->ofm.region] = true; | |
| 318 | 334 | |
| 319 | 335 | return 0; |
| 320 | 336 | } |
| @@ -324,6 +340,7 @@ static int calc_sizes_elemwise(struct drm_device *ddev, · 3 unmodified lines | ||
| 324 | 340 | u16 op, struct cmd_state *st, |
| 325 | 341 | bool ifm, bool ifm2) |
| 326 | 342 | { |
| 343 | + struct ethosu_device *edev = to_ethosu_device(ddev); | |
| 327 | 344 | u32 height, width, depth; |
| 328 | 345 | u64 len; |
| 329 | 346 | |
| @@ -332,8 +349,8 @@ static int calc_sizes_elemwise(struct drm_device *ddev, · 2 unmodified lines | ||
| 332 | 349 | width = st->ifm.broadcast & 0x2 ? 0 : st->ofm.width; |
| 333 | 350 | depth = st->ifm.broadcast & 0x4 ? 0 : st->ofm.depth; |
| 334 | 351 | |
| 335 | − len = feat_matrix_length(info, &st->ifm, width, | |
| 336 | − height, depth); | |
| 352 | + len = feat_matrix_length(edev, info, &st->ifm, width, | |
| 353 | + height, depth, false); | |
| 337 | 354 | dev_dbg(ddev->dev, "op %d: IFM:%d:0x%llx-0x%llx\n", |
| 338 | 355 | op, st->ifm.region, st->ifm.base[0], len); |
| 339 | 356 | if (len == U64_MAX) |
| @@ -345,21 +362,22 @@ static int calc_sizes_elemwise(struct drm_device *ddev, · 5 unmodified lines | ||
| 345 | 362 | width = st->ifm2.broadcast & 0x2 ? 0 : st->ofm.width; |
| 346 | 363 | depth = st->ifm2.broadcast & 0x4 ? 0 : st->ofm.depth; |
| 347 | 364 | |
| 348 | − len = feat_matrix_length(info, &st->ifm2, width, | |
| 349 | − height, depth); | |
| 365 | + len = feat_matrix_length(edev, info, &st->ifm2, width, | |
| 366 | + height, depth, false); | |
| 350 | 367 | dev_dbg(ddev->dev, "op %d: IFM2:%d:0x%llx-0x%llx\n", |
| 351 | 368 | op, st->ifm2.region, st->ifm2.base[0], len); |
| 352 | 369 | if (len == U64_MAX) |
| 353 | 370 | return -EINVAL; |
| 354 | 371 | } |
| 355 | 372 | |
| 356 | − len = feat_matrix_length(info, &st->ofm, st->ofm.width, | |
| 357 | − st->ofm.height[2], st->ofm.depth); | |
| 373 | + len = feat_matrix_length(edev, info, &st->ofm, st->ofm.width, | |
| 374 | + st->ofm.height[2], st->ofm.depth, true); | |
| 358 | 375 | dev_dbg(ddev->dev, "op %d: OFM:%d:0x%llx-0x%llx\n", |
| 359 | 376 | op, st->ofm.region, st->ofm.base[0], len); |
| 360 | 377 | if (len == U64_MAX) |
| 361 | 378 | return -EINVAL; |
| 362 | − info->output_region[st->ofm.region] = true; | |
| 379 | + if (!feat_matrix_chained(edev, &st->ofm)) | |
| 380 | + info->output_region[st->ofm.region] = true; | |
| 363 | 381 | |
| 364 | 382 | return 0; |
| 365 | 383 | } |
| @@ -1273,14 +1273,14 @@ impl Thread { · 1272 unmodified lines | ||
| 1273 | 1273 | inner.extended_error = |
| 1274 | 1274 | ExtendedError::new(info.debug_id as u32, err.reply, source.to_errno()); |
| 1275 | 1275 | } |
| 1276 | − } | |
| 1277 | 1276 | |
| 1278 | − pr_warn!( | |
| 1279 | − "{}:{} transaction to {} failed: {err:?}", | |
| 1280 | − info.from_pid, | |
| 1281 | − info.from_tid, | |
| 1282 | − info.to_pid | |
| 1283 | − ); | |
| 1277 | + pr_warn!( | |
| 1278 | + "{}:{} transaction to {} failed: {err:?}", | |
| 1279 | + info.from_pid, | |
| 1280 | + info.from_tid, | |
| 1281 | + info.to_pid | |
| 1282 | + ); | |
| 1283 | + } | |
| 1284 | 1284 | } |
| 1285 | 1285 | } |
| 1286 | 1286 | |
| @@ -1950,9 +1950,14 @@ static int rbd_object_map_update_finish(struct rbd_obj_request *obj_req, · 1949 unmodified lines | ||
| 1950 | 1950 | bool has_current_state; |
| 1951 | 1951 | void *p; |
| 1952 | 1952 | |
| 1953 | − if (osd_req->r_result) | |
| 1953 | + if (osd_req->r_result < 0) | |
| 1954 | 1954 | return osd_req->r_result; |
| 1955 | 1955 | |
| 1956 | + /* | |
| 1957 | + * Writes aren't allowed to return a data payload. | |
| 1958 | + */ | |
| 1959 | + WARN_ON_ONCE(osd_req->r_result > 0); | |
| 1960 | + | |
| 1956 | 1961 | /* |
| 1957 | 1962 | * Nothing to do for a snapshot object map. |
| 1958 | 1963 | */ |
| @@ -19,6 +19,7 @@ · 18 unmodified lines | ||
| 19 | 19 | #include <linux/errno.h> |
| 20 | 20 | #include <linux/major.h> |
| 21 | 21 | #include <linux/wait.h> |
| 22 | +#include <linux/wait_bit.h> | |
| 22 | 23 | #include <linux/blkdev.h> |
| 23 | 24 | #include <linux/init.h> |
| 24 | 25 | #include <linux/swap.h> |
| @@ -26,7 +27,6 @@ · 1 unmodified line | ||
| 26 | 27 | #include <linux/compat.h> |
| 27 | 28 | #include <linux/mutex.h> |
| 28 | 29 | #include <linux/writeback.h> |
| 29 | −#include <linux/completion.h> | |
| 30 | 30 | #include <linux/highmem.h> |
| 31 | 31 | #include <linux/sysfs.h> |
| 32 | 32 | #include <linux/miscdevice.h> |
| @@ -327,7 +327,6 @@ struct ublk_device { · 294 unmodified lines | ||
| 327 | 327 | |
| 328 | 328 | struct ublk_params params; |
| 329 | 329 | |
| 330 | − struct completion completion; | |
| 331 | 330 | u32 nr_queue_ready; |
| 332 | 331 | bool unprivileged_daemons; |
| 333 | 332 | struct mutex cancel_mutex; |
| @@ -3054,12 +3053,12 @@ static void ublk_mark_io_ready(struct ublk_device *ub, u16 q_id, · 2720 unmodified lines | ||
| 3054 | 3053 | if (ublk_dev_ready(ub)) { |
| 3055 | 3054 | /* |
| 3056 | 3055 | * All queues ready - clear device-level canceling flag |
| 3057 | − * and complete the recovery/initialization. | |
| 3056 | + * and wake ublk_dev_ready() waiters. | |
| 3058 | 3057 | */ |
| 3059 | 3058 | mutex_lock(&ub->cancel_mutex); |
| 3060 | 3059 | ub->canceling = false; |
| 3061 | 3060 | mutex_unlock(&ub->cancel_mutex); |
| 3062 | − complete_all(&ub->completion); | |
| 3061 | + wake_up_var(&ub->nr_queue_ready); | |
| 3063 | 3062 | } |
| 3064 | 3063 | } |
| 3065 | 3064 | |
| @@ -4273,7 +4272,6 @@ static int ublk_init_queues(struct ublk_device *ub) · 1207 unmodified lines | ||
| 4273 | 4272 | goto fail; |
| 4274 | 4273 | } |
| 4275 | 4274 | |
| 4276 | − init_completion(&ub->completion); | |
| 4277 | 4275 | return 0; |
| 4278 | 4276 | |
| 4279 | 4277 | fail: |
| @@ -4417,6 +4415,26 @@ static bool ublk_validate_user_pid(struct ublk_device *ub, pid_t ublksrv_pid) · 137 unmodified lines | ||
| 4417 | 4415 | return ub->ublksrv_tgid == ublksrv_pid; |
| 4418 | 4416 | } |
| 4419 | 4417 | |
| 4418 | +/* | |
| 4419 | + * Wait until all queues have fetched their I/O commands, and return with | |
| 4420 | + * ub->mutex held and readiness guaranteed: then every queue's ->canceling | |
| 4421 | + * is cleared. Ready may regress between wakeup and mutex_lock() (F_BATCH | |
| 4422 | + * UNPREP, daemon death), so re-check it under the mutex and wait again. | |
| 4423 | + */ | |
| 4424 | +static int ublk_wait_dev_ready_and_lock(struct ublk_device *ub) | |
| 4425 | +{ | |
| 4426 | + while (true) { | |
| 4427 | + if (wait_var_event_interruptible(&ub->nr_queue_ready, | |
| 4428 | + ublk_dev_ready(ub))) | |
| 4429 | + return -EINTR; | |
| 4430 | + | |
| 4431 | + mutex_lock(&ub->mutex); | |
| 4432 | + if (ublk_dev_ready(ub)) | |
| 4433 | + return 0; | |
| 4434 | + mutex_unlock(&ub->mutex); | |
| 4435 | + } | |
| 4436 | +} | |
| 4437 | + | |
| 4420 | 4438 | static int ublk_ctrl_start_dev(struct ublk_device *ub, |
| 4421 | 4439 | const struct ublksrv_ctrl_cmd *header) |
| 4422 | 4440 | { |
| @@ -4499,15 +4517,10 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, · 76 unmodified lines | ||
| 4499 | 4517 | }; |
| 4500 | 4518 | } |
| 4501 | 4519 | |
| 4502 | − if (wait_for_completion_interruptible(&ub->completion) != 0) | |
| 4520 | + if (ublk_wait_dev_ready_and_lock(ub)) | |
| 4503 | 4521 | return -EINTR; |
| 4504 | 4522 | |
| 4505 | − if (!ublk_validate_user_pid(ub, ublksrv_pid)) | |
| 4506 | − return -EINVAL; | |
| 4507 | − | |
| 4508 | − mutex_lock(&ub->mutex); | |
| 4509 | − /* device may become not ready in case of F_BATCH */ | |
| 4510 | − if (!ublk_dev_ready(ub)) { | |
| 4523 | + if (!ublk_validate_user_pid(ub, ublksrv_pid)) { | |
| 4511 | 4524 | ret = -EINVAL; |
| 4512 | 4525 | goto out_unlock; |
| 4513 | 4526 | } |
| @@ -5071,7 +5084,6 @@ static int ublk_ctrl_start_recovery(struct ublk_device *ub) · 557 unmodified lines | ||
| 5071 | 5084 | goto out_unlock; |
| 5072 | 5085 | } |
| 5073 | 5086 | pr_devel("%s: start recovery for dev id %d\n", __func__, ub->ub_number); |
| 5074 | − init_completion(&ub->completion); | |
| 5075 | 5087 | ret = 0; |
| 5076 | 5088 | out_unlock: |
| 5077 | 5089 | mutex_unlock(&ub->mutex); |
| @@ -5087,16 +5099,17 @@ static int ublk_ctrl_end_recovery(struct ublk_device *ub, · 9 unmodified lines | ||
| 5087 | 5099 | pr_devel("%s: Waiting for all FETCH_REQs, dev id %d...\n", __func__, |
| 5088 | 5100 | header->dev_id); |
| 5089 | 5101 | |
| 5090 | − if (wait_for_completion_interruptible(&ub->completion)) | |
| 5102 | + if (ublk_wait_dev_ready_and_lock(ub)) | |
| 5091 | 5103 | return -EINTR; |
| 5092 | 5104 | |
| 5093 | 5105 | pr_devel("%s: All FETCH_REQs received, dev id %d\n", __func__, |
| 5094 | 5106 | header->dev_id); |
| 5095 | 5107 | |
| 5096 | − if (!ublk_validate_user_pid(ub, ublksrv_pid)) | |
| 5097 | − return -EINVAL; | |
| 5108 | + if (!ublk_validate_user_pid(ub, ublksrv_pid)) { | |
| 5109 | + ret = -EINVAL; | |
| 5110 | + goto out_unlock; | |
| 5111 | + } | |
| 5098 | 5112 | |
| 5099 | − mutex_lock(&ub->mutex); | |
| 5100 | 5113 | if (ublk_nosrv_should_stop_dev(ub)) |
| 5101 | 5114 | goto out_unlock; |
| 5102 | 5115 | |
| @@ -2782,7 +2782,9 @@ static int btusb_setup_realtek(struct hci_dev *hdev) · 2781 unmodified lines | ||
| 2782 | 2782 | |
| 2783 | 2783 | static int btusb_recv_event_realtek(struct hci_dev *hdev, struct sk_buff *skb) |
| 2784 | 2784 | { |
| 2785 | − if (skb->data[0] == HCI_VENDOR_PKT && skb->data[2] == RTK_SUB_EVENT_CODE_COREDUMP) { | |
| 2785 | + if (skb->len >= HCI_EVENT_HDR_SIZE + 1 && | |
| 2786 | + skb->data[0] == HCI_VENDOR_PKT && | |
| 2787 | + skb->data[2] == RTK_SUB_EVENT_CODE_COREDUMP) { | |
| 2786 | 2788 | struct rtk_dev_coredump_hdr hdr = { |
| 2787 | 2789 | .code = RTK_DEVCOREDUMP_CODE_MEMDUMP, |
| 2788 | 2790 | }; |
| @@ -3187,6 +3187,7 @@ static noinline int mmc_ioctl_cdrom_volume(struct cdrom_device_info *cdi, · 3186 unmodified lines | ||
| 3187 | 3187 | |
| 3188 | 3188 | /* set volume */ |
| 3189 | 3189 | cgc->buffer = buffer + offset - 8; |
| 3190 | + cgc->buflen -= offset - 8; | |
| 3190 | 3191 | memset(cgc->buffer, 0, 8); |
| 3191 | 3192 | return cdrom_mode_select(cdi, cgc); |
| 3192 | 3193 | } |
| @@ -211,6 +211,13 @@ static irqreturn_t parport_interrupt(int irq, void *d) · 210 unmodified lines | ||
| 211 | 211 | unsigned int ctrl; |
| 212 | 212 | unsigned short val = 0; |
| 213 | 213 | |
| 214 | + /* | |
| 215 | + * Check device is fully attached. Device interrupts should have | |
| 216 | + * been disabled, but do this in case of bad hardware. | |
| 217 | + */ | |
| 218 | + if (!dev->attached) | |
| 219 | + return IRQ_NONE; | |
| 220 | + | |
| 214 | 221 | ctrl = inb(dev->iobase + PARPORT_CTRL_REG); |
| 215 | 222 | if (!(ctrl & PARPORT_CTRL_IRQ_ENA)) |
| 216 | 223 | return IRQ_NONE; |
| @@ -233,6 +240,9 @@ static int parport_attach(struct comedi_device *dev, · 16 unmodified lines | ||
| 233 | 240 | if (ret) |
| 234 | 241 | return ret; |
| 235 | 242 | |
| 243 | + outb(0, dev->iobase + PARPORT_DATA_REG); | |
| 244 | + outb(0, dev->iobase + PARPORT_CTRL_REG); | |
| 245 | + | |
| 236 | 246 | if (it->options[1]) { |
| 237 | 247 | ret = request_irq(it->options[1], parport_interrupt, 0, |
| 238 | 248 | dev->board_name, dev); |
| @@ -288,9 +298,6 @@ static int parport_attach(struct comedi_device *dev, · 49 unmodified lines | ||
| 288 | 298 | s->cancel = parport_intr_cancel; |
| 289 | 299 | } |
| 290 | 300 | |
| 291 | − outb(0, dev->iobase + PARPORT_DATA_REG); | |
| 292 | − outb(0, dev->iobase + PARPORT_CTRL_REG); | |
| 293 | − | |
| 294 | 301 | return 0; |
| 295 | 302 | } |
| 296 | 303 | |
| @@ -297,31 +297,34 @@ static struct fwnet_fragment_info *fwnet_frag_new( · 296 unmodified lines | ||
| 297 | 297 | if (fi->offset + fi->len == offset) { |
| 298 | 298 | /* The new fragment can be tacked on to the end */ |
| 299 | 299 | /* Did the new fragment plug a hole? */ |
| 300 | − fi2 = list_entry(fi->fi_link.next, | |
| 301 | − struct fwnet_fragment_info, fi_link); | |
| 302 | − if (fi->offset + fi->len == fi2->offset) { | |
| 303 | − /* glue fragments together */ | |
| 304 | − fi->len += len + fi2->len; | |
| 305 | − list_del(&fi2->fi_link); | |
| 306 | − kfree(fi2); | |
| 307 | − } else { | |
| 308 | − fi->len += len; | |
| 300 | + if (!list_is_last(&fi->fi_link, &pd->fi_list)) { | |
| 301 | + fi2 = list_next_entry(fi, fi_link); | |
| 302 | + if (offset + len == fi2->offset) { | |
| 303 | + /* glue fragments together */ | |
| 304 | + fi->len += len + fi2->len; | |
| 305 | + list_del(&fi2->fi_link); | |
| 306 | + kfree(fi2); | |
| 307 | + | |
| 308 | + return fi; | |
| 309 | + } | |
| 309 | 310 | } |
| 311 | + fi->len += len; | |
| 310 | 312 | |
| 311 | 313 | return fi; |
| 312 | 314 | } |
| 313 | 315 | if (offset + len == fi->offset) { |
| 314 | 316 | /* The new fragment can be tacked on to the beginning */ |
| 315 | 317 | /* Did the new fragment plug a hole? */ |
| 316 | − fi2 = list_entry(fi->fi_link.prev, | |
| 317 | − struct fwnet_fragment_info, fi_link); | |
| 318 | − if (fi2->offset + fi2->len == fi->offset) { | |
| 319 | − /* glue fragments together */ | |
| 320 | − fi2->len += fi->len + len; | |
| 321 | − list_del(&fi->fi_link); | |
| 322 | − kfree(fi); | |
| 323 | − | |
| 324 | − return fi2; | |
| 318 | + if (!list_is_first(&fi->fi_link, &pd->fi_list)) { | |
| 319 | + fi2 = list_prev_entry(fi, fi_link); | |
| 320 | + if (fi2->offset + fi2->len == offset) { | |
| 321 | + /* glue fragments together */ | |
| 322 | + fi2->len += fi->len + len; | |
| 323 | + list_del(&fi->fi_link); | |
| 324 | + kfree(fi); | |
| 325 | + | |
| 326 | + return fi2; | |
| 327 | + } | |
| 325 | 328 | } |
| 326 | 329 | fi->offset = offset; |
| 327 | 330 | fi->len += len; |
| @@ -1499,8 +1499,9 @@ int stratix10_svc_async_poll(struct stratix10_svc_chan *chan, · 1498 unmodified lines | ||
| 1499 | 1499 | WARN_ON_ONCE(1); |
| 1500 | 1500 | } |
| 1501 | 1501 | return 0; |
| 1502 | − } else if (handle->res.a0 == INTEL_SIP_SMC_STATUS_BUSY) { | |
| 1503 | − dev_dbg(ctrl->dev, "async message is still in progress\n"); | |
| 1502 | + } else if (handle->res.a0 == INTEL_SIP_SMC_STATUS_BUSY || | |
| 1503 | + handle->res.a0 == INTEL_SIP_SMC_STATUS_NO_RESPONSE) { | |
| 1504 | + dev_dbg(ctrl->dev, "async message is not ready yet\n"); | |
| 1504 | 1505 | return -EAGAIN; |
| 1505 | 1506 | } |
| 1506 | 1507 | |
| @@ -1857,14 +1858,16 @@ void *stratix10_svc_allocate_memory(struct stratix10_svc_chan *chan, · 350 unmodified lines | ||
| 1857 | 1858 | struct gen_pool *genpool = chan->ctrl->genpool; |
| 1858 | 1859 | size_t s = roundup(size, 1 << genpool->min_alloc_order); |
| 1859 | 1860 | |
| 1860 | − pmem = devm_kzalloc(chan->ctrl->dev, sizeof(*pmem), GFP_KERNEL); | |
| 1861 | + pmem = kzalloc_obj(*pmem); | |
| 1861 | 1862 | if (!pmem) |
| 1862 | 1863 | return ERR_PTR(-ENOMEM); |
| 1863 | 1864 | |
| 1864 | 1865 | guard(mutex)(&svc_mem_lock); |
| 1865 | 1866 | va = gen_pool_alloc(genpool, s); |
| 1866 | − if (!va) | |
| 1867 | + if (!va) { | |
| 1868 | + kfree(pmem); | |
| 1867 | 1869 | return ERR_PTR(-ENOMEM); |
| 1870 | + } | |
| 1868 | 1871 | |
| 1869 | 1872 | memset((void *)va, 0, s); |
| 1870 | 1873 | pa = gen_pool_virt_to_phys(genpool, va); |
| @@ -1890,6 +1893,7 @@ EXPORT_SYMBOL_GPL(stratix10_svc_allocate_memory); · 19 unmodified lines | ||
| 1890 | 1893 | void stratix10_svc_free_memory(struct stratix10_svc_chan *chan, void *kaddr) |
| 1891 | 1894 | { |
| 1892 | 1895 | struct stratix10_svc_data_mem *pmem; |
| 1896 | + | |
| 1893 | 1897 | guard(mutex)(&svc_mem_lock); |
| 1894 | 1898 | |
| 1895 | 1899 | list_for_each_entry(pmem, &svc_data_mem, node) |
| @@ -1898,10 +1902,9 @@ void stratix10_svc_free_memory(struct stratix10_svc_chan *chan, void *kaddr) · 2 unmodified lines | ||
| 1898 | 1902 | (unsigned long)kaddr, pmem->size); |
| 1899 | 1903 | pmem->vaddr = NULL; |
| 1900 | 1904 | list_del(&pmem->node); |
| 1905 | + kfree(pmem); | |
| 1901 | 1906 | return; |
| 1902 | 1907 | } |
| 1903 | − | |
| 1904 | − list_del(&svc_data_mem); | |
| 1905 | 1908 | } |
| 1906 | 1909 | EXPORT_SYMBOL_GPL(stratix10_svc_free_memory); |
| 1907 | 1910 | |
| @@ -2046,12 +2049,12 @@ static void stratix10_svc_drv_remove(struct platform_device *pdev) · 138 unmodified lines | ||
| 2046 | 2049 | struct stratix10_svc_controller *ctrl = platform_get_drvdata(pdev); |
| 2047 | 2050 | struct stratix10_svc *svc = ctrl->svc; |
| 2048 | 2051 | |
| 2052 | + platform_device_unregister(svc->stratix10_svc_rsu); | |
| 2053 | + | |
| 2049 | 2054 | stratix10_svc_async_exit(ctrl); |
| 2050 | 2055 | |
| 2051 | 2056 | of_platform_depopulate(ctrl->dev); |
| 2052 | 2057 | |
| 2053 | − platform_device_unregister(svc->stratix10_svc_rsu); | |
| 2054 | − | |
| 2055 | 2058 | for (i = 0; i < SVC_NUM_CHANNEL; i++) { |
| 2056 | 2059 | if (ctrl->chans[i].task) { |
| 2057 | 2060 | kthread_stop(ctrl->chans[i].task); |
| @@ -3324,7 +3324,8 @@ static void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev, · 3323 unmodified lines | ||
| 3324 | 3324 | acrtc = get_crtc_by_otg_inst( |
| 3325 | 3325 | adev, state->stream_status[i].primary_otg_inst); |
| 3326 | 3326 | |
| 3327 | − if (acrtc && state->stream_status[i].plane_count != 0) { | |
| 3327 | + if (acrtc && state->stream_status[i].plane_count != 0 && | |
| 3328 | + amdgpu_ip_version(adev, DCE_HWIP, 0) == 0) { | |
| 3328 | 3329 | irq_source = IRQ_TYPE_PFLIP + acrtc->otg_inst; |
| 3329 | 3330 | rc = dc_interrupt_set(adev->dm.dc, irq_source, enable) ? 0 : -EBUSY; |
| 3330 | 3331 | if (rc) |
| @@ -280,10 +280,19 @@ static inline int amdgpu_dm_crtc_set_vblank(struct drm_crtc *crtc, bool enable) · 279 unmodified lines | ||
| 280 | 280 | * is enabled. On DCE, vupdate is only needed in VRR mode. |
| 281 | 281 | */ |
| 282 | 282 | if (amdgpu_ip_version(adev, DCE_HWIP, 0) != 0) { |
| 283 | − rc = amdgpu_dm_crtc_set_vupdate_irq(crtc, enable); | |
| 283 | + if (enable) { | |
| 284 | + rc = amdgpu_irq_get(adev, &adev->vupdate_irq, irq_type); | |
| 285 | + drm_dbg_vbl(crtc->dev, "Get vupdate_irq ret=%d\n", rc); | |
| 286 | + } else { | |
| 287 | + rc = amdgpu_irq_put(adev, &adev->vupdate_irq, irq_type); | |
| 288 | + drm_dbg_vbl(crtc->dev, "Put vupdate_irq ret=%d\n", rc); | |
| 289 | + } | |
| 284 | 290 | } else if (dc_supports_vrr(dm->dc->ctx->dce_version)) { |
| 285 | 291 | if (enable) { |
| 286 | − /* vblank irq on -> Only need vupdate irq in vrr mode */ | |
| 292 | + /* vblank irq on -> Only need vupdate irq in vrr mode | |
| 293 | + * Not ref-counted since we need explicit enable/disable | |
| 294 | + * for DCE VRR handling | |
| 295 | + */ | |
| 287 | 296 | if (amdgpu_dm_crtc_vrr_active(acrtc_state)) |
| 288 | 297 | rc = amdgpu_dm_crtc_set_vupdate_irq(crtc, true); |
| 289 | 298 | } else { |
| @@ -781,7 +781,7 @@ enum drm_gpusvm_scan_result drm_gpusvm_scan_mm(struct drm_gpusvm_range *range, · 780 unmodified lines | ||
| 781 | 781 | const struct dev_pagemap *other = NULL; |
| 782 | 782 | int err, i; |
| 783 | 783 | |
| 784 | − pfns = kvmalloc_array(npages, sizeof(*pfns), GFP_KERNEL); | |
| 784 | + pfns = kvcalloc(npages, sizeof(*pfns), GFP_KERNEL); | |
| 785 | 785 | if (!pfns) |
| 786 | 786 | return DRM_GPUSVM_SCAN_UNPOPULATED; |
| 787 | 787 | |
| @@ -1753,8 +1753,10 @@ int drm_gpusvm_range_evict(struct drm_gpusvm *gpusvm, · 965 unmodified lines | ||
| 1753 | 1753 | return -EFAULT; |
| 1754 | 1754 | |
| 1755 | 1755 | pfns = kvmalloc_array(npages, sizeof(*pfns), GFP_KERNEL); |
| 1756 | − if (!pfns) | |
| 1756 | + if (!pfns) { | |
| 1757 | + mmput(mm); | |
| 1757 | 1758 | return -ENOMEM; |
| 1759 | + } | |
| 1758 | 1760 | |
| 1759 | 1761 | hmm_range.hmm_pfns = pfns; |
| 1760 | 1762 | while (!time_after(jiffies, timeout)) { |
| @@ -727,8 +727,10 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation, · 726 unmodified lines | ||
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | err = ops->populate_devmem_pfn(devmem_allocation, npages, migrate.dst); |
| 730 | − if (err) | |
| 731 | − goto err_aborted_migration; | |
| 730 | + if (err) { | |
| 731 | + npages = 0; | |
| 732 | + goto err_finalize; | |
| 733 | + } | |
| 732 | 734 | |
| 733 | 735 | own_pages = 0; |
| 734 | 736 | |
| @@ -807,8 +809,11 @@ next: · 72 unmodified lines | ||
| 807 | 809 | msecs_to_jiffies(mdetails->timeslice_ms); |
| 808 | 810 | |
| 809 | 811 | err_finalize: |
| 810 | − if (err) | |
| 812 | + if (err) { | |
| 811 | 813 | drm_pagemap_migration_unlock_put_pages(npages, migrate.dst); |
| 814 | + for (i = npages; i < npages_in_range(start, end); ++i) | |
| 815 | + migrate.dst[i] = 0; | |
| 816 | + } | |
| 812 | 817 | err_aborted_migration: |
| 813 | 818 | migrate_vma_pages(&migrate); |
| 814 | 819 | |
| @@ -98,6 +98,7 @@ static int xfer_read(struct i2c_adapter *adap, struct i2c_msg *pmsg) · 97 unmodified lines | ||
| 98 | 98 | struct oaktrail_hdmi_dev *hdmi_dev = i2c_get_adapdata(adap); |
| 99 | 99 | struct hdmi_i2c_dev *i2c_dev = hdmi_dev->i2c_dev; |
| 100 | 100 | u32 temp; |
| 101 | + int ret; | |
| 101 | 102 | |
| 102 | 103 | i2c_dev->status = I2C_STAT_INIT; |
| 103 | 104 | i2c_dev->msg = pmsg; |
| @@ -109,9 +110,14 @@ static int xfer_read(struct i2c_adapter *adap, struct i2c_msg *pmsg) · 5 unmodified lines | ||
| 109 | 110 | HDMI_WRITE(HDMI_HI2CHCR, temp); |
| 110 | 111 | HDMI_READ(HDMI_HI2CHCR); |
| 111 | 112 | |
| 112 | − while (i2c_dev->status != I2C_TRANSACTION_DONE) | |
| 113 | − wait_for_completion_interruptible_timeout(&i2c_dev->complete, | |
| 113 | + while (i2c_dev->status != I2C_TRANSACTION_DONE) { | |
| 114 | + ret = wait_for_completion_interruptible_timeout(&i2c_dev->complete, | |
| 114 | 115 | 10 * HZ); |
| 116 | + if (ret < 0) | |
| 117 | + return ret; | |
| 118 | + if (!ret) | |
| 119 | + return -ETIMEDOUT; | |
| 120 | + } | |
| 115 | 121 | |
| 116 | 122 | return 0; |
| 117 | 123 | } |
| @@ -130,7 +136,7 @@ static int oaktrail_hdmi_i2c_access(struct i2c_adapter *adap, · 12 unmodified lines | ||
| 130 | 136 | { |
| 131 | 137 | struct oaktrail_hdmi_dev *hdmi_dev = i2c_get_adapdata(adap); |
| 132 | 138 | struct hdmi_i2c_dev *i2c_dev = hdmi_dev->i2c_dev; |
| 133 | − int i; | |
| 139 | + int i, ret = 0; | |
| 134 | 140 | |
| 135 | 141 | mutex_lock(&i2c_dev->i2c_lock); |
| 136 | 142 | |
| @@ -142,9 +148,11 @@ static int oaktrail_hdmi_i2c_access(struct i2c_adapter *adap, · 5 unmodified lines | ||
| 142 | 148 | for (i = 0; i < num; i++) { |
| 143 | 149 | if (pmsg->len && pmsg->buf) { |
| 144 | 150 | if (pmsg->flags & I2C_M_RD) |
| 145 | − xfer_read(adap, pmsg); | |
| 151 | + ret = xfer_read(adap, pmsg); | |
| 146 | 152 | else |
| 147 | − xfer_write(adap, pmsg); | |
| 153 | + ret = xfer_write(adap, pmsg); | |
| 154 | + if (ret) | |
| 155 | + break; | |
| 148 | 156 | } |
| 149 | 157 | pmsg++; /* next message */ |
| 150 | 158 | } |
| @@ -154,6 +162,9 @@ static int oaktrail_hdmi_i2c_access(struct i2c_adapter *adap, · 3 unmodified lines | ||
| 154 | 162 | |
| 155 | 163 | mutex_unlock(&i2c_dev->i2c_lock); |
| 156 | 164 | |
| 165 | + if (ret) | |
| 166 | + return ret; | |
| 167 | + | |
| 157 | 168 | return i; |
| 158 | 169 | } |
| 159 | 170 | |
| @@ -615,12 +615,7 @@ check_if_vesa_backlight_possible(struct intel_dp *intel_dp) · 614 unmodified lines | ||
| 615 | 615 | int ret; |
| 616 | 616 | u8 bit_min, bit_max; |
| 617 | 617 | |
| 618 | − /* | |
| 619 | − * Since we only support Fully AUX Based VESA Backlight interface make sure | |
| 620 | − * backlight enable is possible via AUX along with backlight adjustment | |
| 621 | − */ | |
| 622 | − if (!(intel_dp->edp_dpcd[1] & DP_EDP_BACKLIGHT_AUX_ENABLE_CAP && | |
| 623 | − intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP)) | |
| 618 | + if (!(intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP)) | |
| 624 | 619 | return false; |
| 625 | 620 | |
| 626 | 621 | ret = drm_dp_dpcd_read_byte(&intel_dp->aux, DP_EDP_PWMGEN_BIT_COUNT_CAP_MIN, &bit_min); |
| @@ -747,6 +747,7 @@ pvr_vm_map(struct pvr_vm_context *vm_ctx, struct pvr_gem_object *pvr_obj, · 746 unmodified lines | ||
| 747 | 747 | |
| 748 | 748 | pvr_gem_object_get(pvr_obj); |
| 749 | 749 | |
| 750 | + mutex_lock(&vm_ctx->lock); | |
| 750 | 751 | err = drm_gpuvm_exec_lock(&vm_exec); |
| 751 | 752 | if (err) |
| 752 | 753 | goto err_cleanup; |
| @@ -756,6 +757,7 @@ pvr_vm_map(struct pvr_vm_context *vm_ctx, struct pvr_gem_object *pvr_obj, · 3 unmodified lines | ||
| 756 | 757 | drm_gpuvm_exec_unlock(&vm_exec); |
| 757 | 758 | |
| 758 | 759 | err_cleanup: |
| 760 | + mutex_unlock(&vm_ctx->lock); | |
| 759 | 761 | pvr_vm_bind_op_fini(&bind_op); |
| 760 | 762 | |
| 761 | 763 | return err; |
| @@ -232,6 +232,7 @@ config DRM_PANEL_HIMAX_HX83121A · 231 unmodified lines | ||
| 232 | 232 | depends on OF |
| 233 | 233 | depends on DRM_MIPI_DSI |
| 234 | 234 | depends on BACKLIGHT_CLASS_DEVICE |
| 235 | + select DRM_DISPLAY_HELPER | |
| 235 | 236 | select DRM_DISPLAY_DSC_HELPER |
| 236 | 237 | select DRM_KMS_HELPER |
| 237 | 238 | help |
| @@ -332,6 +333,7 @@ config DRM_PANEL_ILITEK_ILI9882T · 94 unmodified lines | ||
| 332 | 333 | depends on OF |
| 333 | 334 | depends on DRM_MIPI_DSI |
| 334 | 335 | depends on BACKLIGHT_CLASS_DEVICE |
| 336 | + select DRM_DISPLAY_HELPER | |
| 335 | 337 | select DRM_DISPLAY_DSC_HELPER |
| 336 | 338 | help |
| 337 | 339 | Say Y if you want to enable support for panels based on the |
| @@ -954,6 +956,7 @@ config DRM_PANEL_SAMSUNG_S6E3HA8 · 616 unmodified lines | ||
| 954 | 956 | depends on OF |
| 955 | 957 | depends on DRM_MIPI_DSI |
| 956 | 958 | depends on BACKLIGHT_CLASS_DEVICE |
| 959 | + select DRM_DISPLAY_HELPER | |
| 957 | 960 | select DRM_DISPLAY_DSC_HELPER |
| 958 | 961 | help |
| 959 | 962 | Say Y or M here if you want to enable support for the |
| @@ -2562,9 +2562,12 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi) · 2561 unmodified lines | ||
| 2562 | 2562 | "Couldn't get our power regulator\n"); |
| 2563 | 2563 | |
| 2564 | 2564 | ctx->iovcc = devm_regulator_get_optional(&dsi->dev, "iovcc"); |
| 2565 | − if (IS_ERR(ctx->iovcc)) | |
| 2566 | − return dev_err_probe(&dsi->dev, PTR_ERR(ctx->iovcc), | |
| 2565 | + if (IS_ERR(ctx->iovcc)) { | |
| 2566 | + if (PTR_ERR(ctx->iovcc) != -ENODEV) | |
| 2567 | + return dev_err_probe(&dsi->dev, PTR_ERR(ctx->iovcc), | |
| 2567 | 2568 | "Couldn't get our iovcc regulator\n"); |
| 2569 | + ctx->iovcc = NULL; | |
| 2570 | + } | |
| 2568 | 2571 | |
| 2569 | 2572 | ctx->reset = devm_gpiod_get_optional(&dsi->dev, "reset", GPIOD_OUT_LOW); |
| 2570 | 2573 | if (IS_ERR(ctx->reset)) |
| @@ -95,13 +95,9 @@ static void drm_gem_shmem_test_obj_create_private(struct kunit *test) · 94 unmodified lines | ||
| 95 | 95 | sg_init_one(sgt->sgl, buf, TEST_SIZE); |
| 96 | 96 | |
| 97 | 97 | /* |
| 98 | − * Set the DMA mask to 64-bits and map the sgtables | |
| 99 | − * otherwise drm_gem_shmem_free will cause a warning | |
| 100 | − * on debug kernels. | |
| 98 | + * Map the sgtables otherwise drm_gem_shmem_free will cause a warning on | |
| 99 | + * debug kernels. | |
| 101 | 100 | */ |
| 102 | − ret = dma_set_mask(drm_dev->dev, DMA_BIT_MASK(64)); | |
| 103 | − KUNIT_ASSERT_EQ(test, ret, 0); | |
| 104 | − | |
| 105 | 101 | ret = dma_map_sgtable(drm_dev->dev, sgt, DMA_BIDIRECTIONAL, 0); |
| 106 | 102 | KUNIT_ASSERT_EQ(test, ret, 0); |
| 107 | 103 | |
| @@ -352,11 +348,19 @@ static int drm_gem_shmem_test_init(struct kunit *test) · 244 unmodified lines | ||
| 352 | 348 | { |
| 353 | 349 | struct device *dev; |
| 354 | 350 | struct drm_device *drm_dev; |
| 351 | + int ret; | |
| 355 | 352 | |
| 356 | 353 | /* Allocate a parent device */ |
| 357 | 354 | dev = drm_kunit_helper_alloc_device(test); |
| 358 | 355 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); |
| 359 | 356 | |
| 357 | + /* | |
| 358 | + * Set the DMA mask to 64-bits to avoid intermittent failures calling | |
| 359 | + * drm_gem_shmem_get_pages_sgt(). | |
| 360 | + */ | |
| 361 | + ret = dma_set_mask(dev, DMA_BIT_MASK(64)); | |
| 362 | + KUNIT_ASSERT_EQ(test, ret, 0); | |
| 363 | + | |
| 360 | 364 | /* |
| 361 | 365 | * The DRM core will automatically initialize the GEM core and create |
| 362 | 366 | * a DRM Memory Manager object which provides an address space pool |
| @@ -315,33 +315,16 @@ static const u32 appletbdrm_primary_plane_formats[] = { · 314 unmodified lines | ||
| 315 | 315 | DRM_FORMAT_XRGB8888, /* emulated */ |
| 316 | 316 | }; |
| 317 | 317 | |
| 318 | −static int appletbdrm_primary_plane_helper_atomic_check(struct drm_plane *plane, | |
| 319 | − struct drm_atomic_commit *state) | |
| 318 | +static int appletbdrm_primary_plane_helper_begin_fb_access(struct drm_plane *plane, | |
| 319 | + struct drm_plane_state *new_plane_state) | |
| 320 | 320 | { |
| 321 | − struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane); | |
| 322 | − struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane); | |
| 323 | − struct drm_crtc *new_crtc = new_plane_state->crtc; | |
| 324 | − struct drm_crtc_state *new_crtc_state = NULL; | |
| 325 | 321 | struct appletbdrm_plane_state *appletbdrm_state = to_appletbdrm_plane_state(new_plane_state); |
| 322 | + size_t frames_size = 0; | |
| 326 | 323 | struct drm_atomic_helper_damage_iter iter; |
| 327 | 324 | struct drm_rect damage; |
| 328 | − size_t frames_size = 0; | |
| 329 | 325 | size_t request_size; |
| 330 | − int ret; | |
| 331 | − | |
| 332 | − if (new_crtc) | |
| 333 | − new_crtc_state = drm_atomic_get_new_crtc_state(state, new_crtc); | |
| 334 | 326 | |
| 335 | − ret = drm_atomic_helper_check_plane_state(new_plane_state, new_crtc_state, | |
| 336 | − DRM_PLANE_NO_SCALING, | |
| 337 | − DRM_PLANE_NO_SCALING, | |
| 338 | − false, false); | |
| 339 | − if (ret) | |
| 340 | − return ret; | |
| 341 | − else if (!new_plane_state->visible) | |
| 342 | − return 0; | |
| 343 | − | |
| 344 | − drm_atomic_helper_damage_iter_init(&iter, old_plane_state, new_plane_state); | |
| 327 | + drm_atomic_helper_damage_iter_init(&iter, plane->state, new_plane_state); | |
| 345 | 328 | drm_atomic_for_each_plane_damage(&iter, &damage) { |
| 346 | 329 | frames_size += struct_size((struct appletbdrm_frame *)0, buf, rect_size(&damage)); |
| 347 | 330 | } |
| @@ -366,6 +349,29 @@ static int appletbdrm_primary_plane_helper_atomic_check(struct drm_plane *plane, · 18 unmodified lines | ||
| 366 | 349 | appletbdrm_state->request_size = request_size; |
| 367 | 350 | appletbdrm_state->frames_size = frames_size; |
| 368 | 351 | |
| 352 | + return drm_gem_begin_shadow_fb_access(plane, new_plane_state); | |
| 353 | +} | |
| 354 | + | |
| 355 | +static int appletbdrm_primary_plane_helper_atomic_check(struct drm_plane *plane, | |
| 356 | + struct drm_atomic_commit *state) | |
| 357 | +{ | |
| 358 | + struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane); | |
| 359 | + struct drm_crtc *new_crtc = new_plane_state->crtc; | |
| 360 | + struct drm_crtc_state *new_crtc_state = NULL; | |
| 361 | + int ret; | |
| 362 | + | |
| 363 | + if (new_crtc) | |
| 364 | + new_crtc_state = drm_atomic_get_new_crtc_state(state, new_crtc); | |
| 365 | + | |
| 366 | + ret = drm_atomic_helper_check_plane_state(new_plane_state, new_crtc_state, | |
| 367 | + DRM_PLANE_NO_SCALING, | |
| 368 | + DRM_PLANE_NO_SCALING, | |
| 369 | + false, false); | |
| 370 | + if (ret) | |
| 371 | + return ret; | |
| 372 | + else if (!new_plane_state->visible) | |
| 373 | + return 0; | |
| 374 | + | |
| 369 | 375 | return 0; |
| 370 | 376 | } |
| 371 | 377 | |
| @@ -468,7 +474,7 @@ end_fb_cpu_access: · 96 unmodified lines | ||
| 468 | 474 | } |
| 469 | 475 | |
| 470 | 476 | static void appletbdrm_primary_plane_helper_atomic_update(struct drm_plane *plane, |
| 471 | − struct drm_atomic_commit *old_state) | |
| 477 | + struct drm_atomic_commit *old_state) | |
| 472 | 478 | { |
| 473 | 479 | struct appletbdrm_device *adev = drm_to_adev(plane->dev); |
| 474 | 480 | struct drm_device *drm = plane->dev; |
| @@ -552,7 +558,8 @@ static void appletbdrm_primary_plane_destroy_state(struct drm_plane *plane, · 77 unmodified lines | ||
| 552 | 558 | } |
| 553 | 559 | |
| 554 | 560 | static const struct drm_plane_helper_funcs appletbdrm_primary_plane_helper_funcs = { |
| 555 | − DRM_GEM_SHADOW_PLANE_HELPER_FUNCS, | |
| 561 | + .begin_fb_access = appletbdrm_primary_plane_helper_begin_fb_access, | |
| 562 | + .end_fb_access = drm_gem_end_shadow_fb_access, | |
| 556 | 563 | .atomic_check = appletbdrm_primary_plane_helper_atomic_check, |
| 557 | 564 | .atomic_update = appletbdrm_primary_plane_helper_atomic_update, |
| 558 | 565 | .atomic_disable = appletbdrm_primary_plane_helper_atomic_disable, |
| @@ -6,9 +6,10 @@ · 5 unmodified lines | ||
| 6 | 6 | #include <drm/ttm/ttm_backup.h> |
| 7 | 7 | |
| 8 | 8 | #include <linux/export.h> |
| 9 | −#include <linux/page-flags.h> | |
| 10 | 9 | #include <linux/swap.h> |
| 11 | 10 | |
| 11 | +#include "ttm_pool_internal.h" | |
| 12 | + | |
| 12 | 13 | /* |
| 13 | 14 | * Need to map shmem indices to handle since a handle value |
| 14 | 15 | * of 0 means error, following the swp_entry_t convention. |
| @@ -68,17 +69,23 @@ int ttm_backup_copy_page(struct file *backup, struct page *dst, · 53 unmodified lines | ||
| 68 | 69 | } |
| 69 | 70 | |
| 70 | 71 | /** |
| 71 | − * ttm_backup_backup_page() - Backup a page | |
| 72 | + * ttm_backup_backup_folio() - Backup a folio | |
| 72 | 73 | * @backup: The struct backup pointer to use. |
| 73 | − * @page: The page to back up. | |
| 74 | − * @writeback: Whether to perform immediate writeback of the page. | |
| 74 | + * @folio: The folio to back up. | |
| 75 | + * @order: The allocation order of @folio. Since TTM allocates higher-order | |
| 76 | + * pages without __GFP_COMP, folio_nr_pages(@folio) would always | |
| 77 | + * return 1; the caller must pass the true order explicitly. | |
| 78 | + * @writeback: Whether to perform immediate writeback of the folio's pages. | |
| 75 | 79 | * This may have performance implications. |
| 76 | − * @idx: A unique integer for each page and each struct backup. | |
| 80 | + * @idx: A unique integer for the first page of the folio and each struct backup. | |
| 77 | 81 | * This allows the backup implementation to avoid managing |
| 78 | 82 | * its address space separately. |
| 79 | − * @page_gfp: The gfp value used when the page was allocated. | |
| 80 | − * This is used for accounting purposes. | |
| 83 | + * @folio_gfp: The gfp value used when the folio was allocated. | |
| 84 | + * Currently unused. | |
| 81 | 85 | * @alloc_gfp: The gfp to be used when allocating memory. |
| 86 | + * @nr_pages_backed: Output. On a successful return, set to the number of | |
| 87 | + * pages actually backed up, which may be less than (1 << @order) | |
| 88 | + * if an -ENOMEM was encountered mid-folio. | |
| 82 | 89 | * |
| 83 | 90 | * Context: If called from reclaim context, the caller needs to |
| 84 | 91 | * assert that the shrinker gfp has __GFP_FS set, to avoid |
| @@ -87,53 +94,87 @@ int ttm_backup_copy_page(struct file *backup, struct page *dst, · 2 unmodified lines | ||
| 87 | 94 | * that the shrinker gfp has __GFP_IO set, since without it, |
| 88 | 95 | * we're not allowed to start backup IO. |
| 89 | 96 | * |
| 90 | − * Return: A handle on success. Negative error code on failure. | |
| 91 | − * | |
| 92 | − * Note: This function could be extended to back up a folio and | |
| 93 | − * implementations would then split the folio internally if needed. | |
| 94 | − * Drawback is that the caller would then have to keep track of | |
| 95 | − * the folio size- and usage. | |
| 97 | + * Return: A handle for the first backed-up page on success (handles for | |
| 98 | + * subsequent pages follow sequentially). -ENOMEM if no pages could be backed | |
| 99 | + * up. Any other negative error code if a non-ENOMEM failure occurred; in that | |
| 100 | + * case any pages backed up so far are truncated before returning. | |
| 96 | 101 | */ |
| 97 | 102 | s64 |
| 98 | −ttm_backup_backup_page(struct file *backup, struct page *page, | |
| 99 | − bool writeback, pgoff_t idx, gfp_t page_gfp, | |
| 100 | − gfp_t alloc_gfp) | |
| 103 | +ttm_backup_backup_folio(struct file *backup, struct folio *folio, | |
| 104 | + unsigned int order, bool writeback, pgoff_t idx, | |
| 105 | + gfp_t folio_gfp, gfp_t alloc_gfp, | |
| 106 | + pgoff_t *nr_pages_backed) | |
| 101 | 107 | { |
| 102 | 108 | struct address_space *mapping = backup->f_mapping; |
| 103 | − unsigned long handle = 0; | |
| 109 | + int nr_pages = 1 << order; | |
| 104 | 110 | struct folio *to_folio; |
| 105 | − int ret; | |
| 106 | − | |
| 107 | − to_folio = shmem_read_folio_gfp(mapping, idx, alloc_gfp); | |
| 108 | − if (IS_ERR(to_folio)) | |
| 109 | − return PTR_ERR(to_folio); | |
| 110 | − | |
| 111 | − folio_mark_accessed(to_folio); | |
| 112 | − folio_lock(to_folio); | |
| 113 | − folio_mark_dirty(to_folio); | |
| 114 | − copy_highpage(folio_file_page(to_folio, idx), page); | |
| 115 | − handle = ttm_backup_shmem_idx_to_handle(idx); | |
| 116 | − | |
| 117 | − if (writeback && !folio_mapped(to_folio) && | |
| 118 | − folio_clear_dirty_for_io(to_folio)) { | |
| 119 | − folio_set_reclaim(to_folio); | |
| 120 | − ret = shmem_writeout(to_folio, NULL, NULL); | |
| 121 | − if (!folio_test_writeback(to_folio)) | |
| 122 | − folio_clear_reclaim(to_folio); | |
| 111 | + int ret, i; | |
| 112 | + | |
| 113 | + *nr_pages_backed = 0; | |
| 114 | + | |
| 115 | + for (i = 0; i < nr_pages; ) { | |
| 116 | + int to_nr, j; | |
| 117 | + | |
| 123 | 118 | /* |
| 124 | − * If writeout succeeds, it unlocks the folio. errors | |
| 125 | − * are otherwise dropped, since writeout is only best | |
| 126 | − * effort here. | |
| 119 | + * Only inject past the first subpage so *nr_pages_backed is | |
| 120 | + * always > 0 here, matching a genuine mid-compound -ENOMEM | |
| 121 | + * and driving the caller's reactive split fallback instead | |
| 122 | + * of an early, no-progress failure. | |
| 127 | 123 | */ |
| 128 | − if (ret) | |
| 124 | + if (IS_ENABLED(CONFIG_FAULT_INJECTION) && i && | |
| 125 | + ttm_backup_fault_inject_folio()) | |
| 126 | + to_folio = ERR_PTR(-ENOMEM); | |
| 127 | + else | |
| 128 | + to_folio = shmem_read_folio_gfp(mapping, idx + i, alloc_gfp); | |
| 129 | + if (IS_ERR(to_folio)) { | |
| 130 | + int err = PTR_ERR(to_folio); | |
| 131 | + | |
| 132 | + if (err == -ENOMEM && *nr_pages_backed) | |
| 133 | + return ttm_backup_shmem_idx_to_handle(idx); | |
| 134 | + | |
| 135 | + if (*nr_pages_backed) { | |
| 136 | + shmem_truncate_range(file_inode(backup), | |
| 137 | + (loff_t)idx << PAGE_SHIFT, | |
| 138 | + ((loff_t)(idx + i) << PAGE_SHIFT) - 1); | |
| 139 | + /* | |
| 140 | + * The pages just truncated are no longer | |
| 141 | + * backed up; don't let the caller mistake | |
| 142 | + * them for valid handles. | |
| 143 | + */ | |
| 144 | + *nr_pages_backed = 0; | |
| 145 | + } | |
| 146 | + return err; | |
| 147 | + } | |
| 148 | + | |
| 149 | + to_nr = min_t(int, nr_pages - i, | |
| 150 | + folio_next_index(to_folio) - (idx + i)); | |
| 151 | + | |
| 152 | + folio_mark_accessed(to_folio); | |
| 153 | + folio_lock(to_folio); | |
| 154 | + folio_mark_dirty(to_folio); | |
| 155 | + | |
| 156 | + for (j = 0; j < to_nr; j++) | |
| 157 | + copy_highpage(folio_file_page(to_folio, idx + i + j), | |
| 158 | + folio_page(folio, i + j)); | |
| 159 | + | |
| 160 | + if (writeback && !folio_mapped(to_folio) && | |
| 161 | + folio_clear_dirty_for_io(to_folio)) { | |
| 162 | + folio_set_reclaim(to_folio); | |
| 163 | + ret = shmem_writeout(to_folio, NULL, NULL); | |
| 164 | + if (!folio_test_writeback(to_folio)) | |
| 165 | + folio_clear_reclaim(to_folio); | |
| 166 | + if (ret == AOP_WRITEPAGE_ACTIVATE) | |
| 167 | + folio_unlock(to_folio); | |
| 168 | + } else { | |
| 129 | 169 | folio_unlock(to_folio); |
| 130 | − } else { | |
| 131 | − folio_unlock(to_folio); | |
| 132 | − } | |
| 170 | + } | |
| 133 | 171 | |
| 134 | − folio_put(to_folio); | |
| 172 | + folio_put(to_folio); | |
| 173 | + i += to_nr; | |
| 174 | + *nr_pages_backed = i; | |
| 175 | + } | |
| 135 | 176 | |
| 136 | − return handle; | |
| 177 | + return ttm_backup_shmem_idx_to_handle(idx); | |
| 137 | 178 | } |
| 138 | 179 | |
| 139 | 180 | /** |
| @@ -53,8 +53,23 @@ · 52 unmodified lines | ||
| 53 | 53 | #ifdef CONFIG_FAULT_INJECTION |
| 54 | 54 | #include <linux/fault-inject.h> |
| 55 | 55 | static DECLARE_FAULT_ATTR(backup_fault_inject); |
| 56 | + | |
| 57 | +/* | |
| 58 | + * Exposed to ttm_backup.c so a mid-compound subpage can be made to fail | |
| 59 | + * with -ENOMEM, exercising the reactive split-and-retry fallback in | |
| 60 | + * ttm_pool_backup() for high-order backups. | |
| 61 | + */ | |
| 62 | +bool ttm_backup_fault_inject_folio(void) | |
| 63 | +{ | |
| 64 | + return should_fail(&backup_fault_inject, 1); | |
| 65 | +} | |
| 56 | 66 | #else |
| 57 | 67 | #define should_fail(...) false |
| 68 | + | |
| 69 | +bool ttm_backup_fault_inject_folio(void) | |
| 70 | +{ | |
| 71 | + return false; | |
| 72 | +} | |
| 58 | 73 | #endif |
| 59 | 74 | |
| 60 | 75 | /** |
| @@ -487,7 +502,7 @@ static void ttm_pool_split_for_swap(struct ttm_pool *pool, struct page *p) · 426 unmodified lines | ||
| 487 | 502 | /** |
| 488 | 503 | * DOC: Partial backup and restoration of a struct ttm_tt. |
| 489 | 504 | * |
| 490 | − * Swapout using ttm_backup_backup_page() and swapin using | |
| 505 | + * Swapout using ttm_backup_backup_folio() and swapin using | |
| 491 | 506 | * ttm_backup_copy_page() may fail. |
| 492 | 507 | * The former most likely due to lack of swap-space or memory, the latter due |
| 493 | 508 | * to lack of memory or because of signal interruption during waits. |
| @@ -1036,12 +1051,12 @@ long ttm_pool_backup(struct ttm_pool *pool, struct ttm_tt *tt, · 542 unmodified lines | ||
| 1036 | 1051 | { |
| 1037 | 1052 | struct file *backup = tt->backup; |
| 1038 | 1053 | struct page *page; |
| 1039 | − unsigned long handle; | |
| 1040 | 1054 | gfp_t alloc_gfp; |
| 1041 | 1055 | gfp_t gfp; |
| 1042 | 1056 | int ret = 0; |
| 1043 | 1057 | pgoff_t shrunken = 0; |
| 1044 | − pgoff_t i, num_pages; | |
| 1058 | + pgoff_t i, j, num_pages, npages; | |
| 1059 | + pgoff_t nr_backed; | |
| 1045 | 1060 | |
| 1046 | 1061 | if (WARN_ON(ttm_tt_is_backed_up(tt))) |
| 1047 | 1062 | return -EINVAL; |
| @@ -1119,9 +1134,11 @@ long ttm_pool_backup(struct ttm_pool *pool, struct ttm_tt *tt, · 71 unmodified lines | ||
| 1119 | 1134 | if (IS_ENABLED(CONFIG_FAULT_INJECTION) && should_fail(&backup_fault_inject, 1)) |
| 1120 | 1135 | num_pages = DIV_ROUND_UP(num_pages, 2); |
| 1121 | 1136 | |
| 1122 | − for (i = 0; i < num_pages; ++i) { | |
| 1123 | − s64 shandle; | |
| 1137 | + for (i = 0; i < num_pages; i += npages) { | |
| 1138 | + unsigned int order; | |
| 1139 | + s64 handle; | |
| 1124 | 1140 | |
| 1141 | + npages = 1; | |
| 1125 | 1142 | page = tt->pages[i]; |
| 1126 | 1143 | if (unlikely(!page)) |
| 1127 | 1144 | continue; |
| @@ -1130,19 +1147,61 @@ long ttm_pool_backup(struct ttm_pool *pool, struct ttm_tt *tt, · 2 unmodified lines | ||
| 1130 | 1147 | if (unlikely(ttm_backup_page_ptr_is_handle(page))) |
| 1131 | 1148 | continue; |
| 1132 | 1149 | |
| 1133 | − ttm_pool_split_for_swap(pool, page); | |
| 1150 | + order = ttm_pool_page_order(pool, page); | |
| 1151 | + npages = 1UL << order; | |
| 1152 | + | |
| 1153 | + /* | |
| 1154 | + * We don't allow dipping kernel reserves for high order backup | |
| 1155 | + */ | |
| 1156 | + if (order) | |
| 1157 | + alloc_gfp |= __GFP_NOMEMALLOC; | |
| 1158 | + else | |
| 1159 | + alloc_gfp &= ~__GFP_NOMEMALLOC; | |
| 1160 | + | |
| 1161 | + /* | |
| 1162 | + * Back up the compound atomically at its native order. If | |
| 1163 | + * fault injection truncated num_pages mid-compound, skip | |
| 1164 | + * the partial tail rather than splitting. | |
| 1165 | + */ | |
| 1166 | + if (unlikely(i + npages > num_pages)) | |
| 1167 | + break; | |
| 1134 | 1168 | |
| 1135 | − shandle = ttm_backup_backup_page(backup, page, flags->writeback, i, | |
| 1136 | − gfp, alloc_gfp); | |
| 1137 | − if (shandle < 0) { | |
| 1138 | − /* We allow partially shrunken tts */ | |
| 1139 | − ret = shandle; | |
| 1169 | + handle = ttm_backup_backup_folio(backup, page_folio(page), | |
| 1170 | + order, flags->writeback, i, | |
| 1171 | + gfp, alloc_gfp, | |
| 1172 | + &nr_backed); | |
| 1173 | + /* | |
| 1174 | + * Zero progress on this compound (whether order 0 or a | |
| 1175 | + * high-order compound that failed before backing up even | |
| 1176 | + * its first subpage) is unrecoverable: bail out rather than | |
| 1177 | + * looping forever with npages == nr_backed == 0 below. | |
| 1178 | + */ | |
| 1179 | + if (unlikely(handle < 0 && !nr_backed)) { | |
| 1180 | + ret = handle; | |
| 1140 | 1181 | break; |
| 1141 | 1182 | } |
| 1142 | − handle = shandle; | |
| 1143 | − tt->pages[i] = ttm_backup_handle_to_page_ptr(handle); | |
| 1144 | − __free_pages_gpu_account(page, 0, false); | |
| 1145 | − shrunken++; | |
| 1183 | + | |
| 1184 | + for (j = 0; j < nr_backed; j++) | |
| 1185 | + tt->pages[i + j] = ttm_backup_handle_to_page_ptr(handle + j); | |
| 1186 | + | |
| 1187 | + shrunken += nr_backed; | |
| 1188 | + | |
| 1189 | + if (unlikely(nr_backed < npages)) { | |
| 1190 | + /* | |
| 1191 | + * Partial OOM backup: split the compound and free the | |
| 1192 | + * subpages whose content is now in shmem. Continue the | |
| 1193 | + * loop from the first un-backed order-0 page. | |
| 1194 | + */ | |
| 1195 | + ttm_pool_split_for_swap(pool, page); | |
| 1196 | + for (j = 0; j < nr_backed; j++) | |
| 1197 | + __free_pages_gpu_account(page + j, 0, false); | |
| 1198 | + npages = nr_backed; | |
| 1199 | + continue; | |
| 1200 | + } | |
| 1201 | + | |
| 1202 | + /* Fully backed up: free at native order. */ | |
| 1203 | + page->private = 0; | |
| 1204 | + __free_pages_gpu_account(page, order, false); | |
| 1146 | 1205 | } |
| 1147 | 1206 | |
| 1148 | 1207 | return shrunken ? shrunken : ret; |
| @@ -22,4 +22,12 @@ static inline unsigned int ttm_pool_beneficial_order(struct ttm_pool *pool) · 21 unmodified lines | ||
| 22 | 22 | return pool->alloc_flags & 0xff; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | +/* | |
| 26 | + * Implemented in ttm_pool.c, used by ttm_backup.c. Returns true if a fault | |
| 27 | + * should be injected mid-compound to test the reactive split-and-retry | |
| 28 | + * fallback in ttm_pool_backup(). Always returns false when | |
| 29 | + * CONFIG_FAULT_INJECTION is disabled. | |
| 30 | + */ | |
| 31 | +bool ttm_backup_fault_inject_folio(void); | |
| 32 | + | |
| 25 | 33 | #endif |
| @@ -571,6 +571,8 @@ extern bool super_pages; · 570 unmodified lines | ||
| 571 | 571 | void v3d_init_hw_state(struct v3d_dev *v3d); |
| 572 | 572 | int v3d_gem_init(struct drm_device *dev); |
| 573 | 573 | void v3d_gem_destroy(struct drm_device *dev); |
| 574 | +void v3d_idle_axi(struct v3d_dev *v3d, int core); | |
| 575 | +void v3d_idle_gca(struct v3d_dev *v3d); | |
| 574 | 576 | void v3d_reset_sms(struct v3d_dev *v3d); |
| 575 | 577 | void v3d_reset(struct v3d_dev *v3d); |
| 576 | 578 | void v3d_invalidate_caches(struct v3d_dev *v3d); |
| @@ -36,9 +36,21 @@ v3d_init_core(struct v3d_dev *v3d, int core) · 35 unmodified lines | ||
| 36 | 36 | V3D_CORE_WRITE(core, V3D_CTL_L2TFLEND, ~0); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | −static void | |
| 39 | +void | |
| 40 | 40 | v3d_idle_axi(struct v3d_dev *v3d, int core) |
| 41 | 41 | { |
| 42 | + if (v3d->ver >= V3D_GEN_71) { | |
| 43 | + V3D_WRITE(V3D_GMP_CFG(v3d->ver), V3D_GMP_CFG_STOP_REQ); | |
| 44 | + | |
| 45 | + if (wait_for((V3D_READ(V3D_GMP_STATUS(v3d->ver)) & | |
| 46 | + (V3D_GMP_STATUS_RD_COUNT_MASK | | |
| 47 | + V3D_GMP_STATUS_WR_COUNT_MASK | | |
| 48 | + V3D_GMP_STATUS_CFG_BUSY)) == 0, 100)) { | |
| 49 | + drm_err(&v3d->drm, "Failed to wait for safe GMP shutdown\n"); | |
| 50 | + } | |
| 51 | + return; | |
| 52 | + } | |
| 53 | + | |
| 42 | 54 | V3D_CORE_WRITE(core, V3D_GMP_CFG(v3d->ver), V3D_GMP_CFG_STOP_REQ); |
| 43 | 55 | |
| 44 | 56 | if (wait_for((V3D_CORE_READ(core, V3D_GMP_STATUS(v3d->ver)) & |
| @@ -49,7 +61,7 @@ v3d_idle_axi(struct v3d_dev *v3d, int core) · 4 unmodified lines | ||
| 49 | 61 | } |
| 50 | 62 | } |
| 51 | 63 | |
| 52 | −static void | |
| 64 | +void | |
| 53 | 65 | v3d_idle_gca(struct v3d_dev *v3d) |
| 54 | 66 | { |
| 55 | 67 | if (v3d->ver >= V3D_GEN_41) |
| @@ -54,8 +54,15 @@ int v3d_power_suspend(struct device *dev) · 53 unmodified lines | ||
| 54 | 54 | |
| 55 | 55 | v3d_clean_caches(v3d); |
| 56 | 56 | |
| 57 | + /* Wait until V3D has no active or pending AXI transactions. */ | |
| 58 | + v3d_idle_axi(v3d, 0); | |
| 59 | + v3d_idle_gca(v3d); | |
| 60 | + | |
| 57 | 61 | ret = v3d_suspend_sms(v3d); |
| 58 | 62 | if (ret) { |
| 63 | + /* Staying active: undo the GMP STOP_REQ from v3d_idle_axi(). */ | |
| 64 | + V3D_WRITE(V3D_GMP_CFG(v3d->ver), | |
| 65 | + V3D_READ(V3D_GMP_CFG(v3d->ver)) & ~V3D_GMP_CFG_STOP_REQ); | |
| 59 | 66 | v3d_irq_enable(v3d); |
| 60 | 67 | return ret; |
| 61 | 68 | } |
| @@ -732,9 +732,13 @@ static int vc4_gem_object_mmap(struct drm_gem_object *obj, struct vm_area_struct · 731 unmodified lines | ||
| 732 | 732 | { |
| 733 | 733 | struct vc4_bo *bo = to_vc4_bo(obj); |
| 734 | 734 | |
| 735 | − if (bo->validated_shader && (vma->vm_flags & VM_WRITE)) { | |
| 736 | − DRM_DEBUG("mmapping of shader BOs for writing not allowed.\n"); | |
| 737 | − return -EINVAL; | |
| 735 | + if (bo->validated_shader) { | |
| 736 | + if (vma->vm_flags & VM_WRITE) { | |
| 737 | + DRM_DEBUG("mmapping of shader BOs for writing not allowed.\n"); | |
| 738 | + return -EINVAL; | |
| 739 | + } | |
| 740 | + | |
| 741 | + vm_flags_clear(vma, VM_MAYWRITE); | |
| 738 | 742 | } |
| 739 | 743 | |
| 740 | 744 | mutex_lock(&bo->madv_lock); |
| @@ -1044,7 +1048,7 @@ static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused) · 303 unmodified lines | ||
| 1044 | 1048 | struct vc4_dev *vc4 = to_vc4_dev(dev); |
| 1045 | 1049 | int i; |
| 1046 | 1050 | |
| 1047 | − timer_delete(&vc4->bo_cache.time_timer); | |
| 1051 | + timer_shutdown_sync(&vc4->bo_cache.time_timer); | |
| 1048 | 1052 | cancel_work_sync(&vc4->bo_cache.time_work); |
| 1049 | 1053 | |
| 1050 | 1054 | vc4_bo_cache_purge(dev); |
| @@ -1752,7 +1752,7 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) · 1751 unmodified lines | ||
| 1752 | 1752 | static void vc4_hvs_unbind(struct device *dev, struct device *master, |
| 1753 | 1753 | void *data) |
| 1754 | 1754 | { |
| 1755 | − struct drm_device *drm = dev_get_drvdata(master); | |
| 1755 | + struct drm_device *drm = data; | |
| 1756 | 1756 | struct vc4_dev *vc4 = to_vc4_dev(drm); |
| 1757 | 1757 | struct vc4_hvs *hvs = vc4->hvs; |
| 1758 | 1758 | struct drm_mm_node *node, *next; |
| @@ -494,7 +494,7 @@ err_put_runtime_pm: · 493 unmodified lines | ||
| 494 | 494 | static void vc4_v3d_unbind(struct device *dev, struct device *master, |
| 495 | 495 | void *data) |
| 496 | 496 | { |
| 497 | − struct drm_device *drm = dev_get_drvdata(master); | |
| 497 | + struct drm_device *drm = data; | |
| 498 | 498 | struct vc4_dev *vc4 = to_vc4_dev(drm); |
| 499 | 499 | |
| 500 | 500 | vc4_irq_uninstall(drm); |
| @@ -78,7 +78,7 @@ static int vmw_gb_surface_unbind(struct vmw_resource *res, · 77 unmodified lines | ||
| 78 | 78 | static int vmw_gb_surface_destroy(struct vmw_resource *res); |
| 79 | 79 | static int |
| 80 | 80 | vmw_gb_surface_define_internal(struct drm_device *dev, |
| 81 | − struct drm_vmw_gb_surface_create_ext_req *req, | |
| 81 | + const struct drm_vmw_gb_surface_create_ext_req *req, | |
| 82 | 82 | struct drm_vmw_gb_surface_create_rep *rep, |
| 83 | 83 | struct drm_file *file_priv); |
| 84 | 84 | static int |
| @@ -1503,7 +1503,7 @@ int vmw_gb_surface_reference_ext_ioctl(struct drm_device *dev, void *data, · 1418 unmodified lines | ||
| 1503 | 1503 | */ |
| 1504 | 1504 | static int |
| 1505 | 1505 | vmw_gb_surface_define_internal(struct drm_device *dev, |
| 1506 | − struct drm_vmw_gb_surface_create_ext_req *req, | |
| 1506 | + const struct drm_vmw_gb_surface_create_ext_req *req, | |
| 1507 | 1507 | struct drm_vmw_gb_surface_create_rep *rep, |
| 1508 | 1508 | struct drm_file *file_priv) |
| 1509 | 1509 | { |
| @@ -1521,9 +1521,21 @@ vmw_gb_surface_define_internal(struct drm_device *dev, · 11 unmodified lines | ||
| 1521 | 1521 | req->base.svga3d_flags); |
| 1522 | 1522 | |
| 1523 | 1523 | /* array_size must be null for non-GL3 host. */ |
| 1524 | − if (req->base.array_size > 0 && !has_sm4_context(dev_priv)) { | |
| 1525 | − VMW_DEBUG_USER("SM4 surface not supported.\n"); | |
| 1526 | − return -EINVAL; | |
| 1524 | + if (req->base.array_size > 0) { | |
| 1525 | + if (has_sm5_context(dev_priv)) { | |
| 1526 | + if (req->base.array_size > SVGA3D_SM5_MAX_SURFACE_ARRAYSIZE) { | |
| 1527 | + VMW_DEBUG_USER("Invalid Surface Array Size.\n"); | |
| 1528 | + return -EINVAL; | |
| 1529 | + } | |
| 1530 | + } else if (has_sm4_context(dev_priv)) { | |
| 1531 | + if (req->base.array_size > SVGA3D_SM4_MAX_SURFACE_ARRAYSIZE) { | |
| 1532 | + VMW_DEBUG_USER("Invalid Surface Array Size.\n"); | |
| 1533 | + return -EINVAL; | |
| 1534 | + } | |
| 1535 | + } else { | |
| 1536 | + VMW_DEBUG_USER("SM4+ surface not supported.\n"); | |
| 1537 | + return -EINVAL; | |
| 1538 | + } | |
| 1527 | 1539 | } |
| 1528 | 1540 | |
| 1529 | 1541 | if (!has_sm4_1_context(dev_priv)) { |
| @@ -95,18 +95,21 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c) · 94 unmodified lines | ||
| 95 | 95 | struct platform_device *pdev; |
| 96 | 96 | struct fwnode_handle *fwnode; |
| 97 | 97 | int ret; |
| 98 | + u32 id; | |
| 98 | 99 | |
| 99 | 100 | fwnode = fwnode_create_software_node(xe_i2c_adapter_properties, NULL); |
| 100 | 101 | if (IS_ERR(fwnode)) |
| 101 | 102 | return PTR_ERR(fwnode); |
| 102 | 103 | |
| 104 | + id = (pci_domain_nr(pci->bus) << 16) | pci_dev_id(pci); | |
| 105 | + | |
| 103 | 106 | /* |
| 104 | 107 | * Not using platform_device_register_full() here because we don't have |
| 105 | 108 | * a handle to the platform_device before it returns. xe_i2c_notifier() |
| 106 | 109 | * uses that handle, but it may be called before |
| 107 | 110 | * platform_device_register_full() is done. |
| 108 | 111 | */ |
| 109 | − pdev = platform_device_alloc(adapter_name, pci_dev_id(pci)); | |
| 112 | + pdev = platform_device_alloc(adapter_name, id); | |
| 110 | 113 | if (!pdev) { |
| 111 | 114 | ret = -ENOMEM; |
| 112 | 115 | goto err_fwnode_remove; |
| @@ -1313,6 +1313,7 @@ int xe_migrate_ccs_rw_copy(struct xe_tile *tile, struct xe_exec_queue *q, · 1312 unmodified lines | ||
| 1313 | 1313 | * content. |
| 1314 | 1314 | * @src_bo: The buffer object @src is currently bound to. |
| 1315 | 1315 | * @read_write : Creates BB commands for CCS read/write. |
| 1316 | + * @bound: Device is bound | |
| 1316 | 1317 | * |
| 1317 | 1318 | * Directly clearing the BB lacks atomicity and can lead to undefined |
| 1318 | 1319 | * behavior if the vCPU is halted mid-operation during the clearing |
| @@ -1325,7 +1326,8 @@ int xe_migrate_ccs_rw_copy(struct xe_tile *tile, struct xe_exec_queue *q, · 6 unmodified lines | ||
| 1325 | 1326 | * Returns: None. |
| 1326 | 1327 | */ |
| 1327 | 1328 | void xe_migrate_ccs_rw_copy_clear(struct xe_bo *src_bo, |
| 1328 | − enum xe_sriov_vf_ccs_rw_ctxs read_write) | |
| 1329 | + enum xe_sriov_vf_ccs_rw_ctxs read_write, | |
| 1330 | + bool bound) | |
| 1329 | 1331 | { |
| 1330 | 1332 | struct xe_mem_pool_node *bb = src_bo->bb_ccs[read_write]; |
| 1331 | 1333 | struct xe_device *xe = xe_bo_device(src_bo); |
| @@ -1339,13 +1341,15 @@ void xe_migrate_ccs_rw_copy_clear(struct xe_bo *src_bo, · 7 unmodified lines | ||
| 1339 | 1341 | bb_pool = ctx->mem.ccs_bb_pool; |
| 1340 | 1342 | |
| 1341 | 1343 | scoped_guard(mutex, xe_mem_pool_bo_swap_guard(bb_pool)) { |
| 1342 | − xe_mem_pool_swap_shadow_locked(bb_pool); | |
| 1344 | + if (bound) { | |
| 1345 | + xe_mem_pool_swap_shadow_locked(bb_pool); | |
| 1343 | 1346 | |
| 1344 | − cs = xe_mem_pool_node_cpu_addr(bb); | |
| 1345 | − memset(cs, MI_NOOP, bb->sa_node.size); | |
| 1346 | − xe_sriov_vf_ccs_rw_update_bb_addr(ctx); | |
| 1347 | + cs = xe_mem_pool_node_cpu_addr(bb); | |
| 1348 | + memset(cs, MI_NOOP, bb->sa_node.size); | |
| 1349 | + xe_sriov_vf_ccs_rw_update_bb_addr(ctx); | |
| 1347 | 1350 | |
| 1348 | − xe_mem_pool_sync_shadow_locked(bb); | |
| 1351 | + xe_mem_pool_sync_shadow_locked(bb); | |
| 1352 | + } | |
| 1349 | 1353 | xe_mem_pool_free_node(bb); |
| 1350 | 1354 | src_bo->bb_ccs[read_write] = NULL; |
| 1351 | 1355 | } |
| @@ -142,7 +142,8 @@ int xe_migrate_ccs_rw_copy(struct xe_tile *tile, struct xe_exec_queue *q, · 141 unmodified lines | ||
| 142 | 142 | enum xe_sriov_vf_ccs_rw_ctxs read_write); |
| 143 | 143 | |
| 144 | 144 | void xe_migrate_ccs_rw_copy_clear(struct xe_bo *src_bo, |
| 145 | − enum xe_sriov_vf_ccs_rw_ctxs read_write); | |
| 145 | + enum xe_sriov_vf_ccs_rw_ctxs read_write, | |
| 146 | + bool bound); | |
| 146 | 147 | |
| 147 | 148 | struct xe_lrc *xe_migrate_lrc(struct xe_migrate *migrate); |
| 148 | 149 | struct xe_exec_queue *xe_migrate_exec_queue(struct xe_migrate *migrate); |
| @@ -3,6 +3,8 @@ · 2 unmodified lines | ||
| 3 | 3 | * Copyright © 2025 Intel Corporation |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | +#include <drm/drm_drv.h> | |
| 7 | + | |
| 6 | 8 | #include "instructions/xe_mi_commands.h" |
| 7 | 9 | #include "instructions/xe_gpu_commands.h" |
| 8 | 10 | #include "xe_bb.h" |
| @@ -446,7 +448,7 @@ err_unwind: · 437 unmodified lines | ||
| 446 | 448 | */ |
| 447 | 449 | for_each_ccs_rw_ctx(ctx_id) { |
| 448 | 450 | if (bo->bb_ccs[ctx_id]) |
| 449 | − xe_migrate_ccs_rw_copy_clear(bo, ctx_id); | |
| 451 | + xe_migrate_ccs_rw_copy_clear(bo, ctx_id, true); | |
| 450 | 452 | } |
| 451 | 453 | return err; |
| 452 | 454 | } |
| @@ -466,19 +468,27 @@ int xe_sriov_vf_ccs_detach_bo(struct xe_bo *bo) · 13 unmodified lines | ||
| 466 | 468 | struct xe_device *xe = xe_bo_device(bo); |
| 467 | 469 | enum xe_sriov_vf_ccs_rw_ctxs ctx_id; |
| 468 | 470 | struct xe_mem_pool_node *bb; |
| 471 | + bool bound; | |
| 472 | + int idx; | |
| 469 | 473 | |
| 470 | 474 | xe_assert(xe, IS_VF_CCS_READY(xe)); |
| 471 | 475 | |
| 472 | 476 | if (!xe_bo_has_valid_ccs_bb(bo)) |
| 473 | 477 | return 0; |
| 474 | 478 | |
| 479 | + bound = drm_dev_enter(&xe->drm, &idx); | |
| 480 | + | |
| 475 | 481 | for_each_ccs_rw_ctx(ctx_id) { |
| 476 | 482 | bb = bo->bb_ccs[ctx_id]; |
| 477 | 483 | if (!bb) |
| 478 | 484 | continue; |
| 479 | 485 | |
| 480 | − xe_migrate_ccs_rw_copy_clear(bo, ctx_id); | |
| 486 | + xe_migrate_ccs_rw_copy_clear(bo, ctx_id, bound); | |
| 481 | 487 | } |
| 488 | + | |
| 489 | + if (bound) | |
| 490 | + drm_dev_exit(idx); | |
| 491 | + | |
| 482 | 492 | return 0; |
| 483 | 493 | } |
| 484 | 494 | |
| @@ -1809,10 +1809,10 @@ err_close: · 1808 unmodified lines | ||
| 1809 | 1809 | return ERR_PTR(err); |
| 1810 | 1810 | |
| 1811 | 1811 | err_svm_fini: |
| 1812 | − if (flags & XE_VM_FLAG_FAULT_MODE) { | |
| 1813 | − vm->size = 0; /* close the vm */ | |
| 1814 | − xe_svm_fini(vm); | |
| 1815 | − } | |
| 1812 | + vm->size = 0; /* close the vm */ | |
| 1813 | + if (flags & XE_VM_FLAG_FAULT_MODE) | |
| 1814 | + xe_svm_close(vm); | |
| 1815 | + xe_svm_fini(vm); | |
| 1816 | 1816 | err_no_resv: |
| 1817 | 1817 | mutex_destroy(&vm->snap_mutex); |
| 1818 | 1818 | for_each_tile(tile, xe, id) |
| @@ -332,6 +332,20 @@ static int xe_vm_invalidate_madvise_range(struct xe_vm *vm, u64 start, u64 end) · 331 unmodified lines | ||
| 332 | 332 | return err; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | +/** | |
| 336 | + * madvise_range_needs_invalidation() - Check whether madvise needs invalidation | |
| 337 | + * @args: madvise ioctl arguments | |
| 338 | + * | |
| 339 | + * Purgeable state updates only touch VMA/BO metadata. PTEs stay valid and are | |
| 340 | + * zapped only if the BO is later purged. | |
| 341 | + * | |
| 342 | + * Return: true when the update needs PTE invalidation. | |
| 343 | + */ | |
| 344 | +static bool madvise_range_needs_invalidation(const struct drm_xe_madvise *args) | |
| 345 | +{ | |
| 346 | + return args->type != DRM_XE_VMA_ATTR_PURGEABLE_STATE; | |
| 347 | +} | |
| 348 | + | |
| 335 | 349 | static bool madvise_args_are_sane(struct xe_device *xe, const struct drm_xe_madvise *args) |
| 336 | 350 | { |
| 337 | 351 | if (XE_IOCTL_DBG(xe, !args)) |
| @@ -708,8 +722,9 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil · 370 unmodified lines | ||
| 708 | 722 | madvise_funcs[attr_type](xe, vm, madvise_range.vmas, madvise_range.num_vmas, args, |
| 709 | 723 | &details); |
| 710 | 724 | |
| 711 | − err = xe_vm_invalidate_madvise_range(vm, madvise_range.addr, | |
| 712 | − madvise_range.addr + args->range); | |
| 725 | + if (madvise_range_needs_invalidation(args)) | |
| 726 | + err = xe_vm_invalidate_madvise_range(vm, madvise_range.addr, | |
| 727 | + madvise_range.addr + args->range); | |
| 713 | 728 | |
| 714 | 729 | if (madvise_range.has_svm_userptr_vmas) |
| 715 | 730 | xe_svm_notifier_unlock(vm); |
| @@ -1009,7 +1009,7 @@ struct ec_sensors_data { · 1008 unmodified lines | ||
| 1009 | 1009 | /* sorted list of unique register banks */ |
| 1010 | 1010 | u8 banks[ASUS_EC_MAX_BANK + 1]; |
| 1011 | 1011 | /* in jiffies */ |
| 1012 | − unsigned long last_updated; | |
| 1012 | + u64 next_update; | |
| 1013 | 1013 | struct lock_data lock_data; |
| 1014 | 1014 | /* number of board EC sensors */ |
| 1015 | 1015 | u8 nr_sensors; |
| @@ -1189,7 +1189,7 @@ static int asus_ec_block_read(const struct device *dev, · 173 unmodified lines | ||
| 1189 | 1189 | } |
| 1190 | 1190 | for (ireg = 0; ireg < ec->nr_registers; ireg++) { |
| 1191 | 1191 | reg_bank = register_bank(ec->registers[ireg]); |
| 1192 | − if (reg_bank < bank) { | |
| 1192 | + if (reg_bank != bank) { | |
| 1193 | 1193 | continue; |
| 1194 | 1194 | } |
| 1195 | 1195 | ec_read(register_index(ec->registers[ireg]), |
| @@ -1278,13 +1278,12 @@ static int get_cached_value_or_update(const struct device *dev, · 82 unmodified lines | ||
| 1278 | 1278 | int sensor_index, |
| 1279 | 1279 | struct ec_sensors_data *state, s32 *value) |
| 1280 | 1280 | { |
| 1281 | − if (time_after(jiffies, state->last_updated + HZ)) { | |
| 1281 | + if (time_after64(get_jiffies_64(), state->next_update)) { | |
| 1282 | 1282 | if (update_ec_sensors(dev, state)) { |
| 1283 | 1283 | dev_err(dev, "update_ec_sensors() failure\n"); |
| 1284 | 1284 | return -EIO; |
| 1285 | 1285 | } |
| 1286 | − | |
| 1287 | − state->last_updated = jiffies; | |
| 1286 | + state->next_update = get_jiffies_64() + HZ; | |
| 1288 | 1287 | } |
| 1289 | 1288 | |
| 1290 | 1289 | *value = state->sensors[sensor_index].cached_value; |
| @@ -1402,6 +1401,7 @@ static int asus_ec_probe(struct platform_device *pdev) · 111 unmodified lines | ||
| 1402 | 1401 | if (!ec_data) |
| 1403 | 1402 | return -ENOMEM; |
| 1404 | 1403 | |
| 1404 | + ec_data->next_update = INITIAL_JIFFIES; | |
| 1405 | 1405 | dev_set_drvdata(dev, ec_data); |
| 1406 | 1406 | ec_data->board_info = pboard_info; |
| 1407 | 1407 | |
| @@ -1495,9 +1495,11 @@ static int asus_ec_probe(struct platform_device *pdev) · 87 unmodified lines | ||
| 1495 | 1495 | if (!nr_count[type]) |
| 1496 | 1496 | continue; |
| 1497 | 1497 | |
| 1498 | − asus_ec_hwmon_add_chan_info(asus_ec_hwmon_chan, dev, | |
| 1499 | − nr_count[type], type, | |
| 1500 | − hwmon_attributes[type]); | |
| 1498 | + status = asus_ec_hwmon_add_chan_info(asus_ec_hwmon_chan, dev, | |
| 1499 | + nr_count[type], type, | |
| 1500 | + hwmon_attributes[type]); | |
| 1501 | + if (status) | |
| 1502 | + return status; | |
| 1501 | 1503 | *ptr_asus_ec_ci++ = asus_ec_hwmon_chan++; |
| 1502 | 1504 | } |
| 1503 | 1505 | |
| @@ -645,6 +645,7 @@ static int ccp_probe(struct hid_device *hdev, const struct hid_device_id *id) · 644 unmodified lines | ||
| 645 | 645 | |
| 646 | 646 | out_hw_close: |
| 647 | 647 | hid_hw_close(hdev); |
| 648 | + hid_device_io_stop(hdev); | |
| 648 | 649 | out_hw_stop: |
| 649 | 650 | hid_hw_stop(hdev); |
| 650 | 651 | return ret; |
| @@ -822,6 +822,7 @@ static int corsairpsu_probe(struct hid_device *hdev, const struct hid_device_id · 821 unmodified lines | ||
| 822 | 822 | |
| 823 | 823 | fail_and_close: |
| 824 | 824 | hid_hw_close(hdev); |
| 825 | + hid_device_io_stop(hdev); | |
| 825 | 826 | fail_and_stop: |
| 826 | 827 | hid_hw_stop(hdev); |
| 827 | 828 | return ret; |
| @@ -371,13 +371,15 @@ static int waterforce_probe(struct hid_device *hdev, const struct hid_device_id · 370 unmodified lines | ||
| 371 | 371 | if (IS_ERR(priv->hwmon_dev)) { |
| 372 | 372 | ret = PTR_ERR(priv->hwmon_dev); |
| 373 | 373 | hid_err(hdev, "hwmon registration failed with %d\n", ret); |
| 374 | − goto fail_and_close; | |
| 374 | + goto fail_and_io_stop; | |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | waterforce_debugfs_init(priv); |
| 378 | 378 | |
| 379 | 379 | return 0; |
| 380 | 380 | |
| 381 | +fail_and_io_stop: | |
| 382 | + hid_device_io_stop(hdev); | |
| 381 | 383 | fail_and_close: |
| 382 | 384 | hid_hw_close(hdev); |
| 383 | 385 | fail_and_stop: |
| @@ -948,7 +948,7 @@ static int kraken3_probe(struct hid_device *hdev, const struct hid_device_id *id · 947 unmodified lines | ||
| 948 | 948 | ret = kraken3_init_device(hdev); |
| 949 | 949 | if (ret < 0) { |
| 950 | 950 | hid_err(hdev, "device init failed with %d\n", ret); |
| 951 | − goto fail_and_close; | |
| 951 | + goto fail_and_stop_io; | |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | ret = kraken3_get_fw_ver(hdev); |
| @@ -960,13 +960,15 @@ static int kraken3_probe(struct hid_device *hdev, const struct hid_device_id *id · 5 unmodified lines | ||
| 960 | 960 | if (IS_ERR(priv->hwmon_dev)) { |
| 961 | 961 | ret = PTR_ERR(priv->hwmon_dev); |
| 962 | 962 | hid_err(hdev, "hwmon registration failed with %d\n", ret); |
| 963 | − goto fail_and_close; | |
| 963 | + goto fail_and_stop_io; | |
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | kraken3_debugfs_init(priv, device_name); |
| 967 | 967 | |
| 968 | 968 | return 0; |
| 969 | 969 | |
| 970 | +fail_and_stop_io: | |
| 971 | + hid_device_io_stop(hdev); | |
| 970 | 972 | fail_and_close: |
| 971 | 973 | hid_hw_close(hdev); |
| 972 | 974 | fail_and_stop: |
| @@ -768,7 +768,7 @@ static int nzxt_smart2_hid_probe(struct hid_device *hdev, · 767 unmodified lines | ||
| 768 | 768 | |
| 769 | 769 | out_hw_close: |
| 770 | 770 | hid_hw_close(hdev); |
| 771 | − | |
| 771 | + hid_device_io_stop(hdev); | |
| 772 | 772 | out_hw_stop: |
| 773 | 773 | hid_hw_stop(hdev); |
| 774 | 774 | return ret; |
| @@ -1052,32 +1052,49 @@ static int occ_setup_sensor_attrs(struct occ *occ) · 1051 unmodified lines | ||
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | 1054 | /* only need to do this once at startup, as OCC won't change sensors on us */ |
| 1055 | −static void occ_parse_poll_response(struct occ *occ) | |
| 1055 | +static int occ_parse_poll_response(struct occ *occ) | |
| 1056 | 1056 | { |
| 1057 | 1057 | unsigned int i, old_offset, offset = 0, size = 0; |
| 1058 | + u16 data_length; | |
| 1058 | 1059 | struct occ_sensor *sensor; |
| 1059 | − struct occ_sensors *sensors = &occ->sensors; | |
| 1060 | + struct occ_sensors parsed = {}; | |
| 1061 | + struct occ_sensors *sensors = &parsed; | |
| 1060 | 1062 | struct occ_response *resp = &occ->resp; |
| 1061 | 1063 | struct occ_poll_response *poll = |
| 1062 | 1064 | (struct occ_poll_response *)&resp->data[0]; |
| 1063 | 1065 | struct occ_poll_response_header *header = &poll->header; |
| 1064 | 1066 | struct occ_sensor_data_block *block = &poll->block; |
| 1065 | 1067 | |
| 1068 | + data_length = get_unaligned_be16(&resp->data_length); | |
| 1069 | + if (data_length < sizeof(*header) || data_length > OCC_RESP_DATA_BYTES) { | |
| 1070 | + dev_err(occ->bus_dev, "invalid OCC poll response length %u\n", | |
| 1071 | + data_length); | |
| 1072 | + return -EMSGSIZE; | |
| 1073 | + } | |
| 1074 | + | |
| 1066 | 1075 | dev_info(occ->bus_dev, "OCC found, code level: %.16s\n", |
| 1067 | 1076 | header->occ_code_level); |
| 1068 | 1077 | |
| 1069 | 1078 | for (i = 0; i < header->num_sensor_data_blocks; ++i) { |
| 1070 | 1079 | block = (struct occ_sensor_data_block *)((u8 *)block + offset); |
| 1080 | + if (size + sizeof(*header) + sizeof(block->header) > | |
| 1081 | + data_length) { | |
| 1082 | + dev_err(occ->bus_dev, | |
| 1083 | + "truncated OCC sensor block header\n"); | |
| 1084 | + return -EMSGSIZE; | |
| 1085 | + } | |
| 1086 | + | |
| 1071 | 1087 | old_offset = offset; |
| 1072 | 1088 | offset = (block->header.num_sensors * |
| 1073 | 1089 | block->header.sensor_length) + sizeof(block->header); |
| 1074 | − size += offset; | |
| 1075 | 1090 | |
| 1076 | 1091 | /* validate all the length/size fields */ |
| 1077 | − if ((size + sizeof(*header)) >= OCC_RESP_DATA_BYTES) { | |
| 1078 | − dev_warn(occ->bus_dev, "exceeded response buffer\n"); | |
| 1079 | − return; | |
| 1092 | + if (size + sizeof(*header) + offset > data_length) { | |
| 1093 | + dev_err(occ->bus_dev, | |
| 1094 | + "exceeded OCC poll response length\n"); | |
| 1095 | + return -EMSGSIZE; | |
| 1080 | 1096 | } |
| 1097 | + size += offset; | |
| 1081 | 1098 | |
| 1082 | 1099 | dev_dbg(occ->bus_dev, " %04x..%04x: %.4s (%d sensors)\n", |
| 1083 | 1100 | old_offset, offset - 1, block->header.eye_catcher, |
| @@ -1107,6 +1124,9 @@ static void occ_parse_poll_response(struct occ *occ) · 23 unmodified lines | ||
| 1107 | 1124 | |
| 1108 | 1125 | dev_dbg(occ->bus_dev, "Max resp size: %u+%zd=%zd\n", size, |
| 1109 | 1126 | sizeof(*header), size + sizeof(*header)); |
| 1127 | + occ->sensors = parsed; | |
| 1128 | + | |
| 1129 | + return 0; | |
| 1110 | 1130 | } |
| 1111 | 1131 | |
| 1112 | 1132 | int occ_active(struct occ *occ, bool active) |
| @@ -1138,10 +1158,12 @@ int occ_active(struct occ *occ, bool active) · 25 unmodified lines | ||
| 1138 | 1158 | goto unlock; |
| 1139 | 1159 | } |
| 1140 | 1160 | |
| 1141 | − occ->active = true; | |
| 1142 | 1161 | occ->next_update = jiffies + OCC_UPDATE_FREQUENCY; |
| 1143 | − occ_parse_poll_response(occ); | |
| 1162 | + rc = occ_parse_poll_response(occ); | |
| 1163 | + if (rc) | |
| 1164 | + goto unlock; | |
| 1144 | 1165 | |
| 1166 | + occ->active = true; | |
| 1145 | 1167 | rc = occ_setup_sensor_attrs(occ); |
| 1146 | 1168 | if (rc) { |
| 1147 | 1169 | dev_err(occ->bus_dev, |
| @@ -88,6 +88,33 @@ static int max34440_read_word_data(struct i2c_client *client, int page, · 87 unmodified lines | ||
| 88 | 88 | ret = pmbus_read_word_data(client, page, phase, |
| 89 | 89 | data->iout_oc_warn_limit); |
| 90 | 90 | break; |
| 91 | + case PMBUS_VIN_OV_FAULT_LIMIT: | |
| 92 | + case PMBUS_VIN_OV_WARN_LIMIT: | |
| 93 | + case PMBUS_VIN_UV_WARN_LIMIT: | |
| 94 | + case PMBUS_VIN_UV_FAULT_LIMIT: | |
| 95 | + case PMBUS_MFR_VIN_MIN: | |
| 96 | + case PMBUS_MFR_VIN_MAX: | |
| 97 | + case PMBUS_IIN_OC_WARN_LIMIT: | |
| 98 | + case PMBUS_IIN_OC_FAULT_LIMIT: | |
| 99 | + case PMBUS_MFR_IIN_MAX: | |
| 100 | + case PMBUS_MFR_VOUT_MIN: | |
| 101 | + case PMBUS_MFR_VOUT_MAX: | |
| 102 | + case PMBUS_IOUT_UC_FAULT_LIMIT: | |
| 103 | + case PMBUS_MFR_IOUT_MAX: | |
| 104 | + case PMBUS_UT_WARN_LIMIT: | |
| 105 | + case PMBUS_UT_FAULT_LIMIT: | |
| 106 | + case PMBUS_MFR_MAX_TEMP_1: | |
| 107 | + /* | |
| 108 | + * MAX34451/ADPM family do not support VIN/IIN limit registers, | |
| 109 | + * manufacturer-specific min/max registers, or undercurrent/ | |
| 110 | + * undertemperature fault limits. Accessing these triggers CML | |
| 111 | + * error and asserts ALERT. | |
| 112 | + */ | |
| 113 | + if (data->id == max34451 || data->id == adpm12160 || | |
| 114 | + data->id == adpm12200 || data->id == adpm12250) | |
| 115 | + return -ENXIO; | |
| 116 | + ret = -ENODATA; | |
| 117 | + break; | |
| 91 | 118 | case PMBUS_VIRT_READ_VOUT_MIN: |
| 92 | 119 | ret = pmbus_read_word_data(client, page, phase, |
| 93 | 120 | MAX34440_MFR_VOUT_MIN); |
| @@ -244,6 +271,51 @@ static int max34440_read_byte_data(struct i2c_client *client, int page, int reg) · 150 unmodified lines | ||
| 244 | 271 | return ret; |
| 245 | 272 | } |
| 246 | 273 | |
| 274 | +static int max34451_read_byte_data(struct i2c_client *client, int page, int reg) | |
| 275 | +{ | |
| 276 | + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); | |
| 277 | + const struct max34440_data *data = to_max34440_data(info); | |
| 278 | + | |
| 279 | + switch (reg) { | |
| 280 | + case PMBUS_STATUS_BYTE: | |
| 281 | + case PMBUS_STATUS_OTHER: | |
| 282 | + /* | |
| 283 | + * MAX34451/ADPM family do not support STATUS_BYTE or | |
| 284 | + * STATUS_OTHER registers. Accessing them triggers CML | |
| 285 | + * error and asserts ALERT. | |
| 286 | + */ | |
| 287 | + if (data->id == max34451 || data->id == adpm12160 || | |
| 288 | + data->id == adpm12200 || data->id == adpm12250) | |
| 289 | + return -ENXIO; | |
| 290 | + return -ENODATA; | |
| 291 | + default: | |
| 292 | + return -ENODATA; | |
| 293 | + } | |
| 294 | +} | |
| 295 | + | |
| 296 | +static int max34451_write_byte_data(struct i2c_client *client, int page, | |
| 297 | + int reg, u8 byte) | |
| 298 | +{ | |
| 299 | + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); | |
| 300 | + const struct max34440_data *data = to_max34440_data(info); | |
| 301 | + | |
| 302 | + switch (reg) { | |
| 303 | + case PMBUS_STATUS_BYTE: | |
| 304 | + case PMBUS_STATUS_OTHER: | |
| 305 | + /* | |
| 306 | + * MAX34451/ADPM family do not support STATUS_BYTE or | |
| 307 | + * STATUS_OTHER registers. Writing to them triggers CML | |
| 308 | + * error and asserts ALERT. | |
| 309 | + */ | |
| 310 | + if (data->id == max34451 || data->id == adpm12160 || | |
| 311 | + data->id == adpm12200 || data->id == adpm12250) | |
| 312 | + return -ENXIO; | |
| 313 | + return -ENODATA; | |
| 314 | + default: | |
| 315 | + return -ENODATA; | |
| 316 | + } | |
| 317 | +} | |
| 318 | + | |
| 247 | 319 | static int max34451_set_supported_funcs(struct i2c_client *client, |
| 248 | 320 | struct max34440_data *data) |
| 249 | 321 | { |
| @@ -363,7 +435,9 @@ static struct pmbus_driver_info max34440_info[] = { · 113 unmodified lines | ||
| 363 | 435 | .func[9] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT, |
| 364 | 436 | .func[10] = PMBUS_HAVE_IIN | PMBUS_HAVE_STATUS_INPUT, |
| 365 | 437 | .func[18] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, |
| 438 | + .read_byte_data = max34451_read_byte_data, | |
| 366 | 439 | .read_word_data = max34440_read_word_data, |
| 440 | + .write_byte_data = max34451_write_byte_data, | |
| 367 | 441 | .write_word_data = max34440_write_word_data, |
| 368 | 442 | }, |
| 369 | 443 | [adpm12200] = { |
| @@ -399,7 +473,9 @@ static struct pmbus_driver_info max34440_info[] = { · 29 unmodified lines | ||
| 399 | 473 | .func[10] = PMBUS_HAVE_IIN | PMBUS_HAVE_STATUS_INPUT, |
| 400 | 474 | .func[14] = PMBUS_HAVE_IOUT, |
| 401 | 475 | .func[18] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, |
| 476 | + .read_byte_data = max34451_read_byte_data, | |
| 402 | 477 | .read_word_data = max34440_read_word_data, |
| 478 | + .write_byte_data = max34451_write_byte_data, | |
| 403 | 479 | .write_word_data = max34440_write_word_data, |
| 404 | 480 | }, |
| 405 | 481 | [adpm12250] = { |
| @@ -433,7 +509,9 @@ static struct pmbus_driver_info max34440_info[] = { · 27 unmodified lines | ||
| 433 | 509 | .func[10] = PMBUS_HAVE_IIN | PMBUS_HAVE_STATUS_INPUT, |
| 434 | 510 | .func[14] = PMBUS_HAVE_IOUT, |
| 435 | 511 | .func[18] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, |
| 512 | + .read_byte_data = max34451_read_byte_data, | |
| 436 | 513 | .read_word_data = max34440_read_word_data, |
| 514 | + .write_byte_data = max34451_write_byte_data, | |
| 437 | 515 | .write_word_data = max34440_write_word_data, |
| 438 | 516 | }, |
| 439 | 517 | [max34440] = { |
| @@ -581,7 +659,9 @@ static struct pmbus_driver_info max34440_info[] = { · 141 unmodified lines | ||
| 581 | 659 | .func[18] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, |
| 582 | 660 | .func[19] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, |
| 583 | 661 | .func[20] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, |
| 662 | + .read_byte_data = max34451_read_byte_data, | |
| 584 | 663 | .read_word_data = max34440_read_word_data, |
| 664 | + .write_byte_data = max34451_write_byte_data, | |
| 585 | 665 | .write_word_data = max34440_write_word_data, |
| 586 | 666 | .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, |
| 587 | 667 | }, |
| @@ -843,18 +843,8 @@ err_put_dev: · 842 unmodified lines | ||
| 843 | 843 | return err; |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | −static int intel_th_output_release(struct inode *inode, struct file *file) | |
| 847 | −{ | |
| 848 | − struct intel_th_device *thdev = file->private_data; | |
| 849 | − | |
| 850 | − put_device(&thdev->dev); | |
| 851 | − | |
| 852 | − return 0; | |
| 853 | −} | |
| 854 | − | |
| 855 | 846 | static const struct file_operations intel_th_output_fops = { |
| 856 | 847 | .open = intel_th_output_open, |
| 857 | − .release = intel_th_output_release, | |
| 858 | 848 | .llseek = noop_llseek, |
| 859 | 849 | }; |
| 860 | 850 | |
| @@ -1490,8 +1490,10 @@ static int intel_th_msc_release(struct inode *inode, struct file *file) · 1489 unmodified lines | ||
| 1490 | 1490 | { |
| 1491 | 1491 | struct msc_iter *iter = file->private_data; |
| 1492 | 1492 | struct msc *msc = iter->msc; |
| 1493 | + struct intel_th_device *thdev = msc->thdev; | |
| 1493 | 1494 | |
| 1494 | 1495 | msc_iter_remove(iter, msc); |
| 1496 | + put_device(&thdev->dev); | |
| 1495 | 1497 | |
| 1496 | 1498 | return 0; |
| 1497 | 1499 | } |
| @@ -113,7 +113,7 @@ static void bng_re_fill_fw_msg(struct bnge_fw_msg *fw_msg, void *msg, · 112 unmodified lines | ||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | static int bng_re_net_ring_free(struct bng_re_dev *rdev, |
| 116 | − u16 fw_ring_id, int type) | |
| 116 | + u32 fw_ring_id, int type) | |
| 117 | 117 | { |
| 118 | 118 | struct bnge_auxr_dev *aux_dev = rdev->aux_dev; |
| 119 | 119 | struct hwrm_ring_free_input req = {}; |
| @@ -123,7 +123,7 @@ static int bng_re_net_ring_free(struct bng_re_dev *rdev, · 3 unmodified lines | ||
| 123 | 123 | |
| 124 | 124 | bng_re_init_hwrm_hdr((void *)&req, HWRM_RING_FREE); |
| 125 | 125 | req.ring_type = type; |
| 126 | − req.ring_id = cpu_to_le16(fw_ring_id); | |
| 126 | + req.ring_id = cpu_to_le32(fw_ring_id); | |
| 127 | 127 | bng_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp, |
| 128 | 128 | sizeof(resp), BNGE_DFLT_HWRM_CMD_TIMEOUT); |
| 129 | 129 | rc = bnge_send_msg(aux_dev, &fw_msg); |
| @@ -161,7 +161,7 @@ static int bng_re_net_ring_alloc(struct bng_re_dev *rdev, · 31 unmodified lines | ||
| 161 | 161 | sizeof(resp), BNGE_DFLT_HWRM_CMD_TIMEOUT); |
| 162 | 162 | rc = bnge_send_msg(aux_dev, &fw_msg); |
| 163 | 163 | if (!rc) |
| 164 | − *fw_ring_id = le16_to_cpu(resp.ring_id); | |
| 164 | + *fw_ring_id = (u16)le32_to_cpu(resp.ring_id); | |
| 165 | 165 | |
| 166 | 166 | return rc; |
| 167 | 167 | } |
| @@ -3864,6 +3864,12 @@ not_found: · 3863 unmodified lines | ||
| 3864 | 3864 | return 1; |
| 3865 | 3865 | |
| 3866 | 3866 | found: |
| 3867 | + if (early_acpihid_map_size == EARLY_MAP_SIZE) { | |
| 3868 | + pr_err("Early ACPI HID map overflow - ignoring ivrs_acpihid%s\n", | |
| 3869 | + str); | |
| 3870 | + return 1; | |
| 3871 | + } | |
| 3872 | + | |
| 3867 | 3873 | p = acpiid; |
| 3868 | 3874 | hid = strsep(&p, ":"); |
| 3869 | 3875 | uid = p; |
| @@ -1450,11 +1450,23 @@ static int iommu_completion_wait(struct amd_iommu *iommu) · 1449 unmodified lines | ||
| 1450 | 1450 | int ret; |
| 1451 | 1451 | u64 data; |
| 1452 | 1452 | |
| 1453 | − if (!iommu->need_sync) | |
| 1454 | − return 0; | |
| 1455 | − | |
| 1456 | 1453 | raw_spin_lock_irqsave(&iommu->lock, flags); |
| 1457 | 1454 | |
| 1455 | + if (!iommu->need_sync) { | |
| 1456 | + /* | |
| 1457 | + * No command has been queued since the last completion-wait. | |
| 1458 | + * A concurrent CPU may have already queued that CWAIT and | |
| 1459 | + * cleared need_sync; need_sync == false only means a covering | |
| 1460 | + * CWAIT is queued, not that all prior commands have completed. | |
| 1461 | + * Wait for the last allocated sequence number so that any | |
| 1462 | + * command queued before this call (possibly on another CPU) | |
| 1463 | + * is guaranteed to have completed before returning. | |
| 1464 | + */ | |
| 1465 | + data = iommu->cmd_sem_val; | |
| 1466 | + raw_spin_unlock_irqrestore(&iommu->lock, flags); | |
| 1467 | + return wait_on_sem(iommu, data); | |
| 1468 | + } | |
| 1469 | + | |
| 1458 | 1470 | data = get_cmdsem_val(iommu); |
| 1459 | 1471 | build_completion_wait(&cmd, iommu, data); |
| 1460 | 1472 | |
| @@ -1464,9 +1476,7 @@ static int iommu_completion_wait(struct amd_iommu *iommu) · 3 unmodified lines | ||
| 1464 | 1476 | if (ret) |
| 1465 | 1477 | return ret; |
| 1466 | 1478 | |
| 1467 | − ret = wait_on_sem(iommu, data); | |
| 1468 | − | |
| 1469 | − return ret; | |
| 1479 | + return wait_on_sem(iommu, data); | |
| 1470 | 1480 | } |
| 1471 | 1481 | |
| 1472 | 1482 | static void domain_flush_complete(struct protection_domain *domain) |
| @@ -59,7 +59,9 @@ static int validate_gdte_nested(struct iommu_hwpt_amd_guest *gdte) · 58 unmodified lines | ||
| 59 | 59 | return 0; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | −static void *gdom_info_load_or_alloc_locked(struct xarray *xa, unsigned long index) | |
| 62 | +static void *gdom_info_load_or_alloc_locked(struct xarray *xa, | |
| 63 | + unsigned long index, | |
| 64 | + unsigned long *flags) | |
| 63 | 65 | { |
| 64 | 66 | struct guest_domain_mapping_info *elm, *res; |
| 65 | 67 | |
| @@ -67,13 +69,13 @@ static void *gdom_info_load_or_alloc_locked(struct xarray *xa, unsigned long ind · 1 unmodified line | ||
| 67 | 69 | if (elm) |
| 68 | 70 | return elm; |
| 69 | 71 | |
| 70 | − xa_unlock(xa); | |
| 72 | + xa_unlock_irqrestore(xa, *flags); | |
| 71 | 73 | elm = kzalloc_obj(struct guest_domain_mapping_info); |
| 72 | − xa_lock(xa); | |
| 74 | + xa_lock_irqsave(xa, *flags); | |
| 73 | 75 | if (!elm) |
| 74 | 76 | return ERR_PTR(-ENOMEM); |
| 75 | 77 | |
| 76 | − res = __xa_cmpxchg(xa, index, NULL, elm, GFP_KERNEL); | |
| 78 | + res = __xa_cmpxchg(xa, index, NULL, elm, GFP_ATOMIC); | |
| 77 | 79 | if (xa_is_err(res)) |
| 78 | 80 | res = ERR_PTR(xa_err(res)); |
| 79 | 81 | |
| @@ -95,6 +97,7 @@ amd_iommu_alloc_domain_nested(struct iommufd_viommu *viommu, u32 flags, · 15 unmodified lines | ||
| 95 | 97 | const struct iommu_user_data *user_data) |
| 96 | 98 | { |
| 97 | 99 | int ret; |
| 100 | + unsigned long irqflags; | |
| 98 | 101 | struct nested_domain *ndom; |
| 99 | 102 | struct guest_domain_mapping_info *gdom_info; |
| 100 | 103 | struct amd_iommu_viommu *aviommu = container_of(viommu, struct amd_iommu_viommu, core); |
| @@ -136,11 +139,12 @@ amd_iommu_alloc_domain_nested(struct iommufd_viommu *viommu, u32 flags, · 35 unmodified lines | ||
| 136 | 139 | * keep track of the gDomID mapping. When the S2 is changed, the INVALIDATE_IOMMU_PAGES |
| 137 | 140 | * command must be issued for each hDomID in the xarray. |
| 138 | 141 | */ |
| 139 | − xa_lock(&aviommu->gdomid_array); | |
| 142 | + xa_lock_irqsave(&aviommu->gdomid_array, irqflags); | |
| 140 | 143 | |
| 141 | − gdom_info = gdom_info_load_or_alloc_locked(&aviommu->gdomid_array, ndom->gdom_id); | |
| 144 | + gdom_info = gdom_info_load_or_alloc_locked(&aviommu->gdomid_array, | |
| 145 | + ndom->gdom_id, &irqflags); | |
| 142 | 146 | if (IS_ERR(gdom_info)) { |
| 143 | − xa_unlock(&aviommu->gdomid_array); | |
| 147 | + xa_unlock_irqrestore(&aviommu->gdomid_array, irqflags); | |
| 144 | 148 | ret = PTR_ERR(gdom_info); |
| 145 | 149 | goto out_err; |
| 146 | 150 | } |
| @@ -148,7 +152,7 @@ amd_iommu_alloc_domain_nested(struct iommufd_viommu *viommu, u32 flags, · 1 unmodified line | ||
| 148 | 152 | /* Check if gDomID exist */ |
| 149 | 153 | if (refcount_inc_not_zero(&gdom_info->users)) { |
| 150 | 154 | ndom->gdom_info = gdom_info; |
| 151 | − xa_unlock(&aviommu->gdomid_array); | |
| 155 | + xa_unlock_irqrestore(&aviommu->gdomid_array, irqflags); | |
| 152 | 156 | |
| 153 | 157 | pr_debug("%s: Found gdom_id=%#x, hdom_id=%#x\n", |
| 154 | 158 | __func__, ndom->gdom_id, gdom_info->hdom_id); |
| @@ -161,7 +165,7 @@ amd_iommu_alloc_domain_nested(struct iommufd_viommu *viommu, u32 flags, · 6 unmodified lines | ||
| 161 | 165 | if (gdom_info->hdom_id <= 0) { |
| 162 | 166 | __xa_cmpxchg(&aviommu->gdomid_array, |
| 163 | 167 | ndom->gdom_id, gdom_info, NULL, GFP_ATOMIC); |
| 164 | − xa_unlock(&aviommu->gdomid_array); | |
| 168 | + xa_unlock_irqrestore(&aviommu->gdomid_array, irqflags); | |
| 165 | 169 | ret = -ENOSPC; |
| 166 | 170 | goto out_err_gdom_info; |
| 167 | 171 | } |
| @@ -169,7 +173,7 @@ amd_iommu_alloc_domain_nested(struct iommufd_viommu *viommu, u32 flags, · 1 unmodified line | ||
| 169 | 173 | ndom->gdom_info = gdom_info; |
| 170 | 174 | refcount_set(&gdom_info->users, 1); |
| 171 | 175 | |
| 172 | − xa_unlock(&aviommu->gdomid_array); | |
| 176 | + xa_unlock_irqrestore(&aviommu->gdomid_array, irqflags); | |
| 173 | 177 | |
| 174 | 178 | pr_debug("%s: Allocate gdom_id=%#x, hdom_id=%#x\n", |
| 175 | 179 | __func__, ndom->gdom_id, gdom_info->hdom_id); |
| @@ -257,14 +261,15 @@ static int nested_attach_device(struct iommu_domain *dom, struct device *dev, · 81 unmodified lines | ||
| 257 | 261 | |
| 258 | 262 | static void nested_domain_free(struct iommu_domain *dom) |
| 259 | 263 | { |
| 264 | + unsigned long irqflags; | |
| 260 | 265 | struct guest_domain_mapping_info *curr; |
| 261 | − struct nested_domain *ndom = to_ndomain(dom); | |
| 266 | + struct nested_domain *ndom __free(kfree) = to_ndomain(dom); | |
| 262 | 267 | struct amd_iommu_viommu *aviommu = ndom->viommu; |
| 263 | 268 | |
| 264 | − xa_lock(&aviommu->gdomid_array); | |
| 269 | + xa_lock_irqsave(&aviommu->gdomid_array, irqflags); | |
| 265 | 270 | |
| 266 | 271 | if (!refcount_dec_and_test(&ndom->gdom_info->users)) { |
| 267 | − xa_unlock(&aviommu->gdomid_array); | |
| 272 | + xa_unlock_irqrestore(&aviommu->gdomid_array, irqflags); | |
| 268 | 273 | return; |
| 269 | 274 | } |
| 270 | 275 | |
| @@ -275,7 +280,7 @@ static void nested_domain_free(struct iommu_domain *dom) · 4 unmodified lines | ||
| 275 | 280 | curr = __xa_cmpxchg(&aviommu->gdomid_array, ndom->gdom_id, |
| 276 | 281 | ndom->gdom_info, NULL, GFP_ATOMIC); |
| 277 | 282 | |
| 278 | − xa_unlock(&aviommu->gdomid_array); | |
| 283 | + xa_unlock_irqrestore(&aviommu->gdomid_array, irqflags); | |
| 279 | 284 | if (WARN_ON(!curr || xa_err(curr))) |
| 280 | 285 | return; |
| 281 | 286 | |
| @@ -285,7 +290,6 @@ static void nested_domain_free(struct iommu_domain *dom) · 3 unmodified lines | ||
| 285 | 290 | |
| 286 | 291 | amd_iommu_pdom_id_free(ndom->gdom_info->hdom_id); |
| 287 | 292 | kfree(curr); |
| 288 | − kfree(ndom); | |
| 289 | 293 | } |
| 290 | 294 | |
| 291 | 295 | static const struct iommu_domain_ops nested_domain_ops = { |
| @@ -63,7 +63,7 @@ void dmar_latency_disable(struct intel_iommu *iommu, enum latency_type type) · 62 unmodified lines | ||
| 63 | 63 | return; |
| 64 | 64 | |
| 65 | 65 | spin_lock_irqsave(&latency_lock, flags); |
| 66 | − memset(&lstat[type], 0, sizeof(*lstat) * DMAR_LATENCY_NUM); | |
| 66 | + memset(&lstat[type], 0, sizeof(*lstat)); | |
| 67 | 67 | spin_unlock_irqrestore(&latency_lock, flags); |
| 68 | 68 | } |
| 69 | 69 | |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | |
| 28 | 28 | void intel_svm_check(struct intel_iommu *iommu) |
| 29 | 29 | { |
| 30 | − if (!pasid_supported(iommu)) | |
| 30 | + if (!pasid_supported(iommu) || !ecap_smpwc(iommu->ecap)) | |
| 31 | 31 | return; |
| 32 | 32 | |
| 33 | 33 | if (cpu_feature_enabled(X86_FEATURE_GBPAGES) && |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | * Intel Management Engine Interface (Intel MEI) Linux driver |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | +#include <linux/cleanup.h> | |
| 7 | 8 | #include <linux/module.h> |
| 8 | 9 | #include <linux/device.h> |
| 9 | 10 | #include <linux/kernel.h> |
| @@ -1330,15 +1331,16 @@ static void mei_dev_bus_put(struct mei_device *bus) · 1320 unmodified lines | ||
| 1330 | 1331 | static void mei_cl_bus_dev_release(struct device *dev) |
| 1331 | 1332 | { |
| 1332 | 1333 | struct mei_cl_device *cldev = to_mei_cl_device(dev); |
| 1333 | − struct mei_device *mdev = cldev->cl->dev; | |
| 1334 | + struct mei_device *bus = cldev->bus; | |
| 1334 | 1335 | struct mei_cl *cl; |
| 1335 | 1336 | |
| 1336 | − mei_cl_flush_queues(cldev->cl, NULL); | |
| 1337 | − mei_me_cl_put(cldev->me_cl); | |
| 1338 | − mei_dev_bus_put(cldev->bus); | |
| 1339 | − | |
| 1340 | − list_for_each_entry(cl, &mdev->file_list, link) | |
| 1341 | − WARN_ON(cl == cldev->cl); | |
| 1337 | + scoped_guard(mutex, &bus->device_lock) { | |
| 1338 | + mei_cl_flush_queues(cldev->cl, NULL); | |
| 1339 | + mei_me_cl_put(cldev->me_cl); | |
| 1340 | + list_for_each_entry(cl, &bus->file_list, link) | |
| 1341 | + WARN_ON(cl == cldev->cl); | |
| 1342 | + } | |
| 1343 | + mei_dev_bus_put(bus); | |
| 1342 | 1344 | |
| 1343 | 1345 | kfree(cldev->cl); |
| 1344 | 1346 | kfree(cldev); |
| @@ -367,7 +367,7 @@ static long nsm_dev_ioctl(struct file *file, unsigned int cmd, · 366 unmodified lines | ||
| 367 | 367 | /* Copy user argument struct to kernel argument struct */ |
| 368 | 368 | r = -EFAULT; |
| 369 | 369 | if (copy_from_user(&raw, argp, _IOC_SIZE(cmd))) |
| 370 | − goto out; | |
| 370 | + return r; | |
| 371 | 371 | |
| 372 | 372 | mutex_lock(&nsm->lock); |
| 373 | 373 | |
| @@ -413,6 +413,7 @@ static int nsm_device_init_vq(struct virtio_device *vdev) · 39 unmodified lines | ||
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | static const struct file_operations nsm_dev_fops = { |
| 416 | + .owner = THIS_MODULE, | |
| 416 | 417 | .unlocked_ioctl = nsm_dev_ioctl, |
| 417 | 418 | .compat_ioctl = compat_ptr_ioctl, |
| 418 | 419 | }; |
| @@ -1211,7 +1211,7 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) · 1210 unmodified lines | ||
| 1211 | 1211 | data = true; |
| 1212 | 1212 | } |
| 1213 | 1213 | v6 = false; |
| 1214 | − group.ip4 = iph->daddr; | |
| 1214 | + group.ip4 = ip_hdr(skb)->daddr; | |
| 1215 | 1215 | #if IS_ENABLED(CONFIG_IPV6) |
| 1216 | 1216 | } else if (iph->version == 6) { |
| 1217 | 1217 | ip6h = ipv6_hdr(skb); |
| @@ -1235,7 +1235,7 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) · 17 unmodified lines | ||
| 1235 | 1235 | data = true; |
| 1236 | 1236 | } |
| 1237 | 1237 | v6 = true; |
| 1238 | − group.ip6 = ip6h->daddr; | |
| 1238 | + group.ip6 = ipv6_hdr(skb)->daddr; | |
| 1239 | 1239 | #endif |
| 1240 | 1240 | } else { |
| 1241 | 1241 | dev->stats.tx_errors++; |
| @@ -1278,12 +1278,12 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) · 36 unmodified lines | ||
| 1278 | 1278 | hlist_for_each_entry_rcu(gnode, &tunnel->groups[hash], |
| 1279 | 1279 | node) { |
| 1280 | 1280 | if (!v6) { |
| 1281 | − if (gnode->group_addr.ip4 == iph->daddr) | |
| 1281 | + if (gnode->group_addr.ip4 == group.ip4) | |
| 1282 | 1282 | goto found; |
| 1283 | 1283 | #if IS_ENABLED(CONFIG_IPV6) |
| 1284 | 1284 | } else { |
| 1285 | 1285 | if (ipv6_addr_equal(&gnode->group_addr.ip6, |
| 1286 | − &ip6h->daddr)) | |
| 1286 | + &group.ip6)) | |
| 1287 | 1287 | goto found; |
| 1288 | 1288 | #endif |
| 1289 | 1289 | } |
| @@ -2000,14 +2000,18 @@ static void amt_igmpv3_report_handler(struct amt_dev *amt, struct sk_buff *skb, · 710 unmodified lines | ||
| 2000 | 2000 | struct igmpv3_report *ihrv3 = igmpv3_report_hdr(skb); |
| 2001 | 2001 | int len = skb_transport_offset(skb) + sizeof(*ihrv3); |
| 2002 | 2002 | void *zero_grec = (void *)&igmpv3_zero_grec; |
| 2003 | − struct iphdr *iph = ip_hdr(skb); | |
| 2004 | 2003 | struct amt_group_node *gnode; |
| 2005 | 2004 | union amt_addr group, host; |
| 2006 | 2005 | struct igmpv3_grec *grec; |
| 2006 | + __be32 saddr; | |
| 2007 | 2007 | u16 nsrcs; |
| 2008 | + u16 ngrec; | |
| 2008 | 2009 | int i; |
| 2009 | 2010 | |
| 2010 | − for (i = 0; i < ntohs(ihrv3->ngrec); i++) { | |
| 2011 | + saddr = ip_hdr(skb)->saddr; | |
| 2012 | + ngrec = ntohs(ihrv3->ngrec); | |
| 2013 | + | |
| 2014 | + for (i = 0; i < ngrec; i++) { | |
| 2011 | 2015 | len += sizeof(*grec); |
| 2012 | 2016 | if (!ip_mc_may_pull(skb, len)) |
| 2013 | 2017 | break; |
| @@ -2019,10 +2023,13 @@ static void amt_igmpv3_report_handler(struct amt_dev *amt, struct sk_buff *skb, · 5 unmodified lines | ||
| 2019 | 2023 | if (!ip_mc_may_pull(skb, len)) |
| 2020 | 2024 | break; |
| 2021 | 2025 | |
| 2026 | + grec = (void *)(skb->data + len - sizeof(*grec) - | |
| 2027 | + nsrcs * sizeof(__be32)); | |
| 2028 | + | |
| 2022 | 2029 | memset(&group, 0, sizeof(union amt_addr)); |
| 2023 | 2030 | group.ip4 = grec->grec_mca; |
| 2024 | 2031 | memset(&host, 0, sizeof(union amt_addr)); |
| 2025 | − host.ip4 = iph->saddr; | |
| 2032 | + host.ip4 = saddr; | |
| 2026 | 2033 | gnode = amt_lookup_group(tunnel, &group, &host, false); |
| 2027 | 2034 | if (!gnode) { |
| 2028 | 2035 | gnode = amt_add_group(amt, tunnel, &group, &host, |
| @@ -2162,14 +2169,18 @@ static void amt_mldv2_report_handler(struct amt_dev *amt, struct sk_buff *skb, · 133 unmodified lines | ||
| 2162 | 2169 | struct mld2_report *mld2r = (struct mld2_report *)icmp6_hdr(skb); |
| 2163 | 2170 | int len = skb_transport_offset(skb) + sizeof(*mld2r); |
| 2164 | 2171 | void *zero_grec = (void *)&mldv2_zero_grec; |
| 2165 | − struct ipv6hdr *ip6h = ipv6_hdr(skb); | |
| 2166 | 2172 | struct amt_group_node *gnode; |
| 2167 | 2173 | union amt_addr group, host; |
| 2168 | 2174 | struct mld2_grec *grec; |
| 2175 | + struct in6_addr saddr; | |
| 2169 | 2176 | u16 nsrcs; |
| 2177 | + u16 ngrec; | |
| 2170 | 2178 | int i; |
| 2171 | 2179 | |
| 2172 | − for (i = 0; i < ntohs(mld2r->mld2r_ngrec); i++) { | |
| 2180 | + saddr = ipv6_hdr(skb)->saddr; | |
| 2181 | + ngrec = ntohs(mld2r->mld2r_ngrec); | |
| 2182 | + | |
| 2183 | + for (i = 0; i < ngrec; i++) { | |
| 2173 | 2184 | len += sizeof(*grec); |
| 2174 | 2185 | if (!ipv6_mc_may_pull(skb, len)) |
| 2175 | 2186 | break; |
| @@ -2181,10 +2192,13 @@ static void amt_mldv2_report_handler(struct amt_dev *amt, struct sk_buff *skb, · 5 unmodified lines | ||
| 2181 | 2192 | if (!ipv6_mc_may_pull(skb, len)) |
| 2182 | 2193 | break; |
| 2183 | 2194 | |
| 2195 | + grec = (void *)(skb->data + len - sizeof(*grec) - | |
| 2196 | + nsrcs * sizeof(struct in6_addr)); | |
| 2197 | + | |
| 2184 | 2198 | memset(&group, 0, sizeof(union amt_addr)); |
| 2185 | 2199 | group.ip6 = grec->grec_mca; |
| 2186 | 2200 | memset(&host, 0, sizeof(union amt_addr)); |
| 2187 | − host.ip6 = ip6h->saddr; | |
| 2201 | + host.ip6 = saddr; | |
| 2188 | 2202 | gnode = amt_lookup_group(tunnel, &group, &host, true); |
| 2189 | 2203 | if (!gnode) { |
| 2190 | 2204 | gnode = amt_add_group(amt, tunnel, &group, &host, |
| @@ -2305,7 +2319,9 @@ static bool amt_multicast_data_handler(struct amt_dev *amt, struct sk_buff *skb) · 114 unmodified lines | ||
| 2305 | 2319 | skb_push(skb, sizeof(*eth)); |
| 2306 | 2320 | skb_reset_mac_header(skb); |
| 2307 | 2321 | skb_pull(skb, sizeof(*eth)); |
| 2308 | − eth = eth_hdr(skb); | |
| 2322 | + | |
| 2323 | + if (skb_cow_head(skb, 0)) | |
| 2324 | + return true; | |
| 2309 | 2325 | |
| 2310 | 2326 | if (!pskb_may_pull(skb, sizeof(*iph))) |
| 2311 | 2327 | return true; |
| @@ -2315,6 +2331,7 @@ static bool amt_multicast_data_handler(struct amt_dev *amt, struct sk_buff *skb) · 3 unmodified lines | ||
| 2315 | 2331 | if (!ipv4_is_multicast(iph->daddr)) |
| 2316 | 2332 | return true; |
| 2317 | 2333 | skb->protocol = htons(ETH_P_IP); |
| 2334 | + eth = eth_hdr(skb); | |
| 2318 | 2335 | eth->h_proto = htons(ETH_P_IP); |
| 2319 | 2336 | ip_eth_mc_map(iph->daddr, eth->h_dest); |
| 2320 | 2337 | #if IS_ENABLED(CONFIG_IPV6) |
| @@ -2328,6 +2345,7 @@ static bool amt_multicast_data_handler(struct amt_dev *amt, struct sk_buff *skb) · 7 unmodified lines | ||
| 2328 | 2345 | if (!ipv6_addr_is_multicast(&ip6h->daddr)) |
| 2329 | 2346 | return true; |
| 2330 | 2347 | skb->protocol = htons(ETH_P_IPV6); |
| 2348 | + eth = eth_hdr(skb); | |
| 2331 | 2349 | eth->h_proto = htons(ETH_P_IPV6); |
| 2332 | 2350 | ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest); |
| 2333 | 2351 | #endif |
| @@ -2351,10 +2369,12 @@ static bool amt_membership_query_handler(struct amt_dev *amt, · 17 unmodified lines | ||
| 2351 | 2369 | struct sk_buff *skb) |
| 2352 | 2370 | { |
| 2353 | 2371 | struct amt_header_membership_query *amtmq; |
| 2354 | − struct igmpv3_query *ihv3; | |
| 2355 | 2372 | struct ethhdr *eth, *oeth; |
| 2373 | + struct igmpv3_query *ihv3; | |
| 2374 | + u8 h_source[ETH_ALEN]; | |
| 2356 | 2375 | struct iphdr *iph; |
| 2357 | 2376 | int hdr_size, len; |
| 2377 | + u64 response_mac; | |
| 2358 | 2378 | |
| 2359 | 2379 | hdr_size = sizeof(*amtmq) + sizeof(struct udphdr); |
| 2360 | 2380 | if (!pskb_may_pull(skb, hdr_size)) |
| @@ -2367,6 +2387,8 @@ static bool amt_membership_query_handler(struct amt_dev *amt, · 6 unmodified lines | ||
| 2367 | 2387 | if (amtmq->nonce != amt->nonce) |
| 2368 | 2388 | return true; |
| 2369 | 2389 | |
| 2390 | + response_mac = amtmq->response_mac; | |
| 2391 | + | |
| 2370 | 2392 | hdr_size -= sizeof(*eth); |
| 2371 | 2393 | if (iptunnel_pull_header(skb, hdr_size, htons(ETH_P_TEB), false)) |
| 2372 | 2394 | return true; |
| @@ -2376,6 +2398,9 @@ static bool amt_membership_query_handler(struct amt_dev *amt, · 3 unmodified lines | ||
| 2376 | 2398 | skb_pull(skb, sizeof(*eth)); |
| 2377 | 2399 | skb_reset_network_header(skb); |
| 2378 | 2400 | eth = eth_hdr(skb); |
| 2401 | + ether_addr_copy(h_source, oeth->h_source); | |
| 2402 | + if (skb_cow_head(skb, 0)) | |
| 2403 | + return true; | |
| 2379 | 2404 | if (!pskb_may_pull(skb, sizeof(*iph))) |
| 2380 | 2405 | return true; |
| 2381 | 2406 | |
| @@ -2388,6 +2413,7 @@ static bool amt_membership_query_handler(struct amt_dev *amt, · 6 unmodified lines | ||
| 2388 | 2413 | sizeof(*ihv3))) |
| 2389 | 2414 | return true; |
| 2390 | 2415 | |
| 2416 | + iph = ip_hdr(skb); | |
| 2391 | 2417 | if (!ipv4_is_multicast(iph->daddr)) |
| 2392 | 2418 | return true; |
| 2393 | 2419 | |
| @@ -2395,10 +2421,11 @@ static bool amt_membership_query_handler(struct amt_dev *amt, · 1 unmodified line | ||
| 2395 | 2421 | skb_reset_transport_header(skb); |
| 2396 | 2422 | skb_push(skb, sizeof(*iph) + AMT_IPHDR_OPTS); |
| 2397 | 2423 | WRITE_ONCE(amt->ready4, true); |
| 2398 | − amt->mac = amtmq->response_mac; | |
| 2424 | + amt->mac = response_mac; | |
| 2399 | 2425 | amt->req_cnt = 0; |
| 2400 | 2426 | amt->qi = ihv3->qqic; |
| 2401 | 2427 | skb->protocol = htons(ETH_P_IP); |
| 2428 | + eth = eth_hdr(skb); | |
| 2402 | 2429 | eth->h_proto = htons(ETH_P_IP); |
| 2403 | 2430 | ip_eth_mc_map(iph->daddr, eth->h_dest); |
| 2404 | 2431 | #if IS_ENABLED(CONFIG_IPV6) |
| @@ -2421,10 +2448,11 @@ static bool amt_membership_query_handler(struct amt_dev *amt, · 16 unmodified lines | ||
| 2421 | 2448 | skb_reset_transport_header(skb); |
| 2422 | 2449 | skb_push(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS); |
| 2423 | 2450 | WRITE_ONCE(amt->ready6, true); |
| 2424 | − amt->mac = amtmq->response_mac; | |
| 2451 | + amt->mac = response_mac; | |
| 2425 | 2452 | amt->req_cnt = 0; |
| 2426 | 2453 | amt->qi = mld2q->mld2q_qqic; |
| 2427 | 2454 | skb->protocol = htons(ETH_P_IPV6); |
| 2455 | + eth = eth_hdr(skb); | |
| 2428 | 2456 | eth->h_proto = htons(ETH_P_IPV6); |
| 2429 | 2457 | ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest); |
| 2430 | 2458 | #endif |
| @@ -2432,7 +2460,7 @@ static bool amt_membership_query_handler(struct amt_dev *amt, · 1 unmodified line | ||
| 2432 | 2460 | return true; |
| 2433 | 2461 | } |
| 2434 | 2462 | |
| 2435 | − ether_addr_copy(eth->h_source, oeth->h_source); | |
| 2463 | + ether_addr_copy(eth->h_source, h_source); | |
| 2436 | 2464 | skb->pkt_type = PACKET_MULTICAST; |
| 2437 | 2465 | skb->ip_summed = CHECKSUM_NONE; |
| 2438 | 2466 | len = skb->len; |
| @@ -2455,8 +2483,11 @@ static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb) · 16 unmodified lines | ||
| 2455 | 2483 | struct ethhdr *eth; |
| 2456 | 2484 | struct iphdr *iph; |
| 2457 | 2485 | int len, hdr_size; |
| 2486 | + u64 response_mac; | |
| 2487 | + __be32 saddr; | |
| 2488 | + __be32 nonce; | |
| 2458 | 2489 | |
| 2459 | − iph = ip_hdr(skb); | |
| 2490 | + saddr = ip_hdr(skb)->saddr; | |
| 2460 | 2491 | |
| 2461 | 2492 | hdr_size = sizeof(*amtmu) + sizeof(struct udphdr); |
| 2462 | 2493 | if (!pskb_may_pull(skb, hdr_size)) |
| @@ -2466,15 +2497,18 @@ static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb) · 3 unmodified lines | ||
| 2466 | 2497 | if (amtmu->reserved || amtmu->version) |
| 2467 | 2498 | return true; |
| 2468 | 2499 | |
| 2500 | + nonce = amtmu->nonce; | |
| 2501 | + response_mac = amtmu->response_mac; | |
| 2502 | + | |
| 2469 | 2503 | if (iptunnel_pull_header(skb, hdr_size, skb->protocol, false)) |
| 2470 | 2504 | return true; |
| 2471 | 2505 | |
| 2472 | 2506 | skb_reset_network_header(skb); |
| 2473 | 2507 | |
| 2474 | 2508 | list_for_each_entry_rcu(tunnel, &amt->tunnel_list, list) { |
| 2475 | − if (tunnel->ip4 == iph->saddr) { | |
| 2476 | − if ((amtmu->nonce == tunnel->nonce && | |
| 2477 | − amtmu->response_mac == tunnel->mac)) { | |
| 2509 | + if (tunnel->ip4 == saddr) { | |
| 2510 | + if ((nonce == tunnel->nonce && | |
| 2511 | + response_mac == tunnel->mac)) { | |
| 2478 | 2512 | mod_delayed_work(amt_wq, &tunnel->gc_wq, |
| 2479 | 2513 | msecs_to_jiffies(amt_gmi(amt)) |
| 2480 | 2514 | * 3); |
| @@ -2492,6 +2526,9 @@ report: · 11 unmodified lines | ||
| 2492 | 2526 | if (!pskb_may_pull(skb, sizeof(*iph))) |
| 2493 | 2527 | return true; |
| 2494 | 2528 | |
| 2529 | + if (skb_cow_head(skb, 0)) | |
| 2530 | + return true; | |
| 2531 | + | |
| 2495 | 2532 | iph = ip_hdr(skb); |
| 2496 | 2533 | if (iph->version == 4) { |
| 2497 | 2534 | if (ip_mc_check_igmp(skb)) { |
| @@ -2508,6 +2545,7 @@ report: · 10 unmodified lines | ||
| 2508 | 2545 | eth = eth_hdr(skb); |
| 2509 | 2546 | skb->protocol = htons(ETH_P_IP); |
| 2510 | 2547 | eth->h_proto = htons(ETH_P_IP); |
| 2548 | + iph = ip_hdr(skb); | |
| 2511 | 2549 | ip_eth_mc_map(iph->daddr, eth->h_dest); |
| 2512 | 2550 | #if IS_ENABLED(CONFIG_IPV6) |
| 2513 | 2551 | } else if (iph->version == 6) { |
| @@ -2527,6 +2565,7 @@ report: · 13 unmodified lines | ||
| 2527 | 2565 | eth = eth_hdr(skb); |
| 2528 | 2566 | skb->protocol = htons(ETH_P_IPV6); |
| 2529 | 2567 | eth->h_proto = htons(ETH_P_IPV6); |
| 2568 | + ip6h = ipv6_hdr(skb); | |
| 2530 | 2569 | ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest); |
| 2531 | 2570 | #endif |
| 2532 | 2571 | } else { |
| @@ -2772,7 +2811,7 @@ drop: · 239 unmodified lines | ||
| 2772 | 2811 | static int amt_rcv(struct sock *sk, struct sk_buff *skb) |
| 2773 | 2812 | { |
| 2774 | 2813 | struct amt_dev *amt; |
| 2775 | − struct iphdr *iph; | |
| 2814 | + __be32 saddr; | |
| 2776 | 2815 | int type; |
| 2777 | 2816 | bool err; |
| 2778 | 2817 | |
| @@ -2785,7 +2824,7 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb) · 6 unmodified lines | ||
| 2785 | 2824 | } |
| 2786 | 2825 | |
| 2787 | 2826 | skb->dev = amt->dev; |
| 2788 | − iph = ip_hdr(skb); | |
| 2827 | + saddr = ip_hdr(skb)->saddr; | |
| 2789 | 2828 | type = amt_parse_type(skb); |
| 2790 | 2829 | if (type == -1) { |
| 2791 | 2830 | err = true; |
| @@ -2795,7 +2834,7 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb) · 3 unmodified lines | ||
| 2795 | 2834 | if (amt->mode == AMT_MODE_GATEWAY) { |
| 2796 | 2835 | switch (type) { |
| 2797 | 2836 | case AMT_MSG_ADVERTISEMENT: |
| 2798 | − if (iph->saddr != amt->discovery_ip) { | |
| 2837 | + if (saddr != amt->discovery_ip) { | |
| 2799 | 2838 | netdev_dbg(amt->dev, "Invalid Relay IP\n"); |
| 2800 | 2839 | err = true; |
| 2801 | 2840 | goto drop; |
| @@ -2807,7 +2846,7 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb) · 5 unmodified lines | ||
| 2807 | 2846 | } |
| 2808 | 2847 | goto out; |
| 2809 | 2848 | case AMT_MSG_MULTICAST_DATA: |
| 2810 | − if (iph->saddr != amt->remote_ip) { | |
| 2849 | + if (saddr != amt->remote_ip) { | |
| 2811 | 2850 | netdev_dbg(amt->dev, "Invalid Relay IP\n"); |
| 2812 | 2851 | err = true; |
| 2813 | 2852 | goto drop; |
| @@ -2818,7 +2857,7 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb) · 4 unmodified lines | ||
| 2818 | 2857 | else |
| 2819 | 2858 | goto out; |
| 2820 | 2859 | case AMT_MSG_MEMBERSHIP_QUERY: |
| 2821 | − if (iph->saddr != amt->remote_ip) { | |
| 2860 | + if (saddr != amt->remote_ip) { | |
| 2822 | 2861 | netdev_dbg(amt->dev, "Invalid Relay IP\n"); |
| 2823 | 2862 | err = true; |
| 2824 | 2863 | goto drop; |
| @@ -2995,9 +3034,15 @@ static int amt_dev_open(struct net_device *dev) · 170 unmodified lines | ||
| 2995 | 3034 | amt->event_idx = 0; |
| 2996 | 3035 | amt->nr_events = 0; |
| 2997 | 3036 | |
| 3037 | + enable_delayed_work(&amt->discovery_wq); | |
| 3038 | + enable_delayed_work(&amt->req_wq); | |
| 3039 | + | |
| 2998 | 3040 | err = amt_socket_create(amt); |
| 2999 | − if (err) | |
| 3041 | + if (err) { | |
| 3042 | + disable_delayed_work(&amt->req_wq); | |
| 3043 | + disable_delayed_work(&amt->discovery_wq); | |
| 3000 | 3044 | return err; |
| 3045 | + } | |
| 3001 | 3046 | |
| 3002 | 3047 | amt->req_cnt = 0; |
| 3003 | 3048 | amt->remote_ip = 0; |
| @@ -3023,8 +3068,8 @@ static int amt_dev_stop(struct net_device *dev) · 19 unmodified lines | ||
| 3023 | 3068 | struct sock *sk; |
| 3024 | 3069 | int i; |
| 3025 | 3070 | |
| 3026 | − cancel_delayed_work_sync(&amt->req_wq); | |
| 3027 | − cancel_delayed_work_sync(&amt->discovery_wq); | |
| 3071 | + disable_delayed_work_sync(&amt->req_wq); | |
| 3072 | + disable_delayed_work_sync(&amt->discovery_wq); | |
| 3028 | 3073 | cancel_delayed_work_sync(&amt->secret_wq); |
| 3029 | 3074 | |
| 3030 | 3075 | /* shutdown */ |
| @@ -3278,6 +3323,8 @@ static int amt_newlink(struct net_device *dev, · 247 unmodified lines | ||
| 3278 | 3323 | INIT_DELAYED_WORK(&amt->req_wq, amt_req_work); |
| 3279 | 3324 | INIT_DELAYED_WORK(&amt->secret_wq, amt_secret_work); |
| 3280 | 3325 | INIT_WORK(&amt->event_wq, amt_event_work); |
| 3326 | + disable_delayed_work(&amt->req_wq); | |
| 3327 | + disable_delayed_work(&amt->discovery_wq); | |
| 3281 | 3328 | INIT_LIST_HEAD(&amt->tunnel_list); |
| 3282 | 3329 | return 0; |
| 3283 | 3330 | err: |
| @@ -3455,7 +3455,8 @@ static void bond_send_validate(struct bonding *bond, struct slave *slave) · 3454 unmodified lines | ||
| 3455 | 3455 | { |
| 3456 | 3456 | bond_arp_send_all(bond, slave); |
| 3457 | 3457 | #if IS_ENABLED(CONFIG_IPV6) |
| 3458 | − bond_ns_send_all(bond, slave); | |
| 3458 | + if (likely(ipv6_mod_enabled())) | |
| 3459 | + bond_ns_send_all(bond, slave); | |
| 3459 | 3460 | #endif |
| 3460 | 3461 | } |
| 3461 | 3462 | |
| @@ -1686,11 +1686,14 @@ static void airoha_qdma_stop_napi(struct airoha_qdma *qdma) · 1685 unmodified lines | ||
| 1686 | 1686 | } |
| 1687 | 1687 | } |
| 1688 | 1688 | |
| 1689 | −static void airoha_dev_get_hw_stats(struct airoha_gdm_dev *dev) | |
| 1689 | +static void airoha_update_hw_stats(struct airoha_gdm_dev *dev) | |
| 1690 | 1690 | { |
| 1691 | 1691 | struct airoha_gdm_port *port = dev->port; |
| 1692 | 1692 | struct airoha_eth *eth = dev->eth; |
| 1693 | 1693 | u32 val, i = 0; |
| 1694 | + u64 data; | |
| 1695 | + | |
| 1696 | + spin_lock(&port->stats_lock); | |
| 1694 | 1697 | |
| 1695 | 1698 | /* Read relevant MIB for GDM with multiple port attached */ |
| 1696 | 1699 | if (port->id == AIROHA_GDM3_IDX || port->id == AIROHA_GDM4_IDX) |
| @@ -1701,152 +1704,188 @@ static void airoha_dev_get_hw_stats(struct airoha_gdm_dev *dev) · 4 unmodified lines | ||
| 1701 | 1704 | |
| 1702 | 1705 | u64_stats_update_begin(&dev->stats.syncp); |
| 1703 | 1706 | |
| 1704 | − /* TX */ | |
| 1707 | + /* TX - 64-bit H+L registers: hw accumulates the total, read directly. | |
| 1708 | + * Use local variable to prevent readers from seeing intermediate values. | |
| 1709 | + * Clamp to prevent regression from torn reads between H and L. | |
| 1710 | + */ | |
| 1705 | 1711 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_OK_PKT_CNT_H(port->id)); |
| 1706 | − dev->stats.tx_ok_pkts += ((u64)val << 32); | |
| 1712 | + data = (u64)val << 32; | |
| 1707 | 1713 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_OK_PKT_CNT_L(port->id)); |
| 1708 | − dev->stats.tx_ok_pkts += val; | |
| 1714 | + data += val; | |
| 1715 | + dev->stats.tx_ok_pkts = max(data, dev->stats.tx_ok_pkts); | |
| 1709 | 1716 | |
| 1710 | 1717 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_OK_BYTE_CNT_H(port->id)); |
| 1711 | − dev->stats.tx_ok_bytes += ((u64)val << 32); | |
| 1718 | + data = (u64)val << 32; | |
| 1712 | 1719 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_OK_BYTE_CNT_L(port->id)); |
| 1713 | − dev->stats.tx_ok_bytes += val; | |
| 1720 | + data += val; | |
| 1721 | + dev->stats.tx_ok_bytes = max(data, dev->stats.tx_ok_bytes); | |
| 1714 | 1722 | |
| 1723 | + /* TX - 32-bit registers: accumulate delta to handle wrap-around. */ | |
| 1715 | 1724 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_DROP_CNT(port->id)); |
| 1716 | − dev->stats.tx_drops += val; | |
| 1725 | + dev->stats.tx_drops += (u32)(val - dev->stats.mib_prev.tx_drops); | |
| 1726 | + dev->stats.mib_prev.tx_drops = val; | |
| 1717 | 1727 | |
| 1718 | 1728 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_BC_CNT(port->id)); |
| 1719 | − dev->stats.tx_broadcast += val; | |
| 1729 | + dev->stats.tx_broadcast += (u32)(val - dev->stats.mib_prev.tx_broadcast); | |
| 1730 | + dev->stats.mib_prev.tx_broadcast = val; | |
| 1720 | 1731 | |
| 1721 | 1732 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_MC_CNT(port->id)); |
| 1722 | − dev->stats.tx_multicast += val; | |
| 1733 | + dev->stats.tx_multicast += (u32)(val - dev->stats.mib_prev.tx_multicast); | |
| 1734 | + dev->stats.mib_prev.tx_multicast = val; | |
| 1723 | 1735 | |
| 1724 | 1736 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_RUNT_CNT(port->id)); |
| 1725 | − dev->stats.tx_len[i] += val; | |
| 1737 | + dev->stats.mib_prev.tx_runt64 += | |
| 1738 | + (u32)(val - dev->stats.mib_prev.tx_runt); | |
| 1739 | + dev->stats.mib_prev.tx_runt = val; | |
| 1726 | 1740 | |
| 1741 | + /* tx_len[0]: RUNT (32-bit, delta) + E64 (64-bit, absolute). */ | |
| 1742 | + data = dev->stats.mib_prev.tx_runt64; | |
| 1727 | 1743 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_E64_CNT_H(port->id)); |
| 1728 | − dev->stats.tx_len[i] += ((u64)val << 32); | |
| 1744 | + data += (u64)val << 32; | |
| 1729 | 1745 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_E64_CNT_L(port->id)); |
| 1730 | − dev->stats.tx_len[i++] += val; | |
| 1746 | + data += val; | |
| 1747 | + dev->stats.tx_len[i] = max(data, dev->stats.tx_len[i]); | |
| 1748 | + i++; | |
| 1731 | 1749 | |
| 1732 | 1750 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L64_CNT_H(port->id)); |
| 1733 | − dev->stats.tx_len[i] += ((u64)val << 32); | |
| 1751 | + data = (u64)val << 32; | |
| 1734 | 1752 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L64_CNT_L(port->id)); |
| 1735 | − dev->stats.tx_len[i++] += val; | |
| 1753 | + data += val; | |
| 1754 | + dev->stats.tx_len[i] = max(data, dev->stats.tx_len[i]); | |
| 1755 | + i++; | |
| 1736 | 1756 | |
| 1737 | 1757 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L127_CNT_H(port->id)); |
| 1738 | − dev->stats.tx_len[i] += ((u64)val << 32); | |
| 1758 | + data = (u64)val << 32; | |
| 1739 | 1759 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L127_CNT_L(port->id)); |
| 1740 | − dev->stats.tx_len[i++] += val; | |
| 1760 | + data += val; | |
| 1761 | + dev->stats.tx_len[i] = max(data, dev->stats.tx_len[i]); | |
| 1762 | + i++; | |
| 1741 | 1763 | |
| 1742 | 1764 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L255_CNT_H(port->id)); |
| 1743 | − dev->stats.tx_len[i] += ((u64)val << 32); | |
| 1765 | + data = (u64)val << 32; | |
| 1744 | 1766 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L255_CNT_L(port->id)); |
| 1745 | − dev->stats.tx_len[i++] += val; | |
| 1767 | + data += val; | |
| 1768 | + dev->stats.tx_len[i] = max(data, dev->stats.tx_len[i]); | |
| 1769 | + i++; | |
| 1746 | 1770 | |
| 1747 | 1771 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L511_CNT_H(port->id)); |
| 1748 | − dev->stats.tx_len[i] += ((u64)val << 32); | |
| 1772 | + data = (u64)val << 32; | |
| 1749 | 1773 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L511_CNT_L(port->id)); |
| 1750 | − dev->stats.tx_len[i++] += val; | |
| 1774 | + data += val; | |
| 1775 | + dev->stats.tx_len[i] = max(data, dev->stats.tx_len[i]); | |
| 1776 | + i++; | |
| 1751 | 1777 | |
| 1752 | 1778 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L1023_CNT_H(port->id)); |
| 1753 | − dev->stats.tx_len[i] += ((u64)val << 32); | |
| 1779 | + data = (u64)val << 32; | |
| 1754 | 1780 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L1023_CNT_L(port->id)); |
| 1755 | − dev->stats.tx_len[i++] += val; | |
| 1781 | + data += val; | |
| 1782 | + dev->stats.tx_len[i] = max(data, dev->stats.tx_len[i]); | |
| 1783 | + i++; | |
| 1756 | 1784 | |
| 1757 | 1785 | val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_LONG_CNT(port->id)); |
| 1758 | − dev->stats.tx_len[i++] += val; | |
| 1786 | + dev->stats.tx_len[i++] += (u32)(val - dev->stats.mib_prev.tx_long); | |
| 1787 | + dev->stats.mib_prev.tx_long = val; | |
| 1759 | 1788 | |
| 1760 | 1789 | /* RX */ |
| 1761 | 1790 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_OK_PKT_CNT_H(port->id)); |
| 1762 | − dev->stats.rx_ok_pkts += ((u64)val << 32); | |
| 1791 | + data = (u64)val << 32; | |
| 1763 | 1792 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_OK_PKT_CNT_L(port->id)); |
| 1764 | − dev->stats.rx_ok_pkts += val; | |
| 1793 | + data += val; | |
| 1794 | + dev->stats.rx_ok_pkts = max(data, dev->stats.rx_ok_pkts); | |
| 1765 | 1795 | |
| 1766 | 1796 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_OK_BYTE_CNT_H(port->id)); |
| 1767 | − dev->stats.rx_ok_bytes += ((u64)val << 32); | |
| 1797 | + data = (u64)val << 32; | |
| 1768 | 1798 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_OK_BYTE_CNT_L(port->id)); |
| 1769 | − dev->stats.rx_ok_bytes += val; | |
| 1799 | + data += val; | |
| 1800 | + dev->stats.rx_ok_bytes = max(data, dev->stats.rx_ok_bytes); | |
| 1770 | 1801 | |
| 1771 | 1802 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_DROP_CNT(port->id)); |
| 1772 | − dev->stats.rx_drops += val; | |
| 1803 | + dev->stats.rx_drops += (u32)(val - dev->stats.mib_prev.rx_drops); | |
| 1804 | + dev->stats.mib_prev.rx_drops = val; | |
| 1773 | 1805 | |
| 1774 | 1806 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_BC_CNT(port->id)); |
| 1775 | − dev->stats.rx_broadcast += val; | |
| 1807 | + dev->stats.rx_broadcast += (u32)(val - dev->stats.mib_prev.rx_broadcast); | |
| 1808 | + dev->stats.mib_prev.rx_broadcast = val; | |
| 1776 | 1809 | |
| 1777 | 1810 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_MC_CNT(port->id)); |
| 1778 | − dev->stats.rx_multicast += val; | |
| 1811 | + dev->stats.rx_multicast += (u32)(val - dev->stats.mib_prev.rx_multicast); | |
| 1812 | + dev->stats.mib_prev.rx_multicast = val; | |
| 1779 | 1813 | |
| 1780 | 1814 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ERROR_DROP_CNT(port->id)); |
| 1781 | − dev->stats.rx_errors += val; | |
| 1815 | + dev->stats.rx_errors += (u32)(val - dev->stats.mib_prev.rx_errors); | |
| 1816 | + dev->stats.mib_prev.rx_errors = val; | |
| 1782 | 1817 | |
| 1783 | 1818 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_CRC_ERR_CNT(port->id)); |
| 1784 | − dev->stats.rx_crc_error += val; | |
| 1819 | + dev->stats.rx_crc_error += (u32)(val - dev->stats.mib_prev.rx_crc_error); | |
| 1820 | + dev->stats.mib_prev.rx_crc_error = val; | |
| 1785 | 1821 | |
| 1786 | 1822 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_OVERFLOW_DROP_CNT(port->id)); |
| 1787 | − dev->stats.rx_over_errors += val; | |
| 1823 | + dev->stats.rx_over_errors += (u32)(val - dev->stats.mib_prev.rx_over_errors); | |
| 1824 | + dev->stats.mib_prev.rx_over_errors = val; | |
| 1788 | 1825 | |
| 1789 | 1826 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_FRAG_CNT(port->id)); |
| 1790 | − dev->stats.rx_fragment += val; | |
| 1827 | + dev->stats.rx_fragment += (u32)(val - dev->stats.mib_prev.rx_fragment); | |
| 1828 | + dev->stats.mib_prev.rx_fragment = val; | |
| 1791 | 1829 | |
| 1792 | 1830 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_JABBER_CNT(port->id)); |
| 1793 | − dev->stats.rx_jabber += val; | |
| 1831 | + dev->stats.rx_jabber += (u32)(val - dev->stats.mib_prev.rx_jabber); | |
| 1832 | + dev->stats.mib_prev.rx_jabber = val; | |
| 1794 | 1833 | |
| 1795 | 1834 | i = 0; |
| 1796 | 1835 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_RUNT_CNT(port->id)); |
| 1797 | − dev->stats.rx_len[i] += val; | |
| 1836 | + dev->stats.mib_prev.rx_runt64 += | |
| 1837 | + (u32)(val - dev->stats.mib_prev.rx_runt); | |
| 1838 | + dev->stats.mib_prev.rx_runt = val; | |
| 1798 | 1839 | |
| 1840 | + /* rx_len[0]: RUNT (32-bit, delta) + E64 (64-bit, absolute). */ | |
| 1841 | + data = dev->stats.mib_prev.rx_runt64; | |
| 1799 | 1842 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_E64_CNT_H(port->id)); |
| 1800 | − dev->stats.rx_len[i] += ((u64)val << 32); | |
| 1843 | + data += (u64)val << 32; | |
| 1801 | 1844 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_E64_CNT_L(port->id)); |
| 1802 | − dev->stats.rx_len[i++] += val; | |
| 1845 | + data += val; | |
| 1846 | + dev->stats.rx_len[i] = max(data, dev->stats.rx_len[i]); | |
| 1847 | + i++; | |
| 1803 | 1848 | |
| 1804 | 1849 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L64_CNT_H(port->id)); |
| 1805 | − dev->stats.rx_len[i] += ((u64)val << 32); | |
| 1850 | + data = (u64)val << 32; | |
| 1806 | 1851 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L64_CNT_L(port->id)); |
| 1807 | − dev->stats.rx_len[i++] += val; | |
| 1852 | + data += val; | |
| 1853 | + dev->stats.rx_len[i] = max(data, dev->stats.rx_len[i]); | |
| 1854 | + i++; | |
| 1808 | 1855 | |
| 1809 | 1856 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L127_CNT_H(port->id)); |
| 1810 | − dev->stats.rx_len[i] += ((u64)val << 32); | |
| 1857 | + data = (u64)val << 32; | |
| 1811 | 1858 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L127_CNT_L(port->id)); |
| 1812 | − dev->stats.rx_len[i++] += val; | |
| 1859 | + data += val; | |
| 1860 | + dev->stats.rx_len[i] = max(data, dev->stats.rx_len[i]); | |
| 1861 | + i++; | |
| 1813 | 1862 | |
| 1814 | 1863 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L255_CNT_H(port->id)); |
| 1815 | − dev->stats.rx_len[i] += ((u64)val << 32); | |
| 1864 | + data = (u64)val << 32; | |
| 1816 | 1865 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L255_CNT_L(port->id)); |
| 1817 | − dev->stats.rx_len[i++] += val; | |
| 1866 | + data += val; | |
| 1867 | + dev->stats.rx_len[i] = max(data, dev->stats.rx_len[i]); | |
| 1868 | + i++; | |
| 1818 | 1869 | |
| 1819 | 1870 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L511_CNT_H(port->id)); |
| 1820 | − dev->stats.rx_len[i] += ((u64)val << 32); | |
| 1871 | + data = (u64)val << 32; | |
| 1821 | 1872 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L511_CNT_L(port->id)); |
| 1822 | − dev->stats.rx_len[i++] += val; | |
| 1873 | + data += val; | |
| 1874 | + dev->stats.rx_len[i] = max(data, dev->stats.rx_len[i]); | |
| 1875 | + i++; | |
| 1823 | 1876 | |
| 1824 | 1877 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L1023_CNT_H(port->id)); |
| 1825 | − dev->stats.rx_len[i] += ((u64)val << 32); | |
| 1878 | + data = (u64)val << 32; | |
| 1826 | 1879 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L1023_CNT_L(port->id)); |
| 1827 | − dev->stats.rx_len[i++] += val; | |
| 1880 | + data += val; | |
| 1881 | + dev->stats.rx_len[i] = max(data, dev->stats.rx_len[i]); | |
| 1882 | + i++; | |
| 1828 | 1883 | |
| 1829 | 1884 | val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_LONG_CNT(port->id)); |
| 1830 | − dev->stats.rx_len[i++] += val; | |
| 1885 | + dev->stats.rx_len[i] += (u32)(val - dev->stats.mib_prev.rx_long); | |
| 1886 | + dev->stats.mib_prev.rx_long = val; | |
| 1831 | 1887 | |
| 1832 | 1888 | u64_stats_update_end(&dev->stats.syncp); |
| 1833 | −} | |
| 1834 | − | |
| 1835 | −static void airoha_update_hw_stats(struct airoha_gdm_dev *dev) | |
| 1836 | −{ | |
| 1837 | − struct airoha_gdm_port *port = dev->port; | |
| 1838 | − int i; | |
| 1839 | − | |
| 1840 | − spin_lock(&port->stats_lock); | |
| 1841 | − | |
| 1842 | − for (i = 0; i < ARRAY_SIZE(port->devs); i++) { | |
| 1843 | − if (port->devs[i]) | |
| 1844 | − airoha_dev_get_hw_stats(port->devs[i]); | |
| 1845 | − } | |
| 1846 | − | |
| 1847 | − /* Reset MIB counters */ | |
| 1848 | − airoha_fe_set(dev->eth, REG_FE_GDM_MIB_CLEAR(port->id), | |
| 1849 | − FE_GDM_MIB_RX_CLEAR_MASK | FE_GDM_MIB_TX_CLEAR_MASK); | |
| 1850 | 1889 | |
| 1851 | 1890 | spin_unlock(&port->stats_lock); |
| 1852 | 1891 | } |
| @@ -2504,8 +2543,7 @@ static int airoha_tc_setup_qdisc_ets(struct net_device *dev, · 651 unmodified lines | ||
| 2504 | 2543 | if (opt->parent == TC_H_ROOT) |
| 2505 | 2544 | return -EINVAL; |
| 2506 | 2545 | |
| 2507 | − channel = TC_H_MAJ(opt->handle) >> 16; | |
| 2508 | − channel = channel % AIROHA_NUM_QOS_CHANNELS; | |
| 2546 | + channel = TC_H_MIN(opt->parent) % AIROHA_NUM_QOS_CHANNELS; | |
| 2509 | 2547 | |
| 2510 | 2548 | switch (opt->command) { |
| 2511 | 2549 | case TC_ETS_REPLACE: |
| @@ -245,6 +245,33 @@ struct airoha_hw_stats { · 244 unmodified lines | ||
| 245 | 245 | u64 rx_fragment; |
| 246 | 246 | u64 rx_jabber; |
| 247 | 247 | u64 rx_len[7]; |
| 248 | + | |
| 249 | + struct { | |
| 250 | + /* Previous HW register values for 32-bit counter delta | |
| 251 | + * tracking. Storing the last seen value and accumulating | |
| 252 | + * (u32)(curr - prev) into the 64-bit software counter | |
| 253 | + * handles wrap-around transparently via unsigned arithmetic. | |
| 254 | + * tx_runt64/rx_runt64 hold the running sum of runt deltas. | |
| 255 | + * These fields are never reported to userspace. | |
| 256 | + */ | |
| 257 | + u32 tx_drops; | |
| 258 | + u32 tx_broadcast; | |
| 259 | + u32 tx_multicast; | |
| 260 | + u32 tx_runt; | |
| 261 | + u32 tx_long; | |
| 262 | + u64 tx_runt64; | |
| 263 | + u32 rx_drops; | |
| 264 | + u32 rx_broadcast; | |
| 265 | + u32 rx_multicast; | |
| 266 | + u32 rx_errors; | |
| 267 | + u32 rx_crc_error; | |
| 268 | + u32 rx_over_errors; | |
| 269 | + u32 rx_fragment; | |
| 270 | + u32 rx_jabber; | |
| 271 | + u32 rx_runt; | |
| 272 | + u32 rx_long; | |
| 273 | + u64 rx_runt64; | |
| 274 | + } mib_prev; | |
| 248 | 275 | }; |
| 249 | 276 | |
| 250 | 277 | enum { |
| @@ -168,7 +168,7 @@ static int airoha_npu_send_msg(struct airoha_npu *npu, int func_id, · 167 unmodified lines | ||
| 168 | 168 | dma_addr_t dma_addr; |
| 169 | 169 | int ret; |
| 170 | 170 | |
| 171 | − dma_addr = dma_map_single(npu->dev, p, size, DMA_TO_DEVICE); | |
| 171 | + dma_addr = dma_map_single(npu->dev, p, size, DMA_BIDIRECTIONAL); | |
| 172 | 172 | ret = dma_mapping_error(npu->dev, dma_addr); |
| 173 | 173 | if (ret) |
| 174 | 174 | return ret; |
| @@ -191,7 +191,7 @@ static int airoha_npu_send_msg(struct airoha_npu *npu, int func_id, · 16 unmodified lines | ||
| 191 | 191 | |
| 192 | 192 | spin_unlock_bh(&npu->cores[core].lock); |
| 193 | 193 | |
| 194 | − dma_unmap_single(npu->dev, dma_addr, size, DMA_TO_DEVICE); | |
| 194 | + dma_unmap_single(npu->dev, dma_addr, size, DMA_BIDIRECTIONAL); | |
| 195 | 195 | |
| 196 | 196 | return ret; |
| 197 | 197 | } |
| @@ -1659,6 +1659,7 @@ void airoha_ppe_deinit(struct airoha_eth *eth) · 1658 unmodified lines | ||
| 1659 | 1659 | npu = rcu_replace_pointer(eth->npu, NULL, |
| 1660 | 1660 | lockdep_is_held(&flow_offload_mutex)); |
| 1661 | 1661 | if (npu) { |
| 1662 | + synchronize_rcu(); | |
| 1662 | 1663 | npu->ops.ppe_deinit(npu); |
| 1663 | 1664 | airoha_npu_put(npu); |
| 1664 | 1665 | } |
| @@ -18,7 +18,13 @@ static int pdsc_process_notifyq(struct pdsc_qcq *qcq) · 17 unmodified lines | ||
| 18 | 18 | comp = cq_info->comp; |
| 19 | 19 | eid = le64_to_cpu(comp->event.eid); |
| 20 | 20 | while (eid > pdsc->last_eid) { |
| 21 | − u16 ecode = le16_to_cpu(comp->event.ecode); | |
| 21 | + u16 ecode; | |
| 22 | + | |
| 23 | + /* Order the payload read after the event id, the field the | |
| 24 | + * driver uses to detect a new completion. | |
| 25 | + */ | |
| 26 | + dma_rmb(); | |
| 27 | + ecode = le16_to_cpu(comp->event.ecode); | |
| 22 | 28 | |
| 23 | 29 | switch (ecode) { |
| 24 | 30 | case PDS_EVENT_LINK_CHANGE: |
| @@ -101,6 +107,10 @@ void pdsc_process_adminq(struct pdsc_qcq *qcq) · 76 unmodified lines | ||
| 101 | 107 | spin_lock_irqsave(&pdsc->adminq_lock, irqflags); |
| 102 | 108 | comp = cq->info[cq->tail_idx].comp; |
| 103 | 109 | while (pdsc_color_match(comp->color, cq->done_color)) { |
| 110 | + /* Order the payload reads after the color bit, the field the | |
| 111 | + * driver uses to detect a new completion. | |
| 112 | + */ | |
| 113 | + dma_rmb(); | |
| 104 | 114 | q_info = &q->info[q->tail_idx]; |
| 105 | 115 | q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1); |
| 106 | 116 | |
| @@ -177,17 +177,21 @@ void pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf, · 176 unmodified lines | ||
| 177 | 177 | { |
| 178 | 178 | struct pds_auxiliary_dev *padev; |
| 179 | 179 | |
| 180 | − if (!*pd_ptr) | |
| 181 | − return; | |
| 182 | − | |
| 183 | 180 | mutex_lock(&pf->config_lock); |
| 184 | 181 | |
| 182 | + /* A concurrent del may have already torn this device down and | |
| 183 | + * cleared it. | |
| 184 | + */ | |
| 185 | 185 | padev = *pd_ptr; |
| 186 | + if (!padev) | |
| 187 | + goto out_unlock; | |
| 188 | + | |
| 186 | 189 | pds_client_unregister(pf, padev->client_id); |
| 187 | 190 | auxiliary_device_delete(&padev->aux_dev); |
| 188 | 191 | auxiliary_device_uninit(&padev->aux_dev); |
| 189 | 192 | *pd_ptr = NULL; |
| 190 | 193 | |
| 194 | +out_unlock: | |
| 191 | 195 | mutex_unlock(&pf->config_lock); |
| 192 | 196 | } |
| 193 | 197 | |
| @@ -210,6 +214,13 @@ int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf, · 16 unmodified lines | ||
| 210 | 214 | |
| 211 | 215 | mutex_lock(&pf->config_lock); |
| 212 | 216 | |
| 217 | + /* Nothing to do if the aux device is already present. This also | |
| 218 | + * guards against a second add overwriting *pd_ptr and leaking the | |
| 219 | + * first, symmetric with the check in pdsc_auxbus_dev_del(). | |
| 220 | + */ | |
| 221 | + if (*pd_ptr) | |
| 222 | + goto out_unlock; | |
| 223 | + | |
| 213 | 224 | mask = BIT_ULL(PDSC_S_FW_DEAD) | |
| 214 | 225 | BIT_ULL(PDSC_S_STOPPING_DRIVER); |
| 215 | 226 | if (cf->state & mask) { |
| @@ -110,7 +110,6 @@ static void pdsc_qcq_intr_free(struct pdsc *pdsc, struct pdsc_qcq *qcq) · 109 unmodified lines | ||
| 110 | 110 | return; |
| 111 | 111 | |
| 112 | 112 | pdsc_intr_free(pdsc, qcq->intx); |
| 113 | − qcq->intx = PDS_CORE_INTR_INDEX_NOT_ASSIGNED; | |
| 114 | 113 | } |
| 115 | 114 | |
| 116 | 115 | static int pdsc_qcq_intr_alloc(struct pdsc *pdsc, struct pdsc_qcq *qcq) |
| @@ -145,6 +144,12 @@ void pdsc_qcq_free(struct pdsc *pdsc, struct pdsc_qcq *qcq) · 28 unmodified lines | ||
| 145 | 144 | |
| 146 | 145 | pdsc_qcq_intr_free(pdsc, qcq); |
| 147 | 146 | |
| 147 | + /* Drain any work queued by ISR before it was freed above */ | |
| 148 | + if (qcq->work.func) | |
| 149 | + cancel_work_sync(&qcq->work); | |
| 150 | + | |
| 151 | + qcq->intx = PDS_CORE_INTR_INDEX_NOT_ASSIGNED; | |
| 152 | + | |
| 148 | 153 | if (qcq->q_base) |
| 149 | 154 | dma_free_coherent(dev, qcq->q_size, |
| 150 | 155 | qcq->q_base, qcq->q_base_pa); |
| @@ -304,8 +309,11 @@ err_out: · 153 unmodified lines | ||
| 304 | 309 | |
| 305 | 310 | static void pdsc_core_uninit(struct pdsc *pdsc) |
| 306 | 311 | { |
| 307 | − pdsc_qcq_free(pdsc, &pdsc->notifyqcq); | |
| 312 | + /* Free adminqcq first: its work accesses notifyqcq, so we must | |
| 313 | + * disable its IRQ and drain its work before freeing notifyqcq. | |
| 314 | + */ | |
| 308 | 315 | pdsc_qcq_free(pdsc, &pdsc->adminqcq); |
| 316 | + pdsc_qcq_free(pdsc, &pdsc->notifyqcq); | |
| 309 | 317 | |
| 310 | 318 | if (pdsc->kern_dbpage) { |
| 311 | 319 | iounmap(pdsc->kern_dbpage); |
| @@ -479,8 +487,6 @@ void pdsc_teardown(struct pdsc *pdsc, bool removing) · 167 unmodified lines | ||
| 479 | 487 | { |
| 480 | 488 | if (!pdsc->pdev->is_virtfn) |
| 481 | 489 | pdsc_devcmd_reset(pdsc); |
| 482 | − if (pdsc->adminqcq.work.func) | |
| 483 | − cancel_work_sync(&pdsc->adminqcq.work); | |
| 484 | 490 | |
| 485 | 491 | pci_clear_master(pdsc->pdev); |
| 486 | 492 | |
| @@ -533,6 +539,7 @@ static void pdsc_adminq_wait_and_dec_once_unused(struct pdsc *pdsc) · 46 unmodified lines | ||
| 533 | 539 | dev_dbg_ratelimited(pdsc->dev, "%s: adminq in use\n", |
| 534 | 540 | __func__); |
| 535 | 541 | cpu_relax(); |
| 542 | + cond_resched(); | |
| 536 | 543 | } |
| 537 | 544 | } |
| 538 | 545 | |
| @@ -606,9 +613,10 @@ void pdsc_pci_reset_thread(struct work_struct *work) · 67 unmodified lines | ||
| 606 | 613 | struct pdsc *pdsc = container_of(work, struct pdsc, pci_reset_work); |
| 607 | 614 | struct pci_dev *pdev = pdsc->pdev; |
| 608 | 615 | |
| 609 | − pci_dev_get(pdev); | |
| 610 | − pci_reset_function(pdev); | |
| 611 | − pci_dev_put(pdev); | |
| 616 | + /* Use try variant to avoid deadlock with pdsc_remove(). | |
| 617 | + * If lock is contended, the watchdog timer will retry. | |
| 618 | + */ | |
| 619 | + pci_try_reset_function(pdev); | |
| 612 | 620 | } |
| 613 | 621 | |
| 614 | 622 | static void pdsc_check_pci_health(struct pdsc *pdsc) |
| @@ -90,6 +90,12 @@ int pdsc_dl_flash_update(struct devlink *dl, · 89 unmodified lines | ||
| 90 | 90 | { |
| 91 | 91 | struct pdsc *pdsc = devlink_priv(dl); |
| 92 | 92 | |
| 93 | + if (params->component) { | |
| 94 | + NL_SET_ERR_MSG_MOD(extack, | |
| 95 | + "Component update not supported by this device"); | |
| 96 | + return -EOPNOTSUPP; | |
| 97 | + } | |
| 98 | + | |
| 93 | 99 | return pdsc_firmware_update(pdsc, params->fw, extack); |
| 94 | 100 | } |
| 95 | 101 | |
| @@ -238,6 +238,10 @@ static int pdsc_init_pf(struct pdsc *pdsc) · 237 unmodified lines | ||
| 238 | 238 | /* General workqueue and timer, but don't start timer yet */ |
| 239 | 239 | snprintf(wq_name, sizeof(wq_name), "%s.%d", PDS_CORE_DRV_NAME, pdsc->uid); |
| 240 | 240 | pdsc->wq = create_singlethread_workqueue(wq_name); |
| 241 | + if (!pdsc->wq) { | |
| 242 | + err = -ENOMEM; | |
| 243 | + goto err_out_unmap_bars; | |
| 244 | + } | |
| 241 | 245 | INIT_WORK(&pdsc->health_work, pdsc_health_thread); |
| 242 | 246 | INIT_WORK(&pdsc->pci_reset_work, pdsc_pci_reset_thread); |
| 243 | 247 | timer_setup(&pdsc->wdtimer, pdsc_wdtimer_cb, 0); |
| @@ -253,7 +257,7 @@ static int pdsc_init_pf(struct pdsc *pdsc) · 9 unmodified lines | ||
| 253 | 257 | err = pdsc_setup(pdsc, PDSC_SETUP_INIT); |
| 254 | 258 | if (err) { |
| 255 | 259 | mutex_unlock(&pdsc->config_lock); |
| 256 | − goto err_out_unmap_bars; | |
| 260 | + goto err_out_shutdown_timer; | |
| 257 | 261 | } |
| 258 | 262 | |
| 259 | 263 | err = pdsc_start(pdsc); |
| @@ -305,13 +309,14 @@ err_out_stop: · 45 unmodified lines | ||
| 305 | 309 | pdsc_stop(pdsc); |
| 306 | 310 | err_out_teardown: |
| 307 | 311 | pdsc_teardown(pdsc, PDSC_TEARDOWN_REMOVING); |
| 308 | −err_out_unmap_bars: | |
| 312 | +err_out_shutdown_timer: | |
| 309 | 313 | timer_shutdown_sync(&pdsc->wdtimer); |
| 310 | 314 | if (pdsc->wq) |
| 311 | 315 | destroy_workqueue(pdsc->wq); |
| 312 | 316 | mutex_destroy(&pdsc->config_lock); |
| 313 | 317 | mutex_destroy(&pdsc->devcmd_lock); |
| 314 | 318 | pci_free_irq_vectors(pdsc->pdev); |
| 319 | +err_out_unmap_bars: | |
| 315 | 320 | pdsc_unmap_bars(pdsc); |
| 316 | 321 | err_out_release_regions: |
| 317 | 322 | pci_release_regions(pdsc->pdev); |
| @@ -435,8 +440,6 @@ static void pdsc_remove(struct pci_dev *pdev) · 117 unmodified lines | ||
| 435 | 440 | pdsc_auxbus_dev_del(pdsc, pdsc, &pdsc->padev); |
| 436 | 441 | |
| 437 | 442 | timer_shutdown_sync(&pdsc->wdtimer); |
| 438 | − if (pdsc->wq) | |
| 439 | − destroy_workqueue(pdsc->wq); | |
| 440 | 443 | |
| 441 | 444 | mutex_lock(&pdsc->config_lock); |
| 442 | 445 | set_bit(PDSC_S_STOPPING_DRIVER, &pdsc->state); |
| @@ -444,6 +447,9 @@ static void pdsc_remove(struct pci_dev *pdev) · 1 unmodified line | ||
| 444 | 447 | pdsc_stop(pdsc); |
| 445 | 448 | pdsc_teardown(pdsc, PDSC_TEARDOWN_REMOVING); |
| 446 | 449 | mutex_unlock(&pdsc->config_lock); |
| 450 | + | |
| 451 | + if (pdsc->wq) | |
| 452 | + destroy_workqueue(pdsc->wq); | |
| 447 | 453 | mutex_destroy(&pdsc->config_lock); |
| 448 | 454 | mutex_destroy(&pdsc->devcmd_lock); |
| 449 | 455 | |
| @@ -267,9 +267,14 @@ static void xgbe_an37_set(struct xgbe_prv_data *pdata, bool enable, · 266 unmodified lines | ||
| 267 | 267 | |
| 268 | 268 | XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_CTRL1, reg); |
| 269 | 269 | |
| 270 | − reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL); | |
| 271 | − reg |= XGBE_VEND2_MAC_AUTO_SW; | |
| 272 | − XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL, reg); | |
| 270 | + if (pdata->an_mode == XGBE_AN_MODE_CL37_SGMII) { | |
| 271 | + reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL); | |
| 272 | + if (enable) | |
| 273 | + reg |= XGBE_VEND2_MAC_AUTO_SW; | |
| 274 | + else | |
| 275 | + reg &= ~XGBE_VEND2_MAC_AUTO_SW; | |
| 276 | + XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL, reg); | |
| 277 | + } | |
| 273 | 278 | } |
| 274 | 279 | |
| 275 | 280 | static void xgbe_an37_restart(struct xgbe_prv_data *pdata) |
| @@ -36,6 +36,7 @@ struct bnge_pf_info { · 35 unmodified lines | ||
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | 38 | #define INVALID_HW_RING_ID ((u16)-1) |
| 39 | +#define INVALID_HW_RING_ID_32BIT (U32_MAX) | |
| 39 | 40 | |
| 40 | 41 | enum { |
| 41 | 42 | BNGE_FW_CAP_SHORT_CMD = BIT_ULL(0), |
| @@ -1283,7 +1283,7 @@ int bnge_hwrm_stat_ctx_alloc(struct bnge_net *bn) · 1282 unmodified lines | ||
| 1283 | 1283 | |
| 1284 | 1284 | int hwrm_ring_free_send_msg(struct bnge_net *bn, |
| 1285 | 1285 | struct bnge_ring_struct *ring, |
| 1286 | − u32 ring_type, int cmpl_ring_id) | |
| 1286 | + u32 ring_type, u32 cmpl_ring_id) | |
| 1287 | 1287 | { |
| 1288 | 1288 | struct hwrm_ring_free_input *req; |
| 1289 | 1289 | struct bnge_dev *bd = bn->bd; |
| @@ -1295,7 +1295,7 @@ int hwrm_ring_free_send_msg(struct bnge_net *bn, · 5 unmodified lines | ||
| 1295 | 1295 | |
| 1296 | 1296 | req->cmpl_ring = cpu_to_le16(cmpl_ring_id); |
| 1297 | 1297 | req->ring_type = ring_type; |
| 1298 | − req->ring_id = cpu_to_le16(ring->fw_ring_id); | |
| 1298 | + req->ring_id = cpu_to_le32(ring->fw_ring_id); | |
| 1299 | 1299 | |
| 1300 | 1300 | bnge_hwrm_req_hold(bd, req); |
| 1301 | 1301 | rc = bnge_hwrm_req_send(bd, req); |
| @@ -1317,7 +1317,7 @@ int hwrm_ring_alloc_send_msg(struct bnge_net *bn, · 15 unmodified lines | ||
| 1317 | 1317 | struct hwrm_ring_alloc_output *resp; |
| 1318 | 1318 | struct hwrm_ring_alloc_input *req; |
| 1319 | 1319 | struct bnge_dev *bd = bn->bd; |
| 1320 | − u16 ring_id, flags = 0; | |
| 1320 | + u32 ring_id, flags = 0; | |
| 1321 | 1321 | int rc; |
| 1322 | 1322 | |
| 1323 | 1323 | rc = bnge_hwrm_req_init(bd, req, HWRM_RING_ALLOC); |
| @@ -1401,7 +1401,7 @@ int hwrm_ring_alloc_send_msg(struct bnge_net *bn, · 77 unmodified lines | ||
| 1401 | 1401 | |
| 1402 | 1402 | resp = bnge_hwrm_req_hold(bd, req); |
| 1403 | 1403 | rc = bnge_hwrm_req_send(bd, req); |
| 1404 | − ring_id = le16_to_cpu(resp->ring_id); | |
| 1404 | + ring_id = le32_to_cpu(resp->ring_id); | |
| 1405 | 1405 | bnge_hwrm_req_drop(bd, req); |
| 1406 | 1406 | |
| 1407 | 1407 | exit: |
| @@ -50,7 +50,7 @@ int bnge_hwrm_cfa_l2_set_rx_mask(struct bnge_dev *bd, · 49 unmodified lines | ||
| 50 | 50 | void bnge_hwrm_stat_ctx_free(struct bnge_net *bn); |
| 51 | 51 | int bnge_hwrm_stat_ctx_alloc(struct bnge_net *bn); |
| 52 | 52 | int hwrm_ring_free_send_msg(struct bnge_net *bn, struct bnge_ring_struct *ring, |
| 53 | − u32 ring_type, int cmpl_ring_id); | |
| 53 | + u32 ring_type, u32 cmpl_ring_id); | |
| 54 | 54 | int hwrm_ring_alloc_send_msg(struct bnge_net *bn, |
| 55 | 55 | struct bnge_ring_struct *ring, |
| 56 | 56 | u32 ring_type, u32 map_index); |
| @@ -1327,12 +1327,12 @@ err_free_core: · 1326 unmodified lines | ||
| 1327 | 1327 | return rc; |
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | −u16 bnge_cp_ring_for_rx(struct bnge_rx_ring_info *rxr) | |
| 1330 | +u32 bnge_cp_ring_for_rx(struct bnge_rx_ring_info *rxr) | |
| 1331 | 1331 | { |
| 1332 | 1332 | return rxr->rx_cpr->ring_struct.fw_ring_id; |
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | −u16 bnge_cp_ring_for_tx(struct bnge_tx_ring_info *txr) | |
| 1335 | +u32 bnge_cp_ring_for_tx(struct bnge_tx_ring_info *txr) | |
| 1336 | 1336 | { |
| 1337 | 1337 | return txr->tx_cpr->ring_struct.fw_ring_id; |
| 1338 | 1338 | } |
| @@ -1375,12 +1375,12 @@ static void bnge_init_nq_tree(struct bnge_net *bn) · 36 unmodified lines | ||
| 1375 | 1375 | struct bnge_nq_ring_info *nqr = &bn->bnapi[i]->nq_ring; |
| 1376 | 1376 | struct bnge_ring_struct *ring = &nqr->ring_struct; |
| 1377 | 1377 | |
| 1378 | − ring->fw_ring_id = INVALID_HW_RING_ID; | |
| 1378 | + ring->fw_ring_id = INVALID_HW_RING_ID_32BIT; | |
| 1379 | 1379 | for (j = 0; j < nqr->cp_ring_count; j++) { |
| 1380 | 1380 | struct bnge_cp_ring_info *cpr = &nqr->cp_ring_arr[j]; |
| 1381 | 1381 | |
| 1382 | 1382 | ring = &cpr->ring_struct; |
| 1383 | − ring->fw_ring_id = INVALID_HW_RING_ID; | |
| 1383 | + ring->fw_ring_id = INVALID_HW_RING_ID_32BIT; | |
| 1384 | 1384 | } |
| 1385 | 1385 | } |
| 1386 | 1386 | } |
| @@ -1637,7 +1637,7 @@ static void bnge_init_one_rx_ring_rxbd(struct bnge_net *bn, · 250 unmodified lines | ||
| 1637 | 1637 | |
| 1638 | 1638 | ring = &rxr->rx_ring_struct; |
| 1639 | 1639 | bnge_init_rxbd_pages(ring, type); |
| 1640 | − ring->fw_ring_id = INVALID_HW_RING_ID; | |
| 1640 | + ring->fw_ring_id = INVALID_HW_RING_ID_32BIT; | |
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | 1643 | static void bnge_init_one_agg_ring_rxbd(struct bnge_net *bn, |
| @@ -1647,7 +1647,7 @@ static void bnge_init_one_agg_ring_rxbd(struct bnge_net *bn, · 3 unmodified lines | ||
| 1647 | 1647 | u32 type; |
| 1648 | 1648 | |
| 1649 | 1649 | ring = &rxr->rx_agg_ring_struct; |
| 1650 | − ring->fw_ring_id = INVALID_HW_RING_ID; | |
| 1650 | + ring->fw_ring_id = INVALID_HW_RING_ID_32BIT; | |
| 1651 | 1651 | if (bnge_is_agg_reqd(bn->bd)) { |
| 1652 | 1652 | type = ((u32)BNGE_RX_PAGE_SIZE << RX_BD_LEN_SHIFT) | |
| 1653 | 1653 | RX_BD_TYPE_RX_AGG_BD | RX_BD_FLAGS_SOP; |
| @@ -1708,7 +1708,7 @@ static void bnge_init_tx_rings(struct bnge_net *bn) · 54 unmodified lines | ||
| 1708 | 1708 | struct bnge_tx_ring_info *txr = &bn->tx_ring[i]; |
| 1709 | 1709 | struct bnge_ring_struct *ring = &txr->tx_ring_struct; |
| 1710 | 1710 | |
| 1711 | − ring->fw_ring_id = INVALID_HW_RING_ID; | |
| 1711 | + ring->fw_ring_id = INVALID_HW_RING_ID_32BIT; | |
| 1712 | 1712 | |
| 1713 | 1713 | netif_queue_set_napi(bn->netdev, i, NETDEV_QUEUE_TYPE_TX, |
| 1714 | 1714 | &txr->bnapi->napi); |
| @@ -1867,7 +1867,7 @@ static int bnge_hwrm_rx_agg_ring_alloc(struct bnge_net *bn, · 152 unmodified lines | ||
| 1867 | 1867 | ring->fw_ring_id); |
| 1868 | 1868 | bnge_db_write(bn->bd, &rxr->rx_agg_db, rxr->rx_agg_prod); |
| 1869 | 1869 | bnge_db_write(bn->bd, &rxr->rx_db, rxr->rx_prod); |
| 1870 | − bn->grp_info[grp_idx].agg_fw_ring_id = ring->fw_ring_id; | |
| 1870 | + bn->grp_info[grp_idx].agg_fw_ring_id = (u16)ring->fw_ring_id; | |
| 1871 | 1871 | |
| 1872 | 1872 | return 0; |
| 1873 | 1873 | } |
| @@ -1886,7 +1886,7 @@ static int bnge_hwrm_rx_ring_alloc(struct bnge_net *bn, · 12 unmodified lines | ||
| 1886 | 1886 | return rc; |
| 1887 | 1887 | |
| 1888 | 1888 | bnge_set_db(bn, &rxr->rx_db, type, map_idx, ring->fw_ring_id); |
| 1889 | − bn->grp_info[map_idx].rx_fw_ring_id = ring->fw_ring_id; | |
| 1889 | + bn->grp_info[map_idx].rx_fw_ring_id = (u16)ring->fw_ring_id; | |
| 1890 | 1890 | |
| 1891 | 1891 | return 0; |
| 1892 | 1892 | } |
| @@ -1916,7 +1916,7 @@ static int bnge_hwrm_ring_alloc(struct bnge_net *bn) · 23 unmodified lines | ||
| 1916 | 1916 | bnge_set_db(bn, &nqr->nq_db, type, map_idx, ring->fw_ring_id); |
| 1917 | 1917 | bnge_db_nq(bn, &nqr->nq_db, nqr->nq_raw_cons); |
| 1918 | 1918 | enable_irq(vector); |
| 1919 | − bn->grp_info[i].nq_fw_ring_id = ring->fw_ring_id; | |
| 1919 | + bn->grp_info[i].nq_fw_ring_id = (u16)ring->fw_ring_id; | |
| 1920 | 1920 | |
| 1921 | 1921 | if (!i) { |
| 1922 | 1922 | rc = bnge_hwrm_set_async_event_cr(bd, ring->fw_ring_id); |
| @@ -1986,15 +1986,13 @@ void bnge_fill_hw_rss_tbl(struct bnge_net *bn, struct bnge_vnic_info *vnic) · 63 unmodified lines | ||
| 1986 | 1986 | tbl_size = bnge_get_rxfh_indir_size(bd); |
| 1987 | 1987 | |
| 1988 | 1988 | for (i = 0; i < tbl_size; i++) { |
| 1989 | − u16 ring_id, j; | |
| 1989 | + u32 j; | |
| 1990 | 1990 | |
| 1991 | 1991 | j = bd->rss_indir_tbl[i]; |
| 1992 | 1992 | rxr = &bn->rx_ring[j]; |
| 1993 | 1993 | |
| 1994 | − ring_id = rxr->rx_ring_struct.fw_ring_id; | |
| 1995 | − *ring_tbl++ = cpu_to_le16(ring_id); | |
| 1996 | − ring_id = bnge_cp_ring_for_rx(rxr); | |
| 1997 | − *ring_tbl++ = cpu_to_le16(ring_id); | |
| 1994 | + *ring_tbl++ = cpu_to_le16(rxr->rx_ring_struct.fw_ring_id); | |
| 1995 | + *ring_tbl++ = cpu_to_le16(bnge_cp_ring_for_rx(rxr)); | |
| 1998 | 1996 | } |
| 1999 | 1997 | } |
| 2000 | 1998 | |
| @@ -2285,7 +2283,7 @@ static void bnge_disable_int(struct bnge_net *bn) · 284 unmodified lines | ||
| 2285 | 2283 | nqr = &bnapi->nq_ring; |
| 2286 | 2284 | ring = &nqr->ring_struct; |
| 2287 | 2285 | |
| 2288 | − if (ring->fw_ring_id != INVALID_HW_RING_ID) | |
| 2286 | + if (ring->fw_ring_id != INVALID_HW_RING_ID_32BIT) | |
| 2289 | 2287 | bnge_db_nq(bn, &nqr->nq_db, nqr->nq_raw_cons); |
| 2290 | 2288 | } |
| 2291 | 2289 | } |
| @@ -2401,7 +2399,7 @@ static void bnge_hwrm_rx_ring_free(struct bnge_net *bn, · 109 unmodified lines | ||
| 2401 | 2399 | u32 grp_idx = rxr->bnapi->index; |
| 2402 | 2400 | u32 cmpl_ring_id; |
| 2403 | 2401 | |
| 2404 | − if (ring->fw_ring_id == INVALID_HW_RING_ID) | |
| 2402 | + if (ring->fw_ring_id == INVALID_HW_RING_ID_32BIT) | |
| 2405 | 2403 | return; |
| 2406 | 2404 | |
| 2407 | 2405 | cmpl_ring_id = bnge_cp_ring_for_rx(rxr); |
| @@ -2409,7 +2407,7 @@ static void bnge_hwrm_rx_ring_free(struct bnge_net *bn, · 1 unmodified line | ||
| 2409 | 2407 | RING_FREE_REQ_RING_TYPE_RX, |
| 2410 | 2408 | close_path ? cmpl_ring_id : |
| 2411 | 2409 | INVALID_HW_RING_ID); |
| 2412 | − ring->fw_ring_id = INVALID_HW_RING_ID; | |
| 2410 | + ring->fw_ring_id = INVALID_HW_RING_ID_32BIT; | |
| 2413 | 2411 | bn->grp_info[grp_idx].rx_fw_ring_id = INVALID_HW_RING_ID; |
| 2414 | 2412 | } |
| 2415 | 2413 | |
| @@ -2421,14 +2419,14 @@ static void bnge_hwrm_rx_agg_ring_free(struct bnge_net *bn, · 5 unmodified lines | ||
| 2421 | 2419 | u32 grp_idx = rxr->bnapi->index; |
| 2422 | 2420 | u32 cmpl_ring_id; |
| 2423 | 2421 | |
| 2424 | − if (ring->fw_ring_id == INVALID_HW_RING_ID) | |
| 2422 | + if (ring->fw_ring_id == INVALID_HW_RING_ID_32BIT) | |
| 2425 | 2423 | return; |
| 2426 | 2424 | |
| 2427 | 2425 | cmpl_ring_id = bnge_cp_ring_for_rx(rxr); |
| 2428 | 2426 | hwrm_ring_free_send_msg(bn, ring, RING_FREE_REQ_RING_TYPE_RX_AGG, |
| 2429 | 2427 | close_path ? cmpl_ring_id : |
| 2430 | 2428 | INVALID_HW_RING_ID); |
| 2431 | − ring->fw_ring_id = INVALID_HW_RING_ID; | |
| 2429 | + ring->fw_ring_id = INVALID_HW_RING_ID_32BIT; | |
| 2432 | 2430 | bn->grp_info[grp_idx].agg_fw_ring_id = INVALID_HW_RING_ID; |
| 2433 | 2431 | } |
| 2434 | 2432 | |
| @@ -2439,14 +2437,14 @@ static void bnge_hwrm_tx_ring_free(struct bnge_net *bn, · 4 unmodified lines | ||
| 2439 | 2437 | struct bnge_ring_struct *ring = &txr->tx_ring_struct; |
| 2440 | 2438 | u32 cmpl_ring_id; |
| 2441 | 2439 | |
| 2442 | − if (ring->fw_ring_id == INVALID_HW_RING_ID) | |
| 2440 | + if (ring->fw_ring_id == INVALID_HW_RING_ID_32BIT) | |
| 2443 | 2441 | return; |
| 2444 | 2442 | |
| 2445 | 2443 | cmpl_ring_id = close_path ? bnge_cp_ring_for_tx(txr) : |
| 2446 | 2444 | INVALID_HW_RING_ID; |
| 2447 | 2445 | hwrm_ring_free_send_msg(bn, ring, RING_FREE_REQ_RING_TYPE_TX, |
| 2448 | 2446 | cmpl_ring_id); |
| 2449 | − ring->fw_ring_id = INVALID_HW_RING_ID; | |
| 2447 | + ring->fw_ring_id = INVALID_HW_RING_ID_32BIT; | |
| 2450 | 2448 | } |
| 2451 | 2449 | |
| 2452 | 2450 | static void bnge_hwrm_cp_ring_free(struct bnge_net *bn, |
| @@ -2455,12 +2453,12 @@ static void bnge_hwrm_cp_ring_free(struct bnge_net *bn, · 2 unmodified lines | ||
| 2455 | 2453 | struct bnge_ring_struct *ring; |
| 2456 | 2454 | |
| 2457 | 2455 | ring = &cpr->ring_struct; |
| 2458 | − if (ring->fw_ring_id == INVALID_HW_RING_ID) | |
| 2456 | + if (ring->fw_ring_id == INVALID_HW_RING_ID_32BIT) | |
| 2459 | 2457 | return; |
| 2460 | 2458 | |
| 2461 | 2459 | hwrm_ring_free_send_msg(bn, ring, RING_FREE_REQ_RING_TYPE_L2_CMPL, |
| 2462 | 2460 | INVALID_HW_RING_ID); |
| 2463 | − ring->fw_ring_id = INVALID_HW_RING_ID; | |
| 2461 | + ring->fw_ring_id = INVALID_HW_RING_ID_32BIT; | |
| 2464 | 2462 | } |
| 2465 | 2463 | |
| 2466 | 2464 | static void bnge_hwrm_ring_free(struct bnge_net *bn, bool close_path) |
| @@ -2496,11 +2494,11 @@ static void bnge_hwrm_ring_free(struct bnge_net *bn, bool close_path) · 29 unmodified lines | ||
| 2496 | 2494 | bnge_hwrm_cp_ring_free(bn, &nqr->cp_ring_arr[j]); |
| 2497 | 2495 | |
| 2498 | 2496 | ring = &nqr->ring_struct; |
| 2499 | − if (ring->fw_ring_id != INVALID_HW_RING_ID) { | |
| 2497 | + if (ring->fw_ring_id != INVALID_HW_RING_ID_32BIT) { | |
| 2500 | 2498 | hwrm_ring_free_send_msg(bn, ring, |
| 2501 | 2499 | RING_FREE_REQ_RING_TYPE_NQ, |
| 2502 | 2500 | INVALID_HW_RING_ID); |
| 2503 | − ring->fw_ring_id = INVALID_HW_RING_ID; | |
| 2501 | + ring->fw_ring_id = INVALID_HW_RING_ID_32BIT; | |
| 2504 | 2502 | bn->grp_info[i].nq_fw_ring_id = INVALID_HW_RING_ID; |
| 2505 | 2503 | } |
| 2506 | 2504 | } |
| @@ -630,8 +630,8 @@ struct bnge_l2_filter { · 629 unmodified lines | ||
| 630 | 630 | refcount_t refcnt; |
| 631 | 631 | }; |
| 632 | 632 | |
| 633 | −u16 bnge_cp_ring_for_rx(struct bnge_rx_ring_info *rxr); | |
| 634 | −u16 bnge_cp_ring_for_tx(struct bnge_tx_ring_info *txr); | |
| 633 | +u32 bnge_cp_ring_for_rx(struct bnge_rx_ring_info *rxr); | |
| 634 | +u32 bnge_cp_ring_for_tx(struct bnge_tx_ring_info *txr); | |
| 635 | 635 | void bnge_fill_hw_rss_tbl(struct bnge_net *bn, struct bnge_vnic_info *vnic); |
| 636 | 636 | int bnge_alloc_rx_data(struct bnge_net *bn, struct bnge_rx_ring_info *rxr, |
| 637 | 637 | u16 prod, gfp_t gfp); |
| @@ -184,7 +184,7 @@ struct bnge_ctx_mem_info { · 183 unmodified lines | ||
| 184 | 184 | struct bnge_ring_struct { |
| 185 | 185 | struct bnge_ring_mem_info ring_mem; |
| 186 | 186 | |
| 187 | − u16 fw_ring_id; | |
| 187 | + u32 fw_ring_id; | |
| 188 | 188 | union { |
| 189 | 189 | u16 grp_idx; |
| 190 | 190 | u16 map_idx; /* Used by NQs */ |
| @@ -4732,6 +4732,7 @@ static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv) · 4731 unmodified lines | ||
| 4732 | 4732 | dpaa2_mac_disconnect(mac); |
| 4733 | 4733 | |
| 4734 | 4734 | dpaa2_mac_close(mac); |
| 4735 | + put_device(&mac->mc_dev->dev); | |
| 4735 | 4736 | kfree(mac); |
| 4736 | 4737 | } |
| 4737 | 4738 | |
| @@ -1560,6 +1560,7 @@ static void dpaa2_switch_port_disconnect_mac(struct ethsw_port_priv *port_priv) · 1559 unmodified lines | ||
| 1560 | 1560 | dpaa2_mac_disconnect(mac); |
| 1561 | 1561 | |
| 1562 | 1562 | dpaa2_mac_close(mac); |
| 1563 | + put_device(&mac->mc_dev->dev); | |
| 1563 | 1564 | kfree(mac); |
| 1564 | 1565 | } |
| 1565 | 1566 | |
| @@ -900,22 +900,28 @@ static void dtsec_mac_config(struct phylink_config *config, unsigned int mode, · 899 unmodified lines | ||
| 900 | 900 | { |
| 901 | 901 | struct mac_device *mac_dev = fman_config_to_mac(config); |
| 902 | 902 | struct dtsec_regs __iomem *regs = mac_dev->fman_mac->regs; |
| 903 | − u32 tmp; | |
| 903 | + u32 ecntrl, maccfg2; | |
| 904 | + | |
| 905 | + maccfg2 = ioread32be(®s->maccfg2); | |
| 906 | + maccfg2 &= ~(MACCFG2_NIBBLE_MODE | MACCFG2_BYTE_MODE); | |
| 904 | 907 | |
| 905 | 908 | switch (state->interface) { |
| 906 | 909 | case PHY_INTERFACE_MODE_RMII: |
| 907 | − tmp = DTSEC_ECNTRL_RMM; | |
| 910 | + ecntrl = DTSEC_ECNTRL_RMM; | |
| 911 | + maccfg2 |= MACCFG2_NIBBLE_MODE; | |
| 908 | 912 | break; |
| 909 | 913 | case PHY_INTERFACE_MODE_RGMII: |
| 910 | 914 | case PHY_INTERFACE_MODE_RGMII_ID: |
| 911 | 915 | case PHY_INTERFACE_MODE_RGMII_RXID: |
| 912 | 916 | case PHY_INTERFACE_MODE_RGMII_TXID: |
| 913 | − tmp = DTSEC_ECNTRL_GMIIM | DTSEC_ECNTRL_RPM; | |
| 917 | + ecntrl = DTSEC_ECNTRL_GMIIM | DTSEC_ECNTRL_RPM; | |
| 918 | + maccfg2 |= MACCFG2_BYTE_MODE; | |
| 914 | 919 | break; |
| 915 | 920 | case PHY_INTERFACE_MODE_SGMII: |
| 916 | 921 | case PHY_INTERFACE_MODE_1000BASEX: |
| 917 | 922 | case PHY_INTERFACE_MODE_2500BASEX: |
| 918 | − tmp = DTSEC_ECNTRL_TBIM | DTSEC_ECNTRL_SGMIIM; | |
| 923 | + ecntrl = DTSEC_ECNTRL_TBIM | DTSEC_ECNTRL_SGMIIM; | |
| 924 | + maccfg2 |= MACCFG2_BYTE_MODE; | |
| 919 | 925 | break; |
| 920 | 926 | default: |
| 921 | 927 | dev_warn(mac_dev->dev, "cannot configure dTSEC for %s\n", |
| @@ -923,7 +929,8 @@ static void dtsec_mac_config(struct phylink_config *config, unsigned int mode, · 1 unmodified line | ||
| 923 | 929 | return; |
| 924 | 930 | } |
| 925 | 931 | |
| 926 | − iowrite32be(tmp, ®s->ecntrl); | |
| 932 | + iowrite32be(ecntrl, ®s->ecntrl); | |
| 933 | + iowrite32be(maccfg2, ®s->maccfg2); | |
| 927 | 934 | } |
| 928 | 935 | |
| 929 | 936 | static void dtsec_link_up(struct phylink_config *config, struct phy_device *phy, |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | ||
| 13 | 13 | #include <linux/netdevice.h> |
| 14 | 14 | #include <linux/net_tstamp.h> |
| 15 | 15 | #include <linux/pci.h> |
| 16 | +#include <linux/timer.h> | |
| 16 | 17 | #include <linux/ptp_clock_kernel.h> |
| 17 | 18 | #include <linux/u64_stats_sync.h> |
| 18 | 19 | #include <net/page_pool/helpers.h> |
| @@ -41,6 +42,7 @@ · 22 unmodified lines | ||
| 41 | 42 | |
| 42 | 43 | /* Interval to schedule a stats report update, 20000ms. */ |
| 43 | 44 | #define GVE_STATS_REPORT_TIMER_PERIOD 20000 |
| 45 | +#define GVE_RX_NAPI_RESCHED_MS 20 /* msecs */ | |
| 44 | 46 | |
| 45 | 47 | /* Numbers of NIC tx/rx stats in stats report. */ |
| 46 | 48 | #define NIC_TX_STATS_REPORT_NUM 0 |
| @@ -341,6 +343,7 @@ struct gve_rx_ring { · 294 unmodified lines | ||
| 341 | 343 | struct xdp_rxq_info xdp_rxq; |
| 342 | 344 | struct xsk_buff_pool *xsk_pool; |
| 343 | 345 | struct page_frag_cache page_cache; /* Page cache to allocate XDP frames */ |
| 346 | + struct timer_list starvation_timer; /* for queue starvation recovery */ | |
| 344 | 347 | }; |
| 345 | 348 | |
| 346 | 349 | /* A TX desc ring entry */ |
| @@ -18,6 +18,16 @@ · 17 unmodified lines | ||
| 18 | 18 | #include <net/tcp.h> |
| 19 | 19 | #include <net/xdp_sock_drv.h> |
| 20 | 20 | |
| 21 | +static void gve_rx_starvation_timer(struct timer_list *t) | |
| 22 | +{ | |
| 23 | + struct gve_rx_ring *rx = timer_container_of(rx, t, starvation_timer); | |
| 24 | + struct gve_priv *priv = rx->gve; | |
| 25 | + struct gve_notify_block *block; | |
| 26 | + | |
| 27 | + block = &priv->ntfy_blocks[rx->ntfy_id]; | |
| 28 | + napi_schedule(&block->napi); | |
| 29 | +} | |
| 30 | + | |
| 21 | 31 | static void gve_rx_free_hdr_bufs(struct gve_priv *priv, struct gve_rx_ring *rx) |
| 22 | 32 | { |
| 23 | 33 | struct device *hdev = &priv->pdev->dev; |
| @@ -120,6 +130,7 @@ void gve_rx_stop_ring_dqo(struct gve_priv *priv, int idx) · 96 unmodified lines | ||
| 120 | 130 | |
| 121 | 131 | if (rx->dqo.page_pool) |
| 122 | 132 | page_pool_disable_direct_recycling(rx->dqo.page_pool); |
| 133 | + timer_shutdown_sync(&rx->starvation_timer); | |
| 123 | 134 | gve_remove_napi(priv, ntfy_idx); |
| 124 | 135 | gve_rx_remove_from_block(priv, idx); |
| 125 | 136 | gve_rx_reset_ring_dqo(priv, idx); |
| @@ -208,8 +219,10 @@ static int gve_rx_alloc_hdr_bufs(struct gve_priv *priv, struct gve_rx_ring *rx, · 82 unmodified lines | ||
| 208 | 219 | void gve_rx_start_ring_dqo(struct gve_priv *priv, int idx) |
| 209 | 220 | { |
| 210 | 221 | int ntfy_idx = gve_rx_idx_to_ntfy(priv, idx); |
| 222 | + struct gve_rx_ring *rx = &priv->rx[idx]; | |
| 211 | 223 | |
| 212 | 224 | gve_rx_add_to_block(priv, idx); |
| 225 | + timer_setup(&rx->starvation_timer, gve_rx_starvation_timer, 0); | |
| 213 | 226 | gve_add_napi(priv, ntfy_idx, gve_napi_poll_dqo); |
| 214 | 227 | } |
| 215 | 228 | |
| @@ -365,6 +378,7 @@ void gve_rx_post_buffers_dqo(struct gve_rx_ring *rx) · 149 unmodified lines | ||
| 365 | 378 | struct gve_rx_compl_queue_dqo *complq = &rx->dqo.complq; |
| 366 | 379 | struct gve_rx_buf_queue_dqo *bufq = &rx->dqo.bufq; |
| 367 | 380 | struct gve_priv *priv = rx->gve; |
| 381 | + u32 num_bufs_avail_to_hw; | |
| 368 | 382 | u32 num_avail_slots; |
| 369 | 383 | u32 num_full_slots; |
| 370 | 384 | u32 num_posted = 0; |
| @@ -400,6 +414,26 @@ void gve_rx_post_buffers_dqo(struct gve_rx_ring *rx) · 29 unmodified lines | ||
| 400 | 414 | } |
| 401 | 415 | |
| 402 | 416 | rx->fill_cnt += num_posted; |
| 417 | + | |
| 418 | + /* If the queue has fewer than GVE_RX_BUF_THRESH_DQO descriptors | |
| 419 | + * visible to the hardware, the hardware is in danger of starving | |
| 420 | + * and cannot trigger interrupts. | |
| 421 | + * | |
| 422 | + * We use a threshold of 32 because a single maximum-sized RSC | |
| 423 | + * packet can consume up to 19 descriptors in the Rx path. Lower | |
| 424 | + * thresholds (e.g., 8 or 16) would be unsafe as they could cause | |
| 425 | + * the device to drop/stall on a maximum-sized RSC packet. | |
| 426 | + * | |
| 427 | + * Start the timer to periodically reschedule NAPI and recover. | |
| 428 | + */ | |
| 429 | + num_bufs_avail_to_hw = | |
| 430 | + ((bufq->tail & ~(GVE_RX_BUF_THRESH_DQO - 1)) - | |
| 431 | + bufq->head) & bufq->mask; | |
| 432 | + | |
| 433 | + if (num_bufs_avail_to_hw < GVE_RX_BUF_THRESH_DQO) { | |
| 434 | + mod_timer(&rx->starvation_timer, | |
| 435 | + jiffies + msecs_to_jiffies(GVE_RX_NAPI_RESCHED_MS)); | |
| 436 | + } | |
| 403 | 437 | } |
| 404 | 438 | |
| 405 | 439 | static void gve_rx_skb_csum(struct sk_buff *skb, |
| @@ -594,7 +594,11 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget) · 593 unmodified lines | ||
| 594 | 594 | skb = build_skb(buf, priv->rx_buf_size); |
| 595 | 595 | if (unlikely(!skb)) { |
| 596 | 596 | net_dbg_ratelimited("build_skb failed\n"); |
| 597 | − goto refill; | |
| 597 | + /* Retain the slot; return budget so NAPI retries this | |
| 598 | + * buffer. Refill would overwrite rx_buf[]/rx_phys[] | |
| 599 | + * and leak them. | |
| 600 | + */ | |
| 601 | + return budget; | |
| 598 | 602 | } |
| 599 | 603 | |
| 600 | 604 | dma_unmap_single(priv->dev, priv->rx_phys[priv->rx_head], |
| @@ -622,14 +626,15 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget) · 21 unmodified lines | ||
| 622 | 626 | rx++; |
| 623 | 627 | } |
| 624 | 628 | |
| 625 | −refill: | |
| 626 | 629 | buf = netdev_alloc_frag(priv->rx_buf_size); |
| 627 | 630 | if (!buf) |
| 628 | 631 | goto done; |
| 629 | 632 | phys = dma_map_single(priv->dev, buf, |
| 630 | 633 | RX_BUF_SIZE, DMA_FROM_DEVICE); |
| 631 | − if (dma_mapping_error(priv->dev, phys)) | |
| 634 | + if (dma_mapping_error(priv->dev, phys)) { | |
| 635 | + skb_free_frag(buf); | |
| 632 | 636 | goto done; |
| 637 | + } | |
| 633 | 638 | priv->rx_buf[priv->rx_head] = buf; |
| 634 | 639 | priv->rx_phys[priv->rx_head] = phys; |
| 635 | 640 | hip04_set_recv_desc(priv, phys); |
| @@ -104,8 +104,6 @@ struct hinic_dev { · 103 unmodified lines | ||
| 104 | 104 | u16 num_rss; |
| 105 | 105 | u16 rss_limit; |
| 106 | 106 | struct hinic_rss_type rss_type; |
| 107 | − u8 *rss_hkey_user; | |
| 108 | − s32 *rss_indir_user; | |
| 109 | 107 | struct hinic_intr_coal_info *rx_intr_coalesce; |
| 110 | 108 | struct hinic_intr_coal_info *tx_intr_coalesce; |
| 111 | 109 | struct hinic_sriov_info sriov_info; |
| @@ -1064,17 +1064,6 @@ static int __set_rss_rxfh(struct net_device *netdev, · 1063 unmodified lines | ||
| 1064 | 1064 | int err; |
| 1065 | 1065 | |
| 1066 | 1066 | if (indir) { |
| 1067 | − if (!nic_dev->rss_indir_user) { | |
| 1068 | − nic_dev->rss_indir_user = | |
| 1069 | − kzalloc(sizeof(u32) * HINIC_RSS_INDIR_SIZE, | |
| 1070 | − GFP_KERNEL); | |
| 1071 | − if (!nic_dev->rss_indir_user) | |
| 1072 | − return -ENOMEM; | |
| 1073 | − } | |
| 1074 | − | |
| 1075 | − memcpy(nic_dev->rss_indir_user, indir, | |
| 1076 | − sizeof(u32) * HINIC_RSS_INDIR_SIZE); | |
| 1077 | − | |
| 1078 | 1067 | err = hinic_rss_set_indir_tbl(nic_dev, |
| 1079 | 1068 | nic_dev->rss_tmpl_idx, indir); |
| 1080 | 1069 | if (err) |
| @@ -1082,16 +1071,6 @@ static int __set_rss_rxfh(struct net_device *netdev, · 1 unmodified line | ||
| 1082 | 1071 | } |
| 1083 | 1072 | |
| 1084 | 1073 | if (key) { |
| 1085 | − if (!nic_dev->rss_hkey_user) { | |
| 1086 | − nic_dev->rss_hkey_user = | |
| 1087 | − kzalloc(HINIC_RSS_KEY_SIZE * 2, GFP_KERNEL); | |
| 1088 | − | |
| 1089 | − if (!nic_dev->rss_hkey_user) | |
| 1090 | − return -ENOMEM; | |
| 1091 | − } | |
| 1092 | − | |
| 1093 | − memcpy(nic_dev->rss_hkey_user, key, HINIC_RSS_KEY_SIZE); | |
| 1094 | − | |
| 1095 | 1074 | err = hinic_rss_set_template_tbl(nic_dev, |
| 1096 | 1075 | nic_dev->rss_tmpl_idx, key); |
| 1097 | 1076 | if (err) |
| @@ -767,6 +767,9 @@ static inline bool ice_is_txtime_ena(const struct ice_tx_ring *ring) · 766 unmodified lines | ||
| 767 | 767 | struct ice_vsi *vsi = ring->vsi; |
| 768 | 768 | struct ice_pf *pf = vsi->back; |
| 769 | 769 | |
| 770 | + if (vsi->type != ICE_VSI_PF) | |
| 771 | + return false; | |
| 772 | + | |
| 770 | 773 | return test_bit(ring->q_index, pf->txtime_txqs); |
| 771 | 774 | } |
| 772 | 775 | |
| @@ -512,9 +512,6 @@ int ice_eswitch_attach_vf(struct ice_pf *pf, struct ice_vf *vf) · 511 unmodified lines | ||
| 512 | 512 | struct ice_repr *repr; |
| 513 | 513 | int err; |
| 514 | 514 | |
| 515 | − if (!ice_is_eswitch_mode_switchdev(pf)) | |
| 516 | − return 0; | |
| 517 | − | |
| 518 | 515 | repr = ice_repr_create_vf(vf); |
| 519 | 516 | if (IS_ERR(repr)) |
| 520 | 517 | return PTR_ERR(repr); |
| @@ -2623,7 +2623,7 @@ int ice_init_lag(struct ice_pf *pf) · 2622 unmodified lines | ||
| 2623 | 2623 | goto free_lport_res; |
| 2624 | 2624 | |
| 2625 | 2625 | /* associate recipes to profiles */ |
| 2626 | − for (n = 0; n < ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER; n++) { | |
| 2626 | + for (n = 0; n < ICE_MAX_NUM_PROFILES; n++) { | |
| 2627 | 2627 | err = ice_aq_get_recipe_to_profile(&pf->hw, n, |
| 2628 | 2628 | &recipe_bits, NULL); |
| 2629 | 2629 | if (err) |
| @@ -2368,6 +2368,9 @@ int ice_parser_profile_init(struct ice_parser_result *rslt, · 2367 unmodified lines | ||
| 2368 | 2368 | u16 proto_off = 0; |
| 2369 | 2369 | u16 off; |
| 2370 | 2370 | |
| 2371 | + if (rslt->ptype >= ICE_FLOW_PTYPE_MAX) | |
| 2372 | + return -EINVAL; | |
| 2373 | + | |
| 2371 | 2374 | memset(prof, 0, sizeof(*prof)); |
| 2372 | 2375 | set_bit(rslt->ptype, prof->ptypes); |
| 2373 | 2376 | if (blk == ICE_BLK_SW) { |
| @@ -346,7 +346,7 @@ static u64 ice_ptp_extend_40b_ts(struct ice_pf *pf, u64 in_tstamp) · 345 unmodified lines | ||
| 346 | 346 | return 0; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | − return ice_ptp_extend_32b_ts(pf->ptp.cached_phc_time, | |
| 349 | + return ice_ptp_extend_32b_ts(READ_ONCE(pf->ptp.cached_phc_time), | |
| 350 | 350 | (in_tstamp >> 8) & mask); |
| 351 | 351 | } |
| 352 | 352 | |
| @@ -3037,6 +3037,11 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) · 2684 unmodified lines | ||
| 3037 | 3037 | struct ice_ptp *ptp = &pf->ptp; |
| 3038 | 3038 | int err; |
| 3039 | 3039 | |
| 3040 | + if (ptp->state == ICE_PTP_UNINIT) { | |
| 3041 | + dev_dbg(ice_pf_to_dev(pf), "PTP was not initialized, skipping rebuild\n"); | |
| 3042 | + return; | |
| 3043 | + } | |
| 3044 | + | |
| 3040 | 3045 | if (ptp->state == ICE_PTP_READY) { |
| 3041 | 3046 | ice_ptp_prepare_for_reset(pf, reset_type); |
| 3042 | 3047 | } else if (ptp->state != ICE_PTP_RESETTING) { |
| @@ -484,12 +484,14 @@ static int ice_start_vfs(struct ice_pf *pf) · 483 unmodified lines | ||
| 484 | 484 | goto teardown; |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | − retval = ice_eswitch_attach_vf(pf, vf); | |
| 488 | − if (retval) { | |
| 489 | − dev_err(ice_pf_to_dev(pf), "Failed to attach VF %d to eswitch, error %d", | |
| 490 | − vf->vf_id, retval); | |
| 491 | − ice_vf_vsi_release(vf); | |
| 492 | − goto teardown; | |
| 487 | + if (ice_is_eswitch_mode_switchdev(pf)) { | |
| 488 | + retval = ice_eswitch_attach_vf(pf, vf); | |
| 489 | + if (retval) { | |
| 490 | + dev_err(ice_pf_to_dev(pf), "Failed to attach VF %d to eswitch, error %d", | |
| 491 | + vf->vf_id, retval); | |
| 492 | + ice_vf_vsi_release(vf); | |
| 493 | + goto teardown; | |
| 494 | + } | |
| 493 | 495 | } |
| 494 | 496 | |
| 495 | 497 | set_bit(ICE_VF_STATE_INIT, vf->vf_states); |
| @@ -1654,7 +1654,7 @@ int ice_tx_csum(struct ice_tx_buf *first, struct ice_tx_offload_params *off) · 1653 unmodified lines | ||
| 1654 | 1654 | ret = ipv6_skip_exthdr(skb, exthdr - skb->data, |
| 1655 | 1655 | &l4_proto, &frag_off); |
| 1656 | 1656 | if (ret < 0) |
| 1657 | − return -1; | |
| 1657 | + goto checksum_sw_fb; | |
| 1658 | 1658 | } |
| 1659 | 1659 | |
| 1660 | 1660 | /* define outer transport */ |
| @@ -1673,11 +1673,7 @@ int ice_tx_csum(struct ice_tx_buf *first, struct ice_tx_offload_params *off) · 12 unmodified lines | ||
| 1673 | 1673 | l4.hdr = skb_inner_network_header(skb); |
| 1674 | 1674 | break; |
| 1675 | 1675 | default: |
| 1676 | − if (first->tx_flags & ICE_TX_FLAGS_TSO) | |
| 1677 | − return -1; | |
| 1678 | − | |
| 1679 | − skb_checksum_help(skb); | |
| 1680 | − return 0; | |
| 1676 | + goto checksum_sw_fb; | |
| 1681 | 1677 | } |
| 1682 | 1678 | |
| 1683 | 1679 | /* compute outer L3 header size */ |
| @@ -1736,7 +1732,7 @@ int ice_tx_csum(struct ice_tx_buf *first, struct ice_tx_offload_params *off) · 52 unmodified lines | ||
| 1736 | 1732 | ipv6_skip_exthdr(skb, exthdr - skb->data, &l4_proto, |
| 1737 | 1733 | &frag_off); |
| 1738 | 1734 | } else { |
| 1739 | − return -1; | |
| 1735 | + goto checksum_sw_fb; | |
| 1740 | 1736 | } |
| 1741 | 1737 | |
| 1742 | 1738 | /* compute inner L3 header size */ |
| @@ -1789,15 +1785,17 @@ int ice_tx_csum(struct ice_tx_buf *first, struct ice_tx_offload_params *off) · 46 unmodified lines | ||
| 1789 | 1785 | break; |
| 1790 | 1786 | |
| 1791 | 1787 | default: |
| 1792 | − if (first->tx_flags & ICE_TX_FLAGS_TSO) | |
| 1793 | − return -1; | |
| 1794 | − skb_checksum_help(skb); | |
| 1795 | − return 0; | |
| 1788 | + goto checksum_sw_fb; | |
| 1796 | 1789 | } |
| 1797 | 1790 | |
| 1798 | 1791 | off->td_cmd |= cmd; |
| 1799 | 1792 | off->td_offset |= offset; |
| 1800 | 1793 | return 1; |
| 1794 | + | |
| 1795 | +checksum_sw_fb: | |
| 1796 | + if (first->tx_flags & ICE_TX_FLAGS_TSO) | |
| 1797 | + return -1; | |
| 1798 | + return skb_checksum_help(skb); | |
| 1801 | 1799 | } |
| 1802 | 1800 | |
| 1803 | 1801 | /** |
| @@ -812,7 +812,8 @@ void ice_reset_all_vfs(struct ice_pf *pf) · 811 unmodified lines | ||
| 812 | 812 | } |
| 813 | 813 | ice_vf_post_vsi_rebuild(vf); |
| 814 | 814 | |
| 815 | − ice_eswitch_attach_vf(pf, vf); | |
| 815 | + if (ice_is_eswitch_mode_switchdev(pf)) | |
| 816 | + ice_eswitch_attach_vf(pf, vf); | |
| 816 | 817 | |
| 817 | 818 | mutex_unlock(&vf->cfg_lock); |
| 818 | 819 | } |
| @@ -3555,7 +3555,6 @@ restart: · 3554 unmodified lines | ||
| 3555 | 3555 | |
| 3556 | 3556 | pci_sriov_set_totalvfs(adapter->pdev, idpf_get_max_vfs(adapter)); |
| 3557 | 3557 | num_max_vports = idpf_get_max_vports(adapter); |
| 3558 | − adapter->max_vports = num_max_vports; | |
| 3559 | 3558 | adapter->vports = kzalloc_objs(*adapter->vports, num_max_vports); |
| 3560 | 3559 | if (!adapter->vports) |
| 3561 | 3560 | return -ENOMEM; |
| @@ -3576,6 +3575,12 @@ restart: · 14 unmodified lines | ||
| 3576 | 3575 | goto err_netdev_alloc; |
| 3577 | 3576 | } |
| 3578 | 3577 | |
| 3578 | + /* Set max_vports only after vports, netdevs and vport_config buffers | |
| 3579 | + * are allocated to make sure max_vport bound loops don't end up | |
| 3580 | + * crashing, following allocation errors on init. | |
| 3581 | + */ | |
| 3582 | + adapter->max_vports = num_max_vports; | |
| 3583 | + | |
| 3579 | 3584 | /* Start the mailbox task before requesting vectors. This will ensure |
| 3580 | 3585 | * vector information response from mailbox is handled |
| 3581 | 3586 | */ |
| @@ -272,6 +272,7 @@ exit: · 271 unmodified lines | ||
| 272 | 272 | if (allocated) { |
| 273 | 273 | pfvf->flags |= OTX2_FLAG_MCAM_ENTRIES_ALLOC; |
| 274 | 274 | pfvf->flags |= OTX2_FLAG_NTUPLE_SUPPORT; |
| 275 | + pfvf->flags |= OTX2_FLAG_TC_FLOWER_SUPPORT; | |
| 275 | 276 | } |
| 276 | 277 | |
| 277 | 278 | if (allocated != count) |
| @@ -30,6 +30,7 @@ · 29 unmodified lines | ||
| 30 | 30 | #define OTX2_UNSUPP_LSE_DEPTH GENMASK(6, 4) |
| 31 | 31 | |
| 32 | 32 | #define MCAST_INVALID_GRP (-1U) |
| 33 | +#define RATE_MANTISSA_BITS 8 | |
| 33 | 34 | |
| 34 | 35 | static void otx2_get_egress_burst_cfg(struct otx2_nic *nic, u32 burst, |
| 35 | 36 | u32 *burst_exp, u32 *burst_mantissa) |
| @@ -66,28 +67,30 @@ static void otx2_get_egress_burst_cfg(struct otx2_nic *nic, u32 burst, · 30 unmodified lines | ||
| 66 | 67 | static void otx2_get_egress_rate_cfg(u64 maxrate, u32 *exp, |
| 67 | 68 | u32 *mantissa, u32 *div_exp) |
| 68 | 69 | { |
| 69 | − u64 tmp; | |
| 70 | − | |
| 71 | 70 | /* Rate calculation by hardware |
| 72 | 71 | * |
| 73 | 72 | * PIR_ADD = ((256 + mantissa) << exp) / 256 |
| 74 | 73 | * rate = (2 * PIR_ADD) / ( 1 << div_exp) |
| 75 | 74 | * The resultant rate is in Mbps. |
| 75 | + * | |
| 76 | + * Use div_exp = 0 and compute exp/mantissa for maxrate / 2; the | |
| 77 | + * leading factor of two yields the full rate. Rates below 2 Mbps | |
| 78 | + * are floored to the smallest step (exp = 0, mantissa = 0). | |
| 76 | 79 | */ |
| 77 | 80 | |
| 78 | − /* 2Mbps to 100Gbps can be expressed with div_exp = 0. | |
| 79 | − * Setting this to '0' will ease the calculation of | |
| 80 | − * exponent and mantissa. | |
| 81 | − */ | |
| 82 | 81 | *div_exp = 0; |
| 83 | − | |
| 84 | 82 | if (maxrate) { |
| 85 | − *exp = ilog2(maxrate) ? ilog2(maxrate) - 1 : 0; | |
| 86 | − tmp = maxrate - rounddown_pow_of_two(maxrate); | |
| 87 | − if (maxrate < MAX_RATE_MANTISSA) | |
| 88 | − *mantissa = tmp * 2; | |
| 89 | − else | |
| 90 | − *mantissa = tmp / (1ULL << (*exp - 7)); | |
| 83 | + maxrate = maxrate / 2; | |
| 84 | + if (!maxrate) { | |
| 85 | + /* Rates below 2 Mbps map to the smallest step */ | |
| 86 | + *exp = 0; | |
| 87 | + *mantissa = 0; | |
| 88 | + } else { | |
| 89 | + *exp = ilog2(maxrate); | |
| 90 | + /* Clear MSB and derive fractional bits */ | |
| 91 | + maxrate &= ~BIT(*exp); | |
| 92 | + *mantissa = (maxrate << RATE_MANTISSA_BITS) >> *exp; | |
| 93 | + } | |
| 91 | 94 | } else { |
| 92 | 95 | /* Instead of disabling rate limiting, set all values to max */ |
| 93 | 96 | *exp = MAX_RATE_EXPONENT; |
| @@ -173,6 +173,13 @@ static int mlx5e_dcbnl_ieee_getets(struct net_device *netdev, · 172 unmodified lines | ||
| 173 | 173 | } |
| 174 | 174 | memcpy(ets->tc_tsa, priv->dcbx.tc_tsa, sizeof(ets->tc_tsa)); |
| 175 | 175 | |
| 176 | + /* Report 0 for non ETS TSA */ | |
| 177 | + for (i = 0; i < ets->ets_cap; i++) { | |
| 178 | + if (ets->tc_tx_bw[i] == MLX5E_MAX_BW_ALLOC && | |
| 179 | + priv->dcbx.tc_tsa[i] != IEEE_8021QAZ_TSA_ETS) | |
| 180 | + ets->tc_tx_bw[i] = 0; | |
| 181 | + } | |
| 182 | + | |
| 176 | 183 | return err; |
| 177 | 184 | } |
| 178 | 185 | |
| @@ -317,6 +324,14 @@ static int mlx5e_dbcnl_validate_ets(struct net_device *netdev, · 138 unmodified lines | ||
| 317 | 324 | } |
| 318 | 325 | } |
| 319 | 326 | |
| 327 | + for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { | |
| 328 | + if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_CB_SHAPER) { | |
| 329 | + netdev_err(netdev, | |
| 330 | + "Failed to validate ETS: CB Shaper is not supported\n"); | |
| 331 | + return -EOPNOTSUPP; | |
| 332 | + } | |
| 333 | + } | |
| 334 | + | |
| 320 | 335 | /* Validate Bandwidth Sum */ |
| 321 | 336 | for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { |
| 322 | 337 | if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_ETS) { |
| @@ -211,11 +211,11 @@ static void mlx5e_disable_async_events(struct mlx5e_priv *priv) · 210 unmodified lines | ||
| 211 | 211 | |
| 212 | 212 | static int mlx5e_devcom_event_mpv(int event, void *my_data, void *event_data) |
| 213 | 213 | { |
| 214 | − struct mlx5e_priv *slave_priv = my_data; | |
| 214 | + struct mlx5e_priv *master_priv = event_data; | |
| 215 | 215 | |
| 216 | 216 | switch (event) { |
| 217 | 217 | case MPV_DEVCOM_MASTER_UP: |
| 218 | − mlx5_devcom_comp_set_ready(slave_priv->devcom, true); | |
| 218 | + mlx5_devcom_comp_set_ready(master_priv->devcom, true); | |
| 219 | 219 | break; |
| 220 | 220 | case MPV_DEVCOM_MASTER_DOWN: |
| 221 | 221 | /* no need for comp set ready false since we unregister after |
| @@ -71,7 +71,7 @@ int esw_egress_acl_vlan_create(struct mlx5_eswitch *esw, · 70 unmodified lines | ||
| 71 | 71 | flow_act.action = flow_action; |
| 72 | 72 | vport->egress.allowed_vlan = |
| 73 | 73 | mlx5_add_flow_rules(vport->egress.acl, spec, |
| 74 | − &flow_act, fwd_dest, 0); | |
| 74 | + &flow_act, fwd_dest, fwd_dest ? 1 : 0); | |
| 75 | 75 | if (IS_ERR(vport->egress.allowed_vlan)) { |
| 76 | 76 | err = PTR_ERR(vport->egress.allowed_vlan); |
| 77 | 77 | esw_warn(esw->dev, |
| @@ -314,7 +314,7 @@ static int mlx5_query_module_id(struct mlx5_core_dev *dev, int module_num, · 313 unmodified lines | ||
| 314 | 314 | return -EIO; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | − ptr = MLX5_ADDR_OF(mcia_reg, out, dword_0); | |
| 317 | + ptr = MLX5_ADDR_OF(mcia_reg, out, dwords); | |
| 318 | 318 | |
| 319 | 319 | *module_id = ptr[0]; |
| 320 | 320 | |
| @@ -399,7 +399,7 @@ static int mlx5_query_mcia(struct mlx5_core_dev *dev, · 78 unmodified lines | ||
| 399 | 399 | return -EIO; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | − ptr = MLX5_ADDR_OF(mcia_reg, out, dword_0); | |
| 402 | + ptr = MLX5_ADDR_OF(mcia_reg, out, dwords); | |
| 403 | 403 | memcpy(data, ptr, size); |
| 404 | 404 | |
| 405 | 405 | return size; |
| @@ -96,6 +96,9 @@ static int nfp_cpp_resource_find(struct nfp_cpp *cpp, struct nfp_resource *res) · 95 unmodified lines | ||
| 96 | 96 | res->mutex = |
| 97 | 97 | nfp_cpp_mutex_alloc(cpp, |
| 98 | 98 | NFP_RESOURCE_TBL_TARGET, addr, key); |
| 99 | + if (!res->mutex) | |
| 100 | + return -ENOMEM; | |
| 101 | + | |
| 99 | 102 | res->cpp_id = NFP_CPP_ID(entry.region.cpp_target, |
| 100 | 103 | entry.region.cpp_action, |
| 101 | 104 | entry.region.cpp_token); |
| @@ -192,6 +192,12 @@ enum rtase_sw_flag_content { · 191 unmodified lines | ||
| 192 | 192 | RTASE_SWF_MSIX_ENABLED = BIT(2), |
| 193 | 193 | }; |
| 194 | 194 | |
| 195 | +enum rtase_parse_result { | |
| 196 | + RTASE_PARSE_OK, | |
| 197 | + RTASE_PARSE_SKIP, | |
| 198 | + RTASE_PARSE_DROP, | |
| 199 | +}; | |
| 200 | + | |
| 195 | 201 | #define RSVD_MASK 0x3FFFC000 |
| 196 | 202 | |
| 197 | 203 | struct rtase_tx_desc { |
| @@ -363,4 +369,6 @@ struct rtase_private { · 165 unmodified lines | ||
| 363 | 369 | |
| 364 | 370 | #define RTASE_MSS_MASK GENMASK(28, 18) |
| 365 | 371 | |
| 372 | +#define RTASE_MIN_PAD_LEN 47 | |
| 373 | + | |
| 366 | 374 | #endif /* RTASE_H */ |
| @@ -61,6 +61,7 @@ · 60 unmodified lines | ||
| 61 | 61 | #include <linux/pci.h> |
| 62 | 62 | #include <linux/pm_runtime.h> |
| 63 | 63 | #include <linux/prefetch.h> |
| 64 | +#include <linux/ptp_classify.h> | |
| 64 | 65 | #include <linux/rtnetlink.h> |
| 65 | 66 | #include <linux/tcp.h> |
| 66 | 67 | #include <asm/irq.h> |
| @@ -1252,6 +1253,199 @@ static u32 rtase_tx_csum(struct sk_buff *skb, const struct net_device *dev) · 1185 unmodified lines | ||
| 1252 | 1253 | return csum_cmd; |
| 1253 | 1254 | } |
| 1254 | 1255 | |
| 1256 | +static enum rtase_parse_result rtase_get_l3_proto(struct sk_buff *skb, | |
| 1257 | + __be16 *proto, | |
| 1258 | + u32 *network_offset) | |
| 1259 | +{ | |
| 1260 | + struct vlan_hdr *vh, _vh; | |
| 1261 | + struct ethhdr *eh, _eh; | |
| 1262 | + u32 offset = ETH_HLEN; | |
| 1263 | + | |
| 1264 | + eh = skb_header_pointer(skb, 0, sizeof(_eh), &_eh); | |
| 1265 | + if (!eh) | |
| 1266 | + return RTASE_PARSE_DROP; | |
| 1267 | + | |
| 1268 | + *proto = eh->h_proto; | |
| 1269 | + | |
| 1270 | + while (eth_type_vlan(*proto)) { | |
| 1271 | + vh = skb_header_pointer(skb, offset, sizeof(_vh), &_vh); | |
| 1272 | + if (!vh) | |
| 1273 | + return RTASE_PARSE_DROP; | |
| 1274 | + | |
| 1275 | + *proto = vh->h_vlan_encapsulated_proto; | |
| 1276 | + offset += VLAN_HLEN; | |
| 1277 | + } | |
| 1278 | + | |
| 1279 | + *network_offset = offset; | |
| 1280 | + | |
| 1281 | + return RTASE_PARSE_OK; | |
| 1282 | +} | |
| 1283 | + | |
| 1284 | +static bool rtase_pad_to_transport_len(struct sk_buff *skb, | |
| 1285 | + u32 transport_offset, | |
| 1286 | + u32 pad_to_len) | |
| 1287 | +{ | |
| 1288 | + u32 trans_data_len; | |
| 1289 | + u32 pad_len; | |
| 1290 | + | |
| 1291 | + trans_data_len = skb->len - transport_offset; | |
| 1292 | + if (trans_data_len >= pad_to_len) | |
| 1293 | + return true; | |
| 1294 | + | |
| 1295 | + if (skb_is_nonlinear(skb)) { | |
| 1296 | + if (skb_linearize(skb)) | |
| 1297 | + return false; | |
| 1298 | + } | |
| 1299 | + | |
| 1300 | + pad_len = pad_to_len - trans_data_len; | |
| 1301 | + if (__skb_put_padto(skb, skb->len + pad_len, false)) | |
| 1302 | + return false; | |
| 1303 | + | |
| 1304 | + return true; | |
| 1305 | +} | |
| 1306 | + | |
| 1307 | +static enum rtase_parse_result rtase_get_transport_offset(struct sk_buff *skb, | |
| 1308 | + u32 *transport_offset, | |
| 1309 | + u8 *transport_proto, | |
| 1310 | + u32 *pad_to_len) | |
| 1311 | +{ | |
| 1312 | + enum rtase_parse_result ret; | |
| 1313 | + struct ipv6hdr *i6h, _i6h; | |
| 1314 | + struct iphdr *ih, _ih; | |
| 1315 | + bool non_first_frag; | |
| 1316 | + __be16 proto; | |
| 1317 | + u32 offset; | |
| 1318 | + u32 no; | |
| 1319 | + | |
| 1320 | + ret = rtase_get_l3_proto(skb, &proto, &no); | |
| 1321 | + if (ret != RTASE_PARSE_OK) | |
| 1322 | + return ret; | |
| 1323 | + | |
| 1324 | + switch (proto) { | |
| 1325 | + case htons(ETH_P_IP): | |
| 1326 | + ih = skb_header_pointer(skb, no, sizeof(_ih), &_ih); | |
| 1327 | + if (!ih) | |
| 1328 | + return RTASE_PARSE_DROP; | |
| 1329 | + | |
| 1330 | + if (ih->ihl < 5) | |
| 1331 | + return RTASE_PARSE_DROP; | |
| 1332 | + | |
| 1333 | + offset = no + ih->ihl * 4; | |
| 1334 | + if (offset > skb->len) | |
| 1335 | + return RTASE_PARSE_DROP; | |
| 1336 | + | |
| 1337 | + non_first_frag = ntohs(ih->frag_off) & IP_OFFSET; | |
| 1338 | + | |
| 1339 | + if (ih->protocol == IPPROTO_TCP) { | |
| 1340 | + if (skb->len - offset < sizeof(struct tcphdr)) { | |
| 1341 | + if (non_first_frag) { | |
| 1342 | + *transport_offset = offset; | |
| 1343 | + *transport_proto = IPPROTO_TCP; | |
| 1344 | + *pad_to_len = sizeof(struct tcphdr); | |
| 1345 | + | |
| 1346 | + return RTASE_PARSE_OK; | |
| 1347 | + } | |
| 1348 | + | |
| 1349 | + return RTASE_PARSE_DROP; | |
| 1350 | + } | |
| 1351 | + | |
| 1352 | + return RTASE_PARSE_SKIP; | |
| 1353 | + } | |
| 1354 | + | |
| 1355 | + if (ih->protocol != IPPROTO_UDP) | |
| 1356 | + return RTASE_PARSE_SKIP; | |
| 1357 | + | |
| 1358 | + *transport_offset = offset; | |
| 1359 | + *transport_proto = IPPROTO_UDP; | |
| 1360 | + | |
| 1361 | + if (skb->len - offset < sizeof(struct udphdr)) { | |
| 1362 | + if (non_first_frag) { | |
| 1363 | + *pad_to_len = sizeof(struct udphdr); | |
| 1364 | + | |
| 1365 | + return RTASE_PARSE_OK; | |
| 1366 | + } | |
| 1367 | + | |
| 1368 | + return RTASE_PARSE_DROP; | |
| 1369 | + } | |
| 1370 | + | |
| 1371 | + return RTASE_PARSE_OK; | |
| 1372 | + | |
| 1373 | + case htons(ETH_P_IPV6): | |
| 1374 | + i6h = skb_header_pointer(skb, no, sizeof(_i6h), &_i6h); | |
| 1375 | + if (!i6h) | |
| 1376 | + return RTASE_PARSE_DROP; | |
| 1377 | + | |
| 1378 | + offset = no + sizeof(*i6h); | |
| 1379 | + | |
| 1380 | + if (i6h->nexthdr == IPPROTO_TCP) { | |
| 1381 | + if (skb->len - offset < sizeof(struct tcphdr)) | |
| 1382 | + return RTASE_PARSE_DROP; | |
| 1383 | + | |
| 1384 | + return RTASE_PARSE_SKIP; | |
| 1385 | + } | |
| 1386 | + | |
| 1387 | + if (i6h->nexthdr != IPPROTO_UDP) | |
| 1388 | + return RTASE_PARSE_SKIP; | |
| 1389 | + | |
| 1390 | + if (skb->len - offset < sizeof(struct udphdr)) | |
| 1391 | + return RTASE_PARSE_DROP; | |
| 1392 | + | |
| 1393 | + *transport_offset = offset; | |
| 1394 | + *transport_proto = IPPROTO_UDP; | |
| 1395 | + | |
| 1396 | + return RTASE_PARSE_OK; | |
| 1397 | + | |
| 1398 | + default: | |
| 1399 | + return RTASE_PARSE_SKIP; | |
| 1400 | + } | |
| 1401 | +} | |
| 1402 | + | |
| 1403 | +static bool rtase_skb_pad(struct sk_buff *skb) | |
| 1404 | +{ | |
| 1405 | + enum rtase_parse_result ret; | |
| 1406 | + u32 transport_offset; | |
| 1407 | + __be16 *dest, _dest; | |
| 1408 | + u32 trans_data_len; | |
| 1409 | + u32 pad_to_len = 0; | |
| 1410 | + u8 transport_proto; | |
| 1411 | + u16 dest_port; | |
| 1412 | + | |
| 1413 | + ret = rtase_get_transport_offset(skb, &transport_offset, | |
| 1414 | + &transport_proto, &pad_to_len); | |
| 1415 | + if (ret == RTASE_PARSE_SKIP) { | |
| 1416 | + return true; | |
| 1417 | + } else if (ret == RTASE_PARSE_DROP) { | |
| 1418 | + netdev_dbg(skb->dev, "drop malformed packet\n"); | |
| 1419 | + return false; | |
| 1420 | + } | |
| 1421 | + | |
| 1422 | + if (pad_to_len && | |
| 1423 | + !rtase_pad_to_transport_len(skb, transport_offset, pad_to_len)) | |
| 1424 | + return false; | |
| 1425 | + | |
| 1426 | + if (transport_proto != IPPROTO_UDP) | |
| 1427 | + return true; | |
| 1428 | + | |
| 1429 | + trans_data_len = skb->len - transport_offset; | |
| 1430 | + if (trans_data_len < offsetof(struct udphdr, len) || | |
| 1431 | + trans_data_len >= RTASE_MIN_PAD_LEN) | |
| 1432 | + return true; | |
| 1433 | + | |
| 1434 | + dest = skb_header_pointer(skb, | |
| 1435 | + transport_offset + | |
| 1436 | + offsetof(struct udphdr, dest), | |
| 1437 | + sizeof(_dest), &_dest); | |
| 1438 | + if (!dest) | |
| 1439 | + return true; | |
| 1440 | + | |
| 1441 | + dest_port = ntohs(*dest); | |
| 1442 | + if (dest_port != PTP_EV_PORT && dest_port != PTP_GEN_PORT) | |
| 1443 | + return true; | |
| 1444 | + | |
| 1445 | + return rtase_pad_to_transport_len(skb, transport_offset, | |
| 1446 | + RTASE_MIN_PAD_LEN); | |
| 1447 | +} | |
| 1448 | + | |
| 1255 | 1449 | static int rtase_xmit_frags(struct rtase_ring *ring, struct sk_buff *skb, |
| 1256 | 1450 | u32 opts1, u32 opts2) |
| 1257 | 1451 | { |
| @@ -1365,6 +1559,9 @@ static netdev_tx_t rtase_start_xmit(struct sk_buff *skb, · 107 unmodified lines | ||
| 1365 | 1559 | opts2 |= rtase_tx_csum(skb, dev); |
| 1366 | 1560 | } |
| 1367 | 1561 | |
| 1562 | + if (!rtase_skb_pad(skb)) | |
| 1563 | + goto err_dma_0; | |
| 1564 | + | |
| 1368 | 1565 | frags = rtase_xmit_frags(ring, skb, opts1, opts2); |
| 1369 | 1566 | if (unlikely(frags < 0)) |
| 1370 | 1567 | goto err_dma_0; |
| @@ -525,6 +525,32 @@ static int intel_set_reg_access(const struct pmc_serdes_regs *regs, int max_regs · 524 unmodified lines | ||
| 525 | 525 | return ret; |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | +/* | |
| 529 | + * Return true if the SerDes lane rate must change to serve @interface. | |
| 530 | + * If the current rate cannot be determined, reconfigure as before. | |
| 531 | + */ | |
| 532 | +static bool intel_serdes_needs_reconfig(struct stmmac_priv *priv, | |
| 533 | + struct intel_priv_data *intel_priv, | |
| 534 | + phy_interface_t interface) | |
| 535 | +{ | |
| 536 | + u32 cur_rate, want_rate; | |
| 537 | + int data; | |
| 538 | + | |
| 539 | + if (!intel_priv->mdio_adhoc_addr) | |
| 540 | + return true; | |
| 541 | + | |
| 542 | + data = mdiobus_read(priv->mii, intel_priv->mdio_adhoc_addr, | |
| 543 | + SERDES_GCR0); | |
| 544 | + if (data < 0) | |
| 545 | + return true; | |
| 546 | + | |
| 547 | + cur_rate = (data & SERDES_RATE_MASK) >> SERDES_RATE_PCIE_SHIFT; | |
| 548 | + want_rate = interface == PHY_INTERFACE_MODE_2500BASEX ? | |
| 549 | + SERDES_RATE_PCIE_GEN2 : SERDES_RATE_PCIE_GEN1; | |
| 550 | + | |
| 551 | + return cur_rate != want_rate; | |
| 552 | +} | |
| 553 | + | |
| 528 | 554 | static int intel_mac_finish(struct net_device *ndev, |
| 529 | 555 | void *intel_data, |
| 530 | 556 | unsigned int mode, |
| @@ -536,6 +562,11 @@ static int intel_mac_finish(struct net_device *ndev, · 5 unmodified lines | ||
| 536 | 562 | int max_regs = 0; |
| 537 | 563 | int ret = 0; |
| 538 | 564 | |
| 565 | + if (!intel_serdes_needs_reconfig(priv, intel_priv, interface)) { | |
| 566 | + priv->plat->phy_interface = interface; | |
| 567 | + return 0; | |
| 568 | + } | |
| 569 | + | |
| 539 | 570 | ret = intel_tsn_lane_is_available(ndev, intel_priv); |
| 540 | 571 | if (ret < 0) { |
| 541 | 572 | netdev_info(priv->dev, "No TSN lane available to set the registers.\n"); |
| @@ -106,6 +106,17 @@ static void dwmac4_dma_init_channel(struct stmmac_priv *priv, · 105 unmodified lines | ||
| 106 | 106 | ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan)); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | +static void dwmac4_dma_deinit_channel(struct stmmac_priv *priv, | |
| 110 | + void __iomem *ioaddr, u32 chan) | |
| 111 | +{ | |
| 112 | + const struct dwmac4_addrs *dwmac4_addrs = priv->plat->dwmac4_addrs; | |
| 113 | + u32 value; | |
| 114 | + | |
| 115 | + value = readl(ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan)); | |
| 116 | + value &= ~DMA_CHAN_INTR_DEFAULT_MASK; | |
| 117 | + writel(value, ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan)); | |
| 118 | +} | |
| 119 | + | |
| 109 | 120 | static void dwmac410_dma_init_channel(struct stmmac_priv *priv, |
| 110 | 121 | void __iomem *ioaddr, |
| 111 | 122 | struct stmmac_dma_cfg *dma_cfg, u32 chan) |
| @@ -125,6 +136,17 @@ static void dwmac410_dma_init_channel(struct stmmac_priv *priv, · 13 unmodified lines | ||
| 125 | 136 | ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan)); |
| 126 | 137 | } |
| 127 | 138 | |
| 139 | +static void dwmac410_dma_deinit_channel(struct stmmac_priv *priv, | |
| 140 | + void __iomem *ioaddr, u32 chan) | |
| 141 | +{ | |
| 142 | + const struct dwmac4_addrs *dwmac4_addrs = priv->plat->dwmac4_addrs; | |
| 143 | + u32 value; | |
| 144 | + | |
| 145 | + value = readl(ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan)); | |
| 146 | + value &= ~DMA_CHAN_INTR_DEFAULT_MASK_4_10; | |
| 147 | + writel(value, ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan)); | |
| 148 | +} | |
| 149 | + | |
| 128 | 150 | static void dwmac4_dma_init(void __iomem *ioaddr, |
| 129 | 151 | struct stmmac_dma_cfg *dma_cfg) |
| 130 | 152 | { |
| @@ -548,6 +570,7 @@ const struct stmmac_dma_ops dwmac4_dma_ops = { · 417 unmodified lines | ||
| 548 | 570 | .reset = dwmac4_dma_reset, |
| 549 | 571 | .init = dwmac4_dma_init, |
| 550 | 572 | .init_chan = dwmac4_dma_init_channel, |
| 573 | + .deinit_chan = dwmac4_dma_deinit_channel, | |
| 551 | 574 | .init_rx_chan = dwmac4_dma_init_rx_chan, |
| 552 | 575 | .init_tx_chan = dwmac4_dma_init_tx_chan, |
| 553 | 576 | .axi = dwmac4_dma_axi, |
| @@ -577,6 +600,7 @@ const struct stmmac_dma_ops dwmac410_dma_ops = { · 23 unmodified lines | ||
| 577 | 600 | .reset = dwmac4_dma_reset, |
| 578 | 601 | .init = dwmac4_dma_init, |
| 579 | 602 | .init_chan = dwmac410_dma_init_channel, |
| 603 | + .deinit_chan = dwmac410_dma_deinit_channel, | |
| 580 | 604 | .init_rx_chan = dwmac4_dma_init_rx_chan, |
| 581 | 605 | .init_tx_chan = dwmac4_dma_init_tx_chan, |
| 582 | 606 | .axi = dwmac4_dma_axi, |
| @@ -1370,36 +1370,40 @@ static int dwxgmac2_config_l4_filter(struct mac_device_info *hw, u32 filter_no, · 1369 unmodified lines | ||
| 1370 | 1370 | value &= ~XGMAC_L4PEN0; |
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | − value &= ~(XGMAC_L4SPM0 | XGMAC_L4SPIM0); | |
| 1374 | − value &= ~(XGMAC_L4DPM0 | XGMAC_L4DPIM0); | |
| 1375 | 1373 | if (sa) { |
| 1376 | 1374 | value |= XGMAC_L4SPM0; |
| 1377 | 1375 | if (inv) |
| 1378 | 1376 | value |= XGMAC_L4SPIM0; |
| 1377 | + else | |
| 1378 | + value &= ~XGMAC_L4SPIM0; | |
| 1379 | 1379 | } else { |
| 1380 | 1380 | value |= XGMAC_L4DPM0; |
| 1381 | 1381 | if (inv) |
| 1382 | 1382 | value |= XGMAC_L4DPIM0; |
| 1383 | + else | |
| 1384 | + value &= ~XGMAC_L4DPIM0; | |
| 1383 | 1385 | } |
| 1384 | 1386 | |
| 1385 | 1387 | ret = dwxgmac2_filter_write(hw, filter_no, XGMAC_L3L4_CTRL, value); |
| 1386 | 1388 | if (ret) |
| 1387 | 1389 | return ret; |
| 1388 | 1390 | |
| 1389 | − if (sa) { | |
| 1390 | − value = FIELD_PREP(XGMAC_L4SP0, match); | |
| 1391 | + ret = dwxgmac2_filter_read(hw, filter_no, XGMAC_L4_ADDR, &value); | |
| 1392 | + if (ret) | |
| 1393 | + return ret; | |
| 1391 | 1394 | |
| 1392 | − ret = dwxgmac2_filter_write(hw, filter_no, XGMAC_L4_ADDR, value); | |
| 1393 | − if (ret) | |
| 1394 | − return ret; | |
| 1395 | + if (sa) { | |
| 1396 | + value &= ~XGMAC_L4SP0; | |
| 1397 | + value |= FIELD_PREP(XGMAC_L4SP0, match); | |
| 1395 | 1398 | } else { |
| 1396 | − value = FIELD_PREP(XGMAC_L4DP0, match); | |
| 1397 | − | |
| 1398 | − ret = dwxgmac2_filter_write(hw, filter_no, XGMAC_L4_ADDR, value); | |
| 1399 | − if (ret) | |
| 1400 | − return ret; | |
| 1399 | + value &= ~XGMAC_L4DP0; | |
| 1400 | + value |= FIELD_PREP(XGMAC_L4DP0, match); | |
| 1401 | 1401 | } |
| 1402 | 1402 | |
| 1403 | + ret = dwxgmac2_filter_write(hw, filter_no, XGMAC_L4_ADDR, value); | |
| 1404 | + if (ret) | |
| 1405 | + return ret; | |
| 1406 | + | |
| 1403 | 1407 | if (!en) |
| 1404 | 1408 | return dwxgmac2_filter_write(hw, filter_no, XGMAC_L3L4_CTRL, 0); |
| 1405 | 1409 | |
| @@ -170,6 +170,8 @@ struct stmmac_dma_ops { · 169 unmodified lines | ||
| 170 | 170 | void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg); |
| 171 | 171 | void (*init_chan)(struct stmmac_priv *priv, void __iomem *ioaddr, |
| 172 | 172 | struct stmmac_dma_cfg *dma_cfg, u32 chan); |
| 173 | + void (*deinit_chan)(struct stmmac_priv *priv, void __iomem *ioaddr, | |
| 174 | + u32 chan); | |
| 173 | 175 | void (*init_rx_chan)(struct stmmac_priv *priv, void __iomem *ioaddr, |
| 174 | 176 | struct stmmac_dma_cfg *dma_cfg, |
| 175 | 177 | dma_addr_t phy, u32 chan); |
| @@ -235,6 +237,8 @@ struct stmmac_dma_ops { · 59 unmodified lines | ||
| 235 | 237 | stmmac_do_void_callback(__priv, dma, init, __args) |
| 236 | 238 | #define stmmac_init_chan(__priv, __args...) \ |
| 237 | 239 | stmmac_do_void_callback(__priv, dma, init_chan, __priv, __args) |
| 240 | +#define stmmac_deinit_chan(__priv, __args...) \ | |
| 241 | + stmmac_do_void_callback(__priv, dma, deinit_chan, __priv, __args) | |
| 238 | 242 | #define stmmac_init_rx_chan(__priv, __args...) \ |
| 239 | 243 | stmmac_do_void_callback(__priv, dma, init_rx_chan, __priv, __args) |
| 240 | 244 | #define stmmac_init_tx_chan(__priv, __args...) \ |
| @@ -1083,63 +1083,45 @@ static void stmmac_mac_link_up(struct phylink_config *config, · 1082 unmodified lines | ||
| 1083 | 1083 | old_ctrl = readl(priv->ioaddr + MAC_CTRL_REG); |
| 1084 | 1084 | ctrl = old_ctrl & ~priv->hw->link.speed_mask; |
| 1085 | 1085 | |
| 1086 | − if (interface == PHY_INTERFACE_MODE_USXGMII) { | |
| 1087 | − switch (speed) { | |
| 1088 | − case SPEED_10000: | |
| 1089 | − ctrl |= priv->hw->link.xgmii.speed10000; | |
| 1090 | − break; | |
| 1091 | − case SPEED_5000: | |
| 1092 | − ctrl |= priv->hw->link.xgmii.speed5000; | |
| 1093 | − break; | |
| 1094 | − case SPEED_2500: | |
| 1086 | + switch (speed) { | |
| 1087 | + case SPEED_100000: | |
| 1088 | + ctrl |= priv->hw->link.xlgmii.speed100000; | |
| 1089 | + break; | |
| 1090 | + case SPEED_50000: | |
| 1091 | + ctrl |= priv->hw->link.xlgmii.speed50000; | |
| 1092 | + break; | |
| 1093 | + case SPEED_40000: | |
| 1094 | + ctrl |= priv->hw->link.xlgmii.speed40000; | |
| 1095 | + break; | |
| 1096 | + case SPEED_25000: | |
| 1097 | + ctrl |= priv->hw->link.xlgmii.speed25000; | |
| 1098 | + break; | |
| 1099 | + case SPEED_10000: | |
| 1100 | + ctrl |= priv->hw->link.xgmii.speed10000; | |
| 1101 | + break; | |
| 1102 | + case SPEED_5000: | |
| 1103 | + ctrl |= priv->hw->link.xgmii.speed5000; | |
| 1104 | + break; | |
| 1105 | + case SPEED_2500: | |
| 1106 | + if (interface == PHY_INTERFACE_MODE_USXGMII) | |
| 1095 | 1107 | ctrl |= priv->hw->link.xgmii.speed2500; |
| 1096 | − break; | |
| 1097 | − default: | |
| 1098 | − return; | |
| 1099 | − } | |
| 1100 | − } else if (interface == PHY_INTERFACE_MODE_XLGMII) { | |
| 1101 | − switch (speed) { | |
| 1102 | − case SPEED_100000: | |
| 1103 | − ctrl |= priv->hw->link.xlgmii.speed100000; | |
| 1104 | − break; | |
| 1105 | − case SPEED_50000: | |
| 1106 | − ctrl |= priv->hw->link.xlgmii.speed50000; | |
| 1107 | − break; | |
| 1108 | − case SPEED_40000: | |
| 1109 | − ctrl |= priv->hw->link.xlgmii.speed40000; | |
| 1110 | − break; | |
| 1111 | − case SPEED_25000: | |
| 1112 | − ctrl |= priv->hw->link.xlgmii.speed25000; | |
| 1113 | − break; | |
| 1114 | − case SPEED_10000: | |
| 1115 | − ctrl |= priv->hw->link.xgmii.speed10000; | |
| 1116 | − break; | |
| 1117 | − case SPEED_2500: | |
| 1118 | − ctrl |= priv->hw->link.speed2500; | |
| 1119 | − break; | |
| 1120 | − case SPEED_1000: | |
| 1121 | − ctrl |= priv->hw->link.speed1000; | |
| 1122 | − break; | |
| 1123 | − default: | |
| 1124 | − return; | |
| 1125 | − } | |
| 1126 | − } else { | |
| 1127 | − switch (speed) { | |
| 1128 | − case SPEED_2500: | |
| 1108 | + else | |
| 1129 | 1109 | ctrl |= priv->hw->link.speed2500; |
| 1130 | − break; | |
| 1131 | − case SPEED_1000: | |
| 1132 | − ctrl |= priv->hw->link.speed1000; | |
| 1133 | − break; | |
| 1134 | − case SPEED_100: | |
| 1135 | − ctrl |= priv->hw->link.speed100; | |
| 1136 | − break; | |
| 1137 | − case SPEED_10: | |
| 1138 | − ctrl |= priv->hw->link.speed10; | |
| 1139 | − break; | |
| 1140 | − default: | |
| 1141 | − return; | |
| 1142 | − } | |
| 1110 | + break; | |
| 1111 | + case SPEED_1000: | |
| 1112 | + ctrl |= priv->hw->link.speed1000; | |
| 1113 | + break; | |
| 1114 | + case SPEED_100: | |
| 1115 | + ctrl |= priv->hw->link.speed100; | |
| 1116 | + break; | |
| 1117 | + case SPEED_10: | |
| 1118 | + ctrl |= priv->hw->link.speed10; | |
| 1119 | + break; | |
| 1120 | + default: | |
| 1121 | + netdev_err(priv->dev, | |
| 1122 | + "unsupported speed %s on %s, leaving the MAC disabled\n", | |
| 1123 | + phy_speed_to_str(speed), phy_modes(interface)); | |
| 1124 | + return; | |
| 1143 | 1125 | } |
| 1144 | 1126 | |
| 1145 | 1127 | if (priv->plat->fix_mac_speed) |
| @@ -2560,6 +2542,7 @@ static void stmmac_stop_all_dma(struct stmmac_priv *priv) · 1414 unmodified lines | ||
| 2560 | 2542 | { |
| 2561 | 2543 | u8 rx_channels_count = priv->plat->rx_queues_to_use; |
| 2562 | 2544 | u8 tx_channels_count = priv->plat->tx_queues_to_use; |
| 2545 | + u8 dma_csr_ch = max(rx_channels_count, tx_channels_count); | |
| 2563 | 2546 | u8 chan; |
| 2564 | 2547 | |
| 2565 | 2548 | for (chan = 0; chan < rx_channels_count; chan++) |
| @@ -2567,6 +2550,9 @@ static void stmmac_stop_all_dma(struct stmmac_priv *priv) · 1 unmodified line | ||
| 2567 | 2550 | |
| 2568 | 2551 | for (chan = 0; chan < tx_channels_count; chan++) |
| 2569 | 2552 | stmmac_stop_tx_dma(priv, chan); |
| 2553 | + | |
| 2554 | + for (chan = 0; chan < dma_csr_ch; chan++) | |
| 2555 | + stmmac_deinit_chan(priv, priv->ioaddr, chan); | |
| 2570 | 2556 | } |
| 2571 | 2557 | |
| 2572 | 2558 | /** |
| @@ -446,6 +446,7 @@ static int tc_parse_flow_actions(struct stmmac_priv *priv, · 445 unmodified lines | ||
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | #define ETHER_TYPE_FULL_MASK cpu_to_be16(~0) |
| 449 | +#define IP_PROTO_FULL_MASK 0xFF | |
| 449 | 450 | |
| 450 | 451 | static int tc_add_basic_flow(struct stmmac_priv *priv, |
| 451 | 452 | struct flow_cls_offload *cls, |
| @@ -461,6 +462,37 @@ static int tc_add_basic_flow(struct stmmac_priv *priv, · 9 unmodified lines | ||
| 461 | 462 | |
| 462 | 463 | flow_rule_match_basic(rule, &match); |
| 463 | 464 | |
| 465 | + /* Both network proto and transport proto not present in the key */ | |
| 466 | + if (!match.mask || !(match.mask->n_proto || match.mask->ip_proto)) { | |
| 467 | + NL_SET_ERR_MSG_MOD(cls->common.extack, | |
| 468 | + "filter must specify network or transport protocol"); | |
| 469 | + return -EOPNOTSUPP; | |
| 470 | + } | |
| 471 | + | |
| 472 | + /* If the proto is present in the key and is not full mask */ | |
| 473 | + if ((match.mask->n_proto && match.mask->n_proto != ETHER_TYPE_FULL_MASK) || | |
| 474 | + (match.mask->ip_proto && match.mask->ip_proto != IP_PROTO_FULL_MASK)) { | |
| 475 | + NL_SET_ERR_MSG_MOD(cls->common.extack, | |
| 476 | + "only full protocol mask is supported"); | |
| 477 | + return -EOPNOTSUPP; | |
| 478 | + } | |
| 479 | + | |
| 480 | + /* Network proto is present in the key and is not IPv4 */ | |
| 481 | + if (match.mask->n_proto && match.key->n_proto != cpu_to_be16(ETH_P_IP)) { | |
| 482 | + NL_SET_ERR_MSG_MOD(cls->common.extack, | |
| 483 | + "only IPv4 network protocol is supported"); | |
| 484 | + return -EOPNOTSUPP; | |
| 485 | + } | |
| 486 | + | |
| 487 | + /* Transport proto is present in the key and is not TCP or UDP */ | |
| 488 | + if (match.mask->ip_proto && | |
| 489 | + match.key->ip_proto != IPPROTO_TCP && | |
| 490 | + match.key->ip_proto != IPPROTO_UDP) { | |
| 491 | + NL_SET_ERR_MSG_MOD(cls->common.extack, | |
| 492 | + "only TCP and UDP transport protocols are supported"); | |
| 493 | + return -EOPNOTSUPP; | |
| 494 | + } | |
| 495 | + | |
| 464 | 496 | entry->ip_proto = match.key->ip_proto; |
| 465 | 497 | return 0; |
| 466 | 498 | } |
| @@ -598,6 +630,8 @@ static int tc_add_flow(struct stmmac_priv *priv, · 131 unmodified lines | ||
| 598 | 630 | ret = tc_flow_parsers[i].fn(priv, cls, entry); |
| 599 | 631 | if (!ret) |
| 600 | 632 | entry->in_use = true; |
| 633 | + else if (ret == -EOPNOTSUPP) | |
| 634 | + return ret; | |
| 601 | 635 | } |
| 602 | 636 | |
| 603 | 637 | if (!entry->in_use) |
| @@ -627,6 +661,7 @@ static int tc_del_flow(struct stmmac_priv *priv, · 23 unmodified lines | ||
| 627 | 661 | entry->in_use = false; |
| 628 | 662 | entry->cookie = 0; |
| 629 | 663 | entry->is_l4 = false; |
| 664 | + entry->action = 0; | |
| 630 | 665 | return ret; |
| 631 | 666 | } |
| 632 | 667 | |
| @@ -96,11 +96,13 @@ int txgbe_read_eeprom_hostif(struct wx *wx, · 95 unmodified lines | ||
| 96 | 96 | dword_len = round_up(length, 4) >> 2; |
| 97 | 97 | |
| 98 | 98 | for (i = 0; i < dword_len; i++) { |
| 99 | + u32 copy_len = min_t(u32, 4, length - i * 4); | |
| 100 | + | |
| 99 | 101 | value = rd32a(wx, WX_FW2SW_MBOX, i + offset); |
| 100 | 102 | le32_to_cpus(&value); |
| 101 | 103 | |
| 102 | − memcpy(data, &value, 4); | |
| 103 | − data += 4; | |
| 104 | + memcpy(data, &value, copy_len); | |
| 105 | + data += copy_len; | |
| 104 | 106 | } |
| 105 | 107 | |
| 106 | 108 | return 0; |
| @@ -945,6 +945,7 @@ static void txgbe_remove(struct pci_dev *pdev) · 944 unmodified lines | ||
| 945 | 945 | netdev = wx->netdev; |
| 946 | 946 | wx_disable_sriov(wx); |
| 947 | 947 | unregister_netdev(netdev); |
| 948 | + txgbe_fdir_filter_exit(wx); | |
| 948 | 949 | |
| 949 | 950 | timer_shutdown_sync(&wx->service_timer); |
| 950 | 951 | cancel_work_sync(&wx->service_task); |
| @@ -43,8 +43,17 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN"); · 42 unmodified lines | ||
| 43 | 43 | #define GENEVE_OPT_GRO_HINT_LEN 1 |
| 44 | 44 | |
| 45 | 45 | struct geneve_opt_gro_hint { |
| 46 | +#if defined(__LITTLE_ENDIAN_BITFIELD) | |
| 46 | 47 | u8 inner_proto_id:2, |
| 47 | − nested_is_v6:1; | |
| 48 | + nested_is_v6:1, | |
| 49 | + rsvd:5; | |
| 50 | +#elif defined(__BIG_ENDIAN_BITFIELD) | |
| 51 | + u8 rsvd:5, | |
| 52 | + nested_is_v6:1, | |
| 53 | + inner_proto_id:2; | |
| 54 | +#else | |
| 55 | +#error "Please fix <asm/byteorder.h>" | |
| 56 | +#endif | |
| 48 | 57 | u8 nested_nh_offset; |
| 49 | 58 | u8 nested_tp_offset; |
| 50 | 59 | u8 nested_hdr_len; |
| @@ -577,6 +586,7 @@ static int geneve_post_decap_hint(const struct sock *sk, struct sk_buff *skb, · 526 unmodified lines | ||
| 577 | 586 | struct iphdr *iph; |
| 578 | 587 | struct udphdr *uh; |
| 579 | 588 | __be16 p; |
| 589 | + int err; | |
| 580 | 590 | |
| 581 | 591 | hint_off = geneve_sk_gro_hint_off(sk, *geneveh, &p, &len); |
| 582 | 592 | if (!hint_off) |
| @@ -601,12 +611,20 @@ static int geneve_post_decap_hint(const struct sock *sk, struct sk_buff *skb, · 18 unmodified lines | ||
| 601 | 611 | !geneve_opt_gro_hint_validate(skb->data, gro_hint))) |
| 602 | 612 | return -EINVAL; |
| 603 | 613 | |
| 604 | − ipv6h = (void *)skb->data + gro_hint->nested_nh_offset; | |
| 605 | − iph = (struct iphdr *)ipv6h; | |
| 606 | 614 | total_len = skb->len - gro_hint->nested_nh_offset; |
| 607 | 615 | if (total_len >= GRO_LEGACY_MAX_SIZE) |
| 608 | 616 | return -E2BIG; |
| 609 | 617 | |
| 618 | + err = skb_ensure_writable(skb, gro_hint->nested_tp_offset + sizeof(*uh)); | |
| 619 | + if (unlikely(err)) | |
| 620 | + return err; | |
| 621 | + | |
| 622 | + *geneveh = geneve_hdr(skb); | |
| 623 | + gro_hint = geneve_opt_gro_hint(*geneveh, hint_off); | |
| 624 | + | |
| 625 | + ipv6h = (void *)skb->data + gro_hint->nested_nh_offset; | |
| 626 | + iph = (struct iphdr *)ipv6h; | |
| 627 | + | |
| 610 | 628 | /* |
| 611 | 629 | * After stripping the outer encap, the packet still carries a |
| 612 | 630 | * tunnel encapsulation: the nested one. |
| @@ -2376,6 +2394,9 @@ static int geneve_changelink(struct net_device *dev, struct nlattr *tb[], · 1763 unmodified lines | ||
| 2376 | 2394 | struct geneve_config cfg; |
| 2377 | 2395 | int err; |
| 2378 | 2396 | |
| 2397 | + if (!rtnl_dev_link_net_capable(dev, geneve->net)) | |
| 2398 | + return -EPERM; | |
| 2399 | + | |
| 2379 | 2400 | /* If the geneve device is configured for metadata (or externally |
| 2380 | 2401 | * controlled, for example, OVS), then nothing can be changed. |
| 2381 | 2402 | */ |
| @@ -669,8 +669,9 @@ static int gtp1u_send_echo_resp(struct gtp_dev *gtp, struct sk_buff *skb) · 668 unmodified lines | ||
| 669 | 669 | return -1; |
| 670 | 670 | |
| 671 | 671 | /* pull GTP and UDP headers */ |
| 672 | − skb_pull_data(skb, | |
| 673 | − sizeof(struct gtp1_header_long) + sizeof(struct udphdr)); | |
| 672 | + if (!skb_pull_data(skb, sizeof(struct gtp1_header_long) + | |
| 673 | + sizeof(struct udphdr))) | |
| 674 | + return -1; | |
| 674 | 675 | |
| 675 | 676 | gtp_pkt = skb_push(skb, sizeof(struct gtp1u_packet)); |
| 676 | 677 | memset(gtp_pkt, 0, sizeof(struct gtp1u_packet)); |
| @@ -826,13 +827,17 @@ static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb) · 149 unmodified lines | ||
| 826 | 827 | if (!pskb_may_pull(skb, hdrlen)) |
| 827 | 828 | return -1; |
| 828 | 829 | |
| 830 | + gtp1 = (struct gtp1_header *)(skb->data + sizeof(struct udphdr)); | |
| 831 | + | |
| 832 | + if (gtp1->flags & GTP1_F_EXTHDR && | |
| 833 | + gtp_parse_exthdrs(skb, &hdrlen) < 0) | |
| 834 | + return -1; | |
| 835 | + | |
| 829 | 836 | if (gtp_inner_proto(skb, hdrlen, &inner_proto) < 0) { |
| 830 | 837 | netdev_dbg(gtp->dev, "GTP packet does not encapsulate an IP packet\n"); |
| 831 | 838 | return -1; |
| 832 | 839 | } |
| 833 | 840 | |
| 834 | − gtp1 = (struct gtp1_header *)(skb->data + sizeof(struct udphdr)); | |
| 835 | − | |
| 836 | 841 | pctx = gtp1_pdp_find(gtp, ntohl(gtp1->tid), |
| 837 | 842 | gtp_proto_to_family(inner_proto)); |
| 838 | 843 | if (!pctx) { |
| @@ -840,10 +845,6 @@ static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb) · 1 unmodified line | ||
| 840 | 845 | return 1; |
| 841 | 846 | } |
| 842 | 847 | |
| 843 | − if (gtp1->flags & GTP1_F_EXTHDR && | |
| 844 | − gtp_parse_exthdrs(skb, &hdrlen) < 0) | |
| 845 | − return -1; | |
| 846 | − | |
| 847 | 848 | return gtp_rx(pctx, skb, hdrlen, gtp->role, inner_proto); |
| 848 | 849 | } |
| 849 | 850 | |
| @@ -731,18 +731,21 @@ static __init int mctp_i3c_mod_init(void) · 730 unmodified lines | ||
| 731 | 731 | int rc; |
| 732 | 732 | |
| 733 | 733 | rc = i3c_register_notifier(&mctp_i3c_notifier); |
| 734 | − if (rc < 0) { | |
| 735 | − i3c_driver_unregister(&mctp_i3c_driver); | |
| 734 | + if (rc < 0) | |
| 736 | 735 | return rc; |
| 737 | − } | |
| 738 | 736 | |
| 739 | 737 | i3c_for_each_bus_locked(mctp_i3c_bus_add_new, NULL); |
| 740 | 738 | |
| 741 | 739 | rc = i3c_driver_register(&mctp_i3c_driver); |
| 742 | 740 | if (rc < 0) |
| 743 | − return rc; | |
| 741 | + goto err_unregister_notifier; | |
| 744 | 742 | |
| 745 | 743 | return 0; |
| 744 | + | |
| 745 | +err_unregister_notifier: | |
| 746 | + i3c_unregister_notifier(&mctp_i3c_notifier); | |
| 747 | + mctp_i3c_bus_remove_all(); | |
| 748 | + return rc; | |
| 746 | 749 | } |
| 747 | 750 | |
| 748 | 751 | static __exit void mctp_i3c_mod_exit(void) |
| @@ -318,7 +318,7 @@ static void mctp_serial_push_header(struct mctp_serial *dev, u8 c) · 317 unmodified lines | ||
| 318 | 318 | } else { |
| 319 | 319 | dev->rxlen = c; |
| 320 | 320 | dev->rxpos = 0; |
| 321 | − dev->rxstate = STATE_DATA; | |
| 321 | + dev->rxstate = c > 0 ? STATE_DATA : STATE_TRAILER; | |
| 322 | 322 | dev->rxfcs = crc_ccitt_byte(dev->rxfcs, c); |
| 323 | 323 | } |
| 324 | 324 | break; |
| @@ -142,7 +142,7 @@ void ovpn_decrypt_post(void *data, int ret) · 141 unmodified lines | ||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /* keep track of last received authenticated packet for keepalive */ |
| 145 | − WRITE_ONCE(peer->last_recv, ktime_get_real_seconds()); | |
| 145 | + WRITE_ONCE(peer->last_recv, ktime_get_boottime_seconds()); | |
| 146 | 146 | |
| 147 | 147 | rcu_read_lock(); |
| 148 | 148 | sock = rcu_dereference(peer->sock); |
| @@ -294,7 +294,7 @@ void ovpn_encrypt_post(void *data, int ret) · 145 unmodified lines | ||
| 294 | 294 | |
| 295 | 295 | ovpn_peer_stats_increment_tx(&peer->link_stats, orig_len); |
| 296 | 296 | /* keep track of last sent packet for keepalive */ |
| 297 | − WRITE_ONCE(peer->last_sent, ktime_get_real_seconds()); | |
| 297 | + WRITE_ONCE(peer->last_sent, ktime_get_boottime_seconds()); | |
| 298 | 298 | /* skb passed down the stack - don't free it */ |
| 299 | 299 | skb = NULL; |
| 300 | 300 | err_unlock: |
| @@ -26,11 +26,12 @@ static void unlock_ovpn(struct ovpn_priv *ovpn, · 25 unmodified lines | ||
| 26 | 26 | struct llist_head *release_list) |
| 27 | 27 | __releases(&ovpn->lock) |
| 28 | 28 | { |
| 29 | − struct ovpn_peer *peer; | |
| 29 | + struct ovpn_peer *peer, *next; | |
| 30 | 30 | |
| 31 | 31 | spin_unlock_bh(&ovpn->lock); |
| 32 | 32 | |
| 33 | − llist_for_each_entry(peer, release_list->first, release_entry) { | |
| 33 | + llist_for_each_entry_safe(peer, next, release_list->first, | |
| 34 | + release_entry) { | |
| 34 | 35 | ovpn_socket_release(peer); |
| 35 | 36 | ovpn_peer_put(peer); |
| 36 | 37 | } |
| @@ -44,7 +45,7 @@ static void unlock_ovpn(struct ovpn_priv *ovpn, · 7 unmodified lines | ||
| 44 | 45 | */ |
| 45 | 46 | void ovpn_peer_keepalive_set(struct ovpn_peer *peer, u32 interval, u32 timeout) |
| 46 | 47 | { |
| 47 | − time64_t now = ktime_get_real_seconds(); | |
| 48 | + time64_t now = ktime_get_boottime_seconds(); | |
| 48 | 49 | |
| 49 | 50 | netdev_dbg(peer->ovpn->dev, |
| 50 | 51 | "scheduling keepalive for peer %u: interval=%u timeout=%u\n", |
| @@ -1167,7 +1168,6 @@ static void ovpn_peer_release_p2p(struct ovpn_priv *ovpn, struct sock *sk, · 1116 unmodified lines | ||
| 1167 | 1168 | ovpn_sock = rcu_access_pointer(peer->sock); |
| 1168 | 1169 | if (!ovpn_sock || ovpn_sock->sk != sk) { |
| 1169 | 1170 | spin_unlock_bh(&ovpn->lock); |
| 1170 | − ovpn_peer_put(peer); | |
| 1171 | 1171 | return; |
| 1172 | 1172 | } |
| 1173 | 1173 | } |
| @@ -1285,8 +1285,10 @@ static time64_t ovpn_peer_keepalive_work_single(struct ovpn_peer *peer, · 111 unmodified lines | ||
| 1285 | 1285 | netdev_dbg(peer->ovpn->dev, |
| 1286 | 1286 | "sending keepalive to peer %u\n", |
| 1287 | 1287 | peer->id); |
| 1288 | − if (schedule_work(&peer->keepalive_work)) | |
| 1289 | − ovpn_peer_hold(peer); | |
| 1288 | + if (WARN_ON(!ovpn_peer_hold(peer))) | |
| 1289 | + return 0; | |
| 1290 | + if (!schedule_work(&peer->keepalive_work)) | |
| 1291 | + ovpn_peer_put(peer); | |
| 1290 | 1292 | } |
| 1291 | 1293 | |
| 1292 | 1294 | if (next_run1 < next_run2) |
| @@ -1357,7 +1359,7 @@ void ovpn_peer_keepalive_work(struct work_struct *work) · 64 unmodified lines | ||
| 1357 | 1359 | { |
| 1358 | 1360 | struct ovpn_priv *ovpn = container_of(work, struct ovpn_priv, |
| 1359 | 1361 | keepalive_work.work); |
| 1360 | − time64_t next_run = 0, now = ktime_get_real_seconds(); | |
| 1362 | + time64_t next_run = 0, now = ktime_get_boottime_seconds(); | |
| 1361 | 1363 | LLIST_HEAD(release_list); |
| 1362 | 1364 | |
| 1363 | 1365 | spin_lock_bh(&ovpn->lock); |
| @@ -151,7 +151,8 @@ err: · 150 unmodified lines | ||
| 151 | 151 | /* take reference for deferred peer deletion. should never fail */ |
| 152 | 152 | if (WARN_ON(!ovpn_peer_hold(peer))) |
| 153 | 153 | goto err_nopeer; |
| 154 | − schedule_work(&peer->tcp.defer_del_work); | |
| 154 | + if (!schedule_work(&peer->tcp.defer_del_work)) | |
| 155 | + ovpn_peer_put(peer); | |
| 155 | 156 | ovpn_dev_dstats_rx_dropped(peer->ovpn->dev); |
| 156 | 157 | err_nopeer: |
| 157 | 158 | kfree_skb(skb); |
| @@ -283,7 +284,8 @@ static void ovpn_tcp_send_sock(struct ovpn_peer *peer, struct sock *sk) · 125 unmodified lines | ||
| 283 | 284 | * stream therefore we abort the connection |
| 284 | 285 | */ |
| 285 | 286 | ovpn_peer_hold(peer); |
| 286 | − schedule_work(&peer->tcp.defer_del_work); | |
| 287 | + if (!schedule_work(&peer->tcp.defer_del_work)) | |
| 288 | + ovpn_peer_put(peer); | |
| 287 | 289 | |
| 288 | 290 | /* we bail out immediately and keep tx_in_progress set |
| 289 | 291 | * to true. This way we prevent more TX attempts |
| @@ -1058,6 +1058,7 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs, · 1057 unmodified lines | ||
| 1058 | 1058 | |
| 1059 | 1059 | /* Reset link_state */ |
| 1060 | 1060 | state->link = false; |
| 1061 | + state->an_complete = false; | |
| 1061 | 1062 | state->speed = SPEED_UNKNOWN; |
| 1062 | 1063 | state->duplex = DUPLEX_UNKNOWN; |
| 1063 | 1064 | state->pause = 0; |
| @@ -1069,6 +1070,8 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs, · 5 unmodified lines | ||
| 1069 | 1070 | if (ret < 0) |
| 1070 | 1071 | return ret; |
| 1071 | 1072 | |
| 1073 | + state->an_complete = ret & DW_VR_MII_AN_STS_C37_ANCMPLT_INTR; | |
| 1074 | + | |
| 1072 | 1075 | if (ret & DW_VR_MII_C37_ANSGM_SP_LNKSTS) { |
| 1073 | 1076 | int speed_value; |
| 1074 | 1077 | |
| @@ -1086,34 +1089,13 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs, · 11 unmodified lines | ||
| 1086 | 1089 | state->duplex = DUPLEX_FULL; |
| 1087 | 1090 | else |
| 1088 | 1091 | state->duplex = DUPLEX_HALF; |
| 1089 | − } else if (ret == DW_VR_MII_AN_STS_C37_ANCMPLT_INTR) { | |
| 1090 | − int speed, duplex; | |
| 1091 | − | |
| 1092 | − state->link = true; | |
| 1093 | − | |
| 1094 | − speed = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_BMCR); | |
| 1095 | − if (speed < 0) | |
| 1096 | − return speed; | |
| 1097 | − | |
| 1098 | − speed &= BMCR_SPEED100 | BMCR_SPEED1000; | |
| 1099 | − if (speed == BMCR_SPEED1000) | |
| 1100 | − state->speed = SPEED_1000; | |
| 1101 | − else if (speed == BMCR_SPEED100) | |
| 1102 | − state->speed = SPEED_100; | |
| 1103 | − else if (speed == 0) | |
| 1104 | − state->speed = SPEED_10; | |
| 1105 | − | |
| 1106 | − duplex = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_ADVERTISE); | |
| 1107 | − if (duplex < 0) | |
| 1108 | − return duplex; | |
| 1109 | 1092 | |
| 1110 | − if (duplex & ADVERTISE_1000XFULL) | |
| 1111 | − state->duplex = DUPLEX_FULL; | |
| 1112 | − else if (duplex & ADVERTISE_1000XHALF) | |
| 1113 | − state->duplex = DUPLEX_HALF; | |
| 1093 | + return 0; | |
| 1094 | + } | |
| 1114 | 1095 | |
| 1096 | + /* Clear AN complete status or interrupt */ | |
| 1097 | + if (state->an_complete) | |
| 1115 | 1098 | xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0); |
| 1116 | − } | |
| 1117 | 1099 | |
| 1118 | 1100 | return 0; |
| 1119 | 1101 | } |
| @@ -753,7 +753,7 @@ static int m88e1111_config_inband(struct phy_device *phydev, unsigned int modes) · 752 unmodified lines | ||
| 753 | 753 | err = phy_modify(phydev, MII_M1111_PHY_EXT_SR, |
| 754 | 754 | MII_M1111_HWCFG_SERIAL_AN_BYPASS, extsr); |
| 755 | 755 | if (err < 0) |
| 756 | − return extsr; | |
| 756 | + return err; | |
| 757 | 757 | |
| 758 | 758 | return phy_modify_paged(phydev, MII_MARVELL_FIBER_PAGE, MII_BMCR, |
| 759 | 759 | BMCR_ANENABLE, bmcr); |
| @@ -810,7 +810,9 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 809 unmodified lines | ||
| 810 | 810 | case PPPIOCSMRU: |
| 811 | 811 | if (get_user(val, p)) |
| 812 | 812 | break; |
| 813 | + ppp_recv_lock(ppp); | |
| 813 | 814 | ppp->mru = val; |
| 815 | + ppp_recv_unlock(ppp); | |
| 814 | 816 | err = 0; |
| 815 | 817 | break; |
| 816 | 818 | |
| @@ -831,7 +833,9 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 14 unmodified lines | ||
| 831 | 833 | break; |
| 832 | 834 | |
| 833 | 835 | case PPPIOCGFLAGS: |
| 836 | + ppp_lock(ppp); | |
| 834 | 837 | val = ppp->flags | ppp->xstate | ppp->rstate; |
| 838 | + ppp_unlock(ppp); | |
| 835 | 839 | if (put_user(val, p)) |
| 836 | 840 | break; |
| 837 | 841 | err = 0; |
| @@ -855,7 +859,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 17 unmodified lines | ||
| 855 | 859 | case PPPIOCSDEBUG: |
| 856 | 860 | if (get_user(val, p)) |
| 857 | 861 | break; |
| 858 | − ppp->debug = val; | |
| 862 | + WRITE_ONCE(ppp->debug, val); | |
| 859 | 863 | err = 0; |
| 860 | 864 | break; |
| 861 | 865 | |
| @@ -866,16 +870,16 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 4 unmodified lines | ||
| 866 | 870 | break; |
| 867 | 871 | |
| 868 | 872 | case PPPIOCGIDLE32: |
| 869 | − idle32.xmit_idle = (jiffies - ppp->last_xmit) / HZ; | |
| 870 | − idle32.recv_idle = (jiffies - ppp->last_recv) / HZ; | |
| 871 | − if (copy_to_user(argp, &idle32, sizeof(idle32))) | |
| 873 | + idle32.xmit_idle = max(0L, (long)(jiffies - READ_ONCE(ppp->last_xmit))) / HZ; | |
| 874 | + idle32.recv_idle = max(0L, (long)(jiffies - READ_ONCE(ppp->last_recv))) / HZ; | |
| 875 | + if (copy_to_user(argp, &idle32, sizeof(idle32))) | |
| 872 | 876 | break; |
| 873 | 877 | err = 0; |
| 874 | 878 | break; |
| 875 | 879 | |
| 876 | 880 | case PPPIOCGIDLE64: |
| 877 | − idle64.xmit_idle = (jiffies - ppp->last_xmit) / HZ; | |
| 878 | − idle64.recv_idle = (jiffies - ppp->last_recv) / HZ; | |
| 881 | + idle64.xmit_idle = max(0L, (long)(jiffies - READ_ONCE(ppp->last_xmit))) / HZ; | |
| 882 | + idle64.recv_idle = max(0L, (long)(jiffies - READ_ONCE(ppp->last_recv))) / HZ; | |
| 879 | 883 | if (copy_to_user(argp, &idle64, sizeof(idle64))) |
| 880 | 884 | break; |
| 881 | 885 | err = 0; |
| @@ -916,7 +920,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 34 unmodified lines | ||
| 916 | 920 | if (copy_to_user(argp, &npi, sizeof(npi))) |
| 917 | 921 | break; |
| 918 | 922 | } else { |
| 919 | − ppp->npmode[i] = npi.mode; | |
| 923 | + WRITE_ONCE(ppp->npmode[i], npi.mode); | |
| 920 | 924 | /* we may be able to transmit more packets now (??) */ |
| 921 | 925 | netif_wake_queue(ppp->dev); |
| 922 | 926 | } |
| @@ -1454,7 +1458,7 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev) · 531 unmodified lines | ||
| 1454 | 1458 | goto outf; |
| 1455 | 1459 | |
| 1456 | 1460 | /* Drop, accept or reject the packet */ |
| 1457 | − switch (ppp->npmode[npi]) { | |
| 1461 | + switch (READ_ONCE(ppp->npmode[npi])) { | |
| 1458 | 1462 | case NPMODE_PASS: |
| 1459 | 1463 | break; |
| 1460 | 1464 | case NPMODE_QUEUE: |
| @@ -1482,7 +1486,7 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev) · 21 unmodified lines | ||
| 1482 | 1486 | |
| 1483 | 1487 | outf: |
| 1484 | 1488 | kfree_skb(skb); |
| 1485 | − ++dev->stats.tx_dropped; | |
| 1489 | + DEV_STATS_INC(dev, tx_dropped); | |
| 1486 | 1490 | return NETDEV_TX_OK; |
| 1487 | 1491 | } |
| 1488 | 1492 | |
| @@ -1532,11 +1536,11 @@ ppp_net_siocdevprivate(struct net_device *dev, struct ifreq *ifr, · 43 unmodified lines | ||
| 1532 | 1536 | static void |
| 1533 | 1537 | ppp_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats64) |
| 1534 | 1538 | { |
| 1535 | − stats64->rx_errors = dev->stats.rx_errors; | |
| 1536 | − stats64->tx_errors = dev->stats.tx_errors; | |
| 1537 | − stats64->rx_dropped = dev->stats.rx_dropped; | |
| 1538 | − stats64->tx_dropped = dev->stats.tx_dropped; | |
| 1539 | − stats64->rx_length_errors = dev->stats.rx_length_errors; | |
| 1539 | + stats64->rx_errors = DEV_STATS_READ(dev, rx_errors); | |
| 1540 | + stats64->tx_errors = DEV_STATS_READ(dev, tx_errors); | |
| 1541 | + stats64->rx_dropped = DEV_STATS_READ(dev, rx_dropped); | |
| 1542 | + stats64->tx_dropped = DEV_STATS_READ(dev, tx_dropped); | |
| 1543 | + stats64->rx_length_errors = DEV_STATS_READ(dev, rx_length_errors); | |
| 1540 | 1544 | dev_fetch_sw_netstats(stats64, dev->tstats); |
| 1541 | 1545 | } |
| 1542 | 1546 | |
| @@ -1790,7 +1794,7 @@ ppp_prepare_tx_skb(struct ppp *ppp, struct sk_buff **pskb) · 247 unmodified lines | ||
| 1790 | 1794 | *(__be16 *)skb_push(skb, 2) = htons(PPP_FILTER_OUTBOUND_TAG); |
| 1791 | 1795 | if (ppp->pass_filter && |
| 1792 | 1796 | bpf_prog_run(ppp->pass_filter, skb) == 0) { |
| 1793 | − if (ppp->debug & 1) | |
| 1797 | + if (READ_ONCE(ppp->debug) & 1) | |
| 1794 | 1798 | netdev_printk(KERN_DEBUG, ppp->dev, |
| 1795 | 1799 | "PPP: outbound frame " |
| 1796 | 1800 | "not passed\n"); |
| @@ -1800,11 +1804,11 @@ ppp_prepare_tx_skb(struct ppp *ppp, struct sk_buff **pskb) · 3 unmodified lines | ||
| 1800 | 1804 | /* if this packet passes the active filter, record the time */ |
| 1801 | 1805 | if (!(ppp->active_filter && |
| 1802 | 1806 | bpf_prog_run(ppp->active_filter, skb) == 0)) |
| 1803 | − ppp->last_xmit = jiffies; | |
| 1807 | + WRITE_ONCE(ppp->last_xmit, jiffies); | |
| 1804 | 1808 | skb_pull(skb, 2); |
| 1805 | 1809 | #else |
| 1806 | 1810 | /* for data packets, record the time */ |
| 1807 | − ppp->last_xmit = jiffies; | |
| 1811 | + WRITE_ONCE(ppp->last_xmit, jiffies); | |
| 1808 | 1812 | #endif /* CONFIG_PPP_FILTER */ |
| 1809 | 1813 | } |
| 1810 | 1814 | |
| @@ -1889,7 +1893,7 @@ ppp_prepare_tx_skb(struct ppp *ppp, struct sk_buff **pskb) · 78 unmodified lines | ||
| 1889 | 1893 | |
| 1890 | 1894 | drop: |
| 1891 | 1895 | kfree_skb(skb); |
| 1892 | − ++ppp->dev->stats.tx_errors; | |
| 1896 | + DEV_STATS_INC(ppp->dev, tx_errors); | |
| 1893 | 1897 | return 1; |
| 1894 | 1898 | } |
| 1895 | 1899 | |
| @@ -2154,9 +2158,9 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb) · 258 unmodified lines | ||
| 2154 | 2158 | noskb: |
| 2155 | 2159 | spin_unlock(&pch->downl); |
| 2156 | 2160 | err_linearize: |
| 2157 | − if (ppp->debug & 1) | |
| 2161 | + if (READ_ONCE(ppp->debug) & 1) | |
| 2158 | 2162 | netdev_err(ppp->dev, "PPP: no memory (fragment)\n"); |
| 2159 | − ++ppp->dev->stats.tx_errors; | |
| 2163 | + DEV_STATS_INC(ppp->dev, tx_errors); | |
| 2160 | 2164 | ++ppp->nxseq; |
| 2161 | 2165 | return 1; /* abandon the frame */ |
| 2162 | 2166 | } |
| @@ -2329,7 +2333,7 @@ ppp_input(struct ppp_channel *chan, struct sk_buff *skb) · 166 unmodified lines | ||
| 2329 | 2333 | if (!ppp_decompress_proto(skb)) { |
| 2330 | 2334 | kfree_skb(skb); |
| 2331 | 2335 | if (ppp) { |
| 2332 | − ++ppp->dev->stats.rx_length_errors; | |
| 2336 | + DEV_STATS_INC(ppp->dev, rx_length_errors); | |
| 2333 | 2337 | ppp_receive_error(ppp); |
| 2334 | 2338 | } |
| 2335 | 2339 | goto done; |
| @@ -2391,7 +2395,7 @@ ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) · 55 unmodified lines | ||
| 2391 | 2395 | static void |
| 2392 | 2396 | ppp_receive_error(struct ppp *ppp) |
| 2393 | 2397 | { |
| 2394 | − ++ppp->dev->stats.rx_errors; | |
| 2398 | + DEV_STATS_INC(ppp->dev, rx_errors); | |
| 2395 | 2399 | if (ppp->vj) |
| 2396 | 2400 | slhc_toss(ppp->vj); |
| 2397 | 2401 | } |
| @@ -2502,7 +2506,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb) · 104 unmodified lines | ||
| 2502 | 2506 | *(__be16 *)skb_push(skb, 2) = htons(PPP_FILTER_INBOUND_TAG); |
| 2503 | 2507 | if (ppp->pass_filter && |
| 2504 | 2508 | bpf_prog_run(ppp->pass_filter, skb) == 0) { |
| 2505 | − if (ppp->debug & 1) | |
| 2509 | + if (READ_ONCE(ppp->debug) & 1) | |
| 2506 | 2510 | netdev_printk(KERN_DEBUG, ppp->dev, |
| 2507 | 2511 | "PPP: inbound frame " |
| 2508 | 2512 | "not passed\n"); |
| @@ -2511,14 +2515,14 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb) · 2 unmodified lines | ||
| 2511 | 2515 | } |
| 2512 | 2516 | if (!(ppp->active_filter && |
| 2513 | 2517 | bpf_prog_run(ppp->active_filter, skb) == 0)) |
| 2514 | − ppp->last_recv = jiffies; | |
| 2518 | + WRITE_ONCE(ppp->last_recv, jiffies); | |
| 2515 | 2519 | __skb_pull(skb, 2); |
| 2516 | 2520 | } else |
| 2517 | 2521 | #endif /* CONFIG_PPP_FILTER */ |
| 2518 | − ppp->last_recv = jiffies; | |
| 2522 | + WRITE_ONCE(ppp->last_recv, jiffies); | |
| 2519 | 2523 | |
| 2520 | 2524 | if ((ppp->dev->flags & IFF_UP) == 0 || |
| 2521 | − ppp->npmode[npi] != NPMODE_PASS) { | |
| 2525 | + READ_ONCE(ppp->npmode[npi]) != NPMODE_PASS) { | |
| 2522 | 2526 | kfree_skb(skb); |
| 2523 | 2527 | } else { |
| 2524 | 2528 | /* chop off protocol */ |
| @@ -2658,7 +2662,7 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) · 133 unmodified lines | ||
| 2658 | 2662 | */ |
| 2659 | 2663 | if (seq_before(seq, ppp->nextseq)) { |
| 2660 | 2664 | kfree_skb(skb); |
| 2661 | − ++ppp->dev->stats.rx_dropped; | |
| 2665 | + DEV_STATS_INC(ppp->dev, rx_dropped); | |
| 2662 | 2666 | ppp_receive_error(ppp); |
| 2663 | 2667 | return; |
| 2664 | 2668 | } |
| @@ -2694,7 +2698,7 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) · 29 unmodified lines | ||
| 2694 | 2698 | if (pskb_may_pull(skb, 2)) |
| 2695 | 2699 | ppp_receive_nonmp_frame(ppp, skb); |
| 2696 | 2700 | else { |
| 2697 | − ++ppp->dev->stats.rx_length_errors; | |
| 2701 | + DEV_STATS_INC(ppp->dev, rx_length_errors); | |
| 2698 | 2702 | kfree_skb(skb); |
| 2699 | 2703 | ppp_receive_error(ppp); |
| 2700 | 2704 | } |
| @@ -2771,7 +2775,7 @@ ppp_mp_reconstruct(struct ppp *ppp) · 70 unmodified lines | ||
| 2771 | 2775 | seq = seq_before(minseq, PPP_MP_CB(p)->sequence)? |
| 2772 | 2776 | minseq + 1: PPP_MP_CB(p)->sequence; |
| 2773 | 2777 | |
| 2774 | − if (ppp->debug & 1) | |
| 2778 | + if (READ_ONCE(ppp->debug) & 1) | |
| 2775 | 2779 | netdev_printk(KERN_DEBUG, ppp->dev, |
| 2776 | 2780 | "lost frag %u..%u\n", |
| 2777 | 2781 | oldseq, seq-1); |
| @@ -2800,7 +2804,7 @@ ppp_mp_reconstruct(struct ppp *ppp) · 22 unmodified lines | ||
| 2800 | 2804 | if (lost == 0 && (PPP_MP_CB(p)->BEbits & E) && |
| 2801 | 2805 | (PPP_MP_CB(head)->BEbits & B)) { |
| 2802 | 2806 | if (len > ppp->mrru + 2) { |
| 2803 | − ++ppp->dev->stats.rx_length_errors; | |
| 2807 | + DEV_STATS_INC(ppp->dev, rx_length_errors); | |
| 2804 | 2808 | netdev_printk(KERN_DEBUG, ppp->dev, |
| 2805 | 2809 | "PPP: reconstructed packet" |
| 2806 | 2810 | " is too long (%d)\n", len); |
| @@ -2820,7 +2824,7 @@ ppp_mp_reconstruct(struct ppp *ppp) · 13 unmodified lines | ||
| 2820 | 2824 | struct sk_buff *tmp2; |
| 2821 | 2825 | |
| 2822 | 2826 | skb_queue_reverse_walk_from_safe(list, p, tmp2) { |
| 2823 | − if (ppp->debug & 1) | |
| 2827 | + if (READ_ONCE(ppp->debug) & 1) | |
| 2824 | 2828 | netdev_printk(KERN_DEBUG, ppp->dev, |
| 2825 | 2829 | "discarding frag %u\n", |
| 2826 | 2830 | PPP_MP_CB(p)->sequence); |
| @@ -2842,7 +2846,7 @@ ppp_mp_reconstruct(struct ppp *ppp) · 15 unmodified lines | ||
| 2842 | 2846 | skb_queue_walk_safe(list, p, tmp) { |
| 2843 | 2847 | if (p == head) |
| 2844 | 2848 | break; |
| 2845 | − if (ppp->debug & 1) | |
| 2849 | + if (READ_ONCE(ppp->debug) & 1) | |
| 2846 | 2850 | netdev_printk(KERN_DEBUG, ppp->dev, |
| 2847 | 2851 | "discarding frag %u\n", |
| 2848 | 2852 | PPP_MP_CB(p)->sequence); |
| @@ -2850,12 +2854,12 @@ ppp_mp_reconstruct(struct ppp *ppp) · 1 unmodified line | ||
| 2850 | 2854 | kfree_skb(p); |
| 2851 | 2855 | } |
| 2852 | 2856 | |
| 2853 | − if (ppp->debug & 1) | |
| 2857 | + if (READ_ONCE(ppp->debug) & 1) | |
| 2854 | 2858 | netdev_printk(KERN_DEBUG, ppp->dev, |
| 2855 | 2859 | " missed pkts %u..%u\n", |
| 2856 | 2860 | ppp->nextseq, |
| 2857 | 2861 | PPP_MP_CB(head)->sequence-1); |
| 2858 | − ++ppp->dev->stats.rx_dropped; | |
| 2862 | + DEV_STATS_INC(ppp->dev, rx_dropped); | |
| 2859 | 2863 | ppp_receive_error(ppp); |
| 2860 | 2864 | } |
| 2861 | 2865 | |
| @@ -3161,7 +3165,8 @@ ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound) · 299 unmodified lines | ||
| 3161 | 3165 | if (!ppp->rc_state) |
| 3162 | 3166 | break; |
| 3163 | 3167 | if (ppp->rcomp->decomp_init(ppp->rc_state, dp, len, |
| 3164 | − ppp->file.index, 0, ppp->mru, ppp->debug)) { | |
| 3168 | + ppp->file.index, 0, ppp->mru, | |
| 3169 | + READ_ONCE(ppp->debug))) { | |
| 3165 | 3170 | ppp->rstate |= SC_DECOMP_RUN; |
| 3166 | 3171 | ppp->rstate &= ~(SC_DC_ERROR | SC_DC_FERROR); |
| 3167 | 3172 | } |
| @@ -3170,7 +3175,8 @@ ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound) · 2 unmodified lines | ||
| 3170 | 3175 | if (!ppp->xc_state) |
| 3171 | 3176 | break; |
| 3172 | 3177 | if (ppp->xcomp->comp_init(ppp->xc_state, dp, len, |
| 3173 | − ppp->file.index, 0, ppp->debug)) | |
| 3178 | + ppp->file.index, 0, | |
| 3179 | + READ_ONCE(ppp->debug))) | |
| 3174 | 3180 | ppp->xstate |= SC_COMP_RUN; |
| 3175 | 3181 | } |
| 3176 | 3182 | break; |
| @@ -3322,8 +3328,8 @@ ppp_get_stats(struct ppp *ppp, struct ppp_stats *st) · 145 unmodified lines | ||
| 3322 | 3328 | st->p.ppp_opackets += tx_packets; |
| 3323 | 3329 | st->p.ppp_obytes += tx_bytes; |
| 3324 | 3330 | } |
| 3325 | − st->p.ppp_ierrors = ppp->dev->stats.rx_errors; | |
| 3326 | − st->p.ppp_oerrors = ppp->dev->stats.tx_errors; | |
| 3331 | + st->p.ppp_ierrors = DEV_STATS_READ(ppp->dev, rx_errors); | |
| 3332 | + st->p.ppp_oerrors = DEV_STATS_READ(ppp->dev, tx_errors); | |
| 3327 | 3333 | if (!vj) |
| 3328 | 3334 | return; |
| 3329 | 3335 | st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed; |
| @@ -825,6 +825,7 @@ static int pppoe_sendmsg(struct socket *sock, struct msghdr *m, · 824 unmodified lines | ||
| 825 | 825 | dev_hard_header(skb, dev, ETH_P_PPP_SES, |
| 826 | 826 | po->pppoe_pa.remote, NULL, total_len); |
| 827 | 827 | |
| 828 | + ph = pppoe_hdr(skb); | |
| 828 | 829 | memcpy(ph, &hdr, sizeof(struct pppoe_hdr)); |
| 829 | 830 | |
| 830 | 831 | ph->length = htons(total_len); |
| @@ -693,6 +693,8 @@ static void slip_receive_buf(struct tty_struct *tty, const u8 *cp, const u8 *fp, · 692 unmodified lines | ||
| 693 | 693 | if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) |
| 694 | 694 | return; |
| 695 | 695 | |
| 696 | + spin_lock_bh(&sl->lock); | |
| 697 | + | |
| 696 | 698 | /* Read the characters out of the buffer */ |
| 697 | 699 | while (count--) { |
| 698 | 700 | if (fp && *fp++) { |
| @@ -708,6 +710,8 @@ static void slip_receive_buf(struct tty_struct *tty, const u8 *cp, const u8 *fp, · 9 unmodified lines | ||
| 708 | 710 | #endif |
| 709 | 711 | slip_unesc(sl, *cp++); |
| 710 | 712 | } |
| 713 | + | |
| 714 | + spin_unlock_bh(&sl->lock); | |
| 711 | 715 | } |
| 712 | 716 | |
| 713 | 717 | /************************************ |
| @@ -1530,7 +1530,11 @@ vmxnet3_get_hdr_len(struct vmxnet3_adapter *adapter, struct sk_buff *skb, · 1529 unmodified lines | ||
| 1530 | 1530 | struct ipv6hdr *ipv6; |
| 1531 | 1531 | struct tcphdr *tcp; |
| 1532 | 1532 | } hdr; |
| 1533 | − BUG_ON(gdesc->rcd.tcp == 0); | |
| 1533 | + | |
| 1534 | + /* v4/v6/tcp then describe the inner header, which we can't locate. */ | |
| 1535 | + if ((le32_to_cpu(gdesc->dword[0]) & (1UL << VMXNET3_RCD_HDR_INNER_SHIFT)) || | |
| 1536 | + gdesc->rcd.tcp == 0) | |
| 1537 | + return 0; | |
| 1534 | 1538 | |
| 1535 | 1539 | maplen = skb_headlen(skb); |
| 1536 | 1540 | if (unlikely(sizeof(struct iphdr) + sizeof(struct tcphdr) > maplen)) |
| @@ -1544,15 +1548,21 @@ vmxnet3_get_hdr_len(struct vmxnet3_adapter *adapter, struct sk_buff *skb, · 7 unmodified lines | ||
| 1544 | 1548 | |
| 1545 | 1549 | hdr.eth = eth_hdr(skb); |
| 1546 | 1550 | if (gdesc->rcd.v4) { |
| 1547 | − BUG_ON(hdr.eth->h_proto != htons(ETH_P_IP) && | |
| 1548 | − hdr.veth->h_vlan_encapsulated_proto != htons(ETH_P_IP)); | |
| 1551 | + if (hdr.eth->h_proto != htons(ETH_P_IP) && | |
| 1552 | + hdr.veth->h_vlan_encapsulated_proto != htons(ETH_P_IP)) | |
| 1553 | + return 0; | |
| 1554 | + | |
| 1549 | 1555 | hdr.ptr += hlen; |
| 1550 | − BUG_ON(hdr.ipv4->protocol != IPPROTO_TCP); | |
| 1556 | + if (hdr.ipv4->protocol != IPPROTO_TCP) | |
| 1557 | + return 0; | |
| 1558 | + | |
| 1551 | 1559 | hlen = hdr.ipv4->ihl << 2; |
| 1552 | 1560 | hdr.ptr += hdr.ipv4->ihl << 2; |
| 1553 | 1561 | } else if (gdesc->rcd.v6) { |
| 1554 | − BUG_ON(hdr.eth->h_proto != htons(ETH_P_IPV6) && | |
| 1555 | − hdr.veth->h_vlan_encapsulated_proto != htons(ETH_P_IPV6)); | |
| 1562 | + if (hdr.eth->h_proto != htons(ETH_P_IPV6) && | |
| 1563 | + hdr.veth->h_vlan_encapsulated_proto != htons(ETH_P_IPV6)) | |
| 1564 | + return 0; | |
| 1565 | + | |
| 1556 | 1566 | hdr.ptr += hlen; |
| 1557 | 1567 | /* Use an estimated value, since we also need to handle |
| 1558 | 1568 | * TSO case. |
| @@ -4421,6 +4421,9 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], · 4420 unmodified lines | ||
| 4421 | 4421 | struct vxlan_rdst *dst; |
| 4422 | 4422 | int err; |
| 4423 | 4423 | |
| 4424 | + if (!rtnl_dev_link_net_capable(dev, vxlan->net)) | |
| 4425 | + return -EPERM; | |
| 4426 | + | |
| 4424 | 4427 | dst = &vxlan->default_dst; |
| 4425 | 4428 | err = vxlan_nl2conf(tb, data, dev, &conf, true, extack); |
| 4426 | 4429 | if (err) |
| @@ -42,6 +42,7 @@ struct vxlan_mdb_remote { · 41 unmodified lines | ||
| 42 | 42 | }; |
| 43 | 43 | |
| 44 | 44 | #define VXLAN_SGRP_F_DELETE BIT(0) |
| 45 | +#define VXLAN_SGRP_F_NEW BIT(1) | |
| 45 | 46 | |
| 46 | 47 | struct vxlan_mdb_src_entry { |
| 47 | 48 | struct hlist_node node; |
| @@ -844,6 +845,7 @@ vxlan_mdb_remote_src_add(const struct vxlan_mdb_config *cfg, · 796 unmodified lines | ||
| 844 | 845 | ent = vxlan_mdb_remote_src_entry_add(remote, &src->addr); |
| 845 | 846 | if (!ent) |
| 846 | 847 | return -ENOMEM; |
| 848 | + ent->flags |= VXLAN_SGRP_F_NEW; | |
| 847 | 849 | } else if (!(cfg->nlflags & NLM_F_REPLACE)) { |
| 848 | 850 | NL_SET_ERR_MSG_MOD(extack, "Source entry already exists"); |
| 849 | 851 | return -EEXIST; |
| @@ -853,15 +855,16 @@ vxlan_mdb_remote_src_add(const struct vxlan_mdb_config *cfg, · 3 unmodified lines | ||
| 853 | 855 | if (err) |
| 854 | 856 | goto err_src_del; |
| 855 | 857 | |
| 856 | − /* Clear flags in case source entry was marked for deletion as part of | |
| 857 | − * replace flow. | |
| 858 | + /* Clear the deletion mark so the entry survives the replace sweep. | |
| 859 | + * The new mark is retained until the whole operation succeeds. | |
| 858 | 860 | */ |
| 859 | − ent->flags = 0; | |
| 861 | + ent->flags &= ~VXLAN_SGRP_F_DELETE; | |
| 860 | 862 | |
| 861 | 863 | return 0; |
| 862 | 864 | |
| 863 | 865 | err_src_del: |
| 864 | − vxlan_mdb_remote_src_entry_del(ent); | |
| 866 | + if (ent->flags & VXLAN_SGRP_F_NEW) | |
| 867 | + vxlan_mdb_remote_src_entry_del(ent); | |
| 865 | 868 | return err; |
| 866 | 869 | } |
| 867 | 870 | |
| @@ -889,11 +892,19 @@ static int vxlan_mdb_remote_srcs_add(const struct vxlan_mdb_config *cfg, · 21 unmodified lines | ||
| 889 | 892 | goto err_src_del; |
| 890 | 893 | } |
| 891 | 894 | |
| 895 | + hlist_for_each_entry(ent, &remote->src_list, node) | |
| 896 | + ent->flags &= ~VXLAN_SGRP_F_NEW; | |
| 897 | + | |
| 892 | 898 | return 0; |
| 893 | 899 | |
| 894 | 900 | err_src_del: |
| 895 | − hlist_for_each_entry_safe(ent, tmp, &remote->src_list, node) | |
| 896 | − vxlan_mdb_remote_src_del(cfg->vxlan, &cfg->group, remote, ent); | |
| 901 | + hlist_for_each_entry_safe(ent, tmp, &remote->src_list, node) { | |
| 902 | + if (ent->flags & VXLAN_SGRP_F_NEW) | |
| 903 | + vxlan_mdb_remote_src_del(cfg->vxlan, &cfg->group, remote, | |
| 904 | + ent); | |
| 905 | + else | |
| 906 | + ent->flags &= ~VXLAN_SGRP_F_DELETE; | |
| 907 | + } | |
| 897 | 908 | return err; |
| 898 | 909 | } |
| 899 | 910 | |
| @@ -1069,7 +1080,7 @@ vxlan_mdb_remote_srcs_replace(const struct vxlan_mdb_config *cfg, · 169 unmodified lines | ||
| 1069 | 1080 | |
| 1070 | 1081 | err = vxlan_mdb_remote_srcs_add(cfg, remote, extack); |
| 1071 | 1082 | if (err) |
| 1072 | − goto err_clear_delete; | |
| 1083 | + return err; | |
| 1073 | 1084 | |
| 1074 | 1085 | hlist_for_each_entry_safe(ent, tmp, &remote->src_list, node) { |
| 1075 | 1086 | if (ent->flags & VXLAN_SGRP_F_DELETE) |
| @@ -1078,11 +1089,6 @@ vxlan_mdb_remote_srcs_replace(const struct vxlan_mdb_config *cfg, · 2 unmodified lines | ||
| 1078 | 1089 | } |
| 1079 | 1090 | |
| 1080 | 1091 | return 0; |
| 1081 | − | |
| 1082 | −err_clear_delete: | |
| 1083 | − hlist_for_each_entry(ent, &remote->src_list, node) | |
| 1084 | − ent->flags &= ~VXLAN_SGRP_F_DELETE; | |
| 1085 | − return err; | |
| 1086 | 1092 | } |
| 1087 | 1093 | |
| 1088 | 1094 | static int vxlan_mdb_remote_replace(const struct vxlan_mdb_config *cfg, |
| @@ -514,7 +514,8 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev) · 513 unmodified lines | ||
| 514 | 514 | if (card->irq) |
| 515 | 515 | free_irq(card->irq, card); |
| 516 | 516 | |
| 517 | − wanxl_reset(card); | |
| 517 | + if (card->plx) | |
| 518 | + wanxl_reset(card); | |
| 518 | 519 | |
| 519 | 520 | for (i = 0; i < RX_QUEUE_LENGTH; i++) |
| 520 | 521 | if (card->rx_skbs[i]) { |
| @@ -706,6 +706,7 @@ static int ath10k_htt_rx_pop_paddr32_list(struct ath10k_htt *htt, · 705 unmodified lines | ||
| 706 | 706 | if (!(__le32_to_cpu(rxd_attention->flags) & |
| 707 | 707 | RX_ATTENTION_FLAGS_MSDU_DONE)) { |
| 708 | 708 | ath10k_warn(htt->ar, "tried to pop an incomplete frame, oops!\n"); |
| 709 | + __skb_queue_purge(list); | |
| 709 | 710 | return -EIO; |
| 710 | 711 | } |
| 711 | 712 | } |
| @@ -770,6 +771,7 @@ static int ath10k_htt_rx_pop_paddr64_list(struct ath10k_htt *htt, · 58 unmodified lines | ||
| 770 | 771 | if (!(__le32_to_cpu(rxd_attention->flags) & |
| 771 | 772 | RX_ATTENTION_FLAGS_MSDU_DONE)) { |
| 772 | 773 | ath10k_warn(htt->ar, "tried to pop an incomplete frame, oops!\n"); |
| 774 | + __skb_queue_purge(list); | |
| 773 | 775 | return -EIO; |
| 774 | 776 | } |
| 775 | 777 | } |
| @@ -996,6 +996,7 @@ static int ath11k_ahb_fw_resources_init(struct ath11k_base *ab) · 995 unmodified lines | ||
| 996 | 996 | ret = ath11k_ahb_setup_msa_resources(ab); |
| 997 | 997 | if (ret) { |
| 998 | 998 | ath11k_err(ab, "failed to setup msa resources\n"); |
| 999 | + of_node_put(node); | |
| 999 | 1000 | return ret; |
| 1000 | 1001 | } |
| 1001 | 1002 | |
| @@ -4618,6 +4618,9 @@ static void ath11k_hal_rx_msdu_list_get(struct ath11k *ar, · 4617 unmodified lines | ||
| 4618 | 4618 | msdu_details = &msdu_link->msdu_link[0]; |
| 4619 | 4619 | |
| 4620 | 4620 | for (i = 0; i < HAL_RX_NUM_MSDU_DESC; i++) { |
| 4621 | + if (!i && FIELD_GET(BUFFER_ADDR_INFO0_ADDR, | |
| 4622 | + msdu_details[i].buf_addr_info.info0) == 0) | |
| 4623 | + break; | |
| 4621 | 4624 | if (FIELD_GET(BUFFER_ADDR_INFO0_ADDR, |
| 4622 | 4625 | msdu_details[i].buf_addr_info.info0) == 0) { |
| 4623 | 4626 | msdu_desc_info = &msdu_details[i - 1].rx_msdu_info; |
| @@ -199,6 +199,8 @@ static void ath11k_pci_soc_global_reset(struct ath11k_base *ab) · 198 unmodified lines | ||
| 199 | 199 | val |= PCIE_SOC_GLOBAL_RESET_V; |
| 200 | 200 | |
| 201 | 201 | ath11k_pcic_write32(ab, PCIE_SOC_GLOBAL_RESET, val); |
| 202 | + /* Flush the posted write to the device */ | |
| 203 | + ath11k_pcic_read32(ab, PCIE_SOC_GLOBAL_RESET); | |
| 202 | 204 | |
| 203 | 205 | /* TODO: exact time to sleep is uncertain */ |
| 204 | 206 | delay = 10; |
| @@ -208,6 +210,8 @@ static void ath11k_pci_soc_global_reset(struct ath11k_base *ab) · 3 unmodified lines | ||
| 208 | 210 | val &= ~PCIE_SOC_GLOBAL_RESET_V; |
| 209 | 211 | |
| 210 | 212 | ath11k_pcic_write32(ab, PCIE_SOC_GLOBAL_RESET, val); |
| 213 | + /* Flush the posted write to the device */ | |
| 214 | + ath11k_pcic_read32(ab, PCIE_SOC_GLOBAL_RESET); | |
| 211 | 215 | |
| 212 | 216 | mdelay(delay); |
| 213 | 217 | |
| @@ -3294,9 +3294,14 @@ static void ath11k_qmi_driver_event_work(struct work_struct *work) · 3293 unmodified lines | ||
| 3294 | 3294 | clear_bit(ATH11K_FLAG_CRASH_FLUSH, |
| 3295 | 3295 | &ab->dev_flags); |
| 3296 | 3296 | clear_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags); |
| 3297 | − ath11k_core_qmi_firmware_ready(ab); | |
| 3298 | − set_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags); | |
| 3299 | − | |
| 3297 | + if (!test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) { | |
| 3298 | + ret = ath11k_core_qmi_firmware_ready(ab); | |
| 3299 | + if (ret) { | |
| 3300 | + set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); | |
| 3301 | + break; | |
| 3302 | + } | |
| 3303 | + set_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags); | |
| 3304 | + } | |
| 3300 | 3305 | break; |
| 3301 | 3306 | case ATH11K_QMI_EVENT_COLD_BOOT_CAL_DONE: |
| 3302 | 3307 | break; |
| @@ -274,11 +274,14 @@ int ath12k_dp_link_peer_rhash_tbl_init(struct ath12k_dp *dp) · 273 unmodified lines | ||
| 274 | 274 | |
| 275 | 275 | void ath12k_dp_link_peer_rhash_tbl_destroy(struct ath12k_dp *dp) |
| 276 | 276 | { |
| 277 | − mutex_lock(&dp->link_peer_rhash_tbl_lock); | |
| 277 | + guard(mutex)(&dp->link_peer_rhash_tbl_lock); | |
| 278 | + | |
| 279 | + if (!dp->rhead_peer_addr) | |
| 280 | + return; | |
| 281 | + | |
| 278 | 282 | rhashtable_destroy(dp->rhead_peer_addr); |
| 279 | 283 | kfree(dp->rhead_peer_addr); |
| 280 | 284 | dp->rhead_peer_addr = NULL; |
| 281 | − mutex_unlock(&dp->link_peer_rhash_tbl_lock); | |
| 282 | 285 | } |
| 283 | 286 | |
| 284 | 287 | static int ath12k_dp_link_peer_rhash_insert(struct ath12k_dp *dp, |
| @@ -570,6 +573,8 @@ int ath12k_dp_link_peer_assign(struct ath12k_dp *dp, struct ath12k_dp_hw *dp_hw, · 285 unmodified lines | ||
| 570 | 573 | peerid_index = ath12k_dp_peer_get_peerid_index(dp, peer->peer_id); |
| 571 | 574 | |
| 572 | 575 | rcu_assign_pointer(dp_peer->link_peers[peer->link_id], peer); |
| 576 | + WRITE_ONCE(dp_peer->link_peers_map, | |
| 577 | + READ_ONCE(dp_peer->link_peers_map) | BIT(peer->link_id)); | |
| 573 | 578 | |
| 574 | 579 | rcu_assign_pointer(dp_hw->dp_peers[peerid_index], dp_peer); |
| 575 | 580 | |
| @@ -632,6 +637,8 @@ void ath12k_dp_link_peer_unassign(struct ath12k_dp *dp, struct ath12k_dp_hw *dp_ · 56 unmodified lines | ||
| 632 | 637 | peerid_index = ath12k_dp_peer_get_peerid_index(dp, peer->peer_id); |
| 633 | 638 | |
| 634 | 639 | rcu_assign_pointer(dp_peer->link_peers[peer->link_id], NULL); |
| 640 | + WRITE_ONCE(dp_peer->link_peers_map, | |
| 641 | + READ_ONCE(dp_peer->link_peers_map) & ~BIT(peer->link_id)); | |
| 635 | 642 | |
| 636 | 643 | rcu_assign_pointer(dp_hw->dp_peers[peerid_index], NULL); |
| 637 | 644 | |
| @@ -140,6 +140,7 @@ struct ath12k_dp_peer { · 139 unmodified lines | ||
| 140 | 140 | |
| 141 | 141 | /* Info used in MMIC verification of * RX fragments */ |
| 142 | 142 | struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1]; |
| 143 | + unsigned long link_peers_map; | |
| 143 | 144 | struct ath12k_dp_link_peer __rcu *link_peers[ATH12K_NUM_MAX_LINKS]; |
| 144 | 145 | struct ath12k_reoq_buf reoq_bufs[IEEE80211_NUM_TIDS + 1]; |
| 145 | 146 | struct ath12k_dp_rx_tid rx_tid[IEEE80211_NUM_TIDS + 1]; |
| @@ -1384,10 +1384,9 @@ void ath12k_dp_rx_deliver_msdu(struct ath12k_pdev_dp *dp_pdev, struct napi_struc · 1383 unmodified lines | ||
| 1384 | 1384 | |
| 1385 | 1385 | pubsta = peer ? peer->sta : NULL; |
| 1386 | 1386 | |
| 1387 | − if (pubsta && pubsta->valid_links) { | |
| 1388 | − status->link_valid = 1; | |
| 1389 | − status->link_id = peer->hw_links[rxcb->hw_link_id]; | |
| 1390 | − } | |
| 1387 | + status->link_valid = 0; | |
| 1388 | + if (pubsta && pubsta->valid_links) | |
| 1389 | + ath12k_hw_set_rx_link_id(dp->hw_params, peer, rxcb, status); | |
| 1391 | 1390 | |
| 1392 | 1391 | ath12k_dbg(dp->ab, ATH12K_DBG_DATA, |
| 1393 | 1392 | "rx skb %p len %u peer %pM %d %s sn %u %s%s%s%s%s%s%s%s%s%s rate_idx %u vht_nss %u freq %u band %u flag 0x%x fcs-err %i mic-err %i amsdu-more %i\n", |
| @@ -13,6 +13,10 @@ · 12 unmodified lines | ||
| 13 | 13 | #include "wmi.h" |
| 14 | 14 | #include "hal.h" |
| 15 | 15 | |
| 16 | +struct ath12k_dp_peer; | |
| 17 | +struct ath12k_skb_rxcb; | |
| 18 | +struct ieee80211_rx_status; | |
| 19 | + | |
| 16 | 20 | /* Target configuration defines */ |
| 17 | 21 | |
| 18 | 22 | /* Num VDEVS per radio */ |
| @@ -243,6 +247,9 @@ struct ath12k_hw_ops { · 224 unmodified lines | ||
| 243 | 247 | bool (*dp_srng_is_tx_comp_ring)(int ring_num); |
| 244 | 248 | bool (*is_frame_link_agnostic)(struct ath12k_link_vif *arvif, |
| 245 | 249 | struct ieee80211_mgmt *mgmt); |
| 250 | + void (*set_rx_link_id)(struct ath12k_dp_peer *dp_peer, | |
| 251 | + struct ath12k_skb_rxcb *rxcb, | |
| 252 | + struct ieee80211_rx_status *status); | |
| 246 | 253 | }; |
| 247 | 254 | |
| 248 | 255 | static inline |
| @@ -273,6 +280,15 @@ static inline int ath12k_hw_mac_id_to_srng_id(const struct ath12k_hw_params *hw, · 24 unmodified lines | ||
| 273 | 280 | return 0; |
| 274 | 281 | } |
| 275 | 282 | |
| 283 | +static inline void ath12k_hw_set_rx_link_id(const struct ath12k_hw_params *hw, | |
| 284 | + struct ath12k_dp_peer *dp_peer, | |
| 285 | + struct ath12k_skb_rxcb *rxcb, | |
| 286 | + struct ieee80211_rx_status *status) | |
| 287 | +{ | |
| 288 | + if (hw->hw_ops->set_rx_link_id) | |
| 289 | + hw->hw_ops->set_rx_link_id(dp_peer, rxcb, status); | |
| 290 | +} | |
| 291 | + | |
| 276 | 292 | struct ath12k_fw_ie { |
| 277 | 293 | __le32 id; |
| 278 | 294 | __le32 len; |
| @@ -1238,9 +1238,13 @@ void ath12k_mac_peer_cleanup_all(struct ath12k *ar) · 1237 unmodified lines | ||
| 1238 | 1238 | /* cleanup dp peer */ |
| 1239 | 1239 | spin_lock_bh(&dp_hw->peer_lock); |
| 1240 | 1240 | dp_peer = peer->dp_peer; |
| 1241 | − peerid_index = ath12k_dp_peer_get_peerid_index(dp, peer->peer_id); | |
| 1242 | − rcu_assign_pointer(dp_peer->link_peers[peer->link_id], NULL); | |
| 1243 | − rcu_assign_pointer(dp_hw->dp_peers[peerid_index], NULL); | |
| 1241 | + if (dp_peer) { | |
| 1242 | + peerid_index = ath12k_dp_peer_get_peerid_index(dp, peer->peer_id); | |
| 1243 | + rcu_assign_pointer(dp_peer->link_peers[peer->link_id], NULL); | |
| 1244 | + WRITE_ONCE(dp_peer->link_peers_map, | |
| 1245 | + READ_ONCE(dp_peer->link_peers_map) & ~BIT(peer->link_id)); | |
| 1246 | + rcu_assign_pointer(dp_hw->dp_peers[peerid_index], NULL); | |
| 1247 | + } | |
| 1244 | 1248 | spin_unlock_bh(&dp_hw->peer_lock); |
| 1245 | 1249 | |
| 1246 | 1250 | ath12k_dp_link_peer_rhash_delete(dp, peer); |
| @@ -188,6 +188,8 @@ static void ath12k_pci_soc_global_reset(struct ath12k_base *ab) · 187 unmodified lines | ||
| 188 | 188 | val |= PCIE_SOC_GLOBAL_RESET_V; |
| 189 | 189 | |
| 190 | 190 | ath12k_pci_write32(ab, PCIE_SOC_GLOBAL_RESET, val); |
| 191 | + /* Flush the posted write to the device */ | |
| 192 | + ath12k_pci_read32(ab, PCIE_SOC_GLOBAL_RESET); | |
| 191 | 193 | |
| 192 | 194 | /* TODO: exact time to sleep is uncertain */ |
| 193 | 195 | delay = 10; |
| @@ -197,6 +199,8 @@ static void ath12k_pci_soc_global_reset(struct ath12k_base *ab) · 3 unmodified lines | ||
| 197 | 199 | val &= ~PCIE_SOC_GLOBAL_RESET_V; |
| 198 | 200 | |
| 199 | 201 | ath12k_pci_write32(ab, PCIE_SOC_GLOBAL_RESET, val); |
| 202 | + /* Flush the posted write to the device */ | |
| 203 | + ath12k_pci_read32(ab, PCIE_SOC_GLOBAL_RESET); | |
| 200 | 204 | |
| 201 | 205 | mdelay(delay); |
| 202 | 206 | |
| @@ -453,6 +453,9 @@ err_free: · 452 unmodified lines | ||
| 453 | 453 | |
| 454 | 454 | void ath12k_link_sta_rhash_tbl_destroy(struct ath12k_base *ab) |
| 455 | 455 | { |
| 456 | + if (!ab->rhead_sta_addr) | |
| 457 | + return; | |
| 458 | + | |
| 456 | 459 | rhashtable_destroy(ab->rhead_sta_addr); |
| 457 | 460 | kfree(ab->rhead_sta_addr); |
| 458 | 461 | ab->rhead_sta_addr = NULL; |
| @@ -5,6 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | #include "dp_rx.h" |
| 8 | +#include "../dp_peer.h" | |
| 8 | 9 | #include "../dp_tx.h" |
| 9 | 10 | #include "../peer.h" |
| 10 | 11 | #include "hal_qcn9274.h" |
| @@ -2315,3 +2316,35 @@ ath12k_wifi7_dp_rxdesc_mpdu_valid(struct ath12k_base *ab, · 2304 unmodified lines | ||
| 2315 | 2316 | |
| 2316 | 2317 | return tlv_tag == HAL_RX_MPDU_START; |
| 2317 | 2318 | } |
| 2319 | + | |
| 2320 | +void | |
| 2321 | +ath12k_wifi7_dp_rx_set_link_id_qcn9274(struct ath12k_dp_peer *dp_peer, | |
| 2322 | + struct ath12k_skb_rxcb *rxcb, | |
| 2323 | + struct ieee80211_rx_status *status) | |
| 2324 | +{ | |
| 2325 | + status->link_valid = 1; | |
| 2326 | + status->link_id = dp_peer->hw_links[rxcb->hw_link_id]; | |
| 2327 | +} | |
| 2328 | + | |
| 2329 | +void | |
| 2330 | +ath12k_wifi7_dp_rx_set_link_id_wcn7850(struct ath12k_dp_peer *dp_peer, | |
| 2331 | + struct ath12k_skb_rxcb *rxcb, | |
| 2332 | + struct ieee80211_rx_status *status) | |
| 2333 | +{ | |
| 2334 | + struct ath12k_dp_link_peer *link_peer; | |
| 2335 | + unsigned long links_map; | |
| 2336 | + int i; | |
| 2337 | + | |
| 2338 | + RCU_LOCKDEP_WARN(!rcu_read_lock_held(), | |
| 2339 | + "ath12k set rx link id called without rcu lock"); | |
| 2340 | + | |
| 2341 | + links_map = READ_ONCE(dp_peer->link_peers_map); | |
| 2342 | + for_each_set_bit(i, &links_map, ATH12K_NUM_MAX_LINKS) { | |
| 2343 | + link_peer = rcu_dereference(dp_peer->link_peers[i]); | |
| 2344 | + if (link_peer && link_peer->peer_id == rxcb->peer_id) { | |
| 2345 | + status->link_valid = 1; | |
| 2346 | + status->link_id = link_peer->link_id; | |
| 2347 | + return; | |
| 2348 | + } | |
| 2349 | + } | |
| 2350 | +} | |
| @@ -57,4 +57,10 @@ ath12k_wifi7_dp_rxdesc_mpdu_valid(struct ath12k_base *ab, · 56 unmodified lines | ||
| 57 | 57 | struct hal_rx_desc *rx_desc); |
| 58 | 58 | int ath12k_wifi7_dp_rx_tid_delete_handler(struct ath12k_base *ab, |
| 59 | 59 | struct ath12k_dp_rx_tid_rxq *rx_tid); |
| 60 | +void ath12k_wifi7_dp_rx_set_link_id_qcn9274(struct ath12k_dp_peer *dp_peer, | |
| 61 | + struct ath12k_skb_rxcb *rxcb, | |
| 62 | + struct ieee80211_rx_status *status); | |
| 63 | +void ath12k_wifi7_dp_rx_set_link_id_wcn7850(struct ath12k_dp_peer *dp_peer, | |
| 64 | + struct ath12k_skb_rxcb *rxcb, | |
| 65 | + struct ieee80211_rx_status *status); | |
| 60 | 66 | #endif |
| @@ -158,6 +158,7 @@ static const struct ath12k_hw_ops qcn9274_ops = { · 157 unmodified lines | ||
| 158 | 158 | .get_ring_selector = ath12k_wifi7_hw_get_ring_selector_qcn9274, |
| 159 | 159 | .dp_srng_is_tx_comp_ring = ath12k_wifi7_dp_srng_is_comp_ring_qcn9274, |
| 160 | 160 | .is_frame_link_agnostic = ath12k_wifi7_is_frame_link_agnostic_qcn9274, |
| 161 | + .set_rx_link_id = ath12k_wifi7_dp_rx_set_link_id_qcn9274, | |
| 161 | 162 | }; |
| 162 | 163 | |
| 163 | 164 | static const struct ath12k_hw_ops wcn7850_ops = { |
| @@ -168,6 +169,7 @@ static const struct ath12k_hw_ops wcn7850_ops = { · 4 unmodified lines | ||
| 168 | 169 | .get_ring_selector = ath12k_wifi7_hw_get_ring_selector_wcn7850, |
| 169 | 170 | .dp_srng_is_tx_comp_ring = ath12k_wifi7_dp_srng_is_comp_ring_wcn7850, |
| 170 | 171 | .is_frame_link_agnostic = ath12k_wifi7_is_frame_link_agnostic_wcn7850, |
| 172 | + .set_rx_link_id = ath12k_wifi7_dp_rx_set_link_id_wcn7850, | |
| 171 | 173 | }; |
| 172 | 174 | |
| 173 | 175 | static const struct ath12k_hw_ops qcc2072_ops = { |
| @@ -178,6 +180,7 @@ static const struct ath12k_hw_ops qcc2072_ops = { · 4 unmodified lines | ||
| 178 | 180 | .get_ring_selector = ath12k_wifi7_hw_get_ring_selector_wcn7850, |
| 179 | 181 | .dp_srng_is_tx_comp_ring = ath12k_wifi7_dp_srng_is_comp_ring_wcn7850, |
| 180 | 182 | .is_frame_link_agnostic = ath12k_wifi7_is_frame_link_agnostic_wcn7850, |
| 183 | + .set_rx_link_id = ath12k_wifi7_dp_rx_set_link_id_wcn7850, | |
| 181 | 184 | }; |
| 182 | 185 | |
| 183 | 186 | #define ATH12K_TX_RING_MASK_0 0x1 |
| @@ -1723,13 +1723,15 @@ void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid_mux, u16 seq_no, · 1722 unmodified lines | ||
| 1723 | 1723 | |
| 1724 | 1724 | rxtid = &aggr_conn->rx_tid[tid]; |
| 1725 | 1725 | |
| 1726 | − if (win_sz < AGGR_WIN_SZ_MIN || win_sz > AGGR_WIN_SZ_MAX) | |
| 1727 | − ath6kl_dbg(ATH6KL_DBG_WLAN_RX, "%s: win_sz %d, tid %d\n", | |
| 1728 | − __func__, win_sz, tid); | |
| 1729 | − | |
| 1730 | 1726 | if (rxtid->aggr) |
| 1731 | 1727 | aggr_delete_tid_state(aggr_conn, tid); |
| 1732 | 1728 | |
| 1729 | + if (win_sz < AGGR_WIN_SZ_MIN || win_sz > AGGR_WIN_SZ_MAX) { | |
| 1730 | + ath6kl_dbg(ATH6KL_DBG_WLAN_RX, "%s: win_sz %d, tid %d\n", | |
| 1731 | + __func__, win_sz, tid); | |
| 1732 | + return; | |
| 1733 | + } | |
| 1734 | + | |
| 1733 | 1735 | rxtid->seq_next = seq_no; |
| 1734 | 1736 | hold_q_size = TID_WINDOW_SZ(win_sz) * sizeof(struct skb_hold_q); |
| 1735 | 1737 | rxtid->hold_q = kzalloc(hold_q_size, GFP_KERNEL); |
| @@ -1828,7 +1830,7 @@ void aggr_reset_state(struct aggr_info_conn *aggr_conn) · 92 unmodified lines | ||
| 1828 | 1830 | return; |
| 1829 | 1831 | |
| 1830 | 1832 | if (aggr_conn->timer_scheduled) { |
| 1831 | − timer_delete(&aggr_conn->timer); | |
| 1833 | + timer_delete_sync(&aggr_conn->timer); | |
| 1832 | 1834 | aggr_conn->timer_scheduled = false; |
| 1833 | 1835 | } |
| 1834 | 1836 | |
| @@ -484,6 +484,18 @@ static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) · 483 unmodified lines | ||
| 484 | 484 | |
| 485 | 485 | evt = (struct wmi_tx_complete_event *) datap; |
| 486 | 486 | |
| 487 | + if (len < sizeof(*evt)) { | |
| 488 | + ath6kl_dbg(ATH6KL_DBG_WMI, "tx complete: invalid len %d\n", | |
| 489 | + len); | |
| 490 | + return -EINVAL; | |
| 491 | + } | |
| 492 | + | |
| 493 | + if (len < sizeof(*evt) + evt->num_msg * sizeof(struct tx_complete_msg_v1)) { | |
| 494 | + ath6kl_dbg(ATH6KL_DBG_WMI, "tx complete: invalid len %d for %u msgs\n", | |
| 495 | + len, evt->num_msg); | |
| 496 | + return -EINVAL; | |
| 497 | + } | |
| 498 | + | |
| 487 | 499 | ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n", |
| 488 | 500 | evt->num_msg, evt->msg_len, evt->msg_type); |
| 489 | 501 | |
| @@ -862,6 +874,14 @@ static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len, · 372 unmodified lines | ||
| 862 | 874 | |
| 863 | 875 | ev = (struct wmi_connect_event *) datap; |
| 864 | 876 | |
| 877 | + if (len < sizeof(*ev) + ev->beacon_ie_len + | |
| 878 | + ev->assoc_req_len + ev->assoc_resp_len) { | |
| 879 | + ath6kl_dbg(ATH6KL_DBG_WMI, | |
| 880 | + "connect event: IE lengths %u+%u+%u exceed buffer %d\n", | |
| 881 | + ev->beacon_ie_len, ev->assoc_req_len, | |
| 882 | + ev->assoc_resp_len, len); | |
| 883 | + return -EINVAL; | |
| 884 | + } | |
| 865 | 885 | if (vif->nw_type == AP_NETWORK) { |
| 866 | 886 | /* AP mode start/STA connected event */ |
| 867 | 887 | struct net_device *dev = vif->ndev; |
| @@ -1215,15 +1215,10 @@ static int ath9k_hif_request_firmware(struct hif_device_usb *hif_dev, · 1214 unmodified lines | ||
| 1215 | 1215 | ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name, |
| 1216 | 1216 | &hif_dev->udev->dev, GFP_KERNEL, |
| 1217 | 1217 | hif_dev, ath9k_hif_usb_firmware_cb); |
| 1218 | − if (ret) { | |
| 1218 | + if (ret) | |
| 1219 | 1219 | dev_err(&hif_dev->udev->dev, |
| 1220 | 1220 | "ath9k_htc: Async request for firmware %s failed\n", |
| 1221 | 1221 | hif_dev->fw_name); |
| 1222 | − return ret; | |
| 1223 | − } | |
| 1224 | − | |
| 1225 | − dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n", | |
| 1226 | − hif_dev->fw_name); | |
| 1227 | 1222 | |
| 1228 | 1223 | return ret; |
| 1229 | 1224 | } |
| @@ -150,7 +150,8 @@ static void carl9170_cmd_callback(struct ar9170 *ar, u32 len, void *buffer) · 149 unmodified lines | ||
| 150 | 150 | spin_lock(&ar->cmd_lock); |
| 151 | 151 | if (ar->readbuf) { |
| 152 | 152 | if (len >= 4) |
| 153 | − memcpy(ar->readbuf, buffer + 4, len - 4); | |
| 153 | + memcpy(ar->readbuf, buffer + 4, | |
| 154 | + min_t(u32, len - 4, ar->readlen)); | |
| 154 | 155 | |
| 155 | 156 | ar->readbuf = NULL; |
| 156 | 157 | } |
| @@ -917,7 +918,9 @@ static void carl9170_rx_stream(struct ar9170 *ar, void *buf, unsigned int len) · 760 unmodified lines | ||
| 917 | 918 | } |
| 918 | 919 | } |
| 919 | 920 | |
| 920 | − skb_put_data(ar->rx_failover, tbuf, tlen); | |
| 921 | + skb_put_data(ar->rx_failover, tbuf, | |
| 922 | + min_t(unsigned int, tlen, | |
| 923 | + ar->rx_failover_missing)); | |
| 921 | 924 | ar->rx_failover_missing -= tlen; |
| 922 | 925 | |
| 923 | 926 | if (ar->rx_failover_missing <= 0) { |
| @@ -692,7 +692,7 @@ void carl9170_tx_process_status(struct ar9170 *ar, · 691 unmodified lines | ||
| 692 | 692 | unsigned int i; |
| 693 | 693 | |
| 694 | 694 | for (i = 0; i < cmd->hdr.ext; i++) { |
| 695 | − if (WARN_ON(i > ((cmd->hdr.len / 2) + 1))) { | |
| 695 | + if (WARN_ON(i >= (cmd->hdr.len / 2))) { | |
| 696 | 696 | print_hex_dump_bytes("UU:", DUMP_PREFIX_NONE, |
| 697 | 697 | (void *) cmd, cmd->hdr.len + 4); |
| 698 | 698 | break; |
| @@ -1521,13 +1521,16 @@ static inline int at76_guess_freq(struct at76_priv *priv) · 1520 unmodified lines | ||
| 1521 | 1521 | |
| 1522 | 1522 | if (ieee80211_is_probe_resp(hdr->frame_control)) { |
| 1523 | 1523 | el_off = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); |
| 1524 | − el = ((struct ieee80211_mgmt *)hdr)->u.probe_resp.variable; | |
| 1525 | 1524 | } else if (ieee80211_is_beacon(hdr->frame_control)) { |
| 1526 | 1525 | el_off = offsetof(struct ieee80211_mgmt, u.beacon.variable); |
| 1527 | − el = ((struct ieee80211_mgmt *)hdr)->u.beacon.variable; | |
| 1528 | 1526 | } else { |
| 1529 | 1527 | goto exit; |
| 1530 | 1528 | } |
| 1529 | + | |
| 1530 | + if (len < el_off) | |
| 1531 | + goto exit; | |
| 1532 | + | |
| 1533 | + el = priv->rx_skb->data + el_off; | |
| 1531 | 1534 | len -= el_off; |
| 1532 | 1535 | |
| 1533 | 1536 | el = cfg80211_find_ie(WLAN_EID_DS_PARAMS, el, len); |
| @@ -911,6 +911,7 @@ int brcmf_sdiod_probe(struct brcmf_sdio_dev *sdiodev) · 910 unmodified lines | ||
| 911 | 911 | return ret; |
| 912 | 912 | } |
| 913 | 913 | switch (sdiodev->func2->device) { |
| 914 | + case SDIO_DEVICE_ID_BROADCOM_43752: | |
| 914 | 915 | case SDIO_DEVICE_ID_BROADCOM_CYPRESS_4373: |
| 915 | 916 | f2_blksz = SDIO_4373_FUNC2_BLOCKSIZE; |
| 916 | 917 | break; |
| @@ -1069,6 +1070,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, · 152 unmodified lines | ||
| 1069 | 1070 | bus_if = kzalloc_obj(*bus_if); |
| 1070 | 1071 | if (!bus_if) |
| 1071 | 1072 | return -ENOMEM; |
| 1073 | + mutex_init(&bus_if->bus_reset_lock); | |
| 1072 | 1074 | sdiodev = kzalloc_obj(*sdiodev); |
| 1073 | 1075 | if (!sdiodev) { |
| 1074 | 1076 | kfree(bus_if); |
| @@ -1130,6 +1132,14 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func) · 55 unmodified lines | ||
| 1130 | 1132 | if (func->num != 1) |
| 1131 | 1133 | return; |
| 1132 | 1134 | |
| 1135 | + /* Drain bus_reset before the shared brcmf_sdiod_remove() | |
| 1136 | + * teardown, which the SDIO reset callback also reaches. The | |
| 1137 | + * data worker can arm bus_reset via brcmf_fw_crashed(); cancel | |
| 1138 | + * it first. | |
| 1139 | + */ | |
| 1140 | + brcmf_sdio_cancel_datawork(sdiodev->bus); | |
| 1141 | + brcmf_bus_cancel_reset_work(bus_if); | |
| 1142 | + | |
| 1133 | 1143 | /* only proceed with rest of cleanup if func 1 */ |
| 1134 | 1144 | brcmf_sdiod_remove(sdiodev); |
| 1135 | 1145 | |
| @@ -1204,6 +1214,8 @@ static int brcmf_ops_sdio_suspend(struct device *dev) · 68 unmodified lines | ||
| 1204 | 1214 | } else { |
| 1205 | 1215 | /* power will be cut so remove device, probe again in resume */ |
| 1206 | 1216 | brcmf_sdiod_intr_unregister(sdiodev); |
| 1217 | + brcmf_sdio_cancel_datawork(sdiodev->bus); | |
| 1218 | + brcmf_bus_cancel_reset_work(bus_if); | |
| 1207 | 1219 | ret = brcmf_sdiod_remove(sdiodev); |
| 1208 | 1220 | if (ret) |
| 1209 | 1221 | brcmf_err("Failed to remove device on suspend\n"); |
| @@ -1229,6 +1241,8 @@ static int brcmf_ops_sdio_resume(struct device *dev) · 19 unmodified lines | ||
| 1229 | 1241 | ret = brcmf_sdiod_probe(sdiodev); |
| 1230 | 1242 | if (ret) |
| 1231 | 1243 | brcmf_err("Failed to probe device on resume\n"); |
| 1244 | + else | |
| 1245 | + brcmf_bus_allow_reset_work(bus_if); | |
| 1232 | 1246 | } else { |
| 1233 | 1247 | if (sdiodev->wowl_enabled && sdiodev->settings->bus.sdio.oob_irq_supported) |
| 1234 | 1248 | disable_irq_wake(sdiodev->settings->bus.sdio.oob_irq_nr); |
| @@ -9,6 +9,7 @@ · 8 unmodified lines | ||
| 9 | 9 | #include <linux/kernel.h> |
| 10 | 10 | #include <linux/firmware.h> |
| 11 | 11 | #include <linux/device.h> |
| 12 | +#include <linux/mutex.h> | |
| 12 | 13 | #include "debug.h" |
| 13 | 14 | |
| 14 | 15 | /* IDs of the 6 default common rings of msgbuf protocol */ |
| @@ -179,6 +180,8 @@ struct brcmf_bus { · 164 unmodified lines | ||
| 179 | 180 | enum brcmf_fwvendor fwvid; |
| 180 | 181 | bool always_use_fws_queue; |
| 181 | 182 | bool wowl_supported; |
| 183 | + bool removing; /* device removal in progress; quiesce async work */ | |
| 184 | + struct mutex bus_reset_lock; | |
| 182 | 185 | |
| 183 | 186 | const struct brcmf_bus_ops *ops; |
| 184 | 187 | struct brcmf_bus_msgbuf *msgbuf; |
| @@ -186,6 +189,9 @@ struct brcmf_bus { · 1 unmodified line | ||
| 186 | 189 | struct list_head list; |
| 187 | 190 | }; |
| 188 | 191 | |
| 192 | +void brcmf_bus_cancel_reset_work(struct brcmf_bus *bus_if); | |
| 193 | +void brcmf_bus_allow_reset_work(struct brcmf_bus *bus_if); | |
| 194 | + | |
| 189 | 195 | /* |
| 190 | 196 | * callback wrappers |
| 191 | 197 | */ |
| @@ -2146,7 +2146,7 @@ brcmf_set_key_mgmt(struct net_device *ndev, struct cfg80211_connect_params *sme) · 2145 unmodified lines | ||
| 2146 | 2146 | sme->crypto.akm_suites[0]); |
| 2147 | 2147 | return -EINVAL; |
| 2148 | 2148 | } |
| 2149 | − } else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED)) { | |
| 2149 | + } else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED | WPA2_AUTH_1X_SHA256)) { | |
| 2150 | 2150 | switch (sme->crypto.akm_suites[0]) { |
| 2151 | 2151 | case WLAN_AKM_SUITE_8021X: |
| 2152 | 2152 | val = WPA2_AUTH_UNSPECIFIED; |
| @@ -1167,6 +1167,35 @@ static int brcmf_revinfo_read(struct seq_file *s, void *data) · 1166 unmodified lines | ||
| 1167 | 1167 | return 0; |
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | +/* | |
| 1171 | + * Serialize arming from debugfs reset and brcmf_fw_crashed() against | |
| 1172 | + * teardown. The remove path sets ->removing and drains the work while | |
| 1173 | + * holding bus_reset_lock, so a racing armer is either drained or skips it. | |
| 1174 | + */ | |
| 1175 | +static void brcmf_bus_schedule_reset(struct brcmf_bus *bus_if) | |
| 1176 | +{ | |
| 1177 | + mutex_lock(&bus_if->bus_reset_lock); | |
| 1178 | + if (bus_if->drvr && bus_if->drvr->bus_reset.func && !bus_if->removing) | |
| 1179 | + schedule_work(&bus_if->drvr->bus_reset); | |
| 1180 | + mutex_unlock(&bus_if->bus_reset_lock); | |
| 1181 | +} | |
| 1182 | + | |
| 1183 | +void brcmf_bus_cancel_reset_work(struct brcmf_bus *bus_if) | |
| 1184 | +{ | |
| 1185 | + mutex_lock(&bus_if->bus_reset_lock); | |
| 1186 | + bus_if->removing = true; | |
| 1187 | + if (bus_if->drvr) | |
| 1188 | + cancel_work_sync(&bus_if->drvr->bus_reset); | |
| 1189 | + mutex_unlock(&bus_if->bus_reset_lock); | |
| 1190 | +} | |
| 1191 | + | |
| 1192 | +void brcmf_bus_allow_reset_work(struct brcmf_bus *bus_if) | |
| 1193 | +{ | |
| 1194 | + mutex_lock(&bus_if->bus_reset_lock); | |
| 1195 | + bus_if->removing = false; | |
| 1196 | + mutex_unlock(&bus_if->bus_reset_lock); | |
| 1197 | +} | |
| 1198 | + | |
| 1170 | 1199 | static void brcmf_core_bus_reset(struct work_struct *work) |
| 1171 | 1200 | { |
| 1172 | 1201 | struct brcmf_pub *drvr = container_of(work, struct brcmf_pub, |
| @@ -1187,7 +1216,7 @@ static ssize_t bus_reset_write(struct file *file, const char __user *user_buf, · 14 unmodified lines | ||
| 1187 | 1216 | if (value != 1) |
| 1188 | 1217 | return -EINVAL; |
| 1189 | 1218 | |
| 1190 | − schedule_work(&drvr->bus_reset); | |
| 1219 | + brcmf_bus_schedule_reset(drvr->bus_if); | |
| 1191 | 1220 | |
| 1192 | 1221 | return count; |
| 1193 | 1222 | } |
| @@ -1417,14 +1446,23 @@ void brcmf_dev_coredump(struct device *dev) · 223 unmodified lines | ||
| 1417 | 1446 | void brcmf_fw_crashed(struct device *dev) |
| 1418 | 1447 | { |
| 1419 | 1448 | struct brcmf_bus *bus_if = dev_get_drvdata(dev); |
| 1420 | − struct brcmf_pub *drvr = bus_if->drvr; | |
| 1449 | + struct brcmf_pub *drvr; | |
| 1450 | + | |
| 1451 | + /* May fire before brcmf_attach() wires up drvr, or after removal | |
| 1452 | + * has cleared it; guard the derefs below (and the arming gate in | |
| 1453 | + * brcmf_bus_schedule_reset() already checks drvr/->removing). | |
| 1454 | + */ | |
| 1455 | + if (!bus_if) | |
| 1456 | + return; | |
| 1457 | + drvr = bus_if->drvr; | |
| 1458 | + if (!drvr) | |
| 1459 | + return; | |
| 1421 | 1460 | |
| 1422 | 1461 | bphy_err(drvr, "Firmware has halted or crashed\n"); |
| 1423 | 1462 | |
| 1424 | 1463 | brcmf_dev_coredump(dev); |
| 1425 | 1464 | |
| 1426 | − if (drvr->bus_reset.func) | |
| 1427 | − schedule_work(&drvr->bus_reset); | |
| 1465 | + brcmf_bus_schedule_reset(bus_if); | |
| 1428 | 1466 | } |
| 1429 | 1467 | |
| 1430 | 1468 | void brcmf_detach(struct device *dev) |
| @@ -1383,16 +1383,20 @@ fail: · 1382 unmodified lines | ||
| 1383 | 1383 | static void |
| 1384 | 1384 | brcmf_pcie_release_scratchbuffers(struct brcmf_pciedev_info *devinfo) |
| 1385 | 1385 | { |
| 1386 | − if (devinfo->shared.scratch) | |
| 1386 | + if (devinfo->shared.scratch) { | |
| 1387 | 1387 | dma_free_coherent(&devinfo->pdev->dev, |
| 1388 | 1388 | BRCMF_DMA_D2H_SCRATCH_BUF_LEN, |
| 1389 | 1389 | devinfo->shared.scratch, |
| 1390 | 1390 | devinfo->shared.scratch_dmahandle); |
| 1391 | − if (devinfo->shared.ringupd) | |
| 1391 | + devinfo->shared.scratch = NULL; | |
| 1392 | + } | |
| 1393 | + if (devinfo->shared.ringupd) { | |
| 1392 | 1394 | dma_free_coherent(&devinfo->pdev->dev, |
| 1393 | 1395 | BRCMF_DMA_D2H_RINGUPD_BUF_LEN, |
| 1394 | 1396 | devinfo->shared.ringupd, |
| 1395 | 1397 | devinfo->shared.ringupd_dmahandle); |
| 1398 | + devinfo->shared.ringupd = NULL; | |
| 1399 | + } | |
| 1396 | 1400 | } |
| 1397 | 1401 | |
| 1398 | 1402 | static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo) |
| @@ -2499,6 +2503,7 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 1100 unmodified lines | ||
| 2499 | 2503 | ret = -ENOMEM; |
| 2500 | 2504 | goto fail; |
| 2501 | 2505 | } |
| 2506 | + mutex_init(&bus->bus_reset_lock); | |
| 2502 | 2507 | bus->msgbuf = kzalloc_obj(*bus->msgbuf); |
| 2503 | 2508 | if (!bus->msgbuf) { |
| 2504 | 2509 | ret = -ENOMEM; |
| @@ -2594,6 +2599,11 @@ brcmf_pcie_remove(struct pci_dev *pdev) · 89 unmodified lines | ||
| 2594 | 2599 | if (devinfo->ci) |
| 2595 | 2600 | brcmf_pcie_intr_disable(devinfo); |
| 2596 | 2601 | |
| 2602 | + if (devinfo->irq_allocated) | |
| 2603 | + synchronize_irq(pdev->irq); | |
| 2604 | + | |
| 2605 | + brcmf_bus_cancel_reset_work(bus); | |
| 2606 | + | |
| 2597 | 2607 | brcmf_detach(&pdev->dev); |
| 2598 | 2608 | brcmf_free(&pdev->dev); |
| 2599 | 2609 | |
| @@ -4560,6 +4560,12 @@ fail: · 4559 unmodified lines | ||
| 4560 | 4560 | return ret; |
| 4561 | 4561 | } |
| 4562 | 4562 | |
| 4563 | +void brcmf_sdio_cancel_datawork(struct brcmf_sdio *bus) | |
| 4564 | +{ | |
| 4565 | + if (bus) | |
| 4566 | + cancel_work_sync(&bus->datawork); | |
| 4567 | +} | |
| 4568 | + | |
| 4563 | 4569 | /* Detach and free everything */ |
| 4564 | 4570 | void brcmf_sdio_remove(struct brcmf_sdio *bus) |
| 4565 | 4571 | { |
| @@ -361,6 +361,7 @@ int brcmf_sdiod_remove(struct brcmf_sdio_dev *sdiodev); · 360 unmodified lines | ||
| 361 | 361 | int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev); |
| 362 | 362 | void brcmf_sdio_remove(struct brcmf_sdio *bus); |
| 363 | 363 | void brcmf_sdio_isr(struct brcmf_sdio *bus, bool in_isr); |
| 364 | +void brcmf_sdio_cancel_datawork(struct brcmf_sdio *bus); | |
| 364 | 365 | |
| 365 | 366 | void brcmf_sdio_wd_timer(struct brcmf_sdio *bus, bool active); |
| 366 | 367 | void brcmf_sdio_wowl_config(struct device *dev, bool enabled); |
| @@ -1260,6 +1260,7 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo, · 1259 unmodified lines | ||
| 1260 | 1260 | ret = -ENOMEM; |
| 1261 | 1261 | goto fail; |
| 1262 | 1262 | } |
| 1263 | + mutex_init(&bus->bus_reset_lock); | |
| 1263 | 1264 | |
| 1264 | 1265 | bus->dev = dev; |
| 1265 | 1266 | bus_pub->bus = bus; |
| @@ -1329,6 +1330,8 @@ brcmf_usb_disconnect_cb(struct brcmf_usbdev_info *devinfo) · 63 unmodified lines | ||
| 1329 | 1330 | return; |
| 1330 | 1331 | brcmf_dbg(USB, "Enter, bus_pub %p\n", devinfo); |
| 1331 | 1332 | |
| 1333 | + brcmf_bus_cancel_reset_work(devinfo->bus_pub.bus); | |
| 1334 | + | |
| 1332 | 1335 | brcmf_detach(devinfo->dev); |
| 1333 | 1336 | brcmf_free(devinfo->dev); |
| 1334 | 1337 | kfree(devinfo->bus_pub.bus); |
| @@ -15,6 +15,7 @@ · 14 unmodified lines | ||
| 15 | 15 | .non_shared_ant = ANT_B, \ |
| 16 | 16 | .vht_mu_mimo_supported = true, \ |
| 17 | 17 | .uhb_supported = true, \ |
| 18 | + .unii9_supported = true, \ | |
| 18 | 19 | .eht_supported = true, \ |
| 19 | 20 | .uhr_supported = true, \ |
| 20 | 21 | .num_rbds = IWL_NUM_RBDS_EHT, \ |
| @@ -865,6 +865,11 @@ int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt) · 864 unmodified lines | ||
| 865 | 865 | min_size, max_size, |
| 866 | 866 | &tbl_rev); |
| 867 | 867 | if (!IS_ERR(wifi_pkg)) { |
| 868 | + if (tbl_rev < 0 || | |
| 869 | + tbl_rev >= BITS_PER_BYTE * | |
| 870 | + sizeof(rev_data[idx].revisions)) | |
| 871 | + continue; | |
| 872 | + | |
| 868 | 873 | if (!(BIT(tbl_rev) & rev_data[idx].revisions)) |
| 869 | 874 | continue; |
| 870 | 875 | |
| @@ -205,6 +205,7 @@ struct iwl_nvm_get_info_phy { · 204 unmodified lines | ||
| 205 | 205 | |
| 206 | 206 | #define IWL_NUM_CHANNELS_V1 51 |
| 207 | 207 | #define IWL_NUM_CHANNELS_V2 110 |
| 208 | +#define IWL_NUM_CHANNELS_V3 115 | |
| 208 | 209 | |
| 209 | 210 | /** |
| 210 | 211 | * struct iwl_nvm_get_info_regulatory_v1 - regulatory information |
| @@ -219,12 +220,12 @@ struct iwl_nvm_get_info_regulatory_v1 { · 8 unmodified lines | ||
| 219 | 220 | } __packed; /* REGULATORY_NVM_GET_INFO_REGULATORY_S_VER_1 */ |
| 220 | 221 | |
| 221 | 222 | /** |
| 222 | − * struct iwl_nvm_get_info_regulatory - regulatory information | |
| 223 | + * struct iwl_nvm_get_info_regulatory_v2 - regulatory information | |
| 223 | 224 | * @lar_enabled: is LAR enabled |
| 224 | 225 | * @n_channels: number of valid channels in the array |
| 225 | 226 | * @channel_profile: regulatory data of this channel |
| 226 | 227 | */ |
| 227 | −struct iwl_nvm_get_info_regulatory { | |
| 228 | +struct iwl_nvm_get_info_regulatory_v2 { | |
| 228 | 229 | __le32 lar_enabled; |
| 229 | 230 | __le32 n_channels; |
| 230 | 231 | __le32 channel_profile[IWL_NUM_CHANNELS_V2]; |
| @@ -244,6 +245,32 @@ struct iwl_nvm_get_info_rsp_v3 { · 13 unmodified lines | ||
| 244 | 245 | struct iwl_nvm_get_info_regulatory_v1 regulatory; |
| 245 | 246 | } __packed; /* REGULATORY_NVM_GET_INFO_RSP_API_S_VER_3 */ |
| 246 | 247 | |
| 248 | +/** | |
| 249 | + * struct iwl_nvm_get_info_rsp_v4 - response to get NVM data | |
| 250 | + * @general: general NVM data | |
| 251 | + * @mac_sku: data relating to MAC sku | |
| 252 | + * @phy_sku: data relating to PHY sku | |
| 253 | + * @regulatory: regulatory data | |
| 254 | + */ | |
| 255 | +struct iwl_nvm_get_info_rsp_v4 { | |
| 256 | + struct iwl_nvm_get_info_general general; | |
| 257 | + struct iwl_nvm_get_info_sku mac_sku; | |
| 258 | + struct iwl_nvm_get_info_phy phy_sku; | |
| 259 | + struct iwl_nvm_get_info_regulatory_v2 regulatory; | |
| 260 | +} __packed; /* REGULATORY_NVM_GET_INFO_RSP_API_S_VER_4 */ | |
| 261 | + | |
| 262 | +/** | |
| 263 | + * struct iwl_nvm_get_info_regulatory - regulatory information | |
| 264 | + * @lar_enabled: is LAR enabled | |
| 265 | + * @n_channels: number of valid channels in the array | |
| 266 | + * @channel_profile: regulatory data of this channel | |
| 267 | + */ | |
| 268 | +struct iwl_nvm_get_info_regulatory { | |
| 269 | + __le32 lar_enabled; | |
| 270 | + __le32 n_channels; | |
| 271 | + __le32 channel_profile[IWL_NUM_CHANNELS_V3]; | |
| 272 | +} __packed; /* REGULATORY_NVM_GET_INFO_REGULATORY_S_VER_3 */ | |
| 273 | + | |
| 247 | 274 | /** |
| 248 | 275 | * struct iwl_nvm_get_info_rsp - response to get NVM data |
| 249 | 276 | * @general: general NVM data |
| @@ -256,7 +283,7 @@ struct iwl_nvm_get_info_rsp { · 6 unmodified lines | ||
| 256 | 283 | struct iwl_nvm_get_info_sku mac_sku; |
| 257 | 284 | struct iwl_nvm_get_info_phy phy_sku; |
| 258 | 285 | struct iwl_nvm_get_info_regulatory regulatory; |
| 259 | −} __packed; /* REGULATORY_NVM_GET_INFO_RSP_API_S_VER_4 */ | |
| 286 | +} __packed; /* REGULATORY_NVM_GET_INFO_RSP_API_S_VER_5 */ | |
| 260 | 287 | |
| 261 | 288 | /** |
| 262 | 289 | * struct iwl_nvm_access_complete_cmd - NVM_ACCESS commands are completed |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ |
| 2 | 2 | /* |
| 3 | − * Copyright (C) 2012-2014, 2018-2025 Intel Corporation | |
| 3 | + * Copyright (C) 2012-2014, 2018-2026 Intel Corporation | |
| 4 | 4 | * Copyright (C) 2013-2015 Intel Mobile Communications GmbH |
| 5 | 5 | * Copyright (C) 2016-2017 Intel Deutschland GmbH |
| 6 | 6 | */ |
| @@ -1319,7 +1319,7 @@ struct iwl_scan_offload_match_info { · 1312 unmodified lines | ||
| 1319 | 1319 | u8 resume_while_scanning; |
| 1320 | 1320 | u8 self_recovery; |
| 1321 | 1321 | __le16 reserved; |
| 1322 | − struct iwl_scan_offload_profile_match matches[]; | |
| 1322 | + struct iwl_scan_offload_profile_match matches[IWL_SCAN_MAX_PROFILES_V2]; | |
| 1323 | 1323 | } __packed; /* SCAN_OFFLOAD_PROFILES_QUERY_RSP_S_VER_3 and |
| 1324 | 1324 | * SCAN_OFFLOAD_MATCH_INFO_NOTIFICATION_S_VER_1 |
| 1325 | 1325 | */ |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 2 | 2 | /* |
| 3 | − * Copyright(c) 2020-2025 Intel Corporation | |
| 3 | + * Copyright(c) 2020-2026 Intel Corporation | |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | #include "iwl-drv.h" |
| @@ -12,6 +12,7 @@ · 5 unmodified lines | ||
| 12 | 12 | #include "fw/api/alive.h" |
| 13 | 13 | #include "fw/uefi.h" |
| 14 | 14 | #include "fw/img.h" |
| 15 | +#include "fw/dbg.h" | |
| 15 | 16 | |
| 16 | 17 | #define IWL_PNVM_REDUCED_CAP_BIT BIT(25) |
| 17 | 18 | |
| @@ -26,6 +27,12 @@ static bool iwl_pnvm_complete_fn(struct iwl_notif_wait_data *notif_wait, · 8 unmodified lines | ||
| 26 | 27 | struct iwl_trans *trans = (struct iwl_trans *)data; |
| 27 | 28 | struct iwl_pnvm_init_complete_ntfy *pnvm_ntf = (void *)pkt->data; |
| 28 | 29 | |
| 30 | + if (IWL_FW_CHECK(trans, | |
| 31 | + iwl_rx_packet_payload_len(pkt) < sizeof(*pnvm_ntf), | |
| 32 | + "Bad notif len: %d\n", | |
| 33 | + iwl_rx_packet_payload_len(pkt))) | |
| 34 | + return true; | |
| 35 | + | |
| 29 | 36 | IWL_DEBUG_FW(trans, |
| 30 | 37 | "PNVM complete notification received with status 0x%0x\n", |
| 31 | 38 | le32_to_cpu(pnvm_ntf->status)); |
| @@ -389,7 +389,7 @@ bool iwl_add_mcc_to_tas_block_list(u16 *list, u8 *size, u16 mcc) · 388 unmodified lines | ||
| 389 | 389 | if (*size >= IWL_WTAS_BLACK_LIST_MAX) |
| 390 | 390 | return false; |
| 391 | 391 | |
| 392 | − list[*size++] = mcc; | |
| 392 | + list[(*size)++] = mcc; | |
| 393 | 393 | return true; |
| 394 | 394 | } |
| 395 | 395 | IWL_EXPORT_SYMBOL(iwl_add_mcc_to_tas_block_list); |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 2 | 2 | /* |
| 3 | − * Copyright (C) 2012-2014, 2018-2021, 2025 Intel Corporation | |
| 3 | + * Copyright (C) 2012-2014, 2018-2021, 2025-2026 Intel Corporation | |
| 4 | 4 | * Copyright (C) 2013-2015 Intel Mobile Communications GmbH |
| 5 | 5 | * Copyright (C) 2016-2017 Intel Deutschland GmbH |
| 6 | 6 | */ |
| @@ -14,9 +14,17 @@ static void iwl_parse_shared_mem_22000(struct iwl_fw_runtime *fwrt, · 7 unmodified lines | ||
| 14 | 14 | { |
| 15 | 15 | struct iwl_shared_mem_cfg *mem_cfg = (void *)pkt->data; |
| 16 | 16 | int i, lmac; |
| 17 | − int lmac_num = le32_to_cpu(mem_cfg->lmac_num); | |
| 18 | − u8 api_ver = iwl_fw_lookup_notif_ver(fwrt->fw, SYSTEM_GROUP, | |
| 19 | − SHARED_MEM_CFG_CMD, 0); | |
| 17 | + int lmac_num; | |
| 18 | + u8 api_ver; | |
| 19 | + | |
| 20 | + if (IWL_FW_CHECK(fwrt, iwl_rx_packet_payload_len(pkt) < | |
| 21 | + offsetofend(struct iwl_shared_mem_cfg, lmac_smem[1]), | |
| 22 | + "bad shared mem notification size\n")) | |
| 23 | + return; | |
| 24 | + | |
| 25 | + lmac_num = le32_to_cpu(mem_cfg->lmac_num); | |
| 26 | + api_ver = iwl_fw_lookup_notif_ver(fwrt->fw, SYSTEM_GROUP, | |
| 27 | + SHARED_MEM_CFG_CMD, 0); | |
| 20 | 28 | |
| 21 | 29 | /* Note: notification has 3 entries, but we only expect 2 */ |
| 22 | 30 | if (IWL_FW_CHECK(fwrt, lmac_num > ARRAY_SIZE(fwrt->smem_cfg.lmac), |
| @@ -30,7 +38,7 @@ static void iwl_parse_shared_mem_22000(struct iwl_fw_runtime *fwrt, · 7 unmodified lines | ||
| 30 | 38 | |
| 31 | 39 | if (api_ver >= 4 && |
| 32 | 40 | !IWL_FW_CHECK(fwrt, iwl_rx_packet_payload_len(pkt) < sizeof(*mem_cfg), |
| 33 | − "bad shared mem notification size\n")) { | |
| 41 | + "bad shared mem notification size (v4)\n")) { | |
| 34 | 42 | fwrt->smem_cfg.rxfifo2_control_size = |
| 35 | 43 | le32_to_cpu(mem_cfg->rxfifo2_control_size); |
| 36 | 44 | } |
| @@ -53,6 +61,11 @@ static void iwl_parse_shared_mem(struct iwl_fw_runtime *fwrt, · 16 unmodified lines | ||
| 53 | 61 | struct iwl_shared_mem_cfg_v2 *mem_cfg = (void *)pkt->data; |
| 54 | 62 | int i; |
| 55 | 63 | |
| 64 | + if (IWL_FW_CHECK(fwrt, iwl_rx_packet_payload_len(pkt) < | |
| 65 | + offsetof(struct iwl_shared_mem_cfg_v2, rxfifo_addr), | |
| 66 | + "bad shared mem notification size\n")) | |
| 67 | + return; | |
| 68 | + | |
| 56 | 69 | fwrt->smem_cfg.num_lmacs = 1; |
| 57 | 70 | |
| 58 | 71 | fwrt->smem_cfg.num_txfifo_entries = ARRAY_SIZE(mem_cfg->txfifo_size); |
| @@ -67,6 +80,11 @@ static void iwl_parse_shared_mem(struct iwl_fw_runtime *fwrt, · 8 unmodified lines | ||
| 67 | 80 | /* new API has more data, from rxfifo_addr field and on */ |
| 68 | 81 | if (fw_has_capa(&fwrt->fw->ucode_capa, |
| 69 | 82 | IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG)) { |
| 83 | + if (IWL_FW_CHECK(fwrt, iwl_rx_packet_payload_len(pkt) < | |
| 84 | + sizeof(*mem_cfg), | |
| 85 | + "bad shared mem notification size (extend)\n")) | |
| 86 | + return; | |
| 87 | + | |
| 70 | 88 | BUILD_BUG_ON(sizeof(fwrt->smem_cfg.internal_txfifo_size) != |
| 71 | 89 | sizeof(mem_cfg->internal_txfifo_size)); |
| 72 | 90 | |
| @@ -700,7 +700,7 @@ int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt) · 699 unmodified lines | ||
| 700 | 700 | return -EINVAL; |
| 701 | 701 | |
| 702 | 702 | parse_table: |
| 703 | − if (!(BIT(data->revision) & valid_rev)) { | |
| 703 | + if (data->revision >= 32 || !(BIT(data->revision) & valid_rev)) { | |
| 704 | 704 | ret = -EINVAL; |
| 705 | 705 | IWL_DEBUG_RADIO(fwrt, |
| 706 | 706 | "Unsupported UEFI PPAG revision:%d\n", |
| @@ -415,6 +415,7 @@ struct iwl_mac_cfg { · 414 unmodified lines | ||
| 415 | 415 | * @vht_mu_mimo_supported: VHT MU-MIMO support |
| 416 | 416 | * @nvm_type: see &enum iwl_nvm_type |
| 417 | 417 | * @uhb_supported: ultra high band channels supported |
| 418 | + * @unii9_supported: UNII-9 channels supported | |
| 418 | 419 | * @eht_supported: EHT supported |
| 419 | 420 | * @uhr_supported: UHR supported |
| 420 | 421 | * @num_rbds: number of receive buffer descriptors to use |
| @@ -450,6 +451,7 @@ struct iwl_rf_cfg { · 29 unmodified lines | ||
| 450 | 451 | lp_xtal_workaround:1, |
| 451 | 452 | vht_mu_mimo_supported:1, |
| 452 | 453 | uhb_supported:1, |
| 454 | + unii9_supported:1, | |
| 453 | 455 | eht_supported:1, |
| 454 | 456 | uhr_supported:1; |
| 455 | 457 | u8 valid_tx_ant; |
| @@ -475,6 +475,7 @@ static int iwl_dbg_tlv_parse_bin(struct iwl_trans *trans, const u8 *data, · 474 unmodified lines | ||
| 475 | 475 | { |
| 476 | 476 | const struct iwl_ucode_tlv *tlv; |
| 477 | 477 | u32 tlv_len; |
| 478 | + size_t aligned_tlv_len; | |
| 478 | 479 | |
| 479 | 480 | while (len >= sizeof(*tlv)) { |
| 480 | 481 | len -= sizeof(*tlv); |
| @@ -487,8 +488,16 @@ static int iwl_dbg_tlv_parse_bin(struct iwl_trans *trans, const u8 *data, · 6 unmodified lines | ||
| 487 | 488 | len, tlv_len); |
| 488 | 489 | return -EINVAL; |
| 489 | 490 | } |
| 490 | − len -= ALIGN(tlv_len, 4); | |
| 491 | − data += sizeof(*tlv) + ALIGN(tlv_len, 4); | |
| 491 | + | |
| 492 | + aligned_tlv_len = ALIGN(tlv_len, 4); | |
| 493 | + if (len < aligned_tlv_len) { | |
| 494 | + IWL_ERR(trans, "invalid aligned TLV len: %zd/%zu\n", | |
| 495 | + len, aligned_tlv_len); | |
| 496 | + return -EINVAL; | |
| 497 | + } | |
| 498 | + | |
| 499 | + len -= aligned_tlv_len; | |
| 500 | + data += sizeof(*tlv) + aligned_tlv_len; | |
| 492 | 501 | |
| 493 | 502 | iwl_dbg_tlv_alloc(trans, tlv, true); |
| 494 | 503 | } |
| @@ -492,7 +492,7 @@ static void set_sec_offset(struct iwl_firmware_pieces *pieces, · 491 unmodified lines | ||
| 492 | 492 | * Gets uCode section from tlv. |
| 493 | 493 | */ |
| 494 | 494 | static int iwl_store_ucode_sec(struct fw_img_parsing *img, |
| 495 | − const void *data, int size) | |
| 495 | + const void *data, size_t size) | |
| 496 | 496 | { |
| 497 | 497 | struct fw_sec *sec; |
| 498 | 498 | const struct fw_sec_parsing *sec_parse; |
| @@ -501,6 +501,9 @@ static int iwl_store_ucode_sec(struct fw_img_parsing *img, · 2 unmodified lines | ||
| 501 | 501 | if (WARN_ON(!img || !data)) |
| 502 | 502 | return -EINVAL; |
| 503 | 503 | |
| 504 | + if (size < sizeof(sec_parse->offset)) | |
| 505 | + return -EINVAL; | |
| 506 | + | |
| 504 | 507 | sec_parse = (const struct fw_sec_parsing *)data; |
| 505 | 508 | |
| 506 | 509 | alloc_size = sizeof(*img->sec) * (img->sec_counter + 1); |
| @@ -804,6 +807,7 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv, · 297 unmodified lines | ||
| 804 | 807 | u32 build, paging_mem_size; |
| 805 | 808 | int num_of_cpus; |
| 806 | 809 | bool usniffer_req = false; |
| 810 | + size_t aligned_tlv_len; | |
| 807 | 811 | |
| 808 | 812 | if (len < sizeof(*ucode)) { |
| 809 | 813 | IWL_ERR(drv, "uCode has invalid length: %zd\n", len); |
| @@ -852,8 +856,16 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv, · 42 unmodified lines | ||
| 852 | 856 | len, tlv_len); |
| 853 | 857 | return -EINVAL; |
| 854 | 858 | } |
| 855 | − len -= ALIGN(tlv_len, 4); | |
| 856 | − data += sizeof(*tlv) + ALIGN(tlv_len, 4); | |
| 859 | + | |
| 860 | + aligned_tlv_len = ALIGN(tlv_len, 4); | |
| 861 | + if (len < aligned_tlv_len) { | |
| 862 | + IWL_ERR(drv, "invalid aligned TLV len: %zd/%zu\n", | |
| 863 | + len, aligned_tlv_len); | |
| 864 | + return -EINVAL; | |
| 865 | + } | |
| 866 | + | |
| 867 | + len -= aligned_tlv_len; | |
| 868 | + data += sizeof(*tlv) + aligned_tlv_len; | |
| 857 | 869 | |
| 858 | 870 | switch (tlv_type) { |
| 859 | 871 | case IWL_UCODE_TLV_INST: |
| @@ -85,16 +85,7 @@ static const u16 iwl_nvm_channels[] = { · 84 unmodified lines | ||
| 85 | 85 | 149, 153, 157, 161, 165 |
| 86 | 86 | }; |
| 87 | 87 | |
| 88 | −static const u16 iwl_ext_nvm_channels[] = { | |
| 89 | − /* 2.4 GHz */ | |
| 90 | − 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, | |
| 91 | − /* 5 GHz */ | |
| 92 | − 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, | |
| 93 | − 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, | |
| 94 | − 149, 153, 157, 161, 165, 169, 173, 177, 181 | |
| 95 | −}; | |
| 96 | − | |
| 97 | −static const u16 iwl_uhb_nvm_channels[] = { | |
| 88 | +static const u16 iwl_unii9_nvm_channels[] = { | |
| 98 | 89 | /* 2.4 GHz */ |
| 99 | 90 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 100 | 91 | /* 5 GHz */ |
| @@ -105,12 +96,16 @@ static const u16 iwl_uhb_nvm_channels[] = { · 4 unmodified lines | ||
| 105 | 96 | 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, |
| 106 | 97 | 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129, |
| 107 | 98 | 133, 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, 177, 181, 185, |
| 108 | − 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 233 | |
| 99 | + 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 233, | |
| 100 | + | |
| 101 | + /* UNII-9 */ | |
| 102 | + 237, 241, 245, 249, 253 | |
| 109 | 103 | }; |
| 110 | 104 | |
| 111 | 105 | #define IWL_NVM_NUM_CHANNELS ARRAY_SIZE(iwl_nvm_channels) |
| 112 | −#define IWL_NVM_NUM_CHANNELS_EXT ARRAY_SIZE(iwl_ext_nvm_channels) | |
| 113 | −#define IWL_NVM_NUM_CHANNELS_UHB ARRAY_SIZE(iwl_uhb_nvm_channels) | |
| 106 | +#define IWL_NVM_NUM_CHANNELS_EXT 51 | |
| 107 | +#define IWL_NVM_NUM_CHANNELS_UHB 110 | |
| 108 | +#define IWL_NVM_NUM_CHANNELS_UNII9 ARRAY_SIZE(iwl_unii9_nvm_channels) | |
| 114 | 109 | #define NUM_2GHZ_CHANNELS 14 |
| 115 | 110 | #define NUM_5GHZ_CHANNELS 37 |
| 116 | 111 | #define FIRST_2GHZ_HT_MINUS 5 |
| @@ -351,12 +346,15 @@ static int iwl_init_channel_map(struct iwl_trans *trans, · 234 unmodified lines | ||
| 351 | 346 | int num_of_ch; |
| 352 | 347 | const u16 *nvm_chan; |
| 353 | 348 | |
| 354 | − if (cfg->uhb_supported) { | |
| 349 | + if (cfg->unii9_supported) { | |
| 350 | + num_of_ch = IWL_NVM_NUM_CHANNELS_UNII9; | |
| 351 | + nvm_chan = iwl_unii9_nvm_channels; | |
| 352 | + } else if (cfg->uhb_supported) { | |
| 355 | 353 | num_of_ch = IWL_NVM_NUM_CHANNELS_UHB; |
| 356 | − nvm_chan = iwl_uhb_nvm_channels; | |
| 354 | + nvm_chan = iwl_unii9_nvm_channels; | |
| 357 | 355 | } else if (cfg->nvm_type == IWL_NVM_EXT) { |
| 358 | 356 | num_of_ch = IWL_NVM_NUM_CHANNELS_EXT; |
| 359 | − nvm_chan = iwl_ext_nvm_channels; | |
| 357 | + nvm_chan = iwl_unii9_nvm_channels; | |
| 360 | 358 | } else { |
| 361 | 359 | num_of_ch = IWL_NVM_NUM_CHANNELS; |
| 362 | 360 | nvm_chan = iwl_nvm_channels; |
| @@ -1441,7 +1439,9 @@ iwl_parse_mei_nvm_data(struct iwl_trans *trans, const struct iwl_rf_cfg *cfg, · 1078 unmodified lines | ||
| 1441 | 1439 | u8 rx_chains = fw->valid_rx_ant; |
| 1442 | 1440 | u8 tx_chains = fw->valid_rx_ant; |
| 1443 | 1441 | |
| 1444 | − if (cfg->uhb_supported) | |
| 1442 | + if (cfg->unii9_supported) | |
| 1443 | + data = kzalloc_flex(*data, channels, IWL_NVM_NUM_CHANNELS_UNII9); | |
| 1444 | + else if (cfg->uhb_supported) | |
| 1445 | 1445 | data = kzalloc_flex(*data, channels, IWL_NVM_NUM_CHANNELS_UHB); |
| 1446 | 1446 | else |
| 1447 | 1447 | data = kzalloc_flex(*data, channels, IWL_NVM_NUM_CHANNELS_EXT); |
| @@ -1506,7 +1506,9 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_rf_cfg *cfg, · 58 unmodified lines | ||
| 1506 | 1506 | u16 lar_config; |
| 1507 | 1507 | const __le16 *ch_section; |
| 1508 | 1508 | |
| 1509 | − if (cfg->uhb_supported) | |
| 1509 | + if (cfg->unii9_supported) | |
| 1510 | + data = kzalloc_flex(*data, channels, IWL_NVM_NUM_CHANNELS_UNII9); | |
| 1511 | + else if (cfg->uhb_supported) | |
| 1510 | 1512 | data = kzalloc_flex(*data, channels, IWL_NVM_NUM_CHANNELS_UHB); |
| 1511 | 1513 | else if (cfg->nvm_type != IWL_NVM_EXT) |
| 1512 | 1514 | data = kzalloc_flex(*data, channels, IWL_NVM_NUM_CHANNELS); |
| @@ -1727,12 +1729,15 @@ iwl_parse_nvm_mcc_info(struct iwl_trans *trans, · 214 unmodified lines | ||
| 1727 | 1729 | int max_num_ch; |
| 1728 | 1730 | struct iwl_reg_capa reg_capa; |
| 1729 | 1731 | |
| 1730 | − if (cfg->uhb_supported) { | |
| 1732 | + if (cfg->unii9_supported) { | |
| 1733 | + max_num_ch = IWL_NVM_NUM_CHANNELS_UNII9; | |
| 1734 | + nvm_chan = iwl_unii9_nvm_channels; | |
| 1735 | + } else if (cfg->uhb_supported) { | |
| 1731 | 1736 | max_num_ch = IWL_NVM_NUM_CHANNELS_UHB; |
| 1732 | − nvm_chan = iwl_uhb_nvm_channels; | |
| 1737 | + nvm_chan = iwl_unii9_nvm_channels; | |
| 1733 | 1738 | } else if (cfg->nvm_type == IWL_NVM_EXT) { |
| 1734 | 1739 | max_num_ch = IWL_NVM_NUM_CHANNELS_EXT; |
| 1735 | − nvm_chan = iwl_ext_nvm_channels; | |
| 1740 | + nvm_chan = iwl_unii9_nvm_channels; | |
| 1736 | 1741 | } else { |
| 1737 | 1742 | max_num_ch = IWL_NVM_NUM_CHANNELS; |
| 1738 | 1743 | nvm_chan = iwl_nvm_channels; |
| @@ -2087,13 +2092,26 @@ struct iwl_nvm_data *iwl_get_nvm(struct iwl_trans *trans, · 348 unmodified lines | ||
| 2087 | 2092 | struct iwl_nvm_get_info_rsp_v3 *rsp_v3; |
| 2088 | 2093 | bool v4 = fw_has_api(&fw->ucode_capa, |
| 2089 | 2094 | IWL_UCODE_TLV_API_REGULATORY_NVM_INFO); |
| 2090 | − size_t rsp_size = v4 ? sizeof(*rsp) : sizeof(*rsp_v3); | |
| 2095 | + size_t rsp_size; | |
| 2091 | 2096 | void *channel_profile; |
| 2092 | 2097 | |
| 2093 | 2098 | ret = iwl_trans_send_cmd(trans, &hcmd); |
| 2094 | 2099 | if (ret) |
| 2095 | 2100 | return ERR_PTR(ret); |
| 2096 | 2101 | |
| 2102 | + switch (iwl_fw_lookup_notif_ver(fw, REGULATORY_AND_NVM_GROUP, | |
| 2103 | + NVM_GET_INFO, 0)) { | |
| 2104 | + case 5: | |
| 2105 | + rsp_size = sizeof(struct iwl_nvm_get_info_rsp); | |
| 2106 | + break; | |
| 2107 | + case 4: | |
| 2108 | + rsp_size = sizeof(struct iwl_nvm_get_info_rsp_v4); | |
| 2109 | + break; | |
| 2110 | + default: | |
| 2111 | + rsp_size = sizeof(struct iwl_nvm_get_info_rsp_v3); | |
| 2112 | + break; | |
| 2113 | + } | |
| 2114 | + | |
| 2097 | 2115 | if (WARN(iwl_rx_packet_payload_len(hcmd.resp_pkt) != rsp_size, |
| 2098 | 2116 | "Invalid payload len in NVM response from FW %d", |
| 2099 | 2117 | iwl_rx_packet_payload_len(hcmd.resp_pkt))) { |
| @@ -2107,7 +2125,7 @@ struct iwl_nvm_data *iwl_get_nvm(struct iwl_trans *trans, · 7 unmodified lines | ||
| 2107 | 2125 | if (empty_otp) |
| 2108 | 2126 | IWL_INFO(trans, "OTP is empty\n"); |
| 2109 | 2127 | |
| 2110 | − nvm = kzalloc_flex(*nvm, channels, IWL_NUM_CHANNELS_V2); | |
| 2128 | + nvm = kzalloc_flex(*nvm, channels, IWL_NUM_CHANNELS_V3); | |
| 2111 | 2129 | if (!nvm) { |
| 2112 | 2130 | ret = -ENOMEM; |
| 2113 | 2131 | goto out; |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 2 | 2 | /* |
| 3 | − * Copyright (C) 2024-2025 Intel Corporation | |
| 3 | + * Copyright (C) 2024-2026 Intel Corporation | |
| 4 | 4 | */ |
| 5 | 5 | #include "agg.h" |
| 6 | 6 | #include "sta.h" |
| @@ -222,6 +222,11 @@ iwl_mld_reorder(struct iwl_mld *mld, struct napi_struct *napi, · 215 unmodified lines | ||
| 222 | 222 | if (baid == IWL_RX_REORDER_DATA_INVALID_BAID) |
| 223 | 223 | return IWL_MLD_PASS_SKB; |
| 224 | 224 | |
| 225 | + if (IWL_FW_CHECK(mld, baid >= ARRAY_SIZE(mld->fw_id_to_ba), | |
| 226 | + "Got out-of-range BAID %u in reorder_data=0x%x\n", | |
| 227 | + baid, reorder)) | |
| 228 | + return IWL_MLD_PASS_SKB; | |
| 229 | + | |
| 225 | 230 | /* no sta yet */ |
| 226 | 231 | if (WARN_ONCE(!sta, |
| 227 | 232 | "Got valid BAID without a valid station assigned\n")) |
| @@ -1708,7 +1708,7 @@ static void iwl_mld_check_he_obss_narrow_bw_ru_iter(struct wiphy *wiphy, · 1707 unmodified lines | ||
| 1708 | 1708 | elem = cfg80211_find_elem(WLAN_EID_EXT_CAPABILITY, ies->data, |
| 1709 | 1709 | ies->len); |
| 1710 | 1710 | |
| 1711 | − if (!elem || elem->datalen < 10 || | |
| 1711 | + if (!elem || elem->datalen < 11 || | |
| 1712 | 1712 | !(elem->data[10] & |
| 1713 | 1713 | WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT)) { |
| 1714 | 1714 | *tolerated = false; |
| @@ -18,9 +18,15 @@ static struct iwl_mcc_update_resp_v8 * · 17 unmodified lines | ||
| 18 | 18 | iwl_mld_copy_mcc_resp(const struct iwl_rx_packet *pkt) |
| 19 | 19 | { |
| 20 | 20 | const struct iwl_mcc_update_resp_v8 *mcc_resp_v8 = (const void *)pkt->data; |
| 21 | − int n_channels = __le32_to_cpu(mcc_resp_v8->n_channels); | |
| 22 | 21 | struct iwl_mcc_update_resp_v8 *resp_cp; |
| 23 | − int notif_len = struct_size(resp_cp, channels, n_channels); | |
| 22 | + int n_channels; | |
| 23 | + int notif_len; | |
| 24 | + | |
| 25 | + if (iwl_rx_packet_payload_len(pkt) < sizeof(*mcc_resp_v8)) | |
| 26 | + return ERR_PTR(-EINVAL); | |
| 27 | + | |
| 28 | + n_channels = __le32_to_cpu(mcc_resp_v8->n_channels); | |
| 29 | + notif_len = struct_size(resp_cp, channels, n_channels); | |
| 24 | 30 | |
| 25 | 31 | if (iwl_rx_packet_payload_len(pkt) != notif_len) |
| 26 | 32 | return ERR_PTR(-EINVAL); |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 2 | 2 | /* |
| 3 | − * Copyright (C) 2024-2025 Intel Corporation | |
| 3 | + * Copyright (C) 2024-2026 Intel Corporation | |
| 4 | 4 | */ |
| 5 | 5 | #ifdef CONFIG_THERMAL |
| 6 | 6 | #include <linux/sort.h> |
| @@ -272,6 +272,7 @@ static void iwl_mld_thermal_zone_register(struct iwl_mld *mld) · 265 unmodified lines | ||
| 272 | 272 | if (ret) { |
| 273 | 273 | IWL_DEBUG_TEMP(mld, "Failed to enable thermal zone\n"); |
| 274 | 274 | thermal_zone_device_unregister(mld->tzone); |
| 275 | + mld->tzone = NULL; | |
| 275 | 276 | } |
| 276 | 277 | } |
| 277 | 278 | |
| @@ -385,10 +386,8 @@ static void iwl_mld_thermal_zone_unregister(struct iwl_mld *mld) · 107 unmodified lines | ||
| 385 | 386 | return; |
| 386 | 387 | |
| 387 | 388 | IWL_DEBUG_TEMP(mld, "Thermal zone device unregister\n"); |
| 388 | − if (mld->tzone) { | |
| 389 | − thermal_zone_device_unregister(mld->tzone); | |
| 390 | − mld->tzone = NULL; | |
| 391 | − } | |
| 389 | + thermal_zone_device_unregister(mld->tzone); | |
| 390 | + mld->tzone = NULL; | |
| 392 | 391 | } |
| 393 | 392 | |
| 394 | 393 | static void iwl_mld_cooling_device_unregister(struct iwl_mld *mld) |
| @@ -1120,6 +1120,10 @@ void iwl_mld_handle_tx_resp_notif(struct iwl_mld *mld, · 1119 unmodified lines | ||
| 1120 | 1120 | ssn = le32_to_cpup((__le32 *)agg_status + |
| 1121 | 1121 | tx_resp->frame_count) & 0xFFFF; |
| 1122 | 1122 | |
| 1123 | + if (IWL_FW_CHECK(mld, txq_id >= ARRAY_SIZE(mld->fw_id_to_txq), | |
| 1124 | + "Invalid txq id %d\n", txq_id)) | |
| 1125 | + return; | |
| 1126 | + | |
| 1123 | 1127 | __skb_queue_head_init(&skbs); |
| 1124 | 1128 | |
| 1125 | 1129 | /* we can free until ssn % q.n_bd not inclusive */ |
| @@ -1509,6 +1509,10 @@ static void iwl_mvm_report_wakeup_reasons(struct iwl_mvm *mvm, · 1508 unmodified lines | ||
| 1509 | 1509 | if (WARN_ON_ONCE(truncated < 0)) |
| 1510 | 1510 | truncated = 0; |
| 1511 | 1511 | |
| 1512 | + /* this would be a firmware bug */ | |
| 1513 | + if (WARN_ON_ONCE(pktsize < sizeof(*hdr))) | |
| 1514 | + return; | |
| 1515 | + | |
| 1512 | 1516 | if (ieee80211_is_data(hdr->frame_control)) { |
| 1513 | 1517 | int hdrlen = ieee80211_hdrlen(hdr->frame_control); |
| 1514 | 1518 | int ivlen = 0, icvlen = 4; /* also FCS */ |
| @@ -1517,10 +1521,6 @@ static void iwl_mvm_report_wakeup_reasons(struct iwl_mvm *mvm, · 2 unmodified lines | ||
| 1517 | 1521 | if (!pkt) |
| 1518 | 1522 | goto report; |
| 1519 | 1523 | |
| 1520 | − skb_put_data(pkt, pktdata, hdrlen); | |
| 1521 | − pktdata += hdrlen; | |
| 1522 | − pktsize -= hdrlen; | |
| 1523 | − | |
| 1524 | 1524 | if (ieee80211_has_protected(hdr->frame_control)) { |
| 1525 | 1525 | /* |
| 1526 | 1526 | * This is unlocked and using gtk_i(c)vlen, |
| @@ -1539,13 +1539,24 @@ static void iwl_mvm_report_wakeup_reasons(struct iwl_mvm *mvm, · 12 unmodified lines | ||
| 1539 | 1539 | |
| 1540 | 1540 | /* if truncated, FCS/ICV is (partially) gone */ |
| 1541 | 1541 | if (truncated >= icvlen) { |
| 1542 | − icvlen = 0; | |
| 1543 | 1542 | truncated -= icvlen; |
| 1543 | + icvlen = 0; | |
| 1544 | 1544 | } else { |
| 1545 | 1545 | icvlen -= truncated; |
| 1546 | 1546 | truncated = 0; |
| 1547 | 1547 | } |
| 1548 | 1548 | |
| 1549 | + if (IWL_FW_CHECK(mvm, | |
| 1550 | + pktsize <= hdrlen + ivlen + icvlen, | |
| 1551 | + "pktsize is too small %d\n", | |
| 1552 | + pktsize)) { | |
| 1553 | + kfree_skb(pkt); | |
| 1554 | + return; | |
| 1555 | + } | |
| 1556 | + | |
| 1557 | + skb_put_data(pkt, pktdata, hdrlen); | |
| 1558 | + pktdata += hdrlen; | |
| 1559 | + pktsize -= hdrlen; | |
| 1549 | 1560 | pktsize -= ivlen + icvlen; |
| 1550 | 1561 | pktdata += ivlen; |
| 1551 | 1562 | |
| @@ -2123,16 +2134,16 @@ static void iwl_mvm_parse_wowlan_info_notif(struct iwl_mvm *mvm, · 571 unmodified lines | ||
| 2123 | 2134 | struct iwl_wowlan_status_data *status, |
| 2124 | 2135 | u32 len) |
| 2125 | 2136 | { |
| 2126 | − if (IWL_FW_CHECK(mvm, data->num_mlo_link_keys, | |
| 2127 | − "MLO is not supported, shouldn't receive MLO keys\n")) | |
| 2128 | − return; | |
| 2129 | − | |
| 2130 | 2137 | if (len < sizeof(*data)) { |
| 2131 | 2138 | IWL_ERR(mvm, "Invalid WoWLAN info notification!\n"); |
| 2132 | 2139 | status = NULL; |
| 2133 | 2140 | return; |
| 2134 | 2141 | } |
| 2135 | 2142 | |
| 2143 | + if (IWL_FW_CHECK(mvm, data->num_mlo_link_keys, | |
| 2144 | + "MLO is not supported, shouldn't receive MLO keys\n")) | |
| 2145 | + return; | |
| 2146 | + | |
| 2136 | 2147 | if (mvm->fast_resume) |
| 2137 | 2148 | return; |
| 2138 | 2149 | |
| @@ -2448,13 +2459,15 @@ iwl_mvm_netdetect_query_results(struct iwl_mvm *mvm, · 309 unmodified lines | ||
| 2448 | 2459 | |
| 2449 | 2460 | if (fw_has_api(&mvm->fw->ucode_capa, |
| 2450 | 2461 | IWL_UCODE_TLV_API_SCAN_OFFLOAD_CHANS)) { |
| 2451 | − query_len = sizeof(struct iwl_scan_offload_match_info); | |
| 2452 | 2462 | matches_len = sizeof(struct iwl_scan_offload_profile_match) * |
| 2453 | 2463 | max_profiles; |
| 2464 | + query_len = offsetof(struct iwl_scan_offload_match_info, | |
| 2465 | + matches) + matches_len; | |
| 2454 | 2466 | } else { |
| 2455 | − query_len = sizeof(struct iwl_scan_offload_profiles_query_v1); | |
| 2456 | 2467 | matches_len = sizeof(struct iwl_scan_offload_profile_match_v1) * |
| 2457 | 2468 | max_profiles; |
| 2469 | + query_len = sizeof(struct iwl_scan_offload_profiles_query_v1) + | |
| 2470 | + matches_len; | |
| 2458 | 2471 | } |
| 2459 | 2472 | |
| 2460 | 2473 | len = iwl_rx_packet_payload_len(cmd.resp_pkt); |
| @@ -2756,7 +2769,7 @@ static int iwl_mvm_wowlan_store_wake_pkt(struct iwl_mvm *mvm, · 295 unmodified lines | ||
| 2756 | 2769 | struct iwl_wowlan_status_data *status, |
| 2757 | 2770 | u32 len) |
| 2758 | 2771 | { |
| 2759 | − u32 data_size, packet_len = le32_to_cpu(notif->wake_packet_length); | |
| 2772 | + u32 data_size, packet_len; | |
| 2760 | 2773 | |
| 2761 | 2774 | if (len < sizeof(*notif)) { |
| 2762 | 2775 | IWL_ERR(mvm, "Invalid WoWLAN wake packet notification!\n"); |
| @@ -2775,6 +2788,7 @@ static int iwl_mvm_wowlan_store_wake_pkt(struct iwl_mvm *mvm, · 12 unmodified lines | ||
| 2775 | 2788 | return -EIO; |
| 2776 | 2789 | } |
| 2777 | 2790 | |
| 2791 | + packet_len = le32_to_cpu(notif->wake_packet_length); | |
| 2778 | 2792 | data_size = len - offsetof(struct iwl_wowlan_wake_pkt_notif, wake_packet); |
| 2779 | 2793 | |
| 2780 | 2794 | /* data_size got the padding from the notification, remove it. */ |
| @@ -2807,7 +2821,8 @@ static void iwl_mvm_nd_match_info_handler(struct iwl_mvm *mvm, · 26 unmodified lines | ||
| 2807 | 2821 | if (IS_ERR_OR_NULL(vif)) |
| 2808 | 2822 | return; |
| 2809 | 2823 | |
| 2810 | − if (len < sizeof(struct iwl_scan_offload_match_info) + matches_len) { | |
| 2824 | + if (len < offsetof(struct iwl_scan_offload_match_info, matches) + | |
| 2825 | + matches_len) { | |
| 2811 | 2826 | IWL_ERR(mvm, "Invalid scan match info notification\n"); |
| 2812 | 2827 | return; |
| 2813 | 2828 | } |
| @@ -2942,6 +2957,11 @@ static bool iwl_mvm_wait_d3_notif(struct iwl_notif_wait_data *notif_wait, · 128 unmodified lines | ||
| 2942 | 2957 | case WIDE_ID(PROT_OFFLOAD_GROUP, D3_END_NOTIFICATION): { |
| 2943 | 2958 | struct iwl_d3_end_notif *notif = (void *)pkt->data; |
| 2944 | 2959 | |
| 2960 | + if (len < sizeof(*notif)) { | |
| 2961 | + IWL_ERR(mvm, "Invalid D3 end notification size\n"); | |
| 2962 | + break; | |
| 2963 | + } | |
| 2964 | + | |
| 2945 | 2965 | d3_data->d3_end_flags = __le32_to_cpu(notif->flags); |
| 2946 | 2966 | d3_data->notif_received |= IWL_D3_NOTIF_D3_END_NOTIF; |
| 2947 | 2967 | |
| @@ -646,7 +646,8 @@ static void iter(struct ieee80211_hw *hw, · 645 unmodified lines | ||
| 646 | 646 | WARN_ON(*target->cipher == IWL_LOCATION_CIPHER_INVALID); |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | −static void | |
| 649 | +/* The tk buffer is assumed to be exactly TK_11AZ_LEN bytes */ | |
| 650 | +static int | |
| 650 | 651 | iwl_mvm_ftm_set_secured_ranging(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 651 | 652 | u8 *bssid, u8 *cipher, u8 *hltk, u8 *tk, |
| 652 | 653 | u8 *rx_pn, u8 *tx_pn, __le32 *flags) |
| @@ -656,12 +657,12 @@ iwl_mvm_ftm_set_secured_ranging(struct iwl_mvm *mvm, struct ieee80211_vif *vif, · 3 unmodified lines | ||
| 656 | 657 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 657 | 658 | |
| 658 | 659 | if (mvmvif->ftm_unprotected) |
| 659 | − return; | |
| 660 | + return 0; | |
| 660 | 661 | #endif |
| 661 | 662 | |
| 662 | 663 | if (!(le32_to_cpu(*flags) & (IWL_INITIATOR_AP_FLAGS_NON_TB | |
| 663 | 664 | IWL_INITIATOR_AP_FLAGS_TB))) |
| 664 | − return; | |
| 665 | + return 0; | |
| 665 | 666 | |
| 666 | 667 | lockdep_assert_held(&mvm->mutex); |
| 667 | 668 | |
| @@ -679,14 +680,31 @@ iwl_mvm_ftm_set_secured_ranging(struct iwl_mvm *mvm, struct ieee80211_vif *vif, · 11 unmodified lines | ||
| 679 | 680 | if (vif->cfg.assoc && |
| 680 | 681 | !memcmp(vif->bss_conf.bssid, bssid, ETH_ALEN)) { |
| 681 | 682 | struct iwl_mvm_ftm_iter_data target; |
| 683 | + u32 key_len; | |
| 682 | 684 | |
| 683 | 685 | target.bssid = bssid; |
| 684 | 686 | target.cipher = cipher; |
| 685 | 687 | target.tk = NULL; |
| 686 | 688 | ieee80211_iter_keys(mvm->hw, vif, iter, &target); |
| 687 | 689 | |
| 688 | − if (!WARN_ON(!target.tk)) | |
| 689 | − memcpy(tk, target.tk, TK_11AZ_LEN); | |
| 690 | + if (WARN_ON(!target.tk)) | |
| 691 | + return -EINVAL; | |
| 692 | + | |
| 693 | + switch (*target.cipher) { | |
| 694 | + case IWL_LOCATION_CIPHER_CCMP_128: | |
| 695 | + case IWL_LOCATION_CIPHER_GCMP_128: | |
| 696 | + key_len = WLAN_KEY_LEN_CCMP; | |
| 697 | + break; | |
| 698 | + case IWL_LOCATION_CIPHER_GCMP_256: | |
| 699 | + key_len = WLAN_KEY_LEN_GCMP_256; | |
| 700 | + break; | |
| 701 | + default: | |
| 702 | + WARN_ON(1); | |
| 703 | + return -EINVAL; | |
| 704 | + } | |
| 705 | + | |
| 706 | + memset(tk, 0, TK_11AZ_LEN); | |
| 707 | + memcpy(tk, target.tk, key_len); | |
| 690 | 708 | } else { |
| 691 | 709 | memcpy(tk, entry->tk, sizeof(entry->tk)); |
| 692 | 710 | } |
| @@ -695,8 +713,10 @@ iwl_mvm_ftm_set_secured_ranging(struct iwl_mvm *mvm, struct ieee80211_vif *vif, · 2 unmodified lines | ||
| 695 | 713 | memcpy(tx_pn, entry->tx_pn, sizeof(entry->tx_pn)); |
| 696 | 714 | |
| 697 | 715 | FTM_SET_FLAG(SECURED); |
| 698 | − return; | |
| 716 | + return 0; | |
| 699 | 717 | } |
| 718 | + | |
| 719 | + return 0; | |
| 700 | 720 | } |
| 701 | 721 | |
| 702 | 722 | static int |
| @@ -708,12 +728,11 @@ iwl_mvm_ftm_put_target_v7(struct iwl_mvm *mvm, struct ieee80211_vif *vif, · 5 unmodified lines | ||
| 708 | 728 | if (err) |
| 709 | 729 | return err; |
| 710 | 730 | |
| 711 | − iwl_mvm_ftm_set_secured_ranging(mvm, vif, target->bssid, | |
| 712 | − &target->cipher, target->hltk, | |
| 713 | − target->tk, target->rx_pn, | |
| 714 | − target->tx_pn, | |
| 715 | − &target->initiator_ap_flags); | |
| 716 | − return err; | |
| 731 | + return iwl_mvm_ftm_set_secured_ranging(mvm, vif, target->bssid, | |
| 732 | + &target->cipher, target->hltk, | |
| 733 | + target->tk, target->rx_pn, | |
| 734 | + target->tx_pn, | |
| 735 | + &target->initiator_ap_flags); | |
| 717 | 736 | } |
| 718 | 737 | |
| 719 | 738 | static int iwl_mvm_ftm_start_v11(struct iwl_mvm *mvm, |
| @@ -881,11 +900,13 @@ iwl_mvm_ftm_put_target_v10(struct iwl_mvm *mvm, struct ieee80211_vif *vif, · 161 unmodified lines | ||
| 881 | 900 | iwl_mvm_ftm_set_target_flags(mvm, peer, &target->initiator_ap_flags); |
| 882 | 901 | iwl_mvm_ftm_set_sta(mvm, vif, peer, &target->sta_id, |
| 883 | 902 | &target->initiator_ap_flags); |
| 884 | − iwl_mvm_ftm_set_secured_ranging(mvm, vif, target->bssid, | |
| 885 | − &target->cipher, target->hltk, | |
| 886 | − target->tk, target->rx_pn, | |
| 887 | − target->tx_pn, | |
| 888 | − &target->initiator_ap_flags); | |
| 903 | + ret = iwl_mvm_ftm_set_secured_ranging(mvm, vif, target->bssid, | |
| 904 | + &target->cipher, target->hltk, | |
| 905 | + target->tk, target->rx_pn, | |
| 906 | + target->tx_pn, | |
| 907 | + &target->initiator_ap_flags); | |
| 908 | + if (ret) | |
| 909 | + return ret; | |
| 889 | 910 | |
| 890 | 911 | i2r_max_sts = IWL_MVM_FTM_I2R_MAX_STS > 1 ? 1 : |
| 891 | 912 | IWL_MVM_FTM_I2R_MAX_STS; |
| @@ -964,12 +964,22 @@ int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm) · 963 unmodified lines | ||
| 964 | 964 | return ret; |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | + if (IWL_FW_CHECK(mvm, | |
| 968 | + iwl_rx_packet_payload_len(cmd.resp_pkt) != | |
| 969 | + sizeof(*resp), | |
| 970 | + "Wrong size for iwl_geo_tx_power_profiles_resp: %d\n", | |
| 971 | + iwl_rx_packet_payload_len(cmd.resp_pkt))) { | |
| 972 | + ret = -EIO; | |
| 973 | + goto out; | |
| 974 | + } | |
| 975 | + | |
| 967 | 976 | resp = (void *)cmd.resp_pkt->data; |
| 968 | 977 | ret = le32_to_cpu(resp->profile_idx); |
| 969 | 978 | |
| 970 | 979 | if (WARN_ON(ret > BIOS_GEO_MAX_PROFILE_NUM)) |
| 971 | 980 | ret = -EIO; |
| 972 | 981 | |
| 982 | +out: | |
| 973 | 983 | iwl_free_resp(&cmd); |
| 974 | 984 | return ret; |
| 975 | 985 | } |
| @@ -1493,49 +1493,54 @@ void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm, · 1492 unmodified lines | ||
| 1493 | 1493 | { |
| 1494 | 1494 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 1495 | 1495 | unsigned int pkt_len = iwl_rx_packet_payload_len(pkt); |
| 1496 | − struct iwl_extended_beacon_notif *beacon = (void *)pkt->data; | |
| 1497 | − struct iwl_extended_beacon_notif_v5 *beacon_v5 = (void *)pkt->data; | |
| 1498 | 1496 | struct ieee80211_vif *csa_vif; |
| 1499 | 1497 | struct ieee80211_vif *tx_blocked_vif; |
| 1500 | 1498 | struct agg_tx_status *agg_status; |
| 1499 | + u32 beacon_gp2; | |
| 1501 | 1500 | u16 status; |
| 1502 | 1501 | |
| 1503 | 1502 | lockdep_assert_held(&mvm->mutex); |
| 1504 | 1503 | |
| 1505 | − mvm->ap_last_beacon_gp2 = le32_to_cpu(beacon->gp2); | |
| 1506 | − | |
| 1507 | 1504 | if (!iwl_mvm_is_short_beacon_notif_supported(mvm)) { |
| 1505 | + struct iwl_extended_beacon_notif_v5 *beacon = (void *)pkt->data; | |
| 1508 | 1506 | struct iwl_tx_resp *beacon_notify_hdr = |
| 1509 | − &beacon_v5->beacon_notify_hdr; | |
| 1507 | + &beacon->beacon_notify_hdr; | |
| 1510 | 1508 | |
| 1511 | − if (unlikely(pkt_len < sizeof(*beacon_v5))) | |
| 1509 | + if (unlikely(pkt_len < sizeof(*beacon))) | |
| 1512 | 1510 | return; |
| 1513 | 1511 | |
| 1514 | − mvm->ibss_manager = beacon_v5->ibss_mgr_status != 0; | |
| 1512 | + beacon_gp2 = le32_to_cpu(beacon->gp2); | |
| 1513 | + | |
| 1514 | + mvm->ibss_manager = beacon->ibss_mgr_status != 0; | |
| 1515 | 1515 | agg_status = iwl_mvm_get_agg_status(mvm, beacon_notify_hdr); |
| 1516 | 1516 | status = le16_to_cpu(agg_status->status) & TX_STATUS_MSK; |
| 1517 | 1517 | IWL_DEBUG_RX(mvm, |
| 1518 | 1518 | "beacon status %#x retries:%d tsf:0x%016llX gp2:0x%X rate:%d\n", |
| 1519 | 1519 | status, beacon_notify_hdr->failure_frame, |
| 1520 | 1520 | le64_to_cpu(beacon->tsf), |
| 1521 | − mvm->ap_last_beacon_gp2, | |
| 1521 | + beacon_gp2, | |
| 1522 | 1522 | le32_to_cpu(beacon_notify_hdr->initial_rate)); |
| 1523 | 1523 | } else { |
| 1524 | + const struct iwl_extended_beacon_notif *beacon = | |
| 1525 | + (void *)pkt->data; | |
| 1526 | + | |
| 1524 | 1527 | if (unlikely(pkt_len < sizeof(*beacon))) |
| 1525 | 1528 | return; |
| 1526 | 1529 | |
| 1530 | + beacon_gp2 = le32_to_cpu(beacon->gp2); | |
| 1531 | + | |
| 1527 | 1532 | mvm->ibss_manager = beacon->ibss_mgr_status != 0; |
| 1528 | 1533 | status = le32_to_cpu(beacon->status) & TX_STATUS_MSK; |
| 1529 | 1534 | IWL_DEBUG_RX(mvm, |
| 1530 | 1535 | "beacon status %#x tsf:0x%016llX gp2:0x%X\n", |
| 1531 | 1536 | status, le64_to_cpu(beacon->tsf), |
| 1532 | − mvm->ap_last_beacon_gp2); | |
| 1537 | + beacon_gp2); | |
| 1533 | 1538 | } |
| 1534 | 1539 | |
| 1535 | 1540 | csa_vif = rcu_dereference_protected(mvm->csa_vif, |
| 1536 | 1541 | lockdep_is_held(&mvm->mutex)); |
| 1537 | 1542 | if (unlikely(csa_vif && csa_vif->bss_conf.csa_active)) |
| 1538 | − iwl_mvm_csa_count_down(mvm, csa_vif, mvm->ap_last_beacon_gp2, | |
| 1543 | + iwl_mvm_csa_count_down(mvm, csa_vif, beacon_gp2, | |
| 1539 | 1544 | (status == TX_STATUS_SUCCESS)); |
| 1540 | 1545 | |
| 1541 | 1546 | tx_blocked_vif = rcu_dereference_protected(mvm->csa_tx_blocked_vif, |
| @@ -625,9 +625,7 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) · 624 unmodified lines | ||
| 625 | 625 | hw->wiphy->max_sched_scan_reqs = 1; |
| 626 | 626 | hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX; |
| 627 | 627 | hw->wiphy->max_match_sets = iwl_umac_scan_get_max_profiles(mvm->fw); |
| 628 | − /* we create the 802.11 header and zero length SSID IE. */ | |
| 629 | − hw->wiphy->max_sched_scan_ie_len = | |
| 630 | − SCAN_OFFLOAD_PROBE_REQ_SIZE - 24 - 2; | |
| 628 | + hw->wiphy->max_sched_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm); | |
| 631 | 629 | hw->wiphy->max_sched_scan_plans = IWL_MAX_SCHED_SCAN_PLANS; |
| 632 | 630 | hw->wiphy->max_sched_scan_plan_interval = U16_MAX; |
| 633 | 631 | |
| @@ -3061,7 +3059,6 @@ void iwl_mvm_stop_ap_ibss_common(struct iwl_mvm *mvm, · 2427 unmodified lines | ||
| 3061 | 3059 | } |
| 3062 | 3060 | |
| 3063 | 3061 | mvmvif->ap_ibss_active = false; |
| 3064 | − mvm->ap_last_beacon_gp2 = 0; | |
| 3065 | 3062 | |
| 3066 | 3063 | if (vif->type == NL80211_IFTYPE_AP && !vif->p2p) { |
| 3067 | 3064 | iwl_mvm_vif_set_low_latency(mvmvif, false, |
| @@ -3490,7 +3487,7 @@ static void iwl_mvm_check_he_obss_narrow_bw_ru_iter(struct wiphy *wiphy, · 422 unmodified lines | ||
| 3490 | 3487 | elem = cfg80211_find_elem(WLAN_EID_EXT_CAPABILITY, ies->data, |
| 3491 | 3488 | ies->len); |
| 3492 | 3489 | |
| 3493 | − if (!elem || elem->datalen < 10 || | |
| 3490 | + if (!elem || elem->datalen < 11 || | |
| 3494 | 3491 | !(elem->data[10] & |
| 3495 | 3492 | WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT)) { |
| 3496 | 3493 | data->tolerated = false; |
| @@ -1168,9 +1168,6 @@ struct iwl_mvm { · 1167 unmodified lines | ||
| 1168 | 1168 | struct ieee80211_vif __rcu *csa_tx_blocked_vif; |
| 1169 | 1169 | u8 csa_tx_block_bcn_timeout; |
| 1170 | 1170 | |
| 1171 | − /* system time of last beacon (for AP/GO interface) */ | |
| 1172 | − u32 ap_last_beacon_gp2; | |
| 1173 | − | |
| 1174 | 1171 | /* indicates that we transmitted the last beacon */ |
| 1175 | 1172 | bool ibss_manager; |
| 1176 | 1173 | |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 2 | 2 | /* |
| 3 | − * Copyright (C) 2012-2014, 2018-2019, 2021-2025 Intel Corporation | |
| 3 | + * Copyright (C) 2012-2014, 2018-2019, 2021-2026 Intel Corporation | |
| 4 | 4 | * Copyright (C) 2013-2015 Intel Mobile Communications GmbH |
| 5 | 5 | * Copyright (C) 2016-2017 Intel Deutschland GmbH |
| 6 | 6 | */ |
| @@ -416,6 +416,7 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2, · 409 unmodified lines | ||
| 416 | 416 | int ret, resp_ver; |
| 417 | 417 | u32 status; |
| 418 | 418 | int resp_len, n_channels; |
| 419 | + unsigned int pkt_len; | |
| 419 | 420 | u16 mcc; |
| 420 | 421 | |
| 421 | 422 | if (WARN_ON_ONCE(!iwl_mvm_is_lar_supported(mvm))) |
| @@ -431,6 +432,7 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2, · 9 unmodified lines | ||
| 431 | 432 | return ERR_PTR(ret); |
| 432 | 433 | |
| 433 | 434 | pkt = cmd.resp_pkt; |
| 435 | + pkt_len = iwl_rx_packet_payload_len(pkt); | |
| 434 | 436 | |
| 435 | 437 | resp_ver = iwl_fw_lookup_notif_ver(mvm->fw, IWL_ALWAYS_LONG_GROUP, |
| 436 | 438 | MCC_UPDATE_CMD, 0); |
| @@ -439,9 +441,18 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2, · 2 unmodified lines | ||
| 439 | 441 | if (resp_ver >= 8) { |
| 440 | 442 | struct iwl_mcc_update_resp_v8 *mcc_resp_v8 = (void *)pkt->data; |
| 441 | 443 | |
| 444 | + if (IWL_FW_CHECK(mvm, pkt_len < sizeof(*mcc_resp_v8), | |
| 445 | + "MCC v8 response too short: %u\n", pkt_len)) { | |
| 446 | + resp_cp = ERR_PTR(-EINVAL); | |
| 447 | + goto exit; | |
| 448 | + } | |
| 449 | + | |
| 442 | 450 | n_channels = __le32_to_cpu(mcc_resp_v8->n_channels); |
| 443 | − if (iwl_rx_packet_payload_len(pkt) != | |
| 444 | − struct_size(mcc_resp_v8, channels, n_channels)) { | |
| 451 | + if (IWL_FW_CHECK(mvm, | |
| 452 | + pkt_len != | |
| 453 | + struct_size(mcc_resp_v8, channels, n_channels), | |
| 454 | + "invalid MCC v8 response size: %u (n_channels=%d)\n", | |
| 455 | + pkt_len, n_channels)) { | |
| 445 | 456 | resp_cp = ERR_PTR(-EINVAL); |
| 446 | 457 | goto exit; |
| 447 | 458 | } |
| @@ -464,9 +475,18 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2, · 16 unmodified lines | ||
| 464 | 475 | IWL_UCODE_TLV_CAPA_MCC_UPDATE_11AX_SUPPORT)) { |
| 465 | 476 | struct iwl_mcc_update_resp_v4 *mcc_resp_v4 = (void *)pkt->data; |
| 466 | 477 | |
| 478 | + if (IWL_FW_CHECK(mvm, pkt_len < sizeof(*mcc_resp_v4), | |
| 479 | + "MCC v4 response too short: %u\n", pkt_len)) { | |
| 480 | + resp_cp = ERR_PTR(-EINVAL); | |
| 481 | + goto exit; | |
| 482 | + } | |
| 483 | + | |
| 467 | 484 | n_channels = __le32_to_cpu(mcc_resp_v4->n_channels); |
| 468 | − if (iwl_rx_packet_payload_len(pkt) != | |
| 469 | − struct_size(mcc_resp_v4, channels, n_channels)) { | |
| 485 | + if (IWL_FW_CHECK(mvm, | |
| 486 | + pkt_len != | |
| 487 | + struct_size(mcc_resp_v4, channels, n_channels), | |
| 488 | + "invalid MCC v4 response size: %u (n_channels=%d)\n", | |
| 489 | + pkt_len, n_channels)) { | |
| 470 | 490 | resp_cp = ERR_PTR(-EINVAL); |
| 471 | 491 | goto exit; |
| 472 | 492 | } |
| @@ -489,9 +509,18 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2, · 16 unmodified lines | ||
| 489 | 509 | } else { |
| 490 | 510 | struct iwl_mcc_update_resp_v3 *mcc_resp_v3 = (void *)pkt->data; |
| 491 | 511 | |
| 512 | + if (IWL_FW_CHECK(mvm, pkt_len < sizeof(*mcc_resp_v3), | |
| 513 | + "MCC v3 response too short: %u\n", pkt_len)) { | |
| 514 | + resp_cp = ERR_PTR(-EINVAL); | |
| 515 | + goto exit; | |
| 516 | + } | |
| 517 | + | |
| 492 | 518 | n_channels = __le32_to_cpu(mcc_resp_v3->n_channels); |
| 493 | − if (iwl_rx_packet_payload_len(pkt) != | |
| 494 | − struct_size(mcc_resp_v3, channels, n_channels)) { | |
| 519 | + if (IWL_FW_CHECK(mvm, | |
| 520 | + pkt_len != | |
| 521 | + struct_size(mcc_resp_v3, channels, n_channels), | |
| 522 | + "invalid MCC v3 response size: %u (n_channels=%d)\n", | |
| 523 | + pkt_len, n_channels)) { | |
| 495 | 524 | resp_cp = ERR_PTR(-EINVAL); |
| 496 | 525 | goto exit; |
| 497 | 526 | } |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 2 | 2 | /* |
| 3 | − * Copyright (C) 2021 - 2023, 2025 Intel Corporation | |
| 3 | + * Copyright (C) 2021 - 2023, 2025-2026 Intel Corporation | |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | #include "mvm.h" |
| @@ -121,6 +121,8 @@ iwl_mvm_get_crosstimestamp_fw(struct iwl_mvm *mvm, u32 *gp2, u64 *sys_time) · 114 unmodified lines | ||
| 121 | 121 | *sys_time = (u64)le32_to_cpu(resp->platform_timestamp_hi) << 32 | |
| 122 | 122 | le32_to_cpu(resp->platform_timestamp_lo); |
| 123 | 123 | |
| 124 | + iwl_free_resp(&cmd); | |
| 125 | + | |
| 124 | 126 | return ret; |
| 125 | 127 | } |
| 126 | 128 | |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 2 | 2 | /* |
| 3 | 3 | * Copyright (C) 2017 Intel Deutschland GmbH |
| 4 | − * Copyright (C) 2018-2025 Intel Corporation | |
| 4 | + * Copyright (C) 2018-2026 Intel Corporation | |
| 5 | 5 | */ |
| 6 | 6 | #include "rs.h" |
| 7 | 7 | #include "fw-api.h" |
| @@ -423,9 +423,14 @@ void iwl_mvm_tlc_update_notif(struct iwl_mvm *mvm, · 415 unmodified lines | ||
| 423 | 423 | struct iwl_lq_sta_rs_fw *lq_sta; |
| 424 | 424 | u32 flags; |
| 425 | 425 | |
| 426 | + notif = (void *)pkt->data; | |
| 427 | + if (IWL_FW_CHECK(mvm, notif->sta_id >= mvm->fw->ucode_capa.num_stations, | |
| 428 | + "Invalid sta id (%d) in TLC notification\n", | |
| 429 | + notif->sta_id)) | |
| 430 | + return; | |
| 431 | + | |
| 426 | 432 | rcu_read_lock(); |
| 427 | 433 | |
| 428 | − notif = (void *)pkt->data; | |
| 429 | 434 | link_sta = rcu_dereference(mvm->fw_id_to_link_sta[notif->sta_id]); |
| 430 | 435 | sta = rcu_dereference(mvm->fw_id_to_mac_id[notif->sta_id]); |
| 431 | 436 | if (IS_ERR_OR_NULL(sta) || !link_sta) { |
| @@ -1227,6 +1227,11 @@ void iwl_mvm_window_status_notif(struct iwl_mvm *mvm, · 1226 unmodified lines | ||
| 1227 | 1227 | /* get the station */ |
| 1228 | 1228 | sta_id = (ratid & BA_WINDOW_STATUS_STA_ID_MSK) |
| 1229 | 1229 | >> BA_WINDOW_STATUS_STA_ID_POS; |
| 1230 | + if (IWL_FW_CHECK(mvm, | |
| 1231 | + sta_id >= mvm->fw->ucode_capa.num_stations, | |
| 1232 | + "Invalid sta id (%d) in BA window status notification\n", | |
| 1233 | + sta_id)) | |
| 1234 | + continue; | |
| 1230 | 1235 | sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); |
| 1231 | 1236 | if (IS_ERR_OR_NULL(sta)) |
| 1232 | 1237 | continue; |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 2 | 2 | /* |
| 3 | − * Copyright (C) 2012-2014, 2018-2025 Intel Corporation | |
| 3 | + * Copyright (C) 2012-2014, 2018-2026 Intel Corporation | |
| 4 | 4 | * Copyright (C) 2013-2015 Intel Mobile Communications GmbH |
| 5 | 5 | * Copyright (C) 2016-2017 Intel Deutschland GmbH |
| 6 | 6 | */ |
| @@ -3144,8 +3144,6 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm, · 3137 unmodified lines | ||
| 3144 | 3144 | if (ret) |
| 3145 | 3145 | return ret; |
| 3146 | 3146 | |
| 3147 | − iwl_mvm_build_scan_probe(mvm, vif, ies, ¶ms); | |
| 3148 | − | |
| 3149 | 3147 | /* for 6 GHZ band only PSC channels need to be added */ |
| 3150 | 3148 | for (i = 0; i < params.n_channels; i++) { |
| 3151 | 3149 | struct ieee80211_channel *channel = params.channels[i]; |
| @@ -3179,6 +3177,8 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm, · 27 unmodified lines | ||
| 3179 | 3177 | goto out; |
| 3180 | 3178 | } |
| 3181 | 3179 | |
| 3180 | + iwl_mvm_build_scan_probe(mvm, vif, ies, ¶ms); | |
| 3181 | + | |
| 3182 | 3182 | uid = iwl_mvm_build_scan_cmd(mvm, vif, &hcmd, ¶ms, type); |
| 3183 | 3183 | if (uid < 0) { |
| 3184 | 3184 | ret = uid; |
| @@ -3217,6 +3217,10 @@ void iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm, · 32 unmodified lines | ||
| 3217 | 3217 | |
| 3218 | 3218 | mvm->mei_scan_filter.is_mei_limited_scan = false; |
| 3219 | 3219 | |
| 3220 | + if (IWL_FW_CHECK(mvm, uid >= ARRAY_SIZE(mvm->scan_uid_status), | |
| 3221 | + "FW reports out-of-range scan UID %d\n", uid)) | |
| 3222 | + return; | |
| 3223 | + | |
| 3220 | 3224 | IWL_DEBUG_SCAN(mvm, |
| 3221 | 3225 | "Scan completed: uid=%u type=%u, status=%s, EBS=%s\n", |
| 3222 | 3226 | uid, mvm->scan_uid_status[uid], |
| @@ -951,6 +951,11 @@ void iwl_mvm_rx_session_protect_notif(struct iwl_mvm *mvm, · 950 unmodified lines | ||
| 951 | 951 | struct ieee80211_vif *vif; |
| 952 | 952 | struct iwl_mvm_vif *mvmvif; |
| 953 | 953 | |
| 954 | + if (IWL_FW_CHECK(mvm, id >= ARRAY_SIZE(mvm->vif_id_to_mac), | |
| 955 | + "Invalid mac_link_id (%d) in session protect notif\n", | |
| 956 | + id)) | |
| 957 | + return; | |
| 958 | + | |
| 954 | 959 | rcu_read_lock(); |
| 955 | 960 | |
| 956 | 961 | /* note we use link ID == MAC ID */ |
| @@ -1544,6 +1544,17 @@ static inline u32 iwl_mvm_get_scd_ssn(struct iwl_mvm *mvm, · 1543 unmodified lines | ||
| 1544 | 1544 | return val & 0xFFF; |
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | +static inline size_t iwl_mvm_tx_resp_min_len(struct iwl_mvm *mvm, | |
| 1548 | + struct iwl_tx_resp *tx_resp) | |
| 1549 | +{ | |
| 1550 | + struct agg_tx_status *agg_status = | |
| 1551 | + iwl_mvm_get_agg_status(mvm, tx_resp); | |
| 1552 | + | |
| 1553 | + /* The aggregate response ends with a trailing SCD SSN __le32 word. */ | |
| 1554 | + return (u8 *)(agg_status + tx_resp->frame_count) - (u8 *)tx_resp + | |
| 1555 | + sizeof(__le32); | |
| 1556 | +} | |
| 1557 | + | |
| 1547 | 1558 | static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm, |
| 1548 | 1559 | struct iwl_rx_packet *pkt) |
| 1549 | 1560 | { |
| @@ -1847,6 +1858,9 @@ static void iwl_mvm_rx_tx_cmd_agg(struct iwl_mvm *mvm, · 297 unmodified lines | ||
| 1847 | 1858 | int queue = SEQ_TO_QUEUE(sequence); |
| 1848 | 1859 | struct ieee80211_sta *sta; |
| 1849 | 1860 | |
| 1861 | + if (WARN_ON_ONCE(iwl_mvm_has_new_tx_api(mvm))) | |
| 1862 | + return; | |
| 1863 | + | |
| 1850 | 1864 | if (WARN_ON_ONCE(queue < IWL_MVM_DQA_MIN_DATA_QUEUE && |
| 1851 | 1865 | (queue != IWL_MVM_DQA_BSS_CLIENT_QUEUE))) |
| 1852 | 1866 | return; |
| @@ -1881,6 +1895,26 @@ void iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) · 28 unmodified lines | ||
| 1881 | 1895 | { |
| 1882 | 1896 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 1883 | 1897 | struct iwl_tx_resp *tx_resp = (void *)pkt->data; |
| 1898 | + size_t min_len; | |
| 1899 | + | |
| 1900 | + if (IWL_FW_CHECK(mvm, !tx_resp->frame_count, | |
| 1901 | + "invalid TX_CMD frame_count %u\n", | |
| 1902 | + tx_resp->frame_count)) | |
| 1903 | + return; | |
| 1904 | + | |
| 1905 | + if (IWL_FW_CHECK(mvm, | |
| 1906 | + iwl_mvm_has_new_tx_api(mvm) && | |
| 1907 | + tx_resp->frame_count != 1, | |
| 1908 | + "invalid TX_CMD frame_count %u for new TX API\n", | |
| 1909 | + tx_resp->frame_count)) | |
| 1910 | + return; | |
| 1911 | + | |
| 1912 | + min_len = iwl_mvm_tx_resp_min_len(mvm, tx_resp); | |
| 1913 | + if (IWL_FW_CHECK(mvm, iwl_rx_packet_payload_len(pkt) < min_len, | |
| 1914 | + "invalid TX_CMD len %u (frame_count %u, min %zu)\n", | |
| 1915 | + iwl_rx_packet_payload_len(pkt), tx_resp->frame_count, | |
| 1916 | + min_len)) | |
| 1917 | + return; | |
| 1884 | 1918 | |
| 1885 | 1919 | if (tx_resp->frame_count == 1) |
| 1886 | 1920 | iwl_mvm_rx_tx_cmd_single(mvm, pkt); |
| @@ -2100,8 +2134,14 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) · 213 unmodified lines | ||
| 2100 | 2134 | if (tid == IWL_MGMT_TID) |
| 2101 | 2135 | tid = IWL_MAX_TID_COUNT; |
| 2102 | 2136 | |
| 2137 | + if (IWL_FW_CHECK(mvm, tid >= | |
| 2138 | + ARRAY_SIZE(mvmsta->tid_data), | |
| 2139 | + "invalid TID %d in compressed BA\n", | |
| 2140 | + tid)) | |
| 2141 | + continue; | |
| 2142 | + | |
| 2103 | 2143 | if (mvmsta) |
| 2104 | − mvmsta->tid_data[i].lq_color = lq_color; | |
| 2144 | + mvmsta->tid_data[tid].lq_color = lq_color; | |
| 2105 | 2145 | |
| 2106 | 2146 | iwl_mvm_tx_reclaim(mvm, sta_id, tid, |
| 2107 | 2147 | (int)(le16_to_cpu(ba_tfd->q_num)), |
| @@ -2121,6 +2161,9 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) · 13 unmodified lines | ||
| 2121 | 2161 | ba_notif = (void *)pkt->data; |
| 2122 | 2162 | sta_id = ba_notif->sta_id; |
| 2123 | 2163 | tid = ba_notif->tid; |
| 2164 | + if (IWL_FW_CHECK(mvm, tid >= ARRAY_SIZE(mvmsta->tid_data), | |
| 2165 | + "invalid TID %d in BA notif\n", tid)) | |
| 2166 | + return; | |
| 2124 | 2167 | /* "flow" corresponds to Tx queue */ |
| 2125 | 2168 | txq = le16_to_cpu(ba_notif->scd_flow); |
| 2126 | 2169 | /* "ssn" is start of block-ack Tx window, corresponds to index |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 2 | 2 | /* |
| 3 | 3 | * Copyright (C) 2017 Intel Deutschland GmbH |
| 4 | − * Copyright (C) 2018-2025 Intel Corporation | |
| 4 | + * Copyright (C) 2018-2026 Intel Corporation | |
| 5 | 5 | */ |
| 6 | 6 | #include "iwl-trans.h" |
| 7 | 7 | #include "iwl-fh.h" |
| @@ -99,6 +99,11 @@ int iwl_pcie_init_fw_sec(struct iwl_trans *trans, · 91 unmodified lines | ||
| 99 | 99 | /* add 2 due to separators */ |
| 100 | 100 | paging_cnt = iwl_pcie_get_num_sections(fw, lmac_cnt + umac_cnt + 2); |
| 101 | 101 | |
| 102 | + if (WARN_ON(lmac_cnt > ARRAY_SIZE(ctxt_dram->lmac_img) || | |
| 103 | + umac_cnt > ARRAY_SIZE(ctxt_dram->umac_img) || | |
| 104 | + paging_cnt > ARRAY_SIZE(ctxt_dram->virtual_img))) | |
| 105 | + return -EINVAL; | |
| 106 | + | |
| 102 | 107 | dram->fw = kzalloc_objs(*dram->fw, umac_cnt + lmac_cnt); |
| 103 | 108 | if (!dram->fw) |
| 104 | 109 | return -ENOMEM; |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 2 | 2 | /* |
| 3 | − * Copyright (C) 2003-2014, 2018-2024 Intel Corporation | |
| 3 | + * Copyright (C) 2003-2014, 2018-2024, 2026 Intel Corporation | |
| 4 | 4 | * Copyright (C) 2013-2015 Intel Mobile Communications GmbH |
| 5 | 5 | * Copyright (C) 2016-2017 Intel Deutschland GmbH |
| 6 | 6 | */ |
| @@ -1238,11 +1238,16 @@ void iwl_pcie_rx_free(struct iwl_trans *trans) · 1231 unmodified lines | ||
| 1238 | 1238 | } |
| 1239 | 1239 | } |
| 1240 | 1240 | kfree(trans_pcie->rx_pool); |
| 1241 | + trans_pcie->rx_pool = NULL; | |
| 1241 | 1242 | kfree(trans_pcie->global_table); |
| 1243 | + trans_pcie->global_table = NULL; | |
| 1242 | 1244 | kfree(trans_pcie->rxq); |
| 1245 | + trans_pcie->rxq = NULL; | |
| 1243 | 1246 | |
| 1244 | − if (trans_pcie->alloc_page) | |
| 1247 | + if (trans_pcie->alloc_page) { | |
| 1245 | 1248 | __free_pages(trans_pcie->alloc_page, trans_pcie->rx_page_order); |
| 1249 | + trans_pcie->alloc_page = NULL; | |
| 1250 | + } | |
| 1246 | 1251 | } |
| 1247 | 1252 | |
| 1248 | 1253 | static void iwl_pcie_rx_move_to_allocator(struct iwl_rxq *rxq, |
| @@ -823,7 +823,7 @@ struct chan_band_param_set { · 822 unmodified lines | ||
| 823 | 823 | |
| 824 | 824 | struct mwifiex_ie_types_chan_band_list_param_set { |
| 825 | 825 | struct mwifiex_ie_types_header header; |
| 826 | − struct chan_band_param_set chan_band_param[1]; | |
| 826 | + struct chan_band_param_set chan_band_param[]; | |
| 827 | 827 | } __packed; |
| 828 | 828 | |
| 829 | 829 | struct mwifiex_ie_types_rates_param_set { |
| @@ -886,7 +886,7 @@ struct mwifiex_ie_types_wildcard_ssid_params { · 56 unmodified lines | ||
| 886 | 886 | #define TSF_DATA_SIZE 8 |
| 887 | 887 | struct mwifiex_ie_types_tsf_timestamp { |
| 888 | 888 | struct mwifiex_ie_types_header header; |
| 889 | − u8 tsf_data[1]; | |
| 889 | + u8 tsf_data[]; | |
| 890 | 890 | } __packed; |
| 891 | 891 | |
| 892 | 892 | struct mwifiex_cf_param_set { |
| @@ -903,8 +903,8 @@ struct mwifiex_ibss_param_set { · 10 unmodified lines | ||
| 903 | 903 | struct mwifiex_ie_types_ss_param_set { |
| 904 | 904 | struct mwifiex_ie_types_header header; |
| 905 | 905 | union { |
| 906 | − struct mwifiex_cf_param_set cf_param_set[1]; | |
| 907 | − struct mwifiex_ibss_param_set ibss_param_set[1]; | |
| 906 | + DECLARE_FLEX_ARRAY(struct mwifiex_cf_param_set, cf_param_set); | |
| 907 | + DECLARE_FLEX_ARRAY(struct mwifiex_ibss_param_set, ibss_param_set); | |
| 908 | 908 | } cf_ibss; |
| 909 | 909 | } __packed; |
| 910 | 910 | |
| @@ -922,8 +922,8 @@ struct mwifiex_ds_param_set { · 11 unmodified lines | ||
| 922 | 922 | struct mwifiex_ie_types_phy_param_set { |
| 923 | 923 | struct mwifiex_ie_types_header header; |
| 924 | 924 | union { |
| 925 | − struct mwifiex_fh_param_set fh_param_set[1]; | |
| 926 | − struct mwifiex_ds_param_set ds_param_set[1]; | |
| 925 | + DECLARE_FLEX_ARRAY(struct mwifiex_fh_param_set, fh_param_set); | |
| 926 | + DECLARE_FLEX_ARRAY(struct mwifiex_ds_param_set, ds_param_set); | |
| 927 | 927 | } fh_ds; |
| 928 | 928 | } __packed; |
| 929 | 929 | |
| @@ -1383,7 +1383,7 @@ struct host_cmd_ds_802_11_snmp_mib { · 453 unmodified lines | ||
| 1383 | 1383 | __le16 query_type; |
| 1384 | 1384 | __le16 oid; |
| 1385 | 1385 | __le16 buf_size; |
| 1386 | − u8 value[1]; | |
| 1386 | + u8 value[]; | |
| 1387 | 1387 | } __packed; |
| 1388 | 1388 | |
| 1389 | 1389 | struct mwifiex_rate_scope { |
| @@ -1551,7 +1551,7 @@ struct mwifiex_scan_cmd_config { · 161 unmodified lines | ||
| 1551 | 1551 | * TLV_TYPE_CHANLIST, mwifiex_ie_types_chan_list_param_set |
| 1552 | 1552 | * WLAN_EID_SSID, mwifiex_ie_types_ssid_param_set |
| 1553 | 1553 | */ |
| 1554 | − u8 tlv_buf[1]; /* SSID TLV(s) and ChanList TLVs are stored | |
| 1554 | + u8 tlv_buf[]; /* SSID TLV(s) and ChanList TLVs are stored | |
| 1555 | 1555 | here */ |
| 1556 | 1556 | } __packed; |
| 1557 | 1557 | |
| @@ -1683,7 +1683,7 @@ struct host_cmd_ds_802_11_bg_scan_query_rsp { · 125 unmodified lines | ||
| 1683 | 1683 | struct mwifiex_ietypes_domain_param_set { |
| 1684 | 1684 | struct mwifiex_ie_types_header header; |
| 1685 | 1685 | u8 country_code[IEEE80211_COUNTRY_STRING_LEN]; |
| 1686 | − struct ieee80211_country_ie_triplet triplet[1]; | |
| 1686 | + struct ieee80211_country_ie_triplet triplet[]; | |
| 1687 | 1687 | } __packed; |
| 1688 | 1688 | |
| 1689 | 1689 | struct host_cmd_ds_802_11d_domain_info { |
| @@ -421,15 +421,15 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, · 420 unmodified lines | ||
| 421 | 421 | |
| 422 | 422 | phy_tlv = (struct mwifiex_ie_types_phy_param_set *) pos; |
| 423 | 423 | phy_tlv->header.type = cpu_to_le16(WLAN_EID_DS_PARAMS); |
| 424 | − phy_tlv->header.len = cpu_to_le16(sizeof(phy_tlv->fh_ds.ds_param_set)); | |
| 425 | − memcpy(&phy_tlv->fh_ds.ds_param_set, | |
| 424 | + phy_tlv->header.len = cpu_to_le16(sizeof(*phy_tlv->fh_ds.ds_param_set)); | |
| 425 | + memcpy(phy_tlv->fh_ds.ds_param_set, | |
| 426 | 426 | &bss_desc->phy_param_set.ds_param_set.current_chan, |
| 427 | − sizeof(phy_tlv->fh_ds.ds_param_set)); | |
| 427 | + sizeof(*phy_tlv->fh_ds.ds_param_set)); | |
| 428 | 428 | pos += sizeof(phy_tlv->header) + le16_to_cpu(phy_tlv->header.len); |
| 429 | 429 | |
| 430 | 430 | ss_tlv = (struct mwifiex_ie_types_ss_param_set *) pos; |
| 431 | 431 | ss_tlv->header.type = cpu_to_le16(WLAN_EID_CF_PARAMS); |
| 432 | − ss_tlv->header.len = cpu_to_le16(sizeof(ss_tlv->cf_ibss.cf_param_set)); | |
| 432 | + ss_tlv->header.len = cpu_to_le16(sizeof(*ss_tlv->cf_ibss.cf_param_set)); | |
| 433 | 433 | pos += sizeof(ss_tlv->header) + le16_to_cpu(ss_tlv->header.len); |
| 434 | 434 | |
| 435 | 435 | /* Get the common rates supported between the driver and the BSS Desc */ |
| @@ -108,7 +108,7 @@ static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, · 107 unmodified lines | ||
| 108 | 108 | "cmd: SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid); |
| 109 | 109 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SNMP_MIB); |
| 110 | 110 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_snmp_mib) |
| 111 | − - 1 + S_DS_GEN); | |
| 111 | + + S_DS_GEN); | |
| 112 | 112 | |
| 113 | 113 | snmp_mib->oid = cpu_to_le16((u16)cmd_oid); |
| 114 | 114 | if (cmd_action == HostCmd_ACT_GEN_GET) { |
| @@ -196,6 +196,7 @@ static int mwifiex_request_rgpower_table(struct mwifiex_private *priv) · 195 unmodified lines | ||
| 196 | 196 | struct mwifiex_adapter *adapter = priv->adapter; |
| 197 | 197 | char rgpower_table_name[30]; |
| 198 | 198 | char country_code[3]; |
| 199 | + int ret; | |
| 199 | 200 | |
| 200 | 201 | strscpy(country_code, domain_info->country_code, sizeof(country_code)); |
| 201 | 202 | |
| @@ -214,16 +215,17 @@ static int mwifiex_request_rgpower_table(struct mwifiex_private *priv) · 12 unmodified lines | ||
| 214 | 215 | adapter->rgpower_data = NULL; |
| 215 | 216 | } |
| 216 | 217 | |
| 217 | − if ((request_firmware(&adapter->rgpower_data, rgpower_table_name, | |
| 218 | − adapter->dev))) { | |
| 218 | + ret = request_firmware_direct(&adapter->rgpower_data, rgpower_table_name, | |
| 219 | + adapter->dev); | |
| 220 | + | |
| 221 | + if (ret) { | |
| 219 | 222 | mwifiex_dbg( |
| 220 | 223 | adapter, INFO, |
| 221 | − "info: %s: failed to request regulatory power table\n", | |
| 222 | − __func__); | |
| 223 | − return -EIO; | |
| 224 | + "info: %s: failed to request regulatory power table: %d\n", | |
| 225 | + __func__, ret); | |
| 224 | 226 | } |
| 225 | 227 | |
| 226 | − return 0; | |
| 228 | + return ret; | |
| 227 | 229 | } |
| 228 | 230 | |
| 229 | 231 | static int mwifiex_dnld_rgpower_table(struct mwifiex_private *priv) |
| @@ -215,7 +215,7 @@ mwifiex_tdls_add_ht_oper(struct mwifiex_private *priv, const u8 *mac, · 214 unmodified lines | ||
| 215 | 215 | |
| 216 | 216 | /* follow AP's channel bandwidth */ |
| 217 | 217 | if (ISSUPP_CHANWIDTH40(priv->adapter->hw_dot_11n_dev_cap) && |
| 218 | − bss_desc->bcn_ht_cap && | |
| 218 | + bss_desc->bcn_ht_oper && | |
| 219 | 219 | ISALLOWED_CHANWIDTH40(bss_desc->bcn_ht_oper->ht_param)) |
| 220 | 220 | ht_oper->ht_param = bss_desc->bcn_ht_oper->ht_param; |
| 221 | 221 | |
| @@ -123,11 +123,31 @@ int mwifiex_process_uap_event(struct mwifiex_private *priv) · 122 unmodified lines | ||
| 123 | 123 | len = ETH_ALEN; |
| 124 | 124 | |
| 125 | 125 | if (len != -1) { |
| 126 | + u16 evt_len = le16_to_cpu(event->len); | |
| 127 | + | |
| 126 | 128 | sinfo->assoc_req_ies = &event->data[len]; |
| 127 | 129 | len = (u8 *)sinfo->assoc_req_ies - |
| 128 | 130 | (u8 *)&event->frame_control; |
| 129 | − sinfo->assoc_req_ies_len = | |
| 130 | − le16_to_cpu(event->len) - (u16)len; | |
| 131 | + | |
| 132 | + /* | |
| 133 | + * event->len is reported by the device firmware | |
| 134 | + * and is not otherwise validated. Reject a | |
| 135 | + * length that underflows the header, or that | |
| 136 | + * would place the association request IEs | |
| 137 | + * outside the fixed-size event_body[] buffer the | |
| 138 | + * event was copied into; otherwise the IE walk | |
| 139 | + * in mwifiex_set_sta_ht_cap() reads past | |
| 140 | + * event_body and out of the adapter slab object. | |
| 141 | + */ | |
| 142 | + if (evt_len < len || | |
| 143 | + (u8 *)&event->frame_control + evt_len > | |
| 144 | + adapter->event_body + MAX_EVENT_SIZE) { | |
| 145 | + mwifiex_dbg(adapter, ERROR, | |
| 146 | + "invalid STA assoc event length\n"); | |
| 147 | + kfree(sinfo); | |
| 148 | + return -1; | |
| 149 | + } | |
| 150 | + sinfo->assoc_req_ies_len = evt_len - (u16)len; | |
| 131 | 151 | } |
| 132 | 152 | } |
| 133 | 153 | cfg80211_new_sta(priv->netdev->ieee80211_ptr, event->sta_addr, |
| @@ -38,8 +38,8 @@ config MT792x_USB · 37 unmodified lines | ||
| 38 | 38 | select MT76_USB |
| 39 | 39 | |
| 40 | 40 | config MT76_NPU |
| 41 | − bool | |
| 42 | − depends on MT76_CORE | |
| 41 | + tristate | |
| 42 | + depends on NET_AIROHA_NPU=y || MT76_CORE=NET_AIROHA_NPU | |
| 43 | 43 | |
| 44 | 44 | source "drivers/net/wireless/mediatek/mt76/mt76x0/Kconfig" |
| 45 | 45 | source "drivers/net/wireless/mediatek/mt76/mt76x2/Kconfig" |
| @@ -12,7 +12,11 @@ mt76-y := \ · 11 unmodified lines | ||
| 12 | 12 | mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o \ |
| 13 | 13 | tx.o agg-rx.o mcu.o wed.o scan.o channel.o |
| 14 | 14 | |
| 15 | −mt76-$(CONFIG_MT76_NPU) += npu.o | |
| 15 | +ifdef CONFIG_MT76_NPU | |
| 16 | +# CONFIG_MT76_NPU is tristate to simplify dependency tracking, | |
| 17 | +# but it behaves as a bool symbol here. | |
| 18 | +mt76-y += npu.o | |
| 19 | +endif | |
| 16 | 20 | mt76-$(CONFIG_PCI) += pci.o |
| 17 | 21 | mt76-$(CONFIG_NL80211_TESTMODE) += testmode.o |
| 18 | 22 | |
| @@ -1189,7 +1189,10 @@ void mt76_dma_cleanup(struct mt76_dev *dev) · 1188 unmodified lines | ||
| 1189 | 1189 | mt76_for_each_q_rx(dev, i) { |
| 1190 | 1190 | struct mt76_queue *q = &dev->q_rx[i]; |
| 1191 | 1191 | |
| 1192 | − netif_napi_del(&dev->napi[i]); | |
| 1192 | + if (!mt76_queue_is_wed_rro(q)) { | |
| 1193 | + napi_disable(&dev->napi[i]); | |
| 1194 | + netif_napi_del(&dev->napi[i]); | |
| 1195 | + } | |
| 1193 | 1196 | mt76_dma_rx_cleanup(dev, q); |
| 1194 | 1197 | |
| 1195 | 1198 | page_pool_destroy(q->page_pool); |
| @@ -181,7 +181,7 @@ mt76_eeprom_override(struct mt76_phy *phy) · 180 unmodified lines | ||
| 181 | 181 | if (err == -EPROBE_DEFER) |
| 182 | 182 | return err; |
| 183 | 183 | |
| 184 | − if (err) { | |
| 184 | + if (!is_valid_ether_addr(phy->macaddr)) { | |
| 185 | 185 | eth_random_addr(phy->macaddr); |
| 186 | 186 | dev_info(dev->dev, |
| 187 | 187 | "Invalid MAC address, using random address %pM\n", |
| @@ -1647,7 +1647,7 @@ int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, · 1646 unmodified lines | ||
| 1647 | 1647 | int mt76_testmode_set_state(struct mt76_phy *phy, enum mt76_testmode_state state); |
| 1648 | 1648 | int mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len); |
| 1649 | 1649 | |
| 1650 | −#ifdef CONFIG_MT76_NPU | |
| 1650 | +#if IS_ENABLED(CONFIG_MT76_NPU) | |
| 1651 | 1651 | void mt76_npu_check_ppe(struct mt76_dev *dev, struct sk_buff *skb, |
| 1652 | 1652 | u32 info); |
| 1653 | 1653 | int mt76_npu_dma_add_buf(struct mt76_phy *phy, struct mt76_queue *q, |
| @@ -1736,12 +1736,12 @@ static inline int mt76_npu_send_txrx_addr(struct mt76_dev *dev, int ifindex, · 82 unmodified lines | ||
| 1736 | 1736 | |
| 1737 | 1737 | static inline bool mt76_npu_device_active(struct mt76_dev *dev) |
| 1738 | 1738 | { |
| 1739 | − return !!rcu_access_pointer(dev->mmio.npu); | |
| 1739 | + return mt76_is_mmio(dev) && !!rcu_access_pointer(dev->mmio.npu); | |
| 1740 | 1740 | } |
| 1741 | 1741 | |
| 1742 | 1742 | static inline bool mt76_ppe_device_active(struct mt76_dev *dev) |
| 1743 | 1743 | { |
| 1744 | − return !!rcu_access_pointer(dev->mmio.ppe_dev); | |
| 1744 | + return mt76_is_mmio(dev) && !!rcu_access_pointer(dev->mmio.ppe_dev); | |
| 1745 | 1745 | } |
| 1746 | 1746 | |
| 1747 | 1747 | static inline int mt76_npu_send_msg(struct airoha_npu *npu, int ifindex, |
| @@ -1601,6 +1601,8 @@ bool mt7615_rx_check(struct mt76_dev *mdev, void *data, int len) · 1600 unmodified lines | ||
| 1601 | 1601 | |
| 1602 | 1602 | switch (type) { |
| 1603 | 1603 | case PKT_TYPE_TXRX_NOTIFY: |
| 1604 | + if (!mt76_is_mmio(mdev)) | |
| 1605 | + return false; | |
| 1604 | 1606 | mt7615_mac_tx_free(dev, data, len); |
| 1605 | 1607 | return false; |
| 1606 | 1608 | case PKT_TYPE_TXS: |
| @@ -1634,6 +1636,10 @@ void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, · 27 unmodified lines | ||
| 1634 | 1636 | dev_kfree_skb(skb); |
| 1635 | 1637 | break; |
| 1636 | 1638 | case PKT_TYPE_TXRX_NOTIFY: |
| 1639 | + if (!mt76_is_mmio(mdev)) { | |
| 1640 | + dev_kfree_skb(skb); | |
| 1641 | + break; | |
| 1642 | + } | |
| 1637 | 1643 | mt7615_mac_tx_free(dev, skb->data, skb->len); |
| 1638 | 1644 | dev_kfree_skb(skb); |
| 1639 | 1645 | break; |
| @@ -1458,6 +1458,8 @@ mt76_connac_mcu_uni_bss_he_tlv(struct mt76_phy *phy, struct ieee80211_vif *vif, · 1457 unmodified lines | ||
| 1458 | 1458 | struct bss_info_uni_he *he; |
| 1459 | 1459 | |
| 1460 | 1460 | cap = mt76_connac_get_he_phy_cap(phy, vif); |
| 1461 | + if (!cap) | |
| 1462 | + return; | |
| 1461 | 1463 | |
| 1462 | 1464 | he = (struct bss_info_uni_he *)tlv; |
| 1463 | 1465 | he->he_pe_duration = vif->bss_conf.htc_trig_based_pkt_ext; |
| @@ -595,6 +595,8 @@ mt7915_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, · 594 unmodified lines | ||
| 595 | 595 | struct tlv *tlv; |
| 596 | 596 | |
| 597 | 597 | cap = mt76_connac_get_he_phy_cap(phy->mt76, vif); |
| 598 | + if (!cap) | |
| 599 | + return; | |
| 598 | 600 | |
| 599 | 601 | tlv = mt76_connac_mcu_add_tlv(skb, BSS_INFO_HE_BASIC, sizeof(*he)); |
| 600 | 602 | |
| @@ -1177,13 +1179,12 @@ mt7915_mcu_sta_bfer_vht(struct ieee80211_sta *sta, struct mt7915_phy *phy, · 576 unmodified lines | ||
| 1177 | 1179 | } |
| 1178 | 1180 | |
| 1179 | 1181 | static void |
| 1180 | −mt7915_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif, | |
| 1181 | − struct mt7915_phy *phy, struct sta_rec_bf *bf) | |
| 1182 | +mt7915_mcu_sta_bfer_he(struct ieee80211_sta *sta, | |
| 1183 | + const struct ieee80211_sta_he_cap *vc, | |
| 1184 | + struct sta_rec_bf *bf) | |
| 1182 | 1185 | { |
| 1183 | 1186 | struct ieee80211_sta_he_cap *pc = &sta->deflink.he_cap; |
| 1184 | 1187 | struct ieee80211_he_cap_elem *pe = &pc->he_cap_elem; |
| 1185 | − const struct ieee80211_sta_he_cap *vc = | |
| 1186 | − mt76_connac_get_he_phy_cap(phy->mt76, vif); | |
| 1187 | 1188 | const struct ieee80211_he_cap_elem *ve = &vc->he_cap_elem; |
| 1188 | 1189 | u16 mcs_map = le16_to_cpu(pc->he_mcs_nss_supp.rx_mcs_80); |
| 1189 | 1190 | u8 nss_mcs = mt7915_mcu_get_sta_nss(mcs_map); |
| @@ -1242,6 +1243,7 @@ mt7915_mcu_sta_bfer_tlv(struct mt7915_dev *dev, struct sk_buff *skb, · 52 unmodified lines | ||
| 1242 | 1243 | { |
| 1243 | 1244 | struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; |
| 1244 | 1245 | struct mt7915_phy *phy = mvif->phy; |
| 1246 | + const struct ieee80211_sta_he_cap *vc = NULL; | |
| 1245 | 1247 | int tx_ant = hweight8(phy->mt76->chainmask) - 1; |
| 1246 | 1248 | struct sta_rec_bf *bf; |
| 1247 | 1249 | struct tlv *tlv; |
| @@ -1260,6 +1262,12 @@ mt7915_mcu_sta_bfer_tlv(struct mt7915_dev *dev, struct sk_buff *skb, · 12 unmodified lines | ||
| 1260 | 1262 | if (!ebf && !dev->ibf) |
| 1261 | 1263 | return; |
| 1262 | 1264 | |
| 1265 | + if (sta->deflink.he_cap.has_he && ebf) { | |
| 1266 | + vc = mt76_connac_get_he_phy_cap(phy->mt76, vif); | |
| 1267 | + if (!vc) | |
| 1268 | + return; | |
| 1269 | + } | |
| 1270 | + | |
| 1263 | 1271 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_BF, sizeof(*bf)); |
| 1264 | 1272 | bf = (struct sta_rec_bf *)tlv; |
| 1265 | 1273 | |
| @@ -1268,7 +1276,7 @@ mt7915_mcu_sta_bfer_tlv(struct mt7915_dev *dev, struct sk_buff *skb, · 2 unmodified lines | ||
| 1268 | 1276 | * ht: iBF only, since mac80211 lacks of eBF support |
| 1269 | 1277 | */ |
| 1270 | 1278 | if (sta->deflink.he_cap.has_he && ebf) |
| 1271 | − mt7915_mcu_sta_bfer_he(sta, vif, phy, bf); | |
| 1279 | + mt7915_mcu_sta_bfer_he(sta, vc, bf); | |
| 1272 | 1280 | else if (sta->deflink.vht_cap.vht_supported) |
| 1273 | 1281 | mt7915_mcu_sta_bfer_vht(sta, phy, bf, ebf); |
| 1274 | 1282 | else if (sta->deflink.ht_cap.ht_supported) |
| @@ -570,8 +570,9 @@ bool mt7921_rx_check(struct mt76_dev *mdev, void *data, int len) · 569 unmodified lines | ||
| 570 | 570 | |
| 571 | 571 | switch (type) { |
| 572 | 572 | case PKT_TYPE_TXRX_NOTIFY: |
| 573 | − /* PKT_TYPE_TXRX_NOTIFY can be received only by mmio devices */ | |
| 574 | − mt7921_mac_tx_free(dev, data, len); /* mmio */ | |
| 573 | + if (!mt76_is_mmio(mdev)) | |
| 574 | + return false; | |
| 575 | + mt7921_mac_tx_free(dev, data, len); | |
| 575 | 576 | return false; |
| 576 | 577 | case PKT_TYPE_TXS: |
| 577 | 578 | for (rxd += 2; rxd + 8 <= end; rxd += 8) |
| @@ -600,7 +601,10 @@ void mt7921_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, · 22 unmodified lines | ||
| 600 | 601 | |
| 601 | 602 | switch (type) { |
| 602 | 603 | case PKT_TYPE_TXRX_NOTIFY: |
| 603 | − /* PKT_TYPE_TXRX_NOTIFY can be received only by mmio devices */ | |
| 604 | + if (!mt76_is_mmio(mdev)) { | |
| 605 | + napi_consume_skb(skb, 1); | |
| 606 | + break; | |
| 607 | + } | |
| 604 | 608 | mt7921_mac_tx_free(dev, skb->data, skb->len); |
| 605 | 609 | napi_consume_skb(skb, 1); |
| 606 | 610 | break; |
| @@ -1203,8 +1203,9 @@ bool mt7925_rx_check(struct mt76_dev *mdev, void *data, int len) · 1202 unmodified lines | ||
| 1203 | 1203 | |
| 1204 | 1204 | switch (type) { |
| 1205 | 1205 | case PKT_TYPE_TXRX_NOTIFY: |
| 1206 | − /* PKT_TYPE_TXRX_NOTIFY can be received only by mmio devices */ | |
| 1207 | − mt7925_mac_tx_free(dev, data, len); /* mmio */ | |
| 1206 | + if (!mt76_is_mmio(mdev)) | |
| 1207 | + return false; | |
| 1208 | + mt7925_mac_tx_free(dev, data, len); | |
| 1208 | 1209 | return false; |
| 1209 | 1210 | case PKT_TYPE_TXS: |
| 1210 | 1211 | for (rxd += 4; rxd + 12 <= end; rxd += 12) |
| @@ -1240,7 +1241,10 @@ void mt7925_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, · 29 unmodified lines | ||
| 1240 | 1241 | |
| 1241 | 1242 | switch (type) { |
| 1242 | 1243 | case PKT_TYPE_TXRX_NOTIFY: |
| 1243 | − /* PKT_TYPE_TXRX_NOTIFY can be received only by mmio devices */ | |
| 1244 | + if (!mt76_is_mmio(mdev)) { | |
| 1245 | + napi_consume_skb(skb, 1); | |
| 1246 | + break; | |
| 1247 | + } | |
| 1244 | 1248 | mt7925_mac_tx_free(dev, skb->data, skb->len); |
| 1245 | 1249 | napi_consume_skb(skb, 1); |
| 1246 | 1250 | break; |
| @@ -1284,6 +1288,9 @@ mt7925_vif_connect_iter(void *priv, u8 *mac, · 37 unmodified lines | ||
| 1284 | 1288 | |
| 1285 | 1289 | for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 1286 | 1290 | bss_conf = mt792x_vif_to_bss_conf(vif, i); |
| 1291 | + if (!bss_conf) | |
| 1292 | + continue; | |
| 1293 | + | |
| 1287 | 1294 | mconf = mt792x_vif_to_link(mvif, i); |
| 1288 | 1295 | |
| 1289 | 1296 | mt76_connac_mcu_uni_add_dev(&dev->mphy, bss_conf, &mconf->mt76, |
| @@ -1713,6 +1713,9 @@ static void mt7925_sta_set_decap_offload(struct ieee80211_hw *hw, · 1712 unmodified lines | ||
| 1713 | 1713 | mconf = mt792x_vif_to_link(mvif, i); |
| 1714 | 1714 | mlink = mt792x_sta_to_link(msta, i); |
| 1715 | 1715 | |
| 1716 | + if (!mlink) | |
| 1717 | + continue; | |
| 1718 | + | |
| 1716 | 1719 | if (enabled) |
| 1717 | 1720 | set_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags); |
| 1718 | 1721 | else |
| @@ -2773,6 +2773,8 @@ mt7925_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *link_conf, · 2772 unmodified lines | ||
| 2773 | 2773 | struct tlv *tlv; |
| 2774 | 2774 | |
| 2775 | 2775 | cap = mt76_connac_get_he_phy_cap(phy->mt76, link_conf->vif); |
| 2776 | + if (!cap) | |
| 2777 | + return; | |
| 2776 | 2778 | |
| 2777 | 2779 | tlv = mt76_connac_mcu_add_tlv(skb, UNI_BSS_INFO_HE_BASIC, sizeof(*he)); |
| 2778 | 2780 | |
| @@ -16,6 +16,6 @@ config MT7996E · 15 unmodified lines | ||
| 16 | 16 | config MT7996_NPU |
| 17 | 17 | bool "MT7996 (PCIe) NPU support" |
| 18 | 18 | depends on MT7996E |
| 19 | − depends on NET_AIROHA_NPU=y || MT7996E=NET_AIROHA_NPU | |
| 19 | + depends on NET_AIROHA_NPU=y || MT76_CORE=NET_AIROHA_NPU | |
| 20 | 20 | select MT76_NPU |
| 21 | 21 | default n |
| @@ -935,6 +935,8 @@ mt7996_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, · 934 unmodified lines | ||
| 935 | 935 | struct tlv *tlv; |
| 936 | 936 | |
| 937 | 937 | cap = mt76_connac_get_he_phy_cap(phy->mt76, vif); |
| 938 | + if (!cap) | |
| 939 | + return; | |
| 938 | 940 | |
| 939 | 941 | tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_HE_BASIC, sizeof(*he)); |
| 940 | 942 | |
| @@ -1855,17 +1857,18 @@ mt7996_mcu_sta_bfer_he(struct ieee80211_link_sta *link_sta, · 914 unmodified lines | ||
| 1855 | 1857 | { |
| 1856 | 1858 | struct ieee80211_sta_he_cap *pc = &link_sta->he_cap; |
| 1857 | 1859 | struct ieee80211_he_cap_elem *pe = &pc->he_cap_elem; |
| 1858 | − const struct ieee80211_sta_he_cap *vc = | |
| 1859 | − mt76_connac_get_he_phy_cap(phy->mt76, vif); | |
| 1860 | − const struct ieee80211_he_cap_elem *ve = &vc->he_cap_elem; | |
| 1861 | 1860 | u16 mcs_map = le16_to_cpu(pc->he_mcs_nss_supp.rx_mcs_80); |
| 1862 | 1861 | u8 nss_mcs = mt7996_mcu_get_sta_nss(mcs_map); |
| 1862 | + const struct ieee80211_he_cap_elem *ve; | |
| 1863 | + const struct ieee80211_sta_he_cap *vc; | |
| 1863 | 1864 | u8 snd_dim, sts; |
| 1864 | 1865 | |
| 1866 | + vc = mt76_connac_get_he_phy_cap(phy->mt76, vif); | |
| 1865 | 1867 | if (!vc) |
| 1866 | 1868 | return; |
| 1867 | 1869 | |
| 1868 | 1870 | bf->tx_mode = MT_PHY_TYPE_HE_SU; |
| 1871 | + ve = &vc->he_cap_elem; | |
| 1869 | 1872 | |
| 1870 | 1873 | mt7996_mcu_sta_sounding_rate(bf, phy); |
| 1871 | 1874 | |
| @@ -1921,14 +1924,18 @@ mt7996_mcu_sta_bfer_eht(struct ieee80211_link_sta *link_sta, · 49 unmodified lines | ||
| 1921 | 1924 | struct ieee80211_sta_eht_cap *pc = &link_sta->eht_cap; |
| 1922 | 1925 | struct ieee80211_eht_cap_elem_fixed *pe = &pc->eht_cap_elem; |
| 1923 | 1926 | struct ieee80211_eht_mcs_nss_supp *eht_nss = &pc->eht_mcs_nss_supp; |
| 1924 | − const struct ieee80211_sta_eht_cap *vc = | |
| 1925 | − mt76_connac_get_eht_phy_cap(phy->mt76, vif); | |
| 1926 | − const struct ieee80211_eht_cap_elem_fixed *ve = &vc->eht_cap_elem; | |
| 1927 | 1927 | u8 nss_mcs = u8_get_bits(eht_nss->bw._80.rx_tx_mcs9_max_nss, |
| 1928 | 1928 | IEEE80211_EHT_MCS_NSS_RX) - 1; |
| 1929 | + const struct ieee80211_eht_cap_elem_fixed *ve; | |
| 1930 | + const struct ieee80211_sta_eht_cap *vc; | |
| 1929 | 1931 | u8 snd_dim, sts; |
| 1930 | 1932 | |
| 1933 | + vc = mt76_connac_get_eht_phy_cap(phy->mt76, vif); | |
| 1934 | + if (!vc) | |
| 1935 | + return; | |
| 1936 | + | |
| 1931 | 1937 | bf->tx_mode = MT_PHY_TYPE_EHT_MU; |
| 1938 | + ve = &vc->eht_cap_elem; | |
| 1932 | 1939 | |
| 1933 | 1940 | mt7996_mcu_sta_sounding_rate(bf, phy); |
| 1934 | 1941 | |
| @@ -600,6 +600,11 @@ static s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, · 599 unmodified lines | ||
| 600 | 600 | u16 ies_len; |
| 601 | 601 | struct wilc_assoc_resp *res = (struct wilc_assoc_resp *)buffer; |
| 602 | 602 | |
| 603 | + if (buffer_len < sizeof(*res)) { | |
| 604 | + ret_conn_info->status = WLAN_STATUS_UNSPECIFIED_FAILURE; | |
| 605 | + return -EINVAL; | |
| 606 | + } | |
| 607 | + | |
| 603 | 608 | ret_conn_info->status = le16_to_cpu(res->status_code); |
| 604 | 609 | if (ret_conn_info->status == WLAN_STATUS_SUCCESS) { |
| 605 | 610 | ies = &buffer[sizeof(*res)]; |
| @@ -870,9 +870,9 @@ static const struct nla_policy hwsim_genl_policy[HWSIM_ATTR_MAX + 1] = { · 869 unmodified lines | ||
| 870 | 870 | [HWSIM_ATTR_FLAGS] = { .type = NLA_U32 }, |
| 871 | 871 | [HWSIM_ATTR_RX_RATE] = { .type = NLA_U32 }, |
| 872 | 872 | [HWSIM_ATTR_SIGNAL] = { .type = NLA_U32 }, |
| 873 | − [HWSIM_ATTR_TX_INFO] = { .type = NLA_BINARY, | |
| 874 | − .len = IEEE80211_TX_MAX_RATES * | |
| 875 | − sizeof(struct hwsim_tx_rate)}, | |
| 873 | + [HWSIM_ATTR_TX_INFO] = | |
| 874 | + NLA_POLICY_EXACT_LEN(IEEE80211_TX_MAX_RATES * | |
| 875 | + sizeof(struct hwsim_tx_rate)), | |
| 876 | 876 | [HWSIM_ATTR_COOKIE] = { .type = NLA_U64 }, |
| 877 | 877 | [HWSIM_ATTR_CHANNELS] = { .type = NLA_U32 }, |
| 878 | 878 | [HWSIM_ATTR_RADIO_ID] = { .type = NLA_U32 }, |
| @@ -30,7 +30,6 @@ · 29 unmodified lines | ||
| 30 | 30 | #define LOONGSON_ACPI_HKEY_HID "LOON0000" |
| 31 | 31 | |
| 32 | 32 | #define ACPI_LAPTOP_NAME "loongson-laptop" |
| 33 | −#define ACPI_LAPTOP_ACPI_EVENT_PREFIX "loongson" | |
| 34 | 33 | |
| 35 | 34 | #define MAX_ACPI_ARGS 3 |
| 36 | 35 | #define GENERIC_HOTKEY_MAP_MAX 64 |
| @@ -167,8 +166,6 @@ static int __init setup_acpi_notify(struct generic_sub_driver *sub_driver) · 130 unmodified lines | ||
| 167 | 166 | } |
| 168 | 167 | |
| 169 | 168 | sub_driver->device->driver_data = sub_driver; |
| 170 | − sprintf(acpi_device_class(sub_driver->device), "%s/%s", | |
| 171 | − ACPI_LAPTOP_ACPI_EVENT_PREFIX, sub_driver->name); | |
| 172 | 169 | |
| 173 | 170 | status = acpi_install_notify_handler(*sub_driver->handle, |
| 174 | 171 | sub_driver->type, dispatch_acpi_notify, sub_driver); |
| @@ -189,6 +186,7 @@ static int __init setup_acpi_notify(struct generic_sub_driver *sub_driver) · 14 unmodified lines | ||
| 189 | 186 | |
| 190 | 187 | static int loongson_hotkey_suspend(struct device *dev) |
| 191 | 188 | { |
| 189 | + bl_powered = false; | |
| 192 | 190 | return 0; |
| 193 | 191 | } |
| 194 | 192 | |
| @@ -1618,6 +1618,8 @@ static DEVICE_ATTR_RW(charge_control_end_threshold); · 1617 unmodified lines | ||
| 1618 | 1618 | |
| 1619 | 1619 | static int asus_wmi_battery_add(struct power_supply *battery, struct acpi_battery_hook *hook) |
| 1620 | 1620 | { |
| 1621 | + int ret, rv; | |
| 1622 | + | |
| 1621 | 1623 | /* The WMI method does not provide a way to specific a battery, so we |
| 1622 | 1624 | * just assume it is the first battery. |
| 1623 | 1625 | * Note: On some newer ASUS laptops (Zenbook UM431DA), the primary/first |
| @@ -1635,12 +1637,30 @@ static int asus_wmi_battery_add(struct power_supply *battery, struct acpi_batter · 11 unmodified lines | ||
| 1635 | 1637 | |
| 1636 | 1638 | /* The charge threshold is only reset when the system is power cycled, |
| 1637 | 1639 | * and we can't read the current threshold, however the majority of |
| 1638 | − * platforms retains it, therefore signal the threshold as unknown | |
| 1639 | − * until user explicitly sets it to a new value. | |
| 1640 | + * platforms retains it. | |
| 1641 | + * | |
| 1642 | + * Setting a negative value would signal the threshold as unknown | |
| 1643 | + * until user explicitly sets it to a new value, however to avoid | |
| 1644 | + * regressing userspace, we initialize it to a value of 100. | |
| 1640 | 1645 | */ |
| 1641 | − charge_end_threshold = -1; | |
| 1646 | + charge_end_threshold = 100; | |
| 1647 | + ret = asus_wmi_set_devstate(ASUS_WMI_DEVID_RSOC, charge_end_threshold, &rv); | |
| 1648 | + if (ret) { | |
| 1649 | + pr_err("Failed to reset battery charge threshold\n"); | |
| 1650 | + goto asus_wmi_battery_add_err; | |
| 1651 | + } | |
| 1652 | + | |
| 1653 | + if (rv != 1) { | |
| 1654 | + pr_err("Error in battery charge threshold reset\n"); | |
| 1655 | + ret = -EIO; | |
| 1656 | + goto asus_wmi_battery_add_err; | |
| 1657 | + } | |
| 1642 | 1658 | |
| 1643 | 1659 | return 0; |
| 1660 | +asus_wmi_battery_add_err: | |
| 1661 | + device_remove_file(&battery->dev, | |
| 1662 | + &dev_attr_charge_control_end_threshold); | |
| 1663 | + return ret; | |
| 1644 | 1664 | } |
| 1645 | 1665 | |
| 1646 | 1666 | static int asus_wmi_battery_remove(struct power_supply *battery, struct acpi_battery_hook *hook) |
| @@ -103,6 +103,12 @@ static void intel_vsec_remove_aux(void *data) · 102 unmodified lines | ||
| 103 | 103 | auxiliary_device_uninit(data); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | +static void intel_vsec_dev_free(struct intel_vsec_device *intel_vsec_dev) | |
| 107 | +{ | |
| 108 | + kfree(intel_vsec_dev->acpi_disc); | |
| 109 | + kfree(intel_vsec_dev); | |
| 110 | +} | |
| 111 | + | |
| 106 | 112 | static void intel_vsec_dev_release(struct device *dev) |
| 107 | 113 | { |
| 108 | 114 | struct intel_vsec_device *intel_vsec_dev = dev_to_ivdev(dev); |
| @@ -111,8 +117,7 @@ static void intel_vsec_dev_release(struct device *dev) · 2 unmodified lines | ||
| 111 | 117 | |
| 112 | 118 | ida_free(intel_vsec_dev->ida, intel_vsec_dev->auxdev.id); |
| 113 | 119 | |
| 114 | − kfree(intel_vsec_dev->acpi_disc); | |
| 115 | − kfree(intel_vsec_dev); | |
| 120 | + intel_vsec_dev_free(intel_vsec_dev); | |
| 116 | 121 | } |
| 117 | 122 | |
| 118 | 123 | static const struct vsec_feature_dependency * |
| @@ -218,20 +223,22 @@ int intel_vsec_add_aux(struct device *parent, · 99 unmodified lines | ||
| 218 | 223 | struct auxiliary_device *auxdev = &intel_vsec_dev->auxdev; |
| 219 | 224 | int ret, id; |
| 220 | 225 | |
| 221 | − if (!parent) | |
| 226 | + if (!parent) { | |
| 227 | + intel_vsec_dev_free(intel_vsec_dev); | |
| 222 | 228 | return -EINVAL; |
| 229 | + } | |
| 223 | 230 | |
| 224 | 231 | ret = xa_alloc(&auxdev_array, &intel_vsec_dev->id, intel_vsec_dev, |
| 225 | 232 | PMT_XA_LIMIT, GFP_KERNEL); |
| 226 | 233 | if (ret < 0) { |
| 227 | − kfree(intel_vsec_dev); | |
| 234 | + intel_vsec_dev_free(intel_vsec_dev); | |
| 228 | 235 | return ret; |
| 229 | 236 | } |
| 230 | 237 | |
| 231 | 238 | id = ida_alloc(intel_vsec_dev->ida, GFP_KERNEL); |
| 232 | 239 | if (id < 0) { |
| 233 | 240 | xa_erase(&auxdev_array, intel_vsec_dev->id); |
| 234 | − kfree(intel_vsec_dev); | |
| 241 | + intel_vsec_dev_free(intel_vsec_dev); | |
| 235 | 242 | return id; |
| 236 | 243 | } |
| 237 | 244 | |
| @@ -779,6 +779,7 @@ static void netc_timer_init(struct netc_timer *priv) · 778 unmodified lines | ||
| 779 | 779 | netc_timer_wr(priv, NETC_TMR_FIPER_CTRL, fiper_ctrl); |
| 780 | 780 | netc_timer_wr(priv, NETC_TMR_ECTRL, NETC_TMR_DEFAULT_ETTF_THR); |
| 781 | 781 | |
| 782 | + netc_timer_offset_write(priv, 0); | |
| 782 | 783 | ktime_get_real_ts64(&now); |
| 783 | 784 | ns = timespec64_to_ns(&now); |
| 784 | 785 | netc_timer_cnt_write(priv, ns); |
| @@ -107,6 +107,9 @@ static __init int ptp_s390_init(void) · 106 unmodified lines | ||
| 107 | 107 | if (IS_ERR(ptp_stcke_clock)) |
| 108 | 108 | return PTR_ERR(ptp_stcke_clock); |
| 109 | 109 | |
| 110 | + if (!test_facility(28) || !ptff_query(PTFF_QPT)) | |
| 111 | + return 0; | |
| 112 | + | |
| 110 | 113 | ptp_qpt_clock = ptp_clock_register(&ptp_s390_qpt_info, NULL); |
| 111 | 114 | if (IS_ERR(ptp_qpt_clock)) { |
| 112 | 115 | ptp_clock_unregister(ptp_stcke_clock); |
| @@ -117,7 +120,8 @@ static __init int ptp_s390_init(void) · 4 unmodified lines | ||
| 117 | 120 | |
| 118 | 121 | static __exit void ptp_s390_exit(void) |
| 119 | 122 | { |
| 120 | − ptp_clock_unregister(ptp_qpt_clock); | |
| 123 | + if (ptp_qpt_clock) | |
| 124 | + ptp_clock_unregister(ptp_qpt_clock); | |
| 121 | 125 | ptp_clock_unregister(ptp_stcke_clock); |
| 122 | 126 | } |
| 123 | 127 | |
| @@ -1220,10 +1220,98 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, · 1219 unmodified lines | ||
| 1220 | 1220 | { |
| 1221 | 1221 | const struct regulator_ops *ops = rdev->desc->ops; |
| 1222 | 1222 | int ret; |
| 1223 | + bool apply_uV; | |
| 1224 | + | |
| 1225 | + /* | |
| 1226 | + * Decide up front, from the constraints as handed to us, whether | |
| 1227 | + * apply_uV needs to run below. The clamping pass right after this | |
| 1228 | + * may rewrite constraints->min_uV/max_uV (e.g. the fixed-voltage | |
| 1229 | + * autoconfigure case), and we don't want that to change whether | |
| 1230 | + * apply_uV fires. | |
| 1231 | + */ | |
| 1232 | + apply_uV = rdev->constraints->apply_uV && | |
| 1233 | + rdev->constraints->min_uV && rdev->constraints->max_uV; | |
| 1234 | + | |
| 1235 | + /* | |
| 1236 | + * Constrain machine-level voltage specs to fit the actual range | |
| 1237 | + * supported by this regulator before apply_uV (below) tries to | |
| 1238 | + * force hardware to a value from that range: otherwise apply_uV | |
| 1239 | + * can target a constraint value that doesn't correspond to any | |
| 1240 | + * real voltage selector and fail registration outright, even | |
| 1241 | + * though the clamping pass would have narrowed it to a value | |
| 1242 | + * the regulator can actually hit. | |
| 1243 | + */ | |
| 1244 | + if (ops->list_voltage && rdev->desc->n_voltages) { | |
| 1245 | + int count = rdev->desc->n_voltages; | |
| 1246 | + int i; | |
| 1247 | + int min_uV = INT_MAX; | |
| 1248 | + int max_uV = INT_MIN; | |
| 1249 | + int cmin = constraints->min_uV; | |
| 1250 | + int cmax = constraints->max_uV; | |
| 1251 | + | |
| 1252 | + /* it's safe to autoconfigure fixed-voltage supplies | |
| 1253 | + * and the constraints are used by list_voltage. | |
| 1254 | + */ | |
| 1255 | + if (count == 1 && !cmin) { | |
| 1256 | + cmin = 1; | |
| 1257 | + cmax = INT_MAX; | |
| 1258 | + constraints->min_uV = cmin; | |
| 1259 | + constraints->max_uV = cmax; | |
| 1260 | + } | |
| 1261 | + | |
| 1262 | + /* voltage constraints are optional */ | |
| 1263 | + if ((cmin == 0) && (cmax == 0)) { | |
| 1264 | + /* nothing more to do */ | |
| 1265 | + | |
| 1266 | + /* else require explicit machine-level constraints */ | |
| 1267 | + } else if (cmin <= 0 || cmax <= 0 || cmax < cmin) { | |
| 1268 | + rdev_err(rdev, "invalid voltage constraints\n"); | |
| 1269 | + return -EINVAL; | |
| 1270 | + | |
| 1271 | + /* no need to loop voltages if range is continuous */ | |
| 1272 | + } else if (rdev->desc->continuous_voltage_range) { | |
| 1273 | + /* nothing more to do */ | |
| 1274 | + | |
| 1275 | + } else { | |
| 1276 | + /* initial: [cmin..cmax] valid, [min_uV..max_uV] not */ | |
| 1277 | + for (i = 0; i < count; i++) { | |
| 1278 | + int value; | |
| 1279 | + | |
| 1280 | + value = ops->list_voltage(rdev, i); | |
| 1281 | + if (value <= 0) | |
| 1282 | + continue; | |
| 1283 | + | |
| 1284 | + /* maybe adjust [min_uV..max_uV] */ | |
| 1285 | + if (value >= cmin && value < min_uV) | |
| 1286 | + min_uV = value; | |
| 1287 | + if (value <= cmax && value > max_uV) | |
| 1288 | + max_uV = value; | |
| 1289 | + } | |
| 1290 | + | |
| 1291 | + /* final: [min_uV..max_uV] valid iff constraints valid */ | |
| 1292 | + if (max_uV < min_uV) { | |
| 1293 | + rdev_err(rdev, | |
| 1294 | + "unsupportable voltage constraints %u-%uuV\n", | |
| 1295 | + min_uV, max_uV); | |
| 1296 | + return -EINVAL; | |
| 1297 | + } | |
| 1298 | + | |
| 1299 | + /* use regulator's subset of machine constraints */ | |
| 1300 | + if (constraints->min_uV < min_uV) { | |
| 1301 | + rdev_dbg(rdev, "override min_uV, %d -> %d\n", | |
| 1302 | + constraints->min_uV, min_uV); | |
| 1303 | + constraints->min_uV = min_uV; | |
| 1304 | + } | |
| 1305 | + if (constraints->max_uV > max_uV) { | |
| 1306 | + rdev_dbg(rdev, "override max_uV, %d -> %d\n", | |
| 1307 | + constraints->max_uV, max_uV); | |
| 1308 | + constraints->max_uV = max_uV; | |
| 1309 | + } | |
| 1310 | + } | |
| 1311 | + } | |
| 1223 | 1312 | |
| 1224 | 1313 | /* do we need to apply the constraint voltage */ |
| 1225 | − if (rdev->constraints->apply_uV && | |
| 1226 | − rdev->constraints->min_uV && rdev->constraints->max_uV) { | |
| 1314 | + if (apply_uV) { | |
| 1227 | 1315 | int target_min, target_max; |
| 1228 | 1316 | int current_uV = regulator_get_voltage_rdev(rdev); |
| 1229 | 1317 | |
| @@ -1278,77 +1366,6 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, · 48 unmodified lines | ||
| 1278 | 1366 | } |
| 1279 | 1367 | } |
| 1280 | 1368 | |
| 1281 | − /* constrain machine-level voltage specs to fit | |
| 1282 | − * the actual range supported by this regulator. | |
| 1283 | − */ | |
| 1284 | − if (ops->list_voltage && rdev->desc->n_voltages) { | |
| 1285 | − int count = rdev->desc->n_voltages; | |
| 1286 | − int i; | |
| 1287 | − int min_uV = INT_MAX; | |
| 1288 | − int max_uV = INT_MIN; | |
| 1289 | − int cmin = constraints->min_uV; | |
| 1290 | − int cmax = constraints->max_uV; | |
| 1291 | − | |
| 1292 | − /* it's safe to autoconfigure fixed-voltage supplies | |
| 1293 | − * and the constraints are used by list_voltage. | |
| 1294 | − */ | |
| 1295 | − if (count == 1 && !cmin) { | |
| 1296 | − cmin = 1; | |
| 1297 | − cmax = INT_MAX; | |
| 1298 | − constraints->min_uV = cmin; | |
| 1299 | − constraints->max_uV = cmax; | |
| 1300 | − } | |
| 1301 | − | |
| 1302 | − /* voltage constraints are optional */ | |
| 1303 | − if ((cmin == 0) && (cmax == 0)) | |
| 1304 | − return 0; | |
| 1305 | − | |
| 1306 | − /* else require explicit machine-level constraints */ | |
| 1307 | − if (cmin <= 0 || cmax <= 0 || cmax < cmin) { | |
| 1308 | − rdev_err(rdev, "invalid voltage constraints\n"); | |
| 1309 | − return -EINVAL; | |
| 1310 | − } | |
| 1311 | − | |
| 1312 | − /* no need to loop voltages if range is continuous */ | |
| 1313 | − if (rdev->desc->continuous_voltage_range) | |
| 1314 | − return 0; | |
| 1315 | − | |
| 1316 | − /* initial: [cmin..cmax] valid, [min_uV..max_uV] not */ | |
| 1317 | − for (i = 0; i < count; i++) { | |
| 1318 | − int value; | |
| 1319 | − | |
| 1320 | − value = ops->list_voltage(rdev, i); | |
| 1321 | − if (value <= 0) | |
| 1322 | − continue; | |
| 1323 | − | |
| 1324 | − /* maybe adjust [min_uV..max_uV] */ | |
| 1325 | − if (value >= cmin && value < min_uV) | |
| 1326 | − min_uV = value; | |
| 1327 | − if (value <= cmax && value > max_uV) | |
| 1328 | − max_uV = value; | |
| 1329 | − } | |
| 1330 | − | |
| 1331 | − /* final: [min_uV..max_uV] valid iff constraints valid */ | |
| 1332 | − if (max_uV < min_uV) { | |
| 1333 | − rdev_err(rdev, | |
| 1334 | − "unsupportable voltage constraints %u-%uuV\n", | |
| 1335 | − min_uV, max_uV); | |
| 1336 | − return -EINVAL; | |
| 1337 | − } | |
| 1338 | − | |
| 1339 | − /* use regulator's subset of machine constraints */ | |
| 1340 | − if (constraints->min_uV < min_uV) { | |
| 1341 | − rdev_dbg(rdev, "override min_uV, %d -> %d\n", | |
| 1342 | − constraints->min_uV, min_uV); | |
| 1343 | − constraints->min_uV = min_uV; | |
| 1344 | − } | |
| 1345 | − if (constraints->max_uV > max_uV) { | |
| 1346 | − rdev_dbg(rdev, "override max_uV, %d -> %d\n", | |
| 1347 | − constraints->max_uV, max_uV); | |
| 1348 | − constraints->max_uV = max_uV; | |
| 1349 | − } | |
| 1350 | − } | |
| 1351 | − | |
| 1352 | 1369 | return 0; |
| 1353 | 1370 | } |
| 1354 | 1371 | |
| @@ -492,7 +492,7 @@ static const struct regulator_ops mt6358_volt_fixed_ops = { · 491 unmodified lines | ||
| 492 | 492 | .list_voltage = regulator_list_voltage_linear, |
| 493 | 493 | .map_voltage = regulator_map_voltage_linear, |
| 494 | 494 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 495 | − .get_voltage_sel = mt6358_get_buck_voltage_sel, | |
| 495 | + .get_voltage_sel = regulator_get_voltage_sel_regmap, | |
| 496 | 496 | .set_voltage_time_sel = regulator_set_voltage_time_sel, |
| 497 | 497 | .enable = regulator_enable_regmap, |
| 498 | 498 | .disable = regulator_disable_regmap, |
| @@ -1552,12 +1552,9 @@ static u16 mpam_wa_t241_calc_min_from_max(struct mpam_props *props, · 1551 unmodified lines | ||
| 1552 | 1552 | static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, |
| 1553 | 1553 | struct mpam_config *cfg) |
| 1554 | 1554 | { |
| 1555 | − u32 pri_val = 0; | |
| 1556 | 1555 | u16 cmax = MPAMCFG_CMAX_CMAX; |
| 1557 | 1556 | struct mpam_msc *msc = ris->vmsc->msc; |
| 1558 | 1557 | struct mpam_props *rprops = &ris->props; |
| 1559 | − u16 dspri = GENMASK(rprops->dspri_wd, 0); | |
| 1560 | − u16 intpri = GENMASK(rprops->intpri_wd, 0); | |
| 1561 | 1558 | |
| 1562 | 1559 | mutex_lock(&msc->part_sel_lock); |
| 1563 | 1560 | __mpam_part_sel(ris->ris_idx, partid, msc); |
| @@ -1583,9 +1580,9 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, · 19 unmodified lines | ||
| 1583 | 1580 | |
| 1584 | 1581 | if (mpam_has_feature(mpam_feat_mbw_part, rprops)) { |
| 1585 | 1582 | if (mpam_has_feature(mpam_feat_mbw_part, cfg)) |
| 1586 | − mpam_reset_msc_bitmap(msc, MPAMCFG_MBW_PBM, rprops->mbw_pbm_bits); | |
| 1587 | − else | |
| 1588 | 1583 | mpam_write_partsel_reg(msc, MBW_PBM, cfg->mbw_pbm); |
| 1584 | + else | |
| 1585 | + mpam_reset_msc_bitmap(msc, MPAMCFG_MBW_PBM, rprops->mbw_pbm_bits); | |
| 1589 | 1586 | } |
| 1590 | 1587 | |
| 1591 | 1588 | if (mpam_has_feature(mpam_feat_mbw_min, rprops)) { |
| @@ -1622,16 +1619,25 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, · 30 unmodified lines | ||
| 1622 | 1619 | |
| 1623 | 1620 | if (mpam_has_feature(mpam_feat_intpri_part, rprops) || |
| 1624 | 1621 | mpam_has_feature(mpam_feat_dspri_part, rprops)) { |
| 1625 | − /* aces high? */ | |
| 1626 | − if (!mpam_has_feature(mpam_feat_intpri_part_0_low, rprops)) | |
| 1627 | − intpri = 0; | |
| 1628 | − if (!mpam_has_feature(mpam_feat_dspri_part_0_low, rprops)) | |
| 1629 | − dspri = 0; | |
| 1622 | + u32 pri_val = 0; | |
| 1623 | + | |
| 1624 | + if (mpam_has_feature(mpam_feat_intpri_part, rprops)) { | |
| 1625 | + u16 intpri = GENMASK(rprops->intpri_wd - 1, 0); | |
| 1626 | + | |
| 1627 | + /* aces high? */ | |
| 1628 | + if (!mpam_has_feature(mpam_feat_intpri_part_0_low, rprops)) | |
| 1629 | + intpri = 0; | |
| 1630 | 1630 | |
| 1631 | − if (mpam_has_feature(mpam_feat_intpri_part, rprops)) | |
| 1632 | 1631 | pri_val |= FIELD_PREP(MPAMCFG_PRI_INTPRI, intpri); |
| 1633 | − if (mpam_has_feature(mpam_feat_dspri_part, rprops)) | |
| 1632 | + } | |
| 1633 | + if (mpam_has_feature(mpam_feat_dspri_part, rprops)) { | |
| 1634 | + u16 dspri = GENMASK(rprops->dspri_wd - 1, 0); | |
| 1635 | + | |
| 1636 | + if (!mpam_has_feature(mpam_feat_dspri_part_0_low, rprops)) | |
| 1637 | + dspri = 0; | |
| 1638 | + | |
| 1634 | 1639 | pri_val |= FIELD_PREP(MPAMCFG_PRI_DSPRI, dspri); |
| 1640 | + } | |
| 1635 | 1641 | |
| 1636 | 1642 | mpam_write_partsel_reg(msc, PRI, pri_val); |
| 1637 | 1643 | } |
| @@ -2606,8 +2612,10 @@ static void __destroy_component_cfg(struct mpam_component *comp) · 968 unmodified lines | ||
| 2606 | 2612 | msc = vmsc->msc; |
| 2607 | 2613 | |
| 2608 | 2614 | if (mpam_mon_sel_lock(msc)) { |
| 2609 | − list_for_each_entry(ris, &vmsc->ris, vmsc_list) | |
| 2610 | − add_to_garbage(ris->mbwu_state); | |
| 2615 | + list_for_each_entry(ris, &vmsc->ris, vmsc_list) { | |
| 2616 | + if (ris->mbwu_state) | |
| 2617 | + add_to_garbage(ris->mbwu_state); | |
| 2618 | + } | |
| 2611 | 2619 | mpam_mon_sel_unlock(msc); |
| 2612 | 2620 | } |
| 2613 | 2621 | } |
| @@ -494,8 +494,8 @@ static bool k1_spi_write(struct k1_spi_driver_data *drv_data, u32 val) · 493 unmodified lines | ||
| 494 | 494 | { |
| 495 | 495 | unsigned int count; |
| 496 | 496 | |
| 497 | − /* Get the number of open slots in the FIFO; zero means all */ | |
| 498 | − count = FIELD_GET(SSP_STATUS_TFL, val) ? : K1_SPI_FIFO_SIZE; | |
| 497 | + /* Get the number of free slots in the FIFO */ | |
| 498 | + count = K1_SPI_FIFO_SIZE - FIELD_GET(SSP_STATUS_TFL, val); | |
| 499 | 499 | |
| 500 | 500 | /* |
| 501 | 501 | * Limit how much we try to send at a time, to reduce the |
| @@ -670,7 +670,14 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) · 669 unmodified lines | ||
| 670 | 670 | while (cnt < in_len) { |
| 671 | 671 | eid = in_ie[cnt]; |
| 672 | 672 | |
| 673 | − if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&in_ie[cnt + 2], wps_oui, 4))) { | |
| 673 | + if (cnt + 2 > in_len) | |
| 674 | + break; | |
| 675 | + | |
| 676 | + if (in_ie[cnt + 1] + 2 > in_len - cnt) | |
| 677 | + break; | |
| 678 | + | |
| 679 | + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (in_ie[cnt + 1] >= 4) && | |
| 680 | + (!memcmp(&in_ie[cnt + 2], wps_oui, 4))) { | |
| 674 | 681 | wpsie_ptr = &in_ie[cnt]; |
| 675 | 682 | |
| 676 | 683 | if (wps_ie) |
| @@ -1957,7 +1957,7 @@ static u8 rtw_get_chan_type(struct adapter *adapter) · 1956 unmodified lines | ||
| 1957 | 1957 | else |
| 1958 | 1958 | return NL80211_CHAN_NO_HT; |
| 1959 | 1959 | case CHANNEL_WIDTH_40: |
| 1960 | − if (mlme_ext->cur_ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) | |
| 1960 | + if (mlme_ext->cur_ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) | |
| 1961 | 1961 | return NL80211_CHAN_HT40PLUS; |
| 1962 | 1962 | else |
| 1963 | 1963 | return NL80211_CHAN_HT40MINUS; |
| @@ -318,9 +318,11 @@ static int mid8250_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 317 unmodified lines | ||
| 318 | 318 | if (!uart.port.membase) |
| 319 | 319 | return -ENOMEM; |
| 320 | 320 | |
| 321 | − ret = mid->board->setup(mid, &uart.port); | |
| 322 | − if (ret) | |
| 323 | − return ret; | |
| 321 | + if (mid->board->setup) { | |
| 322 | + ret = mid->board->setup(mid, &uart.port); | |
| 323 | + if (ret) | |
| 324 | + return ret; | |
| 325 | + } | |
| 324 | 326 | |
| 325 | 327 | ret = mid8250_dma_setup(mid, &uart); |
| 326 | 328 | if (ret) |
| @@ -336,7 +338,8 @@ static int mid8250_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 9 unmodified lines | ||
| 336 | 338 | return 0; |
| 337 | 339 | |
| 338 | 340 | err: |
| 339 | − mid->board->exit(mid); | |
| 341 | + if (mid->board->exit) | |
| 342 | + mid->board->exit(mid); | |
| 340 | 343 | return ret; |
| 341 | 344 | } |
| 342 | 345 | |
| @@ -346,7 +349,8 @@ static void mid8250_remove(struct pci_dev *pdev) · 3 unmodified lines | ||
| 346 | 349 | |
| 347 | 350 | serial8250_unregister_port(mid->line); |
| 348 | 351 | |
| 349 | − mid->board->exit(mid); | |
| 352 | + if (mid->board->exit) | |
| 353 | + mid->board->exit(mid); | |
| 350 | 354 | } |
| 351 | 355 | |
| 352 | 356 | static const struct mid8250_board pnw_board = { |
| @@ -1273,6 +1273,17 @@ static int sc16is7xx_gpio_set(struct gpio_chip *chip, unsigned int offset, · 1272 unmodified lines | ||
| 1273 | 1273 | return 0; |
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | +static int sc16is7xx_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) | |
| 1277 | +{ | |
| 1278 | + struct sc16is7xx_port *s = gpiochip_get_data(chip); | |
| 1279 | + struct uart_port *port = &s->p[0].port; | |
| 1280 | + unsigned int val; | |
| 1281 | + | |
| 1282 | + val = sc16is7xx_port_read(port, SC16IS7XX_IODIR_REG); | |
| 1283 | + | |
| 1284 | + return val & BIT(offset) ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN; | |
| 1285 | +} | |
| 1286 | + | |
| 1276 | 1287 | static int sc16is7xx_gpio_direction_input(struct gpio_chip *chip, |
| 1277 | 1288 | unsigned offset) |
| 1278 | 1289 | { |
| @@ -1350,6 +1361,7 @@ static int sc16is7xx_setup_gpio_chip(struct sc16is7xx_port *s) · 71 unmodified lines | ||
| 1350 | 1361 | s->gpio.parent = dev; |
| 1351 | 1362 | s->gpio.label = dev_name(dev); |
| 1352 | 1363 | s->gpio.init_valid_mask = sc16is7xx_gpio_init_valid_mask; |
| 1364 | + s->gpio.get_direction = sc16is7xx_gpio_get_direction; | |
| 1353 | 1365 | s->gpio.direction_input = sc16is7xx_gpio_direction_input; |
| 1354 | 1366 | s->gpio.get = sc16is7xx_gpio_get; |
| 1355 | 1367 | s->gpio.direction_output = sc16is7xx_gpio_direction_output; |
| @@ -396,9 +396,15 @@ hv_uio_remove(struct hv_device *dev) · 395 unmodified lines | ||
| 396 | 396 | vmbus_free_ring(dev->channel); |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | +static const struct hv_vmbus_device_id hv_uio_id_table[] = { | |
| 400 | + { HV_FCOPY_GUID }, | |
| 401 | + {} | |
| 402 | +}; | |
| 403 | +MODULE_DEVICE_TABLE(vmbus, hv_uio_id_table); | |
| 404 | + | |
| 399 | 405 | static struct hv_driver hv_uio_drv = { |
| 400 | 406 | .name = "uio_hv_generic", |
| 401 | − .id_table = NULL, /* only dynamic id's */ | |
| 407 | + .id_table = hv_uio_id_table, | |
| 402 | 408 | .probe = hv_uio_probe, |
| 403 | 409 | .remove = hv_uio_remove, |
| 404 | 410 | }; |
| @@ -2549,6 +2549,7 @@ static struct usbatm_driver uea_usbatm_driver = { · 2548 unmodified lines | ||
| 2549 | 2549 | static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 2550 | 2550 | { |
| 2551 | 2551 | struct usb_device *usb = interface_to_usbdev(intf); |
| 2552 | + bool single_iface = usb->config->desc.bNumInterfaces == 1; | |
| 2552 | 2553 | int ret; |
| 2553 | 2554 | |
| 2554 | 2555 | uea_dbg(usb, "ADSL device found with vid (%#X) pid (%#X) Rev (%#X): %s\n", |
| @@ -2557,6 +2558,22 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id) · 2 unmodified lines | ||
| 2557 | 2558 | le16_to_cpu(usb->descriptor.bcdDevice), |
| 2558 | 2559 | chip_name[UEA_CHIP_VERSION(id)]); |
| 2559 | 2560 | |
| 2561 | + /* | |
| 2562 | + * uea_probe() decides between the pre-firmware and post-firmware case | |
| 2563 | + * from the USB id and stores a different object as interface data in | |
| 2564 | + * each case: a struct completion for a pre-firmware device, a struct | |
| 2565 | + * usbatm_data for a post-firmware one. uea_disconnect() instead tells | |
| 2566 | + * the two apart by the number of interfaces (a pre-firmware device | |
| 2567 | + * exposes a single interface, ADI930 has 2 and eagle has 3). A crafted | |
| 2568 | + * device advertising a pre-firmware id together with a multi-interface | |
| 2569 | + * descriptor (or the other way around) makes the two disagree, so that | |
| 2570 | + * usbatm_usb_disconnect() treats the small completion object as a | |
| 2571 | + * struct usbatm_data and reads out of bounds. Reject such inconsistent | |
| 2572 | + * descriptors so both paths make the same decision. | |
| 2573 | + */ | |
| 2574 | + if (UEA_IS_PREFIRM(id) != single_iface) | |
| 2575 | + return -ENODEV; | |
| 2576 | + | |
| 2560 | 2577 | usb_reset_device(usb); |
| 2561 | 2578 | |
| 2562 | 2579 | if (UEA_IS_PREFIRM(id)) { |
| @@ -1250,6 +1250,7 @@ static void ci_hdrc_remove(struct platform_device *pdev) · 1249 unmodified lines | ||
| 1250 | 1250 | usb_role_switch_unregister(ci->role_switch); |
| 1251 | 1251 | |
| 1252 | 1252 | if (ci->supports_runtime_pm) { |
| 1253 | + pm_runtime_dont_use_autosuspend(&pdev->dev); | |
| 1253 | 1254 | pm_runtime_get_sync(&pdev->dev); |
| 1254 | 1255 | pm_runtime_disable(&pdev->dev); |
| 1255 | 1256 | pm_runtime_put_noidle(&pdev->dev); |
| @@ -740,6 +740,8 @@ static void connector_unbind(struct device *dev, struct device *connector, void · 739 unmodified lines | ||
| 740 | 740 | |
| 741 | 741 | sysfs_remove_link(&connector->kobj, dev_name(dev)); |
| 742 | 742 | sysfs_remove_link(&dev->kobj, "connector"); |
| 743 | + if (port_dev->child) | |
| 744 | + typec_deattach(port_dev->connector, &port_dev->child->dev); | |
| 743 | 745 | port_dev->connector = NULL; |
| 744 | 746 | } |
| 745 | 747 | |
| @@ -899,10 +899,15 @@ bos_descriptors_read(struct file *filp, struct kobject *kobj, · 898 unmodified lines | ||
| 899 | 899 | { |
| 900 | 900 | struct device *dev = kobj_to_dev(kobj); |
| 901 | 901 | struct usb_device *udev = to_usb_device(dev); |
| 902 | − struct usb_host_bos *bos = udev->bos; | |
| 902 | + struct usb_host_bos *bos; | |
| 903 | 903 | struct usb_bos_descriptor *desc; |
| 904 | 904 | size_t desclen, n = 0; |
| 905 | + int rc; | |
| 905 | 906 | |
| 907 | + rc = usb_lock_device_interruptible(udev); | |
| 908 | + if (rc < 0) | |
| 909 | + return -EINTR; | |
| 910 | + bos = udev->bos; | |
| 906 | 911 | if (bos) { |
| 907 | 912 | desc = bos->desc; |
| 908 | 913 | desclen = le16_to_cpu(desc->wTotalLength); |
| @@ -911,6 +916,7 @@ bos_descriptors_read(struct file *filp, struct kobject *kobj, · 2 unmodified lines | ||
| 911 | 916 | memcpy(buf, (void *) desc + off, n); |
| 912 | 917 | } |
| 913 | 918 | } |
| 919 | + usb_unlock_device(udev); | |
| 914 | 920 | return n; |
| 915 | 921 | } |
| 916 | 922 | static const BIN_ATTR_RO(bos_descriptors, 65535); /* max-size BOS */ |
| @@ -1309,6 +1309,7 @@ static void f_midi_free(struct usb_function *f) · 1308 unmodified lines | ||
| 1309 | 1309 | opts = container_of(f->fi, struct f_midi_opts, func_inst); |
| 1310 | 1310 | mutex_lock(&opts->lock); |
| 1311 | 1311 | if (!--midi->free_ref) { |
| 1312 | + cancel_work_sync(&midi->work); | |
| 1312 | 1313 | kfree(midi->id); |
| 1313 | 1314 | kfifo_free(&midi->in_req_fifo); |
| 1314 | 1315 | kfree(midi); |
| @@ -1189,6 +1189,10 @@ static int ncm_unwrap_ntb(struct gether *port, · 1188 unmodified lines | ||
| 1189 | 1189 | frame_max = ncm_opts->max_segment_size; |
| 1190 | 1190 | |
| 1191 | 1191 | parse_ntb: |
| 1192 | + if (to_process < (int)opts->nth_size) { | |
| 1193 | + INFO(port->func.config->cdev, "Packet too small for headers\n"); | |
| 1194 | + goto err; | |
| 1195 | + } | |
| 1192 | 1196 | tmp = (__le16 *)ntb_ptr; |
| 1193 | 1197 | |
| 1194 | 1198 | /* dwSignature */ |
| @@ -1209,8 +1213,12 @@ parse_ntb: · 14 unmodified lines | ||
| 1209 | 1213 | tmp++; /* skip wSequence */ |
| 1210 | 1214 | |
| 1211 | 1215 | block_len = get_ncm(&tmp, opts->block_length); |
| 1216 | + if (block_len == 0) | |
| 1217 | + block_len = to_process; | |
| 1218 | + | |
| 1212 | 1219 | /* (d)wBlockLength */ |
| 1213 | − if ((block_len < opts->nth_size + opts->ndp_size) || (block_len > ntb_max)) { | |
| 1220 | + if ((block_len < opts->nth_size + opts->ndp_size) || (block_len > ntb_max) || | |
| 1221 | + (block_len > to_process)) { | |
| 1214 | 1222 | INFO(port->func.config->cdev, "Bad block length: %#X\n", block_len); |
| 1215 | 1223 | goto err; |
| 1216 | 1224 | } |
| @@ -1273,7 +1281,7 @@ parse_ntb: · 56 unmodified lines | ||
| 1273 | 1281 | index = index2; |
| 1274 | 1282 | /* wDatagramIndex[0] */ |
| 1275 | 1283 | if ((index < opts->nth_size) || |
| 1276 | − (index > block_len - opts->dpe_size)) { | |
| 1284 | + (index > block_len)) { | |
| 1277 | 1285 | INFO(port->func.config->cdev, |
| 1278 | 1286 | "Bad index: %#X\n", index); |
| 1279 | 1287 | goto err; |
| @@ -1285,7 +1293,8 @@ parse_ntb: · 5 unmodified lines | ||
| 1285 | 1293 | * ethernet hdr + crc or larger than max frame size |
| 1286 | 1294 | */ |
| 1287 | 1295 | if ((dg_len < 14 + crc_len) || |
| 1288 | − (dg_len > frame_max)) { | |
| 1296 | + (dg_len > frame_max) || | |
| 1297 | + (dg_len > block_len - index)) { | |
| 1289 | 1298 | INFO(port->func.config->cdev, |
| 1290 | 1299 | "Bad dgram length: %#X\n", dg_len); |
| 1291 | 1300 | goto err; |
| @@ -1310,7 +1319,7 @@ parse_ntb: · 18 unmodified lines | ||
| 1310 | 1319 | dg_len2 = get_ncm(&tmp, opts->dgram_item_len); |
| 1311 | 1320 | |
| 1312 | 1321 | /* wDatagramIndex[1] */ |
| 1313 | − if (index2 > block_len - opts->dpe_size) { | |
| 1322 | + if (index2 > block_len) { | |
| 1314 | 1323 | INFO(port->func.config->cdev, |
| 1315 | 1324 | "Bad index: %#X\n", index2); |
| 1316 | 1325 | goto err; |
| @@ -431,7 +431,7 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) · 430 unmodified lines | ||
| 431 | 431 | { |
| 432 | 432 | struct printer_dev *dev = fd->private_data; |
| 433 | 433 | unsigned long flags; |
| 434 | − size_t size; | |
| 434 | + size_t size, not_copied, copied; | |
| 435 | 435 | size_t bytes_copied; |
| 436 | 436 | struct usb_request *req; |
| 437 | 437 | /* This is a pointer to the current USB rx request. */ |
| @@ -524,10 +524,12 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) · 86 unmodified lines | ||
| 524 | 524 | else |
| 525 | 525 | size = len; |
| 526 | 526 | |
| 527 | − size -= copy_to_user(buf, current_rx_buf, size); | |
| 528 | − bytes_copied += size; | |
| 529 | − len -= size; | |
| 530 | − buf += size; | |
| 527 | + not_copied = copy_to_user(buf, current_rx_buf, size); | |
| 528 | + copied = size - not_copied; | |
| 529 | + | |
| 530 | + bytes_copied += copied; | |
| 531 | + len -= copied; | |
| 532 | + buf += copied; | |
| 531 | 533 | |
| 532 | 534 | spin_lock_irqsave(&dev->lock, flags); |
| 533 | 535 | |
| @@ -542,6 +544,17 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) · 8 unmodified lines | ||
| 542 | 544 | if (dev->interface < 0) |
| 543 | 545 | goto out_disabled; |
| 544 | 546 | |
| 547 | + if (!copied) { | |
| 548 | + dev->current_rx_req = current_rx_req; | |
| 549 | + dev->current_rx_bytes = current_rx_bytes; | |
| 550 | + dev->current_rx_buf = current_rx_buf; | |
| 551 | + spin_unlock_irqrestore(&dev->lock, flags); | |
| 552 | + mutex_unlock(&dev->lock_printer_io); | |
| 553 | + return bytes_copied ? bytes_copied : -EFAULT; | |
| 554 | + } | |
| 555 | + | |
| 556 | + size = copied; | |
| 557 | + | |
| 545 | 558 | /* If we not returning all the data left in this RX request |
| 546 | 559 | * buffer then adjust the amount of data left in the buffer. |
| 547 | 560 | * Othewise if we are done with this RX request buffer then |
| @@ -2363,31 +2363,158 @@ ep_fail: · 2362 unmodified lines | ||
| 2363 | 2363 | return -ENOTSUPP; |
| 2364 | 2364 | } |
| 2365 | 2365 | |
| 2366 | −struct guas_setup_wq { | |
| 2367 | − struct work_struct work; | |
| 2368 | − struct f_uas *fu; | |
| 2369 | − unsigned int alt; | |
| 2370 | −}; | |
| 2366 | +static void tcm_cleanup_old_alt(struct f_uas *fu) | |
| 2367 | +{ | |
| 2368 | + if (fu->flags & USBG_IS_UAS) | |
| 2369 | + uasp_cleanup_old_alt(fu); | |
| 2370 | + else if (fu->flags & USBG_IS_BOT) | |
| 2371 | + bot_cleanup_old_alt(fu); | |
| 2372 | + fu->flags = 0; | |
| 2373 | +} | |
| 2374 | + | |
| 2375 | +static void tcm_delayed_set_alt_done(struct f_uas *fu) | |
| 2376 | +{ | |
| 2377 | + unsigned long flags; | |
| 2378 | + | |
| 2379 | + spin_lock_irqsave(&fu->delayed_set_alt_lock, flags); | |
| 2380 | + fu->delayed_set_alt_state = USBG_DELAYED_SET_ALT_IDLE; | |
| 2381 | + fu->delayed_set_alt_cancel = false; | |
| 2382 | + spin_unlock_irqrestore(&fu->delayed_set_alt_lock, flags); | |
| 2383 | +} | |
| 2384 | + | |
| 2385 | +static bool tcm_delayed_set_alt_cancelled(struct f_uas *fu) | |
| 2386 | +{ | |
| 2387 | + bool cancelled; | |
| 2388 | + unsigned long flags; | |
| 2389 | + | |
| 2390 | + spin_lock_irqsave(&fu->delayed_set_alt_lock, flags); | |
| 2391 | + cancelled = fu->delayed_set_alt_cancel; | |
| 2392 | + spin_unlock_irqrestore(&fu->delayed_set_alt_lock, flags); | |
| 2393 | + | |
| 2394 | + return cancelled; | |
| 2395 | +} | |
| 2396 | + | |
| 2397 | +static bool tcm_complete_delayed_status(struct f_uas *fu) | |
| 2398 | +{ | |
| 2399 | + struct usb_composite_dev *cdev = fu->function.config->cdev; | |
| 2400 | + struct usb_request *req = cdev->req; | |
| 2401 | + unsigned long cdev_flags; | |
| 2402 | + bool cancelled; | |
| 2403 | + int ret; | |
| 2404 | + | |
| 2405 | + spin_lock_irqsave(&cdev->lock, cdev_flags); | |
| 2406 | + spin_lock(&fu->delayed_set_alt_lock); | |
| 2407 | + cancelled = fu->delayed_set_alt_cancel; | |
| 2408 | + if (!cancelled) { | |
| 2409 | + fu->delayed_set_alt_state = USBG_DELAYED_SET_ALT_IDLE; | |
| 2410 | + fu->delayed_set_alt_cancel = false; | |
| 2411 | + } | |
| 2412 | + spin_unlock(&fu->delayed_set_alt_lock); | |
| 2413 | + | |
| 2414 | + if (cancelled) { | |
| 2415 | + spin_unlock_irqrestore(&cdev->lock, cdev_flags); | |
| 2416 | + return false; | |
| 2417 | + } | |
| 2418 | + | |
| 2419 | + if (cdev->delayed_status == 0) { | |
| 2420 | + WARN(cdev, "%s: Unexpected call\n", __func__); | |
| 2421 | + } else if (--cdev->delayed_status == 0) { | |
| 2422 | + req->length = 0; | |
| 2423 | + req->context = cdev; | |
| 2424 | + ret = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC); | |
| 2425 | + if (ret == 0) { | |
| 2426 | + cdev->setup_pending = true; | |
| 2427 | + } else { | |
| 2428 | + req->status = 0; | |
| 2429 | + req->complete(cdev->gadget->ep0, req); | |
| 2430 | + } | |
| 2431 | + } | |
| 2432 | + | |
| 2433 | + spin_unlock_irqrestore(&cdev->lock, cdev_flags); | |
| 2434 | + | |
| 2435 | + return true; | |
| 2436 | +} | |
| 2437 | + | |
| 2438 | +static bool tcm_cancel_delayed_set_alt(struct f_uas *fu) | |
| 2439 | +{ | |
| 2440 | + bool cleanup = false; | |
| 2441 | + bool cancel = false; | |
| 2442 | + unsigned long flags; | |
| 2443 | + | |
| 2444 | + spin_lock_irqsave(&fu->delayed_set_alt_lock, flags); | |
| 2445 | + switch (fu->delayed_set_alt_state) { | |
| 2446 | + case USBG_DELAYED_SET_ALT_IDLE: | |
| 2447 | + cleanup = true; | |
| 2448 | + break; | |
| 2449 | + case USBG_DELAYED_SET_ALT_QUEUED: | |
| 2450 | + case USBG_DELAYED_SET_ALT_RUNNING: | |
| 2451 | + fu->delayed_set_alt_cancel = true; | |
| 2452 | + cancel = true; | |
| 2453 | + break; | |
| 2454 | + } | |
| 2455 | + spin_unlock_irqrestore(&fu->delayed_set_alt_lock, flags); | |
| 2456 | + | |
| 2457 | + if (cancel && cancel_work(&fu->delayed_set_alt)) { | |
| 2458 | + spin_lock_irqsave(&fu->delayed_set_alt_lock, flags); | |
| 2459 | + if (fu->delayed_set_alt_state == USBG_DELAYED_SET_ALT_QUEUED) { | |
| 2460 | + fu->delayed_set_alt_state = USBG_DELAYED_SET_ALT_IDLE; | |
| 2461 | + fu->delayed_set_alt_cancel = false; | |
| 2462 | + cleanup = true; | |
| 2463 | + } | |
| 2464 | + spin_unlock_irqrestore(&fu->delayed_set_alt_lock, flags); | |
| 2465 | + } | |
| 2466 | + | |
| 2467 | + return cleanup; | |
| 2468 | +} | |
| 2469 | + | |
| 2470 | +static void tcm_cancel_delayed_set_alt_sync(struct f_uas *fu) | |
| 2471 | +{ | |
| 2472 | + unsigned long flags; | |
| 2473 | + | |
| 2474 | + spin_lock_irqsave(&fu->delayed_set_alt_lock, flags); | |
| 2475 | + if (fu->delayed_set_alt_state != USBG_DELAYED_SET_ALT_IDLE) | |
| 2476 | + fu->delayed_set_alt_cancel = true; | |
| 2477 | + spin_unlock_irqrestore(&fu->delayed_set_alt_lock, flags); | |
| 2478 | + | |
| 2479 | + cancel_work_sync(&fu->delayed_set_alt); | |
| 2480 | + | |
| 2481 | + spin_lock_irqsave(&fu->delayed_set_alt_lock, flags); | |
| 2482 | + fu->delayed_set_alt_state = USBG_DELAYED_SET_ALT_IDLE; | |
| 2483 | + fu->delayed_set_alt_cancel = false; | |
| 2484 | + spin_unlock_irqrestore(&fu->delayed_set_alt_lock, flags); | |
| 2485 | +} | |
| 2371 | 2486 | |
| 2372 | 2487 | static void tcm_delayed_set_alt(struct work_struct *wq) |
| 2373 | 2488 | { |
| 2374 | − struct guas_setup_wq *work = container_of(wq, struct guas_setup_wq, | |
| 2375 | − work); | |
| 2376 | − struct f_uas *fu = work->fu; | |
| 2377 | − int alt = work->alt; | |
| 2489 | + struct f_uas *fu = container_of(wq, struct f_uas, delayed_set_alt); | |
| 2490 | + unsigned long flags; | |
| 2491 | + unsigned int alt; | |
| 2378 | 2492 | |
| 2379 | − kfree(work); | |
| 2493 | + spin_lock_irqsave(&fu->delayed_set_alt_lock, flags); | |
| 2494 | + if (fu->delayed_set_alt_state != USBG_DELAYED_SET_ALT_QUEUED) { | |
| 2495 | + spin_unlock_irqrestore(&fu->delayed_set_alt_lock, flags); | |
| 2496 | + return; | |
| 2497 | + } | |
| 2498 | + fu->delayed_set_alt_state = USBG_DELAYED_SET_ALT_RUNNING; | |
| 2499 | + alt = fu->delayed_alt; | |
| 2500 | + spin_unlock_irqrestore(&fu->delayed_set_alt_lock, flags); | |
| 2380 | 2501 | |
| 2381 | − if (fu->flags & USBG_IS_BOT) | |
| 2382 | − bot_cleanup_old_alt(fu); | |
| 2383 | − if (fu->flags & USBG_IS_UAS) | |
| 2384 | − uasp_cleanup_old_alt(fu); | |
| 2502 | + tcm_cleanup_old_alt(fu); | |
| 2503 | + | |
| 2504 | + if (tcm_delayed_set_alt_cancelled(fu)) | |
| 2505 | + goto out_done; | |
| 2385 | 2506 | |
| 2386 | 2507 | if (alt == USB_G_ALT_INT_BBB) |
| 2387 | 2508 | bot_set_alt(fu); |
| 2388 | 2509 | else if (alt == USB_G_ALT_INT_UAS) |
| 2389 | 2510 | uasp_set_alt(fu); |
| 2390 | − usb_composite_setup_continue(fu->function.config->cdev); | |
| 2511 | + | |
| 2512 | + if (tcm_complete_delayed_status(fu)) | |
| 2513 | + return; | |
| 2514 | + | |
| 2515 | + tcm_cleanup_old_alt(fu); | |
| 2516 | +out_done: | |
| 2517 | + tcm_delayed_set_alt_done(fu); | |
| 2391 | 2518 | } |
| 2392 | 2519 | |
| 2393 | 2520 | static int tcm_get_alt(struct usb_function *f, unsigned intf) |
| @@ -2413,15 +2540,20 @@ static int tcm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) · 19 unmodified lines | ||
| 2413 | 2540 | return -EOPNOTSUPP; |
| 2414 | 2541 | |
| 2415 | 2542 | if ((alt == USB_G_ALT_INT_BBB) || (alt == USB_G_ALT_INT_UAS)) { |
| 2416 | − struct guas_setup_wq *work; | |
| 2543 | + unsigned long flags; | |
| 2417 | 2544 | |
| 2418 | − work = kmalloc_obj(*work, GFP_ATOMIC); | |
| 2419 | − if (!work) | |
| 2420 | − return -ENOMEM; | |
| 2421 | − INIT_WORK(&work->work, tcm_delayed_set_alt); | |
| 2422 | − work->fu = fu; | |
| 2423 | − work->alt = alt; | |
| 2424 | − schedule_work(&work->work); | |
| 2545 | + spin_lock_irqsave(&fu->delayed_set_alt_lock, flags); | |
| 2546 | + if (fu->delayed_set_alt_state != USBG_DELAYED_SET_ALT_IDLE) { | |
| 2547 | + spin_unlock_irqrestore(&fu->delayed_set_alt_lock, | |
| 2548 | + flags); | |
| 2549 | + return -EBUSY; | |
| 2550 | + } | |
| 2551 | + fu->delayed_alt = alt; | |
| 2552 | + fu->delayed_set_alt_cancel = false; | |
| 2553 | + fu->delayed_set_alt_state = USBG_DELAYED_SET_ALT_QUEUED; | |
| 2554 | + spin_unlock_irqrestore(&fu->delayed_set_alt_lock, flags); | |
| 2555 | + | |
| 2556 | + schedule_work(&fu->delayed_set_alt); | |
| 2425 | 2557 | return USB_GADGET_DELAYED_STATUS; |
| 2426 | 2558 | } |
| 2427 | 2559 | return -EOPNOTSUPP; |
| @@ -2431,11 +2563,8 @@ static void tcm_disable(struct usb_function *f) · 3 unmodified lines | ||
| 2431 | 2563 | { |
| 2432 | 2564 | struct f_uas *fu = to_f_uas(f); |
| 2433 | 2565 | |
| 2434 | − if (fu->flags & USBG_IS_UAS) | |
| 2435 | − uasp_cleanup_old_alt(fu); | |
| 2436 | − else if (fu->flags & USBG_IS_BOT) | |
| 2437 | − bot_cleanup_old_alt(fu); | |
| 2438 | − fu->flags = 0; | |
| 2566 | + if (tcm_cancel_delayed_set_alt(fu)) | |
| 2567 | + tcm_cleanup_old_alt(fu); | |
| 2439 | 2568 | } |
| 2440 | 2569 | |
| 2441 | 2570 | static int tcm_setup(struct usb_function *f, |
| @@ -2583,11 +2712,16 @@ static void tcm_free(struct usb_function *f) · 141 unmodified lines | ||
| 2583 | 2712 | { |
| 2584 | 2713 | struct f_uas *tcm = to_f_uas(f); |
| 2585 | 2714 | |
| 2715 | + tcm_cancel_delayed_set_alt_sync(tcm); | |
| 2586 | 2716 | kfree(tcm); |
| 2587 | 2717 | } |
| 2588 | 2718 | |
| 2589 | 2719 | static void tcm_unbind(struct usb_configuration *c, struct usb_function *f) |
| 2590 | 2720 | { |
| 2721 | + struct f_uas *fu = to_f_uas(f); | |
| 2722 | + | |
| 2723 | + tcm_cancel_delayed_set_alt_sync(fu); | |
| 2724 | + tcm_cleanup_old_alt(fu); | |
| 2591 | 2725 | usb_free_all_descriptors(f); |
| 2592 | 2726 | } |
| 2593 | 2727 | |
| @@ -2620,6 +2754,8 @@ static struct usb_function *tcm_alloc(struct usb_function_instance *fi) · 26 unmodified lines | ||
| 2620 | 2754 | fu->function.disable = tcm_disable; |
| 2621 | 2755 | fu->function.free_func = tcm_free; |
| 2622 | 2756 | fu->tpg = tpg_instances[i].tpg; |
| 2757 | + INIT_WORK(&fu->delayed_set_alt, tcm_delayed_set_alt); | |
| 2758 | + spin_lock_init(&fu->delayed_set_alt_lock); | |
| 2623 | 2759 | |
| 2624 | 2760 | hash_init(fu->stream_hash); |
| 2625 | 2761 | mutex_unlock(&tpg_instances_lock); |
| @@ -3,6 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | #define __TARGET_USB_GADGET_H__ |
| 4 | 4 | |
| 5 | 5 | #include <linux/kref.h> |
| 6 | +#include <linux/spinlock.h> | |
| 6 | 7 | /* #include <linux/usb/uas.h> */ |
| 7 | 8 | #include <linux/hashtable.h> |
| 8 | 9 | #include <linux/usb/composite.h> |
| @@ -29,6 +30,12 @@ enum { · 20 unmodified lines | ||
| 29 | 30 | |
| 30 | 31 | #define USB_G_DEFAULT_SESSION_TAGS USBG_NUM_CMDS |
| 31 | 32 | |
| 33 | +enum { | |
| 34 | + USBG_DELAYED_SET_ALT_IDLE = 0, | |
| 35 | + USBG_DELAYED_SET_ALT_QUEUED, | |
| 36 | + USBG_DELAYED_SET_ALT_RUNNING, | |
| 37 | +}; | |
| 38 | + | |
| 32 | 39 | struct tcm_usbg_nexus { |
| 33 | 40 | struct se_session *tvn_se_sess; |
| 34 | 41 | }; |
| @@ -132,6 +139,12 @@ struct f_uas { · 97 unmodified lines | ||
| 132 | 139 | #define USBG_BOT_CMD_PEND (1 << 4) |
| 133 | 140 | #define USBG_BOT_WEDGED (1 << 5) |
| 134 | 141 | |
| 142 | + struct work_struct delayed_set_alt; | |
| 143 | + spinlock_t delayed_set_alt_lock; /* protects delayed_set_alt_* */ | |
| 144 | + unsigned int delayed_alt; | |
| 145 | + unsigned int delayed_set_alt_state; | |
| 146 | + bool delayed_set_alt_cancel; | |
| 147 | + | |
| 135 | 148 | struct usbg_cdb cmd[USBG_NUM_CMDS]; |
| 136 | 149 | struct usb_ep *ep_in; |
| 137 | 150 | struct usb_ep *ep_out; |
| @@ -200,6 +200,8 @@ uvc_send_response(struct uvc_device *uvc, struct uvc_request_data *data) · 199 unmodified lines | ||
| 200 | 200 | return usb_ep_set_halt(cdev->gadget->ep0); |
| 201 | 201 | |
| 202 | 202 | req->length = min_t(unsigned int, uvc->event_length, data->length); |
| 203 | + if (req->length > sizeof(data->data)) | |
| 204 | + req->length = sizeof(data->data); | |
| 203 | 205 | req->zero = data->length < uvc->event_length; |
| 204 | 206 | |
| 205 | 207 | memcpy(req->buf, data->data, req->length); |
| @@ -585,9 +585,29 @@ disable_clk: · 584 unmodified lines | ||
| 585 | 585 | static void bdc_remove(struct platform_device *pdev) |
| 586 | 586 | { |
| 587 | 587 | struct bdc *bdc; |
| 588 | + unsigned long flags; | |
| 589 | + u32 temp; | |
| 588 | 590 | |
| 589 | 591 | bdc = platform_get_drvdata(pdev); |
| 590 | 592 | dev_dbg(bdc->dev, "%s ()\n", __func__); |
| 593 | + /* | |
| 594 | + * Disable the device interrupt source before freeing the IRQ: | |
| 595 | + * clear BDC_GIE so the controller stops asserting interrupts, | |
| 596 | + * then free_irq drains any in-flight handler. | |
| 597 | + */ | |
| 598 | + spin_lock_irqsave(&bdc->lock, flags); | |
| 599 | + temp = bdc_readl(bdc->regs, BDC_BDCSC); | |
| 600 | + temp &= ~BDC_GIE; | |
| 601 | + bdc_writel(bdc->regs, BDC_BDCSC, temp); | |
| 602 | + spin_unlock_irqrestore(&bdc->lock, flags); | |
| 603 | + free_irq(bdc->irq, bdc); | |
| 604 | + /* | |
| 605 | + * Drain func_wake_notify after free_irq: the IRQ handler arms this | |
| 606 | + * delayed_work via bdc_sr_uspc -> handle_link_state_change -> | |
| 607 | + * schedule_delayed_work (self-rearmed in bdc_func_wake_timer), so | |
| 608 | + * the IRQ must be released first to prevent re-arm after cancel. | |
| 609 | + */ | |
| 610 | + cancel_delayed_work_sync(&bdc->func_wake_notify); | |
| 591 | 611 | bdc_udc_exit(bdc); |
| 592 | 612 | bdc_hw_exit(bdc); |
| 593 | 613 | bdc_phy_exit(bdc); |
| @@ -530,8 +530,8 @@ int bdc_udc_init(struct bdc *bdc) · 529 unmodified lines | ||
| 530 | 530 | |
| 531 | 531 | |
| 532 | 532 | bdc->gadget.name = BRCM_BDC_NAME; |
| 533 | − ret = devm_request_irq(bdc->dev, bdc->irq, bdc_udc_interrupt, | |
| 534 | − IRQF_SHARED, BRCM_BDC_NAME, bdc); | |
| 533 | + ret = request_irq(bdc->irq, bdc_udc_interrupt, IRQF_SHARED, | |
| 534 | + BRCM_BDC_NAME, bdc); | |
| 535 | 535 | if (ret) { |
| 536 | 536 | dev_err(bdc->dev, |
| 537 | 537 | "failed to request irq #%d %d\n", |
| @@ -542,7 +542,7 @@ int bdc_udc_init(struct bdc *bdc) · 4 unmodified lines | ||
| 542 | 542 | ret = bdc_init_ep(bdc); |
| 543 | 543 | if (ret) { |
| 544 | 544 | dev_err(bdc->dev, "bdc init ep fail: %d\n", ret); |
| 545 | − return ret; | |
| 545 | + goto err0; | |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | ret = usb_add_gadget_udc(bdc->dev, &bdc->gadget); |
| @@ -571,6 +571,7 @@ int bdc_udc_init(struct bdc *bdc) · 22 unmodified lines | ||
| 571 | 571 | err1: |
| 572 | 572 | usb_del_gadget_udc(&bdc->gadget); |
| 573 | 573 | err0: |
| 574 | + free_irq(bdc->irq, bdc); | |
| 574 | 575 | bdc_free_ep(bdc); |
| 575 | 576 | |
| 576 | 577 | return ret; |
| @@ -278,6 +278,7 @@ struct dummy { · 277 unmodified lines | ||
| 278 | 278 | unsigned ints_enabled:1; |
| 279 | 279 | unsigned udc_suspended:1; |
| 280 | 280 | unsigned pullup:1; |
| 281 | + unsigned fifo_req_busy:1; | |
| 281 | 282 | |
| 282 | 283 | /* |
| 283 | 284 | * HOST side support |
| @@ -329,6 +330,26 @@ static inline struct dummy *gadget_dev_to_dummy(struct device *dev) · 45 unmodified lines | ||
| 329 | 330 | |
| 330 | 331 | /* DEVICE/GADGET SIDE UTILITY ROUTINES */ |
| 331 | 332 | |
| 333 | +/* | |
| 334 | + * Give back a gadget request with dum->lock dropped around the callback. | |
| 335 | + * If @req is the shared fifo_req, clear fifo_req_busy afterward: the flag | |
| 336 | + * was set in dummy_queue() when the shared request was taken and must stay | |
| 337 | + * set until its completion callback has returned; list_del_init() alone | |
| 338 | + * makes the request look idle while the callback is still running. | |
| 339 | + * Caller holds dum->lock and has already done list_del_init() + status. | |
| 340 | + */ | |
| 341 | +static void dummy_giveback(struct dummy *dum, struct usb_ep *_ep, | |
| 342 | + struct dummy_request *req) | |
| 343 | +{ | |
| 344 | + bool fifo = req == &dum->fifo_req; | |
| 345 | + | |
| 346 | + spin_unlock(&dum->lock); | |
| 347 | + usb_gadget_giveback_request(_ep, &req->req); | |
| 348 | + spin_lock(&dum->lock); | |
| 349 | + if (fifo) | |
| 350 | + dum->fifo_req_busy = 0; | |
| 351 | +} | |
| 352 | + | |
| 332 | 353 | /* called with spinlock held */ |
| 333 | 354 | static void nuke(struct dummy *dum, struct dummy_ep *ep) |
| 334 | 355 | { |
| @@ -339,9 +360,7 @@ static void nuke(struct dummy *dum, struct dummy_ep *ep) · 4 unmodified lines | ||
| 339 | 360 | list_del_init(&req->queue); |
| 340 | 361 | req->req.status = -ESHUTDOWN; |
| 341 | 362 | |
| 342 | − spin_unlock(&dum->lock); | |
| 343 | − usb_gadget_giveback_request(&ep->ep, &req->req); | |
| 344 | − spin_lock(&dum->lock); | |
| 363 | + dummy_giveback(dum, &ep->ep, req); | |
| 345 | 364 | } |
| 346 | 365 | } |
| 347 | 366 | |
| @@ -728,10 +747,11 @@ static int dummy_queue(struct usb_ep *_ep, struct usb_request *_req, · 380 unmodified lines | ||
| 728 | 747 | |
| 729 | 748 | /* implement an emulated single-request FIFO */ |
| 730 | 749 | if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && |
| 731 | − list_empty(&dum->fifo_req.queue) && | |
| 750 | + !dum->fifo_req_busy && | |
| 732 | 751 | list_empty(&ep->queue) && |
| 733 | 752 | _req->length <= FIFO_SIZE) { |
| 734 | 753 | req = &dum->fifo_req; |
| 754 | + dum->fifo_req_busy = 1; | |
| 735 | 755 | req->req = *_req; |
| 736 | 756 | req->req.buf = dum->fifo_buf; |
| 737 | 757 | memcpy(dum->fifo_buf, _req->buf, _req->length); |
| @@ -785,9 +805,7 @@ static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req) · 47 unmodified lines | ||
| 785 | 805 | dev_dbg(udc_dev(dum), |
| 786 | 806 | "dequeued req %p from %s, len %d buf %p\n", |
| 787 | 807 | req, _ep->name, _req->length, _req->buf); |
| 788 | − spin_unlock(&dum->lock); | |
| 789 | − usb_gadget_giveback_request(_ep, _req); | |
| 790 | − spin_lock(&dum->lock); | |
| 808 | + dummy_giveback(dum, _ep, req); | |
| 791 | 809 | } |
| 792 | 810 | spin_unlock_irqrestore(&dum->lock, flags); |
| 793 | 811 | return retval; |
| @@ -1523,9 +1541,7 @@ top: · 729 unmodified lines | ||
| 1523 | 1541 | if (req->req.status != -EINPROGRESS) { |
| 1524 | 1542 | list_del_init(&req->queue); |
| 1525 | 1543 | |
| 1526 | − spin_unlock(&dum->lock); | |
| 1527 | − usb_gadget_giveback_request(&ep->ep, &req->req); | |
| 1528 | − spin_lock(&dum->lock); | |
| 1544 | + dummy_giveback(dum, &ep->ep, req); | |
| 1529 | 1545 | |
| 1530 | 1546 | /* requests might have been unlinked... */ |
| 1531 | 1547 | rescan = 1; |
| @@ -1910,9 +1926,7 @@ restart: · 378 unmodified lines | ||
| 1910 | 1926 | dev_dbg(udc_dev(dum), "stale req = %p\n", |
| 1911 | 1927 | req); |
| 1912 | 1928 | |
| 1913 | − spin_unlock(&dum->lock); | |
| 1914 | − usb_gadget_giveback_request(&ep->ep, &req->req); | |
| 1915 | − spin_lock(&dum->lock); | |
| 1929 | + dummy_giveback(dum, &ep->ep, req); | |
| 1916 | 1930 | ep->already_seen = 0; |
| 1917 | 1931 | goto restart; |
| 1918 | 1932 | } |
| @@ -184,7 +184,7 @@ __acquires(ep->udc->lock) · 183 unmodified lines | ||
| 184 | 184 | usb_gadget_unmap_request(&ep->udc->gadget, &req->req, ep_is_in(ep)); |
| 185 | 185 | |
| 186 | 186 | if (status && (status != -ESHUTDOWN)) |
| 187 | − dev_vdbg(&udc->gadget.dev, "complete %s req %p stat %d len %u/%u\n", | |
| 187 | + dev_vdbg(udc->dev, "complete %s req %p stat %d len %u/%u\n", | |
| 188 | 188 | ep->ep.name, &req->req, status, |
| 189 | 189 | req->req.actual, req->req.length); |
| 190 | 190 | |
| @@ -286,7 +286,7 @@ static int dr_controller_setup(struct fsl_udc *udc) · 95 unmodified lines | ||
| 286 | 286 | timeout = jiffies + FSL_UDC_RESET_TIMEOUT; |
| 287 | 287 | while (fsl_readl(&dr_regs->usbcmd) & USB_CMD_CTRL_RESET) { |
| 288 | 288 | if (time_after(jiffies, timeout)) { |
| 289 | − dev_err(&udc->gadget.dev, "udc reset timeout!\n"); | |
| 289 | + dev_err(udc->dev, "udc reset timeout!\n"); | |
| 290 | 290 | return -ETIMEDOUT; |
| 291 | 291 | } |
| 292 | 292 | cpu_relax(); |
| @@ -309,7 +309,7 @@ static int dr_controller_setup(struct fsl_udc *udc) · 16 unmodified lines | ||
| 309 | 309 | tmp &= USB_EP_LIST_ADDRESS_MASK; |
| 310 | 310 | fsl_writel(tmp, &dr_regs->endpointlistaddr); |
| 311 | 311 | |
| 312 | − dev_vdbg(&udc->gadget.dev, | |
| 312 | + dev_vdbg(udc->dev, | |
| 313 | 313 | "vir[qh_base] is %p phy[qh_base] is 0x%8x reg is 0x%8x\n", |
| 314 | 314 | udc->ep_qh, (int)tmp, |
| 315 | 315 | fsl_readl(&dr_regs->endpointlistaddr)); |
| @@ -500,7 +500,7 @@ static void struct_ep_qh_setup(struct fsl_udc *udc, unsigned char ep_num, · 184 unmodified lines | ||
| 500 | 500 | tmp = max_pkt_len << EP_QUEUE_HEAD_MAX_PKT_LEN_POS; |
| 501 | 501 | break; |
| 502 | 502 | default: |
| 503 | − dev_vdbg(&udc->gadget.dev, "error ep type is %d\n", ep_type); | |
| 503 | + dev_vdbg(udc->dev, "error ep type is %d\n", ep_type); | |
| 504 | 504 | return; |
| 505 | 505 | } |
| 506 | 506 | if (zlt) |
| @@ -613,7 +613,7 @@ static int fsl_ep_enable(struct usb_ep *_ep, · 106 unmodified lines | ||
| 613 | 613 | spin_unlock_irqrestore(&udc->lock, flags); |
| 614 | 614 | retval = 0; |
| 615 | 615 | |
| 616 | − dev_vdbg(&udc->gadget.dev, "enabled %s (ep%d%s) maxpacket %d\n", | |
| 616 | + dev_vdbg(udc->dev, "enabled %s (ep%d%s) maxpacket %d\n", | |
| 617 | 617 | ep->ep.name, ep->ep.desc->bEndpointAddress & 0x0f, |
| 618 | 618 | (desc->bEndpointAddress & USB_DIR_IN) ? "in" : "out", |
| 619 | 619 | max); |
| @@ -634,13 +634,8 @@ static int fsl_ep_disable(struct usb_ep *_ep) · 14 unmodified lines | ||
| 634 | 634 | int ep_num; |
| 635 | 635 | |
| 636 | 636 | ep = container_of(_ep, struct fsl_ep, ep); |
| 637 | − if (!_ep || !ep->ep.desc) { | |
| 638 | − /* | |
| 639 | − * dev_vdbg(&udc->gadget.dev, "%s not enabled\n", | |
| 640 | − * _ep ? ep->ep.name : NULL); | |
| 641 | − */ | |
| 637 | + if (!_ep || !ep->ep.desc) | |
| 642 | 638 | return -EINVAL; |
| 643 | − } | |
| 644 | 639 | |
| 645 | 640 | /* disable ep on controller */ |
| 646 | 641 | ep_num = ep_index(ep); |
| @@ -664,7 +659,7 @@ static int fsl_ep_disable(struct usb_ep *_ep) · 17 unmodified lines | ||
| 664 | 659 | ep->stopped = 1; |
| 665 | 660 | spin_unlock_irqrestore(&udc->lock, flags); |
| 666 | 661 | |
| 667 | − dev_vdbg(&udc->gadget.dev, "disabled %s OK\n", _ep->name); | |
| 662 | + dev_vdbg(udc->dev, "disabled %s OK\n", _ep->name); | |
| 668 | 663 | return 0; |
| 669 | 664 | } |
| 670 | 665 | |
| @@ -724,9 +719,6 @@ static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) · 53 unmodified lines | ||
| 724 | 719 | { |
| 725 | 720 | u32 temp, bitmask, tmp_stat; |
| 726 | 721 | |
| 727 | − /* dev_vdbg(&udc->gadget.dev, "QH addr Register 0x%8x\n", dr_regs->endpointlistaddr); | |
| 728 | − dev_vdbg(&udc->gadget.dev, "ep_qh[%d] addr is 0x%8x\n", i, (u32)&(ep->udc->ep_qh[i])); */ | |
| 729 | − | |
| 730 | 722 | bitmask = ep_is_in(ep) |
| 731 | 723 | ? (1 << (ep_index(ep) + 16)) |
| 732 | 724 | : (1 << (ep_index(ep))); |
| @@ -813,7 +805,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, · 80 unmodified lines | ||
| 813 | 805 | *is_last = 0; |
| 814 | 806 | |
| 815 | 807 | if ((*is_last) == 0) |
| 816 | − dev_vdbg(&udc_controller->gadget.dev, "multi-dtd request!\n"); | |
| 808 | + dev_vdbg(udc_controller->dev, "multi-dtd request!\n"); | |
| 817 | 809 | /* Fill in the transfer size; set active bit */ |
| 818 | 810 | swap_temp = ((*length << DTD_LENGTH_BIT_POS) | DTD_STATUS_ACTIVE); |
| 819 | 811 | |
| @@ -825,7 +817,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, · 5 unmodified lines | ||
| 825 | 817 | |
| 826 | 818 | mb(); |
| 827 | 819 | |
| 828 | − dev_vdbg(&udc_controller->gadget.dev, "length = %d address= 0x%x\n", *length, (int)*dma); | |
| 820 | + dev_vdbg(udc_controller->dev, "length = %d address= 0x%x\n", *length, (int)*dma); | |
| 829 | 821 | |
| 830 | 822 | return dtd; |
| 831 | 823 | } |
| @@ -876,11 +868,11 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) · 44 unmodified lines | ||
| 876 | 868 | /* catch various bogus parameters */ |
| 877 | 869 | if (!_req || !req->req.complete || !req->req.buf |
| 878 | 870 | || !list_empty(&req->queue)) { |
| 879 | − dev_vdbg(&udc->gadget.dev, "%s, bad params\n", __func__); | |
| 871 | + dev_vdbg(udc->dev, "%s, bad params\n", __func__); | |
| 880 | 872 | return -EINVAL; |
| 881 | 873 | } |
| 882 | 874 | if (unlikely(!ep->ep.desc)) { |
| 883 | − dev_vdbg(&udc->gadget.dev, "%s, bad ep\n", __func__); | |
| 875 | + dev_vdbg(udc->dev, "%s, bad ep\n", __func__); | |
| 884 | 876 | return -EINVAL; |
| 885 | 877 | } |
| 886 | 878 | if (usb_endpoint_xfer_isoc(ep->ep.desc)) { |
| @@ -1040,7 +1032,7 @@ static int fsl_ep_set_halt(struct usb_ep *_ep, int value) · 153 unmodified lines | ||
| 1040 | 1032 | udc->ep0_dir = 0; |
| 1041 | 1033 | } |
| 1042 | 1034 | out: |
| 1043 | − dev_vdbg(&udc->gadget.dev, "%s %s halt stat %d\n", ep->ep.name, | |
| 1035 | + dev_vdbg(udc->dev, "%s %s halt stat %d\n", ep->ep.name, | |
| 1044 | 1036 | value ? "set" : "clear", status); |
| 1045 | 1037 | |
| 1046 | 1038 | return status; |
| @@ -1109,7 +1101,7 @@ static void fsl_ep_fifo_flush(struct usb_ep *_ep) · 62 unmodified lines | ||
| 1109 | 1101 | /* Wait until flush complete */ |
| 1110 | 1102 | while (fsl_readl(&dr_regs->endptflush)) { |
| 1111 | 1103 | if (time_after(jiffies, timeout)) { |
| 1112 | − dev_err(&udc_controller->gadget.dev, | |
| 1104 | + dev_err(udc_controller->dev, | |
| 1113 | 1105 | "ep flush timeout\n"); |
| 1114 | 1106 | return; |
| 1115 | 1107 | } |
| @@ -1182,7 +1174,7 @@ static int fsl_vbus_session(struct usb_gadget *gadget, int is_active) · 66 unmodified lines | ||
| 1182 | 1174 | |
| 1183 | 1175 | udc = container_of(gadget, struct fsl_udc, gadget); |
| 1184 | 1176 | spin_lock_irqsave(&udc->lock, flags); |
| 1185 | − dev_vdbg(&gadget->dev, "VBUS %s\n", str_on_off(is_active)); | |
| 1177 | + dev_vdbg(udc->dev, "VBUS %s\n", str_on_off(is_active)); | |
| 1186 | 1178 | udc->vbus_active = (is_active != 0); |
| 1187 | 1179 | if (can_pullup(udc)) |
| 1188 | 1180 | fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP), |
| @@ -1548,7 +1540,7 @@ static void ep0_req_complete(struct fsl_udc *udc, struct fsl_ep *ep0, · 359 unmodified lines | ||
| 1548 | 1540 | udc->ep0_state = WAIT_FOR_SETUP; |
| 1549 | 1541 | break; |
| 1550 | 1542 | case WAIT_FOR_SETUP: |
| 1551 | − dev_err(&udc->gadget.dev, "Unexpected ep0 packets\n"); | |
| 1543 | + dev_err(udc->dev, "Unexpected ep0 packets\n"); | |
| 1552 | 1544 | break; |
| 1553 | 1545 | default: |
| 1554 | 1546 | ep0stall(udc); |
| @@ -1617,7 +1609,7 @@ static int process_ep_req(struct fsl_udc *udc, int pipe, · 62 unmodified lines | ||
| 1617 | 1609 | errors = hc32_to_cpu(curr_td->size_ioc_sts); |
| 1618 | 1610 | if (errors & DTD_ERROR_MASK) { |
| 1619 | 1611 | if (errors & DTD_STATUS_HALTED) { |
| 1620 | − dev_err(&udc->gadget.dev, "dTD error %08x QH=%d\n", errors, pipe); | |
| 1612 | + dev_err(udc->dev, "dTD error %08x QH=%d\n", errors, pipe); | |
| 1621 | 1613 | /* Clear the errors and Halt condition */ |
| 1622 | 1614 | tmp = hc32_to_cpu(curr_qh->size_ioc_int_sts); |
| 1623 | 1615 | tmp &= ~errors; |
| @@ -1628,26 +1620,26 @@ static int process_ep_req(struct fsl_udc *udc, int pipe, · 4 unmodified lines | ||
| 1628 | 1620 | break; |
| 1629 | 1621 | } |
| 1630 | 1622 | if (errors & DTD_STATUS_DATA_BUFF_ERR) { |
| 1631 | − dev_vdbg(&udc->gadget.dev, "Transfer overflow\n"); | |
| 1623 | + dev_vdbg(udc->dev, "Transfer overflow\n"); | |
| 1632 | 1624 | status = -EPROTO; |
| 1633 | 1625 | break; |
| 1634 | 1626 | } else if (errors & DTD_STATUS_TRANSACTION_ERR) { |
| 1635 | − dev_vdbg(&udc->gadget.dev, "ISO error\n"); | |
| 1627 | + dev_vdbg(udc->dev, "ISO error\n"); | |
| 1636 | 1628 | status = -EILSEQ; |
| 1637 | 1629 | break; |
| 1638 | 1630 | } else |
| 1639 | − dev_err(&udc->gadget.dev, | |
| 1631 | + dev_err(udc->dev, | |
| 1640 | 1632 | "Unknown error has occurred (0x%x)!\n", |
| 1641 | 1633 | errors); |
| 1642 | 1634 | |
| 1643 | 1635 | } else if (hc32_to_cpu(curr_td->size_ioc_sts) |
| 1644 | 1636 | & DTD_STATUS_ACTIVE) { |
| 1645 | − dev_vdbg(&udc->gadget.dev, "Request not complete\n"); | |
| 1637 | + dev_vdbg(udc->dev, "Request not complete\n"); | |
| 1646 | 1638 | status = REQ_UNCOMPLETE; |
| 1647 | 1639 | return status; |
| 1648 | 1640 | } else if (remaining_length) { |
| 1649 | 1641 | if (direction) { |
| 1650 | − dev_vdbg(&udc->gadget.dev, | |
| 1642 | + dev_vdbg(udc->dev, | |
| 1651 | 1643 | "Transmit dTD remaining length not zero\n"); |
| 1652 | 1644 | status = -EPROTO; |
| 1653 | 1645 | break; |
| @@ -1655,8 +1647,7 @@ static int process_ep_req(struct fsl_udc *udc, int pipe, · 1 unmodified line | ||
| 1655 | 1647 | break; |
| 1656 | 1648 | } |
| 1657 | 1649 | } else { |
| 1658 | − dev_vdbg(&udc->gadget.dev, | |
| 1659 | − "dTD transmitted successful\n"); | |
| 1650 | + dev_vdbg(udc->dev, "dTD transmitted successful\n"); | |
| 1660 | 1651 | } |
| 1661 | 1652 | |
| 1662 | 1653 | if (j != curr_req->dtd_count - 1) |
| @@ -1699,7 +1690,7 @@ static void dtd_complete_irq(struct fsl_udc *udc) · 36 unmodified lines | ||
| 1699 | 1690 | |
| 1700 | 1691 | /* If the ep is configured */ |
| 1701 | 1692 | if (!curr_ep->ep.name) { |
| 1702 | − dev_warn(&udc->gadget.dev, "Invalid EP?\n"); | |
| 1693 | + dev_warn(udc->dev, "Invalid EP?\n"); | |
| 1703 | 1694 | continue; |
| 1704 | 1695 | } |
| 1705 | 1696 | |
| @@ -1708,7 +1699,7 @@ static void dtd_complete_irq(struct fsl_udc *udc) · 2 unmodified lines | ||
| 1708 | 1699 | queue) { |
| 1709 | 1700 | status = process_ep_req(udc, i, curr_req); |
| 1710 | 1701 | |
| 1711 | − dev_vdbg(&udc->gadget.dev, | |
| 1702 | + dev_vdbg(udc->dev, | |
| 1712 | 1703 | "status of process_ep_req= %d, ep = %d\n", |
| 1713 | 1704 | status, ep_num); |
| 1714 | 1705 | if (status == REQ_UNCOMPLETE) |
| @@ -1829,7 +1820,7 @@ static void reset_irq(struct fsl_udc *udc) · 114 unmodified lines | ||
| 1829 | 1820 | while (fsl_readl(&dr_regs->endpointprime)) { |
| 1830 | 1821 | /* Wait until all endptprime bits cleared */ |
| 1831 | 1822 | if (time_after(jiffies, timeout)) { |
| 1832 | − dev_err(&udc->gadget.dev, "Timeout for reset\n"); | |
| 1823 | + dev_err(udc->dev, "Timeout for reset\n"); | |
| 1833 | 1824 | break; |
| 1834 | 1825 | } |
| 1835 | 1826 | cpu_relax(); |
| @@ -1839,7 +1830,7 @@ static void reset_irq(struct fsl_udc *udc) · 3 unmodified lines | ||
| 1839 | 1830 | fsl_writel(0xffffffff, &dr_regs->endptflush); |
| 1840 | 1831 | |
| 1841 | 1832 | if (fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET) { |
| 1842 | − dev_vdbg(&udc->gadget.dev, "Bus reset\n"); | |
| 1833 | + dev_vdbg(udc->dev, "Bus reset\n"); | |
| 1843 | 1834 | /* Bus is reseting */ |
| 1844 | 1835 | udc->bus_reset = 1; |
| 1845 | 1836 | /* Reset all the queues, include XD, dTD, EP queue |
| @@ -1847,7 +1838,7 @@ static void reset_irq(struct fsl_udc *udc) · 1 unmodified line | ||
| 1847 | 1838 | reset_queues(udc, true); |
| 1848 | 1839 | udc->usb_state = USB_STATE_DEFAULT; |
| 1849 | 1840 | } else { |
| 1850 | − dev_vdbg(&udc->gadget.dev, "Controller reset\n"); | |
| 1841 | + dev_vdbg(udc->dev, "Controller reset\n"); | |
| 1851 | 1842 | /* initialize usb hw reg except for regs for EP, not |
| 1852 | 1843 | * touch usbintr reg */ |
| 1853 | 1844 | dr_controller_setup(udc); |
| @@ -1881,7 +1872,7 @@ static irqreturn_t fsl_udc_irq(int irq, void *_udc) · 27 unmodified lines | ||
| 1881 | 1872 | /* Clear notification bits */ |
| 1882 | 1873 | fsl_writel(irq_src, &dr_regs->usbsts); |
| 1883 | 1874 | |
| 1884 | − /* dev_vdbg(&udc->gadget.dev, "irq_src [0x%8x]", irq_src); */ | |
| 1875 | + /* dev_vdbg(udc->dev, "irq_src [0x%8x]", irq_src); */ | |
| 1885 | 1876 | |
| 1886 | 1877 | /* Need to resume? */ |
| 1887 | 1878 | if (udc->usb_state == USB_STATE_SUSPENDED) |
| @@ -1890,7 +1881,7 @@ static irqreturn_t fsl_udc_irq(int irq, void *_udc) · 2 unmodified lines | ||
| 1890 | 1881 | |
| 1891 | 1882 | /* USB Interrupt */ |
| 1892 | 1883 | if (irq_src & USB_STS_INT) { |
| 1893 | − dev_vdbg(&udc->gadget.dev, "Packet int\n"); | |
| 1884 | + dev_vdbg(udc->dev, "Packet int\n"); | |
| 1894 | 1885 | /* Setup package, we only support ep0 as control ep */ |
| 1895 | 1886 | if (fsl_readl(&dr_regs->endptsetupstat) & EP_SETUP_STATUS_EP0) { |
| 1896 | 1887 | tripwire_handler(udc, 0, |
| @@ -1919,7 +1910,7 @@ static irqreturn_t fsl_udc_irq(int irq, void *_udc) · 22 unmodified lines | ||
| 1919 | 1910 | |
| 1920 | 1911 | /* Reset Received */ |
| 1921 | 1912 | if (irq_src & USB_STS_RESET) { |
| 1922 | − dev_vdbg(&udc->gadget.dev, "reset int\n"); | |
| 1913 | + dev_vdbg(udc->dev, "reset int\n"); | |
| 1923 | 1914 | reset_irq(udc); |
| 1924 | 1915 | status = IRQ_HANDLED; |
| 1925 | 1916 | } |
| @@ -1931,7 +1922,7 @@ static irqreturn_t fsl_udc_irq(int irq, void *_udc) · 5 unmodified lines | ||
| 1931 | 1922 | } |
| 1932 | 1923 | |
| 1933 | 1924 | if (irq_src & (USB_STS_ERR | USB_STS_SYS_ERR)) { |
| 1934 | − dev_vdbg(&udc->gadget.dev, "Error IRQ %x\n", irq_src); | |
| 1925 | + dev_vdbg(udc->dev, "Error IRQ %x\n", irq_src); | |
| 1935 | 1926 | } |
| 1936 | 1927 | |
| 1937 | 1928 | spin_unlock_irqrestore(&udc->lock, flags); |
| @@ -1967,7 +1958,7 @@ static int fsl_udc_start(struct usb_gadget *g, · 29 unmodified lines | ||
| 1967 | 1958 | udc_controller->transceiver->otg, |
| 1968 | 1959 | &udc_controller->gadget); |
| 1969 | 1960 | if (retval < 0) { |
| 1970 | − dev_err(&udc_controller->gadget.dev, "can't bind to transceiver\n"); | |
| 1961 | + dev_err(udc_controller->dev, "can't bind to transceiver\n"); | |
| 1971 | 1962 | udc_controller->driver = NULL; |
| 1972 | 1963 | return retval; |
| 1973 | 1964 | } |
| @@ -2252,7 +2243,7 @@ static int struct_udc_setup(struct fsl_udc *udc, · 278 unmodified lines | ||
| 2252 | 2243 | |
| 2253 | 2244 | udc->eps = kzalloc_objs(struct fsl_ep, udc->max_ep); |
| 2254 | 2245 | if (!udc->eps) { |
| 2255 | − dev_err(&udc->gadget.dev, "kmalloc udc endpoint status failed\n"); | |
| 2246 | + dev_err(udc->dev, "kmalloc udc endpoint status failed\n"); | |
| 2256 | 2247 | goto eps_alloc_failed; |
| 2257 | 2248 | } |
| 2258 | 2249 | |
| @@ -2267,7 +2258,7 @@ static int struct_udc_setup(struct fsl_udc *udc, · 8 unmodified lines | ||
| 2267 | 2258 | udc->ep_qh = dma_alloc_coherent(&pdev->dev, size, |
| 2268 | 2259 | &udc->ep_qh_dma, GFP_KERNEL); |
| 2269 | 2260 | if (!udc->ep_qh) { |
| 2270 | − dev_err(&udc->gadget.dev, "malloc QHs for udc failed\n"); | |
| 2261 | + dev_err(udc->dev, "malloc QHs for udc failed\n"); | |
| 2271 | 2262 | goto ep_queue_alloc_failed; |
| 2272 | 2263 | } |
| 2273 | 2264 | |
| @@ -2278,14 +2269,14 @@ static int struct_udc_setup(struct fsl_udc *udc, · 4 unmodified lines | ||
| 2278 | 2269 | udc->status_req = container_of(fsl_alloc_request(NULL, GFP_KERNEL), |
| 2279 | 2270 | struct fsl_req, req); |
| 2280 | 2271 | if (!udc->status_req) { |
| 2281 | − dev_err(&udc->gadget.dev, "kzalloc for udc status request failed\n"); | |
| 2272 | + dev_err(udc->dev, "kzalloc for udc status request failed\n"); | |
| 2282 | 2273 | goto udc_status_alloc_failed; |
| 2283 | 2274 | } |
| 2284 | 2275 | |
| 2285 | 2276 | /* allocate a small amount of memory to get valid address */ |
| 2286 | 2277 | udc->status_req->req.buf = kmalloc(8, GFP_KERNEL); |
| 2287 | 2278 | if (!udc->status_req->req.buf) { |
| 2288 | − dev_err(&udc->gadget.dev, "kzalloc for udc request buffer failed\n"); | |
| 2279 | + dev_err(udc->dev, "kzalloc for udc request buffer failed\n"); | |
| 2289 | 2280 | goto udc_req_buf_alloc_failed; |
| 2290 | 2281 | } |
| 2291 | 2282 | |
| @@ -2373,6 +2364,7 @@ static int fsl_udc_probe(struct platform_device *pdev) · 81 unmodified lines | ||
| 2373 | 2364 | if (udc_controller == NULL) |
| 2374 | 2365 | return -ENOMEM; |
| 2375 | 2366 | |
| 2367 | + udc_controller->dev = &pdev->dev; | |
| 2376 | 2368 | pdata = dev_get_platdata(&pdev->dev); |
| 2377 | 2369 | udc_controller->pdata = pdata; |
| 2378 | 2370 | spin_lock_init(&udc_controller->lock); |
| @@ -2382,7 +2374,7 @@ static int fsl_udc_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 2382 | 2374 | if (pdata->operating_mode == FSL_USB2_DR_OTG) { |
| 2383 | 2375 | udc_controller->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); |
| 2384 | 2376 | if (IS_ERR_OR_NULL(udc_controller->transceiver)) { |
| 2385 | − dev_err(&udc_controller->gadget.dev, "Can't find OTG driver!\n"); | |
| 2377 | + dev_err(&pdev->dev, "Can't find OTG driver!\n"); | |
| 2386 | 2378 | ret = -ENODEV; |
| 2387 | 2379 | goto err_kfree; |
| 2388 | 2380 | } |
| @@ -2398,7 +2390,7 @@ static int fsl_udc_probe(struct platform_device *pdev) · 9 unmodified lines | ||
| 2398 | 2390 | if (pdata->operating_mode == FSL_USB2_DR_DEVICE) { |
| 2399 | 2391 | if (!request_mem_region(res->start, resource_size(res), |
| 2400 | 2392 | driver_name)) { |
| 2401 | − dev_err(&udc_controller->gadget.dev, "request mem region for %s failed\n", pdev->name); | |
| 2393 | + dev_err(&pdev->dev, "failed to request mem region\n"); | |
| 2402 | 2394 | ret = -EBUSY; |
| 2403 | 2395 | goto err_kfree; |
| 2404 | 2396 | } |
| @@ -2429,7 +2421,7 @@ static int fsl_udc_probe(struct platform_device *pdev) · 24 unmodified lines | ||
| 2429 | 2421 | /* Read Device Controller Capability Parameters register */ |
| 2430 | 2422 | dccparams = fsl_readl(&dr_regs->dccparams); |
| 2431 | 2423 | if (!(dccparams & DCCPARAMS_DC)) { |
| 2432 | − dev_err(&udc_controller->gadget.dev, "This SOC doesn't support device role\n"); | |
| 2424 | + dev_err(&pdev->dev, "This SOC doesn't support device role\n"); | |
| 2433 | 2425 | ret = -ENODEV; |
| 2434 | 2426 | goto err_exit; |
| 2435 | 2427 | } |
| @@ -2447,14 +2439,14 @@ static int fsl_udc_probe(struct platform_device *pdev) · 11 unmodified lines | ||
| 2447 | 2439 | ret = request_irq(udc_controller->irq, fsl_udc_irq, IRQF_SHARED, |
| 2448 | 2440 | driver_name, udc_controller); |
| 2449 | 2441 | if (ret != 0) { |
| 2450 | − dev_err(&udc_controller->gadget.dev, "cannot request irq %d err %d\n", | |
| 2442 | + dev_err(&pdev->dev, "cannot request irq %d err %d\n", | |
| 2451 | 2443 | udc_controller->irq, ret); |
| 2452 | 2444 | goto err_exit; |
| 2453 | 2445 | } |
| 2454 | 2446 | |
| 2455 | 2447 | /* Initialize the udc structure including QH member and other member */ |
| 2456 | 2448 | if (struct_udc_setup(udc_controller, pdev)) { |
| 2457 | − dev_err(&udc_controller->gadget.dev, "Can't initialize udc data structure\n"); | |
| 2449 | + dev_err(&pdev->dev, "Can't initialize udc data structure\n"); | |
| 2458 | 2450 | ret = -ENOMEM; |
| 2459 | 2451 | goto err_free_irq; |
| 2460 | 2452 | } |
| @@ -2474,7 +2466,6 @@ static int fsl_udc_probe(struct platform_device *pdev) · 13 unmodified lines | ||
| 2474 | 2466 | udc_controller->gadget.name = driver_name; |
| 2475 | 2467 | |
| 2476 | 2468 | /* Setup gadget.dev and register with kernel */ |
| 2477 | − dev_set_name(&udc_controller->gadget.dev, "gadget"); | |
| 2478 | 2469 | udc_controller->gadget.dev.of_node = pdev->dev.of_node; |
| 2479 | 2470 | |
| 2480 | 2471 | if (!IS_ERR_OR_NULL(udc_controller->transceiver)) |
| @@ -2548,12 +2539,6 @@ static void fsl_udc_remove(struct platform_device *pdev) · 67 unmodified lines | ||
| 2548 | 2539 | |
| 2549 | 2540 | DECLARE_COMPLETION_ONSTACK(done); |
| 2550 | 2541 | |
| 2551 | − if (!udc_controller) { | |
| 2552 | − dev_err(&pdev->dev, | |
| 2553 | − "Driver still in use but removing anyhow\n"); | |
| 2554 | − return; | |
| 2555 | − } | |
| 2556 | − | |
| 2557 | 2542 | udc_controller->done = &done; |
| 2558 | 2543 | usb_del_gadget_udc(&udc_controller->gadget); |
| 2559 | 2544 | |
| @@ -470,6 +470,7 @@ struct fsl_ep { · 469 unmodified lines | ||
| 470 | 470 | #define EP_DIR_OUT 0 |
| 471 | 471 | |
| 472 | 472 | struct fsl_udc { |
| 473 | + struct device *dev; | |
| 473 | 474 | struct usb_gadget gadget; |
| 474 | 475 | struct usb_gadget_driver *driver; |
| 475 | 476 | struct fsl_usb2_platform_data *pdata; |
| @@ -2374,9 +2374,10 @@ static int pxa_udc_probe(struct platform_device *pdev) · 2373 unmodified lines | ||
| 2374 | 2374 | struct pxa_udc *udc = &memory; |
| 2375 | 2375 | int retval = 0; |
| 2376 | 2376 | |
| 2377 | − udc->gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_ASIS); | |
| 2377 | + udc->gpiod = devm_gpiod_get_optional(&pdev->dev, NULL, GPIOD_ASIS); | |
| 2378 | 2378 | if (IS_ERR(udc->gpiod)) |
| 2379 | − return PTR_ERR(udc->gpiod); | |
| 2379 | + return dev_err_probe(&pdev->dev, PTR_ERR(udc->gpiod), | |
| 2380 | + "Couldn't find or request D+ gpio\n"); | |
| 2380 | 2381 | |
| 2381 | 2382 | udc->regs = devm_platform_ioremap_resource(pdev, 0); |
| 2382 | 2383 | if (IS_ERR(udc->regs)) |
| @@ -2395,11 +2396,6 @@ static int pxa_udc_probe(struct platform_device *pdev) · 12 unmodified lines | ||
| 2395 | 2396 | udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); |
| 2396 | 2397 | } |
| 2397 | 2398 | |
| 2398 | − if (IS_ERR(udc->gpiod)) { | |
| 2399 | − dev_err(&pdev->dev, "Couldn't find or request D+ gpio : %ld\n", | |
| 2400 | − PTR_ERR(udc->gpiod)); | |
| 2401 | − return PTR_ERR(udc->gpiod); | |
| 2402 | − } | |
| 2403 | 2399 | if (udc->gpiod) |
| 2404 | 2400 | gpiod_direction_output(udc->gpiod, 0); |
| 2405 | 2401 | |
| @@ -3133,7 +3133,6 @@ int udc_probe(struct udc *dev) · 3132 unmodified lines | ||
| 3133 | 3133 | /* device struct setup */ |
| 3134 | 3134 | dev->gadget.ops = &udc_ops; |
| 3135 | 3135 | |
| 3136 | − dev_set_name(&dev->gadget.dev, "gadget"); | |
| 3137 | 3136 | dev->gadget.name = name; |
| 3138 | 3137 | dev->gadget.max_speed = USB_SPEED_HIGH; |
| 3139 | 3138 | |
| @@ -448,6 +448,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · 447 unmodified lines | ||
| 448 | 448 | if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == PCI_DEVICE_ID_VIA_VL805) { |
| 449 | 449 | xhci->quirks |= XHCI_LPM_SUPPORT; |
| 450 | 450 | xhci->quirks |= XHCI_TRB_OVERFETCH; |
| 451 | + xhci->dma_mask_bits = 36; | |
| 451 | 452 | } |
| 452 | 453 | |
| 453 | 454 | if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && |
| @@ -5466,6 +5466,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) · 5465 unmodified lines | ||
| 5466 | 5466 | if (xhci->hci_version > 0x100) |
| 5467 | 5467 | xhci->hcc_params2 = readl(&xhci->cap_regs->hcc_params2); |
| 5468 | 5468 | |
| 5469 | + xhci->dma_mask_bits = 64; | |
| 5469 | 5470 | xhci->max_slots = min(HCS_MAX_SLOTS(hcs_params1), MAX_HC_SLOTS); |
| 5470 | 5471 | xhci->max_ports = min(HCS_MAX_PORTS(hcs_params1), MAX_HC_PORTS); |
| 5471 | 5472 | /* xhci-plat or xhci-pci might have set max_interrupters already */ |
| @@ -5515,12 +5516,16 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) · 43 unmodified lines | ||
| 5515 | 5516 | if (xhci->quirks & XHCI_NO_64BIT_SUPPORT) |
| 5516 | 5517 | xhci->hcc_params &= ~BIT(0); |
| 5517 | 5518 | |
| 5518 | − /* Set dma_mask and coherent_dma_mask to 64-bits, | |
| 5519 | − * if xHC supports 64-bit addressing */ | |
| 5519 | + /* | |
| 5520 | + * Set dma_mask and coherent_dma_mask to 64-bits if xHC supports | |
| 5521 | + * 64-bit addressing, unless a controller-specific quirk callback | |
| 5522 | + * limits the usable address width. | |
| 5523 | + */ | |
| 5520 | 5524 | if ((xhci->hcc_params & HCC_64BIT_ADDR) && |
| 5521 | − !dma_set_mask(dev, DMA_BIT_MASK(64))) { | |
| 5522 | − xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n"); | |
| 5523 | − dma_set_coherent_mask(dev, DMA_BIT_MASK(64)); | |
| 5525 | + !dma_set_mask(dev, DMA_BIT_MASK(xhci->dma_mask_bits))) { | |
| 5526 | + xhci_dbg(xhci, "Enabling %u-bit DMA addresses.\n", | |
| 5527 | + xhci->dma_mask_bits); | |
| 5528 | + dma_set_coherent_mask(dev, DMA_BIT_MASK(xhci->dma_mask_bits)); | |
| 5524 | 5529 | } else { |
| 5525 | 5530 | /* |
| 5526 | 5531 | * This is to avoid error in cases where a 32-bit USB |
| @@ -1526,6 +1526,7 @@ struct xhci_hcd { · 1525 unmodified lines | ||
| 1526 | 1526 | /* imod_interval in ns (I * 250ns) */ |
| 1527 | 1527 | u32 imod_interval; |
| 1528 | 1528 | u32 page_size; |
| 1529 | + unsigned int dma_mask_bits; | |
| 1529 | 1530 | /* MSI-X/MSI vectors */ |
| 1530 | 1531 | int nvecs; |
| 1531 | 1532 | /* optional clocks */ |
| @@ -454,7 +454,6 @@ static int omap2430_probe(struct platform_device *pdev) · 453 unmodified lines | ||
| 454 | 454 | dev_err(&pdev->dev, "failed to register musb device\n"); |
| 455 | 455 | goto err_disable_rpm; |
| 456 | 456 | } |
| 457 | − of_node_put(np); | |
| 458 | 457 | |
| 459 | 458 | return 0; |
| 460 | 459 | |
| @@ -464,7 +463,6 @@ err_put_control_otghs: · 3 unmodified lines | ||
| 464 | 463 | if (!IS_ERR(glue->control_otghs)) |
| 465 | 464 | put_device(glue->control_otghs); |
| 466 | 465 | err_put_musb: |
| 467 | − of_node_put(np); | |
| 468 | 466 | platform_device_put(musb); |
| 469 | 467 | |
| 470 | 468 | return ret; |
| @@ -1072,6 +1072,8 @@ static const struct usb_device_id id_table_combined[] = { · 1071 unmodified lines | ||
| 1072 | 1072 | { USB_DEVICE_INTERFACE_NUMBER(ALTERA_VID, ALTERA_UB3_602E_PID, 3) }, |
| 1073 | 1073 | /* Abacus Electrics */ |
| 1074 | 1074 | { USB_DEVICE(FTDI_VID, ABACUS_OPTICAL_PROBE_PID) }, |
| 1075 | + /* Endress+Hauser AG devices */ | |
| 1076 | + { USB_DEVICE(FTDI_VID, FTDI_EH_FXA291_PID) }, | |
| 1075 | 1077 | { } /* Terminating entry */ |
| 1076 | 1078 | }; |
| 1077 | 1079 | |
| @@ -313,6 +313,11 @@ · 312 unmodified lines | ||
| 313 | 313 | #define FTDI_ELV_UDF77_PID 0xFB5E /* USB DCF Funkuhr (UDF 77) */ |
| 314 | 314 | #define FTDI_ELV_UIO88_PID 0xFB5F /* USB-I/O Interface (UIO 88) */ |
| 315 | 315 | |
| 316 | +/* | |
| 317 | + * Endress+Hauser AG product ids (FTDI_VID) | |
| 318 | + */ | |
| 319 | +#define FTDI_EH_FXA291_PID 0xE510 | |
| 320 | + | |
| 316 | 321 | /* |
| 317 | 322 | * EVER Eco Pro UPS (http://www.ever.com.pl/) |
| 318 | 323 | */ |
| @@ -646,7 +646,8 @@ static void edge_interrupt_callback(struct urb *urb) · 645 unmodified lines | ||
| 646 | 646 | if (edge_port && edge_port->open) { |
| 647 | 647 | spin_lock_irqsave(&edge_port->ep_lock, |
| 648 | 648 | flags); |
| 649 | − edge_port->txCredits += txCredits; | |
| 649 | + edge_port->txCredits = min(edge_port->txCredits + txCredits, | |
| 650 | + edge_port->maxTxCredits); | |
| 650 | 651 | spin_unlock_irqrestore(&edge_port->ep_lock, |
| 651 | 652 | flags); |
| 652 | 653 | dev_dbg(dev, "%s - txcredits for port%d = %d\n", |
| @@ -1464,6 +1464,12 @@ static int do_boot_mode(struct edgeport_serial *serial, · 1463 unmodified lines | ||
| 1464 | 1464 | /* Allocate a 15.5k buffer + 3 byte header */ |
| 1465 | 1465 | buffer_size = (((1024 * 16) - 512) + |
| 1466 | 1466 | sizeof(struct ti_i2c_image_header)); |
| 1467 | + if (fw->size - 4 > buffer_size) { | |
| 1468 | + dev_err(dev, "%s - firmware image is too large\n", | |
| 1469 | + __func__); | |
| 1470 | + return -EINVAL; | |
| 1471 | + } | |
| 1472 | + | |
| 1467 | 1473 | buffer = kmalloc(buffer_size, GFP_KERNEL); |
| 1468 | 1474 | if (!buffer) |
| 1469 | 1475 | return -ENOMEM; |
| @@ -33,6 +33,8 @@ struct keyspan_pda_private { · 32 unmodified lines | ||
| 33 | 33 | struct work_struct unthrottle_work; |
| 34 | 34 | struct usb_serial *serial; |
| 35 | 35 | struct usb_serial_port *port; |
| 36 | + bool throttled; | |
| 37 | + bool throttle_req; | |
| 36 | 38 | }; |
| 37 | 39 | |
| 38 | 40 | static int keyspan_pda_write_start(struct usb_serial_port *port); |
| @@ -148,6 +150,7 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) · 109 unmodified lines | ||
| 148 | 150 | int retval; |
| 149 | 151 | int status = urb->status; |
| 150 | 152 | struct keyspan_pda_private *priv; |
| 153 | + bool throttled = false; | |
| 151 | 154 | unsigned long flags; |
| 152 | 155 | |
| 153 | 156 | priv = usb_get_serial_port_data(port); |
| @@ -209,16 +212,24 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) · 55 unmodified lines | ||
| 209 | 212 | } |
| 210 | 213 | |
| 211 | 214 | exit: |
| 212 | − retval = usb_submit_urb(urb, GFP_ATOMIC); | |
| 213 | − if (retval) | |
| 214 | − dev_err(&port->dev, | |
| 215 | − "%s - usb_submit_urb failed with result %d\n", | |
| 216 | − __func__, retval); | |
| 215 | + spin_lock_irqsave(&port->lock, flags); | |
| 216 | + if (priv->throttle_req) { | |
| 217 | + priv->throttled = true; | |
| 218 | + throttled = true; | |
| 219 | + } | |
| 220 | + spin_unlock_irqrestore(&port->lock, flags); | |
| 221 | + | |
| 222 | + if (!throttled) { | |
| 223 | + retval = usb_submit_urb(urb, GFP_ATOMIC); | |
| 224 | + if (retval) | |
| 225 | + dev_err(&port->dev, "failed to resubmit in urb: %d\n", retval); | |
| 226 | + } | |
| 217 | 227 | } |
| 218 | 228 | |
| 219 | 229 | static void keyspan_pda_rx_throttle(struct tty_struct *tty) |
| 220 | 230 | { |
| 221 | 231 | struct usb_serial_port *port = tty->driver_data; |
| 232 | + struct keyspan_pda_private *priv = usb_get_serial_port_data(port); | |
| 222 | 233 | |
| 223 | 234 | /* |
| 224 | 235 | * Stop receiving characters. We just turn off the URB request, and |
| @@ -228,16 +239,29 @@ static void keyspan_pda_rx_throttle(struct tty_struct *tty) · 3 unmodified lines | ||
| 228 | 239 | * send an XOFF, although it might make sense to foist that off upon |
| 229 | 240 | * the device too. |
| 230 | 241 | */ |
| 231 | − usb_kill_urb(port->interrupt_in_urb); | |
| 242 | + spin_lock_irq(&port->lock); | |
| 243 | + priv->throttle_req = true; | |
| 244 | + spin_unlock_irq(&port->lock); | |
| 232 | 245 | } |
| 233 | 246 | |
| 234 | 247 | static void keyspan_pda_rx_unthrottle(struct tty_struct *tty) |
| 235 | 248 | { |
| 236 | 249 | struct usb_serial_port *port = tty->driver_data; |
| 250 | + struct keyspan_pda_private *priv = usb_get_serial_port_data(port); | |
| 251 | + bool throttled; | |
| 252 | + int ret; | |
| 237 | 253 | |
| 238 | − /* just restart the receive interrupt URB */ | |
| 239 | − if (usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL)) | |
| 240 | − dev_dbg(&port->dev, "usb_submit_urb(read urb) failed\n"); | |
| 254 | + spin_lock_irq(&port->lock); | |
| 255 | + throttled = priv->throttled; | |
| 256 | + priv->throttled = false; | |
| 257 | + priv->throttle_req = false; | |
| 258 | + spin_unlock_irq(&port->lock); | |
| 259 | + | |
| 260 | + if (throttled) { | |
| 261 | + ret = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | |
| 262 | + if (ret) | |
| 263 | + dev_err(&port->dev, "failed to submit in urb: %d\n", ret); | |
| 264 | + } | |
| 241 | 265 | } |
| 242 | 266 | |
| 243 | 267 | static speed_t keyspan_pda_setbaud(struct usb_serial *serial, speed_t baud) |
| @@ -577,6 +601,8 @@ static int keyspan_pda_open(struct tty_struct *tty, · 333 unmodified lines | ||
| 577 | 601 | |
| 578 | 602 | spin_lock_irq(&port->lock); |
| 579 | 603 | priv->tx_room = rc; |
| 604 | + priv->throttled = false; | |
| 605 | + priv->throttle_req = false; | |
| 580 | 606 | spin_unlock_irq(&port->lock); |
| 581 | 607 | |
| 582 | 608 | rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
| @@ -1080,6 +1080,13 @@ static int mxuport_probe(struct usb_serial *serial, · 1079 unmodified lines | ||
| 1080 | 1080 | /* Use the firmware already in the device */ |
| 1081 | 1081 | err = 0; |
| 1082 | 1082 | } else { |
| 1083 | + if (fw_p->size <= VER_ADDR_3) { | |
| 1084 | + dev_err(&serial->interface->dev, | |
| 1085 | + "Firmware %s is too short\n", buf); | |
| 1086 | + err = -EINVAL; | |
| 1087 | + goto out; | |
| 1088 | + } | |
| 1089 | + | |
| 1083 | 1090 | local_ver = ((fw_p->data[VER_ADDR_1] << 16) | |
| 1084 | 1091 | (fw_p->data[VER_ADDR_2] << 8) | |
| 1085 | 1092 | fw_p->data[VER_ADDR_3]); |
| @@ -2496,6 +2496,7 @@ static const struct usb_device_id option_ids[] = { · 2495 unmodified lines | ||
| 2496 | 2496 | .driver_info = RSVD(5) }, |
| 2497 | 2497 | { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x1003, 0xff), /* Rolling RW135R-GL (laptop MBIM) */ |
| 2498 | 2498 | .driver_info = RSVD(5) }, |
| 2499 | + { USB_DEVICE_INTERFACE_CLASS(0x3466, 0x3301, 0xff) }, /* TDTECH MT5710-CN */ | |
| 2499 | 2500 | { USB_DEVICE_AND_INTERFACE_INFO(0x3731, 0x0100, 0xff, 0xff, 0x30) }, /* NetPrisma LCUK54-WWD for Global */ |
| 2500 | 2501 | { USB_DEVICE_AND_INTERFACE_INFO(0x3731, 0x0100, 0xff, 0x00, 0x40) }, |
| 2501 | 2502 | { USB_DEVICE_AND_INTERFACE_INFO(0x3731, 0x0100, 0xff, 0xff, 0x40) }, |
| @@ -395,6 +395,13 @@ UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110, · 394 unmodified lines | ||
| 395 | 395 | USB_SC_DEVICE, USB_PR_CB, NULL, |
| 396 | 396 | US_FL_MAX_SECTORS_MIN), |
| 397 | 397 | |
| 398 | +/* Reported by Ai Chao <aichao@kylinos.cn> */ | |
| 399 | +UNUSUAL_DEV( 0x04b4, 0xb708, 0x0000, 0xffff, | |
| 400 | + "Longmai Technologies", | |
| 401 | + "USB Key", | |
| 402 | + USB_SC_SCSI, USB_PR_BULK, NULL, | |
| 403 | + US_FL_NO_ATA_1X), | |
| 404 | + | |
| 398 | 405 | /* |
| 399 | 406 | * Reported by Simon Levitt <simon@whattf.com> |
| 400 | 407 | * This entry needs Sub and Proto fields |
| @@ -529,6 +529,129 @@ err: · 528 unmodified lines | ||
| 529 | 529 | return ret; |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | +static void ucsi_dump_duplicate_altmode(struct ucsi_connector *con, | |
| 533 | + u8 recipient, u16 svid, | |
| 534 | + u32 existing_vdo, u32 new_vdo, | |
| 535 | + int offset) | |
| 536 | +{ | |
| 537 | + static const char * const recipient_names[] = { | |
| 538 | + [UCSI_RECIPIENT_CON] = "port", | |
| 539 | + [UCSI_RECIPIENT_SOP] = "partner", | |
| 540 | + [UCSI_RECIPIENT_SOP_P] = "plug", | |
| 541 | + [UCSI_RECIPIENT_SOP_PP] = "cable plug prime", | |
| 542 | + }; | |
| 543 | + | |
| 544 | + dev_warn(con->ucsi->dev, | |
| 545 | + "con%d: Firmware bug: duplicate %s altmode SVID 0x%04x at offset %d, ignoring but please contact the BIOS vendor to fix this issue.\n", | |
| 546 | + con->num, recipient_names[recipient], svid, offset); | |
| 547 | + | |
| 548 | + if (existing_vdo != new_vdo) | |
| 549 | + dev_warn(con->ucsi->dev, | |
| 550 | + "con%d: VDO mismatch: 0x%08x vs 0x%08x\n", | |
| 551 | + con->num, existing_vdo, new_vdo); | |
| 552 | +} | |
| 553 | + | |
| 554 | +/* Count altmodes in @altmodes that advertise @svid. */ | |
| 555 | +static int ucsi_altmode_count_svid(struct typec_altmode **altmodes, u16 svid) | |
| 556 | +{ | |
| 557 | + int count = 0; | |
| 558 | + int k; | |
| 559 | + | |
| 560 | + for (k = 0; k < UCSI_MAX_ALTMODES; k++) { | |
| 561 | + if (!altmodes[k]) | |
| 562 | + break; | |
| 563 | + if (altmodes[k]->svid == svid) | |
| 564 | + count++; | |
| 565 | + } | |
| 566 | + | |
| 567 | + return count; | |
| 568 | +} | |
| 569 | + | |
| 570 | +/* | |
| 571 | + * Check if an altmode is a duplicate. Some firmware implementations | |
| 572 | + * incorrectly return the same altmode multiple times, causing sysfs errors. | |
| 573 | + * Returns true if the altmode should be skipped. | |
| 574 | + * | |
| 575 | + * The matching rules differ by recipient: | |
| 576 | + * | |
| 577 | + * - UCSI_RECIPIENT_CON (port) and UCSI_RECIPIENT_SOP_P (plug): | |
| 578 | + * Two altmodes with identical SVID and VDO are byte-for-byte duplicates | |
| 579 | + * and the second has no observable function. Drop them. | |
| 580 | + * | |
| 581 | + * - UCSI_RECIPIENT_SOP (partner): | |
| 582 | + * The typec class binds each partner altmode to a port altmode of the | |
| 583 | + * same SVID via altmode_match()/device_find_child(), which returns the | |
| 584 | + * first port altmode with a matching SVID. If the partner advertises | |
| 585 | + * more altmodes for SVID X than the port advertises, the surplus | |
| 586 | + * partner altmode(s) collapse onto an already-paired port altmode and | |
| 587 | + * trigger a "duplicate filename .../partner" sysfs error during | |
| 588 | + * typec_altmode_create_links(). Use the port-side altmode count for | |
| 589 | + * SVID X as the authoritative cap and reject any partner altmode that | |
| 590 | + * would exceed it. This preserves legitimate multi-Mode partner | |
| 591 | + * altmodes (e.g. vendor SVIDs that the port really does advertise | |
| 592 | + * twice) while filtering the firmware-generated duplicates that have | |
| 593 | + * no port counterpart. | |
| 594 | + */ | |
| 595 | +static bool ucsi_altmode_is_duplicate(struct ucsi_connector *con, u8 recipient, | |
| 596 | + const struct ucsi_altmode *alt_batch, int batch_idx, | |
| 597 | + u16 svid, u32 vdo, int offset) | |
| 598 | +{ | |
| 599 | + struct typec_altmode **altmodes; | |
| 600 | + int port_count, partner_count; | |
| 601 | + int k; | |
| 602 | + | |
| 603 | + /* Check for duplicates within the current batch first */ | |
| 604 | + for (k = 0; k < batch_idx; k++) { | |
| 605 | + if (alt_batch[k].svid == svid && alt_batch[k].mid == vdo) { | |
| 606 | + ucsi_dump_duplicate_altmode(con, recipient, svid, | |
| 607 | + vdo, vdo, offset); | |
| 608 | + return true; | |
| 609 | + } | |
| 610 | + } | |
| 611 | + | |
| 612 | + switch (recipient) { | |
| 613 | + case UCSI_RECIPIENT_SOP: | |
| 614 | + /* | |
| 615 | + * Cap partner altmodes per SVID by the port-side count: | |
| 616 | + * any further partner altmode for that SVID would alias an | |
| 617 | + * already-paired port altmode and break typec sysfs. | |
| 618 | + */ | |
| 619 | + port_count = ucsi_altmode_count_svid(con->port_altmode, svid); | |
| 620 | + partner_count = ucsi_altmode_count_svid(con->partner_altmode, | |
| 621 | + svid); | |
| 622 | + if (port_count && partner_count >= port_count) { | |
| 623 | + ucsi_dump_duplicate_altmode(con, recipient, svid, | |
| 624 | + con->partner_altmode[partner_count - 1]->vdo, | |
| 625 | + vdo, offset); | |
| 626 | + return true; | |
| 627 | + } | |
| 628 | + return false; | |
| 629 | + case UCSI_RECIPIENT_CON: | |
| 630 | + altmodes = con->port_altmode; | |
| 631 | + break; | |
| 632 | + case UCSI_RECIPIENT_SOP_P: | |
| 633 | + altmodes = con->plug_altmode; | |
| 634 | + break; | |
| 635 | + default: | |
| 636 | + return false; | |
| 637 | + } | |
| 638 | + | |
| 639 | + /* CON and SOP_P: drop only exact SVID+VDO duplicates. */ | |
| 640 | + for (k = 0; k < UCSI_MAX_ALTMODES; k++) { | |
| 641 | + if (!altmodes[k]) | |
| 642 | + break; | |
| 643 | + | |
| 644 | + if (altmodes[k]->svid != svid || altmodes[k]->vdo != vdo) | |
| 645 | + continue; | |
| 646 | + | |
| 647 | + ucsi_dump_duplicate_altmode(con, recipient, svid, | |
| 648 | + altmodes[k]->vdo, vdo, offset); | |
| 649 | + return true; | |
| 650 | + } | |
| 651 | + | |
| 652 | + return false; | |
| 653 | +} | |
| 654 | + | |
| 532 | 655 | static int |
| 533 | 656 | ucsi_register_altmodes_nvidia(struct ucsi_connector *con, u8 recipient) |
| 534 | 657 | { |
| @@ -583,19 +706,25 @@ ucsi_register_altmodes_nvidia(struct ucsi_connector *con, u8 recipient) · 48 unmodified lines | ||
| 583 | 706 | |
| 584 | 707 | /* now register altmodes */ |
| 585 | 708 | for (i = 0; i < max_altmodes; i++) { |
| 586 | − memset(&desc, 0, sizeof(desc)); | |
| 587 | − if (multi_dp) { | |
| 588 | − desc.svid = updated[i].svid; | |
| 589 | − desc.vdo = updated[i].mid; | |
| 590 | − } else { | |
| 591 | − desc.svid = orig[i].svid; | |
| 592 | − desc.vdo = orig[i].mid; | |
| 593 | − } | |
| 594 | − desc.roles = TYPEC_PORT_DRD; | |
| 709 | + struct ucsi_altmode *altmode_array = multi_dp ? updated : orig; | |
| 595 | 710 | |
| 596 | − if (!desc.svid) | |
| 711 | + if (!altmode_array[i].svid) | |
| 597 | 712 | return 0; |
| 598 | 713 | |
| 714 | + /* | |
| 715 | + * Check for duplicates in current array and already | |
| 716 | + * registered altmodes. Skip if duplicate found. | |
| 717 | + */ | |
| 718 | + if (ucsi_altmode_is_duplicate(con, recipient, altmode_array, i, | |
| 719 | + altmode_array[i].svid, | |
| 720 | + altmode_array[i].mid, i)) | |
| 721 | + continue; | |
| 722 | + | |
| 723 | + memset(&desc, 0, sizeof(desc)); | |
| 724 | + desc.svid = altmode_array[i].svid; | |
| 725 | + desc.vdo = altmode_array[i].mid; | |
| 726 | + desc.roles = TYPEC_PORT_DRD; | |
| 727 | + | |
| 599 | 728 | ret = ucsi_register_altmode(con, &desc, recipient); |
| 600 | 729 | if (ret) |
| 601 | 730 | return ret; |
| @@ -653,6 +782,15 @@ static int ucsi_register_altmodes(struct ucsi_connector *con, u8 recipient) · 51 unmodified lines | ||
| 653 | 782 | if (!alt[j].svid) |
| 654 | 783 | return 0; |
| 655 | 784 | |
| 785 | + /* | |
| 786 | + * Check for duplicates in current batch and already | |
| 787 | + * registered altmodes. Skip if duplicate found. | |
| 788 | + */ | |
| 789 | + if (ucsi_altmode_is_duplicate(con, recipient, alt, j, | |
| 790 | + alt[j].svid, alt[j].mid, | |
| 791 | + i - num + j)) | |
| 792 | + continue; | |
| 793 | + | |
| 656 | 794 | memset(&desc, 0, sizeof(desc)); |
| 657 | 795 | desc.vdo = alt[j].mid; |
| 658 | 796 | desc.svid = alt[j].svid; |
| @@ -1845,6 +1983,42 @@ out_unlock: · 1186 unmodified lines | ||
| 1845 | 1983 | return ret; |
| 1846 | 1984 | } |
| 1847 | 1985 | |
| 1986 | +static void ucsi_unregister_port(struct ucsi_connector *con) | |
| 1987 | +{ | |
| 1988 | + struct ucsi_work *uwork; | |
| 1989 | + | |
| 1990 | + if (con->wq) { | |
| 1991 | + mutex_lock(&con->lock); | |
| 1992 | + ucsi_unregister_partner(con); | |
| 1993 | + /* | |
| 1994 | + * queue delayed items immediately so they can execute | |
| 1995 | + * and free themselves before the wq is destroyed | |
| 1996 | + */ | |
| 1997 | + list_for_each_entry(uwork, &con->partner_tasks, node) { | |
| 1998 | + if (cancel_delayed_work(&uwork->work)) | |
| 1999 | + queue_delayed_work(con->wq, &uwork->work, 0); | |
| 2000 | + } | |
| 2001 | + mutex_unlock(&con->lock); | |
| 2002 | + | |
| 2003 | + destroy_workqueue(con->wq); | |
| 2004 | + con->wq = NULL; | |
| 2005 | + } else { | |
| 2006 | + ucsi_unregister_partner(con); | |
| 2007 | + } | |
| 2008 | + | |
| 2009 | + ucsi_unregister_altmodes(con, UCSI_RECIPIENT_CON); | |
| 2010 | + ucsi_unregister_port_psy(con); | |
| 2011 | + | |
| 2012 | + usb_power_delivery_unregister_capabilities(con->port_sink_caps); | |
| 2013 | + con->port_sink_caps = NULL; | |
| 2014 | + usb_power_delivery_unregister_capabilities(con->port_source_caps); | |
| 2015 | + con->port_source_caps = NULL; | |
| 2016 | + usb_power_delivery_unregister(con->pd); | |
| 2017 | + con->pd = NULL; | |
| 2018 | + typec_unregister_port(con->port); | |
| 2019 | + con->port = NULL; | |
| 2020 | +} | |
| 2021 | + | |
| 1848 | 2022 | static u64 ucsi_get_supported_notifications(struct ucsi *ucsi) |
| 1849 | 2023 | { |
| 1850 | 2024 | u16 features = ucsi->cap.features; |
| @@ -1968,25 +2142,11 @@ static int ucsi_init(struct ucsi *ucsi) · 117 unmodified lines | ||
| 1968 | 2142 | return 0; |
| 1969 | 2143 | |
| 1970 | 2144 | err_unregister: |
| 2145 | + for (con = connector; con->port; con++) | |
| 2146 | + ucsi_unregister_port(con); | |
| 1971 | 2147 | for (i = 0; i < ucsi->cap.num_connectors; i++) |
| 1972 | 2148 | lockdep_unregister_key(&connector[i].lock_key); |
| 1973 | 2149 | |
| 1974 | − for (con = connector; con->port; con++) { | |
| 1975 | − if (con->wq) | |
| 1976 | − destroy_workqueue(con->wq); | |
| 1977 | − ucsi_unregister_partner(con); | |
| 1978 | − ucsi_unregister_altmodes(con, UCSI_RECIPIENT_CON); | |
| 1979 | − ucsi_unregister_port_psy(con); | |
| 1980 | − | |
| 1981 | − usb_power_delivery_unregister_capabilities(con->port_sink_caps); | |
| 1982 | − con->port_sink_caps = NULL; | |
| 1983 | − usb_power_delivery_unregister_capabilities(con->port_source_caps); | |
| 1984 | − con->port_source_caps = NULL; | |
| 1985 | − usb_power_delivery_unregister(con->pd); | |
| 1986 | − con->pd = NULL; | |
| 1987 | − typec_unregister_port(con->port); | |
| 1988 | − con->port = NULL; | |
| 1989 | − } | |
| 1990 | 2150 | kfree(connector); |
| 1991 | 2151 | err_reset: |
| 1992 | 2152 | memset(&ucsi->cap, 0, sizeof(ucsi->cap)); |
| @@ -2214,33 +2374,7 @@ void ucsi_unregister(struct ucsi *ucsi) · 221 unmodified lines | ||
| 2214 | 2374 | |
| 2215 | 2375 | for (i = 0; i < ucsi->cap.num_connectors; i++) { |
| 2216 | 2376 | cancel_work_sync(&ucsi->connector[i].work); |
| 2217 | − | |
| 2218 | − if (ucsi->connector[i].wq) { | |
| 2219 | − struct ucsi_work *uwork; | |
| 2220 | − | |
| 2221 | − mutex_lock(&ucsi->connector[i].lock); | |
| 2222 | − /* | |
| 2223 | − * queue delayed items immediately so they can execute | |
| 2224 | − * and free themselves before the wq is destroyed | |
| 2225 | − */ | |
| 2226 | − list_for_each_entry(uwork, &ucsi->connector[i].partner_tasks, node) | |
| 2227 | − mod_delayed_work(ucsi->connector[i].wq, &uwork->work, 0); | |
| 2228 | − mutex_unlock(&ucsi->connector[i].lock); | |
| 2229 | − destroy_workqueue(ucsi->connector[i].wq); | |
| 2230 | − } | |
| 2231 | − | |
| 2232 | − ucsi_unregister_partner(&ucsi->connector[i]); | |
| 2233 | − ucsi_unregister_altmodes(&ucsi->connector[i], | |
| 2234 | − UCSI_RECIPIENT_CON); | |
| 2235 | − ucsi_unregister_port_psy(&ucsi->connector[i]); | |
| 2236 | − | |
| 2237 | − usb_power_delivery_unregister_capabilities(ucsi->connector[i].port_sink_caps); | |
| 2238 | − ucsi->connector[i].port_sink_caps = NULL; | |
| 2239 | − usb_power_delivery_unregister_capabilities(ucsi->connector[i].port_source_caps); | |
| 2240 | − ucsi->connector[i].port_source_caps = NULL; | |
| 2241 | − usb_power_delivery_unregister(ucsi->connector[i].pd); | |
| 2242 | − ucsi->connector[i].pd = NULL; | |
| 2243 | − typec_unregister_port(ucsi->connector[i].port); | |
| 2377 | + ucsi_unregister_port(&ucsi->connector[i]); | |
| 2244 | 2378 | lockdep_unregister_key(&ucsi->connector[i].lock_key); |
| 2245 | 2379 | } |
| 2246 | 2380 | |
| @@ -139,28 +139,6 @@ static int yoga_c630_ucsi_sync_control(struct ucsi *ucsi, · 138 unmodified lines | ||
| 139 | 139 | return ret; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | −static bool yoga_c630_ucsi_update_altmodes(struct ucsi *ucsi, | |
| 143 | − u8 recipient, | |
| 144 | − struct ucsi_altmode *orig, | |
| 145 | − struct ucsi_altmode *updated) | |
| 146 | −{ | |
| 147 | − int i; | |
| 148 | − | |
| 149 | − if (orig[0].svid == 0 || recipient != UCSI_RECIPIENT_SOP) | |
| 150 | − return false; | |
| 151 | − | |
| 152 | − /* EC is nice and repeats altmodes again and again. Ignore copies. */ | |
| 153 | − for (i = 1; i < UCSI_MAX_ALTMODES; i++) { | |
| 154 | − if (orig[i].svid == orig[0].svid) { | |
| 155 | − dev_dbg(ucsi->dev, "Found duplicate altmodes, starting from %d\n", i); | |
| 156 | − memset(&orig[i], 0, (UCSI_MAX_ALTMODES - i) * sizeof(*orig)); | |
| 157 | − break; | |
| 158 | − } | |
| 159 | − } | |
| 160 | − | |
| 161 | − return false; | |
| 162 | −} | |
| 163 | − | |
| 164 | 142 | static void yoga_c630_ucsi_update_connector(struct ucsi_connector *con) |
| 165 | 143 | { |
| 166 | 144 | if (con->num == 1) |
| @@ -174,7 +152,6 @@ static const struct ucsi_operations yoga_c630_ucsi_ops = { · 7 unmodified lines | ||
| 174 | 152 | .read_message_in = yoga_c630_ucsi_read_message_in, |
| 175 | 153 | .sync_control = yoga_c630_ucsi_sync_control, |
| 176 | 154 | .async_control = yoga_c630_ucsi_async_control, |
| 177 | − .update_altmodes = yoga_c630_ucsi_update_altmodes, | |
| 178 | 155 | .update_connector = yoga_c630_ucsi_update_connector, |
| 179 | 156 | }; |
| 180 | 157 | |
| @@ -731,10 +731,12 @@ static int vhost_net_build_xdp(struct vhost_net_virtqueue *nvq, · 730 unmodified lines | ||
| 731 | 731 | goto err; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | − gso = buf + pad - sock_hlen; | |
| 735 | − | |
| 736 | − if (!sock_hlen) | |
| 734 | + if (!sock_hlen) { | |
| 737 | 735 | memset(buf, 0, pad); |
| 736 | + gso = buf; | |
| 737 | + } else { | |
| 738 | + gso = buf + pad - sock_hlen; | |
| 739 | + } | |
| 738 | 740 | |
| 739 | 741 | if ((gso->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) && |
| 740 | 742 | vhost16_to_cpu(vq, gso->csum_start) + |
| @@ -82,8 +82,8 @@ static int mmio_guard_ioremap_hook(phys_addr_t phys, size_t size, · 81 unmodified lines | ||
| 82 | 82 | if (protval != PROT_DEVICE_nGnRE && protval != PROT_DEVICE_nGnRnE) |
| 83 | 83 | return 0; |
| 84 | 84 | |
| 85 | + end = PAGE_ALIGN(phys + size); | |
| 85 | 86 | phys = PAGE_ALIGN_DOWN(phys); |
| 86 | − end = phys + PAGE_ALIGN(size); | |
| 87 | 87 | |
| 88 | 88 | while (phys < end) { |
| 89 | 89 | const int func_id = ARM_SMCCC_VENDOR_HYP_KVM_MMIO_GUARD_FUNC_ID; |
| @@ -1017,10 +1017,6 @@ static int virtballoon_probe(struct virtio_device *vdev) · 1016 unmodified lines | ||
| 1017 | 1017 | unsigned int capacity; |
| 1018 | 1018 | |
| 1019 | 1019 | capacity = virtqueue_get_vring_size(vb->reporting_vq); |
| 1020 | − if (capacity < PAGE_REPORTING_CAPACITY) { | |
| 1021 | − err = -ENOSPC; | |
| 1022 | − goto out_unregister_oom; | |
| 1023 | − } | |
| 1024 | 1020 | |
| 1025 | 1021 | vb->pr_dev_info.order = PAGE_REPORTING_ORDER_UNSPECIFIED; |
| 1026 | 1022 | |
| @@ -1041,6 +1037,7 @@ static int virtballoon_probe(struct virtio_device *vdev) · 14 unmodified lines | ||
| 1041 | 1037 | vb->pr_dev_info.order = 5; |
| 1042 | 1038 | #endif |
| 1043 | 1039 | |
| 1040 | + vb->pr_dev_info.capacity = capacity; | |
| 1044 | 1041 | err = page_reporting_register(&vb->pr_dev_info); |
| 1045 | 1042 | if (err) |
| 1046 | 1043 | goto out_unregister_oom; |
| @@ -147,6 +147,9 @@ static int airoha_wdt_probe(struct platform_device *pdev) · 146 unmodified lines | ||
| 147 | 147 | |
| 148 | 148 | /* Watchdog ticks at half the bus rate */ |
| 149 | 149 | airoha_wdt->wdt_freq = clk_get_rate(bus_clk) / 2; |
| 150 | + if (!airoha_wdt->wdt_freq) | |
| 151 | + return dev_err_probe(dev, -EINVAL, | |
| 152 | + "invalid clock frequency\n"); | |
| 150 | 153 | |
| 151 | 154 | /* Initialize struct watchdog device */ |
| 152 | 155 | wdog_dev = &airoha_wdt->wdog_dev; |
| @@ -183,9 +183,14 @@ static int ni903x_acpi_probe(struct platform_device *pdev) · 182 unmodified lines | ||
| 183 | 183 | struct device *dev = &pdev->dev; |
| 184 | 184 | struct watchdog_device *wdd; |
| 185 | 185 | struct ni903x_wdt *wdt; |
| 186 | + acpi_handle handle; | |
| 186 | 187 | acpi_status status; |
| 187 | 188 | int ret; |
| 188 | 189 | |
| 190 | + handle = ACPI_HANDLE(dev); | |
| 191 | + if (!handle) | |
| 192 | + return -ENODEV; | |
| 193 | + | |
| 189 | 194 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
| 190 | 195 | if (!wdt) |
| 191 | 196 | return -ENOMEM; |
| @@ -193,7 +198,7 @@ static int ni903x_acpi_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 193 | 198 | platform_set_drvdata(pdev, wdt); |
| 194 | 199 | wdt->dev = dev; |
| 195 | 200 | |
| 196 | − status = acpi_walk_resources(ACPI_HANDLE(dev), METHOD_NAME__CRS, | |
| 201 | + status = acpi_walk_resources(handle, METHOD_NAME__CRS, | |
| 197 | 202 | ni903x_resources, wdt); |
| 198 | 203 | if (ACPI_FAILURE(status) || wdt->io_base == 0) { |
| 199 | 204 | dev_err(dev, "failed to get resources\n"); |
| @@ -56,8 +56,7 @@ MODULE_PARM_DESC(early_enable, · 55 unmodified lines | ||
| 56 | 56 | |
| 57 | 57 | static const struct watchdog_info s32g_wdt_info = { |
| 58 | 58 | .identity = "s32g watchdog", |
| 59 | − .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | | |
| 60 | − WDIOC_GETTIMEOUT | WDIOC_GETTIMELEFT, | |
| 59 | + .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, | |
| 61 | 60 | }; |
| 62 | 61 | |
| 63 | 62 | static struct s32g_wdt_device *wdd_to_s32g_wdt(struct watchdog_device *wdd) |
| @@ -167,6 +167,8 @@ void watchdog_unregister_governor(struct watchdog_governor *gov) · 166 unmodified lines | ||
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | spin_lock_irq(&pretimeout_lock); |
| 170 | + if (default_gov == gov) | |
| 171 | + default_gov = NULL; | |
| 170 | 172 | list_for_each_entry(p, &pretimeout_list, entry) |
| 171 | 173 | if (p->wdd->gov == gov) |
| 172 | 174 | p->wdd->gov = default_gov; |
| @@ -415,7 +415,7 @@ void afs_edit_dir_remove(struct afs_vnode *vnode, · 414 unmodified lines | ||
| 415 | 415 | if (!afs_dir_init_iter(&iter, name)) |
| 416 | 416 | return; |
| 417 | 417 | |
| 418 | − meta = afs_dir_find_block(&iter, 0); | |
| 418 | + meta = afs_dir_get_block(&iter, 0); | |
| 419 | 419 | if (!meta) |
| 420 | 420 | return; |
| 421 | 421 | |
| @@ -231,6 +231,10 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) · 230 unmodified lines | ||
| 231 | 231 | for (i = 0; i < exec_params.hdr.e_phnum; i++, phdr++) { |
| 232 | 232 | switch (phdr->p_type) { |
| 233 | 233 | case PT_INTERP: |
| 234 | + /* elf ABI allows only one interpreter */ | |
| 235 | + if (interpreter_name) | |
| 236 | + continue; | |
| 237 | + | |
| 234 | 238 | retval = -ENOMEM; |
| 235 | 239 | if (phdr->p_filesz > PATH_MAX) |
| 236 | 240 | goto error; |
| @@ -228,9 +228,6 @@ static int load_misc_binary(struct linux_binprm *bprm) · 227 unmodified lines | ||
| 228 | 228 | goto ret; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | − if (fmt->flags & MISC_FMT_OPEN_BINARY) | |
| 232 | − bprm->have_execfd = 1; | |
| 233 | − | |
| 234 | 231 | /* make argv[1] be the path to the binary */ |
| 235 | 232 | retval = copy_string_kernel(bprm->interp, bprm); |
| 236 | 233 | if (retval < 0) |
| @@ -260,6 +257,8 @@ static int load_misc_binary(struct linux_binprm *bprm) · 23 unmodified lines | ||
| 260 | 257 | goto ret; |
| 261 | 258 | |
| 262 | 259 | bprm->interpreter = interp_file; |
| 260 | + if (fmt->flags & MISC_FMT_OPEN_BINARY) | |
| 261 | + bprm->have_execfd = 1; | |
| 263 | 262 | if (fmt->flags & MISC_FMT_CREDENTIALS) |
| 264 | 263 | bprm->execfd_creds = 1; |
| 265 | 264 | |
| @@ -3054,7 +3054,10 @@ void btrfs_backref_free_node(struct btrfs_backref_cache *cache, · 3053 unmodified lines | ||
| 3054 | 3054 | if (node) { |
| 3055 | 3055 | ASSERT(list_empty(&node->list)); |
| 3056 | 3056 | ASSERT(list_empty(&node->lower)); |
| 3057 | − ASSERT(node->eb == NULL, "node->eb->start=%llu", node->eb->start); | |
| 3057 | + ASSERT(node->eb == NULL, "node->eb->start=%llu level=%d owner=%llu", | |
| 3058 | + node->eb ? node->eb->start : 0, | |
| 3059 | + node->eb ? btrfs_header_level(node->eb) : 0, | |
| 3060 | + node->eb ? btrfs_header_owner(node->eb) : 0); | |
| 3058 | 3061 | cache->nr_nodes--; |
| 3059 | 3062 | btrfs_put_root(node->root); |
| 3060 | 3063 | kfree(node); |
| @@ -476,6 +476,8 @@ static inline bool btrfs_inode_can_compress(const struct btrfs_inode *inode) · 475 unmodified lines | ||
| 476 | 476 | if (inode->flags & BTRFS_INODE_NODATACOW || |
| 477 | 477 | inode->flags & BTRFS_INODE_NODATASUM) |
| 478 | 478 | return false; |
| 479 | + if (btrfs_is_data_reloc_root(inode->root)) | |
| 480 | + return false; | |
| 479 | 481 | return true; |
| 480 | 482 | } |
| 481 | 483 | |
| @@ -2004,7 +2004,7 @@ static noinline_for_stack bool lock_extent_buffer_for_io(struct extent_buffer *e · 2003 unmodified lines | ||
| 2004 | 2004 | |
| 2005 | 2005 | btrfs_set_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN); |
| 2006 | 2006 | percpu_counter_add_batch(&fs_info->dirty_metadata_bytes, |
| 2007 | − -eb->len, | |
| 2007 | + -(s64)eb->len, | |
| 2008 | 2008 | fs_info->dirty_metadata_batch); |
| 2009 | 2009 | ret = true; |
| 2010 | 2010 | } else { |
| @@ -3774,7 +3774,7 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans, · 1763 unmodified lines | ||
| 3774 | 3774 | return; |
| 3775 | 3775 | |
| 3776 | 3776 | buffer_tree_clear_mark(eb, PAGECACHE_TAG_DIRTY); |
| 3777 | − percpu_counter_add_batch(&fs_info->dirty_metadata_bytes, -eb->len, | |
| 3777 | + percpu_counter_add_batch(&fs_info->dirty_metadata_bytes, -(s64)eb->len, | |
| 3778 | 3778 | fs_info->dirty_metadata_batch); |
| 3779 | 3779 | |
| 3780 | 3780 | for (int i = 0; i < num_extent_folios(eb); i++) { |
| @@ -866,13 +866,13 @@ void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end, · 865 unmodified lines | ||
| 866 | 866 | goto next; |
| 867 | 867 | } |
| 868 | 868 | |
| 869 | − flags = em->flags; | |
| 870 | 869 | /* |
| 871 | 870 | * In case we split the extent map, we want to preserve the |
| 872 | 871 | * EXTENT_FLAG_LOGGING flag on our extent map, but we don't want |
| 873 | 872 | * it on the new extent maps. |
| 874 | 873 | */ |
| 875 | − em->flags &= ~(EXTENT_FLAG_PINNED | EXTENT_FLAG_LOGGING); | |
| 874 | + flags = em->flags & ~EXTENT_FLAG_LOGGING; | |
| 875 | + em->flags &= ~EXTENT_FLAG_PINNED; | |
| 876 | 876 | modified = !list_empty(&em->list); |
| 877 | 877 | |
| 878 | 878 | /* |
| @@ -8068,7 +8068,8 @@ static int btrfs_getattr(struct mnt_idmap *idmap, · 8067 unmodified lines | ||
| 8068 | 8068 | stat->result_mask |= STATX_SUBVOL; |
| 8069 | 8069 | |
| 8070 | 8070 | spin_lock(&BTRFS_I(inode)->lock); |
| 8071 | − delalloc_bytes = BTRFS_I(inode)->new_delalloc_bytes; | |
| 8071 | + delalloc_bytes = S_ISREG(inode->i_mode) ? | |
| 8072 | + BTRFS_I(inode)->new_delalloc_bytes : 0; | |
| 8072 | 8073 | inode_bytes = inode_get_bytes(inode); |
| 8073 | 8074 | spin_unlock(&BTRFS_I(inode)->lock); |
| 8074 | 8075 | stat->blocks = (ALIGN(inode_bytes, blocksize) + |
| @@ -2048,6 +2048,7 @@ static int _btrfs_ioctl_get_subvol_info(struct inode *inode, · 2047 unmodified lines | ||
| 2048 | 2048 | ret = -ENOENT; |
| 2049 | 2049 | goto out; |
| 2050 | 2050 | } |
| 2051 | + ret = 0; | |
| 2051 | 2052 | } |
| 2052 | 2053 | |
| 2053 | 2054 | out: |
| @@ -588,6 +588,7 @@ static int __add_reloc_root(struct btrfs_root *root, struct reloc_control *rc) · 587 unmodified lines | ||
| 588 | 588 | btrfs_err(fs_info, |
| 589 | 589 | "Duplicate root found for start=%llu while inserting into relocation tree", |
| 590 | 590 | node->bytenr); |
| 591 | + kfree(node); | |
| 591 | 592 | return -EEXIST; |
| 592 | 593 | } |
| 593 | 594 | |
| @@ -890,6 +891,13 @@ static int get_new_location(struct inode *reloc_inode, u64 *new_bytenr, · 296 unmodified lines | ||
| 890 | 891 | leaf = path->nodes[0]; |
| 891 | 892 | fi = btrfs_item_ptr(leaf, path->slots[0], |
| 892 | 893 | struct btrfs_file_extent_item); |
| 894 | + if (unlikely(btrfs_file_extent_type(leaf, fi) == BTRFS_FILE_EXTENT_INLINE)) { | |
| 895 | + btrfs_print_leaf(leaf); | |
| 896 | + btrfs_err(fs_info, | |
| 897 | + "unexpected inline file extent item for data reloc inode %llu key offset %llu", | |
| 898 | + btrfs_ino(BTRFS_I(reloc_inode)), bytenr); | |
| 899 | + return -EUCLEAN; | |
| 900 | + } | |
| 893 | 901 | |
| 894 | 902 | /* |
| 895 | 903 | * The cluster-boundary key searched above is always written by |
| @@ -1518,6 +1526,17 @@ static int insert_dirty_subvol(struct btrfs_trans_handle *trans, · 622 unmodified lines | ||
| 1518 | 1526 | return 0; |
| 1519 | 1527 | } |
| 1520 | 1528 | |
| 1529 | +static void clear_reloc_root(struct btrfs_root *root) | |
| 1530 | +{ | |
| 1531 | + root->reloc_root = NULL; | |
| 1532 | + /* | |
| 1533 | + * Need barrier to ensure clear_bit() only happens after | |
| 1534 | + * root->reloc_root = NULL. Pairs with have_reloc_root(). | |
| 1535 | + */ | |
| 1536 | + smp_wmb(); | |
| 1537 | + clear_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state); | |
| 1538 | +} | |
| 1539 | + | |
| 1521 | 1540 | static int clean_dirty_subvols(struct reloc_control *rc) |
| 1522 | 1541 | { |
| 1523 | 1542 | struct btrfs_root *root; |
| @@ -1532,13 +1551,7 @@ static int clean_dirty_subvols(struct reloc_control *rc) · 8 unmodified lines | ||
| 1532 | 1551 | struct btrfs_root *reloc_root = root->reloc_root; |
| 1533 | 1552 | |
| 1534 | 1553 | list_del_init(&root->reloc_dirty_list); |
| 1535 | − root->reloc_root = NULL; | |
| 1536 | − /* | |
| 1537 | − * Need barrier to ensure clear_bit() only happens after | |
| 1538 | − * root->reloc_root = NULL. Pairs with have_reloc_root. | |
| 1539 | − */ | |
| 1540 | − smp_wmb(); | |
| 1541 | − clear_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state); | |
| 1554 | + clear_reloc_root(root); | |
| 1542 | 1555 | if (reloc_root) { |
| 1543 | 1556 | /* |
| 1544 | 1557 | * btrfs_drop_snapshot drops our ref we hold for |
| @@ -1914,21 +1927,39 @@ again: · 369 unmodified lines | ||
| 1914 | 1927 | goto out; |
| 1915 | 1928 | } |
| 1916 | 1929 | ret = merge_reloc_root(rc, root); |
| 1917 | − btrfs_put_root(root); | |
| 1918 | 1930 | if (ret) { |
| 1919 | − if (list_empty(&reloc_root->root_list)) | |
| 1931 | + /* | |
| 1932 | + * Clear the reloc root since below we will call | |
| 1933 | + * free_reloc_roots(), otherwise we leave | |
| 1934 | + * root->reloc_root pointing to a freed reloc | |
| 1935 | + * root and trigger a use-after-free during | |
| 1936 | + * unmount or elsewhere. | |
| 1937 | + */ | |
| 1938 | + clear_reloc_root(root); | |
| 1939 | + btrfs_put_root(root); | |
| 1940 | + /* | |
| 1941 | + * We are adding the reloc_root to the local | |
| 1942 | + * reloc_roots list, so we add a ref for this | |
| 1943 | + * list which will be dropped below by the call | |
| 1944 | + * to free_reloc_roots(). | |
| 1945 | + */ | |
| 1946 | + if (list_empty(&reloc_root->root_list)) { | |
| 1920 | 1947 | list_add_tail(&reloc_root->root_list, |
| 1921 | 1948 | &reloc_roots); |
| 1949 | + btrfs_grab_root(reloc_root); | |
| 1950 | + } | |
| 1951 | + /* Now drop the ref for root->reloc_root. */ | |
| 1952 | + btrfs_put_root(reloc_root); | |
| 1922 | 1953 | goto out; |
| 1923 | 1954 | } |
| 1955 | + btrfs_put_root(root); | |
| 1924 | 1956 | } else { |
| 1925 | 1957 | if (!IS_ERR(root)) { |
| 1926 | 1958 | if (root->reloc_root == reloc_root) { |
| 1927 | − root->reloc_root = NULL; | |
| 1959 | + clear_reloc_root(root); | |
| 1960 | + /* Drop the ref for root->reloc_root. */ | |
| 1928 | 1961 | btrfs_put_root(reloc_root); |
| 1929 | 1962 | } |
| 1930 | − clear_bit(BTRFS_ROOT_DEAD_RELOC_TREE, | |
| 1931 | − &root->state); | |
| 1932 | 1963 | btrfs_put_root(root); |
| 1933 | 1964 | } |
| 1934 | 1965 | |
| @@ -359,6 +359,23 @@ void btrfs_subpage_set_dirty(const struct btrfs_fs_info *fs_info, · 358 unmodified lines | ||
| 359 | 359 | folio_mark_dirty(folio); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | +static void folio_clear_tags(struct folio *folio) | |
| 363 | +{ | |
| 364 | + struct address_space *mapping = folio_mapping(folio); | |
| 365 | + XA_STATE(xas, &mapping->i_pages, folio->index); | |
| 366 | + unsigned long flags; | |
| 367 | + | |
| 368 | + ASSERT(folio_test_locked(folio)); | |
| 369 | + ASSERT(mapping); | |
| 370 | + ASSERT(mapping_use_writeback_tags(mapping)); | |
| 371 | + | |
| 372 | + xas_lock_irqsave(&xas, flags); | |
| 373 | + xas_load(&xas); | |
| 374 | + xas_clear_mark(&xas, PAGECACHE_TAG_DIRTY); | |
| 375 | + xas_clear_mark(&xas, PAGECACHE_TAG_TOWRITE); | |
| 376 | + xas_unlock_irqrestore(&xas, flags); | |
| 377 | +} | |
| 378 | + | |
| 362 | 379 | /* |
| 363 | 380 | * Extra clear_and_test function for subpage dirty bitmap. |
| 364 | 381 | * |
| @@ -403,7 +420,6 @@ void btrfs_subpage_set_writeback(const struct btrfs_fs_info *fs_info, · 38 unmodified lines | ||
| 403 | 420 | unsigned int start_bit = subpage_calc_start_bit(fs_info, folio, |
| 404 | 421 | writeback, start, len); |
| 405 | 422 | unsigned long flags; |
| 406 | − bool keep_write; | |
| 407 | 423 | |
| 408 | 424 | spin_lock_irqsave(&bfs->lock, flags); |
| 409 | 425 | bitmap_set(bfs->bitmaps, start_bit, len >> fs_info->sectorsize_bits); |
| @@ -413,10 +429,14 @@ void btrfs_subpage_set_writeback(const struct btrfs_fs_info *fs_info, · 3 unmodified lines | ||
| 413 | 429 | * folio. Doing so can cause WB_SYNC_ALL writepages() to overlook it, |
| 414 | 430 | * assume writeback is complete, and exit too early — violating sync |
| 415 | 431 | * ordering guarantees. |
| 432 | + * | |
| 433 | + * Instead we manually clear the DIRTY and TOWRITE tags after the folio | |
| 434 | + * is no longer dirty. | |
| 416 | 435 | */ |
| 417 | − keep_write = folio_test_dirty(folio); | |
| 418 | 436 | if (!folio_test_writeback(folio)) |
| 419 | − __folio_start_writeback(folio, keep_write); | |
| 437 | + __folio_start_writeback(folio, true); | |
| 438 | + if (!folio_test_dirty(folio)) | |
| 439 | + folio_clear_tags(folio); | |
| 420 | 440 | spin_unlock_irqrestore(&bfs->lock, flags); |
| 421 | 441 | } |
| 422 | 442 | |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | #include <linux/namei.h> |
| 23 | 23 | #include <linux/miscdevice.h> |
| 24 | 24 | #include <linux/magic.h> |
| 25 | +#include <linux/memcontrol.h> | |
| 25 | 26 | #include <linux/slab.h> |
| 26 | 27 | #include <linux/ratelimit.h> |
| 27 | 28 | #include <linux/crc32c.h> |
| @@ -2434,6 +2435,15 @@ static long btrfs_nr_cached_objects(struct super_block *sb, struct shrink_contro · 2406 unmodified lines | ||
| 2434 | 2435 | struct btrfs_fs_info *fs_info = btrfs_sb(sb); |
| 2435 | 2436 | const s64 nr = percpu_counter_read_positive(&fs_info->evictable_extent_maps); |
| 2436 | 2437 | |
| 2438 | + /* | |
| 2439 | + * The evictable extent map counter is filesystem-global and does not | |
| 2440 | + * honour sc->memcg, so it is only meaningful on the global (kswapd or | |
| 2441 | + * root direct reclaim) shrink path. Skip the per-memcg iterations of | |
| 2442 | + * shrink_slab_memcg() to avoid queueing duplicate global work. | |
| 2443 | + */ | |
| 2444 | + if (!mem_cgroup_shrink_is_root(sc)) | |
| 2445 | + return 0; | |
| 2446 | + | |
| 2437 | 2447 | trace_btrfs_extent_map_shrinker_count(fs_info, nr); |
| 2438 | 2448 | |
| 2439 | 2449 | return nr; |
| @@ -790,6 +790,9 @@ static int write_folio_nounlock(struct folio *folio, · 789 unmodified lines | ||
| 790 | 790 | ceph_wbc.truncate_size, true); |
| 791 | 791 | if (IS_ERR(req)) { |
| 792 | 792 | folio_redirty_for_writepage(wbc, folio); |
| 793 | + if (atomic_long_dec_return(&fsc->writeback_count) < | |
| 794 | + CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb)) | |
| 795 | + fsc->write_congested = false; | |
| 793 | 796 | return PTR_ERR(req); |
| 794 | 797 | } |
| 795 | 798 | |
| @@ -809,6 +812,9 @@ static int write_folio_nounlock(struct folio *folio, · 13 unmodified lines | ||
| 809 | 812 | folio_redirty_for_writepage(wbc, folio); |
| 810 | 813 | folio_end_writeback(folio); |
| 811 | 814 | ceph_osdc_put_request(req); |
| 815 | + if (atomic_long_dec_return(&fsc->writeback_count) < | |
| 816 | + CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb)) | |
| 817 | + fsc->write_congested = false; | |
| 812 | 818 | return PTR_ERR(bounce_page); |
| 813 | 819 | } |
| 814 | 820 | } |
| @@ -847,6 +853,9 @@ static int write_folio_nounlock(struct folio *folio, · 32 unmodified lines | ||
| 847 | 853 | ceph_vinop(inode), folio); |
| 848 | 854 | folio_redirty_for_writepage(wbc, folio); |
| 849 | 855 | folio_end_writeback(folio); |
| 856 | + if (atomic_long_dec_return(&fsc->writeback_count) < | |
| 857 | + CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb)) | |
| 858 | + fsc->write_congested = false; | |
| 850 | 859 | return err; |
| 851 | 860 | } |
| 852 | 861 | if (err == -EBLOCKLISTED) |
| @@ -3094,7 +3094,19 @@ int __ceph_get_caps(struct inode *inode, struct ceph_file_info *fi, int need, · 3093 unmodified lines | ||
| 3094 | 3094 | ret = -ERESTARTSYS; |
| 3095 | 3095 | break; |
| 3096 | 3096 | } |
| 3097 | − wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); | |
| 3097 | + | |
| 3098 | + /* | |
| 3099 | + * If a cap update is lost after | |
| 3100 | + * mds_wanted was raised, waiting | |
| 3101 | + * forever will never make progress. | |
| 3102 | + * Retry the renew path periodically | |
| 3103 | + * so we can resend synchronously. | |
| 3104 | + */ | |
| 3105 | + if (!wait_woken(&wait, TASK_INTERRUPTIBLE, | |
| 3106 | + CEPH_GET_CAPS_WAIT_TIMEOUT)) { | |
| 3107 | + ret = -EUCLEAN; | |
| 3108 | + break; | |
| 3109 | + } | |
| 3098 | 3110 | } |
| 3099 | 3111 | |
| 3100 | 3112 | remove_wait_queue(&ci->i_cap_wq, &wait); |
| @@ -3128,7 +3140,8 @@ int __ceph_get_caps(struct inode *inode, struct ceph_file_info *fi, int need, · 27 unmodified lines | ||
| 3128 | 3140 | continue; |
| 3129 | 3141 | } |
| 3130 | 3142 | if (ret == -EUCLEAN) { |
| 3131 | − /* session was killed, try renew caps */ | |
| 3143 | + /* session was killed or a waited cap | |
| 3144 | + * request needs a retry */ | |
| 3132 | 3145 | ret = ceph_renew_caps(inode, flags); |
| 3133 | 3146 | if (ret == 0) |
| 3134 | 3147 | continue; |
| @@ -4375,6 +4388,7 @@ void ceph_handle_caps(struct ceph_mds_session *session, · 1240 unmodified lines | ||
| 4375 | 4388 | |
| 4376 | 4389 | snaptrace = h + 1; |
| 4377 | 4390 | snaptrace_len = le32_to_cpu(h->snap_trace_len); |
| 4391 | + ceph_decode_need(&snaptrace, end, snaptrace_len, bad); | |
| 4378 | 4392 | p = snaptrace + snaptrace_len; |
| 4379 | 4393 | |
| 4380 | 4394 | if (msg_version >= 2) { |
| @@ -546,11 +546,16 @@ more: · 545 unmodified lines | ||
| 546 | 546 | pr_warn_client(cl, |
| 547 | 547 | "%p %llx.%llx rde->offset 0x%llx ctx->pos 0x%llx\n", |
| 548 | 548 | inode, ceph_vinop(inode), rde->offset, ctx->pos); |
| 549 | + ceph_mdsc_put_request(dfi->last_readdir); | |
| 550 | + dfi->last_readdir = NULL; | |
| 549 | 551 | return -EIO; |
| 550 | 552 | } |
| 551 | 553 | |
| 552 | − if (WARN_ON_ONCE(!rde->inode.in)) | |
| 554 | + if (WARN_ON_ONCE(!rde->inode.in)) { | |
| 555 | + ceph_mdsc_put_request(dfi->last_readdir); | |
| 556 | + dfi->last_readdir = NULL; | |
| 553 | 557 | return -EIO; |
| 558 | + } | |
| 554 | 559 | |
| 555 | 560 | ctx->pos = rde->offset; |
| 556 | 561 | doutc(cl, "%p %llx.%llx (%d/%d) -> %llx '%.*s' %p\n", inode, |
| @@ -314,7 +314,7 @@ static int ceph_init_file(struct inode *inode, struct file *file, int fmode) · 313 unmodified lines | ||
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /* |
| 317 | − * try renew caps after session gets killed. | |
| 317 | + * Retry cap acquisition after a stale session or a lost cap update. | |
| 318 | 318 | */ |
| 319 | 319 | int ceph_renew_caps(struct inode *inode, int fmode) |
| 320 | 320 | { |
| @@ -322,14 +322,15 @@ int ceph_renew_caps(struct inode *inode, int fmode) · 1 unmodified line | ||
| 322 | 322 | struct ceph_client *cl = mdsc->fsc->client; |
| 323 | 323 | struct ceph_inode_info *ci = ceph_inode(inode); |
| 324 | 324 | struct ceph_mds_request *req; |
| 325 | − int err, flags, wanted; | |
| 325 | + int err, flags, wanted, issued; | |
| 326 | 326 | |
| 327 | 327 | spin_lock(&ci->i_ceph_lock); |
| 328 | 328 | __ceph_touch_fmode(ci, mdsc, fmode); |
| 329 | 329 | wanted = __ceph_caps_file_wanted(ci); |
| 330 | + issued = __ceph_caps_issued(ci, NULL); | |
| 330 | 331 | if (__ceph_is_any_real_caps(ci) && |
| 331 | − (!(wanted & CEPH_CAP_ANY_WR) || ci->i_auth_cap)) { | |
| 332 | − int issued = __ceph_caps_issued(ci, NULL); | |
| 332 | + (!(wanted & CEPH_CAP_ANY_WR) || ci->i_auth_cap) && | |
| 333 | + (issued & wanted) == wanted) { | |
| 333 | 334 | spin_unlock(&ci->i_ceph_lock); |
| 334 | 335 | doutc(cl, "%p %llx.%llx want %s issued %s updating mds_wanted\n", |
| 335 | 336 | inode, ceph_vinop(inode), ceph_cap_string(wanted), |
| @@ -72,6 +72,9 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) · 71 unmodified lines | ||
| 72 | 72 | struct ceph_ioctl_layout nl; |
| 73 | 73 | int err; |
| 74 | 74 | |
| 75 | + if (!inode_owner_or_capable(&nop_mnt_idmap, inode)) | |
| 76 | + return -EACCES; | |
| 77 | + | |
| 75 | 78 | if (copy_from_user(&l, arg, sizeof(l))) |
| 76 | 79 | return -EFAULT; |
| 77 | 80 | |
| @@ -142,6 +145,9 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg) · 64 unmodified lines | ||
| 142 | 145 | int err; |
| 143 | 146 | struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(inode->i_sb)->mdsc; |
| 144 | 147 | |
| 148 | + if (!inode_owner_or_capable(&nop_mnt_idmap, inode)) | |
| 149 | + return -EACCES; | |
| 150 | + | |
| 145 | 151 | /* copy and validate */ |
| 146 | 152 | if (copy_from_user(&l, arg, sizeof(l))) |
| 147 | 153 | return -EFAULT; |
| @@ -6,6 +6,7 @@ · 5 unmodified lines | ||
| 6 | 6 | #include <linux/slab.h> |
| 7 | 7 | #include <linux/gfp.h> |
| 8 | 8 | #include <linux/sched.h> |
| 9 | +#include <linux/sched/mm.h> | |
| 9 | 10 | #include <linux/delay.h> |
| 10 | 11 | #include <linux/debugfs.h> |
| 11 | 12 | #include <linux/seq_file.h> |
| @@ -4015,6 +4016,7 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg) · 4003 unmodified lines | ||
| 4015 | 4016 | struct ceph_mds_reply_head *head = msg->front.iov_base; |
| 4016 | 4017 | struct ceph_mds_reply_info_parsed *rinfo; /* parsed reply info */ |
| 4017 | 4018 | struct ceph_snap_realm *realm; |
| 4019 | + unsigned int nofs_flags; | |
| 4018 | 4020 | u64 tid; |
| 4019 | 4021 | int err, result; |
| 4020 | 4022 | int mds = session->s_mds; |
| @@ -4158,6 +4160,14 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg) · 137 unmodified lines | ||
| 4158 | 4160 | |
| 4159 | 4161 | /* insert trace into our cache */ |
| 4160 | 4162 | mutex_lock(&req->r_fill_mutex); |
| 4163 | + | |
| 4164 | + /* disable fs reclaim while we are using current->journal_info | |
| 4165 | + * for our own purposes, or else shrinkers of other | |
| 4166 | + * filesystems might dereference this pointer as a different | |
| 4167 | + * type | |
| 4168 | + */ | |
| 4169 | + nofs_flags = memalloc_nofs_save(); | |
| 4170 | + | |
| 4161 | 4171 | current->journal_info = req; |
| 4162 | 4172 | err = ceph_fill_trace(mdsc->fsc->sb, req); |
| 4163 | 4173 | if (err == 0) { |
| @@ -4166,6 +4176,7 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg) · 2 unmodified lines | ||
| 4166 | 4176 | err = ceph_readdir_prepopulate(req, req->r_session); |
| 4167 | 4177 | } |
| 4168 | 4178 | current->journal_info = NULL; |
| 4179 | + memalloc_nofs_restore(nofs_flags); | |
| 4169 | 4180 | mutex_unlock(&req->r_fill_mutex); |
| 4170 | 4181 | |
| 4171 | 4182 | up_read(&mdsc->snap_rwsem); |
| @@ -77,6 +77,7 @@ struct ceph_fs_client; · 76 unmodified lines | ||
| 77 | 77 | struct ceph_cap; |
| 78 | 78 | |
| 79 | 79 | #define MDS_AUTH_UID_ANY -1 |
| 80 | +#define CEPH_GET_CAPS_WAIT_TIMEOUT (5 * HZ) | |
| 80 | 81 | #define CEPH_CAP_FLUSH_WAIT_TIMEOUT_SEC 60 |
| 81 | 82 | #define CEPH_CAP_FLUSH_MAX_DUMP_ENTRIES 5 |
| 82 | 83 | #define CEPH_CAP_FLUSH_MAX_DUMP_ITERS 5 |
| @@ -22,22 +22,14 @@ · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | #include "fscrypt_private.h" |
| 24 | 24 | |
| 25 | −static struct block_device **fscrypt_get_devices(struct super_block *sb, | |
| 26 | − unsigned int *num_devs) | |
| 25 | +static unsigned int | |
| 26 | +fscrypt_get_devices(struct super_block *sb, | |
| 27 | + struct block_device *devs[FSCRYPT_MAX_DEVICES]) | |
| 27 | 28 | { |
| 28 | − struct block_device **devs; | |
| 29 | − | |
| 30 | − if (sb->s_cop->get_devices) { | |
| 31 | − devs = sb->s_cop->get_devices(sb, num_devs); | |
| 32 | − if (devs) | |
| 33 | − return devs; | |
| 34 | − } | |
| 35 | − devs = kmalloc_obj(*devs); | |
| 36 | − if (!devs) | |
| 37 | − return ERR_PTR(-ENOMEM); | |
| 29 | + if (sb->s_cop->get_devices) | |
| 30 | + return sb->s_cop->get_devices(sb, devs); | |
| 38 | 31 | devs[0] = sb->s_bdev; |
| 39 | − *num_devs = 1; | |
| 40 | − return devs; | |
| 32 | + return 1; | |
| 41 | 33 | } |
| 42 | 34 | |
| 43 | 35 | static unsigned int fscrypt_get_dun_bytes(const struct fscrypt_inode_info *ci) |
| @@ -96,7 +88,7 @@ int fscrypt_select_encryption_impl(struct fscrypt_inode_info *ci, · 52 unmodified lines | ||
| 96 | 88 | const struct inode *inode = ci->ci_inode; |
| 97 | 89 | struct super_block *sb = inode->i_sb; |
| 98 | 90 | struct blk_crypto_config crypto_cfg; |
| 99 | − struct block_device **devs; | |
| 91 | + struct block_device *devs[FSCRYPT_MAX_DEVICES]; | |
| 100 | 92 | unsigned int num_devs; |
| 101 | 93 | unsigned int i; |
| 102 | 94 | |
| @@ -135,20 +127,15 @@ int fscrypt_select_encryption_impl(struct fscrypt_inode_info *ci, · 32 unmodified lines | ||
| 135 | 127 | crypto_cfg.key_type = is_hw_wrapped_key ? |
| 136 | 128 | BLK_CRYPTO_KEY_TYPE_HW_WRAPPED : BLK_CRYPTO_KEY_TYPE_RAW; |
| 137 | 129 | |
| 138 | − devs = fscrypt_get_devices(sb, &num_devs); | |
| 139 | − if (IS_ERR(devs)) | |
| 140 | − return PTR_ERR(devs); | |
| 141 | − | |
| 130 | + num_devs = fscrypt_get_devices(sb, devs); | |
| 142 | 131 | for (i = 0; i < num_devs; i++) { |
| 143 | 132 | if (!blk_crypto_config_supported(devs[i], &crypto_cfg)) |
| 144 | − goto out_free_devs; | |
| 133 | + return 0; | |
| 145 | 134 | } |
| 146 | 135 | |
| 147 | 136 | fscrypt_log_blk_crypto_impl(ci->ci_mode, devs, num_devs, &crypto_cfg); |
| 148 | 137 | |
| 149 | 138 | ci->ci_inlinecrypt = true; |
| 150 | −out_free_devs: | |
| 151 | − kfree(devs); | |
| 152 | 139 | |
| 153 | 140 | return 0; |
| 154 | 141 | } |
| @@ -164,7 +151,7 @@ int fscrypt_prepare_inline_crypt_key(struct fscrypt_prepared_key *prep_key, · 9 unmodified lines | ||
| 164 | 151 | enum blk_crypto_key_type key_type = is_hw_wrapped ? |
| 165 | 152 | BLK_CRYPTO_KEY_TYPE_HW_WRAPPED : BLK_CRYPTO_KEY_TYPE_RAW; |
| 166 | 153 | struct blk_crypto_key *blk_key; |
| 167 | − struct block_device **devs; | |
| 154 | + struct block_device *devs[FSCRYPT_MAX_DEVICES]; | |
| 168 | 155 | unsigned int num_devs; |
| 169 | 156 | unsigned int i; |
| 170 | 157 | int err; |
| @@ -182,17 +169,12 @@ int fscrypt_prepare_inline_crypt_key(struct fscrypt_prepared_key *prep_key, · 11 unmodified lines | ||
| 182 | 169 | } |
| 183 | 170 | |
| 184 | 171 | /* Start using blk-crypto on all the filesystem's block devices. */ |
| 185 | − devs = fscrypt_get_devices(sb, &num_devs); | |
| 186 | − if (IS_ERR(devs)) { | |
| 187 | − err = PTR_ERR(devs); | |
| 188 | − goto fail; | |
| 189 | − } | |
| 172 | + num_devs = fscrypt_get_devices(sb, devs); | |
| 190 | 173 | for (i = 0; i < num_devs; i++) { |
| 191 | 174 | err = blk_crypto_start_using_key(devs[i], blk_key); |
| 192 | 175 | if (err) |
| 193 | 176 | break; |
| 194 | 177 | } |
| 195 | − kfree(devs); | |
| 196 | 178 | if (err) { |
| 197 | 179 | fscrypt_err(inode, "error %d starting to use blk-crypto", err); |
| 198 | 180 | goto fail; |
| @@ -210,20 +192,21 @@ void fscrypt_destroy_inline_crypt_key(struct super_block *sb, · 11 unmodified lines | ||
| 210 | 192 | struct fscrypt_prepared_key *prep_key) |
| 211 | 193 | { |
| 212 | 194 | struct blk_crypto_key *blk_key = prep_key->blk_key; |
| 213 | − struct block_device **devs; | |
| 195 | + struct block_device *devs[FSCRYPT_MAX_DEVICES]; | |
| 214 | 196 | unsigned int num_devs; |
| 215 | 197 | unsigned int i; |
| 216 | 198 | |
| 217 | 199 | if (!blk_key) |
| 218 | 200 | return; |
| 219 | 201 | |
| 220 | − /* Evict the key from all the filesystem's block devices. */ | |
| 221 | − devs = fscrypt_get_devices(sb, &num_devs); | |
| 222 | − if (!IS_ERR(devs)) { | |
| 223 | − for (i = 0; i < num_devs; i++) | |
| 224 | − blk_crypto_evict_key(devs[i], blk_key); | |
| 225 | − kfree(devs); | |
| 226 | − } | |
| 202 | + /* | |
| 203 | + * Evict the key from all the filesystem's block devices. | |
| 204 | + * This *must* be done before the key is freed. | |
| 205 | + */ | |
| 206 | + num_devs = fscrypt_get_devices(sb, devs); | |
| 207 | + for (i = 0; i < num_devs; i++) | |
| 208 | + blk_crypto_evict_key(devs[i], blk_key); | |
| 209 | + | |
| 227 | 210 | kfree_sensitive(blk_key); |
| 228 | 211 | } |
| 229 | 212 | |
| @@ -147,13 +147,19 @@ find_or_insert_direct_key(struct fscrypt_direct_key *to_insert, · 146 unmodified lines | ||
| 147 | 147 | if (memcmp(ci->ci_policy.v1.master_key_descriptor, |
| 148 | 148 | dk->dk_descriptor, FSCRYPT_KEY_DESCRIPTOR_SIZE) != 0) |
| 149 | 149 | continue; |
| 150 | + /* The sb is used at eviction time, so it must be the same. */ | |
| 151 | + if (ci->ci_inode->i_sb != dk->dk_sb) | |
| 152 | + continue; | |
| 150 | 153 | if (ci->ci_mode != dk->dk_mode) |
| 151 | 154 | continue; |
| 152 | 155 | if (!fscrypt_is_key_prepared(&dk->dk_key, ci)) |
| 153 | 156 | continue; |
| 154 | 157 | if (crypto_memneq(raw_key, dk->dk_raw, ci->ci_mode->keysize)) |
| 155 | 158 | continue; |
| 156 | − /* using existing tfm with same (descriptor, mode, raw_key) */ | |
| 159 | + /* | |
| 160 | + * Use an existing prepared key with the same (descriptor, sb, | |
| 161 | + * mode, inlinecrypt, raw_key) combination. | |
| 162 | + */ | |
| 157 | 163 | refcount_inc(&dk->dk_refcount); |
| 158 | 164 | spin_unlock(&fscrypt_direct_keys_lock); |
| 159 | 165 | free_direct_key(to_insert); |
| @@ -459,11 +459,14 @@ static struct kmem_cache *pwq_cache __ro_after_init; · 458 unmodified lines | ||
| 459 | 459 | * Wrapper anchor for file->f_ep when the watched file is not itself an |
| 460 | 460 | * eventpoll; for the epoll-watches-epoll case, file->f_ep points at |
| 461 | 461 | * &watched_ep->refs directly. The ->next field threads |
| 462 | − * ctx->tfile_check_list during one EPOLL_CTL_ADD path check. | |
| 462 | + * ctx->tfile_check_list during one EPOLL_CTL_ADD path check. The ->file | |
| 463 | + * field holds a reference to the associated file while the head is on | |
| 464 | + * the list. | |
| 463 | 465 | */ |
| 464 | 466 | struct epitems_head { |
| 465 | 467 | struct hlist_head epitems; |
| 466 | 468 | struct epitems_head *next; |
| 469 | + struct file *file; | |
| 467 | 470 | }; |
| 468 | 471 | |
| 469 | 472 | static struct kmem_cache *ephead_cache __ro_after_init; |
| @@ -480,6 +483,16 @@ static void list_file(struct file *file, struct ep_ctl_ctx *ctx) · 10 unmodified lines | ||
| 480 | 483 | |
| 481 | 484 | head = container_of(file->f_ep, struct epitems_head, epitems); |
| 482 | 485 | if (!head->next) { |
| 486 | + /* | |
| 487 | + * The caller owns a reference to @file or holds the ep->mtx for the | |
| 488 | + * epitem that led here. The latter blocks eventpoll_release_file() | |
| 489 | + * before the file allocation can be freed and reused. A dying leaf | |
| 490 | + * can be skipped since removing links cannot increase the reverse | |
| 491 | + * path count. | |
| 492 | + */ | |
| 493 | + if (!file_ref_get(&file->f_ref)) | |
| 494 | + return; | |
| 495 | + head->file = file; | |
| 483 | 496 | head->next = ctx->tfile_check_list; |
| 484 | 497 | ctx->tfile_check_list = head; |
| 485 | 498 | } |
| @@ -489,15 +502,18 @@ static void unlist_file(struct epitems_head *head) · 3 unmodified lines | ||
| 489 | 502 | { |
| 490 | 503 | struct epitems_head *to_free = head; |
| 491 | 504 | struct hlist_node *p = rcu_dereference(hlist_first_rcu(&head->epitems)); |
| 505 | + struct file *file = head->file; | |
| 492 | 506 | if (p) { |
| 493 | 507 | struct epitem *epi= container_of(p, struct epitem, fllink); |
| 494 | 508 | spin_lock(&epi->ffd.file->f_lock); |
| 495 | 509 | if (!hlist_empty(&head->epitems)) |
| 496 | 510 | to_free = NULL; |
| 497 | 511 | head->next = NULL; |
| 512 | + head->file = NULL; | |
| 498 | 513 | spin_unlock(&epi->ffd.file->f_lock); |
| 499 | 514 | } |
| 500 | 515 | free_ephead(to_free); |
| 516 | + fput(file); | |
| 501 | 517 | } |
| 502 | 518 | |
| 503 | 519 | #ifdef CONFIG_SYSCTL |
| @@ -740,7 +740,7 @@ int transfer_args_to_stack(struct linux_binprm *bprm, · 739 unmodified lines | ||
| 740 | 740 | stop = bprm->p >> PAGE_SHIFT; |
| 741 | 741 | sp = *sp_location; |
| 742 | 742 | |
| 743 | − for (index = MAX_ARG_PAGES - 1; index >= stop; index--) { | |
| 743 | + for (index = MAX_ARG_PAGES; index-- > stop; ) { | |
| 744 | 744 | unsigned int offset = index == stop ? bprm->p & ~PAGE_MASK : 0; |
| 745 | 745 | char *src = kmap_local_page(bprm->page[index]) + offset; |
| 746 | 746 | sp -= PAGE_SIZE - offset; |
| @@ -3749,24 +3749,27 @@ static bool f2fs_has_stable_inodes(struct super_block *sb) · 3748 unmodified lines | ||
| 3749 | 3749 | return true; |
| 3750 | 3750 | } |
| 3751 | 3751 | |
| 3752 | −static struct block_device **f2fs_get_devices(struct super_block *sb, | |
| 3753 | − unsigned int *num_devs) | |
| 3752 | +static unsigned int | |
| 3753 | +f2fs_get_devices(struct super_block *sb, | |
| 3754 | + struct block_device *devs[FSCRYPT_MAX_DEVICES]) | |
| 3754 | 3755 | { |
| 3755 | 3756 | struct f2fs_sb_info *sbi = F2FS_SB(sb); |
| 3756 | − struct block_device **devs; | |
| 3757 | + int ndevs; | |
| 3757 | 3758 | int i; |
| 3758 | 3759 | |
| 3759 | − if (!f2fs_is_multi_device(sbi)) | |
| 3760 | − return NULL; | |
| 3760 | + static_assert(MAX_DEVICES <= FSCRYPT_MAX_DEVICES); | |
| 3761 | 3761 | |
| 3762 | − devs = kmalloc_objs(*devs, sbi->s_ndevs); | |
| 3763 | − if (!devs) | |
| 3764 | − return ERR_PTR(-ENOMEM); | |
| 3762 | + if (!f2fs_is_multi_device(sbi)) { | |
| 3763 | + devs[0] = sb->s_bdev; | |
| 3764 | + return 1; | |
| 3765 | + } | |
| 3766 | + ndevs = sbi->s_ndevs; | |
| 3767 | + if (WARN_ON_ONCE(ndevs > FSCRYPT_MAX_DEVICES)) | |
| 3768 | + ndevs = FSCRYPT_MAX_DEVICES; | |
| 3765 | 3769 | |
| 3766 | − for (i = 0; i < sbi->s_ndevs; i++) | |
| 3770 | + for (i = 0; i < ndevs; i++) | |
| 3767 | 3771 | devs[i] = FDEV(i).bdev; |
| 3768 | − *num_devs = sbi->s_ndevs; | |
| 3769 | − return devs; | |
| 3772 | + return ndevs; | |
| 3770 | 3773 | } |
| 3771 | 3774 | |
| 3772 | 3775 | static const struct fscrypt_operations f2fs_cryptops = { |
| @@ -249,13 +249,13 @@ static inline unsigned char fat_checksum(const __u8 *name) · 248 unmodified lines | ||
| 249 | 249 | return s; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | −static inline sector_t fat_clus_to_blknr(struct msdos_sb_info *sbi, int clus) | |
| 252 | +static inline sector_t fat_clus_to_blknr(const struct msdos_sb_info *sbi, int clus) | |
| 253 | 253 | { |
| 254 | 254 | return ((sector_t)clus - FAT_START_ENT) * sbi->sec_per_clus |
| 255 | 255 | + sbi->data_start; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | −static inline void fat_get_blknr_offset(struct msdos_sb_info *sbi, | |
| 258 | +static inline void fat_get_blknr_offset(const struct msdos_sb_info *sbi, | |
| 259 | 259 | loff_t i_pos, sector_t *blknr, int *offset) |
| 260 | 260 | { |
| 261 | 261 | *blknr = i_pos >> sbi->dir_per_block_bits; |
| @@ -22,7 +22,7 @@ static void fat_checksum_test(struct kunit *test) · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | static void fat_clus_to_blknr_test(struct kunit *test) |
| 24 | 24 | { |
| 25 | − struct msdos_sb_info sbi = { | |
| 25 | + static const struct msdos_sb_info sbi = { | |
| 26 | 26 | .sec_per_clus = 4, |
| 27 | 27 | .data_start = 100, |
| 28 | 28 | }; |
| @@ -34,7 +34,7 @@ static void fat_clus_to_blknr_test(struct kunit *test) · 5 unmodified lines | ||
| 34 | 34 | |
| 35 | 35 | static void fat_get_blknr_offset_test(struct kunit *test) |
| 36 | 36 | { |
| 37 | − struct msdos_sb_info sbi = { | |
| 37 | + static const struct msdos_sb_info sbi = { | |
| 38 | 38 | .dir_per_block = 16, |
| 39 | 39 | .dir_per_block_bits = 4, |
| 40 | 40 | }; |
| @@ -68,11 +68,13 @@ static bool ifs_set_range_uptodate(struct folio *folio, · 67 unmodified lines | ||
| 68 | 68 | struct iomap_folio_state *ifs, size_t off, size_t len) |
| 69 | 69 | { |
| 70 | 70 | struct inode *inode = folio->mapping->host; |
| 71 | − unsigned int first_blk = off >> inode->i_blkbits; | |
| 72 | − unsigned int last_blk = (off + len - 1) >> inode->i_blkbits; | |
| 73 | − unsigned int nr_blks = last_blk - first_blk + 1; | |
| 71 | + unsigned int first_blk, last_blk; | |
| 74 | 72 | |
| 75 | − bitmap_set(ifs->state, first_blk, nr_blks); | |
| 73 | + if (len) { | |
| 74 | + first_blk = off >> inode->i_blkbits; | |
| 75 | + last_blk = (off + len - 1) >> inode->i_blkbits; | |
| 76 | + bitmap_set(ifs->state, first_blk, last_blk - first_blk + 1); | |
| 77 | + } | |
| 76 | 78 | return ifs_is_fully_uptodate(folio, ifs); |
| 77 | 79 | } |
| 78 | 80 | |
| @@ -172,18 +174,29 @@ static unsigned iomap_find_dirty_range(struct folio *folio, u64 *range_start, · 93 unmodified lines | ||
| 172 | 174 | return range_end - *range_start; |
| 173 | 175 | } |
| 174 | 176 | |
| 177 | +/* | |
| 178 | + * Clear the per-block dirty bits for the range [@off, @off + @len) within a | |
| 179 | + * folio. The range is rounded inwards so that only blocks fully covered by | |
| 180 | + * the range are cleared. This is required for operations like folio | |
| 181 | + * invalidation, where we must ensure a block is fully clean before discarding | |
| 182 | + * it. | |
| 183 | + */ | |
| 175 | 184 | static void ifs_clear_range_dirty(struct folio *folio, |
| 176 | 185 | struct iomap_folio_state *ifs, size_t off, size_t len) |
| 177 | 186 | { |
| 178 | 187 | struct inode *inode = folio->mapping->host; |
| 179 | 188 | unsigned int blks_per_folio = i_blocks_per_folio(inode, folio); |
| 180 | − unsigned int first_blk = (off >> inode->i_blkbits); | |
| 181 | − unsigned int last_blk = (off + len - 1) >> inode->i_blkbits; | |
| 182 | − unsigned int nr_blks = last_blk - first_blk + 1; | |
| 189 | + unsigned int first_blk = round_up(off, i_blocksize(inode)) >> | |
| 190 | + inode->i_blkbits; | |
| 191 | + unsigned int last_blk = (off + len) >> inode->i_blkbits; | |
| 183 | 192 | unsigned long flags; |
| 184 | 193 | |
| 194 | + if (first_blk >= last_blk) | |
| 195 | + return; | |
| 196 | + | |
| 185 | 197 | spin_lock_irqsave(&ifs->state_lock, flags); |
| 186 | − bitmap_clear(ifs->state, first_blk + blks_per_folio, nr_blks); | |
| 198 | + bitmap_clear(ifs->state, first_blk + blks_per_folio, | |
| 199 | + last_blk - first_blk); | |
| 187 | 200 | spin_unlock_irqrestore(&ifs->state_lock, flags); |
| 188 | 201 | } |
| 189 | 202 | |
| @@ -195,18 +208,29 @@ static void iomap_clear_range_dirty(struct folio *folio, size_t off, size_t len) · 5 unmodified lines | ||
| 195 | 208 | ifs_clear_range_dirty(folio, ifs, off, len); |
| 196 | 209 | } |
| 197 | 210 | |
| 211 | +/* | |
| 212 | + * Set the per-block dirty bits for the range [@off, @off + @len) within a | |
| 213 | + * folio. The range is rounded outwards so that any block partially touched | |
| 214 | + * by the range is marked dirty. This ensures blocks containing even a | |
| 215 | + * single dirty byte will be included in subsequent writeback, preventing | |
| 216 | + * data loss when partial blocks are written. | |
| 217 | + */ | |
| 198 | 218 | static void ifs_set_range_dirty(struct folio *folio, |
| 199 | 219 | struct iomap_folio_state *ifs, size_t off, size_t len) |
| 200 | 220 | { |
| 201 | 221 | struct inode *inode = folio->mapping->host; |
| 202 | 222 | unsigned int blks_per_folio = i_blocks_per_folio(inode, folio); |
| 203 | − unsigned int first_blk = (off >> inode->i_blkbits); | |
| 204 | − unsigned int last_blk = (off + len - 1) >> inode->i_blkbits; | |
| 205 | − unsigned int nr_blks = last_blk - first_blk + 1; | |
| 223 | + unsigned int first_blk, last_blk; | |
| 206 | 224 | unsigned long flags; |
| 207 | 225 | |
| 226 | + if (!len) | |
| 227 | + return; | |
| 228 | + | |
| 229 | + first_blk = off >> inode->i_blkbits; | |
| 230 | + last_blk = (off + len - 1) >> inode->i_blkbits; | |
| 208 | 231 | spin_lock_irqsave(&ifs->state_lock, flags); |
| 209 | − bitmap_set(ifs->state, first_blk + blks_per_folio, nr_blks); | |
| 232 | + bitmap_set(ifs->state, first_blk + blks_per_folio, | |
| 233 | + last_blk - first_blk + 1); | |
| 210 | 234 | spin_unlock_irqrestore(&ifs->state_lock, flags); |
| 211 | 235 | } |
| 212 | 236 | |
| @@ -811,6 +835,8 @@ void iomap_invalidate_folio(struct folio *folio, size_t offset, size_t len) · 598 unmodified lines | ||
| 811 | 835 | WARN_ON_ONCE(folio_test_writeback(folio)); |
| 812 | 836 | folio_cancel_dirty(folio); |
| 813 | 837 | ifs_free(folio); |
| 838 | + } else { | |
| 839 | + iomap_clear_range_dirty(folio, offset, len); | |
| 814 | 840 | } |
| 815 | 841 | } |
| 816 | 842 | EXPORT_SYMBOL_GPL(iomap_invalidate_folio); |
| @@ -1619,6 +1645,7 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero, · 802 unmodified lines | ||
| 1619 | 1645 | const struct iomap_write_ops *write_ops) |
| 1620 | 1646 | { |
| 1621 | 1647 | u64 bytes = iomap_length(iter); |
| 1648 | + bool zeroed = false; | |
| 1622 | 1649 | int status; |
| 1623 | 1650 | |
| 1624 | 1651 | do { |
| @@ -1639,6 +1666,8 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero, · 14 unmodified lines | ||
| 1639 | 1666 | /* a NULL folio means we're done with a folio batch */ |
| 1640 | 1667 | if (!folio) { |
| 1641 | 1668 | status = iomap_iter_advance_full(iter); |
| 1669 | + if (status) | |
| 1670 | + return status; | |
| 1642 | 1671 | break; |
| 1643 | 1672 | } |
| 1644 | 1673 | |
| @@ -1649,6 +1678,7 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero, · 4 unmodified lines | ||
| 1649 | 1678 | bytes); |
| 1650 | 1679 | |
| 1651 | 1680 | folio_zero_range(folio, offset, bytes); |
| 1681 | + zeroed = true; | |
| 1652 | 1682 | folio_mark_accessed(folio); |
| 1653 | 1683 | |
| 1654 | 1684 | ret = iomap_write_end(iter, bytes, bytes, folio); |
| @@ -1658,10 +1688,10 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero, · 3 unmodified lines | ||
| 1658 | 1688 | |
| 1659 | 1689 | status = iomap_iter_advance(iter, bytes); |
| 1660 | 1690 | if (status) |
| 1661 | − break; | |
| 1691 | + return status; | |
| 1662 | 1692 | } while ((bytes = iomap_length(iter)) > 0); |
| 1663 | 1693 | |
| 1664 | − if (did_zero) | |
| 1694 | + if (did_zero && zeroed) | |
| 1665 | 1695 | *did_zero = true; |
| 1666 | 1696 | return status; |
| 1667 | 1697 | } |
| @@ -385,6 +385,8 @@ static bool iomap_ioend_can_merge(struct iomap_ioend *ioend, · 384 unmodified lines | ||
| 385 | 385 | |
| 386 | 386 | if (ioend->io_bio.bi_status != next->io_bio.bi_status) |
| 387 | 387 | return false; |
| 388 | + if (ioend->io_private != next->io_private) | |
| 389 | + return false; | |
| 388 | 390 | if (next->io_flags & IOMAP_IOEND_BOUNDARY) |
| 389 | 391 | return false; |
| 390 | 392 | if ((ioend->io_flags & IOMAP_IOEND_NOMERGE_FLAGS) != |
| @@ -901,7 +901,8 @@ static __be32 nlmsvc_proc_granted_msg(struct svc_rqst *rqstp) · 900 unmodified lines | ||
| 901 | 901 | if (argp->xdrgen.cookie.len > NLM_MAXCOOKIELEN) |
| 902 | 902 | return rpc_garbage_args; |
| 903 | 903 | |
| 904 | − host = nlm3svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false); | |
| 904 | + host = nlmsvc_lookup_host(rqstp, argp->xdrgen.alock.caller_name.data, | |
| 905 | + argp->xdrgen.alock.caller_name.len); | |
| 905 | 906 | if (!host) |
| 906 | 907 | return rpc_system_err; |
| 907 | 908 | |
| @@ -528,6 +528,7 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, · 527 unmodified lines | ||
| 528 | 528 | struct file *file_out, loff_t pos_out, |
| 529 | 529 | loff_t len, unsigned int flags, enum ovl_copyop op) |
| 530 | 530 | { |
| 531 | + struct inode *inode_in = file_inode(file_in); | |
| 531 | 532 | struct inode *inode_out = file_inode(file_out); |
| 532 | 533 | struct file *realfile_in, *realfile_out; |
| 533 | 534 | loff_t ret; |
| @@ -551,7 +552,20 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, · 17 unmodified lines | ||
| 551 | 552 | if (IS_ERR(realfile_in)) |
| 552 | 553 | goto out_unlock; |
| 553 | 554 | |
| 554 | − with_ovl_creds(file_inode(file_out)->i_sb) { | |
| 555 | + /* | |
| 556 | + * For cross-sb copy, vfs_copy_file_range() will verify read access with | |
| 557 | + * the mounter creds of the dest fs mounter, so we need to explicitly | |
| 558 | + * verify read access with the source mounter creds. | |
| 559 | + */ | |
| 560 | + if (unlikely(inode_in->i_sb != inode_out->i_sb)) { | |
| 561 | + with_ovl_creds(inode_in->i_sb) { | |
| 562 | + ret = rw_verify_area(READ, realfile_in, &pos_in, len); | |
| 563 | + if (unlikely(ret)) | |
| 564 | + goto out_unlock; | |
| 565 | + } | |
| 566 | + } | |
| 567 | + | |
| 568 | + with_ovl_creds(inode_out->i_sb) { | |
| 555 | 569 | switch (op) { |
| 556 | 570 | case OVL_COPY: |
| 557 | 571 | ret = vfs_copy_file_range(realfile_in, pos_in, |
| @@ -13,7 +13,7 @@ static bool ovl_is_escaped_xattr(struct super_block *sb, const char *name) · 12 unmodified lines | ||
| 13 | 13 | OVL_XATTR_ESCAPE_USER_PREFIX_LEN) == 0; |
| 14 | 14 | else |
| 15 | 15 | return strncmp(name, OVL_XATTR_ESCAPE_TRUSTED_PREFIX, |
| 16 | − OVL_XATTR_ESCAPE_TRUSTED_PREFIX_LEN - 1) == 0; | |
| 16 | + OVL_XATTR_ESCAPE_TRUSTED_PREFIX_LEN) == 0; | |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | static bool ovl_is_own_xattr(struct super_block *sb, const char *name) |
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | #include <linux/anon_inodes.h> |
| 3 | +#include <linux/compat.h> | |
| 3 | 4 | #include <linux/exportfs.h> |
| 4 | 5 | #include <linux/file.h> |
| 5 | 6 | #include <linux/fs.h> |
| @@ -107,7 +108,7 @@ struct pidfs_attr { · 101 unmodified lines | ||
| 107 | 108 | |
| 108 | 109 | #if BITS_PER_LONG == 32 |
| 109 | 110 | |
| 110 | −DEFINE_SPINLOCK(pidfs_ino_lock); | |
| 111 | +static DEFINE_SPINLOCK(pidfs_ino_lock); | |
| 111 | 112 | static u64 pidfs_ino_nr = 1; |
| 112 | 113 | |
| 113 | 114 | static inline unsigned long pidfs_ino(u64 ino) |
| @@ -659,6 +660,17 @@ static long pidfd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 545 unmodified lines | ||
| 659 | 660 | return open_namespace(ns_common); |
| 660 | 661 | } |
| 661 | 662 | |
| 663 | +#ifdef CONFIG_COMPAT | |
| 664 | +static long pidfd_compat_ioctl(struct file *file, unsigned int cmd, | |
| 665 | + unsigned long arg) | |
| 666 | +{ | |
| 667 | + if (cmd == FS_IOC32_GETVERSION) | |
| 668 | + cmd = FS_IOC_GETVERSION; | |
| 669 | + | |
| 670 | + return pidfd_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); | |
| 671 | +} | |
| 672 | +#endif | |
| 673 | + | |
| 662 | 674 | static int pidfs_file_release(struct inode *inode, struct file *file) |
| 663 | 675 | { |
| 664 | 676 | struct pid *pid = inode->i_private; |
| @@ -686,7 +698,9 @@ static const struct file_operations pidfs_file_operations = { · 21 unmodified lines | ||
| 686 | 698 | .show_fdinfo = pidfd_show_fdinfo, |
| 687 | 699 | #endif |
| 688 | 700 | .unlocked_ioctl = pidfd_ioctl, |
| 689 | − .compat_ioctl = compat_ptr_ioctl, | |
| 701 | +#ifdef CONFIG_COMPAT | |
| 702 | + .compat_ioctl = pidfd_compat_ioctl, | |
| 703 | +#endif | |
| 690 | 704 | }; |
| 691 | 705 | |
| 692 | 706 | struct pid *pidfd_pid(const struct file *file) |
| @@ -915,6 +929,20 @@ static struct dentry *pidfs_fh_to_dentry(struct super_block *sb, · 222 unmodified lines | ||
| 915 | 929 | return path.dentry; |
| 916 | 930 | } |
| 917 | 931 | |
| 932 | +static struct file *pidfs_dentry_open(const struct path *path, | |
| 933 | + unsigned int flags, | |
| 934 | + const struct cred *cred) | |
| 935 | +{ | |
| 936 | + struct file *file; | |
| 937 | + | |
| 938 | + /* pidfds are always O_RDWR. */ | |
| 939 | + file = dentry_open(path, flags | O_RDWR, cred); | |
| 940 | + /* do_dentry_open() strips O_EXCL and O_TRUNC. */ | |
| 941 | + if (!IS_ERR(file)) | |
| 942 | + file->f_flags |= flags & (PIDFD_THREAD | PIDFD_AUTOKILL); | |
| 943 | + return file; | |
| 944 | +} | |
| 945 | + | |
| 918 | 946 | /* |
| 919 | 947 | * Make sure that we reject any nonsensical flags that users pass via |
| 920 | 948 | * open_by_handle_at(). Note that PIDFD_THREAD is defined as O_EXCL, and |
| @@ -940,11 +968,13 @@ static int pidfs_export_permission(struct handle_to_path_ctx *ctx, · 19 unmodified lines | ||
| 940 | 968 | static struct file *pidfs_export_open(const struct path *path, unsigned int oflags) |
| 941 | 969 | { |
| 942 | 970 | /* |
| 943 | − * Clear O_LARGEFILE as open_by_handle_at() forces it and raise | |
| 944 | − * O_RDWR as pidfds always are. | |
| 971 | + * Opening via file handle may never raise PIDFD_AUTOKILL. That can | |
| 972 | + * only be done at task creation! | |
| 945 | 973 | */ |
| 946 | − oflags &= ~O_LARGEFILE; | |
| 947 | − return dentry_open(path, oflags | O_RDWR, current_cred()); | |
| 974 | + if (WARN_ON_ONCE(oflags & PIDFD_AUTOKILL)) | |
| 975 | + return ERR_PTR(-EINVAL); | |
| 976 | + /* Clear O_LARGEFILE as open_by_handle_at() forces it. */ | |
| 977 | + return pidfs_dentry_open(path, oflags & ~O_LARGEFILE, current_cred()); | |
| 948 | 978 | } |
| 949 | 979 | |
| 950 | 980 | static const struct export_operations pidfs_export_operations = { |
| @@ -1108,7 +1138,6 @@ static struct file_system_type pidfs_type = { · 157 unmodified lines | ||
| 1108 | 1138 | |
| 1109 | 1139 | struct file *pidfs_alloc_file(struct pid *pid, unsigned int flags) |
| 1110 | 1140 | { |
| 1111 | − struct file *pidfd_file; | |
| 1112 | 1141 | struct path path __free(path_put) = {}; |
| 1113 | 1142 | int ret; |
| 1114 | 1143 | |
| @@ -1126,16 +1155,7 @@ struct file *pidfs_alloc_file(struct pid *pid, unsigned int flags) · 11 unmodified lines | ||
| 1126 | 1155 | VFS_WARN_ON_ONCE(!pid->attr); |
| 1127 | 1156 | |
| 1128 | 1157 | flags &= ~PIDFD_STALE; |
| 1129 | − flags |= O_RDWR; | |
| 1130 | − pidfd_file = dentry_open(&path, flags, current_cred()); | |
| 1131 | − /* | |
| 1132 | − * Raise PIDFD_THREAD and PIDFD_AUTOKILL explicitly as | |
| 1133 | − * do_dentry_open() strips O_EXCL and O_TRUNC. | |
| 1134 | − */ | |
| 1135 | − if (!IS_ERR(pidfd_file)) | |
| 1136 | − pidfd_file->f_flags |= (flags & (PIDFD_THREAD | PIDFD_AUTOKILL)); | |
| 1137 | − | |
| 1138 | − return pidfd_file; | |
| 1158 | + return pidfs_dentry_open(&path, flags, current_cred()); | |
| 1139 | 1159 | } |
| 1140 | 1160 | |
| 1141 | 1161 | void __init pidfs_init(void) |
| @@ -93,6 +93,13 @@ static void __forget_cached_acl(struct posix_acl **p) · 92 unmodified lines | ||
| 93 | 93 | { |
| 94 | 94 | struct posix_acl *old; |
| 95 | 95 | |
| 96 | + /* | |
| 97 | + * ACL_DONT_CACHE is expected to be a "const" value and xchg it with | |
| 98 | + * ACL_NOT_CACHED would enable acl caching for the inode - | |
| 99 | + * clearly not what the caller has intended. | |
| 100 | + */ | |
| 101 | + if (READ_ONCE(*p) == ACL_DONT_CACHE) | |
| 102 | + return; | |
| 96 | 103 | old = xchg(p, ACL_NOT_CACHED); |
| 97 | 104 | if (!is_uncached_acl(old)) |
| 98 | 105 | posix_acl_release(old); |
| @@ -46,7 +46,7 @@ static const char *proc_ns_get_link(struct dentry *dentry, · 45 unmodified lines | ||
| 46 | 46 | const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops; |
| 47 | 47 | struct task_struct *task; |
| 48 | 48 | struct path ns_path; |
| 49 | − int error = -EACCES; | |
| 49 | + int error; | |
| 50 | 50 | |
| 51 | 51 | if (!dentry) |
| 52 | 52 | return ERR_PTR(-ECHILD); |
| @@ -59,6 +59,7 @@ static const char *proc_ns_get_link(struct dentry *dentry, · 6 unmodified lines | ||
| 59 | 59 | if (error) |
| 60 | 60 | goto out_put_task; |
| 61 | 61 | |
| 62 | + error = -EACCES; | |
| 62 | 63 | if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) |
| 63 | 64 | goto out; |
| 64 | 65 | |
| @@ -90,6 +91,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl · 25 unmodified lines | ||
| 90 | 91 | if (res) |
| 91 | 92 | goto out_put_task; |
| 92 | 93 | |
| 94 | + res = -EACCES; | |
| 93 | 95 | if (ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) { |
| 94 | 96 | res = ns_get_name(name, sizeof(name), task, ns_ops); |
| 95 | 97 | if (res >= 0) |
| @@ -440,6 +440,7 @@ cifs_alloc_inode(struct super_block *sb) · 439 unmodified lines | ||
| 440 | 440 | return NULL; |
| 441 | 441 | cifs_inode->cifsAttrs = ATTR_ARCHIVE; /* default */ |
| 442 | 442 | cifs_inode->time = 0; |
| 443 | + cifs_inode->time_last_write = 0; | |
| 443 | 444 | /* |
| 444 | 445 | * Until the file is open and we have gotten oplock info back from the |
| 445 | 446 | * server, can not assume caching of file data or metadata. |
| @@ -1566,6 +1566,7 @@ struct cifsInodeInfo { · 1565 unmodified lines | ||
| 1566 | 1566 | spinlock_t writers_lock; |
| 1567 | 1567 | unsigned int writers; /* Number of writers on this inode */ |
| 1568 | 1568 | unsigned long time; /* jiffies of last update of inode */ |
| 1569 | + unsigned long time_last_write; /* jiffies of last writable close or truncate */ | |
| 1569 | 1570 | u64 uniqueid; /* server inode number */ |
| 1570 | 1571 | u64 createtime; /* creation time on server */ |
| 1571 | 1572 | __u8 lease_key[SMB2_LEASE_KEY_SIZE]; /* lease key for this inode */ |
| @@ -1423,11 +1423,21 @@ void smb2_deferred_work_close(struct work_struct *work) · 1422 unmodified lines | ||
| 1423 | 1423 | { |
| 1424 | 1424 | struct cifsFileInfo *cfile = container_of(work, |
| 1425 | 1425 | struct cifsFileInfo, deferred.work); |
| 1426 | + struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry)); | |
| 1426 | 1427 | |
| 1427 | − spin_lock(&CIFS_I(d_inode(cfile->dentry))->deferred_lock); | |
| 1428 | + spin_lock(&cinode->deferred_lock); | |
| 1428 | 1429 | cifs_del_deferred_close(cfile); |
| 1429 | 1430 | cfile->deferred_close_scheduled = false; |
| 1430 | − spin_unlock(&CIFS_I(d_inode(cfile->dentry))->deferred_lock); | |
| 1431 | + spin_unlock(&cinode->deferred_lock); | |
| 1432 | + /* | |
| 1433 | + * Refresh time_last_write immediately before the actual server close | |
| 1434 | + * so the protection window is anchored to the real close time, not | |
| 1435 | + * the earlier userspace close time stored by cifs_close(). | |
| 1436 | + */ | |
| 1437 | + if (OPEN_FMODE(cfile->f_flags) & FMODE_WRITE) { | |
| 1438 | + /* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ | |
| 1439 | + smp_store_release(&cinode->time_last_write, jiffies); | |
| 1440 | + } | |
| 1431 | 1441 | _cifsFileInfo_put(cfile, true, false); |
| 1432 | 1442 | } |
| 1433 | 1443 | |
| @@ -1457,6 +1467,10 @@ int cifs_close(struct inode *inode, struct file *file) · 23 unmodified lines | ||
| 1457 | 1467 | if (file->private_data != NULL) { |
| 1458 | 1468 | cfile = file->private_data; |
| 1459 | 1469 | file->private_data = NULL; |
| 1470 | + if (file->f_mode & FMODE_WRITE) { | |
| 1471 | + /* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ | |
| 1472 | + smp_store_release(&cinode->time_last_write, jiffies); | |
| 1473 | + } | |
| 1460 | 1474 | dclose = kmalloc_obj(struct cifs_deferred_close); |
| 1461 | 1475 | if ((cfile->status_file_deleted == false) && |
| 1462 | 1476 | (smb2_can_defer_close(inode, dclose))) { |
| @@ -3225,13 +3239,26 @@ static int is_inode_writable(struct cifsInodeInfo *cifs_inode) · 1762 unmodified lines | ||
| 3225 | 3239 | bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file, |
| 3226 | 3240 | bool from_readdir) |
| 3227 | 3241 | { |
| 3242 | + struct cifs_sb_info *cifs_sb; | |
| 3243 | + unsigned long tlw; | |
| 3244 | + | |
| 3228 | 3245 | if (!cifsInode) |
| 3229 | 3246 | return true; |
| 3230 | 3247 | |
| 3248 | + cifs_sb = CIFS_SB(cifsInode); | |
| 3249 | + | |
| 3231 | 3250 | if (is_inode_writable(cifsInode) || |
| 3232 | 3251 | ((cifsInode->oplock & CIFS_CACHE_RW_FLG) != 0 && from_readdir)) { |
| 3233 | 3252 | /* This inode is open for write at least once */ |
| 3234 | − struct cifs_sb_info *cifs_sb = CIFS_SB(cifsInode); | |
| 3253 | + | |
| 3254 | + /* | |
| 3255 | + * Readdir data is unreliable when we have writable handles or | |
| 3256 | + * an exclusive lease -- never allow it to change i_size, even | |
| 3257 | + * on direct-IO mounts where the server's directory metadata | |
| 3258 | + * can still lag behind the actual file state. | |
| 3259 | + */ | |
| 3260 | + if (from_readdir) | |
| 3261 | + return false; | |
| 3235 | 3262 | |
| 3236 | 3263 | if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_DIRECT_IO) { |
| 3237 | 3264 | /* since no page cache to corrupt on directio |
| @@ -3243,8 +3270,40 @@ bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file, · 5 unmodified lines | ||
| 3243 | 3270 | return true; |
| 3244 | 3271 | |
| 3245 | 3272 | return false; |
| 3246 | − } else | |
| 3247 | − return true; | |
| 3273 | + } | |
| 3274 | + | |
| 3275 | + /* | |
| 3276 | + * No writable handles open. Check whether we are within the attribute | |
| 3277 | + * cache validity window of a recent local modification. | |
| 3278 | + * | |
| 3279 | + * For the close() path: cifs_close() calls smp_store_release() on | |
| 3280 | + * time_last_write before _cifsFileInfo_put() removes the handle under | |
| 3281 | + * open_file_lock. That spin_unlock() is a store-release that pairs | |
| 3282 | + * with the spin_lock() (load-acquire) in is_inode_writable() above, | |
| 3283 | + * so if is_inode_writable() returned false the smp_load_acquire() | |
| 3284 | + * below is guaranteed to observe any time_last_write update from a | |
| 3285 | + * concurrent close(). | |
| 3286 | + * | |
| 3287 | + * For the setattr/truncate paths: those callers use smp_store_release() | |
| 3288 | + * directly; the smp_load_acquire() below pairs with that store. There | |
| 3289 | + * is no shared lock between setattr and readdir, so this relies on | |
| 3290 | + * acquire-release semantics alone. The store propagation latency on | |
| 3291 | + * weakly-ordered architectures (nanoseconds) is negligible relative to | |
| 3292 | + * the acregmax window (seconds) and the readdir RPC round-trip | |
| 3293 | + * (milliseconds), making this a sound design choice in practice. | |
| 3294 | + * | |
| 3295 | + * time_last_write == 0 means the inode has never been written locally; | |
| 3296 | + * skip the window check to avoid false positives near boot time when | |
| 3297 | + * jiffies is still close to INITIAL_JIFFIES on 32-bit systems. | |
| 3298 | + */ | |
| 3299 | + if (from_readdir) { | |
| 3300 | + /* Pairs with smp_store_release() at close and truncate sites. */ | |
| 3301 | + tlw = smp_load_acquire(&cifsInode->time_last_write); | |
| 3302 | + if (tlw && time_before(jiffies, tlw + cifs_sb->ctx->acregmax)) | |
| 3303 | + return false; | |
| 3304 | + } | |
| 3305 | + | |
| 3306 | + return true; | |
| 3248 | 3307 | } |
| 3249 | 3308 | |
| 3250 | 3309 | void cifs_oplock_break(struct work_struct *work) |
| @@ -237,6 +237,8 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr, · 236 unmodified lines | ||
| 237 | 237 | if (is_size_safe_to_change(cifs_i, fattr->cf_eof, from_readdir)) { |
| 238 | 238 | i_size_write(inode, fattr->cf_eof); |
| 239 | 239 | inode->i_blocks = CIFS_INO_BLOCKS(fattr->cf_bytes); |
| 240 | + } else if (from_readdir && i_size_read(inode) != fattr->cf_eof) { | |
| 241 | + cifs_i->time = 0; | |
| 240 | 242 | } |
| 241 | 243 | |
| 242 | 244 | if (S_ISLNK(fattr->cf_mode) && fattr->cf_symlink_target) { |
| @@ -3277,6 +3279,8 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs) · 3034 unmodified lines | ||
| 3277 | 3279 | |
| 3278 | 3280 | if ((attrs->ia_valid & ATTR_SIZE) && |
| 3279 | 3281 | attrs->ia_size != i_size_read(inode)) { |
| 3282 | + /* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ | |
| 3283 | + smp_store_release(&cifsInode->time_last_write, jiffies); | |
| 3280 | 3284 | truncate_setsize(inode, attrs->ia_size); |
| 3281 | 3285 | netfs_resize_file(&cifsInode->netfs, attrs->ia_size, true); |
| 3282 | 3286 | fscache_resize_cookie(cifs_inode_cookie(inode), attrs->ia_size); |
| @@ -3478,6 +3482,8 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) · 195 unmodified lines | ||
| 3478 | 3482 | |
| 3479 | 3483 | if ((attrs->ia_valid & ATTR_SIZE) && |
| 3480 | 3484 | attrs->ia_size != i_size_read(inode)) { |
| 3485 | + /* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ | |
| 3486 | + smp_store_release(&cifsInode->time_last_write, jiffies); | |
| 3481 | 3487 | truncate_setsize(inode, attrs->ia_size); |
| 3482 | 3488 | netfs_resize_file(&cifsInode->netfs, attrs->ia_size, true); |
| 3483 | 3489 | fscache_resize_cookie(cifs_inode_cookie(inode), attrs->ia_size); |
| @@ -497,7 +497,7 @@ cifs_del_deferred_close(struct cifsFileInfo *cfile) · 496 unmodified lines | ||
| 497 | 497 | void |
| 498 | 498 | cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode) |
| 499 | 499 | { |
| 500 | − struct cifsFileInfo *cfile = NULL; | |
| 500 | + struct cifsFileInfo *cfile = NULL, *failed_cfile = NULL; | |
| 501 | 501 | struct file_list *tmp_list, *tmp_next_list; |
| 502 | 502 | LIST_HEAD(file_head); |
| 503 | 503 | |
| @@ -514,8 +514,10 @@ cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode) · 10 unmodified lines | ||
| 514 | 514 | |
| 515 | 515 | tmp_list = kmalloc_obj(struct file_list, |
| 516 | 516 | GFP_ATOMIC); |
| 517 | − if (tmp_list == NULL) | |
| 517 | + if (tmp_list == NULL) { | |
| 518 | + failed_cfile = cfile; | |
| 518 | 519 | break; |
| 520 | + } | |
| 519 | 521 | tmp_list->cfile = cfile; |
| 520 | 522 | list_add_tail(&tmp_list->list, &file_head); |
| 521 | 523 | } |
| @@ -523,8 +525,24 @@ cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode) · 1 unmodified line | ||
| 523 | 525 | } |
| 524 | 526 | spin_unlock(&cifs_inode->open_file_lock); |
| 525 | 527 | |
| 528 | + if (failed_cfile) { | |
| 529 | + if (OPEN_FMODE(failed_cfile->f_flags) & FMODE_WRITE) { | |
| 530 | + /* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ | |
| 531 | + smp_store_release(&CIFS_I(d_inode(failed_cfile->dentry))->time_last_write, | |
| 532 | + jiffies); | |
| 533 | + } | |
| 534 | + _cifsFileInfo_put(failed_cfile, false, false); | |
| 535 | + } | |
| 536 | + | |
| 526 | 537 | list_for_each_entry_safe(tmp_list, tmp_next_list, &file_head, list) { |
| 527 | − _cifsFileInfo_put(tmp_list->cfile, false, false); | |
| 538 | + struct cifsFileInfo *cfile = tmp_list->cfile; | |
| 539 | + | |
| 540 | + if (OPEN_FMODE(cfile->f_flags) & FMODE_WRITE) { | |
| 541 | + /* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ | |
| 542 | + smp_store_release(&CIFS_I(d_inode(cfile->dentry))->time_last_write, | |
| 543 | + jiffies); | |
| 544 | + } | |
| 545 | + _cifsFileInfo_put(cfile, false, false); | |
| 528 | 546 | list_del(&tmp_list->list); |
| 529 | 547 | kfree(tmp_list); |
| 530 | 548 | } |
| @@ -533,7 +551,7 @@ cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode) · 2 unmodified lines | ||
| 533 | 551 | void |
| 534 | 552 | cifs_close_all_deferred_files(struct cifs_tcon *tcon) |
| 535 | 553 | { |
| 536 | − struct cifsFileInfo *cfile; | |
| 554 | + struct cifsFileInfo *cfile, *failed_cfile = NULL; | |
| 537 | 555 | struct file_list *tmp_list, *tmp_next_list; |
| 538 | 556 | LIST_HEAD(file_head); |
| 539 | 557 | |
| @@ -547,8 +565,10 @@ cifs_close_all_deferred_files(struct cifs_tcon *tcon) · 7 unmodified lines | ||
| 547 | 565 | |
| 548 | 566 | tmp_list = kmalloc_obj(struct file_list, |
| 549 | 567 | GFP_ATOMIC); |
| 550 | − if (tmp_list == NULL) | |
| 568 | + if (tmp_list == NULL) { | |
| 569 | + failed_cfile = cfile; | |
| 551 | 570 | break; |
| 571 | + } | |
| 552 | 572 | tmp_list->cfile = cfile; |
| 553 | 573 | list_add_tail(&tmp_list->list, &file_head); |
| 554 | 574 | } |
| @@ -556,8 +576,24 @@ cifs_close_all_deferred_files(struct cifs_tcon *tcon) · 1 unmodified line | ||
| 556 | 576 | } |
| 557 | 577 | spin_unlock(&tcon->open_file_lock); |
| 558 | 578 | |
| 579 | + if (failed_cfile) { | |
| 580 | + if (OPEN_FMODE(failed_cfile->f_flags) & FMODE_WRITE) { | |
| 581 | + /* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ | |
| 582 | + smp_store_release(&CIFS_I(d_inode(failed_cfile->dentry))->time_last_write, | |
| 583 | + jiffies); | |
| 584 | + } | |
| 585 | + _cifsFileInfo_put(failed_cfile, true, false); | |
| 586 | + } | |
| 587 | + | |
| 559 | 588 | list_for_each_entry_safe(tmp_list, tmp_next_list, &file_head, list) { |
| 560 | − _cifsFileInfo_put(tmp_list->cfile, true, false); | |
| 589 | + struct cifsFileInfo *cfile = tmp_list->cfile; | |
| 590 | + | |
| 591 | + if (OPEN_FMODE(cfile->f_flags) & FMODE_WRITE) { | |
| 592 | + /* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ | |
| 593 | + smp_store_release(&CIFS_I(d_inode(cfile->dentry))->time_last_write, | |
| 594 | + jiffies); | |
| 595 | + } | |
| 596 | + _cifsFileInfo_put(cfile, true, false); | |
| 561 | 597 | list_del(&tmp_list->list); |
| 562 | 598 | kfree(tmp_list); |
| 563 | 599 | } |
| @@ -604,7 +640,7 @@ void cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon, · 40 unmodified lines | ||
| 604 | 640 | struct dentry *dentry) |
| 605 | 641 | { |
| 606 | 642 | struct file_list *tmp_list, *tmp_next_list; |
| 607 | − struct cifsFileInfo *cfile; | |
| 643 | + struct cifsFileInfo *cfile, *failed_cfile = NULL; | |
| 608 | 644 | LIST_HEAD(file_head); |
| 609 | 645 | |
| 610 | 646 | spin_lock(&tcon->open_file_lock); |
| @@ -617,16 +653,34 @@ void cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon, · 6 unmodified lines | ||
| 617 | 653 | spin_unlock(&CIFS_I(d_inode(cfile->dentry))->deferred_lock); |
| 618 | 654 | |
| 619 | 655 | tmp_list = kmalloc_obj(struct file_list, GFP_ATOMIC); |
| 620 | − if (tmp_list == NULL) | |
| 656 | + if (tmp_list == NULL) { | |
| 657 | + failed_cfile = cfile; | |
| 621 | 658 | break; |
| 659 | + } | |
| 622 | 660 | tmp_list->cfile = cfile; |
| 623 | 661 | list_add_tail(&tmp_list->list, &file_head); |
| 624 | 662 | } |
| 625 | 663 | } |
| 626 | 664 | spin_unlock(&tcon->open_file_lock); |
| 627 | 665 | |
| 666 | + if (failed_cfile) { | |
| 667 | + if (OPEN_FMODE(failed_cfile->f_flags) & FMODE_WRITE) { | |
| 668 | + /* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ | |
| 669 | + smp_store_release(&CIFS_I(d_inode(failed_cfile->dentry))->time_last_write, | |
| 670 | + jiffies); | |
| 671 | + } | |
| 672 | + _cifsFileInfo_put(failed_cfile, true, false); | |
| 673 | + } | |
| 674 | + | |
| 628 | 675 | list_for_each_entry_safe(tmp_list, tmp_next_list, &file_head, list) { |
| 629 | − _cifsFileInfo_put(tmp_list->cfile, true, false); | |
| 676 | + struct cifsFileInfo *cfile = tmp_list->cfile; | |
| 677 | + | |
| 678 | + if (OPEN_FMODE(cfile->f_flags) & FMODE_WRITE) { | |
| 679 | + /* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ | |
| 680 | + smp_store_release(&CIFS_I(d_inode(cfile->dentry))->time_last_write, | |
| 681 | + jiffies); | |
| 682 | + } | |
| 683 | + _cifsFileInfo_put(cfile, true, false); | |
| 630 | 684 | list_del(&tmp_list->list); |
| 631 | 685 | kfree(tmp_list); |
| 632 | 686 | } |
| @@ -682,6 +736,8 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size, · 49 unmodified lines | ||
| 682 | 736 | int i, rc = 0; |
| 683 | 737 | char *data_end; |
| 684 | 738 | struct dfs_referral_level_3 *ref; |
| 739 | + unsigned int path_consumed; | |
| 740 | + size_t search_name_len; | |
| 685 | 741 | |
| 686 | 742 | if (rsp_size < sizeof(*rsp)) { |
| 687 | 743 | cifs_dbg(VFS | ONCE, |
| @@ -728,6 +784,7 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size, · 40 unmodified lines | ||
| 728 | 784 | rc = -ENOMEM; |
| 729 | 785 | goto parse_DFS_referrals_exit; |
| 730 | 786 | } |
| 787 | + search_name_len = strlen(searchName); | |
| 731 | 788 | |
| 732 | 789 | /* collect necessary data from referrals */ |
| 733 | 790 | for (i = 0; i < *num_of_nodes; i++) { |
| @@ -736,21 +793,34 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size, · 2 unmodified lines | ||
| 736 | 793 | struct dfs_info3_param *node = (*target_nodes)+i; |
| 737 | 794 | |
| 738 | 795 | node->flags = le32_to_cpu(rsp->DFSFlags); |
| 796 | + path_consumed = le16_to_cpu(rsp->PathConsumed); | |
| 739 | 797 | if (is_unicode) { |
| 740 | − __le16 *tmp = kmalloc(strlen(searchName)*2 + 2, | |
| 741 | − GFP_KERNEL); | |
| 742 | − if (tmp == NULL) { | |
| 798 | + size_t search_name_utf16_len = search_name_len * 2 + 2; | |
| 799 | + __le16 *tmp; | |
| 800 | + | |
| 801 | + if (path_consumed > search_name_utf16_len) { | |
| 802 | + rc = -EINVAL; | |
| 803 | + goto parse_DFS_referrals_exit; | |
| 804 | + } | |
| 805 | + | |
| 806 | + tmp = kmalloc(search_name_utf16_len, GFP_KERNEL); | |
| 807 | + if (!tmp) { | |
| 743 | 808 | rc = -ENOMEM; |
| 744 | 809 | goto parse_DFS_referrals_exit; |
| 745 | 810 | } |
| 746 | − cifsConvertToUTF16((__le16 *) tmp, searchName, | |
| 811 | + cifsConvertToUTF16((__le16 *)tmp, searchName, | |
| 747 | 812 | PATH_MAX, nls_codepage, remap); |
| 748 | − node->path_consumed = cifs_utf16_bytes(tmp, | |
| 749 | − le16_to_cpu(rsp->PathConsumed), | |
| 750 | − nls_codepage); | |
| 813 | + node->path_consumed = cifs_utf16_bytes(tmp, path_consumed, | |
| 814 | + nls_codepage); | |
| 751 | 815 | kfree(tmp); |
| 752 | − } else | |
| 753 | − node->path_consumed = le16_to_cpu(rsp->PathConsumed); | |
| 816 | + } else { | |
| 817 | + if (path_consumed > search_name_len) { | |
| 818 | + rc = -EINVAL; | |
| 819 | + goto parse_DFS_referrals_exit; | |
| 820 | + } | |
| 821 | + | |
| 822 | + node->path_consumed = path_consumed; | |
| 823 | + } | |
| 754 | 824 | |
| 755 | 825 | node->server_type = le16_to_cpu(ref->ServerType); |
| 756 | 826 | node->ref_flag = le16_to_cpu(ref->ReferralEntryFlags); |
| @@ -952,7 +952,7 @@ static bool cifs_dir_emit(struct dir_context *ctx, · 951 unmodified lines | ||
| 952 | 952 | static int cifs_filldir(char *find_entry, struct file *file, |
| 953 | 953 | struct dir_context *ctx, |
| 954 | 954 | char *scratch_buf, unsigned int max_len, |
| 955 | − struct cached_fid *cfid) | |
| 955 | + char *end_of_smb, struct cached_fid *cfid) | |
| 956 | 956 | { |
| 957 | 957 | struct cifsFileInfo *file_info = file->private_data; |
| 958 | 958 | struct super_block *sb = file_inode(file)->i_sb; |
| @@ -974,6 +974,11 @@ static int cifs_filldir(char *find_entry, struct file *file, · 15 unmodified lines | ||
| 974 | 974 | return -EINVAL; |
| 975 | 975 | } |
| 976 | 976 | |
| 977 | + if (de.name + de.namelen > end_of_smb) { | |
| 978 | + cifs_dbg(VFS, "search entry name extends past end of SMB\n"); | |
| 979 | + return -EINVAL; | |
| 980 | + } | |
| 981 | + | |
| 977 | 982 | /* skip . and .. since we added them first */ |
| 978 | 983 | if (cifs_entry_is_dot(&de, file_info->srch_inf.unicode)) |
| 979 | 984 | return 0; |
| @@ -1194,7 +1199,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx) · 214 unmodified lines | ||
| 1194 | 1199 | */ |
| 1195 | 1200 | *tmp_buf = 0; |
| 1196 | 1201 | rc = cifs_filldir(current_entry, file, ctx, |
| 1197 | − tmp_buf, max_len, cfid); | |
| 1202 | + tmp_buf, max_len, end_of_smb, cfid); | |
| 1198 | 1203 | if (rc) { |
| 1199 | 1204 | if (rc > 0) |
| 1200 | 1205 | rc = 0; |
| @@ -30,6 +30,19 @@ static struct smb2_symlink_err_rsp *symlink_data(const struct kvec *iov) · 29 unmodified lines | ||
| 30 | 30 | u8 *end = (u8 *)err + iov->iov_len; |
| 31 | 31 | u32 len; |
| 32 | 32 | |
| 33 | + /* | |
| 34 | + * Per [MS-SMB2] section 2.2.2, a STATUS_STOPPED_ON_SYMLINK response has to | |
| 35 | + * carry a Symbolic Link Error Response, so ByteCount cannot be zero. Some | |
| 36 | + * servers (e.g. the macOS built-in SMB server) violate this and return an | |
| 37 | + * empty error response, with both ErrorContextCount and ByteCount set to | |
| 38 | + * zero, i.e. without the symlink target. Detect this and return -ENODATA | |
| 39 | + * so that callers can tell "server did not send the target" apart from a | |
| 40 | + * malformed response, and retrieve the target with FSCTL_GET_REPARSE_POINT | |
| 41 | + * instead. | |
| 42 | + */ | |
| 43 | + if (!err->ErrorContextCount && !le32_to_cpu(err->ByteCount)) | |
| 44 | + return ERR_PTR(-ENODATA); | |
| 45 | + | |
| 33 | 46 | if (err->ErrorContextCount) { |
| 34 | 47 | struct smb2_error_context_rsp *p; |
| 35 | 48 | |
| @@ -199,6 +212,14 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, · 163 unmodified lines | ||
| 199 | 212 | rc = smb2_parse_symlink_response(oparms->cifs_sb, &err_iov, |
| 200 | 213 | oparms->path, |
| 201 | 214 | &data->symlink_target); |
| 215 | + /* | |
| 216 | + * If smb2_parse_symlink_response returned -ENODATA then the | |
| 217 | + * symlink_target was not sent. Treat this as if the SMB2_open() | |
| 218 | + * failed with STATUS_IO_REPARSE_TAG_NOT_HANDLED status, which is | |
| 219 | + * indicated by the -EIO errno. | |
| 220 | + */ | |
| 221 | + if (rc == -ENODATA) | |
| 222 | + rc = -EIO; | |
| 202 | 223 | if (!rc) { |
| 203 | 224 | memset(&data->fi, 0, sizeof(data->fi)); |
| 204 | 225 | oparms->create_options |= OPEN_REPARSE_POINT; |
| @@ -792,9 +792,19 @@ static int parse_create_response(struct cifs_open_info_data *data, · 791 unmodified lines | ||
| 792 | 792 | rc = smb2_parse_symlink_response(cifs_sb, iov, |
| 793 | 793 | full_path, |
| 794 | 794 | &data->symlink_target); |
| 795 | − if (rc) | |
| 795 | + if (rc != 0 && rc != -ENODATA) | |
| 796 | 796 | return rc; |
| 797 | − tag = IO_REPARSE_TAG_SYMLINK; | |
| 797 | + /* | |
| 798 | + * -ENODATA means that the response was parsed but did not contain | |
| 799 | + * the symlink target at all (see symlink_data()). Treat it like | |
| 800 | + * STATUS_IO_REPARSE_TAG_NOT_HANDLED, which does not contain it | |
| 801 | + * either: leave the tag unset and clear rc, so that the caller | |
| 802 | + * retrieves the target with SMB2_OP_GET_REPARSE. | |
| 803 | + */ | |
| 804 | + if (rc == -ENODATA) | |
| 805 | + rc = 0; | |
| 806 | + else | |
| 807 | + tag = IO_REPARSE_TAG_SYMLINK; | |
| 798 | 808 | reparse_point = true; |
| 799 | 809 | break; |
| 800 | 810 | case STATUS_SUCCESS: |
| @@ -987,7 +997,14 @@ int smb2_query_path_info(const unsigned int xid, · 186 unmodified lines | ||
| 987 | 997 | rc = -EOPNOTSUPP; |
| 988 | 998 | } |
| 989 | 999 | |
| 990 | − if (data->reparse.tag == IO_REPARSE_TAG_SYMLINK && !rc) { | |
| 1000 | + /* | |
| 1001 | + * If the symlink was already parsed in create response then it is needed to fix | |
| 1002 | + * its type now (after the second call with OPEN_REPARSE_POINT which filled the | |
| 1003 | + * data->fi.Attributes). If the symlink was not parsed in create response then | |
| 1004 | + * the data->symlink_target was not filled yet and then the type will be fixed | |
| 1005 | + * later after data->symlink_target is filled. | |
| 1006 | + */ | |
| 1007 | + if (data->reparse.tag == IO_REPARSE_TAG_SYMLINK && !rc && data->symlink_target) { | |
| 991 | 1008 | bool directory = le32_to_cpu(data->fi.Attributes) & ATTR_DIRECTORY; |
| 992 | 1009 | rc = smb2_fix_symlink_target_type(&data->symlink_target, directory, cifs_sb); |
| 993 | 1010 | } |
| @@ -56,7 +56,8 @@ int ksmbd_decompress_request(struct ksmbd_conn *conn) · 55 unmodified lines | ||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | max_allowed_pdu_size = SMB3_MAX_MSGSIZE + conn->vals->max_write_size; |
| 59 | − if (out_size > max_allowed_pdu_size || | |
| 59 | + if (out_size < sizeof(struct smb2_pdu) || | |
| 60 | + out_size > max_allowed_pdu_size || | |
| 60 | 61 | out_size > MAX_STREAM_PROT_LEN) |
| 61 | 62 | return -EINVAL; |
| 62 | 63 | |
| @@ -441,6 +441,8 @@ bool ksmbd_conn_alive(struct ksmbd_conn *conn) · 440 unmodified lines | ||
| 441 | 441 | /* "+2" for BCC field (ByteCount, 2 bytes) */ |
| 442 | 442 | #define SMB1_MIN_SUPPORTED_PDU_SIZE (sizeof(struct smb_hdr) + 2) |
| 443 | 443 | #define SMB2_MIN_SUPPORTED_PDU_SIZE (sizeof(struct smb2_pdu)) |
| 444 | +#define SMB2_TRANSFORM_MIN_SUPPORTED_PDU_SIZE \ | |
| 445 | + (sizeof(struct smb2_transform_hdr) + sizeof(struct smb2_hdr)) | |
| 444 | 446 | |
| 445 | 447 | /** |
| 446 | 448 | * ksmbd_conn_handler_loop() - session thread to listen on new smb requests |
| @@ -455,6 +457,7 @@ int ksmbd_conn_handler_loop(void *p) · 8 unmodified lines | ||
| 455 | 457 | struct ksmbd_conn *conn = (struct ksmbd_conn *)p; |
| 456 | 458 | struct ksmbd_transport *t = conn->transport; |
| 457 | 459 | unsigned int pdu_size, max_allowed_pdu_size, max_req; |
| 460 | + __le32 proto; | |
| 458 | 461 | char hdr_buf[4] = {0,}; |
| 459 | 462 | int size; |
| 460 | 463 | |
| @@ -546,11 +549,14 @@ recheck: · 85 unmodified lines | ||
| 546 | 549 | if (!ksmbd_smb_request(conn)) |
| 547 | 550 | break; |
| 548 | 551 | |
| 549 | − if (((struct smb2_hdr *)smb_get_msg(conn->request_buf))->ProtocolId == | |
| 550 | − SMB2_PROTO_NUMBER) { | |
| 551 | − if (pdu_size < SMB2_MIN_SUPPORTED_PDU_SIZE) | |
| 552 | − break; | |
| 553 | − } | |
| 552 | + proto = *(__le32 *)smb_get_msg(conn->request_buf); | |
| 553 | + if (proto == SMB2_PROTO_NUMBER && | |
| 554 | + pdu_size < SMB2_MIN_SUPPORTED_PDU_SIZE) | |
| 555 | + break; | |
| 556 | + | |
| 557 | + if (proto == SMB2_TRANSFORM_PROTO_NUM && | |
| 558 | + pdu_size < SMB2_TRANSFORM_MIN_SUPPORTED_PDU_SIZE) | |
| 559 | + break; | |
| 554 | 560 | |
| 555 | 561 | if (!default_conn_ops.process_fn) { |
| 556 | 562 | pr_err("No connection request callback\n"); |
| @@ -112,6 +112,7 @@ static int __process_request(struct ksmbd_work *work, struct ksmbd_conn *conn, · 111 unmodified lines | ||
| 112 | 112 | { |
| 113 | 113 | struct smb_version_cmds *cmds; |
| 114 | 114 | u16 command; |
| 115 | + bool signed_req; | |
| 115 | 116 | int ret; |
| 116 | 117 | |
| 117 | 118 | if (check_conn_state(work)) |
| @@ -138,7 +139,14 @@ andx_again: · 20 unmodified lines | ||
| 138 | 139 | return SERVER_HANDLER_ABORT; |
| 139 | 140 | } |
| 140 | 141 | |
| 141 | − if (work->sess && conn->ops->is_sign_req(work, command)) { | |
| 142 | + signed_req = conn->ops->is_sign_req && conn->ops->is_sign_req(work, command); | |
| 143 | + if (work->sess && work->sess->sign && !work->encrypted && | |
| 144 | + !signed_req) { | |
| 145 | + conn->ops->set_rsp_status(work, STATUS_ACCESS_DENIED); | |
| 146 | + return SERVER_HANDLER_ABORT; | |
| 147 | + } | |
| 148 | + | |
| 149 | + if (work->sess && signed_req) { | |
| 142 | 150 | ret = conn->ops->check_sign_req(work); |
| 143 | 151 | if (!ret) { |
| 144 | 152 | conn->ops->set_rsp_status(work, STATUS_ACCESS_DENIED); |
| @@ -1717,11 +1717,6 @@ static int ntlm_authenticate(struct ksmbd_work *work, · 1716 unmodified lines | ||
| 1717 | 1717 | return -EPERM; |
| 1718 | 1718 | } |
| 1719 | 1719 | |
| 1720 | − /* Check for previous session */ | |
| 1721 | − prev_id = le64_to_cpu(req->PreviousSessionId); | |
| 1722 | − if (prev_id && prev_id != sess->id) | |
| 1723 | − destroy_previous_session(conn, user, prev_id); | |
| 1724 | − | |
| 1725 | 1720 | if (sess->state == SMB2_SESSION_VALID) { |
| 1726 | 1721 | /* |
| 1727 | 1722 | * Reuse session if anonymous try to connect |
| @@ -1761,6 +1756,10 @@ static int ntlm_authenticate(struct ksmbd_work *work, · 33 unmodified lines | ||
| 1761 | 1756 | } |
| 1762 | 1757 | } |
| 1763 | 1758 | |
| 1759 | + prev_id = le64_to_cpu(req->PreviousSessionId); | |
| 1760 | + if (prev_id && prev_id != sess->id) | |
| 1761 | + destroy_previous_session(conn, sess->user, prev_id); | |
| 1762 | + | |
| 1764 | 1763 | /* |
| 1765 | 1764 | * If session state is SMB2_SESSION_VALID, We can assume |
| 1766 | 1765 | * that it is reauthentication. And the user/password |
| @@ -9596,8 +9595,7 @@ bool smb2_is_sign_req(struct ksmbd_work *work, unsigned int command) · 7829 unmodified lines | ||
| 9596 | 9595 | struct smb2_hdr *rcv_hdr2 = smb_get_msg(work->request_buf); |
| 9597 | 9596 | |
| 9598 | 9597 | if ((rcv_hdr2->Flags & SMB2_FLAGS_SIGNED) && |
| 9599 | − command != SMB2_NEGOTIATE_HE && | |
| 9600 | − command != SMB2_OPLOCK_BREAK_HE) | |
| 9598 | + command != SMB2_NEGOTIATE_HE) | |
| 9601 | 9599 | return true; |
| 9602 | 9600 | |
| 9603 | 9601 | return false; |
| @@ -608,7 +608,8 @@ static void parse_dacl(struct mnt_idmap *idmap, · 607 unmodified lines | ||
| 608 | 608 | static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap, |
| 609 | 609 | struct smb_ace *pndace, |
| 610 | 610 | struct smb_fattr *fattr, u16 *num_aces, |
| 611 | − u16 *size, u32 nt_aces_num) | |
| 611 | + u16 *size, u16 existing_nt_aces, | |
| 612 | + bool had_nt_aces) | |
| 612 | 613 | { |
| 613 | 614 | struct posix_acl_entry *pace; |
| 614 | 615 | struct smb_sid *sid; |
| @@ -640,14 +641,14 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap, · 25 unmodified lines | ||
| 640 | 641 | |
| 641 | 642 | gid = posix_acl_gid_translate(idmap, pace); |
| 642 | 643 | id_to_sid(gid, SIDUNIX_GROUP, sid); |
| 643 | − } else if (pace->e_tag == ACL_OTHER && !nt_aces_num) { | |
| 644 | + } else if (pace->e_tag == ACL_OTHER && !had_nt_aces) { | |
| 644 | 645 | smb_copy_sid(sid, &sid_everyone); |
| 645 | 646 | } else { |
| 646 | 647 | kfree(sid); |
| 647 | 648 | continue; |
| 648 | 649 | } |
| 649 | 650 | ntace = pndace; |
| 650 | − for (j = 0; j < nt_aces_num; j++) { | |
| 651 | + for (j = 0; j < existing_nt_aces; j++) { | |
| 651 | 652 | if (ntace->sid.sub_auth[ntace->sid.num_subauth - 1] == |
| 652 | 653 | sid->sub_auth[sid->num_subauth - 1]) |
| 653 | 654 | goto pass_same_sid; |
| @@ -662,6 +663,7 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap, · 8 unmodified lines | ||
| 662 | 663 | ace_sz = fill_ace_for_sid(ntace, sid, ACCESS_ALLOWED, flags, |
| 663 | 664 | pace->e_perm, 0777); |
| 664 | 665 | if (check_add_overflow(*size, ace_sz, size)) { |
| 666 | + *size -= ace_sz; | |
| 665 | 667 | kfree(sid); |
| 666 | 668 | break; |
| 667 | 669 | } |
| @@ -676,6 +678,7 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap, · 8 unmodified lines | ||
| 676 | 678 | ace_sz = fill_ace_for_sid(ntace, sid, ACCESS_ALLOWED, |
| 677 | 679 | 0x03, pace->e_perm, 0777); |
| 678 | 680 | if (check_add_overflow(*size, ace_sz, size)) { |
| 681 | + *size -= ace_sz; | |
| 679 | 682 | kfree(sid); |
| 680 | 683 | break; |
| 681 | 684 | } |
| @@ -689,7 +692,7 @@ pass_same_sid: · 7 unmodified lines | ||
| 689 | 692 | kfree(sid); |
| 690 | 693 | } |
| 691 | 694 | |
| 692 | − if (nt_aces_num) | |
| 695 | + if (had_nt_aces) | |
| 693 | 696 | return; |
| 694 | 697 | |
| 695 | 698 | posix_default_acl: |
| @@ -721,6 +724,7 @@ posix_default_acl: · 25 unmodified lines | ||
| 721 | 724 | ace_sz = fill_ace_for_sid(ntace, sid, ACCESS_ALLOWED, 0x0b, |
| 722 | 725 | pace->e_perm, 0777); |
| 723 | 726 | if (check_add_overflow(*size, ace_sz, size)) { |
| 727 | + *size -= ace_sz; | |
| 724 | 728 | kfree(sid); |
| 725 | 729 | break; |
| 726 | 730 | } |
| @@ -742,6 +746,7 @@ static void set_ntacl_dacl(struct mnt_idmap *idmap, · 15 unmodified lines | ||
| 742 | 746 | { |
| 743 | 747 | struct smb_ace *ntace, *pndace; |
| 744 | 748 | u16 nt_num_aces = le16_to_cpu(nt_dacl->num_aces), num_aces = 0; |
| 749 | + u16 copied_nt_aces; | |
| 745 | 750 | unsigned short size = 0; |
| 746 | 751 | int i; |
| 747 | 752 | |
| @@ -751,20 +756,29 @@ static void set_ntacl_dacl(struct mnt_idmap *idmap, · 3 unmodified lines | ||
| 751 | 756 | for (i = 0; i < nt_num_aces; i++) { |
| 752 | 757 | unsigned short nt_ace_size; |
| 753 | 758 | |
| 754 | − if (offsetof(struct smb_ace, access_req) > aces_size) | |
| 759 | + if (aces_size < offsetof(struct smb_ace, sid) + | |
| 760 | + CIFS_SID_BASE_SIZE) | |
| 755 | 761 | break; |
| 756 | 762 | |
| 757 | 763 | nt_ace_size = le16_to_cpu(ntace->size); |
| 758 | − if (nt_ace_size > aces_size) | |
| 764 | + if (nt_ace_size > aces_size || | |
| 765 | + nt_ace_size < offsetof(struct smb_ace, sid) + | |
| 766 | + CIFS_SID_BASE_SIZE) | |
| 759 | 767 | break; |
| 760 | 768 | |
| 761 | 769 | if (ntace->sid.num_subauth == 0 || |
| 762 | − ntace->sid.num_subauth > SID_MAX_SUB_AUTHORITIES) | |
| 770 | + ntace->sid.num_subauth > SID_MAX_SUB_AUTHORITIES || | |
| 771 | + nt_ace_size < offsetof(struct smb_ace, sid) + | |
| 772 | + CIFS_SID_BASE_SIZE + | |
| 773 | + sizeof(__le32) * | |
| 774 | + ntace->sid.num_subauth) | |
| 763 | 775 | goto next_ace; |
| 764 | 776 | |
| 765 | 777 | memcpy((char *)pndace + size, ntace, nt_ace_size); |
| 766 | − if (check_add_overflow(size, nt_ace_size, &size)) | |
| 778 | + if (check_add_overflow(size, nt_ace_size, &size)) { | |
| 779 | + size -= nt_ace_size; | |
| 767 | 780 | break; |
| 781 | + } | |
| 768 | 782 | num_aces++; |
| 769 | 783 | |
| 770 | 784 | next_ace: |
| @@ -773,8 +787,10 @@ next_ace: · 2 unmodified lines | ||
| 773 | 787 | } |
| 774 | 788 | } |
| 775 | 789 | |
| 790 | + copied_nt_aces = num_aces; | |
| 776 | 791 | set_posix_acl_entries_dacl(idmap, pndace, fattr, |
| 777 | − &num_aces, &size, nt_num_aces); | |
| 792 | + &num_aces, &size, copied_nt_aces, | |
| 793 | + nt_num_aces != 0); | |
| 778 | 794 | pndacl->num_aces = cpu_to_le16(num_aces); |
| 779 | 795 | pndacl->size = cpu_to_le16(le16_to_cpu(pndacl->size) + size); |
| 780 | 796 | } |
| @@ -792,7 +808,7 @@ static void set_mode_dacl(struct mnt_idmap *idmap, · 11 unmodified lines | ||
| 792 | 808 | |
| 793 | 809 | if (fattr->cf_acls) { |
| 794 | 810 | set_posix_acl_entries_dacl(idmap, pndace, fattr, |
| 795 | − &num_aces, &size, num_aces); | |
| 811 | + &num_aces, &size, num_aces, false); | |
| 796 | 812 | goto out; |
| 797 | 813 | } |
| 798 | 814 | |
| @@ -1886,10 +1886,6 @@ int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap, · 1885 unmodified lines | ||
| 1886 | 1886 | const struct path *path, struct inode *parent_inode) |
| 1887 | 1887 | { |
| 1888 | 1888 | struct posix_acl *acls; |
| 1889 | − struct posix_acl_entry *pace; | |
| 1890 | − struct dentry *dentry = path->dentry; | |
| 1891 | − struct inode *inode = d_inode(dentry); | |
| 1892 | − int rc, i; | |
| 1893 | 1889 | |
| 1894 | 1890 | if (!IS_ENABLED(CONFIG_FS_POSIX_ACL)) |
| 1895 | 1891 | return -EOPNOTSUPP; |
| @@ -1897,29 +1893,9 @@ int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap, · 1 unmodified line | ||
| 1897 | 1893 | acls = get_inode_acl(parent_inode, ACL_TYPE_DEFAULT); |
| 1898 | 1894 | if (IS_ERR_OR_NULL(acls)) |
| 1899 | 1895 | return -ENOENT; |
| 1900 | − pace = acls->a_entries; | |
| 1901 | − | |
| 1902 | − for (i = 0; i < acls->a_count; i++, pace++) { | |
| 1903 | − if (pace->e_tag == ACL_MASK) { | |
| 1904 | − pace->e_perm = 0x07; | |
| 1905 | − break; | |
| 1906 | − } | |
| 1907 | − } | |
| 1908 | − | |
| 1909 | − rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls); | |
| 1910 | − if (rc < 0) | |
| 1911 | − ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_ACCESS) failed, rc : %d\n", | |
| 1912 | − rc); | |
| 1913 | − if (S_ISDIR(inode->i_mode)) { | |
| 1914 | − rc = set_posix_acl(idmap, dentry, ACL_TYPE_DEFAULT, | |
| 1915 | − acls); | |
| 1916 | − if (rc < 0) | |
| 1917 | − ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n", | |
| 1918 | − rc); | |
| 1919 | − } | |
| 1920 | 1896 | |
| 1921 | 1897 | posix_acl_release(acls); |
| 1922 | − return rc; | |
| 1898 | + return 0; | |
| 1923 | 1899 | } |
| 1924 | 1900 | |
| 1925 | 1901 | void ksmbd_vfs_update_compressed_fattr(struct dentry *dentry, __le32 *fattr) |
| @@ -1082,18 +1082,35 @@ void emergency_remount(void) · 1081 unmodified lines | ||
| 1082 | 1082 | } |
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | +static inline bool get_active_super(struct super_block *sb) | |
| 1086 | +{ | |
| 1087 | + bool active = false; | |
| 1088 | + | |
| 1089 | + if (super_lock_excl(sb)) { | |
| 1090 | + active = atomic_inc_not_zero(&sb->s_active); | |
| 1091 | + super_unlock_excl(sb); | |
| 1092 | + } | |
| 1093 | + return active; | |
| 1094 | +} | |
| 1095 | + | |
| 1085 | 1096 | static void do_thaw_all_callback(struct super_block *sb, void *unused) |
| 1086 | 1097 | { |
| 1098 | + if (!get_active_super(sb)) | |
| 1099 | + return; | |
| 1100 | + | |
| 1101 | + /* fs_bdev_thaw() acquires s_umount so it must not be held here */ | |
| 1087 | 1102 | if (IS_ENABLED(CONFIG_BLOCK)) |
| 1088 | 1103 | while (sb->s_bdev && !bdev_thaw(sb->s_bdev)) |
| 1089 | 1104 | pr_warn("Emergency Thaw on %pg\n", sb->s_bdev); |
| 1090 | − thaw_super_locked(sb, FREEZE_HOLDER_USERSPACE, NULL); | |
| 1091 | − return; | |
| 1105 | + | |
| 1106 | + if (super_lock_excl(sb)) | |
| 1107 | + thaw_super_locked(sb, FREEZE_HOLDER_USERSPACE, NULL); | |
| 1108 | + deactivate_super(sb); | |
| 1092 | 1109 | } |
| 1093 | 1110 | |
| 1094 | 1111 | static void do_thaw_all(struct work_struct *work) |
| 1095 | 1112 | { |
| 1096 | − __iterate_supers(do_thaw_all_callback, NULL, SUPER_ITER_EXCL); | |
| 1113 | + __iterate_supers(do_thaw_all_callback, NULL, SUPER_ITER_UNLOCKED); | |
| 1097 | 1114 | kfree(work); |
| 1098 | 1115 | printk(KERN_WARNING "Emergency Thaw complete\n"); |
| 1099 | 1116 | } |
| @@ -1114,17 +1131,6 @@ void emergency_thaw_all(void) · 14 unmodified lines | ||
| 1114 | 1131 | } |
| 1115 | 1132 | } |
| 1116 | 1133 | |
| 1117 | −static inline bool get_active_super(struct super_block *sb) | |
| 1118 | −{ | |
| 1119 | − bool active = false; | |
| 1120 | − | |
| 1121 | − if (super_lock_excl(sb)) { | |
| 1122 | − active = atomic_inc_not_zero(&sb->s_active); | |
| 1123 | − super_unlock_excl(sb); | |
| 1124 | − } | |
| 1125 | − return active; | |
| 1126 | −} | |
| 1127 | − | |
| 1128 | 1134 | static const char *filesystems_freeze_ptr = "filesystems_freeze"; |
| 1129 | 1135 | |
| 1130 | 1136 | static void filesystems_freeze_callback(struct super_block *sb, void *freeze_all_ptr) |
| @@ -13,9 +13,8 @@ · 12 unmodified lines | ||
| 13 | 13 | * ttm_backup_handle_to_page_ptr() - Convert handle to struct page pointer |
| 14 | 14 | * @handle: The handle to convert. |
| 15 | 15 | * |
| 16 | − * Converts an opaque handle received from the | |
| 17 | − * ttm_backup_backup_page() function to an (invalid) | |
| 18 | − * struct page pointer suitable for a struct page array. | |
| 16 | + * Converts an opaque handle received from a ttm_backup_backup_*() | |
| 17 | + * function to an (invalid) struct page pointer suitable for a struct page array. | |
| 19 | 18 | * |
| 20 | 19 | * Return: An (invalid) struct page pointer. |
| 21 | 20 | */ |
| @@ -59,9 +58,10 @@ int ttm_backup_copy_page(struct file *backup, struct page *dst, · 37 unmodified lines | ||
| 59 | 58 | pgoff_t handle, bool intr, gfp_t additional_gfp); |
| 60 | 59 | |
| 61 | 60 | s64 |
| 62 | −ttm_backup_backup_page(struct file *backup, struct page *page, | |
| 63 | − bool writeback, pgoff_t idx, gfp_t page_gfp, | |
| 64 | − gfp_t alloc_gfp); | |
| 61 | +ttm_backup_backup_folio(struct file *backup, struct folio *folio, | |
| 62 | + unsigned int order, bool writeback, pgoff_t idx, | |
| 63 | + gfp_t folio_gfp, gfp_t alloc_gfp, | |
| 64 | + pgoff_t *nr_pages_backed); | |
| 65 | 65 | |
| 66 | 66 | void ttm_backup_fini(struct file *backup); |
| 67 | 67 | |
| @@ -134,6 +134,8 @@ static inline bool mem_alloc_profiling_enabled(void) · 133 unmodified lines | ||
| 134 | 134 | &mem_alloc_profiling_key); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | +bool mem_alloc_profiling_permanently_disabled(void); | |
| 138 | + | |
| 137 | 139 | static inline struct alloc_tag_counters alloc_tag_read(struct alloc_tag *tag) |
| 138 | 140 | { |
| 139 | 141 | struct alloc_tag_counters v = { 0, 0 }; |
| @@ -239,6 +241,7 @@ static inline bool alloc_tag_is_inaccurate(struct alloc_tag *tag) · 99 unmodified lines | ||
| 239 | 241 | |
| 240 | 242 | #define DEFINE_ALLOC_TAG(_alloc_tag) |
| 241 | 243 | static inline bool mem_alloc_profiling_enabled(void) { return false; } |
| 244 | +static inline bool mem_alloc_profiling_permanently_disabled(void) { return true; } | |
| 242 | 245 | static inline void alloc_tag_add(union codetag_ref *ref, struct alloc_tag *tag, |
| 243 | 246 | size_t bytes) {} |
| 244 | 247 | static inline void alloc_tag_sub(union codetag_ref *ref, size_t bytes) {} |
| @@ -8317,8 +8317,7 @@ struct hwrm_ring_alloc_output { · 8316 unmodified lines | ||
| 8317 | 8317 | __le16 req_type; |
| 8318 | 8318 | __le16 seq_id; |
| 8319 | 8319 | __le16 resp_len; |
| 8320 | − __le16 ring_id; | |
| 8321 | − __le16 logical_ring_id; | |
| 8320 | + __le32 ring_id; | |
| 8322 | 8321 | u8 push_buffer_index; |
| 8323 | 8322 | #define RING_ALLOC_RESP_PUSH_BUFFER_INDEX_PING_BUFFER 0x0UL |
| 8324 | 8323 | #define RING_ALLOC_RESP_PUSH_BUFFER_INDEX_PONG_BUFFER 0x1UL |
| @@ -8345,10 +8344,10 @@ struct hwrm_ring_free_input { · 20 unmodified lines | ||
| 8345 | 8344 | u8 flags; |
| 8346 | 8345 | #define RING_FREE_REQ_FLAGS_VIRTIO_RING_VALID 0x1UL |
| 8347 | 8346 | #define RING_FREE_REQ_FLAGS_LAST RING_FREE_REQ_FLAGS_VIRTIO_RING_VALID |
| 8348 | − __le16 ring_id; | |
| 8347 | + __le16 unused_1; | |
| 8349 | 8348 | __le32 prod_idx; |
| 8350 | 8349 | __le32 opaque; |
| 8351 | − __le32 unused_1; | |
| 8350 | + __le32 ring_id; | |
| 8352 | 8351 | }; |
| 8353 | 8352 | |
| 8354 | 8353 | /* hwrm_ring_free_output (size:128b/16B) */ |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | 2 | /* |
| 3 | 3 | * DAMON api |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #ifndef _DAMON_H_ |
| @@ -67,6 +67,9 @@ · 66 unmodified lines | ||
| 67 | 67 | * INTEL_SIP_SMC_STATUS_REJECTED: |
| 68 | 68 | * Secure monitor software reject the service client's request. |
| 69 | 69 | * |
| 70 | + * INTEL_SIP_SMC_STATUS_NO_RESPONSE: | |
| 71 | + * Secure monitor software has no response for the request yet. | |
| 72 | + * | |
| 70 | 73 | * INTEL_SIP_SMC_STATUS_ERROR: |
| 71 | 74 | * There is error during the process of service request. |
| 72 | 75 | * |
| @@ -77,6 +80,7 @@ · 4 unmodified lines | ||
| 77 | 80 | #define INTEL_SIP_SMC_STATUS_OK 0x0 |
| 78 | 81 | #define INTEL_SIP_SMC_STATUS_BUSY 0x1 |
| 79 | 82 | #define INTEL_SIP_SMC_STATUS_REJECTED 0x2 |
| 83 | +#define INTEL_SIP_SMC_STATUS_NO_RESPONSE 0x3 | |
| 80 | 84 | #define INTEL_SIP_SMC_STATUS_ERROR 0x4 |
| 81 | 85 | #define INTEL_SIP_SMC_RSU_ERROR 0x7 |
| 82 | 86 | |
| @@ -606,7 +610,7 @@ INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_COMPLETED_WRITE) · 523 unmodified lines | ||
| 606 | 610 | |
| 607 | 611 | /** |
| 608 | 612 | * Request INTEL_SIP_SMC_FUNCID_FCS_SEND_CERTIFICATE |
| 609 | − * Sync call to send a signed certificate | |
| 613 | + * Async call to send a signed certificate | |
| 610 | 614 | * |
| 611 | 615 | * Call register usage: |
| 612 | 616 | * a0 INTEL_SIP_SMC_FCS_SEND_CERTIFICATE |
| @@ -615,7 +619,7 @@ INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_COMPLETED_WRITE) · 2 unmodified lines | ||
| 615 | 619 | * a3-a7 not used |
| 616 | 620 | * |
| 617 | 621 | * Return status: |
| 618 | − * a0 INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_FCS_REJECTED | |
| 622 | + * a0 INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_REJECTED | |
| 619 | 623 | * a1-a3 not used |
| 620 | 624 | */ |
| 621 | 625 | #define INTEL_SIP_SMC_FUNCID_FCS_SEND_CERTIFICATE 93 |
| @@ -631,9 +635,11 @@ INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_COMPLETED_WRITE) · 9 unmodified lines | ||
| 631 | 635 | * a1-a7 not used |
| 632 | 636 | * |
| 633 | 637 | * Return status: |
| 634 | − * a0 INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_FCS_ERROR or | |
| 635 | − * INTEL_SIP_SMC_FCS_REJECTED | |
| 636 | − * a1-a3 not used | |
| 638 | + * a0 INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_STATUS_ERROR or | |
| 639 | + * INTEL_SIP_SMC_STATUS_REJECTED | |
| 640 | + * a1 mailbox error if a0 is INTEL_SIP_SMC_STATUS_ERROR | |
| 641 | + * a2 physical address for the structure of fuse and key hashes | |
| 642 | + * a3 the size of structure | |
| 637 | 643 | * |
| 638 | 644 | */ |
| 639 | 645 | #define INTEL_SIP_SMC_FUNCID_FCS_GET_PROVISION_DATA 94 |
| @@ -57,6 +57,9 @@ struct fscrypt_name { · 56 unmodified lines | ||
| 57 | 57 | /* Maximum value for the third parameter of fscrypt_operations.set_context(). */ |
| 58 | 58 | #define FSCRYPT_SET_CONTEXT_MAX_SIZE 40 |
| 59 | 59 | |
| 60 | +/* Maximum supported number of block devices per filesystem */ | |
| 61 | +#define FSCRYPT_MAX_DEVICES 8 | |
| 62 | + | |
| 60 | 63 | #ifdef CONFIG_FS_ENCRYPTION |
| 61 | 64 | |
| 62 | 65 | /* Crypto operations for filesystems */ |
| @@ -181,21 +184,20 @@ struct fscrypt_operations { · 118 unmodified lines | ||
| 181 | 184 | bool (*has_stable_inodes)(struct super_block *sb); |
| 182 | 185 | |
| 183 | 186 | /* |
| 184 | − * Return an array of pointers to the block devices to which the | |
| 185 | − * filesystem may write encrypted file contents, NULL if the filesystem | |
| 186 | − * only has a single such block device, or an ERR_PTR() on error. | |
| 187 | + * Retrieve the list of block devices to which the filesystem may write | |
| 188 | + * encrypted file contents. | |
| 187 | 189 | * |
| 188 | − * On successful non-NULL return, *num_devs is set to the number of | |
| 189 | − * devices in the returned array. The caller must free the returned | |
| 190 | − * array using kfree(). | |
| 190 | + * This writes the block_device pointers to @devs and returns the count | |
| 191 | + * (between 1 and FSCRYPT_MAX_DEVICES inclusively). | |
| 191 | 192 | * |
| 192 | 193 | * If the filesystem can use multiple block devices (other than block |
| 193 | 194 | * devices that aren't used for encrypted file contents, such as |
| 194 | 195 | * external journal devices), and wants to support inline encryption, |
| 195 | 196 | * then it must implement this function. Otherwise it's not needed. |
| 196 | 197 | */ |
| 197 | − struct block_device **(*get_devices)(struct super_block *sb, | |
| 198 | − unsigned int *num_devs); | |
| 198 | + unsigned int (*get_devices)( | |
| 199 | + struct super_block *sb, | |
| 200 | + struct block_device *devs[FSCRYPT_MAX_DEVICES]); | |
| 199 | 201 | }; |
| 200 | 202 | |
| 201 | 203 | int fscrypt_d_revalidate(struct inode *dir, const struct qstr *name, |
| @@ -520,6 +520,22 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg) · 519 unmodified lines | ||
| 520 | 520 | return (memcg == root_mem_cgroup); |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | +/** | |
| 524 | + * mem_cgroup_shrink_is_root - is this a global or root-memcg shrink invocation? | |
| 525 | + * @sc: shrink_control describing the current shrinker call | |
| 526 | + * | |
| 527 | + * Returns true when @sc represents a global reclaim shrink (sc->memcg == NULL) | |
| 528 | + * or a root-memcg shrink, i.e. not a per-memcg iteration of | |
| 529 | + * shrink_slab_memcg(). Filesystems whose ->nr_cached_objects()/ | |
| 530 | + * ->free_cached_objects() implementations operate on filesystem-global state | |
| 531 | + * and do not honour sc->memcg can use this to early-return 0 in per-memcg | |
| 532 | + * contexts. | |
| 533 | + */ | |
| 534 | +static inline bool mem_cgroup_shrink_is_root(struct shrink_control *sc) | |
| 535 | +{ | |
| 536 | + return !sc->memcg || mem_cgroup_is_root(sc->memcg); | |
| 537 | +} | |
| 538 | + | |
| 523 | 539 | static inline bool obj_cgroup_is_root(const struct obj_cgroup *objcg) |
| 524 | 540 | { |
| 525 | 541 | return objcg->is_root; |
| @@ -1071,6 +1087,11 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg) · 545 unmodified lines | ||
| 1071 | 1087 | return true; |
| 1072 | 1088 | } |
| 1073 | 1089 | |
| 1090 | +static inline bool mem_cgroup_shrink_is_root(struct shrink_control *sc) | |
| 1091 | +{ | |
| 1092 | + return true; | |
| 1093 | +} | |
| 1094 | + | |
| 1074 | 1095 | static inline bool obj_cgroup_is_root(const struct obj_cgroup *objcg) |
| 1075 | 1096 | { |
| 1076 | 1097 | return true; |
| @@ -12215,18 +12215,7 @@ struct mlx5_ifc_mcia_reg_bits { · 12214 unmodified lines | ||
| 12215 | 12215 | |
| 12216 | 12216 | u8 reserved_at_60[0x20]; |
| 12217 | 12217 | |
| 12218 | − u8 dword_0[0x20]; | |
| 12219 | − u8 dword_1[0x20]; | |
| 12220 | − u8 dword_2[0x20]; | |
| 12221 | − u8 dword_3[0x20]; | |
| 12222 | − u8 dword_4[0x20]; | |
| 12223 | − u8 dword_5[0x20]; | |
| 12224 | − u8 dword_6[0x20]; | |
| 12225 | − u8 dword_7[0x20]; | |
| 12226 | − u8 dword_8[0x20]; | |
| 12227 | − u8 dword_9[0x20]; | |
| 12228 | − u8 dword_10[0x20]; | |
| 12229 | − u8 dword_11[0x20]; | |
| 12218 | + u8 dwords[0x400]; | |
| 12230 | 12219 | }; |
| 12231 | 12220 | |
| 12232 | 12221 | struct mlx5_ifc_dcbx_param_bits { |
| @@ -5,7 +5,6 @@ · 4 unmodified lines | ||
| 5 | 5 | #include <linux/mmzone.h> |
| 6 | 6 | #include <linux/scatterlist.h> |
| 7 | 7 | |
| 8 | −/* This value should always be a power of 2, see page_reporting_cycle() */ | |
| 9 | 8 | #define PAGE_REPORTING_CAPACITY 32 |
| 10 | 9 | #define PAGE_REPORTING_ORDER_UNSPECIFIED -1 |
| 11 | 10 | |
| @@ -22,6 +21,9 @@ struct page_reporting_dev_info { · 10 unmodified lines | ||
| 22 | 21 | |
| 23 | 22 | /* Minimal order of page reporting */ |
| 24 | 23 | unsigned int order; |
| 24 | + | |
| 25 | + /* Max pages per report batch; 0 (default) means PAGE_REPORTING_CAPACITY */ | |
| 26 | + unsigned int capacity; | |
| 25 | 27 | }; |
| 26 | 28 | |
| 27 | 29 | /* Tear-down and bring-up for page reporting devices */ |
| @@ -58,10 +58,13 @@ enum _slab_flag_bits { · 57 unmodified lines | ||
| 58 | 58 | #endif |
| 59 | 59 | _SLAB_OBJECT_POISON, |
| 60 | 60 | _SLAB_CMPXCHG_DOUBLE, |
| 61 | +#ifdef CONFIG_SLAB_OBJ_EXT | |
| 61 | 62 | _SLAB_NO_OBJ_EXT, |
| 62 | −#if defined(CONFIG_SLAB_OBJ_EXT) && defined(CONFIG_64BIT) | |
| 63 | +#ifdef CONFIG_64BIT | |
| 63 | 64 | _SLAB_OBJ_EXT_IN_OBJ, |
| 64 | 65 | #endif |
| 66 | +#endif | |
| 67 | + _SLAB_NO_SHEAVES, | |
| 65 | 68 | _SLAB_FLAGS_LAST_BIT |
| 66 | 69 | }; |
| 67 | 70 | |
| @@ -239,8 +242,14 @@ enum _slab_flag_bits { · 171 unmodified lines | ||
| 239 | 242 | #endif |
| 240 | 243 | #define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ |
| 241 | 244 | |
| 242 | −/* Slab created using create_boot_cache */ | |
| 245 | +/* Slab caches without obj_exts array */ | |
| 246 | +#ifdef CONFIG_SLAB_OBJ_EXT | |
| 243 | 247 | #define SLAB_NO_OBJ_EXT __SLAB_FLAG_BIT(_SLAB_NO_OBJ_EXT) |
| 248 | +#else | |
| 249 | +#define SLAB_NO_OBJ_EXT __SLAB_FLAG_UNUSED | |
| 250 | +#endif | |
| 251 | + | |
| 252 | +#define SLAB_NO_SHEAVES __SLAB_FLAG_BIT(_SLAB_NO_SHEAVES) | |
| 244 | 253 | |
| 245 | 254 | #if defined(CONFIG_SLAB_OBJ_EXT) && defined(CONFIG_64BIT) |
| 246 | 255 | #define SLAB_OBJ_EXT_IN_OBJ __SLAB_FLAG_BIT(_SLAB_OBJ_EXT_IN_OBJ) |
| @@ -505,8 +514,12 @@ typedef struct { unsigned long v; } kmalloc_token_t; · 258 unmodified lines | ||
| 505 | 514 | extern unsigned long random_kmalloc_seed; |
| 506 | 515 | #define __kmalloc_token(...) ((kmalloc_token_t){ .v = _CODE_LOCATION_ }) |
| 507 | 516 | #elif defined(CONFIG_KMALLOC_PARTITION_TYPED) |
| 517 | +#ifdef __CHECKER__ | |
| 518 | +#define __kmalloc_token(...) ((kmalloc_token_t){ .v = 0 }) | |
| 519 | +#else /* !__CHECKER__ */ | |
| 508 | 520 | #define __kmalloc_token(...) ((kmalloc_token_t){ .v = __builtin_infer_alloc_token(__VA_ARGS__) }) |
| 509 | −#endif | |
| 521 | +#endif /* __CHECKER__ */ | |
| 522 | +#endif /* CONFIG_KMALLOC_PARTITION_TYPED */ | |
| 510 | 523 | #define DECL_TOKEN_PARAM(_token) , kmalloc_token_t (_token) |
| 511 | 524 | #define _PASS_TOKEN_PARAM(_token) , (_token) |
| 512 | 525 | #define PASS_TOKEN_PARAM(_token) (_token) |
| @@ -699,6 +712,9 @@ enum kmalloc_cache_type { · 186 unmodified lines | ||
| 699 | 712 | #endif |
| 700 | 713 | #ifndef CONFIG_MEMCG |
| 701 | 714 | KMALLOC_CGROUP = KMALLOC_NORMAL, |
| 715 | +#endif | |
| 716 | +#ifndef CONFIG_SLAB_OBJ_EXT | |
| 717 | + KMALLOC_NO_OBJ_EXT = KMALLOC_NORMAL, | |
| 702 | 718 | #endif |
| 703 | 719 | KMALLOC_PARTITION_START = KMALLOC_NORMAL, |
| 704 | 720 | KMALLOC_PARTITION_END = KMALLOC_PARTITION_START + KMALLOC_PARTITION_CACHES_NR, |
| @@ -712,6 +728,9 @@ enum kmalloc_cache_type { · 7 unmodified lines | ||
| 712 | 728 | #endif |
| 713 | 729 | #ifdef CONFIG_MEMCG |
| 714 | 730 | KMALLOC_CGROUP, |
| 731 | +#endif | |
| 732 | +#ifdef CONFIG_SLAB_OBJ_EXT | |
| 733 | + KMALLOC_NO_OBJ_EXT, | |
| 715 | 734 | #endif |
| 716 | 735 | NR_KMALLOC_TYPES |
| 717 | 736 | }; |
| @@ -226,6 +226,9 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, · 225 unmodified lines | ||
| 226 | 226 | u8 bit_rate, u8 data_bits, u8 stop_bits, |
| 227 | 227 | u8 parity, u8 flow_ctrl_settings, |
| 228 | 228 | u8 xon_char, u8 xoff_char, u16 param_mask); |
| 229 | +int rfcomm_dlc_send_rpn(struct rfcomm_dlc *d, u8 bit_rate, u8 data_bits, | |
| 230 | + u8 stop_bits, u8 parity, u8 flow_ctrl_settings, | |
| 231 | + u8 xon_char, u8 xoff_char, u16 param_mask); | |
| 229 | 232 | |
| 230 | 233 | /* ---- RFCOMM DLCs (channels) ---- */ |
| 231 | 234 | struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio); |
| @@ -156,8 +156,20 @@ static inline int tcf_classify(struct sk_buff *skb, · 155 unmodified lines | ||
| 156 | 156 | { |
| 157 | 157 | return TC_ACT_UNSPEC; |
| 158 | 158 | } |
| 159 | − | |
| 160 | 159 | #endif |
| 160 | +static inline int tcf_classify_qdisc(struct sk_buff *skb, | |
| 161 | + const struct tcf_proto *tp, | |
| 162 | + struct tcf_result *res, bool compat_mode) | |
| 163 | +{ | |
| 164 | + int ret = tcf_classify(skb, NULL, tp, res, compat_mode); | |
| 165 | + | |
| 166 | + /* TC_ACT_REDIRECT from qdisc filter chains is not supported. | |
| 167 | + * Use BPF via tcx or mirred redirect instead. | |
| 168 | + */ | |
| 169 | + if (unlikely(ret == TC_ACT_REDIRECT)) | |
| 170 | + ret = TC_ACT_SHOT; | |
| 171 | + return ret; | |
| 172 | +} | |
| 161 | 173 | |
| 162 | 174 | static inline unsigned long |
| 163 | 175 | __cls_set_class(unsigned long *clp, unsigned long cl) |
| @@ -1974,6 +1974,8 @@ static inline void tcp_fast_path_check(struct sock *sk) · 1973 unmodified lines | ||
| 1974 | 1974 | |
| 1975 | 1975 | bool tcp_oow_rate_limited(struct net *net, const struct sk_buff *skb, |
| 1976 | 1976 | int mib_idx, u32 *last_oow_ack_time); |
| 1977 | +void tcp_reqsk_send_challenge_ack(struct sock *sk, struct sk_buff *skb, | |
| 1978 | + struct request_sock *req); | |
| 1977 | 1979 | |
| 1978 | 1980 | static inline void tcp_mib_init(struct net *net) |
| 1979 | 1981 | { |
| @@ -67,6 +67,8 @@ struct fdl_state { · 66 unmodified lines | ||
| 67 | 67 | #if IS_ENABLED(CONFIG_SND_SOC_SDCA_FDL) |
| 68 | 68 | |
| 69 | 69 | int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt); |
| 70 | +void sdca_fdl_free_state(struct sdca_interrupt *interrupt); | |
| 71 | + | |
| 70 | 72 | int sdca_fdl_process(struct sdca_interrupt *interrupt); |
| 71 | 73 | int sdca_fdl_sync(struct device *dev, struct sdca_function_data *function, |
| 72 | 74 | struct sdca_interrupt_info *info); |
| @@ -30,9 +30,12 @@ struct sdca_function_data; · 29 unmodified lines | ||
| 30 | 30 | * @function: Pointer to the Function that the interrupt is associated with. |
| 31 | 31 | * @entity: Pointer to the Entity that the interrupt is associated with. |
| 32 | 32 | * @control: Pointer to the Control that the interrupt is associated with. |
| 33 | + * @handler: Handler function to be called for the IRQ. | |
| 33 | 34 | * @priv: Pointer to private data for use by the handler. |
| 35 | + * @free_priv: Pointer to a function that can be used to free the priv data. | |
| 34 | 36 | * @irq: IRQ number allocated to this interrupt, also used internally to track |
| 35 | 37 | * the IRQ being assigned. |
| 38 | + * @early_request: Flag to indicate this IRQ was requested at bus probe time. | |
| 36 | 39 | */ |
| 37 | 40 | struct sdca_interrupt { |
| 38 | 41 | const char *name; |
| @@ -44,10 +47,13 @@ struct sdca_interrupt { · 5 unmodified lines | ||
| 44 | 47 | struct sdca_function_data *function; |
| 45 | 48 | struct sdca_entity *entity; |
| 46 | 49 | struct sdca_control *control; |
| 50 | + irq_handler_t handler; | |
| 47 | 51 | |
| 48 | 52 | void *priv; |
| 53 | + void (*free_priv)(struct sdca_interrupt *interrupt); | |
| 49 | 54 | |
| 50 | 55 | int irq; |
| 56 | + bool early_request; | |
| 51 | 57 | }; |
| 52 | 58 | |
| 53 | 59 | /** |
| @@ -86,8 +92,12 @@ int sdca_irq_populate(struct sdca_function_data *function, · 32 unmodified lines | ||
| 86 | 92 | void sdca_irq_cleanup(struct device *dev, |
| 87 | 93 | struct sdca_function_data *function, |
| 88 | 94 | struct sdca_interrupt_info *info); |
| 89 | −struct sdca_interrupt_info *sdca_irq_allocate(struct device *dev, | |
| 90 | − struct regmap *regmap, int irq); | |
| 95 | +void sdca_irq_cleanup_late(struct device *dev, | |
| 96 | + struct sdca_function_data *function, | |
| 97 | + struct sdca_interrupt_info *info); | |
| 98 | + | |
| 99 | +struct sdca_interrupt_info *devm_sdca_irq_allocate(struct device *dev, | |
| 100 | + struct regmap *regmap, int irq); | |
| 91 | 101 | |
| 92 | 102 | void sdca_irq_enable_early(struct sdca_function_data *function, |
| 93 | 103 | struct sdca_interrupt_info *info); |
| @@ -28,6 +28,9 @@ struct jack_state { · 27 unmodified lines | ||
| 28 | 28 | }; |
| 29 | 29 | |
| 30 | 30 | int sdca_jack_alloc_state(struct sdca_interrupt *interrupt); |
| 31 | +int sdca_jack_init_state(struct sdca_interrupt *interrupt); | |
| 32 | +void sdca_jack_free_state(struct sdca_interrupt *interrupt); | |
| 33 | + | |
| 31 | 34 | int sdca_jack_process(struct sdca_interrupt *interrupt); |
| 32 | 35 | int sdca_jack_set_jack(struct sdca_interrupt_info *info, struct snd_soc_jack *jack); |
| 33 | 36 | int sdca_jack_report(struct sdca_interrupt *interrupt); |
| @@ -78,6 +78,7 @@ struct snd_soc_component_driver { · 77 unmodified lines | ||
| 78 | 78 | unsigned int num_dapm_routes; |
| 79 | 79 | |
| 80 | 80 | int (*probe)(struct snd_soc_component *component); |
| 81 | + int (*fixup_controls)(struct snd_soc_component *component); | |
| 81 | 82 | void (*remove)(struct snd_soc_component *component); |
| 82 | 83 | int (*suspend)(struct snd_soc_component *component); |
| 83 | 84 | int (*resume)(struct snd_soc_component *component); |
| @@ -380,6 +381,7 @@ void snd_soc_component_suspend(struct snd_soc_component *component); · 296 unmodified lines | ||
| 380 | 381 | void snd_soc_component_resume(struct snd_soc_component *component); |
| 381 | 382 | int snd_soc_component_is_suspended(struct snd_soc_component *component); |
| 382 | 383 | int snd_soc_component_probe(struct snd_soc_component *component); |
| 384 | +int snd_soc_component_fixup_controls(struct snd_soc_component *component); | |
| 383 | 385 | void snd_soc_component_remove(struct snd_soc_component *component); |
| 384 | 386 | int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component, |
| 385 | 387 | struct device_node *ep); |
| @@ -1,6 +1,10 @@ | ||
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | 2 | #undef TRACE_SYSTEM |
| 3 | −#define TRACE_SYSTEM memory_failure | |
| 3 | +/* | |
| 4 | + * For historical versions, memory_failure_event is in ras subsystem, | |
| 5 | + * some user programs depend on it. | |
| 6 | + */ | |
| 7 | +#define TRACE_SYSTEM ras | |
| 4 | 8 | #define TRACE_INCLUDE_FILE memory-failure |
| 5 | 9 | |
| 6 | 10 | #if !defined(_TRACE_MEMORY_FAILURE_H) || defined(TRACE_HEADER_MULTI_READ) |
| @@ -598,7 +598,7 @@ struct btrfs_ioctl_search_args_v2 { · 597 unmodified lines | ||
| 598 | 598 | __u64 buf_size; /* in - size of buffer |
| 599 | 599 | * out - on EOVERFLOW: needed size |
| 600 | 600 | * to store item */ |
| 601 | − __u64 buf[]; /* out - found items */ | |
| 601 | + __u8 buf[]; /* out - found items */ | |
| 602 | 602 | }; |
| 603 | 603 | |
| 604 | 604 | /* With a @src_length of zero, the range from @src_offset->EOF is cloned! */ |
| @@ -23,7 +23,7 @@ enum { · 22 unmodified lines | ||
| 23 | 23 | IO_URING_QUERY_OPCODES = 0, |
| 24 | 24 | IO_URING_QUERY_ZCRX = 1, |
| 25 | 25 | IO_URING_QUERY_SCQ = 2, |
| 26 | − IO_URING_QUERY_ZCRX_NOTIF = 3, | |
| 26 | + IO_URING_QUERY_ZCRX_EVENT = 3, | |
| 27 | 27 | |
| 28 | 28 | __IO_URING_QUERY_MAX, |
| 29 | 29 | }; |
| @@ -63,13 +63,13 @@ struct io_uring_query_zcrx { · 33 unmodified lines | ||
| 63 | 63 | __u64 __resv2; |
| 64 | 64 | }; |
| 65 | 65 | |
| 66 | −struct io_uring_query_zcrx_notif { | |
| 67 | − /* Bitmask of supported ZCRX_NOTIF_* flags */ | |
| 68 | − __u32 notif_flags; | |
| 69 | − /* Size of io_uring_zcrx_notif_stats */ | |
| 70 | − __u32 notif_stats_size; | |
| 66 | +struct io_uring_query_zcrx_event { | |
| 67 | + /* Bitmask of supported ZCRX_EVENT_* flags */ | |
| 68 | + __u32 event_flags; | |
| 69 | + /* Size of zcrx_stats */ | |
| 70 | + __u32 stats_size; | |
| 71 | 71 | /* Required alignment for the stats struct within the region (ie stats_offset) */ |
| 72 | − __u32 notif_stats_off_alignment; | |
| 72 | + __u32 stats_off_alignment; | |
| 73 | 73 | __u32 __resv1; |
| 74 | 74 | __u64 __resv2[4]; |
| 75 | 75 | }; |
| @@ -65,30 +65,30 @@ enum zcrx_features { · 64 unmodified lines | ||
| 65 | 65 | * value in struct io_uring_zcrx_ifq_reg::rx_buf_len. |
| 66 | 66 | */ |
| 67 | 67 | ZCRX_FEATURE_RX_PAGE_SIZE = 1 << 0, |
| 68 | − ZCRX_FEATURE_NOTIFICATION = 1 << 1, | |
| 68 | + ZCRX_FEATURE_EVENT = 1 << 1, | |
| 69 | 69 | }; |
| 70 | 70 | |
| 71 | −enum zcrx_notification_type { | |
| 72 | − ZCRX_NOTIF_NO_BUFFERS, | |
| 73 | − ZCRX_NOTIF_COPY, | |
| 71 | +enum zcrx_event_type { | |
| 72 | + ZCRX_EVENT_ALLOC_FAIL, | |
| 73 | + ZCRX_EVENT_COPY, | |
| 74 | 74 | |
| 75 | − __ZCRX_NOTIF_TYPE_LAST, | |
| 75 | + __ZCRX_EVENT_TYPE_LAST, | |
| 76 | 76 | }; |
| 77 | 77 | |
| 78 | −enum zcrx_notification_desc_flags { | |
| 79 | − /* If set, stats_offset holds a valid offset to a notif_stats struct */ | |
| 80 | − ZCRX_NOTIF_DESC_FLAG_STATS = 1 << 0, | |
| 78 | +enum zcrx_event_desc_flags { | |
| 79 | + /* If set, stats_offset holds a valid offset to a zcrx_stats struct */ | |
| 80 | + ZCRX_EVENT_DESC_FLAG_STATS = 1 << 0, | |
| 81 | 81 | }; |
| 82 | 82 | |
| 83 | −struct zcrx_notif_stats { | |
| 83 | +struct zcrx_stats { | |
| 84 | 84 | __u64 copy_count; /* cumulative copy-fallback CQEs */ |
| 85 | 85 | __u64 copy_bytes; /* cumulative bytes copied */ |
| 86 | 86 | }; |
| 87 | 87 | |
| 88 | −struct zcrx_notification_desc { | |
| 88 | +struct zcrx_event_desc { | |
| 89 | 89 | __u64 user_data; |
| 90 | 90 | __u32 type_mask; |
| 91 | − __u32 flags; /* see enum zcrx_notification_desc_flags */ | |
| 91 | + __u32 flags; /* see enum zcrx_event_desc_flags */ | |
| 92 | 92 | __u64 stats_offset; /* offset from the beginning of refill ring region for stats */ |
| 93 | 93 | __u64 __resv2[9]; |
| 94 | 94 | }; |
| @@ -108,14 +108,14 @@ struct io_uring_zcrx_ifq_reg { · 13 unmodified lines | ||
| 108 | 108 | struct io_uring_zcrx_offsets offsets; |
| 109 | 109 | __u32 zcrx_id; |
| 110 | 110 | __u32 rx_buf_len; |
| 111 | − __u64 notif_desc; /* see struct zcrx_notification_desc */ | |
| 111 | + __u64 event_desc; /* see struct zcrx_event_desc */ | |
| 112 | 112 | __u64 __resv[2]; |
| 113 | 113 | }; |
| 114 | 114 | |
| 115 | 115 | enum zcrx_ctrl_op { |
| 116 | 116 | ZCRX_CTRL_FLUSH_RQ, |
| 117 | 117 | ZCRX_CTRL_EXPORT, |
| 118 | − ZCRX_CTRL_ARM_NOTIFICATION, | |
| 118 | + ZCRX_CTRL_ARM_EVENT, | |
| 119 | 119 | |
| 120 | 120 | __ZCRX_CTRL_LAST, |
| 121 | 121 | }; |
| @@ -129,8 +129,8 @@ struct zcrx_ctrl_export { · 7 unmodified lines | ||
| 129 | 129 | __u32 __resv1[11]; |
| 130 | 130 | }; |
| 131 | 131 | |
| 132 | −struct zcrx_ctrl_arm_notif { | |
| 133 | − __u32 notif_type; | |
| 132 | +struct zcrx_ctrl_arm_event { | |
| 133 | + __u32 event_type; /* see enum zcrx_event_type */ | |
| 134 | 134 | __u32 __resv[11]; |
| 135 | 135 | }; |
| 136 | 136 | |
| @@ -142,7 +142,7 @@ struct zcrx_ctrl { · 5 unmodified lines | ||
| 142 | 142 | union { |
| 143 | 143 | struct zcrx_ctrl_export zc_export; |
| 144 | 144 | struct zcrx_ctrl_flush_rq zc_flush; |
| 145 | − struct zcrx_ctrl_arm_notif zc_arm_notif; | |
| 145 | + struct zcrx_ctrl_arm_event zc_arm_event; | |
| 146 | 146 | }; |
| 147 | 147 | }; |
| 148 | 148 | |
| @@ -190,6 +190,9 @@ config RUSTC_HAS_FILE_WITH_NUL · 189 unmodified lines | ||
| 190 | 190 | config RUSTC_HAS_FILE_AS_C_STR |
| 191 | 191 | def_bool RUSTC_VERSION >= 109100 |
| 192 | 192 | |
| 193 | +config RUSTC_HAS_SUSPICIOUS_RUNTIME_SYMBOL_DEFINITIONS | |
| 194 | + def_bool RUSTC_VERSION >= 109800 | |
| 195 | + | |
| 193 | 196 | config PAHOLE_VERSION |
| 194 | 197 | int |
| 195 | 198 | default "$(PAHOLE_VERSION)" |
| @@ -9,7 +9,7 @@ · 8 unmodified lines | ||
| 9 | 9 | union io_query_data { |
| 10 | 10 | struct io_uring_query_opcode opcodes; |
| 11 | 11 | struct io_uring_query_zcrx zcrx; |
| 12 | − struct io_uring_query_zcrx_notif zcrx_notif; | |
| 12 | + struct io_uring_query_zcrx_event zcrx_notif; | |
| 13 | 13 | struct io_uring_query_scq scq; |
| 14 | 14 | }; |
| 15 | 15 | |
| @@ -47,11 +47,11 @@ static ssize_t io_query_zcrx(union io_query_data *data) · 31 unmodified lines | ||
| 47 | 47 | |
| 48 | 48 | static ssize_t io_query_zcrx_notif(union io_query_data *data) |
| 49 | 49 | { |
| 50 | − struct io_uring_query_zcrx_notif *e = &data->zcrx_notif; | |
| 50 | + struct io_uring_query_zcrx_event *e = &data->zcrx_notif; | |
| 51 | 51 | |
| 52 | − e->notif_flags = ZCRX_NOTIF_TYPE_MASK; | |
| 53 | − e->notif_stats_size = sizeof(struct zcrx_notif_stats); | |
| 54 | − e->notif_stats_off_alignment = __alignof__(struct zcrx_notif_stats); | |
| 52 | + e->event_flags = ZCRX_EVENT_TYPE_MASK; | |
| 53 | + e->stats_size = sizeof(struct zcrx_stats); | |
| 54 | + e->stats_off_alignment = __alignof__(struct zcrx_stats); | |
| 55 | 55 | e->__resv1 = 0; |
| 56 | 56 | memset(&e->__resv2, 0, sizeof(e->__resv2)); |
| 57 | 57 | return sizeof(*e); |
| @@ -96,7 +96,7 @@ static int io_handle_query_entry(union io_query_data *data, void __user *uhdr, · 38 unmodified lines | ||
| 96 | 96 | case IO_URING_QUERY_ZCRX: |
| 97 | 97 | ret = io_query_zcrx(data); |
| 98 | 98 | break; |
| 99 | − case IO_URING_QUERY_ZCRX_NOTIF: | |
| 99 | + case IO_URING_QUERY_ZCRX_EVENT: | |
| 100 | 100 | ret = io_query_zcrx_notif(data); |
| 101 | 101 | break; |
| 102 | 102 | case IO_URING_QUERY_SCQ: |
| @@ -615,6 +615,24 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res) · 614 unmodified lines | ||
| 615 | 615 | smp_store_release(&req->iopoll_completed, 1); |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | +static inline ssize_t io_fixup_restart_res(ssize_t ret) | |
| 619 | +{ | |
| 620 | + switch (ret) { | |
| 621 | + case -ERESTARTSYS: | |
| 622 | + case -ERESTARTNOINTR: | |
| 623 | + case -ERESTARTNOHAND: | |
| 624 | + case -ERESTART_RESTARTBLOCK: | |
| 625 | + /* | |
| 626 | + * We can't just restart the syscall, since previously | |
| 627 | + * submitted sqes may already be in progress. Just fail | |
| 628 | + * this IO with EINTR. | |
| 629 | + */ | |
| 630 | + return -EINTR; | |
| 631 | + default: | |
| 632 | + return ret; | |
| 633 | + } | |
| 634 | +} | |
| 635 | + | |
| 618 | 636 | static inline void io_rw_done(struct io_kiocb *req, ssize_t ret) |
| 619 | 637 | { |
| 620 | 638 | struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); |
| @@ -624,21 +642,8 @@ static inline void io_rw_done(struct io_kiocb *req, ssize_t ret) · 3 unmodified lines | ||
| 624 | 642 | return; |
| 625 | 643 | |
| 626 | 644 | /* transform internal restart error codes */ |
| 627 | − if (unlikely(ret < 0)) { | |
| 628 | − switch (ret) { | |
| 629 | − case -ERESTARTSYS: | |
| 630 | − case -ERESTARTNOINTR: | |
| 631 | − case -ERESTARTNOHAND: | |
| 632 | − case -ERESTART_RESTARTBLOCK: | |
| 633 | − /* | |
| 634 | − * We can't just restart the syscall, since previously | |
| 635 | − * submitted sqes may already be in progress. Just fail | |
| 636 | − * this IO with EINTR. | |
| 637 | − */ | |
| 638 | − ret = -EINTR; | |
| 639 | − break; | |
| 640 | − } | |
| 641 | − } | |
| 645 | + if (unlikely(ret < 0)) | |
| 646 | + ret = io_fixup_restart_res(ret); | |
| 642 | 647 | |
| 643 | 648 | if (req->flags & REQ_F_IOPOLL) |
| 644 | 649 | io_complete_rw_iopoll(&rw->kiocb, ret); |
| @@ -1034,7 +1039,8 @@ int io_read(struct io_kiocb *req, unsigned int issue_flags) · 389 unmodified lines | ||
| 1034 | 1039 | |
| 1035 | 1040 | if (req->flags & REQ_F_BUFFERS_COMMIT) |
| 1036 | 1041 | io_kbuf_recycle(req, sel.buf_list, issue_flags); |
| 1037 | − return ret; | |
| 1042 | + | |
| 1043 | + return io_fixup_restart_res(ret); | |
| 1038 | 1044 | } |
| 1039 | 1045 | |
| 1040 | 1046 | int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags) |
| @@ -1068,8 +1074,10 @@ int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags) · 27 unmodified lines | ||
| 1068 | 1074 | return IOU_RETRY; |
| 1069 | 1075 | } else if (ret <= 0) { |
| 1070 | 1076 | io_kbuf_recycle(req, sel.buf_list, issue_flags); |
| 1071 | − if (ret < 0) | |
| 1077 | + if (ret < 0) { | |
| 1078 | + ret = io_fixup_restart_res(ret); | |
| 1072 | 1079 | req_set_fail(req); |
| 1080 | + } | |
| 1073 | 1081 | } else if (!(req->flags & REQ_F_APOLL_MULTISHOT)) { |
| 1074 | 1082 | cflags = io_put_kbuf(req, ret, sel.buf_list); |
| 1075 | 1083 | } else { |
| @@ -766,7 +766,7 @@ static int import_zcrx(struct io_ring_ctx *ctx, · 765 unmodified lines | ||
| 766 | 766 | return -EINVAL; |
| 767 | 767 | if (reg->if_rxq || reg->rq_entries || reg->area_ptr || reg->region_ptr) |
| 768 | 768 | return -EINVAL; |
| 769 | − if (reg->notif_desc) | |
| 769 | + if (reg->event_desc) | |
| 770 | 770 | return -EINVAL; |
| 771 | 771 | if (reg->flags & ~ZCRX_REG_IMPORT) |
| 772 | 772 | return -EINVAL; |
| @@ -855,7 +855,7 @@ netdev_put_unlock: · 82 unmodified lines | ||
| 855 | 855 | |
| 856 | 856 | static int zcrx_validate_notif_stats(struct io_zcrx_ifq *ifq, |
| 857 | 857 | const struct io_uring_zcrx_ifq_reg *reg, |
| 858 | − const struct zcrx_notification_desc *notif) | |
| 858 | + const struct zcrx_event_desc *notif) | |
| 859 | 859 | { |
| 860 | 860 | size_t stats_off = notif->stats_offset; |
| 861 | 861 | size_t used, end; |
| @@ -863,12 +863,12 @@ static int zcrx_validate_notif_stats(struct io_zcrx_ifq *ifq, · 1 unmodified line | ||
| 863 | 863 | used = reg->offsets.rqes + |
| 864 | 864 | sizeof(struct io_uring_zcrx_rqe) * reg->rq_entries; |
| 865 | 865 | |
| 866 | − if (!IS_ALIGNED(stats_off, __alignof__(struct zcrx_notif_stats))) | |
| 866 | + if (!IS_ALIGNED(stats_off, __alignof__(struct zcrx_stats))) | |
| 867 | 867 | return -EINVAL; |
| 868 | 868 | if (stats_off < used) |
| 869 | 869 | return -ERANGE; |
| 870 | 870 | if (check_add_overflow(stats_off, |
| 871 | − sizeof(struct zcrx_notif_stats), | |
| 871 | + sizeof(struct zcrx_stats), | |
| 872 | 872 | &end)) |
| 873 | 873 | return -ERANGE; |
| 874 | 874 | if (end > io_region_size(&ifq->rq_region)) |
| @@ -883,7 +883,7 @@ static int zcrx_validate_notif_stats(struct io_zcrx_ifq *ifq, · 8 unmodified lines | ||
| 883 | 883 | int io_register_zcrx(struct io_ring_ctx *ctx, |
| 884 | 884 | struct io_uring_zcrx_ifq_reg __user *arg) |
| 885 | 885 | { |
| 886 | − struct zcrx_notification_desc notif; | |
| 886 | + struct zcrx_event_desc notif; | |
| 887 | 887 | struct io_uring_zcrx_area_reg area; |
| 888 | 888 | struct io_uring_zcrx_ifq_reg reg; |
| 889 | 889 | struct io_uring_region_desc rd; |
| @@ -928,14 +928,14 @@ int io_register_zcrx(struct io_ring_ctx *ctx, · 38 unmodified lines | ||
| 928 | 928 | return -EFAULT; |
| 929 | 929 | |
| 930 | 930 | memset(¬if, 0, sizeof(notif)); |
| 931 | − if (reg.notif_desc && copy_from_user(¬if, u64_to_user_ptr(reg.notif_desc), | |
| 931 | + if (reg.event_desc && copy_from_user(¬if, u64_to_user_ptr(reg.event_desc), | |
| 932 | 932 | sizeof(notif))) |
| 933 | 933 | return -EFAULT; |
| 934 | − if (notif.type_mask & ~ZCRX_NOTIF_TYPE_MASK) | |
| 934 | + if (notif.type_mask & ~ZCRX_EVENT_TYPE_MASK) | |
| 935 | 935 | return -EINVAL; |
| 936 | − if (notif.flags & ~ZCRX_NOTIF_DESC_FLAG_STATS) | |
| 936 | + if (notif.flags & ~ZCRX_EVENT_DESC_FLAG_STATS) | |
| 937 | 937 | return -EINVAL; |
| 938 | − if (!(notif.flags & ZCRX_NOTIF_DESC_FLAG_STATS)) { | |
| 938 | + if (!(notif.flags & ZCRX_EVENT_DESC_FLAG_STATS)) { | |
| 939 | 939 | if (notif.stats_offset) |
| 940 | 940 | return -EINVAL; |
| 941 | 941 | } |
| @@ -970,7 +970,7 @@ int io_register_zcrx(struct io_ring_ctx *ctx, · 28 unmodified lines | ||
| 970 | 970 | if (ret) |
| 971 | 971 | goto err; |
| 972 | 972 | |
| 973 | − if (notif.flags & ZCRX_NOTIF_DESC_FLAG_STATS) { | |
| 973 | + if (notif.flags & ZCRX_EVENT_DESC_FLAG_STATS) { | |
| 974 | 974 | ret = zcrx_validate_notif_stats(ifq, ®, ¬if); |
| 975 | 975 | if (ret) |
| 976 | 976 | goto err; |
| @@ -1244,7 +1244,7 @@ static netmem_ref io_pp_zc_alloc_netmems(struct page_pool *pp, gfp_t gfp) · 267 unmodified lines | ||
| 1244 | 1244 | |
| 1245 | 1245 | allocated = io_zcrx_refill_slow(pp, ifq, netmems, to_alloc); |
| 1246 | 1246 | if (!allocated) { |
| 1247 | − zcrx_send_notif(ifq, ZCRX_NOTIF_NO_BUFFERS); | |
| 1247 | + zcrx_send_notif(ifq, ZCRX_EVENT_ALLOC_FAIL); | |
| 1248 | 1248 | return 0; |
| 1249 | 1249 | } |
| 1250 | 1250 | out_return: |
| @@ -1406,16 +1406,16 @@ static int zcrx_flush_rq(struct io_ring_ctx *ctx, struct io_zcrx_ifq *zcrx, · 155 unmodified lines | ||
| 1406 | 1406 | static int zcrx_arm_notif(struct io_ring_ctx *ctx, struct io_zcrx_ifq *zcrx, |
| 1407 | 1407 | struct zcrx_ctrl *ctrl) |
| 1408 | 1408 | { |
| 1409 | − const struct zcrx_ctrl_arm_notif *an = &ctrl->zc_arm_notif; | |
| 1409 | + const struct zcrx_ctrl_arm_event *an = &ctrl->zc_arm_event; | |
| 1410 | 1410 | unsigned type_mask; |
| 1411 | 1411 | |
| 1412 | − if (an->notif_type >= __ZCRX_NOTIF_TYPE_LAST) | |
| 1412 | + if (an->event_type >= __ZCRX_EVENT_TYPE_LAST) | |
| 1413 | 1413 | return -EINVAL; |
| 1414 | 1414 | if (!mem_is_zero(&an->__resv, sizeof(an->__resv))) |
| 1415 | 1415 | return -EINVAL; |
| 1416 | 1416 | |
| 1417 | 1417 | guard(spinlock_bh)(&zcrx->ctx_lock); |
| 1418 | − type_mask = 1U << an->notif_type; | |
| 1418 | + type_mask = 1U << an->event_type; | |
| 1419 | 1419 | if (type_mask & ~zcrx->fired_notifs) |
| 1420 | 1420 | return -EINVAL; |
| 1421 | 1421 | zcrx->fired_notifs &= ~type_mask; |
| @@ -1428,7 +1428,7 @@ int io_zcrx_ctrl(struct io_ring_ctx *ctx, void __user *arg, unsigned nr_args) · 6 unmodified lines | ||
| 1428 | 1428 | struct io_zcrx_ifq *zcrx; |
| 1429 | 1429 | |
| 1430 | 1430 | BUILD_BUG_ON(sizeof(ctrl.zc_export) != sizeof(ctrl.zc_flush)); |
| 1431 | − BUILD_BUG_ON(sizeof(ctrl.zc_export) != sizeof(ctrl.zc_arm_notif)); | |
| 1431 | + BUILD_BUG_ON(sizeof(ctrl.zc_export) != sizeof(ctrl.zc_arm_event)); | |
| 1432 | 1432 | |
| 1433 | 1433 | if (nr_args) |
| 1434 | 1434 | return -EINVAL; |
| @@ -1446,7 +1446,7 @@ int io_zcrx_ctrl(struct io_ring_ctx *ctx, void __user *arg, unsigned nr_args) · 11 unmodified lines | ||
| 1446 | 1446 | return zcrx_flush_rq(ctx, zcrx, &ctrl); |
| 1447 | 1447 | case ZCRX_CTRL_EXPORT: |
| 1448 | 1448 | return zcrx_export(ctx, zcrx, &ctrl, arg); |
| 1449 | − case ZCRX_CTRL_ARM_NOTIFICATION: | |
| 1449 | + case ZCRX_CTRL_ARM_EVENT: | |
| 1450 | 1450 | return zcrx_arm_notif(ctx, zcrx, &ctrl); |
| 1451 | 1451 | } |
| 1452 | 1452 | |
| @@ -1592,7 +1592,7 @@ static int io_zcrx_copy_frag(struct io_kiocb *req, struct io_zcrx_ifq *ifq, · 139 unmodified lines | ||
| 1592 | 1592 | zcrx_stat_add(&ifq->notif_stats->copy_count, 1); |
| 1593 | 1593 | zcrx_stat_add(&ifq->notif_stats->copy_bytes, ret); |
| 1594 | 1594 | } |
| 1595 | − zcrx_send_notif(ifq, ZCRX_NOTIF_COPY); | |
| 1595 | + zcrx_send_notif(ifq, ZCRX_EVENT_COPY); | |
| 1596 | 1596 | } |
| 1597 | 1597 | |
| 1598 | 1598 | return ret; |
| @@ -10,8 +10,9 @@ · 9 unmodified lines | ||
| 10 | 10 | |
| 11 | 11 | #define ZCRX_SUPPORTED_REG_FLAGS (ZCRX_REG_IMPORT | ZCRX_REG_NODEV) |
| 12 | 12 | #define ZCRX_FEATURES (ZCRX_FEATURE_RX_PAGE_SIZE |\ |
| 13 | − ZCRX_FEATURE_NOTIFICATION) | |
| 14 | −#define ZCRX_NOTIF_TYPE_MASK ((1U << ZCRX_NOTIF_NO_BUFFERS) | (1U << ZCRX_NOTIF_COPY)) | |
| 13 | + ZCRX_FEATURE_EVENT) | |
| 14 | +#define ZCRX_EVENT_TYPE_MASK ((1U << ZCRX_EVENT_ALLOC_FAIL) |\ | |
| 15 | + (1U << ZCRX_EVENT_COPY)) | |
| 15 | 16 | |
| 16 | 17 | struct io_zcrx_mem { |
| 17 | 18 | unsigned long size; |
| @@ -80,7 +81,7 @@ struct io_zcrx_ifq { · 62 unmodified lines | ||
| 80 | 81 | u32 allowed_notif_mask; |
| 81 | 82 | u32 fired_notifs; |
| 82 | 83 | u64 notif_data; |
| 83 | − struct zcrx_notif_stats *notif_stats; | |
| 84 | + struct zcrx_stats *notif_stats; | |
| 84 | 85 | }; |
| 85 | 86 | |
| 86 | 87 | #if defined(CONFIG_IO_URING_ZCRX) |
| @@ -9189,7 +9189,8 @@ static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog, · 9188 unmodified lines | ||
| 9189 | 9189 | return ret; |
| 9190 | 9190 | if (check_mem_reg(env, reg, argno, arg->mem_size)) |
| 9191 | 9191 | return -EINVAL; |
| 9192 | − if (!(arg->arg_type & PTR_MAYBE_NULL) && (reg->type & PTR_MAYBE_NULL)) { | |
| 9192 | + if (!(arg->arg_type & PTR_MAYBE_NULL) && | |
| 9193 | + (type_may_be_null(reg->type) || bpf_register_is_null(reg))) { | |
| 9193 | 9194 | bpf_log(log, "%s is expected to be non-NULL\n", |
| 9194 | 9195 | reg_arg_name(env, argno)); |
| 9195 | 9196 | return -EINVAL; |
| @@ -378,7 +378,7 @@ static const struct luo_ioctl_op luo_session_ioctl_ops[] = { · 377 unmodified lines | ||
| 378 | 378 | IOCTL_OP(LIVEUPDATE_SESSION_RETRIEVE_FD, luo_session_retrieve_fd, |
| 379 | 379 | struct liveupdate_session_retrieve_fd, token, LUO_IOCTL_INCOMING), |
| 380 | 380 | IOCTL_OP(LIVEUPDATE_SESSION_GET_NAME, luo_session_get_name, |
| 381 | − struct liveupdate_session_retrieve_fd, token, LUO_IOCTL_ALL), | |
| 381 | + struct liveupdate_session_get_name, name, LUO_IOCTL_ALL), | |
| 382 | 382 | }; |
| 383 | 383 | |
| 384 | 384 | static bool luo_ioctl_type_valid(struct luo_session *session, |
| @@ -137,10 +137,10 @@ csd_do_func(smp_call_func_t func, void *info, call_single_data_t *csd) · 136 unmodified lines | ||
| 137 | 137 | trace_csd_function_exit(func, csd); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | −#ifdef CONFIG_CSD_LOCK_WAIT_DEBUG | |
| 141 | − | |
| 142 | 140 | static DEFINE_STATIC_KEY_MAYBE(CONFIG_CSD_LOCK_WAIT_DEBUG_DEFAULT, csdlock_debug_enabled); |
| 143 | 141 | |
| 142 | +#ifdef CONFIG_CSD_LOCK_WAIT_DEBUG | |
| 143 | + | |
| 144 | 144 | /* |
| 145 | 145 | * Parse the csdlock_debug= kernel boot parameter. |
| 146 | 146 | * |
| @@ -342,6 +342,10 @@ static __always_inline void csd_lock_wait(call_single_data_t *csd) · 195 unmodified lines | ||
| 342 | 342 | smp_cond_load_acquire(&csd->node.u_flags, !(VAL & CSD_FLAG_LOCK)); |
| 343 | 343 | } |
| 344 | 344 | #else |
| 345 | +static __always_inline void __csd_lock_wait(call_single_data_t *csd) | |
| 346 | +{ | |
| 347 | +} | |
| 348 | + | |
| 345 | 349 | static void csd_lock_record(call_single_data_t *csd) |
| 346 | 350 | { |
| 347 | 351 | } |
| @@ -354,8 +358,23 @@ static __always_inline void csd_lock_wait(call_single_data_t *csd) · 6 unmodified lines | ||
| 354 | 358 | |
| 355 | 359 | static __always_inline void csd_lock(call_single_data_t *csd) |
| 356 | 360 | { |
| 357 | − csd_lock_wait(csd); | |
| 358 | − csd->node.u_flags |= CSD_FLAG_LOCK; | |
| 361 | + if (IS_ENABLED(CONFIG_CSD_LOCK_WAIT_DEBUG) && | |
| 362 | + static_branch_unlikely(&csdlock_debug_enabled)) { | |
| 363 | + | |
| 364 | + for (;;) { | |
| 365 | + unsigned int flags; | |
| 366 | + | |
| 367 | + __csd_lock_wait(csd); | |
| 368 | + flags = READ_ONCE(csd->node.u_flags); | |
| 369 | + | |
| 370 | + if (!(flags & CSD_FLAG_LOCK) && | |
| 371 | + try_cmpxchg_acquire(&csd->node.u_flags, &flags, flags | CSD_FLAG_LOCK)) | |
| 372 | + break; | |
| 373 | + } | |
| 374 | + } else { | |
| 375 | + csd_lock_wait(csd); | |
| 376 | + csd->node.u_flags |= CSD_FLAG_LOCK; | |
| 377 | + } | |
| 359 | 378 | |
| 360 | 379 | /* |
| 361 | 380 | * prevent CPU from reordering the above assignment |
| @@ -380,7 +399,8 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data); · 18 unmodified lines | ||
| 380 | 399 | #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG |
| 381 | 400 | static call_single_data_t *get_single_csd_data(int cpu) |
| 382 | 401 | { |
| 383 | − if (static_branch_unlikely(&csdlock_debug_enabled)) | |
| 402 | + if (static_branch_unlikely(&csdlock_debug_enabled) && | |
| 403 | + (unsigned int)cpu < nr_cpu_ids) | |
| 384 | 404 | return per_cpu_ptr(&csd_data, cpu); |
| 385 | 405 | return this_cpu_ptr(&csd_data); |
| 386 | 406 | } |
| @@ -1097,6 +1097,12 @@ struct ftrace_ops global_ops = { · 1096 unmodified lines | ||
| 1097 | 1097 | FTRACE_OPS_FL_PID, |
| 1098 | 1098 | }; |
| 1099 | 1099 | |
| 1100 | +/* | |
| 1101 | + * parser_lock - Protects trace_parser state against concurrent operations. | |
| 1102 | + * Held across trace_get_user() and subsequent buffer parsing to prevent races. | |
| 1103 | + */ | |
| 1104 | +static DEFINE_MUTEX(parser_lock); | |
| 1105 | + | |
| 1100 | 1106 | /* |
| 1101 | 1107 | * Used by the stack unwinder to know about dynamic ftrace trampolines. |
| 1102 | 1108 | */ |
| @@ -5842,6 +5848,8 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, · 4739 unmodified lines | ||
| 5842 | 5848 | /* iter->hash is a local copy, so we don't need regex_lock */ |
| 5843 | 5849 | |
| 5844 | 5850 | parser = &iter->parser; |
| 5851 | + | |
| 5852 | + guard(mutex)(&parser_lock); | |
| 5845 | 5853 | read = trace_get_user(parser, ubuf, cnt, ppos); |
| 5846 | 5854 | |
| 5847 | 5855 | if (read >= 0 && trace_parser_loaded(parser) && |
| @@ -6984,12 +6992,14 @@ int ftrace_regex_release(struct inode *inode, struct file *file) · 1136 unmodified lines | ||
| 6984 | 6992 | iter = file->private_data; |
| 6985 | 6993 | |
| 6986 | 6994 | parser = &iter->parser; |
| 6995 | + mutex_lock(&parser_lock); | |
| 6987 | 6996 | if (trace_parser_loaded(parser)) { |
| 6988 | 6997 | int enable = !(iter->flags & FTRACE_ITER_NOTRACE); |
| 6989 | 6998 | |
| 6990 | 6999 | ftrace_process_regex(iter, parser->buffer, |
| 6991 | 7000 | parser->idx, enable); |
| 6992 | 7001 | } |
| 7002 | + mutex_unlock(&parser_lock); | |
| 6993 | 7003 | |
| 6994 | 7004 | trace_parser_put(parser); |
| 6995 | 7005 | |
| @@ -7321,10 +7331,12 @@ ftrace_graph_release(struct inode *inode, struct file *file) · 325 unmodified lines | ||
| 7321 | 7331 | |
| 7322 | 7332 | parser = &fgd->parser; |
| 7323 | 7333 | |
| 7334 | + mutex_lock(&parser_lock); | |
| 7324 | 7335 | if (trace_parser_loaded((parser))) { |
| 7325 | 7336 | ret = ftrace_graph_set_hash(fgd->new_hash, |
| 7326 | 7337 | parser->buffer); |
| 7327 | 7338 | } |
| 7339 | + mutex_unlock(&parser_lock); | |
| 7328 | 7340 | |
| 7329 | 7341 | trace_parser_put(parser); |
| 7330 | 7342 | |
| @@ -7437,6 +7449,7 @@ ftrace_graph_write(struct file *file, const char __user *ubuf, · 106 unmodified lines | ||
| 7437 | 7449 | |
| 7438 | 7450 | parser = &fgd->parser; |
| 7439 | 7451 | |
| 7452 | + guard(mutex)(&parser_lock); | |
| 7440 | 7453 | read = trace_get_user(parser, ubuf, cnt, ppos); |
| 7441 | 7454 | |
| 7442 | 7455 | if (read >= 0 && trace_parser_loaded(parser) && |
| @@ -6187,7 +6187,7 @@ char *trace_user_fault_read(struct trace_user_buf_info *tinfo, · 6186 unmodified lines | ||
| 6187 | 6187 | { |
| 6188 | 6188 | int cpu = smp_processor_id(); |
| 6189 | 6189 | char *buffer = per_cpu_ptr(tinfo->tbuf, cpu)->buf; |
| 6190 | − unsigned int cnt; | |
| 6190 | + unsigned long long cnt; | |
| 6191 | 6191 | int trys = 0; |
| 6192 | 6192 | int ret; |
| 6193 | 6193 | |
| @@ -1941,6 +1941,7 @@ struct event_trigger_data { · 1940 unmodified lines | ||
| 1941 | 1941 | struct list_head named_list; |
| 1942 | 1942 | struct event_trigger_data *named_data; |
| 1943 | 1943 | struct llist_node llist; |
| 1944 | + void (*private_data_free)(struct event_trigger_data *data); | |
| 1944 | 1945 | }; |
| 1945 | 1946 | |
| 1946 | 1947 | /* Avoid typos */ |
| @@ -172,7 +172,8 @@ static bool eprobe_dyn_event_match(const char *system, const char *event, · 171 unmodified lines | ||
| 172 | 172 | if (!slash) |
| 173 | 173 | return false; |
| 174 | 174 | |
| 175 | − if (strncmp(ep->event_system, argv[0], slash - argv[0])) | |
| 175 | + if (strncmp(ep->event_system, argv[0], slash - argv[0]) || | |
| 176 | + ep->event_system[slash - argv[0]] != '\0') | |
| 176 | 177 | return false; |
| 177 | 178 | if (strcmp(ep->event_name, slash + 1)) |
| 178 | 179 | return false; |
| @@ -1350,7 +1350,9 @@ __ftrace_set_clr_event_nolock(struct trace_array *tr, const char *match, · 1349 unmodified lines | ||
| 1350 | 1350 | call = file->event_call; |
| 1351 | 1351 | |
| 1352 | 1352 | /* If a module is specified, skip events that are not that module */ |
| 1353 | − if (module && (!call->module || strcmp(module_name(call->module), module))) | |
| 1353 | + if (module && | |
| 1354 | + ((call->flags & TRACE_EVENT_FL_DYNAMIC) || | |
| 1355 | + !call->module || strcmp(module_name(call->module), module))) | |
| 1354 | 1356 | continue; |
| 1355 | 1357 | |
| 1356 | 1358 | name = trace_event_name(call); |
| @@ -6349,6 +6349,7 @@ static void event_hist_trigger_free(struct event_trigger_data *data) · 6348 unmodified lines | ||
| 6349 | 6349 | |
| 6350 | 6350 | trigger_data_free(data); |
| 6351 | 6351 | |
| 6352 | + tracepoint_synchronize_unregister(); | |
| 6352 | 6353 | remove_hist_vars(hist_data); |
| 6353 | 6354 | |
| 6354 | 6355 | unregister_field_var_hists(hist_data); |
| @@ -6388,6 +6389,7 @@ static void event_hist_trigger_named_free(struct event_trigger_data *data) · 33 unmodified lines | ||
| 6388 | 6389 | |
| 6389 | 6390 | del_named_trigger(data); |
| 6390 | 6391 | trigger_data_free(data); |
| 6392 | + tracepoint_synchronize_unregister(); | |
| 6391 | 6393 | kfree(cmd_ops); |
| 6392 | 6394 | } |
| 6393 | 6395 | } |
| @@ -38,6 +38,13 @@ static void trigger_create_kthread_locked(void) · 37 unmodified lines | ||
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | +static void trigger_data_free_one(struct event_trigger_data *data) | |
| 42 | +{ | |
| 43 | + if (data->private_data_free) | |
| 44 | + data->private_data_free(data); | |
| 45 | + kfree(data); | |
| 46 | +} | |
| 47 | + | |
| 41 | 48 | static void trigger_data_free_queued_locked(void) |
| 42 | 49 | { |
| 43 | 50 | struct event_trigger_data *data, *tmp; |
| @@ -52,7 +59,7 @@ static void trigger_data_free_queued_locked(void) · 8 unmodified lines | ||
| 52 | 59 | tracepoint_synchronize_unregister(); |
| 53 | 60 | |
| 54 | 61 | llist_for_each_entry_safe(data, tmp, llnodes, llist) |
| 55 | − kfree(data); | |
| 62 | + trigger_data_free_one(data); | |
| 56 | 63 | } |
| 57 | 64 | |
| 58 | 65 | /* Bulk garbage collection of event_trigger_data elements */ |
| @@ -75,7 +82,7 @@ static int trigger_kthread_fn(void *ignore) · 16 unmodified lines | ||
| 75 | 82 | tracepoint_synchronize_unregister(); |
| 76 | 83 | |
| 77 | 84 | llist_for_each_entry_safe(data, tmp, llnodes, llist) |
| 78 | − kfree(data); | |
| 85 | + trigger_data_free_one(data); | |
| 79 | 86 | } |
| 80 | 87 | |
| 81 | 88 | return 0; |
| @@ -1717,6 +1724,14 @@ int event_enable_trigger_print(struct seq_file *m, · 1635 unmodified lines | ||
| 1717 | 1724 | return 0; |
| 1718 | 1725 | } |
| 1719 | 1726 | |
| 1727 | +static void enable_trigger_private_data_free(struct event_trigger_data *data) | |
| 1728 | +{ | |
| 1729 | + struct enable_trigger_data *enable_data = data->private_data; | |
| 1730 | + | |
| 1731 | + trace_event_put_ref(enable_data->file->event_call); | |
| 1732 | + kfree(enable_data); | |
| 1733 | +} | |
| 1734 | + | |
| 1720 | 1735 | void event_enable_trigger_free(struct event_trigger_data *data) |
| 1721 | 1736 | { |
| 1722 | 1737 | struct enable_trigger_data *enable_data = data->private_data; |
| @@ -1728,9 +1743,8 @@ void event_enable_trigger_free(struct event_trigger_data *data) · 5 unmodified lines | ||
| 1728 | 1743 | if (!data->ref) { |
| 1729 | 1744 | /* Remove the SOFT_MODE flag */ |
| 1730 | 1745 | trace_event_enable_disable(enable_data->file, 0, 1); |
| 1731 | − trace_event_put_ref(enable_data->file->event_call); | |
| 1746 | + data->private_data_free = enable_trigger_private_data_free; | |
| 1732 | 1747 | trigger_data_free(data); |
| 1733 | − kfree(enable_data); | |
| 1734 | 1748 | } |
| 1735 | 1749 | } |
| 1736 | 1750 | |
| @@ -109,7 +109,6 @@ static void mmio_pipe_open(struct trace_iterator *iter) · 108 unmodified lines | ||
| 109 | 109 | iter->private = hiter; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | −/* XXX: This is not called when the pipe is closed! */ | |
| 113 | 112 | static void mmio_close(struct trace_iterator *iter) |
| 114 | 113 | { |
| 115 | 114 | struct header_iter *hiter = iter->private; |
| @@ -146,7 +145,7 @@ static ssize_t mmio_read(struct trace_iterator *iter, struct file *filp, · 30 unmodified lines | ||
| 146 | 145 | goto print_out; |
| 147 | 146 | } |
| 148 | 147 | |
| 149 | − if (!hiter) | |
| 148 | + if (!hiter || !hiter->dev) | |
| 150 | 149 | return 0; |
| 151 | 150 | |
| 152 | 151 | mmio_print_pcidev(s, hiter->dev); |
| @@ -279,6 +278,7 @@ static struct tracer mmio_tracer __read_mostly = · 126 unmodified lines | ||
| 279 | 278 | .start = mmio_trace_start, |
| 280 | 279 | .pipe_open = mmio_pipe_open, |
| 281 | 280 | .close = mmio_close, |
| 281 | + .pipe_close = mmio_close, | |
| 282 | 282 | .read = mmio_read, |
| 283 | 283 | .print_line = mmio_print_line, |
| 284 | 284 | .noboot = true, |
| @@ -188,7 +188,7 @@ void __trace_probe_log_err(int offset, int err_type) · 187 unmodified lines | ||
| 188 | 188 | |
| 189 | 189 | lockdep_assert_held(&dyn_event_ops_mutex); |
| 190 | 190 | |
| 191 | − if (!trace_probe_log.argv) | |
| 191 | + if (!trace_probe_log.argv || !trace_probe_log.argc) | |
| 192 | 192 | return; |
| 193 | 193 | |
| 194 | 194 | /* Recalculate the length and allocate buffer */ |
| @@ -2013,7 +2013,7 @@ int traceprobe_update_arg(struct probe_arg *arg) · 1818 unmodified lines | ||
| 2013 | 2013 | } |
| 2014 | 2014 | |
| 2015 | 2015 | /* When len=0, we just calculate the needed length */ |
| 2016 | −#define LEN_OR_ZERO (len ? len - pos : 0) | |
| 2016 | +#define LEN_OR_ZERO (len > pos ? len - pos : 0) | |
| 2017 | 2017 | static int __set_print_fmt(struct trace_probe *tp, char *buf, int len, |
| 2018 | 2018 | enum probe_print_type ptype) |
| 2019 | 2019 | { |
| @@ -2338,16 +2338,17 @@ int trace_probe_compare_arg_type(struct trace_probe *a, struct trace_probe *b) · 318 unmodified lines | ||
| 2338 | 2338 | bool trace_probe_match_command_args(struct trace_probe *tp, |
| 2339 | 2339 | int argc, const char **argv) |
| 2340 | 2340 | { |
| 2341 | − char buf[MAX_ARGSTR_LEN + 1]; | |
| 2342 | 2341 | int i; |
| 2343 | 2342 | |
| 2344 | 2343 | if (tp->nr_args < argc) |
| 2345 | 2344 | return false; |
| 2346 | 2345 | |
| 2347 | 2346 | for (i = 0; i < argc; i++) { |
| 2348 | − snprintf(buf, sizeof(buf), "%s=%s", | |
| 2349 | − tp->args[i].name, tp->args[i].comm); | |
| 2350 | − if (strcmp(buf, argv[i])) | |
| 2347 | + int len = strlen(tp->args[i].name); | |
| 2348 | + | |
| 2349 | + if (strncmp(argv[i], tp->args[i].name, len) || | |
| 2350 | + argv[i][len] != '=' || | |
| 2351 | + strcmp(argv[i] + len + 1, tp->args[i].comm)) | |
| 2351 | 2352 | return false; |
| 2352 | 2353 | } |
| 2353 | 2354 | return true; |
| @@ -1004,11 +1004,10 @@ int trace_remote_alloc_buffer(struct trace_buffer_desc *desc, size_t desc_size, · 1003 unmodified lines | ||
| 1004 | 1004 | desc->nr_cpus++; |
| 1005 | 1005 | |
| 1006 | 1006 | for (id = 0; id < nr_pages; id++) { |
| 1007 | + rb_desc->nr_page_va++; | |
| 1007 | 1008 | rb_desc->page_va[id] = (unsigned long)__get_free_page(GFP_KERNEL); |
| 1008 | 1009 | if (!rb_desc->page_va[id]) |
| 1009 | 1010 | goto err; |
| 1010 | − | |
| 1011 | − rb_desc->nr_page_va++; | |
| 1012 | 1011 | } |
| 1013 | 1012 | rb_desc = __next_ring_buffer_desc(rb_desc); |
| 1014 | 1013 | } |
| @@ -1150,10 +1149,21 @@ static ssize_t remote_events_dir_enable_write(struct file *filp, const char __us · 135 unmodified lines | ||
| 1150 | 1149 | |
| 1151 | 1150 | for (i = 0; i < remote->nr_events; i++) { |
| 1152 | 1151 | struct remote_event *evt = &remote->events[i]; |
| 1152 | + int eret; | |
| 1153 | 1153 | |
| 1154 | − trace_remote_enable_event(remote, evt, enable); | |
| 1154 | + eret = trace_remote_enable_event(remote, evt, enable); | |
| 1155 | + /* | |
| 1156 | + * Save the first error and return that. Some events | |
| 1157 | + * may still have been enabled, but let the user | |
| 1158 | + * know that something went wrong. | |
| 1159 | + */ | |
| 1160 | + if (!ret && eret) | |
| 1161 | + ret = eret; | |
| 1155 | 1162 | } |
| 1156 | 1163 | |
| 1164 | + if (ret) | |
| 1165 | + return ret; | |
| 1166 | + | |
| 1157 | 1167 | return count; |
| 1158 | 1168 | } |
| 1159 | 1169 | |
| @@ -1451,6 +1451,11 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id) · 1450 unmodified lines | ||
| 1451 | 1451 | if (syscall_get_data(sys_data, args, &user_ptr, |
| 1452 | 1452 | &size, user_sizes, &uargs, buf_size) < 0) |
| 1453 | 1453 | return; |
| 1454 | + | |
| 1455 | + /* The above may have caused a migration */ | |
| 1456 | + head = this_cpu_ptr(sys_data->enter_event->perf_events); | |
| 1457 | + if (hlist_empty(head)) | |
| 1458 | + return; | |
| 1454 | 1459 | } |
| 1455 | 1460 | |
| 1456 | 1461 | /* get the size after alignment with the u32 buffer size field */ |
| @@ -26,6 +26,15 @@ static bool mem_profiling_support = true; · 25 unmodified lines | ||
| 26 | 26 | static bool mem_profiling_support; |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | +/* | |
| 30 | + * Memory allocation profiling is permanently disabled and cannot be enabled. | |
| 31 | + * Must be called after setup_early_mem_profiling(). | |
| 32 | + */ | |
| 33 | +bool mem_alloc_profiling_permanently_disabled(void) | |
| 34 | +{ | |
| 35 | + return !mem_profiling_support; | |
| 36 | +} | |
| 37 | + | |
| 29 | 38 | static struct codetag_type *alloc_tag_cttype; |
| 30 | 39 | |
| 31 | 40 | #ifdef CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPU |
| @@ -878,6 +878,7 @@ int rhashtable_walk_start_check(struct rhashtable_iter *iter) · 877 unmodified lines | ||
| 878 | 878 | iter->walker.tbl = rht_dereference_rcu(ht->tbl, ht); |
| 879 | 879 | iter->slot = 0; |
| 880 | 880 | iter->skip = 0; |
| 881 | + iter->p = NULL; | |
| 881 | 882 | return -EAGAIN; |
| 882 | 883 | } |
| 883 | 884 | |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* |
| 3 | 3 | * Data Access Monitor |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #define pr_fmt(fmt) "damon: " fmt |
| @@ -356,8 +354,21 @@ int damon_set_regions(struct damon_target *t, struct damon_addr_range *ranges, · 347 unmodified lines | ||
| 356 | 354 | { |
| 357 | 355 | struct damon_region *r, *next; |
| 358 | 356 | unsigned int i; |
| 357 | + unsigned long last_end; | |
| 359 | 358 | int err; |
| 360 | 359 | |
| 360 | + for (i = 0; i < nr_ranges; i++) { | |
| 361 | + unsigned long start, end; | |
| 362 | + | |
| 363 | + start = ALIGN_DOWN(ranges[i].start, min_region_sz); | |
| 364 | + end = ALIGN(ranges[i].end, min_region_sz); | |
| 365 | + if (start >= end) | |
| 366 | + return -EINVAL; | |
| 367 | + if (i > 0 && last_end > start) | |
| 368 | + return -EINVAL; | |
| 369 | + last_end = end; | |
| 370 | + } | |
| 371 | + | |
| 361 | 372 | /* Remove regions which are not in the new ranges */ |
| 362 | 373 | damon_for_each_region_safe(r, next, t) { |
| 363 | 374 | for (i = 0; i < nr_ranges; i++) { |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* |
| 3 | 3 | * DAMON-based LRU-lists Sorting |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #define pr_fmt(fmt) "damon-lru-sort: " fmt |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* |
| 3 | 3 | * Common Code for DAMON Modules |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #include <linux/damon.h> |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | 2 | /* |
| 3 | 3 | * Common Code for DAMON Modules |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #include <linux/moduleparam.h> |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* |
| 3 | 3 | * Common Code for Data Access Monitoring |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #include <linux/migrate.h> |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | 2 | /* |
| 3 | 3 | * Common Code for Data Access Monitoring |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #include <linux/damon.h> |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* |
| 3 | 3 | * DAMON Code for The Physical Address Space |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #define pr_fmt(fmt) "damon-pa: " fmt |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* |
| 3 | 3 | * DAMON-based page reclamation |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #define pr_fmt(fmt) "damon-reclaim: " fmt |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* |
| 3 | 3 | * Common Code for DAMON Sysfs Interface |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #include <linux/slab.h> |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | 2 | /* |
| 3 | 3 | * Common Code for DAMON Sysfs Interface |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #include <linux/damon.h> |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* |
| 3 | 3 | * DAMON sysfs Interface |
| 4 | − * | |
| 5 | − * Copyright (c) 2022 SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #include <linux/slab.h> |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* |
| 3 | 3 | * DAMON sysfs Interface |
| 4 | − * | |
| 5 | − * Copyright (c) 2022 SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #include <linux/pid.h> |
| @@ -1,10 +1,6 @@ | ||
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | 2 | /* |
| 3 | 3 | * Data Access Monitor Unit Tests |
| 4 | − * | |
| 5 | − * Copyright 2019 Amazon.com, Inc. or its affiliates. All rights reserved. | |
| 6 | − * | |
| 7 | − * Author: SeongJae Park <sj@kernel.org> | |
| 8 | 4 | */ |
| 9 | 5 | |
| 10 | 6 | #ifdef CONFIG_DAMON_KUNIT_TEST |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | 2 | /* |
| 3 | 3 | * Data Access Monitor Unit Tests |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #ifdef CONFIG_DAMON_SYSFS_KUNIT_TEST |
| @@ -1,10 +1,6 @@ | ||
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | 2 | /* |
| 3 | 3 | * Data Access Monitor Unit Tests |
| 4 | − * | |
| 5 | − * Copyright 2019 Amazon.com, Inc. or its affiliates. All rights reserved. | |
| 6 | − * | |
| 7 | − * Author: SeongJae Park <sj@kernel.org> | |
| 8 | 4 | */ |
| 9 | 5 | |
| 10 | 6 | #ifdef CONFIG_DAMON_VADDR_KUNIT_TEST |
| @@ -1,8 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* |
| 3 | 3 | * DAMON Code for Virtual Address Spaces |
| 4 | − * | |
| 5 | − * Author: SeongJae Park <sj@kernel.org> | |
| 6 | 4 | */ |
| 7 | 5 | |
| 8 | 6 | #define pr_fmt(fmt) "damon-va: " fmt |
| @@ -3587,10 +3587,6 @@ static void __split_folio_to_order(struct folio *folio, int old_order, · 3586 unmodified lines | ||
| 3587 | 3587 | (1L << PG_dropbehind) | |
| 3588 | 3588 | LRU_GEN_MASK | LRU_REFS_MASK)); |
| 3589 | 3589 | |
| 3590 | − if (handle_hwpoison && | |
| 3591 | − page_range_has_hwpoisoned(new_head, new_nr_pages)) | |
| 3592 | − folio_set_has_hwpoisoned(new_folio); | |
| 3593 | − | |
| 3594 | 3590 | new_folio->mapping = folio->mapping; |
| 3595 | 3591 | new_folio->index = folio->index + i; |
| 3596 | 3592 | |
| @@ -3612,6 +3608,14 @@ static void __split_folio_to_order(struct folio *folio, int old_order, · 15 unmodified lines | ||
| 3612 | 3608 | folio_set_large_rmappable(new_folio); |
| 3613 | 3609 | } |
| 3614 | 3610 | |
| 3611 | + /* | |
| 3612 | + * PG_has_hwpoisoned is on the 2nd page, so set it after | |
| 3613 | + * the compound head is prepped. | |
| 3614 | + */ | |
| 3615 | + if (handle_hwpoison && | |
| 3616 | + page_range_has_hwpoisoned(new_head, new_nr_pages)) | |
| 3617 | + folio_set_has_hwpoisoned(new_folio); | |
| 3618 | + | |
| 3615 | 3619 | if (folio_test_young(folio)) |
| 3616 | 3620 | folio_set_young(new_folio); |
| 3617 | 3621 | if (folio_test_idle(folio)) |
| @@ -687,7 +687,7 @@ static struct kmemleak_object *__alloc_object(gfp_t gfp) · 686 unmodified lines | ||
| 687 | 687 | atomic_set(&object->use_count, 1); |
| 688 | 688 | object->excess_ref = 0; |
| 689 | 689 | object->count = 0; /* white color initially */ |
| 690 | − object->checksum = 0; | |
| 690 | + object->checksum = ~0; | |
| 691 | 691 | object->del_state = 0; |
| 692 | 692 | |
| 693 | 693 | /* task information */ |
| @@ -981,7 +981,7 @@ static void reset_checksum(unsigned long ptr) · 287 unmodified lines | ||
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | raw_spin_lock_irqsave(&object->lock, flags); |
| 984 | − object->checksum = 0; | |
| 984 | + object->checksum = ~0; | |
| 985 | 985 | raw_spin_unlock_irqrestore(&object->lock, flags); |
| 986 | 986 | put_object(object); |
| 987 | 987 | } |
| @@ -1410,7 +1410,8 @@ static bool update_checksum(struct kmemleak_object *object) · 422 unmodified lines | ||
| 1410 | 1410 | for_each_possible_cpu(cpu) { |
| 1411 | 1411 | void *ptr = per_cpu_ptr((void __percpu *)object->pointer, cpu); |
| 1412 | 1412 | |
| 1413 | − object->checksum ^= crc32(0, kasan_reset_tag((void *)ptr), object->size); | |
| 1413 | + object->checksum = crc32(object->checksum, | |
| 1414 | + kasan_reset_tag((void *)ptr), object->size); | |
| 1414 | 1415 | } |
| 1415 | 1416 | } else { |
| 1416 | 1417 | object->checksum = crc32(0, kasan_reset_tag((void *)object->pointer), object->size); |
| @@ -173,11 +173,8 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, · 172 unmodified lines | ||
| 173 | 173 | * any pages that may have already been present from the previous |
| 174 | 174 | * list processed. This should result in us reporting all pages on |
| 175 | 175 | * an idle system in about 30 seconds. |
| 176 | − * | |
| 177 | − * The division here should be cheap since PAGE_REPORTING_CAPACITY | |
| 178 | − * should always be a power of 2. | |
| 179 | 176 | */ |
| 180 | − budget = DIV_ROUND_UP(area->nr_free, PAGE_REPORTING_CAPACITY * 16); | |
| 177 | + budget = DIV_ROUND_UP(area->nr_free, prdev->capacity * 16); | |
| 181 | 178 | |
| 182 | 179 | /* loop through free list adding unreported pages to sg list */ |
| 183 | 180 | list_for_each_entry_safe(page, next, list, lru) { |
| @@ -222,10 +219,10 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, · 38 unmodified lines | ||
| 222 | 219 | spin_unlock_irq(&zone->lock); |
| 223 | 220 | |
| 224 | 221 | /* begin processing pages in local list */ |
| 225 | − err = prdev->report(prdev, sgl, PAGE_REPORTING_CAPACITY); | |
| 222 | + err = prdev->report(prdev, sgl, prdev->capacity); | |
| 226 | 223 | |
| 227 | 224 | /* reset offset since the full list was reported */ |
| 228 | − *offset = PAGE_REPORTING_CAPACITY; | |
| 225 | + *offset = prdev->capacity; | |
| 229 | 226 | |
| 230 | 227 | /* update budget to reflect call to report function */ |
| 231 | 228 | budget--; |
| @@ -234,7 +231,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, · 2 unmodified lines | ||
| 234 | 231 | spin_lock_irq(&zone->lock); |
| 235 | 232 | |
| 236 | 233 | /* flush reported pages from the sg list */ |
| 237 | − page_reporting_drain(prdev, sgl, PAGE_REPORTING_CAPACITY, !err); | |
| 234 | + page_reporting_drain(prdev, sgl, prdev->capacity, !err); | |
| 238 | 235 | |
| 239 | 236 | /* |
| 240 | 237 | * Reset next to first entry, the old next isn't valid |
| @@ -260,13 +257,13 @@ static int · 19 unmodified lines | ||
| 260 | 257 | page_reporting_process_zone(struct page_reporting_dev_info *prdev, |
| 261 | 258 | struct scatterlist *sgl, struct zone *zone) |
| 262 | 259 | { |
| 263 | − unsigned int order, mt, leftover, offset = PAGE_REPORTING_CAPACITY; | |
| 260 | + unsigned int order, mt, leftover, offset = prdev->capacity; | |
| 264 | 261 | unsigned long watermark; |
| 265 | 262 | int err = 0; |
| 266 | 263 | |
| 267 | 264 | /* Generate minimum watermark to be able to guarantee progress */ |
| 268 | 265 | watermark = low_wmark_pages(zone) + |
| 269 | − (PAGE_REPORTING_CAPACITY << page_reporting_order); | |
| 266 | + (prdev->capacity << page_reporting_order); | |
| 270 | 267 | |
| 271 | 268 | /* |
| 272 | 269 | * Cancel request if insufficient free memory or if we failed |
| @@ -290,7 +287,7 @@ page_reporting_process_zone(struct page_reporting_dev_info *prdev, · 17 unmodified lines | ||
| 290 | 287 | } |
| 291 | 288 | |
| 292 | 289 | /* report the leftover pages before going idle */ |
| 293 | − leftover = PAGE_REPORTING_CAPACITY - offset; | |
| 290 | + leftover = prdev->capacity - offset; | |
| 294 | 291 | if (leftover) { |
| 295 | 292 | sgl = &sgl[offset]; |
| 296 | 293 | err = prdev->report(prdev, sgl, leftover); |
| @@ -322,11 +319,11 @@ static void page_reporting_process(struct work_struct *work) · 25 unmodified lines | ||
| 322 | 319 | atomic_set(&prdev->state, state); |
| 323 | 320 | |
| 324 | 321 | /* allocate scatterlist to store pages being reported on */ |
| 325 | − sgl = kmalloc_objs(*sgl, PAGE_REPORTING_CAPACITY); | |
| 322 | + sgl = kmalloc_objs(*sgl, prdev->capacity); | |
| 326 | 323 | if (!sgl) |
| 327 | 324 | goto err_out; |
| 328 | 325 | |
| 329 | − sg_init_table(sgl, PAGE_REPORTING_CAPACITY); | |
| 326 | + sg_init_table(sgl, prdev->capacity); | |
| 330 | 327 | |
| 331 | 328 | for_each_zone(zone) { |
| 332 | 329 | err = page_reporting_process_zone(prdev, sgl, zone); |
| @@ -377,6 +374,9 @@ int page_reporting_register(struct page_reporting_dev_info *prdev) · 44 unmodified lines | ||
| 377 | 374 | page_reporting_order = pageblock_order; |
| 378 | 375 | } |
| 379 | 376 | |
| 377 | + if (!prdev->capacity || prdev->capacity > PAGE_REPORTING_CAPACITY) | |
| 378 | + prdev->capacity = PAGE_REPORTING_CAPACITY; | |
| 379 | + | |
| 380 | 380 | /* initialize state and work structures */ |
| 381 | 381 | atomic_set(&prdev->state, PAGE_REPORTING_IDLE); |
| 382 | 382 | INIT_DELAYED_WORK(&prdev->work, &page_reporting_process); |
| @@ -243,21 +243,31 @@ restart: · 242 unmodified lines | ||
| 243 | 243 | */ |
| 244 | 244 | pmde = pmdp_get_lockless(pvmw->pmd); |
| 245 | 245 | |
| 246 | − if (pmd_trans_huge(pmde) || pmd_is_migration_entry(pmde)) { | |
| 246 | + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && | |
| 247 | + (pmd_trans_huge(pmde) || pmd_is_migration_entry(pmde) || | |
| 248 | + pmd_is_device_private_entry(pmde))) { | |
| 247 | 249 | pvmw->ptl = pmd_lock(mm, pvmw->pmd); |
| 248 | 250 | pmde = *pvmw->pmd; |
| 249 | − if (!pmd_present(pmde)) { | |
| 251 | + if (pmd_is_migration_entry(pmde)) { | |
| 250 | 252 | softleaf_t entry; |
| 251 | 253 | |
| 252 | − if (!thp_migration_supported() || | |
| 253 | − !(pvmw->flags & PVMW_MIGRATION)) | |
| 254 | + if (!(pvmw->flags & PVMW_MIGRATION)) | |
| 254 | 255 | return not_found(pvmw); |
| 255 | 256 | entry = softleaf_from_pmd(pmde); |
| 257 | + if (!check_pmd(softleaf_to_pfn(entry), pvmw)) | |
| 258 | + return not_found(pvmw); | |
| 259 | + return true; | |
| 260 | + } else if (pmd_is_device_private_entry(pmde)) { | |
| 261 | + softleaf_t entry; | |
| 256 | 262 | |
| 257 | − if (!softleaf_is_migration(entry) || | |
| 258 | − !check_pmd(softleaf_to_pfn(entry), pvmw)) | |
| 263 | + if (pvmw->flags & PVMW_MIGRATION) | |
| 264 | + return not_found(pvmw); | |
| 265 | + entry = softleaf_from_pmd(pmde); | |
| 266 | + if (!check_pmd(softleaf_to_pfn(entry), pvmw)) | |
| 259 | 267 | return not_found(pvmw); |
| 260 | 268 | return true; |
| 269 | + } else if (!pmd_present(pmde)) { | |
| 270 | + return not_found(pvmw); | |
| 261 | 271 | } |
| 262 | 272 | if (likely(pmd_trans_huge(pmde))) { |
| 263 | 273 | if (pvmw->flags & PVMW_MIGRATION) |
| @@ -266,17 +276,10 @@ restart: · 2 unmodified lines | ||
| 266 | 276 | return not_found(pvmw); |
| 267 | 277 | return true; |
| 268 | 278 | } |
| 269 | − /* THP pmd was split under us: handle on pte level */ | |
| 279 | + /* THP/device-private pmd was split under us: handle on pte level */ | |
| 270 | 280 | spin_unlock(pvmw->ptl); |
| 271 | 281 | pvmw->ptl = NULL; |
| 272 | 282 | } else if (!pmd_present(pmde)) { |
| 273 | − const softleaf_t entry = softleaf_from_pmd(pmde); | |
| 274 | − | |
| 275 | − if (softleaf_is_device_private(entry)) { | |
| 276 | − pvmw->ptl = pmd_lock(mm, pvmw->pmd); | |
| 277 | − return true; | |
| 278 | − } | |
| 279 | − | |
| 280 | 283 | if ((pvmw->flags & PVMW_SYNC) && |
| 281 | 284 | thp_vma_suitable_order(vma, pvmw->address, |
| 282 | 285 | PMD_ORDER) && |
| @@ -846,6 +846,16 @@ static long shmem_unused_huge_count(struct super_block *sb, · 845 unmodified lines | ||
| 846 | 846 | struct shrink_control *sc) |
| 847 | 847 | { |
| 848 | 848 | struct shmem_sb_info *sbinfo = SHMEM_SB(sb); |
| 849 | + | |
| 850 | + /* | |
| 851 | + * The per-superblock shrinklist is filesystem-global and does not | |
| 852 | + * honour sc->memcg, so it is only meaningful on the global (kswapd or | |
| 853 | + * root direct reclaim) shrink path. Skip the per-memcg iterations of | |
| 854 | + * shrink_slab_memcg() to avoid queueing duplicate global work. | |
| 855 | + */ | |
| 856 | + if (!mem_cgroup_shrink_is_root(sc)) | |
| 857 | + return 0; | |
| 858 | + | |
| 849 | 859 | return READ_ONCE(sbinfo->shrinklist_len); |
| 850 | 860 | } |
| 851 | 861 | #else /* !CONFIG_TRANSPARENT_HUGEPAGE */ |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | #define SLAB_ALLOC_NOLOCK 0x01 /* a kmalloc_nolock() allocation */ |
| 23 | 23 | #define SLAB_ALLOC_NEW_SLAB 0x02 /* a flag for alloc_slab_obj_exts() */ |
| 24 | 24 | #define SLAB_ALLOC_NO_RECURSE 0x04 /* prevent kmalloc() recursion */ |
| 25 | +#define SLAB_ALLOC_NO_OBJ_EXT 0x08 /* prevent obj_exts array allocation */ | |
| 25 | 26 | |
| 26 | 27 | static inline bool alloc_flags_allow_spinning(const unsigned int alloc_flags) |
| 27 | 28 | { |
| @@ -386,12 +387,17 @@ static inline unsigned int size_index_elem(unsigned int bytes) · 358 unmodified lines | ||
| 386 | 387 | * KMALLOC_MAX_CACHE_SIZE and the caller must check that. |
| 387 | 388 | */ |
| 388 | 389 | static inline struct kmem_cache * |
| 389 | −kmalloc_slab(size_t size, kmem_buckets *b, gfp_t flags, kmalloc_token_t token) | |
| 390 | +kmalloc_slab(size_t size, kmem_buckets *b, gfp_t flags, kmalloc_token_t token, | |
| 391 | + unsigned int alloc_flags) | |
| 390 | 392 | { |
| 391 | 393 | unsigned int index; |
| 394 | + enum kmalloc_cache_type type = kmalloc_type(flags, token); | |
| 395 | + | |
| 396 | + if (alloc_flags & SLAB_ALLOC_NO_OBJ_EXT) | |
| 397 | + type = KMALLOC_NO_OBJ_EXT; | |
| 392 | 398 | |
| 393 | 399 | if (!b) |
| 394 | − b = &kmalloc_caches[kmalloc_type(flags, token)]; | |
| 400 | + b = &kmalloc_caches[type]; | |
| 395 | 401 | if (size <= 192) |
| 396 | 402 | index = kmalloc_size_index[size_index_elem(size)]; |
| 397 | 403 | else |
| @@ -426,7 +432,8 @@ static inline bool is_kmalloc_normal(struct kmem_cache *s) · 28 unmodified lines | ||
| 426 | 432 | { |
| 427 | 433 | if (!is_kmalloc_cache(s)) |
| 428 | 434 | return false; |
| 429 | − return !(s->flags & (SLAB_CACHE_DMA|SLAB_ACCOUNT|SLAB_RECLAIM_ACCOUNT)); | |
| 435 | + | |
| 436 | + return !(s->flags & (SLAB_CACHE_DMA|SLAB_ACCOUNT|SLAB_RECLAIM_ACCOUNT|SLAB_NO_OBJ_EXT)); | |
| 430 | 437 | } |
| 431 | 438 | |
| 432 | 439 | bool __kfree_rcu_sheaf(struct kmem_cache *s, void *obj); |
| @@ -529,6 +536,25 @@ static inline void metadata_access_disable(void) · 96 unmodified lines | ||
| 529 | 536 | kasan_enable_current(); |
| 530 | 537 | } |
| 531 | 538 | |
| 539 | +/* | |
| 540 | + * Return true if KMALLOC_NORMAL caches may need obj_exts arrays. | |
| 541 | + * | |
| 542 | + * Memory allocation profiling requires obj_exts for all caches. | |
| 543 | + * Memcg usually doesn't need them for normal kmalloc caches, but kmalloc types | |
| 544 | + * with a priority higher than KMALLOC_CGROUP can be aliased with KMALLOC_NORMAL. | |
| 545 | + */ | |
| 546 | +static inline bool need_kmalloc_no_objext(void) | |
| 547 | +{ | |
| 548 | + if (!mem_alloc_profiling_permanently_disabled()) | |
| 549 | + return true; | |
| 550 | + | |
| 551 | + if (!mem_cgroup_kmem_disabled() && | |
| 552 | + (KMALLOC_NORMAL == KMALLOC_RECLAIM)) | |
| 553 | + return true; | |
| 554 | + | |
| 555 | + return false; | |
| 556 | +} | |
| 557 | + | |
| 532 | 558 | #ifdef CONFIG_SLAB_OBJ_EXT |
| 533 | 559 | |
| 534 | 560 | /* |
| @@ -783,11 +783,15 @@ u8 kmalloc_size_index[24] __ro_after_init = { · 782 unmodified lines | ||
| 783 | 783 | size_t kmalloc_size_roundup(size_t size) |
| 784 | 784 | { |
| 785 | 785 | if (size && size <= KMALLOC_MAX_CACHE_SIZE) { |
| 786 | + struct kmem_cache *s; | |
| 787 | + | |
| 786 | 788 | /* |
| 787 | 789 | * The flags don't matter since size_index is common to all. |
| 788 | 790 | * Neither does the caller for just getting ->object_size. |
| 789 | 791 | */ |
| 790 | − return kmalloc_slab(size, NULL, GFP_KERNEL, __kmalloc_token(0))->object_size; | |
| 792 | + s = kmalloc_slab(size, NULL, GFP_KERNEL, __kmalloc_token(0), | |
| 793 | + SLAB_ALLOC_DEFAULT); | |
| 794 | + return s->object_size; | |
| 791 | 795 | } |
| 792 | 796 | |
| 793 | 797 | /* Above the smaller buckets, size is a multiple of page size. */ |
| @@ -843,6 +847,12 @@ EXPORT_SYMBOL(kmalloc_size_roundup); · 49 unmodified lines | ||
| 843 | 847 | #define KMALLOC_PARTITION_NAME(N, sz) |
| 844 | 848 | #endif |
| 845 | 849 | |
| 850 | +#ifdef CONFIG_SLAB_OBJ_EXT | |
| 851 | +#define KMALLOC_NO_OBJ_EXT_NAME(sz) .name[KMALLOC_NO_OBJ_EXT] = "kmalloc-no-objext-" #sz, | |
| 852 | +#else | |
| 853 | +#define KMALLOC_NO_OBJ_EXT_NAME(sz) | |
| 854 | +#endif | |
| 855 | + | |
| 846 | 856 | #define INIT_KMALLOC_INFO(__size, __short_size) \ |
| 847 | 857 | { \ |
| 848 | 858 | .name[KMALLOC_NORMAL] = "kmalloc-" #__short_size, \ |
| @@ -850,6 +860,7 @@ EXPORT_SYMBOL(kmalloc_size_roundup); · 1 unmodified line | ||
| 850 | 860 | KMALLOC_CGROUP_NAME(__short_size) \ |
| 851 | 861 | KMALLOC_DMA_NAME(__short_size) \ |
| 852 | 862 | KMALLOC_PARTITION_NAME(KMALLOC_PARTITION_CACHES_NR, __short_size) \ |
| 863 | + KMALLOC_NO_OBJ_EXT_NAME(__short_size) \ | |
| 853 | 864 | .size = __size, \ |
| 854 | 865 | } |
| 855 | 866 | |
| @@ -957,6 +968,12 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type) · 101 unmodified lines | ||
| 957 | 968 | return; |
| 958 | 969 | } |
| 959 | 970 | flags |= SLAB_ACCOUNT; |
| 971 | + } else if (IS_ENABLED(CONFIG_SLAB_OBJ_EXT) && type == KMALLOC_NO_OBJ_EXT) { | |
| 972 | + if (!need_kmalloc_no_objext()) { | |
| 973 | + kmalloc_caches[type][idx] = kmalloc_caches[KMALLOC_NORMAL][idx]; | |
| 974 | + return; | |
| 975 | + } | |
| 976 | + flags |= SLAB_NO_OBJ_EXT | SLAB_NO_MERGE; | |
| 960 | 977 | } else if (IS_ENABLED(CONFIG_ZONE_DMA) && (type == KMALLOC_DMA)) { |
| 961 | 978 | flags |= SLAB_CACHE_DMA; |
| 962 | 979 | } |
| @@ -2123,42 +2123,6 @@ static inline void init_slab_obj_exts(struct slab *slab) · 2122 unmodified lines | ||
| 2123 | 2123 | slab->obj_exts = 0; |
| 2124 | 2124 | } |
| 2125 | 2125 | |
| 2126 | −/* | |
| 2127 | − * Calculate the allocation size for slabobj_ext array. | |
| 2128 | − * | |
| 2129 | − * When memory allocation profiling is enabled, the obj_exts array | |
| 2130 | − * could be allocated from the same slab cache it's being allocated for. | |
| 2131 | − * This would prevent the slab from ever being freed because it would | |
| 2132 | − * always contain at least one allocated object (its own obj_exts array). | |
| 2133 | − * | |
| 2134 | − * To avoid this, increase the allocation size when we detect the array | |
| 2135 | − * may come from the same cache, forcing it to use a different cache. | |
| 2136 | − */ | |
| 2137 | −static inline size_t obj_exts_alloc_size(struct kmem_cache *s, | |
| 2138 | − struct slab *slab, gfp_t gfp) | |
| 2139 | −{ | |
| 2140 | − size_t sz = sizeof(struct slabobj_ext) * slab->objects; | |
| 2141 | − struct kmem_cache *obj_exts_cache; | |
| 2142 | − | |
| 2143 | − if (sz > KMALLOC_MAX_CACHE_SIZE) | |
| 2144 | − return sz; | |
| 2145 | − | |
| 2146 | − if (!is_kmalloc_normal(s)) | |
| 2147 | − return sz; | |
| 2148 | − | |
| 2149 | − obj_exts_cache = kmalloc_slab(sz, NULL, gfp, __kmalloc_token(0)); | |
| 2150 | − /* | |
| 2151 | − * We can't simply compare s with obj_exts_cache, because partitioned kmalloc | |
| 2152 | − * caches have multiple caches per size, selected by caller address or type. | |
| 2153 | − * Since caller address or type may differ between kmalloc_slab() and actual | |
| 2154 | − * allocation, bump size when sizes are equal. | |
| 2155 | − */ | |
| 2156 | − if (s->object_size == obj_exts_cache->object_size) | |
| 2157 | − return obj_exts_cache->object_size + 1; | |
| 2158 | − | |
| 2159 | − return sz; | |
| 2160 | −} | |
| 2161 | − | |
| 2162 | 2126 | int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s, |
| 2163 | 2127 | gfp_t gfp, unsigned int alloc_flags) |
| 2164 | 2128 | { |
| @@ -2168,14 +2132,18 @@ int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s, · 3 unmodified lines | ||
| 2168 | 2132 | unsigned long new_exts; |
| 2169 | 2133 | unsigned long old_exts; |
| 2170 | 2134 | struct slabobj_ext *vec; |
| 2171 | − size_t sz; | |
| 2135 | + size_t sz = sizeof(struct slabobj_ext) * slab->objects; | |
| 2172 | 2136 | |
| 2173 | 2137 | gfp &= ~OBJCGS_CLEAR_MASK; |
| 2174 | − /* Prevent recursive extension vector allocation */ | |
| 2175 | − alloc_flags |= SLAB_ALLOC_NO_RECURSE; | |
| 2176 | − alloc_flags &= ~SLAB_ALLOC_NEW_SLAB; | |
| 2138 | + /* | |
| 2139 | + * In most cases, obj_exts arrays are allocated from normal kmalloc. | |
| 2140 | + * However, normal kmalloc caches must allocate them from | |
| 2141 | + * KMALLOC_NO_OBJ_EXT caches to prevent recursion. | |
| 2142 | + */ | |
| 2143 | + if (is_kmalloc_normal(s)) | |
| 2144 | + alloc_flags |= SLAB_ALLOC_NO_OBJ_EXT; | |
| 2177 | 2145 | |
| 2178 | − sz = obj_exts_alloc_size(s, slab, gfp); | |
| 2146 | + alloc_flags &= ~SLAB_ALLOC_NEW_SLAB; | |
| 2179 | 2147 | |
| 2180 | 2148 | /* This will use kmalloc_nolock() if alloc_flags say so */ |
| 2181 | 2149 | vec = kmalloc_flags(sz, gfp | __GFP_ZERO, alloc_flags, slab_nid(slab)); |
| @@ -2193,8 +2161,21 @@ int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s, · 11 unmodified lines | ||
| 2193 | 2161 | return -ENOMEM; |
| 2194 | 2162 | } |
| 2195 | 2163 | |
| 2196 | − VM_WARN_ON_ONCE(virt_to_slab(vec) != NULL && | |
| 2197 | − virt_to_slab(vec)->slab_cache == s); | |
| 2164 | + if (IS_ENABLED(CONFIG_DEBUG_VM)) { | |
| 2165 | + struct kmem_cache *exts_cache; | |
| 2166 | + struct slab *exts_slab; | |
| 2167 | + | |
| 2168 | + exts_slab = virt_to_slab(vec); | |
| 2169 | + if (exts_slab) { | |
| 2170 | + /* | |
| 2171 | + * The vector must be allocated from either normal or | |
| 2172 | + * KMALLOC_NO_OBJ_EXT kmalloc caches to avoid cycles. | |
| 2173 | + */ | |
| 2174 | + exts_cache = exts_slab->slab_cache; | |
| 2175 | + WARN_ON_ONCE(!is_kmalloc_normal(exts_cache) && | |
| 2176 | + !(exts_cache->flags & SLAB_NO_OBJ_EXT)); | |
| 2177 | + } | |
| 2178 | + } | |
| 2198 | 2179 | |
| 2199 | 2180 | new_exts = (unsigned long)vec; |
| 2200 | 2181 | #ifdef CONFIG_MEMCG |
| @@ -2217,7 +2198,6 @@ retry: · 16 unmodified lines | ||
| 2217 | 2198 | * assign slabobj_exts in parallel. In this case the existing |
| 2218 | 2199 | * objcg vector should be reused. |
| 2219 | 2200 | */ |
| 2220 | − mark_obj_codetag_empty(vec); | |
| 2221 | 2201 | if (unlikely(!allow_spin)) |
| 2222 | 2202 | kfree_nolock(vec); |
| 2223 | 2203 | else |
| @@ -2253,14 +2233,6 @@ static inline void free_slab_obj_exts(struct slab *slab, bool allow_spin) · 29 unmodified lines | ||
| 2253 | 2233 | return; |
| 2254 | 2234 | } |
| 2255 | 2235 | |
| 2256 | − /* | |
| 2257 | − * obj_exts was created with SLAB_ALLOC_NO_RECURSE flag, therefore its | |
| 2258 | − * corresponding extension will be NULL. alloc_tag_sub() will throw a | |
| 2259 | − * warning if slab has extensions but the extension of an object is | |
| 2260 | − * NULL, therefore replace NULL with CODETAG_EMPTY to indicate that | |
| 2261 | − * the extension for obj_exts is expected to be NULL. | |
| 2262 | − */ | |
| 2263 | − mark_obj_codetag_empty(obj_exts); | |
| 2264 | 2236 | if (allow_spin) |
| 2265 | 2237 | kfree(obj_exts); |
| 2266 | 2238 | else |
| @@ -5356,7 +5328,7 @@ void *__do_kmalloc_node(kmem_buckets *b, gfp_t flags, int node, · 3089 unmodified lines | ||
| 5356 | 5328 | if (unlikely(!size)) |
| 5357 | 5329 | return ZERO_SIZE_PTR; |
| 5358 | 5330 | |
| 5359 | − s = kmalloc_slab(size, b, flags, token); | |
| 5331 | + s = kmalloc_slab(size, b, flags, token, ac->alloc_flags); | |
| 5360 | 5332 | |
| 5361 | 5333 | ret = slab_alloc_node(s, flags, node, ac); |
| 5362 | 5334 | ret = kasan_kmalloc(s, ret, size, flags); |
| @@ -5419,7 +5391,9 @@ static void *__kmalloc_nolock_noprof(DECL_TOKEN_PARAMS(size, token), gfp_t gfp_f · 56 unmodified lines | ||
| 5419 | 5391 | retry: |
| 5420 | 5392 | if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) |
| 5421 | 5393 | return NULL; |
| 5422 | − s = kmalloc_slab(size, NULL, gfp_flags, PASS_TOKEN_PARAM(token)); | |
| 5394 | + | |
| 5395 | + s = kmalloc_slab(size, NULL, gfp_flags, PASS_TOKEN_PARAM(token), | |
| 5396 | + ac->alloc_flags); | |
| 5423 | 5397 | |
| 5424 | 5398 | if (!(s->flags & __CMPXCHG_DOUBLE) && !kmem_cache_debug(s)) |
| 5425 | 5399 | /* |
| @@ -6217,7 +6191,6 @@ static void free_to_pcs_bulk(struct kmem_cache *s, size_t size, void **p) · 791 unmodified lines | ||
| 6217 | 6191 | void *remote_objects[PCS_BATCH_MAX]; |
| 6218 | 6192 | unsigned int remote_nr = 0; |
| 6219 | 6193 | |
| 6220 | −next_remote_batch: | |
| 6221 | 6194 | while (i < size) { |
| 6222 | 6195 | struct slab *slab = virt_to_slab(p[i]); |
| 6223 | 6196 | |
| @@ -6232,8 +6205,11 @@ next_remote_batch: · 8 unmodified lines | ||
| 6232 | 6205 | if (unlikely(!can_free_to_pcs(slab))) { |
| 6233 | 6206 | remote_objects[remote_nr] = p[i]; |
| 6234 | 6207 | p[i] = p[--size]; |
| 6235 | − if (++remote_nr >= PCS_BATCH_MAX) | |
| 6236 | − goto flush_remote; | |
| 6208 | + if (++remote_nr >= PCS_BATCH_MAX) { | |
| 6209 | + __kmem_cache_free_bulk(s, remote_nr, &remote_objects[0]); | |
| 6210 | + stat_add(s, FREE_SLOWPATH, remote_nr); | |
| 6211 | + remote_nr = 0; | |
| 6212 | + } | |
| 6237 | 6213 | continue; |
| 6238 | 6214 | } |
| 6239 | 6215 | |
| @@ -6317,10 +6293,6 @@ flush_remote: · 77 unmodified lines | ||
| 6317 | 6293 | if (remote_nr) { |
| 6318 | 6294 | __kmem_cache_free_bulk(s, remote_nr, &remote_objects[0]); |
| 6319 | 6295 | stat_add(s, FREE_SLOWPATH, remote_nr); |
| 6320 | − if (i < size) { | |
| 6321 | − remote_nr = 0; | |
| 6322 | − goto next_remote_batch; | |
| 6323 | − } | |
| 6324 | 6296 | } |
| 6325 | 6297 | } |
| 6326 | 6298 | |
| @@ -7801,12 +7773,12 @@ static unsigned int calculate_sheaf_capacity(struct kmem_cache *s, · 1474 unmodified lines | ||
| 7801 | 7773 | return 0; |
| 7802 | 7774 | |
| 7803 | 7775 | /* |
| 7804 | − * Bootstrap caches can't have sheaves for now (SLAB_NO_OBJ_EXT). | |
| 7776 | + * Bootstrap caches can't have sheaves for now (SLAB_NO_SHEAVES). | |
| 7805 | 7777 | * SLAB_NOLEAKTRACE caches (e.g., kmemleak's object_cache) must not |
| 7806 | 7778 | * have sheaves to avoid recursion when sheaf allocation triggers |
| 7807 | 7779 | * kmemleak tracking. |
| 7808 | 7780 | */ |
| 7809 | − if (s->flags & (SLAB_NO_OBJ_EXT | SLAB_NOLEAKTRACE)) | |
| 7781 | + if (s->flags & (SLAB_NO_SHEAVES | SLAB_NOLEAKTRACE)) | |
| 7810 | 7782 | return 0; |
| 7811 | 7783 | |
| 7812 | 7784 | /* |
| @@ -7981,10 +7953,10 @@ static int calculate_sizes(struct kmem_cache_args *args, struct kmem_cache *s) · 168 unmodified lines | ||
| 7981 | 7953 | s->allocflags |= __GFP_RECLAIMABLE; |
| 7982 | 7954 | |
| 7983 | 7955 | /* |
| 7984 | − * For KMALLOC_NORMAL caches we enable sheaves later by | |
| 7985 | − * bootstrap_kmalloc_sheaves() to avoid recursion | |
| 7956 | + * For kmalloc caches we enable sheaves later by | |
| 7957 | + * bootstrap_kmalloc_sheaves() to avoid recursion. | |
| 7986 | 7958 | */ |
| 7987 | − if (!is_kmalloc_normal(s)) | |
| 7959 | + if (!is_kmalloc_cache(s)) | |
| 7988 | 7960 | s->sheaf_capacity = calculate_sheaf_capacity(s, args); |
| 7989 | 7961 | |
| 7990 | 7962 | /* |
| @@ -8499,6 +8471,8 @@ static void __init bootstrap_cache_sheaves(struct kmem_cache *s) · 508 unmodified lines | ||
| 8499 | 8471 | bool failed = false; |
| 8500 | 8472 | int node, cpu; |
| 8501 | 8473 | |
| 8474 | + VM_WARN_ON_ONCE(cache_has_sheaves(s)); | |
| 8475 | + | |
| 8502 | 8476 | capacity = calculate_sheaf_capacity(s, &empty_args); |
| 8503 | 8477 | |
| 8504 | 8478 | /* capacity can be 0 due to debugging or SLUB_TINY */ |
| @@ -8548,10 +8522,13 @@ static void __init bootstrap_kmalloc_sheaves(void) · 43 unmodified lines | ||
| 8548 | 8522 | { |
| 8549 | 8523 | enum kmalloc_cache_type type; |
| 8550 | 8524 | |
| 8551 | − for (type = KMALLOC_NORMAL; type <= KMALLOC_PARTITION_END; type++) { | |
| 8525 | + for (type = KMALLOC_NORMAL; type < NR_KMALLOC_TYPES; type++) { | |
| 8552 | 8526 | for (int idx = 0; idx < KMALLOC_SHIFT_HIGH + 1; idx++) { |
| 8553 | − if (kmalloc_caches[type][idx]) | |
| 8554 | − bootstrap_cache_sheaves(kmalloc_caches[type][idx]); | |
| 8527 | + struct kmem_cache *s = kmalloc_caches[type][idx]; | |
| 8528 | + | |
| 8529 | + /* Do not bootstrap twice when caches are aliased */ | |
| 8530 | + if (s && !cache_has_sheaves(s)) | |
| 8531 | + bootstrap_cache_sheaves(s); | |
| 8555 | 8532 | } |
| 8556 | 8533 | } |
| 8557 | 8534 | } |
| @@ -8583,7 +8560,8 @@ void __init kmem_cache_init(void) · 25 unmodified lines | ||
| 8583 | 8560 | |
| 8584 | 8561 | create_boot_cache(kmem_cache_node, "kmem_cache_node", |
| 8585 | 8562 | sizeof(struct kmem_cache_node), |
| 8586 | − SLAB_HWCACHE_ALIGN | SLAB_NO_OBJ_EXT, 0, 0); | |
| 8563 | + SLAB_HWCACHE_ALIGN | SLAB_NO_SHEAVES | SLAB_NO_OBJ_EXT, | |
| 8564 | + 0, 0); | |
| 8587 | 8565 | |
| 8588 | 8566 | hotplug_node_notifier(slab_memory_callback, SLAB_CALLBACK_PRI); |
| 8589 | 8567 | |
| @@ -8593,7 +8571,8 @@ void __init kmem_cache_init(void) · 3 unmodified lines | ||
| 8593 | 8571 | create_boot_cache(kmem_cache, "kmem_cache", |
| 8594 | 8572 | offsetof(struct kmem_cache, per_node) + |
| 8595 | 8573 | nr_node_ids * sizeof(struct kmem_cache_per_node_ptrs), |
| 8596 | − SLAB_HWCACHE_ALIGN | SLAB_NO_OBJ_EXT, 0, 0); | |
| 8574 | + SLAB_HWCACHE_ALIGN | SLAB_NO_SHEAVES | SLAB_NO_OBJ_EXT, | |
| 8575 | + 0, 0); | |
| 8597 | 8576 | |
| 8598 | 8577 | kmem_cache = bootstrap(&boot_kmem_cache); |
| 8599 | 8578 | kmem_cache_node = bootstrap(&boot_kmem_cache_node); |
| @@ -2111,7 +2111,10 @@ static bool vma_can_userfault(struct vm_area_struct *vma, vm_flags_t vm_flags, · 2110 unmodified lines | ||
| 2111 | 2111 | { |
| 2112 | 2112 | const struct vm_uffd_ops *ops = vma_uffd_ops(vma); |
| 2113 | 2113 | |
| 2114 | − if (vma->vm_flags & VM_DROPPABLE) | |
| 2114 | + if (vma->vm_flags & (VM_DROPPABLE | VM_SHADOW_STACK)) | |
| 2115 | + return false; | |
| 2116 | + | |
| 2117 | + if (!is_vm_hugetlb_page(vma) && (vma->vm_flags & VM_SPECIAL)) | |
| 2115 | 2118 | return false; |
| 2116 | 2119 | |
| 2117 | 2120 | vm_flags &= __VM_UFFD_FLAGS; |
| @@ -929,12 +929,16 @@ int hci_update_eir_sync(struct hci_dev *hdev) · 928 unmodified lines | ||
| 929 | 929 | |
| 930 | 930 | memset(&cp, 0, sizeof(cp)); |
| 931 | 931 | |
| 932 | + hci_dev_lock(hdev); | |
| 932 | 933 | eir_create(hdev, cp.data); |
| 933 | 934 | |
| 934 | − if (memcmp(cp.data, hdev->eir, sizeof(cp.data)) == 0) | |
| 935 | + if (memcmp(cp.data, hdev->eir, sizeof(cp.data)) == 0) { | |
| 936 | + hci_dev_unlock(hdev); | |
| 935 | 937 | return 0; |
| 938 | + } | |
| 936 | 939 | |
| 937 | 940 | memcpy(hdev->eir, cp.data, sizeof(cp.data)); |
| 941 | + hci_dev_unlock(hdev); | |
| 938 | 942 | |
| 939 | 943 | return __hci_cmd_sync_status(hdev, HCI_OP_WRITE_EIR, sizeof(cp), &cp, |
| 940 | 944 | HCI_CMD_TIMEOUT); |
| @@ -966,6 +970,7 @@ int hci_update_class_sync(struct hci_dev *hdev) · 25 unmodified lines | ||
| 966 | 970 | if (hci_dev_test_flag(hdev, HCI_SERVICE_CACHE)) |
| 967 | 971 | return 0; |
| 968 | 972 | |
| 973 | + hci_dev_lock(hdev); | |
| 969 | 974 | cod[0] = hdev->minor_class; |
| 970 | 975 | cod[1] = hdev->major_class; |
| 971 | 976 | cod[2] = get_service_classes(hdev); |
| @@ -973,8 +978,12 @@ int hci_update_class_sync(struct hci_dev *hdev) · 1 unmodified line | ||
| 973 | 978 | if (hci_dev_test_flag(hdev, HCI_LIMITED_DISCOVERABLE)) |
| 974 | 979 | cod[1] |= 0x20; |
| 975 | 980 | |
| 976 | − if (memcmp(cod, hdev->dev_class, 3) == 0) | |
| 981 | + if (memcmp(cod, hdev->dev_class, 3) == 0) { | |
| 982 | + hci_dev_unlock(hdev); | |
| 977 | 983 | return 0; |
| 984 | + } | |
| 985 | + | |
| 986 | + hci_dev_unlock(hdev); | |
| 978 | 987 | |
| 979 | 988 | return __hci_cmd_sync_status(hdev, HCI_OP_WRITE_CLASS_OF_DEV, |
| 980 | 989 | sizeof(cod), cod, HCI_CMD_TIMEOUT); |
| @@ -1028,6 +1028,23 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, · 1027 unmodified lines | ||
| 1028 | 1028 | return rfcomm_send_frame(s, buf, ptr - buf); |
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | +int rfcomm_dlc_send_rpn(struct rfcomm_dlc *d, u8 bit_rate, u8 data_bits, | |
| 1032 | + u8 stop_bits, u8 parity, u8 flow_ctrl_settings, | |
| 1033 | + u8 xon_char, u8 xoff_char, u16 param_mask) | |
| 1034 | +{ | |
| 1035 | + int err = -ENOTCONN; | |
| 1036 | + | |
| 1037 | + rfcomm_lock(); | |
| 1038 | + if (d->session) | |
| 1039 | + err = rfcomm_send_rpn(d->session, 1, d->dlci, bit_rate, | |
| 1040 | + data_bits, stop_bits, parity, | |
| 1041 | + flow_ctrl_settings, xon_char, xoff_char, | |
| 1042 | + param_mask); | |
| 1043 | + rfcomm_unlock(); | |
| 1044 | + | |
| 1045 | + return err; | |
| 1046 | +} | |
| 1047 | + | |
| 1031 | 1048 | static int rfcomm_send_rls(struct rfcomm_session *s, int cr, u8 dlci, u8 status) |
| 1032 | 1049 | { |
| 1033 | 1050 | struct rfcomm_hdr *hdr; |
| @@ -858,7 +858,7 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, · 857 unmodified lines | ||
| 858 | 858 | |
| 859 | 859 | BT_DBG("tty %p termios %p", tty, old); |
| 860 | 860 | |
| 861 | − if (!dev || !dev->dlc || !dev->dlc->session) | |
| 861 | + if (!dev || !dev->dlc) | |
| 862 | 862 | return; |
| 863 | 863 | |
| 864 | 864 | /* Handle turning off CRTSCTS */ |
| @@ -979,9 +979,8 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, · 114 unmodified lines | ||
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | if (changes) |
| 982 | − rfcomm_send_rpn(dev->dlc->session, 1, dev->dlc->dlci, baud, | |
| 983 | − data_bits, stop_bits, parity, | |
| 984 | − RFCOMM_RPN_FLOW_NONE, x_on, x_off, changes); | |
| 982 | + rfcomm_dlc_send_rpn(dev->dlc, baud, data_bits, stop_bits, parity, | |
| 983 | + RFCOMM_RPN_FLOW_NONE, x_on, x_off, changes); | |
| 985 | 984 | } |
| 986 | 985 | |
| 987 | 986 | static void rfcomm_tty_throttle(struct tty_struct *tty) |
| @@ -271,7 +271,8 @@ static void __vlan_tunnel_handle_range(const struct net_bridge_port *p, · 270 unmodified lines | ||
| 271 | 271 | if (!*v_start) |
| 272 | 272 | goto out_init; |
| 273 | 273 | |
| 274 | − if (v && curr_change && br_vlan_can_enter_range(v, *v_end)) { | |
| 274 | + if (v && curr_change && | |
| 275 | + br_vlan_can_enter_range(v, *v_end, br_get_pvid(vg))) { | |
| 275 | 276 | *v_end = v; |
| 276 | 277 | return; |
| 277 | 278 | } |
| @@ -1627,7 +1627,8 @@ void br_vlan_notify(const struct net_bridge *br, · 1626 unmodified lines | ||
| 1627 | 1627 | u16 vid, u16 vid_range, |
| 1628 | 1628 | int cmd); |
| 1629 | 1629 | bool br_vlan_can_enter_range(const struct net_bridge_vlan *v_curr, |
| 1630 | − const struct net_bridge_vlan *range_end); | |
| 1630 | + const struct net_bridge_vlan *range_end, | |
| 1631 | + u16 pvid); | |
| 1631 | 1632 | |
| 1632 | 1633 | void br_vlan_fill_forward_path_pvid(struct net_bridge *br, |
| 1633 | 1634 | struct net_device_path_ctx *ctx, |
| @@ -1874,7 +1875,8 @@ static inline void br_vlan_notify(const struct net_bridge *br, · 240 unmodified lines | ||
| 1874 | 1875 | } |
| 1875 | 1876 | |
| 1876 | 1877 | static inline bool br_vlan_can_enter_range(const struct net_bridge_vlan *v_curr, |
| 1877 | − const struct net_bridge_vlan *range_end) | |
| 1878 | + const struct net_bridge_vlan *range_end, | |
| 1879 | + u16 pvid) | |
| 1878 | 1880 | { |
| 1879 | 1881 | return true; |
| 1880 | 1882 | } |
| @@ -1982,9 +1982,11 @@ out_kfree: · 1981 unmodified lines | ||
| 1982 | 1982 | |
| 1983 | 1983 | /* check if v_curr can enter a range ending in range_end */ |
| 1984 | 1984 | bool br_vlan_can_enter_range(const struct net_bridge_vlan *v_curr, |
| 1985 | − const struct net_bridge_vlan *range_end) | |
| 1985 | + const struct net_bridge_vlan *range_end, | |
| 1986 | + u16 pvid) | |
| 1986 | 1987 | { |
| 1987 | − return v_curr->vid - range_end->vid == 1 && | |
| 1988 | + return v_curr->vid != pvid && range_end->vid != pvid && | |
| 1989 | + v_curr->vid - range_end->vid == 1 && | |
| 1988 | 1990 | range_end->flags == v_curr->flags && |
| 1989 | 1991 | br_vlan_opts_eq_range(v_curr, range_end); |
| 1990 | 1992 | } |
| @@ -2066,8 +2068,8 @@ static int br_vlan_dump_dev(const struct net_device *dev, · 75 unmodified lines | ||
| 2066 | 2068 | idx += range_end->vid - range_start->vid + 1; |
| 2067 | 2069 | |
| 2068 | 2070 | range_start = v; |
| 2069 | − } else if (dump_stats || v->vid == pvid || | |
| 2070 | − !br_vlan_can_enter_range(v, range_end)) { | |
| 2071 | + } else if (dump_stats || | |
| 2072 | + !br_vlan_can_enter_range(v, range_end, pvid)) { | |
| 2071 | 2073 | u16 vlan_flags = br_vlan_flags(range_start, pvid); |
| 2072 | 2074 | |
| 2073 | 2075 | if (!br_vlan_fill_vids(skb, range_start->vid, |
| @@ -350,8 +350,7 @@ int br_vlan_process_options(const struct net_bridge *br, · 349 unmodified lines | ||
| 350 | 350 | continue; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | − if (v->vid == pvid || | |
| 354 | − !br_vlan_can_enter_range(v, curr_end)) { | |
| 353 | + if (!br_vlan_can_enter_range(v, curr_end, pvid)) { | |
| 355 | 354 | br_vlan_notify(br, p, curr_start->vid, |
| 356 | 355 | curr_end->vid, RTM_NEWVLAN); |
| 357 | 356 | curr_start = v; |
| @@ -849,9 +849,16 @@ static int ceph_x_update_authorizer( · 848 unmodified lines | ||
| 849 | 849 | |
| 850 | 850 | au = (struct ceph_x_authorizer *)auth->authorizer; |
| 851 | 851 | if (au->secret_id < th->secret_id) { |
| 852 | + int ret; | |
| 853 | + | |
| 852 | 854 | dout("ceph_x_update_authorizer service %u secret %llu < %llu\n", |
| 853 | 855 | au->service, au->secret_id, th->secret_id); |
| 854 | − return ceph_x_build_authorizer(ac, th, au); | |
| 856 | + ret = ceph_x_build_authorizer(ac, th, au); | |
| 857 | + if (ret) | |
| 858 | + return ret; | |
| 859 | + | |
| 860 | + auth->authorizer_buf = au->buf->vec.iov_base; | |
| 861 | + auth->authorizer_buf_len = au->buf->vec.iov_len; | |
| 855 | 862 | } |
| 856 | 863 | return 0; |
| 857 | 864 | } |
| @@ -762,13 +762,13 @@ void ceph_destroy_client(struct ceph_client *client) · 761 unmodified lines | ||
| 762 | 762 | |
| 763 | 763 | atomic_set(&client->msgr.stopping, 1); |
| 764 | 764 | |
| 765 | + ceph_debugfs_client_cleanup(client); | |
| 766 | + | |
| 765 | 767 | /* unmount */ |
| 766 | 768 | ceph_osdc_stop(&client->osdc); |
| 767 | 769 | ceph_monc_stop(&client->monc); |
| 768 | 770 | ceph_messenger_fini(&client->msgr); |
| 769 | 771 | |
| 770 | − ceph_debugfs_client_cleanup(client); | |
| 771 | − | |
| 772 | 772 | ceph_destroy_options(client->options); |
| 773 | 773 | |
| 774 | 774 | kfree(client); |
| @@ -299,7 +299,7 @@ static int decode_lockers(void **p, void *end, u8 *type, char **tag, · 298 unmodified lines | ||
| 299 | 299 | if (ret) |
| 300 | 300 | return ret; |
| 301 | 301 | |
| 302 | − *num_lockers = ceph_decode_32(p); | |
| 302 | + ceph_decode_32_safe(p, end, *num_lockers, err_inval); | |
| 303 | 303 | *lockers = kzalloc_objs(**lockers, *num_lockers, GFP_NOIO); |
| 304 | 304 | if (!*lockers) |
| 305 | 305 | return -ENOMEM; |
| @@ -310,7 +310,8 @@ static int decode_lockers(void **p, void *end, u8 *type, char **tag, · 4 unmodified lines | ||
| 310 | 310 | goto err_free_lockers; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | − *type = ceph_decode_8(p); | |
| 313 | + ret = -EINVAL; | |
| 314 | + ceph_decode_8_safe(p, end, *type, err_free_lockers); | |
| 314 | 315 | s = ceph_extract_encoded_string(p, end, NULL, GFP_NOIO); |
| 315 | 316 | if (IS_ERR(s)) { |
| 316 | 317 | ret = PTR_ERR(s); |
| @@ -320,6 +321,9 @@ static int decode_lockers(void **p, void *end, u8 *type, char **tag, · 3 unmodified lines | ||
| 320 | 321 | *tag = s; |
| 321 | 322 | return 0; |
| 322 | 323 | |
| 324 | +err_inval: | |
| 325 | + return -EINVAL; | |
| 326 | + | |
| 323 | 327 | err_free_lockers: |
| 324 | 328 | ceph_free_lockers(*lockers, *num_lockers); |
| 325 | 329 | return ret; |
| @@ -114,7 +114,7 @@ static struct ceph_monmap *ceph_monmap_decode(void **p, void *end, bool msgr2) · 113 unmodified lines | ||
| 114 | 114 | |
| 115 | 115 | dout("%s fsid %pU epoch %u num_mon %u\n", __func__, &fsid, epoch, |
| 116 | 116 | num_mon); |
| 117 | − if (num_mon > CEPH_MAX_MON) | |
| 117 | + if (num_mon == 0 || num_mon > CEPH_MAX_MON) | |
| 118 | 118 | goto e_inval; |
| 119 | 119 | |
| 120 | 120 | monmap = kmalloc_flex(*monmap, mon_inst, num_mon, GFP_NOIO); |
| @@ -821,7 +821,7 @@ static void handle_get_version_reply(struct ceph_mon_client *monc, · 700 unmodified lines | ||
| 821 | 821 | struct ceph_mon_generic_request *req; |
| 822 | 822 | u64 tid = le64_to_cpu(msg->hdr.tid); |
| 823 | 823 | void *p = msg->front.iov_base; |
| 824 | − void *end = p + msg->front_alloc_len; | |
| 824 | + void *const end = p + msg->front.iov_len; | |
| 825 | 825 | u64 handle; |
| 826 | 826 | |
| 827 | 827 | dout("%s msg %p tid %llu\n", __func__, msg, tid); |
| @@ -518,6 +518,8 @@ static struct crush_map *crush_decode(void *pbyval, void *end) · 517 unmodified lines | ||
| 518 | 518 | ceph_decode_need(p, end, 4*sizeof(u32), bad); |
| 519 | 519 | b->id = ceph_decode_32(p); |
| 520 | 520 | b->type = ceph_decode_16(p); |
| 521 | + if (b->type == 0) | |
| 522 | + goto bad; | |
| 521 | 523 | b->alg = ceph_decode_8(p); |
| 522 | 524 | if (b->alg != alg) { |
| 523 | 525 | b->alg = 0; |
| @@ -1436,7 +1438,7 @@ static struct ceph_pg_mapping *__decode_pg_temp(void **p, void *end, · 912 unmodified lines | ||
| 1436 | 1438 | ceph_decode_32_safe(p, end, len, e_inval); |
| 1437 | 1439 | if (len == 0 && incremental) |
| 1438 | 1440 | return NULL; /* new_pg_temp: [] to remove */ |
| 1439 | − if ((size_t)len > (SIZE_MAX - sizeof(*pg)) / sizeof(u32)) | |
| 1441 | + if (len > CEPH_PG_MAX_SIZE) | |
| 1440 | 1442 | return ERR_PTR(-EINVAL); |
| 1441 | 1443 | |
| 1442 | 1444 | ceph_decode_need(p, end, len * sizeof(u32), e_inval); |
| @@ -1617,7 +1619,7 @@ static struct ceph_pg_mapping *__decode_pg_upmap_items(void **p, void *end, · 174 unmodified lines | ||
| 1617 | 1619 | u32 len, i; |
| 1618 | 1620 | |
| 1619 | 1621 | ceph_decode_32_safe(p, end, len, e_inval); |
| 1620 | − if ((size_t)len > (SIZE_MAX - sizeof(*pg)) / (2 * sizeof(u32))) | |
| 1622 | + if (len > CEPH_PG_MAX_SIZE) | |
| 1621 | 1623 | return ERR_PTR(-EINVAL); |
| 1622 | 1624 | |
| 1623 | 1625 | ceph_decode_need(p, end, 2 * len * sizeof(u32), e_inval); |
| @@ -1842,6 +1844,8 @@ static int decode_new_up_state_weight(void **p, void *end, u8 struct_v, · 218 unmodified lines | ||
| 1842 | 1844 | void *new_up_client; |
| 1843 | 1845 | void *new_state; |
| 1844 | 1846 | void *new_weight_end; |
| 1847 | + const u32 new_state_item_size = | |
| 1848 | + sizeof(u32) + (struct_v >= 5 ? sizeof(u32) : sizeof(u8)); | |
| 1845 | 1849 | u32 len; |
| 1846 | 1850 | int ret; |
| 1847 | 1851 | int i; |
| @@ -1862,7 +1866,8 @@ static int decode_new_up_state_weight(void **p, void *end, u8 struct_v, · 14 unmodified lines | ||
| 1862 | 1866 | |
| 1863 | 1867 | new_state = *p; |
| 1864 | 1868 | ceph_decode_32_safe(p, end, len, e_inval); |
| 1865 | − len *= sizeof(u32) + (struct_v >= 5 ? sizeof(u32) : sizeof(u8)); | |
| 1869 | + if (check_mul_overflow(len, new_state_item_size, &len)) | |
| 1870 | + goto e_inval; | |
| 1866 | 1871 | ceph_decode_need(p, end, len, e_inval); |
| 1867 | 1872 | *p += len; |
| 1868 | 1873 | |
| @@ -3055,8 +3060,11 @@ static int get_immediate_parent(struct crush_map *c, int id, · 1186 unmodified lines | ||
| 3055 | 3060 | if (b->items[j] != id) |
| 3056 | 3061 | continue; |
| 3057 | 3062 | |
| 3058 | − *parent_type_id = b->type; | |
| 3059 | 3063 | type_cn = lookup_crush_name(&c->type_names, b->type); |
| 3064 | + if (WARN_ON_ONCE(!type_cn)) | |
| 3065 | + continue; | |
| 3066 | + | |
| 3067 | + *parent_type_id = b->type; | |
| 3060 | 3068 | parent_loc->cl_type_name = type_cn->cn_name; |
| 3061 | 3069 | parent_loc->cl_name = cn->cn_name; |
| 3062 | 3070 | return b->id; |
| @@ -530,10 +530,10 @@ static void net_dm_packet_trace_kfree_skb_hit(void *ignore, · 529 unmodified lines | ||
| 530 | 530 | return; |
| 531 | 531 | |
| 532 | 532 | unlock_free: |
| 533 | − spin_unlock_irqrestore(&data->drop_queue.lock, flags); | |
| 534 | 533 | u64_stats_update_begin(&data->stats.syncp); |
| 535 | 534 | u64_stats_inc(&data->stats.dropped); |
| 536 | 535 | u64_stats_update_end(&data->stats.syncp); |
| 536 | + spin_unlock_irqrestore(&data->drop_queue.lock, flags); | |
| 537 | 537 | consume_skb(nskb); |
| 538 | 538 | } |
| 539 | 539 | |
| @@ -566,13 +566,13 @@ static size_t net_dm_packet_report_size(size_t payload_len) · 26 unmodified lines | ||
| 566 | 566 | /* NET_DM_ATTR_ORIGIN */ |
| 567 | 567 | nla_total_size(sizeof(u16)) + |
| 568 | 568 | /* NET_DM_ATTR_PC */ |
| 569 | − nla_total_size(sizeof(u64)) + | |
| 569 | + nla_total_size_64bit(sizeof(u64)) + | |
| 570 | 570 | /* NET_DM_ATTR_SYMBOL */ |
| 571 | 571 | nla_total_size(NET_DM_MAX_SYMBOL_LEN + 1) + |
| 572 | 572 | /* NET_DM_ATTR_IN_PORT */ |
| 573 | 573 | net_dm_in_port_size() + |
| 574 | 574 | /* NET_DM_ATTR_TIMESTAMP */ |
| 575 | − nla_total_size(sizeof(u64)) + | |
| 575 | + nla_total_size_64bit(sizeof(u64)) + | |
| 576 | 576 | /* NET_DM_ATTR_ORIG_LEN */ |
| 577 | 577 | nla_total_size(sizeof(u32)) + |
| 578 | 578 | /* NET_DM_ATTR_PROTO */ |
| @@ -671,9 +671,7 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb, · 92 unmodified lines | ||
| 671 | 671 | if (nla_put_u16(msg, NET_DM_ATTR_PROTO, be16_to_cpu(skb->protocol))) |
| 672 | 672 | goto nla_put_failure; |
| 673 | 673 | |
| 674 | − attr = skb_put(msg, nla_total_size(payload_len)); | |
| 675 | − attr->nla_type = NET_DM_ATTR_PAYLOAD; | |
| 676 | − attr->nla_len = nla_attr_size(payload_len); | |
| 674 | + attr = __nla_reserve(msg, NET_DM_ATTR_PAYLOAD, payload_len); | |
| 677 | 675 | if (skb_copy_bits(skb, 0, nla_data(attr), payload_len)) |
| 678 | 676 | goto nla_put_failure; |
| 679 | 677 | |
| @@ -768,7 +766,7 @@ net_dm_hw_packet_report_size(size_t payload_len, · 88 unmodified lines | ||
| 768 | 766 | /* NET_DM_ATTR_FLOW_ACTION_COOKIE */ |
| 769 | 767 | net_dm_flow_action_cookie_size(hw_metadata) + |
| 770 | 768 | /* NET_DM_ATTR_TIMESTAMP */ |
| 771 | − nla_total_size(sizeof(u64)) + | |
| 769 | + nla_total_size_64bit(sizeof(u64)) + | |
| 772 | 770 | /* NET_DM_ATTR_ORIG_LEN */ |
| 773 | 771 | nla_total_size(sizeof(u32)) + |
| 774 | 772 | /* NET_DM_ATTR_PROTO */ |
| @@ -831,9 +829,7 @@ static int net_dm_hw_packet_report_fill(struct sk_buff *msg, · 56 unmodified lines | ||
| 831 | 829 | if (nla_put_u16(msg, NET_DM_ATTR_PROTO, be16_to_cpu(skb->protocol))) |
| 832 | 830 | goto nla_put_failure; |
| 833 | 831 | |
| 834 | − attr = skb_put(msg, nla_total_size(payload_len)); | |
| 835 | − attr->nla_type = NET_DM_ATTR_PAYLOAD; | |
| 836 | − attr->nla_len = nla_attr_size(payload_len); | |
| 832 | + attr = __nla_reserve(msg, NET_DM_ATTR_PAYLOAD, payload_len); | |
| 837 | 833 | if (skb_copy_bits(skb, 0, nla_data(attr), payload_len)) |
| 838 | 834 | goto nla_put_failure; |
| 839 | 835 | |
| @@ -1001,10 +997,10 @@ net_dm_hw_trap_packet_probe(void *ignore, const struct devlink *devlink, · 161 unmodified lines | ||
| 1001 | 997 | return; |
| 1002 | 998 | |
| 1003 | 999 | unlock_free: |
| 1004 | − spin_unlock_irqrestore(&hw_data->drop_queue.lock, flags); | |
| 1005 | 1000 | u64_stats_update_begin(&hw_data->stats.syncp); |
| 1006 | 1001 | u64_stats_inc(&hw_data->stats.dropped); |
| 1007 | 1002 | u64_stats_update_end(&hw_data->stats.syncp); |
| 1003 | + spin_unlock_irqrestore(&hw_data->drop_queue.lock, flags); | |
| 1008 | 1004 | net_dm_hw_metadata_free(n_hw_metadata); |
| 1009 | 1005 | free: |
| 1010 | 1006 | consume_skb(nskb); |
| @@ -2552,11 +2552,13 @@ out_drop: · 2551 unmodified lines | ||
| 2552 | 2552 | |
| 2553 | 2553 | BPF_CALL_2(bpf_redirect, u32, ifindex, u64, flags) |
| 2554 | 2554 | { |
| 2555 | − struct bpf_redirect_info *ri = bpf_net_ctx_get_ri(); | |
| 2555 | + struct bpf_redirect_info *ri; | |
| 2556 | 2556 | |
| 2557 | − if (unlikely(flags & (~(BPF_F_INGRESS) | BPF_F_REDIRECT_INTERNAL))) | |
| 2557 | + if (unlikely(!bpf_net_ctx_get() || | |
| 2558 | + (flags & (~(BPF_F_INGRESS) | BPF_F_REDIRECT_INTERNAL)))) | |
| 2558 | 2559 | return TC_ACT_SHOT; |
| 2559 | 2560 | |
| 2561 | + ri = bpf_net_ctx_get_ri(); | |
| 2560 | 2562 | ri->flags = flags; |
| 2561 | 2563 | ri->tgt_index = ifindex; |
| 2562 | 2564 | |
| @@ -2573,11 +2575,12 @@ static const struct bpf_func_proto bpf_redirect_proto = { · 10 unmodified lines | ||
| 2573 | 2575 | |
| 2574 | 2576 | BPF_CALL_2(bpf_redirect_peer, u32, ifindex, u64, flags) |
| 2575 | 2577 | { |
| 2576 | − struct bpf_redirect_info *ri = bpf_net_ctx_get_ri(); | |
| 2578 | + struct bpf_redirect_info *ri; | |
| 2577 | 2579 | |
| 2578 | − if (unlikely(flags)) | |
| 2580 | + if (unlikely(!bpf_net_ctx_get() || flags)) | |
| 2579 | 2581 | return TC_ACT_SHOT; |
| 2580 | 2582 | |
| 2583 | + ri = bpf_net_ctx_get_ri(); | |
| 2581 | 2584 | ri->flags = BPF_F_PEER; |
| 2582 | 2585 | ri->tgt_index = ifindex; |
| 2583 | 2586 | |
| @@ -2595,11 +2598,13 @@ static const struct bpf_func_proto bpf_redirect_peer_proto = { · 11 unmodified lines | ||
| 2595 | 2598 | BPF_CALL_4(bpf_redirect_neigh, u32, ifindex, struct bpf_redir_neigh *, params, |
| 2596 | 2599 | int, plen, u64, flags) |
| 2597 | 2600 | { |
| 2598 | − struct bpf_redirect_info *ri = bpf_net_ctx_get_ri(); | |
| 2601 | + struct bpf_redirect_info *ri; | |
| 2599 | 2602 | |
| 2600 | − if (unlikely((plen && plen < sizeof(*params)) || flags)) | |
| 2603 | + if (unlikely((plen && plen < sizeof(*params)) || | |
| 2604 | + !bpf_net_ctx_get() || flags)) | |
| 2601 | 2605 | return TC_ACT_SHOT; |
| 2602 | 2606 | |
| 2607 | + ri = bpf_net_ctx_get_ri(); | |
| 2603 | 2608 | ri->flags = BPF_F_NEIGH | (plen ? BPF_F_NEXTHOP : 0); |
| 2604 | 2609 | ri->tgt_index = ifindex; |
| 2605 | 2610 | |
| @@ -229,7 +229,9 @@ done: · 228 unmodified lines | ||
| 229 | 229 | |
| 230 | 230 | int skb_gro_receive_list(struct sk_buff *p, struct sk_buff *skb) |
| 231 | 231 | { |
| 232 | − if (unlikely(p->len + skb->len >= 65536)) | |
| 232 | + /* make sure to check flush flag and to not merge */ | |
| 233 | + if (unlikely(p->len + skb->len >= 65536 || | |
| 234 | + NAPI_GRO_CB(skb)->flush)) | |
| 233 | 235 | return -E2BIG; |
| 234 | 236 | |
| 235 | 237 | if (!pskb_may_pull(skb, skb_gro_offset(skb))) { |
| @@ -2547,6 +2547,11 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority, · 2546 unmodified lines | ||
| 2547 | 2547 | |
| 2548 | 2548 | cgroup_sk_clone(&newsk->sk_cgrp_data); |
| 2549 | 2549 | |
| 2550 | + RCU_INIT_POINTER(newsk->sk_reuseport_cb, NULL); | |
| 2551 | + | |
| 2552 | + if (sock_needs_netstamp(sk) && newsk->sk_flags & SK_FLAGS_TIMESTAMP) | |
| 2553 | + net_enable_timestamp(); | |
| 2554 | + | |
| 2550 | 2555 | rcu_read_lock(); |
| 2551 | 2556 | filter = rcu_dereference(sk->sk_filter); |
| 2552 | 2557 | if (filter != NULL) |
| @@ -2569,8 +2574,6 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority, · 16 unmodified lines | ||
| 2569 | 2574 | goto free; |
| 2570 | 2575 | } |
| 2571 | 2576 | |
| 2572 | − RCU_INIT_POINTER(newsk->sk_reuseport_cb, NULL); | |
| 2573 | − | |
| 2574 | 2577 | if (bpf_sk_storage_clone(sk, newsk)) |
| 2575 | 2578 | goto free; |
| 2576 | 2579 | |
| @@ -2598,9 +2601,6 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority, · 21 unmodified lines | ||
| 2598 | 2601 | |
| 2599 | 2602 | if (newsk->sk_prot->sockets_allocated) |
| 2600 | 2603 | sk_sockets_allocated_inc(newsk); |
| 2601 | − | |
| 2602 | − if (sock_needs_netstamp(sk) && newsk->sk_flags & SK_FLAGS_TIMESTAMP) | |
| 2603 | − net_enable_timestamp(); | |
| 2604 | 2604 | out: |
| 2605 | 2605 | return newsk; |
| 2606 | 2606 | free: |
| @@ -242,6 +242,8 @@ void hsr_del_port(struct hsr_port *port) · 241 unmodified lines | ||
| 242 | 242 | netdev_rx_handler_unregister(port->dev); |
| 243 | 243 | if (!port->hsr->fwd_offloaded) |
| 244 | 244 | dev_set_promiscuity(port->dev, -1); |
| 245 | + if (port->type == HSR_PT_SLAVE_A || port->type == HSR_PT_SLAVE_B) | |
| 246 | + vlan_vids_del_by_dev(port->dev, master->dev); | |
| 245 | 247 | netdev_upper_dev_unlink(port->dev, master->dev); |
| 246 | 248 | if (hsr->prot_version == PRP_V1 && |
| 247 | 249 | port->type == HSR_PT_SLAVE_B) { |
| @@ -63,12 +63,12 @@ int __ip4_datagram_connect(struct sock *sk, struct sockaddr_unsized *uaddr, int · 62 unmodified lines | ||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /* Update addresses before rehashing */ |
| 66 | − inet->inet_daddr = fl4->daddr; | |
| 66 | + WRITE_ONCE(inet->inet_daddr, fl4->daddr); | |
| 67 | 67 | inet->inet_dport = usin->sin_port; |
| 68 | 68 | if (!inet->inet_saddr) |
| 69 | 69 | inet->inet_saddr = fl4->saddr; |
| 70 | 70 | if (!inet->inet_rcv_saddr) { |
| 71 | − inet->inet_rcv_saddr = fl4->saddr; | |
| 71 | + WRITE_ONCE(inet->inet_rcv_saddr, fl4->saddr); | |
| 72 | 72 | if (sk->sk_prot->rehash) |
| 73 | 73 | sk->sk_prot->rehash(sk); |
| 74 | 74 | } |
| @@ -548,11 +548,23 @@ static struct rtable *icmp_route_lookup(struct net *net, struct flowi4 *fl4, · 547 unmodified lines | ||
| 548 | 548 | if (IS_ERR(rt2)) |
| 549 | 549 | err = PTR_ERR(rt2); |
| 550 | 550 | } else { |
| 551 | − struct flowi4 fl4_2 = {}; | |
| 551 | + struct flowi4 fl4_2 = fl4_dec; | |
| 552 | 552 | unsigned long orefdst; |
| 553 | 553 | |
| 554 | − fl4_2.daddr = fl4_dec.saddr; | |
| 555 | − rt2 = ip_route_output_key(net, &fl4_2); | |
| 554 | + swap(fl4_2.daddr, fl4_2.saddr); | |
| 555 | + switch (fl4_2.flowi4_proto) { | |
| 556 | + case IPPROTO_TCP: | |
| 557 | + case IPPROTO_UDP: | |
| 558 | + case IPPROTO_SCTP: | |
| 559 | + case IPPROTO_DCCP: | |
| 560 | + swap(fl4_2.fl4_sport, fl4_2.fl4_dport); | |
| 561 | + break; | |
| 562 | + } | |
| 563 | + | |
| 564 | + fl4_2.flowi4_oif = l3mdev_master_ifindex(route_lookup_dev); | |
| 565 | + fl4_2.flowi4_flags |= FLOWI_FLAG_ANYSRC; | |
| 566 | + | |
| 567 | + rt2 = __ip_route_output_key(net, &fl4_2); | |
| 556 | 568 | if (IS_ERR(rt2)) { |
| 557 | 569 | err = PTR_ERR(rt2); |
| 558 | 570 | goto relookup_failed; |
| @@ -1018,6 +1018,8 @@ static void __gre_tunnel_init(struct net_device *dev) · 1017 unmodified lines | ||
| 1018 | 1018 | dev->features |= GRE_FEATURES; |
| 1019 | 1019 | dev->hw_features |= GRE_FEATURES; |
| 1020 | 1020 | |
| 1021 | + dev->lltx = true; | |
| 1022 | + | |
| 1021 | 1023 | /* TCP offload with GRE SEQ is not supported, nor can we support 2 |
| 1022 | 1024 | * levels of outer headers requiring an update. |
| 1023 | 1025 | */ |
| @@ -1029,8 +1031,6 @@ static void __gre_tunnel_init(struct net_device *dev) · 5 unmodified lines | ||
| 1029 | 1031 | |
| 1030 | 1032 | dev->features |= NETIF_F_GSO_SOFTWARE; |
| 1031 | 1033 | dev->hw_features |= NETIF_F_GSO_SOFTWARE; |
| 1032 | − | |
| 1033 | − dev->lltx = true; | |
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | static int ipgre_tunnel_init(struct net_device *dev) |
| @@ -1788,8 +1788,8 @@ static bool nh_res_bucket_migrate(struct nh_res_table *res_table, · 1787 unmodified lines | ||
| 1788 | 1788 | bool notify_nl, bool force) |
| 1789 | 1789 | { |
| 1790 | 1790 | struct nh_res_bucket *bucket = &res_table->nh_buckets[bucket_index]; |
| 1791 | + struct netlink_ext_ack extack = {}; | |
| 1791 | 1792 | struct nh_grp_entry *new_nhge; |
| 1792 | − struct netlink_ext_ack extack; | |
| 1793 | 1793 | int err; |
| 1794 | 1794 | |
| 1795 | 1795 | new_nhge = list_first_entry_or_null(&res_table->uw_nh_entries, |
| @@ -118,13 +118,21 @@ bool raw_v4_match(struct net *net, const struct sock *sk, unsigned short num, · 117 unmodified lines | ||
| 118 | 118 | __be32 raddr, __be32 laddr, int dif, int sdif) |
| 119 | 119 | { |
| 120 | 120 | const struct inet_sock *inet = inet_sk(sk); |
| 121 | + __be32 daddr, rcv_saddr; | |
| 121 | 122 | |
| 122 | − if (net_eq(sock_net(sk), net) && inet->inet_num == num && | |
| 123 | − !(inet->inet_daddr && inet->inet_daddr != raddr) && | |
| 124 | − !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) && | |
| 125 | − raw_sk_bound_dev_eq(net, sk->sk_bound_dev_if, dif, sdif)) | |
| 126 | − return true; | |
| 127 | − return false; | |
| 123 | + if (!net_eq(sock_net(sk), net) || inet->inet_num != num) | |
| 124 | + return false; | |
| 125 | + | |
| 126 | + daddr = READ_ONCE(inet->inet_daddr); | |
| 127 | + if (daddr && daddr != raddr) | |
| 128 | + return false; | |
| 129 | + | |
| 130 | + rcv_saddr = READ_ONCE(inet->inet_rcv_saddr); | |
| 131 | + if (rcv_saddr && rcv_saddr != laddr) | |
| 132 | + return false; | |
| 133 | + | |
| 134 | + return raw_sk_bound_dev_eq(net, READ_ONCE(sk->sk_bound_dev_if), | |
| 135 | + dif, sdif); | |
| 128 | 136 | } |
| 129 | 137 | EXPORT_SYMBOL_GPL(raw_v4_match); |
| 130 | 138 | |
| @@ -722,7 +730,8 @@ static int raw_bind(struct sock *sk, struct sockaddr_unsized *uaddr, · 591 unmodified lines | ||
| 722 | 730 | chk_addr_ret)) |
| 723 | 731 | goto out; |
| 724 | 732 | |
| 725 | − inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr; | |
| 733 | + inet->inet_saddr = addr->sin_addr.s_addr; | |
| 734 | + WRITE_ONCE(inet->inet_rcv_saddr, addr->sin_addr.s_addr); | |
| 726 | 735 | if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST) |
| 727 | 736 | inet->inet_saddr = 0; /* Use device */ |
| 728 | 737 | sk_dst_reset(sk); |
| @@ -604,7 +604,7 @@ wait_for_sndbuf: · 603 unmodified lines | ||
| 604 | 604 | wait_for_memory: |
| 605 | 605 | err = sk_stream_wait_memory(sk, &timeo); |
| 606 | 606 | if (err) { |
| 607 | − if (msg_tx && msg_tx != psock->cork) | |
| 607 | + if (msg_tx == &tmp) | |
| 608 | 608 | sk_msg_free(sk, msg_tx); |
| 609 | 609 | goto out_err; |
| 610 | 610 | } |
| @@ -4038,24 +4038,17 @@ static void tcp_send_ack_reflect_ect(struct sock *sk, bool accecn_reflector) · 4037 unmodified lines | ||
| 4038 | 4038 | __tcp_send_ack(sk, tp->rcv_nxt, flags); |
| 4039 | 4039 | } |
| 4040 | 4040 | |
| 4041 | −/* RFC 5961 7 [ACK Throttling] */ | |
| 4042 | −static void tcp_send_challenge_ack(struct sock *sk, bool accecn_reflector) | |
| 4041 | +/* Consume one slot from the per-netns RFC 5961 challenge ACK quota. | |
| 4042 | + * Returns true if a challenge ACK may be sent. | |
| 4043 | + */ | |
| 4044 | +static bool tcp_challenge_ack_allowed(struct net *net) | |
| 4043 | 4045 | { |
| 4044 | − struct tcp_sock *tp = tcp_sk(sk); | |
| 4045 | − struct net *net = sock_net(sk); | |
| 4046 | 4046 | u32 count, now, ack_limit; |
| 4047 | 4047 | |
| 4048 | − /* First check our per-socket dupack rate limit. */ | |
| 4049 | − if (__tcp_oow_rate_limited(net, | |
| 4050 | − LINUX_MIB_TCPACKSKIPPEDCHALLENGE, | |
| 4051 | − &tp->last_oow_ack_time)) | |
| 4052 | − return; | |
| 4053 | − | |
| 4054 | 4048 | ack_limit = READ_ONCE(net->ipv4.sysctl_tcp_challenge_ack_limit); |
| 4055 | 4049 | if (ack_limit == INT_MAX) |
| 4056 | − goto send_ack; | |
| 4050 | + return true; | |
| 4057 | 4051 | |
| 4058 | − /* Then check host-wide RFC 5961 rate limit. */ | |
| 4059 | 4052 | now = jiffies / HZ; |
| 4060 | 4053 | if (now != READ_ONCE(net->ipv4.tcp_challenge_timestamp)) { |
| 4061 | 4054 | u32 half = (ack_limit + 1) >> 1; |
| @@ -4067,12 +4060,49 @@ static void tcp_send_challenge_ack(struct sock *sk, bool accecn_reflector) · 5 unmodified lines | ||
| 4067 | 4060 | count = READ_ONCE(net->ipv4.tcp_challenge_count); |
| 4068 | 4061 | if (count > 0) { |
| 4069 | 4062 | WRITE_ONCE(net->ipv4.tcp_challenge_count, count - 1); |
| 4070 | −send_ack: | |
| 4063 | + return true; | |
| 4064 | + } | |
| 4065 | + return false; | |
| 4066 | +} | |
| 4067 | + | |
| 4068 | +/* RFC 5961 7 [ACK Throttling] */ | |
| 4069 | +static void tcp_send_challenge_ack(struct sock *sk, bool accecn_reflector) | |
| 4070 | +{ | |
| 4071 | + struct tcp_sock *tp = tcp_sk(sk); | |
| 4072 | + struct net *net = sock_net(sk); | |
| 4073 | + | |
| 4074 | + /* First check our per-socket dupack rate limit. */ | |
| 4075 | + if (__tcp_oow_rate_limited(net, | |
| 4076 | + LINUX_MIB_TCPACKSKIPPEDCHALLENGE, | |
| 4077 | + &tp->last_oow_ack_time)) | |
| 4078 | + return; | |
| 4079 | + | |
| 4080 | + /* Then check the per-netns RFC 5961 rate limit. */ | |
| 4081 | + if (tcp_challenge_ack_allowed(net)) { | |
| 4071 | 4082 | NET_INC_STATS(net, LINUX_MIB_TCPCHALLENGEACK); |
| 4072 | 4083 | tcp_send_ack_reflect_ect(sk, accecn_reflector); |
| 4073 | 4084 | } |
| 4074 | 4085 | } |
| 4075 | 4086 | |
| 4087 | +/* Send a challenge ACK from a SYN-RECEIVED request socket. Uses | |
| 4088 | + * __tcp_oow_rate_limited() directly so that an RST carrying payload | |
| 4089 | + * cannot bypass the per-request rate limit. | |
| 4090 | + */ | |
| 4091 | +void tcp_reqsk_send_challenge_ack(struct sock *sk, struct sk_buff *skb, | |
| 4092 | + struct request_sock *req) | |
| 4093 | +{ | |
| 4094 | + struct net *net = sock_net(sk); | |
| 4095 | + | |
| 4096 | + if (__tcp_oow_rate_limited(net, LINUX_MIB_TCPACKSKIPPEDCHALLENGE, | |
| 4097 | + &tcp_rsk(req)->last_oow_ack_time)) | |
| 4098 | + return; | |
| 4099 | + | |
| 4100 | + if (tcp_challenge_ack_allowed(net)) { | |
| 4101 | + NET_INC_STATS(net, LINUX_MIB_TCPCHALLENGEACK); | |
| 4102 | + req->rsk_ops->send_ack(sk, skb, req); | |
| 4103 | + } | |
| 4104 | +} | |
| 4105 | + | |
| 4076 | 4106 | static void tcp_store_ts_recent(struct tcp_sock *tp) |
| 4077 | 4107 | { |
| 4078 | 4108 | tp->rx_opt.ts_recent = tp->rx_opt.rcv_tsval; |
| @@ -971,6 +971,9 @@ static void tcp_v4_send_ack(const struct sock *sk, · 970 unmodified lines | ||
| 971 | 971 | key->rcv_next); |
| 972 | 972 | arg.iov[0].iov_len += tcp_ao_len_aligned(key->ao_key); |
| 973 | 973 | rep.th.doff = arg.iov[0].iov_len / 4; |
| 974 | + memset((u8 *)&rep.opt[offset] + tcp_ao_maclen(key->ao_key), | |
| 975 | + TCPOPT_NOP, tcp_ao_len_aligned(key->ao_key) - | |
| 976 | + tcp_ao_len(key->ao_key)); | |
| 974 | 977 | |
| 975 | 978 | tcp_ao_hash_hdr(AF_INET, (char *)&rep.opt[offset], |
| 976 | 979 | key->ao_key, key->traffic_key, |
| @@ -3143,8 +3146,11 @@ static struct sock *bpf_iter_tcp_batch(struct seq_file *seq) · 2166 unmodified lines | ||
| 3143 | 3146 | bpf_iter_tcp_put_batch(iter); |
| 3144 | 3147 | err = bpf_iter_tcp_realloc_batch(iter, expected * 3 / 2, |
| 3145 | 3148 | GFP_USER); |
| 3146 | − if (err) | |
| 3149 | + if (err) { | |
| 3150 | + iter->cur_sk = 0; | |
| 3151 | + iter->end_sk = 0; | |
| 3147 | 3152 | return ERR_PTR(err); |
| 3153 | + } | |
| 3148 | 3154 | |
| 3149 | 3155 | sk = bpf_iter_tcp_resume(seq); |
| 3150 | 3156 | if (!sk) |
| @@ -833,7 +833,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, · 832 unmodified lines | ||
| 833 | 833 | * elsewhere and is checked directly against the child socket rather |
| 834 | 834 | * than req because user data may have been sent out. |
| 835 | 835 | */ |
| 836 | − if ((flg & TCP_FLAG_ACK) && !fastopen && | |
| 836 | + if ((flg & TCP_FLAG_ACK) && !(flg & TCP_FLAG_RST) && !fastopen && | |
| 837 | 837 | (TCP_SKB_CB(skb)->ack_seq != |
| 838 | 838 | tcp_rsk(req)->snt_isn + 1)) |
| 839 | 839 | return sk; |
| @@ -872,6 +872,16 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, · 32 unmodified lines | ||
| 872 | 872 | flg &= ~TCP_FLAG_SYN; |
| 873 | 873 | } |
| 874 | 874 | |
| 875 | + /* RFC 5961 section 3.2, as clarified by RFC 9293 section | |
| 876 | + * 3.10.7.4, requires a challenge ACK for a non-exact | |
| 877 | + * in-window RST in SYN-RECEIVED. | |
| 878 | + */ | |
| 879 | + if ((flg & TCP_FLAG_RST) && | |
| 880 | + TCP_SKB_CB(skb)->seq != tcp_rsk(req)->rcv_nxt) { | |
| 881 | + tcp_reqsk_send_challenge_ack(sk, skb, req); | |
| 882 | + return NULL; | |
| 883 | + } | |
| 884 | + | |
| 875 | 885 | /* RFC793: "second check the RST bit" and |
| 876 | 886 | * "fourth, check the SYN bit" |
| 877 | 887 | */ |
| @@ -85,6 +85,7 @@ static void ila_csum_adjust_transport(struct sk_buff *skb, · 84 unmodified lines | ||
| 85 | 85 | struct tcphdr *th = (struct tcphdr *) |
| 86 | 86 | (skb_network_header(skb) + nhoff); |
| 87 | 87 | |
| 88 | + ip6h = ipv6_hdr(skb); | |
| 88 | 89 | diff = get_csum_diff(ip6h, p); |
| 89 | 90 | inet_proto_csum_replace_by_diff(&th->check, skb, |
| 90 | 91 | diff, true, true); |
| @@ -96,6 +97,7 @@ static void ila_csum_adjust_transport(struct sk_buff *skb, · 5 unmodified lines | ||
| 96 | 97 | (skb_network_header(skb) + nhoff); |
| 97 | 98 | |
| 98 | 99 | if (uh->check || skb->ip_summed == CHECKSUM_PARTIAL) { |
| 100 | + ip6h = ipv6_hdr(skb); | |
| 99 | 101 | diff = get_csum_diff(ip6h, p); |
| 100 | 102 | inet_proto_csum_replace_by_diff(&uh->check, skb, |
| 101 | 103 | diff, true, true); |
| @@ -110,6 +112,7 @@ static void ila_csum_adjust_transport(struct sk_buff *skb, · 8 unmodified lines | ||
| 110 | 112 | struct icmp6hdr *ih = (struct icmp6hdr *) |
| 111 | 113 | (skb_network_header(skb) + nhoff); |
| 112 | 114 | |
| 115 | + ip6h = ipv6_hdr(skb); | |
| 113 | 116 | diff = get_csum_diff(ip6h, p); |
| 114 | 117 | inet_proto_csum_replace_by_diff(&ih->icmp6_cksum, skb, |
| 115 | 118 | diff, true, true); |
| @@ -127,6 +130,15 @@ void ila_update_ipv6_locator(struct sk_buff *skb, struct ila_params *p, · 11 unmodified lines | ||
| 127 | 130 | switch (p->csum_mode) { |
| 128 | 131 | case ILA_CSUM_ADJUST_TRANSPORT: |
| 129 | 132 | ila_csum_adjust_transport(skb, p); |
| 133 | + /* | |
| 134 | + * ila_csum_adjust_transport() calls pskb_may_pull(), which can | |
| 135 | + * reallocate the skb head and leave ip6h (and the iaddr derived | |
| 136 | + * from it) dangling; reload both before the write below. The | |
| 137 | + * other csum modes do not pull, so their cached pointers stay | |
| 138 | + * valid. | |
| 139 | + */ | |
| 140 | + ip6h = ipv6_hdr(skb); | |
| 141 | + iaddr = ila_a2i(&ip6h->daddr); | |
| 130 | 142 | break; |
| 131 | 143 | case ILA_CSUM_NEUTRAL_MAP: |
| 132 | 144 | if (sir2ila) { |
| @@ -1455,6 +1455,8 @@ static void ip6gre_tnl_init_features(struct net_device *dev) · 1454 unmodified lines | ||
| 1455 | 1455 | dev->features |= GRE6_FEATURES; |
| 1456 | 1456 | dev->hw_features |= GRE6_FEATURES; |
| 1457 | 1457 | |
| 1458 | + dev->lltx = true; | |
| 1459 | + | |
| 1458 | 1460 | /* TCP offload with GRE SEQ is not supported, nor can we support 2 |
| 1459 | 1461 | * levels of outer headers requiring an update. |
| 1460 | 1462 | */ |
| @@ -1466,8 +1468,6 @@ static void ip6gre_tnl_init_features(struct net_device *dev) · 5 unmodified lines | ||
| 1466 | 1468 | |
| 1467 | 1469 | dev->features |= NETIF_F_GSO_SOFTWARE; |
| 1468 | 1470 | dev->hw_features |= NETIF_F_GSO_SOFTWARE; |
| 1469 | − | |
| 1470 | − dev->lltx = true; | |
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | 1473 | static int ip6gre_tunnel_init_common(struct net_device *dev) |
| @@ -349,7 +349,7 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr, · 348 unmodified lines | ||
| 349 | 349 | const struct ipv6hdr *ip6h = (const struct ipv6hdr *)skb->data; |
| 350 | 350 | |
| 351 | 351 | if (!raw_v6_match(net, sk, nexthdr, &ip6h->saddr, &ip6h->daddr, |
| 352 | − inet6_iif(skb), inet6_iif(skb))) | |
| 352 | + inet6_iif(skb), inet6_sdif(skb))) | |
| 353 | 353 | continue; |
| 354 | 354 | rawv6_err(sk, skb, type, code, inner_offset, info); |
| 355 | 355 | } |
| @@ -4022,7 +4022,7 @@ static int __ip6_del_rt_siblings(struct fib6_info *rt, struct fib6_config *cfg) · 4021 unmodified lines | ||
| 4022 | 4022 | struct fib6_node *fn; |
| 4023 | 4023 | |
| 4024 | 4024 | /* prefer to send a single notification with all hops */ |
| 4025 | − skb = nlmsg_new(rt6_nlmsg_size(rt), gfp_any()); | |
| 4025 | + skb = nlmsg_new(rt6_nlmsg_size(rt), GFP_ATOMIC); | |
| 4026 | 4026 | if (skb) { |
| 4027 | 4027 | u32 seq = info->nlh ? info->nlh->nlmsg_seq : 0; |
| 4028 | 4028 | |
| @@ -4078,7 +4078,7 @@ out_put: · 49 unmodified lines | ||
| 4078 | 4078 | |
| 4079 | 4079 | if (skb) { |
| 4080 | 4080 | rtnl_notify(skb, net, info->portid, RTNLGRP_IPV6_ROUTE, |
| 4081 | − info->nlh, gfp_any()); | |
| 4081 | + info->nlh, GFP_ATOMIC); | |
| 4082 | 4082 | } |
| 4083 | 4083 | return err; |
| 4084 | 4084 | } |
| @@ -923,6 +923,8 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32 · 922 unmodified lines | ||
| 923 | 923 | (tcp_ao_len(key->ao_key) << 16) | |
| 924 | 924 | (key->ao_key->sndid << 8) | |
| 925 | 925 | (key->rcv_next)); |
| 926 | + memset((u8 *)topt + tcp_ao_maclen(key->ao_key), TCPOPT_NOP, | |
| 927 | + tcp_ao_len_aligned(key->ao_key) - tcp_ao_len(key->ao_key)); | |
| 926 | 928 | |
| 927 | 929 | tcp_ao_hash_hdr(AF_INET6, (char *)topt, key->ao_key, |
| 928 | 930 | key->traffic_key, |
| @@ -337,6 +337,7 @@ static void iucv_sever_path(struct sock *sk, int with_user_data) · 336 unmodified lines | ||
| 337 | 337 | unsigned char user_data[16]; |
| 338 | 338 | struct iucv_sock *iucv = iucv_sk(sk); |
| 339 | 339 | struct iucv_path *path = iucv->path; |
| 340 | + struct sock_msg_q *p, *n; | |
| 340 | 341 | |
| 341 | 342 | /* Whoever resets the path pointer, must sever and free it. */ |
| 342 | 343 | if (xchg(&iucv->path, NULL)) { |
| @@ -348,6 +349,19 @@ static void iucv_sever_path(struct sock *sk, int with_user_data) · 5 unmodified lines | ||
| 348 | 349 | } else |
| 349 | 350 | pr_iucv->path_sever(path, NULL); |
| 350 | 351 | iucv_path_free(path); |
| 352 | + | |
| 353 | + /* | |
| 354 | + * Message notifications queued on message_q still reference | |
| 355 | + * the now freed path; drop them, otherwise a later recvmsg() | |
| 356 | + * would pass the freed iucv_path to message_receive() via | |
| 357 | + * iucv_process_message_q(). | |
| 358 | + */ | |
| 359 | + spin_lock_bh(&iucv->message_q.lock); | |
| 360 | + list_for_each_entry_safe(p, n, &iucv->message_q.list, list) { | |
| 361 | + list_del(&p->list); | |
| 362 | + kfree(p); | |
| 363 | + } | |
| 364 | + spin_unlock_bh(&iucv->message_q.lock); | |
| 351 | 365 | } |
| 352 | 366 | } |
| 353 | 367 | |
| @@ -1872,7 +1886,8 @@ static int afiucv_hs_callback_syn(struct sock *sk, struct sk_buff *skb) · 1518 unmodified lines | ||
| 1872 | 1886 | afiucv_swap_src_dest(skb); |
| 1873 | 1887 | trans_hdr->flags = AF_IUCV_FLAG_SYN | AF_IUCV_FLAG_FIN; |
| 1874 | 1888 | err = dev_queue_xmit(skb); |
| 1875 | − iucv_sock_kill(nsk); | |
| 1889 | + if (nsk) | |
| 1890 | + iucv_sock_kill(nsk); | |
| 1876 | 1891 | bh_unlock_sock(sk); |
| 1877 | 1892 | goto out; |
| 1878 | 1893 | } |
| @@ -2611,6 +2611,9 @@ static int sta_apply_parameters(struct ieee80211_local *local, · 2610 unmodified lines | ||
| 2611 | 2611 | memcpy(&sta->deflink.pub->supp_rates, |
| 2612 | 2612 | &nmi_sta->deflink.pub->supp_rates, |
| 2613 | 2613 | sizeof(sta->deflink.pub->supp_rates)); |
| 2614 | + | |
| 2615 | + sta->deflink.pub->agg = nmi_sta->deflink.pub->agg; | |
| 2616 | + __ieee80211_sta_recalc_aggregates(sta, 0); | |
| 2614 | 2617 | } |
| 2615 | 2618 | |
| 2616 | 2619 | /* set the STA state after all sta info from usermode has been set */ |
| @@ -399,6 +399,10 @@ static int ieee80211_vif_update_links(struct ieee80211_sub_if_data *sdata, · 398 unmodified lines | ||
| 399 | 399 | memcpy(sdata->link, old_data, sizeof(old_data)); |
| 400 | 400 | memcpy(sdata->vif.link_conf, old, sizeof(old)); |
| 401 | 401 | ieee80211_set_vif_links_bitmaps(sdata, old_links, dormant_links); |
| 402 | + for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) { | |
| 403 | + ieee80211_link_debugfs_remove(&links[link_id]->data); | |
| 404 | + ieee80211_link_stop(&links[link_id]->data); | |
| 405 | + } | |
| 402 | 406 | /* and free (only) the newly allocated links */ |
| 403 | 407 | memset(to_free, 0, sizeof(links)); |
| 404 | 408 | goto free; |
| @@ -1717,6 +1717,8 @@ static void sta_ps_start(struct sta_info *sta) · 1716 unmodified lines | ||
| 1717 | 1717 | else |
| 1718 | 1718 | clear_bit(tid, &sta->txq_buffered_tids); |
| 1719 | 1719 | } |
| 1720 | + | |
| 1721 | + sta_info_recalc_tim(sta); | |
| 1720 | 1722 | } |
| 1721 | 1723 | |
| 1722 | 1724 | static void sta_ps_end(struct sta_info *sta) |
| @@ -891,6 +891,11 @@ llsec_do_decrypt_auth(struct sk_buff *skb, const struct mac802154_llsec *sec, · 890 unmodified lines | ||
| 891 | 891 | data = skb_mac_header(skb) + skb->mac_len; |
| 892 | 892 | datalen = skb_tail_pointer(skb) - data; |
| 893 | 893 | |
| 894 | + if (datalen < authlen) { | |
| 895 | + kfree_sensitive(req); | |
| 896 | + return -EBADMSG; | |
| 897 | + } | |
| 898 | + | |
| 894 | 899 | sg_init_one(&sg, skb_mac_header(skb), assoclen + datalen); |
| 895 | 900 | |
| 896 | 901 | if (!(hdr->sec.level & IEEE802154_SCF_SECLEVEL_ENC)) { |
| @@ -179,6 +179,7 @@ void mac802154_scan_worker(struct work_struct *work) · 178 unmodified lines | ||
| 179 | 179 | enum nl802154_scan_types scan_req_type; |
| 180 | 180 | struct ieee802154_sub_if_data *sdata; |
| 181 | 181 | unsigned int scan_duration = 0; |
| 182 | + netdevice_tracker dev_tracker; | |
| 182 | 183 | struct wpan_phy *wpan_phy; |
| 183 | 184 | u8 scan_req_duration; |
| 184 | 185 | u8 page, channel; |
| @@ -209,6 +210,14 @@ void mac802154_scan_worker(struct work_struct *work) · 24 unmodified lines | ||
| 209 | 210 | return; |
| 210 | 211 | } |
| 211 | 212 | |
| 213 | + /* | |
| 214 | + * sdata->dev is dereferenced below after rcu_read_unlock() and outside | |
| 215 | + * the rtnl, and a concurrent DEL_INTERFACE / PHY teardown can free it | |
| 216 | + * asynchronously from netdev_run_todo(). Pin it with a reference taken | |
| 217 | + * while the RCU read lock is still held, and drop it at every exit. | |
| 218 | + */ | |
| 219 | + netdev_hold(sdata->dev, &dev_tracker, GFP_ATOMIC); | |
| 220 | + | |
| 212 | 221 | wpan_phy = scan_req->wpan_phy; |
| 213 | 222 | scan_req_type = scan_req->type; |
| 214 | 223 | scan_req_duration = scan_req->duration; |
| @@ -262,12 +271,14 @@ void mac802154_scan_worker(struct work_struct *work) · 47 unmodified lines | ||
| 262 | 271 | "Scan page %u channel %u for %ums\n", |
| 263 | 272 | page, channel, jiffies_to_msecs(scan_duration)); |
| 264 | 273 | queue_delayed_work(local->mac_wq, &local->scan_work, scan_duration); |
| 274 | + netdev_put(sdata->dev, &dev_tracker); | |
| 265 | 275 | return; |
| 266 | 276 | |
| 267 | 277 | end_scan: |
| 268 | 278 | rtnl_lock(); |
| 269 | 279 | mac802154_scan_cleanup_locked(local, sdata, false); |
| 270 | 280 | rtnl_unlock(); |
| 281 | + netdev_put(sdata->dev, &dev_tracker); | |
| 271 | 282 | } |
| 272 | 283 | |
| 273 | 284 | int mac802154_trigger_scan_locked(struct ieee802154_sub_if_data *sdata, |
| @@ -536,7 +536,9 @@ int __init mctp_device_init(void) · 535 unmodified lines | ||
| 536 | 536 | { |
| 537 | 537 | int err; |
| 538 | 538 | |
| 539 | − register_netdevice_notifier(&mctp_dev_nb); | |
| 539 | + err = register_netdevice_notifier(&mctp_dev_nb); | |
| 540 | + if (err) | |
| 541 | + return err; | |
| 540 | 542 | |
| 541 | 543 | err = rtnl_af_register(&mctp_af_ops); |
| 542 | 544 | if (err) |
| @@ -922,8 +922,7 @@ static int mpls_nh_build_multi(struct mpls_route_config *cfg, · 921 unmodified lines | ||
| 922 | 922 | struct nlattr *nla_via, *nla_newdst; |
| 923 | 923 | int remaining = cfg->rc_mp_len; |
| 924 | 924 | int err = 0; |
| 925 | − | |
| 926 | − rt->rt_nhn = 0; | |
| 925 | + u8 nhs = 0; | |
| 927 | 926 | |
| 928 | 927 | change_nexthops(rt) { |
| 929 | 928 | int attrlen; |
| @@ -959,12 +958,15 @@ static int mpls_nh_build_multi(struct mpls_route_config *cfg, · 29 unmodified lines | ||
| 959 | 958 | rt->rt_nhn_alive--; |
| 960 | 959 | |
| 961 | 960 | rtnh = rtnh_next(rtnh, &remaining); |
| 962 | − rt->rt_nhn++; | |
| 961 | + nhs++; | |
| 963 | 962 | } endfor_nexthops(rt); |
| 964 | 963 | |
| 964 | + rt->rt_nhn = nhs; | |
| 965 | + | |
| 965 | 966 | return 0; |
| 966 | 967 | |
| 967 | 968 | errout: |
| 969 | + rt->rt_nhn = nhs; | |
| 968 | 970 | return err; |
| 969 | 971 | } |
| 970 | 972 | |
| @@ -157,17 +157,11 @@ static void mptcp_parse_option(const struct sk_buff *skb, · 156 unmodified lines | ||
| 157 | 157 | ptr++; |
| 158 | 158 | |
| 159 | 159 | flags = (*ptr++) & MPTCP_DSS_FLAG_MASK; |
| 160 | − mp_opt->data_fin = (flags & MPTCP_DSS_DATA_FIN) != 0; | |
| 161 | 160 | mp_opt->dsn64 = (flags & MPTCP_DSS_DSN64) != 0; |
| 162 | 161 | mp_opt->use_map = (flags & MPTCP_DSS_HAS_MAP) != 0; |
| 163 | 162 | mp_opt->ack64 = (flags & MPTCP_DSS_ACK64) != 0; |
| 164 | 163 | mp_opt->use_ack = (flags & MPTCP_DSS_HAS_ACK); |
| 165 | 164 | |
| 166 | − pr_debug("data_fin=%d dsn64=%d use_map=%d ack64=%d use_ack=%d\n", | |
| 167 | − mp_opt->data_fin, mp_opt->dsn64, | |
| 168 | − mp_opt->use_map, mp_opt->ack64, | |
| 169 | − mp_opt->use_ack); | |
| 170 | − | |
| 171 | 165 | expected_opsize = TCPOLEN_MPTCP_DSS_BASE; |
| 172 | 166 | |
| 173 | 167 | if (mp_opt->use_ack) { |
| @@ -178,12 +172,18 @@ static void mptcp_parse_option(const struct sk_buff *skb, · 4 unmodified lines | ||
| 178 | 172 | } |
| 179 | 173 | |
| 180 | 174 | if (mp_opt->use_map) { |
| 175 | + mp_opt->data_fin = (flags & MPTCP_DSS_DATA_FIN) != 0; | |
| 181 | 176 | if (mp_opt->dsn64) |
| 182 | 177 | expected_opsize += TCPOLEN_MPTCP_DSS_MAP64; |
| 183 | 178 | else |
| 184 | 179 | expected_opsize += TCPOLEN_MPTCP_DSS_MAP32; |
| 185 | 180 | } |
| 186 | 181 | |
| 182 | + pr_debug("data_fin=%d dsn64=%d use_map=%d ack64=%d use_ack=%d\n", | |
| 183 | + mp_opt->data_fin, mp_opt->dsn64, | |
| 184 | + mp_opt->use_map, mp_opt->ack64, | |
| 185 | + mp_opt->use_ack); | |
| 186 | + | |
| 187 | 187 | /* Always parse any csum presence combination, we will enforce |
| 188 | 188 | * RFC 8684 Section 3.3.0 checks later in subflow_data_ready |
| 189 | 189 | */ |
| @@ -571,10 +571,7 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, · 381 unmodified lines | ||
| 571 | 571 | bool ret = false; |
| 572 | 572 | |
| 573 | 573 | /* Zero `use_ack` and `use_map` flags with one shot. */ |
| 574 | − BUILD_BUG_ON(sizeof_field(struct mptcp_ext, flags) != sizeof(u16)); | |
| 575 | − BUILD_BUG_ON(!IS_ALIGNED(offsetof(struct mptcp_ext, flags), | |
| 576 | − sizeof(u16))); | |
| 577 | − *(u16 *)&opts->ext_copy.flags = 0; | |
| 574 | + memset(&opts->ext_copy.flags, 0, sizeof(opts->ext_copy.flags)); | |
| 578 | 575 | opts->csum_reqd = READ_ONCE(msk->csum_enabled); |
| 579 | 576 | mpext = skb ? mptcp_get_ext(skb) : NULL; |
| 580 | 577 | |
| @@ -132,12 +132,15 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, · 131 unmodified lines | ||
| 132 | 132 | __be16 msk_sport = ((struct inet_sock *) |
| 133 | 133 | inet_sk((struct sock *)msk))->inet_sport; |
| 134 | 134 | struct mptcp_pm_addr_entry *entry; |
| 135 | + int id; | |
| 135 | 136 | |
| 136 | 137 | spin_lock_bh(&msk->pm.lock); |
| 137 | 138 | entry = mptcp_userspace_pm_lookup_addr(msk, &skc->addr); |
| 139 | + id = entry ? entry->addr.id : -1; | |
| 138 | 140 | spin_unlock_bh(&msk->pm.lock); |
| 139 | − if (entry) | |
| 140 | − return entry->addr.id; | |
| 141 | + | |
| 142 | + if (id != -1) | |
| 143 | + return id; | |
| 141 | 144 | |
| 142 | 145 | if (skc->addr.port == msk_sport) |
| 143 | 146 | skc->addr.port = 0; |
| @@ -2545,6 +2545,22 @@ static void __mptcp_subflow_disconnect(struct sock *ssk, · 2544 unmodified lines | ||
| 2545 | 2545 | } |
| 2546 | 2546 | } |
| 2547 | 2547 | |
| 2548 | +static void mptcp_cleanup_ssk_backlog(struct sock *sk, struct sock *ssk) | |
| 2549 | +{ | |
| 2550 | + struct mptcp_sock *msk = mptcp_sk(sk); | |
| 2551 | + struct sk_buff *skb; | |
| 2552 | + | |
| 2553 | + mptcp_data_lock(sk); | |
| 2554 | + list_for_each_entry(skb, &msk->backlog_list, list) { | |
| 2555 | + if (skb->sk != ssk) | |
| 2556 | + continue; | |
| 2557 | + | |
| 2558 | + atomic_sub(skb->truesize, &skb->sk->sk_rmem_alloc); | |
| 2559 | + skb->sk = NULL; | |
| 2560 | + } | |
| 2561 | + mptcp_data_unlock(sk); | |
| 2562 | +} | |
| 2563 | + | |
| 2548 | 2564 | /* subflow sockets can be either outgoing (connect) or incoming |
| 2549 | 2565 | * (accept). |
| 2550 | 2566 | * |
| @@ -2568,6 +2584,9 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, · 17 unmodified lines | ||
| 2568 | 2584 | lock_sock_nested(ssk, SINGLE_DEPTH_NESTING); |
| 2569 | 2585 | subflow->closing = 1; |
| 2570 | 2586 | |
| 2587 | + if (flags & MPTCP_CF_PUSH) | |
| 2588 | + mptcp_cleanup_ssk_backlog(sk, ssk); | |
| 2589 | + | |
| 2571 | 2590 | /* Borrow the fwd allocated page left-over; fwd memory for the subflow |
| 2572 | 2591 | * could be negative at this point, but will be reach zero soon - when |
| 2573 | 2592 | * the data allocated using such fragment will be freed. |
| @@ -2659,9 +2678,6 @@ out: · 85 unmodified lines | ||
| 2659 | 2678 | void mptcp_close_ssk(struct sock *sk, struct sock *ssk, |
| 2660 | 2679 | struct mptcp_subflow_context *subflow) |
| 2661 | 2680 | { |
| 2662 | − struct mptcp_sock *msk = mptcp_sk(sk); | |
| 2663 | − struct sk_buff *skb; | |
| 2664 | − | |
| 2665 | 2681 | /* The first subflow can already be closed or disconnected */ |
| 2666 | 2682 | if (subflow->close_event_done || READ_ONCE(subflow->local_id) < 0) |
| 2667 | 2683 | return; |
| @@ -2671,17 +2687,6 @@ void mptcp_close_ssk(struct sock *sk, struct sock *ssk, · 3 unmodified lines | ||
| 2671 | 2687 | if (sk->sk_state == TCP_ESTABLISHED) |
| 2672 | 2688 | mptcp_event(MPTCP_EVENT_SUB_CLOSED, mptcp_sk(sk), ssk, GFP_KERNEL); |
| 2673 | 2689 | |
| 2674 | − /* Remove any reference from the backlog to this ssk; backlog skbs consume | |
| 2675 | − * space in the msk receive queue, no need to touch sk->sk_rmem_alloc | |
| 2676 | − */ | |
| 2677 | − list_for_each_entry(skb, &msk->backlog_list, list) { | |
| 2678 | − if (skb->sk != ssk) | |
| 2679 | − continue; | |
| 2680 | − | |
| 2681 | − atomic_sub(skb->truesize, &skb->sk->sk_rmem_alloc); | |
| 2682 | − skb->sk = NULL; | |
| 2683 | − } | |
| 2684 | − | |
| 2685 | 2690 | /* subflow aborted before reaching the fully_established status |
| 2686 | 2691 | * attempt the creation of the next subflow |
| 2687 | 2692 | */ |
| @@ -3907,6 +3912,7 @@ bool mptcp_finish_join(struct sock *ssk) · 1219 unmodified lines | ||
| 3907 | 3912 | mptcp_data_unlock(parent); |
| 3908 | 3913 | |
| 3909 | 3914 | if (!ret) { |
| 3915 | + mptcp_pm_close_subflow(msk); | |
| 3910 | 3916 | err_prohibited: |
| 3911 | 3917 | subflow->reset_reason = MPTCP_RST_EPROHIBIT; |
| 3912 | 3918 | return false; |
| @@ -837,12 +837,8 @@ static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port, · 836 unmodified lines | ||
| 837 | 837 | u16 mru = OVS_CB(skb)->mru; |
| 838 | 838 | u32 cutlen = OVS_CB(skb)->cutlen; |
| 839 | 839 | |
| 840 | − if (unlikely(cutlen > 0)) { | |
| 841 | − if (skb->len - cutlen > ovs_mac_header_len(key)) | |
| 842 | − pskb_trim(skb, skb->len - cutlen); | |
| 843 | − else | |
| 844 | − pskb_trim(skb, ovs_mac_header_len(key)); | |
| 845 | − } | |
| 840 | + if (unlikely(cutlen < skb->len)) | |
| 841 | + pskb_trim(skb, max(cutlen, ovs_mac_header_len(key))); | |
| 846 | 842 | |
| 847 | 843 | if (likely(!mru || |
| 848 | 844 | (skb->len <= mru + vport->dev->hard_header_len))) { |
| @@ -1234,7 +1230,7 @@ static void execute_psample(struct datapath *dp, struct sk_buff *skb, · 385 unmodified lines | ||
| 1234 | 1230 | |
| 1235 | 1231 | psample_group.net = ovs_dp_get_net(dp); |
| 1236 | 1232 | md.in_ifindex = OVS_CB(skb)->input_vport->dev->ifindex; |
| 1237 | − md.trunc_size = skb->len - OVS_CB(skb)->cutlen; | |
| 1233 | + md.trunc_size = min(skb->len, OVS_CB(skb)->cutlen); | |
| 1238 | 1234 | md.rate_as_probability = 1; |
| 1239 | 1235 | |
| 1240 | 1236 | rate = OVS_CB(skb)->probability ? OVS_CB(skb)->probability : U32_MAX; |
| @@ -1284,22 +1280,21 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, · 43 unmodified lines | ||
| 1284 | 1280 | clone = skb_clone(skb, GFP_ATOMIC); |
| 1285 | 1281 | if (clone) |
| 1286 | 1282 | do_output(dp, clone, port, key); |
| 1287 | − OVS_CB(skb)->cutlen = 0; | |
| 1283 | + OVS_CB(skb)->cutlen = U32_MAX; | |
| 1288 | 1284 | break; |
| 1289 | 1285 | } |
| 1290 | 1286 | |
| 1291 | 1287 | case OVS_ACTION_ATTR_TRUNC: { |
| 1292 | 1288 | struct ovs_action_trunc *trunc = nla_data(a); |
| 1293 | 1289 | |
| 1294 | − if (skb->len > trunc->max_len) | |
| 1295 | − OVS_CB(skb)->cutlen = skb->len - trunc->max_len; | |
| 1290 | + OVS_CB(skb)->cutlen = trunc->max_len; | |
| 1296 | 1291 | break; |
| 1297 | 1292 | } |
| 1298 | 1293 | |
| 1299 | 1294 | case OVS_ACTION_ATTR_USERSPACE: |
| 1300 | 1295 | output_userspace(dp, skb, key, a, attr, |
| 1301 | 1296 | len, OVS_CB(skb)->cutlen); |
| 1302 | − OVS_CB(skb)->cutlen = 0; | |
| 1297 | + OVS_CB(skb)->cutlen = U32_MAX; | |
| 1303 | 1298 | if (nla_is_last(a, rem)) { |
| 1304 | 1299 | consume_skb(skb); |
| 1305 | 1300 | return 0; |
| @@ -1453,7 +1448,7 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, · 147 unmodified lines | ||
| 1453 | 1448 | |
| 1454 | 1449 | case OVS_ACTION_ATTR_PSAMPLE: |
| 1455 | 1450 | execute_psample(dp, skb, a); |
| 1456 | − OVS_CB(skb)->cutlen = 0; | |
| 1451 | + OVS_CB(skb)->cutlen = U32_MAX; | |
| 1457 | 1452 | if (nla_is_last(a, rem)) { |
| 1458 | 1453 | consume_skb(skb); |
| 1459 | 1454 | return 0; |
| @@ -276,7 +276,7 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key) · 275 unmodified lines | ||
| 276 | 276 | upcall.portid = ovs_vport_find_upcall_portid(p, skb); |
| 277 | 277 | |
| 278 | 278 | upcall.mru = OVS_CB(skb)->mru; |
| 279 | − error = ovs_dp_upcall(dp, skb, key, &upcall, 0); | |
| 279 | + error = ovs_dp_upcall(dp, skb, key, &upcall, U32_MAX); | |
| 280 | 280 | switch (error) { |
| 281 | 281 | case 0: |
| 282 | 282 | case -EAGAIN: |
| @@ -457,7 +457,8 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, · 174 unmodified lines | ||
| 457 | 457 | struct sk_buff *nskb = NULL; |
| 458 | 458 | struct sk_buff *user_skb = NULL; /* to be queued to userspace */ |
| 459 | 459 | struct nlattr *nla; |
| 460 | − size_t len; | |
| 460 | + size_t msg_size; | |
| 461 | + size_t skb_len; | |
| 461 | 462 | unsigned int hlen; |
| 462 | 463 | int err, dp_ifindex; |
| 463 | 464 | u64 hash; |
| @@ -478,7 +479,8 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, · 14 unmodified lines | ||
| 478 | 479 | skb = nskb; |
| 479 | 480 | } |
| 480 | 481 | |
| 481 | − if (nla_attr_size(skb->len) > USHRT_MAX) { | |
| 482 | + skb_len = min(skb->len, cutlen); | |
| 483 | + if (nla_attr_size(skb_len) > USHRT_MAX) { | |
| 482 | 484 | err = -EFBIG; |
| 483 | 485 | goto out; |
| 484 | 486 | } |
| @@ -493,13 +495,13 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, · 8 unmodified lines | ||
| 493 | 495 | * padding logic. Only perform zerocopy if padding is not required. |
| 494 | 496 | */ |
| 495 | 497 | if (dp->user_features & OVS_DP_F_UNALIGNED) |
| 496 | − hlen = skb_zerocopy_headlen(skb); | |
| 498 | + hlen = min(skb_zerocopy_headlen(skb), cutlen); | |
| 497 | 499 | else |
| 498 | − hlen = skb->len; | |
| 500 | + hlen = skb_len; | |
| 499 | 501 | |
| 500 | − len = upcall_msg_size(upcall_info, hlen - cutlen, | |
| 501 | − OVS_CB(skb)->acts_origlen); | |
| 502 | − user_skb = genlmsg_new(len, GFP_ATOMIC); | |
| 502 | + msg_size = upcall_msg_size(upcall_info, hlen, | |
| 503 | + OVS_CB(skb)->acts_origlen); | |
| 504 | + user_skb = genlmsg_new(msg_size, GFP_ATOMIC); | |
| 503 | 505 | if (!user_skb) { |
| 504 | 506 | err = -ENOMEM; |
| 505 | 507 | goto out; |
| @@ -560,7 +562,7 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, · 54 unmodified lines | ||
| 560 | 562 | } |
| 561 | 563 | |
| 562 | 564 | /* Add OVS_PACKET_ATTR_LEN when packet is truncated */ |
| 563 | − if (cutlen > 0 && | |
| 565 | + if (skb_len < skb->len && | |
| 564 | 566 | nla_put_u32(user_skb, OVS_PACKET_ATTR_LEN, skb->len)) { |
| 565 | 567 | err = -ENOBUFS; |
| 566 | 568 | goto out; |
| @@ -585,9 +587,9 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, · 18 unmodified lines | ||
| 585 | 587 | err = -ENOBUFS; |
| 586 | 588 | goto out; |
| 587 | 589 | } |
| 588 | − nla->nla_len = nla_attr_size(skb->len - cutlen); | |
| 590 | + nla->nla_len = nla_attr_size(skb_len); | |
| 589 | 591 | |
| 590 | − err = skb_zerocopy(user_skb, skb, skb->len - cutlen, hlen); | |
| 592 | + err = skb_zerocopy(user_skb, skb, skb_len, hlen); | |
| 591 | 593 | if (err) |
| 592 | 594 | goto out; |
| 593 | 595 | |
| @@ -644,6 +646,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info) · 50 unmodified lines | ||
| 644 | 646 | packet->ignore_df = 1; |
| 645 | 647 | } |
| 646 | 648 | OVS_CB(packet)->mru = mru; |
| 649 | + OVS_CB(packet)->cutlen = U32_MAX; | |
| 647 | 650 | |
| 648 | 651 | if (a[OVS_PACKET_ATTR_HASH]) { |
| 649 | 652 | hash = nla_get_u64(a[OVS_PACKET_ATTR_HASH]); |
| @@ -118,7 +118,7 @@ struct datapath { · 117 unmodified lines | ||
| 118 | 118 | * @mru: The maximum received fragement size; 0 if the packet is not |
| 119 | 119 | * fragmented. |
| 120 | 120 | * @acts_origlen: The netlink size of the flow actions applied to this skb. |
| 121 | − * @cutlen: The number of bytes from the packet end to be removed. | |
| 121 | + * @cutlen: The number of bytes in the packet to preserve on output. | |
| 122 | 122 | * @probability: The sampling probability that was applied to this skb; 0 means |
| 123 | 123 | * no sampling has occurred; U32_MAX means 100% probability. |
| 124 | 124 | * @upcall_pid: Netlink socket PID to use for sending this packet to userspace; |
| @@ -502,7 +502,7 @@ int ovs_vport_receive(struct vport *vport, struct sk_buff *skb, · 501 unmodified lines | ||
| 502 | 502 | |
| 503 | 503 | OVS_CB(skb)->input_vport = vport; |
| 504 | 504 | OVS_CB(skb)->mru = 0; |
| 505 | − OVS_CB(skb)->cutlen = 0; | |
| 505 | + OVS_CB(skb)->cutlen = U32_MAX; | |
| 506 | 506 | OVS_CB(skb)->probability = 0; |
| 507 | 507 | OVS_CB(skb)->upcall_pid = 0; |
| 508 | 508 | if (unlikely(dev_net(skb->dev) != ovs_dp_get_net(vport->dp))) { |
| @@ -4561,7 +4561,11 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, · 4560 unmodified lines | ||
| 4561 | 4561 | |
| 4562 | 4562 | spin_lock(&po->bind_lock); |
| 4563 | 4563 | WRITE_ONCE(po->num, num); |
| 4564 | − if (was_running) | |
| 4564 | + /* | |
| 4565 | + * NETDEV_UNREGISTER may have invalidated the binding while bind_lock | |
| 4566 | + * was dropped above. Do not re-add a fanout hook to a dead device. | |
| 4567 | + */ | |
| 4568 | + if (was_running && READ_ONCE(po->ifindex) != -1) | |
| 4565 | 4569 | register_prot_hook(sk); |
| 4566 | 4570 | |
| 4567 | 4571 | spin_unlock(&po->bind_lock); |
| @@ -55,6 +55,8 @@ static unsigned char *pep_get_sb(struct sk_buff *skb, u8 *ptype, u8 *plen, · 54 unmodified lines | ||
| 55 | 55 | ph = skb_header_pointer(skb, 0, 2, &h); |
| 56 | 56 | if (ph == NULL || ph->sb_len < 2 || !pskb_may_pull(skb, ph->sb_len)) |
| 57 | 57 | return NULL; |
| 58 | + /* pskb_may_pull() may have reallocated the head; refetch ph. */ | |
| 59 | + ph = skb_header_pointer(skb, 0, 2, &h); | |
| 58 | 60 | ph->sb_len -= 2; |
| 59 | 61 | *ptype = ph->sb_type; |
| 60 | 62 | *plen = ph->sb_len; |
| @@ -350,16 +350,34 @@ static struct pernet_operations phonet_net_ops = { · 349 unmodified lines | ||
| 350 | 350 | /* Initialize Phonet devices list */ |
| 351 | 351 | int __init phonet_device_init(void) |
| 352 | 352 | { |
| 353 | − int err = register_pernet_subsys(&phonet_net_ops); | |
| 353 | + int err; | |
| 354 | + | |
| 355 | + err = register_pernet_subsys(&phonet_net_ops); | |
| 354 | 356 | if (err) |
| 355 | 357 | return err; |
| 356 | 358 | |
| 357 | − proc_create_net("pnresource", 0, init_net.proc_net, &pn_res_seq_ops, | |
| 358 | − sizeof(struct seq_net_private)); | |
| 359 | − register_netdevice_notifier(&phonet_device_notifier); | |
| 359 | + if (!proc_create_net("pnresource", 0, init_net.proc_net, | |
| 360 | + &pn_res_seq_ops, sizeof(struct seq_net_private))) { | |
| 361 | + err = -ENOMEM; | |
| 362 | + goto err_pernet; | |
| 363 | + } | |
| 364 | + | |
| 365 | + err = register_netdevice_notifier(&phonet_device_notifier); | |
| 366 | + if (err) | |
| 367 | + goto err_proc; | |
| 368 | + | |
| 360 | 369 | err = phonet_netlink_register(); |
| 361 | 370 | if (err) |
| 362 | − phonet_device_exit(); | |
| 371 | + goto err_notifier; | |
| 372 | + | |
| 373 | + return 0; | |
| 374 | + | |
| 375 | +err_notifier: | |
| 376 | + unregister_netdevice_notifier(&phonet_device_notifier); | |
| 377 | +err_proc: | |
| 378 | + remove_proc_entry("pnresource", init_net.proc_net); | |
| 379 | +err_pernet: | |
| 380 | + unregister_pernet_subsys(&phonet_net_ops); | |
| 363 | 381 | return err; |
| 364 | 382 | } |
| 365 | 383 | |
| @@ -367,8 +385,8 @@ void phonet_device_exit(void) · 1 unmodified line | ||
| 367 | 385 | { |
| 368 | 386 | rtnl_unregister_all(PF_PHONET); |
| 369 | 387 | unregister_netdevice_notifier(&phonet_device_notifier); |
| 370 | − unregister_pernet_subsys(&phonet_net_ops); | |
| 371 | 388 | remove_proc_entry("pnresource", init_net.proc_net); |
| 389 | + unregister_pernet_subsys(&phonet_net_ops); | |
| 372 | 390 | } |
| 373 | 391 | |
| 374 | 392 | int phonet_route_add(struct net_device *dev, u8 daddr) |
| @@ -1263,6 +1263,14 @@ static int qrtr_create(struct net *net, struct socket *sock, · 1262 unmodified lines | ||
| 1263 | 1263 | if (sock->type != SOCK_DGRAM) |
| 1264 | 1264 | return -EPROTOTYPE; |
| 1265 | 1265 | |
| 1266 | + /* QRTR keeps its port and node state in module-global variables that | |
| 1267 | + * are not partitioned per network namespace, and the in-kernel name | |
| 1268 | + * service only operates in init_net. Confine the family to init_net so | |
| 1269 | + * a socket in another namespace cannot reach the global control plane. | |
| 1270 | + */ | |
| 1271 | + if (!net_eq(net, &init_net)) | |
| 1272 | + return -EAFNOSUPPORT; | |
| 1273 | + | |
| 1266 | 1274 | sk = sk_alloc(net, AF_QIPCRTR, GFP_KERNEL, &qrtr_proto, kern); |
| 1267 | 1275 | if (!sk) |
| 1268 | 1276 | return -ENOMEM; |
| @@ -76,11 +76,11 @@ struct qrtr_node { · 75 unmodified lines | ||
| 76 | 76 | * requirements. If the requirement changes in the future, these values can be |
| 77 | 77 | * increased. |
| 78 | 78 | */ |
| 79 | −#define QRTR_NS_MAX_NODES 64 | |
| 79 | +#define QRTR_NS_MAX_NODES 512 | |
| 80 | 80 | #define QRTR_NS_MAX_SERVERS 256 |
| 81 | 81 | #define QRTR_NS_MAX_LOOKUPS 64 |
| 82 | 82 | |
| 83 | −static u8 node_count; | |
| 83 | +static u16 node_count; | |
| 84 | 84 | |
| 85 | 85 | static struct qrtr_node *node_get(unsigned int node_id) |
| 86 | 86 | { |
| @@ -429,6 +429,10 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr, · 428 unmodified lines | ||
| 429 | 429 | sa = (struct sockaddr *)&sin; |
| 430 | 430 | } else { |
| 431 | 431 | #if IS_ENABLED(CONFIG_IPV6) |
| 432 | + if (!ipv6_mod_enabled()) { | |
| 433 | + ret = -EADDRNOTAVAIL; | |
| 434 | + goto out; | |
| 435 | + } | |
| 432 | 436 | memset(&sin6, 0, sizeof(sin6)); |
| 433 | 437 | sin6.sin6_family = AF_INET6; |
| 434 | 438 | sin6.sin6_addr = *addr; |
| @@ -810,6 +810,10 @@ int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id, · 809 unmodified lines | ||
| 810 | 810 | dp = event->param.conn.private_data; |
| 811 | 811 | if (isv6) { |
| 812 | 812 | #if IS_ENABLED(CONFIG_IPV6) |
| 813 | + if (!ipv6_mod_enabled()) { | |
| 814 | + err = -EOPNOTSUPP; | |
| 815 | + goto out; | |
| 816 | + } | |
| 813 | 817 | dp_cmn = &dp->ricp_v6.dp_cmn; |
| 814 | 818 | saddr6 = &dp->ricp_v6.dp_saddr; |
| 815 | 819 | daddr6 = &dp->ricp_v6.dp_daddr; |
| @@ -399,6 +399,21 @@ void rds_recv_incoming(struct rds_connection *conn, struct in6_addr *saddr, · 398 unmodified lines | ||
| 399 | 399 | goto out; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | + /* | |
| 403 | + * rds_find_bound() uses a global (netns-agnostic) hash table. | |
| 404 | + * An RDS connection created in netns A can match a socket bound | |
| 405 | + * in the init netns, delivering inc cross-netns with inc->i_conn | |
| 406 | + * pointing into netns A. When cleanup_net() then frees that conn, | |
| 407 | + * any subsequent dereference of inc->i_conn is a use-after-free. | |
| 408 | + * Drop the inc if the receiving socket lives in a different netns. | |
| 409 | + */ | |
| 410 | + if (!net_eq(sock_net(rds_rs_to_sk(rs)), rds_conn_net(conn))) { | |
| 411 | + rds_stats_inc(s_recv_drop_no_sock); | |
| 412 | + rds_sock_put(rs); | |
| 413 | + rs = NULL; | |
| 414 | + goto out; | |
| 415 | + } | |
| 416 | + | |
| 402 | 417 | /* Process extension headers */ |
| 403 | 418 | rds_recv_incoming_exthdrs(inc, rs); |
| 404 | 419 | |
| @@ -366,9 +366,11 @@ int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr, · 365 unmodified lines | ||
| 366 | 366 | rcu_read_unlock(); |
| 367 | 367 | } |
| 368 | 368 | #if IS_ENABLED(CONFIG_IPV6) |
| 369 | − ret = ipv6_chk_addr(net, addr, dev, 0); | |
| 370 | − if (ret) | |
| 371 | − return 0; | |
| 369 | + if (ipv6_mod_enabled()) { | |
| 370 | + ret = ipv6_chk_addr(net, addr, dev, 0); | |
| 371 | + if (ret) | |
| 372 | + return 0; | |
| 373 | + } | |
| 372 | 374 | #endif |
| 373 | 375 | return -EADDRNOTAVAIL; |
| 374 | 376 | } |
| @@ -655,13 +657,13 @@ static void __net_exit rds_tcp_exit_net(struct net *net) · 280 unmodified lines | ||
| 655 | 657 | { |
| 656 | 658 | struct rds_tcp_net *rtn = net_generic(net, rds_tcp_netid); |
| 657 | 659 | |
| 658 | − rds_tcp_kill_sock(net); | |
| 659 | − | |
| 660 | 660 | if (rtn->rds_tcp_sysctl) |
| 661 | 661 | unregister_net_sysctl_table(rtn->rds_tcp_sysctl); |
| 662 | 662 | |
| 663 | 663 | if (net != &init_net) |
| 664 | 664 | kfree(rtn->ctl_table); |
| 665 | + | |
| 666 | + rds_tcp_kill_sock(net); | |
| 665 | 667 | } |
| 666 | 668 | |
| 667 | 669 | static struct pernet_operations rds_tcp_net_ops = { |
| @@ -1285,9 +1285,11 @@ int rxrpc_io_thread(void *data); · 1284 unmodified lines | ||
| 1285 | 1285 | void rxrpc_post_response(struct rxrpc_connection *conn, struct sk_buff *skb); |
| 1286 | 1286 | static inline void rxrpc_wake_up_io_thread(struct rxrpc_local *local) |
| 1287 | 1287 | { |
| 1288 | − if (!local->io_thread) | |
| 1288 | + struct task_struct *io_thread = READ_ONCE(local->io_thread); | |
| 1289 | + | |
| 1290 | + if (!io_thread) | |
| 1289 | 1291 | return; |
| 1290 | − wake_up_process(READ_ONCE(local->io_thread)); | |
| 1292 | + wake_up_process(io_thread); | |
| 1291 | 1293 | } |
| 1292 | 1294 | |
| 1293 | 1295 | static inline bool rxrpc_protocol_error(struct sk_buff *skb, enum rxrpc_abort_reason why) |
| @@ -4045,7 +4045,7 @@ struct sk_buff *tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, stru · 4044 unmodified lines | ||
| 4045 | 4045 | |
| 4046 | 4046 | fl = rcu_dereference_bh(qe->filter_chain); |
| 4047 | 4047 | |
| 4048 | − switch (tcf_classify(skb, NULL, fl, &cl_res, false)) { | |
| 4048 | + switch (tcf_classify_qdisc(skb, fl, &cl_res, false)) { | |
| 4049 | 4049 | case TC_ACT_SHOT: |
| 4050 | 4050 | qdisc_qstats_drop(sch); |
| 4051 | 4051 | __qdisc_drop(skb, to_free); |
| @@ -4057,10 +4057,6 @@ struct sk_buff *tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, stru · 5 unmodified lines | ||
| 4057 | 4057 | __qdisc_drop(skb, to_free); |
| 4058 | 4058 | *ret = __NET_XMIT_STOLEN; |
| 4059 | 4059 | return NULL; |
| 4060 | − case TC_ACT_REDIRECT: | |
| 4061 | − skb_do_redirect(skb); | |
| 4062 | − *ret = __NET_XMIT_STOLEN; | |
| 4063 | − return NULL; | |
| 4064 | 4060 | case TC_ACT_CONSUMED: |
| 4065 | 4061 | *ret = __NET_XMIT_STOLEN; |
| 4066 | 4062 | return NULL; |
| @@ -415,12 +415,13 @@ static __u8 __detect_linklayer(struct tc_ratespec *r, __u32 *rtab) · 414 unmodified lines | ||
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | static struct qdisc_rate_table *qdisc_rtab_list; |
| 418 | +static DEFINE_SPINLOCK(qdisc_rtab_lock); | |
| 418 | 419 | |
| 419 | 420 | struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, |
| 420 | 421 | struct nlattr *tab, |
| 421 | 422 | struct netlink_ext_ack *extack) |
| 422 | 423 | { |
| 423 | − struct qdisc_rate_table *rtab; | |
| 424 | + struct qdisc_rate_table *rtab, *new_rtab; | |
| 424 | 425 | |
| 425 | 426 | if (tab == NULL || r->rate == 0 || |
| 426 | 427 | r->cell_log == 0 || r->cell_log >= 32 || |
| @@ -429,15 +430,20 @@ struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, · 2 unmodified lines | ||
| 429 | 430 | return NULL; |
| 430 | 431 | } |
| 431 | 432 | |
| 433 | + new_rtab = kmalloc_obj(*new_rtab); | |
| 434 | + | |
| 435 | + spin_lock(&qdisc_rtab_lock); | |
| 432 | 436 | for (rtab = qdisc_rtab_list; rtab; rtab = rtab->next) { |
| 433 | 437 | if (!memcmp(&rtab->rate, r, sizeof(struct tc_ratespec)) && |
| 434 | 438 | !memcmp(&rtab->data, nla_data(tab), TC_RTAB_SIZE)) { |
| 435 | 439 | rtab->refcnt++; |
| 440 | + spin_unlock(&qdisc_rtab_lock); | |
| 441 | + kfree(new_rtab); | |
| 436 | 442 | return rtab; |
| 437 | 443 | } |
| 438 | 444 | } |
| 439 | 445 | |
| 440 | − rtab = kmalloc_obj(*rtab); | |
| 446 | + rtab = new_rtab; | |
| 441 | 447 | if (rtab) { |
| 442 | 448 | rtab->rate = *r; |
| 443 | 449 | rtab->refcnt = 1; |
| @@ -449,6 +455,7 @@ struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, · 5 unmodified lines | ||
| 449 | 455 | } else { |
| 450 | 456 | NL_SET_ERR_MSG(extack, "Failed to allocate new qdisc rate table"); |
| 451 | 457 | } |
| 458 | + spin_unlock(&qdisc_rtab_lock); | |
| 452 | 459 | return rtab; |
| 453 | 460 | } |
| 454 | 461 | EXPORT_SYMBOL(qdisc_get_rtab); |
| @@ -457,18 +464,25 @@ void qdisc_put_rtab(struct qdisc_rate_table *tab) · 2 unmodified lines | ||
| 457 | 464 | { |
| 458 | 465 | struct qdisc_rate_table *rtab, **rtabp; |
| 459 | 466 | |
| 460 | − if (!tab || --tab->refcnt) | |
| 467 | + if (!tab) | |
| 461 | 468 | return; |
| 462 | 469 | |
| 470 | + spin_lock(&qdisc_rtab_lock); | |
| 471 | + if (--tab->refcnt) { | |
| 472 | + spin_unlock(&qdisc_rtab_lock); | |
| 473 | + return; | |
| 474 | + } | |
| 475 | + | |
| 463 | 476 | for (rtabp = &qdisc_rtab_list; |
| 464 | 477 | (rtab = *rtabp) != NULL; |
| 465 | 478 | rtabp = &rtab->next) { |
| 466 | 479 | if (rtab == tab) { |
| 467 | 480 | *rtabp = rtab->next; |
| 468 | − kfree(rtab); | |
| 469 | − return; | |
| 481 | + break; | |
| 470 | 482 | } |
| 471 | 483 | } |
| 484 | + spin_unlock(&qdisc_rtab_lock); | |
| 485 | + kfree(tab); | |
| 472 | 486 | } |
| 473 | 487 | EXPORT_SYMBOL(qdisc_put_rtab); |
| 474 | 488 | |
| @@ -1727,7 +1727,7 @@ static u32 cake_classify(struct Qdisc *sch, struct cake_tin_data **t, · 1726 unmodified lines | ||
| 1727 | 1727 | goto hash; |
| 1728 | 1728 | |
| 1729 | 1729 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
| 1730 | − result = tcf_classify(skb, NULL, filter, &res, false); | |
| 1730 | + result = tcf_classify_qdisc(skb, filter, &res, false); | |
| 1731 | 1731 | |
| 1732 | 1732 | if (result >= 0) { |
| 1733 | 1733 | #ifdef CONFIG_NET_CLS_ACT |
| @@ -312,7 +312,7 @@ static struct drr_class *drr_classify(struct sk_buff *skb, struct Qdisc *sch, · 311 unmodified lines | ||
| 312 | 312 | |
| 313 | 313 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
| 314 | 314 | fl = rcu_dereference_bh(q->filter_list); |
| 315 | − result = tcf_classify(skb, NULL, fl, &res, false); | |
| 315 | + result = tcf_classify_qdisc(skb, fl, &res, false); | |
| 316 | 316 | if (result >= 0) { |
| 317 | 317 | #ifdef CONFIG_NET_CLS_ACT |
| 318 | 318 | switch (result) { |
| @@ -364,7 +364,7 @@ static int dualpi2_skb_classify(struct dualpi2_sched_data *q, · 363 unmodified lines | ||
| 364 | 364 | if (!fl) |
| 365 | 365 | return NET_XMIT_SUCCESS; |
| 366 | 366 | |
| 367 | − result = tcf_classify(skb, NULL, fl, &res, false); | |
| 367 | + result = tcf_classify_qdisc(skb, fl, &res, false); | |
| 368 | 368 | if (result >= 0) { |
| 369 | 369 | #ifdef CONFIG_NET_CLS_ACT |
| 370 | 370 | switch (result) { |
| @@ -391,7 +391,7 @@ static struct ets_class *ets_classify(struct sk_buff *skb, struct Qdisc *sch, · 390 unmodified lines | ||
| 391 | 391 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
| 392 | 392 | if (TC_H_MAJ(skb->priority) != sch->handle) { |
| 393 | 393 | fl = rcu_dereference_bh(q->filter_list); |
| 394 | − err = tcf_classify(skb, NULL, fl, &res, false); | |
| 394 | + err = tcf_classify_qdisc(skb, fl, &res, false); | |
| 395 | 395 | #ifdef CONFIG_NET_CLS_ACT |
| 396 | 396 | switch (err) { |
| 397 | 397 | case TC_ACT_STOLEN: |
| @@ -91,7 +91,7 @@ static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch, · 90 unmodified lines | ||
| 91 | 91 | return fq_codel_hash(q, skb) + 1; |
| 92 | 92 | |
| 93 | 93 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
| 94 | − result = tcf_classify(skb, NULL, filter, &res, false); | |
| 94 | + result = tcf_classify_qdisc(skb, filter, &res, false); | |
| 95 | 95 | if (result >= 0) { |
| 96 | 96 | #ifdef CONFIG_NET_CLS_ACT |
| 97 | 97 | switch (result) { |
| @@ -96,7 +96,7 @@ static unsigned int fq_pie_classify(struct sk_buff *skb, struct Qdisc *sch, · 95 unmodified lines | ||
| 96 | 96 | return fq_pie_hash(q, skb) + 1; |
| 97 | 97 | |
| 98 | 98 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
| 99 | − result = tcf_classify(skb, NULL, filter, &res, false); | |
| 99 | + result = tcf_classify_qdisc(skb, filter, &res, false); | |
| 100 | 100 | if (result >= 0) { |
| 101 | 101 | #ifdef CONFIG_NET_CLS_ACT |
| 102 | 102 | switch (result) { |
| @@ -1143,7 +1143,7 @@ hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) · 1142 unmodified lines | ||
| 1143 | 1143 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
| 1144 | 1144 | head = &q->root; |
| 1145 | 1145 | tcf = rcu_dereference_bh(q->root.filter_list); |
| 1146 | − while (tcf && (result = tcf_classify(skb, NULL, tcf, &res, false)) >= 0) { | |
| 1146 | + while (tcf && (result = tcf_classify_qdisc(skb, tcf, &res, false)) >= 0) { | |
| 1147 | 1147 | #ifdef CONFIG_NET_CLS_ACT |
| 1148 | 1148 | switch (result) { |
| 1149 | 1149 | case TC_ACT_QUEUED: |
| @@ -243,7 +243,7 @@ static struct htb_class *htb_classify(struct sk_buff *skb, struct Qdisc *sch, · 242 unmodified lines | ||
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
| 246 | − while (tcf && (result = tcf_classify(skb, NULL, tcf, &res, false)) >= 0) { | |
| 246 | + while (tcf && (result = tcf_classify_qdisc(skb, tcf, &res, false)) >= 0) { | |
| 247 | 247 | #ifdef CONFIG_NET_CLS_ACT |
| 248 | 248 | switch (result) { |
| 249 | 249 | case TC_ACT_QUEUED: |
| @@ -36,7 +36,7 @@ multiq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) · 35 unmodified lines | ||
| 36 | 36 | int err; |
| 37 | 37 | |
| 38 | 38 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
| 39 | − err = tcf_classify(skb, NULL, fl, &res, false); | |
| 39 | + err = tcf_classify_qdisc(skb, fl, &res, false); | |
| 40 | 40 | #ifdef CONFIG_NET_CLS_ACT |
| 41 | 41 | switch (err) { |
| 42 | 42 | case TC_ACT_STOLEN: |
| @@ -39,7 +39,7 @@ prio_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) · 38 unmodified lines | ||
| 39 | 39 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
| 40 | 40 | if (TC_H_MAJ(skb->priority) != sch->handle) { |
| 41 | 41 | fl = rcu_dereference_bh(q->filter_list); |
| 42 | − err = tcf_classify(skb, NULL, fl, &res, false); | |
| 42 | + err = tcf_classify_qdisc(skb, fl, &res, false); | |
| 43 | 43 | #ifdef CONFIG_NET_CLS_ACT |
| 44 | 44 | switch (err) { |
| 45 | 45 | case TC_ACT_STOLEN: |
| @@ -709,7 +709,7 @@ static struct qfq_class *qfq_classify(struct sk_buff *skb, struct Qdisc *sch, · 708 unmodified lines | ||
| 709 | 709 | |
| 710 | 710 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
| 711 | 711 | fl = rcu_dereference_bh(q->filter_list); |
| 712 | − result = tcf_classify(skb, NULL, fl, &res, false); | |
| 712 | + result = tcf_classify_qdisc(skb, fl, &res, false); | |
| 713 | 713 | if (result >= 0) { |
| 714 | 714 | #ifdef CONFIG_NET_CLS_ACT |
| 715 | 715 | switch (result) { |
| @@ -260,7 +260,7 @@ static bool sfb_classify(struct sk_buff *skb, struct tcf_proto *fl, · 259 unmodified lines | ||
| 260 | 260 | struct tcf_result res; |
| 261 | 261 | int result; |
| 262 | 262 | |
| 263 | − result = tcf_classify(skb, NULL, fl, &res, false); | |
| 263 | + result = tcf_classify_qdisc(skb, fl, &res, false); | |
| 264 | 264 | if (result >= 0) { |
| 265 | 265 | #ifdef CONFIG_NET_CLS_ACT |
| 266 | 266 | switch (result) { |
| @@ -171,7 +171,7 @@ static unsigned int sfq_classify(struct sk_buff *skb, struct Qdisc *sch, · 170 unmodified lines | ||
| 171 | 171 | return sfq_hash(q, skb) + 1; |
| 172 | 172 | |
| 173 | 173 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
| 174 | − result = tcf_classify(skb, NULL, fl, &res, false); | |
| 174 | + result = tcf_classify_qdisc(skb, fl, &res, false); | |
| 175 | 175 | if (result >= 0) { |
| 176 | 176 | #ifdef CONFIG_NET_CLS_ACT |
| 177 | 177 | switch (result) { |
| @@ -672,7 +672,7 @@ int sctp_auth_ep_add_chunkid(struct sctp_endpoint *ep, __u8 chunk_id) · 671 unmodified lines | ||
| 672 | 672 | /* Check if we can add this chunk to the array */ |
| 673 | 673 | param_len = ntohs(p->param_hdr.length); |
| 674 | 674 | nchunks = param_len - sizeof(struct sctp_paramhdr); |
| 675 | − if (nchunks == SCTP_NUM_CHUNK_TYPES) | |
| 675 | + if (nchunks == SCTP_AUTH_MAX_CHUNKS) | |
| 676 | 676 | return -EINVAL; |
| 677 | 677 | |
| 678 | 678 | p->chunks[nchunks] = chunk_id; |
| @@ -1383,10 +1383,6 @@ static int __net_init sctp_defaults_init(struct net *net) · 1382 unmodified lines | ||
| 1383 | 1383 | net->sctp.l3mdev_accept = 1; |
| 1384 | 1384 | #endif |
| 1385 | 1385 | |
| 1386 | − status = sctp_sysctl_net_register(net); | |
| 1387 | − if (status) | |
| 1388 | − goto err_sysctl_register; | |
| 1389 | − | |
| 1390 | 1386 | /* Allocate and initialise sctp mibs. */ |
| 1391 | 1387 | status = init_sctp_mibs(net); |
| 1392 | 1388 | if (status) |
| @@ -1420,8 +1416,6 @@ err_init_proc: · 27 unmodified lines | ||
| 1420 | 1416 | cleanup_sctp_mibs(net); |
| 1421 | 1417 | #endif |
| 1422 | 1418 | err_init_mibs: |
| 1423 | − sctp_sysctl_net_unregister(net); | |
| 1424 | −err_sysctl_register: | |
| 1425 | 1419 | return status; |
| 1426 | 1420 | } |
| 1427 | 1421 | |
| @@ -1436,7 +1430,6 @@ static void __net_exit sctp_defaults_exit(struct net *net) · 8 unmodified lines | ||
| 1436 | 1430 | net->sctp.proc_net_sctp = NULL; |
| 1437 | 1431 | #endif |
| 1438 | 1432 | cleanup_sctp_mibs(net); |
| 1439 | − sctp_sysctl_net_unregister(net); | |
| 1440 | 1433 | } |
| 1441 | 1434 | |
| 1442 | 1435 | static struct pernet_operations sctp_defaults_ops = { |
| @@ -1450,16 +1443,28 @@ static int __net_init sctp_ctrlsock_init(struct net *net) · 7 unmodified lines | ||
| 1450 | 1443 | |
| 1451 | 1444 | /* Initialize the control inode/socket for handling OOTB packets. */ |
| 1452 | 1445 | status = sctp_ctl_sock_init(net); |
| 1453 | − if (status) | |
| 1446 | + if (status) { | |
| 1454 | 1447 | pr_err("Failed to initialize the SCTP control sock\n"); |
| 1448 | + return status; | |
| 1449 | + } | |
| 1450 | + | |
| 1451 | + status = sctp_sysctl_net_register(net); | |
| 1452 | + if (status) { | |
| 1453 | + inet_ctl_sock_destroy(net->sctp.ctl_sock); | |
| 1454 | + net->sctp.ctl_sock = NULL; | |
| 1455 | + } | |
| 1455 | 1456 | |
| 1456 | 1457 | return status; |
| 1457 | 1458 | } |
| 1458 | 1459 | |
| 1459 | 1460 | static void __net_exit sctp_ctrlsock_exit(struct net *net) |
| 1460 | 1461 | { |
| 1462 | + sctp_sysctl_net_unregister(net); | |
| 1463 | + sctp_udp_sock_stop(net); | |
| 1464 | + | |
| 1461 | 1465 | /* Free the control endpoint. */ |
| 1462 | 1466 | inet_ctl_sock_destroy(net->sctp.ctl_sock); |
| 1467 | + net->sctp.ctl_sock = NULL; | |
| 1463 | 1468 | } |
| 1464 | 1469 | |
| 1465 | 1470 | static struct pernet_operations sctp_ctrlsock_ops = { |
| @@ -3153,6 +3153,12 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc, · 3152 unmodified lines | ||
| 3153 | 3153 | if (!peer) |
| 3154 | 3154 | return SCTP_ERROR_DNS_FAILED; |
| 3155 | 3155 | |
| 3156 | + /* Don't free asconf->transport; a later wildcard DEL-IP | |
| 3157 | + * parameter reuses it. | |
| 3158 | + */ | |
| 3159 | + if (peer == asconf->transport) | |
| 3160 | + return SCTP_ERROR_REQ_REFUSED; | |
| 3161 | + | |
| 3156 | 3162 | sctp_assoc_rm_peer(asoc, peer); |
| 3157 | 3163 | break; |
| 3158 | 3164 | case SCTP_PARAM_SET_PRIMARY: |
| @@ -643,7 +643,7 @@ static bool sctp_auth_chunk_verify(struct net *net, struct sctp_chunk *chunk, · 642 unmodified lines | ||
| 643 | 643 | struct sctp_chunk auth; |
| 644 | 644 | |
| 645 | 645 | if (!chunk->auth_chunk) |
| 646 | − return true; | |
| 646 | + return !sctp_auth_recv_cid(chunk->chunk_hdr->type, asoc); | |
| 647 | 647 | |
| 648 | 648 | /* SCTP-AUTH: auth_chunk pointer is only set when the cookie-echo |
| 649 | 649 | * is supposed to be authenticated and we have to do delayed |
| @@ -308,7 +308,8 @@ int sctp_send_reset_streams(struct sctp_association *asoc, · 307 unmodified lines | ||
| 308 | 308 | goto out; |
| 309 | 309 | |
| 310 | 310 | param_len += str_nums * sizeof(__u16) + |
| 311 | − sizeof(struct sctp_strreset_inreq); | |
| 311 | + (out ? sizeof(struct sctp_strreset_inreq) | |
| 312 | + : sizeof(struct sctp_strreset_outreq)); | |
| 312 | 313 | } |
| 313 | 314 | |
| 314 | 315 | if (param_len > SCTP_MAX_CHUNK_LEN - |
| @@ -639,6 +640,9 @@ struct sctp_chunk *sctp_process_strreset_inreq( · 324 unmodified lines | ||
| 639 | 640 | |
| 640 | 641 | nums = (ntohs(param.p->length) - sizeof(*inreq)) / sizeof(__u16); |
| 641 | 642 | str_p = inreq->list_of_streams; |
| 643 | + if (nums * sizeof(__u16) + sizeof(struct sctp_strreset_outreq) > | |
| 644 | + SCTP_MAX_CHUNK_LEN - sizeof(struct sctp_reconf_chunk)) | |
| 645 | + goto out; | |
| 642 | 646 | for (i = 0; i < nums; i++) { |
| 643 | 647 | if (ntohs(str_p[i]) >= stream->outcnt) { |
| 644 | 648 | result = SCTP_STRRESET_ERR_WRONG_SSN; |
| @@ -615,11 +615,16 @@ int sctp_sysctl_net_register(struct net *net) · 614 unmodified lines | ||
| 615 | 615 | |
| 616 | 616 | void sctp_sysctl_net_unregister(struct net *net) |
| 617 | 617 | { |
| 618 | + struct ctl_table_header *header = net->sctp.sysctl_header; | |
| 618 | 619 | const struct ctl_table *table; |
| 619 | 620 | |
| 620 | − table = net->sctp.sysctl_header->ctl_table_arg; | |
| 621 | − unregister_net_sysctl_table(net->sctp.sysctl_header); | |
| 621 | + if (!header) | |
| 622 | + return; | |
| 623 | + | |
| 624 | + table = header->ctl_table_arg; | |
| 625 | + unregister_net_sysctl_table(header); | |
| 622 | 626 | kfree(table); |
| 627 | + net->sctp.sysctl_header = NULL; | |
| 623 | 628 | } |
| 624 | 629 | |
| 625 | 630 | static struct ctl_table_header *sctp_sysctl_header; |
| @@ -113,12 +113,16 @@ const struct nla_policy tipc_nl_node_policy[TIPC_NLA_NODE_MAX + 1] = { · 112 unmodified lines | ||
| 113 | 113 | }; |
| 114 | 114 | |
| 115 | 115 | /* Properties valid for media, bearer and link */ |
| 116 | +static const struct netlink_range_validation tipc_nl_mtu_range = { | |
| 117 | + .max = U16_MAX, | |
| 118 | +}; | |
| 119 | + | |
| 116 | 120 | const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = { |
| 117 | 121 | [TIPC_NLA_PROP_UNSPEC] = { .type = NLA_UNSPEC }, |
| 118 | 122 | [TIPC_NLA_PROP_PRIO] = { .type = NLA_U32 }, |
| 119 | 123 | [TIPC_NLA_PROP_TOL] = { .type = NLA_U32 }, |
| 120 | 124 | [TIPC_NLA_PROP_WIN] = { .type = NLA_U32 }, |
| 121 | − [TIPC_NLA_PROP_MTU] = { .type = NLA_U32 }, | |
| 125 | + [TIPC_NLA_PROP_MTU] = NLA_POLICY_FULL_RANGE(NLA_U32, &tipc_nl_mtu_range), | |
| 122 | 126 | [TIPC_NLA_PROP_BROADCAST] = { .type = NLA_U32 }, |
| 123 | 127 | [TIPC_NLA_PROP_BROADCAST_RATIO] = { .type = NLA_U32 } |
| 124 | 128 | }; |
| @@ -221,6 +221,10 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, · 220 unmodified lines | ||
| 221 | 221 | int rem; |
| 222 | 222 | |
| 223 | 223 | len = (*cmd->dumpit)(buf, &cb); |
| 224 | + if (len < 0) { | |
| 225 | + err = len; | |
| 226 | + goto err_out; | |
| 227 | + } | |
| 224 | 228 | |
| 225 | 229 | nlmsg_for_each_msg(nlmsg, nlmsg_hdr(buf), len, rem) { |
| 226 | 230 | err = nlmsg_parse_deprecated(nlmsg, GENL_HDRLEN, |
| @@ -502,6 +502,7 @@ static int tipc_sk_create(struct net *net, struct socket *sock, · 501 unmodified lines | ||
| 502 | 502 | tipc_set_sk_state(sk, TIPC_OPEN); |
| 503 | 503 | if (tipc_sk_insert(tsk)) { |
| 504 | 504 | sk_free(sk); |
| 505 | + sock->sk = NULL; | |
| 505 | 506 | pr_warn("Socket create failed; port number exhausted\n"); |
| 506 | 507 | return -EINVAL; |
| 507 | 508 | } |
| @@ -1935,7 +1936,7 @@ static int tipc_recvmsg(struct socket *sock, struct msghdr *m, · 1427 unmodified lines | ||
| 1935 | 1936 | if (likely(!err)) { |
| 1936 | 1937 | int offset = skb_cb->bytes_read; |
| 1937 | 1938 | |
| 1938 | − copy = min_t(int, dlen - offset, buflen); | |
| 1939 | + copy = min_t(size_t, dlen - offset, buflen); | |
| 1939 | 1940 | rc = skb_copy_datagram_msg(skb, hlen + offset, m, copy); |
| 1940 | 1941 | if (unlikely(rc)) |
| 1941 | 1942 | goto exit; |
| @@ -2067,7 +2068,7 @@ static int tipc_recvstream(struct socket *sock, struct msghdr *m, · 125 unmodified lines | ||
| 2067 | 2068 | /* Copy data if msg ok, otherwise return error/partial data */ |
| 2068 | 2069 | if (likely(!err)) { |
| 2069 | 2070 | offset = skb_cb->bytes_read; |
| 2070 | − copy = min_t(int, dlen - offset, buflen - copied); | |
| 2071 | + copy = min_t(size_t, dlen - offset, buflen - copied); | |
| 2071 | 2072 | rc = skb_copy_datagram_msg(skb, hlen + offset, m, copy); |
| 2072 | 2073 | if (unlikely(rc)) |
| 2073 | 2074 | break; |
| @@ -94,6 +94,8 @@ struct udp_replicast { · 93 unmodified lines | ||
| 94 | 94 | * @ifindex: local address scope |
| 95 | 95 | * @work: used to schedule deferred work on a bearer |
| 96 | 96 | * @rcast: associated udp_replicast container |
| 97 | + * @rcast_lock: serialize updates to @rcast.list against concurrent updaters | |
| 98 | + * @disabled: bearer is being torn down; reject further @rcast.list additions | |
| 97 | 99 | */ |
| 98 | 100 | struct udp_bearer { |
| 99 | 101 | struct tipc_bearer __rcu *bearer; |
| @@ -101,6 +103,8 @@ struct udp_bearer { · 1 unmodified line | ||
| 101 | 103 | u32 ifindex; |
| 102 | 104 | struct work_struct work; |
| 103 | 105 | struct udp_replicast rcast; |
| 106 | + spinlock_t rcast_lock; | |
| 107 | + bool disabled; | |
| 104 | 108 | }; |
| 105 | 109 | |
| 106 | 110 | static int tipc_udp_is_mcast_addr(struct udp_media_addr *addr) |
| @@ -278,26 +282,6 @@ out: · 171 unmodified lines | ||
| 278 | 282 | return err; |
| 279 | 283 | } |
| 280 | 284 | |
| 281 | −static bool tipc_udp_is_known_peer(struct tipc_bearer *b, | |
| 282 | − struct udp_media_addr *addr) | |
| 283 | −{ | |
| 284 | − struct udp_replicast *rcast, *tmp; | |
| 285 | − struct udp_bearer *ub; | |
| 286 | − | |
| 287 | − ub = rcu_dereference_rtnl(b->media_ptr); | |
| 288 | − if (!ub) { | |
| 289 | − pr_err_ratelimited("UDP bearer instance not found\n"); | |
| 290 | − return false; | |
| 291 | − } | |
| 292 | − | |
| 293 | − list_for_each_entry_safe(rcast, tmp, &ub->rcast.list, list) { | |
| 294 | − if (!memcmp(&rcast->addr, addr, sizeof(struct udp_media_addr))) | |
| 295 | − return true; | |
| 296 | − } | |
| 297 | − | |
| 298 | − return false; | |
| 299 | −} | |
| 300 | − | |
| 301 | 285 | static int tipc_udp_rcast_add(struct tipc_bearer *b, |
| 302 | 286 | struct udp_media_addr *addr) |
| 303 | 287 | { |
| @@ -308,16 +292,34 @@ static int tipc_udp_rcast_add(struct tipc_bearer *b, · 4 unmodified lines | ||
| 308 | 292 | if (!ub) |
| 309 | 293 | return -ENODEV; |
| 310 | 294 | |
| 295 | + spin_lock_bh(&ub->rcast_lock); | |
| 296 | + if (ub->disabled) { | |
| 297 | + spin_unlock_bh(&ub->rcast_lock); | |
| 298 | + return 0; | |
| 299 | + } | |
| 300 | + list_for_each_entry(rcast, &ub->rcast.list, list) { | |
| 301 | + if (!memcmp(&rcast->addr, addr, sizeof(*addr))) { | |
| 302 | + spin_unlock_bh(&ub->rcast_lock); | |
| 303 | + return 0; | |
| 304 | + } | |
| 305 | + } | |
| 306 | + | |
| 311 | 307 | rcast = kmalloc_obj(*rcast, GFP_ATOMIC); |
| 312 | − if (!rcast) | |
| 308 | + if (!rcast) { | |
| 309 | + spin_unlock_bh(&ub->rcast_lock); | |
| 313 | 310 | return -ENOMEM; |
| 311 | + } | |
| 314 | 312 | |
| 315 | 313 | if (dst_cache_init(&rcast->dst_cache, GFP_ATOMIC)) { |
| 314 | + spin_unlock_bh(&ub->rcast_lock); | |
| 316 | 315 | kfree(rcast); |
| 317 | 316 | return -ENOMEM; |
| 318 | 317 | } |
| 319 | 318 | |
| 320 | 319 | memcpy(&rcast->addr, addr, sizeof(struct udp_media_addr)); |
| 320 | + list_add_rcu(&rcast->list, &ub->rcast.list); | |
| 321 | + b->bcast_addr.broadcast = TIPC_REPLICAST_SUPPORT; | |
| 322 | + spin_unlock_bh(&ub->rcast_lock); | |
| 321 | 323 | |
| 322 | 324 | if (ntohs(addr->proto) == ETH_P_IP) |
| 323 | 325 | pr_info("New replicast peer: %pI4\n", &rcast->addr.ipv4); |
| @@ -325,8 +327,6 @@ static int tipc_udp_rcast_add(struct tipc_bearer *b, · 1 unmodified line | ||
| 325 | 327 | else if (ntohs(addr->proto) == ETH_P_IPV6) |
| 326 | 328 | pr_info("New replicast peer: %pI6\n", &rcast->addr.ipv6); |
| 327 | 329 | #endif |
| 328 | − b->bcast_addr.broadcast = TIPC_REPLICAST_SUPPORT; | |
| 329 | − list_add_rcu(&rcast->list, &ub->rcast.list); | |
| 330 | 330 | return 0; |
| 331 | 331 | } |
| 332 | 332 | |
| @@ -361,9 +361,6 @@ static int tipc_udp_rcast_disc(struct tipc_bearer *b, struct sk_buff *skb) · 28 unmodified lines | ||
| 361 | 361 | return 0; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | − if (likely(tipc_udp_is_known_peer(b, &src))) | |
| 365 | − return 0; | |
| 366 | − | |
| 367 | 364 | return tipc_udp_rcast_add(b, &src); |
| 368 | 365 | } |
| 369 | 366 | |
| @@ -644,9 +641,6 @@ int tipc_udp_nl_bearer_add(struct tipc_bearer *b, struct nlattr *attr) · 274 unmodified lines | ||
| 644 | 641 | return -EINVAL; |
| 645 | 642 | } |
| 646 | 643 | |
| 647 | − if (tipc_udp_is_known_peer(b, &addr)) | |
| 648 | − return 0; | |
| 649 | − | |
| 650 | 644 | return tipc_udp_rcast_add(b, &addr); |
| 651 | 645 | } |
| 652 | 646 | |
| @@ -679,6 +673,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, · 26 unmodified lines | ||
| 679 | 673 | return -ENOMEM; |
| 680 | 674 | |
| 681 | 675 | INIT_LIST_HEAD(&ub->rcast.list); |
| 676 | + spin_lock_init(&ub->rcast_lock); | |
| 682 | 677 | |
| 683 | 678 | if (!attrs[TIPC_NLA_BEARER_UDP_OPTS]) |
| 684 | 679 | goto err; |
| @@ -819,10 +814,13 @@ static void cleanup_bearer(struct work_struct *work) · 134 unmodified lines | ||
| 819 | 814 | struct udp_replicast *rcast, *tmp; |
| 820 | 815 | struct tipc_net *tn; |
| 821 | 816 | |
| 817 | + spin_lock_bh(&ub->rcast_lock); | |
| 822 | 818 | list_for_each_entry_safe(rcast, tmp, &ub->rcast.list, list) { |
| 823 | 819 | list_del_rcu(&rcast->list); |
| 824 | 820 | call_rcu_hurry(&rcast->rcu, rcast_free_rcu); |
| 825 | 821 | } |
| 822 | + ub->disabled = true; | |
| 823 | + spin_unlock_bh(&ub->rcast_lock); | |
| 826 | 824 | |
| 827 | 825 | tn = tipc_net(sock_net(ub->sk)); |
| 828 | 826 | |
| @@ -595,13 +595,15 @@ void tls_device_splice_eof(struct socket *sock) · 594 unmodified lines | ||
| 595 | 595 | struct tls_context *tls_ctx = tls_get_ctx(sk); |
| 596 | 596 | struct iov_iter iter = {}; |
| 597 | 597 | |
| 598 | − if (!tls_is_partially_sent_record(tls_ctx)) | |
| 598 | + if (!tls_is_partially_sent_record(tls_ctx) && | |
| 599 | + !tls_is_pending_open_record(tls_ctx)) | |
| 599 | 600 | return; |
| 600 | 601 | |
| 601 | 602 | mutex_lock(&tls_ctx->tx_lock); |
| 602 | 603 | lock_sock(sk); |
| 603 | 604 | |
| 604 | − if (tls_is_partially_sent_record(tls_ctx)) { | |
| 605 | + if (tls_is_partially_sent_record(tls_ctx) || | |
| 606 | + tls_is_pending_open_record(tls_ctx)) { | |
| 605 | 607 | iov_iter_bvec(&iter, ITER_SOURCE, NULL, 0, 0); |
| 606 | 608 | tls_push_data(sk, &iter, 0, 0, TLS_RECORD_TYPE_DATA); |
| 607 | 609 | } |
| @@ -26,6 +26,13 @@ · 25 unmodified lines | ||
| 26 | 26 | /* Threshold for detecting small packets to copy */ |
| 27 | 27 | #define GOOD_COPY_LEN 128 |
| 28 | 28 | |
| 29 | +/* Max payload that can be collapsed into a single linear skb, using the same | |
| 30 | + * allocation threshold as virtio_vsock_alloc_skb() to avoid adding pressure | |
| 31 | + * on the page allocator. | |
| 32 | + */ | |
| 33 | +#define MAX_COLLAPSE_LEN \ | |
| 34 | + SKB_MAX_ORDER(VIRTIO_VSOCK_SKB_HEADROOM, PAGE_ALLOC_COSTLY_ORDER) | |
| 35 | + | |
| 29 | 36 | static void virtio_transport_cancel_close_work(struct vsock_sock *vsk, |
| 30 | 37 | bool cancel_timeout); |
| 31 | 38 | static s64 virtio_transport_has_space(struct virtio_vsock_sock *vvs); |
| @@ -420,6 +427,145 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk, · 388 unmodified lines | ||
| 420 | 427 | return ret; |
| 421 | 428 | } |
| 422 | 429 | |
| 430 | +static bool virtio_transport_can_collapse(struct sk_buff *skb) | |
| 431 | +{ | |
| 432 | + /* skbs that are partially consumed, mark a SEQPACKET message boundary, | |
| 433 | + * or are already large enough should not be collapsed: they either | |
| 434 | + * need special accounting, carry protocol state, or already have a | |
| 435 | + * good data-to-overhead ratio. | |
| 436 | + */ | |
| 437 | + if (VIRTIO_VSOCK_SKB_CB(skb)->offset) | |
| 438 | + return false; | |
| 439 | + if (le32_to_cpu(virtio_vsock_hdr(skb)->flags) & VIRTIO_VSOCK_SEQ_EOM) | |
| 440 | + return false; | |
| 441 | + if (skb->len >= MAX_COLLAPSE_LEN) | |
| 442 | + return false; | |
| 443 | + return true; | |
| 444 | +} | |
| 445 | + | |
| 446 | +/* Iterate through the packets in the queue starting from the current skb to | |
| 447 | + * count the number of bytes we can collapse. | |
| 448 | + */ | |
| 449 | +static unsigned int | |
| 450 | +virtio_transport_collapse_size(struct sk_buff *skb, struct sk_buff_head *queue) | |
| 451 | +{ | |
| 452 | + unsigned int target = skb->len - VIRTIO_VSOCK_SKB_CB(skb)->offset; | |
| 453 | + | |
| 454 | + while ((skb = skb_peek_next(skb, queue)) && | |
| 455 | + virtio_transport_can_collapse(skb)) { | |
| 456 | + unsigned int len = skb->len - VIRTIO_VSOCK_SKB_CB(skb)->offset; | |
| 457 | + | |
| 458 | + if (len > MAX_COLLAPSE_LEN - target) | |
| 459 | + return target; | |
| 460 | + | |
| 461 | + target += len; | |
| 462 | + } | |
| 463 | + | |
| 464 | + return target; | |
| 465 | +} | |
| 466 | + | |
| 467 | +/* Called under lock_sock to compact the receive queue by merging small skbs. | |
| 468 | + * @min_to_free: minimum number of skbs to eliminate from the queue. May free | |
| 469 | + * more to fill each collapsed skb to capacity. | |
| 470 | + */ | |
| 471 | +static void | |
| 472 | +virtio_transport_collapse_rx_queue(struct virtio_vsock_sock *vvs, | |
| 473 | + u32 min_to_free) | |
| 474 | +{ | |
| 475 | + struct sk_buff *skb, *next_skb, *new_skb = NULL; | |
| 476 | + struct sk_buff_head new_queue; | |
| 477 | + u32 saved = 0; | |
| 478 | + | |
| 479 | + __skb_queue_head_init(&new_queue); | |
| 480 | + | |
| 481 | + skb_queue_walk_safe(&vvs->rx_queue, skb, next_skb) { | |
| 482 | + struct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb); | |
| 483 | + u32 src_off = VIRTIO_VSOCK_SKB_CB(skb)->offset; | |
| 484 | + u32 src_len = skb->len - src_off; | |
| 485 | + bool keep; | |
| 486 | + | |
| 487 | + keep = !virtio_transport_can_collapse(skb); | |
| 488 | + if (keep) { | |
| 489 | + /* Finalize pending collapsed skb to preserve packet | |
| 490 | + * ordering. | |
| 491 | + */ | |
| 492 | + if (new_skb) { | |
| 493 | + __skb_queue_tail(&new_queue, new_skb); | |
| 494 | + new_skb = NULL; | |
| 495 | + saved--; | |
| 496 | + } | |
| 497 | + goto next; | |
| 498 | + } | |
| 499 | + | |
| 500 | + /* Finalize if this packet won't fit in the remaining tailroom, | |
| 501 | + * so we can allocate a right-sized new_skb. | |
| 502 | + */ | |
| 503 | + if (new_skb && src_len > skb_tailroom(new_skb)) { | |
| 504 | + __skb_queue_tail(&new_queue, new_skb); | |
| 505 | + new_skb = NULL; | |
| 506 | + saved--; | |
| 507 | + } | |
| 508 | + | |
| 509 | + if (!new_skb) { | |
| 510 | + unsigned int alloc_size; | |
| 511 | + | |
| 512 | + /* Check after finalizing to opportunistically fill | |
| 513 | + * each collapsed skb to capacity, merging more skbs | |
| 514 | + * than strictly required. | |
| 515 | + */ | |
| 516 | + if (saved >= min_to_free) | |
| 517 | + break; | |
| 518 | + | |
| 519 | + alloc_size = virtio_transport_collapse_size(skb, &vvs->rx_queue); | |
| 520 | + | |
| 521 | + /* Only this skb's data is eligible, nothing to merge | |
| 522 | + * with. Keep as-is. | |
| 523 | + */ | |
| 524 | + if (alloc_size <= src_len) { | |
| 525 | + keep = true; | |
| 526 | + goto next; | |
| 527 | + } | |
| 528 | + | |
| 529 | + new_skb = virtio_vsock_alloc_linear_skb(alloc_size + | |
| 530 | + VIRTIO_VSOCK_SKB_HEADROOM, GFP_KERNEL); | |
| 531 | + if (!new_skb) | |
| 532 | + break; | |
| 533 | + | |
| 534 | + memcpy(virtio_vsock_hdr(new_skb), hdr, | |
| 535 | + sizeof(struct virtio_vsock_hdr)); | |
| 536 | + virtio_vsock_hdr(new_skb)->len = 0; | |
| 537 | + } | |
| 538 | + | |
| 539 | + /* Cannot fail since src_off/src_len are within bounds, but if | |
| 540 | + * it does, discard new_skb to avoid queuing corrupted data. | |
| 541 | + */ | |
| 542 | + if (WARN_ON_ONCE(skb_copy_bits(skb, src_off, | |
| 543 | + skb_put(new_skb, src_len), | |
| 544 | + src_len))) { | |
| 545 | + kfree_skb(new_skb); | |
| 546 | + new_skb = NULL; | |
| 547 | + break; | |
| 548 | + } | |
| 549 | + | |
| 550 | + le32_add_cpu(&virtio_vsock_hdr(new_skb)->len, src_len); | |
| 551 | + virtio_vsock_hdr(new_skb)->flags |= hdr->flags; | |
| 552 | + | |
| 553 | +next: | |
| 554 | + __skb_unlink(skb, &vvs->rx_queue); | |
| 555 | + if (keep) { | |
| 556 | + __skb_queue_tail(&new_queue, skb); | |
| 557 | + } else { | |
| 558 | + consume_skb(skb); | |
| 559 | + saved++; | |
| 560 | + } | |
| 561 | + } | |
| 562 | + | |
| 563 | + if (new_skb) | |
| 564 | + __skb_queue_tail(&new_queue, new_skb); | |
| 565 | + | |
| 566 | + skb_queue_splice(&new_queue, &vvs->rx_queue); | |
| 567 | +} | |
| 568 | + | |
| 423 | 569 | static bool virtio_transport_inc_rx_pkt(struct virtio_vsock_sock *vvs, |
| 424 | 570 | u32 len) |
| 425 | 571 | { |
| @@ -1354,12 +1500,29 @@ virtio_transport_recv_enqueue(struct vsock_sock *vsk, · 928 unmodified lines | ||
| 1354 | 1500 | { |
| 1355 | 1501 | struct virtio_vsock_sock *vvs = vsk->trans; |
| 1356 | 1502 | bool can_enqueue, free_pkt = false; |
| 1503 | + u32 len, queue_max, queue_len; | |
| 1357 | 1504 | struct virtio_vsock_hdr *hdr; |
| 1358 | − u32 len; | |
| 1359 | 1505 | |
| 1360 | 1506 | hdr = virtio_vsock_hdr(skb); |
| 1361 | 1507 | len = le32_to_cpu(hdr->len); |
| 1362 | 1508 | |
| 1509 | + /* virtio_transport_inc_rx_pkt() rejects packets when the per-skb | |
| 1510 | + * overhead (skb_queue_len * SKB_TRUESIZE(0)) exceeds buf_alloc. | |
| 1511 | + * Proactively collapse the queue before that happens. | |
| 1512 | + * No rx_lock needed: lock_sock is held by caller, preventing | |
| 1513 | + * concurrent enqueue or dequeue. | |
| 1514 | + */ | |
| 1515 | + queue_max = vvs->buf_alloc / SKB_TRUESIZE(0); | |
| 1516 | + queue_len = skb_queue_len(&vvs->rx_queue); | |
| 1517 | + if (queue_len >= queue_max) { | |
| 1518 | + /* Walking a large queue may take a significant amount of time | |
| 1519 | + * and cache misses, causing traffic burstiness. Limit the | |
| 1520 | + * collapse to freeing room for this packet and the next one. | |
| 1521 | + * It may free more to fill each collapsed skb to capacity. | |
| 1522 | + */ | |
| 1523 | + virtio_transport_collapse_rx_queue(vvs, queue_len + 2 - queue_max); | |
| 1524 | + } | |
| 1525 | + | |
| 1363 | 1526 | spin_lock_bh(&vvs->rx_lock); |
| 1364 | 1527 | |
| 1365 | 1528 | can_enqueue = virtio_transport_inc_rx_pkt(vvs, len); |
| @@ -263,8 +263,9 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev, · 262 unmodified lines | ||
| 263 | 263 | "FTM: nominal time is required for PD NTB ranging"); |
| 264 | 264 | return -EINVAL; |
| 265 | 265 | } |
| 266 | − out->ftm.nominal_time = | |
| 267 | − nla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_NOMINAL_TIME]); | |
| 266 | + if (tb[NL80211_PMSR_FTM_REQ_ATTR_NOMINAL_TIME]) | |
| 267 | + out->ftm.nominal_time = | |
| 268 | + nla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_NOMINAL_TIME]); | |
| 268 | 269 | |
| 269 | 270 | if (tb[NL80211_PMSR_FTM_REQ_ATTR_MIN_TIME_BETWEEN_MEASUREMENTS]) |
| 270 | 271 | out->ftm.min_time_between_measurements = |
| @@ -1768,15 +1768,19 @@ void x25_kill_by_neigh(struct x25_neigh *nb) · 1767 unmodified lines | ||
| 1768 | 1768 | { |
| 1769 | 1769 | struct sock *s; |
| 1770 | 1770 | |
| 1771 | +again: | |
| 1771 | 1772 | write_lock_bh(&x25_list_lock); |
| 1772 | 1773 | |
| 1773 | 1774 | sk_for_each(s, &x25_list) { |
| 1774 | 1775 | if (x25_sk(s)->neighbour == nb) { |
| 1776 | + sock_hold(s); | |
| 1775 | 1777 | write_unlock_bh(&x25_list_lock); |
| 1776 | 1778 | lock_sock(s); |
| 1777 | − x25_disconnect(s, ENETUNREACH, 0, 0); | |
| 1779 | + if (x25_sk(s)->neighbour == nb) | |
| 1780 | + x25_disconnect(s, ENETUNREACH, 0, 0); | |
| 1778 | 1781 | release_sock(s); |
| 1779 | − write_lock_bh(&x25_list_lock); | |
| 1782 | + sock_put(s); | |
| 1783 | + goto again; | |
| 1780 | 1784 | } |
| 1781 | 1785 | } |
| 1782 | 1786 | write_unlock_bh(&x25_list_lock); |
| @@ -84,11 +84,15 @@ core-flags := \ · 83 unmodified lines | ||
| 84 | 84 | --edition=$(core-edition) \ |
| 85 | 85 | $(call cfgs-to-flags,$(core-cfgs)) |
| 86 | 86 | |
| 87 | +zerocopy-cfgs := \ | |
| 88 | + no_fp_fmt_parse | |
| 89 | + | |
| 87 | 90 | zerocopy-flags := \ |
| 88 | − --cap-lints=allow | |
| 91 | + --cap-lints=allow \ | |
| 92 | + $(call cfgs-to-flags,$(zerocopy-cfgs)) | |
| 89 | 93 | |
| 90 | 94 | zerocopy-envs := \ |
| 91 | − CARGO_PKG_VERSION=0.8.50 | |
| 95 | + CARGO_PKG_VERSION=0.8.54 | |
| 92 | 96 | |
| 93 | 97 | proc_macro2-cfgs := \ |
| 94 | 98 | feature="proc-macro" \ |
| @@ -128,11 +132,15 @@ syn-flags := \ · 33 unmodified lines | ||
| 128 | 132 | --extern quote \ |
| 129 | 133 | $(call cfgs-to-flags,$(syn-cfgs)) |
| 130 | 134 | |
| 135 | +zerocopy_derive-cfgs := \ | |
| 136 | + zerocopy_unstable_linux | |
| 137 | + | |
| 131 | 138 | zerocopy_derive-flags := \ |
| 132 | 139 | --cap-lints=allow \ |
| 133 | 140 | --extern proc_macro2 \ |
| 134 | 141 | --extern quote \ |
| 135 | − --extern syn | |
| 142 | + --extern syn \ | |
| 143 | + $(call cfgs-to-flags,$(zerocopy_derive-cfgs)) | |
| 136 | 144 | |
| 137 | 145 | pin_init_internal-cfgs := \ |
| 138 | 146 | kernel USE_RUSTC_FEATURES |
| @@ -644,9 +652,11 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L · 505 unmodified lines | ||
| 644 | 652 | rust-analyzer: |
| 645 | 653 | $(Q)MAKEFLAGS= $(srctree)/scripts/generate_rust_analyzer.py \ |
| 646 | 654 | --cfgs='core=$(core-cfgs)' $(core-edition) \ |
| 655 | + --cfgs='zerocopy=$(zerocopy-cfgs)' \ | |
| 647 | 656 | --cfgs='proc_macro2=$(proc_macro2-cfgs)' \ |
| 648 | 657 | --cfgs='quote=$(quote-cfgs)' \ |
| 649 | 658 | --cfgs='syn=$(syn-cfgs)' \ |
| 659 | + --cfgs='zerocopy_derive=$(zerocopy_derive-cfgs)' \ | |
| 650 | 660 | --cfgs='pin_init_internal=$(pin_init_internal-cfgs)' \ |
| 651 | 661 | --cfgs='pin_init=$(pin_init-cfgs)' \ |
| 652 | 662 | --envs='zerocopy=$(zerocopy-envs)' \ |
| @@ -27,6 +27,10 @@ · 26 unmodified lines | ||
| 27 | 27 | #[allow(clippy::ref_as_ptr)] |
| 28 | 28 | #[allow(clippy::undocumented_unsafe_blocks)] |
| 29 | 29 | #[cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))] |
| 30 | +#[cfg_attr( | |
| 31 | + CONFIG_RUSTC_HAS_SUSPICIOUS_RUNTIME_SYMBOL_DEFINITIONS, | |
| 32 | + allow(suspicious_runtime_symbol_definitions) | |
| 33 | +)] | |
| 30 | 34 | mod bindings_raw { |
| 31 | 35 | use pin_init::{MaybeZeroable, Zeroable}; |
| 32 | 36 | |
| @@ -708,9 +708,7 @@ macro_rules! impl_device_context_into_aref { · 707 unmodified lines | ||
| 708 | 708 | #[macro_export] |
| 709 | 709 | macro_rules! dev_printk { |
| 710 | 710 | ($method:ident, $dev:expr, $($f:tt)*) => { |
| 711 | − { | |
| 712 | − $crate::device::Device::$method($dev.as_ref(), $crate::prelude::fmt!($($f)*)) | |
| 713 | − } | |
| 711 | + $crate::device::Device::$method($dev.as_ref(), $crate::prelude::fmt!($($f)*)) | |
| 714 | 712 | } |
| 715 | 713 | } |
| 716 | 714 | |
| @@ -737,7 +735,7 @@ macro_rules! dev_printk { · 20 unmodified lines | ||
| 737 | 735 | /// ``` |
| 738 | 736 | #[macro_export] |
| 739 | 737 | macro_rules! dev_emerg { |
| 740 | − ($($f:tt)*) => { $crate::dev_printk!(pr_emerg, $($f)*); } | |
| 738 | + ($($f:tt)*) => { $crate::dev_printk!(pr_emerg, $($f)*) } | |
| 741 | 739 | } |
| 742 | 740 | |
| 743 | 741 | /// Prints an alert-level message (level 1) prefixed with device information. |
| @@ -763,7 +761,7 @@ macro_rules! dev_emerg { · 19 unmodified lines | ||
| 763 | 761 | /// ``` |
| 764 | 762 | #[macro_export] |
| 765 | 763 | macro_rules! dev_alert { |
| 766 | − ($($f:tt)*) => { $crate::dev_printk!(pr_alert, $($f)*); } | |
| 764 | + ($($f:tt)*) => { $crate::dev_printk!(pr_alert, $($f)*) } | |
| 767 | 765 | } |
| 768 | 766 | |
| 769 | 767 | /// Prints a critical-level message (level 2) prefixed with device information. |
| @@ -789,7 +787,7 @@ macro_rules! dev_alert { · 19 unmodified lines | ||
| 789 | 787 | /// ``` |
| 790 | 788 | #[macro_export] |
| 791 | 789 | macro_rules! dev_crit { |
| 792 | − ($($f:tt)*) => { $crate::dev_printk!(pr_crit, $($f)*); } | |
| 790 | + ($($f:tt)*) => { $crate::dev_printk!(pr_crit, $($f)*) } | |
| 793 | 791 | } |
| 794 | 792 | |
| 795 | 793 | /// Prints an error-level message (level 3) prefixed with device information. |
| @@ -815,7 +813,7 @@ macro_rules! dev_crit { · 19 unmodified lines | ||
| 815 | 813 | /// ``` |
| 816 | 814 | #[macro_export] |
| 817 | 815 | macro_rules! dev_err { |
| 818 | − ($($f:tt)*) => { $crate::dev_printk!(pr_err, $($f)*); } | |
| 816 | + ($($f:tt)*) => { $crate::dev_printk!(pr_err, $($f)*) } | |
| 819 | 817 | } |
| 820 | 818 | |
| 821 | 819 | /// Prints a warning-level message (level 4) prefixed with device information. |
| @@ -841,7 +839,7 @@ macro_rules! dev_err { · 19 unmodified lines | ||
| 841 | 839 | /// ``` |
| 842 | 840 | #[macro_export] |
| 843 | 841 | macro_rules! dev_warn { |
| 844 | − ($($f:tt)*) => { $crate::dev_printk!(pr_warn, $($f)*); } | |
| 842 | + ($($f:tt)*) => { $crate::dev_printk!(pr_warn, $($f)*) } | |
| 845 | 843 | } |
| 846 | 844 | |
| 847 | 845 | /// Prints a notice-level message (level 5) prefixed with device information. |
| @@ -867,7 +865,7 @@ macro_rules! dev_warn { · 19 unmodified lines | ||
| 867 | 865 | /// ``` |
| 868 | 866 | #[macro_export] |
| 869 | 867 | macro_rules! dev_notice { |
| 870 | − ($($f:tt)*) => { $crate::dev_printk!(pr_notice, $($f)*); } | |
| 868 | + ($($f:tt)*) => { $crate::dev_printk!(pr_notice, $($f)*) } | |
| 871 | 869 | } |
| 872 | 870 | |
| 873 | 871 | /// Prints an info-level message (level 6) prefixed with device information. |
| @@ -893,7 +891,7 @@ macro_rules! dev_notice { · 19 unmodified lines | ||
| 893 | 891 | /// ``` |
| 894 | 892 | #[macro_export] |
| 895 | 893 | macro_rules! dev_info { |
| 896 | − ($($f:tt)*) => { $crate::dev_printk!(pr_info, $($f)*); } | |
| 894 | + ($($f:tt)*) => { $crate::dev_printk!(pr_info, $($f)*) } | |
| 897 | 895 | } |
| 898 | 896 | |
| 899 | 897 | /// Prints a debug-level message (level 7) prefixed with device information. |
| @@ -919,5 +917,5 @@ macro_rules! dev_info { · 19 unmodified lines | ||
| 919 | 917 | /// ``` |
| 920 | 918 | #[macro_export] |
| 921 | 919 | macro_rules! dev_dbg { |
| 922 | − ($($f:tt)*) => { $crate::dev_printk!(pr_dbg, $($f)*); } | |
| 920 | + ($($f:tt)*) => { $crate::dev_printk!(pr_dbg, $($f)*) } | |
| 923 | 921 | } |
| @@ -441,15 +441,22 @@ impl Delta { · 440 unmodified lines | ||
| 441 | 441 | /// to the value in the [`Delta`]. |
| 442 | 442 | #[inline] |
| 443 | 443 | pub fn as_micros_ceil(self) -> i64 { |
| 444 | + let n = self.as_nanos(); | |
| 445 | + let n = if n >= 0 { | |
| 446 | + n.saturating_add(NSEC_PER_USEC - 1) | |
| 447 | + } else { | |
| 448 | + n | |
| 449 | + }; | |
| 450 | + | |
| 444 | 451 | #[cfg(CONFIG_64BIT)] |
| 445 | 452 | { |
| 446 | − self.as_nanos().saturating_add(NSEC_PER_USEC - 1) / NSEC_PER_USEC | |
| 453 | + n / NSEC_PER_USEC | |
| 447 | 454 | } |
| 448 | 455 | |
| 449 | 456 | #[cfg(not(CONFIG_64BIT))] |
| 450 | 457 | // SAFETY: It is always safe to call `ktime_to_us()` with any value. |
| 451 | 458 | unsafe { |
| 452 | − bindings::ktime_to_us(self.as_nanos().saturating_add(NSEC_PER_USEC - 1)) | |
| 459 | + bindings::ktime_to_us(n) | |
| 453 | 460 | } |
| 454 | 461 | } |
| 455 | 462 | |
| @@ -24,6 +24,10 @@ · 23 unmodified lines | ||
| 24 | 24 | unsafe_op_in_unsafe_fn |
| 25 | 25 | )] |
| 26 | 26 | #![cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))] |
| 27 | +#![cfg_attr( | |
| 28 | + CONFIG_RUSTC_HAS_SUSPICIOUS_RUNTIME_SYMBOL_DEFINITIONS, | |
| 29 | + allow(suspicious_runtime_symbol_definitions) | |
| 30 | +)] | |
| 27 | 31 | #![feature(cfi_encoding)] |
| 28 | 32 | |
| 29 | 33 | // Manual definition of blocklisted types. |
| @@ -1,14 +1,14 @@ | ||
| 1 | 1 | # `zerocopy-derive` |
| 2 | 2 | |
| 3 | −These source files come from the Rust `zerocopy-derive` crate, version v0.8.50 | |
| 4 | −(released 2026-05-31), hosted in the <https://github.com/google/zerocopy> | |
| 3 | +These source files come from the Rust `zerocopy-derive` crate, version v0.8.54 | |
| 4 | +(released 2026-07-08), hosted in the <https://github.com/google/zerocopy> | |
| 5 | 5 | repository, licensed under "BSD-2-Clause OR Apache-2.0 OR MIT" and only |
| 6 | −modified to add the SPDX license identifiers and to remove the generation of | |
| 6 | +modified to tweak the SPDX license identifiers and to remove the generation of | |
| 7 | 7 | non-ASCII identifiers. |
| 8 | 8 | |
| 9 | 9 | For copyright details, please see: |
| 10 | 10 | |
| 11 | − https://github.com/google/zerocopy/blob/v0.8.50/README.md?plain=1 | |
| 12 | − https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-BSD | |
| 13 | − https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-APACHE | |
| 14 | − https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-MIT | |
| 11 | + https://github.com/google/zerocopy/blob/v0.8.54/README.md?plain=1 | |
| 12 | + https://github.com/google/zerocopy/blob/v0.8.54/LICENSE-BSD | |
| 13 | + https://github.com/google/zerocopy/blob/v0.8.54/LICENSE-APACHE | |
| 14 | + https://github.com/google/zerocopy/blob/v0.8.54/LICENSE-MIT | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | use proc_macro2::{Span, TokenStream}; |
| 4 | 4 | use syn::{ |
| 5 | 5 | parse_quote, Data, DataEnum, DataStruct, DataUnion, Error, Expr, ExprLit, ExprUnary, Lit, UnOp, |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | use proc_macro2::{Span, TokenStream}; |
| 4 | 4 | use quote::quote; |
| 5 | 5 | use syn::{Data, DataEnum, DataStruct, DataUnion, Error, Type}; |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | use proc_macro2::TokenStream; |
| 4 | 4 | use quote::quote; |
| 5 | 5 | use syn::{parse_quote, Data, Error, Type}; |
| @@ -87,7 +87,6 @@ fn derive_known_layout_for_repr_c_struct<'a>( · 81 unmodified lines | ||
| 87 | 87 | }; |
| 88 | 88 | |
| 89 | 89 | let inner_extras = { |
| 90 | − let leading_fields_tys = leading_fields_tys.clone(); | |
| 91 | 90 | let methods = make_methods(*trailing_field_ty); |
| 92 | 91 | let (_, ty_generics, _) = ctx.ast.generics.split_for_impl(); |
| 93 | 92 | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | pub mod from_bytes; |
| 4 | 4 | pub mod into_bytes; |
| 5 | 5 | pub mod known_layout; |
| @@ -15,8 +15,8 @@ use crate::{ · 9 unmodified lines | ||
| 15 | 15 | util::{Ctx, DataExt, FieldBounds, ImplBlockBuilder, Trait}, |
| 16 | 16 | }; |
| 17 | 17 | |
| 18 | −pub(crate) fn derive_immutable(ctx: &Ctx, _top_level: Trait) -> TokenStream { | |
| 19 | − match &ctx.ast.data { | |
| 18 | +pub(crate) fn derive_immutable(ctx: &Ctx, _top_level: Trait) -> Result<TokenStream, Error> { | |
| 19 | + Ok(match &ctx.ast.data { | |
| 20 | 20 | Data::Struct(strct) => { |
| 21 | 21 | ImplBlockBuilder::new(ctx, strct, Trait::Immutable, FieldBounds::ALL_SELF).build() |
| 22 | 22 | } |
| @@ -26,7 +26,7 @@ pub(crate) fn derive_immutable(ctx: &Ctx, _top_level: Trait) -> TokenStream { · 3 unmodified lines | ||
| 26 | 26 | Data::Union(unn) => { |
| 27 | 27 | ImplBlockBuilder::new(ctx, unn, Trait::Immutable, FieldBounds::ALL_SELF).build() |
| 28 | 28 | } |
| 29 | − } | |
| 29 | + }) | |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | pub(crate) fn derive_hash(ctx: &Ctx, _top_level: Trait) -> Result<TokenStream, Error> { |
| @@ -97,16 +97,20 @@ pub(crate) fn derive_split_at(ctx: &Ctx, _top_level: Trait) -> Result<TokenStrea · 64 unmodified lines | ||
| 97 | 97 | match &ctx.ast.data { |
| 98 | 98 | Data::Struct(_) => {} |
| 99 | 99 | Data::Enum(_) | Data::Union(_) => { |
| 100 | − return Err(Error::new(Span::call_site(), "can only be applied to structs")); | |
| 100 | + return ctx | |
| 101 | + .error_or_skip(Error::new(Span::call_site(), "can only be applied to structs")); | |
| 101 | 102 | } |
| 102 | 103 | }; |
| 103 | 104 | |
| 104 | 105 | if repr.get_packed().is_some() { |
| 105 | − return Err(Error::new(Span::call_site(), "must not have #[repr(packed)] attribute")); | |
| 106 | + return ctx.error_or_skip(Error::new( | |
| 107 | + Span::call_site(), | |
| 108 | + "must not have #[repr(packed)] attribute", | |
| 109 | + )); | |
| 106 | 110 | } |
| 107 | 111 | |
| 108 | 112 | if !(repr.is_c() || repr.is_transparent()) { |
| 109 | − return Err(Error::new( | |
| 113 | + return ctx.error_or_skip(Error::new( | |
| 110 | 114 | Span::call_site(), |
| 111 | 115 | "must have #[repr(C)] or #[repr(transparent)] in order to guarantee this type's layout is splitable", |
| 112 | 116 | )); |
| @@ -116,7 +120,7 @@ pub(crate) fn derive_split_at(ctx: &Ctx, _top_level: Trait) -> Result<TokenStrea · 3 unmodified lines | ||
| 116 | 120 | let trailing_field = if let Some(((_, _, trailing_field), _)) = fields.split_last() { |
| 117 | 121 | trailing_field |
| 118 | 122 | } else { |
| 119 | − return Err(Error::new(Span::call_site(), "must at least one field")); | |
| 123 | + return ctx.error_or_skip(Error::new(Span::call_site(), "must at least one field")); | |
| 120 | 124 | }; |
| 121 | 125 | |
| 122 | 126 | let zerocopy_crate = &ctx.zerocopy_crate; |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | use proc_macro2::TokenStream; |
| 4 | 4 | use quote::quote; |
| 5 | 5 | use syn::{ |
| @@ -531,8 +531,8 @@ fn derive_has_field_struct_union(ctx: &Ctx, data: &dyn DataExt) -> TokenStream { · 525 unmodified lines | ||
| 531 | 531 | data, |
| 532 | 532 | Trait::ProjectField { |
| 533 | 533 | variant_id: variant_id.clone(), |
| 534 | − field: field.clone(), | |
| 535 | − field_id: field_id.clone(), | |
| 534 | + field, | |
| 535 | + field_id, | |
| 536 | 536 | invariants: parse_quote!((Aliasing, Alignment, #zerocopy_crate::invariant::Initialized)), |
| 537 | 537 | }, |
| 538 | 538 | FieldBounds::None, |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | use proc_macro2::{Span, TokenStream}; |
| 4 | 4 | use syn::{Data, DataEnum, DataStruct, DataUnion, Error}; |
| 5 | 5 | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2019 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -129,6 +129,40 @@ derive!(ByteHash => derive_hash => crate::derive::derive_hash); · 123 unmodified lines | ||
| 129 | 129 | derive!(ByteEq => derive_eq => crate::derive::derive_eq); |
| 130 | 130 | derive!(SplitAt => derive_split_at => crate::derive::derive_split_at); |
| 131 | 131 | |
| 132 | +#[cfg_attr(not(zerocopy_unstable_linux), doc(hidden))] | |
| 133 | +#[proc_macro_derive(most_traits, attributes(zerocopy))] | |
| 134 | +pub fn most_traits(ts: proc_macro::TokenStream) -> proc_macro::TokenStream { | |
| 135 | + let ast = syn::parse_macro_input!(ts as DeriveInput); | |
| 136 | + let ctx = match Ctx::try_from_derive_input(ast) { | |
| 137 | + Ok(ctx) => ctx, | |
| 138 | + Err(e) => return e.into_compile_error().into(), | |
| 139 | + } | |
| 140 | + .skip_on_error(); | |
| 141 | + | |
| 142 | + // top-level traits for which to attempt a derive | |
| 143 | + let derives: [(fn(&Ctx, Trait) -> _, _); 6] = [ | |
| 144 | + (crate::derive::known_layout::derive, Trait::KnownLayout), | |
| 145 | + (crate::derive::derive_immutable, Trait::Immutable), | |
| 146 | + (crate::derive::from_bytes::derive_from_bytes, Trait::FromBytes), | |
| 147 | + (crate::derive::into_bytes::derive_into_bytes, Trait::IntoBytes), | |
| 148 | + (crate::derive::derive_split_at, Trait::SplitAt), | |
| 149 | + (crate::derive::unaligned::derive_unaligned, Trait::Unaligned), | |
| 150 | + ]; | |
| 151 | + | |
| 152 | + let mut tokens = proc_macro2::TokenStream::new(); | |
| 153 | + for (derive, t) in derives { | |
| 154 | + tokens.extend(derive(&ctx, t)) | |
| 155 | + } | |
| 156 | + | |
| 157 | + // We wrap in `const_block` as a backstop in case any derive fails | |
| 158 | + // to wrap its output in `const_block` (and thus fails to annotate) | |
| 159 | + // with the full set of `#[allow(...)]` attributes). | |
| 160 | + let ts = const_block([Some(tokens)]); | |
| 161 | + #[cfg(test)] | |
| 162 | + crate::util::testutil::check_hygiene(ts.clone()); | |
| 163 | + ts.into() | |
| 164 | +} | |
| 165 | + | |
| 132 | 166 | /// Deprecated: prefer [`FromZeros`] instead. |
| 133 | 167 | #[deprecated(since = "0.8.0", note = "`FromZeroes` was renamed to `FromZeros`")] |
| 134 | 168 | #[doc(hidden)] |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2019 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2019 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -98,6 +98,11 @@ impl Ctx { · 92 unmodified lines | ||
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | + pub(crate) fn skip_on_error(mut self) -> Self { | |
| 102 | + self.skip_on_error = true; | |
| 103 | + self | |
| 104 | + } | |
| 105 | + | |
| 101 | 106 | pub(crate) fn core_path(&self) -> TokenStream { |
| 102 | 107 | let zerocopy_crate = &self.zerocopy_crate; |
| 103 | 108 | quote!(#zerocopy_crate::util::macro_util::core_reexport) |
| @@ -106,20 +111,21 @@ impl Ctx { · 2 unmodified lines | ||
| 106 | 111 | pub(crate) fn cfg_compile_error(&self) -> TokenStream { |
| 107 | 112 | // By checking both during the compilation of the proc macro *and* in |
| 108 | 113 | // the generated code, we ensure that `--cfg |
| 109 | − // zerocopy_unstable_derive_on_error` need only be passed *either* when | |
| 114 | + // zerocopy_unstable_linux` need only be passed *either* when | |
| 110 | 115 | // compiling this crate *or* when compiling the user's crate. The former |
| 111 | 116 | // is preferable, but in some situations (such as when cross-compiling |
| 112 | 117 | // using `cargo build --target`), it doesn't get propagated to this |
| 113 | 118 | // crate's build by default. |
| 114 | − if cfg!(zerocopy_unstable_derive_on_error) { | |
| 119 | + if cfg!(zerocopy_unstable_linux) { | |
| 115 | 120 | quote!() |
| 116 | 121 | } else if let Some(span) = self.on_error_span { |
| 117 | 122 | let core = self.core_path(); |
| 118 | − let error_message = "`on_error` is experimental; pass '--cfg zerocopy_unstable_derive_on_error' to enable"; | |
| 123 | + let error_message = | |
| 124 | + "`on_error` is experimental; pass '--cfg zerocopy_unstable_linux' to enable"; | |
| 119 | 125 | quote::quote_spanned! {span=> |
| 120 | 126 | #[allow(unused_attributes, unexpected_cfgs)] |
| 121 | 127 | const _: () = { |
| 122 | − #[cfg(not(zerocopy_unstable_derive_on_error))] | |
| 128 | + #[cfg(not(zerocopy_unstable_linux))] | |
| 123 | 129 | #core::compile_error!(#error_message); |
| 124 | 130 | }; |
| 125 | 131 | } |
| @@ -612,6 +618,20 @@ impl<'a> ImplBlockBuilder<'a> { · 486 unmodified lines | ||
| 612 | 618 | } |
| 613 | 619 | }; |
| 614 | 620 | |
| 621 | + let zerocopy_bounds = | |
| 622 | + field_type_bounds | |
| 623 | + .into_iter() | |
| 624 | + .chain(padding_check_bound) | |
| 625 | + .chain(self_bounds) | |
| 626 | + .map(|bound| { | |
| 627 | + if self.ctx.skip_on_error { | |
| 628 | + parse_quote!(for<'zc> #bound) | |
| 629 | + } else { | |
| 630 | + bound.clone() | |
| 631 | + } | |
| 632 | + }) | |
| 633 | + .collect::<Vec<_>>(); | |
| 634 | + | |
| 615 | 635 | let bounds = self |
| 616 | 636 | .ctx |
| 617 | 637 | .ast |
| @@ -621,9 +641,7 @@ impl<'a> ImplBlockBuilder<'a> { · 3 unmodified lines | ||
| 621 | 641 | .map(|where_clause| where_clause.predicates.iter()) |
| 622 | 642 | .into_iter() |
| 623 | 643 | .flatten() |
| 624 | − .chain(field_type_bounds.iter()) | |
| 625 | − .chain(padding_check_bound.iter()) | |
| 626 | − .chain(self_bounds.iter()); | |
| 644 | + .chain(zerocopy_bounds.iter()); | |
| 627 | 645 | |
| 628 | 646 | // The parameters with trait bounds, but without type defaults. |
| 629 | 647 | let mut params: Vec<_> = self |
| @@ -1,14 +1,13 @@ | ||
| 1 | 1 | # `zerocopy` |
| 2 | 2 | |
| 3 | −These source files come from the Rust `zerocopy` crate, version v0.8.50 | |
| 4 | −(released 2026-05-31), hosted in the <https://github.com/google/zerocopy> | |
| 3 | +These source files come from the Rust `zerocopy` crate, version v0.8.54 | |
| 4 | +(released 2026-07-08), hosted in the <https://github.com/google/zerocopy> | |
| 5 | 5 | repository, licensed under "BSD-2-Clause OR Apache-2.0 OR MIT" and only |
| 6 | −modified to add the SPDX license identifiers and to remove `Display` | |
| 7 | −for `f32` and `f64`. | |
| 6 | +modified to tweak the SPDX license identifiers. | |
| 8 | 7 | |
| 9 | 8 | For copyright details, please see: |
| 10 | 9 | |
| 11 | − https://github.com/google/zerocopy/blob/v0.8.50/README.md?plain=1 | |
| 12 | − https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-BSD | |
| 13 | − https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-APACHE | |
| 14 | − https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-MIT | |
| 10 | + https://github.com/google/zerocopy/blob/v0.8.54/README.md?plain=1 | |
| 11 | + https://github.com/google/zerocopy/blob/v0.8.54/LICENSE-BSD | |
| 12 | + https://github.com/google/zerocopy/blob/v0.8.54/LICENSE-APACHE | |
| 13 | + https://github.com/google/zerocopy/blob/v0.8.54/LICENSE-MIT | |
| @@ -1,5 +1,4 @@ | ||
| 1 | 1 | /* SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT */ |
| 2 | − | |
| 3 | 2 | /* |
| 4 | 3 | Copyright 2026 The Fuchsia Authors |
| 5 | 4 | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2024 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2019 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -100,6 +100,7 @@ mod private { · 94 unmodified lines | ||
| 100 | 100 | |
| 101 | 101 | #[allow(missing_copy_implementations, missing_debug_implementations)] |
| 102 | 102 | #[doc(hidden)] |
| 103 | +#[derive(PartialEq)] | |
| 103 | 104 | pub enum Order { |
| 104 | 105 | BigEndian, |
| 105 | 106 | LittleEndian, |
| @@ -164,6 +165,42 @@ pub type BE = BigEndian; · 58 unmodified lines | ||
| 164 | 165 | /// A type alias for [`LittleEndian`]. |
| 165 | 166 | pub type LE = LittleEndian; |
| 166 | 167 | |
| 168 | +macro_rules! impl_dbg_trait { | |
| 169 | + ($name:ident, $native:ident) => { | |
| 170 | + impl<O: ByteOrder> Debug for $name<O> { | |
| 171 | + #[inline] | |
| 172 | + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { | |
| 173 | + // This results in a format like "U16(42)". | |
| 174 | + f.debug_tuple(stringify!($name)).field(&self.get()).finish() | |
| 175 | + } | |
| 176 | + } | |
| 177 | + }; | |
| 178 | +} | |
| 179 | + | |
| 180 | +macro_rules! impl_dbg_traits { | |
| 181 | + ($name:ident, $native:ident, "floating point number") => { | |
| 182 | + #[cfg(not(no_fp_fmt_parse))] | |
| 183 | + impl_dbg_trait!($name, $native); | |
| 184 | + | |
| 185 | + #[cfg(no_fp_fmt_parse)] | |
| 186 | + impl<O: ByteOrder> Debug for $name<O> { | |
| 187 | + #[inline] | |
| 188 | + fn fmt(&self, _f: &mut Formatter<'_>) -> fmt::Result { | |
| 189 | + panic!("floating point support is turned off"); | |
| 190 | + } | |
| 191 | + } | |
| 192 | + }; | |
| 193 | + ($name:ident, $native:ident, "unsigned integer") => { | |
| 194 | + impl_dbg_traits!($name, $native, @all_types); | |
| 195 | + }; | |
| 196 | + ($name:ident, $native:ident, "signed integer") => { | |
| 197 | + impl_dbg_traits!($name, $native, @all_types); | |
| 198 | + }; | |
| 199 | + ($name:ident, $native:ident, @all_types) => { | |
| 200 | + impl_dbg_trait!($name, $native); | |
| 201 | + }; | |
| 202 | +} | |
| 203 | + | |
| 167 | 204 | macro_rules! impl_fmt_trait { |
| 168 | 205 | ($name:ident, $native:ident, $trait:ident) => { |
| 169 | 206 | impl<O: ByteOrder> $trait for $name<O> { |
| @@ -177,6 +214,8 @@ macro_rules! impl_fmt_trait { · 7 unmodified lines | ||
| 177 | 214 | |
| 178 | 215 | macro_rules! impl_fmt_traits { |
| 179 | 216 | ($name:ident, $native:ident, "floating point number") => { |
| 217 | + #[cfg(not(no_fp_fmt_parse))] | |
| 218 | + impl_fmt_trait!($name, $native, Display); | |
| 180 | 219 | }; |
| 181 | 220 | ($name:ident, $native:ident, "unsigned integer") => { |
| 182 | 221 | impl_fmt_traits!($name, $native, @all_types); |
| @@ -687,16 +726,9 @@ example of how it can be used for parsing UDP packets. · 504 unmodified lines | ||
| 687 | 726 | } |
| 688 | 727 | } |
| 689 | 728 | |
| 729 | + impl_dbg_traits!($name, $native, $number_kind); | |
| 690 | 730 | impl_fmt_traits!($name, $native, $number_kind); |
| 691 | 731 | impl_ops_traits!($name, $native, $number_kind); |
| 692 | − | |
| 693 | − impl<O: ByteOrder> Debug for $name<O> { | |
| 694 | − #[inline] | |
| 695 | − fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { | |
| 696 | − // This results in a format like "U16(42)". | |
| 697 | − f.debug_tuple(stringify!($name)).field(&self.get()).finish() | |
| 698 | − } | |
| 699 | − } | |
| 700 | 732 | }; |
| 701 | 733 | } |
| 702 | 734 | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2024 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under the 2-Clause BSD License <LICENSE-BSD or |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2024 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under the 2-Clause BSD License <LICENSE-BSD or |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2024 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under the 2-Clause BSD License <LICENSE-BSD or |
| @@ -1359,7 +1359,7 @@ mod simd { · 1353 unmodified lines | ||
| 1359 | 1359 | #[cfg(not(no_zerocopy_aarch64_simd_1_59_0))] |
| 1360 | 1360 | simd_arch_mod!( |
| 1361 | 1361 | #[cfg(all( |
| 1362 | − target_arch = "aarch64", | |
| 1362 | + target_arch = "aarch64", | |
| 1363 | 1363 | any( |
| 1364 | 1364 | target_endian = "little", |
| 1365 | 1365 | not(no_zerocopy_aarch64_simd_be_1_87_0) |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2024 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under the 2-Clause BSD License <LICENSE-BSD or |
| @@ -71,6 +71,8 @@ impl SizeInfo { · 65 unmodified lines | ||
| 71 | 71 | /// Attempts to create a `SizeInfo` from `Self` in which `elem_size` is a |
| 72 | 72 | /// `NonZeroUsize`. If `elem_size` is 0, returns `None`. |
| 73 | 73 | #[allow(unused)] |
| 74 | + #[cfg_attr(not(zerocopy_inline_always), inline)] | |
| 75 | + #[cfg_attr(zerocopy_inline_always, inline(always))] | |
| 74 | 76 | const fn try_to_nonzero_elem_size(&self) -> Option<SizeInfo<NonZeroUsize>> { |
| 75 | 77 | Some(match *self { |
| 76 | 78 | SizeInfo::Sized { size } => SizeInfo::Sized { size }, |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2018 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under the 2-Clause BSD License <LICENSE-BSD or |
| @@ -12,7 +12,7 @@ · 6 unmodified lines | ||
| 12 | 12 | // After updating the following doc comment, make sure to run the following |
| 13 | 13 | // command to update `README.md` based on its contents: |
| 14 | 14 | // |
| 15 | −// cargo -q run --manifest-path tools/Cargo.toml -p generate-readme > README.md | |
| 15 | +// (cd .. && cargo -q run --manifest-path tools/Cargo.toml -p generate-readme) > README.md | |
| 16 | 16 | |
| 17 | 17 | //! ***<span style="font-size: 140%">Fast, safe, <span |
| 18 | 18 | //! style="color:red;">compile error</span>. Pick two.</span>*** |
| @@ -174,7 +174,7 @@ · 155 unmodified lines | ||
| 174 | 174 | //! |
| 175 | 175 | //! [Miri]: https://github.com/rust-lang/miri |
| 176 | 176 | //! [Kani]: https://github.com/model-checking/kani |
| 177 | −//! [soundness policy]: https://github.com/google/zerocopy/blob/main/POLICIES.md#soundness | |
| 177 | +//! [soundness policy]: https://github.com/google/zerocopy/blob/main/zerocopy/POLICIES.md#soundness | |
| 178 | 178 | //! |
| 179 | 179 | //! # Relationship to Project Safe Transmute |
| 180 | 180 | //! |
| @@ -203,7 +203,7 @@ · 22 unmodified lines | ||
| 203 | 203 | //! |
| 204 | 204 | //! See our [MSRV policy]. |
| 205 | 205 | //! |
| 206 | −//! [MSRV policy]: https://github.com/google/zerocopy/blob/main/POLICIES.md#msrv | |
| 206 | +//! [MSRV policy]: https://github.com/google/zerocopy/blob/main/zerocopy/POLICIES.md#msrv | |
| 207 | 207 | //! |
| 208 | 208 | //! # Changelog |
| 209 | 209 | //! |
| @@ -435,6 +435,8 @@ const _: () = { · 225 unmodified lines | ||
| 435 | 435 | WARNING |
| 436 | 436 | }; |
| 437 | 437 | |
| 438 | +#[cfg(all(any(feature = "derive", test), zerocopy_unstable_linux))] | |
| 439 | +pub use zerocopy_derive::most_traits; | |
| 438 | 440 | /// Implements [`KnownLayout`]. |
| 439 | 441 | /// |
| 440 | 442 | /// This derive analyzes various aspects of a type's layout that are needed for |
| @@ -2832,7 +2834,7 @@ pub unsafe trait TryFromBytes { · 2391 unmodified lines | ||
| 2832 | 2834 | /// ``` |
| 2833 | 2835 | /// |
| 2834 | 2836 | /// [`try_mut_from_bytes`]: TryFromBytes::try_mut_from_bytes |
| 2835 | − /// | |
| 2837 | + /// | |
| 2836 | 2838 | #[doc = codegen_header!("h5", "try_mut_from_bytes_with_elems")] |
| 2837 | 2839 | /// |
| 2838 | 2840 | /// See [`TryFromBytes::try_ref_from_bytes_with_elems`](#method.try_ref_from_bytes_with_elems.codegen). |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2024 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under the 2-Clause BSD License <LICENSE-BSD or |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2024 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2024 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2023 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2023 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2025 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2024 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under the 2-Clause BSD License <LICENSE-BSD or |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2025 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under the 2-Clause BSD License <LICENSE-BSD or |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2022 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2023 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2023 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -150,6 +150,8 @@ pub(crate) fn validate_aligned_to<T: AsAddress, U>(t: T) -> Result<(), Alignment · 144 unmodified lines | ||
| 150 | 150 | // Ensures that we add the minimum required padding. |
| 151 | 151 | kani::ensures(|&p| p < align.get()), |
| 152 | 152 | )] |
| 153 | +#[cfg_attr(not(zerocopy_inline_always), inline)] | |
| 154 | +#[cfg_attr(zerocopy_inline_always, inline(always))] | |
| 153 | 155 | pub(crate) const fn padding_needed_for(len: usize, align: NonZeroUsize) -> usize { |
| 154 | 156 | #[cfg(kani)] |
| 155 | 157 | #[kani::proof_for_contract(padding_needed_for)] |
| @@ -251,6 +253,8 @@ pub(crate) const fn round_down_to_next_multiple_of_alignment( · 95 unmodified lines | ||
| 251 | 253 | n & mask |
| 252 | 254 | } |
| 253 | 255 | |
| 256 | +#[cfg_attr(not(zerocopy_inline_always), inline)] | |
| 257 | +#[cfg_attr(zerocopy_inline_always, inline(always))] | |
| 254 | 258 | pub(crate) const fn max(a: NonZeroUsize, b: NonZeroUsize) -> NonZeroUsize { |
| 255 | 259 | if a.get() < b.get() { |
| 256 | 260 | b |
| @@ -259,6 +263,8 @@ pub(crate) const fn max(a: NonZeroUsize, b: NonZeroUsize) -> NonZeroUsize { · 2 unmodified lines | ||
| 259 | 263 | } |
| 260 | 264 | } |
| 261 | 265 | |
| 266 | +#[cfg_attr(not(zerocopy_inline_always), inline)] | |
| 267 | +#[cfg_attr(zerocopy_inline_always, inline(always))] | |
| 262 | 268 | pub(crate) const fn min(a: NonZeroUsize, b: NonZeroUsize) -> NonZeroUsize { |
| 263 | 269 | if a.get() > b.get() { |
| 264 | 270 | b |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT |
| 2 | − | |
| 2 | +// | |
| 3 | 3 | // Copyright 2023 The Fuchsia Authors |
| 4 | 4 | // |
| 5 | 5 | // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| @@ -343,6 +343,8 @@ static int tas2781_read_acpi(struct tas2781_hda *tas_hda, · 342 unmodified lines | ||
| 343 | 343 | strscpy(p->dev_name, hid, sizeof(p->dev_name)); |
| 344 | 344 | physdev = get_device(acpi_get_first_physical_node(adev)); |
| 345 | 345 | acpi_dev_put(adev); |
| 346 | + if (!physdev) | |
| 347 | + return -ENODEV; | |
| 346 | 348 | |
| 347 | 349 | property = "ti,dev-index"; |
| 348 | 350 | ret = device_property_count_u32(physdev, property); |
| @@ -385,7 +387,6 @@ static int tas2781_read_acpi(struct tas2781_hda *tas_hda, · 36 unmodified lines | ||
| 385 | 387 | err: |
| 386 | 388 | dev_err(p->dev, "read acpi error, ret: %d\n", ret); |
| 387 | 389 | put_device(physdev); |
| 388 | − acpi_dev_put(adev); | |
| 389 | 390 | |
| 390 | 391 | return ret; |
| 391 | 392 | } |
| @@ -44,6 +44,13 @@ static const struct dmi_system_id acp70_acpi_flag_override_table[] = { · 43 unmodified lines | ||
| 44 | 44 | DMI_MATCH(DMI_PRODUCT_NAME, "83W5"), |
| 45 | 45 | }, |
| 46 | 46 | }, |
| 47 | + { | |
| 48 | + /* Lenovo Legion 7 15ASH11 (Strix Halo, ACP 7.0) */ | |
| 49 | + .matches = { | |
| 50 | + DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), | |
| 51 | + DMI_MATCH(DMI_PRODUCT_NAME, "83V9"), | |
| 52 | + }, | |
| 53 | + }, | |
| 47 | 54 | { |
| 48 | 55 | .matches = { |
| 49 | 56 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC"), |
| @@ -45,6 +45,13 @@ static struct snd_soc_card acp6x_card = { · 44 unmodified lines | ||
| 45 | 45 | }; |
| 46 | 46 | |
| 47 | 47 | static const struct dmi_system_id yc_acp_quirk_table[] = { |
| 48 | + { | |
| 49 | + .driver_data = &acp6x_card, | |
| 50 | + .matches = { | |
| 51 | + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | |
| 52 | + DMI_MATCH(DMI_PRODUCT_NAME, "Aspire AG14-22P"), | |
| 53 | + } | |
| 54 | + }, | |
| 48 | 55 | { |
| 49 | 56 | .driver_data = &acp6x_card, |
| 50 | 57 | .matches = { |
| @@ -521,6 +528,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { · 470 unmodified lines | ||
| 521 | 528 | DMI_MATCH(DMI_PRODUCT_NAME, "Vector A16 HX A8WHG"), |
| 522 | 529 | } |
| 523 | 530 | }, |
| 531 | + { | |
| 532 | + .driver_data = &acp6x_card, | |
| 533 | + .matches = { | |
| 534 | + DMI_MATCH(DMI_BOARD_VENDOR, "Micro-Star International Co., Ltd."), | |
| 535 | + DMI_MATCH(DMI_PRODUCT_NAME, "Crosshair A16 HX D7WFKG"), | |
| 536 | + } | |
| 537 | + }, | |
| 524 | 538 | { |
| 525 | 539 | .driver_data = &acp6x_card, |
| 526 | 540 | .matches = { |
| @@ -829,6 +843,14 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { · 302 unmodified lines | ||
| 829 | 843 | DMI_MATCH(DMI_BOARD_NAME, "PM1403CDA"), |
| 830 | 844 | } |
| 831 | 845 | }, |
| 846 | + { | |
| 847 | + .driver_data = &acp6x_card, | |
| 848 | + .matches = { | |
| 849 | + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC."), | |
| 850 | + DMI_MATCH(DMI_PRODUCT_NAME, "Vivobook_ASUSLaptop M6500RE_M6500RE"), | |
| 851 | + } | |
| 852 | + }, | |
| 853 | + | |
| 832 | 854 | {} |
| 833 | 855 | }; |
| 834 | 856 | |
| @@ -2423,8 +2423,9 @@ static int max98090_probe(struct snd_soc_component *component) · 2422 unmodified lines | ||
| 2423 | 2423 | dev_dbg(component->dev, "max98090_probe\n"); |
| 2424 | 2424 | |
| 2425 | 2425 | max98090->mclk = devm_clk_get(component->dev, "mclk"); |
| 2426 | − if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER) | |
| 2427 | − return -EPROBE_DEFER; | |
| 2426 | + if (IS_ERR(max98090->mclk)) | |
| 2427 | + if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER) | |
| 2428 | + return -EPROBE_DEFER; | |
| 2428 | 2429 | |
| 2429 | 2430 | max98090->component = component; |
| 2430 | 2431 | |
| @@ -1987,8 +1987,9 @@ static int max98095_probe(struct snd_soc_component *component) · 1986 unmodified lines | ||
| 1987 | 1987 | int ret = 0; |
| 1988 | 1988 | |
| 1989 | 1989 | max98095->mclk = devm_clk_get(component->dev, "mclk"); |
| 1990 | − if (PTR_ERR(max98095->mclk) == -EPROBE_DEFER) | |
| 1991 | − return -EPROBE_DEFER; | |
| 1990 | + if (IS_ERR(max98095->mclk)) | |
| 1991 | + if (PTR_ERR(max98095->mclk) == -EPROBE_DEFER) | |
| 1992 | + return -EPROBE_DEFER; | |
| 1992 | 1993 | |
| 1993 | 1994 | /* reset the codec, the DSP core, and disable all interrupts */ |
| 1994 | 1995 | max98095_reset(component); |
| @@ -113,6 +113,7 @@ static int rt722_sdca_mbq_size(struct device *dev, unsigned int reg) · 112 unmodified lines | ||
| 113 | 113 | case 0x2000090 ... 0x2000094: |
| 114 | 114 | case 0x20000b1: |
| 115 | 115 | case 0x20000b4: |
| 116 | + case 0x3010000: | |
| 116 | 117 | case 0x3110000: |
| 117 | 118 | case 0x5300000 ... 0x5300300: |
| 118 | 119 | case 0x5400002: |
| @@ -196,15 +197,18 @@ static bool rt722_sdca_volatile_register(struct device *dev, unsigned int reg) · 77 unmodified lines | ||
| 196 | 197 | case 0x2000007: |
| 197 | 198 | case 0x200000d: |
| 198 | 199 | case 0x2000019: |
| 200 | + case 0x200001a: | |
| 199 | 201 | case 0x2000020: |
| 200 | 202 | case 0x2000030: |
| 201 | 203 | case 0x2000046: |
| 202 | 204 | case 0x2000067: |
| 203 | 205 | case 0x2000084: |
| 204 | 206 | case 0x2000086: |
| 207 | + case 0x3010000: | |
| 205 | 208 | case 0x3110000: |
| 206 | 209 | case 0x5800003: |
| 207 | 210 | case 0x5810000: |
| 211 | + case 0x6100008: | |
| 208 | 212 | case 0x44011000 ... 0x440115ff: |
| 209 | 213 | case 0x44012000: |
| 210 | 214 | case 0x44012021: |
| @@ -1851,6 +1851,17 @@ static void rt722_sdca_jack_preset(struct rt722_sdca_priv *rt722) · 1850 unmodified lines | ||
| 1851 | 1851 | } |
| 1852 | 1852 | } |
| 1853 | 1853 | |
| 1854 | +static void rt722_sdca_reset(struct rt722_sdca_priv *rt722) | |
| 1855 | +{ | |
| 1856 | + rt722_sdca_index_update_bits(rt722, RT722_VENDOR_REG, | |
| 1857 | + RT722_LDO1_CTL, RT722_HIDDEN_REG_SW_RESET, | |
| 1858 | + RT722_HIDDEN_REG_SW_RESET); | |
| 1859 | + rt722_sdca_index_update_bits(rt722, RT722_VENDOR_HDA_CTL, | |
| 1860 | + RT722_HDA_LEGACY_RESET_CTL, 0x1, 0x1); | |
| 1861 | + if (rt722->hw_vid == RT722_VA) | |
| 1862 | + rt722_sdca_index_write(rt722, RT722_VENDOR_REG, RT722_LDO1_CTL, 0xb091); | |
| 1863 | +} | |
| 1864 | + | |
| 1854 | 1865 | int rt722_sdca_io_init(struct device *dev, struct sdw_slave *slave) |
| 1855 | 1866 | { |
| 1856 | 1867 | struct rt722_sdca_priv *rt722 = dev_get_drvdata(dev); |
| @@ -1888,6 +1899,9 @@ int rt722_sdca_io_init(struct device *dev, struct sdw_slave *slave) · 31 unmodified lines | ||
| 1888 | 1899 | rt722->hw_vid = (val & 0x0f00) >> 8; |
| 1889 | 1900 | dev_dbg(&slave->dev, "%s hw_vid=0x%x\n", __func__, rt722->hw_vid); |
| 1890 | 1901 | |
| 1902 | + if (!rt722->first_hw_init) | |
| 1903 | + rt722_sdca_reset(rt722); | |
| 1904 | + | |
| 1891 | 1905 | rt722_sdca_dmic_preset(rt722); |
| 1892 | 1906 | rt722_sdca_amp_preset(rt722); |
| 1893 | 1907 | rt722_sdca_jack_preset(rt722); |
| @@ -32,15 +32,16 @@ · 31 unmodified lines | ||
| 32 | 32 | static const unsigned int float_vol_db_lookup[] = { |
| 33 | 33 | 0x00000d43, 0x000010b2, 0x00001505, 0x00001a67, 0x00002151, |
| 34 | 34 | 0x000029f1, 0x000034cd, 0x00004279, 0x000053af, 0x0000695b, |
| 35 | −0x0000695b, 0x0000a6fa, 0x0000d236, 0x000108a4, 0x00014d2a, | |
| 35 | +0x000084a3, 0x0000a6fa, 0x0000d236, 0x000108a4, 0x00014d2a, | |
| 36 | 36 | 0x0001a36e, 0x00021008, 0x000298c0, 0x000344df, 0x00041d8f, |
| 37 | 37 | 0x00052e5a, 0x000685c8, 0x00083621, 0x000a566d, 0x000d03a7, |
| 38 | 38 | 0x0010624d, 0x0014a050, 0x0019f786, 0x0020b0bc, 0x0029279d, |
| 39 | 39 | 0x0033cf8d, 0x004139d3, 0x00521d50, 0x00676044, 0x0082248a, |
| 40 | 40 | 0x00a3d70a, 0x00ce4328, 0x0103ab3d, 0x0146e75d, 0x019b8c27, |
| 41 | 41 | 0x02061b89, 0x028c423f, 0x03352529, 0x0409c2b0, 0x05156d68, |
| 42 | −0x080e9f96, 0x0a24b062, 0x0cc509ab, 0x10137987, 0x143d1362, | |
| 43 | −0x197a967f, 0x2013739e, 0x28619ae9, 0x32d64617, 0x40000000 | |
| 42 | +0x06666666, 0x080e9f96, 0x0a24b062, 0x0cc509ab, 0x10137987, | |
| 43 | +0x143d1362, 0x197a967f, 0x2013739e, 0x28619ae9, 0x32d64617, | |
| 44 | +0x40000000 | |
| 44 | 45 | }; |
| 45 | 46 | |
| 46 | 47 | struct tas2562_data { |
| @@ -471,30 +472,45 @@ static int tas2562_volume_control_put(struct snd_kcontrol *kcontrol, · 424 unmodified lines | ||
| 471 | 472 | { |
| 472 | 473 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); |
| 473 | 474 | struct tas2562_data *tas2562 = snd_soc_component_get_drvdata(component); |
| 474 | − int ret; | |
| 475 | + int ret, index; | |
| 475 | 476 | u32 reg_val; |
| 476 | 477 | |
| 477 | − reg_val = float_vol_db_lookup[ucontrol->value.integer.value[0]/2]; | |
| 478 | − ret = snd_soc_component_write(component, TAS2562_DVC_CFG4, | |
| 479 | − (reg_val & 0xff)); | |
| 480 | − if (ret) | |
| 481 | − return ret; | |
| 482 | − ret = snd_soc_component_write(component, TAS2562_DVC_CFG3, | |
| 483 | − ((reg_val >> 8) & 0xff)); | |
| 478 | + if (tas2562->volume_lvl == ucontrol->value.integer.value[0]) | |
| 479 | + return 0; | |
| 480 | + | |
| 481 | + index = ucontrol->value.integer.value[0] / 2; | |
| 482 | + if (index < 0 || index >= ARRAY_SIZE(float_vol_db_lookup)) | |
| 483 | + return -EINVAL; | |
| 484 | + | |
| 485 | + reg_val = float_vol_db_lookup[index]; | |
| 486 | + | |
| 487 | + /* | |
| 488 | + * The device applies the 32-bit coefficient to the playback path on | |
| 489 | + * the write to DVC_CFG4 (the LSB, book 0 page 2 reg 0x0F), so the | |
| 490 | + * bytes must be written MSB first and DVC_CFG4 last. Writing CFG4 | |
| 491 | + * first latches a mix of the previous coefficient's upper bytes and | |
| 492 | + * the new LSB instead of the requested value. | |
| 493 | + */ | |
| 494 | + ret = snd_soc_component_write(component, TAS2562_DVC_CFG1, | |
| 495 | + ((reg_val >> 24) & 0xff)); | |
| 484 | 496 | if (ret) |
| 485 | 497 | return ret; |
| 486 | 498 | ret = snd_soc_component_write(component, TAS2562_DVC_CFG2, |
| 487 | 499 | ((reg_val >> 16) & 0xff)); |
| 488 | 500 | if (ret) |
| 489 | 501 | return ret; |
| 490 | − ret = snd_soc_component_write(component, TAS2562_DVC_CFG1, | |
| 491 | − ((reg_val >> 24) & 0xff)); | |
| 502 | + ret = snd_soc_component_write(component, TAS2562_DVC_CFG3, | |
| 503 | + ((reg_val >> 8) & 0xff)); | |
| 504 | + if (ret) | |
| 505 | + return ret; | |
| 506 | + ret = snd_soc_component_write(component, TAS2562_DVC_CFG4, | |
| 507 | + (reg_val & 0xff)); | |
| 492 | 508 | if (ret) |
| 493 | 509 | return ret; |
| 494 | 510 | |
| 495 | 511 | tas2562->volume_lvl = ucontrol->value.integer.value[0]; |
| 496 | 512 | |
| 497 | − return 0; | |
| 513 | + return 1; | |
| 498 | 514 | } |
| 499 | 515 | |
| 500 | 516 | /* Digital Volume Control. From 0 dB to -110 dB in 1 dB steps */ |
| @@ -732,6 +748,8 @@ static int tas2562_probe(struct i2c_client *client) · 231 unmodified lines | ||
| 732 | 748 | data->client = client; |
| 733 | 749 | data->dev = &client->dev; |
| 734 | 750 | data->model_id = (uintptr_t)i2c_get_match_data(client); |
| 751 | + /* Register default is 0x40400000, this is closest */ | |
| 752 | + data->volume_lvl = (ARRAY_SIZE(float_vol_db_lookup) - 1) * 2; | |
| 735 | 753 | |
| 736 | 754 | tas2562_parse_dt(data); |
| 737 | 755 | |
| @@ -1310,8 +1310,8 @@ static void cali_reg_update(struct bulk_reg_val *p, · 1309 unmodified lines | ||
| 1310 | 1310 | t->sin_gn[2]); |
| 1311 | 1311 | break; |
| 1312 | 1312 | case TAS2781_PRM_SINEGAIN2_REG: |
| 1313 | − reg = TASDEVICE_REG(t->sin_gn[0], t->sin_gn[1], | |
| 1314 | − t->sin_gn[2]); | |
| 1313 | + reg = TASDEVICE_REG(t->sin_gn2[0], t->sin_gn2[1], | |
| 1314 | + t->sin_gn2[2]); | |
| 1315 | 1315 | break; |
| 1316 | 1316 | default: |
| 1317 | 1317 | reg = 0; |
| @@ -1419,7 +1419,7 @@ static int fsl_asrc_probe(struct platform_device *pdev) · 1418 unmodified lines | ||
| 1419 | 1419 | ret = fsl_asrc_m2m_init(asrc); |
| 1420 | 1420 | if (ret) { |
| 1421 | 1421 | dev_err(&pdev->dev, "failed to init m2m device %d\n", ret); |
| 1422 | − return ret; | |
| 1422 | + goto err_pm_get_sync; | |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | 1425 | return 0; |
| @@ -2269,7 +2269,7 @@ static int fsl_easrc_probe(struct platform_device *pdev) · 2268 unmodified lines | ||
| 2269 | 2269 | ret = fsl_asrc_m2m_init(easrc); |
| 2270 | 2270 | if (ret) { |
| 2271 | 2271 | dev_err(&pdev->dev, "failed to init m2m device %d\n", ret); |
| 2272 | − return ret; | |
| 2272 | + goto err_pm_disable; | |
| 2273 | 2273 | } |
| 2274 | 2274 | |
| 2275 | 2275 | return 0; |
| @@ -8,6 +8,7 @@ · 7 unmodified lines | ||
| 8 | 8 | |
| 9 | 9 | #include <sound/soc-acpi.h> |
| 10 | 10 | #include <sound/soc-acpi-intel-match.h> |
| 11 | +#include <sound/soc-acpi-intel-ssp-common.h> | |
| 11 | 12 | #include "soc-acpi-intel-sdw-mockup-match.h" |
| 12 | 13 | |
| 13 | 14 | static const struct snd_soc_acpi_codecs nvl_essx_83x6 = { |
| @@ -15,6 +16,11 @@ static const struct snd_soc_acpi_codecs nvl_essx_83x6 = { · 1 unmodified line | ||
| 15 | 16 | .codecs = { "ESSX8316", "ESSX8326", "ESSX8336"}, |
| 16 | 17 | }; |
| 17 | 18 | |
| 19 | +static const struct snd_soc_acpi_codecs nvl_rt5682_rt5682s_hp = { | |
| 20 | + .num_codecs = 2, | |
| 21 | + .codecs = {RT5682_ACPI_HID, RT5682S_ACPI_HID}, | |
| 22 | +}; | |
| 23 | + | |
| 18 | 24 | struct snd_soc_acpi_mach snd_soc_acpi_intel_nvl_machines[] = { |
| 19 | 25 | { |
| 20 | 26 | .comp_ids = &nvl_essx_83x6, |
| @@ -24,6 +30,13 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_nvl_machines[] = { · 3 unmodified lines | ||
| 24 | 30 | SND_SOC_ACPI_TPLG_INTEL_SSP_MSB | |
| 25 | 31 | SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER, |
| 26 | 32 | }, |
| 33 | + { | |
| 34 | + .comp_ids = &nvl_rt5682_rt5682s_hp, | |
| 35 | + .drv_name = "sof_rt5682", | |
| 36 | + .sof_tplg_filename = "sof-nvl-rt5682", /* the tplg suffix is added at run time */ | |
| 37 | + .tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER | | |
| 38 | + SND_SOC_ACPI_TPLG_INTEL_SSP_MSB, | |
| 39 | + }, | |
| 27 | 40 | {}, |
| 28 | 41 | }; |
| 29 | 42 | EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_nvl_machines); |
| @@ -111,8 +111,8 @@ static void class_boot_work(struct work_struct *work) · 110 unmodified lines | ||
| 111 | 111 | |
| 112 | 112 | regcache_cache_only(drv->dev_regmap, false); |
| 113 | 113 | |
| 114 | − drv->irq_info = sdca_irq_allocate(drv->dev, drv->dev_regmap, | |
| 115 | − drv->sdw->irq); | |
| 114 | + drv->irq_info = devm_sdca_irq_allocate(drv->dev, drv->dev_regmap, | |
| 115 | + drv->sdw->irq); | |
| 116 | 116 | if (IS_ERR(drv->irq_info)) |
| 117 | 117 | goto err; |
| 118 | 118 | |
| @@ -191,7 +191,7 @@ static const struct snd_soc_dai_ops class_function_sdw_ops = { · 190 unmodified lines | ||
| 191 | 191 | .hw_free = class_function_sdw_remove_peripheral, |
| 192 | 192 | }; |
| 193 | 193 | |
| 194 | −static int class_function_component_probe(struct snd_soc_component *component) | |
| 194 | +static int class_function_component_fixup_controls(struct snd_soc_component *component) | |
| 195 | 195 | { |
| 196 | 196 | struct class_function_drv *drv = snd_soc_component_get_drvdata(component); |
| 197 | 197 | struct sdca_class_drv *core = drv->core; |
| @@ -217,7 +217,7 @@ static int class_function_set_jack(struct snd_soc_component *component, · 19 unmodified lines | ||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | static const struct snd_soc_component_driver class_function_component_drv = { |
| 220 | − .probe = class_function_component_probe, | |
| 220 | + .fixup_controls = class_function_component_fixup_controls, | |
| 221 | 221 | .remove = class_function_component_remove, |
| 222 | 222 | .endianness = 1, |
| 223 | 223 | }; |
| @@ -408,7 +408,7 @@ static void class_function_remove(struct auxiliary_device *auxdev) · 184 unmodified lines | ||
| 408 | 408 | { |
| 409 | 409 | struct class_function_drv *drv = auxiliary_get_drvdata(auxdev); |
| 410 | 410 | |
| 411 | − sdca_irq_cleanup(drv->dev, drv->function, drv->core->irq_info); | |
| 411 | + sdca_irq_cleanup_late(drv->dev, drv->function, drv->core->irq_info); | |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | static int class_function_runtime_suspend(struct device *dev) |
| @@ -43,7 +43,7 @@ void sdca_lookup_swft(struct sdw_slave *slave) · 42 unmodified lines | ||
| 43 | 43 | dev_info(&slave->dev, "SWFT not available\n"); |
| 44 | 44 | else |
| 45 | 45 | devm_add_action_or_reset(&slave->dev, devm_acpi_table_put, |
| 46 | − &slave->sdca_data.swft); | |
| 46 | + slave->sdca_data.swft); | |
| 47 | 47 | } |
| 48 | 48 | EXPORT_SYMBOL_NS(sdca_lookup_swft, "SND_SOC_SDCA"); |
| 49 | 49 | |
| @@ -258,7 +258,8 @@ static int fdl_load_file(struct sdca_interrupt *interrupt, · 257 unmodified lines | ||
| 258 | 258 | |
| 259 | 259 | if (!swf) { |
| 260 | 260 | dev_err(dev, "failed to locate SWF\n"); |
| 261 | − return -ENOENT; | |
| 261 | + ret = -ENOENT; | |
| 262 | + goto error; | |
| 262 | 263 | } |
| 263 | 264 | |
| 264 | 265 | dev_info(dev, "loading SWF: %x-%x-%x\n", |
| @@ -270,6 +271,8 @@ static int fdl_load_file(struct sdca_interrupt *interrupt, · 5 unmodified lines | ||
| 270 | 271 | SDCA_CTL_XU_FDL_MESSAGEOFFSET, fdl_file->fdl_offset, |
| 271 | 272 | SDCA_CTL_XU_FDL_MESSAGELENGTH, swf->data, |
| 272 | 273 | swf->file_length - offsetof(struct acpi_sw_file, data)); |
| 274 | + | |
| 275 | +error: | |
| 273 | 276 | release_firmware(firmware); |
| 274 | 277 | return ret; |
| 275 | 278 | } |
| @@ -481,10 +484,9 @@ EXPORT_SYMBOL_NS_GPL(sdca_fdl_process, "SND_SOC_SDCA"); · 205 unmodified lines | ||
| 481 | 484 | */ |
| 482 | 485 | int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt) |
| 483 | 486 | { |
| 484 | − struct device *dev = interrupt->dev; | |
| 485 | 487 | struct fdl_state *fdl_state; |
| 486 | 488 | |
| 487 | − fdl_state = devm_kzalloc(dev, sizeof(*fdl_state), GFP_KERNEL); | |
| 489 | + fdl_state = kzalloc_obj(*fdl_state); | |
| 488 | 490 | if (!fdl_state) |
| 489 | 491 | return -ENOMEM; |
| 490 | 492 | |
| @@ -499,3 +501,13 @@ int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt) · 8 unmodified lines | ||
| 499 | 501 | return 0; |
| 500 | 502 | } |
| 501 | 503 | EXPORT_SYMBOL_NS_GPL(sdca_fdl_alloc_state, "SND_SOC_SDCA"); |
| 504 | + | |
| 505 | +/** | |
| 506 | + * sdca_fdl_free_state - free state for an FDL interrupt | |
| 507 | + * @interrupt: SDCA interrupt structure. | |
| 508 | + */ | |
| 509 | +void sdca_fdl_free_state(struct sdca_interrupt *interrupt) | |
| 510 | +{ | |
| 511 | + kfree(interrupt->priv); | |
| 512 | +} | |
| 513 | +EXPORT_SYMBOL_NS_GPL(sdca_fdl_free_state, "SND_SOC_SDCA"); | |
| @@ -855,6 +855,8 @@ static int find_sdca_control_range(struct device *dev, · 854 unmodified lines | ||
| 855 | 855 | return 0; |
| 856 | 856 | else if (num_range < 0) |
| 857 | 857 | return num_range; |
| 858 | + else if (num_range < 2 * sizeof(*limits)) | |
| 859 | + return -EINVAL; | |
| 858 | 860 | |
| 859 | 861 | range_list = devm_kcalloc(dev, num_range, sizeof(*range_list), GFP_KERNEL); |
| 860 | 862 | if (!range_list) |
| @@ -421,7 +421,8 @@ static struct sdca_interrupt *get_interrupt_data(struct device *dev, int irq, · 420 unmodified lines | ||
| 421 | 421 | * |
| 422 | 422 | * This is intended to be used as part of the Function boot process. It |
| 423 | 423 | * can be called before the soundcard is registered (ie. doesn't depend |
| 424 | − * on component) and will register the FDL interrupts. | |
| 424 | + * on component) and will populate all the required IRQ data, as well as | |
| 425 | + * registering the FDL interrupts to start booting the device. | |
| 425 | 426 | * |
| 426 | 427 | * Return: Zero on success, and a negative error code on failure. |
| 427 | 428 | */ |
| @@ -448,21 +449,36 @@ int sdca_irq_populate_early(struct device *dev, struct regmap *regmap, · 20 unmodified lines | ||
| 448 | 449 | else if (!interrupt) |
| 449 | 450 | continue; |
| 450 | 451 | |
| 452 | + ret = sdca_irq_data_populate(dev, regmap, NULL, function, | |
| 453 | + entity, control, interrupt); | |
| 454 | + if (ret) | |
| 455 | + return ret; | |
| 456 | + | |
| 451 | 457 | switch (SDCA_CTL_TYPE(entity->type, control->sel)) { |
| 452 | − case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER): | |
| 453 | − ret = sdca_irq_data_populate(dev, regmap, NULL, | |
| 454 | − function, entity, | |
| 455 | − control, interrupt); | |
| 458 | + case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_STATUS): | |
| 459 | + interrupt->handler = function_status_handler; | |
| 460 | + break; | |
| 461 | + case SDCA_CTL_TYPE_S(GE, DETECTED_MODE): | |
| 462 | + interrupt->handler = detected_mode_handler; | |
| 463 | + interrupt->free_priv = sdca_jack_free_state; | |
| 464 | + | |
| 465 | + ret = sdca_jack_alloc_state(interrupt); | |
| 456 | 466 | if (ret) |
| 457 | 467 | return ret; |
| 468 | + break; | |
| 469 | + case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER): | |
| 470 | + interrupt->handler = fdl_owner_handler; | |
| 471 | + interrupt->free_priv = sdca_fdl_free_state; | |
| 458 | 472 | |
| 459 | 473 | ret = sdca_fdl_alloc_state(interrupt); |
| 460 | 474 | if (ret) |
| 461 | 475 | return ret; |
| 462 | 476 | |
| 477 | + interrupt->early_request = true; | |
| 478 | + | |
| 463 | 479 | ret = sdca_irq_request_locked(dev, info, irq, |
| 464 | 480 | interrupt->name, |
| 465 | − fdl_owner_handler, | |
| 481 | + interrupt->handler, | |
| 466 | 482 | interrupt); |
| 467 | 483 | if (ret) { |
| 468 | 484 | dev_err(dev, "failed to request irq %s: %d\n", |
| @@ -470,7 +486,11 @@ int sdca_irq_populate_early(struct device *dev, struct regmap *regmap, · 1 unmodified line | ||
| 470 | 486 | return ret; |
| 471 | 487 | } |
| 472 | 488 | break; |
| 489 | + case SDCA_CTL_TYPE_S(HIDE, HIDTX_CURRENTOWNER): | |
| 490 | + interrupt->handler = hid_handler; | |
| 491 | + break; | |
| 473 | 492 | default: |
| 493 | + interrupt->handler = base_handler; | |
| 474 | 494 | break; |
| 475 | 495 | } |
| 476 | 496 | } |
| @@ -495,66 +515,38 @@ int sdca_irq_populate(struct sdca_function_data *function, · 18 unmodified lines | ||
| 495 | 515 | struct sdca_interrupt_info *info) |
| 496 | 516 | { |
| 497 | 517 | struct device *dev = component->dev; |
| 498 | − int i, j; | |
| 518 | + int i, ret; | |
| 499 | 519 | |
| 500 | 520 | guard(mutex)(&info->irq_lock); |
| 501 | 521 | |
| 502 | − for (i = 0; i < function->num_entities; i++) { | |
| 503 | − struct sdca_entity *entity = &function->entities[i]; | |
| 522 | + for (i = 0; i < SDCA_MAX_INTERRUPTS; i++) { | |
| 523 | + struct sdca_interrupt *interrupt = &info->irqs[i]; | |
| 524 | + struct sdca_control *control = interrupt->control; | |
| 525 | + struct sdca_entity *entity = interrupt->entity; | |
| 526 | + int irq; | |
| 504 | 527 | |
| 505 | − for (j = 0; j < entity->num_controls; j++) { | |
| 506 | − struct sdca_control *control = &entity->controls[j]; | |
| 507 | − int irq = control->interrupt_position; | |
| 508 | − struct sdca_interrupt *interrupt; | |
| 509 | − irq_handler_t handler; | |
| 510 | − int ret; | |
| 528 | + if (interrupt->function != function || interrupt->irq) | |
| 529 | + continue; | |
| 511 | 530 | |
| 512 | − interrupt = get_interrupt_data(dev, irq, info); | |
| 513 | − if (IS_ERR(interrupt)) | |
| 514 | − return PTR_ERR(interrupt); | |
| 515 | − else if (!interrupt) | |
| 516 | − continue; | |
| 531 | + interrupt->component = component; | |
| 517 | 532 | |
| 518 | − ret = sdca_irq_data_populate(dev, NULL, component, | |
| 519 | − function, entity, control, | |
| 520 | − interrupt); | |
| 533 | + switch (SDCA_CTL_TYPE(entity->type, control->sel)) { | |
| 534 | + case SDCA_CTL_TYPE_S(GE, DETECTED_MODE): | |
| 535 | + ret = sdca_jack_init_state(interrupt); | |
| 521 | 536 | if (ret) |
| 522 | 537 | return ret; |
| 538 | + break; | |
| 539 | + default: | |
| 540 | + break; | |
| 541 | + } | |
| 523 | 542 | |
| 524 | − handler = base_handler; | |
| 525 | − | |
| 526 | − switch (SDCA_CTL_TYPE(entity->type, control->sel)) { | |
| 527 | − case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_STATUS): | |
| 528 | − handler = function_status_handler; | |
| 529 | − break; | |
| 530 | − case SDCA_CTL_TYPE_S(GE, DETECTED_MODE): | |
| 531 | − ret = sdca_jack_alloc_state(interrupt); | |
| 532 | − if (ret) | |
| 533 | − return ret; | |
| 534 | − | |
| 535 | − handler = detected_mode_handler; | |
| 536 | − break; | |
| 537 | − case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER): | |
| 538 | − ret = sdca_fdl_alloc_state(interrupt); | |
| 539 | − if (ret) | |
| 540 | − return ret; | |
| 541 | − | |
| 542 | − handler = fdl_owner_handler; | |
| 543 | − break; | |
| 544 | − case SDCA_CTL_TYPE_S(HIDE, HIDTX_CURRENTOWNER): | |
| 545 | − handler = hid_handler; | |
| 546 | − break; | |
| 547 | − default: | |
| 548 | − break; | |
| 549 | − } | |
| 550 | − | |
| 551 | − ret = sdca_irq_request_locked(dev, info, irq, interrupt->name, | |
| 552 | − handler, interrupt); | |
| 553 | − if (ret) { | |
| 554 | − dev_err(dev, "failed to request irq %s: %d\n", | |
| 555 | − interrupt->name, ret); | |
| 556 | − return ret; | |
| 557 | − } | |
| 543 | + irq = interrupt->control->interrupt_position; | |
| 544 | + ret = sdca_irq_request_locked(dev, info, irq, interrupt->name, | |
| 545 | + interrupt->handler, interrupt); | |
| 546 | + if (ret) { | |
| 547 | + dev_err(dev, "failed to request irq %s: %d\n", | |
| 548 | + interrupt->name, ret); | |
| 549 | + return ret; | |
| 558 | 550 | } |
| 559 | 551 | } |
| 560 | 552 | |
| @@ -562,17 +554,10 @@ int sdca_irq_populate(struct sdca_function_data *function, · 1 unmodified line | ||
| 562 | 554 | } |
| 563 | 555 | EXPORT_SYMBOL_NS_GPL(sdca_irq_populate, "SND_SOC_SDCA"); |
| 564 | 556 | |
| 565 | −/** | |
| 566 | − * sdca_irq_cleanup - Free all the individual IRQs for an SDCA Function | |
| 567 | − * @dev: Device pointer against which the sdca_interrupt_info was allocated. | |
| 568 | − * @function: Pointer to the SDCA Function. | |
| 569 | − * @info: Pointer to the SDCA interrupt info for this device. | |
| 570 | − * | |
| 571 | − * Typically this would be called from the driver for a single SDCA Function. | |
| 572 | − */ | |
| 573 | −void sdca_irq_cleanup(struct device *dev, | |
| 574 | − struct sdca_function_data *function, | |
| 575 | − struct sdca_interrupt_info *info) | |
| 557 | +static void sdca_irq_cleanup_flags(struct device *dev, | |
| 558 | + struct sdca_function_data *function, | |
| 559 | + struct sdca_interrupt_info *info, | |
| 560 | + bool late_cleanup) | |
| 576 | 561 | { |
| 577 | 562 | int i; |
| 578 | 563 | |
| @@ -581,18 +566,59 @@ void sdca_irq_cleanup(struct device *dev, · 2 unmodified lines | ||
| 581 | 566 | for (i = 0; i < SDCA_MAX_INTERRUPTS; i++) { |
| 582 | 567 | struct sdca_interrupt *interrupt = &info->irqs[i]; |
| 583 | 568 | |
| 584 | − if (interrupt->function != function || !interrupt->irq) | |
| 569 | + if (interrupt->function != function || | |
| 570 | + (interrupt->early_request && !late_cleanup)) | |
| 571 | + continue; | |
| 572 | + | |
| 573 | + if (interrupt->irq) | |
| 574 | + sdca_irq_free_locked(dev, info, i, interrupt->name, interrupt); | |
| 575 | + | |
| 576 | + if (!late_cleanup) | |
| 585 | 577 | continue; |
| 586 | 578 | |
| 587 | − sdca_irq_free_locked(dev, info, i, interrupt->name, interrupt); | |
| 579 | + if (interrupt->free_priv) | |
| 580 | + interrupt->free_priv(interrupt); | |
| 588 | 581 | |
| 589 | 582 | kfree(interrupt->name); |
| 590 | 583 | } |
| 591 | 584 | } |
| 585 | + | |
| 586 | +/** | |
| 587 | + * sdca_irq_cleanup - Free the regular IRQs for an SDCA Function | |
| 588 | + * @dev: Device pointer against which the sdca_interrupt_info was allocated. | |
| 589 | + * @function: Pointer to the SDCA Function. | |
| 590 | + * @info: Pointer to the SDCA interrupt info for this device. | |
| 591 | + * | |
| 592 | + * Typically this would be called from the driver for a single SDCA Function | |
| 593 | + * from component remove. | |
| 594 | + */ | |
| 595 | +void sdca_irq_cleanup(struct device *dev, | |
| 596 | + struct sdca_function_data *function, | |
| 597 | + struct sdca_interrupt_info *info) | |
| 598 | +{ | |
| 599 | + sdca_irq_cleanup_flags(dev, function, info, false); | |
| 600 | +} | |
| 592 | 601 | EXPORT_SYMBOL_NS_GPL(sdca_irq_cleanup, "SND_SOC_SDCA"); |
| 593 | 602 | |
| 594 | 603 | /** |
| 595 | − * sdca_irq_allocate - allocate an SDCA interrupt structure for a device | |
| 604 | + * sdca_irq_cleanup_late - Free the early IRQs for an SDCA Function | |
| 605 | + * @dev: Device pointer against which the sdca_interrupt_info was allocated. | |
| 606 | + * @function: Pointer to the SDCA Function. | |
| 607 | + * @info: Pointer to the SDCA interrupt info for this device. | |
| 608 | + * | |
| 609 | + * Typically this would be called from the driver for a single SDCA Function | |
| 610 | + * from bus remove. | |
| 611 | + */ | |
| 612 | +void sdca_irq_cleanup_late(struct device *dev, | |
| 613 | + struct sdca_function_data *function, | |
| 614 | + struct sdca_interrupt_info *info) | |
| 615 | +{ | |
| 616 | + sdca_irq_cleanup_flags(dev, function, info, true); | |
| 617 | +} | |
| 618 | +EXPORT_SYMBOL_NS_GPL(sdca_irq_cleanup_late, "SND_SOC_SDCA"); | |
| 619 | + | |
| 620 | +/** | |
| 621 | + * devm_sdca_irq_allocate - allocate an SDCA interrupt structure for a device | |
| 596 | 622 | * @sdev: Device pointer against which things should be allocated. |
| 597 | 623 | * @regmap: regmap to be used for accessing the SDCA IRQ registers. |
| 598 | 624 | * @irq: The interrupt number. |
| @@ -604,8 +630,8 @@ EXPORT_SYMBOL_NS_GPL(sdca_irq_cleanup, "SND_SOC_SDCA"); · 5 unmodified lines | ||
| 604 | 630 | * Return: A pointer to the allocated sdca_interrupt_info struct, or an |
| 605 | 631 | * error code. |
| 606 | 632 | */ |
| 607 | −struct sdca_interrupt_info *sdca_irq_allocate(struct device *sdev, | |
| 608 | − struct regmap *regmap, int irq) | |
| 633 | +struct sdca_interrupt_info *devm_sdca_irq_allocate(struct device *sdev, | |
| 634 | + struct regmap *regmap, int irq) | |
| 609 | 635 | { |
| 610 | 636 | struct sdca_interrupt_info *info; |
| 611 | 637 | int ret, i; |
| @@ -634,7 +660,7 @@ struct sdca_interrupt_info *sdca_irq_allocate(struct device *sdev, · 22 unmodified lines | ||
| 634 | 660 | |
| 635 | 661 | return info; |
| 636 | 662 | } |
| 637 | −EXPORT_SYMBOL_NS_GPL(sdca_irq_allocate, "SND_SOC_SDCA"); | |
| 663 | +EXPORT_SYMBOL_NS_GPL(devm_sdca_irq_allocate, "SND_SOC_SDCA"); | |
| 638 | 664 | |
| 639 | 665 | static void irq_enable_flags(struct sdca_function_data *function, |
| 640 | 666 | struct sdca_interrupt_info *info, bool early) |
| @@ -41,26 +41,12 @@ int sdca_jack_process(struct sdca_interrupt *interrupt) · 40 unmodified lines | ||
| 41 | 41 | struct jack_state *state = interrupt->priv; |
| 42 | 42 | struct snd_kcontrol *kctl = state->kctl; |
| 43 | 43 | struct snd_ctl_elem_value *ucontrol __free(kfree) = NULL; |
| 44 | + struct soc_enum *soc_enum; | |
| 44 | 45 | unsigned int reg, val; |
| 45 | 46 | int ret; |
| 46 | 47 | |
| 47 | 48 | guard(rwsem_write)(rwsem); |
| 48 | 49 | |
| 49 | − if (!kctl) { | |
| 50 | − const char *name __free(kfree) = kasprintf(GFP_KERNEL, "%s %s", | |
| 51 | − interrupt->entity->label, | |
| 52 | − SDCA_CTL_SELECTED_MODE_NAME); | |
| 53 | − | |
| 54 | − if (!name) | |
| 55 | − return -ENOMEM; | |
| 56 | − | |
| 57 | − kctl = snd_soc_component_get_kcontrol(component, name); | |
| 58 | − if (!kctl) | |
| 59 | − dev_dbg(dev, "control not found: %s\n", name); | |
| 60 | − else | |
| 61 | − state->kctl = kctl; | |
| 62 | − } | |
| 63 | − | |
| 64 | 50 | reg = SDW_SDCA_CTL(interrupt->function->desc->adr, interrupt->entity->id, |
| 65 | 51 | interrupt->control->sel, 0); |
| 66 | 52 | |
| @@ -96,30 +82,21 @@ int sdca_jack_process(struct sdca_interrupt *interrupt) · 29 unmodified lines | ||
| 96 | 82 | |
| 97 | 83 | dev_dbg(dev, "%s: %#x\n", interrupt->name, val); |
| 98 | 84 | |
| 99 | − if (kctl) { | |
| 100 | − struct soc_enum *soc_enum = (struct soc_enum *)kctl->private_value; | |
| 101 | − | |
| 102 | − ucontrol = kzalloc_obj(*ucontrol); | |
| 103 | − if (!ucontrol) | |
| 104 | − return -ENOMEM; | |
| 85 | + ucontrol = kzalloc_obj(*ucontrol); | |
| 86 | + if (!ucontrol) | |
| 87 | + return -ENOMEM; | |
| 105 | 88 | |
| 106 | − ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(soc_enum, val); | |
| 89 | + soc_enum = (struct soc_enum *)kctl->private_value; | |
| 90 | + ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(soc_enum, val); | |
| 107 | 91 | |
| 108 | − ret = snd_soc_dapm_put_enum_double(kctl, ucontrol); | |
| 109 | − if (ret < 0) { | |
| 110 | − dev_err(dev, "failed to update selected mode: %d\n", ret); | |
| 111 | − return ret; | |
| 112 | − } | |
| 113 | − | |
| 114 | − snd_ctl_notify(card->snd_card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); | |
| 115 | − } else { | |
| 116 | − ret = regmap_write(interrupt->function_regmap, reg, val); | |
| 117 | − if (ret) { | |
| 118 | − dev_err(dev, "failed to write selected mode: %d\n", ret); | |
| 119 | − return ret; | |
| 120 | − } | |
| 92 | + ret = snd_soc_dapm_put_enum_double(kctl, ucontrol); | |
| 93 | + if (ret < 0) { | |
| 94 | + dev_err(dev, "failed to update selected mode: %d\n", ret); | |
| 95 | + return ret; | |
| 121 | 96 | } |
| 122 | 97 | |
| 98 | + snd_ctl_notify(card->snd_card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); | |
| 99 | + | |
| 123 | 100 | return sdca_jack_report(interrupt); |
| 124 | 101 | } |
| 125 | 102 | EXPORT_SYMBOL_NS_GPL(sdca_jack_process, "SND_SOC_SDCA"); |
| @@ -132,10 +109,9 @@ EXPORT_SYMBOL_NS_GPL(sdca_jack_process, "SND_SOC_SDCA"); · 6 unmodified lines | ||
| 132 | 109 | */ |
| 133 | 110 | int sdca_jack_alloc_state(struct sdca_interrupt *interrupt) |
| 134 | 111 | { |
| 135 | − struct device *dev = interrupt->dev; | |
| 136 | 112 | struct jack_state *jack_state; |
| 137 | 113 | |
| 138 | − jack_state = devm_kzalloc(dev, sizeof(*jack_state), GFP_KERNEL); | |
| 114 | + jack_state = kzalloc_obj(*jack_state); | |
| 139 | 115 | if (!jack_state) |
| 140 | 116 | return -ENOMEM; |
| 141 | 117 | |
| @@ -145,6 +121,42 @@ int sdca_jack_alloc_state(struct sdca_interrupt *interrupt) · 3 unmodified lines | ||
| 145 | 121 | } |
| 146 | 122 | EXPORT_SYMBOL_NS_GPL(sdca_jack_alloc_state, "SND_SOC_SDCA"); |
| 147 | 123 | |
| 124 | +/** | |
| 125 | + * sdca_jack_free_state - free state for a jack interrupt | |
| 126 | + * @interrupt: SDCA interrupt structure. | |
| 127 | + */ | |
| 128 | +void sdca_jack_free_state(struct sdca_interrupt *interrupt) | |
| 129 | +{ | |
| 130 | + kfree(interrupt->priv); | |
| 131 | +} | |
| 132 | +EXPORT_SYMBOL_NS_GPL(sdca_jack_free_state, "SND_SOC_SDCA"); | |
| 133 | + | |
| 134 | +/** | |
| 135 | + * sdca_jack_init_state - Initialise transient state for a jack interrupt | |
| 136 | + * @interrupt: SDCA interrupt structure. | |
| 137 | + * | |
| 138 | + * Return: Zero on success or a negative error code. | |
| 139 | + */ | |
| 140 | +int sdca_jack_init_state(struct sdca_interrupt *interrupt) | |
| 141 | +{ | |
| 142 | + struct jack_state *jack_state = interrupt->priv; | |
| 143 | + const char *name __free(kfree) = kasprintf(GFP_KERNEL, "%s %s", | |
| 144 | + interrupt->entity->label, | |
| 145 | + SDCA_CTL_SELECTED_MODE_NAME); | |
| 146 | + | |
| 147 | + if (!name) | |
| 148 | + return -ENOMEM; | |
| 149 | + | |
| 150 | + jack_state->kctl = snd_soc_component_get_kcontrol(interrupt->component, name); | |
| 151 | + if (!jack_state->kctl) { | |
| 152 | + dev_err(interrupt->dev, "control not found: %s\n", name); | |
| 153 | + return -ENODEV; | |
| 154 | + } | |
| 155 | + | |
| 156 | + return 0; | |
| 157 | +} | |
| 158 | +EXPORT_SYMBOL_NS_GPL(sdca_jack_init_state, "SND_SOC_SDCA"); | |
| 159 | + | |
| 148 | 160 | static int type_get_mask(enum sdca_terminal_type type) |
| 149 | 161 | { |
| 150 | 162 | switch (type) { |
| @@ -192,7 +204,7 @@ int sdca_jack_set_jack(struct sdca_interrupt_info *info, struct snd_soc_jack *ja · 41 unmodified lines | ||
| 192 | 204 | struct sdca_control_range *range; |
| 193 | 205 | struct jack_state *jack_state; |
| 194 | 206 | |
| 195 | − if (!interrupt->irq) | |
| 207 | + if (!interrupt->dev) | |
| 196 | 208 | continue; |
| 197 | 209 | |
| 198 | 210 | switch (SDCA_CTL_TYPE(entity->type, control->sel)) { |
| @@ -141,7 +141,7 @@ int sdca_ump_read_message(struct device *dev, · 140 unmodified lines | ||
| 141 | 141 | return ret; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | − if (msg_len > buf_len - msg_offset) { | |
| 144 | + if (msg_offset + msg_len > buf_len) { | |
| 145 | 145 | dev_err(dev, "%s: message too big for UMP buffer: %d\n", |
| 146 | 146 | entity->label, msg_len); |
| 147 | 147 | return -EINVAL; |
| @@ -207,7 +207,7 @@ int sdca_ump_write_message(struct device *dev, · 59 unmodified lines | ||
| 207 | 207 | buf_len = sdca_range(range, SDCA_MESSAGEOFFSET_BUFFER_LENGTH, 0); |
| 208 | 208 | ump_mode = sdca_range(range, SDCA_MESSAGEOFFSET_UMP_MODE, 0); |
| 209 | 209 | |
| 210 | − if (msg_len > buf_len - msg_offset) { | |
| 210 | + if (msg_offset + msg_len > buf_len) { | |
| 211 | 211 | dev_err(dev, "%s: message too big for UMP buffer: %d\n", |
| 212 | 212 | entity->label, msg_len); |
| 213 | 213 | return -EINVAL; |
| @@ -310,6 +310,16 @@ int snd_soc_component_probe(struct snd_soc_component *component) · 309 unmodified lines | ||
| 310 | 310 | return soc_component_ret(component, ret); |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | +int snd_soc_component_fixup_controls(struct snd_soc_component *component) | |
| 314 | +{ | |
| 315 | + int ret = 0; | |
| 316 | + | |
| 317 | + if (component->driver->fixup_controls) | |
| 318 | + ret = component->driver->fixup_controls(component); | |
| 319 | + | |
| 320 | + return soc_component_ret(component, ret); | |
| 321 | +} | |
| 322 | + | |
| 313 | 323 | void snd_soc_component_remove(struct snd_soc_component *component) |
| 314 | 324 | { |
| 315 | 325 | if (component->driver->remove) |
| @@ -2162,6 +2162,11 @@ static int snd_soc_bind_card(struct snd_soc_card *card) · 2161 unmodified lines | ||
| 2162 | 2162 | goto probe_end; |
| 2163 | 2163 | |
| 2164 | 2164 | snd_soc_dapm_new_widgets(card); |
| 2165 | + for_each_card_components(card, component) { | |
| 2166 | + ret = snd_soc_component_fixup_controls(component); | |
| 2167 | + if (ret < 0) | |
| 2168 | + goto probe_end; | |
| 2169 | + } | |
| 2165 | 2170 | snd_soc_card_fixup_controls(card); |
| 2166 | 2171 | |
| 2167 | 2172 | ret = snd_card_register(card->snd_card); |
| @@ -251,16 +251,22 @@ static int cv1800b_adc_volume_set(struct snd_kcontrol *kcontrol, · 250 unmodified lines | ||
| 251 | 251 | |
| 252 | 252 | u32 v_left = clamp_t(u32, ucontrol->value.integer.value[0], 0, 24); |
| 253 | 253 | u32 v_right = clamp_t(u32, ucontrol->value.integer.value[1], 0, 24); |
| 254 | − u32 val; | |
| 254 | + u32 val, old_val; | |
| 255 | 255 | |
| 256 | 256 | val = readl(priv->regs + CV1800B_RXADC_ANA0); |
| 257 | + old_val = val; | |
| 258 | + | |
| 257 | 259 | val = u32_replace_bits(val, cv1800b_gains[v_left], |
| 258 | 260 | REG_COMB_LEFT_VOLUME); |
| 259 | 261 | val = u32_replace_bits(val, cv1800b_gains[v_right], |
| 260 | 262 | REG_COMB_RIGHT_VOLUME); |
| 263 | + | |
| 264 | + if (val == old_val) | |
| 265 | + return 0; | |
| 266 | + | |
| 261 | 267 | writel(val, priv->regs + CV1800B_RXADC_ANA0); |
| 262 | 268 | |
| 263 | − return 0; | |
| 269 | + return 1; | |
| 264 | 270 | } |
| 265 | 271 | |
| 266 | 272 | static DECLARE_TLV_DB_SCALE(cv1800b_volume_tlv, 0, 200, 0); |
| @@ -2256,6 +2256,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { · 2255 unmodified lines | ||
| 2256 | 2256 | DEVICE_FLG(0x046d, 0x0a8f, /* Logitech H390 headset */ |
| 2257 | 2257 | QUIRK_FLAG_CTL_MSG_DELAY_1M | |
| 2258 | 2258 | QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE), |
| 2259 | + DEVICE_FLG(0x046d, 0x0af7, /* Logitech PRO X 2 LIGHTSPEED */ | |
| 2260 | + QUIRK_FLAG_MIXER_GET_CUR_BROKEN), | |
| 2259 | 2261 | DEVICE_FLG(0x0499, 0x1506, /* Yamaha THR5 */ |
| 2260 | 2262 | QUIRK_FLAG_GENERIC_IMPLICIT_FB), |
| 2261 | 2263 | DEVICE_FLG(0x0499, 0x1509, /* Steinberg UR22 */ |
| @@ -444,6 +444,7 @@ struct kvm_s390_vm_cpu_machine { · 443 unmodified lines | ||
| 444 | 444 | #define KVM_S390_VM_CPU_FEAT_PFMFI 11 |
| 445 | 445 | #define KVM_S390_VM_CPU_FEAT_SIGPIF 12 |
| 446 | 446 | #define KVM_S390_VM_CPU_FEAT_KSS 13 |
| 447 | +#define KVM_S390_VM_CPU_FEAT_ASTFLEIE2 14 | |
| 447 | 448 | struct kvm_s390_vm_cpu_feat { |
| 448 | 449 | __u64 feat[16]; |
| 449 | 450 | }; |
| @@ -379,6 +379,7 @@ · 378 unmodified lines | ||
| 379 | 379 | #define X86_FEATURE_AVIC (15*32+13) /* "avic" Virtual Interrupt Controller */ |
| 380 | 380 | #define X86_FEATURE_V_VMSAVE_VMLOAD (15*32+15) /* "v_vmsave_vmload" Virtual VMSAVE VMLOAD */ |
| 381 | 381 | #define X86_FEATURE_VGIF (15*32+16) /* "vgif" Virtual GIF */ |
| 382 | +#define X86_FEATURE_GMET (15*32+17) /* Guest Mode Execution Trap */ | |
| 382 | 383 | #define X86_FEATURE_X2AVIC (15*32+18) /* "x2avic" Virtual x2apic */ |
| 383 | 384 | #define X86_FEATURE_V_SPEC_CTRL (15*32+20) /* "v_spec_ctrl" Virtual SPEC_CTRL */ |
| 384 | 385 | #define X86_FEATURE_VNMI (15*32+25) /* "vnmi" Virtual NMI */ |
| @@ -473,6 +474,7 @@ · 88 unmodified lines | ||
| 473 | 474 | #define X86_FEATURE_GP_ON_USER_CPUID (20*32+17) /* User CPUID faulting */ |
| 474 | 475 | |
| 475 | 476 | #define X86_FEATURE_PREFETCHI (20*32+20) /* Prefetch Data/Instruction to Cache Level */ |
| 477 | +#define X86_FEATURE_AVX512_BMM (20*32+23) /* AVX512 Bit Matrix Multiply instructions */ | |
| 476 | 478 | #define X86_FEATURE_ERAPS (20*32+24) /* Enhanced Return Address Predictor Security */ |
| 477 | 479 | #define X86_FEATURE_SBPB (20*32+27) /* Selective Branch Prediction Barrier */ |
| 478 | 480 | #define X86_FEATURE_IBPB_BRTYPE (20*32+28) /* MSR_PRED_CMD[IBPB] flushes all branch type predictions */ |
| @@ -572,4 +574,5 @@ · 93 unmodified lines | ||
| 572 | 574 | #define X86_BUG_ITS_NATIVE_ONLY X86_BUG( 1*32+ 8) /* "its_native_only" CPU is affected by ITS, VMX is not affected */ |
| 573 | 575 | #define X86_BUG_TSA X86_BUG( 1*32+ 9) /* "tsa" CPU is affected by Transient Scheduler Attacks */ |
| 574 | 576 | #define X86_BUG_VMSCAPE X86_BUG( 1*32+10) /* "vmscape" CPU is affected by VMSCAPE attacks from guests */ |
| 577 | +#define X86_BUG_SEAMRET_INVD_VMCS X86_BUG( 1*32+11) /* "seamret_invd_vmcs" SEAMRET from P-SEAMLDR clears the current VMCS */ | |
| 575 | 578 | #endif /* _ASM_X86_CPUFEATURES_H */ |
| @@ -674,6 +674,9 @@ · 673 unmodified lines | ||
| 674 | 674 | #define MSR_AMD64_DC_CFG 0xc0011022 |
| 675 | 675 | #define MSR_AMD64_TW_CFG 0xc0011023 |
| 676 | 676 | |
| 677 | +#define MSR_AMD64_FP_CFG 0xc0011028 | |
| 678 | +#define MSR_AMD64_FP_CFG_ZEN1_DENORM_FIX_BIT 9 | |
| 679 | + | |
| 677 | 680 | #define MSR_AMD64_DE_CFG 0xc0011029 |
| 678 | 681 | #define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT 1 |
| 679 | 682 | #define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE BIT_ULL(MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT) |
| @@ -698,6 +701,8 @@ · 18 unmodified lines | ||
| 698 | 701 | #define MSR_AMD64_IBSBRTARGET 0xc001103b |
| 699 | 702 | #define MSR_AMD64_ICIBSEXTDCTL 0xc001103c |
| 700 | 703 | #define MSR_AMD64_IBSOPDATA4 0xc001103d |
| 704 | +#define MSR_AMD64_IBSOPCTL2 0xc001103e | |
| 705 | +#define MSR_AMD64_IBSFETCHCTL2 0xc001103f | |
| 701 | 706 | #define MSR_AMD64_IBS_REG_COUNT_MAX 8 /* includes MSR_AMD64_IBSBRTARGET */ |
| 702 | 707 | #define MSR_AMD64_SVM_AVIC_DOORBELL 0xc001011b |
| 703 | 708 | #define MSR_AMD64_VM_PAGE_FLUSH 0xc001011e |
| @@ -765,12 +770,14 @@ · 61 unmodified lines | ||
| 765 | 770 | #define MSR_AMD_CPPC_CAP2 0xc00102b2 |
| 766 | 771 | #define MSR_AMD_CPPC_REQ 0xc00102b3 |
| 767 | 772 | #define MSR_AMD_CPPC_STATUS 0xc00102b4 |
| 773 | +#define MSR_AMD_CPPC_REQ2 0xc00102b5 | |
| 768 | 774 | |
| 769 | 775 | /* Masks for use with MSR_AMD_CPPC_CAP1 */ |
| 770 | 776 | #define AMD_CPPC_LOWEST_PERF_MASK GENMASK(7, 0) |
| 771 | 777 | #define AMD_CPPC_LOWNONLIN_PERF_MASK GENMASK(15, 8) |
| 772 | 778 | #define AMD_CPPC_NOMINAL_PERF_MASK GENMASK(23, 16) |
| 773 | 779 | #define AMD_CPPC_HIGHEST_PERF_MASK GENMASK(31, 24) |
| 780 | +#define AMD_CPPC_FLOOR_PERF_CNT_MASK GENMASK_ULL(39, 32) | |
| 774 | 781 | |
| 775 | 782 | /* Masks for use with MSR_AMD_CPPC_REQ */ |
| 776 | 783 | #define AMD_CPPC_MAX_PERF_MASK GENMASK(7, 0) |
| @@ -778,6 +785,9 @@ · 1 unmodified line | ||
| 778 | 785 | #define AMD_CPPC_DES_PERF_MASK GENMASK(23, 16) |
| 779 | 786 | #define AMD_CPPC_EPP_PERF_MASK GENMASK(31, 24) |
| 780 | 787 | |
| 788 | +/* Masks for use with MSR_AMD_CPPC_REQ2 */ | |
| 789 | +#define AMD_CPPC_FLOOR_PERF_MASK GENMASK(7, 0) | |
| 790 | + | |
| 781 | 791 | /* AMD Performance Counter Global Status and Control MSRs */ |
| 782 | 792 | #define MSR_AMD64_PERF_CNTR_GLOBAL_STATUS 0xc0000300 |
| 783 | 793 | #define MSR_AMD64_PERF_CNTR_GLOBAL_CTL 0xc0000301 |
| @@ -889,6 +899,7 @@ · 105 unmodified lines | ||
| 889 | 899 | #define MSR_K7_HWCR_IRPERF_EN_BIT 30 |
| 890 | 900 | #define MSR_K7_HWCR_IRPERF_EN BIT_ULL(MSR_K7_HWCR_IRPERF_EN_BIT) |
| 891 | 901 | #define MSR_K7_HWCR_CPUID_USER_DIS_BIT 35 |
| 902 | +#define MSR_K7_HWCR_CPUID_USER_DIS BIT_ULL(MSR_K7_HWCR_CPUID_USER_DIS_BIT) | |
| 892 | 903 | #define MSR_K7_FID_VID_CTL 0xc0010041 |
| 893 | 904 | #define MSR_K7_FID_VID_STATUS 0xc0010042 |
| 894 | 905 | #define MSR_K7_HWCR_CPB_DIS_BIT 25 |
| @@ -197,13 +197,13 @@ struct kvm_msrs { · 196 unmodified lines | ||
| 197 | 197 | __u32 nmsrs; /* number of msrs in entries */ |
| 198 | 198 | __u32 pad; |
| 199 | 199 | |
| 200 | − struct kvm_msr_entry entries[]; | |
| 200 | + __DECLARE_FLEX_ARRAY(struct kvm_msr_entry, entries); | |
| 201 | 201 | }; |
| 202 | 202 | |
| 203 | 203 | /* for KVM_GET_MSR_INDEX_LIST */ |
| 204 | 204 | struct kvm_msr_list { |
| 205 | 205 | __u32 nmsrs; /* number of msrs in entries */ |
| 206 | − __u32 indices[]; | |
| 206 | + __DECLARE_FLEX_ARRAY(__u32, indices); | |
| 207 | 207 | }; |
| 208 | 208 | |
| 209 | 209 | /* Maximum size of any access bitmap in bytes */ |
| @@ -245,7 +245,7 @@ struct kvm_cpuid_entry { · 35 unmodified lines | ||
| 245 | 245 | struct kvm_cpuid { |
| 246 | 246 | __u32 nent; |
| 247 | 247 | __u32 padding; |
| 248 | − struct kvm_cpuid_entry entries[]; | |
| 248 | + __DECLARE_FLEX_ARRAY(struct kvm_cpuid_entry, entries); | |
| 249 | 249 | }; |
| 250 | 250 | |
| 251 | 251 | struct kvm_cpuid_entry2 { |
| @@ -267,7 +267,7 @@ struct kvm_cpuid_entry2 { · 15 unmodified lines | ||
| 267 | 267 | struct kvm_cpuid2 { |
| 268 | 268 | __u32 nent; |
| 269 | 269 | __u32 padding; |
| 270 | − struct kvm_cpuid_entry2 entries[]; | |
| 270 | + __DECLARE_FLEX_ARRAY(struct kvm_cpuid_entry2, entries); | |
| 271 | 271 | }; |
| 272 | 272 | |
| 273 | 273 | /* for KVM_GET_PIT and KVM_SET_PIT */ |
| @@ -398,7 +398,7 @@ struct kvm_xsave { · 124 unmodified lines | ||
| 398 | 398 | * the contents of CPUID leaf 0xD on the host. |
| 399 | 399 | */ |
| 400 | 400 | __u32 region[1024]; |
| 401 | − __u32 extra[]; | |
| 401 | + __DECLARE_FLEX_ARRAY(__u32, extra); | |
| 402 | 402 | }; |
| 403 | 403 | |
| 404 | 404 | #define KVM_MAX_XCRS 16 |
| @@ -477,6 +477,7 @@ struct kvm_sync_regs { · 72 unmodified lines | ||
| 477 | 477 | #define KVM_X86_QUIRK_STUFF_FEATURE_MSRS (1 << 8) |
| 478 | 478 | #define KVM_X86_QUIRK_IGNORE_GUEST_PAT (1 << 9) |
| 479 | 479 | #define KVM_X86_QUIRK_VMCS12_ALLOW_FREEZE_IN_SMM (1 << 10) |
| 480 | +#define KVM_X86_QUIRK_NESTED_SVM_SHARED_PAT (1 << 11) | |
| 480 | 481 | |
| 481 | 482 | #define KVM_STATE_NESTED_FORMAT_VMX 0 |
| 482 | 483 | #define KVM_STATE_NESTED_FORMAT_SVM 1 |
| @@ -532,6 +533,7 @@ struct kvm_svm_nested_state_data { · 49 unmodified lines | ||
| 532 | 533 | |
| 533 | 534 | struct kvm_svm_nested_state_hdr { |
| 534 | 535 | __u64 vmcb_pa; |
| 536 | + __u64 gpat; | |
| 535 | 537 | }; |
| 536 | 538 | |
| 537 | 539 | /* for KVM_CAP_NESTED_STATE */ |
| @@ -566,7 +568,7 @@ struct kvm_pmu_event_filter { · 28 unmodified lines | ||
| 566 | 568 | __u32 fixed_counter_bitmap; |
| 567 | 569 | __u32 flags; |
| 568 | 570 | __u32 pad[4]; |
| 569 | − __u64 events[]; | |
| 571 | + __DECLARE_FLEX_ARRAY(__u64, events); | |
| 570 | 572 | }; |
| 571 | 573 | |
| 572 | 574 | #define KVM_PMU_EVENT_ALLOW 0 |
| @@ -103,38 +103,38 @@ · 102 unmodified lines | ||
| 103 | 103 | #define SVM_EXIT_VMGEXIT 0x403 |
| 104 | 104 | |
| 105 | 105 | /* SEV-ES software-defined VMGEXIT events */ |
| 106 | −#define SVM_VMGEXIT_MMIO_READ 0x80000001 | |
| 107 | −#define SVM_VMGEXIT_MMIO_WRITE 0x80000002 | |
| 108 | −#define SVM_VMGEXIT_NMI_COMPLETE 0x80000003 | |
| 109 | −#define SVM_VMGEXIT_AP_HLT_LOOP 0x80000004 | |
| 110 | −#define SVM_VMGEXIT_AP_JUMP_TABLE 0x80000005 | |
| 106 | +#define SVM_VMGEXIT_MMIO_READ 0x80000001ull | |
| 107 | +#define SVM_VMGEXIT_MMIO_WRITE 0x80000002ull | |
| 108 | +#define SVM_VMGEXIT_NMI_COMPLETE 0x80000003ull | |
| 109 | +#define SVM_VMGEXIT_AP_HLT_LOOP 0x80000004ull | |
| 110 | +#define SVM_VMGEXIT_AP_JUMP_TABLE 0x80000005ull | |
| 111 | 111 | #define SVM_VMGEXIT_SET_AP_JUMP_TABLE 0 |
| 112 | 112 | #define SVM_VMGEXIT_GET_AP_JUMP_TABLE 1 |
| 113 | −#define SVM_VMGEXIT_PSC 0x80000010 | |
| 114 | −#define SVM_VMGEXIT_GUEST_REQUEST 0x80000011 | |
| 115 | −#define SVM_VMGEXIT_EXT_GUEST_REQUEST 0x80000012 | |
| 116 | −#define SVM_VMGEXIT_AP_CREATION 0x80000013 | |
| 113 | +#define SVM_VMGEXIT_PSC 0x80000010ull | |
| 114 | +#define SVM_VMGEXIT_GUEST_REQUEST 0x80000011ull | |
| 115 | +#define SVM_VMGEXIT_EXT_GUEST_REQUEST 0x80000012ull | |
| 116 | +#define SVM_VMGEXIT_AP_CREATION 0x80000013ull | |
| 117 | 117 | #define SVM_VMGEXIT_AP_CREATE_ON_INIT 0 |
| 118 | 118 | #define SVM_VMGEXIT_AP_CREATE 1 |
| 119 | 119 | #define SVM_VMGEXIT_AP_DESTROY 2 |
| 120 | −#define SVM_VMGEXIT_SNP_RUN_VMPL 0x80000018 | |
| 121 | −#define SVM_VMGEXIT_SAVIC 0x8000001a | |
| 120 | +#define SVM_VMGEXIT_SNP_RUN_VMPL 0x80000018ull | |
| 121 | +#define SVM_VMGEXIT_SAVIC 0x8000001aull | |
| 122 | 122 | #define SVM_VMGEXIT_SAVIC_REGISTER_GPA 0 |
| 123 | 123 | #define SVM_VMGEXIT_SAVIC_UNREGISTER_GPA 1 |
| 124 | 124 | #define SVM_VMGEXIT_SAVIC_SELF_GPA ~0ULL |
| 125 | −#define SVM_VMGEXIT_HV_FEATURES 0x8000fffd | |
| 126 | −#define SVM_VMGEXIT_TERM_REQUEST 0x8000fffe | |
| 125 | +#define SVM_VMGEXIT_HV_FEATURES 0x8000fffdull | |
| 126 | +#define SVM_VMGEXIT_TERM_REQUEST 0x8000fffeull | |
| 127 | 127 | #define SVM_VMGEXIT_TERM_REASON(reason_set, reason_code) \ |
| 128 | 128 | /* SW_EXITINFO1[3:0] */ \ |
| 129 | 129 | (((((u64)reason_set) & 0xf)) | \ |
| 130 | 130 | /* SW_EXITINFO1[11:4] */ \ |
| 131 | 131 | ((((u64)reason_code) & 0xff) << 4)) |
| 132 | −#define SVM_VMGEXIT_UNSUPPORTED_EVENT 0x8000ffff | |
| 132 | +#define SVM_VMGEXIT_UNSUPPORTED_EVENT 0x8000ffffull | |
| 133 | 133 | |
| 134 | 134 | /* Exit code reserved for hypervisor/software use */ |
| 135 | −#define SVM_EXIT_SW 0xf0000000 | |
| 135 | +#define SVM_EXIT_SW 0xf0000000ull | |
| 136 | 136 | |
| 137 | −#define SVM_EXIT_ERR -1 | |
| 137 | +#define SVM_EXIT_ERR -1ull | |
| 138 | 138 | |
| 139 | 139 | #define SVM_EXIT_REASONS \ |
| 140 | 140 | { SVM_EXIT_READ_CR0, "read_cr0" }, \ |
| @@ -273,17 +273,17 @@ enum { · 272 unmodified lines | ||
| 273 | 273 | * |
| 274 | 274 | * %__GFP_ZERO returns a zeroed page on success. |
| 275 | 275 | * |
| 276 | − * %__GFP_ZEROTAGS zeroes memory tags at allocation time if the memory itself | |
| 277 | − * is being zeroed (either via __GFP_ZERO or via init_on_alloc, provided that | |
| 278 | − * __GFP_SKIP_ZERO is not set). This flag is intended for optimization: setting | |
| 279 | − * memory tags at the same time as zeroing memory has minimal additional | |
| 280 | − * performance impact. | |
| 276 | + * %__GFP_ZEROTAGS zeroes memory tags at allocation time. Setting memory tags at | |
| 277 | + * the same time as zeroing memory (e.g., with __GFP_ZERO) has minimal | |
| 278 | + * additional performance impact. However, __GFP_ZEROTAGS also zeroes the tags | |
| 279 | + * even if memory is not getting zeroed at allocation time (e.g., | |
| 280 | + * with init_on_free). | |
| 281 | 281 | * |
| 282 | 282 | * %__GFP_SKIP_KASAN makes KASAN skip unpoisoning on page allocation. |
| 283 | 283 | * Used for userspace and vmalloc pages; the latter are unpoisoned by |
| 284 | − * kasan_unpoison_vmalloc instead. For userspace pages, results in | |
| 285 | − * poisoning being skipped as well, see should_skip_kasan_poison for | |
| 286 | − * details. Only effective in HW_TAGS mode. | |
| 284 | + * kasan_unpoison_vmalloc instead. If passed to vmalloc, kasan_unpoison_vmalloc | |
| 285 | + * is skipped too. For userspace pages, results in poisoning being skipped as | |
| 286 | + * well, see should_skip_kasan_poison for details. Only effective in HW_TAGS mode. | |
| 287 | 287 | */ |
| 288 | 288 | #define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN) |
| 289 | 289 | #define __GFP_COMP ((__force gfp_t)___GFP_COMP) |
| @@ -50,4 +50,22 @@ · 49 unmodified lines | ||
| 50 | 50 | |
| 51 | 51 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) |
| 52 | 52 | |
| 53 | +/* | |
| 54 | + * Divide positive or negative dividend by positive or negative divisor | |
| 55 | + * and round to closest integer. Result is undefined for negative | |
| 56 | + * divisors if the dividend variable type is unsigned and for negative | |
| 57 | + * dividends if the divisor variable type is unsigned. | |
| 58 | + */ | |
| 59 | +#define __KERNEL_DIV_ROUND_CLOSEST(x, divisor) \ | |
| 60 | +({ \ | |
| 61 | + __typeof__(x) __x = x; \ | |
| 62 | + __typeof__(divisor) __d = divisor; \ | |
| 63 | + \ | |
| 64 | + (((__typeof__(x))-1) > 0 || \ | |
| 65 | + ((__typeof__(divisor))-1) > 0 || \ | |
| 66 | + (((__x) > 0) == ((__d) > 0))) ? \ | |
| 67 | + (((__x) + ((__d) / 2)) / (__d)) : \ | |
| 68 | + (((__x) - ((__d) / 2)) / (__d)); \ | |
| 69 | +}) | |
| 70 | + | |
| 53 | 71 | #endif /* _UAPI_LINUX_CONST_H */ |
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | #include <linux/const.h> |
| 12 | 12 | #include <linux/types.h> |
| 13 | 13 | #include <linux/compiler.h> |
| 14 | +#include <linux/stddef.h> | |
| 14 | 15 | #include <linux/ioctl.h> |
| 15 | 16 | #include <asm/kvm.h> |
| 16 | 17 | |
| @@ -542,7 +543,7 @@ struct kvm_coalesced_mmio { · 525 unmodified lines | ||
| 542 | 543 | |
| 543 | 544 | struct kvm_coalesced_mmio_ring { |
| 544 | 545 | __u32 first, last; |
| 545 | − struct kvm_coalesced_mmio coalesced_mmio[]; | |
| 546 | + __DECLARE_FLEX_ARRAY(struct kvm_coalesced_mmio, coalesced_mmio); | |
| 546 | 547 | }; |
| 547 | 548 | |
| 548 | 549 | #define KVM_COALESCED_MMIO_MAX \ |
| @@ -592,7 +593,7 @@ struct kvm_clear_dirty_log { · 43 unmodified lines | ||
| 592 | 593 | /* for KVM_SET_SIGNAL_MASK */ |
| 593 | 594 | struct kvm_signal_mask { |
| 594 | 595 | __u32 len; |
| 595 | − __u8 sigset[]; | |
| 596 | + __DECLARE_FLEX_ARRAY(__u8, sigset); | |
| 596 | 597 | }; |
| 597 | 598 | |
| 598 | 599 | /* for KVM_TPR_ACCESS_REPORTING */ |
| @@ -703,6 +704,11 @@ struct kvm_enable_cap { · 104 unmodified lines | ||
| 703 | 704 | #define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL |
| 704 | 705 | #define KVM_VM_TYPE_ARM_IPA_SIZE(x) \ |
| 705 | 706 | ((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK) |
| 707 | + | |
| 708 | +#define KVM_VM_TYPE_ARM_PROTECTED (1UL << 31) | |
| 709 | +#define KVM_VM_TYPE_ARM_MASK (KVM_VM_TYPE_ARM_IPA_SIZE_MASK | \ | |
| 710 | + KVM_VM_TYPE_ARM_PROTECTED) | |
| 711 | + | |
| 706 | 712 | /* |
| 707 | 713 | * ioctls for /dev/kvm fds: |
| 708 | 714 | */ |
| @@ -989,6 +995,8 @@ struct kvm_enable_cap { · 280 unmodified lines | ||
| 989 | 995 | #define KVM_CAP_ARM_SEA_TO_USER 245 |
| 990 | 996 | #define KVM_CAP_S390_USER_OPEREXEC 246 |
| 991 | 997 | #define KVM_CAP_S390_KEYOP 247 |
| 998 | +#define KVM_CAP_S390_VSIE_ESAMODE 248 | |
| 999 | +#define KVM_CAP_S390_HPAGE_2G 249 | |
| 992 | 1000 | |
| 993 | 1001 | struct kvm_irq_routing_irqchip { |
| 994 | 1002 | __u32 irqchip; |
| @@ -1051,7 +1059,7 @@ struct kvm_irq_routing_entry { · 56 unmodified lines | ||
| 1051 | 1059 | struct kvm_irq_routing { |
| 1052 | 1060 | __u32 nr; |
| 1053 | 1061 | __u32 flags; |
| 1054 | − struct kvm_irq_routing_entry entries[]; | |
| 1062 | + __DECLARE_FLEX_ARRAY(struct kvm_irq_routing_entry, entries); | |
| 1055 | 1063 | }; |
| 1056 | 1064 | |
| 1057 | 1065 | #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0) |
| @@ -1142,7 +1150,7 @@ struct kvm_dirty_tlb { · 84 unmodified lines | ||
| 1142 | 1150 | |
| 1143 | 1151 | struct kvm_reg_list { |
| 1144 | 1152 | __u64 n; /* number of regs */ |
| 1145 | − __u64 reg[]; | |
| 1153 | + __DECLARE_FLEX_ARRAY(__u64, reg); | |
| 1146 | 1154 | }; |
| 1147 | 1155 | |
| 1148 | 1156 | struct kvm_one_reg { |
| @@ -1224,6 +1232,8 @@ enum kvm_device_type { · 75 unmodified lines | ||
| 1224 | 1232 | #define KVM_DEV_TYPE_LOONGARCH_EIOINTC KVM_DEV_TYPE_LOONGARCH_EIOINTC |
| 1225 | 1233 | KVM_DEV_TYPE_LOONGARCH_PCHPIC, |
| 1226 | 1234 | #define KVM_DEV_TYPE_LOONGARCH_PCHPIC KVM_DEV_TYPE_LOONGARCH_PCHPIC |
| 1235 | + KVM_DEV_TYPE_LOONGARCH_DMSINTC, | |
| 1236 | +#define KVM_DEV_TYPE_LOONGARCH_DMSINTC KVM_DEV_TYPE_LOONGARCH_DMSINTC | |
| 1227 | 1237 | KVM_DEV_TYPE_ARM_VGIC_V5, |
| 1228 | 1238 | #define KVM_DEV_TYPE_ARM_VGIC_V5 KVM_DEV_TYPE_ARM_VGIC_V5 |
| 1229 | 1239 | |
| @@ -1610,7 +1620,7 @@ struct kvm_stats_desc { · 380 unmodified lines | ||
| 1610 | 1620 | #ifdef __KERNEL__ |
| 1611 | 1621 | char name[KVM_STATS_NAME_SIZE]; |
| 1612 | 1622 | #else |
| 1613 | − char name[]; | |
| 1623 | + __DECLARE_FLEX_ARRAY(char, name); | |
| 1614 | 1624 | #endif |
| 1615 | 1625 | }; |
| 1616 | 1626 | |
| @@ -840,6 +840,7 @@ enum { · 839 unmodified lines | ||
| 840 | 840 | #define RTEXT_FILTER_CFM_CONFIG (1 << 5) |
| 841 | 841 | #define RTEXT_FILTER_CFM_STATUS (1 << 6) |
| 842 | 842 | #define RTEXT_FILTER_MST (1 << 7) |
| 843 | +#define RTEXT_FILTER_NAME_ONLY (1 << 8) | |
| 843 | 844 | |
| 844 | 845 | /* End of information exported to user level */ |
| 845 | 846 | |
| @@ -206,6 +206,7 @@ static bool is_rust_noreturn(const struct symbol *func) · 205 unmodified lines | ||
| 206 | 206 | str_ends_with(func->name, "_4core9panicking18panic_nounwind_fmt") || |
| 207 | 207 | str_ends_with(func->name, "_4core9panicking19assert_failed_inner") || |
| 208 | 208 | str_ends_with(func->name, "_4core9panicking30panic_null_pointer_dereference") || |
| 209 | + str_ends_with(func->name, "_4core9panicking32panic_null_reference_constructed") || | |
| 209 | 210 | str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference") || |
| 210 | 211 | str_ends_with(func->name, "_7___rustc17rust_begin_unwind") || |
| 211 | 212 | strstr(func->name, "_4core9panicking13assert_failed") || |
| @@ -0,0 +1,4 @@ | ||
| 1 | +# SPDX-License-Identifier: GPL-2.0-only | |
| 2 | +.tmp | |
| 3 | +*.skel.h | |
| 4 | +vmlinux.h | |
| @@ -356,7 +356,7 @@ struct ucred { · 355 unmodified lines | ||
| 356 | 356 | |
| 357 | 357 | /* Flags to be cleared on entry by sendmsg and sendmmsg syscalls */ |
| 358 | 358 | #define MSG_INTERNAL_SENDMSG_FLAGS \ |
| 359 | − (MSG_SPLICE_PAGES | MSG_SENDPAGE_NOPOLICY | MSG_SENDPAGE_DECRYPTED) | |
| 359 | + (MSG_SPLICE_PAGES | MSG_SENDPAGE_NOPOLICY | MSG_SENDPAGE_DECRYPTED | MSG_NO_SHARED_FRAGS) | |
| 360 | 360 | |
| 361 | 361 | /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ |
| 362 | 362 | #define SOL_IP 0 |
| @@ -1,3 +1,4 @@ | ||
| 1 | +/* SPDX-License-Identifier: MIT */ | |
| 1 | 2 | /* |
| 2 | 3 | * Header for the Direct Rendering Manager |
| 3 | 4 | * |
| @@ -11,25 +12,6 @@ · 7 unmodified lines | ||
| 11 | 12 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
| 12 | 13 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
| 13 | 14 | * All rights reserved. |
| 14 | − * | |
| 15 | − * Permission is hereby granted, free of charge, to any person obtaining a | |
| 16 | − * copy of this software and associated documentation files (the "Software"), | |
| 17 | − * to deal in the Software without restriction, including without limitation | |
| 18 | − * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
| 19 | − * and/or sell copies of the Software, and to permit persons to whom the | |
| 20 | − * Software is furnished to do so, subject to the following conditions: | |
| 21 | − * | |
| 22 | − * The above copyright notice and this permission notice (including the next | |
| 23 | − * paragraph) shall be included in all copies or substantial portions of the | |
| 24 | − * Software. | |
| 25 | − * | |
| 26 | − * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 27 | − * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 28 | − * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
| 29 | − * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
| 30 | − * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
| 31 | − * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
| 32 | − * OTHER DEALINGS IN THE SOFTWARE. | |
| 33 | 15 | */ |
| 34 | 16 | |
| 35 | 17 | #ifndef _DRM_H_ |
| @@ -1323,6 +1305,13 @@ extern "C" { · 1287 unmodified lines | ||
| 1323 | 1305 | */ |
| 1324 | 1306 | #define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xCE, struct drm_mode_fb_cmd2) |
| 1325 | 1307 | |
| 1308 | +/** | |
| 1309 | + * DRM_IOCTL_SYNCOBJ_EVENTFD - Register an eventfd to be signalled by a syncobj. | |
| 1310 | + * | |
| 1311 | + * This can be used to integrate a syncobj in an event loop. | |
| 1312 | + * | |
| 1313 | + * The IOCTL argument is a struct drm_syncobj_eventfd. | |
| 1314 | + */ | |
| 1326 | 1315 | #define DRM_IOCTL_SYNCOBJ_EVENTFD DRM_IOWR(0xCF, struct drm_syncobj_eventfd) |
| 1327 | 1316 | |
| 1328 | 1317 | /** |
| @@ -395,7 +395,16 @@ struct file_attr { · 394 unmodified lines | ||
| 395 | 395 | #define FS_DAX_FL 0x02000000 /* Inode is DAX */ |
| 396 | 396 | #define FS_INLINE_DATA_FL 0x10000000 /* Reserved for ext4 */ |
| 397 | 397 | #define FS_PROJINHERIT_FL 0x20000000 /* Create with parents projid */ |
| 398 | −#define FS_CASEFOLD_FL 0x40000000 /* Folder is case insensitive */ | |
| 398 | +/* | |
| 399 | + * FS_CASEFOLD_FL indicates case-insensitive name lookup. The | |
| 400 | + * bit is most often reported on directories, where it controls | |
| 401 | + * lookups of entries within. Filesystems that derive | |
| 402 | + * case-insensitivity from mount or volume state may also report | |
| 403 | + * it on non-directory inodes; userspace must not assume the bit | |
| 404 | + * is directory-only. FS_XFLAG_CASEFOLD reports the same | |
| 405 | + * information read-only via FS_IOC_FSGETXATTR. | |
| 406 | + */ | |
| 407 | +#define FS_CASEFOLD_FL 0x40000000 | |
| 399 | 408 | #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ |
| 400 | 409 | |
| 401 | 410 | #define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */ |
| @@ -82,6 +82,7 @@ CONFIG_NET_SCH_BPF=y · 81 unmodified lines | ||
| 82 | 82 | CONFIG_NET_SCH_FQ=y |
| 83 | 83 | CONFIG_NET_SCH_INGRESS=y |
| 84 | 84 | CONFIG_NET_SCH_HTB=y |
| 85 | +CONFIG_NET_SCH_RED=y | |
| 85 | 86 | CONFIG_NET_SCHED=y |
| 86 | 87 | CONFIG_NETDEVSIM=y |
| 87 | 88 | CONFIG_NETFILTER=y |
| @@ -0,0 +1,113 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | + | |
| 3 | +#include <test_progs.h> | |
| 4 | +#include <network_helpers.h> | |
| 5 | +#include <sys/socket.h> | |
| 6 | +#include <netinet/in.h> | |
| 7 | +#include <arpa/inet.h> | |
| 8 | +#include <unistd.h> | |
| 9 | +#include <string.h> | |
| 10 | + | |
| 11 | +#include "test_tc_qevent.skel.h" | |
| 12 | + | |
| 13 | +#define NS_TX "tc_qevent_tx" | |
| 14 | +#define NS_RX "tc_qevent_rx" | |
| 15 | +#define IP_TX "10.255.0.1" | |
| 16 | +#define IP_RX "10.255.0.2" | |
| 17 | +#define PIN_PATH "/sys/fs/bpf/tc_qevent_redirect" | |
| 18 | + | |
| 19 | +static void blast_udp(void) | |
| 20 | +{ | |
| 21 | + struct sockaddr_in dst = {}; | |
| 22 | + char buf[1400] = {}; | |
| 23 | + int fd, i; | |
| 24 | + | |
| 25 | + fd = socket(AF_INET, SOCK_DGRAM, 0); | |
| 26 | + if (!ASSERT_GE(fd, 0, "udp socket")) | |
| 27 | + return; | |
| 28 | + | |
| 29 | + dst.sin_family = AF_INET; | |
| 30 | + dst.sin_port = htons(12345); | |
| 31 | + inet_pton(AF_INET, IP_RX, &dst.sin_addr); | |
| 32 | + | |
| 33 | + /* | |
| 34 | + * Push far more than the RED queue can hold. Once qavg crosses qth_min | |
| 35 | + * every further packet hits the congestion_drop / early_drop qevent. | |
| 36 | + */ | |
| 37 | + for (i = 0; i < 50000; i++) | |
| 38 | + sendto(fd, buf, sizeof(buf), MSG_DONTWAIT, | |
| 39 | + (struct sockaddr *)&dst, sizeof(dst)); | |
| 40 | + | |
| 41 | + close(fd); | |
| 42 | +} | |
| 43 | + | |
| 44 | +static void run_qevent_redirect(struct bpf_program *prog, __u64 *counter) | |
| 45 | +{ | |
| 46 | + struct nstoken *tok = NULL; | |
| 47 | + int err; | |
| 48 | + | |
| 49 | + SYS_NOFAIL("ip netns del %s", NS_TX); | |
| 50 | + SYS_NOFAIL("ip netns del %s", NS_RX); | |
| 51 | + unlink(PIN_PATH); | |
| 52 | + | |
| 53 | + err = bpf_program__pin(prog, PIN_PATH); | |
| 54 | + if (!ASSERT_OK(err, "pin prog")) | |
| 55 | + return; | |
| 56 | + | |
| 57 | + SYS(unpin, "ip netns add %s", NS_TX); | |
| 58 | + SYS(del_tx, "ip netns add %s", NS_RX); | |
| 59 | + SYS(del_rx, "ip -n %s link add veth0 type veth peer name veth1 netns %s", NS_TX, NS_RX); | |
| 60 | + SYS(del_rx, "ip -n %s addr add %s/24 dev veth0", NS_TX, IP_TX); | |
| 61 | + SYS(del_rx, "ip -n %s link set veth0 up", NS_TX); | |
| 62 | + SYS(del_rx, "ip -n %s addr add %s/24 dev veth1", NS_RX, IP_RX); | |
| 63 | + SYS(del_rx, "ip -n %s link set veth1 up", NS_RX); | |
| 64 | + | |
| 65 | + tok = open_netns(NS_TX); | |
| 66 | + if (!ASSERT_OK_PTR(tok, "open_netns")) | |
| 67 | + goto del_rx; | |
| 68 | + | |
| 69 | + SYS(close_ns, "tc qdisc add dev veth0 root handle 1: htb default 1"); | |
| 70 | + SYS(close_ns, "tc class add dev veth0 parent 1: classid 1:1 htb rate 1mbit ceil 1mbit"); | |
| 71 | + | |
| 72 | + if (system("tc qdisc add dev veth0 parent 1:1 handle 11: red " | |
| 73 | + "limit 500000 avpkt 1000 probability 1 min 5000 max 6000 " | |
| 74 | + "burst 6 qevent early_drop block 10 2>/dev/null")) { | |
| 75 | + test__skip(); | |
| 76 | + goto close_ns; | |
| 77 | + } | |
| 78 | + | |
| 79 | + if (system("tc filter add block 10 bpf da object-pinned " | |
| 80 | + PIN_PATH " 2>/dev/null")) { | |
| 81 | + test__skip(); | |
| 82 | + goto close_ns; | |
| 83 | + } | |
| 84 | + | |
| 85 | + blast_udp(); | |
| 86 | + ASSERT_GT(*counter, 0, "qevent classifier ran"); | |
| 87 | +close_ns: | |
| 88 | + close_netns(tok); | |
| 89 | +del_rx: | |
| 90 | + SYS_NOFAIL("ip netns del %s", NS_RX); | |
| 91 | +del_tx: | |
| 92 | + SYS_NOFAIL("ip netns del %s", NS_TX); | |
| 93 | +unpin: | |
| 94 | + bpf_program__unpin(prog, PIN_PATH); | |
| 95 | +} | |
| 96 | + | |
| 97 | +void test_tc_qevent(void) | |
| 98 | +{ | |
| 99 | + struct test_tc_qevent *skel; | |
| 100 | + | |
| 101 | + skel = test_tc_qevent__open_and_load(); | |
| 102 | + if (!ASSERT_OK_PTR(skel, "open_and_load")) | |
| 103 | + return; | |
| 104 | + | |
| 105 | + if (test__start_subtest("redirect_verdict")) | |
| 106 | + run_qevent_redirect(skel->progs.qevent_redirect_verdict, | |
| 107 | + &skel->bss->verdict_calls); | |
| 108 | + if (test__start_subtest("redirect_helper")) | |
| 109 | + run_qevent_redirect(skel->progs.qevent_redirect_helper, | |
| 110 | + &skel->bss->helper_calls); | |
| 111 | + | |
| 112 | + test_tc_qevent__destroy(skel); | |
| 113 | +} | |
| @@ -0,0 +1,23 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +#include "vmlinux.h" | |
| 3 | +#include <bpf/bpf_helpers.h> | |
| 4 | + | |
| 5 | +int redirect_ifindex = 1; | |
| 6 | +__u64 verdict_calls = 0; | |
| 7 | +__u64 helper_calls = 0; | |
| 8 | + | |
| 9 | +SEC("tc") | |
| 10 | +int qevent_redirect_verdict(struct __sk_buff *skb) | |
| 11 | +{ | |
| 12 | + __sync_fetch_and_add(&verdict_calls, 1); | |
| 13 | + return TCX_REDIRECT; | |
| 14 | +} | |
| 15 | + | |
| 16 | +SEC("tc") | |
| 17 | +int qevent_redirect_helper(struct __sk_buff *skb) | |
| 18 | +{ | |
| 19 | + __sync_fetch_and_add(&helper_calls, 1); | |
| 20 | + return bpf_redirect(redirect_ifindex, 0); | |
| 21 | +} | |
| 22 | + | |
| 23 | +char _license[] SEC("license") = "GPL"; | |
| @@ -185,6 +185,16 @@ int arg_tag_nonnull_ptr_good(void *ctx) · 184 unmodified lines | ||
| 185 | 185 | return subprog_nonnull_ptr_good(&x, &y); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | +SEC("?raw_tp") | |
| 189 | +__failure __log_level(2) | |
| 190 | +__msg("R1 is expected to be non-NULL") | |
| 191 | +int arg_tag_nonnull_ptr_null_bad(void *ctx) | |
| 192 | +{ | |
| 193 | + int y = 74; | |
| 194 | + | |
| 195 | + return subprog_nonnull_ptr_good(NULL, &y); | |
| 196 | +} | |
| 197 | + | |
| 188 | 198 | /* this global subprog can be now called from many types of entry progs, each |
| 189 | 199 | * with different context type |
| 190 | 200 | */ |
| @@ -4,6 +4,8 @@ CONFIG_DEBUG_INFO_BTF_MODULES=n · 3 unmodified lines | ||
| 4 | 4 | CONFIG_INET_PSP=y |
| 5 | 5 | CONFIG_IPV6=y |
| 6 | 6 | CONFIG_MACSEC=m |
| 7 | +CONFIG_NET_CLS_ACT=y | |
| 8 | +CONFIG_NET_CLS_BPF=y | |
| 7 | 9 | CONFIG_NETCONSOLE=m |
| 8 | 10 | CONFIG_NETCONSOLE_DYNAMIC=y |
| 9 | 11 | CONFIG_NETCONSOLE_EXTENDED_LOG=y |
| @@ -11,6 +13,7 @@ CONFIG_NETDEVSIM=m · 1 unmodified line | ||
7 more lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 17 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 2 lines aren’t shown here.
This diff is large: its 3 lines aren’t shown here.
This diff is large: its 21 lines aren’t shown here.
This diff is large: its 348 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 24 lines aren’t shown here.
This diff is large: its 16 lines aren’t shown here.
This diff is large: its 5 lines aren’t shown here.
This diff is large: its 37 lines aren’t shown here.
This diff is large: its 9 lines aren’t shown here.
This diff is large: its 17 lines aren’t shown here.
This diff is large: its 13 lines aren’t shown here.
This diff is large: its 18 lines aren’t shown here.
This diff is large: its 2 lines aren’t shown here.
This diff is large: its 62 lines aren’t shown here.
This diff is large: its 24 lines aren’t shown here.
This diff is large: its 8 lines aren’t shown here.
This diff is large: its 101 lines aren’t shown here.