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

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

Cross-merge networking fixes after downstream PR (net-6.12-rc4).

Conflicts:

107a034d5c1e ("net/mlx5: qos: Store rate groups in a qos domain")
1da9cfd6c41c ("net/mlx5: Unregister notifier on eswitch init failure")

Signed-off-by: Paolo Abeni <pabeni@redhat.com>

+2954 -1595
+3
.mailmap
··· 210 210 Fenglin Wu <quic_fenglinw@quicinc.com> <fenglinw@codeaurora.org> 211 211 Filipe Lautert <filipe@icewall.org> 212 212 Finn Thain <fthain@linux-m68k.org> <fthain@telegraphics.com.au> 213 + Fiona Behrens <me@kloenk.dev> 214 + Fiona Behrens <me@kloenk.dev> <me@kloenk.de> 215 + Fiona Behrens <me@kloenk.dev> <fin@nyantec.com> 213 216 Franck Bui-Huu <vagabon.xyz@gmail.com> 214 217 Frank Rowand <frowand.list@gmail.com> <frank.rowand@am.sony.com> 215 218 Frank Rowand <frowand.list@gmail.com> <frank.rowand@sony.com>
+54
Documentation/devicetree/bindings/display/elgin,jg10309-01.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/display/elgin,jg10309-01.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Elgin JG10309-01 SPI-controlled display 8 + 9 + maintainers: 10 + - Fabio Estevam <festevam@gmail.com> 11 + 12 + description: | 13 + The Elgin JG10309-01 SPI-controlled display is used on the RV1108-Elgin-r1 14 + board and is a custom display. 15 + 16 + allOf: 17 + - $ref: /schemas/spi/spi-peripheral-props.yaml# 18 + 19 + properties: 20 + compatible: 21 + const: elgin,jg10309-01 22 + 23 + reg: 24 + maxItems: 1 25 + 26 + spi-max-frequency: 27 + maximum: 24000000 28 + 29 + spi-cpha: true 30 + 31 + spi-cpol: true 32 + 33 + required: 34 + - compatible 35 + - reg 36 + - spi-cpha 37 + - spi-cpol 38 + 39 + additionalProperties: false 40 + 41 + examples: 42 + - | 43 + spi { 44 + #address-cells = <1>; 45 + #size-cells = <0>; 46 + 47 + display@0 { 48 + compatible = "elgin,jg10309-01"; 49 + reg = <0>; 50 + spi-max-frequency = <24000000>; 51 + spi-cpha; 52 + spi-cpol; 53 + }; 54 + };
+23 -3
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.yaml
··· 82 82 enum: 83 83 - fsl,ls1043a-extirq 84 84 - fsl,ls1046a-extirq 85 - - fsl,ls1088a-extirq 86 - - fsl,ls2080a-extirq 87 - - fsl,lx2160a-extirq 88 85 then: 89 86 properties: 90 87 interrupt-map: 91 88 minItems: 12 92 89 maxItems: 12 90 + interrupt-map-mask: 91 + items: 92 + - const: 0xf 93 + - const: 0 94 + 95 + - if: 96 + properties: 97 + compatible: 98 + contains: 99 + enum: 100 + - fsl,ls1088a-extirq 101 + - fsl,ls2080a-extirq 102 + - fsl,lx2160a-extirq 103 + # The driver(drivers/irqchip/irq-ls-extirq.c) have not use standard DT 104 + # function to parser interrupt-map. So it doesn't consider '#address-size' 105 + # in parent interrupt controller, such as GIC. 106 + # 107 + # When dt-binding verify interrupt-map, item data matrix is spitted at 108 + # incorrect position. Remove interrupt-map restriction because it always 109 + # wrong. 110 + 111 + then: 112 + properties: 93 113 interrupt-map-mask: 94 114 items: 95 115 - const: 0xf
+1 -1
Documentation/devicetree/bindings/misc/fsl,qoriq-mc.yaml
··· 113 113 114 114 msi-parent: 115 115 deprecated: true 116 - $ref: /schemas/types.yaml#/definitions/phandle 116 + maxItems: 1 117 117 description: 118 118 Describes the MSI controller node handling message 119 119 interrupts for the MC. When there is no translation
+1
Documentation/devicetree/bindings/net/brcm,unimac-mdio.yaml
··· 26 26 - brcm,asp-v2.1-mdio 27 27 - brcm,asp-v2.2-mdio 28 28 - brcm,unimac-mdio 29 + - brcm,bcm6846-mdio 29 30 30 31 reg: 31 32 minItems: 1
-2
Documentation/devicetree/bindings/trivial-devices.yaml
··· 101 101 - domintech,dmard09 102 102 # DMARD10: 3-axis Accelerometer 103 103 - domintech,dmard10 104 - # Elgin SPI-controlled LCD 105 - - elgin,jg10309-01 106 104 # MMA7660FC: 3-Axis Orientation/Motion Detection Sensor 107 105 - fsl,mma7660 108 106 # MMA8450Q: Xtrinsic Low-power, 3-axis Xtrinsic Accelerometer
+1 -6
MAINTAINERS
··· 12944 12944 M: Viresh Kumar <vireshk@kernel.org> 12945 12945 L: linux-ide@vger.kernel.org 12946 12946 S: Maintained 12947 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git 12948 12947 F: drivers/ata/pata_arasan_cf.c 12949 12948 F: include/linux/pata_arasan_cf_data.h 12950 12949 ··· 12957 12958 M: Linus Walleij <linus.walleij@linaro.org> 12958 12959 L: linux-ide@vger.kernel.org 12959 12960 S: Maintained 12960 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git 12961 12961 F: drivers/ata/pata_ftide010.c 12962 12962 F: drivers/ata/sata_gemini.c 12963 12963 F: drivers/ata/sata_gemini.h 12964 12964 12965 12965 LIBATA SATA AHCI PLATFORM devices support 12966 12966 M: Hans de Goede <hdegoede@redhat.com> 12967 - M: Jens Axboe <axboe@kernel.dk> 12968 12967 L: linux-ide@vger.kernel.org 12969 12968 S: Maintained 12970 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git 12971 12969 F: drivers/ata/ahci_platform.c 12972 12970 F: drivers/ata/libahci_platform.c 12973 12971 F: include/linux/ahci_platform.h ··· 12973 12977 M: Serge Semin <fancer.lancer@gmail.com> 12974 12978 L: linux-ide@vger.kernel.org 12975 12979 S: Maintained 12976 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata.git 12977 12980 F: Documentation/devicetree/bindings/ata/baikal,bt1-ahci.yaml 12978 12981 F: Documentation/devicetree/bindings/ata/snps,dwc-ahci.yaml 12979 12982 F: drivers/ata/ahci_dwc.c ··· 12981 12986 M: Mikael Pettersson <mikpelinux@gmail.com> 12982 12987 L: linux-ide@vger.kernel.org 12983 12988 S: Maintained 12984 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git 12985 12989 F: drivers/ata/sata_promise.* 12986 12990 12987 12991 LIBATA SUBSYSTEM (Serial and Parallel ATA drivers) ··· 16086 16092 F: net/core/drop_monitor.c 16087 16093 16088 16094 NETWORKING DRIVERS 16095 + M: Andrew Lunn <andrew+netdev@lunn.ch> 16089 16096 M: "David S. Miller" <davem@davemloft.net> 16090 16097 M: Eric Dumazet <edumazet@google.com> 16091 16098 M: Jakub Kicinski <kuba@kernel.org>
+1 -1
Makefile
··· 2 2 VERSION = 6 3 3 PATCHLEVEL = 12 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc2 5 + EXTRAVERSION = -rc3 6 6 NAME = Baby Opossum Posse 7 7 8 8 # *DOCUMENTATION*
+1
arch/powerpc/kernel/head_8xx.S
··· 494 494 bctr /* jump into table */ 495 495 152: 496 496 mfdar r11 497 + mtdar r10 497 498 mtctr r11 /* restore ctr reg from DAR */ 498 499 mfspr r11, SPRN_SPRG_THREAD 499 500 stw r10, DAR(r11)
+4
arch/x86/xen/enlighten_pv.c
··· 1032 1032 switch (msr) { 1033 1033 case MSR_IA32_APICBASE: 1034 1034 val &= ~X2APIC_ENABLE; 1035 + if (smp_processor_id() == 0) 1036 + val |= MSR_IA32_APICBASE_BSP; 1037 + else 1038 + val &= ~MSR_IA32_APICBASE_BSP; 1035 1039 break; 1036 1040 } 1037 1041 return val;
+1 -1
crypto/algapi.c
··· 373 373 q->cra_flags |= CRYPTO_ALG_DEAD; 374 374 alg = test->adult; 375 375 376 - if (list_empty(&alg->cra_list)) 376 + if (crypto_is_dead(alg)) 377 377 goto complete; 378 378 379 379 if (err == -ECANCELED)
+11 -12
crypto/testmgr.c
··· 1940 1940 atfm = crypto_alloc_ahash(driver, type, mask); 1941 1941 if (IS_ERR(atfm)) { 1942 1942 if (PTR_ERR(atfm) == -ENOENT) 1943 - return -ENOENT; 1943 + return 0; 1944 1944 pr_err("alg: hash: failed to allocate transform for %s: %ld\n", 1945 1945 driver, PTR_ERR(atfm)); 1946 1946 return PTR_ERR(atfm); ··· 2706 2706 tfm = crypto_alloc_aead(driver, type, mask); 2707 2707 if (IS_ERR(tfm)) { 2708 2708 if (PTR_ERR(tfm) == -ENOENT) 2709 - return -ENOENT; 2709 + return 0; 2710 2710 pr_err("alg: aead: failed to allocate transform for %s: %ld\n", 2711 2711 driver, PTR_ERR(tfm)); 2712 2712 return PTR_ERR(tfm); ··· 3285 3285 tfm = crypto_alloc_skcipher(driver, type, mask); 3286 3286 if (IS_ERR(tfm)) { 3287 3287 if (PTR_ERR(tfm) == -ENOENT) 3288 - return -ENOENT; 3288 + return 0; 3289 3289 pr_err("alg: skcipher: failed to allocate transform for %s: %ld\n", 3290 3290 driver, PTR_ERR(tfm)); 3291 3291 return PTR_ERR(tfm); ··· 3700 3700 tfm = crypto_alloc_cipher(driver, type, mask); 3701 3701 if (IS_ERR(tfm)) { 3702 3702 if (PTR_ERR(tfm) == -ENOENT) 3703 - return -ENOENT; 3703 + return 0; 3704 3704 printk(KERN_ERR "alg: cipher: Failed to load transform for " 3705 3705 "%s: %ld\n", driver, PTR_ERR(tfm)); 3706 3706 return PTR_ERR(tfm); ··· 3726 3726 acomp = crypto_alloc_acomp(driver, type, mask); 3727 3727 if (IS_ERR(acomp)) { 3728 3728 if (PTR_ERR(acomp) == -ENOENT) 3729 - return -ENOENT; 3729 + return 0; 3730 3730 pr_err("alg: acomp: Failed to load transform for %s: %ld\n", 3731 3731 driver, PTR_ERR(acomp)); 3732 3732 return PTR_ERR(acomp); ··· 3740 3740 comp = crypto_alloc_comp(driver, type, mask); 3741 3741 if (IS_ERR(comp)) { 3742 3742 if (PTR_ERR(comp) == -ENOENT) 3743 - return -ENOENT; 3743 + return 0; 3744 3744 pr_err("alg: comp: Failed to load transform for %s: %ld\n", 3745 3745 driver, PTR_ERR(comp)); 3746 3746 return PTR_ERR(comp); ··· 3818 3818 rng = crypto_alloc_rng(driver, type, mask); 3819 3819 if (IS_ERR(rng)) { 3820 3820 if (PTR_ERR(rng) == -ENOENT) 3821 - return -ENOENT; 3821 + return 0; 3822 3822 printk(KERN_ERR "alg: cprng: Failed to load transform for %s: " 3823 3823 "%ld\n", driver, PTR_ERR(rng)); 3824 3824 return PTR_ERR(rng); ··· 3846 3846 3847 3847 drng = crypto_alloc_rng(driver, type, mask); 3848 3848 if (IS_ERR(drng)) { 3849 + kfree_sensitive(buf); 3849 3850 if (PTR_ERR(drng) == -ENOENT) 3850 - goto out_no_rng; 3851 + return 0; 3851 3852 printk(KERN_ERR "alg: drbg: could not allocate DRNG handle for " 3852 3853 "%s\n", driver); 3853 - out_no_rng: 3854 - kfree_sensitive(buf); 3855 3854 return PTR_ERR(drng); 3856 3855 } 3857 3856 ··· 4094 4095 tfm = crypto_alloc_kpp(driver, type, mask); 4095 4096 if (IS_ERR(tfm)) { 4096 4097 if (PTR_ERR(tfm) == -ENOENT) 4097 - return -ENOENT; 4098 + return 0; 4098 4099 pr_err("alg: kpp: Failed to load tfm for %s: %ld\n", 4099 4100 driver, PTR_ERR(tfm)); 4100 4101 return PTR_ERR(tfm); ··· 4324 4325 tfm = crypto_alloc_akcipher(driver, type, mask); 4325 4326 if (IS_ERR(tfm)) { 4326 4327 if (PTR_ERR(tfm) == -ENOENT) 4327 - return -ENOENT; 4328 + return 0; 4328 4329 pr_err("alg: akcipher: Failed to load tfm for %s: %ld\n", 4329 4330 driver, PTR_ERR(tfm)); 4330 4331 return PTR_ERR(tfm);
+10 -66
drivers/acpi/resource.c
··· 448 448 }, 449 449 }, 450 450 { 451 - /* Asus ExpertBook B1402CBA */ 451 + /* Asus ExpertBook B1402C* */ 452 452 .matches = { 453 453 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 454 - DMI_MATCH(DMI_BOARD_NAME, "B1402CBA"), 454 + DMI_MATCH(DMI_BOARD_NAME, "B1402C"), 455 455 }, 456 456 }, 457 457 { 458 - /* Asus ExpertBook B1402CVA */ 458 + /* Asus ExpertBook B1502C* */ 459 459 .matches = { 460 460 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 461 - DMI_MATCH(DMI_BOARD_NAME, "B1402CVA"), 461 + DMI_MATCH(DMI_BOARD_NAME, "B1502C"), 462 462 }, 463 463 }, 464 464 { 465 - /* Asus ExpertBook B1502CBA */ 465 + /* Asus ExpertBook B2402 (B2402CBA / B2402FBA / B2402CVA / B2402FVA) */ 466 466 .matches = { 467 467 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 468 - DMI_MATCH(DMI_BOARD_NAME, "B1502CBA"), 468 + DMI_MATCH(DMI_BOARD_NAME, "B2402"), 469 469 }, 470 470 }, 471 471 { 472 - /* Asus ExpertBook B1502CGA */ 472 + /* Asus ExpertBook B2502 (B2502CBA / B2502FBA / B2502CVA / B2502FVA) */ 473 473 .matches = { 474 474 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 475 - DMI_MATCH(DMI_BOARD_NAME, "B1502CGA"), 476 - }, 477 - }, 478 - { 479 - /* Asus ExpertBook B1502CVA */ 480 - .matches = { 481 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 482 - DMI_MATCH(DMI_BOARD_NAME, "B1502CVA"), 483 - }, 484 - }, 485 - { 486 - /* Asus ExpertBook B2402CBA */ 487 - .matches = { 488 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 489 - DMI_MATCH(DMI_BOARD_NAME, "B2402CBA"), 490 - }, 491 - }, 492 - { 493 - /* Asus ExpertBook B2402FBA */ 494 - .matches = { 495 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 496 - DMI_MATCH(DMI_BOARD_NAME, "B2402FBA"), 497 - }, 498 - }, 499 - { 500 - /* Asus ExpertBook B2502 */ 501 - .matches = { 502 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 503 - DMI_MATCH(DMI_BOARD_NAME, "B2502CBA"), 504 - }, 505 - }, 506 - { 507 - /* Asus ExpertBook B2502FBA */ 508 - .matches = { 509 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 510 - DMI_MATCH(DMI_BOARD_NAME, "B2502FBA"), 511 - }, 512 - }, 513 - { 514 - /* Asus ExpertBook B2502CVA */ 515 - .matches = { 516 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 517 - DMI_MATCH(DMI_BOARD_NAME, "B2502CVA"), 475 + DMI_MATCH(DMI_BOARD_NAME, "B2502"), 518 476 }, 519 477 }, 520 478 { ··· 490 532 }, 491 533 }, 492 534 { 493 - /* Asus Vivobook Pro N6506MV */ 535 + /* Asus Vivobook Pro N6506M* */ 494 536 .matches = { 495 537 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 496 - DMI_MATCH(DMI_BOARD_NAME, "N6506MV"), 497 - }, 498 - }, 499 - { 500 - /* Asus Vivobook Pro N6506MU */ 501 - .matches = { 502 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 503 - DMI_MATCH(DMI_BOARD_NAME, "N6506MU"), 504 - }, 505 - }, 506 - { 507 - /* Asus Vivobook Pro N6506MJ */ 508 - .matches = { 509 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 510 - DMI_MATCH(DMI_BOARD_NAME, "N6506MJ"), 538 + DMI_MATCH(DMI_BOARD_NAME, "N6506M"), 511 539 }, 512 540 }, 513 541 {
+14 -4
drivers/ata/libata-eh.c
··· 4099 4099 4100 4100 WARN_ON(ap->pflags & ATA_PFLAG_SUSPENDED); 4101 4101 4102 - /* Set all devices attached to the port in standby mode */ 4103 - ata_for_each_link(link, ap, HOST_FIRST) { 4104 - ata_for_each_dev(dev, link, ENABLED) 4105 - ata_dev_power_set_standby(dev); 4102 + /* 4103 + * We will reach this point for all of the PM events: 4104 + * PM_EVENT_SUSPEND (if runtime pm, PM_EVENT_AUTO will also be set) 4105 + * PM_EVENT_FREEZE, and PM_EVENT_HIBERNATE. 4106 + * 4107 + * We do not want to perform disk spin down for PM_EVENT_FREEZE. 4108 + * (Spin down will be performed by the subsequent PM_EVENT_HIBERNATE.) 4109 + */ 4110 + if (!(ap->pm_mesg.event & PM_EVENT_FREEZE)) { 4111 + /* Set all devices attached to the port in standby mode */ 4112 + ata_for_each_link(link, ap, HOST_FIRST) { 4113 + ata_for_each_dev(dev, link, ENABLED) 4114 + ata_dev_power_set_standby(dev); 4115 + } 4106 4116 } 4107 4117 4108 4118 /*
+15 -10
drivers/base/power/common.c
··· 195 195 struct device *pd_dev = NULL; 196 196 int ret, i, num_pds = 0; 197 197 bool by_id = true; 198 + size_t size; 198 199 u32 pd_flags = data ? data->pd_flags : 0; 199 200 u32 link_flags = pd_flags & PD_FLAG_NO_DEV_LINK ? 0 : 200 201 DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME; ··· 218 217 if (num_pds <= 0) 219 218 return 0; 220 219 221 - pds = devm_kzalloc(dev, sizeof(*pds), GFP_KERNEL); 220 + pds = kzalloc(sizeof(*pds), GFP_KERNEL); 222 221 if (!pds) 223 222 return -ENOMEM; 224 223 225 - pds->pd_devs = devm_kcalloc(dev, num_pds, sizeof(*pds->pd_devs), 226 - GFP_KERNEL); 227 - if (!pds->pd_devs) 228 - return -ENOMEM; 229 - 230 - pds->pd_links = devm_kcalloc(dev, num_pds, sizeof(*pds->pd_links), 231 - GFP_KERNEL); 232 - if (!pds->pd_links) 233 - return -ENOMEM; 224 + size = sizeof(*pds->pd_devs) + sizeof(*pds->pd_links); 225 + pds->pd_devs = kcalloc(num_pds, size, GFP_KERNEL); 226 + if (!pds->pd_devs) { 227 + ret = -ENOMEM; 228 + goto free_pds; 229 + } 230 + pds->pd_links = (void *)(pds->pd_devs + num_pds); 234 231 235 232 if (link_flags && pd_flags & PD_FLAG_DEV_LINK_ON) 236 233 link_flags |= DL_FLAG_RPM_ACTIVE; ··· 271 272 device_link_del(pds->pd_links[i]); 272 273 dev_pm_domain_detach(pds->pd_devs[i], true); 273 274 } 275 + kfree(pds->pd_devs); 276 + free_pds: 277 + kfree(pds); 274 278 return ret; 275 279 } 276 280 EXPORT_SYMBOL_GPL(dev_pm_domain_attach_list); ··· 365 363 device_link_del(list->pd_links[i]); 366 364 dev_pm_domain_detach(list->pd_devs[i], true); 367 365 } 366 + 367 + kfree(list->pd_devs); 368 + kfree(list); 368 369 } 369 370 EXPORT_SYMBOL_GPL(dev_pm_domain_detach_list); 370 371
+6 -6
drivers/crypto/marvell/cesa/hash.c
··· 947 947 .base = { 948 948 .cra_name = "md5", 949 949 .cra_driver_name = "mv-md5", 950 - .cra_priority = 300, 950 + .cra_priority = 0, 951 951 .cra_flags = CRYPTO_ALG_ASYNC | 952 952 CRYPTO_ALG_ALLOCATES_MEMORY | 953 953 CRYPTO_ALG_KERN_DRIVER_ONLY, ··· 1018 1018 .base = { 1019 1019 .cra_name = "sha1", 1020 1020 .cra_driver_name = "mv-sha1", 1021 - .cra_priority = 300, 1021 + .cra_priority = 0, 1022 1022 .cra_flags = CRYPTO_ALG_ASYNC | 1023 1023 CRYPTO_ALG_ALLOCATES_MEMORY | 1024 1024 CRYPTO_ALG_KERN_DRIVER_ONLY, ··· 1092 1092 .base = { 1093 1093 .cra_name = "sha256", 1094 1094 .cra_driver_name = "mv-sha256", 1095 - .cra_priority = 300, 1095 + .cra_priority = 0, 1096 1096 .cra_flags = CRYPTO_ALG_ASYNC | 1097 1097 CRYPTO_ALG_ALLOCATES_MEMORY | 1098 1098 CRYPTO_ALG_KERN_DRIVER_ONLY, ··· 1302 1302 .base = { 1303 1303 .cra_name = "hmac(md5)", 1304 1304 .cra_driver_name = "mv-hmac-md5", 1305 - .cra_priority = 300, 1305 + .cra_priority = 0, 1306 1306 .cra_flags = CRYPTO_ALG_ASYNC | 1307 1307 CRYPTO_ALG_ALLOCATES_MEMORY | 1308 1308 CRYPTO_ALG_KERN_DRIVER_ONLY, ··· 1373 1373 .base = { 1374 1374 .cra_name = "hmac(sha1)", 1375 1375 .cra_driver_name = "mv-hmac-sha1", 1376 - .cra_priority = 300, 1376 + .cra_priority = 0, 1377 1377 .cra_flags = CRYPTO_ALG_ASYNC | 1378 1378 CRYPTO_ALG_ALLOCATES_MEMORY | 1379 1379 CRYPTO_ALG_KERN_DRIVER_ONLY, ··· 1444 1444 .base = { 1445 1445 .cra_name = "hmac(sha256)", 1446 1446 .cra_driver_name = "mv-hmac-sha256", 1447 - .cra_priority = 300, 1447 + .cra_priority = 0, 1448 1448 .cra_flags = CRYPTO_ALG_ASYNC | 1449 1449 CRYPTO_ALG_ALLOCATES_MEMORY | 1450 1450 CRYPTO_ALG_KERN_DRIVER_ONLY,
+3 -1
drivers/gpio/gpio-aspeed.c
··· 406 406 gpio->dcache[GPIO_BANK(offset)] = reg; 407 407 408 408 iowrite32(reg, addr); 409 + /* Flush write */ 410 + ioread32(addr); 409 411 } 410 412 411 413 static void aspeed_gpio_set(struct gpio_chip *gc, unsigned int offset, ··· 1193 1191 if (!gpio_id) 1194 1192 return -EINVAL; 1195 1193 1196 - gpio->clk = of_clk_get(pdev->dev.of_node, 0); 1194 + gpio->clk = devm_clk_get_enabled(&pdev->dev, NULL); 1197 1195 if (IS_ERR(gpio->clk)) { 1198 1196 dev_warn(&pdev->dev, 1199 1197 "Failed to get clock from devicetree, debouncing disabled\n");
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
··· 1439 1439 list_add_tail(&vm->vm_list_node, 1440 1440 &(vm->process_info->vm_list_head)); 1441 1441 vm->process_info->n_vms++; 1442 - 1443 - *ef = dma_fence_get(&vm->process_info->eviction_fence->base); 1442 + if (ef) 1443 + *ef = dma_fence_get(&vm->process_info->eviction_fence->base); 1444 1444 mutex_unlock(&vm->process_info->lock); 1445 1445 1446 1446 return 0;
+5 -2
drivers/gpu/drm/amd/amdkfd/kfd_process.c
··· 1702 1702 1703 1703 ret = amdgpu_amdkfd_gpuvm_acquire_process_vm(dev->adev, avm, 1704 1704 &p->kgd_process_info, 1705 - &ef); 1705 + p->ef ? NULL : &ef); 1706 1706 if (ret) { 1707 1707 dev_err(dev->adev->dev, "Failed to create process VM object\n"); 1708 1708 return ret; 1709 1709 } 1710 - RCU_INIT_POINTER(p->ef, ef); 1710 + 1711 + if (!p->ef) 1712 + RCU_INIT_POINTER(p->ef, ef); 1713 + 1711 1714 pdd->drm_priv = drm_file->private_data; 1712 1715 1713 1716 ret = kfd_process_device_reserve_ib_mem(pdd);
+4 -3
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 2972 2972 2973 2973 hpd_rx_irq_work_suspend(dm); 2974 2974 2975 - if (adev->dm.dc->caps.ips_support) 2976 - dc_allow_idle_optimizations(adev->dm.dc, true); 2977 - 2978 2975 dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3); 2976 + 2977 + if (dm->dc->caps.ips_support && adev->in_s0ix) 2978 + dc_allow_idle_optimizations(dm->dc, true); 2979 + 2979 2980 dc_dmub_srv_set_power_state(dm->dc->ctx->dmub_srv, DC_ACPI_CM_POWER_STATE_D3); 2980 2981 2981 2982 return 0;
+34 -11
drivers/gpu/drm/amd/display/dc/core/dc.c
··· 5065 5065 return true; 5066 5066 } 5067 5067 5068 + static void clear_update_flags(struct dc_surface_update *srf_updates, 5069 + int surface_count, struct dc_stream_state *stream) 5070 + { 5071 + int i; 5072 + 5073 + if (stream) 5074 + stream->update_flags.raw = 0; 5075 + 5076 + for (i = 0; i < surface_count; i++) 5077 + if (srf_updates[i].surface) 5078 + srf_updates[i].surface->update_flags.raw = 0; 5079 + } 5080 + 5068 5081 bool dc_update_planes_and_stream(struct dc *dc, 5069 5082 struct dc_surface_update *srf_updates, int surface_count, 5070 5083 struct dc_stream_state *stream, 5071 5084 struct dc_stream_update *stream_update) 5072 5085 { 5086 + bool ret = false; 5087 + 5073 5088 dc_exit_ips_for_hw_access(dc); 5074 5089 /* 5075 5090 * update planes and stream version 3 separates FULL and FAST updates ··· 5101 5086 * features as they are now transparent to the new sequence. 5102 5087 */ 5103 5088 if (dc->ctx->dce_version >= DCN_VERSION_4_01) 5104 - return update_planes_and_stream_v3(dc, srf_updates, 5089 + ret = update_planes_and_stream_v3(dc, srf_updates, 5105 5090 surface_count, stream, stream_update); 5106 - return update_planes_and_stream_v2(dc, srf_updates, 5091 + else 5092 + ret = update_planes_and_stream_v2(dc, srf_updates, 5107 5093 surface_count, stream, stream_update); 5094 + 5095 + if (ret) 5096 + clear_update_flags(srf_updates, surface_count, stream); 5097 + 5098 + return ret; 5108 5099 } 5109 5100 5110 5101 void dc_commit_updates_for_stream(struct dc *dc, ··· 5120 5099 struct dc_stream_update *stream_update, 5121 5100 struct dc_state *state) 5122 5101 { 5102 + bool ret = false; 5103 + 5123 5104 dc_exit_ips_for_hw_access(dc); 5124 5105 /* TODO: Since change commit sequence can have a huge impact, 5125 5106 * we decided to only enable it for DCN3x. However, as soon as ··· 5129 5106 * the new sequence for all ASICs. 5130 5107 */ 5131 5108 if (dc->ctx->dce_version >= DCN_VERSION_4_01) { 5132 - update_planes_and_stream_v3(dc, srf_updates, surface_count, 5109 + ret = update_planes_and_stream_v3(dc, srf_updates, surface_count, 5133 5110 stream, stream_update); 5134 - return; 5135 - } 5136 - if (dc->ctx->dce_version >= DCN_VERSION_3_2) { 5137 - update_planes_and_stream_v2(dc, srf_updates, surface_count, 5111 + } else if (dc->ctx->dce_version >= DCN_VERSION_3_2) { 5112 + ret = update_planes_and_stream_v2(dc, srf_updates, surface_count, 5138 5113 stream, stream_update); 5139 - return; 5140 - } 5141 - update_planes_and_stream_v1(dc, srf_updates, surface_count, stream, 5142 - stream_update, state); 5114 + } else 5115 + ret = update_planes_and_stream_v1(dc, srf_updates, surface_count, stream, 5116 + stream_update, state); 5117 + 5118 + if (ret) 5119 + clear_update_flags(srf_updates, surface_count, stream); 5143 5120 } 5144 5121 5145 5122 uint8_t dc_get_current_stream_count(struct dc *dc)
+13 -13
drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h
··· 60 60 61 61 struct vi_dpm_table { 62 62 uint32_t count; 63 - struct vi_dpm_level dpm_level[] __counted_by(count); 63 + struct vi_dpm_level dpm_level[]; 64 64 }; 65 65 66 66 #define PCIE_PERF_REQ_REMOVE_REGISTRY 0 ··· 91 91 92 92 struct phm_clock_array { 93 93 uint32_t count; 94 - uint32_t values[] __counted_by(count); 94 + uint32_t values[]; 95 95 }; 96 96 97 97 struct phm_clock_voltage_dependency_record { ··· 123 123 124 124 struct phm_clock_voltage_dependency_table { 125 125 uint32_t count; 126 - struct phm_clock_voltage_dependency_record entries[] __counted_by(count); 126 + struct phm_clock_voltage_dependency_record entries[]; 127 127 }; 128 128 129 129 struct phm_phase_shedding_limits_record { ··· 140 140 141 141 struct phm_uvd_clock_voltage_dependency_table { 142 142 uint8_t count; 143 - struct phm_uvd_clock_voltage_dependency_record entries[] __counted_by(count); 143 + struct phm_uvd_clock_voltage_dependency_record entries[]; 144 144 }; 145 145 146 146 struct phm_acp_clock_voltage_dependency_record { ··· 150 150 151 151 struct phm_acp_clock_voltage_dependency_table { 152 152 uint32_t count; 153 - struct phm_acp_clock_voltage_dependency_record entries[] __counted_by(count); 153 + struct phm_acp_clock_voltage_dependency_record entries[]; 154 154 }; 155 155 156 156 struct phm_vce_clock_voltage_dependency_record { ··· 161 161 162 162 struct phm_phase_shedding_limits_table { 163 163 uint32_t count; 164 - struct phm_phase_shedding_limits_record entries[] __counted_by(count); 164 + struct phm_phase_shedding_limits_record entries[]; 165 165 }; 166 166 167 167 struct phm_vceclock_voltage_dependency_table { 168 168 uint8_t count; 169 - struct phm_vceclock_voltage_dependency_record entries[] __counted_by(count); 169 + struct phm_vceclock_voltage_dependency_record entries[]; 170 170 }; 171 171 172 172 struct phm_uvdclock_voltage_dependency_table { 173 173 uint8_t count; 174 - struct phm_uvdclock_voltage_dependency_record entries[] __counted_by(count); 174 + struct phm_uvdclock_voltage_dependency_record entries[]; 175 175 }; 176 176 177 177 struct phm_samuclock_voltage_dependency_table { 178 178 uint8_t count; 179 - struct phm_samuclock_voltage_dependency_record entries[] __counted_by(count); 179 + struct phm_samuclock_voltage_dependency_record entries[]; 180 180 }; 181 181 182 182 struct phm_acpclock_voltage_dependency_table { 183 183 uint32_t count; 184 - struct phm_acpclock_voltage_dependency_record entries[] __counted_by(count); 184 + struct phm_acpclock_voltage_dependency_record entries[]; 185 185 }; 186 186 187 187 struct phm_vce_clock_voltage_dependency_table { 188 188 uint8_t count; 189 - struct phm_vce_clock_voltage_dependency_record entries[] __counted_by(count); 189 + struct phm_vce_clock_voltage_dependency_record entries[]; 190 190 }; 191 191 192 192 ··· 393 393 394 394 struct phm_cac_leakage_table { 395 395 uint32_t count; 396 - union phm_cac_leakage_record entries[] __counted_by(count); 396 + union phm_cac_leakage_record entries[]; 397 397 }; 398 398 399 399 struct phm_samu_clock_voltage_dependency_record { ··· 404 404 405 405 struct phm_samu_clock_voltage_dependency_table { 406 406 uint8_t count; 407 - struct phm_samu_clock_voltage_dependency_record entries[] __counted_by(count); 407 + struct phm_samu_clock_voltage_dependency_record entries[]; 408 408 }; 409 409 410 410 struct phm_cac_tdp_table {
+2 -1
drivers/gpu/drm/drm_fbdev_dma.c
··· 50 50 if (!fb_helper->dev) 51 51 return; 52 52 53 - fb_deferred_io_cleanup(info); 53 + if (info->fbdefio) 54 + fb_deferred_io_cleanup(info); 54 55 drm_fb_helper_fini(fb_helper); 55 56 56 57 drm_client_buffer_vunmap(fb_helper->buffer);
+7 -3
drivers/gpu/drm/i915/display/intel_hdcp.c
··· 1094 1094 hdcp->value = value; 1095 1095 if (update_property) { 1096 1096 drm_connector_get(&connector->base); 1097 - queue_work(i915->unordered_wq, &hdcp->prop_work); 1097 + if (!queue_work(i915->unordered_wq, &hdcp->prop_work)) 1098 + drm_connector_put(&connector->base); 1098 1099 } 1099 1100 } 1100 1101 ··· 2525 2524 mutex_lock(&hdcp->mutex); 2526 2525 hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED; 2527 2526 drm_connector_get(&connector->base); 2528 - queue_work(i915->unordered_wq, &hdcp->prop_work); 2527 + if (!queue_work(i915->unordered_wq, &hdcp->prop_work)) 2528 + drm_connector_put(&connector->base); 2529 2529 mutex_unlock(&hdcp->mutex); 2530 2530 } 2531 2531 ··· 2543 2541 */ 2544 2542 if (!desired_and_not_enabled && !content_protection_type_changed) { 2545 2543 drm_connector_get(&connector->base); 2546 - queue_work(i915->unordered_wq, &hdcp->prop_work); 2544 + if (!queue_work(i915->unordered_wq, &hdcp->prop_work)) 2545 + drm_connector_put(&connector->base); 2546 + 2547 2547 } 2548 2548 } 2549 2549
+1 -1
drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h
··· 210 210 } *rm; 211 211 212 212 struct { 213 - struct mutex mutex;; 213 + struct mutex mutex; 214 214 struct idr idr; 215 215 } client_id; 216 216
+1 -1
drivers/gpu/drm/nouveau/nouveau_dmem.c
··· 193 193 if (!spage || !(src & MIGRATE_PFN_MIGRATE)) 194 194 goto done; 195 195 196 - dpage = alloc_page_vma(GFP_HIGHUSER, vmf->vma, vmf->address); 196 + dpage = alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vmf->vma, vmf->address); 197 197 if (!dpage) 198 198 goto done; 199 199
+1 -1
drivers/gpu/drm/nouveau/nouveau_drm.c
··· 331 331 return; 332 332 } 333 333 334 - ret = nouveau_channel_new(&drm->client, false, runm, NvDmaFB, NvDmaTT, &drm->cechan); 334 + ret = nouveau_channel_new(&drm->client, true, runm, NvDmaFB, NvDmaTT, &drm->cechan); 335 335 if (ret) 336 336 NV_ERROR(drm, "failed to create ce channel, %d\n", ret); 337 337 }
+2 -7
drivers/gpu/drm/radeon/atombios_dp.c
··· 228 228 { 229 229 struct drm_device *dev = radeon_connector->base.dev; 230 230 struct radeon_device *rdev = dev->dev_private; 231 - int ret; 232 231 233 232 radeon_connector->ddc_bus->rec.hpd = radeon_connector->hpd.hpd; 234 - radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev; 235 233 radeon_connector->ddc_bus->aux.drm_dev = radeon_connector->base.dev; 236 234 if (ASIC_IS_DCE5(rdev)) { 237 235 if (radeon_auxch) ··· 240 242 radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer_atom; 241 243 } 242 244 243 - ret = drm_dp_aux_register(&radeon_connector->ddc_bus->aux); 244 - if (!ret) 245 - radeon_connector->ddc_bus->has_aux = true; 246 - 247 - WARN(ret, "drm_dp_aux_register() failed with error %d\n", ret); 245 + drm_dp_aux_init(&radeon_connector->ddc_bus->aux); 246 + radeon_connector->ddc_bus->has_aux = true; 248 247 } 249 248 250 249 /***** general DP utility functions *****/
+17
drivers/gpu/drm/radeon/radeon_connectors.c
··· 1786 1786 return MODE_OK; 1787 1787 } 1788 1788 1789 + static int 1790 + radeon_connector_late_register(struct drm_connector *connector) 1791 + { 1792 + struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1793 + int r = 0; 1794 + 1795 + if (radeon_connector->ddc_bus->has_aux) { 1796 + radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev; 1797 + r = drm_dp_aux_register(&radeon_connector->ddc_bus->aux); 1798 + } 1799 + 1800 + return r; 1801 + } 1802 + 1789 1803 static const struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = { 1790 1804 .get_modes = radeon_dp_get_modes, 1791 1805 .mode_valid = radeon_dp_mode_valid, ··· 1814 1800 .early_unregister = radeon_connector_unregister, 1815 1801 .destroy = radeon_connector_destroy, 1816 1802 .force = radeon_dvi_force, 1803 + .late_register = radeon_connector_late_register, 1817 1804 }; 1818 1805 1819 1806 static const struct drm_connector_funcs radeon_edp_connector_funcs = { ··· 1825 1810 .early_unregister = radeon_connector_unregister, 1826 1811 .destroy = radeon_connector_destroy, 1827 1812 .force = radeon_dvi_force, 1813 + .late_register = radeon_connector_late_register, 1828 1814 }; 1829 1815 1830 1816 static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs = { ··· 1836 1820 .early_unregister = radeon_connector_unregister, 1837 1821 .destroy = radeon_connector_destroy, 1838 1822 .force = radeon_dvi_force, 1823 + .late_register = radeon_connector_late_register, 1839 1824 }; 1840 1825 1841 1826 void
-3
drivers/gpu/drm/radeon/radeon_gem.c
··· 44 44 int radeon_gem_prime_pin(struct drm_gem_object *obj); 45 45 void radeon_gem_prime_unpin(struct drm_gem_object *obj); 46 46 47 - const struct drm_gem_object_funcs radeon_gem_object_funcs; 48 - 49 47 static vm_fault_t radeon_gem_fault(struct vm_fault *vmf) 50 48 { 51 49 struct ttm_buffer_object *bo = vmf->vma->vm_private_data; ··· 130 132 return r; 131 133 } 132 134 *obj = &robj->tbo.base; 133 - (*obj)->funcs = &radeon_gem_object_funcs; 134 135 robj->pid = task_pid_nr(current); 135 136 136 137 mutex_lock(&rdev->gem.mutex);
+1
drivers/gpu/drm/radeon/radeon_object.c
··· 151 151 if (bo == NULL) 152 152 return -ENOMEM; 153 153 drm_gem_private_object_init(rdev_to_drm(rdev), &bo->tbo.base, size); 154 + bo->tbo.base.funcs = &radeon_gem_object_funcs; 154 155 bo->rdev = rdev; 155 156 bo->surface_reg = -1; 156 157 INIT_LIST_HEAD(&bo->list);
+11
drivers/gpu/drm/scheduler/sched_main.c
··· 87 87 #define CREATE_TRACE_POINTS 88 88 #include "gpu_scheduler_trace.h" 89 89 90 + #ifdef CONFIG_LOCKDEP 91 + static struct lockdep_map drm_sched_lockdep_map = { 92 + .name = "drm_sched_lockdep_map" 93 + }; 94 + #endif 95 + 90 96 #define to_drm_sched_job(sched_job) \ 91 97 container_of((sched_job), struct drm_sched_job, queue_node) 92 98 ··· 1275 1269 sched->submit_wq = submit_wq; 1276 1270 sched->own_submit_wq = false; 1277 1271 } else { 1272 + #ifdef CONFIG_LOCKDEP 1273 + sched->submit_wq = alloc_ordered_workqueue_lockdep_map(name, 0, 1274 + &drm_sched_lockdep_map); 1275 + #else 1278 1276 sched->submit_wq = alloc_ordered_workqueue(name, 0); 1277 + #endif 1279 1278 if (!sched->submit_wq) 1280 1279 return -ENOMEM; 1281 1280
+33 -13
drivers/gpu/drm/tegra/gr3d.c
··· 46 46 unsigned int nclocks; 47 47 struct reset_control_bulk_data resets[RST_GR3D_MAX]; 48 48 unsigned int nresets; 49 - struct dev_pm_domain_list *pd_list; 50 49 51 50 DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS); 52 51 }; ··· 369 370 return 0; 370 371 } 371 372 373 + static void gr3d_del_link(void *link) 374 + { 375 + device_link_del(link); 376 + } 377 + 372 378 static int gr3d_init_power(struct device *dev, struct gr3d *gr3d) 373 379 { 374 - struct dev_pm_domain_attach_data pd_data = { 375 - .pd_names = (const char *[]) { "3d0", "3d1" }, 376 - .num_pd_names = 2, 377 - }; 380 + static const char * const opp_genpd_names[] = { "3d0", "3d1", NULL }; 381 + const u32 link_flags = DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME; 382 + struct device **opp_virt_devs, *pd_dev; 383 + struct device_link *link; 384 + unsigned int i; 378 385 int err; 379 386 380 387 err = of_count_phandle_with_args(dev->of_node, "power-domains", ··· 414 409 if (dev->pm_domain) 415 410 return 0; 416 411 417 - err = dev_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list); 418 - if (err < 0) 412 + err = devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs); 413 + if (err) 419 414 return err; 415 + 416 + for (i = 0; opp_genpd_names[i]; i++) { 417 + pd_dev = opp_virt_devs[i]; 418 + if (!pd_dev) { 419 + dev_err(dev, "failed to get %s power domain\n", 420 + opp_genpd_names[i]); 421 + return -EINVAL; 422 + } 423 + 424 + link = device_link_add(dev, pd_dev, link_flags); 425 + if (!link) { 426 + dev_err(dev, "failed to link to %s\n", dev_name(pd_dev)); 427 + return -EINVAL; 428 + } 429 + 430 + err = devm_add_action_or_reset(dev, gr3d_del_link, link); 431 + if (err) 432 + return err; 433 + } 420 434 421 435 return 0; 422 436 } ··· 527 503 528 504 err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); 529 505 if (err) 530 - goto err; 506 + return err; 531 507 532 508 err = host1x_client_register(&gr3d->client.base); 533 509 if (err < 0) { 534 510 dev_err(&pdev->dev, "failed to register host1x client: %d\n", 535 511 err); 536 - goto err; 512 + return err; 537 513 } 538 514 539 515 /* initialize address register map */ ··· 541 517 set_bit(gr3d_addr_regs[i], gr3d->addr_regs); 542 518 543 519 return 0; 544 - err: 545 - dev_pm_domain_detach_list(gr3d->pd_list); 546 - return err; 547 520 } 548 521 549 522 static void gr3d_remove(struct platform_device *pdev) ··· 549 528 550 529 pm_runtime_disable(&pdev->dev); 551 530 host1x_client_unregister(&gr3d->client.base); 552 - dev_pm_domain_detach_list(gr3d->pd_list); 553 531 } 554 532 555 533 static int __maybe_unused gr3d_runtime_suspend(struct device *dev)
+8 -1
drivers/gpu/drm/v3d/v3d_perfmon.c
··· 306 306 static int v3d_perfmon_idr_del(int id, void *elem, void *data) 307 307 { 308 308 struct v3d_perfmon *perfmon = elem; 309 + struct v3d_dev *v3d = (struct v3d_dev *)data; 310 + 311 + /* If the active perfmon is being destroyed, stop it first */ 312 + if (perfmon == v3d->active_perfmon) 313 + v3d_perfmon_stop(v3d, perfmon, false); 309 314 310 315 v3d_perfmon_put(perfmon); 311 316 ··· 319 314 320 315 void v3d_perfmon_close_file(struct v3d_file_priv *v3d_priv) 321 316 { 317 + struct v3d_dev *v3d = v3d_priv->v3d; 318 + 322 319 mutex_lock(&v3d_priv->perfmon.lock); 323 - idr_for_each(&v3d_priv->perfmon.idr, v3d_perfmon_idr_del, NULL); 320 + idr_for_each(&v3d_priv->perfmon.idr, v3d_perfmon_idr_del, v3d); 324 321 idr_destroy(&v3d_priv->perfmon.idr); 325 322 mutex_unlock(&v3d_priv->perfmon.lock); 326 323 mutex_destroy(&v3d_priv->perfmon.lock);
+6 -1
drivers/gpu/drm/vc4/vc4_perfmon.c
··· 116 116 static int vc4_perfmon_idr_del(int id, void *elem, void *data) 117 117 { 118 118 struct vc4_perfmon *perfmon = elem; 119 + struct vc4_dev *vc4 = (struct vc4_dev *)data; 120 + 121 + /* If the active perfmon is being destroyed, stop it first */ 122 + if (perfmon == vc4->active_perfmon) 123 + vc4_perfmon_stop(vc4, perfmon, false); 119 124 120 125 vc4_perfmon_put(perfmon); 121 126 ··· 135 130 return; 136 131 137 132 mutex_lock(&vc4file->perfmon.lock); 138 - idr_for_each(&vc4file->perfmon.idr, vc4_perfmon_idr_del, NULL); 133 + idr_for_each(&vc4file->perfmon.idr, vc4_perfmon_idr_del, vc4); 139 134 idr_destroy(&vc4file->perfmon.idr); 140 135 mutex_unlock(&vc4file->perfmon.lock); 141 136 mutex_destroy(&vc4file->perfmon.lock);
+1 -1
drivers/gpu/drm/xe/xe_debugfs.c
··· 187 187 debugfs_create_file("forcewake_all", 0400, root, xe, 188 188 &forcewake_all_fops); 189 189 190 - debugfs_create_file("wedged_mode", 0400, root, xe, 190 + debugfs_create_file("wedged_mode", 0600, root, xe, 191 191 &wedged_mode_fops); 192 192 193 193 for (mem_type = XE_PL_VRAM0; mem_type <= XE_PL_VRAM1; ++mem_type) {
+3 -1
drivers/gpu/drm/xe/xe_gt.c
··· 874 874 int ret = 0; 875 875 876 876 if ((!xe_uc_fw_is_available(&gt->uc.gsc.fw) || 877 - xe_uc_fw_is_loaded(&gt->uc.gsc.fw)) && XE_WA(gt, 22019338487)) 877 + xe_uc_fw_is_loaded(&gt->uc.gsc.fw) || 878 + xe_uc_fw_is_in_error_state(&gt->uc.gsc.fw)) && 879 + XE_WA(gt, 22019338487)) 878 880 ret = xe_guc_pc_restore_stashed_freq(&gt->uc.guc.pc); 879 881 880 882 return ret;
+26 -18
drivers/gpu/drm/xe/xe_guc_ct.c
··· 667 667 num_g2h = 1; 668 668 669 669 if (g2h_fence_needs_alloc(g2h_fence)) { 670 - void *ptr; 671 - 672 670 g2h_fence->seqno = next_ct_seqno(ct, true); 673 - ptr = xa_store(&ct->fence_lookup, 674 - g2h_fence->seqno, 675 - g2h_fence, GFP_ATOMIC); 676 - if (IS_ERR(ptr)) { 677 - ret = PTR_ERR(ptr); 671 + ret = xa_err(xa_store(&ct->fence_lookup, 672 + g2h_fence->seqno, g2h_fence, 673 + GFP_ATOMIC)); 674 + if (ret) 678 675 goto out; 679 - } 680 676 } 681 677 682 678 seqno = g2h_fence->seqno; ··· 875 879 retry_same_fence: 876 880 ret = guc_ct_send(ct, action, len, 0, 0, &g2h_fence); 877 881 if (unlikely(ret == -ENOMEM)) { 878 - void *ptr; 879 - 880 882 /* Retry allocation /w GFP_KERNEL */ 881 - ptr = xa_store(&ct->fence_lookup, 882 - g2h_fence.seqno, 883 - &g2h_fence, GFP_KERNEL); 884 - if (IS_ERR(ptr)) 885 - return PTR_ERR(ptr); 883 + ret = xa_err(xa_store(&ct->fence_lookup, g2h_fence.seqno, 884 + &g2h_fence, GFP_KERNEL)); 885 + if (ret) 886 + return ret; 886 887 887 888 goto retry_same_fence; 888 889 } else if (unlikely(ret)) { ··· 896 903 } 897 904 898 905 ret = wait_event_timeout(ct->g2h_fence_wq, g2h_fence.done, HZ); 906 + 907 + /* 908 + * Ensure we serialize with completion side to prevent UAF with fence going out of scope on 909 + * the stack, since we have no clue if it will fire after the timeout before we can erase 910 + * from the xa. Also we have some dependent loads and stores below for which we need the 911 + * correct ordering, and we lack the needed barriers. 912 + */ 913 + mutex_lock(&ct->lock); 899 914 if (!ret) { 900 - xe_gt_err(gt, "Timed out wait for G2H, fence %u, action %04x", 901 - g2h_fence.seqno, action[0]); 915 + xe_gt_err(gt, "Timed out wait for G2H, fence %u, action %04x, done %s", 916 + g2h_fence.seqno, action[0], str_yes_no(g2h_fence.done)); 902 917 xa_erase_irq(&ct->fence_lookup, g2h_fence.seqno); 918 + mutex_unlock(&ct->lock); 903 919 return -ETIME; 904 920 } 905 921 906 922 if (g2h_fence.retry) { 907 923 xe_gt_dbg(gt, "H2G action %#x retrying: reason %#x\n", 908 924 action[0], g2h_fence.reason); 925 + mutex_unlock(&ct->lock); 909 926 goto retry; 910 927 } 911 928 if (g2h_fence.fail) { ··· 924 921 ret = -EIO; 925 922 } 926 923 927 - return ret > 0 ? response_buffer ? g2h_fence.response_len : g2h_fence.response_data : ret; 924 + if (ret > 0) 925 + ret = response_buffer ? g2h_fence.response_len : g2h_fence.response_data; 926 + 927 + mutex_unlock(&ct->lock); 928 + 929 + return ret; 928 930 } 929 931 930 932 /**
+4 -81
drivers/gpu/drm/xe/xe_guc_submit.c
··· 224 224 EXEC_QUEUE_STATE_BANNED)); 225 225 } 226 226 227 - #ifdef CONFIG_PROVE_LOCKING 228 - static int alloc_submit_wq(struct xe_guc *guc) 229 - { 230 - int i; 231 - 232 - for (i = 0; i < NUM_SUBMIT_WQ; ++i) { 233 - guc->submission_state.submit_wq_pool[i] = 234 - alloc_ordered_workqueue("submit_wq", 0); 235 - if (!guc->submission_state.submit_wq_pool[i]) 236 - goto err_free; 237 - } 238 - 239 - return 0; 240 - 241 - err_free: 242 - while (i) 243 - destroy_workqueue(guc->submission_state.submit_wq_pool[--i]); 244 - 245 - return -ENOMEM; 246 - } 247 - 248 - static void free_submit_wq(struct xe_guc *guc) 249 - { 250 - int i; 251 - 252 - for (i = 0; i < NUM_SUBMIT_WQ; ++i) 253 - destroy_workqueue(guc->submission_state.submit_wq_pool[i]); 254 - } 255 - 256 - static struct workqueue_struct *get_submit_wq(struct xe_guc *guc) 257 - { 258 - int idx = guc->submission_state.submit_wq_idx++ % NUM_SUBMIT_WQ; 259 - 260 - return guc->submission_state.submit_wq_pool[idx]; 261 - } 262 - #else 263 - static int alloc_submit_wq(struct xe_guc *guc) 264 - { 265 - return 0; 266 - } 267 - 268 - static void free_submit_wq(struct xe_guc *guc) 269 - { 270 - 271 - } 272 - 273 - static struct workqueue_struct *get_submit_wq(struct xe_guc *guc) 274 - { 275 - return NULL; 276 - } 277 - #endif 278 - 279 - static void xe_guc_submit_fini(struct xe_guc *guc) 280 - { 281 - struct xe_device *xe = guc_to_xe(guc); 282 - struct xe_gt *gt = guc_to_gt(guc); 283 - int ret; 284 - 285 - ret = wait_event_timeout(guc->submission_state.fini_wq, 286 - xa_empty(&guc->submission_state.exec_queue_lookup), 287 - HZ * 5); 288 - 289 - drain_workqueue(xe->destroy_wq); 290 - 291 - xe_gt_assert(gt, ret); 292 - } 293 - 294 227 static void guc_submit_fini(struct drm_device *drm, void *arg) 295 228 { 296 229 struct xe_guc *guc = arg; 297 230 298 - xe_guc_submit_fini(guc); 299 231 xa_destroy(&guc->submission_state.exec_queue_lookup); 300 - free_submit_wq(guc); 301 232 } 302 233 303 234 static void guc_submit_wedged_fini(void *arg) ··· 290 359 if (err) 291 360 return err; 292 361 293 - err = alloc_submit_wq(guc); 294 - if (err) 295 - return err; 296 - 297 362 gt->exec_queue_ops = &guc_exec_queue_ops; 298 363 299 364 xa_init(&guc->submission_state.exec_queue_lookup); ··· 320 393 static int alloc_guc_id(struct xe_guc *guc, struct xe_exec_queue *q) 321 394 { 322 395 int ret; 323 - void *ptr; 324 396 int i; 325 397 326 398 /* ··· 339 413 q->guc->id = ret; 340 414 341 415 for (i = 0; i < q->width; ++i) { 342 - ptr = xa_store(&guc->submission_state.exec_queue_lookup, 343 - q->guc->id + i, q, GFP_NOWAIT); 344 - if (IS_ERR(ptr)) { 345 - ret = PTR_ERR(ptr); 416 + ret = xa_err(xa_store(&guc->submission_state.exec_queue_lookup, 417 + q->guc->id + i, q, GFP_NOWAIT)); 418 + if (ret) 346 419 goto err_release; 347 - } 348 420 } 349 421 350 422 return 0; ··· 1406 1482 timeout = (q->vm && xe_vm_in_lr_mode(q->vm)) ? MAX_SCHEDULE_TIMEOUT : 1407 1483 msecs_to_jiffies(q->sched_props.job_timeout_ms); 1408 1484 err = xe_sched_init(&ge->sched, &drm_sched_ops, &xe_sched_ops, 1409 - get_submit_wq(guc), 1410 - q->lrc[0]->ring.size / MAX_JOB_SIZE_BYTES, 64, 1485 + NULL, q->lrc[0]->ring.size / MAX_JOB_SIZE_BYTES, 64, 1411 1486 timeout, guc_to_gt(guc)->ordered_wq, NULL, 1412 1487 q->name, gt_to_xe(q->gt)->drm.dev); 1413 1488 if (err)
-7
drivers/gpu/drm/xe/xe_guc_types.h
··· 72 72 atomic_t stopped; 73 73 /** @submission_state.lock: protects submission state */ 74 74 struct mutex lock; 75 - #ifdef CONFIG_PROVE_LOCKING 76 - #define NUM_SUBMIT_WQ 256 77 - /** @submission_state.submit_wq_pool: submission ordered workqueues pool */ 78 - struct workqueue_struct *submit_wq_pool[NUM_SUBMIT_WQ]; 79 - /** @submission_state.submit_wq_idx: submission ordered workqueue index */ 80 - int submit_wq_idx; 81 - #endif 82 75 /** @submission_state.enabled: submission is enabled */ 83 76 bool enabled; 84 77 /** @submission_state.fini_wq: submit fini wait queue */
+3 -11
drivers/hid/amd-sfh-hid/amd_sfh_client.c
··· 236 236 cl_data->in_data = in_data; 237 237 238 238 for (i = 0; i < cl_data->num_hid_devices; i++) { 239 - in_data->sensor_virt_addr[i] = dma_alloc_coherent(dev, sizeof(int) * 8, 240 - &cl_data->sensor_dma_addr[i], 241 - GFP_KERNEL); 239 + in_data->sensor_virt_addr[i] = dmam_alloc_coherent(dev, sizeof(int) * 8, 240 + &cl_data->sensor_dma_addr[i], 241 + GFP_KERNEL); 242 242 if (!in_data->sensor_virt_addr[i]) { 243 243 rc = -ENOMEM; 244 244 goto cleanup; ··· 331 331 int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata) 332 332 { 333 333 struct amdtp_cl_data *cl_data = privdata->cl_data; 334 - struct amd_input_data *in_data = cl_data->in_data; 335 334 int i, status; 336 335 337 336 for (i = 0; i < cl_data->num_hid_devices; i++) { ··· 350 351 cancel_delayed_work_sync(&cl_data->work_buffer); 351 352 amdtp_hid_remove(cl_data); 352 353 353 - for (i = 0; i < cl_data->num_hid_devices; i++) { 354 - if (in_data->sensor_virt_addr[i]) { 355 - dma_free_coherent(&privdata->pdev->dev, 8 * sizeof(int), 356 - in_data->sensor_virt_addr[i], 357 - cl_data->sensor_dma_addr[i]); 358 - } 359 - } 360 354 return 0; 361 355 }
+2
drivers/hid/hid-ids.h
··· 1036 1036 #define USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3220_SERIES 0xc056 1037 1037 #define USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3215_SERIES 0xc057 1038 1038 #define USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3225_SERIES 0xc058 1039 + #define USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3325_SERIES 0x430c 1040 + #define USB_DEVICE_ID_PLANTRONICS_ENCOREPRO_500_SERIES 0x431e 1039 1041 1040 1042 #define USB_VENDOR_ID_PANASONIC 0x04da 1041 1043 #define USB_DEVICE_ID_PANABOARD_UBT780 0x1044
+9
drivers/hid/hid-multitouch.c
··· 2026 2026 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2027 2027 USB_VENDOR_ID_ELAN, 0x3148) }, 2028 2028 2029 + { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU, 2030 + HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2031 + USB_VENDOR_ID_ELAN, 0x32ae) }, 2032 + 2029 2033 /* Elitegroup panel */ 2030 2034 { .driver_data = MT_CLS_SERIAL, 2031 2035 MT_USB_DEVICE(USB_VENDOR_ID_ELITEGROUP, ··· 2098 2094 { .driver_data = MT_CLS_VTL, 2099 2095 HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2100 2096 0x347d, 0x7853) }, 2097 + 2098 + /* HONOR MagicBook Art 14 touchpad */ 2099 + { .driver_data = MT_CLS_VTL, 2100 + HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, 2101 + 0x35cc, 0x0104) }, 2101 2102 2102 2103 /* Ilitek dual touch panel */ 2103 2104 { .driver_data = MT_CLS_NSMU,
+23
drivers/hid/hid-plantronics.c
··· 38 38 (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) 39 39 40 40 #define PLT_QUIRK_DOUBLE_VOLUME_KEYS BIT(0) 41 + #define PLT_QUIRK_FOLLOWED_OPPOSITE_VOLUME_KEYS BIT(1) 41 42 42 43 #define PLT_DOUBLE_KEY_TIMEOUT 5 /* ms */ 44 + #define PLT_FOLLOWED_OPPOSITE_KEY_TIMEOUT 220 /* ms */ 43 45 44 46 struct plt_drv_data { 45 47 unsigned long device_type; ··· 139 137 140 138 drv_data->last_volume_key_ts = cur_ts; 141 139 } 140 + if (drv_data->quirks & PLT_QUIRK_FOLLOWED_OPPOSITE_VOLUME_KEYS) { 141 + unsigned long prev_ts, cur_ts; 142 + 143 + /* Usages are filtered in plantronics_usages. */ 144 + 145 + if (!value) /* Handle key presses only. */ 146 + return 0; 147 + 148 + prev_ts = drv_data->last_volume_key_ts; 149 + cur_ts = jiffies; 150 + if (jiffies_to_msecs(cur_ts - prev_ts) <= PLT_FOLLOWED_OPPOSITE_KEY_TIMEOUT) 151 + return 1; /* Ignore the followed opposite volume key. */ 152 + 153 + drv_data->last_volume_key_ts = cur_ts; 154 + } 142 155 143 156 return 0; 144 157 } ··· 227 210 { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, 228 211 USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3225_SERIES), 229 212 .driver_data = PLT_QUIRK_DOUBLE_VOLUME_KEYS }, 213 + { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, 214 + USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3325_SERIES), 215 + .driver_data = PLT_QUIRK_FOLLOWED_OPPOSITE_VOLUME_KEYS }, 216 + { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, 217 + USB_DEVICE_ID_PLANTRONICS_ENCOREPRO_500_SERIES), 218 + .driver_data = PLT_QUIRK_FOLLOWED_OPPOSITE_VOLUME_KEYS }, 230 219 { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, HID_ANY_ID) }, 231 220 { } 232 221 };
+1 -1
drivers/hid/intel-ish-hid/ishtp-fw-loader.c
··· 635 635 const struct firmware *fw, 636 636 const struct shim_fw_info fw_info) 637 637 { 638 - int rv; 638 + int rv = 0; 639 639 void *dma_buf; 640 640 dma_addr_t dma_buf_phy; 641 641 u32 fragment_offset, fragment_size, payload_max_size;
+2
drivers/hid/wacom_wac.c
··· 2567 2567 /* Going into range select tool */ 2568 2568 if (wacom_wac->hid_data.invert_state) 2569 2569 wacom_wac->tool[0] = BTN_TOOL_RUBBER; 2570 + else if (wacom_wac->features.quirks & WACOM_QUIRK_AESPEN) 2571 + wacom_wac->tool[0] = BTN_TOOL_PEN; 2570 2572 else if (wacom_wac->id[0]) 2571 2573 wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]); 2572 2574 else
+6
drivers/hwmon/Kconfig
··· 162 162 tristate "Analog Devices ADM9240 and compatibles" 163 163 depends on I2C 164 164 select HWMON_VID 165 + select REGMAP_I2C 165 166 help 166 167 If you say yes here you get support for Analog Devices ADM9240, 167 168 Dallas DS1780, National Semiconductor LM81 sensor chips. ··· 224 223 config SENSORS_ADT7470 225 224 tristate "Analog Devices ADT7470" 226 225 depends on I2C 226 + select REGMAP_I2C 227 227 help 228 228 If you say yes here you get support for the Analog Devices 229 229 ADT7470 temperature monitoring chips. ··· 1001 999 config SENSORS_LTC2991 1002 1000 tristate "Analog Devices LTC2991" 1003 1001 depends on I2C 1002 + select REGMAP_I2C 1004 1003 help 1005 1004 If you say yes here you get support for Analog Devices LTC2991 1006 1005 Octal I2C Voltage, Current, and Temperature Monitor. The LTC2991 ··· 1149 1146 config SENSORS_MAX1668 1150 1147 tristate "Maxim MAX1668 and compatibles" 1151 1148 depends on I2C 1149 + select REGMAP_I2C 1152 1150 help 1153 1151 If you say yes here you get support for MAX1668, MAX1989 and 1154 1152 MAX1805 chips. ··· 1279 1275 config SENSORS_MC34VR500 1280 1276 tristate "NXP MC34VR500 hardware monitoring driver" 1281 1277 depends on I2C 1278 + select REGMAP_I2C 1282 1279 help 1283 1280 If you say yes here you get support for the temperature and input 1284 1281 voltage sensors of the NXP MC34VR500. ··· 2317 2312 config SENSORS_TMP513 2318 2313 tristate "Texas Instruments TMP513 and compatibles" 2319 2314 depends on I2C 2315 + select REGMAP_I2C 2320 2316 help 2321 2317 If you say yes here you get support for Texas Instruments TMP512, 2322 2318 and TMP513 temperature and power supply sensor chips.
+1 -2
drivers/hwmon/adt7475.c
··· 1735 1735 static int adt7475_fan_pwm_config(struct i2c_client *client) 1736 1736 { 1737 1737 struct adt7475_data *data = i2c_get_clientdata(client); 1738 - struct fwnode_handle *child; 1739 1738 struct adt7475_pwm_config cfg = {}; 1740 1739 int ret; 1741 1740 1742 - device_for_each_child_node(&client->dev, child) { 1741 + device_for_each_child_node_scoped(&client->dev, child) { 1743 1742 if (!fwnode_property_present(child, "pwms")) 1744 1743 continue; 1745 1744
+1 -1
drivers/hwmon/intel-m10-bmc-hwmon.c
··· 358 358 { 0x4f0, 0x4f4, 0x4f8, 0x52c, 0x0, 500, "Board Top Near FPGA Temperature" }, 359 359 { 0x4fc, 0x500, 0x504, 0x52c, 0x0, 500, "Board Bottom Near CVL Temperature" }, 360 360 { 0x508, 0x50c, 0x510, 0x52c, 0x0, 500, "Board Top East Near VRs Temperature" }, 361 - { 0x514, 0x518, 0x51c, 0x52c, 0x0, 500, "Columbiaville Die Temperature" }, 361 + { 0x514, 0x518, 0x51c, 0x52c, 0x0, 500, "CVL Die Temperature" }, 362 362 { 0x520, 0x524, 0x528, 0x52c, 0x0, 500, "Board Rear Side Temperature" }, 363 363 { 0x530, 0x534, 0x538, 0x52c, 0x0, 500, "Board Front Side Temperature" }, 364 364 { 0x53c, 0x540, 0x544, 0x0, 0x0, 500, "QSFP1 Case Temperature" },
+2
drivers/infiniband/core/addr.c
··· 269 269 break; 270 270 #endif 271 271 } 272 + if (!ret && dev && is_vlan_dev(dev)) 273 + dev = vlan_dev_real_dev(dev); 272 274 return ret ? ERR_PTR(ret) : dev; 273 275 } 274 276
+2
drivers/infiniband/core/nldev.c
··· 2816 2816 nlh = nlmsg_put(skb, 0, 0, 2817 2817 RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_MONITOR), 2818 2818 0, 0); 2819 + if (!nlh) 2820 + goto err_free; 2819 2821 2820 2822 switch (type) { 2821 2823 case RDMA_REGISTER_EVENT:
+1 -1
drivers/infiniband/hw/bnxt_re/hw_counters.c
··· 366 366 goto done; 367 367 } 368 368 } 369 - if (rdev->pacing.dbr_pacing) 369 + if (rdev->pacing.dbr_pacing && bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx)) 370 370 bnxt_re_copy_db_pacing_stats(rdev, stats); 371 371 } 372 372
+5 -1
drivers/infiniband/hw/bnxt_re/ib_verbs.c
··· 1307 1307 0 : BNXT_QPLIB_RESERVED_QP_WRS; 1308 1308 entries = bnxt_re_init_depth(entries + diff + 1, uctx); 1309 1309 sq->max_wqe = min_t(u32, entries, dev_attr->max_qp_wqes + diff + 1); 1310 - sq->max_sw_wqe = bnxt_qplib_get_depth(sq, qplqp->wqe_mode, true); 1310 + if (qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE) 1311 + sq->max_sw_wqe = bnxt_qplib_get_depth(sq, qplqp->wqe_mode, true); 1312 + else 1313 + sq->max_sw_wqe = sq->max_wqe; 1314 + 1311 1315 } 1312 1316 sq->q_full_delta = diff + 1; 1313 1317 /*
+25 -22
drivers/infiniband/hw/bnxt_re/main.c
··· 188 188 189 189 bnxt_re_set_db_offset(rdev); 190 190 rc = bnxt_qplib_map_db_bar(&rdev->qplib_res); 191 - if (rc) 191 + if (rc) { 192 + kfree(rdev->chip_ctx); 193 + rdev->chip_ctx = NULL; 192 194 return rc; 195 + } 193 196 194 197 if (bnxt_qplib_determine_atomics(en_dev->pdev)) 195 198 ibdev_info(&rdev->ibdev, ··· 534 531 static void __wait_for_fifo_occupancy_below_th(struct bnxt_re_dev *rdev) 535 532 { 536 533 struct bnxt_qplib_db_pacing_data *pacing_data = rdev->qplib_res.pacing_data; 534 + u32 retry_fifo_check = 1000; 537 535 u32 fifo_occup; 538 536 539 537 /* loop shouldn't run infintely as the occupancy usually goes ··· 548 544 549 545 if (fifo_occup < pacing_data->pacing_th) 550 546 break; 547 + if (!retry_fifo_check--) { 548 + dev_info_once(rdev_to_dev(rdev), 549 + "%s: fifo_occup = 0x%xfifo_max_depth = 0x%x pacing_th = 0x%x\n", 550 + __func__, fifo_occup, pacing_data->fifo_max_depth, 551 + pacing_data->pacing_th); 552 + break; 553 + } 554 + 551 555 } 552 556 } 553 557 ··· 969 957 return ib_register_device(ibdev, "bnxt_re%d", &rdev->en_dev->pdev->dev); 970 958 } 971 959 972 - static struct bnxt_re_dev *bnxt_re_dev_add(struct bnxt_aux_priv *aux_priv, 960 + static struct bnxt_re_dev *bnxt_re_dev_add(struct auxiliary_device *adev, 973 961 struct bnxt_en_dev *en_dev) 974 962 { 975 963 struct bnxt_re_dev *rdev; ··· 985 973 rdev->nb.notifier_call = NULL; 986 974 rdev->netdev = en_dev->net; 987 975 rdev->en_dev = en_dev; 976 + rdev->adev = adev; 988 977 rdev->id = rdev->en_dev->pdev->devfn; 989 978 INIT_LIST_HEAD(&rdev->qp_list); 990 979 mutex_init(&rdev->qp_lock); ··· 1038 1025 static int bnxt_re_handle_qp_async_event(struct creq_qp_event *qp_event, 1039 1026 struct bnxt_re_qp *qp) 1040 1027 { 1041 - struct bnxt_re_srq *srq = container_of(qp->qplib_qp.srq, struct bnxt_re_srq, 1042 - qplib_srq); 1043 1028 struct creq_qp_error_notification *err_event; 1029 + struct bnxt_re_srq *srq = NULL; 1044 1030 struct ib_event event = {}; 1045 1031 unsigned int flags; 1032 + 1033 + if (qp->qplib_qp.srq) 1034 + srq = container_of(qp->qplib_qp.srq, struct bnxt_re_srq, 1035 + qplib_srq); 1046 1036 1047 1037 if (qp->qplib_qp.state == CMDQ_MODIFY_QP_NEW_STATE_ERR && 1048 1038 rdma_is_kernel_res(&qp->ib_qp.res)) { ··· 1274 1258 { 1275 1259 struct bnxt_re_cq *cq = container_of(handle, struct bnxt_re_cq, 1276 1260 qplib_cq); 1277 - u32 *cq_ptr; 1278 1261 1279 - if (cq->ib_cq.comp_handler) { 1280 - if (cq->uctx_cq_page) { 1281 - cq_ptr = (u32 *)cq->uctx_cq_page; 1282 - *cq_ptr = cq->qplib_cq.toggle; 1283 - } 1262 + if (cq->ib_cq.comp_handler) 1284 1263 (*cq->ib_cq.comp_handler)(&cq->ib_cq, cq->ib_cq.cq_context); 1285 - } 1286 1264 1287 1265 return 0; 1288 1266 } ··· 1833 1823 */ 1834 1824 rtnl_lock(); 1835 1825 en_info->rdev = rdev; 1836 - rdev->adev = adev; 1837 1826 rtnl_unlock(); 1838 1827 } 1839 1828 ··· 1849 1840 en_dev = en_info->en_dev; 1850 1841 1851 1842 1852 - rdev = bnxt_re_dev_add(aux_priv, en_dev); 1843 + rdev = bnxt_re_dev_add(adev, en_dev); 1853 1844 if (!rdev || !rdev_to_dev(rdev)) { 1854 1845 rc = -ENOMEM; 1855 1846 goto exit; ··· 1874 1865 rdev->nb.notifier_call = NULL; 1875 1866 pr_err("%s: Cannot register to netdevice_notifier", 1876 1867 ROCE_DRV_MODULE_NAME); 1877 - return rc; 1868 + goto re_dev_unreg; 1878 1869 } 1879 1870 bnxt_re_setup_cc(rdev, true); 1880 1871 1881 1872 return 0; 1882 1873 1874 + re_dev_unreg: 1875 + ib_unregister_device(&rdev->ibdev); 1883 1876 re_dev_uninit: 1884 1877 bnxt_re_update_en_info_rdev(NULL, en_info, adev); 1885 1878 bnxt_re_dev_uninit(rdev, BNXT_RE_COMPLETE_REMOVE); ··· 2025 2014 auxiliary_set_drvdata(adev, en_info); 2026 2015 2027 2016 rc = bnxt_re_add_device(adev, BNXT_RE_COMPLETE_INIT); 2028 - if (rc) 2029 - goto err; 2030 2017 mutex_unlock(&bnxt_re_mutex); 2031 - return 0; 2032 - 2033 - err: 2034 - mutex_unlock(&bnxt_re_mutex); 2035 - bnxt_re_remove(adev); 2036 - 2037 2018 return rc; 2038 2019 } 2039 2020
+5
drivers/infiniband/hw/bnxt_re/qplib_fp.c
··· 327 327 case NQ_BASE_TYPE_CQ_NOTIFICATION: 328 328 { 329 329 struct nq_cn *nqcne = (struct nq_cn *)nqe; 330 + struct bnxt_re_cq *cq_p; 330 331 331 332 q_handle = le32_to_cpu(nqcne->cq_handle_low); 332 333 q_handle |= (u64)le32_to_cpu(nqcne->cq_handle_high) ··· 338 337 cq->toggle = (le16_to_cpu(nqe->info10_type) & 339 338 NQ_CN_TOGGLE_MASK) >> NQ_CN_TOGGLE_SFT; 340 339 cq->dbinfo.toggle = cq->toggle; 340 + cq_p = container_of(cq, struct bnxt_re_cq, qplib_cq); 341 + if (cq_p->uctx_cq_page) 342 + *((u32 *)cq_p->uctx_cq_page) = cq->toggle; 343 + 341 344 bnxt_qplib_armen_db(&cq->dbinfo, 342 345 DBC_DBC_TYPE_CQ_ARMENA); 343 346 spin_lock_bh(&cq->compl_lock);
+1 -1
drivers/infiniband/hw/bnxt_re/qplib_fp.h
··· 170 170 }; 171 171 u32 q_key; 172 172 u32 dst_qp; 173 - u16 avid; 173 + u32 avid; 174 174 } send; 175 175 176 176 /* Send Raw Ethernet and QP1 */
+1 -1
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c
··· 525 525 /* failed with status */ 526 526 dev_err(&rcfw->pdev->dev, "cmdq[%#x]=%#x status %#x\n", 527 527 cookie, opcode, evnt->status); 528 - rc = -EFAULT; 528 + rc = -EIO; 529 529 } 530 530 531 531 return rc;
+5 -16
drivers/infiniband/hw/bnxt_re/qplib_res.c
··· 244 244 sginfo.pgsize = npde * pg_size; 245 245 sginfo.npages = 1; 246 246 rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_0], &sginfo); 247 + if (rc) 248 + goto fail; 247 249 248 250 /* Alloc PBL pages */ 249 251 sginfo.npages = npbl; ··· 257 255 dst_virt_ptr = 258 256 (dma_addr_t **)hwq->pbl[PBL_LVL_0].pg_arr; 259 257 src_phys_ptr = hwq->pbl[PBL_LVL_1].pg_map_arr; 260 - if (hwq_attr->type == HWQ_TYPE_MR) { 261 - /* For MR it is expected that we supply only 1 contigous 262 - * page i.e only 1 entry in the PDL that will contain 263 - * all the PBLs for the user supplied memory region 264 - */ 265 - for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count; 266 - i++) 267 - dst_virt_ptr[0][i] = src_phys_ptr[i] | 268 - flag; 269 - } else { 270 - for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count; 271 - i++) 272 - dst_virt_ptr[PTR_PG(i)][PTR_IDX(i)] = 273 - src_phys_ptr[i] | 274 - PTU_PDE_VALID; 275 - } 258 + for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count; i++) 259 + dst_virt_ptr[0][i] = src_phys_ptr[i] | flag; 260 + 276 261 /* Alloc or init PTEs */ 277 262 rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_2], 278 263 hwq_attr->sginfo);
+10 -1
drivers/infiniband/hw/bnxt_re/qplib_sp.c
··· 140 140 min_t(u32, sb->max_sge_var_wqe, BNXT_VAR_MAX_SGE) : 6; 141 141 attr->max_cq = le32_to_cpu(sb->max_cq); 142 142 attr->max_cq_wqes = le32_to_cpu(sb->max_cqe); 143 + if (!bnxt_qplib_is_chip_gen_p7(rcfw->res->cctx)) 144 + attr->max_cq_wqes = min_t(u32, BNXT_QPLIB_MAX_CQ_WQES, attr->max_cq_wqes); 143 145 attr->max_cq_sges = attr->max_qp_sges; 144 146 attr->max_mr = le32_to_cpu(sb->max_mr); 145 147 attr->max_mw = le32_to_cpu(sb->max_mw); ··· 159 157 if (!bnxt_qplib_is_chip_gen_p7(rcfw->res->cctx)) 160 158 attr->l2_db_size = (sb->l2_db_space_size + 1) * 161 159 (0x01 << RCFW_DBR_BASE_PAGE_SHIFT); 162 - attr->max_sgid = BNXT_QPLIB_NUM_GIDS_SUPPORTED; 160 + /* 161 + * Read the max gid supported by HW. 162 + * For each entry in HW GID in HW table, we consume 2 163 + * GID entries in the kernel GID table. So max_gid reported 164 + * to stack can be up to twice the value reported by the HW, up to 256 gids. 165 + */ 166 + attr->max_sgid = le32_to_cpu(sb->max_gid); 167 + attr->max_sgid = min_t(u32, BNXT_QPLIB_NUM_GIDS_SUPPORTED, 2 * attr->max_sgid); 163 168 attr->dev_cap_flags = le16_to_cpu(sb->dev_cap_flags); 164 169 attr->dev_cap_flags2 = le16_to_cpu(sb->dev_cap_ext_flags_2); 165 170
+1
drivers/infiniband/hw/bnxt_re/qplib_sp.h
··· 56 56 u32 max_qp_wqes; 57 57 u32 max_qp_sges; 58 58 u32 max_cq; 59 + #define BNXT_QPLIB_MAX_CQ_WQES 0xfffff 59 60 u32 max_cq_wqes; 60 61 u32 max_cq_sges; 61 62 u32 max_mr;
+4 -5
drivers/infiniband/hw/cxgb4/cm.c
··· 2086 2086 err = -ENOMEM; 2087 2087 if (n->dev->flags & IFF_LOOPBACK) { 2088 2088 if (iptype == 4) 2089 - pdev = ip_dev_find(&init_net, *(__be32 *)peer_ip); 2089 + pdev = __ip_dev_find(&init_net, *(__be32 *)peer_ip, false); 2090 2090 else if (IS_ENABLED(CONFIG_IPV6)) 2091 2091 for_each_netdev(&init_net, pdev) { 2092 2092 if (ipv6_chk_addr(&init_net, ··· 2101 2101 err = -ENODEV; 2102 2102 goto out; 2103 2103 } 2104 + if (is_vlan_dev(pdev)) 2105 + pdev = vlan_dev_real_dev(pdev); 2104 2106 ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t, 2105 2107 n, pdev, rt_tos2priority(tos)); 2106 - if (!ep->l2t) { 2107 - dev_put(pdev); 2108 + if (!ep->l2t) 2108 2109 goto out; 2109 - } 2110 2110 ep->mtu = pdev->mtu; 2111 2111 ep->tx_chan = cxgb4_port_chan(pdev); 2112 2112 ep->smac_idx = ((struct port_info *)netdev_priv(pdev))->smt_idx; ··· 2119 2119 ep->rss_qid = cdev->rdev.lldi.rxq_ids[ 2120 2120 cxgb4_port_idx(pdev) * step]; 2121 2121 set_tcp_window(ep, (struct port_info *)netdev_priv(pdev)); 2122 - dev_put(pdev); 2123 2122 } else { 2124 2123 pdev = get_real_dev(n->dev); 2125 2124 ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t,
+1 -1
drivers/infiniband/hw/irdma/cm.c
··· 3631 3631 /** 3632 3632 * irdma_accept - registered call for connection to be accepted 3633 3633 * @cm_id: cm information for passive connection 3634 - * @conn_param: accpet parameters 3634 + * @conn_param: accept parameters 3635 3635 */ 3636 3636 int irdma_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) 3637 3637 {
+2
drivers/infiniband/sw/siw/siw_qp_tx.c
··· 331 331 msg.msg_flags &= ~MSG_MORE; 332 332 333 333 tcp_rate_check_app_limited(sk); 334 + if (!sendpage_ok(page[i])) 335 + msg.msg_flags &= ~MSG_SPLICE_PAGES; 334 336 bvec_set_page(&bvec, page[i], bytes, offset); 335 337 iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size); 336 338
+68 -12
drivers/infiniband/ulp/srpt/ib_srpt.c
··· 68 68 static u64 srpt_service_guid; 69 69 static DEFINE_SPINLOCK(srpt_dev_lock); /* Protects srpt_dev_list. */ 70 70 static LIST_HEAD(srpt_dev_list); /* List of srpt_device structures. */ 71 + static DEFINE_MUTEX(srpt_mc_mutex); /* Protects srpt_memory_caches. */ 72 + static DEFINE_XARRAY(srpt_memory_caches); /* See also srpt_memory_cache_entry */ 71 73 72 74 static unsigned srp_max_req_size = DEFAULT_MAX_REQ_SIZE; 73 75 module_param(srp_max_req_size, int, 0444); ··· 106 104 static void srpt_recv_done(struct ib_cq *cq, struct ib_wc *wc); 107 105 static void srpt_send_done(struct ib_cq *cq, struct ib_wc *wc); 108 106 static void srpt_process_wait_list(struct srpt_rdma_ch *ch); 107 + 108 + /* Type of the entries in srpt_memory_caches. */ 109 + struct srpt_memory_cache_entry { 110 + refcount_t ref; 111 + struct kmem_cache *c; 112 + }; 113 + 114 + static struct kmem_cache *srpt_cache_get(unsigned int object_size) 115 + { 116 + struct srpt_memory_cache_entry *e; 117 + char name[32]; 118 + void *res; 119 + 120 + guard(mutex)(&srpt_mc_mutex); 121 + e = xa_load(&srpt_memory_caches, object_size); 122 + if (e) { 123 + refcount_inc(&e->ref); 124 + return e->c; 125 + } 126 + snprintf(name, sizeof(name), "srpt-%u", object_size); 127 + e = kmalloc(sizeof(*e), GFP_KERNEL); 128 + if (!e) 129 + return NULL; 130 + refcount_set(&e->ref, 1); 131 + e->c = kmem_cache_create(name, object_size, /*align=*/512, 0, NULL); 132 + if (!e->c) 133 + goto free_entry; 134 + res = xa_store(&srpt_memory_caches, object_size, e, GFP_KERNEL); 135 + if (xa_is_err(res)) 136 + goto destroy_cache; 137 + return e->c; 138 + 139 + destroy_cache: 140 + kmem_cache_destroy(e->c); 141 + 142 + free_entry: 143 + kfree(e); 144 + return NULL; 145 + } 146 + 147 + static void srpt_cache_put(struct kmem_cache *c) 148 + { 149 + struct srpt_memory_cache_entry *e = NULL; 150 + unsigned long object_size; 151 + 152 + guard(mutex)(&srpt_mc_mutex); 153 + xa_for_each(&srpt_memory_caches, object_size, e) 154 + if (e->c == c) 155 + break; 156 + if (WARN_ON_ONCE(!e)) 157 + return; 158 + if (!refcount_dec_and_test(&e->ref)) 159 + return; 160 + WARN_ON_ONCE(xa_erase(&srpt_memory_caches, object_size) != e); 161 + kmem_cache_destroy(e->c); 162 + kfree(e); 163 + } 109 164 110 165 /* 111 166 * The only allowed channel state changes are those that change the channel ··· 2178 2119 ch->sport->sdev, ch->rq_size, 2179 2120 ch->rsp_buf_cache, DMA_TO_DEVICE); 2180 2121 2181 - kmem_cache_destroy(ch->rsp_buf_cache); 2122 + srpt_cache_put(ch->rsp_buf_cache); 2182 2123 2183 2124 srpt_free_ioctx_ring((struct srpt_ioctx **)ch->ioctx_recv_ring, 2184 2125 sdev, ch->rq_size, 2185 2126 ch->req_buf_cache, DMA_FROM_DEVICE); 2186 2127 2187 - kmem_cache_destroy(ch->req_buf_cache); 2128 + srpt_cache_put(ch->req_buf_cache); 2188 2129 2189 2130 kref_put(&ch->kref, srpt_free_ch); 2190 2131 } ··· 2304 2245 INIT_LIST_HEAD(&ch->cmd_wait_list); 2305 2246 ch->max_rsp_size = ch->sport->port_attrib.srp_max_rsp_size; 2306 2247 2307 - ch->rsp_buf_cache = kmem_cache_create("srpt-rsp-buf", ch->max_rsp_size, 2308 - 512, 0, NULL); 2248 + ch->rsp_buf_cache = srpt_cache_get(ch->max_rsp_size); 2309 2249 if (!ch->rsp_buf_cache) 2310 2250 goto free_ch; 2311 2251 ··· 2338 2280 alignment_offset = round_up(imm_data_offset, 512) - 2339 2281 imm_data_offset; 2340 2282 req_sz = alignment_offset + imm_data_offset + srp_max_req_size; 2341 - ch->req_buf_cache = kmem_cache_create("srpt-req-buf", req_sz, 2342 - 512, 0, NULL); 2283 + ch->req_buf_cache = srpt_cache_get(req_sz); 2343 2284 if (!ch->req_buf_cache) 2344 2285 goto free_rsp_ring; 2345 2286 ··· 2535 2478 ch->req_buf_cache, DMA_FROM_DEVICE); 2536 2479 2537 2480 free_recv_cache: 2538 - kmem_cache_destroy(ch->req_buf_cache); 2481 + srpt_cache_put(ch->req_buf_cache); 2539 2482 2540 2483 free_rsp_ring: 2541 2484 srpt_free_ioctx_ring((struct srpt_ioctx **)ch->ioctx_ring, ··· 2543 2486 ch->rsp_buf_cache, DMA_TO_DEVICE); 2544 2487 2545 2488 free_rsp_cache: 2546 - kmem_cache_destroy(ch->rsp_buf_cache); 2489 + srpt_cache_put(ch->rsp_buf_cache); 2547 2490 2548 2491 free_ch: 2549 2492 if (rdma_cm_id) ··· 3112 3055 srpt_free_ioctx_ring((struct srpt_ioctx **)sdev->ioctx_ring, sdev, 3113 3056 sdev->srq_size, sdev->req_buf_cache, 3114 3057 DMA_FROM_DEVICE); 3115 - kmem_cache_destroy(sdev->req_buf_cache); 3058 + srpt_cache_put(sdev->req_buf_cache); 3116 3059 sdev->srq = NULL; 3117 3060 } 3118 3061 ··· 3139 3082 pr_debug("create SRQ #wr= %d max_allow=%d dev= %s\n", sdev->srq_size, 3140 3083 sdev->device->attrs.max_srq_wr, dev_name(&device->dev)); 3141 3084 3142 - sdev->req_buf_cache = kmem_cache_create("srpt-srq-req-buf", 3143 - srp_max_req_size, 0, 0, NULL); 3085 + sdev->req_buf_cache = srpt_cache_get(srp_max_req_size); 3144 3086 if (!sdev->req_buf_cache) 3145 3087 goto free_srq; 3146 3088 ··· 3161 3105 return 0; 3162 3106 3163 3107 free_cache: 3164 - kmem_cache_destroy(sdev->req_buf_cache); 3108 + srpt_cache_put(sdev->req_buf_cache); 3165 3109 3166 3110 free_srq: 3167 3111 ib_destroy_srq(srq);
+2 -1
drivers/mmc/core/queue.c
··· 388 388 389 389 blk_queue_rq_timeout(mq->queue, 60 * HZ); 390 390 391 - dma_set_max_seg_size(mmc_dev(host), queue_max_segment_size(mq->queue)); 391 + if (mmc_dev(host)->dma_parms) 392 + dma_set_max_seg_size(mmc_dev(host), queue_max_segment_size(mq->queue)); 392 393 393 394 INIT_WORK(&mq->recovery_work, mmc_mq_recovery_handler); 394 395 INIT_WORK(&mq->complete_work, mmc_blk_mq_complete_work);
+18 -53
drivers/mmc/host/mvsdio.c
··· 38 38 unsigned int xfer_mode; 39 39 unsigned int intr_en; 40 40 unsigned int ctrl; 41 - bool use_pio; 42 - struct sg_mapping_iter sg_miter; 43 41 unsigned int pio_size; 42 + void *pio_ptr; 44 43 unsigned int sg_frags; 45 44 unsigned int ns_per_clk; 46 45 unsigned int clock; ··· 114 115 * data when the buffer is not aligned on a 64 byte 115 116 * boundary. 116 117 */ 117 - unsigned int miter_flags = SG_MITER_ATOMIC; /* Used from IRQ */ 118 - 119 - if (data->flags & MMC_DATA_READ) 120 - miter_flags |= SG_MITER_TO_SG; 121 - else 122 - miter_flags |= SG_MITER_FROM_SG; 123 - 124 118 host->pio_size = data->blocks * data->blksz; 125 - sg_miter_start(&host->sg_miter, data->sg, data->sg_len, miter_flags); 119 + host->pio_ptr = sg_virt(data->sg); 126 120 if (!nodma) 127 - dev_dbg(host->dev, "fallback to PIO for data\n"); 128 - host->use_pio = true; 121 + dev_dbg(host->dev, "fallback to PIO for data at 0x%p size %d\n", 122 + host->pio_ptr, host->pio_size); 129 123 return 1; 130 124 } else { 131 125 dma_addr_t phys_addr; ··· 129 137 phys_addr = sg_dma_address(data->sg); 130 138 mvsd_write(MVSD_SYS_ADDR_LOW, (u32)phys_addr & 0xffff); 131 139 mvsd_write(MVSD_SYS_ADDR_HI, (u32)phys_addr >> 16); 132 - host->use_pio = false; 133 140 return 0; 134 141 } 135 142 } ··· 288 297 { 289 298 void __iomem *iobase = host->base; 290 299 291 - if (host->use_pio) { 292 - sg_miter_stop(&host->sg_miter); 300 + if (host->pio_ptr) { 301 + host->pio_ptr = NULL; 293 302 host->pio_size = 0; 294 303 } else { 295 304 dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->sg_frags, ··· 344 353 static irqreturn_t mvsd_irq(int irq, void *dev) 345 354 { 346 355 struct mvsd_host *host = dev; 347 - struct sg_mapping_iter *sgm = &host->sg_miter; 348 356 void __iomem *iobase = host->base; 349 357 u32 intr_status, intr_done_mask; 350 358 int irq_handled = 0; 351 - u16 *p; 352 - int s; 353 359 354 360 intr_status = mvsd_read(MVSD_NOR_INTR_STATUS); 355 361 dev_dbg(host->dev, "intr 0x%04x intr_en 0x%04x hw_state 0x%04x\n", ··· 370 382 spin_lock(&host->lock); 371 383 372 384 /* PIO handling, if needed. Messy business... */ 373 - if (host->use_pio) { 374 - /* 375 - * As we set sgm->consumed this always gives a valid buffer 376 - * position. 377 - */ 378 - if (!sg_miter_next(sgm)) { 379 - /* This should not happen */ 380 - dev_err(host->dev, "ran out of scatter segments\n"); 381 - spin_unlock(&host->lock); 382 - host->intr_en &= 383 - ~(MVSD_NOR_RX_READY | MVSD_NOR_RX_FIFO_8W | 384 - MVSD_NOR_TX_AVAIL | MVSD_NOR_TX_FIFO_8W); 385 - mvsd_write(MVSD_NOR_INTR_EN, host->intr_en); 386 - return IRQ_HANDLED; 387 - } 388 - p = sgm->addr; 389 - s = sgm->length; 390 - if (s > host->pio_size) 391 - s = host->pio_size; 392 - } 393 - 394 - if (host->use_pio && 385 + if (host->pio_size && 395 386 (intr_status & host->intr_en & 396 387 (MVSD_NOR_RX_READY | MVSD_NOR_RX_FIFO_8W))) { 397 - 388 + u16 *p = host->pio_ptr; 389 + int s = host->pio_size; 398 390 while (s >= 32 && (intr_status & MVSD_NOR_RX_FIFO_8W)) { 399 391 readsw(iobase + MVSD_FIFO, p, 16); 400 392 p += 16; 401 393 s -= 32; 402 - sgm->consumed += 32; 403 394 intr_status = mvsd_read(MVSD_NOR_INTR_STATUS); 404 395 } 405 396 /* ··· 391 424 put_unaligned(mvsd_read(MVSD_FIFO), p++); 392 425 put_unaligned(mvsd_read(MVSD_FIFO), p++); 393 426 s -= 4; 394 - sgm->consumed += 4; 395 427 intr_status = mvsd_read(MVSD_NOR_INTR_STATUS); 396 428 } 397 429 if (s && s < 4 && (intr_status & MVSD_NOR_RX_READY)) { ··· 398 432 val[0] = mvsd_read(MVSD_FIFO); 399 433 val[1] = mvsd_read(MVSD_FIFO); 400 434 memcpy(p, ((void *)&val) + 4 - s, s); 401 - sgm->consumed += s; 402 435 s = 0; 403 436 intr_status = mvsd_read(MVSD_NOR_INTR_STATUS); 404 437 } 405 - /* PIO transfer done */ 406 - host->pio_size -= sgm->consumed; 407 - if (host->pio_size == 0) { 438 + if (s == 0) { 408 439 host->intr_en &= 409 440 ~(MVSD_NOR_RX_READY | MVSD_NOR_RX_FIFO_8W); 410 441 mvsd_write(MVSD_NOR_INTR_EN, host->intr_en); ··· 413 450 } 414 451 dev_dbg(host->dev, "pio %d intr 0x%04x hw_state 0x%04x\n", 415 452 s, intr_status, mvsd_read(MVSD_HW_STATE)); 453 + host->pio_ptr = p; 454 + host->pio_size = s; 416 455 irq_handled = 1; 417 - } else if (host->use_pio && 456 + } else if (host->pio_size && 418 457 (intr_status & host->intr_en & 419 458 (MVSD_NOR_TX_AVAIL | MVSD_NOR_TX_FIFO_8W))) { 459 + u16 *p = host->pio_ptr; 460 + int s = host->pio_size; 420 461 /* 421 462 * The TX_FIFO_8W bit is unreliable. When set, bursting 422 463 * 16 halfwords all at once in the FIFO drops data. Actually ··· 431 464 mvsd_write(MVSD_FIFO, get_unaligned(p++)); 432 465 mvsd_write(MVSD_FIFO, get_unaligned(p++)); 433 466 s -= 4; 434 - sgm->consumed += 4; 435 467 intr_status = mvsd_read(MVSD_NOR_INTR_STATUS); 436 468 } 437 469 if (s < 4) { ··· 439 473 memcpy(((void *)&val) + 4 - s, p, s); 440 474 mvsd_write(MVSD_FIFO, val[0]); 441 475 mvsd_write(MVSD_FIFO, val[1]); 442 - sgm->consumed += s; 443 476 s = 0; 444 477 intr_status = mvsd_read(MVSD_NOR_INTR_STATUS); 445 478 } 446 - /* PIO transfer done */ 447 - host->pio_size -= sgm->consumed; 448 - if (host->pio_size == 0) { 479 + if (s == 0) { 449 480 host->intr_en &= 450 481 ~(MVSD_NOR_TX_AVAIL | MVSD_NOR_TX_FIFO_8W); 451 482 mvsd_write(MVSD_NOR_INTR_EN, host->intr_en); ··· 450 487 } 451 488 dev_dbg(host->dev, "pio %d intr 0x%04x hw_state 0x%04x\n", 452 489 s, intr_status, mvsd_read(MVSD_HW_STATE)); 490 + host->pio_ptr = p; 491 + host->pio_size = s; 453 492 irq_handled = 1; 454 493 } 455 494
+8
drivers/mmc/host/sdhci-of-dwcmshc.c
··· 852 852 853 853 sdhci_reset(host, mask); 854 854 855 + /* The T-Head 1520 SoC does not comply with the SDHCI specification 856 + * regarding the "Software Reset for CMD line should clear 'Command 857 + * Complete' in the Normal Interrupt Status Register." Clear the bit 858 + * here to compensate for this quirk. 859 + */ 860 + if (mask & SDHCI_RESET_CMD) 861 + sdhci_writel(host, SDHCI_INT_RESPONSE, SDHCI_INT_STATUS); 862 + 855 863 if (priv->flags & FLAG_IO_FIXED_1V8) { 856 864 ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); 857 865 if (!(ctrl_2 & SDHCI_CTRL_VDD_180)) {
+1 -1
drivers/net/dsa/mv88e6xxx/chip.c
··· 6360 6360 .invalid_port_mask = BIT(1) | BIT(2) | BIT(8), 6361 6361 .num_internal_phys = 5, 6362 6362 .internal_phys_offset = 3, 6363 - .max_vid = 4095, 6363 + .max_vid = 8191, 6364 6364 .max_sid = 63, 6365 6365 .port_base_addr = 0x0, 6366 6366 .phy_base_addr = 0x0,
-1
drivers/net/dsa/vitesse-vsc73xx-core.c
··· 851 851 852 852 dev_info(vsc->dev, "set up the switch\n"); 853 853 854 - ds->untag_bridge_pvid = true; 855 854 ds->max_num_bridges = DSA_TAG_8021Q_MAX_NUM_BRIDGES; 856 855 ds->fdb_isolation = true; 857 856
+2 -1
drivers/net/ethernet/aeroflex/greth.c
··· 484 484 485 485 if (unlikely(skb->len > MAX_FRAME_SIZE)) { 486 486 dev->stats.tx_errors++; 487 - goto out; 487 + goto len_error; 488 488 } 489 489 490 490 /* Save skb pointer. */ ··· 575 575 map_error: 576 576 if (net_ratelimit()) 577 577 dev_warn(greth->dev, "Could not create TX DMA mapping\n"); 578 + len_error: 578 579 dev_kfree_skb(skb); 579 580 out: 580 581 return err;
+1
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
··· 322 322 } 323 323 /* Rewind so we do not have a hole */ 324 324 spb_index = intf->tx_spb_index; 325 + dev_kfree_skb(skb); 325 326 return NETDEV_TX_OK; 326 327 } 327 328
+1
drivers/net/ethernet/broadcom/bcmsysport.c
··· 1359 1359 netif_err(priv, tx_err, dev, "DMA map failed at %p (len=%d)\n", 1360 1360 skb->data, skb_len); 1361 1361 ret = NETDEV_TX_OK; 1362 + dev_kfree_skb_any(skb); 1362 1363 goto out; 1363 1364 } 1364 1365
+11 -3
drivers/net/ethernet/cadence/macb_main.c
··· 930 930 return ret; 931 931 } 932 932 933 - if (of_phy_is_fixed_link(np)) 934 - return mdiobus_register(bp->mii_bus); 935 - 936 933 /* Only create the PHY from the device tree if at least one PHY is 937 934 * described. Otherwise scan the entire MDIO bus. We do this to support 938 935 * old device tree that did not follow the best practices and did not ··· 950 953 951 954 static int macb_mii_init(struct macb *bp) 952 955 { 956 + struct device_node *child, *np = bp->pdev->dev.of_node; 953 957 int err = -ENXIO; 958 + 959 + /* With fixed-link, we don't need to register the MDIO bus, 960 + * except if we have a child named "mdio" in the device tree. 961 + * In that case, some devices may be attached to the MACB's MDIO bus. 962 + */ 963 + child = of_get_child_by_name(np, "mdio"); 964 + if (child) 965 + of_node_put(child); 966 + else if (of_phy_is_fixed_link(np)) 967 + return macb_mii_probe(bp->dev); 954 968 955 969 /* Enable management port */ 956 970 macb_writel(bp, NCR, MACB_BIT(MPE));
+43 -13
drivers/net/ethernet/freescale/enetc/enetc.c
··· 902 902 903 903 if (unlikely(tx_frm_cnt && netif_carrier_ok(ndev) && 904 904 __netif_subqueue_stopped(ndev, tx_ring->index) && 905 + !test_bit(ENETC_TX_DOWN, &priv->flags) && 905 906 (enetc_bd_unused(tx_ring) >= ENETC_TXBDS_MAX_NEEDED))) { 906 907 netif_wake_subqueue(ndev, tx_ring->index); 907 908 } ··· 1378 1377 int xdp_tx_bd_cnt, i, k; 1379 1378 int xdp_tx_frm_cnt = 0; 1380 1379 1380 + if (unlikely(test_bit(ENETC_TX_DOWN, &priv->flags))) 1381 + return -ENETDOWN; 1382 + 1381 1383 enetc_lock_mdio(); 1382 1384 1383 1385 tx_ring = priv->xdp_tx_ring[smp_processor_id()]; ··· 1525 1521 &rx_ring->rx_swbd[rx_ring_first]); 1526 1522 enetc_bdr_idx_inc(rx_ring, &rx_ring_first); 1527 1523 } 1528 - rx_ring->stats.xdp_drops++; 1529 1524 } 1530 1525 1531 1526 static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring, ··· 1589 1586 fallthrough; 1590 1587 case XDP_DROP: 1591 1588 enetc_xdp_drop(rx_ring, orig_i, i); 1589 + rx_ring->stats.xdp_drops++; 1592 1590 break; 1593 1591 case XDP_PASS: 1594 1592 rxbd = orig_rxbd; ··· 1606 1602 break; 1607 1603 case XDP_TX: 1608 1604 tx_ring = priv->xdp_tx_ring[rx_ring->index]; 1605 + if (unlikely(test_bit(ENETC_TX_DOWN, &priv->flags))) { 1606 + enetc_xdp_drop(rx_ring, orig_i, i); 1607 + tx_ring->stats.xdp_tx_drops++; 1608 + break; 1609 + } 1610 + 1609 1611 xdp_tx_bd_cnt = enetc_rx_swbd_to_xdp_tx_swbd(xdp_tx_arr, 1610 1612 rx_ring, 1611 1613 orig_i, i); ··· 2233 2223 enetc_rxbdr_wr(hw, idx, ENETC_RBMR, rbmr); 2234 2224 } 2235 2225 2236 - static void enetc_enable_bdrs(struct enetc_ndev_priv *priv) 2226 + static void enetc_enable_rx_bdrs(struct enetc_ndev_priv *priv) 2227 + { 2228 + struct enetc_hw *hw = &priv->si->hw; 2229 + int i; 2230 + 2231 + for (i = 0; i < priv->num_rx_rings; i++) 2232 + enetc_enable_rxbdr(hw, priv->rx_ring[i]); 2233 + } 2234 + 2235 + static void enetc_enable_tx_bdrs(struct enetc_ndev_priv *priv) 2237 2236 { 2238 2237 struct enetc_hw *hw = &priv->si->hw; 2239 2238 int i; 2240 2239 2241 2240 for (i = 0; i < priv->num_tx_rings; i++) 2242 2241 enetc_enable_txbdr(hw, priv->tx_ring[i]); 2243 - 2244 - for (i = 0; i < priv->num_rx_rings; i++) 2245 - enetc_enable_rxbdr(hw, priv->rx_ring[i]); 2246 2242 } 2247 2243 2248 2244 static void enetc_disable_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring) ··· 2267 2251 enetc_txbdr_wr(hw, idx, ENETC_TBMR, 0); 2268 2252 } 2269 2253 2270 - static void enetc_disable_bdrs(struct enetc_ndev_priv *priv) 2254 + static void enetc_disable_rx_bdrs(struct enetc_ndev_priv *priv) 2255 + { 2256 + struct enetc_hw *hw = &priv->si->hw; 2257 + int i; 2258 + 2259 + for (i = 0; i < priv->num_rx_rings; i++) 2260 + enetc_disable_rxbdr(hw, priv->rx_ring[i]); 2261 + } 2262 + 2263 + static void enetc_disable_tx_bdrs(struct enetc_ndev_priv *priv) 2271 2264 { 2272 2265 struct enetc_hw *hw = &priv->si->hw; 2273 2266 int i; 2274 2267 2275 2268 for (i = 0; i < priv->num_tx_rings; i++) 2276 2269 enetc_disable_txbdr(hw, priv->tx_ring[i]); 2277 - 2278 - for (i = 0; i < priv->num_rx_rings; i++) 2279 - enetc_disable_rxbdr(hw, priv->rx_ring[i]); 2280 2270 } 2281 2271 2282 2272 static void enetc_wait_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring) ··· 2482 2460 enable_irq(irq); 2483 2461 } 2484 2462 2485 - enetc_enable_bdrs(priv); 2463 + enetc_enable_tx_bdrs(priv); 2464 + 2465 + enetc_enable_rx_bdrs(priv); 2486 2466 2487 2467 netif_tx_start_all_queues(ndev); 2468 + 2469 + clear_bit(ENETC_TX_DOWN, &priv->flags); 2488 2470 } 2489 2471 EXPORT_SYMBOL_GPL(enetc_start); 2490 2472 ··· 2546 2520 struct enetc_ndev_priv *priv = netdev_priv(ndev); 2547 2521 int i; 2548 2522 2523 + set_bit(ENETC_TX_DOWN, &priv->flags); 2524 + 2549 2525 netif_tx_stop_all_queues(ndev); 2550 2526 2551 - enetc_disable_bdrs(priv); 2527 + enetc_disable_rx_bdrs(priv); 2528 + 2529 + enetc_wait_bdrs(priv); 2530 + 2531 + enetc_disable_tx_bdrs(priv); 2552 2532 2553 2533 for (i = 0; i < priv->bdr_int_num; i++) { 2554 2534 int irq = pci_irq_vector(priv->si->pdev, ··· 2564 2532 napi_synchronize(&priv->int_vector[i]->napi); 2565 2533 napi_disable(&priv->int_vector[i]->napi); 2566 2534 } 2567 - 2568 - enetc_wait_bdrs(priv); 2569 2535 2570 2536 enetc_clear_interrupts(priv); 2571 2537 }
+1
drivers/net/ethernet/freescale/enetc/enetc.h
··· 325 325 326 326 enum enetc_flags_bit { 327 327 ENETC_TX_ONESTEP_TSTAMP_IN_PROGRESS = 0, 328 + ENETC_TX_DOWN, 328 329 }; 329 330 330 331 /* interrupt coalescing modes */
+2 -2
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
··· 2411 2411 NIX_AF_TL3_TL2X_LINKX_CFG(tl2_tl3_link_schq, link)); 2412 2412 if (!(cfg & BIT_ULL(12))) 2413 2413 continue; 2414 - bmap |= (1 << i); 2414 + bmap |= BIT_ULL(i); 2415 2415 cfg &= ~BIT_ULL(12); 2416 2416 rvu_write64(rvu, blkaddr, 2417 2417 NIX_AF_TL3_TL2X_LINKX_CFG(tl2_tl3_link_schq, link), cfg); ··· 2432 2432 2433 2433 /* Set NIX_AF_TL3_TL2_LINKX_CFG[ENA] for the TL3/TL2 queue */ 2434 2434 for (i = 0; i < (rvu->hw->cgx_links + rvu->hw->lbk_links); i++) { 2435 - if (!(bmap & (1 << i))) 2435 + if (!(bmap & BIT_ULL(i))) 2436 2436 continue; 2437 2437 cfg = rvu_read64(rvu, blkaddr, 2438 2438 NIX_AF_TL3_TL2X_LINKX_CFG(tl2_tl3_link_schq, link));
+1 -1
drivers/net/ethernet/mediatek/mtk_eth_soc.c
··· 1171 1171 if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr))) 1172 1172 return -ENOMEM; 1173 1173 1174 - for (i = 0; i < cnt; i++) { 1174 + for (i = 0; i < len; i++) { 1175 1175 struct mtk_tx_dma_v2 *txd; 1176 1176 1177 1177 txd = eth->scratch_ring + (j * MTK_FQ_DMA_LENGTH + i) * soc->tx.desc_size;
+6 -2
drivers/net/ethernet/mellanox/mlx5/core/cmd.c
··· 1765 1765 } 1766 1766 } 1767 1767 1768 + #define MLX5_MAX_MANAGE_PAGES_CMD_ENT 1 1769 + #define MLX5_CMD_MASK ((1UL << (cmd->vars.max_reg_cmds + \ 1770 + MLX5_MAX_MANAGE_PAGES_CMD_ENT)) - 1) 1771 + 1768 1772 static void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev) 1769 1773 { 1770 1774 struct mlx5_cmd *cmd = &dev->cmd; ··· 1780 1776 /* wait for pending handlers to complete */ 1781 1777 mlx5_eq_synchronize_cmd_irq(dev); 1782 1778 spin_lock_irqsave(&dev->cmd.alloc_lock, flags); 1783 - vector = ~dev->cmd.vars.bitmask & ((1ul << (1 << dev->cmd.vars.log_sz)) - 1); 1779 + vector = ~dev->cmd.vars.bitmask & MLX5_CMD_MASK; 1784 1780 if (!vector) 1785 1781 goto no_trig; 1786 1782 ··· 2365 2361 2366 2362 cmd->state = MLX5_CMDIF_STATE_DOWN; 2367 2363 cmd->vars.max_reg_cmds = (1 << cmd->vars.log_sz) - 1; 2368 - cmd->vars.bitmask = (1UL << cmd->vars.max_reg_cmds) - 1; 2364 + cmd->vars.bitmask = MLX5_CMD_MASK; 2369 2365 2370 2366 sema_init(&cmd->vars.sem, cmd->vars.max_reg_cmds); 2371 2367 sema_init(&cmd->vars.pages_sem, 1);
+3 -1
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 6509 6509 mlx5e_dcbnl_delete_app(priv); 6510 6510 unregister_netdev(priv->netdev); 6511 6511 _mlx5e_suspend(adev, false); 6512 - priv->profile->cleanup(priv); 6512 + /* Avoid cleanup if profile rollback failed. */ 6513 + if (priv->profile) 6514 + priv->profile->cleanup(priv); 6513 6515 mlx5e_destroy_netdev(priv); 6514 6516 mlx5e_devlink_port_unregister(mlx5e_dev); 6515 6517 mlx5e_destroy_devlink(mlx5e_dev);
+6
drivers/net/ethernet/mellanox/mlx5/core/eq.c
··· 1061 1061 struct mlx5_eq_comp *eq; 1062 1062 int ret = 0; 1063 1063 1064 + if (vecidx >= table->max_comp_eqs) { 1065 + mlx5_core_dbg(dev, "Requested vector index %u should be less than %u", 1066 + vecidx, table->max_comp_eqs); 1067 + return -EINVAL; 1068 + } 1069 + 1064 1070 mutex_lock(&table->comp_lock); 1065 1071 eq = xa_load(&table->comp_eqs, vecidx); 1066 1072 if (eq) {
+1 -3
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_bwc.c
··· 691 691 static int 692 692 hws_bwc_matcher_rehash_size(struct mlx5hws_bwc_matcher *bwc_matcher) 693 693 { 694 - u32 num_of_rules; 695 694 int ret; 696 695 697 696 /* If the current matcher size is already at its max size, we can't ··· 704 705 * Need to check again if we really need rehash. 705 706 * If the reason for rehash was size, but not any more - skip rehash. 706 707 */ 707 - num_of_rules = __atomic_load_n(&bwc_matcher->num_of_rules, __ATOMIC_RELAXED); 708 - if (!hws_bwc_matcher_rehash_size_needed(bwc_matcher, num_of_rules)) 708 + if (!hws_bwc_matcher_rehash_size_needed(bwc_matcher, bwc_matcher->num_of_rules)) 709 709 return 0; 710 710 711 711 /* Now we're done all the checking - do the rehash:
+1
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_context.h
··· 46 46 struct mlx5hws_send_engine *send_queue; 47 47 size_t queues; 48 48 struct mutex *bwc_send_queue_locks; /* protect BWC queues */ 49 + struct lock_class_key *bwc_lock_class_keys; 49 50 struct list_head tbl_list; 50 51 struct mlx5hws_context_debug_info debug_info; 51 52 struct xarray peer_ctx_xa;
+2 -2
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_definer.c
··· 1925 1925 ret = hws_definer_conv_match_params_to_hl(ctx, mt, match_hl); 1926 1926 if (ret) { 1927 1927 mlx5hws_err(ctx, "Failed to convert items to header layout\n"); 1928 - goto free_fc; 1928 + goto free_match_hl; 1929 1929 } 1930 1930 1931 1931 /* Find the match definer layout for header layout match union */ ··· 1946 1946 1947 1947 free_fc: 1948 1948 kfree(mt->fc); 1949 - 1949 + free_match_hl: 1950 1950 kfree(match_hl); 1951 1951 return ret; 1952 1952 }
+19 -3
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_send.c
··· 941 941 942 942 static void hws_send_queues_bwc_locks_destroy(struct mlx5hws_context *ctx) 943 943 { 944 - int bwc_queues = ctx->queues - 1; 944 + int bwc_queues = mlx5hws_bwc_queues(ctx); 945 945 int i; 946 946 947 947 if (!mlx5hws_context_bwc_supported(ctx)) 948 948 return; 949 949 950 - for (i = 0; i < bwc_queues; i++) 950 + for (i = 0; i < bwc_queues; i++) { 951 951 mutex_destroy(&ctx->bwc_send_queue_locks[i]); 952 + lockdep_unregister_key(ctx->bwc_lock_class_keys + i); 953 + } 954 + 955 + kfree(ctx->bwc_lock_class_keys); 952 956 kfree(ctx->bwc_send_queue_locks); 953 957 } 954 958 ··· 981 977 if (!ctx->bwc_send_queue_locks) 982 978 return -ENOMEM; 983 979 984 - for (i = 0; i < bwc_queues; i++) 980 + ctx->bwc_lock_class_keys = kcalloc(bwc_queues, 981 + sizeof(*ctx->bwc_lock_class_keys), 982 + GFP_KERNEL); 983 + if (!ctx->bwc_lock_class_keys) 984 + goto err_lock_class_keys; 985 + 986 + for (i = 0; i < bwc_queues; i++) { 985 987 mutex_init(&ctx->bwc_send_queue_locks[i]); 988 + lockdep_register_key(ctx->bwc_lock_class_keys + i); 989 + } 986 990 987 991 return 0; 992 + 993 + err_lock_class_keys: 994 + kfree(ctx->bwc_send_queue_locks); 995 + return -ENOMEM; 988 996 } 989 997 990 998 int mlx5hws_send_queues_open(struct mlx5hws_context *ctx,
+14 -21
drivers/net/ethernet/microchip/lan743x_ptp.c
··· 401 401 u32 nano_seconds = 0; 402 402 u32 seconds = 0; 403 403 404 - if (ts) { 405 - if (ts->tv_sec > 0xFFFFFFFFLL || 406 - ts->tv_sec < 0) { 407 - netif_warn(adapter, drv, adapter->netdev, 408 - "ts->tv_sec out of range, %lld\n", 409 - ts->tv_sec); 410 - return -ERANGE; 411 - } 412 - if (ts->tv_nsec >= 1000000000L || 413 - ts->tv_nsec < 0) { 414 - netif_warn(adapter, drv, adapter->netdev, 415 - "ts->tv_nsec out of range, %ld\n", 416 - ts->tv_nsec); 417 - return -ERANGE; 418 - } 419 - seconds = ts->tv_sec; 420 - nano_seconds = ts->tv_nsec; 421 - lan743x_ptp_clock_set(adapter, seconds, nano_seconds, 0); 422 - } else { 423 - netif_warn(adapter, drv, adapter->netdev, "ts == NULL\n"); 424 - return -EINVAL; 404 + if (ts->tv_sec > 0xFFFFFFFFLL) { 405 + netif_warn(adapter, drv, adapter->netdev, 406 + "ts->tv_sec out of range, %lld\n", 407 + ts->tv_sec); 408 + return -ERANGE; 425 409 } 410 + if (ts->tv_nsec < 0) { 411 + netif_warn(adapter, drv, adapter->netdev, 412 + "ts->tv_nsec out of range, %ld\n", 413 + ts->tv_nsec); 414 + return -ERANGE; 415 + } 416 + seconds = ts->tv_sec; 417 + nano_seconds = ts->tv_nsec; 418 + lan743x_ptp_clock_set(adapter, seconds, nano_seconds, 0); 426 419 427 420 return 0; 428 421 }
+6 -6
drivers/net/ethernet/microchip/sparx5/sparx5_mirror.c
··· 31 31 /* Add port to mirror (only front ports) */ 32 32 static void sparx5_mirror_port_add(struct sparx5 *sparx5, u32 idx, u32 portno) 33 33 { 34 - u32 val, reg = portno; 34 + u64 reg = portno; 35 + u32 val; 35 36 36 - reg = portno / BITS_PER_BYTE; 37 - val = BIT(portno % BITS_PER_BYTE); 37 + val = BIT(do_div(reg, 32)); 38 38 39 39 if (reg == 0) 40 40 return spx5_rmw(val, val, sparx5, ANA_AC_PROBE_PORT_CFG(idx)); ··· 45 45 /* Delete port from mirror (only front ports) */ 46 46 static void sparx5_mirror_port_del(struct sparx5 *sparx5, u32 idx, u32 portno) 47 47 { 48 - u32 val, reg = portno; 48 + u64 reg = portno; 49 + u32 val; 49 50 50 - reg = portno / BITS_PER_BYTE; 51 - val = BIT(portno % BITS_PER_BYTE); 51 + val = BIT(do_div(reg, 32)); 52 52 53 53 if (reg == 0) 54 54 return spx5_rmw(0, val, sparx5, ANA_AC_PROBE_PORT_CFG(idx));
+2
drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c
··· 1444 1444 1445 1445 ret = vcap_del_rule(&test_vctrl, &test_netdev, id); 1446 1446 KUNIT_EXPECT_EQ(test, 0, ret); 1447 + 1448 + vcap_free_rule(rule); 1447 1449 } 1448 1450 1449 1451 static void vcap_api_set_rule_counter_test(struct kunit *test)
+12 -13
drivers/net/ethernet/renesas/ravb_main.c
··· 1745 1745 struct ravb_private *priv = netdev_priv(ndev); 1746 1746 const struct ravb_hw_info *hw_info = priv->info; 1747 1747 1748 - info->so_timestamping = 1749 - SOF_TIMESTAMPING_TX_SOFTWARE | 1750 - SOF_TIMESTAMPING_TX_HARDWARE | 1751 - SOF_TIMESTAMPING_RX_HARDWARE | 1752 - SOF_TIMESTAMPING_RAW_HARDWARE; 1753 - info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); 1754 - info->rx_filters = 1755 - (1 << HWTSTAMP_FILTER_NONE) | 1756 - (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) | 1757 - (1 << HWTSTAMP_FILTER_ALL); 1758 - if (hw_info->gptp || hw_info->ccc_gac) 1748 + if (hw_info->gptp || hw_info->ccc_gac) { 1749 + info->so_timestamping = 1750 + SOF_TIMESTAMPING_TX_SOFTWARE | 1751 + SOF_TIMESTAMPING_TX_HARDWARE | 1752 + SOF_TIMESTAMPING_RX_HARDWARE | 1753 + SOF_TIMESTAMPING_RAW_HARDWARE; 1754 + info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); 1755 + info->rx_filters = 1756 + (1 << HWTSTAMP_FILTER_NONE) | 1757 + (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) | 1758 + (1 << HWTSTAMP_FILTER_ALL); 1759 1759 info->phc_index = ptp_clock_index(priv->ptp.clock); 1760 - else 1761 - info->phc_index = 0; 1760 + } 1762 1761 1763 1762 return 0; 1764 1763 }
+1
drivers/net/ethernet/renesas/rtsn.c
··· 1057 1057 if (skb->len >= TX_DS) { 1058 1058 priv->stats.tx_dropped++; 1059 1059 priv->stats.tx_errors++; 1060 + dev_kfree_skb_any(skb); 1060 1061 goto out; 1061 1062 } 1062 1063
+14 -4
drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c
··· 127 127 value &= ~XPCS_WRAP_UPHY_RX_CONTROL_AUX_RX_IDDQ; 128 128 writel(value, mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 129 129 130 + usleep_range(10, 20); /* 50ns min delay needed as per HW design */ 130 131 value = readl(mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 131 132 value &= ~XPCS_WRAP_UPHY_RX_CONTROL_RX_SLEEP; 132 133 writel(value, mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 133 134 135 + usleep_range(10, 20); /* 500ns min delay needed as per HW design */ 134 136 value = readl(mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 135 137 value |= XPCS_WRAP_UPHY_RX_CONTROL_RX_CAL_EN; 136 138 writel(value, mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); ··· 145 143 return err; 146 144 } 147 145 146 + usleep_range(10, 20); /* 50ns min delay needed as per HW design */ 148 147 value = readl(mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 149 148 value |= XPCS_WRAP_UPHY_RX_CONTROL_RX_DATA_EN; 150 149 writel(value, mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 151 150 152 151 value = readl(mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 152 + value &= ~XPCS_WRAP_UPHY_RX_CONTROL_RX_PCS_PHY_RDY; 153 + writel(value, mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 154 + 155 + usleep_range(10, 20); /* 50ns min delay needed as per HW design */ 156 + value = readl(mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 153 157 value |= XPCS_WRAP_UPHY_RX_CONTROL_RX_CDR_RESET; 154 158 writel(value, mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 155 159 156 - value = readl(mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 157 - value &= ~XPCS_WRAP_UPHY_RX_CONTROL_RX_CDR_RESET; 158 - writel(value, mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 159 - 160 + usleep_range(10, 20); /* 50ns min delay needed as per HW design */ 160 161 value = readl(mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 161 162 value |= XPCS_WRAP_UPHY_RX_CONTROL_RX_PCS_PHY_RDY; 163 + writel(value, mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 164 + 165 + msleep(30); /* 30ms delay needed as per HW design */ 166 + value = readl(mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 167 + value &= ~XPCS_WRAP_UPHY_RX_CONTROL_RX_CDR_RESET; 162 168 writel(value, mgbe->xpcs + XPCS_WRAP_UPHY_RX_CONTROL); 163 169 164 170 err = readl_poll_timeout(mgbe->xpcs + XPCS_WRAP_IRQ_STATUS, value,
+2
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
··· 1051 1051 if (net_ratelimit()) 1052 1052 netdev_err(ndev, "TX DMA mapping error\n"); 1053 1053 ndev->stats.tx_dropped++; 1054 + dev_kfree_skb_any(skb); 1054 1055 return NETDEV_TX_OK; 1055 1056 } 1056 1057 desc_set_phys_addr(lp, phys, cur_p); ··· 1072 1071 ndev->stats.tx_dropped++; 1073 1072 axienet_free_tx_chain(lp, orig_tail_ptr, ii + 1, 1074 1073 true, NULL, 0); 1074 + dev_kfree_skb_any(skb); 1075 1075 return NETDEV_TX_OK; 1076 1076 } 1077 1077 desc_set_phys_addr(lp, phys, cur_p);
-18
drivers/net/macsec.c
··· 154 154 return sa; 155 155 } 156 156 157 - static struct macsec_rx_sa *macsec_active_rxsa_get(struct macsec_rx_sc *rx_sc) 158 - { 159 - struct macsec_rx_sa *sa = NULL; 160 - int an; 161 - 162 - for (an = 0; an < MACSEC_NUM_AN; an++) { 163 - sa = macsec_rxsa_get(rx_sc->sa[an]); 164 - if (sa) 165 - break; 166 - } 167 - return sa; 168 - } 169 - 170 157 static void free_rx_sc_rcu(struct rcu_head *head) 171 158 { 172 159 struct macsec_rx_sc *rx_sc = container_of(head, struct macsec_rx_sc, rcu_head); ··· 1195 1208 /* If validateFrames is Strict or the C bit in the 1196 1209 * SecTAG is set, discard 1197 1210 */ 1198 - struct macsec_rx_sa *active_rx_sa = macsec_active_rxsa_get(rx_sc); 1199 1211 if (hdr->tci_an & MACSEC_TCI_C || 1200 1212 secy->validate_frames == MACSEC_VALIDATE_STRICT) { 1201 1213 u64_stats_update_begin(&rxsc_stats->syncp); 1202 1214 rxsc_stats->stats.InPktsNotUsingSA++; 1203 1215 u64_stats_update_end(&rxsc_stats->syncp); 1204 1216 DEV_STATS_INC(secy->netdev, rx_errors); 1205 - if (active_rx_sa) 1206 - this_cpu_inc(active_rx_sa->stats->InPktsNotUsingSA); 1207 1217 goto drop_nosa; 1208 1218 } 1209 1219 ··· 1210 1226 u64_stats_update_begin(&rxsc_stats->syncp); 1211 1227 rxsc_stats->stats.InPktsUnusedSA++; 1212 1228 u64_stats_update_end(&rxsc_stats->syncp); 1213 - if (active_rx_sa) 1214 - this_cpu_inc(active_rx_sa->stats->InPktsUnusedSA); 1215 1229 goto deliver; 1216 1230 } 1217 1231
+1
drivers/net/mdio/mdio-bcm-unimac.c
··· 337 337 { .compatible = "brcm,asp-v2.2-mdio", }, 338 338 { .compatible = "brcm,asp-v2.1-mdio", }, 339 339 { .compatible = "brcm,asp-v2.0-mdio", }, 340 + { .compatible = "brcm,bcm6846-mdio", }, 340 341 { .compatible = "brcm,genet-mdio-v5", }, 341 342 { .compatible = "brcm,genet-mdio-v4", }, 342 343 { .compatible = "brcm,genet-mdio-v3", },
+9 -6
drivers/net/netdevsim/dev.c
··· 836 836 nsim_dev = nsim_trap_data->nsim_dev; 837 837 838 838 if (!devl_trylock(priv_to_devlink(nsim_dev))) { 839 - schedule_delayed_work(&nsim_dev->trap_data->trap_report_dw, 1); 839 + queue_delayed_work(system_unbound_wq, 840 + &nsim_dev->trap_data->trap_report_dw, 1); 840 841 return; 841 842 } 842 843 ··· 849 848 continue; 850 849 851 850 nsim_dev_trap_report(nsim_dev_port); 851 + cond_resched(); 852 852 } 853 853 devl_unlock(priv_to_devlink(nsim_dev)); 854 - 855 - schedule_delayed_work(&nsim_dev->trap_data->trap_report_dw, 856 - msecs_to_jiffies(NSIM_TRAP_REPORT_INTERVAL_MS)); 854 + queue_delayed_work(system_unbound_wq, 855 + &nsim_dev->trap_data->trap_report_dw, 856 + msecs_to_jiffies(NSIM_TRAP_REPORT_INTERVAL_MS)); 857 857 } 858 858 859 859 static int nsim_dev_traps_init(struct devlink *devlink) ··· 909 907 910 908 INIT_DELAYED_WORK(&nsim_dev->trap_data->trap_report_dw, 911 909 nsim_dev_trap_report_work); 912 - schedule_delayed_work(&nsim_dev->trap_data->trap_report_dw, 913 - msecs_to_jiffies(NSIM_TRAP_REPORT_INTERVAL_MS)); 910 + queue_delayed_work(system_unbound_wq, 911 + &nsim_dev->trap_data->trap_report_dw, 912 + msecs_to_jiffies(NSIM_TRAP_REPORT_INTERVAL_MS)); 914 913 915 914 return 0; 916 915
+1
drivers/net/usb/usbnet.c
··· 1870 1870 * may trigger an error resubmitting itself and, worse, 1871 1871 * schedule a timer. So we kill it all just in case. 1872 1872 */ 1873 + usbnet_mark_going_away(dev); 1873 1874 cancel_work_sync(&dev->kevent); 1874 1875 del_timer_sync(&dev->delay); 1875 1876 free_netdev(net);
+1 -1
drivers/net/vmxnet3/vmxnet3_xdp.c
··· 148 148 } else { /* XDP buffer from page pool */ 149 149 page = virt_to_page(xdpf->data); 150 150 tbi->dma_addr = page_pool_get_dma_addr(page) + 151 - VMXNET3_XDP_HEADROOM; 151 + (xdpf->data - (void *)xdpf); 152 152 dma_sync_single_for_device(&adapter->pdev->dev, 153 153 tbi->dma_addr, buf_size, 154 154 DMA_TO_DEVICE);
+15
drivers/of/of_kunit_helpers.c
··· 10 10 #include <kunit/test.h> 11 11 #include <kunit/resource.h> 12 12 13 + #include "of_private.h" 14 + 15 + /** 16 + * of_root_kunit_skip() - Skip test if the root node isn't populated 17 + * @test: test to skip if the root node isn't populated 18 + */ 19 + void of_root_kunit_skip(struct kunit *test) 20 + { 21 + if (IS_ENABLED(CONFIG_ARM64) && IS_ENABLED(CONFIG_ACPI) && !of_root) 22 + kunit_skip(test, "arm64+acpi doesn't populate a root node"); 23 + } 24 + EXPORT_SYMBOL_GPL(of_root_kunit_skip); 25 + 13 26 #if defined(CONFIG_OF_OVERLAY) && defined(CONFIG_OF_EARLY_FLATTREE) 14 27 15 28 static void of_overlay_fdt_apply_kunit_exit(void *ovcs_id) ··· 48 35 { 49 36 int ret; 50 37 int *copy_id; 38 + 39 + of_root_kunit_skip(test); 51 40 52 41 copy_id = kunit_kmalloc(test, sizeof(*copy_id), GFP_KERNEL); 53 42 if (!copy_id)
+3
drivers/of/of_private.h
··· 42 42 extern struct list_head aliases_lookup; 43 43 extern struct kset *of_kset; 44 44 45 + struct kunit; 46 + extern void of_root_kunit_skip(struct kunit *test); 47 + 45 48 #if defined(CONFIG_OF_DYNAMIC) 46 49 extern int of_property_notify(int action, struct device_node *np, 47 50 struct property *prop, struct property *old_prop);
+3
drivers/of/of_test.c
··· 7 7 8 8 #include <kunit/test.h> 9 9 10 + #include "of_private.h" 11 + 10 12 /* 11 13 * Test that the root node "/" can be found by path. 12 14 */ ··· 38 36 39 37 static int of_dtb_test_init(struct kunit *test) 40 38 { 39 + of_root_kunit_skip(test); 41 40 if (!IS_ENABLED(CONFIG_OF_EARLY_FLATTREE)) 42 41 kunit_skip(test, "requires CONFIG_OF_EARLY_FLATTREE"); 43 42
+4 -1
drivers/of/overlay_test.c
··· 11 11 #include <kunit/of.h> 12 12 #include <kunit/test.h> 13 13 14 + #include "of_private.h" 15 + 14 16 static const char * const kunit_node_name = "kunit-test"; 15 17 static const char * const kunit_compatible = "test,empty"; 16 18 ··· 64 62 struct device *dev; 65 63 struct device_node *np; 66 64 65 + of_root_kunit_skip(test); 67 66 if (!IS_ENABLED(CONFIG_OF_EARLY_FLATTREE)) 68 67 kunit_skip(test, "requires CONFIG_OF_EARLY_FLATTREE for root node"); 69 68 ··· 76 73 77 74 np = of_find_node_by_name(NULL, kunit_node_name); 78 75 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, np); 79 - of_node_put_kunit(test, np); 76 + of_node_put_kunit(&fake, np); 80 77 81 78 pdev = of_find_device_by_node(np); 82 79 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev);
+3 -1
drivers/opp/core.c
··· 2630 2630 2631 2631 /* Attach genpds */ 2632 2632 if (config->genpd_names) { 2633 - if (config->required_devs) 2633 + if (config->required_devs) { 2634 + ret = -EINVAL; 2634 2635 goto err; 2636 + } 2635 2637 2636 2638 ret = _opp_attach_genpd(opp_table, dev, config->genpd_names, 2637 2639 config->virt_devs);
+1 -1
drivers/pmdomain/qcom/cpr.c
··· 1052 1052 of_parse_phandle(child_np, "required-opps", 0); 1053 1053 1054 1054 if (child_req_np == ref_np) { 1055 - u64 rate; 1055 + u64 rate = 0; 1056 1056 1057 1057 of_property_read_u64(child_np, "opp-hz", &rate); 1058 1058 return (unsigned long) rate;
+1
drivers/powercap/intel_rapl_msr.c
··· 147 147 X86_MATCH_VFM(INTEL_RAPTORLAKE_P, NULL), 148 148 X86_MATCH_VFM(INTEL_METEORLAKE, NULL), 149 149 X86_MATCH_VFM(INTEL_METEORLAKE_L, NULL), 150 + X86_MATCH_VFM(INTEL_ARROWLAKE_U, NULL), 150 151 {} 151 152 }; 152 153
+15 -4
drivers/powercap/intel_rapl_tpmi.c
··· 15 15 #include <linux/module.h> 16 16 #include <linux/slab.h> 17 17 18 - #define TPMI_RAPL_VERSION 1 18 + #define TPMI_RAPL_MAJOR_VERSION 0 19 + #define TPMI_RAPL_MINOR_VERSION 1 19 20 20 21 /* 1 header + 10 registers + 5 reserved. 8 bytes for each. */ 21 22 #define TPMI_RAPL_DOMAIN_SIZE 128 ··· 155 154 tpmi_domain_size = tpmi_domain_header >> 16 & 0xff; 156 155 tpmi_domain_flags = tpmi_domain_header >> 32 & 0xffff; 157 156 158 - if (tpmi_domain_version != TPMI_RAPL_VERSION) { 159 - pr_warn(FW_BUG "Unsupported version:%d\n", tpmi_domain_version); 157 + if (tpmi_domain_version == TPMI_VERSION_INVALID) { 158 + pr_warn(FW_BUG "Invalid version\n"); 160 159 return -ENODEV; 161 160 } 161 + 162 + if (TPMI_MAJOR_VERSION(tpmi_domain_version) != TPMI_RAPL_MAJOR_VERSION) { 163 + pr_warn(FW_BUG "Unsupported major version:%ld\n", 164 + TPMI_MAJOR_VERSION(tpmi_domain_version)); 165 + return -ENODEV; 166 + } 167 + 168 + if (TPMI_MINOR_VERSION(tpmi_domain_version) > TPMI_RAPL_MINOR_VERSION) 169 + pr_info("Ignore: Unsupported minor version:%ld\n", 170 + TPMI_MINOR_VERSION(tpmi_domain_version)); 162 171 163 172 /* Domain size: in unit of 128 Bytes */ 164 173 if (tpmi_domain_size != 1) { ··· 192 181 pr_warn(FW_BUG "System domain must support Domain Info register\n"); 193 182 return -ENODEV; 194 183 } 195 - tpmi_domain_info = readq(trp->base + offset + TPMI_RAPL_REG_DOMAIN_INFO); 184 + tpmi_domain_info = readq(trp->base + offset + TPMI_RAPL_REG_DOMAIN_INFO * 8); 196 185 if (!(tpmi_domain_info & TPMI_RAPL_DOMAIN_ROOT)) 197 186 return 0; 198 187 domain_type = RAPL_DOMAIN_PLATFORM;
+1 -1
drivers/scsi/fnic/fnic_main.c
··· 830 830 spin_lock_init(&fnic->vlans_lock); 831 831 INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame); 832 832 INIT_WORK(&fnic->event_work, fnic_handle_event); 833 - INIT_WORK(&fnic->flush_work, fnic_flush_tx); 834 833 skb_queue_head_init(&fnic->fip_frame_queue); 835 834 INIT_LIST_HEAD(&fnic->evlist); 836 835 INIT_LIST_HEAD(&fnic->vlans); ··· 947 948 948 949 INIT_WORK(&fnic->link_work, fnic_handle_link); 949 950 INIT_WORK(&fnic->frame_work, fnic_handle_frame); 951 + INIT_WORK(&fnic->flush_work, fnic_flush_tx); 950 952 skb_queue_head_init(&fnic->frame_queue); 951 953 skb_queue_head_init(&fnic->tx_queue); 952 954
+2 -2
drivers/scsi/scsi_transport_fc.c
··· 1250 1250 */ 1251 1251 if (rport->port_state == FC_PORTSTATE_ONLINE) 1252 1252 rport->port_state = port_state; 1253 - else 1253 + else if (port_state != rport->port_state) 1254 1254 return -EINVAL; 1255 1255 } else if (port_state == FC_PORTSTATE_ONLINE) { 1256 1256 /* ··· 1260 1260 */ 1261 1261 if (rport->port_state == FC_PORTSTATE_MARGINAL) 1262 1262 rport->port_state = port_state; 1263 - else 1263 + else if (port_state != rport->port_state) 1264 1264 return -EINVAL; 1265 1265 } else 1266 1266 return -EINVAL;
+1 -1
drivers/scsi/wd33c93.c
··· 831 831 /* construct an IDENTIFY message with correct disconnect bit */ 832 832 833 833 hostdata->outgoing_msg[0] = IDENTIFY(0, cmd->device->lun); 834 - if (scsi_pointer->phase) 834 + if (WD33C93_scsi_pointer(cmd)->phase) 835 835 hostdata->outgoing_msg[0] |= 0x40; 836 836 837 837 if (hostdata->sync_stat[cmd->device->id] == SS_FIRST) {
+1 -1
drivers/target/target_core_user.c
··· 2130 2130 } 2131 2131 2132 2132 ret = genlmsg_multicast_allns(&tcmu_genl_family, skb, 0, 2133 - TCMU_MCGRP_CONFIG, GFP_KERNEL); 2133 + TCMU_MCGRP_CONFIG); 2134 2134 2135 2135 /* Wait during an add as the listener may not be up yet */ 2136 2136 if (ret == 0 ||
-2
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
··· 416 416 if (!pci_info->no_legacy) 417 417 proc_thermal_remove(proc_priv); 418 418 proc_thermal_mmio_remove(pdev, proc_priv); 419 - pci_disable_device(pdev); 420 419 421 420 return ret; 422 421 } ··· 437 438 proc_thermal_mmio_remove(pdev, pci_info->proc_priv); 438 439 if (!pci_info->no_legacy) 439 440 proc_thermal_remove(proc_priv); 440 - pci_disable_device(pdev); 441 441 } 442 442 443 443 #ifdef CONFIG_PM_SLEEP
+24 -46
drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c
··· 13 13 14 14 static const struct rapl_mmio_regs rapl_mmio_default = { 15 15 .reg_unit = 0x5938, 16 - .regs[RAPL_DOMAIN_PACKAGE] = { 0x59a0, 0x593c, 0x58f0, 0, 0x5930}, 16 + .regs[RAPL_DOMAIN_PACKAGE] = { 0x59a0, 0x593c, 0x58f0, 0, 0x5930, 0x59b0}, 17 17 .regs[RAPL_DOMAIN_DRAM] = { 0x58e0, 0x58e8, 0x58ec, 0, 0}, 18 - .limits[RAPL_DOMAIN_PACKAGE] = BIT(POWER_LIMIT2), 18 + .limits[RAPL_DOMAIN_PACKAGE] = BIT(POWER_LIMIT2) | BIT(POWER_LIMIT4), 19 19 .limits[RAPL_DOMAIN_DRAM] = BIT(POWER_LIMIT2), 20 20 }; 21 - 22 - static int rapl_mmio_cpu_online(unsigned int cpu) 23 - { 24 - struct rapl_package *rp; 25 - 26 - /* mmio rapl supports package 0 only for now */ 27 - if (topology_physical_package_id(cpu)) 28 - return 0; 29 - 30 - rp = rapl_find_package_domain_cpuslocked(cpu, &rapl_mmio_priv, true); 31 - if (!rp) { 32 - rp = rapl_add_package_cpuslocked(cpu, &rapl_mmio_priv, true); 33 - if (IS_ERR(rp)) 34 - return PTR_ERR(rp); 35 - } 36 - cpumask_set_cpu(cpu, &rp->cpumask); 37 - return 0; 38 - } 39 - 40 - static int rapl_mmio_cpu_down_prep(unsigned int cpu) 41 - { 42 - struct rapl_package *rp; 43 - int lead_cpu; 44 - 45 - rp = rapl_find_package_domain_cpuslocked(cpu, &rapl_mmio_priv, true); 46 - if (!rp) 47 - return 0; 48 - 49 - cpumask_clear_cpu(cpu, &rp->cpumask); 50 - lead_cpu = cpumask_first(&rp->cpumask); 51 - if (lead_cpu >= nr_cpu_ids) 52 - rapl_remove_package_cpuslocked(rp); 53 - else if (rp->lead_cpu == cpu) 54 - rp->lead_cpu = lead_cpu; 55 - return 0; 56 - } 57 21 58 22 static int rapl_mmio_read_raw(int cpu, struct reg_action *ra) 59 23 { ··· 46 82 int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv) 47 83 { 48 84 const struct rapl_mmio_regs *rapl_regs = &rapl_mmio_default; 85 + struct rapl_package *rp; 49 86 enum rapl_domain_reg_id reg; 50 87 enum rapl_domain_type domain; 51 88 int ret; ··· 74 109 return PTR_ERR(rapl_mmio_priv.control_type); 75 110 } 76 111 77 - ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "powercap/rapl:online", 78 - rapl_mmio_cpu_online, rapl_mmio_cpu_down_prep); 79 - if (ret < 0) { 80 - powercap_unregister_control_type(rapl_mmio_priv.control_type); 81 - rapl_mmio_priv.control_type = NULL; 82 - return ret; 112 + /* Register a RAPL package device for package 0 which is always online */ 113 + rp = rapl_find_package_domain(0, &rapl_mmio_priv, false); 114 + if (rp) { 115 + ret = -EEXIST; 116 + goto err; 83 117 } 84 - rapl_mmio_priv.pcap_rapl_online = ret; 118 + 119 + rp = rapl_add_package(0, &rapl_mmio_priv, false); 120 + if (IS_ERR(rp)) { 121 + ret = PTR_ERR(rp); 122 + goto err; 123 + } 85 124 86 125 return 0; 126 + 127 + err: 128 + powercap_unregister_control_type(rapl_mmio_priv.control_type); 129 + rapl_mmio_priv.control_type = NULL; 130 + return ret; 87 131 } 88 132 EXPORT_SYMBOL_GPL(proc_thermal_rapl_add); 89 133 90 134 void proc_thermal_rapl_remove(void) 91 135 { 136 + struct rapl_package *rp; 137 + 92 138 if (IS_ERR_OR_NULL(rapl_mmio_priv.control_type)) 93 139 return; 94 140 95 - cpuhp_remove_state(rapl_mmio_priv.pcap_rapl_online); 141 + rp = rapl_find_package_domain(0, &rapl_mmio_priv, false); 142 + if (rp) 143 + rapl_remove_package(rp); 96 144 powercap_unregister_control_type(rapl_mmio_priv.control_type); 97 145 } 98 146 EXPORT_SYMBOL_GPL(proc_thermal_rapl_remove);
+2 -3
drivers/thermal/thermal_core.c
··· 728 728 mutex_lock(&thermal_list_lock); 729 729 list_for_each_entry(tz, &thermal_tz_list, node) { 730 730 if (tz->id == id) { 731 + get_device(&tz->device); 731 732 match = tz; 732 733 break; 733 734 } ··· 1606 1605 ida_destroy(&tz->ida); 1607 1606 1608 1607 device_del(&tz->device); 1609 - 1610 - kfree(tz->tzp); 1611 - 1612 1608 put_device(&tz->device); 1613 1609 1614 1610 thermal_notify_tz_delete(tz); 1615 1611 1616 1612 wait_for_completion(&tz->removal); 1613 + kfree(tz->tzp); 1617 1614 kfree(tz); 1618 1615 } 1619 1616 EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
+3
drivers/thermal/thermal_core.h
··· 194 194 195 195 struct thermal_zone_device *thermal_zone_get_by_id(int id); 196 196 197 + DEFINE_CLASS(thermal_zone_get_by_id, struct thermal_zone_device *, 198 + if (_T) put_device(&_T->device), thermal_zone_get_by_id(id), int id) 199 + 197 200 static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev) 198 201 { 199 202 return cdev->ops->get_requested_power && cdev->ops->state2power &&
+3 -6
drivers/thermal/thermal_netlink.c
··· 443 443 { 444 444 struct sk_buff *msg = p->msg; 445 445 const struct thermal_trip_desc *td; 446 - struct thermal_zone_device *tz; 447 446 struct nlattr *start_trip; 448 447 int id; 449 448 ··· 451 452 452 453 id = nla_get_u32(p->attrs[THERMAL_GENL_ATTR_TZ_ID]); 453 454 454 - tz = thermal_zone_get_by_id(id); 455 + CLASS(thermal_zone_get_by_id, tz)(id); 455 456 if (!tz) 456 457 return -EINVAL; 457 458 ··· 487 488 static int thermal_genl_cmd_tz_get_temp(struct param *p) 488 489 { 489 490 struct sk_buff *msg = p->msg; 490 - struct thermal_zone_device *tz; 491 491 int temp, ret, id; 492 492 493 493 if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID]) ··· 494 496 495 497 id = nla_get_u32(p->attrs[THERMAL_GENL_ATTR_TZ_ID]); 496 498 497 - tz = thermal_zone_get_by_id(id); 499 + CLASS(thermal_zone_get_by_id, tz)(id); 498 500 if (!tz) 499 501 return -EINVAL; 500 502 ··· 512 514 static int thermal_genl_cmd_tz_get_gov(struct param *p) 513 515 { 514 516 struct sk_buff *msg = p->msg; 515 - struct thermal_zone_device *tz; 516 517 int id, ret = 0; 517 518 518 519 if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID]) ··· 519 522 520 523 id = nla_get_u32(p->attrs[THERMAL_GENL_ATTR_TZ_ID]); 521 524 522 - tz = thermal_zone_get_by_id(id); 525 + CLASS(thermal_zone_get_by_id, tz)(id); 523 526 if (!tz) 524 527 return -EINVAL; 525 528
+2 -3
drivers/ufs/core/ufshcd.c
··· 2933 2933 struct utp_transfer_req_desc *utrdlp = hba->utrdl_base_addr; 2934 2934 dma_addr_t cmd_desc_element_addr = hba->ucdl_dma_addr + 2935 2935 i * ufshcd_get_ucd_size(hba); 2936 - u16 response_offset = offsetof(struct utp_transfer_cmd_desc, 2937 - response_upiu); 2938 - u16 prdt_offset = offsetof(struct utp_transfer_cmd_desc, prd_table); 2936 + u16 response_offset = le16_to_cpu(utrdlp[i].response_upiu_offset); 2937 + u16 prdt_offset = le16_to_cpu(utrdlp[i].prd_table_offset); 2939 2938 2940 2939 lrb->utr_descriptor_ptr = utrdlp + i; 2941 2940 lrb->utrd_dma_addr = hba->utrdl_dma_addr +
+22 -8
drivers/usb/dwc3/core.c
··· 544 544 int dwc3_event_buffers_setup(struct dwc3 *dwc) 545 545 { 546 546 struct dwc3_event_buffer *evt; 547 + u32 reg; 547 548 548 549 if (!dwc->ev_buf) 549 550 return 0; ··· 557 556 upper_32_bits(evt->dma)); 558 557 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), 559 558 DWC3_GEVNTSIZ_SIZE(evt->length)); 560 - dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); 561 559 560 + /* Clear any stale event */ 561 + reg = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0)); 562 + dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), reg); 562 563 return 0; 563 564 } 564 565 ··· 587 584 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), 0); 588 585 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), DWC3_GEVNTSIZ_INTMASK 589 586 | DWC3_GEVNTSIZ_SIZE(0)); 590 - dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); 587 + 588 + /* Clear any stale event */ 589 + reg = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0)); 590 + dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), reg); 591 591 } 592 592 593 593 static void dwc3_core_num_eps(struct dwc3 *dwc) ··· 2505 2499 2506 2500 switch (dwc->current_dr_role) { 2507 2501 case DWC3_GCTL_PRTCAP_DEVICE: 2508 - dwc3_gadget_process_pending_events(dwc); 2502 + if (dwc->pending_events) { 2503 + pm_runtime_put(dwc->dev); 2504 + dwc->pending_events = false; 2505 + enable_irq(dwc->irq_gadget); 2506 + } 2509 2507 break; 2510 2508 case DWC3_GCTL_PRTCAP_HOST: 2511 2509 default: ··· 2562 2552 static int dwc3_resume(struct device *dev) 2563 2553 { 2564 2554 struct dwc3 *dwc = dev_get_drvdata(dev); 2565 - int ret; 2555 + int ret = 0; 2566 2556 2567 2557 pinctrl_pm_select_default_state(dev); 2568 2558 ··· 2570 2560 pm_runtime_set_active(dev); 2571 2561 2572 2562 ret = dwc3_resume_common(dwc, PMSG_RESUME); 2573 - if (ret) { 2563 + if (ret) 2574 2564 pm_runtime_set_suspended(dev); 2575 - return ret; 2576 - } 2577 2565 2578 2566 pm_runtime_enable(dev); 2579 2567 2580 - return 0; 2568 + return ret; 2581 2569 } 2582 2570 2583 2571 static void dwc3_complete(struct device *dev) ··· 2597 2589 static const struct dev_pm_ops dwc3_dev_pm_ops = { 2598 2590 SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume) 2599 2591 .complete = dwc3_complete, 2592 + 2593 + /* 2594 + * Runtime suspend halts the controller on disconnection. It relies on 2595 + * platforms with custom connection notification to start the controller 2596 + * again. 2597 + */ 2600 2598 SET_RUNTIME_PM_OPS(dwc3_runtime_suspend, dwc3_runtime_resume, 2601 2599 dwc3_runtime_idle) 2602 2600 };
-4
drivers/usb/dwc3/core.h
··· 1675 1675 #if !IS_ENABLED(CONFIG_USB_DWC3_HOST) 1676 1676 int dwc3_gadget_suspend(struct dwc3 *dwc); 1677 1677 int dwc3_gadget_resume(struct dwc3 *dwc); 1678 - void dwc3_gadget_process_pending_events(struct dwc3 *dwc); 1679 1678 #else 1680 1679 static inline int dwc3_gadget_suspend(struct dwc3 *dwc) 1681 1680 { ··· 1686 1687 return 0; 1687 1688 } 1688 1689 1689 - static inline void dwc3_gadget_process_pending_events(struct dwc3 *dwc) 1690 - { 1691 - } 1692 1690 #endif /* !IS_ENABLED(CONFIG_USB_DWC3_HOST) */ 1693 1691 1694 1692 #if IS_ENABLED(CONFIG_USB_DWC3_ULPI)
-11
drivers/usb/dwc3/gadget.c
··· 4728 4728 4729 4729 return dwc3_gadget_soft_connect(dwc); 4730 4730 } 4731 - 4732 - void dwc3_gadget_process_pending_events(struct dwc3 *dwc) 4733 - { 4734 - if (dwc->pending_events) { 4735 - dwc3_interrupt(dwc->irq_gadget, dwc->ev_buf); 4736 - dwc3_thread_interrupt(dwc->irq_gadget, dwc->ev_buf); 4737 - pm_runtime_put(dwc->dev); 4738 - dwc->pending_events = false; 4739 - enable_irq(dwc->irq_gadget); 4740 - } 4741 - }
+1
drivers/usb/gadget/udc/core.c
··· 1696 1696 driver->driver.bus = &gadget_bus_type; 1697 1697 driver->driver.owner = owner; 1698 1698 driver->driver.mod_name = mod_name; 1699 + driver->driver.probe_type = PROBE_FORCE_SYNCHRONOUS; 1699 1700 ret = driver_register(&driver->driver); 1700 1701 if (ret) { 1701 1702 pr_warn("%s: driver registration failed: %d\n",
+5
drivers/usb/host/xhci-pci.c
··· 79 79 #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142 80 80 #define PCI_DEVICE_ID_ASMEDIA_1142_XHCI 0x1242 81 81 #define PCI_DEVICE_ID_ASMEDIA_2142_XHCI 0x2142 82 + #define PCI_DEVICE_ID_ASMEDIA_3042_XHCI 0x3042 82 83 #define PCI_DEVICE_ID_ASMEDIA_3242_XHCI 0x3242 83 84 84 85 #define PCI_DEVICE_ID_CADENCE 0x17CD ··· 451 450 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && 452 451 pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI) 453 452 xhci->quirks |= XHCI_ASMEDIA_MODIFY_FLOWCONTROL; 453 + 454 + if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && 455 + pdev->device == PCI_DEVICE_ID_ASMEDIA_3042_XHCI) 456 + xhci->quirks |= XHCI_RESET_ON_RESUME; 454 457 455 458 if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241) 456 459 xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7;
+12
drivers/usb/misc/Kconfig
··· 331 331 this config will enable the driver and it will automatically 332 332 match the state of the USB subsystem. If this driver is a 333 333 module it will be called onboard_usb_dev. 334 + 335 + config USB_ONBOARD_DEV_USB5744 336 + bool "Onboard USB Microchip usb5744 hub with SMBus support" 337 + depends on (USB_ONBOARD_DEV && I2C=y) || (USB_ONBOARD_DEV=m && I2C=m) 338 + help 339 + Say Y here if you want to support onboard USB Microchip usb5744 340 + hub that requires SMBus initialization. 341 + 342 + This options enables usb5744 i2c default initialization sequence 343 + during hub start-up configuration stage. It is must to enable this 344 + option on AMD Kria KR260 Robotics Starter Kit as this hub is 345 + connected to USB-SD converter which mounts the root filesystem.
+4 -2
drivers/usb/misc/onboard_usb_dev.c
··· 311 311 312 312 static int onboard_dev_5744_i2c_init(struct i2c_client *client) 313 313 { 314 - #if IS_ENABLED(CONFIG_I2C) 314 + #if IS_ENABLED(CONFIG_USB_ONBOARD_DEV_USB5744) 315 315 struct device *dev = &client->dev; 316 316 int ret; 317 317 ··· 394 394 395 395 i2c_node = of_parse_phandle(pdev->dev.of_node, "i2c-bus", 0); 396 396 if (i2c_node) { 397 - struct i2c_client *client; 397 + struct i2c_client *client = NULL; 398 398 399 + #if IS_ENABLED(CONFIG_USB_ONBOARD_DEV_USB5744) 399 400 client = of_find_i2c_device_by_node(i2c_node); 401 + #endif 400 402 of_node_put(i2c_node); 401 403 402 404 if (!client) {
+9 -12
drivers/usb/misc/yurex.c
··· 34 34 #define YUREX_BUF_SIZE 8 35 35 #define YUREX_WRITE_TIMEOUT (HZ*2) 36 36 37 - #define MAX_S64_STRLEN 20 /* {-}922337203685477580{7,8} */ 38 - 39 37 /* table of devices that work with this driver */ 40 38 static struct usb_device_id yurex_table[] = { 41 39 { USB_DEVICE(YUREX_VENDOR_ID, YUREX_PRODUCT_ID) }, ··· 400 402 loff_t *ppos) 401 403 { 402 404 struct usb_yurex *dev; 403 - int len = 0; 404 - char in_buffer[MAX_S64_STRLEN]; 405 + int len; 406 + char in_buffer[20]; 407 + unsigned long flags; 405 408 406 409 dev = file->private_data; 407 410 ··· 412 413 return -ENODEV; 413 414 } 414 415 415 - if (WARN_ON_ONCE(dev->bbu > S64_MAX || dev->bbu < S64_MIN)) { 416 - mutex_unlock(&dev->io_mutex); 417 - return -EIO; 418 - } 419 - 420 - spin_lock_irq(&dev->lock); 421 - scnprintf(in_buffer, MAX_S64_STRLEN, "%lld\n", dev->bbu); 422 - spin_unlock_irq(&dev->lock); 416 + spin_lock_irqsave(&dev->lock, flags); 417 + len = snprintf(in_buffer, 20, "%lld\n", dev->bbu); 418 + spin_unlock_irqrestore(&dev->lock, flags); 423 419 mutex_unlock(&dev->io_mutex); 420 + 421 + if (WARN_ON_ONCE(len >= sizeof(in_buffer))) 422 + return -EIO; 424 423 425 424 return simple_read_from_buffer(buffer, count, ppos, in_buffer, len); 426 425 }
+11
drivers/usb/storage/unusual_devs.h
··· 2423 2423 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 2424 2424 US_FL_NOT_LOCKABLE), 2425 2425 2426 + /* 2427 + * Reported by Icenowy Zheng <uwu@icenowy.me> 2428 + * This is an interface for vendor-specific cryptic commands instead 2429 + * of real USB storage device. 2430 + */ 2431 + UNUSUAL_DEV( 0xe5b7, 0x0811, 0x0100, 0x0100, 2432 + "ZhuHai JieLi Technology", 2433 + "JieLi BR21", 2434 + USB_SC_DEVICE, USB_PR_DEVICE, NULL, 2435 + US_FL_IGNORE_DEVICE), 2436 + 2426 2437 /* Reported by Andrew Simmons <andrew.simmons@gmail.com> */ 2427 2438 UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001, 2428 2439 "DataStor",
+2 -2
drivers/video/fbdev/amifb.c
··· 3774 3774 * triggers a section mismatch warning. 3775 3775 */ 3776 3776 static struct platform_driver amifb_driver __refdata = { 3777 - .remove_new = __exit_p(amifb_remove), 3778 - .driver = { 3777 + .remove = __exit_p(amifb_remove), 3778 + .driver = { 3779 3779 .name = "amiga-video", 3780 3780 }, 3781 3781 };
+1 -1
drivers/video/fbdev/arcfb.c
··· 548 548 549 549 static struct platform_driver arcfb_driver = { 550 550 .probe = arcfb_probe, 551 - .remove_new = arcfb_remove, 551 + .remove = arcfb_remove, 552 552 .driver = { 553 553 .name = "arcfb", 554 554 },
+1 -1
drivers/video/fbdev/atmel_lcdfb.c
··· 1299 1299 1300 1300 static struct platform_driver atmel_lcdfb_driver = { 1301 1301 .probe = atmel_lcdfb_probe, 1302 - .remove_new = atmel_lcdfb_remove, 1302 + .remove = atmel_lcdfb_remove, 1303 1303 .suspend = atmel_lcdfb_suspend, 1304 1304 .resume = atmel_lcdfb_resume, 1305 1305 .driver = {
+1 -1
drivers/video/fbdev/au1100fb.c
··· 588 588 .name = "au1100-lcd", 589 589 }, 590 590 .probe = au1100fb_drv_probe, 591 - .remove_new = au1100fb_drv_remove, 591 + .remove = au1100fb_drv_remove, 592 592 .suspend = au1100fb_drv_suspend, 593 593 .resume = au1100fb_drv_resume, 594 594 };
+1 -1
drivers/video/fbdev/au1200fb.c
··· 1833 1833 .pm = AU1200FB_PMOPS, 1834 1834 }, 1835 1835 .probe = au1200fb_drv_probe, 1836 - .remove_new = au1200fb_drv_remove, 1836 + .remove = au1200fb_drv_remove, 1837 1837 }; 1838 1838 module_platform_driver(au1200fb_driver); 1839 1839
+1 -1
drivers/video/fbdev/broadsheetfb.c
··· 1151 1151 1152 1152 static struct platform_driver broadsheetfb_driver = { 1153 1153 .probe = broadsheetfb_probe, 1154 - .remove_new = broadsheetfb_remove, 1154 + .remove = broadsheetfb_remove, 1155 1155 .driver = { 1156 1156 .name = "broadsheetfb", 1157 1157 },
+1 -1
drivers/video/fbdev/bw2.c
··· 372 372 .of_match_table = bw2_match, 373 373 }, 374 374 .probe = bw2_probe, 375 - .remove_new = bw2_remove, 375 + .remove = bw2_remove, 376 376 }; 377 377 378 378 static int __init bw2_init(void)
+1 -1
drivers/video/fbdev/cg14.c
··· 590 590 .of_match_table = cg14_match, 591 591 }, 592 592 .probe = cg14_probe, 593 - .remove_new = cg14_remove, 593 + .remove = cg14_remove, 594 594 }; 595 595 596 596 static int __init cg14_init(void)
+1 -1
drivers/video/fbdev/cg3.c
··· 458 458 .of_match_table = cg3_match, 459 459 }, 460 460 .probe = cg3_probe, 461 - .remove_new = cg3_remove, 461 + .remove = cg3_remove, 462 462 }; 463 463 464 464 static int __init cg3_init(void)
+1 -1
drivers/video/fbdev/cg6.c
··· 858 858 .of_match_table = cg6_match, 859 859 }, 860 860 .probe = cg6_probe, 861 - .remove_new = cg6_remove, 861 + .remove = cg6_remove, 862 862 }; 863 863 864 864 static int __init cg6_init(void)
+1 -1
drivers/video/fbdev/clps711x-fb.c
··· 371 371 .of_match_table = clps711x_fb_dt_ids, 372 372 }, 373 373 .probe = clps711x_fb_probe, 374 - .remove_new = clps711x_fb_remove, 374 + .remove = clps711x_fb_remove, 375 375 }; 376 376 module_platform_driver(clps711x_fb_driver); 377 377
+1 -1
drivers/video/fbdev/cobalt_lcdfb.c
··· 344 344 345 345 static struct platform_driver cobalt_lcdfb_driver = { 346 346 .probe = cobalt_lcdfb_probe, 347 - .remove_new = cobalt_lcdfb_remove, 347 + .remove = cobalt_lcdfb_remove, 348 348 .driver = { 349 349 .name = "cobalt-lcd", 350 350 },
+1 -1
drivers/video/fbdev/da8xx-fb.c
··· 1652 1652 1653 1653 static struct platform_driver da8xx_fb_driver = { 1654 1654 .probe = fb_probe, 1655 - .remove_new = fb_remove, 1655 + .remove = fb_remove, 1656 1656 .driver = { 1657 1657 .name = DRIVER_NAME, 1658 1658 .pm = &fb_pm_ops,
+1 -1
drivers/video/fbdev/ep93xx-fb.c
··· 592 592 593 593 static struct platform_driver ep93xxfb_driver = { 594 594 .probe = ep93xxfb_probe, 595 - .remove_new = ep93xxfb_remove, 595 + .remove = ep93xxfb_remove, 596 596 .driver = { 597 597 .name = "ep93xx-fb", 598 598 },
+1 -1
drivers/video/fbdev/ffb.c
··· 1053 1053 .of_match_table = ffb_match, 1054 1054 }, 1055 1055 .probe = ffb_probe, 1056 - .remove_new = ffb_remove, 1056 + .remove = ffb_remove, 1057 1057 }; 1058 1058 1059 1059 static int __init ffb_init(void)
+3 -3
drivers/video/fbdev/fsl-diu-fb.c
··· 1876 1876 MODULE_DEVICE_TABLE(of, fsl_diu_match); 1877 1877 1878 1878 static struct platform_driver fsl_diu_driver = { 1879 - .driver = { 1879 + .driver = { 1880 1880 .name = "fsl-diu-fb", 1881 1881 .of_match_table = fsl_diu_match, 1882 1882 }, 1883 - .probe = fsl_diu_probe, 1884 - .remove_new = fsl_diu_remove, 1883 + .probe = fsl_diu_probe, 1884 + .remove = fsl_diu_remove, 1885 1885 .suspend = fsl_diu_suspend, 1886 1886 .resume = fsl_diu_resume, 1887 1887 };
+3 -3
drivers/video/fbdev/gbefb.c
··· 1247 1247 1248 1248 static struct platform_driver gbefb_driver = { 1249 1249 .probe = gbefb_probe, 1250 - .remove_new = gbefb_remove, 1251 - .driver = { 1250 + .remove = gbefb_remove, 1251 + .driver = { 1252 1252 .name = "gbefb", 1253 - .dev_groups = gbefb_groups, 1253 + .dev_groups = gbefb_groups, 1254 1254 }, 1255 1255 }; 1256 1256
+1 -1
drivers/video/fbdev/goldfishfb.c
··· 311 311 312 312 static struct platform_driver goldfish_fb_driver = { 313 313 .probe = goldfish_fb_probe, 314 - .remove_new = goldfish_fb_remove, 314 + .remove = goldfish_fb_remove, 315 315 .driver = { 316 316 .name = "goldfish_fb", 317 317 .of_match_table = goldfish_fb_of_match,
+1 -1
drivers/video/fbdev/grvga.c
··· 540 540 .of_match_table = svgactrl_of_match, 541 541 }, 542 542 .probe = grvga_probe, 543 - .remove_new = grvga_remove, 543 + .remove = grvga_remove, 544 544 }; 545 545 546 546 module_platform_driver(grvga_driver);
+1 -1
drivers/video/fbdev/hecubafb.c
··· 235 235 236 236 static struct platform_driver hecubafb_driver = { 237 237 .probe = hecubafb_probe, 238 - .remove_new = hecubafb_remove, 238 + .remove = hecubafb_remove, 239 239 .driver = { 240 240 .name = "hecubafb", 241 241 },
+1 -1
drivers/video/fbdev/hgafb.c
··· 629 629 630 630 static struct platform_driver hgafb_driver = { 631 631 .probe = hgafb_probe, 632 - .remove_new = hgafb_remove, 632 + .remove = hgafb_remove, 633 633 .driver = { 634 634 .name = "hgafb", 635 635 },
+1 -1
drivers/video/fbdev/hitfb.c
··· 476 476 477 477 static struct platform_driver hitfb_driver = { 478 478 .probe = hitfb_probe, 479 - .remove_new = hitfb_remove, 479 + .remove = hitfb_remove, 480 480 .driver = { 481 481 .name = "hitfb", 482 482 .pm = &hitfb_dev_pm_ops,
+1 -1
drivers/video/fbdev/imxfb.c
··· 1105 1105 .pm = pm_sleep_ptr(&imxfb_pm_ops), 1106 1106 }, 1107 1107 .probe = imxfb_probe, 1108 - .remove_new = imxfb_remove, 1108 + .remove = imxfb_remove, 1109 1109 .id_table = imxfb_devtype, 1110 1110 }; 1111 1111 module_platform_driver(imxfb_driver);
+1 -1
drivers/video/fbdev/leo.c
··· 657 657 .of_match_table = leo_match, 658 658 }, 659 659 .probe = leo_probe, 660 - .remove_new = leo_remove, 660 + .remove = leo_remove, 661 661 }; 662 662 663 663 static int __init leo_init(void)
+1 -1
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c
··· 834 834 .of_match_table = of_platform_mb862xx_tbl, 835 835 }, 836 836 .probe = of_platform_mb862xx_probe, 837 - .remove_new = of_platform_mb862xx_remove, 837 + .remove = of_platform_mb862xx_remove, 838 838 }; 839 839 #endif 840 840
+1 -1
drivers/video/fbdev/metronomefb.c
··· 707 707 708 708 static struct platform_driver metronomefb_driver = { 709 709 .probe = metronomefb_probe, 710 - .remove_new = metronomefb_remove, 710 + .remove = metronomefb_remove, 711 711 .driver = { 712 712 .name = "metronomefb", 713 713 },
+1 -1
drivers/video/fbdev/ocfb.c
··· 391 391 392 392 static struct platform_driver ocfb_driver = { 393 393 .probe = ocfb_probe, 394 - .remove_new = ocfb_remove, 394 + .remove = ocfb_remove, 395 395 .driver = { 396 396 .name = "ocfb_fb", 397 397 .of_match_table = ocfb_match,
+2 -2
drivers/video/fbdev/offb.c
··· 673 673 .name = "bootx-noscreen", 674 674 }, 675 675 .probe = offb_probe_bootx_noscreen, 676 - .remove_new = offb_remove, 676 + .remove = offb_remove, 677 677 }; 678 678 679 679 static int offb_probe_display(struct platform_device *pdev) ··· 695 695 .of_match_table = offb_of_match_display, 696 696 }, 697 697 .probe = offb_probe_display, 698 - .remove_new = offb_remove, 698 + .remove = offb_remove, 699 699 }; 700 700 701 701 static int __init offb_init(void)
+1 -1
drivers/video/fbdev/omap/omapfb_main.c
··· 1825 1825 1826 1826 static struct platform_driver omapfb_driver = { 1827 1827 .probe = omapfb_probe, 1828 - .remove_new = omapfb_remove, 1828 + .remove = omapfb_remove, 1829 1829 .suspend = omapfb_suspend, 1830 1830 .resume = omapfb_resume, 1831 1831 .driver = {
+1 -1
drivers/video/fbdev/omap2/omapfb/displays/connector-analog-tv.c
··· 245 245 246 246 static struct platform_driver tvc_connector_driver = { 247 247 .probe = tvc_probe, 248 - .remove_new = tvc_remove, 248 + .remove = tvc_remove, 249 249 .driver = { 250 250 .name = "connector-analog-tv", 251 251 .of_match_table = tvc_of_match,
+1 -1
drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c
··· 328 328 329 329 static struct platform_driver dvi_connector_driver = { 330 330 .probe = dvic_probe, 331 - .remove_new = dvic_remove, 331 + .remove = dvic_remove, 332 332 .driver = { 333 333 .name = "connector-dvi", 334 334 .of_match_table = dvic_of_match,
+1 -1
drivers/video/fbdev/omap2/omapfb/displays/connector-hdmi.c
··· 272 272 273 273 static struct platform_driver hdmi_connector_driver = { 274 274 .probe = hdmic_probe, 275 - .remove_new = hdmic_remove, 275 + .remove = hdmic_remove, 276 276 .driver = { 277 277 .name = "connector-hdmi", 278 278 .of_match_table = hdmic_of_match,
+1 -1
drivers/video/fbdev/omap2/omapfb/displays/encoder-opa362.c
··· 258 258 259 259 static struct platform_driver opa362_driver = { 260 260 .probe = opa362_probe, 261 - .remove_new = opa362_remove, 261 + .remove = opa362_remove, 262 262 .driver = { 263 263 .name = "amplifier-opa362", 264 264 .of_match_table = opa362_of_match,
+1 -1
drivers/video/fbdev/omap2/omapfb/displays/encoder-tfp410.c
··· 245 245 246 246 static struct platform_driver tfp410_driver = { 247 247 .probe = tfp410_probe, 248 - .remove_new = tfp410_remove, 248 + .remove = tfp410_remove, 249 249 .driver = { 250 250 .name = "tfp410", 251 251 .of_match_table = tfp410_of_match,
+1 -1
drivers/video/fbdev/omap2/omapfb/displays/encoder-tpd12s015.c
··· 311 311 312 312 static struct platform_driver tpd_driver = { 313 313 .probe = tpd_probe, 314 - .remove_new = tpd_remove, 314 + .remove = tpd_remove, 315 315 .driver = { 316 316 .name = "tpd12s015", 317 317 .of_match_table = tpd_of_match,
+1 -1
drivers/video/fbdev/omap2/omapfb/displays/panel-dpi.c
··· 234 234 235 235 static struct platform_driver panel_dpi_driver = { 236 236 .probe = panel_dpi_probe, 237 - .remove_new = panel_dpi_remove, 237 + .remove = panel_dpi_remove, 238 238 .driver = { 239 239 .name = "panel-dpi", 240 240 .of_match_table = panel_dpi_of_match,
+1 -1
drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c
··· 1275 1275 1276 1276 static struct platform_driver dsicm_driver = { 1277 1277 .probe = dsicm_probe, 1278 - .remove_new = dsicm_remove, 1278 + .remove = dsicm_remove, 1279 1279 .driver = { 1280 1280 .name = "panel-dsi-cm", 1281 1281 .of_match_table = dsicm_of_match,
+1 -1
drivers/video/fbdev/omap2/omapfb/displays/panel-sharp-ls037v7dw01.c
··· 315 315 316 316 static struct platform_driver sharp_ls_driver = { 317 317 .probe = sharp_ls_probe, 318 - .remove_new = sharp_ls_remove, 318 + .remove = sharp_ls_remove, 319 319 .driver = { 320 320 .name = "panel-sharp-ls037v7dw01", 321 321 .of_match_table = sharp_ls_of_match,
+3 -3
drivers/video/fbdev/omap2/omapfb/dss/core.c
··· 185 185 } 186 186 187 187 static struct platform_driver omap_dss_driver = { 188 - .remove_new = omap_dss_remove, 188 + .remove = omap_dss_remove, 189 189 .shutdown = omap_dss_shutdown, 190 - .driver = { 191 - .name = "omapdss", 190 + .driver = { 191 + .name = "omapdss", 192 192 }, 193 193 }; 194 194
+1 -1
drivers/video/fbdev/omap2/omapfb/dss/dispc.c
··· 4072 4072 4073 4073 static struct platform_driver omap_dispchw_driver = { 4074 4074 .probe = dispc_probe, 4075 - .remove_new = dispc_remove, 4075 + .remove = dispc_remove, 4076 4076 .driver = { 4077 4077 .name = "omapdss_dispc", 4078 4078 .pm = &dispc_pm_ops,
+2 -2
drivers/video/fbdev/omap2/omapfb/dss/dpi.c
··· 817 817 818 818 static struct platform_driver omap_dpi_driver = { 819 819 .probe = dpi_probe, 820 - .remove_new = dpi_remove, 821 - .driver = { 820 + .remove = dpi_remove, 821 + .driver = { 822 822 .name = "omapdss_dpi", 823 823 .suppress_bind_attrs = true, 824 824 },
+1 -1
drivers/video/fbdev/omap2/omapfb/dss/dsi.c
··· 5565 5565 5566 5566 static struct platform_driver omap_dsihw_driver = { 5567 5567 .probe = dsi_probe, 5568 - .remove_new = dsi_remove, 5568 + .remove = dsi_remove, 5569 5569 .driver = { 5570 5570 .name = "omapdss_dsi", 5571 5571 .pm = &dsi_pm_ops,
+1 -1
drivers/video/fbdev/omap2/omapfb/dss/dss.c
··· 1278 1278 1279 1279 static struct platform_driver omap_dsshw_driver = { 1280 1280 .probe = dss_probe, 1281 - .remove_new = dss_remove, 1281 + .remove = dss_remove, 1282 1282 .driver = { 1283 1283 .name = "omapdss_dss", 1284 1284 .pm = &dss_pm_ops,
+3 -3
drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
··· 792 792 793 793 static struct platform_driver omapdss_hdmihw_driver = { 794 794 .probe = hdmi4_probe, 795 - .remove_new = hdmi4_remove, 796 - .driver = { 797 - .name = "omapdss_hdmi", 795 + .remove = hdmi4_remove, 796 + .driver = { 797 + .name = "omapdss_hdmi", 798 798 .pm = &hdmi_pm_ops, 799 799 .of_match_table = hdmi_of_match, 800 800 .suppress_bind_attrs = true,
+1 -1
drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
··· 834 834 835 835 static struct platform_driver omapdss_hdmihw_driver = { 836 836 .probe = hdmi5_probe, 837 - .remove_new = hdmi5_remove, 837 + .remove = hdmi5_remove, 838 838 .driver = { 839 839 .name = "omapdss_hdmi5", 840 840 .pm = &hdmi_pm_ops,
+3 -3
drivers/video/fbdev/omap2/omapfb/dss/sdi.c
··· 382 382 383 383 static struct platform_driver omap_sdi_driver = { 384 384 .probe = sdi_probe, 385 - .remove_new = sdi_remove, 386 - .driver = { 387 - .name = "omapdss_sdi", 385 + .remove = sdi_remove, 386 + .driver = { 387 + .name = "omapdss_sdi", 388 388 .suppress_bind_attrs = true, 389 389 }, 390 390 };
+3 -3
drivers/video/fbdev/omap2/omapfb/dss/venc.c
··· 920 920 921 921 static struct platform_driver omap_venchw_driver = { 922 922 .probe = venc_probe, 923 - .remove_new = venc_remove, 924 - .driver = { 925 - .name = "omapdss_venc", 923 + .remove = venc_remove, 924 + .driver = { 925 + .name = "omapdss_venc", 926 926 .pm = &venc_pm_ops, 927 927 .of_match_table = venc_of_match, 928 928 .suppress_bind_attrs = true,
+1 -1
drivers/video/fbdev/omap2/omapfb/omapfb-main.c
··· 2614 2614 2615 2615 static struct platform_driver omapfb_driver = { 2616 2616 .probe = omapfb_probe, 2617 - .remove_new = omapfb_remove, 2617 + .remove = omapfb_remove, 2618 2618 .driver = { 2619 2619 .name = "omapfb", 2620 2620 },
+1 -1
drivers/video/fbdev/p9100.c
··· 347 347 .of_match_table = p9100_match, 348 348 }, 349 349 .probe = p9100_probe, 350 - .remove_new = p9100_remove, 350 + .remove = p9100_remove, 351 351 }; 352 352 353 353 static int __init p9100_init(void)
+1 -1
drivers/video/fbdev/platinumfb.c
··· 668 668 .of_match_table = platinumfb_match, 669 669 }, 670 670 .probe = platinumfb_probe, 671 - .remove_new = platinumfb_remove, 671 + .remove = platinumfb_remove, 672 672 }; 673 673 674 674 static int __init platinumfb_init(void)
+1 -1
drivers/video/fbdev/pxa168fb.c
··· 799 799 .name = "pxa168-fb", 800 800 }, 801 801 .probe = pxa168fb_probe, 802 - .remove_new = pxa168fb_remove, 802 + .remove = pxa168fb_remove, 803 803 }; 804 804 805 805 module_platform_driver(pxa168fb_driver);
+4 -4
drivers/video/fbdev/pxa3xx-gcu.c
··· 696 696 #endif 697 697 698 698 static struct platform_driver pxa3xx_gcu_driver = { 699 - .probe = pxa3xx_gcu_probe, 700 - .remove_new = pxa3xx_gcu_remove, 701 - .driver = { 702 - .name = DRV_NAME, 699 + .probe = pxa3xx_gcu_probe, 700 + .remove = pxa3xx_gcu_remove, 701 + .driver = { 702 + .name = DRV_NAME, 703 703 .of_match_table = of_match_ptr(pxa3xx_gcu_of_match), 704 704 }, 705 705 };
+1 -1
drivers/video/fbdev/pxafb.c
··· 2427 2427 2428 2428 static struct platform_driver pxafb_driver = { 2429 2429 .probe = pxafb_probe, 2430 - .remove_new = pxafb_remove, 2430 + .remove = pxafb_remove, 2431 2431 .driver = { 2432 2432 .name = "pxa2xx-fb", 2433 2433 .of_match_table = pxafb_of_dev_id,
+1 -1
drivers/video/fbdev/s1d13xxxfb.c
··· 1001 1001 1002 1002 static struct platform_driver s1d13xxxfb_driver = { 1003 1003 .probe = s1d13xxxfb_probe, 1004 - .remove_new = s1d13xxxfb_remove, 1004 + .remove = s1d13xxxfb_remove, 1005 1005 #ifdef CONFIG_PM 1006 1006 .suspend = s1d13xxxfb_suspend, 1007 1007 .resume = s1d13xxxfb_resume,
+1 -1
drivers/video/fbdev/s3c-fb.c
··· 1789 1789 1790 1790 static struct platform_driver s3c_fb_driver = { 1791 1791 .probe = s3c_fb_probe, 1792 - .remove_new = s3c_fb_remove, 1792 + .remove = s3c_fb_remove, 1793 1793 .id_table = s3c_fb_driver_ids, 1794 1794 .driver = { 1795 1795 .name = "s3c-fb",
+1 -1
drivers/video/fbdev/sh7760fb.c
··· 575 575 .name = "sh7760-lcdc", 576 576 }, 577 577 .probe = sh7760fb_probe, 578 - .remove_new = sh7760fb_remove, 578 + .remove = sh7760fb_remove, 579 579 }; 580 580 581 581 module_platform_driver(sh7760_lcdc_driver);
+1 -1
drivers/video/fbdev/sh_mobile_lcdcfb.c
··· 2648 2648 .pm = &sh_mobile_lcdc_dev_pm_ops, 2649 2649 }, 2650 2650 .probe = sh_mobile_lcdc_probe, 2651 - .remove_new = sh_mobile_lcdc_remove, 2651 + .remove = sh_mobile_lcdc_remove, 2652 2652 }; 2653 2653 2654 2654 module_platform_driver(sh_mobile_lcdc_driver);
+1 -1
drivers/video/fbdev/simplefb.c
··· 677 677 .of_match_table = simplefb_of_match, 678 678 }, 679 679 .probe = simplefb_probe, 680 - .remove_new = simplefb_remove, 680 + .remove = simplefb_remove, 681 681 }; 682 682 683 683 module_platform_driver(simplefb_driver);
+1 -1
drivers/video/fbdev/sm501fb.c
··· 2211 2211 2212 2212 static struct platform_driver sm501fb_driver = { 2213 2213 .probe = sm501fb_probe, 2214 - .remove_new = sm501fb_remove, 2214 + .remove = sm501fb_remove, 2215 2215 .suspend = sm501fb_suspend, 2216 2216 .resume = sm501fb_resume, 2217 2217 .driver = {
+1 -1
drivers/video/fbdev/tcx.c
··· 505 505 .of_match_table = tcx_match, 506 506 }, 507 507 .probe = tcx_probe, 508 - .remove_new = tcx_remove, 508 + .remove = tcx_remove, 509 509 }; 510 510 511 511 static int __init tcx_init(void)
+1 -1
drivers/video/fbdev/uvesafb.c
··· 1794 1794 1795 1795 static struct platform_driver uvesafb_driver = { 1796 1796 .probe = uvesafb_probe, 1797 - .remove_new = uvesafb_remove, 1797 + .remove = uvesafb_remove, 1798 1798 .driver = { 1799 1799 .name = "uvesafb", 1800 1800 },
+1 -1
drivers/video/fbdev/vesafb.c
··· 515 515 .name = "vesa-framebuffer", 516 516 }, 517 517 .probe = vesafb_probe, 518 - .remove_new = vesafb_remove, 518 + .remove = vesafb_remove, 519 519 }; 520 520 521 521 module_platform_driver(vesafb_driver);
+1 -1
drivers/video/fbdev/vfb.c
··· 493 493 494 494 static struct platform_driver vfb_driver = { 495 495 .probe = vfb_probe, 496 - .remove_new = vfb_remove, 496 + .remove = vfb_remove, 497 497 .driver = { 498 498 .name = "vfb", 499 499 },
+1 -1
drivers/video/fbdev/vga16fb.c
··· 1417 1417 1418 1418 static struct platform_driver vga16fb_driver = { 1419 1419 .probe = vga16fb_probe, 1420 - .remove_new = vga16fb_remove, 1420 + .remove = vga16fb_remove, 1421 1421 .driver = { 1422 1422 .name = "vga16fb", 1423 1423 },
+1 -1
drivers/video/fbdev/via/via-gpio.c
··· 292 292 .name = "viafb-gpio", 293 293 }, 294 294 .probe = viafb_gpio_probe, 295 - .remove_new = viafb_gpio_remove, 295 + .remove = viafb_gpio_remove, 296 296 }; 297 297 298 298 int viafb_gpio_init(void)
+1 -1
drivers/video/fbdev/via/via_i2c.c
··· 265 265 .name = "viafb-i2c", 266 266 }, 267 267 .probe = viafb_i2c_probe, 268 - .remove_new = viafb_i2c_remove, 268 + .remove = viafb_i2c_remove, 269 269 }; 270 270 271 271 int viafb_i2c_init(void)
+1 -1
drivers/video/fbdev/vt8500lcdfb.c
··· 471 471 472 472 static struct platform_driver vt8500lcd_driver = { 473 473 .probe = vt8500lcd_probe, 474 - .remove_new = vt8500lcd_remove, 474 + .remove = vt8500lcd_remove, 475 475 .driver = { 476 476 .name = "vt8500-lcd", 477 477 .of_match_table = of_match_ptr(via_dt_ids),
+1 -1
drivers/video/fbdev/wm8505fb.c
··· 392 392 393 393 static struct platform_driver wm8505fb_driver = { 394 394 .probe = wm8505fb_probe, 395 - .remove_new = wm8505fb_remove, 395 + .remove = wm8505fb_remove, 396 396 .driver = { 397 397 .name = DRIVER_NAME, 398 398 .of_match_table = wmt_dt_ids,
+1 -1
drivers/video/fbdev/wmt_ge_rops.c
··· 159 159 160 160 static struct platform_driver wmt_ge_rops_driver = { 161 161 .probe = wmt_ge_rops_probe, 162 - .remove_new = wmt_ge_rops_remove, 162 + .remove = wmt_ge_rops_remove, 163 163 .driver = { 164 164 .name = "wmt_ge_rops", 165 165 .of_match_table = wmt_dt_ids,
+1 -1
drivers/video/fbdev/xilinxfb.c
··· 488 488 489 489 static struct platform_driver xilinxfb_of_driver = { 490 490 .probe = xilinxfb_of_probe, 491 - .remove_new = xilinxfb_of_remove, 491 + .remove = xilinxfb_of_remove, 492 492 .driver = { 493 493 .name = DRIVER_NAME, 494 494 .of_match_table = xilinxfb_of_match,
+1 -1
fs/Kconfig
··· 388 388 389 389 config NFS_COMMON_LOCALIO_SUPPORT 390 390 tristate 391 - default n 391 + depends on NFS_LOCALIO 392 392 default y if NFSD=y || NFS_FS=y 393 393 default m if NFSD=m && NFS_FS=m 394 394 select SUNRPC
+10
fs/bcachefs/alloc_background.c
··· 639 639 continue; 640 640 } 641 641 642 + if (k.k->p.offset < ca->mi.first_bucket) { 643 + bch2_btree_iter_set_pos(&iter, POS(k.k->p.inode, ca->mi.first_bucket)); 644 + continue; 645 + } 646 + 647 + if (k.k->p.offset >= ca->mi.nbuckets) { 648 + bch2_btree_iter_set_pos(&iter, POS(k.k->p.inode + 1, 0)); 649 + continue; 650 + } 651 + 642 652 struct bch_alloc_v4 a; 643 653 *bucket_gen(ca, k.k->p.offset) = bch2_alloc_to_v4(k, &a)->gen; 644 654 0;
+2 -1
fs/bcachefs/bcachefs_format.h
··· 678 678 x(disk_accounting_v2, BCH_VERSION(1, 9)) \ 679 679 x(disk_accounting_v3, BCH_VERSION(1, 10)) \ 680 680 x(disk_accounting_inum, BCH_VERSION(1, 11)) \ 681 - x(rebalance_work_acct_fix, BCH_VERSION(1, 12)) 681 + x(rebalance_work_acct_fix, BCH_VERSION(1, 12)) \ 682 + x(inode_has_child_snapshots, BCH_VERSION(1, 13)) 682 683 683 684 enum bcachefs_metadata_version { 684 685 bcachefs_metadata_version_min = 9,
+9 -6
fs/bcachefs/btree_gc.c
··· 1224 1224 u64 b, start_time = local_clock(); 1225 1225 int ret; 1226 1226 1227 - /* 1228 - * Ideally we would be using state_lock and not gc_gens_lock here, but that 1229 - * introduces a deadlock in the RO path - we currently take the state 1230 - * lock at the start of going RO, thus the gc thread may get stuck: 1231 - */ 1232 1227 if (!mutex_trylock(&c->gc_gens_lock)) 1233 1228 return 0; 1234 1229 1235 1230 trace_and_count(c, gc_gens_start, c); 1236 1231 1237 - down_read(&c->state_lock); 1232 + /* 1233 + * We have to use trylock here. Otherwise, we would 1234 + * introduce a deadlock in the RO path - we take the 1235 + * state lock at the start of going RO. 1236 + */ 1237 + if (!down_read_trylock(&c->state_lock)) { 1238 + mutex_unlock(&c->gc_gens_lock); 1239 + return 0; 1240 + } 1238 1241 1239 1242 for_each_member_device(c, ca) { 1240 1243 struct bucket_gens *gens = bucket_gens(ca);
+3 -2
fs/bcachefs/btree_io.c
··· 1838 1838 struct btree_trans *trans = bch2_trans_get(c); 1839 1839 1840 1840 btree_node_lock_nopath_nofail(trans, &b->c, SIX_LOCK_read); 1841 + 1842 + /* we don't need transaction context anymore after we got the lock. */ 1843 + bch2_trans_put(trans); 1841 1844 __btree_node_write_done(c, b); 1842 1845 six_unlock_read(&b->c.lock); 1843 - 1844 - bch2_trans_put(trans); 1845 1846 } 1846 1847 1847 1848 static void btree_node_write_work(struct work_struct *work)
+3 -3
fs/bcachefs/btree_iter.c
··· 2381 2381 else 2382 2382 iter_pos = bkey_max(iter->pos, bkey_start_pos(k.k)); 2383 2383 2384 - if (unlikely(!(iter->flags & BTREE_ITER_is_extents) 2385 - ? bkey_gt(iter_pos, end) 2386 - : bkey_ge(iter_pos, end))) 2384 + if (unlikely(iter->flags & BTREE_ITER_all_snapshots ? bpos_gt(iter_pos, end) : 2385 + iter->flags & BTREE_ITER_is_extents ? bkey_ge(iter_pos, end) : 2386 + bkey_gt(iter_pos, end))) 2387 2387 goto end; 2388 2388 2389 2389 break;
+8
fs/bcachefs/btree_iter.h
··· 857 857 for_each_btree_key_upto_norestart(_trans, _iter, _btree_id, _start,\ 858 858 SPOS_MAX, _flags, _k, _ret) 859 859 860 + #define for_each_btree_key_reverse_norestart(_trans, _iter, _btree_id, \ 861 + _start, _flags, _k, _ret) \ 862 + for (bch2_trans_iter_init((_trans), &(_iter), (_btree_id), \ 863 + (_start), (_flags)); \ 864 + (_k) = bch2_btree_iter_peek_prev_type(&(_iter), _flags), \ 865 + !((_ret) = bkey_err(_k)) && (_k).k; \ 866 + bch2_btree_iter_rewind(&(_iter))) 867 + 860 868 #define for_each_btree_key_continue_norestart(_iter, _flags, _k, _ret) \ 861 869 for_each_btree_key_upto_continue_norestart(_iter, SPOS_MAX, _flags, _k, _ret) 862 870
+3
fs/bcachefs/btree_node_scan.c
··· 171 171 if (BTREE_NODE_LEVEL(bn) >= BTREE_MAX_DEPTH) 172 172 return; 173 173 174 + if (BTREE_NODE_ID(bn) >= BTREE_ID_NR_MAX) 175 + return; 176 + 174 177 rcu_read_lock(); 175 178 struct found_btree_node n = { 176 179 .btree_id = BTREE_NODE_ID(bn),
+1
fs/bcachefs/data_update.c
··· 80 80 if (ptr2 == ptr) 81 81 break; 82 82 83 + ca = bch2_dev_have_ref(c, ptr2->dev); 83 84 bucket = PTR_BUCKET_POS(ca, ptr2); 84 85 bch2_bucket_nocow_unlock(&c->nocow_locks, bucket, 0); 85 86 }
+115 -36
fs/bcachefs/disk_accounting.c
··· 242 242 *p = swab64(*p); 243 243 } 244 244 245 + static inline void __accounting_to_replicas(struct bch_replicas_entry_v1 *r, 246 + struct disk_accounting_pos acc) 247 + { 248 + unsafe_memcpy(r, &acc.replicas, 249 + replicas_entry_bytes(&acc.replicas), 250 + "variable length struct"); 251 + } 252 + 245 253 static inline bool accounting_to_replicas(struct bch_replicas_entry_v1 *r, struct bpos p) 246 254 { 247 255 struct disk_accounting_pos acc_k; ··· 257 249 258 250 switch (acc_k.type) { 259 251 case BCH_DISK_ACCOUNTING_replicas: 260 - unsafe_memcpy(r, &acc_k.replicas, 261 - replicas_entry_bytes(&acc_k.replicas), 262 - "variable length struct"); 252 + __accounting_to_replicas(r, acc_k); 263 253 return true; 264 254 default: 265 255 return false; ··· 614 608 return ret; 615 609 } 616 610 611 + static int bch2_disk_accounting_validate_late(struct btree_trans *trans, 612 + struct disk_accounting_pos acc, 613 + u64 *v, unsigned nr) 614 + { 615 + struct bch_fs *c = trans->c; 616 + struct printbuf buf = PRINTBUF; 617 + int ret = 0, invalid_dev = -1; 618 + 619 + switch (acc.type) { 620 + case BCH_DISK_ACCOUNTING_replicas: { 621 + struct bch_replicas_padded r; 622 + __accounting_to_replicas(&r.e, acc); 623 + 624 + for (unsigned i = 0; i < r.e.nr_devs; i++) 625 + if (r.e.devs[i] != BCH_SB_MEMBER_INVALID && 626 + !bch2_dev_exists(c, r.e.devs[i])) { 627 + invalid_dev = r.e.devs[i]; 628 + goto invalid_device; 629 + } 630 + 631 + /* 632 + * All replicas entry checks except for invalid device are done 633 + * in bch2_accounting_validate 634 + */ 635 + BUG_ON(bch2_replicas_entry_validate(&r.e, c, &buf)); 636 + 637 + if (fsck_err_on(!bch2_replicas_marked_locked(c, &r.e), 638 + trans, accounting_replicas_not_marked, 639 + "accounting not marked in superblock replicas\n %s", 640 + (printbuf_reset(&buf), 641 + bch2_accounting_key_to_text(&buf, &acc), 642 + buf.buf))) { 643 + /* 644 + * We're not RW yet and still single threaded, dropping 645 + * and retaking lock is ok: 646 + */ 647 + percpu_up_write(&c->mark_lock); 648 + ret = bch2_mark_replicas(c, &r.e); 649 + if (ret) 650 + goto fsck_err; 651 + percpu_down_write(&c->mark_lock); 652 + } 653 + break; 654 + } 655 + 656 + case BCH_DISK_ACCOUNTING_dev_data_type: 657 + if (!bch2_dev_exists(c, acc.dev_data_type.dev)) { 658 + invalid_dev = acc.dev_data_type.dev; 659 + goto invalid_device; 660 + } 661 + break; 662 + } 663 + 664 + fsck_err: 665 + printbuf_exit(&buf); 666 + return ret; 667 + invalid_device: 668 + if (fsck_err(trans, accounting_to_invalid_device, 669 + "accounting entry points to invalid device %i\n %s", 670 + invalid_dev, 671 + (printbuf_reset(&buf), 672 + bch2_accounting_key_to_text(&buf, &acc), 673 + buf.buf))) { 674 + for (unsigned i = 0; i < nr; i++) 675 + v[i] = -v[i]; 676 + 677 + ret = commit_do(trans, NULL, NULL, 0, 678 + bch2_disk_accounting_mod(trans, &acc, v, nr, false)) ?: 679 + -BCH_ERR_remove_disk_accounting_entry; 680 + } else { 681 + ret = -BCH_ERR_remove_disk_accounting_entry; 682 + } 683 + goto fsck_err; 684 + } 685 + 617 686 /* 618 687 * At startup time, initialize the in memory accounting from the btree (and 619 688 * journal) ··· 747 666 } 748 667 keys->gap = keys->nr = dst - keys->data; 749 668 750 - percpu_down_read(&c->mark_lock); 751 - for (unsigned i = 0; i < acc->k.nr; i++) { 669 + percpu_down_write(&c->mark_lock); 670 + unsigned i = 0; 671 + while (i < acc->k.nr) { 672 + unsigned idx = inorder_to_eytzinger0(i, acc->k.nr); 673 + 674 + struct disk_accounting_pos acc_k; 675 + bpos_to_disk_accounting_pos(&acc_k, acc->k.data[idx].pos); 676 + 752 677 u64 v[BCH_ACCOUNTING_MAX_COUNTERS]; 753 - bch2_accounting_mem_read_counters(acc, i, v, ARRAY_SIZE(v), false); 754 - 755 - if (bch2_is_zero(v, sizeof(v[0]) * acc->k.data[i].nr_counters)) 756 - continue; 757 - 758 - struct bch_replicas_padded r; 759 - if (!accounting_to_replicas(&r.e, acc->k.data[i].pos)) 760 - continue; 678 + bch2_accounting_mem_read_counters(acc, idx, v, ARRAY_SIZE(v), false); 761 679 762 680 /* 763 - * If the replicas entry is invalid it'll get cleaned up by 764 - * check_allocations: 681 + * If the entry counters are zeroed, it should be treated as 682 + * nonexistent - it might point to an invalid device. 683 + * 684 + * Remove it, so that if it's re-added it gets re-marked in the 685 + * superblock: 765 686 */ 766 - if (bch2_replicas_entry_validate(&r.e, c, &buf)) 687 + ret = bch2_is_zero(v, sizeof(v[0]) * acc->k.data[idx].nr_counters) 688 + ? -BCH_ERR_remove_disk_accounting_entry 689 + : bch2_disk_accounting_validate_late(trans, acc_k, 690 + v, acc->k.data[idx].nr_counters); 691 + 692 + if (ret == -BCH_ERR_remove_disk_accounting_entry) { 693 + free_percpu(acc->k.data[idx].v[0]); 694 + free_percpu(acc->k.data[idx].v[1]); 695 + darray_remove_item(&acc->k, &acc->k.data[idx]); 696 + eytzinger0_sort(acc->k.data, acc->k.nr, sizeof(acc->k.data[0]), 697 + accounting_pos_cmp, NULL); 698 + ret = 0; 767 699 continue; 768 - 769 - struct disk_accounting_pos k; 770 - bpos_to_disk_accounting_pos(&k, acc->k.data[i].pos); 771 - 772 - if (fsck_err_on(!bch2_replicas_marked_locked(c, &r.e), 773 - trans, accounting_replicas_not_marked, 774 - "accounting not marked in superblock replicas\n %s", 775 - (printbuf_reset(&buf), 776 - bch2_accounting_key_to_text(&buf, &k), 777 - buf.buf))) { 778 - /* 779 - * We're not RW yet and still single threaded, dropping 780 - * and retaking lock is ok: 781 - */ 782 - percpu_up_read(&c->mark_lock); 783 - ret = bch2_mark_replicas(c, &r.e); 784 - if (ret) 785 - goto fsck_err; 786 - percpu_down_read(&c->mark_lock); 787 700 } 701 + 702 + if (ret) 703 + goto fsck_err; 704 + i++; 788 705 } 789 706 790 707 preempt_disable(); ··· 821 742 } 822 743 preempt_enable(); 823 744 fsck_err: 824 - percpu_up_read(&c->mark_lock); 745 + percpu_up_write(&c->mark_lock); 825 746 err: 826 747 printbuf_exit(&buf); 827 748 bch2_trans_put(trans);
+64 -30
fs/bcachefs/ec.c
··· 124 124 "incorrect value size (%zu < %u)", 125 125 bkey_val_u64s(k.k), stripe_val_u64s(s)); 126 126 127 + bkey_fsck_err_on(s->csum_granularity_bits >= 64, 128 + c, stripe_csum_granularity_bad, 129 + "invalid csum granularity (%u >= 64)", 130 + s->csum_granularity_bits); 131 + 127 132 ret = bch2_bkey_ptrs_validate(c, k, flags); 128 133 fsck_err: 129 134 return ret; ··· 150 145 nr_data, 151 146 s.nr_redundant); 152 147 bch2_prt_csum_type(out, s.csum_type); 153 - prt_printf(out, " gran %u", 1U << s.csum_granularity_bits); 148 + prt_str(out, " gran "); 149 + if (s.csum_granularity_bits < 64) 150 + prt_printf(out, "%llu", 1ULL << s.csum_granularity_bits); 151 + else 152 + prt_printf(out, "(invalid shift %u)", s.csum_granularity_bits); 154 153 155 154 if (s.disk_label) { 156 155 prt_str(out, " label"); ··· 1206 1197 /* stripe creation: */ 1207 1198 1208 1199 static int ec_stripe_key_update(struct btree_trans *trans, 1209 - struct bkey_i_stripe *new, 1210 - bool create) 1200 + struct bkey_i_stripe *old, 1201 + struct bkey_i_stripe *new) 1211 1202 { 1212 1203 struct bch_fs *c = trans->c; 1213 - struct btree_iter iter; 1214 - struct bkey_s_c k; 1215 - int ret; 1204 + bool create = !old; 1216 1205 1217 - k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_stripes, 1218 - new->k.p, BTREE_ITER_intent); 1219 - ret = bkey_err(k); 1206 + struct btree_iter iter; 1207 + struct bkey_s_c k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_stripes, 1208 + new->k.p, BTREE_ITER_intent); 1209 + int ret = bkey_err(k); 1220 1210 if (ret) 1221 1211 goto err; 1222 1212 1223 - if (k.k->type != (create ? KEY_TYPE_deleted : KEY_TYPE_stripe)) { 1224 - bch2_fs_inconsistent(c, "error %s stripe: got existing key type %s", 1225 - create ? "creating" : "updating", 1226 - bch2_bkey_types[k.k->type]); 1213 + if (bch2_fs_inconsistent_on(k.k->type != (create ? KEY_TYPE_deleted : KEY_TYPE_stripe), 1214 + c, "error %s stripe: got existing key type %s", 1215 + create ? "creating" : "updating", 1216 + bch2_bkey_types[k.k->type])) { 1227 1217 ret = -EINVAL; 1228 1218 goto err; 1229 1219 } 1230 1220 1231 1221 if (k.k->type == KEY_TYPE_stripe) { 1232 - const struct bch_stripe *old = bkey_s_c_to_stripe(k).v; 1233 - unsigned i; 1222 + const struct bch_stripe *v = bkey_s_c_to_stripe(k).v; 1234 1223 1235 - if (old->nr_blocks != new->v.nr_blocks) { 1236 - bch_err(c, "error updating stripe: nr_blocks does not match"); 1237 - ret = -EINVAL; 1238 - goto err; 1239 - } 1224 + BUG_ON(old->v.nr_blocks != new->v.nr_blocks); 1225 + BUG_ON(old->v.nr_blocks != v->nr_blocks); 1240 1226 1241 - for (i = 0; i < new->v.nr_blocks; i++) { 1242 - unsigned v = stripe_blockcount_get(old, i); 1227 + for (unsigned i = 0; i < new->v.nr_blocks; i++) { 1228 + unsigned sectors = stripe_blockcount_get(v, i); 1243 1229 1244 - BUG_ON(v && 1245 - (old->ptrs[i].dev != new->v.ptrs[i].dev || 1246 - old->ptrs[i].gen != new->v.ptrs[i].gen || 1247 - old->ptrs[i].offset != new->v.ptrs[i].offset)); 1230 + if (!bch2_extent_ptr_eq(old->v.ptrs[i], new->v.ptrs[i]) && sectors) { 1231 + struct printbuf buf = PRINTBUF; 1248 1232 1249 - stripe_blockcount_set(&new->v, i, v); 1233 + prt_printf(&buf, "stripe changed nonempty block %u", i); 1234 + prt_str(&buf, "\nold: "); 1235 + bch2_bkey_val_to_text(&buf, c, k); 1236 + prt_str(&buf, "\nnew: "); 1237 + bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&new->k_i)); 1238 + bch2_fs_inconsistent(c, "%s", buf.buf); 1239 + printbuf_exit(&buf); 1240 + ret = -EINVAL; 1241 + goto err; 1242 + } 1243 + 1244 + /* 1245 + * If the stripe ptr changed underneath us, it must have 1246 + * been dev_remove_stripes() -> * invalidate_stripe_to_dev() 1247 + */ 1248 + if (!bch2_extent_ptr_eq(old->v.ptrs[i], v->ptrs[i])) { 1249 + BUG_ON(v->ptrs[i].dev != BCH_SB_MEMBER_INVALID); 1250 + 1251 + if (bch2_extent_ptr_eq(old->v.ptrs[i], new->v.ptrs[i])) 1252 + new->v.ptrs[i].dev = BCH_SB_MEMBER_INVALID; 1253 + } 1254 + 1255 + stripe_blockcount_set(&new->v, i, sectors); 1250 1256 } 1251 1257 } 1252 1258 ··· 1523 1499 BCH_TRANS_COMMIT_no_check_rw| 1524 1500 BCH_TRANS_COMMIT_no_enospc, 1525 1501 ec_stripe_key_update(trans, 1526 - bkey_i_to_stripe(&s->new_stripe.key), 1527 - !s->have_existing_stripe)); 1502 + s->have_existing_stripe 1503 + ? bkey_i_to_stripe(&s->existing_stripe.key) 1504 + : NULL, 1505 + bkey_i_to_stripe(&s->new_stripe.key))); 1528 1506 bch_err_msg(c, ret, "creating stripe key"); 1529 1507 if (ret) { 1530 1508 goto err; ··· 1902 1876 bitmap_and(devs.d, devs.d, c->rw_devs[BCH_DATA_user].d, BCH_SB_MEMBERS_MAX); 1903 1877 1904 1878 for_each_set_bit(i, h->s->blocks_gotten, v->nr_blocks) { 1905 - __clear_bit(v->ptrs[i].dev, devs.d); 1879 + /* 1880 + * Note: we don't yet repair invalid blocks (failed/removed 1881 + * devices) when reusing stripes - we still need a codepath to 1882 + * walk backpointers and update all extents that point to that 1883 + * block when updating the stripe 1884 + */ 1885 + if (v->ptrs[i].dev != BCH_SB_MEMBER_INVALID) 1886 + __clear_bit(v->ptrs[i].dev, devs.d); 1887 + 1906 1888 if (i < h->s->nr_data) 1907 1889 nr_have_data++; 1908 1890 else
+2 -1
fs/bcachefs/errcode.h
··· 268 268 x(BCH_ERR_nopromote, nopromote_no_writes) \ 269 269 x(BCH_ERR_nopromote, nopromote_enomem) \ 270 270 x(0, invalid_snapshot_node) \ 271 - x(0, option_needs_open_fs) 271 + x(0, option_needs_open_fs) \ 272 + x(0, remove_disk_accounting_entry) 272 273 273 274 enum bch_errcode { 274 275 BCH_ERR_START = 2048,
+10
fs/bcachefs/extents.h
··· 695 695 int bch2_bkey_ptrs_validate(struct bch_fs *, struct bkey_s_c, 696 696 enum bch_validate_flags); 697 697 698 + static inline bool bch2_extent_ptr_eq(struct bch_extent_ptr ptr1, 699 + struct bch_extent_ptr ptr2) 700 + { 701 + return (ptr1.cached == ptr2.cached && 702 + ptr1.unwritten == ptr2.unwritten && 703 + ptr1.offset == ptr2.offset && 704 + ptr1.dev == ptr2.dev && 705 + ptr1.dev == ptr2.dev); 706 + } 707 + 698 708 void bch2_ptr_swab(struct bkey_s); 699 709 700 710 const struct bch_extent_rebalance *bch2_bkey_rebalance_opts(struct bkey_s_c);
+2 -1
fs/bcachefs/fs-io-direct.c
··· 369 369 370 370 static __always_inline long bch2_dio_write_done(struct dio_write *dio) 371 371 { 372 + struct bch_fs *c = dio->op.c; 372 373 struct kiocb *req = dio->req; 373 374 struct bch_inode_info *inode = dio->inode; 374 375 bool sync = dio->sync; ··· 388 387 ret = dio->op.error ?: ((long) dio->written << 9); 389 388 bio_put(&dio->op.wbio.bio); 390 389 391 - bch2_write_ref_put(dio->op.c, BCH_WRITE_REF_dio_write); 390 + bch2_write_ref_put(c, BCH_WRITE_REF_dio_write); 392 391 393 392 /* inode->i_dio_count is our ref on inode and thus bch_fs */ 394 393 inode_dio_end(&inode->v);
+99 -3
fs/bcachefs/fs.c
··· 157 157 return a.subvol == b.subvol && a.inum == b.inum; 158 158 } 159 159 160 + static u32 bch2_vfs_inode_hash_fn(const void *data, u32 len, u32 seed) 161 + { 162 + const subvol_inum *inum = data; 163 + 164 + return jhash(&inum->inum, sizeof(inum->inum), seed); 165 + } 166 + 167 + static u32 bch2_vfs_inode_obj_hash_fn(const void *data, u32 len, u32 seed) 168 + { 169 + const struct bch_inode_info *inode = data; 170 + 171 + return bch2_vfs_inode_hash_fn(&inode->ei_inum, sizeof(inode->ei_inum), seed); 172 + } 173 + 160 174 static int bch2_vfs_inode_cmp_fn(struct rhashtable_compare_arg *arg, 161 175 const void *obj) 162 176 { ··· 184 170 .head_offset = offsetof(struct bch_inode_info, hash), 185 171 .key_offset = offsetof(struct bch_inode_info, ei_inum), 186 172 .key_len = sizeof(subvol_inum), 173 + .hashfn = bch2_vfs_inode_hash_fn, 174 + .obj_hashfn = bch2_vfs_inode_obj_hash_fn, 187 175 .obj_cmpfn = bch2_vfs_inode_cmp_fn, 188 176 .automatic_shrinking = true, 189 177 }; 190 178 191 - struct bch_inode_info *__bch2_inode_hash_find(struct bch_fs *c, subvol_inum inum) 179 + int bch2_inode_or_descendents_is_open(struct btree_trans *trans, struct bpos p) 180 + { 181 + struct bch_fs *c = trans->c; 182 + struct rhashtable *ht = &c->vfs_inodes_table; 183 + subvol_inum inum = (subvol_inum) { .inum = p.offset }; 184 + DARRAY(u32) subvols; 185 + int ret = 0; 186 + 187 + if (!test_bit(BCH_FS_started, &c->flags)) 188 + return false; 189 + 190 + darray_init(&subvols); 191 + restart_from_top: 192 + 193 + /* 194 + * Tweaked version of __rhashtable_lookup(); we need to get a list of 195 + * subvolumes in which the given inode number is open. 196 + * 197 + * For this to work, we don't include the subvolume ID in the key that 198 + * we hash - all inodes with the same inode number regardless of 199 + * subvolume will hash to the same slot. 200 + * 201 + * This will be less than ideal if the same file is ever open 202 + * simultaneously in many different snapshots: 203 + */ 204 + rcu_read_lock(); 205 + struct rhash_lock_head __rcu *const *bkt; 206 + struct rhash_head *he; 207 + unsigned int hash; 208 + struct bucket_table *tbl = rht_dereference_rcu(ht->tbl, ht); 209 + restart: 210 + hash = rht_key_hashfn(ht, tbl, &inum, bch2_vfs_inodes_params); 211 + bkt = rht_bucket(tbl, hash); 212 + do { 213 + struct bch_inode_info *inode; 214 + 215 + rht_for_each_entry_rcu_from(inode, he, rht_ptr_rcu(bkt), tbl, hash, hash) { 216 + if (inode->ei_inum.inum == inum.inum) { 217 + ret = darray_push_gfp(&subvols, inode->ei_inum.subvol, 218 + GFP_NOWAIT|__GFP_NOWARN); 219 + if (ret) { 220 + rcu_read_unlock(); 221 + ret = darray_make_room(&subvols, 1); 222 + if (ret) 223 + goto err; 224 + subvols.nr = 0; 225 + goto restart_from_top; 226 + } 227 + } 228 + } 229 + /* An object might have been moved to a different hash chain, 230 + * while we walk along it - better check and retry. 231 + */ 232 + } while (he != RHT_NULLS_MARKER(bkt)); 233 + 234 + /* Ensure we see any new tables. */ 235 + smp_rmb(); 236 + 237 + tbl = rht_dereference_rcu(tbl->future_tbl, ht); 238 + if (unlikely(tbl)) 239 + goto restart; 240 + rcu_read_unlock(); 241 + 242 + darray_for_each(subvols, i) { 243 + u32 snap; 244 + ret = bch2_subvolume_get_snapshot(trans, *i, &snap); 245 + if (ret) 246 + goto err; 247 + 248 + ret = bch2_snapshot_is_ancestor(c, snap, p.snapshot); 249 + if (ret) 250 + break; 251 + } 252 + err: 253 + darray_exit(&subvols); 254 + return ret; 255 + } 256 + 257 + static struct bch_inode_info *__bch2_inode_hash_find(struct bch_fs *c, subvol_inum inum) 192 258 { 193 259 return rhashtable_lookup_fast(&c->vfs_inodes_table, &inum, bch2_vfs_inodes_params); 194 260 } ··· 278 184 subvol_inum inum) 279 185 { 280 186 wait_queue_head_t *wq; 281 - DEFINE_WAIT_BIT(wait, &inode->v.i_state, __I_NEW); 187 + struct wait_bit_queue_entry wait; 188 + 282 189 wq = inode_bit_waitqueue(&wait, &inode->v, __I_NEW); 283 190 prepare_to_wait(wq, &wait.wq_entry, TASK_UNINTERRUPTIBLE); 284 191 spin_unlock(&inode->v.i_lock); ··· 347 252 348 253 set_bit(EI_INODE_HASHED, &inode->ei_flags); 349 254 retry: 350 - if (unlikely(rhashtable_lookup_insert_fast(&c->vfs_inodes_table, 255 + if (unlikely(rhashtable_lookup_insert_key(&c->vfs_inodes_table, 256 + &inode->ei_inum, 351 257 &inode->hash, 352 258 bch2_vfs_inodes_params))) { 353 259 old = bch2_inode_hash_find(c, trans, inode->ei_inum);
+3 -6
fs/bcachefs/fs.h
··· 54 54 return inode->ei_inum; 55 55 } 56 56 57 - struct bch_inode_info *__bch2_inode_hash_find(struct bch_fs *, subvol_inum); 58 - 59 57 /* 60 58 * Set if we've gotten a btree error for this inode, and thus the vfs inode and 61 59 * btree inode may be inconsistent: ··· 146 148 __bch2_create(struct mnt_idmap *, struct bch_inode_info *, 147 149 struct dentry *, umode_t, dev_t, subvol_inum, unsigned); 148 150 151 + int bch2_inode_or_descendents_is_open(struct btree_trans *trans, struct bpos p); 152 + 149 153 int bch2_fs_quota_transfer(struct bch_fs *, 150 154 struct bch_inode_info *, 151 155 struct bch_qid, ··· 198 198 199 199 #define bch2_inode_update_after_write(_trans, _inode, _inode_u, _fields) ({ do {} while (0); }) 200 200 201 - static inline struct bch_inode_info *__bch2_inode_hash_find(struct bch_fs *c, subvol_inum inum) 202 - { 203 - return NULL; 204 - } 201 + static inline int bch2_inode_or_descendents_is_open(struct btree_trans *trans, struct bpos p) { return 0; } 205 202 206 203 static inline void bch2_evict_subvolume_inodes(struct bch_fs *c, 207 204 snapshot_id_list *s) {}
+231 -153
fs/bcachefs/fsck.c
··· 326 326 return ret; 327 327 } 328 328 329 + static inline bool inode_should_reattach(struct bch_inode_unpacked *inode) 330 + { 331 + if (inode->bi_inum == BCACHEFS_ROOT_INO && 332 + inode->bi_subvol == BCACHEFS_ROOT_SUBVOL) 333 + return false; 334 + 335 + return !inode->bi_dir && !(inode->bi_flags & BCH_INODE_unlinked); 336 + } 337 + 338 + static int maybe_delete_dirent(struct btree_trans *trans, struct bpos d_pos, u32 snapshot) 339 + { 340 + struct btree_iter iter; 341 + struct bkey_s_c k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_dirents, 342 + SPOS(d_pos.inode, d_pos.offset, snapshot), 343 + BTREE_ITER_intent| 344 + BTREE_ITER_with_updates); 345 + int ret = bkey_err(k); 346 + if (ret) 347 + return ret; 348 + 349 + if (bpos_eq(k.k->p, d_pos)) { 350 + /* 351 + * delet_at() doesn't work because the update path doesn't 352 + * internally use BTREE_ITER_with_updates yet 353 + */ 354 + struct bkey_i *k = bch2_trans_kmalloc(trans, sizeof(*k)); 355 + ret = PTR_ERR_OR_ZERO(k); 356 + if (ret) 357 + goto err; 358 + 359 + bkey_init(&k->k); 360 + k->k.type = KEY_TYPE_whiteout; 361 + k->k.p = iter.pos; 362 + ret = bch2_trans_update(trans, &iter, k, BTREE_UPDATE_internal_snapshot_node); 363 + } 364 + err: 365 + bch2_trans_iter_exit(trans, &iter); 366 + return ret; 367 + } 368 + 329 369 static int reattach_inode(struct btree_trans *trans, struct bch_inode_unpacked *inode) 330 370 { 331 371 struct bch_fs *c = trans->c; 332 - struct bch_hash_info dir_hash; 333 372 struct bch_inode_unpacked lostfound; 334 373 char name_buf[20]; 335 - struct qstr name; 336 - u64 dir_offset = 0; 337 - u32 dirent_snapshot = inode->bi_snapshot; 338 374 int ret; 339 375 376 + u32 dirent_snapshot = inode->bi_snapshot; 340 377 if (inode->bi_subvol) { 341 378 inode->bi_parent_subvol = BCACHEFS_ROOT_SUBVOL; 342 379 ··· 404 367 if (ret) 405 368 return ret; 406 369 407 - dir_hash = bch2_hash_info_init(c, &lostfound); 370 + struct bch_hash_info dir_hash = bch2_hash_info_init(c, &lostfound); 371 + struct qstr name = (struct qstr) QSTR(name_buf); 408 372 409 - name = (struct qstr) QSTR(name_buf); 373 + inode->bi_dir = lostfound.bi_inum; 410 374 411 375 ret = bch2_dirent_create_snapshot(trans, 412 376 inode->bi_parent_subvol, lostfound.bi_inum, ··· 416 378 inode_d_type(inode), 417 379 &name, 418 380 inode->bi_subvol ?: inode->bi_inum, 419 - &dir_offset, 381 + &inode->bi_dir_offset, 420 382 STR_HASH_must_create); 421 383 if (ret) { 422 384 bch_err_msg(c, ret, "error creating dirent"); 423 385 return ret; 424 386 } 425 387 426 - inode->bi_dir = lostfound.bi_inum; 427 - inode->bi_dir_offset = dir_offset; 388 + ret = __bch2_fsck_write_inode(trans, inode); 389 + if (ret) 390 + return ret; 428 391 429 - return __bch2_fsck_write_inode(trans, inode); 392 + /* 393 + * Fix up inodes in child snapshots: if they should also be reattached 394 + * update the backpointer field, if they should not be we need to emit 395 + * whiteouts for the dirent we just created. 396 + */ 397 + if (!inode->bi_subvol && bch2_snapshot_is_leaf(c, inode->bi_snapshot) <= 0) { 398 + snapshot_id_list whiteouts_done; 399 + struct btree_iter iter; 400 + struct bkey_s_c k; 401 + 402 + darray_init(&whiteouts_done); 403 + 404 + for_each_btree_key_reverse_norestart(trans, iter, 405 + BTREE_ID_inodes, SPOS(0, inode->bi_inum, inode->bi_snapshot - 1), 406 + BTREE_ITER_all_snapshots|BTREE_ITER_intent, k, ret) { 407 + if (k.k->p.offset != inode->bi_inum) 408 + break; 409 + 410 + if (!bkey_is_inode(k.k) || 411 + !bch2_snapshot_is_ancestor(c, k.k->p.snapshot, inode->bi_snapshot) || 412 + snapshot_list_has_ancestor(c, &whiteouts_done, k.k->p.snapshot)) 413 + continue; 414 + 415 + struct bch_inode_unpacked child_inode; 416 + bch2_inode_unpack(k, &child_inode); 417 + 418 + if (!inode_should_reattach(&child_inode)) { 419 + ret = maybe_delete_dirent(trans, 420 + SPOS(lostfound.bi_inum, inode->bi_dir_offset, 421 + dirent_snapshot), 422 + k.k->p.snapshot); 423 + if (ret) 424 + break; 425 + 426 + ret = snapshot_list_add(c, &whiteouts_done, k.k->p.snapshot); 427 + if (ret) 428 + break; 429 + } else { 430 + iter.snapshot = k.k->p.snapshot; 431 + child_inode.bi_dir = inode->bi_dir; 432 + child_inode.bi_dir_offset = inode->bi_dir_offset; 433 + 434 + ret = bch2_inode_write_flags(trans, &iter, &child_inode, 435 + BTREE_UPDATE_internal_snapshot_node); 436 + if (ret) 437 + break; 438 + } 439 + } 440 + darray_exit(&whiteouts_done); 441 + bch2_trans_iter_exit(trans, &iter); 442 + } 443 + 444 + return ret; 430 445 } 431 446 432 447 static int remove_backpointer(struct btree_trans *trans, ··· 1085 994 */ 1086 995 inode->bi_dir = 0; 1087 996 inode->bi_dir_offset = 0; 1088 - inode->bi_flags &= ~BCH_INODE_backptr_untrusted; 1089 997 *write_inode = true; 1090 998 } 1091 999 ··· 1096 1006 return ret; 1097 1007 } 1098 1008 1099 - static bool bch2_inode_is_open(struct bch_fs *c, struct bpos p) 1100 - { 1101 - subvol_inum inum = { 1102 - .subvol = snapshot_t(c, p.snapshot)->subvol, 1103 - .inum = p.offset, 1104 - }; 1105 - 1106 - /* snapshot tree corruption, can't safely delete */ 1107 - if (!inum.subvol) { 1108 - bch_warn_ratelimited(c, "%s(): snapshot %u has no subvol, unlinked but can't safely delete", __func__, p.snapshot); 1109 - return true; 1110 - } 1111 - 1112 - return __bch2_inode_hash_find(c, inum) != NULL; 1113 - } 1114 - 1115 1009 static int check_inode(struct btree_trans *trans, 1116 1010 struct btree_iter *iter, 1117 1011 struct bkey_s_c k, 1118 1012 struct bch_inode_unpacked *prev, 1119 - struct snapshots_seen *s, 1120 - bool full) 1013 + struct snapshots_seen *s) 1121 1014 { 1122 1015 struct bch_fs *c = trans->c; 1123 1016 struct printbuf buf = PRINTBUF; ··· 1122 1049 return 0; 1123 1050 1124 1051 BUG_ON(bch2_inode_unpack(k, &u)); 1125 - 1126 - if (!full && 1127 - !(u.bi_flags & (BCH_INODE_i_size_dirty| 1128 - BCH_INODE_i_sectors_dirty| 1129 - BCH_INODE_unlinked))) 1130 - return 0; 1131 1052 1132 1053 if (prev->bi_inum != u.bi_inum) 1133 1054 *prev = u; ··· 1168 1101 ret = 0; 1169 1102 } 1170 1103 1171 - if ((u.bi_flags & (BCH_INODE_i_size_dirty|BCH_INODE_unlinked)) && 1172 - bch2_key_has_snapshot_overwrites(trans, BTREE_ID_inodes, k.k->p)) { 1173 - struct bpos new_min_pos; 1104 + ret = bch2_inode_has_child_snapshots(trans, k.k->p); 1105 + if (ret < 0) 1106 + goto err; 1174 1107 1175 - ret = bch2_propagate_key_to_snapshot_leaves(trans, iter->btree_id, k, &new_min_pos); 1108 + if (fsck_err_on(ret != !!(u.bi_flags & BCH_INODE_has_child_snapshot), 1109 + trans, inode_has_child_snapshots_wrong, 1110 + "inode has_child_snapshots flag wrong (should be %u)\n%s", 1111 + ret, 1112 + (printbuf_reset(&buf), 1113 + bch2_inode_unpacked_to_text(&buf, &u), 1114 + buf.buf))) { 1176 1115 if (ret) 1177 - goto err; 1178 - 1179 - u.bi_flags &= ~BCH_INODE_i_size_dirty|BCH_INODE_unlinked; 1180 - 1181 - ret = __bch2_fsck_write_inode(trans, &u); 1182 - 1183 - bch_err_msg(c, ret, "in fsck updating inode"); 1184 - if (ret) 1185 - goto err_noprint; 1186 - 1187 - if (!bpos_eq(new_min_pos, POS_MIN)) 1188 - bch2_btree_iter_set_pos(iter, bpos_predecessor(new_min_pos)); 1189 - goto err_noprint; 1116 + u.bi_flags |= BCH_INODE_has_child_snapshot; 1117 + else 1118 + u.bi_flags &= ~BCH_INODE_has_child_snapshot; 1119 + do_update = true; 1190 1120 } 1121 + ret = 0; 1191 1122 1192 - if (u.bi_flags & BCH_INODE_unlinked) { 1123 + if ((u.bi_flags & BCH_INODE_unlinked) && 1124 + !(u.bi_flags & BCH_INODE_has_child_snapshot)) { 1193 1125 if (!test_bit(BCH_FS_started, &c->flags)) { 1194 1126 /* 1195 1127 * If we're not in online fsck, don't delete unlinked ··· 1213 1147 if (ret) 1214 1148 goto err; 1215 1149 } else { 1216 - if (fsck_err_on(!bch2_inode_is_open(c, k.k->p), 1150 + ret = bch2_inode_or_descendents_is_open(trans, k.k->p); 1151 + if (ret < 0) 1152 + goto err; 1153 + 1154 + if (fsck_err_on(!ret, 1217 1155 trans, inode_unlinked_and_not_open, 1218 1156 "inode %llu%u unlinked and not open", 1219 1157 u.bi_inum, u.bi_snapshot)) { ··· 1225 1155 bch_err_msg(c, ret, "in fsck deleting inode"); 1226 1156 goto err_noprint; 1227 1157 } 1158 + ret = 0; 1228 1159 } 1229 - } 1230 - 1231 - /* i_size_dirty is vestigal, since we now have logged ops for truncate * */ 1232 - if (u.bi_flags & BCH_INODE_i_size_dirty && 1233 - (!test_bit(BCH_FS_clean_recovery, &c->flags) || 1234 - fsck_err(trans, inode_i_size_dirty_but_clean, 1235 - "filesystem marked clean, but inode %llu has i_size dirty", 1236 - u.bi_inum))) { 1237 - bch_verbose(c, "truncating inode %llu", u.bi_inum); 1238 - 1239 - /* 1240 - * XXX: need to truncate partial blocks too here - or ideally 1241 - * just switch units to bytes and that issue goes away 1242 - */ 1243 - ret = bch2_btree_delete_range_trans(trans, BTREE_ID_extents, 1244 - SPOS(u.bi_inum, round_up(u.bi_size, block_bytes(c)) >> 9, 1245 - iter->pos.snapshot), 1246 - POS(u.bi_inum, U64_MAX), 1247 - 0, NULL); 1248 - bch_err_msg(c, ret, "in fsck truncating inode"); 1249 - if (ret) 1250 - return ret; 1251 - 1252 - /* 1253 - * We truncated without our normal sector accounting hook, just 1254 - * make sure we recalculate it: 1255 - */ 1256 - u.bi_flags |= BCH_INODE_i_sectors_dirty; 1257 - 1258 - u.bi_flags &= ~BCH_INODE_i_size_dirty; 1259 - do_update = true; 1260 - } 1261 - 1262 - /* i_sectors_dirty is vestigal, i_sectors is always updated transactionally */ 1263 - if (u.bi_flags & BCH_INODE_i_sectors_dirty && 1264 - (!test_bit(BCH_FS_clean_recovery, &c->flags) || 1265 - fsck_err(trans, inode_i_sectors_dirty_but_clean, 1266 - "filesystem marked clean, but inode %llu has i_sectors dirty", 1267 - u.bi_inum))) { 1268 - s64 sectors; 1269 - 1270 - bch_verbose(c, "recounting sectors for inode %llu", 1271 - u.bi_inum); 1272 - 1273 - sectors = bch2_count_inode_sectors(trans, u.bi_inum, iter->pos.snapshot); 1274 - if (sectors < 0) { 1275 - bch_err_msg(c, sectors, "in fsck recounting inode sectors"); 1276 - return sectors; 1277 - } 1278 - 1279 - u.bi_sectors = sectors; 1280 - u.bi_flags &= ~BCH_INODE_i_sectors_dirty; 1281 - do_update = true; 1282 - } 1283 - 1284 - if (u.bi_flags & BCH_INODE_backptr_untrusted) { 1285 - u.bi_dir = 0; 1286 - u.bi_dir_offset = 0; 1287 - u.bi_flags &= ~BCH_INODE_backptr_untrusted; 1288 - do_update = true; 1289 1160 } 1290 1161 1291 1162 if (fsck_err_on(u.bi_parent_subvol && ··· 1285 1274 1286 1275 int bch2_check_inodes(struct bch_fs *c) 1287 1276 { 1288 - bool full = c->opts.fsck; 1289 1277 struct bch_inode_unpacked prev = { 0 }; 1290 1278 struct snapshots_seen s; 1291 1279 ··· 1295 1285 POS_MIN, 1296 1286 BTREE_ITER_prefetch|BTREE_ITER_all_snapshots, k, 1297 1287 NULL, NULL, BCH_TRANS_COMMIT_no_enospc, 1298 - check_inode(trans, &iter, k, &prev, &s, full))); 1288 + check_inode(trans, &iter, k, &prev, &s))); 1299 1289 1300 1290 snapshots_seen_exit(&s); 1291 + bch_err_fn(c, ret); 1292 + return ret; 1293 + } 1294 + 1295 + static int find_oldest_inode_needs_reattach(struct btree_trans *trans, 1296 + struct bch_inode_unpacked *inode) 1297 + { 1298 + struct bch_fs *c = trans->c; 1299 + struct btree_iter iter; 1300 + struct bkey_s_c k; 1301 + int ret = 0; 1302 + 1303 + /* 1304 + * We look for inodes to reattach in natural key order, leaves first, 1305 + * but we should do the reattach at the oldest version that needs to be 1306 + * reattached: 1307 + */ 1308 + for_each_btree_key_norestart(trans, iter, 1309 + BTREE_ID_inodes, 1310 + SPOS(0, inode->bi_inum, inode->bi_snapshot + 1), 1311 + BTREE_ITER_all_snapshots, k, ret) { 1312 + if (k.k->p.offset != inode->bi_inum) 1313 + break; 1314 + 1315 + if (!bch2_snapshot_is_ancestor(c, inode->bi_snapshot, k.k->p.snapshot)) 1316 + continue; 1317 + 1318 + if (!bkey_is_inode(k.k)) 1319 + break; 1320 + 1321 + struct bch_inode_unpacked parent_inode; 1322 + bch2_inode_unpack(k, &parent_inode); 1323 + 1324 + if (!inode_should_reattach(&parent_inode)) 1325 + break; 1326 + 1327 + *inode = parent_inode; 1328 + } 1329 + bch2_trans_iter_exit(trans, &iter); 1330 + 1331 + return ret; 1332 + } 1333 + 1334 + static int check_unreachable_inode(struct btree_trans *trans, 1335 + struct btree_iter *iter, 1336 + struct bkey_s_c k) 1337 + { 1338 + struct printbuf buf = PRINTBUF; 1339 + int ret = 0; 1340 + 1341 + if (!bkey_is_inode(k.k)) 1342 + return 0; 1343 + 1344 + struct bch_inode_unpacked inode; 1345 + BUG_ON(bch2_inode_unpack(k, &inode)); 1346 + 1347 + if (!inode_should_reattach(&inode)) 1348 + return 0; 1349 + 1350 + ret = find_oldest_inode_needs_reattach(trans, &inode); 1351 + if (ret) 1352 + return ret; 1353 + 1354 + if (fsck_err(trans, inode_unreachable, 1355 + "unreachable inode:\n%s", 1356 + (bch2_inode_unpacked_to_text(&buf, &inode), 1357 + buf.buf))) 1358 + ret = reattach_inode(trans, &inode); 1359 + fsck_err: 1360 + printbuf_exit(&buf); 1361 + return ret; 1362 + } 1363 + 1364 + /* 1365 + * Reattach unreachable (but not unlinked) inodes 1366 + * 1367 + * Run after check_inodes() and check_dirents(), so we node that inode 1368 + * backpointer fields point to valid dirents, and every inode that has a dirent 1369 + * that points to it has its backpointer field set - so we're just looking for 1370 + * non-unlinked inodes without backpointers: 1371 + * 1372 + * XXX: this is racy w.r.t. hardlink removal in online fsck 1373 + */ 1374 + int bch2_check_unreachable_inodes(struct bch_fs *c) 1375 + { 1376 + int ret = bch2_trans_run(c, 1377 + for_each_btree_key_commit(trans, iter, BTREE_ID_inodes, 1378 + POS_MIN, 1379 + BTREE_ITER_prefetch|BTREE_ITER_all_snapshots, k, 1380 + NULL, NULL, BCH_TRANS_COMMIT_no_enospc, 1381 + check_unreachable_inode(trans, &iter, k))); 1301 1382 bch_err_fn(c, ret); 1302 1383 return ret; 1303 1384 } ··· 1795 1694 !key_visible_in_snapshot(c, s, i->snapshot, k.k->p.snapshot)) 1796 1695 continue; 1797 1696 1798 - if (fsck_err_on(!(i->inode.bi_flags & BCH_INODE_i_size_dirty) && 1799 - k.k->p.offset > round_up(i->inode.bi_size, block_bytes(c)) >> 9 && 1697 + if (fsck_err_on(k.k->p.offset > round_up(i->inode.bi_size, block_bytes(c)) >> 9 && 1800 1698 !bkey_extent_is_reservation(k), 1801 1699 trans, extent_past_end_of_inode, 1802 1700 "extent type past end of inode %llu:%u, i_size %llu\n %s", ··· 2550 2450 if (ret) 2551 2451 break; 2552 2452 2553 - /* 2554 - * We've checked that inode backpointers point to valid dirents; 2555 - * here, it's sufficient to check that the subvolume root has a 2556 - * dirent: 2557 - */ 2558 - if (fsck_err_on(!subvol_root.bi_dir, 2559 - trans, subvol_unreachable, 2560 - "unreachable subvolume %s", 2561 - (bch2_bkey_val_to_text(&buf, c, s.s_c), 2562 - prt_newline(&buf), 2563 - bch2_inode_unpacked_to_text(&buf, &subvol_root), 2564 - buf.buf))) { 2565 - ret = reattach_subvol(trans, s); 2566 - break; 2567 - } 2568 - 2569 2453 u32 parent = le32_to_cpu(s.v->fs_path_parent); 2570 2454 2571 2455 if (darray_u32_has(&subvol_path, parent)) { ··· 2610 2526 return false; 2611 2527 } 2612 2528 2613 - /* 2614 - * Check that a given inode is reachable from its subvolume root - we already 2615 - * verified subvolume connectivity: 2616 - * 2617 - * XXX: we should also be verifying that inodes are in the right subvolumes 2618 - */ 2619 2529 static int check_path(struct btree_trans *trans, pathbuf *p, struct bkey_s_c inode_k) 2620 2530 { 2621 2531 struct bch_fs *c = trans->c; ··· 2622 2544 p->nr = 0; 2623 2545 2624 2546 BUG_ON(bch2_inode_unpack(inode_k, &inode)); 2547 + 2548 + if (!S_ISDIR(inode.bi_mode)) 2549 + return 0; 2625 2550 2626 2551 while (!inode.bi_subvol) { 2627 2552 struct btree_iter dirent_iter; ··· 2640 2559 bch2_trans_iter_exit(trans, &dirent_iter); 2641 2560 2642 2561 if (bch2_err_matches(ret, ENOENT)) { 2643 - ret = 0; 2644 - if (fsck_err(trans, inode_unreachable, 2645 - "unreachable inode\n%s", 2646 - (printbuf_reset(&buf), 2647 - bch2_bkey_val_to_text(&buf, c, inode_k), 2648 - buf.buf))) 2649 - ret = reattach_inode(trans, &inode); 2562 + printbuf_reset(&buf); 2563 + bch2_bkey_val_to_text(&buf, c, inode_k); 2564 + bch_err(c, "unreachable inode in check_directory_structure: %s\n%s", 2565 + bch2_err_str(ret), buf.buf); 2650 2566 goto out; 2651 2567 } 2652 2568 2653 2569 bch2_trans_iter_exit(trans, &dirent_iter); 2654 - 2655 - if (!S_ISDIR(inode.bi_mode)) 2656 - break; 2657 2570 2658 2571 ret = darray_push(p, ((struct pathbuf_entry) { 2659 2572 .inum = inode.bi_inum, ··· 2701 2626 } 2702 2627 2703 2628 /* 2704 - * Check for unreachable inodes, as well as loops in the directory structure: 2705 - * After bch2_check_dirents(), if an inode backpointer doesn't exist that means it's 2706 - * unreachable: 2629 + * Check for loops in the directory structure: all other connectivity issues 2630 + * have been fixed by prior passes 2707 2631 */ 2708 2632 int bch2_check_directory_structure(struct bch_fs *c) 2709 2633 { ··· 2830 2756 if (S_ISDIR(u.bi_mode)) 2831 2757 continue; 2832 2758 2759 + /* 2760 + * Previous passes ensured that bi_nlink is nonzero if 2761 + * it had multiple hardlinks: 2762 + */ 2833 2763 if (!u.bi_nlink) 2834 2764 continue; 2835 2765
+1
fs/bcachefs/fsck.h
··· 9 9 int bch2_check_xattrs(struct bch_fs *); 10 10 int bch2_check_root(struct bch_fs *); 11 11 int bch2_check_subvolume_structure(struct bch_fs *); 12 + int bch2_check_unreachable_inodes(struct bch_fs *); 12 13 int bch2_check_directory_structure(struct bch_fs *); 13 14 int bch2_check_nlinks(struct bch_fs *); 14 15 int bch2_fix_reflink_p(struct bch_fs *);
+242 -33
fs/bcachefs/inode.c
··· 12 12 #include "error.h" 13 13 #include "extents.h" 14 14 #include "extent_update.h" 15 + #include "fs.h" 15 16 #include "inode.h" 16 17 #include "str_hash.h" 17 18 #include "snapshot.h" ··· 34 33 NULL 35 34 }; 36 35 #undef x 36 + 37 + static int delete_ancestor_snapshot_inodes(struct btree_trans *, struct bpos); 37 38 38 39 static const u8 byte_table[8] = { 1, 2, 3, 4, 6, 8, 10, 13 }; 39 40 ··· 578 575 } 579 576 } 580 577 581 - static inline bool bkey_is_deleted_inode(struct bkey_s_c k) 578 + static inline void bkey_inode_flags_set(struct bkey_s k, u64 f) 582 579 { 583 - return bkey_inode_flags(k) & BCH_INODE_unlinked; 580 + switch (k.k->type) { 581 + case KEY_TYPE_inode: 582 + bkey_s_to_inode(k).v->bi_flags = cpu_to_le32(f); 583 + return; 584 + case KEY_TYPE_inode_v2: 585 + bkey_s_to_inode_v2(k).v->bi_flags = cpu_to_le64(f); 586 + return; 587 + case KEY_TYPE_inode_v3: 588 + bkey_s_to_inode_v3(k).v->bi_flags = cpu_to_le64(f); 589 + return; 590 + default: 591 + BUG(); 592 + } 593 + } 594 + 595 + static inline bool bkey_is_unlinked_inode(struct bkey_s_c k) 596 + { 597 + unsigned f = bkey_inode_flags(k) & BCH_INODE_unlinked; 598 + 599 + return (f & BCH_INODE_unlinked) && !(f & BCH_INODE_has_child_snapshot); 600 + } 601 + 602 + static struct bkey_s_c 603 + bch2_bkey_get_iter_snapshot_parent(struct btree_trans *trans, struct btree_iter *iter, 604 + enum btree_id btree, struct bpos pos, 605 + unsigned flags) 606 + { 607 + struct bch_fs *c = trans->c; 608 + struct bkey_s_c k; 609 + int ret = 0; 610 + 611 + for_each_btree_key_upto_norestart(trans, *iter, btree, 612 + bpos_successor(pos), 613 + SPOS(pos.inode, pos.offset, U32_MAX), 614 + flags|BTREE_ITER_all_snapshots, k, ret) 615 + if (bch2_snapshot_is_ancestor(c, pos.snapshot, k.k->p.snapshot)) 616 + return k; 617 + 618 + bch2_trans_iter_exit(trans, iter); 619 + return ret ? bkey_s_c_err(ret) : bkey_s_c_null; 620 + } 621 + 622 + static struct bkey_s_c 623 + bch2_inode_get_iter_snapshot_parent(struct btree_trans *trans, struct btree_iter *iter, 624 + struct bpos pos, unsigned flags) 625 + { 626 + struct bkey_s_c k; 627 + again: 628 + k = bch2_bkey_get_iter_snapshot_parent(trans, iter, BTREE_ID_inodes, pos, flags); 629 + if (!k.k || 630 + bkey_err(k) || 631 + bkey_is_inode(k.k)) 632 + return k; 633 + 634 + bch2_trans_iter_exit(trans, iter); 635 + pos = k.k->p; 636 + goto again; 637 + } 638 + 639 + int __bch2_inode_has_child_snapshots(struct btree_trans *trans, struct bpos pos) 640 + { 641 + struct bch_fs *c = trans->c; 642 + struct btree_iter iter; 643 + struct bkey_s_c k; 644 + int ret = 0; 645 + 646 + for_each_btree_key_upto_norestart(trans, iter, 647 + BTREE_ID_inodes, POS(0, pos.offset), bpos_predecessor(pos), 648 + BTREE_ITER_all_snapshots| 649 + BTREE_ITER_with_updates, k, ret) 650 + if (bch2_snapshot_is_ancestor(c, k.k->p.snapshot, pos.snapshot) && 651 + bkey_is_inode(k.k)) { 652 + ret = 1; 653 + break; 654 + } 655 + bch2_trans_iter_exit(trans, &iter); 656 + return ret; 657 + } 658 + 659 + static int update_inode_has_children(struct btree_trans *trans, 660 + struct bkey_s k, 661 + bool have_child) 662 + { 663 + if (!have_child) { 664 + int ret = bch2_inode_has_child_snapshots(trans, k.k->p); 665 + if (ret) 666 + return ret < 0 ? ret : 0; 667 + } 668 + 669 + u64 f = bkey_inode_flags(k.s_c); 670 + if (have_child != !!(f & BCH_INODE_has_child_snapshot)) 671 + bkey_inode_flags_set(k, f ^ BCH_INODE_has_child_snapshot); 672 + 673 + return 0; 674 + } 675 + 676 + static int update_parent_inode_has_children(struct btree_trans *trans, struct bpos pos, 677 + bool have_child) 678 + { 679 + struct btree_iter iter; 680 + struct bkey_s_c k = bch2_inode_get_iter_snapshot_parent(trans, 681 + &iter, pos, BTREE_ITER_with_updates); 682 + int ret = bkey_err(k); 683 + if (ret) 684 + return ret; 685 + if (!k.k) 686 + return 0; 687 + 688 + if (!have_child) { 689 + ret = bch2_inode_has_child_snapshots(trans, k.k->p); 690 + if (ret) { 691 + ret = ret < 0 ? ret : 0; 692 + goto err; 693 + } 694 + } 695 + 696 + u64 f = bkey_inode_flags(k); 697 + if (have_child != !!(f & BCH_INODE_has_child_snapshot)) { 698 + struct bkey_i *update = bch2_bkey_make_mut(trans, &iter, &k, 699 + BTREE_UPDATE_internal_snapshot_node); 700 + ret = PTR_ERR_OR_ZERO(update); 701 + if (ret) 702 + goto err; 703 + 704 + bkey_inode_flags_set(bkey_i_to_s(update), f ^ BCH_INODE_has_child_snapshot); 705 + } 706 + err: 707 + bch2_trans_iter_exit(trans, &iter); 708 + return ret; 584 709 } 585 710 586 711 int bch2_trigger_inode(struct btree_trans *trans, ··· 717 586 struct bkey_s new, 718 587 enum btree_iter_update_trigger_flags flags) 719 588 { 589 + struct bch_fs *c = trans->c; 590 + 720 591 if ((flags & BTREE_TRIGGER_atomic) && (flags & BTREE_TRIGGER_insert)) { 721 592 BUG_ON(!trans->journal_res.seq); 722 593 bkey_s_to_inode_v3(new).v->bi_journal_seq = cpu_to_le64(trans->journal_res.seq); ··· 732 599 return ret; 733 600 } 734 601 735 - int deleted_delta = (int) bkey_is_deleted_inode(new.s_c) - 736 - (int) bkey_is_deleted_inode(old); 737 - if ((flags & BTREE_TRIGGER_transactional) && deleted_delta) { 738 - int ret = bch2_btree_bit_mod_buffered(trans, BTREE_ID_deleted_inodes, 739 - new.k->p, deleted_delta > 0); 740 - if (ret) 741 - return ret; 602 + if (flags & BTREE_TRIGGER_transactional) { 603 + int unlinked_delta = (int) bkey_is_unlinked_inode(new.s_c) - 604 + (int) bkey_is_unlinked_inode(old); 605 + if (unlinked_delta) { 606 + int ret = bch2_btree_bit_mod_buffered(trans, BTREE_ID_deleted_inodes, 607 + new.k->p, unlinked_delta > 0); 608 + if (ret) 609 + return ret; 610 + } 611 + 612 + /* 613 + * If we're creating or deleting an inode at this snapshot ID, 614 + * and there might be an inode in a parent snapshot ID, we might 615 + * need to set or clear the has_child_snapshot flag on the 616 + * parent. 617 + */ 618 + int deleted_delta = (int) bkey_is_inode(new.k) - 619 + (int) bkey_is_inode(old.k); 620 + if (deleted_delta && 621 + bch2_snapshot_parent(c, new.k->p.snapshot)) { 622 + int ret = update_parent_inode_has_children(trans, new.k->p, 623 + deleted_delta > 0); 624 + if (ret) 625 + return ret; 626 + } 627 + 628 + /* 629 + * When an inode is first updated in a new snapshot, we may need 630 + * to clear has_child_snapshot 631 + */ 632 + if (deleted_delta > 0) { 633 + int ret = update_inode_has_children(trans, new, false); 634 + if (ret) 635 + return ret; 636 + } 742 637 } 743 638 744 639 return 0; ··· 1049 888 if (bch2_err_matches(ret, BCH_ERR_transaction_restart)) 1050 889 goto retry; 1051 890 891 + if (ret) 892 + goto err2; 893 + 894 + ret = delete_ancestor_snapshot_inodes(trans, SPOS(0, inum.inum, snapshot)); 895 + err2: 1052 896 bch2_trans_put(trans); 1053 897 return ret; 1054 898 } ··· 1158 992 return 0; 1159 993 } 1160 994 1161 - int bch2_inode_rm_snapshot(struct btree_trans *trans, u64 inum, u32 snapshot) 995 + static noinline int __bch2_inode_rm_snapshot(struct btree_trans *trans, u64 inum, u32 snapshot) 1162 996 { 1163 997 struct bch_fs *c = trans->c; 1164 998 struct btree_iter iter = { NULL }; ··· 1221 1055 return ret ?: -BCH_ERR_transaction_restart_nested; 1222 1056 } 1223 1057 1058 + /* 1059 + * After deleting an inode, there may be versions in older snapshots that should 1060 + * also be deleted - if they're not referenced by sibling snapshots and not open 1061 + * in other subvolumes: 1062 + */ 1063 + static int delete_ancestor_snapshot_inodes(struct btree_trans *trans, struct bpos pos) 1064 + { 1065 + struct btree_iter iter; 1066 + struct bkey_s_c k; 1067 + int ret; 1068 + next_parent: 1069 + ret = lockrestart_do(trans, 1070 + bkey_err(k = bch2_inode_get_iter_snapshot_parent(trans, &iter, pos, 0))); 1071 + if (ret || !k.k) 1072 + return ret; 1073 + 1074 + bool unlinked = bkey_is_unlinked_inode(k); 1075 + pos = k.k->p; 1076 + bch2_trans_iter_exit(trans, &iter); 1077 + 1078 + if (!unlinked) 1079 + return 0; 1080 + 1081 + ret = lockrestart_do(trans, bch2_inode_or_descendents_is_open(trans, pos)); 1082 + if (ret) 1083 + return ret < 0 ? ret : 0; 1084 + 1085 + ret = __bch2_inode_rm_snapshot(trans, pos.offset, pos.snapshot); 1086 + if (ret) 1087 + return ret; 1088 + goto next_parent; 1089 + } 1090 + 1091 + int bch2_inode_rm_snapshot(struct btree_trans *trans, u64 inum, u32 snapshot) 1092 + { 1093 + return __bch2_inode_rm_snapshot(trans, inum, snapshot) ?: 1094 + delete_ancestor_snapshot_inodes(trans, SPOS(0, inum, snapshot)); 1095 + } 1096 + 1224 1097 static int may_delete_deleted_inode(struct btree_trans *trans, 1225 1098 struct btree_iter *iter, 1226 1099 struct bpos pos, ··· 1269 1064 struct btree_iter inode_iter; 1270 1065 struct bkey_s_c k; 1271 1066 struct bch_inode_unpacked inode; 1067 + struct printbuf buf = PRINTBUF; 1272 1068 int ret; 1273 1069 1274 1070 k = bch2_bkey_get_iter(trans, &inode_iter, BTREE_ID_inodes, pos, BTREE_ITER_cached); ··· 1305 1099 pos.offset, pos.snapshot)) 1306 1100 goto delete; 1307 1101 1102 + if (fsck_err_on(inode.bi_flags & BCH_INODE_has_child_snapshot, 1103 + trans, deleted_inode_has_child_snapshots, 1104 + "inode with child snapshots %llu:%u in deleted_inodes btree", 1105 + pos.offset, pos.snapshot)) 1106 + goto delete; 1107 + 1108 + ret = bch2_inode_has_child_snapshots(trans, k.k->p); 1109 + if (ret < 0) 1110 + goto out; 1111 + 1112 + if (ret) { 1113 + if (fsck_err(trans, inode_has_child_snapshots_wrong, 1114 + "inode has_child_snapshots flag wrong (should be set)\n%s", 1115 + (printbuf_reset(&buf), 1116 + bch2_inode_unpacked_to_text(&buf, &inode), 1117 + buf.buf))) { 1118 + inode.bi_flags |= BCH_INODE_has_child_snapshot; 1119 + ret = __bch2_fsck_write_inode(trans, &inode); 1120 + if (ret) 1121 + goto out; 1122 + } 1123 + goto delete; 1124 + 1125 + } 1126 + 1308 1127 if (test_bit(BCH_FS_clean_recovery, &c->flags) && 1309 1128 !fsck_err(trans, deleted_inode_but_clean, 1310 1129 "filesystem marked as clean but have deleted inode %llu:%u", ··· 1338 1107 goto out; 1339 1108 } 1340 1109 1341 - if (bch2_snapshot_is_internal_node(c, pos.snapshot)) { 1342 - struct bpos new_min_pos; 1343 - 1344 - ret = bch2_propagate_key_to_snapshot_leaves(trans, inode_iter.btree_id, k, &new_min_pos); 1345 - if (ret) 1346 - goto out; 1347 - 1348 - inode.bi_flags &= ~BCH_INODE_unlinked; 1349 - 1350 - ret = bch2_inode_write_flags(trans, &inode_iter, &inode, 1351 - BTREE_UPDATE_internal_snapshot_node); 1352 - bch_err_msg(c, ret, "clearing inode unlinked flag"); 1353 - if (ret) 1354 - goto out; 1355 - 1356 - /* 1357 - * We'll need another write buffer flush to pick up the new 1358 - * unlinked inodes in the snapshot leaves: 1359 - */ 1360 - *need_another_pass = true; 1361 - goto out; 1362 - } 1363 - 1364 1110 ret = 1; 1365 1111 out: 1366 1112 fsck_err: 1367 1113 bch2_trans_iter_exit(trans, &inode_iter); 1114 + printbuf_exit(&buf); 1368 1115 return ret; 1369 1116 delete: 1370 1117 ret = bch2_btree_bit_mod_buffered(trans, BTREE_ID_deleted_inodes, pos, false);
+10
fs/bcachefs/inode.h
··· 5 5 #include "bkey.h" 6 6 #include "bkey_methods.h" 7 7 #include "opts.h" 8 + #include "snapshot.h" 8 9 9 10 enum bch_validate_flags; 10 11 extern const char * const bch2_inode_opts[]; ··· 17 16 int bch2_inode_v3_validate(struct bch_fs *, struct bkey_s_c, 18 17 enum bch_validate_flags); 19 18 void bch2_inode_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); 19 + 20 + int __bch2_inode_has_child_snapshots(struct btree_trans *, struct bpos); 21 + 22 + static inline int bch2_inode_has_child_snapshots(struct btree_trans *trans, struct bpos pos) 23 + { 24 + return bch2_snapshot_is_leaf(trans->c, pos.snapshot) <= 0 25 + ? __bch2_inode_has_child_snapshots(trans, pos) 26 + : 0; 27 + } 20 28 21 29 int bch2_trigger_inode(struct btree_trans *, enum btree_id, unsigned, 22 30 struct bkey_s_c, struct bkey_s,
+2 -1
fs/bcachefs/inode_format.h
··· 133 133 x(i_size_dirty, 5) \ 134 134 x(i_sectors_dirty, 6) \ 135 135 x(unlinked, 7) \ 136 - x(backptr_untrusted, 8) 136 + x(backptr_untrusted, 8) \ 137 + x(has_child_snapshot, 9) 137 138 138 139 /* bits 20+ reserved for packed fields below: */ 139 140
+13
fs/bcachefs/journal.c
··· 603 603 { 604 604 int ret; 605 605 606 + if (closure_wait_event_timeout(&j->async_wait, 607 + (ret = __journal_res_get(j, res, flags)) != -BCH_ERR_journal_res_get_blocked || 608 + (flags & JOURNAL_RES_GET_NONBLOCK), 609 + HZ * 10)) 610 + return ret; 611 + 612 + struct bch_fs *c = container_of(j, struct bch_fs, journal); 613 + struct printbuf buf = PRINTBUF; 614 + bch2_journal_debug_to_text(&buf, j); 615 + bch_err(c, "Journal stuck? Waited for 10 seconds...\n%s", 616 + buf.buf); 617 + printbuf_exit(&buf); 618 + 606 619 closure_wait_event(&j->async_wait, 607 620 (ret = __journal_res_get(j, res, flags)) != -BCH_ERR_journal_res_get_blocked || 608 621 (flags & JOURNAL_RES_GET_NONBLOCK));
+3 -1
fs/bcachefs/opts.c
··· 427 427 prt_printf(out, "%lli", v); 428 428 break; 429 429 case BCH_OPT_STR: 430 - if (flags & OPT_SHOW_FULL_LIST) 430 + if (v < opt->min || v >= opt->max - 1) 431 + prt_printf(out, "(invalid option %lli)", v); 432 + else if (flags & OPT_SHOW_FULL_LIST) 431 433 prt_string_option(out, opt->choices, v); 432 434 else 433 435 prt_str(out, opt->choices[v]);
+2 -1
fs/bcachefs/recovery.c
··· 287 287 BCH_TRANS_COMMIT_no_enospc| 288 288 BCH_TRANS_COMMIT_journal_reclaim| 289 289 BCH_TRANS_COMMIT_skip_accounting_apply| 290 - BCH_TRANS_COMMIT_no_journal_res, 290 + BCH_TRANS_COMMIT_no_journal_res| 291 + BCH_WATERMARK_reclaim, 291 292 bch2_journal_replay_accounting_key(trans, k)); 292 293 if (bch2_fs_fatal_err_on(ret, c, "error replaying accounting; %s", bch2_err_str(ret))) 293 294 goto err;
+1
fs/bcachefs/recovery_passes_types.h
··· 46 46 x(check_dirents, 27, PASS_FSCK) \ 47 47 x(check_xattrs, 28, PASS_FSCK) \ 48 48 x(check_root, 29, PASS_ONLINE|PASS_FSCK) \ 49 + x(check_unreachable_inodes, 40, PASS_ONLINE|PASS_FSCK) \ 49 50 x(check_subvolume_structure, 36, PASS_ONLINE|PASS_FSCK) \ 50 51 x(check_directory_structure, 30, PASS_ONLINE|PASS_FSCK) \ 51 52 x(check_nlinks, 31, PASS_FSCK) \
+31 -8
fs/bcachefs/replicas.c
··· 66 66 prt_printf(out, "]"); 67 67 } 68 68 69 - static int bch2_replicas_entry_validate_locked(struct bch_replicas_entry_v1 *r, 70 - struct bch_sb *sb, 71 - struct printbuf *err) 69 + static int bch2_replicas_entry_sb_validate(struct bch_replicas_entry_v1 *r, 70 + struct bch_sb *sb, 71 + struct printbuf *err) 72 72 { 73 73 if (!r->nr_devs) { 74 74 prt_printf(err, "no devices in entry "); ··· 98 98 struct bch_fs *c, 99 99 struct printbuf *err) 100 100 { 101 - mutex_lock(&c->sb_lock); 102 - int ret = bch2_replicas_entry_validate_locked(r, c->disk_sb.sb, err); 103 - mutex_unlock(&c->sb_lock); 104 - return ret; 101 + if (!r->nr_devs) { 102 + prt_printf(err, "no devices in entry "); 103 + goto bad; 104 + } 105 + 106 + if (r->nr_required > 1 && 107 + r->nr_required >= r->nr_devs) { 108 + prt_printf(err, "bad nr_required in entry "); 109 + goto bad; 110 + } 111 + 112 + for (unsigned i = 0; i < r->nr_devs; i++) 113 + if (r->devs[i] != BCH_SB_MEMBER_INVALID && 114 + !bch2_dev_exists(c, r->devs[i])) { 115 + prt_printf(err, "invalid device %u in entry ", r->devs[i]); 116 + goto bad; 117 + } 118 + 119 + return 0; 120 + bad: 121 + bch2_replicas_entry_to_text(err, r); 122 + return -BCH_ERR_invalid_replicas_entry; 105 123 } 106 124 107 125 void bch2_cpu_replicas_to_text(struct printbuf *out, ··· 704 686 struct bch_replicas_entry_v1 *e = 705 687 cpu_replicas_entry(cpu_r, i); 706 688 707 - int ret = bch2_replicas_entry_validate_locked(e, sb, err); 689 + int ret = bch2_replicas_entry_sb_validate(e, sb, err); 708 690 if (ret) 709 691 return ret; 710 692 ··· 821 803 822 804 rcu_read_lock(); 823 805 for (unsigned i = 0; i < e->nr_devs; i++) { 806 + if (e->devs[i] == BCH_SB_MEMBER_INVALID) { 807 + nr_failed++; 808 + continue; 809 + } 810 + 824 811 nr_online += test_bit(e->devs[i], devs.d); 825 812 826 813 struct bch_dev *ca = bch2_dev_rcu_noerror(c, e->devs[i]);
+4 -1
fs/bcachefs/sb-downgrade.c
··· 78 78 BCH_FSCK_ERR_accounting_mismatch) \ 79 79 x(rebalance_work_acct_fix, \ 80 80 BIT_ULL(BCH_RECOVERY_PASS_check_allocations), \ 81 - BCH_FSCK_ERR_accounting_mismatch) 81 + BCH_FSCK_ERR_accounting_mismatch) \ 82 + x(inode_has_child_snapshots, \ 83 + BIT_ULL(BCH_RECOVERY_PASS_check_inodes), \ 84 + BCH_FSCK_ERR_inode_has_child_snapshots_wrong) 82 85 83 86 #define DOWNGRADE_TABLE() \ 84 87 x(bucket_stripe_sectors, \
+5 -1
fs/bcachefs/sb-errors_format.h
··· 180 180 x(reflink_p_to_missing_reflink_v, 166, 0) \ 181 181 x(stripe_pos_bad, 167, 0) \ 182 182 x(stripe_val_size_bad, 168, 0) \ 183 + x(stripe_csum_granularity_bad, 290, 0) \ 183 184 x(stripe_sector_count_wrong, 169, 0) \ 184 185 x(snapshot_tree_pos_bad, 170, 0) \ 185 186 x(snapshot_tree_to_missing_snapshot, 171, 0) \ ··· 226 225 x(inode_multiple_links_but_nlink_0, 207, FSCK_AUTOFIX) \ 227 226 x(inode_wrong_backpointer, 208, FSCK_AUTOFIX) \ 228 227 x(inode_wrong_nlink, 209, FSCK_AUTOFIX) \ 228 + x(inode_has_child_snapshots_wrong, 287, 0) \ 229 229 x(inode_unreachable, 210, FSCK_AUTOFIX) \ 230 230 x(deleted_inode_but_clean, 211, FSCK_AUTOFIX) \ 231 231 x(deleted_inode_missing, 212, FSCK_AUTOFIX) \ 232 232 x(deleted_inode_is_dir, 213, FSCK_AUTOFIX) \ 233 233 x(deleted_inode_not_unlinked, 214, FSCK_AUTOFIX) \ 234 + x(deleted_inode_has_child_snapshots, 288, FSCK_AUTOFIX) \ 234 235 x(extent_overlapping, 215, 0) \ 235 236 x(key_in_missing_inode, 216, 0) \ 236 237 x(key_in_wrong_inode_type, 217, 0) \ ··· 292 289 x(alloc_key_stripe_sectors_wrong, 271, FSCK_AUTOFIX) \ 293 290 x(accounting_mismatch, 272, FSCK_AUTOFIX) \ 294 291 x(accounting_replicas_not_marked, 273, 0) \ 292 + x(accounting_to_invalid_device, 289, 0) \ 295 293 x(invalid_btree_id, 274, 0) \ 296 294 x(alloc_key_io_time_bad, 275, 0) \ 297 295 x(alloc_key_fragmentation_lru_wrong, 276, FSCK_AUTOFIX) \ ··· 302 298 x(accounting_key_replicas_devs_unsorted, 280, FSCK_AUTOFIX) \ 303 299 x(accounting_key_version_0, 282, FSCK_AUTOFIX) \ 304 300 x(logged_op_but_clean, 283, FSCK_AUTOFIX) \ 305 - x(MAX, 287, 0) 301 + x(MAX, 291, 0) 306 302 307 303 enum bch_sb_error_id { 308 304 #define x(t, n, ...) BCH_FSCK_ERR_##t = n,
+9 -1
fs/bcachefs/sb-members.c
··· 163 163 return -BCH_ERR_invalid_sb_members; 164 164 } 165 165 166 + if (m.btree_bitmap_shift >= 64) { 167 + prt_printf(err, "device %u: invalid btree_bitmap_shift %u", i, m.btree_bitmap_shift); 168 + return -BCH_ERR_invalid_sb_members; 169 + } 170 + 166 171 return 0; 167 172 } 168 173 ··· 252 247 prt_newline(out); 253 248 254 249 prt_printf(out, "Btree allocated bitmap blocksize:\t"); 255 - prt_units_u64(out, 1ULL << m.btree_bitmap_shift); 250 + if (m.btree_bitmap_shift < 64) 251 + prt_units_u64(out, 1ULL << m.btree_bitmap_shift); 252 + else 253 + prt_printf(out, "(invalid shift %u)", m.btree_bitmap_shift); 256 254 prt_newline(out); 257 255 258 256 prt_printf(out, "Btree allocated bitmap:\t");
+30 -99
fs/bcachefs/snapshot.c
··· 905 905 if (bch2_snapshot_equiv(c, id)) 906 906 return 0; 907 907 908 - /* 0 is an invalid tree ID */ 908 + /* Do we need to reconstruct the snapshot_tree entry as well? */ 909 + struct btree_iter iter; 910 + struct bkey_s_c k; 911 + int ret = 0; 909 912 u32 tree_id = 0; 910 - int ret = bch2_snapshot_tree_create(trans, id, 0, &tree_id); 913 + 914 + for_each_btree_key_norestart(trans, iter, BTREE_ID_snapshot_trees, POS_MIN, 915 + 0, k, ret) { 916 + if (le32_to_cpu(bkey_s_c_to_snapshot_tree(k).v->root_snapshot) == id) { 917 + tree_id = k.k->p.offset; 918 + break; 919 + } 920 + } 921 + bch2_trans_iter_exit(trans, &iter); 922 + 911 923 if (ret) 912 924 return ret; 925 + 926 + if (!tree_id) { 927 + ret = bch2_snapshot_tree_create(trans, id, 0, &tree_id); 928 + if (ret) 929 + return ret; 930 + } 913 931 914 932 struct bkey_i_snapshot *snapshot = bch2_trans_kmalloc(trans, sizeof(*snapshot)); 915 933 ret = PTR_ERR_OR_ZERO(snapshot); ··· 938 920 snapshot->k.p = POS(0, id); 939 921 snapshot->v.tree = cpu_to_le32(tree_id); 940 922 snapshot->v.btime.lo = cpu_to_le64(bch2_current_time(c)); 923 + 924 + for_each_btree_key_norestart(trans, iter, BTREE_ID_subvolumes, POS_MIN, 925 + 0, k, ret) { 926 + if (le32_to_cpu(bkey_s_c_to_subvolume(k).v->snapshot) == id) { 927 + snapshot->v.subvol = cpu_to_le32(k.k->p.offset); 928 + SET_BCH_SNAPSHOT_SUBVOL(&snapshot->v, true); 929 + break; 930 + } 931 + } 932 + bch2_trans_iter_exit(trans, &iter); 941 933 942 934 return bch2_btree_insert_trans(trans, BTREE_ID_snapshots, &snapshot->k_i, 0) ?: 943 935 bch2_mark_snapshot(trans, BTREE_ID_snapshots, 0, ··· 1758 1730 bch2_trans_iter_exit(trans, &iter); 1759 1731 1760 1732 return ret; 1761 - } 1762 - 1763 - static u32 bch2_snapshot_smallest_child(struct bch_fs *c, u32 id) 1764 - { 1765 - const struct snapshot_t *s = snapshot_t(c, id); 1766 - 1767 - return s->children[1] ?: s->children[0]; 1768 - } 1769 - 1770 - static u32 bch2_snapshot_smallest_descendent(struct bch_fs *c, u32 id) 1771 - { 1772 - u32 child; 1773 - 1774 - while ((child = bch2_snapshot_smallest_child(c, id))) 1775 - id = child; 1776 - return id; 1777 - } 1778 - 1779 - static int bch2_propagate_key_to_snapshot_leaf(struct btree_trans *trans, 1780 - enum btree_id btree, 1781 - struct bkey_s_c interior_k, 1782 - u32 leaf_id, struct bpos *new_min_pos) 1783 - { 1784 - struct btree_iter iter; 1785 - struct bpos pos = interior_k.k->p; 1786 - struct bkey_s_c k; 1787 - struct bkey_i *new; 1788 - int ret; 1789 - 1790 - pos.snapshot = leaf_id; 1791 - 1792 - bch2_trans_iter_init(trans, &iter, btree, pos, BTREE_ITER_intent); 1793 - k = bch2_btree_iter_peek_slot(&iter); 1794 - ret = bkey_err(k); 1795 - if (ret) 1796 - goto out; 1797 - 1798 - /* key already overwritten in this snapshot? */ 1799 - if (k.k->p.snapshot != interior_k.k->p.snapshot) 1800 - goto out; 1801 - 1802 - if (bpos_eq(*new_min_pos, POS_MIN)) { 1803 - *new_min_pos = k.k->p; 1804 - new_min_pos->snapshot = leaf_id; 1805 - } 1806 - 1807 - new = bch2_bkey_make_mut_noupdate(trans, interior_k); 1808 - ret = PTR_ERR_OR_ZERO(new); 1809 - if (ret) 1810 - goto out; 1811 - 1812 - new->k.p.snapshot = leaf_id; 1813 - ret = bch2_trans_update(trans, &iter, new, 0); 1814 - out: 1815 - bch2_set_btree_iter_dontneed(&iter); 1816 - bch2_trans_iter_exit(trans, &iter); 1817 - return ret; 1818 - } 1819 - 1820 - int bch2_propagate_key_to_snapshot_leaves(struct btree_trans *trans, 1821 - enum btree_id btree, 1822 - struct bkey_s_c k, 1823 - struct bpos *new_min_pos) 1824 - { 1825 - struct bch_fs *c = trans->c; 1826 - struct bkey_buf sk; 1827 - u32 restart_count = trans->restart_count; 1828 - int ret = 0; 1829 - 1830 - bch2_bkey_buf_init(&sk); 1831 - bch2_bkey_buf_reassemble(&sk, c, k); 1832 - k = bkey_i_to_s_c(sk.k); 1833 - 1834 - *new_min_pos = POS_MIN; 1835 - 1836 - for (u32 id = bch2_snapshot_smallest_descendent(c, k.k->p.snapshot); 1837 - id < k.k->p.snapshot; 1838 - id++) { 1839 - if (!bch2_snapshot_is_ancestor(c, id, k.k->p.snapshot) || 1840 - !bch2_snapshot_is_leaf(c, id)) 1841 - continue; 1842 - again: 1843 - ret = btree_trans_too_many_iters(trans) ?: 1844 - bch2_propagate_key_to_snapshot_leaf(trans, btree, k, id, new_min_pos) ?: 1845 - bch2_trans_commit(trans, NULL, NULL, 0); 1846 - if (ret && bch2_err_matches(ret, BCH_ERR_transaction_restart)) { 1847 - bch2_trans_begin(trans); 1848 - goto again; 1849 - } 1850 - 1851 - if (ret) 1852 - break; 1853 - } 1854 - 1855 - bch2_bkey_buf_exit(&sk, c); 1856 - 1857 - return ret ?: trans_was_restarted(trans, restart_count); 1858 1733 } 1859 1734 1860 1735 static int bch2_check_snapshot_needs_deletion(struct btree_trans *trans, struct bkey_s_c k)
-3
fs/bcachefs/snapshot.h
··· 259 259 return __bch2_key_has_snapshot_overwrites(trans, id, pos); 260 260 } 261 261 262 - int bch2_propagate_key_to_snapshot_leaves(struct btree_trans *, enum btree_id, 263 - struct bkey_s_c, struct bpos *); 264 - 265 262 int bch2_snapshots_read(struct bch_fs *); 266 263 void bch2_fs_snapshots_exit(struct bch_fs *); 267 264
+24 -10
fs/bcachefs/super.c
··· 184 184 185 185 DECLARE_WAIT_QUEUE_HEAD(bch2_read_only_wait); 186 186 187 + static void bch2_dev_unlink(struct bch_dev *); 187 188 static void bch2_dev_free(struct bch_dev *); 188 189 static int bch2_dev_alloc(struct bch_fs *, unsigned); 189 190 static int bch2_dev_sysfs_online(struct bch_fs *, struct bch_dev *); ··· 621 620 up_write(&c->state_lock); 622 621 623 622 for_each_member_device(c, ca) 624 - if (ca->kobj.state_in_sysfs && 625 - ca->disk_sb.bdev) 626 - sysfs_remove_link(bdev_kobj(ca->disk_sb.bdev), "bcachefs"); 623 + bch2_dev_unlink(ca); 627 624 628 625 if (c->kobj.state_in_sysfs) 629 626 kobject_del(&c->kobj); ··· 1186 1187 { 1187 1188 cancel_work_sync(&ca->io_error_work); 1188 1189 1189 - if (ca->kobj.state_in_sysfs && 1190 - ca->disk_sb.bdev) 1191 - sysfs_remove_link(bdev_kobj(ca->disk_sb.bdev), "bcachefs"); 1190 + bch2_dev_unlink(ca); 1192 1191 1193 1192 if (ca->kobj.state_in_sysfs) 1194 1193 kobject_del(&ca->kobj); ··· 1223 1226 percpu_ref_kill(&ca->io_ref); 1224 1227 wait_for_completion(&ca->io_ref_completion); 1225 1228 1226 - if (ca->kobj.state_in_sysfs) { 1227 - sysfs_remove_link(bdev_kobj(ca->disk_sb.bdev), "bcachefs"); 1228 - sysfs_remove_link(&ca->kobj, "block"); 1229 - } 1229 + bch2_dev_unlink(ca); 1230 1230 1231 1231 bch2_free_super(&ca->disk_sb); 1232 1232 bch2_dev_journal_exit(ca); ··· 1243 1249 struct bch_dev *ca = container_of(ref, struct bch_dev, io_ref); 1244 1250 1245 1251 complete(&ca->io_ref_completion); 1252 + } 1253 + 1254 + static void bch2_dev_unlink(struct bch_dev *ca) 1255 + { 1256 + struct kobject *b; 1257 + 1258 + /* 1259 + * This is racy w.r.t. the underlying block device being hot-removed, 1260 + * which removes it from sysfs. 1261 + * 1262 + * It'd be lovely if we had a way to handle this race, but the sysfs 1263 + * code doesn't appear to provide a good method and block/holder.c is 1264 + * susceptible as well: 1265 + */ 1266 + if (ca->kobj.state_in_sysfs && 1267 + ca->disk_sb.bdev && 1268 + (b = bdev_kobj(ca->disk_sb.bdev))->state_in_sysfs) { 1269 + sysfs_remove_link(b, "bcachefs"); 1270 + sysfs_remove_link(&ca->kobj, "block"); 1271 + } 1246 1272 } 1247 1273 1248 1274 static int bch2_dev_sysfs_online(struct bch_fs *c, struct bch_dev *ca)
+8 -7
fs/btrfs/delayed-ref.c
··· 849 849 struct btrfs_qgroup_extent_record *qrecord, 850 850 int action, bool *qrecord_inserted_ret) 851 851 { 852 + struct btrfs_fs_info *fs_info = trans->fs_info; 852 853 struct btrfs_delayed_ref_head *existing; 853 854 struct btrfs_delayed_ref_root *delayed_refs; 854 855 bool qrecord_inserted = false; ··· 860 859 if (qrecord) { 861 860 int ret; 862 861 863 - ret = btrfs_qgroup_trace_extent_nolock(trans->fs_info, 864 - delayed_refs, qrecord); 862 + ret = btrfs_qgroup_trace_extent_nolock(fs_info, delayed_refs, qrecord); 865 863 if (ret) { 866 864 /* Clean up if insertion fails or item exists. */ 867 - xa_release(&delayed_refs->dirty_extents, qrecord->bytenr); 865 + xa_release(&delayed_refs->dirty_extents, 866 + qrecord->bytenr >> fs_info->sectorsize_bits); 868 867 /* Caller responsible for freeing qrecord on error. */ 869 868 if (ret < 0) 870 869 return ERR_PTR(ret); ··· 874 873 } 875 874 } 876 875 877 - trace_add_delayed_ref_head(trans->fs_info, head_ref, action); 876 + trace_add_delayed_ref_head(fs_info, head_ref, action); 878 877 879 878 existing = htree_insert(&delayed_refs->href_root, 880 879 &head_ref->href_node); ··· 896 895 if (head_ref->is_data && head_ref->ref_mod < 0) { 897 896 delayed_refs->pending_csums += head_ref->num_bytes; 898 897 trans->delayed_ref_csum_deletions += 899 - btrfs_csum_bytes_to_leaves(trans->fs_info, 900 - head_ref->num_bytes); 898 + btrfs_csum_bytes_to_leaves(fs_info, head_ref->num_bytes); 901 899 } 902 900 delayed_refs->num_heads++; 903 901 delayed_refs->num_heads_ready++; ··· 1030 1030 goto free_head_ref; 1031 1031 } 1032 1032 if (xa_reserve(&trans->transaction->delayed_refs.dirty_extents, 1033 - generic_ref->bytenr, GFP_NOFS)) { 1033 + generic_ref->bytenr >> fs_info->sectorsize_bits, 1034 + GFP_NOFS)) { 1034 1035 ret = -ENOMEM; 1035 1036 goto free_record; 1036 1037 }
+9 -1
fs/btrfs/delayed-ref.h
··· 202 202 /* head ref rbtree */ 203 203 struct rb_root_cached href_root; 204 204 205 - /* Track dirty extent records. */ 205 + /* 206 + * Track dirty extent records. 207 + * The keys correspond to the logical address of the extent ("bytenr") 208 + * right shifted by fs_info->sectorsize_bits. This is both to get a more 209 + * dense index space (optimizes xarray structure) and because indexes in 210 + * xarrays are of "unsigned long" type, meaning they are 32 bits wide on 211 + * 32 bits platforms, limiting the extent range to 4G which is too low 212 + * and makes it unusable (truncated index values) on 32 bits platforms. 213 + */ 206 214 struct xarray dirty_extents; 207 215 208 216 /* this spin lock protects the rbtree and the entries inside */
+16 -5
fs/btrfs/qgroup.c
··· 2005 2005 struct btrfs_qgroup_extent_record *record) 2006 2006 { 2007 2007 struct btrfs_qgroup_extent_record *existing, *ret; 2008 - unsigned long bytenr = record->bytenr; 2008 + const unsigned long index = (record->bytenr >> fs_info->sectorsize_bits); 2009 2009 2010 2010 if (!btrfs_qgroup_full_accounting(fs_info)) 2011 2011 return 1; 2012 + 2013 + #if BITS_PER_LONG == 32 2014 + if (record->bytenr >= MAX_LFS_FILESIZE) { 2015 + btrfs_err_rl(fs_info, 2016 + "qgroup record for extent at %llu is beyond 32bit page cache and xarray index limit", 2017 + record->bytenr); 2018 + btrfs_err_32bit_limit(fs_info); 2019 + return -EOVERFLOW; 2020 + } 2021 + #endif 2012 2022 2013 2023 lockdep_assert_held(&delayed_refs->lock); 2014 2024 trace_btrfs_qgroup_trace_extent(fs_info, record); 2015 2025 2016 2026 xa_lock(&delayed_refs->dirty_extents); 2017 - existing = xa_load(&delayed_refs->dirty_extents, bytenr); 2027 + existing = xa_load(&delayed_refs->dirty_extents, index); 2018 2028 if (existing) { 2019 2029 if (record->data_rsv && !existing->data_rsv) { 2020 2030 existing->data_rsv = record->data_rsv; ··· 2034 2024 return 1; 2035 2025 } 2036 2026 2037 - ret = __xa_store(&delayed_refs->dirty_extents, record->bytenr, record, GFP_ATOMIC); 2027 + ret = __xa_store(&delayed_refs->dirty_extents, index, record, GFP_ATOMIC); 2038 2028 xa_unlock(&delayed_refs->dirty_extents); 2039 2029 if (xa_is_err(ret)) { 2040 2030 qgroup_mark_inconsistent(fs_info); ··· 2139 2129 struct btrfs_fs_info *fs_info = trans->fs_info; 2140 2130 struct btrfs_qgroup_extent_record *record; 2141 2131 struct btrfs_delayed_ref_root *delayed_refs; 2132 + const unsigned long index = (bytenr >> fs_info->sectorsize_bits); 2142 2133 int ret; 2143 2134 2144 2135 if (!btrfs_qgroup_full_accounting(fs_info) || bytenr == 0 || num_bytes == 0) ··· 2148 2137 if (!record) 2149 2138 return -ENOMEM; 2150 2139 2151 - if (xa_reserve(&trans->transaction->delayed_refs.dirty_extents, bytenr, GFP_NOFS)) { 2140 + if (xa_reserve(&trans->transaction->delayed_refs.dirty_extents, index, GFP_NOFS)) { 2152 2141 kfree(record); 2153 2142 return -ENOMEM; 2154 2143 } ··· 2163 2152 spin_unlock(&delayed_refs->lock); 2164 2153 if (ret) { 2165 2154 /* Clean up if insertion fails or item exists. */ 2166 - xa_release(&delayed_refs->dirty_extents, record->bytenr); 2155 + xa_release(&delayed_refs->dirty_extents, index); 2167 2156 kfree(record); 2168 2157 return 0; 2169 2158 }
+1 -3
fs/btrfs/send.c
··· 7190 7190 7191 7191 static int changed_verity(struct send_ctx *sctx, enum btrfs_compare_tree_result result) 7192 7192 { 7193 - int ret = 0; 7194 - 7195 7193 if (!sctx->cur_inode_new_gen && !sctx->cur_inode_deleted) { 7196 7194 if (result == BTRFS_COMPARE_TREE_NEW) 7197 7195 sctx->cur_inode_needs_verity = true; 7198 7196 } 7199 - return ret; 7197 + return 0; 7200 7198 } 7201 7199 7202 7200 static int dir_changed(struct send_ctx *sctx, u64 dir)
+3 -3
fs/btrfs/tree-log.c
··· 1374 1374 struct inode *inode = NULL; 1375 1375 unsigned long ref_ptr; 1376 1376 unsigned long ref_end; 1377 - struct fscrypt_str name; 1377 + struct fscrypt_str name = { 0 }; 1378 1378 int ret; 1379 1379 int log_ref_ver = 0; 1380 1380 u64 parent_objectid; ··· 1845 1845 struct btrfs_dir_item *di, 1846 1846 struct btrfs_key *key) 1847 1847 { 1848 - struct fscrypt_str name; 1848 + struct fscrypt_str name = { 0 }; 1849 1849 struct btrfs_dir_item *dir_dst_di; 1850 1850 struct btrfs_dir_item *index_dst_di; 1851 1851 bool dir_dst_matches = false; ··· 2125 2125 struct extent_buffer *eb; 2126 2126 int slot; 2127 2127 struct btrfs_dir_item *di; 2128 - struct fscrypt_str name; 2128 + struct fscrypt_str name = { 0 }; 2129 2129 struct inode *inode = NULL; 2130 2130 struct btrfs_key location; 2131 2131
+10 -3
fs/erofs/super.c
··· 191 191 if (IS_ERR(file)) 192 192 return PTR_ERR(file); 193 193 194 - dif->file = file; 195 - if (!erofs_is_fileio_mode(sbi)) 194 + if (!erofs_is_fileio_mode(sbi)) { 196 195 dif->dax_dev = fs_dax_get_by_bdev(file_bdev(file), 197 196 &dif->dax_part_off, NULL, NULL); 197 + } else if (!S_ISREG(file_inode(file)->i_mode)) { 198 + fput(file); 199 + return -EINVAL; 200 + } 201 + dif->file = file; 198 202 } 199 203 200 204 dif->blocks = le32_to_cpu(dis->blocks); ··· 718 714 if (IS_ERR(sbi->fdev)) 719 715 return PTR_ERR(sbi->fdev); 720 716 721 - return get_tree_nodev(fc, erofs_fc_fill_super); 717 + if (S_ISREG(file_inode(sbi->fdev)->i_mode) && 718 + sbi->fdev->f_mapping->a_ops->read_folio) 719 + return get_tree_nodev(fc, erofs_fc_fill_super); 720 + fput(sbi->fdev); 722 721 } 723 722 #endif 724 723 return ret;
+9 -20
fs/erofs/zdata.c
··· 710 710 return ret; 711 711 } 712 712 713 - static void z_erofs_try_to_claim_pcluster(struct z_erofs_decompress_frontend *f) 714 - { 715 - struct z_erofs_pcluster *pcl = f->pcl; 716 - z_erofs_next_pcluster_t *owned_head = &f->owned_head; 717 - 718 - /* type 1, nil pcluster (this pcluster doesn't belong to any chain.) */ 719 - if (cmpxchg(&pcl->next, Z_EROFS_PCLUSTER_NIL, 720 - *owned_head) == Z_EROFS_PCLUSTER_NIL) { 721 - *owned_head = &pcl->next; 722 - /* so we can attach this pcluster to our submission chain. */ 723 - f->mode = Z_EROFS_PCLUSTER_FOLLOWED; 724 - return; 725 - } 726 - 727 - /* type 2, it belongs to an ongoing chain */ 728 - f->mode = Z_EROFS_PCLUSTER_INFLIGHT; 729 - } 730 - 731 713 static int z_erofs_register_pcluster(struct z_erofs_decompress_frontend *fe) 732 714 { 733 715 struct erofs_map_blocks *map = &fe->map; ··· 785 803 int ret; 786 804 787 805 DBG_BUGON(fe->pcl); 788 - 789 806 /* must be Z_EROFS_PCLUSTER_TAIL or pointed to previous pcluster */ 790 807 DBG_BUGON(fe->owned_head == Z_EROFS_PCLUSTER_NIL); 791 808 ··· 804 823 805 824 if (ret == -EEXIST) { 806 825 mutex_lock(&fe->pcl->lock); 807 - z_erofs_try_to_claim_pcluster(fe); 826 + /* check if this pcluster hasn't been linked into any chain. */ 827 + if (cmpxchg(&fe->pcl->next, Z_EROFS_PCLUSTER_NIL, 828 + fe->owned_head) == Z_EROFS_PCLUSTER_NIL) { 829 + /* .. so it can be attached to our submission chain */ 830 + fe->owned_head = &fe->pcl->next; 831 + fe->mode = Z_EROFS_PCLUSTER_FOLLOWED; 832 + } else { /* otherwise, it belongs to an inflight chain */ 833 + fe->mode = Z_EROFS_PCLUSTER_INFLIGHT; 834 + } 808 835 } else if (ret) { 809 836 return ret; 810 837 }
+12 -20
fs/erofs/zmap.c
··· 10 10 struct z_erofs_maprecorder { 11 11 struct inode *inode; 12 12 struct erofs_map_blocks *map; 13 - void *kaddr; 14 - 15 13 unsigned long lcn; 16 14 /* compression extent information gathered */ 17 15 u8 type, headtype; ··· 31 33 struct z_erofs_lcluster_index *di; 32 34 unsigned int advise; 33 35 34 - m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb, 35 - pos, EROFS_KMAP); 36 - if (IS_ERR(m->kaddr)) 37 - return PTR_ERR(m->kaddr); 38 - 39 - m->nextpackoff = pos + sizeof(struct z_erofs_lcluster_index); 36 + di = erofs_read_metabuf(&m->map->buf, inode->i_sb, pos, EROFS_KMAP); 37 + if (IS_ERR(di)) 38 + return PTR_ERR(di); 40 39 m->lcn = lcn; 41 - di = m->kaddr; 40 + m->nextpackoff = pos + sizeof(struct z_erofs_lcluster_index); 42 41 43 42 advise = le16_to_cpu(di->di_advise); 44 43 m->type = advise & Z_EROFS_LI_LCLUSTER_TYPE_MASK; ··· 48 53 DBG_BUGON(1); 49 54 return -EFSCORRUPTED; 50 55 } 51 - m->compressedblks = m->delta[0] & 52 - ~Z_EROFS_LI_D0_CBLKCNT; 56 + m->compressedblks = m->delta[0] & ~Z_EROFS_LI_D0_CBLKCNT; 53 57 m->delta[0] = 1; 54 58 } 55 59 m->delta[1] = le16_to_cpu(di->di_u.delta[1]); ··· 104 110 struct erofs_inode *const vi = EROFS_I(m->inode); 105 111 const unsigned int lclusterbits = vi->z_logical_clusterbits; 106 112 unsigned int vcnt, lo, lobits, encodebits, nblk, bytes; 107 - int i; 108 - u8 *in, type; 109 113 bool big_pcluster; 114 + u8 *in, type; 115 + int i; 110 116 111 117 if (1 << amortizedshift == 4 && lclusterbits <= 14) 112 118 vcnt = 2; ··· 115 121 else 116 122 return -EOPNOTSUPP; 117 123 124 + in = erofs_read_metabuf(&m->map->buf, m->inode->i_sb, pos, EROFS_KMAP); 125 + if (IS_ERR(in)) 126 + return PTR_ERR(in); 127 + 118 128 /* it doesn't equal to round_up(..) */ 119 129 m->nextpackoff = round_down(pos, vcnt << amortizedshift) + 120 130 (vcnt << amortizedshift); ··· 126 128 lobits = max(lclusterbits, ilog2(Z_EROFS_LI_D0_CBLKCNT) + 1U); 127 129 encodebits = ((vcnt << amortizedshift) - sizeof(__le32)) * 8 / vcnt; 128 130 bytes = pos & ((vcnt << amortizedshift) - 1); 129 - 130 - in = m->kaddr - bytes; 131 - 131 + in -= bytes; 132 132 i = bytes >> amortizedshift; 133 133 134 134 lo = decode_compactedbits(lobits, in, encodebits * i, &type); ··· 251 255 amortizedshift = 2; 252 256 out: 253 257 pos += lcn * (1 << amortizedshift); 254 - m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb, 255 - pos, EROFS_KMAP); 256 - if (IS_ERR(m->kaddr)) 257 - return PTR_ERR(m->kaddr); 258 258 return unpack_compacted_index(m, amortizedshift, pos, lookahead); 259 259 } 260 260
+2 -1
fs/f2fs/file.c
··· 4647 4647 iov_iter_count(to), READ); 4648 4648 4649 4649 /* In LFS mode, if there is inflight dio, wait for its completion */ 4650 - if (f2fs_lfs_mode(F2FS_I_SB(inode))) 4650 + if (f2fs_lfs_mode(F2FS_I_SB(inode)) && 4651 + get_pages(F2FS_I_SB(inode), F2FS_DIO_WRITE)) 4651 4652 inode_dio_wait(inode); 4652 4653 4653 4654 if (f2fs_should_use_dio(inode, iocb, to)) {
+2
fs/nfs/callback_xdr.c
··· 375 375 376 376 rc_list->rcl_nrefcalls = ntohl(*p++); 377 377 if (rc_list->rcl_nrefcalls) { 378 + if (unlikely(rc_list->rcl_nrefcalls > xdr->buf->len)) 379 + goto out; 378 380 p = xdr_inline_decode(xdr, 379 381 rc_list->rcl_nrefcalls * 2 * sizeof(uint32_t)); 380 382 if (unlikely(p == NULL))
+1
fs/nfs/client.c
··· 996 996 INIT_LIST_HEAD(&server->layouts); 997 997 INIT_LIST_HEAD(&server->state_owners_lru); 998 998 INIT_LIST_HEAD(&server->ss_copies); 999 + INIT_LIST_HEAD(&server->ss_src_copies); 999 1000 1000 1001 atomic_set(&server->active, 0); 1001 1002
+5
fs/nfs/delegation.c
··· 1001 1001 } 1002 1002 1003 1003 nfs_mark_delegation_revoked(delegation); 1004 + clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); 1005 + spin_unlock(&delegation->lock); 1006 + if (nfs_detach_delegation(NFS_I(inode), delegation, NFS_SERVER(inode))) 1007 + nfs_put_delegation(delegation); 1008 + goto out_rcu_unlock; 1004 1009 1005 1010 out_clear_returning: 1006 1011 clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags);
+3 -4
fs/nfs/localio.c
··· 18 18 #include <net/addrconf.h> 19 19 #include <linux/nfs_common.h> 20 20 #include <linux/nfslocalio.h> 21 - #include <linux/module.h> 22 21 #include <linux/bvec.h> 23 22 24 23 #include <linux/nfs.h> ··· 340 341 { 341 342 struct nfs_pgio_header *hdr = iocb->hdr; 342 343 343 - nfs_to->nfsd_file_put_local(iocb->localio); 344 + nfs_to_nfsd_file_put_local(iocb->localio); 344 345 nfs_local_iocb_free(iocb); 345 346 nfs_local_hdr_release(hdr, hdr->task.tk_ops); 346 347 } ··· 621 622 } 622 623 out: 623 624 if (status != 0) { 624 - nfs_to->nfsd_file_put_local(localio); 625 + nfs_to_nfsd_file_put_local(localio); 625 626 hdr->task.tk_status = status; 626 627 nfs_local_hdr_release(hdr, call_ops); 627 628 } ··· 672 673 struct nfs_commit_data *data, 673 674 const struct rpc_call_ops *call_ops) 674 675 { 675 - nfs_to->nfsd_file_put_local(localio); 676 + nfs_to_nfsd_file_put_local(localio); 676 677 call_ops->rpc_call_done(&data->task, data); 677 678 call_ops->rpc_release(data); 678 679 }
+1 -1
fs/nfs/nfs42proc.c
··· 218 218 219 219 if (dst_server != src_server) { 220 220 spin_lock(&src_server->nfs_client->cl_lock); 221 - list_add_tail(&copy->src_copies, &src_server->ss_copies); 221 + list_add_tail(&copy->src_copies, &src_server->ss_src_copies); 222 222 spin_unlock(&src_server->nfs_client->cl_lock); 223 223 } 224 224
+1 -1
fs/nfs/nfs4state.c
··· 1585 1585 complete(&copy->completion); 1586 1586 } 1587 1587 } 1588 - list_for_each_entry(copy, &sp->so_server->ss_copies, src_copies) { 1588 + list_for_each_entry(copy, &sp->so_server->ss_src_copies, src_copies) { 1589 1589 if ((test_bit(NFS_CLNT_SRC_SSC_COPY_STATE, &state->flags) && 1590 1590 !nfs4_stateid_match_other(&state->stateid, 1591 1591 &copy->parent_src_state->stateid)))
+4 -1
fs/nfs_common/nfslocalio.c
··· 142 142 /* We have an implied reference to net thanks to nfsd_serv_try_get */ 143 143 localio = nfs_to->nfsd_open_local_fh(net, uuid->dom, rpc_clnt, 144 144 cred, nfs_fh, fmode); 145 - if (IS_ERR(localio)) 145 + if (IS_ERR(localio)) { 146 + rcu_read_lock(); 146 147 nfs_to->nfsd_serv_put(net); 148 + rcu_read_unlock(); 149 + } 147 150 return localio; 148 151 } 149 152 EXPORT_SYMBOL_GPL(nfs_open_local_fh);
+1 -1
fs/nfsd/filecache.c
··· 398 398 * reference to the associated nn->nfsd_serv. 399 399 */ 400 400 void 401 - nfsd_file_put_local(struct nfsd_file *nf) 401 + nfsd_file_put_local(struct nfsd_file *nf) __must_hold(rcu) 402 402 { 403 403 struct net *net = nf->nf_net; 404 404
+1 -1
fs/nfsd/localio.c
··· 53 53 * 54 54 * On successful return, returned nfsd_file will have its nf_net member 55 55 * set. Caller (NFS client) is responsible for calling nfsd_serv_put and 56 - * nfsd_file_put (via nfs_to->nfsd_file_put_local). 56 + * nfsd_file_put (via nfs_to_nfsd_file_put_local). 57 57 */ 58 58 struct nfsd_file * 59 59 nfsd_open_local_fh(struct net *net, struct auth_domain *dom,
+2 -2
fs/nfsd/nfssvc.c
··· 214 214 return 0; 215 215 } 216 216 217 - bool nfsd_serv_try_get(struct net *net) 217 + bool nfsd_serv_try_get(struct net *net) __must_hold(rcu) 218 218 { 219 219 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 220 220 221 221 return (nn && percpu_ref_tryget_live(&nn->nfsd_serv_ref)); 222 222 } 223 223 224 - void nfsd_serv_put(struct net *net) 224 + void nfsd_serv_put(struct net *net) __must_hold(rcu) 225 225 { 226 226 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 227 227
+3 -3
fs/nfsd/trace.h
··· 1113 1113 ), 1114 1114 1115 1115 TP_fast_assign( 1116 - __entry->xid = be32_to_cpu(rqstp->rq_xid); 1116 + __entry->xid = rqstp ? be32_to_cpu(rqstp->rq_xid) : 0; 1117 1117 __entry->inode = inode; 1118 1118 __entry->may_flags = may_flags; 1119 1119 __entry->nf_ref = nf ? refcount_read(&nf->nf_ref) : 0; ··· 1147 1147 __field(long, error) 1148 1148 ), 1149 1149 TP_fast_assign( 1150 - __entry->xid = be32_to_cpu(rqstp->rq_xid); 1150 + __entry->xid = rqstp ? be32_to_cpu(rqstp->rq_xid) : 0; 1151 1151 __entry->inode = inode; 1152 1152 __entry->may_flags = may_flags; 1153 1153 __entry->error = error; ··· 1177 1177 __field(const void *, nf_file) 1178 1178 ), 1179 1179 TP_fast_assign( 1180 - __entry->xid = be32_to_cpu(rqstp->rq_xid); 1180 + __entry->xid = rqstp ? be32_to_cpu(rqstp->rq_xid) : 0; 1181 1181 __entry->inode = inode; 1182 1182 __entry->may_flags = may_flags; 1183 1183 __entry->nf_ref = refcount_read(&nf->nf_ref);
+14 -3
fs/smb/client/cifs_unicode.c
··· 484 484 /** 485 485 * Remap spaces and periods found at the end of every 486 486 * component of the path. The special cases of '.' and 487 - * '..' do not need to be dealt with explicitly because 488 - * they are addressed in namei.c:link_path_walk(). 487 + * '..' are need to be handled because of symlinks. 488 + * They are treated as non-end-of-string to avoid 489 + * remapping and breaking symlinks pointing to . or .. 489 490 **/ 490 - if ((i == srclen - 1) || (source[i+1] == '\\')) 491 + if ((i == 0 || source[i-1] == '\\') && 492 + source[i] == '.' && 493 + (i == srclen-1 || source[i+1] == '\\')) 494 + end_of_string = false; /* "." case */ 495 + else if (i >= 1 && 496 + (i == 1 || source[i-2] == '\\') && 497 + source[i-1] == '.' && 498 + source[i] == '.' && 499 + (i == srclen-1 || source[i+1] == '\\')) 500 + end_of_string = false; /* ".." case */ 501 + else if ((i == srclen - 1) || (source[i+1] == '\\')) 491 502 end_of_string = true; 492 503 else 493 504 end_of_string = false;
+161 -3
fs/smb/client/reparse.c
··· 14 14 #include "fs_context.h" 15 15 #include "reparse.h" 16 16 17 + static int detect_directory_symlink_target(struct cifs_sb_info *cifs_sb, 18 + const unsigned int xid, 19 + const char *full_path, 20 + const char *symname, 21 + bool *directory); 22 + 17 23 int smb2_create_reparse_symlink(const unsigned int xid, struct inode *inode, 18 24 struct dentry *dentry, struct cifs_tcon *tcon, 19 25 const char *full_path, const char *symname) ··· 30 24 struct inode *new; 31 25 struct kvec iov; 32 26 __le16 *path; 27 + bool directory; 33 28 char *sym, sep = CIFS_DIR_SEP(cifs_sb); 34 29 u16 len, plen; 35 30 int rc = 0; ··· 51 44 rc = -ENOMEM; 52 45 goto out; 53 46 } 47 + 48 + /* 49 + * SMB distinguish between symlink to directory and symlink to file. 50 + * They cannot be exchanged (symlink of file type which points to 51 + * directory cannot be resolved and vice-versa). Try to detect if 52 + * the symlink target could be a directory or not. When detection 53 + * fails then treat symlink as a file (non-directory) symlink. 54 + */ 55 + directory = false; 56 + rc = detect_directory_symlink_target(cifs_sb, xid, full_path, symname, &directory); 57 + if (rc < 0) 58 + goto out; 54 59 55 60 plen = 2 * UniStrnlen((wchar_t *)path, PATH_MAX); 56 61 len = sizeof(*buf) + plen * 2; ··· 88 69 iov.iov_base = buf; 89 70 iov.iov_len = len; 90 71 new = smb2_get_reparse_inode(&data, inode->i_sb, xid, 91 - tcon, full_path, &iov, NULL); 72 + tcon, full_path, directory, 73 + &iov, NULL); 92 74 if (!IS_ERR(new)) 93 75 d_instantiate(dentry, new); 94 76 else ··· 99 79 cifs_free_open_info(&data); 100 80 kfree(buf); 101 81 return rc; 82 + } 83 + 84 + static int detect_directory_symlink_target(struct cifs_sb_info *cifs_sb, 85 + const unsigned int xid, 86 + const char *full_path, 87 + const char *symname, 88 + bool *directory) 89 + { 90 + char sep = CIFS_DIR_SEP(cifs_sb); 91 + struct cifs_open_parms oparms; 92 + struct tcon_link *tlink; 93 + struct cifs_tcon *tcon; 94 + const char *basename; 95 + struct cifs_fid fid; 96 + char *resolved_path; 97 + int full_path_len; 98 + int basename_len; 99 + int symname_len; 100 + char *path_sep; 101 + __u32 oplock; 102 + int open_rc; 103 + 104 + /* 105 + * First do some simple check. If the original Linux symlink target ends 106 + * with slash, or last path component is dot or dot-dot then it is for 107 + * sure symlink to the directory. 108 + */ 109 + basename = kbasename(symname); 110 + basename_len = strlen(basename); 111 + if (basename_len == 0 || /* symname ends with slash */ 112 + (basename_len == 1 && basename[0] == '.') || /* last component is "." */ 113 + (basename_len == 2 && basename[0] == '.' && basename[1] == '.')) { /* or ".." */ 114 + *directory = true; 115 + return 0; 116 + } 117 + 118 + /* 119 + * For absolute symlinks it is not possible to determinate 120 + * if it should point to directory or file. 121 + */ 122 + if (symname[0] == '/') { 123 + cifs_dbg(FYI, 124 + "%s: cannot determinate if the symlink target path '%s' " 125 + "is directory or not, creating '%s' as file symlink\n", 126 + __func__, symname, full_path); 127 + return 0; 128 + } 129 + 130 + /* 131 + * If it was not detected as directory yet and the symlink is relative 132 + * then try to resolve the path on the SMB server, check if the path 133 + * exists and determinate if it is a directory or not. 134 + */ 135 + 136 + full_path_len = strlen(full_path); 137 + symname_len = strlen(symname); 138 + 139 + tlink = cifs_sb_tlink(cifs_sb); 140 + if (IS_ERR(tlink)) 141 + return PTR_ERR(tlink); 142 + 143 + resolved_path = kzalloc(full_path_len + symname_len + 1, GFP_KERNEL); 144 + if (!resolved_path) { 145 + cifs_put_tlink(tlink); 146 + return -ENOMEM; 147 + } 148 + 149 + /* 150 + * Compose the resolved SMB symlink path from the SMB full path 151 + * and Linux target symlink path. 152 + */ 153 + memcpy(resolved_path, full_path, full_path_len+1); 154 + path_sep = strrchr(resolved_path, sep); 155 + if (path_sep) 156 + path_sep++; 157 + else 158 + path_sep = resolved_path; 159 + memcpy(path_sep, symname, symname_len+1); 160 + if (sep == '\\') 161 + convert_delimiter(path_sep, sep); 162 + 163 + tcon = tlink_tcon(tlink); 164 + oparms = CIFS_OPARMS(cifs_sb, tcon, resolved_path, 165 + FILE_READ_ATTRIBUTES, FILE_OPEN, 0, ACL_NO_MODE); 166 + oparms.fid = &fid; 167 + 168 + /* Try to open as a directory (NOT_FILE) */ 169 + oplock = 0; 170 + oparms.create_options = cifs_create_options(cifs_sb, 171 + CREATE_NOT_FILE | OPEN_REPARSE_POINT); 172 + open_rc = tcon->ses->server->ops->open(xid, &oparms, &oplock, NULL); 173 + if (open_rc == 0) { 174 + /* Successful open means that the target path is definitely a directory. */ 175 + *directory = true; 176 + tcon->ses->server->ops->close(xid, tcon, &fid); 177 + } else if (open_rc == -ENOTDIR) { 178 + /* -ENOTDIR means that the target path is definitely a file. */ 179 + *directory = false; 180 + } else if (open_rc == -ENOENT) { 181 + /* -ENOENT means that the target path does not exist. */ 182 + cifs_dbg(FYI, 183 + "%s: symlink target path '%s' does not exist, " 184 + "creating '%s' as file symlink\n", 185 + __func__, symname, full_path); 186 + } else { 187 + /* Try to open as a file (NOT_DIR) */ 188 + oplock = 0; 189 + oparms.create_options = cifs_create_options(cifs_sb, 190 + CREATE_NOT_DIR | OPEN_REPARSE_POINT); 191 + open_rc = tcon->ses->server->ops->open(xid, &oparms, &oplock, NULL); 192 + if (open_rc == 0) { 193 + /* Successful open means that the target path is definitely a file. */ 194 + *directory = false; 195 + tcon->ses->server->ops->close(xid, tcon, &fid); 196 + } else if (open_rc == -EISDIR) { 197 + /* -EISDIR means that the target path is definitely a directory. */ 198 + *directory = true; 199 + } else { 200 + /* 201 + * This code branch is called when we do not have a permission to 202 + * open the resolved_path or some other client/process denied 203 + * opening the resolved_path. 204 + * 205 + * TODO: Try to use ops->query_dir_first on the parent directory 206 + * of resolved_path, search for basename of resolved_path and 207 + * check if the ATTR_DIRECTORY is set in fi.Attributes. In some 208 + * case this could work also when opening of the path is denied. 209 + */ 210 + cifs_dbg(FYI, 211 + "%s: cannot determinate if the symlink target path '%s' " 212 + "is directory or not, creating '%s' as file symlink\n", 213 + __func__, symname, full_path); 214 + } 215 + } 216 + 217 + kfree(resolved_path); 218 + cifs_put_tlink(tlink); 219 + return 0; 102 220 } 103 221 104 222 static int nfs_set_reparse_buf(struct reparse_posix_data *buf, ··· 295 137 }; 296 138 297 139 new = smb2_get_reparse_inode(&data, inode->i_sb, xid, 298 - tcon, full_path, &iov, NULL); 140 + tcon, full_path, false, &iov, NULL); 299 141 if (!IS_ERR(new)) 300 142 d_instantiate(dentry, new); 301 143 else ··· 441 283 data.wsl.eas_len = len; 442 284 443 285 new = smb2_get_reparse_inode(&data, inode->i_sb, 444 - xid, tcon, full_path, 286 + xid, tcon, full_path, false, 445 287 &reparse_iov, &xattr_iov); 446 288 if (!IS_ERR(new)) 447 289 d_instantiate(dentry, new);
+2 -1
fs/smb/client/smb2inode.c
··· 1198 1198 const unsigned int xid, 1199 1199 struct cifs_tcon *tcon, 1200 1200 const char *full_path, 1201 + bool directory, 1201 1202 struct kvec *reparse_iov, 1202 1203 struct kvec *xattr_iov) 1203 1204 { ··· 1218 1217 FILE_READ_ATTRIBUTES | 1219 1218 FILE_WRITE_ATTRIBUTES, 1220 1219 FILE_CREATE, 1221 - CREATE_NOT_DIR | OPEN_REPARSE_POINT, 1220 + (directory ? CREATE_NOT_FILE : CREATE_NOT_DIR) | OPEN_REPARSE_POINT, 1222 1221 ACL_NO_MODE); 1223 1222 if (xattr_iov) 1224 1223 oparms.ea_cctx = xattr_iov;
+1
fs/smb/client/smb2proto.h
··· 61 61 const unsigned int xid, 62 62 struct cifs_tcon *tcon, 63 63 const char *full_path, 64 + bool directory, 64 65 struct kvec *reparse_iov, 65 66 struct kvec *xattr_iov); 66 67 int smb2_query_reparse_point(const unsigned int xid,
+5 -1
fs/smb/server/auth.c
··· 512 512 int in_len, char *out_blob, int *out_len) 513 513 { 514 514 struct ksmbd_spnego_authen_response *resp; 515 + struct ksmbd_login_response_ext *resp_ext = NULL; 515 516 struct ksmbd_user *user = NULL; 516 517 int retval; 517 518 ··· 541 540 goto out; 542 541 } 543 542 544 - user = ksmbd_alloc_user(&resp->login_response); 543 + if (resp->login_response.status & KSMBD_USER_FLAG_EXTENSION) 544 + resp_ext = ksmbd_ipc_login_request_ext(resp->login_response.account); 545 + 546 + user = ksmbd_alloc_user(&resp->login_response, resp_ext); 545 547 if (!user) { 546 548 ksmbd_debug(AUTH, "login failure\n"); 547 549 retval = -ENOMEM;
+17
fs/smb/server/ksmbd_netlink.h
··· 51 51 * - KSMBD_EVENT_SPNEGO_AUTHEN_REQUEST/RESPONSE(ksmbd_spnego_authen_request/response) 52 52 * This event is to make kerberos authentication to be processed in 53 53 * userspace. 54 + * 55 + * - KSMBD_EVENT_LOGIN_REQUEST_EXT/RESPONSE_EXT(ksmbd_login_request_ext/response_ext) 56 + * This event is to get user account extension info to user IPC daemon. 54 57 */ 55 58 56 59 #define KSMBD_GENL_NAME "SMBD_GENL" ··· 146 143 __u16 hash_sz; /* hash size */ 147 144 __s8 hash[KSMBD_REQ_MAX_HASH_SZ]; /* password hash */ 148 145 __u32 reserved[16]; /* Reserved room */ 146 + }; 147 + 148 + /* 149 + * IPC user login response extension. 150 + */ 151 + struct ksmbd_login_response_ext { 152 + __u32 handle; 153 + __s32 ngroups; /* supplementary group count */ 154 + __s8 reserved[128]; /* Reserved room */ 155 + __s8 ____payload[]; 149 156 }; 150 157 151 158 /* ··· 319 306 KSMBD_EVENT_SPNEGO_AUTHEN_REQUEST, 320 307 KSMBD_EVENT_SPNEGO_AUTHEN_RESPONSE = 15, 321 308 309 + KSMBD_EVENT_LOGIN_REQUEST_EXT, 310 + KSMBD_EVENT_LOGIN_RESPONSE_EXT, 311 + 322 312 __KSMBD_EVENT_MAX, 323 313 KSMBD_EVENT_MAX = __KSMBD_EVENT_MAX - 1 324 314 }; ··· 352 336 #define KSMBD_USER_FLAG_BAD_USER BIT(3) 353 337 #define KSMBD_USER_FLAG_GUEST_ACCOUNT BIT(4) 354 338 #define KSMBD_USER_FLAG_DELAY_SESSION BIT(5) 339 + #define KSMBD_USER_FLAG_EXTENSION BIT(6) 355 340 356 341 /* 357 342 * Share config flags.
+37 -8
fs/smb/server/mgmt/user_config.c
··· 12 12 struct ksmbd_user *ksmbd_login_user(const char *account) 13 13 { 14 14 struct ksmbd_login_response *resp; 15 + struct ksmbd_login_response_ext *resp_ext = NULL; 15 16 struct ksmbd_user *user = NULL; 16 17 17 18 resp = ksmbd_ipc_login_request(account); ··· 22 21 if (!(resp->status & KSMBD_USER_FLAG_OK)) 23 22 goto out; 24 23 25 - user = ksmbd_alloc_user(resp); 24 + if (resp->status & KSMBD_USER_FLAG_EXTENSION) 25 + resp_ext = ksmbd_ipc_login_request_ext(account); 26 + 27 + user = ksmbd_alloc_user(resp, resp_ext); 26 28 out: 27 29 kvfree(resp); 28 30 return user; 29 31 } 30 32 31 - struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp) 33 + struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp, 34 + struct ksmbd_login_response_ext *resp_ext) 32 35 { 33 - struct ksmbd_user *user = NULL; 36 + struct ksmbd_user *user; 34 37 35 38 user = kmalloc(sizeof(struct ksmbd_user), GFP_KERNEL); 36 39 if (!user) ··· 49 44 if (user->passkey) 50 45 memcpy(user->passkey, resp->hash, resp->hash_sz); 51 46 52 - if (!user->name || !user->passkey) { 53 - kfree(user->name); 54 - kfree(user->passkey); 55 - kfree(user); 56 - user = NULL; 47 + user->ngroups = 0; 48 + user->sgid = NULL; 49 + 50 + if (!user->name || !user->passkey) 51 + goto err_free; 52 + 53 + if (resp_ext) { 54 + if (resp_ext->ngroups > NGROUPS_MAX) { 55 + pr_err("ngroups(%u) from login response exceeds max groups(%d)\n", 56 + resp_ext->ngroups, NGROUPS_MAX); 57 + goto err_free; 58 + } 59 + 60 + user->sgid = kmemdup(resp_ext->____payload, 61 + resp_ext->ngroups * sizeof(gid_t), 62 + GFP_KERNEL); 63 + if (!user->sgid) 64 + goto err_free; 65 + 66 + user->ngroups = resp_ext->ngroups; 67 + ksmbd_debug(SMB, "supplementary groups : %d\n", user->ngroups); 57 68 } 69 + 58 70 return user; 71 + 72 + err_free: 73 + kfree(user->name); 74 + kfree(user->passkey); 75 + kfree(user); 76 + return NULL; 59 77 } 60 78 61 79 void ksmbd_free_user(struct ksmbd_user *user) 62 80 { 63 81 ksmbd_ipc_logout_request(user->name, user->flags); 82 + kfree(user->sgid); 64 83 kfree(user->name); 65 84 kfree(user->passkey); 66 85 kfree(user);
+4 -1
fs/smb/server/mgmt/user_config.h
··· 18 18 19 19 size_t passkey_sz; 20 20 char *passkey; 21 + int ngroups; 22 + gid_t *sgid; 21 23 }; 22 24 23 25 static inline bool user_guest(struct ksmbd_user *user) ··· 62 60 } 63 61 64 62 struct ksmbd_user *ksmbd_login_user(const char *account); 65 - struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp); 63 + struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp, 64 + struct ksmbd_login_response_ext *resp_ext); 66 65 void ksmbd_free_user(struct ksmbd_user *user); 67 66 int ksmbd_anonymous_user(struct ksmbd_user *user); 68 67 bool ksmbd_compare_user(struct ksmbd_user *u1, struct ksmbd_user *u2);
+21 -5
fs/smb/server/mgmt/user_session.c
··· 177 177 178 178 down_write(&conn->session_lock); 179 179 xa_for_each(&conn->sessions, id, sess) { 180 - if (sess->state != SMB2_SESSION_VALID || 181 - time_after(jiffies, 182 - sess->last_active + SMB2_SESSION_TIMEOUT)) { 180 + if (atomic_read(&sess->refcnt) == 0 && 181 + (sess->state != SMB2_SESSION_VALID || 182 + time_after(jiffies, 183 + sess->last_active + SMB2_SESSION_TIMEOUT))) { 183 184 xa_erase(&conn->sessions, sess->id); 184 185 hash_del(&sess->hlist); 185 186 ksmbd_session_destroy(sess); ··· 270 269 271 270 down_read(&sessions_table_lock); 272 271 sess = __session_lookup(id); 273 - if (sess) 274 - sess->last_active = jiffies; 275 272 up_read(&sessions_table_lock); 276 273 277 274 return sess; ··· 286 287 if (sess && sess->state != SMB2_SESSION_VALID) 287 288 sess = NULL; 288 289 return sess; 290 + } 291 + 292 + void ksmbd_user_session_get(struct ksmbd_session *sess) 293 + { 294 + atomic_inc(&sess->refcnt); 295 + } 296 + 297 + void ksmbd_user_session_put(struct ksmbd_session *sess) 298 + { 299 + if (!sess) 300 + return; 301 + 302 + if (atomic_read(&sess->refcnt) <= 0) 303 + WARN_ON(1); 304 + else 305 + atomic_dec(&sess->refcnt); 289 306 } 290 307 291 308 struct preauth_session *ksmbd_preauth_session_alloc(struct ksmbd_conn *conn, ··· 408 393 xa_init(&sess->rpc_handle_list); 409 394 sess->sequence_number = 1; 410 395 rwlock_init(&sess->tree_conns_lock); 396 + atomic_set(&sess->refcnt, 1); 411 397 412 398 ret = __init_smb2_session(sess); 413 399 if (ret)
+4
fs/smb/server/mgmt/user_session.h
··· 61 61 struct ksmbd_file_table file_table; 62 62 unsigned long last_active; 63 63 rwlock_t tree_conns_lock; 64 + 65 + atomic_t refcnt; 64 66 }; 65 67 66 68 static inline int test_session_flag(struct ksmbd_session *sess, int bit) ··· 106 104 int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name); 107 105 void ksmbd_session_rpc_close(struct ksmbd_session *sess, int id); 108 106 int ksmbd_session_rpc_method(struct ksmbd_session *sess, int id); 107 + void ksmbd_user_session_get(struct ksmbd_session *sess); 108 + void ksmbd_user_session_put(struct ksmbd_session *sess); 109 109 #endif /* __USER_SESSION_MANAGEMENT_H__ */
+2
fs/smb/server/server.c
··· 238 238 } while (is_chained == true); 239 239 240 240 send: 241 + if (work->sess) 242 + ksmbd_user_session_put(work->sess); 241 243 if (work->tcon) 242 244 ksmbd_tree_connect_put(work->tcon); 243 245 smb3_preauth_hash_rsp(work);
+7 -1
fs/smb/server/smb2pdu.c
··· 605 605 606 606 /* Check for validity of user session */ 607 607 work->sess = ksmbd_session_lookup_all(conn, sess_id); 608 - if (work->sess) 608 + if (work->sess) { 609 + ksmbd_user_session_get(work->sess); 609 610 return 1; 611 + } 610 612 ksmbd_debug(SMB, "Invalid user session, Uid %llu\n", sess_id); 611 613 return -ENOENT; 612 614 } ··· 1742 1740 } 1743 1741 1744 1742 conn->binding = true; 1743 + ksmbd_user_session_get(sess); 1745 1744 } else if ((conn->dialect < SMB30_PROT_ID || 1746 1745 server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL) && 1747 1746 (req->Flags & SMB2_SESSION_REQ_FLAG_BINDING)) { ··· 1769 1766 } 1770 1767 1771 1768 conn->binding = false; 1769 + ksmbd_user_session_get(sess); 1772 1770 } 1773 1771 work->sess = sess; 1774 1772 ··· 2232 2228 } 2233 2229 2234 2230 ksmbd_destroy_file_table(&sess->file_table); 2231 + down_write(&conn->session_lock); 2235 2232 sess->state = SMB2_SESSION_EXPIRED; 2233 + up_write(&conn->session_lock); 2236 2234 2237 2235 ksmbd_free_user(sess->user); 2238 2236 sess->user = NULL;
+12 -3
fs/smb/server/smb_common.c
··· 736 736 struct ksmbd_share_config *share) 737 737 { 738 738 struct ksmbd_session *sess = work->sess; 739 + struct ksmbd_user *user = sess->user; 739 740 struct cred *cred; 740 741 struct group_info *gi; 741 742 unsigned int uid; 742 743 unsigned int gid; 744 + int i; 743 745 744 - uid = user_uid(sess->user); 745 - gid = user_gid(sess->user); 746 + uid = user_uid(user); 747 + gid = user_gid(user); 746 748 if (share->force_uid != KSMBD_SHARE_INVALID_UID) 747 749 uid = share->force_uid; 748 750 if (share->force_gid != KSMBD_SHARE_INVALID_GID) ··· 757 755 cred->fsuid = make_kuid(&init_user_ns, uid); 758 756 cred->fsgid = make_kgid(&init_user_ns, gid); 759 757 760 - gi = groups_alloc(0); 758 + gi = groups_alloc(user->ngroups); 761 759 if (!gi) { 762 760 abort_creds(cred); 763 761 return -ENOMEM; 764 762 } 763 + 764 + for (i = 0; i < user->ngroups; i++) 765 + gi->gid[i] = make_kgid(&init_user_ns, user->sgid[i]); 766 + 767 + if (user->ngroups) 768 + groups_sort(gi); 769 + 765 770 set_groups(cred, gi); 766 771 put_group_info(gi); 767 772
+60 -4
fs/smb/server/transport_ipc.c
··· 120 120 }, 121 121 [KSMBD_EVENT_SPNEGO_AUTHEN_RESPONSE] = { 122 122 }, 123 + [KSMBD_EVENT_LOGIN_REQUEST_EXT] = { 124 + .len = sizeof(struct ksmbd_login_request), 125 + }, 126 + [KSMBD_EVENT_LOGIN_RESPONSE_EXT] = { 127 + .len = sizeof(struct ksmbd_login_response_ext), 128 + }, 123 129 }; 124 130 125 131 static struct genl_ops ksmbd_genl_ops[] = { ··· 193 187 .cmd = KSMBD_EVENT_SPNEGO_AUTHEN_RESPONSE, 194 188 .doit = handle_generic_event, 195 189 }, 190 + { 191 + .cmd = KSMBD_EVENT_LOGIN_REQUEST_EXT, 192 + .doit = handle_unsupported_event, 193 + }, 194 + { 195 + .cmd = KSMBD_EVENT_LOGIN_RESPONSE_EXT, 196 + .doit = handle_generic_event, 197 + }, 196 198 }; 197 199 198 200 static struct genl_family ksmbd_genl_family = { ··· 212 198 .module = THIS_MODULE, 213 199 .ops = ksmbd_genl_ops, 214 200 .n_ops = ARRAY_SIZE(ksmbd_genl_ops), 215 - .resv_start_op = KSMBD_EVENT_SPNEGO_AUTHEN_RESPONSE + 1, 201 + .resv_start_op = KSMBD_EVENT_LOGIN_RESPONSE_EXT + 1, 216 202 }; 217 203 218 204 static void ksmbd_nl_init_fixup(void) ··· 473 459 { 474 460 unsigned int msg_sz = entry->msg_sz; 475 461 476 - if (entry->type == KSMBD_EVENT_RPC_REQUEST) { 462 + switch (entry->type) { 463 + case KSMBD_EVENT_RPC_REQUEST: 464 + { 477 465 struct ksmbd_rpc_command *resp = entry->response; 478 466 479 467 msg_sz = sizeof(struct ksmbd_rpc_command) + resp->payload_sz; 480 - } else if (entry->type == KSMBD_EVENT_SPNEGO_AUTHEN_REQUEST) { 468 + break; 469 + } 470 + case KSMBD_EVENT_SPNEGO_AUTHEN_REQUEST: 471 + { 481 472 struct ksmbd_spnego_authen_response *resp = entry->response; 482 473 483 474 msg_sz = sizeof(struct ksmbd_spnego_authen_response) + 484 475 resp->session_key_len + resp->spnego_blob_len; 485 - } else if (entry->type == KSMBD_EVENT_SHARE_CONFIG_REQUEST) { 476 + break; 477 + } 478 + case KSMBD_EVENT_SHARE_CONFIG_REQUEST: 479 + { 486 480 struct ksmbd_share_config_response *resp = entry->response; 487 481 488 482 if (resp->payload_sz) { ··· 500 478 msg_sz = sizeof(struct ksmbd_share_config_response) + 501 479 resp->payload_sz; 502 480 } 481 + break; 482 + } 483 + case KSMBD_EVENT_LOGIN_REQUEST_EXT: 484 + { 485 + struct ksmbd_login_response_ext *resp = entry->response; 486 + 487 + if (resp->ngroups) { 488 + msg_sz = sizeof(struct ksmbd_login_response_ext) + 489 + resp->ngroups * sizeof(gid_t); 490 + } 491 + } 503 492 } 504 493 505 494 return entry->msg_sz != msg_sz ? -EINVAL : 0; ··· 587 554 req->handle = ksmbd_acquire_id(&ipc_ida); 588 555 strscpy(req->account, account, KSMBD_REQ_MAX_ACCOUNT_NAME_SZ); 589 556 557 + resp = ipc_msg_send_request(msg, req->handle); 558 + ipc_msg_handle_free(req->handle); 559 + ipc_msg_free(msg); 560 + return resp; 561 + } 562 + 563 + struct ksmbd_login_response_ext *ksmbd_ipc_login_request_ext(const char *account) 564 + { 565 + struct ksmbd_ipc_msg *msg; 566 + struct ksmbd_login_request *req; 567 + struct ksmbd_login_response_ext *resp; 568 + 569 + if (strlen(account) >= KSMBD_REQ_MAX_ACCOUNT_NAME_SZ) 570 + return NULL; 571 + 572 + msg = ipc_msg_alloc(sizeof(struct ksmbd_login_request)); 573 + if (!msg) 574 + return NULL; 575 + 576 + msg->type = KSMBD_EVENT_LOGIN_REQUEST_EXT; 577 + req = (struct ksmbd_login_request *)msg->payload; 578 + req->handle = ksmbd_acquire_id(&ipc_ida); 579 + strscpy(req->account, account, KSMBD_REQ_MAX_ACCOUNT_NAME_SZ); 590 580 resp = ipc_msg_send_request(msg, req->handle); 591 581 ipc_msg_handle_free(req->handle); 592 582 ipc_msg_free(msg);
+2
fs/smb/server/transport_ipc.h
··· 12 12 13 13 struct ksmbd_login_response * 14 14 ksmbd_ipc_login_request(const char *account); 15 + struct ksmbd_login_response_ext * 16 + ksmbd_ipc_login_request_ext(const char *account); 15 17 16 18 struct ksmbd_session; 17 19 struct ksmbd_share_config;
+35
include/linux/closure.h
··· 454 454 __closure_wait_event(waitlist, _cond); \ 455 455 } while (0) 456 456 457 + #define __closure_wait_event_timeout(waitlist, _cond, _until) \ 458 + ({ \ 459 + struct closure cl; \ 460 + long _t; \ 461 + \ 462 + closure_init_stack(&cl); \ 463 + \ 464 + while (1) { \ 465 + closure_wait(waitlist, &cl); \ 466 + if (_cond) { \ 467 + _t = max_t(long, 1L, _until - jiffies); \ 468 + break; \ 469 + } \ 470 + _t = max_t(long, 0L, _until - jiffies); \ 471 + if (!_t) \ 472 + break; \ 473 + closure_sync_timeout(&cl, _t); \ 474 + } \ 475 + closure_wake_up(waitlist); \ 476 + closure_sync(&cl); \ 477 + _t; \ 478 + }) 479 + 480 + /* 481 + * Returns 0 if timeout expired, remaining time in jiffies (at least 1) if 482 + * condition became true 483 + */ 484 + #define closure_wait_event_timeout(waitlist, _cond, _timeout) \ 485 + ({ \ 486 + unsigned long _until = jiffies + _timeout; \ 487 + (_cond) \ 488 + ? max_t(long, 1L, _until - jiffies) \ 489 + : __closure_wait_event_timeout(waitlist, _cond, _until);\ 490 + }) 491 + 457 492 #endif /* _LINUX_CLOSURE_H */
+2 -1
include/linux/fsl/enetc_mdio.h
··· 59 59 static inline int enetc_mdio_write_c45(struct mii_bus *bus, int phy_id, 60 60 int devad, int regnum, u16 value) 61 61 { return -EINVAL; } 62 - struct enetc_hw *enetc_hw_alloc(struct device *dev, void __iomem *port_regs) 62 + static inline struct enetc_hw *enetc_hw_alloc(struct device *dev, 63 + void __iomem *port_regs) 63 64 { return ERR_PTR(-EINVAL); } 64 65 65 66 #endif
+1
include/linux/nfs_fs_sb.h
··· 249 249 struct list_head layouts; 250 250 struct list_head delegations; 251 251 struct list_head ss_copies; 252 + struct list_head ss_src_copies; 252 253 253 254 unsigned long delegation_gen; 254 255 unsigned long mig_gen;
+15
include/linux/nfslocalio.h
··· 65 65 struct rpc_clnt *, const struct cred *, 66 66 const struct nfs_fh *, const fmode_t); 67 67 68 + static inline void nfs_to_nfsd_file_put_local(struct nfsd_file *localio) 69 + { 70 + /* 71 + * Once reference to nfsd_serv is dropped, NFSD could be 72 + * unloaded, so ensure safe return from nfsd_file_put_local() 73 + * by always taking RCU. 74 + */ 75 + rcu_read_lock(); 76 + nfs_to->nfsd_file_put_local(localio); 77 + rcu_read_unlock(); 78 + } 79 + 68 80 #else /* CONFIG_NFS_LOCALIO */ 69 81 static inline void nfsd_localio_ops_init(void) 82 + { 83 + } 84 + static inline void nfs_to_nfsd_file_put_local(struct nfsd_file *localio) 70 85 { 71 86 } 72 87 #endif /* CONFIG_NFS_LOCALIO */
+1 -2
include/net/genetlink.h
··· 535 535 * @skb: netlink message as socket buffer 536 536 * @portid: own netlink portid to avoid sending to yourself 537 537 * @group: offset of multicast group in groups array 538 - * @flags: allocation flags 539 538 * 540 539 * This function must hold the RTNL or rcu_read_lock(). 541 540 */ 542 541 int genlmsg_multicast_allns(const struct genl_family *family, 543 542 struct sk_buff *skb, u32 portid, 544 - unsigned int group, gfp_t flags); 543 + unsigned int group); 545 544 546 545 /** 547 546 * genlmsg_unicast - unicast a netlink message
+24 -20
io_uring/rw.c
··· 31 31 rwf_t flags; 32 32 }; 33 33 34 - static inline bool io_file_supports_nowait(struct io_kiocb *req) 34 + static bool io_file_supports_nowait(struct io_kiocb *req, __poll_t mask) 35 35 { 36 - return req->flags & REQ_F_SUPPORT_NOWAIT; 36 + /* If FMODE_NOWAIT is set for a file, we're golden */ 37 + if (req->flags & REQ_F_SUPPORT_NOWAIT) 38 + return true; 39 + /* No FMODE_NOWAIT, if we can poll, check the status */ 40 + if (io_file_can_poll(req)) { 41 + struct poll_table_struct pt = { ._key = mask }; 42 + 43 + return vfs_poll(req->file, &pt) & mask; 44 + } 45 + /* No FMODE_NOWAIT support, and file isn't pollable. Tough luck. */ 46 + return false; 37 47 } 38 48 39 49 #ifdef CONFIG_COMPAT ··· 806 796 * supports async. Otherwise it's impossible to use O_NONBLOCK files 807 797 * reliably. If not, or it IOCB_NOWAIT is set, don't retry. 808 798 */ 809 - if ((kiocb->ki_flags & IOCB_NOWAIT) || 810 - ((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req))) 799 + if (kiocb->ki_flags & IOCB_NOWAIT || 800 + ((file->f_flags & O_NONBLOCK && (req->flags & REQ_F_SUPPORT_NOWAIT)))) 811 801 req->flags |= REQ_F_NOWAIT; 812 802 813 803 if (ctx->flags & IORING_SETUP_IOPOLL) { ··· 848 838 849 839 if (force_nonblock) { 850 840 /* If the file doesn't support async, just async punt */ 851 - if (unlikely(!io_file_supports_nowait(req))) 841 + if (unlikely(!io_file_supports_nowait(req, EPOLLIN))) 852 842 return -EAGAIN; 853 843 kiocb->ki_flags |= IOCB_NOWAIT; 854 844 } else { ··· 962 952 ret = __io_read(req, issue_flags); 963 953 964 954 /* 965 - * If the file doesn't support proper NOWAIT, then disable multishot 966 - * and stay in single shot mode. 967 - */ 968 - if (!io_file_supports_nowait(req)) 969 - req->flags &= ~REQ_F_APOLL_MULTISHOT; 970 - 971 - /* 972 955 * If we get -EAGAIN, recycle our buffer and just let normal poll 973 956 * handling arm it. 974 957 */ ··· 975 972 if (issue_flags & IO_URING_F_MULTISHOT) 976 973 return IOU_ISSUE_SKIP_COMPLETE; 977 974 return -EAGAIN; 978 - } 979 - 980 - /* 981 - * Any successful return value will keep the multishot read armed. 982 - */ 983 - if (ret > 0 && req->flags & REQ_F_APOLL_MULTISHOT) { 975 + } else if (ret <= 0) { 976 + io_kbuf_recycle(req, issue_flags); 977 + if (ret < 0) 978 + req_set_fail(req); 979 + } else { 984 980 /* 985 - * Put our buffer and post a CQE. If we fail to post a CQE, then 981 + * Any successful return value will keep the multishot read 982 + * armed, if it's still set. Put our buffer and post a CQE. If 983 + * we fail to post a CQE, or multishot is no longer set, then 986 984 * jump to the termination path. This request is then done. 987 985 */ 988 986 cflags = io_put_kbuf(req, ret, issue_flags); ··· 1030 1026 1031 1027 if (force_nonblock) { 1032 1028 /* If the file doesn't support async, just async punt */ 1033 - if (unlikely(!io_file_supports_nowait(req))) 1029 + if (unlikely(!io_file_supports_nowait(req, EPOLLOUT))) 1034 1030 goto ret_eagain; 1035 1031 1036 1032 /* Check if we can support NOWAIT. */
+7 -1
kernel/rcu/tree_nocb.h
··· 554 554 rcu_nocb_unlock(rdp); 555 555 wake_nocb_gp_defer(rdp, RCU_NOCB_WAKE_LAZY, 556 556 TPS("WakeLazy")); 557 - } else if (!irqs_disabled_flags(flags)) { 557 + } else if (!irqs_disabled_flags(flags) && cpu_online(rdp->cpu)) { 558 558 /* ... if queue was empty ... */ 559 559 rcu_nocb_unlock(rdp); 560 560 wake_nocb_gp(rdp, false); 561 561 trace_rcu_nocb_wake(rcu_state.name, rdp->cpu, 562 562 TPS("WakeEmpty")); 563 563 } else { 564 + /* 565 + * Don't do the wake-up upfront on fragile paths. 566 + * Also offline CPUs can't call swake_up_one_online() from 567 + * (soft-)IRQs. Rely on the final deferred wake-up from 568 + * rcutree_report_cpu_dead() 569 + */ 564 570 rcu_nocb_unlock(rdp); 565 571 wake_nocb_gp_defer(rdp, RCU_NOCB_WAKE, 566 572 TPS("WakeEmptyIsDeferred"));
+102 -86
kernel/sched/ext.c
··· 9 9 #define SCX_OP_IDX(op) (offsetof(struct sched_ext_ops, op) / sizeof(void (*)(void))) 10 10 11 11 enum scx_consts { 12 - SCX_SLICE_BYPASS = SCX_SLICE_DFL / 4, 13 12 SCX_DSP_DFL_MAX_BATCH = 32, 14 13 SCX_DSP_MAX_LOOPS = 32, 15 14 SCX_WATCHDOG_MAX_TIMEOUT = 30 * HZ, ··· 18 19 SCX_EXIT_DUMP_DFL_LEN = 32768, 19 20 20 21 SCX_CPUPERF_ONE = SCHED_CAPACITY_SCALE, 22 + 23 + /* 24 + * Iterating all tasks may take a while. Periodically drop 25 + * scx_tasks_lock to avoid causing e.g. CSD and RCU stalls. 26 + */ 27 + SCX_OPS_TASK_ITER_BATCH = 32, 21 28 }; 22 29 23 30 enum scx_exit_kind { ··· 1279 1274 struct task_struct *locked; 1280 1275 struct rq *rq; 1281 1276 struct rq_flags rf; 1277 + u32 cnt; 1282 1278 }; 1283 1279 1284 1280 /** 1285 - * scx_task_iter_init - Initialize a task iterator 1281 + * scx_task_iter_start - Lock scx_tasks_lock and start a task iteration 1286 1282 * @iter: iterator to init 1287 1283 * 1288 - * Initialize @iter. Must be called with scx_tasks_lock held. Once initialized, 1289 - * @iter must eventually be exited with scx_task_iter_exit(). 1284 + * Initialize @iter and return with scx_tasks_lock held. Once initialized, @iter 1285 + * must eventually be stopped with scx_task_iter_stop(). 1290 1286 * 1291 - * scx_tasks_lock may be released between this and the first next() call or 1292 - * between any two next() calls. If scx_tasks_lock is released between two 1293 - * next() calls, the caller is responsible for ensuring that the task being 1294 - * iterated remains accessible either through RCU read lock or obtaining a 1295 - * reference count. 1287 + * scx_tasks_lock and the rq lock may be released using scx_task_iter_unlock() 1288 + * between this and the first next() call or between any two next() calls. If 1289 + * the locks are released between two next() calls, the caller is responsible 1290 + * for ensuring that the task being iterated remains accessible either through 1291 + * RCU read lock or obtaining a reference count. 1296 1292 * 1297 1293 * All tasks which existed when the iteration started are guaranteed to be 1298 1294 * visited as long as they still exist. 1299 1295 */ 1300 - static void scx_task_iter_init(struct scx_task_iter *iter) 1296 + static void scx_task_iter_start(struct scx_task_iter *iter) 1301 1297 { 1302 - lockdep_assert_held(&scx_tasks_lock); 1303 - 1304 1298 BUILD_BUG_ON(__SCX_DSQ_ITER_ALL_FLAGS & 1305 1299 ((1U << __SCX_DSQ_LNODE_PRIV_SHIFT) - 1)); 1300 + 1301 + spin_lock_irq(&scx_tasks_lock); 1306 1302 1307 1303 iter->cursor = (struct sched_ext_entity){ .flags = SCX_TASK_CURSOR }; 1308 1304 list_add(&iter->cursor.tasks_node, &scx_tasks); 1309 1305 iter->locked = NULL; 1306 + iter->cnt = 0; 1310 1307 } 1311 1308 1312 - /** 1313 - * scx_task_iter_rq_unlock - Unlock rq locked by a task iterator 1314 - * @iter: iterator to unlock rq for 1315 - * 1316 - * If @iter is in the middle of a locked iteration, it may be locking the rq of 1317 - * the task currently being visited. Unlock the rq if so. This function can be 1318 - * safely called anytime during an iteration. 1319 - * 1320 - * Returns %true if the rq @iter was locking is unlocked. %false if @iter was 1321 - * not locking an rq. 1322 - */ 1323 - static bool scx_task_iter_rq_unlock(struct scx_task_iter *iter) 1309 + static void __scx_task_iter_rq_unlock(struct scx_task_iter *iter) 1324 1310 { 1325 1311 if (iter->locked) { 1326 1312 task_rq_unlock(iter->rq, iter->locked, &iter->rf); 1327 1313 iter->locked = NULL; 1328 - return true; 1329 - } else { 1330 - return false; 1331 1314 } 1332 1315 } 1333 1316 1334 1317 /** 1335 - * scx_task_iter_exit - Exit a task iterator 1318 + * scx_task_iter_unlock - Unlock rq and scx_tasks_lock held by a task iterator 1319 + * @iter: iterator to unlock 1320 + * 1321 + * If @iter is in the middle of a locked iteration, it may be locking the rq of 1322 + * the task currently being visited in addition to scx_tasks_lock. Unlock both. 1323 + * This function can be safely called anytime during an iteration. 1324 + */ 1325 + static void scx_task_iter_unlock(struct scx_task_iter *iter) 1326 + { 1327 + __scx_task_iter_rq_unlock(iter); 1328 + spin_unlock_irq(&scx_tasks_lock); 1329 + } 1330 + 1331 + /** 1332 + * scx_task_iter_relock - Lock scx_tasks_lock released by scx_task_iter_unlock() 1333 + * @iter: iterator to re-lock 1334 + * 1335 + * Re-lock scx_tasks_lock unlocked by scx_task_iter_unlock(). Note that it 1336 + * doesn't re-lock the rq lock. Must be called before other iterator operations. 1337 + */ 1338 + static void scx_task_iter_relock(struct scx_task_iter *iter) 1339 + { 1340 + spin_lock_irq(&scx_tasks_lock); 1341 + } 1342 + 1343 + /** 1344 + * scx_task_iter_stop - Stop a task iteration and unlock scx_tasks_lock 1336 1345 * @iter: iterator to exit 1337 1346 * 1338 - * Exit a previously initialized @iter. Must be called with scx_tasks_lock held. 1339 - * If the iterator holds a task's rq lock, that rq lock is released. See 1340 - * scx_task_iter_init() for details. 1347 + * Exit a previously initialized @iter. Must be called with scx_tasks_lock held 1348 + * which is released on return. If the iterator holds a task's rq lock, that rq 1349 + * lock is also released. See scx_task_iter_start() for details. 1341 1350 */ 1342 - static void scx_task_iter_exit(struct scx_task_iter *iter) 1351 + static void scx_task_iter_stop(struct scx_task_iter *iter) 1343 1352 { 1344 - lockdep_assert_held(&scx_tasks_lock); 1345 - 1346 - scx_task_iter_rq_unlock(iter); 1347 1353 list_del_init(&iter->cursor.tasks_node); 1354 + scx_task_iter_unlock(iter); 1348 1355 } 1349 1356 1350 1357 /** 1351 1358 * scx_task_iter_next - Next task 1352 1359 * @iter: iterator to walk 1353 1360 * 1354 - * Visit the next task. See scx_task_iter_init() for details. 1361 + * Visit the next task. See scx_task_iter_start() for details. Locks are dropped 1362 + * and re-acquired every %SCX_OPS_TASK_ITER_BATCH iterations to avoid causing 1363 + * stalls by holding scx_tasks_lock for too long. 1355 1364 */ 1356 1365 static struct task_struct *scx_task_iter_next(struct scx_task_iter *iter) 1357 1366 { 1358 1367 struct list_head *cursor = &iter->cursor.tasks_node; 1359 1368 struct sched_ext_entity *pos; 1360 1369 1361 - lockdep_assert_held(&scx_tasks_lock); 1370 + if (!(++iter->cnt % SCX_OPS_TASK_ITER_BATCH)) { 1371 + scx_task_iter_unlock(iter); 1372 + cond_resched(); 1373 + scx_task_iter_relock(iter); 1374 + } 1362 1375 1363 1376 list_for_each_entry(pos, cursor, tasks_node) { 1364 1377 if (&pos->tasks_node == &scx_tasks) ··· 1397 1374 * @include_dead: Whether we should include dead tasks in the iteration 1398 1375 * 1399 1376 * Visit the non-idle task with its rq lock held. Allows callers to specify 1400 - * whether they would like to filter out dead tasks. See scx_task_iter_init() 1377 + * whether they would like to filter out dead tasks. See scx_task_iter_start() 1401 1378 * for details. 1402 1379 */ 1403 1380 static struct task_struct *scx_task_iter_next_locked(struct scx_task_iter *iter) 1404 1381 { 1405 1382 struct task_struct *p; 1406 1383 1407 - scx_task_iter_rq_unlock(iter); 1384 + __scx_task_iter_rq_unlock(iter); 1408 1385 1409 1386 while ((p = scx_task_iter_next(iter))) { 1410 1387 /* ··· 1972 1949 static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags, 1973 1950 int sticky_cpu) 1974 1951 { 1975 - bool bypassing = scx_rq_bypassing(rq); 1976 1952 struct task_struct **ddsp_taskp; 1977 1953 unsigned long qseq; 1978 1954 ··· 1989 1967 if (!scx_rq_online(rq)) 1990 1968 goto local; 1991 1969 1992 - if (bypassing) 1970 + if (scx_rq_bypassing(rq)) 1993 1971 goto global; 1994 1972 1995 1973 if (p->scx.ddsp_dsq_id != SCX_DSQ_INVALID) ··· 2044 2022 2045 2023 global: 2046 2024 touch_core_sched(rq, p); /* see the comment in local: */ 2047 - p->scx.slice = bypassing ? SCX_SLICE_BYPASS : SCX_SLICE_DFL; 2025 + p->scx.slice = SCX_SLICE_DFL; 2048 2026 dispatch_enqueue(find_global_dsq(p), p, enq_flags); 2049 2027 } 2050 2028 ··· 2980 2958 2981 2959 if (unlikely(!p->scx.slice)) { 2982 2960 if (!scx_rq_bypassing(rq) && !scx_warned_zero_slice) { 2983 - printk_deferred(KERN_WARNING "sched_ext: %s[%d] has zero slice in pick_next_task_scx()\n", 2984 - p->comm, p->pid); 2961 + printk_deferred(KERN_WARNING "sched_ext: %s[%d] has zero slice in %s()\n", 2962 + p->comm, p->pid, __func__); 2985 2963 scx_warned_zero_slice = true; 2986 2964 } 2987 2965 p->scx.slice = SCX_SLICE_DFL; ··· 3086 3064 3087 3065 *found = false; 3088 3066 3089 - if (!static_branch_likely(&scx_builtin_idle_enabled)) { 3090 - scx_ops_error("built-in idle tracking is disabled"); 3091 - return prev_cpu; 3092 - } 3093 - 3094 3067 /* 3095 3068 * If WAKE_SYNC, the waker's local DSQ is empty, and the system is 3096 3069 * under utilized, wake up @p to the local DSQ of the waker. Checking ··· 3150 3133 if (unlikely(wake_flags & WF_EXEC)) 3151 3134 return prev_cpu; 3152 3135 3153 - if (SCX_HAS_OP(select_cpu)) { 3136 + if (SCX_HAS_OP(select_cpu) && !scx_rq_bypassing(task_rq(p))) { 3154 3137 s32 cpu; 3155 3138 struct task_struct **ddsp_taskp; 3156 3139 ··· 3215 3198 { 3216 3199 int cpu = cpu_of(rq); 3217 3200 3218 - if (SCX_HAS_OP(update_idle)) { 3201 + if (SCX_HAS_OP(update_idle) && !scx_rq_bypassing(rq)) { 3219 3202 SCX_CALL_OP(SCX_KF_REST, update_idle, cpu_of(rq), idle); 3220 3203 if (!static_branch_unlikely(&scx_builtin_idle_enabled)) 3221 3204 return; ··· 4278 4261 * the DISABLING state and then cycling the queued tasks through dequeue/enqueue 4279 4262 * to force global FIFO scheduling. 4280 4263 * 4281 - * a. ops.enqueue() is ignored and tasks are queued in simple global FIFO order. 4282 - * %SCX_OPS_ENQ_LAST is also ignored. 4264 + * - ops.select_cpu() is ignored and the default select_cpu() is used. 4283 4265 * 4284 - * b. ops.dispatch() is ignored. 4266 + * - ops.enqueue() is ignored and tasks are queued in simple global FIFO order. 4267 + * %SCX_OPS_ENQ_LAST is also ignored. 4285 4268 * 4286 - * c. balance_scx() does not set %SCX_RQ_BAL_KEEP on non-zero slice as slice 4287 - * can't be trusted. Whenever a tick triggers, the running task is rotated to 4288 - * the tail of the queue with core_sched_at touched. 4269 + * - ops.dispatch() is ignored. 4289 4270 * 4290 - * d. pick_next_task() suppresses zero slice warning. 4271 + * - balance_scx() does not set %SCX_RQ_BAL_KEEP on non-zero slice as slice 4272 + * can't be trusted. Whenever a tick triggers, the running task is rotated to 4273 + * the tail of the queue with core_sched_at touched. 4291 4274 * 4292 - * e. scx_bpf_kick_cpu() is disabled to avoid irq_work malfunction during PM 4293 - * operations. 4275 + * - pick_next_task() suppresses zero slice warning. 4294 4276 * 4295 - * f. scx_prio_less() reverts to the default core_sched_at order. 4277 + * - scx_bpf_kick_cpu() is disabled to avoid irq_work malfunction during PM 4278 + * operations. 4279 + * 4280 + * - scx_prio_less() reverts to the default core_sched_at order. 4296 4281 */ 4297 4282 static void scx_ops_bypass(bool bypass) 4298 4283 { ··· 4364 4345 4365 4346 rq_unlock_irqrestore(rq, &rf); 4366 4347 4367 - /* kick to restore ticks */ 4348 + /* resched to restore ticks and idle state */ 4368 4349 resched_cpu(cpu); 4369 4350 } 4370 4351 } ··· 4486 4467 4487 4468 scx_ops_init_task_enabled = false; 4488 4469 4489 - spin_lock_irq(&scx_tasks_lock); 4490 - scx_task_iter_init(&sti); 4470 + scx_task_iter_start(&sti); 4491 4471 while ((p = scx_task_iter_next_locked(&sti))) { 4492 4472 const struct sched_class *old_class = p->sched_class; 4493 4473 struct sched_enq_and_set_ctx ctx; 4494 4474 4495 4475 sched_deq_and_put_task(p, DEQUEUE_SAVE | DEQUEUE_MOVE, &ctx); 4496 4476 4497 - p->scx.slice = min_t(u64, p->scx.slice, SCX_SLICE_DFL); 4498 4477 __setscheduler_prio(p, p->prio); 4499 4478 check_class_changing(task_rq(p), p, old_class); 4500 4479 ··· 4501 4484 check_class_changed(task_rq(p), p, old_class, p->prio); 4502 4485 scx_ops_exit_task(p); 4503 4486 } 4504 - scx_task_iter_exit(&sti); 4505 - spin_unlock_irq(&scx_tasks_lock); 4487 + scx_task_iter_stop(&sti); 4506 4488 percpu_up_write(&scx_fork_rwsem); 4507 4489 4508 4490 /* no task is on scx, turn off all the switches and flush in-progress calls */ ··· 5152 5136 if (ret) 5153 5137 goto err_disable_unlock_all; 5154 5138 5155 - spin_lock_irq(&scx_tasks_lock); 5156 - scx_task_iter_init(&sti); 5139 + scx_task_iter_start(&sti); 5157 5140 while ((p = scx_task_iter_next_locked(&sti))) { 5158 5141 /* 5159 5142 * @p may already be dead, have lost all its usages counts and ··· 5162 5147 if (!tryget_task_struct(p)) 5163 5148 continue; 5164 5149 5165 - scx_task_iter_rq_unlock(&sti); 5166 - spin_unlock_irq(&scx_tasks_lock); 5150 + scx_task_iter_unlock(&sti); 5167 5151 5168 5152 ret = scx_ops_init_task(p, task_group(p), false); 5169 5153 if (ret) { 5170 5154 put_task_struct(p); 5171 - spin_lock_irq(&scx_tasks_lock); 5172 - scx_task_iter_exit(&sti); 5173 - spin_unlock_irq(&scx_tasks_lock); 5155 + scx_task_iter_relock(&sti); 5156 + scx_task_iter_stop(&sti); 5174 5157 scx_ops_error("ops.init_task() failed (%d) for %s[%d]", 5175 5158 ret, p->comm, p->pid); 5176 5159 goto err_disable_unlock_all; ··· 5177 5164 scx_set_task_state(p, SCX_TASK_READY); 5178 5165 5179 5166 put_task_struct(p); 5180 - spin_lock_irq(&scx_tasks_lock); 5167 + scx_task_iter_relock(&sti); 5181 5168 } 5182 - scx_task_iter_exit(&sti); 5183 - spin_unlock_irq(&scx_tasks_lock); 5169 + scx_task_iter_stop(&sti); 5184 5170 scx_cgroup_unlock(); 5185 5171 percpu_up_write(&scx_fork_rwsem); 5186 5172 ··· 5196 5184 * scx_tasks_lock. 5197 5185 */ 5198 5186 percpu_down_write(&scx_fork_rwsem); 5199 - spin_lock_irq(&scx_tasks_lock); 5200 - scx_task_iter_init(&sti); 5187 + scx_task_iter_start(&sti); 5201 5188 while ((p = scx_task_iter_next_locked(&sti))) { 5202 5189 const struct sched_class *old_class = p->sched_class; 5203 5190 struct sched_enq_and_set_ctx ctx; 5204 5191 5205 5192 sched_deq_and_put_task(p, DEQUEUE_SAVE | DEQUEUE_MOVE, &ctx); 5206 5193 5194 + p->scx.slice = SCX_SLICE_DFL; 5207 5195 __setscheduler_prio(p, p->prio); 5208 5196 check_class_changing(task_rq(p), p, old_class); 5209 5197 ··· 5211 5199 5212 5200 check_class_changed(task_rq(p), p, old_class, p->prio); 5213 5201 } 5214 - scx_task_iter_exit(&sti); 5215 - spin_unlock_irq(&scx_tasks_lock); 5202 + scx_task_iter_stop(&sti); 5216 5203 percpu_up_write(&scx_fork_rwsem); 5217 5204 5218 5205 scx_ops_bypass(false); ··· 5883 5872 __bpf_kfunc s32 scx_bpf_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, 5884 5873 u64 wake_flags, bool *is_idle) 5885 5874 { 5886 - if (!scx_kf_allowed(SCX_KF_SELECT_CPU)) { 5887 - *is_idle = false; 5888 - return prev_cpu; 5875 + if (!static_branch_likely(&scx_builtin_idle_enabled)) { 5876 + scx_ops_error("built-in idle tracking is disabled"); 5877 + goto prev_cpu; 5889 5878 } 5879 + 5880 + if (!scx_kf_allowed(SCX_KF_SELECT_CPU)) 5881 + goto prev_cpu; 5882 + 5890 5883 #ifdef CONFIG_SMP 5891 5884 return scx_select_cpu_dfl(p, prev_cpu, wake_flags, is_idle); 5892 - #else 5885 + #endif 5886 + 5887 + prev_cpu: 5893 5888 *is_idle = false; 5894 5889 return prev_cpu; 5895 - #endif 5896 5890 } 5897 5891 5898 5892 __bpf_kfunc_end_defs();
+3
kernel/time/posix-clock.c
··· 318 318 goto out; 319 319 } 320 320 321 + if (!timespec64_valid_strict(ts)) 322 + return -EINVAL; 323 + 321 324 if (cd.clk->ops.clock_settime) 322 325 err = cd.clk->ops.clock_settime(cd.clk, ts); 323 326 else
+26 -18
kernel/trace/ring_buffer.c
··· 6728 6728 } 6729 6729 6730 6730 for_each_buffer_cpu(buffer, cpu) { 6731 + struct buffer_data_page *old_free_data_page; 6732 + struct list_head old_pages; 6733 + unsigned long flags; 6731 6734 6732 6735 if (!cpumask_test_cpu(cpu, buffer->cpumask)) 6733 6736 continue; 6734 6737 6735 6738 cpu_buffer = buffer->buffers[cpu]; 6736 6739 6740 + raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags); 6741 + 6737 6742 /* Clear the head bit to make the link list normal to read */ 6738 6743 rb_head_page_deactivate(cpu_buffer); 6739 6744 6740 - /* Now walk the list and free all the old sub buffers */ 6741 - list_for_each_entry_safe(bpage, tmp, cpu_buffer->pages, list) { 6742 - list_del_init(&bpage->list); 6743 - free_buffer_page(bpage); 6744 - } 6745 - /* The above loop stopped an the last page needing to be freed */ 6746 - bpage = list_entry(cpu_buffer->pages, struct buffer_page, list); 6747 - free_buffer_page(bpage); 6748 - 6749 - /* Free the current reader page */ 6750 - free_buffer_page(cpu_buffer->reader_page); 6745 + /* 6746 + * Collect buffers from the cpu_buffer pages list and the 6747 + * reader_page on old_pages, so they can be freed later when not 6748 + * under a spinlock. The pages list is a linked list with no 6749 + * head, adding old_pages turns it into a regular list with 6750 + * old_pages being the head. 6751 + */ 6752 + list_add(&old_pages, cpu_buffer->pages); 6753 + list_add(&cpu_buffer->reader_page->list, &old_pages); 6751 6754 6752 6755 /* One page was allocated for the reader page */ 6753 6756 cpu_buffer->reader_page = list_entry(cpu_buffer->new_pages.next, 6754 6757 struct buffer_page, list); 6755 6758 list_del_init(&cpu_buffer->reader_page->list); 6756 6759 6757 - /* The cpu_buffer pages are a link list with no head */ 6760 + /* Install the new pages, remove the head from the list */ 6758 6761 cpu_buffer->pages = cpu_buffer->new_pages.next; 6759 - cpu_buffer->new_pages.next->prev = cpu_buffer->new_pages.prev; 6760 - cpu_buffer->new_pages.prev->next = cpu_buffer->new_pages.next; 6761 - 6762 - /* Clear the new_pages list */ 6763 - INIT_LIST_HEAD(&cpu_buffer->new_pages); 6762 + list_del_init(&cpu_buffer->new_pages); 6764 6763 6765 6764 cpu_buffer->head_page 6766 6765 = list_entry(cpu_buffer->pages, struct buffer_page, list); ··· 6768 6769 cpu_buffer->nr_pages = cpu_buffer->nr_pages_to_update; 6769 6770 cpu_buffer->nr_pages_to_update = 0; 6770 6771 6771 - free_pages((unsigned long)cpu_buffer->free_page, old_order); 6772 + old_free_data_page = cpu_buffer->free_page; 6772 6773 cpu_buffer->free_page = NULL; 6773 6774 6774 6775 rb_head_page_activate(cpu_buffer); 6776 + 6777 + raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); 6778 + 6779 + /* Free old sub buffers */ 6780 + list_for_each_entry_safe(bpage, tmp, &old_pages, list) { 6781 + list_del_init(&bpage->list); 6782 + free_buffer_page(bpage); 6783 + } 6784 + free_pages((unsigned long)old_free_data_page, old_order); 6775 6785 6776 6786 rb_check_pages(cpu_buffer); 6777 6787 }
+3 -3
kernel/trace/trace.c
··· 10621 10621 * cannot be deleted by user space, so keep the reference 10622 10622 * to it. 10623 10623 */ 10624 - if (start) 10624 + if (start) { 10625 10625 tr->flags |= TRACE_ARRAY_FL_BOOT; 10626 - else 10627 - trace_array_put(tr); 10626 + tr->ref++; 10627 + } 10628 10628 10629 10629 while ((tok = strsep(&curr_str, ","))) { 10630 10630 early_enable_events(tr, tok, true);
+2
net/9p/Kconfig
··· 43 43 config NET_9P_USBG 44 44 bool "9P USB Gadget Transport" 45 45 depends on USB_GADGET=y || USB_GADGET=NET_9P 46 + select CONFIGFS_FS 47 + select USB_LIBCOMPOSITE 46 48 help 47 49 This builds support for a transport for 9pfs over 48 50 usb gadget.
+25 -10
net/ipv4/devinet.c
··· 295 295 /* Account for reference dev->ip_ptr (below) */ 296 296 refcount_set(&in_dev->refcnt, 1); 297 297 298 - err = devinet_sysctl_register(in_dev); 299 - if (err) { 300 - in_dev->dead = 1; 301 - neigh_parms_release(&arp_tbl, in_dev->arp_parms); 302 - in_dev_put(in_dev); 303 - in_dev = NULL; 304 - goto out; 298 + if (dev != blackhole_netdev) { 299 + err = devinet_sysctl_register(in_dev); 300 + if (err) { 301 + in_dev->dead = 1; 302 + neigh_parms_release(&arp_tbl, in_dev->arp_parms); 303 + in_dev_put(in_dev); 304 + in_dev = NULL; 305 + goto out; 306 + } 307 + ip_mc_init_dev(in_dev); 308 + if (dev->flags & IFF_UP) 309 + ip_mc_up(in_dev); 305 310 } 306 - ip_mc_init_dev(in_dev); 307 - if (dev->flags & IFF_UP) 308 - ip_mc_up(in_dev); 309 311 310 312 /* we can receive as soon as ip_ptr is set -- do this last */ 311 313 rcu_assign_pointer(dev->ip_ptr, in_dev); ··· 345 343 346 344 in_dev_put(in_dev); 347 345 } 346 + 347 + static int __init inet_blackhole_dev_init(void) 348 + { 349 + int err = 0; 350 + 351 + rtnl_lock(); 352 + if (!inetdev_init(blackhole_netdev)) 353 + err = -ENOMEM; 354 + rtnl_unlock(); 355 + 356 + return err; 357 + } 358 + late_initcall(inet_blackhole_dev_init); 348 359 349 360 int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b) 350 361 {
+16 -5
net/ipv4/inet_connection_sock.c
··· 1047 1047 found = __sk_nulls_del_node_init_rcu(sk); 1048 1048 spin_unlock(lock); 1049 1049 } 1050 - if (timer_pending(&req->rsk_timer) && del_timer_sync(&req->rsk_timer)) 1051 - reqsk_put(req); 1050 + 1052 1051 return found; 1053 1052 } 1054 1053 1055 - bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req) 1054 + static bool __inet_csk_reqsk_queue_drop(struct sock *sk, 1055 + struct request_sock *req, 1056 + bool from_timer) 1056 1057 { 1057 1058 bool unlinked = reqsk_queue_unlink(req); 1059 + 1060 + if (!from_timer && timer_delete_sync(&req->rsk_timer)) 1061 + reqsk_put(req); 1058 1062 1059 1063 if (unlinked) { 1060 1064 reqsk_queue_removed(&inet_csk(sk)->icsk_accept_queue, req); 1061 1065 reqsk_put(req); 1062 1066 } 1067 + 1063 1068 return unlinked; 1069 + } 1070 + 1071 + bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req) 1072 + { 1073 + return __inet_csk_reqsk_queue_drop(sk, req, false); 1064 1074 } 1065 1075 EXPORT_SYMBOL(inet_csk_reqsk_queue_drop); 1066 1076 ··· 1164 1154 1165 1155 if (!inet_ehash_insert(req_to_sk(nreq), req_to_sk(oreq), NULL)) { 1166 1156 /* delete timer */ 1167 - inet_csk_reqsk_queue_drop(sk_listener, nreq); 1157 + __inet_csk_reqsk_queue_drop(sk_listener, nreq, true); 1168 1158 goto no_ownership; 1169 1159 } 1170 1160 ··· 1190 1180 } 1191 1181 1192 1182 drop: 1193 - inet_csk_reqsk_queue_drop_and_put(oreq->rsk_listener, oreq); 1183 + __inet_csk_reqsk_queue_drop(sk_listener, oreq, true); 1184 + reqsk_put(req); 1194 1185 } 1195 1186 1196 1187 static bool reqsk_queue_hash_req(struct request_sock *req,
+3 -1
net/ipv4/udp.c
··· 951 951 skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4; 952 952 skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(datalen, 953 953 cork->gso_size); 954 + 955 + /* Don't checksum the payload, skb will get segmented */ 956 + goto csum_partial; 954 957 } 955 - goto csum_partial; 956 958 } 957 959 958 960 if (is_udplite) /* UDP-Lite */
+3 -1
net/ipv6/udp.c
··· 1266 1266 skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4; 1267 1267 skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(datalen, 1268 1268 cork->gso_size); 1269 + 1270 + /* Don't checksum the payload, skb will get segmented */ 1271 + goto csum_partial; 1269 1272 } 1270 - goto csum_partial; 1271 1273 } 1272 1274 1273 1275 if (is_udplite)
+2 -2
net/l2tp/l2tp_netlink.c
··· 116 116 NLM_F_ACK, tunnel, cmd); 117 117 118 118 if (ret >= 0) { 119 - ret = genlmsg_multicast_allns(family, msg, 0, 0, GFP_ATOMIC); 119 + ret = genlmsg_multicast_allns(family, msg, 0, 0); 120 120 /* We don't care if no one is listening */ 121 121 if (ret == -ESRCH) 122 122 ret = 0; ··· 144 144 NLM_F_ACK, session, cmd); 145 145 146 146 if (ret >= 0) { 147 - ret = genlmsg_multicast_allns(family, msg, 0, 0, GFP_ATOMIC); 147 + ret = genlmsg_multicast_allns(family, msg, 0, 0); 148 148 /* We don't care if no one is listening */ 149 149 if (ret == -ESRCH) 150 150 ret = 0;
+1
net/mptcp/mib.c
··· 17 17 SNMP_MIB_ITEM("MPCapableFallbackSYNACK", MPTCP_MIB_MPCAPABLEACTIVEFALLBACK), 18 18 SNMP_MIB_ITEM("MPCapableSYNTXDrop", MPTCP_MIB_MPCAPABLEACTIVEDROP), 19 19 SNMP_MIB_ITEM("MPCapableSYNTXDisabled", MPTCP_MIB_MPCAPABLEACTIVEDISABLED), 20 + SNMP_MIB_ITEM("MPCapableEndpAttempt", MPTCP_MIB_MPCAPABLEENDPATTEMPT), 20 21 SNMP_MIB_ITEM("MPFallbackTokenInit", MPTCP_MIB_TOKENFALLBACKINIT), 21 22 SNMP_MIB_ITEM("MPTCPRetrans", MPTCP_MIB_RETRANSSEGS), 22 23 SNMP_MIB_ITEM("MPJoinNoTokenFound", MPTCP_MIB_JOINNOTOKEN),
+1
net/mptcp/mib.h
··· 12 12 MPTCP_MIB_MPCAPABLEACTIVEFALLBACK, /* Client-side fallback during 3-way handshake */ 13 13 MPTCP_MIB_MPCAPABLEACTIVEDROP, /* Client-side fallback due to a MPC drop */ 14 14 MPTCP_MIB_MPCAPABLEACTIVEDISABLED, /* Client-side disabled due to past issues */ 15 + MPTCP_MIB_MPCAPABLEENDPATTEMPT, /* Prohibited MPC to port-based endp */ 15 16 MPTCP_MIB_TOKENFALLBACKINIT, /* Could not init/allocate token */ 16 17 MPTCP_MIB_RETRANSSEGS, /* Segments retransmitted at the MPTCP-level */ 17 18 MPTCP_MIB_JOINNOTOKEN, /* Received MP_JOIN but the token was not found */
+2 -1
net/mptcp/pm_netlink.c
··· 873 873 i, rm_id, id, remote_id, msk->mpc_endpoint_id); 874 874 spin_unlock_bh(&msk->pm.lock); 875 875 mptcp_subflow_shutdown(sk, ssk, how); 876 + removed |= subflow->request_join; 876 877 877 878 /* the following takes care of updating the subflows counter */ 878 879 mptcp_close_ssk(sk, ssk, subflow); 879 880 spin_lock_bh(&msk->pm.lock); 880 881 881 - removed |= subflow->request_join; 882 882 if (rm_type == MPTCP_MIB_RMSUBFLOW) 883 883 __MPTCP_INC_STATS(sock_net(sk), rm_type); 884 884 } ··· 1121 1121 */ 1122 1122 inet_sk_state_store(newsk, TCP_LISTEN); 1123 1123 lock_sock(ssk); 1124 + WRITE_ONCE(mptcp_subflow_ctx(ssk)->pm_listener, true); 1124 1125 err = __inet_listen_sk(ssk, backlog); 1125 1126 if (!err) 1126 1127 mptcp_event_pm_listener(ssk, MPTCP_EVENT_LISTENER_CREATED);
+1
net/mptcp/protocol.h
··· 535 535 __unused : 8; 536 536 bool data_avail; 537 537 bool scheduled; 538 + bool pm_listener; /* a listener managed by the kernel PM? */ 538 539 u32 remote_nonce; 539 540 u64 thmac; 540 541 u32 local_nonce;
+11
net/mptcp/subflow.c
··· 132 132 } 133 133 } 134 134 135 + static int subflow_reset_req_endp(struct request_sock *req, struct sk_buff *skb) 136 + { 137 + SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MPCAPABLEENDPATTEMPT); 138 + subflow_add_reset_reason(skb, MPTCP_RST_EPROHIBIT); 139 + return -EPERM; 140 + } 141 + 135 142 /* Init mptcp request socket. 136 143 * 137 144 * Returns an error code if a JOIN has failed and a TCP reset ··· 172 165 if (opt_mp_capable) { 173 166 SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MPCAPABLEPASSIVE); 174 167 168 + if (unlikely(listener->pm_listener)) 169 + return subflow_reset_req_endp(req, skb); 175 170 if (opt_mp_join) 176 171 return 0; 177 172 } else if (opt_mp_join) { ··· 181 172 182 173 if (mp_opt.backup) 183 174 SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINSYNBACKUPRX); 175 + } else if (unlikely(listener->pm_listener)) { 176 + return subflow_reset_req_endp(req, skb); 184 177 } 185 178 186 179 if (opt_mp_capable && listener->request_mptcp) {
+14 -14
net/netlink/genetlink.c
··· 1501 1501 if (IS_ERR(msg)) 1502 1502 return PTR_ERR(msg); 1503 1503 1504 - if (!family->netnsok) { 1504 + if (!family->netnsok) 1505 1505 genlmsg_multicast_netns(&genl_ctrl, &init_net, msg, 0, 1506 1506 0, GFP_KERNEL); 1507 - } else { 1508 - rcu_read_lock(); 1509 - genlmsg_multicast_allns(&genl_ctrl, msg, 0, 1510 - 0, GFP_ATOMIC); 1511 - rcu_read_unlock(); 1512 - } 1507 + else 1508 + genlmsg_multicast_allns(&genl_ctrl, msg, 0, 0); 1513 1509 1514 1510 return 0; 1515 1511 } ··· 1925 1929 1926 1930 core_initcall(genl_init); 1927 1931 1928 - static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group, 1929 - gfp_t flags) 1932 + static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group) 1930 1933 { 1931 1934 struct sk_buff *tmp; 1932 1935 struct net *net, *prev = NULL; 1933 1936 bool delivered = false; 1934 1937 int err; 1935 1938 1939 + rcu_read_lock(); 1936 1940 for_each_net_rcu(net) { 1937 1941 if (prev) { 1938 - tmp = skb_clone(skb, flags); 1942 + tmp = skb_clone(skb, GFP_ATOMIC); 1939 1943 if (!tmp) { 1940 1944 err = -ENOMEM; 1941 1945 goto error; 1942 1946 } 1943 1947 err = nlmsg_multicast(prev->genl_sock, tmp, 1944 - portid, group, flags); 1948 + portid, group, GFP_ATOMIC); 1945 1949 if (!err) 1946 1950 delivered = true; 1947 1951 else if (err != -ESRCH) ··· 1950 1954 1951 1955 prev = net; 1952 1956 } 1957 + err = nlmsg_multicast(prev->genl_sock, skb, portid, group, GFP_ATOMIC); 1953 1958 1954 - err = nlmsg_multicast(prev->genl_sock, skb, portid, group, flags); 1959 + rcu_read_unlock(); 1960 + 1955 1961 if (!err) 1956 1962 delivered = true; 1957 1963 else if (err != -ESRCH) 1958 1964 return err; 1959 1965 return delivered ? 0 : -ESRCH; 1960 1966 error: 1967 + rcu_read_unlock(); 1968 + 1961 1969 kfree_skb(skb); 1962 1970 return err; 1963 1971 } 1964 1972 1965 1973 int genlmsg_multicast_allns(const struct genl_family *family, 1966 1974 struct sk_buff *skb, u32 portid, 1967 - unsigned int group, gfp_t flags) 1975 + unsigned int group) 1968 1976 { 1969 1977 if (WARN_ON_ONCE(group >= family->n_mcgrps)) 1970 1978 return -EINVAL; 1971 1979 1972 1980 group = family->mcgrp_offset + group; 1973 - return genlmsg_mcast(skb, portid, group, flags); 1981 + return genlmsg_mcast(skb, portid, group); 1974 1982 } 1975 1983 EXPORT_SYMBOL(genlmsg_multicast_allns); 1976 1984
+1 -1
net/smc/smc_pnet.c
··· 753 753 754 754 write_lock(&sn->pnetids_ndev.lock); 755 755 list_for_each_entry(pi, &sn->pnetids_ndev.list, list) { 756 - if (smc_pnet_match(pnetid, pe->pnetid)) { 756 + if (smc_pnet_match(pnetid, pi->pnetid)) { 757 757 refcount_inc(&pi->refcnt); 758 758 kfree(pe); 759 759 goto unlock;
+5 -1
net/smc/smc_wr.c
··· 648 648 smc_wr_tx_wait_no_pending_sends(lnk); 649 649 percpu_ref_kill(&lnk->wr_reg_refs); 650 650 wait_for_completion(&lnk->reg_ref_comp); 651 + percpu_ref_exit(&lnk->wr_reg_refs); 651 652 percpu_ref_kill(&lnk->wr_tx_refs); 652 653 wait_for_completion(&lnk->tx_ref_comp); 654 + percpu_ref_exit(&lnk->wr_tx_refs); 653 655 654 656 if (lnk->wr_rx_dma_addr) { 655 657 ib_dma_unmap_single(ibdev, lnk->wr_rx_dma_addr, ··· 914 912 init_waitqueue_head(&lnk->wr_reg_wait); 915 913 rc = percpu_ref_init(&lnk->wr_reg_refs, smcr_wr_reg_refs_free, 0, GFP_KERNEL); 916 914 if (rc) 917 - goto dma_unmap; 915 + goto cancel_ref; 918 916 init_completion(&lnk->reg_ref_comp); 919 917 init_waitqueue_head(&lnk->wr_rx_empty_wait); 920 918 return rc; 921 919 920 + cancel_ref: 921 + percpu_ref_exit(&lnk->wr_tx_refs); 922 922 dma_unmap: 923 923 if (lnk->wr_rx_v2_dma_addr) { 924 924 ib_dma_unmap_single(ibdev, lnk->wr_rx_v2_dma_addr,
+4 -7
net/sunrpc/svc.c
··· 1321 1321 svc_process_common(struct svc_rqst *rqstp) 1322 1322 { 1323 1323 struct xdr_stream *xdr = &rqstp->rq_res_stream; 1324 - struct svc_program *progp; 1324 + struct svc_program *progp = NULL; 1325 1325 const struct svc_procedure *procp = NULL; 1326 1326 struct svc_serv *serv = rqstp->rq_server; 1327 1327 struct svc_process_info process; ··· 1351 1351 rqstp->rq_vers = be32_to_cpup(p++); 1352 1352 rqstp->rq_proc = be32_to_cpup(p); 1353 1353 1354 - for (pr = 0; pr < serv->sv_nprogs; pr++) { 1355 - progp = &serv->sv_programs[pr]; 1356 - 1357 - if (rqstp->rq_prog == progp->pg_prog) 1358 - break; 1359 - } 1354 + for (pr = 0; pr < serv->sv_nprogs; pr++) 1355 + if (rqstp->rq_prog == serv->sv_programs[pr].pg_prog) 1356 + progp = &serv->sv_programs[pr]; 1360 1357 1361 1358 /* 1362 1359 * Decode auth data, and add verifier to reply buffer.
+2 -6
net/wireless/nl80211.c
··· 17986 17986 17987 17987 genlmsg_end(msg, hdr); 17988 17988 17989 - rcu_read_lock(); 17990 17989 genlmsg_multicast_allns(&nl80211_fam, msg, 0, 17991 - NL80211_MCGRP_REGULATORY, GFP_ATOMIC); 17992 - rcu_read_unlock(); 17990 + NL80211_MCGRP_REGULATORY); 17993 17991 17994 17992 return; 17995 17993 ··· 18720 18722 18721 18723 genlmsg_end(msg, hdr); 18722 18724 18723 - rcu_read_lock(); 18724 18725 genlmsg_multicast_allns(&nl80211_fam, msg, 0, 18725 - NL80211_MCGRP_REGULATORY, GFP_ATOMIC); 18726 - rcu_read_unlock(); 18726 + NL80211_MCGRP_REGULATORY); 18727 18727 18728 18728 return; 18729 18729
+3 -12
rust/kernel/device.rs
··· 51 51 /// 52 52 /// It must also be ensured that `bindings::device::release` can be called from any thread. 53 53 /// While not officially documented, this should be the case for any `struct device`. 54 - pub unsafe fn from_raw(ptr: *mut bindings::device) -> ARef<Self> { 55 - // SAFETY: By the safety requirements, ptr is valid. 56 - // Initially increase the reference count by one to compensate for the final decrement once 57 - // this newly created `ARef<Device>` instance is dropped. 58 - unsafe { bindings::get_device(ptr) }; 59 - 60 - // CAST: `Self` is a `repr(transparent)` wrapper around `bindings::device`. 61 - let ptr = ptr.cast::<Self>(); 62 - 63 - // SAFETY: `ptr` is valid by the safety requirements of this function. By the above call to 64 - // `bindings::get_device` we also own a reference to the underlying `struct device`. 65 - unsafe { ARef::from_raw(ptr::NonNull::new_unchecked(ptr)) } 54 + pub unsafe fn get_device(ptr: *mut bindings::device) -> ARef<Self> { 55 + // SAFETY: By the safety requirements ptr is valid 56 + unsafe { Self::as_ref(ptr) }.into() 66 57 } 67 58 68 59 /// Obtain the raw `struct device *`.
+1 -1
rust/kernel/firmware.rs
··· 44 44 /// 45 45 /// # fn no_run() -> Result<(), Error> { 46 46 /// # // SAFETY: *NOT* safe, just for the example to get an `ARef<Device>` instance 47 - /// # let dev = unsafe { Device::from_raw(core::ptr::null_mut()) }; 47 + /// # let dev = unsafe { Device::get_device(core::ptr::null_mut()) }; 48 48 /// 49 49 /// let fw = Firmware::request(c_str!("path/to/firmware.bin"), &dev)?; 50 50 /// let blob = fw.data();
+5 -4
tools/testing/selftests/Makefile
··· 88 88 TARGETS += rseq 89 89 TARGETS += rtc 90 90 TARGETS += rust 91 + TARGETS += sched_ext 91 92 TARGETS += seccomp 92 93 TARGETS += sgx 93 94 TARGETS += sigaltstack ··· 130 129 endif 131 130 endif 132 131 133 - # User can optionally provide a TARGETS skiplist. By default we skip 134 - # BPF since it has cutting edge build time dependencies which require 135 - # more effort to install. 136 - SKIP_TARGETS ?= bpf 132 + # User can optionally provide a TARGETS skiplist. By default we skip 133 + # targets using BPF since it has cutting edge build time dependencies 134 + # which require more effort to install. 135 + SKIP_TARGETS ?= bpf sched_ext 137 136 ifneq ($(SKIP_TARGETS),) 138 137 TMP := $(filter-out $(SKIP_TARGETS), $(TARGETS)) 139 138 override TARGETS := $(TMP)
+31
tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0 3 + # description: ftrace - function profiler with function graph tracing 4 + # requires: function_profile_enabled set_ftrace_filter function_graph:tracer 5 + 6 + # The function graph tracer can now be run along side of the function 7 + # profiler. But there was a bug that caused the combination of the two 8 + # to crash. It also required the function graph tracer to be started 9 + # first. 10 + # 11 + # This test triggers that bug 12 + # 13 + # We need both function_graph and profiling to run this test 14 + 15 + fail() { # mesg 16 + echo $1 17 + exit_fail 18 + } 19 + 20 + echo "Enabling function graph tracer:" 21 + echo function_graph > current_tracer 22 + echo "enable profiler" 23 + 24 + # Older kernels do not allow function_profile to be enabled with 25 + # function graph tracer. If the below fails, mark it as unsupported 26 + echo 1 > function_profile_enabled || exit_unsupported 27 + 28 + # Let it run for a bit to make sure nothing explodes 29 + sleep 1 30 + 31 + exit 0
+1
tools/testing/selftests/net/lib/py/nsim.py
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 + import errno 3 4 import json 4 5 import os 5 6 import random
+86 -31
tools/testing/selftests/net/mptcp/mptcp_join.sh
··· 23 23 cout="" 24 24 err="" 25 25 capout="" 26 + cappid="" 26 27 ns1="" 27 28 ns2="" 28 29 iptables="iptables" ··· 888 887 fi 889 888 } 890 889 890 + cond_start_capture() 891 + { 892 + local ns="$1" 893 + 894 + :> "$capout" 895 + 896 + if $capture; then 897 + local capuser capfile 898 + if [ -z $SUDO_USER ]; then 899 + capuser="" 900 + else 901 + capuser="-Z $SUDO_USER" 902 + fi 903 + 904 + capfile=$(printf "mp_join-%02u-%s.pcap" "$MPTCP_LIB_TEST_COUNTER" "$ns") 905 + 906 + echo "Capturing traffic for test $MPTCP_LIB_TEST_COUNTER into $capfile" 907 + ip netns exec "$ns" tcpdump -i any -s 65535 -B 32768 $capuser -w "$capfile" > "$capout" 2>&1 & 908 + cappid=$! 909 + 910 + sleep 1 911 + fi 912 + } 913 + 914 + cond_stop_capture() 915 + { 916 + if $capture; then 917 + sleep 1 918 + kill $cappid 919 + cat "$capout" 920 + fi 921 + } 922 + 923 + get_port() 924 + { 925 + echo "$((10000 + MPTCP_LIB_TEST_COUNTER - 1))" 926 + } 927 + 891 928 do_transfer() 892 929 { 893 930 local listener_ns="$1" ··· 933 894 local cl_proto="$3" 934 895 local srv_proto="$4" 935 896 local connect_addr="$5" 897 + local port 936 898 937 - local port=$((10000 + MPTCP_LIB_TEST_COUNTER - 1)) 938 - local cappid 939 899 local FAILING_LINKS=${FAILING_LINKS:-""} 940 900 local fastclose=${fastclose:-""} 941 901 local speed=${speed:-"fast"} 902 + port=$(get_port) 942 903 943 904 :> "$cout" 944 905 :> "$sout" 945 - :> "$capout" 946 906 947 - if $capture; then 948 - local capuser 949 - if [ -z $SUDO_USER ] ; then 950 - capuser="" 951 - else 952 - capuser="-Z $SUDO_USER" 953 - fi 954 - 955 - capfile=$(printf "mp_join-%02u-%s.pcap" "$MPTCP_LIB_TEST_COUNTER" "${listener_ns}") 956 - 957 - echo "Capturing traffic for test $MPTCP_LIB_TEST_COUNTER into $capfile" 958 - ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & 959 - cappid=$! 960 - 961 - sleep 1 962 - fi 907 + cond_start_capture ${listener_ns} 963 908 964 909 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 965 910 nstat -n ··· 1030 1007 wait $spid 1031 1008 local rets=$? 1032 1009 1033 - if $capture; then 1034 - sleep 1 1035 - kill $cappid 1036 - fi 1010 + cond_stop_capture 1037 1011 1038 1012 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ 1039 1013 nstat | grep Tcp > /tmp/${listener_ns}.out ··· 1046 1026 ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port" 1047 1027 cat /tmp/${connector_ns}.out 1048 1028 1049 - cat "$capout" 1050 1029 return 1 1051 1030 fi 1052 1031 ··· 1062 1043 fi 1063 1044 rets=$? 1064 1045 1065 - if [ $retc -eq 0 ] && [ $rets -eq 0 ];then 1066 - cat "$capout" 1067 - return 0 1068 - fi 1069 - 1070 - cat "$capout" 1071 - return 1 1046 + [ $retc -eq 0 ] && [ $rets -eq 0 ] 1072 1047 } 1073 1048 1074 1049 make_file() ··· 2886 2873 fail_test 2887 2874 } 2888 2875 2876 + chk_mpc_endp_attempt() 2877 + { 2878 + local retl=$1 2879 + local attempts=$2 2880 + 2881 + print_check "Connect" 2882 + 2883 + if [ ${retl} = 124 ]; then 2884 + fail_test "timeout on connect" 2885 + elif [ ${retl} = 0 ]; then 2886 + fail_test "unexpected successful connect" 2887 + else 2888 + print_ok 2889 + 2890 + print_check "Attempts" 2891 + count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPCapableEndpAttempt") 2892 + if [ -z "$count" ]; then 2893 + print_skip 2894 + elif [ "$count" != "$attempts" ]; then 2895 + fail_test "got ${count} MPC attempt[s] on port-based endpoint, expected ${attempts}" 2896 + else 2897 + print_ok 2898 + fi 2899 + fi 2900 + } 2901 + 2889 2902 add_addr_ports_tests() 2890 2903 { 2891 2904 # signal address with port ··· 3001 2962 run_tests $ns1 $ns2 10.0.1.1 3002 2963 chk_join_nr 2 2 2 3003 2964 chk_add_nr 2 2 2 2965 + fi 2966 + 2967 + if reset "port-based signal endpoint must not accept mpc"; then 2968 + local port retl count 2969 + port=$(get_port) 2970 + 2971 + cond_start_capture ${ns1} 2972 + pm_nl_add_endpoint ${ns1} 10.0.2.1 flags signal port ${port} 2973 + mptcp_lib_wait_local_port_listen ${ns1} ${port} 2974 + 2975 + timeout 1 ip netns exec ${ns2} \ 2976 + ./mptcp_connect -t ${timeout_poll} -p $port -s MPTCP 10.0.2.1 >/dev/null 2>&1 2977 + retl=$? 2978 + cond_stop_capture 2979 + 2980 + chk_mpc_endp_attempt ${retl} 1 3004 2981 fi 3005 2982 } 3006 2983
+4 -1
tools/testing/selftests/net/rds/test.py
··· 14 14 import atexit 15 15 from pwd import getpwuid 16 16 from os import stat 17 - from lib.py import ip 18 17 18 + # Allow utils module to be imported from different directory 19 + this_dir = os.path.dirname(os.path.realpath(__file__)) 20 + sys.path.append(os.path.join(this_dir, "../")) 21 + from lib.py.utils import ip 19 22 20 23 libc = ctypes.cdll.LoadLibrary('libc.so.6') 21 24 setns = libc.setns
+75 -35
tools/testing/selftests/rseq/rseq.c
··· 60 60 /* Flags used during rseq registration. */ 61 61 unsigned int rseq_flags; 62 62 63 - /* 64 - * rseq feature size supported by the kernel. 0 if the registration was 65 - * unsuccessful. 66 - */ 67 - unsigned int rseq_feature_size = -1U; 68 - 69 63 static int rseq_ownership; 70 64 static int rseq_reg_success; /* At least one rseq registration has succeded. */ 71 65 ··· 105 111 } 106 112 } 107 113 114 + /* The rseq areas need to be at least 32 bytes. */ 115 + static 116 + unsigned int get_rseq_min_alloc_size(void) 117 + { 118 + unsigned int alloc_size = rseq_size; 119 + 120 + if (alloc_size < ORIG_RSEQ_ALLOC_SIZE) 121 + alloc_size = ORIG_RSEQ_ALLOC_SIZE; 122 + return alloc_size; 123 + } 124 + 125 + /* 126 + * Return the feature size supported by the kernel. 127 + * 128 + * Depending on the value returned by getauxval(AT_RSEQ_FEATURE_SIZE): 129 + * 130 + * 0: Return ORIG_RSEQ_FEATURE_SIZE (20) 131 + * > 0: Return the value from getauxval(AT_RSEQ_FEATURE_SIZE). 132 + * 133 + * It should never return a value below ORIG_RSEQ_FEATURE_SIZE. 134 + */ 135 + static 136 + unsigned int get_rseq_kernel_feature_size(void) 137 + { 138 + unsigned long auxv_rseq_feature_size, auxv_rseq_align; 139 + 140 + auxv_rseq_align = getauxval(AT_RSEQ_ALIGN); 141 + assert(!auxv_rseq_align || auxv_rseq_align <= RSEQ_THREAD_AREA_ALLOC_SIZE); 142 + 143 + auxv_rseq_feature_size = getauxval(AT_RSEQ_FEATURE_SIZE); 144 + assert(!auxv_rseq_feature_size || auxv_rseq_feature_size <= RSEQ_THREAD_AREA_ALLOC_SIZE); 145 + if (auxv_rseq_feature_size) 146 + return auxv_rseq_feature_size; 147 + else 148 + return ORIG_RSEQ_FEATURE_SIZE; 149 + } 150 + 108 151 int rseq_register_current_thread(void) 109 152 { 110 153 int rc; ··· 150 119 /* Treat libc's ownership as a successful registration. */ 151 120 return 0; 152 121 } 153 - rc = sys_rseq(&__rseq_abi, rseq_size, 0, RSEQ_SIG); 122 + rc = sys_rseq(&__rseq_abi, get_rseq_min_alloc_size(), 0, RSEQ_SIG); 154 123 if (rc) { 155 124 if (RSEQ_READ_ONCE(rseq_reg_success)) { 156 125 /* Incoherent success/failure within process. */ ··· 171 140 /* Treat libc's ownership as a successful unregistration. */ 172 141 return 0; 173 142 } 174 - rc = sys_rseq(&__rseq_abi, rseq_size, RSEQ_ABI_FLAG_UNREGISTER, RSEQ_SIG); 143 + rc = sys_rseq(&__rseq_abi, get_rseq_min_alloc_size(), RSEQ_ABI_FLAG_UNREGISTER, RSEQ_SIG); 175 144 if (rc) 176 145 return -1; 177 146 return 0; 178 - } 179 - 180 - static 181 - unsigned int get_rseq_feature_size(void) 182 - { 183 - unsigned long auxv_rseq_feature_size, auxv_rseq_align; 184 - 185 - auxv_rseq_align = getauxval(AT_RSEQ_ALIGN); 186 - assert(!auxv_rseq_align || auxv_rseq_align <= RSEQ_THREAD_AREA_ALLOC_SIZE); 187 - 188 - auxv_rseq_feature_size = getauxval(AT_RSEQ_FEATURE_SIZE); 189 - assert(!auxv_rseq_feature_size || auxv_rseq_feature_size <= RSEQ_THREAD_AREA_ALLOC_SIZE); 190 - if (auxv_rseq_feature_size) 191 - return auxv_rseq_feature_size; 192 - else 193 - return ORIG_RSEQ_FEATURE_SIZE; 194 147 } 195 148 196 149 static __attribute__((constructor)) ··· 193 178 } 194 179 if (libc_rseq_size_p && libc_rseq_offset_p && libc_rseq_flags_p && 195 180 *libc_rseq_size_p != 0) { 181 + unsigned int libc_rseq_size; 182 + 196 183 /* rseq registration owned by glibc */ 197 184 rseq_offset = *libc_rseq_offset_p; 198 - rseq_size = *libc_rseq_size_p; 185 + libc_rseq_size = *libc_rseq_size_p; 199 186 rseq_flags = *libc_rseq_flags_p; 200 - rseq_feature_size = get_rseq_feature_size(); 201 - if (rseq_feature_size > rseq_size) 202 - rseq_feature_size = rseq_size; 187 + 188 + /* 189 + * Previous versions of glibc expose the value 190 + * 32 even though the kernel only supported 20 191 + * bytes initially. Therefore treat 32 as a 192 + * special-case. glibc 2.40 exposes a 20 bytes 193 + * __rseq_size without using getauxval(3) to 194 + * query the supported size, while still allocating a 32 195 + * bytes area. Also treat 20 as a special-case. 196 + * 197 + * Special-cases are handled by using the following 198 + * value as active feature set size: 199 + * 200 + * rseq_size = min(32, get_rseq_kernel_feature_size()) 201 + */ 202 + switch (libc_rseq_size) { 203 + case ORIG_RSEQ_FEATURE_SIZE: 204 + fallthrough; 205 + case ORIG_RSEQ_ALLOC_SIZE: 206 + { 207 + unsigned int rseq_kernel_feature_size = get_rseq_kernel_feature_size(); 208 + 209 + if (rseq_kernel_feature_size < ORIG_RSEQ_ALLOC_SIZE) 210 + rseq_size = rseq_kernel_feature_size; 211 + else 212 + rseq_size = ORIG_RSEQ_ALLOC_SIZE; 213 + break; 214 + } 215 + default: 216 + /* Otherwise just use the __rseq_size from libc as rseq_size. */ 217 + rseq_size = libc_rseq_size; 218 + break; 219 + } 203 220 return; 204 221 } 205 222 rseq_ownership = 1; 206 223 if (!rseq_available()) { 207 224 rseq_size = 0; 208 - rseq_feature_size = 0; 209 225 return; 210 226 } 211 227 rseq_offset = (void *)&__rseq_abi - rseq_thread_pointer(); 212 228 rseq_flags = 0; 213 - rseq_feature_size = get_rseq_feature_size(); 214 - if (rseq_feature_size == ORIG_RSEQ_FEATURE_SIZE) 215 - rseq_size = ORIG_RSEQ_ALLOC_SIZE; 216 - else 217 - rseq_size = RSEQ_THREAD_AREA_ALLOC_SIZE; 218 229 } 219 230 220 231 static __attribute__((destructor)) ··· 250 209 return; 251 210 rseq_offset = 0; 252 211 rseq_size = -1U; 253 - rseq_feature_size = -1U; 254 212 rseq_ownership = 0; 255 213 } 256 214
+2 -8
tools/testing/selftests/rseq/rseq.h
··· 68 68 /* Flags used during rseq registration. */ 69 69 extern unsigned int rseq_flags; 70 70 71 - /* 72 - * rseq feature size supported by the kernel. 0 if the registration was 73 - * unsuccessful. 74 - */ 75 - extern unsigned int rseq_feature_size; 76 - 77 71 enum rseq_mo { 78 72 RSEQ_MO_RELAXED = 0, 79 73 RSEQ_MO_CONSUME = 1, /* Unused */ ··· 187 193 188 194 static inline bool rseq_node_id_available(void) 189 195 { 190 - return (int) rseq_feature_size >= rseq_offsetofend(struct rseq_abi, node_id); 196 + return (int) rseq_size >= rseq_offsetofend(struct rseq_abi, node_id); 191 197 } 192 198 193 199 /* ··· 201 207 202 208 static inline bool rseq_mm_cid_available(void) 203 209 { 204 - return (int) rseq_feature_size >= rseq_offsetofend(struct rseq_abi, mm_cid); 210 + return (int) rseq_size >= rseq_offsetofend(struct rseq_abi, mm_cid); 205 211 } 206 212 207 213 static inline uint32_t rseq_current_mm_cid(void)
+33 -40
tools/testing/selftests/sched_ext/Makefile
··· 3 3 include ../../../build/Build.include 4 4 include ../../../scripts/Makefile.arch 5 5 include ../../../scripts/Makefile.include 6 + 7 + TEST_GEN_PROGS := runner 8 + 9 + # override lib.mk's default rules 10 + OVERRIDE_TARGETS := 1 6 11 include ../lib.mk 7 - 8 - ifneq ($(LLVM),) 9 - ifneq ($(filter %/,$(LLVM)),) 10 - LLVM_PREFIX := $(LLVM) 11 - else ifneq ($(filter -%,$(LLVM)),) 12 - LLVM_SUFFIX := $(LLVM) 13 - endif 14 - 15 - CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as 16 - else 17 - CC := gcc 18 - endif # LLVM 19 - 20 - ifneq ($(CROSS_COMPILE),) 21 - $(error CROSS_COMPILE not supported for scx selftests) 22 - endif # CROSS_COMPILE 23 12 24 13 CURDIR := $(abspath .) 25 14 REPOROOT := $(abspath ../../../..) ··· 23 34 SCXTOOLSDIR := $(TOOLSDIR)/sched_ext 24 35 SCXTOOLSINCDIR := $(TOOLSDIR)/sched_ext/include 25 36 26 - OUTPUT_DIR := $(CURDIR)/build 37 + OUTPUT_DIR := $(OUTPUT)/build 27 38 OBJ_DIR := $(OUTPUT_DIR)/obj 28 39 INCLUDE_DIR := $(OUTPUT_DIR)/include 29 40 BPFOBJ_DIR := $(OBJ_DIR)/libbpf 30 41 SCXOBJ_DIR := $(OBJ_DIR)/sched_ext 31 42 BPFOBJ := $(BPFOBJ_DIR)/libbpf.a 32 43 LIBBPF_OUTPUT := $(OBJ_DIR)/libbpf/libbpf.a 33 - DEFAULT_BPFTOOL := $(OUTPUT_DIR)/sbin/bpftool 34 - HOST_BUILD_DIR := $(OBJ_DIR) 35 - HOST_OUTPUT_DIR := $(OUTPUT_DIR) 36 44 37 - VMLINUX_BTF_PATHS ?= ../../../../vmlinux \ 45 + DEFAULT_BPFTOOL := $(OUTPUT_DIR)/host/sbin/bpftool 46 + HOST_OBJ_DIR := $(OBJ_DIR)/host/bpftool 47 + HOST_LIBBPF_OUTPUT := $(OBJ_DIR)/host/libbpf/ 48 + HOST_LIBBPF_DESTDIR := $(OUTPUT_DIR)/host/ 49 + HOST_DESTDIR := $(OUTPUT_DIR)/host/ 50 + 51 + VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \ 52 + $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ 53 + ../../../../vmlinux \ 38 54 /sys/kernel/btf/vmlinux \ 39 55 /boot/vmlinux-$(shell uname -r) 40 56 VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS)))) ··· 74 80 # Use '-idirafter': Don't interfere with include mechanics except where the 75 81 # build would have failed anyways. 76 82 define get_sys_includes 77 - $(shell $(1) -v -E - </dev/null 2>&1 \ 83 + $(shell $(1) $(2) -v -E - </dev/null 2>&1 \ 78 84 | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ 79 - $(shell $(1) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') 85 + $(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') 80 86 endef 87 + 88 + ifneq ($(CROSS_COMPILE),) 89 + CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%)) 90 + endif 91 + 92 + CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) 81 93 82 94 BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH) \ 83 95 $(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian) \ 84 96 -I$(CURDIR)/include -I$(CURDIR)/include/bpf-compat \ 85 97 -I$(INCLUDE_DIR) -I$(APIDIR) -I$(SCXTOOLSINCDIR) \ 86 98 -I$(REPOROOT)/include \ 87 - $(call get_sys_includes,$(CLANG)) \ 99 + $(CLANG_SYS_INCLUDES) \ 88 100 -Wall -Wno-compare-distinct-pointer-types \ 89 101 -Wno-incompatible-function-pointer-types \ 90 102 -O2 -mcpu=v3 ··· 98 98 # sort removes libbpf duplicates when not cross-building 99 99 MAKE_DIRS := $(sort $(OBJ_DIR)/libbpf $(OBJ_DIR)/libbpf \ 100 100 $(OBJ_DIR)/bpftool $(OBJ_DIR)/resolve_btfids \ 101 - $(INCLUDE_DIR) $(SCXOBJ_DIR)) 101 + $(HOST_OBJ_DIR) $(INCLUDE_DIR) $(SCXOBJ_DIR)) 102 102 103 103 $(MAKE_DIRS): 104 104 $(call msg,MKDIR,,$@) ··· 108 108 $(APIDIR)/linux/bpf.h \ 109 109 | $(OBJ_DIR)/libbpf 110 110 $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(OBJ_DIR)/libbpf/ \ 111 + ARCH=$(ARCH) CC="$(CC)" CROSS_COMPILE=$(CROSS_COMPILE) \ 111 112 EXTRA_CFLAGS='-g -O0 -fPIC' \ 112 113 DESTDIR=$(OUTPUT_DIR) prefix= all install_headers 113 114 114 115 $(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \ 115 - $(LIBBPF_OUTPUT) | $(OBJ_DIR)/bpftool 116 + $(LIBBPF_OUTPUT) | $(HOST_OBJ_DIR) 116 117 $(Q)$(MAKE) $(submake_extras) -C $(BPFTOOLDIR) \ 117 118 ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) \ 118 119 EXTRA_CFLAGS='-g -O0' \ 119 - OUTPUT=$(OBJ_DIR)/bpftool/ \ 120 - LIBBPF_OUTPUT=$(OBJ_DIR)/libbpf/ \ 121 - LIBBPF_DESTDIR=$(OUTPUT_DIR)/ \ 122 - prefix= DESTDIR=$(OUTPUT_DIR)/ install-bin 120 + OUTPUT=$(HOST_OBJ_DIR)/ \ 121 + LIBBPF_OUTPUT=$(HOST_LIBBPF_OUTPUT) \ 122 + LIBBPF_DESTDIR=$(HOST_LIBBPF_DESTDIR) \ 123 + prefix= DESTDIR=$(HOST_DESTDIR) install-bin 123 124 124 125 $(INCLUDE_DIR)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) | $(INCLUDE_DIR) 125 126 ifeq ($(VMLINUX_H),) ··· 151 150 152 151 override define CLEAN 153 152 rm -rf $(OUTPUT_DIR) 154 - rm -f *.o *.bpf.o *.bpf.skel.h *.bpf.subskel.h 155 153 rm -f $(TEST_GEN_PROGS) 156 - rm -f runner 157 154 endef 158 155 159 156 # Every testcase takes all of the BPF progs are dependencies by default. This ··· 195 196 # function doesn't support using implicit rules otherwise. 196 197 $(testcase-targets): $(SCXOBJ_DIR)/%.o: %.c $(SCXOBJ_DIR)/runner.o $(all_test_bpfprogs) | $(SCXOBJ_DIR) 197 198 $(eval test=$(patsubst %.o,%.c,$(notdir $@))) 198 - $(CC) $(CFLAGS) -c $< -o $@ $(SCXOBJ_DIR)/runner.o 199 + $(CC) $(CFLAGS) -c $< -o $@ 199 200 200 201 $(SCXOBJ_DIR)/util.o: util.c | $(SCXOBJ_DIR) 201 202 $(CC) $(CFLAGS) -c $< -o $@ 202 203 203 - runner: $(SCXOBJ_DIR)/runner.o $(SCXOBJ_DIR)/util.o $(BPFOBJ) $(testcase-targets) 204 + $(OUTPUT)/runner: $(SCXOBJ_DIR)/runner.o $(SCXOBJ_DIR)/util.o $(BPFOBJ) $(testcase-targets) 204 205 @echo "$(testcase-targets)" 205 206 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) 206 - 207 - TEST_GEN_PROGS := runner 208 - 209 - all: runner 210 - 211 - .PHONY: all clean help 212 207 213 208 .DEFAULT_GOAL := all 214 209
+2 -4
tools/testing/selftests/vDSO/Makefile
··· 9 9 TEST_GEN_PROGS += vdso_standalone_test_x86 10 10 endif 11 11 TEST_GEN_PROGS += vdso_test_correctness 12 - ifeq ($(ARCH)$(CONFIG_X86_32),$(filter $(ARCH)$(CONFIG_X86_32),x86 x86_64 loongarch arm64 powerpc s390)) 13 12 TEST_GEN_PROGS += vdso_test_getrandom 14 13 TEST_GEN_PROGS += vdso_test_chacha 15 - endif 16 14 17 15 CFLAGS := -std=gnu99 -O2 18 16 ··· 35 37 $(KHDR_INCLUDES) \ 36 38 -isystem $(top_srcdir)/include/uapi 37 39 38 - $(OUTPUT)/vdso_test_chacha: $(top_srcdir)/tools/arch/$(SRCARCH)/vdso/vgetrandom-chacha.S 40 + $(OUTPUT)/vdso_test_chacha: vgetrandom-chacha.S 39 41 $(OUTPUT)/vdso_test_chacha: CFLAGS += -idirafter $(top_srcdir)/tools/include \ 40 42 -idirafter $(top_srcdir)/tools/include/generated \ 41 43 -idirafter $(top_srcdir)/arch/$(SRCARCH)/include \ 42 44 -idirafter $(top_srcdir)/include \ 43 - -D__ASSEMBLY__ -Wa,--noexecstack 45 + -Wa,--noexecstack
+21 -15
tools/testing/selftests/vDSO/vdso_test_chacha.c
··· 3 3 * Copyright (C) 2022-2024 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. 4 4 */ 5 5 6 + #include <linux/compiler.h> 6 7 #include <tools/le_byteshift.h> 7 8 #include <sys/random.h> 8 9 #include <sys/auxv.h> ··· 74 73 counter[1] = s[13]; 75 74 } 76 75 77 - typedef uint8_t u8; 78 - typedef uint32_t u32; 79 - typedef uint64_t u64; 80 - #include <vdso/getrandom.h> 76 + void __weak __arch_chacha20_blocks_nostack(uint8_t *dst_bytes, const uint32_t *key, uint32_t *counter, size_t nblocks) 77 + { 78 + ksft_exit_skip("Not implemented on architecture\n"); 79 + } 81 80 82 81 int main(int argc, char *argv[]) 83 82 { ··· 91 90 ksft_set_plan(1); 92 91 93 92 for (unsigned int trial = 0; trial < TRIALS; ++trial) { 94 - if (getrandom(key, sizeof(key), 0) != sizeof(key)) { 95 - printf("getrandom() failed!\n"); 96 - return KSFT_SKIP; 97 - } 93 + if (getrandom(key, sizeof(key), 0) != sizeof(key)) 94 + ksft_exit_skip("getrandom() failed unexpectedly\n"); 98 95 memset(counter1, 0, sizeof(counter1)); 99 96 reference_chacha20_blocks(output1, key, counter1, BLOCKS); 100 97 for (unsigned int split = 0; split < BLOCKS; ++split) { ··· 101 102 if (split) 102 103 __arch_chacha20_blocks_nostack(output2, key, counter2, split); 103 104 __arch_chacha20_blocks_nostack(output2 + split * BLOCK_SIZE, key, counter2, BLOCKS - split); 104 - if (memcmp(output1, output2, sizeof(output1)) || memcmp(counter1, counter2, sizeof(counter1))) 105 - return KSFT_FAIL; 105 + if (memcmp(output1, output2, sizeof(output1))) 106 + ksft_exit_fail_msg("Main loop outputs do not match on trial %u, split %u\n", trial, split); 107 + if (memcmp(counter1, counter2, sizeof(counter1))) 108 + ksft_exit_fail_msg("Main loop counters do not match on trial %u, split %u\n", trial, split); 106 109 } 107 110 } 108 111 memset(counter1, 0, sizeof(counter1)); ··· 114 113 115 114 reference_chacha20_blocks(output1, key, counter1, BLOCKS); 116 115 __arch_chacha20_blocks_nostack(output2, key, counter2, BLOCKS); 117 - if (memcmp(output1, output2, sizeof(output1)) || memcmp(counter1, counter2, sizeof(counter1))) 118 - return KSFT_FAIL; 116 + if (memcmp(output1, output2, sizeof(output1))) 117 + ksft_exit_fail_msg("Block limit outputs do not match after first round\n"); 118 + if (memcmp(counter1, counter2, sizeof(counter1))) 119 + ksft_exit_fail_msg("Block limit counters do not match after first round\n"); 119 120 120 121 reference_chacha20_blocks(output1, key, counter1, BLOCKS); 121 122 __arch_chacha20_blocks_nostack(output2, key, counter2, BLOCKS); 122 - if (memcmp(output1, output2, sizeof(output1)) || memcmp(counter1, counter2, sizeof(counter1))) 123 - return KSFT_FAIL; 123 + if (memcmp(output1, output2, sizeof(output1))) 124 + ksft_exit_fail_msg("Block limit outputs do not match after second round\n"); 125 + if (memcmp(counter1, counter2, sizeof(counter1))) 126 + ksft_exit_fail_msg("Block limit counters do not match after second round\n"); 124 127 125 128 ksft_test_result_pass("chacha: PASS\n"); 126 - return KSFT_PASS; 129 + ksft_exit_pass(); 130 + return 0; 127 131 }
+34 -42
tools/testing/selftests/vDSO/vdso_test_getrandom.c
··· 11 11 #include <string.h> 12 12 #include <time.h> 13 13 #include <unistd.h> 14 + #include <sched.h> 14 15 #include <signal.h> 15 16 #include <sys/auxv.h> 16 17 #include <sys/mman.h> ··· 40 39 } \ 41 40 } while (0) 42 41 #endif 42 + 43 + #define ksft_assert(condition) \ 44 + do { if (!(condition)) ksft_exit_fail_msg("Assertion failed: %s\n", #condition); } while (0) 43 45 44 46 static struct { 45 47 pthread_mutex_t lock; ··· 115 111 const char *version = versions[VDSO_VERSION]; 116 112 const char *name = names[VDSO_NAMES][6]; 117 113 unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); 118 - size_t ret; 114 + ssize_t ret; 119 115 120 - if (!sysinfo_ehdr) { 121 - printf("AT_SYSINFO_EHDR is not present!\n"); 122 - exit(KSFT_SKIP); 123 - } 116 + if (!sysinfo_ehdr) 117 + ksft_exit_skip("AT_SYSINFO_EHDR is not present\n"); 124 118 vdso_init_from_sysinfo_ehdr(sysinfo_ehdr); 125 119 vgrnd.fn = (__typeof__(vgrnd.fn))vdso_sym(version, name); 126 - if (!vgrnd.fn) { 127 - printf("%s is missing!\n", name); 128 - exit(KSFT_FAIL); 129 - } 120 + if (!vgrnd.fn) 121 + ksft_exit_skip("%s@%s symbol is missing from vDSO\n", name, version); 130 122 ret = VDSO_CALL(vgrnd.fn, 5, NULL, 0, 0, &vgrnd.params, ~0UL); 131 - if (ret == -ENOSYS) { 132 - printf("unsupported architecture\n"); 133 - exit(KSFT_SKIP); 134 - } else if (ret) { 135 - printf("failed to fetch vgetrandom params!\n"); 136 - exit(KSFT_FAIL); 137 - } 123 + if (ret == -ENOSYS) 124 + ksft_exit_skip("CPU does not have runtime support\n"); 125 + else if (ret) 126 + ksft_exit_fail_msg("Failed to fetch vgetrandom params: %zd\n", ret); 138 127 } 139 128 140 129 static ssize_t vgetrandom(void *buf, size_t len, unsigned long flags) ··· 136 139 137 140 if (!state) { 138 141 state = vgetrandom_get_state(); 139 - if (!state) { 140 - printf("vgetrandom_get_state failed!\n"); 141 - exit(KSFT_FAIL); 142 - } 142 + ksft_assert(state); 143 143 } 144 144 return VDSO_CALL(vgrnd.fn, 5, buf, len, flags, state, vgrnd.params.size_of_opaque_state); 145 145 } ··· 148 154 for (size_t i = 0; i < TRIALS; ++i) { 149 155 unsigned int val; 150 156 ssize_t ret = vgetrandom(&val, sizeof(val), 0); 151 - assert(ret == sizeof(val)); 157 + ksft_assert(ret == sizeof(val)); 152 158 } 153 159 return NULL; 154 160 } ··· 158 164 for (size_t i = 0; i < TRIALS; ++i) { 159 165 unsigned int val; 160 166 ssize_t ret = getrandom(&val, sizeof(val), 0); 161 - assert(ret == sizeof(val)); 167 + ksft_assert(ret == sizeof(val)); 162 168 } 163 169 return NULL; 164 170 } ··· 168 174 for (size_t i = 0; i < TRIALS; ++i) { 169 175 unsigned int val; 170 176 ssize_t ret = syscall(__NR_getrandom, &val, sizeof(val), 0); 171 - assert(ret == sizeof(val)); 177 + ksft_assert(ret == sizeof(val)); 172 178 } 173 179 return NULL; 174 180 } ··· 203 209 204 210 clock_gettime(CLOCK_MONOTONIC, &start); 205 211 for (size_t i = 0; i < THREADS; ++i) 206 - assert(pthread_create(&threads[i], NULL, test_vdso_getrandom, NULL) == 0); 212 + ksft_assert(pthread_create(&threads[i], NULL, test_vdso_getrandom, NULL) == 0); 207 213 for (size_t i = 0; i < THREADS; ++i) 208 214 pthread_join(threads[i], NULL); 209 215 clock_gettime(CLOCK_MONOTONIC, &end); ··· 212 218 213 219 clock_gettime(CLOCK_MONOTONIC, &start); 214 220 for (size_t i = 0; i < THREADS; ++i) 215 - assert(pthread_create(&threads[i], NULL, test_libc_getrandom, NULL) == 0); 221 + ksft_assert(pthread_create(&threads[i], NULL, test_libc_getrandom, NULL) == 0); 216 222 for (size_t i = 0; i < THREADS; ++i) 217 223 pthread_join(threads[i], NULL); 218 224 clock_gettime(CLOCK_MONOTONIC, &end); ··· 221 227 222 228 clock_gettime(CLOCK_MONOTONIC, &start); 223 229 for (size_t i = 0; i < THREADS; ++i) 224 - assert(pthread_create(&threads[i], NULL, test_syscall_getrandom, NULL) == 0); 230 + ksft_assert(pthread_create(&threads[i], NULL, test_syscall_getrandom, NULL) == 0); 225 231 for (size_t i = 0; i < THREADS; ++i) 226 232 pthread_join(threads[i], NULL); 227 233 clock_gettime(CLOCK_MONOTONIC, &end); ··· 246 252 247 253 for (size_t i = 0; i < 1000; ++i) { 248 254 ssize_t ret = vgetrandom(weird_size, sizeof(weird_size), 0); 249 - if (ret != sizeof(weird_size)) 250 - exit(KSFT_FAIL); 255 + ksft_assert(ret == sizeof(weird_size)); 251 256 } 252 257 253 258 ksft_test_result_pass("getrandom: PASS\n"); 254 259 255 260 unshare(CLONE_NEWUSER); 256 - assert(unshare(CLONE_NEWTIME) == 0); 261 + ksft_assert(unshare(CLONE_NEWTIME) == 0); 257 262 child = fork(); 258 - assert(child >= 0); 263 + ksft_assert(child >= 0); 259 264 if (!child) { 260 265 vgetrandom_init(); 261 266 child = getpid(); 262 - assert(ptrace(PTRACE_TRACEME, 0, NULL, NULL) == 0); 263 - assert(kill(child, SIGSTOP) == 0); 264 - assert(vgetrandom(weird_size, sizeof(weird_size), 0) == sizeof(weird_size)); 267 + ksft_assert(ptrace(PTRACE_TRACEME, 0, NULL, NULL) == 0); 268 + ksft_assert(kill(child, SIGSTOP) == 0); 269 + ksft_assert(vgetrandom(weird_size, sizeof(weird_size), 0) == sizeof(weird_size)); 265 270 _exit(0); 266 271 } 267 272 for (;;) { 268 273 struct ptrace_syscall_info info = { 0 }; 269 274 int status, ret; 270 - assert(waitpid(child, &status, 0) >= 0); 275 + ksft_assert(waitpid(child, &status, 0) >= 0); 271 276 if (WIFEXITED(status)) { 272 - if (WEXITSTATUS(status) != 0) 273 - exit(KSFT_FAIL); 277 + ksft_assert(WEXITSTATUS(status) == 0); 274 278 break; 275 279 } 276 - assert(WIFSTOPPED(status)); 280 + ksft_assert(WIFSTOPPED(status)); 277 281 if (WSTOPSIG(status) == SIGSTOP) 278 - assert(ptrace(PTRACE_SETOPTIONS, child, 0, PTRACE_O_TRACESYSGOOD) == 0); 282 + ksft_assert(ptrace(PTRACE_SETOPTIONS, child, 0, PTRACE_O_TRACESYSGOOD) == 0); 279 283 else if (WSTOPSIG(status) == (SIGTRAP | 0x80)) { 280 - assert(ptrace(PTRACE_GET_SYSCALL_INFO, child, sizeof(info), &info) > 0); 284 + ksft_assert(ptrace(PTRACE_GET_SYSCALL_INFO, child, sizeof(info), &info) > 0); 281 285 if (info.op == PTRACE_SYSCALL_INFO_ENTRY && info.entry.nr == __NR_getrandom && 282 286 info.entry.args[0] == (uintptr_t)weird_size && info.entry.args[1] == sizeof(weird_size)) 283 - exit(KSFT_FAIL); 287 + ksft_exit_fail_msg("vgetrandom passed buffer to syscall getrandom unexpectedly\n"); 284 288 } 285 - assert(ptrace(PTRACE_SYSCALL, child, 0, 0) == 0); 289 + ksft_assert(ptrace(PTRACE_SYSCALL, child, 0, 0) == 0); 286 290 } 287 291 288 292 ksft_test_result_pass("getrandom timens: PASS\n"); 289 293 290 - exit(KSFT_PASS); 294 + ksft_exit_pass(); 291 295 } 292 296 293 297 static void usage(const char *argv0)
+18
tools/testing/selftests/vDSO/vgetrandom-chacha.S
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2024 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. 4 + */ 5 + 6 + #define __ASSEMBLY__ 7 + 8 + #if defined(__aarch64__) 9 + #include "../../../../arch/arm64/kernel/vdso/vgetrandom-chacha.S" 10 + #elif defined(__loongarch__) 11 + #include "../../../../arch/loongarch/vdso/vgetrandom-chacha.S" 12 + #elif defined(__powerpc__) || defined(__powerpc64__) 13 + #include "../../../../arch/powerpc/kernel/vdso/vgetrandom-chacha.S" 14 + #elif defined(__s390x__) 15 + #include "../../../../arch/s390/kernel/vdso64/vgetrandom-chacha.S" 16 + #elif defined(__x86_64__) 17 + #include "../../../../arch/x86/entry/vdso/vgetrandom-chacha.S" 18 + #endif