Contents of /trunk/kernel-alx/patches-5.4/0170-5.4.71-all-fixes.patch
Parent Directory | Revision Log
Revision 3635 -
(show annotations)
(download)
Mon Oct 24 12:34:12 2022 UTC (20 months ago) by niro
File size: 110470 byte(s)
Mon Oct 24 12:34:12 2022 UTC (20 months ago) by niro
File size: 110470 byte(s)
-sync kernel patches
1 | diff --git a/Makefile b/Makefile |
2 | index e409fd909560f..f342e64c8c1d1 100644 |
3 | --- a/Makefile |
4 | +++ b/Makefile |
5 | @@ -1,7 +1,7 @@ |
6 | # SPDX-License-Identifier: GPL-2.0 |
7 | VERSION = 5 |
8 | PATCHLEVEL = 4 |
9 | -SUBLEVEL = 70 |
10 | +SUBLEVEL = 71 |
11 | EXTRAVERSION = |
12 | NAME = Kleptomaniac Octopus |
13 | |
14 | diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts b/arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts |
15 | index 66e4ffb4e929d..2c8c2b322c727 100644 |
16 | --- a/arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts |
17 | +++ b/arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts |
18 | @@ -155,6 +155,7 @@ |
19 | }; |
20 | |
21 | &qspi { |
22 | + status = "okay"; |
23 | flash@0 { |
24 | #address-cells = <1>; |
25 | #size-cells = <1>; |
26 | diff --git a/drivers/base/dd.c b/drivers/base/dd.c |
27 | index 1d5dd37f3abe4..84e757860ebb9 100644 |
28 | --- a/drivers/base/dd.c |
29 | +++ b/drivers/base/dd.c |
30 | @@ -518,7 +518,8 @@ static int really_probe(struct device *dev, struct device_driver *drv) |
31 | drv->bus->name, __func__, drv->name, dev_name(dev)); |
32 | if (!list_empty(&dev->devres_head)) { |
33 | dev_crit(dev, "Resources present before probing\n"); |
34 | - return -EBUSY; |
35 | + ret = -EBUSY; |
36 | + goto done; |
37 | } |
38 | |
39 | re_probe: |
40 | @@ -639,7 +640,7 @@ pinctrl_bind_failed: |
41 | ret = 0; |
42 | done: |
43 | atomic_dec(&probe_count); |
44 | - wake_up(&probe_waitqueue); |
45 | + wake_up_all(&probe_waitqueue); |
46 | return ret; |
47 | } |
48 | |
49 | diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c |
50 | index f15ded1ce9057..c6a1dfe79e809 100644 |
51 | --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c |
52 | +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c |
53 | @@ -967,6 +967,7 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm) |
54 | |
55 | release_sg: |
56 | kfree(ttm->sg); |
57 | + ttm->sg = NULL; |
58 | return r; |
59 | } |
60 | |
61 | diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c |
62 | index c002f89685073..9682f30ab6f68 100644 |
63 | --- a/drivers/gpu/drm/nouveau/nouveau_mem.c |
64 | +++ b/drivers/gpu/drm/nouveau/nouveau_mem.c |
65 | @@ -176,6 +176,8 @@ void |
66 | nouveau_mem_del(struct ttm_mem_reg *reg) |
67 | { |
68 | struct nouveau_mem *mem = nouveau_mem(reg); |
69 | + if (!mem) |
70 | + return; |
71 | nouveau_mem_fini(mem); |
72 | kfree(reg->mm_node); |
73 | reg->mm_node = NULL; |
74 | diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c |
75 | index 9a80c3c7e8af2..c40eef4e7a985 100644 |
76 | --- a/drivers/i2c/busses/i2c-i801.c |
77 | +++ b/drivers/i2c/busses/i2c-i801.c |
78 | @@ -1891,6 +1891,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) |
79 | |
80 | pci_set_drvdata(dev, priv); |
81 | |
82 | + dev_pm_set_driver_flags(&dev->dev, DPM_FLAG_NEVER_SKIP); |
83 | pm_runtime_set_autosuspend_delay(&dev->dev, 1000); |
84 | pm_runtime_use_autosuspend(&dev->dev); |
85 | pm_runtime_put_autosuspend(&dev->dev); |
86 | diff --git a/drivers/i2c/busses/i2c-meson.c b/drivers/i2c/busses/i2c-meson.c |
87 | index 1e2647f9a2a72..6661481f125cd 100644 |
88 | --- a/drivers/i2c/busses/i2c-meson.c |
89 | +++ b/drivers/i2c/busses/i2c-meson.c |
90 | @@ -5,6 +5,7 @@ |
91 | * Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com> |
92 | */ |
93 | |
94 | +#include <linux/bitfield.h> |
95 | #include <linux/clk.h> |
96 | #include <linux/completion.h> |
97 | #include <linux/i2c.h> |
98 | @@ -32,12 +33,17 @@ |
99 | #define REG_CTRL_ACK_IGNORE BIT(1) |
100 | #define REG_CTRL_STATUS BIT(2) |
101 | #define REG_CTRL_ERROR BIT(3) |
102 | -#define REG_CTRL_CLKDIV_SHIFT 12 |
103 | -#define REG_CTRL_CLKDIV_MASK GENMASK(21, 12) |
104 | -#define REG_CTRL_CLKDIVEXT_SHIFT 28 |
105 | -#define REG_CTRL_CLKDIVEXT_MASK GENMASK(29, 28) |
106 | +#define REG_CTRL_CLKDIV GENMASK(21, 12) |
107 | +#define REG_CTRL_CLKDIVEXT GENMASK(29, 28) |
108 | + |
109 | +#define REG_SLV_ADDR GENMASK(7, 0) |
110 | +#define REG_SLV_SDA_FILTER GENMASK(10, 8) |
111 | +#define REG_SLV_SCL_FILTER GENMASK(13, 11) |
112 | +#define REG_SLV_SCL_LOW GENMASK(27, 16) |
113 | +#define REG_SLV_SCL_LOW_EN BIT(28) |
114 | |
115 | #define I2C_TIMEOUT_MS 500 |
116 | +#define FILTER_DELAY 15 |
117 | |
118 | enum { |
119 | TOKEN_END = 0, |
120 | @@ -132,19 +138,24 @@ static void meson_i2c_set_clk_div(struct meson_i2c *i2c, unsigned int freq) |
121 | unsigned long clk_rate = clk_get_rate(i2c->clk); |
122 | unsigned int div; |
123 | |
124 | - div = DIV_ROUND_UP(clk_rate, freq * i2c->data->div_factor); |
125 | + div = DIV_ROUND_UP(clk_rate, freq); |
126 | + div -= FILTER_DELAY; |
127 | + div = DIV_ROUND_UP(div, i2c->data->div_factor); |
128 | |
129 | /* clock divider has 12 bits */ |
130 | - if (div >= (1 << 12)) { |
131 | + if (div > GENMASK(11, 0)) { |
132 | dev_err(i2c->dev, "requested bus frequency too low\n"); |
133 | - div = (1 << 12) - 1; |
134 | + div = GENMASK(11, 0); |
135 | } |
136 | |
137 | - meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_CLKDIV_MASK, |
138 | - (div & GENMASK(9, 0)) << REG_CTRL_CLKDIV_SHIFT); |
139 | + meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_CLKDIV, |
140 | + FIELD_PREP(REG_CTRL_CLKDIV, div & GENMASK(9, 0))); |
141 | + |
142 | + meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_CLKDIVEXT, |
143 | + FIELD_PREP(REG_CTRL_CLKDIVEXT, div >> 10)); |
144 | |
145 | - meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_CLKDIVEXT_MASK, |
146 | - (div >> 10) << REG_CTRL_CLKDIVEXT_SHIFT); |
147 | + /* Disable HIGH/LOW mode */ |
148 | + meson_i2c_set_mask(i2c, REG_SLAVE_ADDR, REG_SLV_SCL_LOW_EN, 0); |
149 | |
150 | dev_dbg(i2c->dev, "%s: clk %lu, freq %u, div %u\n", __func__, |
151 | clk_rate, freq, div); |
152 | @@ -273,7 +284,10 @@ static void meson_i2c_do_start(struct meson_i2c *i2c, struct i2c_msg *msg) |
153 | token = (msg->flags & I2C_M_RD) ? TOKEN_SLAVE_ADDR_READ : |
154 | TOKEN_SLAVE_ADDR_WRITE; |
155 | |
156 | - writel(msg->addr << 1, i2c->regs + REG_SLAVE_ADDR); |
157 | + |
158 | + meson_i2c_set_mask(i2c, REG_SLAVE_ADDR, REG_SLV_ADDR, |
159 | + FIELD_PREP(REG_SLV_ADDR, msg->addr << 1)); |
160 | + |
161 | meson_i2c_add_token(i2c, TOKEN_START); |
162 | meson_i2c_add_token(i2c, token); |
163 | } |
164 | @@ -432,6 +446,10 @@ static int meson_i2c_probe(struct platform_device *pdev) |
165 | return ret; |
166 | } |
167 | |
168 | + /* Disable filtering */ |
169 | + meson_i2c_set_mask(i2c, REG_SLAVE_ADDR, |
170 | + REG_SLV_SDA_FILTER | REG_SLV_SCL_FILTER, 0); |
171 | + |
172 | meson_i2c_set_clk_div(i2c, timings.bus_freq_hz); |
173 | |
174 | return 0; |
175 | diff --git a/drivers/i2c/busses/i2c-owl.c b/drivers/i2c/busses/i2c-owl.c |
176 | index b6b5a495118b6..a567fd2b295e1 100644 |
177 | --- a/drivers/i2c/busses/i2c-owl.c |
178 | +++ b/drivers/i2c/busses/i2c-owl.c |
179 | @@ -179,6 +179,9 @@ static irqreturn_t owl_i2c_interrupt(int irq, void *_dev) |
180 | fifostat = readl(i2c_dev->base + OWL_I2C_REG_FIFOSTAT); |
181 | if (fifostat & OWL_I2C_FIFOSTAT_RNB) { |
182 | i2c_dev->err = -ENXIO; |
183 | + /* Clear NACK error bit by writing "1" */ |
184 | + owl_i2c_update_reg(i2c_dev->base + OWL_I2C_REG_FIFOSTAT, |
185 | + OWL_I2C_FIFOSTAT_RNB, true); |
186 | goto stop; |
187 | } |
188 | |
189 | @@ -186,6 +189,9 @@ static irqreturn_t owl_i2c_interrupt(int irq, void *_dev) |
190 | stat = readl(i2c_dev->base + OWL_I2C_REG_STAT); |
191 | if (stat & OWL_I2C_STAT_BEB) { |
192 | i2c_dev->err = -EIO; |
193 | + /* Clear BUS error bit by writing "1" */ |
194 | + owl_i2c_update_reg(i2c_dev->base + OWL_I2C_REG_STAT, |
195 | + OWL_I2C_STAT_BEB, true); |
196 | goto stop; |
197 | } |
198 | |
199 | diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c |
200 | index 305f0160506a0..8a36d78fed63a 100644 |
201 | --- a/drivers/input/misc/ati_remote2.c |
202 | +++ b/drivers/input/misc/ati_remote2.c |
203 | @@ -68,7 +68,7 @@ static int ati_remote2_get_channel_mask(char *buffer, |
204 | { |
205 | pr_debug("%s()\n", __func__); |
206 | |
207 | - return sprintf(buffer, "0x%04x", *(unsigned int *)kp->arg); |
208 | + return sprintf(buffer, "0x%04x\n", *(unsigned int *)kp->arg); |
209 | } |
210 | |
211 | static int ati_remote2_set_mode_mask(const char *val, |
212 | @@ -84,7 +84,7 @@ static int ati_remote2_get_mode_mask(char *buffer, |
213 | { |
214 | pr_debug("%s()\n", __func__); |
215 | |
216 | - return sprintf(buffer, "0x%02x", *(unsigned int *)kp->arg); |
217 | + return sprintf(buffer, "0x%02x\n", *(unsigned int *)kp->arg); |
218 | } |
219 | |
220 | static unsigned int channel_mask = ATI_REMOTE2_MAX_CHANNEL_MASK; |
221 | diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c |
222 | index 2ffec65df3889..1147626f0d253 100644 |
223 | --- a/drivers/iommu/intel-iommu.c |
224 | +++ b/drivers/iommu/intel-iommu.c |
225 | @@ -2560,14 +2560,14 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu, |
226 | } |
227 | |
228 | /* Setup the PASID entry for requests without PASID: */ |
229 | - spin_lock(&iommu->lock); |
230 | + spin_lock_irqsave(&iommu->lock, flags); |
231 | if (hw_pass_through && domain_type_is_si(domain)) |
232 | ret = intel_pasid_setup_pass_through(iommu, domain, |
233 | dev, PASID_RID2PASID); |
234 | else |
235 | ret = intel_pasid_setup_second_level(iommu, domain, |
236 | dev, PASID_RID2PASID); |
237 | - spin_unlock(&iommu->lock); |
238 | + spin_unlock_irqrestore(&iommu->lock, flags); |
239 | if (ret) { |
240 | dev_err(dev, "Setup RID2PASID failed\n"); |
241 | dmar_remove_one_dev_info(dev); |
242 | diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c |
243 | index 9c0ccb3744c28..81b8d5ede484e 100644 |
244 | --- a/drivers/mmc/core/queue.c |
245 | +++ b/drivers/mmc/core/queue.c |
246 | @@ -184,7 +184,7 @@ static void mmc_queue_setup_discard(struct request_queue *q, |
247 | q->limits.discard_granularity = card->pref_erase << 9; |
248 | /* granularity must not be greater than max. discard */ |
249 | if (card->pref_erase > max_discard) |
250 | - q->limits.discard_granularity = 0; |
251 | + q->limits.discard_granularity = SECTOR_SIZE; |
252 | if (mmc_can_secure_erase_trim(card)) |
253 | blk_queue_flag_set(QUEUE_FLAG_SECERASE, q); |
254 | } |
255 | diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c |
256 | index 0d7a173f8e61c..6862c2ef24424 100644 |
257 | --- a/drivers/net/bonding/bond_main.c |
258 | +++ b/drivers/net/bonding/bond_main.c |
259 | @@ -1148,6 +1148,7 @@ static void bond_setup_by_slave(struct net_device *bond_dev, |
260 | |
261 | bond_dev->type = slave_dev->type; |
262 | bond_dev->hard_header_len = slave_dev->hard_header_len; |
263 | + bond_dev->needed_headroom = slave_dev->needed_headroom; |
264 | bond_dev->addr_len = slave_dev->addr_len; |
265 | |
266 | memcpy(bond_dev->broadcast, slave_dev->broadcast, |
267 | diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c |
268 | index d375e438d8054..4fa9d485e2096 100644 |
269 | --- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c |
270 | +++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c |
271 | @@ -1222,7 +1222,7 @@ static int octeon_mgmt_open(struct net_device *netdev) |
272 | */ |
273 | if (netdev->phydev) { |
274 | netif_carrier_off(netdev); |
275 | - phy_start_aneg(netdev->phydev); |
276 | + phy_start(netdev->phydev); |
277 | } |
278 | |
279 | netif_wake_queue(netdev); |
280 | @@ -1250,8 +1250,10 @@ static int octeon_mgmt_stop(struct net_device *netdev) |
281 | napi_disable(&p->napi); |
282 | netif_stop_queue(netdev); |
283 | |
284 | - if (netdev->phydev) |
285 | + if (netdev->phydev) { |
286 | + phy_stop(netdev->phydev); |
287 | phy_disconnect(netdev->phydev); |
288 | + } |
289 | |
290 | netif_carrier_off(netdev); |
291 | |
292 | diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c |
293 | index 222ae76809aa1..cd95d6af8fc1b 100644 |
294 | --- a/drivers/net/ethernet/intel/iavf/iavf_main.c |
295 | +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c |
296 | @@ -3773,7 +3773,6 @@ err_dma: |
297 | return err; |
298 | } |
299 | |
300 | -#ifdef CONFIG_PM |
301 | /** |
302 | * iavf_suspend - Power management suspend routine |
303 | * @pdev: PCI device information struct |
304 | @@ -3781,11 +3780,10 @@ err_dma: |
305 | * |
306 | * Called when the system (VM) is entering sleep/suspend. |
307 | **/ |
308 | -static int iavf_suspend(struct pci_dev *pdev, pm_message_t state) |
309 | +static int __maybe_unused iavf_suspend(struct device *dev_d) |
310 | { |
311 | - struct net_device *netdev = pci_get_drvdata(pdev); |
312 | + struct net_device *netdev = dev_get_drvdata(dev_d); |
313 | struct iavf_adapter *adapter = netdev_priv(netdev); |
314 | - int retval = 0; |
315 | |
316 | netif_device_detach(netdev); |
317 | |
318 | @@ -3803,12 +3801,6 @@ static int iavf_suspend(struct pci_dev *pdev, pm_message_t state) |
319 | |
320 | clear_bit(__IAVF_IN_CRITICAL_TASK, &adapter->crit_section); |
321 | |
322 | - retval = pci_save_state(pdev); |
323 | - if (retval) |
324 | - return retval; |
325 | - |
326 | - pci_disable_device(pdev); |
327 | - |
328 | return 0; |
329 | } |
330 | |
331 | @@ -3818,24 +3810,13 @@ static int iavf_suspend(struct pci_dev *pdev, pm_message_t state) |
332 | * |
333 | * Called when the system (VM) is resumed from sleep/suspend. |
334 | **/ |
335 | -static int iavf_resume(struct pci_dev *pdev) |
336 | +static int __maybe_unused iavf_resume(struct device *dev_d) |
337 | { |
338 | - struct iavf_adapter *adapter = pci_get_drvdata(pdev); |
339 | - struct net_device *netdev = adapter->netdev; |
340 | + struct pci_dev *pdev = to_pci_dev(dev_d); |
341 | + struct net_device *netdev = pci_get_drvdata(pdev); |
342 | + struct iavf_adapter *adapter = netdev_priv(netdev); |
343 | u32 err; |
344 | |
345 | - pci_set_power_state(pdev, PCI_D0); |
346 | - pci_restore_state(pdev); |
347 | - /* pci_restore_state clears dev->state_saved so call |
348 | - * pci_save_state to restore it. |
349 | - */ |
350 | - pci_save_state(pdev); |
351 | - |
352 | - err = pci_enable_device_mem(pdev); |
353 | - if (err) { |
354 | - dev_err(&pdev->dev, "Cannot enable PCI device from suspend.\n"); |
355 | - return err; |
356 | - } |
357 | pci_set_master(pdev); |
358 | |
359 | rtnl_lock(); |
360 | @@ -3859,7 +3840,6 @@ static int iavf_resume(struct pci_dev *pdev) |
361 | return err; |
362 | } |
363 | |
364 | -#endif /* CONFIG_PM */ |
365 | /** |
366 | * iavf_remove - Device Removal Routine |
367 | * @pdev: PCI device information struct |
368 | @@ -3961,16 +3941,15 @@ static void iavf_remove(struct pci_dev *pdev) |
369 | pci_disable_device(pdev); |
370 | } |
371 | |
372 | +static SIMPLE_DEV_PM_OPS(iavf_pm_ops, iavf_suspend, iavf_resume); |
373 | + |
374 | static struct pci_driver iavf_driver = { |
375 | - .name = iavf_driver_name, |
376 | - .id_table = iavf_pci_tbl, |
377 | - .probe = iavf_probe, |
378 | - .remove = iavf_remove, |
379 | -#ifdef CONFIG_PM |
380 | - .suspend = iavf_suspend, |
381 | - .resume = iavf_resume, |
382 | -#endif |
383 | - .shutdown = iavf_shutdown, |
384 | + .name = iavf_driver_name, |
385 | + .id_table = iavf_pci_tbl, |
386 | + .probe = iavf_probe, |
387 | + .remove = iavf_remove, |
388 | + .driver.pm = &iavf_pm_ops, |
389 | + .shutdown = iavf_shutdown, |
390 | }; |
391 | |
392 | /** |
393 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c |
394 | index b6a3370068f1c..7089ffcc4e512 100644 |
395 | --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c |
396 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c |
397 | @@ -69,12 +69,10 @@ enum { |
398 | MLX5_CMD_DELIVERY_STAT_CMD_DESCR_ERR = 0x10, |
399 | }; |
400 | |
401 | -static struct mlx5_cmd_work_ent *alloc_cmd(struct mlx5_cmd *cmd, |
402 | - struct mlx5_cmd_msg *in, |
403 | - struct mlx5_cmd_msg *out, |
404 | - void *uout, int uout_size, |
405 | - mlx5_cmd_cbk_t cbk, |
406 | - void *context, int page_queue) |
407 | +static struct mlx5_cmd_work_ent * |
408 | +cmd_alloc_ent(struct mlx5_cmd *cmd, struct mlx5_cmd_msg *in, |
409 | + struct mlx5_cmd_msg *out, void *uout, int uout_size, |
410 | + mlx5_cmd_cbk_t cbk, void *context, int page_queue) |
411 | { |
412 | gfp_t alloc_flags = cbk ? GFP_ATOMIC : GFP_KERNEL; |
413 | struct mlx5_cmd_work_ent *ent; |
414 | @@ -83,6 +81,7 @@ static struct mlx5_cmd_work_ent *alloc_cmd(struct mlx5_cmd *cmd, |
415 | if (!ent) |
416 | return ERR_PTR(-ENOMEM); |
417 | |
418 | + ent->idx = -EINVAL; |
419 | ent->in = in; |
420 | ent->out = out; |
421 | ent->uout = uout; |
422 | @@ -91,10 +90,16 @@ static struct mlx5_cmd_work_ent *alloc_cmd(struct mlx5_cmd *cmd, |
423 | ent->context = context; |
424 | ent->cmd = cmd; |
425 | ent->page_queue = page_queue; |
426 | + refcount_set(&ent->refcnt, 1); |
427 | |
428 | return ent; |
429 | } |
430 | |
431 | +static void cmd_free_ent(struct mlx5_cmd_work_ent *ent) |
432 | +{ |
433 | + kfree(ent); |
434 | +} |
435 | + |
436 | static u8 alloc_token(struct mlx5_cmd *cmd) |
437 | { |
438 | u8 token; |
439 | @@ -109,7 +114,7 @@ static u8 alloc_token(struct mlx5_cmd *cmd) |
440 | return token; |
441 | } |
442 | |
443 | -static int alloc_ent(struct mlx5_cmd *cmd) |
444 | +static int cmd_alloc_index(struct mlx5_cmd *cmd) |
445 | { |
446 | unsigned long flags; |
447 | int ret; |
448 | @@ -123,7 +128,7 @@ static int alloc_ent(struct mlx5_cmd *cmd) |
449 | return ret < cmd->max_reg_cmds ? ret : -ENOMEM; |
450 | } |
451 | |
452 | -static void free_ent(struct mlx5_cmd *cmd, int idx) |
453 | +static void cmd_free_index(struct mlx5_cmd *cmd, int idx) |
454 | { |
455 | unsigned long flags; |
456 | |
457 | @@ -132,6 +137,22 @@ static void free_ent(struct mlx5_cmd *cmd, int idx) |
458 | spin_unlock_irqrestore(&cmd->alloc_lock, flags); |
459 | } |
460 | |
461 | +static void cmd_ent_get(struct mlx5_cmd_work_ent *ent) |
462 | +{ |
463 | + refcount_inc(&ent->refcnt); |
464 | +} |
465 | + |
466 | +static void cmd_ent_put(struct mlx5_cmd_work_ent *ent) |
467 | +{ |
468 | + if (!refcount_dec_and_test(&ent->refcnt)) |
469 | + return; |
470 | + |
471 | + if (ent->idx >= 0) |
472 | + cmd_free_index(ent->cmd, ent->idx); |
473 | + |
474 | + cmd_free_ent(ent); |
475 | +} |
476 | + |
477 | static struct mlx5_cmd_layout *get_inst(struct mlx5_cmd *cmd, int idx) |
478 | { |
479 | return cmd->cmd_buf + (idx << cmd->log_stride); |
480 | @@ -219,11 +240,6 @@ static void poll_timeout(struct mlx5_cmd_work_ent *ent) |
481 | ent->ret = -ETIMEDOUT; |
482 | } |
483 | |
484 | -static void free_cmd(struct mlx5_cmd_work_ent *ent) |
485 | -{ |
486 | - kfree(ent); |
487 | -} |
488 | - |
489 | static int verify_signature(struct mlx5_cmd_work_ent *ent) |
490 | { |
491 | struct mlx5_cmd_mailbox *next = ent->out->next; |
492 | @@ -842,6 +858,7 @@ static void cb_timeout_handler(struct work_struct *work) |
493 | mlx5_command_str(msg_to_opcode(ent->in)), |
494 | msg_to_opcode(ent->in)); |
495 | mlx5_cmd_comp_handler(dev, 1UL << ent->idx, true); |
496 | + cmd_ent_put(ent); /* for the cmd_ent_get() took on schedule delayed work */ |
497 | } |
498 | |
499 | static void free_msg(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *msg); |
500 | @@ -865,14 +882,14 @@ static void cmd_work_handler(struct work_struct *work) |
501 | sem = ent->page_queue ? &cmd->pages_sem : &cmd->sem; |
502 | down(sem); |
503 | if (!ent->page_queue) { |
504 | - alloc_ret = alloc_ent(cmd); |
505 | + alloc_ret = cmd_alloc_index(cmd); |
506 | if (alloc_ret < 0) { |
507 | mlx5_core_err(dev, "failed to allocate command entry\n"); |
508 | if (ent->callback) { |
509 | ent->callback(-EAGAIN, ent->context); |
510 | mlx5_free_cmd_msg(dev, ent->out); |
511 | free_msg(dev, ent->in); |
512 | - free_cmd(ent); |
513 | + cmd_ent_put(ent); |
514 | } else { |
515 | ent->ret = -EAGAIN; |
516 | complete(&ent->done); |
517 | @@ -908,8 +925,8 @@ static void cmd_work_handler(struct work_struct *work) |
518 | ent->ts1 = ktime_get_ns(); |
519 | cmd_mode = cmd->mode; |
520 | |
521 | - if (ent->callback) |
522 | - schedule_delayed_work(&ent->cb_timeout_work, cb_timeout); |
523 | + if (ent->callback && schedule_delayed_work(&ent->cb_timeout_work, cb_timeout)) |
524 | + cmd_ent_get(ent); |
525 | set_bit(MLX5_CMD_ENT_STATE_PENDING_COMP, &ent->state); |
526 | |
527 | /* Skip sending command to fw if internal error */ |
528 | @@ -923,13 +940,10 @@ static void cmd_work_handler(struct work_struct *work) |
529 | MLX5_SET(mbox_out, ent->out, syndrome, drv_synd); |
530 | |
531 | mlx5_cmd_comp_handler(dev, 1UL << ent->idx, true); |
532 | - /* no doorbell, no need to keep the entry */ |
533 | - free_ent(cmd, ent->idx); |
534 | - if (ent->callback) |
535 | - free_cmd(ent); |
536 | return; |
537 | } |
538 | |
539 | + cmd_ent_get(ent); /* for the _real_ FW event on completion */ |
540 | /* ring doorbell after the descriptor is valid */ |
541 | mlx5_core_dbg(dev, "writing 0x%x to command doorbell\n", 1 << ent->idx); |
542 | wmb(); |
543 | @@ -1029,11 +1043,16 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, |
544 | if (callback && page_queue) |
545 | return -EINVAL; |
546 | |
547 | - ent = alloc_cmd(cmd, in, out, uout, uout_size, callback, context, |
548 | - page_queue); |
549 | + ent = cmd_alloc_ent(cmd, in, out, uout, uout_size, |
550 | + callback, context, page_queue); |
551 | if (IS_ERR(ent)) |
552 | return PTR_ERR(ent); |
553 | |
554 | + /* put for this ent is when consumed, depending on the use case |
555 | + * 1) (!callback) blocking flow: by caller after wait_func completes |
556 | + * 2) (callback) flow: by mlx5_cmd_comp_handler() when ent is handled |
557 | + */ |
558 | + |
559 | ent->token = token; |
560 | ent->polling = force_polling; |
561 | |
562 | @@ -1052,12 +1071,10 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, |
563 | } |
564 | |
565 | if (callback) |
566 | - goto out; |
567 | + goto out; /* mlx5_cmd_comp_handler() will put(ent) */ |
568 | |
569 | err = wait_func(dev, ent); |
570 | - if (err == -ETIMEDOUT) |
571 | - goto out; |
572 | - if (err == -ECANCELED) |
573 | + if (err == -ETIMEDOUT || err == -ECANCELED) |
574 | goto out_free; |
575 | |
576 | ds = ent->ts2 - ent->ts1; |
577 | @@ -1075,7 +1092,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, |
578 | *status = ent->status; |
579 | |
580 | out_free: |
581 | - free_cmd(ent); |
582 | + cmd_ent_put(ent); |
583 | out: |
584 | return err; |
585 | } |
586 | @@ -1490,14 +1507,19 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force |
587 | if (!forced) { |
588 | mlx5_core_err(dev, "Command completion arrived after timeout (entry idx = %d).\n", |
589 | ent->idx); |
590 | - free_ent(cmd, ent->idx); |
591 | - free_cmd(ent); |
592 | + cmd_ent_put(ent); |
593 | } |
594 | continue; |
595 | } |
596 | |
597 | - if (ent->callback) |
598 | - cancel_delayed_work(&ent->cb_timeout_work); |
599 | + if (ent->callback && cancel_delayed_work(&ent->cb_timeout_work)) |
600 | + cmd_ent_put(ent); /* timeout work was canceled */ |
601 | + |
602 | + if (!forced || /* Real FW completion */ |
603 | + pci_channel_offline(dev->pdev) || /* FW is inaccessible */ |
604 | + dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) |
605 | + cmd_ent_put(ent); |
606 | + |
607 | if (ent->page_queue) |
608 | sem = &cmd->pages_sem; |
609 | else |
610 | @@ -1519,10 +1541,6 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force |
611 | ent->ret, deliv_status_to_str(ent->status), ent->status); |
612 | } |
613 | |
614 | - /* only real completion will free the entry slot */ |
615 | - if (!forced) |
616 | - free_ent(cmd, ent->idx); |
617 | - |
618 | if (ent->callback) { |
619 | ds = ent->ts2 - ent->ts1; |
620 | if (ent->op < ARRAY_SIZE(cmd->stats)) { |
621 | @@ -1550,10 +1568,13 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force |
622 | free_msg(dev, ent->in); |
623 | |
624 | err = err ? err : ent->status; |
625 | - if (!forced) |
626 | - free_cmd(ent); |
627 | + /* final consumer is done, release ent */ |
628 | + cmd_ent_put(ent); |
629 | callback(err, context); |
630 | } else { |
631 | + /* release wait_func() so mlx5_cmd_invoke() |
632 | + * can make the final ent_put() |
633 | + */ |
634 | complete(&ent->done); |
635 | } |
636 | up(sem); |
637 | @@ -1563,8 +1584,11 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force |
638 | |
639 | void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev) |
640 | { |
641 | + struct mlx5_cmd *cmd = &dev->cmd; |
642 | + unsigned long bitmask; |
643 | unsigned long flags; |
644 | u64 vector; |
645 | + int i; |
646 | |
647 | /* wait for pending handlers to complete */ |
648 | mlx5_eq_synchronize_cmd_irq(dev); |
649 | @@ -1573,11 +1597,20 @@ void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev) |
650 | if (!vector) |
651 | goto no_trig; |
652 | |
653 | + bitmask = vector; |
654 | + /* we must increment the allocated entries refcount before triggering the completions |
655 | + * to guarantee pending commands will not get freed in the meanwhile. |
656 | + * For that reason, it also has to be done inside the alloc_lock. |
657 | + */ |
658 | + for_each_set_bit(i, &bitmask, (1 << cmd->log_sz)) |
659 | + cmd_ent_get(cmd->ent_arr[i]); |
660 | vector |= MLX5_TRIGGERED_CMD_COMP; |
661 | spin_unlock_irqrestore(&dev->cmd.alloc_lock, flags); |
662 | |
663 | mlx5_core_dbg(dev, "vector 0x%llx\n", vector); |
664 | mlx5_cmd_comp_handler(dev, vector, true); |
665 | + for_each_set_bit(i, &bitmask, (1 << cmd->log_sz)) |
666 | + cmd_ent_put(cmd->ent_arr[i]); |
667 | return; |
668 | |
669 | no_trig: |
670 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h |
671 | index 98304c42e4952..b5c8afe8cd10d 100644 |
672 | --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h |
673 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h |
674 | @@ -92,7 +92,12 @@ struct page_pool; |
675 | #define MLX5_MPWRQ_PAGES_PER_WQE BIT(MLX5_MPWRQ_WQE_PAGE_ORDER) |
676 | |
677 | #define MLX5_MTT_OCTW(npages) (ALIGN(npages, 8) / 2) |
678 | -#define MLX5E_REQUIRED_WQE_MTTS (ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8)) |
679 | +/* Add another page to MLX5E_REQUIRED_WQE_MTTS as a buffer between |
680 | + * WQEs, This page will absorb write overflow by the hardware, when |
681 | + * receiving packets larger than MTU. These oversize packets are |
682 | + * dropped by the driver at a later stage. |
683 | + */ |
684 | +#define MLX5E_REQUIRED_WQE_MTTS (ALIGN(MLX5_MPWRQ_PAGES_PER_WQE + 1, 8)) |
685 | #define MLX5E_LOG_ALIGNED_MPWQE_PPW (ilog2(MLX5E_REQUIRED_WQE_MTTS)) |
686 | #define MLX5E_REQUIRED_MTTS(wqes) (wqes * MLX5E_REQUIRED_WQE_MTTS) |
687 | #define MLX5E_MAX_RQ_NUM_MTTS \ |
688 | @@ -694,6 +699,7 @@ struct mlx5e_rq { |
689 | u32 rqn; |
690 | struct mlx5_core_dev *mdev; |
691 | struct mlx5_core_mkey umr_mkey; |
692 | + struct mlx5e_dma_info wqe_overflow; |
693 | |
694 | /* XDP read-mostly */ |
695 | struct xdp_rxq_info xdp_rxq; |
696 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c |
697 | index 73d3dc07331f1..713dc210f710c 100644 |
698 | --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c |
699 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c |
700 | @@ -217,6 +217,9 @@ static int __mlx5e_add_vlan_rule(struct mlx5e_priv *priv, |
701 | break; |
702 | } |
703 | |
704 | + if (WARN_ONCE(*rule_p, "VLAN rule already exists type %d", rule_type)) |
705 | + return 0; |
706 | + |
707 | *rule_p = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1); |
708 | |
709 | if (IS_ERR(*rule_p)) { |
710 | @@ -397,8 +400,7 @@ static void mlx5e_add_vlan_rules(struct mlx5e_priv *priv) |
711 | for_each_set_bit(i, priv->fs.vlan.active_svlans, VLAN_N_VID) |
712 | mlx5e_add_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_MATCH_STAG_VID, i); |
713 | |
714 | - if (priv->fs.vlan.cvlan_filter_disabled && |
715 | - !(priv->netdev->flags & IFF_PROMISC)) |
716 | + if (priv->fs.vlan.cvlan_filter_disabled) |
717 | mlx5e_add_any_vid_rules(priv); |
718 | } |
719 | |
720 | @@ -415,8 +417,12 @@ static void mlx5e_del_vlan_rules(struct mlx5e_priv *priv) |
721 | for_each_set_bit(i, priv->fs.vlan.active_svlans, VLAN_N_VID) |
722 | mlx5e_del_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_MATCH_STAG_VID, i); |
723 | |
724 | - if (priv->fs.vlan.cvlan_filter_disabled && |
725 | - !(priv->netdev->flags & IFF_PROMISC)) |
726 | + WARN_ON_ONCE(!(test_bit(MLX5E_STATE_DESTROYING, &priv->state))); |
727 | + |
728 | + /* must be called after DESTROY bit is set and |
729 | + * set_rx_mode is called and flushed |
730 | + */ |
731 | + if (priv->fs.vlan.cvlan_filter_disabled) |
732 | mlx5e_del_any_vid_rules(priv); |
733 | } |
734 | |
735 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c |
736 | index ee0d78f801af5..8b8581f71e793 100644 |
737 | --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c |
738 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c |
739 | @@ -266,12 +266,17 @@ static int mlx5e_rq_alloc_mpwqe_info(struct mlx5e_rq *rq, |
740 | |
741 | static int mlx5e_create_umr_mkey(struct mlx5_core_dev *mdev, |
742 | u64 npages, u8 page_shift, |
743 | - struct mlx5_core_mkey *umr_mkey) |
744 | + struct mlx5_core_mkey *umr_mkey, |
745 | + dma_addr_t filler_addr) |
746 | { |
747 | - int inlen = MLX5_ST_SZ_BYTES(create_mkey_in); |
748 | + struct mlx5_mtt *mtt; |
749 | + int inlen; |
750 | void *mkc; |
751 | u32 *in; |
752 | int err; |
753 | + int i; |
754 | + |
755 | + inlen = MLX5_ST_SZ_BYTES(create_mkey_in) + sizeof(*mtt) * npages; |
756 | |
757 | in = kvzalloc(inlen, GFP_KERNEL); |
758 | if (!in) |
759 | @@ -291,6 +296,18 @@ static int mlx5e_create_umr_mkey(struct mlx5_core_dev *mdev, |
760 | MLX5_SET(mkc, mkc, translations_octword_size, |
761 | MLX5_MTT_OCTW(npages)); |
762 | MLX5_SET(mkc, mkc, log_page_size, page_shift); |
763 | + MLX5_SET(create_mkey_in, in, translations_octword_actual_size, |
764 | + MLX5_MTT_OCTW(npages)); |
765 | + |
766 | + /* Initialize the mkey with all MTTs pointing to a default |
767 | + * page (filler_addr). When the channels are activated, UMR |
768 | + * WQEs will redirect the RX WQEs to the actual memory from |
769 | + * the RQ's pool, while the gaps (wqe_overflow) remain mapped |
770 | + * to the default page. |
771 | + */ |
772 | + mtt = MLX5_ADDR_OF(create_mkey_in, in, klm_pas_mtt); |
773 | + for (i = 0 ; i < npages ; i++) |
774 | + mtt[i].ptag = cpu_to_be64(filler_addr); |
775 | |
776 | err = mlx5_core_create_mkey(mdev, umr_mkey, in, inlen); |
777 | |
778 | @@ -302,7 +319,8 @@ static int mlx5e_create_rq_umr_mkey(struct mlx5_core_dev *mdev, struct mlx5e_rq |
779 | { |
780 | u64 num_mtts = MLX5E_REQUIRED_MTTS(mlx5_wq_ll_get_size(&rq->mpwqe.wq)); |
781 | |
782 | - return mlx5e_create_umr_mkey(mdev, num_mtts, PAGE_SHIFT, &rq->umr_mkey); |
783 | + return mlx5e_create_umr_mkey(mdev, num_mtts, PAGE_SHIFT, &rq->umr_mkey, |
784 | + rq->wqe_overflow.addr); |
785 | } |
786 | |
787 | static inline u64 mlx5e_get_mpwqe_offset(struct mlx5e_rq *rq, u16 wqe_ix) |
788 | @@ -370,6 +388,28 @@ static void mlx5e_rq_err_cqe_work(struct work_struct *recover_work) |
789 | mlx5e_reporter_rq_cqe_err(rq); |
790 | } |
791 | |
792 | +static int mlx5e_alloc_mpwqe_rq_drop_page(struct mlx5e_rq *rq) |
793 | +{ |
794 | + rq->wqe_overflow.page = alloc_page(GFP_KERNEL); |
795 | + if (!rq->wqe_overflow.page) |
796 | + return -ENOMEM; |
797 | + |
798 | + rq->wqe_overflow.addr = dma_map_page(rq->pdev, rq->wqe_overflow.page, 0, |
799 | + PAGE_SIZE, rq->buff.map_dir); |
800 | + if (dma_mapping_error(rq->pdev, rq->wqe_overflow.addr)) { |
801 | + __free_page(rq->wqe_overflow.page); |
802 | + return -ENOMEM; |
803 | + } |
804 | + return 0; |
805 | +} |
806 | + |
807 | +static void mlx5e_free_mpwqe_rq_drop_page(struct mlx5e_rq *rq) |
808 | +{ |
809 | + dma_unmap_page(rq->pdev, rq->wqe_overflow.addr, PAGE_SIZE, |
810 | + rq->buff.map_dir); |
811 | + __free_page(rq->wqe_overflow.page); |
812 | +} |
813 | + |
814 | static int mlx5e_alloc_rq(struct mlx5e_channel *c, |
815 | struct mlx5e_params *params, |
816 | struct mlx5e_xsk_param *xsk, |
817 | @@ -434,6 +474,10 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, |
818 | if (err) |
819 | goto err_rq_wq_destroy; |
820 | |
821 | + err = mlx5e_alloc_mpwqe_rq_drop_page(rq); |
822 | + if (err) |
823 | + goto err_rq_wq_destroy; |
824 | + |
825 | rq->mpwqe.wq.db = &rq->mpwqe.wq.db[MLX5_RCV_DBR]; |
826 | |
827 | wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq); |
828 | @@ -474,7 +518,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, |
829 | |
830 | err = mlx5e_create_rq_umr_mkey(mdev, rq); |
831 | if (err) |
832 | - goto err_rq_wq_destroy; |
833 | + goto err_rq_drop_page; |
834 | rq->mkey_be = cpu_to_be32(rq->umr_mkey.key); |
835 | |
836 | err = mlx5e_rq_alloc_mpwqe_info(rq, c); |
837 | @@ -622,6 +666,8 @@ err_free: |
838 | case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ: |
839 | kvfree(rq->mpwqe.info); |
840 | mlx5_core_destroy_mkey(mdev, &rq->umr_mkey); |
841 | +err_rq_drop_page: |
842 | + mlx5e_free_mpwqe_rq_drop_page(rq); |
843 | break; |
844 | default: /* MLX5_WQ_TYPE_CYCLIC */ |
845 | kvfree(rq->wqe.frags); |
846 | @@ -649,6 +695,7 @@ static void mlx5e_free_rq(struct mlx5e_rq *rq) |
847 | case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ: |
848 | kvfree(rq->mpwqe.info); |
849 | mlx5_core_destroy_mkey(rq->mdev, &rq->umr_mkey); |
850 | + mlx5e_free_mpwqe_rq_drop_page(rq); |
851 | break; |
852 | default: /* MLX5_WQ_TYPE_CYCLIC */ |
853 | kvfree(rq->wqe.frags); |
854 | @@ -4281,6 +4328,21 @@ void mlx5e_del_vxlan_port(struct net_device *netdev, struct udp_tunnel_info *ti) |
855 | mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 0); |
856 | } |
857 | |
858 | +static bool mlx5e_gre_tunnel_inner_proto_offload_supported(struct mlx5_core_dev *mdev, |
859 | + struct sk_buff *skb) |
860 | +{ |
861 | + switch (skb->inner_protocol) { |
862 | + case htons(ETH_P_IP): |
863 | + case htons(ETH_P_IPV6): |
864 | + case htons(ETH_P_TEB): |
865 | + return true; |
866 | + case htons(ETH_P_MPLS_UC): |
867 | + case htons(ETH_P_MPLS_MC): |
868 | + return MLX5_CAP_ETH(mdev, tunnel_stateless_mpls_over_gre); |
869 | + } |
870 | + return false; |
871 | +} |
872 | + |
873 | static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv, |
874 | struct sk_buff *skb, |
875 | netdev_features_t features) |
876 | @@ -4303,7 +4365,9 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv, |
877 | |
878 | switch (proto) { |
879 | case IPPROTO_GRE: |
880 | - return features; |
881 | + if (mlx5e_gre_tunnel_inner_proto_offload_supported(priv->mdev, skb)) |
882 | + return features; |
883 | + break; |
884 | case IPPROTO_IPIP: |
885 | case IPPROTO_IPV6: |
886 | if (mlx5e_tunnel_proto_supported(priv->mdev, IPPROTO_IPIP)) |
887 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c |
888 | index 373981a659c7c..6fd9749203944 100644 |
889 | --- a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c |
890 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c |
891 | @@ -115,7 +115,7 @@ static int request_irqs(struct mlx5_core_dev *dev, int nvec) |
892 | return 0; |
893 | |
894 | err_request_irq: |
895 | - for (; i >= 0; i--) { |
896 | + while (i--) { |
897 | struct mlx5_irq *irq = mlx5_irq_get(dev, i); |
898 | int irqn = pci_irq_vector(dev->pdev, i); |
899 | |
900 | diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c |
901 | index 295b27112d367..ec0d5a4a60a98 100644 |
902 | --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c |
903 | +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c |
904 | @@ -290,13 +290,14 @@ mlxsw_sp_acl_tcam_group_add(struct mlxsw_sp_acl_tcam *tcam, |
905 | int err; |
906 | |
907 | group->tcam = tcam; |
908 | - mutex_init(&group->lock); |
909 | INIT_LIST_HEAD(&group->region_list); |
910 | |
911 | err = mlxsw_sp_acl_tcam_group_id_get(tcam, &group->id); |
912 | if (err) |
913 | return err; |
914 | |
915 | + mutex_init(&group->lock); |
916 | + |
917 | return 0; |
918 | } |
919 | |
920 | diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c |
921 | index 903212ad9bb2f..66c97049f52b7 100644 |
922 | --- a/drivers/net/ethernet/realtek/r8169_main.c |
923 | +++ b/drivers/net/ethernet/realtek/r8169_main.c |
924 | @@ -4701,7 +4701,7 @@ static void rtl_hw_start_8168f_1(struct rtl8169_private *tp) |
925 | { 0x08, 0x0001, 0x0002 }, |
926 | { 0x09, 0x0000, 0x0080 }, |
927 | { 0x19, 0x0000, 0x0224 }, |
928 | - { 0x00, 0x0000, 0x0004 }, |
929 | + { 0x00, 0x0000, 0x0008 }, |
930 | { 0x0c, 0x3df0, 0x0200 }, |
931 | }; |
932 | |
933 | @@ -4718,7 +4718,7 @@ static void rtl_hw_start_8411(struct rtl8169_private *tp) |
934 | { 0x06, 0x00c0, 0x0020 }, |
935 | { 0x0f, 0xffff, 0x5200 }, |
936 | { 0x19, 0x0000, 0x0224 }, |
937 | - { 0x00, 0x0000, 0x0004 }, |
938 | + { 0x00, 0x0000, 0x0008 }, |
939 | { 0x0c, 0x3df0, 0x0200 }, |
940 | }; |
941 | |
942 | diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c |
943 | index 907ae1359a7c1..30cdabf64ccc1 100644 |
944 | --- a/drivers/net/ethernet/renesas/ravb_main.c |
945 | +++ b/drivers/net/ethernet/renesas/ravb_main.c |
946 | @@ -1336,51 +1336,6 @@ static inline int ravb_hook_irq(unsigned int irq, irq_handler_t handler, |
947 | return error; |
948 | } |
949 | |
950 | -/* MDIO bus init function */ |
951 | -static int ravb_mdio_init(struct ravb_private *priv) |
952 | -{ |
953 | - struct platform_device *pdev = priv->pdev; |
954 | - struct device *dev = &pdev->dev; |
955 | - int error; |
956 | - |
957 | - /* Bitbang init */ |
958 | - priv->mdiobb.ops = &bb_ops; |
959 | - |
960 | - /* MII controller setting */ |
961 | - priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb); |
962 | - if (!priv->mii_bus) |
963 | - return -ENOMEM; |
964 | - |
965 | - /* Hook up MII support for ethtool */ |
966 | - priv->mii_bus->name = "ravb_mii"; |
967 | - priv->mii_bus->parent = dev; |
968 | - snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", |
969 | - pdev->name, pdev->id); |
970 | - |
971 | - /* Register MDIO bus */ |
972 | - error = of_mdiobus_register(priv->mii_bus, dev->of_node); |
973 | - if (error) |
974 | - goto out_free_bus; |
975 | - |
976 | - return 0; |
977 | - |
978 | -out_free_bus: |
979 | - free_mdio_bitbang(priv->mii_bus); |
980 | - return error; |
981 | -} |
982 | - |
983 | -/* MDIO bus release function */ |
984 | -static int ravb_mdio_release(struct ravb_private *priv) |
985 | -{ |
986 | - /* Unregister mdio bus */ |
987 | - mdiobus_unregister(priv->mii_bus); |
988 | - |
989 | - /* Free bitbang info */ |
990 | - free_mdio_bitbang(priv->mii_bus); |
991 | - |
992 | - return 0; |
993 | -} |
994 | - |
995 | /* Network device open function for Ethernet AVB */ |
996 | static int ravb_open(struct net_device *ndev) |
997 | { |
998 | @@ -1389,13 +1344,6 @@ static int ravb_open(struct net_device *ndev) |
999 | struct device *dev = &pdev->dev; |
1000 | int error; |
1001 | |
1002 | - /* MDIO bus init */ |
1003 | - error = ravb_mdio_init(priv); |
1004 | - if (error) { |
1005 | - netdev_err(ndev, "failed to initialize MDIO\n"); |
1006 | - return error; |
1007 | - } |
1008 | - |
1009 | napi_enable(&priv->napi[RAVB_BE]); |
1010 | napi_enable(&priv->napi[RAVB_NC]); |
1011 | |
1012 | @@ -1473,7 +1421,6 @@ out_free_irq: |
1013 | out_napi_off: |
1014 | napi_disable(&priv->napi[RAVB_NC]); |
1015 | napi_disable(&priv->napi[RAVB_BE]); |
1016 | - ravb_mdio_release(priv); |
1017 | return error; |
1018 | } |
1019 | |
1020 | @@ -1783,8 +1730,6 @@ static int ravb_close(struct net_device *ndev) |
1021 | ravb_ring_free(ndev, RAVB_BE); |
1022 | ravb_ring_free(ndev, RAVB_NC); |
1023 | |
1024 | - ravb_mdio_release(priv); |
1025 | - |
1026 | return 0; |
1027 | } |
1028 | |
1029 | @@ -1936,6 +1881,51 @@ static const struct net_device_ops ravb_netdev_ops = { |
1030 | .ndo_set_features = ravb_set_features, |
1031 | }; |
1032 | |
1033 | +/* MDIO bus init function */ |
1034 | +static int ravb_mdio_init(struct ravb_private *priv) |
1035 | +{ |
1036 | + struct platform_device *pdev = priv->pdev; |
1037 | + struct device *dev = &pdev->dev; |
1038 | + int error; |
1039 | + |
1040 | + /* Bitbang init */ |
1041 | + priv->mdiobb.ops = &bb_ops; |
1042 | + |
1043 | + /* MII controller setting */ |
1044 | + priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb); |
1045 | + if (!priv->mii_bus) |
1046 | + return -ENOMEM; |
1047 | + |
1048 | + /* Hook up MII support for ethtool */ |
1049 | + priv->mii_bus->name = "ravb_mii"; |
1050 | + priv->mii_bus->parent = dev; |
1051 | + snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", |
1052 | + pdev->name, pdev->id); |
1053 | + |
1054 | + /* Register MDIO bus */ |
1055 | + error = of_mdiobus_register(priv->mii_bus, dev->of_node); |
1056 | + if (error) |
1057 | + goto out_free_bus; |
1058 | + |
1059 | + return 0; |
1060 | + |
1061 | +out_free_bus: |
1062 | + free_mdio_bitbang(priv->mii_bus); |
1063 | + return error; |
1064 | +} |
1065 | + |
1066 | +/* MDIO bus release function */ |
1067 | +static int ravb_mdio_release(struct ravb_private *priv) |
1068 | +{ |
1069 | + /* Unregister mdio bus */ |
1070 | + mdiobus_unregister(priv->mii_bus); |
1071 | + |
1072 | + /* Free bitbang info */ |
1073 | + free_mdio_bitbang(priv->mii_bus); |
1074 | + |
1075 | + return 0; |
1076 | +} |
1077 | + |
1078 | static const struct of_device_id ravb_match_table[] = { |
1079 | { .compatible = "renesas,etheravb-r8a7790", .data = (void *)RCAR_GEN2 }, |
1080 | { .compatible = "renesas,etheravb-r8a7794", .data = (void *)RCAR_GEN2 }, |
1081 | @@ -2176,6 +2166,13 @@ static int ravb_probe(struct platform_device *pdev) |
1082 | eth_hw_addr_random(ndev); |
1083 | } |
1084 | |
1085 | + /* MDIO bus init */ |
1086 | + error = ravb_mdio_init(priv); |
1087 | + if (error) { |
1088 | + dev_err(&pdev->dev, "failed to initialize MDIO\n"); |
1089 | + goto out_dma_free; |
1090 | + } |
1091 | + |
1092 | netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll, 64); |
1093 | netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll, 64); |
1094 | |
1095 | @@ -2197,6 +2194,8 @@ static int ravb_probe(struct platform_device *pdev) |
1096 | out_napi_del: |
1097 | netif_napi_del(&priv->napi[RAVB_NC]); |
1098 | netif_napi_del(&priv->napi[RAVB_BE]); |
1099 | + ravb_mdio_release(priv); |
1100 | +out_dma_free: |
1101 | dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, |
1102 | priv->desc_bat_dma); |
1103 | |
1104 | @@ -2228,6 +2227,7 @@ static int ravb_remove(struct platform_device *pdev) |
1105 | unregister_netdev(ndev); |
1106 | netif_napi_del(&priv->napi[RAVB_NC]); |
1107 | netif_napi_del(&priv->napi[RAVB_BE]); |
1108 | + ravb_mdio_release(priv); |
1109 | pm_runtime_disable(&pdev->dev); |
1110 | free_netdev(ndev); |
1111 | platform_set_drvdata(pdev, NULL); |
1112 | diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c |
1113 | index 1a768837ca728..ce1346c14b05a 100644 |
1114 | --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c |
1115 | +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c |
1116 | @@ -662,23 +662,16 @@ static int stmmac_ethtool_op_set_eee(struct net_device *dev, |
1117 | struct stmmac_priv *priv = netdev_priv(dev); |
1118 | int ret; |
1119 | |
1120 | - if (!edata->eee_enabled) { |
1121 | + if (!priv->dma_cap.eee) |
1122 | + return -EOPNOTSUPP; |
1123 | + |
1124 | + if (!edata->eee_enabled) |
1125 | stmmac_disable_eee_mode(priv); |
1126 | - } else { |
1127 | - /* We are asking for enabling the EEE but it is safe |
1128 | - * to verify all by invoking the eee_init function. |
1129 | - * In case of failure it will return an error. |
1130 | - */ |
1131 | - edata->eee_enabled = stmmac_eee_init(priv); |
1132 | - if (!edata->eee_enabled) |
1133 | - return -EOPNOTSUPP; |
1134 | - } |
1135 | |
1136 | ret = phylink_ethtool_set_eee(priv->phylink, edata); |
1137 | if (ret) |
1138 | return ret; |
1139 | |
1140 | - priv->eee_enabled = edata->eee_enabled; |
1141 | priv->tx_lpi_timer = edata->tx_lpi_timer; |
1142 | return 0; |
1143 | } |
1144 | diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c |
1145 | index 4c86a73db475a..f233a6933a976 100644 |
1146 | --- a/drivers/net/macsec.c |
1147 | +++ b/drivers/net/macsec.c |
1148 | @@ -1080,6 +1080,7 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb) |
1149 | struct macsec_rx_sa *rx_sa; |
1150 | struct macsec_rxh_data *rxd; |
1151 | struct macsec_dev *macsec; |
1152 | + unsigned int len; |
1153 | sci_t sci; |
1154 | u32 pn; |
1155 | bool cbit; |
1156 | @@ -1236,9 +1237,10 @@ deliver: |
1157 | macsec_rxsc_put(rx_sc); |
1158 | |
1159 | skb_orphan(skb); |
1160 | + len = skb->len; |
1161 | ret = gro_cells_receive(&macsec->gro_cells, skb); |
1162 | if (ret == NET_RX_SUCCESS) |
1163 | - count_rx(dev, skb->len); |
1164 | + count_rx(dev, len); |
1165 | else |
1166 | macsec->secy.netdev->stats.rx_dropped++; |
1167 | |
1168 | diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig |
1169 | index fe602648b99f5..dcf2051ef2c04 100644 |
1170 | --- a/drivers/net/phy/Kconfig |
1171 | +++ b/drivers/net/phy/Kconfig |
1172 | @@ -193,6 +193,7 @@ config MDIO_THUNDER |
1173 | depends on 64BIT |
1174 | depends on PCI |
1175 | select MDIO_CAVIUM |
1176 | + select MDIO_DEVRES |
1177 | help |
1178 | This driver supports the MDIO interfaces found on Cavium |
1179 | ThunderX SoCs when the MDIO bus device appears as a PCI |
1180 | diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c |
1181 | index 04845a4017f93..606fee99221b8 100644 |
1182 | --- a/drivers/net/team/team.c |
1183 | +++ b/drivers/net/team/team.c |
1184 | @@ -287,7 +287,7 @@ inst_rollback: |
1185 | for (i--; i >= 0; i--) |
1186 | __team_option_inst_del_option(team, dst_opts[i]); |
1187 | |
1188 | - i = option_count - 1; |
1189 | + i = option_count; |
1190 | alloc_rollback: |
1191 | for (i--; i >= 0; i--) |
1192 | kfree(dst_opts[i]); |
1193 | @@ -2111,6 +2111,7 @@ static void team_setup_by_port(struct net_device *dev, |
1194 | dev->header_ops = port_dev->header_ops; |
1195 | dev->type = port_dev->type; |
1196 | dev->hard_header_len = port_dev->hard_header_len; |
1197 | + dev->needed_headroom = port_dev->needed_headroom; |
1198 | dev->addr_len = port_dev->addr_len; |
1199 | dev->mtu = port_dev->mtu; |
1200 | memcpy(dev->broadcast, port_dev->broadcast, port_dev->addr_len); |
1201 | diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c |
1202 | index df2f7cc6dc03a..8e37e1f58c4b9 100644 |
1203 | --- a/drivers/net/usb/ax88179_178a.c |
1204 | +++ b/drivers/net/usb/ax88179_178a.c |
1205 | @@ -1719,6 +1719,7 @@ static const struct driver_info belkin_info = { |
1206 | .status = ax88179_status, |
1207 | .link_reset = ax88179_link_reset, |
1208 | .reset = ax88179_reset, |
1209 | + .stop = ax88179_stop, |
1210 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, |
1211 | .rx_fixup = ax88179_rx_fixup, |
1212 | .tx_fixup = ax88179_tx_fixup, |
1213 | diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c |
1214 | index 13e51ccf02147..491625c1c3084 100644 |
1215 | --- a/drivers/net/usb/rtl8150.c |
1216 | +++ b/drivers/net/usb/rtl8150.c |
1217 | @@ -274,12 +274,20 @@ static int write_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 reg) |
1218 | return 1; |
1219 | } |
1220 | |
1221 | -static inline void set_ethernet_addr(rtl8150_t * dev) |
1222 | +static void set_ethernet_addr(rtl8150_t *dev) |
1223 | { |
1224 | - u8 node_id[6]; |
1225 | + u8 node_id[ETH_ALEN]; |
1226 | + int ret; |
1227 | + |
1228 | + ret = get_registers(dev, IDR, sizeof(node_id), node_id); |
1229 | |
1230 | - get_registers(dev, IDR, sizeof(node_id), node_id); |
1231 | - memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id)); |
1232 | + if (ret == sizeof(node_id)) { |
1233 | + ether_addr_copy(dev->netdev->dev_addr, node_id); |
1234 | + } else { |
1235 | + eth_hw_addr_random(dev->netdev); |
1236 | + netdev_notice(dev->netdev, "Assigned a random MAC address: %pM\n", |
1237 | + dev->netdev->dev_addr); |
1238 | + } |
1239 | } |
1240 | |
1241 | static int rtl8150_set_mac_address(struct net_device *netdev, void *p) |
1242 | diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c |
1243 | index 030d30603c295..99e1a7bc06886 100644 |
1244 | --- a/drivers/net/virtio_net.c |
1245 | +++ b/drivers/net/virtio_net.c |
1246 | @@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = { |
1247 | VIRTIO_NET_F_GUEST_CSUM |
1248 | }; |
1249 | |
1250 | +#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ |
1251 | + (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ |
1252 | + (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ |
1253 | + (1ULL << VIRTIO_NET_F_GUEST_UFO)) |
1254 | + |
1255 | struct virtnet_stat_desc { |
1256 | char desc[ETH_GSTRING_LEN]; |
1257 | size_t offset; |
1258 | @@ -2572,7 +2577,8 @@ static int virtnet_set_features(struct net_device *dev, |
1259 | if (features & NETIF_F_LRO) |
1260 | offloads = vi->guest_offloads_capable; |
1261 | else |
1262 | - offloads = 0; |
1263 | + offloads = vi->guest_offloads_capable & |
1264 | + ~GUEST_OFFLOAD_LRO_MASK; |
1265 | |
1266 | err = virtnet_set_guest_offloads(vi, offloads); |
1267 | if (err) |
1268 | diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c |
1269 | index 207ed6d49ad7c..ce69aaea581a5 100644 |
1270 | --- a/drivers/nvme/host/core.c |
1271 | +++ b/drivers/nvme/host/core.c |
1272 | @@ -2932,8 +2932,10 @@ static int nvme_dev_open(struct inode *inode, struct file *file) |
1273 | } |
1274 | |
1275 | nvme_get_ctrl(ctrl); |
1276 | - if (!try_module_get(ctrl->ops->module)) |
1277 | + if (!try_module_get(ctrl->ops->module)) { |
1278 | + nvme_put_ctrl(ctrl); |
1279 | return -EINVAL; |
1280 | + } |
1281 | |
1282 | file->private_data = ctrl; |
1283 | return 0; |
1284 | diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c |
1285 | index 6d7a813e7183a..e159b78b5f3b4 100644 |
1286 | --- a/drivers/nvme/host/tcp.c |
1287 | +++ b/drivers/nvme/host/tcp.c |
1288 | @@ -861,12 +861,11 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req) |
1289 | else |
1290 | flags |= MSG_MORE; |
1291 | |
1292 | - /* can't zcopy slab pages */ |
1293 | - if (unlikely(PageSlab(page))) { |
1294 | - ret = sock_no_sendpage(queue->sock, page, offset, len, |
1295 | + if (sendpage_ok(page)) { |
1296 | + ret = kernel_sendpage(queue->sock, page, offset, len, |
1297 | flags); |
1298 | } else { |
1299 | - ret = kernel_sendpage(queue->sock, page, offset, len, |
1300 | + ret = sock_no_sendpage(queue->sock, page, offset, len, |
1301 | flags); |
1302 | } |
1303 | if (ret <= 0) |
1304 | diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c |
1305 | index 190e4a6186ef7..f64b82824db28 100644 |
1306 | --- a/drivers/platform/olpc/olpc-ec.c |
1307 | +++ b/drivers/platform/olpc/olpc-ec.c |
1308 | @@ -439,7 +439,9 @@ static int olpc_ec_probe(struct platform_device *pdev) |
1309 | &config); |
1310 | if (IS_ERR(ec->dcon_rdev)) { |
1311 | dev_err(&pdev->dev, "failed to register DCON regulator\n"); |
1312 | - return PTR_ERR(ec->dcon_rdev); |
1313 | + err = PTR_ERR(ec->dcon_rdev); |
1314 | + kfree(ec); |
1315 | + return err; |
1316 | } |
1317 | |
1318 | ec->dbgfs_dir = olpc_ec_setup_debugfs(); |
1319 | diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig |
1320 | index 1cab993205142..000d5693fae74 100644 |
1321 | --- a/drivers/platform/x86/Kconfig |
1322 | +++ b/drivers/platform/x86/Kconfig |
1323 | @@ -269,6 +269,7 @@ config FUJITSU_LAPTOP |
1324 | depends on BACKLIGHT_CLASS_DEVICE |
1325 | depends on ACPI_VIDEO || ACPI_VIDEO = n |
1326 | select INPUT_SPARSEKMAP |
1327 | + select NEW_LEDS |
1328 | select LEDS_CLASS |
1329 | ---help--- |
1330 | This is a driver for laptops built by Fujitsu: |
1331 | diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c |
1332 | index 3393ee95077f6..5c103614a409a 100644 |
1333 | --- a/drivers/platform/x86/intel-vbtn.c |
1334 | +++ b/drivers/platform/x86/intel-vbtn.c |
1335 | @@ -15,9 +15,13 @@ |
1336 | #include <linux/platform_device.h> |
1337 | #include <linux/suspend.h> |
1338 | |
1339 | +/* Returned when NOT in tablet mode on some HP Stream x360 11 models */ |
1340 | +#define VGBS_TABLET_MODE_FLAG_ALT 0x10 |
1341 | /* When NOT in tablet mode, VGBS returns with the flag 0x40 */ |
1342 | -#define TABLET_MODE_FLAG 0x40 |
1343 | -#define DOCK_MODE_FLAG 0x80 |
1344 | +#define VGBS_TABLET_MODE_FLAG 0x40 |
1345 | +#define VGBS_DOCK_MODE_FLAG 0x80 |
1346 | + |
1347 | +#define VGBS_TABLET_MODE_FLAGS (VGBS_TABLET_MODE_FLAG | VGBS_TABLET_MODE_FLAG_ALT) |
1348 | |
1349 | MODULE_LICENSE("GPL"); |
1350 | MODULE_AUTHOR("AceLan Kao"); |
1351 | @@ -148,26 +152,60 @@ static void detect_tablet_mode(struct platform_device *device) |
1352 | if (ACPI_FAILURE(status)) |
1353 | return; |
1354 | |
1355 | - m = !(vgbs & TABLET_MODE_FLAG); |
1356 | + m = !(vgbs & VGBS_TABLET_MODE_FLAGS); |
1357 | input_report_switch(priv->input_dev, SW_TABLET_MODE, m); |
1358 | - m = (vgbs & DOCK_MODE_FLAG) ? 1 : 0; |
1359 | + m = (vgbs & VGBS_DOCK_MODE_FLAG) ? 1 : 0; |
1360 | input_report_switch(priv->input_dev, SW_DOCK, m); |
1361 | } |
1362 | |
1363 | +/* |
1364 | + * There are several laptops (non 2-in-1) models out there which support VGBS, |
1365 | + * but simply always return 0, which we translate to SW_TABLET_MODE=1. This in |
1366 | + * turn causes userspace (libinput) to suppress events from the builtin |
1367 | + * keyboard and touchpad, making the laptop essentially unusable. |
1368 | + * |
1369 | + * Since the problem of wrongly reporting SW_TABLET_MODE=1 in combination |
1370 | + * with libinput, leads to a non-usable system. Where as OTOH many people will |
1371 | + * not even notice when SW_TABLET_MODE is not being reported, a DMI based allow |
1372 | + * list is used here. This list mainly matches on the chassis-type of 2-in-1s. |
1373 | + * |
1374 | + * There are also some 2-in-1s which use the intel-vbtn ACPI interface to report |
1375 | + * SW_TABLET_MODE with a chassis-type of 8 ("Portable") or 10 ("Notebook"), |
1376 | + * these are matched on a per model basis, since many normal laptops with a |
1377 | + * possible broken VGBS ACPI-method also use these chassis-types. |
1378 | + */ |
1379 | +static const struct dmi_system_id dmi_switches_allow_list[] = { |
1380 | + { |
1381 | + .matches = { |
1382 | + DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "31" /* Convertible */), |
1383 | + }, |
1384 | + }, |
1385 | + { |
1386 | + .matches = { |
1387 | + DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "32" /* Detachable */), |
1388 | + }, |
1389 | + }, |
1390 | + { |
1391 | + .matches = { |
1392 | + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
1393 | + DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"), |
1394 | + }, |
1395 | + }, |
1396 | + { |
1397 | + .matches = { |
1398 | + DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
1399 | + DMI_MATCH(DMI_PRODUCT_NAME, "HP Stream x360 Convertible PC 11"), |
1400 | + }, |
1401 | + }, |
1402 | + {} /* Array terminator */ |
1403 | +}; |
1404 | + |
1405 | static bool intel_vbtn_has_switches(acpi_handle handle) |
1406 | { |
1407 | - const char *chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE); |
1408 | unsigned long long vgbs; |
1409 | acpi_status status; |
1410 | |
1411 | - /* |
1412 | - * Some normal laptops have a VGBS method despite being non-convertible |
1413 | - * and their VGBS method always returns 0, causing detect_tablet_mode() |
1414 | - * to report SW_TABLET_MODE=1 to userspace, which causes issues. |
1415 | - * These laptops have a DMI chassis_type of 9 ("Laptop"), do not report |
1416 | - * switches on any devices with a DMI chassis_type of 9. |
1417 | - */ |
1418 | - if (chassis_type && strcmp(chassis_type, "9") == 0) |
1419 | + if (!dmi_check_system(dmi_switches_allow_list)) |
1420 | return false; |
1421 | |
1422 | status = acpi_evaluate_integer(handle, "VGBS", NULL, &vgbs); |
1423 | diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c |
1424 | index da794dcfdd928..abcb336a515a1 100644 |
1425 | --- a/drivers/platform/x86/thinkpad_acpi.c |
1426 | +++ b/drivers/platform/x86/thinkpad_acpi.c |
1427 | @@ -2587,7 +2587,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn, |
1428 | */ |
1429 | static int hotkey_kthread(void *data) |
1430 | { |
1431 | - struct tp_nvram_state s[2]; |
1432 | + struct tp_nvram_state s[2] = { 0 }; |
1433 | u32 poll_mask, event_mask; |
1434 | unsigned int si, so; |
1435 | unsigned long t; |
1436 | @@ -6863,8 +6863,10 @@ static int __init tpacpi_query_bcl_levels(acpi_handle handle) |
1437 | list_for_each_entry(child, &device->children, node) { |
1438 | acpi_status status = acpi_evaluate_object(child->handle, "_BCL", |
1439 | NULL, &buffer); |
1440 | - if (ACPI_FAILURE(status)) |
1441 | + if (ACPI_FAILURE(status)) { |
1442 | + buffer.length = ACPI_ALLOCATE_BUFFER; |
1443 | continue; |
1444 | + } |
1445 | |
1446 | obj = (union acpi_object *)buffer.pointer; |
1447 | if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { |
1448 | diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c |
1449 | index 36ca2cf419bfe..57ab79fbcee95 100644 |
1450 | --- a/drivers/vhost/vhost.c |
1451 | +++ b/drivers/vhost/vhost.c |
1452 | @@ -1299,6 +1299,11 @@ static bool vq_access_ok(struct vhost_virtqueue *vq, unsigned int num, |
1453 | struct vring_used __user *used) |
1454 | |
1455 | { |
1456 | + /* If an IOTLB device is present, the vring addresses are |
1457 | + * GIOVAs. Access validation occurs at prefetch time. */ |
1458 | + if (vq->iotlb) |
1459 | + return true; |
1460 | + |
1461 | return access_ok(desc, vhost_get_desc_size(vq, num)) && |
1462 | access_ok(avail, vhost_get_avail_size(vq, num)) && |
1463 | access_ok(used, vhost_get_used_size(vq, num)); |
1464 | @@ -1394,10 +1399,6 @@ bool vhost_vq_access_ok(struct vhost_virtqueue *vq) |
1465 | if (!vq_log_access_ok(vq, vq->log_base)) |
1466 | return false; |
1467 | |
1468 | - /* Access validation occurs at prefetch time with IOTLB */ |
1469 | - if (vq->iotlb) |
1470 | - return true; |
1471 | - |
1472 | return vq_access_ok(vq, vq->num, vq->desc, vq->avail, vq->used); |
1473 | } |
1474 | EXPORT_SYMBOL_GPL(vhost_vq_access_ok); |
1475 | @@ -1544,8 +1545,7 @@ static long vhost_vring_set_addr(struct vhost_dev *d, |
1476 | /* Also validate log access for used ring if enabled. */ |
1477 | if ((a.flags & (0x1 << VHOST_VRING_F_LOG)) && |
1478 | !log_access_ok(vq->log_base, a.log_guest_addr, |
1479 | - sizeof *vq->used + |
1480 | - vq->num * sizeof *vq->used->ring)) |
1481 | + vhost_get_used_size(vq, vq->num))) |
1482 | return -EINVAL; |
1483 | } |
1484 | |
1485 | diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c |
1486 | index 2d2ee17052e83..f45de374f165f 100644 |
1487 | --- a/drivers/video/console/newport_con.c |
1488 | +++ b/drivers/video/console/newport_con.c |
1489 | @@ -36,12 +36,6 @@ |
1490 | |
1491 | #define FONT_DATA ((unsigned char *)font_vga_8x16.data) |
1492 | |
1493 | -/* borrowed from fbcon.c */ |
1494 | -#define REFCOUNT(fd) (((int *)(fd))[-1]) |
1495 | -#define FNTSIZE(fd) (((int *)(fd))[-2]) |
1496 | -#define FNTCHARCNT(fd) (((int *)(fd))[-3]) |
1497 | -#define FONT_EXTRA_WORDS 3 |
1498 | - |
1499 | static unsigned char *font_data[MAX_NR_CONSOLES]; |
1500 | |
1501 | static struct newport_regs *npregs; |
1502 | @@ -523,6 +517,7 @@ static int newport_set_font(int unit, struct console_font *op) |
1503 | FNTSIZE(new_data) = size; |
1504 | FNTCHARCNT(new_data) = op->charcount; |
1505 | REFCOUNT(new_data) = 0; /* usage counter */ |
1506 | + FNTSUM(new_data) = 0; |
1507 | |
1508 | p = new_data; |
1509 | for (i = 0; i < op->charcount; i++) { |
1510 | diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c |
1511 | index dc7f5c4f0607e..4cf71ee0965a6 100644 |
1512 | --- a/drivers/video/fbdev/core/fbcon.c |
1513 | +++ b/drivers/video/fbdev/core/fbcon.c |
1514 | @@ -2292,6 +2292,9 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) |
1515 | |
1516 | if (font->width <= 8) { |
1517 | j = vc->vc_font.height; |
1518 | + if (font->charcount * j > FNTSIZE(fontdata)) |
1519 | + return -EINVAL; |
1520 | + |
1521 | for (i = 0; i < font->charcount; i++) { |
1522 | memcpy(data, fontdata, j); |
1523 | memset(data + j, 0, 32 - j); |
1524 | @@ -2300,6 +2303,9 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) |
1525 | } |
1526 | } else if (font->width <= 16) { |
1527 | j = vc->vc_font.height * 2; |
1528 | + if (font->charcount * j > FNTSIZE(fontdata)) |
1529 | + return -EINVAL; |
1530 | + |
1531 | for (i = 0; i < font->charcount; i++) { |
1532 | memcpy(data, fontdata, j); |
1533 | memset(data + j, 0, 64 - j); |
1534 | @@ -2307,6 +2313,9 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) |
1535 | fontdata += j; |
1536 | } |
1537 | } else if (font->width <= 24) { |
1538 | + if (font->charcount * (vc->vc_font.height * sizeof(u32)) > FNTSIZE(fontdata)) |
1539 | + return -EINVAL; |
1540 | + |
1541 | for (i = 0; i < font->charcount; i++) { |
1542 | for (j = 0; j < vc->vc_font.height; j++) { |
1543 | *data++ = fontdata[0]; |
1544 | @@ -2319,6 +2328,9 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) |
1545 | } |
1546 | } else { |
1547 | j = vc->vc_font.height * 4; |
1548 | + if (font->charcount * j > FNTSIZE(fontdata)) |
1549 | + return -EINVAL; |
1550 | + |
1551 | for (i = 0; i < font->charcount; i++) { |
1552 | memcpy(data, fontdata, j); |
1553 | memset(data + j, 0, 128 - j); |
1554 | diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fbcon.h |
1555 | index 78bb14c03643e..9315b360c8981 100644 |
1556 | --- a/drivers/video/fbdev/core/fbcon.h |
1557 | +++ b/drivers/video/fbdev/core/fbcon.h |
1558 | @@ -152,13 +152,6 @@ static inline int attr_col_ec(int shift, struct vc_data *vc, |
1559 | #define attr_bgcol_ec(bgshift, vc, info) attr_col_ec(bgshift, vc, info, 0) |
1560 | #define attr_fgcol_ec(fgshift, vc, info) attr_col_ec(fgshift, vc, info, 1) |
1561 | |
1562 | -/* Font */ |
1563 | -#define REFCOUNT(fd) (((int *)(fd))[-1]) |
1564 | -#define FNTSIZE(fd) (((int *)(fd))[-2]) |
1565 | -#define FNTCHARCNT(fd) (((int *)(fd))[-3]) |
1566 | -#define FNTSUM(fd) (((int *)(fd))[-4]) |
1567 | -#define FONT_EXTRA_WORDS 4 |
1568 | - |
1569 | /* |
1570 | * Scroll Method |
1571 | */ |
1572 | diff --git a/drivers/video/fbdev/core/fbcon_rotate.c b/drivers/video/fbdev/core/fbcon_rotate.c |
1573 | index c0d445294aa7c..ac72d4f85f7d0 100644 |
1574 | --- a/drivers/video/fbdev/core/fbcon_rotate.c |
1575 | +++ b/drivers/video/fbdev/core/fbcon_rotate.c |
1576 | @@ -14,6 +14,7 @@ |
1577 | #include <linux/fb.h> |
1578 | #include <linux/vt_kern.h> |
1579 | #include <linux/console.h> |
1580 | +#include <linux/font.h> |
1581 | #include <asm/types.h> |
1582 | #include "fbcon.h" |
1583 | #include "fbcon_rotate.h" |
1584 | diff --git a/drivers/video/fbdev/core/tileblit.c b/drivers/video/fbdev/core/tileblit.c |
1585 | index eb664dbf96f66..adff8d6ffe6f9 100644 |
1586 | --- a/drivers/video/fbdev/core/tileblit.c |
1587 | +++ b/drivers/video/fbdev/core/tileblit.c |
1588 | @@ -13,6 +13,7 @@ |
1589 | #include <linux/fb.h> |
1590 | #include <linux/vt_kern.h> |
1591 | #include <linux/console.h> |
1592 | +#include <linux/font.h> |
1593 | #include <asm/types.h> |
1594 | #include "fbcon.h" |
1595 | |
1596 | diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h |
1597 | index 9a690c10afaa0..23b4f38e23928 100644 |
1598 | --- a/fs/btrfs/ctree.h |
1599 | +++ b/fs/btrfs/ctree.h |
1600 | @@ -2956,6 +2956,8 @@ int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end); |
1601 | loff_t btrfs_remap_file_range(struct file *file_in, loff_t pos_in, |
1602 | struct file *file_out, loff_t pos_out, |
1603 | loff_t len, unsigned int remap_flags); |
1604 | +int btrfs_check_can_nocow(struct btrfs_inode *inode, loff_t pos, |
1605 | + size_t *write_bytes); |
1606 | |
1607 | /* tree-defrag.c */ |
1608 | int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, |
1609 | diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c |
1610 | index 7658f3193175b..388449101705e 100644 |
1611 | --- a/fs/btrfs/extent-tree.c |
1612 | +++ b/fs/btrfs/extent-tree.c |
1613 | @@ -1305,8 +1305,10 @@ static int btrfs_issue_discard(struct block_device *bdev, u64 start, u64 len, |
1614 | int btrfs_discard_extent(struct btrfs_fs_info *fs_info, u64 bytenr, |
1615 | u64 num_bytes, u64 *actual_bytes) |
1616 | { |
1617 | - int ret; |
1618 | + int ret = 0; |
1619 | u64 discarded_bytes = 0; |
1620 | + u64 end = bytenr + num_bytes; |
1621 | + u64 cur = bytenr; |
1622 | struct btrfs_bio *bbio = NULL; |
1623 | |
1624 | |
1625 | @@ -1315,15 +1317,23 @@ int btrfs_discard_extent(struct btrfs_fs_info *fs_info, u64 bytenr, |
1626 | * associated to its stripes that don't go away while we are discarding. |
1627 | */ |
1628 | btrfs_bio_counter_inc_blocked(fs_info); |
1629 | - /* Tell the block device(s) that the sectors can be discarded */ |
1630 | - ret = btrfs_map_block(fs_info, BTRFS_MAP_DISCARD, bytenr, &num_bytes, |
1631 | - &bbio, 0); |
1632 | - /* Error condition is -ENOMEM */ |
1633 | - if (!ret) { |
1634 | - struct btrfs_bio_stripe *stripe = bbio->stripes; |
1635 | + while (cur < end) { |
1636 | + struct btrfs_bio_stripe *stripe; |
1637 | int i; |
1638 | |
1639 | + num_bytes = end - cur; |
1640 | + /* Tell the block device(s) that the sectors can be discarded */ |
1641 | + ret = btrfs_map_block(fs_info, BTRFS_MAP_DISCARD, cur, |
1642 | + &num_bytes, &bbio, 0); |
1643 | + /* |
1644 | + * Error can be -ENOMEM, -ENOENT (no such chunk mapping) or |
1645 | + * -EOPNOTSUPP. For any such error, @num_bytes is not updated, |
1646 | + * thus we can't continue anyway. |
1647 | + */ |
1648 | + if (ret < 0) |
1649 | + goto out; |
1650 | |
1651 | + stripe = bbio->stripes; |
1652 | for (i = 0; i < bbio->num_stripes; i++, stripe++) { |
1653 | u64 bytes; |
1654 | struct request_queue *req_q; |
1655 | @@ -1340,10 +1350,19 @@ int btrfs_discard_extent(struct btrfs_fs_info *fs_info, u64 bytenr, |
1656 | stripe->physical, |
1657 | stripe->length, |
1658 | &bytes); |
1659 | - if (!ret) |
1660 | + if (!ret) { |
1661 | discarded_bytes += bytes; |
1662 | - else if (ret != -EOPNOTSUPP) |
1663 | - break; /* Logic errors or -ENOMEM, or -EIO but I don't know how that could happen JDM */ |
1664 | + } else if (ret != -EOPNOTSUPP) { |
1665 | + /* |
1666 | + * Logic errors or -ENOMEM, or -EIO, but |
1667 | + * unlikely to happen. |
1668 | + * |
1669 | + * And since there are two loops, explicitly |
1670 | + * go to out to avoid confusion. |
1671 | + */ |
1672 | + btrfs_put_bbio(bbio); |
1673 | + goto out; |
1674 | + } |
1675 | |
1676 | /* |
1677 | * Just in case we get back EOPNOTSUPP for some reason, |
1678 | @@ -1353,7 +1372,9 @@ int btrfs_discard_extent(struct btrfs_fs_info *fs_info, u64 bytenr, |
1679 | ret = 0; |
1680 | } |
1681 | btrfs_put_bbio(bbio); |
1682 | + cur += num_bytes; |
1683 | } |
1684 | +out: |
1685 | btrfs_bio_counter_dec(fs_info); |
1686 | |
1687 | if (actual_bytes) |
1688 | diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c |
1689 | index 4e4ddd5629e55..4126513e2429c 100644 |
1690 | --- a/fs/btrfs/file.c |
1691 | +++ b/fs/btrfs/file.c |
1692 | @@ -1546,8 +1546,8 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages, |
1693 | return ret; |
1694 | } |
1695 | |
1696 | -static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos, |
1697 | - size_t *write_bytes) |
1698 | +int btrfs_check_can_nocow(struct btrfs_inode *inode, loff_t pos, |
1699 | + size_t *write_bytes) |
1700 | { |
1701 | struct btrfs_fs_info *fs_info = inode->root->fs_info; |
1702 | struct btrfs_root *root = inode->root; |
1703 | @@ -1647,7 +1647,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb, |
1704 | if (ret < 0) { |
1705 | if ((BTRFS_I(inode)->flags & (BTRFS_INODE_NODATACOW | |
1706 | BTRFS_INODE_PREALLOC)) && |
1707 | - check_can_nocow(BTRFS_I(inode), pos, |
1708 | + btrfs_check_can_nocow(BTRFS_I(inode), pos, |
1709 | &write_bytes) > 0) { |
1710 | /* |
1711 | * For nodata cow case, no need to reserve |
1712 | @@ -1919,13 +1919,28 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, |
1713 | pos = iocb->ki_pos; |
1714 | count = iov_iter_count(from); |
1715 | if (iocb->ki_flags & IOCB_NOWAIT) { |
1716 | + size_t nocow_bytes = count; |
1717 | + |
1718 | /* |
1719 | * We will allocate space in case nodatacow is not set, |
1720 | * so bail |
1721 | */ |
1722 | if (!(BTRFS_I(inode)->flags & (BTRFS_INODE_NODATACOW | |
1723 | BTRFS_INODE_PREALLOC)) || |
1724 | - check_can_nocow(BTRFS_I(inode), pos, &count) <= 0) { |
1725 | + btrfs_check_can_nocow(BTRFS_I(inode), pos, |
1726 | + &nocow_bytes) <= 0) { |
1727 | + inode_unlock(inode); |
1728 | + return -EAGAIN; |
1729 | + } |
1730 | + |
1731 | + /* check_can_nocow() locks the snapshot lock on success */ |
1732 | + btrfs_end_write_no_snapshotting(root); |
1733 | + /* |
1734 | + * There are holes in the range or parts of the range that must |
1735 | + * be COWed (shared extents, RO block groups, etc), so just bail |
1736 | + * out. |
1737 | + */ |
1738 | + if (nocow_bytes < count) { |
1739 | inode_unlock(inode); |
1740 | return -EAGAIN; |
1741 | } |
1742 | diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c |
1743 | index 182e93a5b11d5..67b49b94c9cd6 100644 |
1744 | --- a/fs/btrfs/inode.c |
1745 | +++ b/fs/btrfs/inode.c |
1746 | @@ -5133,11 +5133,13 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len, |
1747 | struct extent_state *cached_state = NULL; |
1748 | struct extent_changeset *data_reserved = NULL; |
1749 | char *kaddr; |
1750 | + bool only_release_metadata = false; |
1751 | u32 blocksize = fs_info->sectorsize; |
1752 | pgoff_t index = from >> PAGE_SHIFT; |
1753 | unsigned offset = from & (blocksize - 1); |
1754 | struct page *page; |
1755 | gfp_t mask = btrfs_alloc_write_mask(mapping); |
1756 | + size_t write_bytes = blocksize; |
1757 | int ret = 0; |
1758 | u64 block_start; |
1759 | u64 block_end; |
1760 | @@ -5149,11 +5151,27 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len, |
1761 | block_start = round_down(from, blocksize); |
1762 | block_end = block_start + blocksize - 1; |
1763 | |
1764 | - ret = btrfs_delalloc_reserve_space(inode, &data_reserved, |
1765 | - block_start, blocksize); |
1766 | - if (ret) |
1767 | - goto out; |
1768 | |
1769 | + ret = btrfs_check_data_free_space(inode, &data_reserved, block_start, |
1770 | + blocksize); |
1771 | + if (ret < 0) { |
1772 | + if ((BTRFS_I(inode)->flags & (BTRFS_INODE_NODATACOW | |
1773 | + BTRFS_INODE_PREALLOC)) && |
1774 | + btrfs_check_can_nocow(BTRFS_I(inode), block_start, |
1775 | + &write_bytes) > 0) { |
1776 | + /* For nocow case, no need to reserve data space */ |
1777 | + only_release_metadata = true; |
1778 | + } else { |
1779 | + goto out; |
1780 | + } |
1781 | + } |
1782 | + ret = btrfs_delalloc_reserve_metadata(BTRFS_I(inode), blocksize); |
1783 | + if (ret < 0) { |
1784 | + if (!only_release_metadata) |
1785 | + btrfs_free_reserved_data_space(inode, data_reserved, |
1786 | + block_start, blocksize); |
1787 | + goto out; |
1788 | + } |
1789 | again: |
1790 | page = find_or_create_page(mapping, index, mask); |
1791 | if (!page) { |
1792 | @@ -5222,14 +5240,26 @@ again: |
1793 | set_page_dirty(page); |
1794 | unlock_extent_cached(io_tree, block_start, block_end, &cached_state); |
1795 | |
1796 | + if (only_release_metadata) |
1797 | + set_extent_bit(&BTRFS_I(inode)->io_tree, block_start, |
1798 | + block_end, EXTENT_NORESERVE, NULL, NULL, |
1799 | + GFP_NOFS); |
1800 | + |
1801 | out_unlock: |
1802 | - if (ret) |
1803 | - btrfs_delalloc_release_space(inode, data_reserved, block_start, |
1804 | - blocksize, true); |
1805 | + if (ret) { |
1806 | + if (only_release_metadata) |
1807 | + btrfs_delalloc_release_metadata(BTRFS_I(inode), |
1808 | + blocksize, true); |
1809 | + else |
1810 | + btrfs_delalloc_release_space(inode, data_reserved, |
1811 | + block_start, blocksize, true); |
1812 | + } |
1813 | btrfs_delalloc_release_extents(BTRFS_I(inode), blocksize); |
1814 | unlock_page(page); |
1815 | put_page(page); |
1816 | out: |
1817 | + if (only_release_metadata) |
1818 | + btrfs_end_write_no_snapshotting(BTRFS_I(inode)->root); |
1819 | extent_changeset_free(data_reserved); |
1820 | return ret; |
1821 | } |
1822 | diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c |
1823 | index 6ad216e8178e8..b0e5dfb9be7ab 100644 |
1824 | --- a/fs/btrfs/send.c |
1825 | +++ b/fs/btrfs/send.c |
1826 | @@ -1257,12 +1257,21 @@ static int __iterate_backrefs(u64 ino, u64 offset, u64 root, void *ctx_) |
1827 | */ |
1828 | if (found->root == bctx->sctx->send_root) { |
1829 | /* |
1830 | - * TODO for the moment we don't accept clones from the inode |
1831 | - * that is currently send. We may change this when |
1832 | - * BTRFS_IOC_CLONE_RANGE supports cloning from and to the same |
1833 | - * file. |
1834 | + * If the source inode was not yet processed we can't issue a |
1835 | + * clone operation, as the source extent does not exist yet at |
1836 | + * the destination of the stream. |
1837 | */ |
1838 | - if (ino >= bctx->cur_objectid) |
1839 | + if (ino > bctx->cur_objectid) |
1840 | + return 0; |
1841 | + /* |
1842 | + * We clone from the inode currently being sent as long as the |
1843 | + * source extent is already processed, otherwise we could try |
1844 | + * to clone from an extent that does not exist yet at the |
1845 | + * destination of the stream. |
1846 | + */ |
1847 | + if (ino == bctx->cur_objectid && |
1848 | + offset + bctx->extent_len > |
1849 | + bctx->sctx->cur_inode_next_write_offset) |
1850 | return 0; |
1851 | } |
1852 | |
1853 | diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c |
1854 | index 4ecd6663dfb51..e798caee978e7 100644 |
1855 | --- a/fs/btrfs/volumes.c |
1856 | +++ b/fs/btrfs/volumes.c |
1857 | @@ -5676,12 +5676,13 @@ void btrfs_put_bbio(struct btrfs_bio *bbio) |
1858 | * replace. |
1859 | */ |
1860 | static int __btrfs_map_block_for_discard(struct btrfs_fs_info *fs_info, |
1861 | - u64 logical, u64 length, |
1862 | + u64 logical, u64 *length_ret, |
1863 | struct btrfs_bio **bbio_ret) |
1864 | { |
1865 | struct extent_map *em; |
1866 | struct map_lookup *map; |
1867 | struct btrfs_bio *bbio; |
1868 | + u64 length = *length_ret; |
1869 | u64 offset; |
1870 | u64 stripe_nr; |
1871 | u64 stripe_nr_end; |
1872 | @@ -5714,7 +5715,8 @@ static int __btrfs_map_block_for_discard(struct btrfs_fs_info *fs_info, |
1873 | } |
1874 | |
1875 | offset = logical - em->start; |
1876 | - length = min_t(u64, em->len - offset, length); |
1877 | + length = min_t(u64, em->start + em->len - logical, length); |
1878 | + *length_ret = length; |
1879 | |
1880 | stripe_len = map->stripe_len; |
1881 | /* |
1882 | @@ -6129,7 +6131,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, |
1883 | |
1884 | if (op == BTRFS_MAP_DISCARD) |
1885 | return __btrfs_map_block_for_discard(fs_info, logical, |
1886 | - *length, bbio_ret); |
1887 | + length, bbio_ret); |
1888 | |
1889 | ret = btrfs_get_io_geometry(fs_info, op, logical, *length, &geom); |
1890 | if (ret < 0) |
1891 | diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c |
1892 | index 64ad466695c55..9a89e5f7c4da3 100644 |
1893 | --- a/fs/cifs/smb2ops.c |
1894 | +++ b/fs/cifs/smb2ops.c |
1895 | @@ -1179,7 +1179,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, |
1896 | rqst[1].rq_iov = si_iov; |
1897 | rqst[1].rq_nvec = 1; |
1898 | |
1899 | - len = sizeof(ea) + ea_name_len + ea_value_len + 1; |
1900 | + len = sizeof(*ea) + ea_name_len + ea_value_len + 1; |
1901 | ea = kzalloc(len, GFP_KERNEL); |
1902 | if (ea == NULL) { |
1903 | rc = -ENOMEM; |
1904 | diff --git a/fs/io_uring.c b/fs/io_uring.c |
1905 | index 2a539b794f3b0..4127ea027a14d 100644 |
1906 | --- a/fs/io_uring.c |
1907 | +++ b/fs/io_uring.c |
1908 | @@ -340,7 +340,7 @@ struct io_kiocb { |
1909 | u64 user_data; |
1910 | u32 result; |
1911 | u32 sequence; |
1912 | - struct task_struct *task; |
1913 | + struct files_struct *files; |
1914 | |
1915 | struct fs_struct *fs; |
1916 | |
1917 | @@ -514,12 +514,14 @@ static inline void io_queue_async_work(struct io_ring_ctx *ctx, |
1918 | } |
1919 | } |
1920 | |
1921 | - req->task = current; |
1922 | + if (req->work.func == io_sq_wq_submit_work) { |
1923 | + req->files = current->files; |
1924 | |
1925 | - spin_lock_irqsave(&ctx->task_lock, flags); |
1926 | - list_add(&req->task_list, &ctx->task_list); |
1927 | - req->work_task = NULL; |
1928 | - spin_unlock_irqrestore(&ctx->task_lock, flags); |
1929 | + spin_lock_irqsave(&ctx->task_lock, flags); |
1930 | + list_add(&req->task_list, &ctx->task_list); |
1931 | + req->work_task = NULL; |
1932 | + spin_unlock_irqrestore(&ctx->task_lock, flags); |
1933 | + } |
1934 | |
1935 | queue_work(ctx->sqo_wq[rw], &req->work); |
1936 | } |
1937 | @@ -668,6 +670,7 @@ static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx, |
1938 | state->cur_req++; |
1939 | } |
1940 | |
1941 | + INIT_LIST_HEAD(&req->task_list); |
1942 | req->file = NULL; |
1943 | req->ctx = ctx; |
1944 | req->flags = 0; |
1945 | @@ -2247,6 +2250,12 @@ restart: |
1946 | |
1947 | if (!ret) { |
1948 | req->work_task = current; |
1949 | + |
1950 | + /* |
1951 | + * Pairs with the smp_store_mb() (B) in |
1952 | + * io_cancel_async_work(). |
1953 | + */ |
1954 | + smp_mb(); /* A */ |
1955 | if (req->flags & REQ_F_CANCEL) { |
1956 | ret = -ECANCELED; |
1957 | goto end_req; |
1958 | @@ -2266,13 +2275,11 @@ restart: |
1959 | break; |
1960 | cond_resched(); |
1961 | } while (1); |
1962 | -end_req: |
1963 | - if (!list_empty(&req->task_list)) { |
1964 | - spin_lock_irq(&ctx->task_lock); |
1965 | - list_del_init(&req->task_list); |
1966 | - spin_unlock_irq(&ctx->task_lock); |
1967 | - } |
1968 | } |
1969 | +end_req: |
1970 | + spin_lock_irq(&ctx->task_lock); |
1971 | + list_del_init(&req->task_list); |
1972 | + spin_unlock_irq(&ctx->task_lock); |
1973 | |
1974 | /* drop submission reference */ |
1975 | io_put_req(req); |
1976 | @@ -2382,6 +2389,8 @@ static bool io_add_to_prev_work(struct async_list *list, struct io_kiocb *req) |
1977 | if (ret) { |
1978 | struct io_ring_ctx *ctx = req->ctx; |
1979 | |
1980 | + req->files = current->files; |
1981 | + |
1982 | spin_lock_irq(&ctx->task_lock); |
1983 | list_add(&req->task_list, &ctx->task_list); |
1984 | req->work_task = NULL; |
1985 | @@ -3712,19 +3721,28 @@ static int io_uring_fasync(int fd, struct file *file, int on) |
1986 | } |
1987 | |
1988 | static void io_cancel_async_work(struct io_ring_ctx *ctx, |
1989 | - struct task_struct *task) |
1990 | + struct files_struct *files) |
1991 | { |
1992 | + struct io_kiocb *req; |
1993 | + |
1994 | if (list_empty(&ctx->task_list)) |
1995 | return; |
1996 | |
1997 | spin_lock_irq(&ctx->task_lock); |
1998 | - while (!list_empty(&ctx->task_list)) { |
1999 | - struct io_kiocb *req; |
2000 | |
2001 | - req = list_first_entry(&ctx->task_list, struct io_kiocb, task_list); |
2002 | - list_del_init(&req->task_list); |
2003 | - req->flags |= REQ_F_CANCEL; |
2004 | - if (req->work_task && (!task || req->task == task)) |
2005 | + list_for_each_entry(req, &ctx->task_list, task_list) { |
2006 | + if (files && req->files != files) |
2007 | + continue; |
2008 | + |
2009 | + /* |
2010 | + * The below executes an smp_mb(), which matches with the |
2011 | + * smp_mb() (A) in io_sq_wq_submit_work() such that either |
2012 | + * we store REQ_F_CANCEL flag to req->flags or we see the |
2013 | + * req->work_task setted in io_sq_wq_submit_work(). |
2014 | + */ |
2015 | + smp_store_mb(req->flags, req->flags | REQ_F_CANCEL); /* B */ |
2016 | + |
2017 | + if (req->work_task) |
2018 | send_sig(SIGINT, req->work_task, 1); |
2019 | } |
2020 | spin_unlock_irq(&ctx->task_lock); |
2021 | @@ -3749,7 +3767,7 @@ static int io_uring_flush(struct file *file, void *data) |
2022 | struct io_ring_ctx *ctx = file->private_data; |
2023 | |
2024 | if (fatal_signal_pending(current) || (current->flags & PF_EXITING)) |
2025 | - io_cancel_async_work(ctx, current); |
2026 | + io_cancel_async_work(ctx, data); |
2027 | |
2028 | return 0; |
2029 | } |
2030 | diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h |
2031 | index f050039ca2c07..e5e2425875953 100644 |
2032 | --- a/include/asm-generic/vmlinux.lds.h |
2033 | +++ b/include/asm-generic/vmlinux.lds.h |
2034 | @@ -599,7 +599,7 @@ |
2035 | #define BTF \ |
2036 | .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) { \ |
2037 | __start_BTF = .; \ |
2038 | - *(.BTF) \ |
2039 | + KEEP(*(.BTF)) \ |
2040 | __stop_BTF = .; \ |
2041 | } |
2042 | #else |
2043 | diff --git a/include/linux/font.h b/include/linux/font.h |
2044 | index 51b91c8b69d58..59faa80f586df 100644 |
2045 | --- a/include/linux/font.h |
2046 | +++ b/include/linux/font.h |
2047 | @@ -59,4 +59,17 @@ extern const struct font_desc *get_default_font(int xres, int yres, |
2048 | /* Max. length for the name of a predefined font */ |
2049 | #define MAX_FONT_NAME 32 |
2050 | |
2051 | +/* Extra word getters */ |
2052 | +#define REFCOUNT(fd) (((int *)(fd))[-1]) |
2053 | +#define FNTSIZE(fd) (((int *)(fd))[-2]) |
2054 | +#define FNTCHARCNT(fd) (((int *)(fd))[-3]) |
2055 | +#define FNTSUM(fd) (((int *)(fd))[-4]) |
2056 | + |
2057 | +#define FONT_EXTRA_WORDS 4 |
2058 | + |
2059 | +struct font_data { |
2060 | + unsigned int extra[FONT_EXTRA_WORDS]; |
2061 | + const unsigned char data[]; |
2062 | +} __packed; |
2063 | + |
2064 | #endif /* _VIDEO_FONT_H */ |
2065 | diff --git a/include/linux/khugepaged.h b/include/linux/khugepaged.h |
2066 | index bc45ea1efbf79..c941b73773216 100644 |
2067 | --- a/include/linux/khugepaged.h |
2068 | +++ b/include/linux/khugepaged.h |
2069 | @@ -15,6 +15,7 @@ extern int __khugepaged_enter(struct mm_struct *mm); |
2070 | extern void __khugepaged_exit(struct mm_struct *mm); |
2071 | extern int khugepaged_enter_vma_merge(struct vm_area_struct *vma, |
2072 | unsigned long vm_flags); |
2073 | +extern void khugepaged_min_free_kbytes_update(void); |
2074 | #ifdef CONFIG_SHMEM |
2075 | extern void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr); |
2076 | #else |
2077 | @@ -85,6 +86,10 @@ static inline void collapse_pte_mapped_thp(struct mm_struct *mm, |
2078 | unsigned long addr) |
2079 | { |
2080 | } |
2081 | + |
2082 | +static inline void khugepaged_min_free_kbytes_update(void) |
2083 | +{ |
2084 | +} |
2085 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ |
2086 | |
2087 | #endif /* _LINUX_KHUGEPAGED_H */ |
2088 | diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h |
2089 | index 897829651204b..6b4f86dfca382 100644 |
2090 | --- a/include/linux/mlx5/driver.h |
2091 | +++ b/include/linux/mlx5/driver.h |
2092 | @@ -769,6 +769,8 @@ struct mlx5_cmd_work_ent { |
2093 | u64 ts2; |
2094 | u16 op; |
2095 | bool polling; |
2096 | + /* Track the max comp handlers */ |
2097 | + refcount_t refcnt; |
2098 | }; |
2099 | |
2100 | struct mlx5_pas { |
2101 | diff --git a/include/linux/net.h b/include/linux/net.h |
2102 | index 9cafb5f353a97..47dd7973ae9bc 100644 |
2103 | --- a/include/linux/net.h |
2104 | +++ b/include/linux/net.h |
2105 | @@ -21,6 +21,7 @@ |
2106 | #include <linux/rcupdate.h> |
2107 | #include <linux/once.h> |
2108 | #include <linux/fs.h> |
2109 | +#include <linux/mm.h> |
2110 | |
2111 | #include <uapi/linux/net.h> |
2112 | |
2113 | @@ -288,6 +289,21 @@ do { \ |
2114 | #define net_get_random_once_wait(buf, nbytes) \ |
2115 | get_random_once_wait((buf), (nbytes)) |
2116 | |
2117 | +/* |
2118 | + * E.g. XFS meta- & log-data is in slab pages, or bcache meta |
2119 | + * data pages, or other high order pages allocated by |
2120 | + * __get_free_pages() without __GFP_COMP, which have a page_count |
2121 | + * of 0 and/or have PageSlab() set. We cannot use send_page for |
2122 | + * those, as that does get_page(); put_page(); and would cause |
2123 | + * either a VM_BUG directly, or __page_cache_release a page that |
2124 | + * would actually still be referenced by someone, leading to some |
2125 | + * obscure delayed Oops somewhere else. |
2126 | + */ |
2127 | +static inline bool sendpage_ok(struct page *page) |
2128 | +{ |
2129 | + return !PageSlab(page) && page_count(page) >= 1; |
2130 | +} |
2131 | + |
2132 | int kernel_sendmsg(struct socket *sock, struct msghdr *msg, struct kvec *vec, |
2133 | size_t num, size_t len); |
2134 | int kernel_sendmsg_locked(struct sock *sk, struct msghdr *msg, |
2135 | diff --git a/include/net/act_api.h b/include/net/act_api.h |
2136 | index 59d05feecfb8a..05b568b92e59d 100644 |
2137 | --- a/include/net/act_api.h |
2138 | +++ b/include/net/act_api.h |
2139 | @@ -156,8 +156,6 @@ int tcf_idr_search(struct tc_action_net *tn, struct tc_action **a, u32 index); |
2140 | int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est, |
2141 | struct tc_action **a, const struct tc_action_ops *ops, |
2142 | int bind, bool cpustats); |
2143 | -void tcf_idr_insert(struct tc_action_net *tn, struct tc_action *a); |
2144 | - |
2145 | void tcf_idr_cleanup(struct tc_action_net *tn, u32 index); |
2146 | int tcf_idr_check_alloc(struct tc_action_net *tn, u32 *index, |
2147 | struct tc_action **a, int bind); |
2148 | diff --git a/include/net/xfrm.h b/include/net/xfrm.h |
2149 | index 12aa6e15e43f6..c00b9ae71ae40 100644 |
2150 | --- a/include/net/xfrm.h |
2151 | +++ b/include/net/xfrm.h |
2152 | @@ -1773,21 +1773,17 @@ static inline unsigned int xfrm_replay_state_esn_len(struct xfrm_replay_state_es |
2153 | static inline int xfrm_replay_clone(struct xfrm_state *x, |
2154 | struct xfrm_state *orig) |
2155 | { |
2156 | - x->replay_esn = kzalloc(xfrm_replay_state_esn_len(orig->replay_esn), |
2157 | + |
2158 | + x->replay_esn = kmemdup(orig->replay_esn, |
2159 | + xfrm_replay_state_esn_len(orig->replay_esn), |
2160 | GFP_KERNEL); |
2161 | if (!x->replay_esn) |
2162 | return -ENOMEM; |
2163 | - |
2164 | - x->replay_esn->bmp_len = orig->replay_esn->bmp_len; |
2165 | - x->replay_esn->replay_window = orig->replay_esn->replay_window; |
2166 | - |
2167 | - x->preplay_esn = kmemdup(x->replay_esn, |
2168 | - xfrm_replay_state_esn_len(x->replay_esn), |
2169 | + x->preplay_esn = kmemdup(orig->preplay_esn, |
2170 | + xfrm_replay_state_esn_len(orig->preplay_esn), |
2171 | GFP_KERNEL); |
2172 | - if (!x->preplay_esn) { |
2173 | - kfree(x->replay_esn); |
2174 | + if (!x->preplay_esn) |
2175 | return -ENOMEM; |
2176 | - } |
2177 | |
2178 | return 0; |
2179 | } |
2180 | diff --git a/kernel/bpf/sysfs_btf.c b/kernel/bpf/sysfs_btf.c |
2181 | index 3b495773de5ae..11b3380887fa0 100644 |
2182 | --- a/kernel/bpf/sysfs_btf.c |
2183 | +++ b/kernel/bpf/sysfs_btf.c |
2184 | @@ -30,15 +30,15 @@ static struct kobject *btf_kobj; |
2185 | |
2186 | static int __init btf_vmlinux_init(void) |
2187 | { |
2188 | - if (!__start_BTF) |
2189 | + bin_attr_btf_vmlinux.size = __stop_BTF - __start_BTF; |
2190 | + |
2191 | + if (!__start_BTF || bin_attr_btf_vmlinux.size == 0) |
2192 | return 0; |
2193 | |
2194 | btf_kobj = kobject_create_and_add("btf", kernel_kobj); |
2195 | if (!btf_kobj) |
2196 | return -ENOMEM; |
2197 | |
2198 | - bin_attr_btf_vmlinux.size = __stop_BTF - __start_BTF; |
2199 | - |
2200 | return sysfs_create_bin_file(btf_kobj, &bin_attr_btf_vmlinux); |
2201 | } |
2202 | |
2203 | diff --git a/kernel/events/core.c b/kernel/events/core.c |
2204 | index 47646050efa0c..09e1cc22221fe 100644 |
2205 | --- a/kernel/events/core.c |
2206 | +++ b/kernel/events/core.c |
2207 | @@ -97,7 +97,7 @@ static void remote_function(void *data) |
2208 | * retry due to any failures in smp_call_function_single(), such as if the |
2209 | * task_cpu() goes offline concurrently. |
2210 | * |
2211 | - * returns @func return value or -ESRCH when the process isn't running |
2212 | + * returns @func return value or -ESRCH or -ENXIO when the process isn't running |
2213 | */ |
2214 | static int |
2215 | task_function_call(struct task_struct *p, remote_function_f func, void *info) |
2216 | @@ -113,7 +113,8 @@ task_function_call(struct task_struct *p, remote_function_f func, void *info) |
2217 | for (;;) { |
2218 | ret = smp_call_function_single(task_cpu(p), remote_function, |
2219 | &data, 1); |
2220 | - ret = !ret ? data.ret : -EAGAIN; |
2221 | + if (!ret) |
2222 | + ret = data.ret; |
2223 | |
2224 | if (ret != -EAGAIN) |
2225 | break; |
2226 | diff --git a/kernel/umh.c b/kernel/umh.c |
2227 | index 3474d6aa55d83..b8c524dcc76f1 100644 |
2228 | --- a/kernel/umh.c |
2229 | +++ b/kernel/umh.c |
2230 | @@ -14,6 +14,7 @@ |
2231 | #include <linux/cred.h> |
2232 | #include <linux/file.h> |
2233 | #include <linux/fdtable.h> |
2234 | +#include <linux/fs_struct.h> |
2235 | #include <linux/workqueue.h> |
2236 | #include <linux/security.h> |
2237 | #include <linux/mount.h> |
2238 | @@ -75,6 +76,14 @@ static int call_usermodehelper_exec_async(void *data) |
2239 | flush_signal_handlers(current, 1); |
2240 | spin_unlock_irq(¤t->sighand->siglock); |
2241 | |
2242 | + /* |
2243 | + * Initial kernel threads share ther FS with init, in order to |
2244 | + * get the init root directory. But we've now created a new |
2245 | + * thread that is going to execve a user process and has its own |
2246 | + * 'struct fs_struct'. Reset umask to the default. |
2247 | + */ |
2248 | + current->fs->umask = 0022; |
2249 | + |
2250 | /* |
2251 | * Our parent (unbound workqueue) runs with elevated scheduling |
2252 | * priority. Avoid propagating that into the userspace child. |
2253 | diff --git a/lib/fonts/font_10x18.c b/lib/fonts/font_10x18.c |
2254 | index 532f0ff89a962..0e2deac97da0d 100644 |
2255 | --- a/lib/fonts/font_10x18.c |
2256 | +++ b/lib/fonts/font_10x18.c |
2257 | @@ -8,8 +8,8 @@ |
2258 | |
2259 | #define FONTDATAMAX 9216 |
2260 | |
2261 | -static const unsigned char fontdata_10x18[FONTDATAMAX] = { |
2262 | - |
2263 | +static struct font_data fontdata_10x18 = { |
2264 | + { 0, 0, FONTDATAMAX, 0 }, { |
2265 | /* 0 0x00 '^@' */ |
2266 | 0x00, 0x00, /* 0000000000 */ |
2267 | 0x00, 0x00, /* 0000000000 */ |
2268 | @@ -5129,8 +5129,7 @@ static const unsigned char fontdata_10x18[FONTDATAMAX] = { |
2269 | 0x00, 0x00, /* 0000000000 */ |
2270 | 0x00, 0x00, /* 0000000000 */ |
2271 | 0x00, 0x00, /* 0000000000 */ |
2272 | - |
2273 | -}; |
2274 | +} }; |
2275 | |
2276 | |
2277 | const struct font_desc font_10x18 = { |
2278 | @@ -5138,7 +5137,7 @@ const struct font_desc font_10x18 = { |
2279 | .name = "10x18", |
2280 | .width = 10, |
2281 | .height = 18, |
2282 | - .data = fontdata_10x18, |
2283 | + .data = fontdata_10x18.data, |
2284 | #ifdef __sparc__ |
2285 | .pref = 5, |
2286 | #else |
2287 | diff --git a/lib/fonts/font_6x10.c b/lib/fonts/font_6x10.c |
2288 | index 09b2cc03435b9..87da8acd07db0 100644 |
2289 | --- a/lib/fonts/font_6x10.c |
2290 | +++ b/lib/fonts/font_6x10.c |
2291 | @@ -1,8 +1,10 @@ |
2292 | // SPDX-License-Identifier: GPL-2.0 |
2293 | #include <linux/font.h> |
2294 | |
2295 | -static const unsigned char fontdata_6x10[] = { |
2296 | +#define FONTDATAMAX 2560 |
2297 | |
2298 | +static struct font_data fontdata_6x10 = { |
2299 | + { 0, 0, FONTDATAMAX, 0 }, { |
2300 | /* 0 0x00 '^@' */ |
2301 | 0x00, /* 00000000 */ |
2302 | 0x00, /* 00000000 */ |
2303 | @@ -3074,14 +3076,13 @@ static const unsigned char fontdata_6x10[] = { |
2304 | 0x00, /* 00000000 */ |
2305 | 0x00, /* 00000000 */ |
2306 | 0x00, /* 00000000 */ |
2307 | - |
2308 | -}; |
2309 | +} }; |
2310 | |
2311 | const struct font_desc font_6x10 = { |
2312 | .idx = FONT6x10_IDX, |
2313 | .name = "6x10", |
2314 | .width = 6, |
2315 | .height = 10, |
2316 | - .data = fontdata_6x10, |
2317 | + .data = fontdata_6x10.data, |
2318 | .pref = 0, |
2319 | }; |
2320 | diff --git a/lib/fonts/font_6x11.c b/lib/fonts/font_6x11.c |
2321 | index d7136c33f1f01..5e975dfa10a53 100644 |
2322 | --- a/lib/fonts/font_6x11.c |
2323 | +++ b/lib/fonts/font_6x11.c |
2324 | @@ -9,8 +9,8 @@ |
2325 | |
2326 | #define FONTDATAMAX (11*256) |
2327 | |
2328 | -static const unsigned char fontdata_6x11[FONTDATAMAX] = { |
2329 | - |
2330 | +static struct font_data fontdata_6x11 = { |
2331 | + { 0, 0, FONTDATAMAX, 0 }, { |
2332 | /* 0 0x00 '^@' */ |
2333 | 0x00, /* 00000000 */ |
2334 | 0x00, /* 00000000 */ |
2335 | @@ -3338,8 +3338,7 @@ static const unsigned char fontdata_6x11[FONTDATAMAX] = { |
2336 | 0x00, /* 00000000 */ |
2337 | 0x00, /* 00000000 */ |
2338 | 0x00, /* 00000000 */ |
2339 | - |
2340 | -}; |
2341 | +} }; |
2342 | |
2343 | |
2344 | const struct font_desc font_vga_6x11 = { |
2345 | @@ -3347,7 +3346,7 @@ const struct font_desc font_vga_6x11 = { |
2346 | .name = "ProFont6x11", |
2347 | .width = 6, |
2348 | .height = 11, |
2349 | - .data = fontdata_6x11, |
2350 | + .data = fontdata_6x11.data, |
2351 | /* Try avoiding this font if possible unless on MAC */ |
2352 | .pref = -2000, |
2353 | }; |
2354 | diff --git a/lib/fonts/font_7x14.c b/lib/fonts/font_7x14.c |
2355 | index 89752d0b23e8b..86d298f385058 100644 |
2356 | --- a/lib/fonts/font_7x14.c |
2357 | +++ b/lib/fonts/font_7x14.c |
2358 | @@ -8,8 +8,8 @@ |
2359 | |
2360 | #define FONTDATAMAX 3584 |
2361 | |
2362 | -static const unsigned char fontdata_7x14[FONTDATAMAX] = { |
2363 | - |
2364 | +static struct font_data fontdata_7x14 = { |
2365 | + { 0, 0, FONTDATAMAX, 0 }, { |
2366 | /* 0 0x00 '^@' */ |
2367 | 0x00, /* 0000000 */ |
2368 | 0x00, /* 0000000 */ |
2369 | @@ -4105,8 +4105,7 @@ static const unsigned char fontdata_7x14[FONTDATAMAX] = { |
2370 | 0x00, /* 0000000 */ |
2371 | 0x00, /* 0000000 */ |
2372 | 0x00, /* 0000000 */ |
2373 | - |
2374 | -}; |
2375 | +} }; |
2376 | |
2377 | |
2378 | const struct font_desc font_7x14 = { |
2379 | @@ -4114,6 +4113,6 @@ const struct font_desc font_7x14 = { |
2380 | .name = "7x14", |
2381 | .width = 7, |
2382 | .height = 14, |
2383 | - .data = fontdata_7x14, |
2384 | + .data = fontdata_7x14.data, |
2385 | .pref = 0, |
2386 | }; |
2387 | diff --git a/lib/fonts/font_8x16.c b/lib/fonts/font_8x16.c |
2388 | index b7ab1f5fbdb8a..37cedd36ca5ef 100644 |
2389 | --- a/lib/fonts/font_8x16.c |
2390 | +++ b/lib/fonts/font_8x16.c |
2391 | @@ -10,8 +10,8 @@ |
2392 | |
2393 | #define FONTDATAMAX 4096 |
2394 | |
2395 | -static const unsigned char fontdata_8x16[FONTDATAMAX] = { |
2396 | - |
2397 | +static struct font_data fontdata_8x16 = { |
2398 | + { 0, 0, FONTDATAMAX, 0 }, { |
2399 | /* 0 0x00 '^@' */ |
2400 | 0x00, /* 00000000 */ |
2401 | 0x00, /* 00000000 */ |
2402 | @@ -4619,8 +4619,7 @@ static const unsigned char fontdata_8x16[FONTDATAMAX] = { |
2403 | 0x00, /* 00000000 */ |
2404 | 0x00, /* 00000000 */ |
2405 | 0x00, /* 00000000 */ |
2406 | - |
2407 | -}; |
2408 | +} }; |
2409 | |
2410 | |
2411 | const struct font_desc font_vga_8x16 = { |
2412 | @@ -4628,7 +4627,7 @@ const struct font_desc font_vga_8x16 = { |
2413 | .name = "VGA8x16", |
2414 | .width = 8, |
2415 | .height = 16, |
2416 | - .data = fontdata_8x16, |
2417 | + .data = fontdata_8x16.data, |
2418 | .pref = 0, |
2419 | }; |
2420 | EXPORT_SYMBOL(font_vga_8x16); |
2421 | diff --git a/lib/fonts/font_8x8.c b/lib/fonts/font_8x8.c |
2422 | index 2328ebc8bab5d..8ab695538395d 100644 |
2423 | --- a/lib/fonts/font_8x8.c |
2424 | +++ b/lib/fonts/font_8x8.c |
2425 | @@ -9,8 +9,8 @@ |
2426 | |
2427 | #define FONTDATAMAX 2048 |
2428 | |
2429 | -static const unsigned char fontdata_8x8[FONTDATAMAX] = { |
2430 | - |
2431 | +static struct font_data fontdata_8x8 = { |
2432 | + { 0, 0, FONTDATAMAX, 0 }, { |
2433 | /* 0 0x00 '^@' */ |
2434 | 0x00, /* 00000000 */ |
2435 | 0x00, /* 00000000 */ |
2436 | @@ -2570,8 +2570,7 @@ static const unsigned char fontdata_8x8[FONTDATAMAX] = { |
2437 | 0x00, /* 00000000 */ |
2438 | 0x00, /* 00000000 */ |
2439 | 0x00, /* 00000000 */ |
2440 | - |
2441 | -}; |
2442 | +} }; |
2443 | |
2444 | |
2445 | const struct font_desc font_vga_8x8 = { |
2446 | @@ -2579,6 +2578,6 @@ const struct font_desc font_vga_8x8 = { |
2447 | .name = "VGA8x8", |
2448 | .width = 8, |
2449 | .height = 8, |
2450 | - .data = fontdata_8x8, |
2451 | + .data = fontdata_8x8.data, |
2452 | .pref = 0, |
2453 | }; |
2454 | diff --git a/lib/fonts/font_acorn_8x8.c b/lib/fonts/font_acorn_8x8.c |
2455 | index 0ff0e85d4481b..069b3e80c4344 100644 |
2456 | --- a/lib/fonts/font_acorn_8x8.c |
2457 | +++ b/lib/fonts/font_acorn_8x8.c |
2458 | @@ -3,7 +3,10 @@ |
2459 | |
2460 | #include <linux/font.h> |
2461 | |
2462 | -static const unsigned char acorndata_8x8[] = { |
2463 | +#define FONTDATAMAX 2048 |
2464 | + |
2465 | +static struct font_data acorndata_8x8 = { |
2466 | +{ 0, 0, FONTDATAMAX, 0 }, { |
2467 | /* 00 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */ |
2468 | /* 01 */ 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */ |
2469 | /* 02 */ 0x7e, 0xff, 0xbd, 0xff, 0xc3, 0xe7, 0xff, 0x7e, /* ^B */ |
2470 | @@ -260,14 +263,14 @@ static const unsigned char acorndata_8x8[] = { |
2471 | /* FD */ 0x38, 0x04, 0x18, 0x20, 0x3c, 0x00, 0x00, 0x00, |
2472 | /* FE */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, |
2473 | /* FF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
2474 | -}; |
2475 | +} }; |
2476 | |
2477 | const struct font_desc font_acorn_8x8 = { |
2478 | .idx = ACORN8x8_IDX, |
2479 | .name = "Acorn8x8", |
2480 | .width = 8, |
2481 | .height = 8, |
2482 | - .data = acorndata_8x8, |
2483 | + .data = acorndata_8x8.data, |
2484 | #ifdef CONFIG_ARCH_ACORN |
2485 | .pref = 20, |
2486 | #else |
2487 | diff --git a/lib/fonts/font_mini_4x6.c b/lib/fonts/font_mini_4x6.c |
2488 | index 838caa1cfef70..1449876c6a270 100644 |
2489 | --- a/lib/fonts/font_mini_4x6.c |
2490 | +++ b/lib/fonts/font_mini_4x6.c |
2491 | @@ -43,8 +43,8 @@ __END__; |
2492 | |
2493 | #define FONTDATAMAX 1536 |
2494 | |
2495 | -static const unsigned char fontdata_mini_4x6[FONTDATAMAX] = { |
2496 | - |
2497 | +static struct font_data fontdata_mini_4x6 = { |
2498 | + { 0, 0, FONTDATAMAX, 0 }, { |
2499 | /*{*/ |
2500 | /* Char 0: ' ' */ |
2501 | 0xee, /*= [*** ] */ |
2502 | @@ -2145,14 +2145,14 @@ static const unsigned char fontdata_mini_4x6[FONTDATAMAX] = { |
2503 | 0xee, /*= [*** ] */ |
2504 | 0x00, /*= [ ] */ |
2505 | /*}*/ |
2506 | -}; |
2507 | +} }; |
2508 | |
2509 | const struct font_desc font_mini_4x6 = { |
2510 | .idx = MINI4x6_IDX, |
2511 | .name = "MINI4x6", |
2512 | .width = 4, |
2513 | .height = 6, |
2514 | - .data = fontdata_mini_4x6, |
2515 | + .data = fontdata_mini_4x6.data, |
2516 | .pref = 3, |
2517 | }; |
2518 | |
2519 | diff --git a/lib/fonts/font_pearl_8x8.c b/lib/fonts/font_pearl_8x8.c |
2520 | index b15d3c342c5bb..32d65551e7ed2 100644 |
2521 | --- a/lib/fonts/font_pearl_8x8.c |
2522 | +++ b/lib/fonts/font_pearl_8x8.c |
2523 | @@ -14,8 +14,8 @@ |
2524 | |
2525 | #define FONTDATAMAX 2048 |
2526 | |
2527 | -static const unsigned char fontdata_pearl8x8[FONTDATAMAX] = { |
2528 | - |
2529 | +static struct font_data fontdata_pearl8x8 = { |
2530 | + { 0, 0, FONTDATAMAX, 0 }, { |
2531 | /* 0 0x00 '^@' */ |
2532 | 0x00, /* 00000000 */ |
2533 | 0x00, /* 00000000 */ |
2534 | @@ -2575,14 +2575,13 @@ static const unsigned char fontdata_pearl8x8[FONTDATAMAX] = { |
2535 | 0x00, /* 00000000 */ |
2536 | 0x00, /* 00000000 */ |
2537 | 0x00, /* 00000000 */ |
2538 | - |
2539 | -}; |
2540 | +} }; |
2541 | |
2542 | const struct font_desc font_pearl_8x8 = { |
2543 | .idx = PEARL8x8_IDX, |
2544 | .name = "PEARL8x8", |
2545 | .width = 8, |
2546 | .height = 8, |
2547 | - .data = fontdata_pearl8x8, |
2548 | + .data = fontdata_pearl8x8.data, |
2549 | .pref = 2, |
2550 | }; |
2551 | diff --git a/lib/fonts/font_sun12x22.c b/lib/fonts/font_sun12x22.c |
2552 | index 955d6eee3959d..641a6b4dca424 100644 |
2553 | --- a/lib/fonts/font_sun12x22.c |
2554 | +++ b/lib/fonts/font_sun12x22.c |
2555 | @@ -3,8 +3,8 @@ |
2556 | |
2557 | #define FONTDATAMAX 11264 |
2558 | |
2559 | -static const unsigned char fontdata_sun12x22[FONTDATAMAX] = { |
2560 | - |
2561 | +static struct font_data fontdata_sun12x22 = { |
2562 | + { 0, 0, FONTDATAMAX, 0 }, { |
2563 | /* 0 0x00 '^@' */ |
2564 | 0x00, 0x00, /* 000000000000 */ |
2565 | 0x00, 0x00, /* 000000000000 */ |
2566 | @@ -6148,8 +6148,7 @@ static const unsigned char fontdata_sun12x22[FONTDATAMAX] = { |
2567 | 0x00, 0x00, /* 000000000000 */ |
2568 | 0x00, 0x00, /* 000000000000 */ |
2569 | 0x00, 0x00, /* 000000000000 */ |
2570 | - |
2571 | -}; |
2572 | +} }; |
2573 | |
2574 | |
2575 | const struct font_desc font_sun_12x22 = { |
2576 | @@ -6157,7 +6156,7 @@ const struct font_desc font_sun_12x22 = { |
2577 | .name = "SUN12x22", |
2578 | .width = 12, |
2579 | .height = 22, |
2580 | - .data = fontdata_sun12x22, |
2581 | + .data = fontdata_sun12x22.data, |
2582 | #ifdef __sparc__ |
2583 | .pref = 5, |
2584 | #else |
2585 | diff --git a/lib/fonts/font_sun8x16.c b/lib/fonts/font_sun8x16.c |
2586 | index 03d71e53954ab..193fe6d988e08 100644 |
2587 | --- a/lib/fonts/font_sun8x16.c |
2588 | +++ b/lib/fonts/font_sun8x16.c |
2589 | @@ -3,7 +3,8 @@ |
2590 | |
2591 | #define FONTDATAMAX 4096 |
2592 | |
2593 | -static const unsigned char fontdata_sun8x16[FONTDATAMAX] = { |
2594 | +static struct font_data fontdata_sun8x16 = { |
2595 | +{ 0, 0, FONTDATAMAX, 0 }, { |
2596 | /* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
2597 | /* */ 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00, |
2598 | /* */ 0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xc3,0xe7,0xff,0xff,0x7e,0x00,0x00,0x00,0x00, |
2599 | @@ -260,14 +261,14 @@ static const unsigned char fontdata_sun8x16[FONTDATAMAX] = { |
2600 | /* */ 0x00,0x70,0xd8,0x30,0x60,0xc8,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
2601 | /* */ 0x00,0x00,0x00,0x00,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x00,0x00,0x00,0x00,0x00, |
2602 | /* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
2603 | -}; |
2604 | +} }; |
2605 | |
2606 | const struct font_desc font_sun_8x16 = { |
2607 | .idx = SUN8x16_IDX, |
2608 | .name = "SUN8x16", |
2609 | .width = 8, |
2610 | .height = 16, |
2611 | - .data = fontdata_sun8x16, |
2612 | + .data = fontdata_sun8x16.data, |
2613 | #ifdef __sparc__ |
2614 | .pref = 10, |
2615 | #else |
2616 | diff --git a/lib/fonts/font_ter16x32.c b/lib/fonts/font_ter16x32.c |
2617 | index 3f0cf1ccdf3a4..91b9c283bd9cc 100644 |
2618 | --- a/lib/fonts/font_ter16x32.c |
2619 | +++ b/lib/fonts/font_ter16x32.c |
2620 | @@ -4,8 +4,8 @@ |
2621 | |
2622 | #define FONTDATAMAX 16384 |
2623 | |
2624 | -static const unsigned char fontdata_ter16x32[FONTDATAMAX] = { |
2625 | - |
2626 | +static struct font_data fontdata_ter16x32 = { |
2627 | + { 0, 0, FONTDATAMAX, 0 }, { |
2628 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
2629 | 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfc, 0x7f, 0xfc, |
2630 | 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, |
2631 | @@ -2054,8 +2054,7 @@ static const unsigned char fontdata_ter16x32[FONTDATAMAX] = { |
2632 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
2633 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
2634 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 255 */ |
2635 | - |
2636 | -}; |
2637 | +} }; |
2638 | |
2639 | |
2640 | const struct font_desc font_ter_16x32 = { |
2641 | @@ -2063,7 +2062,7 @@ const struct font_desc font_ter_16x32 = { |
2642 | .name = "TER16x32", |
2643 | .width = 16, |
2644 | .height = 32, |
2645 | - .data = fontdata_ter16x32, |
2646 | + .data = fontdata_ter16x32.data, |
2647 | #ifdef __sparc__ |
2648 | .pref = 5, |
2649 | #else |
2650 | diff --git a/mm/khugepaged.c b/mm/khugepaged.c |
2651 | index 9ec618d5ea557..f0d7e6483ba32 100644 |
2652 | --- a/mm/khugepaged.c |
2653 | +++ b/mm/khugepaged.c |
2654 | @@ -54,6 +54,9 @@ enum scan_result { |
2655 | #define CREATE_TRACE_POINTS |
2656 | #include <trace/events/huge_memory.h> |
2657 | |
2658 | +static struct task_struct *khugepaged_thread __read_mostly; |
2659 | +static DEFINE_MUTEX(khugepaged_mutex); |
2660 | + |
2661 | /* default scan 8*512 pte (or vmas) every 30 second */ |
2662 | static unsigned int khugepaged_pages_to_scan __read_mostly; |
2663 | static unsigned int khugepaged_pages_collapsed; |
2664 | @@ -832,6 +835,18 @@ static struct page *khugepaged_alloc_hugepage(bool *wait) |
2665 | |
2666 | static bool khugepaged_prealloc_page(struct page **hpage, bool *wait) |
2667 | { |
2668 | + /* |
2669 | + * If the hpage allocated earlier was briefly exposed in page cache |
2670 | + * before collapse_file() failed, it is possible that racing lookups |
2671 | + * have not yet completed, and would then be unpleasantly surprised by |
2672 | + * finding the hpage reused for the same mapping at a different offset. |
2673 | + * Just release the previous allocation if there is any danger of that. |
2674 | + */ |
2675 | + if (*hpage && page_count(*hpage) > 1) { |
2676 | + put_page(*hpage); |
2677 | + *hpage = NULL; |
2678 | + } |
2679 | + |
2680 | if (!*hpage) |
2681 | *hpage = khugepaged_alloc_hugepage(wait); |
2682 | |
2683 | @@ -2165,8 +2180,6 @@ static void set_recommended_min_free_kbytes(void) |
2684 | |
2685 | int start_stop_khugepaged(void) |
2686 | { |
2687 | - static struct task_struct *khugepaged_thread __read_mostly; |
2688 | - static DEFINE_MUTEX(khugepaged_mutex); |
2689 | int err = 0; |
2690 | |
2691 | mutex_lock(&khugepaged_mutex); |
2692 | @@ -2193,3 +2206,11 @@ fail: |
2693 | mutex_unlock(&khugepaged_mutex); |
2694 | return err; |
2695 | } |
2696 | + |
2697 | +void khugepaged_min_free_kbytes_update(void) |
2698 | +{ |
2699 | + mutex_lock(&khugepaged_mutex); |
2700 | + if (khugepaged_enabled() && khugepaged_thread) |
2701 | + set_recommended_min_free_kbytes(); |
2702 | + mutex_unlock(&khugepaged_mutex); |
2703 | +} |
2704 | diff --git a/mm/page_alloc.c b/mm/page_alloc.c |
2705 | index 373ca57807589..aff0bb4629bdf 100644 |
2706 | --- a/mm/page_alloc.c |
2707 | +++ b/mm/page_alloc.c |
2708 | @@ -68,6 +68,7 @@ |
2709 | #include <linux/lockdep.h> |
2710 | #include <linux/nmi.h> |
2711 | #include <linux/psi.h> |
2712 | +#include <linux/khugepaged.h> |
2713 | |
2714 | #include <asm/sections.h> |
2715 | #include <asm/tlbflush.h> |
2716 | @@ -7870,6 +7871,8 @@ int __meminit init_per_zone_wmark_min(void) |
2717 | setup_min_slab_ratio(); |
2718 | #endif |
2719 | |
2720 | + khugepaged_min_free_kbytes_update(); |
2721 | + |
2722 | return 0; |
2723 | } |
2724 | postcore_initcall(init_per_zone_wmark_min) |
2725 | diff --git a/net/core/skbuff.c b/net/core/skbuff.c |
2726 | index 08d9915d50c0f..466d6273da9f2 100644 |
2727 | --- a/net/core/skbuff.c |
2728 | +++ b/net/core/skbuff.c |
2729 | @@ -5515,7 +5515,7 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto, |
2730 | lse->label_stack_entry = mpls_lse; |
2731 | skb_postpush_rcsum(skb, lse, MPLS_HLEN); |
2732 | |
2733 | - if (ethernet) |
2734 | + if (ethernet && mac_len >= ETH_HLEN) |
2735 | skb_mod_eth_type(skb, eth_hdr(skb), mpls_proto); |
2736 | skb->protocol = mpls_proto; |
2737 | |
2738 | @@ -5555,7 +5555,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len, |
2739 | skb_reset_mac_header(skb); |
2740 | skb_set_network_header(skb, mac_len); |
2741 | |
2742 | - if (ethernet) { |
2743 | + if (ethernet && mac_len >= ETH_HLEN) { |
2744 | struct ethhdr *hdr; |
2745 | |
2746 | /* use mpls_hdr() to get ethertype to account for VLANs. */ |
2747 | diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c |
2748 | index 2ffa33b5ef404..97f2b11ce2034 100644 |
2749 | --- a/net/ipv4/tcp.c |
2750 | +++ b/net/ipv4/tcp.c |
2751 | @@ -971,7 +971,8 @@ ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset, |
2752 | long timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); |
2753 | |
2754 | if (IS_ENABLED(CONFIG_DEBUG_VM) && |
2755 | - WARN_ONCE(PageSlab(page), "page must not be a Slab one")) |
2756 | + WARN_ONCE(!sendpage_ok(page), |
2757 | + "page must not be a Slab one and have page_count > 0")) |
2758 | return -EINVAL; |
2759 | |
2760 | /* Wait for a connection to finish. One exception is TCP Fast Open |
2761 | diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c |
2762 | index 35f963690a70e..87a5037a9cb3e 100644 |
2763 | --- a/net/ipv4/tcp_ipv4.c |
2764 | +++ b/net/ipv4/tcp_ipv4.c |
2765 | @@ -1719,12 +1719,12 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb) |
2766 | |
2767 | __skb_pull(skb, hdrlen); |
2768 | if (skb_try_coalesce(tail, skb, &fragstolen, &delta)) { |
2769 | - thtail->window = th->window; |
2770 | - |
2771 | TCP_SKB_CB(tail)->end_seq = TCP_SKB_CB(skb)->end_seq; |
2772 | |
2773 | - if (after(TCP_SKB_CB(skb)->ack_seq, TCP_SKB_CB(tail)->ack_seq)) |
2774 | + if (likely(!before(TCP_SKB_CB(skb)->ack_seq, TCP_SKB_CB(tail)->ack_seq))) { |
2775 | TCP_SKB_CB(tail)->ack_seq = TCP_SKB_CB(skb)->ack_seq; |
2776 | + thtail->window = th->window; |
2777 | + } |
2778 | |
2779 | /* We have to update both TCP_SKB_CB(tail)->tcp_flags and |
2780 | * thtail->fin, so that the fast path in tcp_rcv_established() |
2781 | diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c |
2782 | index c86e404cd65bb..d06d7d58eaf27 100644 |
2783 | --- a/net/openvswitch/conntrack.c |
2784 | +++ b/net/openvswitch/conntrack.c |
2785 | @@ -905,15 +905,19 @@ static int ovs_ct_nat(struct net *net, struct sw_flow_key *key, |
2786 | } |
2787 | err = ovs_ct_nat_execute(skb, ct, ctinfo, &info->range, maniptype); |
2788 | |
2789 | - if (err == NF_ACCEPT && |
2790 | - ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) { |
2791 | - if (maniptype == NF_NAT_MANIP_SRC) |
2792 | - maniptype = NF_NAT_MANIP_DST; |
2793 | - else |
2794 | - maniptype = NF_NAT_MANIP_SRC; |
2795 | - |
2796 | - err = ovs_ct_nat_execute(skb, ct, ctinfo, &info->range, |
2797 | - maniptype); |
2798 | + if (err == NF_ACCEPT && ct->status & IPS_DST_NAT) { |
2799 | + if (ct->status & IPS_SRC_NAT) { |
2800 | + if (maniptype == NF_NAT_MANIP_SRC) |
2801 | + maniptype = NF_NAT_MANIP_DST; |
2802 | + else |
2803 | + maniptype = NF_NAT_MANIP_SRC; |
2804 | + |
2805 | + err = ovs_ct_nat_execute(skb, ct, ctinfo, &info->range, |
2806 | + maniptype); |
2807 | + } else if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL) { |
2808 | + err = ovs_ct_nat_execute(skb, ct, ctinfo, NULL, |
2809 | + NF_NAT_MANIP_SRC); |
2810 | + } |
2811 | } |
2812 | |
2813 | /* Mark NAT done if successful and update the flow key. */ |
2814 | diff --git a/net/rxrpc/conn_event.c b/net/rxrpc/conn_event.c |
2815 | index 06fcff2ebbba1..b5864683f200d 100644 |
2816 | --- a/net/rxrpc/conn_event.c |
2817 | +++ b/net/rxrpc/conn_event.c |
2818 | @@ -341,18 +341,18 @@ static int rxrpc_process_event(struct rxrpc_connection *conn, |
2819 | return ret; |
2820 | |
2821 | spin_lock(&conn->channel_lock); |
2822 | - spin_lock(&conn->state_lock); |
2823 | + spin_lock_bh(&conn->state_lock); |
2824 | |
2825 | if (conn->state == RXRPC_CONN_SERVICE_CHALLENGING) { |
2826 | conn->state = RXRPC_CONN_SERVICE; |
2827 | - spin_unlock(&conn->state_lock); |
2828 | + spin_unlock_bh(&conn->state_lock); |
2829 | for (loop = 0; loop < RXRPC_MAXCALLS; loop++) |
2830 | rxrpc_call_is_secure( |
2831 | rcu_dereference_protected( |
2832 | conn->channels[loop].call, |
2833 | lockdep_is_held(&conn->channel_lock))); |
2834 | } else { |
2835 | - spin_unlock(&conn->state_lock); |
2836 | + spin_unlock_bh(&conn->state_lock); |
2837 | } |
2838 | |
2839 | spin_unlock(&conn->channel_lock); |
2840 | diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c |
2841 | index 0c98313dd7a8c..85a9ff8cd236a 100644 |
2842 | --- a/net/rxrpc/key.c |
2843 | +++ b/net/rxrpc/key.c |
2844 | @@ -903,7 +903,7 @@ int rxrpc_request_key(struct rxrpc_sock *rx, char __user *optval, int optlen) |
2845 | |
2846 | _enter(""); |
2847 | |
2848 | - if (optlen <= 0 || optlen > PAGE_SIZE - 1) |
2849 | + if (optlen <= 0 || optlen > PAGE_SIZE - 1 || rx->securities) |
2850 | return -EINVAL; |
2851 | |
2852 | description = memdup_user_nul(optval, optlen); |
2853 | @@ -941,7 +941,7 @@ int rxrpc_server_keyring(struct rxrpc_sock *rx, char __user *optval, |
2854 | if (IS_ERR(description)) |
2855 | return PTR_ERR(description); |
2856 | |
2857 | - key = request_key_net(&key_type_keyring, description, sock_net(&rx->sk), NULL); |
2858 | + key = request_key(&key_type_keyring, description, NULL); |
2859 | if (IS_ERR(key)) { |
2860 | kfree(description); |
2861 | _leave(" = %ld", PTR_ERR(key)); |
2862 | @@ -1073,7 +1073,7 @@ static long rxrpc_read(const struct key *key, |
2863 | |
2864 | switch (token->security_index) { |
2865 | case RXRPC_SECURITY_RXKAD: |
2866 | - toksize += 9 * 4; /* viceid, kvno, key*2 + len, begin, |
2867 | + toksize += 8 * 4; /* viceid, kvno, key*2, begin, |
2868 | * end, primary, tktlen */ |
2869 | toksize += RND(token->kad->ticket_len); |
2870 | break; |
2871 | @@ -1108,7 +1108,8 @@ static long rxrpc_read(const struct key *key, |
2872 | break; |
2873 | |
2874 | default: /* we have a ticket we can't encode */ |
2875 | - BUG(); |
2876 | + pr_err("Unsupported key token type (%u)\n", |
2877 | + token->security_index); |
2878 | continue; |
2879 | } |
2880 | |
2881 | @@ -1139,6 +1140,14 @@ static long rxrpc_read(const struct key *key, |
2882 | memcpy((u8 *)xdr + _l, &zero, 4 - (_l & 3)); \ |
2883 | xdr += (_l + 3) >> 2; \ |
2884 | } while(0) |
2885 | +#define ENCODE_BYTES(l, s) \ |
2886 | + do { \ |
2887 | + u32 _l = (l); \ |
2888 | + memcpy(xdr, (s), _l); \ |
2889 | + if (_l & 3) \ |
2890 | + memcpy((u8 *)xdr + _l, &zero, 4 - (_l & 3)); \ |
2891 | + xdr += (_l + 3) >> 2; \ |
2892 | + } while(0) |
2893 | #define ENCODE64(x) \ |
2894 | do { \ |
2895 | __be64 y = cpu_to_be64(x); \ |
2896 | @@ -1166,7 +1175,7 @@ static long rxrpc_read(const struct key *key, |
2897 | case RXRPC_SECURITY_RXKAD: |
2898 | ENCODE(token->kad->vice_id); |
2899 | ENCODE(token->kad->kvno); |
2900 | - ENCODE_DATA(8, token->kad->session_key); |
2901 | + ENCODE_BYTES(8, token->kad->session_key); |
2902 | ENCODE(token->kad->start); |
2903 | ENCODE(token->kad->expiry); |
2904 | ENCODE(token->kad->primary_flag); |
2905 | @@ -1216,7 +1225,6 @@ static long rxrpc_read(const struct key *key, |
2906 | break; |
2907 | |
2908 | default: |
2909 | - BUG(); |
2910 | break; |
2911 | } |
2912 | |
2913 | diff --git a/net/sched/act_api.c b/net/sched/act_api.c |
2914 | index 69d4676a402f5..4a5ef2adb2e57 100644 |
2915 | --- a/net/sched/act_api.c |
2916 | +++ b/net/sched/act_api.c |
2917 | @@ -303,6 +303,8 @@ static int tcf_del_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb, |
2918 | |
2919 | mutex_lock(&idrinfo->lock); |
2920 | idr_for_each_entry_ul(idr, p, tmp, id) { |
2921 | + if (IS_ERR(p)) |
2922 | + continue; |
2923 | ret = tcf_idr_release_unsafe(p); |
2924 | if (ret == ACT_P_DELETED) { |
2925 | module_put(ops->owner); |
2926 | @@ -451,17 +453,6 @@ err1: |
2927 | } |
2928 | EXPORT_SYMBOL(tcf_idr_create); |
2929 | |
2930 | -void tcf_idr_insert(struct tc_action_net *tn, struct tc_action *a) |
2931 | -{ |
2932 | - struct tcf_idrinfo *idrinfo = tn->idrinfo; |
2933 | - |
2934 | - mutex_lock(&idrinfo->lock); |
2935 | - /* Replace ERR_PTR(-EBUSY) allocated by tcf_idr_check_alloc */ |
2936 | - WARN_ON(!IS_ERR(idr_replace(&idrinfo->action_idr, a, a->tcfa_index))); |
2937 | - mutex_unlock(&idrinfo->lock); |
2938 | -} |
2939 | -EXPORT_SYMBOL(tcf_idr_insert); |
2940 | - |
2941 | /* Cleanup idr index that was allocated but not initialized. */ |
2942 | |
2943 | void tcf_idr_cleanup(struct tc_action_net *tn, u32 index) |
2944 | @@ -839,6 +830,26 @@ static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = { |
2945 | [TCA_ACT_OPTIONS] = { .type = NLA_NESTED }, |
2946 | }; |
2947 | |
2948 | +static void tcf_idr_insert_many(struct tc_action *actions[]) |
2949 | +{ |
2950 | + int i; |
2951 | + |
2952 | + for (i = 0; i < TCA_ACT_MAX_PRIO; i++) { |
2953 | + struct tc_action *a = actions[i]; |
2954 | + struct tcf_idrinfo *idrinfo; |
2955 | + |
2956 | + if (!a) |
2957 | + continue; |
2958 | + idrinfo = a->idrinfo; |
2959 | + mutex_lock(&idrinfo->lock); |
2960 | + /* Replace ERR_PTR(-EBUSY) allocated by tcf_idr_check_alloc if |
2961 | + * it is just created, otherwise this is just a nop. |
2962 | + */ |
2963 | + idr_replace(&idrinfo->action_idr, a, a->tcfa_index); |
2964 | + mutex_unlock(&idrinfo->lock); |
2965 | + } |
2966 | +} |
2967 | + |
2968 | struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, |
2969 | struct nlattr *nla, struct nlattr *est, |
2970 | char *name, int ovr, int bind, |
2971 | @@ -921,6 +932,13 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, |
2972 | if (err < 0) |
2973 | goto err_mod; |
2974 | |
2975 | + if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN) && |
2976 | + !rcu_access_pointer(a->goto_chain)) { |
2977 | + tcf_action_destroy_1(a, bind); |
2978 | + NL_SET_ERR_MSG(extack, "can't use goto chain with NULL chain"); |
2979 | + return ERR_PTR(-EINVAL); |
2980 | + } |
2981 | + |
2982 | if (!name && tb[TCA_ACT_COOKIE]) |
2983 | tcf_set_action_cookie(&a->act_cookie, cookie); |
2984 | |
2985 | @@ -931,13 +949,6 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, |
2986 | if (err != ACT_P_CREATED) |
2987 | module_put(a_o->owner); |
2988 | |
2989 | - if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN) && |
2990 | - !rcu_access_pointer(a->goto_chain)) { |
2991 | - tcf_action_destroy_1(a, bind); |
2992 | - NL_SET_ERR_MSG(extack, "can't use goto chain with NULL chain"); |
2993 | - return ERR_PTR(-EINVAL); |
2994 | - } |
2995 | - |
2996 | return a; |
2997 | |
2998 | err_mod: |
2999 | @@ -981,6 +992,11 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, |
3000 | actions[i - 1] = act; |
3001 | } |
3002 | |
3003 | + /* We have to commit them all together, because if any error happened in |
3004 | + * between, we could not handle the failure gracefully. |
3005 | + */ |
3006 | + tcf_idr_insert_many(actions); |
3007 | + |
3008 | *attr_size = tcf_action_full_attrs_size(sz); |
3009 | return i - 1; |
3010 | |
3011 | diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c |
3012 | index 04b7bd4ec7513..b7d83d01841b1 100644 |
3013 | --- a/net/sched/act_bpf.c |
3014 | +++ b/net/sched/act_bpf.c |
3015 | @@ -361,9 +361,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, |
3016 | if (goto_ch) |
3017 | tcf_chain_put_by_act(goto_ch); |
3018 | |
3019 | - if (res == ACT_P_CREATED) { |
3020 | - tcf_idr_insert(tn, *act); |
3021 | - } else { |
3022 | + if (res != ACT_P_CREATED) { |
3023 | /* make sure the program being replaced is no longer executing */ |
3024 | synchronize_rcu(); |
3025 | tcf_bpf_cfg_cleanup(&old); |
3026 | diff --git a/net/sched/act_connmark.c b/net/sched/act_connmark.c |
3027 | index 1a8f2f85ea1ab..b00105e623341 100644 |
3028 | --- a/net/sched/act_connmark.c |
3029 | +++ b/net/sched/act_connmark.c |
3030 | @@ -139,7 +139,6 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla, |
3031 | ci->net = net; |
3032 | ci->zone = parm->zone; |
3033 | |
3034 | - tcf_idr_insert(tn, *a); |
3035 | ret = ACT_P_CREATED; |
3036 | } else if (ret > 0) { |
3037 | ci = to_connmark(*a); |
3038 | diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c |
3039 | index 428b1ae00123d..fa1b1fd10c441 100644 |
3040 | --- a/net/sched/act_csum.c |
3041 | +++ b/net/sched/act_csum.c |
3042 | @@ -110,9 +110,6 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla, |
3043 | if (params_new) |
3044 | kfree_rcu(params_new, rcu); |
3045 | |
3046 | - if (ret == ACT_P_CREATED) |
3047 | - tcf_idr_insert(tn, *a); |
3048 | - |
3049 | return ret; |
3050 | put_chain: |
3051 | if (goto_ch) |
3052 | diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c |
3053 | index e32c4732ddf83..6119c31dcd072 100644 |
3054 | --- a/net/sched/act_ct.c |
3055 | +++ b/net/sched/act_ct.c |
3056 | @@ -740,8 +740,6 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, |
3057 | tcf_chain_put_by_act(goto_ch); |
3058 | if (params) |
3059 | call_rcu(¶ms->rcu, tcf_ct_params_free); |
3060 | - if (res == ACT_P_CREATED) |
3061 | - tcf_idr_insert(tn, *a); |
3062 | |
3063 | return res; |
3064 | |
3065 | diff --git a/net/sched/act_ctinfo.c b/net/sched/act_ctinfo.c |
3066 | index a91fcee810efa..9722204399a42 100644 |
3067 | --- a/net/sched/act_ctinfo.c |
3068 | +++ b/net/sched/act_ctinfo.c |
3069 | @@ -269,9 +269,6 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, |
3070 | if (cp_new) |
3071 | kfree_rcu(cp_new, rcu); |
3072 | |
3073 | - if (ret == ACT_P_CREATED) |
3074 | - tcf_idr_insert(tn, *a); |
3075 | - |
3076 | return ret; |
3077 | |
3078 | put_chain: |
3079 | diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c |
3080 | index 324f1d1f6d477..faf68a44b8451 100644 |
3081 | --- a/net/sched/act_gact.c |
3082 | +++ b/net/sched/act_gact.c |
3083 | @@ -139,8 +139,6 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, |
3084 | if (goto_ch) |
3085 | tcf_chain_put_by_act(goto_ch); |
3086 | |
3087 | - if (ret == ACT_P_CREATED) |
3088 | - tcf_idr_insert(tn, *a); |
3089 | return ret; |
3090 | release_idr: |
3091 | tcf_idr_release(*a, bind); |
3092 | diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c |
3093 | index 778371bac93e2..488d10476e850 100644 |
3094 | --- a/net/sched/act_ife.c |
3095 | +++ b/net/sched/act_ife.c |
3096 | @@ -626,9 +626,6 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, |
3097 | if (p) |
3098 | kfree_rcu(p, rcu); |
3099 | |
3100 | - if (ret == ACT_P_CREATED) |
3101 | - tcf_idr_insert(tn, *a); |
3102 | - |
3103 | return ret; |
3104 | metadata_parse_err: |
3105 | if (goto_ch) |
3106 | diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c |
3107 | index 214a03d405cf9..02b0cb67643e9 100644 |
3108 | --- a/net/sched/act_ipt.c |
3109 | +++ b/net/sched/act_ipt.c |
3110 | @@ -189,8 +189,6 @@ static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla, |
3111 | ipt->tcfi_t = t; |
3112 | ipt->tcfi_hook = hook; |
3113 | spin_unlock_bh(&ipt->tcf_lock); |
3114 | - if (ret == ACT_P_CREATED) |
3115 | - tcf_idr_insert(tn, *a); |
3116 | return ret; |
3117 | |
3118 | err3: |
3119 | diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c |
3120 | index 27f624971121b..8327ef9793ef8 100644 |
3121 | --- a/net/sched/act_mirred.c |
3122 | +++ b/net/sched/act_mirred.c |
3123 | @@ -194,8 +194,6 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, |
3124 | spin_lock(&mirred_list_lock); |
3125 | list_add(&m->tcfm_list, &mirred_list); |
3126 | spin_unlock(&mirred_list_lock); |
3127 | - |
3128 | - tcf_idr_insert(tn, *a); |
3129 | } |
3130 | |
3131 | return ret; |
3132 | diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c |
3133 | index f786775699b51..f496c99d98266 100644 |
3134 | --- a/net/sched/act_mpls.c |
3135 | +++ b/net/sched/act_mpls.c |
3136 | @@ -273,8 +273,6 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla, |
3137 | if (p) |
3138 | kfree_rcu(p, rcu); |
3139 | |
3140 | - if (ret == ACT_P_CREATED) |
3141 | - tcf_idr_insert(tn, *a); |
3142 | return ret; |
3143 | put_chain: |
3144 | if (goto_ch) |
3145 | diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c |
3146 | index ea4c5359e7dfb..8b5d2360a4dc2 100644 |
3147 | --- a/net/sched/act_nat.c |
3148 | +++ b/net/sched/act_nat.c |
3149 | @@ -93,9 +93,6 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, |
3150 | if (goto_ch) |
3151 | tcf_chain_put_by_act(goto_ch); |
3152 | |
3153 | - if (ret == ACT_P_CREATED) |
3154 | - tcf_idr_insert(tn, *a); |
3155 | - |
3156 | return ret; |
3157 | release_idr: |
3158 | tcf_idr_release(*a, bind); |
3159 | diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c |
3160 | index b5bc631b96b7e..ff4f2437b5925 100644 |
3161 | --- a/net/sched/act_pedit.c |
3162 | +++ b/net/sched/act_pedit.c |
3163 | @@ -237,8 +237,6 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, |
3164 | spin_unlock_bh(&p->tcf_lock); |
3165 | if (goto_ch) |
3166 | tcf_chain_put_by_act(goto_ch); |
3167 | - if (ret == ACT_P_CREATED) |
3168 | - tcf_idr_insert(tn, *a); |
3169 | return ret; |
3170 | |
3171 | put_chain: |
3172 | diff --git a/net/sched/act_police.c b/net/sched/act_police.c |
3173 | index 89c04c52af3da..8fd23a8b88a5e 100644 |
3174 | --- a/net/sched/act_police.c |
3175 | +++ b/net/sched/act_police.c |
3176 | @@ -201,8 +201,6 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, |
3177 | if (new) |
3178 | kfree_rcu(new, rcu); |
3179 | |
3180 | - if (ret == ACT_P_CREATED) |
3181 | - tcf_idr_insert(tn, *a); |
3182 | return ret; |
3183 | |
3184 | failure: |
3185 | diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c |
3186 | index 514456a0b9a83..74450b0f69fc5 100644 |
3187 | --- a/net/sched/act_sample.c |
3188 | +++ b/net/sched/act_sample.c |
3189 | @@ -116,8 +116,6 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, |
3190 | if (goto_ch) |
3191 | tcf_chain_put_by_act(goto_ch); |
3192 | |
3193 | - if (ret == ACT_P_CREATED) |
3194 | - tcf_idr_insert(tn, *a); |
3195 | return ret; |
3196 | put_chain: |
3197 | if (goto_ch) |
3198 | diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c |
3199 | index 6120e56117ca1..6b0617de71c00 100644 |
3200 | --- a/net/sched/act_simple.c |
3201 | +++ b/net/sched/act_simple.c |
3202 | @@ -156,8 +156,6 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, |
3203 | goto release_idr; |
3204 | } |
3205 | |
3206 | - if (ret == ACT_P_CREATED) |
3207 | - tcf_idr_insert(tn, *a); |
3208 | return ret; |
3209 | put_chain: |
3210 | if (goto_ch) |
3211 | diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c |
3212 | index f98b2791ecec4..f736da513d53a 100644 |
3213 | --- a/net/sched/act_skbedit.c |
3214 | +++ b/net/sched/act_skbedit.c |
3215 | @@ -214,8 +214,6 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, |
3216 | if (goto_ch) |
3217 | tcf_chain_put_by_act(goto_ch); |
3218 | |
3219 | - if (ret == ACT_P_CREATED) |
3220 | - tcf_idr_insert(tn, *a); |
3221 | return ret; |
3222 | put_chain: |
3223 | if (goto_ch) |
3224 | diff --git a/net/sched/act_skbmod.c b/net/sched/act_skbmod.c |
3225 | index 888437f97ba62..e858a0a9c0457 100644 |
3226 | --- a/net/sched/act_skbmod.c |
3227 | +++ b/net/sched/act_skbmod.c |
3228 | @@ -190,8 +190,6 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, |
3229 | if (goto_ch) |
3230 | tcf_chain_put_by_act(goto_ch); |
3231 | |
3232 | - if (ret == ACT_P_CREATED) |
3233 | - tcf_idr_insert(tn, *a); |
3234 | return ret; |
3235 | put_chain: |
3236 | if (goto_ch) |
3237 | diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c |
3238 | index d55669e147417..bdaa04a9a7fa4 100644 |
3239 | --- a/net/sched/act_tunnel_key.c |
3240 | +++ b/net/sched/act_tunnel_key.c |
3241 | @@ -392,9 +392,6 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, |
3242 | if (goto_ch) |
3243 | tcf_chain_put_by_act(goto_ch); |
3244 | |
3245 | - if (ret == ACT_P_CREATED) |
3246 | - tcf_idr_insert(tn, *a); |
3247 | - |
3248 | return ret; |
3249 | |
3250 | put_chain: |
3251 | diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c |
3252 | index 08aaf719a70fb..3c26042f4ea6d 100644 |
3253 | --- a/net/sched/act_vlan.c |
3254 | +++ b/net/sched/act_vlan.c |
3255 | @@ -228,8 +228,6 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, |
3256 | if (p) |
3257 | kfree_rcu(p, rcu); |
3258 | |
3259 | - if (ret == ACT_P_CREATED) |
3260 | - tcf_idr_insert(tn, *a); |
3261 | return ret; |
3262 | put_chain: |
3263 | if (goto_ch) |
3264 | diff --git a/net/sctp/auth.c b/net/sctp/auth.c |
3265 | index 4278764d82b82..1d898ee4018c9 100644 |
3266 | --- a/net/sctp/auth.c |
3267 | +++ b/net/sctp/auth.c |
3268 | @@ -494,6 +494,7 @@ int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp) |
3269 | out_err: |
3270 | /* Clean up any successful allocations */ |
3271 | sctp_auth_destroy_hmacs(ep->auth_hmacs); |
3272 | + ep->auth_hmacs = NULL; |
3273 | return -ENOMEM; |
3274 | } |
3275 | |
3276 | diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c |
3277 | index 70b203e5d5fd0..515d295309a86 100644 |
3278 | --- a/net/tls/tls_sw.c |
3279 | +++ b/net/tls/tls_sw.c |
3280 | @@ -2137,10 +2137,15 @@ void tls_sw_release_resources_tx(struct sock *sk) |
3281 | struct tls_context *tls_ctx = tls_get_ctx(sk); |
3282 | struct tls_sw_context_tx *ctx = tls_sw_ctx_tx(tls_ctx); |
3283 | struct tls_rec *rec, *tmp; |
3284 | + int pending; |
3285 | |
3286 | /* Wait for any pending async encryptions to complete */ |
3287 | - smp_store_mb(ctx->async_notify, true); |
3288 | - if (atomic_read(&ctx->encrypt_pending)) |
3289 | + spin_lock_bh(&ctx->encrypt_compl_lock); |
3290 | + ctx->async_notify = true; |
3291 | + pending = atomic_read(&ctx->encrypt_pending); |
3292 | + spin_unlock_bh(&ctx->encrypt_compl_lock); |
3293 | + |
3294 | + if (pending) |
3295 | crypto_wait_req(-EINPROGRESS, &ctx->async_wait); |
3296 | |
3297 | tls_tx_records(sk, -1); |
3298 | diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c |
3299 | index ec559dbad56ea..7bc4f37655237 100644 |
3300 | --- a/net/wireless/nl80211.c |
3301 | +++ b/net/wireless/nl80211.c |
3302 | @@ -3975,6 +3975,9 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info) |
3303 | if (err) |
3304 | return err; |
3305 | |
3306 | + if (key.idx < 0) |
3307 | + return -EINVAL; |
3308 | + |
3309 | if (info->attrs[NL80211_ATTR_MAC]) |
3310 | mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); |
3311 | |
3312 | diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c |
3313 | index 0ab2b35c95deb..00af31d3e7744 100644 |
3314 | --- a/net/xfrm/xfrm_interface.c |
3315 | +++ b/net/xfrm/xfrm_interface.c |
3316 | @@ -293,7 +293,7 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl) |
3317 | } |
3318 | |
3319 | mtu = dst_mtu(dst); |
3320 | - if (!skb->ignore_df && skb->len > mtu) { |
3321 | + if (skb->len > mtu) { |
3322 | skb_dst_update_pmtu_no_confirm(skb, mtu); |
3323 | |
3324 | if (skb->protocol == htons(ETH_P_IPV6)) { |
3325 | diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c |
3326 | index f3423562d9336..aaea8cb7459d8 100644 |
3327 | --- a/net/xfrm/xfrm_state.c |
3328 | +++ b/net/xfrm/xfrm_state.c |
3329 | @@ -1016,7 +1016,8 @@ static void xfrm_state_look_at(struct xfrm_policy *pol, struct xfrm_state *x, |
3330 | */ |
3331 | if (x->km.state == XFRM_STATE_VALID) { |
3332 | if ((x->sel.family && |
3333 | - !xfrm_selector_match(&x->sel, fl, x->sel.family)) || |
3334 | + (x->sel.family != family || |
3335 | + !xfrm_selector_match(&x->sel, fl, family))) || |
3336 | !security_xfrm_state_pol_flow_match(x, pol, fl)) |
3337 | return; |
3338 | |
3339 | @@ -1029,7 +1030,9 @@ static void xfrm_state_look_at(struct xfrm_policy *pol, struct xfrm_state *x, |
3340 | *acq_in_progress = 1; |
3341 | } else if (x->km.state == XFRM_STATE_ERROR || |
3342 | x->km.state == XFRM_STATE_EXPIRED) { |
3343 | - if (xfrm_selector_match(&x->sel, fl, x->sel.family) && |
3344 | + if ((!x->sel.family || |
3345 | + (x->sel.family == family && |
3346 | + xfrm_selector_match(&x->sel, fl, family))) && |
3347 | security_xfrm_state_pol_flow_match(x, pol, fl)) |
3348 | *error = -ESRCH; |
3349 | } |
3350 | @@ -1069,7 +1072,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr, |
3351 | tmpl->mode == x->props.mode && |
3352 | tmpl->id.proto == x->id.proto && |
3353 | (tmpl->id.spi == x->id.spi || !tmpl->id.spi)) |
3354 | - xfrm_state_look_at(pol, x, fl, encap_family, |
3355 | + xfrm_state_look_at(pol, x, fl, family, |
3356 | &best, &acquire_in_progress, &error); |
3357 | } |
3358 | if (best || acquire_in_progress) |
3359 | @@ -1086,7 +1089,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr, |
3360 | tmpl->mode == x->props.mode && |
3361 | tmpl->id.proto == x->id.proto && |
3362 | (tmpl->id.spi == x->id.spi || !tmpl->id.spi)) |
3363 | - xfrm_state_look_at(pol, x, fl, encap_family, |
3364 | + xfrm_state_look_at(pol, x, fl, family, |
3365 | &best, &acquire_in_progress, &error); |
3366 | } |
3367 | |
3368 | @@ -1438,6 +1441,30 @@ out: |
3369 | EXPORT_SYMBOL(xfrm_state_add); |
3370 | |
3371 | #ifdef CONFIG_XFRM_MIGRATE |
3372 | +static inline int clone_security(struct xfrm_state *x, struct xfrm_sec_ctx *security) |
3373 | +{ |
3374 | + struct xfrm_user_sec_ctx *uctx; |
3375 | + int size = sizeof(*uctx) + security->ctx_len; |
3376 | + int err; |
3377 | + |
3378 | + uctx = kmalloc(size, GFP_KERNEL); |
3379 | + if (!uctx) |
3380 | + return -ENOMEM; |
3381 | + |
3382 | + uctx->exttype = XFRMA_SEC_CTX; |
3383 | + uctx->len = size; |
3384 | + uctx->ctx_doi = security->ctx_doi; |
3385 | + uctx->ctx_alg = security->ctx_alg; |
3386 | + uctx->ctx_len = security->ctx_len; |
3387 | + memcpy(uctx + 1, security->ctx_str, security->ctx_len); |
3388 | + err = security_xfrm_state_alloc(x, uctx); |
3389 | + kfree(uctx); |
3390 | + if (err) |
3391 | + return err; |
3392 | + |
3393 | + return 0; |
3394 | +} |
3395 | + |
3396 | static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, |
3397 | struct xfrm_encap_tmpl *encap) |
3398 | { |
3399 | @@ -1494,6 +1521,10 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, |
3400 | goto error; |
3401 | } |
3402 | |
3403 | + if (orig->security) |
3404 | + if (clone_security(x, orig->security)) |
3405 | + goto error; |
3406 | + |
3407 | if (orig->coaddr) { |
3408 | x->coaddr = kmemdup(orig->coaddr, sizeof(*x->coaddr), |
3409 | GFP_KERNEL); |
3410 | @@ -1507,6 +1538,7 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, |
3411 | } |
3412 | |
3413 | memcpy(&x->mark, &orig->mark, sizeof(x->mark)); |
3414 | + memcpy(&x->props.smark, &orig->props.smark, sizeof(x->props.smark)); |
3415 | |
3416 | if (xfrm_init_state(x) < 0) |
3417 | goto error; |
3418 | @@ -1518,7 +1550,7 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, |
3419 | x->tfcpad = orig->tfcpad; |
3420 | x->replay_maxdiff = orig->replay_maxdiff; |
3421 | x->replay_maxage = orig->replay_maxage; |
3422 | - x->curlft.add_time = orig->curlft.add_time; |
3423 | + memcpy(&x->curlft, &orig->curlft, sizeof(x->curlft)); |
3424 | x->km.state = orig->km.state; |
3425 | x->km.seq = orig->km.seq; |
3426 | x->replay = orig->replay; |
3427 | diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c |
3428 | index 1f60124eb19bb..a30d62186f5e9 100644 |
3429 | --- a/tools/perf/builtin-top.c |
3430 | +++ b/tools/perf/builtin-top.c |
3431 | @@ -683,7 +683,9 @@ repeat: |
3432 | delay_msecs = top->delay_secs * MSEC_PER_SEC; |
3433 | set_term_quiet_input(&save); |
3434 | /* trash return*/ |
3435 | - getc(stdin); |
3436 | + clearerr(stdin); |
3437 | + if (poll(&stdin_poll, 1, 0) > 0) |
3438 | + getc(stdin); |
3439 | |
3440 | while (!done) { |
3441 | perf_top__print_sym_table(top); |
3442 | diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c |
3443 | index 4a800499d7c35..22daf2bdf5faf 100644 |
3444 | --- a/tools/perf/tests/topology.c |
3445 | +++ b/tools/perf/tests/topology.c |
3446 | @@ -33,10 +33,8 @@ static int session_write_header(char *path) |
3447 | { |
3448 | struct perf_session *session; |
3449 | struct perf_data data = { |
3450 | - .file = { |
3451 | - .path = path, |
3452 | - }, |
3453 | - .mode = PERF_DATA_MODE_WRITE, |
3454 | + .path = path, |
3455 | + .mode = PERF_DATA_MODE_WRITE, |
3456 | }; |
3457 | |
3458 | session = perf_session__new(&data, false, NULL); |
3459 | @@ -63,10 +61,8 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) |
3460 | { |
3461 | struct perf_session *session; |
3462 | struct perf_data data = { |
3463 | - .file = { |
3464 | - .path = path, |
3465 | - }, |
3466 | - .mode = PERF_DATA_MODE_READ, |
3467 | + .path = path, |
3468 | + .mode = PERF_DATA_MODE_READ, |
3469 | }; |
3470 | int i; |
3471 |