Unified · Split
| @@ -9,7 +9,7 @@ · 8 unmodified lines | ||
| 9 | 9 | Linus |
| 10 | 10 | ---------- |
| 11 | 11 | |
| 12 | −M: Matt Mackal | |
| 12 | +N: Matt Mackal | |
| 13 | 13 | E: mpm@selenic.com |
| 14 | 14 | D: SLOB slab allocator |
| 15 | 15 | |
| @@ -1910,7 +1910,7 @@ S: Ra'annana, Israel · 1894 unmodified lines | ||
| 1910 | 1910 | |
| 1911 | 1911 | N: Andi Kleen |
| 1912 | 1912 | E: andi@firstfloor.org |
| 1913 | −U: http://www.halobates.de | |
| 1913 | +W: http://www.halobates.de | |
| 1914 | 1914 | D: network, x86, NUMA, various hacks |
| 1915 | 1915 | S: Schwalbenstr. 96 |
| 1916 | 1916 | S: 85551 Ottobrunn |
| @@ -2089,8 +2089,8 @@ D: ST Microelectronics SPEAr13xx PCI host bridge driver · 172 unmodified lines | ||
| 2089 | 2089 | D: Synopsys Designware PCI host bridge driver |
| 2090 | 2090 | |
| 2091 | 2091 | N: Gabor Kuti |
| 2092 | −M: seasons@falcon.sch.bme.hu | |
| 2093 | −M: seasons@makosteszta.sote.hu | |
| 2092 | +E: seasons@falcon.sch.bme.hu | |
| 2093 | +E: seasons@makosteszta.sote.hu | |
| 2094 | 2094 | D: Original author of software suspend |
| 2095 | 2095 | |
| 2096 | 2096 | N: Jaroslav Kysela |
| @@ -9,10 +9,26 @@ The following properties are common to the Ethernet controllers: · 8 unmodified lines | ||
| 9 | 9 | - max-speed: number, specifies maximum speed in Mbit/s supported by the device; |
| 10 | 10 | - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than |
| 11 | 11 | the maximum frame size (there's contradiction in ePAPR). |
| 12 | −- phy-mode: string, operation mode of the PHY interface; supported values are | |
| 13 | − "mii", "gmii", "sgmii", "qsgmii", "tbi", "rev-mii", "rmii", "rgmii", "rgmii-id", | |
| 14 | − "rgmii-rxid", "rgmii-txid", "rtbi", "smii", "xgmii", "trgmii"; this is now a | |
| 15 | − de-facto standard property; | |
| 12 | +- phy-mode: string, operation mode of the PHY interface. This is now a de-facto | |
| 13 | + standard property; supported values are: | |
| 14 | + * "mii" | |
| 15 | + * "gmii" | |
| 16 | + * "sgmii" | |
| 17 | + * "qsgmii" | |
| 18 | + * "tbi" | |
| 19 | + * "rev-mii" | |
| 20 | + * "rmii" | |
| 21 | + * "rgmii" (RX and TX delays are added by the MAC when required) | |
| 22 | + * "rgmii-id" (RGMII with internal RX and TX delays provided by the PHY, the | |
| 23 | + MAC should not add the RX or TX delays in this case) | |
| 24 | + * "rgmii-rxid" (RGMII with internal RX delay provided by the PHY, the MAC | |
| 25 | + should not add an RX delay in this case) | |
| 26 | + * "rgmii-txid" (RGMII with internal TX delay provided by the PHY, the MAC | |
| 27 | + should not add an TX delay in this case) | |
| 28 | + * "rtbi" | |
| 29 | + * "smii" | |
| 30 | + * "xgmii" | |
| 31 | + * "trgmii" | |
| 16 | 32 | - phy-connection-type: the same as "phy-mode" property but described in ePAPR; |
| 17 | 33 | - phy-handle: phandle, specifies a reference to a node representing a PHY |
| 18 | 34 | device; this property is described in ePAPR and so preferred; |
| @@ -62,10 +62,13 @@ nf_conntrack_generic_timeout - INTEGER (seconds) · 61 unmodified lines | ||
| 62 | 62 | protocols. |
| 63 | 63 | |
| 64 | 64 | nf_conntrack_helper - BOOLEAN |
| 65 | − 0 - disabled | |
| 66 | − not 0 - enabled (default) | |
| 65 | + 0 - disabled (default) | |
| 66 | + not 0 - enabled | |
| 67 | 67 | |
| 68 | 68 | Enable automatic conntrack helper assignment. |
| 69 | + If disabled it is required to set up iptables rules to assign | |
| 70 | + helpers to connections. See the CT target description in the | |
| 71 | + iptables-extensions(8) man page for further information. | |
| 69 | 72 | |
| 70 | 73 | nf_conntrack_icmp_timeout - INTEGER (seconds) |
| 71 | 74 | default 30 |
| @@ -9257,11 +9257,12 @@ S: Maintained · 9256 unmodified lines | ||
| 9257 | 9257 | F: drivers/pci/host/*layerscape* |
| 9258 | 9258 | |
| 9259 | 9259 | PCI DRIVER FOR IMX6 |
| 9260 | −M: Richard Zhu <Richard.Zhu@freescale.com> | |
| 9260 | +M: Richard Zhu <hongxing.zhu@nxp.com> | |
| 9261 | 9261 | M: Lucas Stach <l.stach@pengutronix.de> |
| 9262 | 9262 | L: linux-pci@vger.kernel.org |
| 9263 | 9263 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) |
| 9264 | 9264 | S: Maintained |
| 9265 | +F: Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt | |
| 9265 | 9266 | F: drivers/pci/host/*imx6* |
| 9266 | 9267 | |
| 9267 | 9268 | PCI DRIVER FOR TI KEYSTONE |
| @@ -9320,17 +9321,11 @@ F: drivers/pci/host/pci-exynos.c · 52 unmodified lines | ||
| 9320 | 9321 | |
| 9321 | 9322 | PCI DRIVER FOR SYNOPSIS DESIGNWARE |
| 9322 | 9323 | M: Jingoo Han <jingoohan1@gmail.com> |
| 9323 | −M: Pratyush Anand <pratyush.anand@gmail.com> | |
| 9324 | −L: linux-pci@vger.kernel.org | |
| 9325 | −S: Maintained | |
| 9326 | −F: drivers/pci/host/*designware* | |
| 9327 | − | |
| 9328 | −PCI DRIVER FOR SYNOPSYS PROTOTYPING DEVICE | |
| 9329 | −M: Jose Abreu <Jose.Abreu@synopsys.com> | |
| 9324 | +M: Joao Pinto <Joao.Pinto@synopsys.com> | |
| 9330 | 9325 | L: linux-pci@vger.kernel.org |
| 9331 | 9326 | S: Maintained |
| 9332 | 9327 | F: Documentation/devicetree/bindings/pci/designware-pcie.txt |
| 9333 | −F: drivers/pci/host/pcie-designware-plat.c | |
| 9328 | +F: drivers/pci/host/*designware* | |
| 9334 | 9329 | |
| 9335 | 9330 | PCI DRIVER FOR GENERIC OF HOSTS |
| 9336 | 9331 | M: Will Deacon <will.deacon@arm.com> |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | VERSION = 4 |
| 2 | 2 | PATCHLEVEL = 9 |
| 3 | 3 | SUBLEVEL = 0 |
| 4 | −EXTRAVERSION = -rc7 | |
| 4 | +EXTRAVERSION = -rc8 | |
| 5 | 5 | NAME = Psychotic Stoned Sheep |
| 6 | 6 | |
| 7 | 7 | # *DOCUMENTATION* |
| @@ -607,6 +607,13 @@ else · 599 unmodified lines | ||
| 607 | 607 | include/config/auto.conf: ; |
| 608 | 608 | endif # $(dot-config) |
| 609 | 609 | |
| 610 | +# For the kernel to actually contain only the needed exported symbols, | |
| 611 | +# we have to build modules as well to determine what those symbols are. | |
| 612 | +# (this can be evaluated only once include/config/auto.conf has been included) | |
| 613 | +ifdef CONFIG_TRIM_UNUSED_KSYMS | |
| 614 | + KBUILD_MODULES := 1 | |
| 615 | +endif | |
| 616 | + | |
| 610 | 617 | # The all: target is the default when no target is given on the |
| 611 | 618 | # command line. |
| 612 | 619 | # This allow a user to issue only 'make' to build a kernel including modules |
| @@ -944,7 +951,7 @@ ifdef CONFIG_GDB_SCRIPTS · 331 unmodified lines | ||
| 944 | 951 | endif |
| 945 | 952 | ifdef CONFIG_TRIM_UNUSED_KSYMS |
| 946 | 953 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ |
| 947 | − "$(MAKE) KBUILD_MODULES=1 -f $(srctree)/Makefile vmlinux_prereq" | |
| 954 | + "$(MAKE) -f $(srctree)/Makefile vmlinux" | |
| 948 | 955 | endif |
| 949 | 956 | |
| 950 | 957 | # standalone target for easier testing |
| @@ -1019,8 +1026,6 @@ prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic · 68 unmodified lines | ||
| 1019 | 1026 | prepare1: prepare2 $(version_h) include/generated/utsrelease.h \ |
| 1020 | 1027 | include/config/auto.conf |
| 1021 | 1028 | $(cmd_crmodverdir) |
| 1022 | − $(Q)test -e include/generated/autoksyms.h || \ | |
| 1023 | − touch include/generated/autoksyms.h | |
| 1024 | 1029 | |
| 1025 | 1030 | archprepare: archheaders archscripts prepare1 scripts_basic |
| 1026 | 1031 | |
| @@ -22,10 +22,11 @@ · 21 unmodified lines | ||
| 22 | 22 | static inline void __delay(unsigned long loops) |
| 23 | 23 | { |
| 24 | 24 | __asm__ __volatile__( |
| 25 | − " lp 1f \n" | |
| 26 | − " nop \n" | |
| 27 | − "1: \n" | |
| 28 | − : "+l"(loops)); | |
| 25 | + " mov lp_count, %0 \n" | |
| 26 | + " lp 1f \n" | |
| 27 | + " nop \n" | |
| 28 | + "1: \n" | |
| 29 | + : : "r"(loops)); | |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | 32 | extern void __bad_udelay(void); |
| @@ -280,7 +280,7 @@ static inline void pmd_set(pmd_t *pmdp, pte_t *ptep) · 279 unmodified lines | ||
| 280 | 280 | |
| 281 | 281 | #define pte_page(pte) pfn_to_page(pte_pfn(pte)) |
| 282 | 282 | #define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot) |
| 283 | −#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) | |
| 283 | +#define pfn_pte(pfn, prot) __pte(__pfn_to_phys(pfn) | pgprot_val(prot)) | |
| 284 | 284 | |
| 285 | 285 | /* Don't use virt_to_pfn for macros below: could cause truncations for PAE40*/ |
| 286 | 286 | #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) |
| @@ -23,7 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | static int l2_line_sz; |
| 25 | 25 | static int ioc_exists; |
| 26 | −int slc_enable = 1, ioc_enable = 1; | |
| 26 | +int slc_enable = 1, ioc_enable = 0; | |
| 27 | 27 | unsigned long perip_base = ARC_UNCACHED_ADDR_SPACE; /* legacy value for boot */ |
| 28 | 28 | unsigned long perip_end = 0xFFFFFFFF; /* legacy value */ |
| 29 | 29 | |
| @@ -745,7 +745,6 @@ dtb-$(CONFIG_MACH_SUN4I) += \ · 744 unmodified lines | ||
| 745 | 745 | sun4i-a10-pcduino2.dtb \ |
| 746 | 746 | sun4i-a10-pov-protab2-ips9.dtb |
| 747 | 747 | dtb-$(CONFIG_MACH_SUN5I) += \ |
| 748 | − ntc-gr8-evb.dtb \ | |
| 749 | 748 | sun5i-a10s-auxtek-t003.dtb \ |
| 750 | 749 | sun5i-a10s-auxtek-t004.dtb \ |
| 751 | 750 | sun5i-a10s-mk802.dtb \ |
| @@ -761,6 +760,7 @@ dtb-$(CONFIG_MACH_SUN5I) += \ · 9 unmodified lines | ||
| 761 | 760 | sun5i-a13-olinuxino-micro.dtb \ |
| 762 | 761 | sun5i-a13-q8-tablet.dtb \ |
| 763 | 762 | sun5i-a13-utoo-p66.dtb \ |
| 763 | + sun5i-gr8-evb.dtb \ | |
| 764 | 764 | sun5i-r8-chip.dtb |
| 765 | 765 | dtb-$(CONFIG_MACH_SUN6I) += \ |
| 766 | 766 | sun6i-a31-app4-evb1.dtb \ |
| @@ -283,6 +283,8 @@ · 282 unmodified lines | ||
| 283 | 283 | clock-frequency = <400000>; |
| 284 | 284 | pinctrl-names = "default"; |
| 285 | 285 | pinctrl-0 = <&pinctrl_i2c0_default>; |
| 286 | + #address-cells = <1>; | |
| 287 | + #size-cells = <0>; | |
| 286 | 288 | |
| 287 | 289 | status = "disabled"; |
| 288 | 290 | }; |
| @@ -296,6 +298,8 @@ · 7 unmodified lines | ||
| 296 | 298 | clock-frequency = <400000>; |
| 297 | 299 | pinctrl-names = "default"; |
| 298 | 300 | pinctrl-0 = <&pinctrl_i2c1_default>; |
| 301 | + #address-cells = <1>; | |
| 302 | + #size-cells = <0>; | |
| 299 | 303 | |
| 300 | 304 | status = "disabled"; |
| 301 | 305 | }; |
| @@ -309,6 +313,8 @@ · 7 unmodified lines | ||
| 309 | 313 | clock-frequency = <400000>; |
| 310 | 314 | pinctrl-names = "default"; |
| 311 | 315 | pinctrl-0 = <&pinctrl_i2c2_default>; |
| 316 | + #address-cells = <1>; | |
| 317 | + #size-cells = <0>; | |
| 312 | 318 | |
| 313 | 319 | status = "disabled"; |
| 314 | 320 | }; |
| @@ -322,6 +328,8 @@ · 7 unmodified lines | ||
| 322 | 328 | clock-frequency = <400000>; |
| 323 | 329 | pinctrl-names = "default"; |
| 324 | 330 | pinctrl-0 = <&pinctrl_i2c3_default>; |
| 331 | + #address-cells = <1>; | |
| 332 | + #size-cells = <0>; | |
| 325 | 333 | |
| 326 | 334 | status = "disabled"; |
| 327 | 335 | }; |
| @@ -335,6 +343,8 @@ · 7 unmodified lines | ||
| 335 | 343 | clock-frequency = <400000>; |
| 336 | 344 | pinctrl-names = "default"; |
| 337 | 345 | pinctrl-0 = <&pinctrl_i2c4_default>; |
| 346 | + #address-cells = <1>; | |
| 347 | + #size-cells = <0>; | |
| 338 | 348 | |
| 339 | 349 | status = "disabled"; |
| 340 | 350 | }; |
| @@ -348,6 +358,8 @@ · 7 unmodified lines | ||
| 348 | 358 | clock-frequency = <400000>; |
| 349 | 359 | pinctrl-names = "default"; |
| 350 | 360 | pinctrl-0 = <&pinctrl_i2c5_default>; |
| 361 | + #address-cells = <1>; | |
| 362 | + #size-cells = <0>; | |
| 351 | 363 | |
| 352 | 364 | status = "disabled"; |
| 353 | 365 | }; |
| @@ -363,6 +375,8 @@ · 9 unmodified lines | ||
| 363 | 375 | clock-frequency = <400000>; |
| 364 | 376 | pinctrl-names = "default"; |
| 365 | 377 | pinctrl-0 = <&pinctrl_i2c10_default>; |
| 378 | + #address-cells = <1>; | |
| 379 | + #size-cells = <0>; | |
| 366 | 380 | |
| 367 | 381 | status = "disabled"; |
| 368 | 382 | }; |
| @@ -376,6 +390,8 @@ · 7 unmodified lines | ||
| 376 | 390 | clock-frequency = <400000>; |
| 377 | 391 | pinctrl-names = "default"; |
| 378 | 392 | pinctrl-0 = <&pinctrl_i2c11_default>; |
| 393 | + #address-cells = <1>; | |
| 394 | + #size-cells = <0>; | |
| 379 | 395 | |
| 380 | 396 | status = "disabled"; |
| 381 | 397 | }; |
| @@ -44,7 +44,7 @@ · 43 unmodified lines | ||
| 44 | 44 | */ |
| 45 | 45 | |
| 46 | 46 | /dts-v1/; |
| 47 | −#include "ntc-gr8.dtsi" | |
| 47 | +#include "sun5i-gr8.dtsi" | |
| 48 | 48 | #include "sunxi-common-regulators.dtsi" |
| 49 | 49 | |
| 50 | 50 | #include <dt-bindings/gpio/gpio.h> |
File renamed without changes.
| @@ -393,7 +393,7 @@ · 392 unmodified lines | ||
| 393 | 393 | #address-cells = <3>; |
| 394 | 394 | #size-cells = <2>; |
| 395 | 395 | dma-coherent; |
| 396 | − ranges = <0x01000000 0x00 0x5f800000 0x00 0x5f800000 0x0 0x00800000>, | |
| 396 | + ranges = <0x01000000 0x00 0x00000000 0x00 0x5f800000 0x0 0x00800000>, | |
| 397 | 397 | <0x02000000 0x00 0x50000000 0x00 0x50000000 0x0 0x08000000>, |
| 398 | 398 | <0x42000000 0x40 0x00000000 0x40 0x00000000 0x1 0x00000000>; |
| 399 | 399 | #interrupt-cells = <1>; |
| @@ -76,7 +76,7 @@ · 75 unmodified lines | ||
| 76 | 76 | compatible = "arm,idle-state"; |
| 77 | 77 | arm,psci-suspend-param = <0x1010000>; |
| 78 | 78 | local-timer-stop; |
| 79 | − entry-latency-us = <300>; | |
| 79 | + entry-latency-us = <400>; | |
| 80 | 80 | exit-latency-us = <1200>; |
| 81 | 81 | min-residency-us = <2500>; |
| 82 | 82 | }; |
| @@ -76,7 +76,7 @@ · 75 unmodified lines | ||
| 76 | 76 | compatible = "arm,idle-state"; |
| 77 | 77 | arm,psci-suspend-param = <0x1010000>; |
| 78 | 78 | local-timer-stop; |
| 79 | − entry-latency-us = <300>; | |
| 79 | + entry-latency-us = <400>; | |
| 80 | 80 | exit-latency-us = <1200>; |
| 81 | 81 | min-residency-us = <2500>; |
| 82 | 82 | }; |
| @@ -76,7 +76,7 @@ · 75 unmodified lines | ||
| 76 | 76 | compatible = "arm,idle-state"; |
| 77 | 77 | arm,psci-suspend-param = <0x1010000>; |
| 78 | 78 | local-timer-stop; |
| 79 | − entry-latency-us = <300>; | |
| 79 | + entry-latency-us = <400>; | |
| 80 | 80 | exit-latency-us = <1200>; |
| 81 | 81 | min-residency-us = <2500>; |
| 82 | 82 | }; |
| @@ -1436,13 +1436,6 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports, · 1435 unmodified lines | ||
| 1436 | 1436 | "ahci: MRSM is on, fallback to single MSI\n"); |
| 1437 | 1437 | pci_free_irq_vectors(pdev); |
| 1438 | 1438 | } |
| 1439 | − | |
| 1440 | − /* | |
| 1441 | − * -ENOSPC indicated we don't have enough vectors. Don't bother | |
| 1442 | − * trying a single vectors for any other error: | |
| 1443 | − */ | |
| 1444 | − if (nvec < 0 && nvec != -ENOSPC) | |
| 1445 | − return nvec; | |
| 1446 | 1439 | } |
| 1447 | 1440 | |
| 1448 | 1441 | /* |
| @@ -1088,7 +1088,7 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) · 1087 unmodified lines | ||
| 1088 | 1088 | desc[1] = tf->command; /* status */ |
| 1089 | 1089 | desc[2] = tf->device; |
| 1090 | 1090 | desc[3] = tf->nsect; |
| 1091 | − desc[0] = 0; | |
| 1091 | + desc[7] = 0; | |
| 1092 | 1092 | if (tf->flags & ATA_TFLAG_LBA48) { |
| 1093 | 1093 | desc[8] |= 0x80; |
| 1094 | 1094 | if (tf->hob_nsect) |
| @@ -1403,7 +1403,8 @@ static ssize_t hot_remove_store(struct class *class, · 1402 unmodified lines | ||
| 1403 | 1403 | zram = idr_find(&zram_index_idr, dev_id); |
| 1404 | 1404 | if (zram) { |
| 1405 | 1405 | ret = zram_remove(zram); |
| 1406 | − idr_remove(&zram_index_idr, dev_id); | |
| 1406 | + if (!ret) | |
| 1407 | + idr_remove(&zram_index_idr, dev_id); | |
| 1407 | 1408 | } else { |
| 1408 | 1409 | ret = -ENODEV; |
| 1409 | 1410 | } |
| @@ -20,7 +20,7 @@ config CLK_BCM_KONA · 19 unmodified lines | ||
| 20 | 20 | |
| 21 | 21 | config COMMON_CLK_IPROC |
| 22 | 22 | bool "Broadcom iProc clock support" |
| 23 | − depends on ARCH_BCM_IPROC || COMPILE_TEST | |
| 23 | + depends on ARCH_BCM_IPROC || ARCH_BCM_63XX || COMPILE_TEST | |
| 24 | 24 | depends on COMMON_CLK |
| 25 | 25 | default ARCH_BCM_IPROC |
| 26 | 26 | help |
| @@ -143,7 +143,7 @@ static SUNXI_CCU_NKM_WITH_MUX_GATE_LOCK(pll_mipi_clk, "pll-mipi", · 142 unmodified lines | ||
| 143 | 143 | 4, 2, /* K */ |
| 144 | 144 | 0, 4, /* M */ |
| 145 | 145 | 21, 0, /* mux */ |
| 146 | − BIT(31), /* gate */ | |
| 146 | + BIT(31) | BIT(23) | BIT(22), /* gate */ | |
| 147 | 147 | BIT(28), /* lock */ |
| 148 | 148 | CLK_SET_RATE_UNGATE); |
| 149 | 149 | |
| @@ -131,7 +131,7 @@ static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_mipi_clk, "pll-mipi", · 130 unmodified lines | ||
| 131 | 131 | 8, 4, /* N */ |
| 132 | 132 | 4, 2, /* K */ |
| 133 | 133 | 0, 4, /* M */ |
| 134 | − BIT(31), /* gate */ | |
| 134 | + BIT(31) | BIT(23) | BIT(22), /* gate */ | |
| 135 | 135 | BIT(28), /* lock */ |
| 136 | 136 | CLK_SET_RATE_UNGATE); |
| 137 | 137 | |
| @@ -485,7 +485,6 @@ static int amdgpu_atpx_power_state(enum vga_switcheroo_client_id id, · 484 unmodified lines | ||
| 485 | 485 | */ |
| 486 | 486 | static bool amdgpu_atpx_pci_probe_handle(struct pci_dev *pdev) |
| 487 | 487 | { |
| 488 | − struct pci_dev *parent_pdev = pci_upstream_bridge(pdev); | |
| 489 | 488 | acpi_handle dhandle, atpx_handle; |
| 490 | 489 | acpi_status status; |
| 491 | 490 | |
| @@ -500,7 +499,6 @@ static bool amdgpu_atpx_pci_probe_handle(struct pci_dev *pdev) · 8 unmodified lines | ||
| 500 | 499 | } |
| 501 | 500 | amdgpu_atpx_priv.dhandle = dhandle; |
| 502 | 501 | amdgpu_atpx_priv.atpx.handle = atpx_handle; |
| 503 | − amdgpu_atpx_priv.bridge_pm_usable = parent_pdev && parent_pdev->bridge_d3; | |
| 504 | 502 | return true; |
| 505 | 503 | } |
| 506 | 504 | |
| @@ -562,17 +560,25 @@ static bool amdgpu_atpx_detect(void) · 55 unmodified lines | ||
| 562 | 560 | struct pci_dev *pdev = NULL; |
| 563 | 561 | bool has_atpx = false; |
| 564 | 562 | int vga_count = 0; |
| 563 | + bool d3_supported = false; | |
| 564 | + struct pci_dev *parent_pdev; | |
| 565 | 565 | |
| 566 | 566 | while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { |
| 567 | 567 | vga_count++; |
| 568 | 568 | |
| 569 | 569 | has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true); |
| 570 | + | |
| 571 | + parent_pdev = pci_upstream_bridge(pdev); | |
| 572 | + d3_supported |= parent_pdev && parent_pdev->bridge_d3; | |
| 570 | 573 | } |
| 571 | 574 | |
| 572 | 575 | while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) { |
| 573 | 576 | vga_count++; |
| 574 | 577 | |
| 575 | 578 | has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true); |
| 579 | + | |
| 580 | + parent_pdev = pci_upstream_bridge(pdev); | |
| 581 | + d3_supported |= parent_pdev && parent_pdev->bridge_d3; | |
| 576 | 582 | } |
| 577 | 583 | |
| 578 | 584 | if (has_atpx && vga_count == 2) { |
| @@ -580,6 +586,7 @@ static bool amdgpu_atpx_detect(void) · 1 unmodified line | ||
| 580 | 586 | printk(KERN_INFO "vga_switcheroo: detected switching method %s handle\n", |
| 581 | 587 | acpi_method_name); |
| 582 | 588 | amdgpu_atpx_priv.atpx_detected = true; |
| 589 | + amdgpu_atpx_priv.bridge_pm_usable = d3_supported; | |
| 583 | 590 | amdgpu_atpx_init(); |
| 584 | 591 | return true; |
| 585 | 592 | } |
| @@ -2214,6 +2214,7 @@ uint32_t polaris10_get_mac_definition(uint32_t value) · 2213 unmodified lines | ||
| 2214 | 2214 | int polaris10_process_firmware_header(struct pp_hwmgr *hwmgr) |
| 2215 | 2215 | { |
| 2216 | 2216 | struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)(hwmgr->smumgr->backend); |
| 2217 | + struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); | |
| 2217 | 2218 | uint32_t tmp; |
| 2218 | 2219 | int result; |
| 2219 | 2220 | bool error = false; |
| @@ -2233,8 +2234,10 @@ int polaris10_process_firmware_header(struct pp_hwmgr *hwmgr) · 13 unmodified lines | ||
| 2233 | 2234 | offsetof(SMU74_Firmware_Header, SoftRegisters), |
| 2234 | 2235 | &tmp, SMC_RAM_END); |
| 2235 | 2236 | |
| 2236 | − if (!result) | |
| 2237 | + if (!result) { | |
| 2238 | + data->soft_regs_start = tmp; | |
| 2237 | 2239 | smu_data->smu7_data.soft_regs_start = tmp; |
| 2240 | + } | |
| 2238 | 2241 | |
| 2239 | 2242 | error |= (0 != result); |
| 2240 | 2243 | |
| @@ -375,7 +375,6 @@ static int hdlcd_drm_bind(struct device *dev) · 374 unmodified lines | ||
| 375 | 375 | |
| 376 | 376 | err_fbdev: |
| 377 | 377 | drm_kms_helper_poll_fini(drm); |
| 378 | − drm_mode_config_cleanup(drm); | |
| 379 | 378 | drm_vblank_cleanup(drm); |
| 380 | 379 | err_vblank: |
| 381 | 380 | pm_runtime_disable(drm->dev); |
| @@ -387,6 +386,7 @@ err_unload: · 5 unmodified lines | ||
| 387 | 386 | drm_irq_uninstall(drm); |
| 388 | 387 | of_reserved_mem_device_release(drm->dev); |
| 389 | 388 | err_free: |
| 389 | + drm_mode_config_cleanup(drm); | |
| 390 | 390 | dev_set_drvdata(dev, NULL); |
| 391 | 391 | drm_dev_unref(drm); |
| 392 | 392 | |
| @@ -254,10 +254,12 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_ · 253 unmodified lines | ||
| 254 | 254 | req->value = dev->mode_config.async_page_flip; |
| 255 | 255 | break; |
| 256 | 256 | case DRM_CAP_PAGE_FLIP_TARGET: |
| 257 | − req->value = 1; | |
| 258 | − drm_for_each_crtc(crtc, dev) { | |
| 259 | − if (!crtc->funcs->page_flip_target) | |
| 260 | − req->value = 0; | |
| 257 | + if (drm_core_check_feature(dev, DRIVER_MODESET)) { | |
| 258 | + req->value = 1; | |
| 259 | + drm_for_each_crtc(crtc, dev) { | |
| 260 | + if (!crtc->funcs->page_flip_target) | |
| 261 | + req->value = 0; | |
| 262 | + } | |
| 261 | 263 | } |
| 262 | 264 | break; |
| 263 | 265 | case DRM_CAP_CURSOR_WIDTH: |
| @@ -2268,7 +2268,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) · 2267 unmodified lines | ||
| 2268 | 2268 | page = shmem_read_mapping_page(mapping, i); |
| 2269 | 2269 | if (IS_ERR(page)) { |
| 2270 | 2270 | ret = PTR_ERR(page); |
| 2271 | − goto err_pages; | |
| 2271 | + goto err_sg; | |
| 2272 | 2272 | } |
| 2273 | 2273 | } |
| 2274 | 2274 | #ifdef CONFIG_SWIOTLB |
| @@ -2311,8 +2311,9 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) · 36 unmodified lines | ||
| 2311 | 2311 | |
| 2312 | 2312 | return 0; |
| 2313 | 2313 | |
| 2314 | −err_pages: | |
| 2314 | +err_sg: | |
| 2315 | 2315 | sg_mark_end(sg); |
| 2316 | +err_pages: | |
| 2316 | 2317 | for_each_sgt_page(page, sgt_iter, st) |
| 2317 | 2318 | put_page(page); |
| 2318 | 2319 | sg_free_table(st); |
| @@ -12260,7 +12260,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, · 12259 unmodified lines | ||
| 12260 | 12260 | intel_crtc->reset_count = i915_reset_count(&dev_priv->gpu_error); |
| 12261 | 12261 | if (i915_reset_in_progress_or_wedged(&dev_priv->gpu_error)) { |
| 12262 | 12262 | ret = -EIO; |
| 12263 | − goto cleanup; | |
| 12263 | + goto unlock; | |
| 12264 | 12264 | } |
| 12265 | 12265 | |
| 12266 | 12266 | atomic_inc(&intel_crtc->unpin_work_count); |
| @@ -12352,6 +12352,7 @@ cleanup_unpin: · 85 unmodified lines | ||
| 12352 | 12352 | intel_unpin_fb_obj(fb, crtc->primary->state->rotation); |
| 12353 | 12353 | cleanup_pending: |
| 12354 | 12354 | atomic_dec(&intel_crtc->unpin_work_count); |
| 12355 | +unlock: | |
| 12355 | 12356 | mutex_unlock(&dev->struct_mutex); |
| 12356 | 12357 | cleanup: |
| 12357 | 12358 | crtc->primary->fb = old_fb; |
| @@ -479,7 +479,6 @@ static int radeon_atpx_power_state(enum vga_switcheroo_client_id id, · 478 unmodified lines | ||
| 479 | 479 | */ |
| 480 | 480 | static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev) |
| 481 | 481 | { |
| 482 | − struct pci_dev *parent_pdev = pci_upstream_bridge(pdev); | |
| 483 | 482 | acpi_handle dhandle, atpx_handle; |
| 484 | 483 | acpi_status status; |
| 485 | 484 | |
| @@ -493,7 +492,6 @@ static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev) · 7 unmodified lines | ||
| 493 | 492 | |
| 494 | 493 | radeon_atpx_priv.dhandle = dhandle; |
| 495 | 494 | radeon_atpx_priv.atpx.handle = atpx_handle; |
| 496 | − radeon_atpx_priv.bridge_pm_usable = parent_pdev && parent_pdev->bridge_d3; | |
| 497 | 495 | return true; |
| 498 | 496 | } |
| 499 | 497 | |
| @@ -555,11 +553,16 @@ static bool radeon_atpx_detect(void) · 55 unmodified lines | ||
| 555 | 553 | struct pci_dev *pdev = NULL; |
| 556 | 554 | bool has_atpx = false; |
| 557 | 555 | int vga_count = 0; |
| 556 | + bool d3_supported = false; | |
| 557 | + struct pci_dev *parent_pdev; | |
| 558 | 558 | |
| 559 | 559 | while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { |
| 560 | 560 | vga_count++; |
| 561 | 561 | |
| 562 | 562 | has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true); |
| 563 | + | |
| 564 | + parent_pdev = pci_upstream_bridge(pdev); | |
| 565 | + d3_supported |= parent_pdev && parent_pdev->bridge_d3; | |
| 563 | 566 | } |
| 564 | 567 | |
| 565 | 568 | /* some newer PX laptops mark the dGPU as a non-VGA display device */ |
| @@ -567,6 +570,9 @@ static bool radeon_atpx_detect(void) · 1 unmodified line | ||
| 567 | 570 | vga_count++; |
| 568 | 571 | |
| 569 | 572 | has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true); |
| 573 | + | |
| 574 | + parent_pdev = pci_upstream_bridge(pdev); | |
| 575 | + d3_supported |= parent_pdev && parent_pdev->bridge_d3; | |
| 570 | 576 | } |
| 571 | 577 | |
| 572 | 578 | if (has_atpx && vga_count == 2) { |
| @@ -574,6 +580,7 @@ static bool radeon_atpx_detect(void) · 1 unmodified line | ||
| 574 | 580 | printk(KERN_INFO "vga_switcheroo: detected switching method %s handle\n", |
| 575 | 581 | acpi_method_name); |
| 576 | 582 | radeon_atpx_priv.atpx_detected = true; |
| 583 | + radeon_atpx_priv.bridge_pm_usable = d3_supported; | |
| 577 | 584 | radeon_atpx_init(); |
| 578 | 585 | return true; |
| 579 | 586 | } |
| @@ -381,9 +381,7 @@ static int octeon_i2c_read(struct octeon_i2c *i2c, int target, · 380 unmodified lines | ||
| 381 | 381 | if (result) |
| 382 | 382 | return result; |
| 383 | 383 | |
| 384 | − data[i] = octeon_i2c_data_read(i2c, &result); | |
| 385 | − if (result) | |
| 386 | − return result; | |
| 384 | + data[i] = octeon_i2c_data_read(i2c); | |
| 387 | 385 | if (recv_len && i == 0) { |
| 388 | 386 | if (data[i] > I2C_SMBUS_BLOCK_MAX + 1) |
| 389 | 387 | return -EPROTO; |
| @@ -5,7 +5,6 @@ · 4 unmodified lines | ||
| 5 | 5 | #include <linux/i2c.h> |
| 6 | 6 | #include <linux/i2c-smbus.h> |
| 7 | 7 | #include <linux/io.h> |
| 8 | −#include <linux/iopoll.h> | |
| 9 | 8 | #include <linux/kernel.h> |
| 10 | 9 | #include <linux/pci.h> |
| 11 | 10 | |
| @@ -145,9 +144,9 @@ static inline void octeon_i2c_reg_write(struct octeon_i2c *i2c, u64 eop_reg, u8 · 133 unmodified lines | ||
| 145 | 144 | u64 tmp; |
| 146 | 145 | |
| 147 | 146 | __raw_writeq(SW_TWSI_V | eop_reg | data, i2c->twsi_base + SW_TWSI(i2c)); |
| 148 | − | |
| 149 | − readq_poll_timeout(i2c->twsi_base + SW_TWSI(i2c), tmp, tmp & SW_TWSI_V, | |
| 150 | − I2C_OCTEON_EVENT_WAIT, i2c->adap.timeout); | |
| 147 | + do { | |
| 148 | + tmp = __raw_readq(i2c->twsi_base + SW_TWSI(i2c)); | |
| 149 | + } while ((tmp & SW_TWSI_V) != 0); | |
| 151 | 150 | } |
| 152 | 151 | |
| 153 | 152 | #define octeon_i2c_ctl_write(i2c, val) \ |
| @@ -164,28 +163,24 @@ static inline void octeon_i2c_reg_write(struct octeon_i2c *i2c, u64 eop_reg, u8 · 10 unmodified lines | ||
| 164 | 163 | * |
| 165 | 164 | * The I2C core registers are accessed indirectly via the SW_TWSI CSR. |
| 166 | 165 | */ |
| 167 | −static inline int octeon_i2c_reg_read(struct octeon_i2c *i2c, u64 eop_reg, | |
| 168 | − int *error) | |
| 166 | +static inline u8 octeon_i2c_reg_read(struct octeon_i2c *i2c, u64 eop_reg) | |
| 169 | 167 | { |
| 170 | 168 | u64 tmp; |
| 171 | − int ret; | |
| 172 | 169 | |
| 173 | 170 | __raw_writeq(SW_TWSI_V | eop_reg | SW_TWSI_R, i2c->twsi_base + SW_TWSI(i2c)); |
| 171 | + do { | |
| 172 | + tmp = __raw_readq(i2c->twsi_base + SW_TWSI(i2c)); | |
| 173 | + } while ((tmp & SW_TWSI_V) != 0); | |
| 174 | 174 | |
| 175 | − ret = readq_poll_timeout(i2c->twsi_base + SW_TWSI(i2c), tmp, | |
| 176 | − tmp & SW_TWSI_V, I2C_OCTEON_EVENT_WAIT, | |
| 177 | − i2c->adap.timeout); | |
| 178 | − if (error) | |
| 179 | − *error = ret; | |
| 180 | 175 | return tmp & 0xFF; |
| 181 | 176 | } |
| 182 | 177 | |
| 183 | 178 | #define octeon_i2c_ctl_read(i2c) \ |
| 184 | − octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_CTL, NULL) | |
| 185 | −#define octeon_i2c_data_read(i2c, error) \ | |
| 186 | − octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_DATA, error) | |
| 179 | + octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_CTL) | |
| 180 | +#define octeon_i2c_data_read(i2c) \ | |
| 181 | + octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_DATA) | |
| 187 | 182 | #define octeon_i2c_stat_read(i2c) \ |
| 188 | − octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_STAT, NULL) | |
| 183 | + octeon_i2c_reg_read(i2c, SW_TWSI_EOP_TWSI_STAT) | |
| 189 | 184 | |
| 190 | 185 | /** |
| 191 | 186 | * octeon_i2c_read_int - read the TWSI_INT register |
| @@ -1115,10 +1115,6 @@ static int psmouse_extensions(struct psmouse *psmouse, · 1114 unmodified lines | ||
| 1115 | 1115 | if (psmouse_try_protocol(psmouse, PSMOUSE_TOUCHKIT_PS2, |
| 1116 | 1116 | &max_proto, set_properties, true)) |
| 1117 | 1117 | return PSMOUSE_TOUCHKIT_PS2; |
| 1118 | − | |
| 1119 | − if (psmouse_try_protocol(psmouse, PSMOUSE_BYD, | |
| 1120 | − &max_proto, set_properties, true)) | |
| 1121 | − return PSMOUSE_BYD; | |
| 1122 | 1118 | } |
| 1123 | 1119 | |
| 1124 | 1120 | /* |
| @@ -43,11 +43,22 @@ struct __packed pucan_command { · 42 unmodified lines | ||
| 43 | 43 | u16 args[3]; |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | +#define PUCAN_TSLOW_BRP_BITS 10 | |
| 47 | +#define PUCAN_TSLOW_TSGEG1_BITS 8 | |
| 48 | +#define PUCAN_TSLOW_TSGEG2_BITS 7 | |
| 49 | +#define PUCAN_TSLOW_SJW_BITS 7 | |
| 50 | + | |
| 51 | +#define PUCAN_TSLOW_BRP_MASK ((1 << PUCAN_TSLOW_BRP_BITS) - 1) | |
| 52 | +#define PUCAN_TSLOW_TSEG1_MASK ((1 << PUCAN_TSLOW_TSGEG1_BITS) - 1) | |
| 53 | +#define PUCAN_TSLOW_TSEG2_MASK ((1 << PUCAN_TSLOW_TSGEG2_BITS) - 1) | |
| 54 | +#define PUCAN_TSLOW_SJW_MASK ((1 << PUCAN_TSLOW_SJW_BITS) - 1) | |
| 55 | + | |
| 46 | 56 | /* uCAN TIMING_SLOW command fields */ |
| 47 | −#define PUCAN_TSLOW_SJW_T(s, t) (((s) & 0xf) | ((!!(t)) << 7)) | |
| 48 | −#define PUCAN_TSLOW_TSEG2(t) ((t) & 0xf) | |
| 49 | −#define PUCAN_TSLOW_TSEG1(t) ((t) & 0x3f) | |
| 50 | −#define PUCAN_TSLOW_BRP(b) ((b) & 0x3ff) | |
| 57 | +#define PUCAN_TSLOW_SJW_T(s, t) (((s) & PUCAN_TSLOW_SJW_MASK) | \ | |
| 58 | + ((!!(t)) << 7)) | |
| 59 | +#define PUCAN_TSLOW_TSEG2(t) ((t) & PUCAN_TSLOW_TSEG2_MASK) | |
| 60 | +#define PUCAN_TSLOW_TSEG1(t) ((t) & PUCAN_TSLOW_TSEG1_MASK) | |
| 61 | +#define PUCAN_TSLOW_BRP(b) ((b) & PUCAN_TSLOW_BRP_MASK) | |
| 51 | 62 | |
| 52 | 63 | struct __packed pucan_timing_slow { |
| 53 | 64 | __le16 opcode_channel; |
| @@ -60,11 +71,21 @@ struct __packed pucan_timing_slow { · 6 unmodified lines | ||
| 60 | 71 | __le16 brp; /* BaudRate Prescaler */ |
| 61 | 72 | }; |
| 62 | 73 | |
| 74 | +#define PUCAN_TFAST_BRP_BITS 10 | |
| 75 | +#define PUCAN_TFAST_TSGEG1_BITS 5 | |
| 76 | +#define PUCAN_TFAST_TSGEG2_BITS 4 | |
| 77 | +#define PUCAN_TFAST_SJW_BITS 4 | |
| 78 | + | |
| 79 | +#define PUCAN_TFAST_BRP_MASK ((1 << PUCAN_TFAST_BRP_BITS) - 1) | |
| 80 | +#define PUCAN_TFAST_TSEG1_MASK ((1 << PUCAN_TFAST_TSGEG1_BITS) - 1) | |
| 81 | +#define PUCAN_TFAST_TSEG2_MASK ((1 << PUCAN_TFAST_TSGEG2_BITS) - 1) | |
| 82 | +#define PUCAN_TFAST_SJW_MASK ((1 << PUCAN_TFAST_SJW_BITS) - 1) | |
| 83 | + | |
| 63 | 84 | /* uCAN TIMING_FAST command fields */ |
| 64 | −#define PUCAN_TFAST_SJW(s) ((s) & 0x3) | |
| 65 | −#define PUCAN_TFAST_TSEG2(t) ((t) & 0x7) | |
| 66 | −#define PUCAN_TFAST_TSEG1(t) ((t) & 0xf) | |
| 67 | −#define PUCAN_TFAST_BRP(b) ((b) & 0x3ff) | |
| 85 | +#define PUCAN_TFAST_SJW(s) ((s) & PUCAN_TFAST_SJW_MASK) | |
| 86 | +#define PUCAN_TFAST_TSEG2(t) ((t) & PUCAN_TFAST_TSEG2_MASK) | |
| 87 | +#define PUCAN_TFAST_TSEG1(t) ((t) & PUCAN_TFAST_TSEG1_MASK) | |
| 88 | +#define PUCAN_TFAST_BRP(b) ((b) & PUCAN_TFAST_BRP_MASK) | |
| 68 | 89 | |
| 69 | 90 | struct __packed pucan_timing_fast { |
| 70 | 91 | __le16 opcode_channel; |
| @@ -39,6 +39,7 @@ static struct usb_device_id peak_usb_table[] = { · 38 unmodified lines | ||
| 39 | 39 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)}, |
| 40 | 40 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)}, |
| 41 | 41 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)}, |
| 42 | + {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBX6_PRODUCT_ID)}, | |
| 42 | 43 | {} /* Terminating entry */ |
| 43 | 44 | }; |
| 44 | 45 | |
| @@ -50,6 +51,7 @@ static const struct peak_usb_adapter *const peak_usb_adapters_list[] = { · 5 unmodified lines | ||
| 50 | 51 | &pcan_usb_pro, |
| 51 | 52 | &pcan_usb_fd, |
| 52 | 53 | &pcan_usb_pro_fd, |
| 54 | + &pcan_usb_x6, | |
| 53 | 55 | }; |
| 54 | 56 | |
| 55 | 57 | /* |
| @@ -27,6 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | #define PCAN_USBPRO_PRODUCT_ID 0x000d |
| 28 | 28 | #define PCAN_USBPROFD_PRODUCT_ID 0x0011 |
| 29 | 29 | #define PCAN_USBFD_PRODUCT_ID 0x0012 |
| 30 | +#define PCAN_USBX6_PRODUCT_ID 0x0014 | |
| 30 | 31 | |
| 31 | 32 | #define PCAN_USB_DRIVER_NAME "peak_usb" |
| 32 | 33 | |
| @@ -90,6 +91,7 @@ extern const struct peak_usb_adapter pcan_usb; · 57 unmodified lines | ||
| 90 | 91 | extern const struct peak_usb_adapter pcan_usb_pro; |
| 91 | 92 | extern const struct peak_usb_adapter pcan_usb_fd; |
| 92 | 93 | extern const struct peak_usb_adapter pcan_usb_pro_fd; |
| 94 | +extern const struct peak_usb_adapter pcan_usb_x6; | |
| 93 | 95 | |
| 94 | 96 | struct peak_time_ref { |
| 95 | 97 | struct timeval tv_host_0, tv_host; |
| @@ -993,24 +993,24 @@ static void pcan_usb_fd_free(struct peak_usb_device *dev) · 992 unmodified lines | ||
| 993 | 993 | static const struct can_bittiming_const pcan_usb_fd_const = { |
| 994 | 994 | .name = "pcan_usb_fd", |
| 995 | 995 | .tseg1_min = 1, |
| 996 | − .tseg1_max = 64, | |
| 996 | + .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS), | |
| 997 | 997 | .tseg2_min = 1, |
| 998 | − .tseg2_max = 16, | |
| 999 | − .sjw_max = 16, | |
| 998 | + .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS), | |
| 999 | + .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS), | |
| 1000 | 1000 | .brp_min = 1, |
| 1001 | − .brp_max = 1024, | |
| 1001 | + .brp_max = (1 << PUCAN_TSLOW_BRP_BITS), | |
| 1002 | 1002 | .brp_inc = 1, |
| 1003 | 1003 | }; |
| 1004 | 1004 | |
| 1005 | 1005 | static const struct can_bittiming_const pcan_usb_fd_data_const = { |
| 1006 | 1006 | .name = "pcan_usb_fd", |
| 1007 | 1007 | .tseg1_min = 1, |
| 1008 | − .tseg1_max = 16, | |
| 1008 | + .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS), | |
| 1009 | 1009 | .tseg2_min = 1, |
| 1010 | − .tseg2_max = 8, | |
| 1011 | − .sjw_max = 4, | |
| 1010 | + .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS), | |
| 1011 | + .sjw_max = (1 << PUCAN_TFAST_SJW_BITS), | |
| 1012 | 1012 | .brp_min = 1, |
| 1013 | − .brp_max = 1024, | |
| 1013 | + .brp_max = (1 << PUCAN_TFAST_BRP_BITS), | |
| 1014 | 1014 | .brp_inc = 1, |
| 1015 | 1015 | }; |
| 1016 | 1016 | |
| @@ -1065,24 +1065,24 @@ const struct peak_usb_adapter pcan_usb_fd = { · 48 unmodified lines | ||
| 1065 | 1065 | static const struct can_bittiming_const pcan_usb_pro_fd_const = { |
| 1066 | 1066 | .name = "pcan_usb_pro_fd", |
| 1067 | 1067 | .tseg1_min = 1, |
| 1068 | − .tseg1_max = 64, | |
| 1068 | + .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS), | |
| 1069 | 1069 | .tseg2_min = 1, |
| 1070 | − .tseg2_max = 16, | |
| 1071 | − .sjw_max = 16, | |
| 1070 | + .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS), | |
| 1071 | + .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS), | |
| 1072 | 1072 | .brp_min = 1, |
| 1073 | − .brp_max = 1024, | |
| 1073 | + .brp_max = (1 << PUCAN_TSLOW_BRP_BITS), | |
| 1074 | 1074 | .brp_inc = 1, |
| 1075 | 1075 | }; |
| 1076 | 1076 | |
| 1077 | 1077 | static const struct can_bittiming_const pcan_usb_pro_fd_data_const = { |
| 1078 | 1078 | .name = "pcan_usb_pro_fd", |
| 1079 | 1079 | .tseg1_min = 1, |
| 1080 | − .tseg1_max = 16, | |
| 1080 | + .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS), | |
| 1081 | 1081 | .tseg2_min = 1, |
| 1082 | − .tseg2_max = 8, | |
| 1083 | − .sjw_max = 4, | |
| 1082 | + .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS), | |
| 1083 | + .sjw_max = (1 << PUCAN_TFAST_SJW_BITS), | |
| 1084 | 1084 | .brp_min = 1, |
| 1085 | − .brp_max = 1024, | |
| 1085 | + .brp_max = (1 << PUCAN_TFAST_BRP_BITS), | |
| 1086 | 1086 | .brp_inc = 1, |
| 1087 | 1087 | }; |
| 1088 | 1088 | |
| @@ -1132,3 +1132,75 @@ const struct peak_usb_adapter pcan_usb_pro_fd = { · 43 unmodified lines | ||
| 1132 | 1132 | |
| 1133 | 1133 | .do_get_berr_counter = pcan_usb_fd_get_berr_counter, |
| 1134 | 1134 | }; |
| 1135 | + | |
| 1136 | +/* describes the PCAN-USB X6 adapter */ | |
| 1137 | +static const struct can_bittiming_const pcan_usb_x6_const = { | |
| 1138 | + .name = "pcan_usb_x6", | |
| 1139 | + .tseg1_min = 1, | |
| 1140 | + .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS), | |
| 1141 | + .tseg2_min = 1, | |
| 1142 | + .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS), | |
| 1143 | + .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS), | |
| 1144 | + .brp_min = 1, | |
| 1145 | + .brp_max = (1 << PUCAN_TSLOW_BRP_BITS), | |
| 1146 | + .brp_inc = 1, | |
| 1147 | +}; | |
| 1148 | + | |
| 1149 | +static const struct can_bittiming_const pcan_usb_x6_data_const = { | |
| 1150 | + .name = "pcan_usb_x6", | |
| 1151 | + .tseg1_min = 1, | |
| 1152 | + .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS), | |
| 1153 | + .tseg2_min = 1, | |
| 1154 | + .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS), | |
| 1155 | + .sjw_max = (1 << PUCAN_TFAST_SJW_BITS), | |
| 1156 | + .brp_min = 1, | |
| 1157 | + .brp_max = (1 << PUCAN_TFAST_BRP_BITS), | |
| 1158 | + .brp_inc = 1, | |
| 1159 | +}; | |
| 1160 | + | |
| 1161 | +const struct peak_usb_adapter pcan_usb_x6 = { | |
| 1162 | + .name = "PCAN-USB X6", | |
| 1163 | + .device_id = PCAN_USBX6_PRODUCT_ID, | |
| 1164 | + .ctrl_count = PCAN_USBPROFD_CHANNEL_COUNT, | |
| 1165 | + .ctrlmode_supported = CAN_CTRLMODE_FD | | |
| 1166 | + CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY, | |
| 1167 | + .clock = { | |
| 1168 | + .freq = PCAN_UFD_CRYSTAL_HZ, | |
| 1169 | + }, | |
| 1170 | + .bittiming_const = &pcan_usb_x6_const, | |
| 1171 | + .data_bittiming_const = &pcan_usb_x6_data_const, | |
| 1172 | + | |
| 1173 | + /* size of device private data */ | |
| 1174 | + .sizeof_dev_private = sizeof(struct pcan_usb_fd_device), | |
| 1175 | + | |
| 1176 | + /* timestamps usage */ | |
| 1177 | + .ts_used_bits = 32, | |
| 1178 | + .ts_period = 1000000, /* calibration period in ts. */ | |
| 1179 | + .us_per_ts_scale = 1, /* us = (ts * scale) >> shift */ | |
| 1180 | + .us_per_ts_shift = 0, | |
| 1181 | + | |
| 1182 | + /* give here messages in/out endpoints */ | |
| 1183 | + .ep_msg_in = PCAN_USBPRO_EP_MSGIN, | |
| 1184 | + .ep_msg_out = {PCAN_USBPRO_EP_MSGOUT_0, PCAN_USBPRO_EP_MSGOUT_1}, | |
| 1185 | + | |
| 1186 | + /* size of rx/tx usb buffers */ | |
| 1187 | + .rx_buffer_size = PCAN_UFD_RX_BUFFER_SIZE, | |
| 1188 | + .tx_buffer_size = PCAN_UFD_TX_BUFFER_SIZE, | |
| 1189 | + | |
| 1190 | + /* device callbacks */ | |
| 1191 | + .intf_probe = pcan_usb_pro_probe, /* same as PCAN-USB Pro */ | |
| 1192 | + .dev_init = pcan_usb_fd_init, | |
| 1193 | + | |
| 1194 | + .dev_exit = pcan_usb_fd_exit, | |
| 1195 | + .dev_free = pcan_usb_fd_free, | |
| 1196 | + .dev_set_bus = pcan_usb_fd_set_bus, | |
| 1197 | + .dev_set_bittiming = pcan_usb_fd_set_bittiming_slow, | |
| 1198 | + .dev_set_data_bittiming = pcan_usb_fd_set_bittiming_fast, | |
| 1199 | + .dev_decode_buf = pcan_usb_fd_decode_buf, | |
| 1200 | + .dev_start = pcan_usb_fd_start, | |
| 1201 | + .dev_stop = pcan_usb_fd_stop, | |
| 1202 | + .dev_restart_async = pcan_usb_fd_restart_async, | |
| 1203 | + .dev_encode_msg = pcan_usb_fd_encode_msg, | |
| 1204 | + | |
| 1205 | + .do_get_berr_counter = pcan_usb_fd_get_berr_counter, | |
| 1206 | +}; | |
| @@ -400,12 +400,6 @@ static int tse_rx(struct altera_tse_private *priv, int limit) · 399 unmodified lines | ||
| 400 | 400 | |
| 401 | 401 | skb_put(skb, pktlength); |
| 402 | 402 | |
| 403 | − /* make cache consistent with receive packet buffer */ | |
| 404 | − dma_sync_single_for_cpu(priv->device, | |
| 405 | − priv->rx_ring[entry].dma_addr, | |
| 406 | − priv->rx_ring[entry].len, | |
| 407 | − DMA_FROM_DEVICE); | |
| 408 | − | |
| 409 | 403 | dma_unmap_single(priv->device, priv->rx_ring[entry].dma_addr, |
| 410 | 404 | priv->rx_ring[entry].len, DMA_FROM_DEVICE); |
| 411 | 405 | |
| @@ -469,7 +463,6 @@ static int tse_tx_complete(struct altera_tse_private *priv) · 57 unmodified lines | ||
| 469 | 463 | |
| 470 | 464 | if (unlikely(netif_queue_stopped(priv->dev) && |
| 471 | 465 | tse_tx_avail(priv) > TSE_TX_THRESH(priv))) { |
| 472 | − netif_tx_lock(priv->dev); | |
| 473 | 466 | if (netif_queue_stopped(priv->dev) && |
| 474 | 467 | tse_tx_avail(priv) > TSE_TX_THRESH(priv)) { |
| 475 | 468 | if (netif_msg_tx_done(priv)) |
| @@ -477,7 +470,6 @@ static int tse_tx_complete(struct altera_tse_private *priv) · 1 unmodified line | ||
| 477 | 470 | __func__); |
| 478 | 471 | netif_wake_queue(priv->dev); |
| 479 | 472 | } |
| 480 | − netif_tx_unlock(priv->dev); | |
| 481 | 473 | } |
| 482 | 474 | |
| 483 | 475 | spin_unlock(&priv->tx_lock); |
| @@ -592,10 +584,6 @@ static int tse_start_xmit(struct sk_buff *skb, struct net_device *dev) · 108 unmodified lines | ||
| 592 | 584 | buffer->dma_addr = dma_addr; |
| 593 | 585 | buffer->len = nopaged_len; |
| 594 | 586 | |
| 595 | − /* Push data out of the cache hierarchy into main memory */ | |
| 596 | − dma_sync_single_for_device(priv->device, buffer->dma_addr, | |
| 597 | − buffer->len, DMA_TO_DEVICE); | |
| 598 | − | |
| 599 | 587 | priv->dmaops->tx_buffer(priv, buffer); |
| 600 | 588 | |
| 601 | 589 | skb_tx_timestamp(skb); |
| @@ -819,6 +807,8 @@ static int init_phy(struct net_device *dev) · 217 unmodified lines | ||
| 819 | 807 | |
| 820 | 808 | if (!phydev) { |
| 821 | 809 | netdev_err(dev, "Could not find the PHY\n"); |
| 810 | + if (fixed_link) | |
| 811 | + of_phy_deregister_fixed_link(priv->device->of_node); | |
| 822 | 812 | return -ENODEV; |
| 823 | 813 | } |
| 824 | 814 | |
| @@ -1545,10 +1535,15 @@ err_free_netdev: · 720 unmodified lines | ||
| 1545 | 1535 | static int altera_tse_remove(struct platform_device *pdev) |
| 1546 | 1536 | { |
| 1547 | 1537 | struct net_device *ndev = platform_get_drvdata(pdev); |
| 1538 | + struct altera_tse_private *priv = netdev_priv(ndev); | |
| 1548 | 1539 | |
| 1549 | − if (ndev->phydev) | |
| 1540 | + if (ndev->phydev) { | |
| 1550 | 1541 | phy_disconnect(ndev->phydev); |
| 1551 | 1542 | |
| 1543 | + if (of_phy_is_fixed_link(priv->device->of_node)) | |
| 1544 | + of_phy_deregister_fixed_link(priv->device->of_node); | |
| 1545 | + } | |
| 1546 | + | |
| 1552 | 1547 | platform_set_drvdata(pdev, NULL); |
| 1553 | 1548 | altera_tse_mdio_destroy(ndev); |
| 1554 | 1549 | unregister_netdev(ndev); |
| @@ -829,7 +829,7 @@ static int xgbe_remove(struct platform_device *pdev) · 828 unmodified lines | ||
| 829 | 829 | return 0; |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | −#ifdef CONFIG_PM | |
| 832 | +#ifdef CONFIG_PM_SLEEP | |
| 833 | 833 | static int xgbe_suspend(struct device *dev) |
| 834 | 834 | { |
| 835 | 835 | struct net_device *netdev = dev_get_drvdata(dev); |
| @@ -874,7 +874,7 @@ static int xgbe_resume(struct device *dev) · 38 unmodified lines | ||
| 874 | 874 | |
| 875 | 875 | return ret; |
| 876 | 876 | } |
| 877 | −#endif /* CONFIG_PM */ | |
| 877 | +#endif /* CONFIG_PM_SLEEP */ | |
| 878 | 878 | |
| 879 | 879 | #ifdef CONFIG_ACPI |
| 880 | 880 | static const struct acpi_device_id xgbe_acpi_match[] = { |
| @@ -1466,12 +1466,12 @@ static int nb8800_probe(struct platform_device *pdev) · 1465 unmodified lines | ||
| 1466 | 1466 | |
| 1467 | 1467 | ret = nb8800_hw_init(dev); |
| 1468 | 1468 | if (ret) |
| 1469 | − goto err_free_bus; | |
| 1469 | + goto err_deregister_fixed_link; | |
| 1470 | 1470 | |
| 1471 | 1471 | if (ops && ops->init) { |
| 1472 | 1472 | ret = ops->init(dev); |
| 1473 | 1473 | if (ret) |
| 1474 | − goto err_free_bus; | |
| 1474 | + goto err_deregister_fixed_link; | |
| 1475 | 1475 | } |
| 1476 | 1476 | |
| 1477 | 1477 | dev->netdev_ops = &nb8800_netdev_ops; |
| @@ -1504,6 +1504,9 @@ static int nb8800_probe(struct platform_device *pdev) · 26 unmodified lines | ||
| 1504 | 1504 | |
| 1505 | 1505 | err_free_dma: |
| 1506 | 1506 | nb8800_dma_free(dev); |
| 1507 | +err_deregister_fixed_link: | |
| 1508 | + if (of_phy_is_fixed_link(pdev->dev.of_node)) | |
| 1509 | + of_phy_deregister_fixed_link(pdev->dev.of_node); | |
| 1507 | 1510 | err_free_bus: |
| 1508 | 1511 | of_node_put(priv->phy_node); |
| 1509 | 1512 | mdiobus_unregister(bus); |
| @@ -1521,6 +1524,8 @@ static int nb8800_remove(struct platform_device *pdev) · 11 unmodified lines | ||
| 1521 | 1524 | struct nb8800_priv *priv = netdev_priv(ndev); |
| 1522 | 1525 | |
| 1523 | 1526 | unregister_netdev(ndev); |
| 1527 | + if (of_phy_is_fixed_link(pdev->dev.of_node)) | |
| 1528 | + of_phy_deregister_fixed_link(pdev->dev.of_node); | |
| 1524 | 1529 | of_node_put(priv->phy_node); |
| 1525 | 1530 | |
| 1526 | 1531 | mdiobus_unregister(priv->mii_bus); |
| @@ -1755,13 +1755,13 @@ static int bcm_sysport_probe(struct platform_device *pdev) · 1754 unmodified lines | ||
| 1755 | 1755 | if (priv->irq0 <= 0 || priv->irq1 <= 0) { |
| 1756 | 1756 | dev_err(&pdev->dev, "invalid interrupts\n"); |
| 1757 | 1757 | ret = -EINVAL; |
| 1758 | − goto err; | |
| 1758 | + goto err_free_netdev; | |
| 1759 | 1759 | } |
| 1760 | 1760 | |
| 1761 | 1761 | priv->base = devm_ioremap_resource(&pdev->dev, r); |
| 1762 | 1762 | if (IS_ERR(priv->base)) { |
| 1763 | 1763 | ret = PTR_ERR(priv->base); |
| 1764 | − goto err; | |
| 1764 | + goto err_free_netdev; | |
| 1765 | 1765 | } |
| 1766 | 1766 | |
| 1767 | 1767 | priv->netdev = dev; |
| @@ -1779,7 +1779,7 @@ static int bcm_sysport_probe(struct platform_device *pdev) · 11 unmodified lines | ||
| 1779 | 1779 | ret = of_phy_register_fixed_link(dn); |
| 1780 | 1780 | if (ret) { |
| 1781 | 1781 | dev_err(&pdev->dev, "failed to register fixed PHY\n"); |
| 1782 | − goto err; | |
| 1782 | + goto err_free_netdev; | |
| 1783 | 1783 | } |
| 1784 | 1784 | |
| 1785 | 1785 | priv->phy_dn = dn; |
| @@ -1821,7 +1821,7 @@ static int bcm_sysport_probe(struct platform_device *pdev) · 35 unmodified lines | ||
| 1821 | 1821 | ret = register_netdev(dev); |
| 1822 | 1822 | if (ret) { |
| 1823 | 1823 | dev_err(&pdev->dev, "failed to register net_device\n"); |
| 1824 | − goto err; | |
| 1824 | + goto err_deregister_fixed_link; | |
| 1825 | 1825 | } |
| 1826 | 1826 | |
| 1827 | 1827 | priv->rev = topctrl_readl(priv, REV_CNTL) & REV_MASK; |
| @@ -1832,7 +1832,11 @@ static int bcm_sysport_probe(struct platform_device *pdev) · 4 unmodified lines | ||
| 1832 | 1832 | priv->base, priv->irq0, priv->irq1, txq, rxq); |
| 1833 | 1833 | |
| 1834 | 1834 | return 0; |
| 1835 | −err: | |
| 1835 | + | |
| 1836 | +err_deregister_fixed_link: | |
| 1837 | + if (of_phy_is_fixed_link(dn)) | |
| 1838 | + of_phy_deregister_fixed_link(dn); | |
| 1839 | +err_free_netdev: | |
| 1836 | 1840 | free_netdev(dev); |
| 1837 | 1841 | return ret; |
| 1838 | 1842 | } |
| @@ -1840,11 +1844,14 @@ err: · 1 unmodified line | ||
| 1840 | 1844 | static int bcm_sysport_remove(struct platform_device *pdev) |
| 1841 | 1845 | { |
| 1842 | 1846 | struct net_device *dev = dev_get_drvdata(&pdev->dev); |
| 1847 | + struct device_node *dn = pdev->dev.of_node; | |
| 1843 | 1848 | |
| 1844 | 1849 | /* Not much to do, ndo_close has been called |
| 1845 | 1850 | * and we use managed allocations |
| 1846 | 1851 | */ |
| 1847 | 1852 | unregister_netdev(dev); |
| 1853 | + if (of_phy_is_fixed_link(dn)) | |
| 1854 | + of_phy_deregister_fixed_link(dn); | |
| 1848 | 1855 | free_netdev(dev); |
| 1849 | 1856 | dev_set_drvdata(&pdev->dev, NULL); |
| 1850 | 1857 | |
| @@ -1172,6 +1172,7 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev, · 1171 unmodified lines | ||
| 1172 | 1172 | struct bcmgenet_tx_ring *ring) |
| 1173 | 1173 | { |
| 1174 | 1174 | struct bcmgenet_priv *priv = netdev_priv(dev); |
| 1175 | + struct device *kdev = &priv->pdev->dev; | |
| 1175 | 1176 | struct enet_cb *tx_cb_ptr; |
| 1176 | 1177 | struct netdev_queue *txq; |
| 1177 | 1178 | unsigned int pkts_compl = 0; |
| @@ -1199,13 +1200,13 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev, · 21 unmodified lines | ||
| 1199 | 1200 | if (tx_cb_ptr->skb) { |
| 1200 | 1201 | pkts_compl++; |
| 1201 | 1202 | bytes_compl += GENET_CB(tx_cb_ptr->skb)->bytes_sent; |
| 1202 | − dma_unmap_single(&dev->dev, | |
| 1203 | + dma_unmap_single(kdev, | |
| 1203 | 1204 | dma_unmap_addr(tx_cb_ptr, dma_addr), |
| 1204 | 1205 | dma_unmap_len(tx_cb_ptr, dma_len), |
| 1205 | 1206 | DMA_TO_DEVICE); |
| 1206 | 1207 | bcmgenet_free_cb(tx_cb_ptr); |
| 1207 | 1208 | } else if (dma_unmap_addr(tx_cb_ptr, dma_addr)) { |
| 1208 | − dma_unmap_page(&dev->dev, | |
| 1209 | + dma_unmap_page(kdev, | |
| 1209 | 1210 | dma_unmap_addr(tx_cb_ptr, dma_addr), |
| 1210 | 1211 | dma_unmap_len(tx_cb_ptr, dma_len), |
| 1211 | 1212 | DMA_TO_DEVICE); |
| @@ -1775,6 +1776,7 @@ static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv, · 563 unmodified lines | ||
| 1775 | 1776 | |
| 1776 | 1777 | static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv) |
| 1777 | 1778 | { |
| 1779 | + struct device *kdev = &priv->pdev->dev; | |
| 1778 | 1780 | struct enet_cb *cb; |
| 1779 | 1781 | int i; |
| 1780 | 1782 | |
| @@ -1782,7 +1784,7 @@ static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv) · 1 unmodified line | ||
| 1782 | 1784 | cb = &priv->rx_cbs[i]; |
| 1783 | 1785 | |
| 1784 | 1786 | if (dma_unmap_addr(cb, dma_addr)) { |
| 1785 | − dma_unmap_single(&priv->dev->dev, | |
| 1787 | + dma_unmap_single(kdev, | |
| 1786 | 1788 | dma_unmap_addr(cb, dma_addr), |
| 1787 | 1789 | priv->rx_buf_len, DMA_FROM_DEVICE); |
| 1788 | 1790 | dma_unmap_addr_set(cb, dma_addr, 0); |
| @@ -542,8 +542,10 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv) · 541 unmodified lines | ||
| 542 | 542 | /* Make sure we initialize MoCA PHYs with a link down */ |
| 543 | 543 | if (phy_mode == PHY_INTERFACE_MODE_MOCA) { |
| 544 | 544 | phydev = of_phy_find_device(dn); |
| 545 | − if (phydev) | |
| 545 | + if (phydev) { | |
| 546 | 546 | phydev->link = 0; |
| 547 | + put_device(&phydev->mdio.dev); | |
| 548 | + } | |
| 547 | 549 | } |
| 548 | 550 | |
| 549 | 551 | return 0; |
| @@ -625,6 +627,7 @@ static int bcmgenet_mii_bus_init(struct bcmgenet_priv *priv) · 75 unmodified lines | ||
| 625 | 627 | int bcmgenet_mii_init(struct net_device *dev) |
| 626 | 628 | { |
| 627 | 629 | struct bcmgenet_priv *priv = netdev_priv(dev); |
| 630 | + struct device_node *dn = priv->pdev->dev.of_node; | |
| 628 | 631 | int ret; |
| 629 | 632 | |
| 630 | 633 | ret = bcmgenet_mii_alloc(priv); |
| @@ -638,6 +641,8 @@ int bcmgenet_mii_init(struct net_device *dev) · 7 unmodified lines | ||
| 638 | 641 | return 0; |
| 639 | 642 | |
| 640 | 643 | out: |
| 644 | + if (of_phy_is_fixed_link(dn)) | |
| 645 | + of_phy_deregister_fixed_link(dn); | |
| 641 | 646 | of_node_put(priv->phy_dn); |
| 642 | 647 | mdiobus_unregister(priv->mii_bus); |
| 643 | 648 | mdiobus_free(priv->mii_bus); |
| @@ -647,7 +652,10 @@ out: · 3 unmodified lines | ||
| 647 | 652 | void bcmgenet_mii_exit(struct net_device *dev) |
| 648 | 653 | { |
| 649 | 654 | struct bcmgenet_priv *priv = netdev_priv(dev); |
| 655 | + struct device_node *dn = priv->pdev->dev.of_node; | |
| 650 | 656 | |
| 657 | + if (of_phy_is_fixed_link(dn)) | |
| 658 | + of_phy_deregister_fixed_link(dn); | |
| 651 | 659 | of_node_put(priv->phy_dn); |
| 652 | 660 | mdiobus_unregister(priv->mii_bus); |
| 653 | 661 | mdiobus_free(priv->mii_bus); |
| @@ -975,6 +975,7 @@ static inline void macb_init_rx_ring(struct macb *bp) · 974 unmodified lines | ||
| 975 | 975 | addr += bp->rx_buffer_size; |
| 976 | 976 | } |
| 977 | 977 | bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP); |
| 978 | + bp->rx_tail = 0; | |
| 978 | 979 | } |
| 979 | 980 | |
| 980 | 981 | static int macb_rx(struct macb *bp, int budget) |
| @@ -1156,6 +1157,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) · 175 unmodified lines | ||
| 1156 | 1157 | if (status & MACB_BIT(RXUBR)) { |
| 1157 | 1158 | ctrl = macb_readl(bp, NCR); |
| 1158 | 1159 | macb_writel(bp, NCR, ctrl & ~MACB_BIT(RE)); |
| 1160 | + wmb(); | |
| 1159 | 1161 | macb_writel(bp, NCR, ctrl | MACB_BIT(RE)); |
| 1160 | 1162 | |
| 1161 | 1163 | if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE) |
| @@ -1616,8 +1618,6 @@ static void macb_init_rings(struct macb *bp) · 454 unmodified lines | ||
| 1616 | 1618 | bp->queues[0].tx_head = 0; |
| 1617 | 1619 | bp->queues[0].tx_tail = 0; |
| 1618 | 1620 | bp->queues[0].tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP); |
| 1619 | − | |
| 1620 | − bp->rx_tail = 0; | |
| 1621 | 1621 | } |
| 1622 | 1622 | |
| 1623 | 1623 | static void macb_reset_hw(struct macb *bp) |
| @@ -2770,6 +2770,7 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id) · 1146 unmodified lines | ||
| 2770 | 2770 | if (intstatus & MACB_BIT(RXUBR)) { |
| 2771 | 2771 | ctl = macb_readl(lp, NCR); |
| 2772 | 2772 | macb_writel(lp, NCR, ctl & ~MACB_BIT(RE)); |
| 2773 | + wmb(); | |
| 2773 | 2774 | macb_writel(lp, NCR, ctl | MACB_BIT(RE)); |
| 2774 | 2775 | } |
| 2775 | 2776 | |
| @@ -168,6 +168,7 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN · 167 unmodified lines | ||
| 168 | 168 | CH_PCI_ID_TABLE_FENTRY(0x509a), /* Custom T520-CR */ |
| 169 | 169 | CH_PCI_ID_TABLE_FENTRY(0x509b), /* Custom T540-CR LOM */ |
| 170 | 170 | CH_PCI_ID_TABLE_FENTRY(0x509c), /* Custom T520-CR*/ |
| 171 | + CH_PCI_ID_TABLE_FENTRY(0x509d), /* Custom T540-CR*/ | |
| 171 | 172 | |
| 172 | 173 | /* T6 adapters: |
| 173 | 174 | */ |
| @@ -574,6 +574,8 @@ struct fec_enet_private { · 573 unmodified lines | ||
| 574 | 574 | unsigned int reload_period; |
| 575 | 575 | int pps_enable; |
| 576 | 576 | unsigned int next_counter; |
| 577 | + | |
| 578 | + u64 ethtool_stats[0]; | |
| 577 | 579 | }; |
| 578 | 580 | |
| 579 | 581 | void fec_ptp_init(struct platform_device *pdev); |
| @@ -2313,14 +2313,24 @@ static const struct fec_stat { · 2312 unmodified lines | ||
| 2313 | 2313 | { "IEEE_rx_octets_ok", IEEE_R_OCTETS_OK }, |
| 2314 | 2314 | }; |
| 2315 | 2315 | |
| 2316 | −static void fec_enet_get_ethtool_stats(struct net_device *dev, | |
| 2317 | − struct ethtool_stats *stats, u64 *data) | |
| 2316 | +static void fec_enet_update_ethtool_stats(struct net_device *dev) | |
| 2318 | 2317 | { |
| 2319 | 2318 | struct fec_enet_private *fep = netdev_priv(dev); |
| 2320 | 2319 | int i; |
| 2321 | 2320 | |
| 2322 | 2321 | for (i = 0; i < ARRAY_SIZE(fec_stats); i++) |
| 2323 | − data[i] = readl(fep->hwp + fec_stats[i].offset); | |
| 2322 | + fep->ethtool_stats[i] = readl(fep->hwp + fec_stats[i].offset); | |
| 2323 | +} | |
| 2324 | + | |
| 2325 | +static void fec_enet_get_ethtool_stats(struct net_device *dev, | |
| 2326 | + struct ethtool_stats *stats, u64 *data) | |
| 2327 | +{ | |
| 2328 | + struct fec_enet_private *fep = netdev_priv(dev); | |
| 2329 | + | |
| 2330 | + if (netif_running(dev)) | |
| 2331 | + fec_enet_update_ethtool_stats(dev); | |
| 2332 | + | |
| 2333 | + memcpy(data, fep->ethtool_stats, ARRAY_SIZE(fec_stats) * sizeof(u64)); | |
| 2324 | 2334 | } |
| 2325 | 2335 | |
| 2326 | 2336 | static void fec_enet_get_strings(struct net_device *netdev, |
| @@ -2874,6 +2884,8 @@ fec_enet_close(struct net_device *ndev) · 547 unmodified lines | ||
| 2874 | 2884 | if (fep->quirks & FEC_QUIRK_ERR006687) |
| 2875 | 2885 | imx6q_cpuidle_fec_irqs_unused(); |
| 2876 | 2886 | |
| 2887 | + fec_enet_update_ethtool_stats(ndev); | |
| 2888 | + | |
| 2877 | 2889 | fec_enet_clk_enable(ndev, false); |
| 2878 | 2890 | pinctrl_pm_select_sleep_state(&fep->pdev->dev); |
| 2879 | 2891 | pm_runtime_mark_last_busy(&fep->pdev->dev); |
| @@ -3180,6 +3192,8 @@ static int fec_enet_init(struct net_device *ndev) · 300 unmodified lines | ||
| 3180 | 3192 | |
| 3181 | 3193 | fec_restart(ndev); |
| 3182 | 3194 | |
| 3195 | + fec_enet_update_ethtool_stats(ndev); | |
| 3196 | + | |
| 3183 | 3197 | return 0; |
| 3184 | 3198 | } |
| 3185 | 3199 | |
| @@ -3278,7 +3292,8 @@ fec_probe(struct platform_device *pdev) · 92 unmodified lines | ||
| 3278 | 3292 | fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs); |
| 3279 | 3293 | |
| 3280 | 3294 | /* Init network device */ |
| 3281 | − ndev = alloc_etherdev_mqs(sizeof(struct fec_enet_private), | |
| 3295 | + ndev = alloc_etherdev_mqs(sizeof(struct fec_enet_private) + | |
| 3296 | + ARRAY_SIZE(fec_stats) * sizeof(u64), | |
| 3282 | 3297 | num_tx_qs, num_rx_qs); |
| 3283 | 3298 | if (!ndev) |
| 3284 | 3299 | return -ENOMEM; |
| @@ -3475,6 +3490,8 @@ failed_regulator: · 190 unmodified lines | ||
| 3475 | 3490 | failed_clk_ipg: |
| 3476 | 3491 | fec_enet_clk_enable(ndev, false); |
| 3477 | 3492 | failed_clk: |
| 3493 | + if (of_phy_is_fixed_link(np)) | |
| 3494 | + of_phy_deregister_fixed_link(np); | |
| 3478 | 3495 | failed_phy: |
| 3479 | 3496 | of_node_put(phy_node); |
| 3480 | 3497 | failed_ioremap: |
| @@ -3488,6 +3505,7 @@ fec_drv_remove(struct platform_device *pdev) · 7 unmodified lines | ||
| 3488 | 3505 | { |
| 3489 | 3506 | struct net_device *ndev = platform_get_drvdata(pdev); |
| 3490 | 3507 | struct fec_enet_private *fep = netdev_priv(ndev); |
| 3508 | + struct device_node *np = pdev->dev.of_node; | |
| 3491 | 3509 | |
| 3492 | 3510 | cancel_work_sync(&fep->tx_timeout_work); |
| 3493 | 3511 | fec_ptp_stop(pdev); |
| @@ -3495,6 +3513,8 @@ fec_drv_remove(struct platform_device *pdev) · 1 unmodified line | ||
| 3495 | 3513 | fec_enet_mii_remove(fep); |
| 3496 | 3514 | if (fep->reg_phy) |
| 3497 | 3515 | regulator_disable(fep->reg_phy); |
| 3516 | + if (of_phy_is_fixed_link(np)) | |
| 3517 | + of_phy_deregister_fixed_link(np); | |
| 3498 | 3518 | of_node_put(fep->phy_node); |
| 3499 | 3519 | free_netdev(ndev); |
| 3500 | 3520 | |
| @@ -1107,6 +1107,9 @@ int memac_free(struct fman_mac *memac) · 1106 unmodified lines | ||
| 1107 | 1107 | { |
| 1108 | 1108 | free_init_resources(memac); |
| 1109 | 1109 | |
| 1110 | + if (memac->pcsphy) | |
| 1111 | + put_device(&memac->pcsphy->mdio.dev); | |
| 1112 | + | |
| 1110 | 1113 | kfree(memac->memac_drv_param); |
| 1111 | 1114 | kfree(memac); |
| 1112 | 1115 | |
| @@ -892,6 +892,8 @@ static int mac_probe(struct platform_device *_of_dev) · 891 unmodified lines | ||
| 892 | 892 | priv->fixed_link->duplex = phy->duplex; |
| 893 | 893 | priv->fixed_link->pause = phy->pause; |
| 894 | 894 | priv->fixed_link->asym_pause = phy->asym_pause; |
| 895 | + | |
| 896 | + put_device(&phy->mdio.dev); | |
| 895 | 897 | } |
| 896 | 898 | |
| 897 | 899 | err = mac_dev->init(mac_dev); |
| @@ -980,7 +980,7 @@ static int fs_enet_probe(struct platform_device *ofdev) · 979 unmodified lines | ||
| 980 | 980 | err = clk_prepare_enable(clk); |
| 981 | 981 | if (err) { |
| 982 | 982 | ret = err; |
| 983 | − goto out_free_fpi; | |
| 983 | + goto out_deregister_fixed_link; | |
| 984 | 984 | } |
| 985 | 985 | fpi->clk_per = clk; |
| 986 | 986 | } |
| @@ -1061,6 +1061,9 @@ out_put: · 74 unmodified lines | ||
| 1061 | 1061 | of_node_put(fpi->phy_node); |
| 1062 | 1062 | if (fpi->clk_per) |
| 1063 | 1063 | clk_disable_unprepare(fpi->clk_per); |
| 1064 | +out_deregister_fixed_link: | |
| 1065 | + if (of_phy_is_fixed_link(ofdev->dev.of_node)) | |
| 1066 | + of_phy_deregister_fixed_link(ofdev->dev.of_node); | |
| 1064 | 1067 | out_free_fpi: |
| 1065 | 1068 | kfree(fpi); |
| 1066 | 1069 | return ret; |
| @@ -1079,6 +1082,8 @@ static int fs_enet_remove(struct platform_device *ofdev) · 12 unmodified lines | ||
| 1079 | 1082 | of_node_put(fep->fpi->phy_node); |
| 1080 | 1083 | if (fep->fpi->clk_per) |
| 1081 | 1084 | clk_disable_unprepare(fep->fpi->clk_per); |
| 1085 | + if (of_phy_is_fixed_link(ofdev->dev.of_node)) | |
| 1086 | + of_phy_deregister_fixed_link(ofdev->dev.of_node); | |
| 1082 | 1087 | free_netdev(ndev); |
| 1083 | 1088 | return 0; |
| 1084 | 1089 | } |
| @@ -1312,6 +1312,7 @@ static void gfar_init_addr_hash_table(struct gfar_private *priv) · 1311 unmodified lines | ||
| 1312 | 1312 | */ |
| 1313 | 1313 | static int gfar_probe(struct platform_device *ofdev) |
| 1314 | 1314 | { |
| 1315 | + struct device_node *np = ofdev->dev.of_node; | |
| 1315 | 1316 | struct net_device *dev = NULL; |
| 1316 | 1317 | struct gfar_private *priv = NULL; |
| 1317 | 1318 | int err = 0, i; |
| @@ -1462,6 +1463,8 @@ static int gfar_probe(struct platform_device *ofdev) · 144 unmodified lines | ||
| 1462 | 1463 | return 0; |
| 1463 | 1464 | |
| 1464 | 1465 | register_fail: |
| 1466 | + if (of_phy_is_fixed_link(np)) | |
| 1467 | + of_phy_deregister_fixed_link(np); | |
| 1465 | 1468 | unmap_group_regs(priv); |
| 1466 | 1469 | gfar_free_rx_queues(priv); |
| 1467 | 1470 | gfar_free_tx_queues(priv); |
| @@ -1474,11 +1477,16 @@ register_fail: · 6 unmodified lines | ||
| 1474 | 1477 | static int gfar_remove(struct platform_device *ofdev) |
| 1475 | 1478 | { |
| 1476 | 1479 | struct gfar_private *priv = platform_get_drvdata(ofdev); |
| 1480 | + struct device_node *np = ofdev->dev.of_node; | |
| 1477 | 1481 | |
| 1478 | 1482 | of_node_put(priv->phy_node); |
| 1479 | 1483 | of_node_put(priv->tbi_node); |
| 1480 | 1484 | |
| 1481 | 1485 | unregister_netdev(priv->ndev); |
| 1486 | + | |
| 1487 | + if (of_phy_is_fixed_link(np)) | |
| 1488 | + of_phy_deregister_fixed_link(np); | |
| 1489 | + | |
| 1482 | 1490 | unmap_group_regs(priv); |
| 1483 | 1491 | gfar_free_rx_queues(priv); |
| 1484 | 1492 | gfar_free_tx_queues(priv); |
| @@ -3868,9 +3868,8 @@ static int ucc_geth_probe(struct platform_device* ofdev) · 3867 unmodified lines | ||
| 3868 | 3868 | dev = alloc_etherdev(sizeof(*ugeth)); |
| 3869 | 3869 | |
| 3870 | 3870 | if (dev == NULL) { |
| 3871 | − of_node_put(ug_info->tbi_node); | |
| 3872 | − of_node_put(ug_info->phy_node); | |
| 3873 | − return -ENOMEM; | |
| 3871 | + err = -ENOMEM; | |
| 3872 | + goto err_deregister_fixed_link; | |
| 3874 | 3873 | } |
| 3875 | 3874 | |
| 3876 | 3875 | ugeth = netdev_priv(dev); |
| @@ -3907,10 +3906,7 @@ static int ucc_geth_probe(struct platform_device* ofdev) · 30 unmodified lines | ||
| 3907 | 3906 | if (netif_msg_probe(ugeth)) |
| 3908 | 3907 | pr_err("%s: Cannot register net device, aborting\n", |
| 3909 | 3908 | dev->name); |
| 3910 | − free_netdev(dev); | |
| 3911 | − of_node_put(ug_info->tbi_node); | |
| 3912 | − of_node_put(ug_info->phy_node); | |
| 3913 | − return err; | |
| 3909 | + goto err_free_netdev; | |
| 3914 | 3910 | } |
| 3915 | 3911 | |
| 3916 | 3912 | mac_addr = of_get_mac_address(np); |
| @@ -3923,16 +3919,29 @@ static int ucc_geth_probe(struct platform_device* ofdev) · 6 unmodified lines | ||
| 3923 | 3919 | ugeth->node = np; |
| 3924 | 3920 | |
| 3925 | 3921 | return 0; |
| 3922 | + | |
| 3923 | +err_free_netdev: | |
| 3924 | + free_netdev(dev); | |
| 3925 | +err_deregister_fixed_link: | |
| 3926 | + if (of_phy_is_fixed_link(np)) | |
| 3927 | + of_phy_deregister_fixed_link(np); | |
| 3928 | + of_node_put(ug_info->tbi_node); | |
| 3929 | + of_node_put(ug_info->phy_node); | |
| 3930 | + | |
| 3931 | + return err; | |
| 3926 | 3932 | } |
| 3927 | 3933 | |
| 3928 | 3934 | static int ucc_geth_remove(struct platform_device* ofdev) |
| 3929 | 3935 | { |
| 3930 | 3936 | struct net_device *dev = platform_get_drvdata(ofdev); |
| 3931 | 3937 | struct ucc_geth_private *ugeth = netdev_priv(dev); |
| 3938 | + struct device_node *np = ofdev->dev.of_node; | |
| 3932 | 3939 | |
| 3933 | 3940 | unregister_netdev(dev); |
| 3934 | 3941 | free_netdev(dev); |
| 3935 | 3942 | ucc_geth_memclean(ugeth); |
| 3943 | + if (of_phy_is_fixed_link(np)) | |
| 3944 | + of_phy_deregister_fixed_link(np); | |
| 3936 | 3945 | of_node_put(ugeth->ug_info->tbi_node); |
| 3937 | 3946 | of_node_put(ugeth->ug_info->phy_node); |
| 3938 | 3947 | |
| @@ -4931,11 +4931,15 @@ static int igb_tso(struct igb_ring *tx_ring, · 4930 unmodified lines | ||
| 4931 | 4931 | |
| 4932 | 4932 | /* initialize outer IP header fields */ |
| 4933 | 4933 | if (ip.v4->version == 4) { |
| 4934 | + unsigned char *csum_start = skb_checksum_start(skb); | |
| 4935 | + unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4); | |
| 4936 | + | |
| 4934 | 4937 | /* IP header will have to cancel out any data that |
| 4935 | 4938 | * is not a part of the outer IP header |
| 4936 | 4939 | */ |
| 4937 | − ip.v4->check = csum_fold(csum_add(lco_csum(skb), | |
| 4938 | − csum_unfold(l4.tcp->check))); | |
| 4940 | + ip.v4->check = csum_fold(csum_partial(trans_start, | |
| 4941 | + csum_start - trans_start, | |
| 4942 | + 0)); | |
| 4939 | 4943 | type_tucmd |= E1000_ADVTXD_TUCMD_IPV4; |
| 4940 | 4944 | |
| 4941 | 4945 | ip.v4->tot_len = 0; |
| @@ -1965,11 +1965,15 @@ static int igbvf_tso(struct igbvf_ring *tx_ring, · 1964 unmodified lines | ||
| 1965 | 1965 | |
| 1966 | 1966 | /* initialize outer IP header fields */ |
| 1967 | 1967 | if (ip.v4->version == 4) { |
| 1968 | + unsigned char *csum_start = skb_checksum_start(skb); | |
| 1969 | + unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4); | |
| 1970 | + | |
| 1968 | 1971 | /* IP header will have to cancel out any data that |
| 1969 | 1972 | * is not a part of the outer IP header |
| 1970 | 1973 | */ |
| 1971 | − ip.v4->check = csum_fold(csum_add(lco_csum(skb), | |
| 1972 | − csum_unfold(l4.tcp->check))); | |
| 1974 | + ip.v4->check = csum_fold(csum_partial(trans_start, | |
| 1975 | + csum_start - trans_start, | |
| 1976 | + 0)); | |
| 1973 | 1977 | type_tucmd |= E1000_ADVTXD_TUCMD_IPV4; |
| 1974 | 1978 | |
| 1975 | 1979 | ip.v4->tot_len = 0; |
| @@ -7277,11 +7277,15 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring, · 7276 unmodified lines | ||
| 7277 | 7277 | |
| 7278 | 7278 | /* initialize outer IP header fields */ |
| 7279 | 7279 | if (ip.v4->version == 4) { |
| 7280 | + unsigned char *csum_start = skb_checksum_start(skb); | |
| 7281 | + unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4); | |
| 7282 | + | |
| 7280 | 7283 | /* IP header will have to cancel out any data that |
| 7281 | 7284 | * is not a part of the outer IP header |
| 7282 | 7285 | */ |
| 7283 | − ip.v4->check = csum_fold(csum_add(lco_csum(skb), | |
| 7284 | − csum_unfold(l4.tcp->check))); | |
| 7286 | + ip.v4->check = csum_fold(csum_partial(trans_start, | |
| 7287 | + csum_start - trans_start, | |
| 7288 | + 0)); | |
| 7285 | 7289 | type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; |
| 7286 | 7290 | |
| 7287 | 7291 | ip.v4->tot_len = 0; |
| @@ -3329,11 +3329,15 @@ static int ixgbevf_tso(struct ixgbevf_ring *tx_ring, · 3328 unmodified lines | ||
| 3329 | 3329 | |
| 3330 | 3330 | /* initialize outer IP header fields */ |
| 3331 | 3331 | if (ip.v4->version == 4) { |
| 3332 | + unsigned char *csum_start = skb_checksum_start(skb); | |
| 3333 | + unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4); | |
| 3334 | + | |
| 3332 | 3335 | /* IP header will have to cancel out any data that |
| 3333 | 3336 | * is not a part of the outer IP header |
| 3334 | 3337 | */ |
| 3335 | − ip.v4->check = csum_fold(csum_add(lco_csum(skb), | |
| 3336 | − csum_unfold(l4.tcp->check))); | |
| 3338 | + ip.v4->check = csum_fold(csum_partial(trans_start, | |
| 3339 | + csum_start - trans_start, | |
| 3340 | + 0)); | |
| 3337 | 3341 | type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; |
| 3338 | 3342 | |
| 3339 | 3343 | ip.v4->tot_len = 0; |
| @@ -4191,6 +4191,8 @@ err_clk: · 4190 unmodified lines | ||
| 4191 | 4191 | clk_disable_unprepare(pp->clk); |
| 4192 | 4192 | err_put_phy_node: |
| 4193 | 4193 | of_node_put(phy_node); |
| 4194 | + if (of_phy_is_fixed_link(dn)) | |
| 4195 | + of_phy_deregister_fixed_link(dn); | |
| 4194 | 4196 | err_free_irq: |
| 4195 | 4197 | irq_dispose_mapping(dev->irq); |
| 4196 | 4198 | err_free_netdev: |
| @@ -4202,6 +4204,7 @@ err_free_netdev: · 5 unmodified lines | ||
| 4202 | 4204 | static int mvneta_remove(struct platform_device *pdev) |
| 4203 | 4205 | { |
| 4204 | 4206 | struct net_device *dev = platform_get_drvdata(pdev); |
| 4207 | + struct device_node *dn = pdev->dev.of_node; | |
| 4205 | 4208 | struct mvneta_port *pp = netdev_priv(dev); |
| 4206 | 4209 | |
| 4207 | 4210 | unregister_netdev(dev); |
| @@ -4209,6 +4212,8 @@ static int mvneta_remove(struct platform_device *pdev) · 1 unmodified line | ||
| 4209 | 4212 | clk_disable_unprepare(pp->clk); |
| 4210 | 4213 | free_percpu(pp->ports); |
| 4211 | 4214 | free_percpu(pp->stats); |
| 4215 | + if (of_phy_is_fixed_link(dn)) | |
| 4216 | + of_phy_deregister_fixed_link(dn); | |
| 4212 | 4217 | irq_dispose_mapping(dev->irq); |
| 4213 | 4218 | of_node_put(pp->phy_node); |
| 4214 | 4219 | free_netdev(dev); |
| @@ -318,6 +318,8 @@ static int mtk_phy_connect(struct net_device *dev) · 317 unmodified lines | ||
| 318 | 318 | return 0; |
| 319 | 319 | |
| 320 | 320 | err_phy: |
| 321 | + if (of_phy_is_fixed_link(mac->of_node)) | |
| 322 | + of_phy_deregister_fixed_link(mac->of_node); | |
| 321 | 323 | of_node_put(np); |
| 322 | 324 | dev_err(eth->dev, "%s: invalid phy\n", __func__); |
| 323 | 325 | return -EINVAL; |
| @@ -1923,6 +1925,8 @@ static void mtk_uninit(struct net_device *dev) · 1599 unmodified lines | ||
| 1923 | 1925 | struct mtk_eth *eth = mac->hw; |
| 1924 | 1926 | |
| 1925 | 1927 | phy_disconnect(dev->phydev); |
| 1928 | + if (of_phy_is_fixed_link(mac->of_node)) | |
| 1929 | + of_phy_deregister_fixed_link(mac->of_node); | |
| 1926 | 1930 | mtk_irq_disable(eth, MTK_QDMA_INT_MASK, ~0); |
| 1927 | 1931 | mtk_irq_disable(eth, MTK_PDMA_INT_MASK, ~0); |
| 1928 | 1932 | } |
| @@ -2079,13 +2079,6 @@ err: · 2078 unmodified lines | ||
| 2079 | 2079 | return -ENOMEM; |
| 2080 | 2080 | } |
| 2081 | 2081 | |
| 2082 | −static void mlx4_en_shutdown(struct net_device *dev) | |
| 2083 | −{ | |
| 2084 | − rtnl_lock(); | |
| 2085 | − netif_device_detach(dev); | |
| 2086 | − mlx4_en_close(dev); | |
| 2087 | − rtnl_unlock(); | |
| 2088 | −} | |
| 2089 | 2082 | |
| 2090 | 2083 | static int mlx4_en_copy_priv(struct mlx4_en_priv *dst, |
| 2091 | 2084 | struct mlx4_en_priv *src, |
| @@ -2162,8 +2155,6 @@ void mlx4_en_destroy_netdev(struct net_device *dev) · 70 unmodified lines | ||
| 2162 | 2155 | { |
| 2163 | 2156 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 2164 | 2157 | struct mlx4_en_dev *mdev = priv->mdev; |
| 2165 | − bool shutdown = mdev->dev->persist->interface_state & | |
| 2166 | − MLX4_INTERFACE_STATE_SHUTDOWN; | |
| 2167 | 2158 | |
| 2168 | 2159 | en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port); |
| 2169 | 2160 | |
| @@ -2171,10 +2162,7 @@ void mlx4_en_destroy_netdev(struct net_device *dev) · 1 unmodified line | ||
| 2171 | 2162 | if (priv->registered) { |
| 2172 | 2163 | devlink_port_type_clear(mlx4_get_devlink_port(mdev->dev, |
| 2173 | 2164 | priv->port)); |
| 2174 | − if (shutdown) | |
| 2175 | − mlx4_en_shutdown(dev); | |
| 2176 | − else | |
| 2177 | − unregister_netdev(dev); | |
| 2165 | + unregister_netdev(dev); | |
| 2178 | 2166 | } |
| 2179 | 2167 | |
| 2180 | 2168 | if (priv->allocated) |
| @@ -2203,8 +2191,7 @@ void mlx4_en_destroy_netdev(struct net_device *dev) · 22 unmodified lines | ||
| 2203 | 2191 | kfree(priv->tx_ring); |
| 2204 | 2192 | kfree(priv->tx_cq); |
| 2205 | 2193 | |
| 2206 | − if (!shutdown) | |
| 2207 | − free_netdev(dev); | |
| 2194 | + free_netdev(dev); | |
| 2208 | 2195 | } |
| 2209 | 2196 | |
| 2210 | 2197 | static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu) |
| @@ -4147,11 +4147,8 @@ static void mlx4_shutdown(struct pci_dev *pdev) · 4146 unmodified lines | ||
| 4147 | 4147 | |
| 4148 | 4148 | mlx4_info(persist->dev, "mlx4_shutdown was called\n"); |
| 4149 | 4149 | mutex_lock(&persist->interface_state_mutex); |
| 4150 | − if (persist->interface_state & MLX4_INTERFACE_STATE_UP) { | |
| 4151 | − /* Notify mlx4 clients that the kernel is being shut down */ | |
| 4152 | − persist->interface_state |= MLX4_INTERFACE_STATE_SHUTDOWN; | |
| 4150 | + if (persist->interface_state & MLX4_INTERFACE_STATE_UP) | |
| 4153 | 4151 | mlx4_unload_one(pdev); |
| 4154 | − } | |
| 4155 | 4152 | mutex_unlock(&persist->interface_state_mutex); |
| 4156 | 4153 | } |
| 4157 | 4154 | |
| @@ -1457,7 +1457,12 @@ EXPORT_SYMBOL_GPL(mlx4_multicast_detach); · 1456 unmodified lines | ||
| 1457 | 1457 | int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port, |
| 1458 | 1458 | u32 qpn, enum mlx4_net_trans_promisc_mode mode) |
| 1459 | 1459 | { |
| 1460 | − struct mlx4_net_trans_rule rule; | |
| 1460 | + struct mlx4_net_trans_rule rule = { | |
| 1461 | + .queue_mode = MLX4_NET_TRANS_Q_FIFO, | |
| 1462 | + .exclusive = 0, | |
| 1463 | + .allow_loopback = 1, | |
| 1464 | + }; | |
| 1465 | + | |
| 1461 | 1466 | u64 *regid_p; |
| 1462 | 1467 | |
| 1463 | 1468 | switch (mode) { |
| @@ -212,6 +212,7 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt) · 211 unmodified lines | ||
| 212 | 212 | |
| 213 | 213 | phy_np = of_parse_phandle(np, "phy-handle", 0); |
| 214 | 214 | adpt->phydev = of_phy_find_device(phy_np); |
| 215 | + of_node_put(phy_np); | |
| 215 | 216 | } |
| 216 | 217 | |
| 217 | 218 | if (!adpt->phydev) { |
| @@ -711,6 +711,8 @@ static int emac_probe(struct platform_device *pdev) · 710 unmodified lines | ||
| 711 | 711 | err_undo_napi: |
| 712 | 712 | netif_napi_del(&adpt->rx_q.napi); |
| 713 | 713 | err_undo_mdiobus: |
| 714 | + if (!has_acpi_companion(&pdev->dev)) | |
| 715 | + put_device(&adpt->phydev->mdio.dev); | |
| 714 | 716 | mdiobus_unregister(adpt->mii_bus); |
| 715 | 717 | err_undo_clocks: |
| 716 | 718 | emac_clks_teardown(adpt); |
| @@ -730,6 +732,8 @@ static int emac_remove(struct platform_device *pdev) · 13 unmodified lines | ||
| 730 | 732 | |
| 731 | 733 | emac_clks_teardown(adpt); |
| 732 | 734 | |
| 735 | + if (!has_acpi_companion(&pdev->dev)) | |
| 736 | + put_device(&adpt->phydev->mdio.dev); | |
| 733 | 737 | mdiobus_unregister(adpt->mii_bus); |
| 734 | 738 | free_netdev(netdev); |
| 735 | 739 | |
| @@ -1008,20 +1008,18 @@ static int ravb_phy_init(struct net_device *ndev) · 1007 unmodified lines | ||
| 1008 | 1008 | of_node_put(pn); |
| 1009 | 1009 | if (!phydev) { |
| 1010 | 1010 | netdev_err(ndev, "failed to connect PHY\n"); |
| 1011 | − return -ENOENT; | |
| 1011 | + err = -ENOENT; | |
| 1012 | + goto err_deregister_fixed_link; | |
| 1012 | 1013 | } |
| 1013 | 1014 | |
| 1014 | 1015 | /* This driver only support 10/100Mbit speeds on Gen3 |
| 1015 | 1016 | * at this time. |
| 1016 | 1017 | */ |
| 1017 | 1018 | if (priv->chip_id == RCAR_GEN3) { |
| 1018 | − int err; | |
| 1019 | − | |
| 1020 | 1019 | err = phy_set_max_speed(phydev, SPEED_100); |
| 1021 | 1020 | if (err) { |
| 1022 | 1021 | netdev_err(ndev, "failed to limit PHY to 100Mbit/s\n"); |
| 1023 | − phy_disconnect(phydev); | |
| 1024 | − return err; | |
| 1022 | + goto err_phy_disconnect; | |
| 1025 | 1023 | } |
| 1026 | 1024 | |
| 1027 | 1025 | netdev_info(ndev, "limited PHY to 100Mbit/s\n"); |
| @@ -1033,6 +1031,14 @@ static int ravb_phy_init(struct net_device *ndev) · 5 unmodified lines | ||
| 1033 | 1031 | phy_attached_info(phydev); |
| 1034 | 1032 | |
| 1035 | 1033 | return 0; |
| 1034 | + | |
| 1035 | +err_phy_disconnect: | |
| 1036 | + phy_disconnect(phydev); | |
| 1037 | +err_deregister_fixed_link: | |
| 1038 | + if (of_phy_is_fixed_link(np)) | |
| 1039 | + of_phy_deregister_fixed_link(np); | |
| 1040 | + | |
| 1041 | + return err; | |
| 1036 | 1042 | } |
| 1037 | 1043 | |
| 1038 | 1044 | /* PHY control start function */ |
| @@ -1634,6 +1640,7 @@ static void ravb_set_rx_mode(struct net_device *ndev) · 595 unmodified lines | ||
| 1634 | 1640 | /* Device close function for Ethernet AVB */ |
| 1635 | 1641 | static int ravb_close(struct net_device *ndev) |
| 1636 | 1642 | { |
| 1643 | + struct device_node *np = ndev->dev.parent->of_node; | |
| 1637 | 1644 | struct ravb_private *priv = netdev_priv(ndev); |
| 1638 | 1645 | struct ravb_tstamp_skb *ts_skb, *ts_skb2; |
| 1639 | 1646 | |
| @@ -1663,6 +1670,8 @@ static int ravb_close(struct net_device *ndev) · 23 unmodified lines | ||
| 1663 | 1670 | if (ndev->phydev) { |
| 1664 | 1671 | phy_stop(ndev->phydev); |
| 1665 | 1672 | phy_disconnect(ndev->phydev); |
| 1673 | + if (of_phy_is_fixed_link(np)) | |
| 1674 | + of_phy_deregister_fixed_link(np); | |
| 1666 | 1675 | } |
| 1667 | 1676 | |
| 1668 | 1677 | if (priv->chip_id != RCAR_GEN2) { |
| @@ -518,7 +518,7 @@ static struct sh_eth_cpu_data r7s72100_data = { · 517 unmodified lines | ||
| 518 | 518 | |
| 519 | 519 | .ecsr_value = ECSR_ICD, |
| 520 | 520 | .ecsipr_value = ECSIPR_ICDIP, |
| 521 | − .eesipr_value = 0xff7f009f, | |
| 521 | + .eesipr_value = 0xe77f009f, | |
| 522 | 522 | |
| 523 | 523 | .tx_check = EESR_TC1 | EESR_FTC, |
| 524 | 524 | .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | |
| @@ -50,10 +50,23 @@ static int dwmac_generic_probe(struct platform_device *pdev) · 49 unmodified lines | ||
| 50 | 50 | if (plat_dat->init) { |
| 51 | 51 | ret = plat_dat->init(pdev, plat_dat->bsp_priv); |
| 52 | 52 | if (ret) |
| 53 | − return ret; | |
| 53 | + goto err_remove_config_dt; | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | − return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 56 | + ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 57 | + if (ret) | |
| 58 | + goto err_exit; | |
| 59 | + | |
| 60 | + return 0; | |
| 61 | + | |
| 62 | +err_exit: | |
| 63 | + if (plat_dat->exit) | |
| 64 | + plat_dat->exit(pdev, plat_dat->bsp_priv); | |
| 65 | +err_remove_config_dt: | |
| 66 | + if (pdev->dev.of_node) | |
| 67 | + stmmac_remove_config_dt(pdev, plat_dat); | |
| 68 | + | |
| 69 | + return ret; | |
| 57 | 70 | } |
| 58 | 71 | |
| 59 | 72 | static const struct of_device_id dwmac_generic_match[] = { |
| @@ -271,15 +271,17 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) · 270 unmodified lines | ||
| 271 | 271 | return PTR_ERR(plat_dat); |
| 272 | 272 | |
| 273 | 273 | gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); |
| 274 | − if (!gmac) | |
| 275 | − return -ENOMEM; | |
| 274 | + if (!gmac) { | |
| 275 | + err = -ENOMEM; | |
| 276 | + goto err_remove_config_dt; | |
| 277 | + } | |
| 276 | 278 | |
| 277 | 279 | gmac->pdev = pdev; |
| 278 | 280 | |
| 279 | 281 | err = ipq806x_gmac_of_parse(gmac); |
| 280 | 282 | if (err) { |
| 281 | 283 | dev_err(dev, "device tree parsing error\n"); |
| 282 | − return err; | |
| 284 | + goto err_remove_config_dt; | |
| 283 | 285 | } |
| 284 | 286 | |
| 285 | 287 | regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL, |
| @@ -300,7 +302,8 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) · 14 unmodified lines | ||
| 300 | 302 | default: |
| 301 | 303 | dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n", |
| 302 | 304 | phy_modes(gmac->phy_mode)); |
| 303 | − return -EINVAL; | |
| 305 | + err = -EINVAL; | |
| 306 | + goto err_remove_config_dt; | |
| 304 | 307 | } |
| 305 | 308 | regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val); |
| 306 | 309 | |
| @@ -319,7 +322,8 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) · 12 unmodified lines | ||
| 319 | 322 | default: |
| 320 | 323 | dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n", |
| 321 | 324 | phy_modes(gmac->phy_mode)); |
| 322 | − return -EINVAL; | |
| 325 | + err = -EINVAL; | |
| 326 | + goto err_remove_config_dt; | |
| 323 | 327 | } |
| 324 | 328 | regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val); |
| 325 | 329 | |
| @@ -346,7 +350,16 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) · 20 unmodified lines | ||
| 346 | 350 | plat_dat->bsp_priv = gmac; |
| 347 | 351 | plat_dat->fix_mac_speed = ipq806x_gmac_fix_mac_speed; |
| 348 | 352 | |
| 349 | − return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 353 | + err = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 354 | + if (err) | |
| 355 | + goto err_remove_config_dt; | |
| 356 | + | |
| 357 | + return 0; | |
| 358 | + | |
| 359 | +err_remove_config_dt: | |
| 360 | + stmmac_remove_config_dt(pdev, plat_dat); | |
| 361 | + | |
| 362 | + return err; | |
| 350 | 363 | } |
| 351 | 364 | |
| 352 | 365 | static const struct of_device_id ipq806x_gmac_dwmac_match[] = { |
| @@ -46,7 +46,8 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev) · 45 unmodified lines | ||
| 46 | 46 | reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg"); |
| 47 | 47 | if (IS_ERR(reg)) { |
| 48 | 48 | dev_err(&pdev->dev, "syscon lookup failed\n"); |
| 49 | − return PTR_ERR(reg); | |
| 49 | + ret = PTR_ERR(reg); | |
| 50 | + goto err_remove_config_dt; | |
| 50 | 51 | } |
| 51 | 52 | |
| 52 | 53 | if (plat_dat->interface == PHY_INTERFACE_MODE_MII) { |
| @@ -55,13 +56,23 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 55 | 56 | ethmode = LPC18XX_CREG_CREG6_ETHMODE_RMII; |
| 56 | 57 | } else { |
| 57 | 58 | dev_err(&pdev->dev, "Only MII and RMII mode supported\n"); |
| 58 | − return -EINVAL; | |
| 59 | + ret = -EINVAL; | |
| 60 | + goto err_remove_config_dt; | |
| 59 | 61 | } |
| 60 | 62 | |
| 61 | 63 | regmap_update_bits(reg, LPC18XX_CREG_CREG6, |
| 62 | 64 | LPC18XX_CREG_CREG6_ETHMODE_MASK, ethmode); |
| 63 | 65 | |
| 64 | − return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 66 | + ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 67 | + if (ret) | |
| 68 | + goto err_remove_config_dt; | |
| 69 | + | |
| 70 | + return 0; | |
| 71 | + | |
| 72 | +err_remove_config_dt: | |
| 73 | + stmmac_remove_config_dt(pdev, plat_dat); | |
| 74 | + | |
| 75 | + return ret; | |
| 65 | 76 | } |
| 66 | 77 | |
| 67 | 78 | static const struct of_device_id lpc18xx_dwmac_match[] = { |
| @@ -64,18 +64,31 @@ static int meson6_dwmac_probe(struct platform_device *pdev) · 63 unmodified lines | ||
| 64 | 64 | return PTR_ERR(plat_dat); |
| 65 | 65 | |
| 66 | 66 | dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); |
| 67 | − if (!dwmac) | |
| 68 | − return -ENOMEM; | |
| 67 | + if (!dwmac) { | |
| 68 | + ret = -ENOMEM; | |
| 69 | + goto err_remove_config_dt; | |
| 70 | + } | |
| 69 | 71 | |
| 70 | 72 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 71 | 73 | dwmac->reg = devm_ioremap_resource(&pdev->dev, res); |
| 72 | − if (IS_ERR(dwmac->reg)) | |
| 73 | − return PTR_ERR(dwmac->reg); | |
| 74 | + if (IS_ERR(dwmac->reg)) { | |
| 75 | + ret = PTR_ERR(dwmac->reg); | |
| 76 | + goto err_remove_config_dt; | |
| 77 | + } | |
| 74 | 78 | |
| 75 | 79 | plat_dat->bsp_priv = dwmac; |
| 76 | 80 | plat_dat->fix_mac_speed = meson6_dwmac_fix_mac_speed; |
| 77 | 81 | |
| 78 | − return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 82 | + ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 83 | + if (ret) | |
| 84 | + goto err_remove_config_dt; | |
| 85 | + | |
| 86 | + return 0; | |
| 87 | + | |
| 88 | +err_remove_config_dt: | |
| 89 | + stmmac_remove_config_dt(pdev, plat_dat); | |
| 90 | + | |
| 91 | + return ret; | |
| 79 | 92 | } |
| 80 | 93 | |
| 81 | 94 | static const struct of_device_id meson6_dwmac_match[] = { |
| @@ -264,32 +264,48 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) · 263 unmodified lines | ||
| 264 | 264 | return PTR_ERR(plat_dat); |
| 265 | 265 | |
| 266 | 266 | dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); |
| 267 | − if (!dwmac) | |
| 268 | − return -ENOMEM; | |
| 267 | + if (!dwmac) { | |
| 268 | + ret = -ENOMEM; | |
| 269 | + goto err_remove_config_dt; | |
| 270 | + } | |
| 269 | 271 | |
| 270 | 272 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 271 | 273 | dwmac->regs = devm_ioremap_resource(&pdev->dev, res); |
| 272 | − if (IS_ERR(dwmac->regs)) | |
| 273 | − return PTR_ERR(dwmac->regs); | |
| 274 | + if (IS_ERR(dwmac->regs)) { | |
| 275 | + ret = PTR_ERR(dwmac->regs); | |
| 276 | + goto err_remove_config_dt; | |
| 277 | + } | |
| 274 | 278 | |
| 275 | 279 | dwmac->pdev = pdev; |
| 276 | 280 | dwmac->phy_mode = of_get_phy_mode(pdev->dev.of_node); |
| 277 | 281 | if (dwmac->phy_mode < 0) { |
| 278 | 282 | dev_err(&pdev->dev, "missing phy-mode property\n"); |
| 279 | − return -EINVAL; | |
| 283 | + ret = -EINVAL; | |
| 284 | + goto err_remove_config_dt; | |
| 280 | 285 | } |
| 281 | 286 | |
| 282 | 287 | ret = meson8b_init_clk(dwmac); |
| 283 | 288 | if (ret) |
| 284 | − return ret; | |
| 289 | + goto err_remove_config_dt; | |
| 285 | 290 | |
| 286 | 291 | ret = meson8b_init_prg_eth(dwmac); |
| 287 | 292 | if (ret) |
| 288 | − return ret; | |
| 293 | + goto err_remove_config_dt; | |
| 289 | 294 | |
| 290 | 295 | plat_dat->bsp_priv = dwmac; |
| 291 | 296 | |
| 292 | − return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 297 | + ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 298 | + if (ret) | |
| 299 | + goto err_clk_disable; | |
| 300 | + | |
| 301 | + return 0; | |
| 302 | + | |
| 303 | +err_clk_disable: | |
| 304 | + clk_disable_unprepare(dwmac->m25_div_clk); | |
| 305 | +err_remove_config_dt: | |
| 306 | + stmmac_remove_config_dt(pdev, plat_dat); | |
| 307 | + | |
| 308 | + return ret; | |
| 293 | 309 | } |
| 294 | 310 | |
| 295 | 311 | static int meson8b_dwmac_remove(struct platform_device *pdev) |
| @@ -981,14 +981,27 @@ static int rk_gmac_probe(struct platform_device *pdev) · 980 unmodified lines | ||
| 981 | 981 | plat_dat->resume = rk_gmac_resume; |
| 982 | 982 | |
| 983 | 983 | plat_dat->bsp_priv = rk_gmac_setup(pdev, data); |
| 984 | − if (IS_ERR(plat_dat->bsp_priv)) | |
| 985 | − return PTR_ERR(plat_dat->bsp_priv); | |
| 984 | + if (IS_ERR(plat_dat->bsp_priv)) { | |
| 985 | + ret = PTR_ERR(plat_dat->bsp_priv); | |
| 986 | + goto err_remove_config_dt; | |
| 987 | + } | |
| 986 | 988 | |
| 987 | 989 | ret = rk_gmac_init(pdev, plat_dat->bsp_priv); |
| 988 | 990 | if (ret) |
| 989 | − return ret; | |
| 991 | + goto err_remove_config_dt; | |
| 992 | + | |
| 993 | + ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 994 | + if (ret) | |
| 995 | + goto err_gmac_exit; | |
| 996 | + | |
| 997 | + return 0; | |
| 998 | + | |
| 999 | +err_gmac_exit: | |
| 1000 | + rk_gmac_exit(pdev, plat_dat->bsp_priv); | |
| 1001 | +err_remove_config_dt: | |
| 1002 | + stmmac_remove_config_dt(pdev, plat_dat); | |
| 990 | 1003 | |
| 991 | − return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 1004 | + return ret; | |
| 992 | 1005 | } |
| 993 | 1006 | |
| 994 | 1007 | static const struct of_device_id rk_gmac_dwmac_match[] = { |
| @@ -304,6 +304,8 @@ static int socfpga_dwmac_probe(struct platform_device *pdev) · 303 unmodified lines | ||
| 304 | 304 | struct device *dev = &pdev->dev; |
| 305 | 305 | int ret; |
| 306 | 306 | struct socfpga_dwmac *dwmac; |
| 307 | + struct net_device *ndev; | |
| 308 | + struct stmmac_priv *stpriv; | |
| 307 | 309 | |
| 308 | 310 | ret = stmmac_get_platform_resources(pdev, &stmmac_res); |
| 309 | 311 | if (ret) |
| @@ -314,32 +316,43 @@ static int socfpga_dwmac_probe(struct platform_device *pdev) · 4 unmodified lines | ||
| 314 | 316 | return PTR_ERR(plat_dat); |
| 315 | 317 | |
| 316 | 318 | dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL); |
| 317 | − if (!dwmac) | |
| 318 | − return -ENOMEM; | |
| 319 | + if (!dwmac) { | |
| 320 | + ret = -ENOMEM; | |
| 321 | + goto err_remove_config_dt; | |
| 322 | + } | |
| 319 | 323 | |
| 320 | 324 | ret = socfpga_dwmac_parse_data(dwmac, dev); |
| 321 | 325 | if (ret) { |
| 322 | 326 | dev_err(dev, "Unable to parse OF data\n"); |
| 323 | − return ret; | |
| 327 | + goto err_remove_config_dt; | |
| 324 | 328 | } |
| 325 | 329 | |
| 326 | 330 | plat_dat->bsp_priv = dwmac; |
| 327 | 331 | plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed; |
| 328 | 332 | |
| 329 | 333 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
| 334 | + if (ret) | |
| 335 | + goto err_remove_config_dt; | |
| 330 | 336 | |
| 331 | − if (!ret) { | |
| 332 | − struct net_device *ndev = platform_get_drvdata(pdev); | |
| 333 | − struct stmmac_priv *stpriv = netdev_priv(ndev); | |
| 337 | + ndev = platform_get_drvdata(pdev); | |
| 338 | + stpriv = netdev_priv(ndev); | |
| 334 | 339 | |
| 335 | − /* The socfpga driver needs to control the stmmac reset to | |
| 336 | − * set the phy mode. Create a copy of the core reset handel | |
| 337 | − * so it can be used by the driver later. | |
| 338 | − */ | |
| 339 | − dwmac->stmmac_rst = stpriv->stmmac_rst; | |
| 340 | + /* The socfpga driver needs to control the stmmac reset to set the phy | |
| 341 | + * mode. Create a copy of the core reset handle so it can be used by | |
| 342 | + * the driver later. | |
| 343 | + */ | |
| 344 | + dwmac->stmmac_rst = stpriv->stmmac_rst; | |
| 340 | 345 | |
| 341 | − ret = socfpga_dwmac_set_phy_mode(dwmac); | |
| 342 | − } | |
| 346 | + ret = socfpga_dwmac_set_phy_mode(dwmac); | |
| 347 | + if (ret) | |
| 348 | + goto err_dvr_remove; | |
| 349 | + | |
| 350 | + return 0; | |
| 351 | + | |
| 352 | +err_dvr_remove: | |
| 353 | + stmmac_dvr_remove(&pdev->dev); | |
| 354 | +err_remove_config_dt: | |
| 355 | + stmmac_remove_config_dt(pdev, plat_dat); | |
| 343 | 356 | |
| 344 | 357 | return ret; |
| 345 | 358 | } |
| @@ -345,13 +345,15 @@ static int sti_dwmac_probe(struct platform_device *pdev) · 344 unmodified lines | ||
| 345 | 345 | return PTR_ERR(plat_dat); |
| 346 | 346 | |
| 347 | 347 | dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); |
| 348 | − if (!dwmac) | |
| 349 | − return -ENOMEM; | |
| 348 | + if (!dwmac) { | |
| 349 | + ret = -ENOMEM; | |
| 350 | + goto err_remove_config_dt; | |
| 351 | + } | |
| 350 | 352 | |
| 351 | 353 | ret = sti_dwmac_parse_data(dwmac, pdev); |
| 352 | 354 | if (ret) { |
| 353 | 355 | dev_err(&pdev->dev, "Unable to parse OF data\n"); |
| 354 | − return ret; | |
| 356 | + goto err_remove_config_dt; | |
| 355 | 357 | } |
| 356 | 358 | |
| 357 | 359 | dwmac->fix_retime_src = data->fix_retime_src; |
| @@ -363,9 +365,20 @@ static int sti_dwmac_probe(struct platform_device *pdev) · 5 unmodified lines | ||
| 363 | 365 | |
| 364 | 366 | ret = sti_dwmac_init(pdev, plat_dat->bsp_priv); |
| 365 | 367 | if (ret) |
| 366 | − return ret; | |
| 368 | + goto err_remove_config_dt; | |
| 369 | + | |
| 370 | + ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 371 | + if (ret) | |
| 372 | + goto err_dwmac_exit; | |
| 373 | + | |
| 374 | + return 0; | |
| 375 | + | |
| 376 | +err_dwmac_exit: | |
| 377 | + sti_dwmac_exit(pdev, plat_dat->bsp_priv); | |
| 378 | +err_remove_config_dt: | |
| 379 | + stmmac_remove_config_dt(pdev, plat_dat); | |
| 367 | 380 | |
| 368 | − return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 381 | + return ret; | |
| 369 | 382 | } |
| 370 | 383 | |
| 371 | 384 | static const struct sti_dwmac_of_data stih4xx_dwmac_data = { |
| @@ -107,24 +107,33 @@ static int stm32_dwmac_probe(struct platform_device *pdev) · 106 unmodified lines | ||
| 107 | 107 | return PTR_ERR(plat_dat); |
| 108 | 108 | |
| 109 | 109 | dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); |
| 110 | − if (!dwmac) | |
| 111 | − return -ENOMEM; | |
| 110 | + if (!dwmac) { | |
| 111 | + ret = -ENOMEM; | |
| 112 | + goto err_remove_config_dt; | |
| 113 | + } | |
| 112 | 114 | |
| 113 | 115 | ret = stm32_dwmac_parse_data(dwmac, &pdev->dev); |
| 114 | 116 | if (ret) { |
| 115 | 117 | dev_err(&pdev->dev, "Unable to parse OF data\n"); |
| 116 | − return ret; | |
| 118 | + goto err_remove_config_dt; | |
| 117 | 119 | } |
| 118 | 120 | |
| 119 | 121 | plat_dat->bsp_priv = dwmac; |
| 120 | 122 | |
| 121 | 123 | ret = stm32_dwmac_init(plat_dat); |
| 122 | 124 | if (ret) |
| 123 | − return ret; | |
| 125 | + goto err_remove_config_dt; | |
| 124 | 126 | |
| 125 | 127 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
| 126 | 128 | if (ret) |
| 127 | − stm32_dwmac_clk_disable(dwmac); | |
| 129 | + goto err_clk_disable; | |
| 130 | + | |
| 131 | + return 0; | |
| 132 | + | |
| 133 | +err_clk_disable: | |
| 134 | + stm32_dwmac_clk_disable(dwmac); | |
| 135 | +err_remove_config_dt: | |
| 136 | + stmmac_remove_config_dt(pdev, plat_dat); | |
| 128 | 137 | |
| 129 | 138 | return ret; |
| 130 | 139 | } |
| @@ -120,22 +120,27 @@ static int sun7i_gmac_probe(struct platform_device *pdev) · 119 unmodified lines | ||
| 120 | 120 | return PTR_ERR(plat_dat); |
| 121 | 121 | |
| 122 | 122 | gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); |
| 123 | − if (!gmac) | |
| 124 | − return -ENOMEM; | |
| 123 | + if (!gmac) { | |
| 124 | + ret = -ENOMEM; | |
| 125 | + goto err_remove_config_dt; | |
| 126 | + } | |
| 125 | 127 | |
| 126 | 128 | gmac->interface = of_get_phy_mode(dev->of_node); |
| 127 | 129 | |
| 128 | 130 | gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx"); |
| 129 | 131 | if (IS_ERR(gmac->tx_clk)) { |
| 130 | 132 | dev_err(dev, "could not get tx clock\n"); |
| 131 | − return PTR_ERR(gmac->tx_clk); | |
| 133 | + ret = PTR_ERR(gmac->tx_clk); | |
| 134 | + goto err_remove_config_dt; | |
| 132 | 135 | } |
| 133 | 136 | |
| 134 | 137 | /* Optional regulator for PHY */ |
| 135 | 138 | gmac->regulator = devm_regulator_get_optional(dev, "phy"); |
| 136 | 139 | if (IS_ERR(gmac->regulator)) { |
| 137 | − if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER) | |
| 138 | − return -EPROBE_DEFER; | |
| 140 | + if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER) { | |
| 141 | + ret = -EPROBE_DEFER; | |
| 142 | + goto err_remove_config_dt; | |
| 143 | + } | |
| 139 | 144 | dev_info(dev, "no regulator found\n"); |
| 140 | 145 | gmac->regulator = NULL; |
| 141 | 146 | } |
| @@ -151,11 +156,18 @@ static int sun7i_gmac_probe(struct platform_device *pdev) · 9 unmodified lines | ||
| 151 | 156 | |
| 152 | 157 | ret = sun7i_gmac_init(pdev, plat_dat->bsp_priv); |
| 153 | 158 | if (ret) |
| 154 | − return ret; | |
| 159 | + goto err_remove_config_dt; | |
| 155 | 160 | |
| 156 | 161 | ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
| 157 | 162 | if (ret) |
| 158 | − sun7i_gmac_exit(pdev, plat_dat->bsp_priv); | |
| 163 | + goto err_gmac_exit; | |
| 164 | + | |
| 165 | + return 0; | |
| 166 | + | |
| 167 | +err_gmac_exit: | |
| 168 | + sun7i_gmac_exit(pdev, plat_dat->bsp_priv); | |
| 169 | +err_remove_config_dt: | |
| 170 | + stmmac_remove_config_dt(pdev, plat_dat); | |
| 159 | 171 | |
| 160 | 172 | return ret; |
| 161 | 173 | } |
| @@ -3416,7 +3416,6 @@ int stmmac_dvr_remove(struct device *dev) · 3415 unmodified lines | ||
| 3416 | 3416 | stmmac_set_mac(priv->ioaddr, false); |
| 3417 | 3417 | netif_carrier_off(ndev); |
| 3418 | 3418 | unregister_netdev(ndev); |
| 3419 | − of_node_put(priv->plat->phy_node); | |
| 3420 | 3419 | if (priv->stmmac_rst) |
| 3421 | 3420 | reset_control_assert(priv->stmmac_rst); |
| 3422 | 3421 | clk_disable_unprepare(priv->pclk); |
| @@ -200,7 +200,6 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat, · 199 unmodified lines | ||
| 200 | 200 | /** |
| 201 | 201 | * stmmac_probe_config_dt - parse device-tree driver parameters |
| 202 | 202 | * @pdev: platform_device structure |
| 203 | − * @plat: driver data platform structure | |
| 204 | 203 | * @mac: MAC address to use |
| 205 | 204 | * Description: |
| 206 | 205 | * this function is to read the driver parameters from device-tree and |
| @@ -306,7 +305,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) · 99 unmodified lines | ||
| 306 | 305 | dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg), |
| 307 | 306 | GFP_KERNEL); |
| 308 | 307 | if (!dma_cfg) { |
| 309 | − of_node_put(plat->phy_node); | |
| 308 | + stmmac_remove_config_dt(pdev, plat); | |
| 310 | 309 | return ERR_PTR(-ENOMEM); |
| 311 | 310 | } |
| 312 | 311 | plat->dma_cfg = dma_cfg; |
| @@ -329,14 +328,37 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) · 16 unmodified lines | ||
| 329 | 328 | |
| 330 | 329 | return plat; |
| 331 | 330 | } |
| 331 | + | |
| 332 | +/** | |
| 333 | + * stmmac_remove_config_dt - undo the effects of stmmac_probe_config_dt() | |
| 334 | + * @pdev: platform_device structure | |
| 335 | + * @plat: driver data platform structure | |
| 336 | + * | |
| 337 | + * Release resources claimed by stmmac_probe_config_dt(). | |
| 338 | + */ | |
| 339 | +void stmmac_remove_config_dt(struct platform_device *pdev, | |
| 340 | + struct plat_stmmacenet_data *plat) | |
| 341 | +{ | |
| 342 | + struct device_node *np = pdev->dev.of_node; | |
| 343 | + | |
| 344 | + if (of_phy_is_fixed_link(np)) | |
| 345 | + of_phy_deregister_fixed_link(np); | |
| 346 | + of_node_put(plat->phy_node); | |
| 347 | +} | |
| 332 | 348 | #else |
| 333 | 349 | struct plat_stmmacenet_data * |
| 334 | 350 | stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) |
| 335 | 351 | { |
| 336 | 352 | return ERR_PTR(-ENOSYS); |
| 337 | 353 | } |
| 354 | + | |
| 355 | +void stmmac_remove_config_dt(struct platform_device *pdev, | |
| 356 | + struct plat_stmmacenet_data *plat) | |
| 357 | +{ | |
| 358 | +} | |
| 338 | 359 | #endif /* CONFIG_OF */ |
| 339 | 360 | EXPORT_SYMBOL_GPL(stmmac_probe_config_dt); |
| 361 | +EXPORT_SYMBOL_GPL(stmmac_remove_config_dt); | |
| 340 | 362 | |
| 341 | 363 | int stmmac_get_platform_resources(struct platform_device *pdev, |
| 342 | 364 | struct stmmac_resources *stmmac_res) |
| @@ -392,10 +414,13 @@ int stmmac_pltfr_remove(struct platform_device *pdev) · 49 unmodified lines | ||
| 392 | 414 | { |
| 393 | 415 | struct net_device *ndev = platform_get_drvdata(pdev); |
| 394 | 416 | struct stmmac_priv *priv = netdev_priv(ndev); |
| 417 | + struct plat_stmmacenet_data *plat = priv->plat; | |
| 395 | 418 | int ret = stmmac_dvr_remove(&pdev->dev); |
| 396 | 419 | |
| 397 | − if (priv->plat->exit) | |
| 398 | − priv->plat->exit(pdev, priv->plat->bsp_priv); | |
| 420 | + if (plat->exit) | |
| 421 | + plat->exit(pdev, plat->bsp_priv); | |
| 422 | + | |
| 423 | + stmmac_remove_config_dt(pdev, plat); | |
| 399 | 424 | |
| 400 | 425 | return ret; |
| 401 | 426 | } |
| @@ -23,6 +23,8 @@ · 22 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | struct plat_stmmacenet_data * |
| 25 | 25 | stmmac_probe_config_dt(struct platform_device *pdev, const char **mac); |
| 26 | +void stmmac_remove_config_dt(struct platform_device *pdev, | |
| 27 | + struct plat_stmmacenet_data *plat); | |
| 26 | 28 | |
| 27 | 29 | int stmmac_get_platform_resources(struct platform_device *pdev, |
| 28 | 30 | struct stmmac_resources *stmmac_res); |
| @@ -2881,7 +2881,7 @@ static int dwceqos_probe(struct platform_device *pdev) · 2880 unmodified lines | ||
| 2881 | 2881 | ret = of_get_phy_mode(lp->pdev->dev.of_node); |
| 2882 | 2882 | if (ret < 0) { |
| 2883 | 2883 | dev_err(&lp->pdev->dev, "error in getting phy i/f\n"); |
| 2884 | − goto err_out_clk_dis_phy; | |
| 2884 | + goto err_out_deregister_fixed_link; | |
| 2885 | 2885 | } |
| 2886 | 2886 | |
| 2887 | 2887 | lp->phy_interface = ret; |
| @@ -2889,14 +2889,14 @@ static int dwceqos_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 2889 | 2889 | ret = dwceqos_mii_init(lp); |
| 2890 | 2890 | if (ret) { |
| 2891 | 2891 | dev_err(&lp->pdev->dev, "error in dwceqos_mii_init\n"); |
| 2892 | − goto err_out_clk_dis_phy; | |
| 2892 | + goto err_out_deregister_fixed_link; | |
| 2893 | 2893 | } |
| 2894 | 2894 | |
| 2895 | 2895 | ret = dwceqos_mii_probe(ndev); |
| 2896 | 2896 | if (ret != 0) { |
| 2897 | 2897 | netdev_err(ndev, "mii_probe fail.\n"); |
| 2898 | 2898 | ret = -ENXIO; |
| 2899 | − goto err_out_clk_dis_phy; | |
| 2899 | + goto err_out_deregister_fixed_link; | |
| 2900 | 2900 | } |
| 2901 | 2901 | |
| 2902 | 2902 | dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0); |
| @@ -2914,7 +2914,7 @@ static int dwceqos_probe(struct platform_device *pdev) · 11 unmodified lines | ||
| 2914 | 2914 | if (ret) { |
| 2915 | 2915 | dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n", |
| 2916 | 2916 | ret); |
| 2917 | − goto err_out_clk_dis_phy; | |
| 2917 | + goto err_out_deregister_fixed_link; | |
| 2918 | 2918 | } |
| 2919 | 2919 | dev_info(&lp->pdev->dev, "pdev->id %d, baseaddr 0x%08lx, irq %d\n", |
| 2920 | 2920 | pdev->id, ndev->base_addr, ndev->irq); |
| @@ -2924,7 +2924,7 @@ static int dwceqos_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 2924 | 2924 | if (ret) { |
| 2925 | 2925 | dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n", |
| 2926 | 2926 | ndev->irq, ret); |
| 2927 | − goto err_out_clk_dis_phy; | |
| 2927 | + goto err_out_deregister_fixed_link; | |
| 2928 | 2928 | } |
| 2929 | 2929 | |
| 2930 | 2930 | if (netif_msg_probe(lp)) |
| @@ -2935,11 +2935,14 @@ static int dwceqos_probe(struct platform_device *pdev) · 4 unmodified lines | ||
| 2935 | 2935 | ret = register_netdev(ndev); |
| 2936 | 2936 | if (ret) { |
| 2937 | 2937 | dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); |
| 2938 | − goto err_out_clk_dis_phy; | |
| 2938 | + goto err_out_deregister_fixed_link; | |
| 2939 | 2939 | } |
| 2940 | 2940 | |
| 2941 | 2941 | return 0; |
| 2942 | 2942 | |
| 2943 | +err_out_deregister_fixed_link: | |
| 2944 | + if (of_phy_is_fixed_link(pdev->dev.of_node)) | |
| 2945 | + of_phy_deregister_fixed_link(pdev->dev.of_node); | |
| 2943 | 2946 | err_out_clk_dis_phy: |
| 2944 | 2947 | clk_disable_unprepare(lp->phy_ref_clk); |
| 2945 | 2948 | err_out_clk_dis_aper: |
| @@ -2959,8 +2962,11 @@ static int dwceqos_remove(struct platform_device *pdev) · 13 unmodified lines | ||
| 2959 | 2962 | if (ndev) { |
| 2960 | 2963 | lp = netdev_priv(ndev); |
| 2961 | 2964 | |
| 2962 | − if (ndev->phydev) | |
| 2965 | + if (ndev->phydev) { | |
| 2963 | 2966 | phy_disconnect(ndev->phydev); |
| 2967 | + if (of_phy_is_fixed_link(pdev->dev.of_node)) | |
| 2968 | + of_phy_deregister_fixed_link(pdev->dev.of_node); | |
| 2969 | + } | |
| 2964 | 2970 | mdiobus_unregister(lp->mii_bus); |
| 2965 | 2971 | mdiobus_free(lp->mii_bus); |
| 2966 | 2972 | |
| @@ -2459,20 +2459,8 @@ static void cpsw_remove_dt(struct platform_device *pdev) · 2458 unmodified lines | ||
| 2459 | 2459 | if (strcmp(slave_node->name, "slave")) |
| 2460 | 2460 | continue; |
| 2461 | 2461 | |
| 2462 | − if (of_phy_is_fixed_link(slave_node)) { | |
| 2463 | − struct phy_device *phydev; | |
| 2464 | − | |
| 2465 | − phydev = of_phy_find_device(slave_node); | |
| 2466 | − if (phydev) { | |
| 2467 | − fixed_phy_unregister(phydev); | |
| 2468 | − /* Put references taken by | |
| 2469 | − * of_phy_find_device() and | |
| 2470 | − * of_phy_register_fixed_link(). | |
| 2471 | − */ | |
| 2472 | − phy_device_free(phydev); | |
| 2473 | − phy_device_free(phydev); | |
| 2474 | − } | |
| 2475 | − } | |
| 2462 | + if (of_phy_is_fixed_link(slave_node)) | |
| 2463 | + of_phy_deregister_fixed_link(slave_node); | |
| 2476 | 2464 | |
| 2477 | 2465 | of_node_put(slave_data->phy_node); |
| 2478 | 2466 | |
| @@ -2942,6 +2930,8 @@ static int cpsw_resume(struct device *dev) · 463 unmodified lines | ||
| 2942 | 2930 | /* Select default pin state */ |
| 2943 | 2931 | pinctrl_pm_select_default_state(dev); |
| 2944 | 2932 | |
| 2933 | + /* shut up ASSERT_RTNL() warning in netif_set_real_num_tx/rx_queues */ | |
| 2934 | + rtnl_lock(); | |
| 2945 | 2935 | if (cpsw->data.dual_emac) { |
| 2946 | 2936 | int i; |
| 2947 | 2937 | |
| @@ -2953,6 +2943,8 @@ static int cpsw_resume(struct device *dev) · 5 unmodified lines | ||
| 2953 | 2943 | if (netif_running(ndev)) |
| 2954 | 2944 | cpsw_ndo_open(ndev); |
| 2955 | 2945 | } |
| 2946 | + rtnl_unlock(); | |
| 2947 | + | |
| 2956 | 2948 | return 0; |
| 2957 | 2949 | } |
| 2958 | 2950 | #endif |
| @@ -1767,6 +1767,7 @@ static int davinci_emac_try_get_mac(struct platform_device *pdev, · 1766 unmodified lines | ||
| 1767 | 1767 | */ |
| 1768 | 1768 | static int davinci_emac_probe(struct platform_device *pdev) |
| 1769 | 1769 | { |
| 1770 | + struct device_node *np = pdev->dev.of_node; | |
| 1770 | 1771 | int rc = 0; |
| 1771 | 1772 | struct resource *res, *res_ctrl; |
| 1772 | 1773 | struct net_device *ndev; |
| @@ -1805,7 +1806,7 @@ static int davinci_emac_probe(struct platform_device *pdev) · 32 unmodified lines | ||
| 1805 | 1806 | if (!pdata) { |
| 1806 | 1807 | dev_err(&pdev->dev, "no platform data\n"); |
| 1807 | 1808 | rc = -ENODEV; |
| 1808 | − goto no_pdata; | |
| 1809 | + goto err_free_netdev; | |
| 1809 | 1810 | } |
| 1810 | 1811 | |
| 1811 | 1812 | /* MAC addr and PHY mask , RMII enable info from platform_data */ |
| @@ -1941,6 +1942,10 @@ no_cpdma_chan: · 129 unmodified lines | ||
| 1941 | 1942 | cpdma_chan_destroy(priv->rxchan); |
| 1942 | 1943 | cpdma_ctlr_destroy(priv->dma); |
| 1943 | 1944 | no_pdata: |
| 1945 | + if (of_phy_is_fixed_link(np)) | |
| 1946 | + of_phy_deregister_fixed_link(np); | |
| 1947 | + of_node_put(priv->phy_node); | |
| 1948 | +err_free_netdev: | |
| 1944 | 1949 | free_netdev(ndev); |
| 1945 | 1950 | return rc; |
| 1946 | 1951 | } |
| @@ -1956,6 +1961,7 @@ static int davinci_emac_remove(struct platform_device *pdev) · 9 unmodified lines | ||
| 1956 | 1961 | { |
| 1957 | 1962 | struct net_device *ndev = platform_get_drvdata(pdev); |
| 1958 | 1963 | struct emac_priv *priv = netdev_priv(ndev); |
| 1964 | + struct device_node *np = pdev->dev.of_node; | |
| 1959 | 1965 | |
| 1960 | 1966 | dev_notice(&ndev->dev, "DaVinci EMAC: davinci_emac_remove()\n"); |
| 1961 | 1967 | |
| @@ -1968,6 +1974,8 @@ static int davinci_emac_remove(struct platform_device *pdev) · 6 unmodified lines | ||
| 1968 | 1974 | unregister_netdev(ndev); |
| 1969 | 1975 | of_node_put(priv->phy_node); |
| 1970 | 1976 | pm_runtime_disable(&pdev->dev); |
| 1977 | + if (of_phy_is_fixed_link(np)) | |
| 1978 | + of_phy_deregister_fixed_link(np); | |
| 1971 | 1979 | free_netdev(ndev); |
| 1972 | 1980 | |
| 1973 | 1981 | return 0; |
| @@ -859,7 +859,6 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 858 unmodified lines | ||
| 859 | 859 | struct geneve_dev *geneve = netdev_priv(dev); |
| 860 | 860 | struct geneve_sock *gs4; |
| 861 | 861 | struct rtable *rt = NULL; |
| 862 | − const struct iphdr *iip; /* interior IP header */ | |
| 863 | 862 | int err = -EINVAL; |
| 864 | 863 | struct flowi4 fl4; |
| 865 | 864 | __u8 tos, ttl; |
| @@ -890,8 +889,6 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 24 unmodified lines | ||
| 890 | 889 | sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); |
| 891 | 890 | skb_reset_mac_header(skb); |
| 892 | 891 | |
| 893 | − iip = ip_hdr(skb); | |
| 894 | − | |
| 895 | 892 | if (info) { |
| 896 | 893 | const struct ip_tunnel_key *key = &info->key; |
| 897 | 894 | u8 *opts = NULL; |
| @@ -911,7 +908,7 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 13 unmodified lines | ||
| 911 | 908 | if (unlikely(err)) |
| 912 | 909 | goto tx_error; |
| 913 | 910 | |
| 914 | − tos = ip_tunnel_ecn_encap(key->tos, iip, skb); | |
| 911 | + tos = ip_tunnel_ecn_encap(key->tos, ip_hdr(skb), skb); | |
| 915 | 912 | ttl = key->ttl; |
| 916 | 913 | df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; |
| 917 | 914 | } else { |
| @@ -920,7 +917,7 @@ static netdev_tx_t geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 2 unmodified lines | ||
| 920 | 917 | if (unlikely(err)) |
| 921 | 918 | goto tx_error; |
| 922 | 919 | |
| 923 | − tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, iip, skb); | |
| 920 | + tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, ip_hdr(skb), skb); | |
| 924 | 921 | ttl = geneve->ttl; |
| 925 | 922 | if (!ttl && IN_MULTICAST(ntohl(fl4.daddr))) |
| 926 | 923 | ttl = 1; |
| @@ -952,7 +949,6 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 25 unmodified lines | ||
| 952 | 949 | { |
| 953 | 950 | struct geneve_dev *geneve = netdev_priv(dev); |
| 954 | 951 | struct dst_entry *dst = NULL; |
| 955 | − const struct iphdr *iip; /* interior IP header */ | |
| 956 | 952 | struct geneve_sock *gs6; |
| 957 | 953 | int err = -EINVAL; |
| 958 | 954 | struct flowi6 fl6; |
| @@ -982,8 +978,6 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 23 unmodified lines | ||
| 982 | 978 | sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); |
| 983 | 979 | skb_reset_mac_header(skb); |
| 984 | 980 | |
| 985 | − iip = ip_hdr(skb); | |
| 986 | − | |
| 987 | 981 | if (info) { |
| 988 | 982 | const struct ip_tunnel_key *key = &info->key; |
| 989 | 983 | u8 *opts = NULL; |
| @@ -1004,7 +998,7 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 14 unmodified lines | ||
| 1004 | 998 | if (unlikely(err)) |
| 1005 | 999 | goto tx_error; |
| 1006 | 1000 | |
| 1007 | − prio = ip_tunnel_ecn_encap(key->tos, iip, skb); | |
| 1001 | + prio = ip_tunnel_ecn_encap(key->tos, ip_hdr(skb), skb); | |
| 1008 | 1002 | ttl = key->ttl; |
| 1009 | 1003 | label = info->key.label; |
| 1010 | 1004 | } else { |
| @@ -1014,7 +1008,7 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 3 unmodified lines | ||
| 1014 | 1008 | goto tx_error; |
| 1015 | 1009 | |
| 1016 | 1010 | prio = ip_tunnel_ecn_encap(ip6_tclass(fl6.flowlabel), |
| 1017 | − iip, skb); | |
| 1011 | + ip_hdr(skb), skb); | |
| 1018 | 1012 | ttl = geneve->ttl; |
| 1019 | 1013 | if (!ttl && ipv6_addr_is_multicast(&fl6.daddr)) |
| 1020 | 1014 | ttl = 1; |
| @@ -497,6 +497,7 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev, · 496 unmodified lines | ||
| 497 | 497 | struct net_device *phy_dev; |
| 498 | 498 | int err; |
| 499 | 499 | u16 mode = IPVLAN_MODE_L3; |
| 500 | + bool create = false; | |
| 500 | 501 | |
| 501 | 502 | if (!tb[IFLA_LINK]) |
| 502 | 503 | return -EINVAL; |
| @@ -513,6 +514,7 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev, · 10 unmodified lines | ||
| 513 | 514 | err = ipvlan_port_create(phy_dev); |
| 514 | 515 | if (err < 0) |
| 515 | 516 | return err; |
| 517 | + create = true; | |
| 516 | 518 | } |
| 517 | 519 | |
| 518 | 520 | if (data && data[IFLA_IPVLAN_MODE]) |
| @@ -536,22 +538,27 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev, · 17 unmodified lines | ||
| 536 | 538 | |
| 537 | 539 | err = register_netdevice(dev); |
| 538 | 540 | if (err < 0) |
| 539 | − return err; | |
| 541 | + goto destroy_ipvlan_port; | |
| 540 | 542 | |
| 541 | 543 | err = netdev_upper_dev_link(phy_dev, dev); |
| 542 | 544 | if (err) { |
| 543 | − unregister_netdevice(dev); | |
| 544 | − return err; | |
| 545 | + goto unregister_netdev; | |
| 545 | 546 | } |
| 546 | 547 | err = ipvlan_set_port_mode(port, mode); |
| 547 | 548 | if (err) { |
| 548 | − unregister_netdevice(dev); | |
| 549 | − return err; | |
| 549 | + goto unregister_netdev; | |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | list_add_tail_rcu(&ipvlan->pnode, &port->ipvlans); |
| 553 | 553 | netif_stacked_transfer_operstate(phy_dev, dev); |
| 554 | 554 | return 0; |
| 555 | + | |
| 556 | +unregister_netdev: | |
| 557 | + unregister_netdevice(dev); | |
| 558 | +destroy_ipvlan_port: | |
| 559 | + if (create) | |
| 560 | + ipvlan_port_destroy(phy_dev); | |
| 561 | + return err; | |
| 555 | 562 | } |
| 556 | 563 | |
| 557 | 564 | static void ipvlan_link_delete(struct net_device *dev, struct list_head *head) |
| @@ -518,7 +518,9 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, · 517 unmodified lines | ||
| 518 | 518 | |
| 519 | 519 | mtt = irda_get_mtt(skb); |
| 520 | 520 | pr_debug("%s(%ld), mtt=%d\n", __func__ , jiffies, mtt); |
| 521 | − if (mtt) | |
| 521 | + if (mtt > 1000) | |
| 522 | + mdelay(mtt/1000); | |
| 523 | + else if (mtt) | |
| 522 | 524 | udelay(mtt); |
| 523 | 525 | |
| 524 | 526 | /* Enable DMA interrupt */ |
| @@ -491,7 +491,13 @@ static int macvtap_newlink(struct net *src_net, · 490 unmodified lines | ||
| 491 | 491 | /* Don't put anything that may fail after macvlan_common_newlink |
| 492 | 492 | * because we can't undo what it does. |
| 493 | 493 | */ |
| 494 | − return macvlan_common_newlink(src_net, dev, tb, data); | |
| 494 | + err = macvlan_common_newlink(src_net, dev, tb, data); | |
| 495 | + if (err) { | |
| 496 | + netdev_rx_handler_unregister(dev); | |
| 497 | + return err; | |
| 498 | + } | |
| 499 | + | |
| 500 | + return 0; | |
| 495 | 501 | } |
| 496 | 502 | |
| 497 | 503 | static void macvtap_dellink(struct net_device *dev, |
| @@ -736,13 +742,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, · 238 unmodified lines | ||
| 736 | 742 | |
| 737 | 743 | if (zerocopy) |
| 738 | 744 | err = zerocopy_sg_from_iter(skb, from); |
| 739 | − else { | |
| 745 | + else | |
| 740 | 746 | err = skb_copy_datagram_from_iter(skb, 0, from, len); |
| 741 | − if (!err && m && m->msg_control) { | |
| 742 | − struct ubuf_info *uarg = m->msg_control; | |
| 743 | − uarg->callback(uarg, false); | |
| 744 | − } | |
| 745 | − } | |
| 746 | 747 | |
| 747 | 748 | if (err) |
| 748 | 749 | goto err_kfree; |
| @@ -773,7 +774,11 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, · 24 unmodified lines | ||
| 773 | 774 | skb_shinfo(skb)->destructor_arg = m->msg_control; |
| 774 | 775 | skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; |
| 775 | 776 | skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; |
| 777 | + } else if (m && m->msg_control) { | |
| 778 | + struct ubuf_info *uarg = m->msg_control; | |
| 779 | + uarg->callback(uarg, false); | |
| 776 | 780 | } |
| 781 | + | |
| 777 | 782 | if (vlan) { |
| 778 | 783 | skb->dev = vlan->dev; |
| 779 | 784 | dev_queue_xmit(skb); |
| @@ -102,15 +102,19 @@ static int rtl8211f_config_init(struct phy_device *phydev) · 101 unmodified lines | ||
| 102 | 102 | if (ret < 0) |
| 103 | 103 | return ret; |
| 104 | 104 | |
| 105 | − if (phydev->interface == PHY_INTERFACE_MODE_RGMII) { | |
| 106 | − /* enable TXDLY */ | |
| 107 | − phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08); | |
| 108 | − reg = phy_read(phydev, 0x11); | |
| 105 | + phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08); | |
| 106 | + reg = phy_read(phydev, 0x11); | |
| 107 | + | |
| 108 | + /* enable TX-delay for rgmii-id and rgmii-txid, otherwise disable it */ | |
| 109 | + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || | |
| 110 | + phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) | |
| 109 | 111 | reg |= RTL8211F_TX_DELAY; |
| 110 | − phy_write(phydev, 0x11, reg); | |
| 111 | − /* restore to default page 0 */ | |
| 112 | − phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0); | |
| 113 | − } | |
| 112 | + else | |
| 113 | + reg &= ~RTL8211F_TX_DELAY; | |
| 114 | + | |
| 115 | + phy_write(phydev, 0x11, reg); | |
| 116 | + /* restore to default page 0 */ | |
| 117 | + phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0); | |
| 114 | 118 | |
| 115 | 119 | return 0; |
| 116 | 120 | } |
| @@ -1246,13 +1246,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · 1245 unmodified lines | ||
| 1246 | 1246 | |
| 1247 | 1247 | if (zerocopy) |
| 1248 | 1248 | err = zerocopy_sg_from_iter(skb, from); |
| 1249 | − else { | |
| 1249 | + else | |
| 1250 | 1250 | err = skb_copy_datagram_from_iter(skb, 0, from, len); |
| 1251 | − if (!err && msg_control) { | |
| 1252 | − struct ubuf_info *uarg = msg_control; | |
| 1253 | − uarg->callback(uarg, false); | |
| 1254 | − } | |
| 1255 | − } | |
| 1256 | 1251 | |
| 1257 | 1252 | if (err) { |
| 1258 | 1253 | this_cpu_inc(tun->pcpu_stats->rx_dropped); |
| @@ -1298,6 +1293,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · 39 unmodified lines | ||
| 1298 | 1293 | skb_shinfo(skb)->destructor_arg = msg_control; |
| 1299 | 1294 | skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; |
| 1300 | 1295 | skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; |
| 1296 | + } else if (msg_control) { | |
| 1297 | + struct ubuf_info *uarg = msg_control; | |
| 1298 | + uarg->callback(uarg, false); | |
| 1301 | 1299 | } |
| 1302 | 1300 | |
| 1303 | 1301 | skb_reset_network_header(skb); |
| @@ -603,12 +603,12 @@ static void ax88772_suspend(struct usbnet *dev) · 602 unmodified lines | ||
| 603 | 603 | u16 medium; |
| 604 | 604 | |
| 605 | 605 | /* Stop MAC operation */ |
| 606 | − medium = asix_read_medium_status(dev, 0); | |
| 606 | + medium = asix_read_medium_status(dev, 1); | |
| 607 | 607 | medium &= ~AX_MEDIUM_RE; |
| 608 | − asix_write_medium_mode(dev, medium, 0); | |
| 608 | + asix_write_medium_mode(dev, medium, 1); | |
| 609 | 609 | |
| 610 | 610 | netdev_dbg(dev->net, "ax88772_suspend: medium=0x%04x\n", |
| 611 | − asix_read_medium_status(dev, 0)); | |
| 611 | + asix_read_medium_status(dev, 1)); | |
| 612 | 612 | |
| 613 | 613 | /* Preserve BMCR for restoring */ |
| 614 | 614 | priv->presvd_phy_bmcr = |
| @@ -388,12 +388,6 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb) · 387 unmodified lines | ||
| 388 | 388 | case USB_CDC_NOTIFY_NETWORK_CONNECTION: |
| 389 | 389 | netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n", |
| 390 | 390 | event->wValue ? "on" : "off"); |
| 391 | − | |
| 392 | − /* Work-around for devices with broken off-notifications */ | |
| 393 | − if (event->wValue && | |
| 394 | − !test_bit(__LINK_STATE_NOCARRIER, &dev->net->state)) | |
| 395 | − usbnet_link_change(dev, 0, 0); | |
| 396 | − | |
| 397 | 391 | usbnet_link_change(dev, !!event->wValue, 0); |
| 398 | 392 | break; |
| 399 | 393 | case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */ |
| @@ -466,6 +460,36 @@ static int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, struct sk_buff *skb) · 66 unmodified lines | ||
| 466 | 460 | return 1; |
| 467 | 461 | } |
| 468 | 462 | |
| 463 | +/* Ensure correct link state | |
| 464 | + * | |
| 465 | + * Some devices (ZTE MF823/831/910) export two carrier on notifications when | |
| 466 | + * connected. This causes the link state to be incorrect. Work around this by | |
| 467 | + * always setting the state to off, then on. | |
| 468 | + */ | |
| 469 | +void usbnet_cdc_zte_status(struct usbnet *dev, struct urb *urb) | |
| 470 | +{ | |
| 471 | + struct usb_cdc_notification *event; | |
| 472 | + | |
| 473 | + if (urb->actual_length < sizeof(*event)) | |
| 474 | + return; | |
| 475 | + | |
| 476 | + event = urb->transfer_buffer; | |
| 477 | + | |
| 478 | + if (event->bNotificationType != USB_CDC_NOTIFY_NETWORK_CONNECTION) { | |
| 479 | + usbnet_cdc_status(dev, urb); | |
| 480 | + return; | |
| 481 | + } | |
| 482 | + | |
| 483 | + netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n", | |
| 484 | + event->wValue ? "on" : "off"); | |
| 485 | + | |
| 486 | + if (event->wValue && | |
| 487 | + netif_carrier_ok(dev->net)) | |
| 488 | + netif_carrier_off(dev->net); | |
| 489 | + | |
| 490 | + usbnet_link_change(dev, !!event->wValue, 0); | |
| 491 | +} | |
| 492 | + | |
| 469 | 493 | static const struct driver_info cdc_info = { |
| 470 | 494 | .description = "CDC Ethernet Device", |
| 471 | 495 | .flags = FLAG_ETHER | FLAG_POINTTOPOINT, |
| @@ -481,7 +505,7 @@ static const struct driver_info zte_cdc_info = { · 9 unmodified lines | ||
| 481 | 505 | .flags = FLAG_ETHER | FLAG_POINTTOPOINT, |
| 482 | 506 | .bind = usbnet_cdc_zte_bind, |
| 483 | 507 | .unbind = usbnet_cdc_unbind, |
| 484 | − .status = usbnet_cdc_status, | |
| 508 | + .status = usbnet_cdc_zte_status, | |
| 485 | 509 | .set_rx_mode = usbnet_cdc_update_filter, |
| 486 | 510 | .manage_power = usbnet_manage_power, |
| 487 | 511 | .rx_fixup = usbnet_cdc_zte_rx_fixup, |
| @@ -894,6 +894,7 @@ static const struct usb_device_id products[] = { · 893 unmodified lines | ||
| 894 | 894 | {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ |
| 895 | 895 | {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ |
| 896 | 896 | {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ |
| 897 | + {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ | |
| 897 | 898 | {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ |
| 898 | 899 | {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ |
| 899 | 900 | {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ |
| @@ -611,6 +611,7 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan, · 610 unmodified lines | ||
| 611 | 611 | struct vxlan_rdst *rd = NULL; |
| 612 | 612 | struct vxlan_fdb *f; |
| 613 | 613 | int notify = 0; |
| 614 | + int rc; | |
| 614 | 615 | |
| 615 | 616 | f = __vxlan_find_mac(vxlan, mac); |
| 616 | 617 | if (f) { |
| @@ -641,8 +642,7 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan, · 24 unmodified lines | ||
| 641 | 642 | if ((flags & NLM_F_APPEND) && |
| 642 | 643 | (is_multicast_ether_addr(f->eth_addr) || |
| 643 | 644 | is_zero_ether_addr(f->eth_addr))) { |
| 644 | − int rc = vxlan_fdb_append(f, ip, port, vni, ifindex, | |
| 645 | − &rd); | |
| 645 | + rc = vxlan_fdb_append(f, ip, port, vni, ifindex, &rd); | |
| 646 | 646 | |
| 647 | 647 | if (rc < 0) |
| 648 | 648 | return rc; |
| @@ -673,7 +673,11 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan, · 24 unmodified lines | ||
| 673 | 673 | INIT_LIST_HEAD(&f->remotes); |
| 674 | 674 | memcpy(f->eth_addr, mac, ETH_ALEN); |
| 675 | 675 | |
| 676 | − vxlan_fdb_append(f, ip, port, vni, ifindex, &rd); | |
| 676 | + rc = vxlan_fdb_append(f, ip, port, vni, ifindex, &rd); | |
| 677 | + if (rc < 0) { | |
| 678 | + kfree(f); | |
| 679 | + return rc; | |
| 680 | + } | |
| 677 | 681 | |
| 678 | 682 | ++vxlan->addrcnt; |
| 679 | 683 | hlist_add_head_rcu(&f->hlist, |
| @@ -2222,8 +2222,9 @@ done: · 2221 unmodified lines | ||
| 2222 | 2222 | is_scanning_required = 1; |
| 2223 | 2223 | } else { |
| 2224 | 2224 | mwifiex_dbg(priv->adapter, MSG, |
| 2225 | − "info: trying to associate to '%s' bssid %pM\n", | |
| 2226 | − (char *)req_ssid.ssid, bss->bssid); | |
| 2225 | + "info: trying to associate to '%.*s' bssid %pM\n", | |
| 2226 | + req_ssid.ssid_len, (char *)req_ssid.ssid, | |
| 2227 | + bss->bssid); | |
| 2227 | 2228 | memcpy(&priv->cfg_bssid, bss->bssid, ETH_ALEN); |
| 2228 | 2229 | break; |
| 2229 | 2230 | } |
| @@ -2283,8 +2284,8 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, · 53 unmodified lines | ||
| 2283 | 2284 | } |
| 2284 | 2285 | |
| 2285 | 2286 | mwifiex_dbg(adapter, INFO, |
| 2286 | − "info: Trying to associate to %s and bssid %pM\n", | |
| 2287 | − (char *)sme->ssid, sme->bssid); | |
| 2287 | + "info: Trying to associate to %.*s and bssid %pM\n", | |
| 2288 | + (int)sme->ssid_len, (char *)sme->ssid, sme->bssid); | |
| 2288 | 2289 | |
| 2289 | 2290 | if (!mwifiex_stop_bg_scan(priv)) |
| 2290 | 2291 | cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy); |
| @@ -2417,8 +2418,8 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, · 126 unmodified lines | ||
| 2417 | 2418 | } |
| 2418 | 2419 | |
| 2419 | 2420 | mwifiex_dbg(priv->adapter, MSG, |
| 2420 | − "info: trying to join to %s and bssid %pM\n", | |
| 2421 | − (char *)params->ssid, params->bssid); | |
| 2421 | + "info: trying to join to %.*s and bssid %pM\n", | |
| 2422 | + params->ssid_len, (char *)params->ssid, params->bssid); | |
| 2422 | 2423 | |
| 2423 | 2424 | mwifiex_set_ibss_params(priv, params); |
| 2424 | 2425 | |
| @@ -490,3 +490,18 @@ int of_phy_register_fixed_link(struct device_node *np) · 489 unmodified lines | ||
| 490 | 490 | return -ENODEV; |
| 491 | 491 | } |
| 492 | 492 | EXPORT_SYMBOL(of_phy_register_fixed_link); |
| 493 | + | |
| 494 | +void of_phy_deregister_fixed_link(struct device_node *np) | |
| 495 | +{ | |
| 496 | + struct phy_device *phydev; | |
| 497 | + | |
| 498 | + phydev = of_phy_find_device(np); | |
| 499 | + if (!phydev) | |
| 500 | + return; | |
| 501 | + | |
| 502 | + fixed_phy_unregister(phydev); | |
| 503 | + | |
| 504 | + put_device(&phydev->mdio.dev); /* of_phy_find_device() */ | |
| 505 | + phy_device_free(phydev); /* fixed_phy_register() */ | |
| 506 | +} | |
| 507 | +EXPORT_SYMBOL(of_phy_deregister_fixed_link); | |
| @@ -3,7 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | * |
| 4 | 4 | * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) |
| 5 | 5 | * |
| 6 | − * Authors: Joao Pinto <jpmpinto@gmail.com> | |
| 6 | + * Authors: Joao Pinto <Joao.Pinto@synopsys.com> | |
| 7 | 7 | * |
| 8 | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | 9 | * it under the terms of the GNU General Public License version 2 as |
| @@ -307,20 +307,6 @@ out: · 306 unmodified lines | ||
| 307 | 307 | return 0; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | −static struct pci_dev *pcie_find_root_port(struct pci_dev *dev) | |
| 311 | −{ | |
| 312 | − while (1) { | |
| 313 | − if (!pci_is_pcie(dev)) | |
| 314 | − break; | |
| 315 | − if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) | |
| 316 | − return dev; | |
| 317 | − if (!dev->bus->self) | |
| 318 | − break; | |
| 319 | − dev = dev->bus->self; | |
| 320 | − } | |
| 321 | − return NULL; | |
| 322 | −} | |
| 323 | − | |
| 324 | 310 | static int find_aer_device_iter(struct device *device, void *data) |
| 325 | 311 | { |
| 326 | 312 | struct pcie_device **result = data; |
| @@ -1439,6 +1439,21 @@ static void program_hpp_type1(struct pci_dev *dev, struct hpp_type1 *hpp) · 1438 unmodified lines | ||
| 1439 | 1439 | dev_warn(&dev->dev, "PCI-X settings not supported\n"); |
| 1440 | 1440 | } |
| 1441 | 1441 | |
| 1442 | +static bool pcie_root_rcb_set(struct pci_dev *dev) | |
| 1443 | +{ | |
| 1444 | + struct pci_dev *rp = pcie_find_root_port(dev); | |
| 1445 | + u16 lnkctl; | |
| 1446 | + | |
| 1447 | + if (!rp) | |
| 1448 | + return false; | |
| 1449 | + | |
| 1450 | + pcie_capability_read_word(rp, PCI_EXP_LNKCTL, &lnkctl); | |
| 1451 | + if (lnkctl & PCI_EXP_LNKCTL_RCB) | |
| 1452 | + return true; | |
| 1453 | + | |
| 1454 | + return false; | |
| 1455 | +} | |
| 1456 | + | |
| 1442 | 1457 | static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) |
| 1443 | 1458 | { |
| 1444 | 1459 | int pos; |
| @@ -1468,9 +1483,20 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) · 23 unmodified lines | ||
| 1468 | 1483 | ~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or); |
| 1469 | 1484 | |
| 1470 | 1485 | /* Initialize Link Control Register */ |
| 1471 | − if (pcie_cap_has_lnkctl(dev)) | |
| 1486 | + if (pcie_cap_has_lnkctl(dev)) { | |
| 1487 | + | |
| 1488 | + /* | |
| 1489 | + * If the Root Port supports Read Completion Boundary of | |
| 1490 | + * 128, set RCB to 128. Otherwise, clear it. | |
| 1491 | + */ | |
| 1492 | + hpp->pci_exp_lnkctl_and |= PCI_EXP_LNKCTL_RCB; | |
| 1493 | + hpp->pci_exp_lnkctl_or &= ~PCI_EXP_LNKCTL_RCB; | |
| 1494 | + if (pcie_root_rcb_set(dev)) | |
| 1495 | + hpp->pci_exp_lnkctl_or |= PCI_EXP_LNKCTL_RCB; | |
| 1496 | + | |
| 1472 | 1497 | pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL, |
| 1473 | 1498 | ~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or); |
| 1499 | + } | |
| 1474 | 1500 | |
| 1475 | 1501 | /* Find Advanced Error Reporting Enhanced Capability */ |
| 1476 | 1502 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); |
| @@ -474,6 +474,7 @@ static int meson_pwm_probe(struct platform_device *pdev) · 473 unmodified lines | ||
| 474 | 474 | if (IS_ERR(meson->base)) |
| 475 | 475 | return PTR_ERR(meson->base); |
| 476 | 476 | |
| 477 | + spin_lock_init(&meson->lock); | |
| 477 | 478 | meson->chip.dev = &pdev->dev; |
| 478 | 479 | meson->chip.ops = &meson_pwm_ops; |
| 479 | 480 | meson->chip.base = -1; |
| @@ -425,6 +425,8 @@ void pwmchip_sysfs_unexport_children(struct pwm_chip *chip) · 424 unmodified lines | ||
| 425 | 425 | if (test_bit(PWMF_EXPORTED, &pwm->flags)) |
| 426 | 426 | pwm_unexport_child(parent, pwm); |
| 427 | 427 | } |
| 428 | + | |
| 429 | + put_device(parent); | |
| 428 | 430 | } |
| 429 | 431 | |
| 430 | 432 | static int __init pwm_sysfs_init(void) |
| @@ -1083,7 +1083,7 @@ unsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba *phba) · 1082 unmodified lines | ||
| 1083 | 1083 | nonemb_cmd = &phba->boot_struct.nonemb_cmd; |
| 1084 | 1084 | nonemb_cmd->size = sizeof(*resp); |
| 1085 | 1085 | nonemb_cmd->va = pci_alloc_consistent(phba->ctrl.pdev, |
| 1086 | − sizeof(nonemb_cmd->size), | |
| 1086 | + nonemb_cmd->size, | |
| 1087 | 1087 | &nonemb_cmd->dma); |
| 1088 | 1088 | if (!nonemb_cmd->va) { |
| 1089 | 1089 | mutex_unlock(&ctrl->mbox_lock); |
| @@ -2009,7 +2009,7 @@ static struct hpsa_scsi_dev_t *lookup_hpsa_scsi_dev(struct ctlr_info *h, · 2008 unmodified lines | ||
| 2009 | 2009 | |
| 2010 | 2010 | static int hpsa_slave_alloc(struct scsi_device *sdev) |
| 2011 | 2011 | { |
| 2012 | − struct hpsa_scsi_dev_t *sd; | |
| 2012 | + struct hpsa_scsi_dev_t *sd = NULL; | |
| 2013 | 2013 | unsigned long flags; |
| 2014 | 2014 | struct ctlr_info *h; |
| 2015 | 2015 | |
| @@ -2026,7 +2026,8 @@ static int hpsa_slave_alloc(struct scsi_device *sdev) · 10 unmodified lines | ||
| 2026 | 2026 | sd->target = sdev_id(sdev); |
| 2027 | 2027 | sd->lun = sdev->lun; |
| 2028 | 2028 | } |
| 2029 | − } else | |
| 2029 | + } | |
| 2030 | + if (!sd) | |
| 2030 | 2031 | sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev), |
| 2031 | 2032 | sdev_id(sdev), sdev->lun); |
| 2032 | 2033 | |
| @@ -3840,6 +3841,7 @@ static int hpsa_update_device_info(struct ctlr_info *h, · 1807 unmodified lines | ||
| 3840 | 3841 | sizeof(this_device->vendor)); |
| 3841 | 3842 | memcpy(this_device->model, &inq_buff[16], |
| 3842 | 3843 | sizeof(this_device->model)); |
| 3844 | + this_device->rev = inq_buff[2]; | |
| 3843 | 3845 | memset(this_device->device_id, 0, |
| 3844 | 3846 | sizeof(this_device->device_id)); |
| 3845 | 3847 | if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8, |
| @@ -3929,10 +3931,14 @@ static void figure_bus_target_lun(struct ctlr_info *h, · 83 unmodified lines | ||
| 3929 | 3931 | |
| 3930 | 3932 | if (!is_logical_dev_addr_mode(lunaddrbytes)) { |
| 3931 | 3933 | /* physical device, target and lun filled in later */ |
| 3932 | − if (is_hba_lunid(lunaddrbytes)) | |
| 3934 | + if (is_hba_lunid(lunaddrbytes)) { | |
| 3935 | + int bus = HPSA_HBA_BUS; | |
| 3936 | + | |
| 3937 | + if (!device->rev) | |
| 3938 | + bus = HPSA_LEGACY_HBA_BUS; | |
| 3933 | 3939 | hpsa_set_bus_target_lun(device, |
| 3934 | − HPSA_HBA_BUS, 0, lunid & 0x3fff); | |
| 3935 | − else | |
| 3940 | + bus, 0, lunid & 0x3fff); | |
| 3941 | + } else | |
| 3936 | 3942 | /* defer target, lun assignment for physical devices */ |
| 3937 | 3943 | hpsa_set_bus_target_lun(device, |
| 3938 | 3944 | HPSA_PHYSICAL_DEVICE_BUS, -1, -1); |
| @@ -69,6 +69,7 @@ struct hpsa_scsi_dev_t { · 68 unmodified lines | ||
| 69 | 69 | u64 sas_address; |
| 70 | 70 | unsigned char vendor[8]; /* bytes 8-15 of inquiry data */ |
| 71 | 71 | unsigned char model[16]; /* bytes 16-31 of inquiry data */ |
| 72 | + unsigned char rev; /* byte 2 of inquiry data */ | |
| 72 | 73 | unsigned char raid_level; /* from inquiry page 0xC1 */ |
| 73 | 74 | unsigned char volume_offline; /* discovered via TUR or VPD */ |
| 74 | 75 | u16 queue_depth; /* max queue_depth for this device */ |
| @@ -402,6 +403,7 @@ struct offline_device_entry { · 327 unmodified lines | ||
| 402 | 403 | #define HPSA_RAID_VOLUME_BUS 1 |
| 403 | 404 | #define HPSA_EXTERNAL_RAID_VOLUME_BUS 2 |
| 404 | 405 | #define HPSA_HBA_BUS 0 |
| 406 | +#define HPSA_LEGACY_HBA_BUS 3 | |
| 405 | 407 | |
| 406 | 408 | /* |
| 407 | 409 | Send the command to the hardware |
| @@ -308,7 +308,7 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost) · 307 unmodified lines | ||
| 308 | 308 | fc_stats = &lport->host_stats; |
| 309 | 309 | memset(fc_stats, 0, sizeof(struct fc_host_statistics)); |
| 310 | 310 | |
| 311 | − fc_stats->seconds_since_last_reset = (lport->boot_time - jiffies) / HZ; | |
| 311 | + fc_stats->seconds_since_last_reset = (jiffies - lport->boot_time) / HZ; | |
| 312 | 312 | |
| 313 | 313 | for_each_possible_cpu(cpu) { |
| 314 | 314 | struct fc_stats *stats; |
| @@ -3885,6 +3885,11 @@ _scsih_temp_threshold_events(struct MPT3SAS_ADAPTER *ioc, · 3884 unmodified lines | ||
| 3885 | 3885 | } |
| 3886 | 3886 | } |
| 3887 | 3887 | |
| 3888 | +static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd) | |
| 3889 | +{ | |
| 3890 | + return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16); | |
| 3891 | +} | |
| 3892 | + | |
| 3888 | 3893 | /** |
| 3889 | 3894 | * _scsih_flush_running_cmds - completing outstanding commands. |
| 3890 | 3895 | * @ioc: per adapter object |
| @@ -3906,6 +3911,9 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc) · 15 unmodified lines | ||
| 3906 | 3911 | if (!scmd) |
| 3907 | 3912 | continue; |
| 3908 | 3913 | count++; |
| 3914 | + if (ata_12_16_cmd(scmd)) | |
| 3915 | + scsi_internal_device_unblock(scmd->device, | |
| 3916 | + SDEV_RUNNING); | |
| 3909 | 3917 | mpt3sas_base_free_smid(ioc, smid); |
| 3910 | 3918 | scsi_dma_unmap(scmd); |
| 3911 | 3919 | if (ioc->pci_error_recovery) |
| @@ -4010,11 +4018,6 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status) · 98 unmodified lines | ||
| 4010 | 4018 | SAM_STAT_CHECK_CONDITION; |
| 4011 | 4019 | } |
| 4012 | 4020 | |
| 4013 | −static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd) | |
| 4014 | −{ | |
| 4015 | − return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16); | |
| 4016 | −} | |
| 4017 | − | |
| 4018 | 4021 | /** |
| 4019 | 4022 | * scsih_qcmd - main scsi request entry point |
| 4020 | 4023 | * @scmd: pointer to scsi command object |
| @@ -791,8 +791,10 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf · 790 unmodified lines | ||
| 791 | 791 | slot->slot_tag = tag; |
| 792 | 792 | |
| 793 | 793 | slot->buf = pci_pool_alloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma); |
| 794 | − if (!slot->buf) | |
| 794 | + if (!slot->buf) { | |
| 795 | + rc = -ENOMEM; | |
| 795 | 796 | goto err_out_tag; |
| 797 | + } | |
| 796 | 798 | memset(slot->buf, 0, MVS_SLOT_BUF_SZ); |
| 797 | 799 | |
| 798 | 800 | tei.task = task; |
| @@ -356,8 +356,8 @@ struct qlogicpti { · 355 unmodified lines | ||
| 356 | 356 | |
| 357 | 357 | /* The rest of the elements are unimportant for performance. */ |
| 358 | 358 | struct qlogicpti *next; |
| 359 | − __u32 res_dvma; /* Ptr to RESPONSE bufs (DVMA)*/ | |
| 360 | − __u32 req_dvma; /* Ptr to REQUEST bufs (DVMA) */ | |
| 359 | + dma_addr_t res_dvma; /* Ptr to RESPONSE bufs (DVMA)*/ | |
| 360 | + dma_addr_t req_dvma; /* Ptr to REQUEST bufs (DVMA) */ | |
| 361 | 361 | u_char fware_majrev, fware_minrev, fware_micrev; |
| 362 | 362 | struct Scsi_Host *qhost; |
| 363 | 363 | int qpti_id; |
| @@ -3232,9 +3232,6 @@ int btrfs_dirty_pages(struct btrfs_root *root, struct inode *inode, · 3231 unmodified lines | ||
| 3232 | 3232 | loff_t pos, size_t write_bytes, |
| 3233 | 3233 | struct extent_state **cached); |
| 3234 | 3234 | int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end); |
| 3235 | −ssize_t btrfs_copy_file_range(struct file *file_in, loff_t pos_in, | |
| 3236 | − struct file *file_out, loff_t pos_out, | |
| 3237 | − size_t len, unsigned int flags); | |
| 3238 | 3235 | int btrfs_clone_file_range(struct file *file_in, loff_t pos_in, |
| 3239 | 3236 | struct file *file_out, loff_t pos_out, u64 len); |
| 3240 | 3237 | |
| @@ -2998,7 +2998,6 @@ const struct file_operations btrfs_file_operations = { · 2997 unmodified lines | ||
| 2998 | 2998 | #ifdef CONFIG_COMPAT |
| 2999 | 2999 | .compat_ioctl = btrfs_compat_ioctl, |
| 3000 | 3000 | #endif |
| 3001 | − .copy_file_range = btrfs_copy_file_range, | |
| 3002 | 3001 | .clone_file_range = btrfs_clone_file_range, |
| 3003 | 3002 | .dedupe_file_range = btrfs_dedupe_file_range, |
| 3004 | 3003 | }; |
| @@ -3980,18 +3980,6 @@ out_unlock: · 3979 unmodified lines | ||
| 3980 | 3980 | return ret; |
| 3981 | 3981 | } |
| 3982 | 3982 | |
| 3983 | −ssize_t btrfs_copy_file_range(struct file *file_in, loff_t pos_in, | |
| 3984 | − struct file *file_out, loff_t pos_out, | |
| 3985 | − size_t len, unsigned int flags) | |
| 3986 | −{ | |
| 3987 | − ssize_t ret; | |
| 3988 | − | |
| 3989 | − ret = btrfs_clone_files(file_out, file_in, pos_in, len, pos_out); | |
| 3990 | − if (ret == 0) | |
| 3991 | − ret = len; | |
| 3992 | − return ret; | |
| 3993 | −} | |
| 3994 | − | |
| 3995 | 3983 | int btrfs_clone_file_range(struct file *src_file, loff_t off, |
| 3996 | 3984 | struct file *dst_file, loff_t destoff, u64 len) |
| 3997 | 3985 | { |
| @@ -808,7 +808,11 @@ calc_seckey(struct cifs_ses *ses) · 807 unmodified lines | ||
| 808 | 808 | struct crypto_skcipher *tfm_arc4; |
| 809 | 809 | struct scatterlist sgin, sgout; |
| 810 | 810 | struct skcipher_request *req; |
| 811 | − unsigned char sec_key[CIFS_SESS_KEY_SIZE]; /* a nonce */ | |
| 811 | + unsigned char *sec_key; | |
| 812 | + | |
| 813 | + sec_key = kmalloc(CIFS_SESS_KEY_SIZE, GFP_KERNEL); | |
| 814 | + if (sec_key == NULL) | |
| 815 | + return -ENOMEM; | |
| 812 | 816 | |
| 813 | 817 | get_random_bytes(sec_key, CIFS_SESS_KEY_SIZE); |
| 814 | 818 | |
| @@ -816,7 +820,7 @@ calc_seckey(struct cifs_ses *ses) · 1 unmodified line | ||
| 816 | 820 | if (IS_ERR(tfm_arc4)) { |
| 817 | 821 | rc = PTR_ERR(tfm_arc4); |
| 818 | 822 | cifs_dbg(VFS, "could not allocate crypto API arc4\n"); |
| 819 | − return rc; | |
| 823 | + goto out; | |
| 820 | 824 | } |
| 821 | 825 | |
| 822 | 826 | rc = crypto_skcipher_setkey(tfm_arc4, ses->auth_key.response, |
| @@ -854,7 +858,8 @@ calc_seckey(struct cifs_ses *ses) · 31 unmodified lines | ||
| 854 | 858 | |
| 855 | 859 | out_free_cipher: |
| 856 | 860 | crypto_free_skcipher(tfm_arc4); |
| 857 | − | |
| 861 | +out: | |
| 862 | + kfree(sec_key); | |
| 858 | 863 | return rc; |
| 859 | 864 | } |
| 860 | 865 | |
| @@ -3427,6 +3427,7 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL, · 3426 unmodified lines | ||
| 3427 | 3427 | __u16 rc = 0; |
| 3428 | 3428 | struct cifs_posix_acl *cifs_acl = (struct cifs_posix_acl *)parm_data; |
| 3429 | 3429 | struct posix_acl_xattr_header *local_acl = (void *)pACL; |
| 3430 | + struct posix_acl_xattr_entry *ace = (void *)(local_acl + 1); | |
| 3430 | 3431 | int count; |
| 3431 | 3432 | int i; |
| 3432 | 3433 | |
| @@ -3453,8 +3454,7 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL, · 20 unmodified lines | ||
| 3453 | 3454 | return 0; |
| 3454 | 3455 | } |
| 3455 | 3456 | for (i = 0; i < count; i++) { |
| 3456 | − rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i], | |
| 3457 | − (struct posix_acl_xattr_entry *)(local_acl + 1)); | |
| 3457 | + rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i], &ace[i]); | |
| 3458 | 3458 | if (rc != 0) { |
| 3459 | 3459 | /* ACE not converted */ |
| 3460 | 3460 | break; |
| @@ -412,6 +412,9 @@ cifs_reconnect(struct TCP_Server_Info *server) · 411 unmodified lines | ||
| 412 | 412 | } |
| 413 | 413 | } while (server->tcpStatus == CifsNeedReconnect); |
| 414 | 414 | |
| 415 | + if (server->tcpStatus == CifsNeedNegotiate) | |
| 416 | + mod_delayed_work(cifsiod_wq, &server->echo, 0); | |
| 417 | + | |
| 415 | 418 | return rc; |
| 416 | 419 | } |
| 417 | 420 | |
| @@ -421,17 +424,25 @@ cifs_echo_request(struct work_struct *work) · 3 unmodified lines | ||
| 421 | 424 | int rc; |
| 422 | 425 | struct TCP_Server_Info *server = container_of(work, |
| 423 | 426 | struct TCP_Server_Info, echo.work); |
| 424 | − unsigned long echo_interval = server->echo_interval; | |
| 427 | + unsigned long echo_interval; | |
| 428 | + | |
| 429 | + /* | |
| 430 | + * If we need to renegotiate, set echo interval to zero to | |
| 431 | + * immediately call echo service where we can renegotiate. | |
| 432 | + */ | |
| 433 | + if (server->tcpStatus == CifsNeedNegotiate) | |
| 434 | + echo_interval = 0; | |
| 435 | + else | |
| 436 | + echo_interval = server->echo_interval; | |
| 425 | 437 | |
| 426 | 438 | /* |
| 427 | − * We cannot send an echo if it is disabled or until the | |
| 428 | − * NEGOTIATE_PROTOCOL request is done, which is indicated by | |
| 429 | − * server->ops->need_neg() == true. Also, no need to ping if | |
| 430 | − * we got a response recently. | |
| 439 | + * We cannot send an echo if it is disabled. | |
| 440 | + * Also, no need to ping if we got a response recently. | |
| 431 | 441 | */ |
| 432 | 442 | |
| 433 | 443 | if (server->tcpStatus == CifsNeedReconnect || |
| 434 | − server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew || | |
| 444 | + server->tcpStatus == CifsExiting || | |
| 445 | + server->tcpStatus == CifsNew || | |
| 435 | 446 | (server->ops->can_echo && !server->ops->can_echo(server)) || |
| 436 | 447 | time_before(jiffies, server->lstrp + echo_interval - HZ)) |
| 437 | 448 | goto requeue_echo; |
| @@ -442,7 +453,7 @@ cifs_echo_request(struct work_struct *work) · 4 unmodified lines | ||
| 442 | 453 | server->hostname); |
| 443 | 454 | |
| 444 | 455 | requeue_echo: |
| 445 | − queue_delayed_work(cifsiod_wq, &server->echo, echo_interval); | |
| 456 | + queue_delayed_work(cifsiod_wq, &server->echo, server->echo_interval); | |
| 446 | 457 | } |
| 447 | 458 | |
| 448 | 459 | static bool |
| @@ -377,9 +377,9 @@ repeat: · 376 unmodified lines | ||
| 377 | 377 | { |
| 378 | 378 | int p; |
| 379 | 379 | for (p = 0; p < rr->u.ER.len_id; p++) |
| 380 | − printk("%c", rr->u.ER.data[p]); | |
| 380 | + printk(KERN_CONT "%c", rr->u.ER.data[p]); | |
| 381 | 381 | } |
| 382 | − printk("\n"); | |
| 382 | + printk(KERN_CONT "\n"); | |
| 383 | 383 | break; |
| 384 | 384 | case SIG('P', 'X'): |
| 385 | 385 | inode->i_mode = isonum_733(rr->u.PX.mode); |
| @@ -5194,7 +5194,7 @@ int ocfs2_change_extent_flag(handle_t *handle, · 5193 unmodified lines | ||
| 5194 | 5194 | rec = &el->l_recs[index]; |
| 5195 | 5195 | if (new_flags && (rec->e_flags & new_flags)) { |
| 5196 | 5196 | mlog(ML_ERROR, "Owner %llu tried to set %d flags on an " |
| 5197 | − "extent that already had them", | |
| 5197 | + "extent that already had them\n", | |
| 5198 | 5198 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), |
| 5199 | 5199 | new_flags); |
| 5200 | 5200 | goto out; |
| @@ -5202,7 +5202,7 @@ int ocfs2_change_extent_flag(handle_t *handle, · 1 unmodified line | ||
| 5202 | 5202 | |
| 5203 | 5203 | if (clear_flags && !(rec->e_flags & clear_flags)) { |
| 5204 | 5204 | mlog(ML_ERROR, "Owner %llu tried to clear %d flags on an " |
| 5205 | − "extent that didn't have them", | |
| 5205 | + "extent that didn't have them\n", | |
| 5206 | 5206 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), |
| 5207 | 5207 | clear_flags); |
| 5208 | 5208 | goto out; |
| @@ -5713,8 +5713,7 @@ int ocfs2_remove_btree_range(struct inode *inode, · 504 unmodified lines | ||
| 5713 | 5713 | struct ocfs2_refcount_tree *ref_tree = NULL; |
| 5714 | 5714 | |
| 5715 | 5715 | if ((flags & OCFS2_EXT_REFCOUNTED) && len) { |
| 5716 | − BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & | |
| 5717 | − OCFS2_HAS_REFCOUNT_FL)); | |
| 5716 | + BUG_ON(!ocfs2_is_refcount_inode(inode)); | |
| 5718 | 5717 | |
| 5719 | 5718 | if (!refcount_tree_locked) { |
| 5720 | 5719 | ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1, |
| @@ -464,6 +464,15 @@ static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) · 463 unmodified lines | ||
| 464 | 464 | trace_ocfs2_bmap((unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 465 | 465 | (unsigned long long)block); |
| 466 | 466 | |
| 467 | + /* | |
| 468 | + * The swap code (ab-)uses ->bmap to get a block mapping and then | |
| 469 | + * bypasseѕ the file system for actual I/O. We really can't allow | |
| 470 | + * that on refcounted inodes, so we have to skip out here. And yes, | |
| 471 | + * 0 is the magic code for a bmap error.. | |
| 472 | + */ | |
| 473 | + if (ocfs2_is_refcount_inode(inode)) | |
| 474 | + return 0; | |
| 475 | + | |
| 467 | 476 | /* We don't need to lock journal system files, since they aren't |
| 468 | 477 | * accessed concurrently from multiple nodes. |
| 469 | 478 | */ |
| @@ -2254,10 +2263,10 @@ out: · 1784 unmodified lines | ||
| 2254 | 2263 | return ret; |
| 2255 | 2264 | } |
| 2256 | 2265 | |
| 2257 | −static void ocfs2_dio_end_io_write(struct inode *inode, | |
| 2258 | − struct ocfs2_dio_write_ctxt *dwc, | |
| 2259 | − loff_t offset, | |
| 2260 | − ssize_t bytes) | |
| 2266 | +static int ocfs2_dio_end_io_write(struct inode *inode, | |
| 2267 | + struct ocfs2_dio_write_ctxt *dwc, | |
| 2268 | + loff_t offset, | |
| 2269 | + ssize_t bytes) | |
| 2261 | 2270 | { |
| 2262 | 2271 | struct ocfs2_cached_dealloc_ctxt dealloc; |
| 2263 | 2272 | struct ocfs2_extent_tree et; |
| @@ -2308,7 +2317,7 @@ static void ocfs2_dio_end_io_write(struct inode *inode, · 44 unmodified lines | ||
| 2308 | 2317 | mlog_errno(ret); |
| 2309 | 2318 | } |
| 2310 | 2319 | |
| 2311 | − di = (struct ocfs2_dinode *)di_bh; | |
| 2320 | + di = (struct ocfs2_dinode *)di_bh->b_data; | |
| 2312 | 2321 | |
| 2313 | 2322 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh); |
| 2314 | 2323 | |
| @@ -2365,6 +2374,8 @@ out: · 50 unmodified lines | ||
| 2365 | 2374 | if (locked) |
| 2366 | 2375 | inode_unlock(inode); |
| 2367 | 2376 | ocfs2_dio_free_write_ctx(inode, dwc); |
| 2377 | + | |
| 2378 | + return ret; | |
| 2368 | 2379 | } |
| 2369 | 2380 | |
| 2370 | 2381 | /* |
| @@ -2379,21 +2390,19 @@ static int ocfs2_dio_end_io(struct kiocb *iocb, · 8 unmodified lines | ||
| 2379 | 2390 | { |
| 2380 | 2391 | struct inode *inode = file_inode(iocb->ki_filp); |
| 2381 | 2392 | int level; |
| 2382 | − | |
| 2383 | − if (bytes <= 0) | |
| 2384 | − return 0; | |
| 2393 | + int ret = 0; | |
| 2385 | 2394 | |
| 2386 | 2395 | /* this io's submitter should not have unlocked this before we could */ |
| 2387 | 2396 | BUG_ON(!ocfs2_iocb_is_rw_locked(iocb)); |
| 2388 | 2397 | |
| 2389 | − if (private) | |
| 2390 | − ocfs2_dio_end_io_write(inode, private, offset, bytes); | |
| 2398 | + if (bytes > 0 && private) | |
| 2399 | + ret = ocfs2_dio_end_io_write(inode, private, offset, bytes); | |
| 2391 | 2400 | |
| 2392 | 2401 | ocfs2_iocb_clear_rw_locked(iocb); |
| 2393 | 2402 | |
| 2394 | 2403 | level = ocfs2_iocb_rw_locked_level(iocb); |
| 2395 | 2404 | ocfs2_rw_unlock(inode, level); |
| 2396 | − return 0; | |
| 2405 | + return ret; | |
| 2397 | 2406 | } |
| 2398 | 2407 | |
| 2399 | 2408 | static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) |
| @@ -1030,7 +1030,7 @@ int ocfs2_extend_no_holes(struct inode *inode, struct buffer_head *di_bh, · 1029 unmodified lines | ||
| 1030 | 1030 | * Only quota files call this without a bh, and they can't be |
| 1031 | 1031 | * refcounted. |
| 1032 | 1032 | */ |
| 1033 | − BUG_ON(!di_bh && (oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); | |
| 1033 | + BUG_ON(!di_bh && ocfs2_is_refcount_inode(inode)); | |
| 1034 | 1034 | BUG_ON(!di_bh && !(oi->ip_flags & OCFS2_INODE_SYSTEM_FILE)); |
| 1035 | 1035 | |
| 1036 | 1036 | clusters_to_add = ocfs2_clusters_for_bytes(inode->i_sb, new_i_size); |
| @@ -1667,9 +1667,9 @@ static void ocfs2_calc_trunc_pos(struct inode *inode, · 630 unmodified lines | ||
| 1667 | 1667 | *done = ret; |
| 1668 | 1668 | } |
| 1669 | 1669 | |
| 1670 | −static int ocfs2_remove_inode_range(struct inode *inode, | |
| 1671 | − struct buffer_head *di_bh, u64 byte_start, | |
| 1672 | − u64 byte_len) | |
| 1670 | +int ocfs2_remove_inode_range(struct inode *inode, | |
| 1671 | + struct buffer_head *di_bh, u64 byte_start, | |
| 1672 | + u64 byte_len) | |
| 1673 | 1673 | { |
| 1674 | 1674 | int ret = 0, flags = 0, done = 0, i; |
| 1675 | 1675 | u32 trunc_start, trunc_len, trunc_end, trunc_cpos, phys_cpos; |
| @@ -1719,8 +1719,7 @@ static int ocfs2_remove_inode_range(struct inode *inode, · 43 unmodified lines | ||
| 1719 | 1719 | * within one cluster(means is not exactly aligned to clustersize). |
| 1720 | 1720 | */ |
| 1721 | 1721 | |
| 1722 | − if (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL) { | |
| 1723 | − | |
| 1722 | + if (ocfs2_is_refcount_inode(inode)) { | |
| 1724 | 1723 | ret = ocfs2_cow_file_pos(inode, di_bh, byte_start); |
| 1725 | 1724 | if (ret) { |
| 1726 | 1725 | mlog_errno(ret); |
| @@ -2036,7 +2035,7 @@ int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos, · 309 unmodified lines | ||
| 2036 | 2035 | struct super_block *sb = inode->i_sb; |
| 2037 | 2036 | |
| 2038 | 2037 | if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb)) || |
| 2039 | − !(OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL) || | |
| 2038 | + !ocfs2_is_refcount_inode(inode) || | |
| 2040 | 2039 | OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) |
| 2041 | 2040 | return 0; |
| 2042 | 2041 | |
| @@ -2440,6 +2439,31 @@ out: · 397 unmodified lines | ||
| 2440 | 2439 | return offset; |
| 2441 | 2440 | } |
| 2442 | 2441 | |
| 2442 | +static int ocfs2_file_clone_range(struct file *file_in, | |
| 2443 | + loff_t pos_in, | |
| 2444 | + struct file *file_out, | |
| 2445 | + loff_t pos_out, | |
| 2446 | + u64 len) | |
| 2447 | +{ | |
| 2448 | + return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, | |
| 2449 | + len, false); | |
| 2450 | +} | |
| 2451 | + | |
| 2452 | +static ssize_t ocfs2_file_dedupe_range(struct file *src_file, | |
| 2453 | + u64 loff, | |
| 2454 | + u64 len, | |
| 2455 | + struct file *dst_file, | |
| 2456 | + u64 dst_loff) | |
| 2457 | +{ | |
| 2458 | + int error; | |
| 2459 | + | |
| 2460 | + error = ocfs2_reflink_remap_range(src_file, loff, dst_file, dst_loff, | |
| 2461 | + len, true); | |
| 2462 | + if (error) | |
| 2463 | + return error; | |
| 2464 | + return len; | |
| 2465 | +} | |
| 2466 | + | |
| 2443 | 2467 | const struct inode_operations ocfs2_file_iops = { |
| 2444 | 2468 | .setattr = ocfs2_setattr, |
| 2445 | 2469 | .getattr = ocfs2_getattr, |
| @@ -2479,6 +2503,8 @@ const struct file_operations ocfs2_fops = { · 33 unmodified lines | ||
| 2479 | 2503 | .splice_read = generic_file_splice_read, |
| 2480 | 2504 | .splice_write = iter_file_splice_write, |
| 2481 | 2505 | .fallocate = ocfs2_fallocate, |
| 2506 | + .clone_file_range = ocfs2_file_clone_range, | |
| 2507 | + .dedupe_file_range = ocfs2_file_dedupe_range, | |
| 2482 | 2508 | }; |
| 2483 | 2509 | |
| 2484 | 2510 | const struct file_operations ocfs2_dops = { |
| @@ -2524,6 +2550,8 @@ const struct file_operations ocfs2_fops_no_plocks = { · 39 unmodified lines | ||
| 2524 | 2550 | .splice_read = generic_file_splice_read, |
| 2525 | 2551 | .splice_write = iter_file_splice_write, |
| 2526 | 2552 | .fallocate = ocfs2_fallocate, |
| 2553 | + .clone_file_range = ocfs2_file_clone_range, | |
| 2554 | + .dedupe_file_range = ocfs2_file_dedupe_range, | |
| 2527 | 2555 | }; |
| 2528 | 2556 | |
| 2529 | 2557 | const struct file_operations ocfs2_dops_no_plocks = { |
| @@ -82,4 +82,7 @@ int ocfs2_change_file_space(struct file *file, unsigned int cmd, · 81 unmodified lines | ||
| 82 | 82 | |
| 83 | 83 | int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos, |
| 84 | 84 | size_t count); |
| 85 | +int ocfs2_remove_inode_range(struct inode *inode, | |
| 86 | + struct buffer_head *di_bh, u64 byte_start, | |
| 87 | + u64 byte_len); | |
| 85 | 88 | #endif /* OCFS2_FILE_H */ |
| @@ -181,4 +181,10 @@ static inline struct ocfs2_inode_info *cache_info_to_inode(struct ocfs2_caching_ · 180 unmodified lines | ||
| 181 | 181 | return container_of(ci, struct ocfs2_inode_info, ip_metadata_cache); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | +/* Does this inode have the reflink flag set? */ | |
| 185 | +static inline bool ocfs2_is_refcount_inode(struct inode *inode) | |
| 186 | +{ | |
| 187 | + return (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL); | |
| 188 | +} | |
| 189 | + | |
| 184 | 190 | #endif /* OCFS2_INODE_H */ |
| @@ -235,10 +235,7 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context, · 234 unmodified lines | ||
| 235 | 235 | u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); |
| 236 | 236 | |
| 237 | 237 | if ((ext_flags & OCFS2_EXT_REFCOUNTED) && *len) { |
| 238 | − | |
| 239 | − BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & | |
| 240 | − OCFS2_HAS_REFCOUNT_FL)); | |
| 241 | − | |
| 238 | + BUG_ON(!ocfs2_is_refcount_inode(inode)); | |
| 242 | 239 | BUG_ON(!context->refcount_loc); |
| 243 | 240 | |
| 244 | 241 | ret = ocfs2_lock_refcount_tree(osb, context->refcount_loc, 1, |
| @@ -581,10 +578,7 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context, · 336 unmodified lines | ||
| 581 | 578 | phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); |
| 582 | 579 | |
| 583 | 580 | if ((ext_flags & OCFS2_EXT_REFCOUNTED) && len) { |
| 584 | − | |
| 585 | − BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & | |
| 586 | − OCFS2_HAS_REFCOUNT_FL)); | |
| 587 | − | |
| 581 | + BUG_ON(!ocfs2_is_refcount_inode(inode)); | |
| 588 | 582 | BUG_ON(!context->refcount_loc); |
| 589 | 583 | |
| 590 | 584 | ret = ocfs2_lock_refcount_tree(osb, context->refcount_loc, 1, |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | #include "xattr.h" |
| 35 | 35 | #include "namei.h" |
| 36 | 36 | #include "ocfs2_trace.h" |
| 37 | +#include "file.h" | |
| 37 | 38 | |
| 38 | 39 | #include <linux/bio.h> |
| 39 | 40 | #include <linux/blkdev.h> |
| @@ -410,7 +411,7 @@ static int ocfs2_get_refcount_block(struct inode *inode, u64 *ref_blkno) · 370 unmodified lines | ||
| 410 | 411 | goto out; |
| 411 | 412 | } |
| 412 | 413 | |
| 413 | − BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); | |
| 414 | + BUG_ON(!ocfs2_is_refcount_inode(inode)); | |
| 414 | 415 | |
| 415 | 416 | di = (struct ocfs2_dinode *)di_bh->b_data; |
| 416 | 417 | *ref_blkno = le64_to_cpu(di->i_refcount_loc); |
| @@ -570,7 +571,7 @@ static int ocfs2_create_refcount_tree(struct inode *inode, · 153 unmodified lines | ||
| 570 | 571 | u32 num_got; |
| 571 | 572 | u64 suballoc_loc, first_blkno; |
| 572 | 573 | |
| 573 | − BUG_ON(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL); | |
| 574 | + BUG_ON(ocfs2_is_refcount_inode(inode)); | |
| 574 | 575 | |
| 575 | 576 | trace_ocfs2_create_refcount_tree( |
| 576 | 577 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
| @@ -708,7 +709,7 @@ static int ocfs2_set_refcount_tree(struct inode *inode, · 131 unmodified lines | ||
| 708 | 709 | struct ocfs2_refcount_block *rb; |
| 709 | 710 | struct ocfs2_refcount_tree *ref_tree; |
| 710 | 711 | |
| 711 | − BUG_ON(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL); | |
| 712 | + BUG_ON(ocfs2_is_refcount_inode(inode)); | |
| 712 | 713 | |
| 713 | 714 | ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1, |
| 714 | 715 | &ref_tree, &ref_root_bh); |
| @@ -775,7 +776,7 @@ int ocfs2_remove_refcount_tree(struct inode *inode, struct buffer_head *di_bh) · 60 unmodified lines | ||
| 775 | 776 | u64 blk = 0, bg_blkno = 0, ref_blkno = le64_to_cpu(di->i_refcount_loc); |
| 776 | 777 | u16 bit = 0; |
| 777 | 778 | |
| 778 | − if (!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)) | |
| 779 | + if (!ocfs2_is_refcount_inode(inode)) | |
| 779 | 780 | return 0; |
| 780 | 781 | |
| 781 | 782 | BUG_ON(!ref_blkno); |
| @@ -2299,11 +2300,10 @@ int ocfs2_decrease_refcount(struct inode *inode, · 1517 unmodified lines | ||
| 2299 | 2300 | { |
| 2300 | 2301 | int ret; |
| 2301 | 2302 | u64 ref_blkno; |
| 2302 | − struct ocfs2_inode_info *oi = OCFS2_I(inode); | |
| 2303 | 2303 | struct buffer_head *ref_root_bh = NULL; |
| 2304 | 2304 | struct ocfs2_refcount_tree *tree; |
| 2305 | 2305 | |
| 2306 | − BUG_ON(!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); | |
| 2306 | + BUG_ON(!ocfs2_is_refcount_inode(inode)); | |
| 2307 | 2307 | |
| 2308 | 2308 | ret = ocfs2_get_refcount_block(inode, &ref_blkno); |
| 2309 | 2309 | if (ret) { |
| @@ -2533,7 +2533,6 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode, · 223 unmodified lines | ||
| 2533 | 2533 | int *ref_blocks) |
| 2534 | 2534 | { |
| 2535 | 2535 | int ret; |
| 2536 | − struct ocfs2_inode_info *oi = OCFS2_I(inode); | |
| 2537 | 2536 | struct buffer_head *ref_root_bh = NULL; |
| 2538 | 2537 | struct ocfs2_refcount_tree *tree; |
| 2539 | 2538 | u64 start_cpos = ocfs2_blocks_to_clusters(inode->i_sb, phys_blkno); |
| @@ -2544,7 +2543,7 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode, · 4 unmodified lines | ||
| 2544 | 2543 | goto out; |
| 2545 | 2544 | } |
| 2546 | 2545 | |
| 2547 | − BUG_ON(!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); | |
| 2546 | + BUG_ON(!ocfs2_is_refcount_inode(inode)); | |
| 2548 | 2547 | |
| 2549 | 2548 | ret = ocfs2_get_refcount_tree(OCFS2_SB(inode->i_sb), |
| 2550 | 2549 | refcount_loc, &tree); |
| @@ -3412,14 +3411,13 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode, · 861 unmodified lines | ||
| 3412 | 3411 | { |
| 3413 | 3412 | int ret; |
| 3414 | 3413 | u32 cow_start = 0, cow_len = 0; |
| 3415 | − struct ocfs2_inode_info *oi = OCFS2_I(inode); | |
| 3416 | 3414 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 3417 | 3415 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; |
| 3418 | 3416 | struct buffer_head *ref_root_bh = NULL; |
| 3419 | 3417 | struct ocfs2_refcount_tree *ref_tree; |
| 3420 | 3418 | struct ocfs2_cow_context *context = NULL; |
| 3421 | 3419 | |
| 3422 | − BUG_ON(!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); | |
| 3420 | + BUG_ON(!ocfs2_is_refcount_inode(inode)); | |
| 3423 | 3421 | |
| 3424 | 3422 | ret = ocfs2_refcount_cal_cow_clusters(inode, &di->id2.i_list, |
| 3425 | 3423 | cpos, write_len, max_cpos, |
| @@ -3629,11 +3627,10 @@ int ocfs2_refcount_cow_xattr(struct inode *inode, · 203 unmodified lines | ||
| 3629 | 3627 | { |
| 3630 | 3628 | int ret; |
| 3631 | 3629 | struct ocfs2_xattr_value_root *xv = vb->vb_xv; |
| 3632 | − struct ocfs2_inode_info *oi = OCFS2_I(inode); | |
| 3633 | 3630 | struct ocfs2_cow_context *context = NULL; |
| 3634 | 3631 | u32 cow_start, cow_len; |
| 3635 | 3632 | |
| 3636 | − BUG_ON(!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); | |
| 3633 | + BUG_ON(!ocfs2_is_refcount_inode(inode)); | |
| 3637 | 3634 | |
| 3638 | 3635 | ret = ocfs2_refcount_cal_cow_clusters(inode, &xv->xr_list, |
| 3639 | 3636 | cpos, write_len, UINT_MAX, |
| @@ -3696,6 +3693,9 @@ int ocfs2_add_refcount_flag(struct inode *inode, · 56 unmodified lines | ||
| 3696 | 3693 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 3697 | 3694 | struct ocfs2_alloc_context *meta_ac = NULL; |
| 3698 | 3695 | |
| 3696 | + /* We need to be able to handle at least an extent tree split. */ | |
| 3697 | + ref_blocks = ocfs2_extend_meta_needed(data_et->et_root_el); | |
| 3698 | + | |
| 3699 | 3699 | ret = ocfs2_calc_refcount_meta_credits(inode->i_sb, |
| 3700 | 3700 | ref_ci, ref_root_bh, |
| 3701 | 3701 | p_cluster, num_clusters, |
| @@ -3807,7 +3807,7 @@ static int ocfs2_attach_refcount_tree(struct inode *inode, · 105 unmodified lines | ||
| 3807 | 3807 | |
| 3808 | 3808 | ocfs2_init_dealloc_ctxt(&dealloc); |
| 3809 | 3809 | |
| 3810 | − if (!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)) { | |
| 3810 | + if (!ocfs2_is_refcount_inode(inode)) { | |
| 3811 | 3811 | ret = ocfs2_create_refcount_tree(inode, di_bh); |
| 3812 | 3812 | if (ret) { |
| 3813 | 3813 | mlog_errno(ret); |
| @@ -3934,6 +3934,13 @@ static int ocfs2_add_refcounted_extent(struct inode *inode, · 120 unmodified lines | ||
| 3934 | 3934 | ret = ocfs2_increase_refcount(handle, ref_ci, ref_root_bh, |
| 3935 | 3935 | p_cluster, num_clusters, |
| 3936 | 3936 | meta_ac, dealloc); |
| 3937 | + if (ret) { | |
| 3938 | + mlog_errno(ret); | |
| 3939 | + goto out_commit; | |
| 3940 | + } | |
| 3941 | + | |
| 3942 | + ret = dquot_alloc_space_nodirty(inode, | |
| 3943 | + ocfs2_clusters_to_bytes(osb->sb, num_clusters)); | |
| 3937 | 3944 | if (ret) |
| 3938 | 3945 | mlog_errno(ret); |
| 3939 | 3946 | |
| @@ -4442,3 +4449,434 @@ out: · 502 unmodified lines | ||
| 4442 | 4449 | |
| 4443 | 4450 | return error; |
| 4444 | 4451 | } |
| 4452 | + | |
| 4453 | +/* Update destination inode size, if necessary. */ | |
| 4454 | +static int ocfs2_reflink_update_dest(struct inode *dest, | |
| 4455 | + struct buffer_head *d_bh, | |
| 4456 | + loff_t newlen) | |
| 4457 | +{ | |
| 4458 | + handle_t *handle; | |
| 4459 | + int ret; | |
| 4460 | + | |
| 4461 | + dest->i_blocks = ocfs2_inode_sector_count(dest); | |
| 4462 | + | |
| 4463 | + if (newlen <= i_size_read(dest)) | |
| 4464 | + return 0; | |
| 4465 | + | |
| 4466 | + handle = ocfs2_start_trans(OCFS2_SB(dest->i_sb), | |
| 4467 | + OCFS2_INODE_UPDATE_CREDITS); | |
| 4468 | + if (IS_ERR(handle)) { | |
| 4469 | + ret = PTR_ERR(handle); | |
| 4470 | + mlog_errno(ret); | |
| 4471 | + return ret; | |
| 4472 | + } | |
| 4473 | + | |
| 4474 | + /* Extend i_size if needed. */ | |
| 4475 | + spin_lock(&OCFS2_I(dest)->ip_lock); | |
| 4476 | + if (newlen > i_size_read(dest)) | |
| 4477 | + i_size_write(dest, newlen); | |
| 4478 | + spin_unlock(&OCFS2_I(dest)->ip_lock); | |
| 4479 | + dest->i_ctime = dest->i_mtime = current_time(dest); | |
| 4480 | + | |
| 4481 | + ret = ocfs2_mark_inode_dirty(handle, dest, d_bh); | |
| 4482 | + if (ret) { | |
| 4483 | + mlog_errno(ret); | |
| 4484 | + goto out_commit; | |
| 4485 | + } | |
| 4486 | + | |
| 4487 | +out_commit: | |
| 4488 | + ocfs2_commit_trans(OCFS2_SB(dest->i_sb), handle); | |
| 4489 | + return ret; | |
| 4490 | +} | |
| 4491 | + | |
| 4492 | +/* Remap the range pos_in:len in s_inode to pos_out:len in t_inode. */ | |
| 4493 | +static int ocfs2_reflink_remap_extent(struct inode *s_inode, | |
| 4494 | + struct buffer_head *s_bh, | |
| 4495 | + loff_t pos_in, | |
| 4496 | + struct inode *t_inode, | |
| 4497 | + struct buffer_head *t_bh, | |
| 4498 | + loff_t pos_out, | |
| 4499 | + loff_t len, | |
| 4500 | + struct ocfs2_cached_dealloc_ctxt *dealloc) | |
| 4501 | +{ | |
| 4502 | + struct ocfs2_extent_tree s_et; | |
| 4503 | + struct ocfs2_extent_tree t_et; | |
| 4504 | + struct ocfs2_dinode *dis; | |
| 4505 | + struct buffer_head *ref_root_bh = NULL; | |
| 4506 | + struct ocfs2_refcount_tree *ref_tree; | |
| 4507 | + struct ocfs2_super *osb; | |
| 4508 | + loff_t pstart, plen; | |
| 4509 | + u32 p_cluster, num_clusters, slast, spos, tpos; | |
| 4510 | + unsigned int ext_flags; | |
| 4511 | + int ret = 0; | |
| 4512 | + | |
| 4513 | + osb = OCFS2_SB(s_inode->i_sb); | |
| 4514 | + dis = (struct ocfs2_dinode *)s_bh->b_data; | |
| 4515 | + ocfs2_init_dinode_extent_tree(&s_et, INODE_CACHE(s_inode), s_bh); | |
| 4516 | + ocfs2_init_dinode_extent_tree(&t_et, INODE_CACHE(t_inode), t_bh); | |
| 4517 | + | |
| 4518 | + spos = ocfs2_bytes_to_clusters(s_inode->i_sb, pos_in); | |
| 4519 | + tpos = ocfs2_bytes_to_clusters(t_inode->i_sb, pos_out); | |
| 4520 | + slast = ocfs2_clusters_for_bytes(s_inode->i_sb, pos_in + len); | |
| 4521 | + | |
| 4522 | + while (spos < slast) { | |
| 4523 | + if (fatal_signal_pending(current)) { | |
| 4524 | + ret = -EINTR; | |
| 4525 | + goto out; | |
| 4526 | + } | |
| 4527 | + | |
| 4528 | + /* Look up the extent. */ | |
| 4529 | + ret = ocfs2_get_clusters(s_inode, spos, &p_cluster, | |
| 4530 | + &num_clusters, &ext_flags); | |
| 4531 | + if (ret) { | |
| 4532 | + mlog_errno(ret); | |
| 4533 | + goto out; | |
| 4534 | + } | |
| 4535 | + | |
| 4536 | + num_clusters = min_t(u32, num_clusters, slast - spos); | |
| 4537 | + | |
| 4538 | + /* Punch out the dest range. */ | |
| 4539 | + pstart = ocfs2_clusters_to_bytes(t_inode->i_sb, tpos); | |
| 4540 | + plen = ocfs2_clusters_to_bytes(t_inode->i_sb, num_clusters); | |
| 4541 | + ret = ocfs2_remove_inode_range(t_inode, t_bh, pstart, plen); | |
| 4542 | + if (ret) { | |
| 4543 | + mlog_errno(ret); | |
| 4544 | + goto out; | |
| 4545 | + } | |
| 4546 | + | |
| 4547 | + if (p_cluster == 0) | |
| 4548 | + goto next_loop; | |
| 4549 | + | |
| 4550 | + /* Lock the refcount btree... */ | |
| 4551 | + ret = ocfs2_lock_refcount_tree(osb, | |
| 4552 | + le64_to_cpu(dis->i_refcount_loc), | |
| 4553 | + 1, &ref_tree, &ref_root_bh); | |
| 4554 | + if (ret) { | |
| 4555 | + mlog_errno(ret); | |
| 4556 | + goto out; | |
| 4557 | + } | |
| 4558 | + | |
| 4559 | + /* Mark s_inode's extent as refcounted. */ | |
| 4560 | + if (!(ext_flags & OCFS2_EXT_REFCOUNTED)) { | |
| 4561 | + ret = ocfs2_add_refcount_flag(s_inode, &s_et, | |
| 4562 | + &ref_tree->rf_ci, | |
| 4563 | + ref_root_bh, spos, | |
| 4564 | + p_cluster, num_clusters, | |
| 4565 | + dealloc, NULL); | |
| 4566 | + if (ret) { | |
| 4567 | + mlog_errno(ret); | |
| 4568 | + goto out_unlock_refcount; | |
| 4569 | + } | |
| 4570 | + } | |
| 4571 | + | |
| 4572 | + /* Map in the new extent. */ | |
| 4573 | + ext_flags |= OCFS2_EXT_REFCOUNTED; | |
| 4574 | + ret = ocfs2_add_refcounted_extent(t_inode, &t_et, | |
| 4575 | + &ref_tree->rf_ci, | |
| 4576 | + ref_root_bh, | |
| 4577 | + tpos, p_cluster, | |
| 4578 | + num_clusters, | |
| 4579 | + ext_flags, | |
| 4580 | + dealloc); | |
| 4581 | + if (ret) { | |
| 4582 | + mlog_errno(ret); | |
| 4583 | + goto out_unlock_refcount; | |
| 4584 | + } | |
| 4585 | + | |
| 4586 | + ocfs2_unlock_refcount_tree(osb, ref_tree, 1); | |
| 4587 | + brelse(ref_root_bh); | |
| 4588 | +next_loop: | |
| 4589 | + spos += num_clusters; | |
| 4590 | + tpos += num_clusters; | |
| 4591 | + } | |
| 4592 | + | |
| 4593 | +out: | |
| 4594 | + return ret; | |
| 4595 | +out_unlock_refcount: | |
| 4596 | + ocfs2_unlock_refcount_tree(osb, ref_tree, 1); | |
| 4597 | + brelse(ref_root_bh); | |
| 4598 | + return ret; | |
| 4599 | +} | |
| 4600 | + | |
| 4601 | +/* Set up refcount tree and remap s_inode to t_inode. */ | |
| 4602 | +static int ocfs2_reflink_remap_blocks(struct inode *s_inode, | |
| 4603 | + struct buffer_head *s_bh, | |
| 4604 | + loff_t pos_in, | |
| 4605 | + struct inode *t_inode, | |
| 4606 | + struct buffer_head *t_bh, | |
| 4607 | + loff_t pos_out, | |
| 4608 | + loff_t len) | |
| 4609 | +{ | |
| 4610 | + struct ocfs2_cached_dealloc_ctxt dealloc; | |
| 4611 | + struct ocfs2_super *osb; | |
| 4612 | + struct ocfs2_dinode *dis; | |
| 4613 | + struct ocfs2_dinode *dit; | |
| 4614 | + int ret; | |
| 4615 | + | |
| 4616 | + osb = OCFS2_SB(s_inode->i_sb); | |
| 4617 | + dis = (struct ocfs2_dinode *)s_bh->b_data; | |
| 4618 | + dit = (struct ocfs2_dinode *)t_bh->b_data; | |
| 4619 | + ocfs2_init_dealloc_ctxt(&dealloc); | |
| 4620 | + | |
| 4621 | + /* | |
| 4622 | + * If we're reflinking the entire file and the source is inline | |
| 4623 | + * data, just copy the contents. | |
| 4624 | + */ | |
| 4625 | + if (pos_in == pos_out && pos_in == 0 && len == i_size_read(s_inode) && | |
| 4626 | + i_size_read(t_inode) <= len && | |
| 4627 | + (OCFS2_I(s_inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)) { | |
| 4628 | + ret = ocfs2_duplicate_inline_data(s_inode, s_bh, t_inode, t_bh); | |
| 4629 | + if (ret) | |
| 4630 | + mlog_errno(ret); | |
| 4631 | + goto out; | |
| 4632 | + } | |
| 4633 | + | |
| 4634 | + /* | |
| 4635 | + * If both inodes belong to two different refcount groups then | |
| 4636 | + * forget it because we don't know how (or want) to go merging | |
| 4637 | + * refcount trees. | |
| 4638 | + */ | |
| 4639 | + ret = -EOPNOTSUPP; | |
| 4640 | + if (ocfs2_is_refcount_inode(s_inode) && | |
| 4641 | + ocfs2_is_refcount_inode(t_inode) && | |
| 4642 | + le64_to_cpu(dis->i_refcount_loc) != | |
| 4643 | + le64_to_cpu(dit->i_refcount_loc)) | |
| 4644 | + goto out; | |
| 4645 | + | |
| 4646 | + /* Neither inode has a refcount tree. Add one to s_inode. */ | |
| 4647 | + if (!ocfs2_is_refcount_inode(s_inode) && | |
| 4648 | + !ocfs2_is_refcount_inode(t_inode)) { | |
| 4649 | + ret = ocfs2_create_refcount_tree(s_inode, s_bh); | |
| 4650 | + if (ret) { | |
| 4651 | + mlog_errno(ret); | |
| 4652 | + goto out; | |
| 4653 | + } | |
| 4654 | + } | |
| 4655 | + | |
| 4656 | + /* Ensure that both inodes end up with the same refcount tree. */ | |
| 4657 | + if (!ocfs2_is_refcount_inode(s_inode)) { | |
| 4658 | + ret = ocfs2_set_refcount_tree(s_inode, s_bh, | |
| 4659 | + le64_to_cpu(dit->i_refcount_loc)); | |
| 4660 | + if (ret) { | |
| 4661 | + mlog_errno(ret); | |
| 4662 | + goto out; | |
| 4663 | + } | |
| 4664 | + } | |
| 4665 | + if (!ocfs2_is_refcount_inode(t_inode)) { | |
| 4666 | + ret = ocfs2_set_refcount_tree(t_inode, t_bh, | |
| 4667 | + le64_to_cpu(dis->i_refcount_loc)); | |
| 4668 | + if (ret) { | |
| 4669 | + mlog_errno(ret); | |
| 4670 | + goto out; | |
| 4671 | + } | |
| 4672 | + } | |
| 4673 | + | |
| 4674 | + /* Turn off inline data in the dest file. */ | |
| 4675 | + if (OCFS2_I(t_inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { | |
| 4676 | + ret = ocfs2_convert_inline_data_to_extents(t_inode, t_bh); | |
| 4677 | + if (ret) { | |
| 4678 | + mlog_errno(ret); | |
| 4679 | + goto out; | |
| 4680 | + } | |
| 4681 | + } | |
| 4682 | + | |
| 4683 | + /* Actually remap extents now. */ | |
| 4684 | + ret = ocfs2_reflink_remap_extent(s_inode, s_bh, pos_in, t_inode, t_bh, | |
| 4685 | + pos_out, len, &dealloc); | |
| 4686 | + if (ret) { | |
| 4687 | + mlog_errno(ret); | |
| 4688 | + goto out; | |
| 4689 | + } | |
| 4690 | + | |
| 4691 | +out: | |
| 4692 | + if (ocfs2_dealloc_has_cluster(&dealloc)) { | |
| 4693 | + ocfs2_schedule_truncate_log_flush(osb, 1); | |
| 4694 | + ocfs2_run_deallocs(osb, &dealloc); | |
| 4695 | + } | |
| 4696 | + | |
| 4697 | + return ret; | |
| 4698 | +} | |
| 4699 | + | |
| 4700 | +/* Lock an inode and grab a bh pointing to the inode. */ | |
| 4701 | +static int ocfs2_reflink_inodes_lock(struct inode *s_inode, | |
| 4702 | + struct buffer_head **bh1, | |
| 4703 | + struct inode *t_inode, | |
| 4704 | + struct buffer_head **bh2) | |
| 4705 | +{ | |
| 4706 | + struct inode *inode1; | |
| 4707 | + struct inode *inode2; | |
| 4708 | + struct ocfs2_inode_info *oi1; | |
| 4709 | + struct ocfs2_inode_info *oi2; | |
| 4710 | + bool same_inode = (s_inode == t_inode); | |
| 4711 | + int status; | |
| 4712 | + | |
| 4713 | + /* First grab the VFS and rw locks. */ | |
| 4714 | + lock_two_nondirectories(s_inode, t_inode); | |
| 4715 | + inode1 = s_inode; | |
| 4716 | + inode2 = t_inode; | |
| 4717 | + if (inode1->i_ino > inode2->i_ino) | |
| 4718 | + swap(inode1, inode2); | |
| 4719 | + | |
| 4720 | + status = ocfs2_rw_lock(inode1, 1); | |
| 4721 | + if (status) { | |
| 4722 | + mlog_errno(status); | |
| 4723 | + goto out_i1; | |
| 4724 | + } | |
| 4725 | + if (!same_inode) { | |
| 4726 | + status = ocfs2_rw_lock(inode2, 1); | |
| 4727 | + if (status) { | |
| 4728 | + mlog_errno(status); | |
| 4729 | + goto out_i2; | |
| 4730 | + } | |
| 4731 | + } | |
| 4732 | + | |
| 4733 | + /* Now go for the cluster locks */ | |
| 4734 | + oi1 = OCFS2_I(inode1); | |
| 4735 | + oi2 = OCFS2_I(inode2); | |
| 4736 | + | |
| 4737 | + trace_ocfs2_double_lock((unsigned long long)oi1->ip_blkno, | |
| 4738 | + (unsigned long long)oi2->ip_blkno); | |
| 4739 | + | |
| 4740 | + if (*bh1) | |
| 4741 | + *bh1 = NULL; | |
| 4742 | + if (*bh2) | |
| 4743 | + *bh2 = NULL; | |
| 4744 | + | |
| 4745 | + /* We always want to lock the one with the lower lockid first. */ | |
| 4746 | + if (oi1->ip_blkno > oi2->ip_blkno) | |
| 4747 | + mlog_errno(-ENOLCK); | |
| 4748 | + | |
| 4749 | + /* lock id1 */ | |
| 4750 | + status = ocfs2_inode_lock_nested(inode1, bh1, 1, OI_LS_REFLINK_TARGET); | |
| 4751 | + if (status < 0) { | |
| 4752 | + if (status != -ENOENT) | |
| 4753 | + mlog_errno(status); | |
| 4754 | + goto out_rw2; | |
| 4755 | + } | |
| 4756 | + | |
| 4757 | + /* lock id2 */ | |
| 4758 | + if (!same_inode) { | |
| 4759 | + status = ocfs2_inode_lock_nested(inode2, bh2, 1, | |
| 4760 | + OI_LS_REFLINK_TARGET); | |
| 4761 | + if (status < 0) { | |
| 4762 | + if (status != -ENOENT) | |
| 4763 | + mlog_errno(status); | |
| 4764 | + goto out_cl1; | |
| 4765 | + } | |
| 4766 | + } else | |
| 4767 | + *bh2 = *bh1; | |
| 4768 | + | |
| 4769 | + trace_ocfs2_double_lock_end( | |
| 4770 | + (unsigned long long)OCFS2_I(inode1)->ip_blkno, | |
| 4771 | + (unsigned long long)OCFS2_I(inode2)->ip_blkno); | |
| 4772 | + | |
| 4773 | + return 0; | |
| 4774 | + | |
| 4775 | +out_cl1: | |
| 4776 | + ocfs2_inode_unlock(inode1, 1); | |
| 4777 | + brelse(*bh1); | |
| 4778 | + *bh1 = NULL; | |
| 4779 | +out_rw2: | |
| 4780 | + ocfs2_rw_unlock(inode2, 1); | |
| 4781 | +out_i2: | |
| 4782 | + ocfs2_rw_unlock(inode1, 1); | |
| 4783 | +out_i1: | |
| 4784 | + unlock_two_nondirectories(s_inode, t_inode); | |
| 4785 | + return status; | |
| 4786 | +} | |
| 4787 | + | |
| 4788 | +/* Unlock both inodes and release buffers. */ | |
| 4789 | +static void ocfs2_reflink_inodes_unlock(struct inode *s_inode, | |
| 4790 | + struct buffer_head *s_bh, | |
| 4791 | + struct inode *t_inode, | |
| 4792 | + struct buffer_head *t_bh) | |
| 4793 | +{ | |
| 4794 | + ocfs2_inode_unlock(s_inode, 1); | |
| 4795 | + ocfs2_rw_unlock(s_inode, 1); | |
| 4796 | + brelse(s_bh); | |
| 4797 | + if (s_inode != t_inode) { | |
| 4798 | + ocfs2_inode_unlock(t_inode, 1); | |
| 4799 | + ocfs2_rw_unlock(t_inode, 1); | |
| 4800 | + brelse(t_bh); | |
| 4801 | + } | |
| 4802 | + unlock_two_nondirectories(s_inode, t_inode); | |
| 4803 | +} | |
| 4804 | + | |
| 4805 | +/* Link a range of blocks from one file to another. */ | |
| 4806 | +int ocfs2_reflink_remap_range(struct file *file_in, | |
| 4807 | + loff_t pos_in, | |
| 4808 | + struct file *file_out, | |
| 4809 | + loff_t pos_out, | |
| 4810 | + u64 len, | |
| 4811 | + bool is_dedupe) | |
| 4812 | +{ | |
| 4813 | + struct inode *inode_in = file_inode(file_in); | |
| 4814 | + struct inode *inode_out = file_inode(file_out); | |
| 4815 | + struct ocfs2_super *osb = OCFS2_SB(inode_in->i_sb); | |
| 4816 | + struct buffer_head *in_bh = NULL, *out_bh = NULL; | |
| 4817 | + bool same_inode = (inode_in == inode_out); | |
| 4818 | + ssize_t ret; | |
| 4819 | + | |
| 4820 | + if (!ocfs2_refcount_tree(osb)) | |
| 4821 | + return -EOPNOTSUPP; | |
| 4822 | + if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) | |
| 4823 | + return -EROFS; | |
| 4824 | + | |
| 4825 | + /* Lock both files against IO */ | |
| 4826 | + ret = ocfs2_reflink_inodes_lock(inode_in, &in_bh, inode_out, &out_bh); | |
| 4827 | + if (ret) | |
| 4828 | + return ret; | |
| 4829 | + | |
| 4830 | + /* Check file eligibility and prepare for block sharing. */ | |
| 4831 | + ret = -EINVAL; | |
| 4832 | + if ((OCFS2_I(inode_in)->ip_flags & OCFS2_INODE_SYSTEM_FILE) || | |
| 4833 | + (OCFS2_I(inode_out)->ip_flags & OCFS2_INODE_SYSTEM_FILE)) | |
| 4834 | + goto out_unlock; | |
| 4835 | + | |
| 4836 | + ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, | |
| 4837 | + &len, is_dedupe); | |
| 4838 | + if (ret || len == 0) | |
| 4839 | + goto out_unlock; | |
| 4840 | + | |
| 4841 | + /* Lock out changes to the allocation maps and remap. */ | |
| 4842 | + down_write(&OCFS2_I(inode_in)->ip_alloc_sem); | |
| 4843 | + if (!same_inode) | |
| 4844 | + down_write_nested(&OCFS2_I(inode_out)->ip_alloc_sem, | |
| 4845 | + SINGLE_DEPTH_NESTING); | |
| 4846 | + | |
| 4847 | + ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, | |
| 4848 | + out_bh, pos_out, len); | |
| 4849 | + | |
| 4850 | + /* Zap any page cache for the destination file's range. */ | |
| 4851 | + if (!ret) | |
| 4852 | + truncate_inode_pages_range(&inode_out->i_data, pos_out, | |
| 4853 | + PAGE_ALIGN(pos_out + len) - 1); | |
| 4854 | + | |
| 4855 | + up_write(&OCFS2_I(inode_in)->ip_alloc_sem); | |
| 4856 | + if (!same_inode) | |
| 4857 | + up_write(&OCFS2_I(inode_out)->ip_alloc_sem); | |
| 4858 | + if (ret) { | |
| 4859 | + mlog_errno(ret); | |
| 4860 | + goto out_unlock; | |
| 4861 | + } | |
| 4862 | + | |
| 4863 | + /* | |
| 4864 | + * Empty the extent map so that we may get the right extent | |
| 4865 | + * record from the disk. | |
| 4866 | + */ | |
| 4867 | + ocfs2_extent_map_trunc(inode_in, 0); | |
| 4868 | + ocfs2_extent_map_trunc(inode_out, 0); | |
| 4869 | + | |
| 4870 | + ret = ocfs2_reflink_update_dest(inode_out, out_bh, pos_out + len); | |
| 4871 | + if (ret) { | |
| 4872 | + mlog_errno(ret); | |
| 4873 | + goto out_unlock; | |
| 4874 | + } | |
| 4875 | + | |
| 4876 | + ocfs2_reflink_inodes_unlock(inode_in, in_bh, inode_out, out_bh); | |
| 4877 | + return 0; | |
| 4878 | + | |
| 4879 | +out_unlock: | |
| 4880 | + ocfs2_reflink_inodes_unlock(inode_in, in_bh, inode_out, out_bh); | |
| 4881 | + return ret; | |
| 4882 | +} | |
| @@ -115,4 +115,11 @@ int ocfs2_reflink_ioctl(struct inode *inode, · 114 unmodified lines | ||
| 115 | 115 | const char __user *oldname, |
| 116 | 116 | const char __user *newname, |
| 117 | 117 | bool preserve); |
| 118 | +int ocfs2_reflink_remap_range(struct file *file_in, | |
| 119 | + loff_t pos_in, | |
| 120 | + struct file *file_out, | |
| 121 | + loff_t pos_out, | |
| 122 | + u64 len, | |
| 123 | + bool is_dedupe); | |
| 124 | + | |
| 118 | 125 | #endif /* OCFS2_REFCOUNTTREE_H */ |
| @@ -2577,7 +2577,7 @@ int ocfs2_xattr_remove(struct inode *inode, struct buffer_head *di_bh) · 2576 unmodified lines | ||
| 2577 | 2577 | if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL)) |
| 2578 | 2578 | return 0; |
| 2579 | 2579 | |
| 2580 | − if (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL) { | |
| 2580 | + if (ocfs2_is_refcount_inode(inode)) { | |
| 2581 | 2581 | ret = ocfs2_lock_refcount_tree(OCFS2_SB(inode->i_sb), |
| 2582 | 2582 | le64_to_cpu(di->i_refcount_loc), |
| 2583 | 2583 | 1, &ref_tree, &ref_root_bh); |
| @@ -3608,7 +3608,7 @@ int ocfs2_xattr_set(struct inode *inode, · 1024 unmodified lines | ||
| 3608 | 3608 | } |
| 3609 | 3609 | |
| 3610 | 3610 | /* Check whether the value is refcounted and do some preparation. */ |
| 3611 | − if (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL && | |
| 3611 | + if (ocfs2_is_refcount_inode(inode) && | |
| 3612 | 3612 | (!xis.not_found || !xbs.not_found)) { |
| 3613 | 3613 | ret = ocfs2_prepare_refcount_xattr(inode, di, &xi, |
| 3614 | 3614 | &xis, &xbs, &ref_tree, |
| @@ -328,11 +328,11 @@ static struct dentry *ovl_d_real(struct dentry *dentry, · 327 unmodified lines | ||
| 328 | 328 | if (!real) |
| 329 | 329 | goto bug; |
| 330 | 330 | |
| 331 | + /* Handle recursion */ | |
| 332 | + real = d_real(real, inode, open_flags); | |
| 333 | + | |
| 331 | 334 | if (!inode || inode == d_inode(real)) |
| 332 | 335 | return real; |
| 333 | − | |
| 334 | − /* Handle recursion */ | |
| 335 | − return d_real(real, inode, open_flags); | |
| 336 | 336 | bug: |
| 337 | 337 | WARN(1, "ovl_d_real(%pd4, %s:%lu): real dentry not found\n", dentry, |
| 338 | 338 | inode ? inode->i_sb->s_id : "NULL", inode ? inode->i_ino : 0); |
| @@ -1542,20 +1542,37 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, · 1541 unmodified lines | ||
| 1542 | 1542 | if (ret) |
| 1543 | 1543 | return ret; |
| 1544 | 1544 | |
| 1545 | − ret = -EOPNOTSUPP; | |
| 1546 | − if (file_out->f_op->copy_file_range) | |
| 1545 | + /* | |
| 1546 | + * Try cloning first, this is supported by more file systems, and | |
| 1547 | + * more efficient if both clone and copy are supported (e.g. NFS). | |
| 1548 | + */ | |
| 1549 | + if (file_in->f_op->clone_file_range) { | |
| 1550 | + ret = file_in->f_op->clone_file_range(file_in, pos_in, | |
| 1551 | + file_out, pos_out, len); | |
| 1552 | + if (ret == 0) { | |
| 1553 | + ret = len; | |
| 1554 | + goto done; | |
| 1555 | + } | |
| 1556 | + } | |
| 1557 | + | |
| 1558 | + if (file_out->f_op->copy_file_range) { | |
| 1547 | 1559 | ret = file_out->f_op->copy_file_range(file_in, pos_in, file_out, |
| 1548 | 1560 | pos_out, len, flags); |
| 1549 | − if (ret == -EOPNOTSUPP) | |
| 1550 | − ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out, | |
| 1551 | − len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0); | |
| 1561 | + if (ret != -EOPNOTSUPP) | |
| 1562 | + goto done; | |
| 1563 | + } | |
| 1564 | + | |
| 1565 | + ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out, | |
| 1566 | + len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0); | |
| 1552 | 1567 | |
| 1568 | +done: | |
| 1553 | 1569 | if (ret > 0) { |
| 1554 | 1570 | fsnotify_access(file_in); |
| 1555 | 1571 | add_rchar(current, ret); |
| 1556 | 1572 | fsnotify_modify(file_out); |
| 1557 | 1573 | add_wchar(current, ret); |
| 1558 | 1574 | } |
| 1575 | + | |
| 1559 | 1576 | inc_syscr(current); |
| 1560 | 1577 | inc_syscw(current); |
| 1561 | 1578 | |
| @@ -1650,6 +1667,114 @@ static int clone_verify_area(struct file *file, loff_t pos, u64 len, bool write) · 88 unmodified lines | ||
| 1650 | 1667 | return security_file_permission(file, write ? MAY_WRITE : MAY_READ); |
| 1651 | 1668 | } |
| 1652 | 1669 | |
| 1670 | +/* | |
| 1671 | + * Check that the two inodes are eligible for cloning, the ranges make | |
| 1672 | + * sense, and then flush all dirty data. Caller must ensure that the | |
| 1673 | + * inodes have been locked against any other modifications. | |
| 1674 | + */ | |
| 1675 | +int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, | |
| 1676 | + struct inode *inode_out, loff_t pos_out, | |
| 1677 | + u64 *len, bool is_dedupe) | |
| 1678 | +{ | |
| 1679 | + loff_t bs = inode_out->i_sb->s_blocksize; | |
| 1680 | + loff_t blen; | |
| 1681 | + loff_t isize; | |
| 1682 | + bool same_inode = (inode_in == inode_out); | |
| 1683 | + int ret; | |
| 1684 | + | |
| 1685 | + /* Don't touch certain kinds of inodes */ | |
| 1686 | + if (IS_IMMUTABLE(inode_out)) | |
| 1687 | + return -EPERM; | |
| 1688 | + | |
| 1689 | + if (IS_SWAPFILE(inode_in) || IS_SWAPFILE(inode_out)) | |
| 1690 | + return -ETXTBSY; | |
| 1691 | + | |
| 1692 | + /* Don't reflink dirs, pipes, sockets... */ | |
| 1693 | + if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) | |
| 1694 | + return -EISDIR; | |
| 1695 | + if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) | |
| 1696 | + return -EINVAL; | |
| 1697 | + | |
| 1698 | + /* Are we going all the way to the end? */ | |
| 1699 | + isize = i_size_read(inode_in); | |
| 1700 | + if (isize == 0) { | |
| 1701 | + *len = 0; | |
| 1702 | + return 0; | |
| 1703 | + } | |
| 1704 | + | |
| 1705 | + /* Zero length dedupe exits immediately; reflink goes to EOF. */ | |
| 1706 | + if (*len == 0) { | |
| 1707 | + if (is_dedupe) { | |
| 1708 | + *len = 0; | |
| 1709 | + return 0; | |
| 1710 | + } | |
| 1711 | + *len = isize - pos_in; | |
| 1712 | + } | |
| 1713 | + | |
| 1714 | + /* Ensure offsets don't wrap and the input is inside i_size */ | |
| 1715 | + if (pos_in + *len < pos_in || pos_out + *len < pos_out || | |
| 1716 | + pos_in + *len > isize) | |
| 1717 | + return -EINVAL; | |
| 1718 | + | |
| 1719 | + /* Don't allow dedupe past EOF in the dest file */ | |
| 1720 | + if (is_dedupe) { | |
| 1721 | + loff_t disize; | |
| 1722 | + | |
| 1723 | + disize = i_size_read(inode_out); | |
| 1724 | + if (pos_out >= disize || pos_out + *len > disize) | |
| 1725 | + return -EINVAL; | |
| 1726 | + } | |
| 1727 | + | |
| 1728 | + /* If we're linking to EOF, continue to the block boundary. */ | |
| 1729 | + if (pos_in + *len == isize) | |
| 1730 | + blen = ALIGN(isize, bs) - pos_in; | |
| 1731 | + else | |
| 1732 | + blen = *len; | |
| 1733 | + | |
| 1734 | + /* Only reflink if we're aligned to block boundaries */ | |
| 1735 | + if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_in + blen, bs) || | |
| 1736 | + !IS_ALIGNED(pos_out, bs) || !IS_ALIGNED(pos_out + blen, bs)) | |
| 1737 | + return -EINVAL; | |
| 1738 | + | |
| 1739 | + /* Don't allow overlapped reflink within the same file */ | |
| 1740 | + if (same_inode) { | |
| 1741 | + if (pos_out + blen > pos_in && pos_out < pos_in + blen) | |
| 1742 | + return -EINVAL; | |
| 1743 | + } | |
| 1744 | + | |
| 1745 | + /* Wait for the completion of any pending IOs on both files */ | |
| 1746 | + inode_dio_wait(inode_in); | |
| 1747 | + if (!same_inode) | |
| 1748 | + inode_dio_wait(inode_out); | |
| 1749 | + | |
| 1750 | + ret = filemap_write_and_wait_range(inode_in->i_mapping, | |
| 1751 | + pos_in, pos_in + *len - 1); | |
| 1752 | + if (ret) | |
| 1753 | + return ret; | |
| 1754 | + | |
| 1755 | + ret = filemap_write_and_wait_range(inode_out->i_mapping, | |
| 1756 | + pos_out, pos_out + *len - 1); | |
| 1757 | + if (ret) | |
| 1758 | + return ret; | |
| 1759 | + | |
| 1760 | + /* | |
| 1761 | + * Check that the extents are the same. | |
| 1762 | + */ | |
| 1763 | + if (is_dedupe) { | |
| 1764 | + bool is_same = false; | |
| 1765 | + | |
| 1766 | + ret = vfs_dedupe_file_range_compare(inode_in, pos_in, | |
| 1767 | + inode_out, pos_out, *len, &is_same); | |
| 1768 | + if (ret) | |
| 1769 | + return ret; | |
| 1770 | + if (!is_same) | |
| 1771 | + return -EBADE; | |
| 1772 | + } | |
| 1773 | + | |
| 1774 | + return 0; | |
| 1775 | +} | |
| 1776 | +EXPORT_SYMBOL(vfs_clone_file_prep_inodes); | |
| 1777 | + | |
| 1653 | 1778 | int vfs_clone_file_range(struct file *file_in, loff_t pos_in, |
| 1654 | 1779 | struct file *file_out, loff_t pos_out, u64 len) |
| 1655 | 1780 | { |
| @@ -1701,6 +1826,102 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in, · 45 unmodified lines | ||
| 1701 | 1826 | } |
| 1702 | 1827 | EXPORT_SYMBOL(vfs_clone_file_range); |
| 1703 | 1828 | |
| 1829 | +/* | |
| 1830 | + * Read a page's worth of file data into the page cache. Return the page | |
| 1831 | + * locked. | |
| 1832 | + */ | |
| 1833 | +static struct page *vfs_dedupe_get_page(struct inode *inode, loff_t offset) | |
| 1834 | +{ | |
| 1835 | + struct address_space *mapping; | |
| 1836 | + struct page *page; | |
| 1837 | + pgoff_t n; | |
| 1838 | + | |
| 1839 | + n = offset >> PAGE_SHIFT; | |
| 1840 | + mapping = inode->i_mapping; | |
| 1841 | + page = read_mapping_page(mapping, n, NULL); | |
| 1842 | + if (IS_ERR(page)) | |
| 1843 | + return page; | |
| 1844 | + if (!PageUptodate(page)) { | |
| 1845 | + put_page(page); | |
| 1846 | + return ERR_PTR(-EIO); | |
| 1847 | + } | |
| 1848 | + lock_page(page); | |
| 1849 | + return page; | |
| 1850 | +} | |
| 1851 | + | |
| 1852 | +/* | |
| 1853 | + * Compare extents of two files to see if they are the same. | |
| 1854 | + * Caller must have locked both inodes to prevent write races. | |
| 1855 | + */ | |
| 1856 | +int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, | |
| 1857 | + struct inode *dest, loff_t destoff, | |
| 1858 | + loff_t len, bool *is_same) | |
| 1859 | +{ | |
| 1860 | + loff_t src_poff; | |
| 1861 | + loff_t dest_poff; | |
| 1862 | + void *src_addr; | |
| 1863 | + void *dest_addr; | |
| 1864 | + struct page *src_page; | |
| 1865 | + struct page *dest_page; | |
| 1866 | + loff_t cmp_len; | |
| 1867 | + bool same; | |
| 1868 | + int error; | |
| 1869 | + | |
| 1870 | + error = -EINVAL; | |
| 1871 | + same = true; | |
| 1872 | + while (len) { | |
| 1873 | + src_poff = srcoff & (PAGE_SIZE - 1); | |
| 1874 | + dest_poff = destoff & (PAGE_SIZE - 1); | |
| 1875 | + cmp_len = min(PAGE_SIZE - src_poff, | |
| 1876 | + PAGE_SIZE - dest_poff); | |
| 1877 | + cmp_len = min(cmp_len, len); | |
| 1878 | + if (cmp_len <= 0) | |
| 1879 | + goto out_error; | |
| 1880 | + | |
| 1881 | + src_page = vfs_dedupe_get_page(src, srcoff); | |
| 1882 | + if (IS_ERR(src_page)) { | |
| 1883 | + error = PTR_ERR(src_page); | |
| 1884 | + goto out_error; | |
| 1885 | + } | |
| 1886 | + dest_page = vfs_dedupe_get_page(dest, destoff); | |
| 1887 | + if (IS_ERR(dest_page)) { | |
| 1888 | + error = PTR_ERR(dest_page); | |
| 1889 | + unlock_page(src_page); | |
| 1890 | + put_page(src_page); | |
| 1891 | + goto out_error; | |
| 1892 | + } | |
| 1893 | + src_addr = kmap_atomic(src_page); | |
| 1894 | + dest_addr = kmap_atomic(dest_page); | |
| 1895 | + | |
| 1896 | + flush_dcache_page(src_page); | |
| 1897 | + flush_dcache_page(dest_page); | |
| 1898 | + | |
| 1899 | + if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len)) | |
| 1900 | + same = false; | |
| 1901 | + | |
| 1902 | + kunmap_atomic(dest_addr); | |
| 1903 | + kunmap_atomic(src_addr); | |
| 1904 | + unlock_page(dest_page); | |
| 1905 | + unlock_page(src_page); | |
| 1906 | + put_page(dest_page); | |
| 1907 | + put_page(src_page); | |
| 1908 | + | |
| 1909 | + if (!same) | |
| 1910 | + break; | |
| 1911 | + | |
| 1912 | + srcoff += cmp_len; | |
| 1913 | + destoff += cmp_len; | |
| 1914 | + len -= cmp_len; | |
| 1915 | + } | |
| 1916 | + | |
| 1917 | + *is_same = same; | |
| 1918 | + return 0; | |
| 1919 | + | |
| 1920 | +out_error: | |
| 1921 | + return error; | |
| 1922 | +} | |
| 1923 | +EXPORT_SYMBOL(vfs_dedupe_file_range_compare); | |
| 1924 | + | |
| 1704 | 1925 | int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) |
| 1705 | 1926 | { |
| 1706 | 1927 | struct file_dedupe_range_info *info; |
| @@ -909,24 +909,6 @@ out_unlock: · 908 unmodified lines | ||
| 909 | 909 | return error; |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | −STATIC ssize_t | |
| 913 | −xfs_file_copy_range( | |
| 914 | − struct file *file_in, | |
| 915 | − loff_t pos_in, | |
| 916 | − struct file *file_out, | |
| 917 | − loff_t pos_out, | |
| 918 | − size_t len, | |
| 919 | − unsigned int flags) | |
| 920 | −{ | |
| 921 | − int error; | |
| 922 | − | |
| 923 | − error = xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, | |
| 924 | − len, false); | |
| 925 | − if (error) | |
| 926 | − return error; | |
| 927 | − return len; | |
| 928 | −} | |
| 929 | − | |
| 930 | 912 | STATIC int |
| 931 | 913 | xfs_file_clone_range( |
| 932 | 914 | struct file *file_in, |
| @@ -1625,7 +1607,6 @@ const struct file_operations xfs_file_operations = { · 692 unmodified lines | ||
| 1625 | 1607 | .fsync = xfs_file_fsync, |
| 1626 | 1608 | .get_unmapped_area = thp_get_unmapped_area, |
| 1627 | 1609 | .fallocate = xfs_file_fallocate, |
| 1628 | − .copy_file_range = xfs_file_copy_range, | |
| 1629 | 1610 | .clone_file_range = xfs_file_clone_range, |
| 1630 | 1611 | .dedupe_file_range = xfs_file_dedupe_range, |
| 1631 | 1612 | }; |
| @@ -1164,111 +1164,6 @@ err: · 1163 unmodified lines | ||
| 1164 | 1164 | return error; |
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | −/* | |
| 1168 | − * Read a page's worth of file data into the page cache. Return the page | |
| 1169 | − * locked. | |
| 1170 | − */ | |
| 1171 | −static struct page * | |
| 1172 | −xfs_get_page( | |
| 1173 | − struct inode *inode, | |
| 1174 | − xfs_off_t offset) | |
| 1175 | −{ | |
| 1176 | − struct address_space *mapping; | |
| 1177 | − struct page *page; | |
| 1178 | − pgoff_t n; | |
| 1179 | − | |
| 1180 | − n = offset >> PAGE_SHIFT; | |
| 1181 | − mapping = inode->i_mapping; | |
| 1182 | − page = read_mapping_page(mapping, n, NULL); | |
| 1183 | − if (IS_ERR(page)) | |
| 1184 | − return page; | |
| 1185 | − if (!PageUptodate(page)) { | |
| 1186 | − put_page(page); | |
| 1187 | − return ERR_PTR(-EIO); | |
| 1188 | − } | |
| 1189 | − lock_page(page); | |
| 1190 | − return page; | |
| 1191 | −} | |
| 1192 | − | |
| 1193 | −/* | |
| 1194 | − * Compare extents of two files to see if they are the same. | |
| 1195 | − */ | |
| 1196 | −static int | |
| 1197 | −xfs_compare_extents( | |
| 1198 | − struct inode *src, | |
| 1199 | − xfs_off_t srcoff, | |
| 1200 | − struct inode *dest, | |
| 1201 | − xfs_off_t destoff, | |
| 1202 | − xfs_off_t len, | |
| 1203 | − bool *is_same) | |
| 1204 | −{ | |
| 1205 | − xfs_off_t src_poff; | |
| 1206 | − xfs_off_t dest_poff; | |
| 1207 | − void *src_addr; | |
| 1208 | − void *dest_addr; | |
| 1209 | − struct page *src_page; | |
| 1210 | − struct page *dest_page; | |
| 1211 | − xfs_off_t cmp_len; | |
| 1212 | − bool same; | |
| 1213 | − int error; | |
| 1214 | − | |
| 1215 | − error = -EINVAL; | |
| 1216 | − same = true; | |
| 1217 | − while (len) { | |
| 1218 | − src_poff = srcoff & (PAGE_SIZE - 1); | |
| 1219 | − dest_poff = destoff & (PAGE_SIZE - 1); | |
| 1220 | − cmp_len = min(PAGE_SIZE - src_poff, | |
| 1221 | − PAGE_SIZE - dest_poff); | |
| 1222 | − cmp_len = min(cmp_len, len); | |
| 1223 | − ASSERT(cmp_len > 0); | |
| 1224 | − | |
| 1225 | − trace_xfs_reflink_compare_extents(XFS_I(src), srcoff, cmp_len, | |
| 1226 | − XFS_I(dest), destoff); | |
| 1227 | − | |
| 1228 | − src_page = xfs_get_page(src, srcoff); | |
| 1229 | − if (IS_ERR(src_page)) { | |
| 1230 | − error = PTR_ERR(src_page); | |
| 1231 | − goto out_error; | |
| 1232 | − } | |
| 1233 | − dest_page = xfs_get_page(dest, destoff); | |
| 1234 | − if (IS_ERR(dest_page)) { | |
| 1235 | − error = PTR_ERR(dest_page); | |
| 1236 | − unlock_page(src_page); | |
| 1237 | − put_page(src_page); | |
| 1238 | − goto out_error; | |
| 1239 | − } | |
| 1240 | − src_addr = kmap_atomic(src_page); | |
| 1241 | − dest_addr = kmap_atomic(dest_page); | |
| 1242 | − | |
| 1243 | − flush_dcache_page(src_page); | |
| 1244 | − flush_dcache_page(dest_page); | |
| 1245 | − | |
| 1246 | − if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len)) | |
| 1247 | − same = false; | |
| 1248 | − | |
| 1249 | − kunmap_atomic(dest_addr); | |
| 1250 | − kunmap_atomic(src_addr); | |
| 1251 | − unlock_page(dest_page); | |
| 1252 | − unlock_page(src_page); | |
| 1253 | − put_page(dest_page); | |
| 1254 | − put_page(src_page); | |
| 1255 | − | |
| 1256 | − if (!same) | |
| 1257 | − break; | |
| 1258 | − | |
| 1259 | − srcoff += cmp_len; | |
| 1260 | − destoff += cmp_len; | |
| 1261 | − len -= cmp_len; | |
| 1262 | − } | |
| 1263 | − | |
| 1264 | − *is_same = same; | |
| 1265 | − return 0; | |
| 1266 | − | |
| 1267 | −out_error: | |
| 1268 | − trace_xfs_reflink_compare_extents_error(XFS_I(dest), error, _RET_IP_); | |
| 1269 | − return error; | |
| 1270 | −} | |
| 1271 | − | |
| 1272 | 1167 | /* |
| 1273 | 1168 | * Link a range of blocks from one file to another. |
| 1274 | 1169 | */ |
| @@ -1286,14 +1181,11 @@ xfs_reflink_remap_range( · 11 unmodified lines | ||
| 1286 | 1181 | struct inode *inode_out = file_inode(file_out); |
| 1287 | 1182 | struct xfs_inode *dest = XFS_I(inode_out); |
| 1288 | 1183 | struct xfs_mount *mp = src->i_mount; |
| 1289 | − loff_t bs = inode_out->i_sb->s_blocksize; | |
| 1290 | 1184 | bool same_inode = (inode_in == inode_out); |
| 1291 | 1185 | xfs_fileoff_t sfsbno, dfsbno; |
| 1292 | 1186 | xfs_filblks_t fsblen; |
| 1293 | 1187 | xfs_extlen_t cowextsize; |
| 1294 | − loff_t isize; | |
| 1295 | 1188 | ssize_t ret; |
| 1296 | − loff_t blen; | |
| 1297 | 1189 | |
| 1298 | 1190 | if (!xfs_sb_version_hasreflink(&mp->m_sb)) |
| 1299 | 1191 | return -EOPNOTSUPP; |
| @@ -1310,26 +1202,8 @@ xfs_reflink_remap_range( · 10 unmodified lines | ||
| 1310 | 1202 | xfs_lock_two_inodes(src, dest, XFS_MMAPLOCK_EXCL); |
| 1311 | 1203 | } |
| 1312 | 1204 | |
| 1313 | − /* Don't touch certain kinds of inodes */ | |
| 1314 | − ret = -EPERM; | |
| 1315 | − if (IS_IMMUTABLE(inode_out)) | |
| 1316 | − goto out_unlock; | |
| 1317 | − | |
| 1318 | − ret = -ETXTBSY; | |
| 1319 | − if (IS_SWAPFILE(inode_in) || IS_SWAPFILE(inode_out)) | |
| 1320 | − goto out_unlock; | |
| 1321 | − | |
| 1322 | − | |
| 1323 | − /* Don't reflink dirs, pipes, sockets... */ | |
| 1324 | − ret = -EISDIR; | |
| 1325 | − if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) | |
| 1326 | − goto out_unlock; | |
| 1205 | + /* Check file eligibility and prepare for block sharing. */ | |
| 1327 | 1206 | ret = -EINVAL; |
| 1328 | − if (S_ISFIFO(inode_in->i_mode) || S_ISFIFO(inode_out->i_mode)) | |
| 1329 | − goto out_unlock; | |
| 1330 | − if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) | |
| 1331 | − goto out_unlock; | |
| 1332 | − | |
| 1333 | 1207 | /* Don't reflink realtime inodes */ |
| 1334 | 1208 | if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest)) |
| 1335 | 1209 | goto out_unlock; |
| @@ -1338,91 +1212,18 @@ xfs_reflink_remap_range( · 2 unmodified lines | ||
| 1338 | 1212 | if (IS_DAX(inode_in) || IS_DAX(inode_out)) |
| 1339 | 1213 | goto out_unlock; |
| 1340 | 1214 | |
| 1341 | − /* Are we going all the way to the end? */ | |
| 1342 | − isize = i_size_read(inode_in); | |
| 1343 | − if (isize == 0) { | |
| 1344 | − ret = 0; | |
| 1345 | − goto out_unlock; | |
| 1346 | − } | |
| 1347 | − | |
| 1348 | − if (len == 0) | |
| 1349 | − len = isize - pos_in; | |
| 1350 | − | |
| 1351 | − /* Ensure offsets don't wrap and the input is inside i_size */ | |
| 1352 | − if (pos_in + len < pos_in || pos_out + len < pos_out || | |
| 1353 | − pos_in + len > isize) | |
| 1354 | − goto out_unlock; | |
| 1355 | − | |
| 1356 | − /* Don't allow dedupe past EOF in the dest file */ | |
| 1357 | − if (is_dedupe) { | |
| 1358 | − loff_t disize; | |
| 1359 | − | |
| 1360 | − disize = i_size_read(inode_out); | |
| 1361 | − if (pos_out >= disize || pos_out + len > disize) | |
| 1362 | − goto out_unlock; | |
| 1363 | − } | |
| 1364 | − | |
| 1365 | − /* If we're linking to EOF, continue to the block boundary. */ | |
| 1366 | − if (pos_in + len == isize) | |
| 1367 | − blen = ALIGN(isize, bs) - pos_in; | |
| 1368 | − else | |
| 1369 | − blen = len; | |
| 1370 | − | |
| 1371 | − /* Only reflink if we're aligned to block boundaries */ | |
| 1372 | − if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_in + blen, bs) || | |
| 1373 | − !IS_ALIGNED(pos_out, bs) || !IS_ALIGNED(pos_out + blen, bs)) | |
| 1374 | − goto out_unlock; | |
| 1375 | − | |
| 1376 | − /* Don't allow overlapped reflink within the same file */ | |
| 1377 | − if (same_inode) { | |
| 1378 | − if (pos_out + blen > pos_in && pos_out < pos_in + blen) | |
| 1379 | − goto out_unlock; | |
| 1380 | − } | |
| 1381 | − | |
| 1382 | − /* Wait for the completion of any pending IOs on both files */ | |
| 1383 | − inode_dio_wait(inode_in); | |
| 1384 | − if (!same_inode) | |
| 1385 | − inode_dio_wait(inode_out); | |
| 1386 | − | |
| 1387 | − ret = filemap_write_and_wait_range(inode_in->i_mapping, | |
| 1388 | − pos_in, pos_in + len - 1); | |
| 1389 | − if (ret) | |
| 1390 | − goto out_unlock; | |
| 1391 | − | |
| 1392 | − ret = filemap_write_and_wait_range(inode_out->i_mapping, | |
| 1393 | − pos_out, pos_out + len - 1); | |
| 1394 | − if (ret) | |
| 1215 | + ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, | |
| 1216 | + &len, is_dedupe); | |
| 1217 | + if (ret || len == 0) | |
| 1395 | 1218 | goto out_unlock; |
| 1396 | 1219 | |
| 1397 | 1220 | trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); |
| 1398 | 1221 | |
| 1399 | − /* | |
| 1400 | − * Check that the extents are the same. | |
| 1401 | − */ | |
| 1402 | − if (is_dedupe) { | |
| 1403 | − bool is_same = false; | |
| 1404 | − | |
| 1405 | − ret = xfs_compare_extents(inode_in, pos_in, inode_out, pos_out, | |
| 1406 | − len, &is_same); | |
| 1407 | − if (ret) | |
| 1408 | − goto out_unlock; | |
| 1409 | − if (!is_same) { | |
| 1410 | − ret = -EBADE; | |
| 1411 | − goto out_unlock; | |
| 1412 | − } | |
| 1413 | − } | |
| 1414 | − | |
| 1222 | + /* Set flags and remap blocks. */ | |
| 1415 | 1223 | ret = xfs_reflink_set_inode_flag(src, dest); |
| 1416 | 1224 | if (ret) |
| 1417 | 1225 | goto out_unlock; |
| 1418 | 1226 | |
| 1419 | − /* | |
| 1420 | − * Invalidate the page cache so that we can clear any CoW mappings | |
| 1421 | − * in the destination file. | |
| 1422 | − */ | |
| 1423 | − truncate_inode_pages_range(&inode_out->i_data, pos_out, | |
| 1424 | − PAGE_ALIGN(pos_out + len) - 1); | |
| 1425 | − | |
| 1426 | 1227 | dfsbno = XFS_B_TO_FSBT(mp, pos_out); |
| 1427 | 1228 | sfsbno = XFS_B_TO_FSBT(mp, pos_in); |
| 1428 | 1229 | fsblen = XFS_B_TO_FSB(mp, len); |
| @@ -1431,6 +1232,10 @@ xfs_reflink_remap_range( · 2 unmodified lines | ||
| 1431 | 1232 | if (ret) |
| 1432 | 1233 | goto out_unlock; |
| 1433 | 1234 | |
| 1235 | + /* Zap any page cache for the destination file's range. */ | |
| 1236 | + truncate_inode_pages_range(&inode_out->i_data, pos_out, | |
| 1237 | + PAGE_ALIGN(pos_out + len) - 1); | |
| 1238 | + | |
| 1434 | 1239 | /* |
| 1435 | 1240 | * Carry the cowextsize hint from src to dest if we're sharing the |
| 1436 | 1241 | * entire source file to the entire destination file, the source file |
| @@ -54,6 +54,7 @@ KSYM(__kstrtab_\name): · 53 unmodified lines | ||
| 54 | 54 | KSYM(__kcrctab_\name): |
| 55 | 55 | __put KSYM(__crc_\name) |
| 56 | 56 | .weak KSYM(__crc_\name) |
| 57 | + .set KSYM(__crc_\name), 0 | |
| 57 | 58 | .previous |
| 58 | 59 | #endif |
| 59 | 60 | #endif |
| @@ -263,7 +263,9 @@ · 262 unmodified lines | ||
| 263 | 263 | #endif |
| 264 | 264 | #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP && !__CHECKER__ */ |
| 265 | 265 | |
| 266 | −#if GCC_VERSION >= 50000 | |
| 266 | +#if GCC_VERSION >= 70000 | |
| 267 | +#define KASAN_ABI_VERSION 5 | |
| 268 | +#elif GCC_VERSION >= 50000 | |
| 267 | 269 | #define KASAN_ABI_VERSION 4 |
| 268 | 270 | #elif GCC_VERSION >= 40902 |
| 269 | 271 | #define KASAN_ABI_VERSION 3 |
| @@ -1778,8 +1778,14 @@ extern ssize_t vfs_writev(struct file *, const struct iovec __user *, · 1777 unmodified lines | ||
| 1778 | 1778 | unsigned long, loff_t *, int); |
| 1779 | 1779 | extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, |
| 1780 | 1780 | loff_t, size_t, unsigned int); |
| 1781 | +extern int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, | |
| 1782 | + struct inode *inode_out, loff_t pos_out, | |
| 1783 | + u64 *len, bool is_dedupe); | |
| 1781 | 1784 | extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in, |
| 1782 | 1785 | struct file *file_out, loff_t pos_out, u64 len); |
| 1786 | +extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, | |
| 1787 | + struct inode *dest, loff_t destoff, | |
| 1788 | + loff_t len, bool *is_same); | |
| 1783 | 1789 | extern int vfs_dedupe_file_range(struct file *file, |
| 1784 | 1790 | struct file_dedupe_range *same); |
| 1785 | 1791 | |
| @@ -476,7 +476,6 @@ enum { · 475 unmodified lines | ||
| 476 | 476 | enum { |
| 477 | 477 | MLX4_INTERFACE_STATE_UP = 1 << 0, |
| 478 | 478 | MLX4_INTERFACE_STATE_DELETION = 1 << 1, |
| 479 | − MLX4_INTERFACE_STATE_SHUTDOWN = 1 << 2, | |
| 480 | 479 | }; |
| 481 | 480 | |
| 482 | 481 | #define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \ |
| @@ -29,6 +29,7 @@ struct phy_device *of_phy_attach(struct net_device *dev, · 28 unmodified lines | ||
| 29 | 29 | extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np); |
| 30 | 30 | extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np); |
| 31 | 31 | extern int of_phy_register_fixed_link(struct device_node *np); |
| 32 | +extern void of_phy_deregister_fixed_link(struct device_node *np); | |
| 32 | 33 | extern bool of_phy_is_fixed_link(struct device_node *np); |
| 33 | 34 | |
| 34 | 35 | #else /* CONFIG_OF */ |
| @@ -83,6 +84,9 @@ static inline int of_phy_register_fixed_link(struct device_node *np) · 48 unmodified lines | ||
| 83 | 84 | { |
| 84 | 85 | return -ENOSYS; |
| 85 | 86 | } |
| 87 | +static inline void of_phy_deregister_fixed_link(struct device_node *np) | |
| 88 | +{ | |
| 89 | +} | |
| 86 | 90 | static inline bool of_phy_is_fixed_link(struct device_node *np) |
| 87 | 91 | { |
| 88 | 92 | return false; |
| @@ -374,16 +374,13 @@ static inline struct page *read_mapping_page(struct address_space *mapping, · 373 unmodified lines | ||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /* |
| 377 | − * Get the offset in PAGE_SIZE. | |
| 378 | − * (TODO: hugepage should have ->index in PAGE_SIZE) | |
| 377 | + * Get index of the page with in radix-tree | |
| 378 | + * (TODO: remove once hugetlb pages will have ->index in PAGE_SIZE) | |
| 379 | 379 | */ |
| 380 | −static inline pgoff_t page_to_pgoff(struct page *page) | |
| 380 | +static inline pgoff_t page_to_index(struct page *page) | |
| 381 | 381 | { |
| 382 | 382 | pgoff_t pgoff; |
| 383 | 383 | |
| 384 | − if (unlikely(PageHeadHuge(page))) | |
| 385 | − return page->index << compound_order(page); | |
| 386 | − | |
| 387 | 384 | if (likely(!PageTransTail(page))) |
| 388 | 385 | return page->index; |
| 389 | 386 | |
| @@ -396,6 +393,18 @@ static inline pgoff_t page_to_pgoff(struct page *page) · 6 unmodified lines | ||
| 396 | 393 | return pgoff; |
| 397 | 394 | } |
| 398 | 395 | |
| 396 | +/* | |
| 397 | + * Get the offset in PAGE_SIZE. | |
| 398 | + * (TODO: hugepage should have ->index in PAGE_SIZE) | |
| 399 | + */ | |
| 400 | +static inline pgoff_t page_to_pgoff(struct page *page) | |
| 401 | +{ | |
| 402 | + if (unlikely(PageHeadHuge(page))) | |
| 403 | + return page->index << compound_order(page); | |
| 404 | + | |
| 405 | + return page_to_index(page); | |
| 406 | +} | |
| 407 | + | |
| 399 | 408 | /* |
| 400 | 409 | * Return byte-offset into filesystem object for page. |
| 401 | 410 | */ |
| @@ -1928,6 +1928,20 @@ static inline int pci_pcie_type(const struct pci_dev *dev) · 1927 unmodified lines | ||
| 1928 | 1928 | return (pcie_caps_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4; |
| 1929 | 1929 | } |
| 1930 | 1930 | |
| 1931 | +static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev) | |
| 1932 | +{ | |
| 1933 | + while (1) { | |
| 1934 | + if (!pci_is_pcie(dev)) | |
| 1935 | + break; | |
| 1936 | + if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) | |
| 1937 | + return dev; | |
| 1938 | + if (!dev->bus->self) | |
| 1939 | + break; | |
| 1940 | + dev = dev->bus->self; | |
| 1941 | + } | |
| 1942 | + return NULL; | |
| 1943 | +} | |
| 1944 | + | |
| 1931 | 1945 | void pci_request_acs(void); |
| 1932 | 1946 | bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags); |
| 1933 | 1947 | bool pci_acs_path_enabled(struct pci_dev *start, |
| @@ -970,6 +970,8 @@ int compat_ipv6_setsockopt(struct sock *sk, int level, int optname, · 969 unmodified lines | ||
| 970 | 970 | int compat_ipv6_getsockopt(struct sock *sk, int level, int optname, |
| 971 | 971 | char __user *optval, int __user *optlen); |
| 972 | 972 | |
| 973 | +int __ip6_datagram_connect(struct sock *sk, struct sockaddr *addr, | |
| 974 | + int addr_len); | |
| 973 | 975 | int ip6_datagram_connect(struct sock *sk, struct sockaddr *addr, int addr_len); |
| 974 | 976 | int ip6_datagram_connect_v6_only(struct sock *sk, struct sockaddr *addr, |
| 975 | 977 | int addr_len); |
| @@ -100,6 +100,9 @@ struct nf_conn { · 99 unmodified lines | ||
| 100 | 100 | |
| 101 | 101 | possible_net_t ct_net; |
| 102 | 102 | |
| 103 | +#if IS_ENABLED(CONFIG_NF_NAT) | |
| 104 | + struct rhlist_head nat_bysource; | |
| 105 | +#endif | |
| 103 | 106 | /* all members below initialized via memset */ |
| 104 | 107 | u8 __nfct_init_offset[0]; |
| 105 | 108 | |
| @@ -117,9 +120,6 @@ struct nf_conn { · 11 unmodified lines | ||
| 117 | 120 | /* Extensions */ |
| 118 | 121 | struct nf_ct_ext *ext; |
| 119 | 122 | |
| 120 | −#if IS_ENABLED(CONFIG_NF_NAT) | |
| 121 | − struct rhash_head nat_bysource; | |
| 122 | −#endif | |
| 123 | 123 | /* Storage reserved for other modules, must be the last member */ |
| 124 | 124 | union nf_conntrack_proto proto; |
| 125 | 125 | }; |
| @@ -313,7 +313,7 @@ void nft_unregister_set(struct nft_set_ops *ops); · 312 unmodified lines | ||
| 313 | 313 | * @size: maximum set size |
| 314 | 314 | * @nelems: number of elements |
| 315 | 315 | * @ndeact: number of deactivated elements queued for removal |
| 316 | − * @timeout: default timeout value in msecs | |
| 316 | + * @timeout: default timeout value in jiffies | |
| 317 | 317 | * @gc_int: garbage collection interval in msecs |
| 318 | 318 | * @policy: set parameterization (see enum nft_set_policies) |
| 319 | 319 | * @udlen: user data length |
| @@ -640,7 +640,7 @@ · 639 unmodified lines | ||
| 640 | 640 | * Control a data application associated with the currently viewed channel, |
| 641 | 641 | * e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.) |
| 642 | 642 | */ |
| 643 | −#define KEY_DATA 0x275 | |
| 643 | +#define KEY_DATA 0x277 | |
| 644 | 644 | |
| 645 | 645 | #define BTN_TRIGGER_HAPPY 0x2c0 |
| 646 | 646 | #define BTN_TRIGGER_HAPPY1 0x2c0 |
| @@ -11,3 +11,4 @@ header-y += tc_vlan.h · 10 unmodified lines | ||
| 11 | 11 | header-y += tc_bpf.h |
| 12 | 12 | header-y += tc_connmark.h |
| 13 | 13 | header-y += tc_ife.h |
| 14 | +header-y += tc_tunnel_key.h | |
| @@ -1945,7 +1945,6 @@ config MODULE_FORCE_UNLOAD · 1944 unmodified lines | ||
| 1945 | 1945 | |
| 1946 | 1946 | config MODVERSIONS |
| 1947 | 1947 | bool "Module versioning support" |
| 1948 | − depends on BROKEN | |
| 1949 | 1948 | help |
| 1950 | 1949 | Usually, you have to use modules compiled with your kernel. |
| 1951 | 1950 | Saying Y here makes it sometimes possible to use modules |
| @@ -2454,6 +2454,7 @@ static bool states_equal(struct bpf_verifier_env *env, · 2453 unmodified lines | ||
| 2454 | 2454 | struct bpf_verifier_state *old, |
| 2455 | 2455 | struct bpf_verifier_state *cur) |
| 2456 | 2456 | { |
| 2457 | + bool varlen_map_access = env->varlen_map_value_access; | |
| 2457 | 2458 | struct bpf_reg_state *rold, *rcur; |
| 2458 | 2459 | int i; |
| 2459 | 2460 | |
| @@ -2467,12 +2468,17 @@ static bool states_equal(struct bpf_verifier_env *env, · 7 unmodified lines | ||
| 2467 | 2468 | /* If the ranges were not the same, but everything else was and |
| 2468 | 2469 | * we didn't do a variable access into a map then we are a-ok. |
| 2469 | 2470 | */ |
| 2470 | − if (!env->varlen_map_value_access && | |
| 2471 | + if (!varlen_map_access && | |
| 2471 | 2472 | rold->type == rcur->type && rold->imm == rcur->imm) |
| 2472 | 2473 | continue; |
| 2473 | 2474 | |
| 2475 | + /* If we didn't map access then again we don't care about the | |
| 2476 | + * mismatched range values and it's ok if our old type was | |
| 2477 | + * UNKNOWN and we didn't go to a NOT_INIT'ed reg. | |
| 2478 | + */ | |
| 2474 | 2479 | if (rold->type == NOT_INIT || |
| 2475 | − (rold->type == UNKNOWN_VALUE && rcur->type != NOT_INIT)) | |
| 2480 | + (!varlen_map_access && rold->type == UNKNOWN_VALUE && | |
| 2481 | + rcur->type != NOT_INIT)) | |
| 2476 | 2482 | continue; |
| 2477 | 2483 | |
| 2478 | 2484 | if (rold->type == PTR_TO_PACKET && rcur->type == PTR_TO_PACKET && |
| @@ -1301,8 +1301,9 @@ static int check_version(Elf_Shdr *sechdrs, · 1300 unmodified lines | ||
| 1301 | 1301 | goto bad_version; |
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | − pr_warn("%s: no symbol version for %s\n", mod->name, symname); | |
| 1305 | − return 0; | |
| 1304 | + /* Broken toolchain. Warn once, then let it go.. */ | |
| 1305 | + pr_warn_once("%s: no symbol version for %s\n", mod->name, symname); | |
| 1306 | + return 1; | |
| 1306 | 1307 | |
| 1307 | 1308 | bad_version: |
| 1308 | 1309 | pr_warn("%s: disagrees about version of symbol %s\n", |
| @@ -362,6 +362,7 @@ void debug_object_init(void *addr, struct debug_obj_descr *descr) · 361 unmodified lines | ||
| 362 | 362 | |
| 363 | 363 | __debug_object_init(addr, descr, 0); |
| 364 | 364 | } |
| 365 | +EXPORT_SYMBOL_GPL(debug_object_init); | |
| 365 | 366 | |
| 366 | 367 | /** |
| 367 | 368 | * debug_object_init_on_stack - debug checks when an object on stack is |
| @@ -376,6 +377,7 @@ void debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr) · 8 unmodified lines | ||
| 376 | 377 | |
| 377 | 378 | __debug_object_init(addr, descr, 1); |
| 378 | 379 | } |
| 380 | +EXPORT_SYMBOL_GPL(debug_object_init_on_stack); | |
| 379 | 381 | |
| 380 | 382 | /** |
| 381 | 383 | * debug_object_activate - debug checks when an object is activated |
| @@ -449,6 +451,7 @@ int debug_object_activate(void *addr, struct debug_obj_descr *descr) · 67 unmodified lines | ||
| 449 | 451 | } |
| 450 | 452 | return 0; |
| 451 | 453 | } |
| 454 | +EXPORT_SYMBOL_GPL(debug_object_activate); | |
| 452 | 455 | |
| 453 | 456 | /** |
| 454 | 457 | * debug_object_deactivate - debug checks when an object is deactivated |
| @@ -496,6 +499,7 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr) · 41 unmodified lines | ||
| 496 | 499 | |
| 497 | 500 | raw_spin_unlock_irqrestore(&db->lock, flags); |
| 498 | 501 | } |
| 502 | +EXPORT_SYMBOL_GPL(debug_object_deactivate); | |
| 499 | 503 | |
| 500 | 504 | /** |
| 501 | 505 | * debug_object_destroy - debug checks when an object is destroyed |
| @@ -542,6 +546,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr) · 40 unmodified lines | ||
| 542 | 546 | out_unlock: |
| 543 | 547 | raw_spin_unlock_irqrestore(&db->lock, flags); |
| 544 | 548 | } |
| 549 | +EXPORT_SYMBOL_GPL(debug_object_destroy); | |
| 545 | 550 | |
| 546 | 551 | /** |
| 547 | 552 | * debug_object_free - debug checks when an object is freed |
| @@ -582,6 +587,7 @@ void debug_object_free(void *addr, struct debug_obj_descr *descr) · 34 unmodified lines | ||
| 582 | 587 | out_unlock: |
| 583 | 588 | raw_spin_unlock_irqrestore(&db->lock, flags); |
| 584 | 589 | } |
| 590 | +EXPORT_SYMBOL_GPL(debug_object_free); | |
| 585 | 591 | |
| 586 | 592 | /** |
| 587 | 593 | * debug_object_assert_init - debug checks when object should be init-ed |
| @@ -626,6 +632,7 @@ void debug_object_assert_init(void *addr, struct debug_obj_descr *descr) · 38 unmodified lines | ||
| 626 | 632 | |
| 627 | 633 | raw_spin_unlock_irqrestore(&db->lock, flags); |
| 628 | 634 | } |
| 635 | +EXPORT_SYMBOL_GPL(debug_object_assert_init); | |
| 629 | 636 | |
| 630 | 637 | /** |
| 631 | 638 | * debug_object_active_state - debug checks object usage state machine |
| @@ -673,6 +680,7 @@ debug_object_active_state(void *addr, struct debug_obj_descr *descr, · 41 unmodified lines | ||
| 673 | 680 | |
| 674 | 681 | raw_spin_unlock_irqrestore(&db->lock, flags); |
| 675 | 682 | } |
| 683 | +EXPORT_SYMBOL_GPL(debug_object_active_state); | |
| 676 | 684 | |
| 677 | 685 | #ifdef CONFIG_DEBUG_OBJECTS_FREE |
| 678 | 686 | static void __debug_check_no_obj_freed(const void *address, unsigned long size) |
| @@ -20,6 +20,11 @@ · 19 unmodified lines | ||
| 20 | 20 | #include <linux/uaccess.h> |
| 21 | 21 | #include <linux/module.h> |
| 22 | 22 | |
| 23 | +/* | |
| 24 | + * Note: test functions are marked noinline so that their names appear in | |
| 25 | + * reports. | |
| 26 | + */ | |
| 27 | + | |
| 23 | 28 | static noinline void __init kmalloc_oob_right(void) |
| 24 | 29 | { |
| 25 | 30 | char *ptr; |
| @@ -411,6 +416,29 @@ static noinline void __init copy_user_test(void) · 385 unmodified lines | ||
| 411 | 416 | kfree(kmem); |
| 412 | 417 | } |
| 413 | 418 | |
| 419 | +static noinline void __init use_after_scope_test(void) | |
| 420 | +{ | |
| 421 | + volatile char *volatile p; | |
| 422 | + | |
| 423 | + pr_info("use-after-scope on int\n"); | |
| 424 | + { | |
| 425 | + int local = 0; | |
| 426 | + | |
| 427 | + p = (char *)&local; | |
| 428 | + } | |
| 429 | + p[0] = 1; | |
| 430 | + p[3] = 1; | |
| 431 | + | |
| 432 | + pr_info("use-after-scope on array\n"); | |
| 433 | + { | |
| 434 | + char local[1024] = {0}; | |
| 435 | + | |
| 436 | + p = local; | |
| 437 | + } | |
| 438 | + p[0] = 1; | |
| 439 | + p[1023] = 1; | |
| 440 | +} | |
| 441 | + | |
| 414 | 442 | static int __init kmalloc_tests_init(void) |
| 415 | 443 | { |
| 416 | 444 | kmalloc_oob_right(); |
| @@ -436,6 +464,7 @@ static int __init kmalloc_tests_init(void) · 19 unmodified lines | ||
| 436 | 464 | kasan_global_oob(); |
| 437 | 465 | ksize_unpoisons_memory(); |
| 438 | 466 | copy_user_test(); |
| 467 | + use_after_scope_test(); | |
| 439 | 468 | return -EAGAIN; |
| 440 | 469 | } |
| 441 | 470 | |
| @@ -1456,9 +1456,9 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr, · 1455 unmodified lines | ||
| 1456 | 1456 | new_ptl = pmd_lockptr(mm, new_pmd); |
| 1457 | 1457 | if (new_ptl != old_ptl) |
| 1458 | 1458 | spin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING); |
| 1459 | − if (pmd_present(*old_pmd) && pmd_dirty(*old_pmd)) | |
| 1460 | − force_flush = true; | |
| 1461 | 1459 | pmd = pmdp_huge_get_and_clear(mm, old_addr, old_pmd); |
| 1460 | + if (pmd_present(pmd) && pmd_dirty(pmd)) | |
| 1461 | + force_flush = true; | |
| 1462 | 1462 | VM_BUG_ON(!pmd_none(*new_pmd)); |
| 1463 | 1463 | |
| 1464 | 1464 | if (pmd_move_must_withdraw(new_ptl, old_ptl) && |
| @@ -764,6 +764,25 @@ EXPORT_SYMBOL(__asan_storeN_noabort); · 763 unmodified lines | ||
| 764 | 764 | void __asan_handle_no_return(void) {} |
| 765 | 765 | EXPORT_SYMBOL(__asan_handle_no_return); |
| 766 | 766 | |
| 767 | +/* Emitted by compiler to poison large objects when they go out of scope. */ | |
| 768 | +void __asan_poison_stack_memory(const void *addr, size_t size) | |
| 769 | +{ | |
| 770 | + /* | |
| 771 | + * Addr is KASAN_SHADOW_SCALE_SIZE-aligned and the object is surrounded | |
| 772 | + * by redzones, so we simply round up size to simplify logic. | |
| 773 | + */ | |
| 774 | + kasan_poison_shadow(addr, round_up(size, KASAN_SHADOW_SCALE_SIZE), | |
| 775 | + KASAN_USE_AFTER_SCOPE); | |
| 776 | +} | |
| 777 | +EXPORT_SYMBOL(__asan_poison_stack_memory); | |
| 778 | + | |
| 779 | +/* Emitted by compiler to unpoison large objects when they go into scope. */ | |
| 780 | +void __asan_unpoison_stack_memory(const void *addr, size_t size) | |
| 781 | +{ | |
| 782 | + kasan_unpoison_shadow(addr, size); | |
| 783 | +} | |
| 784 | +EXPORT_SYMBOL(__asan_unpoison_stack_memory); | |
| 785 | + | |
| 767 | 786 | #ifdef CONFIG_MEMORY_HOTPLUG |
| 768 | 787 | static int kasan_mem_notifier(struct notifier_block *nb, |
| 769 | 788 | unsigned long action, void *data) |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #define KASAN_STACK_MID 0xF2 |
| 22 | 22 | #define KASAN_STACK_RIGHT 0xF3 |
| 23 | 23 | #define KASAN_STACK_PARTIAL 0xF4 |
| 24 | +#define KASAN_USE_AFTER_SCOPE 0xF8 | |
| 24 | 25 | |
| 25 | 26 | /* Don't break randconfig/all*config builds */ |
| 26 | 27 | #ifndef KASAN_ABI_VERSION |
| @@ -53,6 +54,9 @@ struct kasan_global { · 26 unmodified lines | ||
| 53 | 54 | #if KASAN_ABI_VERSION >= 4 |
| 54 | 55 | struct kasan_source_location *location; |
| 55 | 56 | #endif |
| 57 | +#if KASAN_ABI_VERSION >= 5 | |
| 58 | + char *odr_indicator; | |
| 59 | +#endif | |
| 56 | 60 | }; |
| 57 | 61 | |
| 58 | 62 | /** |
| @@ -90,6 +90,9 @@ static void print_error_description(struct kasan_access_info *info) · 89 unmodified lines | ||
| 90 | 90 | case KASAN_KMALLOC_FREE: |
| 91 | 91 | bug_type = "use-after-free"; |
| 92 | 92 | break; |
| 93 | + case KASAN_USE_AFTER_SCOPE: | |
| 94 | + bug_type = "use-after-scope"; | |
| 95 | + break; | |
| 93 | 96 | } |
| 94 | 97 | |
| 95 | 98 | pr_err("BUG: KASAN: %s in %pS at addr %p\n", |
| @@ -103,6 +103,7 @@ static struct khugepaged_scan khugepaged_scan = { · 102 unmodified lines | ||
| 103 | 103 | .mm_head = LIST_HEAD_INIT(khugepaged_scan.mm_head), |
| 104 | 104 | }; |
| 105 | 105 | |
| 106 | +#ifdef CONFIG_SYSFS | |
| 106 | 107 | static ssize_t scan_sleep_millisecs_show(struct kobject *kobj, |
| 107 | 108 | struct kobj_attribute *attr, |
| 108 | 109 | char *buf) |
| @@ -295,6 +296,7 @@ struct attribute_group khugepaged_attr_group = { · 186 unmodified lines | ||
| 295 | 296 | .attrs = khugepaged_attr, |
| 296 | 297 | .name = "khugepaged", |
| 297 | 298 | }; |
| 299 | +#endif /* CONFIG_SYSFS */ | |
| 298 | 300 | |
| 299 | 301 | #define VM_NO_KHUGEPAGED (VM_SPECIAL | VM_HUGETLB) |
| 300 | 302 | |
| @@ -190,10 +190,13 @@ unsigned int munlock_vma_page(struct page *page) · 189 unmodified lines | ||
| 190 | 190 | */ |
| 191 | 191 | spin_lock_irq(zone_lru_lock(zone)); |
| 192 | 192 | |
| 193 | − nr_pages = hpage_nr_pages(page); | |
| 194 | − if (!TestClearPageMlocked(page)) | |
| 193 | + if (!TestClearPageMlocked(page)) { | |
| 194 | + /* Potentially, PTE-mapped THP: do not skip the rest PTEs */ | |
| 195 | + nr_pages = 1; | |
| 195 | 196 | goto unlock_out; |
| 197 | + } | |
| 196 | 198 | |
| 199 | + nr_pages = hpage_nr_pages(page); | |
| 197 | 200 | __mod_zone_page_state(zone, NR_MLOCK, -nr_pages); |
| 198 | 201 | |
| 199 | 202 | if (__munlock_isolate_lru_page(page, true)) { |
| @@ -149,14 +149,18 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd, · 148 unmodified lines | ||
| 149 | 149 | if (pte_none(*old_pte)) |
| 150 | 150 | continue; |
| 151 | 151 | |
| 152 | + pte = ptep_get_and_clear(mm, old_addr, old_pte); | |
| 152 | 153 | /* |
| 153 | − * We are remapping a dirty PTE, make sure to | |
| 154 | − * flush TLB before we drop the PTL for the | |
| 154 | + * If we are remapping a dirty PTE, make sure | |
| 155 | + * to flush TLB before we drop the PTL for the | |
| 155 | 156 | * old PTE or we may race with page_mkclean(). |
| 157 | + * | |
| 158 | + * This check has to be done after we removed the | |
| 159 | + * old PTE from page tables or another thread may | |
| 160 | + * dirty it after the check and before the removal. | |
| 156 | 161 | */ |
| 157 | − if (pte_present(*old_pte) && pte_dirty(*old_pte)) | |
| 162 | + if (pte_present(pte) && pte_dirty(pte)) | |
| 158 | 163 | force_flush = true; |
| 159 | − pte = ptep_get_and_clear(mm, old_addr, old_pte); | |
| 160 | 164 | pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr); |
| 161 | 165 | pte = move_soft_dirty_pte(pte); |
| 162 | 166 | set_pte_at(mm, new_addr, new_pte, pte); |
| @@ -283,7 +283,7 @@ void truncate_inode_pages_range(struct address_space *mapping, · 282 unmodified lines | ||
| 283 | 283 | |
| 284 | 284 | if (!trylock_page(page)) |
| 285 | 285 | continue; |
| 286 | − WARN_ON(page_to_pgoff(page) != index); | |
| 286 | + WARN_ON(page_to_index(page) != index); | |
| 287 | 287 | if (PageWriteback(page)) { |
| 288 | 288 | unlock_page(page); |
| 289 | 289 | continue; |
| @@ -371,7 +371,7 @@ void truncate_inode_pages_range(struct address_space *mapping, · 81 unmodified lines | ||
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | lock_page(page); |
| 374 | − WARN_ON(page_to_pgoff(page) != index); | |
| 374 | + WARN_ON(page_to_index(page) != index); | |
| 375 | 375 | wait_on_page_writeback(page); |
| 376 | 376 | truncate_inode_page(mapping, page); |
| 377 | 377 | unlock_page(page); |
| @@ -492,7 +492,7 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping, · 114 unmodified lines | ||
| 492 | 492 | if (!trylock_page(page)) |
| 493 | 493 | continue; |
| 494 | 494 | |
| 495 | − WARN_ON(page_to_pgoff(page) != index); | |
| 495 | + WARN_ON(page_to_index(page) != index); | |
| 496 | 496 | |
| 497 | 497 | /* Middle of THP: skip */ |
| 498 | 498 | if (PageTransTail(page)) { |
| @@ -612,7 +612,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping, · 113 unmodified lines | ||
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | lock_page(page); |
| 615 | − WARN_ON(page_to_pgoff(page) != index); | |
| 615 | + WARN_ON(page_to_index(page) != index); | |
| 616 | 616 | if (page->mapping != mapping) { |
| 617 | 617 | unlock_page(page); |
| 618 | 618 | continue; |
| @@ -2354,6 +2354,8 @@ static void shrink_node_memcg(struct pglist_data *pgdat, struct mem_cgroup *memc · 2353 unmodified lines | ||
| 2354 | 2354 | } |
| 2355 | 2355 | } |
| 2356 | 2356 | |
| 2357 | + cond_resched(); | |
| 2358 | + | |
| 2357 | 2359 | if (nr_reclaimed < nr_to_reclaim || scan_adjusted) |
| 2358 | 2360 | continue; |
| 2359 | 2361 | |
| @@ -348,7 +348,7 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, · 347 unmodified lines | ||
| 348 | 348 | shadow_nodes = list_lru_shrink_count(&workingset_shadow_nodes, sc); |
| 349 | 349 | local_irq_enable(); |
| 350 | 350 | |
| 351 | − if (memcg_kmem_enabled()) { | |
| 351 | + if (sc->memcg) { | |
| 352 | 352 | pages = mem_cgroup_node_nr_lru_pages(sc->memcg, sc->nid, |
| 353 | 353 | LRU_ALL_FILE); |
| 354 | 354 | } else { |
| @@ -95,7 +95,6 @@ static void flow_cache_gc_task(struct work_struct *work) · 94 unmodified lines | ||
| 95 | 95 | list_for_each_entry_safe(fce, n, &gc_list, u.gc_list) { |
| 96 | 96 | flow_entry_kill(fce, xfrm); |
| 97 | 97 | atomic_dec(&xfrm->flow_cache_gc_count); |
| 98 | − WARN_ON(atomic_read(&xfrm->flow_cache_gc_count) < 0); | |
| 99 | 98 | } |
| 100 | 99 | } |
| 101 | 100 | |
| @@ -236,9 +235,8 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir, · 134 unmodified lines | ||
| 236 | 235 | if (fcp->hash_count > fc->high_watermark) |
| 237 | 236 | flow_cache_shrink(fc, fcp); |
| 238 | 237 | |
| 239 | − if (fcp->hash_count > 2 * fc->high_watermark || | |
| 240 | − atomic_read(&net->xfrm.flow_cache_gc_count) > fc->high_watermark) { | |
| 241 | − atomic_inc(&net->xfrm.flow_cache_genid); | |
| 238 | + if (atomic_read(&net->xfrm.flow_cache_gc_count) > | |
| 239 | + 2 * num_online_cpus() * fc->high_watermark) { | |
| 242 | 240 | flo = ERR_PTR(-ENOBUFS); |
| 243 | 241 | goto ret_object; |
| 244 | 242 | } |
| @@ -931,8 +931,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, · 930 unmodified lines | ||
| 931 | 931 | + nla_total_size(4) /* IFLA_PROMISCUITY */ |
| 932 | 932 | + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */ |
| 933 | 933 | + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */ |
| 934 | − + nla_total_size(4) /* IFLA_MAX_GSO_SEGS */ | |
| 935 | − + nla_total_size(4) /* IFLA_MAX_GSO_SIZE */ | |
| 934 | + + nla_total_size(4) /* IFLA_GSO_MAX_SEGS */ | |
| 935 | + + nla_total_size(4) /* IFLA_GSO_MAX_SIZE */ | |
| 936 | 936 | + nla_total_size(1) /* IFLA_OPERSTATE */ |
| 937 | 937 | + nla_total_size(1) /* IFLA_LINKMODE */ |
| 938 | 938 | + nla_total_size(4) /* IFLA_CARRIER_CHANGES */ |
| @@ -715,7 +715,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, · 714 unmodified lines | ||
| 715 | 715 | val = min_t(u32, val, sysctl_wmem_max); |
| 716 | 716 | set_sndbuf: |
| 717 | 717 | sk->sk_userlocks |= SOCK_SNDBUF_LOCK; |
| 718 | − sk->sk_sndbuf = max_t(u32, val * 2, SOCK_MIN_SNDBUF); | |
| 718 | + sk->sk_sndbuf = max_t(int, val * 2, SOCK_MIN_SNDBUF); | |
| 719 | 719 | /* Wake up sending tasks if we upped the value. */ |
| 720 | 720 | sk->sk_write_space(sk); |
| 721 | 721 | break; |
| @@ -751,7 +751,7 @@ set_rcvbuf: · 29 unmodified lines | ||
| 751 | 751 | * returning the value we actually used in getsockopt |
| 752 | 752 | * is the most desirable behavior. |
| 753 | 753 | */ |
| 754 | − sk->sk_rcvbuf = max_t(u32, val * 2, SOCK_MIN_RCVBUF); | |
| 754 | + sk->sk_rcvbuf = max_t(int, val * 2, SOCK_MIN_RCVBUF); | |
| 755 | 755 | break; |
| 756 | 756 | |
| 757 | 757 | case SO_RCVBUFFORCE: |
| @@ -700,6 +700,7 @@ int dccp_invalid_packet(struct sk_buff *skb) · 699 unmodified lines | ||
| 700 | 700 | { |
| 701 | 701 | const struct dccp_hdr *dh; |
| 702 | 702 | unsigned int cscov; |
| 703 | + u8 dccph_doff; | |
| 703 | 704 | |
| 704 | 705 | if (skb->pkt_type != PACKET_HOST) |
| 705 | 706 | return 1; |
| @@ -721,18 +722,19 @@ int dccp_invalid_packet(struct sk_buff *skb) · 15 unmodified lines | ||
| 721 | 722 | /* |
| 722 | 723 | * If P.Data Offset is too small for packet type, drop packet and return |
| 723 | 724 | */ |
| 724 | − if (dh->dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) { | |
| 725 | − DCCP_WARN("P.Data Offset(%u) too small\n", dh->dccph_doff); | |
| 725 | + dccph_doff = dh->dccph_doff; | |
| 726 | + if (dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) { | |
| 727 | + DCCP_WARN("P.Data Offset(%u) too small\n", dccph_doff); | |
| 726 | 728 | return 1; |
| 727 | 729 | } |
| 728 | 730 | /* |
| 729 | 731 | * If P.Data Offset is too too large for packet, drop packet and return |
| 730 | 732 | */ |
| 731 | − if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) { | |
| 732 | − DCCP_WARN("P.Data Offset(%u) too large\n", dh->dccph_doff); | |
| 733 | + if (!pskb_may_pull(skb, dccph_doff * sizeof(u32))) { | |
| 734 | + DCCP_WARN("P.Data Offset(%u) too large\n", dccph_doff); | |
| 733 | 735 | return 1; |
| 734 | 736 | } |
| 735 | − | |
| 737 | + dh = dccp_hdr(skb); | |
| 736 | 738 | /* |
| 737 | 739 | * If P.type is not Data, Ack, or DataAck and P.X == 0 (the packet |
| 738 | 740 | * has short sequence numbers), drop packet and return |
| @@ -233,6 +233,8 @@ int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev, · 232 unmodified lines | ||
| 233 | 233 | genphy_read_status(phydev); |
| 234 | 234 | if (ds->ops->adjust_link) |
| 235 | 235 | ds->ops->adjust_link(ds, port, phydev); |
| 236 | + | |
| 237 | + put_device(&phydev->mdio.dev); | |
| 236 | 238 | } |
| 237 | 239 | |
| 238 | 240 | return 0; |
| @@ -504,15 +506,8 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, · 265 unmodified lines | ||
| 504 | 506 | |
| 505 | 507 | void dsa_cpu_dsa_destroy(struct device_node *port_dn) |
| 506 | 508 | { |
| 507 | − struct phy_device *phydev; | |
| 508 | − | |
| 509 | − if (of_phy_is_fixed_link(port_dn)) { | |
| 510 | − phydev = of_phy_find_device(port_dn); | |
| 511 | − if (phydev) { | |
| 512 | − phy_device_free(phydev); | |
| 513 | − fixed_phy_unregister(phydev); | |
| 514 | − } | |
| 515 | − } | |
| 509 | + if (of_phy_is_fixed_link(port_dn)) | |
| 510 | + of_phy_deregister_fixed_link(port_dn); | |
| 516 | 511 | } |
| 517 | 512 | |
| 518 | 513 | static void dsa_switch_destroy(struct dsa_switch *ds) |
| @@ -28,8 +28,10 @@ static struct dsa_switch_tree *dsa_get_dst(u32 tree) · 27 unmodified lines | ||
| 28 | 28 | struct dsa_switch_tree *dst; |
| 29 | 29 | |
| 30 | 30 | list_for_each_entry(dst, &dsa_switch_trees, list) |
| 31 | − if (dst->tree == tree) | |
| 31 | + if (dst->tree == tree) { | |
| 32 | + kref_get(&dst->refcount); | |
| 32 | 33 | return dst; |
| 34 | + } | |
| 33 | 35 | return NULL; |
| 34 | 36 | } |
| 35 | 37 | |
| @@ -1125,7 +1125,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, · 1124 unmodified lines | ||
| 1125 | 1125 | p->phy_interface = mode; |
| 1126 | 1126 | |
| 1127 | 1127 | phy_dn = of_parse_phandle(port_dn, "phy-handle", 0); |
| 1128 | − if (of_phy_is_fixed_link(port_dn)) { | |
| 1128 | + if (!phy_dn && of_phy_is_fixed_link(port_dn)) { | |
| 1129 | 1129 | /* In the case of a fixed PHY, the DT node associated |
| 1130 | 1130 | * to the fixed PHY is the Port DT node |
| 1131 | 1131 | */ |
| @@ -1135,7 +1135,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, · 3 unmodified lines | ||
| 1135 | 1135 | return ret; |
| 1136 | 1136 | } |
| 1137 | 1137 | phy_is_fixed = true; |
| 1138 | − phy_dn = port_dn; | |
| 1138 | + phy_dn = of_node_get(port_dn); | |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | if (ds->ops->get_phy_flags) |
| @@ -1154,6 +1154,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, · 12 unmodified lines | ||
| 1154 | 1154 | ret = dsa_slave_phy_connect(p, slave_dev, phy_id); |
| 1155 | 1155 | if (ret) { |
| 1156 | 1156 | netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret); |
| 1157 | + of_node_put(phy_dn); | |
| 1157 | 1158 | return ret; |
| 1158 | 1159 | } |
| 1159 | 1160 | } else { |
| @@ -1162,6 +1163,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, · 2 unmodified lines | ||
| 1162 | 1163 | phy_flags, |
| 1163 | 1164 | p->phy_interface); |
| 1164 | 1165 | } |
| 1166 | + | |
| 1167 | + of_node_put(phy_dn); | |
| 1165 | 1168 | } |
| 1166 | 1169 | |
| 1167 | 1170 | if (p->phy && phy_is_fixed) |
| @@ -1174,6 +1177,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, · 6 unmodified lines | ||
| 1174 | 1177 | ret = dsa_slave_phy_connect(p, slave_dev, p->port); |
| 1175 | 1178 | if (ret) { |
| 1176 | 1179 | netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret); |
| 1180 | + if (phy_is_fixed) | |
| 1181 | + of_phy_deregister_fixed_link(port_dn); | |
| 1177 | 1182 | return ret; |
| 1178 | 1183 | } |
| 1179 | 1184 | } |
| @@ -1289,10 +1294,18 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent, · 109 unmodified lines | ||
| 1289 | 1294 | void dsa_slave_destroy(struct net_device *slave_dev) |
| 1290 | 1295 | { |
| 1291 | 1296 | struct dsa_slave_priv *p = netdev_priv(slave_dev); |
| 1297 | + struct dsa_switch *ds = p->parent; | |
| 1298 | + struct device_node *port_dn; | |
| 1299 | + | |
| 1300 | + port_dn = ds->ports[p->port].dn; | |
| 1292 | 1301 | |
| 1293 | 1302 | netif_carrier_off(slave_dev); |
| 1294 | − if (p->phy) | |
| 1303 | + if (p->phy) { | |
| 1295 | 1304 | phy_disconnect(p->phy); |
| 1305 | + | |
| 1306 | + if (of_phy_is_fixed_link(port_dn)) | |
| 1307 | + of_phy_deregister_fixed_link(port_dn); | |
| 1308 | + } | |
| 1296 | 1309 | unregister_netdev(slave_dev); |
| 1297 | 1310 | free_netdev(slave_dev); |
| 1298 | 1311 | } |
| @@ -715,6 +715,7 @@ config DEFAULT_TCP_CONG · 714 unmodified lines | ||
| 715 | 715 | default "reno" if DEFAULT_RENO |
| 716 | 716 | default "dctcp" if DEFAULT_DCTCP |
| 717 | 717 | default "cdg" if DEFAULT_CDG |
| 718 | + default "bbr" if DEFAULT_BBR | |
| 718 | 719 | default "cubic" |
| 719 | 720 | |
| 720 | 721 | config TCP_MD5SIG |
| @@ -1233,7 +1233,7 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb, · 1232 unmodified lines | ||
| 1233 | 1233 | fixedid = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID); |
| 1234 | 1234 | |
| 1235 | 1235 | /* fixed ID is invalid if DF bit is not set */ |
| 1236 | − if (fixedid && !(iph->frag_off & htons(IP_DF))) | |
| 1236 | + if (fixedid && !(ip_hdr(skb)->frag_off & htons(IP_DF))) | |
| 1237 | 1237 | goto out; |
| 1238 | 1238 | } |
| 1239 | 1239 | |
| @@ -476,7 +476,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb) · 475 unmodified lines | ||
| 476 | 476 | esph = (void *)skb_push(skb, 4); |
| 477 | 477 | *seqhi = esph->spi; |
| 478 | 478 | esph->spi = esph->seq_no; |
| 479 | − esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.input.hi); | |
| 479 | + esph->seq_no = XFRM_SKB_CB(skb)->seq.input.hi; | |
| 480 | 480 | aead_request_set_callback(req, 0, esp_input_done_esn, skb); |
| 481 | 481 | } |
| 482 | 482 | |
| @@ -107,6 +107,8 @@ int __ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb) · 106 unmodified lines | ||
| 107 | 107 | if (unlikely(!skb)) |
| 108 | 108 | return 0; |
| 109 | 109 | |
| 110 | + skb->protocol = htons(ETH_P_IP); | |
| 111 | + | |
| 110 | 112 | return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT, |
| 111 | 113 | net, sk, skb, NULL, skb_dst(skb)->dev, |
| 112 | 114 | dst_output); |
| @@ -24,10 +24,11 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t · 23 unmodified lines | ||
| 24 | 24 | struct flowi4 fl4 = {}; |
| 25 | 25 | __be32 saddr = iph->saddr; |
| 26 | 26 | __u8 flags = skb->sk ? inet_sk_flowi_flags(skb->sk) : 0; |
| 27 | + struct net_device *dev = skb_dst(skb)->dev; | |
| 27 | 28 | unsigned int hh_len; |
| 28 | 29 | |
| 29 | 30 | if (addr_type == RTN_UNSPEC) |
| 30 | − addr_type = inet_addr_type(net, saddr); | |
| 31 | + addr_type = inet_addr_type_dev_table(net, dev, saddr); | |
| 31 | 32 | if (addr_type == RTN_LOCAL || addr_type == RTN_UNICAST) |
| 32 | 33 | flags |= FLOWI_FLAG_ANYSRC; |
| 33 | 34 | else |
| @@ -40,6 +41,8 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t · 6 unmodified lines | ||
| 40 | 41 | fl4.saddr = saddr; |
| 41 | 42 | fl4.flowi4_tos = RT_TOS(iph->tos); |
| 42 | 43 | fl4.flowi4_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0; |
| 44 | + if (!fl4.flowi4_oif) | |
| 45 | + fl4.flowi4_oif = l3mdev_master_ifindex(dev); | |
| 43 | 46 | fl4.flowi4_mark = skb->mark; |
| 44 | 47 | fl4.flowi4_flags = flags; |
| 45 | 48 | rt = ip_route_output_key(net, &fl4); |
| @@ -1201,8 +1201,8 @@ static int translate_compat_table(struct xt_table_info **pinfo, · 1200 unmodified lines | ||
| 1201 | 1201 | |
| 1202 | 1202 | newinfo->number = compatr->num_entries; |
| 1203 | 1203 | for (i = 0; i < NF_ARP_NUMHOOKS; i++) { |
| 1204 | − newinfo->hook_entry[i] = info->hook_entry[i]; | |
| 1205 | − newinfo->underflow[i] = info->underflow[i]; | |
| 1204 | + newinfo->hook_entry[i] = compatr->hook_entry[i]; | |
| 1205 | + newinfo->underflow[i] = compatr->underflow[i]; | |
| 1206 | 1206 | } |
| 1207 | 1207 | entry1 = newinfo->entries; |
| 1208 | 1208 | pos = entry1; |
| @@ -139,7 +139,8 @@ void ip6_datagram_release_cb(struct sock *sk) · 138 unmodified lines | ||
| 139 | 139 | } |
| 140 | 140 | EXPORT_SYMBOL_GPL(ip6_datagram_release_cb); |
| 141 | 141 | |
| 142 | −static int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |
| 142 | +int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, | |
| 143 | + int addr_len) | |
| 143 | 144 | { |
| 144 | 145 | struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; |
| 145 | 146 | struct inet_sock *inet = inet_sk(sk); |
| @@ -252,6 +253,7 @@ ipv4_connected: · 106 unmodified lines | ||
| 252 | 253 | out: |
| 253 | 254 | return err; |
| 254 | 255 | } |
| 256 | +EXPORT_SYMBOL_GPL(__ip6_datagram_connect); | |
| 255 | 257 | |
| 256 | 258 | int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) |
| 257 | 259 | { |
| @@ -418,7 +418,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb) · 417 unmodified lines | ||
| 418 | 418 | esph = (void *)skb_push(skb, 4); |
| 419 | 419 | *seqhi = esph->spi; |
| 420 | 420 | esph->spi = esph->seq_no; |
| 421 | − esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.input.hi); | |
| 421 | + esph->seq_no = XFRM_SKB_CB(skb)->seq.input.hi; | |
| 422 | 422 | aead_request_set_callback(req, 0, esp_input_done_esn, skb); |
| 423 | 423 | } |
| 424 | 424 | |
| @@ -447,8 +447,10 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, · 446 unmodified lines | ||
| 447 | 447 | |
| 448 | 448 | if (__ipv6_addr_needs_scope_id(addr_type)) |
| 449 | 449 | iif = skb->dev->ifindex; |
| 450 | − else | |
| 451 | − iif = l3mdev_master_ifindex(skb_dst(skb)->dev); | |
| 450 | + else { | |
| 451 | + dst = skb_dst(skb); | |
| 452 | + iif = l3mdev_master_ifindex(dst ? dst->dev : skb->dev); | |
| 453 | + } | |
| 452 | 454 | |
| 453 | 455 | /* |
| 454 | 456 | * Must not send error if the source does not uniquely |
| @@ -99,7 +99,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, · 98 unmodified lines | ||
| 99 | 99 | segs = ops->callbacks.gso_segment(skb, features); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | − if (IS_ERR(segs)) | |
| 102 | + if (IS_ERR_OR_NULL(segs)) | |
| 103 | 103 | goto out; |
| 104 | 104 | |
| 105 | 105 | gso_partial = !!(skb_shinfo(segs)->gso_type & SKB_GSO_PARTIAL); |
| @@ -1181,7 +1181,6 @@ route_lookup: · 1180 unmodified lines | ||
| 1181 | 1181 | if (err) |
| 1182 | 1182 | return err; |
| 1183 | 1183 | |
| 1184 | − skb->protocol = htons(ETH_P_IPV6); | |
| 1185 | 1184 | skb_push(skb, sizeof(struct ipv6hdr)); |
| 1186 | 1185 | skb_reset_network_header(skb); |
| 1187 | 1186 | ipv6h = ipv6_hdr(skb); |
| @@ -1138,6 +1138,33 @@ static struct xfrm6_protocol vti_ipcomp6_protocol __read_mostly = { · 1137 unmodified lines | ||
| 1138 | 1138 | .priority = 100, |
| 1139 | 1139 | }; |
| 1140 | 1140 | |
| 1141 | +static bool is_vti6_tunnel(const struct net_device *dev) | |
| 1142 | +{ | |
| 1143 | + return dev->netdev_ops == &vti6_netdev_ops; | |
| 1144 | +} | |
| 1145 | + | |
| 1146 | +static int vti6_device_event(struct notifier_block *unused, | |
| 1147 | + unsigned long event, void *ptr) | |
| 1148 | +{ | |
| 1149 | + struct net_device *dev = netdev_notifier_info_to_dev(ptr); | |
| 1150 | + struct ip6_tnl *t = netdev_priv(dev); | |
| 1151 | + | |
| 1152 | + if (!is_vti6_tunnel(dev)) | |
| 1153 | + return NOTIFY_DONE; | |
| 1154 | + | |
| 1155 | + switch (event) { | |
| 1156 | + case NETDEV_DOWN: | |
| 1157 | + if (!net_eq(t->net, dev_net(dev))) | |
| 1158 | + xfrm_garbage_collect(t->net); | |
| 1159 | + break; | |
| 1160 | + } | |
| 1161 | + return NOTIFY_DONE; | |
| 1162 | +} | |
| 1163 | + | |
| 1164 | +static struct notifier_block vti6_notifier_block __read_mostly = { | |
| 1165 | + .notifier_call = vti6_device_event, | |
| 1166 | +}; | |
| 1167 | + | |
| 1141 | 1168 | /** |
| 1142 | 1169 | * vti6_tunnel_init - register protocol and reserve needed resources |
| 1143 | 1170 | * |
| @@ -1148,6 +1175,8 @@ static int __init vti6_tunnel_init(void) · 4 unmodified lines | ||
| 1148 | 1175 | const char *msg; |
| 1149 | 1176 | int err; |
| 1150 | 1177 | |
| 1178 | + register_netdevice_notifier(&vti6_notifier_block); | |
| 1179 | + | |
| 1151 | 1180 | msg = "tunnel device"; |
| 1152 | 1181 | err = register_pernet_device(&vti6_net_ops); |
| 1153 | 1182 | if (err < 0) |
| @@ -1180,6 +1209,7 @@ xfrm_proto_ah_failed: · 26 unmodified lines | ||
| 1180 | 1209 | xfrm_proto_esp_failed: |
| 1181 | 1210 | unregister_pernet_device(&vti6_net_ops); |
| 1182 | 1211 | pernet_dev_failed: |
| 1212 | + unregister_netdevice_notifier(&vti6_notifier_block); | |
| 1183 | 1213 | pr_err("vti6 init: failed to register %s\n", msg); |
| 1184 | 1214 | return err; |
| 1185 | 1215 | } |
| @@ -1194,6 +1224,7 @@ static void __exit vti6_tunnel_cleanup(void) · 8 unmodified lines | ||
| 1194 | 1224 | xfrm6_protocol_deregister(&vti_ah6_protocol, IPPROTO_AH); |
| 1195 | 1225 | xfrm6_protocol_deregister(&vti_esp6_protocol, IPPROTO_ESP); |
| 1196 | 1226 | unregister_pernet_device(&vti6_net_ops); |
| 1227 | + unregister_netdevice_notifier(&vti6_notifier_block); | |
| 1197 | 1228 | } |
| 1198 | 1229 | |
| 1199 | 1230 | module_init(vti6_tunnel_init); |
| @@ -576,11 +576,11 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user) · 575 unmodified lines | ||
| 576 | 576 | /* Jumbo payload inhibits frag. header */ |
| 577 | 577 | if (ipv6_hdr(skb)->payload_len == 0) { |
| 578 | 578 | pr_debug("payload len = 0\n"); |
| 579 | − return -EINVAL; | |
| 579 | + return 0; | |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | if (find_prev_fhdr(skb, &prevhdr, &nhoff, &fhoff) < 0) |
| 583 | − return -EINVAL; | |
| 583 | + return 0; | |
| 584 | 584 | |
| 585 | 585 | if (!pskb_may_pull(skb, fhoff + sizeof(*fhdr))) |
| 586 | 586 | return -ENOMEM; |
| @@ -69,7 +69,7 @@ static unsigned int ipv6_defrag(void *priv, · 68 unmodified lines | ||
| 69 | 69 | if (err == -EINPROGRESS) |
| 70 | 70 | return NF_STOLEN; |
| 71 | 71 | |
| 72 | − return NF_ACCEPT; | |
| 72 | + return err == 0 ? NF_ACCEPT : NF_DROP; | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | static struct nf_hook_ops ipv6_defrag_ops[] = { |
| @@ -156,6 +156,7 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook) · 155 unmodified lines | ||
| 156 | 156 | fl6.daddr = oip6h->saddr; |
| 157 | 157 | fl6.fl6_sport = otcph->dest; |
| 158 | 158 | fl6.fl6_dport = otcph->source; |
| 159 | + fl6.flowi6_oif = l3mdev_master_ifindex(skb_dst(oldskb)->dev); | |
| 159 | 160 | security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6)); |
| 160 | 161 | dst = ip6_route_output(net, NULL, &fl6); |
| 161 | 162 | if (dst->error) { |
| @@ -155,6 +155,8 @@ int __ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb) · 154 unmodified lines | ||
| 155 | 155 | if (unlikely(!skb)) |
| 156 | 156 | return 0; |
| 157 | 157 | |
| 158 | + skb->protocol = htons(ETH_P_IPV6); | |
| 159 | + | |
| 158 | 160 | return nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT, |
| 159 | 161 | net, sk, skb, NULL, skb_dst(skb)->dev, |
| 160 | 162 | dst_output); |
| @@ -61,7 +61,8 @@ static struct sock *__l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif · 60 unmodified lines | ||
| 61 | 61 | if ((l2tp->conn_id == tunnel_id) && |
| 62 | 62 | net_eq(sock_net(sk), net) && |
| 63 | 63 | !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) && |
| 64 | − !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)) | |
| 64 | + (!sk->sk_bound_dev_if || !dif || | |
| 65 | + sk->sk_bound_dev_if == dif)) | |
| 65 | 66 | goto found; |
| 66 | 67 | } |
| 67 | 68 | |
| @@ -182,15 +183,17 @@ pass_up: · 114 unmodified lines | ||
| 182 | 183 | struct iphdr *iph = (struct iphdr *) skb_network_header(skb); |
| 183 | 184 | |
| 184 | 185 | read_lock_bh(&l2tp_ip_lock); |
| 185 | − sk = __l2tp_ip_bind_lookup(net, iph->daddr, 0, tunnel_id); | |
| 186 | + sk = __l2tp_ip_bind_lookup(net, iph->daddr, inet_iif(skb), | |
| 187 | + tunnel_id); | |
| 188 | + if (!sk) { | |
| 189 | + read_unlock_bh(&l2tp_ip_lock); | |
| 190 | + goto discard; | |
| 191 | + } | |
| 192 | + | |
| 193 | + sock_hold(sk); | |
| 186 | 194 | read_unlock_bh(&l2tp_ip_lock); |
| 187 | 195 | } |
| 188 | 196 | |
| 189 | − if (sk == NULL) | |
| 190 | − goto discard; | |
| 191 | − | |
| 192 | − sock_hold(sk); | |
| 193 | − | |
| 194 | 197 | if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) |
| 195 | 198 | goto discard_put; |
| 196 | 199 | |
| @@ -256,15 +259,9 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) · 59 unmodified lines | ||
| 256 | 259 | if (addr->l2tp_family != AF_INET) |
| 257 | 260 | return -EINVAL; |
| 258 | 261 | |
| 259 | − ret = -EADDRINUSE; | |
| 260 | − read_lock_bh(&l2tp_ip_lock); | |
| 261 | − if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr, | |
| 262 | − sk->sk_bound_dev_if, addr->l2tp_conn_id)) | |
| 263 | − goto out_in_use; | |
| 264 | − | |
| 265 | − read_unlock_bh(&l2tp_ip_lock); | |
| 266 | − | |
| 267 | 262 | lock_sock(sk); |
| 263 | + | |
| 264 | + ret = -EINVAL; | |
| 268 | 265 | if (!sock_flag(sk, SOCK_ZAPPED)) |
| 269 | 266 | goto out; |
| 270 | 267 | |
| @@ -281,25 +278,28 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) · 10 unmodified lines | ||
| 281 | 278 | inet->inet_rcv_saddr = inet->inet_saddr = addr->l2tp_addr.s_addr; |
| 282 | 279 | if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST) |
| 283 | 280 | inet->inet_saddr = 0; /* Use device */ |
| 284 | − sk_dst_reset(sk); | |
| 285 | 281 | |
| 282 | + write_lock_bh(&l2tp_ip_lock); | |
| 283 | + if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr, | |
| 284 | + sk->sk_bound_dev_if, addr->l2tp_conn_id)) { | |
| 285 | + write_unlock_bh(&l2tp_ip_lock); | |
| 286 | + ret = -EADDRINUSE; | |
| 287 | + goto out; | |
| 288 | + } | |
| 289 | + | |
| 290 | + sk_dst_reset(sk); | |
| 286 | 291 | l2tp_ip_sk(sk)->conn_id = addr->l2tp_conn_id; |
| 287 | 292 | |
| 288 | − write_lock_bh(&l2tp_ip_lock); | |
| 289 | 293 | sk_add_bind_node(sk, &l2tp_ip_bind_table); |
| 290 | 294 | sk_del_node_init(sk); |
| 291 | 295 | write_unlock_bh(&l2tp_ip_lock); |
| 296 | + | |
| 292 | 297 | ret = 0; |
| 293 | 298 | sock_reset_flag(sk, SOCK_ZAPPED); |
| 294 | 299 | |
| 295 | 300 | out: |
| 296 | 301 | release_sock(sk); |
| 297 | 302 | |
| 298 | − return ret; | |
| 299 | − | |
| 300 | −out_in_use: | |
| 301 | − read_unlock_bh(&l2tp_ip_lock); | |
| 302 | − | |
| 303 | 303 | return ret; |
| 304 | 304 | } |
| 305 | 305 | |
| @@ -308,21 +308,24 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len · 2 unmodified lines | ||
| 308 | 308 | struct sockaddr_l2tpip *lsa = (struct sockaddr_l2tpip *) uaddr; |
| 309 | 309 | int rc; |
| 310 | 310 | |
| 311 | − if (sock_flag(sk, SOCK_ZAPPED)) /* Must bind first - autobinding does not work */ | |
| 312 | − return -EINVAL; | |
| 313 | − | |
| 314 | 311 | if (addr_len < sizeof(*lsa)) |
| 315 | 312 | return -EINVAL; |
| 316 | 313 | |
| 317 | 314 | if (ipv4_is_multicast(lsa->l2tp_addr.s_addr)) |
| 318 | 315 | return -EINVAL; |
| 319 | 316 | |
| 320 | − rc = ip4_datagram_connect(sk, uaddr, addr_len); | |
| 321 | − if (rc < 0) | |
| 322 | − return rc; | |
| 323 | − | |
| 324 | 317 | lock_sock(sk); |
| 325 | 318 | |
| 319 | + /* Must bind first - autobinding does not work */ | |
| 320 | + if (sock_flag(sk, SOCK_ZAPPED)) { | |
| 321 | + rc = -EINVAL; | |
| 322 | + goto out_sk; | |
| 323 | + } | |
| 324 | + | |
| 325 | + rc = __ip4_datagram_connect(sk, uaddr, addr_len); | |
| 326 | + if (rc < 0) | |
| 327 | + goto out_sk; | |
| 328 | + | |
| 326 | 329 | l2tp_ip_sk(sk)->peer_conn_id = lsa->l2tp_conn_id; |
| 327 | 330 | |
| 328 | 331 | write_lock_bh(&l2tp_ip_lock); |
| @@ -330,7 +333,9 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len · 1 unmodified line | ||
| 330 | 333 | sk_add_bind_node(sk, &l2tp_ip_bind_table); |
| 331 | 334 | write_unlock_bh(&l2tp_ip_lock); |
| 332 | 335 | |
| 336 | +out_sk: | |
| 333 | 337 | release_sock(sk); |
| 338 | + | |
| 334 | 339 | return rc; |
| 335 | 340 | } |
| 336 | 341 | |
| @@ -72,8 +72,9 @@ static struct sock *__l2tp_ip6_bind_lookup(struct net *net, · 71 unmodified lines | ||
| 72 | 72 | |
| 73 | 73 | if ((l2tp->conn_id == tunnel_id) && |
| 74 | 74 | net_eq(sock_net(sk), net) && |
| 75 | − !(addr && ipv6_addr_equal(addr, laddr)) && | |
| 76 | − !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)) | |
| 75 | + (!addr || ipv6_addr_equal(addr, laddr)) && | |
| 76 | + (!sk->sk_bound_dev_if || !dif || | |
| 77 | + sk->sk_bound_dev_if == dif)) | |
| 77 | 78 | goto found; |
| 78 | 79 | } |
| 79 | 80 | |
| @@ -196,16 +197,17 @@ pass_up: · 116 unmodified lines | ||
| 196 | 197 | struct ipv6hdr *iph = ipv6_hdr(skb); |
| 197 | 198 | |
| 198 | 199 | read_lock_bh(&l2tp_ip6_lock); |
| 199 | − sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, | |
| 200 | − 0, tunnel_id); | |
| 200 | + sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, inet6_iif(skb), | |
| 201 | + tunnel_id); | |
| 202 | + if (!sk) { | |
| 203 | + read_unlock_bh(&l2tp_ip6_lock); | |
| 204 | + goto discard; | |
| 205 | + } | |
| 206 | + | |
| 207 | + sock_hold(sk); | |
| 201 | 208 | read_unlock_bh(&l2tp_ip6_lock); |
| 202 | 209 | } |
| 203 | 210 | |
| 204 | − if (sk == NULL) | |
| 205 | − goto discard; | |
| 206 | − | |
| 207 | − sock_hold(sk); | |
| 208 | − | |
| 209 | 211 | if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) |
| 210 | 212 | goto discard_put; |
| 211 | 213 | |
| @@ -266,6 +268,7 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) · 54 unmodified lines | ||
| 266 | 268 | struct sockaddr_l2tpip6 *addr = (struct sockaddr_l2tpip6 *) uaddr; |
| 267 | 269 | struct net *net = sock_net(sk); |
| 268 | 270 | __be32 v4addr = 0; |
| 271 | + int bound_dev_if; | |
| 269 | 272 | int addr_type; |
| 270 | 273 | int err; |
| 271 | 274 | |
| @@ -284,13 +287,6 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) · 12 unmodified lines | ||
| 284 | 287 | if (addr_type & IPV6_ADDR_MULTICAST) |
| 285 | 288 | return -EADDRNOTAVAIL; |
| 286 | 289 | |
| 287 | − err = -EADDRINUSE; | |
| 288 | − read_lock_bh(&l2tp_ip6_lock); | |
| 289 | − if (__l2tp_ip6_bind_lookup(net, &addr->l2tp_addr, | |
| 290 | − sk->sk_bound_dev_if, addr->l2tp_conn_id)) | |
| 291 | − goto out_in_use; | |
| 292 | − read_unlock_bh(&l2tp_ip6_lock); | |
| 293 | − | |
| 294 | 290 | lock_sock(sk); |
| 295 | 291 | |
| 296 | 292 | err = -EINVAL; |
| @@ -300,28 +296,25 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) · 3 unmodified lines | ||
| 300 | 296 | if (sk->sk_state != TCP_CLOSE) |
| 301 | 297 | goto out_unlock; |
| 302 | 298 | |
| 299 | + bound_dev_if = sk->sk_bound_dev_if; | |
| 300 | + | |
| 303 | 301 | /* Check if the address belongs to the host. */ |
| 304 | 302 | rcu_read_lock(); |
| 305 | 303 | if (addr_type != IPV6_ADDR_ANY) { |
| 306 | 304 | struct net_device *dev = NULL; |
| 307 | 305 | |
| 308 | 306 | if (addr_type & IPV6_ADDR_LINKLOCAL) { |
| 309 | − if (addr_len >= sizeof(struct sockaddr_in6) && | |
| 310 | − addr->l2tp_scope_id) { | |
| 311 | − /* Override any existing binding, if another | |
| 312 | − * one is supplied by user. | |
| 313 | − */ | |
| 314 | − sk->sk_bound_dev_if = addr->l2tp_scope_id; | |
| 315 | − } | |
| 307 | + if (addr->l2tp_scope_id) | |
| 308 | + bound_dev_if = addr->l2tp_scope_id; | |
| 316 | 309 | |
| 317 | 310 | /* Binding to link-local address requires an |
| 318 | − interface */ | |
| 319 | − if (!sk->sk_bound_dev_if) | |
| 311 | + * interface. | |
| 312 | + */ | |
| 313 | + if (!bound_dev_if) | |
| 320 | 314 | goto out_unlock_rcu; |
| 321 | 315 | |
| 322 | 316 | err = -ENODEV; |
| 323 | − dev = dev_get_by_index_rcu(sock_net(sk), | |
| 324 | − sk->sk_bound_dev_if); | |
| 317 | + dev = dev_get_by_index_rcu(sock_net(sk), bound_dev_if); | |
| 325 | 318 | if (!dev) |
| 326 | 319 | goto out_unlock_rcu; |
| 327 | 320 | } |
| @@ -336,13 +329,22 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) · 8 unmodified lines | ||
| 336 | 329 | } |
| 337 | 330 | rcu_read_unlock(); |
| 338 | 331 | |
| 339 | − inet->inet_rcv_saddr = inet->inet_saddr = v4addr; | |
| 332 | + write_lock_bh(&l2tp_ip6_lock); | |
| 333 | + if (__l2tp_ip6_bind_lookup(net, &addr->l2tp_addr, bound_dev_if, | |
| 334 | + addr->l2tp_conn_id)) { | |
| 335 | + write_unlock_bh(&l2tp_ip6_lock); | |
| 336 | + err = -EADDRINUSE; | |
| 337 | + goto out_unlock; | |
| 338 | + } | |
| 339 | + | |
| 340 | + inet->inet_saddr = v4addr; | |
| 341 | + inet->inet_rcv_saddr = v4addr; | |
| 342 | + sk->sk_bound_dev_if = bound_dev_if; | |
| 340 | 343 | sk->sk_v6_rcv_saddr = addr->l2tp_addr; |
| 341 | 344 | np->saddr = addr->l2tp_addr; |
| 342 | 345 | |
| 343 | 346 | l2tp_ip6_sk(sk)->conn_id = addr->l2tp_conn_id; |
| 344 | 347 | |
| 345 | − write_lock_bh(&l2tp_ip6_lock); | |
| 346 | 348 | sk_add_bind_node(sk, &l2tp_ip6_bind_table); |
| 347 | 349 | sk_del_node_init(sk); |
| 348 | 350 | write_unlock_bh(&l2tp_ip6_lock); |
| @@ -355,10 +357,7 @@ out_unlock_rcu: · 6 unmodified lines | ||
| 355 | 357 | rcu_read_unlock(); |
| 356 | 358 | out_unlock: |
| 357 | 359 | release_sock(sk); |
| 358 | − return err; | |
| 359 | 360 | |
| 360 | −out_in_use: | |
| 361 | − read_unlock_bh(&l2tp_ip6_lock); | |
| 362 | 361 | return err; |
| 363 | 362 | } |
| 364 | 363 | |
| @@ -371,9 +370,6 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr, · 6 unmodified lines | ||
| 371 | 370 | int addr_type; |
| 372 | 371 | int rc; |
| 373 | 372 | |
| 374 | − if (sock_flag(sk, SOCK_ZAPPED)) /* Must bind first - autobinding does not work */ | |
| 375 | − return -EINVAL; | |
| 376 | − | |
| 377 | 373 | if (addr_len < sizeof(*lsa)) |
| 378 | 374 | return -EINVAL; |
| 379 | 375 | |
| @@ -390,10 +386,18 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr, · 10 unmodified lines | ||
| 390 | 386 | return -EINVAL; |
| 391 | 387 | } |
| 392 | 388 | |
| 393 | − rc = ip6_datagram_connect(sk, uaddr, addr_len); | |
| 394 | − | |
| 395 | 389 | lock_sock(sk); |
| 396 | 390 | |
| 391 | + /* Must bind first - autobinding does not work */ | |
| 392 | + if (sock_flag(sk, SOCK_ZAPPED)) { | |
| 393 | + rc = -EINVAL; | |
| 394 | + goto out_sk; | |
| 395 | + } | |
| 396 | + | |
| 397 | + rc = __ip6_datagram_connect(sk, uaddr, addr_len); | |
| 398 | + if (rc < 0) | |
| 399 | + goto out_sk; | |
| 400 | + | |
| 397 | 401 | l2tp_ip6_sk(sk)->peer_conn_id = lsa->l2tp_conn_id; |
| 398 | 402 | |
| 399 | 403 | write_lock_bh(&l2tp_ip6_lock); |
| @@ -401,6 +405,7 @@ static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr, · 1 unmodified line | ||
| 401 | 405 | sk_add_bind_node(sk, &l2tp_ip6_bind_table); |
| 402 | 406 | write_unlock_bh(&l2tp_ip6_lock); |
| 403 | 407 | |
| 408 | +out_sk: | |
| 404 | 409 | release_sock(sk); |
| 405 | 410 | |
| 406 | 411 | return rc; |
| @@ -42,7 +42,7 @@ struct nf_nat_conn_key { · 41 unmodified lines | ||
| 42 | 42 | const struct nf_conntrack_zone *zone; |
| 43 | 43 | }; |
| 44 | 44 | |
| 45 | −static struct rhashtable nf_nat_bysource_table; | |
| 45 | +static struct rhltable nf_nat_bysource_table; | |
| 46 | 46 | |
| 47 | 47 | inline const struct nf_nat_l3proto * |
| 48 | 48 | __nf_nat_l3proto_find(u8 family) |
| @@ -193,9 +193,12 @@ static int nf_nat_bysource_cmp(struct rhashtable_compare_arg *arg, · 144 unmodified lines | ||
| 193 | 193 | const struct nf_nat_conn_key *key = arg->key; |
| 194 | 194 | const struct nf_conn *ct = obj; |
| 195 | 195 | |
| 196 | − return same_src(ct, key->tuple) && | |
| 197 | − net_eq(nf_ct_net(ct), key->net) && | |
| 198 | − nf_ct_zone_equal(ct, key->zone, IP_CT_DIR_ORIGINAL); | |
| 196 | + if (!same_src(ct, key->tuple) || | |
| 197 | + !net_eq(nf_ct_net(ct), key->net) || | |
| 198 | + !nf_ct_zone_equal(ct, key->zone, IP_CT_DIR_ORIGINAL)) | |
| 199 | + return 1; | |
| 200 | + | |
| 201 | + return 0; | |
| 199 | 202 | } |
| 200 | 203 | |
| 201 | 204 | static struct rhashtable_params nf_nat_bysource_params = { |
| @@ -204,7 +207,6 @@ static struct rhashtable_params nf_nat_bysource_params = { · 2 unmodified lines | ||
| 204 | 207 | .obj_cmpfn = nf_nat_bysource_cmp, |
| 205 | 208 | .nelem_hint = 256, |
| 206 | 209 | .min_size = 1024, |
| 207 | − .nulls_base = (1U << RHT_BASE_SHIFT), | |
| 208 | 210 | }; |
| 209 | 211 | |
| 210 | 212 | /* Only called for SRC manip */ |
| @@ -223,12 +225,15 @@ find_appropriate_src(struct net *net, · 12 unmodified lines | ||
| 223 | 225 | .tuple = tuple, |
| 224 | 226 | .zone = zone |
| 225 | 227 | }; |
| 228 | + struct rhlist_head *hl; | |
| 226 | 229 | |
| 227 | − ct = rhashtable_lookup_fast(&nf_nat_bysource_table, &key, | |
| 228 | − nf_nat_bysource_params); | |
| 229 | − if (!ct) | |
| 230 | + hl = rhltable_lookup(&nf_nat_bysource_table, &key, | |
| 231 | + nf_nat_bysource_params); | |
| 232 | + if (!hl) | |
| 230 | 233 | return 0; |
| 231 | 234 | |
| 235 | + ct = container_of(hl, typeof(*ct), nat_bysource); | |
| 236 | + | |
| 232 | 237 | nf_ct_invert_tuplepr(result, |
| 233 | 238 | &ct->tuplehash[IP_CT_DIR_REPLY].tuple); |
| 234 | 239 | result->dst = tuple->dst; |
| @@ -446,11 +451,17 @@ nf_nat_setup_info(struct nf_conn *ct, · 211 unmodified lines | ||
| 446 | 451 | } |
| 447 | 452 | |
| 448 | 453 | if (maniptype == NF_NAT_MANIP_SRC) { |
| 454 | + struct nf_nat_conn_key key = { | |
| 455 | + .net = nf_ct_net(ct), | |
| 456 | + .tuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, | |
| 457 | + .zone = nf_ct_zone(ct), | |
| 458 | + }; | |
| 449 | 459 | int err; |
| 450 | 460 | |
| 451 | − err = rhashtable_insert_fast(&nf_nat_bysource_table, | |
| 452 | − &ct->nat_bysource, | |
| 453 | − nf_nat_bysource_params); | |
| 461 | + err = rhltable_insert_key(&nf_nat_bysource_table, | |
| 462 | + &key, | |
| 463 | + &ct->nat_bysource, | |
| 464 | + nf_nat_bysource_params); | |
| 454 | 465 | if (err) |
| 455 | 466 | return NF_DROP; |
| 456 | 467 | } |
| @@ -567,8 +578,8 @@ static int nf_nat_proto_clean(struct nf_conn *ct, void *data) · 110 unmodified lines | ||
| 567 | 578 | * will delete entry from already-freed table. |
| 568 | 579 | */ |
| 569 | 580 | ct->status &= ~IPS_NAT_DONE_MASK; |
| 570 | − rhashtable_remove_fast(&nf_nat_bysource_table, &ct->nat_bysource, | |
| 571 | − nf_nat_bysource_params); | |
| 581 | + rhltable_remove(&nf_nat_bysource_table, &ct->nat_bysource, | |
| 582 | + nf_nat_bysource_params); | |
| 572 | 583 | |
| 573 | 584 | /* don't delete conntrack. Although that would make things a lot |
| 574 | 585 | * simpler, we'd end up flushing all conntracks on nat rmmod. |
| @@ -698,8 +709,8 @@ static void nf_nat_cleanup_conntrack(struct nf_conn *ct) · 123 unmodified lines | ||
| 698 | 709 | if (!nat) |
| 699 | 710 | return; |
| 700 | 711 | |
| 701 | − rhashtable_remove_fast(&nf_nat_bysource_table, &ct->nat_bysource, | |
| 702 | − nf_nat_bysource_params); | |
| 712 | + rhltable_remove(&nf_nat_bysource_table, &ct->nat_bysource, | |
| 713 | + nf_nat_bysource_params); | |
| 703 | 714 | } |
| 704 | 715 | |
| 705 | 716 | static struct nf_ct_ext_type nat_extend __read_mostly = { |
| @@ -834,13 +845,13 @@ static int __init nf_nat_init(void) · 128 unmodified lines | ||
| 834 | 845 | { |
| 835 | 846 | int ret; |
| 836 | 847 | |
| 837 | − ret = rhashtable_init(&nf_nat_bysource_table, &nf_nat_bysource_params); | |
| 848 | + ret = rhltable_init(&nf_nat_bysource_table, &nf_nat_bysource_params); | |
| 838 | 849 | if (ret) |
| 839 | 850 | return ret; |
| 840 | 851 | |
| 841 | 852 | ret = nf_ct_extend_register(&nat_extend); |
| 842 | 853 | if (ret < 0) { |
| 843 | − rhashtable_destroy(&nf_nat_bysource_table); | |
| 854 | + rhltable_destroy(&nf_nat_bysource_table); | |
| 844 | 855 | printk(KERN_ERR "nf_nat_core: Unable to register extension\n"); |
| 845 | 856 | return ret; |
| 846 | 857 | } |
| @@ -864,7 +875,7 @@ static int __init nf_nat_init(void) · 17 unmodified lines | ||
| 864 | 875 | return 0; |
| 865 | 876 | |
| 866 | 877 | cleanup_extend: |
| 867 | − rhashtable_destroy(&nf_nat_bysource_table); | |
| 878 | + rhltable_destroy(&nf_nat_bysource_table); | |
| 868 | 879 | nf_ct_extend_unregister(&nat_extend); |
| 869 | 880 | return ret; |
| 870 | 881 | } |
| @@ -883,7 +894,7 @@ static void __exit nf_nat_cleanup(void) · 12 unmodified lines | ||
| 883 | 894 | for (i = 0; i < NFPROTO_NUMPROTO; i++) |
| 884 | 895 | kfree(nf_nat_l4protos[i]); |
| 885 | 896 | |
| 886 | − rhashtable_destroy(&nf_nat_bysource_table); | |
| 897 | + rhltable_destroy(&nf_nat_bysource_table); | |
| 887 | 898 | } |
| 888 | 899 | |
| 889 | 900 | MODULE_LICENSE("GPL"); |
| @@ -2570,7 +2570,8 @@ static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx, · 2569 unmodified lines | ||
| 2570 | 2570 | } |
| 2571 | 2571 | |
| 2572 | 2572 | if (set->timeout && |
| 2573 | − nla_put_be64(skb, NFTA_SET_TIMEOUT, cpu_to_be64(set->timeout), | |
| 2573 | + nla_put_be64(skb, NFTA_SET_TIMEOUT, | |
| 2574 | + cpu_to_be64(jiffies_to_msecs(set->timeout)), | |
| 2574 | 2575 | NFTA_SET_PAD)) |
| 2575 | 2576 | goto nla_put_failure; |
| 2576 | 2577 | if (set->gc_int && |
| @@ -2859,7 +2860,8 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk, · 282 unmodified lines | ||
| 2859 | 2860 | if (nla[NFTA_SET_TIMEOUT] != NULL) { |
| 2860 | 2861 | if (!(flags & NFT_SET_TIMEOUT)) |
| 2861 | 2862 | return -EINVAL; |
| 2862 | − timeout = be64_to_cpu(nla_get_be64(nla[NFTA_SET_TIMEOUT])); | |
| 2863 | + timeout = msecs_to_jiffies(be64_to_cpu(nla_get_be64( | |
| 2864 | + nla[NFTA_SET_TIMEOUT]))); | |
| 2863 | 2865 | } |
| 2864 | 2866 | gc_int = 0; |
| 2865 | 2867 | if (nla[NFTA_SET_GC_INTERVAL] != NULL) { |
| @@ -3178,7 +3180,8 @@ static int nf_tables_fill_setelem(struct sk_buff *skb, · 312 unmodified lines | ||
| 3178 | 3180 | |
| 3179 | 3181 | if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT) && |
| 3180 | 3182 | nla_put_be64(skb, NFTA_SET_ELEM_TIMEOUT, |
| 3181 | − cpu_to_be64(*nft_set_ext_timeout(ext)), | |
| 3183 | + cpu_to_be64(jiffies_to_msecs( | |
| 3184 | + *nft_set_ext_timeout(ext))), | |
| 3182 | 3185 | NFTA_SET_ELEM_PAD)) |
| 3183 | 3186 | goto nla_put_failure; |
| 3184 | 3187 | |
| @@ -3447,7 +3450,7 @@ void *nft_set_elem_init(const struct nft_set *set, · 262 unmodified lines | ||
| 3447 | 3450 | memcpy(nft_set_ext_data(ext), data, set->dlen); |
| 3448 | 3451 | if (nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION)) |
| 3449 | 3452 | *nft_set_ext_expiration(ext) = |
| 3450 | − jiffies + msecs_to_jiffies(timeout); | |
| 3453 | + jiffies + timeout; | |
| 3451 | 3454 | if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT)) |
| 3452 | 3455 | *nft_set_ext_timeout(ext) = timeout; |
| 3453 | 3456 | |
| @@ -3535,7 +3538,8 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, · 81 unmodified lines | ||
| 3535 | 3538 | if (nla[NFTA_SET_ELEM_TIMEOUT] != NULL) { |
| 3536 | 3539 | if (!(set->flags & NFT_SET_TIMEOUT)) |
| 3537 | 3540 | return -EINVAL; |
| 3538 | − timeout = be64_to_cpu(nla_get_be64(nla[NFTA_SET_ELEM_TIMEOUT])); | |
| 3541 | + timeout = msecs_to_jiffies(be64_to_cpu(nla_get_be64( | |
| 3542 | + nla[NFTA_SET_ELEM_TIMEOUT]))); | |
| 3539 | 3543 | } else if (set->flags & NFT_SET_TIMEOUT) { |
| 3540 | 3544 | timeout = set->timeout; |
| 3541 | 3545 | } |
| @@ -53,6 +53,7 @@ static int nft_hash_init(const struct nft_ctx *ctx, · 52 unmodified lines | ||
| 53 | 53 | { |
| 54 | 54 | struct nft_hash *priv = nft_expr_priv(expr); |
| 55 | 55 | u32 len; |
| 56 | + int err; | |
| 56 | 57 | |
| 57 | 58 | if (!tb[NFTA_HASH_SREG] || |
| 58 | 59 | !tb[NFTA_HASH_DREG] || |
| @@ -67,8 +68,10 @@ static int nft_hash_init(const struct nft_ctx *ctx, · 8 unmodified lines | ||
| 67 | 68 | priv->sreg = nft_parse_register(tb[NFTA_HASH_SREG]); |
| 68 | 69 | priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]); |
| 69 | 70 | |
| 70 | − len = ntohl(nla_get_be32(tb[NFTA_HASH_LEN])); | |
| 71 | − if (len == 0 || len > U8_MAX) | |
| 71 | + err = nft_parse_u32_check(tb[NFTA_HASH_LEN], U8_MAX, &len); | |
| 72 | + if (err < 0) | |
| 73 | + return err; | |
| 74 | + if (len == 0) | |
| 72 | 75 | return -ERANGE; |
| 73 | 76 | |
| 74 | 77 | priv->len = len; |
| @@ -59,6 +59,12 @@ static int nft_range_init(const struct nft_ctx *ctx, const struct nft_expr *expr · 58 unmodified lines | ||
| 59 | 59 | int err; |
| 60 | 60 | u32 op; |
| 61 | 61 | |
| 62 | + if (!tb[NFTA_RANGE_SREG] || | |
| 63 | + !tb[NFTA_RANGE_OP] || | |
| 64 | + !tb[NFTA_RANGE_FROM_DATA] || | |
| 65 | + !tb[NFTA_RANGE_TO_DATA]) | |
| 66 | + return -EINVAL; | |
| 67 | + | |
| 62 | 68 | err = nft_data_init(NULL, &priv->data_from, sizeof(priv->data_from), |
| 63 | 69 | &desc_from, tb[NFTA_RANGE_FROM_DATA]); |
| 64 | 70 | if (err < 0) |
| @@ -322,14 +322,11 @@ static void netlink_skb_set_owner_r(struct sk_buff *skb, struct sock *sk) · 321 unmodified lines | ||
| 322 | 322 | sk_mem_charge(sk, skb->truesize); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | −static void netlink_sock_destruct(struct sock *sk) | |
| 325 | +static void __netlink_sock_destruct(struct sock *sk) | |
| 326 | 326 | { |
| 327 | 327 | struct netlink_sock *nlk = nlk_sk(sk); |
| 328 | 328 | |
| 329 | 329 | if (nlk->cb_running) { |
| 330 | − if (nlk->cb.done) | |
| 331 | − nlk->cb.done(&nlk->cb); | |
| 332 | − | |
| 333 | 330 | module_put(nlk->cb.module); |
| 334 | 331 | kfree_skb(nlk->cb.skb); |
| 335 | 332 | } |
| @@ -346,6 +343,28 @@ static void netlink_sock_destruct(struct sock *sk) · 10 unmodified lines | ||
| 346 | 343 | WARN_ON(nlk_sk(sk)->groups); |
| 347 | 344 | } |
| 348 | 345 | |
| 346 | +static void netlink_sock_destruct_work(struct work_struct *work) | |
| 347 | +{ | |
| 348 | + struct netlink_sock *nlk = container_of(work, struct netlink_sock, | |
| 349 | + work); | |
| 350 | + | |
| 351 | + nlk->cb.done(&nlk->cb); | |
| 352 | + __netlink_sock_destruct(&nlk->sk); | |
| 353 | +} | |
| 354 | + | |
| 355 | +static void netlink_sock_destruct(struct sock *sk) | |
| 356 | +{ | |
| 357 | + struct netlink_sock *nlk = nlk_sk(sk); | |
| 358 | + | |
| 359 | + if (nlk->cb_running && nlk->cb.done) { | |
| 360 | + INIT_WORK(&nlk->work, netlink_sock_destruct_work); | |
| 361 | + schedule_work(&nlk->work); | |
| 362 | + return; | |
| 363 | + } | |
| 364 | + | |
| 365 | + __netlink_sock_destruct(sk); | |
| 366 | +} | |
| 367 | + | |
| 349 | 368 | /* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on |
| 350 | 369 | * SMP. Look, when several writers sleep and reader wakes them up, all but one |
| 351 | 370 | * immediately hit write lock and grab all the cpus. Exclusive sleep solves |
| @@ -3,6 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | |
| 4 | 4 | #include <linux/rhashtable.h> |
| 5 | 5 | #include <linux/atomic.h> |
| 6 | +#include <linux/workqueue.h> | |
| 6 | 7 | #include <net/sock.h> |
| 7 | 8 | |
| 8 | 9 | #define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8) |
| @@ -33,6 +34,7 @@ struct netlink_sock { · 24 unmodified lines | ||
| 33 | 34 | |
| 34 | 35 | struct rhash_head node; |
| 35 | 36 | struct rcu_head rcu; |
| 37 | + struct work_struct work; | |
| 36 | 38 | }; |
| 37 | 39 | |
| 38 | 40 | static inline struct netlink_sock *nlk_sk(struct sock *sk) |
| @@ -370,8 +370,11 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key, · 369 unmodified lines | ||
| 370 | 370 | skb_orphan(skb); |
| 371 | 371 | memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm)); |
| 372 | 372 | err = nf_ct_frag6_gather(net, skb, user); |
| 373 | − if (err) | |
| 373 | + if (err) { | |
| 374 | + if (err != -EINPROGRESS) | |
| 375 | + kfree_skb(skb); | |
| 374 | 376 | return err; |
| 377 | + } | |
| 375 | 378 | |
| 376 | 379 | key->ip.proto = ipv6_hdr(skb)->nexthdr; |
| 377 | 380 | ovs_cb.mru = IP6CB(skb)->frag_max_size; |
| @@ -3648,19 +3648,25 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv · 3647 unmodified lines | ||
| 3648 | 3648 | |
| 3649 | 3649 | if (optlen != sizeof(val)) |
| 3650 | 3650 | return -EINVAL; |
| 3651 | − if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) | |
| 3652 | − return -EBUSY; | |
| 3653 | 3651 | if (copy_from_user(&val, optval, sizeof(val))) |
| 3654 | 3652 | return -EFAULT; |
| 3655 | 3653 | switch (val) { |
| 3656 | 3654 | case TPACKET_V1: |
| 3657 | 3655 | case TPACKET_V2: |
| 3658 | 3656 | case TPACKET_V3: |
| 3659 | − po->tp_version = val; | |
| 3660 | − return 0; | |
| 3657 | + break; | |
| 3661 | 3658 | default: |
| 3662 | 3659 | return -EINVAL; |
| 3663 | 3660 | } |
| 3661 | + lock_sock(sk); | |
| 3662 | + if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) { | |
| 3663 | + ret = -EBUSY; | |
| 3664 | + } else { | |
| 3665 | + po->tp_version = val; | |
| 3666 | + ret = 0; | |
| 3667 | + } | |
| 3668 | + release_sock(sk); | |
| 3669 | + return ret; | |
| 3664 | 3670 | } |
| 3665 | 3671 | case PACKET_RESERVE: |
| 3666 | 3672 | { |
| @@ -4164,6 +4170,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, · 497 unmodified lines | ||
| 4164 | 4170 | /* Added to avoid minimal code churn */ |
| 4165 | 4171 | struct tpacket_req *req = &req_u->req; |
| 4166 | 4172 | |
| 4173 | + lock_sock(sk); | |
| 4167 | 4174 | /* Opening a Tx-ring is NOT supported in TPACKET_V3 */ |
| 4168 | 4175 | if (!closing && tx_ring && (po->tp_version > TPACKET_V2)) { |
| 4169 | 4176 | net_warn_ratelimited("Tx-ring is not supported.\n"); |
| @@ -4245,7 +4252,6 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, · 75 unmodified lines | ||
| 4245 | 4252 | goto out; |
| 4246 | 4253 | } |
| 4247 | 4254 | |
| 4248 | − lock_sock(sk); | |
| 4249 | 4255 | |
| 4250 | 4256 | /* Detach socket from network */ |
| 4251 | 4257 | spin_lock(&po->bind_lock); |
| @@ -4294,11 +4300,11 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, · 42 unmodified lines | ||
| 4294 | 4300 | if (!tx_ring) |
| 4295 | 4301 | prb_shutdown_retire_blk_timer(po, rb_queue); |
| 4296 | 4302 | } |
| 4297 | − release_sock(sk); | |
| 4298 | 4303 | |
| 4299 | 4304 | if (pg_vec) |
| 4300 | 4305 | free_pg_vec(pg_vec, order, req->tp_block_nr); |
| 4301 | 4306 | out: |
| 4307 | + release_sock(sk); | |
| 4302 | 4308 | return err; |
| 4303 | 4309 | } |
| 4304 | 4310 | |
| @@ -659,6 +659,8 @@ out_recv: · 658 unmodified lines | ||
| 659 | 659 | out_pernet: |
| 660 | 660 | unregister_pernet_subsys(&rds_tcp_net_ops); |
| 661 | 661 | out_slab: |
| 662 | + if (unregister_netdevice_notifier(&rds_tcp_dev_notifier)) | |
| 663 | + pr_warn("could not unregister rds_tcp_dev_notifier\n"); | |
| 662 | 664 | kmem_cache_destroy(rds_tcp_conn_slab); |
| 663 | 665 | out: |
| 664 | 666 | return ret; |
| @@ -108,6 +108,17 @@ static void tcf_pedit_cleanup(struct tc_action *a, int bind) · 107 unmodified lines | ||
| 108 | 108 | kfree(keys); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | +static bool offset_valid(struct sk_buff *skb, int offset) | |
| 112 | +{ | |
| 113 | + if (offset > 0 && offset > skb->len) | |
| 114 | + return false; | |
| 115 | + | |
| 116 | + if (offset < 0 && -offset > skb_headroom(skb)) | |
| 117 | + return false; | |
| 118 | + | |
| 119 | + return true; | |
| 120 | +} | |
| 121 | + | |
| 111 | 122 | static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, |
| 112 | 123 | struct tcf_result *res) |
| 113 | 124 | { |
| @@ -134,6 +145,11 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, · 20 unmodified lines | ||
| 134 | 145 | if (tkey->offmask) { |
| 135 | 146 | char *d, _d; |
| 136 | 147 | |
| 148 | + if (!offset_valid(skb, off + tkey->at)) { | |
| 149 | + pr_info("tc filter pedit 'at' offset %d out of bounds\n", | |
| 150 | + off + tkey->at); | |
| 151 | + goto bad; | |
| 152 | + } | |
| 137 | 153 | d = skb_header_pointer(skb, off + tkey->at, 1, |
| 138 | 154 | &_d); |
| 139 | 155 | if (!d) |
| @@ -146,10 +162,10 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, · 6 unmodified lines | ||
| 146 | 162 | " offset must be on 32 bit boundaries\n"); |
| 147 | 163 | goto bad; |
| 148 | 164 | } |
| 149 | − if (offset > 0 && offset > skb->len) { | |
| 150 | − pr_info("tc filter pedit" | |
| 151 | − " offset %d can't exceed pkt length %d\n", | |
| 152 | − offset, skb->len); | |
| 165 | + | |
| 166 | + if (!offset_valid(skb, off + offset)) { | |
| 167 | + pr_info("tc filter pedit offset %d out of bounds\n", | |
| 168 | + offset); | |
| 153 | 169 | goto bad; |
| 154 | 170 | } |
| 155 | 171 | |
| @@ -62,9 +62,6 @@ static unsigned long basic_get(struct tcf_proto *tp, u32 handle) · 61 unmodified lines | ||
| 62 | 62 | struct basic_head *head = rtnl_dereference(tp->root); |
| 63 | 63 | struct basic_filter *f; |
| 64 | 64 | |
| 65 | − if (head == NULL) | |
| 66 | − return 0UL; | |
| 67 | − | |
| 68 | 65 | list_for_each_entry(f, &head->flist, link) { |
| 69 | 66 | if (f->handle == handle) { |
| 70 | 67 | l = (unsigned long) f; |
| @@ -109,7 +106,6 @@ static bool basic_destroy(struct tcf_proto *tp, bool force) · 38 unmodified lines | ||
| 109 | 106 | tcf_unbind_filter(tp, &f->res); |
| 110 | 107 | call_rcu(&f->rcu, basic_delete_filter); |
| 111 | 108 | } |
| 112 | − RCU_INIT_POINTER(tp->root, NULL); | |
| 113 | 109 | kfree_rcu(head, rcu); |
| 114 | 110 | return true; |
| 115 | 111 | } |
| @@ -292,7 +292,6 @@ static bool cls_bpf_destroy(struct tcf_proto *tp, bool force) · 291 unmodified lines | ||
| 292 | 292 | call_rcu(&prog->rcu, __cls_bpf_delete_prog); |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | − RCU_INIT_POINTER(tp->root, NULL); | |
| 296 | 295 | kfree_rcu(head, rcu); |
| 297 | 296 | return true; |
| 298 | 297 | } |
| @@ -303,9 +302,6 @@ static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle) · 4 unmodified lines | ||
| 303 | 302 | struct cls_bpf_prog *prog; |
| 304 | 303 | unsigned long ret = 0UL; |
| 305 | 304 | |
| 306 | − if (head == NULL) | |
| 307 | − return 0UL; | |
| 308 | − | |
| 309 | 305 | list_for_each_entry(prog, &head->plist, link) { |
| 310 | 306 | if (prog->handle == handle) { |
| 311 | 307 | ret = (unsigned long) prog; |
| @@ -137,11 +137,10 @@ static bool cls_cgroup_destroy(struct tcf_proto *tp, bool force) · 136 unmodified lines | ||
| 137 | 137 | |
| 138 | 138 | if (!force) |
| 139 | 139 | return false; |
| 140 | − | |
| 141 | − if (head) { | |
| 142 | − RCU_INIT_POINTER(tp->root, NULL); | |
| 140 | + /* Head can still be NULL due to cls_cgroup_init(). */ | |
| 141 | + if (head) | |
| 143 | 142 | call_rcu(&head->rcu, cls_cgroup_destroy_rcu); |
| 144 | − } | |
| 143 | + | |
| 145 | 144 | return true; |
| 146 | 145 | } |
| 147 | 146 | |
| @@ -596,7 +596,6 @@ static bool flow_destroy(struct tcf_proto *tp, bool force) · 595 unmodified lines | ||
| 596 | 596 | list_del_rcu(&f->list); |
| 597 | 597 | call_rcu(&f->rcu, flow_destroy_filter); |
| 598 | 598 | } |
| 599 | − RCU_INIT_POINTER(tp->root, NULL); | |
| 600 | 599 | kfree_rcu(head, rcu); |
| 601 | 600 | return true; |
| 602 | 601 | } |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | ||
| 13 | 13 | #include <linux/init.h> |
| 14 | 14 | #include <linux/module.h> |
| 15 | 15 | #include <linux/rhashtable.h> |
| 16 | +#include <linux/workqueue.h> | |
| 16 | 17 | |
| 17 | 18 | #include <linux/if_ether.h> |
| 18 | 19 | #include <linux/in6.h> |
| @@ -64,7 +65,10 @@ struct cls_fl_head { · 45 unmodified lines | ||
| 64 | 65 | bool mask_assigned; |
| 65 | 66 | struct list_head filters; |
| 66 | 67 | struct rhashtable_params ht_params; |
| 67 | − struct rcu_head rcu; | |
| 68 | + union { | |
| 69 | + struct work_struct work; | |
| 70 | + struct rcu_head rcu; | |
| 71 | + }; | |
| 68 | 72 | }; |
| 69 | 73 | |
| 70 | 74 | struct cls_fl_filter { |
| @@ -269,6 +273,24 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f) · 198 unmodified lines | ||
| 269 | 273 | dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc); |
| 270 | 274 | } |
| 271 | 275 | |
| 276 | +static void fl_destroy_sleepable(struct work_struct *work) | |
| 277 | +{ | |
| 278 | + struct cls_fl_head *head = container_of(work, struct cls_fl_head, | |
| 279 | + work); | |
| 280 | + if (head->mask_assigned) | |
| 281 | + rhashtable_destroy(&head->ht); | |
| 282 | + kfree(head); | |
| 283 | + module_put(THIS_MODULE); | |
| 284 | +} | |
| 285 | + | |
| 286 | +static void fl_destroy_rcu(struct rcu_head *rcu) | |
| 287 | +{ | |
| 288 | + struct cls_fl_head *head = container_of(rcu, struct cls_fl_head, rcu); | |
| 289 | + | |
| 290 | + INIT_WORK(&head->work, fl_destroy_sleepable); | |
| 291 | + schedule_work(&head->work); | |
| 292 | +} | |
| 293 | + | |
| 272 | 294 | static bool fl_destroy(struct tcf_proto *tp, bool force) |
| 273 | 295 | { |
| 274 | 296 | struct cls_fl_head *head = rtnl_dereference(tp->root); |
| @@ -282,10 +304,9 @@ static bool fl_destroy(struct tcf_proto *tp, bool force) · 7 unmodified lines | ||
| 282 | 304 | list_del_rcu(&f->list); |
| 283 | 305 | call_rcu(&f->rcu, fl_destroy_filter); |
| 284 | 306 | } |
| 285 | − RCU_INIT_POINTER(tp->root, NULL); | |
| 286 | − if (head->mask_assigned) | |
| 287 | − rhashtable_destroy(&head->ht); | |
| 288 | − kfree_rcu(head, rcu); | |
| 307 | + | |
| 308 | + __module_get(THIS_MODULE); | |
| 309 | + call_rcu(&head->rcu, fl_destroy_rcu); | |
| 289 | 310 | return true; |
| 290 | 311 | } |
| 291 | 312 | |
| @@ -711,8 +732,9 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, · 419 unmodified lines | ||
| 711 | 732 | goto errout; |
| 712 | 733 | |
| 713 | 734 | if (fold) { |
| 714 | − rhashtable_remove_fast(&head->ht, &fold->ht_node, | |
| 715 | − head->ht_params); | |
| 735 | + if (!tc_skip_sw(fold->flags)) | |
| 736 | + rhashtable_remove_fast(&head->ht, &fold->ht_node, | |
| 737 | + head->ht_params); | |
| 716 | 738 | fl_hw_destroy_filter(tp, (unsigned long)fold); |
| 717 | 739 | } |
| 718 | 740 | |
| @@ -739,8 +761,9 @@ static int fl_delete(struct tcf_proto *tp, unsigned long arg) · 20 unmodified lines | ||
| 739 | 761 | struct cls_fl_head *head = rtnl_dereference(tp->root); |
| 740 | 762 | struct cls_fl_filter *f = (struct cls_fl_filter *) arg; |
| 741 | 763 | |
| 742 | − rhashtable_remove_fast(&head->ht, &f->ht_node, | |
| 743 | − head->ht_params); | |
| 764 | + if (!tc_skip_sw(f->flags)) | |
| 765 | + rhashtable_remove_fast(&head->ht, &f->ht_node, | |
| 766 | + head->ht_params); | |
| 744 | 767 | list_del_rcu(&f->list); |
| 745 | 768 | fl_hw_destroy_filter(tp, (unsigned long)f); |
| 746 | 769 | tcf_unbind_filter(tp, &f->res); |
| @@ -114,7 +114,6 @@ static bool mall_destroy(struct tcf_proto *tp, bool force) · 113 unmodified lines | ||
| 114 | 114 | |
| 115 | 115 | call_rcu(&f->rcu, mall_destroy_filter); |
| 116 | 116 | } |
| 117 | − RCU_INIT_POINTER(tp->root, NULL); | |
| 118 | 117 | kfree_rcu(head, rcu); |
| 119 | 118 | return true; |
| 120 | 119 | } |
| @@ -152,7 +152,8 @@ static int rsvp_classify(struct sk_buff *skb, const struct tcf_proto *tp, · 151 unmodified lines | ||
| 152 | 152 | return -1; |
| 153 | 153 | nhptr = ip_hdr(skb); |
| 154 | 154 | #endif |
| 155 | − | |
| 155 | + if (unlikely(!head)) | |
| 156 | + return -1; | |
| 156 | 157 | restart: |
| 157 | 158 | |
| 158 | 159 | #if RSVP_DST_LEN == 4 |
| @@ -543,7 +543,6 @@ static bool tcindex_destroy(struct tcf_proto *tp, bool force) · 542 unmodified lines | ||
| 543 | 543 | walker.fn = tcindex_destroy_element; |
| 544 | 544 | tcindex_walk(tp, &walker); |
| 545 | 545 | |
| 546 | − RCU_INIT_POINTER(tp->root, NULL); | |
| 547 | 546 | call_rcu(&p->rcu, __tcindex_destroy); |
| 548 | 547 | return true; |
| 549 | 548 | } |
| @@ -421,6 +421,10 @@ int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b, · 420 unmodified lines | ||
| 421 | 421 | dev = dev_get_by_name(net, driver_name); |
| 422 | 422 | if (!dev) |
| 423 | 423 | return -ENODEV; |
| 424 | + if (tipc_mtu_bad(dev, 0)) { | |
| 425 | + dev_put(dev); | |
| 426 | + return -EINVAL; | |
| 427 | + } | |
| 424 | 428 | |
| 425 | 429 | /* Associate TIPC bearer with L2 bearer */ |
| 426 | 430 | rcu_assign_pointer(b->media_ptr, dev); |
| @@ -610,8 +614,6 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, · 183 unmodified lines | ||
| 610 | 614 | if (!b) |
| 611 | 615 | return NOTIFY_DONE; |
| 612 | 616 | |
| 613 | − b->mtu = dev->mtu; | |
| 614 | − | |
| 615 | 617 | switch (evt) { |
| 616 | 618 | case NETDEV_CHANGE: |
| 617 | 619 | if (netif_carrier_ok(dev)) |
| @@ -624,6 +626,11 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, · 6 unmodified lines | ||
| 624 | 626 | tipc_reset_bearer(net, b); |
| 625 | 627 | break; |
| 626 | 628 | case NETDEV_CHANGEMTU: |
| 629 | + if (tipc_mtu_bad(dev, 0)) { | |
| 630 | + bearer_disable(net, b); | |
| 631 | + break; | |
| 632 | + } | |
| 633 | + b->mtu = dev->mtu; | |
| 627 | 634 | tipc_reset_bearer(net, b); |
| 628 | 635 | break; |
| 629 | 636 | case NETDEV_CHANGEADDR: |
| @@ -39,6 +39,7 @@ · 38 unmodified lines | ||
| 39 | 39 | |
| 40 | 40 | #include "netlink.h" |
| 41 | 41 | #include "core.h" |
| 42 | +#include "msg.h" | |
| 42 | 43 | #include <net/genetlink.h> |
| 43 | 44 | |
| 44 | 45 | #define MAX_MEDIA 3 |
| @@ -59,6 +60,9 @@ · 14 unmodified lines | ||
| 59 | 60 | #define TIPC_MEDIA_TYPE_IB 2 |
| 60 | 61 | #define TIPC_MEDIA_TYPE_UDP 3 |
| 61 | 62 | |
| 63 | +/* minimum bearer MTU */ | |
| 64 | +#define TIPC_MIN_BEARER_MTU (MAX_H_SIZE + INT_H_SIZE) | |
| 65 | + | |
| 62 | 66 | /** |
| 63 | 67 | * struct tipc_media_addr - destination address used by TIPC bearers |
| 64 | 68 | * @value: address info (format defined by media) |
| @@ -215,4 +219,13 @@ void tipc_bearer_xmit(struct net *net, u32 bearer_id, · 150 unmodified lines | ||
| 215 | 219 | void tipc_bearer_bc_xmit(struct net *net, u32 bearer_id, |
| 216 | 220 | struct sk_buff_head *xmitq); |
| 217 | 221 | |
| 222 | +/* check if device MTU is too low for tipc headers */ | |
| 223 | +static inline bool tipc_mtu_bad(struct net_device *dev, unsigned int reserve) | |
| 224 | +{ | |
| 225 | + if (dev->mtu >= TIPC_MIN_BEARER_MTU + reserve) | |
| 226 | + return false; | |
| 227 | + netdev_warn(dev, "MTU too low for tipc bearer\n"); | |
| 228 | + return true; | |
| 229 | +} | |
| 230 | + | |
| 218 | 231 | #endif /* _TIPC_BEARER_H */ |
| @@ -47,8 +47,8 @@ · 46 unmodified lines | ||
| 47 | 47 | #include <linux/pkt_sched.h> |
| 48 | 48 | |
| 49 | 49 | struct tipc_stats { |
| 50 | − u32 sent_info; /* used in counting # sent packets */ | |
| 51 | − u32 recv_info; /* used in counting # recv'd packets */ | |
| 50 | + u32 sent_pkts; | |
| 51 | + u32 recv_pkts; | |
| 52 | 52 | u32 sent_states; |
| 53 | 53 | u32 recv_states; |
| 54 | 54 | u32 sent_probes; |
| @@ -857,7 +857,6 @@ void tipc_link_reset(struct tipc_link *l) · 802 unmodified lines | ||
| 857 | 857 | l->acked = 0; |
| 858 | 858 | l->silent_intv_cnt = 0; |
| 859 | 859 | l->rst_cnt = 0; |
| 860 | − l->stats.recv_info = 0; | |
| 861 | 860 | l->stale_count = 0; |
| 862 | 861 | l->bc_peer_is_up = false; |
| 863 | 862 | memset(&l->mon_state, 0, sizeof(l->mon_state)); |
| @@ -888,6 +887,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list, · 24 unmodified lines | ||
| 888 | 887 | struct sk_buff_head *transmq = &l->transmq; |
| 889 | 888 | struct sk_buff_head *backlogq = &l->backlogq; |
| 890 | 889 | struct sk_buff *skb, *_skb, *bskb; |
| 890 | + int pkt_cnt = skb_queue_len(list); | |
| 891 | 891 | |
| 892 | 892 | /* Match msg importance against this and all higher backlog limits: */ |
| 893 | 893 | if (!skb_queue_empty(backlogq)) { |
| @@ -901,6 +901,11 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list, · 7 unmodified lines | ||
| 901 | 901 | return -EMSGSIZE; |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | + if (pkt_cnt > 1) { | |
| 905 | + l->stats.sent_fragmented++; | |
| 906 | + l->stats.sent_fragments += pkt_cnt; | |
| 907 | + } | |
| 908 | + | |
| 904 | 909 | /* Prepare each packet for sending, and add to relevant queue: */ |
| 905 | 910 | while (skb_queue_len(list)) { |
| 906 | 911 | skb = skb_peek(list); |
| @@ -920,6 +925,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list, · 13 unmodified lines | ||
| 920 | 925 | __skb_queue_tail(xmitq, _skb); |
| 921 | 926 | TIPC_SKB_CB(skb)->ackers = l->ackers; |
| 922 | 927 | l->rcv_unacked = 0; |
| 928 | + l->stats.sent_pkts++; | |
| 923 | 929 | seqno++; |
| 924 | 930 | continue; |
| 925 | 931 | } |
| @@ -968,6 +974,7 @@ void tipc_link_advance_backlog(struct tipc_link *l, struct sk_buff_head *xmitq) · 42 unmodified lines | ||
| 968 | 974 | msg_set_ack(hdr, ack); |
| 969 | 975 | msg_set_bcast_ack(hdr, bc_ack); |
| 970 | 976 | l->rcv_unacked = 0; |
| 977 | + l->stats.sent_pkts++; | |
| 971 | 978 | seqno++; |
| 972 | 979 | } |
| 973 | 980 | l->snd_nxt = seqno; |
| @@ -1260,7 +1267,7 @@ int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb, · 286 unmodified lines | ||
| 1260 | 1267 | |
| 1261 | 1268 | /* Deliver packet */ |
| 1262 | 1269 | l->rcv_nxt++; |
| 1263 | − l->stats.recv_info++; | |
| 1270 | + l->stats.recv_pkts++; | |
| 1264 | 1271 | if (!tipc_data_input(l, skb, l->inputq)) |
| 1265 | 1272 | rc |= tipc_link_input(l, skb, l->inputq); |
| 1266 | 1273 | if (unlikely(++l->rcv_unacked >= TIPC_MIN_LINK_WIN)) |
| @@ -1800,10 +1807,6 @@ void tipc_link_set_queue_limits(struct tipc_link *l, u32 win) · 533 unmodified lines | ||
| 1800 | 1807 | void tipc_link_reset_stats(struct tipc_link *l) |
| 1801 | 1808 | { |
| 1802 | 1809 | memset(&l->stats, 0, sizeof(l->stats)); |
| 1803 | − if (!link_is_bc_sndlink(l)) { | |
| 1804 | − l->stats.sent_info = l->snd_nxt; | |
| 1805 | − l->stats.recv_info = l->rcv_nxt; | |
| 1806 | − } | |
| 1807 | 1810 | } |
| 1808 | 1811 | |
| 1809 | 1812 | static void link_print(struct tipc_link *l, const char *str) |
| @@ -1867,12 +1870,12 @@ static int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s) · 57 unmodified lines | ||
| 1867 | 1870 | }; |
| 1868 | 1871 | |
| 1869 | 1872 | struct nla_map map[] = { |
| 1870 | − {TIPC_NLA_STATS_RX_INFO, s->recv_info}, | |
| 1873 | + {TIPC_NLA_STATS_RX_INFO, 0}, | |
| 1871 | 1874 | {TIPC_NLA_STATS_RX_FRAGMENTS, s->recv_fragments}, |
| 1872 | 1875 | {TIPC_NLA_STATS_RX_FRAGMENTED, s->recv_fragmented}, |
| 1873 | 1876 | {TIPC_NLA_STATS_RX_BUNDLES, s->recv_bundles}, |
| 1874 | 1877 | {TIPC_NLA_STATS_RX_BUNDLED, s->recv_bundled}, |
| 1875 | − {TIPC_NLA_STATS_TX_INFO, s->sent_info}, | |
| 1878 | + {TIPC_NLA_STATS_TX_INFO, 0}, | |
| 1876 | 1879 | {TIPC_NLA_STATS_TX_FRAGMENTS, s->sent_fragments}, |
| 1877 | 1880 | {TIPC_NLA_STATS_TX_FRAGMENTED, s->sent_fragmented}, |
| 1878 | 1881 | {TIPC_NLA_STATS_TX_BUNDLES, s->sent_bundles}, |
| @@ -1947,9 +1950,9 @@ int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg, · 68 unmodified lines | ||
| 1947 | 1950 | goto attr_msg_full; |
| 1948 | 1951 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu)) |
| 1949 | 1952 | goto attr_msg_full; |
| 1950 | − if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->rcv_nxt)) | |
| 1953 | + if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->stats.recv_pkts)) | |
| 1951 | 1954 | goto attr_msg_full; |
| 1952 | − if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, link->snd_nxt)) | |
| 1955 | + if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, link->stats.sent_pkts)) | |
| 1953 | 1956 | goto attr_msg_full; |
| 1954 | 1957 | |
| 1955 | 1958 | if (tipc_link_is_up(link)) |
| @@ -2004,12 +2007,12 @@ static int __tipc_nl_add_bc_link_stat(struct sk_buff *skb, · 48 unmodified lines | ||
| 2004 | 2007 | }; |
| 2005 | 2008 | |
| 2006 | 2009 | struct nla_map map[] = { |
| 2007 | − {TIPC_NLA_STATS_RX_INFO, stats->recv_info}, | |
| 2010 | + {TIPC_NLA_STATS_RX_INFO, stats->recv_pkts}, | |
| 2008 | 2011 | {TIPC_NLA_STATS_RX_FRAGMENTS, stats->recv_fragments}, |
| 2009 | 2012 | {TIPC_NLA_STATS_RX_FRAGMENTED, stats->recv_fragmented}, |
| 2010 | 2013 | {TIPC_NLA_STATS_RX_BUNDLES, stats->recv_bundles}, |
| 2011 | 2014 | {TIPC_NLA_STATS_RX_BUNDLED, stats->recv_bundled}, |
| 2012 | − {TIPC_NLA_STATS_TX_INFO, stats->sent_info}, | |
| 2015 | + {TIPC_NLA_STATS_TX_INFO, stats->sent_pkts}, | |
| 2013 | 2016 | {TIPC_NLA_STATS_TX_FRAGMENTS, stats->sent_fragments}, |
| 2014 | 2017 | {TIPC_NLA_STATS_TX_FRAGMENTED, stats->sent_fragmented}, |
| 2015 | 2018 | {TIPC_NLA_STATS_TX_BUNDLES, stats->sent_bundles}, |
| @@ -2076,9 +2079,9 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg) · 60 unmodified lines | ||
| 2076 | 2079 | goto attr_msg_full; |
| 2077 | 2080 | if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name)) |
| 2078 | 2081 | goto attr_msg_full; |
| 2079 | − if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, bcl->rcv_nxt)) | |
| 2082 | + if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, 0)) | |
| 2080 | 2083 | goto attr_msg_full; |
| 2081 | − if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, bcl->snd_nxt)) | |
| 2084 | + if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, 0)) | |
| 2082 | 2085 | goto attr_msg_full; |
| 2083 | 2086 | |
| 2084 | 2087 | prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP); |
| @@ -697,6 +697,11 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, · 696 unmodified lines | ||
| 697 | 697 | udp_conf.local_ip.s_addr = htonl(INADDR_ANY); |
| 698 | 698 | udp_conf.use_udp_checksums = false; |
| 699 | 699 | ub->ifindex = dev->ifindex; |
| 700 | + if (tipc_mtu_bad(dev, sizeof(struct iphdr) + | |
| 701 | + sizeof(struct udphdr))) { | |
| 702 | + err = -EINVAL; | |
| 703 | + goto err; | |
| 704 | + } | |
| 700 | 705 | b->mtu = dev->mtu - sizeof(struct iphdr) |
| 701 | 706 | - sizeof(struct udphdr); |
| 702 | 707 | #if IS_ENABLED(CONFIG_IPV6) |
| @@ -1268,12 +1268,14 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir, · 1267 unmodified lines | ||
| 1268 | 1268 | err = security_xfrm_policy_lookup(pol->security, |
| 1269 | 1269 | fl->flowi_secid, |
| 1270 | 1270 | policy_to_flow_dir(dir)); |
| 1271 | − if (!err && !xfrm_pol_hold_rcu(pol)) | |
| 1272 | − goto again; | |
| 1273 | − else if (err == -ESRCH) | |
| 1271 | + if (!err) { | |
| 1272 | + if (!xfrm_pol_hold_rcu(pol)) | |
| 1273 | + goto again; | |
| 1274 | + } else if (err == -ESRCH) { | |
| 1274 | 1275 | pol = NULL; |
| 1275 | − else | |
| 1276 | + } else { | |
| 1276 | 1277 | pol = ERR_PTR(err); |
| 1278 | + } | |
| 1277 | 1279 | } else |
| 1278 | 1280 | pol = NULL; |
| 1279 | 1281 | } |
| @@ -2450,7 +2450,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · 2449 unmodified lines | ||
| 2450 | 2450 | |
| 2451 | 2451 | #ifdef CONFIG_COMPAT |
| 2452 | 2452 | if (in_compat_syscall()) |
| 2453 | − return -ENOTSUPP; | |
| 2453 | + return -EOPNOTSUPP; | |
| 2454 | 2454 | #endif |
| 2455 | 2455 | |
| 2456 | 2456 | type = nlh->nlmsg_type; |
| @@ -113,7 +113,7 @@ static int (*bpf_skb_under_cgroup)(void *ctx, void *map, int index) = · 112 unmodified lines | ||
| 113 | 113 | #define PT_REGS_FP(x) ((x)->gprs[11]) /* Works only with CONFIG_FRAME_POINTER */ |
| 114 | 114 | #define PT_REGS_RC(x) ((x)->gprs[2]) |
| 115 | 115 | #define PT_REGS_SP(x) ((x)->gprs[15]) |
| 116 | −#define PT_REGS_IP(x) ((x)->ip) | |
| 116 | +#define PT_REGS_IP(x) ((x)->psw.addr) | |
| 117 | 117 | |
| 118 | 118 | #elif defined(__aarch64__) |
| 119 | 119 | |
| @@ -25,7 +25,7 @@ int do_sample(struct bpf_perf_event_data *ctx) · 24 unmodified lines | ||
| 25 | 25 | u64 ip; |
| 26 | 26 | u32 *value, init_val = 1; |
| 27 | 27 | |
| 28 | − ip = ctx->regs.ip; | |
| 28 | + ip = PT_REGS_IP(&ctx->regs); | |
| 29 | 29 | value = bpf_map_lookup_elem(&ip_map, &ip); |
| 30 | 30 | if (value) |
| 31 | 31 | *value += 1; |
| @@ -50,7 +50,7 @@ int bpf_prog1(struct bpf_perf_event_data *ctx) · 49 unmodified lines | ||
| 50 | 50 | key.userstack = bpf_get_stackid(ctx, &stackmap, USER_STACKID_FLAGS); |
| 51 | 51 | if ((int)key.kernstack < 0 && (int)key.userstack < 0) { |
| 52 | 52 | bpf_trace_printk(fmt, sizeof(fmt), cpu, ctx->sample_period, |
| 53 | − ctx->regs.ip); | |
| 53 | + PT_REGS_IP(&ctx->regs)); | |
| 54 | 54 | return 0; |
| 55 | 55 | } |
| 56 | 56 | |
| @@ -35,6 +35,8 @@ nconfig: $(obj)/nconf · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | silentoldconfig: $(obj)/conf |
| 37 | 37 | $(Q)mkdir -p include/config include/generated |
| 38 | + $(Q)test -e include/generated/autoksyms.h || \ | |
| 39 | + touch include/generated/autoksyms.h | |
| 38 | 40 | $< $(silent) --$@ $(Kconfig) |
| 39 | 41 | |
| 40 | 42 | localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf |
| @@ -304,7 +304,7 @@ struct snd_dbri { · 303 unmodified lines | ||
| 304 | 304 | spinlock_t lock; |
| 305 | 305 | |
| 306 | 306 | struct dbri_dma *dma; /* Pointer to our DMA block */ |
| 307 | − u32 dma_dvma; /* DBRI visible DMA address */ | |
| 307 | + dma_addr_t dma_dvma; /* DBRI visible DMA address */ | |
| 308 | 308 | |
| 309 | 309 | void __iomem *regs; /* dbri HW regs */ |
| 310 | 310 | int dbri_irqp; /* intr queue pointer */ |
| @@ -657,12 +657,14 @@ static void dbri_cmdwait(struct snd_dbri *dbri) · 346 unmodified lines | ||
| 657 | 657 | */ |
| 658 | 658 | static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len) |
| 659 | 659 | { |
| 660 | + u32 dvma_addr = (u32)dbri->dma_dvma; | |
| 661 | + | |
| 660 | 662 | /* Space for 2 WAIT cmds (replaced later by 1 JUMP cmd) */ |
| 661 | 663 | len += 2; |
| 662 | 664 | spin_lock(&dbri->cmdlock); |
| 663 | 665 | if (dbri->cmdptr - dbri->dma->cmd + len < DBRI_NO_CMDS - 2) |
| 664 | 666 | return dbri->cmdptr + 2; |
| 665 | − else if (len < sbus_readl(dbri->regs + REG8) - dbri->dma_dvma) | |
| 667 | + else if (len < sbus_readl(dbri->regs + REG8) - dvma_addr) | |
| 666 | 668 | return dbri->dma->cmd; |
| 667 | 669 | else |
| 668 | 670 | printk(KERN_ERR "DBRI: no space for commands."); |
| @@ -680,6 +682,7 @@ static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len) · 11 unmodified lines | ||
| 680 | 682 | */ |
| 681 | 683 | static void dbri_cmdsend(struct snd_dbri *dbri, s32 *cmd, int len) |
| 682 | 684 | { |
| 685 | + u32 dvma_addr = (u32)dbri->dma_dvma; | |
| 683 | 686 | s32 tmp, addr; |
| 684 | 687 | static int wait_id = 0; |
| 685 | 688 | |
| @@ -689,7 +692,7 @@ static void dbri_cmdsend(struct snd_dbri *dbri, s32 *cmd, int len) · 3 unmodified lines | ||
| 689 | 692 | *(cmd+1) = DBRI_CMD(D_WAIT, 1, wait_id); |
| 690 | 693 | |
| 691 | 694 | /* Replace the last command with JUMP */ |
| 692 | − addr = dbri->dma_dvma + (cmd - len - dbri->dma->cmd) * sizeof(s32); | |
| 695 | + addr = dvma_addr + (cmd - len - dbri->dma->cmd) * sizeof(s32); | |
| 693 | 696 | *(dbri->cmdptr+1) = addr; |
| 694 | 697 | *(dbri->cmdptr) = DBRI_CMD(D_JUMP, 0, 0); |
| 695 | 698 | |
| @@ -747,6 +750,7 @@ static void dbri_reset(struct snd_dbri *dbri) · 51 unmodified lines | ||
| 747 | 750 | /* Lock must not be held before calling this */ |
| 748 | 751 | static void dbri_initialize(struct snd_dbri *dbri) |
| 749 | 752 | { |
| 753 | + u32 dvma_addr = (u32)dbri->dma_dvma; | |
| 750 | 754 | s32 *cmd; |
| 751 | 755 | u32 dma_addr; |
| 752 | 756 | unsigned long flags; |
| @@ -764,7 +768,7 @@ static void dbri_initialize(struct snd_dbri *dbri) · 11 unmodified lines | ||
| 764 | 768 | /* |
| 765 | 769 | * Initialize the interrupt ring buffer. |
| 766 | 770 | */ |
| 767 | − dma_addr = dbri->dma_dvma + dbri_dma_off(intr, 0); | |
| 771 | + dma_addr = dvma_addr + dbri_dma_off(intr, 0); | |
| 768 | 772 | dbri->dma->intr[0] = dma_addr; |
| 769 | 773 | dbri->dbri_irqp = 1; |
| 770 | 774 | /* |
| @@ -778,7 +782,7 @@ static void dbri_initialize(struct snd_dbri *dbri) · 7 unmodified lines | ||
| 778 | 782 | dbri->cmdptr = cmd; |
| 779 | 783 | *(cmd++) = DBRI_CMD(D_WAIT, 1, 0); |
| 780 | 784 | *(cmd++) = DBRI_CMD(D_WAIT, 1, 0); |
| 781 | − dma_addr = dbri->dma_dvma + dbri_dma_off(cmd, 0); | |
| 785 | + dma_addr = dvma_addr + dbri_dma_off(cmd, 0); | |
| 782 | 786 | sbus_writel(dma_addr, dbri->regs + REG8); |
| 783 | 787 | spin_unlock(&dbri->cmdlock); |
| 784 | 788 | |
| @@ -1077,6 +1081,7 @@ static void recv_fixed(struct snd_dbri *dbri, int pipe, volatile __u32 *ptr) · 292 unmodified lines | ||
| 1077 | 1081 | static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period) |
| 1078 | 1082 | { |
| 1079 | 1083 | struct dbri_streaminfo *info = &dbri->stream_info[streamno]; |
| 1084 | + u32 dvma_addr = (u32)dbri->dma_dvma; | |
| 1080 | 1085 | __u32 dvma_buffer; |
| 1081 | 1086 | int desc; |
| 1082 | 1087 | int len; |
| @@ -1177,7 +1182,7 @@ static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period) · 94 unmodified lines | ||
| 1177 | 1182 | else { |
| 1178 | 1183 | dbri->next_desc[last_desc] = desc; |
| 1179 | 1184 | dbri->dma->desc[last_desc].nda = |
| 1180 | − dbri->dma_dvma + dbri_dma_off(desc, desc); | |
| 1185 | + dvma_addr + dbri_dma_off(desc, desc); | |
| 1181 | 1186 | } |
| 1182 | 1187 | |
| 1183 | 1188 | last_desc = desc; |
| @@ -1192,7 +1197,7 @@ static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period) · 8 unmodified lines | ||
| 1192 | 1197 | } |
| 1193 | 1198 | |
| 1194 | 1199 | dbri->dma->desc[last_desc].nda = |
| 1195 | − dbri->dma_dvma + dbri_dma_off(desc, first_desc); | |
| 1200 | + dvma_addr + dbri_dma_off(desc, first_desc); | |
| 1196 | 1201 | dbri->next_desc[last_desc] = first_desc; |
| 1197 | 1202 | dbri->pipes[info->pipe].first_desc = first_desc; |
| 1198 | 1203 | dbri->pipes[info->pipe].desc = first_desc; |
| @@ -1697,6 +1702,7 @@ interrupts are disabled. · 498 unmodified lines | ||
| 1697 | 1702 | static void xmit_descs(struct snd_dbri *dbri) |
| 1698 | 1703 | { |
| 1699 | 1704 | struct dbri_streaminfo *info; |
| 1705 | + u32 dvma_addr = (u32)dbri->dma_dvma; | |
| 1700 | 1706 | s32 *cmd; |
| 1701 | 1707 | unsigned long flags; |
| 1702 | 1708 | int first_td; |
| @@ -1718,7 +1724,7 @@ static void xmit_descs(struct snd_dbri *dbri) · 15 unmodified lines | ||
| 1718 | 1724 | *(cmd++) = DBRI_CMD(D_SDP, 0, |
| 1719 | 1725 | dbri->pipes[info->pipe].sdp |
| 1720 | 1726 | | D_SDP_P | D_SDP_EVERY | D_SDP_C); |
| 1721 | − *(cmd++) = dbri->dma_dvma + | |
| 1727 | + *(cmd++) = dvma_addr + | |
| 1722 | 1728 | dbri_dma_off(desc, first_td); |
| 1723 | 1729 | dbri_cmdsend(dbri, cmd, 2); |
| 1724 | 1730 | |
| @@ -1740,7 +1746,7 @@ static void xmit_descs(struct snd_dbri *dbri) · 15 unmodified lines | ||
| 1740 | 1746 | *(cmd++) = DBRI_CMD(D_SDP, 0, |
| 1741 | 1747 | dbri->pipes[info->pipe].sdp |
| 1742 | 1748 | | D_SDP_P | D_SDP_EVERY | D_SDP_C); |
| 1743 | − *(cmd++) = dbri->dma_dvma + | |
| 1749 | + *(cmd++) = dvma_addr + | |
| 1744 | 1750 | dbri_dma_off(desc, first_td); |
| 1745 | 1751 | dbri_cmdsend(dbri, cmd, 2); |
| 1746 | 1752 | |
| @@ -2539,7 +2545,7 @@ static int snd_dbri_create(struct snd_card *card, · 792 unmodified lines | ||
| 2539 | 2545 | if (!dbri->dma) |
| 2540 | 2546 | return -ENOMEM; |
| 2541 | 2547 | |
| 2542 | − dprintk(D_GEN, "DMA Cmd Block 0x%p (0x%08x)\n", | |
| 2548 | + dprintk(D_GEN, "DMA Cmd Block 0x%p (%pad)\n", | |
| 2543 | 2549 | dbri->dma, dbri->dma_dvma); |
| 2544 | 2550 | |
| 2545 | 2551 | /* Map the registers into memory. */ |
| @@ -50,8 +50,10 @@ void vgic_v2_process_maintenance(struct kvm_vcpu *vcpu) · 49 unmodified lines | ||
| 50 | 50 | |
| 51 | 51 | WARN_ON(cpuif->vgic_lr[lr] & GICH_LR_STATE); |
| 52 | 52 | |
| 53 | − kvm_notify_acked_irq(vcpu->kvm, 0, | |
| 54 | − intid - VGIC_NR_PRIVATE_IRQS); | |
| 53 | + /* Only SPIs require notification */ | |
| 54 | + if (vgic_valid_spi(vcpu->kvm, intid)) | |
| 55 | + kvm_notify_acked_irq(vcpu->kvm, 0, | |
| 56 | + intid - VGIC_NR_PRIVATE_IRQS); | |
| 55 | 57 | } |
| 56 | 58 | } |
| 57 | 59 | |
| @@ -41,8 +41,10 @@ void vgic_v3_process_maintenance(struct kvm_vcpu *vcpu) · 40 unmodified lines | ||
| 41 | 41 | |
| 42 | 42 | WARN_ON(cpuif->vgic_lr[lr] & ICH_LR_STATE); |
| 43 | 43 | |
| 44 | − kvm_notify_acked_irq(vcpu->kvm, 0, | |
| 45 | − intid - VGIC_NR_PRIVATE_IRQS); | |
| 44 | + /* Only SPIs require notification */ | |
| 45 | + if (vgic_valid_spi(vcpu->kvm, intid)) | |
| 46 | + kvm_notify_acked_irq(vcpu->kvm, 0, | |
| 47 | + intid - VGIC_NR_PRIVATE_IRQS); | |
| 46 | 48 | } |
| 47 | 49 | |
| 48 | 50 | /* |
| @@ -2889,10 +2889,10 @@ static int kvm_ioctl_create_device(struct kvm *kvm, · 2888 unmodified lines | ||
| 2889 | 2889 | |
| 2890 | 2890 | ret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC); |
| 2891 | 2891 | if (ret < 0) { |
| 2892 | − ops->destroy(dev); | |
| 2893 | 2892 | mutex_lock(&kvm->lock); |
| 2894 | 2893 | list_del(&dev->vm_node); |
| 2895 | 2894 | mutex_unlock(&kvm->lock); |
| 2895 | + ops->destroy(dev); | |
| 2896 | 2896 | return ret; |
| 2897 | 2897 | } |
| 2898 | 2898 | |