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

Configure Feed

Select the types of activity you want to include in your feed.

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

Cross-merge networking fixes after downstream PR (net-6.13-rc7).

Conflicts:
a42d71e322a8 ("net_sched: sch_cake: Add drop reasons")
737d4d91d35b ("sched: sch_cake: add bounds checks to host bulk flow fairness counts")

Adjacent changes:

drivers/net/ethernet/meta/fbnic/fbnic.h
3a856ab34726 ("eth: fbnic: add IRQ reuse support")
95978931d55f ("eth: fbnic: Revert "eth: fbnic: Add hardware monitoring support via HWMON interface"")

Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+1470 -963
+1 -1
.mailmap
··· 435 435 Martin Kepplinger <martink@posteo.de> <martin.kepplinger@puri.sm> 436 436 Martin Kepplinger <martink@posteo.de> <martin.kepplinger@theobroma-systems.com> 437 437 Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com> <martyna.szapar-mudlaw@intel.com> 438 - Mathieu Othacehe <m.othacehe@gmail.com> <othacehe@gnu.org> 438 + Mathieu Othacehe <othacehe@gnu.org> <m.othacehe@gmail.com> 439 439 Mat Martineau <martineau@kernel.org> <mathew.j.martineau@linux.intel.com> 440 440 Mat Martineau <martineau@kernel.org> <mathewm@codeaurora.org> 441 441 Matthew Wilcox <willy@infradead.org> <matthew.r.wilcox@intel.com>
+12
CREDITS
··· 20 20 E: thomas.ab@samsung.com 21 21 D: Samsung pin controller driver 22 22 23 + N: Jose Abreu 24 + E: jose.abreu@synopsys.com 25 + D: Synopsys DesignWare XPCS MDIO/PCS driver. 26 + 23 27 N: Dragos Acostachioaie 24 28 E: dragos@iname.com 25 29 W: http://www.arbornet.org/~dragos ··· 1432 1428 S: Sterling Heights, Michigan 48313 1433 1429 S: USA 1434 1430 1431 + N: Andy Gospodarek 1432 + E: andy@greyhouse.net 1433 + D: Maintenance and contributions to the network interface bonding driver. 1434 + 1435 1435 N: Wolfgang Grandegger 1436 1436 E: wg@grandegger.com 1437 1437 D: Controller Area Network (device drivers) ··· 1819 1811 D: Author/maintainer of most DRM drivers (especially ATI, MGA) 1820 1812 D: Core DRM templates, general DRM and 3D-related hacking 1821 1813 S: No fixed address 1814 + 1815 + N: Woojung Huh 1816 + E: woojung.huh@microchip.com 1817 + D: Microchip LAN78XX USB Ethernet driver 1822 1818 1823 1819 N: Kenn Humborg 1824 1820 E: kenn@wombat.ie
+1 -1
Documentation/admin-guide/mm/transhuge.rst
··· 436 436 The number of file transparent huge pages mapped to userspace is available 437 437 by reading ShmemPmdMapped and ShmemHugePages fields in ``/proc/meminfo``. 438 438 To identify what applications are mapping file transparent huge pages, it 439 - is necessary to read ``/proc/PID/smaps`` and count the FileHugeMapped fields 439 + is necessary to read ``/proc/PID/smaps`` and count the FilePmdMapped fields 440 440 for each mapping. 441 441 442 442 Note that reading the smaps file is expensive and reading it
+1 -1
Documentation/devicetree/bindings/net/pse-pd/pse-controller.yaml
··· 81 81 List of phandles, each pointing to the power supply for the 82 82 corresponding pairset named in 'pairset-names'. This property 83 83 aligns with IEEE 802.3-2022, Section 33.2.3 and 145.2.4. 84 - PSE Pinout Alternatives (as per IEEE 802.3-2022 Table 145\u20133) 84 + PSE Pinout Alternatives (as per IEEE 802.3-2022 Table 145-3) 85 85 |-----------|---------------|---------------|---------------|---------------| 86 86 | Conductor | Alternative A | Alternative A | Alternative B | Alternative B | 87 87 | | (MDI-X) | (MDI) | (X) | (S) |
+9 -15
MAINTAINERS
··· 949 949 M: Shay Agroskin <shayagr@amazon.com> 950 950 M: Arthur Kiyanovski <akiyano@amazon.com> 951 951 R: David Arinzon <darinzon@amazon.com> 952 - R: Noam Dagan <ndagan@amazon.com> 953 952 R: Saeed Bishara <saeedb@amazon.com> 954 953 L: netdev@vger.kernel.org 955 954 S: Supported ··· 2689 2690 N: atmel 2690 2691 2691 2692 ARM/Microchip Sparx5 SoC support 2692 - M: Lars Povlsen <lars.povlsen@microchip.com> 2693 2693 M: Steen Hegelund <Steen.Hegelund@microchip.com> 2694 2694 M: Daniel Machon <daniel.machon@microchip.com> 2695 2695 M: UNGLinuxDriver@microchip.com ··· 4063 4065 4064 4066 BONDING DRIVER 4065 4067 M: Jay Vosburgh <jv@jvosburgh.net> 4066 - M: Andy Gospodarek <andy@greyhouse.net> 4067 4068 L: netdev@vger.kernel.org 4068 4069 S: Maintained 4069 4070 F: Documentation/networking/bonding.rst ··· 14571 14574 MEDIATEK ETHERNET DRIVER 14572 14575 M: Felix Fietkau <nbd@nbd.name> 14573 14576 M: Sean Wang <sean.wang@mediatek.com> 14574 - M: Mark Lee <Mark-MC.Lee@mediatek.com> 14575 14577 M: Lorenzo Bianconi <lorenzo@kernel.org> 14576 14578 L: netdev@vger.kernel.org 14577 14579 S: Maintained ··· 14760 14764 F: include/soc/mediatek/smi.h 14761 14765 14762 14766 MEDIATEK SWITCH DRIVER 14763 - M: Arınç ÜNAL <arinc.unal@arinc9.com> 14767 + M: Chester A. Unal <chester.a.unal@arinc9.com> 14764 14768 M: Daniel Golle <daniel@makrotopia.org> 14765 14769 M: DENG Qingfang <dqfext@gmail.com> 14766 14770 M: Sean Wang <sean.wang@mediatek.com> ··· 18465 18469 F: drivers/pinctrl/mediatek/ 18466 18470 18467 18471 PIN CONTROLLER - MEDIATEK MIPS 18468 - M: Arınç ÜNAL <arinc.unal@arinc9.com> 18472 + M: Chester A. Unal <chester.a.unal@arinc9.com> 18469 18473 M: Sergio Paracuellos <sergio.paracuellos@gmail.com> 18470 18474 L: linux-mediatek@lists.infradead.org (moderated for non-subscribers) 18471 18475 L: linux-mips@vger.kernel.org ··· 19509 19513 F: arch/mips/ralink 19510 19514 19511 19515 RALINK MT7621 MIPS ARCHITECTURE 19512 - M: Arınç ÜNAL <arinc.unal@arinc9.com> 19516 + M: Chester A. Unal <chester.a.unal@arinc9.com> 19513 19517 M: Sergio Paracuellos <sergio.paracuellos@gmail.com> 19514 19518 L: linux-mips@vger.kernel.org 19515 19519 S: Maintained ··· 20912 20916 SCHEDULER - SCHED_EXT 20913 20917 R: Tejun Heo <tj@kernel.org> 20914 20918 R: David Vernet <void@manifault.com> 20919 + R: Andrea Righi <arighi@nvidia.com> 20920 + R: Changwoo Min <changwoo@igalia.com> 20915 20921 L: linux-kernel@vger.kernel.org 20916 20922 S: Maintained 20917 20923 W: https://github.com/sched-ext/scx ··· 22508 22510 F: drivers/phy/st/phy-stm32-combophy.c 22509 22511 22510 22512 STMMAC ETHERNET DRIVER 22511 - M: Alexandre Torgue <alexandre.torgue@foss.st.com> 22512 - M: Jose Abreu <joabreu@synopsys.com> 22513 22513 L: netdev@vger.kernel.org 22514 - S: Supported 22515 - W: http://www.stlinux.com 22514 + S: Orphan 22516 22515 F: Documentation/networking/device_drivers/ethernet/stmicro/ 22517 22516 F: drivers/net/ethernet/stmicro/stmmac/ 22518 22517 ··· 22741 22746 F: drivers/net/ethernet/synopsys/ 22742 22747 22743 22748 SYNOPSYS DESIGNWARE ETHERNET XPCS DRIVER 22744 - M: Jose Abreu <Jose.Abreu@synopsys.com> 22745 22749 L: netdev@vger.kernel.org 22746 - S: Supported 22750 + S: Orphan 22747 22751 F: drivers/net/pcs/pcs-xpcs.c 22748 22752 F: drivers/net/pcs/pcs-xpcs.h 22749 22753 F: include/linux/pcs/pcs-xpcs.h ··· 23650 23656 23651 23657 TIPC NETWORK LAYER 23652 23658 M: Jon Maloy <jmaloy@redhat.com> 23653 - M: Ying Xue <ying.xue@windriver.com> 23654 23659 L: netdev@vger.kernel.org (core kernel code) 23655 23660 L: tipc-discussion@lists.sourceforge.net (user apps, general discussion) 23656 23661 S: Maintained ··· 24255 24262 F: drivers/usb/isp1760/* 24256 24263 24257 24264 USB LAN78XX ETHERNET DRIVER 24258 - M: Woojung Huh <woojung.huh@microchip.com> 24265 + M: Thangaraj Samynathan <Thangaraj.S@microchip.com> 24266 + M: Rengarajan Sundararajan <Rengarajan.S@microchip.com> 24259 24267 M: UNGLinuxDriver@microchip.com 24260 24268 L: netdev@vger.kernel.org 24261 24269 S: Maintained
+1 -1
Makefile
··· 2 2 VERSION = 6 3 3 PATCHLEVEL = 13 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc5 5 + EXTRAVERSION = -rc6 6 6 NAME = Baby Opossum Posse 7 7 8 8 # *DOCUMENTATION*
+7
drivers/bluetooth/btmtk.c
··· 1472 1472 1473 1473 int btmtk_usb_shutdown(struct hci_dev *hdev) 1474 1474 { 1475 + struct btmtk_data *data = hci_get_priv(hdev); 1475 1476 struct btmtk_hci_wmt_params wmt_params; 1476 1477 u8 param = 0; 1477 1478 int err; 1479 + 1480 + err = usb_autopm_get_interface(data->intf); 1481 + if (err < 0) 1482 + return err; 1478 1483 1479 1484 /* Disable the device */ 1480 1485 wmt_params.op = BTMTK_WMT_FUNC_CTRL; ··· 1491 1486 err = btmtk_usb_hci_wmt_sync(hdev, &wmt_params); 1492 1487 if (err < 0) { 1493 1488 bt_dev_err(hdev, "Failed to send wmt func ctrl (%d)", err); 1489 + usb_autopm_put_interface(data->intf); 1494 1490 return err; 1495 1491 } 1496 1492 1493 + usb_autopm_put_interface(data->intf); 1497 1494 return 0; 1498 1495 } 1499 1496 EXPORT_SYMBOL_GPL(btmtk_usb_shutdown);
+1
drivers/bluetooth/btnxpuart.c
··· 1381 1381 1382 1382 while ((skb = nxp_dequeue(nxpdev))) { 1383 1383 len = serdev_device_write_buf(serdev, skb->data, skb->len); 1384 + serdev_device_wait_until_sent(serdev, 0); 1384 1385 hdev->stat.byte_tx += len; 1385 1386 1386 1387 skb_pull(skb, len);
+1 -1
drivers/cdrom/cdrom.c
··· 1106 1106 } 1107 1107 } 1108 1108 1109 - cd_dbg(CD_OPEN, "all seems well, opening the devicen"); 1109 + cd_dbg(CD_OPEN, "all seems well, opening the device\n"); 1110 1110 1111 1111 /* all seems well, we can open the device */ 1112 1112 ret = cdo->open(cdi, 0); /* open for data */
+2 -1
drivers/clk/imx/clk-imx8mp-audiomix.c
··· 278 278 279 279 #else /* !CONFIG_RESET_CONTROLLER */ 280 280 281 - static int clk_imx8mp_audiomix_reset_controller_register(struct clk_imx8mp_audiomix_priv *priv) 281 + static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev, 282 + struct clk_imx8mp_audiomix_priv *priv) 282 283 { 283 284 return 0; 284 285 }
+12 -1
drivers/clk/thead/clk-th1520-ap.c
··· 779 779 }, 780 780 }; 781 781 782 + static CLK_FIXED_FACTOR_HW(emmc_sdio_ref_clk, "emmc-sdio-ref", 783 + &video_pll_clk.common.hw, 4, 1, 0); 784 + 785 + static const struct clk_parent_data emmc_sdio_ref_clk_pd[] = { 786 + { .hw = &emmc_sdio_ref_clk.hw }, 787 + }; 788 + 782 789 static CCU_GATE(CLK_BROM, brom_clk, "brom", ahb2_cpusys_hclk_pd, 0x100, BIT(4), 0); 783 790 static CCU_GATE(CLK_BMU, bmu_clk, "bmu", axi4_cpusys2_aclk_pd, 0x100, BIT(5), 0); 784 791 static CCU_GATE(CLK_AON2CPU_A2X, aon2cpu_a2x_clk, "aon2cpu-a2x", axi4_cpusys2_aclk_pd, ··· 805 798 0x150, BIT(12), 0); 806 799 static CCU_GATE(CLK_NPU_AXI, npu_axi_clk, "npu-axi", axi_aclk_pd, 0x1c8, BIT(5), 0); 807 800 static CCU_GATE(CLK_CPU2VP, cpu2vp_clk, "cpu2vp", axi_aclk_pd, 0x1e0, BIT(13), 0); 808 - static CCU_GATE(CLK_EMMC_SDIO, emmc_sdio_clk, "emmc-sdio", video_pll_clk_pd, 0x204, BIT(30), 0); 801 + static CCU_GATE(CLK_EMMC_SDIO, emmc_sdio_clk, "emmc-sdio", emmc_sdio_ref_clk_pd, 0x204, BIT(30), 0); 809 802 static CCU_GATE(CLK_GMAC1, gmac1_clk, "gmac1", gmac_pll_clk_pd, 0x204, BIT(26), 0); 810 803 static CCU_GATE(CLK_PADCTRL1, padctrl1_clk, "padctrl1", perisys_apb_pclk_pd, 0x204, BIT(24), 0); 811 804 static CCU_GATE(CLK_DSMART, dsmart_clk, "dsmart", perisys_apb_pclk_pd, 0x204, BIT(23), 0); ··· 1065 1058 if (ret) 1066 1059 return ret; 1067 1060 priv->hws[CLK_PLL_GMAC_100M] = &gmac_pll_clk_100m.hw; 1061 + 1062 + ret = devm_clk_hw_register(dev, &emmc_sdio_ref_clk.hw); 1063 + if (ret) 1064 + return ret; 1068 1065 1069 1066 ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, priv); 1070 1067 if (ret)
+1 -1
drivers/md/dm-ebs-target.c
··· 442 442 static struct target_type ebs_target = { 443 443 .name = "ebs", 444 444 .version = {1, 0, 1}, 445 - .features = DM_TARGET_PASSES_INTEGRITY, 445 + .features = 0, 446 446 .module = THIS_MODULE, 447 447 .ctr = ebs_ctr, 448 448 .dtr = ebs_dtr,
+2 -3
drivers/md/dm-thin.c
··· 2332 2332 struct thin_c *tc = NULL; 2333 2333 2334 2334 rcu_read_lock(); 2335 - if (!list_empty(&pool->active_thins)) { 2336 - tc = list_entry_rcu(pool->active_thins.next, struct thin_c, list); 2335 + tc = list_first_or_null_rcu(&pool->active_thins, struct thin_c, list); 2336 + if (tc) 2337 2337 thin_get(tc); 2338 - } 2339 2338 rcu_read_unlock(); 2340 2339 2341 2340 return tc;
+30 -29
drivers/md/dm-verity-fec.c
··· 40 40 } 41 41 42 42 /* 43 - * Decode an RS block using Reed-Solomon. 44 - */ 45 - static int fec_decode_rs8(struct dm_verity *v, struct dm_verity_fec_io *fio, 46 - u8 *data, u8 *fec, int neras) 47 - { 48 - int i; 49 - uint16_t par[DM_VERITY_FEC_RSM - DM_VERITY_FEC_MIN_RSN]; 50 - 51 - for (i = 0; i < v->fec->roots; i++) 52 - par[i] = fec[i]; 53 - 54 - return decode_rs8(fio->rs, data, par, v->fec->rsn, NULL, neras, 55 - fio->erasures, 0, NULL); 56 - } 57 - 58 - /* 59 43 * Read error-correcting codes for the requested RS block. Returns a pointer 60 44 * to the data block. Caller is responsible for releasing buf. 61 45 */ 62 46 static u8 *fec_read_parity(struct dm_verity *v, u64 rsb, int index, 63 - unsigned int *offset, struct dm_buffer **buf, 64 - unsigned short ioprio) 47 + unsigned int *offset, unsigned int par_buf_offset, 48 + struct dm_buffer **buf, unsigned short ioprio) 65 49 { 66 50 u64 position, block, rem; 67 51 u8 *res; 68 52 53 + /* We have already part of parity bytes read, skip to the next block */ 54 + if (par_buf_offset) 55 + index++; 56 + 69 57 position = (index + rsb) * v->fec->roots; 70 58 block = div64_u64_rem(position, v->fec->io_size, &rem); 71 - *offset = (unsigned int)rem; 59 + *offset = par_buf_offset ? 0 : (unsigned int)rem; 72 60 73 61 res = dm_bufio_read_with_ioprio(v->fec->bufio, block, buf, ioprio); 74 62 if (IS_ERR(res)) { ··· 116 128 { 117 129 int r, corrected = 0, res; 118 130 struct dm_buffer *buf; 119 - unsigned int n, i, offset; 131 + unsigned int n, i, j, offset, par_buf_offset = 0; 132 + uint16_t par_buf[DM_VERITY_FEC_RSM - DM_VERITY_FEC_MIN_RSN]; 120 133 u8 *par, *block; 121 134 struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size); 122 135 123 - par = fec_read_parity(v, rsb, block_offset, &offset, &buf, bio_prio(bio)); 136 + par = fec_read_parity(v, rsb, block_offset, &offset, 137 + par_buf_offset, &buf, bio_prio(bio)); 124 138 if (IS_ERR(par)) 125 139 return PTR_ERR(par); 126 140 ··· 132 142 */ 133 143 fec_for_each_buffer_rs_block(fio, n, i) { 134 144 block = fec_buffer_rs_block(v, fio, n, i); 135 - res = fec_decode_rs8(v, fio, block, &par[offset], neras); 145 + for (j = 0; j < v->fec->roots - par_buf_offset; j++) 146 + par_buf[par_buf_offset + j] = par[offset + j]; 147 + /* Decode an RS block using Reed-Solomon */ 148 + res = decode_rs8(fio->rs, block, par_buf, v->fec->rsn, 149 + NULL, neras, fio->erasures, 0, NULL); 136 150 if (res < 0) { 137 151 r = res; 138 152 goto error; ··· 149 155 if (block_offset >= 1 << v->data_dev_block_bits) 150 156 goto done; 151 157 152 - /* read the next block when we run out of parity bytes */ 153 - offset += v->fec->roots; 158 + /* Read the next block when we run out of parity bytes */ 159 + offset += (v->fec->roots - par_buf_offset); 160 + /* Check if parity bytes are split between blocks */ 161 + if (offset < v->fec->io_size && (offset + v->fec->roots) > v->fec->io_size) { 162 + par_buf_offset = v->fec->io_size - offset; 163 + for (j = 0; j < par_buf_offset; j++) 164 + par_buf[j] = par[offset + j]; 165 + offset += par_buf_offset; 166 + } else 167 + par_buf_offset = 0; 168 + 154 169 if (offset >= v->fec->io_size) { 155 170 dm_bufio_release(buf); 156 171 157 - par = fec_read_parity(v, rsb, block_offset, &offset, &buf, bio_prio(bio)); 172 + par = fec_read_parity(v, rsb, block_offset, &offset, 173 + par_buf_offset, &buf, bio_prio(bio)); 158 174 if (IS_ERR(par)) 159 175 return PTR_ERR(par); 160 176 } ··· 728 724 return -E2BIG; 729 725 } 730 726 731 - if ((f->roots << SECTOR_SHIFT) & ((1 << v->data_dev_block_bits) - 1)) 732 - f->io_size = 1 << v->data_dev_block_bits; 733 - else 734 - f->io_size = v->fec->roots << SECTOR_SHIFT; 727 + f->io_size = 1 << v->data_dev_block_bits; 735 728 736 729 f->bufio = dm_bufio_client_create(f->dev->bdev, 737 730 f->io_size,
+12 -7
drivers/md/persistent-data/dm-array.c
··· 917 917 if (c->block) 918 918 unlock_ablock(c->info, c->block); 919 919 920 - c->block = NULL; 921 - c->ab = NULL; 922 920 c->index = 0; 923 921 924 922 r = dm_btree_cursor_get_value(&c->cursor, &key, &value_le); 925 923 if (r) { 926 924 DMERR("dm_btree_cursor_get_value failed"); 927 - dm_btree_cursor_end(&c->cursor); 925 + goto out; 928 926 929 927 } else { 930 928 r = get_ablock(c->info, le64_to_cpu(value_le), &c->block, &c->ab); 931 929 if (r) { 932 930 DMERR("get_ablock failed"); 933 - dm_btree_cursor_end(&c->cursor); 931 + goto out; 934 932 } 935 933 } 936 934 935 + return 0; 936 + 937 + out: 938 + dm_btree_cursor_end(&c->cursor); 939 + c->block = NULL; 940 + c->ab = NULL; 937 941 return r; 938 942 } 939 943 ··· 960 956 961 957 void dm_array_cursor_end(struct dm_array_cursor *c) 962 958 { 963 - if (c->block) { 959 + if (c->block) 964 960 unlock_ablock(c->info, c->block); 965 - dm_btree_cursor_end(&c->cursor); 966 - } 961 + 962 + dm_btree_cursor_end(&c->cursor); 967 963 } 968 964 EXPORT_SYMBOL_GPL(dm_array_cursor_end); 969 965 ··· 1003 999 } 1004 1000 1005 1001 count -= remaining; 1002 + c->index += (remaining - 1); 1006 1003 r = dm_array_cursor_next(c); 1007 1004 1008 1005 } while (!r);
+1 -1
drivers/net/ethernet/amd/pds_core/devlink.c
··· 118 118 if (err && err != -EIO) 119 119 return err; 120 120 121 - listlen = fw_list.num_fw_slots; 121 + listlen = min(fw_list.num_fw_slots, ARRAY_SIZE(fw_list.fw_names)); 122 122 for (i = 0; i < listlen; i++) { 123 123 if (i < ARRAY_SIZE(fw_slotnames)) 124 124 strscpy(buf, fw_slotnames[i], sizeof(buf));
+33 -5
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 2897 2897 return 0; 2898 2898 } 2899 2899 2900 + static bool bnxt_vnic_is_active(struct bnxt *bp) 2901 + { 2902 + struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; 2903 + 2904 + return vnic->fw_vnic_id != INVALID_HW_RING_ID && vnic->mru > 0; 2905 + } 2906 + 2900 2907 static irqreturn_t bnxt_msix(int irq, void *dev_instance) 2901 2908 { 2902 2909 struct bnxt_napi *bnapi = dev_instance; ··· 3171 3164 break; 3172 3165 } 3173 3166 } 3174 - if (bp->flags & BNXT_FLAG_DIM) { 3167 + if ((bp->flags & BNXT_FLAG_DIM) && bnxt_vnic_is_active(bp)) { 3175 3168 struct dim_sample dim_sample = {}; 3176 3169 3177 3170 dim_update_sample(cpr->event_ctr, ··· 3302 3295 poll_done: 3303 3296 cpr_rx = &cpr->cp_ring_arr[0]; 3304 3297 if (cpr_rx->cp_ring_type == BNXT_NQ_HDL_TYPE_RX && 3305 - (bp->flags & BNXT_FLAG_DIM)) { 3298 + (bp->flags & BNXT_FLAG_DIM) && bnxt_vnic_is_active(bp)) { 3306 3299 struct dim_sample dim_sample = {}; 3307 3300 3308 3301 dim_update_sample(cpr->event_ctr, ··· 7273 7266 return rc; 7274 7267 } 7275 7268 7269 + static void bnxt_cancel_dim(struct bnxt *bp) 7270 + { 7271 + int i; 7272 + 7273 + /* DIM work is initialized in bnxt_enable_napi(). Proceed only 7274 + * if NAPI is enabled. 7275 + */ 7276 + if (!bp->bnapi || test_bit(BNXT_STATE_NAPI_DISABLED, &bp->state)) 7277 + return; 7278 + 7279 + /* Make sure NAPI sees that the VNIC is disabled */ 7280 + synchronize_net(); 7281 + for (i = 0; i < bp->rx_nr_rings; i++) { 7282 + struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; 7283 + struct bnxt_napi *bnapi = rxr->bnapi; 7284 + 7285 + cancel_work_sync(&bnapi->cp_ring.dim.work); 7286 + } 7287 + } 7288 + 7276 7289 static int hwrm_ring_free_send_msg(struct bnxt *bp, 7277 7290 struct bnxt_ring_struct *ring, 7278 7291 u32 ring_type, int cmpl_ring_id) ··· 7393 7366 } 7394 7367 } 7395 7368 7369 + bnxt_cancel_dim(bp); 7396 7370 for (i = 0; i < bp->rx_nr_rings; i++) { 7397 7371 bnxt_hwrm_rx_ring_free(bp, &bp->rx_ring[i], close_path); 7398 7372 bnxt_hwrm_rx_agg_ring_free(bp, &bp->rx_ring[i], close_path); ··· 11358 11330 if (bnapi->in_reset) 11359 11331 cpr->sw_stats->rx.rx_resets++; 11360 11332 napi_disable(&bnapi->napi); 11361 - if (bnapi->rx_ring) 11362 - cancel_work_sync(&cpr->dim.work); 11363 11333 } 11364 11334 } 11365 11335 ··· 15639 15613 bnxt_hwrm_vnic_update(bp, vnic, 15640 15614 VNIC_UPDATE_REQ_ENABLES_MRU_VALID); 15641 15615 } 15642 - 15616 + /* Make sure NAPI sees that the VNIC is disabled */ 15617 + synchronize_net(); 15643 15618 rxr = &bp->rx_ring[idx]; 15619 + cancel_work_sync(&rxr->bnapi->cp_ring.dim.work); 15644 15620 bnxt_hwrm_rx_ring_free(bp, rxr, false); 15645 15621 bnxt_hwrm_rx_agg_ring_free(bp, rxr, false); 15646 15622 rxr->rx_next_cons = 0;
+2 -1
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
··· 208 208 209 209 rc = hwrm_req_replace(bp, req, fw_msg->msg, fw_msg->msg_len); 210 210 if (rc) 211 - return rc; 211 + goto drop_req; 212 212 213 213 hwrm_req_timeout(bp, req, fw_msg->timeout); 214 214 resp = hwrm_req_hold(bp, req); ··· 220 220 221 221 memcpy(fw_msg->resp, resp, resp_len); 222 222 } 223 + drop_req: 223 224 hwrm_req_drop(bp, req); 224 225 return rc; 225 226 }
+4 -1
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
··· 1799 1799 struct adapter *adap = container_of(t, struct adapter, tids); 1800 1800 struct sk_buff *skb; 1801 1801 1802 - WARN_ON(tid_out_of_range(&adap->tids, tid)); 1802 + if (tid_out_of_range(&adap->tids, tid)) { 1803 + dev_err(adap->pdev_dev, "tid %d out of range\n", tid); 1804 + return; 1805 + } 1803 1806 1804 1807 if (t->tid_tab[tid - adap->tids.tid_base]) { 1805 1808 t->tid_tab[tid - adap->tids.tid_base] = NULL;
+9 -5
drivers/net/ethernet/google/gve/gve_main.c
··· 2241 2241 2242 2242 static void gve_set_netdev_xdp_features(struct gve_priv *priv) 2243 2243 { 2244 + xdp_features_t xdp_features; 2245 + 2244 2246 if (priv->queue_format == GVE_GQI_QPL_FORMAT) { 2245 - priv->dev->xdp_features = NETDEV_XDP_ACT_BASIC; 2246 - priv->dev->xdp_features |= NETDEV_XDP_ACT_REDIRECT; 2247 - priv->dev->xdp_features |= NETDEV_XDP_ACT_NDO_XMIT; 2248 - priv->dev->xdp_features |= NETDEV_XDP_ACT_XSK_ZEROCOPY; 2247 + xdp_features = NETDEV_XDP_ACT_BASIC; 2248 + xdp_features |= NETDEV_XDP_ACT_REDIRECT; 2249 + xdp_features |= NETDEV_XDP_ACT_NDO_XMIT; 2250 + xdp_features |= NETDEV_XDP_ACT_XSK_ZEROCOPY; 2249 2251 } else { 2250 - priv->dev->xdp_features = 0; 2252 + xdp_features = 0; 2251 2253 } 2254 + 2255 + xdp_set_features_flag(priv->dev, xdp_features); 2252 2256 } 2253 2257 2254 2258 static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
-3
drivers/net/ethernet/hisilicon/hns3/hnae3.h
··· 916 916 917 917 u8 netdev_flags; 918 918 struct dentry *hnae3_dbgfs; 919 - /* protects concurrent contention between debugfs commands */ 920 - struct mutex dbgfs_lock; 921 - char **dbgfs_buf; 922 919 923 920 /* Network interface message level enabled bits */ 924 921 u32 msg_enable;
+31 -65
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
··· 1260 1260 static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer, 1261 1261 size_t count, loff_t *ppos) 1262 1262 { 1263 - struct hns3_dbg_data *dbg_data = filp->private_data; 1263 + char *buf = filp->private_data; 1264 + 1265 + return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf)); 1266 + } 1267 + 1268 + static int hns3_dbg_open(struct inode *inode, struct file *filp) 1269 + { 1270 + struct hns3_dbg_data *dbg_data = inode->i_private; 1264 1271 struct hnae3_handle *handle = dbg_data->handle; 1265 1272 struct hns3_nic_priv *priv = handle->priv; 1266 - ssize_t size = 0; 1267 - char **save_buf; 1268 - char *read_buf; 1269 1273 u32 index; 1274 + char *buf; 1270 1275 int ret; 1276 + 1277 + if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state) || 1278 + test_bit(HNS3_NIC_STATE_RESETTING, &priv->state)) 1279 + return -EBUSY; 1271 1280 1272 1281 ret = hns3_dbg_get_cmd_index(dbg_data, &index); 1273 1282 if (ret) 1274 1283 return ret; 1275 1284 1276 - mutex_lock(&handle->dbgfs_lock); 1277 - save_buf = &handle->dbgfs_buf[index]; 1285 + buf = kvzalloc(hns3_dbg_cmd[index].buf_len, GFP_KERNEL); 1286 + if (!buf) 1287 + return -ENOMEM; 1278 1288 1279 - if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state) || 1280 - test_bit(HNS3_NIC_STATE_RESETTING, &priv->state)) { 1281 - ret = -EBUSY; 1282 - goto out; 1289 + ret = hns3_dbg_read_cmd(dbg_data, hns3_dbg_cmd[index].cmd, 1290 + buf, hns3_dbg_cmd[index].buf_len); 1291 + if (ret) { 1292 + kvfree(buf); 1293 + return ret; 1283 1294 } 1284 1295 1285 - if (*save_buf) { 1286 - read_buf = *save_buf; 1287 - } else { 1288 - read_buf = kvzalloc(hns3_dbg_cmd[index].buf_len, GFP_KERNEL); 1289 - if (!read_buf) { 1290 - ret = -ENOMEM; 1291 - goto out; 1292 - } 1296 + filp->private_data = buf; 1297 + return 0; 1298 + } 1293 1299 1294 - /* save the buffer addr until the last read operation */ 1295 - *save_buf = read_buf; 1296 - 1297 - /* get data ready for the first time to read */ 1298 - ret = hns3_dbg_read_cmd(dbg_data, hns3_dbg_cmd[index].cmd, 1299 - read_buf, hns3_dbg_cmd[index].buf_len); 1300 - if (ret) 1301 - goto out; 1302 - } 1303 - 1304 - size = simple_read_from_buffer(buffer, count, ppos, read_buf, 1305 - strlen(read_buf)); 1306 - if (size > 0) { 1307 - mutex_unlock(&handle->dbgfs_lock); 1308 - return size; 1309 - } 1310 - 1311 - out: 1312 - /* free the buffer for the last read operation */ 1313 - if (*save_buf) { 1314 - kvfree(*save_buf); 1315 - *save_buf = NULL; 1316 - } 1317 - 1318 - mutex_unlock(&handle->dbgfs_lock); 1319 - return ret; 1300 + static int hns3_dbg_release(struct inode *inode, struct file *filp) 1301 + { 1302 + kvfree(filp->private_data); 1303 + filp->private_data = NULL; 1304 + return 0; 1320 1305 } 1321 1306 1322 1307 static const struct file_operations hns3_dbg_fops = { 1323 1308 .owner = THIS_MODULE, 1324 - .open = simple_open, 1309 + .open = hns3_dbg_open, 1325 1310 .read = hns3_dbg_read, 1311 + .release = hns3_dbg_release, 1326 1312 }; 1327 1313 1328 1314 static int hns3_dbg_bd_file_init(struct hnae3_handle *handle, u32 cmd) ··· 1365 1379 int ret; 1366 1380 u32 i; 1367 1381 1368 - handle->dbgfs_buf = devm_kcalloc(&handle->pdev->dev, 1369 - ARRAY_SIZE(hns3_dbg_cmd), 1370 - sizeof(*handle->dbgfs_buf), 1371 - GFP_KERNEL); 1372 - if (!handle->dbgfs_buf) 1373 - return -ENOMEM; 1374 - 1375 1382 hns3_dbg_dentry[HNS3_DBG_DENTRY_COMMON].dentry = 1376 1383 debugfs_create_dir(name, hns3_dbgfs_root); 1377 1384 handle->hnae3_dbgfs = hns3_dbg_dentry[HNS3_DBG_DENTRY_COMMON].dentry; ··· 1373 1394 hns3_dbg_dentry[i].dentry = 1374 1395 debugfs_create_dir(hns3_dbg_dentry[i].name, 1375 1396 handle->hnae3_dbgfs); 1376 - 1377 - mutex_init(&handle->dbgfs_lock); 1378 1397 1379 1398 for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++) { 1380 1399 if ((hns3_dbg_cmd[i].cmd == HNAE3_DBG_CMD_TM_NODES && ··· 1402 1425 out: 1403 1426 debugfs_remove_recursive(handle->hnae3_dbgfs); 1404 1427 handle->hnae3_dbgfs = NULL; 1405 - mutex_destroy(&handle->dbgfs_lock); 1406 1428 return ret; 1407 1429 } 1408 1430 1409 1431 void hns3_dbg_uninit(struct hnae3_handle *handle) 1410 1432 { 1411 - u32 i; 1412 - 1413 1433 debugfs_remove_recursive(handle->hnae3_dbgfs); 1414 1434 handle->hnae3_dbgfs = NULL; 1415 - 1416 - for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++) 1417 - if (handle->dbgfs_buf[i]) { 1418 - kvfree(handle->dbgfs_buf[i]); 1419 - handle->dbgfs_buf[i] = NULL; 1420 - } 1421 - 1422 - mutex_destroy(&handle->dbgfs_lock); 1423 1435 } 1424 1436 1425 1437 void hns3_dbg_register_debugfs(const char *debugfs_dir_name)
-1
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
··· 2452 2452 return ret; 2453 2453 } 2454 2454 2455 - netdev->features = features; 2456 2455 return 0; 2457 2456 } 2458 2457
+36 -9
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
··· 6 6 #include <linux/etherdevice.h> 7 7 #include <linux/init.h> 8 8 #include <linux/interrupt.h> 9 + #include <linux/irq.h> 9 10 #include <linux/kernel.h> 10 11 #include <linux/module.h> 11 12 #include <linux/netdevice.h> ··· 3575 3574 return ret; 3576 3575 } 3577 3576 3577 + static void hclge_set_reset_pending(struct hclge_dev *hdev, 3578 + enum hnae3_reset_type reset_type) 3579 + { 3580 + /* When an incorrect reset type is executed, the get_reset_level 3581 + * function generates the HNAE3_NONE_RESET flag. As a result, this 3582 + * type do not need to pending. 3583 + */ 3584 + if (reset_type != HNAE3_NONE_RESET) 3585 + set_bit(reset_type, &hdev->reset_pending); 3586 + } 3587 + 3578 3588 static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval) 3579 3589 { 3580 3590 u32 cmdq_src_reg, msix_src_reg, hw_err_src_reg; ··· 3606 3594 */ 3607 3595 if (BIT(HCLGE_VECTOR0_IMPRESET_INT_B) & msix_src_reg) { 3608 3596 dev_info(&hdev->pdev->dev, "IMP reset interrupt\n"); 3609 - set_bit(HNAE3_IMP_RESET, &hdev->reset_pending); 3597 + hclge_set_reset_pending(hdev, HNAE3_IMP_RESET); 3610 3598 set_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state); 3611 3599 *clearval = BIT(HCLGE_VECTOR0_IMPRESET_INT_B); 3612 3600 hdev->rst_stats.imp_rst_cnt++; ··· 3616 3604 if (BIT(HCLGE_VECTOR0_GLOBALRESET_INT_B) & msix_src_reg) { 3617 3605 dev_info(&hdev->pdev->dev, "global reset interrupt\n"); 3618 3606 set_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state); 3619 - set_bit(HNAE3_GLOBAL_RESET, &hdev->reset_pending); 3607 + hclge_set_reset_pending(hdev, HNAE3_GLOBAL_RESET); 3620 3608 *clearval = BIT(HCLGE_VECTOR0_GLOBALRESET_INT_B); 3621 3609 hdev->rst_stats.global_rst_cnt++; 3622 3610 return HCLGE_VECTOR0_EVENT_RST; ··· 3771 3759 snprintf(hdev->misc_vector.name, HNAE3_INT_NAME_LEN, "%s-misc-%s", 3772 3760 HCLGE_NAME, pci_name(hdev->pdev)); 3773 3761 ret = request_irq(hdev->misc_vector.vector_irq, hclge_misc_irq_handle, 3774 - 0, hdev->misc_vector.name, hdev); 3762 + IRQF_NO_AUTOEN, hdev->misc_vector.name, hdev); 3775 3763 if (ret) { 3776 3764 hclge_free_vector(hdev, 0); 3777 3765 dev_err(&hdev->pdev->dev, "request misc irq(%d) fail\n", ··· 4064 4052 case HNAE3_FUNC_RESET: 4065 4053 dev_info(&pdev->dev, "PF reset requested\n"); 4066 4054 /* schedule again to check later */ 4067 - set_bit(HNAE3_FUNC_RESET, &hdev->reset_pending); 4055 + hclge_set_reset_pending(hdev, HNAE3_FUNC_RESET); 4068 4056 hclge_reset_task_schedule(hdev); 4069 4057 break; 4070 4058 default: ··· 4097 4085 rst_level = HNAE3_FLR_RESET; 4098 4086 clear_bit(HNAE3_FLR_RESET, addr); 4099 4087 } 4088 + 4089 + clear_bit(HNAE3_NONE_RESET, addr); 4100 4090 4101 4091 if (hdev->reset_type != HNAE3_NONE_RESET && 4102 4092 rst_level < hdev->reset_type) ··· 4241 4227 return false; 4242 4228 } else if (hdev->rst_stats.reset_fail_cnt < MAX_RESET_FAIL_CNT) { 4243 4229 hdev->rst_stats.reset_fail_cnt++; 4244 - set_bit(hdev->reset_type, &hdev->reset_pending); 4230 + hclge_set_reset_pending(hdev, hdev->reset_type); 4245 4231 dev_info(&hdev->pdev->dev, 4246 4232 "re-schedule reset task(%u)\n", 4247 4233 hdev->rst_stats.reset_fail_cnt); ··· 4484 4470 static void hclge_set_def_reset_request(struct hnae3_ae_dev *ae_dev, 4485 4471 enum hnae3_reset_type rst_type) 4486 4472 { 4473 + #define HCLGE_SUPPORT_RESET_TYPE \ 4474 + (BIT(HNAE3_FLR_RESET) | BIT(HNAE3_FUNC_RESET) | \ 4475 + BIT(HNAE3_GLOBAL_RESET) | BIT(HNAE3_IMP_RESET)) 4476 + 4487 4477 struct hclge_dev *hdev = ae_dev->priv; 4478 + 4479 + if (!(BIT(rst_type) & HCLGE_SUPPORT_RESET_TYPE)) { 4480 + /* To prevent reset triggered by hclge_reset_event */ 4481 + set_bit(HNAE3_NONE_RESET, &hdev->default_reset_request); 4482 + dev_warn(&hdev->pdev->dev, "unsupported reset type %d\n", 4483 + rst_type); 4484 + return; 4485 + } 4488 4486 4489 4487 set_bit(rst_type, &hdev->default_reset_request); 4490 4488 } ··· 11907 11881 11908 11882 hclge_init_rxd_adv_layout(hdev); 11909 11883 11910 - /* Enable MISC vector(vector0) */ 11911 - hclge_enable_vector(&hdev->misc_vector, true); 11912 - 11913 11884 ret = hclge_init_wol(hdev); 11914 11885 if (ret) 11915 11886 dev_warn(&pdev->dev, ··· 11918 11895 11919 11896 hclge_state_init(hdev); 11920 11897 hdev->last_reset_time = jiffies; 11898 + 11899 + /* Enable MISC vector(vector0) */ 11900 + enable_irq(hdev->misc_vector.vector_irq); 11901 + hclge_enable_vector(&hdev->misc_vector, true); 11921 11902 11922 11903 dev_info(&hdev->pdev->dev, "%s driver initialization finished.\n", 11923 11904 HCLGE_DRIVER_NAME); ··· 12328 12301 12329 12302 /* Disable MISC vector(vector0) */ 12330 12303 hclge_enable_vector(&hdev->misc_vector, false); 12331 - synchronize_irq(hdev->misc_vector.vector_irq); 12304 + disable_irq(hdev->misc_vector.vector_irq); 12332 12305 12333 12306 /* Disable all hw interrupts */ 12334 12307 hclge_config_mac_tnl_int(hdev, false);
+3
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
··· 58 58 struct hclge_dev *hdev = vport->back; 59 59 struct hclge_ptp *ptp = hdev->ptp; 60 60 61 + if (!ptp) 62 + return false; 63 + 61 64 if (!test_bit(HCLGE_PTP_FLAG_TX_EN, &ptp->flags) || 62 65 test_and_set_bit(HCLGE_STATE_PTP_TX_HANDLING, &hdev->state)) { 63 66 ptp->tx_skipped++;
+5 -4
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_regs.c
··· 510 510 static int hclge_fetch_pf_reg(struct hclge_dev *hdev, void *data, 511 511 struct hnae3_knic_private_info *kinfo) 512 512 { 513 - #define HCLGE_RING_REG_OFFSET 0x200 514 513 #define HCLGE_RING_INT_REG_OFFSET 0x4 515 514 515 + struct hnae3_queue *tqp; 516 516 int i, j, reg_num; 517 517 int data_num_sum; 518 518 u32 *reg = data; ··· 533 533 reg_num = ARRAY_SIZE(ring_reg_addr_list); 534 534 for (j = 0; j < kinfo->num_tqps; j++) { 535 535 reg += hclge_reg_get_tlv(HCLGE_REG_TAG_RING, reg_num, reg); 536 + tqp = kinfo->tqp[j]; 536 537 for (i = 0; i < reg_num; i++) 537 - *reg++ = hclge_read_dev(&hdev->hw, 538 - ring_reg_addr_list[i] + 539 - HCLGE_RING_REG_OFFSET * j); 538 + *reg++ = readl_relaxed(tqp->io_base - 539 + HCLGE_TQP_REG_OFFSET + 540 + ring_reg_addr_list[i]); 540 541 } 541 542 data_num_sum += (reg_num + HCLGE_REG_TLV_SPACE) * kinfo->num_tqps; 542 543
+34 -7
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
··· 1393 1393 return ret; 1394 1394 } 1395 1395 1396 + static void hclgevf_set_reset_pending(struct hclgevf_dev *hdev, 1397 + enum hnae3_reset_type reset_type) 1398 + { 1399 + /* When an incorrect reset type is executed, the get_reset_level 1400 + * function generates the HNAE3_NONE_RESET flag. As a result, this 1401 + * type do not need to pending. 1402 + */ 1403 + if (reset_type != HNAE3_NONE_RESET) 1404 + set_bit(reset_type, &hdev->reset_pending); 1405 + } 1406 + 1396 1407 static int hclgevf_reset_wait(struct hclgevf_dev *hdev) 1397 1408 { 1398 1409 #define HCLGEVF_RESET_WAIT_US 20000 ··· 1553 1542 hdev->rst_stats.rst_fail_cnt); 1554 1543 1555 1544 if (hdev->rst_stats.rst_fail_cnt < HCLGEVF_RESET_MAX_FAIL_CNT) 1556 - set_bit(hdev->reset_type, &hdev->reset_pending); 1545 + hclgevf_set_reset_pending(hdev, hdev->reset_type); 1557 1546 1558 1547 if (hclgevf_is_reset_pending(hdev)) { 1559 1548 set_bit(HCLGEVF_RESET_PENDING, &hdev->reset_state); ··· 1673 1662 clear_bit(HNAE3_FLR_RESET, addr); 1674 1663 } 1675 1664 1665 + clear_bit(HNAE3_NONE_RESET, addr); 1666 + 1676 1667 return rst_level; 1677 1668 } 1678 1669 ··· 1684 1671 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev); 1685 1672 struct hclgevf_dev *hdev = ae_dev->priv; 1686 1673 1687 - dev_info(&hdev->pdev->dev, "received reset request from VF enet\n"); 1688 - 1689 1674 if (hdev->default_reset_request) 1690 1675 hdev->reset_level = 1691 1676 hclgevf_get_reset_level(&hdev->default_reset_request); 1692 1677 else 1693 1678 hdev->reset_level = HNAE3_VF_FUNC_RESET; 1679 + 1680 + dev_info(&hdev->pdev->dev, "received reset request from VF enet, reset level is %d\n", 1681 + hdev->reset_level); 1694 1682 1695 1683 /* reset of this VF requested */ 1696 1684 set_bit(HCLGEVF_RESET_REQUESTED, &hdev->reset_state); ··· 1703 1689 static void hclgevf_set_def_reset_request(struct hnae3_ae_dev *ae_dev, 1704 1690 enum hnae3_reset_type rst_type) 1705 1691 { 1692 + #define HCLGEVF_SUPPORT_RESET_TYPE \ 1693 + (BIT(HNAE3_VF_RESET) | BIT(HNAE3_VF_FUNC_RESET) | \ 1694 + BIT(HNAE3_VF_PF_FUNC_RESET) | BIT(HNAE3_VF_FULL_RESET) | \ 1695 + BIT(HNAE3_FLR_RESET) | BIT(HNAE3_VF_EXP_RESET)) 1696 + 1706 1697 struct hclgevf_dev *hdev = ae_dev->priv; 1707 1698 1699 + if (!(BIT(rst_type) & HCLGEVF_SUPPORT_RESET_TYPE)) { 1700 + /* To prevent reset triggered by hclge_reset_event */ 1701 + set_bit(HNAE3_NONE_RESET, &hdev->default_reset_request); 1702 + dev_info(&hdev->pdev->dev, "unsupported reset type %d\n", 1703 + rst_type); 1704 + return; 1705 + } 1708 1706 set_bit(rst_type, &hdev->default_reset_request); 1709 1707 } 1710 1708 ··· 1873 1847 */ 1874 1848 if (hdev->reset_attempts > HCLGEVF_MAX_RESET_ATTEMPTS_CNT) { 1875 1849 /* prepare for full reset of stack + pcie interface */ 1876 - set_bit(HNAE3_VF_FULL_RESET, &hdev->reset_pending); 1850 + hclgevf_set_reset_pending(hdev, HNAE3_VF_FULL_RESET); 1877 1851 1878 1852 /* "defer" schedule the reset task again */ 1879 1853 set_bit(HCLGEVF_RESET_PENDING, &hdev->reset_state); 1880 1854 } else { 1881 1855 hdev->reset_attempts++; 1882 1856 1883 - set_bit(hdev->reset_level, &hdev->reset_pending); 1857 + hclgevf_set_reset_pending(hdev, hdev->reset_level); 1884 1858 set_bit(HCLGEVF_RESET_PENDING, &hdev->reset_state); 1885 1859 } 1886 1860 hclgevf_reset_task_schedule(hdev); ··· 2003 1977 rst_ing_reg = hclgevf_read_dev(&hdev->hw, HCLGEVF_RST_ING); 2004 1978 dev_info(&hdev->pdev->dev, 2005 1979 "receive reset interrupt 0x%x!\n", rst_ing_reg); 2006 - set_bit(HNAE3_VF_RESET, &hdev->reset_pending); 1980 + hclgevf_set_reset_pending(hdev, HNAE3_VF_RESET); 2007 1981 set_bit(HCLGEVF_RESET_PENDING, &hdev->reset_state); 2008 1982 set_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state); 2009 1983 *clearval = ~(1U << HCLGEVF_VECTOR0_RST_INT_B); ··· 2313 2287 clear_bit(HCLGEVF_STATE_RST_FAIL, &hdev->state); 2314 2288 2315 2289 INIT_DELAYED_WORK(&hdev->service_task, hclgevf_service_task); 2290 + /* timer needs to be initialized before misc irq */ 2291 + timer_setup(&hdev->reset_timer, hclgevf_reset_timer, 0); 2316 2292 2317 2293 mutex_init(&hdev->mbx_resp.mbx_mutex); 2318 2294 sema_init(&hdev->reset_sem, 1); ··· 3014 2986 HCLGEVF_DRIVER_NAME); 3015 2987 3016 2988 hclgevf_task_schedule(hdev, round_jiffies_relative(HZ)); 3017 - timer_setup(&hdev->reset_timer, hclgevf_reset_timer, 0); 3018 2989 3019 2990 return 0; 3020 2991
+5 -4
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c
··· 123 123 void hclgevf_get_regs(struct hnae3_handle *handle, u32 *version, 124 124 void *data) 125 125 { 126 - #define HCLGEVF_RING_REG_OFFSET 0x200 127 126 #define HCLGEVF_RING_INT_REG_OFFSET 0x4 128 127 129 128 struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); 129 + struct hnae3_queue *tqp; 130 130 int i, j, reg_um; 131 131 u32 *reg = data; 132 132 ··· 147 147 reg_um = ARRAY_SIZE(ring_reg_addr_list); 148 148 for (j = 0; j < hdev->num_tqps; j++) { 149 149 reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_RING, reg_um, reg); 150 + tqp = &hdev->htqp[j].q; 150 151 for (i = 0; i < reg_um; i++) 151 - *reg++ = hclgevf_read_dev(&hdev->hw, 152 - ring_reg_addr_list[i] + 153 - HCLGEVF_RING_REG_OFFSET * j); 152 + *reg++ = readl_relaxed(tqp->io_base - 153 + HCLGEVF_TQP_REG_OFFSET + 154 + ring_reg_addr_list[i]); 154 155 } 155 156 156 157 reg_um = ARRAY_SIZE(tqp_intr_reg_addr_list);
+2
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
··· 2271 2271 struct ice_aqc_get_pkg_info pkg_info[]; 2272 2272 }; 2273 2273 2274 + #define ICE_AQC_GET_CGU_MAX_PHASE_ADJ GENMASK(30, 0) 2275 + 2274 2276 /* Get CGU abilities command response data structure (indirect 0x0C61) */ 2275 2277 struct ice_aqc_get_cgu_abilities { 2276 2278 u8 num_inputs;
+23 -12
drivers/net/ethernet/intel/ice/ice_dpll.c
··· 2065 2065 } 2066 2066 2067 2067 /** 2068 + * ice_dpll_phase_range_set - initialize phase adjust range helper 2069 + * @range: pointer to phase adjust range struct to be initialized 2070 + * @phase_adj: a value to be used as min(-)/max(+) boundary 2071 + */ 2072 + static void ice_dpll_phase_range_set(struct dpll_pin_phase_adjust_range *range, 2073 + u32 phase_adj) 2074 + { 2075 + range->min = -phase_adj; 2076 + range->max = phase_adj; 2077 + } 2078 + 2079 + /** 2068 2080 * ice_dpll_init_info_pins_generic - initializes generic pins info 2069 2081 * @pf: board private structure 2070 2082 * @input: if input pins initialized ··· 2117 2105 for (i = 0; i < pin_num; i++) { 2118 2106 pins[i].idx = i; 2119 2107 pins[i].prop.board_label = labels[i]; 2120 - pins[i].prop.phase_range.min = phase_adj_max; 2121 - pins[i].prop.phase_range.max = -phase_adj_max; 2108 + ice_dpll_phase_range_set(&pins[i].prop.phase_range, 2109 + phase_adj_max); 2122 2110 pins[i].prop.capabilities = cap; 2123 2111 pins[i].pf = pf; 2124 2112 ret = ice_dpll_pin_state_update(pf, &pins[i], pin_type, NULL); ··· 2164 2152 struct ice_hw *hw = &pf->hw; 2165 2153 struct ice_dpll_pin *pins; 2166 2154 unsigned long caps; 2155 + u32 phase_adj_max; 2167 2156 u8 freq_supp_num; 2168 2157 bool input; 2169 2158 ··· 2172 2159 case ICE_DPLL_PIN_TYPE_INPUT: 2173 2160 pins = pf->dplls.inputs; 2174 2161 num_pins = pf->dplls.num_inputs; 2162 + phase_adj_max = pf->dplls.input_phase_adj_max; 2175 2163 input = true; 2176 2164 break; 2177 2165 case ICE_DPLL_PIN_TYPE_OUTPUT: 2178 2166 pins = pf->dplls.outputs; 2179 2167 num_pins = pf->dplls.num_outputs; 2168 + phase_adj_max = pf->dplls.output_phase_adj_max; 2180 2169 input = false; 2181 2170 break; 2182 2171 default: ··· 2203 2188 return ret; 2204 2189 caps |= (DPLL_PIN_CAPABILITIES_PRIORITY_CAN_CHANGE | 2205 2190 DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE); 2206 - pins[i].prop.phase_range.min = 2207 - pf->dplls.input_phase_adj_max; 2208 - pins[i].prop.phase_range.max = 2209 - -pf->dplls.input_phase_adj_max; 2210 2191 } else { 2211 - pins[i].prop.phase_range.min = 2212 - pf->dplls.output_phase_adj_max; 2213 - pins[i].prop.phase_range.max = 2214 - -pf->dplls.output_phase_adj_max; 2215 2192 ret = ice_cgu_get_output_pin_state_caps(hw, i, &caps); 2216 2193 if (ret) 2217 2194 return ret; 2218 2195 } 2196 + ice_dpll_phase_range_set(&pins[i].prop.phase_range, 2197 + phase_adj_max); 2219 2198 pins[i].prop.capabilities = caps; 2220 2199 ret = ice_dpll_pin_state_update(pf, &pins[i], pin_type, NULL); 2221 2200 if (ret) ··· 2317 2308 dp->dpll_idx = abilities.pps_dpll_idx; 2318 2309 d->num_inputs = abilities.num_inputs; 2319 2310 d->num_outputs = abilities.num_outputs; 2320 - d->input_phase_adj_max = le32_to_cpu(abilities.max_in_phase_adj); 2321 - d->output_phase_adj_max = le32_to_cpu(abilities.max_out_phase_adj); 2311 + d->input_phase_adj_max = le32_to_cpu(abilities.max_in_phase_adj) & 2312 + ICE_AQC_GET_CGU_MAX_PHASE_ADJ; 2313 + d->output_phase_adj_max = le32_to_cpu(abilities.max_out_phase_adj) & 2314 + ICE_AQC_GET_CGU_MAX_PHASE_ADJ; 2322 2315 2323 2316 alloc_size = sizeof(*d->inputs) * d->num_inputs; 2324 2317 d->inputs = kzalloc(alloc_size, GFP_KERNEL);
+2 -2
drivers/net/ethernet/intel/ice/ice_ptp_consts.h
··· 761 761 /* rx_desk_rsgb_par */ 762 762 644531250, /* 644.53125 MHz Reed Solomon gearbox */ 763 763 /* tx_desk_rsgb_pcs */ 764 - 644531250, /* 644.53125 MHz Reed Solomon gearbox */ 764 + 390625000, /* 390.625 MHz Reed Solomon gearbox */ 765 765 /* rx_desk_rsgb_pcs */ 766 - 644531250, /* 644.53125 MHz Reed Solomon gearbox */ 766 + 390625000, /* 390.625 MHz Reed Solomon gearbox */ 767 767 /* tx_fixed_delay */ 768 768 1620, 769 769 /* pmd_adj_divisor */
+6
drivers/net/ethernet/intel/igc/igc_base.c
··· 68 68 u32 eecd = rd32(IGC_EECD); 69 69 u16 size; 70 70 71 + /* failed to read reg and got all F's */ 72 + if (!(~eecd)) 73 + return -ENXIO; 74 + 71 75 size = FIELD_GET(IGC_EECD_SIZE_EX_MASK, eecd); 72 76 73 77 /* Added to a constant, "size" becomes the left-shift value ··· 225 221 226 222 /* NVM initialization */ 227 223 ret_val = igc_init_nvm_params_base(hw); 224 + if (ret_val) 225 + goto out; 228 226 switch (hw->mac.type) { 229 227 case igc_i225: 230 228 ret_val = igc_init_nvm_params_i225(hw);
+1
drivers/net/ethernet/mellanox/mlx5/core/cmd.c
··· 1013 1013 complete(&ent->done); 1014 1014 } 1015 1015 up(&cmd->vars.sem); 1016 + complete(&ent->slotted); 1016 1017 return; 1017 1018 } 1018 1019 } else {
-1
drivers/net/ethernet/meta/fbnic/Makefile
··· 13 13 fbnic_ethtool.o \ 14 14 fbnic_fw.o \ 15 15 fbnic_hw_stats.o \ 16 - fbnic_hwmon.o \ 17 16 fbnic_irq.o \ 18 17 fbnic_mac.o \ 19 18 fbnic_netdev.o \
-5
drivers/net/ethernet/meta/fbnic/fbnic.h
··· 24 24 struct device *dev; 25 25 struct net_device *netdev; 26 26 struct dentry *dbg_fbd; 27 - struct device *hwmon; 28 27 29 28 u32 __iomem *uc_addr0; 30 29 u32 __iomem *uc_addr4; ··· 41 42 42 43 struct fbnic_fw_mbx mbx[FBNIC_IPC_MBX_INDICES]; 43 44 struct fbnic_fw_cap fw_cap; 44 - struct fbnic_fw_completion *cmpl_data; 45 45 /* Lock protecting Tx Mailbox queue to prevent possible races */ 46 46 spinlock_t fw_tx_lock; 47 47 ··· 148 150 149 151 int fbnic_fw_enable_mbx(struct fbnic_dev *fbd); 150 152 void fbnic_fw_disable_mbx(struct fbnic_dev *fbd); 151 - 152 - void fbnic_hwmon_register(struct fbnic_dev *fbd); 153 - void fbnic_hwmon_unregister(struct fbnic_dev *fbd); 154 153 155 154 int fbnic_pcs_irq_enable(struct fbnic_dev *fbd); 156 155 void fbnic_pcs_irq_disable(struct fbnic_dev *fbd);
-7
drivers/net/ethernet/meta/fbnic/fbnic_fw.h
··· 44 44 u8 link_fec; 45 45 }; 46 46 47 - struct fbnic_fw_completion { 48 - struct { 49 - s32 millivolts; 50 - s32 millidegrees; 51 - } tsene; 52 - }; 53 - 54 47 void fbnic_mbx_init(struct fbnic_dev *fbd); 55 48 void fbnic_mbx_clean(struct fbnic_dev *fbd); 56 49 void fbnic_mbx_poll(struct fbnic_dev *fbd);
-81
drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* Copyright (c) Meta Platforms, Inc. and affiliates. */ 3 - 4 - #include <linux/hwmon.h> 5 - 6 - #include "fbnic.h" 7 - #include "fbnic_mac.h" 8 - 9 - static int fbnic_hwmon_sensor_id(enum hwmon_sensor_types type) 10 - { 11 - if (type == hwmon_temp) 12 - return FBNIC_SENSOR_TEMP; 13 - if (type == hwmon_in) 14 - return FBNIC_SENSOR_VOLTAGE; 15 - 16 - return -EOPNOTSUPP; 17 - } 18 - 19 - static umode_t fbnic_hwmon_is_visible(const void *drvdata, 20 - enum hwmon_sensor_types type, 21 - u32 attr, int channel) 22 - { 23 - if (type == hwmon_temp && attr == hwmon_temp_input) 24 - return 0444; 25 - if (type == hwmon_in && attr == hwmon_in_input) 26 - return 0444; 27 - 28 - return 0; 29 - } 30 - 31 - static int fbnic_hwmon_read(struct device *dev, enum hwmon_sensor_types type, 32 - u32 attr, int channel, long *val) 33 - { 34 - struct fbnic_dev *fbd = dev_get_drvdata(dev); 35 - const struct fbnic_mac *mac = fbd->mac; 36 - int id; 37 - 38 - id = fbnic_hwmon_sensor_id(type); 39 - return id < 0 ? id : mac->get_sensor(fbd, id, val); 40 - } 41 - 42 - static const struct hwmon_ops fbnic_hwmon_ops = { 43 - .is_visible = fbnic_hwmon_is_visible, 44 - .read = fbnic_hwmon_read, 45 - }; 46 - 47 - static const struct hwmon_channel_info *fbnic_hwmon_info[] = { 48 - HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), 49 - HWMON_CHANNEL_INFO(in, HWMON_I_INPUT), 50 - NULL 51 - }; 52 - 53 - static const struct hwmon_chip_info fbnic_chip_info = { 54 - .ops = &fbnic_hwmon_ops, 55 - .info = fbnic_hwmon_info, 56 - }; 57 - 58 - void fbnic_hwmon_register(struct fbnic_dev *fbd) 59 - { 60 - if (!IS_REACHABLE(CONFIG_HWMON)) 61 - return; 62 - 63 - fbd->hwmon = hwmon_device_register_with_info(fbd->dev, "fbnic", 64 - fbd, &fbnic_chip_info, 65 - NULL); 66 - if (IS_ERR(fbd->hwmon)) { 67 - dev_notice(fbd->dev, 68 - "Failed to register hwmon device %pe\n", 69 - fbd->hwmon); 70 - fbd->hwmon = NULL; 71 - } 72 - } 73 - 74 - void fbnic_hwmon_unregister(struct fbnic_dev *fbd) 75 - { 76 - if (!IS_REACHABLE(CONFIG_HWMON) || !fbd->hwmon) 77 - return; 78 - 79 - hwmon_device_unregister(fbd->hwmon); 80 - fbd->hwmon = NULL; 81 - }
-22
drivers/net/ethernet/meta/fbnic/fbnic_mac.c
··· 686 686 MAC_STAT_TX_BROADCAST); 687 687 } 688 688 689 - static int fbnic_mac_get_sensor_asic(struct fbnic_dev *fbd, int id, long *val) 690 - { 691 - struct fbnic_fw_completion fw_cmpl; 692 - s32 *sensor; 693 - 694 - switch (id) { 695 - case FBNIC_SENSOR_TEMP: 696 - sensor = &fw_cmpl.tsene.millidegrees; 697 - break; 698 - case FBNIC_SENSOR_VOLTAGE: 699 - sensor = &fw_cmpl.tsene.millivolts; 700 - break; 701 - default: 702 - return -EINVAL; 703 - } 704 - 705 - *val = *sensor; 706 - 707 - return 0; 708 - } 709 - 710 689 static const struct fbnic_mac fbnic_mac_asic = { 711 690 .init_regs = fbnic_mac_init_regs, 712 691 .pcs_enable = fbnic_pcs_enable_asic, ··· 695 716 .get_eth_mac_stats = fbnic_mac_get_eth_mac_stats, 696 717 .link_down = fbnic_mac_link_down_asic, 697 718 .link_up = fbnic_mac_link_up_asic, 698 - .get_sensor = fbnic_mac_get_sensor_asic, 699 719 }; 700 720 701 721 /**
-7
drivers/net/ethernet/meta/fbnic/fbnic_mac.h
··· 47 47 #define FBNIC_LINK_MODE_PAM4 (FBNIC_LINK_50R1) 48 48 #define FBNIC_LINK_MODE_MASK (FBNIC_LINK_AUTO - 1) 49 49 50 - enum fbnic_sensor_id { 51 - FBNIC_SENSOR_TEMP, /* Temp in millidegrees Centigrade */ 52 - FBNIC_SENSOR_VOLTAGE, /* Voltage in millivolts */ 53 - }; 54 - 55 50 /* This structure defines the interface hooks for the MAC. The MAC hooks 56 51 * will be configured as a const struct provided with a set of function 57 52 * pointers. ··· 83 88 84 89 void (*link_down)(struct fbnic_dev *fbd); 85 90 void (*link_up)(struct fbnic_dev *fbd, bool tx_pause, bool rx_pause); 86 - 87 - int (*get_sensor)(struct fbnic_dev *fbd, int id, long *val); 88 91 }; 89 92 90 93 int fbnic_mac_init(struct fbnic_dev *fbd);
-3
drivers/net/ethernet/meta/fbnic/fbnic_pci.c
··· 296 296 /* Capture snapshot of hardware stats so netdev can calculate delta */ 297 297 fbnic_reset_hw_stats(fbd); 298 298 299 - fbnic_hwmon_register(fbd); 300 - 301 299 if (!fbd->dsn) { 302 300 dev_warn(&pdev->dev, "Reading serial number failed\n"); 303 301 goto init_failure_mode; ··· 358 360 fbnic_netdev_free(fbd); 359 361 } 360 362 361 - fbnic_hwmon_unregister(fbd); 362 363 fbnic_dbg_fbd_exit(fbd); 363 364 fbnic_devlink_unregister(fbd); 364 365 fbnic_fw_disable_mbx(fbd);
+1 -1
drivers/net/ethernet/realtek/rtase/rtase_main.c
··· 1828 1828 1829 1829 for (i = 0; i < tp->int_nums; i++) { 1830 1830 irq = pci_irq_vector(pdev, i); 1831 - if (!irq) { 1831 + if (irq < 0) { 1832 1832 pci_disable_msix(pdev); 1833 1833 return irq; 1834 1834 }
+11 -3
drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 + #include <linux/iommu.h> 2 3 #include <linux/platform_device.h> 3 4 #include <linux/of.h> 4 5 #include <linux/module.h> ··· 19 18 20 19 struct reset_control *rst_mac; 21 20 struct reset_control *rst_pcs; 21 + 22 + u32 iommu_sid; 22 23 23 24 void __iomem *hv; 24 25 void __iomem *regs; ··· 53 50 #define MGBE_WRAP_COMMON_INTR_ENABLE 0x8704 54 51 #define MAC_SBD_INTR BIT(2) 55 52 #define MGBE_WRAP_AXI_ASID0_CTRL 0x8400 56 - #define MGBE_SID 0x6 57 53 58 54 static int __maybe_unused tegra_mgbe_suspend(struct device *dev) 59 55 { ··· 86 84 writel(MAC_SBD_INTR, mgbe->regs + MGBE_WRAP_COMMON_INTR_ENABLE); 87 85 88 86 /* Program SID */ 89 - writel(MGBE_SID, mgbe->hv + MGBE_WRAP_AXI_ASID0_CTRL); 87 + writel(mgbe->iommu_sid, mgbe->hv + MGBE_WRAP_AXI_ASID0_CTRL); 90 88 91 89 value = readl(mgbe->xpcs + XPCS_WRAP_UPHY_STATUS); 92 90 if ((value & XPCS_WRAP_UPHY_STATUS_TX_P_UP) == 0) { ··· 243 241 if (IS_ERR(mgbe->xpcs)) 244 242 return PTR_ERR(mgbe->xpcs); 245 243 244 + /* get controller's stream id from iommu property in device tree */ 245 + if (!tegra_dev_iommu_get_stream_id(mgbe->dev, &mgbe->iommu_sid)) { 246 + dev_err(mgbe->dev, "failed to get iommu stream id\n"); 247 + return -EINVAL; 248 + } 249 + 246 250 res.addr = mgbe->regs; 247 251 res.irq = irq; 248 252 ··· 354 346 writel(MAC_SBD_INTR, mgbe->regs + MGBE_WRAP_COMMON_INTR_ENABLE); 355 347 356 348 /* Program SID */ 357 - writel(MGBE_SID, mgbe->hv + MGBE_WRAP_AXI_ASID0_CTRL); 349 + writel(mgbe->iommu_sid, mgbe->hv + MGBE_WRAP_AXI_ASID0_CTRL); 358 350 359 351 plat->flags |= STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP; 360 352
+11 -13
drivers/net/ethernet/wangxun/libwx/wx_hw.c
··· 334 334 status = read_poll_timeout(rd32, hicr, hicr & WX_MNG_MBOX_CTL_FWRDY, 1000, 335 335 timeout * 1000, false, wx, WX_MNG_MBOX_CTL); 336 336 337 + buf[0] = rd32(wx, WX_MNG_MBOX); 338 + if ((buf[0] & 0xff0000) >> 16 == 0x80) { 339 + wx_err(wx, "Unknown FW command: 0x%x\n", buffer[0] & 0xff); 340 + status = -EINVAL; 341 + goto rel_out; 342 + } 343 + 337 344 /* Check command completion */ 338 345 if (status) { 339 - wx_dbg(wx, "Command has failed with no status valid.\n"); 340 - 341 - buf[0] = rd32(wx, WX_MNG_MBOX); 342 - if ((buffer[0] & 0xff) != (~buf[0] >> 24)) { 343 - status = -EINVAL; 344 - goto rel_out; 345 - } 346 - if ((buf[0] & 0xff0000) >> 16 == 0x80) { 347 - wx_dbg(wx, "It's unknown cmd.\n"); 348 - status = -EINVAL; 349 - goto rel_out; 350 - } 351 - 346 + wx_err(wx, "Command has failed with no status valid.\n"); 352 347 wx_dbg(wx, "write value:\n"); 353 348 for (i = 0; i < dword_len; i++) 354 349 wx_dbg(wx, "%x ", buffer[i]); 355 350 wx_dbg(wx, "read value:\n"); 356 351 for (i = 0; i < dword_len; i++) 357 352 wx_dbg(wx, "%x ", buf[i]); 353 + wx_dbg(wx, "\ncheck: %x %x\n", buffer[0] & 0xff, ~buf[0] >> 24); 354 + 355 + goto rel_out; 358 356 } 359 357 360 358 if (!return_data)
+5 -1
drivers/net/ieee802154/ca8210.c
··· 3072 3072 spi_set_drvdata(priv->spi, priv); 3073 3073 if (IS_ENABLED(CONFIG_IEEE802154_CA8210_DEBUGFS)) { 3074 3074 cascoda_api_upstream = ca8210_test_int_driver_write; 3075 - ca8210_test_interface_init(priv); 3075 + ret = ca8210_test_interface_init(priv); 3076 + if (ret) { 3077 + dev_crit(&spi_device->dev, "ca8210_test_interface_init failed\n"); 3078 + goto error; 3079 + } 3076 3080 } else { 3077 3081 cascoda_api_upstream = NULL; 3078 3082 }
+4
drivers/net/mctp/mctp-i3c.c
··· 125 125 126 126 xfer.data.in = skb_put(skb, mi->mrl); 127 127 128 + /* Make sure netif_rx() is read in the same order as i3c. */ 129 + mutex_lock(&mi->lock); 128 130 rc = i3c_device_do_priv_xfers(mi->i3c, &xfer, 1); 129 131 if (rc < 0) 130 132 goto err; ··· 168 166 stats->rx_dropped++; 169 167 } 170 168 169 + mutex_unlock(&mi->lock); 171 170 return 0; 172 171 err: 172 + mutex_unlock(&mi->lock); 173 173 kfree_skb(skb); 174 174 return rc; 175 175 }
+5
drivers/nvme/host/nvme.h
··· 173 173 * MSI (but not MSI-X) interrupts are broken and never fire. 174 174 */ 175 175 NVME_QUIRK_BROKEN_MSI = (1 << 21), 176 + 177 + /* 178 + * Align dma pool segment size to 512 bytes 179 + */ 180 + NVME_QUIRK_DMAPOOL_ALIGN_512 = (1 << 22), 176 181 }; 177 182 178 183 /*
+7 -2
drivers/nvme/host/pci.c
··· 2834 2834 2835 2835 static int nvme_setup_prp_pools(struct nvme_dev *dev) 2836 2836 { 2837 + size_t small_align = 256; 2838 + 2837 2839 dev->prp_page_pool = dma_pool_create("prp list page", dev->dev, 2838 2840 NVME_CTRL_PAGE_SIZE, 2839 2841 NVME_CTRL_PAGE_SIZE, 0); 2840 2842 if (!dev->prp_page_pool) 2841 2843 return -ENOMEM; 2842 2844 2845 + if (dev->ctrl.quirks & NVME_QUIRK_DMAPOOL_ALIGN_512) 2846 + small_align = 512; 2847 + 2843 2848 /* Optimisation for I/Os between 4k and 128k */ 2844 2849 dev->prp_small_pool = dma_pool_create("prp list 256", dev->dev, 2845 - 256, 256, 0); 2850 + 256, small_align, 0); 2846 2851 if (!dev->prp_small_pool) { 2847 2852 dma_pool_destroy(dev->prp_page_pool); 2848 2853 return -ENOMEM; ··· 3612 3607 { PCI_VDEVICE(REDHAT, 0x0010), /* Qemu emulated controller */ 3613 3608 .driver_data = NVME_QUIRK_BOGUS_NID, }, 3614 3609 { PCI_DEVICE(0x1217, 0x8760), /* O2 Micro 64GB Steam Deck */ 3615 - .driver_data = NVME_QUIRK_QDEPTH_ONE }, 3610 + .driver_data = NVME_QUIRK_DMAPOOL_ALIGN_512, }, 3616 3611 { PCI_DEVICE(0x126f, 0x2262), /* Silicon Motion generic */ 3617 3612 .driver_data = NVME_QUIRK_NO_DEEPEST_PS | 3618 3613 NVME_QUIRK_BOGUS_NID, },
+7 -11
drivers/nvme/host/tcp.c
··· 2024 2024 return __nvme_tcp_alloc_io_queues(ctrl); 2025 2025 } 2026 2026 2027 - static void nvme_tcp_destroy_io_queues(struct nvme_ctrl *ctrl, bool remove) 2028 - { 2029 - nvme_tcp_stop_io_queues(ctrl); 2030 - if (remove) 2031 - nvme_remove_io_tag_set(ctrl); 2032 - nvme_tcp_free_io_queues(ctrl); 2033 - } 2034 - 2035 2027 static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) 2036 2028 { 2037 2029 int ret, nr_queues; ··· 2168 2176 nvme_sync_io_queues(ctrl); 2169 2177 nvme_tcp_stop_io_queues(ctrl); 2170 2178 nvme_cancel_tagset(ctrl); 2171 - if (remove) 2179 + if (remove) { 2172 2180 nvme_unquiesce_io_queues(ctrl); 2173 - nvme_tcp_destroy_io_queues(ctrl, remove); 2181 + nvme_remove_io_tag_set(ctrl); 2182 + } 2183 + nvme_tcp_free_io_queues(ctrl); 2174 2184 } 2175 2185 2176 2186 static void nvme_tcp_reconnect_or_remove(struct nvme_ctrl *ctrl, ··· 2261 2267 nvme_sync_io_queues(ctrl); 2262 2268 nvme_tcp_stop_io_queues(ctrl); 2263 2269 nvme_cancel_tagset(ctrl); 2264 - nvme_tcp_destroy_io_queues(ctrl, new); 2270 + if (new) 2271 + nvme_remove_io_tag_set(ctrl); 2272 + nvme_tcp_free_io_queues(ctrl); 2265 2273 } 2266 2274 destroy_admin: 2267 2275 nvme_stop_keep_alive(ctrl);
+5 -4
drivers/nvme/target/admin-cmd.c
··· 139 139 unsigned long idx; 140 140 141 141 ctrl = req->sq->ctrl; 142 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) { 142 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) { 143 143 /* we don't have the right data for file backed ns */ 144 144 if (!ns->bdev) 145 145 continue; ··· 331 331 u32 count = 0; 332 332 333 333 if (!(req->cmd->get_log_page.lsp & NVME_ANA_LOG_RGO)) { 334 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) 334 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) { 335 335 if (ns->anagrpid == grpid) 336 336 desc->nsids[count++] = cpu_to_le32(ns->nsid); 337 + } 337 338 } 338 339 339 340 desc->grpid = cpu_to_le32(grpid); ··· 773 772 goto out; 774 773 } 775 774 776 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) { 775 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) { 777 776 if (ns->nsid <= min_endgid) 778 777 continue; 779 778 ··· 816 815 goto out; 817 816 } 818 817 819 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) { 818 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) { 820 819 if (ns->nsid <= min_nsid) 821 820 continue; 822 821 if (match_css && req->ns->csi != req->cmd->identify.csi)
+9 -14
drivers/nvme/target/configfs.c
··· 810 810 NULL, 811 811 }; 812 812 813 - bool nvmet_subsys_nsid_exists(struct nvmet_subsys *subsys, u32 nsid) 814 - { 815 - struct config_item *ns_item; 816 - char name[12]; 817 - 818 - snprintf(name, sizeof(name), "%u", nsid); 819 - mutex_lock(&subsys->namespaces_group.cg_subsys->su_mutex); 820 - ns_item = config_group_find_item(&subsys->namespaces_group, name); 821 - mutex_unlock(&subsys->namespaces_group.cg_subsys->su_mutex); 822 - return ns_item != NULL; 823 - } 824 - 825 813 static void nvmet_ns_release(struct config_item *item) 826 814 { 827 815 struct nvmet_ns *ns = to_nvmet_ns(item); ··· 2242 2254 const char *page, size_t count) 2243 2255 { 2244 2256 struct list_head *entry; 2257 + char *old_nqn, *new_nqn; 2245 2258 size_t len; 2246 2259 2247 2260 len = strcspn(page, "\n"); 2248 2261 if (!len || len > NVMF_NQN_FIELD_LEN - 1) 2249 2262 return -EINVAL; 2263 + 2264 + new_nqn = kstrndup(page, len, GFP_KERNEL); 2265 + if (!new_nqn) 2266 + return -ENOMEM; 2250 2267 2251 2268 down_write(&nvmet_config_sem); 2252 2269 list_for_each(entry, &nvmet_subsystems_group.cg_children) { ··· 2261 2268 if (!strncmp(config_item_name(item), page, len)) { 2262 2269 pr_err("duplicate NQN %s\n", config_item_name(item)); 2263 2270 up_write(&nvmet_config_sem); 2271 + kfree(new_nqn); 2264 2272 return -EINVAL; 2265 2273 } 2266 2274 } 2267 - memset(nvmet_disc_subsys->subsysnqn, 0, NVMF_NQN_FIELD_LEN); 2268 - memcpy(nvmet_disc_subsys->subsysnqn, page, len); 2275 + old_nqn = nvmet_disc_subsys->subsysnqn; 2276 + nvmet_disc_subsys->subsysnqn = new_nqn; 2269 2277 up_write(&nvmet_config_sem); 2270 2278 2279 + kfree(old_nqn); 2271 2280 return len; 2272 2281 } 2273 2282
+63 -45
drivers/nvme/target/core.c
··· 127 127 unsigned long idx; 128 128 u32 nsid = 0; 129 129 130 - xa_for_each(&subsys->namespaces, idx, cur) 130 + nvmet_for_each_enabled_ns(&subsys->namespaces, idx, cur) 131 131 nsid = cur->nsid; 132 132 133 133 return nsid; ··· 441 441 struct nvmet_subsys *subsys = nvmet_req_subsys(req); 442 442 443 443 req->ns = xa_load(&subsys->namespaces, nsid); 444 - if (unlikely(!req->ns)) { 444 + if (unlikely(!req->ns || !req->ns->enabled)) { 445 445 req->error_loc = offsetof(struct nvme_common_command, nsid); 446 - if (nvmet_subsys_nsid_exists(subsys, nsid)) 447 - return NVME_SC_INTERNAL_PATH_ERROR; 448 - return NVME_SC_INVALID_NS | NVME_STATUS_DNR; 446 + if (!req->ns) /* ns doesn't exist! */ 447 + return NVME_SC_INVALID_NS | NVME_STATUS_DNR; 448 + 449 + /* ns exists but it's disabled */ 450 + req->ns = NULL; 451 + return NVME_SC_INTERNAL_PATH_ERROR; 449 452 } 450 453 451 454 percpu_ref_get(&req->ns->ref); ··· 586 583 goto out_unlock; 587 584 588 585 ret = -EMFILE; 589 - if (subsys->nr_namespaces == NVMET_MAX_NAMESPACES) 590 - goto out_unlock; 591 586 592 587 ret = nvmet_bdev_ns_enable(ns); 593 588 if (ret == -ENOTBLK) ··· 600 599 list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) 601 600 nvmet_p2pmem_ns_add_p2p(ctrl, ns); 602 601 603 - ret = percpu_ref_init(&ns->ref, nvmet_destroy_namespace, 604 - 0, GFP_KERNEL); 605 - if (ret) 606 - goto out_dev_put; 607 - 608 - if (ns->nsid > subsys->max_nsid) 609 - subsys->max_nsid = ns->nsid; 610 - 611 - ret = xa_insert(&subsys->namespaces, ns->nsid, ns, GFP_KERNEL); 612 - if (ret) 613 - goto out_restore_subsys_maxnsid; 614 - 615 602 if (ns->pr.enable) { 616 603 ret = nvmet_pr_init_ns(ns); 617 604 if (ret) 618 - goto out_remove_from_subsys; 605 + goto out_dev_put; 619 606 } 620 - 621 - subsys->nr_namespaces++; 622 607 623 608 nvmet_ns_changed(subsys, ns->nsid); 624 609 ns->enabled = true; 610 + xa_set_mark(&subsys->namespaces, ns->nsid, NVMET_NS_ENABLED); 625 611 ret = 0; 626 612 out_unlock: 627 613 mutex_unlock(&subsys->lock); 628 614 return ret; 629 - 630 - out_remove_from_subsys: 631 - xa_erase(&subsys->namespaces, ns->nsid); 632 - out_restore_subsys_maxnsid: 633 - subsys->max_nsid = nvmet_max_nsid(subsys); 634 - percpu_ref_exit(&ns->ref); 635 615 out_dev_put: 636 616 list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) 637 617 pci_dev_put(radix_tree_delete(&ctrl->p2p_ns_map, ns->nsid)); ··· 631 649 goto out_unlock; 632 650 633 651 ns->enabled = false; 634 - xa_erase(&ns->subsys->namespaces, ns->nsid); 635 - if (ns->nsid == subsys->max_nsid) 636 - subsys->max_nsid = nvmet_max_nsid(subsys); 652 + xa_clear_mark(&subsys->namespaces, ns->nsid, NVMET_NS_ENABLED); 637 653 638 654 list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) 639 655 pci_dev_put(radix_tree_delete(&ctrl->p2p_ns_map, ns->nsid)); 656 + 657 + mutex_unlock(&subsys->lock); 658 + 659 + if (ns->pr.enable) 660 + nvmet_pr_exit_ns(ns); 661 + 662 + mutex_lock(&subsys->lock); 663 + nvmet_ns_changed(subsys, ns->nsid); 664 + nvmet_ns_dev_disable(ns); 665 + out_unlock: 666 + mutex_unlock(&subsys->lock); 667 + } 668 + 669 + void nvmet_ns_free(struct nvmet_ns *ns) 670 + { 671 + struct nvmet_subsys *subsys = ns->subsys; 672 + 673 + nvmet_ns_disable(ns); 674 + 675 + mutex_lock(&subsys->lock); 676 + 677 + xa_erase(&subsys->namespaces, ns->nsid); 678 + if (ns->nsid == subsys->max_nsid) 679 + subsys->max_nsid = nvmet_max_nsid(subsys); 640 680 641 681 mutex_unlock(&subsys->lock); 642 682 ··· 675 671 wait_for_completion(&ns->disable_done); 676 672 percpu_ref_exit(&ns->ref); 677 673 678 - if (ns->pr.enable) 679 - nvmet_pr_exit_ns(ns); 680 - 681 674 mutex_lock(&subsys->lock); 682 - 683 675 subsys->nr_namespaces--; 684 - nvmet_ns_changed(subsys, ns->nsid); 685 - nvmet_ns_dev_disable(ns); 686 - out_unlock: 687 676 mutex_unlock(&subsys->lock); 688 - } 689 - 690 - void nvmet_ns_free(struct nvmet_ns *ns) 691 - { 692 - nvmet_ns_disable(ns); 693 677 694 678 down_write(&nvmet_ana_sem); 695 679 nvmet_ana_group_enabled[ns->anagrpid]--; ··· 691 699 { 692 700 struct nvmet_ns *ns; 693 701 702 + mutex_lock(&subsys->lock); 703 + 704 + if (subsys->nr_namespaces == NVMET_MAX_NAMESPACES) 705 + goto out_unlock; 706 + 694 707 ns = kzalloc(sizeof(*ns), GFP_KERNEL); 695 708 if (!ns) 696 - return NULL; 709 + goto out_unlock; 697 710 698 711 init_completion(&ns->disable_done); 699 712 700 713 ns->nsid = nsid; 701 714 ns->subsys = subsys; 715 + 716 + if (percpu_ref_init(&ns->ref, nvmet_destroy_namespace, 0, GFP_KERNEL)) 717 + goto out_free; 718 + 719 + if (ns->nsid > subsys->max_nsid) 720 + subsys->max_nsid = nsid; 721 + 722 + if (xa_insert(&subsys->namespaces, ns->nsid, ns, GFP_KERNEL)) 723 + goto out_exit; 724 + 725 + subsys->nr_namespaces++; 726 + 727 + mutex_unlock(&subsys->lock); 702 728 703 729 down_write(&nvmet_ana_sem); 704 730 ns->anagrpid = NVMET_DEFAULT_ANA_GRPID; ··· 728 718 ns->csi = NVME_CSI_NVM; 729 719 730 720 return ns; 721 + out_exit: 722 + subsys->max_nsid = nvmet_max_nsid(subsys); 723 + percpu_ref_exit(&ns->ref); 724 + out_free: 725 + kfree(ns); 726 + out_unlock: 727 + mutex_unlock(&subsys->lock); 728 + return NULL; 731 729 } 732 730 733 731 static void nvmet_update_sq_head(struct nvmet_req *req) ··· 1412 1394 1413 1395 ctrl->p2p_client = get_device(req->p2p_client); 1414 1396 1415 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) 1397 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) 1416 1398 nvmet_p2pmem_ns_add_p2p(ctrl, ns); 1417 1399 } 1418 1400
+1 -1
drivers/nvme/target/io-cmd-bdev.c
··· 36 36 */ 37 37 id->nsfeat |= 1 << 4; 38 38 /* NPWG = Namespace Preferred Write Granularity. 0's based */ 39 - id->npwg = lpp0b; 39 + id->npwg = to0based(bdev_io_min(bdev) / bdev_logical_block_size(bdev)); 40 40 /* NPWA = Namespace Preferred Write Alignment. 0's based */ 41 41 id->npwa = id->npwg; 42 42 /* NPDG = Namespace Preferred Deallocate Granularity. 0's based */
+7
drivers/nvme/target/nvmet.h
··· 24 24 25 25 #define NVMET_DEFAULT_VS NVME_VS(2, 1, 0) 26 26 27 + #define NVMET_NS_ENABLED XA_MARK_1 27 28 #define NVMET_ASYNC_EVENTS 4 28 29 #define NVMET_ERROR_LOG_SLOTS 128 29 30 #define NVMET_NO_ERROR_LOC ((u16)-1) ··· 33 32 #define NVMET_SN_MAX_SIZE 20 34 33 #define NVMET_FR_MAX_SIZE 8 35 34 #define NVMET_PR_LOG_QUEUE_SIZE 64 35 + 36 + #define nvmet_for_each_ns(xa, index, entry) \ 37 + xa_for_each(xa, index, entry) 38 + 39 + #define nvmet_for_each_enabled_ns(xa, index, entry) \ 40 + xa_for_each_marked(xa, index, entry, NVMET_NS_ENABLED) 36 41 37 42 /* 38 43 * Supported optional AENs:
+4 -4
drivers/nvme/target/pr.c
··· 60 60 goto success; 61 61 } 62 62 63 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) { 63 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) { 64 64 if (ns->pr.enable) 65 65 WRITE_ONCE(ns->pr.notify_mask, mask); 66 66 } ··· 1056 1056 * nvmet_pr_init_ns(), see more details in nvmet_ns_enable(). 1057 1057 * So just check ns->pr.enable. 1058 1058 */ 1059 - xa_for_each(&subsys->namespaces, idx, ns) { 1059 + nvmet_for_each_enabled_ns(&subsys->namespaces, idx, ns) { 1060 1060 if (ns->pr.enable) { 1061 1061 ret = nvmet_pr_alloc_and_insert_pc_ref(ns, ctrl->cntlid, 1062 1062 &ctrl->hostid); ··· 1067 1067 return 0; 1068 1068 1069 1069 free_per_ctrl_refs: 1070 - xa_for_each(&subsys->namespaces, idx, ns) { 1070 + nvmet_for_each_enabled_ns(&subsys->namespaces, idx, ns) { 1071 1071 if (ns->pr.enable) { 1072 1072 pc_ref = xa_erase(&ns->pr_per_ctrl_refs, ctrl->cntlid); 1073 1073 if (pc_ref) ··· 1087 1087 kfifo_free(&ctrl->pr_log_mgr.log_queue); 1088 1088 mutex_destroy(&ctrl->pr_log_mgr.lock); 1089 1089 1090 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) { 1090 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) { 1091 1091 if (ns->pr.enable) { 1092 1092 pc_ref = xa_erase(&ns->pr_per_ctrl_refs, ctrl->cntlid); 1093 1093 if (pc_ref)
-6
drivers/ufs/core/ufshcd-priv.h
··· 237 237 hba->vops->config_scaling_param(hba, p, data); 238 238 } 239 239 240 - static inline void ufshcd_vops_reinit_notify(struct ufs_hba *hba) 241 - { 242 - if (hba->vops && hba->vops->reinit_notify) 243 - hba->vops->reinit_notify(hba); 244 - } 245 - 246 240 static inline int ufshcd_vops_mcq_config_resource(struct ufs_hba *hba) 247 241 { 248 242 if (hba->vops && hba->vops->mcq_config_resource)
+6 -4
drivers/ufs/core/ufshcd.c
··· 8858 8858 ufshcd_device_reset(hba); 8859 8859 ufs_put_device_desc(hba); 8860 8860 ufshcd_hba_stop(hba); 8861 - ufshcd_vops_reinit_notify(hba); 8862 8861 ret = ufshcd_hba_enable(hba); 8863 8862 if (ret) { 8864 8863 dev_err(hba->dev, "Host controller enable failed\n"); ··· 10590 10591 } 10591 10592 10592 10593 /* 10593 - * Set the default power management level for runtime and system PM. 10594 + * Set the default power management level for runtime and system PM if 10595 + * not set by the host controller drivers. 10594 10596 * Default power saving mode is to keep UFS link in Hibern8 state 10595 10597 * and UFS device in sleep state. 10596 10598 */ 10597 - hba->rpm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state( 10599 + if (!hba->rpm_lvl) 10600 + hba->rpm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state( 10598 10601 UFS_SLEEP_PWR_MODE, 10599 10602 UIC_LINK_HIBERN8_STATE); 10600 - hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state( 10603 + if (!hba->spm_lvl) 10604 + hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state( 10601 10605 UFS_SLEEP_PWR_MODE, 10602 10606 UIC_LINK_HIBERN8_STATE); 10603 10607
+19 -12
drivers/ufs/host/ufs-qcom.c
··· 368 368 if (ret) 369 369 return ret; 370 370 371 + if (phy->power_count) { 372 + phy_power_off(phy); 373 + phy_exit(phy); 374 + } 375 + 371 376 /* phy initialization - calibrate the phy */ 372 377 ret = phy_init(phy); 373 378 if (ret) { ··· 871 866 */ 872 867 static void ufs_qcom_advertise_quirks(struct ufs_hba *hba) 873 868 { 869 + const struct ufs_qcom_drvdata *drvdata = of_device_get_match_data(hba->dev); 874 870 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 875 871 876 872 if (host->hw_ver.major == 0x2) ··· 880 874 if (host->hw_ver.major > 0x3) 881 875 hba->quirks |= UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH; 882 876 883 - if (of_device_is_compatible(hba->dev->of_node, "qcom,sm8550-ufshc") || 884 - of_device_is_compatible(hba->dev->of_node, "qcom,sm8650-ufshc")) 885 - hba->quirks |= UFSHCD_QUIRK_BROKEN_LSDBS_CAP; 877 + if (drvdata && drvdata->quirks) 878 + hba->quirks |= drvdata->quirks; 886 879 } 887 880 888 881 static void ufs_qcom_set_phy_gear(struct ufs_qcom_host *host) ··· 1069 1064 struct device *dev = hba->dev; 1070 1065 struct ufs_qcom_host *host; 1071 1066 struct ufs_clk_info *clki; 1067 + const struct ufs_qcom_drvdata *drvdata = of_device_get_match_data(hba->dev); 1072 1068 1073 1069 host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); 1074 1070 if (!host) ··· 1148 1142 /* Failure is non-fatal */ 1149 1143 dev_warn(dev, "%s: failed to configure the testbus %d\n", 1150 1144 __func__, err); 1145 + 1146 + if (drvdata && drvdata->no_phy_retention) 1147 + hba->spm_lvl = UFS_PM_LVL_5; 1151 1148 1152 1149 return 0; 1153 1150 ··· 1588 1579 } 1589 1580 #endif 1590 1581 1591 - static void ufs_qcom_reinit_notify(struct ufs_hba *hba) 1592 - { 1593 - struct ufs_qcom_host *host = ufshcd_get_variant(hba); 1594 - 1595 - phy_power_off(host->generic_phy); 1596 - } 1597 - 1598 1582 /* Resources */ 1599 1583 static const struct ufshcd_res_info ufs_res_info[RES_MAX] = { 1600 1584 {.name = "ufs_mem",}, ··· 1827 1825 .device_reset = ufs_qcom_device_reset, 1828 1826 .config_scaling_param = ufs_qcom_config_scaling_param, 1829 1827 .program_key = ufs_qcom_ice_program_key, 1830 - .reinit_notify = ufs_qcom_reinit_notify, 1831 1828 .mcq_config_resource = ufs_qcom_mcq_config_resource, 1832 1829 .get_hba_mac = ufs_qcom_get_hba_mac, 1833 1830 .op_runtime_config = ufs_qcom_op_runtime_config, ··· 1869 1868 platform_device_msi_free_irqs_all(hba->dev); 1870 1869 } 1871 1870 1871 + static const struct ufs_qcom_drvdata ufs_qcom_sm8550_drvdata = { 1872 + .quirks = UFSHCD_QUIRK_BROKEN_LSDBS_CAP, 1873 + .no_phy_retention = true, 1874 + }; 1875 + 1872 1876 static const struct of_device_id ufs_qcom_of_match[] __maybe_unused = { 1873 1877 { .compatible = "qcom,ufshc" }, 1874 - { .compatible = "qcom,sm8550-ufshc" }, 1878 + { .compatible = "qcom,sm8550-ufshc", .data = &ufs_qcom_sm8550_drvdata }, 1879 + { .compatible = "qcom,sm8650-ufshc", .data = &ufs_qcom_sm8550_drvdata }, 1875 1880 {}, 1876 1881 }; 1877 1882 MODULE_DEVICE_TABLE(of, ufs_qcom_of_match);
+5
drivers/ufs/host/ufs-qcom.h
··· 217 217 bool esi_enabled; 218 218 }; 219 219 220 + struct ufs_qcom_drvdata { 221 + enum ufshcd_quirks quirks; 222 + bool no_phy_retention; 223 + }; 224 + 220 225 static inline u32 221 226 ufs_qcom_get_debug_reg_offset(struct ufs_qcom_host *host, u32 reg) 222 227 {
+9 -8
drivers/vfio/pci/vfio_pci_core.c
··· 1661 1661 unsigned long pfn, pgoff = vmf->pgoff - vma->vm_pgoff; 1662 1662 vm_fault_t ret = VM_FAULT_SIGBUS; 1663 1663 1664 - if (order && (vmf->address & ((PAGE_SIZE << order) - 1) || 1664 + pfn = vma_to_pfn(vma) + pgoff; 1665 + 1666 + if (order && (pfn & ((1 << order) - 1) || 1667 + vmf->address & ((PAGE_SIZE << order) - 1) || 1665 1668 vmf->address + (PAGE_SIZE << order) > vma->vm_end)) { 1666 1669 ret = VM_FAULT_FALLBACK; 1667 1670 goto out; 1668 1671 } 1669 - 1670 - pfn = vma_to_pfn(vma); 1671 1672 1672 1673 down_read(&vdev->memory_lock); 1673 1674 ··· 1677 1676 1678 1677 switch (order) { 1679 1678 case 0: 1680 - ret = vmf_insert_pfn(vma, vmf->address, pfn + pgoff); 1679 + ret = vmf_insert_pfn(vma, vmf->address, pfn); 1681 1680 break; 1682 1681 #ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP 1683 1682 case PMD_ORDER: 1684 - ret = vmf_insert_pfn_pmd(vmf, __pfn_to_pfn_t(pfn + pgoff, 1685 - PFN_DEV), false); 1683 + ret = vmf_insert_pfn_pmd(vmf, 1684 + __pfn_to_pfn_t(pfn, PFN_DEV), false); 1686 1685 break; 1687 1686 #endif 1688 1687 #ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP 1689 1688 case PUD_ORDER: 1690 - ret = vmf_insert_pfn_pud(vmf, __pfn_to_pfn_t(pfn + pgoff, 1691 - PFN_DEV), false); 1689 + ret = vmf_insert_pfn_pud(vmf, 1690 + __pfn_to_pfn_t(pfn, PFN_DEV), false); 1692 1691 break; 1693 1692 #endif 1694 1693 default:
+1 -1
drivers/watchdog/stm32_iwdg.c
··· 286 286 if (!wdt->data->has_early_wakeup) 287 287 return 0; 288 288 289 - irq = platform_get_irq(pdev, 0); 289 + irq = platform_get_irq_optional(pdev, 0); 290 290 if (irq <= 0) 291 291 return 0; 292 292
+5 -1
fs/9p/vfs_addr.c
··· 57 57 int err, len; 58 58 59 59 len = p9_client_write(fid, subreq->start, &subreq->io_iter, &err); 60 + if (len > 0) 61 + __set_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); 60 62 netfs_write_subrequest_terminated(subreq, len ?: err, false); 61 63 } 62 64 ··· 82 80 if (pos + total >= i_size_read(rreq->inode)) 83 81 __set_bit(NETFS_SREQ_HIT_EOF, &subreq->flags); 84 82 85 - if (!err) 83 + if (!err) { 86 84 subreq->transferred += total; 85 + __set_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); 86 + } 87 87 88 88 netfs_read_subreq_terminated(subreq, err, false); 89 89 }
+4 -1
fs/afs/write.c
··· 122 122 if (subreq->debug_index == 3) 123 123 return netfs_write_subrequest_terminated(subreq, -ENOANO, false); 124 124 125 - if (!test_bit(NETFS_SREQ_RETRYING, &subreq->flags)) { 125 + if (!subreq->retry_count) { 126 126 set_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); 127 127 return netfs_write_subrequest_terminated(subreq, -EAGAIN, false); 128 128 } ··· 149 149 afs_wait_for_operation(op); 150 150 ret = afs_put_operation(op); 151 151 switch (ret) { 152 + case 0: 153 + __set_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); 154 + break; 152 155 case -EACCES: 153 156 case -EPERM: 154 157 case -ENOKEY:
+68 -60
fs/btrfs/ioctl.c
··· 4878 4878 return ret; 4879 4879 } 4880 4880 4881 + struct btrfs_uring_encoded_data { 4882 + struct btrfs_ioctl_encoded_io_args args; 4883 + struct iovec iovstack[UIO_FASTIOV]; 4884 + struct iovec *iov; 4885 + struct iov_iter iter; 4886 + }; 4887 + 4881 4888 static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue_flags) 4882 4889 { 4883 4890 size_t copy_end_kernel = offsetofend(struct btrfs_ioctl_encoded_io_args, flags); 4884 4891 size_t copy_end; 4885 - struct btrfs_ioctl_encoded_io_args args = { 0 }; 4886 4892 int ret; 4887 4893 u64 disk_bytenr, disk_io_size; 4888 4894 struct file *file; 4889 4895 struct btrfs_inode *inode; 4890 4896 struct btrfs_fs_info *fs_info; 4891 4897 struct extent_io_tree *io_tree; 4892 - struct iovec iovstack[UIO_FASTIOV]; 4893 - struct iovec *iov = iovstack; 4894 - struct iov_iter iter; 4895 4898 loff_t pos; 4896 4899 struct kiocb kiocb; 4897 4900 struct extent_state *cached_state = NULL; 4898 4901 u64 start, lockend; 4899 4902 void __user *sqe_addr; 4903 + struct btrfs_uring_encoded_data *data = io_uring_cmd_get_async_data(cmd)->op_data; 4900 4904 4901 4905 if (!capable(CAP_SYS_ADMIN)) { 4902 4906 ret = -EPERM; ··· 4914 4910 4915 4911 if (issue_flags & IO_URING_F_COMPAT) { 4916 4912 #if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT) 4917 - struct btrfs_ioctl_encoded_io_args_32 args32; 4918 - 4919 4913 copy_end = offsetofend(struct btrfs_ioctl_encoded_io_args_32, flags); 4920 - if (copy_from_user(&args32, sqe_addr, copy_end)) { 4921 - ret = -EFAULT; 4922 - goto out_acct; 4923 - } 4924 - args.iov = compat_ptr(args32.iov); 4925 - args.iovcnt = args32.iovcnt; 4926 - args.offset = args32.offset; 4927 - args.flags = args32.flags; 4928 4914 #else 4929 4915 return -ENOTTY; 4930 4916 #endif 4931 4917 } else { 4932 4918 copy_end = copy_end_kernel; 4933 - if (copy_from_user(&args, sqe_addr, copy_end)) { 4934 - ret = -EFAULT; 4919 + } 4920 + 4921 + if (!data) { 4922 + data = kzalloc(sizeof(*data), GFP_NOFS); 4923 + if (!data) { 4924 + ret = -ENOMEM; 4935 4925 goto out_acct; 4926 + } 4927 + 4928 + io_uring_cmd_get_async_data(cmd)->op_data = data; 4929 + 4930 + if (issue_flags & IO_URING_F_COMPAT) { 4931 + #if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT) 4932 + struct btrfs_ioctl_encoded_io_args_32 args32; 4933 + 4934 + if (copy_from_user(&args32, sqe_addr, copy_end)) { 4935 + ret = -EFAULT; 4936 + goto out_acct; 4937 + } 4938 + 4939 + data->args.iov = compat_ptr(args32.iov); 4940 + data->args.iovcnt = args32.iovcnt; 4941 + data->args.offset = args32.offset; 4942 + data->args.flags = args32.flags; 4943 + #endif 4944 + } else { 4945 + if (copy_from_user(&data->args, sqe_addr, copy_end)) { 4946 + ret = -EFAULT; 4947 + goto out_acct; 4948 + } 4949 + } 4950 + 4951 + if (data->args.flags != 0) { 4952 + ret = -EINVAL; 4953 + goto out_acct; 4954 + } 4955 + 4956 + data->iov = data->iovstack; 4957 + ret = import_iovec(ITER_DEST, data->args.iov, data->args.iovcnt, 4958 + ARRAY_SIZE(data->iovstack), &data->iov, 4959 + &data->iter); 4960 + if (ret < 0) 4961 + goto out_acct; 4962 + 4963 + if (iov_iter_count(&data->iter) == 0) { 4964 + ret = 0; 4965 + goto out_free; 4936 4966 } 4937 4967 } 4938 4968 4939 - if (args.flags != 0) 4940 - return -EINVAL; 4941 - 4942 - ret = import_iovec(ITER_DEST, args.iov, args.iovcnt, ARRAY_SIZE(iovstack), 4943 - &iov, &iter); 4944 - if (ret < 0) 4945 - goto out_acct; 4946 - 4947 - if (iov_iter_count(&iter) == 0) { 4948 - ret = 0; 4949 - goto out_free; 4950 - } 4951 - 4952 - pos = args.offset; 4953 - ret = rw_verify_area(READ, file, &pos, args.len); 4969 + pos = data->args.offset; 4970 + ret = rw_verify_area(READ, file, &pos, data->args.len); 4954 4971 if (ret < 0) 4955 4972 goto out_free; 4956 4973 ··· 4984 4959 start = ALIGN_DOWN(pos, fs_info->sectorsize); 4985 4960 lockend = start + BTRFS_MAX_UNCOMPRESSED - 1; 4986 4961 4987 - ret = btrfs_encoded_read(&kiocb, &iter, &args, &cached_state, 4962 + ret = btrfs_encoded_read(&kiocb, &data->iter, &data->args, &cached_state, 4988 4963 &disk_bytenr, &disk_io_size); 4989 4964 if (ret < 0 && ret != -EIOCBQUEUED) 4990 4965 goto out_free; 4991 4966 4992 4967 file_accessed(file); 4993 4968 4994 - if (copy_to_user(sqe_addr + copy_end, (const char *)&args + copy_end_kernel, 4995 - sizeof(args) - copy_end_kernel)) { 4969 + if (copy_to_user(sqe_addr + copy_end, 4970 + (const char *)&data->args + copy_end_kernel, 4971 + sizeof(data->args) - copy_end_kernel)) { 4996 4972 if (ret == -EIOCBQUEUED) { 4997 4973 unlock_extent(io_tree, start, lockend, &cached_state); 4998 4974 btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED); ··· 5003 4977 } 5004 4978 5005 4979 if (ret == -EIOCBQUEUED) { 5006 - u64 count; 5007 - 5008 - /* 5009 - * If we've optimized things by storing the iovecs on the stack, 5010 - * undo this. 5011 - */ 5012 - if (!iov) { 5013 - iov = kmalloc(sizeof(struct iovec) * args.iovcnt, GFP_NOFS); 5014 - if (!iov) { 5015 - unlock_extent(io_tree, start, lockend, &cached_state); 5016 - btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED); 5017 - ret = -ENOMEM; 5018 - goto out_acct; 5019 - } 5020 - 5021 - memcpy(iov, iovstack, sizeof(struct iovec) * args.iovcnt); 5022 - } 5023 - 5024 - count = min_t(u64, iov_iter_count(&iter), disk_io_size); 4980 + u64 count = min_t(u64, iov_iter_count(&data->iter), disk_io_size); 5025 4981 5026 4982 /* Match ioctl by not returning past EOF if uncompressed. */ 5027 - if (!args.compression) 5028 - count = min_t(u64, count, args.len); 4983 + if (!data->args.compression) 4984 + count = min_t(u64, count, data->args.len); 5029 4985 5030 - ret = btrfs_uring_read_extent(&kiocb, &iter, start, lockend, 5031 - cached_state, disk_bytenr, 5032 - disk_io_size, count, 5033 - args.compression, iov, cmd); 4986 + ret = btrfs_uring_read_extent(&kiocb, &data->iter, start, lockend, 4987 + cached_state, disk_bytenr, disk_io_size, 4988 + count, data->args.compression, 4989 + data->iov, cmd); 5034 4990 5035 4991 goto out_acct; 5036 4992 } 5037 4993 5038 4994 out_free: 5039 - kfree(iov); 4995 + kfree(data->iov); 5040 4996 5041 4997 out_acct: 5042 4998 if (ret > 0)
+4
fs/btrfs/scrub.c
··· 1541 1541 u64 extent_gen; 1542 1542 int ret; 1543 1543 1544 + if (unlikely(!extent_root)) { 1545 + btrfs_err(fs_info, "no valid extent root for scrub"); 1546 + return -EUCLEAN; 1547 + } 1544 1548 memset(stripe->sectors, 0, sizeof(struct scrub_sector_verification) * 1545 1549 stripe->nr_sectors); 1546 1550 scrub_stripe_reset_bitmaps(stripe);
+2 -2
fs/btrfs/zlib.c
··· 174 174 copy_page(workspace->buf + i * PAGE_SIZE, 175 175 data_in); 176 176 start += PAGE_SIZE; 177 - workspace->strm.avail_in = 178 - (in_buf_folios << PAGE_SHIFT); 179 177 } 180 178 workspace->strm.next_in = workspace->buf; 179 + workspace->strm.avail_in = min(bytes_left, 180 + in_buf_folios << PAGE_SHIFT); 181 181 } else { 182 182 unsigned int pg_off; 183 183 unsigned int cur_len;
+3 -2
fs/btrfs/zoned.c
··· 748 748 (u64)lim->max_segments << PAGE_SHIFT), 749 749 fs_info->sectorsize); 750 750 fs_info->fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_ZONED; 751 - if (fs_info->max_zone_append_size < fs_info->max_extent_size) 752 - fs_info->max_extent_size = fs_info->max_zone_append_size; 751 + 752 + fs_info->max_extent_size = min_not_zero(fs_info->max_extent_size, 753 + fs_info->max_zone_append_size); 753 754 754 755 /* 755 756 * Check mount options here, because we might change fs_info->zoned
+7 -7
fs/cachefiles/daemon.c
··· 15 15 #include <linux/namei.h> 16 16 #include <linux/poll.h> 17 17 #include <linux/mount.h> 18 + #include <linux/security.h> 18 19 #include <linux/statfs.h> 19 20 #include <linux/ctype.h> 20 21 #include <linux/string.h> ··· 577 576 */ 578 577 static int cachefiles_daemon_secctx(struct cachefiles_cache *cache, char *args) 579 578 { 580 - char *secctx; 579 + int err; 581 580 582 581 _enter(",%s", args); 583 582 ··· 586 585 return -EINVAL; 587 586 } 588 587 589 - if (cache->secctx) { 588 + if (cache->have_secid) { 590 589 pr_err("Second security context specified\n"); 591 590 return -EINVAL; 592 591 } 593 592 594 - secctx = kstrdup(args, GFP_KERNEL); 595 - if (!secctx) 596 - return -ENOMEM; 593 + err = security_secctx_to_secid(args, strlen(args), &cache->secid); 594 + if (err) 595 + return err; 597 596 598 - cache->secctx = secctx; 597 + cache->have_secid = true; 599 598 return 0; 600 599 } 601 600 ··· 821 820 put_cred(cache->cache_cred); 822 821 823 822 kfree(cache->rootdirname); 824 - kfree(cache->secctx); 825 823 kfree(cache->tag); 826 824 827 825 _leave("");
+2 -1
fs/cachefiles/internal.h
··· 122 122 #define CACHEFILES_STATE_CHANGED 3 /* T if state changed (poll trigger) */ 123 123 #define CACHEFILES_ONDEMAND_MODE 4 /* T if in on-demand read mode */ 124 124 char *rootdirname; /* name of cache root directory */ 125 - char *secctx; /* LSM security context */ 126 125 char *tag; /* cache binding tag */ 127 126 refcount_t unbind_pincount;/* refcount to do daemon unbind */ 128 127 struct xarray reqs; /* xarray of pending on-demand requests */ ··· 129 130 struct xarray ondemand_ids; /* xarray for ondemand_id allocation */ 130 131 u32 ondemand_id_next; 131 132 u32 msg_id_next; 133 + u32 secid; /* LSM security id */ 134 + bool have_secid; /* whether "secid" was set */ 132 135 }; 133 136 134 137 static inline bool cachefiles_in_ondemand_mode(struct cachefiles_cache *cache)
+3 -3
fs/cachefiles/security.c
··· 18 18 struct cred *new; 19 19 int ret; 20 20 21 - _enter("{%s}", cache->secctx); 21 + _enter("{%u}", cache->have_secid ? cache->secid : 0); 22 22 23 23 new = prepare_kernel_cred(current); 24 24 if (!new) { ··· 26 26 goto error; 27 27 } 28 28 29 - if (cache->secctx) { 30 - ret = set_security_override_from_ctx(new, cache->secctx); 29 + if (cache->have_secid) { 30 + ret = set_security_override(new, cache->secid); 31 31 if (ret < 0) { 32 32 put_cred(new); 33 33 pr_err("Security denies permission to nominate security context: error %d\n",
+2 -1
fs/exfat/dir.c
··· 122 122 type = exfat_get_entry_type(ep); 123 123 if (type == TYPE_UNUSED) { 124 124 brelse(bh); 125 - break; 125 + goto out; 126 126 } 127 127 128 128 if (type != TYPE_FILE && type != TYPE_DIR) { ··· 170 170 } 171 171 } 172 172 173 + out: 173 174 dir_entry->namebuf.lfn[0] = '\0'; 174 175 *cpos = EXFAT_DEN_TO_B(dentry); 175 176 return 0;
+10
fs/exfat/fatent.c
··· 216 216 217 217 if (err) 218 218 goto dec_used_clus; 219 + 220 + if (num_clusters >= sbi->num_clusters - EXFAT_FIRST_CLUSTER) { 221 + /* 222 + * The cluster chain includes a loop, scan the 223 + * bitmap to get the number of used clusters. 224 + */ 225 + exfat_count_used_clusters(sb, &sbi->used_clusters); 226 + 227 + return 0; 228 + } 219 229 } while (clu != EXFAT_EOF_CLUSTER); 220 230 } 221 231
+6
fs/exfat/file.c
··· 545 545 while (pos < new_valid_size) { 546 546 u32 len; 547 547 struct folio *folio; 548 + unsigned long off; 548 549 549 550 len = PAGE_SIZE - (pos & (PAGE_SIZE - 1)); 550 551 if (pos + len > new_valid_size) ··· 555 554 if (err) 556 555 goto out; 557 556 557 + off = offset_in_folio(folio, pos); 558 + folio_zero_new_buffers(folio, off, off + len); 559 + 558 560 err = ops->write_end(file, mapping, pos, len, len, folio, NULL); 559 561 if (err < 0) 560 562 goto out; ··· 566 562 balance_dirty_pages_ratelimited(mapping); 567 563 cond_resched(); 568 564 } 565 + 566 + return 0; 569 567 570 568 out: 571 569 return err;
+2 -2
fs/exfat/namei.c
··· 330 330 331 331 while ((dentry = exfat_search_empty_slot(sb, &hint_femp, p_dir, 332 332 num_entries, es)) < 0) { 333 - if (dentry == -EIO) 334 - break; 333 + if (dentry != -ENOSPC) 334 + return dentry; 335 335 336 336 if (exfat_check_max_dentries(inode)) 337 337 return -ENOSPC;
+1
fs/file.c
··· 22 22 #include <linux/close_range.h> 23 23 #include <linux/file_ref.h> 24 24 #include <net/sock.h> 25 + #include <linux/init_task.h> 25 26 26 27 #include "internal.h" 27 28
+2
fs/fuse/dir.c
··· 1681 1681 */ 1682 1682 if (ff->open_flags & (FOPEN_STREAM | FOPEN_NONSEEKABLE)) 1683 1683 nonseekable_open(inode, file); 1684 + if (!(ff->open_flags & FOPEN_KEEP_CACHE)) 1685 + invalidate_inode_pages2(inode->i_mapping); 1684 1686 } 1685 1687 1686 1688 return err;
+3 -1
fs/hfs/super.c
··· 349 349 goto bail_no_root; 350 350 res = hfs_cat_find_brec(sb, HFS_ROOT_CNID, &fd); 351 351 if (!res) { 352 - if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) { 352 + if (fd.entrylength != sizeof(rec.dir)) { 353 353 res = -EIO; 354 354 goto bail_hfs_find; 355 355 } 356 356 hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength); 357 + if (rec.type != HFS_CDR_DIR) 358 + res = -EIO; 357 359 } 358 360 if (res) 359 361 goto bail_hfs_find;
+57 -9
fs/iomap/buffered-io.c
··· 1774 1774 */ 1775 1775 static int iomap_add_to_ioend(struct iomap_writepage_ctx *wpc, 1776 1776 struct writeback_control *wbc, struct folio *folio, 1777 - struct inode *inode, loff_t pos, unsigned len) 1777 + struct inode *inode, loff_t pos, loff_t end_pos, 1778 + unsigned len) 1778 1779 { 1779 1780 struct iomap_folio_state *ifs = folio->private; 1780 1781 size_t poff = offset_in_folio(folio, pos); ··· 1794 1793 1795 1794 if (ifs) 1796 1795 atomic_add(len, &ifs->write_bytes_pending); 1796 + 1797 + /* 1798 + * Clamp io_offset and io_size to the incore EOF so that ondisk 1799 + * file size updates in the ioend completion are byte-accurate. 1800 + * This avoids recovering files with zeroed tail regions when 1801 + * writeback races with appending writes: 1802 + * 1803 + * Thread 1: Thread 2: 1804 + * ------------ ----------- 1805 + * write [A, A+B] 1806 + * update inode size to A+B 1807 + * submit I/O [A, A+BS] 1808 + * write [A+B, A+B+C] 1809 + * update inode size to A+B+C 1810 + * <I/O completes, updates disk size to min(A+B+C, A+BS)> 1811 + * <power failure> 1812 + * 1813 + * After reboot: 1814 + * 1) with A+B+C < A+BS, the file has zero padding in range 1815 + * [A+B, A+B+C] 1816 + * 1817 + * |< Block Size (BS) >| 1818 + * |DDDDDDDDDDDD0000000000000| 1819 + * ^ ^ ^ 1820 + * A A+B A+B+C 1821 + * (EOF) 1822 + * 1823 + * 2) with A+B+C > A+BS, the file has zero padding in range 1824 + * [A+B, A+BS] 1825 + * 1826 + * |< Block Size (BS) >|< Block Size (BS) >| 1827 + * |DDDDDDDDDDDD0000000000000|00000000000000000000000000| 1828 + * ^ ^ ^ ^ 1829 + * A A+B A+BS A+B+C 1830 + * (EOF) 1831 + * 1832 + * D = Valid Data 1833 + * 0 = Zero Padding 1834 + * 1835 + * Note that this defeats the ability to chain the ioends of 1836 + * appending writes. 1837 + */ 1797 1838 wpc->ioend->io_size += len; 1839 + if (wpc->ioend->io_offset + wpc->ioend->io_size > end_pos) 1840 + wpc->ioend->io_size = end_pos - wpc->ioend->io_offset; 1841 + 1798 1842 wbc_account_cgroup_owner(wbc, folio, len); 1799 1843 return 0; 1800 1844 } 1801 1845 1802 1846 static int iomap_writepage_map_blocks(struct iomap_writepage_ctx *wpc, 1803 1847 struct writeback_control *wbc, struct folio *folio, 1804 - struct inode *inode, u64 pos, unsigned dirty_len, 1805 - unsigned *count) 1848 + struct inode *inode, u64 pos, u64 end_pos, 1849 + unsigned dirty_len, unsigned *count) 1806 1850 { 1807 1851 int error; 1808 1852 ··· 1872 1826 break; 1873 1827 default: 1874 1828 error = iomap_add_to_ioend(wpc, wbc, folio, inode, pos, 1875 - map_len); 1829 + end_pos, map_len); 1876 1830 if (!error) 1877 1831 (*count)++; 1878 1832 break; ··· 1943 1897 * remaining memory is zeroed when mapped, and writes to that 1944 1898 * region are not written out to the file. 1945 1899 * 1946 - * Also adjust the writeback range to skip all blocks entirely 1947 - * beyond i_size. 1900 + * Also adjust the end_pos to the end of file and skip writeback 1901 + * for all blocks entirely beyond i_size. 1948 1902 */ 1949 1903 folio_zero_segment(folio, poff, folio_size(folio)); 1950 - *end_pos = round_up(isize, i_blocksize(inode)); 1904 + *end_pos = isize; 1951 1905 } 1952 1906 1953 1907 return true; ··· 1960 1914 struct inode *inode = folio->mapping->host; 1961 1915 u64 pos = folio_pos(folio); 1962 1916 u64 end_pos = pos + folio_size(folio); 1917 + u64 end_aligned = 0; 1963 1918 unsigned count = 0; 1964 1919 int error = 0; 1965 1920 u32 rlen; ··· 2002 1955 /* 2003 1956 * Walk through the folio to find dirty areas to write back. 2004 1957 */ 2005 - while ((rlen = iomap_find_dirty_range(folio, &pos, end_pos))) { 1958 + end_aligned = round_up(end_pos, i_blocksize(inode)); 1959 + while ((rlen = iomap_find_dirty_range(folio, &pos, end_aligned))) { 2006 1960 error = iomap_writepage_map_blocks(wpc, wbc, folio, inode, 2007 - pos, rlen, &count); 1961 + pos, end_pos, rlen, &count); 2008 1962 if (error) 2009 1963 break; 2010 1964 pos += rlen;
+2 -2
fs/jbd2/commit.c
··· 772 772 /* 773 773 * If the journal is not located on the file system device, 774 774 * then we must flush the file system device before we issue 775 - * the commit record 775 + * the commit record and update the journal tail sequence. 776 776 */ 777 - if (commit_transaction->t_need_data_flush && 777 + if ((commit_transaction->t_need_data_flush || update_tail) && 778 778 (journal->j_fs_dev != journal->j_dev) && 779 779 (journal->j_flags & JBD2_BARRIER)) 780 780 blkdev_issue_flush(journal->j_fs_dev);
+1 -1
fs/jbd2/revoke.c
··· 654 654 set_buffer_jwrite(descriptor); 655 655 BUFFER_TRACE(descriptor, "write"); 656 656 set_buffer_dirty(descriptor); 657 - write_dirty_buffer(descriptor, REQ_SYNC); 657 + write_dirty_buffer(descriptor, JBD2_JOURNAL_REQ_FLAGS); 658 658 } 659 659 #endif 660 660
+8 -2
fs/namespace.c
··· 2055 2055 2056 2056 static bool is_mnt_ns_file(struct dentry *dentry) 2057 2057 { 2058 + struct ns_common *ns; 2059 + 2058 2060 /* Is this a proxy for a mount namespace? */ 2059 - return dentry->d_op == &ns_dentry_operations && 2060 - dentry->d_fsdata == &mntns_operations; 2061 + if (dentry->d_op != &ns_dentry_operations) 2062 + return false; 2063 + 2064 + ns = d_inode(dentry)->i_private; 2065 + 2066 + return ns->ops == &mntns_operations; 2061 2067 } 2062 2068 2063 2069 struct ns_common *from_mnt_ns(struct mnt_namespace *mnt)
+16 -12
fs/netfs/buffered_read.c
··· 275 275 netfs_stat(&netfs_n_rh_download); 276 276 if (rreq->netfs_ops->prepare_read) { 277 277 ret = rreq->netfs_ops->prepare_read(subreq); 278 - if (ret < 0) { 279 - atomic_dec(&rreq->nr_outstanding); 280 - netfs_put_subrequest(subreq, false, 281 - netfs_sreq_trace_put_cancel); 282 - break; 283 - } 278 + if (ret < 0) 279 + goto prep_failed; 284 280 trace_netfs_sreq(subreq, netfs_sreq_trace_prepare); 285 281 } 286 282 287 283 slice = netfs_prepare_read_iterator(subreq); 288 - if (slice < 0) { 289 - atomic_dec(&rreq->nr_outstanding); 290 - netfs_put_subrequest(subreq, false, netfs_sreq_trace_put_cancel); 291 - ret = slice; 292 - break; 293 - } 284 + if (slice < 0) 285 + goto prep_iter_failed; 294 286 295 287 rreq->netfs_ops->issue_read(subreq); 296 288 goto done; ··· 294 302 trace_netfs_sreq(subreq, netfs_sreq_trace_submit); 295 303 netfs_stat(&netfs_n_rh_zero); 296 304 slice = netfs_prepare_read_iterator(subreq); 305 + if (slice < 0) 306 + goto prep_iter_failed; 297 307 __set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags); 298 308 netfs_read_subreq_terminated(subreq, 0, false); 299 309 goto done; ··· 304 310 if (source == NETFS_READ_FROM_CACHE) { 305 311 trace_netfs_sreq(subreq, netfs_sreq_trace_submit); 306 312 slice = netfs_prepare_read_iterator(subreq); 313 + if (slice < 0) 314 + goto prep_iter_failed; 307 315 netfs_read_cache_to_pagecache(rreq, subreq); 308 316 goto done; 309 317 } 310 318 311 319 pr_err("Unexpected read source %u\n", source); 312 320 WARN_ON_ONCE(1); 321 + break; 322 + 323 + prep_iter_failed: 324 + ret = slice; 325 + prep_failed: 326 + subreq->error = ret; 327 + atomic_dec(&rreq->nr_outstanding); 328 + netfs_put_subrequest(subreq, false, netfs_sreq_trace_put_cancel); 313 329 break; 314 330 315 331 done:
-1
fs/netfs/direct_write.c
··· 104 104 trace_netfs_rreq(wreq, netfs_rreq_trace_wait_ip); 105 105 wait_on_bit(&wreq->flags, NETFS_RREQ_IN_PROGRESS, 106 106 TASK_UNINTERRUPTIBLE); 107 - smp_rmb(); /* Read error/transferred after RIP flag */ 108 107 ret = wreq->error; 109 108 if (ret == 0) { 110 109 ret = wreq->transferred;
+19 -14
fs/netfs/read_collect.c
··· 62 62 } else { 63 63 trace_netfs_folio(folio, netfs_folio_trace_read_done); 64 64 } 65 + 66 + folioq_clear(folioq, slot); 65 67 } else { 66 68 // TODO: Use of PG_private_2 is deprecated. 67 69 if (test_bit(NETFS_SREQ_COPY_TO_CACHE, &subreq->flags)) 68 70 netfs_pgpriv2_mark_copy_to_cache(subreq, rreq, folioq, slot); 71 + else 72 + folioq_clear(folioq, slot); 69 73 } 70 74 71 75 if (!test_bit(NETFS_RREQ_DONT_UNLOCK_FOLIOS, &rreq->flags)) { ··· 81 77 folio_unlock(folio); 82 78 } 83 79 } 84 - 85 - folioq_clear(folioq, slot); 86 80 } 87 81 88 82 /* ··· 249 247 250 248 /* Deal with the trickiest case: that this subreq is in the middle of a 251 249 * folio, not touching either edge, but finishes first. In such a 252 - * case, we donate to the previous subreq, if there is one, so that the 253 - * donation is only handled when that completes - and remove this 254 - * subreq from the list. 250 + * case, we donate to the previous subreq, if there is one and if it is 251 + * contiguous, so that the donation is only handled when that completes 252 + * - and remove this subreq from the list. 255 253 * 256 254 * If the previous subreq finished first, we will have acquired their 257 255 * donation and should be able to unlock folios and/or donate nextwards. 258 256 */ 259 257 if (!subreq->consumed && 260 258 !prev_donated && 261 - !list_is_first(&subreq->rreq_link, &rreq->subrequests)) { 259 + !list_is_first(&subreq->rreq_link, &rreq->subrequests) && 260 + subreq->start == prev->start + prev->len) { 262 261 prev = list_prev_entry(subreq, rreq_link); 263 262 WRITE_ONCE(prev->next_donated, prev->next_donated + subreq->len); 264 263 subreq->start += subreq->len; ··· 381 378 task_io_account_read(rreq->transferred); 382 379 383 380 trace_netfs_rreq(rreq, netfs_rreq_trace_wake_ip); 384 - clear_bit_unlock(NETFS_RREQ_IN_PROGRESS, &rreq->flags); 385 - wake_up_bit(&rreq->flags, NETFS_RREQ_IN_PROGRESS); 381 + clear_and_wake_up_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags); 386 382 387 383 trace_netfs_rreq(rreq, netfs_rreq_trace_done); 388 384 netfs_clear_subrequests(rreq, false); ··· 440 438 rreq->origin == NETFS_READPAGE || 441 439 rreq->origin == NETFS_READ_FOR_WRITE)) { 442 440 netfs_consume_read_data(subreq, was_async); 443 - __clear_bit(NETFS_SREQ_NO_PROGRESS, &subreq->flags); 441 + __set_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); 444 442 } 445 443 } 446 444 EXPORT_SYMBOL(netfs_read_subreq_progress); ··· 499 497 rreq->origin == NETFS_READPAGE || 500 498 rreq->origin == NETFS_READ_FOR_WRITE)) { 501 499 netfs_consume_read_data(subreq, was_async); 502 - __clear_bit(NETFS_SREQ_NO_PROGRESS, &subreq->flags); 500 + __set_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); 503 501 } 504 502 rreq->transferred += subreq->transferred; 505 503 } ··· 513 511 } else { 514 512 trace_netfs_sreq(subreq, netfs_sreq_trace_short); 515 513 if (subreq->transferred > subreq->consumed) { 516 - __set_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); 517 - __clear_bit(NETFS_SREQ_NO_PROGRESS, &subreq->flags); 518 - set_bit(NETFS_RREQ_NEED_RETRY, &rreq->flags); 519 - } else if (!__test_and_set_bit(NETFS_SREQ_NO_PROGRESS, &subreq->flags)) { 514 + /* If we didn't read new data, abandon retry. */ 515 + if (subreq->retry_count && 516 + test_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags)) { 517 + __set_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); 518 + set_bit(NETFS_RREQ_NEED_RETRY, &rreq->flags); 519 + } 520 + } else if (test_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags)) { 520 521 __set_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); 521 522 set_bit(NETFS_RREQ_NEED_RETRY, &rreq->flags); 522 523 } else {
+4
fs/netfs/read_pgpriv2.c
··· 170 170 171 171 trace_netfs_write(wreq, netfs_write_trace_copy_to_cache); 172 172 netfs_stat(&netfs_n_wh_copy_to_cache); 173 + if (!wreq->io_streams[1].avail) { 174 + netfs_put_request(wreq, false, netfs_rreq_trace_put_return); 175 + goto couldnt_start; 176 + } 173 177 174 178 for (;;) { 175 179 error = netfs_pgpriv2_copy_folio(wreq, folio);
+5 -3
fs/netfs/read_retry.c
··· 49 49 * up to the first permanently failed one. 50 50 */ 51 51 if (!rreq->netfs_ops->prepare_read && 52 - !test_bit(NETFS_RREQ_COPY_TO_CACHE, &rreq->flags)) { 52 + !rreq->cache_resources.ops) { 53 53 struct netfs_io_subrequest *subreq; 54 54 55 55 list_for_each_entry(subreq, &rreq->subrequests, rreq_link) { 56 56 if (test_bit(NETFS_SREQ_FAILED, &subreq->flags)) 57 57 break; 58 58 if (__test_and_clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags)) { 59 + __clear_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); 60 + subreq->retry_count++; 59 61 netfs_reset_iter(subreq); 60 62 netfs_reissue_read(rreq, subreq); 61 63 } ··· 139 137 stream0->sreq_max_len = subreq->len; 140 138 141 139 __clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); 142 - __set_bit(NETFS_SREQ_RETRYING, &subreq->flags); 140 + __clear_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); 141 + subreq->retry_count++; 143 142 144 143 spin_lock_bh(&rreq->lock); 145 144 list_add_tail(&subreq->rreq_link, &rreq->subrequests); ··· 216 213 subreq->error = -ENOMEM; 217 214 __clear_bit(NETFS_SREQ_FAILED, &subreq->flags); 218 215 __clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); 219 - __clear_bit(NETFS_SREQ_RETRYING, &subreq->flags); 220 216 } 221 217 spin_lock_bh(&rreq->lock); 222 218 list_splice_tail_init(&queue, &rreq->subrequests);
+5 -9
fs/netfs/write_collect.c
··· 179 179 struct iov_iter source = subreq->io_iter; 180 180 181 181 iov_iter_revert(&source, subreq->len - source.count); 182 - __set_bit(NETFS_SREQ_RETRYING, &subreq->flags); 183 182 netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit); 184 183 netfs_reissue_write(stream, subreq, &source); 185 184 } ··· 233 234 /* Renegotiate max_len (wsize) */ 234 235 trace_netfs_sreq(subreq, netfs_sreq_trace_retry); 235 236 __clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); 236 - __set_bit(NETFS_SREQ_RETRYING, &subreq->flags); 237 + subreq->retry_count++; 237 238 stream->prepare_write(subreq); 238 239 239 240 part = min(len, stream->sreq_max_len); ··· 278 279 subreq->start = start; 279 280 subreq->debug_index = atomic_inc_return(&wreq->subreq_counter); 280 281 subreq->stream_nr = to->stream_nr; 281 - __set_bit(NETFS_SREQ_RETRYING, &subreq->flags); 282 + subreq->retry_count = 1; 282 283 283 284 trace_netfs_sreq_ref(wreq->debug_id, subreq->debug_index, 284 285 refcount_read(&subreq->ref), ··· 500 501 goto need_retry; 501 502 if ((notes & MADE_PROGRESS) && test_bit(NETFS_RREQ_PAUSE, &wreq->flags)) { 502 503 trace_netfs_rreq(wreq, netfs_rreq_trace_unpause); 503 - clear_bit_unlock(NETFS_RREQ_PAUSE, &wreq->flags); 504 - wake_up_bit(&wreq->flags, NETFS_RREQ_PAUSE); 504 + clear_and_wake_up_bit(NETFS_RREQ_PAUSE, &wreq->flags); 505 505 } 506 506 507 507 if (notes & NEED_REASSESS) { ··· 603 605 604 606 _debug("finished"); 605 607 trace_netfs_rreq(wreq, netfs_rreq_trace_wake_ip); 606 - clear_bit_unlock(NETFS_RREQ_IN_PROGRESS, &wreq->flags); 607 - wake_up_bit(&wreq->flags, NETFS_RREQ_IN_PROGRESS); 608 + clear_and_wake_up_bit(NETFS_RREQ_IN_PROGRESS, &wreq->flags); 608 609 609 610 if (wreq->iocb) { 610 611 size_t written = min(wreq->transferred, wreq->len); ··· 711 714 712 715 trace_netfs_sreq(subreq, netfs_sreq_trace_terminated); 713 716 714 - clear_bit_unlock(NETFS_SREQ_IN_PROGRESS, &subreq->flags); 715 - wake_up_bit(&subreq->flags, NETFS_SREQ_IN_PROGRESS); 717 + clear_and_wake_up_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags); 716 718 717 719 /* If we are at the head of the queue, wake up the collector, 718 720 * transferring a ref to it if we were the ones to do so.
+2
fs/netfs/write_issue.c
··· 244 244 iov_iter_advance(source, size); 245 245 iov_iter_truncate(&subreq->io_iter, size); 246 246 247 + subreq->retry_count++; 248 + __clear_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); 247 249 __set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags); 248 250 netfs_do_issue_write(stream, subreq); 249 251 }
+8 -1
fs/nfs/fscache.c
··· 263 263 static atomic_t nfs_netfs_debug_id; 264 264 static int nfs_netfs_init_request(struct netfs_io_request *rreq, struct file *file) 265 265 { 266 + if (!file) { 267 + if (WARN_ON_ONCE(rreq->origin != NETFS_PGPRIV2_COPY_TO_CACHE)) 268 + return -EIO; 269 + return 0; 270 + } 271 + 266 272 rreq->netfs_priv = get_nfs_open_context(nfs_file_open_context(file)); 267 273 rreq->debug_id = atomic_inc_return(&nfs_netfs_debug_id); 268 274 /* [DEPRECATED] Use PG_private_2 to mark folio being written to the cache. */ ··· 280 274 281 275 static void nfs_netfs_free_request(struct netfs_io_request *rreq) 282 276 { 283 - put_nfs_open_context(rreq->netfs_priv); 277 + if (rreq->netfs_priv) 278 + put_nfs_open_context(rreq->netfs_priv); 284 279 } 285 280 286 281 static struct nfs_netfs_io_data *nfs_netfs_alloc(struct netfs_io_subrequest *sreq)
+1 -3
fs/notify/fdinfo.c
··· 47 47 size = f->handle_bytes >> 2; 48 48 49 49 ret = exportfs_encode_fid(inode, (struct fid *)f->f_handle, &size); 50 - if ((ret == FILEID_INVALID) || (ret < 0)) { 51 - WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret); 50 + if ((ret == FILEID_INVALID) || (ret < 0)) 52 51 return; 53 - } 54 52 55 53 f->handle_type = ret; 56 54 f->handle_bytes = size * sizeof(u32);
+1 -1
fs/ocfs2/quota_global.c
··· 893 893 int status = 0; 894 894 895 895 trace_ocfs2_get_next_id(from_kqid(&init_user_ns, *qid), type); 896 - if (!sb_has_quota_loaded(sb, type)) { 896 + if (!sb_has_quota_active(sb, type)) { 897 897 status = -ESRCH; 898 898 goto out; 899 899 }
+1
fs/ocfs2/quota_local.c
··· 867 867 brelse(oinfo->dqi_libh); 868 868 brelse(oinfo->dqi_lqi_bh); 869 869 kfree(oinfo); 870 + info->dqi_priv = NULL; 870 871 return status; 871 872 } 872 873
+8 -8
fs/overlayfs/copy_up.c
··· 415 415 return err; 416 416 } 417 417 418 - struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real, 418 + struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct inode *realinode, 419 419 bool is_upper) 420 420 { 421 421 struct ovl_fh *fh; 422 422 int fh_type, dwords; 423 423 int buflen = MAX_HANDLE_SZ; 424 - uuid_t *uuid = &real->d_sb->s_uuid; 424 + uuid_t *uuid = &realinode->i_sb->s_uuid; 425 425 int err; 426 426 427 427 /* Make sure the real fid stays 32bit aligned */ ··· 438 438 * the price or reconnecting the dentry. 439 439 */ 440 440 dwords = buflen >> 2; 441 - fh_type = exportfs_encode_fh(real, (void *)fh->fb.fid, &dwords, 0); 441 + fh_type = exportfs_encode_inode_fh(realinode, (void *)fh->fb.fid, 442 + &dwords, NULL, 0); 442 443 buflen = (dwords << 2); 443 444 444 445 err = -EIO; 445 - if (WARN_ON(fh_type < 0) || 446 - WARN_ON(buflen > MAX_HANDLE_SZ) || 447 - WARN_ON(fh_type == FILEID_INVALID)) 446 + if (fh_type < 0 || fh_type == FILEID_INVALID || 447 + WARN_ON(buflen > MAX_HANDLE_SZ)) 448 448 goto out_err; 449 449 450 450 fh->fb.version = OVL_FH_VERSION; ··· 480 480 if (!ovl_can_decode_fh(origin->d_sb)) 481 481 return NULL; 482 482 483 - return ovl_encode_real_fh(ofs, origin, false); 483 + return ovl_encode_real_fh(ofs, d_inode(origin), false); 484 484 } 485 485 486 486 int ovl_set_origin_fh(struct ovl_fs *ofs, const struct ovl_fh *fh, ··· 505 505 const struct ovl_fh *fh; 506 506 int err; 507 507 508 - fh = ovl_encode_real_fh(ofs, upper, true); 508 + fh = ovl_encode_real_fh(ofs, d_inode(upper), true); 509 509 if (IS_ERR(fh)) 510 510 return PTR_ERR(fh); 511 511
+27 -22
fs/overlayfs/export.c
··· 176 176 * 177 177 * Return 0 for upper file handle, > 0 for lower file handle or < 0 on error. 178 178 */ 179 - static int ovl_check_encode_origin(struct dentry *dentry) 179 + static int ovl_check_encode_origin(struct inode *inode) 180 180 { 181 - struct ovl_fs *ofs = OVL_FS(dentry->d_sb); 181 + struct ovl_fs *ofs = OVL_FS(inode->i_sb); 182 182 bool decodable = ofs->config.nfs_export; 183 + struct dentry *dentry; 184 + int err; 183 185 184 186 /* No upper layer? */ 185 187 if (!ovl_upper_mnt(ofs)) 186 188 return 1; 187 189 188 190 /* Lower file handle for non-upper non-decodable */ 189 - if (!ovl_dentry_upper(dentry) && !decodable) 191 + if (!ovl_inode_upper(inode) && !decodable) 190 192 return 1; 191 193 192 194 /* Upper file handle for pure upper */ 193 - if (!ovl_dentry_lower(dentry)) 195 + if (!ovl_inode_lower(inode)) 194 196 return 0; 195 197 196 198 /* 197 199 * Root is never indexed, so if there's an upper layer, encode upper for 198 200 * root. 199 201 */ 200 - if (dentry == dentry->d_sb->s_root) 202 + if (inode == d_inode(inode->i_sb->s_root)) 201 203 return 0; 202 204 203 205 /* 204 206 * Upper decodable file handle for non-indexed upper. 205 207 */ 206 - if (ovl_dentry_upper(dentry) && decodable && 207 - !ovl_test_flag(OVL_INDEX, d_inode(dentry))) 208 + if (ovl_inode_upper(inode) && decodable && 209 + !ovl_test_flag(OVL_INDEX, inode)) 208 210 return 0; 209 211 210 212 /* ··· 215 213 * ovl_connect_layer() will try to make origin's layer "connected" by 216 214 * copying up a "connectable" ancestor. 217 215 */ 218 - if (d_is_dir(dentry) && decodable) 219 - return ovl_connect_layer(dentry); 216 + if (!decodable || !S_ISDIR(inode->i_mode)) 217 + return 1; 218 + 219 + dentry = d_find_any_alias(inode); 220 + if (!dentry) 221 + return -ENOENT; 222 + 223 + err = ovl_connect_layer(dentry); 224 + dput(dentry); 225 + if (err < 0) 226 + return err; 220 227 221 228 /* Lower file handle for indexed and non-upper dir/non-dir */ 222 229 return 1; 223 230 } 224 231 225 - static int ovl_dentry_to_fid(struct ovl_fs *ofs, struct dentry *dentry, 232 + static int ovl_dentry_to_fid(struct ovl_fs *ofs, struct inode *inode, 226 233 u32 *fid, int buflen) 227 234 { 228 235 struct ovl_fh *fh = NULL; ··· 242 231 * Check if we should encode a lower or upper file handle and maybe 243 232 * copy up an ancestor to make lower file handle connectable. 244 233 */ 245 - err = enc_lower = ovl_check_encode_origin(dentry); 234 + err = enc_lower = ovl_check_encode_origin(inode); 246 235 if (enc_lower < 0) 247 236 goto fail; 248 237 249 238 /* Encode an upper or lower file handle */ 250 - fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_dentry_lower(dentry) : 251 - ovl_dentry_upper(dentry), !enc_lower); 239 + fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_inode_lower(inode) : 240 + ovl_inode_upper(inode), !enc_lower); 252 241 if (IS_ERR(fh)) 253 242 return PTR_ERR(fh); 254 243 ··· 262 251 return err; 263 252 264 253 fail: 265 - pr_warn_ratelimited("failed to encode file handle (%pd2, err=%i)\n", 266 - dentry, err); 254 + pr_warn_ratelimited("failed to encode file handle (ino=%lu, err=%i)\n", 255 + inode->i_ino, err); 267 256 goto out; 268 257 } 269 258 ··· 271 260 struct inode *parent) 272 261 { 273 262 struct ovl_fs *ofs = OVL_FS(inode->i_sb); 274 - struct dentry *dentry; 275 263 int bytes, buflen = *max_len << 2; 276 264 277 265 /* TODO: encode connectable file handles */ 278 266 if (parent) 279 267 return FILEID_INVALID; 280 268 281 - dentry = d_find_any_alias(inode); 282 - if (!dentry) 283 - return FILEID_INVALID; 284 - 285 - bytes = ovl_dentry_to_fid(ofs, dentry, fid, buflen); 286 - dput(dentry); 269 + bytes = ovl_dentry_to_fid(ofs, inode, fid, buflen); 287 270 if (bytes <= 0) 288 271 return FILEID_INVALID; 289 272
+2 -2
fs/overlayfs/namei.c
··· 542 542 struct ovl_fh *fh; 543 543 int err; 544 544 545 - fh = ovl_encode_real_fh(ofs, real, is_upper); 545 + fh = ovl_encode_real_fh(ofs, d_inode(real), is_upper); 546 546 err = PTR_ERR(fh); 547 547 if (IS_ERR(fh)) { 548 548 fh = NULL; ··· 738 738 struct ovl_fh *fh; 739 739 int err; 740 740 741 - fh = ovl_encode_real_fh(ofs, origin, false); 741 + fh = ovl_encode_real_fh(ofs, d_inode(origin), false); 742 742 if (IS_ERR(fh)) 743 743 return PTR_ERR(fh); 744 744
+1 -1
fs/overlayfs/overlayfs.h
··· 865 865 int ovl_maybe_copy_up(struct dentry *dentry, int flags); 866 866 int ovl_copy_xattr(struct super_block *sb, const struct path *path, struct dentry *new); 867 867 int ovl_set_attr(struct ovl_fs *ofs, struct dentry *upper, struct kstat *stat); 868 - struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real, 868 + struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct inode *realinode, 869 869 bool is_upper); 870 870 struct ovl_fh *ovl_get_origin_fh(struct ovl_fs *ofs, struct dentry *origin); 871 871 int ovl_set_origin_fh(struct ovl_fs *ofs, const struct ovl_fh *fh,
+1 -1
fs/proc/task_mmu.c
··· 1810 1810 } 1811 1811 1812 1812 for (; addr != end; addr += PAGE_SIZE, idx++) { 1813 - unsigned long cur_flags = flags; 1813 + u64 cur_flags = flags; 1814 1814 pagemap_entry_t pme; 1815 1815 1816 1816 if (folio && (flags & PM_PRESENT) &&
+4 -7
fs/qnx6/inode.c
··· 179 179 */ 180 180 static const char *qnx6_checkroot(struct super_block *s) 181 181 { 182 - static char match_root[2][3] = {".\0\0", "..\0"}; 183 - int i, error = 0; 182 + int error = 0; 184 183 struct qnx6_dir_entry *dir_entry; 185 184 struct inode *root = d_inode(s->s_root); 186 185 struct address_space *mapping = root->i_mapping; ··· 188 189 if (IS_ERR(folio)) 189 190 return "error reading root directory"; 190 191 dir_entry = kmap_local_folio(folio, 0); 191 - for (i = 0; i < 2; i++) { 192 - /* maximum 3 bytes - due to match_root limitation */ 193 - if (strncmp(dir_entry[i].de_fname, match_root[i], 3)) 194 - error = 1; 195 - } 192 + if (memcmp(dir_entry[0].de_fname, ".", 2) || 193 + memcmp(dir_entry[1].de_fname, "..", 3)) 194 + error = 1; 196 195 folio_release_kmap(folio, dir_entry); 197 196 if (error) 198 197 return "error reading root directory.";
+9 -4
fs/smb/client/cifssmb.c
··· 1319 1319 } 1320 1320 1321 1321 if (rdata->result == -ENODATA) { 1322 - __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); 1323 1322 rdata->result = 0; 1323 + __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); 1324 1324 } else { 1325 1325 size_t trans = rdata->subreq.transferred + rdata->got_bytes; 1326 1326 if (trans < rdata->subreq.len && 1327 1327 rdata->subreq.start + trans == ictx->remote_i_size) { 1328 - __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); 1329 1328 rdata->result = 0; 1329 + __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); 1330 + } else if (rdata->got_bytes > 0) { 1331 + __set_bit(NETFS_SREQ_MADE_PROGRESS, &rdata->subreq.flags); 1330 1332 } 1331 1333 } 1332 1334 ··· 1672 1670 if (written > wdata->subreq.len) 1673 1671 written &= 0xFFFF; 1674 1672 1675 - if (written < wdata->subreq.len) 1673 + if (written < wdata->subreq.len) { 1676 1674 result = -ENOSPC; 1677 - else 1675 + } else { 1678 1676 result = written; 1677 + if (written > 0) 1678 + __set_bit(NETFS_SREQ_MADE_PROGRESS, &wdata->subreq.flags); 1679 + } 1679 1680 break; 1680 1681 case MID_REQUEST_SUBMITTED: 1681 1682 case MID_RETRY_NEEDED:
+6 -3
fs/smb/client/smb2pdu.c
··· 4615 4615 __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); 4616 4616 rdata->result = 0; 4617 4617 } 4618 + __set_bit(NETFS_SREQ_MADE_PROGRESS, &rdata->subreq.flags); 4618 4619 } 4619 4620 trace_smb3_rw_credits(rreq_debug_id, subreq_debug_index, rdata->credits.value, 4620 4621 server->credits, server->in_flight, ··· 4843 4842 4844 4843 cifs_stats_bytes_written(tcon, written); 4845 4844 4846 - if (written < wdata->subreq.len) 4845 + if (written < wdata->subreq.len) { 4847 4846 wdata->result = -ENOSPC; 4848 - else 4847 + } else if (written > 0) { 4849 4848 wdata->subreq.len = written; 4849 + __set_bit(NETFS_SREQ_MADE_PROGRESS, &wdata->subreq.flags); 4850 + } 4850 4851 break; 4851 4852 case MID_REQUEST_SUBMITTED: 4852 4853 case MID_RETRY_NEEDED: ··· 5017 5014 } 5018 5015 #endif 5019 5016 5020 - if (test_bit(NETFS_SREQ_RETRYING, &wdata->subreq.flags)) 5017 + if (wdata->subreq.retry_count > 0) 5021 5018 smb2_set_replay(server, &rqst); 5022 5019 5023 5020 cifs_dbg(FYI, "async write at %llu %u bytes iter=%zx\n",
+10
include/linux/io_uring/cmd.h
··· 18 18 u8 pdu[32]; /* available inline for free use */ 19 19 }; 20 20 21 + struct io_uring_cmd_data { 22 + struct io_uring_sqe sqes[2]; 23 + void *op_data; 24 + }; 25 + 21 26 static inline const void *io_uring_sqe_cmd(const struct io_uring_sqe *sqe) 22 27 { 23 28 return sqe->cmd; ··· 116 111 static inline struct task_struct *io_uring_cmd_get_task(struct io_uring_cmd *cmd) 117 112 { 118 113 return cmd_to_io_kiocb(cmd)->tctx->task; 114 + } 115 + 116 + static inline struct io_uring_cmd_data *io_uring_cmd_get_async_data(struct io_uring_cmd *cmd) 117 + { 118 + return cmd_to_io_kiocb(cmd)->async_data; 119 119 } 120 120 121 121 #endif /* _LINUX_IO_URING_CMD_H */
+1 -1
include/linux/iomap.h
··· 335 335 u16 io_type; 336 336 u16 io_flags; /* IOMAP_F_* */ 337 337 struct inode *io_inode; /* file being written to */ 338 - size_t io_size; /* size of the extent */ 338 + size_t io_size; /* size of data within eof */ 339 339 loff_t io_offset; /* offset in the file */ 340 340 sector_t io_sector; /* start sector of ioend */ 341 341 struct bio io_bio; /* MUST BE LAST! */
+14
include/linux/memfd.h
··· 7 7 #ifdef CONFIG_MEMFD_CREATE 8 8 extern long memfd_fcntl(struct file *file, unsigned int cmd, unsigned int arg); 9 9 struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx); 10 + unsigned int *memfd_file_seals_ptr(struct file *file); 10 11 #else 11 12 static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned int a) 12 13 { ··· 17 16 { 18 17 return ERR_PTR(-EINVAL); 19 18 } 19 + 20 + static inline unsigned int *memfd_file_seals_ptr(struct file *file) 21 + { 22 + return NULL; 23 + } 20 24 #endif 25 + 26 + /* Retrieve memfd seals associated with the file, if any. */ 27 + static inline unsigned int memfd_file_seals(struct file *file) 28 + { 29 + unsigned int *sealsp = memfd_file_seals_ptr(file); 30 + 31 + return sealsp ? *sealsp : 0; 32 + } 21 33 22 34 #endif /* __LINUX_MEMFD_H */
+40 -17
include/linux/mm.h
··· 3125 3125 if (!pmd_ptlock_init(ptdesc)) 3126 3126 return false; 3127 3127 __folio_set_pgtable(folio); 3128 + ptdesc_pmd_pts_init(ptdesc); 3128 3129 lruvec_stat_add_folio(folio, NR_PAGETABLE); 3129 3130 return true; 3130 3131 } ··· 4102 4101 static inline void mem_dump_obj(void *object) {} 4103 4102 #endif 4104 4103 4104 + static inline bool is_write_sealed(int seals) 4105 + { 4106 + return seals & (F_SEAL_WRITE | F_SEAL_FUTURE_WRITE); 4107 + } 4108 + 4109 + /** 4110 + * is_readonly_sealed - Checks whether write-sealed but mapped read-only, 4111 + * in which case writes should be disallowing moving 4112 + * forwards. 4113 + * @seals: the seals to check 4114 + * @vm_flags: the VMA flags to check 4115 + * 4116 + * Returns whether readonly sealed, in which case writess should be disallowed 4117 + * going forward. 4118 + */ 4119 + static inline bool is_readonly_sealed(int seals, vm_flags_t vm_flags) 4120 + { 4121 + /* 4122 + * Since an F_SEAL_[FUTURE_]WRITE sealed memfd can be mapped as 4123 + * MAP_SHARED and read-only, take care to not allow mprotect to 4124 + * revert protections on such mappings. Do this only for shared 4125 + * mappings. For private mappings, don't need to mask 4126 + * VM_MAYWRITE as we still want them to be COW-writable. 4127 + */ 4128 + if (is_write_sealed(seals) && 4129 + ((vm_flags & (VM_SHARED | VM_WRITE)) == VM_SHARED)) 4130 + return true; 4131 + 4132 + return false; 4133 + } 4134 + 4105 4135 /** 4106 4136 * seal_check_write - Check for F_SEAL_WRITE or F_SEAL_FUTURE_WRITE flags and 4107 4137 * handle them. ··· 4144 4112 */ 4145 4113 static inline int seal_check_write(int seals, struct vm_area_struct *vma) 4146 4114 { 4147 - if (seals & (F_SEAL_WRITE | F_SEAL_FUTURE_WRITE)) { 4148 - /* 4149 - * New PROT_WRITE and MAP_SHARED mmaps are not allowed when 4150 - * write seals are active. 4151 - */ 4152 - if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE)) 4153 - return -EPERM; 4115 + if (!is_write_sealed(seals)) 4116 + return 0; 4154 4117 4155 - /* 4156 - * Since an F_SEAL_[FUTURE_]WRITE sealed memfd can be mapped as 4157 - * MAP_SHARED and read-only, take care to not allow mprotect to 4158 - * revert protections on such mappings. Do this only for shared 4159 - * mappings. For private mappings, don't need to mask 4160 - * VM_MAYWRITE as we still want them to be COW-writable. 4161 - */ 4162 - if (vma->vm_flags & VM_SHARED) 4163 - vm_flags_clear(vma, VM_MAYWRITE); 4164 - } 4118 + /* 4119 + * New PROT_WRITE and MAP_SHARED mmaps are not allowed when 4120 + * write seals are active. 4121 + */ 4122 + if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE)) 4123 + return -EPERM; 4165 4124 4166 4125 return 0; 4167 4126 }
+30
include/linux/mm_types.h
··· 445 445 * @pt_index: Used for s390 gmap. 446 446 * @pt_mm: Used for x86 pgds. 447 447 * @pt_frag_refcount: For fragmented page table tracking. Powerpc only. 448 + * @pt_share_count: Used for HugeTLB PMD page table share count. 448 449 * @_pt_pad_2: Padding to ensure proper alignment. 449 450 * @ptl: Lock for the page table. 450 451 * @__page_type: Same as page->page_type. Unused for page tables. ··· 472 471 pgoff_t pt_index; 473 472 struct mm_struct *pt_mm; 474 473 atomic_t pt_frag_refcount; 474 + #ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING 475 + atomic_t pt_share_count; 476 + #endif 475 477 }; 476 478 477 479 union { ··· 519 515 #define page_ptdesc(p) (_Generic((p), \ 520 516 const struct page *: (const struct ptdesc *)(p), \ 521 517 struct page *: (struct ptdesc *)(p))) 518 + 519 + #ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING 520 + static inline void ptdesc_pmd_pts_init(struct ptdesc *ptdesc) 521 + { 522 + atomic_set(&ptdesc->pt_share_count, 0); 523 + } 524 + 525 + static inline void ptdesc_pmd_pts_inc(struct ptdesc *ptdesc) 526 + { 527 + atomic_inc(&ptdesc->pt_share_count); 528 + } 529 + 530 + static inline void ptdesc_pmd_pts_dec(struct ptdesc *ptdesc) 531 + { 532 + atomic_dec(&ptdesc->pt_share_count); 533 + } 534 + 535 + static inline int ptdesc_pmd_pts_count(struct ptdesc *ptdesc) 536 + { 537 + return atomic_read(&ptdesc->pt_share_count); 538 + } 539 + #else 540 + static inline void ptdesc_pmd_pts_init(struct ptdesc *ptdesc) 541 + { 542 + } 543 + #endif 522 544 523 545 /* 524 546 * Used for sizing the vmemmap region on some architectures
+3 -4
include/linux/netfs.h
··· 185 185 short error; /* 0 or error that occurred */ 186 186 unsigned short debug_index; /* Index in list (for debugging output) */ 187 187 unsigned int nr_segs; /* Number of segs in io_iter */ 188 + u8 retry_count; /* The number of retries (0 on initial pass) */ 188 189 enum netfs_io_source source; /* Where to read from/write to */ 189 190 unsigned char stream_nr; /* I/O stream this belongs to */ 190 191 unsigned char curr_folioq_slot; /* Folio currently being read */ ··· 195 194 #define NETFS_SREQ_COPY_TO_CACHE 0 /* Set if should copy the data to the cache */ 196 195 #define NETFS_SREQ_CLEAR_TAIL 1 /* Set if the rest of the read should be cleared */ 197 196 #define NETFS_SREQ_SEEK_DATA_READ 3 /* Set if ->read() should SEEK_DATA first */ 198 - #define NETFS_SREQ_NO_PROGRESS 4 /* Set if we didn't manage to read any data */ 197 + #define NETFS_SREQ_MADE_PROGRESS 4 /* Set if we transferred at least some data */ 199 198 #define NETFS_SREQ_ONDEMAND 5 /* Set if it's from on-demand read mode */ 200 199 #define NETFS_SREQ_BOUNDARY 6 /* Set if ends on hard boundary (eg. ceph object) */ 201 200 #define NETFS_SREQ_HIT_EOF 7 /* Set if short due to EOF */ 202 201 #define NETFS_SREQ_IN_PROGRESS 8 /* Unlocked when the subrequest completes */ 203 202 #define NETFS_SREQ_NEED_RETRY 9 /* Set if the filesystem requests a retry */ 204 - #define NETFS_SREQ_RETRYING 10 /* Set if we're retrying */ 205 - #define NETFS_SREQ_FAILED 11 /* Set if the subreq failed unretryably */ 203 + #define NETFS_SREQ_FAILED 10 /* Set if the subreq failed unretryably */ 206 204 }; 207 205 208 206 enum netfs_io_origin { ··· 269 269 size_t prev_donated; /* Fallback for subreq->prev_donated */ 270 270 refcount_t ref; 271 271 unsigned long flags; 272 - #define NETFS_RREQ_COPY_TO_CACHE 1 /* Need to write to the cache */ 273 272 #define NETFS_RREQ_NO_UNLOCK_FOLIO 2 /* Don't unlock no_unlock_folio on completion */ 274 273 #define NETFS_RREQ_DONT_UNLOCK_FOLIOS 3 /* Don't unlock the folios on completion */ 275 274 #define NETFS_RREQ_FAILED 4 /* The request failed */
+1 -4
include/linux/percpu-defs.h
··· 221 221 } while (0) 222 222 223 223 #define PERCPU_PTR(__p) \ 224 - ({ \ 225 - unsigned long __pcpu_ptr = (__force unsigned long)(__p); \ 226 - (typeof(*(__p)) __force __kernel *)(__pcpu_ptr); \ 227 - }) 224 + (typeof(*(__p)) __force __kernel *)((__force unsigned long)(__p)) 228 225 229 226 #ifdef CONFIG_SMP 230 227
+1 -1
include/net/inet_connection_sock.h
··· 282 282 283 283 static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk) 284 284 { 285 - return inet_csk_reqsk_queue_len(sk) >= READ_ONCE(sk->sk_max_ack_backlog); 285 + return inet_csk_reqsk_queue_len(sk) > READ_ONCE(sk->sk_max_ack_backlog); 286 286 } 287 287 288 288 bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req);
-2
include/ufs/ufshcd.h
··· 329 329 * @program_key: program or evict an inline encryption key 330 330 * @fill_crypto_prdt: initialize crypto-related fields in the PRDT 331 331 * @event_notify: called to notify important events 332 - * @reinit_notify: called to notify reinit of UFSHCD during max gear switch 333 332 * @mcq_config_resource: called to configure MCQ platform resources 334 333 * @get_hba_mac: reports maximum number of outstanding commands supported by 335 334 * the controller. Should be implemented for UFSHCI 4.0 or later ··· 380 381 void *prdt, unsigned int num_segments); 381 382 void (*event_notify)(struct ufs_hba *hba, 382 383 enum ufs_event_type evt, void *data); 383 - void (*reinit_notify)(struct ufs_hba *); 384 384 int (*mcq_config_resource)(struct ufs_hba *hba); 385 385 int (*get_hba_mac)(struct ufs_hba *hba); 386 386 int (*op_runtime_config)(struct ufs_hba *hba);
+1 -1
io_uring/io_uring.c
··· 320 320 ret |= io_alloc_cache_init(&ctx->rw_cache, IO_ALLOC_CACHE_MAX, 321 321 sizeof(struct io_async_rw)); 322 322 ret |= io_alloc_cache_init(&ctx->uring_cache, IO_ALLOC_CACHE_MAX, 323 - sizeof(struct uring_cache)); 323 + sizeof(struct io_uring_cmd_data)); 324 324 spin_lock_init(&ctx->msg_lock); 325 325 ret |= io_alloc_cache_init(&ctx->msg_cache, IO_ALLOC_CACHE_MAX, 326 326 sizeof(struct io_kiocb));
+3 -1
io_uring/kbuf.c
··· 139 139 struct io_uring_buf_ring *br = bl->buf_ring; 140 140 __u16 tail, head = bl->head; 141 141 struct io_uring_buf *buf; 142 + void __user *ret; 142 143 143 144 tail = smp_load_acquire(&br->tail); 144 145 if (unlikely(tail == head)) ··· 154 153 req->flags |= REQ_F_BUFFER_RING | REQ_F_BUFFERS_COMMIT; 155 154 req->buf_list = bl; 156 155 req->buf_index = buf->bid; 156 + ret = u64_to_user_ptr(buf->addr); 157 157 158 158 if (issue_flags & IO_URING_F_UNLOCKED || !io_file_can_poll(req)) { 159 159 /* ··· 170 168 io_kbuf_commit(req, bl, *len, 1); 171 169 req->buf_list = NULL; 172 170 } 173 - return u64_to_user_ptr(buf->addr); 171 + return ret; 174 172 } 175 173 176 174 void __user *io_buffer_select(struct io_kiocb *req, size_t *len,
+1
io_uring/net.c
··· 754 754 if (req->opcode == IORING_OP_RECV) { 755 755 kmsg->msg.msg_name = NULL; 756 756 kmsg->msg.msg_namelen = 0; 757 + kmsg->msg.msg_inq = 0; 757 758 kmsg->msg.msg_control = NULL; 758 759 kmsg->msg.msg_get_inq = 1; 759 760 kmsg->msg.msg_controllen = 0;
+2 -1
io_uring/opdef.c
··· 7 7 #include <linux/fs.h> 8 8 #include <linux/file.h> 9 9 #include <linux/io_uring.h> 10 + #include <linux/io_uring/cmd.h> 10 11 11 12 #include "io_uring.h" 12 13 #include "opdef.h" ··· 415 414 .plug = 1, 416 415 .iopoll = 1, 417 416 .iopoll_queue = 1, 418 - .async_size = 2 * sizeof(struct io_uring_sqe), 417 + .async_size = sizeof(struct io_uring_cmd_data), 419 418 .prep = io_uring_cmd_prep, 420 419 .issue = io_uring_cmd, 421 420 },
+2
io_uring/rw.c
··· 983 983 io_kbuf_recycle(req, issue_flags); 984 984 if (ret < 0) 985 985 req_set_fail(req); 986 + } else if (!(req->flags & REQ_F_APOLL_MULTISHOT)) { 987 + cflags = io_put_kbuf(req, ret, issue_flags); 986 988 } else { 987 989 /* 988 990 * Any successful return value will keep the multishot read
+31 -14
io_uring/timeout.c
··· 85 85 io_req_task_complete(req, ts); 86 86 } 87 87 88 - static bool io_kill_timeout(struct io_kiocb *req, int status) 88 + static __cold bool io_flush_killed_timeouts(struct list_head *list, int err) 89 + { 90 + if (list_empty(list)) 91 + return false; 92 + 93 + while (!list_empty(list)) { 94 + struct io_timeout *timeout; 95 + struct io_kiocb *req; 96 + 97 + timeout = list_first_entry(list, struct io_timeout, list); 98 + list_del_init(&timeout->list); 99 + req = cmd_to_io_kiocb(timeout); 100 + if (err) 101 + req_set_fail(req); 102 + io_req_queue_tw_complete(req, err); 103 + } 104 + 105 + return true; 106 + } 107 + 108 + static void io_kill_timeout(struct io_kiocb *req, struct list_head *list) 89 109 __must_hold(&req->ctx->timeout_lock) 90 110 { 91 111 struct io_timeout_data *io = req->async_data; ··· 113 93 if (hrtimer_try_to_cancel(&io->timer) != -1) { 114 94 struct io_timeout *timeout = io_kiocb_to_cmd(req, struct io_timeout); 115 95 116 - if (status) 117 - req_set_fail(req); 118 96 atomic_set(&req->ctx->cq_timeouts, 119 97 atomic_read(&req->ctx->cq_timeouts) + 1); 120 - list_del_init(&timeout->list); 121 - io_req_queue_tw_complete(req, status); 122 - return true; 98 + list_move_tail(&timeout->list, list); 123 99 } 124 - return false; 125 100 } 126 101 127 102 __cold void io_flush_timeouts(struct io_ring_ctx *ctx) 128 103 { 129 - u32 seq; 130 104 struct io_timeout *timeout, *tmp; 105 + LIST_HEAD(list); 106 + u32 seq; 131 107 132 108 raw_spin_lock_irq(&ctx->timeout_lock); 133 109 seq = ctx->cached_cq_tail - atomic_read(&ctx->cq_timeouts); ··· 147 131 if (events_got < events_needed) 148 132 break; 149 133 150 - io_kill_timeout(req, 0); 134 + io_kill_timeout(req, &list); 151 135 } 152 136 ctx->cq_last_tm_flush = seq; 153 137 raw_spin_unlock_irq(&ctx->timeout_lock); 138 + io_flush_killed_timeouts(&list, 0); 154 139 } 155 140 156 141 static void io_req_tw_fail_links(struct io_kiocb *link, struct io_tw_state *ts) ··· 678 661 bool cancel_all) 679 662 { 680 663 struct io_timeout *timeout, *tmp; 681 - int canceled = 0; 664 + LIST_HEAD(list); 682 665 683 666 /* 684 667 * completion_lock is needed for io_match_task(). Take it before ··· 689 672 list_for_each_entry_safe(timeout, tmp, &ctx->timeout_list, list) { 690 673 struct io_kiocb *req = cmd_to_io_kiocb(timeout); 691 674 692 - if (io_match_task(req, tctx, cancel_all) && 693 - io_kill_timeout(req, -ECANCELED)) 694 - canceled++; 675 + if (io_match_task(req, tctx, cancel_all)) 676 + io_kill_timeout(req, &list); 695 677 } 696 678 raw_spin_unlock_irq(&ctx->timeout_lock); 697 679 spin_unlock(&ctx->completion_lock); 698 - return canceled != 0; 680 + 681 + return io_flush_killed_timeouts(&list, -ECANCELED); 699 682 }
+16 -7
io_uring/uring_cmd.c
··· 16 16 #include "rsrc.h" 17 17 #include "uring_cmd.h" 18 18 19 - static struct uring_cache *io_uring_async_get(struct io_kiocb *req) 19 + static struct io_uring_cmd_data *io_uring_async_get(struct io_kiocb *req) 20 20 { 21 21 struct io_ring_ctx *ctx = req->ctx; 22 - struct uring_cache *cache; 22 + struct io_uring_cmd_data *cache; 23 23 24 24 cache = io_alloc_cache_get(&ctx->uring_cache); 25 25 if (cache) { 26 + cache->op_data = NULL; 26 27 req->flags |= REQ_F_ASYNC_DATA; 27 28 req->async_data = cache; 28 29 return cache; 29 30 } 30 - if (!io_alloc_async_data(req)) 31 - return req->async_data; 31 + if (!io_alloc_async_data(req)) { 32 + cache = req->async_data; 33 + cache->op_data = NULL; 34 + return cache; 35 + } 32 36 return NULL; 33 37 } 34 38 35 39 static void io_req_uring_cleanup(struct io_kiocb *req, unsigned int issue_flags) 36 40 { 37 41 struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd); 38 - struct uring_cache *cache = req->async_data; 42 + struct io_uring_cmd_data *cache = req->async_data; 43 + 44 + if (cache->op_data) { 45 + kfree(cache->op_data); 46 + cache->op_data = NULL; 47 + } 39 48 40 49 if (issue_flags & IO_URING_F_UNLOCKED) 41 50 return; ··· 192 183 const struct io_uring_sqe *sqe) 193 184 { 194 185 struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd); 195 - struct uring_cache *cache; 186 + struct io_uring_cmd_data *cache; 196 187 197 188 cache = io_uring_async_get(req); 198 189 if (unlikely(!cache)) ··· 269 260 270 261 ret = file->f_op->uring_cmd(ioucmd, issue_flags); 271 262 if (ret == -EAGAIN) { 272 - struct uring_cache *cache = req->async_data; 263 + struct io_uring_cmd_data *cache = req->async_data; 273 264 274 265 if (ioucmd->sqe != (void *) cache) 275 266 memcpy(cache, ioucmd->sqe, uring_sqe_size(req->ctx));
-4
io_uring/uring_cmd.h
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 3 - struct uring_cache { 4 - struct io_uring_sqe sqes[2]; 5 - }; 6 - 7 3 int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags); 8 4 int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); 9 5
+1
kernel/gen_kheaders.sh
··· 89 89 90 90 # Create archive and try to normalize metadata for reproducibility. 91 91 tar "${KBUILD_BUILD_TIMESTAMP:+--mtime=$KBUILD_BUILD_TIMESTAMP}" \ 92 + --exclude=".__afs*" --exclude=".nfs*" \ 92 93 --owner=0 --group=0 --sort=name --numeric-owner --mode=u=rw,go=r,a+X \ 93 94 -I $XZ -cf $tarfile -C $cpio_dir/ . > /dev/null 94 95
+1 -1
kernel/kcov.c
··· 166 166 * Unlike in_serving_softirq(), this function returns false when called during 167 167 * a hardirq or an NMI that happened in the softirq context. 168 168 */ 169 - static inline bool in_softirq_really(void) 169 + static __always_inline bool in_softirq_really(void) 170 170 { 171 171 return in_serving_softirq() && !in_hardirq() && !in_nmi(); 172 172 }
+2 -2
kernel/sched/ext.c
··· 4763 4763 * sees scx_rq_bypassing() before moving tasks to SCX. 4764 4764 */ 4765 4765 if (!scx_enabled()) { 4766 - rq_unlock_irqrestore(rq, &rf); 4766 + rq_unlock(rq, &rf); 4767 4767 continue; 4768 4768 } 4769 4769 ··· 7013 7013 return -ENOENT; 7014 7014 7015 7015 INIT_LIST_HEAD(&kit->cursor.node); 7016 - kit->cursor.flags |= SCX_DSQ_LNODE_ITER_CURSOR | flags; 7016 + kit->cursor.flags = SCX_DSQ_LNODE_ITER_CURSOR | flags; 7017 7017 kit->cursor.priv = READ_ONCE(kit->dsq->seq); 7018 7018 7019 7019 return 0;
+14 -9
kernel/workqueue.c
··· 3680 3680 * check_flush_dependency - check for flush dependency sanity 3681 3681 * @target_wq: workqueue being flushed 3682 3682 * @target_work: work item being flushed (NULL for workqueue flushes) 3683 + * @from_cancel: are we called from the work cancel path 3683 3684 * 3684 3685 * %current is trying to flush the whole @target_wq or @target_work on it. 3685 - * If @target_wq doesn't have %WQ_MEM_RECLAIM, verify that %current is not 3686 - * reclaiming memory or running on a workqueue which doesn't have 3687 - * %WQ_MEM_RECLAIM as that can break forward-progress guarantee leading to 3688 - * a deadlock. 3686 + * If this is not the cancel path (which implies work being flushed is either 3687 + * already running, or will not be at all), check if @target_wq doesn't have 3688 + * %WQ_MEM_RECLAIM and verify that %current is not reclaiming memory or running 3689 + * on a workqueue which doesn't have %WQ_MEM_RECLAIM as that can break forward- 3690 + * progress guarantee leading to a deadlock. 3689 3691 */ 3690 3692 static void check_flush_dependency(struct workqueue_struct *target_wq, 3691 - struct work_struct *target_work) 3693 + struct work_struct *target_work, 3694 + bool from_cancel) 3692 3695 { 3693 - work_func_t target_func = target_work ? target_work->func : NULL; 3696 + work_func_t target_func; 3694 3697 struct worker *worker; 3695 3698 3696 - if (target_wq->flags & WQ_MEM_RECLAIM) 3699 + if (from_cancel || target_wq->flags & WQ_MEM_RECLAIM) 3697 3700 return; 3698 3701 3699 3702 worker = current_wq_worker(); 3703 + target_func = target_work ? target_work->func : NULL; 3700 3704 3701 3705 WARN_ONCE(current->flags & PF_MEMALLOC, 3702 3706 "workqueue: PF_MEMALLOC task %d(%s) is flushing !WQ_MEM_RECLAIM %s:%ps", ··· 3984 3980 list_add_tail(&this_flusher.list, &wq->flusher_overflow); 3985 3981 } 3986 3982 3987 - check_flush_dependency(wq, NULL); 3983 + check_flush_dependency(wq, NULL, false); 3988 3984 3989 3985 mutex_unlock(&wq->mutex); 3990 3986 ··· 4159 4155 } 4160 4156 4161 4157 wq = pwq->wq; 4162 - check_flush_dependency(wq, work); 4158 + check_flush_dependency(wq, work, from_cancel); 4163 4159 4164 4160 insert_wq_barrier(pwq, barr, work, worker); 4165 4161 raw_spin_unlock_irq(&pool->lock); ··· 5645 5641 } while (activated); 5646 5642 } 5647 5643 5644 + __printf(1, 0) 5648 5645 static struct workqueue_struct *__alloc_workqueue(const char *fmt, 5649 5646 unsigned int flags, 5650 5647 int max_active, va_list args)
+1
lib/maple_tree.c
··· 4354 4354 ret = 1; 4355 4355 } 4356 4356 if (ret < 0 && range_lo > min) { 4357 + mas_reset(mas); 4357 4358 ret = mas_empty_area(mas, min, range_hi, 1); 4358 4359 if (ret == 0) 4359 4360 ret = 1;
+9 -1
mm/damon/core.c
··· 868 868 NUMA_NO_NODE); 869 869 if (!new_scheme) 870 870 return -ENOMEM; 871 + err = damos_commit(new_scheme, src_scheme); 872 + if (err) { 873 + damon_destroy_scheme(new_scheme); 874 + return err; 875 + } 871 876 damon_add_scheme(dst, new_scheme); 872 877 } 873 878 return 0; ··· 966 961 return -ENOMEM; 967 962 err = damon_commit_target(new_target, false, 968 963 src_target, damon_target_has_pid(src)); 969 - if (err) 964 + if (err) { 965 + damon_destroy_target(new_target); 970 966 return err; 967 + } 968 + damon_add_target(dst, new_target); 971 969 } 972 970 return 0; 973 971 }
-9
mm/filemap.c
··· 124 124 * ->private_lock (zap_pte_range->block_dirty_folio) 125 125 */ 126 126 127 - static void mapping_set_update(struct xa_state *xas, 128 - struct address_space *mapping) 129 - { 130 - if (dax_mapping(mapping) || shmem_mapping(mapping)) 131 - return; 132 - xas_set_update(xas, workingset_update_node); 133 - xas_set_lru(xas, &shadow_nodes); 134 - } 135 - 136 127 static void page_cache_delete(struct address_space *mapping, 137 128 struct folio *folio, void *shadow) 138 129 {
+7 -9
mm/hugetlb.c
··· 7211 7211 spte = hugetlb_walk(svma, saddr, 7212 7212 vma_mmu_pagesize(svma)); 7213 7213 if (spte) { 7214 - get_page(virt_to_page(spte)); 7214 + ptdesc_pmd_pts_inc(virt_to_ptdesc(spte)); 7215 7215 break; 7216 7216 } 7217 7217 } ··· 7226 7226 (pmd_t *)((unsigned long)spte & PAGE_MASK)); 7227 7227 mm_inc_nr_pmds(mm); 7228 7228 } else { 7229 - put_page(virt_to_page(spte)); 7229 + ptdesc_pmd_pts_dec(virt_to_ptdesc(spte)); 7230 7230 } 7231 7231 spin_unlock(&mm->page_table_lock); 7232 7232 out: ··· 7238 7238 /* 7239 7239 * unmap huge page backed by shared pte. 7240 7240 * 7241 - * Hugetlb pte page is ref counted at the time of mapping. If pte is shared 7242 - * indicated by page_count > 1, unmap is achieved by clearing pud and 7243 - * decrementing the ref count. If count == 1, the pte page is not shared. 7244 - * 7245 7241 * Called with page table lock held. 7246 7242 * 7247 7243 * returns: 1 successfully unmapped a shared pte page ··· 7246 7250 int huge_pmd_unshare(struct mm_struct *mm, struct vm_area_struct *vma, 7247 7251 unsigned long addr, pte_t *ptep) 7248 7252 { 7253 + unsigned long sz = huge_page_size(hstate_vma(vma)); 7249 7254 pgd_t *pgd = pgd_offset(mm, addr); 7250 7255 p4d_t *p4d = p4d_offset(pgd, addr); 7251 7256 pud_t *pud = pud_offset(p4d, addr); 7252 7257 7253 7258 i_mmap_assert_write_locked(vma->vm_file->f_mapping); 7254 7259 hugetlb_vma_assert_locked(vma); 7255 - BUG_ON(page_count(virt_to_page(ptep)) == 0); 7256 - if (page_count(virt_to_page(ptep)) == 1) 7260 + if (sz != PMD_SIZE) 7261 + return 0; 7262 + if (!ptdesc_pmd_pts_count(virt_to_ptdesc(ptep))) 7257 7263 return 0; 7258 7264 7259 7265 pud_clear(pud); 7260 - put_page(virt_to_page(ptep)); 7266 + ptdesc_pmd_pts_dec(virt_to_ptdesc(ptep)); 7261 7267 mm_dec_nr_pmds(mm); 7262 7268 return 1; 7263 7269 }
+6
mm/internal.h
··· 1504 1504 /* Only track the nodes of mappings with shadow entries */ 1505 1505 void workingset_update_node(struct xa_node *node); 1506 1506 extern struct list_lru shadow_nodes; 1507 + #define mapping_set_update(xas, mapping) do { \ 1508 + if (!dax_mapping(mapping) && !shmem_mapping(mapping)) { \ 1509 + xas_set_update(xas, workingset_update_node); \ 1510 + xas_set_lru(xas, &shadow_nodes); \ 1511 + } \ 1512 + } while (0) 1507 1513 1508 1514 /* mremap.c */ 1509 1515 unsigned long move_page_tables(struct vm_area_struct *vma,
+3
mm/khugepaged.c
··· 19 19 #include <linux/rcupdate_wait.h> 20 20 #include <linux/swapops.h> 21 21 #include <linux/shmem_fs.h> 22 + #include <linux/dax.h> 22 23 #include <linux/ksm.h> 23 24 24 25 #include <asm/tlb.h> ··· 1837 1836 result = alloc_charge_folio(&new_folio, mm, cc); 1838 1837 if (result != SCAN_SUCCEED) 1839 1838 goto out; 1839 + 1840 + mapping_set_update(&xas, mapping); 1840 1841 1841 1842 __folio_set_locked(new_folio); 1842 1843 if (is_shmem)
+1 -1
mm/kmemleak.c
··· 373 373 374 374 for (i = 0; i < nr_entries; i++) { 375 375 void *ptr = (void *)entries[i]; 376 - warn_or_seq_printf(seq, " [<%pK>] %pS\n", ptr, ptr); 376 + warn_or_seq_printf(seq, " %pS\n", ptr); 377 377 } 378 378 } 379 379
+1 -1
mm/list_lru.c
··· 77 77 spin_lock(&l->lock); 78 78 nr_items = READ_ONCE(l->nr_items); 79 79 if (likely(nr_items != LONG_MIN)) { 80 - WARN_ON(nr_items < 0); 81 80 rcu_read_unlock(); 82 81 return l; 83 82 } ··· 449 450 450 451 list_splice_init(&src->list, &dst->list); 451 452 if (src->nr_items) { 453 + WARN_ON(src->nr_items < 0); 452 454 dst->nr_items += src->nr_items; 453 455 set_shrinker_bit(dst_memcg, nid, lru_shrinker_id(lru)); 454 456 }
+1 -1
mm/memfd.c
··· 170 170 return error; 171 171 } 172 172 173 - static unsigned int *memfd_file_seals_ptr(struct file *file) 173 + unsigned int *memfd_file_seals_ptr(struct file *file) 174 174 { 175 175 if (shmem_file(file)) 176 176 return &SHMEM_I(file_inode(file))->seals;
+5 -1
mm/mmap.c
··· 47 47 #include <linux/oom.h> 48 48 #include <linux/sched/mm.h> 49 49 #include <linux/ksm.h> 50 + #include <linux/memfd.h> 50 51 51 52 #include <linux/uaccess.h> 52 53 #include <asm/cacheflush.h> ··· 369 368 370 369 if (file) { 371 370 struct inode *inode = file_inode(file); 371 + unsigned int seals = memfd_file_seals(file); 372 372 unsigned long flags_mask; 373 373 374 374 if (!file_mmap_ok(file, inode, pgoff, len)) ··· 410 408 vm_flags |= VM_SHARED | VM_MAYSHARE; 411 409 if (!(file->f_mode & FMODE_WRITE)) 412 410 vm_flags &= ~(VM_MAYWRITE | VM_SHARED); 411 + else if (is_readonly_sealed(seals, vm_flags)) 412 + vm_flags &= ~VM_MAYWRITE; 413 413 fallthrough; 414 414 case MAP_PRIVATE: 415 415 if (!(file->f_mode & FMODE_READ)) ··· 892 888 893 889 if (get_area) { 894 890 addr = get_area(file, addr, len, pgoff, flags); 895 - } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) 891 + } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && !file 896 892 && !addr /* no hint */ 897 893 && IS_ALIGNED(len, PMD_SIZE)) { 898 894 /* Ensures that larger anonymous mappings are THP aligned. */
+5 -1
mm/readahead.c
··· 646 646 1UL << order); 647 647 if (index == expected) { 648 648 ra->start += ra->size; 649 - ra->size = get_next_ra_size(ra, max_pages); 649 + /* 650 + * In the case of MADV_HUGEPAGE, the actual size might exceed 651 + * the readahead window. 652 + */ 653 + ra->size = max(ra->size, get_next_ra_size(ra, max_pages)); 650 654 ra->async_size = ra->size; 651 655 goto readit; 652 656 }
+4 -3
mm/shmem.c
··· 1535 1535 !shmem_falloc->waitq && 1536 1536 index >= shmem_falloc->start && 1537 1537 index < shmem_falloc->next) 1538 - shmem_falloc->nr_unswapped++; 1538 + shmem_falloc->nr_unswapped += nr_pages; 1539 1539 else 1540 1540 shmem_falloc = NULL; 1541 1541 spin_unlock(&inode->i_lock); ··· 1689 1689 unsigned long mask = READ_ONCE(huge_shmem_orders_always); 1690 1690 unsigned long within_size_orders = READ_ONCE(huge_shmem_orders_within_size); 1691 1691 unsigned long vm_flags = vma ? vma->vm_flags : 0; 1692 + pgoff_t aligned_index; 1692 1693 bool global_huge; 1693 1694 loff_t i_size; 1694 1695 int order; ··· 1724 1723 /* Allow mTHP that will be fully within i_size. */ 1725 1724 order = highest_order(within_size_orders); 1726 1725 while (within_size_orders) { 1727 - index = round_up(index + 1, order); 1726 + aligned_index = round_up(index + 1, 1 << order); 1728 1727 i_size = round_up(i_size_read(inode), PAGE_SIZE); 1729 - if (i_size >> PAGE_SHIFT >= index) { 1728 + if (i_size >> PAGE_SHIFT >= aligned_index) { 1730 1729 mask |= within_size_orders; 1731 1730 break; 1732 1731 }
+1 -6
mm/util.c
··· 297 297 { 298 298 char *p; 299 299 300 - /* 301 - * Always use GFP_KERNEL, since copy_from_user() can sleep and 302 - * cause pagefault, which makes it pointless to use GFP_NOFS 303 - * or GFP_ATOMIC. 304 - */ 305 - p = kmalloc_track_caller(len + 1, GFP_KERNEL); 300 + p = kmem_buckets_alloc_track_caller(user_buckets, len + 1, GFP_USER | __GFP_NOWARN); 306 301 if (!p) 307 302 return ERR_PTR(-ENOMEM); 308 303
+8 -1
mm/vmscan.c
··· 374 374 if (can_reclaim_anon_pages(NULL, zone_to_nid(zone), NULL)) 375 375 nr += zone_page_state_snapshot(zone, NR_ZONE_INACTIVE_ANON) + 376 376 zone_page_state_snapshot(zone, NR_ZONE_ACTIVE_ANON); 377 - 377 + /* 378 + * If there are no reclaimable file-backed or anonymous pages, 379 + * ensure zones with sufficient free pages are not skipped. 380 + * This prevents zones like DMA32 from being ignored in reclaim 381 + * scenarios where they can still help alleviate memory pressure. 382 + */ 383 + if (nr == 0) 384 + nr = zone_page_state_snapshot(zone, NR_FREE_PAGES); 378 385 return nr; 379 386 } 380 387
+16 -3
mm/zswap.c
··· 880 880 return 0; 881 881 } 882 882 883 + /* Prevent CPU hotplug from freeing up the per-CPU acomp_ctx resources */ 884 + static struct crypto_acomp_ctx *acomp_ctx_get_cpu(struct crypto_acomp_ctx __percpu *acomp_ctx) 885 + { 886 + cpus_read_lock(); 887 + return raw_cpu_ptr(acomp_ctx); 888 + } 889 + 890 + static void acomp_ctx_put_cpu(void) 891 + { 892 + cpus_read_unlock(); 893 + } 894 + 883 895 static bool zswap_compress(struct page *page, struct zswap_entry *entry, 884 896 struct zswap_pool *pool) 885 897 { ··· 905 893 gfp_t gfp; 906 894 u8 *dst; 907 895 908 - acomp_ctx = raw_cpu_ptr(pool->acomp_ctx); 909 - 896 + acomp_ctx = acomp_ctx_get_cpu(pool->acomp_ctx); 910 897 mutex_lock(&acomp_ctx->mutex); 911 898 912 899 dst = acomp_ctx->buffer; ··· 961 950 zswap_reject_alloc_fail++; 962 951 963 952 mutex_unlock(&acomp_ctx->mutex); 953 + acomp_ctx_put_cpu(); 964 954 return comp_ret == 0 && alloc_ret == 0; 965 955 } 966 956 ··· 972 960 struct crypto_acomp_ctx *acomp_ctx; 973 961 u8 *src; 974 962 975 - acomp_ctx = raw_cpu_ptr(entry->pool->acomp_ctx); 963 + acomp_ctx = acomp_ctx_get_cpu(entry->pool->acomp_ctx); 976 964 mutex_lock(&acomp_ctx->mutex); 977 965 978 966 src = zpool_map_handle(zpool, entry->handle, ZPOOL_MM_RO); ··· 1002 990 1003 991 if (src != acomp_ctx->buffer) 1004 992 zpool_unmap_handle(zpool, entry->handle); 993 + acomp_ctx_put_cpu(); 1005 994 } 1006 995 1007 996 /*********************************
+2 -2
net/802/psnap.c
··· 55 55 goto drop; 56 56 57 57 rcu_read_lock(); 58 - proto = find_snap_client(skb_transport_header(skb)); 58 + proto = find_snap_client(skb->data); 59 59 if (proto) { 60 60 /* Pass the frame on. */ 61 - skb->transport_header += 5; 62 61 skb_pull_rcsum(skb, 5); 62 + skb_reset_transport_header(skb); 63 63 rc = proto->rcvfunc(skb, dev, &snap_packet_type, orig_dev); 64 64 } 65 65 rcu_read_unlock();
+6 -5
net/bluetooth/hci_sync.c
··· 1031 1031 1032 1032 static int hci_set_random_addr_sync(struct hci_dev *hdev, bdaddr_t *rpa) 1033 1033 { 1034 - /* If we're advertising or initiating an LE connection we can't 1035 - * go ahead and change the random address at this time. This is 1036 - * because the eventual initiator address used for the 1034 + /* If a random_addr has been set we're advertising or initiating an LE 1035 + * connection we can't go ahead and change the random address at this 1036 + * time. This is because the eventual initiator address used for the 1037 1037 * subsequently created connection will be undefined (some 1038 1038 * controllers use the new address and others the one we had 1039 1039 * when the operation started). ··· 1041 1041 * In this kind of scenario skip the update and let the random 1042 1042 * address be updated at the next cycle. 1043 1043 */ 1044 - if (hci_dev_test_flag(hdev, HCI_LE_ADV) || 1045 - hci_lookup_le_connect(hdev)) { 1044 + if (bacmp(&hdev->random_addr, BDADDR_ANY) && 1045 + (hci_dev_test_flag(hdev, HCI_LE_ADV) || 1046 + hci_lookup_le_connect(hdev))) { 1046 1047 bt_dev_dbg(hdev, "Deferring random address update"); 1047 1048 hci_dev_set_flag(hdev, HCI_RPA_EXPIRED); 1048 1049 return 0;
+36 -2
net/bluetooth/mgmt.c
··· 7655 7655 mgmt_event(MGMT_EV_DEVICE_ADDED, hdev, &ev, sizeof(ev), sk); 7656 7656 } 7657 7657 7658 + static void add_device_complete(struct hci_dev *hdev, void *data, int err) 7659 + { 7660 + struct mgmt_pending_cmd *cmd = data; 7661 + struct mgmt_cp_add_device *cp = cmd->param; 7662 + 7663 + if (!err) { 7664 + device_added(cmd->sk, hdev, &cp->addr.bdaddr, cp->addr.type, 7665 + cp->action); 7666 + device_flags_changed(NULL, hdev, &cp->addr.bdaddr, 7667 + cp->addr.type, hdev->conn_flags, 7668 + PTR_UINT(cmd->user_data)); 7669 + } 7670 + 7671 + mgmt_cmd_complete(cmd->sk, hdev->id, MGMT_OP_ADD_DEVICE, 7672 + mgmt_status(err), &cp->addr, sizeof(cp->addr)); 7673 + mgmt_pending_free(cmd); 7674 + } 7675 + 7658 7676 static int add_device_sync(struct hci_dev *hdev, void *data) 7659 7677 { 7660 7678 return hci_update_passive_scan_sync(hdev); ··· 7681 7663 static int add_device(struct sock *sk, struct hci_dev *hdev, 7682 7664 void *data, u16 len) 7683 7665 { 7666 + struct mgmt_pending_cmd *cmd; 7684 7667 struct mgmt_cp_add_device *cp = data; 7685 7668 u8 auto_conn, addr_type; 7686 7669 struct hci_conn_params *params; ··· 7762 7743 current_flags = params->flags; 7763 7744 } 7764 7745 7765 - err = hci_cmd_sync_queue(hdev, add_device_sync, NULL, NULL); 7766 - if (err < 0) 7746 + cmd = mgmt_pending_new(sk, MGMT_OP_ADD_DEVICE, hdev, data, len); 7747 + if (!cmd) { 7748 + err = -ENOMEM; 7767 7749 goto unlock; 7750 + } 7751 + 7752 + cmd->user_data = UINT_PTR(current_flags); 7753 + 7754 + err = hci_cmd_sync_queue(hdev, add_device_sync, cmd, 7755 + add_device_complete); 7756 + if (err < 0) { 7757 + err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_ADD_DEVICE, 7758 + MGMT_STATUS_FAILED, &cp->addr, 7759 + sizeof(cp->addr)); 7760 + mgmt_pending_free(cmd); 7761 + } 7762 + 7763 + goto unlock; 7768 7764 7769 7765 added: 7770 7766 device_added(sk, hdev, &cp->addr.bdaddr, cp->addr.type, cp->action);
+2 -2
net/bluetooth/rfcomm/tty.c
··· 201 201 struct device_attribute *attr, char *buf) 202 202 { 203 203 struct rfcomm_dev *dev = dev_get_drvdata(tty_dev); 204 - return sprintf(buf, "%pMR\n", &dev->dst); 204 + return sysfs_emit(buf, "%pMR\n", &dev->dst); 205 205 } 206 206 207 207 static ssize_t channel_show(struct device *tty_dev, 208 208 struct device_attribute *attr, char *buf) 209 209 { 210 210 struct rfcomm_dev *dev = dev_get_drvdata(tty_dev); 211 - return sprintf(buf, "%d\n", dev->channel); 211 + return sysfs_emit(buf, "%d\n", dev->channel); 212 212 } 213 213 214 214 static DEVICE_ATTR_RO(address);
+30 -13
net/core/dev.c
··· 753 753 } 754 754 EXPORT_SYMBOL_GPL(dev_fill_forward_path); 755 755 756 + /* must be called under rcu_read_lock(), as we dont take a reference */ 757 + static struct napi_struct *napi_by_id(unsigned int napi_id) 758 + { 759 + unsigned int hash = napi_id % HASH_SIZE(napi_hash); 760 + struct napi_struct *napi; 761 + 762 + hlist_for_each_entry_rcu(napi, &napi_hash[hash], napi_hash_node) 763 + if (napi->napi_id == napi_id) 764 + return napi; 765 + 766 + return NULL; 767 + } 768 + 769 + /* must be called under rcu_read_lock(), as we dont take a reference */ 770 + struct napi_struct *netdev_napi_by_id(struct net *net, unsigned int napi_id) 771 + { 772 + struct napi_struct *napi; 773 + 774 + napi = napi_by_id(napi_id); 775 + if (!napi) 776 + return NULL; 777 + 778 + if (WARN_ON_ONCE(!napi->dev)) 779 + return NULL; 780 + if (!net_eq(net, dev_net(napi->dev))) 781 + return NULL; 782 + 783 + return napi; 784 + } 785 + 756 786 /** 757 787 * __dev_get_by_name - find a device by its name 758 788 * @net: the applicable net namespace ··· 6345 6315 return ret; 6346 6316 } 6347 6317 EXPORT_SYMBOL(napi_complete_done); 6348 - 6349 - /* must be called under rcu_read_lock(), as we dont take a reference */ 6350 - struct napi_struct *napi_by_id(unsigned int napi_id) 6351 - { 6352 - unsigned int hash = napi_id % HASH_SIZE(napi_hash); 6353 - struct napi_struct *napi; 6354 - 6355 - hlist_for_each_entry_rcu(napi, &napi_hash[hash], napi_hash_node) 6356 - if (napi->napi_id == napi_id) 6357 - return napi; 6358 - 6359 - return NULL; 6360 - } 6361 6318 6362 6319 static void skb_defer_free_flush(struct softnet_data *sd) 6363 6320 {
+2 -1
net/core/dev.h
··· 22 22 23 23 extern int netdev_flow_limit_table_len; 24 24 25 + struct napi_struct *netdev_napi_by_id(struct net *net, unsigned int napi_id); 26 + 25 27 #ifdef CONFIG_PROC_FS 26 28 int __init dev_proc_init(void); 27 29 #else ··· 271 269 static inline void xdp_do_check_flushed(struct napi_struct *napi) { } 272 270 #endif 273 271 274 - struct napi_struct *napi_by_id(unsigned int napi_id); 275 272 void kick_defer_list_purge(struct softnet_data *sd, unsigned int cpu); 276 273 277 274 #define XMIT_RECURSION_LIMIT 8
+5 -6
net/core/netdev-genl.c
··· 167 167 void *hdr; 168 168 pid_t pid; 169 169 170 - if (WARN_ON_ONCE(!napi->dev)) 171 - return -EINVAL; 172 170 if (!(napi->dev->flags & IFF_UP)) 173 171 return 0; 174 172 ··· 174 176 if (!hdr) 175 177 return -EMSGSIZE; 176 178 177 - if (napi->napi_id >= MIN_NAPI_ID && 178 - nla_put_u32(rsp, NETDEV_A_NAPI_ID, napi->napi_id)) 179 + if (nla_put_u32(rsp, NETDEV_A_NAPI_ID, napi->napi_id)) 179 180 goto nla_put_failure; 180 181 181 182 if (nla_put_u32(rsp, NETDEV_A_NAPI_IFINDEX, napi->dev->ifindex)) ··· 232 235 rtnl_lock(); 233 236 rcu_read_lock(); 234 237 235 - napi = napi_by_id(napi_id); 238 + napi = netdev_napi_by_id(genl_info_net(info), napi_id); 236 239 if (napi) { 237 240 err = netdev_nl_napi_fill_one(rsp, napi, info); 238 241 } else { ··· 269 272 return err; 270 273 271 274 list_for_each_entry(napi, &netdev->napi_list, dev_list) { 275 + if (napi->napi_id < MIN_NAPI_ID) 276 + continue; 272 277 if (ctx->napi_id && napi->napi_id >= ctx->napi_id) 273 278 continue; 274 279 ··· 353 354 rtnl_lock(); 354 355 rcu_read_lock(); 355 356 356 - napi = napi_by_id(napi_id); 357 + napi = netdev_napi_by_id(genl_info_net(info), napi_id); 357 358 if (napi) { 358 359 err = netdev_nl_napi_set_config(napi, info); 359 360 } else {
+1 -1
net/ipv4/tcp_ipv4.c
··· 898 898 sock_net_set(ctl_sk, net); 899 899 if (sk) { 900 900 ctl_sk->sk_mark = (sk->sk_state == TCP_TIME_WAIT) ? 901 - inet_twsk(sk)->tw_mark : sk->sk_mark; 901 + inet_twsk(sk)->tw_mark : READ_ONCE(sk->sk_mark); 902 902 ctl_sk->sk_priority = (sk->sk_state == TCP_TIME_WAIT) ? 903 903 inet_twsk(sk)->tw_priority : READ_ONCE(sk->sk_priority); 904 904 transmit_time = tcp_transmit_time(sk);
+4
net/mac802154/iface.c
··· 684 684 ASSERT_RTNL(); 685 685 686 686 mutex_lock(&sdata->local->iflist_mtx); 687 + if (list_empty(&sdata->local->interfaces)) { 688 + mutex_unlock(&sdata->local->iflist_mtx); 689 + return; 690 + } 687 691 list_del_rcu(&sdata->list); 688 692 mutex_unlock(&sdata->local->iflist_mtx); 689 693
+9 -8
net/mptcp/ctrl.c
··· 102 102 } 103 103 104 104 #ifdef CONFIG_SYSCTL 105 - static int mptcp_set_scheduler(const struct net *net, const char *name) 105 + static int mptcp_set_scheduler(char *scheduler, const char *name) 106 106 { 107 - struct mptcp_pernet *pernet = mptcp_get_pernet(net); 108 107 struct mptcp_sched_ops *sched; 109 108 int ret = 0; 110 109 111 110 rcu_read_lock(); 112 111 sched = mptcp_sched_find(name); 113 112 if (sched) 114 - strscpy(pernet->scheduler, name, MPTCP_SCHED_NAME_MAX); 113 + strscpy(scheduler, name, MPTCP_SCHED_NAME_MAX); 115 114 else 116 115 ret = -ENOENT; 117 116 rcu_read_unlock(); ··· 121 122 static int proc_scheduler(const struct ctl_table *ctl, int write, 122 123 void *buffer, size_t *lenp, loff_t *ppos) 123 124 { 124 - const struct net *net = current->nsproxy->net_ns; 125 + char (*scheduler)[MPTCP_SCHED_NAME_MAX] = ctl->data; 125 126 char val[MPTCP_SCHED_NAME_MAX]; 126 127 struct ctl_table tbl = { 127 128 .data = val, ··· 129 130 }; 130 131 int ret; 131 132 132 - strscpy(val, mptcp_get_scheduler(net), MPTCP_SCHED_NAME_MAX); 133 + strscpy(val, *scheduler, MPTCP_SCHED_NAME_MAX); 133 134 134 135 ret = proc_dostring(&tbl, write, buffer, lenp, ppos); 135 136 if (write && ret == 0) 136 - ret = mptcp_set_scheduler(net, val); 137 + ret = mptcp_set_scheduler(*scheduler, val); 137 138 138 139 return ret; 139 140 } ··· 160 161 int write, void *buffer, size_t *lenp, 161 162 loff_t *ppos) 162 163 { 163 - struct mptcp_pernet *pernet = mptcp_get_pernet(current->nsproxy->net_ns); 164 + struct mptcp_pernet *pernet = container_of(table->data, 165 + struct mptcp_pernet, 166 + blackhole_timeout); 164 167 int ret; 165 168 166 169 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); ··· 229 228 { 230 229 .procname = "available_schedulers", 231 230 .maxlen = MPTCP_SCHED_BUF_MAX, 232 - .mode = 0644, 231 + .mode = 0444, 233 232 .proc_handler = proc_available_schedulers, 234 233 }, 235 234 {
+4 -1
net/netfilter/nf_conntrack_core.c
··· 2517 2517 struct hlist_nulls_head *hash; 2518 2518 unsigned int nr_slots, i; 2519 2519 2520 - if (*sizep > (UINT_MAX / sizeof(struct hlist_nulls_head))) 2520 + if (*sizep > (INT_MAX / sizeof(struct hlist_nulls_head))) 2521 2521 return NULL; 2522 2522 2523 2523 BUILD_BUG_ON(sizeof(struct hlist_nulls_head) != sizeof(struct hlist_head)); 2524 2524 nr_slots = *sizep = roundup(*sizep, PAGE_SIZE / sizeof(struct hlist_nulls_head)); 2525 + 2526 + if (nr_slots > (INT_MAX / sizeof(struct hlist_nulls_head))) 2527 + return NULL; 2525 2528 2526 2529 hash = kvcalloc(nr_slots, sizeof(struct hlist_nulls_head), GFP_KERNEL); 2527 2530
+11 -4
net/netfilter/nf_tables_api.c
··· 8822 8822 } 8823 8823 8824 8824 static void __nft_unregister_flowtable_net_hooks(struct net *net, 8825 + struct nft_flowtable *flowtable, 8825 8826 struct list_head *hook_list, 8826 8827 bool release_netdev) 8827 8828 { ··· 8830 8829 8831 8830 list_for_each_entry_safe(hook, next, hook_list, list) { 8832 8831 nf_unregister_net_hook(net, &hook->ops); 8832 + flowtable->data.type->setup(&flowtable->data, hook->ops.dev, 8833 + FLOW_BLOCK_UNBIND); 8833 8834 if (release_netdev) { 8834 8835 list_del(&hook->list); 8835 8836 kfree_rcu(hook, rcu); ··· 8840 8837 } 8841 8838 8842 8839 static void nft_unregister_flowtable_net_hooks(struct net *net, 8840 + struct nft_flowtable *flowtable, 8843 8841 struct list_head *hook_list) 8844 8842 { 8845 - __nft_unregister_flowtable_net_hooks(net, hook_list, false); 8843 + __nft_unregister_flowtable_net_hooks(net, flowtable, hook_list, false); 8846 8844 } 8847 8845 8848 8846 static int nft_register_flowtable_net_hooks(struct net *net, ··· 9485 9481 9486 9482 flowtable->data.type->free(&flowtable->data); 9487 9483 list_for_each_entry_safe(hook, next, &flowtable->hook_list, list) { 9488 - flowtable->data.type->setup(&flowtable->data, hook->ops.dev, 9489 - FLOW_BLOCK_UNBIND); 9490 9484 list_del_rcu(&hook->list); 9491 9485 kfree_rcu(hook, rcu); 9492 9486 } ··· 10872 10870 &nft_trans_flowtable_hooks(trans), 10873 10871 trans->msg_type); 10874 10872 nft_unregister_flowtable_net_hooks(net, 10873 + nft_trans_flowtable(trans), 10875 10874 &nft_trans_flowtable_hooks(trans)); 10876 10875 } else { 10877 10876 list_del_rcu(&nft_trans_flowtable(trans)->list); ··· 10881 10878 NULL, 10882 10879 trans->msg_type); 10883 10880 nft_unregister_flowtable_net_hooks(net, 10881 + nft_trans_flowtable(trans), 10884 10882 &nft_trans_flowtable(trans)->hook_list); 10885 10883 } 10886 10884 break; ··· 11144 11140 case NFT_MSG_NEWFLOWTABLE: 11145 11141 if (nft_trans_flowtable_update(trans)) { 11146 11142 nft_unregister_flowtable_net_hooks(net, 11143 + nft_trans_flowtable(trans), 11147 11144 &nft_trans_flowtable_hooks(trans)); 11148 11145 } else { 11149 11146 nft_use_dec_restore(&table->use); 11150 11147 list_del_rcu(&nft_trans_flowtable(trans)->list); 11151 11148 nft_unregister_flowtable_net_hooks(net, 11149 + nft_trans_flowtable(trans), 11152 11150 &nft_trans_flowtable(trans)->hook_list); 11153 11151 } 11154 11152 break; ··· 11743 11737 list_for_each_entry(chain, &table->chains, list) 11744 11738 __nf_tables_unregister_hook(net, table, chain, true); 11745 11739 list_for_each_entry(flowtable, &table->flowtables, list) 11746 - __nft_unregister_flowtable_net_hooks(net, &flowtable->hook_list, 11740 + __nft_unregister_flowtable_net_hooks(net, flowtable, 11741 + &flowtable->hook_list, 11747 11742 true); 11748 11743 } 11749 11744
+32 -7
net/rds/tcp.c
··· 61 61 62 62 static struct kmem_cache *rds_tcp_conn_slab; 63 63 64 - static int rds_tcp_skbuf_handler(const struct ctl_table *ctl, int write, 65 - void *buffer, size_t *lenp, loff_t *fpos); 64 + static int rds_tcp_sndbuf_handler(const struct ctl_table *ctl, int write, 65 + void *buffer, size_t *lenp, loff_t *fpos); 66 + static int rds_tcp_rcvbuf_handler(const struct ctl_table *ctl, int write, 67 + void *buffer, size_t *lenp, loff_t *fpos); 66 68 67 69 static int rds_tcp_min_sndbuf = SOCK_MIN_SNDBUF; 68 70 static int rds_tcp_min_rcvbuf = SOCK_MIN_RCVBUF; ··· 76 74 /* data is per-net pointer */ 77 75 .maxlen = sizeof(int), 78 76 .mode = 0644, 79 - .proc_handler = rds_tcp_skbuf_handler, 77 + .proc_handler = rds_tcp_sndbuf_handler, 80 78 .extra1 = &rds_tcp_min_sndbuf, 81 79 }, 82 80 #define RDS_TCP_RCVBUF 1 ··· 85 83 /* data is per-net pointer */ 86 84 .maxlen = sizeof(int), 87 85 .mode = 0644, 88 - .proc_handler = rds_tcp_skbuf_handler, 86 + .proc_handler = rds_tcp_rcvbuf_handler, 89 87 .extra1 = &rds_tcp_min_rcvbuf, 90 88 }, 91 89 }; ··· 684 682 spin_unlock_irq(&rds_tcp_conn_lock); 685 683 } 686 684 687 - static int rds_tcp_skbuf_handler(const struct ctl_table *ctl, int write, 685 + static int rds_tcp_skbuf_handler(struct rds_tcp_net *rtn, 686 + const struct ctl_table *ctl, int write, 688 687 void *buffer, size_t *lenp, loff_t *fpos) 689 688 { 690 - struct net *net = current->nsproxy->net_ns; 691 689 int err; 692 690 693 691 err = proc_dointvec_minmax(ctl, write, buffer, lenp, fpos); ··· 696 694 *(int *)(ctl->extra1)); 697 695 return err; 698 696 } 699 - if (write) 697 + 698 + if (write && rtn->rds_tcp_listen_sock && rtn->rds_tcp_listen_sock->sk) { 699 + struct net *net = sock_net(rtn->rds_tcp_listen_sock->sk); 700 + 700 701 rds_tcp_sysctl_reset(net); 702 + } 703 + 701 704 return 0; 705 + } 706 + 707 + static int rds_tcp_sndbuf_handler(const struct ctl_table *ctl, int write, 708 + void *buffer, size_t *lenp, loff_t *fpos) 709 + { 710 + struct rds_tcp_net *rtn = container_of(ctl->data, struct rds_tcp_net, 711 + sndbuf_size); 712 + 713 + return rds_tcp_skbuf_handler(rtn, ctl, write, buffer, lenp, fpos); 714 + } 715 + 716 + static int rds_tcp_rcvbuf_handler(const struct ctl_table *ctl, int write, 717 + void *buffer, size_t *lenp, loff_t *fpos) 718 + { 719 + struct rds_tcp_net *rtn = container_of(ctl->data, struct rds_tcp_net, 720 + rcvbuf_size); 721 + 722 + return rds_tcp_skbuf_handler(rtn, ctl, write, buffer, lenp, fpos); 702 723 } 703 724 704 725 static void rds_tcp_exit(void)
+2 -1
net/sched/cls_flow.c
··· 356 356 [TCA_FLOW_KEYS] = { .type = NLA_U32 }, 357 357 [TCA_FLOW_MODE] = { .type = NLA_U32 }, 358 358 [TCA_FLOW_BASECLASS] = { .type = NLA_U32 }, 359 - [TCA_FLOW_RSHIFT] = { .type = NLA_U32 }, 359 + [TCA_FLOW_RSHIFT] = NLA_POLICY_MAX(NLA_U32, 360 + 31 /* BITS_PER_U32 - 1 */), 360 361 [TCA_FLOW_ADDEND] = { .type = NLA_U32 }, 361 362 [TCA_FLOW_MASK] = { .type = NLA_U32 }, 362 363 [TCA_FLOW_XOR] = { .type = NLA_U32 },
+75 -65
net/sched/sch_cake.c
··· 630 630 return (flow_mode & CAKE_FLOW_DUAL_DST) == CAKE_FLOW_DUAL_DST; 631 631 } 632 632 633 + static void cake_dec_srchost_bulk_flow_count(struct cake_tin_data *q, 634 + struct cake_flow *flow, 635 + int flow_mode) 636 + { 637 + if (likely(cake_dsrc(flow_mode) && 638 + q->hosts[flow->srchost].srchost_bulk_flow_count)) 639 + q->hosts[flow->srchost].srchost_bulk_flow_count--; 640 + } 641 + 642 + static void cake_inc_srchost_bulk_flow_count(struct cake_tin_data *q, 643 + struct cake_flow *flow, 644 + int flow_mode) 645 + { 646 + if (likely(cake_dsrc(flow_mode) && 647 + q->hosts[flow->srchost].srchost_bulk_flow_count < CAKE_QUEUES)) 648 + q->hosts[flow->srchost].srchost_bulk_flow_count++; 649 + } 650 + 651 + static void cake_dec_dsthost_bulk_flow_count(struct cake_tin_data *q, 652 + struct cake_flow *flow, 653 + int flow_mode) 654 + { 655 + if (likely(cake_ddst(flow_mode) && 656 + q->hosts[flow->dsthost].dsthost_bulk_flow_count)) 657 + q->hosts[flow->dsthost].dsthost_bulk_flow_count--; 658 + } 659 + 660 + static void cake_inc_dsthost_bulk_flow_count(struct cake_tin_data *q, 661 + struct cake_flow *flow, 662 + int flow_mode) 663 + { 664 + if (likely(cake_ddst(flow_mode) && 665 + q->hosts[flow->dsthost].dsthost_bulk_flow_count < CAKE_QUEUES)) 666 + q->hosts[flow->dsthost].dsthost_bulk_flow_count++; 667 + } 668 + 669 + static u16 cake_get_flow_quantum(struct cake_tin_data *q, 670 + struct cake_flow *flow, 671 + int flow_mode) 672 + { 673 + u16 host_load = 1; 674 + 675 + if (cake_dsrc(flow_mode)) 676 + host_load = max(host_load, 677 + q->hosts[flow->srchost].srchost_bulk_flow_count); 678 + 679 + if (cake_ddst(flow_mode)) 680 + host_load = max(host_load, 681 + q->hosts[flow->dsthost].dsthost_bulk_flow_count); 682 + 683 + /* The get_random_u16() is a way to apply dithering to avoid 684 + * accumulating roundoff errors 685 + */ 686 + return (q->flow_quantum * quantum_div[host_load] + 687 + get_random_u16()) >> 16; 688 + } 689 + 633 690 static u32 cake_hash(struct cake_tin_data *q, const struct sk_buff *skb, 634 691 int flow_mode, u16 flow_override, u16 host_override) 635 692 { ··· 833 776 allocate_dst = cake_ddst(flow_mode); 834 777 835 778 if (q->flows[outer_hash + k].set == CAKE_SET_BULK) { 836 - if (allocate_src) 837 - q->hosts[q->flows[reduced_hash].srchost].srchost_bulk_flow_count--; 838 - if (allocate_dst) 839 - q->hosts[q->flows[reduced_hash].dsthost].dsthost_bulk_flow_count--; 779 + cake_dec_srchost_bulk_flow_count(q, &q->flows[outer_hash + k], flow_mode); 780 + cake_dec_dsthost_bulk_flow_count(q, &q->flows[outer_hash + k], flow_mode); 840 781 } 841 782 found: 842 783 /* reserve queue for future packets in same flow */ ··· 859 804 q->hosts[outer_hash + k].srchost_tag = srchost_hash; 860 805 found_src: 861 806 srchost_idx = outer_hash + k; 862 - if (q->flows[reduced_hash].set == CAKE_SET_BULK) 863 - q->hosts[srchost_idx].srchost_bulk_flow_count++; 864 807 q->flows[reduced_hash].srchost = srchost_idx; 808 + 809 + if (q->flows[reduced_hash].set == CAKE_SET_BULK) 810 + cake_inc_srchost_bulk_flow_count(q, &q->flows[reduced_hash], flow_mode); 865 811 } 866 812 867 813 if (allocate_dst) { ··· 883 827 q->hosts[outer_hash + k].dsthost_tag = dsthost_hash; 884 828 found_dst: 885 829 dsthost_idx = outer_hash + k; 886 - if (q->flows[reduced_hash].set == CAKE_SET_BULK) 887 - q->hosts[dsthost_idx].dsthost_bulk_flow_count++; 888 830 q->flows[reduced_hash].dsthost = dsthost_idx; 831 + 832 + if (q->flows[reduced_hash].set == CAKE_SET_BULK) 833 + cake_inc_dsthost_bulk_flow_count(q, &q->flows[reduced_hash], flow_mode); 889 834 } 890 835 } 891 836 ··· 1898 1841 1899 1842 /* flowchain */ 1900 1843 if (!flow->set || flow->set == CAKE_SET_DECAYING) { 1901 - struct cake_host *srchost = &b->hosts[flow->srchost]; 1902 - struct cake_host *dsthost = &b->hosts[flow->dsthost]; 1903 - u16 host_load = 1; 1904 - 1905 1844 if (!flow->set) { 1906 1845 list_add_tail(&flow->flowchain, &b->new_flows); 1907 1846 } else { ··· 1907 1854 flow->set = CAKE_SET_SPARSE; 1908 1855 b->sparse_flow_count++; 1909 1856 1910 - if (cake_dsrc(q->flow_mode)) 1911 - host_load = max(host_load, srchost->srchost_bulk_flow_count); 1912 - 1913 - if (cake_ddst(q->flow_mode)) 1914 - host_load = max(host_load, dsthost->dsthost_bulk_flow_count); 1915 - 1916 - flow->deficit = (b->flow_quantum * 1917 - quantum_div[host_load]) >> 16; 1857 + flow->deficit = cake_get_flow_quantum(b, flow, q->flow_mode); 1918 1858 } else if (flow->set == CAKE_SET_SPARSE_WAIT) { 1919 - struct cake_host *srchost = &b->hosts[flow->srchost]; 1920 - struct cake_host *dsthost = &b->hosts[flow->dsthost]; 1921 - 1922 1859 /* this flow was empty, accounted as a sparse flow, but actually 1923 1860 * in the bulk rotation. 1924 1861 */ ··· 1916 1873 b->sparse_flow_count--; 1917 1874 b->bulk_flow_count++; 1918 1875 1919 - if (cake_dsrc(q->flow_mode)) 1920 - srchost->srchost_bulk_flow_count++; 1921 - 1922 - if (cake_ddst(q->flow_mode)) 1923 - dsthost->dsthost_bulk_flow_count++; 1924 - 1876 + cake_inc_srchost_bulk_flow_count(b, flow, q->flow_mode); 1877 + cake_inc_dsthost_bulk_flow_count(b, flow, q->flow_mode); 1925 1878 } 1926 1879 1927 1880 if (q->buffer_used > q->buffer_max_used) ··· 1974 1935 { 1975 1936 struct cake_sched_data *q = qdisc_priv(sch); 1976 1937 struct cake_tin_data *b = &q->tins[q->cur_tin]; 1977 - struct cake_host *srchost, *dsthost; 1978 1938 enum skb_drop_reason reason; 1979 1939 ktime_t now = ktime_get(); 1980 1940 struct cake_flow *flow; 1981 1941 struct list_head *head; 1982 1942 bool first_flow = true; 1983 1943 struct sk_buff *skb; 1984 - u16 host_load; 1985 1944 u64 delay; 1986 1945 u32 len; 1987 1946 ··· 2079 2042 q->cur_flow = flow - b->flows; 2080 2043 first_flow = false; 2081 2044 2082 - /* triple isolation (modified DRR++) */ 2083 - srchost = &b->hosts[flow->srchost]; 2084 - dsthost = &b->hosts[flow->dsthost]; 2085 - host_load = 1; 2086 - 2087 2045 /* flow isolation (DRR++) */ 2088 2046 if (flow->deficit <= 0) { 2089 2047 /* Keep all flows with deficits out of the sparse and decaying ··· 2090 2058 b->sparse_flow_count--; 2091 2059 b->bulk_flow_count++; 2092 2060 2093 - if (cake_dsrc(q->flow_mode)) 2094 - srchost->srchost_bulk_flow_count++; 2095 - 2096 - if (cake_ddst(q->flow_mode)) 2097 - dsthost->dsthost_bulk_flow_count++; 2061 + cake_inc_srchost_bulk_flow_count(b, flow, q->flow_mode); 2062 + cake_inc_dsthost_bulk_flow_count(b, flow, q->flow_mode); 2098 2063 2099 2064 flow->set = CAKE_SET_BULK; 2100 2065 } else { ··· 2103 2074 } 2104 2075 } 2105 2076 2106 - if (cake_dsrc(q->flow_mode)) 2107 - host_load = max(host_load, srchost->srchost_bulk_flow_count); 2108 - 2109 - if (cake_ddst(q->flow_mode)) 2110 - host_load = max(host_load, dsthost->dsthost_bulk_flow_count); 2111 - 2112 - WARN_ON(host_load > CAKE_QUEUES); 2113 - 2114 - /* The get_random_u16() is a way to apply dithering to avoid 2115 - * accumulating roundoff errors 2116 - */ 2117 - flow->deficit += (b->flow_quantum * quantum_div[host_load] + 2118 - get_random_u16()) >> 16; 2077 + flow->deficit += cake_get_flow_quantum(b, flow, q->flow_mode); 2119 2078 list_move_tail(&flow->flowchain, &b->old_flows); 2120 2079 2121 2080 goto retry; ··· 2127 2110 if (flow->set == CAKE_SET_BULK) { 2128 2111 b->bulk_flow_count--; 2129 2112 2130 - if (cake_dsrc(q->flow_mode)) 2131 - srchost->srchost_bulk_flow_count--; 2132 - 2133 - if (cake_ddst(q->flow_mode)) 2134 - dsthost->dsthost_bulk_flow_count--; 2113 + cake_dec_srchost_bulk_flow_count(b, flow, q->flow_mode); 2114 + cake_dec_dsthost_bulk_flow_count(b, flow, q->flow_mode); 2135 2115 2136 2116 b->decaying_flow_count++; 2137 2117 } else if (flow->set == CAKE_SET_SPARSE || ··· 2146 2132 else if (flow->set == CAKE_SET_BULK) { 2147 2133 b->bulk_flow_count--; 2148 2134 2149 - if (cake_dsrc(q->flow_mode)) 2150 - srchost->srchost_bulk_flow_count--; 2151 - 2152 - if (cake_ddst(q->flow_mode)) 2153 - dsthost->dsthost_bulk_flow_count--; 2154 - 2135 + cake_dec_srchost_bulk_flow_count(b, flow, q->flow_mode); 2136 + cake_dec_dsthost_bulk_flow_count(b, flow, q->flow_mode); 2155 2137 } else 2156 2138 b->decaying_flow_count--; 2157 2139
+8 -6
net/sctp/sysctl.c
··· 387 387 static int proc_sctp_do_hmac_alg(const struct ctl_table *ctl, int write, 388 388 void *buffer, size_t *lenp, loff_t *ppos) 389 389 { 390 - struct net *net = current->nsproxy->net_ns; 390 + struct net *net = container_of(ctl->data, struct net, 391 + sctp.sctp_hmac_alg); 391 392 struct ctl_table tbl; 392 393 bool changed = false; 393 394 char *none = "none"; ··· 433 432 static int proc_sctp_do_rto_min(const struct ctl_table *ctl, int write, 434 433 void *buffer, size_t *lenp, loff_t *ppos) 435 434 { 436 - struct net *net = current->nsproxy->net_ns; 435 + struct net *net = container_of(ctl->data, struct net, sctp.rto_min); 437 436 unsigned int min = *(unsigned int *) ctl->extra1; 438 437 unsigned int max = *(unsigned int *) ctl->extra2; 439 438 struct ctl_table tbl; ··· 461 460 static int proc_sctp_do_rto_max(const struct ctl_table *ctl, int write, 462 461 void *buffer, size_t *lenp, loff_t *ppos) 463 462 { 464 - struct net *net = current->nsproxy->net_ns; 463 + struct net *net = container_of(ctl->data, struct net, sctp.rto_max); 465 464 unsigned int min = *(unsigned int *) ctl->extra1; 466 465 unsigned int max = *(unsigned int *) ctl->extra2; 467 466 struct ctl_table tbl; ··· 499 498 static int proc_sctp_do_auth(const struct ctl_table *ctl, int write, 500 499 void *buffer, size_t *lenp, loff_t *ppos) 501 500 { 502 - struct net *net = current->nsproxy->net_ns; 501 + struct net *net = container_of(ctl->data, struct net, sctp.auth_enable); 503 502 struct ctl_table tbl; 504 503 int new_value, ret; 505 504 ··· 528 527 static int proc_sctp_do_udp_port(const struct ctl_table *ctl, int write, 529 528 void *buffer, size_t *lenp, loff_t *ppos) 530 529 { 531 - struct net *net = current->nsproxy->net_ns; 530 + struct net *net = container_of(ctl->data, struct net, sctp.udp_port); 532 531 unsigned int min = *(unsigned int *)ctl->extra1; 533 532 unsigned int max = *(unsigned int *)ctl->extra2; 534 533 struct ctl_table tbl; ··· 569 568 static int proc_sctp_do_probe_interval(const struct ctl_table *ctl, int write, 570 569 void *buffer, size_t *lenp, loff_t *ppos) 571 570 { 572 - struct net *net = current->nsproxy->net_ns; 571 + struct net *net = container_of(ctl->data, struct net, 572 + sctp.probe_interval); 573 573 struct ctl_table tbl; 574 574 int ret, new_value; 575 575
+1 -1
net/tls/tls_sw.c
··· 458 458 459 459 tx_err: 460 460 if (rc < 0 && rc != -EAGAIN) 461 - tls_err_abort(sk, -EBADMSG); 461 + tls_err_abort(sk, rc); 462 462 463 463 return rc; 464 464 }
+16 -2
rust/kernel/workqueue.rs
··· 519 519 impl{T} HasWork<Self> for ClosureWork<T> { self.work } 520 520 } 521 521 522 - // SAFETY: TODO. 522 + // SAFETY: The `__enqueue` implementation in RawWorkItem uses a `work_struct` initialized with the 523 + // `run` method of this trait as the function pointer because: 524 + // - `__enqueue` gets the `work_struct` from the `Work` field, using `T::raw_get_work`. 525 + // - The only safe way to create a `Work` object is through `Work::new`. 526 + // - `Work::new` makes sure that `T::Pointer::run` is passed to `init_work_with_key`. 527 + // - Finally `Work` and `RawWorkItem` guarantee that the correct `Work` field 528 + // will be used because of the ID const generic bound. This makes sure that `T::raw_get_work` 529 + // uses the correct offset for the `Work` field, and `Work::new` picks the correct 530 + // implementation of `WorkItemPointer` for `Arc<T>`. 523 531 unsafe impl<T, const ID: u64> WorkItemPointer<ID> for Arc<T> 524 532 where 525 533 T: WorkItem<ID, Pointer = Self>, ··· 545 537 } 546 538 } 547 539 548 - // SAFETY: TODO. 540 + // SAFETY: The `work_struct` raw pointer is guaranteed to be valid for the duration of the call to 541 + // the closure because we get it from an `Arc`, which means that the ref count will be at least 1, 542 + // and we don't drop the `Arc` ourselves. If `queue_work_on` returns true, it is further guaranteed 543 + // to be valid until a call to the function pointer in `work_struct` because we leak the memory it 544 + // points to, and only reclaim it if the closure returns false, or in `WorkItemPointer::run`, which 545 + // is what the function pointer in the `work_struct` must be pointing to, according to the safety 546 + // requirements of `WorkItemPointer`. 549 547 unsafe impl<T, const ID: u64> RawWorkItem<ID> for Arc<T> 550 548 where 551 549 T: WorkItem<ID, Pointer = Self>,
+2 -2
scripts/mksysmap
··· 26 26 # (do not forget a space before each pattern) 27 27 28 28 # local symbols for ARM, MIPS, etc. 29 - / \\$/d 29 + / \$/d 30 30 31 31 # local labels, .LBB, .Ltmpxxx, .L__unnamed_xx, .LASANPC, etc. 32 32 / \.L/d ··· 39 39 / __pi_\.L/d 40 40 41 41 # arm64 local symbols in non-VHE KVM namespace 42 - / __kvm_nvhe_\\$/d 42 + / __kvm_nvhe_\$/d 43 43 / __kvm_nvhe_\.L/d 44 44 45 45 # lld arm/aarch64/mips thunks
+17 -19
scripts/mod/file2alias.c
··· 132 132 * based at address m. 133 133 */ 134 134 #define DEF_FIELD(m, devid, f) \ 135 - typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f)) 135 + typeof(((struct devid *)0)->f) f = \ 136 + get_unaligned_native((typeof(f) *)((m) + OFF_##devid##_##f)) 136 137 137 138 /* Define a variable f that holds the address of field f of struct devid 138 139 * based at address m. Due to the way typeof works, for a field of type ··· 601 600 static void do_pcmcia_entry(struct module *mod, void *symval) 602 601 { 603 602 char alias[256] = {}; 604 - unsigned int i; 603 + 605 604 DEF_FIELD(symval, pcmcia_device_id, match_flags); 606 605 DEF_FIELD(symval, pcmcia_device_id, manf_id); 607 606 DEF_FIELD(symval, pcmcia_device_id, card_id); ··· 609 608 DEF_FIELD(symval, pcmcia_device_id, function); 610 609 DEF_FIELD(symval, pcmcia_device_id, device_no); 611 610 DEF_FIELD_ADDR(symval, pcmcia_device_id, prod_id_hash); 612 - 613 - for (i=0; i<4; i++) { 614 - (*prod_id_hash)[i] = TO_NATIVE((*prod_id_hash)[i]); 615 - } 616 611 617 612 ADD(alias, "m", match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID, 618 613 manf_id); ··· 620 623 function); 621 624 ADD(alias, "pfn", match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO, 622 625 device_no); 623 - ADD(alias, "pa", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, (*prod_id_hash)[0]); 624 - ADD(alias, "pb", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, (*prod_id_hash)[1]); 625 - ADD(alias, "pc", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, (*prod_id_hash)[2]); 626 - ADD(alias, "pd", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, (*prod_id_hash)[3]); 626 + ADD(alias, "pa", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, 627 + get_unaligned_native(*prod_id_hash + 0)); 628 + ADD(alias, "pb", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, 629 + get_unaligned_native(*prod_id_hash + 1)); 630 + ADD(alias, "pc", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, 631 + get_unaligned_native(*prod_id_hash + 2)); 632 + ADD(alias, "pd", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, 633 + get_unaligned_native(*prod_id_hash + 3)); 627 634 628 635 module_alias_printf(mod, true, "pcmcia:%s", alias); 629 636 } ··· 655 654 { 656 655 unsigned int i; 657 656 658 - for (i = min / BITS_PER_LONG; i < max / BITS_PER_LONG + 1; i++) 659 - arr[i] = TO_NATIVE(arr[i]); 660 - for (i = min; i < max; i++) 661 - if (arr[i / BITS_PER_LONG] & (1ULL << (i%BITS_PER_LONG))) 657 + for (i = min; i <= max; i++) 658 + if (get_unaligned_native(arr + i / BITS_PER_LONG) & 659 + (1ULL << (i % BITS_PER_LONG))) 662 660 sprintf(alias + strlen(alias), "%X,*", i); 663 661 } 664 662 ··· 812 812 * Each byte of the guid will be represented by two hex characters 813 813 * in the name. 814 814 */ 815 - 816 815 static void do_vmbus_entry(struct module *mod, void *symval) 817 816 { 818 - int i; 819 817 DEF_FIELD_ADDR(symval, hv_vmbus_device_id, guid); 820 - char guid_name[(sizeof(*guid) + 1) * 2]; 818 + char guid_name[sizeof(*guid) * 2 + 1]; 821 819 822 - for (i = 0; i < (sizeof(*guid) * 2); i += 2) 823 - sprintf(&guid_name[i], "%02x", TO_NATIVE((guid->b)[i/2])); 820 + for (int i = 0; i < sizeof(*guid); i++) 821 + sprintf(&guid_name[i * 2], "%02x", guid->b[i]); 824 822 825 823 module_alias_printf(mod, false, "vmbus:%s", guid_name); 826 824 }
+12 -12
scripts/mod/modpost.c
··· 1138 1138 { 1139 1139 switch (r_type) { 1140 1140 case R_386_32: 1141 - return TO_NATIVE(*location); 1141 + return get_unaligned_native(location); 1142 1142 case R_386_PC32: 1143 - return TO_NATIVE(*location) + 4; 1143 + return get_unaligned_native(location) + 4; 1144 1144 } 1145 1145 1146 1146 return (Elf_Addr)(-1); ··· 1161 1161 switch (r_type) { 1162 1162 case R_ARM_ABS32: 1163 1163 case R_ARM_REL32: 1164 - inst = TO_NATIVE(*(uint32_t *)loc); 1164 + inst = get_unaligned_native((uint32_t *)loc); 1165 1165 return inst + sym->st_value; 1166 1166 case R_ARM_MOVW_ABS_NC: 1167 1167 case R_ARM_MOVT_ABS: 1168 - inst = TO_NATIVE(*(uint32_t *)loc); 1168 + inst = get_unaligned_native((uint32_t *)loc); 1169 1169 offset = sign_extend32(((inst & 0xf0000) >> 4) | (inst & 0xfff), 1170 1170 15); 1171 1171 return offset + sym->st_value; 1172 1172 case R_ARM_PC24: 1173 1173 case R_ARM_CALL: 1174 1174 case R_ARM_JUMP24: 1175 - inst = TO_NATIVE(*(uint32_t *)loc); 1175 + inst = get_unaligned_native((uint32_t *)loc); 1176 1176 offset = sign_extend32((inst & 0x00ffffff) << 2, 25); 1177 1177 return offset + sym->st_value + 8; 1178 1178 case R_ARM_THM_MOVW_ABS_NC: 1179 1179 case R_ARM_THM_MOVT_ABS: 1180 - upper = TO_NATIVE(*(uint16_t *)loc); 1181 - lower = TO_NATIVE(*((uint16_t *)loc + 1)); 1180 + upper = get_unaligned_native((uint16_t *)loc); 1181 + lower = get_unaligned_native((uint16_t *)loc + 1); 1182 1182 offset = sign_extend32(((upper & 0x000f) << 12) | 1183 1183 ((upper & 0x0400) << 1) | 1184 1184 ((lower & 0x7000) >> 4) | ··· 1195 1195 * imm11 = lower[10:0] 1196 1196 * imm32 = SignExtend(S:J2:J1:imm6:imm11:'0') 1197 1197 */ 1198 - upper = TO_NATIVE(*(uint16_t *)loc); 1199 - lower = TO_NATIVE(*((uint16_t *)loc + 1)); 1198 + upper = get_unaligned_native((uint16_t *)loc); 1199 + lower = get_unaligned_native((uint16_t *)loc + 1); 1200 1200 1201 1201 sign = (upper >> 10) & 1; 1202 1202 j1 = (lower >> 13) & 1; ··· 1219 1219 * I2 = NOT(J2 XOR S) 1220 1220 * imm32 = SignExtend(S:I1:I2:imm10:imm11:'0') 1221 1221 */ 1222 - upper = TO_NATIVE(*(uint16_t *)loc); 1223 - lower = TO_NATIVE(*((uint16_t *)loc + 1)); 1222 + upper = get_unaligned_native((uint16_t *)loc); 1223 + lower = get_unaligned_native((uint16_t *)loc + 1); 1224 1224 1225 1225 sign = (upper >> 10) & 1; 1226 1226 j1 = (lower >> 13) & 1; ··· 1241 1241 { 1242 1242 uint32_t inst; 1243 1243 1244 - inst = TO_NATIVE(*location); 1244 + inst = get_unaligned_native(location); 1245 1245 switch (r_type) { 1246 1246 case R_MIPS_LO16: 1247 1247 return inst & 0xffff;
+14
scripts/mod/modpost.h
··· 65 65 #define TO_NATIVE(x) \ 66 66 (target_is_big_endian == host_is_big_endian ? x : bswap(x)) 67 67 68 + #define __get_unaligned_t(type, ptr) ({ \ 69 + const struct { type x; } __attribute__((__packed__)) *__pptr = \ 70 + (typeof(__pptr))(ptr); \ 71 + __pptr->x; \ 72 + }) 73 + 74 + #define get_unaligned(ptr) __get_unaligned_t(typeof(*(ptr)), (ptr)) 75 + 76 + #define get_unaligned_native(ptr) \ 77 + ({ \ 78 + typeof(*(ptr)) _val = get_unaligned(ptr); \ 79 + TO_NATIVE(_val); \ 80 + }) 81 + 68 82 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) 69 83 70 84 #define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
+1 -1
scripts/package/PKGBUILD
··· 103 103 104 104 _package-api-headers() { 105 105 pkgdesc="Kernel headers sanitized for use in userspace" 106 - provides=(linux-api-headers) 106 + provides=(linux-api-headers="${pkgver}") 107 107 conflicts=(linux-api-headers) 108 108 109 109 _prologue
+4 -1
scripts/sorttable.h
··· 110 110 111 111 static int orc_sort_cmp(const void *_a, const void *_b) 112 112 { 113 - struct orc_entry *orc_a; 113 + struct orc_entry *orc_a, *orc_b; 114 114 const int *a = g_orc_ip_table + *(int *)_a; 115 115 const int *b = g_orc_ip_table + *(int *)_b; 116 116 unsigned long a_val = orc_ip(a); ··· 128 128 * whitelisted .o files which didn't get objtool generation. 129 129 */ 130 130 orc_a = g_orc_table + (a - g_orc_ip_table); 131 + orc_b = g_orc_table + (b - g_orc_ip_table); 132 + if (orc_a->type == ORC_TYPE_UNDEFINED && orc_b->type == ORC_TYPE_UNDEFINED) 133 + return 0; 131 134 return orc_a->type == ORC_TYPE_UNDEFINED ? -1 : 1; 132 135 } 133 136
+34 -27
security/selinux/avc.c
··· 174 174 * using a linked list for extended_perms_decision lookup because the list is 175 175 * always small. i.e. less than 5, typically 1 176 176 */ 177 - static struct extended_perms_decision *avc_xperms_decision_lookup(u8 driver, 178 - struct avc_xperms_node *xp_node) 177 + static struct extended_perms_decision * 178 + avc_xperms_decision_lookup(u8 driver, u8 base_perm, 179 + struct avc_xperms_node *xp_node) 179 180 { 180 181 struct avc_xperms_decision_node *xpd_node; 181 182 182 183 list_for_each_entry(xpd_node, &xp_node->xpd_head, xpd_list) { 183 - if (xpd_node->xpd.driver == driver) 184 + if (xpd_node->xpd.driver == driver && 185 + xpd_node->xpd.base_perm == base_perm) 184 186 return &xpd_node->xpd; 185 187 } 186 188 return NULL; ··· 207 205 } 208 206 209 207 static void avc_xperms_allow_perm(struct avc_xperms_node *xp_node, 210 - u8 driver, u8 perm) 208 + u8 driver, u8 base_perm, u8 perm) 211 209 { 212 210 struct extended_perms_decision *xpd; 213 211 security_xperm_set(xp_node->xp.drivers.p, driver); 214 - xpd = avc_xperms_decision_lookup(driver, xp_node); 212 + xp_node->xp.base_perms |= base_perm; 213 + xpd = avc_xperms_decision_lookup(driver, base_perm, xp_node); 215 214 if (xpd && xpd->allowed) 216 215 security_xperm_set(xpd->allowed->p, perm); 217 216 } ··· 248 245 static void avc_copy_xperms_decision(struct extended_perms_decision *dest, 249 246 struct extended_perms_decision *src) 250 247 { 248 + dest->base_perm = src->base_perm; 251 249 dest->driver = src->driver; 252 250 dest->used = src->used; 253 251 if (dest->used & XPERMS_ALLOWED) ··· 276 272 */ 277 273 u8 i = perm >> 5; 278 274 275 + dest->base_perm = src->base_perm; 279 276 dest->used = src->used; 280 277 if (dest->used & XPERMS_ALLOWED) 281 278 dest->allowed->p[i] = src->allowed->p[i]; ··· 362 357 363 358 memcpy(dest->xp.drivers.p, src->xp.drivers.p, sizeof(dest->xp.drivers.p)); 364 359 dest->xp.len = src->xp.len; 360 + dest->xp.base_perms = src->xp.base_perms; 365 361 366 362 /* for each source xpd allocate a destination xpd and copy */ 367 363 list_for_each_entry(src_xpd, &src->xpd_head, xpd_list) { ··· 813 807 * @event : Updating event 814 808 * @perms : Permission mask bits 815 809 * @driver: xperm driver information 810 + * @base_perm: the base permission associated with the extended permission 816 811 * @xperm: xperm permissions 817 812 * @ssid: AVC entry source sid 818 813 * @tsid: AVC entry target sid ··· 827 820 * otherwise, this function updates the AVC entry. The original AVC-entry object 828 821 * will release later by RCU. 829 822 */ 830 - static int avc_update_node(u32 event, u32 perms, u8 driver, u8 xperm, u32 ssid, 831 - u32 tsid, u16 tclass, u32 seqno, 832 - struct extended_perms_decision *xpd, 833 - u32 flags) 823 + static int avc_update_node(u32 event, u32 perms, u8 driver, u8 base_perm, 824 + u8 xperm, u32 ssid, u32 tsid, u16 tclass, u32 seqno, 825 + struct extended_perms_decision *xpd, u32 flags) 834 826 { 835 827 u32 hvalue; 836 828 int rc = 0; ··· 886 880 case AVC_CALLBACK_GRANT: 887 881 node->ae.avd.allowed |= perms; 888 882 if (node->ae.xp_node && (flags & AVC_EXTENDED_PERMS)) 889 - avc_xperms_allow_perm(node->ae.xp_node, driver, xperm); 883 + avc_xperms_allow_perm(node->ae.xp_node, driver, base_perm, xperm); 890 884 break; 891 885 case AVC_CALLBACK_TRY_REVOKE: 892 886 case AVC_CALLBACK_REVOKE: ··· 993 987 avc_insert(ssid, tsid, tclass, avd, xp_node); 994 988 } 995 989 996 - static noinline int avc_denied(u32 ssid, u32 tsid, 997 - u16 tclass, u32 requested, 998 - u8 driver, u8 xperm, unsigned int flags, 999 - struct av_decision *avd) 990 + static noinline int avc_denied(u32 ssid, u32 tsid, u16 tclass, u32 requested, 991 + u8 driver, u8 base_perm, u8 xperm, 992 + unsigned int flags, struct av_decision *avd) 1000 993 { 1001 994 if (flags & AVC_STRICT) 1002 995 return -EACCES; ··· 1004 999 !(avd->flags & AVD_FLAGS_PERMISSIVE)) 1005 1000 return -EACCES; 1006 1001 1007 - avc_update_node(AVC_CALLBACK_GRANT, requested, driver, 1002 + avc_update_node(AVC_CALLBACK_GRANT, requested, driver, base_perm, 1008 1003 xperm, ssid, tsid, tclass, avd->seqno, NULL, flags); 1009 1004 return 0; 1010 1005 } ··· 1017 1012 * driver field is used to specify which set contains the permission. 1018 1013 */ 1019 1014 int avc_has_extended_perms(u32 ssid, u32 tsid, u16 tclass, u32 requested, 1020 - u8 driver, u8 xperm, struct common_audit_data *ad) 1015 + u8 driver, u8 base_perm, u8 xperm, 1016 + struct common_audit_data *ad) 1021 1017 { 1022 1018 struct avc_node *node; 1023 1019 struct av_decision avd; ··· 1053 1047 local_xpd.auditallow = &auditallow; 1054 1048 local_xpd.dontaudit = &dontaudit; 1055 1049 1056 - xpd = avc_xperms_decision_lookup(driver, xp_node); 1050 + xpd = avc_xperms_decision_lookup(driver, base_perm, xp_node); 1057 1051 if (unlikely(!xpd)) { 1058 1052 /* 1059 1053 * Compute the extended_perms_decision only if the driver 1060 - * is flagged 1054 + * is flagged and the base permission is known. 1061 1055 */ 1062 - if (!security_xperm_test(xp_node->xp.drivers.p, driver)) { 1056 + if (!security_xperm_test(xp_node->xp.drivers.p, driver) || 1057 + !(xp_node->xp.base_perms & base_perm)) { 1063 1058 avd.allowed &= ~requested; 1064 1059 goto decision; 1065 1060 } 1066 1061 rcu_read_unlock(); 1067 - security_compute_xperms_decision(ssid, tsid, tclass, 1068 - driver, &local_xpd); 1062 + security_compute_xperms_decision(ssid, tsid, tclass, driver, 1063 + base_perm, &local_xpd); 1069 1064 rcu_read_lock(); 1070 - avc_update_node(AVC_CALLBACK_ADD_XPERMS, requested, 1071 - driver, xperm, ssid, tsid, tclass, avd.seqno, 1065 + avc_update_node(AVC_CALLBACK_ADD_XPERMS, requested, driver, 1066 + base_perm, xperm, ssid, tsid, tclass, avd.seqno, 1072 1067 &local_xpd, 0); 1073 1068 } else { 1074 1069 avc_quick_copy_xperms_decision(xperm, &local_xpd, xpd); ··· 1082 1075 decision: 1083 1076 denied = requested & ~(avd.allowed); 1084 1077 if (unlikely(denied)) 1085 - rc = avc_denied(ssid, tsid, tclass, requested, 1086 - driver, xperm, AVC_EXTENDED_PERMS, &avd); 1078 + rc = avc_denied(ssid, tsid, tclass, requested, driver, 1079 + base_perm, xperm, AVC_EXTENDED_PERMS, &avd); 1087 1080 1088 1081 rcu_read_unlock(); 1089 1082 ··· 1117 1110 avc_compute_av(ssid, tsid, tclass, avd, &xp_node); 1118 1111 denied = requested & ~(avd->allowed); 1119 1112 if (unlikely(denied)) 1120 - return avc_denied(ssid, tsid, tclass, requested, 0, 0, 1113 + return avc_denied(ssid, tsid, tclass, requested, 0, 0, 0, 1121 1114 flags, avd); 1122 1115 return 0; 1123 1116 } ··· 1165 1158 rcu_read_unlock(); 1166 1159 1167 1160 if (unlikely(denied)) 1168 - return avc_denied(ssid, tsid, tclass, requested, 0, 0, 1161 + return avc_denied(ssid, tsid, tclass, requested, 0, 0, 0, 1169 1162 flags, avd); 1170 1163 return 0; 1171 1164 }
+3 -3
security/selinux/hooks.c
··· 3688 3688 return 0; 3689 3689 3690 3690 isec = inode_security(inode); 3691 - rc = avc_has_extended_perms(ssid, isec->sid, isec->sclass, 3692 - requested, driver, xperm, &ad); 3691 + rc = avc_has_extended_perms(ssid, isec->sid, isec->sclass, requested, 3692 + driver, AVC_EXT_IOCTL, xperm, &ad); 3693 3693 out: 3694 3694 return rc; 3695 3695 } ··· 5952 5952 xperm = nlmsg_type & 0xff; 5953 5953 5954 5954 return avc_has_extended_perms(current_sid(), sksec->sid, sksec->sclass, 5955 - perms, driver, xperm, &ad); 5955 + perms, driver, AVC_EXT_NLMSG, xperm, &ad); 5956 5956 } 5957 5957 5958 5958 static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb)
+4 -1
security/selinux/include/avc.h
··· 136 136 int avc_has_perm(u32 ssid, u32 tsid, u16 tclass, u32 requested, 137 137 struct common_audit_data *auditdata); 138 138 139 + #define AVC_EXT_IOCTL (1 << 0) /* Cache entry for an ioctl extended permission */ 140 + #define AVC_EXT_NLMSG (1 << 1) /* Cache entry for an nlmsg extended permission */ 139 141 int avc_has_extended_perms(u32 ssid, u32 tsid, u16 tclass, u32 requested, 140 - u8 driver, u8 perm, struct common_audit_data *ad); 142 + u8 driver, u8 base_perm, u8 perm, 143 + struct common_audit_data *ad); 141 144 142 145 u32 avc_policy_seqno(void); 143 146
+3
security/selinux/include/security.h
··· 239 239 struct extended_perms_decision { 240 240 u8 used; 241 241 u8 driver; 242 + u8 base_perm; 242 243 struct extended_perms_data *allowed; 243 244 struct extended_perms_data *auditallow; 244 245 struct extended_perms_data *dontaudit; ··· 247 246 248 247 struct extended_perms { 249 248 u16 len; /* length associated decision chain */ 249 + u8 base_perms; /* which base permissions are covered */ 250 250 struct extended_perms_data drivers; /* flag drivers that are used */ 251 251 }; 252 252 ··· 259 257 struct extended_perms *xperms); 260 258 261 259 void security_compute_xperms_decision(u32 ssid, u32 tsid, u16 tclass, u8 driver, 260 + u8 base_perm, 262 261 struct extended_perms_decision *xpermd); 263 262 264 263 void security_compute_av_user(u32 ssid, u32 tsid, u16 tclass,
+21 -7
security/selinux/ss/services.c
··· 582 582 } 583 583 584 584 /* 585 - * Flag which drivers have permissions. 585 + * Flag which drivers have permissions and which base permissions are covered. 586 586 */ 587 587 void services_compute_xperms_drivers( 588 588 struct extended_perms *xperms, ··· 592 592 593 593 switch (node->datum.u.xperms->specified) { 594 594 case AVTAB_XPERMS_IOCTLDRIVER: 595 + xperms->base_perms |= AVC_EXT_IOCTL; 595 596 /* if one or more driver has all permissions allowed */ 596 597 for (i = 0; i < ARRAY_SIZE(xperms->drivers.p); i++) 597 598 xperms->drivers.p[i] |= node->datum.u.xperms->perms.p[i]; 598 599 break; 599 600 case AVTAB_XPERMS_IOCTLFUNCTION: 601 + xperms->base_perms |= AVC_EXT_IOCTL; 602 + /* if allowing permissions within a driver */ 603 + security_xperm_set(xperms->drivers.p, 604 + node->datum.u.xperms->driver); 605 + break; 600 606 case AVTAB_XPERMS_NLMSG: 607 + xperms->base_perms |= AVC_EXT_NLMSG; 601 608 /* if allowing permissions within a driver */ 602 609 security_xperm_set(xperms->drivers.p, 603 610 node->datum.u.xperms->driver); ··· 638 631 avd->auditallow = 0; 639 632 avd->auditdeny = 0xffffffff; 640 633 if (xperms) { 641 - memset(&xperms->drivers, 0, sizeof(xperms->drivers)); 642 - xperms->len = 0; 634 + memset(xperms, 0, sizeof(*xperms)); 643 635 } 644 636 645 637 if (unlikely(!tclass || tclass > policydb->p_classes.nprim)) { ··· 975 969 { 976 970 switch (node->datum.u.xperms->specified) { 977 971 case AVTAB_XPERMS_IOCTLFUNCTION: 978 - case AVTAB_XPERMS_NLMSG: 979 - if (xpermd->driver != node->datum.u.xperms->driver) 972 + if (xpermd->base_perm != AVC_EXT_IOCTL || 973 + xpermd->driver != node->datum.u.xperms->driver) 980 974 return; 981 975 break; 982 976 case AVTAB_XPERMS_IOCTLDRIVER: 983 - if (!security_xperm_test(node->datum.u.xperms->perms.p, 984 - xpermd->driver)) 977 + if (xpermd->base_perm != AVC_EXT_IOCTL || 978 + !security_xperm_test(node->datum.u.xperms->perms.p, 979 + xpermd->driver)) 980 + return; 981 + break; 982 + case AVTAB_XPERMS_NLMSG: 983 + if (xpermd->base_perm != AVC_EXT_NLMSG || 984 + xpermd->driver != node->datum.u.xperms->driver) 985 985 return; 986 986 break; 987 987 default: ··· 1022 1010 u32 tsid, 1023 1011 u16 orig_tclass, 1024 1012 u8 driver, 1013 + u8 base_perm, 1025 1014 struct extended_perms_decision *xpermd) 1026 1015 { 1027 1016 struct selinux_policy *policy; ··· 1036 1023 struct ebitmap_node *snode, *tnode; 1037 1024 unsigned int i, j; 1038 1025 1026 + xpermd->base_perm = base_perm; 1039 1027 xpermd->driver = driver; 1040 1028 xpermd->used = 0; 1041 1029 memset(xpermd->allowed->p, 0, sizeof(xpermd->allowed->p));
+3 -3
tools/sched_ext/include/scx/common.bpf.h
··· 40 40 void scx_bpf_dsq_insert_vtime(struct task_struct *p, u64 dsq_id, u64 slice, u64 vtime, u64 enq_flags) __ksym __weak; 41 41 u32 scx_bpf_dispatch_nr_slots(void) __ksym; 42 42 void scx_bpf_dispatch_cancel(void) __ksym; 43 - bool scx_bpf_dsq_move_to_local(u64 dsq_id) __ksym; 44 - void scx_bpf_dsq_move_set_slice(struct bpf_iter_scx_dsq *it__iter, u64 slice) __ksym; 45 - void scx_bpf_dsq_move_set_vtime(struct bpf_iter_scx_dsq *it__iter, u64 vtime) __ksym; 43 + bool scx_bpf_dsq_move_to_local(u64 dsq_id) __ksym __weak; 44 + void scx_bpf_dsq_move_set_slice(struct bpf_iter_scx_dsq *it__iter, u64 slice) __ksym __weak; 45 + void scx_bpf_dsq_move_set_vtime(struct bpf_iter_scx_dsq *it__iter, u64 vtime) __ksym __weak; 46 46 bool scx_bpf_dsq_move(struct bpf_iter_scx_dsq *it__iter, struct task_struct *p, u64 dsq_id, u64 enq_flags) __ksym __weak; 47 47 bool scx_bpf_dsq_move_vtime(struct bpf_iter_scx_dsq *it__iter, struct task_struct *p, u64 dsq_id, u64 enq_flags) __ksym __weak; 48 48 u32 scx_bpf_reenqueue_local(void) __ksym;
+1 -1
tools/sched_ext/scx_central.c
··· 97 97 SCX_BUG_ON(!cpuset, "Failed to allocate cpuset"); 98 98 CPU_ZERO(cpuset); 99 99 CPU_SET(skel->rodata->central_cpu, cpuset); 100 - SCX_BUG_ON(sched_setaffinity(0, sizeof(cpuset), cpuset), 100 + SCX_BUG_ON(sched_setaffinity(0, sizeof(*cpuset), cpuset), 101 101 "Failed to affinitize to central CPU %d (max %d)", 102 102 skel->rodata->central_cpu, skel->rodata->nr_cpu_ids - 1); 103 103 CPU_FREE(cpuset);
+43
tools/testing/selftests/memfd/memfd_test.c
··· 282 282 return p; 283 283 } 284 284 285 + static void *mfd_assert_mmap_read_shared(int fd) 286 + { 287 + void *p; 288 + 289 + p = mmap(NULL, 290 + mfd_def_size, 291 + PROT_READ, 292 + MAP_SHARED, 293 + fd, 294 + 0); 295 + if (p == MAP_FAILED) { 296 + printf("mmap() failed: %m\n"); 297 + abort(); 298 + } 299 + 300 + return p; 301 + } 302 + 285 303 static void *mfd_assert_mmap_private(int fd) 286 304 { 287 305 void *p; ··· 998 980 close(fd); 999 981 } 1000 982 983 + static void test_seal_write_map_read_shared(void) 984 + { 985 + int fd; 986 + void *p; 987 + 988 + printf("%s SEAL-WRITE-MAP-READ\n", memfd_str); 989 + 990 + fd = mfd_assert_new("kern_memfd_seal_write_map_read", 991 + mfd_def_size, 992 + MFD_CLOEXEC | MFD_ALLOW_SEALING); 993 + 994 + mfd_assert_add_seals(fd, F_SEAL_WRITE); 995 + mfd_assert_has_seals(fd, F_SEAL_WRITE); 996 + 997 + p = mfd_assert_mmap_read_shared(fd); 998 + 999 + mfd_assert_read(fd); 1000 + mfd_assert_read_shared(fd); 1001 + mfd_fail_write(fd); 1002 + 1003 + munmap(p, mfd_def_size); 1004 + close(fd); 1005 + } 1006 + 1001 1007 /* 1002 1008 * Test SEAL_SHRINK 1003 1009 * Test whether SEAL_SHRINK actually prevents shrinking ··· 1635 1593 1636 1594 test_seal_write(); 1637 1595 test_seal_future_write(); 1596 + test_seal_write_map_read_shared(); 1638 1597 test_seal_shrink(); 1639 1598 test_seal_grow(); 1640 1599 test_seal_resize();
+1 -1
tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c
··· 20 20 * If we dispatch to a bogus DSQ that will fall back to the 21 21 * builtin global DSQ, we fail gracefully. 22 22 */ 23 - scx_bpf_dispatch_vtime(p, 0xcafef00d, SCX_SLICE_DFL, 23 + scx_bpf_dsq_insert_vtime(p, 0xcafef00d, SCX_SLICE_DFL, 24 24 p->scx.dsq_vtime, 0); 25 25 return cpu; 26 26 }
+2 -2
tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c
··· 17 17 18 18 if (cpu >= 0) { 19 19 /* Shouldn't be allowed to vtime dispatch to a builtin DSQ. */ 20 - scx_bpf_dispatch_vtime(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL, 21 - p->scx.dsq_vtime, 0); 20 + scx_bpf_dsq_insert_vtime(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL, 21 + p->scx.dsq_vtime, 0); 22 22 return cpu; 23 23 } 24 24
+5 -2
tools/testing/selftests/sched_ext/dsp_local_on.bpf.c
··· 43 43 if (!p) 44 44 return; 45 45 46 - target = bpf_get_prandom_u32() % nr_cpus; 46 + if (p->nr_cpus_allowed == nr_cpus) 47 + target = bpf_get_prandom_u32() % nr_cpus; 48 + else 49 + target = scx_bpf_task_cpu(p); 47 50 48 - scx_bpf_dispatch(p, SCX_DSQ_LOCAL_ON | target, SCX_SLICE_DFL, 0); 51 + scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL_ON | target, SCX_SLICE_DFL, 0); 49 52 bpf_task_release(p); 50 53 } 51 54
+3 -2
tools/testing/selftests/sched_ext/dsp_local_on.c
··· 34 34 /* Just sleeping is fine, plenty of scheduling events happening */ 35 35 sleep(1); 36 36 37 - SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_ERROR)); 38 37 bpf_link__destroy(link); 38 + 39 + SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_UNREG)); 39 40 40 41 return SCX_TEST_PASS; 41 42 } ··· 51 50 struct scx_test dsp_local_on = { 52 51 .name = "dsp_local_on", 53 52 .description = "Verify we can directly dispatch tasks to a local DSQs " 54 - "from osp.dispatch()", 53 + "from ops.dispatch()", 55 54 .setup = setup, 56 55 .run = run, 57 56 .cleanup = cleanup,
+1 -1
tools/testing/selftests/sched_ext/enq_select_cpu_fails.bpf.c
··· 31 31 /* Can only call from ops.select_cpu() */ 32 32 scx_bpf_select_cpu_dfl(p, 0, 0, &found); 33 33 34 - scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); 34 + scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); 35 35 } 36 36 37 37 SEC(".struct_ops.link")
+2 -2
tools/testing/selftests/sched_ext/exit.bpf.c
··· 33 33 if (exit_point == EXIT_ENQUEUE) 34 34 EXIT_CLEANLY(); 35 35 36 - scx_bpf_dispatch(p, DSQ_ID, SCX_SLICE_DFL, enq_flags); 36 + scx_bpf_dsq_insert(p, DSQ_ID, SCX_SLICE_DFL, enq_flags); 37 37 } 38 38 39 39 void BPF_STRUCT_OPS(exit_dispatch, s32 cpu, struct task_struct *p) ··· 41 41 if (exit_point == EXIT_DISPATCH) 42 42 EXIT_CLEANLY(); 43 43 44 - scx_bpf_consume(DSQ_ID); 44 + scx_bpf_dsq_move_to_local(DSQ_ID); 45 45 } 46 46 47 47 void BPF_STRUCT_OPS(exit_enable, struct task_struct *p)
+5 -3
tools/testing/selftests/sched_ext/maximal.bpf.c
··· 12 12 13 13 char _license[] SEC("license") = "GPL"; 14 14 15 + #define DSQ_ID 0 16 + 15 17 s32 BPF_STRUCT_OPS(maximal_select_cpu, struct task_struct *p, s32 prev_cpu, 16 18 u64 wake_flags) 17 19 { ··· 22 20 23 21 void BPF_STRUCT_OPS(maximal_enqueue, struct task_struct *p, u64 enq_flags) 24 22 { 25 - scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); 23 + scx_bpf_dsq_insert(p, DSQ_ID, SCX_SLICE_DFL, enq_flags); 26 24 } 27 25 28 26 void BPF_STRUCT_OPS(maximal_dequeue, struct task_struct *p, u64 deq_flags) ··· 30 28 31 29 void BPF_STRUCT_OPS(maximal_dispatch, s32 cpu, struct task_struct *prev) 32 30 { 33 - scx_bpf_consume(SCX_DSQ_GLOBAL); 31 + scx_bpf_dsq_move_to_local(DSQ_ID); 34 32 } 35 33 36 34 void BPF_STRUCT_OPS(maximal_runnable, struct task_struct *p, u64 enq_flags) ··· 125 123 126 124 s32 BPF_STRUCT_OPS_SLEEPABLE(maximal_init) 127 125 { 128 - return 0; 126 + return scx_bpf_create_dsq(DSQ_ID, -1); 129 127 } 130 128 131 129 void BPF_STRUCT_OPS(maximal_exit, struct scx_exit_info *info)
+1 -1
tools/testing/selftests/sched_ext/select_cpu_dfl.bpf.c
··· 30 30 } 31 31 scx_bpf_put_idle_cpumask(idle_mask); 32 32 33 - scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); 33 + scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); 34 34 } 35 35 36 36 SEC(".struct_ops.link")
+1 -1
tools/testing/selftests/sched_ext/select_cpu_dfl_nodispatch.bpf.c
··· 67 67 saw_local = true; 68 68 } 69 69 70 - scx_bpf_dispatch(p, dsq_id, SCX_SLICE_DFL, enq_flags); 70 + scx_bpf_dsq_insert(p, dsq_id, SCX_SLICE_DFL, enq_flags); 71 71 } 72 72 73 73 s32 BPF_STRUCT_OPS(select_cpu_dfl_nodispatch_init_task,
+1 -1
tools/testing/selftests/sched_ext/select_cpu_dispatch.bpf.c
··· 29 29 cpu = prev_cpu; 30 30 31 31 dispatch: 32 - scx_bpf_dispatch(p, dsq_id, SCX_SLICE_DFL, 0); 32 + scx_bpf_dsq_insert(p, dsq_id, SCX_SLICE_DFL, 0); 33 33 return cpu; 34 34 } 35 35
+1 -1
tools/testing/selftests/sched_ext/select_cpu_dispatch_bad_dsq.bpf.c
··· 18 18 s32 prev_cpu, u64 wake_flags) 19 19 { 20 20 /* Dispatching to a random DSQ should fail. */ 21 - scx_bpf_dispatch(p, 0xcafef00d, SCX_SLICE_DFL, 0); 21 + scx_bpf_dsq_insert(p, 0xcafef00d, SCX_SLICE_DFL, 0); 22 22 23 23 return prev_cpu; 24 24 }
+2 -2
tools/testing/selftests/sched_ext/select_cpu_dispatch_dbl_dsp.bpf.c
··· 18 18 s32 prev_cpu, u64 wake_flags) 19 19 { 20 20 /* Dispatching twice in a row is disallowed. */ 21 - scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0); 22 - scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0); 21 + scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0); 22 + scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0); 23 23 24 24 return prev_cpu; 25 25 }
+4 -4
tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c
··· 2 2 /* 3 3 * A scheduler that validates that enqueue flags are properly stored and 4 4 * applied at dispatch time when a task is directly dispatched from 5 - * ops.select_cpu(). We validate this by using scx_bpf_dispatch_vtime(), and 6 - * making the test a very basic vtime scheduler. 5 + * ops.select_cpu(). We validate this by using scx_bpf_dsq_insert_vtime(), 6 + * and making the test a very basic vtime scheduler. 7 7 * 8 8 * Copyright (c) 2024 Meta Platforms, Inc. and affiliates. 9 9 * Copyright (c) 2024 David Vernet <dvernet@meta.com> ··· 47 47 cpu = prev_cpu; 48 48 scx_bpf_test_and_clear_cpu_idle(cpu); 49 49 ddsp: 50 - scx_bpf_dispatch_vtime(p, VTIME_DSQ, SCX_SLICE_DFL, task_vtime(p), 0); 50 + scx_bpf_dsq_insert_vtime(p, VTIME_DSQ, SCX_SLICE_DFL, task_vtime(p), 0); 51 51 return cpu; 52 52 } 53 53 54 54 void BPF_STRUCT_OPS(select_cpu_vtime_dispatch, s32 cpu, struct task_struct *p) 55 55 { 56 - if (scx_bpf_consume(VTIME_DSQ)) 56 + if (scx_bpf_dsq_move_to_local(VTIME_DSQ)) 57 57 consumed = true; 58 58 } 59 59
+2 -2
tools/testing/selftests/tc-testing/tc-tests/filters/flow.json
··· 78 78 "setup": [ 79 79 "$TC qdisc add dev $DEV1 ingress" 80 80 ], 81 - "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 prio 1 protocol ip flow map key dst rshift 0xff", 81 + "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 prio 1 protocol ip flow map key dst rshift 0x1f", 82 82 "expExitCode": "0", 83 83 "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 1 flow", 84 - "matchPattern": "filter parent ffff: protocol ip pref 1 flow chain [0-9]+ handle 0x1 map keys dst rshift 255 baseclass", 84 + "matchPattern": "filter parent ffff: protocol ip pref 1 flow chain [0-9]+ handle 0x1 map keys dst rshift 31 baseclass", 85 85 "matchCount": "1", 86 86 "teardown": [ 87 87 "$TC qdisc del dev $DEV1 ingress"